messagestatus.cpp 17.8 KB
Newer Older
1
2
/*
    This file is part of Akonadi.
3
4
5
    SPDX-FileCopyrightText: 2003 Andreas Gungl <a.gungl@gmx.de>
    SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
    SPDX-FileCopyrightText: 2010 Leo Franchi <lfranchi@kde.org>
6

7
    SPDX-License-Identifier: LGPL-2.0-or-later
8
9
10
11
12
13
*/

#include "messagestatus.h"

#include "messageflags.h"

Laurent Montel's avatar
Laurent Montel committed
14
#include <QString>
15

16
/** The message status format. These can be or'd together.
17
    Note, that the StatusIgnored implies the
Allen Winter's avatar
Allen Winter committed
18
    status to be Read.
19
20
21
    This is done in isRead() and related getters.
    So we can preserve the state when switching a
    thread to Ignored and back. */
22
enum Status {
Laurent Montel's avatar
Laurent Montel committed
23
    StatusUnknown = 0x00000000,
Laurent Montel's avatar
Laurent Montel committed
24
    StatusUnread = 0x00000002, // deprecated
Laurent Montel's avatar
Laurent Montel committed
25
26
27
28
29
30
    StatusRead = 0x00000004,
    StatusDeleted = 0x00000010,
    StatusReplied = 0x00000020,
    StatusForwarded = 0x00000040,
    StatusQueued = 0x00000080,
    StatusSent = 0x00000100,
Laurent Montel's avatar
Laurent Montel committed
31
    StatusFlag = 0x00000200, // flag means important
Laurent Montel's avatar
Laurent Montel committed
32
    StatusWatched = 0x00000400,
Laurent Montel's avatar
Laurent Montel committed
33
    StatusIgnored = 0x00000800, // forces isRead()
Laurent Montel's avatar
Laurent Montel committed
34
35
36
37
38
39
40
41
    StatusToAct = 0x00001000,
    StatusSpam = 0x00002000,
    StatusHam = 0x00004000,
    StatusHasAttachment = 0x00008000,
    StatusHasInvitation = 0x00010000,
    StatusSigned = 0x00020000,
    StatusEncrypted = 0x00040000,
    StatusHasError = 0x00080000
42
43
44
45
};

Akonadi::MessageStatus::MessageStatus()
{
Guy Maurel's avatar
Guy Maurel committed
46
    mStatus = StatusUnknown;
47
48
}

Laurent Montel's avatar
Laurent Montel committed
49
bool Akonadi::MessageStatus::operator==(Akonadi::MessageStatus other) const
50
{
Laurent Montel's avatar
Laurent Montel committed
51
    return mStatus == other.mStatus;
52
53
}

Laurent Montel's avatar
Laurent Montel committed
54
bool Akonadi::MessageStatus::operator!=(Akonadi::MessageStatus other) const
55
{
Laurent Montel's avatar
Laurent Montel committed
56
    return mStatus != other.mStatus;
57
58
}

Laurent Montel's avatar
Laurent Montel committed
59
bool Akonadi::MessageStatus::operator&(Akonadi::MessageStatus other) const
60
{
Guy Maurel's avatar
Guy Maurel committed
61
62
63
    if (mStatus == StatusUnread) {
        return !(other.mStatus & StatusRead);
    }
64

Guy Maurel's avatar
Guy Maurel committed
65
66
67
    if (other.mStatus == StatusUnread) {
        return !(mStatus & StatusRead);
    }
68

Laurent Montel's avatar
Laurent Montel committed
69
    return mStatus & other.mStatus;
70
71
72
73
}

void Akonadi::MessageStatus::clear()
{
Guy Maurel's avatar
Guy Maurel committed
74
75
76
    mStatus = StatusUnknown;
}

Laurent Montel's avatar
Laurent Montel committed
77
void Akonadi::MessageStatus::set(Akonadi::MessageStatus other)
Guy Maurel's avatar
Guy Maurel committed
78
{
Guy Maurel's avatar
Guy Maurel committed
79
    Q_ASSERT(!(other.mStatus & StatusUnread));
Guy Maurel's avatar
Guy Maurel committed
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

    // Those stati are exclusive, but we have to lock at the
    // internal representation because Ignored can manipulate
    // the result of the getter methods.
    if (other.mStatus & StatusRead) {
        setRead();
    }
    if (other.isDeleted()) {
        setDeleted();
    }
    if (other.isReplied()) {
        setReplied();
    }
    if (other.isForwarded()) {
        setForwarded();
    }
    if (other.isQueued()) {
        setQueued();
    }
    if (other.isSent()) {
        setSent();
    }
    if (other.isImportant()) {
        setImportant();
    }

    if (other.isWatched()) {
        setWatched();
    }
    if (other.isIgnored()) {
        setIgnored();
    }
    if (other.isToAct()) {
        setToAct();
    }
    if (other.isSpam()) {
        setSpam();
    }
    if (other.isHam()) {
        setHam();
    }
    if (other.hasAttachment()) {
        setHasAttachment();
    }
    if (other.hasInvitation()) {
        setHasInvitation();
    }
    if (other.isSigned()) {
        setSigned();
    }
    if (other.isEncrypted()) {
        setEncrypted();
    }
    if (other.hasError()) {
        setHasError();
    }
}

Laurent Montel's avatar
Laurent Montel committed
138
void Akonadi::MessageStatus::toggle(Akonadi::MessageStatus other)
Guy Maurel's avatar
Guy Maurel committed
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
{
    Q_ASSERT(!(other.mStatus & StatusUnread));

    if (other.isDeleted()) {
        setDeleted(!(mStatus & StatusDeleted));
    }
    if (other.isReplied()) {
        setReplied(!(mStatus & StatusReplied));
    }
    if (other.isForwarded()) {
        setForwarded(!(mStatus & StatusForwarded));
    }
    if (other.isQueued()) {
        setQueued(!(mStatus & StatusQueued));
    }
    if (other.isSent()) {
        setSent(!(mStatus & StatusSent));
    }
    if (other.isImportant()) {
        setImportant(!(mStatus & StatusFlag));
    }

    if (other.isWatched()) {
        setWatched(!(mStatus & StatusWatched));
    }
    if (other.isIgnored()) {
        setIgnored(!(mStatus & StatusIgnored));
    }
    if (other.isToAct()) {
        setToAct(!(mStatus & StatusToAct));
    }
    if (other.isSpam()) {
        setSpam(!(mStatus & StatusSpam));
    }
    if (other.isHam()) {
        setHam(!(mStatus & StatusHam));
    }
    if (other.hasAttachment()) {
        setHasAttachment(!(mStatus & StatusHasAttachment));
    }
    if (other.hasInvitation()) {
        setHasInvitation(!(mStatus & StatusHasInvitation));
    }
    if (other.isSigned()) {
        setSigned(!(mStatus & StatusSigned));
    }
    if (other.isEncrypted()) {
        setEncrypted(!(mStatus & StatusEncrypted));
    }
    if (other.hasError()) {
        setHasError(!(mStatus & StatusHasError));
    }
191
192
193
194
}

bool Akonadi::MessageStatus::isOfUnknownStatus() const
{
Laurent Montel's avatar
Laurent Montel committed
195
    return mStatus == StatusUnknown;
196
197
198
199
}

bool Akonadi::MessageStatus::isRead() const
{
Laurent Montel's avatar
Laurent Montel committed
200
    return (mStatus & StatusRead) || (mStatus & StatusIgnored);
201
202
203
204
}

bool Akonadi::MessageStatus::isDeleted() const
{
Laurent Montel's avatar
Laurent Montel committed
205
    return mStatus & StatusDeleted;
206
207
208
209
}

bool Akonadi::MessageStatus::isReplied() const
{
Laurent Montel's avatar
Laurent Montel committed
210
    return mStatus & StatusReplied;
211
212
213
214
}

bool Akonadi::MessageStatus::isForwarded() const
{
Laurent Montel's avatar
Laurent Montel committed
215
    return mStatus & StatusForwarded;
216
217
218
219
}

bool Akonadi::MessageStatus::isQueued() const
{
Laurent Montel's avatar
Laurent Montel committed
220
    return mStatus & StatusQueued;
221
222
223
224
}

bool Akonadi::MessageStatus::isSent() const
{
Laurent Montel's avatar
Laurent Montel committed
225
    return mStatus & StatusSent;
226
227
228
229
}

bool Akonadi::MessageStatus::isImportant() const
{
Laurent Montel's avatar
Laurent Montel committed
230
    return mStatus & StatusFlag;
231
232
233
234
}

bool Akonadi::MessageStatus::isWatched() const
{
Laurent Montel's avatar
Laurent Montel committed
235
    return mStatus & StatusWatched;
236
237
238
239
}

bool Akonadi::MessageStatus::isIgnored() const
{
Laurent Montel's avatar
Laurent Montel committed
240
    return mStatus & StatusIgnored;
241
242
243
244
}

bool Akonadi::MessageStatus::isToAct() const
{
Laurent Montel's avatar
Laurent Montel committed
245
    return mStatus & StatusToAct;
246
247
248
249
}

bool Akonadi::MessageStatus::isSpam() const
{
Laurent Montel's avatar
Laurent Montel committed
250
    return mStatus & StatusSpam;
251
252
253
254
}

bool Akonadi::MessageStatus::isHam() const
{
Laurent Montel's avatar
Laurent Montel committed
255
    return mStatus & StatusHam;
256
257
258
259
}

bool Akonadi::MessageStatus::hasAttachment() const
{
Laurent Montel's avatar
Laurent Montel committed
260
    return mStatus & StatusHasAttachment;
261
262
263
264
}

bool Akonadi::MessageStatus::hasInvitation() const
{
Laurent Montel's avatar
Laurent Montel committed
265
    return mStatus & StatusHasInvitation;
266
267
}

Tobias Koenig's avatar
Tobias Koenig committed
268
269
bool Akonadi::MessageStatus::isSigned() const
{
Laurent Montel's avatar
Laurent Montel committed
270
    return mStatus & StatusSigned;
Tobias Koenig's avatar
Tobias Koenig committed
271
272
273
274
}

bool Akonadi::MessageStatus::isEncrypted() const
{
Laurent Montel's avatar
Laurent Montel committed
275
    return mStatus & StatusEncrypted;
Tobias Koenig's avatar
Tobias Koenig committed
276
277
278
279
}

bool Akonadi::MessageStatus::hasError() const
{
Laurent Montel's avatar
Laurent Montel committed
280
    return mStatus & StatusHasError;
Tobias Koenig's avatar
Tobias Koenig committed
281
282
}

Guy Maurel's avatar
Guy Maurel committed
283
void Akonadi::MessageStatus::setRead(bool read)
284
{
Guy Maurel's avatar
Guy Maurel committed
285
286
287
288
289
    if (read) {
        mStatus |= StatusRead;
    } else {
        mStatus &= ~StatusRead;
    }
290
291
}

Guy Maurel's avatar
Guy Maurel committed
292
void Akonadi::MessageStatus::setDeleted(bool deleted)
293
{
Guy Maurel's avatar
Guy Maurel committed
294
295
296
297
298
    if (deleted) {
        mStatus |= StatusDeleted;
    } else {
        mStatus &= ~StatusDeleted;
    }
299
300
}

Guy Maurel's avatar
Guy Maurel committed
301
void Akonadi::MessageStatus::setReplied(bool replied)
302
{
Guy Maurel's avatar
Guy Maurel committed
303
304
305
306
307
    if (replied) {
        mStatus |= StatusReplied;
    } else {
        mStatus &= ~StatusReplied;
    }
308
309
}

Guy Maurel's avatar
Guy Maurel committed
310
void Akonadi::MessageStatus::setForwarded(bool forwarded)
311
{
Guy Maurel's avatar
Guy Maurel committed
312
313
314
315
316
    if (forwarded) {
        mStatus |= StatusForwarded;
    } else {
        mStatus &= ~StatusForwarded;
    }
317
318
}

Guy Maurel's avatar
Guy Maurel committed
319
void Akonadi::MessageStatus::setQueued(bool queued)
320
{
Guy Maurel's avatar
Guy Maurel committed
321
322
323
324
325
    if (queued) {
        mStatus |= StatusQueued;
    } else {
        mStatus &= ~StatusQueued;
    }
326
327
}

Guy Maurel's avatar
Guy Maurel committed
328
void Akonadi::MessageStatus::setSent(bool sent)
329
{
Guy Maurel's avatar
Guy Maurel committed
330
331
332
333
334
335
    if (sent) {
        mStatus &= ~StatusQueued;
        mStatus |= StatusSent;
    } else {
        mStatus &= ~StatusSent;
    }
336
337
}

Guy Maurel's avatar
Guy Maurel committed
338
void Akonadi::MessageStatus::setImportant(bool important)
339
{
Guy Maurel's avatar
Guy Maurel committed
340
341
342
343
344
    if (important) {
        mStatus |= StatusFlag;
    } else {
        mStatus &= ~StatusFlag;
    }
345
346
347
}

// Watched and ignored are mutually exclusive
Guy Maurel's avatar
Guy Maurel committed
348
void Akonadi::MessageStatus::setWatched(bool watched)
349
{
Guy Maurel's avatar
Guy Maurel committed
350
351
352
353
354
355
    if (watched) {
        mStatus &= ~StatusIgnored;
        mStatus |= StatusWatched;
    } else {
        mStatus &= ~StatusWatched;
    }
356
357
}

Guy Maurel's avatar
Guy Maurel committed
358
void Akonadi::MessageStatus::setIgnored(bool ignored)
359
{
Guy Maurel's avatar
Guy Maurel committed
360
361
362
363
364
365
    if (ignored) {
        mStatus &= ~StatusWatched;
        mStatus |= StatusIgnored;
    } else {
        mStatus &= ~StatusIgnored;
    }
366
367
}

Guy Maurel's avatar
Guy Maurel committed
368
void Akonadi::MessageStatus::setToAct(bool toAct)
369
{
Guy Maurel's avatar
Guy Maurel committed
370
371
372
373
374
    if (toAct) {
        mStatus |= StatusToAct;
    } else {
        mStatus &= ~StatusToAct;
    }
375
376
377
}

// Ham and Spam are mutually exclusive
Guy Maurel's avatar
Guy Maurel committed
378
void Akonadi::MessageStatus::setSpam(bool spam)
379
{
Guy Maurel's avatar
Guy Maurel committed
380
381
382
383
384
385
    if (spam) {
        mStatus &= ~StatusHam;
        mStatus |= StatusSpam;
    } else {
        mStatus &= ~StatusSpam;
    }
386
387
}

Guy Maurel's avatar
Guy Maurel committed
388
void Akonadi::MessageStatus::setHam(bool ham)
389
{
Guy Maurel's avatar
Guy Maurel committed
390
391
392
393
394
395
    if (ham) {
        mStatus &= ~StatusSpam;
        mStatus |= StatusHam;
    } else {
        mStatus &= ~StatusHam;
    }
396
397
}

Guy Maurel's avatar
Guy Maurel committed
398
void Akonadi::MessageStatus::setHasAttachment(bool withAttachment)
399
{
Guy Maurel's avatar
Guy Maurel committed
400
401
402
403
404
    if (withAttachment) {
        mStatus |= StatusHasAttachment;
    } else {
        mStatus &= ~StatusHasAttachment;
    }
405
406
}

Guy Maurel's avatar
Guy Maurel committed
407
void Akonadi::MessageStatus::setHasInvitation(bool withInvitation)
408
{
Guy Maurel's avatar
Guy Maurel committed
409
410
411
412
413
    if (withInvitation) {
        mStatus |= StatusHasInvitation;
    } else {
        mStatus &= ~StatusHasInvitation;
    }
414
415
}

Guy Maurel's avatar
Guy Maurel committed
416
void Akonadi::MessageStatus::setSigned(bool value)
Tobias Koenig's avatar
Tobias Koenig committed
417
{
Guy Maurel's avatar
Guy Maurel committed
418
419
420
421
422
    if (value) {
        mStatus |= StatusSigned;
    } else {
        mStatus &= ~StatusSigned;
    }
Tobias Koenig's avatar
Tobias Koenig committed
423
424
}

Guy Maurel's avatar
Guy Maurel committed
425
void Akonadi::MessageStatus::setEncrypted(bool value)
Tobias Koenig's avatar
Tobias Koenig committed
426
{
Guy Maurel's avatar
Guy Maurel committed
427
428
429
430
431
    if (value) {
        mStatus |= StatusEncrypted;
    } else {
        mStatus &= ~StatusEncrypted;
    }
Tobias Koenig's avatar
Tobias Koenig committed
432
433
}

Guy Maurel's avatar
Guy Maurel committed
434
void Akonadi::MessageStatus::setHasError(bool hasError)
Tobias Koenig's avatar
Tobias Koenig committed
435
{
Guy Maurel's avatar
Guy Maurel committed
436
437
438
439
440
    if (hasError) {
        mStatus |= StatusHasError;
    } else {
        mStatus &= ~StatusHasError;
    }
Tobias Koenig's avatar
Tobias Koenig committed
441
442
}

443
444
qint32 Akonadi::MessageStatus::toQInt32() const
{
Guy Maurel's avatar
Guy Maurel committed
445
    return mStatus;
446
447
}

Guy Maurel's avatar
Guy Maurel committed
448
void Akonadi::MessageStatus::fromQInt32(qint32 status)
449
{
Guy Maurel's avatar
Guy Maurel committed
450
    mStatus = status;
451
452
453
454
}

QString Akonadi::MessageStatus::statusStr() const
{
Guy Maurel's avatar
Guy Maurel committed
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
    QByteArray sstr;
    if (mStatus & StatusRead) {
        sstr += 'R';
    } else {
        sstr += 'U';
    }
    if (mStatus & StatusDeleted) {
        sstr += 'D';
    }
    if (mStatus & StatusReplied) {
        sstr += 'A';
    }
    if (mStatus & StatusForwarded) {
        sstr += 'F';
    }
    if (mStatus & StatusQueued) {
        sstr += 'Q';
    }
    if (mStatus & StatusToAct) {
        sstr += 'K';
    }
    if (mStatus & StatusSent) {
        sstr += 'S';
    }
    if (mStatus & StatusFlag) {
        sstr += 'G';
    }
    if (mStatus & StatusWatched) {
        sstr += 'W';
    }
    if (mStatus & StatusIgnored) {
        sstr += 'I';
    }
    if (mStatus & StatusSpam) {
        sstr += 'P';
    }
    if (mStatus & StatusHam) {
        sstr += 'H';
    }
    if (mStatus & StatusHasAttachment) {
        sstr += 'T';
    }

    return QLatin1String(sstr);
}

void Akonadi::MessageStatus::setStatusFromStr(const QString &aStr)
{
    mStatus = StatusUnknown;

    if (aStr.contains(QLatin1Char('U'))) {
        setRead(false);
    }
    if (aStr.contains(QLatin1Char('R'))) {
        setRead();
    }
    if (aStr.contains(QLatin1Char('D'))) {
        setDeleted();
    }
    if (aStr.contains(QLatin1Char('A'))) {
        setReplied();
    }
    if (aStr.contains(QLatin1Char('F'))) {
        setForwarded();
    }
    if (aStr.contains(QLatin1Char('Q'))) {
        setQueued();
    }
    if (aStr.contains(QLatin1Char('K'))) {
        setToAct();
    }
    if (aStr.contains(QLatin1Char('S'))) {
        setSent();
    }
    if (aStr.contains(QLatin1Char('G'))) {
        setImportant();
    }
    if (aStr.contains(QLatin1Char('W'))) {
        setWatched();
    }
    if (aStr.contains(QLatin1Char('I'))) {
        setIgnored();
    }
    if (aStr.contains(QLatin1Char('P'))) {
        setSpam();
    }
    if (aStr.contains(QLatin1Char('H'))) {
        setHam();
    }
    if (aStr.contains(QLatin1Char('T'))) {
        setHasAttachment();
    }
    if (aStr.contains(QLatin1Char('C'))) {
        setHasAttachment(false);
    }
550
551
552
553
}

QSet<QByteArray> Akonadi::MessageStatus::statusFlags() const
{
Guy Maurel's avatar
Guy Maurel committed
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
    QSet<QByteArray> flags;

    if (mStatus & StatusDeleted) {
        flags += Akonadi::MessageFlags::Deleted;
    } else {
        if (mStatus & StatusRead) {
            flags += Akonadi::MessageFlags::Seen;
        }
        if (mStatus & StatusReplied) {
            flags += Akonadi::MessageFlags::Answered;
        }
        if (mStatus & StatusFlag) {
            flags += Akonadi::MessageFlags::Flagged;
        }

        // non standard flags
        if (mStatus & StatusSent) {
            flags += Akonadi::MessageFlags::Sent;
        }
        if (mStatus & StatusQueued) {
            flags += Akonadi::MessageFlags::Queued;
        }
        if (mStatus & StatusReplied) {
            flags += Akonadi::MessageFlags::Replied;
        }
        if (mStatus & StatusForwarded) {
            flags += Akonadi::MessageFlags::Forwarded;
        }
        if (mStatus & StatusToAct) {
            flags += Akonadi::MessageFlags::ToAct;
        }
        if (mStatus & StatusWatched) {
            flags += Akonadi::MessageFlags::Watched;
        }
        if (mStatus & StatusIgnored) {
            flags += Akonadi::MessageFlags::Ignored;
        }
        if (mStatus & StatusHasAttachment) {
            flags += Akonadi::MessageFlags::HasAttachment;
        }
        if (mStatus & StatusHasInvitation) {
            flags += Akonadi::MessageFlags::HasInvitation;
        }
        if (mStatus & StatusSigned) {
            flags += Akonadi::MessageFlags::Signed;
        }
        if (mStatus & StatusEncrypted) {
            flags += Akonadi::MessageFlags::Encrypted;
        }
        if (mStatus & StatusSpam) {
            flags += Akonadi::MessageFlags::Spam;
        }
        if (mStatus & StatusHam) {
            flags += Akonadi::MessageFlags::Ham;
        }
        if (mStatus & StatusHasError) {
            flags += Akonadi::MessageFlags::HasError;
        }
    }

    return flags;
}

void Akonadi::MessageStatus::setStatusFromFlags(const QSet<QByteArray> &flags)
{
    mStatus = StatusUnknown;

Laurent Montel's avatar
Laurent Montel committed
621
    for (const QByteArray &flag : flags) {
Guy Maurel's avatar
Guy Maurel committed
622
        const QByteArray &upperedFlag = flag.toUpper();
Laurent Montel's avatar
Laurent Montel committed
623
        if (upperedFlag == Akonadi::MessageFlags::Deleted) {
Guy Maurel's avatar
Guy Maurel committed
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
            setDeleted();
        } else if (upperedFlag == Akonadi::MessageFlags::Seen) {
            setRead();
        } else if (upperedFlag == Akonadi::MessageFlags::Answered) {
            setReplied();
        } else if (upperedFlag == Akonadi::MessageFlags::Flagged) {
            setImportant();

            // non standard flags
        } else if (upperedFlag == Akonadi::MessageFlags::Sent) {
            setSent();
        } else if (upperedFlag == Akonadi::MessageFlags::Queued) {
            setQueued();
        } else if (upperedFlag == Akonadi::MessageFlags::Replied) {
            setReplied();
        } else if (upperedFlag == Akonadi::MessageFlags::Forwarded) {
            setForwarded();
        } else if (upperedFlag == Akonadi::MessageFlags::ToAct) {
            setToAct();
        } else if (upperedFlag == Akonadi::MessageFlags::Watched) {
            setWatched();
        } else if (upperedFlag == Akonadi::MessageFlags::Ignored) {
            setIgnored();
Laurent Montel's avatar
Laurent Montel committed
647
        } else if (upperedFlag == Akonadi::MessageFlags::HasAttachment) {
Guy Maurel's avatar
Guy Maurel committed
648
            setHasAttachment();
Laurent Montel's avatar
Laurent Montel committed
649
        } else if (upperedFlag == Akonadi::MessageFlags::HasInvitation) {
Guy Maurel's avatar
Guy Maurel committed
650
651
652
653
654
655
656
657
658
659
660
661
662
            setHasInvitation();
        } else if (upperedFlag == Akonadi::MessageFlags::Signed) {
            setSigned();
        } else if (upperedFlag == Akonadi::MessageFlags::Encrypted) {
            setEncrypted();
        } else if (upperedFlag == Akonadi::MessageFlags::Spam) {
            setSpam();
        } else if (upperedFlag == Akonadi::MessageFlags::Ham) {
            setHam();
        } else if (upperedFlag == Akonadi::MessageFlags::HasError) {
            setHasError();
        }
    }
663
664
}

665
const Akonadi::MessageStatus Akonadi::MessageStatus::statusUnread()
666
{
Guy Maurel's avatar
Guy Maurel committed
667
668
669
    Akonadi::MessageStatus st;
    st.mStatus = StatusUnread;
    return st;
670
671
}

672
const Akonadi::MessageStatus Akonadi::MessageStatus::statusRead()
673
{
Guy Maurel's avatar
Guy Maurel committed
674
675
676
    Akonadi::MessageStatus st;
    st.setRead();
    return st;
677
678
}

679
const Akonadi::MessageStatus Akonadi::MessageStatus::statusDeleted()
680
{
Guy Maurel's avatar
Guy Maurel committed
681
682
683
    Akonadi::MessageStatus st;
    st.setDeleted();
    return st;
684
685
}

686
const Akonadi::MessageStatus Akonadi::MessageStatus::statusReplied()
687
{
Guy Maurel's avatar
Guy Maurel committed
688
689
690
    Akonadi::MessageStatus st;
    st.setReplied();
    return st;
691
692
}

693
const Akonadi::MessageStatus Akonadi::MessageStatus::statusForwarded()
694
{
Guy Maurel's avatar
Guy Maurel committed
695
696
697
    Akonadi::MessageStatus st;
    st.setForwarded();
    return st;
698
699
}

700
const Akonadi::MessageStatus Akonadi::MessageStatus::statusQueued()
701
{
Guy Maurel's avatar
Guy Maurel committed
702
703
704
    Akonadi::MessageStatus st;
    st.setQueued();
    return st;
705
706
}

707
const Akonadi::MessageStatus Akonadi::MessageStatus::statusSent()
708
{
Guy Maurel's avatar
Guy Maurel committed
709
710
711
    Akonadi::MessageStatus st;
    st.setSent();
    return st;
712
713
}

714
const Akonadi::MessageStatus Akonadi::MessageStatus::statusImportant()
715
{
Guy Maurel's avatar
Guy Maurel committed
716
717
718
    Akonadi::MessageStatus st;
    st.setImportant();
    return st;
719
720
}

721
const Akonadi::MessageStatus Akonadi::MessageStatus::statusWatched()
722
{
Guy Maurel's avatar
Guy Maurel committed
723
724
725
    Akonadi::MessageStatus st;
    st.setWatched();
    return st;
726
727
}

728
const Akonadi::MessageStatus Akonadi::MessageStatus::statusIgnored()
729
{
Guy Maurel's avatar
Guy Maurel committed
730
731
732
    Akonadi::MessageStatus st;
    st.setIgnored();
    return st;
733
734
}

735
const Akonadi::MessageStatus Akonadi::MessageStatus::statusToAct()
736
{
Guy Maurel's avatar
Guy Maurel committed
737
738
739
    Akonadi::MessageStatus st;
    st.setToAct();
    return st;
740
741
}

742
const Akonadi::MessageStatus Akonadi::MessageStatus::statusSpam()
743
{
Guy Maurel's avatar
Guy Maurel committed
744
745
746
    Akonadi::MessageStatus st;
    st.setSpam();
    return st;
747
748
}

749
const Akonadi::MessageStatus Akonadi::MessageStatus::statusHam()
750
{
Guy Maurel's avatar
Guy Maurel committed
751
752
753
    Akonadi::MessageStatus st;
    st.setHam();
    return st;
754
755
}

756
const Akonadi::MessageStatus Akonadi::MessageStatus::statusHasAttachment()
757
{
Guy Maurel's avatar
Guy Maurel committed
758
759
760
    Akonadi::MessageStatus st;
    st.setHasAttachment();
    return st;
761
762
}

763
const Akonadi::MessageStatus Akonadi::MessageStatus::statusHasInvitation()
764
{
Guy Maurel's avatar
Guy Maurel committed
765
766
767
    MessageStatus st;
    st.setHasInvitation();
    return st;
768
769
}

770
const Akonadi::MessageStatus Akonadi::MessageStatus::statusSigned()
Tobias Koenig's avatar
Tobias Koenig committed
771
{
Guy Maurel's avatar
Guy Maurel committed
772
773
774
    MessageStatus st;
    st.setSigned();
    return st;
Tobias Koenig's avatar
Tobias Koenig committed
775
776
}

777
const Akonadi::MessageStatus Akonadi::MessageStatus::statusEncrypted()
Tobias Koenig's avatar
Tobias Koenig committed
778
{
Guy Maurel's avatar
Guy Maurel committed
779
780
781
    MessageStatus st;
    st.setEncrypted();
    return st;
Tobias Koenig's avatar
Tobias Koenig committed
782
783
}

784
const Akonadi::MessageStatus Akonadi::MessageStatus::statusHasError()
Tobias Koenig's avatar
Tobias Koenig committed
785
{
Guy Maurel's avatar
Guy Maurel committed
786
787
788
    MessageStatus st;
    st.setHasError();
    return st;
Tobias Koenig's avatar
Tobias Koenig committed
789
}
Laurent Montel's avatar
Laurent Montel committed
790
791
792
793
794
795

QDebug operator<<(QDebug d, const Akonadi::MessageStatus &t)
{
    d << "status " << t.statusStr();
    return d;
}