From ed49c55dac215ac2ed9286ebfc36e5a19417f0bb Mon Sep 17 00:00:00 2001 From: zautrix Date: Mon, 20 Sep 2004 19:27:24 +0000 Subject: more DTM sync --- diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 17b9ba2..adb451f 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -254,8 +254,11 @@ void AddressBook::init(const QString &config, const QString &family ) con->writeEntry( "ResourceName", QString("sync_res") ); if ( config.right(4) == ".xml" ) con->writeEntry( "ResourceType", QString("qtopia") ); - else + else if ( config == "sharp" ) { + con->writeEntry( "ResourceType", QString("sharp") ); + } else { con->writeEntry( "ResourceType", QString("file") ); + } //con->sync(); d->mConfig = con; } diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index f8683e7..c1ead9d 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -3026,11 +3026,34 @@ void KABCore::confSync() } void KABCore::syncSharp() { + if ( ! syncExternal("sharp") ) + qDebug("ERROR sync sharp ");; +} +bool KABCore::syncExternal(QString resource) +{ if ( mModified ) save(); - qDebug("pending syncSharp() "); - //mView->syncSharp(); - setModified(); + if ( KABPrefs::instance()->mAskForPreferences ) + edit_sync_options(); + qDebug("syncSharp() "); + AddressBook abLocal( resource,"syncContact"); + bool syncOK = false; + if ( abLocal.load() ) { + qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); + mGlobalSyncMode = SYNC_MODE_EXTERNAL; + abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); + syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, KABPrefs::instance()->mSyncAlgoPrefs ); + if ( syncOK ) { + if ( KABPrefs::instance()->mWriteBackFile ) { + abLocal.saveAB(); + abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); + } + } + setModified(); + } + if ( syncOK ) + mViewManager->refreshView(); + return syncOK; } void KABCore::syncPhone() diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index f01f306..e89bf41 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -460,9 +460,10 @@ class KABCore : public QWidget QString mCurrentSyncName; void quickSyncLocalFile(); bool syncWithFile( QString fn , bool quick ); - void KABCore::syncLocalFile(); - void KABCore::syncPhone(); - void KABCore::syncSharp(); + void syncLocalFile(); + void syncPhone(); + void syncSharp(); + bool syncExternal(QString); void multiSync( bool askforPrefs ); int mCurrentSyncProfile ; void syncRemote( KSyncProfile* prof, bool ask = true); -- cgit v0.9.0.2