summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp1
-rw-r--r--kaddressbook/kabcore.cpp2
-rw-r--r--libkdepim/ksyncmanager.h2
3 files changed, 2 insertions, 3 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 295cf03..03a86f9 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -369,97 +369,96 @@ bool AddressBook::save( Ticket *ticket )
369 kdDebug(5700) << "AddressBook::save()"<< endl; 369 kdDebug(5700) << "AddressBook::save()"<< endl;
370 370
371 if ( ticket->resource() ) { 371 if ( ticket->resource() ) {
372 deleteRemovedAddressees(); 372 deleteRemovedAddressees();
373 return ticket->resource()->save( ticket ); 373 return ticket->resource()->save( ticket );
374 } 374 }
375 375
376 return false; 376 return false;
377} 377}
378void AddressBook::export2File( QString fileName ) 378void AddressBook::export2File( QString fileName )
379{ 379{
380 380
381 QFile outFile( fileName ); 381 QFile outFile( fileName );
382 if ( !outFile.open( IO_WriteOnly ) ) { 382 if ( !outFile.open( IO_WriteOnly ) ) {
383 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 383 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
384 KMessageBox::error( 0, text.arg( fileName ) ); 384 KMessageBox::error( 0, text.arg( fileName ) );
385 return ; 385 return ;
386 } 386 }
387 QTextStream t( &outFile ); 387 QTextStream t( &outFile );
388 t.setEncoding( QTextStream::UnicodeUTF8 ); 388 t.setEncoding( QTextStream::UnicodeUTF8 );
389 Iterator it; 389 Iterator it;
390 KABC::VCardConverter::Version version; 390 KABC::VCardConverter::Version version;
391 version = KABC::VCardConverter::v3_0; 391 version = KABC::VCardConverter::v3_0;
392 for ( it = begin(); it != end(); ++it ) { 392 for ( it = begin(); it != end(); ++it ) {
393 if ( !(*it).IDStr().isEmpty() ) { 393 if ( !(*it).IDStr().isEmpty() ) {
394 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); 394 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
395 } 395 }
396 KABC::VCardConverter converter; 396 KABC::VCardConverter converter;
397 QString vcard; 397 QString vcard;
398 //Resource *resource() const; 398 //Resource *resource() const;
399 converter.addresseeToVCard( *it, vcard, version ); 399 converter.addresseeToVCard( *it, vcard, version );
400 t << vcard << "\r\n"; 400 t << vcard << "\r\n";
401 } 401 }
402 outFile.close(); 402 outFile.close();
403} 403}
404void AddressBook::importFromFile( QString fileName ) 404void AddressBook::importFromFile( QString fileName )
405{ 405{
406 406
407 KABC::Addressee::List list; 407 KABC::Addressee::List list;
408 QFile file( fileName ); 408 QFile file( fileName );
409 409
410 file.open( IO_ReadOnly ); 410 file.open( IO_ReadOnly );
411 QByteArray rawData = file.readAll(); 411 QByteArray rawData = file.readAll();
412 file.close(); 412 file.close();
413 413
414 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 414 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
415 KABC::VCardTool tool; 415 KABC::VCardTool tool;
416 list = tool.parseVCards( data ); 416 list = tool.parseVCards( data );
417
418 KABC::Addressee::List::Iterator it; 417 KABC::Addressee::List::Iterator it;
419 for ( it = list.begin(); it != list.end(); ++it ) { 418 for ( it = list.begin(); it != list.end(); ++it ) {
420 (*it).setResource( 0 ); 419 (*it).setResource( 0 );
421 insertAddressee( (*it), false, true ); 420 insertAddressee( (*it), false, true );
422 } 421 }
423 422
424} 423}
425 424
426bool AddressBook::saveAB() 425bool AddressBook::saveAB()
427{ 426{
428 bool ok = true; 427 bool ok = true;
429 428
430 deleteRemovedAddressees(); 429 deleteRemovedAddressees();
431 Iterator ait; 430 Iterator ait;
432 for ( ait = begin(); ait != end(); ++ait ) { 431 for ( ait = begin(); ait != end(); ++ait ) {
433 if ( !(*ait).IDStr().isEmpty() ) { 432 if ( !(*ait).IDStr().isEmpty() ) {
434 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 433 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
435 } 434 }
436 } 435 }
437 KRES::Manager<Resource>::ActiveIterator it; 436 KRES::Manager<Resource>::ActiveIterator it;
438 KRES::Manager<Resource> *manager = d->mManager; 437 KRES::Manager<Resource> *manager = d->mManager;
439 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 438 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
440 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 439 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
441 Ticket *ticket = requestSaveTicket( *it ); 440 Ticket *ticket = requestSaveTicket( *it );
442// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 441// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
443 if ( !ticket ) { 442 if ( !ticket ) {
444 error( i18n( "Unable to save to resource '%1'. It is locked." ) 443 error( i18n( "Unable to save to resource '%1'. It is locked." )
445 .arg( (*it)->resourceName() ) ); 444 .arg( (*it)->resourceName() ) );
446 return false; 445 return false;
447 } 446 }
448 447
449 //if ( !save( ticket ) ) 448 //if ( !save( ticket ) )
450 if ( ticket->resource() ) { 449 if ( ticket->resource() ) {
451 if ( ! ticket->resource()->save( ticket ) ) 450 if ( ! ticket->resource()->save( ticket ) )
452 ok = false; 451 ok = false;
453 } else 452 } else
454 ok = false; 453 ok = false;
455 454
456 } 455 }
457 } 456 }
458 return ok; 457 return ok;
459} 458}
460 459
461AddressBook::Iterator AddressBook::begin() 460AddressBook::Iterator AddressBook::begin()
462{ 461{
463 Iterator it = Iterator(); 462 Iterator it = Iterator();
464 it.d->mIt = d->mAddressees.begin(); 463 it.d->mIt = d->mAddressees.begin();
465 return it; 464 return it;
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index fa80f5c..12502b0 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2813,75 +2813,75 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2813#if 0 2813#if 0
2814 2814
2815 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 2815 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2816 getEventViewerDialog()->setSyncMode( true ); 2816 getEventViewerDialog()->setSyncMode( true );
2817 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 2817 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2818 getEventViewerDialog()->setSyncMode( false ); 2818 getEventViewerDialog()->setSyncMode( false );
2819 if ( syncOK ) { 2819 if ( syncOK ) {
2820 if ( KOPrefs::instance()->mWriteBackFile ) 2820 if ( KOPrefs::instance()->mWriteBackFile )
2821 { 2821 {
2822 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2822 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2823 storage->save(); 2823 storage->save();
2824 } 2824 }
2825 } 2825 }
2826 setModified(); 2826 setModified();
2827 } 2827 }
2828 2828
2829#endif 2829#endif
2830} 2830}
2831 2831
2832 2832
2833//this is a overwritten callbackmethods from the syncinterface 2833//this is a overwritten callbackmethods from the syncinterface
2834bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2834bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2835{ 2835{
2836 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2836 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2837 2837
2838 AddressBook abLocal( resource,"syncContact"); 2838 AddressBook abLocal( resource,"syncContact");
2839 bool syncOK = false; 2839 bool syncOK = false;
2840 if ( abLocal.load() ) { 2840 if ( abLocal.load() ) {
2841 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2841 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2842 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2842 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2843 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2843 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2844 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2844 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2845 if ( syncOK ) { 2845 if ( syncOK ) {
2846 if ( syncManager->mWriteBackFile ) { 2846 if ( syncManager->mWriteBackFile ) {
2847 abLocal.saveAB(); 2847 abLocal.saveAB();
2848 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2848 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2849 } 2849 }
2850 } 2850 }
2851 setModified(); 2851 setModified();
2852 } 2852 }
2853 if ( syncOK ) 2853 if ( syncOK )
2854 mViewManager->refreshView(); 2854 mViewManager->refreshView();
2855 return syncOK; 2855 return syncOK;
2856 2856
2857} 2857}
2858 2858
2859void KABCore::getFile( bool success ) 2859void KABCore::getFile( bool success )
2860{ 2860{
2861 qDebug("KABCore::getFile ");
2862 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); 2861 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack()));
2863 if ( ! success ) { 2862 if ( ! success ) {
2864 setCaption( i18n("Error receiving file. Nothing changed!") ); 2863 setCaption( i18n("Error receiving file. Nothing changed!") );
2865 return; 2864 return;
2866 } 2865 }
2867 mAddressBook->importFromFile( sentSyncFile() ); 2866 mAddressBook->importFromFile( sentSyncFile() );
2868 topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 2867 topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
2868 mViewManager->refreshView();
2869} 2869}
2870void KABCore::syncFileRequest() 2870void KABCore::syncFileRequest()
2871{ 2871{
2872 mAddressBook->export2File( sentSyncFile() ); 2872 mAddressBook->export2File( sentSyncFile() );
2873} 2873}
2874QString KABCore::sentSyncFile() 2874QString KABCore::sentSyncFile()
2875{ 2875{
2876#ifdef _WIN32_ 2876#ifdef _WIN32_
2877 return locateLocal( "tmp", "copysyncab.vcf" ); 2877 return locateLocal( "tmp", "copysyncab.vcf" );
2878#else 2878#else
2879 return QString( "/tmp/copysyncab.vcf" ); 2879 return QString( "/tmp/copysyncab.vcf" );
2880#endif 2880#endif
2881} 2881}
2882 2882
2883void KABCore::setCaptionBack() 2883void KABCore::setCaptionBack()
2884{ 2884{
2885 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2885 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2886} 2886}
2887 2887
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index aad48d9..32400af 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -77,132 +77,132 @@ class KCommandSocket : public QObject
77public: 77public:
78 enum state { successR, errorR, successW, errorW, quiet }; 78 enum state { successR, errorR, successW, errorW, quiet };
79 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); 79 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
80 void readFile( QString ); 80 void readFile( QString );
81 void writeFile( QString ); 81 void writeFile( QString );
82 void sendStop(); 82 void sendStop();
83 83
84 84
85signals: 85signals:
86 void commandFinished( KCommandSocket*, int ); 86 void commandFinished( KCommandSocket*, int );
87private slots: 87private slots:
88 void startReadFileFromSocket(); 88 void startReadFileFromSocket();
89 void readFileFromSocket(); 89 void readFileFromSocket();
90 void deleteSocket(); 90 void deleteSocket();
91 void writeFileToSocket(); 91 void writeFileToSocket();
92 private : 92 private :
93 QSocket* mSocket; 93 QSocket* mSocket;
94 QString mPassWord; 94 QString mPassWord;
95 Q_UINT16 mPort; 95 Q_UINT16 mPort;
96 QString mHost; 96 QString mHost;
97 QString mFileName; 97 QString mFileName;
98 QTimer* mTimerSocket; 98 QTimer* mTimerSocket;
99 int mRetVal; 99 int mRetVal;
100 QTime mTime; 100 QTime mTime;
101 QString mFileString; 101 QString mFileString;
102 bool mFirst; 102 bool mFirst;
103}; 103};
104 104
105 105
106class KSyncManager : public QObject 106class KSyncManager : public QObject
107{ 107{
108 Q_OBJECT 108 Q_OBJECT
109 109
110 public: 110 public:
111 enum TargetApp { 111 enum TargetApp {
112 KOPI = 0, 112 KOPI = 0,
113 KAPI = 1, 113 KAPI = 1,
114 PWMPI = 2 }; 114 PWMPI = 2 };
115 115
116 116
117 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 117 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
118 ~KSyncManager() ; 118 ~KSyncManager() ;
119 119
120 bool blockSave() { return mBlockSaveFlag; } 120 bool blockSave() { return mBlockSaveFlag; }
121 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 121 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
122 void setDefaultFileName( QString s) { mDefFileName = s ;} 122 void setDefaultFileName( QString s) { mDefFileName = s ;}
123 QString defaultFileName() { return mDefFileName ;} 123 QString defaultFileName() { return mDefFileName ;}
124 QString syncFileName(); 124 QString syncFileName();
125 void fillSyncMenu();
126 125
127 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 126 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
128 QString getCurrentSyncName() { return mCurrentSyncName; } 127 QString getCurrentSyncName() { return mCurrentSyncName; }
129 128
130 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 129 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
131 void hideProgressBar(); 130 void hideProgressBar();
132 bool isProgressBarCanceled(); 131 bool isProgressBarCanceled();
133 132
134 // sync stuff 133 // sync stuff
135 QString mLocalMachineName; 134 QString mLocalMachineName;
136 QStringList mExternSyncProfiles; 135 QStringList mExternSyncProfiles;
137 QStringList mSyncProfileNames; 136 QStringList mSyncProfileNames;
138 bool mAskForPreferences; 137 bool mAskForPreferences;
139 bool mShowSyncSummary; 138 bool mShowSyncSummary;
140 bool mShowSyncEvents; 139 bool mShowSyncEvents;
141 bool mShowTodoInAgenda; 140 bool mShowTodoInAgenda;
142 bool mWriteBackExistingOnly; 141 bool mWriteBackExistingOnly;
143 int mSyncAlgoPrefs; 142 int mSyncAlgoPrefs;
144 int mRingSyncAlgoPrefs; 143 int mRingSyncAlgoPrefs;
145 bool mWriteBackFile; 144 bool mWriteBackFile;
146 int mWriteBackInFuture; 145 int mWriteBackInFuture;
147 QString mPhoneDevice; 146 QString mPhoneDevice;
148 QString mPhoneConnection; 147 QString mPhoneConnection;
149 QString mPhoneModel; 148 QString mPhoneModel;
150 QString mLastSyncedLocalFile; // save! 149 QString mLastSyncedLocalFile; // save!
151 QString mPassWordPiSync; 150 QString mPassWordPiSync;
152 QString mActiveSyncPort; 151 QString mActiveSyncPort;
153 QString mActiveSyncIP ; 152 QString mActiveSyncIP ;
154 153
155 signals: 154 signals:
156 void save(); 155 void save();
157 void request_file(); 156 void request_file();
158 void getFile( bool ); 157 void getFile( bool );
159 158
160 public slots: 159 public slots:
160 void fillSyncMenu();
161 void slotSyncMenu( int ); 161 void slotSyncMenu( int );
162 void deleteCommandSocket(KCommandSocket*s, int state); 162 void deleteCommandSocket(KCommandSocket*s, int state);
163 void readFileFromSocket(); 163 void readFileFromSocket();
164 164
165 private: 165 private:
166 // LR ******************************* 166 // LR *******************************
167 // sync stuff! 167 // sync stuff!
168 void syncPi(); 168 void syncPi();
169 KServerSocket * mServerSocket; 169 KServerSocket * mServerSocket;
170 void enableQuick(); 170 void enableQuick();
171 KPimPrefs* mPrefs; 171 KPimPrefs* mPrefs;
172 QString mDefFileName; 172 QString mDefFileName;
173 QString mCurrentSyncDevice; 173 QString mCurrentSyncDevice;
174 QString mCurrentSyncName; 174 QString mCurrentSyncName;
175 void quickSyncLocalFile(); 175 void quickSyncLocalFile();
176 bool syncWithFile( QString fn , bool quick ); 176 bool syncWithFile( QString fn , bool quick );
177 void syncLocalFile(); 177 void syncLocalFile();
178 void syncPhone(); 178 void syncPhone();
179 void syncSharp(); 179 void syncSharp();
180 bool syncExternalApplication(QString); 180 bool syncExternalApplication(QString);
181 void multiSync( bool askforPrefs ); 181 void multiSync( bool askforPrefs );
182 int mCurrentSyncProfile ; 182 int mCurrentSyncProfile ;
183 void syncRemote( KSyncProfile* prof, bool ask = true); 183 void syncRemote( KSyncProfile* prof, bool ask = true);
184 void edit_sync_options(); 184 void edit_sync_options();
185 int ringSync(); 185 int ringSync();
186 QString getPassword( ); 186 QString getPassword( );
187 187
188 private slots: 188 private slots:
189 void confSync(); 189 void confSync();
190 // ********************* 190 // *********************
191 191
192 private: 192 private:
193 bool mBlockSaveFlag; 193 bool mBlockSaveFlag;
194 194
195 195
196 QWidget* mParent; 196 QWidget* mParent;
197 KSyncInterface* mImplementation; 197 KSyncInterface* mImplementation;
198 TargetApp mTargetApp; 198 TargetApp mTargetApp;
199 QPopupMenu* mSyncMenu; 199 QPopupMenu* mSyncMenu;
200 200
201 QProgressBar* bar; 201 QProgressBar* bar;
202 202
203 203
204 204
205 205
206 206
207}; 207};
208 208