-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 @@ -192,6 +192,6 @@ icalcomponent *ICalFormatImpl::writeEvent(Event *event) case Event::Transparent: - icalcomponent_add_property(vevent, icalproperty_new_transp("TRANSPARENT")); + icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT)); break; case Event::Opaque: - icalcomponent_add_property(vevent, icalproperty_new_transp("OPAQUE")); + icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE)); break; @@ -324,16 +324,17 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) // secrecy - const char *classStr; + enum icalproperty_class classInt; switch (incidence->secrecy()) { case Incidence::SecrecyPublic: - classStr = "PUBLIC"; + classInt = ICAL_CLASS_PUBLIC; break; case Incidence::SecrecyConfidential: - classStr = "CONFIDENTIAL"; + classInt = ICAL_CLASS_CONFIDENTIAL; break; case Incidence::SecrecyPrivate: + classInt =ICAL_CLASS_PRIVATE ; default: - classStr = "PRIVATE"; + classInt =ICAL_CLASS_PRIVATE ; break; } - icalcomponent_add_property(parent,icalproperty_new_class(classStr)); + icalcomponent_add_property(parent,icalproperty_new_class(classInt)); @@ -523,3 +524,4 @@ icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) { - icalattachtype* attach = icalattachtype_new(); +#if 0 + icalattachtype* attach = icalattachtype_new(); if (att->isURI()) @@ -528,5 +530,9 @@ icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) icalattachtype_set_base64(attach, att->data(), 0); - +#endif + icalattach *attach; + if (att->isURI()) + attach = icalattach_new_from_url( att->uri().utf8().data()); + else + attach = icalattach_new_from_data ( (unsigned char *)att->data(), 0, 0); icalproperty *p = icalproperty_new_attach(attach); - if (!att->mimeType().isEmpty()) @@ -688,3 +694,3 @@ icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) icalproperty_action action; - icalattachtype *attach = 0; + icalattach *attach = 0; @@ -693,6 +699,4 @@ icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) action = ICAL_ACTION_PROCEDURE; - attach = icalattachtype_new(); - icalattachtype_set_url(attach,QFile::encodeName(alarm->programFile()).data()); + attach = icalattach_new_from_url( QFile::encodeName(alarm->programFile()).data() ); icalcomponent_add_property(a,icalproperty_new_attach(attach)); - icalattachtype_free(attach); if (!alarm->programArguments().isEmpty()) { @@ -704,6 +708,4 @@ icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) if (!alarm->audioFile().isEmpty()) { - attach = icalattachtype_new(); - icalattachtype_set_url(attach,QFile::encodeName( alarm->audioFile() ).data()); + attach = icalattach_new_from_url(QFile::encodeName( alarm->audioFile() ).data()); icalcomponent_add_property(a,icalproperty_new_attach(attach)); - icalattachtype_free(attach); } @@ -725,6 +727,4 @@ icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) for (QStringList::Iterator at = attachments.begin(); at != attachments.end(); ++at) { - attach = icalattachtype_new(); - icalattachtype_set_url(attach,QFile::encodeName( *at ).data()); + attach = icalattach_new_from_url(QFile::encodeName( *at ).data()); icalcomponent_add_property(a,icalproperty_new_attach(attach)); - icalattachtype_free(attach); } @@ -940,6 +940,4 @@ Event *ICalFormatImpl::readEvent(icalcomponent *vevent) - case ICAL_TRANSP_PROPERTY: // Transparency - transparency = QString::fromUtf8(icalproperty_get_transp(p)); - if( transparency == "TRANSPARENT" ) + if(icalproperty_get_transp(p) == ICAL_TRANSP_TRANSPARENT ) event->setTransparency( Event::Transparent ); @@ -1120,3 +1118,3 @@ Attachment *ICalFormatImpl::readAttachment(icalproperty *attach) { - icalattachtype *a = icalproperty_get_attach(attach); + icalattach *a = icalproperty_get_attach(attach); icalparameter_value v = ICAL_VALUE_NONE; @@ -1125,3 +1123,3 @@ Attachment *ICalFormatImpl::readAttachment(icalproperty *attach) Attachment *attachment = 0; - + /* icalparameter *vp = icalproperty_get_first_parameter(attach, ICAL_VALUE_PARAMETER); @@ -1133,10 +1131,8 @@ Attachment *ICalFormatImpl::readAttachment(icalproperty *attach) e = icalparameter_get_encoding(ep); - - if (v == ICAL_VALUE_BINARY && e == ICAL_ENCODING_BASE64) - attachment = new Attachment(icalattachtype_get_base64(a)); - else if ((v == ICAL_VALUE_NONE || v == ICAL_VALUE_URI) && (e == ICAL_ENCODING_NONE || e == ICAL_ENCODING_8BIT)) { - attachment = new Attachment(QString(icalattachtype_get_url(a))); - } else { - kdWarning(5800) << "Unsupported attachment format, discarding it!" << endl; - return 0; + */ + int isurl = icalattach_get_is_url (a); + if (isurl == 0) + attachment = new Attachment((const char*)icalattach_get_data(a)); + else { + attachment = new Attachment(QString(icalattach_get_url(a))); } @@ -1252,7 +1248,7 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) - case ICAL_CLASS_PROPERTY: - text = icalproperty_get_class(p); - if (strcmp(text,"PUBLIC") == 0) { + case ICAL_CLASS_PROPERTY: { + int inttext = icalproperty_get_class(p); + if (inttext == ICAL_CLASS_PUBLIC ) { incidence->setSecrecy(Incidence::SecrecyPublic); - } else if (strcmp(text,"CONFIDENTIAL") == 0) { + } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) { incidence->setSecrecy(Incidence::SecrecyConfidential); @@ -1261,2 +1257,3 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) } + } break; @@ -1355,5 +1352,5 @@ void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties while (p) { - QString value = QString::fromUtf8(icalproperty_get_x(p)); - customProperties[icalproperty_get_name(p)] = value; + customProperties[icalproperty_get_x_name(p)] = value; + //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) ); @@ -1669,4 +1666,4 @@ void ICalFormatImpl::readAlarm(icalcomponent *alarm,Incidence *incidence) case ICAL_ATTACH_PROPERTY: { - icalattachtype *attach = icalproperty_get_attach(p); - QString url = QFile::decodeName(icalattachtype_get_url(attach)); + icalattach *attach = icalproperty_get_attach(p); + QString url = QFile::decodeName(icalattach_get_url(attach)); switch ( action ) { |