summaryrefslogtreecommitdiffabout
path: root/kabc
authorzautrix <zautrix>2006-02-24 18:49:56 (UTC)
committer zautrix <zautrix>2006-02-24 18:49:56 (UTC)
commitd7738fdfc685192eb2f8317db6ffad3c246001c8 (patch) (side-by-side diff)
treed9aae6ca97851fd1b53c4d9e74740a5ee2b69ea9 /kabc
parent987757f168bbae56100f2aff763b865e81ceec18 (diff)
downloadkdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.zip
kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.tar.gz
kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.tar.bz2
kapi sync
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp22
-rw-r--r--kabc/addressbook.h1
-rw-r--r--kabc/addressee.cpp75
-rw-r--r--kabc/addressee.h4
-rw-r--r--kabc/phonenumber.cpp24
5 files changed, 120 insertions, 6 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index f9e4387..fe59fcb 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -946,6 +946,23 @@ void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool i
}
mergeAB( aBook ,csd, isSubset );
}
+void AddressBook::preOLSync( AddressBook* aBook, const QString& csd )
+{
+ //qDebug("AddressBook::preExternSync ");
+ AddressBook::Iterator it;
+ for ( it = begin(); it != end(); ++it ) {
+ (*it).setID( csd, (*it).externalUID() );
+ (*it).computeCsum( csd );
+ }
+
+ Addressee ad;
+ for ( it = begin(); it != end(); ++it ) {
+ ad = aBook->findByExternUid( (*it).externalUID(), csd );
+ if ( !ad.isEmpty() ) {
+ (*it).mergeOLContact( ad );
+ }
+ }
+}
void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID)
{
//qDebug("AddressBook::postExternSync ");
@@ -964,8 +981,9 @@ void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool
} else {
(*it).setIDStr(":");
if ( setID ) {
- if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
- ad.setID( csd, (*it).externalUID() );
+ if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
+ ad.setID( csd, (*it).externalUID() );{
+ }
} else
ad.setID( csd, (*it).uid() );
(*it).computeCsum( csd );
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index e6daa5e..a8a9fc1 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -308,6 +308,7 @@ class AddressBook : public QObject
bool containsExternalUid( const QString& uid );
void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset );
+ void preOLSync( AddressBook* aBook, const QString& csd);
void postExternSync( AddressBook* aBook, const QString& csd , bool setID );
signals:
/**
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 6cfac80..e8e440c 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -32,6 +32,7 @@ $Id$
#include <kdebug.h>
#include <kapplication.h>
#include <klocale.h>
+#include <kmessagebox.h>
#include <kidmanager.h>
//US
#include <kstandarddirs.h>
@@ -211,7 +212,7 @@ void Addressee::computeCsum(const QString &dev)
{
QStringList l;
//if ( !mData->name.isEmpty() ) l.append(mData->name);
- //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
+ 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.isEmpty() ) l.append( mData->additionalName );
@@ -332,6 +333,53 @@ bool Addressee::matchPhoneNumber( QRegExp* re ) const
return false;
}
+void Addressee::mergeOLContact( const Addressee& ad )
+{
+ if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
+ if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
+ if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
+ if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
+ if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
+ if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
+ if ( !mData->sound.isIntern() ) {
+ if ( mData->sound.url().isEmpty() ) {
+ mData->sound = ad.mData->sound;
+ }
+ }
+ if ( !mData->agent.isIntern() ) {
+ if ( mData->agent.url().isEmpty() ) {
+ mData->agent = ad.mData->agent;
+ }
+ }
+ {
+ Key::List::Iterator itA;
+ for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
+ bool found = false;
+ Key::List::Iterator it;
+ for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
+ if ( (*it) == (*itA)) {
+ found = true;
+ break;
+
+ }
+ }
+ if ( ! found ) {
+ mData->keys.append( *itA );
+ }
+ }
+ }
+
+ KABC::Address addthis = otherAddress();
+ KABC::Address addother = ad.otherAddress();
+ if ( !addthis.isEmpty() && !addother.isEmpty() )
+ addthis.setType( addother.type() );
+ //qDebug("merge contact %s ", ad.uid().latin1());
+ setUid( ad.uid() );
+ setRevision( ad.revision() );
+
+
+}
+
void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
{
// merge all standard non-outlook fields.
@@ -1653,7 +1701,6 @@ void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
{
detach();
mData->empty = false;
-
PhoneNumber::List::Iterator it;
for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
if ( (*it).id() == phoneNumber.id() ) {
@@ -1720,6 +1767,17 @@ PhoneNumber::List Addressee::phoneNumbers( int type ) const
}
return list;
}
+QString Addressee::phoneNumberString( int type ) const
+{
+
+ PhoneNumber::List::ConstIterator it;
+ for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
+ if ((*it).type() == type ) {
+ return ( *it ).number();
+ }
+ }
+ return "";
+}
PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
{
@@ -1925,7 +1983,18 @@ void Addressee::removeAddress( const Address &address )
}
}
}
-
+Address Addressee::otherAddress() const
+{
+ Address::List::ConstIterator it;
+ for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
+ if ( matchBinaryPatternA( (*it).type(), KABC::Address::Work ) )
+ continue;
+ if ( matchBinaryPatternA( (*it).type(), KABC::Address::Home ) )
+ continue;
+ return (*it);
+ }
+ return Address();
+}
Address Addressee::address( int type ) const
{
Address address( type );
diff --git a/kabc/addressee.h b/kabc/addressee.h
index aac78dc..0ea1803 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -118,6 +118,7 @@ class Addressee
void setOriginalExternalUID( const QString &id );
QString originalExternalUID() const;
void mergeContact( const Addressee& ad, bool isSubSet );
+ void mergeOLContact( const Addressee& ad );
void simplifyEmails();
void simplifyAddresses();
void simplifyPhoneNumbers();
@@ -647,6 +648,7 @@ class Addressee
Return phone number, which matches the given type.
*/
PhoneNumber phoneNumber( int type ) const;
+ QString phoneNumberString( int type ) const;
bool matchPhoneNumber( QRegExp* searchExp ) const;
bool matchAddress( QRegExp* searchExp ) const;
@@ -731,7 +733,7 @@ class Addressee
Return list of all addresses.
*/
Address::List addresses() const;
-
+ Address otherAddress() const;
/**
Return list of addresses with a special type.
*/
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp
index 12b9b09..1752745 100644
--- a/kabc/phonenumber.cpp
+++ b/kabc/phonenumber.cpp
@@ -232,6 +232,30 @@ PhoneNumber::TypeList PhoneNumber::supportedTypeList()
list << (Home| Pref) << (Work| Pref) << Cell <<(Pcs|Pref)<< (Pcs|Voice)<< Home << Work << Car << Pcs <<(Work| Msg | Voice) << (Work| Msg) << (Home | Fax) << (Work| Fax) << Fax<< Pager << Isdn << Msg << Pref << Voice;
return list;
}
+
+#if 0
+Home| Pref i18n("Home") Home
+Work| Pref i18n("Work") Business
+Cell i18n("Mobile") Mobile
+Pcs|Pref i18n("SiP") Radio
+Pcs|Voice i18n("VoIP") TTY/TTD
+Home i18n("Home2") Home 2
+Work i18n("Work2") Business 2
+Car i18n("Mobile2") Car
+Pcs i18n("SiP2") Telex
+Work| Msg | Voice i18n("Assistent") Assistent
+Work| Msg i18n("Company") Company
+Home | Fax i18n("Fax (Home)") Home Fax
+Work| Fax i18n("Fax (Work)") Business Fax
+Fax i18n("Fax (Other)") Other Fax
+Pager i18n("Pager") Pager
+Isdn i18n("ISDN") Isdn
+Msg i18n("Callback") Callback
+Pref i18n("Primary") Primary
+Voice; i18n("Other") Other
+
+#endif
+
QStringList PhoneNumber::supportedTypeListNames()
{
static QStringList list;