author | zautrix <zautrix> | 2004-10-09 21:35:22 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-09 21:35:22 (UTC) |
commit | 213a9d993e5a4751b64e18320cfbebb000681d13 (patch) (unidiff) | |
tree | 995b465797464e689b73d3271ff4a3f8f0d3749b /kaddressbook | |
parent | d68435216e1ebc5a7fed391157197994e13992b3 (diff) | |
download | kdepimpi-213a9d993e5a4751b64e18320cfbebb000681d13.zip kdepimpi-213a9d993e5a4751b64e18320cfbebb000681d13.tar.gz kdepimpi-213a9d993e5a4751b64e18320cfbebb000681d13.tar.bz2 |
ab phone sync implemented
-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 | |||
@@ -2814,79 +2814,104 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | |||
2814 | if ( isXML ) { | 2814 | if ( isXML ) { |
2815 | // afterwrite processing | 2815 | // afterwrite processing |
2816 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2816 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2817 | } | 2817 | } |
2818 | } | 2818 | } |
2819 | } | 2819 | } |
2820 | setModified(); | 2820 | setModified(); |
2821 | 2821 | ||
2822 | } | 2822 | } |
2823 | if ( syncOK ) | 2823 | if ( syncOK ) |
2824 | mViewManager->refreshView(); | 2824 | mViewManager->refreshView(); |
2825 | return syncOK; | 2825 | return syncOK; |
2826 | #if 0 | ||
2827 | 2826 | ||
2828 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | ||
2829 | getEventViewerDialog()->setSyncMode( true ); | ||
2830 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | ||
2831 | getEventViewerDialog()->setSyncMode( false ); | ||
2832 | if ( syncOK ) { | ||
2833 | if ( KOPrefs::instance()->mWriteBackFile ) | ||
2834 | { | ||
2835 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | ||
2836 | storage->save(); | ||
2837 | } | ||
2838 | } | ||
2839 | setModified(); | ||
2840 | } | ||
2841 | |||
2842 | #endif | ||
2843 | } | 2827 | } |
2844 | 2828 | ||
2845 | 2829 | ||
2846 | //this is a overwritten callbackmethods from the syncinterface | 2830 | //this is a overwritten callbackmethods from the syncinterface |
2847 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2831 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2848 | { | 2832 | { |
2833 | if ( resource == "phone" ) | ||
2834 | return syncPhone(); | ||
2849 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2835 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2850 | 2836 | ||
2851 | AddressBook abLocal( resource,"syncContact"); | 2837 | AddressBook abLocal( resource,"syncContact"); |
2852 | bool syncOK = false; | 2838 | bool syncOK = false; |
2853 | if ( abLocal.load() ) { | 2839 | if ( abLocal.load() ) { |
2854 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2840 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2855 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2841 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2856 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2842 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2857 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2843 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2858 | if ( syncOK ) { | 2844 | if ( syncOK ) { |
2859 | if ( syncManager->mWriteBackFile ) { | 2845 | if ( syncManager->mWriteBackFile ) { |
2860 | abLocal.saveAB(); | 2846 | abLocal.saveAB(); |
2861 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2847 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2862 | } | 2848 | } |
2863 | } | 2849 | } |
2864 | setModified(); | 2850 | setModified(); |
2865 | } | 2851 | } |
2866 | if ( syncOK ) | 2852 | if ( syncOK ) |
2867 | mViewManager->refreshView(); | 2853 | mViewManager->refreshView(); |
2868 | return syncOK; | 2854 | return syncOK; |
2869 | 2855 | ||
2870 | } | 2856 | } |
2871 | 2857 | void KABCore::message( QString m ) | |
2872 | void KABCore::getFile( bool success ) | ||
2873 | { | 2858 | { |
2859 | |||
2860 | topLevelWidget()->setCaption( m ); | ||
2874 | QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); | 2861 | QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); |
2862 | } | ||
2863 | bool KABCore::syncPhone() | ||
2864 | { | ||
2865 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | ||
2866 | QString fileName; | ||
2867 | #ifdef _WIN32_ | ||
2868 | fileName = locateLocal("tmp", "phonefile.vcf"); | ||
2869 | #else | ||
2870 | fileName = "/tmp/phonefile.vcf"; | ||
2871 | #endif | ||
2872 | if ( !PhoneAccess::readFromPhone( fileName) ) { | ||
2873 | message(i18n("Phone access failed!")); | ||
2874 | return false; | ||
2875 | } | ||
2876 | AddressBook abLocal( fileName,"syncContact"); | ||
2877 | bool syncOK = false; | ||
2878 | if ( abLocal.load() ) { | ||
2879 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | ||
2880 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | ||
2881 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | ||
2882 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | ||
2883 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | ||
2884 | if ( syncOK ) { | ||
2885 | if ( syncManager->mWriteBackFile ) { | ||
2886 | abLocal.saveABphone( fileName ); | ||
2887 | abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | ||
2888 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | ||
2889 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | ||
2890 | } | ||
2891 | } | ||
2892 | setModified(); | ||
2893 | } | ||
2894 | if ( syncOK ) | ||
2895 | mViewManager->refreshView(); | ||
2896 | return syncOK; | ||
2897 | } | ||
2898 | void KABCore::getFile( bool success ) | ||
2899 | { | ||
2875 | if ( ! success ) { | 2900 | if ( ! success ) { |
2876 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2901 | message( i18n("Error receiving file. Nothing changed!") ); |
2877 | return; | 2902 | return; |
2878 | } | 2903 | } |
2879 | mAddressBook->importFromFile( sentSyncFile() , false, true ); | 2904 | mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2880 | topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); | 2905 | message( i18n("Pi-Sync successful!") ); |
2881 | mViewManager->refreshView(); | 2906 | mViewManager->refreshView(); |
2882 | } | 2907 | } |
2883 | void KABCore::syncFileRequest() | 2908 | void KABCore::syncFileRequest() |
2884 | { | 2909 | { |
2885 | mAddressBook->export2File( sentSyncFile() ); | 2910 | mAddressBook->export2File( sentSyncFile() ); |
2886 | } | 2911 | } |
2887 | QString KABCore::sentSyncFile() | 2912 | QString KABCore::sentSyncFile() |
2888 | { | 2913 | { |
2889 | #ifdef _WIN32_ | 2914 | #ifdef _WIN32_ |
2890 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2915 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2891 | #else | 2916 | #else |
2892 | return QString( "/tmp/copysyncab.vcf" ); | 2917 | return QString( "/tmp/copysyncab.vcf" ); |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 43c5f99..04ce33d 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -455,25 +455,26 @@ class KABCore : public QWidget, public KSyncInterface | |||
455 | 455 | ||
456 | class KABCorePrivate; | 456 | class KABCorePrivate; |
457 | KABCorePrivate *d; | 457 | KABCorePrivate *d; |
458 | //US bool mBlockSaveFlag; | 458 | //US bool mBlockSaveFlag; |
459 | 459 | ||
460 | #ifdef KAB_EMBEDDED | 460 | #ifdef KAB_EMBEDDED |
461 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 461 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
462 | #endif //KAB_EMBEDDED | 462 | #endif //KAB_EMBEDDED |
463 | 463 | ||
464 | //this are the overwritten callbackmethods from the syncinterface | 464 | //this are the overwritten callbackmethods from the syncinterface |
465 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 465 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
466 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 466 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
467 | 467 | bool syncPhone(); | |
468 | void message( QString m ); | ||
468 | 469 | ||
469 | // LR ******************************* | 470 | // LR ******************************* |
470 | // sync stuff! | 471 | // sync stuff! |
471 | QString sentSyncFile(); | 472 | QString sentSyncFile(); |
472 | QPopupMenu *syncMenu; | 473 | QPopupMenu *syncMenu; |
473 | KSyncManager* syncManager; | 474 | KSyncManager* syncManager; |
474 | int mGlobalSyncMode; | 475 | int mGlobalSyncMode; |
475 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 476 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
476 | KABC::Addressee getLastSyncAddressee(); | 477 | KABC::Addressee getLastSyncAddressee(); |
477 | QDateTime mLastAddressbookSync; | 478 | QDateTime mLastAddressbookSync; |
478 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); | 479 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); |
479 | // ********************* | 480 | // ********************* |