From 86e5cd48a0074c185f43c657cc4e95763360d78e Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Thu, 29 Nov 2018 20:20:56 +0000 Subject: [PATCH] Suppoer sharing text from kdeconnect-cli Summary: Can be used with the share-text argument like kdeconnect-cli -d adsjsakldsjsa --share-text "hello" Reviewers: #kde_connect, albertvaka Reviewed By: #kde_connect, albertvaka Subscribers: kdeconnect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D17242 --- cli/kdeconnect-cli.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cli/kdeconnect-cli.cpp b/cli/kdeconnect-cli.cpp index f44001d20..345b22239 100644 --- a/cli/kdeconnect-cli.cpp +++ b/cli/kdeconnect-cli.cpp @@ -60,6 +60,7 @@ int main(int argc, char** argv) parser.addOption(QCommandLineOption(QStringLiteral("ping"), i18n("Sends a ping to said device"))); parser.addOption(QCommandLineOption(QStringLiteral("ping-msg"), i18n("Same as ping but you can set the message to display"), i18n("message"))); parser.addOption(QCommandLineOption(QStringLiteral("share"), i18n("Share a file to a said device"), QStringLiteral("path"))); + parser.addOption(QCommandLineOption(QStringLiteral("share-text"), i18n("Share text to a said device"), QStringLiteral("text"))); parser.addOption(QCommandLineOption(QStringLiteral("list-notifications"), i18n("Display the notifications on a said device"))); parser.addOption(QCommandLineOption(QStringLiteral("lock"), i18n("Lock the specified device"))); parser.addOption(QCommandLineOption(QStringLiteral("send-sms"), i18n("Sends an SMS. Requires destination"), i18n("message"))); @@ -168,6 +169,11 @@ int main(int argc, char** argv) for (const QString& url : qAsConst(urls)) { QTextStream(stdout) << i18n("Shared %1", url) << endl; } + } else if (parser.isSet(QStringLiteral("share-text"))) { + QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+device+"/share", QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareText")); + msg.setArguments(QVariantList() << parser.value(QStringLiteral("share-text"))); + blockOnReply(QDBusConnection::sessionBus().asyncCall(msg)); + QTextStream(stdout) << i18n("Shared text: %1", parser.value(QStringLiteral("share-text"))) << endl; } else if(parser.isSet(QStringLiteral("pair"))) { DeviceDbusInterface dev(device); if (!dev.isReachable()) {