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

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:27:40 UTC 2016


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

The following commit has been merged in the master branch:
commit 6ce0b6b874e4f02625c61c7ffafc8ce986f40c0c
Author: Aleix Pol <aleixpol at kde.org>
Date:   Sat Jun 14 20:35:00 2014 +0200

    Document in the desktop files the outgoing types for the plugins
    
    This way we narrow the things a plugin can send, to its own scope. Still
    every plugin can set a list of types, so it should be ok.
---
 core/device.cpp                                    | 23 ++++++++++++++--------
 core/device.h                                      |  3 ++-
 core/kdeconnectplugin.cpp                          | 14 ++++++++++++-
 core/kdeconnectplugin.h                            |  4 +++-
 core/pluginloader.cpp                              |  5 +++--
 core/pluginloader.h                                |  3 ++-
 plugins/battery/batteryplugin.cpp                  |  2 +-
 plugins/battery/kdeconnect_battery.desktop         |  1 +
 plugins/clipboard/clipboardplugin.cpp              |  2 +-
 plugins/kdeconnect_plugin.desktop                  |  3 +++
 .../mpriscontrol/kdeconnect_mpriscontrol.desktop   |  1 +
 plugins/mpriscontrol/mpriscontrolplugin.cpp        |  6 +++---
 .../notifications/kdeconnect_notifications.desktop |  1 +
 .../notifications/notificationsdbusinterface.cpp   |  9 +++++----
 plugins/notifications/notificationsdbusinterface.h |  5 +++--
 plugins/notifications/notificationsplugin.cpp      |  4 ++--
 plugins/ping/kdeconnect_ping.desktop               |  1 +
 plugins/sftp/kdeconnect_sftp.desktop               |  1 +
 plugins/sftp/mounter.cpp                           |  2 +-
 plugins/share/kdeconnect_share.desktop             |  1 +
 plugins/share/shareplugin.cpp                      |  2 +-
 plugins/telephony/kdeconnect_telephony.desktop     |  1 +
 22 files changed, 65 insertions(+), 29 deletions(-)

diff --git a/core/device.cpp b/core/device.cpp
index 65c5809..429ab75 100644
--- a/core/device.cpp
+++ b/core/device.cpp
@@ -105,7 +105,8 @@ QStringList Device::loadedPlugins() const
 void Device::reloadPlugins()
 {
     QMap<QString, KdeConnectPlugin*> newPluginMap;
-    QMultiMap<QString, KdeConnectPlugin*> newPluginsByInterface;
+    QMultiMap<QString, KdeConnectPlugin*> newPluginsByIncomingInterface;
+    QMultiMap<QString, KdeConnectPlugin*> newPluginsByOutgoingInterface;
 
     if (isPaired() && isReachable()) { //Do not load any plugin for unpaired devices, nor useless loading them for unreachable devices
 
@@ -123,16 +124,21 @@ void Device::reloadPlugins()
 
             if (isPluginEnabled) {
                 KdeConnectPlugin* plugin = m_plugins.take(pluginName);
-                QStringList interfaces;
+                QStringList incomingInterfaces, outgoingInterfaces;
                 if (plugin) {
-                    interfaces = m_pluginsByinterface.keys(plugin);
+                    incomingInterfaces = m_pluginsByIncomingInterface.keys(plugin);
+                    outgoingInterfaces = m_pluginsByOutgoingInterface.keys(plugin);
                 } else {
                     PluginData data = loader->instantiatePluginForDevice(pluginName, this);
                     plugin = data.plugin;
-                    interfaces = data.interfaces;
+                    incomingInterfaces = data.incomingInterfaces;
+                    outgoingInterfaces = data.outgoingInterfaces;
                 }
-                foreach(const QString& interface, interfaces) {
-                    newPluginsByInterface.insert(interface, plugin);
+                foreach(const QString& interface, incomingInterfaces) {
+                    newPluginsByIncomingInterface.insert(interface, plugin);
+                }
+                foreach(const QString& interface, outgoingInterfaces) {
+                    newPluginsByOutgoingInterface.insert(interface, plugin);
                 }
                 newPluginMap[pluginName] = plugin;
             }
@@ -143,7 +149,8 @@ void Device::reloadPlugins()
     //them anymore, otherwise they would have been moved to the newPluginMap)
     qDeleteAll(m_plugins);
     m_plugins = newPluginMap;
-    m_pluginsByinterface = newPluginsByInterface;
+    m_pluginsByIncomingInterface = newPluginsByIncomingInterface;
+    m_pluginsByOutgoingInterface = newPluginsByOutgoingInterface;
 
     Q_FOREACH(KdeConnectPlugin* plugin, m_plugins) {
         plugin->connected();
@@ -377,7 +384,7 @@ void Device::privateReceivedPackage(const NetworkPackage& np)
         }
 
     } else if (isPaired()) {
-        QList<KdeConnectPlugin*> plugins = m_pluginsByinterface.values(np.type());
+        QList<KdeConnectPlugin*> plugins = m_pluginsByIncomingInterface.values(np.type());
         foreach(KdeConnectPlugin* plugin, plugins) {
             plugin->receivePackage(np);
         }
diff --git a/core/device.h b/core/device.h
index 5ed1048..bfff085 100644
--- a/core/device.h
+++ b/core/device.h
@@ -132,7 +132,8 @@ private:
 
     QList<DeviceLink*> m_deviceLinks;
     QMap<QString, KdeConnectPlugin*> m_plugins;
-    QMultiMap<QString, KdeConnectPlugin*> m_pluginsByinterface;
+    QMultiMap<QString, KdeConnectPlugin*> m_pluginsByIncomingInterface;
+    QMultiMap<QString, KdeConnectPlugin*> m_pluginsByOutgoingInterface;
 
     QTimer m_pairingTimeut;
 
diff --git a/core/kdeconnectplugin.cpp b/core/kdeconnectplugin.cpp
index 0288bf7..620550b 100644
--- a/core/kdeconnectplugin.cpp
+++ b/core/kdeconnectplugin.cpp
@@ -23,6 +23,7 @@
 struct KdeConnectPluginPrivate
 {
     Device* mDevice;
+    QSet<QString> mOutgoingTypes;
 
     // The Initializer object sets things up, and also does cleanup when it goes out of scope
     // Since the plugins use their own memory, they need their own initializer in order to send encrypted packages
@@ -34,13 +35,14 @@ KdeConnectPlugin::KdeConnectPlugin(QObject* parent, const QVariantList& args)
     , d(new KdeConnectPluginPrivate)
 {
     d->mDevice = qvariant_cast< Device* >(args.first());
+    d->mOutgoingTypes = args.last().toStringList().toSet();
 }
 
 KdeConnectPlugin::~KdeConnectPlugin()
 {
 }
 
-Device* KdeConnectPlugin::device()
+const Device* KdeConnectPlugin::device()
 {
     return d->mDevice;
 }
@@ -49,3 +51,13 @@ Device const* KdeConnectPlugin::device() const
 {
     return d->mDevice;
 }
+
+bool KdeConnectPlugin::sendPackage(NetworkPackage& np) const
+{
+    if(!d->mOutgoingTypes.contains(np.type())) {
+        qWarning() << metaObject()->className() << "tried to send an unsupported package type" << np.type() << ". Supported:" << d->mOutgoingTypes;
+        return false;
+    }
+//     qWarning() << metaObject()->className() << "sends" << np.type() << ". Supported:" << d->mOutgoingTypes;
+    return d->mDevice->sendPackage(np);
+}
diff --git a/core/kdeconnectplugin.h b/core/kdeconnectplugin.h
index 3753c9c..d73491f 100644
--- a/core/kdeconnectplugin.h
+++ b/core/kdeconnectplugin.h
@@ -42,9 +42,11 @@ public:
     KdeConnectPlugin(QObject* parent, const QVariantList& args);
     virtual ~KdeConnectPlugin();
 
-    Device* device();
+    const Device* device();
     Device const* device() const;
 
+    bool sendPackage(NetworkPackage& np) const;
+
 public Q_SLOTS:
     /**
      * Returns true if it has handled the package in some way
diff --git a/core/pluginloader.cpp b/core/pluginloader.cpp
index b430c15..1c10c07 100644
--- a/core/pluginloader.cpp
+++ b/core/pluginloader.cpp
@@ -73,12 +73,13 @@ PluginData PluginLoader::instantiatePluginForDevice(const QString& name, Device*
         return ret;
     }
 
-    ret.interfaces = service->property("X-KdeConnect-SupportedPackageType", QVariant::StringList).toStringList();
+    ret.incomingInterfaces = service->property("X-KdeConnect-SupportedPackageType", QVariant::StringList).toStringList();
+    ret.outgoingInterfaces = service->property("X-KdeConnect-OutgoingPackageType", QVariant::StringList).toStringList();
 
     QVariant deviceVariant = QVariant::fromValue<Device*>(device);
 
     //FIXME any reason to use QObject in template param instead KdeConnectPlugin?
-    ret.plugin = factory->create<KdeConnectPlugin>(device, QVariantList() << deviceVariant);
+    ret.plugin = factory->create<KdeConnectPlugin>(device, QVariantList() << deviceVariant << ret.outgoingInterfaces);
     if (!ret.plugin) {
         kDebug(kdeconnect_kded()) << "Error loading plugin";
         return ret;
diff --git a/core/pluginloader.h b/core/pluginloader.h
index 1a03259..4983730 100644
--- a/core/pluginloader.h
+++ b/core/pluginloader.h
@@ -36,7 +36,8 @@ struct PluginData
 {
     PluginData() : plugin(0) {}
     KdeConnectPlugin* plugin;
-    QStringList interfaces;
+    QStringList incomingInterfaces;
+    QStringList outgoingInterfaces;
 };
 
 class PluginLoader
diff --git a/plugins/battery/batteryplugin.cpp b/plugins/battery/batteryplugin.cpp
index e188453..af3e47a 100644
--- a/plugins/battery/batteryplugin.cpp
+++ b/plugins/battery/batteryplugin.cpp
@@ -44,7 +44,7 @@ void BatteryPlugin::connected()
 {
     NetworkPackage np(PACKAGE_TYPE_BATTERY);
     np.set("request",true);
-    device()->sendPackage(np);
+    sendPackage(np);
 }
 
 BatteryPlugin::~BatteryPlugin()
diff --git a/plugins/battery/kdeconnect_battery.desktop b/plugins/battery/kdeconnect_battery.desktop
index 806d4d5..06f4aab 100644
--- a/plugins/battery/kdeconnect_battery.desktop
+++ b/plugins/battery/kdeconnect_battery.desktop
@@ -58,3 +58,4 @@ Comment[uk]=Показ даних щодо рівня заряду акумул
 Comment[x-test]=xxShow your phone battery next to your computer batteryxx
 
 X-KdeConnect-SupportedPackageType=kdeconnect.battery
+X-KdeConnect-OutgoingPackageType=kdeconnect.battery
diff --git a/plugins/clipboard/clipboardplugin.cpp b/plugins/clipboard/clipboardplugin.cpp
index 9acfa76..bb31bb5 100644
--- a/plugins/clipboard/clipboardplugin.cpp
+++ b/plugins/clipboard/clipboardplugin.cpp
@@ -45,7 +45,7 @@ void ClipboardPlugin::clipboardChanged(QClipboard::Mode mode)
     //kDebug(kdeconnect_kded()) << "ClipboardChanged";
     NetworkPackage np(PACKAGE_TYPE_CLIPBOARD);
     np.set("content",clipboard->text());
-    device()->sendPackage(np);
+    sendPackage(np);
 }
 
 bool ClipboardPlugin::receivePackage(const NetworkPackage& np)
diff --git a/plugins/kdeconnect_plugin.desktop b/plugins/kdeconnect_plugin.desktop
index 5fe070c..017917b 100644
--- a/plugins/kdeconnect_plugin.desktop
+++ b/plugins/kdeconnect_plugin.desktop
@@ -29,3 +29,6 @@ Name[x-test]=xxKDEConnect Pluginxx
 # mandatory, list of all the package types supported
 [PropertyDef::X-KdeConnect-SupportedPackageType]
 Type=QStringList
+
+[PropertyDef::X-KdeConnect-OutgoingPackageType]
+Type=QStringList
diff --git a/plugins/mpriscontrol/kdeconnect_mpriscontrol.desktop b/plugins/mpriscontrol/kdeconnect_mpriscontrol.desktop
index adee287..f7d3c24 100644
--- a/plugins/mpriscontrol/kdeconnect_mpriscontrol.desktop
+++ b/plugins/mpriscontrol/kdeconnect_mpriscontrol.desktop
@@ -57,3 +57,4 @@ Comment[uk]=Віддалене керування відтворенням му
 Comment[x-test]=xxRemote control your music and videosxx
 
 X-KdeConnect-SupportedPackageType=kdeconnect.mpris
+X-KdeConnect-OutgoingPackageType=kdeconnect.mpris
diff --git a/plugins/mpriscontrol/mpriscontrolplugin.cpp b/plugins/mpriscontrol/mpriscontrolplugin.cpp
index 8be5573..30a78c6 100644
--- a/plugins/mpriscontrol/mpriscontrolplugin.cpp
+++ b/plugins/mpriscontrol/mpriscontrolplugin.cpp
@@ -125,7 +125,7 @@ void MprisControlPlugin::propertiesChanged(const QString& propertyInterface, con
         const QString& service = interface->service();
         const QString& player = playerList.key(service);
         np.set("player", player);
-        device()->sendPackage(np);
+        sendPackage(np);
     }
 }
 
@@ -202,7 +202,7 @@ bool MprisControlPlugin::receivePackage (const NetworkPackage& np)
     }
     if (somethingToSend) {
         answer.set("player", player);
-        device()->sendPackage(answer);
+        sendPackage(answer);
     }
 
     return true;
@@ -213,5 +213,5 @@ void MprisControlPlugin::sendPlayerList()
 {
     NetworkPackage np(PACKAGE_TYPE_MPRIS);
     np.set("playerList",playerList.keys());
-    device()->sendPackage(np);
+    sendPackage(np);
 }
diff --git a/plugins/notifications/kdeconnect_notifications.desktop b/plugins/notifications/kdeconnect_notifications.desktop
index 279049a..3c11a28 100644
--- a/plugins/notifications/kdeconnect_notifications.desktop
+++ b/plugins/notifications/kdeconnect_notifications.desktop
@@ -58,3 +58,4 @@ Comment[uk]=Показ сповіщень з телефону у KDE та під
 Comment[x-test]=xxShow phone notifications in KDE and keep them in syncxx
 
 X-KdeConnect-SupportedPackageType=kdeconnect.notification
+X-KdeConnect-OutgoingPackageType=kdeconnect.notification
diff --git a/plugins/notifications/notificationsdbusinterface.cpp b/plugins/notifications/notificationsdbusinterface.cpp
index 25d1bc3..c5bdaeb 100644
--- a/plugins/notifications/notificationsdbusinterface.cpp
+++ b/plugins/notifications/notificationsdbusinterface.cpp
@@ -30,9 +30,10 @@
 #include <core/filetransferjob.h>
 #include "notificationsplugin.h"
 
-NotificationsDbusInterface::NotificationsDbusInterface(Device* device, QObject *parent)
-    : QDBusAbstractAdaptor(parent)
-    , mDevice(device)
+NotificationsDbusInterface::NotificationsDbusInterface(KdeConnectPlugin* plugin)
+    : QDBusAbstractAdaptor(plugin)
+    , mDevice(plugin->device())
+    , mPlugin(plugin)
     , mLastId(0)
     , imagesDir(QDir::temp().absoluteFilePath("kdeconnect"))
 {
@@ -134,7 +135,7 @@ void NotificationsDbusInterface::dismissRequested(Notification* notification)
 
     NetworkPackage np(PACKAGE_TYPE_NOTIFICATION);
     np.set<QString>("cancel", internalId);
-    mDevice->sendPackage(np);
+    mPlugin->sendPackage(np);
 
     //This should be called automatically back from server
     //removeNotification(internalId);
diff --git a/plugins/notifications/notificationsdbusinterface.h b/plugins/notifications/notificationsdbusinterface.h
index 019c02a..acd6736 100644
--- a/plugins/notifications/notificationsdbusinterface.h
+++ b/plugins/notifications/notificationsdbusinterface.h
@@ -37,7 +37,7 @@ class NotificationsDbusInterface
     Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.notifications")
 
 public:
-    explicit NotificationsDbusInterface(Device* device, QObject *parent);
+    explicit NotificationsDbusInterface(KdeConnectPlugin* plugin);
     virtual ~NotificationsDbusInterface();
 
     void processPackage(const NetworkPackage& np);
@@ -56,7 +56,8 @@ private /*methods*/:
     QString newId(); //Generates successive identifitiers to use as public ids
 
 private /*attributes*/:
-    Device* mDevice;
+    const Device* mDevice;
+    KdeConnectPlugin* mPlugin;
     QHash<QString, Notification*> mNotifications;
     QHash<QString, QString> mInternalIdToPublicId;
     int mLastId;
diff --git a/plugins/notifications/notificationsplugin.cpp b/plugins/notifications/notificationsplugin.cpp
index 0440584..67fa825 100644
--- a/plugins/notifications/notificationsplugin.cpp
+++ b/plugins/notifications/notificationsplugin.cpp
@@ -31,14 +31,14 @@ K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_notifications", "kdeconnect
 NotificationsPlugin::NotificationsPlugin(QObject* parent, const QVariantList& args)
     : KdeConnectPlugin(parent, args)
 {
-    notificationsDbusInterface = new NotificationsDbusInterface(device(), parent);
+    notificationsDbusInterface = new NotificationsDbusInterface(this);
 }
 
 void NotificationsPlugin::connected()
 {
     NetworkPackage np(PACKAGE_TYPE_NOTIFICATION);
     np.set("request", true);
-    device()->sendPackage(np);
+    sendPackage(np);
 }
 
 NotificationsPlugin::~NotificationsPlugin()
diff --git a/plugins/ping/kdeconnect_ping.desktop b/plugins/ping/kdeconnect_ping.desktop
index 556ef36..23bfe8e 100644
--- a/plugins/ping/kdeconnect_ping.desktop
+++ b/plugins/ping/kdeconnect_ping.desktop
@@ -59,3 +59,4 @@ Comment[uk]=Надсилання і отримання сигналів підт
 Comment[x-test]=xxSend and receive pingsxx
 
 X-KdeConnect-SupportedPackageType=kdeconnect.ping
+# X-KdeConnect-OutgoingPackageType=kdeconnect.ping
diff --git a/plugins/sftp/kdeconnect_sftp.desktop b/plugins/sftp/kdeconnect_sftp.desktop
index ae16262..84b9fda 100644
--- a/plugins/sftp/kdeconnect_sftp.desktop
+++ b/plugins/sftp/kdeconnect_sftp.desktop
@@ -49,3 +49,4 @@ Comment[uk]=Перегляд файлових систем на сторонні
 Comment[x-test]=xxBrowse the remote device filesystem using SFTPxx
 
 X-KdeConnect-SupportedPackageType=kdeconnect.sftp
+X-KdeConnect-OutgoingPackageType=kdeconnect.sftp
diff --git a/plugins/sftp/mounter.cpp b/plugins/sftp/mounter.cpp
index 8233399..de28e12 100644
--- a/plugins/sftp/mounter.cpp
+++ b/plugins/sftp/mounter.cpp
@@ -231,7 +231,7 @@ void Mounter::start()
     np.set("start", true);
     np.set("id", m_id);
     np.set("idleTimeout", m_idleTimer.interval());
-    m_sftp->device()->sendPackage(np);
+    m_sftp->sendPackage(np);
     
     m_connectTimer.start();
 }
diff --git a/plugins/share/kdeconnect_share.desktop b/plugins/share/kdeconnect_share.desktop
index 9a4c539..6c82d6a 100644
--- a/plugins/share/kdeconnect_share.desktop
+++ b/plugins/share/kdeconnect_share.desktop
@@ -50,3 +50,4 @@ Comment[uk]=Спрощене отримання і надсилання файл
 Comment[x-test]=xxReceive and send files, URLs or plain text easilyxx
 
 X-KdeConnect-SupportedPackageType=kdeconnect.share
+X-KdeConnect-OutgoingPackageType=kdeconnect.share
diff --git a/plugins/share/shareplugin.cpp b/plugins/share/shareplugin.cpp
index 6746573..8af0ae1 100644
--- a/plugins/share/shareplugin.cpp
+++ b/plugins/share/shareplugin.cpp
@@ -154,7 +154,7 @@ void SharePlugin::shareUrl(const QUrl& url)
     } else {
         package.set<QString>("url", url.toString());
     }
-    device()->sendPackage(package);
+    sendPackage(package);
 }
 
 void SharePlugin::connected()
diff --git a/plugins/telephony/kdeconnect_telephony.desktop b/plugins/telephony/kdeconnect_telephony.desktop
index 7bb6f9f..5df0cd3 100644
--- a/plugins/telephony/kdeconnect_telephony.desktop
+++ b/plugins/telephony/kdeconnect_telephony.desktop
@@ -58,3 +58,4 @@ Comment[uk]=Показ сповіщень щодо дзвінків і SMS (ск
 Comment[x-test]=xxShow notifications for calls and SMS (answering coming soon)xx
 
 X-KdeConnect-SupportedPackageType=kdeconnect.telephony
+X-KdeConnect-OutgoingPackageType=

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list