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
@@ -1,53 +1,55 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brwon 3 Copyright (c) 1998 Preston Brwon
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 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 <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"
42 44
43#include "vcalformat.h" 45#include "vcalformat.h"
44 46
45using namespace KCal; 47using namespace KCal;
46 48
47VCalFormat::VCalFormat() 49VCalFormat::VCalFormat()
48{ 50{
49 mCalendar = 0; 51 mCalendar = 0;
50 useLocalTime = false; 52 useLocalTime = false;
51} 53}
52 54
53VCalFormat::~VCalFormat() 55VCalFormat::~VCalFormat()
@@ -87,79 +89,79 @@ bool VCalFormat::load(Calendar *calendar, const QString &fileName)
87 return true; 89 return true;
88} 90}
89 91
90 92
91bool VCalFormat::save(Calendar *calendar, const QString &fileName) 93bool VCalFormat::save(Calendar *calendar, const QString &fileName)
92{ 94{
93 mCalendar = calendar; 95 mCalendar = calendar;
94 if ( ! useLocalTime ) 96 if ( ! useLocalTime )
95 useLocalTime = mCalendar->isLocalTime(); 97 useLocalTime = mCalendar->isLocalTime();
96 98
97 QString tmpStr; 99 QString tmpStr;
98 VObject *vcal, *vo; 100 VObject *vcal, *vo;
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 {
154 curvo = nextVObject( &i ); 156 curvo = nextVObject( &i );
155 } while ( strcmp( vObjectName( curvo ), VCEventProp ) && 157 } while ( strcmp( vObjectName( curvo ), VCEventProp ) &&
156 strcmp( vObjectName( curvo ), VCTodoProp ) ); 158 strcmp( vObjectName( curvo ), VCTodoProp ) );
157 159
158 if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { 160 if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) {
159 Event *event = VEventToEvent( curvo ); 161 Event *event = VEventToEvent( curvo );
160 calendar->addEvent( event ); 162 calendar->addEvent( event );
161 } else { 163 } else {
162 qDebug("VCalFormat::fromString(): Unknown object type. "); 164 qDebug("VCalFormat::fromString(): Unknown object type. ");
163 deleteVObject( vcal ); 165 deleteVObject( vcal );
164 return false; 166 return false;
165 } 167 }
@@ -189,49 +191,49 @@ QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal
189 if ( !todo ) return QString::null; 191 if ( !todo ) return QString::null;
190 bool useL = useLocalTime; 192 bool useL = useLocalTime;
191 useLocalTime = useLocal; 193 useLocalTime = useLocal;
192 mCalendar = calendar; 194 mCalendar = calendar;
193 VObject *vevent = eventToVTodo( todo ); 195 VObject *vevent = eventToVTodo( todo );
194 char *buf = writeMemVObject( 0, 0, vevent ); 196 char *buf = writeMemVObject( 0, 0, vevent );
195 QString result( buf ); 197 QString result( buf );
196 cleanVObject( vevent ); 198 cleanVObject( vevent );
197 useLocalTime = useL; 199 useLocalTime = useL;
198 return result; 200 return result;
199} 201}
200 202
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 );
226 228
227 return result; 229 return result;
228} 230}
229 231
230VObject *VCalFormat::eventToVTodo(const Todo *anEvent) 232VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
231{ 233{
232 VObject *vtodo; 234 VObject *vtodo;
233 QString tmpStr; 235 QString tmpStr;
234 236
235 237
236 vtodo = newVObject(VCTodoProp); 238 vtodo = newVObject(VCTodoProp);
237 239
@@ -250,50 +252,50 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
250 } 252 }
251 253
252 // creation date 254 // creation date
253 tmpStr = qDateTimeToISO(anEvent->created()); 255 tmpStr = qDateTimeToISO(anEvent->created());
254 addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); 256 addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit());
255 257
256 // unique id 258 // unique id
257 addPropValue(vtodo, VCUniqueStringProp, 259 addPropValue(vtodo, VCUniqueStringProp,
258 anEvent->uid().local8Bit()); 260 anEvent->uid().local8Bit());
259 261
260 // revision 262 // revision
261 tmpStr.sprintf("%i", anEvent->revision()); 263 tmpStr.sprintf("%i", anEvent->revision());
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();
288 else if (curAttendee->name().isEmpty() && 290 else if (curAttendee->name().isEmpty() &&
289 curAttendee->email().isEmpty()) 291 curAttendee->email().isEmpty())
290 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; 292 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl;
291 VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); 293 VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit());
292 addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); 294 addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role()));
293 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); 295 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");
294 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); 296 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status()));
295 } 297 }
296 } 298 }
297 299
298 // description BL: 300 // description BL:
299 if (!anEvent->description().isEmpty()) { 301 if (!anEvent->description().isEmpty()) {
@@ -305,78 +307,78 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
305 307
306 // summary 308 // summary
307 if (!anEvent->summary().isEmpty()) 309 if (!anEvent->summary().isEmpty())
308 addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); 310 addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit());
309 311
310 if (!anEvent->location().isEmpty()) 312 if (!anEvent->location().isEmpty())
311 addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); 313 addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit());
312 314
313 // completed 315 // completed
314 // status 316 // status
315 // backward compatibility, KOrganizer used to interpret only these two values 317 // backward compatibility, KOrganizer used to interpret only these two values
316 addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : 318 addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" :
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;
342 if (catStr[0] == ' ') 344 if (catStr[0] == ' ')
343 tmpStr += catStr.mid(1); 345 tmpStr += catStr.mid(1);
344 else 346 else
345 tmpStr += catStr; 347 tmpStr += catStr;
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) {
371 a = addProp(vtodo, VCPAlarmProp); 373 a = addProp(vtodo, VCPAlarmProp);
372 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 374 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
373 addPropValue(a, VCRepeatCountProp, "1"); 375 addPropValue(a, VCRepeatCountProp, "1");
374 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); 376 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile()));
375 } else { 377 } else {
376 a = addProp(vtodo, VCDAlarmProp); 378 a = addProp(vtodo, VCDAlarmProp);
377 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 379 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
378 addPropValue(a, VCRepeatCountProp, "1"); 380 addPropValue(a, VCRepeatCountProp, "1");
379 addPropValue(a, VCDisplayStringProp, "beep!"); 381 addPropValue(a, VCDisplayStringProp, "beep!");
380 } 382 }
381 } 383 }
382 } 384 }
@@ -412,78 +414,78 @@ VObject* VCalFormat::eventToVEvent(Event *anEvent)
412 addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); 414 addPropValue(vevent, VCDTendProp, tmpStr.local8Bit());
413 } 415 }
414 416
415 // creation date 417 // creation date
416 tmpStr = qDateTimeToISO(anEvent->created()); 418 tmpStr = qDateTimeToISO(anEvent->created());
417 addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); 419 addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit());
418 420
419 // unique id 421 // unique id
420 addPropValue(vevent, VCUniqueStringProp, 422 addPropValue(vevent, VCUniqueStringProp,
421 anEvent->uid().local8Bit()); 423 anEvent->uid().local8Bit());
422 424
423 // revision 425 // revision
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())
450 tmpStr = "MAILTO: " + curAttendee->name(); 452 tmpStr = "MAILTO: " + curAttendee->name();
451 else if (curAttendee->name().isEmpty() && 453 else if (curAttendee->name().isEmpty() &&
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:
478 tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); 480 tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency());
479 for (i = 0; i < 7; i++) { 481 for (i = 0; i < 7; i++) {
480 if (anEvent->recurrence()->days().testBit(i)) 482 if (anEvent->recurrence()->days().testBit(i))
481 tmpStr += dayFromNum(i); 483 tmpStr += dayFromNum(i);
482 } 484 }
483 break; 485 break;
484 case Recurrence::rMonthlyPos: 486 case Recurrence::rMonthlyPos:
485 tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); 487 tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency());
486 // write out all rMonthPos's 488 // write out all rMonthPos's
487 tmpPositions = anEvent->recurrence()->monthPositions(); 489 tmpPositions = anEvent->recurrence()->monthPositions();
488 for (tmpPos = tmpPositions.first(); 490 for (tmpPos = tmpPositions.first();
489 tmpPos; 491 tmpPos;
@@ -524,49 +526,49 @@ VObject* VCalFormat::eventToVEvent(Event *anEvent)
524 } 526 }
525 break; 527 break;
526 case Recurrence::rYearlyDay: 528 case Recurrence::rYearlyDay:
527 tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency()); 529 tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency());
528 // write out all the rYearNums; 530 // write out all the rYearNums;
529 tmpDays = anEvent->recurrence()->yearNums(); 531 tmpDays = anEvent->recurrence()->yearNums();
530 for (tmpDay = tmpDays.first(); 532 for (tmpDay = tmpDays.first();
531 tmpDay; 533 tmpDay;
532 tmpDay = tmpDays.next()) { 534 tmpDay = tmpDays.next()) {
533 tmpStr2.sprintf("%i ", *tmpDay); 535 tmpStr2.sprintf("%i ", *tmpDay);
534 tmpStr += tmpStr2; 536 tmpStr += tmpStr2;
535 } 537 }
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) + ";";
561 tmpStr2 += tmpStr; 563 tmpStr2 += tmpStr;
562 } 564 }
563 if (!tmpStr2.isEmpty()) { 565 if (!tmpStr2.isEmpty()) {
564 tmpStr2.truncate(tmpStr2.length()-1); 566 tmpStr2.truncate(tmpStr2.length()-1);
565 addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit()); 567 addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit());
566 } 568 }
567 569
568 // description 570 // description
569 if (!anEvent->description().isEmpty()) { 571 if (!anEvent->description().isEmpty()) {
570 VObject *d = addPropValue(vevent, VCDescriptionProp, 572 VObject *d = addPropValue(vevent, VCDescriptionProp,
571 anEvent->description().local8Bit()); 573 anEvent->description().local8Bit());
572 if (anEvent->description().find('\n') != -1) 574 if (anEvent->description().find('\n') != -1)
@@ -604,96 +606,96 @@ VObject* VCalFormat::eventToVEvent(Event *anEvent)
604 // categories 606 // categories
605 QStringList tmpStrList = anEvent->categories(); 607 QStringList tmpStrList = anEvent->categories();
606 tmpStr = ""; 608 tmpStr = "";
607 QString catStr; 609 QString catStr;
608 for ( QStringList::Iterator it = tmpStrList.begin(); 610 for ( QStringList::Iterator it = tmpStrList.begin();
609 it != tmpStrList.end(); 611 it != tmpStrList.end();
610 ++it ) { 612 ++it ) {
611 catStr = *it; 613 catStr = *it;
612 if (catStr[0] == ' ') 614 if (catStr[0] == ' ')
613 tmpStr += catStr.mid(1); 615 tmpStr += catStr.mid(1);
614 else 616 else
615 tmpStr += catStr; 617 tmpStr += catStr;
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) {
652 a = addProp(vevent, VCPAlarmProp); 654 a = addProp(vevent, VCPAlarmProp);
653 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 655 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
654 addPropValue(a, VCRepeatCountProp, "1"); 656 addPropValue(a, VCRepeatCountProp, "1");
655 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); 657 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile()));
656 } else { 658 } else {
657 a = addProp(vevent, VCDAlarmProp); 659 a = addProp(vevent, VCDAlarmProp);
658 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 660 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
659 addPropValue(a, VCRepeatCountProp, "1"); 661 addPropValue(a, VCRepeatCountProp, "1");
660 addPropValue(a, VCDisplayStringProp, "beep!"); 662 addPropValue(a, VCDisplayStringProp, "beep!");
661 663
662 } 664 }
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
688 return vevent; 690 return vevent;
689} 691}
690 692
691Todo *VCalFormat::VTodoToEvent(VObject *vtodo) 693Todo *VCalFormat::VTodoToEvent(VObject *vtodo)
692{ 694{
693 VObject *vo; 695 VObject *vo;
694 VObjectIterator voi; 696 VObjectIterator voi;
695 char *s; 697 char *s;
696 698
697 Todo *anEvent = new Todo; 699 Todo *anEvent = new Todo;
698 700
699 // creation date 701 // creation date
@@ -1387,96 +1389,96 @@ Event* VCalFormat::VEventToEvent(VObject *vevent)
1387 1389
1388 /* PILOT SYNC STUFF */ 1390 /* PILOT SYNC STUFF */
1389 if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { 1391 if ((vo = isAPropertyOf(vevent, XPilotIdProp))) {
1390 anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 1392 anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo))));
1391 deleteStr(s); 1393 deleteStr(s);
1392 } 1394 }
1393 else 1395 else
1394 anEvent->setPilotId(0); 1396 anEvent->setPilotId(0);
1395 1397
1396 if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { 1398 if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) {
1397 anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 1399 anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo))));
1398 deleteStr(s); 1400 deleteStr(s);
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 }
1437 return tmpStr; 1439 return tmpStr;
1438} 1440}
1439 1441
1440QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) 1442QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr)
1441{ 1443{
1442 QDate tmpDate; 1444 QDate tmpDate;
1443 QTime tmpTime; 1445 QTime tmpTime;
1444 QString tmpStr; 1446 QString tmpStr;
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();
1471 month = dateStr.mid(4,2).toInt(); 1473 month = dateStr.mid(4,2).toInt();
1472 day = dateStr.mid(6,2).toInt(); 1474 day = dateStr.mid(6,2).toInt();
1473 1475
1474 return(QDate(year, month, day)); 1476 return(QDate(year, month, day));
1475} 1477}
1476 1478
1477// take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. 1479// take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc.
1478// and break it down from it's tree-like format into the dictionary format 1480// and break it down from it's tree-like format into the dictionary format
1479// that is used internally in the VCalFormat. 1481// that is used internally in the VCalFormat.
1480void VCalFormat::populate(VObject *vcal) 1482void VCalFormat::populate(VObject *vcal)
1481{ 1483{
1482 // this function will populate the caldict dictionary and other event 1484 // this function will populate the caldict dictionary and other event
@@ -1627,87 +1629,87 @@ int VCalFormat::numFromDay(const QString &day)
1627{ 1629{
1628 if (day == "MO ") return 0; 1630 if (day == "MO ") return 0;
1629 if (day == "TU ") return 1; 1631 if (day == "TU ") return 1;
1630 if (day == "WE ") return 2; 1632 if (day == "WE ") return 2;
1631 if (day == "TH ") return 3; 1633 if (day == "TH ") return 3;
1632 if (day == "FR ") return 4; 1634 if (day == "FR ") return 4;
1633 if (day == "SA ") return 5; 1635 if (day == "SA ") return 5;
1634 if (day == "SU ") return 6; 1636 if (day == "SU ") return 6;
1635 1637
1636 return -1; // something bad happened. :) 1638 return -1; // something bad happened. :)
1637} 1639}
1638Attendee::Role VCalFormat::readRole(const char *s) const 1640Attendee::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")
1664 status = Attendee::NeedsAction; 1666 status = Attendee::NeedsAction;
1665 else if (statStr == "NEEDS ACTION") 1667 else if (statStr == "NEEDS ACTION")
1666 status = Attendee::NeedsAction; 1668 status = Attendee::NeedsAction;
1667 else if (statStr== "ACCEPTED") 1669 else if (statStr== "ACCEPTED")
1668 status = Attendee::Accepted; 1670 status = Attendee::Accepted;
1669 else if (statStr== "SENT") 1671 else if (statStr== "SENT")
1670 status = Attendee::NeedsAction; 1672 status = Attendee::NeedsAction;
1671 else if (statStr== "TENTATIVE") 1673 else if (statStr== "TENTATIVE")
1672 status = Attendee::Tentative; 1674 status = Attendee::Tentative;
1673 else if (statStr== "CONFIRMED") 1675 else if (statStr== "CONFIRMED")
1674 status = Attendee::Accepted; 1676 status = Attendee::Accepted;
1675 else if (statStr== "DECLINED") 1677 else if (statStr== "DECLINED")
1676 status = Attendee::Declined; 1678 status = Attendee::Declined;
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;
1702 case Attendee::Tentative: 1704 case Attendee::Tentative:
1703 return "TENTATIVE"; 1705 return "TENTATIVE";
1704 break; 1706 break;
1705 case Attendee::Delegated: 1707 case Attendee::Delegated:
1706 return "DELEGATED"; 1708 return "DELEGATED";
1707 break; 1709 break;
1708 case Attendee::Completed: 1710 case Attendee::Completed:
1709 return "COMPLETED"; 1711 return "COMPLETED";
1710 break; 1712 break;
1711 case Attendee::InProcess: 1713 case Attendee::InProcess:
1712 return "NEEDS ACTION"; 1714 return "NEEDS ACTION";
1713 break; 1715 break;