Changeset View
Changeset View
Standalone View
Standalone View
cli/kdeconnect-cli.cpp
Show First 20 Lines • Show All 141 Lines • ▼ Show 20 Line(s) | 137 | if (device.isEmpty() && parser.isSet(QStringLiteral("name"))) { | |||
---|---|---|---|---|---|
142 | } | 142 | } | ||
143 | } | 143 | } | ||
144 | if(device.isEmpty()) { | 144 | if(device.isEmpty()) { | ||
145 | QTextStream(stderr) << i18n("No device specified") << endl; | 145 | QTextStream(stderr) << i18n("No device specified") << endl; | ||
146 | parser.showHelp(1); | 146 | parser.showHelp(1); | ||
147 | } | 147 | } | ||
148 | 148 | | |||
149 | if (parser.isSet(QStringLiteral("share"))) { | 149 | if (parser.isSet(QStringLiteral("share"))) { | ||
150 | QList<QUrl> urls; | 150 | QStringList urls; | ||
151 | | ||||
151 | QUrl url = QUrl::fromUserInput(parser.value(QStringLiteral("share")), QDir::currentPath()); | 152 | QUrl url = QUrl::fromUserInput(parser.value(QStringLiteral("share")), QDir::currentPath()); | ||
152 | urls.append(url); | 153 | urls.append(url.toString()); | ||
153 | 154 | | |||
154 | // Check for more arguments | 155 | // Check for more arguments | ||
155 | const auto args = parser.positionalArguments(); | 156 | const auto args = parser.positionalArguments(); | ||
156 | for (const QString& input : args) { | 157 | for (const QString& input : args) { | ||
157 | QUrl url = QUrl::fromUserInput(input, QDir::currentPath()); | 158 | QUrl url = QUrl::fromUserInput(input, QDir::currentPath()); | ||
158 | urls.append(url); | 159 | urls.append(url.toString()); | ||
159 | } | 160 | } | ||
160 | 161 | | |||
161 | for (const QUrl& url : urls) { | 162 | QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+device+"/share", | ||
162 | QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+device+"/share", QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareUrl")); | 163 | QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareUrls")); | ||
163 | msg.setArguments(QVariantList() << url.toString()); | 164 | | ||
165 | msg.setArguments(QVariantList() << QVariant(urls)); | ||||
164 | blockOnReply(QDBusConnection::sessionBus().asyncCall(msg)); | 166 | blockOnReply(QDBusConnection::sessionBus().asyncCall(msg)); | ||
165 | QTextStream(stdout) << i18n("Shared %1", url.toString()) << endl; | 167 | | ||
168 | for (const QString& url : qAsConst(urls)) { | ||||
apolUnsubmitted Not Done apol: for (const QVariant &variant : qAsConst(urls)) {
| |||||
I don't know why I used QVariant here (probably because I was fighting with msg.setArguments for a while). I assume that using for (const QString &url : qAsConst(urls)) is ok as well? eduisters: I don't know why I used QVariant here (probably because I was fighting with msg.setArguments… | |||||
169 | QTextStream(stdout) << i18n("Shared %1", url) << endl; | ||||
166 | } | 170 | } | ||
167 | } else if(parser.isSet(QStringLiteral("pair"))) { | 171 | } else if(parser.isSet(QStringLiteral("pair"))) { | ||
168 | DeviceDbusInterface dev(device); | 172 | DeviceDbusInterface dev(device); | ||
169 | if (!dev.isReachable()) { | 173 | if (!dev.isReachable()) { | ||
170 | //Device doesn't exist, go into discovery mode and wait up to 30 seconds for the device to appear | 174 | //Device doesn't exist, go into discovery mode and wait up to 30 seconds for the device to appear | ||
171 | QEventLoop wait; | 175 | QEventLoop wait; | ||
172 | QTextStream(stderr) << i18n("waiting for device...") << endl; | 176 | QTextStream(stderr) << i18n("waiting for device...") << endl; | ||
173 | blockOnReply(iface.acquireDiscoveryMode(id)); | 177 | blockOnReply(iface.acquireDiscoveryMode(id)); | ||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |