summaryrefslogtreecommitdiffstats
path: root/kopete/plugins/nowlistening/nowlisteningplugin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kopete/plugins/nowlistening/nowlisteningplugin.cpp')
-rw-r--r--kopete/plugins/nowlistening/nowlisteningplugin.cpp108
1 files changed, 78 insertions, 30 deletions
diff --git a/kopete/plugins/nowlistening/nowlisteningplugin.cpp b/kopete/plugins/nowlistening/nowlisteningplugin.cpp
index 31284446..6fcc21cd 100644
--- a/kopete/plugins/nowlistening/nowlisteningplugin.cpp
+++ b/kopete/plugins/nowlistening/nowlisteningplugin.cpp
@@ -258,36 +258,84 @@ void NowListeningPlugin::slotAdvertCurrentMusic()
TQPtrList<Kopete::Account> accountsList = Kopete::AccountManager::self()->accounts();
for( Kopete::Account* a = accountsList.first(); a; a = accountsList.next() )
{
- if( NowListeningConfig::self()->appendStatusAdvertising() )
- {
- // Check for the now listening message in parenthesis,
- // include the header to not override other messages in parenthesis.
- TQRegExp statusSong( TQString(" \\(%1.*\\)$").arg( NowListeningConfig::header()) );
-
- // HACK: Don't keep appending the now listened song. Replace it in the status message.
- advert = a->myself()->property( Kopete::Global::Properties::self()->awayMessage() ).value().toString();
- // Remove the braces when they are no listened song.
- TQString mediaAdvert = mediaPlayerAdvert(false);
- if(!mediaAdvert.isEmpty())
- {
- if(statusSong.search(advert) != -1)
- {
- advert = advert.replace(statusSong, TQString(" (%1)").arg(mediaPlayerAdvert(false)) );
- }
- else
- {
- advert += TQString(" (%1)").arg( mediaPlayerAdvert(false) );
- }
- }
- else
- {
- advert = advert.replace(statusSong, "");
- }
- }
- else
- {
- advert = mediaPlayerAdvert(false); // newTrackPlaying has done the update.
- }
+ /*
+ NOTE:
+ MSN status message(personal message) use a special tag to advert the current music playing.
+ So, we don't send the all formatted string, send a special string seperated by ";".
+
+ Also, do not use MSN hack in appending mode.
+ */
+ if( a->protocol()->pluginId() == "MSNProtocol" && !NowListeningConfig::self()->appendStatusAdvertising() )
+ {
+ TQString track, artist, album, mediaList;
+ bool isPlaying=false;
+
+ if( NowListeningConfig::self()->useSpecifiedMediaPlayer() && d->m_currentMediaPlayer )
+ {
+ if( d->m_currentMediaPlayer->playing() )
+ {
+ track = d->m_currentMediaPlayer->track();
+ artist = d->m_currentMediaPlayer->artist();
+ album = d->m_currentMediaPlayer->album();
+ mediaList = track + ";" + artist + ";" + album;
+ isPlaying = true;
+ }
+ }
+ else
+ {
+ for ( NLMediaPlayer* i = d->m_mediaPlayerList.first(); i; i = d->m_mediaPlayerList.next() )
+ {
+ if( i->playing() )
+ {
+ track = i->track();
+ artist = i->artist();
+ album = i->album();
+ mediaList = track + ";" + artist + ";" + album;
+ isPlaying = true;
+ }
+ }
+ }
+
+ // KDE4 TODO: Use the new status message framework, and remove this "hack".
+ if( isPlaying )
+ {
+ advert = TQString("[Music]%1").arg(mediaList);
+ }
+
+ }
+ else
+ {
+ if( NowListeningConfig::self()->appendStatusAdvertising() )
+ {
+ // Check for the now listening message in parenthesis,
+ // include the header to not override other messages in parenthesis.
+ TQRegExp statusSong( TQString(" \\(%1.*\\)$").arg( NowListeningConfig::header()) );
+
+ // HACK: Don't keep appending the now listened song. Replace it in the status message.
+ advert = a->myself()->property( Kopete::Global::Properties::self()->awayMessage() ).value().toString();
+ // Remove the braces when they are no listened song.
+ TQString mediaAdvert = mediaPlayerAdvert(false);
+ if(!mediaAdvert.isEmpty())
+ {
+ if(statusSong.search(advert) != -1)
+ {
+ advert = advert.replace(statusSong, TQString(" (%1)").arg(mediaPlayerAdvert(false)) );
+ }
+ else
+ {
+ advert += TQString(" (%1)").arg( mediaPlayerAdvert(false) );
+ }
+ }
+ else
+ {
+ advert = advert.replace(statusSong, "");
+ }
+ }
+ else
+ {
+ advert = mediaPlayerAdvert(false); // newTrackPlaying has done the update.
+ }
+ }
a->setOnlineStatus(a->myself()->onlineStatus(), advert);
}