summaryrefslogtreecommitdiff
path: root/libopie
authorzecke <zecke>2002-12-10 17:01:18 (UTC)
committer zecke <zecke>2002-12-10 17:01:18 (UTC)
commit4ecbf7407c19b59fc136c334f9386c53db453930 (patch) (side-by-side diff)
tree1cba438e2533f7109af169b0b77988cec6664192 /libopie
parent36375df6ff103e52455823f7afd64c4f4ae7fcb8 (diff)
downloadopie-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 :)
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp11
-rw-r--r--libopie/pim/opimaccessbackend.h16
-rw-r--r--libopie/pim/opimaccesstemplate.h25
-rw-r--r--libopie/pim/opimcache.h6
-rw-r--r--libopie/pim/opimmainwindow.cpp36
-rw-r--r--libopie/pim/opimmainwindow.h26
-rw-r--r--libopie/pim/opimrecord.cpp82
-rw-r--r--libopie/pim/opimrecord.h12
-rw-r--r--libopie/pim/opimresolver.cpp198
-rw-r--r--libopie/pim/opimresolver.h52
-rw-r--r--libopie/pim/otemplatebase.h63
-rw-r--r--libopie/pim/otodo.cpp3
-rw-r--r--libopie/pim/otodoaccess.cpp32
-rw-r--r--libopie/pim/otodoaccess.h13
-rw-r--r--libopie/pim/otodoaccessxml.cpp43
15 files changed, 536 insertions, 82 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index 6aec62e..38cba72 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -24,2 +24,3 @@
#include "ocontact.h"
+#include "opimresolver.h"
@@ -831,3 +832,3 @@ void OContact::save( QString &buf ) const
Never change order of this list ! It has to be regarding
- enum AddressBookFields !!
+ enum AddressBookFields !!
*/
@@ -1102,8 +1103,8 @@ void OContact::insertEmails( const QStringList &v )
int OContact::rtti() {
- return 2;
+ return OPimResolver::AddressBook;
}
void OContact::setUid( int i )
-{
- OPimRecord::setUid(i);
- replace( Qtopia::AddressUid , QString::number(i));
+{
+ OPimRecord::setUid(i);
+ replace( Qtopia::AddressUid , QString::number(i));
}
diff --git a/libopie/pim/opimaccessbackend.h b/libopie/pim/opimaccessbackend.h
index 4f00bc9..e268f4f 100644
--- a/libopie/pim/opimaccessbackend.h
+++ b/libopie/pim/opimaccessbackend.h
@@ -21,3 +21,5 @@ public:
typedef OTemplateBase<T> Frontend;
- OPimAccessBackend();
+
+ /** The access hint from the frontend */
+ OPimAccessBackend(int access = 0);
virtual ~OPimAccessBackend();
@@ -90,2 +92,3 @@ public:
protected:
+ int access()const;
void cache( const T& t )const;
@@ -100,4 +103,7 @@ protected:
private:
+ class Private;
+ Private* d;
Frontend* m_front;
uint m_read;
+ int m_acc;
@@ -106,3 +112,5 @@ private:
template <class T>
-OPimAccessBackend<T>::OPimAccessBackend() {
+OPimAccessBackend<T>::OPimAccessBackend(int acc)
+ : m_acc( acc )
+{
m_front = 0l;
@@ -140,2 +148,6 @@ uint OPimAccessBackend<T>::readAhead()const {
}
+template <class T>
+int OPimAccessBackend<T>::access()const {
+ return m_acc;
+}
#endif
diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h
index 8cf81c8..259e2c1 100644
--- a/libopie/pim/opimaccesstemplate.h
+++ b/libopie/pim/opimaccesstemplate.h
@@ -24,2 +24,6 @@ class OPimAccessTemplate : public OTemplateBase<T> {
public:
+ enum Access {
+ Random = 0,
+ SortedAccess
+ };
typedef ORecordList<T> List;
@@ -30,4 +34,6 @@ public:
* c'tor BackEnd
+ * enum Access a small hint on how to handle the backend
*/
OPimAccessTemplate( BackEnd* end);
+
virtual ~OPimAccessTemplate();
@@ -37,3 +43,3 @@ public:
*/
- virtual bool load();
+ bool load();
@@ -51,3 +57,3 @@ public:
*/
- virtual bool save();
+ bool save();
@@ -87,3 +93,3 @@ public:
*/
- virtual void clear() ;
+ void clear() ;
@@ -110,3 +116,4 @@ public:
*/
- virtual bool remove( int uid );
+ bool remove( int uid );
+ bool remove( const OPimRecord& );
@@ -125,2 +132,4 @@ public:
void setSaneCacheSize( int );
+
+ QArray<int> records()const;
protected:
@@ -174,2 +183,6 @@ typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const {
template <class T>
+QArray<int> OPimAccessTemplate<T>::records()const {
+ return m_backEnd->allRecords();
+}
+template <class T>
typename OPimAccessTemplate<T>::List
@@ -233,2 +246,6 @@ bool OPimAccessTemplate<T>::remove( int uid ) {
template <class T>
+bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) {
+ return remove( rec.uid() );
+}
+template <class T>
bool OPimAccessTemplate<T>::replace( const T& t ) {
diff --git a/libopie/pim/opimcache.h b/libopie/pim/opimcache.h
index 839550c..73414e5 100644
--- a/libopie/pim/opimcache.h
+++ b/libopie/pim/opimcache.h
@@ -11,4 +11,7 @@ public:
OPimCacheItem( const T& t = T() );
+ OPimCacheItem( const OPimCacheItem& );
~OPimCacheItem();
+ OPimCacheItem &operator=( const OPimCacheItem& );
+
T record()const;
@@ -29,4 +32,7 @@ public:
OPimCache();
+ OPimCache( const OPimCache& );
~OPimCache();
+ OPimCache &operator=( const OPimCache& );
+
bool contains(int uid)const;
diff --git a/libopie/pim/opimmainwindow.cpp b/libopie/pim/opimmainwindow.cpp
index 92be2fd..7e57f3a 100644
--- a/libopie/pim/opimmainwindow.cpp
+++ b/libopie/pim/opimmainwindow.cpp
@@ -5,2 +5,3 @@
+#include "opimresolver.h"
#include "opimmainwindow.h"
@@ -9,3 +10,3 @@ OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent,
const char* name, WFlags flag )
- : QMainWindow( parent, name, flag ), m_service( service ), m_fallBack(0l) {
+ : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) {
@@ -31,2 +32,5 @@ QCopChannel* OPimMainWindow::channel() {
}
+void OPimMainWindow::doSetDocument( const QString& ) {
+
+}
void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) {
@@ -71 +75,31 @@ void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array )
}
+/* implement the url scripting here */
+void OPimMainWindow::setDocument( const QString& str) {
+ doSetDocument( str );
+}
+/*
+ * we now try to get the array demarshalled
+ * check if the rtti matches this one
+ */
+OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) {
+ if ( service() != rtti )
+ return 0l;
+
+ OPimRecord* record = OPimResolver::self()->record( rtti );
+ QDataStream str(array, IO_ReadOnly );
+ if ( !record || !record->loadFromStream(str) ) {
+ delete record;
+ record = 0l;
+ }
+
+ return record;
+}
+/*
+ * get the rtti for the service
+ */
+int OPimMainWindow::service() {
+ if ( m_rtti == -1 )
+ m_rtti = OPimResolver::self()->serviceId( m_service );
+
+ return m_rtti;
+}
diff --git a/libopie/pim/opimmainwindow.h b/libopie/pim/opimmainwindow.h
index 94100bd..34b8a71 100644
--- a/libopie/pim/opimmainwindow.h
+++ b/libopie/pim/opimmainwindow.h
@@ -34,2 +34,7 @@ public:
protected slots:
+ /*
+ * called when a setDocument
+ * couldn't be handled by this window
+ */
+ virtual void doSetDocument( const QString& );
/* for syncing */
@@ -53,10 +58,3 @@ protected slots:
- /* I would love to do this as a template
- * but can't think of a right way
- * because I need signal and slots -zecke
- */
- /*
- * the only pointer in the whole PIM API :(
- */
- virtual OPimRecord* record( int rtti, const QByteArray& ) = 0;
+
QCopChannel* channel();
@@ -65,2 +63,3 @@ private slots:
void appMessage( const QCString&, const QByteArray& );
+ void setDocument( const QString& );
@@ -71,2 +70,3 @@ private:
+ int m_rtti;
QCopChannel* m_channel;
@@ -75,2 +75,12 @@ private:
OPimRecord* m_fallBack;
+
+ /* I would love to do this as a template
+ * but can't think of a right way
+ * because I need signal and slots -zecke
+ */
+ /*
+ * the only pointer in the whole PIM API :(
+ */
+ virtual OPimRecord* record( int rtti, const QByteArray& ) ;
+ int service();
};
diff --git a/libopie/pim/opimrecord.cpp b/libopie/pim/opimrecord.cpp
index 49b5bf9..ac0f4a9 100644
--- a/libopie/pim/opimrecord.cpp
+++ b/libopie/pim/opimrecord.cpp
@@ -1 +1,3 @@
+#include <qarray.h>
+
#include <qpe/categories.h>
@@ -84 +86,81 @@ int OPimRecord::rtti(){
}
+
+/**
+ * now let's put our data into the stream
+ */
+/*
+ * First read UID
+ * Categories
+ * XRef
+ */
+bool OPimRecord::loadFromStream( QDataStream& stream ) {
+ int Int;
+ uint UInt;
+ stream >> Int;
+ setUid(Int);
+
+ /** Categories */
+ stream >> UInt;
+ QArray<int> array(UInt);
+ for (uint i = 0; i < UInt; i++ ) {
+ stream >> array[i];
+ }
+ setCategories( array );
+
+ /*
+ * now we do the X-Ref stuff
+ */
+ OPimXRef xref;
+ stream >> UInt;
+ for ( uint i = 0; i < UInt; i++ ) {
+ xref.setPartner( OPimXRef::One, partner( stream ) );
+ xref.setPartner( OPimXRef::Two, partner( stream ) );
+ m_xrefman.add( xref );
+ }
+
+ return true;
+}
+bool OPimRecord::saveToStream( QDataStream& stream )const {
+ /** UIDs */
+
+ stream << uid();
+
+ /** Categories */
+ stream << categories().count();
+ for ( uint i = 0; i < categories().count(); i++ ) {
+ stream << categories()[i];
+ }
+
+ /*
+ * first the XRef count
+ * then the xrefs
+ */
+ stream << m_xrefman.list().count();
+ for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin();
+ it != m_xrefman.list().end(); ++it ) {
+ flush( (*it).partner( OPimXRef::One), stream );
+ flush( (*it).partner( OPimXRef::Two), stream );
+ }
+ return true;
+}
+void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{
+ str << par.service();
+ str << par.uid();
+ str << par.field();
+}
+OPimXRefPartner OPimRecord::partner( QDataStream& stream ) {
+ OPimXRefPartner par;
+ QString str;
+ int i;
+
+ stream >> str;
+ par.setService( str );
+
+ stream >> i;
+ par.setUid( i );
+
+ stream >> i ;
+ par.setField( i );
+
+ return par;
+}
diff --git a/libopie/pim/opimrecord.h b/libopie/pim/opimrecord.h
index ec99a13..665530f 100644
--- a/libopie/pim/opimrecord.h
+++ b/libopie/pim/opimrecord.h
@@ -3,2 +3,3 @@
+#include <qdatastream.h>
#include <qmap.h>
@@ -107,2 +108,10 @@ public:
+ /**
+ * some marshalling and de marshalling code
+ * saves the OPimRecord
+ * to and from a DataStream
+ */
+ virtual bool loadFromStream(QDataStream& );
+ virtual bool saveToStream( QDataStream& stream )const;
+
protected:
@@ -117,2 +126,5 @@ private:
+private:
+ void flush( const OPimXRefPartner&, QDataStream& stream )const;
+ OPimXRefPartner partner( QDataStream& );
};
diff --git a/libopie/pim/opimresolver.cpp b/libopie/pim/opimresolver.cpp
new file mode 100644
index 0000000..4ebbd6e
--- a/dev/null
+++ b/libopie/pim/opimresolver.cpp
@@ -0,0 +1,198 @@
+#include <qcopchannel_qws.h>
+
+#include <qpe/qcopenvelope_qws.h>
+
+#include "otodoaccess.h"
+#include "ocontactaccess.h"
+
+//#include "opimfactory.h"
+#include "opimresolver.h"
+
+OPimResolver* OPimResolver::m_self = 0l;
+
+OPimResolver::OPimResolver() {
+ /* the built in channels */
+ m_builtIns << "Todolist" << "Addressbook" << "Datebook";
+}
+OPimResolver* OPimResolver::self() {
+ if (!m_self)
+ m_self = new OPimResolver();
+
+ return m_self;
+}
+
+/*
+ * FIXME use a cache here too
+ */
+OPimRecord* OPimResolver::record( const QString& service, int uid ) {
+ OPimRecord* rec = 0l;
+ OPimBase* base = backend( service );
+
+ if ( base )
+ rec = base->record( uid );
+ delete base;
+
+ return rec;
+}
+OPimRecord* OPimResolver::record( const QString& service ) {
+ return record( serviceId( service ) );
+}
+OPimRecord* OPimResolver::record( int rtti ) {
+ OPimRecord* rec = 0l;
+ switch( rtti ) {
+ case 1: /* todolist */
+ rec = new OTodo();
+ case 2: /* contact */
+ rec = new OContact();
+ default:
+ break;
+ }
+ /*
+ * FIXME resolve externally
+ */
+ if (!rec ) {
+ ;
+ }
+ return 0l;
+}
+bool OPimResolver::isBuiltIn( const QString& str) const{
+ return m_builtIns.contains( str );
+}
+QCString OPimResolver::qcopChannel( enum BuiltIn& built)const {
+ QCString str("QPE/");
+ switch( built ) {
+ case TodoList:
+ str += "Todolist";
+ break;
+ case DateBook:
+ str += "Datebook";
+ break;
+ case AddressBook:
+ str += "Addressbook";
+ break;
+ default:
+ break;
+ }
+
+ return str;
+}
+QCString OPimResolver::qcopChannel( const QString& service )const {
+ QCString str("QPE/");
+ str += service.latin1();
+ return str;
+}
+/*
+ * Implement services!!
+ * FIXME
+ */
+QCString OPimResolver::applicationChannel( enum BuiltIn& built)const {
+ QCString str("QPE/Application/");
+ switch( built ) {
+ case TodoList:
+ str += "todolist";
+ break;
+ case DateBook:
+ str += "datebook";
+ break;
+ case AddressBook:
+ str += "addressbook";
+ break;
+ }
+
+ return str;
+}
+QCString OPimResolver::applicationChannel( const QString& service )const {
+ QCString str("QPE/Application/");
+
+ if ( isBuiltIn( service ) ) {
+ if ( service == "Todolist" )
+ str += "todolist";
+ else if ( service == "Datebook" )
+ str += "datebook";
+ else if ( service == "Addressbook" )
+ str += "addressbook";
+ }else
+ ; // FIXME for additional stuff
+
+ return str;
+}
+QStringList OPimResolver::services()const {
+ return m_builtIns;
+}
+QString OPimResolver::serviceName( int rtti ) const{
+ QString str;
+ switch ( rtti ) {
+ case TodoList:
+ str = "Todolist";
+ break;
+ case DateBook:
+ str = "Datebook";
+ break;
+ case AddressBook:
+ str = "Addressbook";
+ break;
+ default:
+ break;
+ }
+ return str;
+ // FIXME me for 3rd party
+}
+int OPimResolver::serviceId( const QString& service ) {
+ int rtti = 0;
+ if ( service == "Todolist" )
+ rtti = TodoList;
+ else if ( service == "Datebook" )
+ rtti = DateBook;
+ else if ( service == "Addressbook" )
+ rtti = AddressBook;
+
+ return rtti;
+}
+/**
+ * check if the 'service' is registered and if so we'll
+ */
+bool OPimResolver::add( const QString& service, const OPimRecord& rec) {
+ if ( QCopChannel::isRegistered( applicationChannel( service ) ) ) {
+ QByteArray data;
+ QDataStream arg(data, IO_WriteOnly );
+ if ( rec.saveToStream( arg ) ) {
+ QCopEnvelope env( applicationChannel( service ), "add(int,QByteArray)" );
+ env << rec.rtti();
+ env << data;
+ }else
+ return false;
+ }else{
+ OPimBase* base = backend( service );
+ if (!base ) return false;
+
+ base->load();
+ base->add( rec );
+ base->save();
+ delete base;
+ }
+
+ return true;
+}
+OPimBase* OPimResolver::backend( const QString& service ) {
+ return backend( serviceId( service ) );
+}
+OPimBase* OPimResolver::backend( int rtti ) {
+ OPimBase* base = 0l;
+ switch( rtti ) {
+ case TodoList:
+ base = new OTodoAccess();
+ break;
+ case DateBook:
+ break;
+ case AddressBook:
+ base = new OContactAccess("Resolver");
+ break;
+ default:
+ break;
+ }
+ // FIXME for 3rd party
+ if (!base )
+ ;
+
+ return base;
+}
diff --git a/libopie/pim/opimresolver.h b/libopie/pim/opimresolver.h
index 86ae3eb..1ce1619 100644
--- a/libopie/pim/opimresolver.h
+++ b/libopie/pim/opimresolver.h
@@ -6,2 +6,4 @@
+#include <opie/otemplatebase.h>
+
/**
@@ -17,3 +19,3 @@
*/
-class OPimResolver : public QObject {
+class OPimResolver {
public:
@@ -26,7 +28,8 @@ public:
- /*
+ /**
* return a record for a uid
- * and an app
+ * and an service
+ * You've THE OWNERSHIP NOW!
*/
- OPimRecord &record( const QString& service, int uid );
+ OPimRecord *record( const QString& service, int uid );
@@ -36,4 +39,10 @@ public:
*/
- QString qcopChannel( enum BuiltIn& )const;
- QString qcopChannel( const QString& service );
+ QCString qcopChannel( enum BuiltIn& )const;
+ QCString qcopChannel( const QString& service )const;
+
+ /**
+ * The Application channel (QPE/Application/name)
+ */
+ QCString applicationChannel( enum BuiltIn& )const;
+ QCString applicationChannel( const QString& service )const;
@@ -43,3 +52,4 @@ public:
QStringList services()const;
-
+ inline QString serviceName(int rrti )const;
+ int serviceId( const QString& Service);
/**
@@ -49,7 +59,31 @@ public:
+
+ /**
+ * record returns an empty record for a given service.
+ * Be sure to delete it!!!
+ *
+ */
+ OPimRecord* record( const QString& service );
+ OPimRecord* record( int rtti );
+
+ /**
+ * you can cast to your
+ */
+ OPimBase* backend( const QString& service );
+ OPimBase* backend( int rtti );
private:
OPimResolver();
- OPimRecord *m_last;
+ void loadData();
+ inline bool isBuiltIn( const QString& )const;
+ OPimRecord* recordExtern( const QString&, int );
+ OPimRecord* recordExtern( const QString& );
+
+ static OPimResolver* m_self;
+ struct Data;
+ class Private;
-}:
+ Data* data;
+ Private* d;
+ QStringList m_builtIns;
+};
diff --git a/libopie/pim/otemplatebase.h b/libopie/pim/otemplatebase.h
index b855919..29fb6ec 100644
--- a/libopie/pim/otemplatebase.h
+++ b/libopie/pim/otemplatebase.h
@@ -5,9 +5,39 @@
-#include "opimrecord.h"
+#include <opie/opimrecord.h>
+
/**
+ * Templates do not have a base class, This is why
+ * we've this class
+ * this is here to give us the possibility
+ * to have a common base class
+ * You may not want to use that interface internaly
+ * POOR mans interface
+ */
+struct OPimBase {
+ /**
+ * return the rtti
+ */
+ virtual int rtti()= 0;
+ virtual OPimRecord* record()const = 0;
+ virtual OPimRecord* record(int uid)const = 0;
+ virtual bool add( const OPimRecord& ) = 0;
+ virtual bool remove( int uid ) = 0;
+ virtual bool remove( const OPimRecord& ) = 0;
+ virtual void clear() = 0;
+ virtual bool load() = 0;
+ virtual bool save() = 0;
+ virtual QArray<int> records()const = 0;
+ /*
+ * ADD editing here?
+ * -zecke
+ */
+
+};
+/**
* internal template base
+ * T needs to implement the copy c'tor!!!
*/
template <class T = OPimRecord>
-class OTemplateBase {
+class OTemplateBase : public OPimBase {
public:
@@ -28,4 +58,33 @@ public:
+ /* reimplement of OPimBase */
+ int rtti();
+ OPimRecord* record()const;
+ OPimRecord* record(int uid )const;
+ static T* rec();
};
+/*
+ * implementation
+ */
+template <class T>
+int
+OTemplateBase<T>::rtti() {
+ return T::rtti();
+}
+template <class T>
+OPimRecord* OTemplateBase<T>::record()const {
+ T* t = new T;
+ return t;
+}
+template <class T>
+OPimRecord* OTemplateBase<T>::record(int uid )const {
+ T t2 = find(uid );
+ T* t1 = new T(t2);
+
+ return t1;
+};
+template <class T>
+T* OTemplateBase<T>::rec() {
+ return new T;
+}
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp
index ece624a..cde2b3d 100644
--- a/libopie/pim/otodo.cpp
+++ b/libopie/pim/otodo.cpp
@@ -18,2 +18,3 @@
#include "opimnotifymanager.h"
+#include "opimresolver.h"
@@ -419,3 +420,3 @@ QString OTodo::recordField(int /*id*/ )const {
int OTodo::rtti(){
- return 1;
+ return OPimResolver::TodoList;
}
diff --git a/libopie/pim/otodoaccess.cpp b/libopie/pim/otodoaccess.cpp
index d860411..5e89a1b 100644
--- a/libopie/pim/otodoaccess.cpp
+++ b/libopie/pim/otodoaccess.cpp
@@ -8,3 +8,3 @@
-OTodoAccess::OTodoAccess( OTodoAccessBackend* end )
+OTodoAccess::OTodoAccess( OTodoAccessBackend* end, enum Access )
: QObject(), OPimAccessTemplate<OTodo>( end ), m_todoBackEnd( end )
@@ -46,32 +46,2 @@ OTodoAccess::List OTodoAccess::overDue() {
}
-void OTodoAccess::addAlarm( const OTodo& event) {
-/* FIXME use the new notifier architecture
- if (!event.hasAlarmDateTime() )
- return;
-
- QDateTime now = QDateTime::currentDateTime();
- QDateTime schedule = event.alarmDateTime();
-
- if ( schedule > now ){
- AlarmServer::addAlarm( schedule,
- "QPE/Application/todolist",
- "alarm(QDateTime,int)", event.uid() );
-
- }
-*/
-}
-void OTodoAccess::delAlarm( int uid) {
-
- QDateTime schedule; // Create null DateTime
-
- // I hope this will remove all scheduled alarms
- // with the given uid !?
- // If not: I have to rethink how to remove already
- // scheduled events... (se)
- // it should be fine -zecke
-// qWarning("Removing alarm for event with uid %d", uid );
- AlarmServer::deleteAlarm( schedule ,
- "QPE/Application/todolist",
- "alarm(QDateTime,int)", uid );
-}
/* sort order */
diff --git a/libopie/pim/otodoaccess.h b/libopie/pim/otodoaccess.h
index c079155..2bb87dc 100644
--- a/libopie/pim/otodoaccess.h
+++ b/libopie/pim/otodoaccess.h
@@ -31,3 +31,3 @@ public:
*/
- OTodoAccess( OTodoAccessBackend* = 0l);
+ OTodoAccess( OTodoAccessBackend* = 0l, enum Access acc = Random );
~OTodoAccess();
@@ -80,13 +80,2 @@ signals:
private:
- /**
- * add an Alarm to the AlarmServer
- */
- void addAlarm( const OTodo& );
-
- /**
- * delete an alarm with the uid from
- * the alarm server
- */
- void delAlarm( int uid );
-
int m_cat;
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp
index b2dfe80..21f93a0 100644
--- a/libopie/pim/otodoaccessxml.cpp
+++ b/libopie/pim/otodoaccessxml.cpp
@@ -1 +1,11 @@
+#include <errno.h>
+#include <fcntl.h>
+
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <unistd.h>
+
+
#include <qfile.h>
@@ -54,10 +64,23 @@ bool OTodoAccessXML::load() {
// 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;
@@ -65,5 +88,8 @@ bool OTodoAccessXML::load() {
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;
@@ -122,2 +148,3 @@ bool OTodoAccessXML::load() {
*/
+ qWarning("End at %d", i );
if (m_events.contains( ev.uid() ) || ev.uid() == 0) {
@@ -133,2 +160,4 @@ bool OTodoAccessXML::load() {
+ munmap(map_addr, attribut.st_size );
+
qWarning("counts %d records loaded!", m_events.count() );