|
1 /* |
|
2 * Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef NMCOMMON_H_ |
|
19 #define NMCOMMON_H_ |
|
20 |
|
21 #include <QtGlobal> |
|
22 #include <QString> |
|
23 #include <QMetaType> |
|
24 #include <QVariant> |
|
25 #include <QDateTime> |
|
26 |
|
27 #include "emailtrace.h" |
|
28 |
|
29 #define USE_POPIMAP_TESTPLUGIN |
|
30 |
|
31 //for pop/imap client plugins testing |
|
32 //used in uiengine, clientplugins and testplugin |
|
33 #ifdef USE_POPIMAP_TESTPLUGIN |
|
34 #define POPTESTPLUGINID 0x2000EEEE |
|
35 #define IMAPTESTPLUGINID 0x2000EEEF |
|
36 #endif |
|
37 |
|
38 /*! |
|
39 \struct NmMailboxEvent |
|
40 \brief Enumeration for mailbox related events |
|
41 */ |
|
42 enum NmMailboxEvent |
|
43 { |
|
44 NmMailboxCreated, |
|
45 NmMailboxChanged, |
|
46 NmMailboxDeleted |
|
47 }; |
|
48 Q_DECLARE_METATYPE(NmMailboxEvent) |
|
49 |
|
50 /*! |
|
51 \struct NmMessageEvent |
|
52 \brief Enumeration for message related events |
|
53 */ |
|
54 enum NmMessageEvent |
|
55 { |
|
56 NmMessageCreated, |
|
57 NmMessageChanged, |
|
58 NmMessageDeleted, |
|
59 NmMessageFound // Search functionality related enumeration. |
|
60 }; |
|
61 Q_DECLARE_METATYPE(NmMessageEvent) |
|
62 |
|
63 enum NmFolderType |
|
64 { |
|
65 NmFolderInbox = 1, |
|
66 NmFolderOutbox, |
|
67 NmFolderDrafts, |
|
68 NmFolderSent, |
|
69 NmFolderDeleted, |
|
70 NmFolderOther |
|
71 }; |
|
72 |
|
73 enum NmConnectState |
|
74 { |
|
75 Connecting, |
|
76 Connected, |
|
77 Disconnecting, |
|
78 Disconnected |
|
79 }; |
|
80 Q_DECLARE_METATYPE(NmConnectState) |
|
81 |
|
82 enum NmSyncState |
|
83 { |
|
84 Synchronizing, |
|
85 SyncComplete |
|
86 }; |
|
87 Q_DECLARE_METATYPE(NmSyncState) |
|
88 |
|
89 enum NmOperationType |
|
90 { |
|
91 NoOp, |
|
92 Synch |
|
93 }; |
|
94 |
|
95 enum NmEnvelopeProperties |
|
96 { |
|
97 MarkAsRead, |
|
98 MarkAsUnread |
|
99 }; |
|
100 |
|
101 enum NmMessagePriority |
|
102 { |
|
103 NmMessagePriorityLow, |
|
104 NmMessagePriorityNormal, |
|
105 NmMessagePriorityHigh |
|
106 }; |
|
107 |
|
108 /*! |
|
109 \struct NmMessageFlag |
|
110 \brief Enumeration for message flags |
|
111 */ |
|
112 enum NmMessageFlag { |
|
113 NmMessageFlagRead = 1, |
|
114 NmMessageFlagReadLocally = 2, |
|
115 NmMessageFlagLow = 4, |
|
116 NmMessageFlagImportant = 8, |
|
117 NmMessageFlagFollowUpComplete = 16, |
|
118 NmMessageFlagFollowUp = 32, |
|
119 NmMessageFlagAttachments = 64, |
|
120 NmMessageFlagMultiple = 128, |
|
121 NmMessageFlagCalendarMsg = 256, |
|
122 NmMessageFlagAnswered = 512, |
|
123 NmMessageFlagForwarded = 1024, |
|
124 NmMessageFlagOnlyToMe = 2048, |
|
125 NmMessageFlagRemoteDeleted = 4096, |
|
126 NmMessageFlagHasMsgSender = 8192 |
|
127 }; |
|
128 Q_DECLARE_FLAGS(NmMessageFlags, NmMessageFlag) |
|
129 Q_DECLARE_OPERATORS_FOR_FLAGS(NmMessageFlags) |
|
130 |
|
131 /** email list sorting options */ |
|
132 enum NmMailSortField |
|
133 { |
|
134 NmMailDontCare, // user accepts any sort order |
|
135 NmMailSortByDate, // sorting is done by date |
|
136 NmMailSortBySender, // sorting is done by sender |
|
137 NmMailSortByRecipient, // sorting is done by recipients |
|
138 NmMailSortBySubject, // sorting is done by subject |
|
139 NmMailSortByPriority, // sorting is done by priority |
|
140 NmMailSortByFlagStatus, // follow up and completed |
|
141 NmMailSortByUnread, // sorting is based on unread |
|
142 NmMailSortBySize, // sorting is done by size |
|
143 NmMailSortByAttachment // sorting is based on if message has attachments |
|
144 }; |
|
145 Q_DECLARE_METATYPE(NmMailSortField) |
|
146 |
|
147 |
|
148 /** email list sort order */ |
|
149 enum NmMailSortOrder |
|
150 { |
|
151 NmMailDescending, |
|
152 NmMailAscending |
|
153 }; |
|
154 Q_DECLARE_METATYPE(NmMailSortOrder) |
|
155 |
|
156 /*! |
|
157 NMail error codes |
|
158 */ |
|
159 |
|
160 const int NmNoError = 0; |
|
161 const int NmNotFoundError = -1; |
|
162 const int NmGeneralError = -2; |
|
163 const int NmCancelError = -3; |
|
164 const int NmAuthenticationError = -200; |
|
165 const int NmServerConnectionError = -201; |
|
166 const int NmConnectionError = -202; |
|
167 |
|
168 /*! |
|
169 Predefined constants for ContentTypes and parameters |
|
170 for ContentType and ContentDisposition |
|
171 */ |
|
172 const QString NmContentTypeMultipartMixed = "multipart/mixed"; |
|
173 const QString NmContentTypeMultipartAlternative = "multipart/alternative"; |
|
174 const QString NmContentTypeMultipartDigest = "multipart/digest"; |
|
175 const QString NmContentTypeMultipartParallel = "multipart/parallel"; |
|
176 const QString NmContentTypeMultipartRelated = "multipart/related"; |
|
177 const QString NmContentTypeTextPlain = "text/plain"; |
|
178 const QString NmContentTypeTextHtml = "text/html"; |
|
179 const QString NmContentTypeTypeMessage = "message/rfc822"; |
|
180 const QString NmContentTypeParamName = " name="; |
|
181 const QString NmContentTypeParamCharset = " charset="; |
|
182 |
|
183 const QString NmContentDispAttachment = " attachment"; |
|
184 const QString NmContentDispParamFilename = " filename="; |
|
185 |
|
186 const QString NmContentDescrAttachmentHtml = "Attachment.html"; |
|
187 |
|
188 /*! |
|
189 It keep info about maximum messages in message list. |
|
190 |
|
191 It is used in NmFrameworkAdapter and NmDataPluginInterface |
|
192 */ |
|
193 static const int NmMaxItemsInMessageList = 1000; |
|
194 |
|
195 /*! |
|
196 \class NmId |
|
197 \brief Unique identifier for any mail spesific objects like mailbox, folder, |
|
198 message, message part etc. Id is stored in unsigned 64 bit integer |
|
199 */ |
|
200 class NmId |
|
201 { |
|
202 public: |
|
203 inline NmId() : mPluginId(0), mId(0) { } |
|
204 inline NmId(quint64 combinedId); |
|
205 inline quint64 id() const; |
|
206 inline void setId(quint64 pluginIdAndId); |
|
207 inline bool operator==(const NmId& id) const; |
|
208 inline bool operator!=(const NmId& id) const; |
|
209 |
|
210 inline quint32 id32() const; |
|
211 inline void setId32(quint32 id32); |
|
212 inline quint32 pluginId32() const; |
|
213 inline void setPluginId32(quint32 pluginId32); |
|
214 |
|
215 private: |
|
216 quint32 mPluginId; |
|
217 quint32 mId; |
|
218 }; |
|
219 |
|
220 Q_DECLARE_METATYPE(NmId) |
|
221 Q_DECLARE_METATYPE(QList<NmId>) |
|
222 |
|
223 /*! |
|
224 Constructor for nm id \a id is 64 bit unsigned integer |
|
225 */ |
|
226 inline NmId::NmId(quint64 combinedId) |
|
227 { |
|
228 setId(combinedId); |
|
229 } |
|
230 |
|
231 /*! |
|
232 Setter for nm id \a id is 64 bit unsigned integer |
|
233 */ |
|
234 inline void NmId::setId(quint64 pluginIdAndId) |
|
235 { |
|
236 // first 32 bits (from big end) refers fs plugin id |
|
237 mPluginId = pluginIdAndId >> 32; |
|
238 // last 32 bits refers fs id |
|
239 mId = pluginIdAndId; |
|
240 } |
|
241 |
|
242 /*! |
|
243 Returns 64 unsigned integer id |
|
244 */ |
|
245 inline quint64 NmId::id() const |
|
246 { |
|
247 quint64 id = mPluginId; |
|
248 id = id << 32; |
|
249 id += mId; |
|
250 return id; |
|
251 } |
|
252 |
|
253 /*! |
|
254 Equal operator |
|
255 */ |
|
256 inline bool NmId::operator==(const NmId& id) const |
|
257 { |
|
258 bool ret = true; |
|
259 if ((mId != id.mId) || (mPluginId != id.mPluginId)) { |
|
260 ret = false; |
|
261 } |
|
262 return ret; |
|
263 } |
|
264 |
|
265 /*! |
|
266 Not equal operator |
|
267 */ |
|
268 inline bool NmId::operator!=(const NmId& id) const |
|
269 { |
|
270 bool ret = false; |
|
271 if ((mId != id.mId) || (mPluginId != id.mPluginId)) { |
|
272 ret = true; |
|
273 } |
|
274 return ret; |
|
275 } |
|
276 |
|
277 /*! |
|
278 return unsigned 32-bit id |
|
279 */ |
|
280 inline quint32 NmId::id32() const |
|
281 { |
|
282 return mId; |
|
283 } |
|
284 |
|
285 /*! |
|
286 returns unsigned 32-bit plugin id |
|
287 */ |
|
288 inline quint32 NmId::pluginId32() const |
|
289 { |
|
290 return mPluginId; |
|
291 } |
|
292 |
|
293 /*! |
|
294 sets unique 32-bit id |
|
295 */ |
|
296 inline void NmId::setId32(quint32 id32) |
|
297 { |
|
298 mId = id32; |
|
299 } |
|
300 |
|
301 /*! |
|
302 sets unique 32-bit plugin id |
|
303 */ |
|
304 inline void NmId::setPluginId32(quint32 pluginId32) |
|
305 { |
|
306 mPluginId = pluginId32; |
|
307 } |
|
308 |
|
309 /*! email list sort criteria definition */ |
|
310 class NmMailSortCriteria |
|
311 { |
|
312 public: |
|
313 NmMailSortField mField; |
|
314 NmMailSortOrder mOrder; |
|
315 }; |
|
316 |
|
317 /*! |
|
318 \class NmOperationCompletionEvent |
|
319 \brief Generic wrapper for information related to asynchronous operations |
|
320 */ |
|
321 class NmOperationCompletionEvent |
|
322 { |
|
323 public: |
|
324 NmOperationType mOperationType; |
|
325 int mCompletionCode; |
|
326 NmId mMailboxId; |
|
327 NmId mFolderId; |
|
328 NmId mMessageId; |
|
329 }; |
|
330 Q_DECLARE_METATYPE(NmOperationCompletionEvent) |
|
331 |
|
332 #endif /* NMCOMMON_H_ */ |
|
333 |
|
334 |
|
335 |