KIMAP2

setquotajob.cpp
1/*
2 Copyright (c) 2009 Andras Mantia <amantia@kde.org>
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
28namespace KIMAP2
29{
30class SetQuotaJobPrivate : public QuotaJobBasePrivate
31{
32public:
33 SetQuotaJobPrivate(Session *session, const QString &name) : QuotaJobBasePrivate(session, name) { }
34 ~SetQuotaJobPrivate() { }
35
37 QByteArray root;
38};
39}
40
41using namespace KIMAP2;
42
43SetQuotaJob::SetQuotaJob(Session *session)
44 : QuotaJobBase(*new SetQuotaJobPrivate(session, "SetQuota"))
45{
46}
47
48SetQuotaJob::~SetQuotaJob()
49{
50}
51
52void SetQuotaJob::doStart()
53{
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
71void SetQuotaJob::handleResponse(const Message &response)
72{
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
82void SetQuotaJob::setQuota(const QByteArray &resource, qint64 limit)
83{
85
86 d->setList[resource.toUpper()] = limit;
87}
88
90{
92
93 d->root = root;
94}
95
97{
98 Q_D(const SetQuotaJob);
99
100 return d->root;
101}
Base class for jobs that operate on mailbox quotas.
qint64 limit(const QByteArray &resource)
Get the current limit for a resource.
Sets resource limits on a quota root.
Definition setquotajob.h:52
QByteArray root() const
The quota root that will be modified.
void setQuota(const QByteArray &resource, qint64 limit)
Set a limit for a quota resource.
void setRoot(const QByteArray &root)
Set the quota root the resource limits should be set for.
QString name(StandardAction id)
qsizetype length() const const
QByteArray number(double n, char format, int precision)
QByteArray toUpper() const const
ConstIterator
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.