From 674e826bb60fc9fae104ec7bd5db031187a45b2d Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Sun, 11 Oct 2020 00:00:13 +0200 Subject: [PATCH] Work around SMS not being sent from cli Something in the demarshalling of the address list is broken and I can't figure out why. Instead expose a much simpler method that only takes one address string. This removes the ability to send to multiple destinations from one command, but that's better than not working at all. This patch is for 20.08 only as the marshalling works differently in master anyway. --- cli/kdeconnect-cli.cpp | 9 ++------- plugins/sms/smsplugin.cpp | 13 +++++++++++++ plugins/sms/smsplugin.h | 1 + 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/cli/kdeconnect-cli.cpp b/cli/kdeconnect-cli.cpp index fcb76c5db..01954dc3f 100644 --- a/cli/kdeconnect-cli.cpp +++ b/cli/kdeconnect-cli.cpp @@ -265,16 +265,11 @@ int main(int argc, char** argv) qDBusRegisterMetaType(); QVariantList addresses; - const QStringList addressList = parser.value(QStringLiteral("destination")).split(QRegularExpression(QStringLiteral("\\s+"))); - - for (const QString& input : addressList) { - ConversationAddress address(input); - addresses << QVariant::fromValue(address); - } + const QString address = parser.value(QStringLiteral("destination")); 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(QDBusVariant(addresses)) << text); + msg.setArguments(QVariantList() << address << text); blockOnReply(DBusHelper::sessionBus().asyncCall(msg)); } else { QTextStream(stderr) << i18n("error: should specify the SMS's recipient by passing --destination "); diff --git a/plugins/sms/smsplugin.cpp b/plugins/sms/smsplugin.cpp index 27074584f..4ef1401db 100644 --- a/plugins/sms/smsplugin.cpp +++ b/plugins/sms/smsplugin.cpp @@ -81,6 +81,19 @@ void SmsPlugin::sendSms(const QDBusVariant& addresses, const QString& messageBod sendPacket(np); } +void SmsPlugin::sendSms(const QString& address, const QString& messageBody) +{ + QVariantMap packetMap({ + {QStringLiteral("sendSms"), true}, + {QStringLiteral("phoneNumber"), address}, + {QStringLiteral("messageBody"), messageBody} + }); + + NetworkPacket np(PACKET_TYPE_SMS_REQUEST, packetMap); + qCDebug(KDECONNECT_PLUGIN_SMS) << "Dispatching SMS send request to remote"; + sendPacket(np); +} + void SmsPlugin::requestAllConversations() { NetworkPacket np(PACKET_TYPE_SMS_REQUEST_CONVERSATIONS); diff --git a/plugins/sms/smsplugin.h b/plugins/sms/smsplugin.h index 9d2e3de8c..149244079 100644 --- a/plugins/sms/smsplugin.h +++ b/plugins/sms/smsplugin.h @@ -128,6 +128,7 @@ public: public Q_SLOTS: Q_SCRIPTABLE void sendSms(const QDBusVariant& addresses, const QString& messageBody, const qint64 subID = -1); + Q_SCRIPTABLE void sendSms(const QString& address, const QString& messageBody); /** * Send a request to the remote for all of its conversations