Diffstat (limited to 'libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp index 0ebda98..77c0253 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp | |||
@@ -37,26 +37,26 @@ | |||
37 | #include <sys/stat.h> | 37 | #include <sys/stat.h> |
38 | 38 | ||
39 | #include <unistd.h> | 39 | #include <unistd.h> |
40 | 40 | ||
41 | #include <qasciidict.h> | 41 | #include <qasciidict.h> |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | 43 | ||
44 | #include <qtopia/global.h> | 44 | #include <qtopia/global.h> |
45 | #include <qtopia/stringutil.h> | 45 | #include <qtopia/stringutil.h> |
46 | #include <qtopia/timeconversion.h> | 46 | #include <qtopia/timeconversion.h> |
47 | 47 | ||
48 | #include <opie2/opimnotifymanager.h> | 48 | #include <opie2/opimnotifymanager.h> |
49 | #include <opie2/orecur.h> | 49 | #include <opie2/opimrecurrence.h> |
50 | #include <opie2/otimezone.h> | 50 | #include <opie2/opimtimezone.h> |
51 | #include <opie2/odatebookaccessbackend_xml.h> | 51 | #include <opie2/odatebookaccessbackend_xml.h> |
52 | 52 | ||
53 | using namespace Opie; | 53 | using namespace Opie; |
54 | 54 | ||
55 | namespace { | 55 | namespace { |
56 | // FROM TT again | 56 | // FROM TT again |
57 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) | 57 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) |
58 | { | 58 | { |
59 | char needleChar; | 59 | char needleChar; |
60 | char haystackChar; | 60 | char haystackChar; |
61 | if (!needle || !haystack || !hLen || !nLen) | 61 | if (!needle || !haystack || !hLen || !nLen) |
62 | return 0; | 62 | return 0; |
@@ -72,28 +72,28 @@ char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) | |||
72 | if (hsearch >= haystack + hLen) | 72 | if (hsearch >= haystack + hLen) |
73 | return (0); | 73 | return (0); |
74 | } while (haystackChar != needleChar); | 74 | } while (haystackChar != needleChar); |
75 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); | 75 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); |
76 | hsearch--; | 76 | hsearch--; |
77 | } | 77 | } |
78 | return ((char *)hsearch); | 78 | return ((char *)hsearch); |
79 | } | 79 | } |
80 | } | 80 | } |
81 | 81 | ||
82 | namespace { | 82 | namespace { |
83 | time_t start, end, created, rp_end; | 83 | time_t start, end, created, rp_end; |
84 | ORecur* rec; | 84 | OPimRecurrence* rec; |
85 | ORecur* recur() { | 85 | OPimRecurrence* recur() { |
86 | if (!rec) | 86 | if (!rec) |
87 | rec = new ORecur; | 87 | rec = new OPimRecurrence; |
88 | 88 | ||
89 | return rec; | 89 | return rec; |
90 | } | 90 | } |
91 | int alarmTime; | 91 | int alarmTime; |
92 | int snd; | 92 | int snd; |
93 | enum Attribute{ | 93 | enum Attribute{ |
94 | FDescription = 0, | 94 | FDescription = 0, |
95 | FLocation, | 95 | FLocation, |
96 | FCategories, | 96 | FCategories, |
97 | FUid, | 97 | FUid, |
98 | FType, | 98 | FType, |
99 | FAlarm, | 99 | FAlarm, |
@@ -105,26 +105,26 @@ namespace { | |||
105 | FRHasEndDate, | 105 | FRHasEndDate, |
106 | FREndDate, | 106 | FREndDate, |
107 | FRStart, | 107 | FRStart, |
108 | FREnd, | 108 | FREnd, |
109 | FNote, | 109 | FNote, |
110 | FCreated, // Should't this be called FRCreated ? | 110 | FCreated, // Should't this be called FRCreated ? |
111 | FTimeZone, | 111 | FTimeZone, |
112 | FRecParent, | 112 | FRecParent, |
113 | FRecChildren, | 113 | FRecChildren, |
114 | FExceptions | 114 | FExceptions |
115 | }; | 115 | }; |
116 | 116 | ||
117 | // FIXME: Use OEvent::toMap() here !! (eilers) | 117 | // FIXME: Use OPimEvent::toMap() here !! (eilers) |
118 | inline void save( const OEvent& ev, QString& buf ) { | 118 | inline void save( const OPimEvent& ev, QString& buf ) { |
119 | qWarning("Saving %d %s", ev.uid(), ev.description().latin1() ); | 119 | qWarning("Saving %d %s", ev.uid(), ev.description().latin1() ); |
120 | buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\""; | 120 | buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\""; |
121 | if (!ev.location().isEmpty() ) | 121 | if (!ev.location().isEmpty() ) |
122 | buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\""; | 122 | buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\""; |
123 | 123 | ||
124 | buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\""; | 124 | buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\""; |
125 | buf += " uid=\"" + QString::number( ev.uid() ) + "\""; | 125 | buf += " uid=\"" + QString::number( ev.uid() ) + "\""; |
126 | 126 | ||
127 | if (ev.isAllDay() ) | 127 | if (ev.isAllDay() ) |
128 | buf += " type=\"AllDay\""; // is that all ?? (eilers) | 128 | buf += " type=\"AllDay\""; // is that all ?? (eilers) |
129 | 129 | ||
130 | if (ev.hasNotifiers() ) { | 130 | if (ev.hasNotifiers() ) { |
@@ -137,27 +137,27 @@ namespace { | |||
137 | buf += "silent"; | 137 | buf += "silent"; |
138 | buf += "\""; | 138 | buf += "\""; |
139 | } | 139 | } |
140 | if ( ev.hasRecurrence() ) { | 140 | if ( ev.hasRecurrence() ) { |
141 | buf += ev.recurrence().toString(); | 141 | buf += ev.recurrence().toString(); |
142 | } | 142 | } |
143 | 143 | ||
144 | /* | 144 | /* |
145 | * fscking timezones :) well, we'll first convert | 145 | * fscking timezones :) well, we'll first convert |
146 | * the QDateTime to a QDateTime in UTC time | 146 | * the QDateTime to a QDateTime in UTC time |
147 | * and then we'll create a nice time_t | 147 | * and then we'll create a nice time_t |
148 | */ | 148 | */ |
149 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); | 149 | OPimTimeZone zone( ev.timeZone().isEmpty() ? OPimTimeZone::current() : ev.timeZone() ); |
150 | buf += " start=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.startDateTime(), OTimeZone::utc() ) ) ) + "\""; | 150 | buf += " start=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.startDateTime(), OPimTimeZone::utc() ) ) ) + "\""; |
151 | buf += " end=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.endDateTime() , OTimeZone::utc() ) ) ) + "\""; | 151 | buf += " end=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.endDateTime() , OPimTimeZone::utc() ) ) ) + "\""; |
152 | if (!ev.note().isEmpty() ) { | 152 | if (!ev.note().isEmpty() ) { |
153 | buf += " note=\"" + Qtopia::escapeString( ev.note() ) + "\""; | 153 | buf += " note=\"" + Qtopia::escapeString( ev.note() ) + "\""; |
154 | } | 154 | } |
155 | 155 | ||
156 | buf += " timezone=\""; | 156 | buf += " timezone=\""; |
157 | if ( ev.timeZone().isEmpty() ) | 157 | if ( ev.timeZone().isEmpty() ) |
158 | buf += "None"; | 158 | buf += "None"; |
159 | else | 159 | else |
160 | buf += ev.timeZone(); | 160 | buf += ev.timeZone(); |
161 | buf += "\""; | 161 | buf += "\""; |
162 | 162 | ||
163 | if (ev.parent() != 0 ) { | 163 | if (ev.parent() != 0 ) { |
@@ -168,26 +168,26 @@ namespace { | |||
168 | QArray<int> children = ev.children(); | 168 | QArray<int> children = ev.children(); |
169 | buf += " recchildren=\""; | 169 | buf += " recchildren=\""; |
170 | for ( uint i = 0; i < children.count(); i++ ) { | 170 | for ( uint i = 0; i < children.count(); i++ ) { |
171 | if ( i != 0 ) buf += " "; | 171 | if ( i != 0 ) buf += " "; |
172 | buf += QString::number( children[i] ); | 172 | buf += QString::number( children[i] ); |
173 | } | 173 | } |
174 | buf+= "\""; | 174 | buf+= "\""; |
175 | } | 175 | } |
176 | 176 | ||
177 | // skip custom writing | 177 | // skip custom writing |
178 | } | 178 | } |
179 | 179 | ||
180 | inline bool forAll( const QMap<int, OEvent>& list, QFile& file ) { | 180 | inline bool forAll( const QMap<int, OPimEvent>& list, QFile& file ) { |
181 | QMap<int, OEvent>::ConstIterator it; | 181 | QMap<int, OPimEvent>::ConstIterator it; |
182 | QString buf; | 182 | QString buf; |
183 | QCString str; | 183 | QCString str; |
184 | int total_written; | 184 | int total_written; |
185 | for ( it = list.begin(); it != list.end(); ++it ) { | 185 | for ( it = list.begin(); it != list.end(); ++it ) { |
186 | buf = "<event"; | 186 | buf = "<event"; |
187 | save( it.data(), buf ); | 187 | save( it.data(), buf ); |
188 | buf += " />\n"; | 188 | buf += " />\n"; |
189 | str = buf.utf8(); | 189 | str = buf.utf8(); |
190 | 190 | ||
191 | total_written = file.writeBlock(str.data(), str.length() ); | 191 | total_written = file.writeBlock(str.data(), str.length() ); |
192 | if ( total_written != int(str.length() ) ) | 192 | if ( total_written != int(str.length() ) ) |
193 | return false; | 193 | return false; |
@@ -255,116 +255,116 @@ bool ODateBookAccessBackend_XML::save() { | |||
255 | 255 | ||
256 | if ( ::rename( strFileNew, m_name ) < 0 ) { | 256 | if ( ::rename( strFileNew, m_name ) < 0 ) { |
257 | QFile::remove( strFileNew ); | 257 | QFile::remove( strFileNew ); |
258 | return false; | 258 | return false; |
259 | } | 259 | } |
260 | 260 | ||
261 | m_changed = false; | 261 | m_changed = false; |
262 | return true; | 262 | return true; |
263 | } | 263 | } |
264 | QArray<int> ODateBookAccessBackend_XML::allRecords()const { | 264 | QArray<int> ODateBookAccessBackend_XML::allRecords()const { |
265 | QArray<int> ints( m_raw.count()+ m_rep.count() ); | 265 | QArray<int> ints( m_raw.count()+ m_rep.count() ); |
266 | uint i = 0; | 266 | uint i = 0; |
267 | QMap<int, OEvent>::ConstIterator it; | 267 | QMap<int, OPimEvent>::ConstIterator it; |
268 | 268 | ||
269 | for ( it = m_raw.begin(); it != m_raw.end(); ++it ) { | 269 | for ( it = m_raw.begin(); it != m_raw.end(); ++it ) { |
270 | ints[i] = it.key(); | 270 | ints[i] = it.key(); |
271 | i++; | 271 | i++; |
272 | } | 272 | } |
273 | for ( it = m_rep.begin(); it != m_rep.end(); ++it ) { | 273 | for ( it = m_rep.begin(); it != m_rep.end(); ++it ) { |
274 | ints[i] = it.key(); | 274 | ints[i] = it.key(); |
275 | i++; | 275 | i++; |
276 | } | 276 | } |
277 | 277 | ||
278 | return ints; | 278 | return ints; |
279 | } | 279 | } |
280 | QArray<int> ODateBookAccessBackend_XML::queryByExample(const OEvent&, int, const QDateTime& ) { | 280 | QArray<int> ODateBookAccessBackend_XML::queryByExample(const OPimEvent&, int, const QDateTime& ) { |
281 | return QArray<int>(); | 281 | return QArray<int>(); |
282 | } | 282 | } |
283 | void ODateBookAccessBackend_XML::clear() { | 283 | void ODateBookAccessBackend_XML::clear() { |
284 | m_changed = true; | 284 | m_changed = true; |
285 | m_raw.clear(); | 285 | m_raw.clear(); |
286 | m_rep.clear(); | 286 | m_rep.clear(); |
287 | } | 287 | } |
288 | OEvent ODateBookAccessBackend_XML::find( int uid ) const{ | 288 | OPimEvent ODateBookAccessBackend_XML::find( int uid ) const{ |
289 | if ( m_raw.contains( uid ) ) | 289 | if ( m_raw.contains( uid ) ) |
290 | return m_raw[uid]; | 290 | return m_raw[uid]; |
291 | else | 291 | else |
292 | return m_rep[uid]; | 292 | return m_rep[uid]; |
293 | } | 293 | } |
294 | bool ODateBookAccessBackend_XML::add( const OEvent& ev ) { | 294 | bool ODateBookAccessBackend_XML::add( const OPimEvent& ev ) { |
295 | m_changed = true; | 295 | m_changed = true; |
296 | if (ev.hasRecurrence() ) | 296 | if (ev.hasRecurrence() ) |
297 | m_rep.insert( ev.uid(), ev ); | 297 | m_rep.insert( ev.uid(), ev ); |
298 | else | 298 | else |
299 | m_raw.insert( ev.uid(), ev ); | 299 | m_raw.insert( ev.uid(), ev ); |
300 | 300 | ||
301 | return true; | 301 | return true; |
302 | } | 302 | } |
303 | bool ODateBookAccessBackend_XML::remove( int uid ) { | 303 | bool ODateBookAccessBackend_XML::remove( int uid ) { |
304 | m_changed = true; | 304 | m_changed = true; |
305 | m_rep.remove( uid ); | 305 | m_rep.remove( uid ); |
306 | m_rep.remove( uid ); | 306 | m_rep.remove( uid ); |
307 | 307 | ||
308 | return true; | 308 | return true; |
309 | } | 309 | } |
310 | bool ODateBookAccessBackend_XML::replace( const OEvent& ev ) { | 310 | bool ODateBookAccessBackend_XML::replace( const OPimEvent& ev ) { |
311 | replace( ev.uid() ); // ??? Shouldn't this be "remove( ev.uid() ) ??? (eilers) | 311 | replace( ev.uid() ); // ??? Shouldn't this be "remove( ev.uid() ) ??? (eilers) |
312 | return add( ev ); | 312 | return add( ev ); |
313 | } | 313 | } |
314 | QArray<int> ODateBookAccessBackend_XML::rawEvents()const { | 314 | QArray<int> ODateBookAccessBackend_XML::rawEvents()const { |
315 | return allRecords(); | 315 | return allRecords(); |
316 | } | 316 | } |
317 | QArray<int> ODateBookAccessBackend_XML::rawRepeats()const { | 317 | QArray<int> ODateBookAccessBackend_XML::rawRepeats()const { |
318 | QArray<int> ints( m_rep.count() ); | 318 | QArray<int> ints( m_rep.count() ); |
319 | uint i = 0; | 319 | uint i = 0; |
320 | QMap<int, OEvent>::ConstIterator it; | 320 | QMap<int, OPimEvent>::ConstIterator it; |
321 | 321 | ||
322 | for ( it = m_rep.begin(); it != m_rep.end(); ++it ) { | 322 | for ( it = m_rep.begin(); it != m_rep.end(); ++it ) { |
323 | ints[i] = it.key(); | 323 | ints[i] = it.key(); |
324 | i++; | 324 | i++; |
325 | } | 325 | } |
326 | 326 | ||
327 | return ints; | 327 | return ints; |
328 | } | 328 | } |
329 | QArray<int> ODateBookAccessBackend_XML::nonRepeats()const { | 329 | QArray<int> ODateBookAccessBackend_XML::nonRepeats()const { |
330 | QArray<int> ints( m_raw.count() ); | 330 | QArray<int> ints( m_raw.count() ); |
331 | uint i = 0; | 331 | uint i = 0; |
332 | QMap<int, OEvent>::ConstIterator it; | 332 | QMap<int, OPimEvent>::ConstIterator it; |
333 | 333 | ||
334 | for ( it = m_raw.begin(); it != m_raw.end(); ++it ) { | 334 | for ( it = m_raw.begin(); it != m_raw.end(); ++it ) { |
335 | ints[i] = it.key(); | 335 | ints[i] = it.key(); |
336 | i++; | 336 | i++; |
337 | } | 337 | } |
338 | 338 | ||
339 | return ints; | 339 | return ints; |
340 | } | 340 | } |
341 | OEvent::ValueList ODateBookAccessBackend_XML::directNonRepeats() { | 341 | OPimEvent::ValueList ODateBookAccessBackend_XML::directNonRepeats() { |
342 | OEvent::ValueList list; | 342 | OPimEvent::ValueList list; |
343 | QMap<int, OEvent>::ConstIterator it; | 343 | QMap<int, OPimEvent>::ConstIterator it; |
344 | for (it = m_raw.begin(); it != m_raw.end(); ++it ) | 344 | for (it = m_raw.begin(); it != m_raw.end(); ++it ) |
345 | list.append( it.data() ); | 345 | list.append( it.data() ); |
346 | 346 | ||
347 | return list; | 347 | return list; |
348 | } | 348 | } |
349 | OEvent::ValueList ODateBookAccessBackend_XML::directRawRepeats() { | 349 | OPimEvent::ValueList ODateBookAccessBackend_XML::directRawRepeats() { |
350 | OEvent::ValueList list; | 350 | OPimEvent::ValueList list; |
351 | QMap<int, OEvent>::ConstIterator it; | 351 | QMap<int, OPimEvent>::ConstIterator it; |
352 | for (it = m_rep.begin(); it != m_rep.end(); ++it ) | 352 | for (it = m_rep.begin(); it != m_rep.end(); ++it ) |
353 | list.append( it.data() ); | 353 | list.append( it.data() ); |
354 | 354 | ||
355 | return list; | 355 | return list; |
356 | } | 356 | } |
357 | 357 | ||
358 | // FIXME: Use OEvent::fromMap() (eilers) | 358 | // FIXME: Use OPimEvent::fromMap() (eilers) |
359 | bool ODateBookAccessBackend_XML::loadFile() { | 359 | bool ODateBookAccessBackend_XML::loadFile() { |
360 | m_changed = false; | 360 | m_changed = false; |
361 | 361 | ||
362 | int fd = ::open( QFile::encodeName(m_name).data(), O_RDONLY ); | 362 | int fd = ::open( QFile::encodeName(m_name).data(), O_RDONLY ); |
363 | if ( fd < 0 ) return false; | 363 | if ( fd < 0 ) return false; |
364 | 364 | ||
365 | struct stat attribute; | 365 | struct stat attribute; |
366 | if ( ::fstat(fd, &attribute ) == -1 ) { | 366 | if ( ::fstat(fd, &attribute ) == -1 ) { |
367 | ::close( fd ); | 367 | ::close( fd ); |
368 | return false; | 368 | return false; |
369 | } | 369 | } |
370 | void* map_addr = ::mmap(NULL, attribute.st_size, PROT_READ, MAP_SHARED, fd, 0 ); | 370 | void* map_addr = ::mmap(NULL, attribute.st_size, PROT_READ, MAP_SHARED, fd, 0 ); |
@@ -405,25 +405,25 @@ bool ODateBookAccessBackend_XML::loadFile() { | |||
405 | int i = 0; | 405 | int i = 0; |
406 | char* point; | 406 | char* point; |
407 | const char* collectionString = "<event "; | 407 | const char* collectionString = "<event "; |
408 | int strLen = ::strlen(collectionString); | 408 | int strLen = ::strlen(collectionString); |
409 | int *find; | 409 | int *find; |
410 | while ( ( point = ::strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0 ) { | 410 | while ( ( point = ::strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0 ) { |
411 | i = point -dt; | 411 | i = point -dt; |
412 | i+= strLen; | 412 | i+= strLen; |
413 | 413 | ||
414 | alarmTime = -1; | 414 | alarmTime = -1; |
415 | snd = 0; // silent | 415 | snd = 0; // silent |
416 | 416 | ||
417 | OEvent ev; | 417 | OPimEvent ev; |
418 | rec = 0; | 418 | rec = 0; |
419 | 419 | ||
420 | while ( TRUE ) { | 420 | while ( TRUE ) { |
421 | while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) | 421 | while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) |
422 | ++i; | 422 | ++i; |
423 | if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) | 423 | if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) |
424 | break; | 424 | break; |
425 | 425 | ||
426 | 426 | ||
427 | // we have another attribute, read it. | 427 | // we have another attribute, read it. |
428 | int j = i; | 428 | int j = i; |
429 | while ( j < len && dt[j] != '=' ) | 429 | while ( j < len && dt[j] != '=' ) |
@@ -471,69 +471,69 @@ bool ODateBookAccessBackend_XML::loadFile() { | |||
471 | } | 471 | } |
472 | } | 472 | } |
473 | /* time to finalize */ | 473 | /* time to finalize */ |
474 | finalizeRecord( ev ); | 474 | finalizeRecord( ev ); |
475 | delete rec; | 475 | delete rec; |
476 | } | 476 | } |
477 | ::munmap(map_addr, attribute.st_size ); | 477 | ::munmap(map_addr, attribute.st_size ); |
478 | m_changed = false; // changed during add | 478 | m_changed = false; // changed during add |
479 | 479 | ||
480 | return true; | 480 | return true; |
481 | } | 481 | } |
482 | 482 | ||
483 | // FIXME: Use OEvent::fromMap() which makes this obsolete.. (eilers) | 483 | // FIXME: Use OPimEvent::fromMap() which makes this obsolete.. (eilers) |
484 | void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { | 484 | void ODateBookAccessBackend_XML::finalizeRecord( OPimEvent& ev ) { |
485 | /* AllDay is alway in UTC */ | 485 | /* AllDay is alway in UTC */ |
486 | if ( ev.isAllDay() ) { | 486 | if ( ev.isAllDay() ) { |
487 | OTimeZone utc = OTimeZone::utc(); | 487 | OPimTimeZone utc = OPimTimeZone::utc(); |
488 | ev.setStartDateTime( utc.fromUTCDateTime( start ) ); | 488 | ev.setStartDateTime( utc.fromUTCDateTime( start ) ); |
489 | ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); | 489 | ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); |
490 | ev.setTimeZone( "UTC"); // make sure it is really utc | 490 | ev.setTimeZone( "UTC"); // make sure it is really utc |
491 | }else { | 491 | }else { |
492 | /* to current date time */ | 492 | /* to current date time */ |
493 | // qWarning(" Start is %d", start ); | 493 | // qWarning(" Start is %d", start ); |
494 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); | 494 | OPimTimeZone zone( ev.timeZone().isEmpty() ? OPimTimeZone::current() : ev.timeZone() ); |
495 | QDateTime date = zone.toDateTime( start ); | 495 | QDateTime date = zone.toDateTime( start ); |
496 | qWarning(" Start is %s", date.toString().latin1() ); | 496 | qWarning(" Start is %s", date.toString().latin1() ); |
497 | ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); | 497 | ev.setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) ); |
498 | 498 | ||
499 | date = zone.toDateTime( end ); | 499 | date = zone.toDateTime( end ); |
500 | ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); | 500 | ev.setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) ); |
501 | } | 501 | } |
502 | if ( rec && rec->doesRecur() ) { | 502 | if ( rec && rec->doesRecur() ) { |
503 | OTimeZone utc = OTimeZone::utc(); | 503 | OPimTimeZone utc = OPimTimeZone::utc(); |
504 | ORecur recu( *rec ); // call copy c'tor; | 504 | OPimRecurrence recu( *rec ); // call copy c'tor; |
505 | recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); | 505 | recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); |
506 | recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); | 506 | recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); |
507 | recu.setStart( ev.startDateTime().date() ); | 507 | recu.setStart( ev.startDateTime().date() ); |
508 | ev.setRecurrence( recu ); | 508 | ev.setRecurrence( recu ); |
509 | } | 509 | } |
510 | 510 | ||
511 | if (alarmTime != -1 ) { | 511 | if (alarmTime != -1 ) { |
512 | QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); | 512 | QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); |
513 | OPimAlarm al( snd , dt ); | 513 | OPimAlarm al( snd , dt ); |
514 | ev.notifiers().add( al ); | 514 | ev.notifiers().add( al ); |
515 | } | 515 | } |
516 | if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { | 516 | if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { |
517 | qWarning("already contains assign uid"); | 517 | qWarning("already contains assign uid"); |
518 | ev.setUid( 1 ); | 518 | ev.setUid( 1 ); |
519 | } | 519 | } |
520 | qWarning("addind %d %s", ev.uid(), ev.description().latin1() ); | 520 | qWarning("addind %d %s", ev.uid(), ev.description().latin1() ); |
521 | if ( ev.hasRecurrence() ) | 521 | if ( ev.hasRecurrence() ) |
522 | m_rep.insert( ev.uid(), ev ); | 522 | m_rep.insert( ev.uid(), ev ); |
523 | else | 523 | else |
524 | m_raw.insert( ev.uid(), ev ); | 524 | m_raw.insert( ev.uid(), ev ); |
525 | 525 | ||
526 | } | 526 | } |
527 | void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) { | 527 | void ODateBookAccessBackend_XML::setField( OPimEvent& e, int id, const QString& value) { |
528 | // qWarning(" setting %s", value.latin1() ); | 528 | // qWarning(" setting %s", value.latin1() ); |
529 | switch( id ) { | 529 | switch( id ) { |
530 | case FDescription: | 530 | case FDescription: |
531 | e.setDescription( value ); | 531 | e.setDescription( value ); |
532 | break; | 532 | break; |
533 | case FLocation: | 533 | case FLocation: |
534 | e.setLocation( value ); | 534 | e.setLocation( value ); |
535 | break; | 535 | break; |
536 | case FCategories: | 536 | case FCategories: |
537 | e.setCategories( e.idsFromString( value ) ); | 537 | e.setCategories( e.idsFromString( value ) ); |
538 | break; | 538 | break; |
539 | case FUid: | 539 | case FUid: |
@@ -545,35 +545,35 @@ void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& val | |||
545 | e.setTimeZone( "UTC" ); | 545 | e.setTimeZone( "UTC" ); |
546 | } | 546 | } |
547 | break; | 547 | break; |
548 | case FAlarm: | 548 | case FAlarm: |
549 | alarmTime = value.toInt(); | 549 | alarmTime = value.toInt(); |
550 | break; | 550 | break; |
551 | case FSound: | 551 | case FSound: |
552 | snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; | 552 | snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; |
553 | break; | 553 | break; |
554 | // recurrence stuff | 554 | // recurrence stuff |
555 | case FRType: | 555 | case FRType: |
556 | if ( value == "Daily" ) | 556 | if ( value == "Daily" ) |
557 | recur()->setType( ORecur::Daily ); | 557 | recur()->setType( OPimRecurrence::Daily ); |
558 | else if ( value == "Weekly" ) | 558 | else if ( value == "Weekly" ) |
559 | recur()->setType( ORecur::Weekly); | 559 | recur()->setType( OPimRecurrence::Weekly); |
560 | else if ( value == "MonthlyDay" ) | 560 | else if ( value == "MonthlyDay" ) |
561 | recur()->setType( ORecur::MonthlyDay ); | 561 | recur()->setType( OPimRecurrence::MonthlyDay ); |
562 | else if ( value == "MonthlyDate" ) | 562 | else if ( value == "MonthlyDate" ) |
563 | recur()->setType( ORecur::MonthlyDate ); | 563 | recur()->setType( OPimRecurrence::MonthlyDate ); |
564 | else if ( value == "Yearly" ) | 564 | else if ( value == "Yearly" ) |
565 | recur()->setType( ORecur::Yearly ); | 565 | recur()->setType( OPimRecurrence::Yearly ); |
566 | else | 566 | else |
567 | recur()->setType( ORecur::NoRepeat ); | 567 | recur()->setType( OPimRecurrence::NoRepeat ); |
568 | break; | 568 | break; |
569 | case FRWeekdays: | 569 | case FRWeekdays: |
570 | recur()->setDays( value.toInt() ); | 570 | recur()->setDays( value.toInt() ); |
571 | break; | 571 | break; |
572 | case FRPosition: | 572 | case FRPosition: |
573 | recur()->setPosition( value.toInt() ); | 573 | recur()->setPosition( value.toInt() ); |
574 | break; | 574 | break; |
575 | case FRFreq: | 575 | case FRFreq: |
576 | recur()->setFrequency( value.toInt() ); | 576 | recur()->setFrequency( value.toInt() ); |
577 | break; | 577 | break; |
578 | case FRHasEndDate: | 578 | case FRHasEndDate: |
579 | recur()->setHasEndDate( value.toInt() ); | 579 | recur()->setHasEndDate( value.toInt() ); |
@@ -618,25 +618,25 @@ void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& val | |||
618 | case FTimeZone: | 618 | case FTimeZone: |
619 | if ( value != "None" ) | 619 | if ( value != "None" ) |
620 | e.setTimeZone( value ); | 620 | e.setTimeZone( value ); |
621 | break; | 621 | break; |
622 | default: | 622 | default: |
623 | break; | 623 | break; |
624 | } | 624 | } |
625 | } | 625 | } |
626 | QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const | 626 | QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const |
627 | { | 627 | { |
628 | QArray<int> m_currentQuery( m_raw.count()+ m_rep.count() ); | 628 | QArray<int> m_currentQuery( m_raw.count()+ m_rep.count() ); |
629 | uint arraycounter = 0; | 629 | uint arraycounter = 0; |
630 | QMap<int, OEvent>::ConstIterator it; | 630 | QMap<int, OPimEvent>::ConstIterator it; |
631 | 631 | ||
632 | for ( it = m_raw.begin(); it != m_raw.end(); ++it ) | 632 | for ( it = m_raw.begin(); it != m_raw.end(); ++it ) |
633 | if ( it.data().match( r ) ) | 633 | if ( it.data().match( r ) ) |
634 | m_currentQuery[arraycounter++] = it.data().uid(); | 634 | m_currentQuery[arraycounter++] = it.data().uid(); |
635 | for ( it = m_rep.begin(); it != m_rep.end(); ++it ) | 635 | for ( it = m_rep.begin(); it != m_rep.end(); ++it ) |
636 | if ( it.data().match( r ) ) | 636 | if ( it.data().match( r ) ) |
637 | m_currentQuery[arraycounter++] = it.data().uid(); | 637 | m_currentQuery[arraycounter++] = it.data().uid(); |
638 | 638 | ||
639 | // Shrink to fit.. | 639 | // Shrink to fit.. |
640 | m_currentQuery.resize(arraycounter); | 640 | m_currentQuery.resize(arraycounter); |
641 | 641 | ||
642 | return m_currentQuery; | 642 | return m_currentQuery; |