summaryrefslogtreecommitdiff
path: root/noncore/unsupported/libopie/pim/ocontactaccessbackend_xml.h
Unidiff
Diffstat (limited to 'noncore/unsupported/libopie/pim/ocontactaccessbackend_xml.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/libopie/pim/ocontactaccessbackend_xml.h163
1 files changed, 163 insertions, 0 deletions
diff --git a/noncore/unsupported/libopie/pim/ocontactaccessbackend_xml.h b/noncore/unsupported/libopie/pim/ocontactaccessbackend_xml.h
new file mode 100644
index 0000000..6857844
--- a/dev/null
+++ b/noncore/unsupported/libopie/pim/ocontactaccessbackend_xml.h
@@ -0,0 +1,163 @@
1/*
2 * XML Backend for the OPIE-Contact Database.
3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 *
6 * =====================================================================
7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 * =====================================================================
12 * ToDo: XML-Backend: Automatic reload if something was changed...
13 * File Locking to protect against concurrent access
14 *
15 *
16 * =====================================================================
17 * Version: $Id$
18 * =====================================================================
19 * History:
20 * $Log$
21 * Revision 1.1 2004/11/16 21:46:07 mickeyl
22 * libopie1 goes into unsupported
23 *
24 * Revision 1.15 2003/09/22 14:31:16 eilers
25 * Added first experimental incarnation of sql-backend for addressbook.
26 * Some modifications to be able to compile the todo sql-backend.
27 * A lot of changes fill follow...
28 *
29 * Revision 1.14 2003/04/13 18:07:10 zecke
30 * More API doc
31 * QString -> const QString&
32 * QString = 0l -> QString::null
33 *
34 * Revision 1.13 2003/03/21 10:33:09 eilers
35 * Merged speed optimized xml backend for contacts to main.
36 * Added QDateTime to querybyexample. For instance, it is now possible to get
37 * all Birthdays/Anniversaries between two dates. This should be used
38 * to show all birthdays in the datebook..
39 * This change is sourcecode backward compatible but you have to upgrade
40 * the binaries for today-addressbook.
41 *
42 * Revision 1.12.2.2 2003/02/11 12:17:28 eilers
43 * Speed optimization. Removed the sequential search loops.
44 *
45 * Revision 1.12.2.1 2003/02/09 15:05:01 eilers
46 * Nothing happened.. Just some cleanup before I will start..
47 *
48 * Revision 1.12 2003/01/03 16:58:03 eilers
49 * Reenable debug output
50 *
51 * Revision 1.11 2003/01/03 12:31:28 eilers
52 * Bugfix for calculating data diffs..
53 *
54 * Revision 1.10 2003/01/02 14:27:12 eilers
55 * Improved query by example: Search by date is possible.. First step
56 * for a today plugin for birthdays..
57 *
58 * Revision 1.9 2002/12/08 12:48:57 eilers
59 * Moved journal-enum from ocontact into i the xml-backend..
60 *
61 * Revision 1.8 2002/11/14 17:04:24 eilers
62 * Sorting will now work if fullname is identical on some entries
63 *
64 * Revision 1.7 2002/11/13 15:02:46 eilers
65 * Small Bug in sorted fixed
66 *
67 * Revision 1.6 2002/11/13 14:14:51 eilers
68 * Added sorted for Contacts..
69 *
70 * Revision 1.5 2002/11/01 15:10:42 eilers
71 * Added regExp-search in database for all fields in a contact.
72 *
73 * Revision 1.4 2002/10/16 10:52:40 eilers
74 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
75 *
76 * Revision 1.3 2002/10/14 16:21:54 eilers
77 * Some minor interface updates
78 *
79 * Revision 1.2 2002/10/07 17:34:24 eilers
80 * added OBackendFactory for advanced backend access
81 *
82 * Revision 1.1 2002/09/27 17:11:44 eilers
83 * Added API for accessing the Contact-Database ! It is compiling, but
84 * please do not expect that anything is working !
85 * I will debug that stuff in the next time ..
86 * Please read README_COMPILE for compiling !
87 *
88 *
89 */
90
91#ifndef _OContactAccessBackend_XML_
92#define _OContactAccessBackend_XML_
93
94#include "ocontactaccessbackend.h"
95#include "ocontactaccess.h"
96
97#include <qlist.h>
98#include <qdict.h>
99
100/* the default xml implementation */
101/**
102 * This class is the XML implementation of a Contact backend
103 * it does implement everything available for OContact.
104 * @see OPimAccessBackend for more information of available methods
105 */
106class OContactAccessBackend_XML : public OContactAccessBackend {
107 public:
108 OContactAccessBackend_XML ( const QString& appname, const QString& filename = QString::null );
109
110 bool save();
111
112 bool load ();
113
114 void clear ();
115
116 bool wasChangedExternally();
117
118 QArray<int> allRecords() const;
119
120 OContact find ( int uid ) const;
121
122 QArray<int> queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() );
123
124 QArray<int> matchRegexp( const QRegExp &r ) const;
125
126 const uint querySettings();
127
128 bool hasQuerySettings (uint querySettings) const;
129
130 // Currently only asc implemented..
131 QArray<int> sorted( bool asc, int , int , int );
132 bool add ( const OContact &newcontact );
133
134 bool replace ( const OContact &contact );
135
136 bool remove ( int uid );
137 bool reload();
138
139 private:
140
141 enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE };
142
143 void addContact_p( const OContact &newcontact );
144
145 /* This function loads the xml-database and the journalfile */
146 bool load( const QString filename, bool isJournal );
147
148
149 void updateJournal( const OContact& cnt, journal_action action );
150 void removeJournal();
151
152 protected:
153 bool m_changed;
154 QString m_journalName;
155 QString m_fileName;
156 QString m_appName;
157 QList<OContact> m_contactList;
158 QDateTime m_readtime;
159
160 QDict<OContact> m_uidToContact;
161};
162
163#endif