Use QVariant instead of QDbusVariant

Needs https://bugreports.qt.io/browse/QTBUG-116002
This commit is contained in:
Albert Vaca Cintora 2023-08-11 11:42:43 +02:00
parent 790b08ee24
commit fc4b8a3297
11 changed files with 33 additions and 31 deletions

View file

@ -63,14 +63,6 @@ ConversationMessage::ConversationMessage(const qint32 &eventField,
{ {
} }
ConversationMessage ConversationMessage::fromDBus(const QDBusVariant &var)
{
QDBusArgument data = var.variant().value<QDBusArgument>();
ConversationMessage message;
data >> message;
return message;
}
ConversationAddress::ConversationAddress(QString address) ConversationAddress::ConversationAddress(QString address)
: m_address(address) : m_address(address)
{ {

View file

@ -56,7 +56,6 @@ public:
const qint64 &subID, const qint64 &subID,
const QList<Attachment> &attachments); const QList<Attachment> &attachments);
static ConversationMessage fromDBus(const QDBusVariant &);
static void registerDbusType(); static void registerDbusType();
qint32 eventField() const qint32 eventField() const

View file

@ -26,7 +26,6 @@ class QDBusPendingCallWatcher;
class QDBusInterface; class QDBusInterface;
class QDBusError; class QDBusError;
class QDBusObjectPath; class QDBusObjectPath;
class QDBusVariant;
class MMTelephonyPlugin : public KdeConnectPlugin class MMTelephonyPlugin : public KdeConnectPlugin
{ {

View file

@ -126,9 +126,9 @@ void ConversationsDbusInterface::addMessages(const QList<ConversationMessage> &m
// Tell the world about what just happened // Tell the world about what just happened
if (newConversation) { if (newConversation) {
Q_EMIT conversationCreated(QDBusVariant(QVariant::fromValue(message))); Q_EMIT conversationCreated(QVariant::fromValue(message));
} else if (latestMessage) { } else if (latestMessage) {
Q_EMIT conversationUpdated(QDBusVariant(QVariant::fromValue(message))); Q_EMIT conversationUpdated(QVariant::fromValue(message));
} }
} }

View file

@ -109,7 +109,7 @@ Q_SIGNALS:
* Emitted whenever a conversation with no cached messages is added, either because the cache * 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 * 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 * 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 * Emitted whenever a message is added to a conversation and it is the newest message in the
* conversation * 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 * Emitted whenever we have handled a response from the phone indicating the total number of

View file

@ -74,7 +74,7 @@ size_t RequestConversationWorker::replyForConversation(const QList<ConversationM
if (i >= howMany) { if (i >= howMany) {
break; break;
} }
Q_EMIT conversationMessageRead(QDBusVariant(QVariant::fromValue(*it))); Q_EMIT conversationMessageRead(QVariant::fromValue(*it));
i++; i++;
} }

View file

@ -36,7 +36,7 @@ public Q_SLOTS:
void work(); void work();
Q_SIGNALS: Q_SIGNALS:
void conversationMessageRead(const QDBusVariant &msg); void conversationMessageRead(const QVariant &msg);
void finished(); void finished();
private: private:

View file

@ -110,15 +110,15 @@ void ConversationListModel::prepareConversationsList()
this); this);
} }
void ConversationListModel::handleCreatedConversation(const QDBusVariant &msg) void ConversationListModel::handleCreatedConversation(const QVariant &msg)
{ {
const ConversationMessage message = ConversationMessage::fromDBus(msg); const ConversationMessage message = msg.value<ConversationMessage>();
createRowFromMessage(message); 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<ConversationMessage>();
createRowFromMessage(message); createRowFromMessage(message);
} }

View file

@ -49,8 +49,8 @@ public:
Q_INVOKABLE void createConversationForAddress(const QString &address); Q_INVOKABLE void createConversationForAddress(const QString &address);
public Q_SLOTS: public Q_SLOTS:
void handleCreatedConversation(const QDBusVariant &msg); void handleCreatedConversation(const QVariant &msg);
void handleConversationUpdated(const QDBusVariant &msg); void handleConversationUpdated(const QVariant &msg);
void createRowFromMessage(const ConversationMessage &message); void createRowFromMessage(const ConversationMessage &message);
void printDBusError(const QDBusError &error); void printDBusError(const QDBusError &error);
void displayContacts(); void displayContacts();

View file

@ -182,10 +182,9 @@ void ConversationModel::createRowFromMessage(const ConversationMessage &message,
knownMessageIDs.insert(message.uID()); 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<ConversationMessage>();
if (message.threadID() != m_threadId) { if (message.threadID() != m_threadId) {
// If a conversation which we are not currently viewing was updated, discard the information // 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; 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); createRowFromMessage(message, 0);
} }
void ConversationModel::handleConversationCreated(const QDBusVariant &msg) void ConversationModel::handleConversationCreated(const QVariant &msg)
{ {
ConversationMessage message = ConversationMessage::fromDBus(msg); ConversationMessage message = msg.value<ConversationMessage>();
if (m_threadId == INVALID_THREAD_ID && SmsHelper::isPhoneNumberMatch(m_addressList[0].address(), message.addresses().first().address()) if (m_threadId == INVALID_THREAD_ID && SmsHelper::isPhoneNumberMatch(m_addressList[0].address(), message.addresses().first().address())
&& !message.isMultitarget()) { && !message.isMultitarget()) {
m_threadId = message.threadID(); m_threadId = message.threadID();
@ -237,4 +235,18 @@ void ConversationModel::requestAttachmentPath(const qint64 &partID, const QStrin
m_conversationsInterface->requestAttachmentFile(partID, uniqueIdentifier); 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" #include "moc_conversationmodel.cpp"

View file

@ -67,9 +67,9 @@ Q_SIGNALS:
void deviceIdChanged(const QString &value); void deviceIdChanged(const QString &value);
private Q_SLOTS: private Q_SLOTS:
void handleConversationUpdate(const QDBusVariant &message); Q_SCRIPTABLE void handleConversationUpdate(const QVariant &message);
void handleConversationLoaded(qint64 threadID); Q_SCRIPTABLE void handleConversationLoaded(qint64 threadID);
void handleConversationCreated(const QDBusVariant &message); Q_SCRIPTABLE void handleConversationCreated(const QVariant &message);
private: private:
void createRowFromMessage(const ConversationMessage &message, int pos); void createRowFromMessage(const ConversationMessage &message, int pos);