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_COPYJOB_H |
21 | #define KIMAP_COPYJOB_H |
22 | |
23 | #include "kimap_export.h" |
24 | |
25 | #include "job.h" |
26 | #include "imapset.h" |
27 | |
28 | namespace KIMAP { |
29 | |
30 | class Session; |
31 | struct Message; |
32 | class CopyJobPrivate; |
33 | |
34 | /** |
35 | * Copies one or more messages to another mailbox. |
36 | * |
37 | * This job can only be run when the session is in the selected state. |
38 | * |
39 | * If the server supports ACLs, the user will need the |
40 | * Acl::Insert right on the target mailbox. |
41 | * In order to preserve message flags, the user may also need |
42 | * some combination of Acl::DeleteMessage, |
43 | * Acl::KeepSeen and Acl::Write on the |
44 | * target mailbox. |
45 | */ |
46 | class KIMAP_EXPORT CopyJob : public Job |
47 | { |
48 | Q_OBJECT |
49 | Q_DECLARE_PRIVATE( CopyJob ) |
50 | |
51 | friend class SessionPrivate; |
52 | |
53 | public: |
54 | explicit CopyJob( Session *session ); |
55 | virtual ~CopyJob(); |
56 | |
57 | /** |
58 | * Sets the destination mailbox. |
59 | * |
60 | * If the mailbox does not exist, the server should not create |
61 | * it automatically and the job should fail. Note, however, |
62 | * that a conforming server may create the mailbox automatically. |
63 | * |
64 | * @param mailBox the (unquoted) name of the mailbox where the |
65 | * messages should be copied to |
66 | */ |
67 | void setMailBox( const QString &mailBox ); |
68 | /** |
69 | * The destination mailbox |
70 | */ |
71 | QString mailBox() const; |
72 | |
73 | /** |
74 | * Sets the messages to be copied |
75 | * |
76 | * If sequence numbers are given, isUidBased() should be false. If UIDs |
77 | * are given, isUidBased() should be true. |
78 | * |
79 | * RFC 3501 is unclear as to what should happen if invalid sequence numbers |
80 | * are passed. If non-existent UIDs are passed, they will be ignored. |
81 | * |
82 | * @param set the sequence numbers or UIDs of the messages to be copied |
83 | */ |
84 | void setSequenceSet( const ImapSet &set ); |
85 | /** |
86 | * The messages that will be copied. |
87 | * |
88 | * isUidBased() can be used to check whether the ImapSet contains |
89 | * sequence numbers or UIDs. |
90 | * |
91 | * @return the sequence numbers or UIDs of the messages to be copied |
92 | */ |
93 | ImapSet sequenceSet() const; |
94 | |
95 | /** |
96 | * Set how the sequence set should be interpreted. |
97 | * |
98 | * @param uidBased if @c true the argument to setSequenceSet will be |
99 | * interpreted as UIDs, if @c false it will be interpreted |
100 | * as sequence numbers |
101 | */ |
102 | void setUidBased( bool uidBased ); |
103 | /** |
104 | * How to interpret the sequence set. |
105 | * |
106 | * @return if @c true the result of sequenceSet() should be |
107 | * interpreted as UIDs, if @c false it should be interpreted |
108 | * as sequence numbers |
109 | */ |
110 | bool isUidBased() const; |
111 | |
112 | /** |
113 | * The UIDs of the new copies of the messages |
114 | * |
115 | * This will be an empty set if no messages have been copied yet |
116 | * or if the server does not support the UIDPLUS extension. |
117 | */ |
118 | ImapSet resultingUids() const; |
119 | |
120 | protected: |
121 | virtual void doStart(); |
122 | virtual void handleResponse(const Message &response); |
123 | }; |
124 | |
125 | } |
126 | |
127 | #endif |
128 | |