summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.h
authorzautrix <zautrix>2004-10-09 21:35:22 (UTC)
committer zautrix <zautrix>2004-10-09 21:35:22 (UTC)
commit213a9d993e5a4751b64e18320cfbebb000681d13 (patch) (unidiff)
tree995b465797464e689b73d3271ff4a3f8f0d3749b /kabc/addressbook.h
parentd68435216e1ebc5a7fed391157197994e13992b3 (diff)
downloadkdepimpi-213a9d993e5a4751b64e18320cfbebb000681d13.zip
kdepimpi-213a9d993e5a4751b64e18320cfbebb000681d13.tar.gz
kdepimpi-213a9d993e5a4751b64e18320cfbebb000681d13.tar.bz2
ab phone sync implemented
Diffstat (limited to 'kabc/addressbook.h') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 532e05d..cc755d1 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -1,343 +1,346 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KABC_ADDRESSBOOK_H 28#ifndef KABC_ADDRESSBOOK_H
29#define KABC_ADDRESSBOOK_H 29#define KABC_ADDRESSBOOK_H
30 30
31#include <qobject.h> 31#include <qobject.h>
32 32
33#include <kresources/manager.h> 33#include <kresources/manager.h>
34#include <qptrlist.h> 34#include <qptrlist.h>
35 35
36#include "addressee.h" 36#include "addressee.h"
37#include "field.h" 37#include "field.h"
38 38
39namespace KABC { 39namespace KABC {
40 40
41class ErrorHandler; 41class ErrorHandler;
42class Resource; 42class Resource;
43class Ticket; 43class Ticket;
44 44
45/** 45/**
46 @short Address Book 46 @short Address Book
47 47
48 This class provides access to a collection of address book entries. 48 This class provides access to a collection of address book entries.
49*/ 49*/
50class AddressBook : public QObject 50class AddressBook : public QObject
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
54 friend QDataStream &operator<<( QDataStream &, const AddressBook & ); 54 friend QDataStream &operator<<( QDataStream &, const AddressBook & );
55 friend QDataStream &operator>>( QDataStream &, AddressBook & ); 55 friend QDataStream &operator>>( QDataStream &, AddressBook & );
56 friend class StdAddressBook; 56 friend class StdAddressBook;
57 57
58 public: 58 public:
59 /** 59 /**
60 @short Address Book Iterator 60 @short Address Book Iterator
61 61
62 This class provides an iterator for address book entries. 62 This class provides an iterator for address book entries.
63 */ 63 */
64 class Iterator 64 class Iterator
65 { 65 {
66 public: 66 public:
67 Iterator(); 67 Iterator();
68 Iterator( const Iterator & ); 68 Iterator( const Iterator & );
69 ~Iterator(); 69 ~Iterator();
70 70
71 Iterator &operator=( const Iterator & ); 71 Iterator &operator=( const Iterator & );
72 const Addressee &operator*() const; 72 const Addressee &operator*() const;
73 Addressee &operator*(); 73 Addressee &operator*();
74 Addressee* operator->(); 74 Addressee* operator->();
75 Iterator &operator++(); 75 Iterator &operator++();
76 Iterator &operator++(int); 76 Iterator &operator++(int);
77 Iterator &operator--(); 77 Iterator &operator--();
78 Iterator &operator--(int); 78 Iterator &operator--(int);
79 bool operator==( const Iterator &it ); 79 bool operator==( const Iterator &it );
80 bool operator!=( const Iterator &it ); 80 bool operator!=( const Iterator &it );
81 81
82 struct IteratorData; 82 struct IteratorData;
83 IteratorData *d; 83 IteratorData *d;
84 }; 84 };
85 85
86 /** 86 /**
87 @short Address Book Const Iterator 87 @short Address Book Const Iterator
88 88
89 This class provides a const iterator for address book entries. 89 This class provides a const iterator for address book entries.
90 */ 90 */
91 class ConstIterator 91 class ConstIterator
92 { 92 {
93 public: 93 public:
94 ConstIterator(); 94 ConstIterator();
95 ConstIterator( const ConstIterator & ); 95 ConstIterator( const ConstIterator & );
96 ~ConstIterator(); 96 ~ConstIterator();
97 97
98 ConstIterator &operator=( const ConstIterator & ); 98 ConstIterator &operator=( const ConstIterator & );
99 const Addressee &operator*() const; 99 const Addressee &operator*() const;
100 const Addressee* operator->() const; 100 const Addressee* operator->() const;
101 ConstIterator &operator++(); 101 ConstIterator &operator++();
102 ConstIterator &operator++(int); 102 ConstIterator &operator++(int);
103 ConstIterator &operator--(); 103 ConstIterator &operator--();
104 ConstIterator &operator--(int); 104 ConstIterator &operator--(int);
105 bool operator==( const ConstIterator &it ); 105 bool operator==( const ConstIterator &it );
106 bool operator!=( const ConstIterator &it ); 106 bool operator!=( const ConstIterator &it );
107 107
108 struct ConstIteratorData; 108 struct ConstIteratorData;
109 ConstIteratorData *d; 109 ConstIteratorData *d;
110 }; 110 };
111 111
112 /** 112 /**
113 Constructs a address book object. 113 Constructs a address book object.
114 114
115 @param format File format class. 115 @param format File format class.
116 */ 116 */
117 AddressBook(); 117 AddressBook();
118 AddressBook( const QString &config ); 118 AddressBook( const QString &config );
119 AddressBook( const QString &config, const QString &family ); 119 AddressBook( const QString &config, const QString &family );
120 virtual ~AddressBook(); 120 virtual ~AddressBook();
121 121
122 /** 122 /**
123 Requests a ticket for saving the addressbook. Calling this function locks 123 Requests a ticket for saving the addressbook. Calling this function locks
124 the addressbook for all other processes. If the address book is already 124 the addressbook for all other processes. If the address book is already
125 locked the function returns 0. You need the returned @ref Ticket object 125 locked the function returns 0. You need the returned @ref Ticket object
126 for calling the @ref save() function. 126 for calling the @ref save() function.
127 127
128 @see save() 128 @see save()
129 */ 129 */
130 Ticket *requestSaveTicket( Resource *resource=0 ); 130 Ticket *requestSaveTicket( Resource *resource=0 );
131 131
132 /** 132 /**
133 Load address book from file. 133 Load address book from file.
134 */ 134 */
135 bool load(); 135 bool load();
136 136
137 /** 137 /**
138 Save address book. The address book is saved to the file, the Ticket 138 Save address book. The address book is saved to the file, the Ticket
139 object has been requested for by @ref requestSaveTicket(). 139 object has been requested for by @ref requestSaveTicket().
140 140
141 @param ticket a ticket object returned by @ref requestSaveTicket() 141 @param ticket a ticket object returned by @ref requestSaveTicket()
142 */ 142 */
143 bool save( Ticket *ticket ); 143 bool save( Ticket *ticket );
144 bool saveAB( ); 144 bool saveAB( );
145 bool saveABphone( QString fileName );
146 void smplifyAddressees();
147 void preparePhoneSync( QString currentSyncDevice, bool isPreSync );
145 void export2File( QString fileName ); 148 void export2File( QString fileName );
146 void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); 149 void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false );
147 void setUntagged(); 150 void setUntagged();
148 void removeUntagged(); 151 void removeUntagged();
149 /** 152 /**
150 Returns a iterator for first entry of address book. 153 Returns a iterator for first entry of address book.
151 */ 154 */
152 Iterator begin(); 155 Iterator begin();
153 156
154 /** 157 /**
155 Returns a const iterator for first entry of address book. 158 Returns a const iterator for first entry of address book.
156 */ 159 */
157 ConstIterator begin() const; 160 ConstIterator begin() const;
158 161
159 /** 162 /**
160 Returns a iterator for first entry of address book. 163 Returns a iterator for first entry of address book.
161 */ 164 */
162 Iterator end(); 165 Iterator end();
163 166
164 /** 167 /**
165 Returns a const iterator for first entry of address book. 168 Returns a const iterator for first entry of address book.
166 */ 169 */
167 ConstIterator end() const; 170 ConstIterator end() const;
168 171
169 /** 172 /**
170 Removes all entries from address book. 173 Removes all entries from address book.
171 */ 174 */
172 void clear(); 175 void clear();
173 176
174 /** 177 /**
175 Insert an Addressee object into address book. If an object with the same 178 Insert an Addressee object into address book. If an object with the same
176 unique id already exists in the address book it it replaced by the new 179 unique id already exists in the address book it it replaced by the new
177 one. If not the new object is appended to the address book. 180 one. If not the new object is appended to the address book.
178 */ 181 */
179 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); 182 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
180 183
181 /** 184 /**
182 Removes entry from the address book. 185 Removes entry from the address book.
183 */ 186 */
184 void removeAddressee( const Addressee & ); 187 void removeAddressee( const Addressee & );
185 188
186 /** 189 /**
187 This is like @ref removeAddressee() just above, with the difference that 190 This is like @ref removeAddressee() just above, with the difference that
188 the first element is a iterator, returned by @ref begin(). 191 the first element is a iterator, returned by @ref begin().
189 */ 192 */
190 void removeAddressee( const Iterator & ); 193 void removeAddressee( const Iterator & );
191 194
192 /** 195 /**
193 Find the specified entry in address book. Returns end(), if the entry 196 Find the specified entry in address book. Returns end(), if the entry
194 couldn't be found. 197 couldn't be found.
195 */ 198 */
196 Iterator find( const Addressee & ); 199 Iterator find( const Addressee & );
197 200
198 /** 201 /**
199 Find the entry specified by an unique id. Returns an empty Addressee 202 Find the entry specified by an unique id. Returns an empty Addressee
200 object, if the address book does not contain an entry with this id. 203 object, if the address book does not contain an entry with this id.
201 */ 204 */
202 Addressee findByUid( const QString & ); 205 Addressee findByUid( const QString & );
203 206
204 207
205 /** 208 /**
206 Returns a list of all addressees in the address book. This list can 209 Returns a list of all addressees in the address book. This list can
207 be sorted with @ref KABC::AddresseeList for example. 210 be sorted with @ref KABC::AddresseeList for example.
208 */ 211 */
209 Addressee::List allAddressees(); 212 Addressee::List allAddressees();
210 213
211 /** 214 /**
212 Find all entries with the specified name in the address book. Returns 215 Find all entries with the specified name in the address book. Returns
213 an empty list, if no entries could be found. 216 an empty list, if no entries could be found.
214 */ 217 */
215 Addressee::List findByName( const QString & ); 218 Addressee::List findByName( const QString & );
216 219
217 /** 220 /**
218 Find all entries with the specified email address in the address book. 221 Find all entries with the specified email address in the address book.
219 Returns an empty list, if no entries could be found. 222 Returns an empty list, if no entries could be found.
220 */ 223 */
221 Addressee::List findByEmail( const QString & ); 224 Addressee::List findByEmail( const QString & );
222 225
223 /** 226 /**
224 Find all entries wich have the specified category in the address book. 227 Find all entries wich have the specified category in the address book.
225 Returns an empty list, if no entries could be found. 228 Returns an empty list, if no entries could be found.
226 */ 229 */
227 Addressee::List findByCategory( const QString & ); 230 Addressee::List findByCategory( const QString & );
228 231
229 /** 232 /**
230 Return a string identifying this addressbook. 233 Return a string identifying this addressbook.
231 */ 234 */
232 virtual QString identifier(); 235 virtual QString identifier();
233 236
234 /** 237 /**
235 Used for debug output. 238 Used for debug output.
236 */ 239 */
237 void dump() const; 240 void dump() const;
238 241
239 void emitAddressBookLocked() { emit addressBookLocked( this ); } 242 void emitAddressBookLocked() { emit addressBookLocked( this ); }
240 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } 243 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); }
241 void emitAddressBookChanged() { emit addressBookChanged( this ); } 244 void emitAddressBookChanged() { emit addressBookChanged( this ); }
242 245
243 /** 246 /**
244 Return list of all Fields known to the address book which are associated 247 Return list of all Fields known to the address book which are associated
245 with the given field category. 248 with the given field category.
246 */ 249 */
247 Field::List fields( int category = Field::All ); 250 Field::List fields( int category = Field::All );
248 251
249 /** 252 /**
250 Add custom field to address book. 253 Add custom field to address book.
251 254
252 @param label User visible label of the field. 255 @param label User visible label of the field.
253 @param category Ored list of field categories. 256 @param category Ored list of field categories.
254 @param key Identifier used as key for reading and writing the field. 257 @param key Identifier used as key for reading and writing the field.
255 @param app String used as application key for reading and writing 258 @param app String used as application key for reading and writing
256 the field. 259 the field.
257 */ 260 */
258 bool addCustomField( const QString &label, int category = Field::All, 261 bool addCustomField( const QString &label, int category = Field::All,
259 const QString &key = QString::null, 262 const QString &key = QString::null,
260 const QString &app = QString::null ); 263 const QString &app = QString::null );
261 264
262 265
263 /** 266 /**
264 Add address book resource. 267 Add address book resource.
265 */ 268 */
266 bool addResource( Resource * ); 269 bool addResource( Resource * );
267 270
268 /** 271 /**
269 Remove address book resource. 272 Remove address book resource.
270 */ 273 */
271 bool removeResource( Resource * ); 274 bool removeResource( Resource * );
272 275
273 /** 276 /**
274 Return pointer list of all resources. 277 Return pointer list of all resources.
275 */ 278 */
276 QPtrList<Resource> resources(); 279 QPtrList<Resource> resources();
277 280
278 /** 281 /**
279 Set the @p ErrorHandler, that is used by @ref error() to 282 Set the @p ErrorHandler, that is used by @ref error() to
280 provide gui-independend error messages. 283 provide gui-independend error messages.
281 */ 284 */
282 void setErrorHandler( ErrorHandler * ); 285 void setErrorHandler( ErrorHandler * );
283 286
284 /** 287 /**
285 Shows gui independend error messages. 288 Shows gui independend error messages.
286 */ 289 */
287 void error( const QString& ); 290 void error( const QString& );
288 291
289 /** 292 /**
290 Query all resources to clean up their lock files 293 Query all resources to clean up their lock files
291 */ 294 */
292 void cleanUp(); 295 void cleanUp();
293 296
294 // sync stuff 297 // sync stuff
295 //Addressee::List getExternLastSyncAddressees(); 298 //Addressee::List getExternLastSyncAddressees();
296 void resetTempSyncStat(); 299 void resetTempSyncStat();
297 QStringList uidList(); 300 QStringList uidList();
298 void removeSyncAddressees( bool removeDeleted = false ); 301 void removeSyncAddressees( bool removeDeleted = false );
299 void mergeAB( AddressBook *aBook, const QString& profile ); 302 void mergeAB( AddressBook *aBook, const QString& profile );
300 Addressee findByExternUid( const QString& uid , const QString& profile ); 303 Addressee findByExternUid( const QString& uid , const QString& profile );
301 bool containsExternalUid( const QString& uid ); 304 bool containsExternalUid( const QString& uid );
302 305
303 void preExternSync( AddressBook* aBook, const QString& csd ); 306 void preExternSync( AddressBook* aBook, const QString& csd );
304 void postExternSync( AddressBook* aBook, const QString& csd ); 307 void postExternSync( AddressBook* aBook, const QString& csd );
305 signals: 308 signals:
306 /** 309 /**
307 Emitted, when the address book has changed on disk. 310 Emitted, when the address book has changed on disk.
308 */ 311 */
309 void addressBookChanged( AddressBook * ); 312 void addressBookChanged( AddressBook * );
310 313
311 /** 314 /**
312 Emitted, when the address book has been locked for writing. 315 Emitted, when the address book has been locked for writing.
313 */ 316 */
314 void addressBookLocked( AddressBook * ); 317 void addressBookLocked( AddressBook * );
315 318
316 /** 319 /**
317 Emitted, when the address book has been unlocked. 320 Emitted, when the address book has been unlocked.
318 */ 321 */
319 void addressBookUnlocked( AddressBook * ); 322 void addressBookUnlocked( AddressBook * );
320 323
321 protected: 324 protected:
322 void deleteRemovedAddressees(); 325 void deleteRemovedAddressees();
323 void setStandardResource( Resource * ); 326 void setStandardResource( Resource * );
324 Resource *standardResource(); 327 Resource *standardResource();
325 KRES::Manager<Resource> *resourceManager(); 328 KRES::Manager<Resource> *resourceManager();
326 329
327 void init(const QString &config, const QString &family); 330 void init(const QString &config, const QString &family);
328 331
329 private: 332 private:
330//US QPtrList<Resource> mDummy; // Remove in KDE 4 333//US QPtrList<Resource> mDummy; // Remove in KDE 4
331 334
332 335
333 struct AddressBookData; 336 struct AddressBookData;
334 AddressBookData *d; 337 AddressBookData *d;
335 bool blockLSEchange; 338 bool blockLSEchange;
336}; 339};
337 340
338QDataStream &operator<<( QDataStream &, const AddressBook & ); 341QDataStream &operator<<( QDataStream &, const AddressBook & );
339QDataStream &operator>>( QDataStream &, AddressBook & ); 342QDataStream &operator>>( QDataStream &, AddressBook & );
340 343
341} 344}
342 345
343#endif 346#endif