Removing earlier hack to pass an address as a string instead of ConversationAdress type.
This commit is contained in:
parent
303a5c09fa
commit
d0367f11fb
8 changed files with 36 additions and 22 deletions
|
@ -136,6 +136,14 @@ ConversationAddress& ConversationAddress::operator=(const ConversationAddress& o
|
|||
return *this;
|
||||
}
|
||||
|
||||
QList<ConversationAddress> ConversationAddress::listfromDBus(const QDBusVariant& var)
|
||||
{
|
||||
QDBusArgument data = var.variant().value<QDBusArgument>();
|
||||
QList<ConversationAddress> addresses;
|
||||
data >> addresses;
|
||||
return addresses;
|
||||
}
|
||||
|
||||
QVariantMap ConversationAddress::toVariant() const
|
||||
{
|
||||
return {
|
||||
|
@ -149,4 +157,6 @@ void ConversationMessage::registerDbusType()
|
|||
qRegisterMetaType<ConversationMessage>();
|
||||
qDBusRegisterMetaType<ConversationAddress>();
|
||||
qRegisterMetaType<ConversationAddress>();
|
||||
qDBusRegisterMetaType<QList<ConversationAddress>>();
|
||||
qRegisterMetaType<QList<ConversationAddress>>();
|
||||
}
|
||||
|
|
|
@ -152,6 +152,7 @@ public:
|
|||
ConversationAddress(const ConversationAddress& other);
|
||||
~ConversationAddress();
|
||||
ConversationAddress& operator=(const ConversationAddress& other);
|
||||
static QList<ConversationAddress> 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_ */
|
||||
|
|
|
@ -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<ConversationAddress> addresses = ConversationAddress::listfromDBus(addressList);
|
||||
m_smsInterface.sendSms(addresses[0].address(), message);
|
||||
}
|
||||
|
||||
void ConversationsDbusInterface::requestAllConversationThreads()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<ConversationAddress>& 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<ConversationAddress>& 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);
|
||||
|
|
|
@ -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<ConversationAddress> 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<ConversationAddress> addressList() const { return m_addressList; }
|
||||
void setAddressList(const QList<ConversationAddress>& 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<ConversationAddress>& 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<ConversationAddress> m_addressList;
|
||||
QSet<qint32> knownMessageIDs; // Set of known Message uIDs
|
||||
};
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -265,8 +265,7 @@ Kirigami.ScrollablePage
|
|||
conversationId: model.conversationId,
|
||||
isMultitarget: isMultitarget,
|
||||
initialMessage: page.initialMessage,
|
||||
device: device,
|
||||
otherParty: sender})
|
||||
device: device})
|
||||
initialMessage = ""
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue