author | zautrix <zautrix> | 2004-09-18 22:33:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-18 22:33:39 (UTC) |
commit | f370d0f89bcaeeb68bd60152a9812a9cd55e5d8a (patch) (side-by-side diff) | |
tree | c1a9de8b305200a7cec885764a0afb4beb92dabb /kabc/addressee.cpp | |
parent | 28f894fd2a0dfbd5f09f9e530f359981efe0198c (diff) | |
download | kdepimpi-f370d0f89bcaeeb68bd60152a9812a9cd55e5d8a.zip kdepimpi-f370d0f89bcaeeb68bd60152a9812a9cd55e5d8a.tar.gz kdepimpi-f370d0f89bcaeeb68bd60152a9812a9cd55e5d8a.tar.bz2 |
more AB sync
-rw-r--r-- | kabc/addressee.cpp | 97 |
1 files changed, 96 insertions, 1 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 7f04d8f..0f5d605 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -129,96 +129,192 @@ void Addressee::detach() bool Addressee::operator==( const Addressee &a ) const { if ( uid() != a.uid() ) return false; if ( mData->name != a.mData->name ) return false; if ( mData->formattedName != a.mData->formattedName ) return false; if ( mData->familyName != a.mData->familyName ) return false; if ( mData->givenName != a.mData->givenName ) return false; if ( mData->additionalName != a.mData->additionalName ) return false; if ( mData->prefix != a.mData->prefix ) return false; if ( mData->suffix != a.mData->suffix ) return false; if ( mData->nickName != a.mData->nickName ) return false; if ( mData->birthday != a.mData->birthday ) return false; if ( mData->mailer != a.mData->mailer ) return false; if ( mData->timeZone != a.mData->timeZone ) return false; if ( mData->geo != a.mData->geo ) return false; if ( mData->title != a.mData->title ) return false; if ( mData->role != a.mData->role ) return false; if ( mData->organization != a.mData->organization ) return false; if ( mData->note != a.mData->note ) return false; if ( mData->productId != a.mData->productId ) return false; if ( mData->revision != a.mData->revision ) return false; if ( mData->sortString != a.mData->sortString ) return false; if ( mData->secrecy != a.mData->secrecy ) return false; if ( mData->logo != a.mData->logo ) return false; if ( mData->photo != a.mData->photo ) return false; if ( mData->sound != a.mData->sound ) return false; if ( mData->agent != a.mData->agent ) return false; if ( ( mData->url.isValid() || a.mData->url.isValid() ) && ( mData->url != a.mData->url ) ) return false; if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; if ( mData->addresses != a.mData->addresses ) return false; if ( mData->keys != a.mData->keys ) return false; if ( mData->emails != a.mData->emails ) return false; if ( mData->categories != a.mData->categories ) return false; if ( mData->custom != a.mData->custom ) return false; return true; } bool Addressee::operator!=( const Addressee &a ) const { return !( a == *this ); } bool Addressee::isEmpty() const { return mData->empty; } +ulong Addressee::getCsum4List( const QStringList & attList) +{ + int max = attList.count(); + ulong cSum = 0; + int j,k,i; + int add; + for ( i = 0; i < max ; ++i ) { + QString s = attList[i]; + if ( ! s.isEmpty() ){ + j = s.length(); + for ( k = 0; k < j; ++k ) { + int mul = k +1; + add = s[k].unicode (); + if ( k < 16 ) + mul = mul * mul; + int ii = i+1; + add = add * mul *ii*ii*ii; + cSum += add; + } + } + + } + //QString dump = attList.join(","); + //qDebug("csum: %d %s", cSum,dump.latin1()); + + return cSum; + +} +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->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()); + // if ( !mData->logo.isEmpty() ) l.append( ); + //if ( !mData->photo.isEmpty() ) l.append( ); + //if ( !mData->sound.isEmpty() ) l.append( ); + //if ( !mData->agent.isEmpty() ) l.append( ); + //if ( mData->url.isValid() ) l.append( ); +#if 0 + if ( !mData->phoneNumbers.isEmpty() ) l.append( ); + if ( !mData->addresses.isEmpty() ) l.append( ); + //if ( !mData->keys.isEmpty() ) l.append( ); + if ( !mData->emails.isEmpty() ) l.append( ); + if ( !mData->categories .isEmpty() ) l.append( ); + if ( !mData->custom.isEmpty() ) l.append( ); +#endif + KABC::PhoneNumber::List phoneNumbers; + KABC::PhoneNumber::List::Iterator phoneIter; + + QStringList t; + for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); + ++phoneIter ) + t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); + t.sort(); + uint iii; + for ( iii = 0; iii < t.count(); ++iii) + l.append( t[iii] ); + t = mData->emails; + t.sort(); + for ( iii = 0; iii < t.count(); ++iii) + l.append( t[iii] ); + t = mData->categories; + t.sort(); + for ( iii = 0; iii < t.count(); ++iii) + l.append( t[iii] ); + t = mData->custom; + t.sort(); + for ( iii = 0; iii < t.count(); ++iii) + l.append( t[iii] ); + KABC::Address::List::Iterator addressIter; + for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); + ++addressIter ) { + t = (*addressIter).asList(); + t.sort(); + for ( iii = 0; iii < t.count(); ++iii) + l.append( t[iii] ); + } + setCsum( dev, QString::number (getCsum4List(l)) ); +} void Addressee::removeID(const QString &prof) { detach(); mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); } void Addressee::setID( const QString & prof , const QString & id ) { detach(); mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); } void Addressee::setTempSyncStat( int id ) { mTempSyncStat = id; } int Addressee::tempSyncStat() const { return mTempSyncStat; } QString Addressee::getID( const QString & prof) { return KIdManager::getId ( mData->mExternalId, prof ); } void Addressee::setCsum( const QString & prof , const QString & id ) { detach(); mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); } QString Addressee::getCsum( const QString & prof) { return KIdManager::getCsum ( mData->mExternalId, prof ); } void Addressee::setIDStr( const QString & s ) { detach(); mData->mExternalId = s; } QString Addressee::IDStr() const { return mData->mExternalId; } @@ -1409,97 +1505,96 @@ void Addressee::insertCategory( const QString &c ) mData->categories.append( c ); } void Addressee::removeCategory( const QString &c ) { detach(); QStringList::Iterator it = mData->categories.find( c ); if ( it == mData->categories.end() ) return; mData->categories.remove( it ); } bool Addressee::hasCategory( const QString &c ) const { return ( mData->categories.contains( c ) ); } void Addressee::setCategories( const QStringList &c ) { detach(); mData->empty = false; mData->categories = c; } QStringList Addressee::categories() const { return mData->categories; } void Addressee::insertCustom( const QString &app, const QString &name, const QString &value ) { if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; detach(); mData->empty = false; QString qualifiedName = app + "-" + name + ":"; QStringList::Iterator it; for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { if ( (*it).startsWith( qualifiedName ) ) { (*it) = qualifiedName + value; return; } } - mData->custom.append( qualifiedName + value ); } void Addressee::removeCustom( const QString &app, const QString &name) { detach(); QString qualifiedName = app + "-" + name + ":"; QStringList::Iterator it; for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { if ( (*it).startsWith( qualifiedName ) ) { mData->custom.remove( it ); return; } } } QString Addressee::custom( const QString &app, const QString &name ) const { QString qualifiedName = app + "-" + name + ":"; QString value; QStringList::ConstIterator it; for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { if ( (*it).startsWith( qualifiedName ) ) { value = (*it).mid( (*it).find( ":" ) + 1 ); break; } } return value; } void Addressee::setCustoms( const QStringList &l ) { detach(); mData->empty = false; mData->custom = l; } QStringList Addressee::customs() const { return mData->custom; } void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |