Port mpris from kDebug to qCDebug

This commit is contained in:
Àlex Fiestas 2014-09-22 00:44:47 +02:00
parent 2b0eecc599
commit 1e9df65d50
2 changed files with 11 additions and 7 deletions

View file

@ -28,7 +28,6 @@
#include <QDBusReply>
#include <QDBusMessage>
#include <core/kdebugnamespace.h>
#include <core/device.h>
#include "mprisdbusinterface.h"
#include "propertiesdbusinterface.h"
@ -36,6 +35,8 @@
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< MprisControlPlugin >(); )
K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_mpriscontrol", "kdeconnect-plugins") )
Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_MPRIS, "kdeconnect.plugin.mpris")
MprisControlPlugin::MprisControlPlugin(QObject* parent, const QVariantList& args)
: KdeConnectPlugin(parent, args)
{
@ -62,7 +63,7 @@ void MprisControlPlugin::serviceOwnerChanged(const QString &name,
if (name.startsWith("org.mpris.MediaPlayer2")) {
kDebug(debugArea()) << "Mpris (un)registered in bus" << name << oldOwner << newOwner;
qCDebug(KDECONNECT_PLUGIN_MPRIS) << "Mpris (un)registered in bus" << name << oldOwner << newOwner;
if (oldOwner.isEmpty()) {
addPlayer(name);
@ -78,7 +79,7 @@ void MprisControlPlugin::addPlayer(const QString& service)
//FIXME: This call hangs and returns an empty string if KDED is still starting!
const QString identity = mprisInterface.property("Identity").toString();
playerList[identity] = service;
kDebug(debugArea()) << "Mpris addPlayer" << service << "->" << identity;
qCDebug(KDECONNECT_PLUGIN_MPRIS) << "Mpris addPlayer" << service << "->" << identity;
sendPlayerList();
OrgFreedesktopDBusPropertiesInterface* freedesktopInterface = new OrgFreedesktopDBusPropertiesInterface(service, "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus(), this);
@ -132,7 +133,7 @@ void MprisControlPlugin::propertiesChanged(const QString& propertyInterface, con
void MprisControlPlugin::removePlayer(const QString& ifaceName)
{
const QString identity = playerList.key(ifaceName);
kDebug(debugArea()) << "Mpris removePlayer" << ifaceName << "->" << identity;
qCDebug(KDECONNECT_PLUGIN_MPRIS) << "Mpris removePlayer" << ifaceName << "->" << identity;
playerList.remove(identity);
sendPlayerList();
}
@ -157,18 +158,18 @@ bool MprisControlPlugin::receivePackage (const NetworkPackage& np)
OrgMprisMediaPlayer2PlayerInterface mprisInterface(playerList[player], "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus());
if (np.has("action")) {
const QString& action = np.get<QString>("action");
kDebug(debugArea()) << "Calling action" << action << "in" << playerList[player];
qCDebug(KDECONNECT_PLUGIN_MPRIS) << "Calling action" << action << "in" << playerList[player];
//TODO: Check for valid actions
mprisInterface.call(action);
}
if (np.has("setVolume")) {
double volume = np.get<int>("setVolume")/100.f;
kDebug(debugArea()) << "Setting volume" << volume << "to" << playerList[player];
qCDebug(KDECONNECT_PLUGIN_MPRIS) << "Setting volume" << volume << "to" << playerList[player];
mprisInterface.setVolume(volume);
}
if (np.has("Seek")) {
int offset = np.get<int>("Seek");
kDebug(debugArea()) << "Seeking" << offset << "to" << playerList[player];
qCDebug(KDECONNECT_PLUGIN_MPRIS) << "Seeking" << offset << "to" << playerList[player];
mprisInterface.Seek(offset);
}

View file

@ -23,11 +23,14 @@
#include <QString>
#include <QHash>
#include <QLoggingCategory>
#include <core/kdeconnectplugin.h>
#define PACKAGE_TYPE_MPRIS QLatin1String("kdeconnect.mpris")
Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_PLUGIN_MPRIS)
class MprisControlPlugin
: public KdeConnectPlugin
{