summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-02-19 10:19:59 (UTC)
committer zautrix <zautrix>2005-02-19 10:19:59 (UTC)
commitd2ed2aaddb88f39f8b2ced18a4ea7f06a63237d3 (patch) (unidiff)
treed57e0a39b6c15b9108c260359fa19986e4823741
parent59a00e603e2ba14885e81c09daf3bb89859ff176 (diff)
downloadkdepimpi-d2ed2aaddb88f39f8b2ced18a4ea7f06a63237d3.zip
kdepimpi-d2ed2aaddb88f39f8b2ced18a4ea7f06a63237d3.tar.gz
kdepimpi-d2ed2aaddb88f39f8b2ced18a4ea7f06a63237d3.tar.bz2
duration fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt2
-rw-r--r--libkcal/icalformatimpl.cpp31
-rw-r--r--libkcal/incidencebase.cpp11
3 files changed, 27 insertions, 17 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index 06aa5f6..01d9e27 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,205 +1,207 @@
1Info about the changes in new versions of KDE-Pim/Pi 1Info about the changes in new versions of KDE-Pim/Pi
2 2
3********** VERSION 2.0.8 ************ 3********** VERSION 2.0.8 ************
4 4
5Fixed a problem in dependency info in the ipk files for the Zaurus. 5Fixed a problem in dependency info in the ipk files for the Zaurus.
6 6
7Added icon for the stealth new week view and made navigation more user friendly in monthview by adding a prev/next week button to the navigator bar. 7Added icon for the stealth new week view and made navigation more user friendly in monthview by adding a prev/next week button to the navigator bar.
8 8
9Added a "go today" button to the datepicker. 9Added a "go today" button to the datepicker.
10 10
11Added "created" and "last modified" to event/todo viewer (and What'sThis viewer) 11Added "created" and "last modified" to event/todo viewer (and What'sThis viewer)
12and made it configureable to show these values. 12and made it configureable to show these values.
13 13
14Fixed a problem for events (from external iCal files) that do have a duration but no end date.
15
14 16
15********** VERSION 2.0.7 ************ 17********** VERSION 2.0.7 ************
16 18
17Added global application font settings 19Added global application font settings
18(for all KDE-Pim/Pi apps) to the general settings. 20(for all KDE-Pim/Pi apps) to the general settings.
19 21
20Fixed a problem in OM/Pi when trying to login to some IMAP servers 22Fixed a problem in OM/Pi when trying to login to some IMAP servers
21(like the IMAP server of Apple: mail.mac.com ) 23(like the IMAP server of Apple: mail.mac.com )
22 24
23Added recurring todos to KO/Pi. 25Added recurring todos to KO/Pi.
24 26
25 27
26********** VERSION 2.0.6 ************ 28********** VERSION 2.0.6 ************
27 29
28Some bugfixes in the pi-sync mode. 30Some bugfixes in the pi-sync mode.
29Added German translation for pi-sync mode. 31Added German translation for pi-sync mode.
30 32
31KO/Pi: 33KO/Pi:
32Made the todolist using alternate background. 34Made the todolist using alternate background.
33 35
34Other minor fixes in KO/Pi. 36Other minor fixes in KO/Pi.
35 37
36 38
37********** VERSION 2.0.5 ************ 39********** VERSION 2.0.5 ************
38 40
39Bugfixes in KO/Pi. 41Bugfixes in KO/Pi.
40 42
41********** VERSION 2.0.4 ************ 43********** VERSION 2.0.4 ************
42 44
43KO/Pi: 45KO/Pi:
44Fixed problem loading translations for summary/location edit boxes in event/todo editor. 46Fixed problem loading translations for summary/location edit boxes in event/todo editor.
45 47
46Added a general "select week number" to the toolbar. 48Added a general "select week number" to the toolbar.
47 49
48Fixed some small problem of the new features introduced in version 2.0.3. 50Fixed some small problem of the new features introduced in version 2.0.3.
49 51
50Made it possible to specify one specific category as category color, 52Made it possible to specify one specific category as category color,
51if more than one categories are selected. 53if more than one categories are selected.
52 54
53Fixed a bug in saving colors for categories with non-ascii characters. 55Fixed a bug in saving colors for categories with non-ascii characters.
54(Like, e.g. German Umlauts). 56(Like, e.g. German Umlauts).
55Propably you have to set your colors again for those categories. 57Propably you have to set your colors again for those categories.
56 58
57 59
58********** VERSION 2.0.3 ************ 60********** VERSION 2.0.3 ************
59 61
60KO/Pi: 62KO/Pi:
61Added feature for changing alarm settings for many items at once: 63Added feature for changing alarm settings for many items at once:
62Open list view (or search dialog), select the desired items and choose in 64Open list view (or search dialog), select the desired items and choose in
63the popup menu: Set alarm for selected... 65the popup menu: Set alarm for selected...
64 66
65Added to the event/todo viewer the option to send an email to 67Added to the event/todo viewer the option to send an email to
66all attendees or all selected (with RSVP) attendees. 68all attendees or all selected (with RSVP) attendees.
67 69
68Made the week-month mode changing in month view faster. 70Made the week-month mode changing in month view faster.
69 71
70Made month view better useable with keyboard. 72Made month view better useable with keyboard.
71Now TAB key jumps to next cell with an event/todo. 73Now TAB key jumps to next cell with an event/todo.
72Scroll in cell with coursor keys, scroll in time (next week) with 74Scroll in cell with coursor keys, scroll in time (next week) with
73Shift/Control + coursorkeys. 75Shift/Control + coursorkeys.
74 76
75Fixed bug that the todo view flat mode was reset after first view update. 77Fixed bug that the todo view flat mode was reset after first view update.
76 78
77If a todo is displayed closed in the todo view, 79If a todo is displayed closed in the todo view,
78it is now displayed in overdue/due today color depending on the subtodos overdue/due today properties. 80it is now displayed in overdue/due today color depending on the subtodos overdue/due today properties.
79 81
80Added info about the numbers of years to the caption (title) information about a birthday event. 82Added info about the numbers of years to the caption (title) information about a birthday event.
81 83
82Made completion date in todo editor editable. 84Made completion date in todo editor editable.
83 85
84Added possibility to save/load templates for journals. 86Added possibility to save/load templates for journals.
85(Which is just a simple "save text to file" or "insert text from file". 87(Which is just a simple "save text to file" or "insert text from file".
86 88
87********** VERSION 2.0.2 ************ 89********** VERSION 2.0.2 ************
88 90
89KO/Pi: 91KO/Pi:
90Fixed the layout problem of the day label buttons 92Fixed the layout problem of the day label buttons
91of the agenda view introduced in version 2.0.1. 93of the agenda view introduced in version 2.0.1.
92 94
93Added WhatsThis support for the todo view and the list view. 95Added WhatsThis support for the todo view and the list view.
94 96
95Added a quite useful feature to the montview. 97Added a quite useful feature to the montview.
96Just click on the week numbers on the left. 98Just click on the week numbers on the left.
97And in the top right corner of month view/agenda view 99And in the top right corner of month view/agenda view
98there is now a "week number quick selector". 100there is now a "week number quick selector".
99(Click on the black triangle). 101(Click on the black triangle).
100 102
101Made the quite difficult timezone change in KO/Pi easy. 103Made the quite difficult timezone change in KO/Pi easy.
102 104
103OM/Pi: 105OM/Pi:
104Fixed too small icons on desktop. 106Fixed too small icons on desktop.
105Fixed non visible icons in mainwindow on Z with fastload enabled. 107Fixed non visible icons in mainwindow on Z with fastload enabled.
106Added signature file setting to smtp account config. 108Added signature file setting to smtp account config.
107And the signature can be edited and saved in the edit mail dialog. 109And the signature can be edited and saved in the edit mail dialog.
108That does mean: 110That does mean:
109Simply edit the signature for the selected smtp account in the 111Simply edit the signature for the selected smtp account in the
110edit new mail dialog and press the "save signature" button there. 112edit new mail dialog and press the "save signature" button there.
111Then the signature is saved to the file specified in the smtp account settings. 113Then the signature is saved to the file specified in the smtp account settings.
112If there is no file specified, it is saved automatically to the file 114If there is no file specified, it is saved automatically to the file
113kdepim/apps/kopiemail/<accountname>.sig. 115kdepim/apps/kopiemail/<accountname>.sig.
114 116
115 117
116 118
117********** VERSION 2.0.1 ************ 119********** VERSION 2.0.1 ************
118 120
119Oooops ... I forgot to test on the Zaurus 5500 ... 121Oooops ... I forgot to test on the Zaurus 5500 ...
120 122
121Fixed many problems of new (english) strings (and german translations) 123Fixed many problems of new (english) strings (and german translations)
122introduced in the latest versions, where the text was not fitting on the 124introduced in the latest versions, where the text was not fitting on the
123240x320 display of the Zaurus 5500. 125240x320 display of the Zaurus 5500.
124 126
125KO/Pi: 127KO/Pi:
126Added a popup menu ( press pen and hold to get popup ) to the agenda view 128Added a popup menu ( press pen and hold to get popup ) to the agenda view
127with many useful items (add event/todo, show next week, two weeks, month, journal). 129with many useful items (add event/todo, show next week, two weeks, month, journal).
128 130
129Added items to the todolist popup menu for: 131Added items to the todolist popup menu for:
130Display all opened, all closed or all todos flat. 132Display all opened, all closed or all todos flat.
131The "flat" view makes is possible to sort all todos after ,e.g., prio or date. 133The "flat" view makes is possible to sort all todos after ,e.g., prio or date.
132Made the reparenting of todos on the desktop possible via Drag&Drop. 134Made the reparenting of todos on the desktop possible via Drag&Drop.
133Fixed several bugs in setting the completed datetime for todos. 135Fixed several bugs in setting the completed datetime for todos.
134Added info about completed datetime of todos to the todo viewer. 136Added info about completed datetime of todos to the todo viewer.
135Now displaying a completed todo (with completed datetime set) in the agenda view 137Now displaying a completed todo (with completed datetime set) in the agenda view
136at the time of the completion. Such that now it is possible to see in the agenda view 138at the time of the completion. Such that now it is possible to see in the agenda view
137when what todo was completed. 139when what todo was completed.
138Fixed behaviour of automatic setting completion of todos with sub-todos/parent todos. 140Fixed behaviour of automatic setting completion of todos with sub-todos/parent todos.
139Now the behaviour is: 141Now the behaviour is:
140Setting a parent to complete sets all (sub)childs to complete. 142Setting a parent to complete sets all (sub)childs to complete.
141Setting a parent to uncomplete does not change the childs. 143Setting a parent to uncomplete does not change the childs.
142Setting a child to uncomplete sets all parent to uncomplete. 144Setting a child to uncomplete sets all parent to uncomplete.
143Setting a child to complete does not change the parents. 145Setting a child to complete does not change the parents.
144 146
145Smart updating and double buffering of the daymatrix. 147Smart updating and double buffering of the daymatrix.
146Showing holidays in the day matrix. 148Showing holidays in the day matrix.
147Many other small performance updates. 149Many other small performance updates.
148 150
149Made day labels in agenda clickable. By clicking a label, the day is displayed in single day mode. 151Made day labels in agenda clickable. By clicking a label, the day is displayed in single day mode.
150 152
151Now the translation file usertranslation.txt is supposed to be in utf8 format. 153Now the translation file usertranslation.txt is supposed to be in utf8 format.
152If you want to translate a language from western europe, just change the germantranslation.txt file. Please read the updated Usertranslation HowTo in KO/Pi Help menu. 154If you want to translate a language from western europe, just change the germantranslation.txt file. Please read the updated Usertranslation HowTo in KO/Pi Help menu.
153 155
154 156
155********** VERSION 2.0.0 ************ 157********** VERSION 2.0.0 ************
156 158
157Stable release 2.0.0! 159Stable release 2.0.0!
158 160
159KO/Pi: 161KO/Pi:
160Fixed problem in edit dialog recreation at startup. 162Fixed problem in edit dialog recreation at startup.
161Made "toggle view*" menu items enabled context sensitive. 163Made "toggle view*" menu items enabled context sensitive.
162Changed agenda size menu to items 1-10. 164Changed agenda size menu to items 1-10.
163Made it possible to change agenda size quickly by pressing mouse on timelabels in agenda view and move mouse up/down. 165Made it possible to change agenda size quickly by pressing mouse on timelabels in agenda view and move mouse up/down.
164Usebility enhancements in the KO/Pi menus. 166Usebility enhancements in the KO/Pi menus.
165Birthday import now adds year to summary. 167Birthday import now adds year to summary.
166What's Next view shows age in years for birthday. 168What's Next view shows age in years for birthday.
167 169
168OM/Pi: 170OM/Pi:
169Added three info lines to display subject, from and to of selected mails. 171Added three info lines to display subject, from and to of selected mails.
170 172
171KA/Pi: 173KA/Pi:
172Fixed jump bar behaviour on Zaurus. 174Fixed jump bar behaviour on Zaurus.
173Now KA/Pi search field supports searching for a range of starting characters. 175Now KA/Pi search field supports searching for a range of starting characters.
174E.g. to search for all contact beginning with b to n, type 176E.g. to search for all contact beginning with b to n, type
175b-n 177b-n
176in the search field. 178in the search field.
177 179
178********** VERSION 1.9.20 ************ 180********** VERSION 1.9.20 ************
179 181
180KO/Pi: 182KO/Pi:
181Added for the "dislplay one day" agenda mode 183Added for the "dislplay one day" agenda mode
182info in the caption and in the day lables: 184info in the caption and in the day lables:
183Now it is displayed, if the selected day is from "day before yesterday" 185Now it is displayed, if the selected day is from "day before yesterday"
184to "day after tomorrow". 186to "day after tomorrow".
185Made it possible to delete a Todo, which has sub-todos. 187Made it possible to delete a Todo, which has sub-todos.
186Fixed two small problems in the todo view. 188Fixed two small problems in the todo view.
187Added missing German translation for filter edit and print dialog. 189Added missing German translation for filter edit and print dialog.
188Made search dialog closeable by cancel key. 190Made search dialog closeable by cancel key.
189 191
190Made it possible to select in the date picker the (ligt grey ) 192Made it possible to select in the date picker the (ligt grey )
191dates of the prev./next month with the mouse. 193dates of the prev./next month with the mouse.
192 194
193OM/Pi: 195OM/Pi:
194"Delete mail" icon in main window now deletes all selected mails. 196"Delete mail" icon in main window now deletes all selected mails.
195Fixed the problem, that the state flag of imap mails was ignored. 197Fixed the problem, that the state flag of imap mails was ignored.
196Now mails with "FLAG_SEEN" on the imap server get no icon in the list view 198Now mails with "FLAG_SEEN" on the imap server get no icon in the list view
197to indecate that they are already seen. 199to indecate that they are already seen.
198Fixed the problem that the body of some mails was not displayed in the 200Fixed the problem that the body of some mails was not displayed in the
199mail viewer when fetching them from the imap server directly to read them. 201mail viewer when fetching them from the imap server directly to read them.
200Made it (configurable) possible to show the "To:" field in the list view. 202Made it (configurable) possible to show the "To:" field in the list view.
201Added to the mail viewer the option "View Source" to make it possible to see the raw mail data. 203Added to the mail viewer the option "View Source" to make it possible to see the raw mail data.
202Added a "Download Mail" button to the mail viewer to quickly download the viewed mail to the 204Added a "Download Mail" button to the mail viewer to quickly download the viewed mail to the
203local storage folder (specified in account settings) of the account of the mail. 205local storage folder (specified in account settings) of the account of the mail.
204Removed some memory leaks in OM/Pi. 206Removed some memory leaks in OM/Pi.
205 207
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index 2e38ae3..eae41aa 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -219,389 +219,389 @@ icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy,
219 icalcomponent_add_property(vfreebusy,icalproperty_new_uid( 219 icalcomponent_add_property(vfreebusy,icalproperty_new_uid(
220 freebusy->uid().utf8())); 220 freebusy->uid().utf8()));
221 } 221 }
222 222
223 //Loops through all the periods in the freebusy object 223 //Loops through all the periods in the freebusy object
224 QValueList<Period> list = freebusy->busyPeriods(); 224 QValueList<Period> list = freebusy->busyPeriods();
225 QValueList<Period>::Iterator it; 225 QValueList<Period>::Iterator it;
226 icalperiodtype period; 226 icalperiodtype period;
227 for (it = list.begin(); it!= list.end(); ++it) { 227 for (it = list.begin(); it!= list.end(); ++it) {
228 period.start = writeICalDateTime((*it).start()); 228 period.start = writeICalDateTime((*it).start());
229 period.end = writeICalDateTime((*it).end()); 229 period.end = writeICalDateTime((*it).end());
230 icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) ); 230 icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) );
231 } 231 }
232 232
233 return vfreebusy; 233 return vfreebusy;
234} 234}
235 235
236icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) 236icalcomponent *ICalFormatImpl::writeJournal(Journal *journal)
237{ 237{
238 icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT); 238 icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT);
239 239
240 writeIncidence(vjournal,journal); 240 writeIncidence(vjournal,journal);
241 241
242 // start time 242 // start time
243 if (journal->dtStart().isValid()) { 243 if (journal->dtStart().isValid()) {
244 icaltimetype start; 244 icaltimetype start;
245 if (journal->doesFloat()) { 245 if (journal->doesFloat()) {
246// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; 246// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl;
247 start = writeICalDate(journal->dtStart().date()); 247 start = writeICalDate(journal->dtStart().date());
248 } else { 248 } else {
249// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; 249// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl;
250 start = writeICalDateTime(journal->dtStart()); 250 start = writeICalDateTime(journal->dtStart());
251 } 251 }
252 icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start)); 252 icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start));
253 } 253 }
254 254
255 return vjournal; 255 return vjournal;
256} 256}
257 257
258void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) 258void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
259{ 259{
260 // pilot sync stuff 260 // pilot sync stuff
261// TODO: move this application-specific code to kpilot 261// TODO: move this application-specific code to kpilot
262 if (incidence->pilotId()) { 262 if (incidence->pilotId()) {
263 incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId())); 263 incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId()));
264 incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus())); 264 incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus()));
265 } 265 }
266 if ( !incidence->IDStr().isEmpty()) { 266 if ( !incidence->IDStr().isEmpty()) {
267 incidence->setNonKDECustomProperty("X-KOPIEXTID",incidence->IDStr() ); 267 incidence->setNonKDECustomProperty("X-KOPIEXTID",incidence->IDStr() );
268 } 268 }
269 269
270 270
271 writeIncidenceBase(parent,incidence); 271 writeIncidenceBase(parent,incidence);
272 if (incidence->cancelled()) { 272 if (incidence->cancelled()) {
273 icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED)); 273 icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED));
274 } 274 }
275 275
276 // creation date 276 // creation date
277 icalcomponent_add_property(parent,icalproperty_new_created( 277 icalcomponent_add_property(parent,icalproperty_new_created(
278 writeICalDateTime(incidence->created()))); 278 writeICalDateTime(incidence->created())));
279 279
280 // unique id 280 // unique id
281 icalcomponent_add_property(parent,icalproperty_new_uid( 281 icalcomponent_add_property(parent,icalproperty_new_uid(
282 incidence->uid().utf8())); 282 incidence->uid().utf8()));
283 283
284 // revision 284 // revision
285 icalcomponent_add_property(parent,icalproperty_new_sequence( 285 icalcomponent_add_property(parent,icalproperty_new_sequence(
286 incidence->revision())); 286 incidence->revision()));
287 287
288 // last modification date 288 // last modification date
289 icalcomponent_add_property(parent,icalproperty_new_lastmodified( 289 icalcomponent_add_property(parent,icalproperty_new_lastmodified(
290 writeICalDateTime(incidence->lastModified()))); 290 writeICalDateTime(incidence->lastModified())));
291 291
292 // description 292 // description
293 if (!incidence->description().isEmpty()) { 293 if (!incidence->description().isEmpty()) {
294 icalcomponent_add_property(parent,icalproperty_new_description( 294 icalcomponent_add_property(parent,icalproperty_new_description(
295 incidence->description().utf8())); 295 incidence->description().utf8()));
296 } 296 }
297 297
298 // summary 298 // summary
299 if (!incidence->summary().isEmpty()) { 299 if (!incidence->summary().isEmpty()) {
300 icalcomponent_add_property(parent,icalproperty_new_summary( 300 icalcomponent_add_property(parent,icalproperty_new_summary(
301 incidence->summary().utf8())); 301 incidence->summary().utf8()));
302 } 302 }
303 303
304 // location 304 // location
305 if (!incidence->location().isEmpty()) { 305 if (!incidence->location().isEmpty()) {
306 icalcomponent_add_property(parent,icalproperty_new_location( 306 icalcomponent_add_property(parent,icalproperty_new_location(
307 incidence->location().utf8())); 307 incidence->location().utf8()));
308 } 308 }
309 309
310// TODO: 310// TODO:
311 // status 311 // status
312// addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8()); 312// addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8());
313 313
314 // secrecy 314 // secrecy
315 enum icalproperty_class classInt; 315 enum icalproperty_class classInt;
316 switch (incidence->secrecy()) { 316 switch (incidence->secrecy()) {
317 case Incidence::SecrecyPublic: 317 case Incidence::SecrecyPublic:
318 classInt = ICAL_CLASS_PUBLIC; 318 classInt = ICAL_CLASS_PUBLIC;
319 break; 319 break;
320 case Incidence::SecrecyConfidential: 320 case Incidence::SecrecyConfidential:
321 classInt = ICAL_CLASS_CONFIDENTIAL; 321 classInt = ICAL_CLASS_CONFIDENTIAL;
322 break; 322 break;
323 case Incidence::SecrecyPrivate: 323 case Incidence::SecrecyPrivate:
324 classInt =ICAL_CLASS_PRIVATE ; 324 classInt =ICAL_CLASS_PRIVATE ;
325 default: 325 default:
326 classInt =ICAL_CLASS_PRIVATE ; 326 classInt =ICAL_CLASS_PRIVATE ;
327 break; 327 break;
328 } 328 }
329 icalcomponent_add_property(parent,icalproperty_new_class(classInt)); 329 icalcomponent_add_property(parent,icalproperty_new_class(classInt));
330 330
331 // priority 331 // priority
332 icalcomponent_add_property(parent,icalproperty_new_priority( 332 icalcomponent_add_property(parent,icalproperty_new_priority(
333 incidence->priority())); 333 incidence->priority()));
334 334
335 // categories 335 // categories
336 QStringList categories = incidence->categories(); 336 QStringList categories = incidence->categories();
337 QStringList::Iterator it; 337 QStringList::Iterator it;
338 for(it = categories.begin(); it != categories.end(); ++it ) { 338 for(it = categories.begin(); it != categories.end(); ++it ) {
339 icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); 339 icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8()));
340 } 340 }
341// TODO: Ensure correct concatenation of categories properties. 341// TODO: Ensure correct concatenation of categories properties.
342 342
343/* 343/*
344 // categories 344 // categories
345 tmpStrList = incidence->getCategories(); 345 tmpStrList = incidence->getCategories();
346 tmpStr = ""; 346 tmpStr = "";
347 QString catStr; 347 QString catStr;
348 for ( QStringList::Iterator it = tmpStrList.begin(); 348 for ( QStringList::Iterator it = tmpStrList.begin();
349 it != tmpStrList.end(); 349 it != tmpStrList.end();
350 ++it ) { 350 ++it ) {
351 catStr = *it; 351 catStr = *it;
352 if (catStr[0] == ' ') 352 if (catStr[0] == ' ')
353 tmpStr += catStr.mid(1); 353 tmpStr += catStr.mid(1);
354 else 354 else
355 tmpStr += catStr; 355 tmpStr += catStr;
356 // this must be a ';' character as the vCalendar specification requires! 356 // this must be a ';' character as the vCalendar specification requires!
357 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 357 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
358 // read in. 358 // read in.
359 tmpStr += ";"; 359 tmpStr += ";";
360 } 360 }
361 if (!tmpStr.isEmpty()) { 361 if (!tmpStr.isEmpty()) {
362 tmpStr.truncate(tmpStr.length()-1); 362 tmpStr.truncate(tmpStr.length()-1);
363 icalcomponent_add_property(parent,icalproperty_new_categories( 363 icalcomponent_add_property(parent,icalproperty_new_categories(
364 writeText(incidence->getCategories().join(";")))); 364 writeText(incidence->getCategories().join(";"))));
365 } 365 }
366*/ 366*/
367 367
368 // related event 368 // related event
369 if (incidence->relatedTo()) { 369 if (incidence->relatedTo()) {
370 icalcomponent_add_property(parent,icalproperty_new_relatedto( 370 icalcomponent_add_property(parent,icalproperty_new_relatedto(
371 incidence->relatedTo()->uid().utf8())); 371 incidence->relatedTo()->uid().utf8()));
372 } 372 }
373 373
374 // recurrence rule stuff 374 // recurrence rule stuff
375 Recurrence *recur = incidence->recurrence(); 375 Recurrence *recur = incidence->recurrence();
376 if (recur->doesRecur()) { 376 if (recur->doesRecur()) {
377 377
378 icalcomponent_add_property(parent,writeRecurrenceRule(recur)); 378 icalcomponent_add_property(parent,writeRecurrenceRule(recur));
379 } 379 }
380 380
381 // recurrence excpetion dates 381 // recurrence excpetion dates
382 DateList dateList = incidence->exDates(); 382 DateList dateList = incidence->exDates();
383 DateList::ConstIterator exIt; 383 DateList::ConstIterator exIt;
384 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { 384 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) {
385 icalcomponent_add_property(parent,icalproperty_new_exdate( 385 icalcomponent_add_property(parent,icalproperty_new_exdate(
386 writeICalDate(*exIt))); 386 writeICalDate(*exIt)));
387 } 387 }
388 388
389 // attachments 389 // attachments
390 QPtrList<Attachment> attachments = incidence->attachments(); 390 QPtrList<Attachment> attachments = incidence->attachments();
391 for (Attachment *at = attachments.first(); at; at = attachments.next()) 391 for (Attachment *at = attachments.first(); at; at = attachments.next())
392 icalcomponent_add_property(parent,writeAttachment(at)); 392 icalcomponent_add_property(parent,writeAttachment(at));
393 393
394 // alarms 394 // alarms
395 QPtrList<Alarm> alarms = incidence->alarms(); 395 QPtrList<Alarm> alarms = incidence->alarms();
396 Alarm* alarm; 396 Alarm* alarm;
397 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 397 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
398 if (alarm->enabled()) { 398 if (alarm->enabled()) {
399 kdDebug(5800) << "Write alarm for " << incidence->summary() << endl; 399 kdDebug(5800) << "Write alarm for " << incidence->summary() << endl;
400 icalcomponent_add_component(parent,writeAlarm(alarm)); 400 icalcomponent_add_component(parent,writeAlarm(alarm));
401 } 401 }
402 } 402 }
403 if( incidence->hasRecurrenceID() ) { 403 if( incidence->hasRecurrenceID() ) {
404 icalcomponent_add_property(parent, 404 icalcomponent_add_property(parent,
405 icalproperty_new_recurrenceid( writeICalDateTime( incidence->recurrenceID()))); 405 icalproperty_new_recurrenceid( writeICalDateTime( incidence->recurrenceID())));
406 } 406 }
407 // duration 407 // duration
408 408
409// turned off as it always is set to PTS0 (and must not occur together with DTEND 409// turned off as it always is set to PTS0 (and must not occur together with DTEND
410 410
411// if (incidence->hasDuration()) { 411 if (incidence->hasDuration()) {
412// icaldurationtype duration; 412 icaldurationtype duration;
413// duration = writeICalDuration(incidence->duration()); 413 duration = writeICalDuration(incidence->duration());
414// icalcomponent_add_property(parent,icalproperty_new_duration(duration)); 414 icalcomponent_add_property(parent,icalproperty_new_duration(duration));
415// } 415 }
416} 416}
417 417
418void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) 418void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase)
419{ 419{
420 icalcomponent_add_property(parent,icalproperty_new_dtstamp( 420 icalcomponent_add_property(parent,icalproperty_new_dtstamp(
421 writeICalDateTime(QDateTime::currentDateTime()))); 421 writeICalDateTime(QDateTime::currentDateTime())));
422 422
423 // organizer stuff 423 // organizer stuff
424 icalcomponent_add_property(parent,icalproperty_new_organizer( 424 icalcomponent_add_property(parent,icalproperty_new_organizer(
425 ("MAILTO:" + incidenceBase->organizer()).utf8())); 425 ("MAILTO:" + incidenceBase->organizer()).utf8()));
426 426
427 // attendees 427 // attendees
428 if (incidenceBase->attendeeCount() != 0) { 428 if (incidenceBase->attendeeCount() != 0) {
429 QPtrList<Attendee> al = incidenceBase->attendees(); 429 QPtrList<Attendee> al = incidenceBase->attendees();
430 QPtrListIterator<Attendee> ai(al); 430 QPtrListIterator<Attendee> ai(al);
431 for (; ai.current(); ++ai) { 431 for (; ai.current(); ++ai) {
432 icalcomponent_add_property(parent,writeAttendee(ai.current())); 432 icalcomponent_add_property(parent,writeAttendee(ai.current()));
433 } 433 }
434 } 434 }
435 435
436 // custom properties 436 // custom properties
437 writeCustomProperties(parent, incidenceBase); 437 writeCustomProperties(parent, incidenceBase);
438} 438}
439 439
440void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties) 440void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties)
441{ 441{
442 QMap<QCString, QString> custom = properties->customProperties(); 442 QMap<QCString, QString> custom = properties->customProperties();
443 for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { 443 for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) {
444 icalproperty *p = icalproperty_new_x(c.data().utf8()); 444 icalproperty *p = icalproperty_new_x(c.data().utf8());
445 icalproperty_set_x_name(p,c.key()); 445 icalproperty_set_x_name(p,c.key());
446 icalcomponent_add_property(parent,p); 446 icalcomponent_add_property(parent,p);
447 } 447 }
448} 448}
449 449
450icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee) 450icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee)
451{ 451{
452 icalproperty *p = icalproperty_new_attendee("mailto:" + attendee->email().utf8()); 452 icalproperty *p = icalproperty_new_attendee("mailto:" + attendee->email().utf8());
453 453
454 if (!attendee->name().isEmpty()) { 454 if (!attendee->name().isEmpty()) {
455 icalproperty_add_parameter(p,icalparameter_new_cn(attendee->name().utf8())); 455 icalproperty_add_parameter(p,icalparameter_new_cn(attendee->name().utf8()));
456 } 456 }
457 457
458 458
459 icalproperty_add_parameter(p,icalparameter_new_rsvp( 459 icalproperty_add_parameter(p,icalparameter_new_rsvp(
460 attendee->RSVP() ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE )); 460 attendee->RSVP() ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE ));
461 461
462 icalparameter_partstat status = ICAL_PARTSTAT_NEEDSACTION; 462 icalparameter_partstat status = ICAL_PARTSTAT_NEEDSACTION;
463 switch (attendee->status()) { 463 switch (attendee->status()) {
464 default: 464 default:
465 case Attendee::NeedsAction: 465 case Attendee::NeedsAction:
466 status = ICAL_PARTSTAT_NEEDSACTION; 466 status = ICAL_PARTSTAT_NEEDSACTION;
467 break; 467 break;
468 case Attendee::Accepted: 468 case Attendee::Accepted:
469 status = ICAL_PARTSTAT_ACCEPTED; 469 status = ICAL_PARTSTAT_ACCEPTED;
470 break; 470 break;
471 case Attendee::Declined: 471 case Attendee::Declined:
472 status = ICAL_PARTSTAT_DECLINED; 472 status = ICAL_PARTSTAT_DECLINED;
473 break; 473 break;
474 case Attendee::Tentative: 474 case Attendee::Tentative:
475 status = ICAL_PARTSTAT_TENTATIVE; 475 status = ICAL_PARTSTAT_TENTATIVE;
476 break; 476 break;
477 case Attendee::Delegated: 477 case Attendee::Delegated:
478 status = ICAL_PARTSTAT_DELEGATED; 478 status = ICAL_PARTSTAT_DELEGATED;
479 break; 479 break;
480 case Attendee::Completed: 480 case Attendee::Completed:
481 status = ICAL_PARTSTAT_COMPLETED; 481 status = ICAL_PARTSTAT_COMPLETED;
482 break; 482 break;
483 case Attendee::InProcess: 483 case Attendee::InProcess:
484 status = ICAL_PARTSTAT_INPROCESS; 484 status = ICAL_PARTSTAT_INPROCESS;
485 break; 485 break;
486 } 486 }
487 icalproperty_add_parameter(p,icalparameter_new_partstat(status)); 487 icalproperty_add_parameter(p,icalparameter_new_partstat(status));
488 488
489 icalparameter_role role = ICAL_ROLE_REQPARTICIPANT; 489 icalparameter_role role = ICAL_ROLE_REQPARTICIPANT;
490 switch (attendee->role()) { 490 switch (attendee->role()) {
491 case Attendee::Chair: 491 case Attendee::Chair:
492 role = ICAL_ROLE_CHAIR; 492 role = ICAL_ROLE_CHAIR;
493 break; 493 break;
494 default: 494 default:
495 case Attendee::ReqParticipant: 495 case Attendee::ReqParticipant:
496 role = ICAL_ROLE_REQPARTICIPANT; 496 role = ICAL_ROLE_REQPARTICIPANT;
497 break; 497 break;
498 case Attendee::OptParticipant: 498 case Attendee::OptParticipant:
499 role = ICAL_ROLE_OPTPARTICIPANT; 499 role = ICAL_ROLE_OPTPARTICIPANT;
500 break; 500 break;
501 case Attendee::NonParticipant: 501 case Attendee::NonParticipant:
502 role = ICAL_ROLE_NONPARTICIPANT; 502 role = ICAL_ROLE_NONPARTICIPANT;
503 break; 503 break;
504 } 504 }
505 icalproperty_add_parameter(p,icalparameter_new_role(role)); 505 icalproperty_add_parameter(p,icalparameter_new_role(role));
506 506
507 if (!attendee->uid().isEmpty()) { 507 if (!attendee->uid().isEmpty()) {
508 icalparameter* icalparameter_uid = icalparameter_new_x(attendee->uid().utf8()); 508 icalparameter* icalparameter_uid = icalparameter_new_x(attendee->uid().utf8());
509 icalparameter_set_xname(icalparameter_uid,"X-UID"); 509 icalparameter_set_xname(icalparameter_uid,"X-UID");
510 icalproperty_add_parameter(p,icalparameter_uid); 510 icalproperty_add_parameter(p,icalparameter_uid);
511 } 511 }
512 512
513 return p; 513 return p;
514} 514}
515 515
516icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) 516icalproperty *ICalFormatImpl::writeAttachment(Attachment *att)
517{ 517{
518#if 0 518#if 0
519 icalattachtype* attach = icalattachtype_new(); 519 icalattachtype* attach = icalattachtype_new();
520 if (att->isURI()) 520 if (att->isURI())
521 icalattachtype_set_url(attach, att->uri().utf8().data()); 521 icalattachtype_set_url(attach, att->uri().utf8().data());
522 else 522 else
523 icalattachtype_set_base64(attach, att->data(), 0); 523 icalattachtype_set_base64(attach, att->data(), 0);
524#endif 524#endif
525 icalattach *attach; 525 icalattach *attach;
526 if (att->isURI()) 526 if (att->isURI())
527 attach = icalattach_new_from_url( att->uri().utf8().data()); 527 attach = icalattach_new_from_url( att->uri().utf8().data());
528 else 528 else
529 attach = icalattach_new_from_data ( (unsigned char *)att->data(), 0, 0); 529 attach = icalattach_new_from_data ( (unsigned char *)att->data(), 0, 0);
530 icalproperty *p = icalproperty_new_attach(attach); 530 icalproperty *p = icalproperty_new_attach(attach);
531 if (!att->mimeType().isEmpty()) 531 if (!att->mimeType().isEmpty())
532 icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data())); 532 icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data()));
533 533
534 if (att->isBinary()) { 534 if (att->isBinary()) {
535 icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY)); 535 icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY));
536 icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64)); 536 icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64));
537 } 537 }
538 return p; 538 return p;
539} 539}
540 540
541icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur) 541icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur)
542{ 542{
543// kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl; 543// kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl;
544 544
545 icalrecurrencetype r; 545 icalrecurrencetype r;
546 546
547 icalrecurrencetype_clear(&r); 547 icalrecurrencetype_clear(&r);
548 548
549 int index = 0; 549 int index = 0;
550 int index2 = 0; 550 int index2 = 0;
551 551
552 QPtrList<Recurrence::rMonthPos> tmpPositions; 552 QPtrList<Recurrence::rMonthPos> tmpPositions;
553 QPtrList<int> tmpDays; 553 QPtrList<int> tmpDays;
554 int *tmpDay; 554 int *tmpDay;
555 Recurrence::rMonthPos *tmpPos; 555 Recurrence::rMonthPos *tmpPos;
556 bool datetime = false; 556 bool datetime = false;
557 int day; 557 int day;
558 int i; 558 int i;
559 559
560 switch(recur->doesRecur()) { 560 switch(recur->doesRecur()) {
561 case Recurrence::rMinutely: 561 case Recurrence::rMinutely:
562 r.freq = ICAL_MINUTELY_RECURRENCE; 562 r.freq = ICAL_MINUTELY_RECURRENCE;
563 datetime = true; 563 datetime = true;
564 break; 564 break;
565 case Recurrence::rHourly: 565 case Recurrence::rHourly:
566 r.freq = ICAL_HOURLY_RECURRENCE; 566 r.freq = ICAL_HOURLY_RECURRENCE;
567 datetime = true; 567 datetime = true;
568 break; 568 break;
569 case Recurrence::rDaily: 569 case Recurrence::rDaily:
570 r.freq = ICAL_DAILY_RECURRENCE; 570 r.freq = ICAL_DAILY_RECURRENCE;
571 break; 571 break;
572 case Recurrence::rWeekly: 572 case Recurrence::rWeekly:
573 r.freq = ICAL_WEEKLY_RECURRENCE; 573 r.freq = ICAL_WEEKLY_RECURRENCE;
574 r.week_start = static_cast<icalrecurrencetype_weekday>(recur->weekStart()%7 + 1); 574 r.week_start = static_cast<icalrecurrencetype_weekday>(recur->weekStart()%7 + 1);
575 for (i = 0; i < 7; i++) { 575 for (i = 0; i < 7; i++) {
576 if (recur->days().testBit(i)) { 576 if (recur->days().testBit(i)) {
577 day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 577 day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1
578 r.by_day[index++] = icalrecurrencetype_day_day_of_week(day); 578 r.by_day[index++] = icalrecurrencetype_day_day_of_week(day);
579 } 579 }
580 } 580 }
581// r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; 581// r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX;
582 break; 582 break;
583 case Recurrence::rMonthlyPos: 583 case Recurrence::rMonthlyPos:
584 r.freq = ICAL_MONTHLY_RECURRENCE; 584 r.freq = ICAL_MONTHLY_RECURRENCE;
585 585
586 tmpPositions = recur->monthPositions(); 586 tmpPositions = recur->monthPositions();
587 for (tmpPos = tmpPositions.first(); 587 for (tmpPos = tmpPositions.first();
588 tmpPos; 588 tmpPos;
589 tmpPos = tmpPositions.next()) { 589 tmpPos = tmpPositions.next()) {
590 for (i = 0; i < 7; i++) { 590 for (i = 0; i < 7; i++) {
591 if (tmpPos->rDays.testBit(i)) { 591 if (tmpPos->rDays.testBit(i)) {
592 day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 592 day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1
593 day += tmpPos->rPos*8; 593 day += tmpPos->rPos*8;
594 if (tmpPos->negative) day = -day; 594 if (tmpPos->negative) day = -day;
595 r.by_day[index++] = day; 595 r.by_day[index++] = day;
596 } 596 }
597 } 597 }
598 } 598 }
599// r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; 599// r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX;
600 break; 600 break;
601 case Recurrence::rMonthlyDay: 601 case Recurrence::rMonthlyDay:
602 r.freq = ICAL_MONTHLY_RECURRENCE; 602 r.freq = ICAL_MONTHLY_RECURRENCE;
603 603
604 tmpDays = recur->monthDays(); 604 tmpDays = recur->monthDays();
605 for (tmpDay = tmpDays.first(); 605 for (tmpDay = tmpDays.first();
606 tmpDay; 606 tmpDay;
607 tmpDay = tmpDays.next()) { 607 tmpDay = tmpDays.next()) {
@@ -1580,395 +1580,396 @@ void ICalFormatImpl::readAlarm(icalcomponent *alarm,Incidence *incidence)
1580 icalproperty_action action = icalproperty_get_action(p); 1580 icalproperty_action action = icalproperty_get_action(p);
1581 Alarm::Type type = Alarm::Display; 1581 Alarm::Type type = Alarm::Display;
1582 switch ( action ) { 1582 switch ( action ) {
1583 case ICAL_ACTION_DISPLAY: type = Alarm::Display; break; 1583 case ICAL_ACTION_DISPLAY: type = Alarm::Display; break;
1584 case ICAL_ACTION_AUDIO: type = Alarm::Audio; break; 1584 case ICAL_ACTION_AUDIO: type = Alarm::Audio; break;
1585 case ICAL_ACTION_PROCEDURE: type = Alarm::Procedure; break; 1585 case ICAL_ACTION_PROCEDURE: type = Alarm::Procedure; break;
1586 case ICAL_ACTION_EMAIL: type = Alarm::Email; break; 1586 case ICAL_ACTION_EMAIL: type = Alarm::Email; break;
1587 default: 1587 default:
1588 ; 1588 ;
1589 return; 1589 return;
1590 } 1590 }
1591 ialarm->setType(type); 1591 ialarm->setType(type);
1592 1592
1593 p = icalcomponent_get_first_property(alarm,ICAL_ANY_PROPERTY); 1593 p = icalcomponent_get_first_property(alarm,ICAL_ANY_PROPERTY);
1594 while (p) { 1594 while (p) {
1595 icalproperty_kind kind = icalproperty_isa(p); 1595 icalproperty_kind kind = icalproperty_isa(p);
1596 1596
1597 switch (kind) { 1597 switch (kind) {
1598 case ICAL_TRIGGER_PROPERTY: { 1598 case ICAL_TRIGGER_PROPERTY: {
1599 icaltriggertype trigger = icalproperty_get_trigger(p); 1599 icaltriggertype trigger = icalproperty_get_trigger(p);
1600 if (icaltime_is_null_time(trigger.time)) { 1600 if (icaltime_is_null_time(trigger.time)) {
1601 if (icaldurationtype_is_null_duration(trigger.duration)) { 1601 if (icaldurationtype_is_null_duration(trigger.duration)) {
1602 kdDebug(5800) << "ICalFormatImpl::readAlarm(): Trigger has no time and no duration." << endl; 1602 kdDebug(5800) << "ICalFormatImpl::readAlarm(): Trigger has no time and no duration." << endl;
1603 } else { 1603 } else {
1604 Duration duration = icaldurationtype_as_int( trigger.duration ); 1604 Duration duration = icaldurationtype_as_int( trigger.duration );
1605 icalparameter *param = icalproperty_get_first_parameter(p,ICAL_RELATED_PARAMETER); 1605 icalparameter *param = icalproperty_get_first_parameter(p,ICAL_RELATED_PARAMETER);
1606 if (param && icalparameter_get_related(param) == ICAL_RELATED_END) 1606 if (param && icalparameter_get_related(param) == ICAL_RELATED_END)
1607 ialarm->setEndOffset(duration); 1607 ialarm->setEndOffset(duration);
1608 else 1608 else
1609 ialarm->setStartOffset(duration); 1609 ialarm->setStartOffset(duration);
1610 } 1610 }
1611 } else { 1611 } else {
1612 ialarm->setTime(readICalDateTime(trigger.time)); 1612 ialarm->setTime(readICalDateTime(trigger.time));
1613 } 1613 }
1614 break; 1614 break;
1615 } 1615 }
1616 case ICAL_DURATION_PROPERTY: { 1616 case ICAL_DURATION_PROPERTY: {
1617 icaldurationtype duration = icalproperty_get_duration(p); 1617 icaldurationtype duration = icalproperty_get_duration(p);
1618 ialarm->setSnoozeTime(icaldurationtype_as_int(duration)/60); 1618 ialarm->setSnoozeTime(icaldurationtype_as_int(duration)/60);
1619 break; 1619 break;
1620 } 1620 }
1621 case ICAL_REPEAT_PROPERTY: 1621 case ICAL_REPEAT_PROPERTY:
1622 ialarm->setRepeatCount(icalproperty_get_repeat(p)); 1622 ialarm->setRepeatCount(icalproperty_get_repeat(p));
1623 break; 1623 break;
1624 1624
1625 // Only in DISPLAY and EMAIL and PROCEDURE alarms 1625 // Only in DISPLAY and EMAIL and PROCEDURE alarms
1626 case ICAL_DESCRIPTION_PROPERTY: { 1626 case ICAL_DESCRIPTION_PROPERTY: {
1627 QString description = QString::fromUtf8(icalproperty_get_description(p)); 1627 QString description = QString::fromUtf8(icalproperty_get_description(p));
1628 switch ( action ) { 1628 switch ( action ) {
1629 case ICAL_ACTION_DISPLAY: 1629 case ICAL_ACTION_DISPLAY:
1630 ialarm->setText( description ); 1630 ialarm->setText( description );
1631 break; 1631 break;
1632 case ICAL_ACTION_PROCEDURE: 1632 case ICAL_ACTION_PROCEDURE:
1633 ialarm->setProgramArguments( description ); 1633 ialarm->setProgramArguments( description );
1634 break; 1634 break;
1635 case ICAL_ACTION_EMAIL: 1635 case ICAL_ACTION_EMAIL:
1636 ialarm->setMailText( description ); 1636 ialarm->setMailText( description );
1637 break; 1637 break;
1638 default: 1638 default:
1639 break; 1639 break;
1640 } 1640 }
1641 break; 1641 break;
1642 } 1642 }
1643 // Only in EMAIL alarm 1643 // Only in EMAIL alarm
1644 case ICAL_SUMMARY_PROPERTY: 1644 case ICAL_SUMMARY_PROPERTY:
1645 ialarm->setMailSubject(QString::fromUtf8(icalproperty_get_summary(p))); 1645 ialarm->setMailSubject(QString::fromUtf8(icalproperty_get_summary(p)));
1646 break; 1646 break;
1647 1647
1648 // Only in EMAIL alarm 1648 // Only in EMAIL alarm
1649 case ICAL_ATTENDEE_PROPERTY: { 1649 case ICAL_ATTENDEE_PROPERTY: {
1650 QString email = QString::fromUtf8(icalproperty_get_attendee(p)); 1650 QString email = QString::fromUtf8(icalproperty_get_attendee(p));
1651 QString name; 1651 QString name;
1652 icalparameter *param = icalproperty_get_first_parameter(p,ICAL_CN_PARAMETER); 1652 icalparameter *param = icalproperty_get_first_parameter(p,ICAL_CN_PARAMETER);
1653 if (param) { 1653 if (param) {
1654 name = QString::fromUtf8(icalparameter_get_cn(param)); 1654 name = QString::fromUtf8(icalparameter_get_cn(param));
1655 } 1655 }
1656 ialarm->addMailAddress(Person(name, email)); 1656 ialarm->addMailAddress(Person(name, email));
1657 break; 1657 break;
1658 } 1658 }
1659 // Only in AUDIO and EMAIL and PROCEDURE alarms 1659 // Only in AUDIO and EMAIL and PROCEDURE alarms
1660 case ICAL_ATTACH_PROPERTY: { 1660 case ICAL_ATTACH_PROPERTY: {
1661 icalattach *attach = icalproperty_get_attach(p); 1661 icalattach *attach = icalproperty_get_attach(p);
1662 QString url = QFile::decodeName(icalattach_get_url(attach)); 1662 QString url = QFile::decodeName(icalattach_get_url(attach));
1663 switch ( action ) { 1663 switch ( action ) {
1664 case ICAL_ACTION_AUDIO: 1664 case ICAL_ACTION_AUDIO:
1665 ialarm->setAudioFile( url ); 1665 ialarm->setAudioFile( url );
1666 break; 1666 break;
1667 case ICAL_ACTION_PROCEDURE: 1667 case ICAL_ACTION_PROCEDURE:
1668 ialarm->setProgramFile( url ); 1668 ialarm->setProgramFile( url );
1669 break; 1669 break;
1670 case ICAL_ACTION_EMAIL: 1670 case ICAL_ACTION_EMAIL:
1671 ialarm->addMailAttachment( url ); 1671 ialarm->addMailAttachment( url );
1672 break; 1672 break;
1673 default: 1673 default:
1674 break; 1674 break;
1675 } 1675 }
1676 break; 1676 break;
1677 } 1677 }
1678 default: 1678 default:
1679 break; 1679 break;
1680 } 1680 }
1681 1681
1682 p = icalcomponent_get_next_property(alarm,ICAL_ANY_PROPERTY); 1682 p = icalcomponent_get_next_property(alarm,ICAL_ANY_PROPERTY);
1683 } 1683 }
1684 1684
1685 // custom properties 1685 // custom properties
1686 readCustomProperties(alarm, ialarm); 1686 readCustomProperties(alarm, ialarm);
1687 1687
1688 // TODO: check for consistency of alarm properties 1688 // TODO: check for consistency of alarm properties
1689} 1689}
1690 1690
1691icaltimetype ICalFormatImpl::writeICalDate(const QDate &date) 1691icaltimetype ICalFormatImpl::writeICalDate(const QDate &date)
1692{ 1692{
1693 icaltimetype t; 1693 icaltimetype t;
1694 1694
1695 t.year = date.year(); 1695 t.year = date.year();
1696 t.month = date.month(); 1696 t.month = date.month();
1697 t.day = date.day(); 1697 t.day = date.day();
1698 1698
1699 t.hour = 0; 1699 t.hour = 0;
1700 t.minute = 0; 1700 t.minute = 0;
1701 t.second = 0; 1701 t.second = 0;
1702 1702
1703 t.is_date = 1; 1703 t.is_date = 1;
1704 1704
1705 t.is_utc = 0; 1705 t.is_utc = 0;
1706 1706
1707 t.zone = 0; 1707 t.zone = 0;
1708 1708
1709 return t; 1709 return t;
1710} 1710}
1711 1711
1712icaltimetype ICalFormatImpl::writeICalDateTime(const QDateTime &dt ) 1712icaltimetype ICalFormatImpl::writeICalDateTime(const QDateTime &dt )
1713{ 1713{
1714 icaltimetype t; 1714 icaltimetype t;
1715 t.is_date = 0; 1715 t.is_date = 0;
1716 t.zone = 0; 1716 t.zone = 0;
1717 QDateTime datetime; 1717 QDateTime datetime;
1718 if ( mParent->utc() ) { 1718 if ( mParent->utc() ) {
1719 int offset = KGlobal::locale()->localTimeOffset( dt ); 1719 int offset = KGlobal::locale()->localTimeOffset( dt );
1720 datetime = dt.addSecs ( -offset*60); 1720 datetime = dt.addSecs ( -offset*60);
1721 t.is_utc = 1; 1721 t.is_utc = 1;
1722 } 1722 }
1723 else { 1723 else {
1724 datetime = dt; 1724 datetime = dt;
1725 t.is_utc = 0; 1725 t.is_utc = 0;
1726 1726
1727 } 1727 }
1728 t.year = datetime.date().year(); 1728 t.year = datetime.date().year();
1729 t.month = datetime.date().month(); 1729 t.month = datetime.date().month();
1730 t.day = datetime.date().day(); 1730 t.day = datetime.date().day();
1731 1731
1732 t.hour = datetime.time().hour(); 1732 t.hour = datetime.time().hour();
1733 t.minute = datetime.time().minute(); 1733 t.minute = datetime.time().minute();
1734 t.second = datetime.time().second(); 1734 t.second = datetime.time().second();
1735 1735
1736 //qDebug("*** time %s localtime %s ",dt .toString().latin1() ,datetime .toString().latin1() ); 1736 //qDebug("*** time %s localtime %s ",dt .toString().latin1() ,datetime .toString().latin1() );
1737 1737
1738// if ( mParent->utc() ) { 1738// if ( mParent->utc() ) {
1739// datetime = KGlobal::locale()->localTime( dt ); 1739// datetime = KGlobal::locale()->localTime( dt );
1740// qDebug("*** time %s localtime %s ",dt .toString().latin1() ,datetime .toString().latin1() ); 1740// qDebug("*** time %s localtime %s ",dt .toString().latin1() ,datetime .toString().latin1() );
1741// if (mParent->timeZoneId().isEmpty()) 1741// if (mParent->timeZoneId().isEmpty())
1742// t = icaltime_as_utc(t, 0); 1742// t = icaltime_as_utc(t, 0);
1743// else 1743// else
1744// t = icaltime_as_utc(t,mParent->timeZoneId().local8Bit()); 1744// t = icaltime_as_utc(t,mParent->timeZoneId().local8Bit());
1745// } 1745// }
1746 1746
1747 return t; 1747 return t;
1748} 1748}
1749 1749
1750QDateTime ICalFormatImpl::readICalDateTime(icaltimetype t) 1750QDateTime ICalFormatImpl::readICalDateTime(icaltimetype t)
1751{ 1751{
1752 QDateTime dt (QDate(t.year,t.month,t.day), 1752 QDateTime dt (QDate(t.year,t.month,t.day),
1753 QTime(t.hour,t.minute,t.second) ); 1753 QTime(t.hour,t.minute,t.second) );
1754 1754
1755 if (t.is_utc) { 1755 if (t.is_utc) {
1756 int offset = KGlobal::locale()->localTimeOffset( dt ); 1756 int offset = KGlobal::locale()->localTimeOffset( dt );
1757 dt = dt.addSecs ( offset*60); 1757 dt = dt.addSecs ( offset*60);
1758 } 1758 }
1759 1759
1760 return dt; 1760 return dt;
1761} 1761}
1762 1762
1763QDate ICalFormatImpl::readICalDate(icaltimetype t) 1763QDate ICalFormatImpl::readICalDate(icaltimetype t)
1764{ 1764{
1765 return QDate(t.year,t.month,t.day); 1765 return QDate(t.year,t.month,t.day);
1766} 1766}
1767 1767
1768icaldurationtype ICalFormatImpl::writeICalDuration(int seconds) 1768icaldurationtype ICalFormatImpl::writeICalDuration(int seconds)
1769{ 1769{
1770 icaldurationtype d; 1770 icaldurationtype d;
1771 1771
1772 d.weeks = seconds % gSecondsPerWeek; 1772 d.is_neg = (seconds<0)?1:0;
1773 seconds -= d.weeks * gSecondsPerWeek; 1773 if (seconds<0) seconds = -seconds;
1774 d.days = seconds % gSecondsPerDay; 1774
1775 seconds -= d.days * gSecondsPerDay; 1775 d.weeks = seconds / gSecondsPerWeek;
1776 d.hours = seconds % gSecondsPerHour; 1776 seconds %= gSecondsPerWeek;
1777 seconds -= d.hours * gSecondsPerHour; 1777 d.days = seconds / gSecondsPerDay;
1778 d.minutes = seconds % gSecondsPerMinute; 1778 seconds %= gSecondsPerDay;
1779 seconds -= d.minutes * gSecondsPerMinute; 1779 d.hours = seconds / gSecondsPerHour;
1780 seconds %= gSecondsPerHour;
1781 d.minutes = seconds / gSecondsPerMinute;
1782 seconds %= gSecondsPerMinute;
1780 d.seconds = seconds; 1783 d.seconds = seconds;
1781 d.is_neg = 0;
1782
1783 return d; 1784 return d;
1784} 1785}
1785 1786
1786int ICalFormatImpl::readICalDuration(icaldurationtype d) 1787int ICalFormatImpl::readICalDuration(icaldurationtype d)
1787{ 1788{
1788 int result = 0; 1789 int result = 0;
1789 1790
1790 result += d.weeks * gSecondsPerWeek; 1791 result += d.weeks * gSecondsPerWeek;
1791 result += d.days * gSecondsPerDay; 1792 result += d.days * gSecondsPerDay;
1792 result += d.hours * gSecondsPerHour; 1793 result += d.hours * gSecondsPerHour;
1793 result += d.minutes * gSecondsPerMinute; 1794 result += d.minutes * gSecondsPerMinute;
1794 result += d.seconds; 1795 result += d.seconds;
1795 1796
1796 if (d.is_neg) result *= -1; 1797 if (d.is_neg) result *= -1;
1797 1798
1798 return result; 1799 return result;
1799} 1800}
1800 1801
1801icalcomponent *ICalFormatImpl::createCalendarComponent(Calendar *cal) 1802icalcomponent *ICalFormatImpl::createCalendarComponent(Calendar *cal)
1802{ 1803{
1803 icalcomponent *calendar; 1804 icalcomponent *calendar;
1804 1805
1805 // Root component 1806 // Root component
1806 calendar = icalcomponent_new(ICAL_VCALENDAR_COMPONENT); 1807 calendar = icalcomponent_new(ICAL_VCALENDAR_COMPONENT);
1807 1808
1808 icalproperty *p; 1809 icalproperty *p;
1809 1810
1810 // Product Identifier 1811 // Product Identifier
1811 p = icalproperty_new_prodid(CalFormat::productId().utf8()); 1812 p = icalproperty_new_prodid(CalFormat::productId().utf8());
1812 icalcomponent_add_property(calendar,p); 1813 icalcomponent_add_property(calendar,p);
1813 1814
1814 // TODO: Add time zone 1815 // TODO: Add time zone
1815 1816
1816 // iCalendar version (2.0) 1817 // iCalendar version (2.0)
1817 p = icalproperty_new_version(const_cast<char *>(_ICAL_VERSION)); 1818 p = icalproperty_new_version(const_cast<char *>(_ICAL_VERSION));
1818 icalcomponent_add_property(calendar,p); 1819 icalcomponent_add_property(calendar,p);
1819 1820
1820 // Custom properties 1821 // Custom properties
1821 if( cal != 0 ) 1822 if( cal != 0 )
1822 writeCustomProperties(calendar, cal); 1823 writeCustomProperties(calendar, cal);
1823 1824
1824 return calendar; 1825 return calendar;
1825} 1826}
1826 1827
1827 1828
1828 1829
1829// take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. 1830// take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc.
1830// and break it down from its tree-like format into the dictionary format 1831// and break it down from its tree-like format into the dictionary format
1831// that is used internally in the ICalFormatImpl. 1832// that is used internally in the ICalFormatImpl.
1832bool ICalFormatImpl::populate( Calendar *cal, icalcomponent *calendar) 1833bool ICalFormatImpl::populate( Calendar *cal, icalcomponent *calendar)
1833{ 1834{
1834 // this function will populate the caldict dictionary and other event 1835 // this function will populate the caldict dictionary and other event
1835 // lists. It turns vevents into Events and then inserts them. 1836 // lists. It turns vevents into Events and then inserts them.
1836 1837
1837 if (!calendar) return false; 1838 if (!calendar) return false;
1838 1839
1839// TODO: check for METHOD 1840// TODO: check for METHOD
1840#if 0 1841#if 0
1841 if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { 1842 if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) {
1842 char *methodType = 0; 1843 char *methodType = 0;
1843 methodType = fakeCString(vObjectUStringZValue(curVO)); 1844 methodType = fakeCString(vObjectUStringZValue(curVO));
1844 if (mEnableDialogs) 1845 if (mEnableDialogs)
1845 KMessageBox::information(mTopWidget, 1846 KMessageBox::information(mTopWidget,
1846 i18n("This calendar is an iTIP transaction of type \"%1\".") 1847 i18n("This calendar is an iTIP transaction of type \"%1\".")
1847 .arg(methodType), 1848 .arg(methodType),
1848 i18n("%1: iTIP Transaction").arg(CalFormat::application())); 1849 i18n("%1: iTIP Transaction").arg(CalFormat::application()));
1849 delete methodType; 1850 delete methodType;
1850 } 1851 }
1851#endif 1852#endif
1852 1853
1853 icalproperty *p; 1854 icalproperty *p;
1854 1855
1855 p = icalcomponent_get_first_property(calendar,ICAL_PRODID_PROPERTY); 1856 p = icalcomponent_get_first_property(calendar,ICAL_PRODID_PROPERTY);
1856 if (!p) { 1857 if (!p) {
1857// TODO: does no PRODID really matter? 1858// TODO: does no PRODID really matter?
1858// mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); 1859// mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown));
1859// return false; 1860// return false;
1860 mLoadedProductId = ""; 1861 mLoadedProductId = "";
1861 mCalendarVersion = 0; 1862 mCalendarVersion = 0;
1862 } else { 1863 } else {
1863 mLoadedProductId = QString::fromUtf8(icalproperty_get_prodid(p)); 1864 mLoadedProductId = QString::fromUtf8(icalproperty_get_prodid(p));
1864 mCalendarVersion = CalFormat::calendarVersion(mLoadedProductId); 1865 mCalendarVersion = CalFormat::calendarVersion(mLoadedProductId);
1865 1866
1866 delete mCompat; 1867 delete mCompat;
1867 mCompat = CompatFactory::createCompat( mLoadedProductId ); 1868 mCompat = CompatFactory::createCompat( mLoadedProductId );
1868 } 1869 }
1869 1870
1870// TODO: check for unknown PRODID 1871// TODO: check for unknown PRODID
1871#if 0 1872#if 0
1872 if (!mCalendarVersion 1873 if (!mCalendarVersion
1873 && CalFormat::productId() != mLoadedProductId) { 1874 && CalFormat::productId() != mLoadedProductId) {
1874 // warn the user that we might have trouble reading non-known calendar. 1875 // warn the user that we might have trouble reading non-known calendar.
1875 if (mEnableDialogs) 1876 if (mEnableDialogs)
1876 KMessageBox::information(mTopWidget, 1877 KMessageBox::information(mTopWidget,
1877 i18n("This vCalendar file was not created by KOrganizer " 1878 i18n("This vCalendar file was not created by KOrganizer "
1878 "or any other product we support. Loading anyway..."), 1879 "or any other product we support. Loading anyway..."),
1879 i18n("%1: Unknown vCalendar Vendor").arg(CalFormat::application())); 1880 i18n("%1: Unknown vCalendar Vendor").arg(CalFormat::application()));
1880 } 1881 }
1881#endif 1882#endif
1882 1883
1883 p = icalcomponent_get_first_property(calendar,ICAL_VERSION_PROPERTY); 1884 p = icalcomponent_get_first_property(calendar,ICAL_VERSION_PROPERTY);
1884 if (!p) { 1885 if (!p) {
1885 mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); 1886 mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown));
1886 return false; 1887 return false;
1887 } else { 1888 } else {
1888 const char *version = icalproperty_get_version(p); 1889 const char *version = icalproperty_get_version(p);
1889 1890
1890 if (strcmp(version,"1.0") == 0) { 1891 if (strcmp(version,"1.0") == 0) {
1891 mParent->setException(new ErrorFormat(ErrorFormat::CalVersion1, 1892 mParent->setException(new ErrorFormat(ErrorFormat::CalVersion1,
1892 i18n("Expected iCalendar format"))); 1893 i18n("Expected iCalendar format")));
1893 return false; 1894 return false;
1894 } else if (strcmp(version,"2.0") != 0) { 1895 } else if (strcmp(version,"2.0") != 0) {
1895 mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); 1896 mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown));
1896 return false; 1897 return false;
1897 } 1898 }
1898 } 1899 }
1899 1900
1900 1901
1901// TODO: check for calendar format version 1902// TODO: check for calendar format version
1902#if 0 1903#if 0
1903 // warn the user we might have trouble reading this unknown version. 1904 // warn the user we might have trouble reading this unknown version.
1904 if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { 1905 if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) {
1905 char *s = fakeCString(vObjectUStringZValue(curVO)); 1906 char *s = fakeCString(vObjectUStringZValue(curVO));
1906 if (strcmp(_VCAL_VERSION, s) != 0) 1907 if (strcmp(_VCAL_VERSION, s) != 0)
1907 if (mEnableDialogs) 1908 if (mEnableDialogs)
1908 KMessageBox::sorry(mTopWidget, 1909 KMessageBox::sorry(mTopWidget,
1909 i18n("This vCalendar file has version %1.\n" 1910 i18n("This vCalendar file has version %1.\n"
1910 "We only support %2.") 1911 "We only support %2.")
1911 .arg(s).arg(_VCAL_VERSION), 1912 .arg(s).arg(_VCAL_VERSION),
1912 i18n("%1: Unknown vCalendar Version").arg(CalFormat::application())); 1913 i18n("%1: Unknown vCalendar Version").arg(CalFormat::application()));
1913 deleteStr(s); 1914 deleteStr(s);
1914 } 1915 }
1915#endif 1916#endif
1916 1917
1917 // custom properties 1918 // custom properties
1918 readCustomProperties(calendar, cal); 1919 readCustomProperties(calendar, cal);
1919 1920
1920// TODO: set time zone 1921// TODO: set time zone
1921#if 0 1922#if 0
1922 // set the time zone 1923 // set the time zone
1923 if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { 1924 if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) {
1924 char *s = fakeCString(vObjectUStringZValue(curVO)); 1925 char *s = fakeCString(vObjectUStringZValue(curVO));
1925 cal->setTimeZone(s); 1926 cal->setTimeZone(s);
1926 deleteStr(s); 1927 deleteStr(s);
1927 } 1928 }
1928#endif 1929#endif
1929 1930
1930 // Store all events with a relatedTo property in a list for post-processing 1931 // Store all events with a relatedTo property in a list for post-processing
1931 mEventsRelate.clear(); 1932 mEventsRelate.clear();
1932 mTodosRelate.clear(); 1933 mTodosRelate.clear();
1933 // TODO: make sure that only actually added ecvens go to this lists. 1934 // TODO: make sure that only actually added ecvens go to this lists.
1934 1935
1935 icalcomponent *c; 1936 icalcomponent *c;
1936 1937
1937 // Iterate through all todos 1938 // Iterate through all todos
1938 c = icalcomponent_get_first_component(calendar,ICAL_VTODO_COMPONENT); 1939 c = icalcomponent_get_first_component(calendar,ICAL_VTODO_COMPONENT);
1939 while (c) { 1940 while (c) {
1940// kdDebug(5800) << "----Todo found" << endl; 1941// kdDebug(5800) << "----Todo found" << endl;
1941 Todo *todo = readTodo(c); 1942 Todo *todo = readTodo(c);
1942 if (!cal->todo(todo->uid())) cal->addTodo(todo); 1943 if (!cal->todo(todo->uid())) cal->addTodo(todo);
1943 c = icalcomponent_get_next_component(calendar,ICAL_VTODO_COMPONENT); 1944 c = icalcomponent_get_next_component(calendar,ICAL_VTODO_COMPONENT);
1944 } 1945 }
1945 1946
1946 // Iterate through all events 1947 // Iterate through all events
1947 c = icalcomponent_get_first_component(calendar,ICAL_VEVENT_COMPONENT); 1948 c = icalcomponent_get_first_component(calendar,ICAL_VEVENT_COMPONENT);
1948 while (c) { 1949 while (c) {
1949// kdDebug(5800) << "----Event found" << endl; 1950// kdDebug(5800) << "----Event found" << endl;
1950 Event *event = readEvent(c); 1951 Event *event = readEvent(c);
1951 if (!cal->event(event->uid())) cal->addEvent(event); 1952 if (!cal->event(event->uid())) cal->addEvent(event);
1952 c = icalcomponent_get_next_component(calendar,ICAL_VEVENT_COMPONENT); 1953 c = icalcomponent_get_next_component(calendar,ICAL_VEVENT_COMPONENT);
1953 } 1954 }
1954 1955
1955 // Iterate through all journals 1956 // Iterate through all journals
1956 c = icalcomponent_get_first_component(calendar,ICAL_VJOURNAL_COMPONENT); 1957 c = icalcomponent_get_first_component(calendar,ICAL_VJOURNAL_COMPONENT);
1957 while (c) { 1958 while (c) {
1958// kdDebug(5800) << "----Journal found" << endl; 1959// kdDebug(5800) << "----Journal found" << endl;
1959 Journal *journal = readJournal(c); 1960 Journal *journal = readJournal(c);
1960 if (!cal->journal(journal->uid())) cal->addJournal(journal); 1961 if (!cal->journal(journal->uid())) cal->addJournal(journal);
1961 c = icalcomponent_get_next_component(calendar,ICAL_VJOURNAL_COMPONENT); 1962 c = icalcomponent_get_next_component(calendar,ICAL_VJOURNAL_COMPONENT);
1962 } 1963 }
1963 1964
1964#if 0 1965#if 0
1965 initPropIterator(&i, vcal); 1966 initPropIterator(&i, vcal);
1966 1967
1967 // go through all the vobjects in the vcal 1968 // go through all the vobjects in the vcal
1968 while (moreIteration(&i)) { 1969 while (moreIteration(&i)) {
1969 curVO = nextVObject(&i); 1970 curVO = nextVObject(&i);
1970 1971
1971 /************************************************************************/ 1972 /************************************************************************/
1972 1973
1973 // now, check to see that the object is an event or todo. 1974 // now, check to see that the object is an event or todo.
1974 if (strcmp(vObjectName(curVO), VCEventProp) == 0) { 1975 if (strcmp(vObjectName(curVO), VCEventProp) == 0) {
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 51f2e9d..1e99082 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -1,307 +1,314 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <klocale.h> 22#include <klocale.h>
23#include <kdebug.h> 23#include <kdebug.h>
24#include <kidmanager.h> 24#include <kidmanager.h>
25 25
26#include "calformat.h" 26#include "calformat.h"
27#include "syncdefines.h" 27#include "syncdefines.h"
28 28
29#include "incidencebase.h" 29#include "incidencebase.h"
30 30
31using namespace KCal; 31using namespace KCal;
32 32
33IncidenceBase::IncidenceBase() : 33IncidenceBase::IncidenceBase() :
34 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), 34 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false),
35 mPilotId(0), mSyncStatus(SYNCMOD) 35 mPilotId(0), mSyncStatus(SYNCMOD)
36{ 36{
37 setUid(CalFormat::createUniqueId()); 37 setUid(CalFormat::createUniqueId());
38 mOrganizer = ""; 38 mOrganizer = "";
39 mFloats = false; 39 mFloats = false;
40 mDuration = 0; 40 mDuration = 0;
41 mHasDuration = false; 41 mHasDuration = false;
42 mPilotId = 0; 42 mPilotId = 0;
43 mExternalId = ":"; 43 mExternalId = ":";
44 mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 44 mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
45 mSyncStatus = 0; 45 mSyncStatus = 0;
46 mAttendees.setAutoDelete( true ); 46 mAttendees.setAutoDelete( true );
47} 47}
48 48
49IncidenceBase::IncidenceBase(const IncidenceBase &i) : 49IncidenceBase::IncidenceBase(const IncidenceBase &i) :
50 CustomProperties( i ) 50 CustomProperties( i )
51{ 51{
52 mReadOnly = i.mReadOnly; 52 mReadOnly = i.mReadOnly;
53 mDtStart = i.mDtStart; 53 mDtStart = i.mDtStart;
54 mDuration = i.mDuration; 54 mDuration = i.mDuration;
55 mHasDuration = i.mHasDuration; 55 mHasDuration = i.mHasDuration;
56 mOrganizer = i.mOrganizer; 56 mOrganizer = i.mOrganizer;
57 mUid = i.mUid; 57 mUid = i.mUid;
58 QPtrList<Attendee> attendees = i.attendees(); 58 QPtrList<Attendee> attendees = i.attendees();
59 for( Attendee *a = attendees.first(); a; a = attendees.next() ) { 59 for( Attendee *a = attendees.first(); a; a = attendees.next() ) {
60 mAttendees.append( new Attendee( *a ) ); 60 mAttendees.append( new Attendee( *a ) );
61 } 61 }
62 mFloats = i.mFloats; 62 mFloats = i.mFloats;
63 mLastModified = i.mLastModified; 63 mLastModified = i.mLastModified;
64 mPilotId = i.mPilotId; 64 mPilotId = i.mPilotId;
65 mTempSyncStat = i.mTempSyncStat; 65 mTempSyncStat = i.mTempSyncStat;
66 mSyncStatus = i.mSyncStatus; 66 mSyncStatus = i.mSyncStatus;
67 mExternalId = i.mExternalId; 67 mExternalId = i.mExternalId;
68 // The copied object is a new one, so it isn't observed by the observer 68 // The copied object is a new one, so it isn't observed by the observer
69 // of the original object. 69 // of the original object.
70 mObservers.clear(); 70 mObservers.clear();
71 71
72 mAttendees.setAutoDelete( true ); 72 mAttendees.setAutoDelete( true );
73} 73}
74 74
75IncidenceBase::~IncidenceBase() 75IncidenceBase::~IncidenceBase()
76{ 76{
77} 77}
78 78
79 79
80bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) 80bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
81{ 81{
82 // do not compare mSyncStatus and mExternalId 82 // do not compare mSyncStatus and mExternalId
83 if( i1.attendees().count() != i2.attendees().count() ) { 83 if( i1.attendees().count() != i2.attendees().count() ) {
84 return false; // no need to check further 84 return false; // no need to check further
85 } 85 }
86 if ( i1.attendees().count() > 0 ) { 86 if ( i1.attendees().count() > 0 ) {
87 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; 87 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ;
88 while ( a1 ) { 88 while ( a1 ) {
89 if ( !( (*a1) == (*a2)) ) 89 if ( !( (*a1) == (*a2)) )
90 { 90 {
91 //qDebug("Attendee not equal "); 91 //qDebug("Attendee not equal ");
92 return false; 92 return false;
93 } 93 }
94 a1 = i1.attendees().next(); 94 a1 = i1.attendees().next();
95 a2 = i2.attendees().next(); 95 a2 = i2.attendees().next();
96 } 96 }
97 } 97 }
98 //if ( i1.dtStart() != i2.dtStart() ) 98 //if ( i1.dtStart() != i2.dtStart() )
99 // return false; 99 // return false;
100#if 0 100#if 0
101 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); 101 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() );
102 qDebug("1 %d ",i1.duration() == i2.duration() ); 102 qDebug("1 %d ",i1.duration() == i2.duration() );
103 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); 103 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() );
104 qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); 104 qDebug("1 %d ",i1.pilotId() == i2.pilotId() );
105 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); 105 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() );
106 qDebug("6 %d ",i1.organizer() == i2.organizer() ); 106 qDebug("6 %d ",i1.organizer() == i2.organizer() );
107 107
108#endif 108#endif
109 if ( i1.hasDuration() == i2.hasDuration() ) {
110 if ( i1.hasDuration() ) {
111 if ( i1.duration() != i2.duration() )
112 return false;
113 }
114 } else {
115 return false;
116 }
117
109 return ( i1.organizer() == i2.organizer() && 118 return ( i1.organizer() == i2.organizer() &&
110 // i1.uid() == i2.uid() && 119 // i1.uid() == i2.uid() &&
111 // Don't compare lastModified, otherwise the operator is not 120 // Don't compare lastModified, otherwise the operator is not
112 // of much use. We are not comparing for identity, after all. 121 // of much use. We are not comparing for identity, after all.
113 i1.doesFloat() == i2.doesFloat() && 122 i1.doesFloat() == i2.doesFloat() &&
114 i1.duration() == i2.duration() &&
115 i1.hasDuration() == i2.hasDuration() &&
116 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); 123 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() );
117 // no need to compare mObserver 124 // no need to compare mObserver
118} 125}
119 126
120 127
121QDateTime IncidenceBase::getEvenTime( QDateTime dt ) 128QDateTime IncidenceBase::getEvenTime( QDateTime dt )
122{ 129{
123 QTime t = dt.time(); 130 QTime t = dt.time();
124 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 131 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
125 return dt; 132 return dt;
126} 133}
127 134
128 135
129void IncidenceBase::setUid(const QString &uid) 136void IncidenceBase::setUid(const QString &uid)
130{ 137{
131 mUid = uid; 138 mUid = uid;
132 updated(); 139 updated();
133} 140}
134 141
135QString IncidenceBase::uid() const 142QString IncidenceBase::uid() const
136{ 143{
137 return mUid; 144 return mUid;
138} 145}
139 146
140void IncidenceBase::setLastModified(const QDateTime &lm) 147void IncidenceBase::setLastModified(const QDateTime &lm)
141{ 148{
142 // DON'T! updated() because we call this from 149 // DON'T! updated() because we call this from
143 // Calendar::updateEvent(). 150 // Calendar::updateEvent().
144 mLastModified = getEvenTime(lm); 151 mLastModified = getEvenTime(lm);
145 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); 152 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1());
146} 153}
147 154
148QDateTime IncidenceBase::lastModified() const 155QDateTime IncidenceBase::lastModified() const
149{ 156{
150 return mLastModified; 157 return mLastModified;
151} 158}
152 159
153void IncidenceBase::setOrganizer(const QString &o) 160void IncidenceBase::setOrganizer(const QString &o)
154{ 161{
155 // we don't check for readonly here, because it is 162 // we don't check for readonly here, because it is
156 // possible that by setting the organizer we are changing 163 // possible that by setting the organizer we are changing
157 // the event's readonly status... 164 // the event's readonly status...
158 mOrganizer = o; 165 mOrganizer = o;
159 if (mOrganizer.left(7).upper() == "MAILTO:") 166 if (mOrganizer.left(7).upper() == "MAILTO:")
160 mOrganizer = mOrganizer.remove(0,7); 167 mOrganizer = mOrganizer.remove(0,7);
161 168
162 updated(); 169 updated();
163} 170}
164 171
165QString IncidenceBase::organizer() const 172QString IncidenceBase::organizer() const
166{ 173{
167 return mOrganizer; 174 return mOrganizer;
168} 175}
169 176
170void IncidenceBase::setReadOnly( bool readOnly ) 177void IncidenceBase::setReadOnly( bool readOnly )
171{ 178{
172 mReadOnly = readOnly; 179 mReadOnly = readOnly;
173} 180}
174 181
175void IncidenceBase::setDtStart(const QDateTime &dtStart) 182void IncidenceBase::setDtStart(const QDateTime &dtStart)
176{ 183{
177// if (mReadOnly) return; 184// if (mReadOnly) return;
178 mDtStart = getEvenTime(dtStart); 185 mDtStart = getEvenTime(dtStart);
179 updated(); 186 updated();
180} 187}
181 188
182 189
183QDateTime IncidenceBase::dtStart() const 190QDateTime IncidenceBase::dtStart() const
184{ 191{
185 return mDtStart; 192 return mDtStart;
186} 193}
187 194
188QString IncidenceBase::dtStartTimeStr() const 195QString IncidenceBase::dtStartTimeStr() const
189{ 196{
190 return KGlobal::locale()->formatTime(dtStart().time()); 197 return KGlobal::locale()->formatTime(dtStart().time());
191} 198}
192 199
193QString IncidenceBase::dtStartDateStr(bool shortfmt) const 200QString IncidenceBase::dtStartDateStr(bool shortfmt) const
194{ 201{
195 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); 202 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
196} 203}
197 204
198QString IncidenceBase::dtStartStr(bool shortfmt) const 205QString IncidenceBase::dtStartStr(bool shortfmt) const
199{ 206{
200 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); 207 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt);
201} 208}
202 209
203 210
204bool IncidenceBase::doesFloat() const 211bool IncidenceBase::doesFloat() const
205{ 212{
206 return mFloats; 213 return mFloats;
207} 214}
208 215
209void IncidenceBase::setFloats(bool f) 216void IncidenceBase::setFloats(bool f)
210{ 217{
211 if (mReadOnly) return; 218 if (mReadOnly) return;
212 mFloats = f; 219 mFloats = f;
213 updated(); 220 updated();
214} 221}
215 222
216 223
217bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) 224bool IncidenceBase::addAttendee(Attendee *a, bool doupdate)
218{ 225{
219 if (mReadOnly) return false; 226 if (mReadOnly) return false;
220 if (a->name().left(7).upper() == "MAILTO:") 227 if (a->name().left(7).upper() == "MAILTO:")
221 a->setName(a->name().remove(0,7)); 228 a->setName(a->name().remove(0,7));
222 229
223 QPtrListIterator<Attendee> qli(mAttendees); 230 QPtrListIterator<Attendee> qli(mAttendees);
224 231
225 qli.toFirst(); 232 qli.toFirst();
226 while (qli) { 233 while (qli) {
227 if (*qli.current() == *a) 234 if (*qli.current() == *a)
228 return false; 235 return false;
229 ++qli; 236 ++qli;
230 } 237 }
231 mAttendees.append(a); 238 mAttendees.append(a);
232 if (doupdate) updated(); 239 if (doupdate) updated();
233 return true; 240 return true;
234} 241}
235 242
236#if 0 243#if 0
237void IncidenceBase::removeAttendee(Attendee *a) 244void IncidenceBase::removeAttendee(Attendee *a)
238{ 245{
239 if (mReadOnly) return; 246 if (mReadOnly) return;
240 mAttendees.removeRef(a); 247 mAttendees.removeRef(a);
241 updated(); 248 updated();
242} 249}
243 250
244void IncidenceBase::removeAttendee(const char *n) 251void IncidenceBase::removeAttendee(const char *n)
245{ 252{
246 Attendee *a; 253 Attendee *a;
247 254
248 if (mReadOnly) return; 255 if (mReadOnly) return;
249 for (a = mAttendees.first(); a; a = mAttendees.next()) 256 for (a = mAttendees.first(); a; a = mAttendees.next())
250 if (a->getName() == n) { 257 if (a->getName() == n) {
251 mAttendees.remove(); 258 mAttendees.remove();
252 break; 259 break;
253 } 260 }
254} 261}
255#endif 262#endif
256 263
257void IncidenceBase::clearAttendees() 264void IncidenceBase::clearAttendees()
258{ 265{
259 if (mReadOnly) return; 266 if (mReadOnly) return;
260 mAttendees.clear(); 267 mAttendees.clear();
261} 268}
262 269
263#if 0 270#if 0
264Attendee *IncidenceBase::getAttendee(const char *n) const 271Attendee *IncidenceBase::getAttendee(const char *n) const
265{ 272{
266 QPtrListIterator<Attendee> qli(mAttendees); 273 QPtrListIterator<Attendee> qli(mAttendees);
267 274
268 qli.toFirst(); 275 qli.toFirst();
269 while (qli) { 276 while (qli) {
270 if (qli.current()->getName() == n) 277 if (qli.current()->getName() == n)
271 return qli.current(); 278 return qli.current();
272 ++qli; 279 ++qli;
273 } 280 }
274 return 0L; 281 return 0L;
275} 282}
276#endif 283#endif
277 284
278Attendee *IncidenceBase::attendeeByMail(const QString &email) 285Attendee *IncidenceBase::attendeeByMail(const QString &email)
279{ 286{
280 QPtrListIterator<Attendee> qli(mAttendees); 287 QPtrListIterator<Attendee> qli(mAttendees);
281 288
282 qli.toFirst(); 289 qli.toFirst();
283 while (qli) { 290 while (qli) {
284 if (qli.current()->email().lower() == email.lower()) 291 if (qli.current()->email().lower() == email.lower())
285 return qli.current(); 292 return qli.current();
286 ++qli; 293 ++qli;
287 } 294 }
288 return 0L; 295 return 0L;
289} 296}
290 297
291Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) 298Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email)
292{ 299{
293 QPtrListIterator<Attendee> qli(mAttendees); 300 QPtrListIterator<Attendee> qli(mAttendees);
294 301
295 QStringList mails = emails; 302 QStringList mails = emails;
296 if (!email.isEmpty()) { 303 if (!email.isEmpty()) {
297 mails.append(email); 304 mails.append(email);
298 } 305 }
299 qli.toFirst(); 306 qli.toFirst();
300 while (qli) { 307 while (qli) {
301 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { 308 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) {
302 if (qli.current()->email().lower() == (*it).lower()) 309 if (qli.current()->email().lower() == (*it).lower())
303 return qli.current(); 310 return qli.current();
304 } 311 }
305 312
306 ++qli; 313 ++qli;
307 } 314 }