From 4ecbf7407c19b59fc136c334f9386c53db453930 Mon Sep 17 00:00:00 2001 From: zecke Date: Tue, 10 Dec 2002 17:01:18 +0000 Subject: 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 :) --- (limited to 'libopie2/opiepim/backend') 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 OPimAccessBackend { public: typedef OTemplateBase 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 -OPimAccessBackend::OPimAccessBackend() { +OPimAccessBackend::OPimAccessBackend(int acc) + : m_acc( acc ) +{ m_front = 0l; } template @@ -138,4 +146,8 @@ template uint OPimAccessBackend::readAhead()const { return m_read; } +template +int OPimAccessBackend::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 +#include + +#include +#include +#include + +#include + + #include #include @@ -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 = "