1 | /* |
2 | Copyright (c) 2007 Volker Krause <vkrause@kde.org> |
3 | |
4 | This library is free software; you can redistribute it and/or modify it |
5 | under the terms of the GNU Library General Public License as published by |
6 | the Free Software Foundation; either version 2 of the License, or (at your |
7 | option) any later version. |
8 | |
9 | This library is distributed in the hope that it will be useful, but WITHOUT |
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public |
12 | License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to the |
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
17 | 02110-1301, USA. |
18 | */ |
19 | |
20 | #ifndef AKONADI_NOTIFICATIONMESSAGE_P_H |
21 | #define AKONADI_NOTIFICATIONMESSAGE_P_H |
22 | |
23 | #include "akonadiprotocolinternals_export.h" |
24 | |
25 | #include <QtCore/QList> |
26 | #include <QtCore/QMetaType> |
27 | #include <QtCore/QSharedDataPointer> |
28 | #include <QtDBus/QDBusArgument> |
29 | |
30 | namespace Akonadi { |
31 | |
32 | /** |
33 | @internal |
34 | Used for sending notification signals over DBus. |
35 | DBus type: (ayiiisayisas) |
36 | */ |
37 | |
38 | class AKONADIPROTOCOLINTERNALS_EXPORT NotificationMessage |
39 | { |
40 | public: |
41 | typedef QList<NotificationMessage> List; |
42 | typedef qint64 Id; |
43 | |
44 | enum Type { |
45 | InvalidType, |
46 | Collection, |
47 | Item |
48 | }; |
49 | |
50 | enum Operation { |
51 | InvalidOp, |
52 | Add, |
53 | Modify, |
54 | Move, |
55 | Remove, |
56 | Link, |
57 | Unlink, |
58 | Subscribe, |
59 | Unsubscribe |
60 | }; |
61 | |
62 | NotificationMessage(); |
63 | NotificationMessage(const NotificationMessage &other); |
64 | ~NotificationMessage(); |
65 | |
66 | NotificationMessage &operator=(const NotificationMessage &other); |
67 | bool operator==(const NotificationMessage &other) const; |
68 | |
69 | static void registerDBusTypes(); |
70 | |
71 | QByteArray sessionId() const; |
72 | void setSessionId(const QByteArray &sessionId); |
73 | |
74 | Type type() const; |
75 | void setType(Type type); |
76 | |
77 | Operation operation() const; |
78 | void setOperation(Operation operation); |
79 | |
80 | Id uid() const; |
81 | void setUid(Id uid); |
82 | |
83 | QString remoteId() const; |
84 | void setRemoteId(const QString &remoteId); |
85 | |
86 | QByteArray resource() const; |
87 | void setResource(const QByteArray &resource); |
88 | |
89 | Id parentCollection() const; |
90 | void setParentCollection(Id parent); |
91 | |
92 | Id parentDestCollection() const; |
93 | void setParentDestCollection(Id parent); |
94 | |
95 | QByteArray destinationResource() const; |
96 | void setDestinationResource(const QByteArray &destResource); |
97 | |
98 | QString mimeType() const; |
99 | void setMimeType(const QString &mimeType); |
100 | |
101 | QSet<QByteArray> itemParts() const; |
102 | void setItemParts(const QSet<QByteArray> &parts); |
103 | |
104 | QString toString() const; |
105 | |
106 | /** |
107 | Adds a new notification message to the given list and compresses notifications |
108 | where possible. |
109 | */ |
110 | static void appendAndCompress(NotificationMessage::List &list, const NotificationMessage &msg); |
111 | // BIC: make the above return bool. |
112 | static void appendAndCompress(NotificationMessage::List &list, const NotificationMessage &msg, bool *appended); |
113 | |
114 | private: |
115 | class Private; |
116 | QSharedDataPointer<Private> d; |
117 | }; |
118 | |
119 | } |
120 | |
121 | QDBusArgument &operator<<(QDBusArgument &arg, const Akonadi::NotificationMessage &msg); |
122 | const QDBusArgument &operator>>(const QDBusArgument &arg, Akonadi::NotificationMessage &msg); |
123 | |
124 | uint qHash(const Akonadi::NotificationMessage &msg); |
125 | |
126 | Q_DECLARE_TYPEINFO(Akonadi::NotificationMessage, Q_MOVABLE_TYPE); |
127 | |
128 | Q_DECLARE_METATYPE(Akonadi::NotificationMessage) |
129 | Q_DECLARE_METATYPE(Akonadi::NotificationMessage::List) |
130 | |
131 | // V2 is used in NotificationSource.xml interface, so it must be |
132 | // defined so that old clients that only include this header |
133 | // will compile |
134 | #include "notificationmessagev2_p.h" |
135 | |
136 | #endif |
137 | |