summaryrefslogtreecommitdiffabout
path: root/kabc
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 /kabc
parent953277a85e6ec5630ab0d64b4d68815e4e4f9906 (diff)
downloadkdepimpi-eea0ff04703dffdbe8b67a0dc9f592597d7450c1.zip
kdepimpi-eea0ff04703dffdbe8b67a0dc9f592597d7450c1.tar.gz
kdepimpi-eea0ff04703dffdbe8b67a0dc9f592597d7450c1.tar.bz2
more AB sync
Diffstat (limited to 'kabc') (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
6 files changed, 79 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$
#include <qmap.h>
#include <qstring.h>
+#include <qstringlist.h>
#include <qvaluelist.h>
// 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 )
con->writeEntry( "ResourceKeys", QString("sync") );
con->writeEntry( "Standard", QString("sync") );
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();
d->mConfig = con;
}
@@ -599,6 +602,27 @@ Addressee AddressBook::findByUid( const QString &uid )
}
return Addressee();
}
+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
Addressee::List AddressBook::getExternLastSyncAddressees()
{
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
void resetTempSyncStat();
QStringList uidList();
void removeDeletedAddressees();
-
-
+ void mergeAB( AddressBook *aBook, const QString& profile );
+ Addressee findByExternUid( const QString& uid , const QString& profile );
signals:
/**
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
QString productId;
QDateTime revision;
QString sortString;
+ QString externalUID;
KURL url;
Secrecy secrecy;
Picture logo;
@@ -271,6 +272,32 @@ void Addressee::computeCsum(const QString &dev)
// qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
setCsum( dev, QString::number (cs ));
}
+
+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)
{
detach();
@@ -323,6 +350,18 @@ QString Addressee::IDStr() const
return mData->mExternalId;
}
+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;
+}
void Addressee::setUid( const QString &id )
{
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
Return, if the address book entry is empty.
*/
bool isEmpty() const;
-
+ void setExternalUID( const QString &id );
+ QString externalUID() const;
+ void mergeContact( Addressee ad );
/**
Set unique identifier.
*/
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
addr.setAdditionalName( contact.middleName() );
addr.setPrefix( contact.nameTitle() );
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() );
// email
QStringList emails = contact.emailList();