Make NetworkPacket Metatype-capable
Summary: I am open to discussion for whether this is desireable. The use-case is for moving NetworkPacket receive handling to a thread other than the one handling the rest of the device. In order to do this, we need to use a QtConnectionType::QueuedConnection. In order for that to work (with NetworkPackets), NetworkPacket has to be registered in the Metatype system. Test Plan: Nothing should be functionally different from before Reviewers: #kde_connect, albertvaka Reviewed By: #kde_connect, albertvaka Subscribers: albertvaka, apol, nicolasfella, kdeconnect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D16469
This commit is contained in:
parent
08b31ce258
commit
0f5c9cd96c
2 changed files with 12 additions and 1 deletions
|
@ -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)
|
void NetworkPacket::createIdentityPacket(NetworkPacket* np)
|
||||||
{
|
{
|
||||||
KdeConnectConfig* config = KdeConnectConfig::instance();
|
KdeConnectConfig* config = KdeConnectConfig::instance();
|
||||||
|
|
|
@ -49,7 +49,8 @@ public:
|
||||||
//const static QCA::EncryptionAlgorithm EncryptionAlgorithm;
|
//const static QCA::EncryptionAlgorithm EncryptionAlgorithm;
|
||||||
const static int s_protocolVersion;
|
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*);
|
static void createIdentityPacket(NetworkPacket*);
|
||||||
|
|
||||||
|
@ -97,5 +98,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
KDECONNECTCORE_EXPORT QDebug operator<<(QDebug s, const NetworkPacket& pkg);
|
KDECONNECTCORE_EXPORT QDebug operator<<(QDebug s, const NetworkPacket& pkg);
|
||||||
|
Q_DECLARE_METATYPE(NetworkPacket)
|
||||||
|
|
||||||
#endif // NETWORKPACKET_H
|
#endif // NETWORKPACKET_H
|
||||||
|
|
Loading…
Reference in a new issue