KIMAP2

setquotajob.cpp
1 /*
2  Copyright (c) 2009 Andras Mantia <[email protected]>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "setquotajob.h"
21 
22 #include "kimap_debug.h"
23 
24 #include "quotajobbase_p.h"
25 #include "message_p.h"
26 #include "session_p.h"
27 
28 namespace KIMAP2
29 {
30 class SetQuotaJobPrivate : public QuotaJobBasePrivate
31 {
32 public:
33  SetQuotaJobPrivate(Session *session, const QString &name) : QuotaJobBasePrivate(session, name) { }
34  ~SetQuotaJobPrivate() { }
35 
37  QByteArray root;
38 };
39 }
40 
41 using namespace KIMAP2;
42 
43 SetQuotaJob::SetQuotaJob(Session *session)
44  : QuotaJobBase(*new SetQuotaJobPrivate(session, "SetQuota"))
45 {
46 }
47 
48 SetQuotaJob::~SetQuotaJob()
49 {
50 }
51 
52 void SetQuotaJob::doStart()
53 {
54  Q_D(SetQuotaJob);
55  QByteArray s;
56  s += '(';
57  for (QMap<QByteArray, qint64>::ConstIterator it = d->setList.constBegin(); it != d->setList.constEnd(); ++it) {
58  s += it.key() + ' ' + QByteArray::number(it.value()) + ' ';
59  }
60  if (d->setList.isEmpty()) {
61  s += ')';
62  } else {
63  s[s.length() - 1] = ')';
64  }
65 
66  qCDebug(KIMAP2_LOG) << "SETQUOTA " << '\"' + d->root + "\" " + s;
67  //XXX: [alexmerry, 2010-07-24]: should d->root be quoted properly?
68  d->sendCommand("SETQUOTA", '\"' + d->root + "\" " + s);
69 }
70 
71 void SetQuotaJob::handleResponse(const Message &response)
72 {
73  Q_D(SetQuotaJob);
74  if (handleErrorReplies(response) == NotHandled) {
75  if (response.content.size() >= 4 &&
76  response.content[1].toString() == "QUOTA") {
77  d->quota = d->readQuota(response.content[3]);
78  }
79  }
80 }
81 
82 void SetQuotaJob::setQuota(const QByteArray &resource, qint64 limit)
83 {
84  Q_D(SetQuotaJob);
85 
86  d->setList[resource.toUpper()] = limit;
87 }
88 
90 {
91  Q_D(SetQuotaJob);
92 
93  d->root = root;
94 }
95 
97 {
98  Q_D(const SetQuotaJob);
99 
100  return d->root;
101 }
QMap::const_iterator constBegin() const const
QByteArray toUpper() const const
int length() const const
void setQuota(const QByteArray &resource, qint64 limit)
Set a limit for a quota resource.
Definition: setquotajob.cpp:82
Sets resource limits on a quota root.
Definition: setquotajob.h:51
QByteArray number(int n, int base)
Base class for jobs that operate on mailbox quotas.
Definition: quotajobbase.h:43
Definition: acl.cpp:25
void setRoot(const QByteArray &root)
Set the quota root the resource limits should be set for.
Definition: setquotajob.cpp:89
QByteArray root() const
The quota root that will be modified.
Definition: setquotajob.cpp:96
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Jun 4 2020 23:02:57 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.