author | ulf69 <ulf69> | 2004-08-02 18:33:07 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-02 18:33:07 (UTC) |
commit | 60a6886f06be31ec690df34dc8e3b8931c2d3bd7 (patch) (unidiff) | |
tree | c4c7c15cfd3753a3342806a11fb8f5c20bb4f923 /kabc | |
parent | 863c4c3678e59ef125c08c00e9532ded5b540f67 (diff) | |
download | kdepimpi-60a6886f06be31ec690df34dc8e3b8931c2d3bd7.zip kdepimpi-60a6886f06be31ec690df34dc8e3b8931c2d3bd7.tar.gz kdepimpi-60a6886f06be31ec690df34dc8e3b8931c2d3bd7.tar.bz2 |
added support for syncable resources
-rw-r--r-- | kabc/addressbook.cpp | 35 | ||||
-rw-r--r-- | kabc/addressbook.h | 30 | ||||
-rw-r--r-- | kabc/kabc.pro | 4 | ||||
-rw-r--r-- | kabc/kabcE.pro | 7 | ||||
-rw-r--r-- | kabc/resource.cpp | 63 | ||||
-rw-r--r-- | kabc/resource.h | 66 |
6 files changed, 161 insertions, 44 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 0838157..20310a0 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -171,453 +171,458 @@ AddressBook::ConstIterator::~ConstIterator() | |||
171 | 171 | ||
172 | const Addressee &AddressBook::ConstIterator::operator*() const | 172 | const Addressee &AddressBook::ConstIterator::operator*() const |
173 | { | 173 | { |
174 | return *(d->mIt); | 174 | return *(d->mIt); |
175 | } | 175 | } |
176 | 176 | ||
177 | const Addressee* AddressBook::ConstIterator::operator->() const | 177 | const Addressee* AddressBook::ConstIterator::operator->() const |
178 | { | 178 | { |
179 | return &(*(d->mIt)); | 179 | return &(*(d->mIt)); |
180 | } | 180 | } |
181 | 181 | ||
182 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 182 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
183 | { | 183 | { |
184 | (d->mIt)++; | 184 | (d->mIt)++; |
185 | return *this; | 185 | return *this; |
186 | } | 186 | } |
187 | 187 | ||
188 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 188 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
189 | { | 189 | { |
190 | (d->mIt)++; | 190 | (d->mIt)++; |
191 | return *this; | 191 | return *this; |
192 | } | 192 | } |
193 | 193 | ||
194 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 194 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
195 | { | 195 | { |
196 | (d->mIt)--; | 196 | (d->mIt)--; |
197 | return *this; | 197 | return *this; |
198 | } | 198 | } |
199 | 199 | ||
200 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 200 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
201 | { | 201 | { |
202 | (d->mIt)--; | 202 | (d->mIt)--; |
203 | return *this; | 203 | return *this; |
204 | } | 204 | } |
205 | 205 | ||
206 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 206 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
207 | { | 207 | { |
208 | return ( d->mIt == it.d->mIt ); | 208 | return ( d->mIt == it.d->mIt ); |
209 | } | 209 | } |
210 | 210 | ||
211 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 211 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
212 | { | 212 | { |
213 | return ( d->mIt != it.d->mIt ); | 213 | return ( d->mIt != it.d->mIt ); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | AddressBook::AddressBook() | 217 | AddressBook::AddressBook() |
218 | { | 218 | { |
219 | init(0); | 219 | init(0, "contact"); |
220 | } | 220 | } |
221 | 221 | ||
222 | AddressBook::AddressBook( const QString &config ) | 222 | AddressBook::AddressBook( const QString &config ) |
223 | { | 223 | { |
224 | init(config); | 224 | init(config, "contact"); |
225 | } | 225 | } |
226 | 226 | ||
227 | void AddressBook::init(const QString &config) | 227 | AddressBook::AddressBook( const QString &config, const QString &family ) |
228 | { | ||
229 | init(config, family); | ||
230 | |||
231 | } | ||
232 | |||
233 | // the default family is "contact" | ||
234 | void AddressBook::init(const QString &config, const QString &family ) | ||
228 | { | 235 | { |
229 | d = new AddressBookData; | 236 | d = new AddressBookData; |
230 | if (config != 0) { | 237 | if (config != 0) { |
231 | d->mConfig = new KConfig( config ); | 238 | d->mConfig = new KConfig( config ); |
232 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 239 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
233 | } | 240 | } |
234 | else { | 241 | else { |
235 | d->mConfig = 0; | 242 | d->mConfig = 0; |
236 | // qDebug("AddressBook::init 1 config=0"); | 243 | // qDebug("AddressBook::init 1 config=0"); |
237 | } | 244 | } |
238 | 245 | ||
239 | //US d->mErrorHandler = 0; | 246 | //US d->mErrorHandler = 0; |
240 | d->mManager = new KRES::Manager<Resource>( "contact" ); | 247 | d->mManager = new KRES::Manager<Resource>( family, false ); |
241 | d->mManager->readConfig( d->mConfig ); | 248 | d->mManager->readConfig( d->mConfig ); |
242 | } | 249 | } |
243 | 250 | ||
244 | AddressBook::~AddressBook() | 251 | AddressBook::~AddressBook() |
245 | { | 252 | { |
246 | delete d->mConfig; d->mConfig = 0; | 253 | delete d->mConfig; d->mConfig = 0; |
247 | delete d->mManager; d->mManager = 0; | 254 | delete d->mManager; d->mManager = 0; |
248 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 255 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
249 | delete d; d = 0; | 256 | delete d; d = 0; |
250 | } | 257 | } |
251 | 258 | ||
252 | bool AddressBook::load() | 259 | bool AddressBook::load() |
253 | { | 260 | { |
254 | 261 | ||
255 | 262 | ||
256 | clear(); | 263 | clear(); |
257 | 264 | ||
258 | KRES::Manager<Resource>::ActiveIterator it; | 265 | KRES::Manager<Resource>::ActiveIterator it; |
259 | bool ok = true; | 266 | bool ok = true; |
260 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 267 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
261 | if ( !(*it)->load() ) { | 268 | if ( !(*it)->load() ) { |
262 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 269 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
263 | ok = false; | 270 | ok = false; |
264 | } | 271 | } |
265 | 272 | ||
266 | // mark all addressees as unchanged | 273 | // mark all addressees as unchanged |
267 | Addressee::List::Iterator addrIt; | 274 | Addressee::List::Iterator addrIt; |
268 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) | 275 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) |
269 | (*addrIt).setChanged( false ); | 276 | (*addrIt).setChanged( false ); |
270 | 277 | ||
271 | return ok; | 278 | return ok; |
272 | } | 279 | } |
273 | 280 | ||
274 | bool AddressBook::save( Ticket *ticket ) | 281 | bool AddressBook::save( Ticket *ticket ) |
275 | { | 282 | { |
276 | kdDebug(5700) << "AddressBook::save()"<< endl; | 283 | kdDebug(5700) << "AddressBook::save()"<< endl; |
277 | 284 | ||
278 | if ( ticket->resource() ) { | 285 | if ( ticket->resource() ) { |
279 | deleteRemovedAddressees(); | 286 | deleteRemovedAddressees(); |
280 | 287 | ||
281 | return ticket->resource()->save( ticket ); | 288 | return ticket->resource()->save( ticket ); |
282 | } | 289 | } |
283 | 290 | ||
284 | return false; | 291 | return false; |
285 | } | 292 | } |
286 | 293 | ||
287 | AddressBook::Iterator AddressBook::begin() | 294 | AddressBook::Iterator AddressBook::begin() |
288 | { | 295 | { |
289 | Iterator it = Iterator(); | 296 | Iterator it = Iterator(); |
290 | it.d->mIt = d->mAddressees.begin(); | 297 | it.d->mIt = d->mAddressees.begin(); |
291 | return it; | 298 | return it; |
292 | } | 299 | } |
293 | 300 | ||
294 | AddressBook::ConstIterator AddressBook::begin() const | 301 | AddressBook::ConstIterator AddressBook::begin() const |
295 | { | 302 | { |
296 | ConstIterator it = ConstIterator(); | 303 | ConstIterator it = ConstIterator(); |
297 | it.d->mIt = d->mAddressees.begin(); | 304 | it.d->mIt = d->mAddressees.begin(); |
298 | return it; | 305 | return it; |
299 | } | 306 | } |
300 | 307 | ||
301 | AddressBook::Iterator AddressBook::end() | 308 | AddressBook::Iterator AddressBook::end() |
302 | { | 309 | { |
303 | Iterator it = Iterator(); | 310 | Iterator it = Iterator(); |
304 | it.d->mIt = d->mAddressees.end(); | 311 | it.d->mIt = d->mAddressees.end(); |
305 | return it; | 312 | return it; |
306 | } | 313 | } |
307 | 314 | ||
308 | AddressBook::ConstIterator AddressBook::end() const | 315 | AddressBook::ConstIterator AddressBook::end() const |
309 | { | 316 | { |
310 | ConstIterator it = ConstIterator(); | 317 | ConstIterator it = ConstIterator(); |
311 | it.d->mIt = d->mAddressees.end(); | 318 | it.d->mIt = d->mAddressees.end(); |
312 | return it; | 319 | return it; |
313 | } | 320 | } |
314 | 321 | ||
315 | void AddressBook::clear() | 322 | void AddressBook::clear() |
316 | { | 323 | { |
317 | d->mAddressees.clear(); | 324 | d->mAddressees.clear(); |
318 | } | 325 | } |
319 | 326 | ||
320 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 327 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
321 | { | 328 | { |
322 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 329 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
323 | 330 | ||
324 | if ( !resource ) | 331 | if ( !resource ) |
325 | { | 332 | { |
326 | qDebug("AddressBook::requestSaveTicket no resource" ); | 333 | qDebug("AddressBook::requestSaveTicket no resource" ); |
327 | resource = standardResource(); | 334 | resource = standardResource(); |
328 | } | 335 | } |
329 | 336 | ||
330 | KRES::Manager<Resource>::ActiveIterator it; | 337 | KRES::Manager<Resource>::ActiveIterator it; |
331 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 338 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
332 | if ( (*it) == resource ) { | 339 | if ( (*it) == resource ) { |
333 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 340 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
334 | return 0; | 341 | return 0; |
335 | else | 342 | else |
336 | return (*it)->requestSaveTicket(); | 343 | return (*it)->requestSaveTicket(); |
337 | } | 344 | } |
338 | } | 345 | } |
339 | 346 | ||
340 | return 0; | 347 | return 0; |
341 | } | 348 | } |
342 | 349 | ||
343 | void AddressBook::insertAddressee( const Addressee &a ) | 350 | void AddressBook::insertAddressee( const Addressee &a ) |
344 | { | 351 | { |
345 | Addressee::List::Iterator it; | 352 | Addressee::List::Iterator it; |
346 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 353 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
347 | if ( a.uid() == (*it).uid() ) { | 354 | if ( a.uid() == (*it).uid() ) { |
348 | bool changed = false; | 355 | bool changed = false; |
349 | Addressee addr = a; | 356 | Addressee addr = a; |
350 | if ( addr != (*it) ) | 357 | if ( addr != (*it) ) |
351 | changed = true; | 358 | changed = true; |
352 | 359 | ||
353 | (*it) = a; | 360 | (*it) = a; |
354 | if ( (*it).resource() == 0 ) | 361 | if ( (*it).resource() == 0 ) |
355 | (*it).setResource( standardResource() ); | 362 | (*it).setResource( standardResource() ); |
356 | 363 | ||
357 | if ( changed ) { | 364 | if ( changed ) { |
358 | (*it).setRevision( QDateTime::currentDateTime() ); | 365 | (*it).setRevision( QDateTime::currentDateTime() ); |
359 | (*it).setChanged( true ); | 366 | (*it).setChanged( true ); |
360 | } | 367 | } |
361 | 368 | ||
362 | return; | 369 | return; |
363 | } | 370 | } |
364 | } | 371 | } |
365 | d->mAddressees.append( a ); | 372 | d->mAddressees.append( a ); |
366 | Addressee& addr = d->mAddressees.last(); | 373 | Addressee& addr = d->mAddressees.last(); |
367 | if ( addr.resource() == 0 ) | 374 | if ( addr.resource() == 0 ) |
368 | addr.setResource( standardResource() ); | 375 | addr.setResource( standardResource() ); |
369 | 376 | ||
370 | addr.setChanged( true ); | 377 | addr.setChanged( true ); |
371 | } | 378 | } |
372 | 379 | ||
373 | void AddressBook::removeAddressee( const Addressee &a ) | 380 | void AddressBook::removeAddressee( const Addressee &a ) |
374 | { | 381 | { |
375 | Iterator it; | 382 | Iterator it; |
376 | for ( it = begin(); it != end(); ++it ) { | 383 | for ( it = begin(); it != end(); ++it ) { |
377 | if ( a.uid() == (*it).uid() ) { | 384 | if ( a.uid() == (*it).uid() ) { |
378 | removeAddressee( it ); | 385 | removeAddressee( it ); |
379 | return; | 386 | return; |
380 | } | 387 | } |
381 | } | 388 | } |
382 | } | 389 | } |
383 | 390 | ||
384 | void AddressBook::removeAddressee( const Iterator &it ) | 391 | void AddressBook::removeAddressee( const Iterator &it ) |
385 | { | 392 | { |
386 | d->mRemovedAddressees.append( (*it) ); | 393 | d->mRemovedAddressees.append( (*it) ); |
387 | d->mAddressees.remove( it.d->mIt ); | 394 | d->mAddressees.remove( it.d->mIt ); |
388 | } | 395 | } |
389 | 396 | ||
390 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 397 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
391 | { | 398 | { |
392 | Iterator it; | 399 | Iterator it; |
393 | for ( it = begin(); it != end(); ++it ) { | 400 | for ( it = begin(); it != end(); ++it ) { |
394 | if ( a.uid() == (*it).uid() ) { | 401 | if ( a.uid() == (*it).uid() ) { |
395 | return it; | 402 | return it; |
396 | } | 403 | } |
397 | } | 404 | } |
398 | return end(); | 405 | return end(); |
399 | } | 406 | } |
400 | 407 | ||
401 | Addressee AddressBook::findByUid( const QString &uid ) | 408 | Addressee AddressBook::findByUid( const QString &uid ) |
402 | { | 409 | { |
403 | Iterator it; | 410 | Iterator it; |
404 | for ( it = begin(); it != end(); ++it ) { | 411 | for ( it = begin(); it != end(); ++it ) { |
405 | if ( uid == (*it).uid() ) { | 412 | if ( uid == (*it).uid() ) { |
406 | return *it; | 413 | return *it; |
407 | } | 414 | } |
408 | } | 415 | } |
409 | return Addressee(); | 416 | return Addressee(); |
410 | } | 417 | } |
411 | 418 | ||
412 | Addressee::List AddressBook::allAddressees() | 419 | Addressee::List AddressBook::allAddressees() |
413 | { | 420 | { |
414 | return d->mAddressees; | 421 | return d->mAddressees; |
415 | } | 422 | } |
416 | 423 | ||
417 | Addressee::List AddressBook::findByName( const QString &name ) | 424 | Addressee::List AddressBook::findByName( const QString &name ) |
418 | { | 425 | { |
419 | Addressee::List results; | 426 | Addressee::List results; |
420 | 427 | ||
421 | Iterator it; | 428 | Iterator it; |
422 | for ( it = begin(); it != end(); ++it ) { | 429 | for ( it = begin(); it != end(); ++it ) { |
423 | if ( name == (*it).name() ) { | 430 | if ( name == (*it).name() ) { |
424 | results.append( *it ); | 431 | results.append( *it ); |
425 | } | 432 | } |
426 | } | 433 | } |
427 | 434 | ||
428 | return results; | 435 | return results; |
429 | } | 436 | } |
430 | 437 | ||
431 | Addressee::List AddressBook::findByEmail( const QString &email ) | 438 | Addressee::List AddressBook::findByEmail( const QString &email ) |
432 | { | 439 | { |
433 | Addressee::List results; | 440 | Addressee::List results; |
434 | QStringList mailList; | 441 | QStringList mailList; |
435 | 442 | ||
436 | Iterator it; | 443 | Iterator it; |
437 | for ( it = begin(); it != end(); ++it ) { | 444 | for ( it = begin(); it != end(); ++it ) { |
438 | mailList = (*it).emails(); | 445 | mailList = (*it).emails(); |
439 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 446 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
440 | if ( email == (*ite) ) { | 447 | if ( email == (*ite) ) { |
441 | results.append( *it ); | 448 | results.append( *it ); |
442 | } | 449 | } |
443 | } | 450 | } |
444 | } | 451 | } |
445 | 452 | ||
446 | return results; | 453 | return results; |
447 | } | 454 | } |
448 | 455 | ||
449 | Addressee::List AddressBook::findByCategory( const QString &category ) | 456 | Addressee::List AddressBook::findByCategory( const QString &category ) |
450 | { | 457 | { |
451 | Addressee::List results; | 458 | Addressee::List results; |
452 | 459 | ||
453 | Iterator it; | 460 | Iterator it; |
454 | for ( it = begin(); it != end(); ++it ) { | 461 | for ( it = begin(); it != end(); ++it ) { |
455 | if ( (*it).hasCategory( category) ) { | 462 | if ( (*it).hasCategory( category) ) { |
456 | results.append( *it ); | 463 | results.append( *it ); |
457 | } | 464 | } |
458 | } | 465 | } |
459 | 466 | ||
460 | return results; | 467 | return results; |
461 | } | 468 | } |
462 | 469 | ||
463 | void AddressBook::dump() const | 470 | void AddressBook::dump() const |
464 | { | 471 | { |
465 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; | 472 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; |
466 | 473 | ||
467 | ConstIterator it; | 474 | ConstIterator it; |
468 | for( it = begin(); it != end(); ++it ) { | 475 | for( it = begin(); it != end(); ++it ) { |
469 | (*it).dump(); | 476 | (*it).dump(); |
470 | } | 477 | } |
471 | 478 | ||
472 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; | 479 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; |
473 | } | 480 | } |
474 | 481 | ||
475 | QString AddressBook::identifier() | 482 | QString AddressBook::identifier() |
476 | { | 483 | { |
477 | QStringList identifier; | 484 | QStringList identifier; |
478 | 485 | ||
479 | 486 | ||
480 | KRES::Manager<Resource>::ActiveIterator it; | 487 | KRES::Manager<Resource>::ActiveIterator it; |
481 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 488 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
482 | if ( !(*it)->identifier().isEmpty() ) | 489 | if ( !(*it)->identifier().isEmpty() ) |
483 | identifier.append( (*it)->identifier() ); | 490 | identifier.append( (*it)->identifier() ); |
484 | } | 491 | } |
485 | 492 | ||
486 | return identifier.join( ":" ); | 493 | return identifier.join( ":" ); |
487 | } | 494 | } |
488 | 495 | ||
489 | Field::List AddressBook::fields( int category ) | 496 | Field::List AddressBook::fields( int category ) |
490 | { | 497 | { |
491 | if ( d->mAllFields.isEmpty() ) { | 498 | if ( d->mAllFields.isEmpty() ) { |
492 | d->mAllFields = Field::allFields(); | 499 | d->mAllFields = Field::allFields(); |
493 | } | 500 | } |
494 | 501 | ||
495 | if ( category == Field::All ) return d->mAllFields; | 502 | if ( category == Field::All ) return d->mAllFields; |
496 | 503 | ||
497 | Field::List result; | 504 | Field::List result; |
498 | Field::List::ConstIterator it; | 505 | Field::List::ConstIterator it; |
499 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { | 506 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { |
500 | if ( (*it)->category() & category ) result.append( *it ); | 507 | if ( (*it)->category() & category ) result.append( *it ); |
501 | } | 508 | } |
502 | 509 | ||
503 | return result; | 510 | return result; |
504 | } | 511 | } |
505 | 512 | ||
506 | bool AddressBook::addCustomField( const QString &label, int category, | 513 | bool AddressBook::addCustomField( const QString &label, int category, |
507 | const QString &key, const QString &app ) | 514 | const QString &key, const QString &app ) |
508 | { | 515 | { |
509 | if ( d->mAllFields.isEmpty() ) { | 516 | if ( d->mAllFields.isEmpty() ) { |
510 | d->mAllFields = Field::allFields(); | 517 | d->mAllFields = Field::allFields(); |
511 | } | 518 | } |
512 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; | 519 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; |
513 | QString a = app.isNull() ? KGlobal::getAppName() : app; | 520 | QString a = app.isNull() ? KGlobal::getAppName() : app; |
514 | 521 | ||
515 | QString k = key.isNull() ? label : key; | 522 | QString k = key.isNull() ? label : key; |
516 | 523 | ||
517 | Field *field = Field::createCustomField( label, category, k, a ); | 524 | Field *field = Field::createCustomField( label, category, k, a ); |
518 | 525 | ||
519 | if ( !field ) return false; | 526 | if ( !field ) return false; |
520 | 527 | ||
521 | d->mAllFields.append( field ); | 528 | d->mAllFields.append( field ); |
522 | 529 | ||
523 | return true; | 530 | return true; |
524 | } | 531 | } |
525 | 532 | ||
526 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) | 533 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) |
527 | { | 534 | { |
528 | if (!ab.d) return s; | 535 | if (!ab.d) return s; |
529 | 536 | ||
530 | return s << ab.d->mAddressees; | 537 | return s << ab.d->mAddressees; |
531 | } | 538 | } |
532 | 539 | ||
533 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) | 540 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) |
534 | { | 541 | { |
535 | if (!ab.d) return s; | 542 | if (!ab.d) return s; |
536 | 543 | ||
537 | s >> ab.d->mAddressees; | 544 | s >> ab.d->mAddressees; |
538 | 545 | ||
539 | return s; | 546 | return s; |
540 | } | 547 | } |
541 | 548 | ||
542 | bool AddressBook::addResource( Resource *resource ) | 549 | bool AddressBook::addResource( Resource *resource ) |
543 | { | 550 | { |
544 | qDebug("AddressBook::addResource 1"); | ||
545 | |||
546 | if ( !resource->open() ) { | 551 | if ( !resource->open() ) { |
547 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; | 552 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; |
548 | return false; | 553 | return false; |
549 | } | 554 | } |
550 | 555 | ||
551 | resource->setAddressBook( this ); | 556 | resource->setAddressBook( this ); |
552 | 557 | ||
553 | d->mManager->add( resource ); | 558 | d->mManager->add( resource ); |
554 | return true; | 559 | return true; |
555 | } | 560 | } |
556 | 561 | ||
557 | bool AddressBook::removeResource( Resource *resource ) | 562 | bool AddressBook::removeResource( Resource *resource ) |
558 | { | 563 | { |
559 | resource->close(); | 564 | resource->close(); |
560 | 565 | ||
561 | if ( resource == standardResource() ) | 566 | if ( resource == standardResource() ) |
562 | d->mManager->setStandardResource( 0 ); | 567 | d->mManager->setStandardResource( 0 ); |
563 | 568 | ||
564 | resource->setAddressBook( 0 ); | 569 | resource->setAddressBook( 0 ); |
565 | 570 | ||
566 | d->mManager->remove( resource ); | 571 | d->mManager->remove( resource ); |
567 | return true; | 572 | return true; |
568 | } | 573 | } |
569 | 574 | ||
570 | QPtrList<Resource> AddressBook::resources() | 575 | QPtrList<Resource> AddressBook::resources() |
571 | { | 576 | { |
572 | QPtrList<Resource> list; | 577 | QPtrList<Resource> list; |
573 | 578 | ||
574 | // qDebug("AddressBook::resources() 1"); | 579 | // qDebug("AddressBook::resources() 1"); |
575 | 580 | ||
576 | KRES::Manager<Resource>::ActiveIterator it; | 581 | KRES::Manager<Resource>::ActiveIterator it; |
577 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 582 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
578 | list.append( *it ); | 583 | list.append( *it ); |
579 | 584 | ||
580 | return list; | 585 | return list; |
581 | } | 586 | } |
582 | 587 | ||
583 | /*US | 588 | /*US |
584 | void AddressBook::setErrorHandler( ErrorHandler *handler ) | 589 | void AddressBook::setErrorHandler( ErrorHandler *handler ) |
585 | { | 590 | { |
586 | delete d->mErrorHandler; | 591 | delete d->mErrorHandler; |
587 | d->mErrorHandler = handler; | 592 | d->mErrorHandler = handler; |
588 | } | 593 | } |
589 | */ | 594 | */ |
590 | 595 | ||
591 | void AddressBook::error( const QString& msg ) | 596 | void AddressBook::error( const QString& msg ) |
592 | { | 597 | { |
593 | /*US | 598 | /*US |
594 | if ( !d->mErrorHandler ) // create default error handler | 599 | if ( !d->mErrorHandler ) // create default error handler |
595 | d->mErrorHandler = new ConsoleErrorHandler; | 600 | d->mErrorHandler = new ConsoleErrorHandler; |
596 | 601 | ||
597 | if ( d->mErrorHandler ) | 602 | if ( d->mErrorHandler ) |
598 | d->mErrorHandler->error( msg ); | 603 | d->mErrorHandler->error( msg ); |
599 | else | 604 | else |
600 | kdError(5700) << "no error handler defined" << endl; | 605 | kdError(5700) << "no error handler defined" << endl; |
601 | */ | 606 | */ |
602 | kdDebug(5700) << "msg" << endl; | 607 | kdDebug(5700) << "msg" << endl; |
603 | qDebug(msg); | 608 | qDebug(msg); |
604 | } | 609 | } |
605 | 610 | ||
606 | void AddressBook::deleteRemovedAddressees() | 611 | void AddressBook::deleteRemovedAddressees() |
607 | { | 612 | { |
608 | Addressee::List::Iterator it; | 613 | Addressee::List::Iterator it; |
609 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { | 614 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { |
610 | Resource *resource = (*it).resource(); | 615 | Resource *resource = (*it).resource(); |
611 | if ( resource && !resource->readOnly() && resource->isOpen() ) | 616 | if ( resource && !resource->readOnly() && resource->isOpen() ) |
612 | resource->removeAddressee( *it ); | 617 | resource->removeAddressee( *it ); |
613 | } | 618 | } |
614 | 619 | ||
615 | d->mRemovedAddressees.clear(); | 620 | d->mRemovedAddressees.clear(); |
616 | } | 621 | } |
617 | 622 | ||
618 | void AddressBook::setStandardResource( Resource *resource ) | 623 | void AddressBook::setStandardResource( Resource *resource ) |
619 | { | 624 | { |
620 | // qDebug("AddressBook::setStandardResource 1"); | 625 | // qDebug("AddressBook::setStandardResource 1"); |
621 | d->mManager->setStandardResource( resource ); | 626 | d->mManager->setStandardResource( resource ); |
622 | } | 627 | } |
623 | 628 | ||
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 3a8e028..f89d7da 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -1,327 +1,327 @@ | |||
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 | virtual ~AddressBook(); | 120 | virtual ~AddressBook(); |
120 | 121 | ||
121 | /** | 122 | /** |
122 | Requests a ticket for saving the addressbook. Calling this function locks | 123 | Requests a ticket for saving the addressbook. Calling this function locks |
123 | 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 |
124 | 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 |
125 | for calling the @ref save() function. | 126 | for calling the @ref save() function. |
126 | 127 | ||
127 | @see save() | 128 | @see save() |
128 | */ | 129 | */ |
129 | Ticket *requestSaveTicket( Resource *resource=0 ); | 130 | Ticket *requestSaveTicket( Resource *resource=0 ); |
130 | 131 | ||
131 | /** | 132 | /** |
132 | Load address book from file. | 133 | Load address book from file. |
133 | */ | 134 | */ |
134 | bool load(); | 135 | bool load(); |
135 | 136 | ||
136 | /** | 137 | /** |
137 | 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 |
138 | object has been requested for by @ref requestSaveTicket(). | 139 | object has been requested for by @ref requestSaveTicket(). |
139 | 140 | ||
140 | @param ticket a ticket object returned by @ref requestSaveTicket() | 141 | @param ticket a ticket object returned by @ref requestSaveTicket() |
141 | */ | 142 | */ |
142 | bool save( Ticket *ticket ); | 143 | bool save( Ticket *ticket ); |
143 | 144 | ||
144 | /** | 145 | /** |
145 | Returns a iterator for first entry of address book. | 146 | Returns a iterator for first entry of address book. |
146 | */ | 147 | */ |
147 | Iterator begin(); | 148 | Iterator begin(); |
148 | 149 | ||
149 | /** | 150 | /** |
150 | Returns a const iterator for first entry of address book. | 151 | Returns a const iterator for first entry of address book. |
151 | */ | 152 | */ |
152 | ConstIterator begin() const; | 153 | ConstIterator begin() const; |
153 | 154 | ||
154 | /** | 155 | /** |
155 | Returns a iterator for first entry of address book. | 156 | Returns a iterator for first entry of address book. |
156 | */ | 157 | */ |
157 | Iterator end(); | 158 | Iterator end(); |
158 | 159 | ||
159 | /** | 160 | /** |
160 | Returns a const iterator for first entry of address book. | 161 | Returns a const iterator for first entry of address book. |
161 | */ | 162 | */ |
162 | ConstIterator end() const; | 163 | ConstIterator end() const; |
163 | 164 | ||
164 | /** | 165 | /** |
165 | Removes all entries from address book. | 166 | Removes all entries from address book. |
166 | */ | 167 | */ |
167 | void clear(); | 168 | void clear(); |
168 | 169 | ||
169 | /** | 170 | /** |
170 | Insert an Addressee object into address book. If an object with the same | 171 | Insert an Addressee object into address book. If an object with the same |
171 | unique id already exists in the address book it it replaced by the new | 172 | unique id already exists in the address book it it replaced by the new |
172 | one. If not the new object is appended to the address book. | 173 | one. If not the new object is appended to the address book. |
173 | */ | 174 | */ |
174 | void insertAddressee( const Addressee & ); | 175 | void insertAddressee( const Addressee & ); |
175 | 176 | ||
176 | /** | 177 | /** |
177 | Removes entry from the address book. | 178 | Removes entry from the address book. |
178 | */ | 179 | */ |
179 | void removeAddressee( const Addressee & ); | 180 | void removeAddressee( const Addressee & ); |
180 | 181 | ||
181 | /** | 182 | /** |
182 | This is like @ref removeAddressee() just above, with the difference that | 183 | This is like @ref removeAddressee() just above, with the difference that |
183 | the first element is a iterator, returned by @ref begin(). | 184 | the first element is a iterator, returned by @ref begin(). |
184 | */ | 185 | */ |
185 | void removeAddressee( const Iterator & ); | 186 | void removeAddressee( const Iterator & ); |
186 | 187 | ||
187 | /** | 188 | /** |
188 | Find the specified entry in address book. Returns end(), if the entry | 189 | Find the specified entry in address book. Returns end(), if the entry |
189 | couldn't be found. | 190 | couldn't be found. |
190 | */ | 191 | */ |
191 | Iterator find( const Addressee & ); | 192 | Iterator find( const Addressee & ); |
192 | 193 | ||
193 | /** | 194 | /** |
194 | Find the entry specified by an unique id. Returns an empty Addressee | 195 | Find the entry specified by an unique id. Returns an empty Addressee |
195 | object, if the address book does not contain an entry with this id. | 196 | object, if the address book does not contain an entry with this id. |
196 | */ | 197 | */ |
197 | Addressee findByUid( const QString & ); | 198 | Addressee findByUid( const QString & ); |
198 | 199 | ||
199 | 200 | ||
200 | /** | 201 | /** |
201 | Returns a list of all addressees in the address book. This list can | 202 | Returns a list of all addressees in the address book. This list can |
202 | be sorted with @ref KABC::AddresseeList for example. | 203 | be sorted with @ref KABC::AddresseeList for example. |
203 | */ | 204 | */ |
204 | Addressee::List allAddressees(); | 205 | Addressee::List allAddressees(); |
205 | 206 | ||
206 | /** | 207 | /** |
207 | Find all entries with the specified name in the address book. Returns | 208 | Find all entries with the specified name in the address book. Returns |
208 | an empty list, if no entries could be found. | 209 | an empty list, if no entries could be found. |
209 | */ | 210 | */ |
210 | Addressee::List findByName( const QString & ); | 211 | Addressee::List findByName( const QString & ); |
211 | 212 | ||
212 | /** | 213 | /** |
213 | Find all entries with the specified email address in the address book. | 214 | Find all entries with the specified email address in the address book. |
214 | Returns an empty list, if no entries could be found. | 215 | Returns an empty list, if no entries could be found. |
215 | */ | 216 | */ |
216 | Addressee::List findByEmail( const QString & ); | 217 | Addressee::List findByEmail( const QString & ); |
217 | 218 | ||
218 | /** | 219 | /** |
219 | Find all entries wich have the specified category in the address book. | 220 | Find all entries wich have the specified category in the address book. |
220 | Returns an empty list, if no entries could be found. | 221 | Returns an empty list, if no entries could be found. |
221 | */ | 222 | */ |
222 | Addressee::List findByCategory( const QString & ); | 223 | Addressee::List findByCategory( const QString & ); |
223 | 224 | ||
224 | /** | 225 | /** |
225 | Return a string identifying this addressbook. | 226 | Return a string identifying this addressbook. |
226 | */ | 227 | */ |
227 | virtual QString identifier(); | 228 | virtual QString identifier(); |
228 | 229 | ||
229 | /** | 230 | /** |
230 | Used for debug output. | 231 | Used for debug output. |
231 | */ | 232 | */ |
232 | void dump() const; | 233 | void dump() const; |
233 | 234 | ||
234 | void emitAddressBookLocked() { emit addressBookLocked( this ); } | 235 | void emitAddressBookLocked() { emit addressBookLocked( this ); } |
235 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } | 236 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } |
236 | void emitAddressBookChanged() { emit addressBookChanged( this ); } | 237 | void emitAddressBookChanged() { emit addressBookChanged( this ); } |
237 | 238 | ||
238 | /** | 239 | /** |
239 | Return list of all Fields known to the address book which are associated | 240 | Return list of all Fields known to the address book which are associated |
240 | with the given field category. | 241 | with the given field category. |
241 | */ | 242 | */ |
242 | Field::List fields( int category = Field::All ); | 243 | Field::List fields( int category = Field::All ); |
243 | 244 | ||
244 | /** | 245 | /** |
245 | Add custom field to address book. | 246 | Add custom field to address book. |
246 | 247 | ||
247 | @param label User visible label of the field. | 248 | @param label User visible label of the field. |
248 | @param category Ored list of field categories. | 249 | @param category Ored list of field categories. |
249 | @param key Identifier used as key for reading and writing the field. | 250 | @param key Identifier used as key for reading and writing the field. |
250 | @param app String used as application key for reading and writing | 251 | @param app String used as application key for reading and writing |
251 | the field. | 252 | the field. |
252 | */ | 253 | */ |
253 | bool addCustomField( const QString &label, int category = Field::All, | 254 | bool addCustomField( const QString &label, int category = Field::All, |
254 | const QString &key = QString::null, | 255 | const QString &key = QString::null, |
255 | const QString &app = QString::null ); | 256 | const QString &app = QString::null ); |
256 | 257 | ||
257 | 258 | ||
258 | /** | 259 | /** |
259 | Add address book resource. | 260 | Add address book resource. |
260 | */ | 261 | */ |
261 | bool addResource( Resource * ); | 262 | bool addResource( Resource * ); |
262 | 263 | ||
263 | /** | 264 | /** |
264 | Remove address book resource. | 265 | Remove address book resource. |
265 | */ | 266 | */ |
266 | bool removeResource( Resource * ); | 267 | bool removeResource( Resource * ); |
267 | 268 | ||
268 | /** | 269 | /** |
269 | Return pointer list of all resources. | 270 | Return pointer list of all resources. |
270 | */ | 271 | */ |
271 | QPtrList<Resource> resources(); | 272 | QPtrList<Resource> resources(); |
272 | 273 | ||
273 | /** | 274 | /** |
274 | Set the @p ErrorHandler, that is used by @ref error() to | 275 | Set the @p ErrorHandler, that is used by @ref error() to |
275 | provide gui-independend error messages. | 276 | provide gui-independend error messages. |
276 | */ | 277 | */ |
277 | void setErrorHandler( ErrorHandler * ); | 278 | void setErrorHandler( ErrorHandler * ); |
278 | 279 | ||
279 | /** | 280 | /** |
280 | Shows gui independend error messages. | 281 | Shows gui independend error messages. |
281 | */ | 282 | */ |
282 | void error( const QString& ); | 283 | void error( const QString& ); |
283 | 284 | ||
284 | /** | 285 | /** |
285 | Query all resources to clean up their lock files | 286 | Query all resources to clean up their lock files |
286 | */ | 287 | */ |
287 | void cleanUp(); | 288 | void cleanUp(); |
288 | 289 | ||
289 | signals: | 290 | signals: |
290 | /** | 291 | /** |
291 | Emitted, when the address book has changed on disk. | 292 | Emitted, when the address book has changed on disk. |
292 | */ | 293 | */ |
293 | void addressBookChanged( AddressBook * ); | 294 | void addressBookChanged( AddressBook * ); |
294 | 295 | ||
295 | /** | 296 | /** |
296 | Emitted, when the address book has been locked for writing. | 297 | Emitted, when the address book has been locked for writing. |
297 | */ | 298 | */ |
298 | void addressBookLocked( AddressBook * ); | 299 | void addressBookLocked( AddressBook * ); |
299 | 300 | ||
300 | /** | 301 | /** |
301 | Emitted, when the address book has been unlocked. | 302 | Emitted, when the address book has been unlocked. |
302 | */ | 303 | */ |
303 | void addressBookUnlocked( AddressBook * ); | 304 | void addressBookUnlocked( AddressBook * ); |
304 | 305 | ||
305 | protected: | 306 | protected: |
306 | void deleteRemovedAddressees(); | 307 | void deleteRemovedAddressees(); |
307 | void setStandardResource( Resource * ); | 308 | void setStandardResource( Resource * ); |
308 | Resource *standardResource(); | 309 | Resource *standardResource(); |
309 | KRES::Manager<Resource> *resourceManager(); | 310 | KRES::Manager<Resource> *resourceManager(); |
310 | 311 | ||
312 | void init(const QString &config, const QString &family); | ||
313 | |||
311 | private: | 314 | private: |
312 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 315 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
313 | 316 | ||
314 | //US optimization | ||
315 | void init(const QString &config); | ||
316 | |||
317 | 317 | ||
318 | struct AddressBookData; | 318 | struct AddressBookData; |
319 | AddressBookData *d; | 319 | AddressBookData *d; |
320 | }; | 320 | }; |
321 | 321 | ||
322 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 322 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
323 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 323 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
324 | 324 | ||
325 | } | 325 | } |
326 | 326 | ||
327 | #endif | 327 | #endif |
diff --git a/kabc/kabc.pro b/kabc/kabc.pro index a8cd695..10b092c 100644 --- a/kabc/kabc.pro +++ b/kabc/kabc.pro | |||
@@ -1,98 +1,99 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | #release debug | 3 | #release debug |
4 | DESTDIR=../bin | 4 | DESTDIR=../bin |
5 | 5 | ||
6 | TARGET = microkabc | 6 | TARGET = microkabc |
7 | 7 | ||
8 | include( ../variables.pri ) | 8 | include( ../variables.pri ) |
9 | 9 | ||
10 | INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../microkde/kio/kio ../qtcompat ../microkde/kdeui | 10 | INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim ../qtcompat ../microkde/kdeui |
11 | 11 | ||
12 | #LIBS += -lmicrokde -lldap | 12 | #LIBS += -lmicrokde -lldap |
13 | LIBS += -L$(QPEDIR)/lib | 13 | LIBS += -L$(QPEDIR)/lib |
14 | DEFINES += KAB_EMBEDDED DESKTOP_VERSION | 14 | DEFINES += KAB_EMBEDDED DESKTOP_VERSION |
15 | unix : { | 15 | unix : { |
16 | 16 | ||
17 | OBJECTS_DIR = obj/unix | 17 | OBJECTS_DIR = obj/unix |
18 | MOC_DIR = moc/unix | 18 | MOC_DIR = moc/unix |
19 | } | 19 | } |
20 | win32: { | 20 | win32: { |
21 | DEFINES += _WIN32_ | 21 | DEFINES += _WIN32_ |
22 | OBJECTS_DIR = obj/win | 22 | OBJECTS_DIR = obj/win |
23 | MOC_DIR = moc/win | 23 | MOC_DIR = moc/win |
24 | } | 24 | } |
25 | INTERFACES = \ | 25 | INTERFACES = \ |
26 | 26 | ||
27 | 27 | ||
28 | HEADERS = \ | 28 | HEADERS = \ |
29 | resource.h \ | 29 | resource.h \ |
30 | stdaddressbook.h \ | 30 | stdaddressbook.h \ |
31 | agent.h \ | 31 | agent.h \ |
32 | geo.h \ | 32 | geo.h \ |
33 | key.h \ | 33 | key.h \ |
34 | field.h \ | 34 | field.h \ |
35 | plugin.h \ | 35 | plugin.h \ |
36 | address.h \ | 36 | address.h \ |
37 | addresseelist.h \ | 37 | addresseelist.h \ |
38 | formatfactory.h \ | 38 | formatfactory.h \ |
39 | formatplugin.h \ | 39 | formatplugin.h \ |
40 | phonenumber.h \ | 40 | phonenumber.h \ |
41 | distributionlist.h \ | 41 | distributionlist.h \ |
42 | distributionlistdialog.h \ | 42 | distributionlistdialog.h \ |
43 | distributionlisteditor.h \ | 43 | distributionlisteditor.h \ |
44 | vcardformatplugin.h \ | 44 | vcardformatplugin.h \ |
45 | formats/vcardformatplugin2.h \ | 45 | formats/vcardformatplugin2.h \ |
46 | picture.h \ | 46 | picture.h \ |
47 | secrecy.h \ | 47 | secrecy.h \ |
48 | sound.h \ | 48 | sound.h \ |
49 | addressbook.h \ | 49 | addressbook.h \ |
50 | timezone.h \ | 50 | timezone.h \ |
51 | tmpaddressbook.h \ | ||
51 | addressee.h \ | 52 | addressee.h \ |
52 | addresseedialog.h \ | 53 | addresseedialog.h \ |
53 | vcardconverter.h \ | 54 | vcardconverter.h \ |
54 | vcard21parser.h \ | 55 | vcard21parser.h \ |
55 | vcardformatimpl.h \ | 56 | vcardformatimpl.h \ |
56 | plugins/file/resourcefile.h \ | 57 | plugins/file/resourcefile.h \ |
57 | plugins/file/resourcefileconfig.h \ | 58 | plugins/file/resourcefileconfig.h \ |
58 | plugins/dir/resourcedir.h \ | 59 | plugins/dir/resourcedir.h \ |
59 | plugins/dir/resourcedirconfig.h \ | 60 | plugins/dir/resourcedirconfig.h \ |
60 | vcardparser/vcardline.h \ | 61 | vcardparser/vcardline.h \ |
61 | vcardparser/vcard.h \ | 62 | vcardparser/vcard.h \ |
62 | vcardparser/vcardtool.h \ | 63 | vcardparser/vcardtool.h \ |
63 | vcardparser/vcardparser.h \ | 64 | vcardparser/vcardparser.h \ |
64 | vcard/include/VCardAdrParam.h \ | 65 | vcard/include/VCardAdrParam.h \ |
65 | vcard/include/VCardAdrValue.h \ | 66 | vcard/include/VCardAdrValue.h \ |
66 | vcard/include/VCardAgentParam.h \ | 67 | vcard/include/VCardAgentParam.h \ |
67 | vcard/include/VCardContentLine.h \ | 68 | vcard/include/VCardContentLine.h \ |
68 | vcard/include/VCardDateParam.h \ | 69 | vcard/include/VCardDateParam.h \ |
69 | vcard/include/VCardDateValue.h \ | 70 | vcard/include/VCardDateValue.h \ |
70 | vcard/include/VCardEmailParam.h \ | 71 | vcard/include/VCardEmailParam.h \ |
71 | vcard/include/VCardGeoValue.h \ | 72 | vcard/include/VCardGeoValue.h \ |
72 | vcard/include/VCardGroup.h \ | 73 | vcard/include/VCardGroup.h \ |
73 | vcard/include/VCardImageParam.h \ | 74 | vcard/include/VCardImageParam.h \ |
74 | vcard/include/VCardImageValue.h \ | 75 | vcard/include/VCardImageValue.h \ |
75 | vcard/include/VCardLangValue.h \ | 76 | vcard/include/VCardLangValue.h \ |
76 | vcard/include/VCardNValue.h \ | 77 | vcard/include/VCardNValue.h \ |
77 | vcard/include/VCardParam.h \ | 78 | vcard/include/VCardParam.h \ |
78 | vcard/include/VCardPhoneNumberValue.h \ | 79 | vcard/include/VCardPhoneNumberValue.h \ |
79 | vcard/include/VCardSourceParam.h \ | 80 | vcard/include/VCardSourceParam.h \ |
80 | vcard/include/VCardTelParam.h \ | 81 | vcard/include/VCardTelParam.h \ |
81 | vcard/include/VCardTextParam.h \ | 82 | vcard/include/VCardTextParam.h \ |
82 | vcard/include/VCardTextNSParam.h \ | 83 | vcard/include/VCardTextNSParam.h \ |
83 | vcard/include/VCardTextValue.h \ | 84 | vcard/include/VCardTextValue.h \ |
84 | vcard/include/VCardTextBinParam.h \ | 85 | vcard/include/VCardTextBinParam.h \ |
85 | vcard/include/VCardURIValue.h \ | 86 | vcard/include/VCardURIValue.h \ |
86 | vcard/include/VCardVCard.h \ | 87 | vcard/include/VCardVCard.h \ |
87 | vcard/include/VCardEntity.h \ | 88 | vcard/include/VCardEntity.h \ |
88 | vcard/include/VCardValue.h \ | 89 | vcard/include/VCardValue.h \ |
89 | vcard/include/VCardSoundValue.h \ | 90 | vcard/include/VCardSoundValue.h \ |
90 | vcard/include/VCardAgentValue.h \ | 91 | vcard/include/VCardAgentValue.h \ |
91 | vcard/include/VCardTelValue.h \ | 92 | vcard/include/VCardTelValue.h \ |
92 | vcard/include/VCardTextBinValue.h \ | 93 | vcard/include/VCardTextBinValue.h \ |
93 | vcard/include/VCardOrgValue.h \ | 94 | vcard/include/VCardOrgValue.h \ |
94 | vcard/include/VCardUTCValue.h \ | 95 | vcard/include/VCardUTCValue.h \ |
95 | vcard/include/VCardClassValue.h \ | 96 | vcard/include/VCardClassValue.h \ |
96 | vcard/include/VCardFloatValue.h \ | 97 | vcard/include/VCardFloatValue.h \ |
97 | vcard/include/VCardTextListValue.h \ | 98 | vcard/include/VCardTextListValue.h \ |
98 | vcard/include/generated/AdrParam-generated.h \ | 99 | vcard/include/generated/AdrParam-generated.h \ |
@@ -112,96 +113,97 @@ vcard/include/generated/Param-generated.h \ | |||
112 | vcard/include/generated/PhoneNumberValue-generated.h \ | 113 | vcard/include/generated/PhoneNumberValue-generated.h \ |
113 | vcard/include/generated/SourceParam-generated.h \ | 114 | vcard/include/generated/SourceParam-generated.h \ |
114 | vcard/include/generated/TelParam-generated.h \ | 115 | vcard/include/generated/TelParam-generated.h \ |
115 | vcard/include/generated/TextParam-generated.h \ | 116 | vcard/include/generated/TextParam-generated.h \ |
116 | vcard/include/generated/TextNSParam-generated.h \ | 117 | vcard/include/generated/TextNSParam-generated.h \ |
117 | vcard/include/generated/TextValue-generated.h \ | 118 | vcard/include/generated/TextValue-generated.h \ |
118 | vcard/include/generated/TextBinParam-generated.h \ | 119 | vcard/include/generated/TextBinParam-generated.h \ |
119 | vcard/include/generated/URIValue-generated.h \ | 120 | vcard/include/generated/URIValue-generated.h \ |
120 | vcard/include/generated/VCard-generated.h \ | 121 | vcard/include/generated/VCard-generated.h \ |
121 | vcard/include/generated/VCardEntity-generated.h \ | 122 | vcard/include/generated/VCardEntity-generated.h \ |
122 | vcard/include/generated/Value-generated.h \ | 123 | vcard/include/generated/Value-generated.h \ |
123 | vcard/include/generated/SoundValue-generated.h \ | 124 | vcard/include/generated/SoundValue-generated.h \ |
124 | vcard/include/generated/AgentValue-generated.h \ | 125 | vcard/include/generated/AgentValue-generated.h \ |
125 | vcard/include/generated/TelValue-generated.h \ | 126 | vcard/include/generated/TelValue-generated.h \ |
126 | vcard/include/generated/TextBinValue-generated.h \ | 127 | vcard/include/generated/TextBinValue-generated.h \ |
127 | vcard/include/generated/OrgValue-generated.h \ | 128 | vcard/include/generated/OrgValue-generated.h \ |
128 | vcard/include/generated/UTCValue-generated.h \ | 129 | vcard/include/generated/UTCValue-generated.h \ |
129 | vcard/include/generated/ClassValue-generated.h \ | 130 | vcard/include/generated/ClassValue-generated.h \ |
130 | vcard/include/generated/FloatValue-generated.h \ | 131 | vcard/include/generated/FloatValue-generated.h \ |
131 | vcard/include/generated/TextListValue-generated.h | 132 | vcard/include/generated/TextListValue-generated.h |
132 | 133 | ||
133 | 134 | ||
134 | # plugins/ldap/resourceldap.h \ | 135 | # plugins/ldap/resourceldap.h \ |
135 | # plugins/ldap/resourceldapconfig.h \ | 136 | # plugins/ldap/resourceldapconfig.h \ |
136 | #formats/binary/binaryformat.h \ | 137 | #formats/binary/binaryformat.h \ |
137 | 138 | ||
138 | 139 | ||
139 | SOURCES = \ | 140 | SOURCES = \ |
140 | distributionlist.cpp \ | 141 | distributionlist.cpp \ |
141 | distributionlistdialog.cpp \ | 142 | distributionlistdialog.cpp \ |
142 | distributionlisteditor.cpp \ | 143 | distributionlisteditor.cpp \ |
143 | vcardformatplugin.cpp \ | 144 | vcardformatplugin.cpp \ |
144 | formats/vcardformatplugin2.cpp \ | 145 | formats/vcardformatplugin2.cpp \ |
145 | formatfactory.cpp \ | 146 | formatfactory.cpp \ |
146 | resource.cpp \ | 147 | resource.cpp \ |
147 | stdaddressbook.cpp \ | 148 | stdaddressbook.cpp \ |
148 | plugin.cpp \ | 149 | plugin.cpp \ |
149 | agent.cpp \ | 150 | agent.cpp \ |
150 | geo.cpp \ | 151 | geo.cpp \ |
151 | key.cpp \ | 152 | key.cpp \ |
152 | field.cpp \ | 153 | field.cpp \ |
153 | address.cpp \ | 154 | address.cpp \ |
154 | phonenumber.cpp \ | 155 | phonenumber.cpp \ |
155 | picture.cpp \ | 156 | picture.cpp \ |
156 | secrecy.cpp \ | 157 | secrecy.cpp \ |
157 | sound.cpp \ | 158 | sound.cpp \ |
158 | addressbook.cpp \ | 159 | addressbook.cpp \ |
159 | timezone.cpp \ | 160 | timezone.cpp \ |
161 | tmpaddressbook.cpp \ | ||
160 | addressee.cpp \ | 162 | addressee.cpp \ |
161 | addresseelist.cpp \ | 163 | addresseelist.cpp \ |
162 | addresseedialog.cpp \ | 164 | addresseedialog.cpp \ |
163 | vcardconverter.cpp \ | 165 | vcardconverter.cpp \ |
164 | vcard21parser.cpp \ | 166 | vcard21parser.cpp \ |
165 | vcardformatimpl.cpp \ | 167 | vcardformatimpl.cpp \ |
166 | plugins/file/resourcefile.cpp \ | 168 | plugins/file/resourcefile.cpp \ |
167 | plugins/file/resourcefileconfig.cpp \ | 169 | plugins/file/resourcefileconfig.cpp \ |
168 | plugins/dir/resourcedir.cpp \ | 170 | plugins/dir/resourcedir.cpp \ |
169 | plugins/dir/resourcedirconfig.cpp \ | 171 | plugins/dir/resourcedirconfig.cpp \ |
170 | vcardparser/vcardline.cpp \ | 172 | vcardparser/vcardline.cpp \ |
171 | vcardparser/vcard.cpp \ | 173 | vcardparser/vcard.cpp \ |
172 | vcardparser/vcardtool.cpp \ | 174 | vcardparser/vcardtool.cpp \ |
173 | vcardparser/vcardparser.cpp \ | 175 | vcardparser/vcardparser.cpp \ |
174 | vcard/AdrParam.cpp \ | 176 | vcard/AdrParam.cpp \ |
175 | vcard/AdrValue.cpp \ | 177 | vcard/AdrValue.cpp \ |
176 | vcard/AgentParam.cpp \ | 178 | vcard/AgentParam.cpp \ |
177 | vcard/ContentLine.cpp \ | 179 | vcard/ContentLine.cpp \ |
178 | vcard/DateParam.cpp \ | 180 | vcard/DateParam.cpp \ |
179 | vcard/DateValue.cpp \ | 181 | vcard/DateValue.cpp \ |
180 | vcard/EmailParam.cpp \ | 182 | vcard/EmailParam.cpp \ |
181 | vcard/Entity.cpp \ | 183 | vcard/Entity.cpp \ |
182 | vcard/Enum.cpp \ | 184 | vcard/Enum.cpp \ |
183 | vcard/GeoValue.cpp \ | 185 | vcard/GeoValue.cpp \ |
184 | vcard/ImageParam.cpp \ | 186 | vcard/ImageParam.cpp \ |
185 | vcard/ImageValue.cpp \ | 187 | vcard/ImageValue.cpp \ |
186 | vcard/LangValue.cpp \ | 188 | vcard/LangValue.cpp \ |
187 | vcard/NValue.cpp \ | 189 | vcard/NValue.cpp \ |
188 | vcard/Param.cpp \ | 190 | vcard/Param.cpp \ |
189 | vcard/PhoneNumberValue.cpp \ | 191 | vcard/PhoneNumberValue.cpp \ |
190 | vcard/RToken.cpp \ | 192 | vcard/RToken.cpp \ |
191 | vcard/SourceParam.cpp \ | 193 | vcard/SourceParam.cpp \ |
192 | vcard/TelParam.cpp \ | 194 | vcard/TelParam.cpp \ |
193 | vcard/TextParam.cpp \ | 195 | vcard/TextParam.cpp \ |
194 | vcard/TextValue.cpp \ | 196 | vcard/TextValue.cpp \ |
195 | vcard/TextBinParam.cpp \ | 197 | vcard/TextBinParam.cpp \ |
196 | vcard/URIValue.cpp \ | 198 | vcard/URIValue.cpp \ |
197 | vcard/VCardv.cpp \ | 199 | vcard/VCardv.cpp \ |
198 | vcard/VCardEntity.cpp \ | 200 | vcard/VCardEntity.cpp \ |
199 | vcard/Value.cpp \ | 201 | vcard/Value.cpp \ |
200 | vcard/SoundValue.cpp \ | 202 | vcard/SoundValue.cpp \ |
201 | vcard/AgentValue.cpp \ | 203 | vcard/AgentValue.cpp \ |
202 | vcard/TelValue.cpp \ | 204 | vcard/TelValue.cpp \ |
203 | vcard/TextBinValue.cpp \ | 205 | vcard/TextBinValue.cpp \ |
204 | vcard/OrgValue.cpp \ | 206 | vcard/OrgValue.cpp \ |
205 | vcard/UTCValue.cpp \ | 207 | vcard/UTCValue.cpp \ |
206 | vcard/ClassValue.cpp \ | 208 | vcard/ClassValue.cpp \ |
207 | vcard/FloatValue.cpp \ | 209 | vcard/FloatValue.cpp \ |
diff --git a/kabc/kabcE.pro b/kabc/kabcE.pro index bc1c0ed..598d4fc 100644 --- a/kabc/kabcE.pro +++ b/kabc/kabcE.pro | |||
@@ -1,87 +1,90 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | TARGET = microkabc | 3 | TARGET = microkabc |
4 | 4 | ||
5 | 5 | ||
6 | INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../qtcompat $(QPEDIR)/include | 6 | INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim ../qtcompat $(QPEDIR)/include |
7 | OBJECTS_DIR = obj/$(PLATFORM) | 7 | OBJECTS_DIR = obj/$(PLATFORM) |
8 | MOC_DIR = moc/$(PLATFORM) | 8 | MOC_DIR = moc/$(PLATFORM) |
9 | DESTDIR = $(QPEDIR)/lib | 9 | DESTDIR = $(QPEDIR)/lib |
10 | LIBS += -lmicrokde | 10 | LIBS += -lmicrokde |
11 | LIBS += -lmicrokdepim | ||
11 | #LIBS += -lldap | 12 | #LIBS += -lldap |
12 | LIBS += -L$(QPEDIR)/lib | 13 | LIBS += -L$(QPEDIR)/lib |
13 | DEFINES += KAB_EMBEDDED | 14 | DEFINES += KAB_EMBEDDED |
14 | 15 | ||
15 | INTERFACES = \ | 16 | INTERFACES = \ |
16 | 17 | ||
17 | HEADERS = \ | 18 | HEADERS = \ |
18 | address.h \ | 19 | address.h \ |
19 | addressbook.h \ | 20 | addressbook.h \ |
20 | addressee.h \ | 21 | addressee.h \ |
21 | addresseedialog.h \ | 22 | addresseedialog.h \ |
22 | addresseelist.h \ | 23 | addresseelist.h \ |
23 | agent.h \ | 24 | agent.h \ |
24 | distributionlist.h \ | 25 | distributionlist.h \ |
25 | distributionlistdialog.h \ | 26 | distributionlistdialog.h \ |
26 | distributionlisteditor.h \ | 27 | distributionlisteditor.h \ |
27 | field.h \ | 28 | field.h \ |
28 | formatfactory.h \ | 29 | formatfactory.h \ |
29 | formatplugin.h \ | 30 | formatplugin.h \ |
30 | geo.h \ | 31 | geo.h \ |
31 | key.h \ | 32 | key.h \ |
32 | phonenumber.h \ | 33 | phonenumber.h \ |
33 | picture.h \ | 34 | picture.h \ |
34 | plugin.h \ | 35 | plugin.h \ |
35 | resource.h \ | 36 | resource.h \ |
36 | secrecy.h \ | 37 | secrecy.h \ |
37 | sound.h \ | 38 | sound.h \ |
38 | stdaddressbook.h \ | 39 | stdaddressbook.h \ |
40 | syncprefwidget.h \ | ||
39 | timezone.h \ | 41 | timezone.h \ |
42 | tmpaddressbook.h \ | ||
40 | vcardconverter.h \ | 43 | vcardconverter.h \ |
41 | vcard21parser.h \ | 44 | vcard21parser.h \ |
42 | vcardformatimpl.h \ | 45 | vcardformatimpl.h \ |
43 | vcardformatplugin.h \ | 46 | vcardformatplugin.h \ |
44 | vcardparser/vcardline.h \ | 47 | vcardparser/vcardline.h \ |
45 | vcardparser/vcard.h \ | 48 | vcardparser/vcard.h \ |
46 | vcardparser/vcardtool.h \ | 49 | vcardparser/vcardtool.h \ |
47 | vcardparser/vcardparser.h \ | 50 | vcardparser/vcardparser.h \ |
48 | vcard/include/VCardAdrParam.h \ | 51 | vcard/include/VCardAdrParam.h \ |
49 | vcard/include/VCardAdrValue.h \ | 52 | vcard/include/VCardAdrValue.h \ |
50 | vcard/include/VCardAgentParam.h \ | 53 | vcard/include/VCardAgentParam.h \ |
51 | vcard/include/VCardContentLine.h \ | 54 | vcard/include/VCardContentLine.h \ |
52 | vcard/include/VCardDateParam.h \ | 55 | vcard/include/VCardDateParam.h \ |
53 | vcard/include/VCardDateValue.h \ | 56 | vcard/include/VCardDateValue.h \ |
54 | vcard/include/VCardEmailParam.h \ | 57 | vcard/include/VCardEmailParam.h \ |
55 | vcard/include/VCardGeoValue.h \ | 58 | vcard/include/VCardGeoValue.h \ |
56 | vcard/include/VCardGroup.h \ | 59 | vcard/include/VCardGroup.h \ |
57 | vcard/include/VCardImageParam.h \ | 60 | vcard/include/VCardImageParam.h \ |
58 | vcard/include/VCardImageValue.h \ | 61 | vcard/include/VCardImageValue.h \ |
59 | vcard/include/VCardLangValue.h \ | 62 | vcard/include/VCardLangValue.h \ |
60 | vcard/include/VCardNValue.h \ | 63 | vcard/include/VCardNValue.h \ |
61 | vcard/include/VCardParam.h \ | 64 | vcard/include/VCardParam.h \ |
62 | vcard/include/VCardPhoneNumberValue.h \ | 65 | vcard/include/VCardPhoneNumberValue.h \ |
63 | vcard/include/VCardSourceParam.h \ | 66 | vcard/include/VCardSourceParam.h \ |
64 | vcard/include/VCardTelParam.h \ | 67 | vcard/include/VCardTelParam.h \ |
65 | vcard/include/VCardTextParam.h \ | 68 | vcard/include/VCardTextParam.h \ |
66 | vcard/include/VCardTextNSParam.h \ | 69 | vcard/include/VCardTextNSParam.h \ |
67 | vcard/include/VCardTextValue.h \ | 70 | vcard/include/VCardTextValue.h \ |
68 | vcard/include/VCardTextBinParam.h \ | 71 | vcard/include/VCardTextBinParam.h \ |
69 | vcard/include/VCardURIValue.h \ | 72 | vcard/include/VCardURIValue.h \ |
70 | vcard/include/VCardVCard.h \ | 73 | vcard/include/VCardVCard.h \ |
71 | vcard/include/VCardEntity.h \ | 74 | vcard/include/VCardEntity.h \ |
72 | vcard/include/VCardValue.h \ | 75 | vcard/include/VCardValue.h \ |
73 | vcard/include/VCardSoundValue.h \ | 76 | vcard/include/VCardSoundValue.h \ |
74 | vcard/include/VCardAgentValue.h \ | 77 | vcard/include/VCardAgentValue.h \ |
75 | vcard/include/VCardTelValue.h \ | 78 | vcard/include/VCardTelValue.h \ |
76 | vcard/include/VCardTextBinValue.h \ | 79 | vcard/include/VCardTextBinValue.h \ |
77 | vcard/include/VCardOrgValue.h \ | 80 | vcard/include/VCardOrgValue.h \ |
78 | vcard/include/VCardUTCValue.h \ | 81 | vcard/include/VCardUTCValue.h \ |
79 | vcard/include/VCardClassValue.h \ | 82 | vcard/include/VCardClassValue.h \ |
80 | vcard/include/VCardFloatValue.h \ | 83 | vcard/include/VCardFloatValue.h \ |
81 | vcard/include/VCardTextListValue.h \ | 84 | vcard/include/VCardTextListValue.h \ |
82 | vcard/include/generated/AdrParam-generated.h \ | 85 | vcard/include/generated/AdrParam-generated.h \ |
83 | vcard/include/generated/AdrValue-generated.h \ | 86 | vcard/include/generated/AdrValue-generated.h \ |
84 | vcard/include/generated/AgentParam-generated.h \ | 87 | vcard/include/generated/AgentParam-generated.h \ |
85 | vcard/include/generated/ContentLine-generated.h \ | 88 | vcard/include/generated/ContentLine-generated.h \ |
86 | vcard/include/generated/DateParam-generated.h \ | 89 | vcard/include/generated/DateParam-generated.h \ |
87 | vcard/include/generated/DateValue-generated.h \ | 90 | vcard/include/generated/DateValue-generated.h \ |
@@ -93,96 +96,98 @@ HEADERS = \ | |||
93 | vcard/include/generated/LangValue-generated.h \ | 96 | vcard/include/generated/LangValue-generated.h \ |
94 | vcard/include/generated/NValue-generated.h \ | 97 | vcard/include/generated/NValue-generated.h \ |
95 | vcard/include/generated/Param-generated.h \ | 98 | vcard/include/generated/Param-generated.h \ |
96 | vcard/include/generated/PhoneNumberValue-generated.h \ | 99 | vcard/include/generated/PhoneNumberValue-generated.h \ |
97 | vcard/include/generated/SourceParam-generated.h \ | 100 | vcard/include/generated/SourceParam-generated.h \ |
98 | vcard/include/generated/TelParam-generated.h \ | 101 | vcard/include/generated/TelParam-generated.h \ |
99 | vcard/include/generated/TextParam-generated.h \ | 102 | vcard/include/generated/TextParam-generated.h \ |
100 | vcard/include/generated/TextNSParam-generated.h \ | 103 | vcard/include/generated/TextNSParam-generated.h \ |
101 | vcard/include/generated/TextValue-generated.h \ | 104 | vcard/include/generated/TextValue-generated.h \ |
102 | vcard/include/generated/TextBinParam-generated.h \ | 105 | vcard/include/generated/TextBinParam-generated.h \ |
103 | vcard/include/generated/URIValue-generated.h \ | 106 | vcard/include/generated/URIValue-generated.h \ |
104 | vcard/include/generated/VCard-generated.h \ | 107 | vcard/include/generated/VCard-generated.h \ |
105 | vcard/include/generated/VCardEntity-generated.h \ | 108 | vcard/include/generated/VCardEntity-generated.h \ |
106 | vcard/include/generated/Value-generated.h \ | 109 | vcard/include/generated/Value-generated.h \ |
107 | vcard/include/generated/SoundValue-generated.h \ | 110 | vcard/include/generated/SoundValue-generated.h \ |
108 | vcard/include/generated/AgentValue-generated.h \ | 111 | vcard/include/generated/AgentValue-generated.h \ |
109 | vcard/include/generated/TelValue-generated.h \ | 112 | vcard/include/generated/TelValue-generated.h \ |
110 | vcard/include/generated/TextBinValue-generated.h \ | 113 | vcard/include/generated/TextBinValue-generated.h \ |
111 | vcard/include/generated/OrgValue-generated.h \ | 114 | vcard/include/generated/OrgValue-generated.h \ |
112 | vcard/include/generated/UTCValue-generated.h \ | 115 | vcard/include/generated/UTCValue-generated.h \ |
113 | vcard/include/generated/ClassValue-generated.h \ | 116 | vcard/include/generated/ClassValue-generated.h \ |
114 | vcard/include/generated/FloatValue-generated.h \ | 117 | vcard/include/generated/FloatValue-generated.h \ |
115 | vcard/include/generated/TextListValue-generated.h | 118 | vcard/include/generated/TextListValue-generated.h |
116 | 119 | ||
117 | 120 | ||
118 | 121 | ||
119 | 122 | ||
120 | SOURCES = \ | 123 | SOURCES = \ |
121 | address.cpp \ | 124 | address.cpp \ |
122 | addressbook.cpp \ | 125 | addressbook.cpp \ |
123 | addressee.cpp \ | 126 | addressee.cpp \ |
124 | addresseedialog.cpp \ | 127 | addresseedialog.cpp \ |
125 | addresseelist.cpp \ | 128 | addresseelist.cpp \ |
126 | agent.cpp \ | 129 | agent.cpp \ |
127 | distributionlist.cpp \ | 130 | distributionlist.cpp \ |
128 | distributionlistdialog.cpp \ | 131 | distributionlistdialog.cpp \ |
129 | distributionlisteditor.cpp \ | 132 | distributionlisteditor.cpp \ |
130 | field.cpp \ | 133 | field.cpp \ |
131 | formatfactory.cpp \ | 134 | formatfactory.cpp \ |
132 | geo.cpp \ | 135 | geo.cpp \ |
133 | key.cpp \ | 136 | key.cpp \ |
134 | phonenumber.cpp \ | 137 | phonenumber.cpp \ |
135 | picture.cpp \ | 138 | picture.cpp \ |
136 | plugin.cpp \ | 139 | plugin.cpp \ |
137 | resource.cpp \ | 140 | resource.cpp \ |
138 | secrecy.cpp \ | 141 | secrecy.cpp \ |
139 | sound.cpp \ | 142 | sound.cpp \ |
140 | stdaddressbook.cpp \ | 143 | stdaddressbook.cpp \ |
144 | syncprefwidget.cpp \ | ||
141 | timezone.cpp \ | 145 | timezone.cpp \ |
146 | tmpaddressbook.cpp \ | ||
142 | vcardconverter.cpp \ | 147 | vcardconverter.cpp \ |
143 | vcard21parser.cpp \ | 148 | vcard21parser.cpp \ |
144 | vcardformatimpl.cpp \ | 149 | vcardformatimpl.cpp \ |
145 | vcardformatplugin.cpp \ | 150 | vcardformatplugin.cpp \ |
146 | vcardparser/vcardline.cpp \ | 151 | vcardparser/vcardline.cpp \ |
147 | vcardparser/vcard.cpp \ | 152 | vcardparser/vcard.cpp \ |
148 | vcardparser/vcardtool.cpp \ | 153 | vcardparser/vcardtool.cpp \ |
149 | vcardparser/vcardparser.cpp \ | 154 | vcardparser/vcardparser.cpp \ |
150 | vcard/AdrParam.cpp \ | 155 | vcard/AdrParam.cpp \ |
151 | vcard/AdrValue.cpp \ | 156 | vcard/AdrValue.cpp \ |
152 | vcard/AgentParam.cpp \ | 157 | vcard/AgentParam.cpp \ |
153 | vcard/ContentLine.cpp \ | 158 | vcard/ContentLine.cpp \ |
154 | vcard/DateParam.cpp \ | 159 | vcard/DateParam.cpp \ |
155 | vcard/DateValue.cpp \ | 160 | vcard/DateValue.cpp \ |
156 | vcard/EmailParam.cpp \ | 161 | vcard/EmailParam.cpp \ |
157 | vcard/Entity.cpp \ | 162 | vcard/Entity.cpp \ |
158 | vcard/Enum.cpp \ | 163 | vcard/Enum.cpp \ |
159 | vcard/GeoValue.cpp \ | 164 | vcard/GeoValue.cpp \ |
160 | vcard/ImageParam.cpp \ | 165 | vcard/ImageParam.cpp \ |
161 | vcard/ImageValue.cpp \ | 166 | vcard/ImageValue.cpp \ |
162 | vcard/LangValue.cpp \ | 167 | vcard/LangValue.cpp \ |
163 | vcard/NValue.cpp \ | 168 | vcard/NValue.cpp \ |
164 | vcard/Param.cpp \ | 169 | vcard/Param.cpp \ |
165 | vcard/PhoneNumberValue.cpp \ | 170 | vcard/PhoneNumberValue.cpp \ |
166 | vcard/RToken.cpp \ | 171 | vcard/RToken.cpp \ |
167 | vcard/SourceParam.cpp \ | 172 | vcard/SourceParam.cpp \ |
168 | vcard/TelParam.cpp \ | 173 | vcard/TelParam.cpp \ |
169 | vcard/TextParam.cpp \ | 174 | vcard/TextParam.cpp \ |
170 | vcard/TextValue.cpp \ | 175 | vcard/TextValue.cpp \ |
171 | vcard/TextBinParam.cpp \ | 176 | vcard/TextBinParam.cpp \ |
172 | vcard/URIValue.cpp \ | 177 | vcard/URIValue.cpp \ |
173 | vcard/VCardv.cpp \ | 178 | vcard/VCardv.cpp \ |
174 | vcard/VCardEntity.cpp \ | 179 | vcard/VCardEntity.cpp \ |
175 | vcard/Value.cpp \ | 180 | vcard/Value.cpp \ |
176 | vcard/SoundValue.cpp \ | 181 | vcard/SoundValue.cpp \ |
177 | vcard/AgentValue.cpp \ | 182 | vcard/AgentValue.cpp \ |
178 | vcard/TelValue.cpp \ | 183 | vcard/TelValue.cpp \ |
179 | vcard/TextBinValue.cpp \ | 184 | vcard/TextBinValue.cpp \ |
180 | vcard/OrgValue.cpp \ | 185 | vcard/OrgValue.cpp \ |
181 | vcard/UTCValue.cpp \ | 186 | vcard/UTCValue.cpp \ |
182 | vcard/ClassValue.cpp \ | 187 | vcard/ClassValue.cpp \ |
183 | vcard/FloatValue.cpp \ | 188 | vcard/FloatValue.cpp \ |
184 | vcard/TextListValue.cpp | 189 | vcard/TextListValue.cpp |
185 | 190 | ||
186 | 191 | ||
187 | # plugins/ldap/resourceldap.cpp \ | 192 | # plugins/ldap/resourceldap.cpp \ |
188 | # plugins/ldap/resourceldapconfig.cpp \ | 193 | # plugins/ldap/resourceldapconfig.cpp \ |
diff --git a/kabc/resource.cpp b/kabc/resource.cpp index 9a1a5f8..9632a3f 100644 --- a/kabc/resource.cpp +++ b/kabc/resource.cpp | |||
@@ -1,95 +1,154 @@ | |||
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 | #include <kdebug.h> | 28 | #include <kdebug.h> |
29 | 29 | ||
30 | #include <ksyncprofile.h> | ||
31 | |||
30 | #include "resource.h" | 32 | #include "resource.h" |
31 | 33 | ||
32 | using namespace KABC; | 34 | using namespace KABC; |
33 | 35 | ||
34 | Resource::Resource( const KConfig *config ) | 36 | Resource::Resource( const KConfig *config, bool syncable ) |
35 | : KRES::Resource( config ), mAddressBook( 0 ) | 37 | : KRES::Resource( config ), mAddressBook( 0 ), mSyncProfile( 0 ) |
36 | { | 38 | { |
39 | if(syncable == true) { | ||
40 | mSyncProfile = new KSyncProfile( identifier() ); | ||
41 | mSyncProfile->setName(resourceName()); | ||
42 | mSyncProfile->readConfig( (KConfig *)config ); | ||
43 | } | ||
37 | } | 44 | } |
38 | 45 | ||
39 | Resource::~Resource() | 46 | Resource::~Resource() |
40 | { | 47 | { |
48 | if (mSyncProfile != 0) { | ||
49 | delete mSyncProfile; | ||
50 | } | ||
41 | } | 51 | } |
42 | 52 | ||
43 | void Resource::writeConfig( KConfig *config ) | 53 | void Resource::writeConfig( KConfig *config ) |
44 | { | 54 | { |
45 | KRES::Resource::writeConfig( config ); | 55 | KRES::Resource::writeConfig( config ); |
56 | |||
57 | if(mSyncProfile != 0) | ||
58 | mSyncProfile->writeConfig( config ); | ||
46 | } | 59 | } |
47 | 60 | ||
61 | |||
48 | void Resource::setAddressBook( AddressBook *ab ) | 62 | void Resource::setAddressBook( AddressBook *ab ) |
49 | { | 63 | { |
50 | mAddressBook = ab; | 64 | mAddressBook = ab; |
51 | } | 65 | } |
52 | 66 | ||
53 | AddressBook *Resource::addressBook() | 67 | AddressBook *Resource::addressBook() |
54 | { | 68 | { |
55 | return mAddressBook; | 69 | return mAddressBook; |
56 | } | 70 | } |
57 | 71 | ||
58 | bool Resource::doOpen() | 72 | bool Resource::doOpen() |
59 | { | 73 | { |
60 | return true; | 74 | return true; |
61 | } | 75 | } |
62 | 76 | ||
63 | void Resource::doClose() | 77 | void Resource::doClose() |
64 | { | 78 | { |
65 | } | 79 | } |
66 | 80 | ||
67 | Ticket *Resource::requestSaveTicket() | 81 | Ticket *Resource::requestSaveTicket() |
68 | { | 82 | { |
69 | return 0; | 83 | return 0; |
70 | } | 84 | } |
71 | 85 | ||
72 | bool Resource::load() | 86 | bool Resource::load() |
73 | { | 87 | { |
74 | return true; | 88 | return true; |
75 | } | 89 | } |
76 | 90 | ||
77 | bool Resource::save( Ticket * ) | 91 | bool Resource::save( Ticket * ) |
78 | { | 92 | { |
79 | return false; | 93 | return false; |
80 | } | 94 | } |
81 | 95 | ||
82 | Ticket *Resource::createTicket( Resource *resource ) | 96 | Ticket *Resource::createTicket( Resource *resource ) |
83 | { | 97 | { |
84 | return new Ticket( resource ); | 98 | return new Ticket( resource ); |
85 | } | 99 | } |
86 | 100 | ||
87 | void Resource::removeAddressee( const Addressee& ) | 101 | void Resource::removeAddressee( const Addressee& ) |
88 | { | 102 | { |
89 | // do nothing | 103 | // do nothing |
90 | } | 104 | } |
91 | 105 | ||
92 | void Resource::cleanUp() | 106 | void Resource::cleanUp() |
93 | { | 107 | { |
94 | // do nothing | 108 | // do nothing |
95 | } | 109 | } |
110 | |||
111 | bool Resource::isSyncable() const | ||
112 | { | ||
113 | return (mSyncProfile != 0); | ||
114 | } | ||
115 | |||
116 | /** | ||
117 | * This method returns the number of elements that are currently in the resource. | ||
118 | */ | ||
119 | int Resource::count() const | ||
120 | { | ||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * This method removes all elements from the resource!! (Not from the addressbook) | ||
126 | */ | ||
127 | bool Resource::clear() | ||
128 | { | ||
129 | return false; | ||
130 | } | ||
131 | |||
132 | QString Resource::fileName() const | ||
133 | { | ||
134 | return mFileName; | ||
135 | } | ||
136 | |||
137 | void Resource::setFileName( const QString &fileName ) | ||
138 | { | ||
139 | mFileName = fileName; | ||
140 | } | ||
141 | |||
142 | /** | ||
143 | * Set the name of resource.You can override this method, | ||
144 | * but also remember to call Resource::setResourceName(). | ||
145 | */ | ||
146 | void Resource::setResourceName( const QString &name ) | ||
147 | { | ||
148 | KRES::Resource::setResourceName(name); | ||
149 | if(mSyncProfile != 0) { | ||
150 | mSyncProfile->setName( name ); | ||
151 | } | ||
152 | |||
153 | } | ||
154 | |||
diff --git a/kabc/resource.h b/kabc/resource.h index c363125..db806a6 100644 --- a/kabc/resource.h +++ b/kabc/resource.h | |||
@@ -1,134 +1,180 @@ | |||
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_RESOURCE_H | 28 | #ifndef KABC_RESOURCE_H |
29 | #define KABC_RESOURCE_H | 29 | #define KABC_RESOURCE_H |
30 | 30 | ||
31 | #include <kresources/resource.h> | 31 | #include <kresources/resource.h> |
32 | 32 | ||
33 | |||
33 | #include "addressbook.h" | 34 | #include "addressbook.h" |
34 | 35 | ||
36 | class KSyncProfile; | ||
37 | |||
35 | namespace KABC { | 38 | namespace KABC { |
36 | 39 | ||
37 | /** | 40 | /** |
38 | * @short Helper class for handling coordinated save of address books. | 41 | * @short Helper class for handling coordinated save of address books. |
39 | * | 42 | * |
40 | * This class is used as helper class for saving address book. | 43 | * This class is used as helper class for saving address book. |
41 | * @see requestSaveTicket(), save(). | 44 | * @see requestSaveTicket(), save(). |
42 | */ | 45 | */ |
43 | class Ticket | 46 | class Ticket |
44 | { | 47 | { |
45 | friend class Resource; | 48 | friend class Resource; |
46 | public: | 49 | public: |
47 | Resource *resource() { return mResource; } | 50 | Resource *resource() { return mResource; } |
48 | 51 | ||
49 | private: | 52 | private: |
50 | Ticket( Resource *resource ) : mResource( resource ) {} | 53 | Ticket( Resource *resource ) : mResource( resource ) {} |
51 | 54 | ||
52 | Resource *mResource; | 55 | Resource *mResource; |
53 | }; | 56 | }; |
54 | 57 | ||
55 | /** | 58 | /** |
56 | * @internal | 59 | * @internal |
57 | */ | 60 | */ |
58 | class Resource : public KRES::Resource | 61 | class Resource : public KRES::Resource |
59 | { | 62 | { |
63 | private: | ||
64 | /** | ||
65 | * make this constructor private to force everybody to use the other one | ||
66 | */ | ||
67 | Resource( const KConfig *config); | ||
68 | |||
60 | public: | 69 | public: |
61 | /** | 70 | /** |
62 | * Constructor | 71 | * Constructor |
63 | */ | 72 | */ |
64 | Resource( const KConfig *config ); | 73 | Resource( const KConfig *config, bool syncable ); |
65 | 74 | ||
66 | /** | 75 | /** |
67 | * Destructor. | 76 | * Destructor. |
68 | */ | 77 | */ |
69 | virtual ~Resource(); | 78 | virtual ~Resource(); |
70 | 79 | ||
71 | /** | 80 | /** |
72 | * Sets the address book of the resource. | 81 | * Sets the address book of the resource. |
73 | */ | 82 | */ |
74 | void setAddressBook( AddressBook* ); | 83 | void setAddressBook( AddressBook* ); |
75 | 84 | ||
76 | /** | 85 | /** |
77 | * Returns a pointer to the addressbook. | 86 | * Returns a pointer to the addressbook. |
78 | */ | 87 | */ |
79 | AddressBook *addressBook(); | 88 | AddressBook *addressBook(); |
80 | 89 | ||
81 | /** | 90 | /** |
82 | * Writes the resource specific config to file. | 91 | * Writes the resource specific config to file. |
83 | */ | 92 | */ |
84 | virtual void writeConfig( KConfig *config ); | 93 | virtual void writeConfig( KConfig *config ); |
85 | 94 | ||
86 | /** | 95 | /** |
87 | * Open the resource and returns if it was successfully | 96 | * Open the resource and returns if it was successfully |
88 | */ | 97 | */ |
89 | virtual bool doOpen(); | 98 | virtual bool doOpen(); |
90 | 99 | ||
91 | /** | 100 | |
92 | * Close the resource and returns if it was successfully | ||
93 | */ | ||
94 | virtual void doClose(); | ||
95 | |||
96 | /** | 101 | /** |
97 | * Request a ticket, you have to pass through @ref save() to | 102 | * Request a ticket, you have to pass through @ref save() to |
98 | * allow locking. | 103 | * allow locking. |
99 | */ | 104 | */ |
100 | virtual Ticket *requestSaveTicket(); | 105 | virtual Ticket *requestSaveTicket(); |
101 | 106 | ||
102 | /** | 107 | /** |
103 | * Load all addressees to the addressbook | 108 | * Load all addressees to the addressbook |
104 | */ | 109 | */ |
105 | virtual bool load(); | 110 | virtual bool load(); |
106 | 111 | ||
107 | /** | 112 | /** |
108 | * Save all addressees to the addressbook. | 113 | * Save all addressees to the addressbook. |
109 | * | 114 | * |
110 | * @param ticket The ticket you get by @ref requestSaveTicket() | 115 | * @param ticket The ticket you get by @ref requestSaveTicket() |
111 | */ | 116 | */ |
112 | virtual bool save( Ticket *ticket ); | 117 | virtual bool save( Ticket *ticket ); |
113 | 118 | ||
114 | /** | 119 | /** |
115 | * Removes a addressee from resource. This method is mainly | 120 | * Removes a addressee from resource. This method is mainly |
116 | * used by record-based resources like LDAP or SQL. | 121 | * used by record-based resources like LDAP or SQL. |
117 | */ | 122 | */ |
118 | virtual void removeAddressee( const Addressee& addr ); | 123 | virtual void removeAddressee( const Addressee& addr ); |
119 | 124 | ||
125 | |||
120 | /** | 126 | /** |
121 | * This method is called by an error handler if the application | 127 | * This method is called by an error handler if the application |
122 | * crashed | 128 | * crashed |
123 | */ | 129 | */ |
124 | virtual void cleanUp(); | 130 | virtual void cleanUp(); |
125 | 131 | ||
132 | |||
133 | /** | ||
134 | * This method returns the number of elements that are currently in the resource. | ||
135 | */ | ||
136 | virtual int count() const; | ||
137 | |||
138 | /** | ||
139 | * This method removes all elements from the resource!! (Not from the addressbook) | ||
140 | */ | ||
141 | virtual bool clear(); | ||
142 | |||
143 | /** | ||
144 | * Set name of file to be used for saving. | ||
145 | */ | ||
146 | virtual void setFileName( const QString & ); | ||
147 | |||
148 | /** | ||
149 | * Return name of file used for loading and saving the address book. | ||
150 | */ | ||
151 | virtual QString fileName() const; | ||
152 | |||
153 | |||
154 | virtual bool isSyncable() const; | ||
155 | |||
156 | /** | ||
157 | * Set the name of resource.You can override this method, | ||
158 | * but also remember to call Resource::setResourceName(). | ||
159 | */ | ||
160 | virtual void setResourceName( const QString &name ); | ||
161 | |||
162 | |||
163 | |||
126 | protected: | 164 | protected: |
127 | Ticket *createTicket( Resource * ); | 165 | Ticket *createTicket( Resource * ); |
166 | virtual void doClose(); | ||
128 | 167 | ||
129 | private: | 168 | private: |
130 | AddressBook *mAddressBook; | 169 | AddressBook *mAddressBook; |
170 | KSyncProfile *mSyncProfile; | ||
171 | QString mFileName; | ||
172 | |||
131 | }; | 173 | }; |
132 | 174 | ||
175 | |||
133 | } | 176 | } |
177 | |||
178 | |||
179 | |||
134 | #endif | 180 | #endif |