-rw-r--r-- | libkcal/icalformatimpl.cpp | 35 |
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,48 +1,51 @@ | |||
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 | ||
30 | extern "C" { | 33 | extern "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 | ||
45 | using namespace KCal; | 48 | using namespace KCal; |
46 | 49 | ||
47 | const int gSecondsPerMinute = 60; | 50 | const int gSecondsPerMinute = 60; |
48 | const int gSecondsPerHour = gSecondsPerMinute * 60; | 51 | const int gSecondsPerHour = gSecondsPerMinute * 60; |
@@ -200,50 +203,50 @@ icalcomponent *ICalFormatImpl::writeEvent(Event *event) | |||
200 | return vevent; | 203 | return vevent; |
201 | } | 204 | } |
202 | 205 | ||
203 | icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, | 206 | icalcomponent *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 | ||
236 | icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) | 239 | icalcomponent *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; |
@@ -363,102 +366,102 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) | |||
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 | ||
415 | void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) | 418 | void 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 | ||
437 | void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties) | 440 | void 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 | ||
447 | icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee) | 450 | icalproperty *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; |
@@ -525,50 +528,50 @@ icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) | |||
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 | ||
538 | icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur) | 541 | icalproperty *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 |
@@ -683,50 +686,50 @@ icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) | |||
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: |
@@ -742,50 +745,50 @@ icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) | |||
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 | ||
776 | Todo *ICalFormatImpl::readTodo(icalcomponent *vtodo) | 779 | Todo *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) { |
@@ -1318,49 +1321,49 @@ void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *inci | |||
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 | ||
1340 | void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) | 1343 | void 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 | ||
1357 | void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence) | 1360 | void 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 | ||