summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/otodoaccessxml.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/otodoaccessxml.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp43
1 files changed, 36 insertions, 7 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index b2dfe80..21f93a0 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -1 +1,11 @@
1#include <errno.h>
2#include <fcntl.h>
3
4#include <sys/mman.h>
5#include <sys/stat.h>
6#include <sys/types.h>
7
8#include <unistd.h>
9
10
1#include <qfile.h> 11#include <qfile.h>
@@ -54,10 +64,23 @@ bool OTodoAccessXML::load() {
54 // but we want to push OpiePIM... to TT..... 64 // but we want to push OpiePIM... to TT.....
55 QFile f(m_file ); 65 // mmap part from zecke :)
56 if (!f.open(IO_ReadOnly) ) 66 int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY );
67 struct stat attribut;
68 if ( fd < 0 ) return false;
69
70 if ( fstat(fd, &attribut ) == -1 ) {
71 ::close( fd );
57 return false; 72 return false;
73 }
74 void* map_addr = ::mmap(NULL, attribut.st_size, PROT_READ, MAP_SHARED, fd, 0 );
75 if ( map_addr == ( (caddr_t)-1) ) {
76 ::close(fd );
77 return false;
78 }
79 /* advise the kernel who we want to read it */
80 ::madvise( map_addr, attribut.st_size, MADV_SEQUENTIAL );
81 /* we do not the file any more */
82 ::close( fd );
58 83
59 QByteArray ba = f.readAll(); 84 char* dt = (char*)map_addr;
60 f.close(); 85 int len = attribut.st_size;
61 char* dt = ba.data();
62 int len = ba.size();
63 int i = 0; 86 int i = 0;
@@ -65,5 +88,8 @@ bool OTodoAccessXML::load() {
65 const char* collectionString = "<Task "; 88 const char* collectionString = "<Task ";
89 int strLen = strlen(collectionString);
66 while ( dt+i != 0 && ( point = strstr( dt+i, collectionString ) ) != 0l ) { 90 while ( dt+i != 0 && ( point = strstr( dt+i, collectionString ) ) != 0l ) {
67 i = point -dt; 91 i = point -dt;
68 i+= strlen(collectionString); 92 i+= strLen;
93 qWarning("Found a start at %d %d", i, (point-dt) );
94
69 OTodo ev; 95 OTodo ev;
@@ -122,2 +148,3 @@ bool OTodoAccessXML::load() {
122 */ 148 */
149 qWarning("End at %d", i );
123 if (m_events.contains( ev.uid() ) || ev.uid() == 0) { 150 if (m_events.contains( ev.uid() ) || ev.uid() == 0) {
@@ -133,2 +160,4 @@ bool OTodoAccessXML::load() {
133 160
161 munmap(map_addr, attribut.st_size );
162
134 qWarning("counts %d records loaded!", m_events.count() ); 163 qWarning("counts %d records loaded!", m_events.count() );