/* nljuk.cpp Kopete Now Listening To plugin Copyright (c) 2002,2003,2004 by Will Stephenson Copyright (c) 2003 by Ismail Donmez Copyright (c) 2002,2003 by the Kopete developers Purpose: This class abstracts the interface to JuK by implementing NLMediaPlayer ************************************************************************* * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ************************************************************************* */ #include #include #include "nlmediaplayer.h" #include "nljuk.h" NLJuk::NLJuk( DCOPClient *client ) : NLMediaPlayer() { m_client = client; m_type = Audio; m_name = "JuK"; } void NLJuk::update() { m_playing = false; TQString newTrack; // see if JuK is registered with DCOP if ( m_client->isApplicationRegistered( "juk" ) ) { // see if it's playing TQByteArray data, replyData; TQCString replyType; TQString result; if ( m_client->call( "juk", "Player", "playing()", data, replyType, replyData ) ) { TQDataStream reply( replyData, IO_ReadOnly ); if ( replyType == "bool" ) { reply >> m_playing; } } { TQDataStream arg( data, IO_WriteOnly ); arg << TQString::fromLatin1("Album"); if ( m_client->call( "juk", "Player", "trackProperty(TQString)", data, replyType, replyData ) ) { TQDataStream reply( replyData, IO_ReadOnly ); if ( replyType == "TQString" ) { reply >> m_album; } } } { TQDataStream arg( data, IO_WriteOnly ); arg << TQString::fromLatin1("Artist"); if ( m_client->call( "juk", "Player", "trackProperty(TQString)", data, replyType, replyData ) ) { TQDataStream reply( replyData, IO_ReadOnly ); if ( replyType == "TQString" ) { reply >> m_artist; } } } { TQDataStream arg( data, IO_WriteOnly ); arg << TQString::fromLatin1("Title"); if ( m_client->call( "juk", "Player", "trackProperty(TQString)", data, replyType, replyData ) ) { TQDataStream reply( replyData, IO_ReadOnly ); if ( replyType == "TQString" ) { reply >> newTrack; } } } if ( newTrack != m_track ) { m_newTrack = true; m_track = newTrack; } else m_newTrack = false; } else kdDebug( 14307 ) << "Juk is not running!\n" << endl; }