KIMAP

enablejob.cpp
1 /*
2  SPDX-FileCopyrightText: 2020 Daniel Vr├ítil <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "enablejob.h"
8 
9 #include <KLocalizedString>
10 
11 #include "job_p.h"
12 #include "kimap_debug.h"
13 #include "response_p.h"
14 #include "session_p.h"
15 
16 namespace KIMAP
17 {
18 class EnableJobPrivate : public JobPrivate
19 {
20 public:
21  using JobPrivate::JobPrivate;
22 
23  QStringList reqCapabilities;
24  QStringList enabledCapabilities;
25 };
26 }
27 
28 using namespace KIMAP;
29 
30 EnableJob::EnableJob(Session *session)
31  : Job(*new EnableJobPrivate(session, i18n("Enable")))
32 {
33 }
34 
35 EnableJob::~EnableJob() = default;
36 
37 void EnableJob::setCapabilities(const QStringList &capabilities)
38 {
39  Q_D(EnableJob);
40  d->reqCapabilities = capabilities;
41 }
42 
44 {
45  Q_D(const EnableJob);
46  return d->enabledCapabilities;
47 }
48 
49 void EnableJob::doStart()
50 {
51  Q_D(EnableJob);
52  d->tags << d->sessionInternal()->sendCommand("ENABLE", d->reqCapabilities.join(QLatin1Char{' '}).toLatin1());
53 }
54 
55 void EnableJob::handleResponse(const Response &response)
56 {
57  Q_D(EnableJob);
58 
59  if (handleErrorReplies(response) == NotHandled) {
60  if (response.content.size() >= 2) {
61  for (int i = 2; i < response.content.size(); ++i) {
62  d->enabledCapabilities.push_back(QString::fromLatin1(response.content[i].toString()));
63  }
64  } else {
65  qCDebug(KIMAP_LOG) << response.toString();
66  }
67  }
68 }
69 
70 #include "moc_enablejob.cpp"
Capabilities capabilities() const
QString i18n(const char *text, const TYPE &arg...)
QStringList enabledCapabilities() const
List of capabilities that were successfully enabled on the server.
Definition: enablejob.cpp:43
Job to enable additional IMAP capabilities.
Definition: enablejob.h:33
QString fromLatin1(const char *str, int size)
void setCapabilities(const QStringList &capabilities)
List of server capabilities to enable.
Definition: enablejob.cpp:37
Q_D(Todo)
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.