From af8a5bc49bc3bb49ef4f7d0806b59e68ac003b82 Mon Sep 17 00:00:00 2001 From: Aniket Kumar Date: Wed, 8 Jul 2020 13:46:56 +0530 Subject: [PATCH] Enabled seding of multi-target messages in SMS app. --- plugins/sms/conversationsdbusinterface.cpp | 20 ++++++-------------- plugins/sms/smsplugin.cpp | 13 +++++++++++-- plugins/sms/smsplugin.h | 4 ++-- smsapp/qml/ConversationDisplay.qml | 4 ++-- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/plugins/sms/conversationsdbusinterface.cpp b/plugins/sms/conversationsdbusinterface.cpp index 1806230d4..4151a6b1b 100644 --- a/plugins/sms/conversationsdbusinterface.cpp +++ b/plugins/sms/conversationsdbusinterface.cpp @@ -194,23 +194,15 @@ void ConversationsDbusInterface::replyToConversation(const qint64& conversationI return; } - if (messagesList.first().isMultitarget()) { - qWarning(KDECONNECT_CONVERSATIONS) << "Tried to reply to a group MMS which is not supported in this version of KDE Connect"; - return; - } + const QList& addressList = messagesList.first().addresses(); + QVariant addresses; + addresses.setValue(addressList); - const QList& addresses = messagesList.first().addresses(); - if (addresses.size() > 1) { - // TODO: Upgrade for multitarget replies - qCWarning(KDECONNECT_CONVERSATIONS) << "Sending replies to multiple recipients is not supported"; - return; - } - m_smsInterface.sendSms(addresses[0].address(), message, messagesList.first().subID()); + m_smsInterface.sendSms(QDBusVariant(addresses), message, messagesList.first().subID()); } -void ConversationsDbusInterface::sendWithoutConversation(const QDBusVariant& addressList, const QString& message) { - QList addresses = ConversationAddress::listfromDBus(addressList); - m_smsInterface.sendSms(addresses[0].address(), message); +void ConversationsDbusInterface::sendWithoutConversation(const QDBusVariant& addresses, const QString& message) { + m_smsInterface.sendSms(addresses, message); } void ConversationsDbusInterface::requestAllConversationThreads() diff --git a/plugins/sms/smsplugin.cpp b/plugins/sms/smsplugin.cpp index 2b4f6667f..27074584f 100644 --- a/plugins/sms/smsplugin.cpp +++ b/plugins/sms/smsplugin.cpp @@ -57,11 +57,20 @@ bool SmsPlugin::receivePacket(const NetworkPacket& np) return true; } -void SmsPlugin::sendSms(const QString& phoneNumber, const QString& messageBody, const qint64 subID) +void SmsPlugin::sendSms(const QDBusVariant& addresses, const QString& messageBody, const qint64 subID) { + QList addressList = ConversationAddress::listfromDBus(addresses); + + QVariantList addressMapList; + for (const ConversationAddress address : addressList) { + QVariantMap addressMap({{QStringLiteral("address"), address.address()}}); + addressMapList.append(addressMap); + qDebug() < * "messageBody": "Hi mom!", * "sub_id": "3859358340534" * } @@ -127,7 +127,7 @@ public: QString dbusPath() const override; public Q_SLOTS: - Q_SCRIPTABLE void sendSms(const QString& phoneNumber, const QString& messageBody, const qint64 subID = -1); + Q_SCRIPTABLE void sendSms(const QDBusVariant& addresses, const QString& messageBody, const qint64 subID = -1); /** * Send a request to the remote for all of its conversations diff --git a/smsapp/qml/ConversationDisplay.qml b/smsapp/qml/ConversationDisplay.qml index d82798d2c..245b96f60 100644 --- a/smsapp/qml/ConversationDisplay.qml +++ b/smsapp/qml/ConversationDisplay.qml @@ -183,7 +183,7 @@ Kirigami.ScrollablePage footer: Controls.Pane { id: sendingArea - enabled: page.deviceConnected && !page.isMultitarget + enabled: page.deviceConnected layer.enabled: sendingArea.enabled layer.effect: DropShadow { verticalOffset: 1 @@ -211,7 +211,7 @@ Kirigami.ScrollablePage Controls.TextArea { anchors.fill: parent id: messageField - placeholderText: page.isMultitarget ? i18nd("kdeconnect-sms", "Replying to multitarget messages is not supported") : i18nd("kdeconnect-sms", "Compose message") + placeholderText: i18nd("kdeconnect-sms", "Compose message") wrapMode: TextEdit.Wrap topPadding: Kirigami.Units.gridUnit * 0.5 bottomPadding: topPadding