summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-19 11:32:40 (UTC)
committer zautrix <zautrix>2004-09-19 11:32:40 (UTC)
commiteea0ff04703dffdbe8b67a0dc9f592597d7450c1 (patch) (unidiff)
tree874549d9c1c6239304fe1540d1b56269652954c0
parent953277a85e6ec5630ab0d64b4d68815e4e4f9906 (diff)
downloadkdepimpi-eea0ff04703dffdbe8b67a0dc9f592597d7450c1.zip
kdepimpi-eea0ff04703dffdbe8b67a0dc9f592597d7450c1.tar.gz
kdepimpi-eea0ff04703dffdbe8b67a0dc9f592597d7450c1.tar.bz2
more AB sync
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/address.h1
-rw-r--r--kabc/addressbook.cpp28
-rw-r--r--kabc/addressbook.h4
-rw-r--r--kabc/addressee.cpp39
-rw-r--r--kabc/addressee.h4
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.cpp9
-rw-r--r--kaddressbook/kabcore.cpp2
7 files changed, 81 insertions, 6 deletions
diff --git a/kabc/address.h b/kabc/address.h
index 6b53c7e..37dd851 100644
--- a/kabc/address.h
+++ b/kabc/address.h
@@ -1,80 +1,81 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 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 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KABC_ADDRESS_H 28#ifndef KABC_ADDRESS_H
29#define KABC_ADDRESS_H 29#define KABC_ADDRESS_H
30 30
31#include <qmap.h> 31#include <qmap.h>
32#include <qstring.h> 32#include <qstring.h>
33#include <qstringlist.h>
33#include <qvaluelist.h> 34#include <qvaluelist.h>
34 35
35// template tags for address formatting localization 36// template tags for address formatting localization
36#define KABC_FMTTAG_realname QString("%n") 37#define KABC_FMTTAG_realname QString("%n")
37#define KABC_FMTTAG_REALNAME QString("%N") 38#define KABC_FMTTAG_REALNAME QString("%N")
38#define KABC_FMTTAG_company QString("%cm") 39#define KABC_FMTTAG_company QString("%cm")
39#define KABC_FMTTAG_COMPANY QString("%CM") 40#define KABC_FMTTAG_COMPANY QString("%CM")
40#define KABC_FMTTAG_pobox QString("%p") 41#define KABC_FMTTAG_pobox QString("%p")
41#define KABC_FMTTAG_street QString("%s") 42#define KABC_FMTTAG_street QString("%s")
42#define KABC_FMTTAG_STREET QString("%S") 43#define KABC_FMTTAG_STREET QString("%S")
43#define KABC_FMTTAG_zipcode QString("%z") 44#define KABC_FMTTAG_zipcode QString("%z")
44#define KABC_FMTTAG_location QString("%l") 45#define KABC_FMTTAG_location QString("%l")
45#define KABC_FMTTAG_LOCATION QString("%L") 46#define KABC_FMTTAG_LOCATION QString("%L")
46#define KABC_FMTTAG_region QString("%r") 47#define KABC_FMTTAG_region QString("%r")
47#define KABC_FMTTAG_REGION QString("%R") 48#define KABC_FMTTAG_REGION QString("%R")
48#define KABC_FMTTAG_newline QString("\\n") 49#define KABC_FMTTAG_newline QString("\\n")
49#define KABC_FMTTAG_condcomma QString("%,") 50#define KABC_FMTTAG_condcomma QString("%,")
50#define KABC_FMTTAG_condwhite QString("%w") 51#define KABC_FMTTAG_condwhite QString("%w")
51#define KABC_FMTTAG_purgeempty QString("%0") 52#define KABC_FMTTAG_purgeempty QString("%0")
52 53
53namespace KABC { 54namespace KABC {
54 55
55/** 56/**
56 @short Postal address information. 57 @short Postal address information.
57 58
58 This class represents information about a postal address. 59 This class represents information about a postal address.
59*/ 60*/
60class Address 61class Address
61{ 62{
62 friend QDataStream &operator<<( QDataStream &, const Address & ); 63 friend QDataStream &operator<<( QDataStream &, const Address & );
63 friend QDataStream &operator>>( QDataStream &, Address & ); 64 friend QDataStream &operator>>( QDataStream &, Address & );
64 65
65 public: 66 public:
66 /** 67 /**
67 List of addresses. 68 List of addresses.
68 */ 69 */
69 typedef QValueList<Address> List; 70 typedef QValueList<Address> List;
70 typedef QValueList<int> TypeList; 71 typedef QValueList<int> TypeList;
71 72
72 /** 73 /**
73 Address types: 74 Address types:
74 75
75 @li @p Dom - domestic 76 @li @p Dom - domestic
76 @li @p Intl - international 77 @li @p Intl - international
77 @li @p Postal - postal 78 @li @p Postal - postal
78 @li @p Parcel - parcel 79 @li @p Parcel - parcel
79 @li @p Home - home address 80 @li @p Home - home address
80 @li @p Work - address at work 81 @li @p Work - address at work
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 46a9cf4..64832f1 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -203,101 +203,104 @@ AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
203 (d->mIt)--; 203 (d->mIt)--;
204 return *this; 204 return *this;
205} 205}
206 206
207bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) 207bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
208{ 208{
209 return ( d->mIt == it.d->mIt ); 209 return ( d->mIt == it.d->mIt );
210} 210}
211 211
212bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 212bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
213{ 213{
214 return ( d->mIt != it.d->mIt ); 214 return ( d->mIt != it.d->mIt );
215} 215}
216 216
217 217
218AddressBook::AddressBook() 218AddressBook::AddressBook()
219{ 219{
220 init(0, "contact"); 220 init(0, "contact");
221} 221}
222 222
223AddressBook::AddressBook( const QString &config ) 223AddressBook::AddressBook( const QString &config )
224{ 224{
225 init(config, "contact"); 225 init(config, "contact");
226} 226}
227 227
228AddressBook::AddressBook( const QString &config, const QString &family ) 228AddressBook::AddressBook( const QString &config, const QString &family )
229{ 229{
230 init(config, family); 230 init(config, family);
231 231
232} 232}
233 233
234// the default family is "contact" 234// the default family is "contact"
235void AddressBook::init(const QString &config, const QString &family ) 235void AddressBook::init(const QString &config, const QString &family )
236{ 236{
237 blockLSEchange = false; 237 blockLSEchange = false;
238 d = new AddressBookData; 238 d = new AddressBookData;
239 QString fami = family; 239 QString fami = family;
240 qDebug("new ab "); 240 qDebug("new ab ");
241 if (config != 0) { 241 if (config != 0) {
242 qDebug("config != 0 "); 242 qDebug("config != 0 ");
243 if ( family == "syncContact" ) { 243 if ( family == "syncContact" ) {
244 qDebug("creating sync config "); 244 qDebug("creating sync config ");
245 fami = "contact"; 245 fami = "contact";
246 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); 246 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
247 con->setGroup( "General" ); 247 con->setGroup( "General" );
248 con->writeEntry( "ResourceKeys", QString("sync") ); 248 con->writeEntry( "ResourceKeys", QString("sync") );
249 con->writeEntry( "Standard", QString("sync") ); 249 con->writeEntry( "Standard", QString("sync") );
250 con->setGroup( "Resource_sync" ); 250 con->setGroup( "Resource_sync" );
251 con->writeEntry( "FileFormat", QString("vcard") );
252 con->writeEntry( "FileName", config ); 251 con->writeEntry( "FileName", config );
252 con->writeEntry( "FileFormat", QString("vcard") );
253 con->writeEntry( "ResourceIdentifier", QString("sync") ); 253 con->writeEntry( "ResourceIdentifier", QString("sync") );
254 con->writeEntry( "ResourceName", QString("sync_res") ); 254 con->writeEntry( "ResourceName", QString("sync_res") );
255 con->writeEntry( "ResourceType", QString("file") ); 255 if ( config.right(4) == ".xml" )
256 con->writeEntry( "ResourceType", QString("qtopia") );
257 else
258 con->writeEntry( "ResourceType", QString("file") );
256 //con->sync(); 259 //con->sync();
257 d->mConfig = con; 260 d->mConfig = con;
258 } 261 }
259 else 262 else
260 d->mConfig = new KConfig( locateLocal("config", config) ); 263 d->mConfig = new KConfig( locateLocal("config", config) );
261// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 264// qDebug("AddressBook::init 1 config=%s",config.latin1() );
262 } 265 }
263 else { 266 else {
264 d->mConfig = 0; 267 d->mConfig = 0;
265// qDebug("AddressBook::init 1 config=0"); 268// qDebug("AddressBook::init 1 config=0");
266 } 269 }
267 270
268//US d->mErrorHandler = 0; 271//US d->mErrorHandler = 0;
269 d->mManager = new KRES::Manager<Resource>( fami, false ); 272 d->mManager = new KRES::Manager<Resource>( fami, false );
270 d->mManager->readConfig( d->mConfig ); 273 d->mManager->readConfig( d->mConfig );
271 if ( family == "syncContact" ) { 274 if ( family == "syncContact" ) {
272 KRES::Manager<Resource> *manager = d->mManager; 275 KRES::Manager<Resource> *manager = d->mManager;
273 KRES::Manager<Resource>::ActiveIterator it; 276 KRES::Manager<Resource>::ActiveIterator it;
274 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 277 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
275 (*it)->setAddressBook( this ); 278 (*it)->setAddressBook( this );
276 if ( !(*it)->open() ) 279 if ( !(*it)->open() )
277 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 280 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
278 } 281 }
279 Resource *res = standardResource(); 282 Resource *res = standardResource();
280 if ( !res ) { 283 if ( !res ) {
281 qDebug("ERROR: no standard resource"); 284 qDebug("ERROR: no standard resource");
282 res = manager->createResource( "file" ); 285 res = manager->createResource( "file" );
283 if ( res ) 286 if ( res )
284 { 287 {
285 addResource( res ); 288 addResource( res );
286 } 289 }
287 else 290 else
288 qDebug(" No resource available!!!"); 291 qDebug(" No resource available!!!");
289 } 292 }
290 setStandardResource( res ); 293 setStandardResource( res );
291 manager->writeConfig(); 294 manager->writeConfig();
292 } 295 }
293 addCustomField( i18n( "Department" ), KABC::Field::Organization, 296 addCustomField( i18n( "Department" ), KABC::Field::Organization,
294 "X-Department", "KADDRESSBOOK" ); 297 "X-Department", "KADDRESSBOOK" );
295 addCustomField( i18n( "Profession" ), KABC::Field::Organization, 298 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
296 "X-Profession", "KADDRESSBOOK" ); 299 "X-Profession", "KADDRESSBOOK" );
297 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 300 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
298 "X-AssistantsName", "KADDRESSBOOK" ); 301 "X-AssistantsName", "KADDRESSBOOK" );
299 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 302 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
300 "X-ManagersName", "KADDRESSBOOK" ); 303 "X-ManagersName", "KADDRESSBOOK" );
301 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 304 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
302 "X-SpousesName", "KADDRESSBOOK" ); 305 "X-SpousesName", "KADDRESSBOOK" );
303 addCustomField( i18n( "Office" ), KABC::Field::Personal, 306 addCustomField( i18n( "Office" ), KABC::Field::Personal,
@@ -554,96 +557,117 @@ void AddressBook::removeDeletedAddressees()
554 deleteRemovedAddressees(); 557 deleteRemovedAddressees();
555 Iterator it = begin(); 558 Iterator it = begin();
556 Iterator it2 ; 559 Iterator it2 ;
557 QDateTime dt ( QDate( 2004,1,1) ); 560 QDateTime dt ( QDate( 2004,1,1) );
558 while ( it != end() ) { 561 while ( it != end() ) {
559 (*it).setRevision( dt ); 562 (*it).setRevision( dt );
560 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 563 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
561 (*it).setIDStr(""); 564 (*it).setIDStr("");
562 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE || (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 565 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE || (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
563 it2 = it; 566 it2 = it;
564 //qDebug("removing %s ",(*it).uid().latin1() ); 567 //qDebug("removing %s ",(*it).uid().latin1() );
565 ++it; 568 ++it;
566 removeAddressee( it2 ); 569 removeAddressee( it2 );
567 } else { 570 } else {
568 //qDebug("skipping %s ",(*it).uid().latin1() ); 571 //qDebug("skipping %s ",(*it).uid().latin1() );
569 ++it; 572 ++it;
570 } 573 }
571 } 574 }
572 deleteRemovedAddressees(); 575 deleteRemovedAddressees();
573} 576}
574 577
575void AddressBook::removeAddressee( const Iterator &it ) 578void AddressBook::removeAddressee( const Iterator &it )
576{ 579{
577 d->mRemovedAddressees.append( (*it) ); 580 d->mRemovedAddressees.append( (*it) );
578 d->mAddressees.remove( it.d->mIt ); 581 d->mAddressees.remove( it.d->mIt );
579} 582}
580 583
581AddressBook::Iterator AddressBook::find( const Addressee &a ) 584AddressBook::Iterator AddressBook::find( const Addressee &a )
582{ 585{
583 Iterator it; 586 Iterator it;
584 for ( it = begin(); it != end(); ++it ) { 587 for ( it = begin(); it != end(); ++it ) {
585 if ( a.uid() == (*it).uid() ) { 588 if ( a.uid() == (*it).uid() ) {
586 return it; 589 return it;
587 } 590 }
588 } 591 }
589 return end(); 592 return end();
590} 593}
591 594
592Addressee AddressBook::findByUid( const QString &uid ) 595Addressee AddressBook::findByUid( const QString &uid )
593{ 596{
594 Iterator it; 597 Iterator it;
595 for ( it = begin(); it != end(); ++it ) { 598 for ( it = begin(); it != end(); ++it ) {
596 if ( uid == (*it).uid() ) { 599 if ( uid == (*it).uid() ) {
597 return *it; 600 return *it;
598 } 601 }
599 } 602 }
600 return Addressee(); 603 return Addressee();
601} 604}
605Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
606{
607 Iterator it;
608 for ( it = begin(); it != end(); ++it ) {
609 if ( uid == (*it).getID( profile ) )
610 return (*it);
611 }
612 return Addressee();
613}
614void AddressBook::mergeAB( AddressBook *aBook, const QString& profile )
615{
616 Iterator it;
617 Addressee ad;
618 for ( it = begin(); it != end(); ++it ) {
619 ad = aBook->findByExternUid( (*it).externalUID(), profile );
620 if ( !ad.isEmpty() ) {
621 (*it).mergeContact( ad );
622 }
623 }
624}
625
602#if 0 626#if 0
603Addressee::List AddressBook::getExternLastSyncAddressees() 627Addressee::List AddressBook::getExternLastSyncAddressees()
604{ 628{
605 Addressee::List results; 629 Addressee::List results;
606 630
607 Iterator it; 631 Iterator it;
608 for ( it = begin(); it != end(); ++it ) { 632 for ( it = begin(); it != end(); ++it ) {
609 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 633 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
610 if ( (*it).familyName().left(4) == "!E: " ) 634 if ( (*it).familyName().left(4) == "!E: " )
611 results.append( *it ); 635 results.append( *it );
612 } 636 }
613 } 637 }
614 638
615 return results; 639 return results;
616} 640}
617#endif 641#endif
618void AddressBook::resetTempSyncStat() 642void AddressBook::resetTempSyncStat()
619{ 643{
620 Iterator it; 644 Iterator it;
621 for ( it = begin(); it != end(); ++it ) { 645 for ( it = begin(); it != end(); ++it ) {
622 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 646 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
623 } 647 }
624 648
625} 649}
626 650
627QStringList AddressBook:: uidList() 651QStringList AddressBook:: uidList()
628{ 652{
629 QStringList results; 653 QStringList results;
630 Iterator it; 654 Iterator it;
631 for ( it = begin(); it != end(); ++it ) { 655 for ( it = begin(); it != end(); ++it ) {
632 results.append( (*it).uid() ); 656 results.append( (*it).uid() );
633 } 657 }
634 return results; 658 return results;
635} 659}
636 660
637 661
638Addressee::List AddressBook::allAddressees() 662Addressee::List AddressBook::allAddressees()
639{ 663{
640 return d->mAddressees; 664 return d->mAddressees;
641 665
642} 666}
643 667
644Addressee::List AddressBook::findByName( const QString &name ) 668Addressee::List AddressBook::findByName( const QString &name )
645{ 669{
646 Addressee::List results; 670 Addressee::List results;
647 671
648 Iterator it; 672 Iterator it;
649 for ( it = begin(); it != end(); ++it ) { 673 for ( it = begin(); it != end(); ++it ) {
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 2f2678b..f40e015 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -248,89 +248,89 @@ class AddressBook : public QObject
248 248
249 @param label User visible label of the field. 249 @param label User visible label of the field.
250 @param category Ored list of field categories. 250 @param category Ored list of field categories.
251 @param key Identifier used as key for reading and writing the field. 251 @param key Identifier used as key for reading and writing the field.
252 @param app String used as application key for reading and writing 252 @param app String used as application key for reading and writing
253 the field. 253 the field.
254 */ 254 */
255 bool addCustomField( const QString &label, int category = Field::All, 255 bool addCustomField( const QString &label, int category = Field::All,
256 const QString &key = QString::null, 256 const QString &key = QString::null,
257 const QString &app = QString::null ); 257 const QString &app = QString::null );
258 258
259 259
260 /** 260 /**
261 Add address book resource. 261 Add address book resource.
262 */ 262 */
263 bool addResource( Resource * ); 263 bool addResource( Resource * );
264 264
265 /** 265 /**
266 Remove address book resource. 266 Remove address book resource.
267 */ 267 */
268 bool removeResource( Resource * ); 268 bool removeResource( Resource * );
269 269
270 /** 270 /**
271 Return pointer list of all resources. 271 Return pointer list of all resources.
272 */ 272 */
273 QPtrList<Resource> resources(); 273 QPtrList<Resource> resources();
274 274
275 /** 275 /**
276 Set the @p ErrorHandler, that is used by @ref error() to 276 Set the @p ErrorHandler, that is used by @ref error() to
277 provide gui-independend error messages. 277 provide gui-independend error messages.
278 */ 278 */
279 void setErrorHandler( ErrorHandler * ); 279 void setErrorHandler( ErrorHandler * );
280 280
281 /** 281 /**
282 Shows gui independend error messages. 282 Shows gui independend error messages.
283 */ 283 */
284 void error( const QString& ); 284 void error( const QString& );
285 285
286 /** 286 /**
287 Query all resources to clean up their lock files 287 Query all resources to clean up their lock files
288 */ 288 */
289 void cleanUp(); 289 void cleanUp();
290 290
291 // sync stuff 291 // sync stuff
292 //Addressee::List getExternLastSyncAddressees(); 292 //Addressee::List getExternLastSyncAddressees();
293 void resetTempSyncStat(); 293 void resetTempSyncStat();
294 QStringList uidList(); 294 QStringList uidList();
295 void removeDeletedAddressees(); 295 void removeDeletedAddressees();
296 296 void mergeAB( AddressBook *aBook, const QString& profile );
297 297 Addressee findByExternUid( const QString& uid , const QString& profile );
298 signals: 298 signals:
299 /** 299 /**
300 Emitted, when the address book has changed on disk. 300 Emitted, when the address book has changed on disk.
301 */ 301 */
302 void addressBookChanged( AddressBook * ); 302 void addressBookChanged( AddressBook * );
303 303
304 /** 304 /**
305 Emitted, when the address book has been locked for writing. 305 Emitted, when the address book has been locked for writing.
306 */ 306 */
307 void addressBookLocked( AddressBook * ); 307 void addressBookLocked( AddressBook * );
308 308
309 /** 309 /**
310 Emitted, when the address book has been unlocked. 310 Emitted, when the address book has been unlocked.
311 */ 311 */
312 void addressBookUnlocked( AddressBook * ); 312 void addressBookUnlocked( AddressBook * );
313 313
314 protected: 314 protected:
315 void deleteRemovedAddressees(); 315 void deleteRemovedAddressees();
316 void setStandardResource( Resource * ); 316 void setStandardResource( Resource * );
317 Resource *standardResource(); 317 Resource *standardResource();
318 KRES::Manager<Resource> *resourceManager(); 318 KRES::Manager<Resource> *resourceManager();
319 319
320 void init(const QString &config, const QString &family); 320 void init(const QString &config, const QString &family);
321 321
322 private: 322 private:
323//US QPtrList<Resource> mDummy; // Remove in KDE 4 323//US QPtrList<Resource> mDummy; // Remove in KDE 4
324 324
325 325
326 struct AddressBookData; 326 struct AddressBookData;
327 AddressBookData *d; 327 AddressBookData *d;
328 bool blockLSEchange; 328 bool blockLSEchange;
329}; 329};
330 330
331QDataStream &operator<<( QDataStream &, const AddressBook & ); 331QDataStream &operator<<( QDataStream &, const AddressBook & );
332QDataStream &operator>>( QDataStream &, AddressBook & ); 332QDataStream &operator>>( QDataStream &, AddressBook & );
333 333
334} 334}
335 335
336#endif 336#endif
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index c34f671..711c261 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -21,96 +21,97 @@
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kidmanager.h> 35#include <kidmanager.h>
36//US 36//US
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 38#include <libkcal/syncdefines.h>
39 39
40//US #include "resource.h" 40//US #include "resource.h"
41#include "addressee.h" 41#include "addressee.h"
42 42
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46 46
47struct Addressee::AddresseeData : public KShared 47struct Addressee::AddresseeData : public KShared
48{ 48{
49 QString uid; 49 QString uid;
50 QString name; 50 QString name;
51 QString formattedName; 51 QString formattedName;
52 QString familyName; 52 QString familyName;
53 QString givenName; 53 QString givenName;
54 QString additionalName; 54 QString additionalName;
55 QString prefix; 55 QString prefix;
56 QString suffix; 56 QString suffix;
57 QString nickName; 57 QString nickName;
58 QDateTime birthday; 58 QDateTime birthday;
59 QString mailer; 59 QString mailer;
60 TimeZone timeZone; 60 TimeZone timeZone;
61 Geo geo; 61 Geo geo;
62 QString title; 62 QString title;
63 QString role; 63 QString role;
64 QString organization; 64 QString organization;
65 QString note; 65 QString note;
66 QString productId; 66 QString productId;
67 QDateTime revision; 67 QDateTime revision;
68 QString sortString; 68 QString sortString;
69 QString externalUID;
69 KURL url; 70 KURL url;
70 Secrecy secrecy; 71 Secrecy secrecy;
71 Picture logo; 72 Picture logo;
72 Picture photo; 73 Picture photo;
73 Sound sound; 74 Sound sound;
74 Agent agent; 75 Agent agent;
75 QString mExternalId; 76 QString mExternalId;
76 PhoneNumber::List phoneNumbers; 77 PhoneNumber::List phoneNumbers;
77 Address::List addresses; 78 Address::List addresses;
78 Key::List keys; 79 Key::List keys;
79 QStringList emails; 80 QStringList emails;
80 QStringList categories; 81 QStringList categories;
81 QStringList custom; 82 QStringList custom;
82 int mTempSyncStat; 83 int mTempSyncStat;
83 Resource *resource; 84 Resource *resource;
84 85
85 bool empty :1; 86 bool empty :1;
86 bool changed :1; 87 bool changed :1;
87}; 88};
88 89
89Addressee::Addressee() 90Addressee::Addressee()
90{ 91{
91 mData = new AddresseeData; 92 mData = new AddresseeData;
92 mData->empty = true; 93 mData->empty = true;
93 mData->changed = false; 94 mData->changed = false;
94 mData->resource = 0; 95 mData->resource = 0;
95 mData->mExternalId = ":"; 96 mData->mExternalId = ":";
96 mData->revision = QDateTime ( QDate( 2004,1,1)); 97 mData->revision = QDateTime ( QDate( 2004,1,1));
97 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 98 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
98} 99}
99 100
100Addressee::~Addressee() 101Addressee::~Addressee()
101{ 102{
102} 103}
103 104
104Addressee::Addressee( const Addressee &a ) 105Addressee::Addressee( const Addressee &a )
105{ 106{
106 mData = a.mData; 107 mData = a.mData;
107} 108}
108 109
109Addressee &Addressee::operator=( const Addressee &a ) 110Addressee &Addressee::operator=( const Addressee &a )
110{ 111{
111 mData = a.mData; 112 mData = a.mData;
112 return (*this); 113 return (*this);
113} 114}
114 115
115Addressee Addressee::copy() 116Addressee Addressee::copy()
116{ 117{
@@ -226,148 +227,186 @@ void Addressee::computeCsum(const QString &dev)
226 // if ( !mData->logo.isEmpty() ) l.append( ); 227 // if ( !mData->logo.isEmpty() ) l.append( );
227 //if ( !mData->photo.isEmpty() ) l.append( ); 228 //if ( !mData->photo.isEmpty() ) l.append( );
228 //if ( !mData->sound.isEmpty() ) l.append( ); 229 //if ( !mData->sound.isEmpty() ) l.append( );
229 //if ( !mData->agent.isEmpty() ) l.append( ); 230 //if ( !mData->agent.isEmpty() ) l.append( );
230 //if ( mData->url.isValid() ) l.append( ); 231 //if ( mData->url.isValid() ) l.append( );
231#if 0 232#if 0
232 if ( !mData->phoneNumbers.isEmpty() ) l.append( ); 233 if ( !mData->phoneNumbers.isEmpty() ) l.append( );
233 if ( !mData->addresses.isEmpty() ) l.append( ); 234 if ( !mData->addresses.isEmpty() ) l.append( );
234 //if ( !mData->keys.isEmpty() ) l.append( ); 235 //if ( !mData->keys.isEmpty() ) l.append( );
235 if ( !mData->emails.isEmpty() ) l.append( ); 236 if ( !mData->emails.isEmpty() ) l.append( );
236 if ( !mData->categories .isEmpty() ) l.append( ); 237 if ( !mData->categories .isEmpty() ) l.append( );
237 if ( !mData->custom.isEmpty() ) l.append( ); 238 if ( !mData->custom.isEmpty() ) l.append( );
238#endif 239#endif
239 KABC::PhoneNumber::List phoneNumbers; 240 KABC::PhoneNumber::List phoneNumbers;
240 KABC::PhoneNumber::List::Iterator phoneIter; 241 KABC::PhoneNumber::List::Iterator phoneIter;
241 242
242 QStringList t; 243 QStringList t;
243 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 244 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
244 ++phoneIter ) 245 ++phoneIter )
245 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 246 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
246 t.sort(); 247 t.sort();
247 uint iii; 248 uint iii;
248 for ( iii = 0; iii < t.count(); ++iii) 249 for ( iii = 0; iii < t.count(); ++iii)
249 l.append( t[iii] ); 250 l.append( t[iii] );
250 t = mData->emails; 251 t = mData->emails;
251 t.sort(); 252 t.sort();
252 for ( iii = 0; iii < t.count(); ++iii) 253 for ( iii = 0; iii < t.count(); ++iii)
253 l.append( t[iii] ); 254 l.append( t[iii] );
254 t = mData->categories; 255 t = mData->categories;
255 t.sort(); 256 t.sort();
256 for ( iii = 0; iii < t.count(); ++iii) 257 for ( iii = 0; iii < t.count(); ++iii)
257 l.append( t[iii] ); 258 l.append( t[iii] );
258 t = mData->custom; 259 t = mData->custom;
259 t.sort(); 260 t.sort();
260 for ( iii = 0; iii < t.count(); ++iii) 261 for ( iii = 0; iii < t.count(); ++iii)
261 l.append( t[iii] ); 262 l.append( t[iii] );
262 KABC::Address::List::Iterator addressIter; 263 KABC::Address::List::Iterator addressIter;
263 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 264 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
264 ++addressIter ) { 265 ++addressIter ) {
265 t = (*addressIter).asList(); 266 t = (*addressIter).asList();
266 t.sort(); 267 t.sort();
267 for ( iii = 0; iii < t.count(); ++iii) 268 for ( iii = 0; iii < t.count(); ++iii)
268 l.append( t[iii] ); 269 l.append( t[iii] );
269 } 270 }
270 uint cs = getCsum4List(l); 271 uint cs = getCsum4List(l);
271 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 272 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
272 setCsum( dev, QString::number (cs )); 273 setCsum( dev, QString::number (cs ));
273} 274}
275
276void Addressee::mergeContact( Addressee ad )
277{
278#if 0
279 if ( !mData->name.isEmpty() ) l.append(mData->name);
280 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
281 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
282 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
283 if ( !mData->additionalName ) l.append( mData->additionalName );
284 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
285 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
286 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
287 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
288 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
289 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
290 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
291 if ( !mData->title .isEmpty() ) l.append( mData->title );
292 if ( !mData->role.isEmpty() ) l.append( mData->role );
293 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
294 if ( !mData->note.isEmpty() ) l.append( mData->note );
295 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
296 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
297 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
298#endif
299}
300
274void Addressee::removeID(const QString &prof) 301void Addressee::removeID(const QString &prof)
275{ 302{
276 detach(); 303 detach();
277 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 304 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
278 305
279} 306}
280void Addressee::setID( const QString & prof , const QString & id ) 307void Addressee::setID( const QString & prof , const QString & id )
281{ 308{
282 detach(); 309 detach();
283 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 310 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
284 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 311 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
285} 312}
286void Addressee::setTempSyncStat( int id ) 313void Addressee::setTempSyncStat( int id )
287{ 314{
288 if ( mData->mTempSyncStat == id ) return; 315 if ( mData->mTempSyncStat == id ) return;
289 detach(); 316 detach();
290 mData->mTempSyncStat = id; 317 mData->mTempSyncStat = id;
291} 318}
292int Addressee::tempSyncStat() const 319int Addressee::tempSyncStat() const
293{ 320{
294 return mData->mTempSyncStat; 321 return mData->mTempSyncStat;
295} 322}
296 323
297QString Addressee::getID( const QString & prof) 324QString Addressee::getID( const QString & prof)
298{ 325{
299 return KIdManager::getId ( mData->mExternalId, prof ); 326 return KIdManager::getId ( mData->mExternalId, prof );
300} 327}
301 328
302void Addressee::setCsum( const QString & prof , const QString & id ) 329void Addressee::setCsum( const QString & prof , const QString & id )
303{ 330{
304 detach(); 331 detach();
305 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 332 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
306 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 333 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
307 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 334 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
308} 335}
309 336
310QString Addressee::getCsum( const QString & prof) 337QString Addressee::getCsum( const QString & prof)
311{ 338{
312 return KIdManager::getCsum ( mData->mExternalId, prof ); 339 return KIdManager::getCsum ( mData->mExternalId, prof );
313} 340}
314 341
315void Addressee::setIDStr( const QString & s ) 342void Addressee::setIDStr( const QString & s )
316{ 343{
317 detach(); 344 detach();
318 mData->mExternalId = s; 345 mData->mExternalId = s;
319} 346}
320 347
321QString Addressee::IDStr() const 348QString Addressee::IDStr() const
322{ 349{
323 return mData->mExternalId; 350 return mData->mExternalId;
324} 351}
325 352
353void Addressee::setExternalUID( const QString &id )
354{
355 if ( id == mData->externalUID ) return;
356 detach();
357 mData->empty = false;
358 mData->externalUID = id;
359}
360
361QString Addressee::externalUID() const
362{
363 return mData->externalUID;
364}
326 365
327void Addressee::setUid( const QString &id ) 366void Addressee::setUid( const QString &id )
328{ 367{
329 if ( id == mData->uid ) return; 368 if ( id == mData->uid ) return;
330 detach(); 369 detach();
331 mData->empty = false; 370 mData->empty = false;
332 mData->uid = id; 371 mData->uid = id;
333} 372}
334 373
335QString Addressee::uid() const 374QString Addressee::uid() const
336{ 375{
337 if ( mData->uid.isEmpty() ) 376 if ( mData->uid.isEmpty() )
338 mData->uid = KApplication::randomString( 10 ); 377 mData->uid = KApplication::randomString( 10 );
339 378
340 return mData->uid; 379 return mData->uid;
341} 380}
342 381
343QString Addressee::uidLabel() 382QString Addressee::uidLabel()
344{ 383{
345 return i18n("Unique Identifier"); 384 return i18n("Unique Identifier");
346} 385}
347 386
348void Addressee::setName( const QString &name ) 387void Addressee::setName( const QString &name )
349{ 388{
350 if ( name == mData->name ) return; 389 if ( name == mData->name ) return;
351 detach(); 390 detach();
352 mData->empty = false; 391 mData->empty = false;
353 mData->name = name; 392 mData->name = name;
354} 393}
355 394
356QString Addressee::name() const 395QString Addressee::name() const
357{ 396{
358 return mData->name; 397 return mData->name;
359} 398}
360 399
361QString Addressee::nameLabel() 400QString Addressee::nameLabel()
362{ 401{
363 return i18n("Name"); 402 return i18n("Name");
364} 403}
365 404
366 405
367void Addressee::setFormattedName( const QString &formattedName ) 406void Addressee::setFormattedName( const QString &formattedName )
368{ 407{
369 if ( formattedName == mData->formattedName ) return; 408 if ( formattedName == mData->formattedName ) return;
370 detach(); 409 detach();
371 mData->empty = false; 410 mData->empty = false;
372 mData->formattedName = formattedName; 411 mData->formattedName = formattedName;
373} 412}
diff --git a/kabc/addressee.h b/kabc/addressee.h
index bfb0840..59fcbd8 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -67,97 +67,99 @@ class Resource;
67 givenName() is the first name and familyName() the last name. In some 67 givenName() is the first name and familyName() the last name. In some
68 countries the family name comes first, that's the reason for the 68 countries the family name comes first, that's the reason for the
69 naming. formattedName() is the full name with the correct formatting. 69 naming. formattedName() is the full name with the correct formatting.
70 It is used as an override, when the correct formatting can't be generated 70 It is used as an override, when the correct formatting can't be generated
71 from the other name fields automatically. 71 from the other name fields automatically.
72 72
73 realName() returns a fully formatted name(). It uses formattedName, if set, 73 realName() returns a fully formatted name(). It uses formattedName, if set,
74 otherwise it constucts the name from the name fields. As fallback, if 74 otherwise it constucts the name from the name fields. As fallback, if
75 nothing else is set it uses name(). 75 nothing else is set it uses name().
76 76
77 name() is the NAME type of RFC2426. It can be used as internal name for the 77 name() is the NAME type of RFC2426. It can be used as internal name for the
78 data enty, but shouldn't be used for displaying the data to the user. 78 data enty, but shouldn't be used for displaying the data to the user.
79 */ 79 */
80class Addressee 80class Addressee
81{ 81{
82 friend QDataStream &operator<<( QDataStream &, const Addressee & ); 82 friend QDataStream &operator<<( QDataStream &, const Addressee & );
83 friend QDataStream &operator>>( QDataStream &, Addressee & ); 83 friend QDataStream &operator>>( QDataStream &, Addressee & );
84 84
85 public: 85 public:
86 typedef QValueList<Addressee> List; 86 typedef QValueList<Addressee> List;
87 87
88 /** 88 /**
89 Construct an empty address book entry. 89 Construct an empty address book entry.
90 */ 90 */
91 Addressee(); 91 Addressee();
92 ~Addressee(); 92 ~Addressee();
93 93
94 Addressee( const Addressee & ); 94 Addressee( const Addressee & );
95 Addressee &operator=( const Addressee & ); 95 Addressee &operator=( const Addressee & );
96 96
97 bool operator==( const Addressee & ) const; 97 bool operator==( const Addressee & ) const;
98 bool operator!=( const Addressee & ) const; 98 bool operator!=( const Addressee & ) const;
99 // sync stuff 99 // sync stuff
100 void setTempSyncStat(int id); 100 void setTempSyncStat(int id);
101 int tempSyncStat() const; 101 int tempSyncStat() const;
102 void setIDStr( const QString & ); 102 void setIDStr( const QString & );
103 QString IDStr() const; 103 QString IDStr() const;
104 void setID( const QString &, const QString & ); 104 void setID( const QString &, const QString & );
105 QString getID( const QString & ); 105 QString getID( const QString & );
106 void setCsum( const QString &, const QString & ); 106 void setCsum( const QString &, const QString & );
107 QString getCsum( const QString & ); 107 QString getCsum( const QString & );
108 void removeID(const QString &); 108 void removeID(const QString &);
109 void computeCsum(const QString &dev); 109 void computeCsum(const QString &dev);
110 ulong getCsum4List( const QStringList & attList); 110 ulong getCsum4List( const QStringList & attList);
111 /** 111 /**
112 Return, if the address book entry is empty. 112 Return, if the address book entry is empty.
113 */ 113 */
114 bool isEmpty() const; 114 bool isEmpty() const;
115 115 void setExternalUID( const QString &id );
116 QString externalUID() const;
117 void mergeContact( Addressee ad );
116 /** 118 /**
117 Set unique identifier. 119 Set unique identifier.
118 */ 120 */
119 void setUid( const QString &uid ); 121 void setUid( const QString &uid );
120 /** 122 /**
121 Return unique identifier. 123 Return unique identifier.
122 */ 124 */
123 QString uid() const; 125 QString uid() const;
124 /** 126 /**
125 Return translated label for uid field. 127 Return translated label for uid field.
126 */ 128 */
127 static QString uidLabel(); 129 static QString uidLabel();
128 130
129 /** 131 /**
130 Set name. 132 Set name.
131 */ 133 */
132 void setName( const QString &name ); 134 void setName( const QString &name );
133 /** 135 /**
134 Return name. 136 Return name.
135 */ 137 */
136 QString name() const; 138 QString name() const;
137 /** 139 /**
138 Return translated label for name field. 140 Return translated label for name field.
139 */ 141 */
140 static QString nameLabel(); 142 static QString nameLabel();
141 143
142 /** 144 /**
143 Set formatted name. 145 Set formatted name.
144 */ 146 */
145 void setFormattedName( const QString &formattedName ); 147 void setFormattedName( const QString &formattedName );
146 /** 148 /**
147 Return formatted name. 149 Return formatted name.
148 */ 150 */
149 QString formattedName() const; 151 QString formattedName() const;
150 /** 152 /**
151 Return translated label for formattedName field. 153 Return translated label for formattedName field.
152 */ 154 */
153 static QString formattedNameLabel(); 155 static QString formattedNameLabel();
154 156
155 /** 157 /**
156 Set family name. 158 Set family name.
157 */ 159 */
158 void setFamilyName( const QString &familyName ); 160 void setFamilyName( const QString &familyName );
159 /** 161 /**
160 Return family name. 162 Return family name.
161 */ 163 */
162 QString familyName() const; 164 QString familyName() const;
163 /** 165 /**
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp
index ac513b6..7d00a3f 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.cpp
+++ b/kabc/plugins/qtopia/qtopiaconverter.cpp
@@ -30,97 +30,104 @@ $Id$
30 30
31 31
32#include "qtopiaconverter.h" 32#include "qtopiaconverter.h"
33 33
34#include <qpe/categories.h> 34#include <qpe/categories.h>
35//US #include <qpe/categoryselect.h> 35//US #include <qpe/categoryselect.h>
36 36
37 37
38using namespace KABC; 38using namespace KABC;
39 39
40QtopiaConverter::QtopiaConverter() : catDB(0) 40QtopiaConverter::QtopiaConverter() : catDB(0)
41{ 41{
42} 42}
43 43
44QtopiaConverter::~QtopiaConverter() 44QtopiaConverter::~QtopiaConverter()
45{ 45{
46 deinit(); 46 deinit();
47} 47}
48 48
49bool QtopiaConverter::init() 49bool QtopiaConverter::init()
50{ 50{
51 catDB = new Categories(); 51 catDB = new Categories();
52 52
53 if (!catDB) 53 if (!catDB)
54 return false; 54 return false;
55 55
56 catDB->load( categoryFileName() ); 56 catDB->load( categoryFileName() );
57 return true; 57 return true;
58} 58}
59 59
60void QtopiaConverter::deinit() 60void QtopiaConverter::deinit()
61{ 61{
62 if (catDB) 62 if (catDB)
63 { 63 {
64 delete catDB; 64 delete catDB;
65 catDB = 0; 65 catDB = 0;
66 } 66 }
67} 67}
68 68
69bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr ) 69bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr )
70{ 70{
71 // name 71 // name
72 addr.setFormattedName(contact.fileAs()); 72 addr.setFormattedName(contact.fileAs());
73 addr.setFamilyName( contact.lastName() ); 73 addr.setFamilyName( contact.lastName() );
74 addr.setGivenName( contact.firstName() ); 74 addr.setGivenName( contact.firstName() );
75 addr.setAdditionalName( contact.middleName() ); 75 addr.setAdditionalName( contact.middleName() );
76 addr.setPrefix( contact.nameTitle() ); 76 addr.setPrefix( contact.nameTitle() );
77 addr.setSuffix( contact.suffix() ); 77 addr.setSuffix( contact.suffix() );
78 78 QString exuid = contact.uid().toString();
79 int ente = exuid.find( "-0000");
80 if ( exuid.left(1) == "{" )
81 exuid = exuid.mid(1);
82 if ( ente > -1 )
83 exuid = exuid.left( ente-1 );
84 addr.setExternalUID( exuid );
85 //qDebug("QtopiaConverter:set uid %s ",addr.externalUID().latin1() );
79 86
80 // email 87 // email
81 QStringList emails = contact.emailList(); 88 QStringList emails = contact.emailList();
82 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 89 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
83 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); 90 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) );
84 } 91 }
85 92
86 if (!contact.defaultEmail().isEmpty()) 93 if (!contact.defaultEmail().isEmpty())
87 addr.insertEmail(contact.defaultEmail(), true); 94 addr.insertEmail(contact.defaultEmail(), true);
88 95
89 // home 96 // home
90 if ((!contact.homeStreet().isEmpty()) || 97 if ((!contact.homeStreet().isEmpty()) ||
91 (!contact.homeCity().isEmpty()) || 98 (!contact.homeCity().isEmpty()) ||
92 (!contact.homeState().isEmpty()) || 99 (!contact.homeState().isEmpty()) ||
93 (!contact.homeZip().isEmpty()) || 100 (!contact.homeZip().isEmpty()) ||
94 (!contact.homeCountry().isEmpty())) 101 (!contact.homeCountry().isEmpty()))
95 { 102 {
96 Address homeaddress; 103 Address homeaddress;
97 homeaddress.setType(Address::Home); 104 homeaddress.setType(Address::Home);
98//US homeaddress.setPostOfficeBox( "" ); 105//US homeaddress.setPostOfficeBox( "" );
99//US homeaddress.setExtended( "" ); 106//US homeaddress.setExtended( "" );
100 homeaddress.setStreet( contact.homeStreet() ); 107 homeaddress.setStreet( contact.homeStreet() );
101 homeaddress.setLocality( contact.homeCity() ); 108 homeaddress.setLocality( contact.homeCity() );
102 homeaddress.setRegion( contact.homeState() ); 109 homeaddress.setRegion( contact.homeState() );
103 homeaddress.setPostalCode( contact.homeZip() ); 110 homeaddress.setPostalCode( contact.homeZip() );
104 homeaddress.setCountry( contact.homeCountry() ); 111 homeaddress.setCountry( contact.homeCountry() );
105 112
106 addr.insertAddress( homeaddress ); 113 addr.insertAddress( homeaddress );
107 } 114 }
108 115
109 if (!contact.homePhone().isEmpty()) 116 if (!contact.homePhone().isEmpty())
110 { 117 {
111 PhoneNumber homephone; 118 PhoneNumber homephone;
112 homephone.setType( PhoneNumber::Home ); 119 homephone.setType( PhoneNumber::Home );
113 homephone.setNumber( contact.homePhone() ); 120 homephone.setNumber( contact.homePhone() );
114 addr.insertPhoneNumber( homephone ); 121 addr.insertPhoneNumber( homephone );
115 } 122 }
116 123
117 if (!contact.homeFax().isEmpty()) 124 if (!contact.homeFax().isEmpty())
118 { 125 {
119 PhoneNumber homefax; 126 PhoneNumber homefax;
120 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); 127 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax );
121 homefax.setNumber( contact.homeFax() ); 128 homefax.setNumber( contact.homeFax() );
122 addr.insertPhoneNumber( homefax ); 129 addr.insertPhoneNumber( homefax );
123 } 130 }
124 131
125 if (!contact.homeMobile().isEmpty()) 132 if (!contact.homeMobile().isEmpty())
126 { 133 {
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index fa0c51f..d6482fb 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2905,96 +2905,98 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2905 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2905 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2906 } 2906 }
2907 qDebug( mes ); 2907 qDebug( mes );
2908 return syncOK; 2908 return syncOK;
2909} 2909}
2910 2910
2911bool KABCore::syncAB(QString filename, int mode) 2911bool KABCore::syncAB(QString filename, int mode)
2912{ 2912{
2913 2913
2914 //pending prepare addresseeview for output 2914 //pending prepare addresseeview for output
2915 //pending detect, if remote file has REV field. if not switch to external sync 2915 //pending detect, if remote file has REV field. if not switch to external sync
2916 mGlobalSyncMode = SYNC_MODE_NORMAL; 2916 mGlobalSyncMode = SYNC_MODE_NORMAL;
2917 AddressBook abLocal(filename,"syncContact"); 2917 AddressBook abLocal(filename,"syncContact");
2918 bool syncOK = false; 2918 bool syncOK = false;
2919 if ( abLocal.load() ) { 2919 if ( abLocal.load() ) {
2920 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2920 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2921 bool external = false; 2921 bool external = false;
2922 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2922 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2923 if ( ! lse.isEmpty() ) { 2923 if ( ! lse.isEmpty() ) {
2924 if ( lse.familyName().left(4) == "!E: " ) 2924 if ( lse.familyName().left(4) == "!E: " )
2925 external = true; 2925 external = true;
2926 } else { 2926 } else {
2927 bool found = false; 2927 bool found = false;
2928 QDateTime dt( QDate( 2004,1,1)); 2928 QDateTime dt( QDate( 2004,1,1));
2929 AddressBook::Iterator it; 2929 AddressBook::Iterator it;
2930 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2930 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2931 if ( (*it).revision() != dt ) { 2931 if ( (*it).revision() != dt ) {
2932 found = true; 2932 found = true;
2933 break; 2933 break;
2934 } 2934 }
2935 } 2935 }
2936 external = ! found; 2936 external = ! found;
2937 } 2937 }
2938 2938
2939 if ( external ) { 2939 if ( external ) {
2940 qDebug("Setting vcf mode to external "); 2940 qDebug("Setting vcf mode to external ");
2941 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2941 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2942 AddressBook::Iterator it; 2942 AddressBook::Iterator it;
2943 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2943 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2944 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2944 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2945 (*it).computeCsum( mCurrentSyncDevice ); 2945 (*it).computeCsum( mCurrentSyncDevice );
2946 } 2946 }
2947 } 2947 }
2948 //AddressBook::Iterator it; 2948 //AddressBook::Iterator it;
2949 //QStringList vcards; 2949 //QStringList vcards;
2950 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2950 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2951 // qDebug("Name %s ", (*it).familyName().latin1()); 2951 // qDebug("Name %s ", (*it).familyName().latin1());
2952 //} 2952 //}
2953 if ( filename.right(4) == ".xml")
2954 abLocal.mergeAB( mAddressBook ,mCurrentSyncDevice );
2953 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2955 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2954 if ( syncOK ) { 2956 if ( syncOK ) {
2955 if ( KABPrefs::instance()->mWriteBackFile ) 2957 if ( KABPrefs::instance()->mWriteBackFile )
2956 { 2958 {
2957 if ( external ) 2959 if ( external )
2958 abLocal.removeDeletedAddressees(); 2960 abLocal.removeDeletedAddressees();
2959 qDebug("Saving remote AB "); 2961 qDebug("Saving remote AB ");
2960 abLocal.saveAB(); 2962 abLocal.saveAB();
2961 } 2963 }
2962 } 2964 }
2963 setModified(); 2965 setModified();
2964 2966
2965 } 2967 }
2966 if ( syncOK ) 2968 if ( syncOK )
2967 mViewManager->refreshView(); 2969 mViewManager->refreshView();
2968 return syncOK; 2970 return syncOK;
2969#if 0 2971#if 0
2970 2972
2971 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 2973 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2972 getEventViewerDialog()->setSyncMode( true ); 2974 getEventViewerDialog()->setSyncMode( true );
2973 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 2975 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2974 getEventViewerDialog()->setSyncMode( false ); 2976 getEventViewerDialog()->setSyncMode( false );
2975 if ( syncOK ) { 2977 if ( syncOK ) {
2976 if ( KOPrefs::instance()->mWriteBackFile ) 2978 if ( KOPrefs::instance()->mWriteBackFile )
2977 { 2979 {
2978 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2980 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2979 storage->save(); 2981 storage->save();
2980 } 2982 }
2981 } 2983 }
2982 setModified(); 2984 setModified();
2983 } 2985 }
2984 2986
2985#endif 2987#endif
2986} 2988}
2987 2989
2988void KABCore::confSync() 2990void KABCore::confSync()
2989{ 2991{
2990 static KSyncPrefsDialog* sp = 0; 2992 static KSyncPrefsDialog* sp = 0;
2991 if ( ! sp ) { 2993 if ( ! sp ) {
2992 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 2994 sp = new KSyncPrefsDialog( this, "syncprefs", true );
2993 } 2995 }
2994 sp->usrReadConfig(); 2996 sp->usrReadConfig();
2995#ifndef DESKTOP_VERSION 2997#ifndef DESKTOP_VERSION
2996 sp->showMaximized(); 2998 sp->showMaximized();
2997#else 2999#else
2998 sp->show(); 3000 sp->show();
2999#endif 3001#endif
3000 sp->exec(); 3002 sp->exec();