summaryrefslogtreecommitdiffabout
path: root/libkcal/icalformatimpl.cpp
Side-by-side diff
Diffstat (limited to 'libkcal/icalformatimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/icalformatimpl.cpp79
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
@@ -187,16 +187,16 @@ icalcomponent *ICalFormatImpl::writeEvent(Event *event)
#endif
// Transparency
switch( event->transparency() ) {
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;
}
return vevent;
}
@@ -319,26 +319,27 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
// TODO:
// status
// addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8());
// 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));
// priority
icalcomponent_add_property(parent,icalproperty_new_priority(
incidence->priority()));
// categories
@@ -518,20 +519,25 @@ icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee)
return p;
}
icalproperty *ICalFormatImpl::writeAttachment(Attachment *att)
{
- icalattachtype* attach = icalattachtype_new();
+#if 0
+ icalattachtype* attach = icalattachtype_new();
if (att->isURI())
icalattachtype_set_url(attach, att->uri().utf8().data());
else
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())
icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data()));
if (att->isBinary()) {
icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY));
icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64));
@@ -683,32 +689,28 @@ icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur)
icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm)
{
icalcomponent *a = icalcomponent_new(ICAL_VALARM_COMPONENT);
icalproperty_action action;
- icalattachtype *attach = 0;
+ icalattach *attach = 0;
switch (alarm->type()) {
case Alarm::Procedure:
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()) {
icalcomponent_add_property(a,icalproperty_new_description(alarm->programArguments().utf8()));
}
break;
case Alarm::Audio:
action = ICAL_ACTION_AUDIO;
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);
}
break;
case Alarm::Email: {
action = ICAL_ACTION_EMAIL;
QValueList<Person> addresses = alarm->mailAddresses();
for (QValueList<Person>::Iterator ad = addresses.begin(); ad != addresses.end(); ++ad) {
@@ -720,16 +722,14 @@ icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm)
}
icalcomponent_add_property(a,icalproperty_new_summary(alarm->mailSubject().utf8()));
icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8()));
QStringList attachments = alarm->mailAttachments();
if (attachments.count() > 0) {
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);
}
}
break;
}
case Alarm::Display:
action = ICAL_ACTION_DISPLAY;
@@ -935,16 +935,14 @@ Event *ICalFormatImpl::readEvent(icalcomponent *vevent)
case ICAL_RELATEDTO_PROPERTY: // releated event (parent)
event->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p)));
mEventsRelate.append(event);
break;
-
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 );
else
event->setTransparency( Event::Opaque );
break;
default:
@@ -1115,33 +1113,31 @@ Attendee *ICalFormatImpl::readAttendee(icalproperty *attendee)
return new Attendee( name, email, rsvp, status, role, uid );
}
Attachment *ICalFormatImpl::readAttachment(icalproperty *attach)
{
- icalattachtype *a = icalproperty_get_attach(attach);
+ icalattach *a = icalproperty_get_attach(attach);
icalparameter_value v = ICAL_VALUE_NONE;
icalparameter_encoding e = ICAL_ENCODING_NONE;
Attachment *attachment = 0;
-
+ /*
icalparameter *vp = icalproperty_get_first_parameter(attach, ICAL_VALUE_PARAMETER);
if (vp)
v = icalparameter_get_value(vp);
icalparameter *ep = icalproperty_get_first_parameter(attach, ICAL_ENCODING_PARAMETER);
if (ep)
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)));
}
icalparameter *p = icalproperty_get_first_parameter(attach, ICAL_FMTTYPE_PARAMETER);
if (p)
attachment->setMimeType(QString(icalparameter_get_fmttype(p)));
@@ -1247,21 +1243,22 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence)
case ICAL_EXDATE_PROPERTY:
icaltime = icalproperty_get_exdate(p);
incidence->addExDate(readICalDate(icaltime));
break;
- 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);
} else {
incidence->setSecrecy(Incidence::SecrecyPrivate);
}
+ }
break;
case ICAL_ATTACH_PROPERTY: // attachments
incidence->addAttachment(readAttachment(p));
break;
@@ -1350,15 +1347,15 @@ void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties
{
QMap<QCString, QString> customProperties;
icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY);
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) );
p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY);
}
properties->setCustomProperties(customProperties);
}
@@ -1664,14 +1661,14 @@ void ICalFormatImpl::readAlarm(icalcomponent *alarm,Incidence *incidence)
}
ialarm->addMailAddress(Person(name, email));
break;
}
// Only in AUDIO and EMAIL and PROCEDURE alarms
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 ) {
case ICAL_ACTION_AUDIO:
ialarm->setAudioFile( url );
break;
case ICAL_ACTION_PROCEDURE:
ialarm->setProgramFile( url );