summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kabc/addressbook.cpp44
-rw-r--r--kabc/addressbook.h3
-rw-r--r--kaddressbook/kabcore.cpp63
-rw-r--r--kaddressbook/kabcore.h3
-rw-r--r--libkcal/phoneformat.cpp12
-rw-r--r--libkdepim/phoneaccess.cpp24
-rw-r--r--libkdepim/phoneaccess.h2
7 files changed, 122 insertions, 29 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 16927e2..d037d2f 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -48,4 +48,5 @@ $Id$
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"
@@ -460,4 +461,47 @@ void AddressBook::removeUntagged()
460 deleteRemovedAddressees(); 461 deleteRemovedAddressees();
461} 462}
463void 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}
473void 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}
487bool 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}
462bool AddressBook::saveAB() 506bool AddressBook::saveAB()
463{ 507{
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 532e05d..cc755d1 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -143,4 +143,7 @@ class AddressBook : public QObject
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 );
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 452f1bc..a7967cb 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2824,21 +2824,5 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2824 mViewManager->refreshView(); 2824 mViewManager->refreshView();
2825 return syncOK; 2825 return syncOK;
2826#if 0
2827
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 2826
2842#endif
2843} 2827}
2844 2828
@@ -2847,4 +2831,6 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2847bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2831bool 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
@@ -2869,14 +2855,53 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2869 2855
2870} 2856}
2857void KABCore::message( QString m )
2858{
2871 2859
2860 topLevelWidget()->setCaption( m );
2861 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack()));
2862}
2863bool 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}
2872void KABCore::getFile( bool success ) 2898void KABCore::getFile( bool success )
2873{ 2899{
2874 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack()));
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}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 43c5f99..04ce33d 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -465,5 +465,6 @@ class KABCore : public QWidget, public KSyncInterface
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 *******************************
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index c39413e..3555dc6 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -292,14 +292,10 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
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);
diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp
index fe914dd..5fafa1f 100644
--- a/libkdepim/phoneaccess.cpp
+++ b/libkdepim/phoneaccess.cpp
@@ -144,5 +144,27 @@ bool PhoneAccess::writeToPhone( QString fileName)
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}
152bool 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;
diff --git a/libkdepim/phoneaccess.h b/libkdepim/phoneaccess.h
index b7c4732..80840e2 100644
--- a/libkdepim/phoneaccess.h
+++ b/libkdepim/phoneaccess.h
@@ -23,4 +23,5 @@
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qobject.h>
25 26
26 27
@@ -35,4 +36,5 @@ class PhoneAccess : public QObject {
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};