File indexing completed on 2024-05-12 05:17:25

0001 /*
0002     Copyright (c) 2009 Andras Mantia <amantia@kde.org>
0003 
0004     This library is free software; you can redistribute it and/or modify it
0005     under the terms of the GNU Library General Public License as published by
0006     the Free Software Foundation; either version 2 of the License, or (at your
0007     option) any later version.
0008 
0009     This library is distributed in the hope that it will be useful, but WITHOUT
0010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
0012     License for more details.
0013 
0014     You should have received a copy of the GNU Library General Public License
0015     along with this library; see the file COPYING.LIB.  If not, write to the
0016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0017     02110-1301, USA.
0018 */
0019 
0020 #ifndef KIMAP2_SETQUOTAJOB_H
0021 #define KIMAP2_SETQUOTAJOB_H
0022 
0023 #include "quotajobbase.h"
0024 
0025 namespace KIMAP2
0026 {
0027 
0028 class Session;
0029 struct Message;
0030 class SetQuotaJobPrivate;
0031 
0032 /**
0033  * Sets resource limits on a quota root.
0034  *
0035  * Quotas are defined with respect to "resources" and "quota roots".
0036  * A resource is a numerical property that can be limited, such
0037  * as the octet size of all the messages in a mailbox, or the
0038  * number of messages in a mailbox.  Each mailbox has one or more
0039  * quota roots, which are where the resource limits are defined.
0040  * A quota root may or may not be a mailbox name, and an empty
0041  * string is a valid quota root.  All mailboxes with the same quota
0042  * root share the resource limits of the quota root.
0043  *
0044  * This job can only be run when the session is in the
0045  * authenticated (or selected) state.
0046  *
0047  * This job requires that the server supports the QUOTA
0048  * capability, defined in
0049  * <a href="http://www.apps.ietf.org/rfc/rfc2087.html">RFC 2087</a>.
0050  */
0051 class KIMAP2_EXPORT SetQuotaJob : public QuotaJobBase
0052 {
0053     Q_OBJECT
0054     Q_DECLARE_PRIVATE(SetQuotaJob)
0055 
0056     friend class SessionPrivate;
0057 
0058 public:
0059     explicit SetQuotaJob(Session *session);
0060     virtual ~SetQuotaJob();
0061 
0062     /**
0063      * Set a limit for a quota resource.
0064      *
0065      * For example, you might set the limit for "STORAGE" to
0066      * 512 to limit the sum of the messages' RFC822.SIZE to
0067      * 512*1024 octets (ie: 512 kb), or the limit for "MESSAGE"
0068      * to 100 to limit the number of messages to 100.
0069      *
0070      * Note that although RFC 2087 allows a resource name to
0071      * be any string, this API actually limits resource names
0072      * to upper-case atoms.  In practice, resource names will
0073      * almost certainly be composed entirely of upper-case latin
0074      * letters (A-Z).
0075      *
0076      * @param resource  the resource name
0077      * @param limit     the maximum value the resource may take
0078      */
0079     void setQuota(const QByteArray &resource, qint64 limit);
0080 
0081     /**
0082      * Set the quota root the resource limits should be set for.
0083      *
0084      * Note: if the quota root does not already exist, the server
0085      * may create it and change the quota roots for any number of
0086      * existing mailboxes in an implementation-defined manner.
0087      *
0088      * @param root the quota root to set, in bytes
0089      * @see GetQuotaRootJob
0090      */
0091     void setRoot(const QByteArray &root);
0092     /**
0093      * The quota root that will be modified.
0094      */
0095     QByteArray root() const;
0096 
0097 protected:
0098     void doStart() Q_DECL_OVERRIDE;
0099     void handleResponse(const Message &response) Q_DECL_OVERRIDE;
0100 
0101 };
0102 
0103 }
0104 
0105 #endif