KIMAP

expungejob.cpp
1/*
2 SPDX-FileCopyrightText: 2009 Andras Mantia <amantia@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "expungejob.h"
8
9#include "kimap_debug.h"
10#include <KLocalizedString>
11
12#include "imapset.h"
13#include "job_p.h"
14#include "response_p.h"
15#include "session_p.h"
16
17namespace KIMAP
18{
19class ExpungeJobPrivate : public JobPrivate
20{
21public:
22 ExpungeJobPrivate(Session *session, const QString &name)
23 : JobPrivate(session, name)
24 {
25 }
26#if 0
27 QList< int > items;
28#endif
29 KIMAP::ImapSet vanished;
30 quint64 highestModSeq = 0;
31};
32}
33
34using namespace KIMAP;
35
36ExpungeJob::ExpungeJob(Session *session)
37 : Job(*new ExpungeJobPrivate(session, i18n("Expunge")))
38{
39}
40
42{
43 Q_D(const ExpungeJob);
44 return d->vanished;
45}
46
48{
49 Q_D(const ExpungeJob);
50 return d->highestModSeq;
51}
52
53void ExpungeJob::doStart()
54{
56 d->tags << d->sessionInternal()->sendCommand("EXPUNGE");
57}
58
59void ExpungeJob::handleResponse(const Response &response)
60{
62
63 // Must be handler before handleErrorReplies(), so the value is available
64 // before the result is emitted.
65 if (response.responseCode.size() >= 2) {
66 if (response.responseCode[0].toString() == "HIGHESTMODSEQ") {
67 d->highestModSeq = response.responseCode[1].toString().toULongLong();
68 }
69 }
70
71 if (handleErrorReplies(response) == NotHandled) {
72 if (response.content.size() >= 3) {
73 if (response.content[1].toString() == "VANISHED") {
74 d->vanished = KIMAP::ImapSet::fromImapSequenceSet(response.content[2].toString());
75 return;
76 } else if (response.content[2].toString() == "EXPUNGE") {
77#if 0
78 QByteArray s = response.content[1].toString();
79 bool ok = true;
80 int id = s.toInt(&ok);
81 if (ok) {
82 d->items.append(id);
83 }
84 //TODO error handling
85#endif
86 return;
87 }
88 }
89 qCDebug(KIMAP_LOG) << "Unhandled response: " << response.toString().constData();
90 }
91}
92
93#include "moc_expungejob.cpp"
Expunges the deleted messages in the selected mailbox.
Definition expungejob.h:33
KIMAP::ImapSet vanishedMessages() const
Returns UIDs of messages that have been expunged.
quint64 newHighestModSeq() const
Returns new highest modification sequence number.
Represents a set of natural numbers (1->∞) in a as compact as possible form.
Definition imapset.h:127
static ImapSet fromImapSequenceSet(const QByteArray &sequence)
Return the set corresponding to the given IMAP-compatible QByteArray representation.
Definition imapset.cpp:285
QString i18n(const char *text, const TYPE &arg...)
QString name(StandardAction id)
int toInt(bool *ok, int base) const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.