From 049c708743f699e0acf630a7a14585fbeb38a3c4 Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Tue, 13 Aug 2013 06:35:58 +0200 Subject: [PATCH] Mpris plugin to new format +commited missing files Added files missing from previous commits (KDevelop git support fault :) Fixed includes in linkprovider.h Added icons to plugins --- daemon/linkproviders/linkprovider.h | 3 +- daemon/plugins/CMakeLists.txt | 1 + daemon/plugins/kdeconnect_plugin.desktop | 5 +++ daemon/plugins/mpris/CMakeLists.txt | 12 ------- daemon/plugins/mpriscontrol/CMakeLists.txt | 36 +++++++++++++++++++ .../kdeconnect_mpriscontrol.desktop | 15 ++++++++ .../mpriscontrolplugin.cpp} | 32 +++++++++-------- .../mpriscontrolplugin.h} | 18 +++++----- .../mprisdbusinterface.xml | 2 +- .../propertiesInterface.xml | 0 daemon/plugins/pausemusic/CMakeLists.txt | 20 +++++++++++ .../pausemusic/kdeconnect_pausemusic.desktop | 15 ++++++++ 12 files changed, 121 insertions(+), 38 deletions(-) create mode 100644 daemon/plugins/kdeconnect_plugin.desktop delete mode 100644 daemon/plugins/mpris/CMakeLists.txt create mode 100644 daemon/plugins/mpriscontrol/CMakeLists.txt create mode 100644 daemon/plugins/mpriscontrol/kdeconnect_mpriscontrol.desktop rename daemon/plugins/{mpris/mpriscontrolpackageinterface.cpp => mpriscontrol/mpriscontrolplugin.cpp} (86%) rename daemon/plugins/{mpris/mpriscontrolpackageinterface.h => mpriscontrol/mpriscontrolplugin.h} (84%) rename daemon/plugins/{mpris => mpriscontrol}/mprisdbusinterface.xml (96%) rename daemon/plugins/{mpris => mpriscontrol}/propertiesInterface.xml (100%) create mode 100644 daemon/plugins/pausemusic/CMakeLists.txt create mode 100644 daemon/plugins/pausemusic/kdeconnect_pausemusic.desktop diff --git a/daemon/linkproviders/linkprovider.h b/daemon/linkproviders/linkprovider.h index 792662bae..e1f13101d 100644 --- a/daemon/linkproviders/linkprovider.h +++ b/daemon/linkproviders/linkprovider.h @@ -25,8 +25,7 @@ #include #include -#include "devicelinks/devicelink.h" -#include "device.h" +#include "../networkpackage.h" class DeviceLink; diff --git a/daemon/plugins/CMakeLists.txt b/daemon/plugins/CMakeLists.txt index 494973ab7..fa90ebf82 100644 --- a/daemon/plugins/CMakeLists.txt +++ b/daemon/plugins/CMakeLists.txt @@ -3,4 +3,5 @@ install(FILES kdeconnect_plugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR}) add_subdirectory(ping) add_subdirectory(pausemusic) +add_subdirectory(mpriscontrol) diff --git a/daemon/plugins/kdeconnect_plugin.desktop b/daemon/plugins/kdeconnect_plugin.desktop new file mode 100644 index 000000000..dd76d9243 --- /dev/null +++ b/daemon/plugins/kdeconnect_plugin.desktop @@ -0,0 +1,5 @@ +[Desktop Entry] +Type=ServiceType +X-KDE-ServiceType=KdeConnect/Plugin +X-KDE-Derived=KPluginInfo +Name=KDEConnect Plugin diff --git a/daemon/plugins/mpris/CMakeLists.txt b/daemon/plugins/mpris/CMakeLists.txt deleted file mode 100644 index e8ca6d1aa..000000000 --- a/daemon/plugins/mpris/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ - -qt4_add_dbus_interface( - kded_kdeconnect_SRCS - packageinterfaces/mprisdbusinterface.xml - mprisdbusinterface -) - -qt4_add_dbus_interface( - kded_kdeconnect_SRCS - packageinterfaces/propertiesInterface.xml - propertiesdbusinterface -) diff --git a/daemon/plugins/mpriscontrol/CMakeLists.txt b/daemon/plugins/mpriscontrol/CMakeLists.txt new file mode 100644 index 000000000..840d614fe --- /dev/null +++ b/daemon/plugins/mpriscontrol/CMakeLists.txt @@ -0,0 +1,36 @@ +find_package(KDE4 REQUIRED) +include (KDE4Defaults) +include_directories(${KDE4_INCLUDES}) + +set(kdeconnect_mpriscontrol_SRCS + mpriscontrolplugin.cpp + ../kdeconnectplugin.cpp + ../pluginloader.cpp + ../../networkpackage.cpp + ../../device.cpp +) + +qt4_add_dbus_interface( + kdeconnect_mpriscontrol_SRCS + mprisdbusinterface.xml + mprisdbusinterface +) + +qt4_add_dbus_interface( + kdeconnect_mpriscontrol_SRCS + propertiesInterface.xml + propertiesdbusinterface +) + +kde4_add_plugin(kdeconnect_mpriscontrol ${kdeconnect_mpriscontrol_SRCS}) + +target_link_libraries(kdeconnect_mpriscontrol + ${KDE4_KDECORE_LIBS} + ${KDE4_KDEUI_LIBS} + ${QT_QTNETWORK_LIBRARY} + qjson +) + +install(TARGETS kdeconnect_mpriscontrol DESTINATION ${PLUGIN_INSTALL_DIR} ) +install(FILES kdeconnect_mpriscontrol.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) + diff --git a/daemon/plugins/mpriscontrol/kdeconnect_mpriscontrol.desktop b/daemon/plugins/mpriscontrol/kdeconnect_mpriscontrol.desktop new file mode 100644 index 000000000..a93e25606 --- /dev/null +++ b/daemon/plugins/mpriscontrol/kdeconnect_mpriscontrol.desktop @@ -0,0 +1,15 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Service +ServiceTypes=KdeConnect/Plugin +X-KDE-Library=kdeconnect_mpriscontrol +X-KDE-PluginInfo-Author=Albert Vaca +X-KDE-PluginInfo-Email=albertvaka@gmail.com +X-KDE-PluginInfo-Name=kdeconnect_mpriscontrol +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-Website=http://albertvaka.wordpress.com +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true +Icon=media-playback-start +Name=Multimedia control receiver +Comment=Remote control your music and videos diff --git a/daemon/plugins/mpris/mpriscontrolpackageinterface.cpp b/daemon/plugins/mpriscontrol/mpriscontrolplugin.cpp similarity index 86% rename from daemon/plugins/mpris/mpriscontrolpackageinterface.cpp rename to daemon/plugins/mpriscontrol/mpriscontrolplugin.cpp index 22df27d29..54ec123b2 100644 --- a/daemon/plugins/mpris/mpriscontrolpackageinterface.cpp +++ b/daemon/plugins/mpriscontrol/mpriscontrolplugin.cpp @@ -18,7 +18,7 @@ * along with this program. If not, see . */ -#include "mpriscontrolpackageinterface.h" +#include "mpriscontrolplugin.h" #include "propertiesdbusinterface.h" @@ -29,7 +29,11 @@ #include #include -MprisControlPackageInterface::MprisControlPackageInterface() +K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< MprisControlPlugin >(); ) +K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_mpriscontrol", "kdeconnect_mpriscontrol") ) + +MprisControlPlugin::MprisControlPlugin(QObject* parent, const QVariantList& args) + : KdeConnectPlugin(parent, args) { //Detect new interfaces @@ -46,7 +50,7 @@ MprisControlPackageInterface::MprisControlPackageInterface() } -void MprisControlPackageInterface::serviceOwnerChanged(const QString &name, +void MprisControlPlugin::serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner) { @@ -54,7 +58,7 @@ void MprisControlPackageInterface::serviceOwnerChanged(const QString &name, if (name.startsWith("org.mpris.MediaPlayer2")) { - qDebug() << "Something (un)registered in bus" << name << oldOwner << newOwner; + qDebug() << "Mpris (un)registered in bus" << name << oldOwner << newOwner; if (oldOwner.isEmpty()) { addPlayer(name); @@ -64,7 +68,7 @@ void MprisControlPackageInterface::serviceOwnerChanged(const QString &name, } } -void MprisControlPackageInterface::addPlayer(const QString& service) +void MprisControlPlugin::addPlayer(const QString& service) { QDBusInterface mprisInterface(service, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2"); const QString& identity = mprisInterface.property("Identity").toString(); @@ -77,7 +81,7 @@ void MprisControlPackageInterface::addPlayer(const QString& service) } -void MprisControlPackageInterface::propertiesChanged(const QString& propertyInterface, const QVariantMap& properties) +void MprisControlPlugin::propertiesChanged(const QString& propertyInterface, const QVariantMap& properties) { NetworkPackage np(PACKAGE_TYPE_MPRIS); @@ -115,19 +119,18 @@ void MprisControlPackageInterface::propertiesChanged(const QString& propertyInte const QString& service = interface->service(); const QString& player = playerList.key(service); np.set("player", player); - sendPackage(np); + device()->sendPackage(np); } } -void MprisControlPackageInterface::removePlayer(const QString& ifaceName) +void MprisControlPlugin::removePlayer(const QString& ifaceName) { playerList.remove(playerList.key(ifaceName)); sendPlayerList(); } -bool MprisControlPackageInterface::receivePackage (const Device& device, const NetworkPackage& np) +bool MprisControlPlugin::receivePackage (const NetworkPackage& np) { - Q_UNUSED(device); if (np.type() != PACKAGE_TYPE_MPRIS) return false; @@ -135,7 +138,7 @@ bool MprisControlPackageInterface::receivePackage (const Device& device, const N const QString& player = np.get("player"); bool valid_player = playerList.contains(player); if (!valid_player || np.get("requestPlayerList")) { - sendPlayerList(&device); + sendPlayerList(); if (!valid_player) { return true; } @@ -185,17 +188,16 @@ bool MprisControlPackageInterface::receivePackage (const Device& device, const N } if (somethingToSend) { answer.set("player", player); - device.sendPackage(answer); + device()->sendPackage(answer); } return true; } -void MprisControlPackageInterface::sendPlayerList(const Device* device) +void MprisControlPlugin::sendPlayerList() { NetworkPackage np(PACKAGE_TYPE_MPRIS); np.set("playerList",playerList.keys()); - if (device == NULL) Q_EMIT sendPackage(np); - else device->sendPackage(np); + device()->sendPackage(np); } diff --git a/daemon/plugins/mpris/mpriscontrolpackageinterface.h b/daemon/plugins/mpriscontrol/mpriscontrolplugin.h similarity index 84% rename from daemon/plugins/mpris/mpriscontrolpackageinterface.h rename to daemon/plugins/mpriscontrol/mpriscontrolplugin.h index 51604b8c5..656f7f482 100644 --- a/daemon/plugins/mpris/mpriscontrolpackageinterface.h +++ b/daemon/plugins/mpriscontrol/mpriscontrolplugin.h @@ -21,22 +21,24 @@ #ifndef MPRISCONTROLPACKAGEINTERFACE_H #define MPRISCONTROLPACKAGEINTERFACE_H -#include "packageinterface.h" -#include "mprisdbusinterface.h" - #include #include #include #include -class MprisControlPackageInterface - : public PackageInterface +#include "../kdeconnectplugin.h" +#include "mprisdbusinterface.h" + +class MprisControlPlugin + : public KdeConnectPlugin { Q_OBJECT public: - MprisControlPackageInterface(); - virtual bool receivePackage(const Device& device, const NetworkPackage& np); + explicit MprisControlPlugin(QObject *parent, const QVariantList &args); + +public Q_SLOTS: + virtual bool receivePackage(const NetworkPackage& np); private Q_SLOTS: void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner); @@ -46,7 +48,7 @@ private: QHash playerList; void addPlayer(const QString& ifaceName); void removePlayer(const QString& ifaceName); - void sendPlayerList(const Device* device = 0); + void sendPlayerList(); int prevVolume; }; diff --git a/daemon/plugins/mpris/mprisdbusinterface.xml b/daemon/plugins/mpriscontrol/mprisdbusinterface.xml similarity index 96% rename from daemon/plugins/mpris/mprisdbusinterface.xml rename to daemon/plugins/mpriscontrol/mprisdbusinterface.xml index 2aaa851f9..652ff0a30 100644 --- a/daemon/plugins/mpris/mprisdbusinterface.xml +++ b/daemon/plugins/mpriscontrol/mprisdbusinterface.xml @@ -28,7 +28,7 @@ - + diff --git a/daemon/plugins/mpris/propertiesInterface.xml b/daemon/plugins/mpriscontrol/propertiesInterface.xml similarity index 100% rename from daemon/plugins/mpris/propertiesInterface.xml rename to daemon/plugins/mpriscontrol/propertiesInterface.xml diff --git a/daemon/plugins/pausemusic/CMakeLists.txt b/daemon/plugins/pausemusic/CMakeLists.txt new file mode 100644 index 000000000..d1afc2fa7 --- /dev/null +++ b/daemon/plugins/pausemusic/CMakeLists.txt @@ -0,0 +1,20 @@ +find_package(KDE4 REQUIRED) +include (KDE4Defaults) +include_directories(${KDE4_INCLUDES}) + +set(kdeconnect_pausemusic_SRCS + pausemusicplugin.cpp + ../kdeconnectplugin.cpp +) + +kde4_add_plugin(kdeconnect_pausemusic ${kdeconnect_pausemusic_SRCS}) + +target_link_libraries(kdeconnect_pausemusic + ${KDE4_KDECORE_LIBS} + ${KDE4_KDEUI_LIBS} + ${QT_QTNETWORK_LIBRARY} + qjson +) + +install(TARGETS kdeconnect_pausemusic DESTINATION ${PLUGIN_INSTALL_DIR} ) +install(FILES kdeconnect_pausemusic.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/daemon/plugins/pausemusic/kdeconnect_pausemusic.desktop b/daemon/plugins/pausemusic/kdeconnect_pausemusic.desktop new file mode 100644 index 000000000..f28563c7f --- /dev/null +++ b/daemon/plugins/pausemusic/kdeconnect_pausemusic.desktop @@ -0,0 +1,15 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Service +ServiceTypes=KdeConnect/Plugin +X-KDE-Library=kdeconnect_pausemusic +X-KDE-PluginInfo-Author=Albert Vaca +X-KDE-PluginInfo-Email=albertvaka@gmail.com +X-KDE-PluginInfo-Name=kdeconnect_pausemusic +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-Website=http://albertvaka.wordpress.com +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true +Icon=speaker +Name=Pause music on call +Comment=Pause music during a phone call