addressee.h 26.3 KB
Newer Older
1
/*
Christophe Giboudeaux's avatar
Christophe Giboudeaux committed
2
    This file is part of the KContacts framework.
3
    Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
                  2013 Tobias Koenig <tokoe@kde.org>
5 6 7 8 9 10 11 12 13 14 15 16 17

    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
Dirk Mueller's avatar
Dirk Mueller committed
18
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Dirk Mueller's avatar
Dirk Mueller committed
19
    Boston, MA 02110-1301, USA.
20
*/
Tobias Koenig's avatar
 
Tobias Koenig committed
21

Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
22 23
#ifndef KCONTACTS_ADDRESSEE_H
#define KCONTACTS_ADDRESSEE_H
Cornelius Schumacher's avatar
Cornelius Schumacher committed
24

Laurent Montel's avatar
Laurent Montel committed
25 26 27 28 29
#include <QDateTime>
#include <QStringList>
#include <QSharedDataPointer>
#include <QUrl>
#include <QMap>
Cornelius Schumacher's avatar
Cornelius Schumacher committed
30

Laurent Montel's avatar
Laurent Montel committed
31 32 33
#include "address.h"
#include "geo.h"
#include "key.h"
Laurent Montel's avatar
Port  
Laurent Montel committed
34
#include "email.h"
Laurent Montel's avatar
Laurent Montel committed
35
#include "lang.h"
36
#include "gender.h"
Laurent Montel's avatar
Laurent Montel committed
37 38 39 40
#include "phonenumber.h"
#include "picture.h"
#include "secrecy.h"
#include "sound.h"
Laurent Montel's avatar
Laurent Montel committed
41
#include "impp.h"
Laurent Montel's avatar
Laurent Montel committed
42
#include "timezone.h"
Laurent Montel's avatar
Laurent Montel committed
43
#include "calendarurl.h"
Laurent Montel's avatar
Laurent Montel committed
44
#include "related.h"
Laurent Montel's avatar
Laurent Montel committed
45
#include "addresseelist.h"
Laurent Montel's avatar
Laurent Montel committed
46
#include "resourcelocatorurl.h"
Laurent Montel's avatar
Laurent Montel committed
47
#include "fieldgroup.h"
48
#include "title.h"
Laurent Montel's avatar
Laurent Montel committed
49
#include "nickname.h"
Laurent Montel's avatar
Laurent Montel committed
50
#include "role.h"
Laurent Montel's avatar
Laurent Montel committed
51
#include "org.h"
Laurent Montel's avatar
Laurent Montel committed
52
#include "clientpidmap.h"
Cornelius Schumacher's avatar
Cornelius Schumacher committed
53

Laurent Montel's avatar
Laurent Montel committed
54 55
namespace KContacts
{
Cornelius Schumacher's avatar
Cornelius Schumacher committed
56

57
class SortMode;
Tobias Koenig's avatar
 
Tobias Koenig committed
58

59
/**
Tobias Koenig's avatar
 
Tobias Koenig committed
60
  @short address book entry
61

Tobias Koenig's avatar
 
Tobias Koenig committed
62
  This class represents an entry in the address book.
63

Tobias Koenig's avatar
 
Tobias Koenig committed
64
  The data of this class is implicitly shared. You can pass this class by value.
65

Tobias Koenig's avatar
 
Tobias Koenig committed
66 67 68
  If you need the name of a field for presenting it to the user you should use
  the functions ending in Label(). They return a translated string which can be
  used as label for the corresponding field.
69

Tobias Koenig's avatar
 
Tobias Koenig committed
70
  About the name fields:
71 72 73

  givenName() is the first name and familyName() the last name. In some
  countries the family name comes first, that's the reason for the
Tobias Koenig's avatar
 
Tobias Koenig committed
74
  naming. formattedName() is the full name with the correct formatting.
Tobias Koenig's avatar
 
Tobias Koenig committed
75 76
  It is used as an override, when the correct formatting can't be generated
  from the other name fields automatically.
77

Tobias Koenig's avatar
 
Tobias Koenig committed
78 79 80
  realName() returns a fully formatted name(). It uses formattedName, if set,
  otherwise it constucts the name from the name fields. As fallback, if
  nothing else is set it uses name().
81

Tobias Koenig's avatar
 
Tobias Koenig committed
82 83
  name() is the NAME type of RFC2426. It can be used as internal name for the
  data enty, but shouldn't be used for displaying the data to the user.
Tobias Koenig's avatar
 
Tobias Koenig committed
84
 */
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
85
class KCONTACTS_EXPORT Addressee
Cornelius Schumacher's avatar
Cornelius Schumacher committed
86
{
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
87 88
    friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const Addressee &);
    friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, Addressee &);
89

Laurent Montel's avatar
Laurent Montel committed
90
public:
Kevin Krammer's avatar
Kevin Krammer committed
91 92 93
    /**
      A list of addressee objects
     */
94
    typedef AddresseeList List;
Kevin Krammer's avatar
Kevin Krammer committed
95 96 97 98 99
    /**
      A map from unique identifier to addressee.

      @see uid()
     */
100
    typedef QHash<QString, Addressee> Map;
Cornelius Schumacher's avatar
Cornelius Schumacher committed
101

102
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
103
      Construct an empty address book entry.
Tobias Koenig's avatar
 
Tobias Koenig committed
104
     */
Cornelius Schumacher's avatar
Cornelius Schumacher committed
105
    Addressee();
106 107 108 109

    /**
      Destroys the address book entry.
     */
Cornelius Schumacher's avatar
Cornelius Schumacher committed
110 111
    ~Addressee();

112 113 114
    /**
      Copy constructor.
     */
Guy Maurel's avatar
Guy Maurel committed
115
    Addressee(const Addressee &other);
116 117 118 119 120 121

    /**
      Assignment operator.

      @return a reference to @c this
    */
Guy Maurel's avatar
Guy Maurel committed
122
    Addressee &operator=(const Addressee &other);
Cornelius Schumacher's avatar
Cornelius Schumacher committed
123

124 125 126 127 128 129
    /**
      Equality operator.

      @return @c true if @c this and the given addressee are equal,
              otherwise @c false
    */
Guy Maurel's avatar
Guy Maurel committed
130
    bool operator==(const Addressee &other) const;
131 132 133 134 135 136 137

    /**
      Not-equal operator.

      @return @c true if @c this and the given addressee are not equal,
              otherwise @c false
    */
Guy Maurel's avatar
Guy Maurel committed
138
    bool operator!=(const Addressee &other) const;
139

140
    /**
141
      Return if the address book entry is empty.
Tobias Koenig's avatar
 
Tobias Koenig committed
142
     */
143
    bool isEmpty() const;
144

145 146
    /**
      Set unique identifier.
147 148

      @param uid the KABC unique identifier
149
     */
Laurent Montel's avatar
Laurent Montel committed
150
    void setUid(const QString &uid);
151

152 153 154 155
    /**
      Return unique identifier.
     */
    QString uid() const;
156

157 158 159 160 161
    /**
      Return translated label for uid field.
     */
    static QString uidLabel();

162 163 164
    /**
      Set name.
     */
Laurent Montel's avatar
Laurent Montel committed
165
    void setName(const QString &name);
166 167 168 169 170 171 172 173 174 175 176 177 178 179

    /**
      Return name.
     */
    QString name() const;

    /**
      Return translated label for name field.
     */
    static QString nameLabel();

    /**
      Set formatted name.
     */
Laurent Montel's avatar
Laurent Montel committed
180
    void setFormattedName(const QString &formattedName);
181 182 183 184 185 186 187 188 189 190 191 192 193 194

    /**
      Return formatted name.
     */
    QString formattedName() const;

    /**
      Return translated label for formattedName field.
     */
    static QString formattedNameLabel();

    /**
      Set family name.
     */
Laurent Montel's avatar
Laurent Montel committed
195
    void setFamilyName(const QString &familyName);
196 197 198 199 200 201 202 203 204 205 206 207 208 209

    /**
      Return family name.
     */
    QString familyName() const;

    /**
      Return translated label for familyName field.
     */
    static QString familyNameLabel();

    /**
      Set given name.
     */
Laurent Montel's avatar
Laurent Montel committed
210
    void setGivenName(const QString &givenName);
211 212 213 214 215 216 217 218 219 220 221 222 223 224

    /**
      Return given name.
     */
    QString givenName() const;

    /**
      Return translated label for givenName field.
     */
    static QString givenNameLabel();

    /**
      Set additional names.
     */
Laurent Montel's avatar
Laurent Montel committed
225
    void setAdditionalName(const QString &additionalName);
226 227 228 229 230 231 232 233 234 235 236 237 238 239

    /**
      Return additional names.
     */
    QString additionalName() const;

    /**
      Return translated label for additionalName field.
     */
    static QString additionalNameLabel();

    /**
      Set honorific prefixes.
     */
Laurent Montel's avatar
Laurent Montel committed
240
    void setPrefix(const QString &prefix);
241 242 243 244 245 246 247 248 249 250 251 252 253 254

    /**
      Return honorific prefixes.
     */
    QString prefix() const;

    /**
      Return translated label for prefix field.
     */
    static QString prefixLabel();

    /**
      Set honorific suffixes.
     */
Laurent Montel's avatar
Laurent Montel committed
255
    void setSuffix(const QString &suffix);
256 257 258 259 260 261 262 263 264 265 266 267 268 269

    /**
      Return honorific suffixes.
     */
    QString suffix() const;

    /**
      Return translated label for suffix field.
     */
    static QString suffixLabel();

    /**
      Set nick name.
     */
Laurent Montel's avatar
Laurent Montel committed
270
    void setNickName(const QString &nickName);
Laurent Montel's avatar
Laurent Montel committed
271 272 273 274 275
    void setNickName(const NickName &nickName);
    void insertExtraNickName(const NickName &nickName);
    void setExtraNickNameList(const NickName::List &nickNameList);
    NickName::List extraNickNameList() const;

276 277 278 279 280 281 282 283 284 285 286
    /**
      Return nick name.
     */
    QString nickName() const;

    /**
      Return translated label for nickName field.
     */
    static QString nickNameLabel();

    /**
287 288
      Set birthday (date and time). If withTime is false the time will be set
      to midnight and birthdayHasTime() will return false afterwards.
Laurent Montel's avatar
Laurent Montel committed
289
      @since 5.4
290
     */
291
    void setBirthday(const QDateTime &birthday, bool withTime = true);
292 293

    /**
294 295 296 297 298 299 300
      Set birthday (date only). birthdayHasTime() will return false afterwards.
     */
    void setBirthday(const QDate &birthday);

    /**
      Return birthday. (If a valid date has been set, birthday().time() will
      always return a valid QTime!)
301 302 303
     */
    QDateTime birthday() const;

304 305 306 307 308
    /**
      Returns true if birthday has been set with a time. Returns false otherwise.
     */
    bool birthdayHasTime() const;

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
    /**
      Return translated label for birthday field.
     */
    static QString birthdayLabel();

    /**
      Return translated label for homeAddressStreet field.
     */
    static QString homeAddressStreetLabel();

    /**
      Return translated label for homeAddressPostOfficeBox field.
     */
    static QString homeAddressPostOfficeBoxLabel();

    /**
      Return translated label for homeAddressLocality field.
     */
    static QString homeAddressLocalityLabel();

    /**
      Return translated label for homeAddressRegion field.
     */
    static QString homeAddressRegionLabel();

    /**
      Return translated label for homeAddressPostalCode field.
     */
    static QString homeAddressPostalCodeLabel();

    /**
      Return translated label for homeAddressCountry field.
     */
    static QString homeAddressCountryLabel();

    /**
      Return translated label for homeAddressLabel field.
     */
    static QString homeAddressLabelLabel();

    /**
      Return translated label for businessAddressStreet field.
     */
    static QString businessAddressStreetLabel();

    /**
      Return translated label for businessAddressPostOfficeBox field.
     */
    static QString businessAddressPostOfficeBoxLabel();

    /**
      Return translated label for businessAddressLocality field.
     */
    static QString businessAddressLocalityLabel();

    /**
      Return translated label for businessAddressRegion field.
     */
    static QString businessAddressRegionLabel();

    /**
      Return translated label for businessAddressPostalCode field.
     */
    static QString businessAddressPostalCodeLabel();

    /**
      Return translated label for businessAddressCountry field.
     */
    static QString businessAddressCountryLabel();

    /**
      Return translated label for businessAddressLabel field.
     */
    static QString businessAddressLabelLabel();

    /**
      Return translated label for homePhone field.
     */
    static QString homePhoneLabel();

    /**
      Return translated label for businessPhone field.
     */
    static QString businessPhoneLabel();

    /**
      Return translated label for mobilePhone field.
     */
    static QString mobilePhoneLabel();

    /**
      Return translated label for homeFax field.
     */
    static QString homeFaxLabel();

    /**
      Return translated label for businessFax field.
     */
    static QString businessFaxLabel();

    /**
      Return translated label for carPhone field.
     */
    static QString carPhoneLabel();

    /**
      Return translated label for isdn field.
     */
    static QString isdnLabel();

    /**
      Return translated label for pager field.
     */
    static QString pagerLabel();

    /**
      Return translated label for email field.
     */
    static QString emailLabel();

    /**
      Set mail client.
     */
Laurent Montel's avatar
Laurent Montel committed
432
    void setMailer(const QString &mailer);
433 434 435 436 437 438 439 440 441 442 443 444 445 446

    /**
      Return mail client.
     */
    QString mailer() const;

    /**
      Return translated label for mailer field.
     */
    static QString mailerLabel();

    /**
      Set time zone.
     */
Laurent Montel's avatar
Laurent Montel committed
447
    void setTimeZone(const TimeZone &timeZone);
448 449 450 451 452 453 454 455 456 457 458 459 460 461

    /**
      Return time zone.
     */
    TimeZone timeZone() const;

    /**
      Return translated label for timeZone field.
     */
    static QString timeZoneLabel();

    /**
      Set geographic position.
     */
Laurent Montel's avatar
Laurent Montel committed
462
    void setGeo(const Geo &geo);
463 464 465 466 467 468 469 470 471 472 473 474 475 476

    /**
      Return geographic position.
     */
    Geo geo() const;

    /**
      Return translated label for geo field.
     */
    static QString geoLabel();

    /**
      Set title.
     */
477
    //Remove in kf6
Laurent Montel's avatar
Laurent Montel committed
478
    void setTitle(const QString &title);
479 480 481 482
    void setTitle(const Title &title);
    void insertExtraTitle(const Title &title);
    void setExtraTitleList(const Title::List &urltitle);
    Title::List extraTitleList() const;
483 484 485 486 487 488 489 490 491 492 493 494 495
    /**
      Return title.
     */
    QString title() const;

    /**
      Return translated label for title field.
     */
    static QString titleLabel();

    /**
      Set role.
     */
Laurent Montel's avatar
Laurent Montel committed
496
    void setRole(const QString &role);
Laurent Montel's avatar
Laurent Montel committed
497 498 499 500
    void setRole(const Role &role);
    void insertExtraRole(const Role &role);
    void setExtraRoleList(const Role::List &roleList);
    Role::List extraRoleList() const;
501 502 503 504 505 506 507 508 509 510 511 512 513 514

    /**
      Return role.
     */
    QString role() const;

    /**
      Return translated label for role field.
     */
    static QString roleLabel();

    /**
      Set organization.
     */
Laurent Montel's avatar
Laurent Montel committed
515
    //Remove in kf6
Laurent Montel's avatar
Laurent Montel committed
516
    void setOrganization(const QString &organization);
Laurent Montel's avatar
Laurent Montel committed
517 518 519 520 521
    void setOrganization(const Org &organization);
    void insertExtraOrganization(const Org &organization);
    void setExtraOrganizationList(const Org::List &orgList);
    Org::List extraOrganizationList() const;

522 523 524 525 526 527 528 529 530 531 532 533 534
    /**
      Return organization.
     */
    QString organization() const;

    /**
      Return translated label for organization field.
     */
    static QString organizationLabel();

    /**
      Set department.
     */
Laurent Montel's avatar
Laurent Montel committed
535
    void setDepartment(const QString &department);
536 537 538 539 540 541 542 543 544 545 546 547 548 549

    /**
      Return department.
     */
    QString department() const;

    /**
      Return translated label for department field.
     */
    static QString departmentLabel();

    /**
      Set note.
     */
Laurent Montel's avatar
Laurent Montel committed
550
    void setNote(const QString &note);
551 552 553 554 555 556 557 558 559 560 561 562 563 564

    /**
      Return note.
     */
    QString note() const;

    /**
      Return translated label for note field.
     */
    static QString noteLabel();

    /**
      Set product identifier.
     */
Laurent Montel's avatar
Laurent Montel committed
565
    void setProductId(const QString &productId);
566 567 568 569 570 571 572 573 574 575 576 577 578 579

    /**
      Return product identifier.
     */
    QString productId() const;

    /**
      Return translated label for productId field.
     */
    static QString productIdLabel();

    /**
      Set revision date.
     */
Laurent Montel's avatar
Laurent Montel committed
580
    void setRevision(const QDateTime &revision);
581 582 583 584 585 586 587 588 589 590 591 592 593 594

    /**
      Return revision date.
     */
    QDateTime revision() const;

    /**
      Return translated label for revision field.
     */
    static QString revisionLabel();

    /**
      Set sort string.
     */
Laurent Montel's avatar
Laurent Montel committed
595
    void setSortString(const QString &sortString);
596 597 598 599 600 601 602 603 604 605 606 607 608 609

    /**
      Return sort string.
     */
    QString sortString() const;

    /**
      Return translated label for sortString field.
     */
    static QString sortStringLabel();

    /**
      Set homepage.
     */
Laurent Montel's avatar
Laurent Montel committed
610
    void setUrl(const ResourceLocatorUrl &url);
Laurent Montel's avatar
Laurent Montel committed
611
    //kf6: remove it
Laurent Montel's avatar
Laurent Montel committed
612
    void setUrl(const QUrl &url);
613 614 615 616

    /**
      Return homepage.
     */
Laurent Montel's avatar
Laurent Montel committed
617
    ResourceLocatorUrl url() const;
618 619 620 621 622 623 624 625 626

    /**
      Return translated label for url field.
     */
    static QString urlLabel();

    /**
      Set security class.
     */
Laurent Montel's avatar
Laurent Montel committed
627
    void setSecrecy(const Secrecy &secrecy);
628 629 630 631 632 633 634 635 636 637 638 639 640 641

    /**
      Return security class.
     */
    Secrecy secrecy() const;

    /**
      Return translated label for secrecy field.
     */
    static QString secrecyLabel();

    /**
      Set logo.
     */
Laurent Montel's avatar
Laurent Montel committed
642
    void setLogo(const Picture &logo);
643 644 645 646 647 648 649 650 651 652 653 654 655 656

    /**
      Return logo.
     */
    Picture logo() const;

    /**
      Return translated label for logo field.
     */
    static QString logoLabel();

    /**
      Set photo.
     */
Laurent Montel's avatar
Laurent Montel committed
657
    void setPhoto(const Picture &photo);
658 659 660 661 662 663 664 665 666 667 668 669 670 671

    /**
      Return photo.
     */
    Picture photo() const;

    /**
      Return translated label for photo field.
     */
    static QString photoLabel();

    /**
      Set sound.
     */
Laurent Montel's avatar
Laurent Montel committed
672
    void setSound(const Sound &sound);
673 674 675 676 677 678 679 680 681 682 683

    /**
      Return sound.
     */
    Sound sound() const;

    /**
      Return translated label for sound field.
     */
    static QString soundLabel();

684
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
685 686 687
      Set name fields by parsing the given string and trying to associate the
      parts of the string with according fields. This function should probably
      be a bit more clever.
Tobias Koenig's avatar
 
Tobias Koenig committed
688
     */
Guy Maurel's avatar
Guy Maurel committed
689
    void setNameFromString(const QString &s);
690 691

    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
692 693
      Return the name of the addressee. This is calculated from all the name
      fields.
Tobias Koenig's avatar
 
Tobias Koenig committed
694
     */
695
    QString realName() const;
Tobias Koenig's avatar
 
Tobias Koenig committed
696 697 698 699 700

    /**
      Return the name that consists of all name parts.
     */
    QString assembledName() const;
701

702
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
703
      Return email address including real name.
704

Tobias Koenig's avatar
 
Tobias Koenig committed
705
      @param email Email address to be used to construct the full email string.
Laurent Montel's avatar
Laurent Montel committed
706
                   If this is QString() the preferred email address is used.
Tobias Koenig's avatar
 
Tobias Koenig committed
707
     */
Laurent Montel's avatar
Laurent Montel committed
708
    QString fullEmail(const QString &email = QString()) const;
709

710
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
711 712
      Insert an email address. If the email address already exists in this
      addressee it is not duplicated.
713

Tobias Koenig's avatar
 
Tobias Koenig committed
714 715 716
      @param email Email address
      @param preferred Set to true, if this is the preferred email address of
                       the addressee.
717
     */
Laurent Montel's avatar
Laurent Montel committed
718
    void insertEmail(const QString &email, bool preferred = false, const QMap<QString, QStringList> &param = QMap<QString, QStringList>());
Tobias Koenig's avatar
 
Tobias Koenig committed
719

720
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
721
      Remove email address. If the email address doesn't exist, nothing happens.
722 723

      @param email Email address to remove
Tobias Koenig's avatar
 
Tobias Koenig committed
724
     */
Laurent Montel's avatar
Laurent Montel committed
725
    void removeEmail(const QString &email);
Tobias Koenig's avatar
 
Tobias Koenig committed
726

727
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
728
      Return preferred email address. This is the first email address or the
729
      last one added with insertEmail() with a set preferred parameter.
Tobias Koenig's avatar
 
Tobias Koenig committed
730
     */
731
    QString preferredEmail() const;
Tobias Koenig's avatar
 
Tobias Koenig committed
732

733
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
734
      Return list of all email addresses.
Tobias Koenig's avatar
 
Tobias Koenig committed
735
     */
736
    QStringList emails() const;
737 738

    /**
Kurt Hindenburg's avatar
Kurt Hindenburg committed
739
       Set the emails to @p list.
740 741 742
       The first email address gets the preferred one!
       @param list The list of email addresses.
     */
Laurent Montel's avatar
Laurent Montel committed
743
    void setEmails(const QStringList &list);
744

745
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
746
      Insert a phone number. If a phone number with the same id already exists
Tobias Koenig's avatar
 
Tobias Koenig committed
747
      in this addressee it is not duplicated.
748 749

      @param phoneNumber The telephone number to insert to the addressee
Tobias Koenig's avatar
 
Tobias Koenig committed
750
     */
Laurent Montel's avatar
Laurent Montel committed
751
    void insertPhoneNumber(const PhoneNumber &phoneNumber);
Tobias Koenig's avatar
 
Tobias Koenig committed
752

753
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
754 755
      Remove phone number. If no phone number with the given id exists for this
      addresse nothing happens.
756 757

      @param phoneNumber The telephone number to remove from the addressee
Tobias Koenig's avatar
 
Tobias Koenig committed
758
     */
Laurent Montel's avatar
Laurent Montel committed
759
    void removePhoneNumber(const PhoneNumber &phoneNumber);
Tobias Koenig's avatar
 
Tobias Koenig committed
760

761
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
762
      Return phone number, which matches the given type.
763 764

      @param type The type of phone number to get
Tobias Koenig's avatar
 
Tobias Koenig committed
765
     */
Laurent Montel's avatar
Laurent Montel committed
766
    PhoneNumber phoneNumber(PhoneNumber::Type type) const;
Tobias Koenig's avatar
 
Tobias Koenig committed
767

768
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
769
      Return list of all phone numbers.
Tobias Koenig's avatar
 
Tobias Koenig committed
770
     */
Cornelius Schumacher's avatar
Cornelius Schumacher committed
771
    PhoneNumber::List phoneNumbers() const;
Tobias Koenig's avatar
 
Tobias Koenig committed
772

773 774
    void setPhoneNumbers(const PhoneNumber::List &phoneNumbers);

Tobias Koenig's avatar
 
Tobias Koenig committed
775
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
776
      Return list of phone numbers with a special type.
777 778

      @param type The type of phone number to get
Tobias Koenig's avatar
 
Tobias Koenig committed
779
     */
Laurent Montel's avatar
Laurent Montel committed
780
    PhoneNumber::List phoneNumbers(PhoneNumber::Type type) const;
Tobias Koenig's avatar
 
Tobias Koenig committed
781

782
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
783
      Return phone number with the given id.
784 785 786

      @param id The identifier of the phone number to look for.
                See PhoneNumber::id()
Tobias Koenig's avatar
 
Tobias Koenig committed
787
     */
Laurent Montel's avatar
Laurent Montel committed
788
    PhoneNumber findPhoneNumber(const QString &id) const;
Tobias Koenig's avatar
 
Tobias Koenig committed
789 790 791 792

    /**
      Insert a key. If a key with the same id already exists
      in this addressee it is not duplicated.
793 794

      @param key The key to insert
Tobias Koenig's avatar
 
Tobias Koenig committed
795
     */
Laurent Montel's avatar
Laurent Montel committed
796
    void insertKey(const Key &key);
Tobias Koenig's avatar
 
Tobias Koenig committed
797 798 799 800

    /**
      Remove a key. If no key with the given id exists for this
      addresse nothing happens.
801 802

      @param key The key to remove
Tobias Koenig's avatar
 
Tobias Koenig committed
803
     */
Laurent Montel's avatar
Laurent Montel committed
804
    void removeKey(const Key &key);
Tobias Koenig's avatar
 
Tobias Koenig committed
805 806 807

    /**
      Return key, which matches the given type.
Tobias Koenig's avatar
 
Tobias Koenig committed
808
      If @p type == Key::Custom you can specify a string
Tobias Koenig's avatar
 
Tobias Koenig committed
809 810
      that should match. If you leave the string empty, the first
      key with a custom value is returned.
811 812 813 814

      @param type The type of key to look for
      @param customTypeString A string to match custom keys against when
             @p type is @c Key::Custom
Tobias Koenig's avatar
 
Tobias Koenig committed
815
     */
Laurent Montel's avatar
Laurent Montel committed
816
    Key key(Key::Type type, const QString &customTypeString = QString()) const;
Tobias Koenig's avatar
 
Tobias Koenig committed
817 818 819 820 821 822

    /**
      Return list of all keys.
     */
    Key::List keys() const;

823 824 825 826
    /**
       Set the list of keys
       @param keys The keys to be set.
     */
Laurent Montel's avatar
Laurent Montel committed
827
    void setKeys(const Key::List &keys);
828

Tobias Koenig's avatar
 
Tobias Koenig committed
829 830
    /**
      Return list of keys with a special type.
Tobias Koenig's avatar
 
Tobias Koenig committed
831
      If @p type == Key::Custom you can specify a string
Tobias Koenig's avatar
 
Tobias Koenig committed
832 833
      that should match. If you leave the string empty, all custom
      keys will be returned.
834 835 836 837

      @param type The type of key to look for
      @param customTypeString A string to match custom keys against when
             @p type is @c Key::Custom
Tobias Koenig's avatar
 
Tobias Koenig committed
838
     */
Laurent Montel's avatar
Laurent Montel committed
839
    Key::List keys(Key::Type type, const QString &customTypeString = QString()) const;
Tobias Koenig's avatar
 
Tobias Koenig committed
840 841 842

    /**
      Return key with the given id.
843 844

      @param id The identifier of the key to look for. See Key::id()
Tobias Koenig's avatar
 
Tobias Koenig committed
845
     */
Laurent Montel's avatar
Laurent Montel committed
846
    Key findKey(const QString &id) const;
847

848
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
849 850
      Insert an address. If an address with the same id already exists
      in this addressee it is not duplicated.
851 852

      @param address The address to insert
Tobias Koenig's avatar
 
Tobias Koenig committed
853
     */
Laurent Montel's avatar
Laurent Montel committed
854
    void insertAddress(const Address &address);
Tobias Koenig's avatar
 
Tobias Koenig committed
855

856
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
857 858
      Remove address. If no address with the given id exists for this
      addresse nothing happens.
859 860

      @param address The address to remove
Tobias Koenig's avatar
 
Tobias Koenig committed
861
     */
Laurent Montel's avatar
Laurent Montel committed
862
    void removeAddress(const Address &address);
Tobias Koenig's avatar
 
Tobias Koenig committed
863

864
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
865
      Return address, which matches the given type.
866 867

      @param type The type of address to look for
Tobias Koenig's avatar
 
Tobias Koenig committed
868
     */
Laurent Montel's avatar
Laurent Montel committed
869
    Address address(Address::Type type) const;
Tobias Koenig's avatar
 
Tobias Koenig committed
870

871
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
872
      Return list of all addresses.
Tobias Koenig's avatar
 
Tobias Koenig committed
873
     */
Cornelius Schumacher's avatar
Cornelius Schumacher committed
874
    Address::List addresses() const;
Tobias Koenig's avatar
 
Tobias Koenig committed
875

Tobias Koenig's avatar
 
Tobias Koenig committed
876
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
877
      Return list of addresses with a special type.
878 879

      @param type The type of addresses to look for
Tobias Koenig's avatar
 
Tobias Koenig committed
880
     */
Laurent Montel's avatar
Laurent Montel committed
881
    Address::List addresses(Address::Type type) const;
882

883
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
884
      Return address with the given id.
885

Kevin Krammer's avatar
Kevin Krammer committed
886
      @param id The identifier of the address to look for. See Address::id()
Tobias Koenig's avatar
 
Tobias Koenig committed
887
     */
Laurent Montel's avatar
Laurent Montel committed
888
    Address findAddress(const QString &id) const;
Cornelius Schumacher's avatar
Cornelius Schumacher committed
889

890
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
891
      Insert category. If the category already exists it is not duplicated.
Tobias Koenig's avatar
 
Tobias Koenig committed
892
     */
Guy Maurel's avatar
Guy Maurel committed
893
    void insertCategory(const QString &category);
Tobias Koenig's avatar
 
Tobias Koenig committed
894

895
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
896
      Remove category.
Tobias Koenig's avatar
 
Tobias Koenig committed
897
     */
Guy Maurel's avatar
Guy Maurel committed
898
    void removeCategory(const QString &category);
Tobias Koenig's avatar
 
Tobias Koenig committed
899

900
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
901
      Return, if addressee has the given category.
Tobias Koenig's avatar
 
Tobias Koenig committed
902
     */
Guy Maurel's avatar
Guy Maurel committed
903
    bool hasCategory(const QString &category) const;
Tobias Koenig's avatar
 
Tobias Koenig committed
904

905
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
906
      Set categories to given value.
Tobias Koenig's avatar
 
Tobias Koenig committed
907
     */
Guy Maurel's avatar
Guy Maurel committed
908
    void setCategories(const QStringList &category);
Tobias Koenig's avatar
 
Tobias Koenig committed
909

910
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
911
      Return list of all set categories.
Tobias Koenig's avatar
 
Tobias Koenig committed
912
     */
913
    QStringList categories() const;
Cornelius Schumacher's avatar
Cornelius Schumacher committed
914

915
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
916 917
      Insert custom entry. The entry is identified by the name of the inserting
      application and a unique name. If an entry with the given app and name
Tobias Koenig's avatar
 
Tobias Koenig committed
918
      already exists its value is replaced with the new given value.
919 920 921

      An empty value isn't allowed (nothing happens if this is called with
      any of the three arguments being empty)
922 923 924 925

      @param app Name of the application inserting this custom entry
      @param name Name of this application specific custom entry
      @param value Value of this application specific custom entry
Tobias Koenig's avatar
 
Tobias Koenig committed
926
     */
Laurent Montel's avatar
Laurent Montel committed
927 928
    void insertCustom(const QString &app, const QString &name,
                      const QString &value);
Tobias Koenig's avatar
 
Tobias Koenig committed
929

930
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
931
      Remove custom entry.
932 933 934

      @param app Name of the application which has inserted this custom entry
      @param name Name of this application specific custom entry
Tobias Koenig's avatar
 
Tobias Koenig committed
935
     */
Laurent Montel's avatar
Laurent Montel committed
936
    void removeCustom(const QString &app, const QString &name);
Tobias Koenig's avatar
 
Tobias Koenig committed
937

938
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
939
      Return value of custom entry, identified by app and entry name.
940 941 942

      @param app Name of the application which has inserted this custom entry
      @param name Name of this application specific custom entry
Tobias Koenig's avatar
 
Tobias Koenig committed
943
     */
Laurent Montel's avatar
Laurent Montel committed
944
    QString custom(const QString &app, const QString &name) const;
Tobias Koenig's avatar
 
Tobias Koenig committed
945

946
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
947
      Set all custom entries.
Tobias Koenig's avatar
 
Tobias Koenig committed
948
     */
Guy Maurel's avatar
Guy Maurel committed
949
    void setCustoms(const QStringList &customs);
Tobias Koenig's avatar
 
Tobias Koenig committed
950

951
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
952
      Return list of all custom entries.
953 954 955

      The format of the custom entries is 'app-key:value' and the list is sorted
      alphabetically by 'app-key'.
Tobias Koenig's avatar
 
Tobias Koenig committed
956
     */
957 958
    QStringList customs() const;

959
    /**
Tobias Koenig's avatar
 
Tobias Koenig committed
960
      Parse full email address. The result is given back in fullName and email.
961 962 963 964

      @param rawEmail The input string to parse for name and email
      @param fullName The name part of the @p rawEmail input, if it contained one
      @param email The email part of the @p rawEmail input, if it contained one
Tobias Koenig's avatar
 
Tobias Koenig committed
965
     */
Laurent Montel's avatar
Laurent Montel committed
966 967
    static void parseEmailAddress(const QString &rawEmail, QString &fullName,
                                  QString &email);
968

Tobias Koenig's avatar
 
Tobias Koenig committed
969 970 971
    /**
      Returns string representation of the addressee.
     */
Tobias Koenig's avatar
Tobias Koenig committed
972
    QString toString() const;
Tobias Koenig's avatar
 
Tobias Koenig committed
973

Tobias Koenig's avatar
 
Tobias Koenig committed
974
    /**
975
      Mark addressee as changed.
976 977

      @param value Sets the status indicating changed data
978
     */
Laurent Montel's avatar
Laurent Montel committed
979
    void setChanged(bool value);
Tobias Koenig's avatar
 
Tobias Koenig committed
980

981 982 983
    /**
      Return whether the addressee is changed.
     */
984 985
    bool changed() const;

Kevin Krammer's avatar
Kevin Krammer committed
986 987 988 989
    /**
      Sets the sort mode implementation.

      Comparing to addressee objects is delegated to an instance
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
990
      of a subclass of KContacts::SortMode.
Kevin Krammer's avatar
Kevin Krammer committed
991 992 993

      @param mode The sort mode implementator to use
     */
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
994
    static void setSortMode(KContacts::SortMode *mode);
995

Kevin Krammer's avatar
Kevin Krammer committed
996 997 998 999 1000 1001 1002
    /**
      Return whether this addressee is "less-than" a given one

      @param addr The addressee object to compare with

      @see setSortMode()
     */
Guy Maurel's avatar
Guy Maurel committed
1003
    bool operator<(const Addressee &addr) const;
Tobias Koenig's avatar
 
Tobias Koenig committed
1004

1005 1006 1007 1008
    /**
      Returns the MIME type used for Addressees
     */
    static QString mimeType();
Laurent Montel's avatar
Port  
Laurent Montel committed
1009 1010

    KContacts::Email::List emailList() const;
Laurent Montel's avatar
Laurent Montel committed
1011
    void setEmailList(const Email::List &list);
Laurent Montel's avatar
Laurent Montel committed
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029

    /**
     * Remove Language
     * @brief removeLang
     * @param language
     */
    void removeLang(const QString &language);
    /**
     * Insert Language
     * @brief insertLang
     * @param language
     */
    void insertLang(const Lang &language);
    /**
     * @brief langs
     * @return List of lang
     */
    Lang::List langs() const;
1030
    void setLangs(const Lang::List &langs);
Laurent Montel's avatar
Laurent Montel committed
1031

1032 1033 1034
    void setGender(const Gender &gender);
    Gender gender() const;

1035 1036
    QString kind() const;
    void setKind(const QString &kind);
Laurent Montel's avatar
Laurent Montel committed
1037 1038

    void insertCalendarUrl(const CalendarUrl &calendarUrl);
Laurent Montel's avatar
Laurent Montel committed
1039
    CalendarUrl::List calendarUrlList() const;
Laurent Montel's avatar
Laurent Montel committed
1040

1041 1042
    void insertExtraSound(const Sound &sound);
    void setExtraSoundList(const Sound::List &soundList);
Laurent Montel's avatar
Laurent Montel committed
1043
    Sound::List extraSoundList() const;
1044 1045 1046

    void insertExtraPhoto(const Picture &picture);
    void setExtraPhotoList(const Picture::List &pictureList);
Laurent Montel's avatar
Laurent Montel committed
1047
    Picture::List extraPhotoList() const;
1048 1049 1050

    void insertExtraLogo(const Picture &logo);
    void setExtraLogoList(const Picture::List &logoList);
Laurent Montel's avatar
Laurent Montel committed
1051
    Picture::List extraLogoList() const;
1052

Laurent Montel's avatar
Laurent Montel committed
1053 1054 1055
    ResourceLocatorUrl::List extraUrlList() const;
    void setExtraUrlList(const ResourceLocatorUrl::List &urlList);
    void insertExtraUrl(const ResourceLocatorUrl &url);
Laurent Montel's avatar
Laurent Montel committed
1056

1057
    //Member
Laurent Montel's avatar
Laurent Montel committed
1058 1059 1060 1061
    void insertMember(const QString &member);
    void setMembers(const QStringList &c);
    QStringList members() const;

1062
    //Relation
Laurent Montel's avatar
Laurent Montel committed
1063 1064 1065
    void insertRelationShip(const Related &related);
    void setRelationShips(const Related::List &c);
    Related::List relationShips() const;
Laurent Montel's avatar
Laurent Montel committed
1066

1067
    //Source
Laurent Montel's avatar
Laurent Montel committed
1068 1069 1070 1071
    void insertSourceUrl(const QUrl &url);
    void setSourcesUrlList(const QVector<QUrl> &urlList);
    QVector<QUrl> sourcesUrlList() const;

1072 1073 1074 1075 1076
    //Impp
    Impp::List imppList() const;
    void setImppList(const Impp::List &imppList);
    void insertImpp(const Impp &impp);

Laurent Montel's avatar
Laurent Montel committed
1077 1078 1079 1080 1081
    //FieldGroup
    FieldGroup::List fieldGroupList() const;
    void setFieldGroupList(const FieldGroup::List &fieldGroupList);
    void insertFieldGroup(const FieldGroup &fieldGroup);

Laurent Montel's avatar
Laurent Montel committed
1082 1083 1084 1085 1086
    //ClientPidMap
    ClientPidMap::List clientPidMapList() const;
    void setClientPidMapList(const ClientPidMap::List &clientpidmaplist);
    void insertClientPidMap(const ClientPidMap &clientpidmap);

Laurent Montel's avatar
Laurent Montel committed
1087
private:
1088 1089
    class Private;
    QSharedDataPointer<Private> d;
Cornelius Schumacher's avatar
Cornelius Schumacher committed
1090 1091
};

Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
1092 1093
KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const Addressee &);
KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, Addressee &);
1094

Cornelius Schumacher's avatar
Cornelius Schumacher committed
1095 1096
}