KContacts

ldifconverter.cpp
1 /*
2  This file is part of the KContacts framework.
3  SPDX-FileCopyrightText: 2003 Helge Deller <[email protected].org>
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 "vcardconverter.h"
24 #include "address.h"
25 #include "addressee.h"
26 #include "kcontacts_debug.h"
27 
28 #include "ldif_p.h"
29 
30 #include <KLocalizedString>
31 
32 #include <QStringList>
33 #include <QTextCodec>
34 #include <QTextStream>
35 
36 using namespace KContacts;
37 
38 /* internal functions - do not use !! */
39 
40 namespace KContacts {
53 void evaluatePair(Addressee &a, Address &homeAddr, Address &workAddr, QString &fieldname, QString &value, int &birthday, int &birthmonth, int &birthyear, ContactGroup &contactGroup);
54 }
55 
56 /* generate LDIF stream */
57 
58 static void ldif_out(QTextStream &t, const QString &formatStr, const QString &value)
59 {
60  if (value.isEmpty()) {
61  return;
62  }
63 
64  const QByteArray txt = Ldif::assembleLine(formatStr, value, 72);
65 
66  // write the string
67  t << QString::fromUtf8(txt) << "\n";
68 }
69 
70 bool LDIFConverter::addresseeAndContactGroupToLDIF(const AddresseeList &addrList, const ContactGroup::List &contactGroupList, QString &str)
71 {
72  bool result = addresseeToLDIF(addrList, str);
73  if (!contactGroupList.isEmpty()) {
74  result = (contactGroupToLDIF(contactGroupList, str) || result); //order matters
75  }
76  return result;
77 }
78 
80 {
81  if (contactGroup.dataCount() <= 0) {
82  return false;
83  }
86  t << "objectclass: top\n";
87  t << "objectclass: groupOfNames\n";
88 
89  for (int i = 0; i < contactGroup.dataCount(); ++i) {
90  const ContactGroup::Data &data = contactGroup.data(i);
91  const QString value = QStringLiteral("cn=%1,mail=%2").arg(data.name(), data.email());
92  ldif_out(t, QStringLiteral("member"), value);
93  }
94 
95  t << "\n";
96  return true;
97 }
98 
100 {
101  if (contactGroupList.count() <= 0) {
102  return false;
103  }
104 
105  bool result = true;
107  const ContactGroup::List::ConstIterator end(contactGroupList.constEnd());
108  for (it = contactGroupList.constBegin(); it != end; ++it) {
109  result = (contactGroupToLDIF(*it, str) || result); //order matters
110  }
111  return result;
112 }
113 
115 {
116  if (addrList.count() <= 0) {
117  return false;
118  }
119 
120  bool result = true;
122  const AddresseeList::ConstIterator end(addrList.constEnd());
123  for (it = addrList.constBegin(); it != end; ++it) {
124  result = (addresseeToLDIF(*it, str) || result); //order matters
125  }
126  return result;
127 }
128 
130 {
131  if (addr.isEmpty()) {
132  return false;
133  }
134 
137 
138  const Address homeAddr = addr.address(Address::Home);
139  const Address workAddr = addr.address(Address::Work);
140 
141  ldif_out(t, QStringLiteral("dn"), QStringLiteral("cn=%1,mail=%2").
142  arg(addr.formattedName().simplified(), addr.preferredEmail()));
143  t << "objectclass: top\n";
144  t << "objectclass: person\n";
145  t << "objectclass: organizationalPerson\n";
146 
147  ldif_out(t, QStringLiteral("givenname"), addr.givenName());
148  ldif_out(t, QStringLiteral("sn"), addr.familyName());
149  ldif_out(t, QStringLiteral("cn"), addr.formattedName().simplified());
150  ldif_out(t, QStringLiteral("uid"), addr.uid());
151  ldif_out(t, QStringLiteral("nickname"), addr.nickName());
152  ldif_out(t, QStringLiteral("xmozillanickname"), addr.nickName());
153  ldif_out(t, QStringLiteral("mozillanickname"), addr.nickName());
154 
155  ldif_out(t, QStringLiteral("mail"), addr.preferredEmail());
156  const QStringList emails = addr.emails();
157  const int numEmails = emails.count();
158  for (int i = 1; i < numEmails; ++i) {
159  if (i == 0) {
160  //nothing
161  } else if (i == 1) {
162  ldif_out(t, QStringLiteral("mozillasecondemail"), emails[1]);
163  } else {
164  ldif_out(t, QStringLiteral("othermailbox"), emails[i]);
165  }
166  }
167  //ldif_out( t, "mozilla_AIMScreenName: %1\n", "screen_name" );
168 
169  ldif_out(t, QStringLiteral("telephonenumber"),
170  addr.phoneNumber(PhoneNumber::Work).number());
171  ldif_out(t, QStringLiteral("facsimiletelephonenumber"),
172  addr.phoneNumber(PhoneNumber::Fax).number());
173  ldif_out(t, QStringLiteral("homephone"),
174  addr.phoneNumber(PhoneNumber::Home).number());
175  ldif_out(t, QStringLiteral("mobile"),
176  addr.phoneNumber(PhoneNumber::Cell).number()); // Netscape 7
177  ldif_out(t, QStringLiteral("cellphone"),
178  addr.phoneNumber(PhoneNumber::Cell).number()); // Netscape 4.x
179  ldif_out(t, QStringLiteral("pager"),
180  addr.phoneNumber(PhoneNumber::Pager).number());
181  ldif_out(t, QStringLiteral("pagerphone"),
182  addr.phoneNumber(PhoneNumber::Pager).number());
183 
184  ldif_out(t, QStringLiteral("streethomeaddress"), homeAddr.street());
185  ldif_out(t, QStringLiteral("postalcode"), workAddr.postalCode());
186  ldif_out(t, QStringLiteral("postofficebox"), workAddr.postOfficeBox());
187 
188  QStringList streets = homeAddr.street().split(QLatin1Char('\n'));
189  const int numberOfStreets(streets.count());
190  if (numberOfStreets > 0) {
191  ldif_out(t, QStringLiteral("homepostaladdress"), streets.at(0)); // Netscape 7
192  }
193  if (numberOfStreets > 1) {
194  ldif_out(t, QStringLiteral("mozillahomepostaladdress2"), streets.at(1)); // Netscape 7
195  }
196  ldif_out(t, QStringLiteral("mozillahomelocalityname"), homeAddr.locality()); // Netscape 7
197  ldif_out(t, QStringLiteral("mozillahomestate"), homeAddr.region());
198  ldif_out(t, QStringLiteral("mozillahomepostalcode"), homeAddr.postalCode());
199  ldif_out(t, QStringLiteral("mozillahomecountryname"),
200  Address::ISOtoCountry(homeAddr.country()));
201  ldif_out(t, QStringLiteral("locality"), workAddr.locality());
202  ldif_out(t, QStringLiteral("streetaddress"), workAddr.street()); // Netscape 4.x
203 
204  streets = workAddr.street().split(QLatin1Char('\n'));
205  const int streetsCount = streets.count();
206  if (streetsCount > 0) {
207  ldif_out(t, QStringLiteral("street"), streets.at(0));
208  }
209  if (streetsCount > 1) {
210  ldif_out(t, QStringLiteral("mozillaworkstreet2"), streets.at(1));
211  }
212  ldif_out(t, QStringLiteral("countryname"), Address::ISOtoCountry(workAddr.country()));
213  ldif_out(t, QStringLiteral("l"), workAddr.locality());
214  ldif_out(t, QStringLiteral("c"), Address::ISOtoCountry(workAddr.country()));
215  ldif_out(t, QStringLiteral("st"), workAddr.region());
216 
217  ldif_out(t, QStringLiteral("title"), addr.title());
218  ldif_out(t, QStringLiteral("vocation"), addr.prefix());
219  ldif_out(t, QStringLiteral("ou"), addr.role());
220  ldif_out(t, QStringLiteral("o"), addr.organization());
221  ldif_out(t, QStringLiteral("organization"), addr.organization());
222  ldif_out(t, QStringLiteral("organizationname"), addr.organization());
223 
224  // Compatibility with older kabc versions.
225  if (!addr.department().isEmpty()) {
226  ldif_out(t, QStringLiteral("department"), addr.department());
227  } else {
228  ldif_out(t, QStringLiteral("department"), addr.custom(QStringLiteral("KADDRESSBOOK"),
229  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  {
286  QString fieldname = ldif.attr().toLower();
287  QString value = QString::fromUtf8(ldif.value());
288  evaluatePair(a, homeAddr, workAddr, fieldname, value, birthday, birthmonth, birthyear, contactGroup);
289  break;
290  }
291  case Ldif::EndEntry:
292  if (contactGroup.count() == 0) {
293  // if the new address is not empty, append it
294  QDate birthDate(birthyear, birthmonth, birthday);
295  if (birthDate.isValid()) {
296  a.setBirthday(birthDate);
297  }
298 
299  if (!a.formattedName().isEmpty() || !a.name().isEmpty()
300  || !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, Address &homeAddr, Address &workAddr, QString &fieldname, QString &value, int &birthday, int &birthmonth, int &birthyear, ContactGroup &contactGroup)
335 {
336  if (fieldname == QLatin1String("dn")) { // ignore
337  return;
338  }
339 
340  if (fieldname.startsWith(QLatin1Char('#'))) {
341  return;
342  }
343 
344  if (fieldname.isEmpty() && !a.note().isEmpty()) {
345  // some LDIF export filters are borken and add additional
346  // comments on stand-alone lines. Just add them to the notes for now.
347  a.setNote(a.note() + QLatin1Char('\n') + value);
348  return;
349  }
350 
351  if (fieldname == QLatin1String("givenname")) {
352  a.setGivenName(value);
353  return;
354  }
355 
356  if (fieldname == QLatin1String("xmozillanickname")
357  || fieldname == QLatin1String("nickname")
358  || fieldname == QLatin1String("mozillanickname")) {
359  a.setNickName(value);
360  return;
361  }
362 
363  if (fieldname == QLatin1String("sn")) {
364  a.setFamilyName(value);
365  return;
366  }
367 
368  if (fieldname == QLatin1String("uid")) {
369  a.setUid(value);
370  return;
371  }
372  if (fieldname == QLatin1String("mail")
373  || fieldname == QLatin1String("mozillasecondemail") /* mozilla */
374  || fieldname == QLatin1String("othermailbox") /*TheBat!*/) {
375  if (a.emails().indexOf(value) == -1) {
376  a.insertEmail(value);
377  }
378  return;
379  }
380 
381  if (fieldname == QLatin1String("title")) {
382  a.setTitle(value);
383  return;
384  }
385 
386  if (fieldname == QLatin1String("vocation")) {
387  a.setPrefix(value);
388  return;
389  }
390 
391  if (fieldname == QLatin1String("cn")) {
392  a.setFormattedName(value);
393  return;
394  }
395 
396  if (fieldname == QLatin1Char('o')
397  || fieldname == QLatin1String("organization") // Exchange
398  || fieldname == QLatin1String("organizationname")) { // Exchange
399  a.setOrganization(value);
400  return;
401  }
402 
403  if (fieldname == QLatin1String("description")
404  || fieldname == QLatin1String("mozillacustom1")
405  || fieldname == QLatin1String("mozillacustom2")
406  || fieldname == QLatin1String("mozillacustom3")
407  || fieldname == QLatin1String("mozillacustom4")
408  || fieldname == QLatin1String("custom1")
409  || fieldname == QLatin1String("custom2")
410  || fieldname == QLatin1String("custom3")
411  || fieldname == QLatin1String("custom4")) {
412  if (!a.note().isEmpty()) {
413  a.setNote(a.note() + QLatin1Char('\n'));
414  }
415  a.setNote(a.note() + value);
416  return;
417  }
418 
419  if (fieldname == QLatin1String("homeurl")
420  || fieldname == QLatin1String("workurl")
421  || fieldname == QLatin1String("mozillahomeurl")) {
422  if (a.url().url().isEmpty()) {
423  ResourceLocatorUrl url;
424  url.setUrl(QUrl(value));
425  a.setUrl(url);
426  return;
427  }
428  if (a.url().url().toDisplayString() == QUrl(value).toDisplayString()) {
429  return;
430  }
431  // TODO: current version of kabc only supports one URL.
432  // TODO: change this with KDE 4
433  }
434 
435  if (fieldname == QLatin1String("homephone")) {
437  return;
438  }
439 
440  if (fieldname == QLatin1String("telephonenumber")) {
442  return;
443  }
444  if (fieldname == QLatin1String("mobile") /* mozilla/Netscape 7 */
445  || fieldname == QLatin1String("cellphone")) {
447  return;
448  }
449 
450  if (fieldname == QLatin1String("pager") // mozilla
451  || fieldname == QLatin1String("pagerphone")) { // mozilla
453  return;
454  }
455 
456  if (fieldname == QLatin1String("facsimiletelephonenumber")) {
458  return;
459  }
460 
461  if (fieldname == QLatin1String("xmozillaanyphone")) { // mozilla
463  return;
464  }
465 
466  if (fieldname == QLatin1String("streethomeaddress")
467  || fieldname == QLatin1String("mozillahomestreet")) { // thunderbird
468  homeAddr.setStreet(value);
469  return;
470  }
471 
472  if (fieldname == QLatin1String("street")
473  || fieldname == QLatin1String("postaladdress")) { // mozilla
474  workAddr.setStreet(value);
475  return;
476  }
477  if (fieldname == QLatin1String("mozillapostaladdress2")
478  || fieldname == QLatin1String("mozillaworkstreet2")) { // mozilla
479  workAddr.setStreet(workAddr.street() + QLatin1Char('\n') + value);
480  return;
481  }
482 
483  if (fieldname == QLatin1String("postalcode")) {
484  workAddr.setPostalCode(value);
485  return;
486  }
487 
488  if (fieldname == QLatin1String("postofficebox")) {
489  workAddr.setPostOfficeBox(value);
490  return;
491  }
492 
493  if (fieldname == QLatin1String("homepostaladdress")) { // Netscape 7
494  homeAddr.setStreet(value);
495  return;
496  }
497 
498  if (fieldname == QLatin1String("mozillahomepostaladdress2")) { // mozilla
499  homeAddr.setStreet(homeAddr.street() + QLatin1Char('\n') + value);
500  return;
501  }
502 
503  if (fieldname == QLatin1String("mozillahomelocalityname")) { // mozilla
504  homeAddr.setLocality(value);
505  return;
506  }
507 
508  if (fieldname == QLatin1String("mozillahomestate")) { // mozilla
509  homeAddr.setRegion(value);
510  return;
511  }
512 
513  if (fieldname == QLatin1String("mozillahomepostalcode")) { // mozilla
514  homeAddr.setPostalCode(value);
515  return;
516  }
517 
518  if (fieldname == QLatin1String("mozillahomecountryname")) { // mozilla
519  if (value.length() <= 2) {
520  value = Address::ISOtoCountry(value);
521  }
522  homeAddr.setCountry(value);
523  return;
524  }
525 
526  if (fieldname == QLatin1String("locality")) {
527  workAddr.setLocality(value);
528  return;
529  }
530 
531  if (fieldname == QLatin1String("streetaddress")) { // Netscape 4.x
532  workAddr.setStreet(value);
533  return;
534  }
535 
536  if (fieldname == QLatin1String("countryname")
537  || fieldname == QLatin1Char('c')) { // mozilla
538  if (value.length() <= 2) {
539  value = Address::ISOtoCountry(value);
540  }
541  workAddr.setCountry(value);
542  return;
543  }
544 
545  if (fieldname == QLatin1Char('l')) { // mozilla
546  workAddr.setLocality(value);
547  return;
548  }
549 
550  if (fieldname == QLatin1String("st")) {
551  workAddr.setRegion(value);
552  return;
553  }
554 
555  if (fieldname == QLatin1String("ou")) {
556  a.setRole(value);
557  return;
558  }
559 
560  if (fieldname == QLatin1String("department")) {
561  a.setDepartment(value);
562  return;
563  }
564 
565  if (fieldname == QLatin1String("member")) {
566  // this is a mozilla list member (cn=xxx, mail=yyy)
567  const QStringList list = value.split(QLatin1Char(','));
568  QString name, email;
569 
571  const QStringList::ConstIterator end(list.constEnd());
572  for (it = list.constBegin(); it != end; ++it) {
573  if ((*it).startsWith(QLatin1String("cn="))) {
574  name = (*it).mid(3).trimmed();
575  }
576  if ((*it).startsWith(QLatin1String("mail="))) {
577  email = (*it).mid(5).trimmed();
578  }
579  }
580  if (!name.isEmpty() && !email.isEmpty()) {
581  email = QLatin1String(" <") + email + QLatin1Char('>');
582  }
583  ContactGroup::Data data;
584  data.setEmail(email);
585  data.setName(name);
586  contactGroup.append(data);
587  return;
588  }
589 
590  if (fieldname == QLatin1String("modifytimestamp")) {
591  if (value == QLatin1String("0Z")) { // ignore
592  return;
593  }
594  QDateTime dt = VCardStringToDate(value);
595  if (dt.isValid()) {
596  a.setRevision(dt);
597  return;
598  }
599  }
600 
601  if (fieldname == QLatin1String("display-name")) {
602  contactGroup.setName(value);
603  return;
604  }
605 
606  if (fieldname == QLatin1String("objectclass")) { // ignore
607  return;
608  }
609 
610  if (fieldname == QLatin1String("birthyear")) {
611  bool ok;
612  birthyear = value.toInt(&ok);
613  if (!ok) {
614  birthyear = -1;
615  }
616  return;
617  }
618  if (fieldname == QLatin1String("birthmonth")) {
619  birthmonth = value.toInt();
620  return;
621  }
622  if (fieldname == QLatin1String("birthday")) {
623  birthday = value.toInt();
624  return;
625  }
626  if (fieldname == QLatin1String("xbatbirthday")) {
627  QDate dt = QDate::fromString(value, QStringLiteral("yyyyMMdd"));
628  if (dt.isValid()) {
629  a.setBirthday(dt);
630  }
631  return;
632  }
633  qCWarning(KCONTACTS_LOG) << QStringLiteral("LDIFConverter: Unknown field for '%1': '%2=%3'\n").
634  arg(a.formattedName(), fieldname, value);
635 }
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:2264
void setFormattedName(const QString &formattedName)
Set formatted name.
Definition: addressee.cpp:619
QString toDisplayString(QUrl::FormattingOptions options) const const
void setLocality(const QString &locality)
Sets the locality, e.g.
Definition: address.cpp:419
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:1716
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:32
void setUid(const QString &uid)
Set unique identifier.
Definition: addressee.cpp:403
QVector::const_iterator constEnd() const const
QString simplified() const const
void setStreet(const QString &street)
Sets the street (including house number).
Definition: address.cpp:403
void setPrefix(const QString &prefix)
Set honorific prefixes.
Definition: addressee.cpp:699
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:659
typedef ConstIterator
void setDepartment(const QString &department)
Set department.
Definition: addressee.cpp:1158
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:1583
Address address(Address::Type type) const
Return address, which matches the given type.
Definition: addressee.cpp:2008
void setUrl(const ResourceLocatorUrl &url)
Set homepage.
Definition: addressee.cpp:1265
void setOrganization(const QString &organization)
Set organization.
Definition: addressee.cpp:1107
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:1005
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:639
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:69
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:435
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:739
PhoneNumber phoneNumber(PhoneNumber::Type type) const
Return phone number, which matches the given type.
Definition: addressee.cpp:1744
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:451
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:1178
Postal address information.
Definition: address.h:27
void setPostOfficeBox(const QString &postOfficeBox)
Sets the post office box.
Definition: address.cpp:371
bool isEmpty() const const
void setCountry(const QString &country)
Sets the country.
Definition: address.cpp:467
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:1218
QTextCodec * codecForName(const QByteArray &name)
static QString ISOtoCountry(const QString &ISOname)
Returns a localized country name for a ISO code.
Definition: address.cpp:668
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:790
int length() const const
address book entry
Definition: addressee.h:68
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:70
int year() const const
int month() const const
void setRole(const QString &role)
Set role.
Definition: addressee.cpp:1056
Phonenumber information.
Definition: phonenumber.h:27
void insertAddress(const Address &address)
Insert an address.
Definition: addressee.cpp:1977
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Sep 21 2020 22:55:32 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.