Changeset View
Changeset View
Standalone View
Standalone View
interfaces/conversationmessage.h
Show All 26 Lines | |||||
27 | #include <QVariantMap> | 27 | #include <QVariantMap> | ||
28 | 28 | | |||
29 | #include "interfaces/kdeconnectinterfaces_export.h" | 29 | #include "interfaces/kdeconnectinterfaces_export.h" | ||
30 | 30 | | |||
31 | class KDECONNECTINTERFACES_EXPORT ConversationMessage | 31 | class KDECONNECTINTERFACES_EXPORT ConversationMessage | ||
32 | : public QObject { | 32 | : public QObject { | ||
33 | Q_OBJECT | 33 | Q_OBJECT | ||
34 | Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.telephony.messages") | 34 | Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.telephony.messages") | ||
35 | Q_PROPERTY(qint32 eventField READ eventField) | ||||
35 | Q_PROPERTY(QString body READ body) | 36 | Q_PROPERTY(QString body READ body) | ||
36 | Q_PROPERTY(QString address READ address) | 37 | Q_PROPERTY(QString address READ address) | ||
37 | Q_PROPERTY(qint64 date READ date) | 38 | Q_PROPERTY(qint64 date READ date) | ||
38 | Q_PROPERTY(qint32 type READ type) | 39 | Q_PROPERTY(qint32 type READ type) | ||
39 | Q_PROPERTY(qint32 read READ read) | 40 | Q_PROPERTY(qint32 read READ read) | ||
40 | Q_PROPERTY(qint32 threadID READ threadID) | 41 | Q_PROPERTY(qint32 threadID READ threadID) | ||
41 | Q_PROPERTY(qint32 uID READ uID) | 42 | Q_PROPERTY(qint32 uID READ uID) | ||
42 | 43 | | |||
43 | public: | 44 | public: | ||
44 | // TYPE field values from Android | 45 | // TYPE field values from Android | ||
45 | enum Types { | 46 | enum Types { | ||
46 | MessageTypeAll = 0, | 47 | MessageTypeAll = 0, | ||
47 | MessageTypeInbox = 1, | 48 | MessageTypeInbox = 1, | ||
48 | MessageTypeSent = 2, | 49 | MessageTypeSent = 2, | ||
49 | MessageTypeDraft = 3, | 50 | MessageTypeDraft = 3, | ||
50 | MessageTypeOutbox = 4, | 51 | MessageTypeOutbox = 4, | ||
51 | MessageTypeFailed = 5, | 52 | MessageTypeFailed = 5, | ||
52 | MessageTypeQueued = 6, | 53 | MessageTypeQueued = 6, | ||
53 | }; | 54 | }; | ||
54 | Q_ENUM(Types); | 55 | Q_ENUM(Types); | ||
55 | 56 | | |||
56 | /** | 57 | /** | ||
58 | * Values describing the possible type of events contained in a message | ||||
59 | * A message's eventField is constructed as a bitwise-OR of events | ||||
60 | * Any events which are unsupported should be ignored | ||||
61 | */ | ||||
62 | enum Events { | ||||
63 | EventTextMessage = 0x1, // This message has a body field which contains pure, human-readable text | ||||
64 | }; | ||||
65 | Q_ENUM(Events) | ||||
66 | | ||||
67 | /** | ||||
57 | * Build a new message from a keyword argument dictionary | 68 | * Build a new message from a keyword argument dictionary | ||
58 | * | 69 | * | ||
59 | * @param args mapping of field names to values as might be contained in a network packet containing a message | 70 | * @param args mapping of field names to values as might be contained in a network packet containing a message | ||
60 | */ | 71 | */ | ||
61 | ConversationMessage(const QVariantMap& args = QVariantMap(), QObject* parent = Q_NULLPTR); | 72 | ConversationMessage(const QVariantMap& args = QVariantMap(), QObject* parent = Q_NULLPTR); | ||
62 | 73 | | |||
63 | ConversationMessage(const QString& body, const QString& address, const qint64& date, | 74 | ConversationMessage(const qint32& eventField, const QString& body, const QString& address, | ||
64 | const qint32& type, const qint32& read, const qint32& threadID, | 75 | const qint64& date, const qint32& type, const qint32& read, | ||
65 | const qint32& uID, | 76 | const qint32& threadID, const qint32& uID, | ||
66 | QObject* parent = Q_NULLPTR); | 77 | QObject* parent = Q_NULLPTR); | ||
67 | 78 | | |||
68 | ConversationMessage(const ConversationMessage& other, QObject* parent = Q_NULLPTR); | 79 | ConversationMessage(const ConversationMessage& other, QObject* parent = Q_NULLPTR); | ||
69 | ~ConversationMessage(); | 80 | ~ConversationMessage(); | ||
70 | ConversationMessage& operator=(const ConversationMessage& other); | 81 | ConversationMessage& operator=(const ConversationMessage& other); | ||
71 | static void registerDbusType(); | 82 | static void registerDbusType(); | ||
72 | 83 | | |||
84 | qint32 eventField() const { return m_eventField; } | ||||
73 | QString body() const { return m_body; } | 85 | QString body() const { return m_body; } | ||
74 | QString address() const { return m_address; } | 86 | QString address() const { return m_address; } | ||
75 | qint64 date() const { return m_date; } | 87 | qint64 date() const { return m_date; } | ||
76 | qint32 type() const { return m_type; } | 88 | qint32 type() const { return m_type; } | ||
77 | qint32 read() const { return m_read; } | 89 | qint32 read() const { return m_read; } | ||
78 | qint32 threadID() const { return m_threadID; } | 90 | qint32 threadID() const { return m_threadID; } | ||
79 | qint32 uID() const { return m_uID; } | 91 | qint32 uID() const { return m_uID; } | ||
80 | 92 | | |||
81 | QVariantMap toVariant() const; | 93 | QVariantMap toVariant() const; | ||
82 | 94 | | |||
95 | bool containsTextBody() const { return (eventField() & ConversationMessage::EventTextMessage); } | ||||
apol: How about `isTextMessage`?
Pure reads weird. | |||||
The reason for not "isTextMessage" is because you could have a picture message which also contains text, so saying "isTextMessage" would technically be not true. The message I am trying to get across with "containsPureText" is that the message contains something which can be directly displayed, as opposed to HTML or some other weirdness. I could change it to something like "containsTextBody" or something if you like that better sredman: The reason for not "isTextMessage" is because you could have a picture message which also… | |||||
apol: I like containsTextBody more, yes. | |||||
96 | | ||||
83 | protected: | 97 | protected: | ||
84 | /** | 98 | /** | ||
99 | * Bitwise OR of event flags | ||||
100 | * Unsupported flags shall cause the message to be ignored | ||||
101 | */ | ||||
102 | qint32 m_eventField; | ||||
103 | | ||||
104 | /** | ||||
85 | * Body of the message | 105 | * Body of the message | ||
86 | */ | 106 | */ | ||
87 | QString m_body; | 107 | QString m_body; | ||
88 | 108 | | |||
89 | /** | 109 | /** | ||
90 | * Remote-side address of the message. Most likely a phone number, but may be an email address | 110 | * Remote-side address of the message. Most likely a phone number, but may be an email address | ||
91 | */ | 111 | */ | ||
92 | QString m_address; | 112 | QString m_address; | ||
Show All 30 Lines |
How about isTextMessage?
Pure reads weird.