summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
index bc51996..24b69fe 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
@@ -14,24 +14,51 @@
14#include <qfile.h> 14#include <qfile.h>
15 15
16#include <qtopia/global.h> 16#include <qtopia/global.h>
17#include <qtopia/stringutil.h> 17#include <qtopia/stringutil.h>
18#include <qtopia/timeconversion.h> 18#include <qtopia/timeconversion.h>
19 19
20#include "opimnotifymanager.h" 20#include "opimnotifymanager.h"
21#include "orecur.h" 21#include "orecur.h"
22#include "otimezone.h" 22#include "otimezone.h"
23#include "odatebookaccessbackend_xml.h" 23#include "odatebookaccessbackend_xml.h"
24 24
25namespace { 25namespace {
26 // FROM TT again
27char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
28{
29 char needleChar;
30 char haystackChar;
31 if (!needle || !haystack || !hLen || !nLen)
32 return 0;
33
34 const char* hsearch = haystack;
35
36 if ((needleChar = *needle++) != 0) {
37 nLen--; //(to make up for needle++)
38 do {
39 do {
40 if ((haystackChar = *hsearch++) == 0)
41 return (0);
42 if (hsearch >= haystack + hLen)
43 return (0);
44 } while (haystackChar != needleChar);
45 } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0);
46 hsearch--;
47 }
48 return ((char *)hsearch);
49}
50}
51
52namespace {
26 time_t start, end, created, rp_end; 53 time_t start, end, created, rp_end;
27 ORecur* rec; 54 ORecur* rec;
28 ORecur* recur() { 55 ORecur* recur() {
29 if (!rec) 56 if (!rec)
30 rec = new ORecur; 57 rec = new ORecur;
31 58
32 return rec; 59 return rec;
33 } 60 }
34 int alarmTime; 61 int alarmTime;
35 int snd; 62 int snd;
36 enum Attribute{ 63 enum Attribute{
37 FDescription = 0, 64 FDescription = 0,
@@ -333,25 +360,25 @@ bool ODateBookAccessBackend_XML::loadFile() {
333 dict.insert( "recparent", new int(FRecParent) ); 360 dict.insert( "recparent", new int(FRecParent) );
334 dict.insert( "recchildren", new int(FRecChildren) ); 361 dict.insert( "recchildren", new int(FRecChildren) );
335 dict.insert( "exceptions", new int(FExceptions) ); 362 dict.insert( "exceptions", new int(FExceptions) );
336 dict.insert( "timezone", new int(FTimeZone) ); 363 dict.insert( "timezone", new int(FTimeZone) );
337 364
338 char* dt = (char*)map_addr; 365 char* dt = (char*)map_addr;
339 int len = attribute.st_size; 366 int len = attribute.st_size;
340 int i = 0; 367 int i = 0;
341 char* point; 368 char* point;
342 const char* collectionString = "<event "; 369 const char* collectionString = "<event ";
343 int strLen = ::strlen(collectionString); 370 int strLen = ::strlen(collectionString);
344 int *find; 371 int *find;
345 while ( dt + 1 != 0 && (( point = ::strstr( dt+i, collectionString ) ) != 0 ) ) { 372 while ( ( point = ::strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0 ) {
346 i = point -dt; 373 i = point -dt;
347 i+= strLen; 374 i+= strLen;
348 375
349 alarmTime = -1; 376 alarmTime = -1;
350 snd = 0; // silent 377 snd = 0; // silent
351 378
352 OEvent ev; 379 OEvent ev;
353 rec = 0; 380 rec = 0;
354 381
355 while ( TRUE ) { 382 while ( TRUE ) {
356 while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) 383 while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') )
357 ++i; 384 ++i;