From 73f00336178a9f312bac2992649120d462e0ac2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Wed, 11 Dec 2019 01:41:26 +0100 Subject: kopete: Restore the MSN protocol because a replacement MSN server was created. This reverts commits 0486034738 - 2d5f9c55da and f6fd4ab6c0. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko --- kopete/plugins/nowlistening/nowlisteningplugin.cpp | 108 +++++++++++++++------ 1 file changed, 78 insertions(+), 30 deletions(-) (limited to 'kopete/plugins/nowlistening/nowlisteningplugin.cpp') 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 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); } -- cgit v1.2.1