-rw-r--r-- | libkcal/vcalformat.cpp | 52 |
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,1715 +1,1717 @@ | |||
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 | ||
45 | using namespace KCal; | 47 | using namespace KCal; |
46 | 48 | ||
47 | VCalFormat::VCalFormat() | 49 | VCalFormat::VCalFormat() |
48 | { | 50 | { |
49 | mCalendar = 0; | 51 | mCalendar = 0; |
50 | useLocalTime = false; | 52 | useLocalTime = false; |
51 | } | 53 | } |
52 | 54 | ||
53 | VCalFormat::~VCalFormat() | 55 | VCalFormat::~VCalFormat() |
54 | { | 56 | { |
55 | } | 57 | } |
56 | 58 | ||
57 | void VCalFormat::setLocalTime ( bool b ) | 59 | void VCalFormat::setLocalTime ( bool b ) |
58 | { | 60 | { |
59 | useLocalTime = b; | 61 | useLocalTime = b; |
60 | } | 62 | } |
61 | bool VCalFormat::load(Calendar *calendar, const QString &fileName) | 63 | bool VCalFormat::load(Calendar *calendar, const QString &fileName) |
62 | { | 64 | { |
63 | mCalendar = calendar; | 65 | mCalendar = calendar; |
64 | clearException(); | 66 | clearException(); |
65 | if ( ! useLocalTime ) | 67 | if ( ! useLocalTime ) |
66 | useLocalTime = mCalendar->isLocalTime(); | 68 | useLocalTime = mCalendar->isLocalTime(); |
67 | VObject *vcal = 0; | 69 | VObject *vcal = 0; |
68 | 70 | ||
69 | // this is not necessarily only 1 vcal. Could be many vcals, or include | 71 | // this is not necessarily only 1 vcal. Could be many vcals, or include |
70 | // a vcard... | 72 | // a vcard... |
71 | vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); | 73 | vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); |
72 | 74 | ||
73 | if (!vcal) { | 75 | if (!vcal) { |
74 | setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); | 76 | setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); |
75 | return FALSE; | 77 | return FALSE; |
76 | } | 78 | } |
77 | 79 | ||
78 | // any other top-level calendar stuff should be added/initialized here | 80 | // any other top-level calendar stuff should be added/initialized here |
79 | 81 | ||
80 | // put all vobjects into their proper places | 82 | // put all vobjects into their proper places |
81 | populate(vcal); | 83 | populate(vcal); |
82 | 84 | ||
83 | // clean up from vcal API stuff | 85 | // clean up from vcal API stuff |
84 | cleanVObjects(vcal); | 86 | cleanVObjects(vcal); |
85 | cleanStrTbl(); | 87 | cleanStrTbl(); |
86 | 88 | ||
87 | return true; | 89 | return true; |
88 | } | 90 | } |
89 | 91 | ||
90 | 92 | ||
91 | bool VCalFormat::save(Calendar *calendar, const QString &fileName) | 93 | bool 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 | ||
137 | bool VCalFormat::fromString( Calendar *calendar, const QString &text ) | 139 | bool 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 | } |
166 | 168 | ||
167 | deleteVObject( vcal ); | 169 | deleteVObject( vcal ); |
168 | 170 | ||
169 | return true; | 171 | return true; |
170 | } | 172 | } |
171 | 173 | ||
172 | QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) | 174 | QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) |
173 | { | 175 | { |
174 | 176 | ||
175 | if ( !event ) return QString::null; | 177 | if ( !event ) return QString::null; |
176 | bool useL = useLocalTime; | 178 | bool useL = useLocalTime; |
177 | useLocalTime = useLocal; | 179 | useLocalTime = useLocal; |
178 | mCalendar = calendar; | 180 | mCalendar = calendar; |
179 | VObject *vevent = eventToVEvent( event ); | 181 | VObject *vevent = eventToVEvent( event ); |
180 | char *buf = writeMemVObject( 0, 0, vevent ); | 182 | char *buf = writeMemVObject( 0, 0, vevent ); |
181 | QString result( buf ); | 183 | QString result( buf ); |
182 | cleanVObject( vevent ); | 184 | cleanVObject( vevent ); |
183 | useLocalTime = useL; | 185 | useLocalTime = useL; |
184 | return result; | 186 | return result; |
185 | } | 187 | } |
186 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) | 188 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) |
187 | { | 189 | { |
188 | 190 | ||
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 | ||
201 | QString VCalFormat::toString( Calendar *calendar ) | 203 | QString 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 | ||
230 | VObject *VCalFormat::eventToVTodo(const Todo *anEvent) | 232 | VObject *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 | ||
238 | // due date | 240 | // due date |
239 | if (anEvent->hasDueDate()) { | 241 | if (anEvent->hasDueDate()) { |
240 | tmpStr = qDateTimeToISO(anEvent->dtDue(), | 242 | tmpStr = qDateTimeToISO(anEvent->dtDue(), |
241 | !anEvent->doesFloat()); | 243 | !anEvent->doesFloat()); |
242 | addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); | 244 | addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); |
243 | } | 245 | } |
244 | 246 | ||
245 | // start date | 247 | // start date |
246 | if (anEvent->hasStartDate()) { | 248 | if (anEvent->hasStartDate()) { |
247 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 249 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
248 | !anEvent->doesFloat()); | 250 | !anEvent->doesFloat()); |
249 | addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); | 251 | addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); |
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()) { |
300 | VObject *d = addPropValue(vtodo, VCDescriptionProp, | 302 | VObject *d = addPropValue(vtodo, VCDescriptionProp, |
301 | anEvent->description().local8Bit()); | 303 | anEvent->description().local8Bit()); |
302 | if (anEvent->description().find('\n') != -1) | 304 | if (anEvent->description().find('\n') != -1) |
303 | addProp(d, VCQuotedPrintableProp); | 305 | addProp(d, VCQuotedPrintableProp); |
304 | } | 306 | } |
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 | } |
383 | 385 | ||
384 | if (anEvent->pilotId()) { | 386 | if (anEvent->pilotId()) { |
385 | // pilot sync stuff | 387 | // pilot sync stuff |
386 | tmpStr.sprintf("%i",anEvent->pilotId()); | 388 | tmpStr.sprintf("%i",anEvent->pilotId()); |
387 | addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); | 389 | addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); |
388 | tmpStr.sprintf("%i",anEvent->syncStatus()); | 390 | tmpStr.sprintf("%i",anEvent->syncStatus()); |
389 | addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); | 391 | addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); |
390 | } | 392 | } |
391 | 393 | ||
392 | return vtodo; | 394 | return vtodo; |
393 | } | 395 | } |
394 | 396 | ||
395 | VObject* VCalFormat::eventToVEvent(Event *anEvent) | 397 | VObject* VCalFormat::eventToVEvent(Event *anEvent) |
396 | { | 398 | { |
397 | VObject *vevent; | 399 | VObject *vevent; |
398 | QString tmpStr; | 400 | QString tmpStr; |
399 | 401 | ||
400 | vevent = newVObject(VCEventProp); | 402 | vevent = newVObject(VCEventProp); |
401 | 403 | ||
402 | // start and end time | 404 | // start and end time |
403 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 405 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
404 | !anEvent->doesFloat()); | 406 | !anEvent->doesFloat()); |
405 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); | 407 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); |
406 | 408 | ||
407 | // events that have time associated but take up no time should | 409 | // events that have time associated but take up no time should |
408 | // not have both DTSTART and DTEND. | 410 | // not have both DTSTART and DTEND. |
409 | if (anEvent->dtStart() != anEvent->dtEnd()) { | 411 | if (anEvent->dtStart() != anEvent->dtEnd()) { |
410 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), | 412 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), |
411 | !anEvent->doesFloat()); | 413 | !anEvent->doesFloat()); |
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; |
490 | tmpPos = tmpPositions.next()) { | 492 | tmpPos = tmpPositions.next()) { |
491 | 493 | ||
492 | tmpStr2.sprintf("%i", tmpPos->rPos); | 494 | tmpStr2.sprintf("%i", tmpPos->rPos); |
493 | if (tmpPos->negative) | 495 | if (tmpPos->negative) |
494 | tmpStr2 += "- "; | 496 | tmpStr2 += "- "; |
495 | else | 497 | else |
496 | tmpStr2 += "+ "; | 498 | tmpStr2 += "+ "; |
497 | tmpStr += tmpStr2; | 499 | tmpStr += tmpStr2; |
498 | for (i = 0; i < 7; i++) { | 500 | for (i = 0; i < 7; i++) { |
499 | if (tmpPos->rDays.testBit(i)) | 501 | if (tmpPos->rDays.testBit(i)) |
500 | tmpStr += dayFromNum(i); | 502 | tmpStr += dayFromNum(i); |
501 | } | 503 | } |
502 | } // loop for all rMonthPos's | 504 | } // loop for all rMonthPos's |
503 | break; | 505 | break; |
504 | case Recurrence::rMonthlyDay: | 506 | case Recurrence::rMonthlyDay: |
505 | tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); | 507 | tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); |
506 | // write out all rMonthDays; | 508 | // write out all rMonthDays; |
507 | tmpDays = anEvent->recurrence()->monthDays(); | 509 | tmpDays = anEvent->recurrence()->monthDays(); |
508 | for (tmpDay = tmpDays.first(); | 510 | for (tmpDay = tmpDays.first(); |
509 | tmpDay; | 511 | tmpDay; |
510 | tmpDay = tmpDays.next()) { | 512 | tmpDay = tmpDays.next()) { |
511 | tmpStr2.sprintf("%i ", *tmpDay); | 513 | tmpStr2.sprintf("%i ", *tmpDay); |
512 | tmpStr += tmpStr2; | 514 | tmpStr += tmpStr2; |
513 | } | 515 | } |
514 | break; | 516 | break; |
515 | case Recurrence::rYearlyMonth: | 517 | case Recurrence::rYearlyMonth: |
516 | tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); | 518 | tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); |
517 | // write out all the rYearNums; | 519 | // write out all the rYearNums; |
518 | tmpDays = anEvent->recurrence()->yearNums(); | 520 | tmpDays = anEvent->recurrence()->yearNums(); |
519 | for (tmpDay = tmpDays.first(); | 521 | for (tmpDay = tmpDays.first(); |
520 | tmpDay; | 522 | tmpDay; |
521 | tmpDay = tmpDays.next()) { | 523 | tmpDay = tmpDays.next()) { |
522 | tmpStr2.sprintf("%i ", *tmpDay); | 524 | tmpStr2.sprintf("%i ", *tmpDay); |
523 | tmpStr += tmpStr2; | 525 | tmpStr += tmpStr2; |
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) |
573 | addProp(d, VCQuotedPrintableProp); | 575 | addProp(d, VCQuotedPrintableProp); |
574 | } | 576 | } |
575 | 577 | ||
576 | // summary | 578 | // summary |
577 | if (!anEvent->summary().isEmpty()) | 579 | if (!anEvent->summary().isEmpty()) |
578 | addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); | 580 | addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); |
579 | 581 | ||
580 | if (!anEvent->location().isEmpty()) | 582 | if (!anEvent->location().isEmpty()) |
581 | addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); | 583 | addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); |
582 | 584 | ||
583 | // status | 585 | // status |
584 | // TODO: define Event status | 586 | // TODO: define Event status |
585 | // addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); | 587 | // addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); |
586 | 588 | ||
587 | // secrecy | 589 | // secrecy |
588 | const char *text = 0; | 590 | const char *text = 0; |
589 | switch (anEvent->secrecy()) { | 591 | switch (anEvent->secrecy()) { |
590 | case Incidence::SecrecyPublic: | 592 | case Incidence::SecrecyPublic: |
591 | text = "PUBLIC"; | 593 | text = "PUBLIC"; |
592 | break; | 594 | break; |
593 | case Incidence::SecrecyPrivate: | 595 | case Incidence::SecrecyPrivate: |
594 | text = "PRIVATE"; | 596 | text = "PRIVATE"; |
595 | break; | 597 | break; |
596 | case Incidence::SecrecyConfidential: | 598 | case Incidence::SecrecyConfidential: |
597 | text = "CONFIDENTIAL"; | 599 | text = "CONFIDENTIAL"; |
598 | break; | 600 | break; |
599 | } | 601 | } |
600 | if (text) { | 602 | if (text) { |
601 | addPropValue(vevent, VCClassProp, text); | 603 | addPropValue(vevent, VCClassProp, text); |
602 | } | 604 | } |
603 | 605 | ||
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 | ||
691 | Todo *VCalFormat::VTodoToEvent(VObject *vtodo) | 693 | Todo *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 |
700 | if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { | 702 | if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { |
701 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 703 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
702 | deleteStr(s); | 704 | deleteStr(s); |
703 | } | 705 | } |
704 | 706 | ||
705 | // unique id | 707 | // unique id |
706 | vo = isAPropertyOf(vtodo, VCUniqueStringProp); | 708 | vo = isAPropertyOf(vtodo, VCUniqueStringProp); |
707 | // while the UID property is preferred, it is not required. We'll use the | 709 | // while the UID property is preferred, it is not required. We'll use the |
708 | // default Event UID if none is given. | 710 | // default Event UID if none is given. |
709 | if (vo) { | 711 | if (vo) { |
710 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); | 712 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); |
711 | deleteStr(s); | 713 | deleteStr(s); |
712 | } | 714 | } |
713 | 715 | ||
714 | // last modification date | 716 | // last modification date |
715 | if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { | 717 | if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { |
716 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 718 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
717 | deleteStr(s); | 719 | deleteStr(s); |
718 | } | 720 | } |
719 | else | 721 | else |
720 | anEvent->setLastModified(QDateTime(QDate::currentDate(), | 722 | anEvent->setLastModified(QDateTime(QDate::currentDate(), |
721 | QTime::currentTime())); | 723 | QTime::currentTime())); |
722 | 724 | ||
723 | // organizer | 725 | // organizer |
724 | // if our extension property for the event's ORGANIZER exists, add it. | 726 | // if our extension property for the event's ORGANIZER exists, add it. |
725 | if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { | 727 | if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { |
726 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); | 728 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); |
727 | deleteStr(s); | 729 | deleteStr(s); |
728 | } else { | 730 | } else { |
729 | anEvent->setOrganizer(mCalendar->getEmail()); | 731 | anEvent->setOrganizer(mCalendar->getEmail()); |
730 | } | 732 | } |
731 | 733 | ||
732 | // attendees. | 734 | // attendees. |
733 | initPropIterator(&voi, vtodo); | 735 | initPropIterator(&voi, vtodo); |
734 | while (moreIteration(&voi)) { | 736 | while (moreIteration(&voi)) { |
735 | vo = nextVObject(&voi); | 737 | vo = nextVObject(&voi); |
736 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { | 738 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { |
737 | Attendee *a; | 739 | Attendee *a; |
738 | VObject *vp; | 740 | VObject *vp; |
739 | s = fakeCString(vObjectUStringZValue(vo)); | 741 | s = fakeCString(vObjectUStringZValue(vo)); |
740 | QString tmpStr = QString::fromLocal8Bit(s); | 742 | QString tmpStr = QString::fromLocal8Bit(s); |
741 | deleteStr(s); | 743 | deleteStr(s); |
742 | tmpStr = tmpStr.simplifyWhiteSpace(); | 744 | tmpStr = tmpStr.simplifyWhiteSpace(); |
743 | int emailPos1, emailPos2; | 745 | int emailPos1, emailPos2; |
744 | if ((emailPos1 = tmpStr.find('<')) > 0) { | 746 | if ((emailPos1 = tmpStr.find('<')) > 0) { |
745 | // both email address and name | 747 | // both email address and name |
746 | emailPos2 = tmpStr.findRev('>'); | 748 | emailPos2 = tmpStr.findRev('>'); |
747 | a = new Attendee(tmpStr.left(emailPos1 - 1), | 749 | a = new Attendee(tmpStr.left(emailPos1 - 1), |
748 | tmpStr.mid(emailPos1 + 1, | 750 | tmpStr.mid(emailPos1 + 1, |
749 | emailPos2 - (emailPos1 + 1))); | 751 | emailPos2 - (emailPos1 + 1))); |
750 | } else if (tmpStr.find('@') > 0) { | 752 | } else if (tmpStr.find('@') > 0) { |
751 | // just an email address | 753 | // just an email address |
752 | a = new Attendee(0, tmpStr); | 754 | a = new Attendee(0, tmpStr); |
753 | } else { | 755 | } else { |
754 | // just a name | 756 | // just a name |
755 | // QString email = tmpStr.replace( QRegExp(" "), "." ); | 757 | // QString email = tmpStr.replace( QRegExp(" "), "." ); |
756 | a = new Attendee(tmpStr,0); | 758 | a = new Attendee(tmpStr,0); |
757 | } | 759 | } |
758 | // is there a Role property? | 760 | // is there a Role property? |
759 | if ((vp = isAPropertyOf(vo, VCRoleProp)) != 0) | 761 | if ((vp = isAPropertyOf(vo, VCRoleProp)) != 0) |
760 | a->setRole(readRole(vObjectStringZValue(vp))); | 762 | a->setRole(readRole(vObjectStringZValue(vp))); |
761 | // is there an RSVP property? | 763 | // is there an RSVP property? |
762 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) | 764 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) |
763 | a->setRSVP(vObjectStringZValue(vp)); | 765 | a->setRSVP(vObjectStringZValue(vp)); |
764 | // is there a status property? | 766 | // is there a status property? |
765 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) | 767 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) |
766 | a->setStatus(readStatus(vObjectStringZValue(vp))); | 768 | a->setStatus(readStatus(vObjectStringZValue(vp))); |
767 | // add the attendee | 769 | // add the attendee |
768 | anEvent->addAttendee(a); | 770 | anEvent->addAttendee(a); |
769 | } | 771 | } |
770 | } | 772 | } |
771 | 773 | ||
772 | // description for todo | 774 | // description for todo |
773 | if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) { | 775 | if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) { |
774 | s = fakeCString(vObjectUStringZValue(vo)); | 776 | s = fakeCString(vObjectUStringZValue(vo)); |
775 | anEvent->setDescription(QString::fromLocal8Bit(s)); | 777 | anEvent->setDescription(QString::fromLocal8Bit(s)); |
776 | deleteStr(s); | 778 | deleteStr(s); |
777 | } | 779 | } |
778 | 780 | ||
779 | // summary | 781 | // summary |
780 | if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { | 782 | if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { |
781 | s = fakeCString(vObjectUStringZValue(vo)); | 783 | s = fakeCString(vObjectUStringZValue(vo)); |
782 | anEvent->setSummary(QString::fromLocal8Bit(s)); | 784 | anEvent->setSummary(QString::fromLocal8Bit(s)); |
783 | deleteStr(s); | 785 | deleteStr(s); |
784 | } | 786 | } |
785 | if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { | 787 | if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { |
786 | s = fakeCString(vObjectUStringZValue(vo)); | 788 | s = fakeCString(vObjectUStringZValue(vo)); |
787 | anEvent->setLocation(QString::fromLocal8Bit(s)); | 789 | anEvent->setLocation(QString::fromLocal8Bit(s)); |
788 | deleteStr(s); | 790 | deleteStr(s); |
789 | } | 791 | } |
790 | 792 | ||
791 | 793 | ||
792 | // completed | 794 | // completed |
793 | // was: status | 795 | // was: status |
794 | if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { | 796 | if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { |
795 | s = fakeCString(vObjectUStringZValue(vo)); | 797 | s = fakeCString(vObjectUStringZValue(vo)); |
796 | if (strcmp(s,"COMPLETED") == 0) { | 798 | if (strcmp(s,"COMPLETED") == 0) { |
797 | anEvent->setCompleted(true); | 799 | anEvent->setCompleted(true); |
798 | } else { | 800 | } else { |
799 | anEvent->setCompleted(false); | 801 | anEvent->setCompleted(false); |
800 | } | 802 | } |
801 | deleteStr(s); | 803 | deleteStr(s); |
802 | } | 804 | } |
803 | else | 805 | else |
804 | anEvent->setCompleted(false); | 806 | anEvent->setCompleted(false); |
805 | 807 | ||
806 | // completion date | 808 | // completion date |
807 | if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { | 809 | if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { |
808 | anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 810 | anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
809 | deleteStr(s); | 811 | deleteStr(s); |
810 | } | 812 | } |
811 | 813 | ||
812 | // priority | 814 | // priority |
813 | if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { | 815 | if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { |
814 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 816 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
815 | deleteStr(s); | 817 | deleteStr(s); |
816 | } | 818 | } |
817 | 819 | ||
818 | // due date | 820 | // due date |
819 | if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { | 821 | if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { |
820 | anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 822 | anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
821 | deleteStr(s); | 823 | deleteStr(s); |
822 | anEvent->setHasDueDate(true); | 824 | anEvent->setHasDueDate(true); |
823 | } else { | 825 | } else { |
824 | anEvent->setHasDueDate(false); | 826 | anEvent->setHasDueDate(false); |
825 | } | 827 | } |
826 | 828 | ||
827 | // start time | 829 | // start time |
828 | if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) { | 830 | if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) { |
829 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 831 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
830 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; | 832 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; |
831 | deleteStr(s); | 833 | deleteStr(s); |
832 | anEvent->setHasStartDate(true); | 834 | anEvent->setHasStartDate(true); |
833 | } else { | 835 | } else { |
834 | anEvent->setHasStartDate(false); | 836 | anEvent->setHasStartDate(false); |
835 | } | 837 | } |
836 | 838 | ||
837 | /* alarm stuff */ | 839 | /* alarm stuff */ |
838 | //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl; | 840 | //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl; |
839 | if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) { | 841 | if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) { |
840 | Alarm* alarm = anEvent->newAlarm(); | 842 | Alarm* alarm = anEvent->newAlarm(); |
841 | VObject *a; | 843 | VObject *a; |
842 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { | 844 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { |
843 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); | 845 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); |
844 | deleteStr(s); | 846 | deleteStr(s); |
845 | } | 847 | } |
846 | alarm->setEnabled(true); | 848 | alarm->setEnabled(true); |
847 | if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) { | 849 | if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) { |
848 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { | 850 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { |
849 | s = fakeCString(vObjectUStringZValue(a)); | 851 | s = fakeCString(vObjectUStringZValue(a)); |
850 | alarm->setProcedureAlarm(QFile::decodeName(s)); | 852 | alarm->setProcedureAlarm(QFile::decodeName(s)); |
851 | deleteStr(s); | 853 | deleteStr(s); |
852 | } | 854 | } |
853 | } | 855 | } |
854 | if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) { | 856 | if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) { |
855 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { | 857 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { |
856 | s = fakeCString(vObjectUStringZValue(a)); | 858 | s = fakeCString(vObjectUStringZValue(a)); |
857 | alarm->setAudioAlarm(QFile::decodeName(s)); | 859 | alarm->setAudioAlarm(QFile::decodeName(s)); |
858 | deleteStr(s); | 860 | deleteStr(s); |
859 | } | 861 | } |
860 | } | 862 | } |
861 | } | 863 | } |
862 | 864 | ||
863 | // related todo | 865 | // related todo |
864 | if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) { | 866 | if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) { |
865 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); | 867 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); |
866 | deleteStr(s); | 868 | deleteStr(s); |
867 | mTodosRelate.append(anEvent); | 869 | mTodosRelate.append(anEvent); |
868 | } | 870 | } |
869 | 871 | ||
870 | // categories | 872 | // categories |
871 | if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) { | 873 | if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) { |
872 | s = fakeCString(vObjectUStringZValue(vo)); | 874 | s = fakeCString(vObjectUStringZValue(vo)); |
873 | QString categories = QString::fromLocal8Bit(s); | 875 | QString categories = QString::fromLocal8Bit(s); |
874 | deleteStr(s); | 876 | deleteStr(s); |
875 | QStringList tmpStrList = QStringList::split( ';', categories ); | 877 | QStringList tmpStrList = QStringList::split( ';', categories ); |
876 | anEvent->setCategories(tmpStrList); | 878 | anEvent->setCategories(tmpStrList); |
877 | } | 879 | } |
878 | 880 | ||
879 | /* PILOT SYNC STUFF */ | 881 | /* PILOT SYNC STUFF */ |
880 | if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) { | 882 | if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) { |
881 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 883 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
882 | deleteStr(s); | 884 | deleteStr(s); |
883 | } | 885 | } |
884 | else | 886 | else |
885 | anEvent->setPilotId(0); | 887 | anEvent->setPilotId(0); |
886 | 888 | ||
887 | if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) { | 889 | if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) { |
888 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 890 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
889 | deleteStr(s); | 891 | deleteStr(s); |
890 | } | 892 | } |
891 | else | 893 | else |
892 | anEvent->setSyncStatus(Event::SYNCMOD); | 894 | anEvent->setSyncStatus(Event::SYNCMOD); |
893 | 895 | ||
894 | return anEvent; | 896 | return anEvent; |
895 | } | 897 | } |
896 | 898 | ||
897 | Event* VCalFormat::VEventToEvent(VObject *vevent) | 899 | Event* VCalFormat::VEventToEvent(VObject *vevent) |
898 | { | 900 | { |
899 | VObject *vo; | 901 | VObject *vo; |
900 | VObjectIterator voi; | 902 | VObjectIterator voi; |
901 | char *s; | 903 | char *s; |
902 | 904 | ||
903 | Event *anEvent = new Event; | 905 | Event *anEvent = new Event; |
904 | 906 | ||
905 | // creation date | 907 | // creation date |
906 | if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { | 908 | if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { |
907 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 909 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
908 | deleteStr(s); | 910 | deleteStr(s); |
909 | } | 911 | } |
910 | 912 | ||
911 | // unique id | 913 | // unique id |
912 | vo = isAPropertyOf(vevent, VCUniqueStringProp); | 914 | vo = isAPropertyOf(vevent, VCUniqueStringProp); |
913 | // while the UID property is preferred, it is not required. We'll use the | 915 | // while the UID property is preferred, it is not required. We'll use the |
914 | // default Event UID if none is given. | 916 | // default Event UID if none is given. |
915 | if (vo) { | 917 | if (vo) { |
916 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); | 918 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); |
917 | deleteStr(s); | 919 | deleteStr(s); |
918 | } | 920 | } |
919 | 921 | ||
920 | // revision | 922 | // revision |
921 | // again NSCAL doesn't give us much to work with, so we improvise... | 923 | // again NSCAL doesn't give us much to work with, so we improvise... |
922 | if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { | 924 | if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { |
923 | anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 925 | anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
924 | deleteStr(s); | 926 | deleteStr(s); |
925 | } | 927 | } |
926 | else | 928 | else |
927 | anEvent->setRevision(0); | 929 | anEvent->setRevision(0); |
928 | 930 | ||
929 | // last modification date | 931 | // last modification date |
930 | if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { | 932 | if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { |
931 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 933 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
932 | deleteStr(s); | 934 | deleteStr(s); |
933 | } | 935 | } |
934 | else | 936 | else |
935 | anEvent->setLastModified(QDateTime(QDate::currentDate(), | 937 | anEvent->setLastModified(QDateTime(QDate::currentDate(), |
936 | QTime::currentTime())); | 938 | QTime::currentTime())); |
937 | 939 | ||
938 | // organizer | 940 | // organizer |
939 | // if our extension property for the event's ORGANIZER exists, add it. | 941 | // if our extension property for the event's ORGANIZER exists, add it. |
940 | if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) { | 942 | if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) { |
941 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); | 943 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); |
942 | deleteStr(s); | 944 | deleteStr(s); |
943 | } else { | 945 | } else { |
944 | anEvent->setOrganizer(mCalendar->getEmail()); | 946 | anEvent->setOrganizer(mCalendar->getEmail()); |
945 | } | 947 | } |
946 | 948 | ||
947 | // deal with attendees. | 949 | // deal with attendees. |
948 | initPropIterator(&voi, vevent); | 950 | initPropIterator(&voi, vevent); |
949 | while (moreIteration(&voi)) { | 951 | while (moreIteration(&voi)) { |
950 | vo = nextVObject(&voi); | 952 | vo = nextVObject(&voi); |
951 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { | 953 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { |
952 | Attendee *a; | 954 | Attendee *a; |
953 | VObject *vp; | 955 | VObject *vp; |
954 | s = fakeCString(vObjectUStringZValue(vo)); | 956 | s = fakeCString(vObjectUStringZValue(vo)); |
955 | QString tmpStr = QString::fromLocal8Bit(s); | 957 | QString tmpStr = QString::fromLocal8Bit(s); |
956 | deleteStr(s); | 958 | deleteStr(s); |
957 | tmpStr = tmpStr.simplifyWhiteSpace(); | 959 | tmpStr = tmpStr.simplifyWhiteSpace(); |
958 | int emailPos1, emailPos2; | 960 | int emailPos1, emailPos2; |
959 | if ((emailPos1 = tmpStr.find('<')) > 0) { | 961 | if ((emailPos1 = tmpStr.find('<')) > 0) { |
960 | // both email address and name | 962 | // both email address and name |
961 | emailPos2 = tmpStr.findRev('>'); | 963 | emailPos2 = tmpStr.findRev('>'); |
962 | a = new Attendee(tmpStr.left(emailPos1 - 1), | 964 | a = new Attendee(tmpStr.left(emailPos1 - 1), |
963 | tmpStr.mid(emailPos1 + 1, | 965 | tmpStr.mid(emailPos1 + 1, |
964 | emailPos2 - (emailPos1 + 1))); | 966 | emailPos2 - (emailPos1 + 1))); |
965 | } else if (tmpStr.find('@') > 0) { | 967 | } else if (tmpStr.find('@') > 0) { |
966 | // just an email address | 968 | // just an email address |
967 | a = new Attendee(0, tmpStr); | 969 | a = new Attendee(0, tmpStr); |
968 | } else { | 970 | } else { |
969 | // just a name | 971 | // just a name |
970 | //QString email = tmpStr.replace( QRegExp(" "), "." ); | 972 | //QString email = tmpStr.replace( QRegExp(" "), "." ); |
971 | a = new Attendee(tmpStr,0); | 973 | a = new Attendee(tmpStr,0); |
972 | } | 974 | } |
973 | 975 | ||
974 | 976 | ||
975 | // is there a Role property? | 977 | // is there a Role property? |
976 | if ((vp = isAPropertyOf(vo, VCRoleProp)) != 0) | 978 | if ((vp = isAPropertyOf(vo, VCRoleProp)) != 0) |
977 | a->setRole(readRole(vObjectStringZValue(vp))); | 979 | a->setRole(readRole(vObjectStringZValue(vp))); |
978 | 980 | ||
979 | // is there an RSVP property? | 981 | // is there an RSVP property? |
980 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) | 982 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) |
981 | a->setRSVP(vObjectStringZValue(vp)); | 983 | a->setRSVP(vObjectStringZValue(vp)); |
982 | // is there a status property? | 984 | // is there a status property? |
983 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) | 985 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) |
984 | a->setStatus(readStatus(vObjectStringZValue(vp))); | 986 | a->setStatus(readStatus(vObjectStringZValue(vp))); |
985 | // add the attendee | 987 | // add the attendee |
986 | anEvent->addAttendee(a); | 988 | anEvent->addAttendee(a); |
987 | } | 989 | } |
988 | } | 990 | } |
989 | 991 | ||
990 | // This isn't strictly true. An event that doesn't have a start time | 992 | // This isn't strictly true. An event that doesn't have a start time |
991 | // or an end time doesn't "float", it has an anchor in time but it doesn't | 993 | // or an end time doesn't "float", it has an anchor in time but it doesn't |
992 | // "take up" any time. | 994 | // "take up" any time. |
993 | /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) || | 995 | /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) || |
994 | (isAPropertyOf(vevent, VCDTendProp) == 0)) { | 996 | (isAPropertyOf(vevent, VCDTendProp) == 0)) { |
995 | anEvent->setFloats(TRUE); | 997 | anEvent->setFloats(TRUE); |
996 | } else { | 998 | } else { |
997 | }*/ | 999 | }*/ |
998 | 1000 | ||
999 | anEvent->setFloats(FALSE); | 1001 | anEvent->setFloats(FALSE); |
1000 | 1002 | ||
1001 | // start time | 1003 | // start time |
1002 | if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) { | 1004 | if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) { |
1003 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 1005 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
1004 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; | 1006 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; |
1005 | deleteStr(s); | 1007 | deleteStr(s); |
1006 | if (anEvent->dtStart().time().isNull()) | 1008 | if (anEvent->dtStart().time().isNull()) |
1007 | anEvent->setFloats(TRUE); | 1009 | anEvent->setFloats(TRUE); |
1008 | } | 1010 | } |
1009 | 1011 | ||
1010 | // stop time | 1012 | // stop time |
1011 | if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) { | 1013 | if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) { |
1012 | anEvent->setDtEnd(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 1014 | anEvent->setDtEnd(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
1013 | deleteStr(s); | 1015 | deleteStr(s); |
1014 | if (anEvent->dtEnd().time().isNull()) | 1016 | if (anEvent->dtEnd().time().isNull()) |
1015 | anEvent->setFloats(TRUE); | 1017 | anEvent->setFloats(TRUE); |
1016 | } | 1018 | } |
1017 | 1019 | ||
1018 | // at this point, there should be at least a start or end time. | 1020 | // at this point, there should be at least a start or end time. |
1019 | // fix up for events that take up no time but have a time associated | 1021 | // fix up for events that take up no time but have a time associated |
1020 | if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) | 1022 | if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) |
1021 | anEvent->setDtStart(anEvent->dtEnd()); | 1023 | anEvent->setDtStart(anEvent->dtEnd()); |
1022 | if (!(vo = isAPropertyOf(vevent, VCDTendProp))) | 1024 | if (!(vo = isAPropertyOf(vevent, VCDTendProp))) |
1023 | anEvent->setDtEnd(anEvent->dtStart()); | 1025 | anEvent->setDtEnd(anEvent->dtStart()); |
1024 | 1026 | ||
1025 | /////////////////////////////////////////////////////////////////////////// | 1027 | /////////////////////////////////////////////////////////////////////////// |
1026 | 1028 | ||
1027 | // repeat stuff | 1029 | // repeat stuff |
1028 | if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) { | 1030 | if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) { |
1029 | QString tmpStr = (s = fakeCString(vObjectUStringZValue(vo))); | 1031 | QString tmpStr = (s = fakeCString(vObjectUStringZValue(vo))); |
1030 | deleteStr(s); | 1032 | deleteStr(s); |
1031 | tmpStr.simplifyWhiteSpace(); | 1033 | tmpStr.simplifyWhiteSpace(); |
1032 | tmpStr = tmpStr.upper(); | 1034 | tmpStr = tmpStr.upper(); |
1033 | 1035 | ||
1034 | /********************************* DAILY ******************************/ | 1036 | /********************************* DAILY ******************************/ |
1035 | if (tmpStr.left(1) == "D") { | 1037 | if (tmpStr.left(1) == "D") { |
1036 | int index = tmpStr.find(' '); | 1038 | int index = tmpStr.find(' '); |
1037 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); | 1039 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); |
1038 | index = tmpStr.findRev(' ') + 1; // advance to last field | 1040 | index = tmpStr.findRev(' ') + 1; // advance to last field |
1039 | if (tmpStr.mid(index,1) == "#") index++; | 1041 | if (tmpStr.mid(index,1) == "#") index++; |
1040 | if (tmpStr.find('T', index) != -1) { | 1042 | if (tmpStr.find('T', index) != -1) { |
1041 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1043 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1042 | anEvent->recurrence()->setDaily(rFreq, rEndDate); | 1044 | anEvent->recurrence()->setDaily(rFreq, rEndDate); |
1043 | } else { | 1045 | } else { |
1044 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1046 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1045 | if (rDuration == 0) // VEvents set this to 0 forever, we use -1 | 1047 | if (rDuration == 0) // VEvents set this to 0 forever, we use -1 |
1046 | anEvent->recurrence()->setDaily(rFreq, -1); | 1048 | anEvent->recurrence()->setDaily(rFreq, -1); |
1047 | else | 1049 | else |
1048 | anEvent->recurrence()->setDaily(rFreq, rDuration); | 1050 | anEvent->recurrence()->setDaily(rFreq, rDuration); |
1049 | } | 1051 | } |
1050 | } | 1052 | } |
1051 | /********************************* WEEKLY ******************************/ | 1053 | /********************************* WEEKLY ******************************/ |
1052 | else if (tmpStr.left(1) == "W") { | 1054 | else if (tmpStr.left(1) == "W") { |
1053 | int index = tmpStr.find(' '); | 1055 | int index = tmpStr.find(' '); |
1054 | int last = tmpStr.findRev(' ') + 1; | 1056 | int last = tmpStr.findRev(' ') + 1; |
1055 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); | 1057 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); |
1056 | index += 1; // advance to beginning of stuff after freq | 1058 | index += 1; // advance to beginning of stuff after freq |
1057 | QBitArray qba(7); | 1059 | QBitArray qba(7); |
1058 | QString dayStr; | 1060 | QString dayStr; |
1059 | if( index == last ) { | 1061 | if( index == last ) { |
1060 | // e.g. W1 #0 | 1062 | // e.g. W1 #0 |
1061 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); | 1063 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); |
1062 | } | 1064 | } |
1063 | else { | 1065 | else { |
1064 | // e.g. W1 SU #0 | 1066 | // e.g. W1 SU #0 |
1065 | while (index < last) { | 1067 | while (index < last) { |
1066 | dayStr = tmpStr.mid(index, 3); | 1068 | dayStr = tmpStr.mid(index, 3); |
1067 | int dayNum = numFromDay(dayStr); | 1069 | int dayNum = numFromDay(dayStr); |
1068 | qba.setBit(dayNum); | 1070 | qba.setBit(dayNum); |
1069 | index += 3; // advance to next day, or possibly "#" | 1071 | index += 3; // advance to next day, or possibly "#" |
1070 | } | 1072 | } |
1071 | } | 1073 | } |
1072 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1074 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1073 | if (tmpStr.find('T', index) != -1) { | 1075 | if (tmpStr.find('T', index) != -1) { |
1074 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1076 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1075 | anEvent->recurrence()->setWeekly(rFreq, qba, rEndDate); | 1077 | anEvent->recurrence()->setWeekly(rFreq, qba, rEndDate); |
1076 | } else { | 1078 | } else { |
1077 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1079 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1078 | if (rDuration == 0) | 1080 | if (rDuration == 0) |
1079 | anEvent->recurrence()->setWeekly(rFreq, qba, -1); | 1081 | anEvent->recurrence()->setWeekly(rFreq, qba, -1); |
1080 | else | 1082 | else |
1081 | anEvent->recurrence()->setWeekly(rFreq, qba, rDuration); | 1083 | anEvent->recurrence()->setWeekly(rFreq, qba, rDuration); |
1082 | } | 1084 | } |
1083 | } | 1085 | } |
1084 | /**************************** MONTHLY-BY-POS ***************************/ | 1086 | /**************************** MONTHLY-BY-POS ***************************/ |
1085 | else if (tmpStr.left(2) == "MP") { | 1087 | else if (tmpStr.left(2) == "MP") { |
1086 | int index = tmpStr.find(' '); | 1088 | int index = tmpStr.find(' '); |
1087 | int last = tmpStr.findRev(' ') + 1; | 1089 | int last = tmpStr.findRev(' ') + 1; |
1088 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1090 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1089 | index += 1; // advance to beginning of stuff after freq | 1091 | index += 1; // advance to beginning of stuff after freq |
1090 | QBitArray qba(7); | 1092 | QBitArray qba(7); |
1091 | short tmpPos; | 1093 | short tmpPos; |
1092 | if( index == last ) { | 1094 | if( index == last ) { |
1093 | // e.g. MP1 #0 | 1095 | // e.g. MP1 #0 |
1094 | tmpPos = anEvent->dtStart().date().day()/7 + 1; | 1096 | tmpPos = anEvent->dtStart().date().day()/7 + 1; |
1095 | if( tmpPos == 5 ) | 1097 | if( tmpPos == 5 ) |
1096 | tmpPos = -1; | 1098 | tmpPos = -1; |
1097 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); | 1099 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); |
1098 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); | 1100 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); |
1099 | } | 1101 | } |
1100 | else { | 1102 | else { |
1101 | // e.g. MP1 1+ SU #0 | 1103 | // e.g. MP1 1+ SU #0 |
1102 | while (index < last) { | 1104 | while (index < last) { |
1103 | tmpPos = tmpStr.mid(index,1).toShort(); | 1105 | tmpPos = tmpStr.mid(index,1).toShort(); |
1104 | index += 1; | 1106 | index += 1; |
1105 | if (tmpStr.mid(index,1) == "-") | 1107 | if (tmpStr.mid(index,1) == "-") |
1106 | // convert tmpPos to negative | 1108 | // convert tmpPos to negative |
1107 | tmpPos = 0 - tmpPos; | 1109 | tmpPos = 0 - tmpPos; |
1108 | index += 2; // advance to day(s) | 1110 | index += 2; // advance to day(s) |
1109 | while (numFromDay(tmpStr.mid(index,3)) >= 0) { | 1111 | while (numFromDay(tmpStr.mid(index,3)) >= 0) { |
1110 | int dayNum = numFromDay(tmpStr.mid(index,3)); | 1112 | int dayNum = numFromDay(tmpStr.mid(index,3)); |
1111 | qba.setBit(dayNum); | 1113 | qba.setBit(dayNum); |
1112 | index += 3; // advance to next day, or possibly pos or "#" | 1114 | index += 3; // advance to next day, or possibly pos or "#" |
1113 | } | 1115 | } |
1114 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); | 1116 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); |
1115 | qba.detach(); | 1117 | qba.detach(); |
1116 | qba.fill(FALSE); // clear out | 1118 | qba.fill(FALSE); // clear out |
1117 | } // while != "#" | 1119 | } // while != "#" |
1118 | } | 1120 | } |
1119 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1121 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1120 | if (tmpStr.find('T', index) != -1) { | 1122 | if (tmpStr.find('T', index) != -1) { |
1121 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length() - | 1123 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length() - |
1122 | index))).date(); | 1124 | index))).date(); |
1123 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rEndDate); | 1125 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rEndDate); |
1124 | } else { | 1126 | } else { |
1125 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1127 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1126 | if (rDuration == 0) | 1128 | if (rDuration == 0) |
1127 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, -1); | 1129 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, -1); |
1128 | else | 1130 | else |
1129 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rDuration); | 1131 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rDuration); |
1130 | } | 1132 | } |
1131 | } | 1133 | } |
1132 | 1134 | ||
1133 | /**************************** MONTHLY-BY-DAY ***************************/ | 1135 | /**************************** MONTHLY-BY-DAY ***************************/ |
1134 | else if (tmpStr.left(2) == "MD") { | 1136 | else if (tmpStr.left(2) == "MD") { |
1135 | int index = tmpStr.find(' '); | 1137 | int index = tmpStr.find(' '); |
1136 | int last = tmpStr.findRev(' ') + 1; | 1138 | int last = tmpStr.findRev(' ') + 1; |
1137 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1139 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1138 | index += 1; | 1140 | index += 1; |
1139 | short tmpDay; | 1141 | short tmpDay; |
1140 | if( index == last ) { | 1142 | if( index == last ) { |
1141 | // e.g. MD1 #0 | 1143 | // e.g. MD1 #0 |
1142 | tmpDay = anEvent->dtStart().date().day(); | 1144 | tmpDay = anEvent->dtStart().date().day(); |
1143 | anEvent->recurrence()->addMonthlyDay(tmpDay); | 1145 | anEvent->recurrence()->addMonthlyDay(tmpDay); |
1144 | } | 1146 | } |
1145 | else { | 1147 | else { |
1146 | // e.g. MD1 3 #0 | 1148 | // e.g. MD1 3 #0 |
1147 | while (index < last) { | 1149 | while (index < last) { |
1148 | int index2 = tmpStr.find(' ', index); | 1150 | int index2 = tmpStr.find(' ', index); |
1149 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); | 1151 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); |
1150 | index = index2-1; | 1152 | index = index2-1; |
1151 | if (tmpStr.mid(index, 1) == "-") | 1153 | if (tmpStr.mid(index, 1) == "-") |
1152 | tmpDay = 0 - tmpDay; | 1154 | tmpDay = 0 - tmpDay; |
1153 | index += 2; // advance the index; | 1155 | index += 2; // advance the index; |
1154 | anEvent->recurrence()->addMonthlyDay(tmpDay); | 1156 | anEvent->recurrence()->addMonthlyDay(tmpDay); |
1155 | } // while != # | 1157 | } // while != # |
1156 | } | 1158 | } |
1157 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1159 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1158 | if (tmpStr.find('T', index) != -1) { | 1160 | if (tmpStr.find('T', index) != -1) { |
1159 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1161 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1160 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rEndDate); | 1162 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rEndDate); |
1161 | } else { | 1163 | } else { |
1162 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1164 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1163 | if (rDuration == 0) | 1165 | if (rDuration == 0) |
1164 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, -1); | 1166 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, -1); |
1165 | else | 1167 | else |
1166 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration); | 1168 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration); |
1167 | } | 1169 | } |
1168 | } | 1170 | } |
1169 | 1171 | ||
1170 | /*********************** YEARLY-BY-MONTH *******************************/ | 1172 | /*********************** YEARLY-BY-MONTH *******************************/ |
1171 | else if (tmpStr.left(2) == "YM") { | 1173 | else if (tmpStr.left(2) == "YM") { |
1172 | // we have to set this such that recurrence accepts addYearlyNum(tmpDay); | 1174 | // we have to set this such that recurrence accepts addYearlyNum(tmpDay); |
1173 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, 1, -1); | 1175 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, 1, -1); |
1174 | int index = tmpStr.find(' '); | 1176 | int index = tmpStr.find(' '); |
1175 | int last = tmpStr.findRev(' ') + 1; | 1177 | int last = tmpStr.findRev(' ') + 1; |
1176 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1178 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1177 | index += 1; | 1179 | index += 1; |
1178 | short tmpMonth; | 1180 | short tmpMonth; |
1179 | if( index == last ) { | 1181 | if( index == last ) { |
1180 | // e.g. YM1 #0 | 1182 | // e.g. YM1 #0 |
1181 | tmpMonth = anEvent->dtStart().date().month(); | 1183 | tmpMonth = anEvent->dtStart().date().month(); |
1182 | anEvent->recurrence()->addYearlyNum(tmpMonth); | 1184 | anEvent->recurrence()->addYearlyNum(tmpMonth); |
1183 | } | 1185 | } |
1184 | else { | 1186 | else { |
1185 | // e.g. YM1 3 #0 | 1187 | // e.g. YM1 3 #0 |
1186 | while (index < last) { | 1188 | while (index < last) { |
1187 | int index2 = tmpStr.find(' ', index); | 1189 | int index2 = tmpStr.find(' ', index); |
1188 | tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); | 1190 | tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); |
1189 | index = index2+1; | 1191 | index = index2+1; |
1190 | anEvent->recurrence()->addYearlyNum(tmpMonth); | 1192 | anEvent->recurrence()->addYearlyNum(tmpMonth); |
1191 | } // while != # | 1193 | } // while != # |
1192 | } | 1194 | } |
1193 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1195 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1194 | if (tmpStr.find('T', index) != -1) { | 1196 | if (tmpStr.find('T', index) != -1) { |
1195 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1197 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1196 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); | 1198 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); |
1197 | } else { | 1199 | } else { |
1198 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1200 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1199 | if (rDuration == 0) | 1201 | if (rDuration == 0) |
1200 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); | 1202 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); |
1201 | else | 1203 | else |
1202 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); | 1204 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); |
1203 | } | 1205 | } |
1204 | } | 1206 | } |
1205 | 1207 | ||
1206 | /*********************** YEARLY-BY-DAY *********************************/ | 1208 | /*********************** YEARLY-BY-DAY *********************************/ |
1207 | else if (tmpStr.left(2) == "YD") { | 1209 | else if (tmpStr.left(2) == "YD") { |
1208 | // we have to set this such that recurrence accepts addYearlyNum(tmpDay); | 1210 | // we have to set this such that recurrence accepts addYearlyNum(tmpDay); |
1209 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, 1, -1); | 1211 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, 1, -1); |
1210 | int index = tmpStr.find(' '); | 1212 | int index = tmpStr.find(' '); |
1211 | int last = tmpStr.findRev(' ') + 1; | 1213 | int last = tmpStr.findRev(' ') + 1; |
1212 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1214 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1213 | index += 1; | 1215 | index += 1; |
1214 | short tmpDay; | 1216 | short tmpDay; |
1215 | if( index == last ) { | 1217 | if( index == last ) { |
1216 | // e.g. YD1 #0 | 1218 | // e.g. YD1 #0 |
1217 | tmpDay = anEvent->dtStart().date().dayOfYear(); | 1219 | tmpDay = anEvent->dtStart().date().dayOfYear(); |
1218 | anEvent->recurrence()->addYearlyNum(tmpDay); | 1220 | anEvent->recurrence()->addYearlyNum(tmpDay); |
1219 | } | 1221 | } |
1220 | else { | 1222 | else { |
1221 | // e.g. YD1 123 #0 | 1223 | // e.g. YD1 123 #0 |
1222 | while (index < last) { | 1224 | while (index < last) { |
1223 | int index2 = tmpStr.find(' ', index); | 1225 | int index2 = tmpStr.find(' ', index); |
1224 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); | 1226 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); |
1225 | index = index2+1; | 1227 | index = index2+1; |
1226 | anEvent->recurrence()->addYearlyNum(tmpDay); | 1228 | anEvent->recurrence()->addYearlyNum(tmpDay); |
1227 | } // while != # | 1229 | } // while != # |
1228 | } | 1230 | } |
1229 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1231 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1230 | if (tmpStr.find('T', index) != -1) { | 1232 | if (tmpStr.find('T', index) != -1) { |
1231 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1233 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1232 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); | 1234 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); |
1233 | } else { | 1235 | } else { |
1234 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1236 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1235 | if (rDuration == 0) | 1237 | if (rDuration == 0) |
1236 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); | 1238 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); |
1237 | else | 1239 | else |
1238 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); | 1240 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); |
1239 | } | 1241 | } |
1240 | } else { | 1242 | } else { |
1241 | kdDebug(5800) << "we don't understand this type of recurrence!" << endl; | 1243 | kdDebug(5800) << "we don't understand this type of recurrence!" << endl; |
1242 | } // if | 1244 | } // if |
1243 | } // repeats | 1245 | } // repeats |
1244 | 1246 | ||
1245 | 1247 | ||
1246 | // recurrence exceptions | 1248 | // recurrence exceptions |
1247 | if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) { | 1249 | if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) { |
1248 | s = fakeCString(vObjectUStringZValue(vo)); | 1250 | s = fakeCString(vObjectUStringZValue(vo)); |
1249 | QStringList exDates = QStringList::split(",",s); | 1251 | QStringList exDates = QStringList::split(",",s); |
1250 | QStringList::ConstIterator it; | 1252 | QStringList::ConstIterator it; |
1251 | for(it = exDates.begin(); it != exDates.end(); ++it ) { | 1253 | for(it = exDates.begin(); it != exDates.end(); ++it ) { |
1252 | anEvent->addExDate(ISOToQDate(*it)); | 1254 | anEvent->addExDate(ISOToQDate(*it)); |
1253 | } | 1255 | } |
1254 | deleteStr(s); | 1256 | deleteStr(s); |
1255 | } | 1257 | } |
1256 | 1258 | ||
1257 | // summary | 1259 | // summary |
1258 | if ((vo = isAPropertyOf(vevent, VCSummaryProp))) { | 1260 | if ((vo = isAPropertyOf(vevent, VCSummaryProp))) { |
1259 | s = fakeCString(vObjectUStringZValue(vo)); | 1261 | s = fakeCString(vObjectUStringZValue(vo)); |
1260 | anEvent->setSummary(QString::fromLocal8Bit(s)); | 1262 | anEvent->setSummary(QString::fromLocal8Bit(s)); |
1261 | deleteStr(s); | 1263 | deleteStr(s); |
1262 | } | 1264 | } |
1263 | if ((vo = isAPropertyOf(vevent, VCLocationProp))) { | 1265 | if ((vo = isAPropertyOf(vevent, VCLocationProp))) { |
1264 | s = fakeCString(vObjectUStringZValue(vo)); | 1266 | s = fakeCString(vObjectUStringZValue(vo)); |
1265 | anEvent->setLocation(QString::fromLocal8Bit(s)); | 1267 | anEvent->setLocation(QString::fromLocal8Bit(s)); |
1266 | deleteStr(s); | 1268 | deleteStr(s); |
1267 | } | 1269 | } |
1268 | 1270 | ||
1269 | // description | 1271 | // description |
1270 | if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) { | 1272 | if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) { |
1271 | s = fakeCString(vObjectUStringZValue(vo)); | 1273 | s = fakeCString(vObjectUStringZValue(vo)); |
1272 | if (!anEvent->description().isEmpty()) { | 1274 | if (!anEvent->description().isEmpty()) { |
1273 | anEvent->setDescription(anEvent->description() + "\n" + | 1275 | anEvent->setDescription(anEvent->description() + "\n" + |
1274 | QString::fromLocal8Bit(s)); | 1276 | QString::fromLocal8Bit(s)); |
1275 | } else { | 1277 | } else { |
1276 | anEvent->setDescription(QString::fromLocal8Bit(s)); | 1278 | anEvent->setDescription(QString::fromLocal8Bit(s)); |
1277 | } | 1279 | } |
1278 | deleteStr(s); | 1280 | deleteStr(s); |
1279 | } | 1281 | } |
1280 | 1282 | ||
1281 | // some stupid vCal exporters ignore the standard and use Description | 1283 | // some stupid vCal exporters ignore the standard and use Description |
1282 | // instead of Summary for the default field. Correct for this. | 1284 | // instead of Summary for the default field. Correct for this. |
1283 | if (anEvent->summary().isEmpty() && | 1285 | if (anEvent->summary().isEmpty() && |
1284 | !(anEvent->description().isEmpty())) { | 1286 | !(anEvent->description().isEmpty())) { |
1285 | QString tmpStr = anEvent->description().simplifyWhiteSpace(); | 1287 | QString tmpStr = anEvent->description().simplifyWhiteSpace(); |
1286 | anEvent->setDescription(""); | 1288 | anEvent->setDescription(""); |
1287 | anEvent->setSummary(tmpStr); | 1289 | anEvent->setSummary(tmpStr); |
1288 | } | 1290 | } |
1289 | 1291 | ||
1290 | #if 0 | 1292 | #if 0 |
1291 | // status | 1293 | // status |
1292 | if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) { | 1294 | if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) { |
1293 | QString tmpStr(s = fakeCString(vObjectUStringZValue(vo))); | 1295 | QString tmpStr(s = fakeCString(vObjectUStringZValue(vo))); |
1294 | deleteStr(s); | 1296 | deleteStr(s); |
1295 | // TODO: Define Event status | 1297 | // TODO: Define Event status |
1296 | // anEvent->setStatus(tmpStr); | 1298 | // anEvent->setStatus(tmpStr); |
1297 | } | 1299 | } |
1298 | else | 1300 | else |
1299 | // anEvent->setStatus("NEEDS ACTION"); | 1301 | // anEvent->setStatus("NEEDS ACTION"); |
1300 | #endif | 1302 | #endif |
1301 | 1303 | ||
1302 | // secrecy | 1304 | // secrecy |
1303 | int secrecy = Incidence::SecrecyPublic; | 1305 | int secrecy = Incidence::SecrecyPublic; |
1304 | if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { | 1306 | if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { |
1305 | s = fakeCString(vObjectUStringZValue(vo)); | 1307 | s = fakeCString(vObjectUStringZValue(vo)); |
1306 | if (strcmp(s,"PRIVATE") == 0) { | 1308 | if (strcmp(s,"PRIVATE") == 0) { |
1307 | secrecy = Incidence::SecrecyPrivate; | 1309 | secrecy = Incidence::SecrecyPrivate; |
1308 | } else if (strcmp(s,"CONFIDENTIAL") == 0) { | 1310 | } else if (strcmp(s,"CONFIDENTIAL") == 0) { |
1309 | secrecy = Incidence::SecrecyConfidential; | 1311 | secrecy = Incidence::SecrecyConfidential; |
1310 | } | 1312 | } |
1311 | deleteStr(s); | 1313 | deleteStr(s); |
1312 | } | 1314 | } |
1313 | anEvent->setSecrecy(secrecy); | 1315 | anEvent->setSecrecy(secrecy); |
1314 | 1316 | ||
1315 | // categories | 1317 | // categories |
1316 | QStringList tmpStrList; | 1318 | QStringList tmpStrList; |
1317 | if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) { | 1319 | if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) { |
1318 | s = fakeCString(vObjectUStringZValue(vo)); | 1320 | s = fakeCString(vObjectUStringZValue(vo)); |
1319 | QString categories = QString::fromLocal8Bit(s); | 1321 | QString categories = QString::fromLocal8Bit(s); |
1320 | deleteStr(s); | 1322 | deleteStr(s); |
1321 | tmpStrList = QStringList::split( ';', categories ); | 1323 | tmpStrList = QStringList::split( ';', categories ); |
1322 | anEvent->setCategories(tmpStrList); | 1324 | anEvent->setCategories(tmpStrList); |
1323 | } | 1325 | } |
1324 | 1326 | ||
1325 | // attachments | 1327 | // attachments |
1326 | initPropIterator(&voi, vevent); | 1328 | initPropIterator(&voi, vevent); |
1327 | while (moreIteration(&voi)) { | 1329 | while (moreIteration(&voi)) { |
1328 | vo = nextVObject(&voi); | 1330 | vo = nextVObject(&voi); |
1329 | if (strcmp(vObjectName(vo), VCAttachProp) == 0) { | 1331 | if (strcmp(vObjectName(vo), VCAttachProp) == 0) { |
1330 | s = fakeCString(vObjectUStringZValue(vo)); | 1332 | s = fakeCString(vObjectUStringZValue(vo)); |
1331 | anEvent->addAttachment(new Attachment(QString(s))); | 1333 | anEvent->addAttachment(new Attachment(QString(s))); |
1332 | deleteStr(s); | 1334 | deleteStr(s); |
1333 | } | 1335 | } |
1334 | } | 1336 | } |
1335 | 1337 | ||
1336 | // resources | 1338 | // resources |
1337 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { | 1339 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { |
1338 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); | 1340 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); |
1339 | deleteStr(s); | 1341 | deleteStr(s); |
1340 | tmpStrList = QStringList::split( ';', resources ); | 1342 | tmpStrList = QStringList::split( ';', resources ); |
1341 | anEvent->setResources(tmpStrList); | 1343 | anEvent->setResources(tmpStrList); |
1342 | } | 1344 | } |
1343 | /* alarm stuff */ | 1345 | /* alarm stuff */ |
1344 | if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) { | 1346 | if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) { |
1345 | Alarm* alarm = anEvent->newAlarm(); | 1347 | Alarm* alarm = anEvent->newAlarm(); |
1346 | VObject *a; | 1348 | VObject *a; |
1347 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { | 1349 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { |
1348 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); | 1350 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); |
1349 | deleteStr(s); | 1351 | deleteStr(s); |
1350 | } | 1352 | } |
1351 | alarm->setEnabled(true); | 1353 | alarm->setEnabled(true); |
1352 | if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) { | 1354 | if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) { |
1353 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { | 1355 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { |
1354 | s = fakeCString(vObjectUStringZValue(a)); | 1356 | s = fakeCString(vObjectUStringZValue(a)); |
1355 | alarm->setProcedureAlarm(QFile::decodeName(s)); | 1357 | alarm->setProcedureAlarm(QFile::decodeName(s)); |
1356 | deleteStr(s); | 1358 | deleteStr(s); |
1357 | } | 1359 | } |
1358 | } | 1360 | } |
1359 | if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { | 1361 | if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { |
1360 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { | 1362 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { |
1361 | s = fakeCString(vObjectUStringZValue(a)); | 1363 | s = fakeCString(vObjectUStringZValue(a)); |
1362 | alarm->setAudioAlarm(QFile::decodeName(s)); | 1364 | alarm->setAudioAlarm(QFile::decodeName(s)); |
1363 | deleteStr(s); | 1365 | deleteStr(s); |
1364 | } | 1366 | } |
1365 | } | 1367 | } |
1366 | } | 1368 | } |
1367 | 1369 | ||
1368 | // priority | 1370 | // priority |
1369 | if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { | 1371 | if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { |
1370 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1372 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1371 | deleteStr(s); | 1373 | deleteStr(s); |
1372 | } | 1374 | } |
1373 | 1375 | ||
1374 | // transparency | 1376 | // transparency |
1375 | if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { | 1377 | if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { |
1376 | int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); | 1378 | int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); |
1377 | anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); | 1379 | anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); |
1378 | deleteStr(s); | 1380 | deleteStr(s); |
1379 | } | 1381 | } |
1380 | 1382 | ||
1381 | // related event | 1383 | // related event |
1382 | if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { | 1384 | if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { |
1383 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); | 1385 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); |
1384 | deleteStr(s); | 1386 | deleteStr(s); |
1385 | mEventsRelate.append(anEvent); | 1387 | mEventsRelate.append(anEvent); |
1386 | } | 1388 | } |
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 | ||
1407 | QString VCalFormat::qDateToISO(const QDate &qd) | 1409 | QString 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 | ||
1419 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) | 1421 | QString 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 | ||
1440 | QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) | 1442 | QDateTime 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 | ||
1466 | QDate VCalFormat::ISOToQDate(const QString &dateStr) | 1468 | QDate 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. |
1480 | void VCalFormat::populate(VObject *vcal) | 1482 | void 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 |
1483 | // lists. It turns vevents into Events and then inserts them. | 1485 | // lists. It turns vevents into Events and then inserts them. |
1484 | 1486 | ||
1485 | VObjectIterator i; | 1487 | VObjectIterator i; |
1486 | VObject *curVO, *curVOProp; | 1488 | VObject *curVO, *curVOProp; |
1487 | Event *anEvent; | 1489 | Event *anEvent; |
1488 | 1490 | ||
1489 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { | 1491 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { |
1490 | char *methodType = 0; | 1492 | char *methodType = 0; |
1491 | methodType = fakeCString(vObjectUStringZValue(curVO)); | 1493 | methodType = fakeCString(vObjectUStringZValue(curVO)); |
1492 | kdDebug() << "This calendar is an iTIP transaction of type '" | 1494 | kdDebug() << "This calendar is an iTIP transaction of type '" |
1493 | << methodType << "'" << endl; | 1495 | << methodType << "'" << endl; |
1494 | delete methodType; | 1496 | delete methodType; |
1495 | } | 1497 | } |
1496 | 1498 | ||
1497 | // warn the user that we might have trouble reading non-known calendar. | 1499 | // warn the user that we might have trouble reading non-known calendar. |
1498 | if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { | 1500 | if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { |
1499 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1501 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1500 | if (strcmp(productId().local8Bit(), s) != 0) | 1502 | if (strcmp(productId().local8Bit(), s) != 0) |
1501 | kdDebug() << "This vCalendar file was not created by KOrganizer " | 1503 | kdDebug() << "This vCalendar file was not created by KOrganizer " |
1502 | "or any other product we support. Loading anyway..." << endl; | 1504 | "or any other product we support. Loading anyway..." << endl; |
1503 | mLoadedProductId = s; | 1505 | mLoadedProductId = s; |
1504 | deleteStr(s); | 1506 | deleteStr(s); |
1505 | } | 1507 | } |
1506 | 1508 | ||
1507 | // warn the user we might have trouble reading this unknown version. | 1509 | // warn the user we might have trouble reading this unknown version. |
1508 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { | 1510 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { |
1509 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1511 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1510 | if (strcmp(_VCAL_VERSION, s) != 0) | 1512 | if (strcmp(_VCAL_VERSION, s) != 0) |
1511 | kdDebug() << "This vCalendar file has version " << s | 1513 | kdDebug() << "This vCalendar file has version " << s |
1512 | << "We only support " << _VCAL_VERSION << endl; | 1514 | << "We only support " << _VCAL_VERSION << endl; |
1513 | deleteStr(s); | 1515 | deleteStr(s); |
1514 | } | 1516 | } |
1515 | 1517 | ||
1516 | // set the time zone | 1518 | // set the time zone |
1517 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { | 1519 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { |
1518 | if ( vObjectUStringZValue(curVO) != 0 ) { | 1520 | if ( vObjectUStringZValue(curVO) != 0 ) { |
1519 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1521 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1520 | mCalendar->setTimeZone(s); | 1522 | mCalendar->setTimeZone(s); |
1521 | deleteStr(s); | 1523 | deleteStr(s); |
1522 | } | 1524 | } |
1523 | } | 1525 | } |
1524 | 1526 | ||
1525 | // Store all events with a relatedTo property in a list for post-processing | 1527 | // Store all events with a relatedTo property in a list for post-processing |
1526 | mEventsRelate.clear(); | 1528 | mEventsRelate.clear(); |
1527 | mTodosRelate.clear(); | 1529 | mTodosRelate.clear(); |
1528 | 1530 | ||
1529 | initPropIterator(&i, vcal); | 1531 | initPropIterator(&i, vcal); |
1530 | 1532 | ||
1531 | // go through all the vobjects in the vcal | 1533 | // go through all the vobjects in the vcal |
1532 | while (moreIteration(&i)) { | 1534 | while (moreIteration(&i)) { |
1533 | curVO = nextVObject(&i); | 1535 | curVO = nextVObject(&i); |
1534 | 1536 | ||
1535 | /************************************************************************/ | 1537 | /************************************************************************/ |
1536 | 1538 | ||
1537 | // now, check to see that the object is an event or todo. | 1539 | // now, check to see that the object is an event or todo. |
1538 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { | 1540 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { |
1539 | 1541 | ||
1540 | if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) { | 1542 | if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) { |
1541 | char *s; | 1543 | char *s; |
1542 | s = fakeCString(vObjectUStringZValue(curVOProp)); | 1544 | s = fakeCString(vObjectUStringZValue(curVOProp)); |
1543 | // check to see if event was deleted by the kpilot conduit | 1545 | // check to see if event was deleted by the kpilot conduit |
1544 | if (atoi(s) == Event::SYNCDEL) { | 1546 | if (atoi(s) == Event::SYNCDEL) { |
1545 | deleteStr(s); | 1547 | deleteStr(s); |
1546 | kdDebug(5800) << "skipping pilot-deleted event" << endl; | 1548 | kdDebug(5800) << "skipping pilot-deleted event" << endl; |
1547 | goto SKIP; | 1549 | goto SKIP; |
1548 | } | 1550 | } |
1549 | deleteStr(s); | 1551 | deleteStr(s); |
1550 | } | 1552 | } |
1551 | 1553 | ||
1552 | // this code checks to see if we are trying to read in an event | 1554 | // 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 | 1555 | // that we already find to be in the calendar. If we find this |
1554 | // to be the case, we skip the event. | 1556 | // to be the case, we skip the event. |
1555 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { | 1557 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { |
1556 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); | 1558 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); |
1557 | QString tmpStr(s); | 1559 | QString tmpStr(s); |
1558 | deleteStr(s); | 1560 | deleteStr(s); |
1559 | 1561 | ||
1560 | if (mCalendar->event(tmpStr)) { | 1562 | if (mCalendar->event(tmpStr)) { |
1561 | goto SKIP; | 1563 | goto SKIP; |
1562 | } | 1564 | } |
1563 | if (mCalendar->todo(tmpStr)) { | 1565 | if (mCalendar->todo(tmpStr)) { |
1564 | goto SKIP; | 1566 | goto SKIP; |
1565 | } | 1567 | } |
1566 | } | 1568 | } |
1567 | 1569 | ||
1568 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && | 1570 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && |
1569 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { | 1571 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { |
1570 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; | 1572 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; |
1571 | goto SKIP; | 1573 | goto SKIP; |
1572 | } | 1574 | } |
1573 | 1575 | ||
1574 | anEvent = VEventToEvent(curVO); | 1576 | anEvent = VEventToEvent(curVO); |
1575 | // we now use addEvent instead of insertEvent so that the | 1577 | // we now use addEvent instead of insertEvent so that the |
1576 | // signal/slot get connected. | 1578 | // signal/slot get connected. |
1577 | if (anEvent) { | 1579 | if (anEvent) { |
1578 | if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) { | 1580 | if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) { |
1579 | kdDebug() << "VCalFormat::populate(): Event has invalid dates." | 1581 | kdDebug() << "VCalFormat::populate(): Event has invalid dates." |
1580 | << endl; | 1582 | << endl; |
1581 | } else { | 1583 | } else { |
1582 | mCalendar->addEvent(anEvent); | 1584 | mCalendar->addEvent(anEvent); |
1583 | } | 1585 | } |
1584 | } else { | 1586 | } else { |
1585 | // some sort of error must have occurred while in translation. | 1587 | // some sort of error must have occurred while in translation. |
1586 | goto SKIP; | 1588 | goto SKIP; |
1587 | } | 1589 | } |
1588 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { | 1590 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { |
1589 | Todo *aTodo = VTodoToEvent(curVO); | 1591 | Todo *aTodo = VTodoToEvent(curVO); |
1590 | mCalendar->addTodo(aTodo); | 1592 | mCalendar->addTodo(aTodo); |
1591 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || | 1593 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || |
1592 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || | 1594 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || |
1593 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { | 1595 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { |
1594 | // do nothing, we know these properties and we want to skip them. | 1596 | // do nothing, we know these properties and we want to skip them. |
1595 | // we have either already processed them or are ignoring them. | 1597 | // we have either already processed them or are ignoring them. |
1596 | ; | 1598 | ; |
1597 | } else { | 1599 | } else { |
1598 | kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; | 1600 | kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; |
1599 | } | 1601 | } |
1600 | SKIP: | 1602 | SKIP: |
1601 | ; | 1603 | ; |
1602 | } // while | 1604 | } // while |
1603 | 1605 | ||
1604 | // Post-Process list of events with relations, put Event objects in relation | 1606 | // Post-Process list of events with relations, put Event objects in relation |
1605 | Event *ev; | 1607 | Event *ev; |
1606 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { | 1608 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { |
1607 | Incidence * inc = mCalendar->event(ev->relatedToUid()); | 1609 | Incidence * inc = mCalendar->event(ev->relatedToUid()); |
1608 | if ( inc ) | 1610 | if ( inc ) |
1609 | ev->setRelatedTo( inc ); | 1611 | ev->setRelatedTo( inc ); |
1610 | } | 1612 | } |
1611 | Todo *todo; | 1613 | Todo *todo; |
1612 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { | 1614 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { |
1613 | Incidence * inc = mCalendar->todo(todo->relatedToUid()); | 1615 | Incidence * inc = mCalendar->todo(todo->relatedToUid()); |
1614 | if ( inc ) | 1616 | if ( inc ) |
1615 | todo->setRelatedTo( inc ); | 1617 | todo->setRelatedTo( inc ); |
1616 | } | 1618 | } |
1617 | } | 1619 | } |
1618 | 1620 | ||
1619 | const char *VCalFormat::dayFromNum(int day) | 1621 | const char *VCalFormat::dayFromNum(int day) |
1620 | { | 1622 | { |
1621 | const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; | 1623 | const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; |
1622 | 1624 | ||
1623 | return days[day]; | 1625 | return days[day]; |
1624 | } | 1626 | } |
1625 | 1627 | ||
1626 | int VCalFormat::numFromDay(const QString &day) | 1628 | 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 | } |
1638 | Attendee::Role VCalFormat::readRole(const char *s) const | 1640 | 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 | ||
1651 | QCString VCalFormat::writeRole(Attendee::Role role) const | 1653 | Q3CString 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 | } |
1657 | Attendee::PartStat VCalFormat::readStatus(const char *s) const | 1659 | Attendee::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 | ||
1689 | QCString VCalFormat::writeStatus(Attendee::PartStat status) const | 1691 | Q3CString 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; |
1714 | } | 1716 | } |
1715 | } | 1717 | } |