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

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_QUOTAJOBBASE_H
0021 #define KIMAP2_QUOTAJOBBASE_H
0022 
0023 #include "kimap2_export.h"
0024 
0025 #include "job.h"
0026 
0027 namespace KIMAP2
0028 {
0029 
0030 class Session;
0031 struct Message;
0032 class QuotaJobBasePrivate;
0033 
0034 /**
0035  * Base class for jobs that operate on mailbox quotas
0036  *
0037  * Provides support for the IMAP QUOTA extension, as defined by
0038  * <a href="http://www.apps.ietf.org/rfc/rfc2087.html" title="IMAP QUOTA extension">RFC 2087</a>.
0039  *
0040  * This class cannot be used directly, you must subclass it and reimplement
0041  * at least the doStart() method.
0042 */
0043 class KIMAP2_EXPORT QuotaJobBase : public Job
0044 {
0045     Q_OBJECT
0046     Q_DECLARE_PRIVATE(QuotaJobBase)
0047 
0048     friend class SessionPrivate;
0049 
0050 public:
0051     explicit QuotaJobBase(Session *session);
0052     virtual ~QuotaJobBase();
0053 
0054     /**
0055      * Get the current usage for a resource.
0056      *
0057      * All quota jobs will normally cause the server to return
0058      * details of resource usage for all resources that were
0059      * queried or modified by the job.
0060      *
0061      * Note that RFC 2087 is slightly ambiguous about whether
0062      * SETQUOTA will cause this information to be sent by the
0063      * server.
0064      *
0065      * Note that if there is no limit for a resource, the
0066      * server will not provide information about resource
0067      * usage.
0068      *
0069      * @param resource  the resource to get the usage for
0070      * @return  the resource usage in appropriate units, or -1
0071      *          if the usage is unknown or there is no
0072      *          limit on the resource
0073      */
0074     qint64 usage(const QByteArray &resource);
0075     /**
0076      * Get the current limit for a resource.
0077      *
0078      * All quota jobs will normally cause the server to return
0079      * details of resource limits for all resources that were
0080      * queried or modified by the job.
0081      *
0082      * Note that RFC 2087 is slightly ambiguous about whether
0083      * SETQUOTA will cause this information to be sent by the
0084      * server.
0085      *
0086      * @param resource  the resource to get the limit for
0087      * @return  the resource limit in appropriate units, or -1
0088      *          if the limit is unknown or there is no limit
0089      *          on the resource
0090      */
0091     qint64 limit(const QByteArray &resource);
0092 
0093 protected:
0094     QuotaJobBase(JobPrivate &dd);
0095 
0096 };
0097 
0098 }
0099 
0100 #endif