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

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:29:46 UTC 2016


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

The following commit has been merged in the master branch:
commit c7429b56b79c07ca5d1cb7db33c1ca7bb424f54f
Author: Aleix Pol <aleixpol at kde.org>
Date:   Sun Jun 5 23:31:13 2016 +0200

    In the CLI interface, make it possible to refer a device by name
    
    Only works with trusted devices
---
 cli/kdeconnect-cli.cpp | 13 +++++++++++--
 core/daemon.cpp        |  9 +++++++++
 core/daemon.h          |  2 ++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/cli/kdeconnect-cli.cpp b/cli/kdeconnect-cli.cpp
index bb3f11f..776ff13 100644
--- a/cli/kdeconnect-cli.cpp
+++ b/cli/kdeconnect-cli.cpp
@@ -60,6 +60,7 @@ int main(int argc, char** argv)
     parser.addOption(QCommandLineOption("list-notifications", i18n("Display the notifications on a said device")));
     parser.addOption(QCommandLineOption("lock", i18n("Lock the specified device")));
     parser.addOption(QCommandLineOption(QStringList("device") << "d", i18n("Device ID"), "dev"));
+    parser.addOption(QCommandLineOption(QStringList("name") << "n", i18n("Device Name"), "name"));
     parser.addOption(QCommandLineOption("encryption-info", i18n("Get encryption info about said device")));
     about.setupCommandLine(&parser);
 
@@ -110,10 +111,18 @@ int main(int argc, char** argv)
         QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect", "org.kde.kdeconnect.daemon", "forceOnNetworkChange");
         QDBusConnection::sessionBus().call(msg);
     } else {
-        if(!parser.isSet("device")) {
+        QString device = parser.value("device");
+        if (device.isEmpty() && parser.isSet("name")) {
+            device = iface.deviceIdByName(parser.value("name"));
+            if (device.isEmpty()) {
+                QTextStream(stderr) << "Couldn't find device: " << parser.value("name") << endl;
+                return 1;
+            }
+        }
+
+        if(device.isEmpty()) {
             QTextStream(stderr) << i18n("No device specified") << endl;
         }
-        const QString device = parser.value("device");
         if(parser.isSet("share")) {
             QUrl url = QUrl::fromUserInput(parser.value("share"), QDir::currentPath());
             parser.clearPositionalArguments();
diff --git a/core/daemon.cpp b/core/daemon.cpp
index 9d4bb43..b41616c 100644
--- a/core/daemon.cpp
+++ b/core/daemon.cpp
@@ -241,6 +241,15 @@ bool Daemon::isDiscoveringDevices() const
     return !d->mDiscoveryModeAcquisitions.isEmpty();
 }
 
+QString Daemon::deviceIdByName(const QString &name) const
+{
+    foreach(Device* d, d->mDevices) {
+        if (d->name() == name && d->isTrusted())
+            return d->id();
+    }
+    return {};
+}
+
 Daemon::~Daemon()
 {
 
diff --git a/core/daemon.h b/core/daemon.h
index 6cc43af..1addbe4 100644
--- a/core/daemon.h
+++ b/core/daemon.h
@@ -70,6 +70,8 @@ public Q_SLOTS:
     //Returns a list of ids. The respective devices can be manipulated using the dbus path: "/modules/kdeconnect/Devices/"+id
     Q_SCRIPTABLE QStringList devices(bool onlyReachable = false, bool onlyPaired = false) const;
 
+    Q_SCRIPTABLE QString deviceIdByName(const QString &name) const;
+
 Q_SIGNALS:
     Q_SCRIPTABLE void deviceAdded(const QString& id);
     Q_SCRIPTABLE void deviceRemoved(const QString& id); //Note that paired devices will never be removed

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list