KIMAP

setquotajob.cpp
1 /*
2  SPDX-FileCopyrightText: 2009 Andras Mantia <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "setquotajob.h"
8 
9 #include "kimap_debug.h"
10 #include <KLocalizedString>
11 
12 #include "quotajobbase_p.h"
13 #include "response_p.h"
14 #include "session_p.h"
15 
16 namespace KIMAP
17 {
18 class SetQuotaJobPrivate : public QuotaJobBasePrivate
19 {
20 public:
21  SetQuotaJobPrivate(Session *session, const QString &name)
22  : QuotaJobBasePrivate(session, name)
23  {
24  }
25  ~SetQuotaJobPrivate()
26  {
27  }
28 
30  QByteArray root;
31 };
32 }
33 
34 using namespace KIMAP;
35 
36 SetQuotaJob::SetQuotaJob(Session *session)
37  : QuotaJobBase(*new SetQuotaJobPrivate(session, i18n("SetQuota")))
38 {
39 }
40 
41 SetQuotaJob::~SetQuotaJob()
42 {
43 }
44 
45 void SetQuotaJob::doStart()
46 {
48  QByteArray s;
49  s += '(';
50  for (QMap<QByteArray, qint64>::ConstIterator it = d->setList.constBegin(), end = d->setList.constEnd(); it != end; ++it) {
51  s += it.key() + ' ' + QByteArray::number(it.value()) + ' ';
52  }
53  if (d->setList.isEmpty()) {
54  s += ')';
55  } else {
56  s[s.length() - 1] = ')';
57  }
58 
59  qCDebug(KIMAP_LOG) << "SETQUOTA " << '\"' + d->root + "\" " + s;
60  // XXX: [alexmerry, 2010-07-24]: should d->root be quoted properly?
61  d->tags << d->sessionInternal()->sendCommand("SETQUOTA", '\"' + d->root + "\" " + s);
62 }
63 
64 void SetQuotaJob::handleResponse(const Response &response)
65 {
67  if (handleErrorReplies(response) == NotHandled) {
68  if (response.content.size() >= 4 && response.content[1].toString() == "QUOTA") {
69  d->quota = d->readQuota(response.content[3]);
70  }
71  }
72 }
73 
74 void SetQuotaJob::setQuota(const QByteArray &resource, qint64 limit)
75 {
77 
78  d->setList[resource.toUpper()] = limit;
79 }
80 
82 {
84 
85  d->root = root;
86 }
87 
89 {
90  Q_D(const SetQuotaJob);
91 
92  return d->root;
93 }
94 
95 #include "moc_setquotajob.cpp"
QMap::const_iterator constBegin() const const
void setQuota(const QByteArray &resource, qint64 limit)
Set a limit for a quota resource.
Definition: setquotajob.cpp:74
qint64 limit(const QByteArray &resource)
Get the current limit for a resource.
QByteArray number(int n, int base)
Base class for jobs that operate on mailbox quotas.
Definition: quotajobbase.h:28
Sets resource limits on a quota root.
Definition: setquotajob.h:36
QString i18n(const char *text, const TYPE &arg...)
QByteArray root() const
The quota root that will be modified.
Definition: setquotajob.cpp:88
QByteArray toUpper() const const
void setRoot(const QByteArray &root)
Set the quota root the resource limits should be set for.
Definition: setquotajob.cpp:81
const char * name(StandardAction id)
int length() const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 10 2023 03:48:59 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.