summaryrefslogtreecommitdiff
path: root/noncore/unsupported/libopie/pim/ocontactaccess.h
Unidiff
Diffstat (limited to 'noncore/unsupported/libopie/pim/ocontactaccess.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/libopie/pim/ocontactaccess.h196
1 files changed, 196 insertions, 0 deletions
diff --git a/noncore/unsupported/libopie/pim/ocontactaccess.h b/noncore/unsupported/libopie/pim/ocontactaccess.h
new file mode 100644
index 0000000..a7a099f
--- a/dev/null
+++ b/noncore/unsupported/libopie/pim/ocontactaccess.h
@@ -0,0 +1,196 @@
1/*
2 * Class to manage the Contacts.
3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org)
6 *
7 * =====================================================================
8 *This program is free software; you can redistribute it and/or
9 *modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation;
11 * either version 2 of the License, or (at your option) any later
12 * version.
13 * =====================================================================
14 * ToDo: Define enum for query settings
15 * =====================================================================
16 * Version: $Id$
17 * =====================================================================
18 * History:
19 * $Log$
20 * Revision 1.1 2004/11/16 21:46:07 mickeyl
21 * libopie1 goes into unsupported
22 *
23 * Revision 1.10 2003/12/22 10:19:26 eilers
24 * Finishing implementation of sql-backend for datebook. But I have to
25 * port the PIM datebook application to use it, before I could debug the
26 * whole stuff.
27 * Thus, PIM-Database backend is finished, but highly experimental. And some
28 * parts are still generic. For instance, the "queryByExample()" methods are
29 * not (or not fully) implemented. Todo: custom-entries not stored.
30 * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular
31 * expression search in the database, which is not supported by sqlite !
32 * Therefore we need either an extended sqlite or a workaround which would
33 * be very slow and memory consuming..
34 *
35 * Revision 1.9 2003/08/01 12:30:16 eilers
36 * Merging changes from BRANCH_1_0 to HEAD
37 *
38 * Revision 1.8.2.1 2003/06/30 14:34:19 eilers
39 * Patches from Zecke:
40 * Fixing and cleaning up extraMap handling
41 * Adding d_ptr for binary compatibility in the future
42 *
43 * Revision 1.8 2003/05/08 13:55:09 tille
44 * search stuff
45 * and match, toRichText & toShortText in oevent
46 *
47 * Revision 1.7 2003/04/13 18:07:10 zecke
48 * More API doc
49 * QString -> const QString&
50 * QString = 0l -> QString::null
51 *
52 * Revision 1.6 2003/01/02 14:27:12 eilers
53 * Improved query by example: Search by date is possible.. First step
54 * for a today plugin for birthdays..
55 *
56 * Revision 1.5 2002/11/13 14:14:51 eilers
57 * Added sorted for Contacts..
58 *
59 * Revision 1.4 2002/11/01 15:10:42 eilers
60 * Added regExp-search in database for all fields in a contact.
61 *
62 * Revision 1.3 2002/10/16 10:52:40 eilers
63 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
64 *
65 * Revision 1.2 2002/10/14 16:21:54 eilers
66 * Some minor interface updates
67 *
68 * Revision 1.1 2002/09/27 17:11:44 eilers
69 * Added API for accessing the Contact-Database ! It is compiling, but
70 * please do not expect that anything is working !
71 * I will debug that stuff in the next time ..
72 * Please read README_COMPILE for compiling !
73 *
74 * =====================================================================
75 */
76#ifndef _OCONTACTACCESS_H
77#define _OCONTACTACCESS_H
78
79#include <qobject.h>
80
81#include <qpe/qcopenvelope_qws.h>
82
83#include <qvaluelist.h>
84#include <qfileinfo.h>
85
86#include "ocontact.h"
87#include "ocontactaccessbackend.h"
88#include "opimaccesstemplate.h"
89
90/**
91 * Class to access the contacts database.
92 * This is just a frontend for the real database handling which is
93 * done by the backend.
94 * This class is used to access the Contacts on a system. This class as any OPIE PIM
95 * class is backend independent.
96 * @author Stefan Eilers, Holger Freyther
97 * @see OPimAccessTemplate
98 */
99class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
100{
101 Q_OBJECT
102
103 public:
104 /**
105 * Create Database with contacts (addressbook).
106 * @param appname Name of application which wants access to the database
107 * (i.e. "todolist")
108 * @param filename The name of the database file. If not set, the default one
109 * is used.
110 * @param backend Pointer to an alternative Backend. If not set, we will use
111 * the default backend.
112 * @param handlesync If <b>true</b> the database stores the current state
113 * automatically if it receives the signals <i>flush()</i> and <i>reload()</i>
114 * which are used before and after synchronisation. If the application wants
115 * to react itself, it should be disabled by setting it to <b>false</b>
116 * @see OContactAccessBackend
117 */
118 OContactAccess (const QString appname, const QString filename = 0l,
119 OContactAccessBackend* backend = 0l, bool handlesync = true);
120 ~OContactAccess ();
121
122 /** Constants for query.
123 * Use this constants to set the query parameters.
124 * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes !
125 * @see queryByExample()
126 */
127 enum QuerySettings {
128 WildCards = 0x0001,
129 IgnoreCase = 0x0002,
130 RegExp = 0x0004,
131 ExactMatch = 0x0008,
132 MatchOne = 0x0010, // Only one Entry must match
133 DateDiff = 0x0020, // Find all entries from today until given date
134 DateYear = 0x0040, // The year matches
135 DateMonth = 0x0080, // The month matches
136 DateDay = 0x0100, // The day matches
137 };
138
139
140 /** Return all Contacts in a sorted manner.
141 * @param ascending true: Sorted in acending order.
142 * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess
143 * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess
144 * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess
145 */
146 List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const;
147
148 /** Return all possible settings.
149 * @return All settings provided by the current backend
150 * (i.e.: query_WildCards & query_IgnoreCase)
151 */
152 const uint querySettings();
153
154 /** Check whether settings are correct.
155 * @return <i>true</i> if the given settings are correct and possible.
156 */
157 bool hasQuerySettings ( int querySettings ) const;
158
159 /**
160 * if the resource was changed externally.
161 * You should use the signal instead of polling possible changes !
162 */
163 bool wasChangedExternally()const;
164
165
166 /** Save contacts database.
167 * Save is more a "commit". After calling this function, all changes are public available.
168 * @return true if successful
169 */
170 bool save();
171
172 signals:
173 /* Signal is emitted if the database was changed. Therefore
174 * we may need to reload to stay consistent.
175 * @param which Pointer to the database who created this event. This pointer
176 * is useful if an application has to handle multiple databases at the same time.
177 * @see reload()
178 */
179 void signalChanged ( const OContactAccess *which );
180
181
182 private:
183 // class OContactAccessPrivate;
184 // OContactAccessPrivate* d;
185 OContactAccessBackend *m_backEnd;
186 bool m_loading:1;
187
188 private slots:
189 void copMessage( const QCString &msg, const QByteArray &data );
190
191 private:
192 class Private;
193 Private *d;
194
195};
196#endif