summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.h
authorzautrix <zautrix>2004-10-10 16:00:04 (UTC)
committer zautrix <zautrix>2004-10-10 16:00:04 (UTC)
commitee6e29a5092d32165b7bf6b39069bd8a1dcd5b0a (patch) (unidiff)
tree1d908bfc23b8a49d43a58bbeadd82c4e08faeff6 /kabc/addressbook.h
parent213a9d993e5a4751b64e18320cfbebb000681d13 (diff)
downloadkdepimpi-ee6e29a5092d32165b7bf6b39069bd8a1dcd5b0a.zip
kdepimpi-ee6e29a5092d32165b7bf6b39069bd8a1dcd5b0a.tar.gz
kdepimpi-ee6e29a5092d32165b7bf6b39069bd8a1dcd5b0a.tar.bz2
many phone AB sync fixes
Diffstat (limited to 'kabc/addressbook.h') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index cc755d1..df9048b 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -1,346 +1,348 @@
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 ); 145 bool saveABphone( QString fileName );
146 void smplifyAddressees(); 146 void smplifyAddressees();
147 void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); 147 void preparePhoneSync( QString currentSyncDevice, bool isPreSync );
148 void export2File( QString fileName ); 148 void export2File( QString fileName );
149 bool export2PhoneFormat( QStringList uids ,QString fileName );
149 void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); 150 void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false );
150 void setUntagged(); 151 void setUntagged();
151 void removeUntagged(); 152 void removeUntagged();
153 void findNewExtIds( QString fileName, QString currentSyncDevice );
152 /** 154 /**
153 Returns a iterator for first entry of address book. 155 Returns a iterator for first entry of address book.
154 */ 156 */
155 Iterator begin(); 157 Iterator begin();
156 158
157 /** 159 /**
158 Returns a const iterator for first entry of address book. 160 Returns a const iterator for first entry of address book.
159 */ 161 */
160 ConstIterator begin() const; 162 ConstIterator begin() const;
161 163
162 /** 164 /**
163 Returns a iterator for first entry of address book. 165 Returns a iterator for first entry of address book.
164 */ 166 */
165 Iterator end(); 167 Iterator end();
166 168
167 /** 169 /**
168 Returns a const iterator for first entry of address book. 170 Returns a const iterator for first entry of address book.
169 */ 171 */
170 ConstIterator end() const; 172 ConstIterator end() const;
171 173
172 /** 174 /**
173 Removes all entries from address book. 175 Removes all entries from address book.
174 */ 176 */
175 void clear(); 177 void clear();
176 178
177 /** 179 /**
178 Insert an Addressee object into address book. If an object with the same 180 Insert an Addressee object into address book. If an object with the same
179 unique id already exists in the address book it it replaced by the new 181 unique id already exists in the address book it it replaced by the new
180 one. If not the new object is appended to the address book. 182 one. If not the new object is appended to the address book.
181 */ 183 */
182 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); 184 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
183 185
184 /** 186 /**
185 Removes entry from the address book. 187 Removes entry from the address book.
186 */ 188 */
187 void removeAddressee( const Addressee & ); 189 void removeAddressee( const Addressee & );
188 190
189 /** 191 /**
190 This is like @ref removeAddressee() just above, with the difference that 192 This is like @ref removeAddressee() just above, with the difference that
191 the first element is a iterator, returned by @ref begin(). 193 the first element is a iterator, returned by @ref begin().
192 */ 194 */
193 void removeAddressee( const Iterator & ); 195 void removeAddressee( const Iterator & );
194 196
195 /** 197 /**
196 Find the specified entry in address book. Returns end(), if the entry 198 Find the specified entry in address book. Returns end(), if the entry
197 couldn't be found. 199 couldn't be found.
198 */ 200 */
199 Iterator find( const Addressee & ); 201 Iterator find( const Addressee & );
200 202
201 /** 203 /**
202 Find the entry specified by an unique id. Returns an empty Addressee 204 Find the entry specified by an unique id. Returns an empty Addressee
203 object, if the address book does not contain an entry with this id. 205 object, if the address book does not contain an entry with this id.
204 */ 206 */
205 Addressee findByUid( const QString & ); 207 Addressee findByUid( const QString & );
206 208
207 209
208 /** 210 /**
209 Returns a list of all addressees in the address book. This list can 211 Returns a list of all addressees in the address book. This list can
210 be sorted with @ref KABC::AddresseeList for example. 212 be sorted with @ref KABC::AddresseeList for example.
211 */ 213 */
212 Addressee::List allAddressees(); 214 Addressee::List allAddressees();
213 215
214 /** 216 /**
215 Find all entries with the specified name in the address book. Returns 217 Find all entries with the specified name in the address book. Returns
216 an empty list, if no entries could be found. 218 an empty list, if no entries could be found.
217 */ 219 */
218 Addressee::List findByName( const QString & ); 220 Addressee::List findByName( const QString & );
219 221
220 /** 222 /**
221 Find all entries with the specified email address in the address book. 223 Find all entries with the specified email address in the address book.
222 Returns an empty list, if no entries could be found. 224 Returns an empty list, if no entries could be found.
223 */ 225 */
224 Addressee::List findByEmail( const QString & ); 226 Addressee::List findByEmail( const QString & );
225 227
226 /** 228 /**
227 Find all entries wich have the specified category in the address book. 229 Find all entries wich have the specified category in the address book.
228 Returns an empty list, if no entries could be found. 230 Returns an empty list, if no entries could be found.
229 */ 231 */
230 Addressee::List findByCategory( const QString & ); 232 Addressee::List findByCategory( const QString & );
231 233
232 /** 234 /**
233 Return a string identifying this addressbook. 235 Return a string identifying this addressbook.
234 */ 236 */
235 virtual QString identifier(); 237 virtual QString identifier();
236 238
237 /** 239 /**
238 Used for debug output. 240 Used for debug output.
239 */ 241 */
240 void dump() const; 242 void dump() const;
241 243
242 void emitAddressBookLocked() { emit addressBookLocked( this ); } 244 void emitAddressBookLocked() { emit addressBookLocked( this ); }
243 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } 245 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); }
244 void emitAddressBookChanged() { emit addressBookChanged( this ); } 246 void emitAddressBookChanged() { emit addressBookChanged( this ); }
245 247
246 /** 248 /**
247 Return list of all Fields known to the address book which are associated 249 Return list of all Fields known to the address book which are associated
248 with the given field category. 250 with the given field category.
249 */ 251 */
250 Field::List fields( int category = Field::All ); 252 Field::List fields( int category = Field::All );
251 253
252 /** 254 /**
253 Add custom field to address book. 255 Add custom field to address book.
254 256
255 @param label User visible label of the field. 257 @param label User visible label of the field.
256 @param category Ored list of field categories. 258 @param category Ored list of field categories.
257 @param key Identifier used as key for reading and writing the field. 259 @param key Identifier used as key for reading and writing the field.
258 @param app String used as application key for reading and writing 260 @param app String used as application key for reading and writing
259 the field. 261 the field.
260 */ 262 */
261 bool addCustomField( const QString &label, int category = Field::All, 263 bool addCustomField( const QString &label, int category = Field::All,
262 const QString &key = QString::null, 264 const QString &key = QString::null,
263 const QString &app = QString::null ); 265 const QString &app = QString::null );
264 266
265 267
266 /** 268 /**
267 Add address book resource. 269 Add address book resource.
268 */ 270 */
269 bool addResource( Resource * ); 271 bool addResource( Resource * );
270 272
271 /** 273 /**
272 Remove address book resource. 274 Remove address book resource.
273 */ 275 */
274 bool removeResource( Resource * ); 276 bool removeResource( Resource * );
275 277
276 /** 278 /**
277 Return pointer list of all resources. 279 Return pointer list of all resources.
278 */ 280 */
279 QPtrList<Resource> resources(); 281 QPtrList<Resource> resources();
280 282
281 /** 283 /**
282 Set the @p ErrorHandler, that is used by @ref error() to 284 Set the @p ErrorHandler, that is used by @ref error() to
283 provide gui-independend error messages. 285 provide gui-independend error messages.
284 */ 286 */
285 void setErrorHandler( ErrorHandler * ); 287 void setErrorHandler( ErrorHandler * );
286 288
287 /** 289 /**
288 Shows gui independend error messages. 290 Shows gui independend error messages.
289 */ 291 */
290 void error( const QString& ); 292 void error( const QString& );
291 293
292 /** 294 /**
293 Query all resources to clean up their lock files 295 Query all resources to clean up their lock files
294 */ 296 */
295 void cleanUp(); 297 void cleanUp();
296 298
297 // sync stuff 299 // sync stuff
298 //Addressee::List getExternLastSyncAddressees(); 300 //Addressee::List getExternLastSyncAddressees();
299 void resetTempSyncStat(); 301 void resetTempSyncStat();
300 QStringList uidList(); 302 QStringList uidList();
301 void removeSyncAddressees( bool removeDeleted = false ); 303 void removeSyncAddressees( bool removeDeleted = false );
302 void mergeAB( AddressBook *aBook, const QString& profile ); 304 void mergeAB( AddressBook *aBook, const QString& profile );
303 Addressee findByExternUid( const QString& uid , const QString& profile ); 305 Addressee findByExternUid( const QString& uid , const QString& profile );
304 bool containsExternalUid( const QString& uid ); 306 bool containsExternalUid( const QString& uid );
305 307
306 void preExternSync( AddressBook* aBook, const QString& csd ); 308 void preExternSync( AddressBook* aBook, const QString& csd );
307 void postExternSync( AddressBook* aBook, const QString& csd ); 309 void postExternSync( AddressBook* aBook, const QString& csd );
308 signals: 310 signals:
309 /** 311 /**
310 Emitted, when the address book has changed on disk. 312 Emitted, when the address book has changed on disk.
311 */ 313 */
312 void addressBookChanged( AddressBook * ); 314 void addressBookChanged( AddressBook * );
313 315
314 /** 316 /**
315 Emitted, when the address book has been locked for writing. 317 Emitted, when the address book has been locked for writing.
316 */ 318 */
317 void addressBookLocked( AddressBook * ); 319 void addressBookLocked( AddressBook * );
318 320
319 /** 321 /**
320 Emitted, when the address book has been unlocked. 322 Emitted, when the address book has been unlocked.
321 */ 323 */
322 void addressBookUnlocked( AddressBook * ); 324 void addressBookUnlocked( AddressBook * );
323 325
324 protected: 326 protected:
325 void deleteRemovedAddressees(); 327 void deleteRemovedAddressees();
326 void setStandardResource( Resource * ); 328 void setStandardResource( Resource * );
327 Resource *standardResource(); 329 Resource *standardResource();
328 KRES::Manager<Resource> *resourceManager(); 330 KRES::Manager<Resource> *resourceManager();
329 331
330 void init(const QString &config, const QString &family); 332 void init(const QString &config, const QString &family);
331 333
332 private: 334 private:
333//US QPtrList<Resource> mDummy; // Remove in KDE 4 335//US QPtrList<Resource> mDummy; // Remove in KDE 4
334 336
335 337
336 struct AddressBookData; 338 struct AddressBookData;
337 AddressBookData *d; 339 AddressBookData *d;
338 bool blockLSEchange; 340 bool blockLSEchange;
339}; 341};
340 342
341QDataStream &operator<<( QDataStream &, const AddressBook & ); 343QDataStream &operator<<( QDataStream &, const AddressBook & );
342QDataStream &operator>>( QDataStream &, AddressBook & ); 344QDataStream &operator>>( QDataStream &, AddressBook & );
343 345
344} 346}
345 347
346#endif 348#endif