-rw-r--r-- | libkdepim/ksyncmanager.cpp | 126 |
1 files changed, 63 insertions, 63 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 568c2a9..01309d5 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,34 +1,34 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | // $Id$ | 21 | // $Id$ |
22 | 22 | ||
23 | #include "ksyncmanager.h" | 23 | #include "ksyncmanager.h" |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | 31 | ||
32 | #include "ksyncprofile.h" | 32 | #include "ksyncprofile.h" |
33 | #include "ksyncprefsdialog.h" | 33 | #include "ksyncprefsdialog.h" |
34 | #include "kpimprefs.h" | 34 | #include "kpimprefs.h" |
@@ -60,33 +60,33 @@ KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, Targ | |||
60 | mServerSocket = 0; | 60 | mServerSocket = 0; |
61 | bar = new QProgressBar ( 1, 0 ); | 61 | bar = new QProgressBar ( 1, 0 ); |
62 | bar->setCaption (""); | 62 | bar->setCaption (""); |
63 | 63 | ||
64 | int w = 300; | 64 | int w = 300; |
65 | if ( QApplication::desktop()->width() < 320 ) | 65 | if ( QApplication::desktop()->width() < 320 ) |
66 | w = 220; | 66 | w = 220; |
67 | int h = bar->sizeHint().height() ; | 67 | int h = bar->sizeHint().height() ; |
68 | int dw = QApplication::desktop()->width(); | 68 | int dw = QApplication::desktop()->width(); |
69 | int dh = QApplication::desktop()->height(); | 69 | int dh = QApplication::desktop()->height(); |
70 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 70 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
71 | 71 | ||
72 | } | 72 | } |
73 | 73 | ||
74 | KSyncManager::~KSyncManager() | 74 | KSyncManager::~KSyncManager() |
75 | { | 75 | { |
76 | delete bar; | 76 | delete bar; |
77 | } | 77 | } |
78 | 78 | ||
79 | 79 | ||
80 | void KSyncManager::fillSyncMenu() | 80 | void KSyncManager::fillSyncMenu() |
81 | { | 81 | { |
82 | if ( mSyncMenu->count() ) | 82 | if ( mSyncMenu->count() ) |
83 | mSyncMenu->clear(); | 83 | mSyncMenu->clear(); |
84 | 84 | ||
85 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 85 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
86 | mSyncMenu->insertSeparator(); | 86 | mSyncMenu->insertSeparator(); |
87 | if ( mServerSocket == 0 ) { | 87 | if ( mServerSocket == 0 ) { |
88 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 88 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
89 | } else { | 89 | } else { |
90 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 90 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
91 | } | 91 | } |
92 | mSyncMenu->insertSeparator(); | 92 | mSyncMenu->insertSeparator(); |
@@ -152,33 +152,33 @@ void KSyncManager::slotSyncMenu( int action ) | |||
152 | multiSync( true ); | 152 | multiSync( true ); |
153 | return; | 153 | return; |
154 | } | 154 | } |
155 | if ( action == 2 ) { | 155 | if ( action == 2 ) { |
156 | enableQuick(); | 156 | enableQuick(); |
157 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 157 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
158 | return; | 158 | return; |
159 | } | 159 | } |
160 | if ( action == 3 ) { | 160 | if ( action == 3 ) { |
161 | delete mServerSocket; | 161 | delete mServerSocket; |
162 | mServerSocket = 0; | 162 | mServerSocket = 0; |
163 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 163 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
164 | return; | 164 | return; |
165 | } | 165 | } |
166 | 166 | ||
167 | if (blockSave()) | 167 | if (blockSave()) |
168 | return; | 168 | return; |
169 | 169 | ||
170 | setBlockSave(true); | 170 | setBlockSave(true); |
171 | 171 | ||
172 | mCurrentSyncProfile = action - 1000 ; | 172 | mCurrentSyncProfile = action - 1000 ; |
173 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 173 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
174 | mCurrentSyncName = mLocalMachineName ; | 174 | mCurrentSyncName = mLocalMachineName ; |
175 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 175 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
176 | KSyncProfile* temp = new KSyncProfile (); | 176 | KSyncProfile* temp = new KSyncProfile (); |
177 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 177 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
178 | temp->readConfig(&config); | 178 | temp->readConfig(&config); |
179 | mAskForPreferences = temp->getAskForPreferences(); | 179 | mAskForPreferences = temp->getAskForPreferences(); |
180 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 180 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
181 | mWriteBackFile = temp->getWriteBackFile(); | 181 | mWriteBackFile = temp->getWriteBackFile(); |
182 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 182 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
183 | mWriteBackInFuture = 0; | 183 | mWriteBackInFuture = 0; |
184 | if ( temp->getWriteBackFuture() ) | 184 | if ( temp->getWriteBackFuture() ) |
@@ -287,48 +287,48 @@ void KSyncManager::enableQuick() | |||
287 | if ( !mServerSocket->ok() ) { | 287 | if ( !mServerSocket->ok() ) { |
288 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); | 288 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); |
289 | delete mServerSocket; | 289 | delete mServerSocket; |
290 | mServerSocket = 0; | 290 | mServerSocket = 0; |
291 | return; | 291 | return; |
292 | } | 292 | } |
293 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 293 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
294 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 294 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
295 | } | 295 | } |
296 | 296 | ||
297 | void KSyncManager::syncLocalFile() | 297 | void KSyncManager::syncLocalFile() |
298 | { | 298 | { |
299 | 299 | ||
300 | QString fn =mPrefs->mLastSyncedLocalFile; | 300 | QString fn =mPrefs->mLastSyncedLocalFile; |
301 | QString ext; | 301 | QString ext; |
302 | 302 | ||
303 | switch(mTargetApp) | 303 | switch(mTargetApp) |
304 | { | 304 | { |
305 | case (KAPI): | 305 | case (KAPI): |
306 | ext = "(*.vcf)"; | 306 | ext = "(*.vcf)"; |
307 | break; | 307 | break; |
308 | case (KOPI): | 308 | case (KOPI): |
309 | ext = "(*.ics/*.vcs)"; | 309 | ext = "(*.ics/*.vcs)"; |
310 | break; | 310 | break; |
311 | case (PWMPI): | 311 | case (PWMPI): |
312 | ext = "(*.pwm)"; | 312 | ext = "(*.pwm)"; |
313 | break; | 313 | break; |
314 | default: | 314 | default: |
315 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); | 315 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); |
316 | break; | 316 | break; |
317 | 317 | ||
318 | } | 318 | } |
319 | 319 | ||
320 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 320 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
321 | if ( fn == "" ) | 321 | if ( fn == "" ) |
322 | return; | 322 | return; |
323 | if ( syncWithFile( fn, false ) ) { | 323 | if ( syncWithFile( fn, false ) ) { |
324 | qDebug("syncLocalFile() successful "); | 324 | qDebug("syncLocalFile() successful "); |
325 | } | 325 | } |
326 | 326 | ||
327 | } | 327 | } |
328 | 328 | ||
329 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 329 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
330 | { | 330 | { |
331 | bool ret = false; | 331 | bool ret = false; |
332 | QFileInfo info; | 332 | QFileInfo info; |
333 | info.setFile( fn ); | 333 | info.setFile( fn ); |
334 | QString mess; | 334 | QString mess; |
@@ -377,33 +377,33 @@ void KSyncManager::multiSync( bool askforPrefs ) | |||
377 | if (blockSave()) | 377 | if (blockSave()) |
378 | return; | 378 | return; |
379 | setBlockSave(true); | 379 | setBlockSave(true); |
380 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 380 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
381 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 381 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
382 | question, | 382 | question, |
383 | i18n("Yes"), i18n("No"), | 383 | i18n("Yes"), i18n("No"), |
384 | 0, 0 ) != 0 ) { | 384 | 0, 0 ) != 0 ) { |
385 | setBlockSave(false); | 385 | setBlockSave(false); |
386 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 386 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
387 | return; | 387 | return; |
388 | } | 388 | } |
389 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 389 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
390 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 390 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
391 | if ( askforPrefs ) { | 391 | if ( askforPrefs ) { |
392 | edit_sync_options(); | 392 | edit_sync_options(); |
393 | mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 393 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
394 | } | 394 | } |
395 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 395 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
396 | qApp->processEvents(); | 396 | qApp->processEvents(); |
397 | int num = ringSync() ; | 397 | int num = ringSync() ; |
398 | if ( num > 1 ) | 398 | if ( num > 1 ) |
399 | ringSync(); | 399 | ringSync(); |
400 | setBlockSave(false); | 400 | setBlockSave(false); |
401 | if ( num ) | 401 | if ( num ) |
402 | emit save(); | 402 | emit save(); |
403 | if ( num ) | 403 | if ( num ) |
404 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 404 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
405 | else | 405 | else |
406 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 406 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
407 | return; | 407 | return; |
408 | } | 408 | } |
409 | 409 | ||
@@ -507,38 +507,38 @@ int KSyncManager::ringSync() | |||
507 | #ifndef _WIN32_ | 507 | #ifndef _WIN32_ |
508 | sleep (1); | 508 | sleep (1); |
509 | #endif | 509 | #endif |
510 | } | 510 | } |
511 | 511 | ||
512 | } | 512 | } |
513 | 513 | ||
514 | } | 514 | } |
515 | delete temp; | 515 | delete temp; |
516 | return syncedProfiles; | 516 | return syncedProfiles; |
517 | } | 517 | } |
518 | 518 | ||
519 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 519 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
520 | { | 520 | { |
521 | QString question; | 521 | QString question; |
522 | if ( ask ) { | 522 | if ( ask ) { |
523 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 523 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
524 | if ( QMessageBox::information( mParent, i18n("Sync"), | 524 | if ( QMessageBox::information( mParent, i18n("Sync"), |
525 | question, | 525 | question, |
526 | i18n("Yes"), i18n("No"), | 526 | i18n("Yes"), i18n("No"), |
527 | 0, 0 ) != 0 ) | 527 | 0, 0 ) != 0 ) |
528 | return; | 528 | return; |
529 | } | 529 | } |
530 | 530 | ||
531 | QString preCommand; | 531 | QString preCommand; |
532 | QString localTempFile; | 532 | QString localTempFile; |
533 | QString postCommand; | 533 | QString postCommand; |
534 | 534 | ||
535 | switch(mTargetApp) | 535 | switch(mTargetApp) |
536 | { | 536 | { |
537 | case (KAPI): | 537 | case (KAPI): |
538 | preCommand = prof->getPreSyncCommandAB(); | 538 | preCommand = prof->getPreSyncCommandAB(); |
539 | postCommand = prof->getPostSyncCommandAB(); | 539 | postCommand = prof->getPostSyncCommandAB(); |
540 | localTempFile = prof->getLocalTempFileAB(); | 540 | localTempFile = prof->getLocalTempFileAB(); |
541 | break; | 541 | break; |
542 | case (KOPI): | 542 | case (KOPI): |
543 | preCommand = prof->getPreSyncCommand(); | 543 | preCommand = prof->getPreSyncCommand(); |
544 | postCommand = prof->getPostSyncCommand(); | 544 | postCommand = prof->getPostSyncCommand(); |
@@ -726,51 +726,51 @@ bool KSyncManager::syncExternalApplication(QString resource) | |||
726 | 726 | ||
727 | bool syncOK = mImplementation->syncExternal(this, resource); | 727 | bool syncOK = mImplementation->syncExternal(this, resource); |
728 | 728 | ||
729 | return syncOK; | 729 | return syncOK; |
730 | 730 | ||
731 | } | 731 | } |
732 | 732 | ||
733 | void KSyncManager::syncPhone() | 733 | void KSyncManager::syncPhone() |
734 | { | 734 | { |
735 | 735 | ||
736 | syncExternalApplication("phone"); | 736 | syncExternalApplication("phone"); |
737 | 737 | ||
738 | } | 738 | } |
739 | 739 | ||
740 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 740 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
741 | { | 741 | { |
742 | if (!bar->isVisible()) | 742 | if (!bar->isVisible()) |
743 | { | 743 | { |
744 | bar->setCaption (caption); | 744 | bar->setCaption (caption); |
745 | bar->setTotalSteps ( total ) ; | 745 | bar->setTotalSteps ( total ) ; |
746 | 746 | ||
747 | bar->show(); | 747 | bar->show(); |
748 | } | 748 | } |
749 | 749 | ||
750 | bar->setProgress( percentage ); | 750 | bar->setProgress( percentage ); |
751 | } | 751 | } |
752 | 752 | ||
753 | void KSyncManager::hideProgressBar() | 753 | void KSyncManager::hideProgressBar() |
754 | { | 754 | { |
755 | bar->hide(); | 755 | bar->hide(); |
756 | } | 756 | } |
757 | 757 | ||
758 | bool KSyncManager::isProgressBarCanceled() | 758 | bool KSyncManager::isProgressBarCanceled() |
759 | { | 759 | { |
760 | return !bar->isVisible(); | 760 | return !bar->isVisible(); |
761 | } | 761 | } |
762 | 762 | ||
763 | QString KSyncManager::syncFileName() | 763 | QString KSyncManager::syncFileName() |
764 | { | 764 | { |
765 | 765 | ||
766 | QString fn = "tempfile"; | 766 | QString fn = "tempfile"; |
767 | switch(mTargetApp) | 767 | switch(mTargetApp) |
768 | { | 768 | { |
769 | case (KAPI): | 769 | case (KAPI): |
770 | fn = "tempsyncab.vcf"; | 770 | fn = "tempsyncab.vcf"; |
771 | break; | 771 | break; |
772 | case (KOPI): | 772 | case (KOPI): |
773 | fn = "tempsynccal.ics"; | 773 | fn = "tempsynccal.ics"; |
774 | break; | 774 | break; |
775 | case (PWMPI): | 775 | case (PWMPI): |
776 | fn = "tempsyncpw.pwm"; | 776 | fn = "tempsyncpw.pwm"; |
@@ -794,49 +794,49 @@ void KSyncManager::syncPi() | |||
794 | if ( ! ok ) { | 794 | if ( ! ok ) { |
795 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 795 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
796 | return; | 796 | return; |
797 | } | 797 | } |
798 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); | 798 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); |
799 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 799 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
800 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); | 800 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); |
801 | commandSocket->readFile( syncFileName() ); | 801 | commandSocket->readFile( syncFileName() ); |
802 | } | 802 | } |
803 | 803 | ||
804 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 804 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
805 | { | 805 | { |
806 | qDebug("MainWindow::deleteCommandSocket %d", state); | 806 | qDebug("MainWindow::deleteCommandSocket %d", state); |
807 | 807 | ||
808 | //enum { success, errorW, errorR, quiet }; | 808 | //enum { success, errorW, errorR, quiet }; |
809 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { | 809 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { |
810 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 810 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
811 | delete s; | 811 | delete s; |
812 | if ( state == KCommandSocket::errorR ) { | 812 | if ( state == KCommandSocket::errorR ) { |
813 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 813 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
814 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 814 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
815 | commandSocket->sendStop(); | 815 | commandSocket->sendStop(); |
816 | } | 816 | } |
817 | return; | 817 | return; |
818 | 818 | ||
819 | } else if ( state == KCommandSocket::errorW ) { | 819 | } else if ( state == KCommandSocket::errorW ) { |
820 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 820 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
821 | 821 | ||
822 | } else if ( state == KCommandSocket::successR ) { | 822 | } else if ( state == KCommandSocket::successR ) { |
823 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 823 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
824 | 824 | ||
825 | } else if ( state == KCommandSocket::successW ) { | 825 | } else if ( state == KCommandSocket::successW ) { |
826 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 826 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
827 | } | 827 | } |
828 | 828 | ||
829 | delete s; | 829 | delete s; |
830 | } | 830 | } |
831 | 831 | ||
832 | void KSyncManager::readFileFromSocket() | 832 | void KSyncManager::readFileFromSocket() |
833 | { | 833 | { |
834 | QString fileName = syncFileName(); | 834 | QString fileName = syncFileName(); |
835 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 835 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
836 | if ( ! syncWithFile( fileName , true ) ) { | 836 | if ( ! syncWithFile( fileName , true ) ) { |
837 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 837 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
838 | qDebug("Syncing failed "); | 838 | qDebug("Syncing failed "); |
839 | return; | 839 | return; |
840 | } | 840 | } |
841 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 841 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
842 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 842 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
@@ -1143,32 +1143,32 @@ void KCommandSocket::readFileFromSocket() | |||
1143 | QTextStream ts ( &file ); | 1143 | QTextStream ts ( &file ); |
1144 | ts.setEncoding( QTextStream::Latin1 ); | 1144 | ts.setEncoding( QTextStream::Latin1 ); |
1145 | ts << mFileString; | 1145 | ts << mFileString; |
1146 | file.close(); | 1146 | file.close(); |
1147 | mFileString = ""; | 1147 | mFileString = ""; |
1148 | mRetVal = successR; | 1148 | mRetVal = successR; |
1149 | mSocket->close(); | 1149 | mSocket->close(); |
1150 | // if state is not idle, deleteSocket(); is called via | 1150 | // if state is not idle, deleteSocket(); is called via |
1151 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1151 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1152 | if ( mSocket->state() == QSocket::Idle ) | 1152 | if ( mSocket->state() == QSocket::Idle ) |
1153 | deleteSocket(); | 1153 | deleteSocket(); |
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | void KCommandSocket::deleteSocket() | 1156 | void KCommandSocket::deleteSocket() |
1157 | { | 1157 | { |
1158 | if ( mTimerSocket->isActive () ) { | 1158 | if ( mTimerSocket->isActive () ) { |
1159 | mTimerSocket->stop(); | 1159 | mTimerSocket->stop(); |
1160 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | 1160 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); |
1161 | mRetVal = errorTO; | 1161 | mRetVal = errorTO; |
1162 | if ( mSocket ) { | 1162 | if ( mSocket ) { |
1163 | mSocket->close(); | 1163 | mSocket->close(); |
1164 | if ( mSocket->state() == QSocket::Idle ) | 1164 | if ( mSocket->state() == QSocket::Idle ) |
1165 | deleteSocket(); | 1165 | deleteSocket(); |
1166 | return; | 1166 | return; |
1167 | } | 1167 | } |
1168 | } | 1168 | } |
1169 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 1169 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
1170 | if ( mSocket) | 1170 | if ( mSocket) |
1171 | delete mSocket; | 1171 | delete mSocket; |
1172 | mSocket = 0; | 1172 | mSocket = 0; |
1173 | emit commandFinished( this, mRetVal ); | 1173 | emit commandFinished( this, mRetVal ); |
1174 | } | 1174 | } |