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;
264  bool end = false;
265  Ldif ldif;
266  Ldif::ParseValue ret;
267  Addressee a;
268  Address homeAddr;
269  Address workAddr;
270  int birthday = -1;
271  int birthmonth = -1;
272  int birthyear = -1;
273  ContactGroup contactGroup;
274  ldif.setLdif(str.toLatin1());
275  QDateTime qdt = dt;
276  if (!qdt.isValid()) {
278  }
279  a.setRevision(qdt);
280  homeAddr = Address(Address::Home);
281  workAddr = Address(Address::Work);
282 
283  do {
284  ret = ldif.nextItem();
285  switch (ret) {
286  case Ldif::Item: {
287  QString fieldname = ldif.attr().toLower();
288  QString value = QString::fromUtf8(ldif.value());
289  evaluatePair(a, homeAddr, workAddr, fieldname, value, birthday, birthmonth, birthyear, contactGroup);
290  break;
291  }
292  case Ldif::EndEntry:
293  if (contactGroup.count() == 0) {
294  // if the new address is not empty, append it
295  QDate birthDate(birthyear, birthmonth, birthday);
296  if (birthDate.isValid()) {
297  a.setBirthday(birthDate);
298  }
299 
300  if (!a.formattedName().isEmpty() || !a.name().isEmpty() || !a.familyName().isEmpty()) {
301  if (!homeAddr.isEmpty()) {
302  a.insertAddress(homeAddr);
303  }
304  if (!workAddr.isEmpty()) {
305  a.insertAddress(workAddr);
306  }
307  addrList.append(a);
308  }
309  } else {
310  contactGroupList.append(contactGroup);
311  }
312  a = Addressee();
313  contactGroup = ContactGroup();
314  a.setRevision(qdt);
315  homeAddr = Address(Address::Home);
316  workAddr = Address(Address::Work);
317  break;
318  case Ldif::MoreData:
319  if (endldif) {
320  end = true;
321  } else {
322  ldif.endLdif();
323  endldif = true;
324  break;
325  }
326  default:
327  break;
328  }
329  } while (!end);
330 
331  return true;
332 }
333 
334 void KContacts::evaluatePair(Addressee &a,
335  Address &homeAddr,
336  Address &workAddr,
337  QString &fieldname,
338  QString &value,
339  int &birthday,
340  int &birthmonth,
341  int &birthyear,
342  ContactGroup &contactGroup)
343 {
344  if (fieldname == QLatin1String("dn")) { // ignore
345  return;
346  }
347 
348  if (fieldname.startsWith(QLatin1Char('#'))) {
349  return;
350  }
351 
352  if (fieldname.isEmpty() && !a.note().isEmpty()) {
353  // some LDIF export filters are broken and add additional
354  // comments on stand-alone lines. Just add them to the notes for now.
355  a.setNote(a.note() + QLatin1Char('\n') + value);
356  return;
357  }
358 
359  if (fieldname == QLatin1String("givenname")) {
360  a.setGivenName(value);
361  return;
362  }
363 
364  if (fieldname == QLatin1String("xmozillanickname") //
365  || fieldname == QLatin1String("nickname") //
366  || fieldname == QLatin1String("mozillanickname")) {
367  a.setNickName(value);
368  return;
369  }
370 
371  if (fieldname == QLatin1String("sn")) {
372  a.setFamilyName(value);
373  return;
374  }
375 
376  if (fieldname == QLatin1String("uid")) {
377  a.setUid(value);
378  return;
379  }
380  if (fieldname == QLatin1String("mail") //
381  || fieldname == QLatin1String("mozillasecondemail") /* mozilla */
382  || fieldname == QLatin1String("othermailbox") /*TheBat!*/) {
383  if (a.emails().indexOf(value) == -1) {
384  a.insertEmail(value);
385  }
386  return;
387  }
388 
389  if (fieldname == QLatin1String("title")) {
390  a.setTitle(value);
391  return;
392  }
393 
394  if (fieldname == QLatin1String("vocation")) {
395  a.setPrefix(value);
396  return;
397  }
398 
399  if (fieldname == QLatin1String("cn")) {
400  a.setFormattedName(value);
401  return;
402  }
403 
404  if (fieldname == QLatin1Char('o') || fieldname == QLatin1String("organization") // Exchange
405  || fieldname == QLatin1String("organizationname")) { // Exchange
406  a.setOrganization(value);
407  return;
408  }
409 
410  // clang-format off
411  if (fieldname == QLatin1String("description")
412  || fieldname == QLatin1String("mozillacustom1")
413  || fieldname == QLatin1String("mozillacustom2")
414  || fieldname == QLatin1String("mozillacustom3")
415  || fieldname == QLatin1String("mozillacustom4")
416  || fieldname == QLatin1String("custom1")
417  || fieldname == QLatin1String("custom2")
418  || fieldname == QLatin1String("custom3")
419  || fieldname == QLatin1String("custom4")) {
420  if (!a.note().isEmpty()) {
421  a.setNote(a.note() + QLatin1Char('\n'));
422  }
423  a.setNote(a.note() + value);
424  return;
425  }
426  // clang-format on
427 
428  if (fieldname == QLatin1String("homeurl") //
429  || fieldname == QLatin1String("workurl") //
430  || fieldname == QLatin1String("mozillahomeurl")) {
431  if (a.url().url().isEmpty()) {
432  ResourceLocatorUrl url;
433  url.setUrl(QUrl(value));
434  a.setUrl(url);
435  return;
436  }
437  if (a.url().url().toDisplayString() == QUrl(value).toDisplayString()) {
438  return;
439  }
440  // TODO: current version of kabc only supports one URL.
441  // TODO: change this with KDE 4
442  }
443 
444  if (fieldname == QLatin1String("homephone")) {
446  return;
447  }
448 
449  if (fieldname == QLatin1String("telephonenumber")) {
451  return;
452  }
453  if (fieldname == QLatin1String("mobile") /* mozilla/Netscape 7 */
454  || fieldname == QLatin1String("cellphone")) {
456  return;
457  }
458 
459  if (fieldname == QLatin1String("pager") // mozilla
460  || fieldname == QLatin1String("pagerphone")) { // mozilla
462  return;
463  }
464 
465  if (fieldname == QLatin1String("facsimiletelephonenumber")) {
467  return;
468  }
469 
470  if (fieldname == QLatin1String("xmozillaanyphone")) { // mozilla
472  return;
473  }
474 
475  if (fieldname == QLatin1String("streethomeaddress") //
476  || fieldname == QLatin1String("mozillahomestreet")) { // thunderbird
477  homeAddr.setStreet(value);
478  return;
479  }
480 
481  if (fieldname == QLatin1String("street") //
482  || fieldname == QLatin1String("postaladdress")) { // mozilla
483  workAddr.setStreet(value);
484  return;
485  }
486  if (fieldname == QLatin1String("mozillapostaladdress2") //
487  || fieldname == QLatin1String("mozillaworkstreet2")) { // mozilla
488  workAddr.setStreet(workAddr.street() + QLatin1Char('\n') + value);
489  return;
490  }
491 
492  if (fieldname == QLatin1String("postalcode")) {
493  workAddr.setPostalCode(value);
494  return;
495  }
496 
497  if (fieldname == QLatin1String("postofficebox")) {
498  workAddr.setPostOfficeBox(value);
499  return;
500  }
501 
502  if (fieldname == QLatin1String("homepostaladdress")) { // Netscape 7
503  homeAddr.setStreet(value);
504  return;
505  }
506 
507  if (fieldname == QLatin1String("mozillahomepostaladdress2")) { // mozilla
508  homeAddr.setStreet(homeAddr.street() + QLatin1Char('\n') + value);
509  return;
510  }
511 
512  if (fieldname == QLatin1String("mozillahomelocalityname")) { // mozilla
513  homeAddr.setLocality(value);
514  return;
515  }
516 
517  if (fieldname == QLatin1String("mozillahomestate")) { // mozilla
518  homeAddr.setRegion(value);
519  return;
520  }
521 
522  if (fieldname == QLatin1String("mozillahomepostalcode")) { // mozilla
523  homeAddr.setPostalCode(value);
524  return;
525  }
526 
527  if (fieldname == QLatin1String("mozillahomecountryname")) { // mozilla
528  if (value.length() <= 2) {
529  value = Address::ISOtoCountry(value);
530  }
531  homeAddr.setCountry(value);
532  return;
533  }
534 
535  if (fieldname == QLatin1String("locality")) {
536  workAddr.setLocality(value);
537  return;
538  }
539 
540  if (fieldname == QLatin1String("streetaddress")) { // Netscape 4.x
541  workAddr.setStreet(value);
542  return;
543  }
544 
545  if (fieldname == QLatin1String("countryname") //
546  || fieldname == QLatin1Char('c')) { // mozilla
547  if (value.length() <= 2) {
548  value = Address::ISOtoCountry(value);
549  }
550  workAddr.setCountry(value);
551  return;
552  }
553 
554  if (fieldname == QLatin1Char('l')) { // mozilla
555  workAddr.setLocality(value);
556  return;
557  }
558 
559  if (fieldname == QLatin1String("st")) {
560  workAddr.setRegion(value);
561  return;
562  }
563 
564  if (fieldname == QLatin1String("ou")) {
565  a.setRole(value);
566  return;
567  }
568 
569  if (fieldname == QLatin1String("department")) {
570  a.setDepartment(value);
571  return;
572  }
573 
574  if (fieldname == QLatin1String("member")) {
575  // this is a mozilla list member (cn=xxx, mail=yyy)
576  const QStringList list = value.split(QLatin1Char(','));
577  QString name;
578  QString email;
579 
581  const QStringList::ConstIterator end(list.constEnd());
582  for (it = list.constBegin(); it != end; ++it) {
583  if ((*it).startsWith(QLatin1String("cn="))) {
584  name = (*it).mid(3).trimmed();
585  }
586  if ((*it).startsWith(QLatin1String("mail="))) {
587  email = (*it).mid(5).trimmed();
588  }
589  }
590  if (!name.isEmpty() && !email.isEmpty()) {
591  email = QLatin1String(" <") + email + QLatin1Char('>');
592  }
593  ContactGroup::Data data;
594  data.setEmail(email);
595  data.setName(name);
596  contactGroup.append(data);
597  return;
598  }
599 
600  if (fieldname == QLatin1String("modifytimestamp")) {
601  if (value == QLatin1String("0Z")) { // ignore
602  return;
603  }
604  QDateTime dt = VCardStringToDate(value);
605  if (dt.isValid()) {
606  a.setRevision(dt);
607  return;
608  }
609  }
610 
611  if (fieldname == QLatin1String("display-name")) {
612  contactGroup.setName(value);
613  return;
614  }
615 
616  if (fieldname == QLatin1String("objectclass")) { // ignore
617  return;
618  }
619 
620  if (fieldname == QLatin1String("birthyear")) {
621  bool ok;
622  birthyear = value.toInt(&ok);
623  if (!ok) {
624  birthyear = -1;
625  }
626  return;
627  }
628  if (fieldname == QLatin1String("birthmonth")) {
629  birthmonth = value.toInt();
630  return;
631  }
632  if (fieldname == QLatin1String("birthday")) {
633  birthday = value.toInt();
634  return;
635  }
636  if (fieldname == QLatin1String("xbatbirthday")) {
637  QDate dt = QDate::fromString(value, QStringLiteral("yyyyMMdd"));
638  if (dt.isValid()) {
639  a.setBirthday(dt);
640  }
641  return;
642  }
643  qCWarning(KCONTACTS_LOG) << QStringLiteral("LDIFConverter: Unknown field for '%1': '%2=%3'\n").arg(a.formattedName(), fieldname, value);
644 }
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 Mon Sep 20 2021 22:56:07 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.