-rw-r--r-- | kaddressbook/kabcore.cpp | 65 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 3 |
2 files changed, 47 insertions, 21 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 452f1bc..a7967cb 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -2823,29 +2823,15 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) if ( syncOK ) mViewManager->refreshView(); return syncOK; -#if 0 - if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { - getEventViewerDialog()->setSyncMode( true ); - syncOK = synchronizeCalendar( mCalendar, calendar, mode ); - getEventViewerDialog()->setSyncMode( false ); - if ( syncOK ) { - if ( KOPrefs::instance()->mWriteBackFile ) - { - storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); - storage->save(); - } - } - setModified(); - } - -#endif } //this is a overwritten callbackmethods from the syncinterface bool KABCore::syncExternal(KSyncManager* manager, QString resource) { + if ( resource == "phone" ) + return syncPhone(); QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); AddressBook abLocal( resource,"syncContact"); @@ -2868,16 +2854,55 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource) return syncOK; } - -void KABCore::getFile( bool success ) +void KABCore::message( QString m ) { + + topLevelWidget()->setCaption( m ); QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); +} +bool KABCore::syncPhone() +{ + QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); + QString fileName; +#ifdef _WIN32_ + fileName = locateLocal("tmp", "phonefile.vcf"); +#else + fileName = "/tmp/phonefile.vcf"; +#endif + if ( !PhoneAccess::readFromPhone( fileName) ) { + message(i18n("Phone access failed!")); + return false; + } + AddressBook abLocal( fileName,"syncContact"); + bool syncOK = false; + if ( abLocal.load() ) { + qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); + mGlobalSyncMode = SYNC_MODE_EXTERNAL; + abLocal.preparePhoneSync( mCurrentSyncDevice, true ); + abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); + syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); + if ( syncOK ) { + if ( syncManager->mWriteBackFile ) { + abLocal.saveABphone( fileName ); + abLocal.preparePhoneSync( mCurrentSyncDevice, false ); + abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); + abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); + } + } + setModified(); + } + if ( syncOK ) + mViewManager->refreshView(); + return syncOK; +} +void KABCore::getFile( bool success ) +{ if ( ! success ) { - setCaption( i18n("Error receiving file. Nothing changed!") ); + message( i18n("Error receiving file. Nothing changed!") ); return; } mAddressBook->importFromFile( sentSyncFile() , false, true ); - topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); + message( i18n("Pi-Sync successful!") ); mViewManager->refreshView(); } void KABCore::syncFileRequest() diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 43c5f99..04ce33d 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -464,7 +464,8 @@ class KABCore : public QWidget, public KSyncInterface //this are the overwritten callbackmethods from the syncinterface virtual bool sync(KSyncManager* manager, QString filename, int mode); virtual bool syncExternal(KSyncManager* manager, QString resource); - + bool syncPhone(); + void message( QString m ); // LR ******************************* // sync stuff! |