Changeset View
Changeset View
Standalone View
Standalone View
cli/kdeconnect-cli.cpp
Show First 20 Lines • Show All 245 Lines • ▼ Show 20 Line(s) | 245 | } else if(parser.isSet(QStringLiteral("list-notifications"))) { | |||
---|---|---|---|---|---|
246 | NotificationsModel notifications; | 246 | NotificationsModel notifications; | ||
247 | notifications.setDeviceId(device); | 247 | notifications.setDeviceId(device); | ||
248 | for(int i=0, rows=notifications.rowCount(); i<rows; ++i) { | 248 | for(int i=0, rows=notifications.rowCount(); i<rows; ++i) { | ||
249 | QModelIndex idx = notifications.index(i); | 249 | QModelIndex idx = notifications.index(i); | ||
250 | QTextStream(stdout) << "- " << idx.data(NotificationsModel::AppNameModelRole).toString() | 250 | QTextStream(stdout) << "- " << idx.data(NotificationsModel::AppNameModelRole).toString() | ||
251 | << ": " << idx.data(NotificationsModel::NameModelRole).toString() << endl; | 251 | << ": " << idx.data(NotificationsModel::NameModelRole).toString() << endl; | ||
252 | } | 252 | } | ||
253 | } else if(parser.isSet(QStringLiteral("list-commands"))) { | 253 | } else if(parser.isSet(QStringLiteral("list-commands"))) { | ||
254 | RemoteCommandsDbusInterface iface(device); | 254 | DeviceRemotecommandsDbusInterface iface(device); | ||
255 | const auto cmds = QJsonDocument::fromJson(iface.commands()).object(); | 255 | QStringList commandIds = iface.commands(); | ||
256 | for (auto it = cmds.constBegin(), itEnd = cmds.constEnd(); it!=itEnd; ++it) { | 256 | | ||
257 | const QJsonObject cont = it->toObject(); | 257 | for (const QString& id : commandIds) { | ||
258 | QTextStream(stdout) << it.key() << ": " << cont.value(QStringLiteral("name")).toString() << ": " << cont.value(QStringLiteral("command")).toString() << endl; | 258 | RemotecommandDbusInterface command(device, id, &app); | ||
259 | QTextStream(stdout) << id << ": " << command.name() << ": " << command.command() << endl; | ||||
259 | } | 260 | } | ||
260 | } else if(parser.isSet(QStringLiteral("execute-command"))) { | 261 | } else if(parser.isSet(QStringLiteral("execute-command"))) { | ||
261 | RemoteCommandsDbusInterface iface(device); | 262 | DeviceRemotecommandsDbusInterface iface(device); | ||
262 | blockOnReply(iface.triggerCommand(parser.value(QStringLiteral("execute-command")))); | 263 | blockOnReply(iface.triggerCommand(parser.value(QStringLiteral("execute-command")))); | ||
263 | } else if(parser.isSet(QStringLiteral("encryption-info"))) { | 264 | } else if(parser.isSet(QStringLiteral("encryption-info"))) { | ||
264 | DeviceDbusInterface dev(device); | 265 | DeviceDbusInterface dev(device); | ||
265 | QString info = blockOnReply<QString>(dev.encryptionInfo()); // QSsl::Der = 1 | 266 | QString info = blockOnReply<QString>(dev.encryptionInfo()); // QSsl::Der = 1 | ||
266 | QTextStream(stdout) << info << endl; | 267 | QTextStream(stdout) << info << endl; | ||
267 | } else { | 268 | } else { | ||
268 | QTextStream(stderr) << i18n("Nothing to be done") << endl; | 269 | QTextStream(stderr) << i18n("Nothing to be done") << endl; | ||
269 | } | 270 | } | ||
270 | } | 271 | } | ||
271 | QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection); | 272 | QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection); | ||
272 | 273 | | |||
273 | return app.exec(); | 274 | return app.exec(); | ||
274 | } | 275 | } |