KIMAP

quotajobbase.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 "quotajobbase.h"
8#include "quotajobbase_p.h"
9#include "response_p.h"
10#include "session_p.h"
11
12#include <KLocalizedString>
13
14using namespace KIMAP;
15
16QMap<QByteArray, QPair<qint64, qint64>> QuotaJobBasePrivate::readQuota(const Response::Part &content)
17{
19 QList<QByteArray> quotas = content.toList();
20
21 int i = 0;
22 while (i < quotas.size() - 2) {
23 QByteArray resource = quotas[i].toUpper();
24 qint64 usage = quotas[i + 1].toInt();
25 qint64 limit = quotas[i + 2].toInt();
26 quotaMap[resource] = qMakePair(usage, limit);
27 i += 3;
28 }
29
30 return quotaMap;
31}
32
33QuotaJobBase::QuotaJobBase(Session *session)
34 : Job(*new QuotaJobBasePrivate(session, i18n("QuotaJobBase")))
35{
36}
37
38QuotaJobBase::QuotaJobBase(JobPrivate &dd)
39 : Job(dd)
40{
41}
42
43QuotaJobBase::~QuotaJobBase()
44{
45}
46
47qint64 QuotaJobBase::usage(const QByteArray &resource)
48{
50
51 QByteArray r = resource.toUpper();
52
53 if (d->quota.contains(r)) {
54 return d->quota[r].first;
55 }
56 return -1;
57}
58
59qint64 QuotaJobBase::limit(const QByteArray &resource)
60{
62
63 QByteArray r = resource.toUpper();
64
65 if (d->quota.contains(r)) {
66 return d->quota[r].second;
67 }
68 return -1;
69}
70
71#include "moc_quotajobbase.cpp"
Base class for jobs that operate on mailbox quotas.
qint64 usage(const QByteArray &resource)
Get the current usage for a resource.
qint64 limit(const QByteArray &resource)
Get the current limit for a resource.
QString i18n(const char *text, const TYPE &arg...)
QByteArray toUpper() const const
QList< T > toList() const const
qsizetype size() const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:17 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.