summaryrefslogtreecommitdiffabout
path: root/libkcal/icalformatimpl.cpp
Unidiff
Diffstat (limited to 'libkcal/icalformatimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/icalformatimpl.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index 65eabc8..ea144ee 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -1,72 +1,75 @@
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 <qdatetime.h> 21#include <qdatetime.h>
22#include <qstring.h> 22#include <qstring.h>
23#include <qptrlist.h> 23#include <q3ptrlist.h>
24#include <qfile.h> 24#include <qfile.h>
25//Added by qt3to4:
26#include <Q3ValueList>
27#include <Q3CString>
25 28
26#include <kdebug.h> 29#include <kdebug.h>
27#include <klocale.h> 30#include <klocale.h>
28#include <kglobal.h> 31#include <kglobal.h>
29 32
30extern "C" { 33extern "C" {
31 #include <ical.h> 34 #include <ical.h>
32 #include <icalss.h> 35 #include <icalss.h>
33 #include <icalparser.h> 36 #include <icalparser.h>
34 #include <icalrestriction.h> 37 #include <icalrestriction.h>
35} 38}
36 39
37#include "calendar.h" 40#include "calendar.h"
38#include "journal.h" 41#include "journal.h"
39#include "icalformat.h" 42#include "icalformat.h"
40#include "icalformatimpl.h" 43#include "icalformatimpl.h"
41#include "compat.h" 44#include "compat.h"
42 45
43#define _ICAL_VERSION "2.0" 46#define _ICAL_VERSION "2.0"
44 47
45using namespace KCal; 48using namespace KCal;
46 49
47const int gSecondsPerMinute = 60; 50const int gSecondsPerMinute = 60;
48const int gSecondsPerHour = gSecondsPerMinute * 60; 51const int gSecondsPerHour = gSecondsPerMinute * 60;
49const int gSecondsPerDay = gSecondsPerHour * 24; 52const int gSecondsPerDay = gSecondsPerHour * 24;
50const int gSecondsPerWeek = gSecondsPerDay * 7; 53const int gSecondsPerWeek = gSecondsPerDay * 7;
51 54
52ICalFormatImpl::ICalFormatImpl( ICalFormat *parent ) : 55ICalFormatImpl::ICalFormatImpl( ICalFormat *parent ) :
53 mParent( parent ), mCalendarVersion( 0 ) 56 mParent( parent ), mCalendarVersion( 0 )
54{ 57{
55 mCompat = new Compat; 58 mCompat = new Compat;
56} 59}
57 60
58ICalFormatImpl::~ICalFormatImpl() 61ICalFormatImpl::~ICalFormatImpl()
59{ 62{
60 delete mCompat; 63 delete mCompat;
61} 64}
62 65
63class ToStringVisitor : public Incidence::Visitor 66class ToStringVisitor : public Incidence::Visitor
64{ 67{
65 public: 68 public:
66 ToStringVisitor( ICalFormatImpl *impl ) : mImpl( impl ), mComponent( 0 ) {} 69 ToStringVisitor( ICalFormatImpl *impl ) : mImpl( impl ), mComponent( 0 ) {}
67 70
68 bool visit( Event *e ) { mComponent = mImpl->writeEvent( e ); return true; } 71 bool visit( Event *e ) { mComponent = mImpl->writeEvent( e ); return true; }
69 bool visit( Todo *e ) { mComponent = mImpl->writeTodo( e ); return true; } 72 bool visit( Todo *e ) { mComponent = mImpl->writeTodo( e ); return true; }
70 bool visit( Journal *e ) { mComponent = mImpl->writeJournal( e ); return true; } 73 bool visit( Journal *e ) { mComponent = mImpl->writeJournal( e ); return true; }
71 74
72 icalcomponent *component() { return mComponent; } 75 icalcomponent *component() { return mComponent; }
@@ -176,98 +179,98 @@ icalcomponent *ICalFormatImpl::writeEvent(Event *event)
176 tmpStrList = anEvent->attachments(); 179 tmpStrList = anEvent->attachments();
177 for ( QStringList::Iterator it = tmpStrList.begin(); 180 for ( QStringList::Iterator it = tmpStrList.begin();
178 it != tmpStrList.end(); 181 it != tmpStrList.end();
179 ++it ) 182 ++it )
180 addPropValue(vevent, VCAttachProp, (*it).utf8()); 183 addPropValue(vevent, VCAttachProp, (*it).utf8());
181 184
182 // resources 185 // resources
183 tmpStrList = anEvent->resources(); 186 tmpStrList = anEvent->resources();
184 tmpStr = tmpStrList.join(";"); 187 tmpStr = tmpStrList.join(";");
185 if (!tmpStr.isEmpty()) 188 if (!tmpStr.isEmpty())
186 addPropValue(vevent, VCResourcesProp, tmpStr.utf8()); 189 addPropValue(vevent, VCResourcesProp, tmpStr.utf8());
187 190
188#endif 191#endif
189 192
190 // Transparency 193 // Transparency
191 switch( event->transparency() ) { 194 switch( event->transparency() ) {
192 case Event::Transparent: 195 case Event::Transparent:
193 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT)); 196 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT));
194 break; 197 break;
195 case Event::Opaque: 198 case Event::Opaque:
196 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE)); 199 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE));
197 break; 200 break;
198 } 201 }
199 202
200 return vevent; 203 return vevent;
201} 204}
202 205
203icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, 206icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy,
204 Scheduler::Method method) 207 Scheduler::Method method)
205{ 208{
206 209
207 210
208 icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT); 211 icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT);
209 212
210 writeIncidenceBase(vfreebusy,freebusy); 213 writeIncidenceBase(vfreebusy,freebusy);
211 214
212 icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart( 215 icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart(
213 writeICalDateTime(freebusy->dtStart()))); 216 writeICalDateTime(freebusy->dtStart())));
214 217
215 icalcomponent_add_property(vfreebusy, icalproperty_new_dtend( 218 icalcomponent_add_property(vfreebusy, icalproperty_new_dtend(
216 writeICalDateTime(freebusy->dtEnd()))); 219 writeICalDateTime(freebusy->dtEnd())));
217 220
218 if (method == Scheduler::Request) { 221 if (method == Scheduler::Request) {
219 icalcomponent_add_property(vfreebusy,icalproperty_new_uid( 222 icalcomponent_add_property(vfreebusy,icalproperty_new_uid(
220 freebusy->uid().utf8())); 223 freebusy->uid().utf8()));
221 } 224 }
222 225
223 //Loops through all the periods in the freebusy object 226 //Loops through all the periods in the freebusy object
224 QValueList<Period> list = freebusy->busyPeriods(); 227 Q3ValueList<Period> list = freebusy->busyPeriods();
225 QValueList<Period>::Iterator it; 228 Q3ValueList<Period>::Iterator it;
226 icalperiodtype period; 229 icalperiodtype period;
227 for (it = list.begin(); it!= list.end(); ++it) { 230 for (it = list.begin(); it!= list.end(); ++it) {
228 period.start = writeICalDateTime((*it).start()); 231 period.start = writeICalDateTime((*it).start());
229 period.end = writeICalDateTime((*it).end()); 232 period.end = writeICalDateTime((*it).end());
230 icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) ); 233 icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) );
231 } 234 }
232 235
233 return vfreebusy; 236 return vfreebusy;
234} 237}
235 238
236icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) 239icalcomponent *ICalFormatImpl::writeJournal(Journal *journal)
237{ 240{
238 icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT); 241 icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT);
239 242
240 writeIncidence(vjournal,journal); 243 writeIncidence(vjournal,journal);
241 244
242 // start time 245 // start time
243 if (journal->dtStart().isValid()) { 246 if (journal->dtStart().isValid()) {
244 icaltimetype start; 247 icaltimetype start;
245 if (journal->doesFloat()) { 248 if (journal->doesFloat()) {
246// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; 249// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl;
247 start = writeICalDate(journal->dtStart().date()); 250 start = writeICalDate(journal->dtStart().date());
248 } else { 251 } else {
249// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; 252// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl;
250 start = writeICalDateTime(journal->dtStart()); 253 start = writeICalDateTime(journal->dtStart());
251 } 254 }
252 icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start)); 255 icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start));
253 } 256 }
254 257
255 return vjournal; 258 return vjournal;
256} 259}
257 260
258void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) 261void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
259{ 262{
260 // pilot sync stuff 263 // pilot sync stuff
261// TODO: move this application-specific code to kpilot 264// TODO: move this application-specific code to kpilot
262 if (incidence->pilotId()) { 265 if (incidence->pilotId()) {
263 incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId())); 266 incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId()));
264 incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus())); 267 incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus()));
265 } 268 }
266 if ( !incidence->IDStr().isEmpty()) { 269 if ( !incidence->IDStr().isEmpty()) {
267 incidence->setNonKDECustomProperty("X-KOPIEXTID",incidence->IDStr() ); 270 incidence->setNonKDECustomProperty("X-KOPIEXTID",incidence->IDStr() );
268 } 271 }
269 272
270 273
271 writeIncidenceBase(parent,incidence); 274 writeIncidenceBase(parent,incidence);
272 if (incidence->cancelled()) { 275 if (incidence->cancelled()) {
273 icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED)); 276 icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED));
@@ -339,150 +342,150 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
339 icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); 342 icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8()));
340 } 343 }
341// TODO: Ensure correct concatenation of categories properties. 344// TODO: Ensure correct concatenation of categories properties.
342 345
343/* 346/*
344 // categories 347 // categories
345 tmpStrList = incidence->getCategories(); 348 tmpStrList = incidence->getCategories();
346 tmpStr = ""; 349 tmpStr = "";
347 QString catStr; 350 QString catStr;
348 for ( QStringList::Iterator it = tmpStrList.begin(); 351 for ( QStringList::Iterator it = tmpStrList.begin();
349 it != tmpStrList.end(); 352 it != tmpStrList.end();
350 ++it ) { 353 ++it ) {
351 catStr = *it; 354 catStr = *it;
352 if (catStr[0] == ' ') 355 if (catStr[0] == ' ')
353 tmpStr += catStr.mid(1); 356 tmpStr += catStr.mid(1);
354 else 357 else
355 tmpStr += catStr; 358 tmpStr += catStr;
356 // this must be a ';' character as the vCalendar specification requires! 359 // this must be a ';' character as the vCalendar specification requires!
357 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 360 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
358 // read in. 361 // read in.
359 tmpStr += ";"; 362 tmpStr += ";";
360 } 363 }
361 if (!tmpStr.isEmpty()) { 364 if (!tmpStr.isEmpty()) {
362 tmpStr.truncate(tmpStr.length()-1); 365 tmpStr.truncate(tmpStr.length()-1);
363 icalcomponent_add_property(parent,icalproperty_new_categories( 366 icalcomponent_add_property(parent,icalproperty_new_categories(
364 writeText(incidence->getCategories().join(";")))); 367 writeText(incidence->getCategories().join(";"))));
365 } 368 }
366*/ 369*/
367 370
368 // related event 371 // related event
369 if (!incidence->relatedToUid().isEmpty()) { 372 if (!incidence->relatedToUid().isEmpty()) {
370 icalcomponent_add_property(parent,icalproperty_new_relatedto( 373 icalcomponent_add_property(parent,icalproperty_new_relatedto(
371 incidence->relatedToUid().utf8())); 374 incidence->relatedToUid().utf8()));
372 } 375 }
373 376
374 // recurrence rule stuff 377 // recurrence rule stuff
375 if (incidence->doesRecur()) { 378 if (incidence->doesRecur()) {
376 icalcomponent_add_property(parent,writeRecurrenceRule(incidence->recurrence())); 379 icalcomponent_add_property(parent,writeRecurrenceRule(incidence->recurrence()));
377 // recurrence excpetion dates 380 // recurrence excpetion dates
378 DateList dateList = incidence->exDates(); 381 DateList dateList = incidence->exDates();
379 DateList::ConstIterator exIt; 382 DateList::ConstIterator exIt;
380 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { 383 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) {
381 icalcomponent_add_property(parent,icalproperty_new_exdate( 384 icalcomponent_add_property(parent,icalproperty_new_exdate(
382 writeICalDate(*exIt))); 385 writeICalDate(*exIt)));
383 } 386 }
384 } 387 }
385 388
386 // attachments 389 // attachments
387 QPtrList<Attachment> attachments = incidence->attachments(); 390 Q3PtrList<Attachment> attachments = incidence->attachments();
388 for (Attachment *at = attachments.first(); at; at = attachments.next()) 391 for (Attachment *at = attachments.first(); at; at = attachments.next())
389 icalcomponent_add_property(parent,writeAttachment(at)); 392 icalcomponent_add_property(parent,writeAttachment(at));
390 393
391 // alarms 394 // alarms
392 QPtrList<Alarm> alarms = incidence->alarms(); 395 Q3PtrList<Alarm> alarms = incidence->alarms();
393 Alarm* alarm; 396 Alarm* alarm;
394 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 397 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
395 if (alarm->enabled()) { 398 if (alarm->enabled()) {
396 kdDebug(5800) << "Write alarm for " << incidence->summary() << endl; 399 kdDebug(5800) << "Write alarm for " << incidence->summary() << endl;
397 icalcomponent_add_component(parent,writeAlarm(alarm)); 400 icalcomponent_add_component(parent,writeAlarm(alarm));
398 } 401 }
399 } 402 }
400 if( incidence->hasRecurrenceID() ) { 403 if( incidence->hasRecurrenceID() ) {
401 icalcomponent_add_property(parent, 404 icalcomponent_add_property(parent,
402 icalproperty_new_recurrenceid( writeICalDateTime( incidence->recurrenceID()))); 405 icalproperty_new_recurrenceid( writeICalDateTime( incidence->recurrenceID())));
403 } 406 }
404 // duration 407 // duration
405 408
406// turned off as it always is set to PTS0 (and must not occur together with DTEND 409// turned off as it always is set to PTS0 (and must not occur together with DTEND
407 410
408 if (incidence->hasDuration()) { 411 if (incidence->hasDuration()) {
409 icaldurationtype duration; 412 icaldurationtype duration;
410 duration = writeICalDuration(incidence->duration()); 413 duration = writeICalDuration(incidence->duration());
411 icalcomponent_add_property(parent,icalproperty_new_duration(duration)); 414 icalcomponent_add_property(parent,icalproperty_new_duration(duration));
412 } 415 }
413} 416}
414 417
415void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) 418void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase)
416{ 419{
417 icalcomponent_add_property(parent,icalproperty_new_dtstamp( 420 icalcomponent_add_property(parent,icalproperty_new_dtstamp(
418 writeICalDateTime(QDateTime::currentDateTime()))); 421 writeICalDateTime(QDateTime::currentDateTime())));
419 422
420 // organizer stuff 423 // organizer stuff
421 icalcomponent_add_property(parent,icalproperty_new_organizer( 424 icalcomponent_add_property(parent,icalproperty_new_organizer(
422 ("MAILTO:" + incidenceBase->organizer()).utf8())); 425 ("MAILTO:" + incidenceBase->organizer()).utf8()));
423 426
424 // attendees 427 // attendees
425 if (incidenceBase->attendeeCount() != 0) { 428 if (incidenceBase->attendeeCount() != 0) {
426 QPtrList<Attendee> al = incidenceBase->attendees(); 429 Q3PtrList<Attendee> al = incidenceBase->attendees();
427 QPtrListIterator<Attendee> ai(al); 430 Q3PtrListIterator<Attendee> ai(al);
428 for (; ai.current(); ++ai) { 431 for (; ai.current(); ++ai) {
429 icalcomponent_add_property(parent,writeAttendee(ai.current())); 432 icalcomponent_add_property(parent,writeAttendee(ai.current()));
430 } 433 }
431 } 434 }
432 435
433 // custom properties 436 // custom properties
434 writeCustomProperties(parent, incidenceBase); 437 writeCustomProperties(parent, incidenceBase);
435} 438}
436 439
437void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties) 440void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties)
438{ 441{
439 QMap<QCString, QString> custom = properties->customProperties(); 442 QMap<Q3CString, QString> custom = properties->customProperties();
440 for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { 443 for (QMap<Q3CString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) {
441 icalproperty *p = icalproperty_new_x(c.data().utf8()); 444 icalproperty *p = icalproperty_new_x(c.data().utf8());
442 icalproperty_set_x_name(p,c.key()); 445 icalproperty_set_x_name(p,c.key());
443 icalcomponent_add_property(parent,p); 446 icalcomponent_add_property(parent,p);
444 } 447 }
445} 448}
446 449
447icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee) 450icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee)
448{ 451{
449 icalproperty *p = icalproperty_new_attendee("mailto:" + attendee->email().utf8()); 452 icalproperty *p = icalproperty_new_attendee("mailto:" + attendee->email().utf8());
450 453
451 if (!attendee->name().isEmpty()) { 454 if (!attendee->name().isEmpty()) {
452 icalproperty_add_parameter(p,icalparameter_new_cn(attendee->name().utf8())); 455 icalproperty_add_parameter(p,icalparameter_new_cn(attendee->name().utf8()));
453 } 456 }
454 457
455 458
456 icalproperty_add_parameter(p,icalparameter_new_rsvp( 459 icalproperty_add_parameter(p,icalparameter_new_rsvp(
457 attendee->RSVP() ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE )); 460 attendee->RSVP() ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE ));
458 461
459 icalparameter_partstat status = ICAL_PARTSTAT_NEEDSACTION; 462 icalparameter_partstat status = ICAL_PARTSTAT_NEEDSACTION;
460 switch (attendee->status()) { 463 switch (attendee->status()) {
461 default: 464 default:
462 case Attendee::NeedsAction: 465 case Attendee::NeedsAction:
463 status = ICAL_PARTSTAT_NEEDSACTION; 466 status = ICAL_PARTSTAT_NEEDSACTION;
464 break; 467 break;
465 case Attendee::Accepted: 468 case Attendee::Accepted:
466 status = ICAL_PARTSTAT_ACCEPTED; 469 status = ICAL_PARTSTAT_ACCEPTED;
467 break; 470 break;
468 case Attendee::Declined: 471 case Attendee::Declined:
469 status = ICAL_PARTSTAT_DECLINED; 472 status = ICAL_PARTSTAT_DECLINED;
470 break; 473 break;
471 case Attendee::Tentative: 474 case Attendee::Tentative:
472 status = ICAL_PARTSTAT_TENTATIVE; 475 status = ICAL_PARTSTAT_TENTATIVE;
473 break; 476 break;
474 case Attendee::Delegated: 477 case Attendee::Delegated:
475 status = ICAL_PARTSTAT_DELEGATED; 478 status = ICAL_PARTSTAT_DELEGATED;
476 break; 479 break;
477 case Attendee::Completed: 480 case Attendee::Completed:
478 status = ICAL_PARTSTAT_COMPLETED; 481 status = ICAL_PARTSTAT_COMPLETED;
479 break; 482 break;
480 case Attendee::InProcess: 483 case Attendee::InProcess:
481 status = ICAL_PARTSTAT_INPROCESS; 484 status = ICAL_PARTSTAT_INPROCESS;
482 break; 485 break;
483 } 486 }
484 icalproperty_add_parameter(p,icalparameter_new_partstat(status)); 487 icalproperty_add_parameter(p,icalparameter_new_partstat(status));
485 488
486 icalparameter_role role = ICAL_ROLE_REQPARTICIPANT; 489 icalparameter_role role = ICAL_ROLE_REQPARTICIPANT;
487 switch (attendee->role()) { 490 switch (attendee->role()) {
488 case Attendee::Chair: 491 case Attendee::Chair:
@@ -501,98 +504,98 @@ icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee)
501 } 504 }
502 icalproperty_add_parameter(p,icalparameter_new_role(role)); 505 icalproperty_add_parameter(p,icalparameter_new_role(role));
503 506
504 if (!attendee->uid().isEmpty()) { 507 if (!attendee->uid().isEmpty()) {
505 icalparameter* icalparameter_uid = icalparameter_new_x(attendee->uid().utf8()); 508 icalparameter* icalparameter_uid = icalparameter_new_x(attendee->uid().utf8());
506 icalparameter_set_xname(icalparameter_uid,"X-UID"); 509 icalparameter_set_xname(icalparameter_uid,"X-UID");
507 icalproperty_add_parameter(p,icalparameter_uid); 510 icalproperty_add_parameter(p,icalparameter_uid);
508 } 511 }
509 512
510 return p; 513 return p;
511} 514}
512 515
513icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) 516icalproperty *ICalFormatImpl::writeAttachment(Attachment *att)
514{ 517{
515#if 0 518#if 0
516 icalattachtype* attach = icalattachtype_new(); 519 icalattachtype* attach = icalattachtype_new();
517 if (att->isUri()) 520 if (att->isUri())
518 icalattachtype_set_url(attach, att->uri().utf8().data()); 521 icalattachtype_set_url(attach, att->uri().utf8().data());
519 else 522 else
520 icalattachtype_set_base64(attach, att->data(), 0); 523 icalattachtype_set_base64(attach, att->data(), 0);
521#endif 524#endif
522 icalattach *attach; 525 icalattach *attach;
523 if (att->isUri()) 526 if (att->isUri())
524 attach = icalattach_new_from_url( att->uri().utf8().data()); 527 attach = icalattach_new_from_url( att->uri().utf8().data());
525 else 528 else
526 attach = icalattach_new_from_data ( (unsigned char *)att->data(), 0, 0); 529 attach = icalattach_new_from_data ( (unsigned char *)att->data(), 0, 0);
527 icalproperty *p = icalproperty_new_attach(attach); 530 icalproperty *p = icalproperty_new_attach(attach);
528 if (!att->mimeType().isEmpty()) 531 if (!att->mimeType().isEmpty())
529 icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data())); 532 icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data()));
530 533
531 if (att->isBinary()) { 534 if (att->isBinary()) {
532 icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY)); 535 icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY));
533 icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64)); 536 icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64));
534 } 537 }
535 return p; 538 return p;
536} 539}
537 540
538icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur) 541icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur)
539{ 542{
540// kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl; 543// kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl;
541 544
542 icalrecurrencetype r; 545 icalrecurrencetype r;
543 546
544 icalrecurrencetype_clear(&r); 547 icalrecurrencetype_clear(&r);
545 548
546 int index = 0; 549 int index = 0;
547 int index2 = 0; 550 int index2 = 0;
548 551
549 QPtrList<Recurrence::rMonthPos> tmpPositions; 552 Q3PtrList<Recurrence::rMonthPos> tmpPositions;
550 QPtrList<int> tmpDays; 553 Q3PtrList<int> tmpDays;
551 int *tmpDay; 554 int *tmpDay;
552 Recurrence::rMonthPos *tmpPos; 555 Recurrence::rMonthPos *tmpPos;
553 bool datetime = false; 556 bool datetime = false;
554 int day; 557 int day;
555 int i; 558 int i;
556 559
557 switch(recur->doesRecur()) { 560 switch(recur->doesRecur()) {
558 case Recurrence::rMinutely: 561 case Recurrence::rMinutely:
559 r.freq = ICAL_MINUTELY_RECURRENCE; 562 r.freq = ICAL_MINUTELY_RECURRENCE;
560 datetime = true; 563 datetime = true;
561 break; 564 break;
562 case Recurrence::rHourly: 565 case Recurrence::rHourly:
563 r.freq = ICAL_HOURLY_RECURRENCE; 566 r.freq = ICAL_HOURLY_RECURRENCE;
564 datetime = true; 567 datetime = true;
565 break; 568 break;
566 case Recurrence::rDaily: 569 case Recurrence::rDaily:
567 r.freq = ICAL_DAILY_RECURRENCE; 570 r.freq = ICAL_DAILY_RECURRENCE;
568 break; 571 break;
569 case Recurrence::rWeekly: 572 case Recurrence::rWeekly:
570 r.freq = ICAL_WEEKLY_RECURRENCE; 573 r.freq = ICAL_WEEKLY_RECURRENCE;
571 r.week_start = static_cast<icalrecurrencetype_weekday>(recur->weekStart()%7 + 1); 574 r.week_start = static_cast<icalrecurrencetype_weekday>(recur->weekStart()%7 + 1);
572 for (i = 0; i < 7; i++) { 575 for (i = 0; i < 7; i++) {
573 if (recur->days().testBit(i)) { 576 if (recur->days().testBit(i)) {
574 day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 577 day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1
575 r.by_day[index++] = icalrecurrencetype_day_day_of_week(day); 578 r.by_day[index++] = icalrecurrencetype_day_day_of_week(day);
576 } 579 }
577 } 580 }
578// r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; 581// r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX;
579 break; 582 break;
580 case Recurrence::rMonthlyPos: 583 case Recurrence::rMonthlyPos:
581 r.freq = ICAL_MONTHLY_RECURRENCE; 584 r.freq = ICAL_MONTHLY_RECURRENCE;
582 585
583 tmpPositions = recur->monthPositions(); 586 tmpPositions = recur->monthPositions();
584 for (tmpPos = tmpPositions.first(); 587 for (tmpPos = tmpPositions.first();
585 tmpPos; 588 tmpPos;
586 tmpPos = tmpPositions.next()) { 589 tmpPos = tmpPositions.next()) {
587 for (i = 0; i < 7; i++) { 590 for (i = 0; i < 7; i++) {
588 if (tmpPos->rDays.testBit(i)) { 591 if (tmpPos->rDays.testBit(i)) {
589 day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 592 day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1
590 day += tmpPos->rPos*8; 593 day += tmpPos->rPos*8;
591 if (tmpPos->negative) day = -day; 594 if (tmpPos->negative) day = -day;
592 r.by_day[index++] = day; 595 r.by_day[index++] = day;
593 } 596 }
594 } 597 }
595 } 598 }
596// r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; 599// r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX;
597 break; 600 break;
598 case Recurrence::rMonthlyDay: 601 case Recurrence::rMonthlyDay:
@@ -659,157 +662,157 @@ icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur)
659 r.count = 0; 662 r.count = 0;
660 } else { 663 } else {
661 if (datetime) 664 if (datetime)
662 r.until = writeICalDateTime(recur->endDateTime()); 665 r.until = writeICalDateTime(recur->endDateTime());
663 else 666 else
664 r.until = writeICalDate(recur->endDate()); 667 r.until = writeICalDate(recur->endDate());
665 } 668 }
666 669
667// Debug output 670// Debug output
668#if 0 671#if 0
669 const char *str = icalrecurrencetype_as_string(&r); 672 const char *str = icalrecurrencetype_as_string(&r);
670 if (str) { 673 if (str) {
671 kdDebug(5800) << " String: " << str << endl; 674 kdDebug(5800) << " String: " << str << endl;
672 } else { 675 } else {
673 kdDebug(5800) << " No String" << endl; 676 kdDebug(5800) << " No String" << endl;
674 } 677 }
675#endif 678#endif
676 679
677 return icalproperty_new_rrule(r); 680 return icalproperty_new_rrule(r);
678} 681}
679 682
680icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) 683icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm)
681{ 684{
682 icalcomponent *a = icalcomponent_new(ICAL_VALARM_COMPONENT); 685 icalcomponent *a = icalcomponent_new(ICAL_VALARM_COMPONENT);
683 686
684 icalproperty_action action; 687 icalproperty_action action;
685 icalattach *attach = 0; 688 icalattach *attach = 0;
686 689
687 switch (alarm->type()) { 690 switch (alarm->type()) {
688 case Alarm::Procedure: 691 case Alarm::Procedure:
689 action = ICAL_ACTION_PROCEDURE; 692 action = ICAL_ACTION_PROCEDURE;
690 attach = icalattach_new_from_url( QFile::encodeName(alarm->programFile()).data() ); 693 attach = icalattach_new_from_url( QFile::encodeName(alarm->programFile()).data() );
691 icalcomponent_add_property(a,icalproperty_new_attach(attach)); 694 icalcomponent_add_property(a,icalproperty_new_attach(attach));
692 if (!alarm->programArguments().isEmpty()) { 695 if (!alarm->programArguments().isEmpty()) {
693 icalcomponent_add_property(a,icalproperty_new_description(alarm->programArguments().utf8())); 696 icalcomponent_add_property(a,icalproperty_new_description(alarm->programArguments().utf8()));
694 } 697 }
695 icalattach_unref( attach ); 698 icalattach_unref( attach );
696 break; 699 break;
697 case Alarm::Audio: 700 case Alarm::Audio:
698 action = ICAL_ACTION_AUDIO; 701 action = ICAL_ACTION_AUDIO;
699 if (!alarm->audioFile().isEmpty()) { 702 if (!alarm->audioFile().isEmpty()) {
700 attach = icalattach_new_from_url(QFile::encodeName( alarm->audioFile() ).data()); 703 attach = icalattach_new_from_url(QFile::encodeName( alarm->audioFile() ).data());
701 icalcomponent_add_property(a,icalproperty_new_attach(attach)); 704 icalcomponent_add_property(a,icalproperty_new_attach(attach));
702 icalattach_unref( attach ); 705 icalattach_unref( attach );
703 } 706 }
704 break; 707 break;
705 case Alarm::Email: { 708 case Alarm::Email: {
706 action = ICAL_ACTION_EMAIL; 709 action = ICAL_ACTION_EMAIL;
707 QValueList<Person> addresses = alarm->mailAddresses(); 710 Q3ValueList<Person> addresses = alarm->mailAddresses();
708 for (QValueList<Person>::Iterator ad = addresses.begin(); ad != addresses.end(); ++ad) { 711 for (Q3ValueList<Person>::Iterator ad = addresses.begin(); ad != addresses.end(); ++ad) {
709 icalproperty *p = icalproperty_new_attendee("MAILTO:" + (*ad).email().utf8()); 712 icalproperty *p = icalproperty_new_attendee("MAILTO:" + (*ad).email().utf8());
710 if (!(*ad).name().isEmpty()) { 713 if (!(*ad).name().isEmpty()) {
711 icalproperty_add_parameter(p,icalparameter_new_cn((*ad).name().utf8())); 714 icalproperty_add_parameter(p,icalparameter_new_cn((*ad).name().utf8()));
712 } 715 }
713 icalcomponent_add_property(a,p); 716 icalcomponent_add_property(a,p);
714 } 717 }
715 icalcomponent_add_property(a,icalproperty_new_summary(alarm->mailSubject().utf8())); 718 icalcomponent_add_property(a,icalproperty_new_summary(alarm->mailSubject().utf8()));
716 icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); 719 icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8()));
717 QStringList attachments = alarm->mailAttachments(); 720 QStringList attachments = alarm->mailAttachments();
718 if (attachments.count() > 0) { 721 if (attachments.count() > 0) {
719 for (QStringList::Iterator at = attachments.begin(); at != attachments.end(); ++at) { 722 for (QStringList::Iterator at = attachments.begin(); at != attachments.end(); ++at) {
720 attach = icalattach_new_from_url(QFile::encodeName( *at ).data()); 723 attach = icalattach_new_from_url(QFile::encodeName( *at ).data());
721 icalcomponent_add_property(a,icalproperty_new_attach(attach)); 724 icalcomponent_add_property(a,icalproperty_new_attach(attach));
722 icalattach_unref( attach ); 725 icalattach_unref( attach );
723 } 726 }
724 } 727 }
725 break; 728 break;
726 } 729 }
727 case Alarm::Display: 730 case Alarm::Display:
728 action = ICAL_ACTION_DISPLAY; 731 action = ICAL_ACTION_DISPLAY;
729 icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); 732 icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8()));
730 break; 733 break;
731 case Alarm::Invalid: 734 case Alarm::Invalid:
732 default: 735 default:
733 kdDebug(5800) << "Unknown type of alarm" << endl; 736 kdDebug(5800) << "Unknown type of alarm" << endl;
734 action = ICAL_ACTION_NONE; 737 action = ICAL_ACTION_NONE;
735 break; 738 break;
736 } 739 }
737 icalcomponent_add_property(a,icalproperty_new_action(action)); 740 icalcomponent_add_property(a,icalproperty_new_action(action));
738 741
739 // Trigger time 742 // Trigger time
740 icaltriggertype trigger; 743 icaltriggertype trigger;
741 if ( alarm->hasTime() ) { 744 if ( alarm->hasTime() ) {
742 trigger.time = writeICalDateTime(alarm->time()); 745 trigger.time = writeICalDateTime(alarm->time());
743 trigger.duration = icaldurationtype_null_duration(); 746 trigger.duration = icaldurationtype_null_duration();
744 } else { 747 } else {
745 trigger.time = icaltime_null_time(); 748 trigger.time = icaltime_null_time();
746 Duration offset; 749 Duration offset;
747 if ( alarm->hasStartOffset() ) 750 if ( alarm->hasStartOffset() )
748 offset = alarm->startOffset(); 751 offset = alarm->startOffset();
749 else 752 else
750 offset = alarm->endOffset(); 753 offset = alarm->endOffset();
751 trigger.duration = icaldurationtype_from_int( offset.asSeconds() ); 754 trigger.duration = icaldurationtype_from_int( offset.asSeconds() );
752 } 755 }
753 icalproperty *p = icalproperty_new_trigger(trigger); 756 icalproperty *p = icalproperty_new_trigger(trigger);
754 if ( alarm->hasEndOffset() ) 757 if ( alarm->hasEndOffset() )
755 icalproperty_add_parameter(p,icalparameter_new_related(ICAL_RELATED_END)); 758 icalproperty_add_parameter(p,icalparameter_new_related(ICAL_RELATED_END));
756 icalcomponent_add_property(a,p); 759 icalcomponent_add_property(a,p);
757 760
758 // Repeat count and duration 761 // Repeat count and duration
759 if (alarm->repeatCount()) { 762 if (alarm->repeatCount()) {
760 icalcomponent_add_property(a,icalproperty_new_repeat(alarm->repeatCount())); 763 icalcomponent_add_property(a,icalproperty_new_repeat(alarm->repeatCount()));
761 icalcomponent_add_property(a,icalproperty_new_duration( 764 icalcomponent_add_property(a,icalproperty_new_duration(
762 icaldurationtype_from_int(alarm->snoozeTime()*60))); 765 icaldurationtype_from_int(alarm->snoozeTime()*60)));
763 } 766 }
764 767
765 // Custom properties 768 // Custom properties
766 QMap<QCString, QString> custom = alarm->customProperties(); 769 QMap<Q3CString, QString> custom = alarm->customProperties();
767 for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { 770 for (QMap<Q3CString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) {
768 icalproperty *p = icalproperty_new_x(c.data().utf8()); 771 icalproperty *p = icalproperty_new_x(c.data().utf8());
769 icalproperty_set_x_name(p,c.key()); 772 icalproperty_set_x_name(p,c.key());
770 icalcomponent_add_property(a,p); 773 icalcomponent_add_property(a,p);
771 } 774 }
772 775
773 return a; 776 return a;
774} 777}
775 778
776Todo *ICalFormatImpl::readTodo(icalcomponent *vtodo) 779Todo *ICalFormatImpl::readTodo(icalcomponent *vtodo)
777{ 780{
778 Todo *todo = new Todo; 781 Todo *todo = new Todo;
779 782
780 readIncidence(vtodo,todo); 783 readIncidence(vtodo,todo);
781 784
782 icalproperty *p = icalcomponent_get_first_property(vtodo,ICAL_ANY_PROPERTY); 785 icalproperty *p = icalcomponent_get_first_property(vtodo,ICAL_ANY_PROPERTY);
783 786
784// int intvalue; 787// int intvalue;
785 icaltimetype icaltime; 788 icaltimetype icaltime;
786 789
787 QStringList categories; 790 QStringList categories;
788 791
789 while (p) { 792 while (p) {
790 icalproperty_kind kind = icalproperty_isa(p); 793 icalproperty_kind kind = icalproperty_isa(p);
791 switch (kind) { 794 switch (kind) {
792 795
793 case ICAL_DUE_PROPERTY: // due date 796 case ICAL_DUE_PROPERTY: // due date
794 icaltime = icalproperty_get_due(p); 797 icaltime = icalproperty_get_due(p);
795 if (icaltime.is_date) { 798 if (icaltime.is_date) {
796 todo->setDtDue(QDateTime(readICalDate(icaltime),QTime(0,0,0))); 799 todo->setDtDue(QDateTime(readICalDate(icaltime),QTime(0,0,0)));
797 todo->setFloats(true); 800 todo->setFloats(true);
798 801
799 } else { 802 } else {
800 todo->setDtDue(readICalDateTime(icaltime)); 803 todo->setDtDue(readICalDateTime(icaltime));
801 todo->setFloats(false); 804 todo->setFloats(false);
802 } 805 }
803 todo->setHasDueDate(true); 806 todo->setHasDueDate(true);
804 break; 807 break;
805 808
806 case ICAL_COMPLETED_PROPERTY: // completion date 809 case ICAL_COMPLETED_PROPERTY: // completion date
807 icaltime = icalproperty_get_completed(p); 810 icaltime = icalproperty_get_completed(p);
808 todo->setCompleted(readICalDateTime(icaltime)); 811 todo->setCompleted(readICalDateTime(icaltime));
809 break; 812 break;
810 813
811 case ICAL_PERCENTCOMPLETE_PROPERTY: // Percent completed 814 case ICAL_PERCENTCOMPLETE_PROPERTY: // Percent completed
812 todo->setPercentComplete(icalproperty_get_percentcomplete(p)); 815 todo->setPercentComplete(icalproperty_get_percentcomplete(p));
813 break; 816 break;
814 817
815 case ICAL_RELATEDTO_PROPERTY: // related todo (parent) 818 case ICAL_RELATEDTO_PROPERTY: // related todo (parent)
@@ -1294,97 +1297,97 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence)
1294 // Cancel backwards compatibility mode for subsequent changes by the application 1297 // Cancel backwards compatibility mode for subsequent changes by the application
1295 if ( readrec ) 1298 if ( readrec )
1296 incidence->recurrence()->setCompatVersion(); 1299 incidence->recurrence()->setCompatVersion();
1297 1300
1298 // add categories 1301 // add categories
1299 incidence->setCategories(categories); 1302 incidence->setCategories(categories);
1300 1303
1301 // iterate through all alarms 1304 // iterate through all alarms
1302 for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); 1305 for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT);
1303 alarm; 1306 alarm;
1304 alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { 1307 alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) {
1305 readAlarm(alarm,incidence); 1308 readAlarm(alarm,incidence);
1306 } 1309 }
1307} 1310}
1308 1311
1309void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) 1312void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase)
1310{ 1313{
1311 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); 1314 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY);
1312 1315
1313 while (p) { 1316 while (p) {
1314 icalproperty_kind kind = icalproperty_isa(p); 1317 icalproperty_kind kind = icalproperty_isa(p);
1315 switch (kind) { 1318 switch (kind) {
1316 1319
1317 case ICAL_UID_PROPERTY: // unique id 1320 case ICAL_UID_PROPERTY: // unique id
1318 incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); 1321 incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p)));
1319 break; 1322 break;
1320 1323
1321 case ICAL_ORGANIZER_PROPERTY: // organizer 1324 case ICAL_ORGANIZER_PROPERTY: // organizer
1322 incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); 1325 incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p)));
1323 break; 1326 break;
1324 1327
1325 case ICAL_ATTENDEE_PROPERTY: // attendee 1328 case ICAL_ATTENDEE_PROPERTY: // attendee
1326 incidenceBase->addAttendee(readAttendee(p)); 1329 incidenceBase->addAttendee(readAttendee(p));
1327 break; 1330 break;
1328 1331
1329 default: 1332 default:
1330 break; 1333 break;
1331 } 1334 }
1332 1335
1333 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); 1336 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY);
1334 } 1337 }
1335 1338
1336 // custom properties 1339 // custom properties
1337 readCustomProperties(parent, incidenceBase); 1340 readCustomProperties(parent, incidenceBase);
1338} 1341}
1339 1342
1340void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) 1343void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties)
1341{ 1344{
1342 QMap<QCString, QString> customProperties; 1345 QMap<Q3CString, QString> customProperties;
1343 1346
1344 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY); 1347 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY);
1345 1348
1346 while (p) { 1349 while (p) {
1347 QString value = QString::fromUtf8(icalproperty_get_x(p)); 1350 QString value = QString::fromUtf8(icalproperty_get_x(p));
1348 customProperties[icalproperty_get_x_name(p)] = value; 1351 customProperties[icalproperty_get_x_name(p)] = value;
1349 //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) ); 1352 //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) );
1350 1353
1351 p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY); 1354 p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY);
1352 } 1355 }
1353 1356
1354 properties->setCustomProperties(customProperties); 1357 properties->setCustomProperties(customProperties);
1355} 1358}
1356 1359
1357void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence) 1360void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence)
1358{ 1361{
1359// kdDebug(5800) << "Read recurrence for " << incidence->summary() << endl; 1362// kdDebug(5800) << "Read recurrence for " << incidence->summary() << endl;
1360 1363
1361 Recurrence *recur = incidence->recurrence(); 1364 Recurrence *recur = incidence->recurrence();
1362 recur->setCompatVersion(mCalendarVersion); 1365 recur->setCompatVersion(mCalendarVersion);
1363 recur->unsetRecurs(); 1366 recur->unsetRecurs();
1364 1367
1365 struct icalrecurrencetype r = rrule; 1368 struct icalrecurrencetype r = rrule;
1366 1369
1367 dumpIcalRecurrence(r); 1370 dumpIcalRecurrence(r);
1368 readRecurrence( r, recur, incidence); 1371 readRecurrence( r, recur, incidence);
1369} 1372}
1370 1373
1371void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurrence* recur, Incidence *incidence) 1374void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurrence* recur, Incidence *incidence)
1372{ 1375{
1373 int wkst; 1376 int wkst;
1374 int index = 0; 1377 int index = 0;
1375 short day = 0; 1378 short day = 0;
1376 QBitArray qba(7); 1379 QBitArray qba(7);
1377 int frequ = r.freq; 1380 int frequ = r.freq;
1378 int interv = r.interval; 1381 int interv = r.interval;
1379 // preprocessing for odd recurrence definitions 1382 // preprocessing for odd recurrence definitions
1380 1383
1381 if ( r.freq == ICAL_MONTHLY_RECURRENCE ) { 1384 if ( r.freq == ICAL_MONTHLY_RECURRENCE ) {
1382 if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { 1385 if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) {
1383 interv = 12; 1386 interv = 12;
1384 } 1387 }
1385 } 1388 }
1386 if ( r.freq == ICAL_YEARLY_RECURRENCE ) { 1389 if ( r.freq == ICAL_YEARLY_RECURRENCE ) {
1387 if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX && r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX ) { 1390 if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX && r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX ) {
1388 frequ = ICAL_MONTHLY_RECURRENCE; 1391 frequ = ICAL_MONTHLY_RECURRENCE;
1389 interv = 12* r.interval; 1392 interv = 12* r.interval;
1390 } 1393 }