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

kaddressbook

  • sources
  • kde-4.12
  • kdepim
  • kaddressbook
  • xxport
  • gmx
gmx_xxport.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KAddressbook.
3  Copyright (c) 2003 - 2004 Helge Deller <deller@kde.org>
4  Copyright (c) 2009 Laurent Montel <montel@kde.org>
5  Copyright (c) 2009 Urs Joss <tschenturs@gmx.ch>
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License along
18  with this program; if not, write to the Free Software Foundation, Inc.,
19  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, permission is given to link this program
22  with any edition of Qt, and distribute the resulting executable,
23  without including the source code for Qt in the source distribution.
24 */
25 
26 /*
27  Description:
28 
29  This import/export filter reads and writes addressbook entries in the
30  gmx format which is natively used by the german freemail provider GMX.
31  The big advantage of this format is, that it stores it's information
32  very consistently and makes parsing pretty simple. Furthermore, most
33  information needed by KABC is available when compared to other formats.
34  For further information please visit http://www.gmx.com
35 
36  A couple of notes:
37 
38  a) Categories
39 
40  GMX allows to define categories in the UI and assign one or more categories
41  to each addressee. The gmxa file contains a list of defined categories in
42  the last part of the file, in the section AB_CATEGORIES. The Category_id in
43  this list is a 1-based index. The multi-category assignement of each
44  contact consists of a bitfield which applies one bit per category. E.g.
45  if one contact belongs to category 1 and 3, the bit-field for the category
46  assignment for this addressee is 0101 or decimal 5.
47 
48  The export of categories into hte gmxa file works flawlessly and also
49  transfers nicely into the addressee categories. During the import of a
50  gmxa file into GMX, the procedure will correctly manage the category
51  bitfield for each contact. However GMX does *not* process the category
52  list in the end of the file. In other words: If your categories have
53  changed (either in kadderssbook or in GMX) since your
54  previous import, the addressee records may point to the wrong - or even
55  non-existing - categories. After an import it is suggested that you
56  manually verify the category list is still valid. If not, you need to
57  manually delete any categories which alphabetically list beyond your new
58  or deleted category and recreate the remaining categories.
59 
60  Only up to 31 different categories over all contacts are exported. Any
61  more categories are ignored.
62 
63  b) Address types
64 
65  Home address and Work address are relatively straight forwardly handled.
66  The third address type "Other" is factored out of a bunch of different
67  address elements, which have been chosen relatively at random. There is
68  some interpretation which is not completely reversible.
69 
70  If you thus export a contact from kaddressbook to GMX
71  and reimport it into kaddressbook, you will not exactly
72  get the same contact as the original one.
73 
74  Also other items affect this non-reversability: GMX should receive a nick
75  name in the gmxa file. If there is none defined in kaddressbook,
76  the export will use the formatted name instead. If you reimport
77  such a record, you'll end up with the formatted name in the nickname field.
78 */
79 
80 #include "gmx_xxport.h"
81 #include "pimcommon/widgets/renamefiledialog.h"
82 
83 #include <KCodecs>
84 #include <KDebug>
85 #include <KFileDialog>
86 #include <KIO/NetAccess>
87 #include <KLocale>
88 #include <KMessageBox>
89 #include <KTemporaryFile>
90 #include <KUrl>
91 
92 #include <QtCore/QFile>
93 #include <QtCore/QMap>
94 #include <QtCore/QList>
95 #include <QtCore/QTextStream>
96 
97 #define GMX_FILESELECTION_STRING QLatin1String("*.gmxa|") + i18n( "GMX address book file (*.gmxa)" )
98 
99 const int typeHome = 0;
100 const int typeWork = 1;
101 const int typeOther = 2;
102 
103 GMXXXPort::GMXXXPort( QWidget *parentWidget )
104  : XXPort( parentWidget )
105 {
106 }
107 
108 static bool checkDateTime( const QString &dateStr, QDateTime &dt )
109 {
110  if ( dateStr.isEmpty() ) {
111  return false;
112  }
113 
114  dt = QDateTime::fromString( dateStr, Qt::ISODate );
115  if ( dt.isValid() && dt.date().year() > 1901 ) {
116  return true;
117  }
118  dt.setDate( QDate() );
119 
120  return false;
121 }
122 
123 /* import */
124 
125 KABC::Addressee::List GMXXXPort::importContacts() const
126 {
127  KABC::Addressee::List addresseeList;
128 
129  QString fileName =
130  KFileDialog::getOpenFileName( QDir::homePath(), GMX_FILESELECTION_STRING, 0 );
131 
132  if ( fileName.isEmpty() ) {
133  return addresseeList;
134  }
135 
136  QFile file( fileName );
137  if ( !file.open( QIODevice::ReadOnly ) ) {
138  QString msg = i18n( "<qt>Unable to open <b>%1</b> for reading.</qt>", fileName );
139  KMessageBox::error( parentWidget(), msg );
140  return addresseeList;
141  }
142 
143  QDateTime dt;
144  QTextStream gmxStream( &file );
145  gmxStream.setCodec( "ISO 8859-1" );
146  QString line, line2;
147  line = gmxStream.readLine();
148  line2 = gmxStream.readLine();
149  if ( !line.startsWith( QLatin1String( "AB_ADDRESSES:" ) ) ||
150  !line2.startsWith( QLatin1String( "Address_id" ) ) ) {
151  KMessageBox::error(
152  parentWidget(),
153  i18n( "%1 is not a GMX address book file.", fileName ) );
154  return addresseeList;
155  }
156 
157  QStringList itemList;
158  QMap<QString, QString> categoriesOfAddressee;
159  typedef QMap<QString, KABC::Addressee *> AddresseeMap;
160  AddresseeMap addresseeMap;
161 
162  // "Address_id,Nickname,Firstname,Lastname,Title,Birthday,Comments,
163  // Change_date,Status,Address_link_id,Categories"
164  line = gmxStream.readLine();
165  while ( ( line != QLatin1String( "####" ) ) && !gmxStream.atEnd() ) {
166  // an addressee entry may spread over several lines in the file
167  while ( 1 ) {
168  itemList = line.split( QLatin1Char('#'), QString::KeepEmptyParts );
169  if ( itemList.count() >= 11 ) {
170  break;
171  }
172  line.append( QLatin1Char('\n') );
173  line.append( gmxStream.readLine() );
174  };
175 
176  // populate the addressee
177  KABC::Addressee *addressee = new KABC::Addressee;
178  addressee->setNickName( itemList.at(1) );
179  addressee->setGivenName( itemList.at(2) );
180  addressee->setFamilyName( itemList.at(3) );
181  addressee->setFormattedName( itemList.at(3) + QLatin1String(", ") + itemList.at(2) );
182  addressee->setPrefix( itemList.at(4) );
183  if ( checkDateTime( itemList.at(5), dt ) ) {
184  addressee->setBirthday( dt );
185  }
186  addressee->setNote( itemList.at(6) );
187  if ( checkDateTime( itemList.at(7), dt ) ) {
188  addressee->setRevision( dt );
189  }
190  // addressee->setStatus( itemList[8] ); Status
191  // addressee->xxx( itemList[9] ); Address_link_id
192  categoriesOfAddressee[ itemList[0] ] = itemList[10];
193  addresseeMap[ itemList[0] ] = addressee;
194 
195  line = gmxStream.readLine();
196  }
197 
198  // now read the address records
199  line = gmxStream.readLine();
200  if ( !line.startsWith( QLatin1String( "AB_ADDRESS_RECORDS:" ) ) ) {
201  kWarning() << "Could not find address records!";
202  return addresseeList;
203  }
204  // Address_id,Record_id,Street,Country,Zipcode,City,Phone,Fax,Mobile,
205  // Mobile_type,Email,Homepage,Position,Comments,Record_type_id,Record_type,
206  // Company,Department,Change_date,Preferred,Status
207  line = gmxStream.readLine();
208  line = gmxStream.readLine();
209 
210  while ( !line.startsWith( QLatin1String( "####" ) ) && !gmxStream.atEnd() ) {
211  // an address entry may spread over several lines in the file
212  while ( 1 ) {
213  itemList = line.split( QLatin1Char('#'), QString::KeepEmptyParts );
214  if ( itemList.count() >= 21 ) {
215  break;
216  }
217  line.append( QLatin1Char('\n') );
218  line.append( gmxStream.readLine() );
219  };
220 
221  KABC::Addressee *addressee = addresseeMap[ itemList[0] ];
222  if ( addressee ) {
223  // itemList[1] = Record_id (numbered item, ignore here)
224  int recordTypeId = itemList[14].toInt();
225  KABC::Address::Type addressType;
226  KABC::PhoneNumber::Type phoneType;
227  switch ( recordTypeId ) {
228  case typeHome:
229  addressType = KABC::Address::Home;
230  phoneType = KABC::PhoneNumber::Home;
231  break;
232  case typeWork:
233  addressType = KABC::Address::Work;
234  phoneType = KABC::PhoneNumber::Work;
235  break;
236  case typeOther:
237  default:
238  addressType = KABC::Address::Intl;
239  phoneType = KABC::PhoneNumber::Voice;
240  break;
241  }
242  KABC::Address address = addressee->address( addressType );
243  address.setStreet( itemList[2] );
244  address.setCountry( itemList[3] );
245  address.setPostalCode( itemList[4] );
246  address.setLocality( itemList[5] );
247  if ( !itemList[6].isEmpty() ) {
248  addressee->insertPhoneNumber(
249  KABC::PhoneNumber( itemList[6], phoneType ) );
250  }
251  if ( !itemList[7].isEmpty() ) {
252  addressee->insertPhoneNumber(
253  KABC::PhoneNumber( itemList[7], KABC::PhoneNumber::Fax ) );
254  }
255  KABC::PhoneNumber::Type cellType = KABC::PhoneNumber::Cell;
256  // itemList[9]=Mobile_type // always 0 or -1(default phone).
257  // if ( itemList[19].toInt() & 4 ) cellType |= KABC::PhoneNumber::Pref;
258  // don't do the above to avoid duplicate mobile numbers
259  if ( !itemList[8].isEmpty() ) {
260  addressee->insertPhoneNumber( KABC::PhoneNumber( itemList[8], cellType ) );
261  }
262  bool preferred = false;
263  if ( itemList[19].toInt() & 1 ) {
264  preferred = true;
265  }
266  addressee->insertEmail( itemList[10], preferred );
267  if ( !itemList[11].isEmpty() ) {
268  addressee->setUrl( itemList[11] );
269  }
270  if ( !itemList[12].isEmpty() ) {
271  addressee->setRole( itemList[12] );
272  }
273  // itemList[13]=Comments
274  // itemList[14]=Record_type_id (0,1,2) - see above
275  // itemList[15]=Record_type (name of this additional record entry)
276  if ( !itemList[16].isEmpty() ) {
277  addressee->setOrganization( itemList[16] ); // Company
278  }
279  if ( !itemList[17].isEmpty() ) {
280  addressee->insertCustom( QLatin1String("KADDRESSBOOK"), QLatin1String("X-Department"), itemList[17] ); // Department
281  }
282  if ( checkDateTime( itemList[18], dt ) ) {
283  addressee->setRevision( dt ); // Change_date
284  }
285  // itemList[19]=Preferred (see above)
286  // itemList[20]=Status (should always be "1")
287  addressee->insertAddress( address );
288  } else {
289  kWarning() << "unresolved line:" << line;
290  }
291  line = gmxStream.readLine();
292  }
293 
294  // extract the categories from the list of addressees of the file to import
295  QStringList usedCategoryList;
296  line = gmxStream.readLine();
297  line2 = gmxStream.readLine();
298  if ( !line.startsWith( QLatin1String( "AB_CATEGORIES:" ) ) ||
299  !line2.startsWith( QLatin1String( "Category_id" ) ) ) {
300  kWarning() << "Could not find category records!";
301  } else {
302  while ( !line.startsWith( QLatin1String( "####" ) ) &&
303  !gmxStream.atEnd() ) {
304  // a category should not spread over multiple lines, but just in case
305  while ( 1 ) {
306  itemList = line.split( QLatin1Char('#'), QString::KeepEmptyParts );
307  if ( itemList.count() >= 3 ) {
308  break;
309  }
310  line.append( QLatin1Char('\n') );
311  line.append( gmxStream.readLine() );
312  };
313  usedCategoryList.append( itemList[1] );
314  line = gmxStream.readLine();
315  };
316  }
317 
318  // now add the addresses to addresseeList
319  for ( AddresseeMap::Iterator addresseeIt = addresseeMap.begin();
320  addresseeIt != addresseeMap.end(); ++addresseeIt ) {
321  KABC::Addressee *addressee = addresseeIt.value();
322  // Add categories
323  // catgories is a bitfield with max 31 defined categories
324  int categories = categoriesOfAddressee[ addresseeIt.key() ].toInt();
325  for ( int i=32; i >= 0; --i ) {
326  // convert category index to bitfield value for comparison
327  int catBit = 1 << i;
328  if ( catBit > categories ) {
329  continue; // current index unassigned
330  }
331  if ( catBit & categories && usedCategoryList.count() > i ) {
332  addressee->insertCategory( usedCategoryList[i] );
333  }
334  }
335  addresseeList.append( *addressee );
336  delete addressee;
337  }
338 
339  file.close();
340  return addresseeList;
341 }
342 
343 /* export */
344 
345 bool GMXXXPort::exportContacts( const KABC::AddresseeList &list ) const
346 {
347  KUrl url = KFileDialog::getSaveUrl(
348  KUrl( QDir::homePath() + QLatin1String("/addressbook.gmx") ), GMX_FILESELECTION_STRING );
349  if ( url.isEmpty() ) {
350  return true;
351  }
352 
353  if ( QFileInfo( url.isLocalFile() ?
354  url.toLocalFile() : url.path() ).exists() ) {
355  if ( url.isLocalFile() && QFileInfo( url.toLocalFile() ).exists() ) {
356  PimCommon::RenameFileDialog::RenameFileDialogResult result = PimCommon::RenameFileDialog::RENAMEFILE_IGNORE;
357  PimCommon::RenameFileDialog *dialog = new PimCommon::RenameFileDialog(url, false, parentWidget());
358  result = static_cast<PimCommon::RenameFileDialog::RenameFileDialogResult>(dialog->exec());
359  if ( result == PimCommon::RenameFileDialog::RENAMEFILE_RENAME ) {
360  url = dialog->newName();
361  } else if (result == PimCommon::RenameFileDialog::RENAMEFILE_IGNORE) {
362  delete dialog;
363  return true;
364  }
365  delete dialog;
366  }
367  }
368 
369  if ( !url.isLocalFile() ) {
370  KTemporaryFile tmpFile;
371  if ( !tmpFile.open() ) {
372  QString txt = i18n( "<qt>Unable to open file <b>%1</b></qt>", url.url() );
373  KMessageBox::error( parentWidget(), txt );
374  return false;
375  }
376 
377  doExport( &tmpFile, list );
378  tmpFile.flush();
379 
380  return KIO::NetAccess::upload( tmpFile.fileName(), url, parentWidget() );
381  } else {
382  QString fileName = url.toLocalFile();
383  QFile file( fileName );
384 
385  if ( !file.open( QIODevice::WriteOnly ) ) {
386  QString txt = i18n( "<qt>Unable to open file <b>%1</b>.</qt>", fileName );
387  KMessageBox::error( parentWidget(), txt );
388  return false;
389  }
390 
391  doExport( &file, list );
392  file.close();
393 
394  return true;
395  }
396 }
397 
398 static const QString dateString( const QDateTime &dt )
399 {
400  if ( !dt.isValid() ) {
401  return QString::fromLatin1( "1000-01-01 00:00:00" );
402  }
403  QString d( dt.toString( Qt::ISODate ) );
404  d[10] = ' '; // remove the "T" in the middle of the string
405  return d;
406 }
407 
408 static const QStringList assignedCategoriesSorted( const KABC::AddresseeList &list )
409 {
410  // Walk through the addressees and return a unique list of up to 31
411  // categories, alphabetically sorted
412  QStringList categoryList;
413  const KABC::Addressee *addressee;
414  for ( KABC::AddresseeList::ConstIterator addresseeIt = list.begin();
415  addresseeIt != list.end() && categoryList.count() < 32; ++addresseeIt ) {
416  addressee = &( *addresseeIt );
417  if ( addressee->isEmpty() ) continue;
418  const QStringList categories = addressee->categories();
419  for ( int i=0; i < categories.count() && categoryList.count() < 32; ++i ) {
420  if ( !categoryList.contains( categories[i]) ) {
421  categoryList.append( categories[i] );
422  }
423  }
424  }
425  categoryList.sort();
426  return categoryList;
427 }
428 
429 void GMXXXPort::doExport( QFile *fp, const KABC::AddresseeList &list ) const
430 {
431  if ( !fp || !list.count() ) {
432  return;
433  }
434 
435  QTextStream t( fp );
436  t.setCodec( "ISO 8859-1" );
437 
438  typedef QMap<int, const KABC::Addressee *> AddresseeMap;
439  AddresseeMap addresseeMap;
440  const KABC::Addressee *addressee;
441 
442  t << "AB_ADDRESSES:\n";
443  t << "Address_id,Nickname,Firstname,Lastname,Title,Birthday,Comments,"
444  "Change_date,Status,Address_link_id,Categories\n";
445 
446  QList<QString> categoryMap;
447  categoryMap.append( assignedCategoriesSorted( list ) );
448 
449  int addresseeId = 0;
450  const QChar DELIM( QLatin1Char('#') );
451  for ( KABC::AddresseeList::ConstIterator it = list.begin();
452  it != list.end(); ++it ) {
453  addressee = &(*it);
454  if ( addressee->isEmpty() ) {
455  continue;
456  }
457  addresseeMap[ ++addresseeId ] = addressee;
458 
459  // Assign categories as bitfield
460  const QStringList categories = addressee->categories();
461  long int category = 0;
462  if ( categories.count() > 0 ) {
463  for ( int i=0; i < categories.count(); ++i ) {
464  if ( categoryMap.contains( categories[i] ) ) {
465  category |= 1 << categoryMap.indexOf( categories[i], 0 ) ;
466  }
467  }
468  }
469 
470  // GMX sorts by nickname by default - don't leave empty
471  QString nickName = addressee->nickName();
472  if ( nickName.isEmpty() ) {
473  nickName = addressee->formattedName();
474  }
475 
476  t << addresseeId << DELIM // Address_id
477  << nickName << DELIM // Nickname
478  << addressee->givenName() << DELIM // Firstname
479  << addressee->familyName() << DELIM // Lastname
480  << addressee->prefix() << DELIM // Title - Note: ->title()
481  // refers to the professional title
482  << dateString( addressee->birthday() ) << DELIM // Birthday
483  << addressee->note() /*.replace('\n',"\r\n")*/ << DELIM // Comments
484  << dateString( addressee->revision() ) << DELIM // Change_date
485  << "1" << DELIM // Status
486  << DELIM // Address_link_id
487  << category << endl; // Categories
488  }
489 
490  t << "####\n";
491  t << "AB_ADDRESS_RECORDS:\n";
492  t << "Address_id,Record_id,Street,Country,Zipcode,City,Phone,Fax,Mobile,"
493  "Mobile_type,Email,Homepage,Position,Comments,Record_type_id,Record_type,"
494  "Company,Department,Change_date,Preferred,Status\n";
495 
496  addresseeId = 1;
497  while ( ( addressee = addresseeMap[ addresseeId ] ) != 0 ) {
498 
499  const KABC::PhoneNumber::List cellPhones =
500  addressee->phoneNumbers( KABC::PhoneNumber::Cell );
501 
502  const QStringList emails = addressee->emails();
503 
504  for ( int recId=0; recId<3; ++recId ) {
505  KABC::Address address;
506  KABC::PhoneNumber phone, fax, cell;
507 
508  // address preference flag:
509  // & 1: preferred email address
510  // & 4: preferred cell phone
511  int prefFlag=0;
512 
513  switch ( recId ) {
514  // Assign address, phone and cellphone, fax if applicable
515  case typeHome:
516  address = addressee->address( KABC::Address::Home );
517  phone = addressee->phoneNumber( KABC::PhoneNumber::Home );
518  if ( cellPhones.count() > 0 ) {
519  cell = cellPhones.at( 0 );
520  if ( !cell.isEmpty() ) {
521  prefFlag |= 4;
522  }
523  }
524  break;
525  case typeWork:
526  address = addressee->address( KABC::Address::Work );
527  phone = addressee->phoneNumber( KABC::PhoneNumber::Work );
528  if ( cellPhones.count() >= 2 ) {
529  cell = cellPhones.at( 1 );
530  }
531  fax = addressee->phoneNumber( KABC::PhoneNumber::Fax );
532  break;
533  case typeOther:
534  default:
535  if ( addressee->addresses( KABC::Address::Home ).count() > 1 ) {
536  address = addressee->addresses( KABC::Address::Home ).at( 1 );
537  }
538  if ( ( address.isEmpty() ) &&
539  ( addressee->addresses( KABC::Address::Work ).count() > 1 ) ) {
540  address = addressee->addresses( KABC::Address::Work ).at( 1 );
541  }
542  if ( address.isEmpty() ) {
543  address = addressee->address( KABC::Address::Dom );
544  }
545  if ( address.isEmpty() ) {
546  address = addressee->address( KABC::Address::Intl );
547  }
548  if ( address.isEmpty() ) {
549  address = addressee->address( KABC::Address::Postal );
550  }
551  if ( address.isEmpty() ) {
552  address = addressee->address( KABC::Address::Parcel );
553  }
554 
555  if ( addressee->phoneNumbers( KABC::PhoneNumber::Home ).count() > 1 ) {
556  phone = addressee->phoneNumbers( KABC::PhoneNumber::Home ).at( 1 );
557  }
558  if ( ( phone.isEmpty() ) && ( addressee->phoneNumbers(
559  KABC::PhoneNumber::Work ).count() > 1 ) )
560  phone = addressee->phoneNumbers( KABC::PhoneNumber::Work ).at( 1 );
561  if ( phone.isEmpty() ) {
562  phone = addressee->phoneNumber( KABC::PhoneNumber::Voice );
563  }
564  if ( phone.isEmpty() ) {
565  phone = addressee->phoneNumber( KABC::PhoneNumber::Msg );
566  }
567  if ( phone.isEmpty() ) {
568  phone = addressee->phoneNumber( KABC::PhoneNumber::Isdn );
569  }
570  if ( phone.isEmpty() ) {
571  phone = addressee->phoneNumber( KABC::PhoneNumber::Car );
572  }
573  if ( phone.isEmpty() ) {
574  phone = addressee->phoneNumber( KABC::PhoneNumber::Pager );
575  }
576 
577  switch ( cellPhones.count() ) {
578  case 0:
579  break;
580  case 1:
581  case 2:
582  if ( !address.isEmpty() ) {
583  cell = cellPhones.at( 0 );
584  }
585  break;
586  default:
587  cell = cellPhones.at( 2 );
588  break;
589  }
590  break;
591  }
592 
593  QString email;
594  if ( emails.count()>recId ) {
595  email = emails[ recId ];
596  if ( email == addressee->preferredEmail() ) {
597  prefFlag |= 1;
598  }
599  }
600 
601  if ( !address.isEmpty() || !phone.isEmpty() ||
602  !cell.isEmpty() || !email.isEmpty() ) {
603  t << addresseeId << DELIM // Address_id
604  << recId << DELIM // Record_id
605  << address.street() << DELIM // Street
606  << address.country() << DELIM // Country
607  << address.postalCode() << DELIM // Zipcode
608  << address.locality() << DELIM // City
609  << phone.number() << DELIM // Phone
610  << fax.number() << DELIM // Fax
611  << cell.number() << DELIM // Mobile
612 
613  << ( ( recId == typeWork ) ? 0 : 1 ) << DELIM // Mobile_type
614 
615  << email << DELIM // Email
616 
617  << ( ( recId == typeWork ) ?
618  addressee->url().url() :
619  QString() ) << DELIM // Homepage
620 
621  << ( ( recId == typeWork ) ?
622  addressee->role() :
623  QString() ) << DELIM // Position
624 
625  << ( ( recId == typeHome ) ?
626  addressee->custom( QLatin1String("KADDRESSBOOK"), QLatin1String("X-SpousesName") ) :
627  QString() ) << DELIM // Comments
628 
629  << recId << DELIM // Record_type_id (0,1,2)
630 
631  << DELIM // Record_type
632 
633  << ( ( recId == typeWork ) ?
634  addressee->organization() :
635  QString() ) << DELIM // Company
636 
637  << ( ( recId == typeWork ) ?
638  addressee->custom( QLatin1String("KADDRESSBOOK"), QLatin1String("X-Department") ) :
639  QString() ) << DELIM // Department
640 
641  << dateString( addressee->revision() ) << DELIM // Change_date
642 
643  << prefFlag << DELIM // Preferred:
644  // ( & 1: preferred email,
645  // & 4: preferred cell phone )
646  << 1 << endl; // Status (should always be "1")
647  }
648  }
649 
650  ++addresseeId;
651  };
652 
653  t << "####" << endl;
654  t << "AB_CATEGORIES:" << endl;
655  t << "Category_id,Name,Icon_id" << endl;
656 
657  // Write Category List (beware: Category_ID 0 is reserved for none
658  // Interestingly: The index here is an int sequence and does not
659  // correspond to the bit reference used above.
660  for ( int i = 0; i < categoryMap.size(); ++i ) {
661  t << ( i + 1 ) << DELIM << categoryMap.at( i ) << DELIM << 0 << endl;
662  }
663  t << "####" << endl;
664 }
665 
assignedCategoriesSorted
static const QStringList assignedCategoriesSorted(const KABC::AddresseeList &list)
Definition: gmx_xxport.cpp:408
XXPort::parentWidget
QWidget * parentWidget() const
Returns the parent widget that can be used as parent for GUI components.
Definition: xxport.cpp:51
gmx_xxport.h
GMX_FILESELECTION_STRING
#define GMX_FILESELECTION_STRING
Definition: gmx_xxport.cpp:97
typeWork
const int typeWork
Definition: gmx_xxport.cpp:100
typeHome
const int typeHome
Definition: gmx_xxport.cpp:99
dateString
static const QString dateString(const QDateTime &dt)
Definition: gmx_xxport.cpp:398
checkDateTime
static bool checkDateTime(const QString &dateStr, QDateTime &dt)
Definition: gmx_xxport.cpp:108
GMXXXPort::exportContacts
bool exportContacts(const KABC::AddresseeList &list) const
Definition: gmx_xxport.cpp:345
XXPort
The base class for all import/export modules.
Definition: xxport.h:32
typeOther
const int typeOther
Definition: gmx_xxport.cpp:101
GMXXXPort::GMXXXPort
GMXXXPort(QWidget *parent=0)
Definition: gmx_xxport.cpp:103
GMXXXPort::importContacts
KABC::Addressee::List importContacts() const
Imports a list of contacts.
Definition: gmx_xxport.cpp:125
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kaddressbook

Skip menu "kaddressbook"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

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