Enabled seding of multi-target messages in SMS app.

This commit is contained in:
Aniket Kumar 2020-07-08 13:46:56 +05:30
parent 0cee486a62
commit af8a5bc49b
4 changed files with 21 additions and 20 deletions

View file

@ -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<ConversationAddress>& addressList = messagesList.first().addresses();
QVariant addresses;
addresses.setValue(addressList);
const QList<ConversationAddress>& 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<ConversationAddress> 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()

View file

@ -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<ConversationAddress> addressList = ConversationAddress::listfromDBus(addresses);
QVariantList addressMapList;
for (const ConversationAddress address : addressList) {
QVariantMap addressMap({{QStringLiteral("address"), address.address()}});
addressMapList.append(addressMap);
qDebug() <<address.address();
}
QVariantMap packetMap({
{QStringLiteral("sendSms"), true},
{QStringLiteral("phoneNumber"), phoneNumber},
{QStringLiteral("addresses"), addressMapList},
{QStringLiteral("messageBody"), messageBody}
});
if (subID != -1) {

View file

@ -86,7 +86,7 @@
*
* The body should look like so:
* { "sendSms": true,
* "phoneNumber": "542904563213",
* "addresses": <List of Addresses>
* "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

View file

@ -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