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

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


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

The following commit has been merged in the master branch:
commit 0cb24acbc03b7eef80a9b3e8f01e5722addc3c59
Author: Albert Vaca <albertvaka at gmail.com>
Date:   Tue Feb 24 22:13:30 2015 -0800

    Improved kdeconnect-cli, adding parameters to ease scripting.
    
    Also:
    Added some missing i18n calls.
    Using QTextStream(stderr) instead of qCritical() to avoid "quoted output".
---
 cli/kdeconnect-cli.cpp | 61 +++++++++++++++++++++++++++++++-------------------
 1 file changed, 38 insertions(+), 23 deletions(-)

diff --git a/cli/kdeconnect-cli.cpp b/cli/kdeconnect-cli.cpp
index b30576c..70a894e 100644
--- a/cli/kdeconnect-cli.cpp
+++ b/cli/kdeconnect-cli.cpp
@@ -45,6 +45,8 @@ int main(int argc, char** argv)
     about.addAuthor( i18n("Albert Vaca Cintora"), QString(), "albertvaka at gmail.com" );
     QCommandLineParser parser;
     parser.addOption(QCommandLineOption(QStringList("l") << "list-devices", i18n("List all devices")));
+    parser.addOption(QCommandLineOption(QStringList("a") << "list-available", i18n("List available (paired and reachable) devices")));
+    parser.addOption(QCommandLineOption("id-only", i18n("Make --list-devices or --list-available print only the devices id, to ease scripting")));
     parser.addOption(QCommandLineOption("refresh", i18n("Search for devices in the network and re-establishe connections")));
     parser.addOption(QCommandLineOption("pair", i18n("Request pairing to a said device")));
     parser.addOption(QCommandLineOption("unpair", i18n("Stop pairing to a said device")));
@@ -59,33 +61,45 @@ int main(int argc, char** argv)
     parser.process(app);
     about.processCommandLine(&parser);
 
-    if(parser.isSet("l")) {
+    if(parser.isSet("l") || parser.isSet("a")) {
         DevicesModel devices;
-        for(int i=0, rows=devices.rowCount(); i<rows; ++i) {
+        if (parser.isSet("a")) {
+            devices.setDisplayFilter(DevicesModel::StatusFlag::StatusPaired | DevicesModel::StatusFlag::StatusReachable);
+        }
+        int deviceCount = devices.rowCount();
+        for(int i=0; i < deviceCount; ++i) {
             QModelIndex idx = devices.index(i);
-            QString statusInfo;
-            switch(idx.data(DevicesModel::StatusModelRole).toInt()) {
-                case DevicesModel::StatusPaired:
-                    statusInfo = "(paired)";
-                    break;
-                case DevicesModel::StatusReachable:
-                    statusInfo = "(reachable)";
-                    break;
-                case DevicesModel::StatusReachable | DevicesModel::StatusPaired:
-                    statusInfo = "(paired and reachable)";
-                    break;
+            if (parser.isSet("id-only")) {
+                QTextStream(stdout) << idx.data(DevicesModel::ModelRoles::IdModelRole).toString() << endl;
+            } else {
+                QString statusInfo;
+                switch(idx.data(DevicesModel::StatusModelRole).toInt()) {
+                    case DevicesModel::StatusPaired:
+                        statusInfo = i18n("(paired)");
+                        break;
+                    case DevicesModel::StatusReachable:
+                        statusInfo = i18n("(reachable)");
+                        break;
+                    case DevicesModel::StatusReachable | DevicesModel::StatusPaired:
+                        statusInfo = i18n("(paired and reachable)");
+                        break;
+                }
+                QTextStream(stdout) << "- " << idx.data(Qt::DisplayRole).toString()
+                        << ": " << idx.data(DevicesModel::IdModelRole).toString() << ' ' << statusInfo << endl;
             }
-            QTextStream(stdout) << "- " << idx.data(Qt::DisplayRole).toString()
-                      << ": " << idx.data(DevicesModel::IdModelRole).toString() << ' ' << statusInfo << endl;
         }
-        QTextStream(stdout) << devices.rowCount() << " devices found" << endl;
+        if (!parser.isSet("id-only")) {
+            QTextStream(stdout) << i18n("%1 device(s) found", deviceCount) << endl;
+        } else if (!deviceCount) {
+            QTextStream(stderr) << i18n("No devices found") << endl;
+        }
     } else if(parser.isSet("refresh")) {
         QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect", "org.kde.kdeconnect.daemon", "forceOnNetworkChange");
         QDBusConnection::sessionBus().call(msg);
     } else {
         QString device;
         if(!parser.isSet("device")) {
-            qCritical() << (i18n("No device specified"));
+            QTextStream(stderr) << i18n("No device specified") << endl;
         }
         device = parser.value("device");
         QUrl url;
@@ -96,12 +110,13 @@ int main(int argc, char** argv)
                 QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+device+"/share", "org.kde.kdeconnect.device.share", "shareUrl");
                 msg.setArguments(QVariantList() << url.toString());
                 QDBusConnection::sessionBus().call(msg);
-            } else
-                qCritical() << (i18n("Couldn't share %1", url.toString()));
+            } else {
+                QTextStream(stderr) << (i18n("Couldn't share %1", url.toString())) << endl;
+            }
         } else if(parser.isSet("pair")) {
             DeviceDbusInterface dev(device);
             if(dev.isPaired())
-                QTextStream(stdout) << "Already paired" << endl;
+                QTextStream(stderr) << i18n("Already paired") << endl;
             else {
                 QDBusPendingReply<void> req = dev.requestPair();
                 req.waitForFinished();
@@ -109,7 +124,7 @@ int main(int argc, char** argv)
         } else if(parser.isSet("unpair")) {
             DeviceDbusInterface dev(device);
             if(!dev.isPaired())
-                QTextStream(stdout) << "Already not paired" << endl;
+                QTextStream(stderr) << i18n("Already not paired") << endl;
             else {
                 QDBusPendingReply<void> req = dev.unpair();
                 req.waitForFinished();
@@ -127,10 +142,10 @@ int main(int argc, char** argv)
             for(int i=0, rows=notifications.rowCount(); i<rows; ++i) {
                 QModelIndex idx = notifications.index(i);
                 QTextStream(stdout) << "- " << idx.data(NotificationsModel::AppNameModelRole).toString()
-                << ": " << idx.data(NotificationsModel::NameModelRole).toString() << endl;
+                    << ": " << idx.data(NotificationsModel::NameModelRole).toString() << endl;
             }
         } else {
-            qCritical() << i18n("Nothing to be done with the device");
+            QTextStream(stderr) << i18n("Nothing to be done") << endl;
         }
     }
     QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection);

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list