[CLI] Use ConversationsDbusInterface to avoid problems with using raw dbus

This commit is contained in:
Simon Redman 2020-10-08 18:39:31 -07:00 committed by Nicolas Fella
parent be63cea8e8
commit a1ebbdfc09

View file

@ -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 <phone number>");
return 1;