diff --git a/interfaces/conversationmessage.h b/interfaces/conversationmessage.h index 7c60141bf..316b1d9c4 100644 --- a/interfaces/conversationmessage.h +++ b/interfaces/conversationmessage.h @@ -47,6 +47,7 @@ public: */ enum Events { EventTextMessage = 0x1, // This message has a body field which contains pure, human-readable text + EventMultiTarget = 0x2, // This is a multitarget (group) message which has an "addresses" field which is a list of participants in the group }; /** @@ -77,6 +78,7 @@ public: QVariantMap toVariant() const; bool containsTextBody() const { return (eventField() & ConversationMessage::EventTextMessage); } + bool isMultitarget() const { return (eventField() & ConversationMessage::EventMultiTarget); } protected: /** diff --git a/plugins/sms/smsplugin.cpp b/plugins/sms/smsplugin.cpp index 64d528d9e..e518388ae 100644 --- a/plugins/sms/smsplugin.cpp +++ b/plugins/sms/smsplugin.cpp @@ -107,8 +107,8 @@ bool SmsPlugin::handleBatchMessages(const NetworkPacket& np) ConversationMessage message(body.toMap()); if (message.containsTextBody()) { forwardToTelepathy(message); - messagesList.append(message); } + messagesList.append(message); } m_conversationInterface->addMessages(messagesList); diff --git a/smsapp/conversationlistmodel.cpp b/smsapp/conversationlistmodel.cpp index 364dc3970..6cf828796 100644 --- a/smsapp/conversationlistmodel.cpp +++ b/smsapp/conversationlistmodel.cpp @@ -23,6 +23,9 @@ #include #include + +#include + #include "interfaces/conversationmessage.h" #include "interfaces/dbusinterfaces.h" #include "smshelper.h" @@ -42,6 +45,7 @@ ConversationListModel::ConversationListModel(QObject* parent) roles.insert(AddressRole, "address"); roles.insert(PersonUriRole, "personUri"); roles.insert(ConversationIdRole, "conversationId"); + roles.insert(MultitargetRole, "isMultitarget"); roles.insert(DateRole, "date"); setItemRoleNames(roles); @@ -159,6 +163,14 @@ void ConversationListModel::createRowFromMessage(const QVariantMap& msg) item->setData(message.threadID(), ConversationIdRole); } + // TODO: Upgrade to support other kinds of media + // Get the body that we should display + QString displayBody = message.containsTextBody() ? message.body() : i18n("(Unsupported Message Type)"); + + // TODO: Upgrade with multitarget support + if (message.isMultitarget()) { + item->setText(i18n("(Multitarget Message)")); + } // Update the message if the data is newer // This will be true if a conversation receives a new message, but false when the user // does something to trigger past conversation history loading @@ -168,8 +180,9 @@ void ConversationListModel::createRowFromMessage(const QVariantMap& msg) // If there was no old data or incoming data is newer, update the record item->setData(message.address(), AddressRole); item->setData(message.type() == ConversationMessage::MessageTypeSent, FromMeRole); - item->setData(message.body(), Qt::ToolTipRole); + item->setData(displayBody, Qt::ToolTipRole); item->setData(message.date(), DateRole); + item->setData(message.isMultitarget(), MultitargetRole); } if (toadd) diff --git a/smsapp/conversationlistmodel.h b/smsapp/conversationlistmodel.h index 9c34cc8a4..77595b727 100644 --- a/smsapp/conversationlistmodel.h +++ b/smsapp/conversationlistmodel.h @@ -83,6 +83,7 @@ public: AddressRole, ConversationIdRole, DateRole, + MultitargetRole, // Indicate that this conversation is multitarget }; Q_ENUM(Roles) diff --git a/smsapp/conversationmodel.cpp b/smsapp/conversationmodel.cpp index 0378182fb..99e0c45b0 100644 --- a/smsapp/conversationmodel.cpp +++ b/smsapp/conversationmodel.cpp @@ -21,6 +21,9 @@ #include "conversationmodel.h" #include + +#include + #include "interfaces/conversationmessage.h" Q_LOGGING_CATEGORY(KDECONNECT_SMS_CONVERSATION_MODEL, "kdeconnect.sms.conversation") @@ -110,8 +113,12 @@ void ConversationModel::createRowFromMessage(const QVariantMap& msg, int pos) return; } + // TODO: Upgrade to support other kinds of media + // Get the body that we should display + QString displayBody = message.containsTextBody() ? message.body() : i18n("(Unsupported Message Type)"); + auto item = new QStandardItem; - item->setText(message.body()); + item->setText(displayBody); item->setData(message.type() == ConversationMessage::MessageTypeSent, FromMeRole); item->setData(message.date(), DateRole); insertRow(pos, item); diff --git a/smsapp/qml/ConversationDisplay.qml b/smsapp/qml/ConversationDisplay.qml index e00e17cdf..08623658b 100644 --- a/smsapp/qml/ConversationDisplay.qml +++ b/smsapp/qml/ConversationDisplay.qml @@ -40,6 +40,7 @@ Kirigami.ScrollablePage property string deviceId // property QtObject device property string conversationId + property bool isMultitarget property string initialMessage property string phoneNumber @@ -127,7 +128,7 @@ Kirigami.ScrollablePage footer: Pane { id: sendingArea - enabled: page.deviceConnected + enabled: page.deviceConnected && !page.isMultitarget layer.enabled: sendingArea.enabled layer.effect: DropShadow { verticalOffset: 1 @@ -148,7 +149,7 @@ Kirigami.ScrollablePage TextArea { id: messageField Layout.fillWidth: true - placeholderText: i18n("Compose message") + placeholderText: page.isMultitarget ? i18n("Replying to multitarget messages is not supported") : i18n("Compose message") wrapMode: TextArea.Wrap topPadding: Kirigami.Units.gridUnit * 0.5 bottomPadding: topPadding diff --git a/smsapp/qml/ConversationList.qml b/smsapp/qml/ConversationList.qml index ab941375f..b5598ed9f 100644 --- a/smsapp/qml/ConversationList.qml +++ b/smsapp/qml/ConversationList.qml @@ -149,6 +149,7 @@ Kirigami.ScrollablePage personUri: model.personUri, phoneNumber: address, conversationId: model.conversationId, + isMultitarget: isMultitarget, initialMessage: page.initialMessage, device: device}) initialMessage = ""