summaryrefslogtreecommitdiffstats
path: root/src/libraries/qmfclient/qmailid.cpp
blob: 92ab2f6d8d080dd2ca5bd3205224fc443d4516a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the Qt Messaging Framework.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include "qmailid.h"

struct QMailIdPrivate
{
    QMailIdPrivate();
    QMailIdPrivate(quint64 value);
    QMailIdPrivate(const QMailIdPrivate& other);

    QMailIdPrivate& operator=(const QMailIdPrivate& other);

    bool isValid() const;
    quint64 toULongLong() const;

    bool operator!=(const QMailIdPrivate& other) const;
    bool operator==(const QMailIdPrivate& other) const;
    bool operator<(const QMailIdPrivate& other) const;

    template <typename Stream> void serialize(Stream &stream) const;
    template <typename Stream> void deserialize(Stream &stream);

private:
    quint64 _value;
};

QMailIdPrivate::QMailIdPrivate()
    : _value(0)

{
}

QMailIdPrivate::QMailIdPrivate(quint64 value)
    : _value(value)
{
}

QMailIdPrivate::QMailIdPrivate(QMailIdPrivate const& other)
    : _value(other._value)
{
}

QMailIdPrivate& QMailIdPrivate::operator=(const QMailIdPrivate& other)
{
    _value = other._value;
    return *this;
}

bool QMailIdPrivate::isValid() const
{
    return _value != 0;
}

quint64 QMailIdPrivate::toULongLong() const
{
    return _value;
}

bool QMailIdPrivate::operator!=(const QMailIdPrivate & other) const
{
    return _value != other._value;
}

bool QMailIdPrivate::operator==(const QMailIdPrivate& other) const
{
    return _value == other._value;
}

bool QMailIdPrivate::operator<(const QMailIdPrivate& other) const
{
    return _value < other._value;
}

template <typename Stream> void QMailIdPrivate::serialize(Stream &stream) const
{
    stream << _value;
}

template <typename Stream> void QMailIdPrivate::deserialize(Stream &stream)
{
    stream >> _value;
}

QDebug& operator<<(QDebug& debug, const QMailIdPrivate &id)
{
    id.serialize(debug);
    return debug;
}

QTextStream& operator<<(QTextStream& s, const QMailIdPrivate &id)
{
    id.serialize(s);
    return s;
}

/*!
    \class QMailAccountId
    \ingroup messaginglibrary

    \preliminary
    \brief The QMailAccountId class is used to identify accounts stored by QMailStore.

    QMailAccountId is a class used to represent accounts stored by the QMailStore, identified
    by their unique numeric internal indentifer.

    A QMailAccountId instance can be tested for validity, and compared to other instances
    for equality.  The numeric value of the identifier is not intrinsically meaningful 
    and cannot be modified.
    
    \sa QMailAccount, QMailStore::account()
*/

/*!
    \typedef QMailAccountIdList
    \relates QMailAccountId
*/

Q_IMPLEMENT_USER_METATYPE(QMailAccountId)

/*! 
    Construct an uninitialized QMailAccountId, for which isValid() returns false.
*/
QMailAccountId::QMailAccountId()
    : d(new QMailIdPrivate)
{
}

/*! 
    Construct a QMailAccountId with the supplied numeric identifier \a value.
*/
QMailAccountId::QMailAccountId(quint64 value)
    : d(new QMailIdPrivate(value))
{
}

/*! \internal */
QMailAccountId::QMailAccountId(const QMailAccountId& other)
    : d(new QMailIdPrivate(*other.d))
{
}

/*! \internal */
QMailAccountId::~QMailAccountId()
{
}

/*! \internal */
QMailAccountId& QMailAccountId::operator=(const QMailAccountId& other) 
{
    *d = *other.d;
    return *this;
}

/*!
    Returns true if this object has been initialized with an identifier.
*/
bool QMailAccountId::isValid() const
{
    return d->isValid();
}

/*! \internal */
quint64 QMailAccountId::toULongLong() const
{
    return d->toULongLong();
}

/*!
    Returns a QVariant containing the value of this account identfier.
*/
QMailAccountId::operator QVariant() const
{
    return QVariant::fromValue(*this);
}

/*!
    Returns true if this object's identifier value differs from that of \a other.
*/
bool QMailAccountId::operator!=(const QMailAccountId& other) const
{
    return *d != *other.d;
}

/*!
    Returns true if this object's identifier value is equal to that of \a other.
*/
bool QMailAccountId::operator==(const QMailAccountId& other) const
{
    return *d == *other.d;
}

/*!
    Returns true if this object's identifier value is less than that of \a other.
*/
bool QMailAccountId::operator<(const QMailAccountId& other) const
{
    return *d < *other.d;
}

/*! 
    \fn QMailAccountId::serialize(Stream&) const
    \internal 
*/
template <typename Stream> void QMailAccountId::serialize(Stream &stream) const
{
    d->serialize(stream);
}

/*! 
    \fn QMailAccountId::deserialize(Stream&)
    \internal 
*/
template <typename Stream> void QMailAccountId::deserialize(Stream &stream)
{
    d->deserialize(stream);
}

/*! \internal */
QDebug& operator<<(QDebug& debug, const QMailAccountId &id)
{
    id.serialize(debug);
    return debug;
}

/*! \internal */
QTextStream& operator<< (QTextStream& s, const QMailAccountId &id)
{
    id.serialize(s);
    return s;
}

Q_IMPLEMENT_USER_METATYPE_TYPEDEF(QMailAccountIdList, QMailAccountIdList)


/*!
    \class QMailThreadId
    \ingroup messaginglibrary

    \preliminary
    \brief The QMailThreadId class is used to identify threads stored by QMailStore.

    QMailThreadId is a class used to represent threads stored by the QMailStore, identified
    by their unique numeric internal indentifer.

    A QMailThreadId instance can be tested for validity, and compared to other instances
    for equality.  The numeric value of the identifier is not intrinsically meaningful
    and cannot be modified.

    \sa QMailThread, QMailStore::thread()
*/

/*!
    \typedef QMailThreadIdList
    \relates QMailThreadId
*/

Q_IMPLEMENT_USER_METATYPE(QMailThreadId)

/*!
    Construct an uninitialized QMailThreadId, for which isValid() returns false.
*/
QMailThreadId::QMailThreadId()
    : d(new QMailIdPrivate)
{
}

/*!
    Construct a QMailThreadId with the supplied numeric identifier \a value.
*/
QMailThreadId::QMailThreadId(quint64 value)
    : d(new QMailIdPrivate(value))
{
}

/*! \internal */
QMailThreadId::QMailThreadId(const QMailThreadId &other)
    : d(new QMailIdPrivate(*other.d))
{
}

/*! \internal */
QMailThreadId::~QMailThreadId()
{
}

/*! \internal */
QMailThreadId& QMailThreadId::operator=(const QMailThreadId &other)
{
    *d = *other.d;
    return *this;
}

/*!
    Returns true if this object has been initialized with an identifier.
*/
bool QMailThreadId::isValid() const
{
    return d->isValid();
}

/*! \internal */
quint64 QMailThreadId::toULongLong() const
{
    return d->toULongLong();
}

/*!
    Returns a QVariant containing the value of this thread identfier.
*/
QMailThreadId::operator QVariant() const
{
    return QVariant::fromValue(*this);
}

/*!
    Returns true if this object's identifier value differs from that of \a other.
*/
bool QMailThreadId::operator!=(const QMailThreadId &other) const
{
    return *d != *other.d;
}

/*!
    Returns true if this object's identifier value is equal to that of \a other.
*/
bool QMailThreadId::operator==(const QMailThreadId& other) const
{
    return *d == *other.d;
}

/*!
    Returns true if this object's identifier value is less than that of \a other.
*/
bool QMailThreadId::operator<(const QMailThreadId& other) const
{
    return *d < *other.d;
}

/*!
    \fn QMailThreadId::serialize(Stream&) const
    \internal
*/
template <typename Stream> void QMailThreadId::serialize(Stream &stream) const
{
    d->serialize(stream);
}

/*!
    \fn QMailThreadId::deserialize(Stream&)
    \internal
*/
template <typename Stream> void QMailThreadId::deserialize(Stream &stream)
{
    d->deserialize(stream);
}

/*! \internal */
QDebug& operator<<(QDebug& debug, const QMailThreadId &id)
{
    id.serialize(debug);
    return debug;
}

/*! \internal */
QTextStream& operator<< (QTextStream& s, const QMailThreadId &id)
{
    id.serialize(s);
    return s;
}

Q_IMPLEMENT_USER_METATYPE_TYPEDEF(QMailThreadIdList, QMailThreadIdList)


/*!
    \class QMailFolderId
    \ingroup messaginglibrary

    \preliminary
    \brief The QMailFolderId class is used to identify folders stored by QMailStore.

    QMailFolderId is a class used to represent folders stored by the QMailStore, identified
    by their unique numeric internal indentifer.

    A QMailFolderId instance can be tested for validity, and compared to other instances
    for equality.  The numeric value of the identifier is not intrinsically meaningful 
    and cannot be modified.
    
    \sa QMailFolder, QMailStore::folder()
*/

/*!
    \typedef QMailFolderIdList
    \relates QMailFolderId
*/

Q_IMPLEMENT_USER_METATYPE(QMailFolderId)

/*! 
    Construct an uninitialized QMailFolderId, for which isValid() returns false.
*/
QMailFolderId::QMailFolderId()
    : d(new QMailIdPrivate)
{
}

/*! 
    Construct a QMailFolderId corresponding to the predefined folder identifier \a id.
*/
QMailFolderId::QMailFolderId(QMailFolderFwd::PredefinedFolderId id)
    : d(new QMailIdPrivate(static_cast<quint64>(id)))
{
}

/*! 
    Construct a QMailFolderId with the supplied numeric identifier \a value.
*/
QMailFolderId::QMailFolderId(quint64 value)
    : d(new QMailIdPrivate(value))
{
}

/*! \internal */
QMailFolderId::QMailFolderId(const QMailFolderId& other)
    : d(new QMailIdPrivate(*other.d))
{
}

/*! \internal */
QMailFolderId::~QMailFolderId()
{
}

/*! \internal */
QMailFolderId& QMailFolderId::operator=(const QMailFolderId& other) 
{
    *d = *other.d;
    return *this;
}

/*!
    Returns true if this object has been initialized with an identifier.
*/
bool QMailFolderId::isValid() const
{
    return d->isValid();
}

/*! \internal */
quint64 QMailFolderId::toULongLong() const
{
    return d->toULongLong();
}

/*!
    Returns a QVariant containing the value of this folder identfier.
*/
QMailFolderId::operator QVariant() const
{
    return QVariant::fromValue(*this);
}

/*!
    Returns true if this object's identifier value differs from that of \a other.
*/
bool QMailFolderId::operator!=(const QMailFolderId& other) const
{
    return *d != *other.d;
}

/*!
    Returns true if this object's identifier value is equal to that of \a other.
*/
bool QMailFolderId::operator==(const QMailFolderId& other) const
{
    return *d == *other.d;
}

/*!
    Returns true if this object's identifier value is less than that of \a other.
*/
bool QMailFolderId::operator<(const QMailFolderId& other) const
{
    return *d < *other.d;
}

/*! 
    \fn QMailFolderId::serialize(Stream&) const
    \internal 
*/
template <typename Stream> void QMailFolderId::serialize(Stream &stream) const
{
    d->serialize(stream);
}

/*! 
    \fn QMailFolderId::deserialize(Stream&)
    \internal 
*/
template <typename Stream> void QMailFolderId::deserialize(Stream &stream)
{
    d->deserialize(stream);
}

/*! \internal */
QDebug& operator<< (QDebug& debug, const QMailFolderId &id)
{
    id.serialize(debug);
    return debug;
}

/*! \internal */
QTextStream& operator<< (QTextStream& s, const QMailFolderId &id)
{
    id.serialize(s);
    return s;
}

Q_IMPLEMENT_USER_METATYPE_TYPEDEF(QMailFolderIdList, QMailFolderIdList)


/*!
    \class QMailMessageId
    \ingroup messaginglibrary

    \preliminary
    \brief The QMailMessageId class is used to identify messages stored by QMailStore.

    QMailMessageId is a class used to represent messages stored by the QMailStore, identified
    by their unique numeric internal indentifer.

    A QMailMessageId instance can be tested for validity, and compared to other instances
    for equality.  The numeric value of the identifier is not intrinsically meaningful 
    and cannot be modified.
    
    \sa QMailMessage, QMailStore::message()
*/

/*!
    \typedef QMailMessageIdList
    \relates QMailMessageId
*/

Q_IMPLEMENT_USER_METATYPE(QMailMessageId)

/*! 
    Construct an uninitialized QMailMessageId, for which isValid() returns false.
*/
QMailMessageId::QMailMessageId()
    : d(new QMailIdPrivate)
{
}

/*! 
    Construct a QMailMessageId with the supplied numeric identifier \a value.
*/
QMailMessageId::QMailMessageId(quint64 value)
    : d(new QMailIdPrivate(value))
{
}

/*! \internal */
QMailMessageId::QMailMessageId(const QMailMessageId& other)
    : d(new QMailIdPrivate(*other.d))
{
}

/*! \internal */
QMailMessageId::~QMailMessageId()
{
}

/*! \internal */
QMailMessageId& QMailMessageId::operator=(const QMailMessageId& other) 
{
    *d = *other.d;
    return *this;
}

/*!
    Returns true if this object has been initialized with an identifier.
*/
bool QMailMessageId::isValid() const
{
    return d->isValid();
}

/*! \internal */
quint64 QMailMessageId::toULongLong() const
{
    return d->toULongLong();
}

/*!
    Returns a QVariant containing the value of this message identfier.
*/
QMailMessageId::operator QVariant() const
{
    return QVariant::fromValue(*this);
}

/*!
    Returns true if this object's identifier value differs from that of \a other.
*/
bool QMailMessageId::operator!= (const QMailMessageId& other) const
{
    return *d != *other.d;
}

/*!
    Returns true if this object's identifier value is equal to that of \a other.
*/
bool QMailMessageId::operator== (const QMailMessageId& other) const
{
    return *d == *other.d;
}

/*!
    Returns true if this object's identifier value is less than that of \a other.
*/
bool QMailMessageId::operator< (const QMailMessageId& other) const
{
    return *d < *other.d;
}

/*! 
    \fn QMailMessageId::serialize(Stream&) const
    \internal 
*/
template <typename Stream> void QMailMessageId::serialize(Stream &stream) const
{
    d->serialize(stream);
}

/*! 
    \fn QMailMessageId::deserialize(Stream&)
    \internal 
*/
template <typename Stream> void QMailMessageId::deserialize(Stream &stream)
{
    d->deserialize(stream);
}

/*! \internal */
QDebug& operator<<(QDebug& debug, const QMailMessageId &id)
{
    id.serialize(debug);
    return debug;
}

/*! \internal */
QTextStream& operator<<(QTextStream& s, const QMailMessageId &id)
{
    id.serialize(s);
    return s;
}

Q_IMPLEMENT_USER_METATYPE_TYPEDEF(QMailMessageIdList, QMailMessageIdList)

/*! \internal */
uint qHash(const QMailAccountId &id)
{
    return qHash(id.toULongLong());
}

/*! \internal */
uint qHash(const QMailFolderId &id)
{
    return qHash(id.toULongLong());
}

/*! \internal */
uint qHash(const QMailMessageId &id)
{
    return qHash(id.toULongLong());
}
/*! \internal */
uint qHash(const QMailThreadId &id)
{
    return qHash(id.toULongLong());
}