summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-04-10 08:53:14 (UTC)
committer zautrix <zautrix>2005-04-10 08:53:14 (UTC)
commit79b12b680f6a0653bcff84c8ef83b23803246b7d (patch) (unidiff)
tree05e4c6d7ac0446eacb7dff6ca466f656b3152793 /libkcal
parent54f5fe5e6f4909109edf915513c02f7af3e7bb2d (diff)
downloadkdepimpi-79b12b680f6a0653bcff84c8ef83b23803246b7d.zip
kdepimpi-79b12b680f6a0653bcff84c8ef83b23803246b7d.tar.gz
kdepimpi-79b12b680f6a0653bcff84c8ef83b23803246b7d.tar.bz2
fixes
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp2
-rw-r--r--libkcal/calformat.cpp20
-rw-r--r--libkcal/icalformatimpl.cpp12
-rw-r--r--libkcal/incidence.cpp7
-rw-r--r--libkcal/todo.cpp38
-rw-r--r--libkcal/vcalformat.cpp16
6 files changed, 51 insertions, 44 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index dcfee5d..406cd48 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -1,105 +1,105 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <stdlib.h> 22#include <stdlib.h>
23#include <time.h> 23#include <time.h>
24 24
25#include <kdebug.h> 25#include <kdebug.h>
26#include <kglobal.h> 26#include <kglobal.h>
27#include <klocale.h> 27#include <klocale.h>
28 28
29#include "exceptions.h" 29#include "exceptions.h"
30#include "calfilter.h" 30#include "calfilter.h"
31 31
32#include "calendar.h" 32#include "calendar.h"
33#include "syncdefines.h" 33#include "syncdefines.h"
34 34
35using namespace KCal; 35using namespace KCal;
36 36
37Calendar::Calendar() 37Calendar::Calendar()
38{ 38{
39 39
40 init(); 40 init();
41 setTimeZoneId( i18n (" 00:00 Europe/London(UTC)") ); 41 setTimeZoneId( " 00:00 Europe/London(UTC)" );
42} 42}
43 43
44Calendar::Calendar( const QString &timeZoneId ) 44Calendar::Calendar( const QString &timeZoneId )
45{ 45{
46 46
47 init(); 47 init();
48 setTimeZoneId(timeZoneId); 48 setTimeZoneId(timeZoneId);
49} 49}
50 50
51void Calendar::init() 51void Calendar::init()
52{ 52{
53 mObserver = 0; 53 mObserver = 0;
54 mNewObserver = false; 54 mNewObserver = false;
55 mUndoIncidence = 0; 55 mUndoIncidence = 0;
56 mModified = false; 56 mModified = false;
57 57
58 // Setup default filter, which does nothing 58 // Setup default filter, which does nothing
59 mDefaultFilter = new CalFilter; 59 mDefaultFilter = new CalFilter;
60 mFilter = mDefaultFilter; 60 mFilter = mDefaultFilter;
61 mFilter->setEnabled(false); 61 mFilter->setEnabled(false);
62 62
63 // initialize random numbers. This is a hack, and not 63 // initialize random numbers. This is a hack, and not
64 // even that good of one at that. 64 // even that good of one at that.
65// srandom(time(0)); 65// srandom(time(0));
66 66
67 // user information... 67 // user information...
68 setOwner(i18n("Unknown Name")); 68 setOwner(i18n("Unknown Name"));
69 setEmail(i18n("unknown@nowhere")); 69 setEmail(i18n("unknown@nowhere"));
70 70
71#if 0 71#if 0
72 tmpStr = KOPrefs::instance()->mTimeZone; 72 tmpStr = KOPrefs::instance()->mTimeZone;
73// kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; 73// kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl;
74 int dstSetting = KOPrefs::instance()->mDaylightSavings; 74 int dstSetting = KOPrefs::instance()->mDaylightSavings;
75 extern long int timezone; 75 extern long int timezone;
76 struct tm *now; 76 struct tm *now;
77 time_t curtime; 77 time_t curtime;
78 curtime = time(0); 78 curtime = time(0);
79 now = localtime(&curtime); 79 now = localtime(&curtime);
80 int hourOff = - ((timezone / 60) / 60); 80 int hourOff = - ((timezone / 60) / 60);
81 if (now->tm_isdst) 81 if (now->tm_isdst)
82 hourOff += 1; 82 hourOff += 1;
83 QString tzStr; 83 QString tzStr;
84 tzStr.sprintf("%.2d%.2d", 84 tzStr.sprintf("%.2d%.2d",
85 hourOff, 85 hourOff,
86 abs((timezone / 60) % 60)); 86 abs((timezone / 60) % 60));
87 87
88 // if no time zone was in the config file, write what we just discovered. 88 // if no time zone was in the config file, write what we just discovered.
89 if (tmpStr.isEmpty()) { 89 if (tmpStr.isEmpty()) {
90// KOPrefs::instance()->mTimeZone = tzStr; 90// KOPrefs::instance()->mTimeZone = tzStr;
91 } else { 91 } else {
92 tzStr = tmpStr; 92 tzStr = tmpStr;
93 } 93 }
94 94
95 // if daylight savings has changed since last load time, we need 95 // if daylight savings has changed since last load time, we need
96 // to rewrite these settings to the config file. 96 // to rewrite these settings to the config file.
97 if ((now->tm_isdst && !dstSetting) || 97 if ((now->tm_isdst && !dstSetting) ||
98 (!now->tm_isdst && dstSetting)) { 98 (!now->tm_isdst && dstSetting)) {
99 KOPrefs::instance()->mTimeZone = tzStr; 99 KOPrefs::instance()->mTimeZone = tzStr;
100 KOPrefs::instance()->mDaylightSavings = now->tm_isdst; 100 KOPrefs::instance()->mDaylightSavings = now->tm_isdst;
101 } 101 }
102 102
103 setTimeZone(tzStr); 103 setTimeZone(tzStr);
104#endif 104#endif
105 105
diff --git a/libkcal/calformat.cpp b/libkcal/calformat.cpp
index 8a3d069..359f65f 100644
--- a/libkcal/calformat.cpp
+++ b/libkcal/calformat.cpp
@@ -1,98 +1,94 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <klocale.h> 21#include <klocale.h>
22#include <kdebug.h> 22#include <kdebug.h>
23#include <kapplication.h> 23#include <kapplication.h>
24 24
25#include "calformat.h" 25#include "calformat.h"
26 26
27using namespace KCal; 27using namespace KCal;
28 28
29QString CalFormat::mApplication = QString::fromLatin1("libkcal"); 29QString CalFormat::mApplication = QString::fromLatin1("libkcal-pi");
30QString CalFormat::mProductId = QString::fromLatin1("-//K Desktop Environment//NONSGML libkcal 3.1//EN"); 30QString CalFormat::mProductId = QString::fromLatin1("-//KDE-Pim//Platform-independent 2.1.0");
31 31
32// An array containing the PRODID strings indexed against the calendar file format version used. 32// An array containing the PRODID strings indexed against the calendar file format version used.
33// Every time the calendar file format is changed, add an entry/entries to this list. 33// Every time the calendar file format is changed, add an entry/entries to this list.
34struct CalVersion { 34struct CalVersion {
35 int version; 35 int version;
36 QString prodId; 36 QString prodId;
37}; 37};
38static CalVersion prodIds[] = { 38static CalVersion prodIds[] = {
39 { 220, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 2.2//EN") }, 39 { 220, QString::fromLatin1("-//KDE-Pim//Pi 2.2//EN") },
40 { 300, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 3.0//EN") }, 40 { 300, QString::fromLatin1("-//KDE-Pim//Pi 3.0//EN") },
41 { 310, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 3.1//EN") }, 41 { 310, QString::fromLatin1("-//KDE-Pim//Pi 3.1//EN") },
42 { 0 , QString() } 42 { 0 , QString() }
43}; 43};
44 44
45 45
46CalFormat::CalFormat() 46CalFormat::CalFormat()
47{ 47{
48 mException = 0; 48 mException = 0;
49} 49}
50 50
51CalFormat::~CalFormat() 51CalFormat::~CalFormat()
52{ 52{
53 delete mException; 53 delete mException;
54} 54}
55 55
56void CalFormat::clearException() 56void CalFormat::clearException()
57{ 57{
58 delete mException; 58 delete mException;
59 mException = 0; 59 mException = 0;
60} 60}
61 61
62void CalFormat::setException(ErrorFormat *exception) 62void CalFormat::setException(ErrorFormat *exception)
63{ 63{
64 delete mException; 64 delete mException;
65 mException = exception; 65 mException = exception;
66} 66}
67 67
68ErrorFormat *CalFormat::exception() 68ErrorFormat *CalFormat::exception()
69{ 69{
70 return mException; 70 return mException;
71} 71}
72 72
73void CalFormat::setApplication(const QString& application, const QString& productID) 73void CalFormat::setApplication(const QString& application, const QString& productID)
74{ 74{
75 mApplication = application; 75 mApplication = application;
76 mProductId = productID; 76 mProductId = productID;
77} 77}
78 78
79QString CalFormat::createUniqueId() 79QString CalFormat::createUniqueId()
80{ 80{
81 int hashTime = QTime::currentTime().hour() + 81 return QString("%1-%2-%3")
82 QTime::currentTime().minute() + QTime::currentTime().second() + 82 .arg("kopi")
83 QTime::currentTime().msec();
84 QString uidStr = QString("%1-%2.%3")
85 .arg(mApplication)
86 .arg(KApplication::random()) 83 .arg(KApplication::random())
87 .arg(hashTime); 84 .arg(QTime::currentTime().msec()+1);
88 return uidStr;
89} 85}
90 86
91int CalFormat::calendarVersion(const char* prodId) 87int CalFormat::calendarVersion(const char* prodId)
92{ 88{
93 for (const CalVersion* cv = prodIds; cv->version; ++cv) { 89 for (const CalVersion* cv = prodIds; cv->version; ++cv) {
94 if (!strcmp(prodId, cv->prodId.local8Bit())) 90 if (!strcmp(prodId, cv->prodId.local8Bit()))
95 return cv->version; 91 return cv->version;
96 } 92 }
97 return 0; 93 return 0;
98} 94}
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index eae41aa..fe7413f 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -305,131 +305,131 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
305 if (!incidence->location().isEmpty()) { 305 if (!incidence->location().isEmpty()) {
306 icalcomponent_add_property(parent,icalproperty_new_location( 306 icalcomponent_add_property(parent,icalproperty_new_location(
307 incidence->location().utf8())); 307 incidence->location().utf8()));
308 } 308 }
309 309
310// TODO: 310// TODO:
311 // status 311 // status
312// addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8()); 312// addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8());
313 313
314 // secrecy 314 // secrecy
315 enum icalproperty_class classInt; 315 enum icalproperty_class classInt;
316 switch (incidence->secrecy()) { 316 switch (incidence->secrecy()) {
317 case Incidence::SecrecyPublic: 317 case Incidence::SecrecyPublic:
318 classInt = ICAL_CLASS_PUBLIC; 318 classInt = ICAL_CLASS_PUBLIC;
319 break; 319 break;
320 case Incidence::SecrecyConfidential: 320 case Incidence::SecrecyConfidential:
321 classInt = ICAL_CLASS_CONFIDENTIAL; 321 classInt = ICAL_CLASS_CONFIDENTIAL;
322 break; 322 break;
323 case Incidence::SecrecyPrivate: 323 case Incidence::SecrecyPrivate:
324 classInt =ICAL_CLASS_PRIVATE ; 324 classInt =ICAL_CLASS_PRIVATE ;
325 default: 325 default:
326 classInt =ICAL_CLASS_PRIVATE ; 326 classInt =ICAL_CLASS_PRIVATE ;
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->relatedTo()) { 369 if (!incidence->relatedToUid().isEmpty()) {
370 icalcomponent_add_property(parent,icalproperty_new_relatedto( 370 icalcomponent_add_property(parent,icalproperty_new_relatedto(
371 incidence->relatedTo()->uid().utf8())); 371 incidence->relatedToUid().utf8()));
372 } 372 }
373 373
374 // recurrence rule stuff 374 // recurrence rule stuff
375 Recurrence *recur = incidence->recurrence(); 375 Recurrence *recur = incidence->recurrence();
376 if (recur->doesRecur()) { 376 if (recur->doesRecur()) {
377 377
378 icalcomponent_add_property(parent,writeRecurrenceRule(recur)); 378 icalcomponent_add_property(parent,writeRecurrenceRule(recur));
379 } 379 }
380 380
381 // recurrence excpetion dates 381 // recurrence excpetion dates
382 DateList dateList = incidence->exDates(); 382 DateList dateList = incidence->exDates();
383 DateList::ConstIterator exIt; 383 DateList::ConstIterator exIt;
384 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { 384 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) {
385 icalcomponent_add_property(parent,icalproperty_new_exdate( 385 icalcomponent_add_property(parent,icalproperty_new_exdate(
386 writeICalDate(*exIt))); 386 writeICalDate(*exIt)));
387 } 387 }
388 388
389 // attachments 389 // attachments
390 QPtrList<Attachment> attachments = incidence->attachments(); 390 QPtrList<Attachment> attachments = incidence->attachments();
391 for (Attachment *at = attachments.first(); at; at = attachments.next()) 391 for (Attachment *at = attachments.first(); at; at = attachments.next())
392 icalcomponent_add_property(parent,writeAttachment(at)); 392 icalcomponent_add_property(parent,writeAttachment(at));
393 393
394 // alarms 394 // alarms
395 QPtrList<Alarm> alarms = incidence->alarms(); 395 QPtrList<Alarm> alarms = incidence->alarms();
396 Alarm* alarm; 396 Alarm* alarm;
397 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 397 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
398 if (alarm->enabled()) { 398 if (alarm->enabled()) {
399 kdDebug(5800) << "Write alarm for " << incidence->summary() << endl; 399 kdDebug(5800) << "Write alarm for " << incidence->summary() << endl;
400 icalcomponent_add_component(parent,writeAlarm(alarm)); 400 icalcomponent_add_component(parent,writeAlarm(alarm));
401 } 401 }
402 } 402 }
403 if( incidence->hasRecurrenceID() ) { 403 if( incidence->hasRecurrenceID() ) {
404 icalcomponent_add_property(parent, 404 icalcomponent_add_property(parent,
405 icalproperty_new_recurrenceid( writeICalDateTime( incidence->recurrenceID()))); 405 icalproperty_new_recurrenceid( writeICalDateTime( incidence->recurrenceID())));
406 } 406 }
407 // duration 407 // duration
408 408
409// turned off as it always is set to PTS0 (and must not occur together with DTEND 409// turned off as it always is set to PTS0 (and must not occur together with DTEND
410 410
411 if (incidence->hasDuration()) { 411 if (incidence->hasDuration()) {
412 icaldurationtype duration; 412 icaldurationtype duration;
413 duration = writeICalDuration(incidence->duration()); 413 duration = writeICalDuration(incidence->duration());
414 icalcomponent_add_property(parent,icalproperty_new_duration(duration)); 414 icalcomponent_add_property(parent,icalproperty_new_duration(duration));
415 } 415 }
416} 416}
417 417
418void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) 418void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase)
419{ 419{
420 icalcomponent_add_property(parent,icalproperty_new_dtstamp( 420 icalcomponent_add_property(parent,icalproperty_new_dtstamp(
421 writeICalDateTime(QDateTime::currentDateTime()))); 421 writeICalDateTime(QDateTime::currentDateTime())));
422 422
423 // organizer stuff 423 // organizer stuff
424 icalcomponent_add_property(parent,icalproperty_new_organizer( 424 icalcomponent_add_property(parent,icalproperty_new_organizer(
425 ("MAILTO:" + incidenceBase->organizer()).utf8())); 425 ("MAILTO:" + incidenceBase->organizer()).utf8()));
426 426
427 // attendees 427 // attendees
428 if (incidenceBase->attendeeCount() != 0) { 428 if (incidenceBase->attendeeCount() != 0) {
429 QPtrList<Attendee> al = incidenceBase->attendees(); 429 QPtrList<Attendee> al = incidenceBase->attendees();
430 QPtrListIterator<Attendee> ai(al); 430 QPtrListIterator<Attendee> ai(al);
431 for (; ai.current(); ++ai) { 431 for (; ai.current(); ++ai) {
432 icalcomponent_add_property(parent,writeAttendee(ai.current())); 432 icalcomponent_add_property(parent,writeAttendee(ai.current()));
433 } 433 }
434 } 434 }
435 435
@@ -1975,133 +1975,137 @@ bool ICalFormatImpl::populate( Calendar *cal, icalcomponent *calendar)
1975 if (strcmp(vObjectName(curVO), VCEventProp) == 0) { 1975 if (strcmp(vObjectName(curVO), VCEventProp) == 0) {
1976 1976
1977 if ((curVOProp = isAPropertyOf(curVO, KPilotStatusProp)) != 0) { 1977 if ((curVOProp = isAPropertyOf(curVO, KPilotStatusProp)) != 0) {
1978 char *s; 1978 char *s;
1979 s = fakeCString(vObjectUStringZValue(curVOProp)); 1979 s = fakeCString(vObjectUStringZValue(curVOProp));
1980 // check to see if event was deleted by the kpilot conduit 1980 // check to see if event was deleted by the kpilot conduit
1981 if (atoi(s) == Event::SYNCDEL) { 1981 if (atoi(s) == Event::SYNCDEL) {
1982 deleteStr(s); 1982 deleteStr(s);
1983 goto SKIP; 1983 goto SKIP;
1984 } 1984 }
1985 deleteStr(s); 1985 deleteStr(s);
1986 } 1986 }
1987 1987
1988 // this code checks to see if we are trying to read in an event 1988 // this code checks to see if we are trying to read in an event
1989 // that we already find to be in the calendar. If we find this 1989 // that we already find to be in the calendar. If we find this
1990 // to be the case, we skip the event. 1990 // to be the case, we skip the event.
1991 if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { 1991 if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) {
1992 char *s = fakeCString(vObjectUStringZValue(curVOProp)); 1992 char *s = fakeCString(vObjectUStringZValue(curVOProp));
1993 QString tmpStr(s); 1993 QString tmpStr(s);
1994 deleteStr(s); 1994 deleteStr(s);
1995 1995
1996 if (cal->event(tmpStr)) { 1996 if (cal->event(tmpStr)) {
1997 goto SKIP; 1997 goto SKIP;
1998 } 1998 }
1999 if (cal->todo(tmpStr)) { 1999 if (cal->todo(tmpStr)) {
2000 goto SKIP; 2000 goto SKIP;
2001 } 2001 }
2002 } 2002 }
2003 2003
2004 if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && 2004 if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) &&
2005 (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { 2005 (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) {
2006 kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; 2006 kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl;
2007 goto SKIP; 2007 goto SKIP;
2008 } 2008 }
2009 2009
2010 anEvent = VEventToEvent(curVO); 2010 anEvent = VEventToEvent(curVO);
2011 // we now use addEvent instead of insertEvent so that the 2011 // we now use addEvent instead of insertEvent so that the
2012 // signal/slot get connected. 2012 // signal/slot get connected.
2013 if (anEvent) 2013 if (anEvent)
2014 cal->addEvent(anEvent); 2014 cal->addEvent(anEvent);
2015 else { 2015 else {
2016 // some sort of error must have occurred while in translation. 2016 // some sort of error must have occurred while in translation.
2017 goto SKIP; 2017 goto SKIP;
2018 } 2018 }
2019 } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { 2019 } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) {
2020 anEvent = VTodoToEvent(curVO); 2020 anEvent = VTodoToEvent(curVO);
2021 cal->addTodo(anEvent); 2021 cal->addTodo(anEvent);
2022 } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || 2022 } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) ||
2023 (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || 2023 (strcmp(vObjectName(curVO), VCProdIdProp) == 0) ||
2024 (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { 2024 (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) {
2025 // do nothing, we know these properties and we want to skip them. 2025 // do nothing, we know these properties and we want to skip them.
2026 // we have either already processed them or are ignoring them. 2026 // we have either already processed them or are ignoring them.
2027 ; 2027 ;
2028 } else { 2028 } else {
2029 ; 2029 ;
2030 } 2030 }
2031 SKIP: 2031 SKIP:
2032 ; 2032 ;
2033 } // while 2033 } // while
2034#endif 2034#endif
2035 2035
2036 // Post-Process list of events with relations, put Event objects in relation 2036 // Post-Process list of events with relations, put Event objects in relation
2037 Event *ev; 2037 Event *ev;
2038 for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { 2038 for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) {
2039 ev->setRelatedTo(cal->event(ev->relatedToUid())); 2039 Incidence * inc = cal->event(ev->relatedToUid());
2040 if ( inc )
2041 ev->setRelatedTo( inc );
2040 } 2042 }
2041 Todo *todo; 2043 Todo *todo;
2042 for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { 2044 for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) {
2043 todo->setRelatedTo(cal->todo(todo->relatedToUid())); 2045 Incidence * inc = cal->todo(todo->relatedToUid());
2046 if ( inc )
2047 todo->setRelatedTo( inc );
2044 } 2048 }
2045 2049
2046 return true; 2050 return true;
2047} 2051}
2048 2052
2049QString ICalFormatImpl::extractErrorProperty(icalcomponent *c) 2053QString ICalFormatImpl::extractErrorProperty(icalcomponent *c)
2050{ 2054{
2051// kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " 2055// kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: "
2052// << icalcomponent_as_ical_string(c) << endl; 2056// << icalcomponent_as_ical_string(c) << endl;
2053 2057
2054 QString errorMessage; 2058 QString errorMessage;
2055 2059
2056 icalproperty *error; 2060 icalproperty *error;
2057 error = icalcomponent_get_first_property(c,ICAL_XLICERROR_PROPERTY); 2061 error = icalcomponent_get_first_property(c,ICAL_XLICERROR_PROPERTY);
2058 while(error) { 2062 while(error) {
2059 errorMessage += icalproperty_get_xlicerror(error); 2063 errorMessage += icalproperty_get_xlicerror(error);
2060 errorMessage += "\n"; 2064 errorMessage += "\n";
2061 error = icalcomponent_get_next_property(c,ICAL_XLICERROR_PROPERTY); 2065 error = icalcomponent_get_next_property(c,ICAL_XLICERROR_PROPERTY);
2062 } 2066 }
2063 2067
2064// kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " << errorMessage << endl; 2068// kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " << errorMessage << endl;
2065 2069
2066 return errorMessage; 2070 return errorMessage;
2067} 2071}
2068 2072
2069void ICalFormatImpl::dumpIcalRecurrence(icalrecurrencetype r) 2073void ICalFormatImpl::dumpIcalRecurrence(icalrecurrencetype r)
2070{ 2074{
2071 int i; 2075 int i;
2072 2076
2073 2077
2074 if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { 2078 if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) {
2075 int index = 0; 2079 int index = 0;
2076 QString out = " By Day: "; 2080 QString out = " By Day: ";
2077 while((i = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { 2081 while((i = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
2078 out.append(QString::number(i) + " "); 2082 out.append(QString::number(i) + " ");
2079 } 2083 }
2080 } 2084 }
2081 if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { 2085 if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) {
2082 int index = 0; 2086 int index = 0;
2083 QString out = " By Month Day: "; 2087 QString out = " By Month Day: ";
2084 while((i = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { 2088 while((i = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
2085 out.append(QString::number(i) + " "); 2089 out.append(QString::number(i) + " ");
2086 } 2090 }
2087 } 2091 }
2088 if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { 2092 if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) {
2089 int index = 0; 2093 int index = 0;
2090 QString out = " By Year Day: "; 2094 QString out = " By Year Day: ";
2091 while((i = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { 2095 while((i = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
2092 out.append(QString::number(i) + " "); 2096 out.append(QString::number(i) + " ");
2093 } 2097 }
2094 } 2098 }
2095 if (r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { 2099 if (r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) {
2096 int index = 0; 2100 int index = 0;
2097 QString out = " By Month: "; 2101 QString out = " By Month: ";
2098 while((i = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { 2102 while((i = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
2099 out.append(QString::number(i) + " "); 2103 out.append(QString::number(i) + " ");
2100 } 2104 }
2101 } 2105 }
2102 if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { 2106 if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) {
2103 int index = 0; 2107 int index = 0;
2104 QString out = " By Set Pos: "; 2108 QString out = " By Set Pos: ";
2105 while((i = r.by_set_pos[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { 2109 while((i = r.by_set_pos[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
2106 out.append(QString::number(i) + " "); 2110 out.append(QString::number(i) + " ");
2107 } 2111 }
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index a312ba5..6bca12c 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -329,129 +329,134 @@ QString Incidence::summary() const
329void Incidence::checkCategories() 329void Incidence::checkCategories()
330{ 330{
331 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); 331 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday"));
332 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); 332 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday"));
333 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); 333 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary"));
334} 334}
335 335
336void Incidence::setCategories(const QStringList &categories) 336void Incidence::setCategories(const QStringList &categories)
337{ 337{
338 if (mReadOnly) return; 338 if (mReadOnly) return;
339 mCategories = categories; 339 mCategories = categories;
340 checkCategories(); 340 checkCategories();
341 updated(); 341 updated();
342} 342}
343 343
344// TODO: remove setCategories(QString) function 344// TODO: remove setCategories(QString) function
345void Incidence::setCategories(const QString &catStr) 345void Incidence::setCategories(const QString &catStr)
346{ 346{
347 if (mReadOnly) return; 347 if (mReadOnly) return;
348 mCategories.clear(); 348 mCategories.clear();
349 349
350 if (catStr.isEmpty()) return; 350 if (catStr.isEmpty()) return;
351 351
352 mCategories = QStringList::split(",",catStr); 352 mCategories = QStringList::split(",",catStr);
353 353
354 QStringList::Iterator it; 354 QStringList::Iterator it;
355 for(it = mCategories.begin();it != mCategories.end(); ++it) { 355 for(it = mCategories.begin();it != mCategories.end(); ++it) {
356 *it = (*it).stripWhiteSpace(); 356 *it = (*it).stripWhiteSpace();
357 } 357 }
358 checkCategories(); 358 checkCategories();
359 updated(); 359 updated();
360} 360}
361 361
362QStringList Incidence::categories() const 362QStringList Incidence::categories() const
363{ 363{
364 return mCategories; 364 return mCategories;
365} 365}
366 366
367QString Incidence::categoriesStr() 367QString Incidence::categoriesStr()
368{ 368{
369 return mCategories.join(","); 369 return mCategories.join(",");
370} 370}
371 371
372void Incidence::setRelatedToUid(const QString &relatedToUid) 372void Incidence::setRelatedToUid(const QString &relatedToUid)
373{ 373{
374 if (mReadOnly) return; 374 if (mReadOnly) return;
375 mRelatedToUid = relatedToUid; 375 mRelatedToUid = relatedToUid;
376} 376}
377 377
378QString Incidence::relatedToUid() const 378QString Incidence::relatedToUid() const
379{ 379{
380 return mRelatedToUid; 380 return mRelatedToUid;
381} 381}
382 382
383void Incidence::setRelatedTo(Incidence *relatedTo) 383void Incidence::setRelatedTo(Incidence *relatedTo)
384{ 384{
385 //qDebug("Incidence::setRelatedTo %d ", relatedTo); 385 //qDebug("Incidence::setRelatedTo %d ", relatedTo);
386 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); 386 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() );
387 if (mReadOnly || mRelatedTo == relatedTo) return; 387 if (mReadOnly || mRelatedTo == relatedTo) return;
388 if(mRelatedTo) { 388 if(mRelatedTo) {
389 // updated(); 389 // updated();
390 mRelatedTo->removeRelation(this); 390 mRelatedTo->removeRelation(this);
391 } 391 }
392 mRelatedTo = relatedTo; 392 mRelatedTo = relatedTo;
393 if (mRelatedTo) mRelatedTo->addRelation(this); 393 if (mRelatedTo) {
394 mRelatedTo->addRelation(this);
395 mRelatedToUid = mRelatedTo->uid();
396 } else {
397 mRelatedToUid = "";
398 }
394} 399}
395 400
396Incidence *Incidence::relatedTo() const 401Incidence *Incidence::relatedTo() const
397{ 402{
398 return mRelatedTo; 403 return mRelatedTo;
399} 404}
400 405
401QPtrList<Incidence> Incidence::relations() const 406QPtrList<Incidence> Incidence::relations() const
402{ 407{
403 return mRelations; 408 return mRelations;
404} 409}
405 410
406void Incidence::addRelation(Incidence *event) 411void Incidence::addRelation(Incidence *event)
407{ 412{
408 if( mRelations.findRef( event ) == -1 ) { 413 if( mRelations.findRef( event ) == -1 ) {
409 mRelations.append(event); 414 mRelations.append(event);
410 //updated(); 415 //updated();
411 } 416 }
412} 417}
413 418
414void Incidence::removeRelation(Incidence *event) 419void Incidence::removeRelation(Incidence *event)
415{ 420{
416 421
417 mRelations.removeRef(event); 422 mRelations.removeRef(event);
418 423
419// if (event->getRelatedTo() == this) event->setRelatedTo(0); 424// if (event->getRelatedTo() == this) event->setRelatedTo(0);
420} 425}
421 426
422bool Incidence::recursOn(const QDate &qd) const 427bool Incidence::recursOn(const QDate &qd) const
423{ 428{
424 if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; 429 if (recurrence()->recursOnPure(qd) && !isException(qd)) return true;
425 else return false; 430 else return false;
426} 431}
427 432
428void Incidence::setExDates(const DateList &exDates) 433void Incidence::setExDates(const DateList &exDates)
429{ 434{
430 if (mReadOnly) return; 435 if (mReadOnly) return;
431 mExDates = exDates; 436 mExDates = exDates;
432 437
433 recurrence()->setRecurExDatesCount(mExDates.count()); 438 recurrence()->setRecurExDatesCount(mExDates.count());
434 439
435 updated(); 440 updated();
436} 441}
437 442
438void Incidence::addExDate(const QDate &date) 443void Incidence::addExDate(const QDate &date)
439{ 444{
440 if (mReadOnly) return; 445 if (mReadOnly) return;
441 mExDates.append(date); 446 mExDates.append(date);
442 447
443 recurrence()->setRecurExDatesCount(mExDates.count()); 448 recurrence()->setRecurExDatesCount(mExDates.count());
444 449
445 updated(); 450 updated();
446} 451}
447 452
448DateList Incidence::exDates() const 453DateList Incidence::exDates() const
449{ 454{
450 return mExDates; 455 return mExDates;
451} 456}
452 457
453bool Incidence::isException(const QDate &date) const 458bool Incidence::isException(const QDate &date) const
454{ 459{
455 DateList::ConstIterator it; 460 DateList::ConstIterator it;
456 for( it = mExDates.begin(); it != mExDates.end(); ++it ) { 461 for( it = mExDates.begin(); it != mExDates.end(); ++it ) {
457 if ( (*it) == date ) { 462 if ( (*it) == date ) {
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 8794f7a..7906046 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -1,169 +1,167 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <kglobalsettings.h> 22#include <kglobalsettings.h>
23#include <klocale.h> 23#include <klocale.h>
24#include <kdebug.h> 24#include <kdebug.h>
25#include <qregexp.h> 25#include <qregexp.h>
26 26
27#include "calendarlocal.h"
28#include "icalformat.h"
27#include "todo.h" 29#include "todo.h"
28 30
29using namespace KCal; 31using namespace KCal;
30 32
31Todo::Todo(): Incidence() 33Todo::Todo(): Incidence()
32{ 34{
33// mStatus = TENTATIVE; 35// mStatus = TENTATIVE;
34 36
35 mHasDueDate = false; 37 mHasDueDate = false;
36 setHasStartDate( false ); 38 setHasStartDate( false );
37 mCompleted = getEvenTime(QDateTime::currentDateTime()); 39 mCompleted = getEvenTime(QDateTime::currentDateTime());
38 mHasCompletedDate = false; 40 mHasCompletedDate = false;
39 mPercentComplete = 0; 41 mPercentComplete = 0;
40 mRunning = false; 42 mRunning = false;
41 mRunSaveTimer = 0; 43 mRunSaveTimer = 0;
42} 44}
43 45
44Todo::Todo(const Todo &t) : Incidence(t) 46Todo::Todo(const Todo &t) : Incidence(t)
45{ 47{
46 mDtDue = t.mDtDue; 48 mDtDue = t.mDtDue;
47 mHasDueDate = t.mHasDueDate; 49 mHasDueDate = t.mHasDueDate;
48 mCompleted = t.mCompleted; 50 mCompleted = t.mCompleted;
49 mHasCompletedDate = t.mHasCompletedDate; 51 mHasCompletedDate = t.mHasCompletedDate;
50 mPercentComplete = t.mPercentComplete; 52 mPercentComplete = t.mPercentComplete;
51 mRunning = false; 53 mRunning = false;
52 mRunSaveTimer = 0; 54 mRunSaveTimer = 0;
53} 55}
54 56
55Todo::~Todo() 57Todo::~Todo()
56{ 58{
57 setRunning( false ); 59 setRunning( false );
60 qDebug("Todo::~Todo() ");
58} 61}
59 62
60void Todo::setRunning( bool run ) 63void Todo::setRunning( bool run )
61{ 64{
62 if ( run == mRunning ) 65 if ( run == mRunning )
63 return; 66 return;
64 if ( !mRunSaveTimer ) { 67 if ( !mRunSaveTimer ) {
65 mRunSaveTimer = new QTimer ( this ); 68 mRunSaveTimer = new QTimer ( this );
66 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); 69 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) );
67 } 70 }
68 mRunning = run; 71 mRunning = run;
69 if ( mRunning ) { 72 if ( mRunning ) {
70 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min 73 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min
71 mRunStart = QDateTime::currentDateTime(); 74 mRunStart = QDateTime::currentDateTime();
72 } else { 75 } else {
73 mRunSaveTimer->stop(); 76 mRunSaveTimer->stop();
74 saveRunningInfoToFile(); 77 saveRunningInfoToFile();
75 } 78 }
76} 79}
77 80
78void Todo::saveRunningInfoToFile() 81void Todo::saveRunningInfoToFile()
79{ 82{
80 qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); 83 qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
81 84
82 QString dir = KGlobalSettings::timeTrackerDir(); 85 QString dir = KGlobalSettings::timeTrackerDir();
83 qDebug("%s ", dir.latin1()); 86 qDebug("%s ", dir.latin1());
84 QString file = "%1-%2-%3-%4-%5-%6-%7.tt"; 87 QString file = "%1%2%3-%4%5%6-%7%8%9-";
85 88 int runtime = mRunStart.secsTo( QDateTime::currentDateTime() );
86 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ).arg( mRunStart.time().msec(), 3 ); 89 runtime = (runtime / 60) +1;
90 int h = runtime / 60;
91 int m = runtime % 60;
92 int d = h / 24;
93 h = h % 24;
94 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ).arg( d,3 ).arg( h,2 ).arg( m,2 );
87 file.replace ( QRegExp (" "), "0" ); 95 file.replace ( QRegExp (" "), "0" );
88 file = dir +"/" +file; 96 file = dir +"/" +file + uid()+".ics";
89 qDebug("%s ", file.latin1()); 97 qDebug("File %s ",file.latin1() );
90 QStringList dataList; 98 CalendarLocal cal;
91 99 cal.setTimeZoneId( " 00:00 Europe/London(UTC)" );
92 //Summary 100 cal.addIncidence( clone() );
93 //Category 101 ICalFormat format;
94 //CategoryColor 102 format.save( &cal, file );
95 //StartRuntime
96 //Runtime
97 //Due
98 //Start
99 //Prio
100 //Erledigt
101 //Uid
102 //Parents uids
103 103
104
105
106} 104}
107 105
108int Todo::runTime() 106int Todo::runTime()
109{ 107{
110 if ( !mRunning ) 108 if ( !mRunning )
111 return 0; 109 return 0;
112 return mRunStart.secsTo( QDateTime::currentDateTime() ); 110 return mRunStart.secsTo( QDateTime::currentDateTime() );
113} 111}
114bool Todo::hasRunningSub() 112bool Todo::hasRunningSub()
115{ 113{
116 if ( mRunning ) 114 if ( mRunning )
117 return true; 115 return true;
118 Incidence *aTodo; 116 Incidence *aTodo;
119 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { 117 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
120 if ( ((Todo*)aTodo)->hasRunningSub() ) 118 if ( ((Todo*)aTodo)->hasRunningSub() )
121 return true; 119 return true;
122 } 120 }
123 return false; 121 return false;
124} 122}
125Incidence *Todo::clone() 123Incidence *Todo::clone()
126{ 124{
127 return new Todo(*this); 125 return new Todo(*this);
128} 126}
129 127
130bool Todo::contains ( Todo* from ) 128bool Todo::contains ( Todo* from )
131{ 129{
132 130
133 if ( !from->summary().isEmpty() ) 131 if ( !from->summary().isEmpty() )
134 if ( !summary().startsWith( from->summary() )) 132 if ( !summary().startsWith( from->summary() ))
135 return false; 133 return false;
136 if ( from->hasStartDate() ) { 134 if ( from->hasStartDate() ) {
137 if ( !hasStartDate() ) 135 if ( !hasStartDate() )
138 return false; 136 return false;
139 if ( from->dtStart() != dtStart()) 137 if ( from->dtStart() != dtStart())
140 return false; 138 return false;
141 } 139 }
142 if ( from->hasDueDate() ){ 140 if ( from->hasDueDate() ){
143 if ( !hasDueDate() ) 141 if ( !hasDueDate() )
144 return false; 142 return false;
145 if ( from->dtDue() != dtDue()) 143 if ( from->dtDue() != dtDue())
146 return false; 144 return false;
147 } 145 }
148 if ( !from->location().isEmpty() ) 146 if ( !from->location().isEmpty() )
149 if ( !location().startsWith( from->location() ) ) 147 if ( !location().startsWith( from->location() ) )
150 return false; 148 return false;
151 if ( !from->description().isEmpty() ) 149 if ( !from->description().isEmpty() )
152 if ( !description().startsWith( from->description() )) 150 if ( !description().startsWith( from->description() ))
153 return false; 151 return false;
154 if ( from->alarms().count() ) { 152 if ( from->alarms().count() ) {
155 Alarm *a = from->alarms().first(); 153 Alarm *a = from->alarms().first();
156 if ( a->enabled() ){ 154 if ( a->enabled() ){
157 if ( !alarms().count() ) 155 if ( !alarms().count() )
158 return false; 156 return false;
159 Alarm *b = alarms().first(); 157 Alarm *b = alarms().first();
160 if( ! b->enabled() ) 158 if( ! b->enabled() )
161 return false; 159 return false;
162 if ( ! (a->offset() == b->offset() )) 160 if ( ! (a->offset() == b->offset() ))
163 return false; 161 return false;
164 } 162 }
165 } 163 }
166 164
167 QStringList cat = categories(); 165 QStringList cat = categories();
168 QStringList catFrom = from->categories(); 166 QStringList catFrom = from->categories();
169 QString nCat; 167 QString nCat;
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp
index 62a31ae..8efc1ea 100644
--- a/libkcal/vcalformat.cpp
+++ b/libkcal/vcalformat.cpp
@@ -265,131 +265,131 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
265 tmpStr = qDateTimeToISO(anEvent->lastModified()); 265 tmpStr = qDateTimeToISO(anEvent->lastModified());
266 addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); 266 addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit());
267 267
268 // organizer stuff 268 // organizer stuff
269 tmpStr = "MAILTO:" + anEvent->organizer(); 269 tmpStr = "MAILTO:" + anEvent->organizer();
270 addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); 270 addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit());
271 271
272 // attendees 272 // attendees
273 if (anEvent->attendeeCount() != 0) { 273 if (anEvent->attendeeCount() != 0) {
274 QPtrList<Attendee> al = anEvent->attendees(); 274 QPtrList<Attendee> al = anEvent->attendees();
275 QPtrListIterator<Attendee> ai(al); 275 QPtrListIterator<Attendee> ai(al);
276 Attendee *curAttendee; 276 Attendee *curAttendee;
277 277
278 for (; ai.current(); ++ai) { 278 for (; ai.current(); ++ai) {
279 curAttendee = ai.current(); 279 curAttendee = ai.current();
280 if (!curAttendee->email().isEmpty() && 280 if (!curAttendee->email().isEmpty() &&
281 !curAttendee->name().isEmpty()) 281 !curAttendee->name().isEmpty())
282 tmpStr = "MAILTO:" + curAttendee->name() + " <" + 282 tmpStr = "MAILTO:" + curAttendee->name() + " <" +
283 curAttendee->email() + ">"; 283 curAttendee->email() + ">";
284 else if (curAttendee->name().isEmpty()) 284 else if (curAttendee->name().isEmpty())
285 tmpStr = "MAILTO: " + curAttendee->email(); 285 tmpStr = "MAILTO: " + curAttendee->email();
286 else if (curAttendee->email().isEmpty()) 286 else if (curAttendee->email().isEmpty())
287 tmpStr = "MAILTO: " + curAttendee->name(); 287 tmpStr = "MAILTO: " + curAttendee->name();
288 else if (curAttendee->name().isEmpty() && 288 else if (curAttendee->name().isEmpty() &&
289 curAttendee->email().isEmpty()) 289 curAttendee->email().isEmpty())
290 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; 290 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl;
291 VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); 291 VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit());
292 addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); 292 addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role()));
293 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); 293 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");
294 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); 294 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status()));
295 } 295 }
296 } 296 }
297 297
298 // description BL: 298 // description BL:
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->relatedTo()) { 329 if (anEvent->relatedToUid()) {
330 addPropValue(vtodo, VCRelatedToProp, 330 addPropValue(vtodo, VCRelatedToProp,
331 anEvent->relatedTo()->uid().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(const Event *anEvent)
@@ -611,131 +611,131 @@ VObject* VCalFormat::eventToVEvent(const Event *anEvent)
611 catStr = *it; 611 catStr = *it;
612 if (catStr[0] == ' ') 612 if (catStr[0] == ' ')
613 tmpStr += catStr.mid(1); 613 tmpStr += catStr.mid(1);
614 else 614 else
615 tmpStr += catStr; 615 tmpStr += catStr;
616 // this must be a ';' character as the vCalendar specification requires! 616 // this must be a ';' character as the vCalendar specification requires!
617 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 617 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
618 // read in. 618 // read in.
619 tmpStr += ";"; 619 tmpStr += ";";
620 } 620 }
621 if (!tmpStr.isEmpty()) { 621 if (!tmpStr.isEmpty()) {
622 tmpStr.truncate(tmpStr.length()-1); 622 tmpStr.truncate(tmpStr.length()-1);
623 addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); 623 addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit());
624 } 624 }
625 625
626 // attachments 626 // attachments
627 // TODO: handle binary attachments! 627 // TODO: handle binary attachments!
628 QPtrList<Attachment> attachments = anEvent->attachments(); 628 QPtrList<Attachment> attachments = anEvent->attachments();
629 for ( Attachment *at = attachments.first(); at; at = attachments.next() ) 629 for ( Attachment *at = attachments.first(); at; at = attachments.next() )
630 addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); 630 addPropValue(vevent, VCAttachProp, at->uri().local8Bit());
631 631
632 // resources 632 // resources
633 tmpStrList = anEvent->resources(); 633 tmpStrList = anEvent->resources();
634 tmpStr = tmpStrList.join(";"); 634 tmpStr = tmpStrList.join(";");
635 if (!tmpStr.isEmpty()) 635 if (!tmpStr.isEmpty())
636 addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); 636 addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit());
637 637
638 // alarm stuff 638 // alarm stuff
639 QPtrList<Alarm> alarms = anEvent->alarms(); 639 QPtrList<Alarm> alarms = anEvent->alarms();
640 Alarm* alarm; 640 Alarm* alarm;
641 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 641 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
642 if (alarm->enabled()) { 642 if (alarm->enabled()) {
643 VObject *a ; 643 VObject *a ;
644 tmpStr = qDateTimeToISO(alarm->time()); 644 tmpStr = qDateTimeToISO(alarm->time());
645 if (alarm->type() == Alarm::Audio) { 645 if (alarm->type() == Alarm::Audio) {
646 a = addProp(vevent, VCAAlarmProp); 646 a = addProp(vevent, VCAAlarmProp);
647 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 647 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
648 addPropValue(a, VCRepeatCountProp, "1"); 648 addPropValue(a, VCRepeatCountProp, "1");
649 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); 649 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile()));
650 } 650 }
651 if (alarm->type() == Alarm::Procedure) { 651 if (alarm->type() == Alarm::Procedure) {
652 a = addProp(vevent, VCPAlarmProp); 652 a = addProp(vevent, VCPAlarmProp);
653 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 653 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
654 addPropValue(a, VCRepeatCountProp, "1"); 654 addPropValue(a, VCRepeatCountProp, "1");
655 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); 655 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile()));
656 } else { 656 } else {
657 a = addProp(vevent, VCDAlarmProp); 657 a = addProp(vevent, VCDAlarmProp);
658 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 658 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
659 addPropValue(a, VCRepeatCountProp, "1"); 659 addPropValue(a, VCRepeatCountProp, "1");
660 addPropValue(a, VCDisplayStringProp, "beep!"); 660 addPropValue(a, VCDisplayStringProp, "beep!");
661 661
662 } 662 }
663 } 663 }
664 } 664 }
665 665
666 // priority 666 // priority
667 tmpStr.sprintf("%i",anEvent->priority()); 667 tmpStr.sprintf("%i",anEvent->priority());
668 addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); 668 addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit());
669 669
670 // transparency 670 // transparency
671 tmpStr.sprintf("%i",anEvent->transparency()); 671 tmpStr.sprintf("%i",anEvent->transparency());
672 addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); 672 addPropValue(vevent, VCTranspProp, tmpStr.local8Bit());
673 673
674 // related event 674 // related event
675 if (anEvent->relatedTo()) { 675 if (anEvent->relatedToUid()) {
676 addPropValue(vevent, VCRelatedToProp, 676 addPropValue(vevent, VCRelatedToProp,
677 anEvent->relatedTo()->uid().local8Bit()); 677 anEvent->relatedToUid().local8Bit());
678 } 678 }
679 679
680 if (anEvent->pilotId()) { 680 if (anEvent->pilotId()) {
681 // pilot sync stuff 681 // pilot sync stuff
682 tmpStr.sprintf("%i",anEvent->pilotId()); 682 tmpStr.sprintf("%i",anEvent->pilotId());
683 addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); 683 addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit());
684 tmpStr.sprintf("%i",anEvent->syncStatus()); 684 tmpStr.sprintf("%i",anEvent->syncStatus());
685 addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); 685 addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit());
686 } 686 }
687 687
688 return vevent; 688 return vevent;
689} 689}
690 690
691Todo *VCalFormat::VTodoToEvent(VObject *vtodo) 691Todo *VCalFormat::VTodoToEvent(VObject *vtodo)
692{ 692{
693 VObject *vo; 693 VObject *vo;
694 VObjectIterator voi; 694 VObjectIterator voi;
695 char *s; 695 char *s;
696 696
697 Todo *anEvent = new Todo; 697 Todo *anEvent = new Todo;
698 698
699 // creation date 699 // creation date
700 if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { 700 if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) {
701 anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 701 anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
702 deleteStr(s); 702 deleteStr(s);
703 } 703 }
704 704
705 // unique id 705 // unique id
706 vo = isAPropertyOf(vtodo, VCUniqueStringProp); 706 vo = isAPropertyOf(vtodo, VCUniqueStringProp);
707 // while the UID property is preferred, it is not required. We'll use the 707 // while the UID property is preferred, it is not required. We'll use the
708 // default Event UID if none is given. 708 // default Event UID if none is given.
709 if (vo) { 709 if (vo) {
710 anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); 710 anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo)));
711 deleteStr(s); 711 deleteStr(s);
712 } 712 }
713 713
714 // last modification date 714 // last modification date
715 if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { 715 if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) {
716 anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 716 anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
717 deleteStr(s); 717 deleteStr(s);
718 } 718 }
719 else 719 else
720 anEvent->setLastModified(QDateTime(QDate::currentDate(), 720 anEvent->setLastModified(QDateTime(QDate::currentDate(),
721 QTime::currentTime())); 721 QTime::currentTime()));
722 722
723 // organizer 723 // organizer
724 // if our extension property for the event's ORGANIZER exists, add it. 724 // if our extension property for the event's ORGANIZER exists, add it.
725 if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { 725 if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) {
726 anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); 726 anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo)));
727 deleteStr(s); 727 deleteStr(s);
728 } else { 728 } else {
729 anEvent->setOrganizer(mCalendar->getEmail()); 729 anEvent->setOrganizer(mCalendar->getEmail());
730 } 730 }
731 731
732 // attendees. 732 // attendees.
733 initPropIterator(&voi, vtodo); 733 initPropIterator(&voi, vtodo);
734 while (moreIteration(&voi)) { 734 while (moreIteration(&voi)) {
735 vo = nextVObject(&voi); 735 vo = nextVObject(&voi);
736 if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { 736 if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) {
737 Attendee *a; 737 Attendee *a;
738 VObject *vp; 738 VObject *vp;
739 s = fakeCString(vObjectUStringZValue(vo)); 739 s = fakeCString(vObjectUStringZValue(vo));
740 QString tmpStr = QString::fromLocal8Bit(s); 740 QString tmpStr = QString::fromLocal8Bit(s);
741 deleteStr(s); 741 deleteStr(s);
@@ -1543,133 +1543,137 @@ void VCalFormat::populate(VObject *vcal)
1543 // check to see if event was deleted by the kpilot conduit 1543 // check to see if event was deleted by the kpilot conduit
1544 if (atoi(s) == Event::SYNCDEL) { 1544 if (atoi(s) == Event::SYNCDEL) {
1545 deleteStr(s); 1545 deleteStr(s);
1546 kdDebug(5800) << "skipping pilot-deleted event" << endl; 1546 kdDebug(5800) << "skipping pilot-deleted event" << endl;
1547 goto SKIP; 1547 goto SKIP;
1548 } 1548 }
1549 deleteStr(s); 1549 deleteStr(s);
1550 } 1550 }
1551 1551
1552 // this code checks to see if we are trying to read in an event 1552 // this code checks to see if we are trying to read in an event
1553 // that we already find to be in the calendar. If we find this 1553 // that we already find to be in the calendar. If we find this
1554 // to be the case, we skip the event. 1554 // to be the case, we skip the event.
1555 if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { 1555 if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) {
1556 char *s = fakeCString(vObjectUStringZValue(curVOProp)); 1556 char *s = fakeCString(vObjectUStringZValue(curVOProp));
1557 QString tmpStr(s); 1557 QString tmpStr(s);
1558 deleteStr(s); 1558 deleteStr(s);
1559 1559
1560 if (mCalendar->event(tmpStr)) { 1560 if (mCalendar->event(tmpStr)) {
1561 goto SKIP; 1561 goto SKIP;
1562 } 1562 }
1563 if (mCalendar->todo(tmpStr)) { 1563 if (mCalendar->todo(tmpStr)) {
1564 goto SKIP; 1564 goto SKIP;
1565 } 1565 }
1566 } 1566 }
1567 1567
1568 if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && 1568 if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) &&
1569 (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { 1569 (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) {
1570 kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; 1570 kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl;
1571 goto SKIP; 1571 goto SKIP;
1572 } 1572 }
1573 1573
1574 anEvent = VEventToEvent(curVO); 1574 anEvent = VEventToEvent(curVO);
1575 // we now use addEvent instead of insertEvent so that the 1575 // we now use addEvent instead of insertEvent so that the
1576 // signal/slot get connected. 1576 // signal/slot get connected.
1577 if (anEvent) { 1577 if (anEvent) {
1578 if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) { 1578 if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) {
1579 kdDebug() << "VCalFormat::populate(): Event has invalid dates." 1579 kdDebug() << "VCalFormat::populate(): Event has invalid dates."
1580 << endl; 1580 << endl;
1581 } else { 1581 } else {
1582 mCalendar->addEvent(anEvent); 1582 mCalendar->addEvent(anEvent);
1583 } 1583 }
1584 } else { 1584 } else {
1585 // some sort of error must have occurred while in translation. 1585 // some sort of error must have occurred while in translation.
1586 goto SKIP; 1586 goto SKIP;
1587 } 1587 }
1588 } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { 1588 } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) {
1589 Todo *aTodo = VTodoToEvent(curVO); 1589 Todo *aTodo = VTodoToEvent(curVO);
1590 mCalendar->addTodo(aTodo); 1590 mCalendar->addTodo(aTodo);
1591 } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || 1591 } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) ||
1592 (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || 1592 (strcmp(vObjectName(curVO), VCProdIdProp) == 0) ||
1593 (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { 1593 (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) {
1594 // do nothing, we know these properties and we want to skip them. 1594 // do nothing, we know these properties and we want to skip them.
1595 // we have either already processed them or are ignoring them. 1595 // we have either already processed them or are ignoring them.
1596 ; 1596 ;
1597 } else { 1597 } else {
1598 kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; 1598 kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl;
1599 } 1599 }
1600 SKIP: 1600 SKIP:
1601 ; 1601 ;
1602 } // while 1602 } // while
1603 1603
1604 // Post-Process list of events with relations, put Event objects in relation 1604 // Post-Process list of events with relations, put Event objects in relation
1605 Event *ev; 1605 Event *ev;
1606 for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { 1606 for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) {
1607 ev->setRelatedTo(mCalendar->event(ev->relatedToUid())); 1607 Incidence * inc = mCalendar->event(ev->relatedToUid());
1608 if ( inc )
1609 ev->setRelatedTo( inc );
1608 } 1610 }
1609 Todo *todo; 1611 Todo *todo;
1610 for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { 1612 for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) {
1611 todo->setRelatedTo(mCalendar->todo(todo->relatedToUid())); 1613 Incidence * inc = mCalendar->todo(todo->relatedToUid());
1614 if ( inc )
1615 todo->setRelatedTo( inc );
1612 } 1616 }
1613} 1617}
1614 1618
1615const char *VCalFormat::dayFromNum(int day) 1619const char *VCalFormat::dayFromNum(int day)
1616{ 1620{
1617 const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; 1621 const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " };
1618 1622
1619 return days[day]; 1623 return days[day];
1620} 1624}
1621 1625
1622int VCalFormat::numFromDay(const QString &day) 1626int VCalFormat::numFromDay(const QString &day)
1623{ 1627{
1624 if (day == "MO ") return 0; 1628 if (day == "MO ") return 0;
1625 if (day == "TU ") return 1; 1629 if (day == "TU ") return 1;
1626 if (day == "WE ") return 2; 1630 if (day == "WE ") return 2;
1627 if (day == "TH ") return 3; 1631 if (day == "TH ") return 3;
1628 if (day == "FR ") return 4; 1632 if (day == "FR ") return 4;
1629 if (day == "SA ") return 5; 1633 if (day == "SA ") return 5;
1630 if (day == "SU ") return 6; 1634 if (day == "SU ") return 6;
1631 1635
1632 return -1; // something bad happened. :) 1636 return -1; // something bad happened. :)
1633} 1637}
1634Attendee::Role VCalFormat::readRole(const char *s) const 1638Attendee::Role VCalFormat::readRole(const char *s) const
1635{ 1639{
1636 QString statStr = s; 1640 QString statStr = s;
1637 statStr = statStr.upper(); 1641 statStr = statStr.upper();
1638 Attendee::Role role = Attendee::ReqParticipant; 1642 Attendee::Role role = Attendee::ReqParticipant;
1639 1643
1640 if ( statStr == "OWNER") 1644 if ( statStr == "OWNER")
1641 role = Attendee::Chair; 1645 role = Attendee::Chair;
1642 // enum Role { ReqParticipant, OptParticipant, NonParticipant, Chair }; 1646 // enum Role { ReqParticipant, OptParticipant, NonParticipant, Chair };
1643 1647
1644 return role; 1648 return role;
1645} 1649}
1646 1650
1647QCString VCalFormat::writeRole(Attendee::Role role) const 1651QCString VCalFormat::writeRole(Attendee::Role role) const
1648{ 1652{
1649 if ( role == Attendee::Chair ) 1653 if ( role == Attendee::Chair )
1650 return "OWNER"; 1654 return "OWNER";
1651 return "ATTENDEE"; 1655 return "ATTENDEE";
1652} 1656}
1653Attendee::PartStat VCalFormat::readStatus(const char *s) const 1657Attendee::PartStat VCalFormat::readStatus(const char *s) const
1654{ 1658{
1655 QString statStr = s; 1659 QString statStr = s;
1656 statStr = statStr.upper(); 1660 statStr = statStr.upper();
1657 Attendee::PartStat status; 1661 Attendee::PartStat status;
1658 1662
1659 if (statStr == "X-ACTION") 1663 if (statStr == "X-ACTION")
1660 status = Attendee::NeedsAction; 1664 status = Attendee::NeedsAction;
1661 else if (statStr == "NEEDS ACTION") 1665 else if (statStr == "NEEDS ACTION")
1662 status = Attendee::NeedsAction; 1666 status = Attendee::NeedsAction;
1663 else if (statStr== "ACCEPTED") 1667 else if (statStr== "ACCEPTED")
1664 status = Attendee::Accepted; 1668 status = Attendee::Accepted;
1665 else if (statStr== "SENT") 1669 else if (statStr== "SENT")
1666 status = Attendee::NeedsAction; 1670 status = Attendee::NeedsAction;
1667 else if (statStr== "TENTATIVE") 1671 else if (statStr== "TENTATIVE")
1668 status = Attendee::Tentative; 1672 status = Attendee::Tentative;
1669 else if (statStr== "CONFIRMED") 1673 else if (statStr== "CONFIRMED")
1670 status = Attendee::Accepted; 1674 status = Attendee::Accepted;
1671 else if (statStr== "DECLINED") 1675 else if (statStr== "DECLINED")
1672 status = Attendee::Declined; 1676 status = Attendee::Declined;
1673 else if (statStr== "COMPLETED") 1677 else if (statStr== "COMPLETED")
1674 status = Attendee::Completed; 1678 status = Attendee::Completed;
1675 else if (statStr== "DELEGATED") 1679 else if (statStr== "DELEGATED")