Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ocontactaccessbackend_xml.h

Go to the documentation of this file.
00001 /*
00002  * XML Backend for the OPIE-Contact Database.
00003  *
00004  * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
00005  *
00006  * =====================================================================
00007  *      This program is free software; you can redistribute it and/or
00008  *      modify it under the terms of the GNU Library General Public
00009  *      License as published by the Free Software Foundation; either
00010  *      version 2 of the License, or (at your option) any later version.
00011  * =====================================================================
00012  * ToDo: XML-Backend: Automatic reload if something was changed...
00013  *       File Locking to protect against concurrent access
00014  *
00015  *
00016  * =====================================================================
00017  * Version: $Id: ocontactaccessbackend_xml.h,v 1.1 2004/11/16 21:46:07 mickeyl Exp $
00018  * =====================================================================
00019  * History:
00020  * $Log: ocontactaccessbackend_xml.h,v $
00021  * Revision 1.1  2004/11/16 21:46:07  mickeyl
00022  * libopie1 goes into unsupported
00023  *
00024  * Revision 1.15  2003/09/22 14:31:16  eilers
00025  * Added first experimental incarnation of sql-backend for addressbook.
00026  * Some modifications to be able to compile the todo sql-backend.
00027  * A lot of changes fill follow...
00028  *
00029  * Revision 1.14  2003/04/13 18:07:10  zecke
00030  * More API doc
00031  * QString -> const QString&
00032  * QString = 0l -> QString::null
00033  *
00034  * Revision 1.13  2003/03/21 10:33:09  eilers
00035  * Merged speed optimized xml backend for contacts to main.
00036  * Added QDateTime to querybyexample. For instance, it is now possible to get
00037  * all Birthdays/Anniversaries between two dates. This should be used
00038  * to show all birthdays in the datebook..
00039  * This change is sourcecode backward compatible but you have to upgrade
00040  * the binaries for today-addressbook.
00041  *
00042  * Revision 1.12.2.2  2003/02/11 12:17:28  eilers
00043  * Speed optimization. Removed the sequential search loops.
00044  *
00045  * Revision 1.12.2.1  2003/02/09 15:05:01  eilers
00046  * Nothing happened.. Just some cleanup before I will start..
00047  *
00048  * Revision 1.12  2003/01/03 16:58:03  eilers
00049  * Reenable debug output
00050  *
00051  * Revision 1.11  2003/01/03 12:31:28  eilers
00052  * Bugfix for calculating data diffs..
00053  *
00054  * Revision 1.10  2003/01/02 14:27:12  eilers
00055  * Improved query by example: Search by date is possible.. First step
00056  * for a today plugin for birthdays..
00057  *
00058  * Revision 1.9  2002/12/08 12:48:57  eilers
00059  * Moved journal-enum from ocontact into i the xml-backend..
00060  *
00061  * Revision 1.8  2002/11/14 17:04:24  eilers
00062  * Sorting will now work if fullname is identical on some entries
00063  *
00064  * Revision 1.7  2002/11/13 15:02:46  eilers
00065  * Small Bug in sorted fixed
00066  *
00067  * Revision 1.6  2002/11/13 14:14:51  eilers
00068  * Added sorted for Contacts..
00069  *
00070  * Revision 1.5  2002/11/01 15:10:42  eilers
00071  * Added regExp-search in database for all fields in a contact.
00072  *
00073  * Revision 1.4  2002/10/16 10:52:40  eilers
00074  * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
00075  *
00076  * Revision 1.3  2002/10/14 16:21:54  eilers
00077  * Some minor interface updates
00078  *
00079  * Revision 1.2  2002/10/07 17:34:24  eilers
00080  * added OBackendFactory for advanced backend access
00081  *
00082  * Revision 1.1  2002/09/27 17:11:44  eilers
00083  * Added API for accessing the Contact-Database ! It is compiling, but
00084  * please do not expect that anything is working !
00085  * I will debug that stuff in the next time ..
00086  * Please read README_COMPILE for compiling !
00087  *
00088  *
00089  */
00090 
00091 #ifndef _OContactAccessBackend_XML_
00092 #define _OContactAccessBackend_XML_
00093 
00094 #include "ocontactaccessbackend.h"
00095 #include "ocontactaccess.h"
00096 
00097 #include <qlist.h>
00098 #include <qdict.h>
00099 
00100 /* the default xml implementation */
00106 class OContactAccessBackend_XML : public OContactAccessBackend {
00107  public:
00108         OContactAccessBackend_XML ( const QString& appname, const QString& filename = QString::null );
00109 
00110         bool save();
00111 
00112         bool load ();
00113 
00114         void clear ();
00115 
00116         bool wasChangedExternally();
00117 
00118         QArray<int> allRecords() const;
00119 
00120         OContact find ( int uid ) const;
00121 
00122         QArray<int> queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() );
00123 
00124         QArray<int> matchRegexp(  const QRegExp &r ) const;
00125 
00126         const uint querySettings();
00127 
00128         bool hasQuerySettings (uint querySettings) const;
00129 
00130         // Currently only asc implemented..
00131         QArray<int> sorted( bool asc,  int , int ,  int );
00132         bool add ( const OContact &newcontact );
00133 
00134         bool replace ( const OContact &contact );
00135 
00136         bool remove ( int uid );
00137         bool reload();
00138 
00139  private:
00140 
00141         enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE };
00142 
00143         void addContact_p( const OContact &newcontact );
00144 
00145         /* This function loads the xml-database and the journalfile */
00146         bool load( const QString filename, bool isJournal );
00147 
00148 
00149         void updateJournal( const OContact& cnt, journal_action action );
00150         void removeJournal();
00151 
00152  protected:
00153         bool m_changed;
00154         QString m_journalName;
00155         QString m_fileName;
00156         QString m_appName;
00157         QList<OContact> m_contactList;
00158         QDateTime m_readtime;
00159 
00160         QDict<OContact> m_uidToContact;
00161 };
00162 
00163 #endif

Generated on Sat Nov 5 16:16:15 2005 for OPIE by  doxygen 1.4.2