summaryrefslogtreecommitdiffabout
path: root/libkcal/icalformatimpl.cpp
Unidiff
Diffstat (limited to 'libkcal/icalformatimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/icalformatimpl.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index 4794bc9..f349681 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -327,109 +327,106 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
327 break; 327 break;
328 } 328 }
329 icalcomponent_add_property(parent,icalproperty_new_class(classInt)); 329 icalcomponent_add_property(parent,icalproperty_new_class(classInt));
330 330
331 // priority 331 // priority
332 icalcomponent_add_property(parent,icalproperty_new_priority( 332 icalcomponent_add_property(parent,icalproperty_new_priority(
333 incidence->priority())); 333 incidence->priority()));
334 334
335 // categories 335 // categories
336 QStringList categories = incidence->categories(); 336 QStringList categories = incidence->categories();
337 QStringList::Iterator it; 337 QStringList::Iterator it;
338 for(it = categories.begin(); it != categories.end(); ++it ) { 338 for(it = categories.begin(); it != categories.end(); ++it ) {
339 icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); 339 icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8()));
340 } 340 }
341// TODO: Ensure correct concatenation of categories properties. 341// TODO: Ensure correct concatenation of categories properties.
342 342
343/* 343/*
344 // categories 344 // categories
345 tmpStrList = incidence->getCategories(); 345 tmpStrList = incidence->getCategories();
346 tmpStr = ""; 346 tmpStr = "";
347 QString catStr; 347 QString catStr;
348 for ( QStringList::Iterator it = tmpStrList.begin(); 348 for ( QStringList::Iterator it = tmpStrList.begin();
349 it != tmpStrList.end(); 349 it != tmpStrList.end();
350 ++it ) { 350 ++it ) {
351 catStr = *it; 351 catStr = *it;
352 if (catStr[0] == ' ') 352 if (catStr[0] == ' ')
353 tmpStr += catStr.mid(1); 353 tmpStr += catStr.mid(1);
354 else 354 else
355 tmpStr += catStr; 355 tmpStr += catStr;
356 // this must be a ';' character as the vCalendar specification requires! 356 // this must be a ';' character as the vCalendar specification requires!
357 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 357 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
358 // read in. 358 // read in.
359 tmpStr += ";"; 359 tmpStr += ";";
360 } 360 }
361 if (!tmpStr.isEmpty()) { 361 if (!tmpStr.isEmpty()) {
362 tmpStr.truncate(tmpStr.length()-1); 362 tmpStr.truncate(tmpStr.length()-1);
363 icalcomponent_add_property(parent,icalproperty_new_categories( 363 icalcomponent_add_property(parent,icalproperty_new_categories(
364 writeText(incidence->getCategories().join(";")))); 364 writeText(incidence->getCategories().join(";"))));
365 } 365 }
366*/ 366*/
367 367
368 // related event 368 // related event
369 if (!incidence->relatedToUid().isEmpty()) { 369 if (!incidence->relatedToUid().isEmpty()) {
370 icalcomponent_add_property(parent,icalproperty_new_relatedto( 370 icalcomponent_add_property(parent,icalproperty_new_relatedto(
371 incidence->relatedToUid().utf8())); 371 incidence->relatedToUid().utf8()));
372 } 372 }
373 373
374 // recurrence rule stuff 374 // recurrence rule stuff
375 Recurrence *recur = incidence->recurrence(); 375 if (incidence->doesRecur()) {
376 if (recur->doesRecur()) { 376 icalcomponent_add_property(parent,writeRecurrenceRule(incidence->recurrence()));
377
378 icalcomponent_add_property(parent,writeRecurrenceRule(recur));
379 }
380
381 // recurrence excpetion dates 377 // recurrence excpetion dates
382 DateList dateList = incidence->exDates(); 378 DateList dateList = incidence->exDates();
383 DateList::ConstIterator exIt; 379 DateList::ConstIterator exIt;
384 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { 380 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) {
385 icalcomponent_add_property(parent,icalproperty_new_exdate( 381 icalcomponent_add_property(parent,icalproperty_new_exdate(
386 writeICalDate(*exIt))); 382 writeICalDate(*exIt)));
387 } 383 }
384 }
388 385
389 // attachments 386 // attachments
390 QPtrList<Attachment> attachments = incidence->attachments(); 387 QPtrList<Attachment> attachments = incidence->attachments();
391 for (Attachment *at = attachments.first(); at; at = attachments.next()) 388 for (Attachment *at = attachments.first(); at; at = attachments.next())
392 icalcomponent_add_property(parent,writeAttachment(at)); 389 icalcomponent_add_property(parent,writeAttachment(at));
393 390
394 // alarms 391 // alarms
395 QPtrList<Alarm> alarms = incidence->alarms(); 392 QPtrList<Alarm> alarms = incidence->alarms();
396 Alarm* alarm; 393 Alarm* alarm;
397 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 394 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
398 if (alarm->enabled()) { 395 if (alarm->enabled()) {
399 kdDebug(5800) << "Write alarm for " << incidence->summary() << endl; 396 kdDebug(5800) << "Write alarm for " << incidence->summary() << endl;
400 icalcomponent_add_component(parent,writeAlarm(alarm)); 397 icalcomponent_add_component(parent,writeAlarm(alarm));
401 } 398 }
402 } 399 }
403 if( incidence->hasRecurrenceID() ) { 400 if( incidence->hasRecurrenceID() ) {
404 icalcomponent_add_property(parent, 401 icalcomponent_add_property(parent,
405 icalproperty_new_recurrenceid( writeICalDateTime( incidence->recurrenceID()))); 402 icalproperty_new_recurrenceid( writeICalDateTime( incidence->recurrenceID())));
406 } 403 }
407 // duration 404 // duration
408 405
409// turned off as it always is set to PTS0 (and must not occur together with DTEND 406// turned off as it always is set to PTS0 (and must not occur together with DTEND
410 407
411 if (incidence->hasDuration()) { 408 if (incidence->hasDuration()) {
412 icaldurationtype duration; 409 icaldurationtype duration;
413 duration = writeICalDuration(incidence->duration()); 410 duration = writeICalDuration(incidence->duration());
414 icalcomponent_add_property(parent,icalproperty_new_duration(duration)); 411 icalcomponent_add_property(parent,icalproperty_new_duration(duration));
415 } 412 }
416} 413}
417 414
418void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) 415void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase)
419{ 416{
420 icalcomponent_add_property(parent,icalproperty_new_dtstamp( 417 icalcomponent_add_property(parent,icalproperty_new_dtstamp(
421 writeICalDateTime(QDateTime::currentDateTime()))); 418 writeICalDateTime(QDateTime::currentDateTime())));
422 419
423 // organizer stuff 420 // organizer stuff
424 icalcomponent_add_property(parent,icalproperty_new_organizer( 421 icalcomponent_add_property(parent,icalproperty_new_organizer(
425 ("MAILTO:" + incidenceBase->organizer()).utf8())); 422 ("MAILTO:" + incidenceBase->organizer()).utf8()));
426 423
427 // attendees 424 // attendees
428 if (incidenceBase->attendeeCount() != 0) { 425 if (incidenceBase->attendeeCount() != 0) {
429 QPtrList<Attendee> al = incidenceBase->attendees(); 426 QPtrList<Attendee> al = incidenceBase->attendees();
430 QPtrListIterator<Attendee> ai(al); 427 QPtrListIterator<Attendee> ai(al);
431 for (; ai.current(); ++ai) { 428 for (; ai.current(); ++ai) {
432 icalcomponent_add_property(parent,writeAttendee(ai.current())); 429 icalcomponent_add_property(parent,writeAttendee(ai.current()));
433 } 430 }
434 } 431 }
435 432
@@ -1250,96 +1247,97 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence)
1250 incidence->addExDate(readICalDate(icaltime)); 1247 incidence->addExDate(readICalDate(icaltime));
1251 break; 1248 break;
1252 1249
1253 case ICAL_CLASS_PROPERTY: { 1250 case ICAL_CLASS_PROPERTY: {
1254 int inttext = icalproperty_get_class(p); 1251 int inttext = icalproperty_get_class(p);
1255 if (inttext == ICAL_CLASS_PUBLIC ) { 1252 if (inttext == ICAL_CLASS_PUBLIC ) {
1256 incidence->setSecrecy(Incidence::SecrecyPublic); 1253 incidence->setSecrecy(Incidence::SecrecyPublic);
1257 } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) { 1254 } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) {
1258 incidence->setSecrecy(Incidence::SecrecyConfidential); 1255 incidence->setSecrecy(Incidence::SecrecyConfidential);
1259 } else { 1256 } else {
1260 incidence->setSecrecy(Incidence::SecrecyPrivate); 1257 incidence->setSecrecy(Incidence::SecrecyPrivate);
1261 } 1258 }
1262 } 1259 }
1263 break; 1260 break;
1264 1261
1265 case ICAL_ATTACH_PROPERTY: // attachments 1262 case ICAL_ATTACH_PROPERTY: // attachments
1266 incidence->addAttachment(readAttachment(p)); 1263 incidence->addAttachment(readAttachment(p));
1267 break; 1264 break;
1268 1265
1269 default: 1266 default:
1270// kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind 1267// kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind
1271// << endl; 1268// << endl;
1272 break; 1269 break;
1273 } 1270 }
1274 1271
1275 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); 1272 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY);
1276 } 1273 }
1277 if ( readrec ) { 1274 if ( readrec ) {
1278 readRecurrenceRule(rectype,incidence); 1275 readRecurrenceRule(rectype,incidence);
1279 } 1276 }
1280 // kpilot stuff 1277 // kpilot stuff
1281// TODO: move this application-specific code to kpilot 1278// TODO: move this application-specific code to kpilot
1282 QString kp = incidence->nonKDECustomProperty("X-PILOTID"); 1279 QString kp = incidence->nonKDECustomProperty("X-PILOTID");
1283 if (!kp.isNull()) { 1280 if (!kp.isNull()) {
1284 incidence->setPilotId(kp.toInt()); 1281 incidence->setPilotId(kp.toInt());
1285 } 1282 }
1286 kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); 1283 kp = incidence->nonKDECustomProperty("X-PILOTSTAT");
1287 if (!kp.isNull()) { 1284 if (!kp.isNull()) {
1288 incidence->setSyncStatus(kp.toInt()); 1285 incidence->setSyncStatus(kp.toInt());
1289 } 1286 }
1290 1287
1291 1288
1292 kp = incidence->nonKDECustomProperty("X-KOPIEXTID"); 1289 kp = incidence->nonKDECustomProperty("X-KOPIEXTID");
1293 if (!kp.isNull()) { 1290 if (!kp.isNull()) {
1294 incidence->setIDStr(kp); 1291 incidence->setIDStr(kp);
1295 } 1292 }
1296 1293
1297 // Cancel backwards compatibility mode for subsequent changes by the application 1294 // Cancel backwards compatibility mode for subsequent changes by the application
1295 if ( readrec )
1298 incidence->recurrence()->setCompatVersion(); 1296 incidence->recurrence()->setCompatVersion();
1299 1297
1300 // add categories 1298 // add categories
1301 incidence->setCategories(categories); 1299 incidence->setCategories(categories);
1302 1300
1303 // iterate through all alarms 1301 // iterate through all alarms
1304 for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); 1302 for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT);
1305 alarm; 1303 alarm;
1306 alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { 1304 alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) {
1307 readAlarm(alarm,incidence); 1305 readAlarm(alarm,incidence);
1308 } 1306 }
1309} 1307}
1310 1308
1311void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) 1309void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase)
1312{ 1310{
1313 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); 1311 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY);
1314 1312
1315 while (p) { 1313 while (p) {
1316 icalproperty_kind kind = icalproperty_isa(p); 1314 icalproperty_kind kind = icalproperty_isa(p);
1317 switch (kind) { 1315 switch (kind) {
1318 1316
1319 case ICAL_UID_PROPERTY: // unique id 1317 case ICAL_UID_PROPERTY: // unique id
1320 incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); 1318 incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p)));
1321 break; 1319 break;
1322 1320
1323 case ICAL_ORGANIZER_PROPERTY: // organizer 1321 case ICAL_ORGANIZER_PROPERTY: // organizer
1324 incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); 1322 incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p)));
1325 break; 1323 break;
1326 1324
1327 case ICAL_ATTENDEE_PROPERTY: // attendee 1325 case ICAL_ATTENDEE_PROPERTY: // attendee
1328 incidenceBase->addAttendee(readAttendee(p)); 1326 incidenceBase->addAttendee(readAttendee(p));
1329 break; 1327 break;
1330 1328
1331 default: 1329 default:
1332 break; 1330 break;
1333 } 1331 }
1334 1332
1335 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); 1333 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY);
1336 } 1334 }
1337 1335
1338 // custom properties 1336 // custom properties
1339 readCustomProperties(parent, incidenceBase); 1337 readCustomProperties(parent, incidenceBase);
1340} 1338}
1341 1339
1342void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) 1340void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties)
1343{ 1341{
1344 QMap<QCString, QString> customProperties; 1342 QMap<QCString, QString> customProperties;
1345 1343