Changeset View
Changeset View
Standalone View
Standalone View
cli/kdeconnect-cli.cpp
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 38 | { | |||
---|---|---|---|---|---|
55 | parser.addOption(QCommandLineOption(QStringLiteral("id-name-only"), i18n("Make --list-devices or --list-available print only the devices id and name, to ease scripting"))); | 55 | parser.addOption(QCommandLineOption(QStringLiteral("id-name-only"), i18n("Make --list-devices or --list-available print only the devices id and name, to ease scripting"))); | ||
56 | parser.addOption(QCommandLineOption(QStringLiteral("refresh"), i18n("Search for devices in the network and re-establish connections"))); | 56 | parser.addOption(QCommandLineOption(QStringLiteral("refresh"), i18n("Search for devices in the network and re-establish connections"))); | ||
57 | parser.addOption(QCommandLineOption(QStringLiteral("pair"), i18n("Request pairing to a said device"))); | 57 | parser.addOption(QCommandLineOption(QStringLiteral("pair"), i18n("Request pairing to a said device"))); | ||
58 | parser.addOption(QCommandLineOption(QStringLiteral("ring"), i18n("Find the said device by ringing it."))); | 58 | parser.addOption(QCommandLineOption(QStringLiteral("ring"), i18n("Find the said device by ringing it."))); | ||
59 | parser.addOption(QCommandLineOption(QStringLiteral("unpair"), i18n("Stop pairing to a said device"))); | 59 | parser.addOption(QCommandLineOption(QStringLiteral("unpair"), i18n("Stop pairing to a said device"))); | ||
60 | parser.addOption(QCommandLineOption(QStringLiteral("ping"), i18n("Sends a ping to said device"))); | 60 | parser.addOption(QCommandLineOption(QStringLiteral("ping"), i18n("Sends a ping to said device"))); | ||
61 | parser.addOption(QCommandLineOption(QStringLiteral("ping-msg"), i18n("Same as ping but you can set the message to display"), i18n("message"))); | 61 | parser.addOption(QCommandLineOption(QStringLiteral("ping-msg"), i18n("Same as ping but you can set the message to display"), i18n("message"))); | ||
62 | parser.addOption(QCommandLineOption(QStringLiteral("share"), i18n("Share a file to a said device"), QStringLiteral("path"))); | 62 | parser.addOption(QCommandLineOption(QStringLiteral("share"), i18n("Share a file to a said device"), QStringLiteral("path"))); | ||
63 | parser.addOption(QCommandLineOption(QStringLiteral("share-text"), i18n("Share text to a said device"), QStringLiteral("text"))); | ||||
63 | parser.addOption(QCommandLineOption(QStringLiteral("list-notifications"), i18n("Display the notifications on a said device"))); | 64 | parser.addOption(QCommandLineOption(QStringLiteral("list-notifications"), i18n("Display the notifications on a said device"))); | ||
64 | parser.addOption(QCommandLineOption(QStringLiteral("lock"), i18n("Lock the specified device"))); | 65 | parser.addOption(QCommandLineOption(QStringLiteral("lock"), i18n("Lock the specified device"))); | ||
65 | parser.addOption(QCommandLineOption(QStringLiteral("send-sms"), i18n("Sends an SMS. Requires destination"), i18n("message"))); | 66 | parser.addOption(QCommandLineOption(QStringLiteral("send-sms"), i18n("Sends an SMS. Requires destination"), i18n("message"))); | ||
66 | parser.addOption(QCommandLineOption(QStringLiteral("destination"), i18n("Phone number to send the message"), i18n("phone number"))); | 67 | parser.addOption(QCommandLineOption(QStringLiteral("destination"), i18n("Phone number to send the message"), i18n("phone number"))); | ||
67 | parser.addOption(QCommandLineOption(QStringList(QStringLiteral("device")) << QStringLiteral("d"), i18n("Device ID"), QStringLiteral("dev"))); | 68 | parser.addOption(QCommandLineOption(QStringList(QStringLiteral("device")) << QStringLiteral("d"), i18n("Device ID"), QStringLiteral("dev"))); | ||
68 | parser.addOption(QCommandLineOption(QStringList(QStringLiteral("name")) << QStringLiteral("n"), i18n("Device Name"), QStringLiteral("name"))); | 69 | parser.addOption(QCommandLineOption(QStringList(QStringLiteral("name")) << QStringLiteral("n"), i18n("Device Name"), QStringLiteral("name"))); | ||
69 | parser.addOption(QCommandLineOption(QStringLiteral("encryption-info"), i18n("Get encryption info about said device"))); | 70 | parser.addOption(QCommandLineOption(QStringLiteral("encryption-info"), i18n("Get encryption info about said device"))); | ||
70 | parser.addOption(QCommandLineOption(QStringLiteral("list-commands"), i18n("Lists remote commands and their ids"))); | 71 | parser.addOption(QCommandLineOption(QStringLiteral("list-commands"), i18n("Lists remote commands and their ids"))); | ||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Line(s) | 150 | if (parser.isSet(QStringLiteral("share"))) { | |||
159 | } | 160 | } | ||
160 | 161 | | |||
161 | for (const QUrl& url : urls) { | 162 | for (const QUrl& url : urls) { | ||
162 | QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+device+"/share", QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareUrl")); | 163 | QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+device+"/share", QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareUrl")); | ||
163 | msg.setArguments(QVariantList() << url.toString()); | 164 | msg.setArguments(QVariantList() << url.toString()); | ||
164 | blockOnReply(QDBusConnection::sessionBus().asyncCall(msg)); | 165 | blockOnReply(QDBusConnection::sessionBus().asyncCall(msg)); | ||
165 | QTextStream(stdout) << i18n("Shared %1", url.toString()) << endl; | 166 | QTextStream(stdout) << i18n("Shared %1", url.toString()) << endl; | ||
166 | } | 167 | } | ||
168 | } else if (parser.isSet(QStringLiteral("share-text"))) { | ||||
169 | QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+device+"/share", QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareText")); | ||||
170 | msg.setArguments(QVariantList() << parser.value(QStringLiteral("share-text"))); | ||||
171 | blockOnReply(QDBusConnection::sessionBus().asyncCall(msg)); | ||||
172 | QTextStream(stdout) << i18n("Shared text: %1", parser.value(QStringLiteral("share-text"))) << endl; | ||||
167 | } else if(parser.isSet(QStringLiteral("pair"))) { | 173 | } else if(parser.isSet(QStringLiteral("pair"))) { | ||
168 | DeviceDbusInterface dev(device); | 174 | DeviceDbusInterface dev(device); | ||
169 | if (!dev.isReachable()) { | 175 | if (!dev.isReachable()) { | ||
170 | //Device doesn't exist, go into discovery mode and wait up to 30 seconds for the device to appear | 176 | //Device doesn't exist, go into discovery mode and wait up to 30 seconds for the device to appear | ||
171 | QEventLoop wait; | 177 | QEventLoop wait; | ||
172 | QTextStream(stderr) << i18n("waiting for device...") << endl; | 178 | QTextStream(stderr) << i18n("waiting for device...") << endl; | ||
173 | blockOnReply(iface.acquireDiscoveryMode(id)); | 179 | blockOnReply(iface.acquireDiscoveryMode(id)); | ||
174 | 180 | | |||
▲ Show 20 Lines • Show All 94 Lines • Show Last 20 Lines |