Changeset View
Changeset View
Standalone View
Standalone View
core/networkpacket.h
- This file was moved from core/networkpackage.h.
Show All 12 Lines | |||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. | ||
16 | * | 16 | * | ||
17 | * You should have received a copy of the GNU General Public License | 17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #ifndef NETWORKPACKAGE_H | 21 | #ifndef NETWORKPACKET_H | ||
22 | #define NETWORKPACKAGE_H | 22 | #define NETWORKPACKET_H | ||
23 | 23 | | |||
24 | #include "networkpackagetypes.h" | 24 | #include "networkpackettypes.h" | ||
25 | 25 | | |||
26 | #include <QObject> | 26 | #include <QObject> | ||
27 | #include <QString> | 27 | #include <QString> | ||
28 | #include <QVariant> | 28 | #include <QVariant> | ||
29 | #include <QIODevice> | 29 | #include <QIODevice> | ||
30 | //#include <QtCrypto> | 30 | //#include <QtCrypto> | ||
31 | #include <QSharedPointer> | 31 | #include <QSharedPointer> | ||
32 | #include <QUrl> | 32 | #include <QUrl> | ||
33 | 33 | | |||
34 | #include "kdeconnectcore_export.h" | 34 | #include "kdeconnectcore_export.h" | ||
35 | 35 | | |||
36 | class FileTransferJob; | 36 | class FileTransferJob; | ||
37 | 37 | | |||
38 | class KDECONNECTCORE_EXPORT NetworkPackage | 38 | class KDECONNECTCORE_EXPORT NetworkPacket | ||
39 | { | 39 | { | ||
40 | Q_GADGET | 40 | Q_GADGET | ||
41 | Q_PROPERTY( QString id READ id WRITE setId ) | 41 | Q_PROPERTY( QString id READ id WRITE setId ) | ||
42 | Q_PROPERTY( QString type READ type WRITE setType ) | 42 | Q_PROPERTY( QString type READ type WRITE setType ) | ||
43 | Q_PROPERTY( QVariantMap body READ body WRITE setBody ) | 43 | Q_PROPERTY( QVariantMap body READ body WRITE setBody ) | ||
44 | Q_PROPERTY( QVariantMap payloadTransferInfo READ payloadTransferInfo WRITE setPayloadTransferInfo ) | 44 | Q_PROPERTY( QVariantMap payloadTransferInfo READ payloadTransferInfo WRITE setPayloadTransferInfo ) | ||
45 | Q_PROPERTY( qint64 payloadSize READ payloadSize WRITE setPayloadSize ) | 45 | Q_PROPERTY( qint64 payloadSize READ payloadSize WRITE setPayloadSize ) | ||
46 | 46 | | |||
47 | public: | 47 | public: | ||
48 | 48 | | |||
49 | //const static QCA::EncryptionAlgorithm EncryptionAlgorithm; | 49 | //const static QCA::EncryptionAlgorithm EncryptionAlgorithm; | ||
50 | const static int s_protocolVersion; | 50 | const static int s_protocolVersion; | ||
51 | 51 | | |||
52 | explicit NetworkPackage(const QString& type, const QVariantMap& body = {}); | 52 | explicit NetworkPacket(const QString& type, const QVariantMap& body = {}); | ||
53 | 53 | | |||
54 | static void createIdentityPackage(NetworkPackage*); | 54 | static void createIdentityPacket(NetworkPacket*); | ||
55 | 55 | | |||
56 | QByteArray serialize() const; | 56 | QByteArray serialize() const; | ||
57 | static bool unserialize(const QByteArray& json, NetworkPackage* out); | 57 | static bool unserialize(const QByteArray& json, NetworkPacket* out); | ||
58 | 58 | | |||
59 | const QString& id() const { return m_id; } | 59 | const QString& id() const { return m_id; } | ||
60 | const QString& type() const { return m_type; } | 60 | const QString& type() const { return m_type; } | ||
61 | QVariantMap& body() { return m_body; } | 61 | QVariantMap& body() { return m_body; } | ||
62 | const QVariantMap& body() const { return m_body; } | 62 | const QVariantMap& body() const { return m_body; } | ||
63 | 63 | | |||
64 | //Get and set info from body. Note that id and type can not be accessed through these. | 64 | //Get and set info from body. Note that id and type can not be accessed through these. | ||
65 | template<typename T> T get(const QString& key, const T& defaultValue = {}) const { | 65 | template<typename T> T get(const QString& key, const T& defaultValue = {}) const { | ||
Show All 25 Lines | 82 | private: | |||
91 | QVariantMap m_body; | 91 | QVariantMap m_body; | ||
92 | 92 | | |||
93 | QSharedPointer<QIODevice> m_payload; | 93 | QSharedPointer<QIODevice> m_payload; | ||
94 | qint64 m_payloadSize; | 94 | qint64 m_payloadSize; | ||
95 | QVariantMap m_payloadTransferInfo; | 95 | QVariantMap m_payloadTransferInfo; | ||
96 | 96 | | |||
97 | }; | 97 | }; | ||
98 | 98 | | |||
99 | KDECONNECTCORE_EXPORT QDebug operator<<(QDebug s, const NetworkPackage& pkg); | 99 | KDECONNECTCORE_EXPORT QDebug operator<<(QDebug s, const NetworkPacket& pkg); | ||
100 | 100 | | |||
101 | #endif // NETWORKPACKAGE_H | 101 | #endif // NETWORKPACKET_H |