-rw-r--r-- | libopie/pim/odatebookaccessbackend_xml.cpp | 29 | ||||
-rw-r--r-- | libopie/pim/otodoaccessxml.cpp | 30 | ||||
-rw-r--r-- | libopie/pim/test/oevent_test.cpp | 21 | ||||
-rw-r--r-- | libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp | 29 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessxml.cpp | 30 |
5 files changed, 114 insertions, 25 deletions
diff --git a/libopie/pim/odatebookaccessbackend_xml.cpp b/libopie/pim/odatebookaccessbackend_xml.cpp index bc51996..24b69fe 100644 --- a/libopie/pim/odatebookaccessbackend_xml.cpp +++ b/libopie/pim/odatebookaccessbackend_xml.cpp | |||
@@ -22,8 +22,35 @@ | |||
22 | #include "otimezone.h" | 22 | #include "otimezone.h" |
23 | #include "odatebookaccessbackend_xml.h" | 23 | #include "odatebookaccessbackend_xml.h" |
24 | 24 | ||
25 | namespace { | 25 | namespace { |
26 | // FROM TT again | ||
27 | char *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 | |||
52 | namespace { | ||
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) |
@@ -341,9 +368,9 @@ bool ODateBookAccessBackend_XML::loadFile() { | |||
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; |
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp index 22b2469..cda300b 100644 --- a/libopie/pim/otodoaccessxml.cpp +++ b/libopie/pim/otodoaccessxml.cpp | |||
@@ -16,8 +16,36 @@ | |||
16 | #include <qpe/timeconversion.h> | 16 | #include <qpe/timeconversion.h> |
17 | 17 | ||
18 | #include "otodoaccessxml.h" | 18 | #include "otodoaccessxml.h" |
19 | 19 | ||
20 | namespace { | ||
21 | // FROM TT again | ||
22 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) | ||
23 | { | ||
24 | char needleChar; | ||
25 | char haystackChar; | ||
26 | if (!needle || !haystack || !hLen || !nLen) | ||
27 | return 0; | ||
28 | |||
29 | const char* hsearch = haystack; | ||
30 | |||
31 | if ((needleChar = *needle++) != 0) { | ||
32 | nLen--; //(to make up for needle++) | ||
33 | do { | ||
34 | do { | ||
35 | if ((haystackChar = *hsearch++) == 0) | ||
36 | return (0); | ||
37 | if (hsearch >= haystack + hLen) | ||
38 | return (0); | ||
39 | } while (haystackChar != needleChar); | ||
40 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); | ||
41 | hsearch--; | ||
42 | } | ||
43 | return ((char *)hsearch); | ||
44 | } | ||
45 | } | ||
46 | |||
47 | |||
20 | OTodoAccessXML::OTodoAccessXML( const QString& appName, | 48 | OTodoAccessXML::OTodoAccessXML( const QString& appName, |
21 | const QString& fileName ) | 49 | const QString& fileName ) |
22 | : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) | 50 | : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) |
23 | { | 51 | { |
@@ -84,9 +112,9 @@ bool OTodoAccessXML::load() { | |||
84 | int i = 0; | 112 | int i = 0; |
85 | char *point; | 113 | char *point; |
86 | const char* collectionString = "<Task "; | 114 | const char* collectionString = "<Task "; |
87 | int strLen = strlen(collectionString); | 115 | int strLen = strlen(collectionString); |
88 | while ( dt+i != 0 && ( point = strstr( dt+i, collectionString ) ) != 0l ) { | 116 | while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) { |
89 | i = point -dt; | 117 | i = point -dt; |
90 | i+= strLen; | 118 | i+= strLen; |
91 | qWarning("Found a start at %d %d", i, (point-dt) ); | 119 | qWarning("Found a start at %d %d", i, (point-dt) ); |
92 | 120 | ||
diff --git a/libopie/pim/test/oevent_test.cpp b/libopie/pim/test/oevent_test.cpp index 247b83b..d83ee0b 100644 --- a/libopie/pim/test/oevent_test.cpp +++ b/libopie/pim/test/oevent_test.cpp | |||
@@ -3,26 +3,8 @@ | |||
3 | #include "../oevent.h" | 3 | #include "../oevent.h" |
4 | #include "../odatebookaccess.h" | 4 | #include "../odatebookaccess.h" |
5 | 5 | ||
6 | int main(int argc, char* argv ) { | 6 | int main(int argc, char* argv ) { |
7 | OEvent ev; | ||
8 | // ev.setUid( 20 ); | ||
9 | |||
10 | ev.setDescription( "Foo Descsfewrf" ); | ||
11 | |||
12 | OEvent ev2 = ev; | ||
13 | ev2.setDescription("Foo3"); | ||
14 | qWarning("%s", ev2.description().latin1() ); | ||
15 | qWarning("%s", ev.description().latin1() ); | ||
16 | |||
17 | QDateTime time = QDateTime::currentDateTime(); | ||
18 | ev2.setStartDateTime( time ); | ||
19 | ev2.setTimeZone( "Europe/London" ); | ||
20 | |||
21 | qWarning("%s", ev2.startDateTime().toString().latin1() ); | ||
22 | qWarning("%s", ev2.startDateTimeInZone().toString().latin1() ); | ||
23 | qWarning("%d %d", ev.isAllDay(), ev2.isAllDay() ); | ||
24 | |||
25 | ODateBookAccess acc; | 7 | ODateBookAccess acc; |
26 | if(!acc.load() ) qWarning("could not load"); | 8 | if(!acc.load() ) qWarning("could not load"); |
27 | 9 | ||
28 | ODateBookAccess::List::Iterator it; | 10 | ODateBookAccess::List::Iterator it; |
@@ -45,10 +27,7 @@ int main(int argc, char* argv ) { | |||
45 | OEffectiveEvent ef = (*effIt); | 27 | OEffectiveEvent ef = (*effIt); |
46 | qWarning("Summary: %s", ef.description().latin1() ); | 28 | qWarning("Summary: %s", ef.description().latin1() ); |
47 | qWarning("Date: %s", ef.date().toString().latin1() ); | 29 | qWarning("Date: %s", ef.date().toString().latin1() ); |
48 | } | 30 | } |
49 | ev.setUid( 1 ); | ||
50 | acc.add( ev ); | ||
51 | acc.save(); | ||
52 | 31 | ||
53 | return 0; | 32 | return 0; |
54 | } | 33 | } |
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 | |||
@@ -22,8 +22,35 @@ | |||
22 | #include "otimezone.h" | 22 | #include "otimezone.h" |
23 | #include "odatebookaccessbackend_xml.h" | 23 | #include "odatebookaccessbackend_xml.h" |
24 | 24 | ||
25 | namespace { | 25 | namespace { |
26 | // FROM TT again | ||
27 | char *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 | |||
52 | namespace { | ||
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) |
@@ -341,9 +368,9 @@ bool ODateBookAccessBackend_XML::loadFile() { | |||
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; |
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index 22b2469..cda300b 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp | |||
@@ -16,8 +16,36 @@ | |||
16 | #include <qpe/timeconversion.h> | 16 | #include <qpe/timeconversion.h> |
17 | 17 | ||
18 | #include "otodoaccessxml.h" | 18 | #include "otodoaccessxml.h" |
19 | 19 | ||
20 | namespace { | ||
21 | // FROM TT again | ||
22 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) | ||
23 | { | ||
24 | char needleChar; | ||
25 | char haystackChar; | ||
26 | if (!needle || !haystack || !hLen || !nLen) | ||
27 | return 0; | ||
28 | |||
29 | const char* hsearch = haystack; | ||
30 | |||
31 | if ((needleChar = *needle++) != 0) { | ||
32 | nLen--; //(to make up for needle++) | ||
33 | do { | ||
34 | do { | ||
35 | if ((haystackChar = *hsearch++) == 0) | ||
36 | return (0); | ||
37 | if (hsearch >= haystack + hLen) | ||
38 | return (0); | ||
39 | } while (haystackChar != needleChar); | ||
40 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); | ||
41 | hsearch--; | ||
42 | } | ||
43 | return ((char *)hsearch); | ||
44 | } | ||
45 | } | ||
46 | |||
47 | |||
20 | OTodoAccessXML::OTodoAccessXML( const QString& appName, | 48 | OTodoAccessXML::OTodoAccessXML( const QString& appName, |
21 | const QString& fileName ) | 49 | const QString& fileName ) |
22 | : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) | 50 | : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) |
23 | { | 51 | { |
@@ -84,9 +112,9 @@ bool OTodoAccessXML::load() { | |||
84 | int i = 0; | 112 | int i = 0; |
85 | char *point; | 113 | char *point; |
86 | const char* collectionString = "<Task "; | 114 | const char* collectionString = "<Task "; |
87 | int strLen = strlen(collectionString); | 115 | int strLen = strlen(collectionString); |
88 | while ( dt+i != 0 && ( point = strstr( dt+i, collectionString ) ) != 0l ) { | 116 | while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) { |
89 | i = point -dt; | 117 | i = point -dt; |
90 | i+= strLen; | 118 | i+= strLen; |
91 | qWarning("Found a start at %d %d", i, (point-dt) ); | 119 | qWarning("Found a start at %d %d", i, (point-dt) ); |
92 | 120 | ||