-rw-r--r-- | libkcal/calendar.cpp | 2 | ||||
-rw-r--r-- | libkcal/calformat.cpp | 20 | ||||
-rw-r--r-- | libkcal/icalformatimpl.cpp | 12 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 7 | ||||
-rw-r--r-- | libkcal/todo.cpp | 38 | ||||
-rw-r--r-- | libkcal/vcalformat.cpp | 16 |
6 files changed, 51 insertions, 44 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index dcfee5d..406cd48 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -1,297 +1,297 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <stdlib.h> | 22 | #include <stdlib.h> |
23 | #include <time.h> | 23 | #include <time.h> |
24 | 24 | ||
25 | #include <kdebug.h> | 25 | #include <kdebug.h> |
26 | #include <kglobal.h> | 26 | #include <kglobal.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | #include "exceptions.h" | 29 | #include "exceptions.h" |
30 | #include "calfilter.h" | 30 | #include "calfilter.h" |
31 | 31 | ||
32 | #include "calendar.h" | 32 | #include "calendar.h" |
33 | #include "syncdefines.h" | 33 | #include "syncdefines.h" |
34 | 34 | ||
35 | using namespace KCal; | 35 | using namespace KCal; |
36 | 36 | ||
37 | Calendar::Calendar() | 37 | Calendar::Calendar() |
38 | { | 38 | { |
39 | 39 | ||
40 | init(); | 40 | init(); |
41 | setTimeZoneId( i18n (" 00:00 Europe/London(UTC)") ); | 41 | setTimeZoneId( " 00:00 Europe/London(UTC)" ); |
42 | } | 42 | } |
43 | 43 | ||
44 | Calendar::Calendar( const QString &timeZoneId ) | 44 | Calendar::Calendar( const QString &timeZoneId ) |
45 | { | 45 | { |
46 | 46 | ||
47 | init(); | 47 | init(); |
48 | setTimeZoneId(timeZoneId); | 48 | setTimeZoneId(timeZoneId); |
49 | } | 49 | } |
50 | 50 | ||
51 | void Calendar::init() | 51 | void Calendar::init() |
52 | { | 52 | { |
53 | mObserver = 0; | 53 | mObserver = 0; |
54 | mNewObserver = false; | 54 | mNewObserver = false; |
55 | mUndoIncidence = 0; | 55 | mUndoIncidence = 0; |
56 | mModified = false; | 56 | mModified = false; |
57 | 57 | ||
58 | // Setup default filter, which does nothing | 58 | // Setup default filter, which does nothing |
59 | mDefaultFilter = new CalFilter; | 59 | mDefaultFilter = new CalFilter; |
60 | mFilter = mDefaultFilter; | 60 | mFilter = mDefaultFilter; |
61 | mFilter->setEnabled(false); | 61 | mFilter->setEnabled(false); |
62 | 62 | ||
63 | // initialize random numbers. This is a hack, and not | 63 | // initialize random numbers. This is a hack, and not |
64 | // even that good of one at that. | 64 | // even that good of one at that. |
65 | // srandom(time(0)); | 65 | // srandom(time(0)); |
66 | 66 | ||
67 | // user information... | 67 | // user information... |
68 | setOwner(i18n("Unknown Name")); | 68 | setOwner(i18n("Unknown Name")); |
69 | setEmail(i18n("unknown@nowhere")); | 69 | setEmail(i18n("unknown@nowhere")); |
70 | 70 | ||
71 | #if 0 | 71 | #if 0 |
72 | tmpStr = KOPrefs::instance()->mTimeZone; | 72 | tmpStr = KOPrefs::instance()->mTimeZone; |
73 | // kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; | 73 | // kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; |
74 | int dstSetting = KOPrefs::instance()->mDaylightSavings; | 74 | int dstSetting = KOPrefs::instance()->mDaylightSavings; |
75 | extern long int timezone; | 75 | extern long int timezone; |
76 | struct tm *now; | 76 | struct tm *now; |
77 | time_t curtime; | 77 | time_t curtime; |
78 | curtime = time(0); | 78 | curtime = time(0); |
79 | now = localtime(&curtime); | 79 | now = localtime(&curtime); |
80 | int hourOff = - ((timezone / 60) / 60); | 80 | int hourOff = - ((timezone / 60) / 60); |
81 | if (now->tm_isdst) | 81 | if (now->tm_isdst) |
82 | hourOff += 1; | 82 | hourOff += 1; |
83 | QString tzStr; | 83 | QString tzStr; |
84 | tzStr.sprintf("%.2d%.2d", | 84 | tzStr.sprintf("%.2d%.2d", |
85 | hourOff, | 85 | hourOff, |
86 | abs((timezone / 60) % 60)); | 86 | abs((timezone / 60) % 60)); |
87 | 87 | ||
88 | // if no time zone was in the config file, write what we just discovered. | 88 | // if no time zone was in the config file, write what we just discovered. |
89 | if (tmpStr.isEmpty()) { | 89 | if (tmpStr.isEmpty()) { |
90 | // KOPrefs::instance()->mTimeZone = tzStr; | 90 | // KOPrefs::instance()->mTimeZone = tzStr; |
91 | } else { | 91 | } else { |
92 | tzStr = tmpStr; | 92 | tzStr = tmpStr; |
93 | } | 93 | } |
94 | 94 | ||
95 | // if daylight savings has changed since last load time, we need | 95 | // if daylight savings has changed since last load time, we need |
96 | // to rewrite these settings to the config file. | 96 | // to rewrite these settings to the config file. |
97 | if ((now->tm_isdst && !dstSetting) || | 97 | if ((now->tm_isdst && !dstSetting) || |
98 | (!now->tm_isdst && dstSetting)) { | 98 | (!now->tm_isdst && dstSetting)) { |
99 | KOPrefs::instance()->mTimeZone = tzStr; | 99 | KOPrefs::instance()->mTimeZone = tzStr; |
100 | KOPrefs::instance()->mDaylightSavings = now->tm_isdst; | 100 | KOPrefs::instance()->mDaylightSavings = now->tm_isdst; |
101 | } | 101 | } |
102 | 102 | ||
103 | setTimeZone(tzStr); | 103 | setTimeZone(tzStr); |
104 | #endif | 104 | #endif |
105 | 105 | ||
106 | // KOPrefs::instance()->writeConfig(); | 106 | // KOPrefs::instance()->writeConfig(); |
107 | } | 107 | } |
108 | 108 | ||
109 | Calendar::~Calendar() | 109 | Calendar::~Calendar() |
110 | { | 110 | { |
111 | delete mDefaultFilter; | 111 | delete mDefaultFilter; |
112 | if ( mUndoIncidence ) | 112 | if ( mUndoIncidence ) |
113 | delete mUndoIncidence; | 113 | delete mUndoIncidence; |
114 | } | 114 | } |
115 | 115 | ||
116 | const QString &Calendar::getOwner() const | 116 | const QString &Calendar::getOwner() const |
117 | { | 117 | { |
118 | return mOwner; | 118 | return mOwner; |
119 | } | 119 | } |
120 | 120 | ||
121 | bool Calendar::undoDeleteIncidence() | 121 | bool Calendar::undoDeleteIncidence() |
122 | { | 122 | { |
123 | if (!mUndoIncidence) | 123 | if (!mUndoIncidence) |
124 | return false; | 124 | return false; |
125 | addIncidence(mUndoIncidence); | 125 | addIncidence(mUndoIncidence); |
126 | mUndoIncidence = 0; | 126 | mUndoIncidence = 0; |
127 | return true; | 127 | return true; |
128 | } | 128 | } |
129 | void Calendar::setOwner(const QString &os) | 129 | void Calendar::setOwner(const QString &os) |
130 | { | 130 | { |
131 | int i; | 131 | int i; |
132 | mOwner = os; | 132 | mOwner = os; |
133 | i = mOwner.find(','); | 133 | i = mOwner.find(','); |
134 | if (i != -1) | 134 | if (i != -1) |
135 | mOwner = mOwner.left(i); | 135 | mOwner = mOwner.left(i); |
136 | 136 | ||
137 | setModified( true ); | 137 | setModified( true ); |
138 | } | 138 | } |
139 | 139 | ||
140 | void Calendar::setTimeZone(const QString & tz) | 140 | void Calendar::setTimeZone(const QString & tz) |
141 | { | 141 | { |
142 | bool neg = FALSE; | 142 | bool neg = FALSE; |
143 | int hours, minutes; | 143 | int hours, minutes; |
144 | QString tmpStr(tz); | 144 | QString tmpStr(tz); |
145 | 145 | ||
146 | if (tmpStr.left(1) == "-") | 146 | if (tmpStr.left(1) == "-") |
147 | neg = TRUE; | 147 | neg = TRUE; |
148 | if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") | 148 | if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") |
149 | tmpStr.remove(0, 1); | 149 | tmpStr.remove(0, 1); |
150 | hours = tmpStr.left(2).toInt(); | 150 | hours = tmpStr.left(2).toInt(); |
151 | if (tmpStr.length() > 2) | 151 | if (tmpStr.length() > 2) |
152 | minutes = tmpStr.right(2).toInt(); | 152 | minutes = tmpStr.right(2).toInt(); |
153 | else | 153 | else |
154 | minutes = 0; | 154 | minutes = 0; |
155 | mTimeZone = (60*hours+minutes); | 155 | mTimeZone = (60*hours+minutes); |
156 | if (neg) | 156 | if (neg) |
157 | mTimeZone = -mTimeZone; | 157 | mTimeZone = -mTimeZone; |
158 | mLocalTime = false; | 158 | mLocalTime = false; |
159 | 159 | ||
160 | setModified( true ); | 160 | setModified( true ); |
161 | } | 161 | } |
162 | 162 | ||
163 | QString Calendar::getTimeZoneStr() const | 163 | QString Calendar::getTimeZoneStr() const |
164 | { | 164 | { |
165 | if (mLocalTime) | 165 | if (mLocalTime) |
166 | return ""; | 166 | return ""; |
167 | QString tmpStr; | 167 | QString tmpStr; |
168 | int hours = abs(mTimeZone / 60); | 168 | int hours = abs(mTimeZone / 60); |
169 | int minutes = abs(mTimeZone % 60); | 169 | int minutes = abs(mTimeZone % 60); |
170 | bool neg = mTimeZone < 0; | 170 | bool neg = mTimeZone < 0; |
171 | 171 | ||
172 | tmpStr.sprintf("%c%.2d%.2d", | 172 | tmpStr.sprintf("%c%.2d%.2d", |
173 | (neg ? '-' : '+'), | 173 | (neg ? '-' : '+'), |
174 | hours, minutes); | 174 | hours, minutes); |
175 | return tmpStr; | 175 | return tmpStr; |
176 | } | 176 | } |
177 | 177 | ||
178 | void Calendar::setTimeZone(int tz) | 178 | void Calendar::setTimeZone(int tz) |
179 | { | 179 | { |
180 | mTimeZone = tz; | 180 | mTimeZone = tz; |
181 | mLocalTime = false; | 181 | mLocalTime = false; |
182 | 182 | ||
183 | setModified( true ); | 183 | setModified( true ); |
184 | } | 184 | } |
185 | 185 | ||
186 | int Calendar::getTimeZone() const | 186 | int Calendar::getTimeZone() const |
187 | { | 187 | { |
188 | return mTimeZone; | 188 | return mTimeZone; |
189 | } | 189 | } |
190 | 190 | ||
191 | void Calendar::setTimeZoneId(const QString &id) | 191 | void Calendar::setTimeZoneId(const QString &id) |
192 | { | 192 | { |
193 | mTimeZoneId = id; | 193 | mTimeZoneId = id; |
194 | mLocalTime = false; | 194 | mLocalTime = false; |
195 | mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); | 195 | mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); |
196 | if ( mTimeZone > 1000) | 196 | if ( mTimeZone > 1000) |
197 | setLocalTime(); | 197 | setLocalTime(); |
198 | //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); | 198 | //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); |
199 | setModified( true ); | 199 | setModified( true ); |
200 | } | 200 | } |
201 | 201 | ||
202 | QString Calendar::timeZoneId() const | 202 | QString Calendar::timeZoneId() const |
203 | { | 203 | { |
204 | return mTimeZoneId; | 204 | return mTimeZoneId; |
205 | } | 205 | } |
206 | 206 | ||
207 | void Calendar::setLocalTime() | 207 | void Calendar::setLocalTime() |
208 | { | 208 | { |
209 | //qDebug("Calendar::setLocalTime() "); | 209 | //qDebug("Calendar::setLocalTime() "); |
210 | mLocalTime = true; | 210 | mLocalTime = true; |
211 | mTimeZone = 0; | 211 | mTimeZone = 0; |
212 | mTimeZoneId = ""; | 212 | mTimeZoneId = ""; |
213 | 213 | ||
214 | setModified( true ); | 214 | setModified( true ); |
215 | } | 215 | } |
216 | 216 | ||
217 | bool Calendar::isLocalTime() const | 217 | bool Calendar::isLocalTime() const |
218 | { | 218 | { |
219 | return mLocalTime; | 219 | return mLocalTime; |
220 | } | 220 | } |
221 | 221 | ||
222 | const QString &Calendar::getEmail() | 222 | const QString &Calendar::getEmail() |
223 | { | 223 | { |
224 | return mOwnerEmail; | 224 | return mOwnerEmail; |
225 | } | 225 | } |
226 | 226 | ||
227 | void Calendar::setEmail(const QString &e) | 227 | void Calendar::setEmail(const QString &e) |
228 | { | 228 | { |
229 | mOwnerEmail = e; | 229 | mOwnerEmail = e; |
230 | 230 | ||
231 | setModified( true ); | 231 | setModified( true ); |
232 | } | 232 | } |
233 | 233 | ||
234 | void Calendar::setFilter(CalFilter *filter) | 234 | void Calendar::setFilter(CalFilter *filter) |
235 | { | 235 | { |
236 | mFilter = filter; | 236 | mFilter = filter; |
237 | } | 237 | } |
238 | 238 | ||
239 | CalFilter *Calendar::filter() | 239 | CalFilter *Calendar::filter() |
240 | { | 240 | { |
241 | return mFilter; | 241 | return mFilter; |
242 | } | 242 | } |
243 | 243 | ||
244 | QPtrList<Incidence> Calendar::incidences() | 244 | QPtrList<Incidence> Calendar::incidences() |
245 | { | 245 | { |
246 | QPtrList<Incidence> incidences; | 246 | QPtrList<Incidence> incidences; |
247 | 247 | ||
248 | Incidence *i; | 248 | Incidence *i; |
249 | 249 | ||
250 | QPtrList<Event> e = events(); | 250 | QPtrList<Event> e = events(); |
251 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 251 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
252 | 252 | ||
253 | QPtrList<Todo> t = todos(); | 253 | QPtrList<Todo> t = todos(); |
254 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 254 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
255 | 255 | ||
256 | QPtrList<Journal> j = journals(); | 256 | QPtrList<Journal> j = journals(); |
257 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 257 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
258 | 258 | ||
259 | return incidences; | 259 | return incidences; |
260 | } | 260 | } |
261 | 261 | ||
262 | void Calendar::resetPilotStat(int id ) | 262 | void Calendar::resetPilotStat(int id ) |
263 | { | 263 | { |
264 | QPtrList<Incidence> incidences; | 264 | QPtrList<Incidence> incidences; |
265 | 265 | ||
266 | Incidence *i; | 266 | Incidence *i; |
267 | 267 | ||
268 | QPtrList<Event> e = rawEvents(); | 268 | QPtrList<Event> e = rawEvents(); |
269 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); | 269 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); |
270 | 270 | ||
271 | QPtrList<Todo> t = rawTodos(); | 271 | QPtrList<Todo> t = rawTodos(); |
272 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); | 272 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); |
273 | 273 | ||
274 | QPtrList<Journal> j = journals(); | 274 | QPtrList<Journal> j = journals(); |
275 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); | 275 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); |
276 | } | 276 | } |
277 | void Calendar::resetTempSyncStat() | 277 | void Calendar::resetTempSyncStat() |
278 | { | 278 | { |
279 | QPtrList<Incidence> incidences; | 279 | QPtrList<Incidence> incidences; |
280 | 280 | ||
281 | Incidence *i; | 281 | Incidence *i; |
282 | 282 | ||
283 | QPtrList<Event> e = rawEvents(); | 283 | QPtrList<Event> e = rawEvents(); |
284 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 284 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
285 | 285 | ||
286 | QPtrList<Todo> t = rawTodos(); | 286 | QPtrList<Todo> t = rawTodos(); |
287 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 287 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
288 | 288 | ||
289 | QPtrList<Journal> j = journals(); | 289 | QPtrList<Journal> j = journals(); |
290 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 290 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
291 | } | 291 | } |
292 | QPtrList<Incidence> Calendar::rawIncidences() | 292 | QPtrList<Incidence> Calendar::rawIncidences() |
293 | { | 293 | { |
294 | QPtrList<Incidence> incidences; | 294 | QPtrList<Incidence> incidences; |
295 | 295 | ||
296 | Incidence *i; | 296 | Incidence *i; |
297 | 297 | ||
diff --git a/libkcal/calformat.cpp b/libkcal/calformat.cpp index 8a3d069..359f65f 100644 --- a/libkcal/calformat.cpp +++ b/libkcal/calformat.cpp | |||
@@ -1,98 +1,94 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <klocale.h> | 21 | #include <klocale.h> |
22 | #include <kdebug.h> | 22 | #include <kdebug.h> |
23 | #include <kapplication.h> | 23 | #include <kapplication.h> |
24 | 24 | ||
25 | #include "calformat.h" | 25 | #include "calformat.h" |
26 | 26 | ||
27 | using namespace KCal; | 27 | using namespace KCal; |
28 | 28 | ||
29 | QString CalFormat::mApplication = QString::fromLatin1("libkcal"); | 29 | QString CalFormat::mApplication = QString::fromLatin1("libkcal-pi"); |
30 | QString CalFormat::mProductId = QString::fromLatin1("-//K Desktop Environment//NONSGML libkcal 3.1//EN"); | 30 | QString CalFormat::mProductId = QString::fromLatin1("-//KDE-Pim//Platform-independent 2.1.0"); |
31 | 31 | ||
32 | // An array containing the PRODID strings indexed against the calendar file format version used. | 32 | // An array containing the PRODID strings indexed against the calendar file format version used. |
33 | // Every time the calendar file format is changed, add an entry/entries to this list. | 33 | // Every time the calendar file format is changed, add an entry/entries to this list. |
34 | struct CalVersion { | 34 | struct CalVersion { |
35 | int version; | 35 | int version; |
36 | QString prodId; | 36 | QString prodId; |
37 | }; | 37 | }; |
38 | static CalVersion prodIds[] = { | 38 | static CalVersion prodIds[] = { |
39 | { 220, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 2.2//EN") }, | 39 | { 220, QString::fromLatin1("-//KDE-Pim//Pi 2.2//EN") }, |
40 | { 300, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 3.0//EN") }, | 40 | { 300, QString::fromLatin1("-//KDE-Pim//Pi 3.0//EN") }, |
41 | { 310, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 3.1//EN") }, | 41 | { 310, QString::fromLatin1("-//KDE-Pim//Pi 3.1//EN") }, |
42 | { 0 , QString() } | 42 | { 0 , QString() } |
43 | }; | 43 | }; |
44 | 44 | ||
45 | 45 | ||
46 | CalFormat::CalFormat() | 46 | CalFormat::CalFormat() |
47 | { | 47 | { |
48 | mException = 0; | 48 | mException = 0; |
49 | } | 49 | } |
50 | 50 | ||
51 | CalFormat::~CalFormat() | 51 | CalFormat::~CalFormat() |
52 | { | 52 | { |
53 | delete mException; | 53 | delete mException; |
54 | } | 54 | } |
55 | 55 | ||
56 | void CalFormat::clearException() | 56 | void CalFormat::clearException() |
57 | { | 57 | { |
58 | delete mException; | 58 | delete mException; |
59 | mException = 0; | 59 | mException = 0; |
60 | } | 60 | } |
61 | 61 | ||
62 | void CalFormat::setException(ErrorFormat *exception) | 62 | void CalFormat::setException(ErrorFormat *exception) |
63 | { | 63 | { |
64 | delete mException; | 64 | delete mException; |
65 | mException = exception; | 65 | mException = exception; |
66 | } | 66 | } |
67 | 67 | ||
68 | ErrorFormat *CalFormat::exception() | 68 | ErrorFormat *CalFormat::exception() |
69 | { | 69 | { |
70 | return mException; | 70 | return mException; |
71 | } | 71 | } |
72 | 72 | ||
73 | void CalFormat::setApplication(const QString& application, const QString& productID) | 73 | void CalFormat::setApplication(const QString& application, const QString& productID) |
74 | { | 74 | { |
75 | mApplication = application; | 75 | mApplication = application; |
76 | mProductId = productID; | 76 | mProductId = productID; |
77 | } | 77 | } |
78 | 78 | ||
79 | QString CalFormat::createUniqueId() | 79 | QString CalFormat::createUniqueId() |
80 | { | 80 | { |
81 | int hashTime = QTime::currentTime().hour() + | 81 | return QString("%1-%2-%3") |
82 | QTime::currentTime().minute() + QTime::currentTime().second() + | 82 | .arg("kopi") |
83 | QTime::currentTime().msec(); | ||
84 | QString uidStr = QString("%1-%2.%3") | ||
85 | .arg(mApplication) | ||
86 | .arg(KApplication::random()) | 83 | .arg(KApplication::random()) |
87 | .arg(hashTime); | 84 | .arg(QTime::currentTime().msec()+1); |
88 | return uidStr; | ||
89 | } | 85 | } |
90 | 86 | ||
91 | int CalFormat::calendarVersion(const char* prodId) | 87 | int CalFormat::calendarVersion(const char* prodId) |
92 | { | 88 | { |
93 | for (const CalVersion* cv = prodIds; cv->version; ++cv) { | 89 | for (const CalVersion* cv = prodIds; cv->version; ++cv) { |
94 | if (!strcmp(prodId, cv->prodId.local8Bit())) | 90 | if (!strcmp(prodId, cv->prodId.local8Bit())) |
95 | return cv->version; | 91 | return cv->version; |
96 | } | 92 | } |
97 | return 0; | 93 | return 0; |
98 | } | 94 | } |
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index eae41aa..fe7413f 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp | |||
@@ -113,515 +113,515 @@ icalcomponent *ICalFormatImpl::writeTodo(Todo *todo) | |||
113 | // kdDebug(5800) << "§§ incidence " << todo->summary() << " has time." << endl; | 113 | // kdDebug(5800) << "§§ incidence " << todo->summary() << " has time." << endl; |
114 | start = writeICalDateTime(todo->dtStart()); | 114 | start = writeICalDateTime(todo->dtStart()); |
115 | } | 115 | } |
116 | icalcomponent_add_property(vtodo,icalproperty_new_dtstart(start)); | 116 | icalcomponent_add_property(vtodo,icalproperty_new_dtstart(start)); |
117 | } | 117 | } |
118 | 118 | ||
119 | // completion date | 119 | // completion date |
120 | if (todo->isCompleted()) { | 120 | if (todo->isCompleted()) { |
121 | if (!todo->hasCompletedDate()) { | 121 | if (!todo->hasCompletedDate()) { |
122 | // If todo was created by KOrganizer <2.2 it has no correct completion | 122 | // If todo was created by KOrganizer <2.2 it has no correct completion |
123 | // date. Set it to now. | 123 | // date. Set it to now. |
124 | todo->setCompleted(QDateTime::currentDateTime()); | 124 | todo->setCompleted(QDateTime::currentDateTime()); |
125 | } | 125 | } |
126 | icaltimetype completed = writeICalDateTime(todo->completed()); | 126 | icaltimetype completed = writeICalDateTime(todo->completed()); |
127 | icalcomponent_add_property(vtodo,icalproperty_new_completed(completed)); | 127 | icalcomponent_add_property(vtodo,icalproperty_new_completed(completed)); |
128 | } | 128 | } |
129 | 129 | ||
130 | icalcomponent_add_property(vtodo, | 130 | icalcomponent_add_property(vtodo, |
131 | icalproperty_new_percentcomplete(todo->percentComplete())); | 131 | icalproperty_new_percentcomplete(todo->percentComplete())); |
132 | 132 | ||
133 | return vtodo; | 133 | return vtodo; |
134 | } | 134 | } |
135 | 135 | ||
136 | icalcomponent *ICalFormatImpl::writeEvent(Event *event) | 136 | icalcomponent *ICalFormatImpl::writeEvent(Event *event) |
137 | { | 137 | { |
138 | kdDebug(5800) << "Write Event '" << event->summary() << "' (" << event->uid() | 138 | kdDebug(5800) << "Write Event '" << event->summary() << "' (" << event->uid() |
139 | << ")" << endl; | 139 | << ")" << endl; |
140 | 140 | ||
141 | QString tmpStr; | 141 | QString tmpStr; |
142 | QStringList tmpStrList; | 142 | QStringList tmpStrList; |
143 | 143 | ||
144 | icalcomponent *vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT); | 144 | icalcomponent *vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT); |
145 | 145 | ||
146 | writeIncidence(vevent,event); | 146 | writeIncidence(vevent,event); |
147 | 147 | ||
148 | // start time | 148 | // start time |
149 | icaltimetype start; | 149 | icaltimetype start; |
150 | if (event->doesFloat()) { | 150 | if (event->doesFloat()) { |
151 | // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; | 151 | // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; |
152 | start = writeICalDate(event->dtStart().date()); | 152 | start = writeICalDate(event->dtStart().date()); |
153 | } else { | 153 | } else { |
154 | // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; | 154 | // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; |
155 | start = writeICalDateTime(event->dtStart()); | 155 | start = writeICalDateTime(event->dtStart()); |
156 | } | 156 | } |
157 | icalcomponent_add_property(vevent,icalproperty_new_dtstart(start)); | 157 | icalcomponent_add_property(vevent,icalproperty_new_dtstart(start)); |
158 | 158 | ||
159 | if (event->hasEndDate()) { | 159 | if (event->hasEndDate()) { |
160 | // end time | 160 | // end time |
161 | icaltimetype end; | 161 | icaltimetype end; |
162 | if (event->doesFloat()) { | 162 | if (event->doesFloat()) { |
163 | // kdDebug(5800) << "§§ Event " << event->summary() << " floats." << endl; | 163 | // kdDebug(5800) << "§§ Event " << event->summary() << " floats." << endl; |
164 | // +1 day because end date is non-inclusive. | 164 | // +1 day because end date is non-inclusive. |
165 | end = writeICalDate( event->dtEnd().date().addDays( 1 ) ); | 165 | end = writeICalDate( event->dtEnd().date().addDays( 1 ) ); |
166 | } else { | 166 | } else { |
167 | // kdDebug(5800) << "§§ Event " << event->summary() << " has time." << endl; | 167 | // kdDebug(5800) << "§§ Event " << event->summary() << " has time." << endl; |
168 | end = writeICalDateTime(event->dtEnd()); | 168 | end = writeICalDateTime(event->dtEnd()); |
169 | } | 169 | } |
170 | icalcomponent_add_property(vevent,icalproperty_new_dtend(end)); | 170 | icalcomponent_add_property(vevent,icalproperty_new_dtend(end)); |
171 | } | 171 | } |
172 | 172 | ||
173 | // TODO: attachments, resources | 173 | // TODO: attachments, resources |
174 | #if 0 | 174 | #if 0 |
175 | // attachments | 175 | // attachments |
176 | tmpStrList = anEvent->attachments(); | 176 | tmpStrList = anEvent->attachments(); |
177 | for ( QStringList::Iterator it = tmpStrList.begin(); | 177 | for ( QStringList::Iterator it = tmpStrList.begin(); |
178 | it != tmpStrList.end(); | 178 | it != tmpStrList.end(); |
179 | ++it ) | 179 | ++it ) |
180 | addPropValue(vevent, VCAttachProp, (*it).utf8()); | 180 | addPropValue(vevent, VCAttachProp, (*it).utf8()); |
181 | 181 | ||
182 | // resources | 182 | // resources |
183 | tmpStrList = anEvent->resources(); | 183 | tmpStrList = anEvent->resources(); |
184 | tmpStr = tmpStrList.join(";"); | 184 | tmpStr = tmpStrList.join(";"); |
185 | if (!tmpStr.isEmpty()) | 185 | if (!tmpStr.isEmpty()) |
186 | addPropValue(vevent, VCResourcesProp, tmpStr.utf8()); | 186 | addPropValue(vevent, VCResourcesProp, tmpStr.utf8()); |
187 | 187 | ||
188 | #endif | 188 | #endif |
189 | 189 | ||
190 | // Transparency | 190 | // Transparency |
191 | switch( event->transparency() ) { | 191 | switch( event->transparency() ) { |
192 | case Event::Transparent: | 192 | case Event::Transparent: |
193 | icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT)); | 193 | icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT)); |
194 | break; | 194 | break; |
195 | case Event::Opaque: | 195 | case Event::Opaque: |
196 | icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE)); | 196 | icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE)); |
197 | break; | 197 | break; |
198 | } | 198 | } |
199 | 199 | ||
200 | return vevent; | 200 | return vevent; |
201 | } | 201 | } |
202 | 202 | ||
203 | icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, | 203 | icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, |
204 | Scheduler::Method method) | 204 | Scheduler::Method method) |
205 | { | 205 | { |
206 | 206 | ||
207 | 207 | ||
208 | icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT); | 208 | icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT); |
209 | 209 | ||
210 | writeIncidenceBase(vfreebusy,freebusy); | 210 | writeIncidenceBase(vfreebusy,freebusy); |
211 | 211 | ||
212 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart( | 212 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart( |
213 | writeICalDateTime(freebusy->dtStart()))); | 213 | writeICalDateTime(freebusy->dtStart()))); |
214 | 214 | ||
215 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtend( | 215 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtend( |
216 | writeICalDateTime(freebusy->dtEnd()))); | 216 | writeICalDateTime(freebusy->dtEnd()))); |
217 | 217 | ||
218 | if (method == Scheduler::Request) { | 218 | if (method == Scheduler::Request) { |
219 | icalcomponent_add_property(vfreebusy,icalproperty_new_uid( | 219 | icalcomponent_add_property(vfreebusy,icalproperty_new_uid( |
220 | freebusy->uid().utf8())); | 220 | freebusy->uid().utf8())); |
221 | } | 221 | } |
222 | 222 | ||
223 | //Loops through all the periods in the freebusy object | 223 | //Loops through all the periods in the freebusy object |
224 | QValueList<Period> list = freebusy->busyPeriods(); | 224 | QValueList<Period> list = freebusy->busyPeriods(); |
225 | QValueList<Period>::Iterator it; | 225 | QValueList<Period>::Iterator it; |
226 | icalperiodtype period; | 226 | icalperiodtype period; |
227 | for (it = list.begin(); it!= list.end(); ++it) { | 227 | for (it = list.begin(); it!= list.end(); ++it) { |
228 | period.start = writeICalDateTime((*it).start()); | 228 | period.start = writeICalDateTime((*it).start()); |
229 | period.end = writeICalDateTime((*it).end()); | 229 | period.end = writeICalDateTime((*it).end()); |
230 | icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) ); | 230 | icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) ); |
231 | } | 231 | } |
232 | 232 | ||
233 | return vfreebusy; | 233 | return vfreebusy; |
234 | } | 234 | } |
235 | 235 | ||
236 | icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) | 236 | icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) |
237 | { | 237 | { |
238 | icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT); | 238 | icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT); |
239 | 239 | ||
240 | writeIncidence(vjournal,journal); | 240 | writeIncidence(vjournal,journal); |
241 | 241 | ||
242 | // start time | 242 | // start time |
243 | if (journal->dtStart().isValid()) { | 243 | if (journal->dtStart().isValid()) { |
244 | icaltimetype start; | 244 | icaltimetype start; |
245 | if (journal->doesFloat()) { | 245 | if (journal->doesFloat()) { |
246 | // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; | 246 | // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; |
247 | start = writeICalDate(journal->dtStart().date()); | 247 | start = writeICalDate(journal->dtStart().date()); |
248 | } else { | 248 | } else { |
249 | // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; | 249 | // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; |
250 | start = writeICalDateTime(journal->dtStart()); | 250 | start = writeICalDateTime(journal->dtStart()); |
251 | } | 251 | } |
252 | icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start)); | 252 | icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start)); |
253 | } | 253 | } |
254 | 254 | ||
255 | return vjournal; | 255 | return vjournal; |
256 | } | 256 | } |
257 | 257 | ||
258 | void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) | 258 | void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) |
259 | { | 259 | { |
260 | // pilot sync stuff | 260 | // pilot sync stuff |
261 | // TODO: move this application-specific code to kpilot | 261 | // TODO: move this application-specific code to kpilot |
262 | if (incidence->pilotId()) { | 262 | if (incidence->pilotId()) { |
263 | incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId())); | 263 | incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId())); |
264 | incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus())); | 264 | incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus())); |
265 | } | 265 | } |
266 | if ( !incidence->IDStr().isEmpty()) { | 266 | if ( !incidence->IDStr().isEmpty()) { |
267 | incidence->setNonKDECustomProperty("X-KOPIEXTID",incidence->IDStr() ); | 267 | incidence->setNonKDECustomProperty("X-KOPIEXTID",incidence->IDStr() ); |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | writeIncidenceBase(parent,incidence); | 271 | writeIncidenceBase(parent,incidence); |
272 | if (incidence->cancelled()) { | 272 | if (incidence->cancelled()) { |
273 | icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED)); | 273 | icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED)); |
274 | } | 274 | } |
275 | 275 | ||
276 | // creation date | 276 | // creation date |
277 | icalcomponent_add_property(parent,icalproperty_new_created( | 277 | icalcomponent_add_property(parent,icalproperty_new_created( |
278 | writeICalDateTime(incidence->created()))); | 278 | writeICalDateTime(incidence->created()))); |
279 | 279 | ||
280 | // unique id | 280 | // unique id |
281 | icalcomponent_add_property(parent,icalproperty_new_uid( | 281 | icalcomponent_add_property(parent,icalproperty_new_uid( |
282 | incidence->uid().utf8())); | 282 | incidence->uid().utf8())); |
283 | 283 | ||
284 | // revision | 284 | // revision |
285 | icalcomponent_add_property(parent,icalproperty_new_sequence( | 285 | icalcomponent_add_property(parent,icalproperty_new_sequence( |
286 | incidence->revision())); | 286 | incidence->revision())); |
287 | 287 | ||
288 | // last modification date | 288 | // last modification date |
289 | icalcomponent_add_property(parent,icalproperty_new_lastmodified( | 289 | icalcomponent_add_property(parent,icalproperty_new_lastmodified( |
290 | writeICalDateTime(incidence->lastModified()))); | 290 | writeICalDateTime(incidence->lastModified()))); |
291 | 291 | ||
292 | // description | 292 | // description |
293 | if (!incidence->description().isEmpty()) { | 293 | if (!incidence->description().isEmpty()) { |
294 | icalcomponent_add_property(parent,icalproperty_new_description( | 294 | icalcomponent_add_property(parent,icalproperty_new_description( |
295 | incidence->description().utf8())); | 295 | incidence->description().utf8())); |
296 | } | 296 | } |
297 | 297 | ||
298 | // summary | 298 | // summary |
299 | if (!incidence->summary().isEmpty()) { | 299 | if (!incidence->summary().isEmpty()) { |
300 | icalcomponent_add_property(parent,icalproperty_new_summary( | 300 | icalcomponent_add_property(parent,icalproperty_new_summary( |
301 | incidence->summary().utf8())); | 301 | incidence->summary().utf8())); |
302 | } | 302 | } |
303 | 303 | ||
304 | // location | 304 | // location |
305 | if (!incidence->location().isEmpty()) { | 305 | if (!incidence->location().isEmpty()) { |
306 | icalcomponent_add_property(parent,icalproperty_new_location( | 306 | icalcomponent_add_property(parent,icalproperty_new_location( |
307 | incidence->location().utf8())); | 307 | incidence->location().utf8())); |
308 | } | 308 | } |
309 | 309 | ||
310 | // TODO: | 310 | // TODO: |
311 | // status | 311 | // status |
312 | // addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8()); | 312 | // addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8()); |
313 | 313 | ||
314 | // secrecy | 314 | // secrecy |
315 | enum icalproperty_class classInt; | 315 | enum icalproperty_class classInt; |
316 | switch (incidence->secrecy()) { | 316 | switch (incidence->secrecy()) { |
317 | case Incidence::SecrecyPublic: | 317 | case Incidence::SecrecyPublic: |
318 | classInt = ICAL_CLASS_PUBLIC; | 318 | classInt = ICAL_CLASS_PUBLIC; |
319 | break; | 319 | break; |
320 | case Incidence::SecrecyConfidential: | 320 | case Incidence::SecrecyConfidential: |
321 | classInt = ICAL_CLASS_CONFIDENTIAL; | 321 | classInt = ICAL_CLASS_CONFIDENTIAL; |
322 | break; | 322 | break; |
323 | case Incidence::SecrecyPrivate: | 323 | case Incidence::SecrecyPrivate: |
324 | classInt =ICAL_CLASS_PRIVATE ; | 324 | classInt =ICAL_CLASS_PRIVATE ; |
325 | default: | 325 | default: |
326 | classInt =ICAL_CLASS_PRIVATE ; | 326 | classInt =ICAL_CLASS_PRIVATE ; |
327 | break; | 327 | break; |
328 | } | 328 | } |
329 | icalcomponent_add_property(parent,icalproperty_new_class(classInt)); | 329 | icalcomponent_add_property(parent,icalproperty_new_class(classInt)); |
330 | 330 | ||
331 | // priority | 331 | // priority |
332 | icalcomponent_add_property(parent,icalproperty_new_priority( | 332 | icalcomponent_add_property(parent,icalproperty_new_priority( |
333 | incidence->priority())); | 333 | incidence->priority())); |
334 | 334 | ||
335 | // categories | 335 | // categories |
336 | QStringList categories = incidence->categories(); | 336 | QStringList categories = incidence->categories(); |
337 | QStringList::Iterator it; | 337 | QStringList::Iterator it; |
338 | for(it = categories.begin(); it != categories.end(); ++it ) { | 338 | for(it = categories.begin(); it != categories.end(); ++it ) { |
339 | icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); | 339 | icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); |
340 | } | 340 | } |
341 | // TODO: Ensure correct concatenation of categories properties. | 341 | // TODO: Ensure correct concatenation of categories properties. |
342 | 342 | ||
343 | /* | 343 | /* |
344 | // categories | 344 | // categories |
345 | tmpStrList = incidence->getCategories(); | 345 | tmpStrList = incidence->getCategories(); |
346 | tmpStr = ""; | 346 | tmpStr = ""; |
347 | QString catStr; | 347 | QString catStr; |
348 | for ( QStringList::Iterator it = tmpStrList.begin(); | 348 | for ( QStringList::Iterator it = tmpStrList.begin(); |
349 | it != tmpStrList.end(); | 349 | it != tmpStrList.end(); |
350 | ++it ) { | 350 | ++it ) { |
351 | catStr = *it; | 351 | catStr = *it; |
352 | if (catStr[0] == ' ') | 352 | if (catStr[0] == ' ') |
353 | tmpStr += catStr.mid(1); | 353 | tmpStr += catStr.mid(1); |
354 | else | 354 | else |
355 | tmpStr += catStr; | 355 | tmpStr += catStr; |
356 | // this must be a ';' character as the vCalendar specification requires! | 356 | // this must be a ';' character as the vCalendar specification requires! |
357 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is | 357 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is |
358 | // read in. | 358 | // read in. |
359 | tmpStr += ";"; | 359 | tmpStr += ";"; |
360 | } | 360 | } |
361 | if (!tmpStr.isEmpty()) { | 361 | if (!tmpStr.isEmpty()) { |
362 | tmpStr.truncate(tmpStr.length()-1); | 362 | tmpStr.truncate(tmpStr.length()-1); |
363 | icalcomponent_add_property(parent,icalproperty_new_categories( | 363 | icalcomponent_add_property(parent,icalproperty_new_categories( |
364 | writeText(incidence->getCategories().join(";")))); | 364 | writeText(incidence->getCategories().join(";")))); |
365 | } | 365 | } |
366 | */ | 366 | */ |
367 | 367 | ||
368 | // related event | 368 | // related event |
369 | if (incidence->relatedTo()) { | 369 | if (!incidence->relatedToUid().isEmpty()) { |
370 | icalcomponent_add_property(parent,icalproperty_new_relatedto( | 370 | icalcomponent_add_property(parent,icalproperty_new_relatedto( |
371 | incidence->relatedTo()->uid().utf8())); | 371 | incidence->relatedToUid().utf8())); |
372 | } | 372 | } |
373 | 373 | ||
374 | // recurrence rule stuff | 374 | // recurrence rule stuff |
375 | Recurrence *recur = incidence->recurrence(); | 375 | Recurrence *recur = incidence->recurrence(); |
376 | if (recur->doesRecur()) { | 376 | if (recur->doesRecur()) { |
377 | 377 | ||
378 | icalcomponent_add_property(parent,writeRecurrenceRule(recur)); | 378 | icalcomponent_add_property(parent,writeRecurrenceRule(recur)); |
379 | } | 379 | } |
380 | 380 | ||
381 | // recurrence excpetion dates | 381 | // recurrence excpetion dates |
382 | DateList dateList = incidence->exDates(); | 382 | DateList dateList = incidence->exDates(); |
383 | DateList::ConstIterator exIt; | 383 | DateList::ConstIterator exIt; |
384 | for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { | 384 | for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { |
385 | icalcomponent_add_property(parent,icalproperty_new_exdate( | 385 | icalcomponent_add_property(parent,icalproperty_new_exdate( |
386 | writeICalDate(*exIt))); | 386 | writeICalDate(*exIt))); |
387 | } | 387 | } |
388 | 388 | ||
389 | // attachments | 389 | // attachments |
390 | QPtrList<Attachment> attachments = incidence->attachments(); | 390 | QPtrList<Attachment> attachments = incidence->attachments(); |
391 | for (Attachment *at = attachments.first(); at; at = attachments.next()) | 391 | for (Attachment *at = attachments.first(); at; at = attachments.next()) |
392 | icalcomponent_add_property(parent,writeAttachment(at)); | 392 | icalcomponent_add_property(parent,writeAttachment(at)); |
393 | 393 | ||
394 | // alarms | 394 | // alarms |
395 | QPtrList<Alarm> alarms = incidence->alarms(); | 395 | QPtrList<Alarm> alarms = incidence->alarms(); |
396 | Alarm* alarm; | 396 | Alarm* alarm; |
397 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { | 397 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { |
398 | if (alarm->enabled()) { | 398 | if (alarm->enabled()) { |
399 | kdDebug(5800) << "Write alarm for " << incidence->summary() << endl; | 399 | kdDebug(5800) << "Write alarm for " << incidence->summary() << endl; |
400 | icalcomponent_add_component(parent,writeAlarm(alarm)); | 400 | icalcomponent_add_component(parent,writeAlarm(alarm)); |
401 | } | 401 | } |
402 | } | 402 | } |
403 | if( incidence->hasRecurrenceID() ) { | 403 | if( incidence->hasRecurrenceID() ) { |
404 | icalcomponent_add_property(parent, | 404 | icalcomponent_add_property(parent, |
405 | icalproperty_new_recurrenceid( writeICalDateTime( incidence->recurrenceID()))); | 405 | icalproperty_new_recurrenceid( writeICalDateTime( incidence->recurrenceID()))); |
406 | } | 406 | } |
407 | // duration | 407 | // duration |
408 | 408 | ||
409 | // turned off as it always is set to PTS0 (and must not occur together with DTEND | 409 | // turned off as it always is set to PTS0 (and must not occur together with DTEND |
410 | 410 | ||
411 | if (incidence->hasDuration()) { | 411 | if (incidence->hasDuration()) { |
412 | icaldurationtype duration; | 412 | icaldurationtype duration; |
413 | duration = writeICalDuration(incidence->duration()); | 413 | duration = writeICalDuration(incidence->duration()); |
414 | icalcomponent_add_property(parent,icalproperty_new_duration(duration)); | 414 | icalcomponent_add_property(parent,icalproperty_new_duration(duration)); |
415 | } | 415 | } |
416 | } | 416 | } |
417 | 417 | ||
418 | void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) | 418 | void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) |
419 | { | 419 | { |
420 | icalcomponent_add_property(parent,icalproperty_new_dtstamp( | 420 | icalcomponent_add_property(parent,icalproperty_new_dtstamp( |
421 | writeICalDateTime(QDateTime::currentDateTime()))); | 421 | writeICalDateTime(QDateTime::currentDateTime()))); |
422 | 422 | ||
423 | // organizer stuff | 423 | // organizer stuff |
424 | icalcomponent_add_property(parent,icalproperty_new_organizer( | 424 | icalcomponent_add_property(parent,icalproperty_new_organizer( |
425 | ("MAILTO:" + incidenceBase->organizer()).utf8())); | 425 | ("MAILTO:" + incidenceBase->organizer()).utf8())); |
426 | 426 | ||
427 | // attendees | 427 | // attendees |
428 | if (incidenceBase->attendeeCount() != 0) { | 428 | if (incidenceBase->attendeeCount() != 0) { |
429 | QPtrList<Attendee> al = incidenceBase->attendees(); | 429 | QPtrList<Attendee> al = incidenceBase->attendees(); |
430 | QPtrListIterator<Attendee> ai(al); | 430 | QPtrListIterator<Attendee> ai(al); |
431 | for (; ai.current(); ++ai) { | 431 | for (; ai.current(); ++ai) { |
432 | icalcomponent_add_property(parent,writeAttendee(ai.current())); | 432 | icalcomponent_add_property(parent,writeAttendee(ai.current())); |
433 | } | 433 | } |
434 | } | 434 | } |
435 | 435 | ||
436 | // custom properties | 436 | // custom properties |
437 | writeCustomProperties(parent, incidenceBase); | 437 | writeCustomProperties(parent, incidenceBase); |
438 | } | 438 | } |
439 | 439 | ||
440 | void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties) | 440 | void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties) |
441 | { | 441 | { |
442 | QMap<QCString, QString> custom = properties->customProperties(); | 442 | QMap<QCString, QString> custom = properties->customProperties(); |
443 | for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { | 443 | for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { |
444 | icalproperty *p = icalproperty_new_x(c.data().utf8()); | 444 | icalproperty *p = icalproperty_new_x(c.data().utf8()); |
445 | icalproperty_set_x_name(p,c.key()); | 445 | icalproperty_set_x_name(p,c.key()); |
446 | icalcomponent_add_property(parent,p); | 446 | icalcomponent_add_property(parent,p); |
447 | } | 447 | } |
448 | } | 448 | } |
449 | 449 | ||
450 | icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee) | 450 | icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee) |
451 | { | 451 | { |
452 | icalproperty *p = icalproperty_new_attendee("mailto:" + attendee->email().utf8()); | 452 | icalproperty *p = icalproperty_new_attendee("mailto:" + attendee->email().utf8()); |
453 | 453 | ||
454 | if (!attendee->name().isEmpty()) { | 454 | if (!attendee->name().isEmpty()) { |
455 | icalproperty_add_parameter(p,icalparameter_new_cn(attendee->name().utf8())); | 455 | icalproperty_add_parameter(p,icalparameter_new_cn(attendee->name().utf8())); |
456 | } | 456 | } |
457 | 457 | ||
458 | 458 | ||
459 | icalproperty_add_parameter(p,icalparameter_new_rsvp( | 459 | icalproperty_add_parameter(p,icalparameter_new_rsvp( |
460 | attendee->RSVP() ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE )); | 460 | attendee->RSVP() ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE )); |
461 | 461 | ||
462 | icalparameter_partstat status = ICAL_PARTSTAT_NEEDSACTION; | 462 | icalparameter_partstat status = ICAL_PARTSTAT_NEEDSACTION; |
463 | switch (attendee->status()) { | 463 | switch (attendee->status()) { |
464 | default: | 464 | default: |
465 | case Attendee::NeedsAction: | 465 | case Attendee::NeedsAction: |
466 | status = ICAL_PARTSTAT_NEEDSACTION; | 466 | status = ICAL_PARTSTAT_NEEDSACTION; |
467 | break; | 467 | break; |
468 | case Attendee::Accepted: | 468 | case Attendee::Accepted: |
469 | status = ICAL_PARTSTAT_ACCEPTED; | 469 | status = ICAL_PARTSTAT_ACCEPTED; |
470 | break; | 470 | break; |
471 | case Attendee::Declined: | 471 | case Attendee::Declined: |
472 | status = ICAL_PARTSTAT_DECLINED; | 472 | status = ICAL_PARTSTAT_DECLINED; |
473 | break; | 473 | break; |
474 | case Attendee::Tentative: | 474 | case Attendee::Tentative: |
475 | status = ICAL_PARTSTAT_TENTATIVE; | 475 | status = ICAL_PARTSTAT_TENTATIVE; |
476 | break; | 476 | break; |
477 | case Attendee::Delegated: | 477 | case Attendee::Delegated: |
478 | status = ICAL_PARTSTAT_DELEGATED; | 478 | status = ICAL_PARTSTAT_DELEGATED; |
479 | break; | 479 | break; |
480 | case Attendee::Completed: | 480 | case Attendee::Completed: |
481 | status = ICAL_PARTSTAT_COMPLETED; | 481 | status = ICAL_PARTSTAT_COMPLETED; |
482 | break; | 482 | break; |
483 | case Attendee::InProcess: | 483 | case Attendee::InProcess: |
484 | status = ICAL_PARTSTAT_INPROCESS; | 484 | status = ICAL_PARTSTAT_INPROCESS; |
485 | break; | 485 | break; |
486 | } | 486 | } |
487 | icalproperty_add_parameter(p,icalparameter_new_partstat(status)); | 487 | icalproperty_add_parameter(p,icalparameter_new_partstat(status)); |
488 | 488 | ||
489 | icalparameter_role role = ICAL_ROLE_REQPARTICIPANT; | 489 | icalparameter_role role = ICAL_ROLE_REQPARTICIPANT; |
490 | switch (attendee->role()) { | 490 | switch (attendee->role()) { |
491 | case Attendee::Chair: | 491 | case Attendee::Chair: |
492 | role = ICAL_ROLE_CHAIR; | 492 | role = ICAL_ROLE_CHAIR; |
493 | break; | 493 | break; |
494 | default: | 494 | default: |
495 | case Attendee::ReqParticipant: | 495 | case Attendee::ReqParticipant: |
496 | role = ICAL_ROLE_REQPARTICIPANT; | 496 | role = ICAL_ROLE_REQPARTICIPANT; |
497 | break; | 497 | break; |
498 | case Attendee::OptParticipant: | 498 | case Attendee::OptParticipant: |
499 | role = ICAL_ROLE_OPTPARTICIPANT; | 499 | role = ICAL_ROLE_OPTPARTICIPANT; |
500 | break; | 500 | break; |
501 | case Attendee::NonParticipant: | 501 | case Attendee::NonParticipant: |
502 | role = ICAL_ROLE_NONPARTICIPANT; | 502 | role = ICAL_ROLE_NONPARTICIPANT; |
503 | break; | 503 | break; |
504 | } | 504 | } |
505 | icalproperty_add_parameter(p,icalparameter_new_role(role)); | 505 | icalproperty_add_parameter(p,icalparameter_new_role(role)); |
506 | 506 | ||
507 | if (!attendee->uid().isEmpty()) { | 507 | if (!attendee->uid().isEmpty()) { |
508 | icalparameter* icalparameter_uid = icalparameter_new_x(attendee->uid().utf8()); | 508 | icalparameter* icalparameter_uid = icalparameter_new_x(attendee->uid().utf8()); |
509 | icalparameter_set_xname(icalparameter_uid,"X-UID"); | 509 | icalparameter_set_xname(icalparameter_uid,"X-UID"); |
510 | icalproperty_add_parameter(p,icalparameter_uid); | 510 | icalproperty_add_parameter(p,icalparameter_uid); |
511 | } | 511 | } |
512 | 512 | ||
513 | return p; | 513 | return p; |
514 | } | 514 | } |
515 | 515 | ||
516 | icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) | 516 | icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) |
517 | { | 517 | { |
518 | #if 0 | 518 | #if 0 |
519 | icalattachtype* attach = icalattachtype_new(); | 519 | icalattachtype* attach = icalattachtype_new(); |
520 | if (att->isURI()) | 520 | if (att->isURI()) |
521 | icalattachtype_set_url(attach, att->uri().utf8().data()); | 521 | icalattachtype_set_url(attach, att->uri().utf8().data()); |
522 | else | 522 | else |
523 | icalattachtype_set_base64(attach, att->data(), 0); | 523 | icalattachtype_set_base64(attach, att->data(), 0); |
524 | #endif | 524 | #endif |
525 | icalattach *attach; | 525 | icalattach *attach; |
526 | if (att->isURI()) | 526 | if (att->isURI()) |
527 | attach = icalattach_new_from_url( att->uri().utf8().data()); | 527 | attach = icalattach_new_from_url( att->uri().utf8().data()); |
528 | else | 528 | else |
529 | attach = icalattach_new_from_data ( (unsigned char *)att->data(), 0, 0); | 529 | attach = icalattach_new_from_data ( (unsigned char *)att->data(), 0, 0); |
530 | icalproperty *p = icalproperty_new_attach(attach); | 530 | icalproperty *p = icalproperty_new_attach(attach); |
531 | if (!att->mimeType().isEmpty()) | 531 | if (!att->mimeType().isEmpty()) |
532 | icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data())); | 532 | icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data())); |
533 | 533 | ||
534 | if (att->isBinary()) { | 534 | if (att->isBinary()) { |
535 | icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY)); | 535 | icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY)); |
536 | icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64)); | 536 | icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64)); |
537 | } | 537 | } |
538 | return p; | 538 | return p; |
539 | } | 539 | } |
540 | 540 | ||
541 | icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur) | 541 | icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur) |
542 | { | 542 | { |
543 | // kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl; | 543 | // kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl; |
544 | 544 | ||
545 | icalrecurrencetype r; | 545 | icalrecurrencetype r; |
546 | 546 | ||
547 | icalrecurrencetype_clear(&r); | 547 | icalrecurrencetype_clear(&r); |
548 | 548 | ||
549 | int index = 0; | 549 | int index = 0; |
550 | int index2 = 0; | 550 | int index2 = 0; |
551 | 551 | ||
552 | QPtrList<Recurrence::rMonthPos> tmpPositions; | 552 | QPtrList<Recurrence::rMonthPos> tmpPositions; |
553 | QPtrList<int> tmpDays; | 553 | QPtrList<int> tmpDays; |
554 | int *tmpDay; | 554 | int *tmpDay; |
555 | Recurrence::rMonthPos *tmpPos; | 555 | Recurrence::rMonthPos *tmpPos; |
556 | bool datetime = false; | 556 | bool datetime = false; |
557 | int day; | 557 | int day; |
558 | int i; | 558 | int i; |
559 | 559 | ||
560 | switch(recur->doesRecur()) { | 560 | switch(recur->doesRecur()) { |
561 | case Recurrence::rMinutely: | 561 | case Recurrence::rMinutely: |
562 | r.freq = ICAL_MINUTELY_RECURRENCE; | 562 | r.freq = ICAL_MINUTELY_RECURRENCE; |
563 | datetime = true; | 563 | datetime = true; |
564 | break; | 564 | break; |
565 | case Recurrence::rHourly: | 565 | case Recurrence::rHourly: |
566 | r.freq = ICAL_HOURLY_RECURRENCE; | 566 | r.freq = ICAL_HOURLY_RECURRENCE; |
567 | datetime = true; | 567 | datetime = true; |
568 | break; | 568 | break; |
569 | case Recurrence::rDaily: | 569 | case Recurrence::rDaily: |
570 | r.freq = ICAL_DAILY_RECURRENCE; | 570 | r.freq = ICAL_DAILY_RECURRENCE; |
571 | break; | 571 | break; |
572 | case Recurrence::rWeekly: | 572 | case Recurrence::rWeekly: |
573 | r.freq = ICAL_WEEKLY_RECURRENCE; | 573 | r.freq = ICAL_WEEKLY_RECURRENCE; |
574 | r.week_start = static_cast<icalrecurrencetype_weekday>(recur->weekStart()%7 + 1); | 574 | r.week_start = static_cast<icalrecurrencetype_weekday>(recur->weekStart()%7 + 1); |
575 | for (i = 0; i < 7; i++) { | 575 | for (i = 0; i < 7; i++) { |
576 | if (recur->days().testBit(i)) { | 576 | if (recur->days().testBit(i)) { |
577 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 | 577 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 |
578 | r.by_day[index++] = icalrecurrencetype_day_day_of_week(day); | 578 | r.by_day[index++] = icalrecurrencetype_day_day_of_week(day); |
579 | } | 579 | } |
580 | } | 580 | } |
581 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; | 581 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; |
582 | break; | 582 | break; |
583 | case Recurrence::rMonthlyPos: | 583 | case Recurrence::rMonthlyPos: |
584 | r.freq = ICAL_MONTHLY_RECURRENCE; | 584 | r.freq = ICAL_MONTHLY_RECURRENCE; |
585 | 585 | ||
586 | tmpPositions = recur->monthPositions(); | 586 | tmpPositions = recur->monthPositions(); |
587 | for (tmpPos = tmpPositions.first(); | 587 | for (tmpPos = tmpPositions.first(); |
588 | tmpPos; | 588 | tmpPos; |
589 | tmpPos = tmpPositions.next()) { | 589 | tmpPos = tmpPositions.next()) { |
590 | for (i = 0; i < 7; i++) { | 590 | for (i = 0; i < 7; i++) { |
591 | if (tmpPos->rDays.testBit(i)) { | 591 | if (tmpPos->rDays.testBit(i)) { |
592 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 | 592 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 |
593 | day += tmpPos->rPos*8; | 593 | day += tmpPos->rPos*8; |
594 | if (tmpPos->negative) day = -day; | 594 | if (tmpPos->negative) day = -day; |
595 | r.by_day[index++] = day; | 595 | r.by_day[index++] = day; |
596 | } | 596 | } |
597 | } | 597 | } |
598 | } | 598 | } |
599 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; | 599 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; |
600 | break; | 600 | break; |
601 | case Recurrence::rMonthlyDay: | 601 | case Recurrence::rMonthlyDay: |
602 | r.freq = ICAL_MONTHLY_RECURRENCE; | 602 | r.freq = ICAL_MONTHLY_RECURRENCE; |
603 | 603 | ||
604 | tmpDays = recur->monthDays(); | 604 | tmpDays = recur->monthDays(); |
605 | for (tmpDay = tmpDays.first(); | 605 | for (tmpDay = tmpDays.first(); |
606 | tmpDay; | 606 | tmpDay; |
607 | tmpDay = tmpDays.next()) { | 607 | tmpDay = tmpDays.next()) { |
608 | r.by_month_day[index++] = icalrecurrencetype_day_position(*tmpDay*8);//*tmpDay); | 608 | r.by_month_day[index++] = icalrecurrencetype_day_position(*tmpDay*8);//*tmpDay); |
609 | } | 609 | } |
610 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; | 610 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; |
611 | break; | 611 | break; |
612 | case Recurrence::rYearlyMonth: | 612 | case Recurrence::rYearlyMonth: |
613 | case Recurrence::rYearlyPos: | 613 | case Recurrence::rYearlyPos: |
614 | r.freq = ICAL_YEARLY_RECURRENCE; | 614 | r.freq = ICAL_YEARLY_RECURRENCE; |
615 | 615 | ||
616 | tmpDays = recur->yearNums(); | 616 | tmpDays = recur->yearNums(); |
617 | for (tmpDay = tmpDays.first(); | 617 | for (tmpDay = tmpDays.first(); |
618 | tmpDay; | 618 | tmpDay; |
619 | tmpDay = tmpDays.next()) { | 619 | tmpDay = tmpDays.next()) { |
620 | r.by_month[index++] = *tmpDay; | 620 | r.by_month[index++] = *tmpDay; |
621 | } | 621 | } |
622 | // r.by_set_pos[index] = ICAL_RECURRENCE_ARRAY_MAX; | 622 | // r.by_set_pos[index] = ICAL_RECURRENCE_ARRAY_MAX; |
623 | if (recur->doesRecur() == Recurrence::rYearlyPos) { | 623 | if (recur->doesRecur() == Recurrence::rYearlyPos) { |
624 | tmpPositions = recur->monthPositions(); | 624 | tmpPositions = recur->monthPositions(); |
625 | for (tmpPos = tmpPositions.first(); | 625 | for (tmpPos = tmpPositions.first(); |
626 | tmpPos; | 626 | tmpPos; |
627 | tmpPos = tmpPositions.next()) { | 627 | tmpPos = tmpPositions.next()) { |
@@ -1783,383 +1783,387 @@ icaldurationtype ICalFormatImpl::writeICalDuration(int seconds) | |||
1783 | d.seconds = seconds; | 1783 | d.seconds = seconds; |
1784 | return d; | 1784 | return d; |
1785 | } | 1785 | } |
1786 | 1786 | ||
1787 | int ICalFormatImpl::readICalDuration(icaldurationtype d) | 1787 | int ICalFormatImpl::readICalDuration(icaldurationtype d) |
1788 | { | 1788 | { |
1789 | int result = 0; | 1789 | int result = 0; |
1790 | 1790 | ||
1791 | result += d.weeks * gSecondsPerWeek; | 1791 | result += d.weeks * gSecondsPerWeek; |
1792 | result += d.days * gSecondsPerDay; | 1792 | result += d.days * gSecondsPerDay; |
1793 | result += d.hours * gSecondsPerHour; | 1793 | result += d.hours * gSecondsPerHour; |
1794 | result += d.minutes * gSecondsPerMinute; | 1794 | result += d.minutes * gSecondsPerMinute; |
1795 | result += d.seconds; | 1795 | result += d.seconds; |
1796 | 1796 | ||
1797 | if (d.is_neg) result *= -1; | 1797 | if (d.is_neg) result *= -1; |
1798 | 1798 | ||
1799 | return result; | 1799 | return result; |
1800 | } | 1800 | } |
1801 | 1801 | ||
1802 | icalcomponent *ICalFormatImpl::createCalendarComponent(Calendar *cal) | 1802 | icalcomponent *ICalFormatImpl::createCalendarComponent(Calendar *cal) |
1803 | { | 1803 | { |
1804 | icalcomponent *calendar; | 1804 | icalcomponent *calendar; |
1805 | 1805 | ||
1806 | // Root component | 1806 | // Root component |
1807 | calendar = icalcomponent_new(ICAL_VCALENDAR_COMPONENT); | 1807 | calendar = icalcomponent_new(ICAL_VCALENDAR_COMPONENT); |
1808 | 1808 | ||
1809 | icalproperty *p; | 1809 | icalproperty *p; |
1810 | 1810 | ||
1811 | // Product Identifier | 1811 | // Product Identifier |
1812 | p = icalproperty_new_prodid(CalFormat::productId().utf8()); | 1812 | p = icalproperty_new_prodid(CalFormat::productId().utf8()); |
1813 | icalcomponent_add_property(calendar,p); | 1813 | icalcomponent_add_property(calendar,p); |
1814 | 1814 | ||
1815 | // TODO: Add time zone | 1815 | // TODO: Add time zone |
1816 | 1816 | ||
1817 | // iCalendar version (2.0) | 1817 | // iCalendar version (2.0) |
1818 | p = icalproperty_new_version(const_cast<char *>(_ICAL_VERSION)); | 1818 | p = icalproperty_new_version(const_cast<char *>(_ICAL_VERSION)); |
1819 | icalcomponent_add_property(calendar,p); | 1819 | icalcomponent_add_property(calendar,p); |
1820 | 1820 | ||
1821 | // Custom properties | 1821 | // Custom properties |
1822 | if( cal != 0 ) | 1822 | if( cal != 0 ) |
1823 | writeCustomProperties(calendar, cal); | 1823 | writeCustomProperties(calendar, cal); |
1824 | 1824 | ||
1825 | return calendar; | 1825 | return calendar; |
1826 | } | 1826 | } |
1827 | 1827 | ||
1828 | 1828 | ||
1829 | 1829 | ||
1830 | // take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. | 1830 | // take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. |
1831 | // and break it down from its tree-like format into the dictionary format | 1831 | // and break it down from its tree-like format into the dictionary format |
1832 | // that is used internally in the ICalFormatImpl. | 1832 | // that is used internally in the ICalFormatImpl. |
1833 | bool ICalFormatImpl::populate( Calendar *cal, icalcomponent *calendar) | 1833 | bool ICalFormatImpl::populate( Calendar *cal, icalcomponent *calendar) |
1834 | { | 1834 | { |
1835 | // this function will populate the caldict dictionary and other event | 1835 | // this function will populate the caldict dictionary and other event |
1836 | // lists. It turns vevents into Events and then inserts them. | 1836 | // lists. It turns vevents into Events and then inserts them. |
1837 | 1837 | ||
1838 | if (!calendar) return false; | 1838 | if (!calendar) return false; |
1839 | 1839 | ||
1840 | // TODO: check for METHOD | 1840 | // TODO: check for METHOD |
1841 | #if 0 | 1841 | #if 0 |
1842 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { | 1842 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { |
1843 | char *methodType = 0; | 1843 | char *methodType = 0; |
1844 | methodType = fakeCString(vObjectUStringZValue(curVO)); | 1844 | methodType = fakeCString(vObjectUStringZValue(curVO)); |
1845 | if (mEnableDialogs) | 1845 | if (mEnableDialogs) |
1846 | KMessageBox::information(mTopWidget, | 1846 | KMessageBox::information(mTopWidget, |
1847 | i18n("This calendar is an iTIP transaction of type \"%1\".") | 1847 | i18n("This calendar is an iTIP transaction of type \"%1\".") |
1848 | .arg(methodType), | 1848 | .arg(methodType), |
1849 | i18n("%1: iTIP Transaction").arg(CalFormat::application())); | 1849 | i18n("%1: iTIP Transaction").arg(CalFormat::application())); |
1850 | delete methodType; | 1850 | delete methodType; |
1851 | } | 1851 | } |
1852 | #endif | 1852 | #endif |
1853 | 1853 | ||
1854 | icalproperty *p; | 1854 | icalproperty *p; |
1855 | 1855 | ||
1856 | p = icalcomponent_get_first_property(calendar,ICAL_PRODID_PROPERTY); | 1856 | p = icalcomponent_get_first_property(calendar,ICAL_PRODID_PROPERTY); |
1857 | if (!p) { | 1857 | if (!p) { |
1858 | // TODO: does no PRODID really matter? | 1858 | // TODO: does no PRODID really matter? |
1859 | // mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); | 1859 | // mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); |
1860 | // return false; | 1860 | // return false; |
1861 | mLoadedProductId = ""; | 1861 | mLoadedProductId = ""; |
1862 | mCalendarVersion = 0; | 1862 | mCalendarVersion = 0; |
1863 | } else { | 1863 | } else { |
1864 | mLoadedProductId = QString::fromUtf8(icalproperty_get_prodid(p)); | 1864 | mLoadedProductId = QString::fromUtf8(icalproperty_get_prodid(p)); |
1865 | mCalendarVersion = CalFormat::calendarVersion(mLoadedProductId); | 1865 | mCalendarVersion = CalFormat::calendarVersion(mLoadedProductId); |
1866 | 1866 | ||
1867 | delete mCompat; | 1867 | delete mCompat; |
1868 | mCompat = CompatFactory::createCompat( mLoadedProductId ); | 1868 | mCompat = CompatFactory::createCompat( mLoadedProductId ); |
1869 | } | 1869 | } |
1870 | 1870 | ||
1871 | // TODO: check for unknown PRODID | 1871 | // TODO: check for unknown PRODID |
1872 | #if 0 | 1872 | #if 0 |
1873 | if (!mCalendarVersion | 1873 | if (!mCalendarVersion |
1874 | && CalFormat::productId() != mLoadedProductId) { | 1874 | && CalFormat::productId() != mLoadedProductId) { |
1875 | // warn the user that we might have trouble reading non-known calendar. | 1875 | // warn the user that we might have trouble reading non-known calendar. |
1876 | if (mEnableDialogs) | 1876 | if (mEnableDialogs) |
1877 | KMessageBox::information(mTopWidget, | 1877 | KMessageBox::information(mTopWidget, |
1878 | i18n("This vCalendar file was not created by KOrganizer " | 1878 | i18n("This vCalendar file was not created by KOrganizer " |
1879 | "or any other product we support. Loading anyway..."), | 1879 | "or any other product we support. Loading anyway..."), |
1880 | i18n("%1: Unknown vCalendar Vendor").arg(CalFormat::application())); | 1880 | i18n("%1: Unknown vCalendar Vendor").arg(CalFormat::application())); |
1881 | } | 1881 | } |
1882 | #endif | 1882 | #endif |
1883 | 1883 | ||
1884 | p = icalcomponent_get_first_property(calendar,ICAL_VERSION_PROPERTY); | 1884 | p = icalcomponent_get_first_property(calendar,ICAL_VERSION_PROPERTY); |
1885 | if (!p) { | 1885 | if (!p) { |
1886 | mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); | 1886 | mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); |
1887 | return false; | 1887 | return false; |
1888 | } else { | 1888 | } else { |
1889 | const char *version = icalproperty_get_version(p); | 1889 | const char *version = icalproperty_get_version(p); |
1890 | 1890 | ||
1891 | if (strcmp(version,"1.0") == 0) { | 1891 | if (strcmp(version,"1.0") == 0) { |
1892 | mParent->setException(new ErrorFormat(ErrorFormat::CalVersion1, | 1892 | mParent->setException(new ErrorFormat(ErrorFormat::CalVersion1, |
1893 | i18n("Expected iCalendar format"))); | 1893 | i18n("Expected iCalendar format"))); |
1894 | return false; | 1894 | return false; |
1895 | } else if (strcmp(version,"2.0") != 0) { | 1895 | } else if (strcmp(version,"2.0") != 0) { |
1896 | mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); | 1896 | mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); |
1897 | return false; | 1897 | return false; |
1898 | } | 1898 | } |
1899 | } | 1899 | } |
1900 | 1900 | ||
1901 | 1901 | ||
1902 | // TODO: check for calendar format version | 1902 | // TODO: check for calendar format version |
1903 | #if 0 | 1903 | #if 0 |
1904 | // warn the user we might have trouble reading this unknown version. | 1904 | // warn the user we might have trouble reading this unknown version. |
1905 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { | 1905 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { |
1906 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1906 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1907 | if (strcmp(_VCAL_VERSION, s) != 0) | 1907 | if (strcmp(_VCAL_VERSION, s) != 0) |
1908 | if (mEnableDialogs) | 1908 | if (mEnableDialogs) |
1909 | KMessageBox::sorry(mTopWidget, | 1909 | KMessageBox::sorry(mTopWidget, |
1910 | i18n("This vCalendar file has version %1.\n" | 1910 | i18n("This vCalendar file has version %1.\n" |
1911 | "We only support %2.") | 1911 | "We only support %2.") |
1912 | .arg(s).arg(_VCAL_VERSION), | 1912 | .arg(s).arg(_VCAL_VERSION), |
1913 | i18n("%1: Unknown vCalendar Version").arg(CalFormat::application())); | 1913 | i18n("%1: Unknown vCalendar Version").arg(CalFormat::application())); |
1914 | deleteStr(s); | 1914 | deleteStr(s); |
1915 | } | 1915 | } |
1916 | #endif | 1916 | #endif |
1917 | 1917 | ||
1918 | // custom properties | 1918 | // custom properties |
1919 | readCustomProperties(calendar, cal); | 1919 | readCustomProperties(calendar, cal); |
1920 | 1920 | ||
1921 | // TODO: set time zone | 1921 | // TODO: set time zone |
1922 | #if 0 | 1922 | #if 0 |
1923 | // set the time zone | 1923 | // set the time zone |
1924 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { | 1924 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { |
1925 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1925 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1926 | cal->setTimeZone(s); | 1926 | cal->setTimeZone(s); |
1927 | deleteStr(s); | 1927 | deleteStr(s); |
1928 | } | 1928 | } |
1929 | #endif | 1929 | #endif |
1930 | 1930 | ||
1931 | // Store all events with a relatedTo property in a list for post-processing | 1931 | // Store all events with a relatedTo property in a list for post-processing |
1932 | mEventsRelate.clear(); | 1932 | mEventsRelate.clear(); |
1933 | mTodosRelate.clear(); | 1933 | mTodosRelate.clear(); |
1934 | // TODO: make sure that only actually added ecvens go to this lists. | 1934 | // TODO: make sure that only actually added ecvens go to this lists. |
1935 | 1935 | ||
1936 | icalcomponent *c; | 1936 | icalcomponent *c; |
1937 | 1937 | ||
1938 | // Iterate through all todos | 1938 | // Iterate through all todos |
1939 | c = icalcomponent_get_first_component(calendar,ICAL_VTODO_COMPONENT); | 1939 | c = icalcomponent_get_first_component(calendar,ICAL_VTODO_COMPONENT); |
1940 | while (c) { | 1940 | while (c) { |
1941 | // kdDebug(5800) << "----Todo found" << endl; | 1941 | // kdDebug(5800) << "----Todo found" << endl; |
1942 | Todo *todo = readTodo(c); | 1942 | Todo *todo = readTodo(c); |
1943 | if (!cal->todo(todo->uid())) cal->addTodo(todo); | 1943 | if (!cal->todo(todo->uid())) cal->addTodo(todo); |
1944 | c = icalcomponent_get_next_component(calendar,ICAL_VTODO_COMPONENT); | 1944 | c = icalcomponent_get_next_component(calendar,ICAL_VTODO_COMPONENT); |
1945 | } | 1945 | } |
1946 | 1946 | ||
1947 | // Iterate through all events | 1947 | // Iterate through all events |
1948 | c = icalcomponent_get_first_component(calendar,ICAL_VEVENT_COMPONENT); | 1948 | c = icalcomponent_get_first_component(calendar,ICAL_VEVENT_COMPONENT); |
1949 | while (c) { | 1949 | while (c) { |
1950 | // kdDebug(5800) << "----Event found" << endl; | 1950 | // kdDebug(5800) << "----Event found" << endl; |
1951 | Event *event = readEvent(c); | 1951 | Event *event = readEvent(c); |
1952 | if (!cal->event(event->uid())) cal->addEvent(event); | 1952 | if (!cal->event(event->uid())) cal->addEvent(event); |
1953 | c = icalcomponent_get_next_component(calendar,ICAL_VEVENT_COMPONENT); | 1953 | c = icalcomponent_get_next_component(calendar,ICAL_VEVENT_COMPONENT); |
1954 | } | 1954 | } |
1955 | 1955 | ||
1956 | // Iterate through all journals | 1956 | // Iterate through all journals |
1957 | c = icalcomponent_get_first_component(calendar,ICAL_VJOURNAL_COMPONENT); | 1957 | c = icalcomponent_get_first_component(calendar,ICAL_VJOURNAL_COMPONENT); |
1958 | while (c) { | 1958 | while (c) { |
1959 | // kdDebug(5800) << "----Journal found" << endl; | 1959 | // kdDebug(5800) << "----Journal found" << endl; |
1960 | Journal *journal = readJournal(c); | 1960 | Journal *journal = readJournal(c); |
1961 | if (!cal->journal(journal->uid())) cal->addJournal(journal); | 1961 | if (!cal->journal(journal->uid())) cal->addJournal(journal); |
1962 | c = icalcomponent_get_next_component(calendar,ICAL_VJOURNAL_COMPONENT); | 1962 | c = icalcomponent_get_next_component(calendar,ICAL_VJOURNAL_COMPONENT); |
1963 | } | 1963 | } |
1964 | 1964 | ||
1965 | #if 0 | 1965 | #if 0 |
1966 | initPropIterator(&i, vcal); | 1966 | initPropIterator(&i, vcal); |
1967 | 1967 | ||
1968 | // go through all the vobjects in the vcal | 1968 | // go through all the vobjects in the vcal |
1969 | while (moreIteration(&i)) { | 1969 | while (moreIteration(&i)) { |
1970 | curVO = nextVObject(&i); | 1970 | curVO = nextVObject(&i); |
1971 | 1971 | ||
1972 | /************************************************************************/ | 1972 | /************************************************************************/ |
1973 | 1973 | ||
1974 | // now, check to see that the object is an event or todo. | 1974 | // now, check to see that the object is an event or todo. |
1975 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { | 1975 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { |
1976 | 1976 | ||
1977 | if ((curVOProp = isAPropertyOf(curVO, KPilotStatusProp)) != 0) { | 1977 | if ((curVOProp = isAPropertyOf(curVO, KPilotStatusProp)) != 0) { |
1978 | char *s; | 1978 | char *s; |
1979 | s = fakeCString(vObjectUStringZValue(curVOProp)); | 1979 | s = fakeCString(vObjectUStringZValue(curVOProp)); |
1980 | // check to see if event was deleted by the kpilot conduit | 1980 | // check to see if event was deleted by the kpilot conduit |
1981 | if (atoi(s) == Event::SYNCDEL) { | 1981 | if (atoi(s) == Event::SYNCDEL) { |
1982 | deleteStr(s); | 1982 | deleteStr(s); |
1983 | goto SKIP; | 1983 | goto SKIP; |
1984 | } | 1984 | } |
1985 | deleteStr(s); | 1985 | deleteStr(s); |
1986 | } | 1986 | } |
1987 | 1987 | ||
1988 | // this code checks to see if we are trying to read in an event | 1988 | // this code checks to see if we are trying to read in an event |
1989 | // that we already find to be in the calendar. If we find this | 1989 | // that we already find to be in the calendar. If we find this |
1990 | // to be the case, we skip the event. | 1990 | // to be the case, we skip the event. |
1991 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { | 1991 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { |
1992 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); | 1992 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); |
1993 | QString tmpStr(s); | 1993 | QString tmpStr(s); |
1994 | deleteStr(s); | 1994 | deleteStr(s); |
1995 | 1995 | ||
1996 | if (cal->event(tmpStr)) { | 1996 | if (cal->event(tmpStr)) { |
1997 | goto SKIP; | 1997 | goto SKIP; |
1998 | } | 1998 | } |
1999 | if (cal->todo(tmpStr)) { | 1999 | if (cal->todo(tmpStr)) { |
2000 | goto SKIP; | 2000 | goto SKIP; |
2001 | } | 2001 | } |
2002 | } | 2002 | } |
2003 | 2003 | ||
2004 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && | 2004 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && |
2005 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { | 2005 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { |
2006 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; | 2006 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; |
2007 | goto SKIP; | 2007 | goto SKIP; |
2008 | } | 2008 | } |
2009 | 2009 | ||
2010 | anEvent = VEventToEvent(curVO); | 2010 | anEvent = VEventToEvent(curVO); |
2011 | // we now use addEvent instead of insertEvent so that the | 2011 | // we now use addEvent instead of insertEvent so that the |
2012 | // signal/slot get connected. | 2012 | // signal/slot get connected. |
2013 | if (anEvent) | 2013 | if (anEvent) |
2014 | cal->addEvent(anEvent); | 2014 | cal->addEvent(anEvent); |
2015 | else { | 2015 | else { |
2016 | // some sort of error must have occurred while in translation. | 2016 | // some sort of error must have occurred while in translation. |
2017 | goto SKIP; | 2017 | goto SKIP; |
2018 | } | 2018 | } |
2019 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { | 2019 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { |
2020 | anEvent = VTodoToEvent(curVO); | 2020 | anEvent = VTodoToEvent(curVO); |
2021 | cal->addTodo(anEvent); | 2021 | cal->addTodo(anEvent); |
2022 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || | 2022 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || |
2023 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || | 2023 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || |
2024 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { | 2024 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { |
2025 | // do nothing, we know these properties and we want to skip them. | 2025 | // do nothing, we know these properties and we want to skip them. |
2026 | // we have either already processed them or are ignoring them. | 2026 | // we have either already processed them or are ignoring them. |
2027 | ; | 2027 | ; |
2028 | } else { | 2028 | } else { |
2029 | ; | 2029 | ; |
2030 | } | 2030 | } |
2031 | SKIP: | 2031 | SKIP: |
2032 | ; | 2032 | ; |
2033 | } // while | 2033 | } // while |
2034 | #endif | 2034 | #endif |
2035 | 2035 | ||
2036 | // Post-Process list of events with relations, put Event objects in relation | 2036 | // Post-Process list of events with relations, put Event objects in relation |
2037 | Event *ev; | 2037 | Event *ev; |
2038 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { | 2038 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { |
2039 | ev->setRelatedTo(cal->event(ev->relatedToUid())); | 2039 | Incidence * inc = cal->event(ev->relatedToUid()); |
2040 | if ( inc ) | ||
2041 | ev->setRelatedTo( inc ); | ||
2040 | } | 2042 | } |
2041 | Todo *todo; | 2043 | Todo *todo; |
2042 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { | 2044 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { |
2043 | todo->setRelatedTo(cal->todo(todo->relatedToUid())); | 2045 | Incidence * inc = cal->todo(todo->relatedToUid()); |
2046 | if ( inc ) | ||
2047 | todo->setRelatedTo( inc ); | ||
2044 | } | 2048 | } |
2045 | 2049 | ||
2046 | return true; | 2050 | return true; |
2047 | } | 2051 | } |
2048 | 2052 | ||
2049 | QString ICalFormatImpl::extractErrorProperty(icalcomponent *c) | 2053 | QString ICalFormatImpl::extractErrorProperty(icalcomponent *c) |
2050 | { | 2054 | { |
2051 | // kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " | 2055 | // kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " |
2052 | // << icalcomponent_as_ical_string(c) << endl; | 2056 | // << icalcomponent_as_ical_string(c) << endl; |
2053 | 2057 | ||
2054 | QString errorMessage; | 2058 | QString errorMessage; |
2055 | 2059 | ||
2056 | icalproperty *error; | 2060 | icalproperty *error; |
2057 | error = icalcomponent_get_first_property(c,ICAL_XLICERROR_PROPERTY); | 2061 | error = icalcomponent_get_first_property(c,ICAL_XLICERROR_PROPERTY); |
2058 | while(error) { | 2062 | while(error) { |
2059 | errorMessage += icalproperty_get_xlicerror(error); | 2063 | errorMessage += icalproperty_get_xlicerror(error); |
2060 | errorMessage += "\n"; | 2064 | errorMessage += "\n"; |
2061 | error = icalcomponent_get_next_property(c,ICAL_XLICERROR_PROPERTY); | 2065 | error = icalcomponent_get_next_property(c,ICAL_XLICERROR_PROPERTY); |
2062 | } | 2066 | } |
2063 | 2067 | ||
2064 | // kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " << errorMessage << endl; | 2068 | // kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " << errorMessage << endl; |
2065 | 2069 | ||
2066 | return errorMessage; | 2070 | return errorMessage; |
2067 | } | 2071 | } |
2068 | 2072 | ||
2069 | void ICalFormatImpl::dumpIcalRecurrence(icalrecurrencetype r) | 2073 | void ICalFormatImpl::dumpIcalRecurrence(icalrecurrencetype r) |
2070 | { | 2074 | { |
2071 | int i; | 2075 | int i; |
2072 | 2076 | ||
2073 | 2077 | ||
2074 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 2078 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
2075 | int index = 0; | 2079 | int index = 0; |
2076 | QString out = " By Day: "; | 2080 | QString out = " By Day: "; |
2077 | while((i = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 2081 | while((i = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
2078 | out.append(QString::number(i) + " "); | 2082 | out.append(QString::number(i) + " "); |
2079 | } | 2083 | } |
2080 | } | 2084 | } |
2081 | if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 2085 | if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
2082 | int index = 0; | 2086 | int index = 0; |
2083 | QString out = " By Month Day: "; | 2087 | QString out = " By Month Day: "; |
2084 | while((i = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 2088 | while((i = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
2085 | out.append(QString::number(i) + " "); | 2089 | out.append(QString::number(i) + " "); |
2086 | } | 2090 | } |
2087 | } | 2091 | } |
2088 | if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 2092 | if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
2089 | int index = 0; | 2093 | int index = 0; |
2090 | QString out = " By Year Day: "; | 2094 | QString out = " By Year Day: "; |
2091 | while((i = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 2095 | while((i = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
2092 | out.append(QString::number(i) + " "); | 2096 | out.append(QString::number(i) + " "); |
2093 | } | 2097 | } |
2094 | } | 2098 | } |
2095 | if (r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 2099 | if (r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
2096 | int index = 0; | 2100 | int index = 0; |
2097 | QString out = " By Month: "; | 2101 | QString out = " By Month: "; |
2098 | while((i = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 2102 | while((i = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
2099 | out.append(QString::number(i) + " "); | 2103 | out.append(QString::number(i) + " "); |
2100 | } | 2104 | } |
2101 | } | 2105 | } |
2102 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 2106 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
2103 | int index = 0; | 2107 | int index = 0; |
2104 | QString out = " By Set Pos: "; | 2108 | QString out = " By Set Pos: "; |
2105 | while((i = r.by_set_pos[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 2109 | while((i = r.by_set_pos[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
2106 | out.append(QString::number(i) + " "); | 2110 | out.append(QString::number(i) + " "); |
2107 | } | 2111 | } |
2108 | } | 2112 | } |
2109 | } | 2113 | } |
2110 | 2114 | ||
2111 | icalcomponent *ICalFormatImpl::createScheduleComponent(IncidenceBase *incidence, | 2115 | icalcomponent *ICalFormatImpl::createScheduleComponent(IncidenceBase *incidence, |
2112 | Scheduler::Method method) | 2116 | Scheduler::Method method) |
2113 | { | 2117 | { |
2114 | icalcomponent *message = createCalendarComponent(); | 2118 | icalcomponent *message = createCalendarComponent(); |
2115 | 2119 | ||
2116 | icalproperty_method icalmethod = ICAL_METHOD_NONE; | 2120 | icalproperty_method icalmethod = ICAL_METHOD_NONE; |
2117 | 2121 | ||
2118 | switch (method) { | 2122 | switch (method) { |
2119 | case Scheduler::Publish: | 2123 | case Scheduler::Publish: |
2120 | icalmethod = ICAL_METHOD_PUBLISH; | 2124 | icalmethod = ICAL_METHOD_PUBLISH; |
2121 | break; | 2125 | break; |
2122 | case Scheduler::Request: | 2126 | case Scheduler::Request: |
2123 | icalmethod = ICAL_METHOD_REQUEST; | 2127 | icalmethod = ICAL_METHOD_REQUEST; |
2124 | break; | 2128 | break; |
2125 | case Scheduler::Refresh: | 2129 | case Scheduler::Refresh: |
2126 | icalmethod = ICAL_METHOD_REFRESH; | 2130 | icalmethod = ICAL_METHOD_REFRESH; |
2127 | break; | 2131 | break; |
2128 | case Scheduler::Cancel: | 2132 | case Scheduler::Cancel: |
2129 | icalmethod = ICAL_METHOD_CANCEL; | 2133 | icalmethod = ICAL_METHOD_CANCEL; |
2130 | break; | 2134 | break; |
2131 | case Scheduler::Add: | 2135 | case Scheduler::Add: |
2132 | icalmethod = ICAL_METHOD_ADD; | 2136 | icalmethod = ICAL_METHOD_ADD; |
2133 | break; | 2137 | break; |
2134 | case Scheduler::Reply: | 2138 | case Scheduler::Reply: |
2135 | icalmethod = ICAL_METHOD_REPLY; | 2139 | icalmethod = ICAL_METHOD_REPLY; |
2136 | break; | 2140 | break; |
2137 | case Scheduler::Counter: | 2141 | case Scheduler::Counter: |
2138 | icalmethod = ICAL_METHOD_COUNTER; | 2142 | icalmethod = ICAL_METHOD_COUNTER; |
2139 | break; | 2143 | break; |
2140 | case Scheduler::Declinecounter: | 2144 | case Scheduler::Declinecounter: |
2141 | icalmethod = ICAL_METHOD_DECLINECOUNTER; | 2145 | icalmethod = ICAL_METHOD_DECLINECOUNTER; |
2142 | break; | 2146 | break; |
2143 | default: | 2147 | default: |
2144 | 2148 | ||
2145 | return message; | 2149 | return message; |
2146 | } | 2150 | } |
2147 | 2151 | ||
2148 | icalcomponent_add_property(message,icalproperty_new_method(icalmethod)); | 2152 | icalcomponent_add_property(message,icalproperty_new_method(icalmethod)); |
2149 | 2153 | ||
2150 | // TODO: check, if dynamic cast is required | 2154 | // TODO: check, if dynamic cast is required |
2151 | if(incidence->type() == "Todo") { | 2155 | if(incidence->type() == "Todo") { |
2152 | Todo *todo = static_cast<Todo *>(incidence); | 2156 | Todo *todo = static_cast<Todo *>(incidence); |
2153 | icalcomponent_add_component(message,writeTodo(todo)); | 2157 | icalcomponent_add_component(message,writeTodo(todo)); |
2154 | } | 2158 | } |
2155 | if(incidence->type() == "Event") { | 2159 | if(incidence->type() == "Event") { |
2156 | Event *event = static_cast<Event *>(incidence); | 2160 | Event *event = static_cast<Event *>(incidence); |
2157 | icalcomponent_add_component(message,writeEvent(event)); | 2161 | icalcomponent_add_component(message,writeEvent(event)); |
2158 | } | 2162 | } |
2159 | if(incidence->type() == "FreeBusy") { | 2163 | if(incidence->type() == "FreeBusy") { |
2160 | FreeBusy *freebusy = static_cast<FreeBusy *>(incidence); | 2164 | FreeBusy *freebusy = static_cast<FreeBusy *>(incidence); |
2161 | icalcomponent_add_component(message,writeFreeBusy(freebusy, method)); | 2165 | icalcomponent_add_component(message,writeFreeBusy(freebusy, method)); |
2162 | } | 2166 | } |
2163 | 2167 | ||
2164 | return message; | 2168 | return message; |
2165 | } | 2169 | } |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index a312ba5..6bca12c 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -137,513 +137,518 @@ bool Incidence::cancelled() const | |||
137 | { | 137 | { |
138 | return mCancelled; | 138 | return mCancelled; |
139 | } | 139 | } |
140 | void Incidence::setCancelled( bool b ) | 140 | void Incidence::setCancelled( bool b ) |
141 | { | 141 | { |
142 | mCancelled = b; | 142 | mCancelled = b; |
143 | updated(); | 143 | updated(); |
144 | } | 144 | } |
145 | bool Incidence::hasStartDate() const | 145 | bool Incidence::hasStartDate() const |
146 | { | 146 | { |
147 | return mHasStartDate; | 147 | return mHasStartDate; |
148 | } | 148 | } |
149 | 149 | ||
150 | void Incidence::setHasStartDate(bool f) | 150 | void Incidence::setHasStartDate(bool f) |
151 | { | 151 | { |
152 | if (mReadOnly) return; | 152 | if (mReadOnly) return; |
153 | mHasStartDate = f; | 153 | mHasStartDate = f; |
154 | updated(); | 154 | updated(); |
155 | } | 155 | } |
156 | 156 | ||
157 | // A string comparison that considers that null and empty are the same | 157 | // A string comparison that considers that null and empty are the same |
158 | static bool stringCompare( const QString& s1, const QString& s2 ) | 158 | static bool stringCompare( const QString& s1, const QString& s2 ) |
159 | { | 159 | { |
160 | if ( s1.isEmpty() && s2.isEmpty() ) | 160 | if ( s1.isEmpty() && s2.isEmpty() ) |
161 | return true; | 161 | return true; |
162 | return s1 == s2; | 162 | return s1 == s2; |
163 | } | 163 | } |
164 | 164 | ||
165 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | 165 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) |
166 | { | 166 | { |
167 | 167 | ||
168 | if( i1.alarms().count() != i2.alarms().count() ) { | 168 | if( i1.alarms().count() != i2.alarms().count() ) { |
169 | return false; // no need to check further | 169 | return false; // no need to check further |
170 | } | 170 | } |
171 | if ( i1.alarms().count() > 0 ) { | 171 | if ( i1.alarms().count() > 0 ) { |
172 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) | 172 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) |
173 | { | 173 | { |
174 | qDebug("alarm not equal "); | 174 | qDebug("alarm not equal "); |
175 | return false; | 175 | return false; |
176 | } | 176 | } |
177 | } | 177 | } |
178 | #if 0 | 178 | #if 0 |
179 | QPtrListIterator<Alarm> a1( i1.alarms() ); | 179 | QPtrListIterator<Alarm> a1( i1.alarms() ); |
180 | QPtrListIterator<Alarm> a2( i2.alarms() ); | 180 | QPtrListIterator<Alarm> a2( i2.alarms() ); |
181 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { | 181 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { |
182 | if( *a1.current() == *a2.current() ) { | 182 | if( *a1.current() == *a2.current() ) { |
183 | continue; | 183 | continue; |
184 | } | 184 | } |
185 | else { | 185 | else { |
186 | return false; | 186 | return false; |
187 | } | 187 | } |
188 | } | 188 | } |
189 | #endif | 189 | #endif |
190 | 190 | ||
191 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { | 191 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { |
192 | if ( i1.hasRecurrenceID() ) { | 192 | if ( i1.hasRecurrenceID() ) { |
193 | if ( i1.recurrenceID() != i2.recurrenceID() ) | 193 | if ( i1.recurrenceID() != i2.recurrenceID() ) |
194 | return false; | 194 | return false; |
195 | } | 195 | } |
196 | 196 | ||
197 | } else { | 197 | } else { |
198 | return false; | 198 | return false; |
199 | } | 199 | } |
200 | 200 | ||
201 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) | 201 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) |
202 | return false; | 202 | return false; |
203 | if ( i1.hasStartDate() == i2.hasStartDate() ) { | 203 | if ( i1.hasStartDate() == i2.hasStartDate() ) { |
204 | if ( i1.hasStartDate() ) { | 204 | if ( i1.hasStartDate() ) { |
205 | if ( i1.dtStart() != i2.dtStart() ) | 205 | if ( i1.dtStart() != i2.dtStart() ) |
206 | return false; | 206 | return false; |
207 | } | 207 | } |
208 | } else { | 208 | } else { |
209 | return false; | 209 | return false; |
210 | } | 210 | } |
211 | if (!( *i1.recurrence() == *i2.recurrence()) ) { | 211 | if (!( *i1.recurrence() == *i2.recurrence()) ) { |
212 | qDebug("recurrence is NOT equal "); | 212 | qDebug("recurrence is NOT equal "); |
213 | return false; | 213 | return false; |
214 | } | 214 | } |
215 | return | 215 | return |
216 | // i1.created() == i2.created() && | 216 | // i1.created() == i2.created() && |
217 | stringCompare( i1.description(), i2.description() ) && | 217 | stringCompare( i1.description(), i2.description() ) && |
218 | stringCompare( i1.summary(), i2.summary() ) && | 218 | stringCompare( i1.summary(), i2.summary() ) && |
219 | i1.categories() == i2.categories() && | 219 | i1.categories() == i2.categories() && |
220 | // no need to compare mRelatedTo | 220 | // no need to compare mRelatedTo |
221 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && | 221 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && |
222 | // i1.relations() == i2.relations() && | 222 | // i1.relations() == i2.relations() && |
223 | i1.exDates() == i2.exDates() && | 223 | i1.exDates() == i2.exDates() && |
224 | i1.attachments() == i2.attachments() && | 224 | i1.attachments() == i2.attachments() && |
225 | i1.resources() == i2.resources() && | 225 | i1.resources() == i2.resources() && |
226 | i1.secrecy() == i2.secrecy() && | 226 | i1.secrecy() == i2.secrecy() && |
227 | i1.priority() == i2.priority() && | 227 | i1.priority() == i2.priority() && |
228 | i1.cancelled() == i2.cancelled() && | 228 | i1.cancelled() == i2.cancelled() && |
229 | stringCompare( i1.location(), i2.location() ); | 229 | stringCompare( i1.location(), i2.location() ); |
230 | } | 230 | } |
231 | 231 | ||
232 | Incidence* Incidence::recreateCloneException( QDate d ) | 232 | Incidence* Incidence::recreateCloneException( QDate d ) |
233 | { | 233 | { |
234 | Incidence* newInc = clone(); | 234 | Incidence* newInc = clone(); |
235 | newInc->recreate(); | 235 | newInc->recreate(); |
236 | if ( doesRecur() ) { | 236 | if ( doesRecur() ) { |
237 | addExDate( d ); | 237 | addExDate( d ); |
238 | newInc->recurrence()->unsetRecurs(); | 238 | newInc->recurrence()->unsetRecurs(); |
239 | if ( type() == "Event") { | 239 | if ( type() == "Event") { |
240 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); | 240 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); |
241 | QTime tim = dtStart().time(); | 241 | QTime tim = dtStart().time(); |
242 | newInc->setDtStart( QDateTime(d, tim) ); | 242 | newInc->setDtStart( QDateTime(d, tim) ); |
243 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 243 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
244 | } else { | 244 | } else { |
245 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); | 245 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); |
246 | QTime tim = ((Todo*)this)->dtDue().time(); | 246 | QTime tim = ((Todo*)this)->dtDue().time(); |
247 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); | 247 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); |
248 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); | 248 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); |
249 | ((Todo*)this)->setRecurDates(); | 249 | ((Todo*)this)->setRecurDates(); |
250 | } | 250 | } |
251 | newInc->setExDates( DateList () ); | 251 | newInc->setExDates( DateList () ); |
252 | } | 252 | } |
253 | return newInc; | 253 | return newInc; |
254 | } | 254 | } |
255 | 255 | ||
256 | void Incidence::recreate() | 256 | void Incidence::recreate() |
257 | { | 257 | { |
258 | setCreated(QDateTime::currentDateTime()); | 258 | setCreated(QDateTime::currentDateTime()); |
259 | 259 | ||
260 | setUid(CalFormat::createUniqueId()); | 260 | setUid(CalFormat::createUniqueId()); |
261 | 261 | ||
262 | setRevision(0); | 262 | setRevision(0); |
263 | setIDStr( ":" ); | 263 | setIDStr( ":" ); |
264 | setLastModified(QDateTime::currentDateTime()); | 264 | setLastModified(QDateTime::currentDateTime()); |
265 | } | 265 | } |
266 | 266 | ||
267 | void Incidence::setReadOnly( bool readOnly ) | 267 | void Incidence::setReadOnly( bool readOnly ) |
268 | { | 268 | { |
269 | IncidenceBase::setReadOnly( readOnly ); | 269 | IncidenceBase::setReadOnly( readOnly ); |
270 | recurrence()->setRecurReadOnly( readOnly); | 270 | recurrence()->setRecurReadOnly( readOnly); |
271 | } | 271 | } |
272 | 272 | ||
273 | void Incidence::setCreated(QDateTime created) | 273 | void Incidence::setCreated(QDateTime created) |
274 | { | 274 | { |
275 | if (mReadOnly) return; | 275 | if (mReadOnly) return; |
276 | mCreated = getEvenTime(created); | 276 | mCreated = getEvenTime(created); |
277 | } | 277 | } |
278 | 278 | ||
279 | QDateTime Incidence::created() const | 279 | QDateTime Incidence::created() const |
280 | { | 280 | { |
281 | return mCreated; | 281 | return mCreated; |
282 | } | 282 | } |
283 | 283 | ||
284 | void Incidence::setRevision(int rev) | 284 | void Incidence::setRevision(int rev) |
285 | { | 285 | { |
286 | if (mReadOnly) return; | 286 | if (mReadOnly) return; |
287 | mRevision = rev; | 287 | mRevision = rev; |
288 | 288 | ||
289 | updated(); | 289 | updated(); |
290 | } | 290 | } |
291 | 291 | ||
292 | int Incidence::revision() const | 292 | int Incidence::revision() const |
293 | { | 293 | { |
294 | return mRevision; | 294 | return mRevision; |
295 | } | 295 | } |
296 | 296 | ||
297 | void Incidence::setDtStart(const QDateTime &dtStart) | 297 | void Incidence::setDtStart(const QDateTime &dtStart) |
298 | { | 298 | { |
299 | 299 | ||
300 | QDateTime dt = getEvenTime(dtStart); | 300 | QDateTime dt = getEvenTime(dtStart); |
301 | recurrence()->setRecurStart( dt); | 301 | recurrence()->setRecurStart( dt); |
302 | IncidenceBase::setDtStart( dt ); | 302 | IncidenceBase::setDtStart( dt ); |
303 | } | 303 | } |
304 | 304 | ||
305 | void Incidence::setDescription(const QString &description) | 305 | void Incidence::setDescription(const QString &description) |
306 | { | 306 | { |
307 | if (mReadOnly) return; | 307 | if (mReadOnly) return; |
308 | mDescription = description; | 308 | mDescription = description; |
309 | updated(); | 309 | updated(); |
310 | } | 310 | } |
311 | 311 | ||
312 | QString Incidence::description() const | 312 | QString Incidence::description() const |
313 | { | 313 | { |
314 | return mDescription; | 314 | return mDescription; |
315 | } | 315 | } |
316 | 316 | ||
317 | 317 | ||
318 | void Incidence::setSummary(const QString &summary) | 318 | void Incidence::setSummary(const QString &summary) |
319 | { | 319 | { |
320 | if (mReadOnly) return; | 320 | if (mReadOnly) return; |
321 | mSummary = summary; | 321 | mSummary = summary; |
322 | updated(); | 322 | updated(); |
323 | } | 323 | } |
324 | 324 | ||
325 | QString Incidence::summary() const | 325 | QString Incidence::summary() const |
326 | { | 326 | { |
327 | return mSummary; | 327 | return mSummary; |
328 | } | 328 | } |
329 | void Incidence::checkCategories() | 329 | void Incidence::checkCategories() |
330 | { | 330 | { |
331 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); | 331 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); |
332 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); | 332 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); |
333 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); | 333 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); |
334 | } | 334 | } |
335 | 335 | ||
336 | void Incidence::setCategories(const QStringList &categories) | 336 | void Incidence::setCategories(const QStringList &categories) |
337 | { | 337 | { |
338 | if (mReadOnly) return; | 338 | if (mReadOnly) return; |
339 | mCategories = categories; | 339 | mCategories = categories; |
340 | checkCategories(); | 340 | checkCategories(); |
341 | updated(); | 341 | updated(); |
342 | } | 342 | } |
343 | 343 | ||
344 | // TODO: remove setCategories(QString) function | 344 | // TODO: remove setCategories(QString) function |
345 | void Incidence::setCategories(const QString &catStr) | 345 | void Incidence::setCategories(const QString &catStr) |
346 | { | 346 | { |
347 | if (mReadOnly) return; | 347 | if (mReadOnly) return; |
348 | mCategories.clear(); | 348 | mCategories.clear(); |
349 | 349 | ||
350 | if (catStr.isEmpty()) return; | 350 | if (catStr.isEmpty()) return; |
351 | 351 | ||
352 | mCategories = QStringList::split(",",catStr); | 352 | mCategories = QStringList::split(",",catStr); |
353 | 353 | ||
354 | QStringList::Iterator it; | 354 | QStringList::Iterator it; |
355 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 355 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
356 | *it = (*it).stripWhiteSpace(); | 356 | *it = (*it).stripWhiteSpace(); |
357 | } | 357 | } |
358 | checkCategories(); | 358 | checkCategories(); |
359 | updated(); | 359 | updated(); |
360 | } | 360 | } |
361 | 361 | ||
362 | QStringList Incidence::categories() const | 362 | QStringList Incidence::categories() const |
363 | { | 363 | { |
364 | return mCategories; | 364 | return mCategories; |
365 | } | 365 | } |
366 | 366 | ||
367 | QString Incidence::categoriesStr() | 367 | QString Incidence::categoriesStr() |
368 | { | 368 | { |
369 | return mCategories.join(","); | 369 | return mCategories.join(","); |
370 | } | 370 | } |
371 | 371 | ||
372 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 372 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
373 | { | 373 | { |
374 | if (mReadOnly) return; | 374 | if (mReadOnly) return; |
375 | mRelatedToUid = relatedToUid; | 375 | mRelatedToUid = relatedToUid; |
376 | } | 376 | } |
377 | 377 | ||
378 | QString Incidence::relatedToUid() const | 378 | QString Incidence::relatedToUid() const |
379 | { | 379 | { |
380 | return mRelatedToUid; | 380 | return mRelatedToUid; |
381 | } | 381 | } |
382 | 382 | ||
383 | void Incidence::setRelatedTo(Incidence *relatedTo) | 383 | void Incidence::setRelatedTo(Incidence *relatedTo) |
384 | { | 384 | { |
385 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 385 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
386 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 386 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
387 | if (mReadOnly || mRelatedTo == relatedTo) return; | 387 | if (mReadOnly || mRelatedTo == relatedTo) return; |
388 | if(mRelatedTo) { | 388 | if(mRelatedTo) { |
389 | // updated(); | 389 | // updated(); |
390 | mRelatedTo->removeRelation(this); | 390 | mRelatedTo->removeRelation(this); |
391 | } | 391 | } |
392 | mRelatedTo = relatedTo; | 392 | mRelatedTo = relatedTo; |
393 | if (mRelatedTo) mRelatedTo->addRelation(this); | 393 | if (mRelatedTo) { |
394 | mRelatedTo->addRelation(this); | ||
395 | mRelatedToUid = mRelatedTo->uid(); | ||
396 | } else { | ||
397 | mRelatedToUid = ""; | ||
398 | } | ||
394 | } | 399 | } |
395 | 400 | ||
396 | Incidence *Incidence::relatedTo() const | 401 | Incidence *Incidence::relatedTo() const |
397 | { | 402 | { |
398 | return mRelatedTo; | 403 | return mRelatedTo; |
399 | } | 404 | } |
400 | 405 | ||
401 | QPtrList<Incidence> Incidence::relations() const | 406 | QPtrList<Incidence> Incidence::relations() const |
402 | { | 407 | { |
403 | return mRelations; | 408 | return mRelations; |
404 | } | 409 | } |
405 | 410 | ||
406 | void Incidence::addRelation(Incidence *event) | 411 | void Incidence::addRelation(Incidence *event) |
407 | { | 412 | { |
408 | if( mRelations.findRef( event ) == -1 ) { | 413 | if( mRelations.findRef( event ) == -1 ) { |
409 | mRelations.append(event); | 414 | mRelations.append(event); |
410 | //updated(); | 415 | //updated(); |
411 | } | 416 | } |
412 | } | 417 | } |
413 | 418 | ||
414 | void Incidence::removeRelation(Incidence *event) | 419 | void Incidence::removeRelation(Incidence *event) |
415 | { | 420 | { |
416 | 421 | ||
417 | mRelations.removeRef(event); | 422 | mRelations.removeRef(event); |
418 | 423 | ||
419 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 424 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
420 | } | 425 | } |
421 | 426 | ||
422 | bool Incidence::recursOn(const QDate &qd) const | 427 | bool Incidence::recursOn(const QDate &qd) const |
423 | { | 428 | { |
424 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; | 429 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; |
425 | else return false; | 430 | else return false; |
426 | } | 431 | } |
427 | 432 | ||
428 | void Incidence::setExDates(const DateList &exDates) | 433 | void Incidence::setExDates(const DateList &exDates) |
429 | { | 434 | { |
430 | if (mReadOnly) return; | 435 | if (mReadOnly) return; |
431 | mExDates = exDates; | 436 | mExDates = exDates; |
432 | 437 | ||
433 | recurrence()->setRecurExDatesCount(mExDates.count()); | 438 | recurrence()->setRecurExDatesCount(mExDates.count()); |
434 | 439 | ||
435 | updated(); | 440 | updated(); |
436 | } | 441 | } |
437 | 442 | ||
438 | void Incidence::addExDate(const QDate &date) | 443 | void Incidence::addExDate(const QDate &date) |
439 | { | 444 | { |
440 | if (mReadOnly) return; | 445 | if (mReadOnly) return; |
441 | mExDates.append(date); | 446 | mExDates.append(date); |
442 | 447 | ||
443 | recurrence()->setRecurExDatesCount(mExDates.count()); | 448 | recurrence()->setRecurExDatesCount(mExDates.count()); |
444 | 449 | ||
445 | updated(); | 450 | updated(); |
446 | } | 451 | } |
447 | 452 | ||
448 | DateList Incidence::exDates() const | 453 | DateList Incidence::exDates() const |
449 | { | 454 | { |
450 | return mExDates; | 455 | return mExDates; |
451 | } | 456 | } |
452 | 457 | ||
453 | bool Incidence::isException(const QDate &date) const | 458 | bool Incidence::isException(const QDate &date) const |
454 | { | 459 | { |
455 | DateList::ConstIterator it; | 460 | DateList::ConstIterator it; |
456 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { | 461 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { |
457 | if ( (*it) == date ) { | 462 | if ( (*it) == date ) { |
458 | return true; | 463 | return true; |
459 | } | 464 | } |
460 | } | 465 | } |
461 | 466 | ||
462 | return false; | 467 | return false; |
463 | } | 468 | } |
464 | 469 | ||
465 | void Incidence::addAttachment(Attachment *attachment) | 470 | void Incidence::addAttachment(Attachment *attachment) |
466 | { | 471 | { |
467 | if (mReadOnly || !attachment) return; | 472 | if (mReadOnly || !attachment) return; |
468 | mAttachments.append(attachment); | 473 | mAttachments.append(attachment); |
469 | updated(); | 474 | updated(); |
470 | } | 475 | } |
471 | 476 | ||
472 | void Incidence::deleteAttachment(Attachment *attachment) | 477 | void Incidence::deleteAttachment(Attachment *attachment) |
473 | { | 478 | { |
474 | mAttachments.removeRef(attachment); | 479 | mAttachments.removeRef(attachment); |
475 | } | 480 | } |
476 | 481 | ||
477 | void Incidence::deleteAttachments(const QString& mime) | 482 | void Incidence::deleteAttachments(const QString& mime) |
478 | { | 483 | { |
479 | Attachment *at = mAttachments.first(); | 484 | Attachment *at = mAttachments.first(); |
480 | while (at) { | 485 | while (at) { |
481 | if (at->mimeType() == mime) | 486 | if (at->mimeType() == mime) |
482 | mAttachments.remove(); | 487 | mAttachments.remove(); |
483 | else | 488 | else |
484 | at = mAttachments.next(); | 489 | at = mAttachments.next(); |
485 | } | 490 | } |
486 | } | 491 | } |
487 | 492 | ||
488 | QPtrList<Attachment> Incidence::attachments() const | 493 | QPtrList<Attachment> Incidence::attachments() const |
489 | { | 494 | { |
490 | return mAttachments; | 495 | return mAttachments; |
491 | } | 496 | } |
492 | 497 | ||
493 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const | 498 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const |
494 | { | 499 | { |
495 | QPtrList<Attachment> attachments; | 500 | QPtrList<Attachment> attachments; |
496 | QPtrListIterator<Attachment> it( mAttachments ); | 501 | QPtrListIterator<Attachment> it( mAttachments ); |
497 | Attachment *at; | 502 | Attachment *at; |
498 | while ( (at = it.current()) ) { | 503 | while ( (at = it.current()) ) { |
499 | if (at->mimeType() == mime) | 504 | if (at->mimeType() == mime) |
500 | attachments.append(at); | 505 | attachments.append(at); |
501 | ++it; | 506 | ++it; |
502 | } | 507 | } |
503 | 508 | ||
504 | return attachments; | 509 | return attachments; |
505 | } | 510 | } |
506 | 511 | ||
507 | void Incidence::setResources(const QStringList &resources) | 512 | void Incidence::setResources(const QStringList &resources) |
508 | { | 513 | { |
509 | if (mReadOnly) return; | 514 | if (mReadOnly) return; |
510 | mResources = resources; | 515 | mResources = resources; |
511 | updated(); | 516 | updated(); |
512 | } | 517 | } |
513 | 518 | ||
514 | QStringList Incidence::resources() const | 519 | QStringList Incidence::resources() const |
515 | { | 520 | { |
516 | return mResources; | 521 | return mResources; |
517 | } | 522 | } |
518 | 523 | ||
519 | 524 | ||
520 | void Incidence::setPriority(int priority) | 525 | void Incidence::setPriority(int priority) |
521 | { | 526 | { |
522 | if (mReadOnly) return; | 527 | if (mReadOnly) return; |
523 | mPriority = priority; | 528 | mPriority = priority; |
524 | updated(); | 529 | updated(); |
525 | } | 530 | } |
526 | 531 | ||
527 | int Incidence::priority() const | 532 | int Incidence::priority() const |
528 | { | 533 | { |
529 | return mPriority; | 534 | return mPriority; |
530 | } | 535 | } |
531 | 536 | ||
532 | void Incidence::setSecrecy(int sec) | 537 | void Incidence::setSecrecy(int sec) |
533 | { | 538 | { |
534 | if (mReadOnly) return; | 539 | if (mReadOnly) return; |
535 | mSecrecy = sec; | 540 | mSecrecy = sec; |
536 | updated(); | 541 | updated(); |
537 | } | 542 | } |
538 | 543 | ||
539 | int Incidence::secrecy() const | 544 | int Incidence::secrecy() const |
540 | { | 545 | { |
541 | return mSecrecy; | 546 | return mSecrecy; |
542 | } | 547 | } |
543 | 548 | ||
544 | QString Incidence::secrecyStr() const | 549 | QString Incidence::secrecyStr() const |
545 | { | 550 | { |
546 | return secrecyName(mSecrecy); | 551 | return secrecyName(mSecrecy); |
547 | } | 552 | } |
548 | 553 | ||
549 | QString Incidence::secrecyName(int secrecy) | 554 | QString Incidence::secrecyName(int secrecy) |
550 | { | 555 | { |
551 | switch (secrecy) { | 556 | switch (secrecy) { |
552 | case SecrecyPublic: | 557 | case SecrecyPublic: |
553 | return i18n("Public"); | 558 | return i18n("Public"); |
554 | break; | 559 | break; |
555 | case SecrecyPrivate: | 560 | case SecrecyPrivate: |
556 | return i18n("Private"); | 561 | return i18n("Private"); |
557 | break; | 562 | break; |
558 | case SecrecyConfidential: | 563 | case SecrecyConfidential: |
559 | return i18n("Confidential"); | 564 | return i18n("Confidential"); |
560 | break; | 565 | break; |
561 | default: | 566 | default: |
562 | return i18n("Undefined"); | 567 | return i18n("Undefined"); |
563 | break; | 568 | break; |
564 | } | 569 | } |
565 | } | 570 | } |
566 | 571 | ||
567 | QStringList Incidence::secrecyList() | 572 | QStringList Incidence::secrecyList() |
568 | { | 573 | { |
569 | QStringList list; | 574 | QStringList list; |
570 | list << secrecyName(SecrecyPublic); | 575 | list << secrecyName(SecrecyPublic); |
571 | list << secrecyName(SecrecyPrivate); | 576 | list << secrecyName(SecrecyPrivate); |
572 | list << secrecyName(SecrecyConfidential); | 577 | list << secrecyName(SecrecyConfidential); |
573 | 578 | ||
574 | return list; | 579 | return list; |
575 | } | 580 | } |
576 | 581 | ||
577 | 582 | ||
578 | QPtrList<Alarm> Incidence::alarms() const | 583 | QPtrList<Alarm> Incidence::alarms() const |
579 | { | 584 | { |
580 | return mAlarms; | 585 | return mAlarms; |
581 | } | 586 | } |
582 | 587 | ||
583 | Alarm* Incidence::newAlarm() | 588 | Alarm* Incidence::newAlarm() |
584 | { | 589 | { |
585 | Alarm* alarm = new Alarm(this); | 590 | Alarm* alarm = new Alarm(this); |
586 | mAlarms.append(alarm); | 591 | mAlarms.append(alarm); |
587 | // updated(); | 592 | // updated(); |
588 | return alarm; | 593 | return alarm; |
589 | } | 594 | } |
590 | 595 | ||
591 | void Incidence::addAlarm(Alarm *alarm) | 596 | void Incidence::addAlarm(Alarm *alarm) |
592 | { | 597 | { |
593 | mAlarms.append(alarm); | 598 | mAlarms.append(alarm); |
594 | updated(); | 599 | updated(); |
595 | } | 600 | } |
596 | 601 | ||
597 | void Incidence::removeAlarm(Alarm *alarm) | 602 | void Incidence::removeAlarm(Alarm *alarm) |
598 | { | 603 | { |
599 | mAlarms.removeRef(alarm); | 604 | mAlarms.removeRef(alarm); |
600 | updated(); | 605 | updated(); |
601 | } | 606 | } |
602 | 607 | ||
603 | void Incidence::clearAlarms() | 608 | void Incidence::clearAlarms() |
604 | { | 609 | { |
605 | mAlarms.clear(); | 610 | mAlarms.clear(); |
606 | updated(); | 611 | updated(); |
607 | } | 612 | } |
608 | 613 | ||
609 | bool Incidence::isAlarmEnabled() const | 614 | bool Incidence::isAlarmEnabled() const |
610 | { | 615 | { |
611 | Alarm* alarm; | 616 | Alarm* alarm; |
612 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 617 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
613 | if (alarm->enabled()) | 618 | if (alarm->enabled()) |
614 | return true; | 619 | return true; |
615 | } | 620 | } |
616 | return false; | 621 | return false; |
617 | } | 622 | } |
618 | 623 | ||
619 | Recurrence *Incidence::recurrence() const | 624 | Recurrence *Incidence::recurrence() const |
620 | { | 625 | { |
621 | return mRecurrence; | 626 | return mRecurrence; |
622 | } | 627 | } |
623 | void Incidence::setRecurrence( Recurrence * r) | 628 | void Incidence::setRecurrence( Recurrence * r) |
624 | { | 629 | { |
625 | delete mRecurrence; | 630 | delete mRecurrence; |
626 | mRecurrence = r; | 631 | mRecurrence = r; |
627 | } | 632 | } |
628 | 633 | ||
629 | void Incidence::setLocation(const QString &location) | 634 | void Incidence::setLocation(const QString &location) |
630 | { | 635 | { |
631 | if (mReadOnly) return; | 636 | if (mReadOnly) return; |
632 | mLocation = location; | 637 | mLocation = location; |
633 | updated(); | 638 | updated(); |
634 | } | 639 | } |
635 | 640 | ||
636 | QString Incidence::location() const | 641 | QString Incidence::location() const |
637 | { | 642 | { |
638 | return mLocation; | 643 | return mLocation; |
639 | } | 644 | } |
640 | 645 | ||
641 | ushort Incidence::doesRecur() const | 646 | ushort Incidence::doesRecur() const |
642 | { | 647 | { |
643 | if ( mRecurrence ) return mRecurrence->doesRecur(); | 648 | if ( mRecurrence ) return mRecurrence->doesRecur(); |
644 | else return Recurrence::rNone; | 649 | else return Recurrence::rNone; |
645 | } | 650 | } |
646 | 651 | ||
647 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const | 652 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const |
648 | { | 653 | { |
649 | QDateTime incidenceStart = dt; | 654 | QDateTime incidenceStart = dt; |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 8794f7a..7906046 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -1,361 +1,359 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <kglobalsettings.h> | 22 | #include <kglobalsettings.h> |
23 | #include <klocale.h> | 23 | #include <klocale.h> |
24 | #include <kdebug.h> | 24 | #include <kdebug.h> |
25 | #include <qregexp.h> | 25 | #include <qregexp.h> |
26 | 26 | ||
27 | #include "calendarlocal.h" | ||
28 | #include "icalformat.h" | ||
27 | #include "todo.h" | 29 | #include "todo.h" |
28 | 30 | ||
29 | using namespace KCal; | 31 | using namespace KCal; |
30 | 32 | ||
31 | Todo::Todo(): Incidence() | 33 | Todo::Todo(): Incidence() |
32 | { | 34 | { |
33 | // mStatus = TENTATIVE; | 35 | // mStatus = TENTATIVE; |
34 | 36 | ||
35 | mHasDueDate = false; | 37 | mHasDueDate = false; |
36 | setHasStartDate( false ); | 38 | setHasStartDate( false ); |
37 | mCompleted = getEvenTime(QDateTime::currentDateTime()); | 39 | mCompleted = getEvenTime(QDateTime::currentDateTime()); |
38 | mHasCompletedDate = false; | 40 | mHasCompletedDate = false; |
39 | mPercentComplete = 0; | 41 | mPercentComplete = 0; |
40 | mRunning = false; | 42 | mRunning = false; |
41 | mRunSaveTimer = 0; | 43 | mRunSaveTimer = 0; |
42 | } | 44 | } |
43 | 45 | ||
44 | Todo::Todo(const Todo &t) : Incidence(t) | 46 | Todo::Todo(const Todo &t) : Incidence(t) |
45 | { | 47 | { |
46 | mDtDue = t.mDtDue; | 48 | mDtDue = t.mDtDue; |
47 | mHasDueDate = t.mHasDueDate; | 49 | mHasDueDate = t.mHasDueDate; |
48 | mCompleted = t.mCompleted; | 50 | mCompleted = t.mCompleted; |
49 | mHasCompletedDate = t.mHasCompletedDate; | 51 | mHasCompletedDate = t.mHasCompletedDate; |
50 | mPercentComplete = t.mPercentComplete; | 52 | mPercentComplete = t.mPercentComplete; |
51 | mRunning = false; | 53 | mRunning = false; |
52 | mRunSaveTimer = 0; | 54 | mRunSaveTimer = 0; |
53 | } | 55 | } |
54 | 56 | ||
55 | Todo::~Todo() | 57 | Todo::~Todo() |
56 | { | 58 | { |
57 | setRunning( false ); | 59 | setRunning( false ); |
60 | qDebug("Todo::~Todo() "); | ||
58 | } | 61 | } |
59 | 62 | ||
60 | void Todo::setRunning( bool run ) | 63 | void Todo::setRunning( bool run ) |
61 | { | 64 | { |
62 | if ( run == mRunning ) | 65 | if ( run == mRunning ) |
63 | return; | 66 | return; |
64 | if ( !mRunSaveTimer ) { | 67 | if ( !mRunSaveTimer ) { |
65 | mRunSaveTimer = new QTimer ( this ); | 68 | mRunSaveTimer = new QTimer ( this ); |
66 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); | 69 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); |
67 | } | 70 | } |
68 | mRunning = run; | 71 | mRunning = run; |
69 | if ( mRunning ) { | 72 | if ( mRunning ) { |
70 | mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min | 73 | mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min |
71 | mRunStart = QDateTime::currentDateTime(); | 74 | mRunStart = QDateTime::currentDateTime(); |
72 | } else { | 75 | } else { |
73 | mRunSaveTimer->stop(); | 76 | mRunSaveTimer->stop(); |
74 | saveRunningInfoToFile(); | 77 | saveRunningInfoToFile(); |
75 | } | 78 | } |
76 | } | 79 | } |
77 | 80 | ||
78 | void Todo::saveRunningInfoToFile() | 81 | void Todo::saveRunningInfoToFile() |
79 | { | 82 | { |
80 | qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); | 83 | qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); |
81 | 84 | ||
82 | QString dir = KGlobalSettings::timeTrackerDir(); | 85 | QString dir = KGlobalSettings::timeTrackerDir(); |
83 | qDebug("%s ", dir.latin1()); | 86 | qDebug("%s ", dir.latin1()); |
84 | QString file = "%1-%2-%3-%4-%5-%6-%7.tt"; | 87 | QString file = "%1%2%3-%4%5%6-%7%8%9-"; |
85 | 88 | int runtime = mRunStart.secsTo( QDateTime::currentDateTime() ); | |
86 | file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ).arg( mRunStart.time().msec(), 3 ); | 89 | runtime = (runtime / 60) +1; |
90 | int h = runtime / 60; | ||
91 | int m = runtime % 60; | ||
92 | int d = h / 24; | ||
93 | h = h % 24; | ||
94 | file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ).arg( d,3 ).arg( h,2 ).arg( m,2 ); | ||
87 | file.replace ( QRegExp (" "), "0" ); | 95 | file.replace ( QRegExp (" "), "0" ); |
88 | file = dir +"/" +file; | 96 | file = dir +"/" +file + uid()+".ics"; |
89 | qDebug("%s ", file.latin1()); | 97 | qDebug("File %s ",file.latin1() ); |
90 | QStringList dataList; | 98 | CalendarLocal cal; |
91 | 99 | cal.setTimeZoneId( " 00:00 Europe/London(UTC)" ); | |
92 | //Summary | 100 | cal.addIncidence( clone() ); |
93 | //Category | 101 | ICalFormat format; |
94 | //CategoryColor | 102 | format.save( &cal, file ); |
95 | //StartRuntime | ||
96 | //Runtime | ||
97 | //Due | ||
98 | //Start | ||
99 | //Prio | ||
100 | //Erledigt | ||
101 | //Uid | ||
102 | //Parents uids | ||
103 | 103 | ||
104 | |||
105 | |||
106 | } | 104 | } |
107 | 105 | ||
108 | int Todo::runTime() | 106 | int Todo::runTime() |
109 | { | 107 | { |
110 | if ( !mRunning ) | 108 | if ( !mRunning ) |
111 | return 0; | 109 | return 0; |
112 | return mRunStart.secsTo( QDateTime::currentDateTime() ); | 110 | return mRunStart.secsTo( QDateTime::currentDateTime() ); |
113 | } | 111 | } |
114 | bool Todo::hasRunningSub() | 112 | bool Todo::hasRunningSub() |
115 | { | 113 | { |
116 | if ( mRunning ) | 114 | if ( mRunning ) |
117 | return true; | 115 | return true; |
118 | Incidence *aTodo; | 116 | Incidence *aTodo; |
119 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { | 117 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { |
120 | if ( ((Todo*)aTodo)->hasRunningSub() ) | 118 | if ( ((Todo*)aTodo)->hasRunningSub() ) |
121 | return true; | 119 | return true; |
122 | } | 120 | } |
123 | return false; | 121 | return false; |
124 | } | 122 | } |
125 | Incidence *Todo::clone() | 123 | Incidence *Todo::clone() |
126 | { | 124 | { |
127 | return new Todo(*this); | 125 | return new Todo(*this); |
128 | } | 126 | } |
129 | 127 | ||
130 | bool Todo::contains ( Todo* from ) | 128 | bool Todo::contains ( Todo* from ) |
131 | { | 129 | { |
132 | 130 | ||
133 | if ( !from->summary().isEmpty() ) | 131 | if ( !from->summary().isEmpty() ) |
134 | if ( !summary().startsWith( from->summary() )) | 132 | if ( !summary().startsWith( from->summary() )) |
135 | return false; | 133 | return false; |
136 | if ( from->hasStartDate() ) { | 134 | if ( from->hasStartDate() ) { |
137 | if ( !hasStartDate() ) | 135 | if ( !hasStartDate() ) |
138 | return false; | 136 | return false; |
139 | if ( from->dtStart() != dtStart()) | 137 | if ( from->dtStart() != dtStart()) |
140 | return false; | 138 | return false; |
141 | } | 139 | } |
142 | if ( from->hasDueDate() ){ | 140 | if ( from->hasDueDate() ){ |
143 | if ( !hasDueDate() ) | 141 | if ( !hasDueDate() ) |
144 | return false; | 142 | return false; |
145 | if ( from->dtDue() != dtDue()) | 143 | if ( from->dtDue() != dtDue()) |
146 | return false; | 144 | return false; |
147 | } | 145 | } |
148 | if ( !from->location().isEmpty() ) | 146 | if ( !from->location().isEmpty() ) |
149 | if ( !location().startsWith( from->location() ) ) | 147 | if ( !location().startsWith( from->location() ) ) |
150 | return false; | 148 | return false; |
151 | if ( !from->description().isEmpty() ) | 149 | if ( !from->description().isEmpty() ) |
152 | if ( !description().startsWith( from->description() )) | 150 | if ( !description().startsWith( from->description() )) |
153 | return false; | 151 | return false; |
154 | if ( from->alarms().count() ) { | 152 | if ( from->alarms().count() ) { |
155 | Alarm *a = from->alarms().first(); | 153 | Alarm *a = from->alarms().first(); |
156 | if ( a->enabled() ){ | 154 | if ( a->enabled() ){ |
157 | if ( !alarms().count() ) | 155 | if ( !alarms().count() ) |
158 | return false; | 156 | return false; |
159 | Alarm *b = alarms().first(); | 157 | Alarm *b = alarms().first(); |
160 | if( ! b->enabled() ) | 158 | if( ! b->enabled() ) |
161 | return false; | 159 | return false; |
162 | if ( ! (a->offset() == b->offset() )) | 160 | if ( ! (a->offset() == b->offset() )) |
163 | return false; | 161 | return false; |
164 | } | 162 | } |
165 | } | 163 | } |
166 | 164 | ||
167 | QStringList cat = categories(); | 165 | QStringList cat = categories(); |
168 | QStringList catFrom = from->categories(); | 166 | QStringList catFrom = from->categories(); |
169 | QString nCat; | 167 | QString nCat; |
170 | unsigned int iii; | 168 | unsigned int iii; |
171 | for ( iii = 0; iii < catFrom.count();++iii ) { | 169 | for ( iii = 0; iii < catFrom.count();++iii ) { |
172 | nCat = catFrom[iii]; | 170 | nCat = catFrom[iii]; |
173 | if ( !nCat.isEmpty() ) | 171 | if ( !nCat.isEmpty() ) |
174 | if ( !cat.contains( nCat )) { | 172 | if ( !cat.contains( nCat )) { |
175 | return false; | 173 | return false; |
176 | } | 174 | } |
177 | } | 175 | } |
178 | if ( from->isCompleted() ) { | 176 | if ( from->isCompleted() ) { |
179 | if ( !isCompleted() ) | 177 | if ( !isCompleted() ) |
180 | return false; | 178 | return false; |
181 | } | 179 | } |
182 | if( priority() != from->priority() ) | 180 | if( priority() != from->priority() ) |
183 | return false; | 181 | return false; |
184 | 182 | ||
185 | 183 | ||
186 | return true; | 184 | return true; |
187 | 185 | ||
188 | } | 186 | } |
189 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) | 187 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) |
190 | { | 188 | { |
191 | 189 | ||
192 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); | 190 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); |
193 | if ( ! ret ) | 191 | if ( ! ret ) |
194 | return false; | 192 | return false; |
195 | if ( t1.hasDueDate() == t2.hasDueDate() ) { | 193 | if ( t1.hasDueDate() == t2.hasDueDate() ) { |
196 | if ( t1.hasDueDate() ) { | 194 | if ( t1.hasDueDate() ) { |
197 | if ( t1.doesFloat() == t2.doesFloat() ) { | 195 | if ( t1.doesFloat() == t2.doesFloat() ) { |
198 | if ( t1.doesFloat() ) { | 196 | if ( t1.doesFloat() ) { |
199 | if ( t1.dtDue().date() != t2.dtDue().date() ) | 197 | if ( t1.dtDue().date() != t2.dtDue().date() ) |
200 | return false; | 198 | return false; |
201 | } else | 199 | } else |
202 | if ( t1.dtDue() != t2.dtDue() ) | 200 | if ( t1.dtDue() != t2.dtDue() ) |
203 | return false; | 201 | return false; |
204 | } else | 202 | } else |
205 | return false;// float != | 203 | return false;// float != |
206 | } | 204 | } |
207 | 205 | ||
208 | } else | 206 | } else |
209 | return false; | 207 | return false; |
210 | if ( t1.percentComplete() != t2.percentComplete() ) | 208 | if ( t1.percentComplete() != t2.percentComplete() ) |
211 | return false; | 209 | return false; |
212 | if ( t1.isCompleted() ) { | 210 | if ( t1.isCompleted() ) { |
213 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { | 211 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { |
214 | if ( t1.hasCompletedDate() ) { | 212 | if ( t1.hasCompletedDate() ) { |
215 | if ( t1.completed() != t2.completed() ) | 213 | if ( t1.completed() != t2.completed() ) |
216 | return false; | 214 | return false; |
217 | } | 215 | } |
218 | 216 | ||
219 | } else | 217 | } else |
220 | return false; | 218 | return false; |
221 | } | 219 | } |
222 | return true; | 220 | return true; |
223 | 221 | ||
224 | } | 222 | } |
225 | 223 | ||
226 | void Todo::setDtDue(const QDateTime &dtDue) | 224 | void Todo::setDtDue(const QDateTime &dtDue) |
227 | { | 225 | { |
228 | //int diffsecs = mDtDue.secsTo(dtDue); | 226 | //int diffsecs = mDtDue.secsTo(dtDue); |
229 | 227 | ||
230 | /*if (mReadOnly) return; | 228 | /*if (mReadOnly) return; |
231 | const QPtrList<Alarm>& alarms = alarms(); | 229 | const QPtrList<Alarm>& alarms = alarms(); |
232 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { | 230 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { |
233 | if (alarm->enabled()) { | 231 | if (alarm->enabled()) { |
234 | alarm->setTime(alarm->time().addSecs(diffsecs)); | 232 | alarm->setTime(alarm->time().addSecs(diffsecs)); |
235 | } | 233 | } |
236 | }*/ | 234 | }*/ |
237 | mDtDue = getEvenTime(dtDue); | 235 | mDtDue = getEvenTime(dtDue); |
238 | 236 | ||
239 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; | 237 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; |
240 | 238 | ||
241 | /*const QPtrList<Alarm>& alarms = alarms(); | 239 | /*const QPtrList<Alarm>& alarms = alarms(); |
242 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) | 240 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) |
243 | alarm->setAlarmStart(mDtDue);*/ | 241 | alarm->setAlarmStart(mDtDue);*/ |
244 | 242 | ||
245 | updated(); | 243 | updated(); |
246 | } | 244 | } |
247 | 245 | ||
248 | QDateTime Todo::dtDue() const | 246 | QDateTime Todo::dtDue() const |
249 | { | 247 | { |
250 | return mDtDue; | 248 | return mDtDue; |
251 | } | 249 | } |
252 | 250 | ||
253 | QString Todo::dtDueTimeStr() const | 251 | QString Todo::dtDueTimeStr() const |
254 | { | 252 | { |
255 | return KGlobal::locale()->formatTime(mDtDue.time()); | 253 | return KGlobal::locale()->formatTime(mDtDue.time()); |
256 | } | 254 | } |
257 | 255 | ||
258 | QString Todo::dtDueDateStr(bool shortfmt) const | 256 | QString Todo::dtDueDateStr(bool shortfmt) const |
259 | { | 257 | { |
260 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); | 258 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); |
261 | } | 259 | } |
262 | 260 | ||
263 | QString Todo::dtDueStr(bool shortfmt) const | 261 | QString Todo::dtDueStr(bool shortfmt) const |
264 | { | 262 | { |
265 | if ( doesFloat() ) | 263 | if ( doesFloat() ) |
266 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); | 264 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); |
267 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); | 265 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); |
268 | } | 266 | } |
269 | // retval 0 : no found | 267 | // retval 0 : no found |
270 | // 1 : due for date found | 268 | // 1 : due for date found |
271 | // 2 : overdue for date found | 269 | // 2 : overdue for date found |
272 | int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) | 270 | int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) |
273 | { | 271 | { |
274 | int retval = 0; | 272 | int retval = 0; |
275 | if ( isCompleted() ) | 273 | if ( isCompleted() ) |
276 | return 0; | 274 | return 0; |
277 | if ( hasDueDate() ) { | 275 | if ( hasDueDate() ) { |
278 | if ( dtDue().date() < date ) | 276 | if ( dtDue().date() < date ) |
279 | return 2; | 277 | return 2; |
280 | // we do not return, because we may find an overdue sub todo | 278 | // we do not return, because we may find an overdue sub todo |
281 | if ( dtDue().date() == date ) | 279 | if ( dtDue().date() == date ) |
282 | retval = 1; | 280 | retval = 1; |
283 | } | 281 | } |
284 | if ( checkSubtodos ) { | 282 | if ( checkSubtodos ) { |
285 | Incidence *aTodo; | 283 | Incidence *aTodo; |
286 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { | 284 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { |
287 | int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); | 285 | int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); |
288 | if ( ret == 2 ) | 286 | if ( ret == 2 ) |
289 | return 2; | 287 | return 2; |
290 | if ( ret == 1) | 288 | if ( ret == 1) |
291 | retval = 1; | 289 | retval = 1; |
292 | } | 290 | } |
293 | } | 291 | } |
294 | return retval; | 292 | return retval; |
295 | } | 293 | } |
296 | int Todo::hasDueSubTodo( bool checkSubtodos ) //= true | 294 | int Todo::hasDueSubTodo( bool checkSubtodos ) //= true |
297 | { | 295 | { |
298 | return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); | 296 | return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); |
299 | } | 297 | } |
300 | bool Todo::hasDueDate() const | 298 | bool Todo::hasDueDate() const |
301 | { | 299 | { |
302 | return mHasDueDate; | 300 | return mHasDueDate; |
303 | } | 301 | } |
304 | 302 | ||
305 | void Todo::setHasDueDate(bool f) | 303 | void Todo::setHasDueDate(bool f) |
306 | { | 304 | { |
307 | if (mReadOnly) return; | 305 | if (mReadOnly) return; |
308 | mHasDueDate = f; | 306 | mHasDueDate = f; |
309 | updated(); | 307 | updated(); |
310 | } | 308 | } |
311 | 309 | ||
312 | 310 | ||
313 | #if 0 | 311 | #if 0 |
314 | void Todo::setStatus(const QString &statStr) | 312 | void Todo::setStatus(const QString &statStr) |
315 | { | 313 | { |
316 | if (mReadOnly) return; | 314 | if (mReadOnly) return; |
317 | QString ss(statStr.upper()); | 315 | QString ss(statStr.upper()); |
318 | 316 | ||
319 | if (ss == "X-ACTION") | 317 | if (ss == "X-ACTION") |
320 | mStatus = NEEDS_ACTION; | 318 | mStatus = NEEDS_ACTION; |
321 | else if (ss == "NEEDS ACTION") | 319 | else if (ss == "NEEDS ACTION") |
322 | mStatus = NEEDS_ACTION; | 320 | mStatus = NEEDS_ACTION; |
323 | else if (ss == "ACCEPTED") | 321 | else if (ss == "ACCEPTED") |
324 | mStatus = ACCEPTED; | 322 | mStatus = ACCEPTED; |
325 | else if (ss == "SENT") | 323 | else if (ss == "SENT") |
326 | mStatus = SENT; | 324 | mStatus = SENT; |
327 | else if (ss == "TENTATIVE") | 325 | else if (ss == "TENTATIVE") |
328 | mStatus = TENTATIVE; | 326 | mStatus = TENTATIVE; |
329 | else if (ss == "CONFIRMED") | 327 | else if (ss == "CONFIRMED") |
330 | mStatus = CONFIRMED; | 328 | mStatus = CONFIRMED; |
331 | else if (ss == "DECLINED") | 329 | else if (ss == "DECLINED") |
332 | mStatus = DECLINED; | 330 | mStatus = DECLINED; |
333 | else if (ss == "COMPLETED") | 331 | else if (ss == "COMPLETED") |
334 | mStatus = COMPLETED; | 332 | mStatus = COMPLETED; |
335 | else if (ss == "DELEGATED") | 333 | else if (ss == "DELEGATED") |
336 | mStatus = DELEGATED; | 334 | mStatus = DELEGATED; |
337 | 335 | ||
338 | updated(); | 336 | updated(); |
339 | } | 337 | } |
340 | 338 | ||
341 | void Todo::setStatus(int status) | 339 | void Todo::setStatus(int status) |
342 | { | 340 | { |
343 | if (mReadOnly) return; | 341 | if (mReadOnly) return; |
344 | mStatus = status; | 342 | mStatus = status; |
345 | updated(); | 343 | updated(); |
346 | } | 344 | } |
347 | 345 | ||
348 | int Todo::status() const | 346 | int Todo::status() const |
349 | { | 347 | { |
350 | return mStatus; | 348 | return mStatus; |
351 | } | 349 | } |
352 | 350 | ||
353 | QString Todo::statusStr() const | 351 | QString Todo::statusStr() const |
354 | { | 352 | { |
355 | switch(mStatus) { | 353 | switch(mStatus) { |
356 | case NEEDS_ACTION: | 354 | case NEEDS_ACTION: |
357 | return QString("NEEDS ACTION"); | 355 | return QString("NEEDS ACTION"); |
358 | break; | 356 | break; |
359 | case ACCEPTED: | 357 | case ACCEPTED: |
360 | return QString("ACCEPTED"); | 358 | return QString("ACCEPTED"); |
361 | break; | 359 | break; |
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index 62a31ae..8efc1ea 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp | |||
@@ -73,861 +73,861 @@ bool VCalFormat::load(Calendar *calendar, const QString &fileName) | |||
73 | if (!vcal) { | 73 | if (!vcal) { |
74 | setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); | 74 | setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); |
75 | return FALSE; | 75 | return FALSE; |
76 | } | 76 | } |
77 | 77 | ||
78 | // any other top-level calendar stuff should be added/initialized here | 78 | // any other top-level calendar stuff should be added/initialized here |
79 | 79 | ||
80 | // put all vobjects into their proper places | 80 | // put all vobjects into their proper places |
81 | populate(vcal); | 81 | populate(vcal); |
82 | 82 | ||
83 | // clean up from vcal API stuff | 83 | // clean up from vcal API stuff |
84 | cleanVObjects(vcal); | 84 | cleanVObjects(vcal); |
85 | cleanStrTbl(); | 85 | cleanStrTbl(); |
86 | 86 | ||
87 | return true; | 87 | return true; |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | bool VCalFormat::save(Calendar *calendar, const QString &fileName) | 91 | bool VCalFormat::save(Calendar *calendar, const QString &fileName) |
92 | { | 92 | { |
93 | mCalendar = calendar; | 93 | mCalendar = calendar; |
94 | if ( ! useLocalTime ) | 94 | if ( ! useLocalTime ) |
95 | useLocalTime = mCalendar->isLocalTime(); | 95 | useLocalTime = mCalendar->isLocalTime(); |
96 | 96 | ||
97 | QString tmpStr; | 97 | QString tmpStr; |
98 | VObject *vcal, *vo; | 98 | VObject *vcal, *vo; |
99 | 99 | ||
100 | 100 | ||
101 | vcal = newVObject(VCCalProp); | 101 | vcal = newVObject(VCCalProp); |
102 | 102 | ||
103 | // addPropValue(vcal,VCLocationProp, "0.0"); | 103 | // addPropValue(vcal,VCLocationProp, "0.0"); |
104 | addPropValue(vcal,VCProdIdProp, productId()); | 104 | addPropValue(vcal,VCProdIdProp, productId()); |
105 | tmpStr = mCalendar->getTimeZoneStr(); | 105 | tmpStr = mCalendar->getTimeZoneStr(); |
106 | //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); | 106 | //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); |
107 | addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); | 107 | addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); |
108 | addPropValue(vcal,VCVersionProp, _VCAL_VERSION); | 108 | addPropValue(vcal,VCVersionProp, _VCAL_VERSION); |
109 | 109 | ||
110 | // TODO STUFF | 110 | // TODO STUFF |
111 | QPtrList<Todo> todoList = mCalendar->rawTodos(); | 111 | QPtrList<Todo> todoList = mCalendar->rawTodos(); |
112 | QPtrListIterator<Todo> qlt(todoList); | 112 | QPtrListIterator<Todo> qlt(todoList); |
113 | for (; qlt.current(); ++qlt) { | 113 | for (; qlt.current(); ++qlt) { |
114 | vo = eventToVTodo(qlt.current()); | 114 | vo = eventToVTodo(qlt.current()); |
115 | addVObjectProp(vcal, vo); | 115 | addVObjectProp(vcal, vo); |
116 | } | 116 | } |
117 | 117 | ||
118 | // EVENT STUFF | 118 | // EVENT STUFF |
119 | QPtrList<Event> events = mCalendar->rawEvents(); | 119 | QPtrList<Event> events = mCalendar->rawEvents(); |
120 | Event *ev; | 120 | Event *ev; |
121 | for(ev=events.first();ev;ev=events.next()) { | 121 | for(ev=events.first();ev;ev=events.next()) { |
122 | vo = eventToVEvent(ev); | 122 | vo = eventToVEvent(ev); |
123 | addVObjectProp(vcal, vo); | 123 | addVObjectProp(vcal, vo); |
124 | } | 124 | } |
125 | 125 | ||
126 | writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); | 126 | writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); |
127 | cleanVObjects(vcal); | 127 | cleanVObjects(vcal); |
128 | cleanStrTbl(); | 128 | cleanStrTbl(); |
129 | 129 | ||
130 | if (QFile::exists(fileName)) { | 130 | if (QFile::exists(fileName)) { |
131 | return true; | 131 | return true; |
132 | } else { | 132 | } else { |
133 | return false; // error | 133 | return false; // error |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
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 | 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->relatedToUid()) { |
330 | addPropValue(vtodo, VCRelatedToProp, | 330 | addPropValue(vtodo, VCRelatedToProp, |
331 | anEvent->relatedTo()->uid().local8Bit()); | 331 | anEvent->relatedToUid().local8Bit()); |
332 | } | 332 | } |
333 | 333 | ||
334 | // categories | 334 | // categories |
335 | QStringList 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 | 399 | ||
400 | vevent = newVObject(VCEventProp); | 400 | vevent = newVObject(VCEventProp); |
401 | 401 | ||
402 | // start and end time | 402 | // start and end time |
403 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 403 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
404 | !anEvent->doesFloat()); | 404 | !anEvent->doesFloat()); |
405 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); | 405 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); |
406 | 406 | ||
407 | // events that have time associated but take up no time should | 407 | // events that have time associated but take up no time should |
408 | // not have both DTSTART and DTEND. | 408 | // not have both DTSTART and DTEND. |
409 | if (anEvent->dtStart() != anEvent->dtEnd()) { | 409 | if (anEvent->dtStart() != anEvent->dtEnd()) { |
410 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), | 410 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), |
411 | !anEvent->doesFloat()); | 411 | !anEvent->doesFloat()); |
412 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); | 412 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); |
413 | } | 413 | } |
414 | 414 | ||
415 | // creation date | 415 | // creation date |
416 | tmpStr = qDateTimeToISO(anEvent->created()); | 416 | tmpStr = qDateTimeToISO(anEvent->created()); |
417 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); | 417 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); |
418 | 418 | ||
419 | // unique id | 419 | // unique id |
420 | addPropValue(vevent, VCUniqueStringProp, | 420 | addPropValue(vevent, VCUniqueStringProp, |
421 | anEvent->uid().local8Bit()); | 421 | anEvent->uid().local8Bit()); |
422 | 422 | ||
423 | // revision | 423 | // revision |
424 | tmpStr.sprintf("%i", anEvent->revision()); | 424 | tmpStr.sprintf("%i", anEvent->revision()); |
425 | addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); | 425 | addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); |
426 | 426 | ||
427 | // last modification date | 427 | // last modification date |
428 | tmpStr = qDateTimeToISO(anEvent->lastModified()); | 428 | tmpStr = qDateTimeToISO(anEvent->lastModified()); |
429 | addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); | 429 | addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); |
430 | 430 | ||
431 | // attendee and organizer stuff | 431 | // attendee and organizer stuff |
432 | tmpStr = "MAILTO:" + anEvent->organizer(); | 432 | tmpStr = "MAILTO:" + anEvent->organizer(); |
433 | addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); | 433 | addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); |
434 | 434 | ||
435 | if (anEvent->attendeeCount() != 0) { | 435 | if (anEvent->attendeeCount() != 0) { |
436 | QPtrList<Attendee> al = anEvent->attendees(); | 436 | QPtrList<Attendee> al = anEvent->attendees(); |
437 | QPtrListIterator<Attendee> ai(al); | 437 | QPtrListIterator<Attendee> ai(al); |
438 | Attendee *curAttendee; | 438 | Attendee *curAttendee; |
439 | 439 | ||
440 | // TODO: Put this functionality into Attendee class | 440 | // TODO: Put this functionality into Attendee class |
441 | for (; ai.current(); ++ai) { | 441 | for (; ai.current(); ++ai) { |
442 | curAttendee = ai.current(); | 442 | curAttendee = ai.current(); |
443 | if (!curAttendee->email().isEmpty() && | 443 | if (!curAttendee->email().isEmpty() && |
444 | !curAttendee->name().isEmpty()) | 444 | !curAttendee->name().isEmpty()) |
445 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + | 445 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + |
446 | curAttendee->email() + ">"; | 446 | curAttendee->email() + ">"; |
447 | else if (curAttendee->name().isEmpty()) | 447 | else if (curAttendee->name().isEmpty()) |
448 | tmpStr = "MAILTO: " + curAttendee->email(); | 448 | tmpStr = "MAILTO: " + curAttendee->email(); |
449 | else if (curAttendee->email().isEmpty()) | 449 | else if (curAttendee->email().isEmpty()) |
450 | tmpStr = "MAILTO: " + curAttendee->name(); | 450 | tmpStr = "MAILTO: " + curAttendee->name(); |
451 | else if (curAttendee->name().isEmpty() && | 451 | else if (curAttendee->name().isEmpty() && |
452 | curAttendee->email().isEmpty()) | 452 | curAttendee->email().isEmpty()) |
453 | 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; |
454 | VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); | 454 | VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); |
455 | addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); | 455 | addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); |
456 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); | 456 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); |
457 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); | 457 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); |
458 | } | 458 | } |
459 | } | 459 | } |
460 | 460 | ||
461 | // recurrence rule stuff | 461 | // recurrence rule stuff |
462 | if (anEvent->recurrence()->doesRecur()) { | 462 | if (anEvent->recurrence()->doesRecur()) { |
463 | // some more variables | 463 | // some more variables |
464 | QPtrList<Recurrence::rMonthPos> tmpPositions; | 464 | QPtrList<Recurrence::rMonthPos> tmpPositions; |
465 | QPtrList<int> tmpDays; | 465 | QPtrList<int> tmpDays; |
466 | int *tmpDay; | 466 | int *tmpDay; |
467 | Recurrence::rMonthPos *tmpPos; | 467 | Recurrence::rMonthPos *tmpPos; |
468 | QString tmpStr2; | 468 | QString tmpStr2; |
469 | int i; | 469 | int i; |
470 | 470 | ||
471 | switch(anEvent->recurrence()->doesRecur()) { | 471 | switch(anEvent->recurrence()->doesRecur()) { |
472 | case Recurrence::rDaily: | 472 | case Recurrence::rDaily: |
473 | tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); | 473 | tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); |
474 | // if (anEvent->rDuration > 0) | 474 | // if (anEvent->rDuration > 0) |
475 | //tmpStr += "#"; | 475 | //tmpStr += "#"; |
476 | break; | 476 | break; |
477 | case Recurrence::rWeekly: | 477 | case Recurrence::rWeekly: |
478 | tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); | 478 | tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); |
479 | for (i = 0; i < 7; i++) { | 479 | for (i = 0; i < 7; i++) { |
480 | if (anEvent->recurrence()->days().testBit(i)) | 480 | if (anEvent->recurrence()->days().testBit(i)) |
481 | tmpStr += dayFromNum(i); | 481 | tmpStr += dayFromNum(i); |
482 | } | 482 | } |
483 | break; | 483 | break; |
484 | case Recurrence::rMonthlyPos: | 484 | case Recurrence::rMonthlyPos: |
485 | tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); | 485 | tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); |
486 | // write out all rMonthPos's | 486 | // write out all rMonthPos's |
487 | tmpPositions = anEvent->recurrence()->monthPositions(); | 487 | tmpPositions = anEvent->recurrence()->monthPositions(); |
488 | for (tmpPos = tmpPositions.first(); | 488 | for (tmpPos = tmpPositions.first(); |
489 | tmpPos; | 489 | tmpPos; |
490 | tmpPos = tmpPositions.next()) { | 490 | tmpPos = tmpPositions.next()) { |
491 | 491 | ||
492 | tmpStr2.sprintf("%i", tmpPos->rPos); | 492 | tmpStr2.sprintf("%i", tmpPos->rPos); |
493 | if (tmpPos->negative) | 493 | if (tmpPos->negative) |
494 | tmpStr2 += "- "; | 494 | tmpStr2 += "- "; |
495 | else | 495 | else |
496 | tmpStr2 += "+ "; | 496 | tmpStr2 += "+ "; |
497 | tmpStr += tmpStr2; | 497 | tmpStr += tmpStr2; |
498 | for (i = 0; i < 7; i++) { | 498 | for (i = 0; i < 7; i++) { |
499 | if (tmpPos->rDays.testBit(i)) | 499 | if (tmpPos->rDays.testBit(i)) |
500 | tmpStr += dayFromNum(i); | 500 | tmpStr += dayFromNum(i); |
501 | } | 501 | } |
502 | } // loop for all rMonthPos's | 502 | } // loop for all rMonthPos's |
503 | break; | 503 | break; |
504 | case Recurrence::rMonthlyDay: | 504 | case Recurrence::rMonthlyDay: |
505 | tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); | 505 | tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); |
506 | // write out all rMonthDays; | 506 | // write out all rMonthDays; |
507 | tmpDays = anEvent->recurrence()->monthDays(); | 507 | tmpDays = anEvent->recurrence()->monthDays(); |
508 | for (tmpDay = tmpDays.first(); | 508 | for (tmpDay = tmpDays.first(); |
509 | tmpDay; | 509 | tmpDay; |
510 | tmpDay = tmpDays.next()) { | 510 | tmpDay = tmpDays.next()) { |
511 | tmpStr2.sprintf("%i ", *tmpDay); | 511 | tmpStr2.sprintf("%i ", *tmpDay); |
512 | tmpStr += tmpStr2; | 512 | tmpStr += tmpStr2; |
513 | } | 513 | } |
514 | break; | 514 | break; |
515 | case Recurrence::rYearlyMonth: | 515 | case Recurrence::rYearlyMonth: |
516 | tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); | 516 | tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); |
517 | // write out all the rYearNums; | 517 | // write out all the rYearNums; |
518 | tmpDays = anEvent->recurrence()->yearNums(); | 518 | tmpDays = anEvent->recurrence()->yearNums(); |
519 | for (tmpDay = tmpDays.first(); | 519 | for (tmpDay = tmpDays.first(); |
520 | tmpDay; | 520 | tmpDay; |
521 | tmpDay = tmpDays.next()) { | 521 | tmpDay = tmpDays.next()) { |
522 | tmpStr2.sprintf("%i ", *tmpDay); | 522 | tmpStr2.sprintf("%i ", *tmpDay); |
523 | tmpStr += tmpStr2; | 523 | tmpStr += tmpStr2; |
524 | } | 524 | } |
525 | break; | 525 | break; |
526 | case Recurrence::rYearlyDay: | 526 | case Recurrence::rYearlyDay: |
527 | tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency()); | 527 | tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency()); |
528 | // write out all the rYearNums; | 528 | // write out all the rYearNums; |
529 | tmpDays = anEvent->recurrence()->yearNums(); | 529 | tmpDays = anEvent->recurrence()->yearNums(); |
530 | for (tmpDay = tmpDays.first(); | 530 | for (tmpDay = tmpDays.first(); |
531 | tmpDay; | 531 | tmpDay; |
532 | tmpDay = tmpDays.next()) { | 532 | tmpDay = tmpDays.next()) { |
533 | tmpStr2.sprintf("%i ", *tmpDay); | 533 | tmpStr2.sprintf("%i ", *tmpDay); |
534 | tmpStr += tmpStr2; | 534 | tmpStr += tmpStr2; |
535 | } | 535 | } |
536 | break; | 536 | break; |
537 | default: | 537 | default: |
538 | kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; | 538 | kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; |
539 | break; | 539 | break; |
540 | } // switch | 540 | } // switch |
541 | 541 | ||
542 | if (anEvent->recurrence()->duration() > 0) { | 542 | if (anEvent->recurrence()->duration() > 0) { |
543 | tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); | 543 | tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); |
544 | tmpStr += tmpStr2; | 544 | tmpStr += tmpStr2; |
545 | } else if (anEvent->recurrence()->duration() == -1) { | 545 | } else if (anEvent->recurrence()->duration() == -1) { |
546 | tmpStr += "#0"; // defined as repeat forever | 546 | tmpStr += "#0"; // defined as repeat forever |
547 | } else { | 547 | } else { |
548 | tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); | 548 | tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); |
549 | } | 549 | } |
550 | addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); | 550 | addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); |
551 | 551 | ||
552 | } // event repeats | 552 | } // event repeats |
553 | 553 | ||
554 | // exceptions to recurrence | 554 | // exceptions to recurrence |
555 | DateList dateList = anEvent->exDates(); | 555 | DateList dateList = anEvent->exDates(); |
556 | DateList::ConstIterator it; | 556 | DateList::ConstIterator it; |
557 | QString tmpStr2; | 557 | QString tmpStr2; |
558 | 558 | ||
559 | for (it = dateList.begin(); it != dateList.end(); ++it) { | 559 | for (it = dateList.begin(); it != dateList.end(); ++it) { |
560 | tmpStr = qDateToISO(*it) + ";"; | 560 | tmpStr = qDateToISO(*it) + ";"; |
561 | tmpStr2 += tmpStr; | 561 | tmpStr2 += tmpStr; |
562 | } | 562 | } |
563 | if (!tmpStr2.isEmpty()) { | 563 | if (!tmpStr2.isEmpty()) { |
564 | tmpStr2.truncate(tmpStr2.length()-1); | 564 | tmpStr2.truncate(tmpStr2.length()-1); |
565 | addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit()); | 565 | addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit()); |
566 | } | 566 | } |
567 | 567 | ||
568 | // description | 568 | // description |
569 | if (!anEvent->description().isEmpty()) { | 569 | if (!anEvent->description().isEmpty()) { |
570 | VObject *d = addPropValue(vevent, VCDescriptionProp, | 570 | VObject *d = addPropValue(vevent, VCDescriptionProp, |
571 | anEvent->description().local8Bit()); | 571 | anEvent->description().local8Bit()); |
572 | if (anEvent->description().find('\n') != -1) | 572 | if (anEvent->description().find('\n') != -1) |
573 | addProp(d, VCQuotedPrintableProp); | 573 | addProp(d, VCQuotedPrintableProp); |
574 | } | 574 | } |
575 | 575 | ||
576 | // summary | 576 | // summary |
577 | if (!anEvent->summary().isEmpty()) | 577 | if (!anEvent->summary().isEmpty()) |
578 | addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); | 578 | addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); |
579 | 579 | ||
580 | if (!anEvent->location().isEmpty()) | 580 | if (!anEvent->location().isEmpty()) |
581 | addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); | 581 | addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); |
582 | 582 | ||
583 | // status | 583 | // status |
584 | // TODO: define Event status | 584 | // TODO: define Event status |
585 | // addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); | 585 | // addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); |
586 | 586 | ||
587 | // secrecy | 587 | // secrecy |
588 | const char *text = 0; | 588 | const char *text = 0; |
589 | switch (anEvent->secrecy()) { | 589 | switch (anEvent->secrecy()) { |
590 | case Incidence::SecrecyPublic: | 590 | case Incidence::SecrecyPublic: |
591 | text = "PUBLIC"; | 591 | text = "PUBLIC"; |
592 | break; | 592 | break; |
593 | case Incidence::SecrecyPrivate: | 593 | case Incidence::SecrecyPrivate: |
594 | text = "PRIVATE"; | 594 | text = "PRIVATE"; |
595 | break; | 595 | break; |
596 | case Incidence::SecrecyConfidential: | 596 | case Incidence::SecrecyConfidential: |
597 | text = "CONFIDENTIAL"; | 597 | text = "CONFIDENTIAL"; |
598 | break; | 598 | break; |
599 | } | 599 | } |
600 | if (text) { | 600 | if (text) { |
601 | addPropValue(vevent, VCClassProp, text); | 601 | addPropValue(vevent, VCClassProp, text); |
602 | } | 602 | } |
603 | 603 | ||
604 | // categories | 604 | // categories |
605 | QStringList tmpStrList = anEvent->categories(); | 605 | QStringList tmpStrList = anEvent->categories(); |
606 | tmpStr = ""; | 606 | tmpStr = ""; |
607 | QString catStr; | 607 | QString catStr; |
608 | for ( QStringList::Iterator it = tmpStrList.begin(); | 608 | for ( QStringList::Iterator it = tmpStrList.begin(); |
609 | it != tmpStrList.end(); | 609 | it != tmpStrList.end(); |
610 | ++it ) { | 610 | ++it ) { |
611 | catStr = *it; | 611 | catStr = *it; |
612 | if (catStr[0] == ' ') | 612 | if (catStr[0] == ' ') |
613 | tmpStr += catStr.mid(1); | 613 | tmpStr += catStr.mid(1); |
614 | else | 614 | else |
615 | tmpStr += catStr; | 615 | tmpStr += catStr; |
616 | // this must be a ';' character as the vCalendar specification requires! | 616 | // this must be a ';' character as the vCalendar specification requires! |
617 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is | 617 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is |
618 | // read in. | 618 | // read in. |
619 | tmpStr += ";"; | 619 | tmpStr += ";"; |
620 | } | 620 | } |
621 | if (!tmpStr.isEmpty()) { | 621 | if (!tmpStr.isEmpty()) { |
622 | tmpStr.truncate(tmpStr.length()-1); | 622 | tmpStr.truncate(tmpStr.length()-1); |
623 | addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); | 623 | addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); |
624 | } | 624 | } |
625 | 625 | ||
626 | // attachments | 626 | // attachments |
627 | // TODO: handle binary attachments! | 627 | // TODO: handle binary attachments! |
628 | QPtrList<Attachment> attachments = anEvent->attachments(); | 628 | QPtrList<Attachment> attachments = anEvent->attachments(); |
629 | for ( Attachment *at = attachments.first(); at; at = attachments.next() ) | 629 | for ( Attachment *at = attachments.first(); at; at = attachments.next() ) |
630 | addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); | 630 | addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); |
631 | 631 | ||
632 | // resources | 632 | // resources |
633 | tmpStrList = anEvent->resources(); | 633 | tmpStrList = anEvent->resources(); |
634 | tmpStr = tmpStrList.join(";"); | 634 | tmpStr = tmpStrList.join(";"); |
635 | if (!tmpStr.isEmpty()) | 635 | if (!tmpStr.isEmpty()) |
636 | addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); | 636 | addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); |
637 | 637 | ||
638 | // alarm stuff | 638 | // alarm stuff |
639 | QPtrList<Alarm> alarms = anEvent->alarms(); | 639 | QPtrList<Alarm> alarms = anEvent->alarms(); |
640 | Alarm* alarm; | 640 | Alarm* alarm; |
641 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { | 641 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { |
642 | if (alarm->enabled()) { | 642 | if (alarm->enabled()) { |
643 | VObject *a ; | 643 | VObject *a ; |
644 | tmpStr = qDateTimeToISO(alarm->time()); | 644 | tmpStr = qDateTimeToISO(alarm->time()); |
645 | if (alarm->type() == Alarm::Audio) { | 645 | if (alarm->type() == Alarm::Audio) { |
646 | a = addProp(vevent, VCAAlarmProp); | 646 | a = addProp(vevent, VCAAlarmProp); |
647 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 647 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
648 | addPropValue(a, VCRepeatCountProp, "1"); | 648 | addPropValue(a, VCRepeatCountProp, "1"); |
649 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); | 649 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); |
650 | } | 650 | } |
651 | if (alarm->type() == Alarm::Procedure) { | 651 | if (alarm->type() == Alarm::Procedure) { |
652 | a = addProp(vevent, VCPAlarmProp); | 652 | a = addProp(vevent, VCPAlarmProp); |
653 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 653 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
654 | addPropValue(a, VCRepeatCountProp, "1"); | 654 | addPropValue(a, VCRepeatCountProp, "1"); |
655 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); | 655 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); |
656 | } else { | 656 | } else { |
657 | a = addProp(vevent, VCDAlarmProp); | 657 | a = addProp(vevent, VCDAlarmProp); |
658 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 658 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
659 | addPropValue(a, VCRepeatCountProp, "1"); | 659 | addPropValue(a, VCRepeatCountProp, "1"); |
660 | addPropValue(a, VCDisplayStringProp, "beep!"); | 660 | addPropValue(a, VCDisplayStringProp, "beep!"); |
661 | 661 | ||
662 | } | 662 | } |
663 | } | 663 | } |
664 | } | 664 | } |
665 | 665 | ||
666 | // priority | 666 | // priority |
667 | tmpStr.sprintf("%i",anEvent->priority()); | 667 | tmpStr.sprintf("%i",anEvent->priority()); |
668 | addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); | 668 | addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); |
669 | 669 | ||
670 | // transparency | 670 | // transparency |
671 | tmpStr.sprintf("%i",anEvent->transparency()); | 671 | tmpStr.sprintf("%i",anEvent->transparency()); |
672 | addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); | 672 | addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); |
673 | 673 | ||
674 | // related event | 674 | // related event |
675 | if (anEvent->relatedTo()) { | 675 | if (anEvent->relatedToUid()) { |
676 | addPropValue(vevent, VCRelatedToProp, | 676 | addPropValue(vevent, VCRelatedToProp, |
677 | anEvent->relatedTo()->uid().local8Bit()); | 677 | anEvent->relatedToUid().local8Bit()); |
678 | } | 678 | } |
679 | 679 | ||
680 | if (anEvent->pilotId()) { | 680 | if (anEvent->pilotId()) { |
681 | // pilot sync stuff | 681 | // pilot sync stuff |
682 | tmpStr.sprintf("%i",anEvent->pilotId()); | 682 | tmpStr.sprintf("%i",anEvent->pilotId()); |
683 | addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); | 683 | addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); |
684 | tmpStr.sprintf("%i",anEvent->syncStatus()); | 684 | tmpStr.sprintf("%i",anEvent->syncStatus()); |
685 | addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); | 685 | addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); |
686 | } | 686 | } |
687 | 687 | ||
688 | return vevent; | 688 | return vevent; |
689 | } | 689 | } |
690 | 690 | ||
691 | Todo *VCalFormat::VTodoToEvent(VObject *vtodo) | 691 | Todo *VCalFormat::VTodoToEvent(VObject *vtodo) |
692 | { | 692 | { |
693 | VObject *vo; | 693 | VObject *vo; |
694 | VObjectIterator voi; | 694 | VObjectIterator voi; |
695 | char *s; | 695 | char *s; |
696 | 696 | ||
697 | Todo *anEvent = new Todo; | 697 | Todo *anEvent = new Todo; |
698 | 698 | ||
699 | // creation date | 699 | // creation date |
700 | if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { | 700 | if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { |
701 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 701 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
702 | deleteStr(s); | 702 | deleteStr(s); |
703 | } | 703 | } |
704 | 704 | ||
705 | // unique id | 705 | // unique id |
706 | vo = isAPropertyOf(vtodo, VCUniqueStringProp); | 706 | vo = isAPropertyOf(vtodo, VCUniqueStringProp); |
707 | // 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 |
708 | // default Event UID if none is given. | 708 | // default Event UID if none is given. |
709 | if (vo) { | 709 | if (vo) { |
710 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); | 710 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); |
711 | deleteStr(s); | 711 | deleteStr(s); |
712 | } | 712 | } |
713 | 713 | ||
714 | // last modification date | 714 | // last modification date |
715 | if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { | 715 | if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { |
716 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 716 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
717 | deleteStr(s); | 717 | deleteStr(s); |
718 | } | 718 | } |
719 | else | 719 | else |
720 | anEvent->setLastModified(QDateTime(QDate::currentDate(), | 720 | anEvent->setLastModified(QDateTime(QDate::currentDate(), |
721 | QTime::currentTime())); | 721 | QTime::currentTime())); |
722 | 722 | ||
723 | // organizer | 723 | // organizer |
724 | // 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. |
725 | if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { | 725 | if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { |
726 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); | 726 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); |
727 | deleteStr(s); | 727 | deleteStr(s); |
728 | } else { | 728 | } else { |
729 | anEvent->setOrganizer(mCalendar->getEmail()); | 729 | anEvent->setOrganizer(mCalendar->getEmail()); |
730 | } | 730 | } |
731 | 731 | ||
732 | // attendees. | 732 | // attendees. |
733 | initPropIterator(&voi, vtodo); | 733 | initPropIterator(&voi, vtodo); |
734 | while (moreIteration(&voi)) { | 734 | while (moreIteration(&voi)) { |
735 | vo = nextVObject(&voi); | 735 | vo = nextVObject(&voi); |
736 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { | 736 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { |
737 | Attendee *a; | 737 | Attendee *a; |
738 | VObject *vp; | 738 | VObject *vp; |
739 | s = fakeCString(vObjectUStringZValue(vo)); | 739 | s = fakeCString(vObjectUStringZValue(vo)); |
740 | QString tmpStr = QString::fromLocal8Bit(s); | 740 | QString tmpStr = QString::fromLocal8Bit(s); |
741 | deleteStr(s); | 741 | deleteStr(s); |
742 | tmpStr = tmpStr.simplifyWhiteSpace(); | 742 | tmpStr = tmpStr.simplifyWhiteSpace(); |
743 | int emailPos1, emailPos2; | 743 | int emailPos1, emailPos2; |
744 | if ((emailPos1 = tmpStr.find('<')) > 0) { | 744 | if ((emailPos1 = tmpStr.find('<')) > 0) { |
745 | // both email address and name | 745 | // both email address and name |
746 | emailPos2 = tmpStr.findRev('>'); | 746 | emailPos2 = tmpStr.findRev('>'); |
747 | a = new Attendee(tmpStr.left(emailPos1 - 1), | 747 | a = new Attendee(tmpStr.left(emailPos1 - 1), |
748 | tmpStr.mid(emailPos1 + 1, | 748 | tmpStr.mid(emailPos1 + 1, |
749 | emailPos2 - (emailPos1 + 1))); | 749 | emailPos2 - (emailPos1 + 1))); |
750 | } else if (tmpStr.find('@') > 0) { | 750 | } else if (tmpStr.find('@') > 0) { |
751 | // just an email address | 751 | // just an email address |
752 | a = new Attendee(0, tmpStr); | 752 | a = new Attendee(0, tmpStr); |
753 | } else { | 753 | } else { |
754 | // just a name | 754 | // just a name |
755 | // QString email = tmpStr.replace( QRegExp(" "), "." ); | 755 | // QString email = tmpStr.replace( QRegExp(" "), "." ); |
756 | a = new Attendee(tmpStr,0); | 756 | a = new Attendee(tmpStr,0); |
757 | } | 757 | } |
758 | // is there a Role property? | 758 | // is there a Role property? |
759 | if ((vp = isAPropertyOf(vo, VCRoleProp)) != 0) | 759 | if ((vp = isAPropertyOf(vo, VCRoleProp)) != 0) |
760 | a->setRole(readRole(vObjectStringZValue(vp))); | 760 | a->setRole(readRole(vObjectStringZValue(vp))); |
761 | // is there an RSVP property? | 761 | // is there an RSVP property? |
762 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) | 762 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) |
763 | a->setRSVP(vObjectStringZValue(vp)); | 763 | a->setRSVP(vObjectStringZValue(vp)); |
764 | // is there a status property? | 764 | // is there a status property? |
765 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) | 765 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) |
766 | a->setStatus(readStatus(vObjectStringZValue(vp))); | 766 | a->setStatus(readStatus(vObjectStringZValue(vp))); |
767 | // add the attendee | 767 | // add the attendee |
768 | anEvent->addAttendee(a); | 768 | anEvent->addAttendee(a); |
769 | } | 769 | } |
770 | } | 770 | } |
771 | 771 | ||
772 | // description for todo | 772 | // description for todo |
773 | if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) { | 773 | if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) { |
774 | s = fakeCString(vObjectUStringZValue(vo)); | 774 | s = fakeCString(vObjectUStringZValue(vo)); |
775 | anEvent->setDescription(QString::fromLocal8Bit(s)); | 775 | anEvent->setDescription(QString::fromLocal8Bit(s)); |
776 | deleteStr(s); | 776 | deleteStr(s); |
777 | } | 777 | } |
778 | 778 | ||
779 | // summary | 779 | // summary |
780 | if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { | 780 | if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { |
781 | s = fakeCString(vObjectUStringZValue(vo)); | 781 | s = fakeCString(vObjectUStringZValue(vo)); |
782 | anEvent->setSummary(QString::fromLocal8Bit(s)); | 782 | anEvent->setSummary(QString::fromLocal8Bit(s)); |
783 | deleteStr(s); | 783 | deleteStr(s); |
784 | } | 784 | } |
785 | if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { | 785 | if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { |
786 | s = fakeCString(vObjectUStringZValue(vo)); | 786 | s = fakeCString(vObjectUStringZValue(vo)); |
787 | anEvent->setLocation(QString::fromLocal8Bit(s)); | 787 | anEvent->setLocation(QString::fromLocal8Bit(s)); |
788 | deleteStr(s); | 788 | deleteStr(s); |
789 | } | 789 | } |
790 | 790 | ||
791 | 791 | ||
792 | // completed | 792 | // completed |
793 | // was: status | 793 | // was: status |
794 | if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { | 794 | if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { |
795 | s = fakeCString(vObjectUStringZValue(vo)); | 795 | s = fakeCString(vObjectUStringZValue(vo)); |
796 | if (strcmp(s,"COMPLETED") == 0) { | 796 | if (strcmp(s,"COMPLETED") == 0) { |
797 | anEvent->setCompleted(true); | 797 | anEvent->setCompleted(true); |
798 | } else { | 798 | } else { |
799 | anEvent->setCompleted(false); | 799 | anEvent->setCompleted(false); |
800 | } | 800 | } |
801 | deleteStr(s); | 801 | deleteStr(s); |
802 | } | 802 | } |
803 | else | 803 | else |
804 | anEvent->setCompleted(false); | 804 | anEvent->setCompleted(false); |
805 | 805 | ||
806 | // completion date | 806 | // completion date |
807 | if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { | 807 | if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { |
808 | anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 808 | anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
809 | deleteStr(s); | 809 | deleteStr(s); |
810 | } | 810 | } |
811 | 811 | ||
812 | // priority | 812 | // priority |
813 | if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { | 813 | if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { |
814 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 814 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
815 | deleteStr(s); | 815 | deleteStr(s); |
816 | } | 816 | } |
817 | 817 | ||
818 | // due date | 818 | // due date |
819 | if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { | 819 | if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { |
820 | anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 820 | anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
821 | deleteStr(s); | 821 | deleteStr(s); |
822 | anEvent->setHasDueDate(true); | 822 | anEvent->setHasDueDate(true); |
823 | } else { | 823 | } else { |
824 | anEvent->setHasDueDate(false); | 824 | anEvent->setHasDueDate(false); |
825 | } | 825 | } |
826 | 826 | ||
827 | // start time | 827 | // start time |
828 | if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) { | 828 | if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) { |
829 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 829 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
830 | // 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; |
831 | deleteStr(s); | 831 | deleteStr(s); |
832 | anEvent->setHasStartDate(true); | 832 | anEvent->setHasStartDate(true); |
833 | } else { | 833 | } else { |
834 | anEvent->setHasStartDate(false); | 834 | anEvent->setHasStartDate(false); |
835 | } | 835 | } |
836 | 836 | ||
837 | /* alarm stuff */ | 837 | /* alarm stuff */ |
838 | //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl; | 838 | //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl; |
839 | if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) { | 839 | if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) { |
840 | Alarm* alarm = anEvent->newAlarm(); | 840 | Alarm* alarm = anEvent->newAlarm(); |
841 | VObject *a; | 841 | VObject *a; |
842 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { | 842 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { |
843 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); | 843 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); |
844 | deleteStr(s); | 844 | deleteStr(s); |
845 | } | 845 | } |
846 | alarm->setEnabled(true); | 846 | alarm->setEnabled(true); |
847 | if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) { | 847 | if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) { |
848 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { | 848 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { |
849 | s = fakeCString(vObjectUStringZValue(a)); | 849 | s = fakeCString(vObjectUStringZValue(a)); |
850 | alarm->setProcedureAlarm(QFile::decodeName(s)); | 850 | alarm->setProcedureAlarm(QFile::decodeName(s)); |
851 | deleteStr(s); | 851 | deleteStr(s); |
852 | } | 852 | } |
853 | } | 853 | } |
854 | if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) { | 854 | if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) { |
855 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { | 855 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { |
856 | s = fakeCString(vObjectUStringZValue(a)); | 856 | s = fakeCString(vObjectUStringZValue(a)); |
857 | alarm->setAudioAlarm(QFile::decodeName(s)); | 857 | alarm->setAudioAlarm(QFile::decodeName(s)); |
858 | deleteStr(s); | 858 | deleteStr(s); |
859 | } | 859 | } |
860 | } | 860 | } |
861 | } | 861 | } |
862 | 862 | ||
863 | // related todo | 863 | // related todo |
864 | if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) { | 864 | if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) { |
865 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); | 865 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); |
866 | deleteStr(s); | 866 | deleteStr(s); |
867 | mTodosRelate.append(anEvent); | 867 | mTodosRelate.append(anEvent); |
868 | } | 868 | } |
869 | 869 | ||
870 | // categories | 870 | // categories |
871 | if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) { | 871 | if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) { |
872 | s = fakeCString(vObjectUStringZValue(vo)); | 872 | s = fakeCString(vObjectUStringZValue(vo)); |
873 | QString categories = QString::fromLocal8Bit(s); | 873 | QString categories = QString::fromLocal8Bit(s); |
874 | deleteStr(s); | 874 | deleteStr(s); |
875 | QStringList tmpStrList = QStringList::split( ';', categories ); | 875 | QStringList tmpStrList = QStringList::split( ';', categories ); |
876 | anEvent->setCategories(tmpStrList); | 876 | anEvent->setCategories(tmpStrList); |
877 | } | 877 | } |
878 | 878 | ||
879 | /* PILOT SYNC STUFF */ | 879 | /* PILOT SYNC STUFF */ |
880 | if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) { | 880 | if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) { |
881 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 881 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
882 | deleteStr(s); | 882 | deleteStr(s); |
883 | } | 883 | } |
884 | else | 884 | else |
885 | anEvent->setPilotId(0); | 885 | anEvent->setPilotId(0); |
886 | 886 | ||
887 | if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) { | 887 | if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) { |
888 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 888 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
889 | deleteStr(s); | 889 | deleteStr(s); |
890 | } | 890 | } |
891 | else | 891 | else |
892 | anEvent->setSyncStatus(Event::SYNCMOD); | 892 | anEvent->setSyncStatus(Event::SYNCMOD); |
893 | 893 | ||
894 | return anEvent; | 894 | return anEvent; |
895 | } | 895 | } |
896 | 896 | ||
897 | Event* VCalFormat::VEventToEvent(VObject *vevent) | 897 | Event* VCalFormat::VEventToEvent(VObject *vevent) |
898 | { | 898 | { |
899 | VObject *vo; | 899 | VObject *vo; |
900 | VObjectIterator voi; | 900 | VObjectIterator voi; |
901 | char *s; | 901 | char *s; |
902 | 902 | ||
903 | Event *anEvent = new Event; | 903 | Event *anEvent = new Event; |
904 | 904 | ||
905 | // creation date | 905 | // creation date |
906 | if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { | 906 | if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { |
907 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 907 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
908 | deleteStr(s); | 908 | deleteStr(s); |
909 | } | 909 | } |
910 | 910 | ||
911 | // unique id | 911 | // unique id |
912 | vo = isAPropertyOf(vevent, VCUniqueStringProp); | 912 | vo = isAPropertyOf(vevent, VCUniqueStringProp); |
913 | // 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 |
914 | // default Event UID if none is given. | 914 | // default Event UID if none is given. |
915 | if (vo) { | 915 | if (vo) { |
916 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); | 916 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); |
917 | deleteStr(s); | 917 | deleteStr(s); |
918 | } | 918 | } |
919 | 919 | ||
920 | // revision | 920 | // revision |
921 | // 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... |
922 | if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { | 922 | if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { |
923 | anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 923 | anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
924 | deleteStr(s); | 924 | deleteStr(s); |
925 | } | 925 | } |
926 | else | 926 | else |
927 | anEvent->setRevision(0); | 927 | anEvent->setRevision(0); |
928 | 928 | ||
929 | // last modification date | 929 | // last modification date |
930 | if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { | 930 | if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { |
931 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 931 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
932 | deleteStr(s); | 932 | deleteStr(s); |
933 | } | 933 | } |
@@ -1351,361 +1351,365 @@ Event* VCalFormat::VEventToEvent(VObject *vevent) | |||
1351 | alarm->setEnabled(true); | 1351 | alarm->setEnabled(true); |
1352 | if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) { | 1352 | if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) { |
1353 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { | 1353 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { |
1354 | s = fakeCString(vObjectUStringZValue(a)); | 1354 | s = fakeCString(vObjectUStringZValue(a)); |
1355 | alarm->setProcedureAlarm(QFile::decodeName(s)); | 1355 | alarm->setProcedureAlarm(QFile::decodeName(s)); |
1356 | deleteStr(s); | 1356 | deleteStr(s); |
1357 | } | 1357 | } |
1358 | } | 1358 | } |
1359 | if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { | 1359 | if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { |
1360 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { | 1360 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { |
1361 | s = fakeCString(vObjectUStringZValue(a)); | 1361 | s = fakeCString(vObjectUStringZValue(a)); |
1362 | alarm->setAudioAlarm(QFile::decodeName(s)); | 1362 | alarm->setAudioAlarm(QFile::decodeName(s)); |
1363 | deleteStr(s); | 1363 | deleteStr(s); |
1364 | } | 1364 | } |
1365 | } | 1365 | } |
1366 | } | 1366 | } |
1367 | 1367 | ||
1368 | // priority | 1368 | // priority |
1369 | if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { | 1369 | if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { |
1370 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1370 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1371 | deleteStr(s); | 1371 | deleteStr(s); |
1372 | } | 1372 | } |
1373 | 1373 | ||
1374 | // transparency | 1374 | // transparency |
1375 | if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { | 1375 | if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { |
1376 | int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); | 1376 | int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); |
1377 | anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); | 1377 | anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); |
1378 | deleteStr(s); | 1378 | deleteStr(s); |
1379 | } | 1379 | } |
1380 | 1380 | ||
1381 | // related event | 1381 | // related event |
1382 | if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { | 1382 | if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { |
1383 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); | 1383 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); |
1384 | deleteStr(s); | 1384 | deleteStr(s); |
1385 | mEventsRelate.append(anEvent); | 1385 | mEventsRelate.append(anEvent); |
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | /* PILOT SYNC STUFF */ | 1388 | /* PILOT SYNC STUFF */ |
1389 | if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { | 1389 | if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { |
1390 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1390 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1391 | deleteStr(s); | 1391 | deleteStr(s); |
1392 | } | 1392 | } |
1393 | else | 1393 | else |
1394 | anEvent->setPilotId(0); | 1394 | anEvent->setPilotId(0); |
1395 | 1395 | ||
1396 | if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { | 1396 | if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { |
1397 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1397 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1398 | deleteStr(s); | 1398 | deleteStr(s); |
1399 | } | 1399 | } |
1400 | else | 1400 | else |
1401 | anEvent->setSyncStatus(Event::SYNCMOD); | 1401 | anEvent->setSyncStatus(Event::SYNCMOD); |
1402 | 1402 | ||
1403 | return anEvent; | 1403 | return anEvent; |
1404 | } | 1404 | } |
1405 | 1405 | ||
1406 | 1406 | ||
1407 | QString VCalFormat::qDateToISO(const QDate &qd) | 1407 | QString VCalFormat::qDateToISO(const QDate &qd) |
1408 | { | 1408 | { |
1409 | QString tmpStr; | 1409 | QString tmpStr; |
1410 | 1410 | ||
1411 | ASSERT(qd.isValid()); | 1411 | ASSERT(qd.isValid()); |
1412 | 1412 | ||
1413 | tmpStr.sprintf("%.2d%.2d%.2d", | 1413 | tmpStr.sprintf("%.2d%.2d%.2d", |
1414 | qd.year(), qd.month(), qd.day()); | 1414 | qd.year(), qd.month(), qd.day()); |
1415 | return tmpStr; | 1415 | return tmpStr; |
1416 | 1416 | ||
1417 | } | 1417 | } |
1418 | 1418 | ||
1419 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) | 1419 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) |
1420 | { | 1420 | { |
1421 | QString tmpStr; | 1421 | QString tmpStr; |
1422 | 1422 | ||
1423 | ASSERT(qdt.date().isValid()); | 1423 | ASSERT(qdt.date().isValid()); |
1424 | ASSERT(qdt.time().isValid()); | 1424 | ASSERT(qdt.time().isValid()); |
1425 | if (zulu && !useLocalTime ) { | 1425 | if (zulu && !useLocalTime ) { |
1426 | QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); | 1426 | QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); |
1427 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", | 1427 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", |
1428 | tmpDT.date().year(), tmpDT.date().month(), | 1428 | tmpDT.date().year(), tmpDT.date().month(), |
1429 | tmpDT.date().day(), tmpDT.time().hour(), | 1429 | tmpDT.date().day(), tmpDT.time().hour(), |
1430 | tmpDT.time().minute(), tmpDT.time().second()); | 1430 | tmpDT.time().minute(), tmpDT.time().second()); |
1431 | } else { | 1431 | } else { |
1432 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", | 1432 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", |
1433 | qdt.date().year(), qdt.date().month(), | 1433 | qdt.date().year(), qdt.date().month(), |
1434 | qdt.date().day(), qdt.time().hour(), | 1434 | qdt.date().day(), qdt.time().hour(), |
1435 | qdt.time().minute(), qdt.time().second()); | 1435 | qdt.time().minute(), qdt.time().second()); |
1436 | } | 1436 | } |
1437 | return tmpStr; | 1437 | return tmpStr; |
1438 | } | 1438 | } |
1439 | 1439 | ||
1440 | QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) | 1440 | QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) |
1441 | { | 1441 | { |
1442 | QDate tmpDate; | 1442 | QDate tmpDate; |
1443 | QTime tmpTime; | 1443 | QTime tmpTime; |
1444 | QString tmpStr; | 1444 | QString tmpStr; |
1445 | int year, month, day, hour, minute, second; | 1445 | int year, month, day, hour, minute, second; |
1446 | 1446 | ||
1447 | tmpStr = dtStr; | 1447 | tmpStr = dtStr; |
1448 | year = tmpStr.left(4).toInt(); | 1448 | year = tmpStr.left(4).toInt(); |
1449 | month = tmpStr.mid(4,2).toInt(); | 1449 | month = tmpStr.mid(4,2).toInt(); |
1450 | day = tmpStr.mid(6,2).toInt(); | 1450 | day = tmpStr.mid(6,2).toInt(); |
1451 | hour = tmpStr.mid(9,2).toInt(); | 1451 | hour = tmpStr.mid(9,2).toInt(); |
1452 | minute = tmpStr.mid(11,2).toInt(); | 1452 | minute = tmpStr.mid(11,2).toInt(); |
1453 | second = tmpStr.mid(13,2).toInt(); | 1453 | second = tmpStr.mid(13,2).toInt(); |
1454 | tmpDate.setYMD(year, month, day); | 1454 | tmpDate.setYMD(year, month, day); |
1455 | tmpTime.setHMS(hour, minute, second); | 1455 | tmpTime.setHMS(hour, minute, second); |
1456 | 1456 | ||
1457 | ASSERT(tmpDate.isValid()); | 1457 | ASSERT(tmpDate.isValid()); |
1458 | ASSERT(tmpTime.isValid()); | 1458 | ASSERT(tmpTime.isValid()); |
1459 | QDateTime tmpDT(tmpDate, tmpTime); | 1459 | QDateTime tmpDT(tmpDate, tmpTime); |
1460 | // correct for GMT if string is in Zulu format | 1460 | // correct for GMT if string is in Zulu format |
1461 | if (dtStr.at(dtStr.length()-1) == 'Z') | 1461 | if (dtStr.at(dtStr.length()-1) == 'Z') |
1462 | tmpDT = tmpDT.addSecs (KGlobal::locale()->localTimeOffset( tmpDT )*60); | 1462 | tmpDT = tmpDT.addSecs (KGlobal::locale()->localTimeOffset( tmpDT )*60); |
1463 | return tmpDT; | 1463 | return tmpDT; |
1464 | } | 1464 | } |
1465 | 1465 | ||
1466 | QDate VCalFormat::ISOToQDate(const QString &dateStr) | 1466 | QDate VCalFormat::ISOToQDate(const QString &dateStr) |
1467 | { | 1467 | { |
1468 | int year, month, day; | 1468 | int year, month, day; |
1469 | 1469 | ||
1470 | year = dateStr.left(4).toInt(); | 1470 | year = dateStr.left(4).toInt(); |
1471 | month = dateStr.mid(4,2).toInt(); | 1471 | month = dateStr.mid(4,2).toInt(); |
1472 | day = dateStr.mid(6,2).toInt(); | 1472 | day = dateStr.mid(6,2).toInt(); |
1473 | 1473 | ||
1474 | return(QDate(year, month, day)); | 1474 | return(QDate(year, month, day)); |
1475 | } | 1475 | } |
1476 | 1476 | ||
1477 | // take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. | 1477 | // take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. |
1478 | // and break it down from it's tree-like format into the dictionary format | 1478 | // and break it down from it's tree-like format into the dictionary format |
1479 | // that is used internally in the VCalFormat. | 1479 | // that is used internally in the VCalFormat. |
1480 | void VCalFormat::populate(VObject *vcal) | 1480 | void VCalFormat::populate(VObject *vcal) |
1481 | { | 1481 | { |
1482 | // this function will populate the caldict dictionary and other event | 1482 | // this function will populate the caldict dictionary and other event |
1483 | // lists. It turns vevents into Events and then inserts them. | 1483 | // lists. It turns vevents into Events and then inserts them. |
1484 | 1484 | ||
1485 | VObjectIterator i; | 1485 | VObjectIterator i; |
1486 | VObject *curVO, *curVOProp; | 1486 | VObject *curVO, *curVOProp; |
1487 | Event *anEvent; | 1487 | Event *anEvent; |
1488 | 1488 | ||
1489 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { | 1489 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { |
1490 | char *methodType = 0; | 1490 | char *methodType = 0; |
1491 | methodType = fakeCString(vObjectUStringZValue(curVO)); | 1491 | methodType = fakeCString(vObjectUStringZValue(curVO)); |
1492 | kdDebug() << "This calendar is an iTIP transaction of type '" | 1492 | kdDebug() << "This calendar is an iTIP transaction of type '" |
1493 | << methodType << "'" << endl; | 1493 | << methodType << "'" << endl; |
1494 | delete methodType; | 1494 | delete methodType; |
1495 | } | 1495 | } |
1496 | 1496 | ||
1497 | // warn the user that we might have trouble reading non-known calendar. | 1497 | // warn the user that we might have trouble reading non-known calendar. |
1498 | if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { | 1498 | if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { |
1499 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1499 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1500 | if (strcmp(productId().local8Bit(), s) != 0) | 1500 | if (strcmp(productId().local8Bit(), s) != 0) |
1501 | kdDebug() << "This vCalendar file was not created by KOrganizer " | 1501 | kdDebug() << "This vCalendar file was not created by KOrganizer " |
1502 | "or any other product we support. Loading anyway..." << endl; | 1502 | "or any other product we support. Loading anyway..." << endl; |
1503 | mLoadedProductId = s; | 1503 | mLoadedProductId = s; |
1504 | deleteStr(s); | 1504 | deleteStr(s); |
1505 | } | 1505 | } |
1506 | 1506 | ||
1507 | // warn the user we might have trouble reading this unknown version. | 1507 | // warn the user we might have trouble reading this unknown version. |
1508 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { | 1508 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { |
1509 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1509 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1510 | if (strcmp(_VCAL_VERSION, s) != 0) | 1510 | if (strcmp(_VCAL_VERSION, s) != 0) |
1511 | kdDebug() << "This vCalendar file has version " << s | 1511 | kdDebug() << "This vCalendar file has version " << s |
1512 | << "We only support " << _VCAL_VERSION << endl; | 1512 | << "We only support " << _VCAL_VERSION << endl; |
1513 | deleteStr(s); | 1513 | deleteStr(s); |
1514 | } | 1514 | } |
1515 | 1515 | ||
1516 | // set the time zone | 1516 | // set the time zone |
1517 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { | 1517 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { |
1518 | if ( vObjectUStringZValue(curVO) != 0 ) { | 1518 | if ( vObjectUStringZValue(curVO) != 0 ) { |
1519 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1519 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1520 | mCalendar->setTimeZone(s); | 1520 | mCalendar->setTimeZone(s); |
1521 | deleteStr(s); | 1521 | deleteStr(s); |
1522 | } | 1522 | } |
1523 | } | 1523 | } |
1524 | 1524 | ||
1525 | // Store all events with a relatedTo property in a list for post-processing | 1525 | // Store all events with a relatedTo property in a list for post-processing |
1526 | mEventsRelate.clear(); | 1526 | mEventsRelate.clear(); |
1527 | mTodosRelate.clear(); | 1527 | mTodosRelate.clear(); |
1528 | 1528 | ||
1529 | initPropIterator(&i, vcal); | 1529 | initPropIterator(&i, vcal); |
1530 | 1530 | ||
1531 | // go through all the vobjects in the vcal | 1531 | // go through all the vobjects in the vcal |
1532 | while (moreIteration(&i)) { | 1532 | while (moreIteration(&i)) { |
1533 | curVO = nextVObject(&i); | 1533 | curVO = nextVObject(&i); |
1534 | 1534 | ||
1535 | /************************************************************************/ | 1535 | /************************************************************************/ |
1536 | 1536 | ||
1537 | // now, check to see that the object is an event or todo. | 1537 | // now, check to see that the object is an event or todo. |
1538 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { | 1538 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { |
1539 | 1539 | ||
1540 | if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) { | 1540 | if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) { |
1541 | char *s; | 1541 | char *s; |
1542 | s = fakeCString(vObjectUStringZValue(curVOProp)); | 1542 | s = fakeCString(vObjectUStringZValue(curVOProp)); |
1543 | // check to see if event was deleted by the kpilot conduit | 1543 | // check to see if event was deleted by the kpilot conduit |
1544 | if (atoi(s) == Event::SYNCDEL) { | 1544 | if (atoi(s) == Event::SYNCDEL) { |
1545 | deleteStr(s); | 1545 | deleteStr(s); |
1546 | kdDebug(5800) << "skipping pilot-deleted event" << endl; | 1546 | kdDebug(5800) << "skipping pilot-deleted event" << endl; |
1547 | goto SKIP; | 1547 | goto SKIP; |
1548 | } | 1548 | } |
1549 | deleteStr(s); | 1549 | deleteStr(s); |
1550 | } | 1550 | } |
1551 | 1551 | ||
1552 | // this code checks to see if we are trying to read in an event | 1552 | // this code checks to see if we are trying to read in an event |
1553 | // that we already find to be in the calendar. If we find this | 1553 | // that we already find to be in the calendar. If we find this |
1554 | // to be the case, we skip the event. | 1554 | // to be the case, we skip the event. |
1555 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { | 1555 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { |
1556 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); | 1556 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); |
1557 | QString tmpStr(s); | 1557 | QString tmpStr(s); |
1558 | deleteStr(s); | 1558 | deleteStr(s); |
1559 | 1559 | ||
1560 | if (mCalendar->event(tmpStr)) { | 1560 | if (mCalendar->event(tmpStr)) { |
1561 | goto SKIP; | 1561 | goto SKIP; |
1562 | } | 1562 | } |
1563 | if (mCalendar->todo(tmpStr)) { | 1563 | if (mCalendar->todo(tmpStr)) { |
1564 | goto SKIP; | 1564 | goto SKIP; |
1565 | } | 1565 | } |
1566 | } | 1566 | } |
1567 | 1567 | ||
1568 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && | 1568 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && |
1569 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { | 1569 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { |
1570 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; | 1570 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; |
1571 | goto SKIP; | 1571 | goto SKIP; |
1572 | } | 1572 | } |
1573 | 1573 | ||
1574 | anEvent = VEventToEvent(curVO); | 1574 | anEvent = VEventToEvent(curVO); |
1575 | // we now use addEvent instead of insertEvent so that the | 1575 | // we now use addEvent instead of insertEvent so that the |
1576 | // signal/slot get connected. | 1576 | // signal/slot get connected. |
1577 | if (anEvent) { | 1577 | if (anEvent) { |
1578 | if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) { | 1578 | if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) { |
1579 | kdDebug() << "VCalFormat::populate(): Event has invalid dates." | 1579 | kdDebug() << "VCalFormat::populate(): Event has invalid dates." |
1580 | << endl; | 1580 | << endl; |
1581 | } else { | 1581 | } else { |
1582 | mCalendar->addEvent(anEvent); | 1582 | mCalendar->addEvent(anEvent); |
1583 | } | 1583 | } |
1584 | } else { | 1584 | } else { |
1585 | // some sort of error must have occurred while in translation. | 1585 | // some sort of error must have occurred while in translation. |
1586 | goto SKIP; | 1586 | goto SKIP; |
1587 | } | 1587 | } |
1588 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { | 1588 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { |
1589 | Todo *aTodo = VTodoToEvent(curVO); | 1589 | Todo *aTodo = VTodoToEvent(curVO); |
1590 | mCalendar->addTodo(aTodo); | 1590 | mCalendar->addTodo(aTodo); |
1591 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || | 1591 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || |
1592 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || | 1592 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || |
1593 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { | 1593 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { |
1594 | // do nothing, we know these properties and we want to skip them. | 1594 | // do nothing, we know these properties and we want to skip them. |
1595 | // we have either already processed them or are ignoring them. | 1595 | // we have either already processed them or are ignoring them. |
1596 | ; | 1596 | ; |
1597 | } else { | 1597 | } else { |
1598 | kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; | 1598 | kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; |
1599 | } | 1599 | } |
1600 | SKIP: | 1600 | SKIP: |
1601 | ; | 1601 | ; |
1602 | } // while | 1602 | } // while |
1603 | 1603 | ||
1604 | // Post-Process list of events with relations, put Event objects in relation | 1604 | // Post-Process list of events with relations, put Event objects in relation |
1605 | Event *ev; | 1605 | Event *ev; |
1606 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { | 1606 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { |
1607 | ev->setRelatedTo(mCalendar->event(ev->relatedToUid())); | 1607 | Incidence * inc = mCalendar->event(ev->relatedToUid()); |
1608 | if ( inc ) | ||
1609 | ev->setRelatedTo( inc ); | ||
1608 | } | 1610 | } |
1609 | Todo *todo; | 1611 | Todo *todo; |
1610 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { | 1612 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { |
1611 | todo->setRelatedTo(mCalendar->todo(todo->relatedToUid())); | 1613 | Incidence * inc = mCalendar->todo(todo->relatedToUid()); |
1614 | if ( inc ) | ||
1615 | todo->setRelatedTo( inc ); | ||
1612 | } | 1616 | } |
1613 | } | 1617 | } |
1614 | 1618 | ||
1615 | const char *VCalFormat::dayFromNum(int day) | 1619 | const char *VCalFormat::dayFromNum(int day) |
1616 | { | 1620 | { |
1617 | const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; | 1621 | const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; |
1618 | 1622 | ||
1619 | return days[day]; | 1623 | return days[day]; |
1620 | } | 1624 | } |
1621 | 1625 | ||
1622 | int VCalFormat::numFromDay(const QString &day) | 1626 | int VCalFormat::numFromDay(const QString &day) |
1623 | { | 1627 | { |
1624 | if (day == "MO ") return 0; | 1628 | if (day == "MO ") return 0; |
1625 | if (day == "TU ") return 1; | 1629 | if (day == "TU ") return 1; |
1626 | if (day == "WE ") return 2; | 1630 | if (day == "WE ") return 2; |
1627 | if (day == "TH ") return 3; | 1631 | if (day == "TH ") return 3; |
1628 | if (day == "FR ") return 4; | 1632 | if (day == "FR ") return 4; |
1629 | if (day == "SA ") return 5; | 1633 | if (day == "SA ") return 5; |
1630 | if (day == "SU ") return 6; | 1634 | if (day == "SU ") return 6; |
1631 | 1635 | ||
1632 | return -1; // something bad happened. :) | 1636 | return -1; // something bad happened. :) |
1633 | } | 1637 | } |
1634 | Attendee::Role VCalFormat::readRole(const char *s) const | 1638 | Attendee::Role VCalFormat::readRole(const char *s) const |
1635 | { | 1639 | { |
1636 | QString statStr = s; | 1640 | QString statStr = s; |
1637 | statStr = statStr.upper(); | 1641 | statStr = statStr.upper(); |
1638 | Attendee::Role role = Attendee::ReqParticipant; | 1642 | Attendee::Role role = Attendee::ReqParticipant; |
1639 | 1643 | ||
1640 | if ( statStr == "OWNER") | 1644 | if ( statStr == "OWNER") |
1641 | role = Attendee::Chair; | 1645 | role = Attendee::Chair; |
1642 | // enum Role { ReqParticipant, OptParticipant, NonParticipant, Chair }; | 1646 | // enum Role { ReqParticipant, OptParticipant, NonParticipant, Chair }; |
1643 | 1647 | ||
1644 | return role; | 1648 | return role; |
1645 | } | 1649 | } |
1646 | 1650 | ||
1647 | QCString VCalFormat::writeRole(Attendee::Role role) const | 1651 | QCString VCalFormat::writeRole(Attendee::Role role) const |
1648 | { | 1652 | { |
1649 | if ( role == Attendee::Chair ) | 1653 | if ( role == Attendee::Chair ) |
1650 | return "OWNER"; | 1654 | return "OWNER"; |
1651 | return "ATTENDEE"; | 1655 | return "ATTENDEE"; |
1652 | } | 1656 | } |
1653 | Attendee::PartStat VCalFormat::readStatus(const char *s) const | 1657 | Attendee::PartStat VCalFormat::readStatus(const char *s) const |
1654 | { | 1658 | { |
1655 | QString statStr = s; | 1659 | QString statStr = s; |
1656 | statStr = statStr.upper(); | 1660 | statStr = statStr.upper(); |
1657 | Attendee::PartStat status; | 1661 | Attendee::PartStat status; |
1658 | 1662 | ||
1659 | if (statStr == "X-ACTION") | 1663 | if (statStr == "X-ACTION") |
1660 | status = Attendee::NeedsAction; | 1664 | status = Attendee::NeedsAction; |
1661 | else if (statStr == "NEEDS ACTION") | 1665 | else if (statStr == "NEEDS ACTION") |
1662 | status = Attendee::NeedsAction; | 1666 | status = Attendee::NeedsAction; |
1663 | else if (statStr== "ACCEPTED") | 1667 | else if (statStr== "ACCEPTED") |
1664 | status = Attendee::Accepted; | 1668 | status = Attendee::Accepted; |
1665 | else if (statStr== "SENT") | 1669 | else if (statStr== "SENT") |
1666 | status = Attendee::NeedsAction; | 1670 | status = Attendee::NeedsAction; |
1667 | else if (statStr== "TENTATIVE") | 1671 | else if (statStr== "TENTATIVE") |
1668 | status = Attendee::Tentative; | 1672 | status = Attendee::Tentative; |
1669 | else if (statStr== "CONFIRMED") | 1673 | else if (statStr== "CONFIRMED") |
1670 | status = Attendee::Accepted; | 1674 | status = Attendee::Accepted; |
1671 | else if (statStr== "DECLINED") | 1675 | else if (statStr== "DECLINED") |
1672 | status = Attendee::Declined; | 1676 | status = Attendee::Declined; |
1673 | else if (statStr== "COMPLETED") | 1677 | else if (statStr== "COMPLETED") |
1674 | status = Attendee::Completed; | 1678 | status = Attendee::Completed; |
1675 | else if (statStr== "DELEGATED") | 1679 | else if (statStr== "DELEGATED") |
1676 | status = Attendee::Delegated; | 1680 | status = Attendee::Delegated; |
1677 | else { | 1681 | else { |
1678 | kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl; | 1682 | kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl; |
1679 | status = Attendee::NeedsAction; | 1683 | status = Attendee::NeedsAction; |
1680 | } | 1684 | } |
1681 | 1685 | ||
1682 | return status; | 1686 | return status; |
1683 | } | 1687 | } |
1684 | 1688 | ||
1685 | QCString VCalFormat::writeStatus(Attendee::PartStat status) const | 1689 | QCString VCalFormat::writeStatus(Attendee::PartStat status) const |
1686 | { | 1690 | { |
1687 | switch(status) { | 1691 | switch(status) { |
1688 | default: | 1692 | default: |
1689 | case Attendee::NeedsAction: | 1693 | case Attendee::NeedsAction: |
1690 | return "NEEDS ACTION"; | 1694 | return "NEEDS ACTION"; |
1691 | break; | 1695 | break; |
1692 | case Attendee::Accepted: | 1696 | case Attendee::Accepted: |
1693 | return "ACCEPTED"; | 1697 | return "ACCEPTED"; |
1694 | break; | 1698 | break; |
1695 | case Attendee::Declined: | 1699 | case Attendee::Declined: |
1696 | return "DECLINED"; | 1700 | return "DECLINED"; |
1697 | break; | 1701 | break; |
1698 | case Attendee::Tentative: | 1702 | case Attendee::Tentative: |
1699 | return "TENTATIVE"; | 1703 | return "TENTATIVE"; |
1700 | break; | 1704 | break; |
1701 | case Attendee::Delegated: | 1705 | case Attendee::Delegated: |
1702 | return "DELEGATED"; | 1706 | return "DELEGATED"; |
1703 | break; | 1707 | break; |
1704 | case Attendee::Completed: | 1708 | case Attendee::Completed: |
1705 | return "COMPLETED"; | 1709 | return "COMPLETED"; |
1706 | break; | 1710 | break; |
1707 | case Attendee::InProcess: | 1711 | case Attendee::InProcess: |
1708 | return "NEEDS ACTION"; | 1712 | return "NEEDS ACTION"; |
1709 | break; | 1713 | break; |
1710 | } | 1714 | } |
1711 | } | 1715 | } |