• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.11.3 API Reference
  • KDE Home
  • Contact Us
 

kabc

  • kabc
addressee.cpp
1 /*** Warning! This file has been generated by the script makeaddressee ***/
2 /*
3  This file is part of libkabc.
4  Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5  Copyright (c) 2003 Carsten Pfeiffer <pfeiffer@kde.org>
6  Copyright (c) 2005 Ingo Kloecker <kloecker@kde.org>
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License as published by the Free Software Foundation; either
11  version 2 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public License
19  along with this library; see the file COPYING.LIB. If not, write to
20  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  Boston, MA 02110-1301, USA.
22 */
23 
24 #include <QtCore/QList>
25 #include <QtCore/QRegExp>
26 #include <QtCore/QSharedData>
27 
28 #include <kdebug.h>
29 #include <klocale.h>
30 #include <klocalizedstring.h>
31 #include <krandom.h>
32 
33 #include "addresseehelper.h"
34 #include "field.h"
35 #ifndef KDEPIM_NO_KRESOURCES
36 #include "resource.h"
37 #endif
38 #include "sortmode.h"
39 
40 #include "addressee.h"
41 
42 using namespace KABC;
43 
44 static bool matchBinaryPattern( int value, int pattern );
45 
46 template <class L>
47 static bool listEquals( const QList<L>&, const QList<L>& );
48 static bool listEquals( const QStringList&, const QStringList& );
49 static bool emailsEquals( const QStringList&, const QStringList& );
50 
51 class Addressee::Private : public QSharedData
52 {
53  public:
54  Private()
55  : mUid( KRandom::randomString( 10 ) ),
56 #ifndef KDEPIM_NO_KRESOURCES
57  mResource( 0 ),
58 #endif
59  mEmpty( true ), mChanged( false )
60  {
61  }
62 
63  Private( const Private &other )
64  : QSharedData( other )
65 #ifndef KDEPIM_NO_KRESOURCES
66  ,mResource( 0 )
67 #endif
68  {
69  mUid = other.mUid;
70  mName = other.mName;
71  mFormattedName = other.mFormattedName;
72  mFamilyName = other.mFamilyName;
73  mGivenName = other.mGivenName;
74  mAdditionalName = other.mAdditionalName;
75  mPrefix = other.mPrefix;
76  mSuffix = other.mSuffix;
77  mNickName = other.mNickName;
78  mBirthday = other.mBirthday;
79  mMailer = other.mMailer;
80  mTimeZone = other.mTimeZone;
81  mGeo = other.mGeo;
82  mTitle = other.mTitle;
83  mRole = other.mRole;
84  mOrganization = other.mOrganization;
85  mDepartment = other.mDepartment;
86  mNote = other.mNote;
87  mProductId = other.mProductId;
88  mRevision = other.mRevision;
89  mSortString = other.mSortString;
90  mUrl = other.mUrl;
91  mSecrecy = other.mSecrecy;
92  mLogo = other.mLogo;
93  mPhoto = other.mPhoto;
94  mSound = other.mSound;
95 
96  mPhoneNumbers = other.mPhoneNumbers;
97  mAddresses = other.mAddresses;
98  mKeys = other.mKeys;
99  mEmails = other.mEmails;
100  mCategories = other.mCategories;
101  mCustomFields = other.mCustomFields;
102 
103 #ifndef KDEPIM_NO_KRESOURCES
104  mResource = other.mResource;
105 #endif
106  mEmpty = other.mEmpty;
107  mChanged = other.mChanged;
108  }
109 
110  ~Private()
111  {
112  }
113 
114  QString mUid;
115  QString mName;
116  QString mFormattedName;
117  QString mFamilyName;
118  QString mGivenName;
119  QString mAdditionalName;
120  QString mPrefix;
121  QString mSuffix;
122  QString mNickName;
123  QDateTime mBirthday;
124  QString mMailer;
125  TimeZone mTimeZone;
126  Geo mGeo;
127  QString mTitle;
128  QString mRole;
129  QString mOrganization;
130  QString mDepartment;
131  QString mNote;
132  QString mProductId;
133  QDateTime mRevision;
134  QString mSortString;
135  KUrl mUrl;
136  Secrecy mSecrecy;
137  Picture mLogo;
138  Picture mPhoto;
139  Sound mSound;
140 
141  PhoneNumber::List mPhoneNumbers;
142  Address::List mAddresses;
143  Key::List mKeys;
144  QStringList mEmails;
145  QStringList mCategories;
146  QMap<QString, QString> mCustomFields;
147 
148 #ifndef KDEPIM_NO_KRESOURCES
149  Resource *mResource;
150 #endif
151 
152  bool mEmpty :1;
153  bool mChanged :1;
154 
155  static KABC::SortMode *mSortMode;
156 };
157 
158 KABC::SortMode *Addressee::Private::mSortMode = 0;
159 
160 Addressee::Addressee()
161  : d( new Private )
162 {
163 }
164 
165 Addressee::~Addressee()
166 {
167 }
168 
169 Addressee::Addressee( const Addressee &other )
170  : d( other.d )
171 {
172 }
173 
174 Addressee& Addressee::operator=( const Addressee &other )
175 {
176  if ( this != &other )
177  d = other.d;
178 
179  return *this;
180 }
181 
182 bool Addressee::operator==( const Addressee &addressee ) const
183 {
184  if ( d->mUid != addressee.d->mUid ) {
185  kDebug() << "uid differs";
186  return false;
187  }
188 
189  if ( d->mName != addressee.d->mName &&
190  !( d->mName.isEmpty() && addressee.d->mName.isEmpty() ) ) {
191  kDebug(5700) << "name differs";
192  return false;
193  }
194 
195  if ( d->mFormattedName != addressee.d->mFormattedName &&
196  !( d->mFormattedName.isEmpty() && addressee.d->mFormattedName.isEmpty() ) ) {
197  kDebug(5700) << "formattedName differs";
198  return false;
199  }
200 
201  if ( d->mFamilyName != addressee.d->mFamilyName &&
202  !( d->mFamilyName.isEmpty() && addressee.d->mFamilyName.isEmpty() ) ) {
203  kDebug(5700) << "familyName differs";
204  return false;
205  }
206 
207  if ( d->mGivenName != addressee.d->mGivenName &&
208  !( d->mGivenName.isEmpty() && addressee.d->mGivenName.isEmpty() ) ) {
209  kDebug(5700) << "givenName differs";
210  return false;
211  }
212 
213  if ( d->mAdditionalName != addressee.d->mAdditionalName &&
214  !( d->mAdditionalName.isEmpty() && addressee.d->mAdditionalName.isEmpty() ) ) {
215  kDebug(5700) << "additionalName differs";
216  return false;
217  }
218 
219  if ( d->mPrefix != addressee.d->mPrefix &&
220  !( d->mPrefix.isEmpty() && addressee.d->mPrefix.isEmpty() ) ) {
221  kDebug(5700) << "prefix differs";
222  return false;
223  }
224 
225  if ( d->mSuffix != addressee.d->mSuffix &&
226  !( d->mSuffix.isEmpty() && addressee.d->mSuffix.isEmpty() ) ) {
227  kDebug(5700) << "suffix differs";
228  return false;
229  }
230 
231  if ( d->mNickName != addressee.d->mNickName &&
232  !( d->mNickName.isEmpty() && addressee.d->mNickName.isEmpty() ) ) {
233  kDebug(5700) << "nickName differs";
234  return false;
235  }
236 
237  if ( d->mBirthday != addressee.d->mBirthday ) {
238  kDebug(5700) << "birthday differs";
239  return false;
240  }
241 
242  if ( d->mMailer != addressee.d->mMailer &&
243  !( d->mMailer.isEmpty() && addressee.d->mMailer.isEmpty() ) ) {
244  kDebug(5700) << "mailer differs";
245  return false;
246  }
247 
248  if ( d->mTimeZone != addressee.d->mTimeZone ) {
249  kDebug(5700) << "timeZone differs";
250  return false;
251  }
252 
253  if ( d->mGeo != addressee.d->mGeo ) {
254  kDebug(5700) << "geo differs";
255  return false;
256  }
257 
258  if ( d->mTitle != addressee.d->mTitle &&
259  !( d->mTitle.isEmpty() && addressee.d->mTitle.isEmpty() ) ) {
260  kDebug(5700) << "title differs";
261  return false;
262  }
263 
264  if ( d->mRole != addressee.d->mRole &&
265  !( d->mRole.isEmpty() && addressee.d->mRole.isEmpty() ) ) {
266  kDebug(5700) << "role differs";
267  return false;
268  }
269 
270  if ( d->mOrganization != addressee.d->mOrganization &&
271  !( d->mOrganization.isEmpty() && addressee.d->mOrganization.isEmpty() ) ) {
272  kDebug(5700) << "organization differs";
273  return false;
274  }
275 
276  if ( d->mDepartment != addressee.d->mDepartment &&
277  !( d->mDepartment.isEmpty() && addressee.d->mDepartment.isEmpty() ) ) {
278  kDebug(5700) << "department differs";
279  return false;
280  }
281 
282  if ( d->mNote != addressee.d->mNote &&
283  !( d->mNote.isEmpty() && addressee.d->mNote.isEmpty() ) ) {
284  kDebug(5700) << "note differs";
285  return false;
286  }
287 
288  if ( d->mProductId != addressee.d->mProductId &&
289  !( d->mProductId.isEmpty() && addressee.d->mProductId.isEmpty() ) ) {
290  kDebug(5700) << "productId differs";
291  return false;
292  }
293 
294  if ( d->mSortString != addressee.d->mSortString &&
295  !( d->mSortString.isEmpty() && addressee.d->mSortString.isEmpty() ) ) {
296  kDebug(5700) << "sortString differs";
297  return false;
298  }
299 
300  if ( d->mSecrecy != addressee.d->mSecrecy ) {
301  kDebug(5700) << "secrecy differs";
302  return false;
303  }
304 
305  if ( d->mLogo != addressee.d->mLogo ) {
306  kDebug(5700) << "logo differs";
307  return false;
308  }
309 
310  if ( d->mPhoto != addressee.d->mPhoto ) {
311  kDebug(5700) << "photo differs";
312  return false;
313  }
314 
315  if ( d->mSound != addressee.d->mSound ) {
316  kDebug(5700) << "sound differs";
317  return false;
318  }
319 
320  if ( ( d->mUrl.isValid() || addressee.d->mUrl.isValid() ) &&
321  ( d->mUrl != addressee.d->mUrl ) ) {
322  kDebug() << "url differs";
323  return false;
324  }
325 
326  if ( !listEquals( d->mPhoneNumbers, addressee.d->mPhoneNumbers ) ) {
327  kDebug() << "phoneNumbers differs";
328  return false;
329  }
330 
331  if ( !listEquals( d->mAddresses, addressee.d->mAddresses ) ) {
332  kDebug() << "addresses differs";
333  return false;
334  }
335 
336  if ( !listEquals( d->mKeys, addressee.d->mKeys ) ) {
337  kDebug() << "keys differs";
338  return false;
339  }
340 
341  if ( !emailsEquals( d->mEmails, addressee.d->mEmails ) ) {
342  kDebug() << "emails differs";
343  return false;
344  }
345 
346  if ( !listEquals( d->mCategories, addressee.d->mCategories ) ) {
347  kDebug() << "categories differs";
348  return false;
349  }
350 
351  if ( d->mCustomFields != addressee.d->mCustomFields ) {
352  kDebug() << "custom differs";
353  return false;
354  }
355 
356  return true;
357 }
358 
359 bool Addressee::operator!=( const Addressee &a ) const
360 {
361  return !( a == *this );
362 }
363 
364 bool Addressee::isEmpty() const
365 {
366  return d->mEmpty;
367 }
368 
369 void Addressee::setUid( const QString &id )
370 {
371  if ( id == d->mUid )
372  return;
373 
374  d->mEmpty = false;
375  d->mUid = id;
376 }
377 
378 QString Addressee::uid() const
379 {
380  return d->mUid;
381 }
382 
383 QString Addressee::uidLabel()
384 {
385  return i18n( "Unique Identifier" );
386 }
387 
388 void Addressee::setName( const QString &name )
389 {
390  if ( name == d->mName )
391  return;
392 
393  d->mEmpty = false;
394  d->mName = name;
395 }
396 
397 QString Addressee::name() const
398 {
399  return d->mName;
400 }
401 
402 QString Addressee::nameLabel()
403 {
404  return i18n( "Name" );
405 }
406 
407 
408 void Addressee::setFormattedName( const QString &formattedName )
409 {
410  if ( formattedName == d->mFormattedName )
411  return;
412 
413  d->mEmpty = false;
414  d->mFormattedName = formattedName;
415 }
416 
417 QString Addressee::formattedName() const
418 {
419  return d->mFormattedName;
420 }
421 
422 QString Addressee::formattedNameLabel()
423 {
424  return i18n( "Formatted Name" );
425 }
426 
427 
428 void Addressee::setFamilyName( const QString &familyName )
429 {
430  if ( familyName == d->mFamilyName )
431  return;
432 
433  d->mEmpty = false;
434  d->mFamilyName = familyName;
435 }
436 
437 QString Addressee::familyName() const
438 {
439  return d->mFamilyName;
440 }
441 
442 QString Addressee::familyNameLabel()
443 {
444  return i18n( "Family Name" );
445 }
446 
447 
448 void Addressee::setGivenName( const QString &givenName )
449 {
450  if ( givenName == d->mGivenName )
451  return;
452 
453  d->mEmpty = false;
454  d->mGivenName = givenName;
455 }
456 
457 QString Addressee::givenName() const
458 {
459  return d->mGivenName;
460 }
461 
462 QString Addressee::givenNameLabel()
463 {
464  return i18n( "Given Name" );
465 }
466 
467 
468 void Addressee::setAdditionalName( const QString &additionalName )
469 {
470  if ( additionalName == d->mAdditionalName )
471  return;
472 
473  d->mEmpty = false;
474  d->mAdditionalName = additionalName;
475 }
476 
477 QString Addressee::additionalName() const
478 {
479  return d->mAdditionalName;
480 }
481 
482 QString Addressee::additionalNameLabel()
483 {
484  return i18n( "Additional Names" );
485 }
486 
487 
488 void Addressee::setPrefix( const QString &prefix )
489 {
490  if ( prefix == d->mPrefix )
491  return;
492 
493  d->mEmpty = false;
494  d->mPrefix = prefix;
495 }
496 
497 QString Addressee::prefix() const
498 {
499  return d->mPrefix;
500 }
501 
502 QString Addressee::prefixLabel()
503 {
504  return i18n( "Honorific Prefixes" );
505 }
506 
507 
508 void Addressee::setSuffix( const QString &suffix )
509 {
510  if ( suffix == d->mSuffix )
511  return;
512 
513  d->mEmpty = false;
514  d->mSuffix = suffix;
515 }
516 
517 QString Addressee::suffix() const
518 {
519  return d->mSuffix;
520 }
521 
522 QString Addressee::suffixLabel()
523 {
524  return i18n( "Honorific Suffixes" );
525 }
526 
527 
528 void Addressee::setNickName( const QString &nickName )
529 {
530  if ( nickName == d->mNickName )
531  return;
532 
533  d->mEmpty = false;
534  d->mNickName = nickName;
535 }
536 
537 QString Addressee::nickName() const
538 {
539  return d->mNickName;
540 }
541 
542 QString Addressee::nickNameLabel()
543 {
544  return i18n( "Nick Name" );
545 }
546 
547 
548 void Addressee::setBirthday( const QDateTime &birthday )
549 {
550  if ( birthday == d->mBirthday )
551  return;
552 
553  d->mEmpty = false;
554  d->mBirthday = birthday;
555 }
556 
557 QDateTime Addressee::birthday() const
558 {
559  return d->mBirthday;
560 }
561 
562 QString Addressee::birthdayLabel()
563 {
564  return i18n( "Birthday" );
565 }
566 
567 
568 QString Addressee::homeAddressStreetLabel()
569 {
570  return i18n( "Home Address Street" );
571 }
572 
573 
574 QString Addressee::homeAddressPostOfficeBoxLabel()
575 {
576  return i18n( "Home Address Post Office Box" );
577 }
578 
579 
580 QString Addressee::homeAddressLocalityLabel()
581 {
582  return i18n( "Home Address City" );
583 }
584 
585 
586 QString Addressee::homeAddressRegionLabel()
587 {
588  return i18n( "Home Address State" );
589 }
590 
591 
592 QString Addressee::homeAddressPostalCodeLabel()
593 {
594  return i18n( "Home Address Zip Code" );
595 }
596 
597 
598 QString Addressee::homeAddressCountryLabel()
599 {
600  return i18n( "Home Address Country" );
601 }
602 
603 
604 QString Addressee::homeAddressLabelLabel()
605 {
606  return i18n( "Home Address Label" );
607 }
608 
609 
610 QString Addressee::businessAddressStreetLabel()
611 {
612  return i18n( "Business Address Street" );
613 }
614 
615 
616 QString Addressee::businessAddressPostOfficeBoxLabel()
617 {
618  return i18n( "Business Address Post Office Box" );
619 }
620 
621 
622 QString Addressee::businessAddressLocalityLabel()
623 {
624  return i18n( "Business Address City" );
625 }
626 
627 
628 QString Addressee::businessAddressRegionLabel()
629 {
630  return i18n( "Business Address State" );
631 }
632 
633 
634 QString Addressee::businessAddressPostalCodeLabel()
635 {
636  return i18n( "Business Address Zip Code" );
637 }
638 
639 
640 QString Addressee::businessAddressCountryLabel()
641 {
642  return i18n( "Business Address Country" );
643 }
644 
645 
646 QString Addressee::businessAddressLabelLabel()
647 {
648  return i18n( "Business Address Label" );
649 }
650 
651 
652 QString Addressee::homePhoneLabel()
653 {
654  return i18n( "Home Phone" );
655 }
656 
657 
658 QString Addressee::businessPhoneLabel()
659 {
660  return i18n( "Business Phone" );
661 }
662 
663 
664 QString Addressee::mobilePhoneLabel()
665 {
666  return i18n( "Mobile Phone" );
667 }
668 
669 
670 QString Addressee::homeFaxLabel()
671 {
672  return i18n( "Home Fax" );
673 }
674 
675 
676 QString Addressee::businessFaxLabel()
677 {
678  return i18n( "Business Fax" );
679 }
680 
681 
682 QString Addressee::carPhoneLabel()
683 {
684  return i18n( "Car Phone" );
685 }
686 
687 
688 QString Addressee::isdnLabel()
689 {
690  return i18n( "ISDN" );
691 }
692 
693 
694 QString Addressee::pagerLabel()
695 {
696  return i18n( "Pager" );
697 }
698 
699 
700 QString Addressee::emailLabel()
701 {
702  return i18n( "Email Address" );
703 }
704 
705 
706 void Addressee::setMailer( const QString &mailer )
707 {
708  if ( mailer == d->mMailer )
709  return;
710 
711  d->mEmpty = false;
712  d->mMailer = mailer;
713 }
714 
715 QString Addressee::mailer() const
716 {
717  return d->mMailer;
718 }
719 
720 QString Addressee::mailerLabel()
721 {
722  return i18n( "Mail Client" );
723 }
724 
725 
726 void Addressee::setTimeZone( const TimeZone &timeZone )
727 {
728  if ( timeZone == d->mTimeZone )
729  return;
730 
731  d->mEmpty = false;
732  d->mTimeZone = timeZone;
733 }
734 
735 TimeZone Addressee::timeZone() const
736 {
737  return d->mTimeZone;
738 }
739 
740 QString Addressee::timeZoneLabel()
741 {
742  return i18n( "Time Zone" );
743 }
744 
745 
746 void Addressee::setGeo( const Geo &geo )
747 {
748  if ( geo == d->mGeo )
749  return;
750 
751  d->mEmpty = false;
752  d->mGeo = geo;
753 }
754 
755 Geo Addressee::geo() const
756 {
757  return d->mGeo;
758 }
759 
760 QString Addressee::geoLabel()
761 {
762  return i18n( "Geographic Position" );
763 }
764 
765 
766 void Addressee::setTitle( const QString &title )
767 {
768  if ( title == d->mTitle )
769  return;
770 
771  d->mEmpty = false;
772  d->mTitle = title;
773 }
774 
775 QString Addressee::title() const
776 {
777  return d->mTitle;
778 }
779 
780 QString Addressee::titleLabel()
781 {
782  return i18nc( "a person's title", "Title" );
783 }
784 
785 
786 void Addressee::setRole( const QString &role )
787 {
788  if ( role == d->mRole )
789  return;
790 
791  d->mEmpty = false;
792  d->mRole = role;
793 }
794 
795 QString Addressee::role() const
796 {
797  return d->mRole;
798 }
799 
800 QString Addressee::roleLabel()
801 {
802  return i18nc( "of a person in an organization", "Role" );
803 }
804 
805 
806 void Addressee::setOrganization( const QString &organization )
807 {
808  if ( organization == d->mOrganization )
809  return;
810 
811  d->mEmpty = false;
812  d->mOrganization = organization;
813 }
814 
815 QString Addressee::organization() const
816 {
817  return d->mOrganization;
818 }
819 
820 QString Addressee::organizationLabel()
821 {
822  return i18n( "Organization" );
823 }
824 
825 
826 void Addressee::setDepartment( const QString &department )
827 {
828  if ( department == d->mDepartment )
829  return;
830 
831  d->mEmpty = false;
832  d->mDepartment = department;
833 }
834 
835 QString Addressee::department() const
836 {
837  return d->mDepartment;
838 }
839 
840 QString Addressee::departmentLabel()
841 {
842  return i18n( "Department" );
843 }
844 
845 
846 void Addressee::setNote( const QString &note )
847 {
848  if ( note == d->mNote )
849  return;
850 
851  d->mEmpty = false;
852  d->mNote = note;
853 }
854 
855 QString Addressee::note() const
856 {
857  return d->mNote;
858 }
859 
860 QString Addressee::noteLabel()
861 {
862  return i18n( "Note" );
863 }
864 
865 
866 void Addressee::setProductId( const QString &productId )
867 {
868  if ( productId == d->mProductId )
869  return;
870 
871  d->mEmpty = false;
872  d->mProductId = productId;
873 }
874 
875 QString Addressee::productId() const
876 {
877  return d->mProductId;
878 }
879 
880 QString Addressee::productIdLabel()
881 {
882  return i18n( "Product Identifier" );
883 }
884 
885 
886 void Addressee::setRevision( const QDateTime &revision )
887 {
888  if ( revision == d->mRevision )
889  return;
890 
891  d->mEmpty = false;
892  d->mRevision = revision;
893 }
894 
895 QDateTime Addressee::revision() const
896 {
897  return d->mRevision;
898 }
899 
900 QString Addressee::revisionLabel()
901 {
902  return i18n( "Revision Date" );
903 }
904 
905 
906 void Addressee::setSortString( const QString &sortString )
907 {
908  if ( sortString == d->mSortString )
909  return;
910 
911  d->mEmpty = false;
912  d->mSortString = sortString;
913 }
914 
915 QString Addressee::sortString() const
916 {
917  return d->mSortString;
918 }
919 
920 QString Addressee::sortStringLabel()
921 {
922  return i18n( "Sort String" );
923 }
924 
925 
926 void Addressee::setUrl( const KUrl &url )
927 {
928  if ( url == d->mUrl )
929  return;
930 
931  d->mEmpty = false;
932  d->mUrl = url;
933 }
934 
935 KUrl Addressee::url() const
936 {
937  return d->mUrl;
938 }
939 
940 QString Addressee::urlLabel()
941 {
942  return i18n( "Homepage" );
943 }
944 
945 
946 void Addressee::setSecrecy( const Secrecy &secrecy )
947 {
948  if ( secrecy == d->mSecrecy )
949  return;
950 
951  d->mEmpty = false;
952  d->mSecrecy = secrecy;
953 }
954 
955 Secrecy Addressee::secrecy() const
956 {
957  return d->mSecrecy;
958 }
959 
960 QString Addressee::secrecyLabel()
961 {
962  return i18n( "Security Class" );
963 }
964 
965 
966 void Addressee::setLogo( const Picture &logo )
967 {
968  if ( logo == d->mLogo )
969  return;
970 
971  d->mEmpty = false;
972  d->mLogo = logo;
973 }
974 
975 Picture Addressee::logo() const
976 {
977  return d->mLogo;
978 }
979 
980 QString Addressee::logoLabel()
981 {
982  return i18n( "Logo" );
983 }
984 
985 
986 void Addressee::setPhoto( const Picture &photo )
987 {
988  if ( photo == d->mPhoto )
989  return;
990 
991  d->mEmpty = false;
992  d->mPhoto = photo;
993 }
994 
995 Picture Addressee::photo() const
996 {
997  return d->mPhoto;
998 }
999 
1000 QString Addressee::photoLabel()
1001 {
1002  return i18n( "Photo" );
1003 }
1004 
1005 
1006 void Addressee::setSound( const Sound &sound )
1007 {
1008  if ( sound == d->mSound )
1009  return;
1010 
1011  d->mEmpty = false;
1012  d->mSound = sound;
1013 }
1014 
1015 Sound Addressee::sound() const
1016 {
1017  return d->mSound;
1018 }
1019 
1020 QString Addressee::soundLabel()
1021 {
1022  return i18n( "Sound" );
1023 }
1024 
1025 
1026 void Addressee::setNameFromString( const QString &s )
1027 {
1028  QString str = s;
1029  //remove enclosing quotes from string
1030  if ( str.length() > 1 &&
1031  s[ 0 ] == QLatin1Char( '"' ) &&
1032  s[ s.length() - 1 ] == QLatin1Char( '"' ) ) {
1033  str = s.mid( 1, s.length() - 2 );
1034  }
1035 
1036  setFormattedName( str );
1037  setName( str );
1038 
1039  // clear all name parts
1040  setPrefix( QString() );
1041  setGivenName( QString() );
1042  setAdditionalName( QString() );
1043  setFamilyName( QString() );
1044  setSuffix( QString() );
1045 
1046  if ( str.isEmpty() )
1047  return;
1048 
1049  static QString spaceStr = QString::fromLatin1( " " );
1050  static QString emptyStr = QString::fromLatin1( "" );
1051  AddresseeHelper *helper = AddresseeHelper::self();
1052 
1053  int i = str.indexOf( QLatin1Char( ',' ) );
1054  if ( i < 0 ) {
1055  QStringList parts = str.split( spaceStr );
1056  int leftOffset = 0;
1057  int rightOffset = parts.count() - 1;
1058 
1059  QString suffix;
1060  while ( rightOffset >= 0 ) {
1061  if ( helper->containsSuffix( parts[ rightOffset ] ) ) {
1062  suffix.prepend( parts[ rightOffset ] + ( suffix.isEmpty() ? emptyStr : spaceStr ) );
1063  rightOffset--;
1064  } else
1065  break;
1066  }
1067  setSuffix( suffix );
1068 
1069  if ( rightOffset < 0 )
1070  return;
1071 
1072  if ( rightOffset - 1 >= 0 && helper->containsPrefix( parts[ rightOffset - 1 ].toLower() ) ) {
1073  setFamilyName( parts[ rightOffset - 1 ] + spaceStr + parts[ rightOffset ] );
1074  rightOffset--;
1075  } else {
1076  if ( helper->tradeAsFamilyName() )
1077  setFamilyName( parts[ rightOffset ] );
1078  else
1079  setGivenName( parts[ rightOffset ] );
1080  }
1081 
1082  QString prefix;
1083  while ( leftOffset < rightOffset ) {
1084  if ( helper->containsTitle( parts[ leftOffset ] ) ) {
1085  prefix.append( ( prefix.isEmpty() ? emptyStr : spaceStr ) + parts[ leftOffset ] );
1086  leftOffset++;
1087  } else
1088  break;
1089  }
1090  setPrefix( prefix );
1091 
1092  if ( leftOffset < rightOffset ) {
1093  setGivenName( parts[ leftOffset ] );
1094  leftOffset++;
1095  }
1096 
1097  QString additionalName;
1098  while ( leftOffset < rightOffset ) {
1099  additionalName.append( ( additionalName.isEmpty() ? emptyStr : spaceStr ) + parts[ leftOffset ] );
1100  leftOffset++;
1101  }
1102  setAdditionalName( additionalName );
1103  } else {
1104  QString part1 = str.left( i );
1105  QString part2 = str.mid( i + 1 );
1106 
1107  QStringList parts = part1.split( spaceStr );
1108  int leftOffset = 0;
1109  int rightOffset = parts.count() - 1;
1110 
1111  if ( parts.count() > 0 ) {
1112 
1113  QString suffix;
1114  while ( rightOffset >= 0 ) {
1115  if ( helper->containsSuffix( parts[ rightOffset ] ) ) {
1116  suffix.prepend( parts[ rightOffset ] + ( suffix.isEmpty() ? emptyStr : spaceStr ) );
1117  rightOffset--;
1118  } else
1119  break;
1120  }
1121  setSuffix( suffix );
1122 
1123  if ( rightOffset - 1 >= 0 && helper->containsPrefix( parts[ rightOffset - 1 ].toLower() ) ) {
1124  setFamilyName( parts[ rightOffset - 1 ] + spaceStr + parts[ rightOffset ] );
1125  rightOffset--;
1126  } else
1127  setFamilyName( parts[ rightOffset ] );
1128 
1129  QString prefix;
1130  while ( leftOffset < rightOffset ) {
1131  if ( helper->containsTitle( parts[ leftOffset ] ) ) {
1132  prefix.append( ( prefix.isEmpty() ? emptyStr : spaceStr ) + parts[ leftOffset ] );
1133  leftOffset++;
1134  } else
1135  break;
1136  }
1137  } else {
1138  setPrefix( QString() );
1139  setFamilyName( QString() );
1140  setSuffix( QString() );
1141  }
1142 
1143  parts = part2.split( spaceStr );
1144 
1145  leftOffset = 0;
1146  rightOffset = parts.count();
1147 
1148  if ( parts.count() > 0 ) {
1149 
1150  QString prefix;
1151  while ( leftOffset < rightOffset ) {
1152  if ( helper->containsTitle( parts[ leftOffset ] ) ) {
1153  prefix.append( ( prefix.isEmpty() ? emptyStr : spaceStr ) + parts[ leftOffset ] );
1154  leftOffset++;
1155  } else
1156  break;
1157  }
1158  setPrefix( prefix );
1159 
1160  if ( leftOffset < rightOffset ) {
1161  setGivenName( parts[ leftOffset ] );
1162  leftOffset++;
1163  }
1164 
1165  QString additionalName;
1166  while ( leftOffset < rightOffset ) {
1167  additionalName.append( ( additionalName.isEmpty() ? emptyStr : spaceStr ) + parts[ leftOffset ] );
1168  leftOffset++;
1169  }
1170  setAdditionalName( additionalName );
1171  } else {
1172  setGivenName( QString() );
1173  setAdditionalName( QString() );
1174  }
1175  }
1176 }
1177 
1178 QString Addressee::realName() const
1179 {
1180  QString n( formattedName() );
1181  if ( !n.isEmpty() )
1182  return n;
1183 
1184  n = assembledName();
1185  if ( !n.isEmpty() )
1186  return n;
1187 
1188  n = name();
1189  if ( !n.isEmpty() )
1190  return n;
1191 
1192  return organization();
1193 }
1194 
1195 QString Addressee::assembledName() const
1196 {
1197  const QString name = prefix() + QLatin1Char( ' ' ) +
1198  givenName() + QLatin1Char( ' ' ) +
1199  additionalName() + QLatin1Char( ' ' ) +
1200  familyName() + QLatin1Char( ' ' ) +
1201  suffix();
1202 
1203  return name.simplified();
1204 }
1205 
1206 QString Addressee::fullEmail( const QString &email ) const
1207 {
1208  QString e;
1209  if ( email.isNull() ) {
1210  e = preferredEmail();
1211  } else {
1212  e = email;
1213  }
1214  if ( e.isEmpty() ) return QString();
1215 
1216  QString text;
1217  if ( realName().isEmpty() )
1218  text = e;
1219  else {
1220  QRegExp needQuotes( QLatin1String( "[^ 0-9A-Za-z\\x0080-\\xFFFF]" ) );
1221  if ( realName().indexOf( needQuotes ) != -1 ) {
1222  QString name = realName();
1223  name.replace( QLatin1String( "\"" ), QLatin1String( "\\\"" ) );
1224  text = QLatin1String( "\"" ) + name + QLatin1String( "\" <" ) + e + QLatin1Char( '>' );
1225  } else
1226  text = realName() + QLatin1String( " <" ) + e + QLatin1Char( '>' );
1227  }
1228 
1229  return text;
1230 }
1231 
1232 void Addressee::insertEmail( const QString &email, bool preferred )
1233 {
1234  if ( email.simplified().isEmpty() )
1235  return;
1236 
1237  if ( d->mEmails.contains( email ) ) {
1238  if ( !preferred || d->mEmails.first() == email )
1239  return;
1240 
1241  d->mEmails.removeAll( email );
1242  d->mEmails.prepend( email );
1243  } else {
1244  d->mEmpty = false;
1245  if ( preferred ) {
1246  d->mEmails.prepend( email );
1247  } else {
1248  d->mEmails.append( email );
1249  }
1250  }
1251 }
1252 
1253 void Addressee::removeEmail( const QString &email )
1254 {
1255  if ( d->mEmails.contains( email ) ) {
1256  d->mEmails.removeAll( email );
1257  }
1258 }
1259 
1260 QString Addressee::preferredEmail() const
1261 {
1262  if ( d->mEmails.count() == 0 )
1263  return QString();
1264  else
1265  return d->mEmails.first();
1266 }
1267 
1268 QStringList Addressee::emails() const
1269 {
1270  return d->mEmails;
1271 }
1272 
1273 void Addressee::setEmails( const QStringList& emails )
1274 {
1275  d->mEmails = emails;
1276 }
1277 void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1278 {
1279  d->mEmpty = false;
1280 
1281  PhoneNumber::List::Iterator it;
1282  for ( it = d->mPhoneNumbers.begin(); it != d->mPhoneNumbers.end(); ++it ) {
1283  if ( ( *it ).id() == phoneNumber.id() ) {
1284  *it = phoneNumber;
1285  return;
1286  }
1287  }
1288  if ( !phoneNumber.number().simplified().isEmpty() )
1289  d->mPhoneNumbers.append( phoneNumber );
1290 }
1291 
1292 void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1293 {
1294  PhoneNumber::List::Iterator it;
1295  for ( it = d->mPhoneNumbers.begin(); it != d->mPhoneNumbers.end(); ++it ) {
1296  if ( ( *it ).id() == phoneNumber.id() ) {
1297  d->mPhoneNumbers.erase( it );
1298  return;
1299  }
1300  }
1301 }
1302 
1303 PhoneNumber Addressee::phoneNumber( PhoneNumber::Type type ) const
1304 {
1305  PhoneNumber phoneNumber( QString(), type );
1306  PhoneNumber::List::ConstIterator it;
1307  for ( it = d->mPhoneNumbers.constBegin(); it != d->mPhoneNumbers.constEnd(); ++it ) {
1308  if ( matchBinaryPattern( ( *it ).type(), type ) ) {
1309  if ( ( *it ).type() & PhoneNumber::Pref ) {
1310  return ( *it );
1311  } else if ( phoneNumber.number().isEmpty() ) {
1312  phoneNumber = ( *it );
1313  }
1314  }
1315  }
1316 
1317  return phoneNumber;
1318 }
1319 
1320 PhoneNumber::List Addressee::phoneNumbers() const
1321 {
1322  return d->mPhoneNumbers;
1323 }
1324 
1325 PhoneNumber::List Addressee::phoneNumbers( PhoneNumber::Type type ) const
1326 {
1327  PhoneNumber::List list;
1328 
1329  PhoneNumber::List::ConstIterator it;
1330  PhoneNumber::List::ConstIterator end( d->mPhoneNumbers.constEnd() );
1331  for ( it = d->mPhoneNumbers.constBegin(); it != end; ++it ) {
1332  if ( matchBinaryPattern( ( *it ).type(), type ) ) {
1333  list.append( *it );
1334  }
1335  }
1336  return list;
1337 }
1338 
1339 PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1340 {
1341  PhoneNumber::List::ConstIterator it;
1342  PhoneNumber::List::ConstIterator end( d->mPhoneNumbers.constEnd() );
1343  for ( it = d->mPhoneNumbers.constBegin(); it != end; ++it ) {
1344  if ( ( *it ).id() == id ) {
1345  return *it;
1346  }
1347  }
1348  return PhoneNumber();
1349 }
1350 
1351 void Addressee::insertKey( const Key &key )
1352 {
1353  d->mEmpty = false;
1354 
1355  Key::List::Iterator it;
1356  for ( it = d->mKeys.begin(); it != d->mKeys.end(); ++it ) {
1357  if ( ( *it ).id() == key.id() ) {
1358  *it = key;
1359  return;
1360  }
1361  }
1362  d->mKeys.append( key );
1363 }
1364 
1365 void Addressee::removeKey( const Key &key )
1366 {
1367  Key::List::Iterator it;
1368  for ( it = d->mKeys.begin(); it != d->mKeys.end(); ++it ) {
1369  if ( ( *it ).id() == key.id() ) {
1370  d->mKeys.removeAll( key );
1371  return;
1372  }
1373  }
1374 }
1375 
1376 Key Addressee::key( Key::Type type, QString customTypeString ) const
1377 {
1378  Key::List::ConstIterator it;
1379  Key::List::ConstIterator end( d->mKeys.constEnd() );
1380  for ( it = d->mKeys.constBegin(); it != end; ++it ) {
1381  if ( ( *it ).type() == type ) {
1382  if ( type == Key::Custom ) {
1383  if ( customTypeString.isEmpty() ) {
1384  return *it;
1385  } else {
1386  if ( ( *it ).customTypeString() == customTypeString )
1387  return ( *it );
1388  }
1389  } else {
1390  return *it;
1391  }
1392  }
1393  }
1394  return Key( QString(), type );
1395 }
1396 
1397 void Addressee::setKeys( const Key::List& list )
1398 {
1399  d->mKeys = list;
1400 }
1401 
1402 Key::List Addressee::keys() const
1403 {
1404  return d->mKeys;
1405 }
1406 
1407 Key::List Addressee::keys( Key::Type type, QString customTypeString ) const
1408 {
1409  Key::List list;
1410 
1411  Key::List::ConstIterator it;
1412  Key::List::ConstIterator end( d->mKeys.constEnd() );
1413  for ( it = d->mKeys.constBegin(); it != end; ++it ) {
1414  if ( ( *it ).type() == type ) {
1415  if ( type == Key::Custom ) {
1416  if ( customTypeString.isEmpty() ) {
1417  list.append( *it );
1418  } else {
1419  if ( ( *it ).customTypeString() == customTypeString )
1420  list.append( *it );
1421  }
1422  } else {
1423  list.append( *it );
1424  }
1425  }
1426  }
1427  return list;
1428 }
1429 
1430 Key Addressee::findKey( const QString &id ) const
1431 {
1432  Key::List::ConstIterator it;
1433  Key::List::ConstIterator end( d->mKeys.constEnd() );
1434  for ( it = d->mKeys.constBegin(); it != end; ++it ) {
1435  if ( ( *it ).id() == id ) {
1436  return *it;
1437  }
1438  }
1439  return Key();
1440 }
1441 
1442 QString Addressee::toString() const
1443 {
1444  QString str;
1445 
1446  str += QLatin1String( "Addressee {\n" );
1447  str += QString::fromLatin1( " Uid: %1\n" ).arg( uid() );
1448 
1449  str += QString::fromLatin1( " Name: %1\n" ).arg( name() );
1450  str += QString::fromLatin1( " FormattedName: %1\n" ).arg( formattedName() );
1451  str += QString::fromLatin1( " FamilyName: %1\n" ).arg( familyName() );
1452  str += QString::fromLatin1( " GivenName: %1\n" ).arg( givenName() );
1453  str += QString::fromLatin1( " AdditionalName: %1\n" ).arg( additionalName() );
1454  str += QString::fromLatin1( " Prefix: %1\n" ).arg( prefix() );
1455  str += QString::fromLatin1( " Suffix: %1\n" ).arg( suffix() );
1456  str += QString::fromLatin1( " NickName: %1\n" ).arg( nickName() );
1457  str += QString::fromLatin1( " Birthday: %1\n" ).arg( birthday().toString() );
1458  str += QString::fromLatin1( " Mailer: %1\n" ).arg( mailer() );
1459  str += QString::fromLatin1( " TimeZone: %1\n" ).arg( timeZone().toString() );
1460  str += QString::fromLatin1( " Geo: %1\n" ).arg( geo().toString() );
1461  str += QString::fromLatin1( " Title: %1\n" ).arg( title() );
1462  str += QString::fromLatin1( " Role: %1\n" ).arg( role() );
1463  str += QString::fromLatin1( " Organization: %1\n" ).arg( organization() );
1464  str += QString::fromLatin1( " Department: %1\n" ).arg( department() );
1465  str += QString::fromLatin1( " Note: %1\n" ).arg( note() );
1466  str += QString::fromLatin1( " ProductId: %1\n" ).arg( productId() );
1467  str += QString::fromLatin1( " Revision: %1\n" ).arg( revision().toString() );
1468  str += QString::fromLatin1( " SortString: %1\n" ).arg( sortString() );
1469  str += QString::fromLatin1( " Url: %1\n" ).arg( url().url() );
1470  str += QString::fromLatin1( " Secrecy: %1\n" ).arg( secrecy().toString() );
1471  str += QString::fromLatin1( " Logo: %1\n" ).arg( logo().toString() );
1472  str += QString::fromLatin1( " Photo: %1\n" ).arg( photo().toString() );
1473  str += QString::fromLatin1( " Sound: %1\n" ).arg( sound().toString() );
1474 
1475  str += QLatin1String( " Emails {\n" );
1476  const QStringList e = emails();
1477  QStringList::ConstIterator it;
1478  for ( it = e.begin(); it != e.end(); ++it ) {
1479  str += QString::fromLatin1( " %1\n" ).arg( *it );
1480  }
1481  str += QLatin1String( " }\n" );
1482 
1483  str += QLatin1String( " PhoneNumbers {\n" );
1484  const PhoneNumber::List p = phoneNumbers();
1485  PhoneNumber::List::ConstIterator it2;
1486  for ( it2 = p.begin(); it2 != p.end(); ++it2 ) {
1487  str += ( *it2 ).toString();
1488  }
1489  str += QLatin1String( " }\n" );
1490 
1491  str += QLatin1String( " Addresses {\n" );
1492  const Address::List a = addresses();
1493  Address::List::ConstIterator it3;
1494  for ( it3 = a.begin(); it3 != a.end(); ++it3 ) {
1495  str += ( *it3 ).toString();
1496  }
1497  str += QLatin1String( " }\n" );
1498 
1499  str += QLatin1String( " Keys {\n" );
1500  const Key::List k = keys();
1501  Key::List::ConstIterator it4;
1502  for ( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1503  str += ( *it4 ).toString();
1504  }
1505  str += QLatin1String( " }\n" );
1506 
1507  str += QLatin1String( "}\n" );
1508 
1509  return str;
1510 }
1511 
1512 
1513 void Addressee::insertAddress( const Address &address )
1514 {
1515  if ( address.isEmpty() )
1516  return;
1517 
1518  d->mEmpty = false;
1519 
1520  Address::List::Iterator it;
1521  for ( it = d->mAddresses.begin(); it != d->mAddresses.end(); ++it ) {
1522  if ( ( *it ).id() == address.id() ) {
1523  *it = address;
1524  return;
1525  }
1526  }
1527 
1528  d->mAddresses.append( address );
1529 }
1530 
1531 void Addressee::removeAddress( const Address &address )
1532 {
1533  Address::List::Iterator it;
1534  for ( it = d->mAddresses.begin(); it != d->mAddresses.end(); ++it ) {
1535  if ( ( *it ).id() == address.id() ) {
1536  d->mAddresses.erase( it );
1537  return;
1538  }
1539  }
1540 }
1541 
1542 Address Addressee::address( Address::Type type ) const
1543 {
1544  Address address( type );
1545  Address::List::ConstIterator it;
1546  Address::List::ConstIterator end( d->mAddresses.constEnd() );
1547  for ( it = d->mAddresses.constBegin(); it != end; ++it ) {
1548  if ( matchBinaryPattern( ( *it ).type(), type ) ) {
1549  if ( ( *it ).type() & Address::Pref ) {
1550  return ( *it );
1551  } else if ( address.isEmpty() ) {
1552  address = ( *it );
1553  }
1554  }
1555  }
1556 
1557  return address;
1558 }
1559 
1560 Address::List Addressee::addresses() const
1561 {
1562  return d->mAddresses;
1563 }
1564 
1565 Address::List Addressee::addresses( Address::Type type ) const
1566 {
1567  Address::List list;
1568 
1569  Address::List::ConstIterator it;
1570  Address::List::ConstIterator end( d->mAddresses.constEnd() );
1571  for ( it = d->mAddresses.constBegin(); it != end; ++it ) {
1572  if ( matchBinaryPattern( ( *it ).type(), type ) ) {
1573  list.append( *it );
1574  }
1575  }
1576 
1577  return list;
1578 }
1579 
1580 Address Addressee::findAddress( const QString &id ) const
1581 {
1582  Address::List::ConstIterator it;
1583  Address::List::ConstIterator end( d->mAddresses.constEnd() );
1584  for ( it = d->mAddresses.constBegin(); it != end; ++it ) {
1585  if ( ( *it ).id() == id ) {
1586  return *it;
1587  }
1588  }
1589  return Address();
1590 }
1591 
1592 void Addressee::insertCategory( const QString &c )
1593 {
1594  d->mEmpty = false;
1595 
1596  if ( d->mCategories.contains( c ) )
1597  return;
1598 
1599  d->mCategories.append( c );
1600 }
1601 
1602 void Addressee::removeCategory( const QString &category )
1603 {
1604  if ( d->mCategories.contains( category ) ) {
1605  d->mCategories.removeAll( category );
1606  }
1607 }
1608 
1609 bool Addressee::hasCategory( const QString &category ) const
1610 {
1611  return d->mCategories.contains( category );
1612 }
1613 
1614 void Addressee::setCategories( const QStringList &c )
1615 {
1616  d->mEmpty = false;
1617 
1618  d->mCategories = c;
1619 }
1620 
1621 QStringList Addressee::categories() const
1622 {
1623  return d->mCategories;
1624 }
1625 
1626 void Addressee::insertCustom( const QString &app, const QString &name,
1627  const QString &value )
1628 {
1629  if ( value.isEmpty() || name.isEmpty() || app.isEmpty() ) {
1630  return;
1631  }
1632 
1633  d->mEmpty = false;
1634 
1635  const QString qualifiedName = app + QLatin1Char( '-' ) + name;
1636 
1637  d->mCustomFields.insert( qualifiedName, value );
1638 }
1639 
1640 void Addressee::removeCustom( const QString &app, const QString &name )
1641 {
1642  const QString qualifiedName = app + QLatin1Char( '-' ) + name;
1643 
1644  d->mCustomFields.remove( qualifiedName );
1645 }
1646 
1647 QString Addressee::custom( const QString &app, const QString &name ) const
1648 {
1649  const QString qualifiedName = app + QLatin1Char( '-' ) + name;
1650 
1651  return d->mCustomFields.value( qualifiedName );
1652 }
1653 
1654 void Addressee::setCustoms( const QStringList &customs )
1655 {
1656  d->mEmpty = false;
1657 
1658  d->mCustomFields.clear();
1659 
1660  foreach ( const QString &custom, customs ) {
1661  const int index = custom.indexOf( QLatin1Char( ':' ) );
1662  if ( index == -1 )
1663  continue;
1664 
1665  const QString qualifiedName = custom.left( index );
1666  const QString value = custom.mid( index + 1 );
1667 
1668  d->mCustomFields.insert( qualifiedName, value );
1669  }
1670 }
1671 
1672 QStringList Addressee::customs() const
1673 {
1674  QStringList result;
1675 
1676  QMapIterator<QString, QString> it( d->mCustomFields );
1677  while ( it.hasNext() ) {
1678  it.next();
1679  result << it.key() + QLatin1Char( ':' ) + it.value();
1680  }
1681 
1682  return result;
1683 }
1684 
1685 void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
1686  QString &email )
1687 {
1688  // This is a simplified version of KPIM::splitAddress().
1689 
1690  fullName.clear();
1691  email.clear();
1692  if ( rawEmail.isEmpty() )
1693  return; // KPIM::AddressEmpty;
1694 
1695  // The code works on 8-bit strings, so convert the input to UTF-8.
1696  QByteArray address = rawEmail.toUtf8();
1697 
1698  QByteArray displayName;
1699  QByteArray addrSpec;
1700  QByteArray comment;
1701 
1702  // The following is a primitive parser for a mailbox-list (cf. RFC 2822).
1703  // The purpose is to extract a displayable string from the mailboxes.
1704  // Comments in the addr-spec are not handled. No error checking is done.
1705 
1706  enum { TopLevel, InComment, InAngleAddress } context = TopLevel;
1707  bool inQuotedString = false;
1708  int commentLevel = 0;
1709  bool stop = false;
1710 
1711  for ( char* p = address.data(); *p && !stop; ++p ) {
1712  switch ( context ) {
1713  case TopLevel : {
1714  switch ( *p ) {
1715  case '"' : inQuotedString = !inQuotedString;
1716  displayName += *p;
1717  break;
1718  case '(' : if ( !inQuotedString ) {
1719  context = InComment;
1720  commentLevel = 1;
1721  }
1722  else
1723  displayName += *p;
1724  break;
1725  case '<' : if ( !inQuotedString ) {
1726  context = InAngleAddress;
1727  }
1728  else
1729  displayName += *p;
1730  break;
1731  case '\\' : // quoted character
1732  displayName += *p;
1733  ++p; // skip the '\'
1734  if ( *p )
1735  displayName += *p;
1736  else
1737  //return KPIM::UnexpectedEnd;
1738  goto ABORT_PARSING;
1739  break;
1740  case ',' : if ( !inQuotedString ) {
1741  //if ( allowMultipleAddresses )
1742  // stop = true;
1743  //else
1744  // return KPIM::UnexpectedComma;
1745  goto ABORT_PARSING;
1746  }
1747  else
1748  displayName += *p;
1749  break;
1750  default : displayName += *p;
1751  }
1752  break;
1753  }
1754  case InComment : {
1755  switch ( *p ) {
1756  case '(' : ++commentLevel;
1757  comment += *p;
1758  break;
1759  case ')' : --commentLevel;
1760  if ( commentLevel == 0 ) {
1761  context = TopLevel;
1762  comment += ' '; // separate the text of several comments
1763  }
1764  else
1765  comment += *p;
1766  break;
1767  case '\\' : // quoted character
1768  comment += *p;
1769  ++p; // skip the '\'
1770  if ( *p )
1771  comment += *p;
1772  else
1773  //return KPIM::UnexpectedEnd;
1774  goto ABORT_PARSING;
1775  break;
1776  default : comment += *p;
1777  }
1778  break;
1779  }
1780  case InAngleAddress : {
1781  switch ( *p ) {
1782  case '"' : inQuotedString = !inQuotedString;
1783  addrSpec += *p;
1784  break;
1785  case '>' : if ( !inQuotedString ) {
1786  context = TopLevel;
1787  }
1788  else
1789  addrSpec += *p;
1790  break;
1791  case '\\' : // quoted character
1792  addrSpec += *p;
1793  ++p; // skip the '\'
1794  if ( *p )
1795  addrSpec += *p;
1796  else
1797  //return KPIM::UnexpectedEnd;
1798  goto ABORT_PARSING;
1799  break;
1800  default : addrSpec += *p;
1801  }
1802  break;
1803  }
1804  } // switch ( context )
1805  }
1806 
1807 ABORT_PARSING:
1808  displayName = displayName.trimmed();
1809  comment = comment.trimmed();
1810  addrSpec = addrSpec.trimmed();
1811 
1812  fullName = QString::fromUtf8( displayName );
1813  email = QString::fromUtf8( addrSpec );
1814 
1815  // check for errors
1816  if ( inQuotedString )
1817  return; // KPIM::UnbalancedQuote;
1818  if ( context == InComment )
1819  return; // KPIM::UnbalancedParens;
1820  if ( context == InAngleAddress )
1821  return; // KPIM::UnclosedAngleAddr;
1822 
1823  if ( addrSpec.isEmpty() ) {
1824  if ( displayName.isEmpty() )
1825  return; // KPIM::NoAddressSpec;
1826  else {
1827  //addrSpec = displayName;
1828  //displayName.truncate( 0 );
1829  // Address of the form "foo@bar" or "foo@bar (Name)".
1830  email = fullName;
1831  fullName = QString::fromUtf8( comment );
1832  }
1833  }
1834 
1835  email = email.toLower();
1836  // Check that we do not have any extra characters on the end of the
1837  // strings
1838  unsigned int len = fullName.length();
1839  if ( fullName[ 0 ] == QLatin1Char( '"' ) && fullName[ len - 1 ] == QLatin1Char( '"' ) ) {
1840  fullName = fullName.mid( 1, len - 2 );
1841  }
1842 }
1843 
1844 #ifndef KDEPIM_NO_KRESOURCES
1845 void Addressee::setResource( Resource *resource )
1846 {
1847  d->mResource = resource;
1848 }
1849 
1850 Resource *Addressee::resource() const
1851 {
1852  return d->mResource;
1853 }
1854 #endif
1855 
1856 void Addressee::setChanged( bool value )
1857 {
1858  d->mChanged = value;
1859 }
1860 
1861 bool Addressee::changed() const
1862 {
1863  return d->mChanged;
1864 }
1865 
1866 void Addressee::setSortMode( KABC::SortMode *mode )
1867 {
1868  Private::mSortMode = mode;
1869 }
1870 
1871 bool Addressee::operator< ( const Addressee &addr ) const
1872 {
1873  if ( !Private::mSortMode )
1874  return false;
1875  else
1876  return Private::mSortMode->lesser( *this, addr );
1877 }
1878 
1879 QString Addressee::mimeType()
1880 {
1881  return QLatin1String( "text/directory" );
1882 }
1883 
1884 QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
1885 {
1886  s << a.d->mUid;
1887 
1888  s << a.d->mName;
1889  s << a.d->mFormattedName;
1890  s << a.d->mFamilyName;
1891  s << a.d->mGivenName;
1892  s << a.d->mAdditionalName;
1893  s << a.d->mPrefix;
1894  s << a.d->mSuffix;
1895  s << a.d->mNickName;
1896  s << a.d->mBirthday;
1897  s << a.d->mMailer;
1898  s << a.d->mTimeZone;
1899  s << a.d->mGeo;
1900  s << a.d->mTitle;
1901  s << a.d->mRole;
1902  s << a.d->mOrganization;
1903  s << a.d->mDepartment;
1904  s << a.d->mNote;
1905  s << a.d->mProductId;
1906  s << a.d->mRevision;
1907  s << a.d->mSortString;
1908  s << a.d->mUrl;
1909  s << a.d->mSecrecy;
1910  s << a.d->mLogo;
1911  s << a.d->mPhoto;
1912  s << a.d->mSound;
1913  s << a.d->mPhoneNumbers;
1914  s << a.d->mAddresses;
1915  s << a.d->mEmails;
1916  s << a.d->mCategories;
1917  s << a.customs();
1918  s << a.d->mKeys;
1919  return s;
1920 }
1921 
1922 QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
1923 {
1924  s >> a.d->mUid;
1925 
1926  s >> a.d->mName;
1927  s >> a.d->mFormattedName;
1928  s >> a.d->mFamilyName;
1929  s >> a.d->mGivenName;
1930  s >> a.d->mAdditionalName;
1931  s >> a.d->mPrefix;
1932  s >> a.d->mSuffix;
1933  s >> a.d->mNickName;
1934  s >> a.d->mBirthday;
1935  s >> a.d->mMailer;
1936  s >> a.d->mTimeZone;
1937  s >> a.d->mGeo;
1938  s >> a.d->mTitle;
1939  s >> a.d->mRole;
1940  s >> a.d->mOrganization;
1941  s >> a.d->mDepartment;
1942  s >> a.d->mNote;
1943  s >> a.d->mProductId;
1944  s >> a.d->mRevision;
1945  s >> a.d->mSortString;
1946  s >> a.d->mUrl;
1947  s >> a.d->mSecrecy;
1948  s >> a.d->mLogo;
1949  s >> a.d->mPhoto;
1950  s >> a.d->mSound;
1951  s >> a.d->mPhoneNumbers;
1952  s >> a.d->mAddresses;
1953  s >> a.d->mEmails;
1954  s >> a.d->mCategories;
1955  QStringList customFields;
1956  s >> customFields;
1957  a.setCustoms( customFields );
1958  s >> a.d->mKeys;
1959 
1960  a.d->mEmpty = false;
1961 
1962  return s;
1963 }
1964 
1965 bool matchBinaryPattern( int value, int pattern )
1966 {
1973  if ( pattern == 0 )
1974  return ( value == 0 );
1975  else
1976  return ( pattern == ( pattern & value ) );
1977 }
1978 
1979 template <class L>
1980 bool listEquals( const QList<L> &list, const QList<L> &pattern )
1981 {
1982  if ( list.count() != pattern.count() )
1983  return false;
1984  const int numberOfElement( list.count() );
1985  for ( int i = 0; i < numberOfElement; ++i ) {
1986  if ( !pattern.contains( list[ i ] ) ) {
1987  return false;
1988  }
1989  }
1990 
1991  return true;
1992 }
1993 
1994 bool listEquals( const QStringList &list, const QStringList &pattern )
1995 {
1996  if ( list.count() != pattern.count() )
1997  return false;
1998 
1999  const int numberOfElement( list.count() );
2000  for ( int i = 0; i < numberOfElement; ++i ) {
2001  if ( !pattern.contains( list[ i ] ) ) {
2002  return false;
2003  }
2004  }
2005 
2006  return true;
2007 }
2008 
2009 bool emailsEquals( const QStringList &list, const QStringList &pattern )
2010 {
2011  if ( list.count() != pattern.count() )
2012  return false;
2013 
2014  if ( list.isEmpty() )
2015  return true;
2016 
2017  if ( list.first() != pattern.first() )
2018  return false;
2019 
2020  QStringList::ConstIterator it;
2021  QStringList::ConstIterator end( list.constEnd() );
2022  for ( it = list.constBegin(); it != end; ++it ) {
2023  if ( !pattern.contains( *it ) ) {
2024  return false;
2025  }
2026  }
2027 
2028  return true;
2029 }
KABC::Sound
Class that holds a Sound clip for a contact.
Definition: sound.h:58
KABC::Addressee::customs
QStringList customs() const
Return list of all custom entries.
Definition: addressee.cpp:1672
KABC::Key::List
QList< Key > List
List of keys.
Definition: key.h:43
KABC::Addressee::homePhoneLabel
static QString homePhoneLabel()
Return translated label for homePhone field.
Definition: addressee.cpp:652
KABC::Addressee::custom
QString custom(const QString &app, const QString &name) const
Return value of custom entry, identified by app and entry name.
Definition: addressee.cpp:1647
KABC::Addressee::department
QString department() const
Return department.
Definition: addressee.cpp:835
KABC::Address
Postal address information.
Definition: address.h:37
KABC::Addressee::geoLabel
static QString geoLabel()
Return translated label for geo field.
Definition: addressee.cpp:760
KABC::Addressee::setNickName
void setNickName(const QString &nickName)
Set nick name.
Definition: addressee.cpp:528
KABC::Addressee::photo
Picture photo() const
Return photo.
Definition: addressee.cpp:995
KABC::Addressee::name
QString name() const
Return name.
Definition: addressee.cpp:397
KABC::Addressee::pagerLabel
static QString pagerLabel()
Return translated label for pager field.
Definition: addressee.cpp:694
KABC::PhoneNumber
Phonenumber information.
Definition: phonenumber.h:38
KABC::Addressee::operator!=
bool operator!=(const Addressee &) const
Not-equal operator.
Definition: addressee.cpp:359
KABC::Addressee::insertEmail
void insertEmail(const QString &email, bool preferred=false)
Insert an email address.
Definition: addressee.cpp:1232
KABC::Picture
A class to store a picture of an addressee.
Definition: picture.h:39
KABC::Addressee::noteLabel
static QString noteLabel()
Return translated label for note field.
Definition: addressee.cpp:860
KABC::Addressee::removeEmail
void removeEmail(const QString &email)
Remove email address.
Definition: addressee.cpp:1253
KABC::AddresseeHelper::containsPrefix
bool containsPrefix(const QString &prefix) const
Queries the list of inclusions.
Definition: addresseehelper.cpp:103
KABC::Addressee::title
QString title() const
Return title.
Definition: addressee.cpp:775
KABC::Addressee::setMailer
void setMailer(const QString &mailer)
Set mail client.
Definition: addressee.cpp:706
KABC::Addressee::findAddress
Address findAddress(const QString &id) const
Return address with the given id.
Definition: addressee.cpp:1580
KABC::Addressee::insertPhoneNumber
void insertPhoneNumber(const PhoneNumber &phoneNumber)
Insert a phone number.
Definition: addressee.cpp:1277
KABC::Address::Pref
preferred address
Definition: address.h:58
KABC::PhoneNumber::number
QString number() const
Returns the phone number.
Definition: phonenumber.cpp:128
KABC::Addressee::homeAddressCountryLabel
static QString homeAddressCountryLabel()
Return translated label for homeAddressCountry field.
Definition: addressee.cpp:598
KABC::Addressee::setSuffix
void setSuffix(const QString &suffix)
Set honorific suffixes.
Definition: addressee.cpp:508
KABC::Addressee::Addressee
Addressee()
Construct an empty address book entry.
Definition: addressee.cpp:160
KABC::Addressee::setPhoto
void setPhoto(const Picture &photo)
Set photo.
Definition: addressee.cpp:986
KABC::SortMode
Sort method for sorting an addressee list.
Definition: sortmode.h:37
KABC::Addressee::homeAddressLocalityLabel
static QString homeAddressLocalityLabel()
Return translated label for homeAddressLocality field.
Definition: addressee.cpp:580
KABC::Addressee::setResource
void setResource(Resource *resource)
Set resource where the addressee is from.
Definition: addressee.cpp:1845
KABC::Addressee::setFormattedName
void setFormattedName(const QString &formattedName)
Set formatted name.
Definition: addressee.cpp:408
KABC::Addressee::revisionLabel
static QString revisionLabel()
Return translated label for revision field.
Definition: addressee.cpp:900
KABC::Key
A class to store an encryption key.
Definition: key.h:34
KABC::Addressee::setRole
void setRole(const QString &role)
Set role.
Definition: addressee.cpp:786
KABC::Addressee::secrecy
Secrecy secrecy() const
Return security class.
Definition: addressee.cpp:955
KABC::Addressee::nameLabel
static QString nameLabel()
Return translated label for name field.
Definition: addressee.cpp:402
KABC::Addressee::organizationLabel
static QString organizationLabel()
Return translated label for organization field.
Definition: addressee.cpp:820
KABC::Addressee::removeAddress
void removeAddress(const Address &address)
Remove address.
Definition: addressee.cpp:1531
KABC::Addressee::fullEmail
QString fullEmail(const QString &email=QString()) const
Return email address including real name.
Definition: addressee.cpp:1206
KABC::Addressee::familyName
QString familyName() const
Return family name.
Definition: addressee.cpp:437
KABC::Addressee::removeKey
void removeKey(const Key &key)
Remove a key.
Definition: addressee.cpp:1365
KABC::AddresseeHelper
This singleton class stores static data, which is shared by all Addressee objects.
Definition: addresseehelper.h:54
KABC::Addressee::findKey
Key findKey(const QString &id) const
Return key with the given id.
Definition: addressee.cpp:1430
KABC::Addressee::setCategories
void setCategories(const QStringList &)
Set categories to given value.
Definition: addressee.cpp:1614
KABC::Addressee::prefix
QString prefix() const
Return honorific prefixes.
Definition: addressee.cpp:497
KABC::Addressee::setGivenName
void setGivenName(const QString &givenName)
Set given name.
Definition: addressee.cpp:448
KABC::Addressee::findPhoneNumber
PhoneNumber findPhoneNumber(const QString &id) const
Return phone number with the given id.
Definition: addressee.cpp:1339
KABC::Addressee::photoLabel
static QString photoLabel()
Return translated label for photo field.
Definition: addressee.cpp:1000
KABC::Addressee::formattedName
QString formattedName() const
Return formatted name.
Definition: addressee.cpp:417
KABC::Addressee::setSortMode
static void setSortMode(KABC::SortMode *mode)
Sets the sort mode implementation.
Definition: addressee.cpp:1866
KABC::Addressee::note
QString note() const
Return note.
Definition: addressee.cpp:855
KABC::Addressee::nickNameLabel
static QString nickNameLabel()
Return translated label for nickName field.
Definition: addressee.cpp:542
KABC::Addressee::sound
Sound sound() const
Return sound.
Definition: addressee.cpp:1015
KABC::Addressee::homeFaxLabel
static QString homeFaxLabel()
Return translated label for homeFax field.
Definition: addressee.cpp:670
KABC::Addressee::setSortString
void setSortString(const QString &sortString)
Set sort string.
Definition: addressee.cpp:906
KABC::Addressee::setAdditionalName
void setAdditionalName(const QString &additionalName)
Set additional names.
Definition: addressee.cpp:468
KABC::AddresseeHelper::containsSuffix
bool containsSuffix(const QString &suffix) const
Queries the list of honoric suffixes.
Definition: addresseehelper.cpp:108
KABC::Addressee::uidLabel
static QString uidLabel()
Return translated label for uid field.
Definition: addressee.cpp:383
KABC::Addressee::setLogo
void setLogo(const Picture &logo)
Set logo.
Definition: addressee.cpp:966
KABC::Addressee::setChanged
void setChanged(bool value)
Mark addressee as changed.
Definition: addressee.cpp:1856
KABC::Addressee::homeAddressStreetLabel
static QString homeAddressStreetLabel()
Return translated label for homeAddressStreet field.
Definition: addressee.cpp:568
KABC::Addressee::setFamilyName
void setFamilyName(const QString &familyName)
Set family name.
Definition: addressee.cpp:428
KABC::Addressee::addresses
Address::List addresses() const
Return list of all addresses.
Definition: addressee.cpp:1560
KABC::Addressee::realName
QString realName() const
Return the name of the addressee.
Definition: addressee.cpp:1178
KABC::Key::Custom
Custom or IANA conform key.
Definition: key.h:51
KABC::Addressee::birthday
QDateTime birthday() const
Return birthday.
Definition: addressee.cpp:557
KABC::Addressee::preferredEmail
QString preferredEmail() const
Return preferred email address.
Definition: addressee.cpp:1260
KABC::Addressee::emails
QStringList emails() const
Return list of all email addresses.
Definition: addressee.cpp:1268
KABC::Addressee::sortString
QString sortString() const
Return sort string.
Definition: addressee.cpp:915
KABC::Addressee::insertCategory
void insertCategory(const QString &)
Insert category.
Definition: addressee.cpp:1592
KABC::Addressee::formattedNameLabel
static QString formattedNameLabel()
Return translated label for formattedName field.
Definition: addressee.cpp:422
KABC::Addressee::setPrefix
void setPrefix(const QString &prefix)
Set honorific prefixes.
Definition: addressee.cpp:488
KABC::Addressee::removeCustom
void removeCustom(const QString &app, const QString &name)
Remove custom entry.
Definition: addressee.cpp:1640
KABC::Addressee::assembledName
QString assembledName() const
Return the name that consists of all name parts.
Definition: addressee.cpp:1195
KABC::Addressee::homeAddressPostalCodeLabel
static QString homeAddressPostalCodeLabel()
Return translated label for homeAddressPostalCode field.
Definition: addressee.cpp:592
KABC::Addressee::suffixLabel
static QString suffixLabel()
Return translated label for suffix field.
Definition: addressee.cpp:522
KABC::Addressee::role
QString role() const
Return role.
Definition: addressee.cpp:795
KABC::Addressee::phoneNumber
PhoneNumber phoneNumber(PhoneNumber::Type type) const
Return phone number, which matches the given type.
Definition: addressee.cpp:1303
KABC::Addressee::soundLabel
static QString soundLabel()
Return translated label for sound field.
Definition: addressee.cpp:1020
KABC::Addressee::roleLabel
static QString roleLabel()
Return translated label for role field.
Definition: addressee.cpp:800
KABC::AddresseeHelper::containsTitle
bool containsTitle(const QString &title) const
Queries the list of honoric prefixes.
Definition: addresseehelper.cpp:98
KABC::Addressee::setTitle
void setTitle(const QString &title)
Set title.
Definition: addressee.cpp:766
KABC::Addressee::businessAddressLabelLabel
static QString businessAddressLabelLabel()
Return translated label for businessAddressLabel field.
Definition: addressee.cpp:646
KABC::Addressee::businessAddressPostOfficeBoxLabel
static QString businessAddressPostOfficeBoxLabel()
Return translated label for businessAddressPostOfficeBox field.
Definition: addressee.cpp:616
KABC::Addressee::setCustoms
void setCustoms(const QStringList &)
Set all custom entries.
Definition: addressee.cpp:1654
KABC::Addressee::operator<
bool operator<(const Addressee &addr) const
Return whether this addressee is &quot;less-than&quot; a given one.
Definition: addressee.cpp:1871
KABC::Key::Type
Type
Key types.
Definition: key.h:48
KABC::Addressee::mailer
QString mailer() const
Return mail client.
Definition: addressee.cpp:715
KABC::Addressee::setDepartment
void setDepartment(const QString &department)
Set department.
Definition: addressee.cpp:826
KABC::PhoneNumber::List
QList< PhoneNumber > List
List of phone numbers.
Definition: phonenumber.h:74
KABC::Addressee::logoLabel
static QString logoLabel()
Return translated label for logo field.
Definition: addressee.cpp:980
KABC::Addressee::homeAddressRegionLabel
static QString homeAddressRegionLabel()
Return translated label for homeAddressRegion field.
Definition: addressee.cpp:586
KABC::Addressee::setSound
void setSound(const Sound &sound)
Set sound.
Definition: addressee.cpp:1006
KABC::Addressee::additionalName
QString additionalName() const
Return additional names.
Definition: addressee.cpp:477
KABC::Address::id
QString id() const
Returns the unique identifier.
Definition: address.cpp:317
KABC::Addressee::setUid
void setUid(const QString &uid)
Set unique identifier.
Definition: addressee.cpp:369
KABC::Addressee::businessAddressRegionLabel
static QString businessAddressRegionLabel()
Return translated label for businessAddressRegion field.
Definition: addressee.cpp:628
KABC::Addressee::insertKey
void insertKey(const Key &key)
Insert a key.
Definition: addressee.cpp:1351
KABC::Addressee::phoneNumbers
PhoneNumber::List phoneNumbers() const
Return list of all phone numbers.
Definition: addressee.cpp:1320
KABC::Addressee::sortStringLabel
static QString sortStringLabel()
Return translated label for sortString field.
Definition: addressee.cpp:920
KABC::AddresseeHelper::self
static AddresseeHelper * self()
Singleton interface to this class.
Definition: addresseehelper.cpp:34
KABC::TimeZone
Time zone information.
Definition: timezone.h:35
KABC::Addressee::businessFaxLabel
static QString businessFaxLabel()
Return translated label for businessFax field.
Definition: addressee.cpp:676
KABC::Addressee::setOrganization
void setOrganization(const QString &organization)
Set organization.
Definition: addressee.cpp:806
KABC::Addressee::categories
QStringList categories() const
Return list of all set categories.
Definition: addressee.cpp:1621
KABC::Addressee::setGeo
void setGeo(const Geo &geo)
Set geographic position.
Definition: addressee.cpp:746
KABC::Addressee::setUrl
void setUrl(const KUrl &url)
Set homepage.
Definition: addressee.cpp:926
KABC::Addressee::businessAddressLocalityLabel
static QString businessAddressLocalityLabel()
Return translated label for businessAddressLocality field.
Definition: addressee.cpp:622
KABC::Addressee::givenName
QString givenName() const
Return given name.
Definition: addressee.cpp:457
KABC::Address::List
QList< Address > List
List of addresses.
Definition: address.h:46
KABC::Addressee::homeAddressLabelLabel
static QString homeAddressLabelLabel()
Return translated label for homeAddressLabel field.
Definition: addressee.cpp:604
KABC::Addressee::carPhoneLabel
static QString carPhoneLabel()
Return translated label for carPhone field.
Definition: addressee.cpp:682
KABC::Addressee::key
Key key(Key::Type type, QString customTypeString=QString()) const
Return key, which matches the given type.
Definition: addressee.cpp:1376
KABC::Addressee::parseEmailAddress
static void parseEmailAddress(const QString &rawEmail, QString &fullName, QString &email)
Parse full email address.
Definition: addressee.cpp:1685
KABC::Addressee::birthdayLabel
static QString birthdayLabel()
Return translated label for birthday field.
Definition: addressee.cpp:562
KABC::Addressee::setName
void setName(const QString &name)
Set name.
Definition: addressee.cpp:388
KABC::Addressee::isEmpty
bool isEmpty() const
Return, if the address book entry is empty.
Definition: addressee.cpp:364
KABC::Addressee::businessAddressCountryLabel
static QString businessAddressCountryLabel()
Return translated label for businessAddressCountry field.
Definition: addressee.cpp:640
KABC::Addressee::removeCategory
void removeCategory(const QString &)
Remove category.
Definition: addressee.cpp:1602
KABC::Addressee::titleLabel
static QString titleLabel()
Return translated label for title field.
Definition: addressee.cpp:780
KABC::Addressee
address book entry
Definition: addressee.h:74
KABC::Addressee::timeZone
TimeZone timeZone() const
Return time zone.
Definition: addressee.cpp:735
KABC::Addressee::setNote
void setNote(const QString &note)
Set note.
Definition: addressee.cpp:846
KABC::Addressee::operator=
Addressee & operator=(const Addressee &)
Assignment operator.
Definition: addressee.cpp:174
KABC::Addressee::mimeType
static QString mimeType()
Returns the MIME type used for Addressees.
Definition: addressee.cpp:1879
KABC::Addressee::setNameFromString
void setNameFromString(const QString &)
Set name fields by parsing the given string and trying to associate the parts of the string with acco...
Definition: addressee.cpp:1026
KABC::Addressee::insertAddress
void insertAddress(const Address &address)
Insert an address.
Definition: addressee.cpp:1513
KABC::Addressee::departmentLabel
static QString departmentLabel()
Return translated label for department field.
Definition: addressee.cpp:840
KABC::Addressee::insertCustom
void insertCustom(const QString &app, const QString &name, const QString &value)
Insert custom entry.
Definition: addressee.cpp:1626
KABC::Addressee::organization
QString organization() const
Return organization.
Definition: addressee.cpp:815
KABC::Addressee::productId
QString productId() const
Return product identifier.
Definition: addressee.cpp:875
KABC::Addressee::productIdLabel
static QString productIdLabel()
Return translated label for productId field.
Definition: addressee.cpp:880
KABC::Addressee::emailLabel
static QString emailLabel()
Return translated label for email field.
Definition: addressee.cpp:700
KABC::Addressee::additionalNameLabel
static QString additionalNameLabel()
Return translated label for additionalName field.
Definition: addressee.cpp:482
KABC::Addressee::setEmails
void setEmails(const QStringList &list)
Set the emails to list.
Definition: addressee.cpp:1273
KABC::Addressee::businessPhoneLabel
static QString businessPhoneLabel()
Return translated label for businessPhone field.
Definition: addressee.cpp:658
KABC::Resource
Definition: resource.h:64
KABC::Addressee::secrecyLabel
static QString secrecyLabel()
Return translated label for secrecy field.
Definition: addressee.cpp:960
KABC::Addressee::resource
Resource * resource() const
Return pointer to resource.
Definition: addressee.cpp:1850
KABC::Addressee::removePhoneNumber
void removePhoneNumber(const PhoneNumber &phoneNumber)
Remove phone number.
Definition: addressee.cpp:1292
KABC::Addressee::changed
bool changed() const
Return whether the addressee is changed.
Definition: addressee.cpp:1861
KABC::Addressee::setRevision
void setRevision(const QDateTime &revision)
Set revision date.
Definition: addressee.cpp:886
KABC::Geo
Geographic position.
Definition: geo.h:35
KABC::Addressee::setProductId
void setProductId(const QString &productId)
Set product identifier.
Definition: addressee.cpp:866
KABC::Key::id
QString id() const
Returns the unique identifier.
Definition: key.cpp:126
KABC::Addressee::uid
QString uid() const
Return unique identifier.
Definition: addressee.cpp:378
KABC::Addressee::urlLabel
static QString urlLabel()
Return translated label for url field.
Definition: addressee.cpp:940
KABC::AddresseeHelper::tradeAsFamilyName
bool tradeAsFamilyName() const
Returns whether or not a single name component should be interpreted as a family name.
Definition: addresseehelper.cpp:113
KABC::Addressee::logo
Picture logo() const
Return logo.
Definition: addressee.cpp:975
KABC::Addressee::~Addressee
~Addressee()
Destroys the address book entry.
Definition: addressee.cpp:165
KABC::Addressee::setBirthday
void setBirthday(const QDateTime &birthday)
Set birthday.
Definition: addressee.cpp:548
KABC::PhoneNumber::id
QString id() const
Returns the unique identifier.
Definition: phonenumber.cpp:118
KABC::PhoneNumber::Pref
Preferred number.
Definition: phonenumber.h:51
KABC::Addressee::setTimeZone
void setTimeZone(const TimeZone &timeZone)
Set time zone.
Definition: addressee.cpp:726
KABC::Addressee::suffix
QString suffix() const
Return honorific suffixes.
Definition: addressee.cpp:517
KABC::Addressee::timeZoneLabel
static QString timeZoneLabel()
Return translated label for timeZone field.
Definition: addressee.cpp:740
KABC::Addressee::url
KUrl url() const
Return homepage.
Definition: addressee.cpp:935
KABC::Addressee::prefixLabel
static QString prefixLabel()
Return translated label for prefix field.
Definition: addressee.cpp:502
KABC::Addressee::familyNameLabel
static QString familyNameLabel()
Return translated label for familyName field.
Definition: addressee.cpp:442
KABC::Address::isEmpty
bool isEmpty() const
Returns true, if the address is empty.
Definition: address.cpp:301
KABC::Addressee::revision
QDateTime revision() const
Return revision date.
Definition: addressee.cpp:895
KABC::Addressee::setSecrecy
void setSecrecy(const Secrecy &secrecy)
Set security class.
Definition: addressee.cpp:946
KABC::Addressee::setKeys
void setKeys(const Key::List &keys)
Set the list of keys.
Definition: addressee.cpp:1397
KABC::Addressee::keys
Key::List keys() const
Return list of all keys.
Definition: addressee.cpp:1402
KABC::Addressee::givenNameLabel
static QString givenNameLabel()
Return translated label for givenName field.
Definition: addressee.cpp:462
KABC::Addressee::homeAddressPostOfficeBoxLabel
static QString homeAddressPostOfficeBoxLabel()
Return translated label for homeAddressPostOfficeBox field.
Definition: addressee.cpp:574
KABC::Addressee::hasCategory
bool hasCategory(const QString &) const
Return, if addressee has the given category.
Definition: addressee.cpp:1609
KABC::Addressee::mobilePhoneLabel
static QString mobilePhoneLabel()
Return translated label for mobilePhone field.
Definition: addressee.cpp:664
KABC::Addressee::operator==
bool operator==(const Addressee &) const
Equality operator.
Definition: addressee.cpp:182
KABC::Addressee::isdnLabel
static QString isdnLabel()
Return translated label for isdn field.
Definition: addressee.cpp:688
KABC::Addressee::toString
QString toString() const
Returns string representation of the addressee.
Definition: addressee.cpp:1442
KABC::Addressee::address
Address address(Address::Type type) const
Return address, which matches the given type.
Definition: addressee.cpp:1542
KABC::Addressee::businessAddressStreetLabel
static QString businessAddressStreetLabel()
Return translated label for businessAddressStreet field.
Definition: addressee.cpp:610
KABC::Addressee::nickName
QString nickName() const
Return nick name.
Definition: addressee.cpp:537
KABC::Addressee::geo
Geo geo() const
Return geographic position.
Definition: addressee.cpp:755
KABC::Addressee::mailerLabel
static QString mailerLabel()
Return translated label for mailer field.
Definition: addressee.cpp:720
KABC::Addressee::businessAddressPostalCodeLabel
static QString businessAddressPostalCodeLabel()
Return translated label for businessAddressPostalCode field.
Definition: addressee.cpp:634
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Nov 26 2013 09:04:12 by doxygen 1.8.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kabc

Skip menu "kabc"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.11.3 API Reference

Skip menu "kdepimlibs-4.11.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal