Logo Search packages:      
Sourcecode: kmess version File versions  Download package

bool NowListeningClient::queryJuk (  )  [slot]

Query Juk for track information.

Definition at line 371 of file nowlisteningclient.cpp.

Referenced by slotUpdate().

{
  mutex_.lock();

  // Start the d-bus interface, needed to check the application status and make calls to it
  QDBusInterface dbusJuk( "org.kde.juk", "/Player", "org.kde.juk.player" );

  // See if the application is registered.
  if( ! dbusJuk.isValid() )
  {
    mutex_.unlock();
    return false;
  }

#ifdef KMESSDEBUG_NOWLISTENINGCLIENT_GENERAL
  kDebug() << "querying Juk for now listening information...";
#endif

  // Call KsCD to know whether it's playing, and what
  const QDBusReply<QString>& album ( dbusJuk.call( QDBus::BlockWithGui, "trackProperty", "Album"  ) );
  const QDBusReply<QString>& track ( dbusJuk.call( QDBus::BlockWithGui, "trackProperty", "Title"  ) );
  const QDBusReply<QString>& artist( dbusJuk.call( QDBus::BlockWithGui, "trackProperty", "Artist" ) );
  const QDBusReply<bool>& isPlaying( dbusJuk.call( QDBus::BlockWithGui, "playing"                 ) );

  if( ! isPlaying.isValid() || ! album.isValid() || ! track.isValid() || ! artist.isValid() )
  {
#ifdef KMESSDEBUG_NOWLISTENINGCLIENT_GENERAL
    kDebug() << "Invalid response from Juk!";
#endif

    mutex_.unlock();
    return false;
  }

  // Save the returned values
  album_   = album;
  track_   = track;
  artist_  = artist;
  playing_ = isPlaying;

  mutex_.unlock();
  return true;
}


Generated by  Doxygen 1.6.0   Back to index