diff --git a/interfaces/conversationmessage.cpp b/interfaces/conversationmessage.cpp index 34e5b25d9..47234ca23 100644 --- a/interfaces/conversationmessage.cpp +++ b/interfaces/conversationmessage.cpp @@ -136,6 +136,14 @@ ConversationAddress& ConversationAddress::operator=(const ConversationAddress& o return *this; } +QList ConversationAddress::listfromDBus(const QDBusVariant& var) +{ + QDBusArgument data = var.variant().value(); + QList addresses; + data >> addresses; + return addresses; +} + QVariantMap ConversationAddress::toVariant() const { return { @@ -149,4 +157,6 @@ void ConversationMessage::registerDbusType() qRegisterMetaType(); qDBusRegisterMetaType(); qRegisterMetaType(); + qDBusRegisterMetaType>(); + qRegisterMetaType>(); } diff --git a/interfaces/conversationmessage.h b/interfaces/conversationmessage.h index d0ce78521..bbf3060ae 100644 --- a/interfaces/conversationmessage.h +++ b/interfaces/conversationmessage.h @@ -152,6 +152,7 @@ public: ConversationAddress(const ConversationAddress& other); ~ConversationAddress(); ConversationAddress& operator=(const ConversationAddress& other); + static QList listfromDBus(const QDBusVariant&); QString address() const { return m_address; } @@ -226,7 +227,7 @@ inline const QDBusArgument& operator>>(const QDBusArgument& argument, Conversati return argument; } -Q_DECLARE_METATYPE(ConversationMessage); -Q_DECLARE_METATYPE(ConversationAddress); +Q_DECLARE_METATYPE(ConversationMessage) +Q_DECLARE_METATYPE(ConversationAddress) #endif /* PLUGINS_TELEPHONY_CONVERSATIONMESSAGE_H_ */ diff --git a/plugins/sms/conversationsdbusinterface.cpp b/plugins/sms/conversationsdbusinterface.cpp index 909703040..1be3b02d5 100644 --- a/plugins/sms/conversationsdbusinterface.cpp +++ b/plugins/sms/conversationsdbusinterface.cpp @@ -208,8 +208,9 @@ void ConversationsDbusInterface::replyToConversation(const qint64& conversationI m_smsInterface.sendSms(addresses[0].address(), message, messagesList.first().subID()); } -void ConversationsDbusInterface::sendWithoutConversation(const QString& address, const QString& message) { - m_smsInterface.sendSms(address, message); +void ConversationsDbusInterface::sendWithoutConversation(const QDBusVariant& addressList, const QString& message) { + QList addresses = ConversationAddress::listfromDBus(addressList); + m_smsInterface.sendSms(addresses[0].address(), message); } void ConversationsDbusInterface::requestAllConversationThreads() diff --git a/plugins/sms/conversationsdbusinterface.h b/plugins/sms/conversationsdbusinterface.h index cad37f2c9..0da7b06f6 100644 --- a/plugins/sms/conversationsdbusinterface.h +++ b/plugins/sms/conversationsdbusinterface.h @@ -90,7 +90,7 @@ public Q_SLOTS: /** * Send a new message to the contact having no previous coversation with */ - void sendWithoutConversation(const QString& address, const QString& message); + void sendWithoutConversation(const QDBusVariant& addressList, const QString& message); /** * Send the request to the Telephony plugin to update the list of conversation threads diff --git a/smsapp/conversationmodel.cpp b/smsapp/conversationmodel.cpp index 6583edadf..189339192 100644 --- a/smsapp/conversationmodel.cpp +++ b/smsapp/conversationmodel.cpp @@ -83,10 +83,12 @@ void ConversationModel::setDeviceId(const QString& deviceId) connect(m_conversationsInterface, SIGNAL(conversationUpdated(QDBusVariant)), this, SLOT(handleConversationUpdate(QDBusVariant))); connect(m_conversationsInterface, SIGNAL(conversationLoaded(qint64, quint64)), this, SLOT(handleConversationLoaded(qint64, quint64))); connect(m_conversationsInterface, SIGNAL(conversationCreated(QDBusVariant)), this, SLOT(handleConversationCreated(QDBusVariant))); + + connect(this, SIGNAL(sendMessageWithoutConversation(QDBusVariant, QString)), m_conversationsInterface, SLOT(sendWithoutConversation(QDBusVariant, QString))); } -void ConversationModel::setOtherPartyAddress(const QString& address) { - m_otherPartyAddress = address; +void ConversationModel::setAddressList(const QList& addressList) { + m_addressList = addressList; } void ConversationModel::sendReplyToConversation(const QString& message) @@ -95,10 +97,11 @@ void ConversationModel::sendReplyToConversation(const QString& message) m_conversationsInterface->replyToConversation(m_threadId, message); } -void ConversationModel::sendMessageWithoutConversation(const QString& message, const QString& address) +void ConversationModel::startNewConversation(const QString& message, const QList& addressList) { - //qCDebug(KDECONNECT_SMS_CONVERSATION_MODEL) << "Trying to send" << message << "to contact address with no previous Conversation" << "and receiver's address" << address; - m_conversationsInterface->sendWithoutConversation(address, message); + QVariant addresses; + addresses.setValue(addressList); + Q_EMIT sendMessageWithoutConversation(QDBusVariant(addresses), message); } void ConversationModel::requestMoreMessages(const quint32& howMany) @@ -163,7 +166,7 @@ void ConversationModel::handleConversationCreated(const QDBusVariant& msg) { ConversationMessage message = ConversationMessage::fromDBus(msg); - if (m_threadId == INVALID_THREAD_ID && SmsHelper::isPhoneNumberMatch(m_otherPartyAddress, message.addresses().first().address()) && !message.isMultitarget()) { + if (m_threadId == INVALID_THREAD_ID && SmsHelper::isPhoneNumberMatch(m_addressList[0].address(), message.addresses().first().address()) && !message.isMultitarget()) { m_threadId = message.threadID(); createRowFromMessage(message, 0); } @@ -183,7 +186,7 @@ void ConversationModel::handleConversationLoaded(qint64 threadID, quint64 numMes QString ConversationModel::getCharCountInfo(const QString& message) const { SmsCharCount count = SmsHelper::getCharCount(message); - + if (count.messages > 1) { // Show remaining char count and message count return QString::number(count.remaining) + QLatin1Char('/') + QString::number(count.messages); diff --git a/smsapp/conversationmodel.h b/smsapp/conversationmodel.h index 80ec6ba7b..96a6b98c3 100644 --- a/smsapp/conversationmodel.h +++ b/smsapp/conversationmodel.h @@ -39,7 +39,7 @@ class ConversationModel Q_OBJECT Q_PROPERTY(qint64 threadId READ threadId WRITE setThreadId) Q_PROPERTY(QString deviceId READ deviceId WRITE setDeviceId) - Q_PROPERTY(QString otherParty READ otherPartyAddress WRITE setOtherPartyAddress) + Q_PROPERTY(QList addressList READ addressList WRITE setAddressList) public: ConversationModel(QObject* parent = nullptr); @@ -60,17 +60,18 @@ public: QString deviceId() const { return m_deviceId; } void setDeviceId(const QString &/*deviceId*/); - QString otherPartyAddress() const { return m_otherPartyAddress; } - void setOtherPartyAddress(const QString& address); + QList addressList() const { return m_addressList; } + void setAddressList(const QList& addressList); Q_INVOKABLE void sendReplyToConversation(const QString& message); - Q_INVOKABLE void sendMessageWithoutConversation(const QString& message, const QString& address); + Q_INVOKABLE void startNewConversation(const QString& message, const QList& addressList); Q_INVOKABLE void requestMoreMessages(const quint32& howMany = 10); Q_INVOKABLE QString getCharCountInfo(const QString& message) const; Q_SIGNALS: void loadingFinished(); + void sendMessageWithoutConversation(const QDBusVariant& addressList, const QString& message); private Q_SLOTS: void handleConversationUpdate(const QDBusVariant &message); @@ -83,7 +84,7 @@ private: DeviceConversationsDbusInterface* m_conversationsInterface; QString m_deviceId; qint64 m_threadId = INVALID_THREAD_ID; - QString m_otherPartyAddress; + QList m_addressList; QSet knownMessageIDs; // Set of known Message uIDs }; diff --git a/smsapp/qml/ConversationDisplay.qml b/smsapp/qml/ConversationDisplay.qml index 827936465..9b683ff3c 100644 --- a/smsapp/qml/ConversationDisplay.qml +++ b/smsapp/qml/ConversationDisplay.qml @@ -38,7 +38,6 @@ Kirigami.ScrollablePage property string conversationId property bool isMultitarget property string initialMessage - property string otherParty property string invalidId: "-1" property bool isInitalized: false @@ -46,7 +45,7 @@ Kirigami.ScrollablePage property var conversationModel: ConversationModel { deviceId: page.deviceId threadId: page.conversationId - otherParty: page.otherParty + addressList: page.addresses onLoadingFinished: { page.isInitalized = true @@ -257,7 +256,7 @@ Kirigami.ScrollablePage // send the message if (page.conversationId == page.invalidId) { - conversationModel.sendMessageWithoutConversation(messageField.text, page.otherParty) + conversationModel.startNewConversation(messageField.text, addresses) } else { conversationModel.sendReplyToConversation(messageField.text) } diff --git a/smsapp/qml/ConversationList.qml b/smsapp/qml/ConversationList.qml index 092acb0e9..6e9f0a6c2 100644 --- a/smsapp/qml/ConversationList.qml +++ b/smsapp/qml/ConversationList.qml @@ -265,8 +265,7 @@ Kirigami.ScrollablePage conversationId: model.conversationId, isMultitarget: isMultitarget, initialMessage: page.initialMessage, - device: device, - otherParty: sender}) + device: device}) initialMessage = "" }