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

bool NowListeningClient::queryKsCD (  )  [slot]

Query KsCD for track information.

Definition at line 322 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 dbusKsCD( "org.kde.kscd", "/CDPlayer", "org.kde.KSCD" );

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

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

  // Call KsCD to know whether it's playing, and what
  const QDBusReply<QString>& album ( dbusKsCD.call( QDBus::BlockWithGui, "currentAlbum"      ) );
  const QDBusReply<QString>& track ( dbusKsCD.call( QDBus::BlockWithGui, "currentTrackTitle" ) );
  const QDBusReply<QString>& artist( dbusKsCD.call( QDBus::BlockWithGui, "currentArtist"     ) );
  const QDBusReply<bool>& isPlaying( dbusKsCD.call( QDBus::BlockWithGui, "playing"           ) );

  if( ! isPlaying.isValid() || ! album.isValid() || ! track.isValid() || ! artist.isValid() )
  {
#ifdef KMESSDEBUG_NOWLISTENINGCLIENT_GENERAL
    kDebug() << "Invalid response from KsCD!";
#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