[cli] Allow sharing files and URLs together
Summary: Depends on D15787 Restricting sharing multiple urls to files seems unnecessary to me. Test Plan: kdeconnect-cli --share foo.txt google.com Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: apol, kdeconnect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D15788
This commit is contained in:
parent
518251342c
commit
7a4bdcc62d
1 changed files with 5 additions and 10 deletions
|
@ -151,22 +151,17 @@ int main(int argc, char** argv)
|
||||||
QUrl url = QUrl::fromUserInput(parser.value(QStringLiteral("share")), QDir::currentPath());
|
QUrl url = QUrl::fromUserInput(parser.value(QStringLiteral("share")), QDir::currentPath());
|
||||||
urls.append(url);
|
urls.append(url);
|
||||||
|
|
||||||
//In case there are more arguments, check if they are files and then send them
|
// Check for more arguments
|
||||||
for (const QString& file : parser.positionalArguments()) {
|
for (const QString& input : parser.positionalArguments()) {
|
||||||
QUrl url = QUrl::fromUserInput(file, QDir::currentPath());
|
QUrl url = QUrl::fromUserInput(input, QDir::currentPath());
|
||||||
if (!url.isLocalFile()) {
|
urls.append(url);
|
||||||
QTextStream(stderr) << i18n("Can't find the file: %1", url.toString()) << endl;
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
urls.append(url);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const QUrl& url : urls) {
|
for (const QUrl& url : urls) {
|
||||||
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+device+"/share", QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareUrl"));
|
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+device+"/share", QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareUrl"));
|
||||||
msg.setArguments(QVariantList() << url.toString());
|
msg.setArguments(QVariantList() << url.toString());
|
||||||
blockOnReply(QDBusConnection::sessionBus().asyncCall(msg));
|
blockOnReply(QDBusConnection::sessionBus().asyncCall(msg));
|
||||||
QTextStream(stdout) << i18n("Sent %1", url.toString()) << endl;
|
QTextStream(stdout) << i18n("Shared %1", url.toString()) << endl;
|
||||||
}
|
}
|
||||||
} else if(parser.isSet(QStringLiteral("pair"))) {
|
} else if(parser.isSet(QStringLiteral("pair"))) {
|
||||||
DeviceDbusInterface dev(device);
|
DeviceDbusInterface dev(device);
|
||||||
|
|
Loading…
Reference in a new issue