KIMAP

createjob.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 "createjob.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 CreateJobPrivate : public JobPrivate
19{
20public:
21 CreateJobPrivate(Session *session, const QString &name)
22 : JobPrivate(session, name)
23 {
24 }
25 ~CreateJobPrivate()
26 {
27 }
28
29 QString mailBox;
30};
31}
32
33using namespace KIMAP;
34
35CreateJob::CreateJob(Session *session)
36 : Job(*new CreateJobPrivate(session, i18n("Create")))
37{
38}
39
40CreateJob::~CreateJob()
41{
42}
43
44void CreateJob::doStart()
45{
47 d->tags << d->sessionInternal()->sendCommand("CREATE", '\"' + KIMAP::encodeImapFolderName(d->mailBox.toUtf8()) + '\"');
48}
49
50void CreateJob::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 // ALREADYEXISTS can be considered a success during CREATE
58 // cf. https://tools.ietf.org/html/rfc5530#section-3
59 if (it->toString() == "ALREADYEXISTS") {
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 CreateJob::setMailBox(const QString &mailBox)
75{
77 d->mailBox = mailBox;
78}
79
81{
82 Q_D(const CreateJob);
83 return d->mailBox;
84}
85
86#include "moc_createjob.cpp"
Creates a new mailbox.
Definition createjob.h:34
QString mailBox() const
The name of the mailbox that will be created.
Definition createjob.cpp:80
void setMailBox(const QString &mailBox)
Set the name of the new mailbox.
Definition createjob.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 Jun 21 2024 11:59:25 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.