summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-18 13:13:58 (UTC)
committer zautrix <zautrix>2004-09-18 13:13:58 (UTC)
commitbb16660f29fc709791aa0ee4cb63a40710a994a8 (patch) (side-by-side diff)
tree5d7387987848039bb3594a624b819d136a38b0cd
parent4ec7c78ebd2c5a79ff224e9b07d9a3164f7fe602 (diff)
downloadkdepimpi-bb16660f29fc709791aa0ee4cb63a40710a994a8.zip
kdepimpi-bb16660f29fc709791aa0ee4cb63a40710a994a8.tar.gz
kdepimpi-bb16660f29fc709791aa0ee4cb63a40710a994a8.tar.bz2
more AB syncing
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp27
-rw-r--r--kabc/addressbook.h5
-rw-r--r--kabc/addressee.cpp54
-rw-r--r--kabc/addressee.h12
-rw-r--r--kaddressbook/kabcore.cpp93
-rw-r--r--kaddressbook/kabcore.h2
6 files changed, 156 insertions, 37 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 70eda1b..9332e21 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -44,2 +44,3 @@ $Id$
#include <kdebug.h>
+#include <libkcal/syncdefines.h>
#include "addressbook.h"
@@ -514,2 +515,28 @@ Addressee AddressBook::findByUid( const QString &uid )
}
+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 );
+ }
+
+}
+
+
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index e43de31..05225f9 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -290,2 +290,7 @@ class AddressBook : public QObject
+ // sync stuff
+ Addressee::List getExternLastSyncAddressees();
+ void resetTempSyncStat();
+
+
signals:
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 4cdd5e5..fb32f6e 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -34,4 +34,6 @@ $Id$
#include <klocale.h>
+#include <kidmanager.h>
//US
#include <kstandarddirs.h>
+#include <libkcal/syncdefines.h>
@@ -72,3 +74,3 @@ struct Addressee::AddresseeData : public KShared
Agent agent;
-
+ QString mExternalId;
PhoneNumber::List phoneNumbers;
@@ -92,2 +94,4 @@ Addressee::Addressee()
mData->resource = 0;
+ mData->mExternalId = ":";
+ mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
}
@@ -101,2 +105,3 @@ Addressee::Addressee( const Addressee &a )
mData = a.mData;
+ mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
}
@@ -170,2 +175,49 @@ bool Addressee::isEmpty() const
}
+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;
+}
+
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 27782f9..f098371 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -98,3 +98,12 @@ class Addressee
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 &);
/**
@@ -817,2 +826,3 @@ class Addressee
void detach();
+ int mTempSyncStat;
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 1196360..53c63ff 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2515,5 +2515,24 @@ QString KABCore::getPassword( )
}
+#include <libkcal/syncdefines.h>
+
+KABC::Addressee KABCore::getLastSyncAddressee()
+{
+ Addressee lse;
+ //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
+ lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
+ if (lse.isEmpty()) {
+ lse.setUid( "last-syncEvent-"+mCurrentSyncDevice );
+ QString sum = "";
+ if ( KABPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
+ sum = "E: ";
+ lse.setFamilyName(sum+mCurrentSyncDevice + i18n(" - sync event"));
+ lse.setRevision( mLastAddressbookSync );
+ lse.setCategories( i18n("SyncEvent") );
+ mAddressBook->insertAddressee( lse );
+ }
+ return lse;
+}
+
bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
{
-#if 0
bool syncOK = true;
@@ -2526,19 +2545,19 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
//QPtrList<Addressee> el = local->rawAddressees();
- Addressee* addresseeR;
+ Addressee addresseeR;
QString uid;
int take;
- Addressee* addresseeL;
- Addressee* addresseeRSync;
- Addressee* addresseeLSync;
- QPtrList<Addressee> addresseeRSyncSharp = remote->getExternLastSyncAddressees();
- QPtrList<Addressee> addresseeLSyncSharp = local->getExternLastSyncAddressees();
+ Addressee addresseeL;
+ Addressee addresseeRSync;
+ Addressee addresseeLSync;
+ KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
+ KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
bool fullDateRange = false;
local->resetTempSyncStat();
- mLastCalendarSync = QDateTime::currentDateTime();
- QDateTime modifiedCalendar = mLastCalendarSync;;
+ mLastAddressbookSync = QDateTime::currentDateTime();
+ QDateTime modifiedCalendar = mLastAddressbookSync;;
addresseeLSync = getLastSyncAddressee();
- addresseeR = remote->addressee("last-syncAddressee-"+mCurrentSyncName );
- if ( addresseeR ) {
- addresseeRSync = (Addressee*) addresseeR->clone();
- remote->deleteAddressee(addresseeR );
+ addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
+ if ( !addresseeR.isEmpty() ) {
+ addresseeRSync = addresseeR;
+ remote->removeAddressee(addresseeR );
@@ -2546,18 +2565,17 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
- addresseeRSync = (Addressee*)addresseeLSync->clone();
+ addresseeRSync = addresseeLSync ;
} else {
fullDateRange = true;
- addresseeRSync = new Addressee();
- addresseeRSync->setSummary(mCurrentSyncName + i18n(" - sync addressee"));
- addresseeRSync->setUid("last-syncAddressee-"+mCurrentSyncName );
- addresseeRSync->setDtStart( mLastCalendarSync );
- addresseeRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
- addresseeRSync->setCategories( i18n("SyncAddressee") );
+ Addressee newAdd;
+ addresseeRSync = newAdd;
+ addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
+ addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
+ addresseeRSync.setRevision( mLastAddressbookSync );
+ addresseeRSync.setCategories( i18n("SyncAddressee") );
}
}
- if ( addresseeLSync->dtStart() == mLastCalendarSync )
+ if ( addresseeLSync.revision() == mLastAddressbookSync )
fullDateRange = true;
-
if ( ! fullDateRange ) {
- if ( addresseeLSync->dtStart() != addresseeRSync->dtStart() ) {
+ if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
@@ -2569,12 +2587,17 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
if ( fullDateRange )
- mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
+ mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
else
- mLastCalendarSync = addresseeLSync->dtStart();
+ mLastAddressbookSync = addresseeLSync.revision();
// for resyncing if own file has changed
+ // PENDING fixme later when implemented
+#if 0
if ( mCurrentSyncDevice == "deleteaftersync" ) {
- mLastCalendarSync = loadedFileVersion;
- qDebug("setting mLastCalendarSync ");
+ mLastAddressbookSync = loadedFileVersion;
+ qDebug("setting mLastAddressbookSync ");
}
+#endif
+
+ #if 0
//qDebug("*************************** ");
- qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
+ qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
QPtrList<Incidence> er = remote->rawIncidences();
@@ -2659,3 +2682,3 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
} else {
- if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
+ if ( inR->lastModified() > mLastAddressbookSync || mode == 5 ) {
inR->setLastModified( modifiedCalendar );
@@ -2715,3 +2738,3 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
} else {
- if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
+ if ( inL->lastModified() < mLastAddressbookSync && mode != 4 ) {
checkExternSyncAddressee(addresseeLSyncSharp, inL);
@@ -2762,8 +2785,8 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
bar.hide();
- mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
+ mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
addresseeLSync->setReadOnly( false );
- addresseeLSync->setDtStart( mLastCalendarSync );
- addresseeRSync->setDtStart( mLastCalendarSync );
- addresseeLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
- addresseeRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
+ addresseeLSync->setDtStart( mLastAddressbookSync );
+ addresseeRSync->setDtStart( mLastAddressbookSync );
+ addresseeLSync->setDtEnd( mLastAddressbookSync.addSecs( 3600 ) );
+ addresseeRSync->setDtEnd( mLastAddressbookSync.addSecs( 3600 ) );
addresseeRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 4487a8a..c67cee6 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -474,2 +474,4 @@ class KABCore : public QWidget
bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
+ KABC::Addressee getLastSyncAddressee();
+ QDateTime mLastAddressbookSync;
public slots: