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_SETQUOTAJOB_H |
21 | #define KIMAP_SETQUOTAJOB_H |
22 | |
23 | #include "quotajobbase.h" |
24 | |
25 | namespace KIMAP { |
26 | |
27 | class Session; |
28 | struct Message; |
29 | class SetQuotaJobPrivate; |
30 | |
31 | /** |
32 | * Sets resource limits on a quota root. |
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 SetQuotaJob : public QuotaJobBase |
51 | { |
52 | Q_OBJECT |
53 | Q_DECLARE_PRIVATE( SetQuotaJob ) |
54 | |
55 | friend class SessionPrivate; |
56 | |
57 | public: |
58 | explicit SetQuotaJob( Session *session ); |
59 | virtual ~SetQuotaJob(); |
60 | |
61 | /** |
62 | * Set a limit for a quota resource. |
63 | * |
64 | * For example, you might set the limit for "STORAGE" to |
65 | * 512 to limit the sum of the messages' RFC822.SIZE to |
66 | * 512*1024 octets (ie: 512 kb), or the limit for "MESSAGE" |
67 | * to 100 to limit the number of messages to 100. |
68 | * |
69 | * Note that although RFC 2087 allows a resource name to |
70 | * be any string, this API actually limits resource names |
71 | * to upper-case atoms. In practice, resource names will |
72 | * almost certainly be composed entirely of upper-case latin |
73 | * letters (A-Z). |
74 | * |
75 | * @param resource the resource name |
76 | * @param limit the maximum value the resource may take |
77 | */ |
78 | void setQuota( const QByteArray &resource, qint64 limit ); |
79 | |
80 | /** |
81 | * Set the quota root the resource limits should be set for. |
82 | * |
83 | * Note: if the quota root does not already exist, the server |
84 | * may create it and change the quota roots for any number of |
85 | * existing mailboxes in an implementation-defined manner. |
86 | * |
87 | * @param root the quota root to set, in bytes |
88 | * @see GetQuotaRootJob |
89 | */ |
90 | void setRoot( const QByteArray &root ); |
91 | /** |
92 | * The quota root that will be modified. |
93 | */ |
94 | QByteArray root() const; |
95 | |
96 | protected: |
97 | virtual void doStart(); |
98 | virtual void handleResponse( const Message &response ); |
99 | |
100 | }; |
101 | |
102 | } |
103 | |
104 | #endif |
105 | |