summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-19 11:32:40 (UTC)
committer zautrix <zautrix>2004-09-19 11:32:40 (UTC)
commiteea0ff04703dffdbe8b67a0dc9f592597d7450c1 (patch) (side-by-side diff)
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
@@ -32,2 +32,3 @@ $Id$
#include <qstring.h>
+#include <qstringlist.h>
#include <qvaluelist.h>
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 46a9cf4..64832f1 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -250,7 +250,10 @@ void AddressBook::init(const QString &config, const QString &family )
con->setGroup( "Resource_sync" );
- con->writeEntry( "FileFormat", QString("vcard") );
con->writeEntry( "FileName", config );
+ con->writeEntry( "FileFormat", QString("vcard") );
con->writeEntry( "ResourceIdentifier", QString("sync") );
con->writeEntry( "ResourceName", QString("sync_res") );
- con->writeEntry( "ResourceType", QString("file") );
+ if ( config.right(4) == ".xml" )
+ con->writeEntry( "ResourceType", QString("qtopia") );
+ else
+ con->writeEntry( "ResourceType", QString("file") );
//con->sync();
@@ -601,2 +604,23 @@ Addressee AddressBook::findByUid( const QString &uid )
}
+Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
+{
+ Iterator it;
+ for ( it = begin(); it != end(); ++it ) {
+ if ( uid == (*it).getID( profile ) )
+ return (*it);
+ }
+ return Addressee();
+}
+void AddressBook::mergeAB( AddressBook *aBook, const QString& profile )
+{
+ Iterator it;
+ Addressee ad;
+ for ( it = begin(); it != end(); ++it ) {
+ ad = aBook->findByExternUid( (*it).externalUID(), profile );
+ if ( !ad.isEmpty() ) {
+ (*it).mergeContact( ad );
+ }
+ }
+}
+
#if 0
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 2f2678b..f40e015 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -295,4 +295,4 @@ class AddressBook : public QObject
void removeDeletedAddressees();
-
-
+ void mergeAB( AddressBook *aBook, const QString& profile );
+ Addressee findByExternUid( const QString& uid , const QString& profile );
signals:
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index c34f671..711c261 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -68,2 +68,3 @@ struct Addressee::AddresseeData : public KShared
QString sortString;
+ QString externalUID;
KURL url;
@@ -273,2 +274,28 @@ void Addressee::computeCsum(const QString &dev)
}
+
+void Addressee::mergeContact( Addressee ad )
+{
+#if 0
+ if ( !mData->name.isEmpty() ) l.append(mData->name);
+ if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
+ if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
+ if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
+ if ( !mData->additionalName ) l.append( mData->additionalName );
+ if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
+ if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
+ if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
+ if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
+ if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
+ if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
+ if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
+ if ( !mData->title .isEmpty() ) l.append( mData->title );
+ if ( !mData->role.isEmpty() ) l.append( mData->role );
+ if ( !mData->organization.isEmpty() ) l.append( mData->organization );
+ if ( !mData->note.isEmpty() ) l.append( mData->note );
+ if ( !mData->productId.isEmpty() ) l.append(mData->productId );
+ if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
+ if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
+#endif
+}
+
void Addressee::removeID(const QString &prof)
@@ -325,2 +352,14 @@ QString Addressee::IDStr() const
+void Addressee::setExternalUID( const QString &id )
+{
+ if ( id == mData->externalUID ) return;
+ detach();
+ mData->empty = false;
+ mData->externalUID = id;
+}
+
+QString Addressee::externalUID() const
+{
+ return mData->externalUID;
+}
diff --git a/kabc/addressee.h b/kabc/addressee.h
index bfb0840..59fcbd8 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -114,3 +114,5 @@ class Addressee
bool isEmpty() const;
-
+ void setExternalUID( const QString &id );
+ QString externalUID() const;
+ void mergeContact( Addressee ad );
/**
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
@@ -77,3 +77,10 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a
addr.setSuffix( contact.suffix() );
-
+ QString exuid = contact.uid().toString();
+ int ente = exuid.find( "-0000");
+ if ( exuid.left(1) == "{" )
+ exuid = exuid.mid(1);
+ if ( ente > -1 )
+ exuid = exuid.left( ente-1 );
+ addr.setExternalUID( exuid );
+ //qDebug("QtopiaConverter:set uid %s ",addr.externalUID().latin1() );
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index fa0c51f..d6482fb 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2952,2 +2952,4 @@ bool KABCore::syncAB(QString filename, int mode)
//}
+ if ( filename.right(4) == ".xml")
+ abLocal.mergeAB( mAddressBook ,mCurrentSyncDevice );
syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );