-rw-r--r-- | libkdepim/ksyncmanager.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 7ee56e4..c6e06f8 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -133,33 +133,33 @@ void KSyncManager::fillSyncMenu() | |||
133 | } | 133 | } |
134 | QDir app_dir; | 134 | QDir app_dir; |
135 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 135 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
136 | if ( mTargetApp == PWMPI) { | 136 | if ( mTargetApp == PWMPI) { |
137 | mSyncMenu->removeItem( 1000 ); | 137 | mSyncMenu->removeItem( 1000 ); |
138 | } | 138 | } |
139 | #ifndef DESKTOP_VERSION | 139 | #ifndef DESKTOP_VERSION |
140 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 140 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
141 | mSyncMenu->removeItem( 1000 ); | 141 | mSyncMenu->removeItem( 1000 ); |
142 | } | 142 | } |
143 | #endif | 143 | #endif |
144 | mSyncMenu->removeItem( 1002 ); | 144 | mSyncMenu->removeItem( 1002 ); |
145 | } | 145 | } |
146 | 146 | ||
147 | void KSyncManager::slotSyncMenu( int action ) | 147 | void KSyncManager::slotSyncMenu( int action ) |
148 | { | 148 | { |
149 | //qDebug("syncaction %d ", action); | 149 | qDebug("syncaction %d ", action); |
150 | if ( action == 0 ) { | 150 | if ( action == 0 ) { |
151 | 151 | ||
152 | // seems to be a Qt2 event handling bug | 152 | // seems to be a Qt2 event handling bug |
153 | // syncmenu.clear causes a segfault at first time | 153 | // syncmenu.clear causes a segfault at first time |
154 | // when we call it after the main event loop, it is ok | 154 | // when we call it after the main event loop, it is ok |
155 | // same behaviour when calling OM/Pi via QCOP for the first time | 155 | // same behaviour when calling OM/Pi via QCOP for the first time |
156 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 156 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
157 | //confSync(); | 157 | //confSync(); |
158 | 158 | ||
159 | return; | 159 | return; |
160 | } | 160 | } |
161 | if ( action == 1 ) { | 161 | if ( action == 1 ) { |
162 | multiSync( true ); | 162 | multiSync( true ); |
163 | return; | 163 | return; |
164 | } | 164 | } |
165 | if ( action == 2 ) { | 165 | if ( action == 2 ) { |
@@ -241,32 +241,36 @@ void KSyncManager::slotSyncMenu( int action ) | |||
241 | syncPhone(); | 241 | syncPhone(); |
242 | } else if ( temp->getIsPiSync() ) { | 242 | } else if ( temp->getIsPiSync() ) { |
243 | if ( mTargetApp == KAPI ) { | 243 | if ( mTargetApp == KAPI ) { |
244 | mPassWordPiSync = temp->getRemotePwAB(); | 244 | mPassWordPiSync = temp->getRemotePwAB(); |
245 | mActiveSyncPort = temp->getRemotePortAB(); | 245 | mActiveSyncPort = temp->getRemotePortAB(); |
246 | mActiveSyncIP = temp->getRemoteIPAB(); | 246 | mActiveSyncIP = temp->getRemoteIPAB(); |
247 | } else if ( mTargetApp == KOPI ) { | 247 | } else if ( mTargetApp == KOPI ) { |
248 | mPassWordPiSync = temp->getRemotePw(); | 248 | mPassWordPiSync = temp->getRemotePw(); |
249 | mActiveSyncPort = temp->getRemotePort(); | 249 | mActiveSyncPort = temp->getRemotePort(); |
250 | mActiveSyncIP = temp->getRemoteIP(); | 250 | mActiveSyncIP = temp->getRemoteIP(); |
251 | } else { | 251 | } else { |
252 | mPassWordPiSync = temp->getRemotePwPWM(); | 252 | mPassWordPiSync = temp->getRemotePwPWM(); |
253 | mActiveSyncPort = temp->getRemotePortPWM(); | 253 | mActiveSyncPort = temp->getRemotePortPWM(); |
254 | mActiveSyncIP = temp->getRemoteIPPWM(); | 254 | mActiveSyncIP = temp->getRemoteIPPWM(); |
255 | } | 255 | } |
256 | syncPi(); | 256 | syncPi(); |
257 | while ( !mPisyncFinished ) { | ||
258 | //qDebug("waiting "); | ||
259 | qApp->processEvents(); | ||
260 | } | ||
257 | } else | 261 | } else |
258 | syncRemote( temp ); | 262 | syncRemote( temp ); |
259 | 263 | ||
260 | } | 264 | } |
261 | } | 265 | } |
262 | delete temp; | 266 | delete temp; |
263 | setBlockSave(false); | 267 | setBlockSave(false); |
264 | } | 268 | } |
265 | 269 | ||
266 | void KSyncManager::enableQuick() | 270 | void KSyncManager::enableQuick() |
267 | { | 271 | { |
268 | QDialog dia ( 0, "input-dialog", true ); | 272 | QDialog dia ( 0, "input-dialog", true ); |
269 | QLineEdit lab ( &dia ); | 273 | QLineEdit lab ( &dia ); |
270 | QVBoxLayout lay( &dia ); | 274 | QVBoxLayout lay( &dia ); |
271 | lab.setText( mPrefs->mPassiveSyncPort ); | 275 | lab.setText( mPrefs->mPassiveSyncPort ); |
272 | lay.setMargin(7); | 276 | lay.setMargin(7); |
@@ -459,33 +463,37 @@ int KSyncManager::ringSync() | |||
459 | } | 463 | } |
460 | 464 | ||
461 | 465 | ||
462 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 466 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
463 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 467 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
464 | ++syncedProfiles; | 468 | ++syncedProfiles; |
465 | // mAskForPreferences = temp->getAskForPreferences(); | 469 | // mAskForPreferences = temp->getAskForPreferences(); |
466 | mWriteBackFile = temp->getWriteBackFile(); | 470 | mWriteBackFile = temp->getWriteBackFile(); |
467 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 471 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
468 | mWriteBackInFuture = 0; | 472 | mWriteBackInFuture = 0; |
469 | if ( temp->getWriteBackFuture() ) | 473 | if ( temp->getWriteBackFuture() ) |
470 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 474 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
471 | mShowSyncSummary = false; | 475 | mShowSyncSummary = false; |
472 | mCurrentSyncDevice = syncProfileNames[i] ; | 476 | mCurrentSyncDevice = syncProfileNames[i] ; |
473 | mCurrentSyncName = mLocalMachineName; | 477 | mCurrentSyncName = mLocalMachineName; |
474 | if ( i == 0 ) { | 478 | if ( i == 0 ) { |
479 | #ifdef DESKTOP_VERSION | ||
480 | syncKDE(); | ||
481 | #else | ||
475 | syncSharp(); | 482 | syncSharp(); |
483 | #endif | ||
476 | } else { | 484 | } else { |
477 | if ( temp->getIsLocalFileSync() ) { | 485 | if ( temp->getIsLocalFileSync() ) { |
478 | switch(mTargetApp) | 486 | switch(mTargetApp) |
479 | { | 487 | { |
480 | case (KAPI): | 488 | case (KAPI): |
481 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 489 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
482 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 490 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
483 | break; | 491 | break; |
484 | case (KOPI): | 492 | case (KOPI): |
485 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 493 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
486 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 494 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
487 | break; | 495 | break; |
488 | case (PWMPI): | 496 | case (PWMPI): |
489 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 497 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
490 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 498 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
491 | break; | 499 | break; |
@@ -501,32 +509,40 @@ int KSyncManager::ringSync() | |||
501 | syncPhone(); | 509 | syncPhone(); |
502 | } else if ( temp->getIsPiSync() ) { | 510 | } else if ( temp->getIsPiSync() ) { |
503 | if ( mTargetApp == KAPI ) { | 511 | if ( mTargetApp == KAPI ) { |
504 | mPassWordPiSync = temp->getRemotePwAB(); | 512 | mPassWordPiSync = temp->getRemotePwAB(); |
505 | mActiveSyncPort = temp->getRemotePortAB(); | 513 | mActiveSyncPort = temp->getRemotePortAB(); |
506 | mActiveSyncIP = temp->getRemoteIPAB(); | 514 | mActiveSyncIP = temp->getRemoteIPAB(); |
507 | } else if ( mTargetApp == KOPI ) { | 515 | } else if ( mTargetApp == KOPI ) { |
508 | mPassWordPiSync = temp->getRemotePw(); | 516 | mPassWordPiSync = temp->getRemotePw(); |
509 | mActiveSyncPort = temp->getRemotePort(); | 517 | mActiveSyncPort = temp->getRemotePort(); |
510 | mActiveSyncIP = temp->getRemoteIP(); | 518 | mActiveSyncIP = temp->getRemoteIP(); |
511 | } else { | 519 | } else { |
512 | mPassWordPiSync = temp->getRemotePwPWM(); | 520 | mPassWordPiSync = temp->getRemotePwPWM(); |
513 | mActiveSyncPort = temp->getRemotePortPWM(); | 521 | mActiveSyncPort = temp->getRemotePortPWM(); |
514 | mActiveSyncIP = temp->getRemoteIPPWM(); | 522 | mActiveSyncIP = temp->getRemoteIPPWM(); |
515 | } | 523 | } |
516 | syncPi(); | 524 | syncPi(); |
525 | while ( !mPisyncFinished ) { | ||
526 | //qDebug("waiting "); | ||
527 | qApp->processEvents(); | ||
528 | } | ||
529 | timer.start(); | ||
530 | while ( timer.elapsed () < 2000 ) { | ||
531 | qApp->processEvents(); | ||
532 | } | ||
517 | } else | 533 | } else |
518 | syncRemote( temp, false ); | 534 | syncRemote( temp, false ); |
519 | 535 | ||
520 | } | 536 | } |
521 | } | 537 | } |
522 | timer.start(); | 538 | timer.start(); |
523 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 539 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
524 | while ( timer.elapsed () < 2000 ) { | 540 | while ( timer.elapsed () < 2000 ) { |
525 | qApp->processEvents(); | 541 | qApp->processEvents(); |
526 | #ifndef _WIN32_ | 542 | #ifndef _WIN32_ |
527 | sleep (1); | 543 | sleep (1); |
528 | #endif | 544 | #endif |
529 | } | 545 | } |
530 | 546 | ||
531 | } | 547 | } |
532 | 548 | ||
@@ -853,88 +869,94 @@ QString KSyncManager::syncFileName() | |||
853 | break; | 869 | break; |
854 | case (PWMPI): | 870 | case (PWMPI): |
855 | fn = "tempsyncpw.pwm"; | 871 | fn = "tempsyncpw.pwm"; |
856 | break; | 872 | break; |
857 | default: | 873 | default: |
858 | break; | 874 | break; |
859 | } | 875 | } |
860 | #ifdef _WIN32_ | 876 | #ifdef _WIN32_ |
861 | return locateLocal( "tmp", fn ); | 877 | return locateLocal( "tmp", fn ); |
862 | #else | 878 | #else |
863 | return (QString( "/tmp/" )+ fn ); | 879 | return (QString( "/tmp/" )+ fn ); |
864 | #endif | 880 | #endif |
865 | } | 881 | } |
866 | 882 | ||
867 | void KSyncManager::syncPi() | 883 | void KSyncManager::syncPi() |
868 | { | 884 | { |
885 | mPisyncFinished = false; | ||
869 | qApp->processEvents(); | 886 | qApp->processEvents(); |
870 | if ( mAskForPreferences ) | 887 | if ( mAskForPreferences ) |
871 | edit_pisync_options(); | 888 | edit_pisync_options(); |
872 | bool ok; | 889 | bool ok; |
873 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 890 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
874 | if ( ! ok ) { | 891 | if ( ! ok ) { |
875 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 892 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
876 | return; | 893 | return; |
877 | } | 894 | } |
878 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); | 895 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); |
879 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 896 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
880 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); | 897 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); |
881 | commandSocket->readFile( syncFileName() ); | 898 | commandSocket->readFile( syncFileName() ); |
882 | } | 899 | } |
883 | 900 | ||
884 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 901 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
885 | { | 902 | { |
886 | //enum { success, errorW, errorR, quiet }; | 903 | //enum { success, errorW, errorR, quiet }; |
887 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { | 904 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { |
888 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 905 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
889 | delete s; | 906 | delete s; |
890 | if ( state == KCommandSocket::errorR ) { | 907 | if ( state == KCommandSocket::errorR ) { |
891 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 908 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
892 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 909 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
893 | commandSocket->sendStop(); | 910 | commandSocket->sendStop(); |
894 | } | 911 | } |
912 | mPisyncFinished = true; | ||
895 | return; | 913 | return; |
896 | 914 | ||
897 | } else if ( state == KCommandSocket::errorW ) { | 915 | } else if ( state == KCommandSocket::errorW ) { |
898 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 916 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
917 | mPisyncFinished = true; | ||
899 | 918 | ||
900 | } else if ( state == KCommandSocket::successR ) { | 919 | } else if ( state == KCommandSocket::successR ) { |
901 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 920 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
902 | 921 | ||
903 | } else if ( state == KCommandSocket::successW ) { | 922 | } else if ( state == KCommandSocket::successW ) { |
904 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 923 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
924 | mPisyncFinished = true; | ||
905 | } | 925 | } |
906 | 926 | ||
907 | delete s; | 927 | delete s; |
908 | } | 928 | } |
909 | 929 | ||
910 | void KSyncManager::readFileFromSocket() | 930 | void KSyncManager::readFileFromSocket() |
911 | { | 931 | { |
912 | QString fileName = syncFileName(); | 932 | QString fileName = syncFileName(); |
913 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 933 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
914 | if ( ! syncWithFile( fileName , true ) ) { | 934 | if ( ! syncWithFile( fileName , true ) ) { |
915 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 935 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
936 | mPisyncFinished = true; | ||
916 | return; | 937 | return; |
917 | } | 938 | } |
918 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 939 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
919 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 940 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
920 | if ( mWriteBackFile ) | 941 | if ( mWriteBackFile ) |
921 | commandSocket->writeFile( fileName ); | 942 | commandSocket->writeFile( fileName ); |
922 | else { | 943 | else { |
923 | commandSocket->sendStop(); | 944 | commandSocket->sendStop(); |
924 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 945 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
946 | mPisyncFinished = true; | ||
925 | } | 947 | } |
926 | } | 948 | } |
927 | 949 | ||
928 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 950 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
929 | { | 951 | { |
930 | mPassWord = pw; | 952 | mPassWord = pw; |
931 | mSocket = 0; | 953 | mSocket = 0; |
932 | mSyncActionDialog = 0; | 954 | mSyncActionDialog = 0; |
933 | blockRC = false; | 955 | blockRC = false; |
934 | }; | 956 | }; |
935 | 957 | ||
936 | void KServerSocket::newConnection ( int socket ) | 958 | void KServerSocket::newConnection ( int socket ) |
937 | { | 959 | { |
938 | // qDebug("KServerSocket:New connection %d ", socket); | 960 | // qDebug("KServerSocket:New connection %d ", socket); |
939 | if ( mSocket ) { | 961 | if ( mSocket ) { |
940 | qDebug("KServerSocket::newConnection Socket deleted! "); | 962 | qDebug("KServerSocket::newConnection Socket deleted! "); |