summaryrefslogtreecommitdiffabout
path: root/libkcal/vcalformat.cpp
Unidiff
Diffstat (limited to 'libkcal/vcalformat.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/vcalformat.cpp52
1 files changed, 27 insertions, 25 deletions
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp
index 2e19740..9cbaf16 100644
--- a/libkcal/vcalformat.cpp
+++ b/libkcal/vcalformat.cpp
@@ -13,29 +13,31 @@
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 <qapplication.h> 22#include <qapplication.h>
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qptrlist.h> 25#include <q3ptrlist.h>
26#include <qregexp.h> 26#include <qregexp.h>
27#include <qclipboard.h> 27#include <qclipboard.h>
28#include <qdialog.h> 28#include <qdialog.h>
29#include <qfile.h> 29#include <qfile.h>
30//Added by qt3to4:
31#include <Q3CString>
30 32
31#include <kdebug.h> 33#include <kdebug.h>
32#include <kglobal.h> 34#include <kglobal.h>
33#include <kmessagebox.h> 35#include <kmessagebox.h>
34#include <kiconloader.h> 36#include <kiconloader.h>
35#include <klocale.h> 37#include <klocale.h>
36 38
37#include "vcc.h" 39#include "vcc.h"
38#include "vobject.h" 40#include "vobject.h"
39 41
40#include "vcaldrag.h" 42#include "vcaldrag.h"
41#include "calendar.h" 43#include "calendar.h"
@@ -99,55 +101,55 @@ bool VCalFormat::save(Calendar *calendar, const QString &fileName)
99 101
100 102
101 vcal = newVObject(VCCalProp); 103 vcal = newVObject(VCCalProp);
102 104
103 // addPropValue(vcal,VCLocationProp, "0.0"); 105 // addPropValue(vcal,VCLocationProp, "0.0");
104 addPropValue(vcal,VCProdIdProp, productId()); 106 addPropValue(vcal,VCProdIdProp, productId());
105 tmpStr = mCalendar->getTimeZoneStr(); 107 tmpStr = mCalendar->getTimeZoneStr();
106 //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); 108 //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() );
107 addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); 109 addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit());
108 addPropValue(vcal,VCVersionProp, _VCAL_VERSION); 110 addPropValue(vcal,VCVersionProp, _VCAL_VERSION);
109 111
110 // TODO STUFF 112 // TODO STUFF
111 QPtrList<Todo> todoList = mCalendar->rawTodos(); 113 Q3PtrList<Todo> todoList = mCalendar->rawTodos();
112 QPtrListIterator<Todo> qlt(todoList); 114 Q3PtrListIterator<Todo> qlt(todoList);
113 for (; qlt.current(); ++qlt) { 115 for (; qlt.current(); ++qlt) {
114 vo = eventToVTodo(qlt.current()); 116 vo = eventToVTodo(qlt.current());
115 addVObjectProp(vcal, vo); 117 addVObjectProp(vcal, vo);
116 } 118 }
117 119
118 // EVENT STUFF 120 // EVENT STUFF
119 QPtrList<Event> events = mCalendar->rawEvents(); 121 Q3PtrList<Event> events = mCalendar->rawEvents();
120 Event *ev; 122 Event *ev;
121 for(ev=events.first();ev;ev=events.next()) { 123 for(ev=events.first();ev;ev=events.next()) {
122 vo = eventToVEvent(ev); 124 vo = eventToVEvent(ev);
123 addVObjectProp(vcal, vo); 125 addVObjectProp(vcal, vo);
124 } 126 }
125 127
126 writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); 128 writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal);
127 cleanVObjects(vcal); 129 cleanVObjects(vcal);
128 cleanStrTbl(); 130 cleanStrTbl();
129 131
130 if (QFile::exists(fileName)) { 132 if (QFile::exists(fileName)) {
131 return true; 133 return true;
132 } else { 134 } else {
133 return false; // error 135 return false; // error
134 } 136 }
135} 137}
136 138
137bool VCalFormat::fromString( Calendar *calendar, const QString &text ) 139bool VCalFormat::fromString( Calendar *calendar, const QString &text )
138{ 140{
139 // TODO: Factor out VCalFormat::fromString() 141 // TODO: Factor out VCalFormat::fromString()
140 142
141 QCString data = text.utf8(); 143 Q3CString data = text.utf8();
142 144
143 if ( !data.size() ) return false; 145 if ( !data.size() ) return false;
144 146
145 VObject *vcal = Parse_MIME( data.data(), data.size()); 147 VObject *vcal = Parse_MIME( data.data(), data.size());
146 if ( !vcal ) return false; 148 if ( !vcal ) return false;
147 149
148 VObjectIterator i; 150 VObjectIterator i;
149 VObject *curvo; 151 VObject *curvo;
150 initPropIterator( &i, vcal ); 152 initPropIterator( &i, vcal );
151 153
152 // we only take the first object. TODO: parse all incidences. 154 // we only take the first object. TODO: parse all incidences.
153 do { 155 do {
@@ -201,25 +203,25 @@ QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal
201QString VCalFormat::toString( Calendar *calendar ) 203QString VCalFormat::toString( Calendar *calendar )
202{ 204{
203 // TODO: Factor out VCalFormat::asString() 205 // TODO: Factor out VCalFormat::asString()
204 206
205 VObject *vcal = newVObject(VCCalProp); 207 VObject *vcal = newVObject(VCCalProp);
206 208
207 addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); 209 addPropValue( vcal, VCProdIdProp, CalFormat::productId() );
208 QString tmpStr = mCalendar->getTimeZoneStr(); 210 QString tmpStr = mCalendar->getTimeZoneStr();
209 addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); 211 addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() );
210 addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); 212 addPropValue( vcal, VCVersionProp, _VCAL_VERSION );
211 213
212 // TODO: Use all data. 214 // TODO: Use all data.
213 QPtrList<Event> events = calendar->events(); 215 Q3PtrList<Event> events = calendar->events();
214 Event *event = events.first(); 216 Event *event = events.first();
215 if ( !event ) return QString::null; 217 if ( !event ) return QString::null;
216 218
217 VObject *vevent = eventToVEvent( event ); 219 VObject *vevent = eventToVEvent( event );
218 220
219 addVObjectProp( vcal, vevent ); 221 addVObjectProp( vcal, vevent );
220 222
221 char *buf = writeMemVObject( 0, 0, vcal ); 223 char *buf = writeMemVObject( 0, 0, vcal );
222 224
223 QString result( buf ); 225 QString result( buf );
224 226
225 cleanVObject( vcal ); 227 cleanVObject( vcal );
@@ -262,26 +264,26 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
262 addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); 264 addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit());
263 265
264 // last modification date 266 // last modification date
265 tmpStr = qDateTimeToISO(anEvent->lastModified()); 267 tmpStr = qDateTimeToISO(anEvent->lastModified());
266 addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); 268 addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit());
267 269
268 // organizer stuff 270 // organizer stuff
269 tmpStr = "MAILTO:" + anEvent->organizer(); 271 tmpStr = "MAILTO:" + anEvent->organizer();
270 addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); 272 addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit());
271 273
272 // attendees 274 // attendees
273 if (anEvent->attendeeCount() != 0) { 275 if (anEvent->attendeeCount() != 0) {
274 QPtrList<Attendee> al = anEvent->attendees(); 276 Q3PtrList<Attendee> al = anEvent->attendees();
275 QPtrListIterator<Attendee> ai(al); 277 Q3PtrListIterator<Attendee> ai(al);
276 Attendee *curAttendee; 278 Attendee *curAttendee;
277 279
278 for (; ai.current(); ++ai) { 280 for (; ai.current(); ++ai) {
279 curAttendee = ai.current(); 281 curAttendee = ai.current();
280 if (!curAttendee->email().isEmpty() && 282 if (!curAttendee->email().isEmpty() &&
281 !curAttendee->name().isEmpty()) 283 !curAttendee->name().isEmpty())
282 tmpStr = "MAILTO:" + curAttendee->name() + " <" + 284 tmpStr = "MAILTO:" + curAttendee->name() + " <" +
283 curAttendee->email() + ">"; 285 curAttendee->email() + ">";
284 else if (curAttendee->name().isEmpty()) 286 else if (curAttendee->name().isEmpty())
285 tmpStr = "MAILTO: " + curAttendee->email(); 287 tmpStr = "MAILTO: " + curAttendee->email();
286 else if (curAttendee->email().isEmpty()) 288 else if (curAttendee->email().isEmpty())
287 tmpStr = "MAILTO: " + curAttendee->name(); 289 tmpStr = "MAILTO: " + curAttendee->name();
@@ -317,25 +319,25 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
317 "NEEDS_ACTION"); 319 "NEEDS_ACTION");
318 // completion date 320 // completion date
319 if (anEvent->hasCompletedDate()) { 321 if (anEvent->hasCompletedDate()) {
320 tmpStr = qDateTimeToISO(anEvent->completed()); 322 tmpStr = qDateTimeToISO(anEvent->completed());
321 addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); 323 addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit());
322 } 324 }
323 325
324 // priority 326 // priority
325 tmpStr.sprintf("%i",anEvent->priority()); 327 tmpStr.sprintf("%i",anEvent->priority());
326 addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); 328 addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit());
327 329
328 // related event 330 // related event
329 if (anEvent->relatedToUid()) { 331 if (!anEvent->relatedToUid().isEmpty()) {
330 addPropValue(vtodo, VCRelatedToProp, 332 addPropValue(vtodo, VCRelatedToProp,
331 anEvent->relatedToUid().local8Bit()); 333 anEvent->relatedToUid().local8Bit());
332 } 334 }
333 335
334 // categories 336 // categories
335 QStringList tmpStrList = anEvent->categories(); 337 QStringList tmpStrList = anEvent->categories();
336 tmpStr = ""; 338 tmpStr = "";
337 QString catStr; 339 QString catStr;
338 for ( QStringList::Iterator it = tmpStrList.begin(); 340 for ( QStringList::Iterator it = tmpStrList.begin();
339 it != tmpStrList.end(); 341 it != tmpStrList.end();
340 ++it ) { 342 ++it ) {
341 catStr = *it; 343 catStr = *it;
@@ -346,25 +348,25 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
346 // this must be a ';' character as the vCalendar specification requires! 348 // 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 349 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
348 // read in. 350 // read in.
349 tmpStr += ";"; 351 tmpStr += ";";
350 } 352 }
351 if (!tmpStr.isEmpty()) { 353 if (!tmpStr.isEmpty()) {
352 tmpStr.truncate(tmpStr.length()-1); 354 tmpStr.truncate(tmpStr.length()-1);
353 addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); 355 addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit());
354 } 356 }
355 357
356 // alarm stuff 358 // alarm stuff
357 kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; 359 kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl;
358 QPtrList<Alarm> alarms = anEvent->alarms(); 360 Q3PtrList<Alarm> alarms = anEvent->alarms();
359 Alarm* alarm; 361 Alarm* alarm;
360 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 362 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
361 if (alarm->enabled()) { 363 if (alarm->enabled()) {
362 VObject *a; 364 VObject *a;
363 tmpStr = qDateTimeToISO(alarm->time()); 365 tmpStr = qDateTimeToISO(alarm->time());
364 if (alarm->type() == Alarm::Audio) { 366 if (alarm->type() == Alarm::Audio) {
365 a = addProp(vtodo, VCAAlarmProp); 367 a = addProp(vtodo, VCAAlarmProp);
366 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 368 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
367 addPropValue(a, VCRepeatCountProp, "1"); 369 addPropValue(a, VCRepeatCountProp, "1");
368 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); 370 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile()));
369 } 371 }
370 else if (alarm->type() == Alarm::Procedure) { 372 else if (alarm->type() == Alarm::Procedure) {
@@ -424,26 +426,26 @@ VObject* VCalFormat::eventToVEvent(Event *anEvent)
424 tmpStr.sprintf("%i", anEvent->revision()); 426 tmpStr.sprintf("%i", anEvent->revision());
425 addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); 427 addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit());
426 428
427 // last modification date 429 // last modification date
428 tmpStr = qDateTimeToISO(anEvent->lastModified()); 430 tmpStr = qDateTimeToISO(anEvent->lastModified());
429 addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); 431 addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit());
430 432
431 // attendee and organizer stuff 433 // attendee and organizer stuff
432 tmpStr = "MAILTO:" + anEvent->organizer(); 434 tmpStr = "MAILTO:" + anEvent->organizer();
433 addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); 435 addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit());
434 436
435 if (anEvent->attendeeCount() != 0) { 437 if (anEvent->attendeeCount() != 0) {
436 QPtrList<Attendee> al = anEvent->attendees(); 438 Q3PtrList<Attendee> al = anEvent->attendees();
437 QPtrListIterator<Attendee> ai(al); 439 Q3PtrListIterator<Attendee> ai(al);
438 Attendee *curAttendee; 440 Attendee *curAttendee;
439 441
440 // TODO: Put this functionality into Attendee class 442 // TODO: Put this functionality into Attendee class
441 for (; ai.current(); ++ai) { 443 for (; ai.current(); ++ai) {
442 curAttendee = ai.current(); 444 curAttendee = ai.current();
443 if (!curAttendee->email().isEmpty() && 445 if (!curAttendee->email().isEmpty() &&
444 !curAttendee->name().isEmpty()) 446 !curAttendee->name().isEmpty())
445 tmpStr = "MAILTO:" + curAttendee->name() + " <" + 447 tmpStr = "MAILTO:" + curAttendee->name() + " <" +
446 curAttendee->email() + ">"; 448 curAttendee->email() + ">";
447 else if (curAttendee->name().isEmpty()) 449 else if (curAttendee->name().isEmpty())
448 tmpStr = "MAILTO: " + curAttendee->email(); 450 tmpStr = "MAILTO: " + curAttendee->email();
449 else if (curAttendee->email().isEmpty()) 451 else if (curAttendee->email().isEmpty())
@@ -452,26 +454,26 @@ VObject* VCalFormat::eventToVEvent(Event *anEvent)
452 curAttendee->email().isEmpty()) 454 curAttendee->email().isEmpty())
453 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; 455 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl;
454 VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); 456 VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit());
455 addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); 457 addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role()));
456 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); 458 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");
457 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); 459 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status()));
458 } 460 }
459 } 461 }
460 462
461 // recurrence rule stuff 463 // recurrence rule stuff
462 if (anEvent->doesRecur()) { 464 if (anEvent->doesRecur()) {
463 // some more variables 465 // some more variables
464 QPtrList<Recurrence::rMonthPos> tmpPositions; 466 Q3PtrList<Recurrence::rMonthPos> tmpPositions;
465 QPtrList<int> tmpDays; 467 Q3PtrList<int> tmpDays;
466 int *tmpDay; 468 int *tmpDay;
467 Recurrence::rMonthPos *tmpPos; 469 Recurrence::rMonthPos *tmpPos;
468 QString tmpStr2; 470 QString tmpStr2;
469 int i; 471 int i;
470 472
471 switch(anEvent->recurrence()->doesRecur()) { 473 switch(anEvent->recurrence()->doesRecur()) {
472 case Recurrence::rDaily: 474 case Recurrence::rDaily:
473 tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); 475 tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency());
474// if (anEvent->rDuration > 0) 476// if (anEvent->rDuration > 0)
475 //tmpStr += "#"; 477 //tmpStr += "#";
476 break; 478 break;
477 case Recurrence::rWeekly: 479 case Recurrence::rWeekly:
@@ -536,25 +538,25 @@ VObject* VCalFormat::eventToVEvent(Event *anEvent)
536 break; 538 break;
537 default: 539 default:
538 kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; 540 kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl;
539 break; 541 break;
540 } // switch 542 } // switch
541 543
542 if (anEvent->recurrence()->duration() > 0) { 544 if (anEvent->recurrence()->duration() > 0) {
543 tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); 545 tmpStr2.sprintf("#%i",anEvent->recurrence()->duration());
544 tmpStr += tmpStr2; 546 tmpStr += tmpStr2;
545 } else if (anEvent->recurrence()->duration() == -1) { 547 } else if (anEvent->recurrence()->duration() == -1) {
546 tmpStr += "#0"; // defined as repeat forever 548 tmpStr += "#0"; // defined as repeat forever
547 } else { 549 } else {
548 tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); 550 tmpStr += qDateTimeToISO((QDateTime)anEvent->recurrence()->endDate(), FALSE);
549 } 551 }
550 addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); 552 addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit());
551 553
552 } // event repeats 554 } // event repeats
553 555
554 // exceptions to recurrence 556 // exceptions to recurrence
555 DateList dateList = anEvent->exDates(); 557 DateList dateList = anEvent->exDates();
556 DateList::ConstIterator it; 558 DateList::ConstIterator it;
557 QString tmpStr2; 559 QString tmpStr2;
558 560
559 for (it = dateList.begin(); it != dateList.end(); ++it) { 561 for (it = dateList.begin(); it != dateList.end(); ++it) {
560 tmpStr = qDateToISO(*it) + ";"; 562 tmpStr = qDateToISO(*it) + ";";
@@ -616,36 +618,36 @@ VObject* VCalFormat::eventToVEvent(Event *anEvent)
616 // this must be a ';' character as the vCalendar specification requires! 618 // 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 619 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
618 // read in. 620 // read in.
619 tmpStr += ";"; 621 tmpStr += ";";
620 } 622 }
621 if (!tmpStr.isEmpty()) { 623 if (!tmpStr.isEmpty()) {
622 tmpStr.truncate(tmpStr.length()-1); 624 tmpStr.truncate(tmpStr.length()-1);
623 addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); 625 addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit());
624 } 626 }
625 627
626 // attachments 628 // attachments
627 // TODO: handle binary attachments! 629 // TODO: handle binary attachments!
628 QPtrList<Attachment> attachments = anEvent->attachments(); 630 Q3PtrList<Attachment> attachments = anEvent->attachments();
629 for ( Attachment *at = attachments.first(); at; at = attachments.next() ) 631 for ( Attachment *at = attachments.first(); at; at = attachments.next() )
630 addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); 632 addPropValue(vevent, VCAttachProp, at->uri().local8Bit());
631 633
632 // resources 634 // resources
633 tmpStrList = anEvent->resources(); 635 tmpStrList = anEvent->resources();
634 tmpStr = tmpStrList.join(";"); 636 tmpStr = tmpStrList.join(";");
635 if (!tmpStr.isEmpty()) 637 if (!tmpStr.isEmpty())
636 addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); 638 addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit());
637 639
638 // alarm stuff 640 // alarm stuff
639 QPtrList<Alarm> alarms = anEvent->alarms(); 641 Q3PtrList<Alarm> alarms = anEvent->alarms();
640 Alarm* alarm; 642 Alarm* alarm;
641 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 643 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
642 if (alarm->enabled()) { 644 if (alarm->enabled()) {
643 VObject *a ; 645 VObject *a ;
644 tmpStr = qDateTimeToISO(alarm->time()); 646 tmpStr = qDateTimeToISO(alarm->time());
645 if (alarm->type() == Alarm::Audio) { 647 if (alarm->type() == Alarm::Audio) {
646 a = addProp(vevent, VCAAlarmProp); 648 a = addProp(vevent, VCAAlarmProp);
647 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 649 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
648 addPropValue(a, VCRepeatCountProp, "1"); 650 addPropValue(a, VCRepeatCountProp, "1");
649 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); 651 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile()));
650 } 652 }
651 if (alarm->type() == Alarm::Procedure) { 653 if (alarm->type() == Alarm::Procedure) {
@@ -663,25 +665,25 @@ VObject* VCalFormat::eventToVEvent(Event *anEvent)
663 } 665 }
664 } 666 }
665 667
666 // priority 668 // priority
667 tmpStr.sprintf("%i",anEvent->priority()); 669 tmpStr.sprintf("%i",anEvent->priority());
668 addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); 670 addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit());
669 671
670 // transparency 672 // transparency
671 tmpStr.sprintf("%i",anEvent->transparency()); 673 tmpStr.sprintf("%i",anEvent->transparency());
672 addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); 674 addPropValue(vevent, VCTranspProp, tmpStr.local8Bit());
673 675
674 // related event 676 // related event
675 if (anEvent->relatedToUid()) { 677 if (!anEvent->relatedToUid().isEmpty()) {
676 addPropValue(vevent, VCRelatedToProp, 678 addPropValue(vevent, VCRelatedToProp,
677 anEvent->relatedToUid().local8Bit()); 679 anEvent->relatedToUid().local8Bit());
678 } 680 }
679 681
680 if (anEvent->pilotId()) { 682 if (anEvent->pilotId()) {
681 // pilot sync stuff 683 // pilot sync stuff
682 tmpStr.sprintf("%i",anEvent->pilotId()); 684 tmpStr.sprintf("%i",anEvent->pilotId());
683 addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); 685 addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit());
684 tmpStr.sprintf("%i",anEvent->syncStatus()); 686 tmpStr.sprintf("%i",anEvent->syncStatus());
685 addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); 687 addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit());
686 } 688 }
687 689
@@ -1399,38 +1401,38 @@ Event* VCalFormat::VEventToEvent(VObject *vevent)
1399 } 1401 }
1400 else 1402 else
1401 anEvent->setSyncStatus(Event::SYNCMOD); 1403 anEvent->setSyncStatus(Event::SYNCMOD);
1402 1404
1403 return anEvent; 1405 return anEvent;
1404} 1406}
1405 1407
1406 1408
1407QString VCalFormat::qDateToISO(const QDate &qd) 1409QString VCalFormat::qDateToISO(const QDate &qd)
1408{ 1410{
1409 QString tmpStr; 1411 QString tmpStr;
1410 1412
1411 ASSERT(qd.isValid()); 1413 Q_ASSERT(qd.isValid());
1412 1414
1413 tmpStr.sprintf("%.2d%.2d%.2d", 1415 tmpStr.sprintf("%.2d%.2d%.2d",
1414 qd.year(), qd.month(), qd.day()); 1416 qd.year(), qd.month(), qd.day());
1415 return tmpStr; 1417 return tmpStr;
1416 1418
1417} 1419}
1418 1420
1419QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) 1421QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu)
1420{ 1422{
1421 QString tmpStr; 1423 QString tmpStr;
1422 1424
1423 ASSERT(qdt.date().isValid()); 1425 Q_ASSERT(qdt.date().isValid());
1424 ASSERT(qdt.time().isValid()); 1426 Q_ASSERT(qdt.time().isValid());
1425 if (zulu && !useLocalTime ) { 1427 if (zulu && !useLocalTime ) {
1426 QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); 1428 QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60);
1427 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", 1429 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ",
1428 tmpDT.date().year(), tmpDT.date().month(), 1430 tmpDT.date().year(), tmpDT.date().month(),
1429 tmpDT.date().day(), tmpDT.time().hour(), 1431 tmpDT.date().day(), tmpDT.time().hour(),
1430 tmpDT.time().minute(), tmpDT.time().second()); 1432 tmpDT.time().minute(), tmpDT.time().second());
1431 } else { 1433 } else {
1432 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", 1434 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d",
1433 qdt.date().year(), qdt.date().month(), 1435 qdt.date().year(), qdt.date().month(),
1434 qdt.date().day(), qdt.time().hour(), 1436 qdt.date().day(), qdt.time().hour(),
1435 qdt.time().minute(), qdt.time().second()); 1437 qdt.time().minute(), qdt.time().second());
1436 } 1438 }
@@ -1445,26 +1447,26 @@ QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr)
1445 int year, month, day, hour, minute, second; 1447 int year, month, day, hour, minute, second;
1446 1448
1447 tmpStr = dtStr; 1449 tmpStr = dtStr;
1448 year = tmpStr.left(4).toInt(); 1450 year = tmpStr.left(4).toInt();
1449 month = tmpStr.mid(4,2).toInt(); 1451 month = tmpStr.mid(4,2).toInt();
1450 day = tmpStr.mid(6,2).toInt(); 1452 day = tmpStr.mid(6,2).toInt();
1451 hour = tmpStr.mid(9,2).toInt(); 1453 hour = tmpStr.mid(9,2).toInt();
1452 minute = tmpStr.mid(11,2).toInt(); 1454 minute = tmpStr.mid(11,2).toInt();
1453 second = tmpStr.mid(13,2).toInt(); 1455 second = tmpStr.mid(13,2).toInt();
1454 tmpDate.setYMD(year, month, day); 1456 tmpDate.setYMD(year, month, day);
1455 tmpTime.setHMS(hour, minute, second); 1457 tmpTime.setHMS(hour, minute, second);
1456 1458
1457 ASSERT(tmpDate.isValid()); 1459 Q_ASSERT(tmpDate.isValid());
1458 ASSERT(tmpTime.isValid()); 1460 Q_ASSERT(tmpTime.isValid());
1459 QDateTime tmpDT(tmpDate, tmpTime); 1461 QDateTime tmpDT(tmpDate, tmpTime);
1460 // correct for GMT if string is in Zulu format 1462 // correct for GMT if string is in Zulu format
1461 if (dtStr.at(dtStr.length()-1) == 'Z') 1463 if (dtStr.at(dtStr.length()-1) == 'Z')
1462 tmpDT = tmpDT.addSecs (KGlobal::locale()->localTimeOffset( tmpDT )*60); 1464 tmpDT = tmpDT.addSecs (KGlobal::locale()->localTimeOffset( tmpDT )*60);
1463 return tmpDT; 1465 return tmpDT;
1464} 1466}
1465 1467
1466QDate VCalFormat::ISOToQDate(const QString &dateStr) 1468QDate VCalFormat::ISOToQDate(const QString &dateStr)
1467{ 1469{
1468 int year, month, day; 1470 int year, month, day;
1469 1471
1470 year = dateStr.left(4).toInt(); 1472 year = dateStr.left(4).toInt();
@@ -1639,25 +1641,25 @@ Attendee::Role VCalFormat::readRole(const char *s) const
1639{ 1641{
1640 QString statStr = s; 1642 QString statStr = s;
1641 statStr = statStr.upper(); 1643 statStr = statStr.upper();
1642 Attendee::Role role = Attendee::ReqParticipant; 1644 Attendee::Role role = Attendee::ReqParticipant;
1643 1645
1644 if ( statStr == "OWNER") 1646 if ( statStr == "OWNER")
1645 role = Attendee::Chair; 1647 role = Attendee::Chair;
1646 // enum Role { ReqParticipant, OptParticipant, NonParticipant, Chair }; 1648 // enum Role { ReqParticipant, OptParticipant, NonParticipant, Chair };
1647 1649
1648 return role; 1650 return role;
1649} 1651}
1650 1652
1651QCString VCalFormat::writeRole(Attendee::Role role) const 1653Q3CString VCalFormat::writeRole(Attendee::Role role) const
1652{ 1654{
1653 if ( role == Attendee::Chair ) 1655 if ( role == Attendee::Chair )
1654 return "OWNER"; 1656 return "OWNER";
1655 return "ATTENDEE"; 1657 return "ATTENDEE";
1656} 1658}
1657Attendee::PartStat VCalFormat::readStatus(const char *s) const 1659Attendee::PartStat VCalFormat::readStatus(const char *s) const
1658{ 1660{
1659 QString statStr = s; 1661 QString statStr = s;
1660 statStr = statStr.upper(); 1662 statStr = statStr.upper();
1661 Attendee::PartStat status; 1663 Attendee::PartStat status;
1662 1664
1663 if (statStr == "X-ACTION") 1665 if (statStr == "X-ACTION")
@@ -1677,25 +1679,25 @@ Attendee::PartStat VCalFormat::readStatus(const char *s) const
1677 else if (statStr== "COMPLETED") 1679 else if (statStr== "COMPLETED")
1678 status = Attendee::Completed; 1680 status = Attendee::Completed;
1679 else if (statStr== "DELEGATED") 1681 else if (statStr== "DELEGATED")
1680 status = Attendee::Delegated; 1682 status = Attendee::Delegated;
1681 else { 1683 else {
1682 kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl; 1684 kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl;
1683 status = Attendee::NeedsAction; 1685 status = Attendee::NeedsAction;
1684 } 1686 }
1685 1687
1686 return status; 1688 return status;
1687} 1689}
1688 1690
1689QCString VCalFormat::writeStatus(Attendee::PartStat status) const 1691Q3CString VCalFormat::writeStatus(Attendee::PartStat status) const
1690{ 1692{
1691 switch(status) { 1693 switch(status) {
1692 default: 1694 default:
1693 case Attendee::NeedsAction: 1695 case Attendee::NeedsAction:
1694 return "NEEDS ACTION"; 1696 return "NEEDS ACTION";
1695 break; 1697 break;
1696 case Attendee::Accepted: 1698 case Attendee::Accepted:
1697 return "ACCEPTED"; 1699 return "ACCEPTED";
1698 break; 1700 break;
1699 case Attendee::Declined: 1701 case Attendee::Declined:
1700 return "DECLINED"; 1702 return "DECLINED";
1701 break; 1703 break;