/usr/include/kabc/addressbook.h is in kdepimlibs5-dev 4:4.8.5-0ubuntu0.3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 | /*
This file is part of libkabc.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KABC_ADDRESSBOOK_H
#define KABC_ADDRESSBOOK_H
#include "kabc_export.h"
#include "addressee.h"
#include "field.h"
#include "kresources/manager.h"
#include <QtCore/QObject>
#include <QtCore/QList>
namespace KABC {
class DistributionList;
class ErrorHandler;
class Resource;
class Ticket;
/**
@short Address Book
This class provides access to a collection of address book entries.
*/
class KABC_EXPORT_DEPRECATED AddressBook : public QObject
{
Q_OBJECT
friend KABC_EXPORT QDataStream &operator<<( QDataStream &lhs,
const AddressBook &rhs );
friend KABC_EXPORT QDataStream &operator>>( QDataStream &lhs,
AddressBook &rhs );
friend class StdAddressBook;
public:
class ConstIterator;
/**
@short Address Book Iterator
This class provides an iterator for address book entries.
*/
class KABC_EXPORT_DEPRECATED Iterator //krazy:exclude=dpointer
{
friend class AddressBook;
friend class ConstIterator;
public:
/**
Default constructor
*/
Iterator();
/**
Copy constructor
*/
Iterator( const Iterator & );
~Iterator();
/**
Assignment operator. Assignes the given iterator to @c *this.
@return this iterator, @c *this
*/
Iterator &operator=( const Iterator & );
/**
Constant Dereference operator.
@note For invalid iterators, the result is undefined.
@return the @c const Addressee object the iterator points to.
*/
const Addressee &operator*() const;
/**
Dereference operator.
@note For invalid iterators, the result is undefined.
@return the Addressee object the iterator points to.
*/
Addressee &operator*();
/**
Arrow Dereference operator, provided for convenience.
@note For invalid iterators, the result is undefined.
@return the Addressee object the iterator points to.
*/
Addressee *operator->();
/**
Preincrement operator. Advances the iterator by one.
@return this iterator, @c *this
*/
Iterator &operator++();
/**
Postincrement operator. Advances the iterator by one.
@note This function does not copy the iterator object.
@return this iterator, @c *this
*/
Iterator &operator++(int);
/**
Predecrement operator. Decreases the iterator by one.
@return this iterator, @c *this
*/
Iterator &operator--();
/**
Postdecrement operator. Decreases the iterator by one.
@note This function does not copy the iterator object.
@return this iterator, @c *this
*/
Iterator &operator--(int);
/**
Equality operator. Compares this iterator to @p it
@param it the iterator to compare this iterator to
@return @c true if both iterators are equal,
@c false otherwise
*/
bool operator==( const Iterator &it ) const;
/**
Inequality operator. Compares this iterator to @p it
@param it the iterator to compare this iterator to
@return @c true if the iterators are not equal,
@c false otherwise
*/
bool operator!=( const Iterator &it ) const;
private:
struct IteratorData;
IteratorData *const d;
};
/**
@short Address Book Const Iterator
This class provides a const iterator for address book entries.
*/
class KABC_EXPORT_DEPRECATED ConstIterator //krazy:exclude=dpointer
{
friend class AddressBook;
public:
/**
* Default constructor
*/
ConstIterator();
/**
Copy constructor
*/
ConstIterator( const ConstIterator & );
#ifndef QT_STRICT_ITERATORS
/**
Copy constructor. Constructs a ConstIterator from
an non-@c const Iterator
*/
ConstIterator( const Iterator & );
#endif
~ConstIterator();
/**
Assignment operator. Assignes the given iterator to @c *this.
@return this iterator, @c *this
*/
ConstIterator &operator=( const ConstIterator & );
/**
Constant Dereference operator.
@note For invalid iterators, the result is undefined.
@note Unlike in Iterator, there is no non-constant
dereference operator.
@return the @c const Addressee object the iterator points to.
*/
const Addressee &operator*() const;
/**
Arrow Dereference operator, provided for convenience.
@note For invalid iterators, the result is undefined.
@return the Addressee object the iterator points to.
*/
const Addressee *operator->() const;
/**
Preincrement operator. Advances the iterator by one.
@return this iterator, @c *this
*/
ConstIterator &operator++();
/**
Postincrement operator. Advances the iterator by one.
@note This function does not copy the iterator object.
@return this iterator, @c *this
*/
ConstIterator &operator++(int);
/**
Predecrement operator. Decreases the iterator by one.
@return this iterator, @c *this
*/
ConstIterator &operator--();
/**
Postdecrement operator. Decreases the iterator by one.
@note This function does not copy the iterator object.
@return this iterator, @c *this
*/
ConstIterator &operator--(int);
/**
Equality operator. Compares this iterator to @p it
@param it the iterator to compare this iterator to
@return @c true if both iterators are equal,
@c false otherwise
*/
bool operator==( const ConstIterator &it ) const;
/**
Inequality operator. Compares this iterator to @p it
@param it the iterator to compare this iterator to
@return @c true if the iterators are not equal,
@c false otherwise
*/
bool operator!=( const ConstIterator &it ) const;
private:
struct ConstIteratorData;
ConstIteratorData *const d;
};
/**
Typedef for STL style iterator
*/
typedef Iterator iterator;
/**
Typedef for STL style iterator
*/
typedef ConstIterator const_iterator;
/**
Constructs an address book object.
You have to add the resources manually before calling load().
*/
AddressBook();
/**
Constructs an address book object.
The resources are loaded automatically.
@param config The config file which contains the resource settings.
*/
AddressBook( const QString &config );
/**
Destructor.
*/
virtual ~AddressBook();
/**
Requests a ticket for saving the addressbook. Calling this function locks
the addressbook for all other processes. You need the returned ticket
object for calling the save() function.
@param resource A pointer to the resource which shall be locked. If 0,
the default resource is locked.
@return 0 if the resource is already locked or a valid save ticket
otherwise.
@see save()
*/
Ticket *requestSaveTicket( Resource *resource = 0 );
/**
Releases the ticket requested previously with requestSaveTicket().
Call this function, if you want to release a ticket without saving.
@param ticket the save ticket acquired with requestSaveTicket()
*/
void releaseSaveTicket( Ticket *ticket );
/**
Loads all addressees synchronously.
@return Whether the loading was successfully.
*/
bool load();
/**
Loads all addressees asynchronously. This function returns immediately
and emits the addressBookChanged() signal as soon as the loading has
finished.
@return Whether the synchronous part of loading was successfully.
*/
bool asyncLoad();
/**
Saves all addressees of one resource synchronously. If the save is
successful the ticket is deleted.
@param ticket The ticket returned by requestSaveTicket().
@return Whether the saving was successfully.
*/
bool save( Ticket *ticket );
/**
Saves all addressees of one resource asynchronously. If the save is
successful the ticket is deleted.
@param ticket The ticket returned by requestSaveTicket().
@return Whether the synchronous part of saving was successfully.
*/
bool asyncSave( Ticket *ticket );
/**
Returns an iterator pointing to the first addressee of address book.
This iterator equals end() if the address book is empty.
*/
ConstIterator begin() const;
ConstIterator constBegin() const { return begin(); }
/**
This is an overloaded member function, provided for convenience. It
behaves essentially like the above function.
*/
Iterator begin();
/**
Returns an iterator pointing to the last addressee of address book.
This iterator equals begin() if the address book is empty.
*/
ConstIterator end() const;
ConstIterator constEnd() const { return end(); }
/**
This is an overloaded member function, provided for convenience. It
behaves essentially like the above function.
*/
Iterator end();
/**
Removes all addressees from the address book.
*/
void clear();
/**
Insert an addressee into the address book. If an addressee with the same
unique id already exists, it is replaced by the new one, otherwise it is
appended.
@param addr The addressee which shall be insert.
*/
void insertAddressee( const Addressee &addr );
/**
Removes an addressee from the address book.
@param addr The addressee which shall be removed.
*/
void removeAddressee( const Addressee &addr );
/**
This is an overloaded member function, provided for convenience. It
behaves essentially like the above function.
@param it An iterator pointing to the addressee which shall be removed.
*/
void removeAddressee( const Iterator &it );
/**
Returns an iterator pointing to the specified addressee. It will return
end() if no addressee matched.
@param addr The addressee you are looking for.
*/
Iterator find( const Addressee &addr );
/**
Returns an iterator pointing to the specified addressee. It will return
end() if no addressee matched.
@param addr The addressee you are looking for.
*/
ConstIterator find( const Addressee &addr ) const;
/**
Searches an addressee with the specified unique identifier.
@param uid The unique identifier you are looking for.
@return The addressee with the specified unique identifier or an
empty addressee.
*/
Addressee findByUid( const QString &uid ) const;
/**
Returns a list of all addressees in the address book.
*/
Addressee::List allAddressees() const;
/**
Searches all addressees which match the specified name.
@param name The name you are looking for.
@return A list of all matching addressees.
*/
Addressee::List findByName( const QString &name ) const;
/**
Searches all addressees which match the specified email address.
@param email The email address you are looking for.
@return A list of all matching addressees.
*/
Addressee::List findByEmail( const QString &email ) const;
/**
Searches all addressees which belongs to the specified category.
@param category The category you are looking for.
@return A list of all matching addressees.
*/
Addressee::List findByCategory( const QString &category ) const;
/**
Creates a distribution list with a given @p name storing it in a
given @p resource
@note The newly created list will be added to the addressbook
automatically on creation.
@param name The localized name of the new distribution list.
@param resource The resource which should save the list. If @c 0
(default) the addressbook's standard resource will be used.
@see standardResource()
*/
DistributionList *createDistributionList( const QString &name, Resource *resource = 0 );
/**
Removes a distribution @p list from its associated resource.
@param list The list to remove.
*/
void removeDistributionList( DistributionList *list );
/**
Returns a distribution list for the given @p identifier or @c 0
@param identifier The ID of the list for look for.
*/
DistributionList *findDistributionListByIdentifier( const QString &identifier );
/**
Returns a distribution list with the given @p name or @c 0
@param name The localized name of the list for look for.
@param caseSensitivity Whether to do string matching case sensitive or
case insensitive. Default is @c Qt::CaseSensitive
*/
DistributionList *findDistributionListByName(
const QString &name,
Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive );
/**
Returns a list of all distribution lists of all resources of this
address book
*/
QList<DistributionList*> allDistributionLists();
/**
Returns a list of names of all distribution lists of all resources
of this address book.
Convenience function, equal to iterate over the list returned
by allDistributionLists()
*/
QStringList allDistributionListNames() const;
/**
Returns a string identifying this addressbook. The identifier is
created by concatenation of the resource identifiers.
*/
virtual QString identifier() const;
/**
Returns a list of all Fields known to the address book which are
associated with the given field category.
*/
Field::List fields( int category = Field::All ) const;
/**
Add custom field to address book.
@param label User visible label of the field.
@param category Ored list of field categories.
@param key Identifier used as key for reading and writing the field.
@param app String used as application key for reading and writing
the field.
*/
bool addCustomField( const QString &label, int category = Field::All,
const QString &key = QString(),
const QString &app = QString() ) const;
/**
Adds a resource to the address book.
@param resource The resource you want to add.
@return Whether opening the resource was successfully.
*/
bool addResource( Resource *resource );
/**
Removes a resource from the address book.
@param resource The resource you want to remove.
@return Whether closing the resource was successfully.
*/
bool removeResource( Resource *resource );
/**
Returns a list of all resources.
*/
QList<Resource*> resources() const;
/**
Sets the @p ErrorHandler, that is used by error() to
provide GUI independent error messages.
@param errorHandler The error handler you want to use.
*/
void setErrorHandler( ErrorHandler *errorHandler );
/**
Shows GUI independent error messages.
@param msg The error message that shall be displayed.
*/
void error( const QString &msg );
/**
Used for debug output. This function prints out the list
of all addressees to kDebug(5700).
*/
void dump() const;
/**
Emits the signal addressBookLocked() using @c this as the parameter
*/
void emitAddressBookLocked() { addressBookLocked( this ); }
/**
Emits the signal addressBookUnlocked() using @c this as the parameter
*/
void emitAddressBookUnlocked() { addressBookUnlocked( this ); }
/**
Emits the signal addressBookChanged() using @c this as the parameter
*/
void emitAddressBookChanged() { addressBookChanged( this ); }
/**
Returns true when the loading of the addressbook has finished,
otherwise false.
*/
bool loadingHasFinished() const;
Q_SIGNALS:
/**
Emitted when one of the resources discovered a change in its backend
or the asynchronous loading of all resources has finished.
You should connect to this signal to update the presentation of
the contact data in your application.
@param addressBook The address book which emitted this signal.
*/
void addressBookChanged( AddressBook *addressBook );
/**
Emitted when one of the resources has been locked for writing.
@param addressBook The address book which emitted this signal.
*/
void addressBookLocked( AddressBook *addressBook );
/**
Emitted when one of the resources has been unlocked.
You should connect to this signal if you want to save your changes
to a resource which is currently locked, and want to get notified when
saving is possible again.
@param addressBook The address book which emitted this signal.
*/
void addressBookUnlocked( AddressBook *addressBook );
/**
Emitted when the asynchronous loading of one resource has finished
after calling asyncLoad().
@param resource The resource which emitted this signal.
*/
void loadingFinished( Resource *resource );
/**
Emitted when the asynchronous saving of one resource has finished
after calling asyncSave().
@param resource The resource which emitted this signal.
*/
void savingFinished( Resource *resource );
protected Q_SLOTS:
/**
Handles loading success.
Resource will be removed from the list of those pending for loading
and signal loadingFinished() will be emitted.
It this has been the last one in this list, signal addressBookChanged()
is emitted as well.
@param resource The resource which has been saved successfully.
*/
void resourceLoadingFinished( Resource *resource );
/**
Handles saving success.
Resource will be removed from the list of those pending for saving.
@param resource The resource which has been saved successfully.
*/
void resourceSavingFinished( Resource *resource );
/**
Handles loading errors.
Resource will be removed from the list of those pending for loading.
If this has been the last one in this list, signal addressBookChanged()
is emitted.
@param resource The resource which could not be loaded.
@param errMsg The message describing the error. See error()
*/
void resourceLoadingError( Resource *resource, const QString &errMsg );
/**
Handles saving errors.
Resource will be removed from the list of those pending for saving.
@param resource The resource which could not be saved.
@param errMsg The message describing the error. See error()
*/
void resourceSavingError( Resource *resource, const QString &errMsg );
protected:
/**
Sets the resource manager's standard resource.
Convenience method for resourceManager()->setStandardResource()
@param resource The resource to use as the standard
@see standardResource()
*/
void setStandardResource( Resource *resource );
/**
Returns the addressbook resource manager's standard resource.
Convenience method for resourceManager()->standardResource()
@see setStandardResource()
*/
Resource *standardResource();
/**
Returns the addressbook's resource manager.
*/
KRES::Manager<Resource> *resourceManager();
private:
class Private;
Private *const d;
};
KABC_EXPORT QDataStream &operator<<( QDataStream &lhs, const AddressBook &rhs );
KABC_EXPORT QDataStream &operator>>( QDataStream &lhs, AddressBook &rhs );
}
#endif
|