From a1ebbdfc093f2daae87b37db1c01a0c91e050ea4 Mon Sep 17 00:00:00 2001 From: Simon Redman Date: Thu, 8 Oct 2020 18:39:31 -0700 Subject: [PATCH] [CLI] Use ConversationsDbusInterface to avoid problems with using raw dbus --- cli/kdeconnect-cli.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/cli/kdeconnect-cli.cpp b/cli/kdeconnect-cli.cpp index cfdb145cf..fa2bd839d 100644 --- a/cli/kdeconnect-cli.cpp +++ b/cli/kdeconnect-cli.cpp @@ -259,12 +259,20 @@ int main(int argc, char** argv) addresses << QVariant::fromValue(address); } - const QStringList urlList = parser.value(QStringLiteral("attachment")).split(QRegularExpression(QStringLiteral("\\s+"))); + const QString message = parser.value(QStringLiteral("send-sms")); - QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + device + QStringLiteral("/sms"), QStringLiteral("org.kde.kdeconnect.device.sms"), QStringLiteral("sendSms")); - const QString text = parser.value(QStringLiteral("send-sms")); - msg.setArguments(QVariantList() << QVariant::fromValue(addresses) << text << QVariant(urlList)); - blockOnReply(DBusHelper::sessionBus().asyncCall(msg)); + const QStringList rawAttachmentUrlsList = parser.value(QStringLiteral("attachment")).split(QRegularExpression(QStringLiteral("\\s+"))); + + QVariantList attachments; + for (const QString& attachmentUrl : rawAttachmentUrlsList) { + // TODO: Construct attachment objects from the list of Urls + Q_UNUSED(attachmentUrl); + } + + DeviceConversationsDbusInterface conversationDbusInterface(device); + auto reply = conversationDbusInterface.sendWithoutConversation(addresses, message, attachments); + + reply.waitForFinished(); } else { QTextStream(stderr) << i18n("error: should specify the SMS's recipient by passing --destination "); return 1;