author | zautrix <zautrix> | 2004-06-29 11:59:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-29 11:59:46 (UTC) |
commit | da43dbdc6c82453228f34766fc74585615cba938 (patch) (unidiff) | |
tree | 16576932cea08bf117b2d0320b0d5f66ee8ad093 /libkcal/icalformatimpl.cpp | |
parent | 627489ea2669d3997676bc3cee0f5d0d0c16c4d4 (diff) | |
download | kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.zip kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.tar.gz kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.tar.bz2 |
New lib ical.Some minor changes as well.
-rw-r--r-- | libkcal/icalformatimpl.cpp | 79 |
1 files changed, 38 insertions, 41 deletions
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index e5c27a0..32a1337 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp | |||
@@ -190,10 +190,10 @@ icalcomponent *ICalFormatImpl::writeEvent(Event *event) | |||
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 | ||
@@ -322,20 +322,21 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) | |||
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( |
@@ -521,14 +522,19 @@ icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee) | |||
521 | 522 | ||
522 | icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) | 523 | icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) |
523 | { | 524 | { |
524 | icalattachtype* attach = icalattachtype_new(); | 525 | #if 0 |
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 | ||
@@ -686,15 +692,13 @@ icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) | |||
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 | } |
@@ -702,10 +706,8 @@ icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) | |||
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: { |
@@ -723,10 +725,8 @@ icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) | |||
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; |
@@ -938,10 +938,8 @@ Event *ICalFormatImpl::readEvent(icalcomponent *vevent) | |||
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 ); |
@@ -1118,12 +1116,12 @@ Attendee *ICalFormatImpl::readAttendee(icalproperty *attendee) | |||
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); |
@@ -1131,14 +1129,12 @@ Attachment *ICalFormatImpl::readAttachment(icalproperty *attach) | |||
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); |
@@ -1250,15 +1246,16 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) | |||
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 |
@@ -1353,9 +1350,9 @@ void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties | |||
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 | } |
@@ -1667,8 +1664,8 @@ void ICalFormatImpl::readAlarm(icalcomponent *alarm,Incidence *incidence) | |||
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 ); |