summaryrefslogtreecommitdiffabout
Unidiff
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
@@ -30,6 +30,7 @@ $Id$
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
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 46a9cf4..64832f1 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -248,11 +248,14 @@ void AddressBook::init(const QString &config, const QString &family )
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 }
@@ -599,6 +602,27 @@ Addressee AddressBook::findByUid( const QString &uid )
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{
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 2f2678b..f40e015 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -293,8 +293,8 @@ class AddressBook : public QObject
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.
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index c34f671..711c261 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -66,6 +66,7 @@ struct Addressee::AddresseeData : public KShared
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;
@@ -271,6 +272,32 @@ void Addressee::computeCsum(const QString &dev)
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();
@@ -323,6 +350,18 @@ QString Addressee::IDStr() const
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{
diff --git a/kabc/addressee.h b/kabc/addressee.h
index bfb0840..59fcbd8 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -112,7 +112,9 @@ class Addressee
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 */
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
@@ -75,7 +75,14 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a
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();
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index fa0c51f..d6482fb 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2950,6 +2950,8 @@ bool KABCore::syncAB(QString filename, int mode)
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 )