libkcal

vcalformat.cpp
1/*
2 This file is part of libkcal.
3
4 Copyright (c) 1998 Preston Brown <pbrown@kde.org>
5 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
22
23#include <tqapplication.h>
24#include <tqdatetime.h>
25#include <tqstring.h>
26#include <tqptrlist.h>
27#include <tqregexp.h>
28#include <tqclipboard.h>
29#include <tqdialog.h>
30#include <tqfile.h>
31
32#include <kdebug.h>
33#include <tdemessagebox.h>
34#include <kiconloader.h>
35#include <tdelocale.h>
36
37#include "vcc.h"
38#include "vobject.h"
39extern "C" {
40#include <libical/icaltime.h>
41#include <libical/icaltimezone.h>
42}
43#include "vcaldrag.h"
44#include "calendar.h"
45
46#include "vcalformat.h"
47
48using namespace KCal;
49
50VCalFormat::VCalFormat()
51{
52}
53
54VCalFormat::~VCalFormat()
55{
56}
57
58bool VCalFormat::load(Calendar *calendar, const TQString &fileName)
59{
60 mCalendar = calendar;
61
63
64 kdDebug(5800) << "VCalFormat::load() " << fileName << endl;
65
66 VObject *vcal = 0;
67
68 // this is not necessarily only 1 vcal. Could be many vcals, or include
69 // a vcard...
70 vcal = Parse_MIME_FromFileName(const_cast<char *>(TQFile::encodeName(fileName).data()));
71
72 if (!vcal) {
74 return FALSE;
75 }
76
77 // any other top-level calendar stuff should be added/initialized here
78
79 // put all vobjects into their proper places
80 populate(vcal);
81
82 // clean up from vcal API stuff
83 cleanVObjects(vcal);
84 cleanStrTbl();
85
86 return true;
87}
88
89
90bool VCalFormat::save(Calendar *calendar, const TQString &fileName)
91{
92 mCalendar = calendar;
93
94 TQString tmpStr;
95 VObject *vcal, *vo;
96
97 kdDebug(5800) << "VCalFormat::save(): " << fileName << endl;
98
99 vcal = newVObject(VCCalProp);
100
101 // addPropValue(vcal,VCLocationProp, "0.0");
102 addPropValue(vcal,VCProdIdProp, productId().latin1());
103 addPropValue(vcal,VCVersionProp, _VCAL_VERSION);
104
105 // TODO STUFF
106 Todo::List todoList = mCalendar->rawTodos();
107 Todo::List::ConstIterator it;
108 for ( it = todoList.begin(); it != todoList.end(); ++it ) {
109 vo = eventToVTodo( *it );
110 addVObjectProp( vcal, vo );
111 }
112
113 // EVENT STUFF
114 Event::List events = mCalendar->rawEvents();
115 Event::List::ConstIterator it2;
116 for( it2 = events.begin(); it2 != events.end(); ++it2 ) {
117 vo = eventToVEvent( *it2 );
118 addVObjectProp( vcal, vo );
119 }
120
121 writeVObjectToFile(TQFile::encodeName(fileName).data() ,vcal);
122 cleanVObjects(vcal);
123 cleanStrTbl();
124
125 if (TQFile::exists(fileName)) {
126 kdDebug(5800) << "No error" << endl;
127 return true;
128 } else {
129 kdDebug(5800) << "Error" << endl;
130 return false; // error
131 }
132
133 return false;
134}
135
136bool VCalFormat::fromString( Calendar *calendar, const TQString &text )
137{
138 // TODO: Factor out VCalFormat::fromString()
139 mCalendar = calendar;
140
141 TQCString data = text.utf8();
142
143 if ( !data.size() ) return false;
144
145 VObject *vcal = Parse_MIME( data.data(), data.size());
146 if ( !vcal ) return false;
147
148 VObjectIterator i;
149 VObject *curvo;
150 initPropIterator( &i, vcal );
151
152 // we only take the first object. TODO: parse all incidences.
153 do {
154 curvo = nextVObject( &i );
155 } while ( strcmp( vObjectName( curvo ), VCEventProp ) &&
156 strcmp( vObjectName( curvo ), VCTodoProp ) );
157
158 if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) {
159 Event *event = VEventToEvent( curvo );
160 calendar->addEvent( event );
161 } else {
162 kdDebug(5800) << "VCalFormat::fromString(): Unknown object type." << endl;
163 deleteVObject( vcal );
164 return false;
165 }
166
167 deleteVObject( vcal );
168
169 return true;
170}
171
172TQString VCalFormat::toString( Calendar *calendar )
173{
174 // TODO: Factor out VCalFormat::asString()
175 mCalendar = calendar;
176
177 VObject *vcal = newVObject(VCCalProp);
178
179 addPropValue( vcal, VCProdIdProp, CalFormat::productId().latin1() );
180 addPropValue( vcal, VCVersionProp, _VCAL_VERSION );
181
182 // TODO: Use all data.
183 Event::List events = calendar->events();
184 Event *event = events.first();
185 if ( !event ) {
186 cleanVObject( vcal );
187 return TQString();
188 }
189
190 VObject *vevent = eventToVEvent( event );
191
192 addVObjectProp( vcal, vevent );
193
194 char *buf = writeMemVObject( 0, 0, vcal );
195
196 TQString result( buf );
197
198 cleanVObject( vcal );
199
200 return result;
201}
202
203VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
204{
205 VObject *vtodo;
206 TQString tmpStr;
207
208 vtodo = newVObject(VCTodoProp);
209
210 // due date
211 if (anEvent->hasDueDate()) {
212 tmpStr = qDateTimeToISO(anEvent->dtDue(),
213 !anEvent->doesFloat());
214 addPropValue(vtodo, VCDueProp, tmpStr.local8Bit());
215 }
216
217 // start date
218 if (anEvent->hasStartDate()) {
219 tmpStr = qDateTimeToISO(anEvent->dtStart(),
220 !anEvent->doesFloat());
221 addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit());
222 }
223
224 // creation date
225 tmpStr = qDateTimeToISO(anEvent->created());
226 addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit());
227
228 // unique id
229 addPropValue(vtodo, VCUniqueStringProp,
230 anEvent->uid().local8Bit());
231
232 // revision
233 tmpStr.sprintf("%i", anEvent->revision());
234 addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit());
235
236 // last modification date
237 tmpStr = qDateTimeToISO(anEvent->lastModified());
238 addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit());
239
240 // organizer stuff
241 // @TODO: How about the common name?
242 tmpStr = "MAILTO:" + anEvent->organizer().email();
243 addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit());
244
245 // attendees
246 if ( anEvent->attendeeCount() > 0 ) {
247 Attendee::List::ConstIterator it;
248 Attendee *curAttendee;
249 for ( it = anEvent->attendees().begin(); it != anEvent->attendees().end();
250 ++it ) {
251 curAttendee = *it;
252 if (!curAttendee->email().isEmpty() &&
253 !curAttendee->name().isEmpty())
254 tmpStr = "MAILTO:" + curAttendee->name() + " <" +
255 curAttendee->email() + ">";
256 else if (curAttendee->name().isEmpty())
257 tmpStr = "MAILTO: " + curAttendee->email();
258 else if (curAttendee->email().isEmpty())
259 tmpStr = "MAILTO: " + curAttendee->name();
260 else if (curAttendee->name().isEmpty() &&
261 curAttendee->email().isEmpty())
262 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl;
263 VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit());
264 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");
265 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status()));
266 }
267 }
268
269 // description BL:
270 if (!anEvent->description().isEmpty()) {
271 VObject *d = addPropValue(vtodo, VCDescriptionProp,
272 anEvent->description().local8Bit());
273 if (anEvent->description().find('\n') != -1)
274 addPropValue(d, VCEncodingProp, VCQuotedPrintableProp);
275 }
276
277 // summary
278 if (!anEvent->summary().isEmpty())
279 addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit());
280
281 // location
282 if (!anEvent->location().isEmpty())
283 addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit());
284
285 // completed
286 // status
287 // backward compatibility, KOrganizer used to interpret only these two values
288 addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" :
289 "NEEDS_ACTION");
290 // completion date
291 if (anEvent->hasCompletedDate()) {
292 tmpStr = qDateTimeToISO(anEvent->completed());
293 addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit());
294 }
295
296 // priority
297 tmpStr.sprintf("%i",anEvent->priority());
298 addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit());
299
300 // related event
301 if (anEvent->relatedTo()) {
302 addPropValue(vtodo, VCRelatedToProp,
303 anEvent->relatedTo()->uid().local8Bit());
304 }
305
306 // categories
307 TQStringList tmpStrList = anEvent->categories();
308 tmpStr = "";
309 TQString catStr;
310 for ( TQStringList::Iterator it = tmpStrList.begin();
311 it != tmpStrList.end();
312 ++it ) {
313 catStr = *it;
314 if (catStr[0] == ' ')
315 tmpStr += catStr.mid(1);
316 else
317 tmpStr += catStr;
318 // this must be a ';' character as the vCalendar specification requires!
319 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
320 // read in.
321 tmpStr += ";";
322 }
323 if (!tmpStr.isEmpty()) {
324 tmpStr.truncate(tmpStr.length()-1);
325 addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit());
326 }
327
328 // alarm stuff
329 kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl;
330 Alarm::List::ConstIterator it;
331 for ( it = anEvent->alarms().begin(); it != anEvent->alarms().end(); ++it ) {
332 Alarm *alarm = *it;
333 if (alarm->enabled()) {
334 VObject *a = addProp(vtodo, VCDAlarmProp);
335 tmpStr = qDateTimeToISO(alarm->time());
336 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
337 addPropValue(a, VCRepeatCountProp, "1");
338 addPropValue(a, VCDisplayStringProp, "beep!");
339 if (alarm->type() == Alarm::Audio) {
340 a = addProp(vtodo, VCAAlarmProp);
341 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
342 addPropValue(a, VCRepeatCountProp, "1");
343 addPropValue(a, VCAudioContentProp, TQFile::encodeName(alarm->audioFile()));
344 }
345 else if (alarm->type() == Alarm::Procedure) {
346 a = addProp(vtodo, VCPAlarmProp);
347 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
348 addPropValue(a, VCRepeatCountProp, "1");
349 addPropValue(a, VCProcedureNameProp, TQFile::encodeName(alarm->programFile()));
350 }
351 }
352 }
353
354 if (anEvent->pilotId()) {
355 // pilot sync stuff
356 tmpStr.sprintf("%lu",anEvent->pilotId());
357 addPropValue(vtodo, KPilotIdProp, tmpStr.local8Bit());
358 tmpStr.sprintf("%i",anEvent->syncStatus());
359 addPropValue(vtodo, KPiloStatusProp, tmpStr.local8Bit());
360 }
361
362 return vtodo;
363}
364
365VObject* VCalFormat::eventToVEvent(const Event *anEvent)
366{
367 VObject *vevent;
368 TQString tmpStr;
369
370 vevent = newVObject(VCEventProp);
371
372 // start and end time
373 tmpStr = qDateTimeToISO(anEvent->dtStart(),
374 !anEvent->doesFloat());
375 addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit());
376
377 // events that have time associated but take up no time should
378 // not have both DTSTART and DTEND.
379 if (anEvent->dtStart() != anEvent->dtEnd()) {
380 tmpStr = qDateTimeToISO(anEvent->dtEnd(),
381 !anEvent->doesFloat());
382 addPropValue(vevent, VCDTendProp, tmpStr.local8Bit());
383 }
384
385 // creation date
386 tmpStr = qDateTimeToISO(anEvent->created());
387 addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit());
388
389 // unique id
390 addPropValue(vevent, VCUniqueStringProp,
391 anEvent->uid().local8Bit());
392
393 // revision
394 tmpStr.sprintf("%i", anEvent->revision());
395 addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit());
396
397 // last modification date
398 tmpStr = qDateTimeToISO(anEvent->lastModified());
399 addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit());
400
401 // attendee and organizer stuff
402 // TODO: What to do with the common name?
403 tmpStr = "MAILTO:" + anEvent->organizer().email();
404 addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit());
405
406 // TODO: Put this functionality into Attendee class
407 if ( anEvent->attendeeCount() > 0 ) {
408 Attendee::List::ConstIterator it;
409 for ( it = anEvent->attendees().begin(); it != anEvent->attendees().end();
410 ++it ) {
411 Attendee *curAttendee = *it;
412 if (!curAttendee->email().isEmpty() &&
413 !curAttendee->name().isEmpty())
414 tmpStr = "MAILTO:" + curAttendee->name() + " <" +
415 curAttendee->email() + ">";
416 else if (curAttendee->name().isEmpty())
417 tmpStr = "MAILTO: " + curAttendee->email();
418 else if (curAttendee->email().isEmpty())
419 tmpStr = "MAILTO: " + curAttendee->name();
420 else if (curAttendee->name().isEmpty() &&
421 curAttendee->email().isEmpty())
422 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl;
423 VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit());
424 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");
425 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status()));
426 }
427 }
428
429 // recurrence rule stuff
430 const Recurrence *recur = anEvent->recurrence();
431 if ( recur->doesRecur() ) {
432 bool validRecur = true;
433 TQString tmpStr2;
434 switch ( recur->recurrenceType() ) {
435 case Recurrence::rDaily:
436 tmpStr.sprintf("D%i ",recur->frequency());
437 break;
438 case Recurrence::rWeekly:
439 tmpStr.sprintf("W%i ",recur->frequency());
440 for (int i = 0; i < 7; i++ ) {
441 TQBitArray days ( recur->days() );
442 if ( days.testBit(i) )
443 tmpStr += dayFromNum(i);
444 }
445 break;
446 case Recurrence::rMonthlyPos: {
447 tmpStr.sprintf("MP%i ", recur->frequency());
448 // write out all rMonthPos's
449 TQValueList<RecurrenceRule::WDayPos> tmpPositions = recur->monthPositions();
450 for ( TQValueListConstIterator<RecurrenceRule::WDayPos> posit = tmpPositions.begin();
451 posit != tmpPositions.end(); ++posit ) {
452 int pos = (*posit).pos();
453 tmpStr2.sprintf("%i", (pos>0) ? pos : (-pos) );
454 if ( pos < 0)
455 tmpStr2 += "- ";
456 else
457 tmpStr2 += "+ ";
458 tmpStr += tmpStr2;
459 tmpStr += dayFromNum( (*posit).day() - 1 );
460 }
461 break; }
462 case Recurrence::rMonthlyDay: {
463 tmpStr.sprintf("MD%i ", recur->frequency());
464 // write out all rMonthDays;
465 TQValueList<int> tmpDays = recur->monthDays();
466 for ( TQValueListIterator<int> tmpDay = tmpDays.begin();
467 tmpDay != tmpDays.end(); ++tmpDay ) {
468 tmpStr2.sprintf( "%i ", *tmpDay );
469 tmpStr += tmpStr2;
470 }
471 break; }
472 case Recurrence::rYearlyMonth: {
473 tmpStr.sprintf("YM%i ", recur->frequency());
474 // write out all the months;'
475 // TODO: Any way to write out the day within the month???
476 TQValueList<int> months = recur->yearMonths();
477 for ( TQValueListIterator<int> mit = months.begin();
478 mit != months.end(); ++mit ) {
479 tmpStr2.sprintf( "%i ", *mit );
480 tmpStr += tmpStr2;
481 }
482 break; }
483 case Recurrence::rYearlyDay: {
484 tmpStr.sprintf("YD%i ", recur->frequency());
485 // write out all the rYearNums;
486 TQValueList<int> tmpDays = recur->yearDays();
487 for ( TQValueListIterator<int> tmpDay = tmpDays.begin();
488 tmpDay != tmpDays.end(); ++tmpDay ) {
489 tmpStr2.sprintf( "%i ", *tmpDay );
490 tmpStr += tmpStr2;
491 }
492 break; }
493 default:
494 // TODO: Write rYearlyPos and arbitrary rules!
495 kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl;
496 validRecur = false;
497 break;
498 } // switch
499
500 if (recur->duration() > 0) {
501 tmpStr2.sprintf("#%i",recur->duration());
502 tmpStr += tmpStr2;
503 } else if (recur->duration() == -1) {
504 tmpStr += "#0"; // defined as repeat forever
505 } else {
506 tmpStr += qDateTimeToISO(recur->endDateTime(), FALSE);
507 }
508 // Only write out the rrule if we have a valid recurrence (i.e. a known
509 // type in thee switch above)
510 if ( validRecur )
511 addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit());
512
513 } // event repeats
514
515 // exceptions to recurrence
516 DateList dateList = recur->exDates();
517 DateList::ConstIterator it;
518 TQString tmpStr2;
519
520 for (it = dateList.begin(); it != dateList.end(); ++it) {
521 tmpStr = qDateToISO(*it) + ";";
522 tmpStr2 += tmpStr;
523 }
524 if (!tmpStr2.isEmpty()) {
525 tmpStr2.truncate(tmpStr2.length()-1);
526 addPropValue(vevent, VCExDateProp, tmpStr2.local8Bit());
527 }
528
529 // description
530 if (!anEvent->description().isEmpty()) {
531 VObject *d = addPropValue(vevent, VCDescriptionProp,
532 anEvent->description().local8Bit());
533 if (anEvent->description().find('\n') != -1)
534 addPropValue(d, VCEncodingProp, VCQuotedPrintableProp);
535 }
536
537 // summary
538 if (!anEvent->summary().isEmpty())
539 addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit());
540
541 // location
542 if (!anEvent->location().isEmpty())
543 addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit());
544
545 // status
546// TODO: define Event status
547// addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit());
548
549 // secrecy
550 const char *text = 0;
551 switch (anEvent->secrecy()) {
552 case Incidence::SecrecyPublic:
553 text = "PUBLIC";
554 break;
555 case Incidence::SecrecyPrivate:
556 text = "PRIVATE";
557 break;
558 case Incidence::SecrecyConfidential:
559 text = "CONFIDENTIAL";
560 break;
561 }
562 if (text) {
563 addPropValue(vevent, VCClassProp, text);
564 }
565
566 // categories
567 TQStringList tmpStrList = anEvent->categories();
568 tmpStr = "";
569 TQString catStr;
570 for ( TQStringList::Iterator it = tmpStrList.begin();
571 it != tmpStrList.end();
572 ++it ) {
573 catStr = *it;
574 if (catStr[0] == ' ')
575 tmpStr += catStr.mid(1);
576 else
577 tmpStr += catStr;
578 // this must be a ';' character as the vCalendar specification requires!
579 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
580 // read in.
581 tmpStr += ";";
582 }
583 if (!tmpStr.isEmpty()) {
584 tmpStr.truncate(tmpStr.length()-1);
585 addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit());
586 }
587
588 // attachments
589 // TODO: handle binary attachments!
590 Attachment::List attachments = anEvent->attachments();
591 Attachment::List::ConstIterator atIt;
592 for ( atIt = attachments.begin(); atIt != attachments.end(); ++atIt )
593 addPropValue( vevent, VCAttachProp, (*atIt)->uri().local8Bit() );
594
595 // resources
596 tmpStrList = anEvent->resources();
597 tmpStr = tmpStrList.join(";");
598 if (!tmpStr.isEmpty())
599 addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit());
600
601 // alarm stuff
602 Alarm::List::ConstIterator it2;
603 for ( it2 = anEvent->alarms().begin(); it2 != anEvent->alarms().end(); ++it2 ) {
604 Alarm *alarm = *it2;
605 if (alarm->enabled()) {
606 VObject *a = addProp(vevent, VCDAlarmProp);
607 tmpStr = qDateTimeToISO(alarm->time());
608 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
609 addPropValue(a, VCRepeatCountProp, "1");
610 addPropValue(a, VCDisplayStringProp, "beep!");
611 if (alarm->type() == Alarm::Audio) {
612 a = addProp(vevent, VCAAlarmProp);
613 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
614 addPropValue(a, VCRepeatCountProp, "1");
615 addPropValue(a, VCAudioContentProp, TQFile::encodeName(alarm->audioFile()));
616 }
617 if (alarm->type() == Alarm::Procedure) {
618 a = addProp(vevent, VCPAlarmProp);
619 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
620 addPropValue(a, VCRepeatCountProp, "1");
621 addPropValue(a, VCProcedureNameProp, TQFile::encodeName(alarm->programFile()));
622 }
623 }
624 }
625
626 // priority
627 tmpStr.sprintf("%i",anEvent->priority());
628 addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit());
629
630 // transparency
631 tmpStr.sprintf("%i",anEvent->transparency());
632 addPropValue(vevent, VCTranspProp, tmpStr.local8Bit());
633
634 // related event
635 if (anEvent->relatedTo()) {
636 addPropValue(vevent, VCRelatedToProp,
637 anEvent->relatedTo()->uid().local8Bit());
638 }
639
640 if (anEvent->pilotId()) {
641 // pilot sync stuff
642 tmpStr.sprintf("%lu",anEvent->pilotId());
643 addPropValue(vevent, KPilotIdProp, tmpStr.local8Bit());
644 tmpStr.sprintf("%i",anEvent->syncStatus());
645 addPropValue(vevent, KPiloStatusProp, tmpStr.local8Bit());
646 }
647
648 return vevent;
649}
650
652{
653 VObject *vo;
654 VObjectIterator voi;
655 char *s;
656
657 Todo *anEvent = new Todo;
658
659 // creation date
660 if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) {
661 anEvent->setCreated(ISOToTQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
662 deleteStr(s);
663 }
664
665 // unique id
666 vo = isAPropertyOf(vtodo, VCUniqueStringProp);
667 // while the UID property is preferred, it is not required. We'll use the
668 // default Event UID if none is given.
669 if (vo) {
670 anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo)));
671 deleteStr(s);
672 }
673
674 // last modification date
675 if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) {
676 anEvent->setLastModified(ISOToTQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
677 deleteStr(s);
678 }
679 else
680 anEvent->setLastModified(TQDateTime(TQDate::currentDate(),
681 TQTime::currentTime()));
682
683 // organizer
684 // if our extension property for the event's ORGANIZER exists, add it.
685 if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) {
686 anEvent->setOrganizer( s = fakeCString(vObjectUStringZValue(vo) ) );
687 deleteStr(s);
688 } else {
689 anEvent->setOrganizer( mCalendar->getOwner() );
690 }
691
692 // attendees.
693 initPropIterator(&voi, vtodo);
694 while (moreIteration(&voi)) {
695 vo = nextVObject(&voi);
696 if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) {
697 Attendee *a;
698 VObject *vp;
699 s = fakeCString(vObjectUStringZValue(vo));
700 TQString tmpStr = TQString::fromLocal8Bit(s);
701 deleteStr(s);
702 tmpStr = tmpStr.simplifyWhiteSpace();
703 int emailPos1, emailPos2;
704 if ((emailPos1 = tmpStr.find('<')) > 0) {
705 // both email address and name
706 emailPos2 = tmpStr.findRev('>');
707 a = new Attendee(tmpStr.left(emailPos1 - 1),
708 tmpStr.mid(emailPos1 + 1,
709 emailPos2 - (emailPos1 + 1)));
710 } else if (tmpStr.find('@') > 0) {
711 // just an email address
712 a = new Attendee(0, tmpStr);
713 } else {
714 // just a name
715 // WTF??? Replacing the spaces of a name and using this as email?
716 TQString email = tmpStr.replace( ' ', '.' );
717 a = new Attendee(tmpStr,email);
718 }
719
720 // is there an RSVP property?
721 if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0)
722 a->setRSVP(vObjectStringZValue(vp));
723 // is there a status property?
724 if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0)
725 a->setStatus(readStatus(vObjectStringZValue(vp)));
726 // add the attendee
727 anEvent->addAttendee(a);
728 }
729 }
730
731 // description for todo
732 if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) {
733 s = fakeCString(vObjectUStringZValue(vo));
734 anEvent->setDescription(TQString::fromLocal8Bit(s));
735 deleteStr(s);
736 }
737
738 // summary
739 if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) {
740 s = fakeCString(vObjectUStringZValue(vo));
741 anEvent->setSummary(TQString::fromLocal8Bit(s));
742 deleteStr(s);
743 }
744
745
746 // location
747 if ((vo = isAPropertyOf(vtodo, VCLocationProp)) != 0) {
748 s = fakeCString(vObjectUStringZValue(vo));
749 anEvent->setLocation( TQString::fromLocal8Bit(s) );
750 deleteStr(s);
751 }
752 // completed
753 // was: status
754 if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) {
755 s = fakeCString(vObjectUStringZValue(vo));
756 if (strcmp(s,"COMPLETED") == 0) {
757 anEvent->setCompleted(true);
758 } else {
759 anEvent->setCompleted(false);
760 }
761 deleteStr(s);
762 }
763 else
764 anEvent->setCompleted(false);
765
766 // completion date
767 if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) {
768 anEvent->setCompleted(ISOToTQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
769 deleteStr(s);
770 }
771
772 // priority
773 if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) {
774 anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo))));
775 deleteStr(s);
776 }
777
778 // due date
779 if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) {
780 anEvent->setDtDue(ISOToTQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
781 deleteStr(s);
782 anEvent->setHasDueDate(true);
783 } else {
784 anEvent->setHasDueDate(false);
785 }
786
787 // start time
788 if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) {
789 anEvent->setDtStart(ISOToTQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
790 // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToTQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl;
791 deleteStr(s);
792 anEvent->setHasStartDate(true);
793 } else {
794 anEvent->setHasStartDate(false);
795 }
796
797 /* alarm stuff */
798 //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl;
799 if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) {
800 Alarm* alarm = anEvent->newAlarm();
801 VObject *a;
802 if ((a = isAPropertyOf(vo, VCRunTimeProp))) {
803 alarm->setTime(ISOToTQDateTime(s = fakeCString(vObjectUStringZValue(a))));
804 deleteStr(s);
805 }
806 alarm->setEnabled(true);
807 if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) {
808 if ((a = isAPropertyOf(vo, VCProcedureNameProp))) {
809 s = fakeCString(vObjectUStringZValue(a));
810 alarm->setProcedureAlarm(TQFile::decodeName(s));
811 deleteStr(s);
812 }
813 }
814 if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) {
815 if ((a = isAPropertyOf(vo, VCAudioContentProp))) {
816 s = fakeCString(vObjectUStringZValue(a));
817 alarm->setAudioAlarm(TQFile::decodeName(s));
818 deleteStr(s);
819 }
820 }
821 }
822
823 // related todo
824 if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) {
825 anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo)));
826 deleteStr(s);
827 mTodosRelate.append(anEvent);
828 }
829
830 // categories
831 if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) {
832 s = fakeCString(vObjectUStringZValue(vo));
833 TQString categories = TQString::fromLocal8Bit(s);
834 deleteStr(s);
835 TQStringList tmpStrList = TQStringList::split( ';', categories );
836 anEvent->setCategories(tmpStrList);
837 }
838
839 /* PILOT SYNC STUFF */
840 if ((vo = isAPropertyOf(vtodo, KPilotIdProp))) {
841 anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo))));
842 deleteStr(s);
843 }
844 else
845 anEvent->setPilotId(0);
846
847 if ((vo = isAPropertyOf(vtodo, KPiloStatusProp))) {
848 anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo))));
849 deleteStr(s);
850 }
851 else
852 anEvent->setSyncStatus(Event::SYNCMOD);
853
854 return anEvent;
855}
856
858{
859 VObject *vo;
860 VObjectIterator voi;
861 char *s;
862
863 Event *anEvent = new Event;
864
865 // creation date
866 if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) {
867 anEvent->setCreated(ISOToTQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
868 deleteStr(s);
869 }
870
871 // unique id
872 vo = isAPropertyOf(vevent, VCUniqueStringProp);
873 // while the UID property is preferred, it is not required. We'll use the
874 // default Event UID if none is given.
875 if (vo) {
876 anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo)));
877 deleteStr(s);
878 }
879
880 // revision
881 // again NSCAL doesn't give us much to work with, so we improvise...
882 if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) {
883 anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo))));
884 deleteStr(s);
885 }
886 else
887 anEvent->setRevision(0);
888
889 // last modification date
890 if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) {
891 anEvent->setLastModified(ISOToTQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
892 deleteStr(s);
893 }
894 else
895 anEvent->setLastModified(TQDateTime(TQDate::currentDate(),
896 TQTime::currentTime()));
897
898 // organizer
899 // if our extension property for the event's ORGANIZER exists, add it.
900 if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) {
901 // FIXME: Also use the full name, not just the email address
902 anEvent->setOrganizer( s = fakeCString(vObjectUStringZValue(vo) ) );
903 deleteStr(s);
904 } else {
905 anEvent->setOrganizer( mCalendar->getOwner() );
906 }
907
908 // deal with attendees.
909 initPropIterator(&voi, vevent);
910 while (moreIteration(&voi)) {
911 vo = nextVObject(&voi);
912 if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) {
913 Attendee *a;
914 VObject *vp;
915 s = fakeCString(vObjectUStringZValue(vo));
916 TQString tmpStr = TQString::fromLocal8Bit(s);
917 deleteStr(s);
918 tmpStr = tmpStr.simplifyWhiteSpace();
919 int emailPos1, emailPos2;
920 if ((emailPos1 = tmpStr.find('<')) > 0) {
921 // both email address and name
922 emailPos2 = tmpStr.findRev('>');
923 a = new Attendee(tmpStr.left(emailPos1 - 1),
924 tmpStr.mid(emailPos1 + 1,
925 emailPos2 - (emailPos1 + 1)));
926 } else if (tmpStr.find('@') > 0) {
927 // just an email address
928 a = new Attendee(0, tmpStr);
929 } else {
930 // just a name
931 TQString email = tmpStr.replace( ' ', '.' );
932 a = new Attendee(tmpStr,email);
933 }
934
935 // is there an RSVP property?
936 if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0)
937 a->setRSVP(vObjectStringZValue(vp));
938 // is there a status property?
939 if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0)
940 a->setStatus(readStatus(vObjectStringZValue(vp)));
941 // add the attendee
942 anEvent->addAttendee(a);
943 }
944 }
945
946 // This isn't strictly true. An event that doesn't have a start time
947 // or an end time doesn't "float", it has an anchor in time but it doesn't
948 // "take up" any time.
949 /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) ||
950 (isAPropertyOf(vevent, VCDTendProp) == 0)) {
951 anEvent->setFloats(TRUE);
952 } else {
953 }*/
954
955 anEvent->setFloats(FALSE);
956
957 // start time
958 if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) {
959 anEvent->setDtStart(ISOToTQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
960 // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToTQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl;
961 deleteStr(s);
962 if (anEvent->dtStart().time().isNull())
963 anEvent->setFloats(TRUE);
964 }
965
966 // stop time
967 if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) {
968 anEvent->setDtEnd(ISOToTQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
969 deleteStr(s);
970 if (anEvent->dtEnd().time().isNull())
971 anEvent->setFloats(TRUE);
972 }
973
974 // at this point, there should be at least a start or end time.
975 // fix up for events that take up no time but have a time associated
976 if (!(vo = isAPropertyOf(vevent, VCDTstartProp)))
977 anEvent->setDtStart(anEvent->dtEnd());
978 if (!(vo = isAPropertyOf(vevent, VCDTendProp)))
979 anEvent->setDtEnd(anEvent->dtStart());
980
982
983 // repeat stuff
984 if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) {
985 TQString tmpStr = (s = fakeCString(vObjectUStringZValue(vo)));
986 deleteStr(s);
987 tmpStr.simplifyWhiteSpace();
988 tmpStr = tmpStr.upper();
989// kdDebug() <<" We have a recurrence rule: " << tmpStr<< endl;
990
991 // first, read the type of the recurrence
992 int typelen = 1;
993 uint type = Recurrence::rNone;
994 if ( tmpStr.left(1) == "D") {
995 type = Recurrence::rDaily;
996 } else if ( tmpStr.left(1) == "W") {
997 type = Recurrence::rWeekly;
998 } else {
999 typelen = 2;
1000 if ( tmpStr.left(2) == "MP") {
1001 type = Recurrence::rMonthlyPos;
1002 } else if ( tmpStr.left(2) == "MD" ) {
1003 type = Recurrence::rMonthlyDay;
1004 } else if ( tmpStr.left(2) == "YM" ) {
1005 type = Recurrence::rYearlyMonth;
1006 } else if ( tmpStr.left(2) == "YD" ) {
1007 type = Recurrence::rYearlyDay;
1008 }
1009 }
1010
1011 if ( type != Recurrence::rNone ) {
1012// kdDebug() << " It's a supported type " << endl;
1013
1014 // Immediately after the type is the frequency
1015 int index = tmpStr.find(' ');
1016 int last = tmpStr.findRev(' ') + 1; // find last entry
1017 int rFreq = tmpStr.mid(typelen, (index-1)).toInt();
1018 ++index; // advance to beginning of stuff after freq
1019
1020 // Read the type-specific settings
1021 switch ( type ) {
1022 case Recurrence::rDaily:
1023 anEvent->recurrence()->setDaily(rFreq);
1024 break;
1025
1026 case Recurrence::rWeekly: {
1027 TQBitArray qba(7);
1028 TQString dayStr;
1029 if( index == last ) {
1030 // e.g. W1 #0
1031 qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1);
1032 }
1033 else {
1034 // e.g. W1 SU #0
1035 while (index < last) {
1036 dayStr = tmpStr.mid(index, 3);
1037 int dayNum = numFromDay(dayStr);
1038 qba.setBit(dayNum);
1039 index += 3; // advance to next day, or possibly "#"
1040 }
1041 }
1042 anEvent->recurrence()->setWeekly( rFreq, qba );
1043 break; }
1044
1045 case Recurrence::rMonthlyPos: {
1046 anEvent->recurrence()->setMonthly( rFreq );
1047
1048 TQBitArray qba(7);
1049 short tmpPos;
1050 if( index == last ) {
1051 // e.g. MP1 #0
1052 tmpPos = anEvent->dtStart().date().day()/7 + 1;
1053 if( tmpPos == 5 )
1054 tmpPos = -1;
1055 qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1);
1056 anEvent->recurrence()->addMonthlyPos( tmpPos, qba );
1057 }
1058 else {
1059 // e.g. MP1 1+ SU #0
1060 while (index < last) {
1061 tmpPos = tmpStr.mid(index,1).toShort();
1062 index += 1;
1063 if (tmpStr.mid(index,1) == "-")
1064 // convert tmpPos to negative
1065 tmpPos = 0 - tmpPos;
1066 index += 2; // advance to day(s)
1067 while (numFromDay(tmpStr.mid(index,3)) >= 0) {
1068 int dayNum = numFromDay(tmpStr.mid(index,3));
1069 qba.setBit(dayNum);
1070 index += 3; // advance to next day, or possibly pos or "#"
1071 }
1072 anEvent->recurrence()->addMonthlyPos( tmpPos, qba );
1073 qba.detach();
1074 qba.fill(FALSE); // clear out
1075 } // while != "#"
1076 }
1077 break;}
1078
1079 case Recurrence::rMonthlyDay:
1080 anEvent->recurrence()->setMonthly( rFreq );
1081 if( index == last ) {
1082 // e.g. MD1 #0
1083 short tmpDay = anEvent->dtStart().date().day();
1084 anEvent->recurrence()->addMonthlyDate( tmpDay );
1085 }
1086 else {
1087 // e.g. MD1 3 #0
1088 while (index < last) {
1089 int index2 = tmpStr.find(' ', index);
1090 short tmpDay = tmpStr.mid(index, (index2-index)).toShort();
1091 index = index2-1;
1092 if (tmpStr.mid(index, 1) == "-")
1093 tmpDay = 0 - tmpDay;
1094 index += 2; // advance the index;
1095 anEvent->recurrence()->addMonthlyDate( tmpDay );
1096 } // while != #
1097 }
1098 break;
1099
1100 case Recurrence::rYearlyMonth:
1101 anEvent->recurrence()->setYearly( rFreq );
1102
1103 if( index == last ) {
1104 // e.g. YM1 #0
1105 short tmpMonth = anEvent->dtStart().date().month();
1106 anEvent->recurrence()->addYearlyMonth( tmpMonth );
1107 }
1108 else {
1109 // e.g. YM1 3 #0
1110 while (index < last) {
1111 int index2 = tmpStr.find(' ', index);
1112 short tmpMonth = tmpStr.mid(index, (index2-index)).toShort();
1113 index = index2 + 1;
1114 anEvent->recurrence()->addYearlyMonth( tmpMonth );
1115 } // while != #
1116 }
1117 break;
1118
1119 case Recurrence::rYearlyDay:
1120 anEvent->recurrence()->setYearly( rFreq );
1121
1122 if( index == last ) {
1123 // e.g. YD1 #0
1124 short tmpDay = anEvent->dtStart().date().dayOfYear();
1125 anEvent->recurrence()->addYearlyDay( tmpDay );
1126 }
1127 else {
1128 // e.g. YD1 123 #0
1129 while (index < last) {
1130 int index2 = tmpStr.find(' ', index);
1131 short tmpDay = tmpStr.mid(index, (index2-index)).toShort();
1132 index = index2+1;
1133 anEvent->recurrence()->addYearlyDay( tmpDay );
1134 } // while != #
1135 }
1136 break;
1137
1138 default: break;
1139 }
1140
1141 // find the last field, which is either the duration or the end date
1142 index = last;
1143 if ( tmpStr.mid(index,1) == "#") {
1144 // Nr of occurrences
1145 index++;
1146 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1147 if ( rDuration > 0 )
1148 anEvent->recurrence()->setDuration( rDuration );
1149 } else if ( tmpStr.find('T', index) != -1 ) {
1150 TQDate rEndDate = (ISOToTQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
1151 anEvent->recurrence()->setEndDateTime( rEndDate );
1152 }
1153// anEvent->recurrence()->dump();
1154
1155 } else {
1156 kdDebug(5800) << "we don't understand this type of recurrence!" << endl;
1157 } // if known recurrence type
1158 } // repeats
1159
1160
1161 // recurrence exceptions
1162 if ((vo = isAPropertyOf(vevent, VCExDateProp)) != 0) {
1163 s = fakeCString(vObjectUStringZValue(vo));
1164 TQStringList exDates = TQStringList::split(",",s);
1165 TQStringList::ConstIterator it;
1166 for(it = exDates.begin(); it != exDates.end(); ++it ) {
1167 anEvent->recurrence()->addExDate(ISOToTQDate(*it));
1168 }
1169 deleteStr(s);
1170 }
1171
1172 // summary
1173 if ((vo = isAPropertyOf(vevent, VCSummaryProp))) {
1174 s = fakeCString(vObjectUStringZValue(vo));
1175 anEvent->setSummary(TQString::fromLocal8Bit(s));
1176 deleteStr(s);
1177 }
1178
1179 // description
1180 if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) {
1181 s = fakeCString(vObjectUStringZValue(vo));
1182 if (!anEvent->description().isEmpty()) {
1183 anEvent->setDescription(anEvent->description() + "\n" +
1184 TQString::fromLocal8Bit(s));
1185 } else {
1186 anEvent->setDescription(TQString::fromLocal8Bit(s));
1187 }
1188 deleteStr(s);
1189 }
1190
1191 // location
1192 if ((vo = isAPropertyOf(vevent, VCLocationProp)) != 0) {
1193 s = fakeCString(vObjectUStringZValue(vo));
1194 anEvent->setLocation( TQString::fromLocal8Bit(s) );
1195 deleteStr(s);
1196 }
1197
1198 // some stupid vCal exporters ignore the standard and use Description
1199 // instead of Summary for the default field. Correct for this.
1200 if (anEvent->summary().isEmpty() &&
1201 !(anEvent->description().isEmpty())) {
1202 TQString tmpStr = anEvent->description().simplifyWhiteSpace();
1203 anEvent->setDescription("");
1204 anEvent->setSummary(tmpStr);
1205 }
1206
1207#if 0
1208 // status
1209 if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) {
1210 TQString tmpStr(s = fakeCString(vObjectUStringZValue(vo)));
1211 deleteStr(s);
1212// TODO: Define Event status
1213// anEvent->setStatus(tmpStr);
1214 }
1215 else
1216// anEvent->setStatus("NEEDS ACTION");
1217#endif
1218
1219 // secrecy
1220 int secrecy = Incidence::SecrecyPublic;
1221 if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) {
1222 s = fakeCString(vObjectUStringZValue(vo));
1223 if (strcmp(s,"PRIVATE") == 0) {
1224 secrecy = Incidence::SecrecyPrivate;
1225 } else if (strcmp(s,"CONFIDENTIAL") == 0) {
1226 secrecy = Incidence::SecrecyConfidential;
1227 }
1228 deleteStr(s);
1229 }
1230 anEvent->setSecrecy(secrecy);
1231
1232 // categories
1233 if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) {
1234 s = fakeCString(vObjectUStringZValue(vo));
1235 TQString categories = TQString::fromLocal8Bit(s);
1236 deleteStr(s);
1237 TQStringList tmpStrList = TQStringList::split( ',', categories );
1238 anEvent->setCategories(tmpStrList);
1239 }
1240
1241 // attachments
1242 initPropIterator(&voi, vevent);
1243 while (moreIteration(&voi)) {
1244 vo = nextVObject(&voi);
1245 if (strcmp(vObjectName(vo), VCAttachProp) == 0) {
1246 s = fakeCString(vObjectUStringZValue(vo));
1247 anEvent->addAttachment(new Attachment(TQString(s)));
1248 deleteStr(s);
1249 }
1250 }
1251
1252 // resources
1253 if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) {
1254 TQString resources = (s = fakeCString(vObjectUStringZValue(vo)));
1255 deleteStr(s);
1256 TQStringList tmpStrList = TQStringList::split( ';', resources );
1257 anEvent->setResources(tmpStrList);
1258 }
1259
1260 /* alarm stuff */
1261 if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) {
1262 Alarm* alarm = anEvent->newAlarm();
1263 VObject *a;
1264 if ((a = isAPropertyOf(vo, VCRunTimeProp))) {
1265 alarm->setTime(ISOToTQDateTime(s = fakeCString(vObjectUStringZValue(a))));
1266 deleteStr(s);
1267 }
1268 alarm->setEnabled(true);
1269 if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) {
1270 if ((a = isAPropertyOf(vo, VCProcedureNameProp))) {
1271 s = fakeCString(vObjectUStringZValue(a));
1272 alarm->setProcedureAlarm(TQFile::decodeName(s));
1273 deleteStr(s);
1274 }
1275 }
1276 if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) {
1277 if ((a = isAPropertyOf(vo, VCAudioContentProp))) {
1278 s = fakeCString(vObjectUStringZValue(a));
1279 alarm->setAudioAlarm(TQFile::decodeName(s));
1280 deleteStr(s);
1281 }
1282 }
1283 }
1284
1285 // priority
1286 if ((vo = isAPropertyOf(vevent, VCPriorityProp))) {
1287 anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo))));
1288 deleteStr(s);
1289 }
1290
1291 // transparency
1292 if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) {
1293 int i = atoi(s = fakeCString(vObjectUStringZValue(vo)));
1294 anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque );
1295 deleteStr(s);
1296 }
1297
1298 // related event
1299 if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) {
1300 anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo)));
1301 deleteStr(s);
1302 mEventsRelate.append(anEvent);
1303 }
1304
1305 /* PILOT SYNC STUFF */
1306 if ((vo = isAPropertyOf(vevent, KPilotIdProp))) {
1307 anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo))));
1308 deleteStr(s);
1309 }
1310 else
1311 anEvent->setPilotId(0);
1312
1313 if ((vo = isAPropertyOf(vevent, KPiloStatusProp))) {
1314 anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo))));
1315 deleteStr(s);
1316 }
1317 else
1318 anEvent->setSyncStatus(Event::SYNCMOD);
1319
1320 return anEvent;
1321}
1322
1323
1324TQString VCalFormat::qDateToISO(const TQDate &qd)
1325{
1326 TQString tmpStr;
1327
1328 Q_ASSERT(qd.isValid());
1329
1330 tmpStr.sprintf("%.2d%.2d%.2d",
1331 qd.year(), qd.month(), qd.day());
1332 return tmpStr;
1333
1334}
1335
1336/* Return the offset of the named zone as seconds. tt is a time
1337 indicating the date for which you want the offset */
1338int vcaltime_utc_offset( TQDateTime ictt, TQString tzid )
1339{
1340 // libical-0.23 stuff:
1341 // struct icaltimetype tt = icaltime_from_timet( ictt.toTime_t(), false );
1342 // return icaltime_utc_offset( tt, tzid.latin1() );
1343 int daylight;
1344 struct icaltimetype tt = icaltime_from_timet_with_zone( ictt.toTime_t(), false, NULL);
1345 return icaltimezone_get_utc_offset(
1346 icaltimezone_get_builtin_timezone( tzid.latin1() ),
1347 &tt, &daylight );
1348}
1349
1350TQString VCalFormat::qDateTimeToISO(const TQDateTime &qdt, bool zulu)
1351{
1352 TQString tmpStr;
1353
1354 Q_ASSERT(qdt.date().isValid());
1355 Q_ASSERT(qdt.time().isValid());
1356 if (zulu) {
1357 TQDateTime tmpDT(qdt);
1358 // correct to GMT:
1359 tmpDT = tmpDT.addSecs(-vcaltime_utc_offset( tmpDT, mCalendar->timeZoneId()));
1360 tmpStr.sprintf( "%.2d%.2d%.2dT%.2d%.2d%.2dZ",
1361 tmpDT.date().year(), tmpDT.date().month(),
1362 tmpDT.date().day(), tmpDT.time().hour(),
1363 tmpDT.time().minute(), tmpDT.time().second());
1364 } else {
1365 tmpStr.sprintf( "%.2d%.2d%.2dT%.2d%.2d%.2d",
1366 qdt.date().year(), qdt.date().month(),
1367 qdt.date().day(), qdt.time().hour(),
1368 qdt.time().minute(), qdt.time().second());
1369 }
1370 return tmpStr;
1371}
1372
1373TQDateTime VCalFormat::ISOToTQDateTime(const TQString & dtStr)
1374{
1375 TQDate tmpDate;
1376 TQTime tmpTime;
1377 TQString tmpStr;
1378 int year, month, day, hour, minute, second;
1379
1380 tmpStr = dtStr;
1381 year = tmpStr.left(4).toInt();
1382 month = tmpStr.mid(4,2).toInt();
1383 day = tmpStr.mid(6,2).toInt();
1384 hour = tmpStr.mid(9,2).toInt();
1385 minute = tmpStr.mid(11,2).toInt();
1386 second = tmpStr.mid(13,2).toInt();
1387 tmpDate.setYMD(year, month, day);
1388 tmpTime.setHMS(hour, minute, second);
1389
1390 Q_ASSERT(tmpDate.isValid());
1391 Q_ASSERT(tmpTime.isValid());
1392 TQDateTime tmpDT(tmpDate, tmpTime);
1393 // correct for GMT if string is in Zulu format
1394 if (dtStr.at(dtStr.length()-1) == 'Z') {
1395 tmpDT = tmpDT.addSecs(vcaltime_utc_offset( tmpDT, mCalendar->timeZoneId()));
1396 }
1397 return tmpDT;
1398}
1399
1400TQDate VCalFormat::ISOToTQDate(const TQString &dateStr)
1401{
1402 int year, month, day;
1403
1404 year = dateStr.left(4).toInt();
1405 month = dateStr.mid(4,2).toInt();
1406 day = dateStr.mid(6,2).toInt();
1407
1408 return(TQDate(year, month, day));
1409}
1410
1411// take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc.
1412// and break it down from it's tree-like format into the dictionary format
1413// that is used internally in the VCalFormat.
1414void VCalFormat::populate(VObject *vcal)
1415{
1416 // this function will populate the caldict dictionary and other event
1417 // lists. It turns vevents into Events and then inserts them.
1418
1419 VObjectIterator i;
1420 VObject *curVO, *curVOProp;
1421 Event *anEvent;
1422
1423 if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) {
1424 char *methodType = 0;
1425 methodType = fakeCString(vObjectUStringZValue(curVO));
1426 kdDebug(5800) << "This calendar is an iTIP transaction of type '"
1427 << methodType << "'" << endl;
1428 deleteStr(methodType);
1429 }
1430
1431 // warn the user that we might have trouble reading non-known calendar.
1432 if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) {
1433 char *s = fakeCString(vObjectUStringZValue(curVO));
1434 if (strcmp(productId().local8Bit(), s) != 0)
1435 kdDebug(5800) << "This vCalendar file was not created by KOrganizer "
1436 "or any other product we support. Loading anyway..." << endl;
1437 mLoadedProductId = s;
1438 deleteStr(s);
1439 }
1440
1441 // warn the user we might have trouble reading this unknown version.
1442 if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) {
1443 char *s = fakeCString(vObjectUStringZValue(curVO));
1444 if (strcmp(_VCAL_VERSION, s) != 0)
1445 kdDebug(5800) << "This vCalendar file has version " << s
1446 << "We only support " << _VCAL_VERSION << endl;
1447 deleteStr(s);
1448 }
1449
1450#if 0
1451 // set the time zone (this is a property of the view, so just discard!)
1452 if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) {
1453 char *s = fakeCString(vObjectUStringZValue(curVO));
1454 mCalendar->setTimeZone(s);
1455 deleteStr(s);
1456 }
1457#endif
1458
1459 // Store all events with a relatedTo property in a list for post-processing
1460 mEventsRelate.clear();
1461 mTodosRelate.clear();
1462
1463 initPropIterator(&i, vcal);
1464
1465 // go through all the vobjects in the vcal
1466 while (moreIteration(&i)) {
1467 curVO = nextVObject(&i);
1468
1469 /************************************************************************/
1470
1471 // now, check to see that the object is an event or todo.
1472 if (strcmp(vObjectName(curVO), VCEventProp) == 0) {
1473
1474 if ((curVOProp = isAPropertyOf(curVO, KPiloStatusProp)) != 0) {
1475 char *s;
1476 s = fakeCString(vObjectUStringZValue(curVOProp));
1477 // check to see if event was deleted by the kpilot conduit
1478 if (atoi(s) == Event::SYNCDEL) {
1479 deleteStr(s);
1480 kdDebug(5800) << "skipping pilot-deleted event" << endl;
1481 goto SKIP;
1482 }
1483 deleteStr(s);
1484 }
1485
1486 // this code checks to see if we are trying to read in an event
1487 // that we already find to be in the calendar. If we find this
1488 // to be the case, we skip the event.
1489 if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) {
1490 char *s = fakeCString(vObjectUStringZValue(curVOProp));
1491 TQString tmpStr(s);
1492 deleteStr(s);
1493
1494 if (mCalendar->incidence(tmpStr)) {
1495 goto SKIP;
1496 }
1497 }
1498
1499 if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) &&
1500 (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) {
1501 kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl;
1502 goto SKIP;
1503 }
1504
1505 anEvent = VEventToEvent(curVO);
1506 // we now use addEvent instead of insertEvent so that the
1507 // signal/slot get connected.
1508 if (anEvent) {
1509 if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) {
1510 kdDebug(5800) << "VCalFormat::populate(): Event has invalid dates."
1511 << endl;
1512 } else {
1513 mCalendar->addEvent(anEvent);
1514 }
1515 } else {
1516 // some sort of error must have occurred while in translation.
1517 goto SKIP;
1518 }
1519 } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) {
1520 Todo *aTodo = VTodoToEvent(curVO);
1521 mCalendar->addTodo(aTodo);
1522 } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) ||
1523 (strcmp(vObjectName(curVO), VCProdIdProp) == 0) ||
1524 (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) {
1525 // do nothing, we know these properties and we want to skip them.
1526 // we have either already processed them or are ignoring them.
1527 ;
1528 } else {
1529 kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl;
1530 }
1531 SKIP:
1532 ;
1533 } // while
1534
1535 // Post-Process list of events with relations, put Event objects in relation
1536 Event::List::ConstIterator eIt;
1537 for ( eIt = mEventsRelate.begin(); eIt != mEventsRelate.end(); ++eIt ) {
1538 (*eIt)->setRelatedTo( mCalendar->incidence( (*eIt)->relatedToUid() ) );
1539 }
1540 Todo::List::ConstIterator tIt;
1541 for ( tIt = mTodosRelate.begin(); tIt != mTodosRelate.end(); ++tIt ) {
1542 (*tIt)->setRelatedTo( mCalendar->incidence( (*tIt)->relatedToUid() ) );
1543 }
1544}
1545
1546const char *VCalFormat::dayFromNum(int day)
1547{
1548 const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " };
1549
1550 return days[day];
1551}
1552
1553int VCalFormat::numFromDay(const TQString &day)
1554{
1555 if (day == "MO ") return 0;
1556 if (day == "TU ") return 1;
1557 if (day == "WE ") return 2;
1558 if (day == "TH ") return 3;
1559 if (day == "FR ") return 4;
1560 if (day == "SA ") return 5;
1561 if (day == "SU ") return 6;
1562
1563 return -1; // something bad happened. :)
1564}
1565
1566Attendee::PartStat VCalFormat::readStatus(const char *s) const
1567{
1568 TQString statStr = s;
1569 statStr = statStr.upper();
1570 Attendee::PartStat status;
1571
1572 if (statStr == "X-ACTION")
1573 status = Attendee::NeedsAction;
1574 else if (statStr == "NEEDS ACTION")
1575 status = Attendee::NeedsAction;
1576 else if (statStr== "ACCEPTED")
1577 status = Attendee::Accepted;
1578 else if (statStr== "SENT")
1579 status = Attendee::NeedsAction;
1580 else if (statStr== "TENTATIVE")
1581 status = Attendee::Tentative;
1582 else if (statStr== "CONFIRMED")
1583 status = Attendee::Accepted;
1584 else if (statStr== "DECLINED")
1585 status = Attendee::Declined;
1586 else if (statStr== "COMPLETED")
1587 status = Attendee::Completed;
1588 else if (statStr== "DELEGATED")
1589 status = Attendee::Delegated;
1590 else {
1591 kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl;
1592 status = Attendee::NeedsAction;
1593 }
1594
1595 return status;
1596}
1597
1598TQCString VCalFormat::writeStatus(Attendee::PartStat status) const
1599{
1600 switch(status) {
1601 default:
1602 case Attendee::NeedsAction:
1603 return "NEEDS ACTION";
1604 break;
1605 case Attendee::Accepted:
1606 return "ACCEPTED";
1607 break;
1608 case Attendee::Declined:
1609 return "DECLINED";
1610 break;
1611 case Attendee::Tentative:
1612 return "TENTATIVE";
1613 break;
1614 case Attendee::Delegated:
1615 return "DELEGATED";
1616 break;
1617 case Attendee::Completed:
1618 return "COMPLETED";
1619 break;
1620 case Attendee::InProcess:
1621 return "NEEDS ACTION";
1622 break;
1623 }
1624}
Provides the main "calendar" object class.
This class represents an alarm notification.
Definition: alarm.h:46
void setAudioAlarm(const TQString &audioFile=TQString())
Set the alarm to be an audio alarm.
Definition: alarm.cpp:149
TQString audioFile() const
Return the name of the audio file for the alarm.
Definition: alarm.cpp:164
TQString programFile() const
Return the name of the program file to execute when the alarm is triggered.
Definition: alarm.cpp:185
TQDateTime time() const
Return the date/time when an alarm goes off.
Definition: alarm.cpp:329
void setEnabled(bool enable)
Set the alarm enabled status.
Definition: alarm.cpp:432
bool enabled() const
Get the alarm enabled status.
Definition: alarm.cpp:438
void setTime(const TQDateTime &alarmTime)
Set the time to trigger an alarm.
Definition: alarm.cpp:321
Type type() const
Return the type of the alarm.
Definition: alarm.cpp:144
void setProcedureAlarm(const TQString &programFile, const TQString &arguments=TQString())
Set the alarm to be a procedure alarm.
Definition: alarm.cpp:169
This class represents information related to an attachment.
Definition: attachment.h:35
This class represents information related to an attendee of an event.
Definition: attendee.h:37
void setRSVP(bool r)
Set if Attendee is asked to reply.
Definition: attendee.h:122
void setStatus(PartStat s)
Set status.
Definition: attendee.cpp:56
bool RSVP() const
Return, if Attendee is asked to reply.
Definition: attendee.h:126
PartStat status() const
Return status.
Definition: attendee.cpp:61
void setException(ErrorFormat *error)
Set exception for this object.
Definition: calformat.cpp:50
void clearException()
Clear exception status of this format object.
Definition: calformat.cpp:44
static const TQString & productId()
Return the PRODID string to write into calendar files.
Definition: calformat.h:87
This is the main "calendar" object class.
Definition: calendar.h:171
virtual bool addEvent(Event *event)=0
Insert an Event into the Calendar.
virtual bool addTodo(Todo *todo)=0
Insert a Todo into the Calendar.
const Person & getOwner() const
Get the owner of the Calendar.
Definition: calendar.cpp:91
virtual Event::List rawEvents(EventSortField sortField=EventSortUnsorted, SortDirection sortDirection=SortDirectionAscending)=0
Return a sorted, unfiltered list of all Events for this Calendar.
TQString timeZoneId() const
Get the Time Zone ID for the Calendar.
Definition: calendar.cpp:112
virtual Event::List events(EventSortField sortField=EventSortUnsorted, SortDirection sortDirection=SortDirectionAscending)
Return a sorted, filtered list of all Events for this Calendar.
Definition: calendar.cpp:458
virtual Todo::List rawTodos(TodoSortField sortField=TodoSortUnsorted, SortDirection sortDirection=SortDirectionAscending)=0
Return a sorted, unfiltered list of all Todos for this Calendar.
Incidence * incidence(const TQString &uid)
Returns the Incidence associated with the given unique identifier.
Definition: calendar.cpp:576
Calendar format related error class.
Definition: exceptions.h:65
@ CalVersionUnknown
Unknown calendar format detected.
Definition: exceptions.h:78
This class provides an Event in the sense of RFC2445.
Definition: event.h:33
void setTransparency(Transparency transparency)
Set the event's time transparency level.
Definition: event.cpp:138
virtual TQDateTime dtEnd() const
Return end date and time.
Definition: event.cpp:85
void setDtEnd(const TQDateTime &dtEnd)
Set end date and time.
Definition: event.cpp:73
Transparency transparency() const
Return the event's time transparency level.
Definition: event.cpp:145
void setOrganizer(const Person &o)
sets the organizer for the event
int attendeeCount() const
Return number of attendees.
void setPilotId(unsigned long id)
Set Pilot Id.
unsigned long pilotId() const
Return Pilot Id.
bool doesFloat() const
Return true or false depending on whether the incidence "floats," i.e.
TQString uid() const
Return the unique id for the event.
const Attendee::List & attendees() const
Return list of attendees.
void setUid(const TQString &)
Set the unique id for the event.
int syncStatus() const
Return synchronisation status.
virtual TQDateTime dtStart() const
returns an event's starting date/time as a TQDateTime.
TQDateTime lastModified() const
Return the time the incidence was last modified.
void setSyncStatus(int status)
Set synchronisation satus.
void setLastModified(const TQDateTime &lm)
Sets the time the incidence was last modified.
void addAttendee(Attendee *attendee, bool doUpdate=true)
Add Attendee to this incidence.
void addAttachment(Attachment *attachment)
Add attachment.
Definition: incidence.cpp:674
void setLocation(const TQString &location)
Set the event's/todo's location.
Definition: incidence.cpp:868
const Alarm::List & alarms() const
All alarms that are associated with this incidence.
Definition: incidence.cpp:828
void setSummary(const TQString &summary)
Set short summary.
Definition: incidence.cpp:286
Alarm * newAlarm()
Create a new alarm which is associated with this incidence.
Definition: incidence.cpp:833
TQDateTime created() const
Return time and date of creation.
Definition: incidence.cpp:246
int revision() const
Return the number of revisions this event has seen.
Definition: incidence.cpp:259
void setPriority(int priority)
Set the incidences priority.
Definition: incidence.cpp:729
void setSecrecy(int)
Sets secrecy status.
Definition: incidence.cpp:786
int secrecy() const
Return the event's secrecy.
Definition: incidence.cpp:793
TQString description() const
Return long description.
Definition: incidence.cpp:280
Incidence * relatedTo() const
What event does this one relate to?
Definition: incidence.cpp:360
TQStringList categories() const
Return categories as a list of strings.
Definition: incidence.cpp:323
void setDescription(const TQString &description)
Set the long description.
Definition: incidence.cpp:273
int priority() const
Return priority.
Definition: incidence.cpp:736
void setFloats(bool f)
Set whether the incidence floats, i.e.
Definition: incidence.cpp:229
void setRelatedToUid(const TQString &)
Point at some other event to which the event relates.
Definition: incidence.cpp:333
virtual void setDtStart(const TQDateTime &dtStart)
Set starting date/time.
Definition: incidence.cpp:264
void setCategories(const TQStringList &categories)
Set categories.
Definition: incidence.cpp:298
void setResources(const TQStringList &resources)
Set resources used, such as Office, Car, etc.
Definition: incidence.cpp:716
TQString location() const
Return the event's/todo's location.
Definition: incidence.cpp:875
Attachment::List attachments() const
Return list of all associated attachments.
Definition: incidence.cpp:695
TQString summary() const
Return short summary.
Definition: incidence.cpp:293
Recurrence * recurrence() const
Return the recurrence rule associated with this incidence.
Definition: incidence.cpp:390
void setRevision(int rev)
Set the number of revisions this event has seen.
Definition: incidence.cpp:251
TQStringList resources() const
Return list of current resources.
Definition: incidence.cpp:723
void setCreated(const TQDateTime &)
Set creation date.
Definition: incidence.cpp:237
This class represents a recurrence rule for a calendar incidence.
Definition: recurrence.h:90
ushort recurrenceType() const
Returns the event's recurrence status.
Definition: recurrence.cpp:189
TQDateTime endDateTime() const
Returns the date/time of the last recurrence.
Definition: recurrence.cpp:351
int frequency() const
Returns frequency of recurrence, in terms of the recurrence time period type.
Definition: recurrence.cpp:465
void setEndDateTime(const TQDateTime &endDateTime)
Sets the date and time of the last recurrence.
Definition: recurrence.cpp:386
void addYearlyDay(int day)
Adds day number of year within a yearly recurrence.
Definition: recurrence.cpp:679
void setYearly(int freq)
Sets an event to recur yearly.
Definition: recurrence.cpp:671
void setWeekly(int freq, int weekStart=1)
Sets an event to recur weekly.
Definition: recurrence.cpp:590
TQBitArray days() const
Returns week day mask (bit 0 = Monday).
Definition: recurrence.cpp:494
void setMonthly(int freq)
Sets an event to recur monthly.
Definition: recurrence.cpp:609
TQValueList< int > monthDays() const
Returns list of day numbers of a month.
Definition: recurrence.cpp:515
void addYearlyMonth(short _rNum)
Adds month in yearly recurrence.
Definition: recurrence.cpp:706
void addMonthlyPos(short pos, const TQBitArray &days)
Adds a position (e.g.
Definition: recurrence.cpp:615
void setDaily(int freq)
Sets an event to recur daily.
Definition: recurrence.cpp:584
bool doesRecur() const
Returns whether the event recurs at all.
Definition: recurrence.cpp:184
int duration() const
Returns -1 if the event recurs infinitely, 0 if the end date is set, otherwise the total number of re...
Definition: recurrence.cpp:395
TQValueList< int > yearMonths() const
Returns the months within a yearly recurrence.
Definition: recurrence.cpp:545
void addMonthlyDate(short day)
Adds a date (e.g.
Definition: recurrence.cpp:657
TQValueList< RecurrenceRule::WDayPos > monthPositions() const
Returns list of day positions in months.
Definition: recurrence.cpp:523
TQValueList< int > yearDays() const
Returns the day numbers within a yearly recurrence.
Definition: recurrence.cpp:533
void setDuration(int duration)
Sets the total number of times the event is to occur, including both the first and last.
Definition: recurrence.cpp:415
This class provides a Todo in the sense of RFC2445.
Definition: todo.h:32
bool hasDueDate() const
Returns true if the todo has a due date, otherwise return false.
Definition: todo.cpp:144
bool isCompleted() const
Returns true if the todo is 100% completed, otherwise return false.
Definition: todo.cpp:217
bool hasStartDate() const
Returns true if the todo has a start date, otherwise return false.
Definition: todo.cpp:157
void setDtDue(const TQDateTime &dtDue, bool first=false)
Sets due date and time.
Definition: todo.cpp:85
void setCompleted(bool completed)
Set completed state.
Definition: todo.cpp:223
TQDateTime dtStart(bool first=false) const
Returns the startdate of the todo.
Definition: todo.cpp:177
TQDateTime completed() const
Returns date and time when todo was completed.
Definition: todo.cpp:235
void setHasStartDate(bool hasStartDate)
Set if the todo has a start date.
Definition: todo.cpp:162
void setDtStart(const TQDateTime &dtStart)
Sets the startdate of the todo.
Definition: todo.cpp:192
bool hasCompletedDate() const
Returns true, if todo has a date associated with completion, otherwise return false.
Definition: todo.cpp:258
TQDateTime dtDue(bool first=false) const
Returns due date and time.
Definition: todo.cpp:117
void setHasDueDate(bool hasDueDate)
Set if the todo has a due date.
Definition: todo.cpp:149
bool save(Calendar *calendar, const TQString &fileName)
Writes out the given calendar to disk in vCalendar format.
Definition: vcalformat.cpp:90
VObject * eventToVTodo(const Todo *anEvent)
translate a Event into a VTodo-type VObject and return pointer
Definition: vcalformat.cpp:203
TQDate ISOToTQDate(const TQString &dtStr)
takes a string in the format YYYYMMDD and returns a valid TQDate.
void populate(VObject *vcal)
takes a vCalendar tree of VObjects, and puts all of them that have the "event" property into the dict...
int numFromDay(const TQString &day)
the reverse of the above function.
Event * VEventToEvent(VObject *vevent)
translates a VObject into a Event and returns a pointer to it.
Definition: vcalformat.cpp:857
TQString qDateToISO(const TQDate &)
takes a TQDate and returns a string in the format YYYYMMDDTHHMMSS
bool fromString(Calendar *, const TQString &)
Parse string and populate calendar with that information.
Definition: vcalformat.cpp:136
bool load(Calendar *calendar, const TQString &fileName)
Loads a calendar on disk in vCalendar format into the given calendar.
Definition: vcalformat.cpp:58
Todo * VTodoToEvent(VObject *vtodo)
translates a VObject of the TODO type into a Event
Definition: vcalformat.cpp:651
TQString toString(Calendar *)
Return calendar information as string.
Definition: vcalformat.cpp:172
TQString qDateTimeToISO(const TQDateTime &, bool zulu=TRUE)
takes a TQDateTime and returns a string in format YYYYMMDDTHHMMSS
VObject * eventToVEvent(const Event *anEvent)
translate a Event into a VObject and returns a pointer to it.
Definition: vcalformat.cpp:365
const char * dayFromNum(int day)
takes a number 0 - 6 and returns the two letter string of that day, i.e.
TQDateTime ISOToTQDateTime(const TQString &dtStr)
takes a string in the format YYYYMMDDTHHMMSS and returns a valid TQDateTime.
Namespace KCal is for global classes, objects and/or functions in libkcal.
Definition: alarm.h:38