summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp44
-rw-r--r--kabc/addressbook.h3
-rw-r--r--kaddressbook/kabcore.cpp65
-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, 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
@@ -42,16 +42,17 @@ $Id$
42#include <qfile.h> 42#include <qfile.h>
43#include <qregexp.h> 43#include <qregexp.h>
44 44
45#include <kglobal.h> 45#include <kglobal.h>
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"
54 55
55//US #include "addressbook.moc" 56//US #include "addressbook.moc"
56 57
57using namespace KABC; 58using namespace KABC;
@@ -454,16 +455,59 @@ void AddressBook::removeUntagged()
454 todel = ait; 455 todel = ait;
455 } else 456 } else
456 todelete = false; 457 todelete = false;
457 } 458 }
458 if ( todelete ) 459 if ( todelete )
459 removeAddressee( todel ); 460 removeAddressee( todel );
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{
464 bool ok = true; 508 bool ok = true;
465 509
466 deleteRemovedAddressees(); 510 deleteRemovedAddressees();
467 Iterator ait; 511 Iterator ait;
468 for ( ait = begin(); ait != end(); ++ait ) { 512 for ( ait = begin(); ait != end(); ++ait ) {
469 if ( !(*ait).IDStr().isEmpty() ) { 513 if ( !(*ait).IDStr().isEmpty() ) {
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 532e05d..cc755d1 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -137,16 +137,19 @@ class AddressBook : public QObject
137 /** 137 /**
138 Save address book. The address book is saved to the file, the Ticket 138 Save address book. The address book is saved to the file, the Ticket
139 object has been requested for by @ref requestSaveTicket(). 139 object has been requested for by @ref requestSaveTicket().
140 140
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();
149 /** 152 /**
150 Returns a iterator for first entry of address book. 153 Returns a iterator for first entry of address book.
151 */ 154 */
152 Iterator begin(); 155 Iterator begin();
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 452f1bc..a7967cb 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2818,39 +2818,25 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
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
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
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 );
@@ -2863,26 +2849,65 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource)
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 2857void KABCore::message( QString m )
2872void 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}
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}
2898void 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}
2883void KABCore::syncFileRequest() 2908void KABCore::syncFileRequest()
2884{ 2909{
2885 mAddressBook->export2File( sentSyncFile() ); 2910 mAddressBook->export2File( sentSyncFile() );
2886} 2911}
2887QString KABCore::sentSyncFile() 2912QString KABCore::sentSyncFile()
2888{ 2913{
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 43c5f99..04ce33d 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -459,17 +459,18 @@ class KABCore : public QWidget, public KSyncInterface
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);
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index c39413e..3555dc6 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -286,26 +286,22 @@ ulong PhoneFormat::getCsum( const QStringList & attList)
286//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 286//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
287#include <stdlib.h> 287#include <stdlib.h>
288#define DEBUGMODE false 288#define DEBUGMODE false
289bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) 289bool 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 }
308 VCalFormat vfload; 304 VCalFormat vfload;
309 vfload.setLocalTime ( true ); 305 vfload.setLocalTime ( true );
310 qDebug("loading file ..."); 306 qDebug("loading file ...");
311 307
diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp
index fe914dd..5fafa1f 100644
--- a/libkdepim/phoneaccess.cpp
+++ b/libkdepim/phoneaccess.cpp
@@ -138,14 +138,36 @@ bool PhoneAccess::writeToPhone( QString fileName)
138#endif 138#endif
139#else 139#else
140 QString command ="kammu --restore " + fileName ; 140 QString command ="kammu --restore " + fileName ;
141#endif 141#endif
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}
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;
149 } 171 }
150 return true; 172 return true;
151} 173}
diff --git a/libkdepim/phoneaccess.h b/libkdepim/phoneaccess.h
index b7c4732..80840e2 100644
--- a/libkdepim/phoneaccess.h
+++ b/libkdepim/phoneaccess.h
@@ -17,26 +17,28 @@
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
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/**
29 This class implements the calendar format used by Phone. 30 This class implements the calendar format used by Phone.
30*/ 31*/
31 32
32class PhoneAccess : public QObject { 33class 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
41 43
42#endif 44#endif