|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "qmailid.h" |
|
43 |
|
44 class MailIdPrivate : public QSharedData |
|
45 { |
|
46 public: |
|
47 MailIdPrivate():QSharedData(){}; |
|
48 |
|
49 quint64 id; |
|
50 }; |
|
51 |
|
52 Q_IMPLEMENT_USER_METATYPE(MailId); |
|
53 |
|
54 MailId::MailId() |
|
55 { |
|
56 d = new MailIdPrivate(); |
|
57 d->id = 0; |
|
58 } |
|
59 |
|
60 MailId::MailId(quint64 value) |
|
61 { |
|
62 d = new MailIdPrivate(); |
|
63 d->id = value; |
|
64 } |
|
65 |
|
66 MailId::MailId(const MailId& other) |
|
67 { |
|
68 d = other.d; |
|
69 } |
|
70 |
|
71 MailId::~MailId() |
|
72 { |
|
73 } |
|
74 |
|
75 MailId& MailId::operator=(const MailId& other) |
|
76 { |
|
77 d = other.d; |
|
78 return *this; |
|
79 } |
|
80 |
|
81 bool MailId::isValid() const |
|
82 { |
|
83 return d->id != 0; |
|
84 } |
|
85 |
|
86 quint64 MailId::toULongLong() const |
|
87 { |
|
88 return d->id; |
|
89 } |
|
90 |
|
91 bool MailId::operator!= (const MailId & other) const |
|
92 { |
|
93 return d->id != other.d->id; |
|
94 } |
|
95 |
|
96 bool MailId::operator== (const MailId& other) const |
|
97 { |
|
98 return d->id == other.d->id; |
|
99 } |
|
100 |
|
101 bool MailId::operator< (const MailId& other) const |
|
102 { |
|
103 return d->id < other.d->id; |
|
104 } |
|
105 |
|
106 template <typename Stream> void MailId::serialize(Stream &stream) const |
|
107 { |
|
108 stream << d->id; |
|
109 } |
|
110 |
|
111 template <typename Stream> void MailId::deserialize(Stream &stream) |
|
112 { |
|
113 stream >> d->id; |
|
114 } |
|
115 |
|
116 |
|
117 QDebug& operator<< (QDebug& debug, const MailId &id) |
|
118 { |
|
119 return debug << id.toULongLong(); |
|
120 } |
|
121 |
|
122 QTextStream& operator<< (QTextStream& s, const MailId &id) |
|
123 { |
|
124 return s << id.toULongLong(); |
|
125 } |
|
126 |
|
127 /*! |
|
128 \class QMailAccountId |
|
129 \ingroup messaginglibrary |
|
130 |
|
131 \preliminary |
|
132 \brief The QMailAccountId class is used to identify accounts stored by QMailStore. |
|
133 |
|
134 QMailAccountId is a class used to represent accounts stored by the QMailStore, identified |
|
135 by their unique numeric internal indentifer. |
|
136 |
|
137 A QMailAccountId instance can be tested for validity, and compared to other instances |
|
138 for equality. The numeric value of the identifier is not intrinsically meaningful |
|
139 and cannot be modified. |
|
140 |
|
141 \sa QMailAccount, QMailStore::account() |
|
142 */ |
|
143 |
|
144 /*! |
|
145 \typedef QMailAccountIdList |
|
146 \relates QMailAccountId |
|
147 */ |
|
148 |
|
149 Q_IMPLEMENT_USER_METATYPE(QMailAccountId); |
|
150 |
|
151 /*! |
|
152 Construct an uninitialized QMailAccountId, for which isValid() returns false. |
|
153 */ |
|
154 QMailAccountId::QMailAccountId() |
|
155 : MailId() |
|
156 { |
|
157 } |
|
158 |
|
159 /*! |
|
160 Construct a QMailAccountId with the supplied numeric identifier \a value. |
|
161 */ |
|
162 QMailAccountId::QMailAccountId(quint64 value) |
|
163 : MailId(value) |
|
164 { |
|
165 } |
|
166 |
|
167 /*! \internal */ |
|
168 QMailAccountId::QMailAccountId(const QMailAccountId& other) |
|
169 : MailId(other) |
|
170 { |
|
171 } |
|
172 |
|
173 /*! \internal */ |
|
174 QMailAccountId::~QMailAccountId() |
|
175 { |
|
176 } |
|
177 |
|
178 /*! \internal */ |
|
179 QMailAccountId& QMailAccountId::operator=(const QMailAccountId& other) |
|
180 { |
|
181 MailId::operator=(other); |
|
182 return *this; |
|
183 } |
|
184 |
|
185 /*! |
|
186 Returns true if this object has been initialized with the identifier of an |
|
187 existing message contained by QMailStore. |
|
188 */ |
|
189 bool QMailAccountId::isValid() const |
|
190 { |
|
191 return MailId::isValid(); |
|
192 } |
|
193 |
|
194 /*! \internal */ |
|
195 quint64 QMailAccountId::toULongLong() const |
|
196 { |
|
197 return MailId::toULongLong(); |
|
198 } |
|
199 |
|
200 /*! |
|
201 Returns a QVariant containing the value of this account identfier. |
|
202 */ |
|
203 QMailAccountId::operator QVariant() const |
|
204 { |
|
205 return QVariant::fromValue(*this); |
|
206 } |
|
207 |
|
208 /*! |
|
209 Returns true if this object's identifier value differs from that of \a other. |
|
210 */ |
|
211 bool QMailAccountId::operator!= (const QMailAccountId& other) const |
|
212 { |
|
213 return MailId::operator!=(other); |
|
214 } |
|
215 |
|
216 /*! |
|
217 Returns true if this object's identifier value is equal to that of \a other. |
|
218 */ |
|
219 bool QMailAccountId::operator== (const QMailAccountId& other) const |
|
220 { |
|
221 return MailId::operator==(other); |
|
222 } |
|
223 |
|
224 /*! |
|
225 Returns true if this object's identifier value is less than that of \a other. |
|
226 */ |
|
227 bool QMailAccountId::operator< (const QMailAccountId& other) const |
|
228 { |
|
229 return MailId::operator<(other); |
|
230 } |
|
231 |
|
232 /*! |
|
233 \fn QMailAccountId::serialize(Stream&) const |
|
234 \internal |
|
235 */ |
|
236 template <typename Stream> void QMailAccountId::serialize(Stream &stream) const |
|
237 { |
|
238 MailId::serialize(stream); |
|
239 } |
|
240 |
|
241 /*! |
|
242 \fn QMailAccountId::deserialize(Stream&) |
|
243 \internal |
|
244 */ |
|
245 template <typename Stream> void QMailAccountId::deserialize(Stream &stream) |
|
246 { |
|
247 MailId::deserialize(stream); |
|
248 } |
|
249 |
|
250 /*! \internal */ |
|
251 QDebug& operator<< (QDebug& debug, const QMailAccountId &id) |
|
252 { |
|
253 return debug << static_cast<const MailId&>(id); |
|
254 } |
|
255 |
|
256 /*! \internal */ |
|
257 QTextStream& operator<< (QTextStream& s, const QMailAccountId &id) |
|
258 { |
|
259 return s << static_cast<const MailId&>(id); |
|
260 } |
|
261 |
|
262 |
|
263 Q_IMPLEMENT_USER_METATYPE_TYPEDEF(QMailAccountIdList, QMailAccountIdList) |
|
264 |
|
265 /*! |
|
266 \class QMailFolderId |
|
267 \ingroup messaginglibrary |
|
268 |
|
269 \preliminary |
|
270 \brief The QMailFolderId class is used to identify folders stored by QMailStore. |
|
271 |
|
272 QMailFolderId is a class used to represent folders stored by the QMailStore, identified |
|
273 by their unique numeric internal indentifer. |
|
274 |
|
275 A QMailFolderId instance can be tested for validity, and compared to other instances |
|
276 for equality. The numeric value of the identifier is not intrinsically meaningful |
|
277 and cannot be modified. |
|
278 |
|
279 \sa QMailFolder, QMailStore::folder() |
|
280 */ |
|
281 |
|
282 /*! |
|
283 \typedef QMailFolderIdList |
|
284 \relates QMailFolderId |
|
285 */ |
|
286 |
|
287 Q_IMPLEMENT_USER_METATYPE(QMailFolderId); |
|
288 |
|
289 /*! |
|
290 Construct an uninitialized QMailFolderId, for which isValid() returns false. |
|
291 */ |
|
292 QMailFolderId::QMailFolderId() |
|
293 : MailId() |
|
294 { |
|
295 } |
|
296 |
|
297 /*! |
|
298 Construct a QMailFolderId corresponding to the predefined folder identifier \a id. |
|
299 */ |
|
300 QMailFolderId::QMailFolderId(QMailFolderFwd::PredefinedFolderId id) |
|
301 : MailId(static_cast<quint64>(id)) |
|
302 { |
|
303 } |
|
304 |
|
305 /*! |
|
306 Construct a QMailFolderId with the supplied numeric identifier \a value. |
|
307 */ |
|
308 QMailFolderId::QMailFolderId(quint64 value) |
|
309 : MailId(value) |
|
310 { |
|
311 } |
|
312 |
|
313 /*! \internal */ |
|
314 QMailFolderId::QMailFolderId(const QMailFolderId& other) |
|
315 : MailId(other) |
|
316 { |
|
317 } |
|
318 |
|
319 /*! \internal */ |
|
320 QMailFolderId::~QMailFolderId() |
|
321 { |
|
322 } |
|
323 |
|
324 /*! \internal */ |
|
325 QMailFolderId& QMailFolderId::operator=(const QMailFolderId& other) |
|
326 { |
|
327 MailId::operator=(other); |
|
328 return *this; |
|
329 } |
|
330 |
|
331 /*! |
|
332 Returns true if this object has been initialized with the identifier of an |
|
333 existing message contained by QMailStore. |
|
334 */ |
|
335 bool QMailFolderId::isValid() const |
|
336 { |
|
337 return MailId::isValid(); |
|
338 } |
|
339 |
|
340 /*! \internal */ |
|
341 quint64 QMailFolderId::toULongLong() const |
|
342 { |
|
343 return MailId::toULongLong(); |
|
344 } |
|
345 |
|
346 /*! |
|
347 Returns a QVariant containing the value of this folder identfier. |
|
348 */ |
|
349 QMailFolderId::operator QVariant() const |
|
350 { |
|
351 return QVariant::fromValue(*this); |
|
352 } |
|
353 |
|
354 /*! |
|
355 Returns true if this object's identifier value differs from that of \a other. |
|
356 */ |
|
357 bool QMailFolderId::operator!= (const QMailFolderId& other) const |
|
358 { |
|
359 return MailId::operator!=(other); |
|
360 } |
|
361 |
|
362 /*! |
|
363 Returns true if this object's identifier value is equal to that of \a other. |
|
364 */ |
|
365 bool QMailFolderId::operator== (const QMailFolderId& other) const |
|
366 { |
|
367 return MailId::operator==(other); |
|
368 } |
|
369 |
|
370 /*! |
|
371 Returns true if this object's identifier value is less than that of \a other. |
|
372 */ |
|
373 bool QMailFolderId::operator< (const QMailFolderId& other) const |
|
374 { |
|
375 return MailId::operator<(other); |
|
376 } |
|
377 |
|
378 /*! |
|
379 \fn QMailFolderId::serialize(Stream&) const |
|
380 \internal |
|
381 */ |
|
382 template <typename Stream> void QMailFolderId::serialize(Stream &stream) const |
|
383 { |
|
384 MailId::serialize(stream); |
|
385 } |
|
386 |
|
387 /*! |
|
388 \fn QMailFolderId::deserialize(Stream&) |
|
389 \internal |
|
390 */ |
|
391 template <typename Stream> void QMailFolderId::deserialize(Stream &stream) |
|
392 { |
|
393 MailId::deserialize(stream); |
|
394 } |
|
395 |
|
396 /*! \internal */ |
|
397 QDebug& operator<< (QDebug& debug, const QMailFolderId &id) |
|
398 { |
|
399 return debug << static_cast<const MailId&>(id); |
|
400 } |
|
401 |
|
402 /*! \internal */ |
|
403 QTextStream& operator<< (QTextStream& s, const QMailFolderId &id) |
|
404 { |
|
405 return s << static_cast<const MailId&>(id); |
|
406 } |
|
407 |
|
408 Q_IMPLEMENT_USER_METATYPE_TYPEDEF(QMailFolderIdList, QMailFolderIdList) |
|
409 |
|
410 |
|
411 /*! |
|
412 \class QMailMessageId |
|
413 \ingroup messaginglibrary |
|
414 |
|
415 \preliminary |
|
416 \brief The QMailMessageId class is used to identify messages stored by QMailStore. |
|
417 |
|
418 QMailMessageId is a class used to represent messages stored by the QMailStore, identified |
|
419 by their unique numeric internal indentifer. |
|
420 |
|
421 A QMailMessageId instance can be tested for validity, and compared to other instances |
|
422 for equality. The numeric value of the identifier is not intrinsically meaningful |
|
423 and cannot be modified. |
|
424 |
|
425 \sa QMailMessage, QMailStore::message() |
|
426 */ |
|
427 |
|
428 /*! |
|
429 \typedef QMailMessageIdList |
|
430 \relates QMailMessageId |
|
431 */ |
|
432 |
|
433 Q_IMPLEMENT_USER_METATYPE(QMailMessageId); |
|
434 |
|
435 /*! |
|
436 Construct an uninitialized QMailMessageId, for which isValid() returns false. |
|
437 */ |
|
438 QMailMessageId::QMailMessageId() |
|
439 : MailId() |
|
440 { |
|
441 } |
|
442 |
|
443 /*! |
|
444 Construct a QMailMessageId with the supplied numeric identifier \a value. |
|
445 */ |
|
446 QMailMessageId::QMailMessageId(quint64 value) |
|
447 : MailId(value) |
|
448 { |
|
449 } |
|
450 |
|
451 /*! \internal */ |
|
452 QMailMessageId::QMailMessageId(const QMailMessageId& other) |
|
453 : MailId(other) |
|
454 { |
|
455 } |
|
456 |
|
457 /*! \internal */ |
|
458 QMailMessageId::~QMailMessageId() |
|
459 { |
|
460 } |
|
461 |
|
462 /*! \internal */ |
|
463 QMailMessageId& QMailMessageId::operator=(const QMailMessageId& other) |
|
464 { |
|
465 MailId::operator=(other); |
|
466 return *this; |
|
467 } |
|
468 |
|
469 /*! |
|
470 Returns true if this object has been initialized with the identifier of an |
|
471 existing message contained by QMailStore. |
|
472 */ |
|
473 bool QMailMessageId::isValid() const |
|
474 { |
|
475 return MailId::isValid(); |
|
476 } |
|
477 |
|
478 /*! \internal */ |
|
479 quint64 QMailMessageId::toULongLong() const |
|
480 { |
|
481 return MailId::toULongLong(); |
|
482 } |
|
483 |
|
484 /*! |
|
485 Returns a QVariant containing the value of this message identfier. |
|
486 */ |
|
487 QMailMessageId::operator QVariant() const |
|
488 { |
|
489 return QVariant::fromValue(*this); |
|
490 } |
|
491 |
|
492 /*! |
|
493 Returns true if this object's identifier value differs from that of \a other. |
|
494 */ |
|
495 bool QMailMessageId::operator!= (const QMailMessageId& other) const |
|
496 { |
|
497 return MailId::operator!=(other); |
|
498 } |
|
499 |
|
500 /*! |
|
501 Returns true if this object's identifier value is equal to that of \a other. |
|
502 */ |
|
503 bool QMailMessageId::operator== (const QMailMessageId& other) const |
|
504 { |
|
505 return MailId::operator==(other); |
|
506 } |
|
507 |
|
508 /*! |
|
509 Returns true if this object's identifier value is less than that of \a other. |
|
510 */ |
|
511 bool QMailMessageId::operator< (const QMailMessageId& other) const |
|
512 { |
|
513 return MailId::operator<(other); |
|
514 } |
|
515 |
|
516 /*! |
|
517 \fn QMailMessageId::serialize(Stream&) const |
|
518 \internal |
|
519 */ |
|
520 template <typename Stream> void QMailMessageId::serialize(Stream &stream) const |
|
521 { |
|
522 MailId::serialize(stream); |
|
523 } |
|
524 |
|
525 /*! |
|
526 \fn QMailMessageId::deserialize(Stream&) |
|
527 \internal |
|
528 */ |
|
529 template <typename Stream> void QMailMessageId::deserialize(Stream &stream) |
|
530 { |
|
531 MailId::deserialize(stream); |
|
532 } |
|
533 |
|
534 /*! \internal */ |
|
535 QDebug& operator<< (QDebug& debug, const QMailMessageId &id) |
|
536 { |
|
537 return debug << static_cast<const MailId&>(id); |
|
538 } |
|
539 |
|
540 /*! \internal */ |
|
541 QTextStream& operator<< (QTextStream& s, const QMailMessageId &id) |
|
542 { |
|
543 return s << static_cast<const MailId&>(id); |
|
544 } |
|
545 |
|
546 Q_IMPLEMENT_USER_METATYPE_TYPEDEF(QMailMessageIdList, QMailMessageIdList) |
|
547 |
|
548 /*! \internal */ |
|
549 uint qHash(const QMailAccountId &id) |
|
550 { |
|
551 return qHash(id.toULongLong()); |
|
552 } |
|
553 |
|
554 /*! \internal */ |
|
555 uint qHash(const QMailFolderId &id) |
|
556 { |
|
557 return qHash(id.toULongLong()); |
|
558 } |
|
559 |
|
560 /*! \internal */ |
|
561 uint qHash(const QMailMessageId &id) |
|
562 { |
|
563 return qHash(id.toULongLong()); |
|
564 } |
|
565 |
|
566 |