author | zautrix <zautrix> | 2005-03-16 23:10:29 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-16 23:10:29 (UTC) |
commit | d2be5ea1cd22f5222aecb0f70a2fe8657fae9698 (patch) (unidiff) | |
tree | 5de4c2b05428d837e2451df06b3ea313bd02c1b8 | |
parent | b7184073d5e552e0f04b14c5fc0c20a7bfd26d3d (diff) | |
download | kdepimpi-d2be5ea1cd22f5222aecb0f70a2fe8657fae9698.zip kdepimpi-d2be5ea1cd22f5222aecb0f70a2fe8657fae9698.tar.gz kdepimpi-d2be5ea1cd22f5222aecb0f70a2fe8657fae9698.tar.bz2 |
fixes
-rw-r--r-- | bin/kdepim/WhatsNew.txt | 3 | ||||
-rw-r--r-- | libkcal/vcalformat.cpp | 50 |
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,136 +1,139 @@ | |||
1 | Info about the changes in new versions of KDE-Pim/Pi | 1 | Info about the changes in new versions of KDE-Pim/Pi |
2 | 2 | ||
3 | ********** VERSION 2.0.17 ************ | 3 | ********** VERSION 2.0.17 ************ |
4 | 4 | ||
5 | KO/Pi: | 5 | KO/Pi: |
6 | Tooltips in month view were not sorted. Fixed. | 6 | Tooltips in month view were not sorted. Fixed. |
7 | Daylabel in agenda view ( for display of one day ) was too short. Fixed. | 7 | Daylabel in agenda view ( for display of one day ) was too short. Fixed. |
8 | Conflict display dialog for syncing was not on top of other windows. Fixed. | 8 | Conflict display dialog for syncing was not on top of other windows. Fixed. |
9 | Fixed some minor problems. | ||
10 | |||
11 | Fixed an endless loop when importing vcs file with RESOURCES entry. | ||
9 | 12 | ||
10 | ********** VERSION 2.0.16 ************ | 13 | ********** VERSION 2.0.16 ************ |
11 | OM/Pi: | 14 | OM/Pi: |
12 | Fixed the SMTP account setting the option. | 15 | Fixed the SMTP account setting the option. |
13 | Fixed something in mail sending. | 16 | Fixed something in mail sending. |
14 | 17 | ||
15 | KO/Pi: | 18 | KO/Pi: |
16 | Added possibility to export selected events/todos as vcal file. | 19 | Added possibility to export selected events/todos as vcal file. |
17 | 20 | ||
18 | ********** VERSION 2.0.15 ************ | 21 | ********** VERSION 2.0.15 ************ |
19 | 22 | ||
20 | PwM/Pi: | 23 | PwM/Pi: |
21 | Added keyboard shorcuts for | 24 | Added 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) |
25 | Fixed length of info in the title. | 28 | Fixed length of info in the title. |
26 | 29 | ||
27 | KO/Pi-KA/Pi: | 30 | KO/Pi-KA/Pi: |
28 | Changed "ME" menu bar entry to an icon. | 31 | Changed "ME" menu bar entry to an icon. |
29 | 32 | ||
30 | KO/Pi: | 33 | KO/Pi: |
31 | Fixed two minor bugs in displaying todos. | 34 | Fixed two minor bugs in displaying todos. |
32 | If in month view a cell is selected, the key shortcut "d" shows now that date. | 35 | If in month view a cell is selected, the key shortcut "d" shows now that date. |
33 | Added complete info for a todo in month view as an icon left of the text. | 36 | Added complete info for a todo in month view as an icon left of the text. |
34 | Fixed problems of displaying data when "<" or ">" are used in summary/location/description. | 37 | Fixed problems of displaying data when "<" or ">" are used in summary/location/description. |
35 | Fixed problem of search dialog size when switching displays. | 38 | Fixed problem of search dialog size when switching displays. |
36 | Cancel key now closes date picker. | 39 | Cancel key now closes date picker. |
37 | Rearranged KO/Pi file menu structure. | 40 | Rearranged KO/Pi file menu structure. |
38 | 41 | ||
39 | OM/Pi: | 42 | OM/Pi: |
40 | Added to the SMTP account setting the option | 43 | Added to the SMTP account setting the option |
41 | "No secure connection". | 44 | "No secure connection". |
42 | You have to configure your SMTP accounts again, sorry. | 45 | You have to configure your SMTP accounts again, sorry. |
43 | 46 | ||
44 | KA/Pi: | 47 | KA/Pi: |
45 | Added support for importing quoted-printable. | 48 | Added support for importing quoted-printable. |
46 | Support was added by Peter P.. Thanks, Peter! | 49 | Support was added by Peter P.. Thanks, Peter! |
47 | 50 | ||
48 | 51 | ||
49 | ********** VERSION 2.0.14 ************ | 52 | ********** VERSION 2.0.14 ************ |
50 | 53 | ||
51 | Made Passwordmanager PwM/Pi more userfriendly: | 54 | Made Passwordmanager PwM/Pi more userfriendly: |
52 | Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. | 55 | Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. |
53 | Fixed bug in KO/Pi todo printing. | 56 | Fixed bug in KO/Pi todo printing. |
54 | Made Qtopia calendar import possible on desktop . | 57 | Made Qtopia calendar import possible on desktop . |
55 | 58 | ||
56 | ********** VERSION 2.0.13 ************ | 59 | ********** VERSION 2.0.13 ************ |
57 | 60 | ||
58 | Fixed a problem in the addressee select dialog and made it more user friendly by adding a minimize splitter. | 61 | Fixed a problem in the addressee select dialog and made it more user friendly by adding a minimize splitter. |
59 | 62 | ||
60 | In the search dialog you can switch now the focus from search line edit to the list view by pressing key "arrow down". | 63 | In the search dialog you can switch now the focus from search line edit to the list view by pressing key "arrow down". |
61 | 64 | ||
62 | OM/Pi: | 65 | OM/Pi: |
63 | Fixed a refresh problem of outgoing/sent/sendfailed folders after sending mails. | 66 | Fixed a refresh problem of outgoing/sent/sendfailed folders after sending mails. |
64 | Added missing German translation. | 67 | Added missing German translation. |
65 | Added warning if path is specified in local folder settings of account config. | 68 | Added 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 | ||
69 | KO/Pi: | 72 | KO/Pi: |
70 | Fixed a bug in todo start/due date handling for non recurring todos with a start and due date. | 73 | Fixed a bug in todo start/due date handling for non recurring todos with a start and due date. |
71 | Fixed some layout problems in the KO/Pi agenda view when there were many conflicting itmes. | 74 | Fixed some layout problems in the KO/Pi agenda view when there were many conflicting itmes. |
72 | Fixed several problems of the keyboard focus in the desktop versions when opening the search dialog/event viewer. | 75 | Fixed several problems of the keyboard focus in the desktop versions when opening the search dialog/event viewer. |
73 | 76 | ||
74 | Fixed problem in pi-sync mode when wrong password was sent. | 77 | Fixed problem in pi-sync mode when wrong password was sent. |
75 | 78 | ||
76 | OM/Pi: | 79 | OM/Pi: |
77 | Fixed a crash when displaying mails with "Show mail as html" was checked in the config. | 80 | Fixed a crash when displaying mails with "Show mail as html" was checked in the config. |
78 | Added a check before displaying the mail if the mail is in html format, if "Show mail as html" is enabled. | 81 | Added 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 | ||
82 | Fixed some problems in pi-sync mode | 85 | Fixed 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 | ||
87 | KO/Pi: | 90 | KO/Pi: |
88 | In the desktop versions the context menu in the search dialog was broken after introducing the What'sThis info for the list view. | 91 | In the desktop versions the context menu in the search dialog was broken after introducing the What'sThis info for the list view. |
89 | This is fixed. | 92 | This is fixed. |
90 | Changed the search dialog a bit to make it more user friendly. | 93 | Changed 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 | ||
93 | Added config option to hide the week number in KO/Pi toolbar. | 96 | Added 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 | ||
97 | Made month view icons for multiday events a bit nicer. | 100 | Made month view icons for multiday events a bit nicer. |
98 | Some minor fixes in KO/Pi | 101 | Some 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 | ||
104 | Fixed a problem in dependency info in the ipk files for the Zaurus. | 107 | Fixed a problem in dependency info in the ipk files for the Zaurus. |
105 | 108 | ||
106 | Added 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. | 109 | Added 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 | ||
108 | Added a "go today" button to the datepicker. | 111 | Added a "go today" button to the datepicker. |
109 | 112 | ||
110 | Added "created" and "last modified" to event/todo viewer (and What'sThis viewer) | 113 | Added "created" and "last modified" to event/todo viewer (and What'sThis viewer) |
111 | and made it configureable to show these values. | 114 | and made it configureable to show these values. |
112 | 115 | ||
113 | Fixed a problem for events (from external iCal files) that do have a duration but no end date. | 116 | Fixed 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 | ||
118 | Added global application font settings | 121 | Added 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 | ||
121 | Fixed a problem in OM/Pi when trying to login to some IMAP servers | 124 | Fixed 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 | ||
124 | Added recurring todos to KO/Pi. | 127 | Added recurring todos to KO/Pi. |
125 | 128 | ||
126 | 129 | ||
127 | ********** VERSION 2.0.6 ************ | 130 | ********** VERSION 2.0.6 ************ |
128 | 131 | ||
129 | Some bugfixes in the pi-sync mode. | 132 | Some bugfixes in the pi-sync mode. |
130 | Added German translation for pi-sync mode. | 133 | Added German translation for pi-sync mode. |
131 | 134 | ||
132 | KO/Pi: | 135 | KO/Pi: |
133 | Made the todolist using alternate background. | 136 | Made the todolist using alternate background. |
134 | 137 | ||
135 | Other minor fixes in KO/Pi. | 138 | Other minor fixes in KO/Pi. |
136 | 139 | ||
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index 223aa5a..62a31ae 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp | |||
@@ -106,629 +106,628 @@ bool VCalFormat::save(Calendar *calendar, const QString &fileName) | |||
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 | ||
137 | bool VCalFormat::fromString( Calendar *calendar, const QString &text ) | 137 | bool 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 | ||
172 | QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) | 172 | QString 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 | } |
186 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) | 186 | QString 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 | ||
201 | QString VCalFormat::toString( Calendar *calendar ) | 201 | QString 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 | ||
230 | VObject *VCalFormat::eventToVTodo(const Todo *anEvent) | 230 | VObject *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 | ||
395 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) | 395 | VObject* 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 | ||
692 | Todo *VCalFormat::VTodoToEvent(VObject *vtodo) | 691 | Todo *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); |
@@ -744,274 +743,261 @@ Todo *VCalFormat::VTodoToEvent(VObject *vtodo) | |||
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 | ||
911 | Event* VCalFormat::VEventToEvent(VObject *vevent) | 897 | Event* 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)))); |
@@ -1203,304 +1189,282 @@ Event* VCalFormat::VEventToEvent(VObject *vevent) | |||
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 | ||
1443 | QString VCalFormat::qDateToISO(const QDate &qd) | 1407 | QString 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 | ||
1455 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) | 1419 | QString 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 | ||
1476 | QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) | 1440 | QDateTime 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 | ||
1502 | QDate VCalFormat::ISOToQDate(const QString &dateStr) | 1466 | QDate 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(); |