-rw-r--r-- | libkcal/icalformatimpl.cpp | 77 |
1 files changed, 37 insertions, 40 deletions
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index e5c27a0..32a1337 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp | |||
@@ -169,52 +169,52 @@ icalcomponent *ICalFormatImpl::writeEvent(Event *event) | |||
169 | } | 169 | } |
170 | icalcomponent_add_property(vevent,icalproperty_new_dtend(end)); | 170 | icalcomponent_add_property(vevent,icalproperty_new_dtend(end)); |
171 | } | 171 | } |
172 | 172 | ||
173 | // TODO: attachments, resources | 173 | // TODO: attachments, resources |
174 | #if 0 | 174 | #if 0 |
175 | // attachments | 175 | // attachments |
176 | tmpStrList = anEvent->attachments(); | 176 | tmpStrList = anEvent->attachments(); |
177 | for ( QStringList::Iterator it = tmpStrList.begin(); | 177 | for ( QStringList::Iterator it = tmpStrList.begin(); |
178 | it != tmpStrList.end(); | 178 | it != tmpStrList.end(); |
179 | ++it ) | 179 | ++it ) |
180 | addPropValue(vevent, VCAttachProp, (*it).utf8()); | 180 | addPropValue(vevent, VCAttachProp, (*it).utf8()); |
181 | 181 | ||
182 | // resources | 182 | // resources |
183 | tmpStrList = anEvent->resources(); | 183 | tmpStrList = anEvent->resources(); |
184 | tmpStr = tmpStrList.join(";"); | 184 | tmpStr = tmpStrList.join(";"); |
185 | if (!tmpStr.isEmpty()) | 185 | if (!tmpStr.isEmpty()) |
186 | addPropValue(vevent, VCResourcesProp, tmpStr.utf8()); | 186 | addPropValue(vevent, VCResourcesProp, tmpStr.utf8()); |
187 | 187 | ||
188 | #endif | 188 | #endif |
189 | 189 | ||
190 | // Transparency | 190 | // Transparency |
191 | switch( event->transparency() ) { | 191 | switch( event->transparency() ) { |
192 | case Event::Transparent: | 192 | case Event::Transparent: |
193 | icalcomponent_add_property(vevent, icalproperty_new_transp("TRANSPARENT")); | 193 | icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT)); |
194 | break; | 194 | break; |
195 | case Event::Opaque: | 195 | case Event::Opaque: |
196 | icalcomponent_add_property(vevent, icalproperty_new_transp("OPAQUE")); | 196 | icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE)); |
197 | break; | 197 | break; |
198 | } | 198 | } |
199 | 199 | ||
200 | return vevent; | 200 | return vevent; |
201 | } | 201 | } |
202 | 202 | ||
203 | icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, | 203 | icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, |
204 | Scheduler::Method method) | 204 | Scheduler::Method method) |
205 | { | 205 | { |
206 | #if QT_VERSION >= 300 | 206 | #if QT_VERSION >= 300 |
207 | kdDebug(5800) << "icalformatimpl: writeFreeBusy: startDate: " | 207 | kdDebug(5800) << "icalformatimpl: writeFreeBusy: startDate: " |
208 | << freebusy->dtStart().toString("ddd MMMM d yyyy: h:m:s ap") << " End Date: " | 208 | << freebusy->dtStart().toString("ddd MMMM d yyyy: h:m:s ap") << " End Date: " |
209 | << freebusy->dtEnd().toString("ddd MMMM d yyyy: h:m:s ap") << endl; | 209 | << freebusy->dtEnd().toString("ddd MMMM d yyyy: h:m:s ap") << endl; |
210 | #endif | 210 | #endif |
211 | 211 | ||
212 | icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT); | 212 | icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT); |
213 | 213 | ||
214 | writeIncidenceBase(vfreebusy,freebusy); | 214 | writeIncidenceBase(vfreebusy,freebusy); |
215 | 215 | ||
216 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart( | 216 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart( |
217 | writeICalDateTime(freebusy->dtStart()))); | 217 | writeICalDateTime(freebusy->dtStart()))); |
218 | 218 | ||
219 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtend( | 219 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtend( |
220 | writeICalDateTime(freebusy->dtEnd()))); | 220 | writeICalDateTime(freebusy->dtEnd()))); |
@@ -301,62 +301,63 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) | |||
301 | 301 | ||
302 | // description | 302 | // description |
303 | if (!incidence->description().isEmpty()) { | 303 | if (!incidence->description().isEmpty()) { |
304 | icalcomponent_add_property(parent,icalproperty_new_description( | 304 | icalcomponent_add_property(parent,icalproperty_new_description( |
305 | incidence->description().utf8())); | 305 | incidence->description().utf8())); |
306 | } | 306 | } |
307 | 307 | ||
308 | // summary | 308 | // summary |
309 | if (!incidence->summary().isEmpty()) { | 309 | if (!incidence->summary().isEmpty()) { |
310 | icalcomponent_add_property(parent,icalproperty_new_summary( | 310 | icalcomponent_add_property(parent,icalproperty_new_summary( |
311 | incidence->summary().utf8())); | 311 | incidence->summary().utf8())); |
312 | } | 312 | } |
313 | 313 | ||
314 | // location | 314 | // location |
315 | if (!incidence->location().isEmpty()) { | 315 | if (!incidence->location().isEmpty()) { |
316 | icalcomponent_add_property(parent,icalproperty_new_location( | 316 | icalcomponent_add_property(parent,icalproperty_new_location( |
317 | incidence->location().utf8())); | 317 | incidence->location().utf8())); |
318 | } | 318 | } |
319 | 319 | ||
320 | // TODO: | 320 | // TODO: |
321 | // status | 321 | // status |
322 | // addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8()); | 322 | // addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8()); |
323 | 323 | ||
324 | // secrecy | 324 | // secrecy |
325 | const char *classStr; | 325 | enum icalproperty_class classInt; |
326 | switch (incidence->secrecy()) { | 326 | switch (incidence->secrecy()) { |
327 | case Incidence::SecrecyPublic: | 327 | case Incidence::SecrecyPublic: |
328 | classStr = "PUBLIC"; | 328 | classInt = ICAL_CLASS_PUBLIC; |
329 | break; | 329 | break; |
330 | case Incidence::SecrecyConfidential: | 330 | case Incidence::SecrecyConfidential: |
331 | classStr = "CONFIDENTIAL"; | 331 | classInt = ICAL_CLASS_CONFIDENTIAL; |
332 | break; | 332 | break; |
333 | case Incidence::SecrecyPrivate: | 333 | case Incidence::SecrecyPrivate: |
334 | classInt =ICAL_CLASS_PRIVATE ; | ||
334 | default: | 335 | default: |
335 | classStr = "PRIVATE"; | 336 | classInt =ICAL_CLASS_PRIVATE ; |
336 | break; | 337 | break; |
337 | } | 338 | } |
338 | icalcomponent_add_property(parent,icalproperty_new_class(classStr)); | 339 | icalcomponent_add_property(parent,icalproperty_new_class(classInt)); |
339 | 340 | ||
340 | // priority | 341 | // priority |
341 | icalcomponent_add_property(parent,icalproperty_new_priority( | 342 | icalcomponent_add_property(parent,icalproperty_new_priority( |
342 | incidence->priority())); | 343 | incidence->priority())); |
343 | 344 | ||
344 | // categories | 345 | // categories |
345 | QStringList categories = incidence->categories(); | 346 | QStringList categories = incidence->categories(); |
346 | QStringList::Iterator it; | 347 | QStringList::Iterator it; |
347 | for(it = categories.begin(); it != categories.end(); ++it ) { | 348 | for(it = categories.begin(); it != categories.end(); ++it ) { |
348 | icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); | 349 | icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); |
349 | } | 350 | } |
350 | // TODO: Ensure correct concatenation of categories properties. | 351 | // TODO: Ensure correct concatenation of categories properties. |
351 | 352 | ||
352 | /* | 353 | /* |
353 | // categories | 354 | // categories |
354 | tmpStrList = incidence->getCategories(); | 355 | tmpStrList = incidence->getCategories(); |
355 | tmpStr = ""; | 356 | tmpStr = ""; |
356 | QString catStr; | 357 | QString catStr; |
357 | for ( QStringList::Iterator it = tmpStrList.begin(); | 358 | for ( QStringList::Iterator it = tmpStrList.begin(); |
358 | it != tmpStrList.end(); | 359 | it != tmpStrList.end(); |
359 | ++it ) { | 360 | ++it ) { |
360 | catStr = *it; | 361 | catStr = *it; |
361 | if (catStr[0] == ' ') | 362 | if (catStr[0] == ' ') |
362 | tmpStr += catStr.mid(1); | 363 | tmpStr += catStr.mid(1); |
@@ -500,56 +501,61 @@ icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee) | |||
500 | default: | 501 | default: |
501 | case Attendee::ReqParticipant: | 502 | case Attendee::ReqParticipant: |
502 | role = ICAL_ROLE_REQPARTICIPANT; | 503 | role = ICAL_ROLE_REQPARTICIPANT; |
503 | break; | 504 | break; |
504 | case Attendee::OptParticipant: | 505 | case Attendee::OptParticipant: |
505 | role = ICAL_ROLE_OPTPARTICIPANT; | 506 | role = ICAL_ROLE_OPTPARTICIPANT; |
506 | break; | 507 | break; |
507 | case Attendee::NonParticipant: | 508 | case Attendee::NonParticipant: |
508 | role = ICAL_ROLE_NONPARTICIPANT; | 509 | role = ICAL_ROLE_NONPARTICIPANT; |
509 | break; | 510 | break; |
510 | } | 511 | } |
511 | icalproperty_add_parameter(p,icalparameter_new_role(role)); | 512 | icalproperty_add_parameter(p,icalparameter_new_role(role)); |
512 | 513 | ||
513 | if (!attendee->uid().isEmpty()) { | 514 | if (!attendee->uid().isEmpty()) { |
514 | icalparameter* icalparameter_uid = icalparameter_new_x(attendee->uid().utf8()); | 515 | icalparameter* icalparameter_uid = icalparameter_new_x(attendee->uid().utf8()); |
515 | icalparameter_set_xname(icalparameter_uid,"X-UID"); | 516 | icalparameter_set_xname(icalparameter_uid,"X-UID"); |
516 | icalproperty_add_parameter(p,icalparameter_uid); | 517 | icalproperty_add_parameter(p,icalparameter_uid); |
517 | } | 518 | } |
518 | 519 | ||
519 | return p; | 520 | return p; |
520 | } | 521 | } |
521 | 522 | ||
522 | icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) | 523 | icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) |
523 | { | 524 | { |
525 | #if 0 | ||
524 | icalattachtype* attach = icalattachtype_new(); | 526 | icalattachtype* attach = icalattachtype_new(); |
525 | if (att->isURI()) | 527 | if (att->isURI()) |
526 | icalattachtype_set_url(attach, att->uri().utf8().data()); | 528 | icalattachtype_set_url(attach, att->uri().utf8().data()); |
527 | else | 529 | else |
528 | icalattachtype_set_base64(attach, att->data(), 0); | 530 | icalattachtype_set_base64(attach, att->data(), 0); |
529 | 531 | #endif | |
532 | icalattach *attach; | ||
533 | if (att->isURI()) | ||
534 | attach = icalattach_new_from_url( att->uri().utf8().data()); | ||
535 | else | ||
536 | attach = icalattach_new_from_data ( (unsigned char *)att->data(), 0, 0); | ||
530 | icalproperty *p = icalproperty_new_attach(attach); | 537 | icalproperty *p = icalproperty_new_attach(attach); |
531 | |||
532 | if (!att->mimeType().isEmpty()) | 538 | if (!att->mimeType().isEmpty()) |
533 | icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data())); | 539 | icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data())); |
534 | 540 | ||
535 | if (att->isBinary()) { | 541 | if (att->isBinary()) { |
536 | icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY)); | 542 | icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY)); |
537 | icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64)); | 543 | icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64)); |
538 | } | 544 | } |
539 | return p; | 545 | return p; |
540 | } | 546 | } |
541 | 547 | ||
542 | icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur) | 548 | icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur) |
543 | { | 549 | { |
544 | // kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl; | 550 | // kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl; |
545 | 551 | ||
546 | icalrecurrencetype r; | 552 | icalrecurrencetype r; |
547 | 553 | ||
548 | icalrecurrencetype_clear(&r); | 554 | icalrecurrencetype_clear(&r); |
549 | 555 | ||
550 | int index = 0; | 556 | int index = 0; |
551 | int index2 = 0; | 557 | int index2 = 0; |
552 | 558 | ||
553 | QPtrList<Recurrence::rMonthPos> tmpPositions; | 559 | QPtrList<Recurrence::rMonthPos> tmpPositions; |
554 | QPtrList<int> tmpDays; | 560 | QPtrList<int> tmpDays; |
555 | int *tmpDay; | 561 | int *tmpDay; |
@@ -665,89 +671,83 @@ icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur) | |||
665 | if (datetime) | 671 | if (datetime) |
666 | r.until = writeICalDateTime(recur->endDateTime()); | 672 | r.until = writeICalDateTime(recur->endDateTime()); |
667 | else | 673 | else |
668 | r.until = writeICalDate(recur->endDate()); | 674 | r.until = writeICalDate(recur->endDate()); |
669 | } | 675 | } |
670 | 676 | ||
671 | // Debug output | 677 | // Debug output |
672 | #if 0 | 678 | #if 0 |
673 | const char *str = icalrecurrencetype_as_string(&r); | 679 | const char *str = icalrecurrencetype_as_string(&r); |
674 | if (str) { | 680 | if (str) { |
675 | kdDebug(5800) << " String: " << str << endl; | 681 | kdDebug(5800) << " String: " << str << endl; |
676 | } else { | 682 | } else { |
677 | kdDebug(5800) << " No String" << endl; | 683 | kdDebug(5800) << " No String" << endl; |
678 | } | 684 | } |
679 | #endif | 685 | #endif |
680 | 686 | ||
681 | return icalproperty_new_rrule(r); | 687 | return icalproperty_new_rrule(r); |
682 | } | 688 | } |
683 | 689 | ||
684 | icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) | 690 | icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) |
685 | { | 691 | { |
686 | icalcomponent *a = icalcomponent_new(ICAL_VALARM_COMPONENT); | 692 | icalcomponent *a = icalcomponent_new(ICAL_VALARM_COMPONENT); |
687 | 693 | ||
688 | icalproperty_action action; | 694 | icalproperty_action action; |
689 | icalattachtype *attach = 0; | 695 | icalattach *attach = 0; |
690 | 696 | ||
691 | switch (alarm->type()) { | 697 | switch (alarm->type()) { |
692 | case Alarm::Procedure: | 698 | case Alarm::Procedure: |
693 | action = ICAL_ACTION_PROCEDURE; | 699 | action = ICAL_ACTION_PROCEDURE; |
694 | attach = icalattachtype_new(); | 700 | attach = icalattach_new_from_url( QFile::encodeName(alarm->programFile()).data() ); |
695 | icalattachtype_set_url(attach,QFile::encodeName(alarm->programFile()).data()); | ||
696 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); | 701 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); |
697 | icalattachtype_free(attach); | ||
698 | if (!alarm->programArguments().isEmpty()) { | 702 | if (!alarm->programArguments().isEmpty()) { |
699 | icalcomponent_add_property(a,icalproperty_new_description(alarm->programArguments().utf8())); | 703 | icalcomponent_add_property(a,icalproperty_new_description(alarm->programArguments().utf8())); |
700 | } | 704 | } |
701 | break; | 705 | break; |
702 | case Alarm::Audio: | 706 | case Alarm::Audio: |
703 | action = ICAL_ACTION_AUDIO; | 707 | action = ICAL_ACTION_AUDIO; |
704 | if (!alarm->audioFile().isEmpty()) { | 708 | if (!alarm->audioFile().isEmpty()) { |
705 | attach = icalattachtype_new(); | 709 | attach = icalattach_new_from_url(QFile::encodeName( alarm->audioFile() ).data()); |
706 | icalattachtype_set_url(attach,QFile::encodeName( alarm->audioFile() ).data()); | ||
707 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); | 710 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); |
708 | icalattachtype_free(attach); | ||
709 | } | 711 | } |
710 | break; | 712 | break; |
711 | case Alarm::Email: { | 713 | case Alarm::Email: { |
712 | action = ICAL_ACTION_EMAIL; | 714 | action = ICAL_ACTION_EMAIL; |
713 | QValueList<Person> addresses = alarm->mailAddresses(); | 715 | QValueList<Person> addresses = alarm->mailAddresses(); |
714 | for (QValueList<Person>::Iterator ad = addresses.begin(); ad != addresses.end(); ++ad) { | 716 | for (QValueList<Person>::Iterator ad = addresses.begin(); ad != addresses.end(); ++ad) { |
715 | icalproperty *p = icalproperty_new_attendee("MAILTO:" + (*ad).email().utf8()); | 717 | icalproperty *p = icalproperty_new_attendee("MAILTO:" + (*ad).email().utf8()); |
716 | if (!(*ad).name().isEmpty()) { | 718 | if (!(*ad).name().isEmpty()) { |
717 | icalproperty_add_parameter(p,icalparameter_new_cn((*ad).name().utf8())); | 719 | icalproperty_add_parameter(p,icalparameter_new_cn((*ad).name().utf8())); |
718 | } | 720 | } |
719 | icalcomponent_add_property(a,p); | 721 | icalcomponent_add_property(a,p); |
720 | } | 722 | } |
721 | icalcomponent_add_property(a,icalproperty_new_summary(alarm->mailSubject().utf8())); | 723 | icalcomponent_add_property(a,icalproperty_new_summary(alarm->mailSubject().utf8())); |
722 | icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); | 724 | icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); |
723 | QStringList attachments = alarm->mailAttachments(); | 725 | QStringList attachments = alarm->mailAttachments(); |
724 | if (attachments.count() > 0) { | 726 | if (attachments.count() > 0) { |
725 | for (QStringList::Iterator at = attachments.begin(); at != attachments.end(); ++at) { | 727 | for (QStringList::Iterator at = attachments.begin(); at != attachments.end(); ++at) { |
726 | attach = icalattachtype_new(); | 728 | attach = icalattach_new_from_url(QFile::encodeName( *at ).data()); |
727 | icalattachtype_set_url(attach,QFile::encodeName( *at ).data()); | ||
728 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); | 729 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); |
729 | icalattachtype_free(attach); | ||
730 | } | 730 | } |
731 | } | 731 | } |
732 | break; | 732 | break; |
733 | } | 733 | } |
734 | case Alarm::Display: | 734 | case Alarm::Display: |
735 | action = ICAL_ACTION_DISPLAY; | 735 | action = ICAL_ACTION_DISPLAY; |
736 | icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); | 736 | icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); |
737 | break; | 737 | break; |
738 | case Alarm::Invalid: | 738 | case Alarm::Invalid: |
739 | default: | 739 | default: |
740 | kdDebug(5800) << "Unknown type of alarm" << endl; | 740 | kdDebug(5800) << "Unknown type of alarm" << endl; |
741 | action = ICAL_ACTION_NONE; | 741 | action = ICAL_ACTION_NONE; |
742 | break; | 742 | break; |
743 | } | 743 | } |
744 | icalcomponent_add_property(a,icalproperty_new_action(action)); | 744 | icalcomponent_add_property(a,icalproperty_new_action(action)); |
745 | 745 | ||
746 | // Trigger time | 746 | // Trigger time |
747 | icaltriggertype trigger; | 747 | icaltriggertype trigger; |
748 | if ( alarm->hasTime() ) { | 748 | if ( alarm->hasTime() ) { |
749 | trigger.time = writeICalDateTime(alarm->time()); | 749 | trigger.time = writeICalDateTime(alarm->time()); |
750 | trigger.duration = icaldurationtype_null_duration(); | 750 | trigger.duration = icaldurationtype_null_duration(); |
751 | } else { | 751 | } else { |
752 | trigger.time = icaltime_null_time(); | 752 | trigger.time = icaltime_null_time(); |
753 | Duration offset; | 753 | Duration offset; |
@@ -917,52 +917,50 @@ Event *ICalFormatImpl::readEvent(icalcomponent *vevent) | |||
917 | anEvent->setAttachments(tmpStrList); | 917 | anEvent->setAttachments(tmpStrList); |
918 | 918 | ||
919 | // resources | 919 | // resources |
920 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { | 920 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { |
921 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); | 921 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); |
922 | deleteStr(s); | 922 | deleteStr(s); |
923 | tmpStrList.clear(); | 923 | tmpStrList.clear(); |
924 | index1 = 0; | 924 | index1 = 0; |
925 | index2 = 0; | 925 | index2 = 0; |
926 | QString resource; | 926 | QString resource; |
927 | while ((index2 = resources.find(';', index1)) != -1) { | 927 | while ((index2 = resources.find(';', index1)) != -1) { |
928 | resource = resources.mid(index1, (index2 - index1)); | 928 | resource = resources.mid(index1, (index2 - index1)); |
929 | tmpStrList.append(resource); | 929 | tmpStrList.append(resource); |
930 | index1 = index2; | 930 | index1 = index2; |
931 | } | 931 | } |
932 | anEvent->setResources(tmpStrList); | 932 | anEvent->setResources(tmpStrList); |
933 | } | 933 | } |
934 | #endif | 934 | #endif |
935 | 935 | ||
936 | case ICAL_RELATEDTO_PROPERTY: // releated event (parent) | 936 | case ICAL_RELATEDTO_PROPERTY: // releated event (parent) |
937 | event->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p))); | 937 | event->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p))); |
938 | mEventsRelate.append(event); | 938 | mEventsRelate.append(event); |
939 | break; | 939 | break; |
940 | 940 | ||
941 | |||
942 | case ICAL_TRANSP_PROPERTY: // Transparency | 941 | case ICAL_TRANSP_PROPERTY: // Transparency |
943 | transparency = QString::fromUtf8(icalproperty_get_transp(p)); | 942 | if(icalproperty_get_transp(p) == ICAL_TRANSP_TRANSPARENT ) |
944 | if( transparency == "TRANSPARENT" ) | ||
945 | event->setTransparency( Event::Transparent ); | 943 | event->setTransparency( Event::Transparent ); |
946 | else | 944 | else |
947 | event->setTransparency( Event::Opaque ); | 945 | event->setTransparency( Event::Opaque ); |
948 | break; | 946 | break; |
949 | 947 | ||
950 | default: | 948 | default: |
951 | // kdDebug(5800) << "ICALFormat::readEvent(): Unknown property: " << kind | 949 | // kdDebug(5800) << "ICALFormat::readEvent(): Unknown property: " << kind |
952 | // << endl; | 950 | // << endl; |
953 | break; | 951 | break; |
954 | } | 952 | } |
955 | 953 | ||
956 | p = icalcomponent_get_next_property(vevent,ICAL_ANY_PROPERTY); | 954 | p = icalcomponent_get_next_property(vevent,ICAL_ANY_PROPERTY); |
957 | } | 955 | } |
958 | 956 | ||
959 | QString msade = event->nonKDECustomProperty("X-MICROSOFT-CDO-ALLDAYEVENT"); | 957 | QString msade = event->nonKDECustomProperty("X-MICROSOFT-CDO-ALLDAYEVENT"); |
960 | if (!msade.isNull()) { | 958 | if (!msade.isNull()) { |
961 | bool floats = (msade == QString::fromLatin1("TRUE")); | 959 | bool floats = (msade == QString::fromLatin1("TRUE")); |
962 | kdDebug(5800) << "ICALFormat::readEvent(): all day event: " << floats << endl; | 960 | kdDebug(5800) << "ICALFormat::readEvent(): all day event: " << floats << endl; |
963 | event->setFloats(floats); | 961 | event->setFloats(floats); |
964 | if (floats) { | 962 | if (floats) { |
965 | QDateTime endDate = event->dtEnd(); | 963 | QDateTime endDate = event->dtEnd(); |
966 | event->setDtEnd(endDate.addDays(-1)); | 964 | event->setDtEnd(endDate.addDays(-1)); |
967 | } | 965 | } |
968 | } | 966 | } |
@@ -1097,69 +1095,67 @@ Attendee *ICalFormatImpl::readAttendee(icalproperty *attendee) | |||
1097 | break; | 1095 | break; |
1098 | case ICAL_ROLE_OPTPARTICIPANT: | 1096 | case ICAL_ROLE_OPTPARTICIPANT: |
1099 | role = Attendee::OptParticipant; | 1097 | role = Attendee::OptParticipant; |
1100 | break; | 1098 | break; |
1101 | case ICAL_ROLE_NONPARTICIPANT: | 1099 | case ICAL_ROLE_NONPARTICIPANT: |
1102 | role = Attendee::NonParticipant; | 1100 | role = Attendee::NonParticipant; |
1103 | break; | 1101 | break; |
1104 | } | 1102 | } |
1105 | } | 1103 | } |
1106 | 1104 | ||
1107 | p = icalproperty_get_first_parameter(attendee,ICAL_X_PARAMETER); | 1105 | p = icalproperty_get_first_parameter(attendee,ICAL_X_PARAMETER); |
1108 | uid = icalparameter_get_xvalue(p); | 1106 | uid = icalparameter_get_xvalue(p); |
1109 | // This should be added, but there seems to be a libical bug here. | 1107 | // This should be added, but there seems to be a libical bug here. |
1110 | /*while (p) { | 1108 | /*while (p) { |
1111 | // if (icalparameter_get_xname(p) == "X-UID") { | 1109 | // if (icalparameter_get_xname(p) == "X-UID") { |
1112 | uid = icalparameter_get_xvalue(p); | 1110 | uid = icalparameter_get_xvalue(p); |
1113 | p = icalproperty_get_next_parameter(attendee,ICAL_X_PARAMETER); | 1111 | p = icalproperty_get_next_parameter(attendee,ICAL_X_PARAMETER); |
1114 | } */ | 1112 | } */ |
1115 | 1113 | ||
1116 | return new Attendee( name, email, rsvp, status, role, uid ); | 1114 | return new Attendee( name, email, rsvp, status, role, uid ); |
1117 | } | 1115 | } |
1118 | 1116 | ||
1119 | Attachment *ICalFormatImpl::readAttachment(icalproperty *attach) | 1117 | Attachment *ICalFormatImpl::readAttachment(icalproperty *attach) |
1120 | { | 1118 | { |
1121 | icalattachtype *a = icalproperty_get_attach(attach); | 1119 | icalattach *a = icalproperty_get_attach(attach); |
1122 | icalparameter_value v = ICAL_VALUE_NONE; | 1120 | icalparameter_value v = ICAL_VALUE_NONE; |
1123 | icalparameter_encoding e = ICAL_ENCODING_NONE; | 1121 | icalparameter_encoding e = ICAL_ENCODING_NONE; |
1124 | 1122 | ||
1125 | Attachment *attachment = 0; | 1123 | Attachment *attachment = 0; |
1126 | 1124 | /* | |
1127 | icalparameter *vp = icalproperty_get_first_parameter(attach, ICAL_VALUE_PARAMETER); | 1125 | icalparameter *vp = icalproperty_get_first_parameter(attach, ICAL_VALUE_PARAMETER); |
1128 | if (vp) | 1126 | if (vp) |
1129 | v = icalparameter_get_value(vp); | 1127 | v = icalparameter_get_value(vp); |
1130 | 1128 | ||
1131 | icalparameter *ep = icalproperty_get_first_parameter(attach, ICAL_ENCODING_PARAMETER); | 1129 | icalparameter *ep = icalproperty_get_first_parameter(attach, ICAL_ENCODING_PARAMETER); |
1132 | if (ep) | 1130 | if (ep) |
1133 | e = icalparameter_get_encoding(ep); | 1131 | e = icalparameter_get_encoding(ep); |
1134 | 1132 | */ | |
1135 | if (v == ICAL_VALUE_BINARY && e == ICAL_ENCODING_BASE64) | 1133 | int isurl = icalattach_get_is_url (a); |
1136 | attachment = new Attachment(icalattachtype_get_base64(a)); | 1134 | if (isurl == 0) |
1137 | else if ((v == ICAL_VALUE_NONE || v == ICAL_VALUE_URI) && (e == ICAL_ENCODING_NONE || e == ICAL_ENCODING_8BIT)) { | 1135 | attachment = new Attachment((const char*)icalattach_get_data(a)); |
1138 | attachment = new Attachment(QString(icalattachtype_get_url(a))); | 1136 | else { |
1139 | } else { | 1137 | attachment = new Attachment(QString(icalattach_get_url(a))); |
1140 | kdWarning(5800) << "Unsupported attachment format, discarding it!" << endl; | ||
1141 | return 0; | ||
1142 | } | 1138 | } |
1143 | 1139 | ||
1144 | icalparameter *p = icalproperty_get_first_parameter(attach, ICAL_FMTTYPE_PARAMETER); | 1140 | icalparameter *p = icalproperty_get_first_parameter(attach, ICAL_FMTTYPE_PARAMETER); |
1145 | if (p) | 1141 | if (p) |
1146 | attachment->setMimeType(QString(icalparameter_get_fmttype(p))); | 1142 | attachment->setMimeType(QString(icalparameter_get_fmttype(p))); |
1147 | 1143 | ||
1148 | return attachment; | 1144 | return attachment; |
1149 | } | 1145 | } |
1150 | #include <qtextcodec.h> | 1146 | #include <qtextcodec.h> |
1151 | void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) | 1147 | void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) |
1152 | { | 1148 | { |
1153 | readIncidenceBase(parent,incidence); | 1149 | readIncidenceBase(parent,incidence); |
1154 | 1150 | ||
1155 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); | 1151 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); |
1156 | bool readrec = false; | 1152 | bool readrec = false; |
1157 | const char *text; | 1153 | const char *text; |
1158 | int intvalue; | 1154 | int intvalue; |
1159 | icaltimetype icaltime; | 1155 | icaltimetype icaltime; |
1160 | icaldurationtype icalduration; | 1156 | icaldurationtype icalduration; |
1161 | struct icalrecurrencetype rectype; | 1157 | struct icalrecurrencetype rectype; |
1162 | QStringList categories; | 1158 | QStringList categories; |
1163 | 1159 | ||
1164 | while (p) { | 1160 | while (p) { |
1165 | icalproperty_kind kind = icalproperty_isa(p); | 1161 | icalproperty_kind kind = icalproperty_isa(p); |
@@ -1229,57 +1225,58 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) | |||
1229 | #endif | 1225 | #endif |
1230 | 1226 | ||
1231 | case ICAL_PRIORITY_PROPERTY: // priority | 1227 | case ICAL_PRIORITY_PROPERTY: // priority |
1232 | intvalue = icalproperty_get_priority(p); | 1228 | intvalue = icalproperty_get_priority(p); |
1233 | incidence->setPriority(intvalue); | 1229 | incidence->setPriority(intvalue); |
1234 | break; | 1230 | break; |
1235 | 1231 | ||
1236 | case ICAL_CATEGORIES_PROPERTY: // categories | 1232 | case ICAL_CATEGORIES_PROPERTY: // categories |
1237 | text = icalproperty_get_categories(p); | 1233 | text = icalproperty_get_categories(p); |
1238 | categories.append(QString::fromUtf8(text)); | 1234 | categories.append(QString::fromUtf8(text)); |
1239 | break; | 1235 | break; |
1240 | //******************************************* | 1236 | //******************************************* |
1241 | case ICAL_RRULE_PROPERTY: | 1237 | case ICAL_RRULE_PROPERTY: |
1242 | // we do need (maybe )start datetime of incidence for recurrence | 1238 | // we do need (maybe )start datetime of incidence for recurrence |
1243 | // such that we can read recurrence only after we read incidence completely | 1239 | // such that we can read recurrence only after we read incidence completely |
1244 | readrec = true; | 1240 | readrec = true; |
1245 | rectype = icalproperty_get_rrule(p); | 1241 | rectype = icalproperty_get_rrule(p); |
1246 | break; | 1242 | break; |
1247 | 1243 | ||
1248 | case ICAL_EXDATE_PROPERTY: | 1244 | case ICAL_EXDATE_PROPERTY: |
1249 | icaltime = icalproperty_get_exdate(p); | 1245 | icaltime = icalproperty_get_exdate(p); |
1250 | incidence->addExDate(readICalDate(icaltime)); | 1246 | incidence->addExDate(readICalDate(icaltime)); |
1251 | break; | 1247 | break; |
1252 | 1248 | ||
1253 | case ICAL_CLASS_PROPERTY: | 1249 | case ICAL_CLASS_PROPERTY: { |
1254 | text = icalproperty_get_class(p); | 1250 | int inttext = icalproperty_get_class(p); |
1255 | if (strcmp(text,"PUBLIC") == 0) { | 1251 | if (inttext == ICAL_CLASS_PUBLIC ) { |
1256 | incidence->setSecrecy(Incidence::SecrecyPublic); | 1252 | incidence->setSecrecy(Incidence::SecrecyPublic); |
1257 | } else if (strcmp(text,"CONFIDENTIAL") == 0) { | 1253 | } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) { |
1258 | incidence->setSecrecy(Incidence::SecrecyConfidential); | 1254 | incidence->setSecrecy(Incidence::SecrecyConfidential); |
1259 | } else { | 1255 | } else { |
1260 | incidence->setSecrecy(Incidence::SecrecyPrivate); | 1256 | incidence->setSecrecy(Incidence::SecrecyPrivate); |
1261 | } | 1257 | } |
1258 | } | ||
1262 | break; | 1259 | break; |
1263 | 1260 | ||
1264 | case ICAL_ATTACH_PROPERTY: // attachments | 1261 | case ICAL_ATTACH_PROPERTY: // attachments |
1265 | incidence->addAttachment(readAttachment(p)); | 1262 | incidence->addAttachment(readAttachment(p)); |
1266 | break; | 1263 | break; |
1267 | 1264 | ||
1268 | default: | 1265 | default: |
1269 | // kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind | 1266 | // kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind |
1270 | // << endl; | 1267 | // << endl; |
1271 | break; | 1268 | break; |
1272 | } | 1269 | } |
1273 | 1270 | ||
1274 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); | 1271 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); |
1275 | } | 1272 | } |
1276 | if ( readrec ) { | 1273 | if ( readrec ) { |
1277 | readRecurrenceRule(rectype,incidence); | 1274 | readRecurrenceRule(rectype,incidence); |
1278 | } | 1275 | } |
1279 | // kpilot stuff | 1276 | // kpilot stuff |
1280 | // TODO: move this application-specific code to kpilot | 1277 | // TODO: move this application-specific code to kpilot |
1281 | QString kp = incidence->nonKDECustomProperty("X-PILOTID"); | 1278 | QString kp = incidence->nonKDECustomProperty("X-PILOTID"); |
1282 | if (!kp.isNull()) { | 1279 | if (!kp.isNull()) { |
1283 | incidence->setPilotId(kp.toInt()); | 1280 | incidence->setPilotId(kp.toInt()); |
1284 | } | 1281 | } |
1285 | kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); | 1282 | kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); |
@@ -1332,51 +1329,51 @@ void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *inci | |||
1332 | break; | 1329 | break; |
1333 | 1330 | ||
1334 | case ICAL_ATTENDEE_PROPERTY: // attendee | 1331 | case ICAL_ATTENDEE_PROPERTY: // attendee |
1335 | incidenceBase->addAttendee(readAttendee(p)); | 1332 | incidenceBase->addAttendee(readAttendee(p)); |
1336 | break; | 1333 | break; |
1337 | 1334 | ||
1338 | default: | 1335 | default: |
1339 | break; | 1336 | break; |
1340 | } | 1337 | } |
1341 | 1338 | ||
1342 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); | 1339 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); |
1343 | } | 1340 | } |
1344 | 1341 | ||
1345 | // custom properties | 1342 | // custom properties |
1346 | readCustomProperties(parent, incidenceBase); | 1343 | readCustomProperties(parent, incidenceBase); |
1347 | } | 1344 | } |
1348 | 1345 | ||
1349 | void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) | 1346 | void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) |
1350 | { | 1347 | { |
1351 | QMap<QCString, QString> customProperties; | 1348 | QMap<QCString, QString> customProperties; |
1352 | 1349 | ||
1353 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY); | 1350 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY); |
1354 | 1351 | ||
1355 | while (p) { | 1352 | while (p) { |
1356 | |||
1357 | QString value = QString::fromUtf8(icalproperty_get_x(p)); | 1353 | QString value = QString::fromUtf8(icalproperty_get_x(p)); |
1358 | customProperties[icalproperty_get_name(p)] = value; | 1354 | customProperties[icalproperty_get_x_name(p)] = value; |
1355 | //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) ); | ||
1359 | 1356 | ||
1360 | p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY); | 1357 | p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY); |
1361 | } | 1358 | } |
1362 | 1359 | ||
1363 | properties->setCustomProperties(customProperties); | 1360 | properties->setCustomProperties(customProperties); |
1364 | } | 1361 | } |
1365 | 1362 | ||
1366 | void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence) | 1363 | void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence) |
1367 | { | 1364 | { |
1368 | // kdDebug(5800) << "Read recurrence for " << incidence->summary() << endl; | 1365 | // kdDebug(5800) << "Read recurrence for " << incidence->summary() << endl; |
1369 | 1366 | ||
1370 | Recurrence *recur = incidence->recurrence(); | 1367 | Recurrence *recur = incidence->recurrence(); |
1371 | recur->setCompatVersion(mCalendarVersion); | 1368 | recur->setCompatVersion(mCalendarVersion); |
1372 | recur->unsetRecurs(); | 1369 | recur->unsetRecurs(); |
1373 | 1370 | ||
1374 | struct icalrecurrencetype r = rrule; | 1371 | struct icalrecurrencetype r = rrule; |
1375 | 1372 | ||
1376 | dumpIcalRecurrence(r); | 1373 | dumpIcalRecurrence(r); |
1377 | readRecurrence( r, recur, incidence); | 1374 | readRecurrence( r, recur, incidence); |
1378 | } | 1375 | } |
1379 | 1376 | ||
1380 | void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurrence* recur, Incidence *incidence) | 1377 | void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurrence* recur, Incidence *incidence) |
1381 | { | 1378 | { |
1382 | int wkst; | 1379 | int wkst; |
@@ -1646,50 +1643,50 @@ void ICalFormatImpl::readAlarm(icalcomponent *alarm,Incidence *incidence) | |||
1646 | break; | 1643 | break; |
1647 | default: | 1644 | default: |
1648 | break; | 1645 | break; |
1649 | } | 1646 | } |
1650 | break; | 1647 | break; |
1651 | } | 1648 | } |
1652 | // Only in EMAIL alarm | 1649 | // Only in EMAIL alarm |
1653 | case ICAL_SUMMARY_PROPERTY: | 1650 | case ICAL_SUMMARY_PROPERTY: |
1654 | ialarm->setMailSubject(QString::fromUtf8(icalproperty_get_summary(p))); | 1651 | ialarm->setMailSubject(QString::fromUtf8(icalproperty_get_summary(p))); |
1655 | break; | 1652 | break; |
1656 | 1653 | ||
1657 | // Only in EMAIL alarm | 1654 | // Only in EMAIL alarm |
1658 | case ICAL_ATTENDEE_PROPERTY: { | 1655 | case ICAL_ATTENDEE_PROPERTY: { |
1659 | QString email = QString::fromUtf8(icalproperty_get_attendee(p)); | 1656 | QString email = QString::fromUtf8(icalproperty_get_attendee(p)); |
1660 | QString name; | 1657 | QString name; |
1661 | icalparameter *param = icalproperty_get_first_parameter(p,ICAL_CN_PARAMETER); | 1658 | icalparameter *param = icalproperty_get_first_parameter(p,ICAL_CN_PARAMETER); |
1662 | if (param) { | 1659 | if (param) { |
1663 | name = QString::fromUtf8(icalparameter_get_cn(param)); | 1660 | name = QString::fromUtf8(icalparameter_get_cn(param)); |
1664 | } | 1661 | } |
1665 | ialarm->addMailAddress(Person(name, email)); | 1662 | ialarm->addMailAddress(Person(name, email)); |
1666 | break; | 1663 | break; |
1667 | } | 1664 | } |
1668 | // Only in AUDIO and EMAIL and PROCEDURE alarms | 1665 | // Only in AUDIO and EMAIL and PROCEDURE alarms |
1669 | case ICAL_ATTACH_PROPERTY: { | 1666 | case ICAL_ATTACH_PROPERTY: { |
1670 | icalattachtype *attach = icalproperty_get_attach(p); | 1667 | icalattach *attach = icalproperty_get_attach(p); |
1671 | QString url = QFile::decodeName(icalattachtype_get_url(attach)); | 1668 | QString url = QFile::decodeName(icalattach_get_url(attach)); |
1672 | switch ( action ) { | 1669 | switch ( action ) { |
1673 | case ICAL_ACTION_AUDIO: | 1670 | case ICAL_ACTION_AUDIO: |
1674 | ialarm->setAudioFile( url ); | 1671 | ialarm->setAudioFile( url ); |
1675 | break; | 1672 | break; |
1676 | case ICAL_ACTION_PROCEDURE: | 1673 | case ICAL_ACTION_PROCEDURE: |
1677 | ialarm->setProgramFile( url ); | 1674 | ialarm->setProgramFile( url ); |
1678 | break; | 1675 | break; |
1679 | case ICAL_ACTION_EMAIL: | 1676 | case ICAL_ACTION_EMAIL: |
1680 | ialarm->addMailAttachment( url ); | 1677 | ialarm->addMailAttachment( url ); |
1681 | break; | 1678 | break; |
1682 | default: | 1679 | default: |
1683 | break; | 1680 | break; |
1684 | } | 1681 | } |
1685 | break; | 1682 | break; |
1686 | } | 1683 | } |
1687 | default: | 1684 | default: |
1688 | break; | 1685 | break; |
1689 | } | 1686 | } |
1690 | 1687 | ||
1691 | p = icalcomponent_get_next_property(alarm,ICAL_ANY_PROPERTY); | 1688 | p = icalcomponent_get_next_property(alarm,ICAL_ANY_PROPERTY); |
1692 | } | 1689 | } |
1693 | 1690 | ||
1694 | // custom properties | 1691 | // custom properties |
1695 | readCustomProperties(alarm, ialarm); | 1692 | readCustomProperties(alarm, ialarm); |