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

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 "kimap_export.h"
0010 
0011 #include "job.h"
0012 
0013 namespace KIMAP
0014 {
0015 class Session;
0016 struct Response;
0017 class MetaDataJobBasePrivate;
0018 
0019 /**
0020  * Base class for jobs that operate on mailbox metadata
0021  *
0022  * Provides support for the IMAP METADATA extension; both the
0023  * final RFC version
0024  * (<a href="https://tools.ietf.org/html/rfc5464">RFC 5464</a>)
0025  * and the older, incompatible draft version (known as ANNOTATEMORE)
0026  * (<a
0027  * href="https://tools.ietf.org/html/draft-daboo-imap-annotatemore-07"
0028  * >draft-daboo-imap-annotatemore-07</a>).
0029  *
0030  * This class cannot be used directly, you must subclass it and reimplement
0031  * at least the doStart() method.
0032  */
0033 class KIMAP_EXPORT MetaDataJobBase : public Job
0034 {
0035     Q_OBJECT
0036     Q_DECLARE_PRIVATE(MetaDataJobBase)
0037 
0038     friend class SessionPrivate;
0039 
0040 public:
0041     explicit MetaDataJobBase(Session *session);
0042     ~MetaDataJobBase() override;
0043 
0044     /**
0045      * Represents the capability level of the server.
0046      */
0047     enum ServerCapability {
0048         /**
0049          * Used to indicate that the server supports the RFC 5464 version
0050          * of the extension.
0051          *
0052          * This corresponds to the METADATA server capability.
0053          */
0054         Metadata = 0,
0055         /**
0056          * Used to indicate that the server supports the
0057          * draft-daboo-imap-annotatemore-07 version of the extension.
0058          *
0059          * This corresponds to the ANNOTATEMORE server capability.
0060          */
0061         Annotatemore
0062     };
0063 
0064     /**
0065      * Set the mailbox to act on
0066      *
0067      * This may be an empty string, in which case metadata for the
0068      * server (rather than a specific mailbox) will be retrieved.
0069      *
0070      * @param mailBox  the name of an existing mailbox, or an empty string
0071      */
0072     void setMailBox(const QString &mailBox);
0073     /**
0074      * The mailbox that will be acted upon.
0075      *
0076      * If this is an empty string, server metadata will be retrieved.
0077      *
0078      * @return  a mailbox name, or an empty string
0079      */
0080     [[nodiscard]] QString mailBox() const;
0081 
0082     /**
0083      * Set what version of the metadata extension to be compatible with.
0084      *
0085      * This will determine the commands that will be sent to the server.
0086      *
0087      * The draft for the metadata extension changed in an incompatible
0088      * way between versions 7 and 8, and some servers support version 7.
0089      * It should be possible to check which version the server supports
0090      * using CapabilityJob: servers implementing
0091      * draft-daboo-imap-annotatemore-07 should advertise the
0092      * ANNOTATEMORE capability, whereas servers implementing the final
0093      * RFC 5464 should advertise the METADATA capability.
0094      *
0095      * The default mode is Metadata.
0096      *
0097      * @param capability  the version of the extension implemented by the server
0098      */
0099     void setServerCapability(ServerCapability capability);
0100     /**
0101      * The version of the metadata extension that will be used.
0102      */
0103     [[nodiscard]] ServerCapability serverCapability() const;
0104 
0105 protected:
0106     MetaDataJobBase(JobPrivate &dd);
0107 };
0108 
0109 }