-rw-r--r-- | kabc/addressbook.cpp | 44 | ||||
-rw-r--r-- | kabc/addressbook.h | 3 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 65 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 3 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 12 | ||||
-rw-r--r-- | libkdepim/phoneaccess.cpp | 24 | ||||
-rw-r--r-- | libkdepim/phoneaccess.h | 2 |
7 files changed, 123 insertions, 30 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 16927e2..d037d2f 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -49,2 +49,3 @@ $Id$ | |||
49 | #include <libkcal/syncdefines.h> | 49 | #include <libkcal/syncdefines.h> |
50 | #include <libkdepim/phoneaccess.h> | ||
50 | #include "addressbook.h" | 51 | #include "addressbook.h" |
@@ -461,2 +462,45 @@ void AddressBook::removeUntagged() | |||
461 | } | 462 | } |
463 | void AddressBook::smplifyAddressees() | ||
464 | { | ||
465 | Iterator ait; | ||
466 | for ( ait = begin(); ait != end(); ++ait ) { | ||
467 | (*ait).simplifyEmails(); | ||
468 | (*ait).simplifyPhoneNumbers(); | ||
469 | (*ait).simplifyPhoneNumberTypes(); | ||
470 | (*ait).simplifyAddresses(); | ||
471 | } | ||
472 | } | ||
473 | void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) | ||
474 | { | ||
475 | Iterator ait; | ||
476 | for ( ait = begin(); ait != end(); ++ait ) { | ||
477 | QString id = (*ait).IDStr(); | ||
478 | (*ait).setIDStr( ":"); | ||
479 | (*ait).setExternalUID( id ); | ||
480 | (*ait).setOriginalExternalUID( id ); | ||
481 | if ( isPreSync ) | ||
482 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | ||
483 | else | ||
484 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | ||
485 | } | ||
486 | } | ||
487 | bool AddressBook::saveABphone( QString fileName ) | ||
488 | { | ||
489 | smplifyAddressees(); | ||
490 | qDebug("saveABphone:: saving AB... "); | ||
491 | if ( ! saveAB() ) | ||
492 | return false; | ||
493 | qDebug("saveABphone:: writing to phone... "); | ||
494 | if ( !PhoneAccess::writeToPhone( fileName) ) { | ||
495 | return false; | ||
496 | } | ||
497 | qDebug("saveABphone:: re-reading from phone... "); | ||
498 | if ( !PhoneAccess::readFromPhone( fileName) ) { | ||
499 | return false; | ||
500 | } | ||
501 | qDebug("reloading phone book... "); | ||
502 | if ( !load() ) | ||
503 | return false; | ||
504 | return true; | ||
505 | } | ||
462 | bool AddressBook::saveAB() | 506 | bool AddressBook::saveAB() |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 532e05d..cc755d1 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -144,2 +144,5 @@ class AddressBook : public QObject | |||
144 | bool saveAB( ); | 144 | bool saveAB( ); |
145 | bool saveABphone( QString fileName ); | ||
146 | void smplifyAddressees(); | ||
147 | void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); | ||
145 | void export2File( QString fileName ); | 148 | void export2File( QString fileName ); |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 452f1bc..a7967cb 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2825,19 +2825,3 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | |||
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 | } |
@@ -2848,2 +2832,4 @@ 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(); |
@@ -2870,8 +2856,47 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource) | |||
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; |
@@ -2879,3 +2904,3 @@ void KABCore::getFile( bool success ) | |||
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(); |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 43c5f99..04ce33d 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -466,3 +466,4 @@ class KABCore : public QWidget, public KSyncInterface | |||
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 | ||
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index c39413e..3555dc6 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -293,12 +293,8 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | |||
293 | #ifdef _WIN32_ | 293 | #ifdef _WIN32_ |
294 | fileName = locateLocal("tmp", "tempfile.vcs"); | 294 | fileName = locateLocal("tmp", "phonefile.vcs"); |
295 | #else | 295 | #else |
296 | fileName = "/tmp/kdepimtemp.vcs"; | 296 | fileName = "/tmp/phonefile.vcs"; |
297 | #endif | 297 | #endif |
298 | #ifdef DESKTOP_VERSION | 298 | QString command; |
299 | QString command ="./kammu --backup " + fileName + " -yes" ; | 299 | int ret = PhoneAccess::readFromPhone( fileName ); |
300 | #else | ||
301 | QString command ="kammu --backup " + fileName + " -yes" ; | ||
302 | #endif | ||
303 | int ret = system ( command.latin1() ); | ||
304 | if ( ret != 0 ) { | 300 | if ( ret != 0 ) { |
diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp index fe914dd..5fafa1f 100644 --- a/libkdepim/phoneaccess.cpp +++ b/libkdepim/phoneaccess.cpp | |||
@@ -145,3 +145,25 @@ bool PhoneAccess::writeToPhone( QString fileName) | |||
145 | int retval = KMessageBox::warningContinueCancel(0, | 145 | int retval = KMessageBox::warningContinueCancel(0, |
146 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone access"),i18n("Retry"),i18n("Cancel")); | 146 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); |
147 | if ( retval != KMessageBox::Continue ) | ||
148 | return false; | ||
149 | } | ||
150 | return true; | ||
151 | } | ||
152 | bool PhoneAccess::readFromPhone( QString fileName) | ||
153 | { | ||
154 | |||
155 | #ifdef DESKTOP_VERSION | ||
156 | #ifdef _WIN32_ | ||
157 | QString command ="kammu --backup " + fileName + " -yes" ; | ||
158 | #else | ||
159 | QString command ="./kammu --backup " + fileName + " -yes" ; | ||
160 | #endif | ||
161 | #else | ||
162 | QString command ="kammu --backup " + fileName + " -yes" ; | ||
163 | #endif | ||
164 | int ret; | ||
165 | while ( (ret = system ( command.latin1())) != 0 ) { | ||
166 | qDebug("Error S::command returned %d.", ret); | ||
167 | int retval = KMessageBox::warningContinueCancel(0, | ||
168 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); | ||
147 | if ( retval != KMessageBox::Continue ) | 169 | if ( retval != KMessageBox::Continue ) |
diff --git a/libkdepim/phoneaccess.h b/libkdepim/phoneaccess.h index b7c4732..80840e2 100644 --- a/libkdepim/phoneaccess.h +++ b/libkdepim/phoneaccess.h | |||
@@ -24,2 +24,3 @@ | |||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qobject.h> | ||
25 | 26 | ||
@@ -36,2 +37,3 @@ class PhoneAccess : public QObject { | |||
36 | static bool writeToPhone( QString fileName ); | 37 | static bool writeToPhone( QString fileName ); |
38 | static bool readFromPhone( QString fileName ); | ||
37 | 39 | ||