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

kabc

  • sources
  • kde-4.12
  • kdepimlibs
  • kabc
vcardtool.cpp
1 /*
2  This file is part of libkabc.
3  Copyright (c) 2003 Tobias Koenig <tokoe@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 #include "vcardtool.h"
22 #include "key.h"
23 #include "picture.h"
24 #include "secrecy.h"
25 #include "sound.h"
26 
27 #include <QtCore/QString>
28 #include <QtCore/QBuffer>
29 
30 using namespace KABC;
31 
32 static bool needsEncoding( const QString &value )
33 {
34  uint length = value.length();
35  for ( uint i = 0; i < length; ++i ) {
36  char c = value.at( i ).toLatin1();
37  if ( ( c < 33 || c > 126 ) && c != ' ' && c != '=' ) {
38  return true;
39  }
40  }
41 
42  return false;
43 }
44 
45 VCardTool::VCardTool()
46 {
47  mAddressTypeMap.insert( QLatin1String( "dom" ), Address::Dom );
48  mAddressTypeMap.insert( QLatin1String( "intl" ), Address::Intl );
49  mAddressTypeMap.insert( QLatin1String( "postal" ), Address::Postal );
50  mAddressTypeMap.insert( QLatin1String( "parcel" ), Address::Parcel );
51  mAddressTypeMap.insert( QLatin1String( "home" ), Address::Home );
52  mAddressTypeMap.insert( QLatin1String( "work" ), Address::Work );
53  mAddressTypeMap.insert( QLatin1String( "pref" ), Address::Pref );
54 
55  mPhoneTypeMap.insert( QLatin1String( "HOME" ), PhoneNumber::Home );
56  mPhoneTypeMap.insert( QLatin1String( "WORK" ), PhoneNumber::Work );
57  mPhoneTypeMap.insert( QLatin1String( "MSG" ), PhoneNumber::Msg );
58  mPhoneTypeMap.insert( QLatin1String( "PREF" ), PhoneNumber::Pref );
59  mPhoneTypeMap.insert( QLatin1String( "VOICE" ), PhoneNumber::Voice );
60  mPhoneTypeMap.insert( QLatin1String( "FAX" ), PhoneNumber::Fax );
61  mPhoneTypeMap.insert( QLatin1String( "CELL" ), PhoneNumber::Cell );
62  mPhoneTypeMap.insert( QLatin1String( "VIDEO" ), PhoneNumber::Video );
63  mPhoneTypeMap.insert( QLatin1String( "BBS" ), PhoneNumber::Bbs );
64  mPhoneTypeMap.insert( QLatin1String( "MODEM" ), PhoneNumber::Modem );
65  mPhoneTypeMap.insert( QLatin1String( "CAR" ), PhoneNumber::Car );
66  mPhoneTypeMap.insert( QLatin1String( "ISDN" ), PhoneNumber::Isdn );
67  mPhoneTypeMap.insert( QLatin1String( "PCS" ), PhoneNumber::Pcs );
68  mPhoneTypeMap.insert( QLatin1String( "PAGER" ), PhoneNumber::Pager );
69 }
70 
71 VCardTool::~VCardTool()
72 {
73 }
74 
75 QByteArray VCardTool::exportVCards( const Addressee::List &list, VCard::Version version ) const
76 {
77  return createVCards( list, version, true /*export vcard*/);
78 }
79 
80 QByteArray VCardTool::createVCards( const Addressee::List &list, VCard::Version version ) const
81 {
82  return createVCards( list, version, false /*don't export*/);
83 }
84 
85 QByteArray VCardTool::createVCards( const Addressee::List &list,
86  VCard::Version version, bool exportVcard ) const
87 {
88  VCard::List vCardList;
89 
90  Addressee::List::ConstIterator addrIt;
91  Addressee::List::ConstIterator listEnd( list.constEnd() );
92  for ( addrIt = list.constBegin(); addrIt != listEnd; ++addrIt ) {
93  VCard card;
94  QStringList::ConstIterator strIt;
95 
96  // ADR + LABEL
97  const Address::List addresses = ( *addrIt ).addresses();
98  for ( Address::List::ConstIterator it = addresses.begin(); it != addresses.end(); ++it ) {
99  QStringList address;
100 
101  const bool isEmpty = ( ( *it ).postOfficeBox().isEmpty() &&
102  ( *it ).extended().isEmpty() &&
103  ( *it ).street().isEmpty() &&
104  ( *it ).locality().isEmpty() &&
105  ( *it ).region().isEmpty() &&
106  ( *it ).postalCode().isEmpty() &&
107  ( *it ).country().isEmpty() );
108 
109  address.append( ( *it ).postOfficeBox().replace( QLatin1Char( ';' ),
110  QLatin1String( "\\;" ) ) );
111 
112  address.append( ( *it ).extended().replace( QLatin1Char( ';' ),
113  QLatin1String( "\\;" ) ) );
114 
115  address.append( ( *it ).street().replace( QLatin1Char( ';' ),
116  QLatin1String( "\\;" ) ) );
117 
118  address.append( ( *it ).locality().replace( QLatin1Char( ';' ),
119  QLatin1String( "\\;" ) ) );
120 
121  address.append( ( *it ).region().replace( QLatin1Char( ';' ),
122  QLatin1String( "\\;" ) ) );
123 
124  address.append( ( *it ).postalCode().replace( QLatin1Char( ';' ),
125  QLatin1String( "\\;" ) ) );
126 
127  address.append( ( *it ).country().replace( QLatin1Char( ';' ),
128  QLatin1String( "\\;" ) ) );
129 
130  VCardLine adrLine( QLatin1String( "ADR" ), address.join( QLatin1String( ";" ) ) );
131  if ( version == VCard::v2_1 && needsEncoding( address.join( QLatin1String( ";" ) ) ) ) {
132  adrLine.addParameter( QLatin1String( "charset" ), QLatin1String( "UTF-8" ) );
133  adrLine.addParameter( QLatin1String( "encoding" ), QLatin1String( "QUOTED-PRINTABLE" ) );
134  }
135 
136  VCardLine labelLine( QLatin1String( "LABEL" ), ( *it ).label() );
137  if ( version == VCard::v2_1 && needsEncoding( ( *it ).label() ) ) {
138  labelLine.addParameter( QLatin1String( "charset" ), QLatin1String( "UTF-8" ) );
139  labelLine.addParameter( QLatin1String( "encoding" ), QLatin1String( "QUOTED-PRINTABLE" ) );
140  }
141 
142  const bool hasLabel = !( *it ).label().isEmpty();
143  QMap<QString, Address::TypeFlag>::ConstIterator typeIt;
144  for ( typeIt = mAddressTypeMap.constBegin();
145  typeIt != mAddressTypeMap.constEnd(); ++typeIt ) {
146  if ( typeIt.value() & ( *it ).type() ) {
147  adrLine.addParameter( QLatin1String( "TYPE" ), typeIt.key() );
148  if ( hasLabel ) {
149  labelLine.addParameter( QLatin1String( "TYPE" ), typeIt.key() );
150  }
151  }
152  }
153 
154  if ( !isEmpty ) {
155  card.addLine( adrLine );
156  }
157  if ( hasLabel ) {
158  card.addLine( labelLine );
159  }
160  }
161 
162  // BDAY
163  card.addLine( VCardLine( QLatin1String( "BDAY" ), createDateTime( ( *addrIt ).birthday() ) ) );
164 
165  // CATEGORIES
166  if ( version == VCard::v3_0 ) {
167  QStringList categories = ( *addrIt ).categories();
168  QStringList::Iterator catIt;
169  QStringList::Iterator catEnd( categories.end() );
170  for ( catIt = categories.begin(); catIt != catEnd; ++catIt ) {
171  ( *catIt ).replace( QLatin1Char( ',' ), QLatin1String( "\\," ) );
172  }
173 
174  VCardLine catLine( QLatin1String( "CATEGORIES" ), categories.join( QLatin1String( "," ) ) );
175  card.addLine( catLine );
176  }
177 
178  // CLASS
179  if ( version == VCard::v3_0 ) {
180  card.addLine( createSecrecy( ( *addrIt ).secrecy() ) );
181  }
182 
183  // EMAIL
184  const QStringList emails = ( *addrIt ).emails();
185  bool pref = true;
186  for ( strIt = emails.begin(); strIt != emails.end(); ++strIt ) {
187  VCardLine line( QLatin1String( "EMAIL" ), *strIt );
188  if ( pref == true && emails.count() > 1 ) {
189  line.addParameter( QLatin1String( "TYPE" ), QLatin1String( "PREF" ) );
190  pref = false;
191  }
192  card.addLine( line );
193  }
194 
195  // FN
196  VCardLine fnLine( QLatin1String( "FN" ), ( *addrIt ).formattedName() );
197  if ( version == VCard::v2_1 && needsEncoding( ( *addrIt ).formattedName() ) ) {
198  fnLine.addParameter( QLatin1String( "charset" ), QLatin1String( "UTF-8" ) );
199  fnLine.addParameter( QLatin1String( "encoding" ), QLatin1String( "QUOTED-PRINTABLE" ) );
200  }
201  card.addLine( fnLine );
202 
203  // GEO
204  const Geo geo = ( *addrIt ).geo();
205  if ( geo.isValid() ) {
206  QString str;
207  str.sprintf( "%.6f;%.6f", geo.latitude(), geo.longitude() );
208  card.addLine( VCardLine( QLatin1String( "GEO" ), str ) );
209  }
210 
211  // KEY
212  const Key::List keys = ( *addrIt ).keys();
213  Key::List::ConstIterator keyIt;
214  Key::List::ConstIterator keyEnd( keys.end() );
215  for ( keyIt = keys.begin(); keyIt != keyEnd; ++keyIt ) {
216  card.addLine( createKey( *keyIt ) );
217  }
218 
219  // LOGO
220  card.addLine( createPicture( QLatin1String( "LOGO" ), ( *addrIt ).logo() ) );
221 
222  // MAILER
223  VCardLine mailerLine( QLatin1String( "MAILER" ), ( *addrIt ).mailer() );
224  if ( version == VCard::v2_1 && needsEncoding( ( *addrIt ).mailer() ) ) {
225  mailerLine.addParameter( QLatin1String( "charset" ), QLatin1String( "UTF-8" ) );
226  mailerLine.addParameter( QLatin1String( "encoding" ), QLatin1String( "QUOTED-PRINTABLE" ) );
227  }
228  card.addLine( mailerLine );
229 
230  // N
231  QStringList name;
232  name.append( ( *addrIt ).familyName().replace( QLatin1Char( ';' ),
233  QLatin1String( "\\;" ) ) );
234 
235  name.append( ( *addrIt ).givenName().replace( QLatin1Char( ';' ),
236  QLatin1String( "\\;" ) ) );
237 
238  name.append( ( *addrIt ).additionalName().replace( QLatin1Char( ';' ),
239  QLatin1String( "\\;" ) ) );
240 
241  name.append( ( *addrIt ).prefix().replace( QLatin1Char( ';' ),
242  QLatin1String( "\\;" ) ) );
243 
244  name.append( ( *addrIt ).suffix().replace( QLatin1Char( ';' ),
245  QLatin1String( "\\;" ) ) );
246 
247  VCardLine nLine( QLatin1String( "N" ), name.join( QLatin1String( ";" ) ) );
248  if ( version == VCard::v2_1 && needsEncoding( name.join( QLatin1String( ";" ) ) ) ) {
249  nLine.addParameter( QLatin1String( "charset" ), QLatin1String( "UTF-8" ) );
250  nLine.addParameter( QLatin1String( "encoding" ), QLatin1String( "QUOTED-PRINTABLE" ) );
251  }
252  card.addLine( nLine );
253 
254  // NAME
255  VCardLine nameLine( QLatin1String( "NAME" ), ( *addrIt ).name() );
256  if ( version == VCard::v2_1 && needsEncoding( ( *addrIt ).name() ) ) {
257  nameLine.addParameter( QLatin1String( "charset" ), QLatin1String( "UTF-8" ) );
258  nameLine.addParameter( QLatin1String( "encoding" ), QLatin1String( "QUOTED-PRINTABLE" ) );
259  }
260  card.addLine( nameLine );
261 
262  // NICKNAME
263  if ( version == VCard::v3_0 ) {
264  card.addLine( VCardLine( QLatin1String( "NICKNAME" ), ( *addrIt ).nickName() ) );
265  }
266 
267  // NOTE
268  VCardLine noteLine( QLatin1String( "NOTE" ), ( *addrIt ).note() );
269  if ( version == VCard::v2_1 && needsEncoding( ( *addrIt ).note() ) ) {
270  noteLine.addParameter( QLatin1String( "charset" ), QLatin1String( "UTF-8" ) );
271  noteLine.addParameter( QLatin1String( "encoding" ), QLatin1String( "QUOTED-PRINTABLE" ) );
272  }
273  card.addLine( noteLine );
274 
275  // ORG
276  QStringList organization;
277  organization.append( ( *addrIt ).organization().replace( QLatin1Char( ';' ),
278  QLatin1String( "\\;" ) ) );
279  if ( !( *addrIt ).department().isEmpty() ) {
280  organization.append( ( *addrIt ).department().replace( QLatin1Char( ';' ),
281  QLatin1String( "\\;" ) ) );
282  }
283  VCardLine orgLine( QLatin1String( "ORG" ), organization.join( QLatin1String( ";" ) ) );
284  if ( version == VCard::v2_1 && needsEncoding( organization.join( QLatin1String( ";" ) ) ) ) {
285  orgLine.addParameter( QLatin1String( "charset" ), QLatin1String( "UTF-8" ) );
286  orgLine.addParameter( QLatin1String( "encoding" ), QLatin1String( "QUOTED-PRINTABLE" ) );
287  }
288  card.addLine( orgLine );
289 
290  // PHOTO
291  card.addLine( createPicture( QLatin1String( "PHOTO" ), ( *addrIt ).photo() ) );
292 
293  // PROID
294  if ( version == VCard::v3_0 ) {
295  card.addLine( VCardLine( QLatin1String( "PRODID" ), ( *addrIt ).productId() ) );
296  }
297 
298  // REV
299  card.addLine( VCardLine( QLatin1String( "REV" ), createDateTime( ( *addrIt ).revision() ) ) );
300 
301  // ROLE
302  VCardLine roleLine( QLatin1String( "ROLE" ), ( *addrIt ).role() );
303  if ( version == VCard::v2_1 && needsEncoding( ( *addrIt ).role() ) ) {
304  roleLine.addParameter( QLatin1String( "charset" ), QLatin1String( "UTF-8" ) );
305  roleLine.addParameter( QLatin1String( "encoding" ), QLatin1String( "QUOTED-PRINTABLE" ) );
306  }
307  card.addLine( roleLine );
308 
309  // SORT-STRING
310  if ( version == VCard::v3_0 ) {
311  card.addLine( VCardLine( QLatin1String( "SORT-STRING" ), ( *addrIt ).sortString() ) );
312  }
313 
314  // SOUND
315  card.addLine( createSound( ( *addrIt ).sound() ) );
316 
317  // TEL
318  const PhoneNumber::List phoneNumbers = ( *addrIt ).phoneNumbers();
319  PhoneNumber::List::ConstIterator phoneIt;
320  PhoneNumber::List::ConstIterator phoneEnd( phoneNumbers.end() );
321  for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneEnd; ++phoneIt ) {
322  VCardLine line( QLatin1String( "TEL" ), ( *phoneIt ).number() );
323 
324  QMap<QString, PhoneNumber::TypeFlag>::ConstIterator typeIt;
325  QMap<QString, PhoneNumber::TypeFlag>::ConstIterator typeEnd( mPhoneTypeMap.constEnd() );
326  for ( typeIt = mPhoneTypeMap.constBegin(); typeIt != typeEnd; ++typeIt ) {
327  if ( typeIt.value() & ( *phoneIt ).type() ) {
328  line.addParameter( QLatin1String( "TYPE" ), typeIt.key() );
329  }
330  }
331 
332  card.addLine( line );
333  }
334 
335  // TITLE
336  VCardLine titleLine( QLatin1String( "TITLE" ), ( *addrIt ).title() );
337  if ( version == VCard::v2_1 && needsEncoding( ( *addrIt ).title() ) ) {
338  titleLine.addParameter( QLatin1String( "charset" ), QLatin1String( "UTF-8" ) );
339  titleLine.addParameter( QLatin1String( "encoding" ), QLatin1String( "QUOTED-PRINTABLE" ) );
340  }
341  card.addLine( titleLine );
342 
343  // TZ
344  const TimeZone timeZone = ( *addrIt ).timeZone();
345  if ( timeZone.isValid() ) {
346  QString str;
347 
348  int neg = 1;
349  if ( timeZone.offset() < 0 ) {
350  neg = -1;
351  }
352 
353  str.sprintf( "%c%02d:%02d", ( timeZone.offset() >= 0 ? '+' : '-' ),
354  ( timeZone.offset() / 60 ) * neg,
355  ( timeZone.offset() % 60 ) * neg );
356 
357  card.addLine( VCardLine( QLatin1String( "TZ" ), str ) );
358  }
359 
360  // UID
361  card.addLine( VCardLine( QLatin1String( "UID" ), ( *addrIt ).uid() ) );
362 
363  // URL
364  card.addLine( VCardLine( QLatin1String( "URL" ), ( *addrIt ).url().url() ) );
365 
366  // VERSION
367  if ( version == VCard::v2_1 ) {
368  card.addLine( VCardLine( QLatin1String( "VERSION" ), QLatin1String( "2.1" ) ) );
369  } else if ( version == VCard::v3_0 ) {
370  card.addLine( VCardLine( QLatin1String( "VERSION" ), QLatin1String( "3.0" ) ) );
371  }
372 
373  // X-
374  const QStringList customs = ( *addrIt ).customs();
375  for ( strIt = customs.begin(); strIt != customs.end(); ++strIt ) {
376  QString identifier = QLatin1String( "X-" ) +
377  ( *strIt ).left( ( *strIt ).indexOf( QLatin1Char( ':' ) ) );
378  const QString value = ( *strIt ).mid( ( *strIt ).indexOf( QLatin1Char( ':' ) ) + 1 );
379  if ( value.isEmpty() ) {
380  continue;
381  }
382  //Convert to standard identifier
383  if ( exportVcard ) {
384  if ( identifier == QLatin1String( "X-messaging/aim-All" ) ) {
385  identifier = QLatin1String( "X-AIM" );
386  } else if ( identifier == QLatin1String( "X-messaging/icq-All" ) ) {
387  identifier = QLatin1String( "X-ICQ" );
388  } else if ( identifier == QLatin1String( "X-messaging/xmpp-All" ) ) {
389  identifier = QLatin1String( "X-JABBER" );
390  } else if ( identifier == QLatin1String( "X-messaging/msn-All" ) ) {
391  identifier = QLatin1String( "X-MSN" );
392  } else if ( identifier == QLatin1String( "X-messaging/yahoo-All" ) ) {
393  identifier = QLatin1String( "X-YAHOO" );
394  } else if ( identifier == QLatin1String( "X-messaging/gadu-All" ) ) {
395  identifier = QLatin1String( "X-GADUGADU" );
396  } else if ( identifier == QLatin1String( "X-messaging/skype-All" ) ) {
397  identifier = QLatin1String( "X-SKYPE" );
398  } else if ( identifier == QLatin1String( "X-messaging/groupwise-All" ) ) {
399  identifier = QLatin1String( "X-GROUPWISE" );
400  } else if ( identifier == QLatin1String( "X-messaging/sms-All" ) ) {
401  identifier = QLatin1String( "X-SMS" );
402  } else if ( identifier == QLatin1String( "X-messaging/meanwhile-All" ) ) {
403  identifier = QLatin1String( "X-MEANWHILE" );
404  } else if ( identifier == QLatin1String( "X-messaging/irc-All" ) ) {
405  identifier = QLatin1String( "X-IRC" ); //Not defined by rfc but need for fixing #300869
406  } else if ( identifier == QLatin1String( "X-messaging/googletalk-All" ) ) {
407  //Not defined by rfc but need for fixing #300869
408  identifier = QLatin1String( "X-GOOGLETALK" );
409  }
410  }
411 
412  VCardLine line( identifier, value );
413  if ( version == VCard::v2_1 && needsEncoding( value ) ) {
414  line.addParameter( QLatin1String( "charset" ), QLatin1String( "UTF-8" ) );
415  line.addParameter( QLatin1String( "encoding" ), QLatin1String( "QUOTED-PRINTABLE" ) );
416  }
417  card.addLine( line );
418  }
419 
420  vCardList.append( card );
421  }
422 
423  return VCardParser::createVCards( vCardList );
424 }
425 
426 Addressee::List VCardTool::parseVCards( const QByteArray &vcard ) const
427 {
428  static const QLatin1Char semicolonSep( ';' );
429  static const QLatin1Char commaSep( ',' );
430  QString identifier;
431 
432  Addressee::List addrList;
433  const VCard::List vCardList = VCardParser::parseVCards( vcard );
434 
435  VCard::List::ConstIterator cardIt;
436  VCard::List::ConstIterator listEnd( vCardList.end() );
437  for ( cardIt = vCardList.begin(); cardIt != listEnd; ++cardIt ) {
438  Addressee addr;
439 
440  const QStringList idents = ( *cardIt ).identifiers();
441  QStringList::ConstIterator identIt;
442  QStringList::ConstIterator identEnd( idents.end() );
443  for ( identIt = idents.begin(); identIt != identEnd; ++identIt ) {
444  const VCardLine::List lines = ( *cardIt ).lines( ( *identIt ) );
445  VCardLine::List::ConstIterator lineIt;
446 
447  // iterate over the lines
448  for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) {
449  identifier = ( *lineIt ).identifier().toLower();
450  // ADR
451  if ( identifier == QLatin1String( "adr" ) ) {
452  Address address;
453  const QStringList addrParts = splitString( semicolonSep, ( *lineIt ).value().toString() );
454  if ( addrParts.count() > 0 ) {
455  address.setPostOfficeBox( addrParts[ 0 ] );
456  }
457  if ( addrParts.count() > 1 ) {
458  address.setExtended( addrParts[ 1 ] );
459  }
460  if ( addrParts.count() > 2 ) {
461  address.setStreet( addrParts[ 2 ] );
462  }
463  if ( addrParts.count() > 3 ) {
464  address.setLocality( addrParts[ 3 ] );
465  }
466  if ( addrParts.count() > 4 ) {
467  address.setRegion( addrParts[ 4 ] );
468  }
469  if ( addrParts.count() > 5 ) {
470  address.setPostalCode( addrParts[ 5 ] );
471  }
472  if ( addrParts.count() > 6 ) {
473  address.setCountry( addrParts[ 6 ] );
474  }
475 
476  Address::Type type;
477 
478  const QStringList types = ( *lineIt ).parameters( QLatin1String( "type" ) );
479  for ( QStringList::ConstIterator it = types.begin(); it != types.end(); ++it ) {
480  type |= mAddressTypeMap[ ( *it ).toLower() ];
481  }
482 
483  address.setType( type );
484  addr.insertAddress( address );
485  }
486 
487  // BDAY
488  else if ( identifier == QLatin1String( "bday" ) ) {
489  addr.setBirthday( parseDateTime( ( *lineIt ).value().toString() ) );
490  }
491 
492  // CATEGORIES
493  else if ( identifier == QLatin1String( "categories" ) ) {
494  const QStringList categories = splitString( commaSep, ( *lineIt ).value().toString() );
495  addr.setCategories( categories );
496  }
497 
498  // CLASS
499  else if ( identifier == QLatin1String( "class" ) ) {
500  addr.setSecrecy( parseSecrecy( *lineIt ) );
501  }
502 
503  // EMAIL
504  else if ( identifier == QLatin1String( "email" ) ) {
505  const QStringList types = ( *lineIt ).parameters( QLatin1String( "type" ) );
506  addr.insertEmail( ( *lineIt ).value().toString(),
507  types.contains( QLatin1String( "PREF" ) ) );
508  }
509 
510  // FN
511  else if ( identifier == QLatin1String( "fn" ) ) {
512  addr.setFormattedName( ( *lineIt ).value().toString() );
513  }
514 
515  // GEO
516  else if ( identifier == QLatin1String( "geo" ) ) {
517  Geo geo;
518 
519  const QStringList geoParts =
520  ( *lineIt ).value().toString().split( QLatin1Char( ';' ), QString::KeepEmptyParts );
521  if ( geoParts.size() >= 2 ) {
522  geo.setLatitude( geoParts[ 0 ].toFloat() );
523  geo.setLongitude( geoParts[ 1 ].toFloat() );
524  addr.setGeo( geo );
525  }
526  }
527 
528  // KEY
529  else if ( identifier == QLatin1String( "key" ) ) {
530  addr.insertKey( parseKey( *lineIt ) );
531  }
532 
533  // LABEL
534  else if ( identifier == QLatin1String( "label" ) ) {
535  Address::Type type;
536 
537  const QStringList types = ( *lineIt ).parameters( QLatin1String( "type" ) );
538  for ( QStringList::ConstIterator it = types.begin(); it != types.end(); ++it ) {
539  type |= mAddressTypeMap[ ( *it ).toLower() ];
540  }
541 
542  bool available = false;
543  KABC::Address::List addressList = addr.addresses();
544  for ( KABC::Address::List::Iterator it = addressList.begin();
545  it != addressList.end(); ++it ) {
546  if ( ( *it ).type() == type ) {
547  ( *it ).setLabel( ( *lineIt ).value().toString() );
548  addr.insertAddress( *it );
549  available = true;
550  break;
551  }
552  }
553 
554  if ( !available ) { // a standalone LABEL tag
555  KABC::Address address( type );
556  address.setLabel( ( *lineIt ).value().toString() );
557  addr.insertAddress( address );
558  }
559  }
560 
561  // LOGO
562  else if ( identifier == QLatin1String( "logo" ) ) {
563  addr.setLogo( parsePicture( *lineIt ) );
564  }
565 
566  // MAILER
567  else if ( identifier == QLatin1String( "mailer" ) ) {
568  addr.setMailer( ( *lineIt ).value().toString() );
569  }
570 
571  // N
572  else if ( identifier == QLatin1String( "n" ) ) {
573  const QStringList nameParts = splitString( semicolonSep, ( *lineIt ).value().toString() );
574  const int numberOfParts( nameParts.count() );
575  if ( numberOfParts > 0 ) {
576  addr.setFamilyName( nameParts[ 0 ] );
577  }
578  if ( numberOfParts > 1 ) {
579  addr.setGivenName( nameParts[ 1 ] );
580  }
581  if ( numberOfParts > 2 ) {
582  addr.setAdditionalName( nameParts[ 2 ] );
583  }
584  if ( numberOfParts > 3 ) {
585  addr.setPrefix( nameParts[ 3 ] );
586  }
587  if ( numberOfParts > 4 ) {
588  addr.setSuffix( nameParts[ 4 ] );
589  }
590  }
591 
592  // NAME
593  else if ( identifier == QLatin1String( "name" ) ) {
594  addr.setName( ( *lineIt ).value().toString() );
595  }
596 
597  // NICKNAME
598  else if ( identifier == QLatin1String( "nickname" ) ) {
599  addr.setNickName( ( *lineIt ).value().toString() );
600  }
601 
602  // NOTE
603  else if ( identifier == QLatin1String( "note" ) ) {
604  addr.setNote( ( *lineIt ).value().toString() );
605  }
606 
607  // ORGANIZATION
608  else if ( identifier == QLatin1String( "org" ) ) {
609  const QStringList orgParts = splitString( semicolonSep, ( *lineIt ).value().toString() );
610  if ( orgParts.count() > 0 ) {
611  addr.setOrganization( orgParts[ 0 ] );
612  }
613  if ( orgParts.count() > 1 ) {
614  addr.setDepartment( orgParts[ 1 ] );
615  }
616  }
617 
618  // PHOTO
619  else if ( identifier == QLatin1String( "photo" ) ) {
620  addr.setPhoto( parsePicture( *lineIt ) );
621  }
622 
623  // PROID
624  else if ( identifier == QLatin1String( "prodid" ) ) {
625  addr.setProductId( ( *lineIt ).value().toString() );
626  }
627 
628  // REV
629  else if ( identifier == QLatin1String( "rev" ) ) {
630  addr.setRevision( parseDateTime( ( *lineIt ).value().toString() ) );
631  }
632 
633  // ROLE
634  else if ( identifier == QLatin1String( "role" ) ) {
635  addr.setRole( ( *lineIt ).value().toString() );
636  }
637 
638  // SORT-STRING
639  else if ( identifier == QLatin1String( "sort-string" ) ) {
640  addr.setSortString( ( *lineIt ).value().toString() );
641  }
642 
643  // SOUND
644  else if ( identifier == QLatin1String( "sound" ) ) {
645  addr.setSound( parseSound( *lineIt ) );
646  }
647 
648  // TEL
649  else if ( identifier == QLatin1String( "tel" ) ) {
650  PhoneNumber phone;
651  phone.setNumber( ( *lineIt ).value().toString() );
652 
653  PhoneNumber::Type type;
654 
655  const QStringList types = ( *lineIt ).parameters( QLatin1String( "type" ) );
656  QStringList::ConstIterator typeEnd( types.end() );
657  for ( QStringList::ConstIterator it = types.begin(); it != typeEnd; ++it ) {
658  type |= mPhoneTypeMap[( *it ).toUpper()];
659  }
660 
661  phone.setType( type );
662 
663  addr.insertPhoneNumber( phone );
664  }
665 
666  // TITLE
667  else if ( identifier == QLatin1String( "title" ) ) {
668  addr.setTitle( ( *lineIt ).value().toString() );
669  }
670 
671  // TZ
672  else if ( identifier == QLatin1String( "tz" ) ) {
673  TimeZone tz;
674  const QString date = ( *lineIt ).value().toString();
675 
676  if ( !date.isEmpty() ) {
677  int hours = date.mid( 1, 2 ).toInt();
678  int minutes = date.mid( 4, 2 ).toInt();
679  int offset = ( hours * 60 ) + minutes;
680  offset = offset * ( date[ 0 ] == QLatin1Char( '+' ) ? 1 : -1 );
681 
682  tz.setOffset( offset );
683  addr.setTimeZone( tz );
684  }
685  }
686 
687  // UID
688  else if ( identifier == QLatin1String( "uid" ) ) {
689  addr.setUid( ( *lineIt ).value().toString() );
690  }
691 
692  // URL
693  else if ( identifier == QLatin1String( "url" ) ) {
694  addr.setUrl( KUrl( ( *lineIt ).value().toString() ) );
695  }
696 
697  // X-
698  else if ( identifier.startsWith( QLatin1String( "x-" ) ) ) {
699  QString ident = ( *lineIt ).identifier();
700  //X-Evolution
701  if ( identifier == QLatin1String( "x-evolution-spouse" ) ||
702  identifier == QLatin1String( "x-spouse" ) ) {
703  ident = QLatin1String( "X-KADDRESSBOOK-X-SpousesName" );
704  } else if ( identifier == QLatin1String( "x-evolution-blog-url" ) ) {
705  ident = QLatin1String( "X-KADDRESSBOOK-BlogFeed" );
706  } else if ( identifier == QLatin1String( "x-evolution-assistant" ) ||
707  identifier == QLatin1String( "x-assistant" ) ) {
708  ident = QLatin1String( "X-KADDRESSBOOK-X-AssistantsName" );
709  } else if ( identifier == QLatin1String( "x-evolution-anniversary" ) ||
710  identifier == QLatin1String( "x-anniversary" ) ) {
711  ident = QLatin1String( "X-KADDRESSBOOK-X-Anniversary" );
712  } else if ( identifier == QLatin1String( "x-evolution-manager" ) ||
713  identifier == QLatin1String( "x-manager" ) ) {
714  ident = QLatin1String( "X-KADDRESSBOOK-X-ManagersName" );
715  } else if ( identifier == QLatin1String( "x-aim" ) ) {
716  ident = QLatin1String( "X-messaging/aim-All" );
717  } else if ( identifier == QLatin1String( "x-icq" ) ) {
718  ident = QLatin1String( "X-messaging/icq-All" );
719  } else if ( identifier == QLatin1String( "x-jabber" ) ) {
720  ident = QLatin1String( "X-messaging/xmpp-All" );
721  } else if ( identifier == QLatin1String( "x-jabber" ) ) {
722  ident = QLatin1String( "X-messaging/xmpp-All" );
723  } else if ( identifier == QLatin1String( "x-msn" ) ) {
724  ident = QLatin1String( "X-messaging/msn-All" );
725  } else if ( identifier == QLatin1String( "x-yahoo" ) ) {
726  ident = QLatin1String( "X-messaging/yahoo-All" );
727  } else if ( identifier == QLatin1String( "x-gadugadu" ) ) {
728  ident = QLatin1String( "X-messaging/gadu-All" );
729  } else if ( identifier == QLatin1String( "x-skype" ) ) {
730  ident = QLatin1String( "X-messaging/skype-All" );
731  } else if ( identifier == QLatin1String( "x-groupwise" ) ) {
732  ident = QLatin1String( "X-messaging/groupwise-All" );
733  } else if ( identifier == QLatin1String( "x-sms" ) ) {
734  ident = QLatin1String( "X-messaging/sms-All" );
735  } else if ( identifier == QLatin1String( "x-meanwhile" ) ) {
736  ident = QLatin1String( "X-messaging/meanwhile-All" );
737  } else if ( identifier == QLatin1String( "x-irc" ) ) {
738  ident = QLatin1String( "X-messaging/irc-All" );
739  } else if ( identifier == QLatin1String( "x-googletalk" ) ) {
740  ident = QLatin1String( "X-messaging/googletalk-All" );
741  }
742 
743  const QString key = ident.mid( 2 );
744  const int dash = key.indexOf( QLatin1Char( '-' ) );
745  addr.insertCustom( key.left( dash ), key.mid( dash + 1 ),
746  ( *lineIt ).value().toString() );
747  }
748  }
749  }
750 
751  addrList.append( addr );
752  }
753 
754  return addrList;
755 }
756 
757 QDateTime VCardTool::parseDateTime( const QString &str ) const
758 {
759  QDate date;
760  QTime time;
761 
762  if ( str.indexOf( QLatin1Char( '-' ) ) == -1 ) { // is base format (yyyymmdd)
763  date = QDate( str.left( 4 ).toInt(), str.mid( 4, 2 ).toInt(),
764  str.mid( 6, 2 ).toInt() );
765  } else { // is extended format yyyy-mm-dd
766  date = QDate( str.left( 4 ).toInt(), str.mid( 5, 2 ).toInt(),
767  str.mid( 8, 2 ).toInt() );
768  }
769 
770  // does it also contain a time ? (Note: mm, ss are optional according ISO-8601)
771  int timeStart = str.indexOf( QLatin1Char( 'T' ) );
772  if ( timeStart >= 0 ) {
773  int hour = 0, minute = 0, second = 0;
774 
775  hour = str.mid( timeStart + 1, 2 ).toInt(); // hour must always be given
776 
777  if ( str.indexOf( QLatin1Char( ':' ), timeStart + 1 ) > 0 ) { // extended format (hh:mm:ss)
778  if ( str.length() >= ( timeStart + 5 ) ) {
779  minute = str.mid( timeStart + 4, 2 ).toInt();
780  if ( str.length() >= ( timeStart + 8 ) ) {
781  second = str.mid( timeStart + 7, 2 ).toInt();
782  }
783  }
784  } else { // basic format (hhmmss)
785  if ( str.length() >= ( timeStart + 4 ) ) {
786  minute = str.mid( timeStart + 3, 2 ).toInt();
787  if ( str.length() >= ( timeStart + 6 ) ) {
788  second = str.mid( timeStart + 5, 2 ).toInt();
789  }
790  }
791  }
792 
793  time = QTime( hour, minute, second );
794  }
795 
796  Qt::TimeSpec spec = ( str.right( 1 ) == QLatin1String( "Z" ) ) ? Qt::UTC : Qt::LocalTime;
797 
798  QDateTime dateTime( date );
799 
800  // explicitly set the time, which might be invalid, to keep the information
801  // that the time is invalid. In createDateTime() the time/invalid flag is
802  // checked which omits then to print the timestamp
803  // This is needed to reproduce the given string in input
804  // e.g. BDAY:2008-12-30
805  // without time shall also result in a string without a time
806  dateTime.setTime( time );
807 
808  dateTime.setTimeSpec( spec );
809  return dateTime;
810 }
811 
812 QString VCardTool::createDateTime( const QDateTime &dateTime ) const
813 {
814  QString str;
815 
816  if ( dateTime.date().isValid() ) {
817  str.sprintf( "%4d-%02d-%02d", dateTime.date().year(), dateTime.date().month(),
818  dateTime.date().day() );
819  if ( dateTime.time().isValid() ) {
820  QString tmp;
821  tmp.sprintf( "T%02d:%02d:%02d", dateTime.time().hour(), dateTime.time().minute(),
822  dateTime.time().second() );
823  str += tmp;
824 
825  if ( dateTime.timeSpec() == Qt::UTC ) {
826  str += QLatin1Char( 'Z' );
827  }
828  }
829  }
830 
831  return str;
832 }
833 
834 Picture VCardTool::parsePicture( const VCardLine &line ) const
835 {
836  Picture pic;
837 
838  const QStringList params = line.parameterList();
839  QString type;
840  if ( params.contains( QLatin1String( "type" ) ) ) {
841  type = line.parameter( QLatin1String( "type" ) );
842  }
843  if ( params.contains( QLatin1String( "encoding" ) ) ) {
844  pic.setRawData( line.value().toByteArray(), type );
845  } else if ( params.contains( QLatin1String( "value" ) ) ) {
846  if ( line.parameter( QLatin1String( "value" ) ).toLower() == QLatin1String( "uri" ) ) {
847  pic.setUrl( line.value().toString() );
848  }
849  }
850 
851  return pic;
852 }
853 
854 VCardLine VCardTool::createPicture( const QString &identifier, const Picture &pic ) const
855 {
856  VCardLine line( identifier );
857 
858  if ( pic.isEmpty() ) {
859  return line;
860  }
861 
862  if ( pic.isIntern() ) {
863  line.setValue( pic.rawData() );
864  line.addParameter( QLatin1String( "encoding" ), QLatin1String( "b" ) );
865  line.addParameter( QLatin1String( "type" ), pic.type() );
866  } else {
867  line.setValue( pic.url() );
868  line.addParameter( QLatin1String( "value" ), QLatin1String( "URI" ) );
869  }
870 
871  return line;
872 }
873 
874 Sound VCardTool::parseSound( const VCardLine &line ) const
875 {
876  Sound snd;
877 
878  const QStringList params = line.parameterList();
879  if ( params.contains( QLatin1String( "encoding" ) ) ) {
880  snd.setData( line.value().toByteArray() );
881  } else if ( params.contains( QLatin1String( "value" ) ) ) {
882  if ( line.parameter( QLatin1String( "value" ) ).toLower() == QLatin1String( "uri" ) ) {
883  snd.setUrl( line.value().toString() );
884  }
885  }
886 
887 /* TODO: support sound types
888  if ( params.contains( "type" ) )
889  snd.setType( line.parameter( "type" ) );
890 */
891 
892  return snd;
893 }
894 
895 VCardLine VCardTool::createSound( const Sound &snd ) const
896 {
897  VCardLine line( QLatin1String( "SOUND" ) );
898 
899  if ( snd.isIntern() ) {
900  if ( !snd.data().isEmpty() ) {
901  line.setValue( snd.data() );
902  line.addParameter( QLatin1String( "encoding" ), QLatin1String( "b" ) );
903  // TODO: need to store sound type!!!
904  }
905  } else if ( !snd.url().isEmpty() ) {
906  line.setValue( snd.url() );
907  line.addParameter( QLatin1String( "value" ), QLatin1String( "URI" ) );
908  }
909 
910  return line;
911 }
912 
913 Key VCardTool::parseKey( const VCardLine &line ) const
914 {
915  Key key;
916 
917  const QStringList params = line.parameterList();
918  if ( params.contains( QLatin1String( "encoding" ) ) ) {
919  key.setBinaryData( line.value().toByteArray() );
920  } else {
921  key.setTextData( line.value().toString() );
922  }
923 
924  if ( params.contains( QLatin1String( "type" ) ) ) {
925  if ( line.parameter( QLatin1String( "type" ) ).toLower() == QLatin1String( "x509" ) ) {
926  key.setType( Key::X509 );
927  } else if ( line.parameter( QLatin1String( "type" ) ).toLower() == QLatin1String( "pgp" ) ) {
928  key.setType( Key::PGP );
929  } else {
930  key.setType( Key::Custom );
931  key.setCustomTypeString( line.parameter( QLatin1String( "type" ) ) );
932  }
933  }
934 
935  return key;
936 }
937 
938 VCardLine VCardTool::createKey( const Key &key ) const
939 {
940  VCardLine line( QLatin1String( "KEY" ) );
941 
942  if ( key.isBinary() ) {
943  if ( !key.binaryData().isEmpty() ) {
944  line.setValue( key.binaryData() );
945  line.addParameter( QLatin1String( "encoding" ), QLatin1String( "b" ) );
946  }
947  } else if ( !key.textData().isEmpty() ) {
948  line.setValue( key.textData() );
949  }
950 
951  if ( key.type() == Key::X509 ) {
952  line.addParameter( QLatin1String( "type" ), QLatin1String( "X509" ) );
953  } else if ( key.type() == Key::PGP ) {
954  line.addParameter( QLatin1String( "type" ), QLatin1String( "PGP" ) );
955  } else if ( key.type() == Key::Custom ) {
956  line.addParameter( QLatin1String( "type" ), key.customTypeString() );
957  }
958 
959  return line;
960 }
961 
962 Secrecy VCardTool::parseSecrecy( const VCardLine &line ) const
963 {
964  Secrecy secrecy;
965 
966  const QString value = line.value().toString().toLower();
967  if ( value == QLatin1String( "public" ) ) {
968  secrecy.setType( Secrecy::Public );
969  } else if ( value == QLatin1String( "private" ) ) {
970  secrecy.setType( Secrecy::Private );
971  } else if ( value == QLatin1String( "confidential" ) ) {
972  secrecy.setType( Secrecy::Confidential );
973  }
974 
975  return secrecy;
976 }
977 
978 VCardLine VCardTool::createSecrecy( const Secrecy &secrecy ) const
979 {
980  VCardLine line( QLatin1String( "CLASS" ) );
981 
982  int type = secrecy.type();
983 
984  if ( type == Secrecy::Public ) {
985  line.setValue( QLatin1String( "PUBLIC" ) );
986  } else if ( type == Secrecy::Private ) {
987  line.setValue( QLatin1String( "PRIVATE" ) );
988  } else if ( type == Secrecy::Confidential ) {
989  line.setValue( QLatin1String( "CONFIDENTIAL" ) );
990  }
991 
992  return line;
993 }
994 
995 QStringList VCardTool::splitString( const QChar &sep, const QString &str ) const
996 {
997  QStringList list;
998  QString value( str );
999 
1000  int start = 0;
1001  int pos = value.indexOf( sep, start );
1002 
1003  while ( pos != -1 ) {
1004  if ( pos == 0 || value[ pos - 1 ] != QLatin1Char( '\\' ) ) {
1005  if ( pos > start && pos <= (int)value.length() ) {
1006  list << value.mid( start, pos - start );
1007  } else {
1008  list << QString();
1009  }
1010 
1011  start = pos + 1;
1012  pos = value.indexOf( sep, start );
1013  } else {
1014  value.replace( pos - 1, 2, sep );
1015  pos = value.indexOf( sep, pos );
1016  }
1017  }
1018 
1019  int l = value.length() - 1;
1020  if ( value.mid( start, l - start + 1 ).length() > 0 ) {
1021  list << value.mid( start, l - start + 1 );
1022  } else {
1023  list << QString();
1024  }
1025 
1026  return list;
1027 }
KABC::Sound
Class that holds a Sound clip for a contact.
Definition: sound.h:58
KABC::PhoneNumber::Pcs
Personal Communication Service.
Definition: phonenumber.h:60
KABC::Key::List
QList< Key > List
List of keys.
Definition: key.h:43
KABC::Address::Dom
domestic
Definition: address.h:52
KABC::Key::textData
QString textData() const
Returns the text data.
Definition: key.cpp:148
KABC::Address::setType
void setType(Type type)
Sets the type of address.
Definition: address.cpp:322
KABC::Address
Postal address information.
Definition: address.h:37
KABC::Addressee::setNickName
void setNickName(const QString &nickName)
Set nick name.
Definition: addressee.cpp:527
KABC::Key::PGP
Pretty Good Privacy key.
Definition: key.h:50
KABC::PhoneNumber
Phonenumber information.
Definition: phonenumber.h:38
KABC::PhoneNumber::Voice
Voice.
Definition: phonenumber.h:52
KABC::Key::setBinaryData
void setBinaryData(const QByteArray &data)
Sets binary data.
Definition: key.cpp:131
KABC::Sound::setData
void setData(const QByteArray &data)
Sets the raw data of the sound.
Definition: sound.cpp:116
KABC::Picture
A class to store a picture of an addressee.
Definition: picture.h:39
KABC::Addressee::insertEmail
void insertEmail(const QString &email, bool preferred=false)
Insert an email address.
Definition: addressee.cpp:1231
KABC::Sound::setUrl
void setUrl(const QString &url)
Sets a URL for the location of the sound file.
Definition: sound.cpp:110
KABC::Addressee::setMailer
void setMailer(const QString &mailer)
Set mail client.
Definition: addressee.cpp:705
KABC::Addressee::insertPhoneNumber
void insertPhoneNumber(const PhoneNumber &phoneNumber)
Insert a phone number.
Definition: addressee.cpp:1276
KABC::Address::Pref
preferred address
Definition: address.h:58
KABC::Geo::setLongitude
void setLongitude(float longitude)
Sets the longitude.
Definition: geo.cpp:90
KABC::AddresseeList
a QValueList of Addressee, with sorting functionality
Definition: addresseelist.h:288
KABC::Addressee::setSuffix
void setSuffix(const QString &suffix)
Set honorific suffixes.
Definition: addressee.cpp:507
KABC::Addressee::setPhoto
void setPhoto(const Picture &photo)
Set photo.
Definition: addressee.cpp:985
KABC::Addressee::setFormattedName
void setFormattedName(const QString &formattedName)
Set formatted name.
Definition: addressee.cpp:407
KABC::Key::setTextData
void setTextData(const QString &data)
Sets text data.
Definition: key.cpp:142
KABC::Key::binaryData
QByteArray binaryData() const
Returns the binary data.
Definition: key.cpp:137
KABC::Key
A class to store an encryption key.
Definition: key.h:34
KABC::Addressee::setRole
void setRole(const QString &role)
Set role.
Definition: addressee.cpp:785
KABC::TimeZone::setOffset
void setOffset(int offset)
Set time zone offset relative to UTC.
Definition: timezone.cpp:66
KABC::Geo::setLatitude
void setLatitude(float latitude)
Sets the latitude.
Definition: geo.cpp:74
KABC::Geo::longitude
float longitude() const
Returns the longitude.
Definition: geo.cpp:101
KABC::Addressee::setCategories
void setCategories(const QStringList &)
Set categories to given value.
Definition: addressee.cpp:1613
KABC::Addressee::setGivenName
void setGivenName(const QString &givenName)
Set given name.
Definition: addressee.cpp:447
KABC::Key::isBinary
bool isBinary() const
Returns whether the key contains binary or text data.
Definition: key.cpp:153
KABC::TimeZone::isValid
bool isValid() const
Return, if this time zone object is valid.
Definition: timezone.cpp:77
KABC::Key::X509
X509 key.
Definition: key.h:49
KABC::Address::setStreet
void setStreet(const QString &street)
Sets the street (including house number).
Definition: address.cpp:388
KABC::PhoneNumber::Bbs
Mailbox.
Definition: phonenumber.h:56
KABC::Addressee::setSortString
void setSortString(const QString &sortString)
Set sort string.
Definition: addressee.cpp:905
KABC::Addressee::setAdditionalName
void setAdditionalName(const QString &additionalName)
Set additional names.
Definition: addressee.cpp:467
KABC::Addressee::setLogo
void setLogo(const Picture &logo)
Set logo.
Definition: addressee.cpp:965
KABC::Picture::rawData
QByteArray rawData() const
Returns the raw data of this picture.
Definition: picture.cpp:203
KABC::PhoneNumber::Fax
Fax machine.
Definition: phonenumber.h:53
KABC::Addressee::setFamilyName
void setFamilyName(const QString &familyName)
Set family name.
Definition: addressee.cpp:427
KABC::Addressee::addresses
Address::List addresses() const
Return list of all addresses.
Definition: addressee.cpp:1559
KABC::Address::Home
home address
Definition: address.h:56
KABC::Key::Custom
Custom or IANA conform key.
Definition: key.h:51
KABC::Addressee::setPrefix
void setPrefix(const QString &prefix)
Set honorific prefixes.
Definition: addressee.cpp:487
KABC::Address::Parcel
parcel
Definition: address.h:55
KABC::Picture::setRawData
void setRawData(const QByteArray &rawData, const QString &type)
Sets the raw data of the picture.
Definition: picture.cpp:171
KABC::Picture::url
QString url() const
Returns the location URL of this picture.
Definition: picture.cpp:189
KABC::PhoneNumber::Cell
Cell phone.
Definition: phonenumber.h:54
KABC::Address::Postal
postal
Definition: address.h:54
KABC::Addressee::setTitle
void setTitle(const QString &title)
Set title.
Definition: addressee.cpp:765
KABC::PhoneNumber::setType
void setType(Type type)
Sets the type.
Definition: phonenumber.cpp:133
KABC::Addressee::setDepartment
void setDepartment(const QString &department)
Set department.
Definition: addressee.cpp:825
KABC::PhoneNumber::setNumber
void setNumber(const QString &number)
Sets the phone number.
Definition: phonenumber.cpp:123
KABC::PhoneNumber::List
QList< PhoneNumber > List
List of phone numbers.
Definition: phonenumber.h:74
KABC::Geo::latitude
float latitude() const
Returns the latitude.
Definition: geo.cpp:85
KABC::Address::setPostOfficeBox
void setPostOfficeBox(const QString &postOfficeBox)
Sets the post office box.
Definition: address.cpp:356
KABC::Addressee::setSound
void setSound(const Sound &sound)
Set sound.
Definition: addressee.cpp:1005
KABC::TimeZone::offset
int offset() const
Return offset in minutes relative to UTC.
Definition: timezone.cpp:72
KABC::Addressee::setUid
void setUid(const QString &uid)
Set unique identifier.
Definition: addressee.cpp:368
KABC::Addressee::insertKey
void insertKey(const Key &key)
Insert a key.
Definition: addressee.cpp:1350
KABC::Sound::data
QByteArray data() const
Returns the raw data of this sound.
Definition: sound.cpp:138
KABC::Geo::isValid
bool isValid() const
Returns, whether this object contains a valid geographical position.
Definition: geo.cpp:106
KABC::PhoneNumber::Modem
Modem.
Definition: phonenumber.h:57
KABC::TimeZone
Time zone information.
Definition: timezone.h:35
KABC::Addressee::setOrganization
void setOrganization(const QString &organization)
Set organization.
Definition: addressee.cpp:805
KABC::Addressee::setGeo
void setGeo(const Geo &geo)
Set geographic position.
Definition: addressee.cpp:745
KABC::Addressee::setUrl
void setUrl(const KUrl &url)
Set homepage.
Definition: addressee.cpp:925
KABC::PhoneNumber::Msg
Messaging.
Definition: phonenumber.h:50
KABC::Address::List
QList< Address > List
List of addresses.
Definition: address.h:46
KABC::Address::setRegion
void setRegion(const QString &region)
Sets the region, e.g.
Definition: address.cpp:420
KABC::Key::setCustomTypeString
void setCustomTypeString(const QString &type)
Sets custom type string.
Definition: key.cpp:163
KABC::PhoneNumber::Video
Video phone.
Definition: phonenumber.h:55
KABC::PhoneNumber::Home
Home number.
Definition: phonenumber.h:48
KABC::Addressee::setName
void setName(const QString &name)
Set name.
Definition: addressee.cpp:387
KABC::Address::setLabel
void setLabel(const QString &label)
Sets the delivery label.
Definition: address.cpp:468
KABC::Addressee
address book entry
Definition: addressee.h:74
KABC::Addressee::setNote
void setNote(const QString &note)
Set note.
Definition: addressee.cpp:845
KABC::PhoneNumber::Work
Office number.
Definition: phonenumber.h:49
KABC::Addressee::insertAddress
void insertAddress(const Address &address)
Insert an address.
Definition: addressee.cpp:1512
KABC::Address::Intl
international
Definition: address.h:53
KABC::Picture::isEmpty
bool isEmpty() const
Returns true, if the picture is empty.
Definition: picture.cpp:136
KABC::Addressee::insertCustom
void insertCustom(const QString &app, const QString &name, const QString &value)
Insert custom entry.
Definition: addressee.cpp:1625
KABC::Key::setType
void setType(Type type)
Sets the type.
Definition: key.cpp:158
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:885
KABC::Geo
Geographic position.
Definition: geo.h:35
KABC::Picture::type
QString type() const
Returns the type of this picture.
Definition: picture.cpp:216
KABC::Addressee::setProductId
void setProductId(const QString &productId)
Set product identifier.
Definition: addressee.cpp:865
KABC::Picture::setUrl
void setUrl(const QString &url)
Sets a URL for the location of the picture file.
Definition: picture.cpp:143
KABC::Key::customTypeString
QString customTypeString() const
Returns the custom type string.
Definition: key.cpp:173
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::setExtended
void setExtended(const QString &extended)
Sets the extended address information.
Definition: address.cpp:372
KABC::Address::Work
address at work
Definition: address.h:57
KABC::Addressee::setBirthday
void setBirthday(const QDateTime &birthday)
Set birthday.
Definition: addressee.cpp:547
KABC::PhoneNumber::Pref
Preferred number.
Definition: phonenumber.h:51
KABC::Sound::isIntern
bool isIntern() const
Returns whether the sound is described by a URL (extern) or by the raw data (intern).
Definition: sound.cpp:122
KABC::PhoneNumber::Car
Car phone.
Definition: phonenumber.h:58
KABC::Addressee::setTimeZone
void setTimeZone(const TimeZone &timeZone)
Set time zone.
Definition: addressee.cpp:725
KABC::PhoneNumber::Isdn
ISDN connection.
Definition: phonenumber.h:59
KABC::Key::type
Type type() const
Returns the type, see Type.
Definition: key.cpp:168
KABC::Geo::toString
QString toString() const
Returns string representation of geographical position.
Definition: geo.cpp:142
KABC::Picture::isIntern
bool isIntern() const
Returns whether the picture is described by a URL (extern) or by the raw data (intern).
Definition: picture.cpp:184
KABC::Addressee::setSecrecy
void setSecrecy(const Secrecy &secrecy)
Set security class.
Definition: addressee.cpp:945
KABC::Sound::url
QString url() const
Returns the location URL of this sound.
Definition: sound.cpp:133
KABC::TimeZone::toString
QString toString() const
Return string representation of time zone offset.
Definition: timezone.cpp:113
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:01:05 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
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

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