KIMAP

deletejob.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 "deletejob.h"
8
9#include <KLocalizedString>
10
11#include "job_p.h"
12#include "response_p.h"
13#include "rfccodecs.h"
14#include "session_p.h"
15
16namespace KIMAP
17{
18class DeleteJobPrivate : public JobPrivate
19{
20public:
21 DeleteJobPrivate(Session *session, const QString &name)
22 : JobPrivate(session, name)
23 {
24 }
25 ~DeleteJobPrivate()
26 {
27 }
28
29 QString mailBox;
30};
31}
32
33using namespace KIMAP;
34
35DeleteJob::DeleteJob(Session *session)
36 : Job(*new DeleteJobPrivate(session, i18n("Delete")))
37{
38}
39
40DeleteJob::~DeleteJob()
41{
42}
43
44void DeleteJob::doStart()
45{
47 d->tags << d->sessionInternal()->sendCommand("DELETE", '\"' + KIMAP::encodeImapFolderName(d->mailBox.toUtf8()) + '\"');
48}
49
50void DeleteJob::handleResponse(const Response &response)
51{
53
54 if (!response.content.isEmpty() && d->tags.contains(response.content.first().toString())) {
55 if (response.content.size() >= 2 && response.content[1].toString() == "NO") {
56 for (auto it = response.responseCode.cbegin(), end = response.responseCode.cend(); it != end; ++it) {
57 // NONEXISTENT can be considered a success during DELETE
58 // cf. https://tools.ietf.org/html/rfc5530#section-3
59 if (it->toString() == "NONEXISTENT") {
60 // Code copied from handleErrorReplies:
61 d->tags.removeAll(response.content.first().toString());
62 if (d->tags.isEmpty()) { // Only emit result when the last command returned
63 emitResult();
64 }
65 return;
66 }
67 }
68 }
69 }
70
71 handleErrorReplies(response);
72}
73
74void DeleteJob::setMailBox(const QString &mailBox)
75{
77 d->mailBox = mailBox;
78}
79
81{
82 Q_D(const DeleteJob);
83 return d->mailBox;
84}
85
86#include "moc_deletejob.cpp"
Delete a mailbox.
Definition deletejob.h:33
QString mailBox() const
The mailbox that will be deleted.
Definition deletejob.cpp:80
void setMailBox(const QString &mailBox)
Set the mailbox to delete.
Definition deletejob.cpp:74
void emitResult()
QString i18n(const char *text, const TYPE &arg...)
QString name(StandardAction id)
const QList< QKeySequence > & end()
This file is part of the IMAP support library and defines the RfcCodecs class.
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:55:08 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.