KIMAP

expungejob.cpp
1 /*
2  SPDX-FileCopyrightText: 2009 Andras Mantia <[email protected]>
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 
17 namespace KIMAP
18 {
19 class ExpungeJobPrivate : public JobPrivate
20 {
21 public:
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 
34 using namespace KIMAP;
35 
36 ExpungeJob::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 
53 void ExpungeJob::doStart()
54 {
55  Q_D(ExpungeJob);
56  d->tags << d->sessionInternal()->sendCommand("EXPUNGE");
57 }
58 
59 void ExpungeJob::handleResponse(const Response &response)
60 {
61  Q_D(ExpungeJob);
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"
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...)
Represents a set of natural numbers (1->∞) in a as compact as possible form.
Definition: imapset.h:126
int toInt(bool *ok, int base) const const
Expunges the deleted messages in the selected mailbox.
Definition: expungejob.h:32
const char * name(StandardAction id)
quint64 newHighestModSeq() const
Returns new highest modification sequence number.
Definition: expungejob.cpp:47
Q_D(Todo)
KIMAP::ImapSet vanishedMessages() const
Returns UIDs of messages that have been expunged.
Definition: expungejob.cpp:41
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 3 2023 03:51:44 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.