summaryrefslogtreecommitdiffabout
path: root/libkcal/vcalformat.cpp
Unidiff
Diffstat (limited to 'libkcal/vcalformat.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/vcalformat.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp
index 8efc1ea..2e19740 100644
--- a/libkcal/vcalformat.cpp
+++ b/libkcal/vcalformat.cpp
@@ -299,260 +299,260 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
299 if (!anEvent->description().isEmpty()) { 299 if (!anEvent->description().isEmpty()) {
300 VObject *d = addPropValue(vtodo, VCDescriptionProp, 300 VObject *d = addPropValue(vtodo, VCDescriptionProp,
301 anEvent->description().local8Bit()); 301 anEvent->description().local8Bit());
302 if (anEvent->description().find('\n') != -1) 302 if (anEvent->description().find('\n') != -1)
303 addProp(d, VCQuotedPrintableProp); 303 addProp(d, VCQuotedPrintableProp);
304 } 304 }
305 305
306 // summary 306 // summary
307 if (!anEvent->summary().isEmpty()) 307 if (!anEvent->summary().isEmpty())
308 addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); 308 addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit());
309 309
310 if (!anEvent->location().isEmpty()) 310 if (!anEvent->location().isEmpty())
311 addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); 311 addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit());
312 312
313 // completed 313 // completed
314 // status 314 // status
315 // backward compatibility, KOrganizer used to interpret only these two values 315 // backward compatibility, KOrganizer used to interpret only these two values
316 addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : 316 addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" :
317 "NEEDS_ACTION"); 317 "NEEDS_ACTION");
318 // completion date 318 // completion date
319 if (anEvent->hasCompletedDate()) { 319 if (anEvent->hasCompletedDate()) {
320 tmpStr = qDateTimeToISO(anEvent->completed()); 320 tmpStr = qDateTimeToISO(anEvent->completed());
321 addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); 321 addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit());
322 } 322 }
323 323
324 // priority 324 // priority
325 tmpStr.sprintf("%i",anEvent->priority()); 325 tmpStr.sprintf("%i",anEvent->priority());
326 addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); 326 addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit());
327 327
328 // related event 328 // related event
329 if (anEvent->relatedToUid()) { 329 if (anEvent->relatedToUid()) {
330 addPropValue(vtodo, VCRelatedToProp, 330 addPropValue(vtodo, VCRelatedToProp,
331 anEvent->relatedToUid().local8Bit()); 331 anEvent->relatedToUid().local8Bit());
332 } 332 }
333 333
334 // categories 334 // categories
335 QStringList tmpStrList = anEvent->categories(); 335 QStringList tmpStrList = anEvent->categories();
336 tmpStr = ""; 336 tmpStr = "";
337 QString catStr; 337 QString catStr;
338 for ( QStringList::Iterator it = tmpStrList.begin(); 338 for ( QStringList::Iterator it = tmpStrList.begin();
339 it != tmpStrList.end(); 339 it != tmpStrList.end();
340 ++it ) { 340 ++it ) {
341 catStr = *it; 341 catStr = *it;
342 if (catStr[0] == ' ') 342 if (catStr[0] == ' ')
343 tmpStr += catStr.mid(1); 343 tmpStr += catStr.mid(1);
344 else 344 else
345 tmpStr += catStr; 345 tmpStr += catStr;
346 // this must be a ';' character as the vCalendar specification requires! 346 // this must be a ';' character as the vCalendar specification requires!
347 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 347 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
348 // read in. 348 // read in.
349 tmpStr += ";"; 349 tmpStr += ";";
350 } 350 }
351 if (!tmpStr.isEmpty()) { 351 if (!tmpStr.isEmpty()) {
352 tmpStr.truncate(tmpStr.length()-1); 352 tmpStr.truncate(tmpStr.length()-1);
353 addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); 353 addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit());
354 } 354 }
355 355
356 // alarm stuff 356 // alarm stuff
357 kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; 357 kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl;
358 QPtrList<Alarm> alarms = anEvent->alarms(); 358 QPtrList<Alarm> alarms = anEvent->alarms();
359 Alarm* alarm; 359 Alarm* alarm;
360 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 360 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
361 if (alarm->enabled()) { 361 if (alarm->enabled()) {
362 VObject *a; 362 VObject *a;
363 tmpStr = qDateTimeToISO(alarm->time()); 363 tmpStr = qDateTimeToISO(alarm->time());
364 if (alarm->type() == Alarm::Audio) { 364 if (alarm->type() == Alarm::Audio) {
365 a = addProp(vtodo, VCAAlarmProp); 365 a = addProp(vtodo, VCAAlarmProp);
366 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 366 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
367 addPropValue(a, VCRepeatCountProp, "1"); 367 addPropValue(a, VCRepeatCountProp, "1");
368 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); 368 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile()));
369 } 369 }
370 else if (alarm->type() == Alarm::Procedure) { 370 else if (alarm->type() == Alarm::Procedure) {
371 a = addProp(vtodo, VCPAlarmProp); 371 a = addProp(vtodo, VCPAlarmProp);
372 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 372 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
373 addPropValue(a, VCRepeatCountProp, "1"); 373 addPropValue(a, VCRepeatCountProp, "1");
374 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); 374 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile()));
375 } else { 375 } else {
376 a = addProp(vtodo, VCDAlarmProp); 376 a = addProp(vtodo, VCDAlarmProp);
377 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 377 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
378 addPropValue(a, VCRepeatCountProp, "1"); 378 addPropValue(a, VCRepeatCountProp, "1");
379 addPropValue(a, VCDisplayStringProp, "beep!"); 379 addPropValue(a, VCDisplayStringProp, "beep!");
380 } 380 }
381 } 381 }
382 } 382 }
383 383
384 if (anEvent->pilotId()) { 384 if (anEvent->pilotId()) {
385 // pilot sync stuff 385 // pilot sync stuff
386 tmpStr.sprintf("%i",anEvent->pilotId()); 386 tmpStr.sprintf("%i",anEvent->pilotId());
387 addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); 387 addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit());
388 tmpStr.sprintf("%i",anEvent->syncStatus()); 388 tmpStr.sprintf("%i",anEvent->syncStatus());
389 addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); 389 addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit());
390 } 390 }
391 391
392 return vtodo; 392 return vtodo;
393} 393}
394 394
395VObject* VCalFormat::eventToVEvent(const Event *anEvent) 395VObject* VCalFormat::eventToVEvent(Event *anEvent)
396{ 396{
397 VObject *vevent; 397 VObject *vevent;
398 QString tmpStr; 398 QString tmpStr;
399 399
400 vevent = newVObject(VCEventProp); 400 vevent = newVObject(VCEventProp);
401 401
402 // start and end time 402 // start and end time
403 tmpStr = qDateTimeToISO(anEvent->dtStart(), 403 tmpStr = qDateTimeToISO(anEvent->dtStart(),
404 !anEvent->doesFloat()); 404 !anEvent->doesFloat());
405 addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); 405 addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit());
406 406
407 // events that have time associated but take up no time should 407 // events that have time associated but take up no time should
408 // not have both DTSTART and DTEND. 408 // not have both DTSTART and DTEND.
409 if (anEvent->dtStart() != anEvent->dtEnd()) { 409 if (anEvent->dtStart() != anEvent->dtEnd()) {
410 tmpStr = qDateTimeToISO(anEvent->dtEnd(), 410 tmpStr = qDateTimeToISO(anEvent->dtEnd(),
411 !anEvent->doesFloat()); 411 !anEvent->doesFloat());
412 addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); 412 addPropValue(vevent, VCDTendProp, tmpStr.local8Bit());
413 } 413 }
414 414
415 // creation date 415 // creation date
416 tmpStr = qDateTimeToISO(anEvent->created()); 416 tmpStr = qDateTimeToISO(anEvent->created());
417 addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); 417 addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit());
418 418
419 // unique id 419 // unique id
420 addPropValue(vevent, VCUniqueStringProp, 420 addPropValue(vevent, VCUniqueStringProp,
421 anEvent->uid().local8Bit()); 421 anEvent->uid().local8Bit());
422 422
423 // revision 423 // revision
424 tmpStr.sprintf("%i", anEvent->revision()); 424 tmpStr.sprintf("%i", anEvent->revision());
425 addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); 425 addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit());
426 426
427 // last modification date 427 // last modification date
428 tmpStr = qDateTimeToISO(anEvent->lastModified()); 428 tmpStr = qDateTimeToISO(anEvent->lastModified());
429 addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); 429 addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit());
430 430
431 // attendee and organizer stuff 431 // attendee and organizer stuff
432 tmpStr = "MAILTO:" + anEvent->organizer(); 432 tmpStr = "MAILTO:" + anEvent->organizer();
433 addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); 433 addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit());
434 434
435 if (anEvent->attendeeCount() != 0) { 435 if (anEvent->attendeeCount() != 0) {
436 QPtrList<Attendee> al = anEvent->attendees(); 436 QPtrList<Attendee> al = anEvent->attendees();
437 QPtrListIterator<Attendee> ai(al); 437 QPtrListIterator<Attendee> ai(al);
438 Attendee *curAttendee; 438 Attendee *curAttendee;
439 439
440 // TODO: Put this functionality into Attendee class 440 // TODO: Put this functionality into Attendee class
441 for (; ai.current(); ++ai) { 441 for (; ai.current(); ++ai) {
442 curAttendee = ai.current(); 442 curAttendee = ai.current();
443 if (!curAttendee->email().isEmpty() && 443 if (!curAttendee->email().isEmpty() &&
444 !curAttendee->name().isEmpty()) 444 !curAttendee->name().isEmpty())
445 tmpStr = "MAILTO:" + curAttendee->name() + " <" + 445 tmpStr = "MAILTO:" + curAttendee->name() + " <" +
446 curAttendee->email() + ">"; 446 curAttendee->email() + ">";
447 else if (curAttendee->name().isEmpty()) 447 else if (curAttendee->name().isEmpty())
448 tmpStr = "MAILTO: " + curAttendee->email(); 448 tmpStr = "MAILTO: " + curAttendee->email();
449 else if (curAttendee->email().isEmpty()) 449 else if (curAttendee->email().isEmpty())
450 tmpStr = "MAILTO: " + curAttendee->name(); 450 tmpStr = "MAILTO: " + curAttendee->name();
451 else if (curAttendee->name().isEmpty() && 451 else if (curAttendee->name().isEmpty() &&
452 curAttendee->email().isEmpty()) 452 curAttendee->email().isEmpty())
453 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; 453 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl;
454 VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); 454 VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit());
455 addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); 455 addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role()));
456 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); 456 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");
457 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); 457 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status()));
458 } 458 }
459 } 459 }
460 460
461 // recurrence rule stuff 461 // recurrence rule stuff
462 if (anEvent->recurrence()->doesRecur()) { 462 if (anEvent->doesRecur()) {
463 // some more variables 463 // some more variables
464 QPtrList<Recurrence::rMonthPos> tmpPositions; 464 QPtrList<Recurrence::rMonthPos> tmpPositions;
465 QPtrList<int> tmpDays; 465 QPtrList<int> tmpDays;
466 int *tmpDay; 466 int *tmpDay;
467 Recurrence::rMonthPos *tmpPos; 467 Recurrence::rMonthPos *tmpPos;
468 QString tmpStr2; 468 QString tmpStr2;
469 int i; 469 int i;
470 470
471 switch(anEvent->recurrence()->doesRecur()) { 471 switch(anEvent->recurrence()->doesRecur()) {
472 case Recurrence::rDaily: 472 case Recurrence::rDaily:
473 tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); 473 tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency());
474// if (anEvent->rDuration > 0) 474// if (anEvent->rDuration > 0)
475 //tmpStr += "#"; 475 //tmpStr += "#";
476 break; 476 break;
477 case Recurrence::rWeekly: 477 case Recurrence::rWeekly:
478 tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); 478 tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency());
479 for (i = 0; i < 7; i++) { 479 for (i = 0; i < 7; i++) {
480 if (anEvent->recurrence()->days().testBit(i)) 480 if (anEvent->recurrence()->days().testBit(i))
481 tmpStr += dayFromNum(i); 481 tmpStr += dayFromNum(i);
482 } 482 }
483 break; 483 break;
484 case Recurrence::rMonthlyPos: 484 case Recurrence::rMonthlyPos:
485 tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); 485 tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency());
486 // write out all rMonthPos's 486 // write out all rMonthPos's
487 tmpPositions = anEvent->recurrence()->monthPositions(); 487 tmpPositions = anEvent->recurrence()->monthPositions();
488 for (tmpPos = tmpPositions.first(); 488 for (tmpPos = tmpPositions.first();
489 tmpPos; 489 tmpPos;
490 tmpPos = tmpPositions.next()) { 490 tmpPos = tmpPositions.next()) {
491 491
492 tmpStr2.sprintf("%i", tmpPos->rPos); 492 tmpStr2.sprintf("%i", tmpPos->rPos);
493 if (tmpPos->negative) 493 if (tmpPos->negative)
494 tmpStr2 += "- "; 494 tmpStr2 += "- ";
495 else 495 else
496 tmpStr2 += "+ "; 496 tmpStr2 += "+ ";
497 tmpStr += tmpStr2; 497 tmpStr += tmpStr2;
498 for (i = 0; i < 7; i++) { 498 for (i = 0; i < 7; i++) {
499 if (tmpPos->rDays.testBit(i)) 499 if (tmpPos->rDays.testBit(i))
500 tmpStr += dayFromNum(i); 500 tmpStr += dayFromNum(i);
501 } 501 }
502 } // loop for all rMonthPos's 502 } // loop for all rMonthPos's
503 break; 503 break;
504 case Recurrence::rMonthlyDay: 504 case Recurrence::rMonthlyDay:
505 tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); 505 tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency());
506 // write out all rMonthDays; 506 // write out all rMonthDays;
507 tmpDays = anEvent->recurrence()->monthDays(); 507 tmpDays = anEvent->recurrence()->monthDays();
508 for (tmpDay = tmpDays.first(); 508 for (tmpDay = tmpDays.first();
509 tmpDay; 509 tmpDay;
510 tmpDay = tmpDays.next()) { 510 tmpDay = tmpDays.next()) {
511 tmpStr2.sprintf("%i ", *tmpDay); 511 tmpStr2.sprintf("%i ", *tmpDay);
512 tmpStr += tmpStr2; 512 tmpStr += tmpStr2;
513 } 513 }
514 break; 514 break;
515 case Recurrence::rYearlyMonth: 515 case Recurrence::rYearlyMonth:
516 tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); 516 tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency());
517 // write out all the rYearNums; 517 // write out all the rYearNums;
518 tmpDays = anEvent->recurrence()->yearNums(); 518 tmpDays = anEvent->recurrence()->yearNums();
519 for (tmpDay = tmpDays.first(); 519 for (tmpDay = tmpDays.first();
520 tmpDay; 520 tmpDay;
521 tmpDay = tmpDays.next()) { 521 tmpDay = tmpDays.next()) {
522 tmpStr2.sprintf("%i ", *tmpDay); 522 tmpStr2.sprintf("%i ", *tmpDay);
523 tmpStr += tmpStr2; 523 tmpStr += tmpStr2;
524 } 524 }
525 break; 525 break;
526 case Recurrence::rYearlyDay: 526 case Recurrence::rYearlyDay:
527 tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency()); 527 tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency());
528 // write out all the rYearNums; 528 // write out all the rYearNums;
529 tmpDays = anEvent->recurrence()->yearNums(); 529 tmpDays = anEvent->recurrence()->yearNums();
530 for (tmpDay = tmpDays.first(); 530 for (tmpDay = tmpDays.first();
531 tmpDay; 531 tmpDay;
532 tmpDay = tmpDays.next()) { 532 tmpDay = tmpDays.next()) {
533 tmpStr2.sprintf("%i ", *tmpDay); 533 tmpStr2.sprintf("%i ", *tmpDay);
534 tmpStr += tmpStr2; 534 tmpStr += tmpStr2;
535 } 535 }
536 break; 536 break;
537 default: 537 default:
538 kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; 538 kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl;
539 break; 539 break;
540 } // switch 540 } // switch
541 541
542 if (anEvent->recurrence()->duration() > 0) { 542 if (anEvent->recurrence()->duration() > 0) {
543 tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); 543 tmpStr2.sprintf("#%i",anEvent->recurrence()->duration());
544 tmpStr += tmpStr2; 544 tmpStr += tmpStr2;
545 } else if (anEvent->recurrence()->duration() == -1) { 545 } else if (anEvent->recurrence()->duration() == -1) {
546 tmpStr += "#0"; // defined as repeat forever 546 tmpStr += "#0"; // defined as repeat forever
547 } else { 547 } else {
548 tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); 548 tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE);
549 } 549 }
550 addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); 550 addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit());
551 551
552 } // event repeats 552 } // event repeats
553 553
554 // exceptions to recurrence 554 // exceptions to recurrence
555 DateList dateList = anEvent->exDates(); 555 DateList dateList = anEvent->exDates();
556 DateList::ConstIterator it; 556 DateList::ConstIterator it;
557 QString tmpStr2; 557 QString tmpStr2;
558 558