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

kabc

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

Skip menu "kdepimlibs 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

Search



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