-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 | |||
@@ -46,8 +46,9 @@ $Id$ | |||
46 | #include <klocale.h> | 46 | #include <klocale.h> |
47 | #include <kmessagebox.h> | 47 | #include <kmessagebox.h> |
48 | #include <kdebug.h> | 48 | #include <kdebug.h> |
49 | #include <libkcal/syncdefines.h> | 49 | #include <libkcal/syncdefines.h> |
50 | #include <libkdepim/phoneaccess.h> | ||
50 | #include "addressbook.h" | 51 | #include "addressbook.h" |
51 | #include "resource.h" | 52 | #include "resource.h" |
52 | #include "vcardconverter.h" | 53 | #include "vcardconverter.h" |
53 | #include "vcardparser/vcardtool.h" | 54 | #include "vcardparser/vcardtool.h" |
@@ -458,8 +459,51 @@ void AddressBook::removeUntagged() | |||
458 | if ( todelete ) | 459 | if ( todelete ) |
459 | removeAddressee( todel ); | 460 | removeAddressee( todel ); |
460 | deleteRemovedAddressees(); | 461 | deleteRemovedAddressees(); |
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() |
463 | { | 507 | { |
464 | bool ok = true; | 508 | bool ok = true; |
465 | 509 | ||
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 532e05d..cc755d1 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -141,8 +141,11 @@ class AddressBook : public QObject | |||
141 | @param ticket a ticket object returned by @ref requestSaveTicket() | 141 | @param ticket a ticket object returned by @ref requestSaveTicket() |
142 | */ | 142 | */ |
143 | bool save( Ticket *ticket ); | 143 | bool save( Ticket *ticket ); |
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 ); |
146 | void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); | 149 | void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); |
147 | void setUntagged(); | 150 | void setUntagged(); |
148 | void removeUntagged(); | 151 | void removeUntagged(); |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 452f1bc..a7967cb 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2822,31 +2822,17 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | |||
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; |
@@ -2867,18 +2853,57 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource) | |||
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 | { |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 43c5f99..04ce33d 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -463,9 +463,10 @@ class KABCore : public QWidget, public KSyncInterface | |||
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(); |
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index c39413e..3555dc6 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -290,18 +290,14 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | |||
290 | { | 290 | { |
291 | 291 | ||
292 | QString fileName; | 292 | QString fileName; |
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 ) { |
305 | qDebug("Error::command returned %d", ret); | 301 | qDebug("Error::command returned %d", ret); |
306 | return false; | 302 | return false; |
307 | } | 303 | } |
diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp index fe914dd..5fafa1f 100644 --- a/libkdepim/phoneaccess.cpp +++ b/libkdepim/phoneaccess.cpp | |||
@@ -142,9 +142,31 @@ bool PhoneAccess::writeToPhone( QString fileName) | |||
142 | int ret; | 142 | int ret; |
143 | while ( (ret = system ( command.latin1())) != 0 ) { | 143 | while ( (ret = system ( command.latin1())) != 0 ) { |
144 | qDebug("Error S::command returned %d.", ret); | 144 | qDebug("Error S::command returned %d.", ret); |
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 ) |
148 | return false; | 170 | return false; |
149 | } | 171 | } |
150 | return true; | 172 | return true; |
diff --git a/libkdepim/phoneaccess.h b/libkdepim/phoneaccess.h index b7c4732..80840e2 100644 --- a/libkdepim/phoneaccess.h +++ b/libkdepim/phoneaccess.h | |||
@@ -21,8 +21,9 @@ | |||
21 | #ifndef PHONEACCESS_H | 21 | #ifndef PHONEACCESS_H |
22 | #define PHONEACCESS_H | 22 | #define PHONEACCESS_H |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qobject.h> | ||
25 | 26 | ||
26 | 27 | ||
27 | 28 | ||
28 | /** | 29 | /** |
@@ -33,8 +34,9 @@ class PhoneAccess : public QObject { | |||
33 | public: | 34 | public: |
34 | 35 | ||
35 | static void writeConfig( QString device,QString connection, QString model ); | 36 | static void writeConfig( QString device,QString connection, QString model ); |
36 | static bool writeToPhone( QString fileName ); | 37 | static bool writeToPhone( QString fileName ); |
38 | static bool readFromPhone( QString fileName ); | ||
37 | 39 | ||
38 | }; | 40 | }; |
39 | 41 | ||
40 | 42 | ||