author | eilers <eilers> | 2002-10-16 10:52:40 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-10-16 10:52:40 (UTC) |
commit | f9756ca203a06fa60413ef1a96416d87b9dc1a6b (patch) (side-by-side diff) | |
tree | 0b67c3c485349a1c31ea82e7c12526b990654d58 | |
parent | 9eba62fc184260f1a0455a6dd057e2ccebf4bdac (diff) | |
download | opie-f9756ca203a06fa60413ef1a96416d87b9dc1a6b.zip opie-f9756ca203a06fa60413ef1a96416d87b9dc1a6b.tar.gz opie-f9756ca203a06fa60413ef1a96416d87b9dc1a6b.tar.bz2 |
Added some docu to the interface and now using the cache infrastucture by zecke.. :)
-rw-r--r-- | libopie/pim/ocontactaccess.cpp | 47 | ||||
-rw-r--r-- | libopie/pim/ocontactaccess.h | 43 | ||||
-rw-r--r-- | libopie/pim/ocontactaccessbackend_xml.h | 21 | ||||
-rw-r--r-- | libopie/pim/opimaccesstemplate.h | 25 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_xml.h | 21 | ||||
-rw-r--r-- | libopie2/opiepim/core/ocontactaccess.cpp | 47 | ||||
-rw-r--r-- | libopie2/opiepim/core/ocontactaccess.h | 43 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimaccesstemplate.h | 25 |
8 files changed, 98 insertions, 174 deletions
diff --git a/libopie/pim/ocontactaccess.cpp b/libopie/pim/ocontactaccess.cpp index e8c0a45..2ca0283 100644 --- a/libopie/pim/ocontactaccess.cpp +++ b/libopie/pim/ocontactaccess.cpp @@ -23,2 +23,5 @@ * $Log$ + * Revision 1.5 2002/10/16 10:52:40 eilers + * Added some docu to the interface and now using the cache infrastucture by zecke.. :) + * * Revision 1.4 2002/10/14 16:21:54 eilers @@ -64,4 +67,3 @@ OContactAccess::OContactAccess ( const QString appname, const QString , OContactAccessBackend* end, bool autosync ): - OPimAccessTemplate<OContact>( end ), - m_changed ( false ) + OPimAccessTemplate<OContact>( end ) { @@ -96,3 +98,2 @@ OContactAccess::~OContactAccess () */ - if ( m_changed ) save(); @@ -101,6 +102,2 @@ OContactAccess::~OContactAccess () -bool OContactAccess::load() -{ - return ( m_backEnd->load() ); -} @@ -112,10 +109,8 @@ bool OContactAccess::save () */ - if ( m_backEnd->wasChangedExternally() ) + if ( OPimAccessTemplate<OContact>::wasChangedExternally() ) reload(); - if ( m_changed ){ - bool status = m_backEnd->save(); + bool status = OPimAccessTemplate<OContact>::save(); if ( !status ) return false; - m_changed = false; /* Now tell everyone that new data is available. @@ -124,4 +119,2 @@ bool OContactAccess::save () - } - return true; @@ -139,25 +132,2 @@ bool OContactAccess::hasQuerySettings ( int querySettings ) const -bool OContactAccess::add ( const OContact& newcontact ) -{ - m_changed = true; - return ( m_backEnd->add ( newcontact ) ); -} - -bool OContactAccess::replace ( const OContact& contact ) -{ - m_changed = true; - return ( m_backEnd->replace ( contact ) ); -} - -bool OContactAccess::remove ( const OContact& t ) -{ - m_changed = true; - return ( m_backEnd->remove ( t.uid() ) ); -} - -bool OContactAccess::remove ( int uid ) -{ - m_changed = true; - return ( m_backEnd->remove ( uid ) ); -} @@ -169,7 +139,2 @@ bool OContactAccess::wasChangedExternally()const -bool OContactAccess::reload() -{ - return ( m_backEnd->reload() ); -} - void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) diff --git a/libopie/pim/ocontactaccess.h b/libopie/pim/ocontactaccess.h index adc66cf..da9c942 100644 --- a/libopie/pim/ocontactaccess.h +++ b/libopie/pim/ocontactaccess.h @@ -19,2 +19,5 @@ * $Log$ + * Revision 1.3 2002/10/16 10:52:40 eilers + * Added some docu to the interface and now using the cache infrastucture by zecke.. :) + * * Revision 1.2 2002/10/14 16:21:54 eilers @@ -93,34 +96,2 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact> - /** Add Contact to database. - * @param newcontact The contact to add. - * @return <i>true</i> if added successfully. - */ - bool add (const OContact& newcontact); - - /** Replace contact. - * Replaces given contact with contact with the user id <i>uid</i>. - * @param uid The user ID - * @param contact The new contact - * @return <i>true</i> if successful. - */ - bool replace ( const OContact& contact ); - - /** Remove contact. - * Removes contact with the user id <i>uid</i>. - * @param The contact to remove - * @return <i>true</i> if successful. - */ - bool remove ( const OContact& t ); - - /** Remove contact. - * Removes contact with the user id <i>uid</i>. - * @param The user id of the contact to remove - * @return <i>true</i> if successful. - */ - bool remove ( int uid ); - - /** Load Database * - */ - bool load(); - /** @@ -131,9 +102,2 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact> - /** Reload database. - * You should execute this function if the external database - * was changed. - * This function will load the external database and afterwards - * rejoin the local changes. Therefore the local database will be set consistent. - */ - bool reload(); @@ -160,3 +124,2 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact> bool m_loading:1; - bool m_changed; diff --git a/libopie/pim/ocontactaccessbackend_xml.h b/libopie/pim/ocontactaccessbackend_xml.h index 50ea329..12a75ba 100644 --- a/libopie/pim/ocontactaccessbackend_xml.h +++ b/libopie/pim/ocontactaccessbackend_xml.h @@ -19,2 +19,5 @@ * $Log$ + * Revision 1.4 2002/10/16 10:52:40 eilers + * Added some docu to the interface and now using the cache infrastucture by zecke.. :) + * * Revision 1.3 2002/10/14 16:21:54 eilers @@ -58,3 +61,4 @@ class OContactAccessBackend_XML : public OContactAccessBackend { public: - OContactAccessBackend_XML ( QString appname, QString filename = 0l ) + OContactAccessBackend_XML ( QString appname, QString filename = 0l ): + m_changed( false ) { @@ -77,2 +81,6 @@ class OContactAccessBackend_XML : public OContactAccessBackend { bool save() { + + if ( !m_changed ) + return true; + QString strNewFile = m_fileName + ".new"; @@ -125,2 +133,4 @@ class OContactAccessBackend_XML : public OContactAccessBackend { removeJournal(); + + m_changed = false; return true; @@ -147,2 +157,3 @@ class OContactAccessBackend_XML : public OContactAccessBackend { m_contactList.clear(); + m_changed = false; @@ -277,2 +288,5 @@ class OContactAccessBackend_XML : public OContactAccessBackend { addContact_p( newcontact ); + + m_changed = true; + return true; @@ -282,2 +296,4 @@ class OContactAccessBackend_XML : public OContactAccessBackend { { + m_changed = true; + bool found = false; @@ -302,2 +318,4 @@ class OContactAccessBackend_XML : public OContactAccessBackend { { + m_changed = true; + bool found = false; @@ -555,2 +573,3 @@ class OContactAccessBackend_XML : public OContactAccessBackend { protected: + bool m_changed; QString m_journalName; diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h index 3e1f393..50cb1e4 100644 --- a/libopie/pim/opimaccesstemplate.h +++ b/libopie/pim/opimaccesstemplate.h @@ -39,4 +39,7 @@ public: - /** - * reload from the backend + /** Reload database. + * You should execute this function if the external database + * was changed. + * This function will load the external database and afterwards + * rejoin the local changes. Therefore the local database will be set consistent. */ @@ -44,4 +47,5 @@ public: - /** - * save to the backend + /** Save contacts database. + * Save is more a "commit". After calling this function, all changes are public available. + * @return true if successful */ @@ -51,2 +55,4 @@ public: * if the resource was changed externally + * You should use the signal handling instead of polling possible changes ! + * zecke: Do you implement a signal for otodoaccess ? */ @@ -61,3 +67,3 @@ public: /** - * queryByExample) + * queryByExample. * @see otodoaccess, ocontactaccess @@ -85,2 +91,4 @@ public: * add T to the backend + * @param t The item to add. + * @return <i>true</i> if added successfully. */ @@ -91,2 +99,4 @@ public: * remove T from the backend + * @param t The item to remove + * @return <i>true</i> if successful. */ @@ -96,2 +106,4 @@ public: * remove the OPimRecord with uid + * @param uid The ID of the item to remove + * @return <i>true</i> if successful. */ @@ -101,2 +113,4 @@ public: * replace T from backend + * @param t The item to replace + * @return <i>true</i> if successful. */ @@ -144,2 +158,3 @@ template <class T> bool OPimAccessTemplate<T>::reload() { + invalidateCache(); // zecke: I think this should be added (se) return m_backEnd->reload(); diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h index 50ea329..12a75ba 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h @@ -19,2 +19,5 @@ * $Log$ + * Revision 1.4 2002/10/16 10:52:40 eilers + * Added some docu to the interface and now using the cache infrastucture by zecke.. :) + * * Revision 1.3 2002/10/14 16:21:54 eilers @@ -58,3 +61,4 @@ class OContactAccessBackend_XML : public OContactAccessBackend { public: - OContactAccessBackend_XML ( QString appname, QString filename = 0l ) + OContactAccessBackend_XML ( QString appname, QString filename = 0l ): + m_changed( false ) { @@ -77,2 +81,6 @@ class OContactAccessBackend_XML : public OContactAccessBackend { bool save() { + + if ( !m_changed ) + return true; + QString strNewFile = m_fileName + ".new"; @@ -125,2 +133,4 @@ class OContactAccessBackend_XML : public OContactAccessBackend { removeJournal(); + + m_changed = false; return true; @@ -147,2 +157,3 @@ class OContactAccessBackend_XML : public OContactAccessBackend { m_contactList.clear(); + m_changed = false; @@ -277,2 +288,5 @@ class OContactAccessBackend_XML : public OContactAccessBackend { addContact_p( newcontact ); + + m_changed = true; + return true; @@ -282,2 +296,4 @@ class OContactAccessBackend_XML : public OContactAccessBackend { { + m_changed = true; + bool found = false; @@ -302,2 +318,4 @@ class OContactAccessBackend_XML : public OContactAccessBackend { { + m_changed = true; + bool found = false; @@ -555,2 +573,3 @@ class OContactAccessBackend_XML : public OContactAccessBackend { protected: + bool m_changed; QString m_journalName; diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp index e8c0a45..2ca0283 100644 --- a/libopie2/opiepim/core/ocontactaccess.cpp +++ b/libopie2/opiepim/core/ocontactaccess.cpp @@ -23,2 +23,5 @@ * $Log$ + * Revision 1.5 2002/10/16 10:52:40 eilers + * Added some docu to the interface and now using the cache infrastucture by zecke.. :) + * * Revision 1.4 2002/10/14 16:21:54 eilers @@ -64,4 +67,3 @@ OContactAccess::OContactAccess ( const QString appname, const QString , OContactAccessBackend* end, bool autosync ): - OPimAccessTemplate<OContact>( end ), - m_changed ( false ) + OPimAccessTemplate<OContact>( end ) { @@ -96,3 +98,2 @@ OContactAccess::~OContactAccess () */ - if ( m_changed ) save(); @@ -101,6 +102,2 @@ OContactAccess::~OContactAccess () -bool OContactAccess::load() -{ - return ( m_backEnd->load() ); -} @@ -112,10 +109,8 @@ bool OContactAccess::save () */ - if ( m_backEnd->wasChangedExternally() ) + if ( OPimAccessTemplate<OContact>::wasChangedExternally() ) reload(); - if ( m_changed ){ - bool status = m_backEnd->save(); + bool status = OPimAccessTemplate<OContact>::save(); if ( !status ) return false; - m_changed = false; /* Now tell everyone that new data is available. @@ -124,4 +119,2 @@ bool OContactAccess::save () - } - return true; @@ -139,25 +132,2 @@ bool OContactAccess::hasQuerySettings ( int querySettings ) const -bool OContactAccess::add ( const OContact& newcontact ) -{ - m_changed = true; - return ( m_backEnd->add ( newcontact ) ); -} - -bool OContactAccess::replace ( const OContact& contact ) -{ - m_changed = true; - return ( m_backEnd->replace ( contact ) ); -} - -bool OContactAccess::remove ( const OContact& t ) -{ - m_changed = true; - return ( m_backEnd->remove ( t.uid() ) ); -} - -bool OContactAccess::remove ( int uid ) -{ - m_changed = true; - return ( m_backEnd->remove ( uid ) ); -} @@ -169,7 +139,2 @@ bool OContactAccess::wasChangedExternally()const -bool OContactAccess::reload() -{ - return ( m_backEnd->reload() ); -} - void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h index adc66cf..da9c942 100644 --- a/libopie2/opiepim/core/ocontactaccess.h +++ b/libopie2/opiepim/core/ocontactaccess.h @@ -19,2 +19,5 @@ * $Log$ + * Revision 1.3 2002/10/16 10:52:40 eilers + * Added some docu to the interface and now using the cache infrastucture by zecke.. :) + * * Revision 1.2 2002/10/14 16:21:54 eilers @@ -93,34 +96,2 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact> - /** Add Contact to database. - * @param newcontact The contact to add. - * @return <i>true</i> if added successfully. - */ - bool add (const OContact& newcontact); - - /** Replace contact. - * Replaces given contact with contact with the user id <i>uid</i>. - * @param uid The user ID - * @param contact The new contact - * @return <i>true</i> if successful. - */ - bool replace ( const OContact& contact ); - - /** Remove contact. - * Removes contact with the user id <i>uid</i>. - * @param The contact to remove - * @return <i>true</i> if successful. - */ - bool remove ( const OContact& t ); - - /** Remove contact. - * Removes contact with the user id <i>uid</i>. - * @param The user id of the contact to remove - * @return <i>true</i> if successful. - */ - bool remove ( int uid ); - - /** Load Database * - */ - bool load(); - /** @@ -131,9 +102,2 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact> - /** Reload database. - * You should execute this function if the external database - * was changed. - * This function will load the external database and afterwards - * rejoin the local changes. Therefore the local database will be set consistent. - */ - bool reload(); @@ -160,3 +124,2 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact> bool m_loading:1; - bool m_changed; diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h index 3e1f393..50cb1e4 100644 --- a/libopie2/opiepim/core/opimaccesstemplate.h +++ b/libopie2/opiepim/core/opimaccesstemplate.h @@ -39,4 +39,7 @@ public: - /** - * reload from the backend + /** Reload database. + * You should execute this function if the external database + * was changed. + * This function will load the external database and afterwards + * rejoin the local changes. Therefore the local database will be set consistent. */ @@ -44,4 +47,5 @@ public: - /** - * save to the backend + /** Save contacts database. + * Save is more a "commit". After calling this function, all changes are public available. + * @return true if successful */ @@ -51,2 +55,4 @@ public: * if the resource was changed externally + * You should use the signal handling instead of polling possible changes ! + * zecke: Do you implement a signal for otodoaccess ? */ @@ -61,3 +67,3 @@ public: /** - * queryByExample) + * queryByExample. * @see otodoaccess, ocontactaccess @@ -85,2 +91,4 @@ public: * add T to the backend + * @param t The item to add. + * @return <i>true</i> if added successfully. */ @@ -91,2 +99,4 @@ public: * remove T from the backend + * @param t The item to remove + * @return <i>true</i> if successful. */ @@ -96,2 +106,4 @@ public: * remove the OPimRecord with uid + * @param uid The ID of the item to remove + * @return <i>true</i> if successful. */ @@ -101,2 +113,4 @@ public: * replace T from backend + * @param t The item to replace + * @return <i>true</i> if successful. */ @@ -144,2 +158,3 @@ template <class T> bool OPimAccessTemplate<T>::reload() { + invalidateCache(); // zecke: I think this should be added (se) return m_backEnd->reload(); |