author | eilers <eilers> | 2003-12-08 15:18:10 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-12-08 15:18:10 (UTC) |
commit | 6974a4bbdc674a2a5d41d801f80035a183faedb5 (patch) (unidiff) | |
tree | 09a719ef263047e92ffb866da13168b7f7d41f23 /libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp | |
parent | 7f2f736597490fd1592d7ed1f40e4abf824673c0 (diff) | |
download | opie-6974a4bbdc674a2a5d41d801f80035a183faedb5.zip opie-6974a4bbdc674a2a5d41d801f80035a183faedb5.tar.gz opie-6974a4bbdc674a2a5d41d801f80035a183faedb5.tar.bz2 |
Committing unfinished sql implementation before merging to libopie2 starts..
Diffstat (limited to 'libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp index 39c43c5..929d004 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp | |||
@@ -68,30 +68,32 @@ namespace { | |||
68 | FType, | 68 | FType, |
69 | FAlarm, | 69 | FAlarm, |
70 | FSound, | 70 | FSound, |
71 | FRType, | 71 | FRType, |
72 | FRWeekdays, | 72 | FRWeekdays, |
73 | FRPosition, | 73 | FRPosition, |
74 | FRFreq, | 74 | FRFreq, |
75 | FRHasEndDate, | 75 | FRHasEndDate, |
76 | FREndDate, | 76 | FREndDate, |
77 | FRStart, | 77 | FRStart, |
78 | FREnd, | 78 | FREnd, |
79 | FNote, | 79 | FNote, |
80 | FCreated, | 80 | FCreated, // Should't this be called FRCreated ? |
81 | FTimeZone, | 81 | FTimeZone, |
82 | FRecParent, | 82 | FRecParent, |
83 | FRecChildren, | 83 | FRecChildren, |
84 | FExceptions | 84 | FExceptions |
85 | }; | 85 | }; |
86 | |||
87 | // FIXME: Use OEvent::toMap() here !! (eilers) | ||
86 | inline void save( const OEvent& ev, QString& buf ) { | 88 | inline void save( const OEvent& ev, QString& buf ) { |
87 | qWarning("Saving %d %s", ev.uid(), ev.description().latin1() ); | 89 | qWarning("Saving %d %s", ev.uid(), ev.description().latin1() ); |
88 | buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\""; | 90 | buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\""; |
89 | if (!ev.location().isEmpty() ) | 91 | if (!ev.location().isEmpty() ) |
90 | buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\""; | 92 | buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\""; |
91 | 93 | ||
92 | buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\""; | 94 | buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\""; |
93 | buf += " uid=\"" + QString::number( ev.uid() ) + "\""; | 95 | buf += " uid=\"" + QString::number( ev.uid() ) + "\""; |
94 | 96 | ||
95 | if (ev.isAllDay() ) | 97 | if (ev.isAllDay() ) |
96 | buf += " type=\"AllDay\""; // is that all ?? (eilers) | 98 | buf += " type=\"AllDay\""; // is that all ?? (eilers) |
97 | 99 | ||
@@ -266,25 +268,25 @@ bool ODateBookAccessBackend_XML::add( const OEvent& ev ) { | |||
266 | m_raw.insert( ev.uid(), ev ); | 268 | m_raw.insert( ev.uid(), ev ); |
267 | 269 | ||
268 | return true; | 270 | return true; |
269 | } | 271 | } |
270 | bool ODateBookAccessBackend_XML::remove( int uid ) { | 272 | bool ODateBookAccessBackend_XML::remove( int uid ) { |
271 | m_changed = true; | 273 | m_changed = true; |
272 | m_rep.remove( uid ); | 274 | m_rep.remove( uid ); |
273 | m_rep.remove( uid ); | 275 | m_rep.remove( uid ); |
274 | 276 | ||
275 | return true; | 277 | return true; |
276 | } | 278 | } |
277 | bool ODateBookAccessBackend_XML::replace( const OEvent& ev ) { | 279 | bool ODateBookAccessBackend_XML::replace( const OEvent& ev ) { |
278 | replace( ev.uid() ); | 280 | replace( ev.uid() ); // ??? Shouldn't this be "remove( ev.uid() ) ??? (eilers) |
279 | return add( ev ); | 281 | return add( ev ); |
280 | } | 282 | } |
281 | QArray<int> ODateBookAccessBackend_XML::rawEvents()const { | 283 | QArray<int> ODateBookAccessBackend_XML::rawEvents()const { |
282 | return allRecords(); | 284 | return allRecords(); |
283 | } | 285 | } |
284 | QArray<int> ODateBookAccessBackend_XML::rawRepeats()const { | 286 | QArray<int> ODateBookAccessBackend_XML::rawRepeats()const { |
285 | QArray<int> ints( m_rep.count() ); | 287 | QArray<int> ints( m_rep.count() ); |
286 | uint i = 0; | 288 | uint i = 0; |
287 | QMap<int, OEvent>::ConstIterator it; | 289 | QMap<int, OEvent>::ConstIterator it; |
288 | 290 | ||
289 | for ( it = m_rep.begin(); it != m_rep.end(); ++it ) { | 291 | for ( it = m_rep.begin(); it != m_rep.end(); ++it ) { |
290 | ints[i] = it.key(); | 292 | ints[i] = it.key(); |
@@ -312,24 +314,26 @@ OEvent::ValueList ODateBookAccessBackend_XML::directNonRepeats() { | |||
312 | list.append( it.data() ); | 314 | list.append( it.data() ); |
313 | 315 | ||
314 | return list; | 316 | return list; |
315 | } | 317 | } |
316 | OEvent::ValueList ODateBookAccessBackend_XML::directRawRepeats() { | 318 | OEvent::ValueList ODateBookAccessBackend_XML::directRawRepeats() { |
317 | OEvent::ValueList list; | 319 | OEvent::ValueList list; |
318 | QMap<int, OEvent>::ConstIterator it; | 320 | QMap<int, OEvent>::ConstIterator it; |
319 | for (it = m_rep.begin(); it != m_rep.end(); ++it ) | 321 | for (it = m_rep.begin(); it != m_rep.end(); ++it ) |
320 | list.append( it.data() ); | 322 | list.append( it.data() ); |
321 | 323 | ||
322 | return list; | 324 | return list; |
323 | } | 325 | } |
326 | |||
327 | // FIXME: Use OEvent::fromMap() (eilers) | ||
324 | bool ODateBookAccessBackend_XML::loadFile() { | 328 | bool ODateBookAccessBackend_XML::loadFile() { |
325 | m_changed = false; | 329 | m_changed = false; |
326 | 330 | ||
327 | int fd = ::open( QFile::encodeName(m_name).data(), O_RDONLY ); | 331 | int fd = ::open( QFile::encodeName(m_name).data(), O_RDONLY ); |
328 | if ( fd < 0 ) return false; | 332 | if ( fd < 0 ) return false; |
329 | 333 | ||
330 | struct stat attribute; | 334 | struct stat attribute; |
331 | if ( ::fstat(fd, &attribute ) == -1 ) { | 335 | if ( ::fstat(fd, &attribute ) == -1 ) { |
332 | ::close( fd ); | 336 | ::close( fd ); |
333 | return false; | 337 | return false; |
334 | } | 338 | } |
335 | void* map_addr = ::mmap(NULL, attribute.st_size, PROT_READ, MAP_SHARED, fd, 0 ); | 339 | void* map_addr = ::mmap(NULL, attribute.st_size, PROT_READ, MAP_SHARED, fd, 0 ); |
@@ -350,25 +354,25 @@ bool ODateBookAccessBackend_XML::loadFile() { | |||
350 | dict.insert( "type", new int(FType) ); | 354 | dict.insert( "type", new int(FType) ); |
351 | dict.insert( "alarm", new int(FAlarm) ); | 355 | dict.insert( "alarm", new int(FAlarm) ); |
352 | dict.insert( "sound", new int(FSound) ); | 356 | dict.insert( "sound", new int(FSound) ); |
353 | dict.insert( "rtype", new int(FRType) ); | 357 | dict.insert( "rtype", new int(FRType) ); |
354 | dict.insert( "rweekdays", new int(FRWeekdays) ); | 358 | dict.insert( "rweekdays", new int(FRWeekdays) ); |
355 | dict.insert( "rposition", new int(FRPosition) ); | 359 | dict.insert( "rposition", new int(FRPosition) ); |
356 | dict.insert( "rfreq", new int(FRFreq) ); | 360 | dict.insert( "rfreq", new int(FRFreq) ); |
357 | dict.insert( "rhasenddate", new int(FRHasEndDate) ); | 361 | dict.insert( "rhasenddate", new int(FRHasEndDate) ); |
358 | dict.insert( "enddt", new int(FREndDate) ); | 362 | dict.insert( "enddt", new int(FREndDate) ); |
359 | dict.insert( "start", new int(FRStart) ); | 363 | dict.insert( "start", new int(FRStart) ); |
360 | dict.insert( "end", new int(FREnd) ); | 364 | dict.insert( "end", new int(FREnd) ); |
361 | dict.insert( "note", new int(FNote) ); | 365 | dict.insert( "note", new int(FNote) ); |
362 | dict.insert( "created", new int(FCreated) ); | 366 | dict.insert( "created", new int(FCreated) ); // Shouldn't this be FRCreated ?? |
363 | dict.insert( "recparent", new int(FRecParent) ); | 367 | dict.insert( "recparent", new int(FRecParent) ); |
364 | dict.insert( "recchildren", new int(FRecChildren) ); | 368 | dict.insert( "recchildren", new int(FRecChildren) ); |
365 | dict.insert( "exceptions", new int(FExceptions) ); | 369 | dict.insert( "exceptions", new int(FExceptions) ); |
366 | dict.insert( "timezone", new int(FTimeZone) ); | 370 | dict.insert( "timezone", new int(FTimeZone) ); |
367 | 371 | ||
368 | char* dt = (char*)map_addr; | 372 | char* dt = (char*)map_addr; |
369 | int len = attribute.st_size; | 373 | int len = attribute.st_size; |
370 | int i = 0; | 374 | int i = 0; |
371 | char* point; | 375 | char* point; |
372 | const char* collectionString = "<event "; | 376 | const char* collectionString = "<event "; |
373 | int strLen = ::strlen(collectionString); | 377 | int strLen = ::strlen(collectionString); |
374 | int *find; | 378 | int *find; |
@@ -435,24 +439,26 @@ bool ODateBookAccessBackend_XML::loadFile() { | |||
435 | setField( ev, *find, str ); | 439 | setField( ev, *find, str ); |
436 | } | 440 | } |
437 | } | 441 | } |
438 | /* time to finalize */ | 442 | /* time to finalize */ |
439 | finalizeRecord( ev ); | 443 | finalizeRecord( ev ); |
440 | delete rec; | 444 | delete rec; |
441 | } | 445 | } |
442 | ::munmap(map_addr, attribute.st_size ); | 446 | ::munmap(map_addr, attribute.st_size ); |
443 | m_changed = false; // changed during add | 447 | m_changed = false; // changed during add |
444 | 448 | ||
445 | return true; | 449 | return true; |
446 | } | 450 | } |
451 | |||
452 | // FIXME: Use OEvent::fromMap() which makes this obsolete.. (eilers) | ||
447 | void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { | 453 | void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { |
448 | /* AllDay is alway in UTC */ | 454 | /* AllDay is alway in UTC */ |
449 | if ( ev.isAllDay() ) { | 455 | if ( ev.isAllDay() ) { |
450 | OTimeZone utc = OTimeZone::utc(); | 456 | OTimeZone utc = OTimeZone::utc(); |
451 | ev.setStartDateTime( utc.fromUTCDateTime( start ) ); | 457 | ev.setStartDateTime( utc.fromUTCDateTime( start ) ); |
452 | ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); | 458 | ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); |
453 | ev.setTimeZone( "UTC"); // make sure it is really utc | 459 | ev.setTimeZone( "UTC"); // make sure it is really utc |
454 | }else { | 460 | }else { |
455 | /* to current date time */ | 461 | /* to current date time */ |
456 | // qWarning(" Start is %d", start ); | 462 | // qWarning(" Start is %d", start ); |
457 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); | 463 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); |
458 | QDateTime date = zone.toDateTime( start ); | 464 | QDateTime date = zone.toDateTime( start ); |