[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:27:43 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=02e18a9
The following commit has been merged in the master branch:
commit 02e18a97593af05fb1e8838eb7a146c2a15e9fa3
Author: Aleix Pol <aleixpol at kde.org>
Date: Mon Jun 23 18:15:10 2014 +0200
Extend kdeconnect-cli
Make it show whether devices are paired.
Let it un/pair devices.
Reviewed by Albert Vaca
---
cli/kdeconnect-cli.cpp | 42 +++++++++++++++++++++++++++++++-----------
1 file changed, 31 insertions(+), 11 deletions(-)
diff --git a/cli/kdeconnect-cli.cpp b/cli/kdeconnect-cli.cpp
index 184ef7e..d7f0da3 100644
--- a/cli/kdeconnect-cli.cpp
+++ b/cli/kdeconnect-cli.cpp
@@ -23,20 +23,23 @@
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <interfaces/devicesmodel.h>
+#include <interfaces/dbusinterfaces.h>
#include <iostream>
#include <QDBusMessage>
#include <QDBusConnection>
int main(int argc, char** argv)
{
- KAboutData about("kctool", "kdeconnect-cli", ki18n(("kctool")), "1.0", ki18n("KDE Connect CLI tool"),
+ KAboutData about("kdeconnect-cli", "kdeconnect-cli", ki18n(("kdeconnect-cli")), "1.0", ki18n("KDE Connect CLI tool"),
KAboutData::License_GPL, ki18n("(C) 2013 Aleix Pol Gonzalez"));
about.addAuthor( ki18n("Aleix Pol Gonzalez"), KLocalizedString(), "aleixpol at kde.org" );
KCmdLineArgs::init(argc, argv, &about);
KCmdLineOptions options;
options.add("l")
.add("list-devices", ki18n("List all devices"));
- options.add("share <path>", ki18n("Share a file"));
+ options.add("share <path>", ki18n("Share a file to a said device"));
+ options.add("pair", ki18n("Request pairing to a said device"));
+ options.add("unpair", ki18n("Stop pairing to a said device"));
options.add("device <dev>", ki18n("Device ID"));
KCmdLineArgs::addCmdLineOptions( options );
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
@@ -46,8 +49,10 @@ int main(int argc, char** argv)
devices.setDisplayFilter(DevicesModel::StatusUnknown);
for(int i=0, rows=devices.rowCount(); i<rows; ++i) {
QModelIndex idx = devices.index(i);
+ bool isParied = idx.data(DevicesModel::IsPairedRole).toBool();
+
std::cout << "- " << idx.data(Qt::DisplayRole).toString().toStdString()
- << ": " << idx.data(DevicesModel::IdModelRole).toString().toStdString() << std::endl;
+ << ": " << idx.data(DevicesModel::IdModelRole).toString().toStdString() << (isParied ? " (paired)" : "") << std::endl;
}
std::cout << devices.rowCount() << " devices found" << std::endl;
} else {
@@ -59,14 +64,29 @@ int main(int argc, char** argv)
QUrl url;
if(args->isSet("share")) {
url = args->makeURL(args->getOption("share").toLatin1());
- }
- args->clear();
-
- if(!url.isEmpty() && !device.isEmpty()) {
- 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);
+ args->clear();
+ if(!url.isEmpty() && !device.isEmpty()) {
+ 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
+ KCmdLineArgs::usageError(i18n("Couldn't share %1", url.toString()));
+ } else if(args->isSet("pair")) {
+ DeviceDbusInterface dev(device);
+ if(dev.isPaired())
+ std::cout << "Already paired" << std::endl;
+ else {
+ QDBusPendingReply<void> req = dev.requestPair();
+ req.waitForFinished();
+ }
+ } else if(args->isSet("unpair")) {
+ DeviceDbusInterface dev(device);
+ if(!dev.isPaired())
+ std::cout << "Already not paired" << std::endl;
+ else {
+ QDBusPendingReply<void> req = dev.unpair();
+ req.waitForFinished();
+ }
} else
KCmdLineArgs::usageError(i18n("Nothing to be done with the device"));
}
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list