-rw-r--r-- | kaddressbook/kabcore.cpp | 65 |
1 files changed, 45 insertions, 20 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() |