-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_xml.h | 21 |
1 files changed, 20 insertions, 1 deletions
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 @@ -14,12 +14,15 @@ * * ===================================================================== * Version: $Id$ * ===================================================================== * History: * $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 * Some minor interface updates * * Revision 1.2 2002/10/07 17:34:24 eilers * added OBackendFactory for advanced backend access * @@ -53,13 +56,14 @@ using namespace Opie; /* the default xml implementation */ class OContactAccessBackend_XML : public OContactAccessBackend { public: - OContactAccessBackend_XML ( QString appname, QString filename = 0l ) + OContactAccessBackend_XML ( QString appname, QString filename = 0l ): + m_changed( false ) { m_appName = appname; /* Set journalfile name ... */ m_journalName = getenv("HOME"); m_journalName +="/.abjournal" + appname; @@ -72,12 +76,16 @@ class OContactAccessBackend_XML : public OContactAccessBackend { /* Load Database now */ load (); } bool save() { + + if ( !m_changed ) + return true; + QString strNewFile = m_fileName + ".new"; QFile f( strNewFile ); if ( !f.open( IO_WriteOnly|IO_Raw ) ) return false; int total_written; @@ -120,12 +128,14 @@ class OContactAccessBackend_XML : public OContactAccessBackend { // remove the tmp file... QFile::remove( strNewFile ); } /* The journalfile should be removed now... */ removeJournal(); + + m_changed = false; return true; } bool load () { m_contactList.clear(); @@ -142,12 +152,13 @@ class OContactAccessBackend_XML : public OContactAccessBackend { return true; } void clear () { m_contactList.clear(); + m_changed = false; } bool wasChangedExternally() { QFileInfo fi( m_fileName ); @@ -272,17 +283,22 @@ class OContactAccessBackend_XML : public OContactAccessBackend { bool add ( const OContact &newcontact ) { //qWarning("odefaultbackend: ACTION::ADD"); updateJournal (newcontact, OContact::ACTION_ADD); addContact_p( newcontact ); + + m_changed = true; + return true; } bool replace ( const OContact &contact ) { + m_changed = true; + bool found = false; QValueListIterator<OContact> it; for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ if ( (*it).uid() == contact.uid() ){ found = true; @@ -297,12 +313,14 @@ class OContactAccessBackend_XML : public OContactAccessBackend { } else return false; } bool remove ( int uid ) { + m_changed = true; + bool found = false; QValueListIterator<OContact> it; for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ if ((*it).uid() == uid){ found = true; break; @@ -550,12 +568,13 @@ class OContactAccessBackend_XML : public OContactAccessBackend { QFile f ( m_journalName ); if ( f.exists() ) f.remove(); } protected: + bool m_changed; QString m_journalName; QString m_fileName; QString m_appName; QValueList<OContact> m_contactList; QDateTime m_readtime; }; |