libopie PIM API Documentation

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