KIMAP

setquotajob.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 "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
16namespace KIMAP
17{
18class SetQuotaJobPrivate : public QuotaJobBasePrivate
19{
20public:
21 SetQuotaJobPrivate(Session *session, const QString &name)
22 : QuotaJobBasePrivate(session, name)
23 {
24 }
25 ~SetQuotaJobPrivate()
26 {
27 }
28
30 QByteArray root;
31};
32}
33
34using namespace KIMAP;
35
36SetQuotaJob::SetQuotaJob(Session *session)
37 : QuotaJobBase(*new SetQuotaJobPrivate(session, i18n("SetQuota")))
38{
39}
40
41SetQuotaJob::~SetQuotaJob()
42{
43}
44
45void 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
64void 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
74void 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"
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:37
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 i18n(const char *text, const TYPE &arg...)
QString name(GameStandardAction 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 Fri Nov 29 2024 11:58:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.