KIMAP

getquotarootjob.h
1/*
2 SPDX-FileCopyrightText: 2009 Andras Mantia <amantia@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "quotajobbase.h"
10
11namespace KIMAP
12{
13class Session;
14struct Message;
15class GetQuotaRootJobPrivate;
16
17/**
18 * Gets the quota root and resource limits for a mailbox.
19 *
20 * Quotas are defined with respect to "resources" and "quota roots".
21 * A resource is a numerical property that can be limited, such
22 * as the octet size of all the messages in a mailbox, or the
23 * number of messages in a mailbox. Each mailbox has one or more
24 * quota roots, which are where the resource limits are defined.
25 * A quota root may or may not be a mailbox name, and an empty
26 * string is a valid quota root. All mailboxes with the same quota
27 * root share the resource limits of the quota root.
28 *
29 * This job can only be run when the session is in the
30 * authenticated (or selected) state.
31 *
32 * This job requires that the server supports the QUOTA
33 * capability, defined in
34 * <a href="https://tools.ietf.org/html/rfc2087">RFC 2087</a>.
35 */
36class KIMAP_EXPORT GetQuotaRootJob : public QuotaJobBase
37{
38 Q_OBJECT
39 Q_DECLARE_PRIVATE(GetQuotaRootJob)
40
41 friend class SessionPrivate;
42
43public:
44 explicit GetQuotaRootJob(Session *session);
45 ~GetQuotaRootJob() override;
46
47 /**
48 * Set the mailbox to get the quota roots for.
49 *
50 * @param mailBox the name of an existing mailbox
51 */
52 void setMailBox(const QString &mailBox);
53 /**
54 * The mailbox that the quota roots will be fetched for.
55 */
56 [[nodiscard]] QString mailBox() const;
57
58 /**
59 * The quota roots for the mailbox.
60 */
61 [[nodiscard]] QList<QByteArray> roots() const;
62 /**
63 * Get the current usage for a resource.
64 *
65 * Note that if there is no limit for a resource, the
66 * server will not provide information about resource
67 * usage.
68 *
69 * @param root the quota root to get the resource usage for
70 * @param resource the resource to get the usage for
71 * @return the resource usage in appropriate units, or -1
72 * if the usage is unknown or there is no
73 * limit on the resource
74 */
75 [[nodiscard]] qint64 usage(const QByteArray &root, const QByteArray &resource) const;
76 /**
77 * Get the current limit for a resource.
78 *
79 * @param root the quota root to get the resource limit for
80 * @param resource the resource to get the limit for
81 * @return the resource limit in appropriate units, or -1
82 * if the limit is unknown or there is no
83 * limit on the resource
84 */
85 [[nodiscard]] qint64 limit(const QByteArray &root, const QByteArray &resource) const;
86
87 /**
88 * Get a map containing all resource usage figures for a quota root.
89 *
90 * @param root the quota root to get resource usage figures for
91 * @return a map from resource names to usage figures
92 */
93 [[nodiscard]] QMap<QByteArray, qint64> allUsages(const QByteArray &root) const;
94 /**
95 * Get a map containing all resource limits for a quota root.
96 *
97 * @param root the quota root to get resource limits for
98 * @return a map from resource names to limits
99 */
100 [[nodiscard]] QMap<QByteArray, qint64> allLimits(const QByteArray &root) const;
101
102protected:
103 void doStart() override;
104 void handleResponse(const Response &response) override;
105};
106
107}
Gets the quota root and resource limits for a mailbox.
Base class for jobs that operate on mailbox quotas.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:37 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.