Changeset View
Changeset View
Standalone View
Standalone View
interfaces/conversationmessage.h
- This file was added.
1 | /** | ||||
---|---|---|---|---|---|
2 | * Copyright 2018 Simon Redman <simon@ergotech.com> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2 of | ||||
7 | * the License or (at your option) version 3 or any later version | ||||
8 | * accepted by the membership of KDE e.V. (or its successor approved | ||||
9 | * by the membership of KDE e.V.), which shall act as a proxy | ||||
10 | * defined in Section 14 of version 3 of the license. | ||||
11 | * | ||||
12 | * This program is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | * GNU General Public License for more details. | ||||
16 | * | ||||
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/>. | ||||
19 | */ | ||||
20 | | ||||
21 | #ifndef PLUGINS_TELEPHONY_CONVERSATIONMESSAGE_H_ | ||||
22 | #define PLUGINS_TELEPHONY_CONVERSATIONMESSAGE_H_ | ||||
23 | | ||||
24 | #include <QObject> | ||||
25 | #include <QDBusMetaType> | ||||
26 | #include <QDBusArgument> | ||||
27 | #include <QVariantMap> | ||||
28 | | ||||
29 | #include "interfaces/kdeconnectinterfaces_export.h" | ||||
30 | | ||||
31 | class KDECONNECTINTERFACES_EXPORT ConversationMessage | ||||
32 | : public QObject { | ||||
33 | Q_OBJECT | ||||
34 | Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.telephony.messages") | ||||
35 | Q_PROPERTY(QString body READ body) | ||||
36 | Q_PROPERTY(QString address READ address) | ||||
37 | Q_PROPERTY(qint64 date READ date) | ||||
38 | Q_PROPERTY(qint32 type READ type) | ||||
39 | Q_PROPERTY(qint32 read READ read) | ||||
40 | Q_PROPERTY(qint32 threadID READ threadID) | ||||
41 | Q_PROPERTY(qint32 uID READ uID) | ||||
42 | | ||||
43 | public: | ||||
44 | // TYPE field values from Android | ||||
45 | enum Types | ||||
46 | { | ||||
47 | MessageTypeAll = 0, | ||||
48 | MessageTypeInbox = 1, | ||||
49 | MessageTypeSent = 2, | ||||
50 | MessageTypeDraft = 3, | ||||
51 | MessageTypeOutbox = 4, | ||||
52 | MessageTypeFailed = 5, | ||||
53 | MessageTypeQueued = 6, | ||||
54 | }; | ||||
55 | Q_ENUM(Types); | ||||
56 | | ||||
57 | /** | ||||
58 | * Build a new message from a keyword argument dictionary | ||||
59 | * | ||||
60 | * @param args mapping of field names to values as might be contained in a network packet containing a message | ||||
61 | */ | ||||
62 | ConversationMessage(const QVariantMap& args = QVariantMap(), QObject* parent = Q_NULLPTR); | ||||
63 | | ||||
64 | ConversationMessage(const QString& body, const QString& address, const qint64& date, | ||||
65 | const qint32& type, const qint32& read, const qint32& threadID, | ||||
66 | const qint32& uID, | ||||
67 | QObject* parent = Q_NULLPTR); | ||||
68 | | ||||
69 | ConversationMessage(const ConversationMessage& other, QObject* parent = Q_NULLPTR); | ||||
70 | ~ConversationMessage(); | ||||
71 | ConversationMessage& operator=(const ConversationMessage& other); | ||||
72 | static void registerDbusType(); | ||||
73 | | ||||
74 | QString body() const { return m_body; } | ||||
75 | QString address() const { return m_address; } | ||||
76 | qint64 date() const { return m_date; } | ||||
77 | qint32 type() const { return m_type; } | ||||
78 | qint32 read() const { return m_read; } | ||||
79 | qint32 threadID() const { return m_threadID; } | ||||
80 | qint32 uID() const { return m_uID; } | ||||
81 | | ||||
82 | QVariantMap toVariant() const; | ||||
83 | | ||||
84 | protected: | ||||
85 | /** | ||||
86 | * Body of the message | ||||
87 | */ | ||||
88 | QString m_body; | ||||
89 | | ||||
90 | /** | ||||
91 | * Remote-side address of the message. Most likely a phone number, but may be an email address | ||||
92 | */ | ||||
93 | QString m_address; | ||||
94 | | ||||
95 | /** | ||||
96 | * Date stamp (Unix epoch millis) associated with the message | ||||
97 | */ | ||||
98 | qint64 m_date; | ||||
99 | | ||||
100 | /** | ||||
101 | * Type of the message. See the message.type enum | ||||
102 | */ | ||||
103 | qint32 m_type; | ||||
104 | | ||||
105 | /** | ||||
106 | * Whether we have a read report for this message | ||||
107 | */ | ||||
108 | qint32 m_read; | ||||
109 | | ||||
110 | /** | ||||
111 | * Tag which binds individual messages into a thread | ||||
112 | */ | ||||
113 | qint32 m_threadID; | ||||
114 | | ||||
115 | /** | ||||
116 | * Value which uniquely identifies a message | ||||
117 | */ | ||||
118 | qint32 m_uID; | ||||
119 | }; | ||||
120 | | ||||
121 | Q_DECLARE_METATYPE(ConversationMessage); | ||||
122 | | ||||
123 | #endif /* PLUGINS_TELEPHONY_CONVERSATIONMESSAGE_H_ */ |