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 | #ifndef KIMAP_GETQUOTAROOTJOB_H |
21 | #define KIMAP_GETQUOTAROOTJOB_H |
22 | |
23 | #include "quotajobbase.h" |
24 | |
25 | namespace KIMAP { |
26 | |
27 | class Session; |
28 | struct Message; |
29 | class GetQuotaRootJobPrivate; |
30 | |
31 | /** |
32 | * Gets the quota root and resource limits for a mailbox. |
33 | * |
34 | * Quotas are defined with respect to "resources" and "quota roots". |
35 | * A resource is a numerical property that can be limited, such |
36 | * as the octet size of all the messages in a mailbox, or the |
37 | * number of messages in a mailbox. Each mailbox has one or more |
38 | * quota roots, which are where the resource limits are defined. |
39 | * A quota root may or may not be a mailbox name, and an empty |
40 | * string is a valid quota root. All mailboxes with the same quota |
41 | * root share the resource limits of the quota root. |
42 | * |
43 | * This job can only be run when the session is in the |
44 | * authenticated (or selected) state. |
45 | * |
46 | * This job requires that the server supports the QUOTA |
47 | * capability, defined in |
48 | * <a href="http://www.apps.ietf.org/rfc/rfc2087.html">RFC 2087</a>. |
49 | */ |
50 | class KIMAP_EXPORT GetQuotaRootJob : public QuotaJobBase |
51 | { |
52 | Q_OBJECT |
53 | Q_DECLARE_PRIVATE( GetQuotaRootJob ) |
54 | |
55 | friend class SessionPrivate; |
56 | |
57 | public: |
58 | explicit GetQuotaRootJob( Session *session ); |
59 | virtual ~GetQuotaRootJob(); |
60 | |
61 | /** |
62 | * Set the mailbox to get the quota roots for. |
63 | * |
64 | * @param mailBox the name of an existing mailbox |
65 | */ |
66 | void setMailBox(const QString &mailBox); |
67 | /** |
68 | * The mailbox that the quota roots will be fetched for. |
69 | */ |
70 | QString mailBox() const; |
71 | |
72 | /** |
73 | * The quota roots for the mailbox. |
74 | */ |
75 | QList<QByteArray> roots() const; |
76 | /** |
77 | * Get the current usage for a resource. |
78 | * |
79 | * Note that if there is no limit for a resource, the |
80 | * server will not provide information about resource |
81 | * usage. |
82 | * |
83 | * @param root the quota root to get the resource usage for |
84 | * @param resource the resource to get the usage for |
85 | * @return the resource usage in appropriate units, or -1 |
86 | * if the usage is unknown or there is no |
87 | * limit on the resource |
88 | */ |
89 | qint64 usage(const QByteArray &root, const QByteArray &resource) const; |
90 | /** |
91 | * Get the current limit for a resource. |
92 | * |
93 | * @param root the quota root to get the resource limit for |
94 | * @param resource the resource to get the limit for |
95 | * @return the resource limit in appropriate units, or -1 |
96 | * if the limit is unknown or there is no |
97 | * limit on the resource |
98 | */ |
99 | qint64 limit(const QByteArray &root, const QByteArray &resource) const; |
100 | |
101 | /** |
102 | * Get a map containing all resource usage figures for a quota root. |
103 | * |
104 | * @param root the quota root to get resource usage figures for |
105 | * @return a map from resource names to usage figures |
106 | */ |
107 | QMap<QByteArray, qint64> allUsages(const QByteArray &root) const; |
108 | /** |
109 | * Get a map containing all resource limits for a quota root. |
110 | * |
111 | * @param root the quota root to get resource limits for |
112 | * @return a map from resource names to limits |
113 | */ |
114 | QMap<QByteArray, qint64> allLimits(const QByteArray &root) const; |
115 | |
116 | protected: |
117 | virtual void doStart(); |
118 | virtual void handleResponse(const Message &response); |
119 | |
120 | }; |
121 | |
122 | } |
123 | |
124 | #endif |
125 | |