Diffstat (limited to 'libopie2/opiepim/core/ocontactaccess.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/ocontactaccess.cpp | 80 |
1 files changed, 32 insertions, 48 deletions
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp index 2e3ec1f..f67a40c 100644 --- a/libopie2/opiepim/core/ocontactaccess.cpp +++ b/libopie2/opiepim/core/ocontactaccess.cpp | |||
@@ -1,98 +1,80 @@ | |||
1 | /* | 1 | /* |
2 | * Class to manage the Contacts. | 2 | This file is part of the Opie Project |
3 | * | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | * | 5 | .=l. |
6 | * ===================================================================== | 6 | .>+-= |
7 | *This program is free software; you can redistribute it and/or | 7 | _;:, .> :=|. This program is free software; you can |
8 | *modify it under the terms of the GNU Library General Public | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | * License as published by the Free Software Foundation; either | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | * version 2 of the License, or (at your option) any later version. | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | * ===================================================================== | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | * Info: This class could just work with a change in the header-file | 12 | ._= =} : or (at your option) any later version. |
13 | * of the Contact class ! Therefore our libopie only compiles | 13 | .%`+i> _;_. |
14 | * with our version of libqpe | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | /* | ||
15 | * ===================================================================== | 30 | * ===================================================================== |
16 | * ToDo: XML-Backend: Automatic reload if something was changed... | 31 | * ToDo: XML-Backend: Automatic reload if something was changed... |
17 | * | 32 | * |
18 | * | 33 | * |
19 | * ===================================================================== | ||
20 | * Version: $Id$ | ||
21 | * ===================================================================== | ||
22 | * History: | ||
23 | * $Log$ | ||
24 | * Revision 1.8 2003/05/08 13:55:09 tille | ||
25 | * search stuff | ||
26 | * and match, toRichText & toShortText in oevent | ||
27 | * | ||
28 | * Revision 1.7 2002/11/13 14:14:51 eilers | ||
29 | * Added sorted for Contacts.. | ||
30 | * | ||
31 | * Revision 1.6 2002/11/01 15:10:42 eilers | ||
32 | * Added regExp-search in database for all fields in a contact. | ||
33 | * | ||
34 | * Revision 1.5 2002/10/16 10:52:40 eilers | ||
35 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) | ||
36 | * | ||
37 | * Revision 1.4 2002/10/14 16:21:54 eilers | ||
38 | * Some minor interface updates | ||
39 | * | ||
40 | * Revision 1.3 2002/10/07 17:34:24 eilers | ||
41 | * added OBackendFactory for advanced backend access | ||
42 | * | ||
43 | * Revision 1.2 2002/10/02 16:18:11 eilers | ||
44 | * debugged and seems to work almost perfectly .. | ||
45 | * | ||
46 | * Revision 1.1 2002/09/27 17:11:44 eilers | ||
47 | * Added API for accessing the Contact-Database ! It is compiling, but | ||
48 | * please do not expect that anything is working ! | ||
49 | * I will debug that stuff in the next time .. | ||
50 | * Please read README_COMPILE for compiling ! | ||
51 | * | ||
52 | * | ||
53 | */ | 34 | */ |
54 | 35 | ||
55 | #include "ocontactaccess.h" | 36 | #include "ocontactaccess.h" |
56 | #include "obackendfactory.h" | 37 | #include "obackendfactory.h" |
57 | 38 | ||
58 | #include <qasciidict.h> | 39 | #include <qasciidict.h> |
59 | #include <qdatetime.h> | 40 | #include <qdatetime.h> |
60 | #include <qfile.h> | 41 | #include <qfile.h> |
61 | #include <qregexp.h> | 42 | #include <qregexp.h> |
62 | #include <qlist.h> | 43 | #include <qlist.h> |
63 | #include <qcopchannel_qws.h> | 44 | #include <qcopchannel_qws.h> |
64 | 45 | ||
65 | //#include <qpe/qcopenvelope_qws.h> | 46 | //#include <qpe/qcopenvelope_qws.h> |
66 | #include <qpe/global.h> | 47 | #include <qpe/global.h> |
67 | 48 | ||
68 | #include <errno.h> | 49 | #include <errno.h> |
69 | #include <fcntl.h> | 50 | #include <fcntl.h> |
70 | #include <unistd.h> | 51 | #include <unistd.h> |
71 | #include <stdlib.h> | 52 | #include <stdlib.h> |
72 | 53 | ||
73 | #include "ocontactaccessbackend_xml.h" | 54 | #include <opie2/ocontactaccessbackend_xml.h> |
74 | 55 | ||
56 | namespace Opie { | ||
75 | 57 | ||
76 | OContactAccess::OContactAccess ( const QString appname, const QString , | 58 | OContactAccess::OContactAccess ( const QString appname, const QString , |
77 | OContactAccessBackend* end, bool autosync ): | 59 | OContactAccessBackend* end, bool autosync ): |
78 | OPimAccessTemplate<OContact>( end ) | 60 | OPimAccessTemplate<OContact>( end ) |
79 | { | 61 | { |
80 | /* take care of the backend. If there is no one defined, we | 62 | /* take care of the backend. If there is no one defined, we |
81 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). | 63 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). |
82 | */ | 64 | */ |
83 | if( end == 0 ) { | 65 | if( end == 0 ) { |
84 | qWarning ("Using BackendFactory !"); | 66 | qWarning ("Using BackendFactory !"); |
85 | end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); | 67 | end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); |
86 | } | 68 | } |
87 | // Set backend locally and in template | 69 | // Set backend locally and in template |
88 | m_backEnd = end; | 70 | m_backEnd = end; |
89 | OPimAccessTemplate<OContact>::setBackEnd (end); | 71 | OPimAccessTemplate<OContact>::setBackEnd (end); |
90 | 72 | ||
91 | 73 | ||
92 | /* Connect signal of external db change to function */ | 74 | /* Connect signal of external db change to function */ |
93 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); | 75 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); |
94 | connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), | 76 | connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), |
95 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); | 77 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); |
96 | if ( autosync ){ | 78 | if ( autosync ){ |
97 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); | 79 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); |
98 | connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), | 80 | connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), |
@@ -145,24 +127,26 @@ ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int | |||
145 | return ( ORecordList<OContact>(matchingContacts, this) ); | 127 | return ( ORecordList<OContact>(matchingContacts, this) ); |
146 | } | 128 | } |
147 | 129 | ||
148 | 130 | ||
149 | bool OContactAccess::wasChangedExternally()const | 131 | bool OContactAccess::wasChangedExternally()const |
150 | { | 132 | { |
151 | return ( m_backEnd->wasChangedExternally() ); | 133 | return ( m_backEnd->wasChangedExternally() ); |
152 | } | 134 | } |
153 | 135 | ||
154 | 136 | ||
155 | void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) | 137 | void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) |
156 | { | 138 | { |
157 | if ( msg == "addressbookUpdated()" ){ | 139 | if ( msg == "addressbookUpdated()" ){ |
158 | qWarning ("OContactAccess: Received addressbokUpdated()"); | 140 | qWarning ("OContactAccess: Received addressbokUpdated()"); |
159 | emit signalChanged ( this ); | 141 | emit signalChanged ( this ); |
160 | } else if ( msg == "flush()" ) { | 142 | } else if ( msg == "flush()" ) { |
161 | qWarning ("OContactAccess: Received flush()"); | 143 | qWarning ("OContactAccess: Received flush()"); |
162 | save (); | 144 | save (); |
163 | } else if ( msg == "reload()" ) { | 145 | } else if ( msg == "reload()" ) { |
164 | qWarning ("OContactAccess: Received reload()"); | 146 | qWarning ("OContactAccess: Received reload()"); |
165 | reload (); | 147 | reload (); |
166 | emit signalChanged ( this ); | 148 | emit signalChanged ( this ); |
167 | } | 149 | } |
168 | } | 150 | } |
151 | |||
152 | } | ||