File indexing completed on 2024-05-12 05:17:17
0001 /* 0002 SPDX-FileCopyrightText: 2009 Andras Mantia <amantia@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "quotajobbase.h" 0010 0011 namespace KIMAP 0012 { 0013 class Session; 0014 struct Response; 0015 class SetQuotaJobPrivate; 0016 0017 /** 0018 * Sets resource limits on a quota root. 0019 * 0020 * Quotas are defined with respect to "resources" and "quota roots". 0021 * A resource is a numerical property that can be limited, such 0022 * as the octet size of all the messages in a mailbox, or the 0023 * number of messages in a mailbox. Each mailbox has one or more 0024 * quota roots, which are where the resource limits are defined. 0025 * A quota root may or may not be a mailbox name, and an empty 0026 * string is a valid quota root. All mailboxes with the same quota 0027 * root share the resource limits of the quota root. 0028 * 0029 * This job can only be run when the session is in the 0030 * authenticated (or selected) state. 0031 * 0032 * This job requires that the server supports the QUOTA 0033 * capability, defined in 0034 * <a href="https://tools.ietf.org/html/rfc2087">RFC 2087</a>. 0035 */ 0036 class KIMAP_EXPORT SetQuotaJob : public QuotaJobBase 0037 { 0038 Q_OBJECT 0039 Q_DECLARE_PRIVATE(SetQuotaJob) 0040 0041 friend class SessionPrivate; 0042 0043 public: 0044 explicit SetQuotaJob(Session *session); 0045 ~SetQuotaJob() override; 0046 0047 /** 0048 * Set a limit for a quota resource. 0049 * 0050 * For example, you might set the limit for "STORAGE" to 0051 * 512 to limit the sum of the messages' RFC822.SIZE to 0052 * 512*1024 octets (ie: 512 kb), or the limit for "MESSAGE" 0053 * to 100 to limit the number of messages to 100. 0054 * 0055 * Note that although RFC 2087 allows a resource name to 0056 * be any string, this API actually limits resource names 0057 * to upper-case atoms. In practice, resource names will 0058 * almost certainly be composed entirely of upper-case latin 0059 * letters (A-Z). 0060 * 0061 * @param resource the resource name 0062 * @param limit the maximum value the resource may take 0063 */ 0064 void setQuota(const QByteArray &resource, qint64 limit); 0065 0066 /** 0067 * Set the quota root the resource limits should be set for. 0068 * 0069 * Note: if the quota root does not already exist, the server 0070 * may create it and change the quota roots for any number of 0071 * existing mailboxes in an implementation-defined manner. 0072 * 0073 * @param root the quota root to set, in bytes 0074 * @see GetQuotaRootJob 0075 */ 0076 void setRoot(const QByteArray &root); 0077 /** 0078 * The quota root that will be modified. 0079 */ 0080 [[nodiscard]] QByteArray root() const; 0081 0082 protected: 0083 void doStart() override; 0084 void handleResponse(const Response &response) override; 0085 }; 0086 0087 }