diff --git a/core/networkpacket.cpp b/core/networkpacket.cpp index a3662fdd1..d6482169e 100644 --- a/core/networkpacket.cpp +++ b/core/networkpacket.cpp @@ -55,6 +55,15 @@ NetworkPacket::NetworkPacket(const QString& type, const QVariantMap& body) { } +NetworkPacket::NetworkPacket(const NetworkPacket& other) + : m_id(other.m_id) + , m_type(other.m_type) + , m_body(QVariantMap(other.m_body)) + , m_payload(other.m_payload) + , m_payloadSize(other.m_payloadSize) +{ +} + void NetworkPacket::createIdentityPacket(NetworkPacket* np) { KdeConnectConfig* config = KdeConnectConfig::instance(); diff --git a/core/networkpacket.h b/core/networkpacket.h index d7d7acfa0..a19d0a21b 100644 --- a/core/networkpacket.h +++ b/core/networkpacket.h @@ -49,7 +49,8 @@ public: //const static QCA::EncryptionAlgorithm EncryptionAlgorithm; const static int s_protocolVersion; - explicit NetworkPacket(const QString& type, const QVariantMap& body = {}); + explicit NetworkPacket(const QString& type = QStringLiteral("empty"), const QVariantMap& body = {}); + NetworkPacket(const NetworkPacket& other); // Copy constructor, required for QMetaType and queued signals static void createIdentityPacket(NetworkPacket*); @@ -97,5 +98,6 @@ private: }; KDECONNECTCORE_EXPORT QDebug operator<<(QDebug s, const NetworkPacket& pkg); +Q_DECLARE_METATYPE(NetworkPacket) #endif // NETWORKPACKET_H