From fc4b8a32978fa516fef1da8810fedc5a1ce68cf0 Mon Sep 17 00:00:00 2001 From: Albert Vaca Cintora Date: Fri, 11 Aug 2023 11:42:43 +0200 Subject: [PATCH] Use QVariant instead of QDbusVariant Needs https://bugreports.qt.io/browse/QTBUG-116002 --- interfaces/conversationmessage.cpp | 8 -------- interfaces/conversationmessage.h | 1 - plugins/mmtelephony/mmtelephonyplugin.h | 1 - plugins/sms/conversationsdbusinterface.cpp | 4 ++-- plugins/sms/conversationsdbusinterface.h | 4 ++-- plugins/sms/requestconversationworker.cpp | 2 +- plugins/sms/requestconversationworker.h | 2 +- smsapp/conversationlistmodel.cpp | 8 ++++---- smsapp/conversationlistmodel.h | 4 ++-- smsapp/conversationmodel.cpp | 24 ++++++++++++++++------ smsapp/conversationmodel.h | 6 +++--- 11 files changed, 33 insertions(+), 31 deletions(-) diff --git a/interfaces/conversationmessage.cpp b/interfaces/conversationmessage.cpp index dee1a551d..56eb10e07 100644 --- a/interfaces/conversationmessage.cpp +++ b/interfaces/conversationmessage.cpp @@ -63,14 +63,6 @@ ConversationMessage::ConversationMessage(const qint32 &eventField, { } -ConversationMessage ConversationMessage::fromDBus(const QDBusVariant &var) -{ - QDBusArgument data = var.variant().value(); - ConversationMessage message; - data >> message; - return message; -} - ConversationAddress::ConversationAddress(QString address) : m_address(address) { diff --git a/interfaces/conversationmessage.h b/interfaces/conversationmessage.h index b60daea13..45ffc6ff1 100644 --- a/interfaces/conversationmessage.h +++ b/interfaces/conversationmessage.h @@ -56,7 +56,6 @@ public: const qint64 &subID, const QList &attachments); - static ConversationMessage fromDBus(const QDBusVariant &); static void registerDbusType(); qint32 eventField() const diff --git a/plugins/mmtelephony/mmtelephonyplugin.h b/plugins/mmtelephony/mmtelephonyplugin.h index 3d9e5a21c..6e6628f15 100644 --- a/plugins/mmtelephony/mmtelephonyplugin.h +++ b/plugins/mmtelephony/mmtelephonyplugin.h @@ -26,7 +26,6 @@ class QDBusPendingCallWatcher; class QDBusInterface; class QDBusError; class QDBusObjectPath; -class QDBusVariant; class MMTelephonyPlugin : public KdeConnectPlugin { diff --git a/plugins/sms/conversationsdbusinterface.cpp b/plugins/sms/conversationsdbusinterface.cpp index 8a1e2c0fc..918c9f9b5 100644 --- a/plugins/sms/conversationsdbusinterface.cpp +++ b/plugins/sms/conversationsdbusinterface.cpp @@ -126,9 +126,9 @@ void ConversationsDbusInterface::addMessages(const QList &m // Tell the world about what just happened if (newConversation) { - Q_EMIT conversationCreated(QDBusVariant(QVariant::fromValue(message))); + Q_EMIT conversationCreated(QVariant::fromValue(message)); } else if (latestMessage) { - Q_EMIT conversationUpdated(QDBusVariant(QVariant::fromValue(message))); + Q_EMIT conversationUpdated(QVariant::fromValue(message)); } } diff --git a/plugins/sms/conversationsdbusinterface.h b/plugins/sms/conversationsdbusinterface.h index 1b431bd48..2917c13c0 100644 --- a/plugins/sms/conversationsdbusinterface.h +++ b/plugins/sms/conversationsdbusinterface.h @@ -109,7 +109,7 @@ Q_SIGNALS: * Emitted whenever a conversation with no cached messages is added, either because the cache * is being populated or because a new conversation has been created */ - Q_SCRIPTABLE void conversationCreated(const QDBusVariant &msg); + Q_SCRIPTABLE void conversationCreated(const QVariant &msg); /** * Emitted whenever a conversation is being deleted @@ -120,7 +120,7 @@ Q_SIGNALS: * Emitted whenever a message is added to a conversation and it is the newest message in the * conversation */ - Q_SCRIPTABLE void conversationUpdated(const QDBusVariant &msg); + Q_SCRIPTABLE void conversationUpdated(const QVariant &msg); /** * Emitted whenever we have handled a response from the phone indicating the total number of diff --git a/plugins/sms/requestconversationworker.cpp b/plugins/sms/requestconversationworker.cpp index 12121041d..fdfcce586 100644 --- a/plugins/sms/requestconversationworker.cpp +++ b/plugins/sms/requestconversationworker.cpp @@ -74,7 +74,7 @@ size_t RequestConversationWorker::replyForConversation(const QList= howMany) { break; } - Q_EMIT conversationMessageRead(QDBusVariant(QVariant::fromValue(*it))); + Q_EMIT conversationMessageRead(QVariant::fromValue(*it)); i++; } diff --git a/plugins/sms/requestconversationworker.h b/plugins/sms/requestconversationworker.h index 38443349a..0e0700234 100644 --- a/plugins/sms/requestconversationworker.h +++ b/plugins/sms/requestconversationworker.h @@ -36,7 +36,7 @@ public Q_SLOTS: void work(); Q_SIGNALS: - void conversationMessageRead(const QDBusVariant &msg); + void conversationMessageRead(const QVariant &msg); void finished(); private: diff --git a/smsapp/conversationlistmodel.cpp b/smsapp/conversationlistmodel.cpp index af357565c..61eada854 100644 --- a/smsapp/conversationlistmodel.cpp +++ b/smsapp/conversationlistmodel.cpp @@ -110,15 +110,15 @@ void ConversationListModel::prepareConversationsList() this); } -void ConversationListModel::handleCreatedConversation(const QDBusVariant &msg) +void ConversationListModel::handleCreatedConversation(const QVariant &msg) { - const ConversationMessage message = ConversationMessage::fromDBus(msg); + const ConversationMessage message = msg.value(); createRowFromMessage(message); } -void ConversationListModel::handleConversationUpdated(const QDBusVariant &msg) +void ConversationListModel::handleConversationUpdated(const QVariant &msg) { - const ConversationMessage message = ConversationMessage::fromDBus(msg); + const ConversationMessage message = msg.value(); createRowFromMessage(message); } diff --git a/smsapp/conversationlistmodel.h b/smsapp/conversationlistmodel.h index 9746a6af0..5e8ce2b37 100644 --- a/smsapp/conversationlistmodel.h +++ b/smsapp/conversationlistmodel.h @@ -49,8 +49,8 @@ public: Q_INVOKABLE void createConversationForAddress(const QString &address); public Q_SLOTS: - void handleCreatedConversation(const QDBusVariant &msg); - void handleConversationUpdated(const QDBusVariant &msg); + void handleCreatedConversation(const QVariant &msg); + void handleConversationUpdated(const QVariant &msg); void createRowFromMessage(const ConversationMessage &message); void printDBusError(const QDBusError &error); void displayContacts(); diff --git a/smsapp/conversationmodel.cpp b/smsapp/conversationmodel.cpp index 523729be6..d751a62f8 100644 --- a/smsapp/conversationmodel.cpp +++ b/smsapp/conversationmodel.cpp @@ -182,10 +182,9 @@ void ConversationModel::createRowFromMessage(const ConversationMessage &message, knownMessageIDs.insert(message.uID()); } -void ConversationModel::handleConversationUpdate(const QDBusVariant &msg) +void ConversationModel::handleConversationUpdate(const QVariant &msg) { - ConversationMessage message = ConversationMessage::fromDBus(msg); - + ConversationMessage message = msg.value(); if (message.threadID() != m_threadId) { // If a conversation which we are not currently viewing was updated, discard the information qCDebug(KDECONNECT_SMS_CONVERSATION_MODEL) << "Saw update for thread" << message.threadID() << "but we are currently viewing" << m_threadId; @@ -194,10 +193,9 @@ void ConversationModel::handleConversationUpdate(const QDBusVariant &msg) createRowFromMessage(message, 0); } -void ConversationModel::handleConversationCreated(const QDBusVariant &msg) +void ConversationModel::handleConversationCreated(const QVariant &msg) { - ConversationMessage message = ConversationMessage::fromDBus(msg); - + ConversationMessage message = msg.value(); if (m_threadId == INVALID_THREAD_ID && SmsHelper::isPhoneNumberMatch(m_addressList[0].address(), message.addresses().first().address()) && !message.isMultitarget()) { m_threadId = message.threadID(); @@ -237,4 +235,18 @@ void ConversationModel::requestAttachmentPath(const qint64 &partID, const QStrin m_conversationsInterface->requestAttachmentFile(partID, uniqueIdentifier); } +QDBusArgument &operator<<(QDBusArgument &argument, const Message& message) +{ + argument.beginStructure(); + argument.endStructure(); + return argument; +} + +const QDBusArgument &operator>>(const QDBusArgument &argument, Message &message) +{ + argument.beginStructure(); + argument.endStructure(); + return argument; +} + #include "moc_conversationmodel.cpp" diff --git a/smsapp/conversationmodel.h b/smsapp/conversationmodel.h index 51314f00b..e19afb82f 100644 --- a/smsapp/conversationmodel.h +++ b/smsapp/conversationmodel.h @@ -67,9 +67,9 @@ Q_SIGNALS: void deviceIdChanged(const QString &value); private Q_SLOTS: - void handleConversationUpdate(const QDBusVariant &message); - void handleConversationLoaded(qint64 threadID); - void handleConversationCreated(const QDBusVariant &message); + Q_SCRIPTABLE void handleConversationUpdate(const QVariant &message); + Q_SCRIPTABLE void handleConversationLoaded(qint64 threadID); + Q_SCRIPTABLE void handleConversationCreated(const QVariant &message); private: void createRowFromMessage(const ConversationMessage &message, int pos);