summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
Side-by-side diff
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp75
1 files changed, 72 insertions, 3 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 6cfac80..e8e440c 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -29,12 +29,13 @@ $Id$
#include <kconfig.h>
#include <ksharedptr.h>
#include <kdebug.h>
#include <kapplication.h>
#include <klocale.h>
+#include <kmessagebox.h>
#include <kidmanager.h>
//US
#include <kstandarddirs.h>
#include <libkcal/syncdefines.h>
//US #include "resource.h"
@@ -208,13 +209,13 @@ ulong Addressee::getCsum4List( const QStringList & attList)
}
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 );
if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
@@ -329,12 +330,59 @@ bool Addressee::matchPhoneNumber( QRegExp* re ) const
return true;
}
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.
//if isSubSet (e.g. mobile phone sync) merge all fields
detach();
@@ -1650,13 +1698,12 @@ void Addressee::setEmails( const QStringList& emails ) {
mData->emails = emails;
}
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() ) {
*it = phoneNumber;
return;
}
@@ -1717,12 +1764,23 @@ PhoneNumber::List Addressee::phoneNumbers( int type ) const
if ( matchBinaryPattern( (*it).type(), type ) ) {
list.append( *it );
}
}
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
{
PhoneNumber::List::ConstIterator it;
for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
if ( (*it).id() == id ) {
@@ -1922,13 +1980,24 @@ void Addressee::removeAddress( const Address &address )
if ( (*it).id() == address.id() ) {
mData->addresses.remove( it );
return;
}
}
}
-
+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 );
Address::List::ConstIterator it;
for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
if ( matchBinaryPatternA( (*it).type(), type ) ) {