[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:28:38 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=5c79e8a

The following commit has been merged in the master branch:
commit 5c79e8a7a6c3b4351be85568f773dc86845268d4
Author: Aleix Pol <aleixpol at kde.org>
Date:   Thu Jun 18 04:01:01 2015 +0200

    Implement an MPRIS client plugin
    
    Makes it possible to control remote MPRIS instances.
    
    REVIEW: 124100
---
 app/qml/main.qml                                   |   5 +-
 app/qml/mpris.qml                                  |  72 ++++++++++
 app/resources.qrc                                  |   1 +
 core/networkpackage.h                              |   1 +
 interfaces/CMakeLists.txt                          |   3 +
 interfaces/dbusinterfaces.cpp                      |  10 ++
 interfaces/dbusinterfaces.h                        |  23 ++-
 .../kdeconnectdeclarativeplugin.cpp                |  11 +-
 plugins/CMakeLists.txt                             |   4 +
 plugins/mpriscontrol/mpriscontrolplugin.cpp        |   2 +-
 plugins/mprisremote/CMakeLists.txt                 |  14 ++
 plugins/mprisremote/kdeconnect_mprisremote.json    |  28 ++++
 plugins/mprisremote/mprisremoteplugin.cpp          | 157 +++++++++++++++++++++
 plugins/mprisremote/mprisremoteplugin.h            |  84 +++++++++++
 14 files changed, 411 insertions(+), 4 deletions(-)

diff --git a/app/qml/main.qml b/app/qml/main.qml
index 43a0d6d..00fb900 100644
--- a/app/qml/main.qml
+++ b/app/qml/main.qml
@@ -92,7 +92,10 @@ ApplicationWindow
                         }
                         Button {
                             text: i18n("Open Multimedia Remote Control")
-                            enabled: false
+                            onClicked: stack.push( {
+                                item: "qrc:/qml/mpris.qml",
+                                properties: { mprisInterface: MprisDbusInterfaceFactory.create(deviceView.currentDevice.id) }
+                            } );
                         }
                         Button {
                             text: i18n("Remote touch and keyboard")
diff --git a/app/qml/mpris.qml b/app/qml/mpris.qml
new file mode 100644
index 0000000..17f0ac0
--- /dev/null
+++ b/app/qml/mpris.qml
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2015 Aleix Pol Gonzalez <aleixpol at kde.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License or (at your option) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import QtQuick 2.2
+import QtQuick.Controls 1.2
+import QtQuick.Layouts 1.2
+
+ColumnLayout
+{
+    id: root
+    property QtObject mprisInterface
+
+    Component.onCompleted: {
+        mprisInterface.requestPlayerList();
+    }
+
+    Item { Layout.fillHeight: true }
+    ComboBox {
+        Layout.fillWidth: true
+        model: root.mprisInterface.playerList
+        onCurrentTextChanged: root.mprisInterface.player = currentText
+    }
+    Label {
+        Layout.fillWidth: true
+        text: root.mprisInterface.nowPlaying
+    }
+    Button {
+        Layout.fillWidth: true
+        text: root.mprisInterface.isPlaying ? "pause" : "play"
+        onClicked: root.mprisInterface.sendAction("PlayPause");
+    }
+    RowLayout {
+        Layout.fillWidth: true
+        Button {
+            Layout.fillWidth: true
+            text: "<<"
+            onClicked: root.mprisInterface.sendAction("Previous")
+        }
+        Button {
+            Layout.fillWidth: true
+            text: ">>"
+            onClicked: root.mprisInterface.sendAction("Next")
+        }
+    }
+    RowLayout {
+        Layout.fillWidth: true
+        Label { text: "x" }
+        Slider {
+            value: root.mprisInterface.volume
+            maximumValue: 100
+            Layout.fillWidth: true
+        }
+    }
+    Item { Layout.fillHeight: true }
+}
diff --git a/app/resources.qrc b/app/resources.qrc
index 0e02918..3731e0a 100644
--- a/app/resources.qrc
+++ b/app/resources.qrc
@@ -2,5 +2,6 @@
  <qresource>
     <file>qml/main.qml</file>
     <file>qml/DeviceDelegate.qml</file>
+    <file>qml/mpris.qml</file>
  </qresource>
 </RCC>
diff --git a/core/networkpackage.h b/core/networkpackage.h
index a79ac4a..6a0bf9c 100644
--- a/core/networkpackage.h
+++ b/core/networkpackage.h
@@ -37,6 +37,7 @@
 
 class FileTransferJob;
 
+// TODO: investigate if we can turn into Q_GADGET, drop QObject
 class KDECONNECTCORE_EXPORT NetworkPackage : public QObject
 {
     Q_OBJECT
diff --git a/interfaces/CMakeLists.txt b/interfaces/CMakeLists.txt
index 7879b35..bae0cff 100644
--- a/interfaces/CMakeLists.txt
+++ b/interfaces/CMakeLists.txt
@@ -31,12 +31,14 @@ set(libkdeconnect_HEADERS
     ${CMAKE_BINARY_DIR}/interfaces/devicesftpinterface.h
     ${CMAKE_BINARY_DIR}/interfaces/devicenotificationsinterface.h
     ${CMAKE_BINARY_DIR}/interfaces/notificationinterface.h
+    ${CMAKE_BINARY_DIR}/interfaces/mprisremoteinterface.h
 )
 
 set_source_files_properties(
     ${CMAKE_BINARY_DIR}/core/org.kde.kdeconnect.daemon.xml
     ${CMAKE_BINARY_DIR}/core/org.kde.kdeconnect.device.xml
     ${CMAKE_BINARY_DIR}/plugins/battery/org.kde.kdeconnect.device.battery.xml
+    ${CMAKE_BINARY_DIR}/plugins/mprisremote/org.kde.kdeconnect.device.mprisremote.xml
     ${CMAKE_BINARY_DIR}/plugins/sftp/org.kde.kdeconnect.device.sftp.xml
     ${CMAKE_BINARY_DIR}/plugins/notifications/org.kde.kdeconnect.device.notifications.xml
     ${CMAKE_BINARY_DIR}/plugins/notifications/org.kde.kdeconnect.device.notifications.notification.xml
@@ -48,6 +50,7 @@ qt5_add_dbus_interface(libkdeconnect_SRC ${CMAKE_BINARY_DIR}/plugins/battery/org
 qt5_add_dbus_interface(libkdeconnect_SRC ${CMAKE_BINARY_DIR}/plugins/sftp/org.kde.kdeconnect.device.sftp.xml devicesftpinterface )
 qt5_add_dbus_interface(libkdeconnect_SRC ${CMAKE_BINARY_DIR}/plugins/notifications/org.kde.kdeconnect.device.notifications.xml devicenotificationsinterface )
 qt5_add_dbus_interface(libkdeconnect_SRC ${CMAKE_BINARY_DIR}/plugins/notifications/org.kde.kdeconnect.device.notifications.notification.xml notificationinterface  )
+qt5_add_dbus_interface(libkdeconnect_SRC ${CMAKE_BINARY_DIR}/plugins/mprisremote/org.kde.kdeconnect.device.mprisremote.xml mprisremoteinterface )
 
 add_library(kdeconnectinterfaces SHARED ${libkdeconnect_SRC})
 set_target_properties(kdeconnectinterfaces PROPERTIES
diff --git a/interfaces/dbusinterfaces.cpp b/interfaces/dbusinterfaces.cpp
index 6ee93bd..69abbf7 100644
--- a/interfaces/dbusinterfaces.cpp
+++ b/interfaces/dbusinterfaces.cpp
@@ -97,3 +97,13 @@ SftpDbusInterface::~SftpDbusInterface()
 {
 
 }
+
+MprisDbusInterface::MprisDbusInterface(const QString& id, QObject* parent)
+    : OrgKdeKdeconnectDeviceMprisremoteInterface(activatedService(), "/modules/kdeconnect/devices/" + id + "/mprisremote", QDBusConnection::sessionBus(), parent)
+{
+    connect(this, &OrgKdeKdeconnectDeviceMprisremoteInterface::propertiesChanged, this, &MprisDbusInterface::propertiesChangedProxy);
+}
+
+MprisDbusInterface::~MprisDbusInterface()
+{
+}
diff --git a/interfaces/dbusinterfaces.h b/interfaces/dbusinterfaces.h
index 142da39..d551fba 100644
--- a/interfaces/dbusinterfaces.h
+++ b/interfaces/dbusinterfaces.h
@@ -29,6 +29,7 @@
 #include "interfaces/devicesftpinterface.h"
 #include "interfaces/devicenotificationsinterface.h"
 #include "interfaces/notificationinterface.h"
+#include "interfaces/mprisremoteinterface.h"
 
 /**
  * Using these "proxy" classes just in case we need to rename the
@@ -47,7 +48,7 @@ class KDECONNECTINTERFACES_EXPORT DeviceDbusInterface
     : public OrgKdeKdeconnectDeviceInterface
 {
     Q_OBJECT
-//  Workaround because OrgKdeKdeconnectDeviceInterface is not generating
+//  TODO: Workaround because OrgKdeKdeconnectDeviceInterface is not generating
 //  the signals for the properties
     Q_PROPERTY(bool isPaired READ isPaired NOTIFY pairingChangedProxy)
 public:
@@ -96,4 +97,24 @@ public:
     virtual ~SftpDbusInterface();
 };
 
+class KDECONNECTINTERFACES_EXPORT MprisDbusInterface
+    : public OrgKdeKdeconnectDeviceMprisremoteInterface
+{
+    Q_OBJECT
+//  TODO: Workaround because qdbusxml2cpp is not generating
+//  the signals for the properties
+    Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY propertiesChangedProxy)
+    Q_PROPERTY(int length READ length NOTIFY propertiesChangedProxy)
+    Q_PROPERTY(QString nowPlaying READ nowPlaying NOTIFY propertiesChangedProxy)
+    Q_PROPERTY(QStringList playerList READ playerList NOTIFY propertiesChangedProxy)
+    Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY propertiesChangedProxy)
+    Q_PROPERTY(int position READ position WRITE setPosition NOTIFY propertiesChangedProxy)
+public:
+    MprisDbusInterface(const QString& deviceId, QObject* parent = 0);
+    virtual ~MprisDbusInterface();
+
+Q_SIGNALS:
+    void propertiesChangedProxy();
+};
+
 #endif
diff --git a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp
index 76a7601..0db9e8b 100644
--- a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp
+++ b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp
@@ -49,6 +49,11 @@ QObject* createSftpInterface(QVariant deviceId)
     return new SftpDbusInterface(deviceId.toString());
 }
 
+QObject* createMprisInterface(QVariant deviceId)
+{
+    return new MprisDbusInterface(deviceId.toString());
+}
+
 QObject* createDBusResponse()
 {
     return new DBusAsyncResponse();
@@ -61,6 +66,7 @@ void KdeConnectDeclarativePlugin::registerTypes(const char* uri)
     qmlRegisterType<DBusAsyncResponse>(uri, 1, 0, "DBusAsyncResponse");
     qmlRegisterType<ProcessRunner>(uri, 1, 0, "ProcessRunner");
     qmlRegisterType<DevicesSortProxyModel>(uri, 1, 0, "DevicesSortProxyModel");
+    qmlRegisterUncreatableType<MprisDbusInterface>(uri, 1, 0, "MprisDbusInterface", QStringLiteral("You're not supposed to instantiate interfacess"));
     qmlRegisterUncreatableType<DeviceDbusInterface>(uri, 1, 0, "DeviceDbusInterface", QStringLiteral("You're not supposed to instantiate interfacess"));
 }
 
@@ -76,10 +82,13 @@ void KdeConnectDeclarativePlugin::initializeEngine(QQmlEngine* engine, const cha
     
     engine->rootContext()->setContextProperty("SftpDbusInterfaceFactory"
       , new ObjectFactory(engine, createSftpInterface));
+
+    engine->rootContext()->setContextProperty("MprisDbusInterfaceFactory"
+      , new ObjectFactory(engine, createMprisInterface));
     
     engine->rootContext()->setContextProperty("DBusResponseFactory"
       , new ObjectFactory(engine, createDBusResponse));    
     
     engine->rootContext()->setContextProperty("DBusResponseWaiter"
-      , DBusResponseWaiter::instance());    
+      , DBusResponseWaiter::instance());
 }
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index 083c087..35aec66 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -14,5 +14,9 @@ add_subdirectory(notifications)
 add_subdirectory(sftp)
 add_subdirectory(screensaver-inhibit)
 
+if(EXPERIMENTALAPP_ENABLED)
+    add_subdirectory(mprisremote)
+endif()
+
 #FIXME: If we split notifications in several files, they won't appear in the same group in the Notifications KCM
 install(FILES kdeconnect.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR})
diff --git a/plugins/mpriscontrol/mpriscontrolplugin.cpp b/plugins/mpriscontrol/mpriscontrolplugin.cpp
index a33cbdc..8318217 100644
--- a/plugins/mpriscontrol/mpriscontrolplugin.cpp
+++ b/plugins/mpriscontrol/mpriscontrolplugin.cpp
@@ -131,7 +131,7 @@ void MprisControlPlugin::propertiesChanged(const QString& propertyInterface, con
         const QString& player = playerList.key(service);
         np.set("player", player);
         // Always also update the position
-        OrgMprisMediaPlayer2PlayerInterface mprisInterface(playerList[player], "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus());
+        OrgMprisMediaPlayer2PlayerInterface mprisInterface(service, "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus());
         if (mprisInterface.canSeek()) {
             long long pos = mprisInterface.position();
             np.set("pos", pos/1000); //Send milis instead of nanos
diff --git a/plugins/mprisremote/CMakeLists.txt b/plugins/mprisremote/CMakeLists.txt
new file mode 100644
index 0000000..0392249
--- /dev/null
+++ b/plugins/mprisremote/CMakeLists.txt
@@ -0,0 +1,14 @@
+kdeconnect_add_plugin(kdeconnect_mprisremote JSON kdeconnect_mprisremote.json SOURCES mprisremoteplugin.cpp)
+
+target_link_libraries(kdeconnect_mprisremote
+    kdeconnectcore
+    Qt5::DBus
+    KF5::I18n
+)
+
+generate_and_install_dbus_interface(
+    kdeconnect_mpriscontrol
+    mprisremoteplugin.h
+    org.kde.kdeconnect.device.mprisremote.xml
+    OPTIONS -a
+)
diff --git a/plugins/mprisremote/kdeconnect_mprisremote.json b/plugins/mprisremote/kdeconnect_mprisremote.json
new file mode 100644
index 0000000..32c150c
--- /dev/null
+++ b/plugins/mprisremote/kdeconnect_mprisremote.json
@@ -0,0 +1,28 @@
+{
+    "Encoding": "UTF-8", 
+    "KPlugin": {
+        "Authors": [
+            {
+                "Email": "aleixpol at kde.org",
+                "Name": "Aleix Pol"
+            }
+        ], 
+        "Description": "Control MPRIS services",
+        "EnabledByDefault": true, 
+        "Icon": "applications-multimedia",
+        "Id": "kdeconnect_mprisremote",
+        "License": "GPL",
+        "Name": "MprisRemote",
+        "ServiceTypes": [
+            "KdeConnect/Plugin"
+        ], 
+        "Version": "0.1", 
+        "Website": "https://kde.org"
+    }, 
+    "X-KdeConnect-OutgoingPackageType": [
+        "kdeconnect.mpris"
+    ], 
+    "X-KdeConnect-SupportedPackageType": [
+        "kdeconnect.mpris"
+    ]
+}
diff --git a/plugins/mprisremote/mprisremoteplugin.cpp b/plugins/mprisremote/mprisremoteplugin.cpp
new file mode 100644
index 0000000..4f2e340
--- /dev/null
+++ b/plugins/mprisremote/mprisremoteplugin.cpp
@@ -0,0 +1,157 @@
+/**
+ * Copyright 2013 Albert Vaca <albertvaka at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License or (at your option) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mprisremoteplugin.h"
+
+#include <KLocalizedString>
+#include <KPluginFactory>
+
+#include <QDebug>
+#include <QDBusConnection>
+#include <QLoggingCategory>
+
+#include <core/device.h>
+
+K_PLUGIN_FACTORY_WITH_JSON( KdeConnectPluginFactory, "kdeconnect_mprisremote.json", registerPlugin< MprisRemotePlugin >(); )
+
+Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_MPRISREMOTE, "kdeconnect.plugin.mprisremote")
+
+MprisRemotePlugin::MprisRemotePlugin(QObject* parent, const QVariantList& args)
+    : KdeConnectPlugin(parent, args)
+    , m_player()
+    , m_playing(false)
+    , m_nowPlaying()
+    , m_volume(50)
+    , m_length(0)
+    , m_lastPosition(0)
+    , m_lastPositionTime()
+    , m_playerList()
+{
+}
+
+MprisRemotePlugin::~MprisRemotePlugin()
+{
+}
+
+bool MprisRemotePlugin::receivePackage(const NetworkPackage& np)
+{
+    if (np.type() != PACKAGE_TYPE_MPRIS)
+        return false;
+
+    if (np.has("nowPlaying") || np.has("volume") || np.has("isPlaying") || np.has("length") || np.has("pos")) {
+        if (np.get<QString>("player") == m_player) {
+            m_nowPlaying = np.get<QString>("nowPlaying", m_nowPlaying);
+            m_volume = np.get<int>("volume", m_volume);
+            m_length = np.get<int>("length", m_length);
+            if(np.has("pos")){
+                m_lastPosition = np.get<int>("pos", m_lastPosition);
+                m_lastPositionTime = QDateTime::currentMSecsSinceEpoch();
+            }
+            m_playing = np.get<bool>("isPlaying", m_playing);
+        }
+    }
+
+    if (np.has("playerList")) {
+        m_playerList = np.get<QStringList>("playerList", QStringList());
+    }
+    Q_EMIT propertiesChanged();
+
+    return true;
+}
+
+long MprisRemotePlugin::position() const
+{
+    if(m_playing) {
+        return m_lastPosition + (QDateTime::currentMSecsSinceEpoch() - m_lastPositionTime);
+    } else {
+        return m_lastPosition;
+    }
+}
+
+void MprisRemotePlugin::connected()
+{
+    QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportAllContents);
+}
+
+QString MprisRemotePlugin::dbusPath() const
+{
+    return "/modules/kdeconnect/devices/" + device()->id() + "/mprisremote";
+}
+
+void MprisRemotePlugin::requestPlayerStatus()
+{
+    NetworkPackage np(PACKAGE_TYPE_MPRIS);
+    np.set("player",m_player);
+    np.set("requestNowPlaying",true);
+    np.set("requestVolume",true);
+    sendPackage(np);
+}
+
+void MprisRemotePlugin::requestPlayerList()
+{
+    NetworkPackage np(PACKAGE_TYPE_MPRIS);
+    np.set("requestPlayerList", true);
+    sendPackage(np);
+}
+
+void MprisRemotePlugin::sendAction(const QString& action)
+{
+    NetworkPackage np(PACKAGE_TYPE_MPRIS);
+    np.set("player", m_player);
+    np.set("action", action);
+    sendPackage(np);
+}
+
+void MprisRemotePlugin::seek(int offset) const
+{
+    NetworkPackage np(PACKAGE_TYPE_MPRIS);
+    np.set("player", m_player);
+    np.set("Seek", offset);
+    sendPackage(np);
+}
+
+void MprisRemotePlugin::setVolume(int volume)
+{
+    NetworkPackage np(PACKAGE_TYPE_MPRIS);
+    np.set("player", m_player);
+    np.set("setVolume",volume);
+    sendPackage(np);
+}
+
+void MprisRemotePlugin::setPosition(int position)
+{
+    NetworkPackage np(PACKAGE_TYPE_MPRIS);
+    np.set("player", m_player);
+    np.set("SetPosition", position);
+    sendPackage(np);
+
+    m_lastPosition = position;
+    m_lastPositionTime = QDateTime::currentMSecsSinceEpoch();
+}
+
+void MprisRemotePlugin::setPlayer(const QString& player)
+{
+    if (m_player != player) {
+        m_player = player;
+        requestPlayerStatus();
+    }
+}
+
+#include "mprisremoteplugin.moc"
diff --git a/plugins/mprisremote/mprisremoteplugin.h b/plugins/mprisremote/mprisremoteplugin.h
new file mode 100644
index 0000000..886e6c5
--- /dev/null
+++ b/plugins/mprisremote/mprisremoteplugin.h
@@ -0,0 +1,84 @@
+/**
+ * Copyright 2013 Albert Vaca <albertvaka at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License or (at your option) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MPRISREMOTEPLUGIN_H
+#define MPRISREMOTEPLUGIN_H
+
+#include <QObject>
+
+#include <core/kdeconnectplugin.h>
+
+#define PACKAGE_TYPE_MPRIS QLatin1String("kdeconnect.mpris")
+
+class Q_DECL_EXPORT MprisRemotePlugin
+    : public KdeConnectPlugin
+{
+    Q_OBJECT
+    Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.mprisremote")
+    Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY propertiesChanged)
+    Q_PROPERTY(int length READ length NOTIFY propertiesChanged)
+    Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY propertiesChanged)
+    Q_PROPERTY(int position READ position WRITE setPosition NOTIFY propertiesChanged)
+    Q_PROPERTY(QStringList playerList READ playerList NOTIFY propertiesChanged)
+    Q_PROPERTY(QString player READ player WRITE setPlayer)
+    Q_PROPERTY(QString nowPlaying READ nowPlaying NOTIFY propertiesChanged)
+
+public:
+    explicit MprisRemotePlugin(QObject *parent, const QVariantList &args);
+    virtual ~MprisRemotePlugin();
+
+    long position() const;
+    int volume() const { return m_volume; }
+    int length() const { return m_length; }
+    bool isPlaying() const { return m_playing; }
+    QStringList playerList() const { return m_playerList; }
+    QString player() const { return m_player; }
+    QString nowPlaying() const { return m_nowPlaying; }
+
+    void setVolume(int volume);
+    void setPosition(int position);
+    void setPlayer(const QString& player);
+
+public Q_SLOTS:
+    virtual bool receivePackage(const NetworkPackage& np);
+    virtual void connected();
+
+    void seek(int offset) const;
+    void requestPlayerStatus();
+    void requestPlayerList();
+    void sendAction(const QString& action);
+
+Q_SIGNALS:
+    void propertiesChanged();
+
+private:
+    QString dbusPath() const;
+
+    QString m_player;
+    bool m_playing;
+    QString m_nowPlaying;
+    int m_volume;
+    long m_length;
+    long m_lastPosition;
+    qint64 m_lastPositionTime;
+    QStringList m_playerList;
+};
+
+#endif

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list