1 | /* |
2 | This file is part of the kcal library. |
3 | |
4 | Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org> |
5 | |
6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. |
10 | |
11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. |
15 | |
16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 | Boston, MA 02110-1301, USA. |
20 | */ |
21 | #ifndef KCAL_SCHEDULER_H |
22 | #define KCAL_SCHEDULER_H |
23 | |
24 | #include "kcal_export.h" |
25 | |
26 | #include <QtCore/QString> |
27 | #include <QtCore/QList> |
28 | |
29 | namespace KCal { |
30 | |
31 | /** |
32 | iTIP methods. |
33 | */ |
34 | enum iTIPMethod { |
35 | iTIPPublish, /**< Event, to-do, journal or freebusy posting */ |
36 | iTIPRequest, /**< Event, to-do or freebusy scheduling request */ |
37 | iTIPReply, /**< Event, to-do or freebusy reply to request */ |
38 | iTIPAdd, /**< Event, to-do or journal additional property request */ |
39 | iTIPCancel, /**< Event, to-do or journal cancellation notice */ |
40 | iTIPRefresh, /**< Event or to-do description update request */ |
41 | iTIPCounter, /**< Event or to-do submit counter proposal */ |
42 | iTIPDeclineCounter,/**< Event or to-do decline a counter proposal */ |
43 | iTIPNoMethod /**< No method */ |
44 | }; |
45 | |
46 | class IncidenceBase; |
47 | class Calendar; |
48 | class ICalFormat; |
49 | class FreeBusyCache; |
50 | |
51 | /** |
52 | @brief |
53 | A Scheduling message class. |
54 | |
55 | This class provides an encapsulation of a scheduling message. |
56 | It associates an incidence with an iTIPMethod and status information. |
57 | */ |
58 | class KCAL_DEPRECATED_EXPORT ScheduleMessage |
59 | { |
60 | public: |
61 | /** |
62 | Message status. |
63 | */ |
64 | enum Status { |
65 | PublishNew, /**< New message posting */ |
66 | PublishUpdate, /**< Updated message */ |
67 | Obsolete, /**< obsolete */ |
68 | RequestNew, /**< Request new message posting */ |
69 | RequestUpdate, /**< Request updated message */ |
70 | Unknown /**< No status */ |
71 | }; |
72 | |
73 | /** |
74 | Creates a scheduling message with method as defined in iTIPMethod |
75 | and a status. |
76 | */ |
77 | ScheduleMessage( IncidenceBase *incidence, iTIPMethod method, Status status ); |
78 | |
79 | /** |
80 | Destructor. |
81 | */ |
82 | ~ScheduleMessage(); |
83 | |
84 | /** |
85 | Returns the event associated with this message. |
86 | */ |
87 | IncidenceBase *event(); |
88 | |
89 | /** |
90 | Returns the iTIP method associated with this message. |
91 | */ |
92 | iTIPMethod method(); |
93 | |
94 | /** |
95 | Returns the status of this message. |
96 | */ |
97 | Status status(); |
98 | |
99 | /** |
100 | Returns a human-readable name for an iTIP message status. |
101 | */ |
102 | static QString statusName( Status status ); |
103 | |
104 | /** |
105 | Returns the error message if there is any. |
106 | */ |
107 | QString error(); |
108 | |
109 | private: |
110 | Q_DISABLE_COPY( ScheduleMessage ) |
111 | class Private; |
112 | Private *const d; |
113 | }; |
114 | |
115 | /** |
116 | This class provides an encapsulation of iTIP transactions (RFC 2446). |
117 | It is an abstract base class for inheritance by implementations of the |
118 | iTIP scheme like iMIP or iRIP. |
119 | */ |
120 | class KCAL_DEPRECATED_EXPORT Scheduler |
121 | { |
122 | public: |
123 | /** |
124 | Creates a scheduler for calendar specified as argument. |
125 | */ |
126 | explicit Scheduler( Calendar *calendar ); |
127 | virtual ~Scheduler(); |
128 | |
129 | /** |
130 | iTIP publish action |
131 | */ |
132 | virtual bool publish( IncidenceBase *incidence, |
133 | const QString &recipients ) = 0; |
134 | /** |
135 | Performs iTIP transaction on incidence. The method is specified as the |
136 | method argument and can be any valid iTIP method. |
137 | |
138 | @param incidence the incidence for the transaction. |
139 | @param method the iTIP transaction method to use. |
140 | */ |
141 | virtual bool performTransaction( IncidenceBase *incidence, |
142 | iTIPMethod method ) = 0; |
143 | |
144 | /** |
145 | Performs iTIP transaction on incidence to specified recipient(s). The |
146 | method is specified as the method argumanet and can be any valid iTIP |
147 | method. |
148 | |
149 | @param incidence the incidence for the transaction. |
150 | @param method the iTIP transaction method to use. |
151 | @param recipients the receipients of the transaction. |
152 | */ |
153 | virtual bool performTransaction( IncidenceBase *incidence, |
154 | iTIPMethod method, |
155 | const QString &recipients ) = 0; |
156 | |
157 | /** |
158 | Retrieves incoming iTIP transactions. |
159 | */ |
160 | virtual QList<ScheduleMessage*> retrieveTransactions() = 0; |
161 | |
162 | /** |
163 | @deprecated: Use the other acceptTransaction() instead |
164 | KDE5: Remove me, make email an optional argument in the other overload |
165 | */ |
166 | bool KCAL_DEPRECATED acceptTransaction( IncidenceBase *incidence, iTIPMethod method, |
167 | ScheduleMessage::Status status ); |
168 | |
169 | /** |
170 | Accepts the transaction. The incidence argument specifies the iCal |
171 | component on which the transaction acts. The status is the result of |
172 | processing a iTIP message with the current calendar and specifies the |
173 | action to be taken for this incidence. |
174 | |
175 | @param incidence the incidence for the transaction. |
176 | @param method iTIP transaction method to check. |
177 | @param status scheduling status. |
178 | @param email the email address of the person for whom this |
179 | transaction is to be performed. |
180 | */ |
181 | bool acceptTransaction( IncidenceBase *incidence, |
182 | iTIPMethod method, |
183 | ScheduleMessage::Status status, |
184 | const QString &email ); |
185 | |
186 | /** |
187 | Returns a machine-readable name for a iTIP method. |
188 | */ |
189 | static QString methodName( iTIPMethod method ); |
190 | |
191 | /** |
192 | Returns a translated human-readable name for a iTIP method. |
193 | */ |
194 | static QString translatedMethodName( iTIPMethod method ); |
195 | |
196 | virtual bool deleteTransaction( IncidenceBase *incidence ); |
197 | |
198 | /** |
199 | Returns the directory where the free-busy information is stored. |
200 | */ |
201 | virtual QString freeBusyDir() = 0; |
202 | |
203 | /** |
204 | Sets the free/busy cache used to store free/busy information. |
205 | */ |
206 | void setFreeBusyCache( FreeBusyCache * ); |
207 | |
208 | /** |
209 | Returns the free/busy cache. |
210 | */ |
211 | FreeBusyCache *freeBusyCache() const; |
212 | |
213 | protected: |
214 | bool acceptPublish( IncidenceBase *, ScheduleMessage::Status status, iTIPMethod method ); |
215 | /** |
216 | @deprecated: Use the other overload instead |
217 | KDE5: remove me |
218 | */ |
219 | bool KCAL_DEPRECATED acceptRequest( IncidenceBase *, ScheduleMessage::Status status ); |
220 | bool acceptRequest( IncidenceBase *, ScheduleMessage::Status status, |
221 | const QString &email ); |
222 | bool acceptAdd( IncidenceBase *, ScheduleMessage::Status status ); |
223 | KCAL_DEPRECATED bool acceptCancel( IncidenceBase *, ScheduleMessage::Status status ); |
224 | bool acceptCancel( IncidenceBase *, ScheduleMessage::Status status, |
225 | const QString & attendee ); |
226 | bool acceptDeclineCounter( IncidenceBase *, ScheduleMessage::Status status ); |
227 | bool acceptReply( IncidenceBase *, ScheduleMessage::Status status, iTIPMethod method ); |
228 | bool acceptRefresh( IncidenceBase *, ScheduleMessage::Status status ); |
229 | bool acceptCounter( IncidenceBase *, ScheduleMessage::Status status ); |
230 | bool acceptFreeBusy( IncidenceBase *, iTIPMethod method ); |
231 | |
232 | Calendar *mCalendar; |
233 | ICalFormat *mFormat; |
234 | |
235 | private: |
236 | Q_DISABLE_COPY( Scheduler ) |
237 | struct Private; |
238 | Private *const d; |
239 | }; |
240 | |
241 | } |
242 | |
243 | #endif |
244 | |