Port mpris from kDebug to qCDebug
This commit is contained in:
parent
2b0eecc599
commit
1e9df65d50
2 changed files with 11 additions and 7 deletions
|
@ -28,7 +28,6 @@
|
||||||
#include <QDBusReply>
|
#include <QDBusReply>
|
||||||
#include <QDBusMessage>
|
#include <QDBusMessage>
|
||||||
|
|
||||||
#include <core/kdebugnamespace.h>
|
|
||||||
#include <core/device.h>
|
#include <core/device.h>
|
||||||
#include "mprisdbusinterface.h"
|
#include "mprisdbusinterface.h"
|
||||||
#include "propertiesdbusinterface.h"
|
#include "propertiesdbusinterface.h"
|
||||||
|
@ -36,6 +35,8 @@
|
||||||
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< MprisControlPlugin >(); )
|
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< MprisControlPlugin >(); )
|
||||||
K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_mpriscontrol", "kdeconnect-plugins") )
|
K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_mpriscontrol", "kdeconnect-plugins") )
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_MPRIS, "kdeconnect.plugin.mpris")
|
||||||
|
|
||||||
MprisControlPlugin::MprisControlPlugin(QObject* parent, const QVariantList& args)
|
MprisControlPlugin::MprisControlPlugin(QObject* parent, const QVariantList& args)
|
||||||
: KdeConnectPlugin(parent, args)
|
: KdeConnectPlugin(parent, args)
|
||||||
{
|
{
|
||||||
|
@ -62,7 +63,7 @@ void MprisControlPlugin::serviceOwnerChanged(const QString &name,
|
||||||
|
|
||||||
if (name.startsWith("org.mpris.MediaPlayer2")) {
|
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()) {
|
if (oldOwner.isEmpty()) {
|
||||||
addPlayer(name);
|
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!
|
//FIXME: This call hangs and returns an empty string if KDED is still starting!
|
||||||
const QString identity = mprisInterface.property("Identity").toString();
|
const QString identity = mprisInterface.property("Identity").toString();
|
||||||
playerList[identity] = service;
|
playerList[identity] = service;
|
||||||
kDebug(debugArea()) << "Mpris addPlayer" << service << "->" << identity;
|
qCDebug(KDECONNECT_PLUGIN_MPRIS) << "Mpris addPlayer" << service << "->" << identity;
|
||||||
sendPlayerList();
|
sendPlayerList();
|
||||||
|
|
||||||
OrgFreedesktopDBusPropertiesInterface* freedesktopInterface = new OrgFreedesktopDBusPropertiesInterface(service, "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus(), this);
|
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)
|
void MprisControlPlugin::removePlayer(const QString& ifaceName)
|
||||||
{
|
{
|
||||||
const QString identity = playerList.key(ifaceName);
|
const QString identity = playerList.key(ifaceName);
|
||||||
kDebug(debugArea()) << "Mpris removePlayer" << ifaceName << "->" << identity;
|
qCDebug(KDECONNECT_PLUGIN_MPRIS) << "Mpris removePlayer" << ifaceName << "->" << identity;
|
||||||
playerList.remove(identity);
|
playerList.remove(identity);
|
||||||
sendPlayerList();
|
sendPlayerList();
|
||||||
}
|
}
|
||||||
|
@ -157,18 +158,18 @@ bool MprisControlPlugin::receivePackage (const NetworkPackage& np)
|
||||||
OrgMprisMediaPlayer2PlayerInterface mprisInterface(playerList[player], "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus());
|
OrgMprisMediaPlayer2PlayerInterface mprisInterface(playerList[player], "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus());
|
||||||
if (np.has("action")) {
|
if (np.has("action")) {
|
||||||
const QString& action = np.get<QString>("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
|
//TODO: Check for valid actions
|
||||||
mprisInterface.call(action);
|
mprisInterface.call(action);
|
||||||
}
|
}
|
||||||
if (np.has("setVolume")) {
|
if (np.has("setVolume")) {
|
||||||
double volume = np.get<int>("setVolume")/100.f;
|
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);
|
mprisInterface.setVolume(volume);
|
||||||
}
|
}
|
||||||
if (np.has("Seek")) {
|
if (np.has("Seek")) {
|
||||||
int offset = np.get<int>("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);
|
mprisInterface.Seek(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,14 @@
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
#include <core/kdeconnectplugin.h>
|
#include <core/kdeconnectplugin.h>
|
||||||
|
|
||||||
#define PACKAGE_TYPE_MPRIS QLatin1String("kdeconnect.mpris")
|
#define PACKAGE_TYPE_MPRIS QLatin1String("kdeconnect.mpris")
|
||||||
|
|
||||||
|
Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_PLUGIN_MPRIS)
|
||||||
|
|
||||||
class MprisControlPlugin
|
class MprisControlPlugin
|
||||||
: public KdeConnectPlugin
|
: public KdeConnectPlugin
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue