KContacts

ldifconverter.cpp
1 /*
2  This file is part of the KContacts framework.
3  SPDX-FileCopyrightText: 2003 Helge Deller <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 /*
9  Useful links:
10  - http://tldp.org/HOWTO/LDAP-Implementation-HOWTO/schemas.html
11  - http://www.faqs.org/rfcs/rfc2849.html
12 
13  Not yet handled items:
14  - objectclass microsoftaddressbook
15  - info,
16  - initials,
17  - otherfacsimiletelephonenumber,
18  - otherpager,
19  - physicaldeliveryofficename,
20 */
21 
22 #include "ldifconverter.h"
23 #include "address.h"
24 #include "kcontacts_debug.h"
25 #include "vcardconverter.h"
26 
27 #include "ldif_p.h"
28 
29 #include <KLocalizedString>
30 
31 #include <QStringList>
32 #include <QTextCodec>
33 #include <QTextStream>
34 
35 using namespace KContacts;
36 
37 /* internal functions - do not use !! */
38 
39 namespace KContacts
40 {
41 /**
42  @internal
43 
44  Evaluates @p fieldname and sets the @p value at the addressee or the address
45  objects when appropriate.
46 
47  @param a The addressee to store information into
48  @param homeAddr The home address to store respective information into
49  @param workAddr The work address to store respective information into
50  @param fieldname LDIF field name to evaluate
51  @param value The value of the field addressed by @p fieldname
52 */
53 void evaluatePair(Addressee &a,
54  Address &homeAddr,
55  Address &workAddr,
56  QString &fieldname,
57  QString &value,
58  int &birthday,
59  int &birthmonth,
60  int &birthyear,
61  ContactGroup &contactGroup);
62 }
63 
64 /* generate LDIF stream */
65 
66 static void ldif_out(QTextStream &t, const QString &formatStr, const QString &value)
67 {
68  if (value.isEmpty()) {
69  return;
70  }
71 
72  const QByteArray txt = Ldif::assembleLine(formatStr, value, 72);
73 
74  // write the string
75  t << QString::fromUtf8(txt) << "\n";
76 }
77 
78 bool LDIFConverter::addresseeAndContactGroupToLDIF(const AddresseeList &addrList, const ContactGroup::List &contactGroupList, QString &str)
79 {
80  bool result = addresseeToLDIF(addrList, str);
81  if (!contactGroupList.isEmpty()) {
82  result = (contactGroupToLDIF(contactGroupList, str) || result); // order matters
83  }
84  return result;
85 }
86 
88 {
89  if (contactGroup.dataCount() <= 0) {
90  return false;
91  }
94  t << "objectclass: top\n";
95  t << "objectclass: groupOfNames\n";
96 
97  for (int i = 0; i < contactGroup.dataCount(); ++i) {
98  const ContactGroup::Data &data = contactGroup.data(i);
99  const QString value = QStringLiteral("cn=%1,mail=%2").arg(data.name(), data.email());
100  ldif_out(t, QStringLiteral("member"), value);
101  }
102 
103  t << "\n";
104  return true;
105 }
106 
108 {
109  if (contactGroupList.count() <= 0) {
110  return false;
111  }
112 
113  bool result = true;
115  const ContactGroup::List::ConstIterator end(contactGroupList.constEnd());
116  for (it = contactGroupList.constBegin(); it != end; ++it) {
117  result = (contactGroupToLDIF(*it, str) || result); // order matters
118  }
119  return result;
120 }
121 
123 {
124  if (addrList.count() <= 0) {
125  return false;
126  }
127 
128  bool result = true;
130  const AddresseeList::ConstIterator end(addrList.constEnd());
131  for (it = addrList.constBegin(); it != end; ++it) {
132  result = (addresseeToLDIF(*it, str) || result); // order matters
133  }
134  return result;
135 }
136 
138 {
139  if (addr.isEmpty()) {
140  return false;
141  }
142 
145 
146  const Address homeAddr = addr.address(Address::Home);
147  const Address workAddr = addr.address(Address::Work);
148 
149  ldif_out(t, QStringLiteral("dn"), QStringLiteral("cn=%1,mail=%2").arg(addr.formattedName().simplified(), addr.preferredEmail()));
150  t << "objectclass: top\n";
151  t << "objectclass: person\n";
152  t << "objectclass: organizationalPerson\n";
153 
154  ldif_out(t, QStringLiteral("givenname"), addr.givenName());
155  ldif_out(t, QStringLiteral("sn"), addr.familyName());
156  ldif_out(t, QStringLiteral("cn"), addr.formattedName().simplified());
157  ldif_out(t, QStringLiteral("uid"), addr.uid());
158  ldif_out(t, QStringLiteral("nickname"), addr.nickName());
159  ldif_out(t, QStringLiteral("xmozillanickname"), addr.nickName());
160  ldif_out(t, QStringLiteral("mozillanickname"), addr.nickName());
161 
162  ldif_out(t, QStringLiteral("mail"), addr.preferredEmail());
163  const QStringList emails = addr.emails();
164  const int numEmails = emails.count();
165  for (int i = 1; i < numEmails; ++i) {
166  if (i == 0) {
167  // nothing
168  } else if (i == 1) {
169  ldif_out(t, QStringLiteral("mozillasecondemail"), emails[1]);
170  } else {
171  ldif_out(t, QStringLiteral("othermailbox"), emails[i]);
172  }
173  }
174  // ldif_out( t, "mozilla_AIMScreenName: %1\n", "screen_name" );
175 
176  ldif_out(t, QStringLiteral("telephonenumber"), addr.phoneNumber(PhoneNumber::Work).number());
177  ldif_out(t, QStringLiteral("facsimiletelephonenumber"), addr.phoneNumber(PhoneNumber::Fax).number());
178  ldif_out(t, QStringLiteral("homephone"), addr.phoneNumber(PhoneNumber::Home).number());
179  ldif_out(t, QStringLiteral("mobile"),
180  addr.phoneNumber(PhoneNumber::Cell).number()); // Netscape 7
181  ldif_out(t, QStringLiteral("cellphone"),
182  addr.phoneNumber(PhoneNumber::Cell).number()); // Netscape 4.x
183  ldif_out(t, QStringLiteral("pager"), addr.phoneNumber(PhoneNumber::Pager).number());
184  ldif_out(t, QStringLiteral("pagerphone"), addr.phoneNumber(PhoneNumber::Pager).number());
185 
186  ldif_out(t, QStringLiteral("streethomeaddress"), homeAddr.street());
187  ldif_out(t, QStringLiteral("postalcode"), workAddr.postalCode());
188  ldif_out(t, QStringLiteral("postofficebox"), workAddr.postOfficeBox());
189 
190  QStringList streets = homeAddr.street().split(QLatin1Char('\n'));
191  const int numberOfStreets(streets.count());
192  if (numberOfStreets > 0) {
193  ldif_out(t, QStringLiteral("homepostaladdress"), streets.at(0)); // Netscape 7
194  }
195  if (numberOfStreets > 1) {
196  ldif_out(t, QStringLiteral("mozillahomepostaladdress2"), streets.at(1)); // Netscape 7
197  }
198  ldif_out(t, QStringLiteral("mozillahomelocalityname"), homeAddr.locality()); // Netscape 7
199  ldif_out(t, QStringLiteral("mozillahomestate"), homeAddr.region());
200  ldif_out(t, QStringLiteral("mozillahomepostalcode"), homeAddr.postalCode());
201  ldif_out(t, QStringLiteral("mozillahomecountryname"), Address::ISOtoCountry(homeAddr.country()));
202  ldif_out(t, QStringLiteral("locality"), workAddr.locality());
203  ldif_out(t, QStringLiteral("streetaddress"), workAddr.street()); // Netscape 4.x
204 
205  streets = workAddr.street().split(QLatin1Char('\n'));
206  const int streetsCount = streets.count();
207  if (streetsCount > 0) {
208  ldif_out(t, QStringLiteral("street"), streets.at(0));
209  }
210  if (streetsCount > 1) {
211  ldif_out(t, QStringLiteral("mozillaworkstreet2"), streets.at(1));
212  }
213  ldif_out(t, QStringLiteral("countryname"), Address::ISOtoCountry(workAddr.country()));
214  ldif_out(t, QStringLiteral("l"), workAddr.locality());
215  ldif_out(t, QStringLiteral("c"), Address::ISOtoCountry(workAddr.country()));
216  ldif_out(t, QStringLiteral("st"), workAddr.region());
217 
218  ldif_out(t, QStringLiteral("title"), addr.title());
219  ldif_out(t, QStringLiteral("vocation"), addr.prefix());
220  ldif_out(t, QStringLiteral("ou"), addr.role());
221  ldif_out(t, QStringLiteral("o"), addr.organization());
222  ldif_out(t, QStringLiteral("organization"), addr.organization());
223  ldif_out(t, QStringLiteral("organizationname"), addr.organization());
224 
225  // Compatibility with older kabc versions.
226  if (!addr.department().isEmpty()) {
227  ldif_out(t, QStringLiteral("department"), addr.department());
228  } else {
229  ldif_out(t, QStringLiteral("department"), addr.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-Department")));
230  }
231 
232  ldif_out(t, QStringLiteral("workurl"), addr.url().url().toDisplayString());
233  ldif_out(t, QStringLiteral("homeurl"), addr.url().url().toDisplayString());
234  ldif_out(t, QStringLiteral("mozillahomeurl"), addr.url().url().toDisplayString());
235 
236  ldif_out(t, QStringLiteral("description"), addr.note());
237  if (addr.revision().isValid()) {
238  ldif_out(t, QStringLiteral("modifytimestamp"), dateToVCardString(addr.revision()));
239  }
240 
241  const QDate birthday = addr.birthday().date();
242  if (birthday.isValid()) {
243  const int year = birthday.year();
244  if (year > 0) {
245  ldif_out(t, QStringLiteral("birthyear"), QString::number(year));
246  }
247  ldif_out(t, QStringLiteral("birthmonth"), QString::number(birthday.month()));
248  ldif_out(t, QStringLiteral("birthday"), QString::number(birthday.day()));
249  }
250 
251  t << "\n";
252 
253  return true;
254 }
255 
256 /* convert from LDIF stream */
257 bool LDIFConverter::LDIFToAddressee(const QString &str, AddresseeList &addrList, ContactGroup::List &contactGroupList, const QDateTime &dt)
258 {
259  if (str.isEmpty()) {
260  return true;
261  }
262 
263  bool endldif = false, end = false;
264  Ldif ldif;
265  Ldif::ParseValue ret;
266  Addressee a;
267  Address homeAddr, workAddr;
268  int birthday = -1;
269  int birthmonth = -1;
270  int birthyear = -1;
271  ContactGroup contactGroup;
272  ldif.setLdif(str.toLatin1());
273  QDateTime qdt = dt;
274  if (!qdt.isValid()) {
276  }
277  a.setRevision(qdt);
278  homeAddr = Address(Address::Home);
279  workAddr = Address(Address::Work);
280 
281  do {
282  ret = ldif.nextItem();
283  switch (ret) {
284  case Ldif::Item: {
285  QString fieldname = ldif.attr().toLower();
286  QString value = QString::fromUtf8(ldif.value());
287  evaluatePair(a, homeAddr, workAddr, fieldname, value, birthday, birthmonth, birthyear, contactGroup);
288  break;
289  }
290  case Ldif::EndEntry:
291  if (contactGroup.count() == 0) {
292  // if the new address is not empty, append it
293  QDate birthDate(birthyear, birthmonth, birthday);
294  if (birthDate.isValid()) {
295  a.setBirthday(birthDate);
296  }
297 
298  if (!a.formattedName().isEmpty() || !a.name().isEmpty() || !a.familyName().isEmpty()) {
299  if (!homeAddr.isEmpty()) {
300  a.insertAddress(homeAddr);
301  }
302  if (!workAddr.isEmpty()) {
303  a.insertAddress(workAddr);
304  }
305  addrList.append(a);
306  }
307  } else {
308  contactGroupList.append(contactGroup);
309  }
310  a = Addressee();
311  contactGroup = ContactGroup();
312  a.setRevision(qdt);
313  homeAddr = Address(Address::Home);
314  workAddr = Address(Address::Work);
315  break;
316  case Ldif::MoreData:
317  if (endldif) {
318  end = true;
319  } else {
320  ldif.endLdif();
321  endldif = true;
322  break;
323  }
324  default:
325  break;
326  }
327  } while (!end);
328 
329  return true;
330 }
331 
332 void KContacts::evaluatePair(Addressee &a,
333  Address &homeAddr,
334  Address &workAddr,
335  QString &fieldname,
336  QString &value,
337  int &birthday,
338  int &birthmonth,
339  int &birthyear,
340  ContactGroup &contactGroup)
341 {
342  if (fieldname == QLatin1String("dn")) { // ignore
343  return;
344  }
345 
346  if (fieldname.startsWith(QLatin1Char('#'))) {
347  return;
348  }
349 
350  if (fieldname.isEmpty() && !a.note().isEmpty()) {
351  // some LDIF export filters are borken and add additional
352  // comments on stand-alone lines. Just add them to the notes for now.
353  a.setNote(a.note() + QLatin1Char('\n') + value);
354  return;
355  }
356 
357  if (fieldname == QLatin1String("givenname")) {
358  a.setGivenName(value);
359  return;
360  }
361 
362  if (fieldname == QLatin1String("xmozillanickname") //
363  || fieldname == QLatin1String("nickname") //
364  || fieldname == QLatin1String("mozillanickname")) {
365  a.setNickName(value);
366  return;
367  }
368 
369  if (fieldname == QLatin1String("sn")) {
370  a.setFamilyName(value);
371  return;
372  }
373 
374  if (fieldname == QLatin1String("uid")) {
375  a.setUid(value);
376  return;
377  }
378  if (fieldname == QLatin1String("mail") //
379  || fieldname == QLatin1String("mozillasecondemail") /* mozilla */
380  || fieldname == QLatin1String("othermailbox") /*TheBat!*/) {
381  if (a.emails().indexOf(value) == -1) {
382  a.insertEmail(value);
383  }
384  return;
385  }
386 
387  if (fieldname == QLatin1String("title")) {
388  a.setTitle(value);
389  return;
390  }
391 
392  if (fieldname == QLatin1String("vocation")) {
393  a.setPrefix(value);
394  return;
395  }
396 
397  if (fieldname == QLatin1String("cn")) {
398  a.setFormattedName(value);
399  return;
400  }
401 
402  if (fieldname == QLatin1Char('o') || fieldname == QLatin1String("organization") // Exchange
403  || fieldname == QLatin1String("organizationname")) { // Exchange
404  a.setOrganization(value);
405  return;
406  }
407 
408  // clang-format off
409  if (fieldname == QLatin1String("description")
410  || fieldname == QLatin1String("mozillacustom1")
411  || fieldname == QLatin1String("mozillacustom2")
412  || fieldname == QLatin1String("mozillacustom3")
413  || fieldname == QLatin1String("mozillacustom4")
414  || fieldname == QLatin1String("custom1")
415  || fieldname == QLatin1String("custom2")
416  || fieldname == QLatin1String("custom3")
417  || fieldname == QLatin1String("custom4")) {
418  if (!a.note().isEmpty()) {
419  a.setNote(a.note() + QLatin1Char('\n'));
420  }
421  a.setNote(a.note() + value);
422  return;
423  }
424  // clang-format on
425 
426  if (fieldname == QLatin1String("homeurl") //
427  || fieldname == QLatin1String("workurl") //
428  || fieldname == QLatin1String("mozillahomeurl")) {
429  if (a.url().url().isEmpty()) {
430  ResourceLocatorUrl url;
431  url.setUrl(QUrl(value));
432  a.setUrl(url);
433  return;
434  }
435  if (a.url().url().toDisplayString() == QUrl(value).toDisplayString()) {
436  return;
437  }
438  // TODO: current version of kabc only supports one URL.
439  // TODO: change this with KDE 4
440  }
441 
442  if (fieldname == QLatin1String("homephone")) {
444  return;
445  }
446 
447  if (fieldname == QLatin1String("telephonenumber")) {
449  return;
450  }
451  if (fieldname == QLatin1String("mobile") /* mozilla/Netscape 7 */
452  || fieldname == QLatin1String("cellphone")) {
454  return;
455  }
456 
457  if (fieldname == QLatin1String("pager") // mozilla
458  || fieldname == QLatin1String("pagerphone")) { // mozilla
460  return;
461  }
462 
463  if (fieldname == QLatin1String("facsimiletelephonenumber")) {
465  return;
466  }
467 
468  if (fieldname == QLatin1String("xmozillaanyphone")) { // mozilla
470  return;
471  }
472 
473  if (fieldname == QLatin1String("streethomeaddress") //
474  || fieldname == QLatin1String("mozillahomestreet")) { // thunderbird
475  homeAddr.setStreet(value);
476  return;
477  }
478 
479  if (fieldname == QLatin1String("street") //
480  || fieldname == QLatin1String("postaladdress")) { // mozilla
481  workAddr.setStreet(value);
482  return;
483  }
484  if (fieldname == QLatin1String("mozillapostaladdress2") //
485  || fieldname == QLatin1String("mozillaworkstreet2")) { // mozilla
486  workAddr.setStreet(workAddr.street() + QLatin1Char('\n') + value);
487  return;
488  }
489 
490  if (fieldname == QLatin1String("postalcode")) {
491  workAddr.setPostalCode(value);
492  return;
493  }
494 
495  if (fieldname == QLatin1String("postofficebox")) {
496  workAddr.setPostOfficeBox(value);
497  return;
498  }
499 
500  if (fieldname == QLatin1String("homepostaladdress")) { // Netscape 7
501  homeAddr.setStreet(value);
502  return;
503  }
504 
505  if (fieldname == QLatin1String("mozillahomepostaladdress2")) { // mozilla
506  homeAddr.setStreet(homeAddr.street() + QLatin1Char('\n') + value);
507  return;
508  }
509 
510  if (fieldname == QLatin1String("mozillahomelocalityname")) { // mozilla
511  homeAddr.setLocality(value);
512  return;
513  }
514 
515  if (fieldname == QLatin1String("mozillahomestate")) { // mozilla
516  homeAddr.setRegion(value);
517  return;
518  }
519 
520  if (fieldname == QLatin1String("mozillahomepostalcode")) { // mozilla
521  homeAddr.setPostalCode(value);
522  return;
523  }
524 
525  if (fieldname == QLatin1String("mozillahomecountryname")) { // mozilla
526  if (value.length() <= 2) {
527  value = Address::ISOtoCountry(value);
528  }
529  homeAddr.setCountry(value);
530  return;
531  }
532 
533  if (fieldname == QLatin1String("locality")) {
534  workAddr.setLocality(value);
535  return;
536  }
537 
538  if (fieldname == QLatin1String("streetaddress")) { // Netscape 4.x
539  workAddr.setStreet(value);
540  return;
541  }
542 
543  if (fieldname == QLatin1String("countryname") //
544  || fieldname == QLatin1Char('c')) { // mozilla
545  if (value.length() <= 2) {
546  value = Address::ISOtoCountry(value);
547  }
548  workAddr.setCountry(value);
549  return;
550  }
551 
552  if (fieldname == QLatin1Char('l')) { // mozilla
553  workAddr.setLocality(value);
554  return;
555  }
556 
557  if (fieldname == QLatin1String("st")) {
558  workAddr.setRegion(value);
559  return;
560  }
561 
562  if (fieldname == QLatin1String("ou")) {
563  a.setRole(value);
564  return;
565  }
566 
567  if (fieldname == QLatin1String("department")) {
568  a.setDepartment(value);
569  return;
570  }
571 
572  if (fieldname == QLatin1String("member")) {
573  // this is a mozilla list member (cn=xxx, mail=yyy)
574  const QStringList list = value.split(QLatin1Char(','));
575  QString name, email;
576 
578  const QStringList::ConstIterator end(list.constEnd());
579  for (it = list.constBegin(); it != end; ++it) {
580  if ((*it).startsWith(QLatin1String("cn="))) {
581  name = (*it).mid(3).trimmed();
582  }
583  if ((*it).startsWith(QLatin1String("mail="))) {
584  email = (*it).mid(5).trimmed();
585  }
586  }
587  if (!name.isEmpty() && !email.isEmpty()) {
588  email = QLatin1String(" <") + email + QLatin1Char('>');
589  }
590  ContactGroup::Data data;
591  data.setEmail(email);
592  data.setName(name);
593  contactGroup.append(data);
594  return;
595  }
596 
597  if (fieldname == QLatin1String("modifytimestamp")) {
598  if (value == QLatin1String("0Z")) { // ignore
599  return;
600  }
601  QDateTime dt = VCardStringToDate(value);
602  if (dt.isValid()) {
603  a.setRevision(dt);
604  return;
605  }
606  }
607 
608  if (fieldname == QLatin1String("display-name")) {
609  contactGroup.setName(value);
610  return;
611  }
612 
613  if (fieldname == QLatin1String("objectclass")) { // ignore
614  return;
615  }
616 
617  if (fieldname == QLatin1String("birthyear")) {
618  bool ok;
619  birthyear = value.toInt(&ok);
620  if (!ok) {
621  birthyear = -1;
622  }
623  return;
624  }
625  if (fieldname == QLatin1String("birthmonth")) {
626  birthmonth = value.toInt();
627  return;
628  }
629  if (fieldname == QLatin1String("birthday")) {
630  birthday = value.toInt();
631  return;
632  }
633  if (fieldname == QLatin1String("xbatbirthday")) {
634  QDate dt = QDate::fromString(value, QStringLiteral("yyyyMMdd"));
635  if (dt.isValid()) {
636  a.setBirthday(dt);
637  }
638  return;
639  }
640  qCWarning(KCONTACTS_LOG) << QStringLiteral("LDIFConverter: Unknown field for '%1': '%2=%3'\n").arg(a.formattedName(), fieldname, value);
641 }
void setCodec(QTextCodec *codec)
KCONTACTS_EXPORT bool contactGroupToLDIF(const ContactGroup::List &contactGroupList, QString &str)
Converts a list of contact group to a LDIF string.
QString custom(const QString &app, const QString &name) const
Return value of custom entry, identified by app and entry name.
Definition: addressee.cpp:2265
void setFormattedName(const QString &formattedName)
Set formatted name.
Definition: addressee.cpp:620
QString toDisplayString(QUrl::FormattingOptions options) const const
void setLocality(const QString &locality)
Sets the locality, e.g.
Definition: address.cpp:424
void setEmail(const QString &email)
Sets the email address of the contact data object.
void insertPhoneNumber(const PhoneNumber &phoneNumber)
Insert a phone number.
Definition: addressee.cpp:1717
void append(const T &value)
KCONTACTS_EXPORT bool addresseeAndContactGroupToLDIF(const AddresseeList &addrList, const QVector< KContacts::ContactGroup > &contactGroupList, QString &str)
Converts a list of addressees and contactgrouplist to a LDIF string.
Class that holds a Resource Locator.
QString name() const
Returns the name of the contact data object.
This class represents a group of contacts.
Definition: contactgroup.h:33
void setUid(const QString &uid)
Set unique identifier.
Definition: addressee.cpp:404
QVector::const_iterator constEnd() const const
QString simplified() const const
void setStreet(const QString &street)
Sets the street (including house number).
Definition: address.cpp:408
void setPrefix(const QString &prefix)
Set honorific prefixes.
Definition: addressee.cpp:700
int day() const const
KCONTACTS_EXPORT bool LDIFToAddressee(const QString &str, AddresseeList &addrList, QVector< KContacts::ContactGroup > &contactGroupList, const QDateTime &dt=QDateTime::currentDateTime())
Converts a LDIF string to a list of addressees.
void setGivenName(const QString &givenName)
Set given name.
Definition: addressee.cpp:660
typedef ConstIterator
void setDepartment(const QString &department)
Set department.
Definition: addressee.cpp:1159
bool isEmpty() const const
void insertEmail(const QString &email, bool preferred=false, const QMap< QString, QStringList > &param=QMap< QString, QStringList >())
Insert an email address.
Definition: addressee.cpp:1584
Address address(Address::Type type) const
Return address, which matches the given type.
Definition: addressee.cpp:2009
void setUrl(const ResourceLocatorUrl &url)
Set homepage.
Definition: addressee.cpp:1266
void setOrganization(const QString &organization)
Set organization.
Definition: addressee.cpp:1108
QDate fromString(const QString &string, Qt::DateFormat format)
QString number(int n, int base)
int count(const T &value) const const
void setTitle(const QString &title)
Set title.
Definition: addressee.cpp:1006
QString fromUtf8(const char *str, int size)
KCONTACTS_EXPORT bool addresseeToLDIF(const AddresseeList &addrList, QString &str)
Converts a list of addressees to a LDIF string.
void setFamilyName(const QString &familyName)
Set family name.
Definition: addressee.cpp:640
int toInt(bool *ok, int base) const const
bool isEmpty() const const
QString trimmed() const const
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const const
home address
Definition: address.h:70
QStringList split(const QString &sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
bool isValid() const const
void setRegion(const QString &region)
Sets the region, e.g.
Definition: address.cpp:440
void setName(const QString &name)
Sets the i18n&#39;d name of the contact group.
QString toLower() const const
void setNickName(const QString &nickName)
Set nick name.
Definition: addressee.cpp:740
PhoneNumber phoneNumber(PhoneNumber::Type type) const
Return phone number, which matches the given type.
Definition: addressee.cpp:1745
void setName(const QString &name)
Sets the name of the contact data object.
void setPostalCode(const QString &code)
Sets the postal code.
Definition: address.cpp:456
bool isValid() const const
QVector::const_iterator constBegin() const const
int count() const
Returns the number of contacts in this group.
QDateTime currentDateTime()
QString email() const
Returns the email address of the contact data object.
QByteArray toLatin1() const const
QString mid(int position, int n) const const
QDate date() const const
void setNote(const QString &note)
Set note.
Definition: addressee.cpp:1179
Postal address information.
Definition: address.h:28
void setPostOfficeBox(const QString &postOfficeBox)
Sets the post office box.
Definition: address.cpp:376
bool isEmpty() const const
void setCountry(const QString &country)
Sets the country.
Definition: address.cpp:472
This class represents a contact data object.
Definition: contactgroup.h:223
int dataCount() const
Returns the number of contact data objects in this group.
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
void setRevision(const QDateTime &revision)
Set revision date.
Definition: addressee.cpp:1219
QTextCodec * codecForName(const QByteArray &name)
static QString ISOtoCountry(const QString &ISOname)
Returns a localized country name for a ISO code.
Definition: address.cpp:673
typedef ConstIterator
int count(const T &value) const const
void setBirthday(const QDateTime &birthday, bool withTime=true)
Set birthday (date and time).
Definition: addressee.cpp:791
int length() const const
address book entry
Definition: addressee.h:69
void append(const ContactReference &reference)
Appends a new contact reference to the contact group.
QList::const_iterator constEnd() const const
Data & data(int index)
Returns the contact data object at the given index.
QList::const_iterator constBegin() const const
address at work
Definition: address.h:71
int year() const const
int month() const const
void setRole(const QString &role)
Set role.
Definition: addressee.cpp:1057
Phonenumber information.
Definition: phonenumber.h:28
void insertAddress(const Address &address)
Insert an address.
Definition: addressee.cpp:1978
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Jun 17 2021 22:54:54 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.