summaryrefslogtreecommitdiff
path: root/libopie/pim/ocontactaccess.cpp
Unidiff
Diffstat (limited to 'libopie/pim/ocontactaccess.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontactaccess.cpp173
1 files changed, 0 insertions, 173 deletions
diff --git a/libopie/pim/ocontactaccess.cpp b/libopie/pim/ocontactaccess.cpp
deleted file mode 100644
index bc359f7..0000000
--- a/libopie/pim/ocontactaccess.cpp
+++ b/dev/null
@@ -1,173 +0,0 @@
1/*
2 * Class to manage the Contacts.
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 * Info: This class could just work with a change in the header-file
13 * of the Contact class ! Therefore our libopie only compiles
14 * with our version of libqpe
15 * =====================================================================
16 * ToDo: XML-Backend: Automatic reload if something was changed...
17 *
18 *
19 * =====================================================================
20 * Version: $Id$
21 * =====================================================================
22 * History:
23 * $Log$
24 * Revision 1.9 2004/03/02 12:14:22 alwin
25 * run the optimize_connect script
26 * the whole cvs is tagged with "before_optimize_connect" if there are problems you
27 * can check the diff (but it had compiled and run here)
28 *
29 * Revision 1.8 2003/05/08 13:55:09 tille
30 * search stuff
31 * and match, toRichText & toShortText in oevent
32 *
33 * Revision 1.7 2002/11/13 14:14:51 eilers
34 * Added sorted for Contacts..
35 *
36 * Revision 1.6 2002/11/01 15:10:42 eilers
37 * Added regExp-search in database for all fields in a contact.
38 *
39 * Revision 1.5 2002/10/16 10:52:40 eilers
40 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
41 *
42 * Revision 1.4 2002/10/14 16:21:54 eilers
43 * Some minor interface updates
44 *
45 * Revision 1.3 2002/10/07 17:34:24 eilers
46 * added OBackendFactory for advanced backend access
47 *
48 * Revision 1.2 2002/10/02 16:18:11 eilers
49 * debugged and seems to work almost perfectly ..
50 *
51 * Revision 1.1 2002/09/27 17:11:44 eilers
52 * Added API for accessing the Contact-Database ! It is compiling, but
53 * please do not expect that anything is working !
54 * I will debug that stuff in the next time ..
55 * Please read README_COMPILE for compiling !
56 *
57 *
58 */
59
60#include "ocontactaccess.h"
61#include "obackendfactory.h"
62
63#include <qasciidict.h>
64#include <qdatetime.h>
65#include <qfile.h>
66#include <qregexp.h>
67#include <qlist.h>
68#include <qcopchannel_qws.h>
69
70//#include <qpe/qcopenvelope_qws.h>
71#include <qpe/global.h>
72
73#include <errno.h>
74#include <fcntl.h>
75#include <unistd.h>
76#include <stdlib.h>
77
78#include "ocontactaccessbackend_xml.h"
79
80
81OContactAccess::OContactAccess ( const QString appname, const QString ,
82 OContactAccessBackend* end, bool autosync ):
83 OPimAccessTemplate<OContact>( end )
84{
85 /* take care of the backend. If there is no one defined, we
86 * will use the XML-Backend as default (until we have a cute SQL-Backend..).
87 */
88 if( end == 0 ) {
89 qWarning ("Using BackendFactory !");
90 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname );
91 }
92 // Set backend locally and in template
93 m_backEnd = end;
94 OPimAccessTemplate<OContact>::setBackEnd (end);
95
96
97 /* Connect signal of external db change to function */
98 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
99 connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)),
100 this, SLOT(copMessage(const QCString&,const QByteArray&)) );
101 if ( autosync ){
102 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this );
103 connect( syncchannel, SIGNAL(received(const QCString&,const QByteArray&)),
104 this, SLOT(copMessage(const QCString&,const QByteArray&)) );
105 }
106
107
108}
109OContactAccess::~OContactAccess ()
110{
111 /* The user may forget to save the changed database, therefore try to
112 * do it for him..
113 */
114 save();
115 // delete m_backEnd; is done by template..
116}
117
118
119bool OContactAccess::save ()
120{
121 /* If the database was changed externally, we could not save the
122 * Data. This will remove added items which is unacceptable !
123 * Therefore: Reload database and merge the data...
124 */
125 if ( OPimAccessTemplate<OContact>::wasChangedExternally() )
126 reload();
127
128 bool status = OPimAccessTemplate<OContact>::save();
129 if ( !status ) return false;
130
131 /* Now tell everyone that new data is available.
132 */
133 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" );
134
135 return true;
136}
137
138const uint OContactAccess::querySettings()
139{
140 return ( m_backEnd->querySettings() );
141}
142
143bool OContactAccess::hasQuerySettings ( int querySettings ) const
144{
145 return ( m_backEnd->hasQuerySettings ( querySettings ) );
146}
147ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const
148{
149 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat );
150 return ( ORecordList<OContact>(matchingContacts, this) );
151}
152
153
154bool OContactAccess::wasChangedExternally()const
155{
156 return ( m_backEnd->wasChangedExternally() );
157}
158
159
160void OContactAccess::copMessage( const QCString &msg, const QByteArray & )
161{
162 if ( msg == "addressbookUpdated()" ){
163 qWarning ("OContactAccess: Received addressbokUpdated()");
164 emit signalChanged ( this );
165 } else if ( msg == "flush()" ) {
166 qWarning ("OContactAccess: Received flush()");
167 save ();
168 } else if ( msg == "reload()" ) {
169 qWarning ("OContactAccess: Received reload()");
170 reload ();
171 emit signalChanged ( this );
172 }
173}