-rw-r--r-- | libkcal/scheduler.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libkcal/scheduler.cpp b/libkcal/scheduler.cpp index 253d8b7..234cfcf 100644 --- a/libkcal/scheduler.cpp +++ b/libkcal/scheduler.cpp | |||
@@ -1,55 +1,57 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <qdir.h> | 21 | #include <qdir.h> |
22 | #include <qfile.h> | 22 | #include <qfile.h> |
23 | #include <qtextstream.h> | 23 | #include <q3textstream.h> |
24 | //Added by qt3to4: | ||
25 | #include <Q3PtrList> | ||
24 | 26 | ||
25 | #include <klocale.h> | 27 | #include <klocale.h> |
26 | #include <kdebug.h> | 28 | #include <kdebug.h> |
27 | #include <kstandarddirs.h> | 29 | #include <kstandarddirs.h> |
28 | 30 | ||
29 | #include "event.h" | 31 | #include "event.h" |
30 | #include "todo.h" | 32 | #include "todo.h" |
31 | #include "freebusy.h" | 33 | #include "freebusy.h" |
32 | #include "icalformat.h" | 34 | #include "icalformat.h" |
33 | #include "calendar.h" | 35 | #include "calendar.h" |
34 | 36 | ||
35 | #include "scheduler.h" | 37 | #include "scheduler.h" |
36 | 38 | ||
37 | using namespace KCal; | 39 | using namespace KCal; |
38 | 40 | ||
39 | ScheduleMessage::ScheduleMessage(IncidenceBase *incidence,int method,ScheduleMessage::Status status) | 41 | ScheduleMessage::ScheduleMessage(IncidenceBase *incidence,int method,ScheduleMessage::Status status) |
40 | { | 42 | { |
41 | mIncidence = incidence; | 43 | mIncidence = incidence; |
42 | mMethod = method; | 44 | mMethod = method; |
43 | mStatus = status; | 45 | mStatus = status; |
44 | } | 46 | } |
45 | 47 | ||
46 | QString ScheduleMessage::statusName(ScheduleMessage::Status status) | 48 | QString ScheduleMessage::statusName(ScheduleMessage::Status status) |
47 | { | 49 | { |
48 | switch (status) { | 50 | switch (status) { |
49 | case PublishNew: | 51 | case PublishNew: |
50 | return i18n("Publish"); | 52 | return i18n("Publish"); |
51 | case Obsolete: | 53 | case Obsolete: |
52 | return i18n("Obsolete"); | 54 | return i18n("Obsolete"); |
53 | case RequestNew: | 55 | case RequestNew: |
54 | return i18n("New Request"); | 56 | return i18n("New Request"); |
55 | case RequestUpdate: | 57 | case RequestUpdate: |
@@ -235,66 +237,66 @@ bool Scheduler::acceptCancel(IncidenceBase *incidence,ScheduleMessage::Status st | |||
235 | if (todo) { | 237 | if (todo) { |
236 | mCalendar->deleteTodo(todo); | 238 | mCalendar->deleteTodo(todo); |
237 | ret = true; | 239 | ret = true; |
238 | } | 240 | } |
239 | } | 241 | } |
240 | deleteTransaction(incidence); | 242 | deleteTransaction(incidence); |
241 | return ret; | 243 | return ret; |
242 | } | 244 | } |
243 | 245 | ||
244 | bool Scheduler::acceptDeclineCounter(IncidenceBase *incidence,ScheduleMessage::Status status) | 246 | bool Scheduler::acceptDeclineCounter(IncidenceBase *incidence,ScheduleMessage::Status status) |
245 | { | 247 | { |
246 | deleteTransaction(incidence); | 248 | deleteTransaction(incidence); |
247 | return false; | 249 | return false; |
248 | } | 250 | } |
249 | 251 | ||
250 | //bool Scheduler::acceptFreeBusy(Incidence *incidence,ScheduleMessage::Status status) | 252 | //bool Scheduler::acceptFreeBusy(Incidence *incidence,ScheduleMessage::Status status) |
251 | //{ | 253 | //{ |
252 | // deleteTransaction(incidence); | 254 | // deleteTransaction(incidence); |
253 | // return false; | 255 | // return false; |
254 | //} | 256 | //} |
255 | 257 | ||
256 | bool Scheduler::acceptReply(IncidenceBase *incidence,ScheduleMessage::Status status, Method method) | 258 | bool Scheduler::acceptReply(IncidenceBase *incidence,ScheduleMessage::Status status, Method method) |
257 | { | 259 | { |
258 | if(incidence->type()=="FreeBusy") { | 260 | if(incidence->type()=="FreeBusy") { |
259 | return acceptFreeBusy(incidence, method); | 261 | return acceptFreeBusy(incidence, method); |
260 | } | 262 | } |
261 | bool ret = false; | 263 | bool ret = false; |
262 | Event *ev = mCalendar->event(incidence->uid()); | 264 | Event *ev = mCalendar->event(incidence->uid()); |
263 | Todo *to = mCalendar->todo(incidence->uid()); | 265 | Todo *to = mCalendar->todo(incidence->uid()); |
264 | if (ev || to) { | 266 | if (ev || to) { |
265 | //get matching attendee in calendar | 267 | //get matching attendee in calendar |
266 | kdDebug(5800) << "Scheduler::acceptTransaction match found!" << endl; | 268 | kdDebug(5800) << "Scheduler::acceptTransaction match found!" << endl; |
267 | QPtrList<Attendee> attendeesIn = incidence->attendees(); | 269 | Q3PtrList<Attendee> attendeesIn = incidence->attendees(); |
268 | QPtrList<Attendee> attendeesEv; | 270 | Q3PtrList<Attendee> attendeesEv; |
269 | if (ev) attendeesEv = ev->attendees(); | 271 | if (ev) attendeesEv = ev->attendees(); |
270 | if (to) attendeesEv = to->attendees(); | 272 | if (to) attendeesEv = to->attendees(); |
271 | Attendee *attIn; | 273 | Attendee *attIn; |
272 | Attendee *attEv; | 274 | Attendee *attEv; |
273 | for ( attIn = attendeesIn.first(); attIn; attIn = attendeesIn.next() ) { | 275 | for ( attIn = attendeesIn.first(); attIn; attIn = attendeesIn.next() ) { |
274 | for ( attEv = attendeesEv.first(); attEv; attEv = attendeesEv.next() ) { | 276 | for ( attEv = attendeesEv.first(); attEv; attEv = attendeesEv.next() ) { |
275 | if (attIn->email()==attEv->email()) { | 277 | if (attIn->email()==attEv->email()) { |
276 | //update attendee-info | 278 | //update attendee-info |
277 | kdDebug(5800) << "Scheduler::acceptTransaction update attendee" << endl; | 279 | kdDebug(5800) << "Scheduler::acceptTransaction update attendee" << endl; |
278 | attEv->setStatus(attIn->status()); | 280 | attEv->setStatus(attIn->status()); |
279 | attEv->setRSVP(false); | 281 | attEv->setRSVP(false); |
280 | // better to not update the sequence number with replys | 282 | // better to not update the sequence number with replys |
281 | //if (ev) ev->setRevision(ev->revision()+1); | 283 | //if (ev) ev->setRevision(ev->revision()+1); |
282 | //if (to) to->setRevision(to->revision()+1); | 284 | //if (to) to->setRevision(to->revision()+1); |
283 | ret = true; | 285 | ret = true; |
284 | } | 286 | } |
285 | } | 287 | } |
286 | } | 288 | } |
287 | } | 289 | } |
288 | if (ret) deleteTransaction(incidence); | 290 | if (ret) deleteTransaction(incidence); |
289 | return ret; | 291 | return ret; |
290 | } | 292 | } |
291 | 293 | ||
292 | bool Scheduler::acceptRefresh(IncidenceBase *incidence,ScheduleMessage::Status status) | 294 | bool Scheduler::acceptRefresh(IncidenceBase *incidence,ScheduleMessage::Status status) |
293 | { | 295 | { |
294 | // handled in korganizer's IncomingDialog | 296 | // handled in korganizer's IncomingDialog |
295 | deleteTransaction(incidence); | 297 | deleteTransaction(incidence); |
296 | return false; | 298 | return false; |
297 | } | 299 | } |
298 | 300 | ||
299 | bool Scheduler::acceptCounter(IncidenceBase *incidence,ScheduleMessage::Status status) | 301 | bool Scheduler::acceptCounter(IncidenceBase *incidence,ScheduleMessage::Status status) |
300 | { | 302 | { |
@@ -313,43 +315,43 @@ bool Scheduler::acceptFreeBusy(IncidenceBase *incidence, Method method) | |||
313 | if(method == Scheduler::Publish) { | 315 | if(method == Scheduler::Publish) { |
314 | from = freebusy->organizer(); | 316 | from = freebusy->organizer(); |
315 | } | 317 | } |
316 | if((method == Scheduler::Reply) && (freebusy->attendeeCount() == 1)) { | 318 | if((method == Scheduler::Reply) && (freebusy->attendeeCount() == 1)) { |
317 | Attendee *attendee = freebusy->attendees().first(); | 319 | Attendee *attendee = freebusy->attendees().first(); |
318 | from = attendee->email(); | 320 | from = attendee->email(); |
319 | } | 321 | } |
320 | 322 | ||
321 | QDir freeBusyDir(freeBusyDirName); | 323 | QDir freeBusyDir(freeBusyDirName); |
322 | if (!freeBusyDir.exists()) { | 324 | if (!freeBusyDir.exists()) { |
323 | kdDebug() << "Directory " << freeBusyDirName << " does not exist!" << endl; | 325 | kdDebug() << "Directory " << freeBusyDirName << " does not exist!" << endl; |
324 | kdDebug() << "Creating directory: " << freeBusyDirName << endl; | 326 | kdDebug() << "Creating directory: " << freeBusyDirName << endl; |
325 | 327 | ||
326 | if(!freeBusyDir.mkdir(freeBusyDirName, TRUE)) { | 328 | if(!freeBusyDir.mkdir(freeBusyDirName, TRUE)) { |
327 | kdDebug() << "Could not create directory: " << freeBusyDirName << endl; | 329 | kdDebug() << "Could not create directory: " << freeBusyDirName << endl; |
328 | return false; | 330 | return false; |
329 | } | 331 | } |
330 | } | 332 | } |
331 | 333 | ||
332 | QString filename(freeBusyDirName); | 334 | QString filename(freeBusyDirName); |
333 | filename += "/"; | 335 | filename += "/"; |
334 | filename += from; | 336 | filename += from; |
335 | filename += ".ifb"; | 337 | filename += ".ifb"; |
336 | QFile f(filename); | 338 | QFile f(filename); |
337 | 339 | ||
338 | kdDebug() << "acceptFreeBusy: filename" << filename << endl; | 340 | kdDebug() << "acceptFreeBusy: filename" << filename << endl; |
339 | 341 | ||
340 | freebusy->clearAttendees(); | 342 | freebusy->clearAttendees(); |
341 | freebusy->setOrganizer(from); | 343 | freebusy->setOrganizer(from); |
342 | 344 | ||
343 | QString messageText = mFormat->createScheduleMessage(freebusy, Publish); | 345 | QString messageText = mFormat->createScheduleMessage(freebusy, Publish); |
344 | 346 | ||
345 | if (!f.open(IO_ReadWrite)) { | 347 | if (!f.open(QIODevice::ReadWrite)) { |
346 | kdDebug() << "acceptFreeBusy: Can't open:" << filename << " for writing" << endl; | 348 | kdDebug() << "acceptFreeBusy: Can't open:" << filename << " for writing" << endl; |
347 | return false; | 349 | return false; |
348 | } | 350 | } |
349 | QTextStream t(&f); | 351 | Q3TextStream t(&f); |
350 | t << messageText; | 352 | t << messageText; |
351 | f.close(); | 353 | f.close(); |
352 | 354 | ||
353 | deleteTransaction(incidence); | 355 | deleteTransaction(incidence); |
354 | return true; | 356 | return true; |
355 | } | 357 | } |