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