From bb16660f29fc709791aa0ee4cb63a40710a994a8 Mon Sep 17 00:00:00 2001 From: zautrix Date: Sat, 18 Sep 2004 13:13:58 +0000 Subject: more AB syncing --- (limited to 'kabc') diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 70eda1b..9332e21 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -42,6 +42,7 @@ $Id$ #include #include #include +#include #include "addressbook.h" #include "resource.h" @@ -512,6 +513,32 @@ Addressee AddressBook::findByUid( const QString &uid ) } return Addressee(); } +Addressee::List AddressBook::getExternLastSyncAddressees() +{ + Addressee::List results; + + Iterator it; + for ( it = begin(); it != end(); ++it ) { + if ( (*it).uid().left( 20 ) == "last-syncAddressee-" ) { + if ( (*it).familyName().left(3) == "E: " ) + results.append( *it ); + } + } + + return results; +} +void AddressBook::resetTempSyncStat() +{ + + + Iterator it; + for ( it = begin(); it != end(); ++it ) { + (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); + } + +} + + Addressee::List AddressBook::allAddressees() { diff --git a/kabc/addressbook.h b/kabc/addressbook.h index e43de31..05225f9 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h @@ -288,6 +288,11 @@ class AddressBook : public QObject */ void cleanUp(); + // sync stuff + Addressee::List getExternLastSyncAddressees(); + void resetTempSyncStat(); + + signals: /** Emitted, when the address book has changed on disk. diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 4cdd5e5..fb32f6e 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -32,8 +32,10 @@ $Id$ #include #include #include +#include //US #include +#include //US #include "resource.h" #include "addressee.h" @@ -70,7 +72,7 @@ struct Addressee::AddresseeData : public KShared Picture photo; Sound sound; Agent agent; - + QString mExternalId; PhoneNumber::List phoneNumbers; Address::List addresses; Key::List keys; @@ -90,6 +92,8 @@ Addressee::Addressee() mData->empty = true; mData->changed = false; mData->resource = 0; + mData->mExternalId = ":"; + mTempSyncStat = SYNC_TEMPSTATE_INITIAL; } Addressee::~Addressee() @@ -99,6 +103,7 @@ Addressee::~Addressee() Addressee::Addressee( const Addressee &a ) { mData = a.mData; + mTempSyncStat = SYNC_TEMPSTATE_INITIAL; } Addressee &Addressee::operator=( const Addressee &a ) @@ -168,6 +173,53 @@ bool Addressee::isEmpty() const { return mData->empty; } +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; +} + void Addressee::setUid( const QString &id ) { diff --git a/kabc/addressee.h b/kabc/addressee.h index 27782f9..f098371 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h @@ -96,7 +96,16 @@ class Addressee bool operator==( const Addressee & ) const; bool operator!=( const Addressee & ) const; - + // sync stuff + void setTempSyncStat(int id); + int tempSyncStat() const; + void setIDStr( const QString & ); + QString IDStr() const; + void setID( const QString &, const QString & ); + QString getID( const QString & ); + void setCsum( const QString &, const QString & ); + QString getCsum( const QString & ); + void removeID(const QString &); /** Return, if the address book entry is empty. */ @@ -815,6 +824,7 @@ class Addressee private: Addressee copy(); void detach(); + int mTempSyncStat; struct AddresseeData; mutable KSharedPtr mData; -- cgit v0.9.0.2