KIMAP

quotajobbase.cpp
1 /*
2  SPDX-FileCopyrightText: 2009 Andras Mantia <[email protected]>
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 
14 using namespace KIMAP;
15 
16 QMap<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 
33 QuotaJobBase::QuotaJobBase(Session *session)
34  : Job(*new QuotaJobBasePrivate(session, i18n("QuotaJobBase")))
35 {
36 }
37 
38 QuotaJobBase::QuotaJobBase(JobPrivate &dd)
39  : Job(dd)
40 {
41 }
42 
43 QuotaJobBase::~QuotaJobBase()
44 {
45 }
46 
47 qint64 QuotaJobBase::usage(const QByteArray &resource)
48 {
49  Q_D(QuotaJobBase);
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 
59 qint64 QuotaJobBase::limit(const QByteArray &resource)
60 {
61  Q_D(QuotaJobBase);
62 
63  QByteArray r = resource.toUpper();
64 
65  if (d->quota.contains(r)) {
66  return d->quota[r].second;
67  }
68  return -1;
69 }
Base class for jobs that operate on mailbox quotas.
Definition: quotajobbase.h:30
QByteArray toUpper() const const
int size() const const
QString i18n(const char *text, const TYPE &arg...)
qint64 limit(const QByteArray &resource)
Get the current limit for a resource.
qint64 usage(const QByteArray &resource)
Get the current usage for a resource.
Definition: acl.cpp:12
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Oct 24 2020 23:16:51 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.