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_METADATAJOBBASE_H |
21 | #define KIMAP_METADATAJOBBASE_H |
22 | |
23 | #include "kimap_export.h" |
24 | |
25 | #include "job.h" |
26 | |
27 | namespace KIMAP { |
28 | |
29 | class Session; |
30 | struct Message; |
31 | class MetaDataJobBasePrivate; |
32 | |
33 | /** |
34 | * Base class for jobs that operate on mailbox metadata |
35 | * |
36 | * Provides support for the IMAP METADATA extension; both the |
37 | * final RFC version |
38 | * (<a href="http://tools.ietf.org/html/rfc5464">RFC 5464</a>) |
39 | * and the older, incompatible draft version (known as ANNOTATEMORE) |
40 | * (<a |
41 | * href="http://tools.ietf.org/html/draft-daboo-imap-annotatemore-07" |
42 | * >draft-daboo-imap-annotatemore-07</a>). |
43 | * |
44 | * This class cannot be used directly, you must subclass it and reimplement |
45 | * at least the doStart() method. |
46 | */ |
47 | class KIMAP_EXPORT MetaDataJobBase : public Job |
48 | { |
49 | Q_OBJECT |
50 | Q_DECLARE_PRIVATE( MetaDataJobBase ) |
51 | |
52 | friend class SessionPrivate; |
53 | |
54 | public: |
55 | explicit MetaDataJobBase( Session *session ); |
56 | virtual ~MetaDataJobBase(); |
57 | |
58 | /** |
59 | * Represents the capability level of the server. |
60 | */ |
61 | enum ServerCapability { |
62 | /** |
63 | * Used to indicate that the server supports the RFC 5464 version |
64 | * of the extension. |
65 | * |
66 | * This corresponds to the METADATA server capability. |
67 | */ |
68 | Metadata = 0, |
69 | /** |
70 | * Used to indicate that the server supports the |
71 | * draft-daboo-imap-annotatemore-07 version of the extension. |
72 | * |
73 | * This corresponds to the ANNOTATEMORE server capability. |
74 | */ |
75 | Annotatemore |
76 | }; |
77 | |
78 | /** |
79 | * Set the mailbox to act on |
80 | * |
81 | * This may be an empty string, in which case metadata for the |
82 | * server (rather than a specific mailbox) will be retrieved. |
83 | * |
84 | * @param mailBox the name of an existing mailbox, or an empty string |
85 | */ |
86 | void setMailBox( const QString &mailBox ); |
87 | /** |
88 | * The mailbox that will be acted upon. |
89 | * |
90 | * If this is an empty string, server metadata will be retrieved. |
91 | * |
92 | * @return a mailbox name, or an empty string |
93 | */ |
94 | QString mailBox() const; |
95 | |
96 | /** |
97 | * Set what version of the metadata extension to be compatible with. |
98 | * |
99 | * This will determine the commands that will be sent to the server. |
100 | * |
101 | * The draft for the metadata extension changed in an incompatible |
102 | * way between versions 7 and 8, and some servers support version 7. |
103 | * It should be possible to check which version the server supports |
104 | * using CapabilityJob: servers implementing |
105 | * draft-daboo-imap-annotatemore-07 should advertise the |
106 | * ANNOTATEMORE capability, whereas servers implementing the final |
107 | * RFC 5464 should advertise the METADATA capability. |
108 | * |
109 | * The default mode is Metadata. |
110 | * |
111 | * @param capability the version of the extension implemented by the server |
112 | */ |
113 | void setServerCapability( const ServerCapability &capability ); |
114 | /** |
115 | * The version of the metadata extension that will be used. |
116 | */ |
117 | ServerCapability serverCapability() const; |
118 | |
119 | protected: |
120 | MetaDataJobBase( JobPrivate &dd ); |
121 | |
122 | }; |
123 | |
124 | } |
125 | |
126 | #endif |
127 | |