author | zecke <zecke> | 2002-12-10 17:01:18 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-12-10 17:01:18 (UTC) |
commit | 4ecbf7407c19b59fc136c334f9386c53db453930 (patch) (side-by-side diff) | |
tree | 1cba438e2533f7109af169b0b77988cec6664192 /libopie2/opiepim/backend | |
parent | 36375df6ff103e52455823f7afd64c4f4ae7fcb8 (diff) | |
download | opie-4ecbf7407c19b59fc136c334f9386c53db453930.zip opie-4ecbf7407c19b59fc136c334f9386c53db453930.tar.gz opie-4ecbf7407c19b59fc136c334f9386c53db453930.tar.bz2 |
get in sync with HEAD again
-OPimBase was added to be used as a default struct inside OPimResolver
and to work with DSOs
-TodoListXML backend now uses mmap and madvise to load data
-OContact added/changed rtti
-OTodo added changed rtti
OPimAccess* added stuff necessary for the Resolver and a 'state'/'hint'
on how to load data
OPimResolver which resolves uid + services to Records, rtti to QCOPChannels
loads arbitary Service backends ( will work with DSOs soon )
-OPimMainWindow added some setDocument scripting possibility and
internal marshalling and demarshalling of Records
-OPimRecord added loadDataFromm and saveDataTo for marshalling purposes
much more :)
-rw-r--r-- | libopie2/opiepim/backend/opimaccessbackend.h | 16 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessxml.cpp | 43 |
2 files changed, 50 insertions, 9 deletions
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h index 4f00bc9..e268f4f 100644 --- a/libopie2/opiepim/backend/opimaccessbackend.h +++ b/libopie2/opiepim/backend/opimaccessbackend.h @@ -19,7 +19,9 @@ template <class T = OPimRecord> class OPimAccessBackend { public: typedef OTemplateBase<T> Frontend; - OPimAccessBackend(); + + /** The access hint from the frontend */ + OPimAccessBackend(int access = 0); virtual ~OPimAccessBackend(); /** @@ -88,6 +90,7 @@ public: */ void setReadAhead( uint count ); protected: + int access()const; void cache( const T& t )const; /** @@ -98,13 +101,18 @@ protected: uint readAhead()const; private: + class Private; + Private* d; Frontend* m_front; uint m_read; + int m_acc; }; template <class T> -OPimAccessBackend<T>::OPimAccessBackend() { +OPimAccessBackend<T>::OPimAccessBackend(int acc) + : m_acc( acc ) +{ m_front = 0l; } template <class T> @@ -138,4 +146,8 @@ template <class T> uint OPimAccessBackend<T>::readAhead()const { return m_read; } +template <class T> +int OPimAccessBackend<T>::access()const { + return m_acc; +} #endif 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,3 +1,13 @@ +#include <errno.h> +#include <fcntl.h> + +#include <sys/mman.h> +#include <sys/stat.h> +#include <sys/types.h> + +#include <unistd.h> + + #include <qfile.h> #include <qvector.h> @@ -52,20 +62,36 @@ bool OTodoAccessXML::load() { // here the custom XML parser from TT it's GPL // but we want to push OpiePIM... to TT..... - QFile f(m_file ); - if (!f.open(IO_ReadOnly) ) + // mmap part from zecke :) + int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY ); + struct stat attribut; + if ( fd < 0 ) return false; + + if ( fstat(fd, &attribut ) == -1 ) { + ::close( fd ); return false; + } + void* map_addr = ::mmap(NULL, attribut.st_size, PROT_READ, MAP_SHARED, fd, 0 ); + if ( map_addr == ( (caddr_t)-1) ) { + ::close(fd ); + return false; + } + /* advise the kernel who we want to read it */ + ::madvise( map_addr, attribut.st_size, MADV_SEQUENTIAL ); + /* we do not the file any more */ + ::close( fd ); - QByteArray ba = f.readAll(); - f.close(); - char* dt = ba.data(); - int len = ba.size(); + char* dt = (char*)map_addr; + int len = attribut.st_size; int i = 0; char *point; const char* collectionString = "<Task "; + int strLen = strlen(collectionString); while ( dt+i != 0 && ( point = strstr( dt+i, collectionString ) ) != 0l ) { i = point -dt; - i+= strlen(collectionString); + i+= strLen; + qWarning("Found a start at %d %d", i, (point-dt) ); + OTodo ev; m_year = m_month = m_day = 0; @@ -120,6 +146,7 @@ bool OTodoAccessXML::load() { /* * now add it */ + qWarning("End at %d", i ); if (m_events.contains( ev.uid() ) || ev.uid() == 0) { ev.setUid( 1 ); m_changed = true; @@ -131,6 +158,8 @@ bool OTodoAccessXML::load() { m_year = m_month = m_day = -1; } + munmap(map_addr, attribut.st_size ); + qWarning("counts %d records loaded!", m_events.count() ); return true; } |