summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-16 23:10:29 (UTC)
committer zautrix <zautrix>2005-03-16 23:10:29 (UTC)
commitd2be5ea1cd22f5222aecb0f70a2fe8657fae9698 (patch) (unidiff)
tree5de4c2b05428d837e2451df06b3ea313bd02c1b8
parentb7184073d5e552e0f04b14c5fc0c20a7bfd26d3d (diff)
downloadkdepimpi-d2be5ea1cd22f5222aecb0f70a2fe8657fae9698.zip
kdepimpi-d2be5ea1cd22f5222aecb0f70a2fe8657fae9698.tar.gz
kdepimpi-d2be5ea1cd22f5222aecb0f70a2fe8657fae9698.tar.bz2
fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt3
-rw-r--r--libkcal/vcalformat.cpp50
2 files changed, 10 insertions, 43 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index 55b120f..81efb6c 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,200 +1,203 @@
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.17 ************ 3********** VERSION 2.0.17 ************
4 4
5KO/Pi: 5KO/Pi:
6Tooltips in month view were not sorted. Fixed. 6Tooltips in month view were not sorted. Fixed.
7Daylabel in agenda view ( for display of one day ) was too short. Fixed. 7Daylabel in agenda view ( for display of one day ) was too short. Fixed.
8Conflict display dialog for syncing was not on top of other windows. Fixed. 8Conflict display dialog for syncing was not on top of other windows. Fixed.
9Fixed some minor problems.
10
11Fixed an endless loop when importing vcs file with RESOURCES entry.
9 12
10********** VERSION 2.0.16 ************ 13********** VERSION 2.0.16 ************
11OM/Pi: 14OM/Pi:
12Fixed the SMTP account setting the option. 15Fixed the SMTP account setting the option.
13Fixed something in mail sending. 16Fixed something in mail sending.
14 17
15KO/Pi: 18KO/Pi:
16Added possibility to export selected events/todos as vcal file. 19Added possibility to export selected events/todos as vcal file.
17 20
18********** VERSION 2.0.15 ************ 21********** VERSION 2.0.15 ************
19 22
20PwM/Pi: 23PwM/Pi:
21Added keyboard shorcuts for 24Added keyboard shorcuts for
22- toggling summary view (space bar) 25- toggling summary view (space bar)
23- delete item (delete + backspace key) 26- delete item (delete + backspace key)
24- add new item ( i + n key) 27- add new item ( i + n key)
25Fixed length of info in the title. 28Fixed length of info in the title.
26 29
27KO/Pi-KA/Pi: 30KO/Pi-KA/Pi:
28Changed "ME" menu bar entry to an icon. 31Changed "ME" menu bar entry to an icon.
29 32
30KO/Pi: 33KO/Pi:
31Fixed two minor bugs in displaying todos. 34Fixed two minor bugs in displaying todos.
32If in month view a cell is selected, the key shortcut "d" shows now that date. 35If in month view a cell is selected, the key shortcut "d" shows now that date.
33Added complete info for a todo in month view as an icon left of the text. 36Added complete info for a todo in month view as an icon left of the text.
34Fixed problems of displaying data when "<" or ">" are used in summary/location/description. 37Fixed problems of displaying data when "<" or ">" are used in summary/location/description.
35Fixed problem of search dialog size when switching displays. 38Fixed problem of search dialog size when switching displays.
36Cancel key now closes date picker. 39Cancel key now closes date picker.
37Rearranged KO/Pi file menu structure. 40Rearranged KO/Pi file menu structure.
38 41
39OM/Pi: 42OM/Pi:
40Added to the SMTP account setting the option 43Added to the SMTP account setting the option
41"No secure connection". 44"No secure connection".
42You have to configure your SMTP accounts again, sorry. 45You have to configure your SMTP accounts again, sorry.
43 46
44KA/Pi: 47KA/Pi:
45Added support for importing quoted-printable. 48Added support for importing quoted-printable.
46Support was added by Peter P.. Thanks, Peter! 49Support was added by Peter P.. Thanks, Peter!
47 50
48 51
49********** VERSION 2.0.14 ************ 52********** VERSION 2.0.14 ************
50 53
51Made Passwordmanager PwM/Pi more userfriendly: 54Made Passwordmanager PwM/Pi more userfriendly:
52Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. 55Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more.
53Fixed bug in KO/Pi todo printing. 56Fixed bug in KO/Pi todo printing.
54Made Qtopia calendar import possible on desktop . 57Made Qtopia calendar import possible on desktop .
55 58
56********** VERSION 2.0.13 ************ 59********** VERSION 2.0.13 ************
57 60
58Fixed a problem in the addressee select dialog and made it more user friendly by adding a minimize splitter. 61Fixed a problem in the addressee select dialog and made it more user friendly by adding a minimize splitter.
59 62
60In the search dialog you can switch now the focus from search line edit to the list view by pressing key "arrow down". 63In the search dialog you can switch now the focus from search line edit to the list view by pressing key "arrow down".
61 64
62OM/Pi: 65OM/Pi:
63Fixed a refresh problem of outgoing/sent/sendfailed folders after sending mails. 66Fixed a refresh problem of outgoing/sent/sendfailed folders after sending mails.
64Added missing German translation. 67Added missing German translation.
65Added warning if path is specified in local folder settings of account config. 68Added warning if path is specified in local folder settings of account config.
66 69
67********** VERSION 2.0.12 ************ 70********** VERSION 2.0.12 ************
68 71
69KO/Pi: 72KO/Pi:
70Fixed a bug in todo start/due date handling for non recurring todos with a start and due date. 73Fixed a bug in todo start/due date handling for non recurring todos with a start and due date.
71Fixed some layout problems in the KO/Pi agenda view when there were many conflicting itmes. 74Fixed some layout problems in the KO/Pi agenda view when there were many conflicting itmes.
72Fixed several problems of the keyboard focus in the desktop versions when opening the search dialog/event viewer. 75Fixed several problems of the keyboard focus in the desktop versions when opening the search dialog/event viewer.
73 76
74Fixed problem in pi-sync mode when wrong password was sent. 77Fixed problem in pi-sync mode when wrong password was sent.
75 78
76OM/Pi: 79OM/Pi:
77Fixed a crash when displaying mails with "Show mail as html" was checked in the config. 80Fixed a crash when displaying mails with "Show mail as html" was checked in the config.
78Added a check before displaying the mail if the mail is in html format, if "Show mail as html" is enabled. 81Added a check before displaying the mail if the mail is in html format, if "Show mail as html" is enabled.
79 82
80********** VERSION 2.0.11 ************ 83********** VERSION 2.0.11 ************
81 84
82Fixed some problems in pi-sync mode 85Fixed some problems in pi-sync mode
83(e.g. details of events were not synced properly) 86(e.g. details of events were not synced properly)
84 87
85********** VERSION 2.0.10 ************ 88********** VERSION 2.0.10 ************
86 89
87KO/Pi: 90KO/Pi:
88In the desktop versions the context menu in the search dialog was broken after introducing the What'sThis info for the list view. 91In the desktop versions the context menu in the search dialog was broken after introducing the What'sThis info for the list view.
89This is fixed. 92This is fixed.
90Changed the search dialog a bit to make it more user friendly. 93Changed the search dialog a bit to make it more user friendly.
91(E.g.: Removed message box about "no items found" and set key focus to search line edit after search). 94(E.g.: Removed message box about "no items found" and set key focus to search line edit after search).
92 95
93Added config option to hide the week number in KO/Pi toolbar. 96Added config option to hide the week number in KO/Pi toolbar.
94 97
95********** VERSION 2.0.9 ************ 98********** VERSION 2.0.9 ************
96 99
97Made month view icons for multiday events a bit nicer. 100Made month view icons for multiday events a bit nicer.
98Some minor fixes in KO/Pi 101Some minor fixes in KO/Pi
99(e.g. go to today did not work for new week view properly). 102(e.g. go to today did not work for new week view properly).
100 103
101 104
102********** VERSION 2.0.8 ************ 105********** VERSION 2.0.8 ************
103 106
104Fixed a problem in dependency info in the ipk files for the Zaurus. 107Fixed a problem in dependency info in the ipk files for the Zaurus.
105 108
106Added 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. 109Added 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.
107 110
108Added a "go today" button to the datepicker. 111Added a "go today" button to the datepicker.
109 112
110Added "created" and "last modified" to event/todo viewer (and What'sThis viewer) 113Added "created" and "last modified" to event/todo viewer (and What'sThis viewer)
111and made it configureable to show these values. 114and made it configureable to show these values.
112 115
113Fixed a problem for events (from external iCal files) that do have a duration but no end date. 116Fixed a problem for events (from external iCal files) that do have a duration but no end date.
114 117
115 118
116********** VERSION 2.0.7 ************ 119********** VERSION 2.0.7 ************
117 120
118Added global application font settings 121Added global application font settings
119(for all KDE-Pim/Pi apps) to the general settings. 122(for all KDE-Pim/Pi apps) to the general settings.
120 123
121Fixed a problem in OM/Pi when trying to login to some IMAP servers 124Fixed a problem in OM/Pi when trying to login to some IMAP servers
122(like the IMAP server of Apple: mail.mac.com ) 125(like the IMAP server of Apple: mail.mac.com )
123 126
124Added recurring todos to KO/Pi. 127Added recurring todos to KO/Pi.
125 128
126 129
127********** VERSION 2.0.6 ************ 130********** VERSION 2.0.6 ************
128 131
129Some bugfixes in the pi-sync mode. 132Some bugfixes in the pi-sync mode.
130Added German translation for pi-sync mode. 133Added German translation for pi-sync mode.
131 134
132KO/Pi: 135KO/Pi:
133Made the todolist using alternate background. 136Made the todolist using alternate background.
134 137
135Other minor fixes in KO/Pi. 138Other minor fixes in KO/Pi.
136 139
137 140
138********** VERSION 2.0.5 ************ 141********** VERSION 2.0.5 ************
139 142
140Bugfixes in KO/Pi. 143Bugfixes in KO/Pi.
141 144
142********** VERSION 2.0.4 ************ 145********** VERSION 2.0.4 ************
143 146
144KO/Pi: 147KO/Pi:
145Fixed problem loading translations for summary/location edit boxes in event/todo editor. 148Fixed problem loading translations for summary/location edit boxes in event/todo editor.
146 149
147Added a general "select week number" to the toolbar. 150Added a general "select week number" to the toolbar.
148 151
149Fixed some small problem of the new features introduced in version 2.0.3. 152Fixed some small problem of the new features introduced in version 2.0.3.
150 153
151Made it possible to specify one specific category as category color, 154Made it possible to specify one specific category as category color,
152if more than one categories are selected. 155if more than one categories are selected.
153 156
154Fixed a bug in saving colors for categories with non-ascii characters. 157Fixed a bug in saving colors for categories with non-ascii characters.
155(Like, e.g. German Umlauts). 158(Like, e.g. German Umlauts).
156Propably you have to set your colors again for those categories. 159Propably you have to set your colors again for those categories.
157 160
158 161
159********** VERSION 2.0.3 ************ 162********** VERSION 2.0.3 ************
160 163
161KO/Pi: 164KO/Pi:
162Added feature for changing alarm settings for many items at once: 165Added feature for changing alarm settings for many items at once:
163Open list view (or search dialog), select the desired items and choose in 166Open list view (or search dialog), select the desired items and choose in
164the popup menu: Set alarm for selected... 167the popup menu: Set alarm for selected...
165 168
166Added to the event/todo viewer the option to send an email to 169Added to the event/todo viewer the option to send an email to
167all attendees or all selected (with RSVP) attendees. 170all attendees or all selected (with RSVP) attendees.
168 171
169Made the week-month mode changing in month view faster. 172Made the week-month mode changing in month view faster.
170 173
171Made month view better useable with keyboard. 174Made month view better useable with keyboard.
172Now TAB key jumps to next cell with an event/todo. 175Now TAB key jumps to next cell with an event/todo.
173Scroll in cell with coursor keys, scroll in time (next week) with 176Scroll in cell with coursor keys, scroll in time (next week) with
174Shift/Control + coursorkeys. 177Shift/Control + coursorkeys.
175 178
176Fixed bug that the todo view flat mode was reset after first view update. 179Fixed bug that the todo view flat mode was reset after first view update.
177 180
178If a todo is displayed closed in the todo view, 181If a todo is displayed closed in the todo view,
179it is now displayed in overdue/due today color depending on the subtodos overdue/due today properties. 182it is now displayed in overdue/due today color depending on the subtodos overdue/due today properties.
180 183
181Added info about the numbers of years to the caption (title) information about a birthday event. 184Added info about the numbers of years to the caption (title) information about a birthday event.
182 185
183Made completion date in todo editor editable. 186Made completion date in todo editor editable.
184 187
185Added possibility to save/load templates for journals. 188Added possibility to save/load templates for journals.
186(Which is just a simple "save text to file" or "insert text from file". 189(Which is just a simple "save text to file" or "insert text from file".
187 190
188********** VERSION 2.0.2 ************ 191********** VERSION 2.0.2 ************
189 192
190KO/Pi: 193KO/Pi:
191Fixed the layout problem of the day label buttons 194Fixed the layout problem of the day label buttons
192of the agenda view introduced in version 2.0.1. 195of the agenda view introduced in version 2.0.1.
193 196
194Added WhatsThis support for the todo view and the list view. 197Added WhatsThis support for the todo view and the list view.
195 198
196Added a quite useful feature to the montview. 199Added a quite useful feature to the montview.
197Just click on the week numbers on the left. 200Just click on the week numbers on the left.
198And in the top right corner of month view/agenda view 201And in the top right corner of month view/agenda view
199there is now a "week number quick selector". 202there is now a "week number quick selector".
200(Click on the black triangle). 203(Click on the black triangle).
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp
index 223aa5a..62a31ae 100644
--- a/libkcal/vcalformat.cpp
+++ b/libkcal/vcalformat.cpp
@@ -42,1040 +42,1026 @@
42 42
43#include "vcalformat.h" 43#include "vcalformat.h"
44 44
45using namespace KCal; 45using namespace KCal;
46 46
47VCalFormat::VCalFormat() 47VCalFormat::VCalFormat()
48{ 48{
49 mCalendar = 0; 49 mCalendar = 0;
50 useLocalTime = false; 50 useLocalTime = false;
51} 51}
52 52
53VCalFormat::~VCalFormat() 53VCalFormat::~VCalFormat()
54{ 54{
55} 55}
56 56
57void VCalFormat::setLocalTime ( bool b ) 57void VCalFormat::setLocalTime ( bool b )
58{ 58{
59 useLocalTime = b; 59 useLocalTime = b;
60} 60}
61bool VCalFormat::load(Calendar *calendar, const QString &fileName) 61bool VCalFormat::load(Calendar *calendar, const QString &fileName)
62{ 62{
63 mCalendar = calendar; 63 mCalendar = calendar;
64 clearException(); 64 clearException();
65 if ( ! useLocalTime ) 65 if ( ! useLocalTime )
66 useLocalTime = mCalendar->isLocalTime(); 66 useLocalTime = mCalendar->isLocalTime();
67 VObject *vcal = 0; 67 VObject *vcal = 0;
68 68
69 // this is not necessarily only 1 vcal. Could be many vcals, or include 69 // this is not necessarily only 1 vcal. Could be many vcals, or include
70 // a vcard... 70 // a vcard...
71 vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); 71 vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data()));
72 72
73 if (!vcal) { 73 if (!vcal) {
74 setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); 74 setException(new ErrorFormat(ErrorFormat::CalVersionUnknown));
75 return FALSE; 75 return FALSE;
76 } 76 }
77 77
78 // any other top-level calendar stuff should be added/initialized here 78 // any other top-level calendar stuff should be added/initialized here
79 79
80 // put all vobjects into their proper places 80 // put all vobjects into their proper places
81 populate(vcal); 81 populate(vcal);
82 82
83 // clean up from vcal API stuff 83 // clean up from vcal API stuff
84 cleanVObjects(vcal); 84 cleanVObjects(vcal);
85 cleanStrTbl(); 85 cleanStrTbl();
86 86
87 return true; 87 return true;
88} 88}
89 89
90 90
91bool VCalFormat::save(Calendar *calendar, const QString &fileName) 91bool VCalFormat::save(Calendar *calendar, const QString &fileName)
92{ 92{
93 mCalendar = calendar; 93 mCalendar = calendar;
94 if ( ! useLocalTime ) 94 if ( ! useLocalTime )
95 useLocalTime = mCalendar->isLocalTime(); 95 useLocalTime = mCalendar->isLocalTime();
96 96
97 QString tmpStr; 97 QString tmpStr;
98 VObject *vcal, *vo; 98 VObject *vcal, *vo;
99 99
100 100
101 vcal = newVObject(VCCalProp); 101 vcal = newVObject(VCCalProp);
102 102
103 // addPropValue(vcal,VCLocationProp, "0.0"); 103 // addPropValue(vcal,VCLocationProp, "0.0");
104 addPropValue(vcal,VCProdIdProp, productId()); 104 addPropValue(vcal,VCProdIdProp, productId());
105 tmpStr = mCalendar->getTimeZoneStr(); 105 tmpStr = mCalendar->getTimeZoneStr();
106 //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); 106 //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() );
107 addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); 107 addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit());
108 addPropValue(vcal,VCVersionProp, _VCAL_VERSION); 108 addPropValue(vcal,VCVersionProp, _VCAL_VERSION);
109 109
110 // TODO STUFF 110 // TODO STUFF
111 QPtrList<Todo> todoList = mCalendar->rawTodos(); 111 QPtrList<Todo> todoList = mCalendar->rawTodos();
112 QPtrListIterator<Todo> qlt(todoList); 112 QPtrListIterator<Todo> qlt(todoList);
113 for (; qlt.current(); ++qlt) { 113 for (; qlt.current(); ++qlt) {
114 vo = eventToVTodo(qlt.current()); 114 vo = eventToVTodo(qlt.current());
115 addVObjectProp(vcal, vo); 115 addVObjectProp(vcal, vo);
116 } 116 }
117 117
118 // EVENT STUFF 118 // EVENT STUFF
119 QPtrList<Event> events = mCalendar->rawEvents(); 119 QPtrList<Event> events = mCalendar->rawEvents();
120 Event *ev; 120 Event *ev;
121 for(ev=events.first();ev;ev=events.next()) { 121 for(ev=events.first();ev;ev=events.next()) {
122 vo = eventToVEvent(ev); 122 vo = eventToVEvent(ev);
123 addVObjectProp(vcal, vo); 123 addVObjectProp(vcal, vo);
124 } 124 }
125 125
126 writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); 126 writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal);
127 cleanVObjects(vcal); 127 cleanVObjects(vcal);
128 cleanStrTbl(); 128 cleanStrTbl();
129 129
130 if (QFile::exists(fileName)) { 130 if (QFile::exists(fileName)) {
131 return true; 131 return true;
132 } else { 132 } else {
133 return false; // error 133 return false; // error
134 } 134 }
135} 135}
136 136
137bool VCalFormat::fromString( Calendar *calendar, const QString &text ) 137bool VCalFormat::fromString( Calendar *calendar, const QString &text )
138{ 138{
139 // TODO: Factor out VCalFormat::fromString() 139 // TODO: Factor out VCalFormat::fromString()
140 140
141 QCString data = text.utf8(); 141 QCString data = text.utf8();
142 142
143 if ( !data.size() ) return false; 143 if ( !data.size() ) return false;
144 144
145 VObject *vcal = Parse_MIME( data.data(), data.size()); 145 VObject *vcal = Parse_MIME( data.data(), data.size());
146 if ( !vcal ) return false; 146 if ( !vcal ) return false;
147 147
148 VObjectIterator i; 148 VObjectIterator i;
149 VObject *curvo; 149 VObject *curvo;
150 initPropIterator( &i, vcal ); 150 initPropIterator( &i, vcal );
151 151
152 // we only take the first object. TODO: parse all incidences. 152 // we only take the first object. TODO: parse all incidences.
153 do { 153 do {
154 curvo = nextVObject( &i ); 154 curvo = nextVObject( &i );
155 } while ( strcmp( vObjectName( curvo ), VCEventProp ) && 155 } while ( strcmp( vObjectName( curvo ), VCEventProp ) &&
156 strcmp( vObjectName( curvo ), VCTodoProp ) ); 156 strcmp( vObjectName( curvo ), VCTodoProp ) );
157 157
158 if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { 158 if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) {
159 Event *event = VEventToEvent( curvo ); 159 Event *event = VEventToEvent( curvo );
160 calendar->addEvent( event ); 160 calendar->addEvent( event );
161 } else { 161 } else {
162 qDebug("VCalFormat::fromString(): Unknown object type. "); 162 qDebug("VCalFormat::fromString(): Unknown object type. ");
163 deleteVObject( vcal ); 163 deleteVObject( vcal );
164 return false; 164 return false;
165 } 165 }
166 166
167 deleteVObject( vcal ); 167 deleteVObject( vcal );
168 168
169 return true; 169 return true;
170} 170}
171 171
172QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) 172QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal)
173{ 173{
174 174
175 if ( !event ) return QString::null; 175 if ( !event ) return QString::null;
176 bool useL = useLocalTime; 176 bool useL = useLocalTime;
177 useLocalTime = useLocal; 177 useLocalTime = useLocal;
178 mCalendar = calendar; 178 mCalendar = calendar;
179 VObject *vevent = eventToVEvent( event ); 179 VObject *vevent = eventToVEvent( event );
180 char *buf = writeMemVObject( 0, 0, vevent ); 180 char *buf = writeMemVObject( 0, 0, vevent );
181 QString result( buf ); 181 QString result( buf );
182 cleanVObject( vevent ); 182 cleanVObject( vevent );
183 useLocalTime = useL; 183 useLocalTime = useL;
184 return result; 184 return result;
185} 185}
186QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) 186QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal )
187{ 187{
188 188
189 if ( !todo ) return QString::null; 189 if ( !todo ) return QString::null;
190 bool useL = useLocalTime; 190 bool useL = useLocalTime;
191 useLocalTime = useLocal; 191 useLocalTime = useLocal;
192 mCalendar = calendar; 192 mCalendar = calendar;
193 VObject *vevent = eventToVTodo( todo ); 193 VObject *vevent = eventToVTodo( todo );
194 char *buf = writeMemVObject( 0, 0, vevent ); 194 char *buf = writeMemVObject( 0, 0, vevent );
195 QString result( buf ); 195 QString result( buf );
196 cleanVObject( vevent ); 196 cleanVObject( vevent );
197 useLocalTime = useL; 197 useLocalTime = useL;
198 return result; 198 return result;
199} 199}
200 200
201QString VCalFormat::toString( Calendar *calendar ) 201QString VCalFormat::toString( Calendar *calendar )
202{ 202{
203 // TODO: Factor out VCalFormat::asString() 203 // TODO: Factor out VCalFormat::asString()
204 204
205 VObject *vcal = newVObject(VCCalProp); 205 VObject *vcal = newVObject(VCCalProp);
206 206
207 addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); 207 addPropValue( vcal, VCProdIdProp, CalFormat::productId() );
208 QString tmpStr = mCalendar->getTimeZoneStr(); 208 QString tmpStr = mCalendar->getTimeZoneStr();
209 addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); 209 addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() );
210 addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); 210 addPropValue( vcal, VCVersionProp, _VCAL_VERSION );
211 211
212 // TODO: Use all data. 212 // TODO: Use all data.
213 QPtrList<Event> events = calendar->events(); 213 QPtrList<Event> events = calendar->events();
214 Event *event = events.first(); 214 Event *event = events.first();
215 if ( !event ) return QString::null; 215 if ( !event ) return QString::null;
216 216
217 VObject *vevent = eventToVEvent( event ); 217 VObject *vevent = eventToVEvent( event );
218 218
219 addVObjectProp( vcal, vevent ); 219 addVObjectProp( vcal, vevent );
220 220
221 char *buf = writeMemVObject( 0, 0, vcal ); 221 char *buf = writeMemVObject( 0, 0, vcal );
222 222
223 QString result( buf ); 223 QString result( buf );
224 224
225 cleanVObject( vcal ); 225 cleanVObject( vcal );
226 226
227 return result; 227 return result;
228} 228}
229 229
230VObject *VCalFormat::eventToVTodo(const Todo *anEvent) 230VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
231{ 231{
232 VObject *vtodo; 232 VObject *vtodo;
233 QString tmpStr; 233 QString tmpStr;
234 QStringList tmpStrList; 234
235 235
236 vtodo = newVObject(VCTodoProp); 236 vtodo = newVObject(VCTodoProp);
237 237
238 // due date 238 // due date
239 if (anEvent->hasDueDate()) { 239 if (anEvent->hasDueDate()) {
240 tmpStr = qDateTimeToISO(anEvent->dtDue(), 240 tmpStr = qDateTimeToISO(anEvent->dtDue(),
241 !anEvent->doesFloat()); 241 !anEvent->doesFloat());
242 addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); 242 addPropValue(vtodo, VCDueProp, tmpStr.local8Bit());
243 } 243 }
244 244
245 // start date 245 // start date
246 if (anEvent->hasStartDate()) { 246 if (anEvent->hasStartDate()) {
247 tmpStr = qDateTimeToISO(anEvent->dtStart(), 247 tmpStr = qDateTimeToISO(anEvent->dtStart(),
248 !anEvent->doesFloat()); 248 !anEvent->doesFloat());
249 addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); 249 addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit());
250 } 250 }
251 251
252 // creation date 252 // creation date
253 tmpStr = qDateTimeToISO(anEvent->created()); 253 tmpStr = qDateTimeToISO(anEvent->created());
254 addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); 254 addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit());
255 255
256 // unique id 256 // unique id
257 addPropValue(vtodo, VCUniqueStringProp, 257 addPropValue(vtodo, VCUniqueStringProp,
258 anEvent->uid().local8Bit()); 258 anEvent->uid().local8Bit());
259 259
260 // revision 260 // revision
261 tmpStr.sprintf("%i", anEvent->revision()); 261 tmpStr.sprintf("%i", anEvent->revision());
262 addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); 262 addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit());
263 263
264 // last modification date 264 // last modification date
265 tmpStr = qDateTimeToISO(anEvent->lastModified()); 265 tmpStr = qDateTimeToISO(anEvent->lastModified());
266 addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); 266 addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit());
267 267
268 // organizer stuff 268 // organizer stuff
269 tmpStr = "MAILTO:" + anEvent->organizer(); 269 tmpStr = "MAILTO:" + anEvent->organizer();
270 addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); 270 addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit());
271 271
272 // attendees 272 // attendees
273 if (anEvent->attendeeCount() != 0) { 273 if (anEvent->attendeeCount() != 0) {
274 QPtrList<Attendee> al = anEvent->attendees(); 274 QPtrList<Attendee> al = anEvent->attendees();
275 QPtrListIterator<Attendee> ai(al); 275 QPtrListIterator<Attendee> ai(al);
276 Attendee *curAttendee; 276 Attendee *curAttendee;
277 277
278 for (; ai.current(); ++ai) { 278 for (; ai.current(); ++ai) {
279 curAttendee = ai.current(); 279 curAttendee = ai.current();
280 if (!curAttendee->email().isEmpty() && 280 if (!curAttendee->email().isEmpty() &&
281 !curAttendee->name().isEmpty()) 281 !curAttendee->name().isEmpty())
282 tmpStr = "MAILTO:" + curAttendee->name() + " <" + 282 tmpStr = "MAILTO:" + curAttendee->name() + " <" +
283 curAttendee->email() + ">"; 283 curAttendee->email() + ">";
284 else if (curAttendee->name().isEmpty()) 284 else if (curAttendee->name().isEmpty())
285 tmpStr = "MAILTO: " + curAttendee->email(); 285 tmpStr = "MAILTO: " + curAttendee->email();
286 else if (curAttendee->email().isEmpty()) 286 else if (curAttendee->email().isEmpty())
287 tmpStr = "MAILTO: " + curAttendee->name(); 287 tmpStr = "MAILTO: " + curAttendee->name();
288 else if (curAttendee->name().isEmpty() && 288 else if (curAttendee->name().isEmpty() &&
289 curAttendee->email().isEmpty()) 289 curAttendee->email().isEmpty())
290 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; 290 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl;
291 VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); 291 VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit());
292 addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); 292 addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role()));
293 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); 293 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");
294 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); 294 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status()));
295 } 295 }
296 } 296 }
297 297
298 // description BL: 298 // description BL:
299 if (!anEvent->description().isEmpty()) { 299 if (!anEvent->description().isEmpty()) {
300 VObject *d = addPropValue(vtodo, VCDescriptionProp, 300 VObject *d = addPropValue(vtodo, VCDescriptionProp,
301 anEvent->description().local8Bit()); 301 anEvent->description().local8Bit());
302 if (anEvent->description().find('\n') != -1) 302 if (anEvent->description().find('\n') != -1)
303 addProp(d, VCQuotedPrintableProp); 303 addProp(d, VCQuotedPrintableProp);
304 } 304 }
305 305
306 // summary 306 // summary
307 if (!anEvent->summary().isEmpty()) 307 if (!anEvent->summary().isEmpty())
308 addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); 308 addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit());
309 309
310 if (!anEvent->location().isEmpty()) 310 if (!anEvent->location().isEmpty())
311 addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); 311 addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit());
312 312
313 // completed 313 // completed
314 // status 314 // status
315 // backward compatibility, KOrganizer used to interpret only these two values 315 // backward compatibility, KOrganizer used to interpret only these two values
316 addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : 316 addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" :
317 "NEEDS_ACTION"); 317 "NEEDS_ACTION");
318 // completion date 318 // completion date
319 if (anEvent->hasCompletedDate()) { 319 if (anEvent->hasCompletedDate()) {
320 tmpStr = qDateTimeToISO(anEvent->completed()); 320 tmpStr = qDateTimeToISO(anEvent->completed());
321 addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); 321 addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit());
322 } 322 }
323 323
324 // priority 324 // priority
325 tmpStr.sprintf("%i",anEvent->priority()); 325 tmpStr.sprintf("%i",anEvent->priority());
326 addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); 326 addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit());
327 327
328 // related event 328 // related event
329 if (anEvent->relatedTo()) { 329 if (anEvent->relatedTo()) {
330 addPropValue(vtodo, VCRelatedToProp, 330 addPropValue(vtodo, VCRelatedToProp,
331 anEvent->relatedTo()->uid().local8Bit()); 331 anEvent->relatedTo()->uid().local8Bit());
332 } 332 }
333 333
334 // categories 334 // categories
335 tmpStrList = anEvent->categories(); 335 QStringList tmpStrList = anEvent->categories();
336 tmpStr = ""; 336 tmpStr = "";
337 QString catStr; 337 QString catStr;
338 for ( QStringList::Iterator it = tmpStrList.begin(); 338 for ( QStringList::Iterator it = tmpStrList.begin();
339 it != tmpStrList.end(); 339 it != tmpStrList.end();
340 ++it ) { 340 ++it ) {
341 catStr = *it; 341 catStr = *it;
342 if (catStr[0] == ' ') 342 if (catStr[0] == ' ')
343 tmpStr += catStr.mid(1); 343 tmpStr += catStr.mid(1);
344 else 344 else
345 tmpStr += catStr; 345 tmpStr += catStr;
346 // this must be a ';' character as the vCalendar specification requires! 346 // this must be a ';' character as the vCalendar specification requires!
347 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 347 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
348 // read in. 348 // read in.
349 tmpStr += ";"; 349 tmpStr += ";";
350 } 350 }
351 if (!tmpStr.isEmpty()) { 351 if (!tmpStr.isEmpty()) {
352 tmpStr.truncate(tmpStr.length()-1); 352 tmpStr.truncate(tmpStr.length()-1);
353 addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); 353 addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit());
354 } 354 }
355 355
356 // alarm stuff 356 // alarm stuff
357 kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; 357 kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl;
358 QPtrList<Alarm> alarms = anEvent->alarms(); 358 QPtrList<Alarm> alarms = anEvent->alarms();
359 Alarm* alarm; 359 Alarm* alarm;
360 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 360 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
361 if (alarm->enabled()) { 361 if (alarm->enabled()) {
362 VObject *a; 362 VObject *a;
363 tmpStr = qDateTimeToISO(alarm->time()); 363 tmpStr = qDateTimeToISO(alarm->time());
364 if (alarm->type() == Alarm::Audio) { 364 if (alarm->type() == Alarm::Audio) {
365 a = addProp(vtodo, VCAAlarmProp); 365 a = addProp(vtodo, VCAAlarmProp);
366 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 366 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
367 addPropValue(a, VCRepeatCountProp, "1"); 367 addPropValue(a, VCRepeatCountProp, "1");
368 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); 368 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile()));
369 } 369 }
370 else if (alarm->type() == Alarm::Procedure) { 370 else if (alarm->type() == Alarm::Procedure) {
371 a = addProp(vtodo, VCPAlarmProp); 371 a = addProp(vtodo, VCPAlarmProp);
372 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 372 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
373 addPropValue(a, VCRepeatCountProp, "1"); 373 addPropValue(a, VCRepeatCountProp, "1");
374 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); 374 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile()));
375 } else { 375 } else {
376 a = addProp(vtodo, VCDAlarmProp); 376 a = addProp(vtodo, VCDAlarmProp);
377 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 377 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
378 addPropValue(a, VCRepeatCountProp, "1"); 378 addPropValue(a, VCRepeatCountProp, "1");
379 addPropValue(a, VCDisplayStringProp, "beep!"); 379 addPropValue(a, VCDisplayStringProp, "beep!");
380 } 380 }
381 } 381 }
382 } 382 }
383 383
384 if (anEvent->pilotId()) { 384 if (anEvent->pilotId()) {
385 // pilot sync stuff 385 // pilot sync stuff
386 tmpStr.sprintf("%i",anEvent->pilotId()); 386 tmpStr.sprintf("%i",anEvent->pilotId());
387 addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); 387 addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit());
388 tmpStr.sprintf("%i",anEvent->syncStatus()); 388 tmpStr.sprintf("%i",anEvent->syncStatus());
389 addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); 389 addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit());
390 } 390 }
391 391
392 return vtodo; 392 return vtodo;
393} 393}
394 394
395VObject* VCalFormat::eventToVEvent(const Event *anEvent) 395VObject* VCalFormat::eventToVEvent(const Event *anEvent)
396{ 396{
397 VObject *vevent; 397 VObject *vevent;
398 QString tmpStr; 398 QString tmpStr;
399 QStringList tmpStrList; 399
400
401 vevent = newVObject(VCEventProp); 400 vevent = newVObject(VCEventProp);
402 401
403 // start and end time 402 // start and end time
404 tmpStr = qDateTimeToISO(anEvent->dtStart(), 403 tmpStr = qDateTimeToISO(anEvent->dtStart(),
405 !anEvent->doesFloat()); 404 !anEvent->doesFloat());
406 addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); 405 addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit());
407 406
408 // events that have time associated but take up no time should 407 // events that have time associated but take up no time should
409 // not have both DTSTART and DTEND. 408 // not have both DTSTART and DTEND.
410 if (anEvent->dtStart() != anEvent->dtEnd()) { 409 if (anEvent->dtStart() != anEvent->dtEnd()) {
411 tmpStr = qDateTimeToISO(anEvent->dtEnd(), 410 tmpStr = qDateTimeToISO(anEvent->dtEnd(),
412 !anEvent->doesFloat()); 411 !anEvent->doesFloat());
413 addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); 412 addPropValue(vevent, VCDTendProp, tmpStr.local8Bit());
414 } 413 }
415 414
416 // creation date 415 // creation date
417 tmpStr = qDateTimeToISO(anEvent->created()); 416 tmpStr = qDateTimeToISO(anEvent->created());
418 addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); 417 addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit());
419 418
420 // unique id 419 // unique id
421 addPropValue(vevent, VCUniqueStringProp, 420 addPropValue(vevent, VCUniqueStringProp,
422 anEvent->uid().local8Bit()); 421 anEvent->uid().local8Bit());
423 422
424 // revision 423 // revision
425 tmpStr.sprintf("%i", anEvent->revision()); 424 tmpStr.sprintf("%i", anEvent->revision());
426 addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); 425 addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit());
427 426
428 // last modification date 427 // last modification date
429 tmpStr = qDateTimeToISO(anEvent->lastModified()); 428 tmpStr = qDateTimeToISO(anEvent->lastModified());
430 addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); 429 addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit());
431 430
432 // attendee and organizer stuff 431 // attendee and organizer stuff
433 tmpStr = "MAILTO:" + anEvent->organizer(); 432 tmpStr = "MAILTO:" + anEvent->organizer();
434 addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); 433 addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit());
435 434
436 if (anEvent->attendeeCount() != 0) { 435 if (anEvent->attendeeCount() != 0) {
437 QPtrList<Attendee> al = anEvent->attendees(); 436 QPtrList<Attendee> al = anEvent->attendees();
438 QPtrListIterator<Attendee> ai(al); 437 QPtrListIterator<Attendee> ai(al);
439 Attendee *curAttendee; 438 Attendee *curAttendee;
440 439
441 // TODO: Put this functionality into Attendee class 440 // TODO: Put this functionality into Attendee class
442 for (; ai.current(); ++ai) { 441 for (; ai.current(); ++ai) {
443 curAttendee = ai.current(); 442 curAttendee = ai.current();
444 if (!curAttendee->email().isEmpty() && 443 if (!curAttendee->email().isEmpty() &&
445 !curAttendee->name().isEmpty()) 444 !curAttendee->name().isEmpty())
446 tmpStr = "MAILTO:" + curAttendee->name() + " <" + 445 tmpStr = "MAILTO:" + curAttendee->name() + " <" +
447 curAttendee->email() + ">"; 446 curAttendee->email() + ">";
448 else if (curAttendee->name().isEmpty()) 447 else if (curAttendee->name().isEmpty())
449 tmpStr = "MAILTO: " + curAttendee->email(); 448 tmpStr = "MAILTO: " + curAttendee->email();
450 else if (curAttendee->email().isEmpty()) 449 else if (curAttendee->email().isEmpty())
451 tmpStr = "MAILTO: " + curAttendee->name(); 450 tmpStr = "MAILTO: " + curAttendee->name();
452 else if (curAttendee->name().isEmpty() && 451 else if (curAttendee->name().isEmpty() &&
453 curAttendee->email().isEmpty()) 452 curAttendee->email().isEmpty())
454 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; 453 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl;
455 VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); 454 VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit());
456 addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); 455 addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role()));
457 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); 456 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");
458 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); 457 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status()));
459 } 458 }
460 } 459 }
461 460
462 // recurrence rule stuff 461 // recurrence rule stuff
463 if (anEvent->recurrence()->doesRecur()) { 462 if (anEvent->recurrence()->doesRecur()) {
464 // some more variables 463 // some more variables
465 QPtrList<Recurrence::rMonthPos> tmpPositions; 464 QPtrList<Recurrence::rMonthPos> tmpPositions;
466 QPtrList<int> tmpDays; 465 QPtrList<int> tmpDays;
467 int *tmpDay; 466 int *tmpDay;
468 Recurrence::rMonthPos *tmpPos; 467 Recurrence::rMonthPos *tmpPos;
469 QString tmpStr2; 468 QString tmpStr2;
470 int i; 469 int i;
471 470
472 switch(anEvent->recurrence()->doesRecur()) { 471 switch(anEvent->recurrence()->doesRecur()) {
473 case Recurrence::rDaily: 472 case Recurrence::rDaily:
474 tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); 473 tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency());
475// if (anEvent->rDuration > 0) 474// if (anEvent->rDuration > 0)
476 //tmpStr += "#"; 475 //tmpStr += "#";
477 break; 476 break;
478 case Recurrence::rWeekly: 477 case Recurrence::rWeekly:
479 tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); 478 tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency());
480 for (i = 0; i < 7; i++) { 479 for (i = 0; i < 7; i++) {
481 if (anEvent->recurrence()->days().testBit(i)) 480 if (anEvent->recurrence()->days().testBit(i))
482 tmpStr += dayFromNum(i); 481 tmpStr += dayFromNum(i);
483 } 482 }
484 break; 483 break;
485 case Recurrence::rMonthlyPos: 484 case Recurrence::rMonthlyPos:
486 tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); 485 tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency());
487 // write out all rMonthPos's 486 // write out all rMonthPos's
488 tmpPositions = anEvent->recurrence()->monthPositions(); 487 tmpPositions = anEvent->recurrence()->monthPositions();
489 for (tmpPos = tmpPositions.first(); 488 for (tmpPos = tmpPositions.first();
490 tmpPos; 489 tmpPos;
491 tmpPos = tmpPositions.next()) { 490 tmpPos = tmpPositions.next()) {
492 491
493 tmpStr2.sprintf("%i", tmpPos->rPos); 492 tmpStr2.sprintf("%i", tmpPos->rPos);
494 if (tmpPos->negative) 493 if (tmpPos->negative)
495 tmpStr2 += "- "; 494 tmpStr2 += "- ";
496 else 495 else
497 tmpStr2 += "+ "; 496 tmpStr2 += "+ ";
498 tmpStr += tmpStr2; 497 tmpStr += tmpStr2;
499 for (i = 0; i < 7; i++) { 498 for (i = 0; i < 7; i++) {
500 if (tmpPos->rDays.testBit(i)) 499 if (tmpPos->rDays.testBit(i))
501 tmpStr += dayFromNum(i); 500 tmpStr += dayFromNum(i);
502 } 501 }
503 } // loop for all rMonthPos's 502 } // loop for all rMonthPos's
504 break; 503 break;
505 case Recurrence::rMonthlyDay: 504 case Recurrence::rMonthlyDay:
506 tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); 505 tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency());
507 // write out all rMonthDays; 506 // write out all rMonthDays;
508 tmpDays = anEvent->recurrence()->monthDays(); 507 tmpDays = anEvent->recurrence()->monthDays();
509 for (tmpDay = tmpDays.first(); 508 for (tmpDay = tmpDays.first();
510 tmpDay; 509 tmpDay;
511 tmpDay = tmpDays.next()) { 510 tmpDay = tmpDays.next()) {
512 tmpStr2.sprintf("%i ", *tmpDay); 511 tmpStr2.sprintf("%i ", *tmpDay);
513 tmpStr += tmpStr2; 512 tmpStr += tmpStr2;
514 } 513 }
515 break; 514 break;
516 case Recurrence::rYearlyMonth: 515 case Recurrence::rYearlyMonth:
517 tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); 516 tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency());
518 // write out all the rYearNums; 517 // write out all the rYearNums;
519 tmpDays = anEvent->recurrence()->yearNums(); 518 tmpDays = anEvent->recurrence()->yearNums();
520 for (tmpDay = tmpDays.first(); 519 for (tmpDay = tmpDays.first();
521 tmpDay; 520 tmpDay;
522 tmpDay = tmpDays.next()) { 521 tmpDay = tmpDays.next()) {
523 tmpStr2.sprintf("%i ", *tmpDay); 522 tmpStr2.sprintf("%i ", *tmpDay);
524 tmpStr += tmpStr2; 523 tmpStr += tmpStr2;
525 } 524 }
526 break; 525 break;
527 case Recurrence::rYearlyDay: 526 case Recurrence::rYearlyDay:
528 tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency()); 527 tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency());
529 // write out all the rYearNums; 528 // write out all the rYearNums;
530 tmpDays = anEvent->recurrence()->yearNums(); 529 tmpDays = anEvent->recurrence()->yearNums();
531 for (tmpDay = tmpDays.first(); 530 for (tmpDay = tmpDays.first();
532 tmpDay; 531 tmpDay;
533 tmpDay = tmpDays.next()) { 532 tmpDay = tmpDays.next()) {
534 tmpStr2.sprintf("%i ", *tmpDay); 533 tmpStr2.sprintf("%i ", *tmpDay);
535 tmpStr += tmpStr2; 534 tmpStr += tmpStr2;
536 } 535 }
537 break; 536 break;
538 default: 537 default:
539 kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; 538 kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl;
540 break; 539 break;
541 } // switch 540 } // switch
542 541
543 if (anEvent->recurrence()->duration() > 0) { 542 if (anEvent->recurrence()->duration() > 0) {
544 tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); 543 tmpStr2.sprintf("#%i",anEvent->recurrence()->duration());
545 tmpStr += tmpStr2; 544 tmpStr += tmpStr2;
546 } else if (anEvent->recurrence()->duration() == -1) { 545 } else if (anEvent->recurrence()->duration() == -1) {
547 tmpStr += "#0"; // defined as repeat forever 546 tmpStr += "#0"; // defined as repeat forever
548 } else { 547 } else {
549 tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); 548 tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE);
550 } 549 }
551 addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); 550 addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit());
552 551
553 } // event repeats 552 } // event repeats
554 553
555 // exceptions to recurrence 554 // exceptions to recurrence
556 DateList dateList = anEvent->exDates(); 555 DateList dateList = anEvent->exDates();
557 DateList::ConstIterator it; 556 DateList::ConstIterator it;
558 QString tmpStr2; 557 QString tmpStr2;
559 558
560 for (it = dateList.begin(); it != dateList.end(); ++it) { 559 for (it = dateList.begin(); it != dateList.end(); ++it) {
561 tmpStr = qDateToISO(*it) + ";"; 560 tmpStr = qDateToISO(*it) + ";";
562 tmpStr2 += tmpStr; 561 tmpStr2 += tmpStr;
563 } 562 }
564 if (!tmpStr2.isEmpty()) { 563 if (!tmpStr2.isEmpty()) {
565 tmpStr2.truncate(tmpStr2.length()-1); 564 tmpStr2.truncate(tmpStr2.length()-1);
566 addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit()); 565 addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit());
567 } 566 }
568 567
569 // description 568 // description
570 if (!anEvent->description().isEmpty()) { 569 if (!anEvent->description().isEmpty()) {
571 VObject *d = addPropValue(vevent, VCDescriptionProp, 570 VObject *d = addPropValue(vevent, VCDescriptionProp,
572 anEvent->description().local8Bit()); 571 anEvent->description().local8Bit());
573 if (anEvent->description().find('\n') != -1) 572 if (anEvent->description().find('\n') != -1)
574 addProp(d, VCQuotedPrintableProp); 573 addProp(d, VCQuotedPrintableProp);
575 } 574 }
576 575
577 // summary 576 // summary
578 if (!anEvent->summary().isEmpty()) 577 if (!anEvent->summary().isEmpty())
579 addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); 578 addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit());
580 579
581 if (!anEvent->location().isEmpty()) 580 if (!anEvent->location().isEmpty())
582 addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); 581 addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit());
583 582
584 // status 583 // status
585// TODO: define Event status 584// TODO: define Event status
586// addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); 585// addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit());
587 586
588 // secrecy 587 // secrecy
589 const char *text = 0; 588 const char *text = 0;
590 switch (anEvent->secrecy()) { 589 switch (anEvent->secrecy()) {
591 case Incidence::SecrecyPublic: 590 case Incidence::SecrecyPublic:
592 text = "PUBLIC"; 591 text = "PUBLIC";
593 break; 592 break;
594 case Incidence::SecrecyPrivate: 593 case Incidence::SecrecyPrivate:
595 text = "PRIVATE"; 594 text = "PRIVATE";
596 break; 595 break;
597 case Incidence::SecrecyConfidential: 596 case Incidence::SecrecyConfidential:
598 text = "CONFIDENTIAL"; 597 text = "CONFIDENTIAL";
599 break; 598 break;
600 } 599 }
601 if (text) { 600 if (text) {
602 addPropValue(vevent, VCClassProp, text); 601 addPropValue(vevent, VCClassProp, text);
603 } 602 }
604 603
605 // categories 604 // categories
606 tmpStrList = anEvent->categories(); 605 QStringList tmpStrList = anEvent->categories();
607 tmpStr = ""; 606 tmpStr = "";
608 QString catStr; 607 QString catStr;
609 for ( QStringList::Iterator it = tmpStrList.begin(); 608 for ( QStringList::Iterator it = tmpStrList.begin();
610 it != tmpStrList.end(); 609 it != tmpStrList.end();
611 ++it ) { 610 ++it ) {
612 catStr = *it; 611 catStr = *it;
613 if (catStr[0] == ' ') 612 if (catStr[0] == ' ')
614 tmpStr += catStr.mid(1); 613 tmpStr += catStr.mid(1);
615 else 614 else
616 tmpStr += catStr; 615 tmpStr += catStr;
617 // this must be a ';' character as the vCalendar specification requires! 616 // this must be a ';' character as the vCalendar specification requires!
618 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 617 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
619 // read in. 618 // read in.
620 tmpStr += ";"; 619 tmpStr += ";";
621 } 620 }
622 if (!tmpStr.isEmpty()) { 621 if (!tmpStr.isEmpty()) {
623 tmpStr.truncate(tmpStr.length()-1); 622 tmpStr.truncate(tmpStr.length()-1);
624 addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); 623 addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit());
625 } 624 }
626 625
627 // attachments 626 // attachments
628 // TODO: handle binary attachments! 627 // TODO: handle binary attachments!
629 QPtrList<Attachment> attachments = anEvent->attachments(); 628 QPtrList<Attachment> attachments = anEvent->attachments();
630 for ( Attachment *at = attachments.first(); at; at = attachments.next() ) 629 for ( Attachment *at = attachments.first(); at; at = attachments.next() )
631 addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); 630 addPropValue(vevent, VCAttachProp, at->uri().local8Bit());
632 631
633 // resources 632 // resources
634 tmpStrList = anEvent->resources(); 633 tmpStrList = anEvent->resources();
635 tmpStr = tmpStrList.join(";"); 634 tmpStr = tmpStrList.join(";");
636 if (!tmpStr.isEmpty()) 635 if (!tmpStr.isEmpty())
637 addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); 636 addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit());
638 637
639 // alarm stuff 638 // alarm stuff
640 QPtrList<Alarm> alarms = anEvent->alarms(); 639 QPtrList<Alarm> alarms = anEvent->alarms();
641 Alarm* alarm; 640 Alarm* alarm;
642 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 641 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
643 if (alarm->enabled()) { 642 if (alarm->enabled()) {
644 VObject *a ; 643 VObject *a ;
645 tmpStr = qDateTimeToISO(alarm->time()); 644 tmpStr = qDateTimeToISO(alarm->time());
646 if (alarm->type() == Alarm::Audio) { 645 if (alarm->type() == Alarm::Audio) {
647 a = addProp(vevent, VCAAlarmProp); 646 a = addProp(vevent, VCAAlarmProp);
648 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 647 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
649 addPropValue(a, VCRepeatCountProp, "1"); 648 addPropValue(a, VCRepeatCountProp, "1");
650 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); 649 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile()));
651 } 650 }
652 if (alarm->type() == Alarm::Procedure) { 651 if (alarm->type() == Alarm::Procedure) {
653 a = addProp(vevent, VCPAlarmProp); 652 a = addProp(vevent, VCPAlarmProp);
654 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 653 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
655 addPropValue(a, VCRepeatCountProp, "1"); 654 addPropValue(a, VCRepeatCountProp, "1");
656 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); 655 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile()));
657 } else { 656 } else {
658 a = addProp(vevent, VCDAlarmProp); 657 a = addProp(vevent, VCDAlarmProp);
659 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 658 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
660 addPropValue(a, VCRepeatCountProp, "1"); 659 addPropValue(a, VCRepeatCountProp, "1");
661 addPropValue(a, VCDisplayStringProp, "beep!"); 660 addPropValue(a, VCDisplayStringProp, "beep!");
662 661
663 } 662 }
664 } 663 }
665 } 664 }
666 665
667 // priority 666 // priority
668 tmpStr.sprintf("%i",anEvent->priority()); 667 tmpStr.sprintf("%i",anEvent->priority());
669 addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); 668 addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit());
670 669
671 // transparency 670 // transparency
672 tmpStr.sprintf("%i",anEvent->transparency()); 671 tmpStr.sprintf("%i",anEvent->transparency());
673 addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); 672 addPropValue(vevent, VCTranspProp, tmpStr.local8Bit());
674 673
675 // related event 674 // related event
676 if (anEvent->relatedTo()) { 675 if (anEvent->relatedTo()) {
677 addPropValue(vevent, VCRelatedToProp, 676 addPropValue(vevent, VCRelatedToProp,
678 anEvent->relatedTo()->uid().local8Bit()); 677 anEvent->relatedTo()->uid().local8Bit());
679 } 678 }
680 679
681 if (anEvent->pilotId()) { 680 if (anEvent->pilotId()) {
682 // pilot sync stuff 681 // pilot sync stuff
683 tmpStr.sprintf("%i",anEvent->pilotId()); 682 tmpStr.sprintf("%i",anEvent->pilotId());
684 addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); 683 addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit());
685 tmpStr.sprintf("%i",anEvent->syncStatus()); 684 tmpStr.sprintf("%i",anEvent->syncStatus());
686 addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); 685 addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit());
687 } 686 }
688 687
689 return vevent; 688 return vevent;
690} 689}
691 690
692Todo *VCalFormat::VTodoToEvent(VObject *vtodo) 691Todo *VCalFormat::VTodoToEvent(VObject *vtodo)
693{ 692{
694 VObject *vo; 693 VObject *vo;
695 VObjectIterator voi; 694 VObjectIterator voi;
696 char *s; 695 char *s;
697 696
698 Todo *anEvent = new Todo; 697 Todo *anEvent = new Todo;
699 698
700 // creation date 699 // creation date
701 if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { 700 if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) {
702 anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 701 anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
703 deleteStr(s); 702 deleteStr(s);
704 } 703 }
705 704
706 // unique id 705 // unique id
707 vo = isAPropertyOf(vtodo, VCUniqueStringProp); 706 vo = isAPropertyOf(vtodo, VCUniqueStringProp);
708 // while the UID property is preferred, it is not required. We'll use the 707 // while the UID property is preferred, it is not required. We'll use the
709 // default Event UID if none is given. 708 // default Event UID if none is given.
710 if (vo) { 709 if (vo) {
711 anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); 710 anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo)));
712 deleteStr(s); 711 deleteStr(s);
713 } 712 }
714 713
715 // last modification date 714 // last modification date
716 if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { 715 if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) {
717 anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 716 anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
718 deleteStr(s); 717 deleteStr(s);
719 } 718 }
720 else 719 else
721 anEvent->setLastModified(QDateTime(QDate::currentDate(), 720 anEvent->setLastModified(QDateTime(QDate::currentDate(),
722 QTime::currentTime())); 721 QTime::currentTime()));
723 722
724 // organizer 723 // organizer
725 // if our extension property for the event's ORGANIZER exists, add it. 724 // if our extension property for the event's ORGANIZER exists, add it.
726 if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { 725 if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) {
727 anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); 726 anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo)));
728 deleteStr(s); 727 deleteStr(s);
729 } else { 728 } else {
730 anEvent->setOrganizer(mCalendar->getEmail()); 729 anEvent->setOrganizer(mCalendar->getEmail());
731 } 730 }
732 731
733 // attendees. 732 // attendees.
734 initPropIterator(&voi, vtodo); 733 initPropIterator(&voi, vtodo);
735 while (moreIteration(&voi)) { 734 while (moreIteration(&voi)) {
736 vo = nextVObject(&voi); 735 vo = nextVObject(&voi);
737 if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { 736 if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) {
738 Attendee *a; 737 Attendee *a;
739 VObject *vp; 738 VObject *vp;
740 s = fakeCString(vObjectUStringZValue(vo)); 739 s = fakeCString(vObjectUStringZValue(vo));
741 QString tmpStr = QString::fromLocal8Bit(s); 740 QString tmpStr = QString::fromLocal8Bit(s);
742 deleteStr(s); 741 deleteStr(s);
743 tmpStr = tmpStr.simplifyWhiteSpace(); 742 tmpStr = tmpStr.simplifyWhiteSpace();
744 int emailPos1, emailPos2; 743 int emailPos1, emailPos2;
745 if ((emailPos1 = tmpStr.find('<')) > 0) { 744 if ((emailPos1 = tmpStr.find('<')) > 0) {
746 // both email address and name 745 // both email address and name
747 emailPos2 = tmpStr.findRev('>'); 746 emailPos2 = tmpStr.findRev('>');
748 a = new Attendee(tmpStr.left(emailPos1 - 1), 747 a = new Attendee(tmpStr.left(emailPos1 - 1),
749 tmpStr.mid(emailPos1 + 1, 748 tmpStr.mid(emailPos1 + 1,
750 emailPos2 - (emailPos1 + 1))); 749 emailPos2 - (emailPos1 + 1)));
751 } else if (tmpStr.find('@') > 0) { 750 } else if (tmpStr.find('@') > 0) {
752 // just an email address 751 // just an email address
753 a = new Attendee(0, tmpStr); 752 a = new Attendee(0, tmpStr);
754 } else { 753 } else {
755 // just a name 754 // just a name
756 // QString email = tmpStr.replace( QRegExp(" "), "." ); 755 // QString email = tmpStr.replace( QRegExp(" "), "." );
757 a = new Attendee(tmpStr,0); 756 a = new Attendee(tmpStr,0);
758 } 757 }
759 // is there a Role property? 758 // is there a Role property?
760 if ((vp = isAPropertyOf(vo, VCRoleProp)) != 0) 759 if ((vp = isAPropertyOf(vo, VCRoleProp)) != 0)
761 a->setRole(readRole(vObjectStringZValue(vp))); 760 a->setRole(readRole(vObjectStringZValue(vp)));
762 // is there an RSVP property? 761 // is there an RSVP property?
763 if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) 762 if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0)
764 a->setRSVP(vObjectStringZValue(vp)); 763 a->setRSVP(vObjectStringZValue(vp));
765 // is there a status property? 764 // is there a status property?
766 if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) 765 if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0)
767 a->setStatus(readStatus(vObjectStringZValue(vp))); 766 a->setStatus(readStatus(vObjectStringZValue(vp)));
768 // add the attendee 767 // add the attendee
769 anEvent->addAttendee(a); 768 anEvent->addAttendee(a);
770 } 769 }
771 } 770 }
772 771
773 // description for todo 772 // description for todo
774 if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) { 773 if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) {
775 s = fakeCString(vObjectUStringZValue(vo)); 774 s = fakeCString(vObjectUStringZValue(vo));
776 anEvent->setDescription(QString::fromLocal8Bit(s)); 775 anEvent->setDescription(QString::fromLocal8Bit(s));
777 deleteStr(s); 776 deleteStr(s);
778 } 777 }
779 778
780 // summary 779 // summary
781 if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { 780 if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) {
782 s = fakeCString(vObjectUStringZValue(vo)); 781 s = fakeCString(vObjectUStringZValue(vo));
783 anEvent->setSummary(QString::fromLocal8Bit(s)); 782 anEvent->setSummary(QString::fromLocal8Bit(s));
784 deleteStr(s); 783 deleteStr(s);
785 } 784 }
786 if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { 785 if ((vo = isAPropertyOf(vtodo, VCLocationProp))) {
787 s = fakeCString(vObjectUStringZValue(vo)); 786 s = fakeCString(vObjectUStringZValue(vo));
788 anEvent->setLocation(QString::fromLocal8Bit(s)); 787 anEvent->setLocation(QString::fromLocal8Bit(s));
789 deleteStr(s); 788 deleteStr(s);
790 } 789 }
791 790
792 791
793 // completed 792 // completed
794 // was: status 793 // was: status
795 if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { 794 if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) {
796 s = fakeCString(vObjectUStringZValue(vo)); 795 s = fakeCString(vObjectUStringZValue(vo));
797 if (strcmp(s,"COMPLETED") == 0) { 796 if (strcmp(s,"COMPLETED") == 0) {
798 anEvent->setCompleted(true); 797 anEvent->setCompleted(true);
799 } else { 798 } else {
800 anEvent->setCompleted(false); 799 anEvent->setCompleted(false);
801 } 800 }
802 deleteStr(s); 801 deleteStr(s);
803 } 802 }
804 else 803 else
805 anEvent->setCompleted(false); 804 anEvent->setCompleted(false);
806 805
807 // completion date 806 // completion date
808 if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { 807 if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) {
809 anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 808 anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
810 deleteStr(s); 809 deleteStr(s);
811 } 810 }
812 811
813 // priority 812 // priority
814 if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { 813 if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) {
815 anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 814 anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo))));
816 deleteStr(s); 815 deleteStr(s);
817 } 816 }
818 817
819 // due date 818 // due date
820 if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { 819 if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) {
821 anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 820 anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
822 deleteStr(s); 821 deleteStr(s);
823 anEvent->setHasDueDate(true); 822 anEvent->setHasDueDate(true);
824 } else { 823 } else {
825 anEvent->setHasDueDate(false); 824 anEvent->setHasDueDate(false);
826 } 825 }
827 826
828 // start time 827 // start time
829 if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) { 828 if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) {
830 anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 829 anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
831 // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; 830 // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl;
832 deleteStr(s); 831 deleteStr(s);
833 anEvent->setHasStartDate(true); 832 anEvent->setHasStartDate(true);
834 } else { 833 } else {
835 anEvent->setHasStartDate(false); 834 anEvent->setHasStartDate(false);
836 } 835 }
837 836
838 /* alarm stuff */ 837 /* alarm stuff */
839 //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl; 838 //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl;
840 if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) { 839 if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) {
841 Alarm* alarm = anEvent->newAlarm(); 840 Alarm* alarm = anEvent->newAlarm();
842 VObject *a; 841 VObject *a;
843 if ((a = isAPropertyOf(vo, VCRunTimeProp))) { 842 if ((a = isAPropertyOf(vo, VCRunTimeProp))) {
844 alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); 843 alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a))));
845 deleteStr(s); 844 deleteStr(s);
846 } 845 }
847 alarm->setEnabled(true); 846 alarm->setEnabled(true);
848 if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) { 847 if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) {
849 if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { 848 if ((a = isAPropertyOf(vo, VCProcedureNameProp))) {
850 s = fakeCString(vObjectUStringZValue(a)); 849 s = fakeCString(vObjectUStringZValue(a));
851 alarm->setProcedureAlarm(QFile::decodeName(s)); 850 alarm->setProcedureAlarm(QFile::decodeName(s));
852 deleteStr(s); 851 deleteStr(s);
853 } 852 }
854 } 853 }
855 if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) { 854 if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) {
856 if ((a = isAPropertyOf(vo, VCAudioContentProp))) { 855 if ((a = isAPropertyOf(vo, VCAudioContentProp))) {
857 s = fakeCString(vObjectUStringZValue(a)); 856 s = fakeCString(vObjectUStringZValue(a));
858 alarm->setAudioAlarm(QFile::decodeName(s)); 857 alarm->setAudioAlarm(QFile::decodeName(s));
859 deleteStr(s); 858 deleteStr(s);
860 } 859 }
861 } 860 }
862 } 861 }
863 862
864 // related todo 863 // related todo
865 if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) { 864 if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) {
866 anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); 865 anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo)));
867 deleteStr(s); 866 deleteStr(s);
868 mTodosRelate.append(anEvent); 867 mTodosRelate.append(anEvent);
869 } 868 }
870 869
871 // categories 870 // categories
872 QStringList tmpStrList;
873 int index1 = 0;
874 int index2 = 0;
875 if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) { 871 if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) {
876 s = fakeCString(vObjectUStringZValue(vo)); 872 s = fakeCString(vObjectUStringZValue(vo));
877 QString categories = QString::fromLocal8Bit(s); 873 QString categories = QString::fromLocal8Bit(s);
878 deleteStr(s); 874 deleteStr(s);
879 //const char* category; 875 QStringList tmpStrList = QStringList::split( ';', categories );
880 QString category;
881 while ((index2 = categories.find(',', index1)) != -1) {
882 //category = (const char *) categories.mid(index1, (index2 - index1));
883 category = categories.mid(index1, (index2 - index1));
884 tmpStrList.append(category);
885 index1 = index2+1;
886 }
887 // get last category
888 category = categories.mid(index1, (categories.length()-index1));
889 tmpStrList.append(category);
890 anEvent->setCategories(tmpStrList); 876 anEvent->setCategories(tmpStrList);
891 } 877 }
892 878
893 /* PILOT SYNC STUFF */ 879 /* PILOT SYNC STUFF */
894 if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) { 880 if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) {
895 anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 881 anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo))));
896 deleteStr(s); 882 deleteStr(s);
897 } 883 }
898 else 884 else
899 anEvent->setPilotId(0); 885 anEvent->setPilotId(0);
900 886
901 if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) { 887 if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) {
902 anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 888 anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo))));
903 deleteStr(s); 889 deleteStr(s);
904 } 890 }
905 else 891 else
906 anEvent->setSyncStatus(Event::SYNCMOD); 892 anEvent->setSyncStatus(Event::SYNCMOD);
907 893
908 return anEvent; 894 return anEvent;
909} 895}
910 896
911Event* VCalFormat::VEventToEvent(VObject *vevent) 897Event* VCalFormat::VEventToEvent(VObject *vevent)
912{ 898{
913 VObject *vo; 899 VObject *vo;
914 VObjectIterator voi; 900 VObjectIterator voi;
915 char *s; 901 char *s;
916 902
917 Event *anEvent = new Event; 903 Event *anEvent = new Event;
918 904
919 // creation date 905 // creation date
920 if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { 906 if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) {
921 anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 907 anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
922 deleteStr(s); 908 deleteStr(s);
923 } 909 }
924 910
925 // unique id 911 // unique id
926 vo = isAPropertyOf(vevent, VCUniqueStringProp); 912 vo = isAPropertyOf(vevent, VCUniqueStringProp);
927 // while the UID property is preferred, it is not required. We'll use the 913 // while the UID property is preferred, it is not required. We'll use the
928 // default Event UID if none is given. 914 // default Event UID if none is given.
929 if (vo) { 915 if (vo) {
930 anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); 916 anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo)));
931 deleteStr(s); 917 deleteStr(s);
932 } 918 }
933 919
934 // revision 920 // revision
935 // again NSCAL doesn't give us much to work with, so we improvise... 921 // again NSCAL doesn't give us much to work with, so we improvise...
936 if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { 922 if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) {
937 anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 923 anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo))));
938 deleteStr(s); 924 deleteStr(s);
939 } 925 }
940 else 926 else
941 anEvent->setRevision(0); 927 anEvent->setRevision(0);
942 928
943 // last modification date 929 // last modification date
944 if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { 930 if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) {
945 anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 931 anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
946 deleteStr(s); 932 deleteStr(s);
947 } 933 }
948 else 934 else
949 anEvent->setLastModified(QDateTime(QDate::currentDate(), 935 anEvent->setLastModified(QDateTime(QDate::currentDate(),
950 QTime::currentTime())); 936 QTime::currentTime()));
951 937
952 // organizer 938 // organizer
953 // if our extension property for the event's ORGANIZER exists, add it. 939 // if our extension property for the event's ORGANIZER exists, add it.
954 if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) { 940 if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) {
955 anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); 941 anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo)));
956 deleteStr(s); 942 deleteStr(s);
957 } else { 943 } else {
958 anEvent->setOrganizer(mCalendar->getEmail()); 944 anEvent->setOrganizer(mCalendar->getEmail());
959 } 945 }
960 946
961 // deal with attendees. 947 // deal with attendees.
962 initPropIterator(&voi, vevent); 948 initPropIterator(&voi, vevent);
963 while (moreIteration(&voi)) { 949 while (moreIteration(&voi)) {
964 vo = nextVObject(&voi); 950 vo = nextVObject(&voi);
965 if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { 951 if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) {
966 Attendee *a; 952 Attendee *a;
967 VObject *vp; 953 VObject *vp;
968 s = fakeCString(vObjectUStringZValue(vo)); 954 s = fakeCString(vObjectUStringZValue(vo));
969 QString tmpStr = QString::fromLocal8Bit(s); 955 QString tmpStr = QString::fromLocal8Bit(s);
970 deleteStr(s); 956 deleteStr(s);
971 tmpStr = tmpStr.simplifyWhiteSpace(); 957 tmpStr = tmpStr.simplifyWhiteSpace();
972 int emailPos1, emailPos2; 958 int emailPos1, emailPos2;
973 if ((emailPos1 = tmpStr.find('<')) > 0) { 959 if ((emailPos1 = tmpStr.find('<')) > 0) {
974 // both email address and name 960 // both email address and name
975 emailPos2 = tmpStr.findRev('>'); 961 emailPos2 = tmpStr.findRev('>');
976 a = new Attendee(tmpStr.left(emailPos1 - 1), 962 a = new Attendee(tmpStr.left(emailPos1 - 1),
977 tmpStr.mid(emailPos1 + 1, 963 tmpStr.mid(emailPos1 + 1,
978 emailPos2 - (emailPos1 + 1))); 964 emailPos2 - (emailPos1 + 1)));
979 } else if (tmpStr.find('@') > 0) { 965 } else if (tmpStr.find('@') > 0) {
980 // just an email address 966 // just an email address
981 a = new Attendee(0, tmpStr); 967 a = new Attendee(0, tmpStr);
982 } else { 968 } else {
983 // just a name 969 // just a name
984 //QString email = tmpStr.replace( QRegExp(" "), "." ); 970 //QString email = tmpStr.replace( QRegExp(" "), "." );
985 a = new Attendee(tmpStr,0); 971 a = new Attendee(tmpStr,0);
986 } 972 }
987 973
988 974
989 // is there a Role property? 975 // is there a Role property?
990 if ((vp = isAPropertyOf(vo, VCRoleProp)) != 0) 976 if ((vp = isAPropertyOf(vo, VCRoleProp)) != 0)
991 a->setRole(readRole(vObjectStringZValue(vp))); 977 a->setRole(readRole(vObjectStringZValue(vp)));
992 978
993 // is there an RSVP property? 979 // is there an RSVP property?
994 if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) 980 if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0)
995 a->setRSVP(vObjectStringZValue(vp)); 981 a->setRSVP(vObjectStringZValue(vp));
996 // is there a status property? 982 // is there a status property?
997 if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) 983 if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0)
998 a->setStatus(readStatus(vObjectStringZValue(vp))); 984 a->setStatus(readStatus(vObjectStringZValue(vp)));
999 // add the attendee 985 // add the attendee
1000 anEvent->addAttendee(a); 986 anEvent->addAttendee(a);
1001 } 987 }
1002 } 988 }
1003 989
1004 // This isn't strictly true. An event that doesn't have a start time 990 // This isn't strictly true. An event that doesn't have a start time
1005 // or an end time doesn't "float", it has an anchor in time but it doesn't 991 // or an end time doesn't "float", it has an anchor in time but it doesn't
1006 // "take up" any time. 992 // "take up" any time.
1007 /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) || 993 /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) ||
1008 (isAPropertyOf(vevent, VCDTendProp) == 0)) { 994 (isAPropertyOf(vevent, VCDTendProp) == 0)) {
1009 anEvent->setFloats(TRUE); 995 anEvent->setFloats(TRUE);
1010 } else { 996 } else {
1011 }*/ 997 }*/
1012 998
1013 anEvent->setFloats(FALSE); 999 anEvent->setFloats(FALSE);
1014 1000
1015 // start time 1001 // start time
1016 if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) { 1002 if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) {
1017 anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 1003 anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
1018 // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; 1004 // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl;
1019 deleteStr(s); 1005 deleteStr(s);
1020 if (anEvent->dtStart().time().isNull()) 1006 if (anEvent->dtStart().time().isNull())
1021 anEvent->setFloats(TRUE); 1007 anEvent->setFloats(TRUE);
1022 } 1008 }
1023 1009
1024 // stop time 1010 // stop time
1025 if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) { 1011 if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) {
1026 anEvent->setDtEnd(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 1012 anEvent->setDtEnd(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
1027 deleteStr(s); 1013 deleteStr(s);
1028 if (anEvent->dtEnd().time().isNull()) 1014 if (anEvent->dtEnd().time().isNull())
1029 anEvent->setFloats(TRUE); 1015 anEvent->setFloats(TRUE);
1030 } 1016 }
1031 1017
1032 // at this point, there should be at least a start or end time. 1018 // at this point, there should be at least a start or end time.
1033 // fix up for events that take up no time but have a time associated 1019 // fix up for events that take up no time but have a time associated
1034 if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) 1020 if (!(vo = isAPropertyOf(vevent, VCDTstartProp)))
1035 anEvent->setDtStart(anEvent->dtEnd()); 1021 anEvent->setDtStart(anEvent->dtEnd());
1036 if (!(vo = isAPropertyOf(vevent, VCDTendProp))) 1022 if (!(vo = isAPropertyOf(vevent, VCDTendProp)))
1037 anEvent->setDtEnd(anEvent->dtStart()); 1023 anEvent->setDtEnd(anEvent->dtStart());
1038 1024
1039 /////////////////////////////////////////////////////////////////////////// 1025 ///////////////////////////////////////////////////////////////////////////
1040 1026
1041 // repeat stuff 1027 // repeat stuff
1042 if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) { 1028 if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) {
1043 QString tmpStr = (s = fakeCString(vObjectUStringZValue(vo))); 1029 QString tmpStr = (s = fakeCString(vObjectUStringZValue(vo)));
1044 deleteStr(s); 1030 deleteStr(s);
1045 tmpStr.simplifyWhiteSpace(); 1031 tmpStr.simplifyWhiteSpace();
1046 tmpStr = tmpStr.upper(); 1032 tmpStr = tmpStr.upper();
1047 1033
1048 /********************************* DAILY ******************************/ 1034 /********************************* DAILY ******************************/
1049 if (tmpStr.left(1) == "D") { 1035 if (tmpStr.left(1) == "D") {
1050 int index = tmpStr.find(' '); 1036 int index = tmpStr.find(' ');
1051 int rFreq = tmpStr.mid(1, (index-1)).toInt(); 1037 int rFreq = tmpStr.mid(1, (index-1)).toInt();
1052 index = tmpStr.findRev(' ') + 1; // advance to last field 1038 index = tmpStr.findRev(' ') + 1; // advance to last field
1053 if (tmpStr.mid(index,1) == "#") index++; 1039 if (tmpStr.mid(index,1) == "#") index++;
1054 if (tmpStr.find('T', index) != -1) { 1040 if (tmpStr.find('T', index) != -1) {
1055 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); 1041 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
1056 anEvent->recurrence()->setDaily(rFreq, rEndDate); 1042 anEvent->recurrence()->setDaily(rFreq, rEndDate);
1057 } else { 1043 } else {
1058 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); 1044 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1059 if (rDuration == 0) // VEvents set this to 0 forever, we use -1 1045 if (rDuration == 0) // VEvents set this to 0 forever, we use -1
1060 anEvent->recurrence()->setDaily(rFreq, -1); 1046 anEvent->recurrence()->setDaily(rFreq, -1);
1061 else 1047 else
1062 anEvent->recurrence()->setDaily(rFreq, rDuration); 1048 anEvent->recurrence()->setDaily(rFreq, rDuration);
1063 } 1049 }
1064 } 1050 }
1065 /********************************* WEEKLY ******************************/ 1051 /********************************* WEEKLY ******************************/
1066 else if (tmpStr.left(1) == "W") { 1052 else if (tmpStr.left(1) == "W") {
1067 int index = tmpStr.find(' '); 1053 int index = tmpStr.find(' ');
1068 int last = tmpStr.findRev(' ') + 1; 1054 int last = tmpStr.findRev(' ') + 1;
1069 int rFreq = tmpStr.mid(1, (index-1)).toInt(); 1055 int rFreq = tmpStr.mid(1, (index-1)).toInt();
1070 index += 1; // advance to beginning of stuff after freq 1056 index += 1; // advance to beginning of stuff after freq
1071 QBitArray qba(7); 1057 QBitArray qba(7);
1072 QString dayStr; 1058 QString dayStr;
1073 if( index == last ) { 1059 if( index == last ) {
1074 // e.g. W1 #0 1060 // e.g. W1 #0
1075 qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); 1061 qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1);
1076 } 1062 }
1077 else { 1063 else {
1078 // e.g. W1 SU #0 1064 // e.g. W1 SU #0
1079 while (index < last) { 1065 while (index < last) {
1080 dayStr = tmpStr.mid(index, 3); 1066 dayStr = tmpStr.mid(index, 3);
1081 int dayNum = numFromDay(dayStr); 1067 int dayNum = numFromDay(dayStr);
@@ -1139,432 +1125,410 @@ Event* VCalFormat::VEventToEvent(VObject *vevent)
1139 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); 1125 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1140 if (rDuration == 0) 1126 if (rDuration == 0)
1141 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, -1); 1127 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, -1);
1142 else 1128 else
1143 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rDuration); 1129 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rDuration);
1144 } 1130 }
1145 } 1131 }
1146 1132
1147 /**************************** MONTHLY-BY-DAY ***************************/ 1133 /**************************** MONTHLY-BY-DAY ***************************/
1148 else if (tmpStr.left(2) == "MD") { 1134 else if (tmpStr.left(2) == "MD") {
1149 int index = tmpStr.find(' '); 1135 int index = tmpStr.find(' ');
1150 int last = tmpStr.findRev(' ') + 1; 1136 int last = tmpStr.findRev(' ') + 1;
1151 int rFreq = tmpStr.mid(2, (index-1)).toInt(); 1137 int rFreq = tmpStr.mid(2, (index-1)).toInt();
1152 index += 1; 1138 index += 1;
1153 short tmpDay; 1139 short tmpDay;
1154 if( index == last ) { 1140 if( index == last ) {
1155 // e.g. MD1 #0 1141 // e.g. MD1 #0
1156 tmpDay = anEvent->dtStart().date().day(); 1142 tmpDay = anEvent->dtStart().date().day();
1157 anEvent->recurrence()->addMonthlyDay(tmpDay); 1143 anEvent->recurrence()->addMonthlyDay(tmpDay);
1158 } 1144 }
1159 else { 1145 else {
1160 // e.g. MD1 3 #0 1146 // e.g. MD1 3 #0
1161 while (index < last) { 1147 while (index < last) {
1162 int index2 = tmpStr.find(' ', index); 1148 int index2 = tmpStr.find(' ', index);
1163 tmpDay = tmpStr.mid(index, (index2-index)).toShort(); 1149 tmpDay = tmpStr.mid(index, (index2-index)).toShort();
1164 index = index2-1; 1150 index = index2-1;
1165 if (tmpStr.mid(index, 1) == "-") 1151 if (tmpStr.mid(index, 1) == "-")
1166 tmpDay = 0 - tmpDay; 1152 tmpDay = 0 - tmpDay;
1167 index += 2; // advance the index; 1153 index += 2; // advance the index;
1168 anEvent->recurrence()->addMonthlyDay(tmpDay); 1154 anEvent->recurrence()->addMonthlyDay(tmpDay);
1169 } // while != # 1155 } // while != #
1170 } 1156 }
1171 index = last; if (tmpStr.mid(index,1) == "#") index++; 1157 index = last; if (tmpStr.mid(index,1) == "#") index++;
1172 if (tmpStr.find('T', index) != -1) { 1158 if (tmpStr.find('T', index) != -1) {
1173 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); 1159 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
1174 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rEndDate); 1160 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rEndDate);
1175 } else { 1161 } else {
1176 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); 1162 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1177 if (rDuration == 0) 1163 if (rDuration == 0)
1178 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, -1); 1164 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, -1);
1179 else 1165 else
1180 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration); 1166 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration);
1181 } 1167 }
1182 } 1168 }
1183 1169
1184 /*********************** YEARLY-BY-MONTH *******************************/ 1170 /*********************** YEARLY-BY-MONTH *******************************/
1185 else if (tmpStr.left(2) == "YM") { 1171 else if (tmpStr.left(2) == "YM") {
1186 // we have to set this such that recurrence accepts addYearlyNum(tmpDay); 1172 // we have to set this such that recurrence accepts addYearlyNum(tmpDay);
1187 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, 1, -1); 1173 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, 1, -1);
1188 int index = tmpStr.find(' '); 1174 int index = tmpStr.find(' ');
1189 int last = tmpStr.findRev(' ') + 1; 1175 int last = tmpStr.findRev(' ') + 1;
1190 int rFreq = tmpStr.mid(2, (index-1)).toInt(); 1176 int rFreq = tmpStr.mid(2, (index-1)).toInt();
1191 index += 1; 1177 index += 1;
1192 short tmpMonth; 1178 short tmpMonth;
1193 if( index == last ) { 1179 if( index == last ) {
1194 // e.g. YM1 #0 1180 // e.g. YM1 #0
1195 tmpMonth = anEvent->dtStart().date().month(); 1181 tmpMonth = anEvent->dtStart().date().month();
1196 anEvent->recurrence()->addYearlyNum(tmpMonth); 1182 anEvent->recurrence()->addYearlyNum(tmpMonth);
1197 } 1183 }
1198 else { 1184 else {
1199 // e.g. YM1 3 #0 1185 // e.g. YM1 3 #0
1200 while (index < last) { 1186 while (index < last) {
1201 int index2 = tmpStr.find(' ', index); 1187 int index2 = tmpStr.find(' ', index);
1202 tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); 1188 tmpMonth = tmpStr.mid(index, (index2-index)).toShort();
1203 index = index2+1; 1189 index = index2+1;
1204 anEvent->recurrence()->addYearlyNum(tmpMonth); 1190 anEvent->recurrence()->addYearlyNum(tmpMonth);
1205 } // while != # 1191 } // while != #
1206 } 1192 }
1207 index = last; if (tmpStr.mid(index,1) == "#") index++; 1193 index = last; if (tmpStr.mid(index,1) == "#") index++;
1208 if (tmpStr.find('T', index) != -1) { 1194 if (tmpStr.find('T', index) != -1) {
1209 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); 1195 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
1210 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); 1196 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate);
1211 } else { 1197 } else {
1212 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); 1198 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1213 if (rDuration == 0) 1199 if (rDuration == 0)
1214 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); 1200 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1);
1215 else 1201 else
1216 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); 1202 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration);
1217 } 1203 }
1218 } 1204 }
1219 1205
1220 /*********************** YEARLY-BY-DAY *********************************/ 1206 /*********************** YEARLY-BY-DAY *********************************/
1221 else if (tmpStr.left(2) == "YD") { 1207 else if (tmpStr.left(2) == "YD") {
1222 // we have to set this such that recurrence accepts addYearlyNum(tmpDay); 1208 // we have to set this such that recurrence accepts addYearlyNum(tmpDay);
1223 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, 1, -1); 1209 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, 1, -1);
1224 int index = tmpStr.find(' '); 1210 int index = tmpStr.find(' ');
1225 int last = tmpStr.findRev(' ') + 1; 1211 int last = tmpStr.findRev(' ') + 1;
1226 int rFreq = tmpStr.mid(2, (index-1)).toInt(); 1212 int rFreq = tmpStr.mid(2, (index-1)).toInt();
1227 index += 1; 1213 index += 1;
1228 short tmpDay; 1214 short tmpDay;
1229 if( index == last ) { 1215 if( index == last ) {
1230 // e.g. YD1 #0 1216 // e.g. YD1 #0
1231 tmpDay = anEvent->dtStart().date().dayOfYear(); 1217 tmpDay = anEvent->dtStart().date().dayOfYear();
1232 anEvent->recurrence()->addYearlyNum(tmpDay); 1218 anEvent->recurrence()->addYearlyNum(tmpDay);
1233 } 1219 }
1234 else { 1220 else {
1235 // e.g. YD1 123 #0 1221 // e.g. YD1 123 #0
1236 while (index < last) { 1222 while (index < last) {
1237 int index2 = tmpStr.find(' ', index); 1223 int index2 = tmpStr.find(' ', index);
1238 tmpDay = tmpStr.mid(index, (index2-index)).toShort(); 1224 tmpDay = tmpStr.mid(index, (index2-index)).toShort();
1239 index = index2+1; 1225 index = index2+1;
1240 anEvent->recurrence()->addYearlyNum(tmpDay); 1226 anEvent->recurrence()->addYearlyNum(tmpDay);
1241 } // while != # 1227 } // while != #
1242 } 1228 }
1243 index = last; if (tmpStr.mid(index,1) == "#") index++; 1229 index = last; if (tmpStr.mid(index,1) == "#") index++;
1244 if (tmpStr.find('T', index) != -1) { 1230 if (tmpStr.find('T', index) != -1) {
1245 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); 1231 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
1246 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); 1232 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate);
1247 } else { 1233 } else {
1248 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); 1234 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1249 if (rDuration == 0) 1235 if (rDuration == 0)
1250 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); 1236 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1);
1251 else 1237 else
1252 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); 1238 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration);
1253 } 1239 }
1254 } else { 1240 } else {
1255 kdDebug(5800) << "we don't understand this type of recurrence!" << endl; 1241 kdDebug(5800) << "we don't understand this type of recurrence!" << endl;
1256 } // if 1242 } // if
1257 } // repeats 1243 } // repeats
1258 1244
1259 1245
1260 // recurrence exceptions 1246 // recurrence exceptions
1261 if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) { 1247 if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) {
1262 s = fakeCString(vObjectUStringZValue(vo)); 1248 s = fakeCString(vObjectUStringZValue(vo));
1263 QStringList exDates = QStringList::split(",",s); 1249 QStringList exDates = QStringList::split(",",s);
1264 QStringList::ConstIterator it; 1250 QStringList::ConstIterator it;
1265 for(it = exDates.begin(); it != exDates.end(); ++it ) { 1251 for(it = exDates.begin(); it != exDates.end(); ++it ) {
1266 anEvent->addExDate(ISOToQDate(*it)); 1252 anEvent->addExDate(ISOToQDate(*it));
1267 } 1253 }
1268 deleteStr(s); 1254 deleteStr(s);
1269 } 1255 }
1270 1256
1271 // summary 1257 // summary
1272 if ((vo = isAPropertyOf(vevent, VCSummaryProp))) { 1258 if ((vo = isAPropertyOf(vevent, VCSummaryProp))) {
1273 s = fakeCString(vObjectUStringZValue(vo)); 1259 s = fakeCString(vObjectUStringZValue(vo));
1274 anEvent->setSummary(QString::fromLocal8Bit(s)); 1260 anEvent->setSummary(QString::fromLocal8Bit(s));
1275 deleteStr(s); 1261 deleteStr(s);
1276 } 1262 }
1277 if ((vo = isAPropertyOf(vevent, VCLocationProp))) { 1263 if ((vo = isAPropertyOf(vevent, VCLocationProp))) {
1278 s = fakeCString(vObjectUStringZValue(vo)); 1264 s = fakeCString(vObjectUStringZValue(vo));
1279 anEvent->setLocation(QString::fromLocal8Bit(s)); 1265 anEvent->setLocation(QString::fromLocal8Bit(s));
1280 deleteStr(s); 1266 deleteStr(s);
1281 } 1267 }
1282 1268
1283 // description 1269 // description
1284 if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) { 1270 if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) {
1285 s = fakeCString(vObjectUStringZValue(vo)); 1271 s = fakeCString(vObjectUStringZValue(vo));
1286 if (!anEvent->description().isEmpty()) { 1272 if (!anEvent->description().isEmpty()) {
1287 anEvent->setDescription(anEvent->description() + "\n" + 1273 anEvent->setDescription(anEvent->description() + "\n" +
1288 QString::fromLocal8Bit(s)); 1274 QString::fromLocal8Bit(s));
1289 } else { 1275 } else {
1290 anEvent->setDescription(QString::fromLocal8Bit(s)); 1276 anEvent->setDescription(QString::fromLocal8Bit(s));
1291 } 1277 }
1292 deleteStr(s); 1278 deleteStr(s);
1293 } 1279 }
1294 1280
1295 // some stupid vCal exporters ignore the standard and use Description 1281 // some stupid vCal exporters ignore the standard and use Description
1296 // instead of Summary for the default field. Correct for this. 1282 // instead of Summary for the default field. Correct for this.
1297 if (anEvent->summary().isEmpty() && 1283 if (anEvent->summary().isEmpty() &&
1298 !(anEvent->description().isEmpty())) { 1284 !(anEvent->description().isEmpty())) {
1299 QString tmpStr = anEvent->description().simplifyWhiteSpace(); 1285 QString tmpStr = anEvent->description().simplifyWhiteSpace();
1300 anEvent->setDescription(""); 1286 anEvent->setDescription("");
1301 anEvent->setSummary(tmpStr); 1287 anEvent->setSummary(tmpStr);
1302 } 1288 }
1303 1289
1304#if 0 1290#if 0
1305 // status 1291 // status
1306 if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) { 1292 if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) {
1307 QString tmpStr(s = fakeCString(vObjectUStringZValue(vo))); 1293 QString tmpStr(s = fakeCString(vObjectUStringZValue(vo)));
1308 deleteStr(s); 1294 deleteStr(s);
1309// TODO: Define Event status 1295// TODO: Define Event status
1310// anEvent->setStatus(tmpStr); 1296// anEvent->setStatus(tmpStr);
1311 } 1297 }
1312 else 1298 else
1313// anEvent->setStatus("NEEDS ACTION"); 1299// anEvent->setStatus("NEEDS ACTION");
1314#endif 1300#endif
1315 1301
1316 // secrecy 1302 // secrecy
1317 int secrecy = Incidence::SecrecyPublic; 1303 int secrecy = Incidence::SecrecyPublic;
1318 if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { 1304 if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) {
1319 s = fakeCString(vObjectUStringZValue(vo)); 1305 s = fakeCString(vObjectUStringZValue(vo));
1320 if (strcmp(s,"PRIVATE") == 0) { 1306 if (strcmp(s,"PRIVATE") == 0) {
1321 secrecy = Incidence::SecrecyPrivate; 1307 secrecy = Incidence::SecrecyPrivate;
1322 } else if (strcmp(s,"CONFIDENTIAL") == 0) { 1308 } else if (strcmp(s,"CONFIDENTIAL") == 0) {
1323 secrecy = Incidence::SecrecyConfidential; 1309 secrecy = Incidence::SecrecyConfidential;
1324 } 1310 }
1325 deleteStr(s); 1311 deleteStr(s);
1326 } 1312 }
1327 anEvent->setSecrecy(secrecy); 1313 anEvent->setSecrecy(secrecy);
1328 1314
1329 // categories 1315 // categories
1330 QStringList tmpStrList; 1316 QStringList tmpStrList;
1331 int index1 = 0;
1332 int index2 = 0;
1333 if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) { 1317 if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) {
1334 s = fakeCString(vObjectUStringZValue(vo)); 1318 s = fakeCString(vObjectUStringZValue(vo));
1335 QString categories = QString::fromLocal8Bit(s); 1319 QString categories = QString::fromLocal8Bit(s);
1336 deleteStr(s); 1320 deleteStr(s);
1337 //const char* category; 1321 tmpStrList = QStringList::split( ';', categories );
1338 QString category;
1339 while ((index2 = categories.find(',', index1)) != -1) {
1340 //category = (const char *) categories.mid(index1, (index2 - index1));
1341 category = categories.mid(index1, (index2 - index1));
1342 tmpStrList.append(category);
1343 index1 = index2+1;
1344 }
1345 // get last category
1346 category = categories.mid(index1, (categories.length()-index1));
1347 tmpStrList.append(category);
1348 anEvent->setCategories(tmpStrList); 1322 anEvent->setCategories(tmpStrList);
1349 } 1323 }
1350 1324
1351 // attachments 1325 // attachments
1352 tmpStrList.clear();
1353 initPropIterator(&voi, vevent); 1326 initPropIterator(&voi, vevent);
1354 while (moreIteration(&voi)) { 1327 while (moreIteration(&voi)) {
1355 vo = nextVObject(&voi); 1328 vo = nextVObject(&voi);
1356 if (strcmp(vObjectName(vo), VCAttachProp) == 0) { 1329 if (strcmp(vObjectName(vo), VCAttachProp) == 0) {
1357 s = fakeCString(vObjectUStringZValue(vo)); 1330 s = fakeCString(vObjectUStringZValue(vo));
1358 anEvent->addAttachment(new Attachment(QString(s))); 1331 anEvent->addAttachment(new Attachment(QString(s)));
1359 deleteStr(s); 1332 deleteStr(s);
1360 } 1333 }
1361 } 1334 }
1362 1335
1363 // resources 1336 // resources
1364 if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { 1337 if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) {
1365 QString resources = (s = fakeCString(vObjectUStringZValue(vo))); 1338 QString resources = (s = fakeCString(vObjectUStringZValue(vo)));
1366 deleteStr(s); 1339 deleteStr(s);
1367 tmpStrList.clear(); 1340 tmpStrList = QStringList::split( ';', resources );
1368 index1 = 0;
1369 index2 = 0;
1370 QString resource;
1371 while ((index2 = resources.find(';', index1)) != -1) {
1372 resource = resources.mid(index1, (index2 - index1));
1373 tmpStrList.append(resource);
1374 index1 = index2;
1375 }
1376 anEvent->setResources(tmpStrList); 1341 anEvent->setResources(tmpStrList);
1377 } 1342 }
1378
1379 /* alarm stuff */ 1343 /* alarm stuff */
1380 if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) { 1344 if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) {
1381 Alarm* alarm = anEvent->newAlarm(); 1345 Alarm* alarm = anEvent->newAlarm();
1382 VObject *a; 1346 VObject *a;
1383 if ((a = isAPropertyOf(vo, VCRunTimeProp))) { 1347 if ((a = isAPropertyOf(vo, VCRunTimeProp))) {
1384 alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); 1348 alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a))));
1385 deleteStr(s); 1349 deleteStr(s);
1386 } 1350 }
1387 alarm->setEnabled(true); 1351 alarm->setEnabled(true);
1388 if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) { 1352 if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) {
1389 if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { 1353 if ((a = isAPropertyOf(vo, VCProcedureNameProp))) {
1390 s = fakeCString(vObjectUStringZValue(a)); 1354 s = fakeCString(vObjectUStringZValue(a));
1391 alarm->setProcedureAlarm(QFile::decodeName(s)); 1355 alarm->setProcedureAlarm(QFile::decodeName(s));
1392 deleteStr(s); 1356 deleteStr(s);
1393 } 1357 }
1394 } 1358 }
1395 if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { 1359 if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) {
1396 if ((a = isAPropertyOf(vo, VCAudioContentProp))) { 1360 if ((a = isAPropertyOf(vo, VCAudioContentProp))) {
1397 s = fakeCString(vObjectUStringZValue(a)); 1361 s = fakeCString(vObjectUStringZValue(a));
1398 alarm->setAudioAlarm(QFile::decodeName(s)); 1362 alarm->setAudioAlarm(QFile::decodeName(s));
1399 deleteStr(s); 1363 deleteStr(s);
1400 } 1364 }
1401 } 1365 }
1402 } 1366 }
1403 1367
1404 // priority 1368 // priority
1405 if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { 1369 if ((vo = isAPropertyOf(vevent, VCPriorityProp))) {
1406 anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 1370 anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo))));
1407 deleteStr(s); 1371 deleteStr(s);
1408 } 1372 }
1409 1373
1410 // transparency 1374 // transparency
1411 if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { 1375 if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) {
1412 int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); 1376 int i = atoi(s = fakeCString(vObjectUStringZValue(vo)));
1413 anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); 1377 anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque );
1414 deleteStr(s); 1378 deleteStr(s);
1415 } 1379 }
1416 1380
1417 // related event 1381 // related event
1418 if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { 1382 if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) {
1419 anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); 1383 anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo)));
1420 deleteStr(s); 1384 deleteStr(s);
1421 mEventsRelate.append(anEvent); 1385 mEventsRelate.append(anEvent);
1422 } 1386 }
1423 1387
1424 /* PILOT SYNC STUFF */ 1388 /* PILOT SYNC STUFF */
1425 if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { 1389 if ((vo = isAPropertyOf(vevent, XPilotIdProp))) {
1426 anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 1390 anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo))));
1427 deleteStr(s); 1391 deleteStr(s);
1428 } 1392 }
1429 else 1393 else
1430 anEvent->setPilotId(0); 1394 anEvent->setPilotId(0);
1431 1395
1432 if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { 1396 if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) {
1433 anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 1397 anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo))));
1434 deleteStr(s); 1398 deleteStr(s);
1435 } 1399 }
1436 else 1400 else
1437 anEvent->setSyncStatus(Event::SYNCMOD); 1401 anEvent->setSyncStatus(Event::SYNCMOD);
1438 1402
1439 return anEvent; 1403 return anEvent;
1440} 1404}
1441 1405
1442 1406
1443QString VCalFormat::qDateToISO(const QDate &qd) 1407QString VCalFormat::qDateToISO(const QDate &qd)
1444{ 1408{
1445 QString tmpStr; 1409 QString tmpStr;
1446 1410
1447 ASSERT(qd.isValid()); 1411 ASSERT(qd.isValid());
1448 1412
1449 tmpStr.sprintf("%.2d%.2d%.2d", 1413 tmpStr.sprintf("%.2d%.2d%.2d",
1450 qd.year(), qd.month(), qd.day()); 1414 qd.year(), qd.month(), qd.day());
1451 return tmpStr; 1415 return tmpStr;
1452 1416
1453} 1417}
1454 1418
1455QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) 1419QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu)
1456{ 1420{
1457 QString tmpStr; 1421 QString tmpStr;
1458 1422
1459 ASSERT(qdt.date().isValid()); 1423 ASSERT(qdt.date().isValid());
1460 ASSERT(qdt.time().isValid()); 1424 ASSERT(qdt.time().isValid());
1461 if (zulu && !useLocalTime ) { 1425 if (zulu && !useLocalTime ) {
1462 QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); 1426 QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60);
1463 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", 1427 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ",
1464 tmpDT.date().year(), tmpDT.date().month(), 1428 tmpDT.date().year(), tmpDT.date().month(),
1465 tmpDT.date().day(), tmpDT.time().hour(), 1429 tmpDT.date().day(), tmpDT.time().hour(),
1466 tmpDT.time().minute(), tmpDT.time().second()); 1430 tmpDT.time().minute(), tmpDT.time().second());
1467 } else { 1431 } else {
1468 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", 1432 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d",
1469 qdt.date().year(), qdt.date().month(), 1433 qdt.date().year(), qdt.date().month(),
1470 qdt.date().day(), qdt.time().hour(), 1434 qdt.date().day(), qdt.time().hour(),
1471 qdt.time().minute(), qdt.time().second()); 1435 qdt.time().minute(), qdt.time().second());
1472 } 1436 }
1473 return tmpStr; 1437 return tmpStr;
1474} 1438}
1475 1439
1476QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) 1440QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr)
1477{ 1441{
1478 QDate tmpDate; 1442 QDate tmpDate;
1479 QTime tmpTime; 1443 QTime tmpTime;
1480 QString tmpStr; 1444 QString tmpStr;
1481 int year, month, day, hour, minute, second; 1445 int year, month, day, hour, minute, second;
1482 1446
1483 tmpStr = dtStr; 1447 tmpStr = dtStr;
1484 year = tmpStr.left(4).toInt(); 1448 year = tmpStr.left(4).toInt();
1485 month = tmpStr.mid(4,2).toInt(); 1449 month = tmpStr.mid(4,2).toInt();
1486 day = tmpStr.mid(6,2).toInt(); 1450 day = tmpStr.mid(6,2).toInt();
1487 hour = tmpStr.mid(9,2).toInt(); 1451 hour = tmpStr.mid(9,2).toInt();
1488 minute = tmpStr.mid(11,2).toInt(); 1452 minute = tmpStr.mid(11,2).toInt();
1489 second = tmpStr.mid(13,2).toInt(); 1453 second = tmpStr.mid(13,2).toInt();
1490 tmpDate.setYMD(year, month, day); 1454 tmpDate.setYMD(year, month, day);
1491 tmpTime.setHMS(hour, minute, second); 1455 tmpTime.setHMS(hour, minute, second);
1492 1456
1493 ASSERT(tmpDate.isValid()); 1457 ASSERT(tmpDate.isValid());
1494 ASSERT(tmpTime.isValid()); 1458 ASSERT(tmpTime.isValid());
1495 QDateTime tmpDT(tmpDate, tmpTime); 1459 QDateTime tmpDT(tmpDate, tmpTime);
1496 // correct for GMT if string is in Zulu format 1460 // correct for GMT if string is in Zulu format
1497 if (dtStr.at(dtStr.length()-1) == 'Z') 1461 if (dtStr.at(dtStr.length()-1) == 'Z')
1498 tmpDT = tmpDT.addSecs (KGlobal::locale()->localTimeOffset( tmpDT )*60); 1462 tmpDT = tmpDT.addSecs (KGlobal::locale()->localTimeOffset( tmpDT )*60);
1499 return tmpDT; 1463 return tmpDT;
1500} 1464}
1501 1465
1502QDate VCalFormat::ISOToQDate(const QString &dateStr) 1466QDate VCalFormat::ISOToQDate(const QString &dateStr)
1503{ 1467{
1504 int year, month, day; 1468 int year, month, day;
1505 1469
1506 year = dateStr.left(4).toInt(); 1470 year = dateStr.left(4).toInt();
1507 month = dateStr.mid(4,2).toInt(); 1471 month = dateStr.mid(4,2).toInt();
1508 day = dateStr.mid(6,2).toInt(); 1472 day = dateStr.mid(6,2).toInt();
1509 1473
1510 return(QDate(year, month, day)); 1474 return(QDate(year, month, day));
1511} 1475}
1512 1476
1513// take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. 1477// take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc.
1514// and break it down from it's tree-like format into the dictionary format 1478// and break it down from it's tree-like format into the dictionary format
1515// that is used internally in the VCalFormat. 1479// that is used internally in the VCalFormat.
1516void VCalFormat::populate(VObject *vcal) 1480void VCalFormat::populate(VObject *vcal)
1517{ 1481{
1518 // this function will populate the caldict dictionary and other event 1482 // this function will populate the caldict dictionary and other event
1519 // lists. It turns vevents into Events and then inserts them. 1483 // lists. It turns vevents into Events and then inserts them.
1520 1484
1521 VObjectIterator i; 1485 VObjectIterator i;
1522 VObject *curVO, *curVOProp; 1486 VObject *curVO, *curVOProp;
1523 Event *anEvent; 1487 Event *anEvent;
1524 1488
1525 if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { 1489 if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) {
1526 char *methodType = 0; 1490 char *methodType = 0;
1527 methodType = fakeCString(vObjectUStringZValue(curVO)); 1491 methodType = fakeCString(vObjectUStringZValue(curVO));
1528 kdDebug() << "This calendar is an iTIP transaction of type '" 1492 kdDebug() << "This calendar is an iTIP transaction of type '"
1529 << methodType << "'" << endl; 1493 << methodType << "'" << endl;
1530 delete methodType; 1494 delete methodType;
1531 } 1495 }
1532 1496
1533 // warn the user that we might have trouble reading non-known calendar. 1497 // warn the user that we might have trouble reading non-known calendar.
1534 if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { 1498 if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) {
1535 char *s = fakeCString(vObjectUStringZValue(curVO)); 1499 char *s = fakeCString(vObjectUStringZValue(curVO));
1536 if (strcmp(productId().local8Bit(), s) != 0) 1500 if (strcmp(productId().local8Bit(), s) != 0)
1537 kdDebug() << "This vCalendar file was not created by KOrganizer " 1501 kdDebug() << "This vCalendar file was not created by KOrganizer "
1538 "or any other product we support. Loading anyway..." << endl; 1502 "or any other product we support. Loading anyway..." << endl;
1539 mLoadedProductId = s; 1503 mLoadedProductId = s;
1540 deleteStr(s); 1504 deleteStr(s);
1541 } 1505 }
1542 1506
1543 // warn the user we might have trouble reading this unknown version. 1507 // warn the user we might have trouble reading this unknown version.
1544 if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { 1508 if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) {
1545 char *s = fakeCString(vObjectUStringZValue(curVO)); 1509 char *s = fakeCString(vObjectUStringZValue(curVO));
1546 if (strcmp(_VCAL_VERSION, s) != 0) 1510 if (strcmp(_VCAL_VERSION, s) != 0)
1547 kdDebug() << "This vCalendar file has version " << s 1511 kdDebug() << "This vCalendar file has version " << s
1548 << "We only support " << _VCAL_VERSION << endl; 1512 << "We only support " << _VCAL_VERSION << endl;
1549 deleteStr(s); 1513 deleteStr(s);
1550 } 1514 }
1551 1515
1552 // set the time zone 1516 // set the time zone
1553 if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { 1517 if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) {
1554 if ( vObjectUStringZValue(curVO) != 0 ) { 1518 if ( vObjectUStringZValue(curVO) != 0 ) {
1555 char *s = fakeCString(vObjectUStringZValue(curVO)); 1519 char *s = fakeCString(vObjectUStringZValue(curVO));
1556 mCalendar->setTimeZone(s); 1520 mCalendar->setTimeZone(s);
1557 deleteStr(s); 1521 deleteStr(s);
1558 } 1522 }
1559 } 1523 }
1560 1524
1561 // Store all events with a relatedTo property in a list for post-processing 1525 // Store all events with a relatedTo property in a list for post-processing
1562 mEventsRelate.clear(); 1526 mEventsRelate.clear();
1563 mTodosRelate.clear(); 1527 mTodosRelate.clear();
1564 1528
1565 initPropIterator(&i, vcal); 1529 initPropIterator(&i, vcal);
1566 1530
1567 // go through all the vobjects in the vcal 1531 // go through all the vobjects in the vcal
1568 while (moreIteration(&i)) { 1532 while (moreIteration(&i)) {
1569 curVO = nextVObject(&i); 1533 curVO = nextVObject(&i);
1570 1534