Hi,
the attached patches should:
1) make nowlistening work fine with amarok2 (I've used kvirc mpris code
as reference)
2) make nowlistening not add metadata when we configure it to to
append/set the current song to the personal message.
3) make wlm set the "listening to" field in the msn protocol using the
metadata provided by nowlistening plugin.
please, nowlistening and kopete hackers, can I commit the patches?
Index: kopete/plugins/nowlistening/nlamarok.cpp
===================================================================
--- kopete/plugins/nowlistening/nlamarok.cpp (revision 898019)
+++ kopete/plugins/nowlistening/nlamarok.cpp (working copy)
@@ -29,11 +29,38 @@
#include "nlmediaplayer.h"
#include "nlamarok.h"
+// from kvirc mpris interface
+struct MPRISPlayerStatus
+{
+ int Play;
+ int Random;
+ int RepeatCurrent;
+ int RepeatPlaylist;
+};
+Q_DECLARE_METATYPE( MPRISPlayerStatus )
+
+QDBusArgument &operator<<(QDBusArgument &argument, const MPRISPlayerStatus
&status)
+{
+ argument.beginStructure();
+ argument << status.Play << status.Random << status.RepeatCurrent <<
status.RepeatPlaylist;
+ argument.endStructure();
+ return argument;
+};
+
+const QDBusArgument &operator>>(const QDBusArgument &argument,
MPRISPlayerStatus &status)
+{
+ argument.beginStructure();
+ argument >> status.Play >> status.Random >> status.RepeatCurrent >>
status.RepeatPlaylist;
+ argument.endStructure();
+ return argument;
+};
+
NLamaroK::NLamaroK() : NLMediaPlayer()
{
m_type = Audio;
m_name = "amaroK";
- m_client = new QDBusInterface("org.mpris.amarok", "/Player");
+ m_client = new QDBusInterface("org.mpris.amarok", "/Player",
"org.freedesktop.MediaPlayer");
+ qDBusRegisterMetaType<MPRISPlayerStatus>();
}
NLamaroK::~NLamaroK()
@@ -51,20 +78,23 @@
if (!m_client->isValid())
{
delete m_client;
- m_client = new QDBusInterface("org.mpris.amarok", "/Player");
+ m_client = new QDBusInterface("org.mpris.amarok", "/Player",
"org.freedesktop.MediaPlayer");
}
if( !m_client->isValid() )
return;
// See if amarok is currently playing.
- QDBusReply<int> statusReply = m_client->call("PositionGet");
- if( statusReply.isValid() )
+ QDBusReply<MPRISPlayerStatus> statusReply = m_client->call("GetStatus");
+ if(statusReply.isValid())
{
- if( statusReply.value() )
- {
+ // 0 = playing, 1 = paused, 2 = stopped
+ if(statusReply.value().Play != 2)
m_playing = true;
- }
+ else
+ m_playing = false;
}
+ else
+ m_playing = false;
QDBusReply<QVariantMap> metaDataReply = m_client->call("GetMetadata");
if (!metaDataReply.isValid())
Index: kopete/plugins/nowlistening/nowlisteningplugin.cpp
===================================================================
--- kopete/plugins/nowlistening/nowlisteningplugin.cpp (revision 898019)
+++ kopete/plugins/nowlistening/nowlisteningplugin.cpp (working copy)
@@ -243,10 +243,6 @@
void NowListeningPlugin::slotAdvertCurrentMusic()
{
- // Do anything when statusAdvertising is off.
- if( !NowListeningConfig::self()->statusAdvertising() &&
!NowListeningConfig::self()->appendStatusAdvertising() )
- return;
-
// This slot is called every 5 seconds, so we check if we have a new
track playing.
if( newTrackPlaying() )
{
@@ -284,11 +280,23 @@
{
Kopete::StatusMessage currentStatusMessage =
a->myself()->statusMessage();
- if(isPlaying)
+ // do not add metadata when replace/append to status is
set
+ if( !NowListeningConfig::self()->statusAdvertising() &&
+
!NowListeningConfig::self()->appendStatusAdvertising() )
{
- currentStatusMessage.addMetaData("title",
track);
- currentStatusMessage.addMetaData("artist",
artist);
- currentStatusMessage.addMetaData("album",
album);
+ // we dont have removeMetaData(), so we create
a new status
+ Kopete::StatusMessage tmpStatusMessage;
+
tmpStatusMessage.setMessage(a->myself()->statusMessage().message());
+
tmpStatusMessage.setTitle(a->myself()->statusMessage().title());
+
+ if(isPlaying)
+ {
+ tmpStatusMessage.addMetaData("title",
track);
+ tmpStatusMessage.addMetaData("artist",
artist);
+ tmpStatusMessage.addMetaData("album",
album);
+ }
+ a->setStatusMessage(tmpStatusMessage);
+ continue;
}
if(
NowListeningConfig::self()->appendStatusAdvertising() )
Index: kopete/protocols/wlm/wlmaccount.cpp
===================================================================
--- kopete/protocols/wlm/wlmaccount.cpp (revision 898019)
+++ kopete/protocols/wlm/wlmaccount.cpp (working copy)
@@ -163,16 +163,35 @@
if (isConnected ())
{
MSN::personalInfo pInfo;
+ pInfo.mediaIsEnabled = 0;
QTextCodec::setCodecForCStrings (QTextCodec::codecForName ("utf8"));
if (reason.message().isEmpty ())
pInfo.PSM = "";
else
pInfo.PSM = reason.message().toAscii ().data ();
-// pInfo.mediaType="Music";
- pInfo.mediaIsEnabled = 0;
-// pInfo.mediaFormat="{0} - {1}";
-// pInfo.mediaLines.push_back("Artist");
-// pInfo.mediaLines.push_back("Song");
+
+ // we have both artist and title
+ if( reason.hasMetaData("artist") && reason.hasMetaData("title") )
+ {
+ pInfo.mediaIsEnabled = 1;
+ pInfo.mediaType="Music";
+ pInfo.mediaLines.push_back(
reason.metaData("artist").toString().toAscii().data() );
+ pInfo.mediaLines.push_back(
reason.metaData("title").toString().toAscii().data() );
+ pInfo.mediaFormat="{0} - {1}";
+ m_server->cb.mainConnection->setPersonalStatus (pInfo);
+ return;
+ }
+
+ // we have only the title
+ if( reason.hasMetaData("title") )
+ {
+ pInfo.mediaIsEnabled = 1;
+ pInfo.mediaType="Music";
+ pInfo.mediaFormat="{0}";
+ pInfo.mediaLines.push_back(
reason.metaData("title").toString().toAscii().data() );
+ m_server->cb.mainConnection->setPersonalStatus (pInfo);
+ return;
+ }
m_server->cb.mainConnection->setPersonalStatus (pInfo);
}
}
_______________________________________________
kopete-devel mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kopete-devel