-rw-r--r-- | libkdepim/ksyncmanager.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 28c48fe..4d859ce 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -296,257 +296,256 @@ void KSyncManager::slotSyncMenu( int action ) | |||
296 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 296 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
297 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 297 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
298 | break; | 298 | break; |
299 | case (KOPI): | 299 | case (KOPI): |
300 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 300 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
301 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 301 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
302 | break; | 302 | break; |
303 | case (PWMPI): | 303 | case (PWMPI): |
304 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 304 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
305 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 305 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
306 | break; | 306 | break; |
307 | default: | 307 | default: |
308 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); | 308 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); |
309 | break; | 309 | break; |
310 | 310 | ||
311 | } | 311 | } |
312 | } else { | 312 | } else { |
313 | if ( temp->getIsPhoneSync() ) { | 313 | if ( temp->getIsPhoneSync() ) { |
314 | mPhoneDevice = temp->getPhoneDevice( ) ; | 314 | mPhoneDevice = temp->getPhoneDevice( ) ; |
315 | mPhoneConnection = temp->getPhoneConnection( ); | 315 | mPhoneConnection = temp->getPhoneConnection( ); |
316 | mPhoneModel = temp->getPhoneModel( ); | 316 | mPhoneModel = temp->getPhoneModel( ); |
317 | syncPhone(); | 317 | syncPhone(); |
318 | } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) { | 318 | } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) { |
319 | mSpecificResources.clear(); | 319 | mSpecificResources.clear(); |
320 | if ( mTargetApp == KAPI ) { | 320 | if ( mTargetApp == KAPI ) { |
321 | mPassWordPiSync = temp->getRemotePwAB(); | 321 | mPassWordPiSync = temp->getRemotePwAB(); |
322 | mActiveSyncPort = temp->getRemotePortAB(); | 322 | mActiveSyncPort = temp->getRemotePortAB(); |
323 | mActiveSyncIP = temp->getRemoteIPAB(); | 323 | mActiveSyncIP = temp->getRemoteIPAB(); |
324 | } else if ( mTargetApp == KOPI ) { | 324 | } else if ( mTargetApp == KOPI ) { |
325 | if ( temp->getIsPiSyncSpec() ) | 325 | if ( temp->getIsPiSyncSpec() ) |
326 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); | 326 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); |
327 | mPassWordPiSync = temp->getRemotePw(); | 327 | mPassWordPiSync = temp->getRemotePw(); |
328 | mActiveSyncPort = temp->getRemotePort(); | 328 | mActiveSyncPort = temp->getRemotePort(); |
329 | mActiveSyncIP = temp->getRemoteIP(); | 329 | mActiveSyncIP = temp->getRemoteIP(); |
330 | } else { | 330 | } else { |
331 | mPassWordPiSync = temp->getRemotePwPWM(); | 331 | mPassWordPiSync = temp->getRemotePwPWM(); |
332 | mActiveSyncPort = temp->getRemotePortPWM(); | 332 | mActiveSyncPort = temp->getRemotePortPWM(); |
333 | mActiveSyncIP = temp->getRemoteIPPWM(); | 333 | mActiveSyncIP = temp->getRemoteIPPWM(); |
334 | } | 334 | } |
335 | syncPi(); | 335 | syncPi(); |
336 | while ( !mPisyncFinished ) { | 336 | while ( !mPisyncFinished ) { |
337 | //qDebug("waiting "); | 337 | //qDebug("waiting "); |
338 | qApp->processEvents(); | 338 | qApp->processEvents(); |
339 | } | 339 | } |
340 | } else | 340 | } else |
341 | syncRemote( temp ); | 341 | syncRemote( temp ); |
342 | 342 | ||
343 | } | 343 | } |
344 | } | 344 | } |
345 | delete temp; | 345 | delete temp; |
346 | setBlockSave(false); | 346 | setBlockSave(false); |
347 | } | 347 | } |
348 | 348 | ||
349 | void KSyncManager::enableQuick( bool ask ) | 349 | void KSyncManager::enableQuick( bool ask ) |
350 | { | 350 | { |
351 | bool autoStart; | 351 | bool autoStart; |
352 | bool changed = false; | 352 | bool changed = false; |
353 | if ( ask ) { | 353 | if ( ask ) { |
354 | QDialog dia ( 0, "input-dialog", true ); | 354 | QDialog dia ( 0, "input-dialog", true ); |
355 | QLineEdit lab ( &dia ); | 355 | QLineEdit lab ( &dia ); |
356 | QVBoxLayout lay( &dia ); | 356 | QVBoxLayout lay( &dia ); |
357 | lab.setText( mPrefs->mPassiveSyncPort ); | 357 | lab.setText( mPrefs->mPassiveSyncPort ); |
358 | lay.setMargin(7); | 358 | lay.setMargin(7); |
359 | lay.setSpacing(7); | 359 | lay.setSpacing(7); |
360 | int po = 9197+mTargetApp; | 360 | int po = 9197+mTargetApp; |
361 | QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); | 361 | QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); |
362 | lay.addWidget( &label); | 362 | lay.addWidget( &label); |
363 | lay.addWidget( &lab); | 363 | lay.addWidget( &lab); |
364 | 364 | ||
365 | QLineEdit lepw ( &dia ); | 365 | QLineEdit lepw ( &dia ); |
366 | lepw.setText( mPrefs->mPassiveSyncPw ); | 366 | lepw.setText( mPrefs->mPassiveSyncPw ); |
367 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 367 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
368 | lay.addWidget( &label2); | 368 | lay.addWidget( &label2); |
369 | lay.addWidget( &lepw); | 369 | lay.addWidget( &lepw); |
370 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); | 370 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); |
371 | lay.addWidget( &autostart); | 371 | lay.addWidget( &autostart); |
372 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); | 372 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); |
373 | #ifdef DESKTOP_VERSION | 373 | #ifdef DESKTOP_VERSION |
374 | #ifdef _WIN32_ | 374 | #ifdef _WIN32_ |
375 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); | 375 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); |
376 | syncdesktop.hide();// not implemented! | 376 | syncdesktop.hide();// not implemented! |
377 | #else | 377 | #else |
378 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); | 378 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); |
379 | #endif | 379 | #endif |
380 | lay.addWidget( &syncdesktop); | 380 | lay.addWidget( &syncdesktop); |
381 | #else | 381 | #else |
382 | mPrefs->mPassiveSyncWithDesktop = false; | 382 | mPrefs->mPassiveSyncWithDesktop = false; |
383 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); | 383 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); |
384 | syncdesktop.hide(); | 384 | syncdesktop.hide(); |
385 | #endif | 385 | #endif |
386 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); | 386 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); |
387 | 387 | ||
388 | QPushButton pb ( "OK", &dia); | 388 | QPushButton pb ( "OK", &dia); |
389 | lay.addWidget( &pb ); | 389 | lay.addWidget( &pb ); |
390 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 390 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
391 | dia.resize( 230,120 ); | 391 | dia.resize( 230,120 ); |
392 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 392 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
393 | dia.show(); | 393 | dia.show(); |
394 | #ifndef DESKTOP_VERSION | 394 | #ifndef DESKTOP_VERSION |
395 | int dw = QApplication::desktop()->width(); | 395 | int dw = QApplication::desktop()->width(); |
396 | int dh = QApplication::desktop()->height(); | 396 | int dh = QApplication::desktop()->height(); |
397 | dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); | 397 | dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); |
398 | #endif | 398 | #endif |
399 | if ( ! dia.exec() ) | 399 | if ( ! dia.exec() ) |
400 | return; | 400 | return; |
401 | dia.hide(); | 401 | dia.hide(); |
402 | qApp->processEvents(); | 402 | qApp->processEvents(); |
403 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { | 403 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { |
404 | changed = true; | 404 | changed = true; |
405 | mPrefs->mPassiveSyncPw = lepw.text(); | 405 | mPrefs->mPassiveSyncPw = lepw.text(); |
406 | } | 406 | } |
407 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { | 407 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { |
408 | mPrefs->mPassiveSyncPort = lab.text(); | 408 | mPrefs->mPassiveSyncPort = lab.text(); |
409 | changed = true; | 409 | changed = true; |
410 | } | 410 | } |
411 | autoStart = autostart.isChecked(); | 411 | autoStart = autostart.isChecked(); |
412 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { | 412 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { |
413 | changed = true; | 413 | changed = true; |
414 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); | 414 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); |
415 | } | 415 | } |
416 | } | 416 | } |
417 | else | 417 | else |
418 | autoStart = mPrefs->mPassiveSyncAutoStart; | 418 | autoStart = mPrefs->mPassiveSyncAutoStart; |
419 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) | 419 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) |
420 | changed = true; | 420 | changed = true; |
421 | bool ok; | 421 | bool ok; |
422 | mPrefs->mPassiveSyncAutoStart = false; | 422 | mPrefs->mPassiveSyncAutoStart = false; |
423 | Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); | 423 | Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); |
424 | qDebug("%d ", port_t); | ||
425 | if ( ! ok || port_t > 65535 ) { | 424 | if ( ! ok || port_t > 65535 ) { |
426 | KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); | 425 | KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); |
427 | return; | 426 | return; |
428 | } | 427 | } |
429 | Q_UINT16 port = port_t; | 428 | Q_UINT16 port = port_t; |
430 | //qDebug("port %d ", port); | 429 | //qDebug("port %d ", port); |
431 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 430 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
432 | mServerSocket->setFileName( defaultFileName() );//bbb | 431 | mServerSocket->setFileName( defaultFileName() );//bbb |
433 | if ( !mServerSocket->ok() ) { | 432 | if ( !mServerSocket->ok() ) { |
434 | QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); | 433 | QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); |
435 | delete mServerSocket; | 434 | delete mServerSocket; |
436 | mServerSocket = 0; | 435 | mServerSocket = 0; |
437 | return; | 436 | return; |
438 | } | 437 | } |
439 | mPrefs->mPassiveSyncAutoStart = autoStart; | 438 | mPrefs->mPassiveSyncAutoStart = autoStart; |
440 | if ( changed ) { | 439 | if ( changed ) { |
441 | mPrefs->writeConfig(); | 440 | mPrefs->writeConfig(); |
442 | } | 441 | } |
443 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 442 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
444 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 443 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
445 | connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) ); | 444 | connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) ); |
446 | connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) ); | 445 | connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) ); |
447 | } | 446 | } |
448 | void KSyncManager::displayErrorPort() | 447 | void KSyncManager::displayErrorPort() |
449 | { | 448 | { |
450 | KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); | 449 | KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); |
451 | } | 450 | } |
452 | void KSyncManager::syncLocalFile() | 451 | void KSyncManager::syncLocalFile() |
453 | { | 452 | { |
454 | 453 | ||
455 | QString fn =mPrefs->mLastSyncedLocalFile; | 454 | QString fn =mPrefs->mLastSyncedLocalFile; |
456 | QString ext; | 455 | QString ext; |
457 | 456 | ||
458 | switch(mTargetApp) | 457 | switch(mTargetApp) |
459 | { | 458 | { |
460 | case (KAPI): | 459 | case (KAPI): |
461 | ext = "(*.vcf)"; | 460 | ext = "(*.vcf)"; |
462 | break; | 461 | break; |
463 | case (KOPI): | 462 | case (KOPI): |
464 | ext = "(*.ics/*.vcs)"; | 463 | ext = "(*.ics/*.vcs)"; |
465 | break; | 464 | break; |
466 | case (PWMPI): | 465 | case (PWMPI): |
467 | ext = "(*.pwm)"; | 466 | ext = "(*.pwm)"; |
468 | break; | 467 | break; |
469 | default: | 468 | default: |
470 | qDebug("KSM::syncLocalFile: invalid apptype selected"); | 469 | qDebug("KSM::syncLocalFile: invalid apptype selected"); |
471 | break; | 470 | break; |
472 | 471 | ||
473 | } | 472 | } |
474 | 473 | ||
475 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 474 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
476 | if ( fn == "" ) | 475 | if ( fn == "" ) |
477 | return; | 476 | return; |
478 | if ( syncWithFile( fn, false ) ) { | 477 | if ( syncWithFile( fn, false ) ) { |
479 | qDebug("KSM::syncLocalFile() successful "); | 478 | qDebug("KSM::syncLocalFile() successful "); |
480 | } | 479 | } |
481 | 480 | ||
482 | } | 481 | } |
483 | 482 | ||
484 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 483 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
485 | { | 484 | { |
486 | bool ret = false; | 485 | bool ret = false; |
487 | QFileInfo info; | 486 | QFileInfo info; |
488 | info.setFile( fn ); | 487 | info.setFile( fn ); |
489 | QString mess; | 488 | QString mess; |
490 | if ( !info. exists() ) { | 489 | if ( !info. exists() ) { |
491 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 490 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
492 | QMessageBox::warning( mParent, i18n("Warning!"), | 491 | QMessageBox::warning( mParent, i18n("Warning!"), |
493 | mess ); | 492 | mess ); |
494 | return ret; | 493 | return ret; |
495 | } | 494 | } |
496 | int result = 0; | 495 | int result = 0; |
497 | if ( !quick ) { | 496 | if ( !quick ) { |
498 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 497 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
499 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 498 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
500 | mess, | 499 | mess, |
501 | i18n("Sync"), i18n("Cancel"), 0, | 500 | i18n("Sync"), i18n("Cancel"), 0, |
502 | 0, 1 ); | 501 | 0, 1 ); |
503 | if ( result ) | 502 | if ( result ) |
504 | return false; | 503 | return false; |
505 | } | 504 | } |
506 | if ( mAskForPreferences ) | 505 | if ( mAskForPreferences ) |
507 | if ( !edit_sync_options()) { | 506 | if ( !edit_sync_options()) { |
508 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 507 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
509 | return false; | 508 | return false; |
510 | } | 509 | } |
511 | if ( result == 0 ) { | 510 | if ( result == 0 ) { |
512 | //qDebug("Now sycing ... "); | 511 | //qDebug("Now sycing ... "); |
513 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) ) | 512 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) ) |
514 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 513 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
515 | else | 514 | else |
516 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 515 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
517 | if ( ! quick ) | 516 | if ( ! quick ) |
518 | mPrefs->mLastSyncedLocalFile = fn; | 517 | mPrefs->mLastSyncedLocalFile = fn; |
519 | } | 518 | } |
520 | return ret; | 519 | return ret; |
521 | } | 520 | } |
522 | 521 | ||
523 | void KSyncManager::quickSyncLocalFile() | 522 | void KSyncManager::quickSyncLocalFile() |
524 | { | 523 | { |
525 | 524 | ||
526 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 525 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
527 | qDebug("KSM::quick syncLocalFile() successful "); | 526 | qDebug("KSM::quick syncLocalFile() successful "); |
528 | 527 | ||
529 | } | 528 | } |
530 | } | 529 | } |
531 | 530 | ||
532 | void KSyncManager::multiSync( bool askforPrefs ) | 531 | void KSyncManager::multiSync( bool askforPrefs ) |
533 | { | 532 | { |
534 | if (blockSave()) | 533 | if (blockSave()) |
535 | return; | 534 | return; |
536 | setBlockSave(true); | 535 | setBlockSave(true); |
537 | mCurrentResourceLocal = ""; | 536 | mCurrentResourceLocal = ""; |
538 | if ( askforPrefs ) { | 537 | if ( askforPrefs ) { |
539 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 538 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
540 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 539 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
541 | question, | 540 | question, |
542 | i18n("Yes"), i18n("No"), | 541 | i18n("Yes"), i18n("No"), |
543 | 0, 0 ) != 0 ) { | 542 | 0, 0 ) != 0 ) { |
544 | setBlockSave(false); | 543 | setBlockSave(false); |
545 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 544 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
546 | return; | 545 | return; |
547 | } | 546 | } |
548 | } | 547 | } |
549 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 548 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
550 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 549 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
551 | if ( askforPrefs ) { | 550 | if ( askforPrefs ) { |
552 | if ( !edit_sync_options()) { | 551 | if ( !edit_sync_options()) { |
@@ -1187,257 +1186,257 @@ void KSyncManager::syncPi() | |||
1187 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1186 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1188 | commandSocket->readFile( syncFileName() ); | 1187 | commandSocket->readFile( syncFileName() ); |
1189 | } | 1188 | } |
1190 | } | 1189 | } |
1191 | 1190 | ||
1192 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 1191 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
1193 | { | 1192 | { |
1194 | //enum { success, errorW, errorR, quiet }; | 1193 | //enum { success, errorW, errorR, quiet }; |
1195 | 1194 | ||
1196 | 1195 | ||
1197 | 1196 | ||
1198 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || | 1197 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || |
1199 | state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { | 1198 | state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { |
1200 | if ( state == KCommandSocket::errorPW ) | 1199 | if ( state == KCommandSocket::errorPW ) |
1201 | mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); | 1200 | mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); |
1202 | else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) | 1201 | else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) |
1203 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 1202 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
1204 | else if ( state == KCommandSocket::errorCA ) | 1203 | else if ( state == KCommandSocket::errorCA ) |
1205 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); | 1204 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); |
1206 | else if ( state == KCommandSocket::errorFI ) | 1205 | else if ( state == KCommandSocket::errorFI ) |
1207 | mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); | 1206 | mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); |
1208 | else if ( state == KCommandSocket::errorED ) | 1207 | else if ( state == KCommandSocket::errorED ) |
1209 | mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); | 1208 | mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); |
1210 | else if ( state == KCommandSocket::errorUN ) | 1209 | else if ( state == KCommandSocket::errorUN ) |
1211 | mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); | 1210 | mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); |
1212 | delete s; | 1211 | delete s; |
1213 | if ( state == KCommandSocket::errorR ) { | 1212 | if ( state == KCommandSocket::errorR ) { |
1214 | KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); | 1213 | KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); |
1215 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1214 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1216 | commandSocket->sendStop(); | 1215 | commandSocket->sendStop(); |
1217 | } | 1216 | } |
1218 | mPisyncFinished = true; | 1217 | mPisyncFinished = true; |
1219 | return; | 1218 | return; |
1220 | 1219 | ||
1221 | } else if ( state == KCommandSocket::errorW ) { | 1220 | } else if ( state == KCommandSocket::errorW ) { |
1222 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 1221 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
1223 | mPisyncFinished = true; | 1222 | mPisyncFinished = true; |
1224 | 1223 | ||
1225 | } else if ( state == KCommandSocket::successR ) { | 1224 | } else if ( state == KCommandSocket::successR ) { |
1226 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 1225 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
1227 | 1226 | ||
1228 | } else if ( state == KCommandSocket::successW ) { | 1227 | } else if ( state == KCommandSocket::successW ) { |
1229 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); | 1228 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); |
1230 | mPisyncFinished = true; | 1229 | mPisyncFinished = true; |
1231 | } else if ( state == KCommandSocket::quiet ){ | 1230 | } else if ( state == KCommandSocket::quiet ){ |
1232 | qDebug("KSS: quiet "); | 1231 | qDebug("KSS: quiet "); |
1233 | mPisyncFinished = true; | 1232 | mPisyncFinished = true; |
1234 | } else { | 1233 | } else { |
1235 | qDebug("KSS: Error: unknown state: %d ", state); | 1234 | qDebug("KSS: Error: unknown state: %d ", state); |
1236 | mPisyncFinished = true; | 1235 | mPisyncFinished = true; |
1237 | } | 1236 | } |
1238 | 1237 | ||
1239 | delete s; | 1238 | delete s; |
1240 | } | 1239 | } |
1241 | 1240 | ||
1242 | void KSyncManager::readFileFromSocket() | 1241 | void KSyncManager::readFileFromSocket() |
1243 | { | 1242 | { |
1244 | QString fileName = syncFileName(); | 1243 | QString fileName = syncFileName(); |
1245 | bool syncOK = true; | 1244 | bool syncOK = true; |
1246 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 1245 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
1247 | if ( ! syncWithFile( fileName , true ) ) { | 1246 | if ( ! syncWithFile( fileName , true ) ) { |
1248 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 1247 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
1249 | syncOK = false; | 1248 | syncOK = false; |
1250 | } | 1249 | } |
1251 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); | 1250 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); |
1252 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1251 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1253 | if ( mWriteBackFile && syncOK ) { | 1252 | if ( mWriteBackFile && syncOK ) { |
1254 | mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); | 1253 | mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); |
1255 | commandSocket->writeFile( fileName ); | 1254 | commandSocket->writeFile( fileName ); |
1256 | } | 1255 | } |
1257 | else { | 1256 | else { |
1258 | commandSocket->sendStop(); | 1257 | commandSocket->sendStop(); |
1259 | if ( syncOK ) | 1258 | if ( syncOK ) |
1260 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1259 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1261 | mPisyncFinished = true; | 1260 | mPisyncFinished = true; |
1262 | } | 1261 | } |
1263 | } | 1262 | } |
1264 | 1263 | ||
1265 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 1264 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
1266 | { | 1265 | { |
1267 | mPendingConnect = 0; | 1266 | mPendingConnect = 0; |
1268 | mPassWord = pw; | 1267 | mPassWord = pw; |
1269 | mSocket = 0; | 1268 | mSocket = 0; |
1270 | mSyncActionDialog = 0; | 1269 | mSyncActionDialog = 0; |
1271 | blockRC = false; | 1270 | blockRC = false; |
1272 | mErrorMessage = 0; | 1271 | mErrorMessage = 0; |
1273 | } | 1272 | } |
1274 | void KServerSocket::waitForSocketFinish() | 1273 | void KServerSocket::waitForSocketFinish() |
1275 | { | 1274 | { |
1276 | if ( mSocket ) { | 1275 | if ( mSocket ) { |
1277 | //qDebug("KSS:: waiting for finish operation"); | 1276 | //qDebug("KSS:: waiting for finish operation"); |
1278 | QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); | 1277 | QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); |
1279 | return; | 1278 | return; |
1280 | } | 1279 | } |
1281 | mSocket = new QSocket( this ); | 1280 | mSocket = new QSocket( this ); |
1282 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 1281 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
1283 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 1282 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
1284 | mSocket->setSocket( mPendingConnect ); | 1283 | mSocket->setSocket( mPendingConnect ); |
1285 | mPendingConnect = 0; | 1284 | mPendingConnect = 0; |
1286 | } | 1285 | } |
1287 | void KServerSocket::newConnection ( int socket ) | 1286 | void KServerSocket::newConnection ( int socket ) |
1288 | { | 1287 | { |
1289 | // qDebug("KServerSocket:New connection %d ", socket); | 1288 | // qDebug("KServerSocket:New connection %d ", socket); |
1290 | if ( mPendingConnect ) { | 1289 | if ( mPendingConnect ) { |
1291 | qDebug("KSS::Error : new Connection"); | 1290 | qDebug("KSS::Error : new Connection"); |
1292 | return; | 1291 | return; |
1293 | } | 1292 | } |
1294 | if ( mSocket ) { | 1293 | if ( mSocket ) { |
1295 | mPendingConnect = socket; | 1294 | mPendingConnect = socket; |
1296 | QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); | 1295 | QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); |
1297 | return; | 1296 | return; |
1298 | qDebug("KSS::newConnection Socket deleted! "); | 1297 | qDebug("KSS::newConnection Socket deleted! "); |
1299 | delete mSocket; | 1298 | delete mSocket; |
1300 | mSocket = 0; | 1299 | mSocket = 0; |
1301 | } | 1300 | } |
1302 | mPendingConnect = 0; | 1301 | mPendingConnect = 0; |
1303 | mSocket = new QSocket( this ); | 1302 | mSocket = new QSocket( this ); |
1304 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 1303 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
1305 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 1304 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
1306 | mSocket->setSocket( socket ); | 1305 | mSocket->setSocket( socket ); |
1307 | } | 1306 | } |
1308 | 1307 | ||
1309 | void KServerSocket::discardClient() | 1308 | void KServerSocket::discardClient() |
1310 | { | 1309 | { |
1311 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1310 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1312 | } | 1311 | } |
1313 | void KServerSocket::deleteSocket() | 1312 | void KServerSocket::deleteSocket() |
1314 | { | 1313 | { |
1315 | qDebug("KSS::deleteSocket"); | 1314 | //qDebug("KSS::deleteSocket"); |
1316 | if ( mSocket ) { | 1315 | if ( mSocket ) { |
1317 | delete mSocket; | 1316 | delete mSocket; |
1318 | mSocket = 0; | 1317 | mSocket = 0; |
1319 | } | 1318 | } |
1320 | if ( mErrorMessage ) | 1319 | if ( mErrorMessage ) |
1321 | QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); | 1320 | QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); |
1322 | } | 1321 | } |
1323 | void KServerSocket::readClient() | 1322 | void KServerSocket::readClient() |
1324 | { | 1323 | { |
1325 | if ( blockRC ) | 1324 | if ( blockRC ) |
1326 | return; | 1325 | return; |
1327 | if ( mSocket == 0 ) { | 1326 | if ( mSocket == 0 ) { |
1328 | qDebug("ERROR::KSS::readClient(): mSocket == 0 "); | 1327 | qDebug("ERROR::KSS::readClient(): mSocket == 0 "); |
1329 | return; | 1328 | return; |
1330 | } | 1329 | } |
1331 | if ( mErrorMessage ) { | 1330 | if ( mErrorMessage ) { |
1332 | mErrorMessage = 999; | 1331 | mErrorMessage = 999; |
1333 | error_connect("ERROR_ED\r\n\r\n"); | 1332 | error_connect("ERROR_ED\r\n\r\n"); |
1334 | return; | 1333 | return; |
1335 | } | 1334 | } |
1336 | mResource = ""; | 1335 | mResource = ""; |
1337 | mErrorMessage = 0; | 1336 | mErrorMessage = 0; |
1338 | //qDebug("KServerSocket::readClient()"); | 1337 | //qDebug("KServerSocket::readClient()"); |
1339 | if ( mSocket->canReadLine() ) { | 1338 | if ( mSocket->canReadLine() ) { |
1340 | QString line = mSocket->readLine(); | 1339 | QString line = mSocket->readLine(); |
1341 | //qDebug("KServerSocket readline: %s ", line.latin1()); | 1340 | //qDebug("KServerSocket readline: %s ", line.latin1()); |
1342 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 1341 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
1343 | if ( tokens[0] == "GET" ) { | 1342 | if ( tokens[0] == "GET" ) { |
1344 | if ( tokens[1] == mPassWord ) { | 1343 | if ( tokens[1] == mPassWord ) { |
1345 | //emit sendFile( mSocket ); | 1344 | //emit sendFile( mSocket ); |
1346 | bool ok = false; | 1345 | bool ok = false; |
1347 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); | 1346 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); |
1348 | if ( ok ) { | 1347 | if ( ok ) { |
1349 | KSyncManager::mRequestedSyncEvent = dt; | 1348 | KSyncManager::mRequestedSyncEvent = dt; |
1350 | } | 1349 | } |
1351 | else | 1350 | else |
1352 | KSyncManager::mRequestedSyncEvent = QDateTime(); | 1351 | KSyncManager::mRequestedSyncEvent = QDateTime(); |
1353 | mResource =tokens[3]; | 1352 | mResource =tokens[3]; |
1354 | send_file(); | 1353 | send_file(); |
1355 | } | 1354 | } |
1356 | else { | 1355 | else { |
1357 | mErrorMessage = 1; | 1356 | mErrorMessage = 1; |
1358 | error_connect("ERROR_PW\r\n\r\n"); | 1357 | error_connect("ERROR_PW\r\n\r\n"); |
1359 | } | 1358 | } |
1360 | } | 1359 | } |
1361 | if ( tokens[0] == "PUT" ) { | 1360 | if ( tokens[0] == "PUT" ) { |
1362 | if ( tokens[1] == mPassWord ) { | 1361 | if ( tokens[1] == mPassWord ) { |
1363 | //emit getFile( mSocket ); | 1362 | //emit getFile( mSocket ); |
1364 | blockRC = true; | 1363 | blockRC = true; |
1365 | mResource =tokens[2]; | 1364 | mResource =tokens[2]; |
1366 | get_file(); | 1365 | get_file(); |
1367 | } | 1366 | } |
1368 | else { | 1367 | else { |
1369 | mErrorMessage = 2; | 1368 | mErrorMessage = 2; |
1370 | error_connect("ERROR_PW\r\n\r\n"); | 1369 | error_connect("ERROR_PW\r\n\r\n"); |
1371 | end_connect(); | 1370 | end_connect(); |
1372 | } | 1371 | } |
1373 | } | 1372 | } |
1374 | if ( tokens[0] == "STOP" ) { | 1373 | if ( tokens[0] == "STOP" ) { |
1375 | //emit endConnect(); | 1374 | //emit endConnect(); |
1376 | end_connect(); | 1375 | end_connect(); |
1377 | } | 1376 | } |
1378 | } | 1377 | } |
1379 | } | 1378 | } |
1380 | void KServerSocket::displayErrorMessage() | 1379 | void KServerSocket::displayErrorMessage() |
1381 | { | 1380 | { |
1382 | if ( mErrorMessage == 1 ) { | 1381 | if ( mErrorMessage == 1 ) { |
1383 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); | 1382 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); |
1384 | mErrorMessage = 0; | 1383 | mErrorMessage = 0; |
1385 | } | 1384 | } |
1386 | else if ( mErrorMessage == 2 ) { | 1385 | else if ( mErrorMessage == 2 ) { |
1387 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); | 1386 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); |
1388 | mErrorMessage = 0; | 1387 | mErrorMessage = 0; |
1389 | } | 1388 | } |
1390 | } | 1389 | } |
1391 | void KServerSocket::error_connect( QString errmess ) | 1390 | void KServerSocket::error_connect( QString errmess ) |
1392 | { | 1391 | { |
1393 | QTextStream os( mSocket ); | 1392 | QTextStream os( mSocket ); |
1394 | os.setEncoding( QTextStream::Latin1 ); | 1393 | os.setEncoding( QTextStream::Latin1 ); |
1395 | os << errmess ; | 1394 | os << errmess ; |
1396 | mSocket->close(); | 1395 | mSocket->close(); |
1397 | if ( mSocket->state() == QSocket::Idle ) { | 1396 | if ( mSocket->state() == QSocket::Idle ) { |
1398 | QTimer::singleShot( 0, this , SLOT ( discardClient())); | 1397 | QTimer::singleShot( 0, this , SLOT ( discardClient())); |
1399 | } | 1398 | } |
1400 | } | 1399 | } |
1401 | void KServerSocket::end_connect() | 1400 | void KServerSocket::end_connect() |
1402 | { | 1401 | { |
1403 | delete mSyncActionDialog; | 1402 | delete mSyncActionDialog; |
1404 | mSyncActionDialog = 0; | 1403 | mSyncActionDialog = 0; |
1405 | } | 1404 | } |
1406 | void KServerSocket::send_file() | 1405 | void KServerSocket::send_file() |
1407 | { | 1406 | { |
1408 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 1407 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
1409 | if ( mSyncActionDialog ) | 1408 | if ( mSyncActionDialog ) |
1410 | delete mSyncActionDialog; | 1409 | delete mSyncActionDialog; |
1411 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 1410 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
1412 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 1411 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
1413 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 1412 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
1414 | label->setAlignment ( Qt::AlignHCenter ); | 1413 | label->setAlignment ( Qt::AlignHCenter ); |
1415 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 1414 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
1416 | lay->addWidget( label); | 1415 | lay->addWidget( label); |
1417 | lay->setMargin(7); | 1416 | lay->setMargin(7); |
1418 | lay->setSpacing(7); | 1417 | lay->setSpacing(7); |
1419 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1418 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1420 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); | 1419 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); |
1421 | //secs = 333; | 1420 | //secs = 333; |
1422 | if ( secs < 0 ) | 1421 | if ( secs < 0 ) |
1423 | secs = secs * (-1); | 1422 | secs = secs * (-1); |
1424 | if ( secs > 30 ) | 1423 | if ( secs > 30 ) |
1425 | //if ( true ) | 1424 | //if ( true ) |
1426 | { | 1425 | { |
1427 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); | 1426 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); |
1428 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1427 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1429 | label->setAlignment ( Qt::AlignHCenter ); | 1428 | label->setAlignment ( Qt::AlignHCenter ); |
1430 | lay->addWidget( label); | 1429 | lay->addWidget( label); |
1431 | if ( secs > 180 ) | 1430 | if ( secs > 180 ) |
1432 | { | 1431 | { |
1433 | if ( secs > 300 ) { | 1432 | if ( secs > 300 ) { |
1434 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { | 1433 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { |
1435 | qDebug("KSS::Sync cancelled ,cs"); | 1434 | qDebug("KSS::Sync cancelled ,cs"); |
1436 | mErrorMessage = 0; | 1435 | mErrorMessage = 0; |
1437 | end_connect(); | 1436 | end_connect(); |
1438 | error_connect("ERROR_CA\r\n\r\n"); | 1437 | error_connect("ERROR_CA\r\n\r\n"); |
1439 | return ; | 1438 | return ; |
1440 | } | 1439 | } |
1441 | } | 1440 | } |
1442 | QFont f = label->font(); | 1441 | QFont f = label->font(); |
1443 | f.setPointSize ( f.pointSize() *2 ); | 1442 | f.setPointSize ( f.pointSize() *2 ); |
@@ -1475,257 +1474,257 @@ void KServerSocket::send_file() | |||
1475 | ts.setEncoding( QTextStream::Latin1 ); | 1474 | ts.setEncoding( QTextStream::Latin1 ); |
1476 | 1475 | ||
1477 | QTextStream os( mSocket ); | 1476 | QTextStream os( mSocket ); |
1478 | os.setEncoding( QTextStream::Latin1 ); | 1477 | os.setEncoding( QTextStream::Latin1 ); |
1479 | while ( ! ts.atEnd() ) { | 1478 | while ( ! ts.atEnd() ) { |
1480 | os << ts.readLine() << "\r\n"; | 1479 | os << ts.readLine() << "\r\n"; |
1481 | } | 1480 | } |
1482 | os << "\r\n"; | 1481 | os << "\r\n"; |
1483 | //os << ts.read(); | 1482 | //os << ts.read(); |
1484 | file.close(); | 1483 | file.close(); |
1485 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 1484 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
1486 | mSocket->close(); | 1485 | mSocket->close(); |
1487 | if ( mSocket->state() == QSocket::Idle ) | 1486 | if ( mSocket->state() == QSocket::Idle ) |
1488 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1487 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1489 | } | 1488 | } |
1490 | void KServerSocket::get_file() | 1489 | void KServerSocket::get_file() |
1491 | { | 1490 | { |
1492 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 1491 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
1493 | 1492 | ||
1494 | piTime.start(); | 1493 | piTime.start(); |
1495 | piFileString = ""; | 1494 | piFileString = ""; |
1496 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 1495 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
1497 | } | 1496 | } |
1498 | 1497 | ||
1499 | 1498 | ||
1500 | void KServerSocket::readBackFileFromSocket() | 1499 | void KServerSocket::readBackFileFromSocket() |
1501 | { | 1500 | { |
1502 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 1501 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
1503 | while ( mSocket->canReadLine () ) { | 1502 | while ( mSocket->canReadLine () ) { |
1504 | piTime.restart(); | 1503 | piTime.restart(); |
1505 | QString line = mSocket->readLine (); | 1504 | QString line = mSocket->readLine (); |
1506 | piFileString += line; | 1505 | piFileString += line; |
1507 | //qDebug("readline: %s ", line.latin1()); | 1506 | //qDebug("readline: %s ", line.latin1()); |
1508 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 1507 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
1509 | 1508 | ||
1510 | } | 1509 | } |
1511 | if ( piTime.elapsed () < 3000 ) { | 1510 | if ( piTime.elapsed () < 3000 ) { |
1512 | // wait for more | 1511 | // wait for more |
1513 | //qDebug("waitformore "); | 1512 | //qDebug("waitformore "); |
1514 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 1513 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
1515 | return; | 1514 | return; |
1516 | } | 1515 | } |
1517 | QString fileName = mFileName; | 1516 | QString fileName = mFileName; |
1518 | QFile file ( fileName ); | 1517 | QFile file ( fileName ); |
1519 | if (!file.open( IO_WriteOnly ) ) { | 1518 | if (!file.open( IO_WriteOnly ) ) { |
1520 | delete mSyncActionDialog; | 1519 | delete mSyncActionDialog; |
1521 | mSyncActionDialog = 0; | 1520 | mSyncActionDialog = 0; |
1522 | qDebug("KSS:Error open read back file "); | 1521 | qDebug("KSS:Error open read back file "); |
1523 | piFileString = ""; | 1522 | piFileString = ""; |
1524 | emit file_received( false, mResource); | 1523 | emit file_received( false, mResource); |
1525 | emit file_received( false); | 1524 | emit file_received( false); |
1526 | blockRC = false; | 1525 | blockRC = false; |
1527 | return ; | 1526 | return ; |
1528 | 1527 | ||
1529 | } | 1528 | } |
1530 | 1529 | ||
1531 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1530 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1532 | QTextStream ts ( &file ); | 1531 | QTextStream ts ( &file ); |
1533 | ts.setEncoding( QTextStream::Latin1 ); | 1532 | ts.setEncoding( QTextStream::Latin1 ); |
1534 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 1533 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
1535 | ts << piFileString; | 1534 | ts << piFileString; |
1536 | mSocket->close(); | 1535 | mSocket->close(); |
1537 | if ( mSocket->state() == QSocket::Idle ) | 1536 | if ( mSocket->state() == QSocket::Idle ) |
1538 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1537 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1539 | file.close(); | 1538 | file.close(); |
1540 | piFileString = ""; | 1539 | piFileString = ""; |
1541 | emit file_received( true, mResource ); | 1540 | emit file_received( true, mResource ); |
1542 | emit file_received( true); | 1541 | emit file_received( true); |
1543 | delete mSyncActionDialog; | 1542 | delete mSyncActionDialog; |
1544 | mSyncActionDialog = 0; | 1543 | mSyncActionDialog = 0; |
1545 | blockRC = false; | 1544 | blockRC = false; |
1546 | 1545 | ||
1547 | } | 1546 | } |
1548 | 1547 | ||
1549 | KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) | 1548 | KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) |
1550 | { | 1549 | { |
1551 | mRemoteResource = remres; | 1550 | mRemoteResource = remres; |
1552 | if ( mRemoteResource.isEmpty() ) | 1551 | if ( mRemoteResource.isEmpty() ) |
1553 | mRemoteResource = "ALL"; | 1552 | mRemoteResource = "ALL"; |
1554 | else | 1553 | else |
1555 | mRemoteResource.replace (QRegExp (" "),"_" ); | 1554 | mRemoteResource.replace (QRegExp (" "),"_" ); |
1556 | mPassWord = password; | 1555 | mPassWord = password; |
1557 | mSocket = 0; | 1556 | mSocket = 0; |
1558 | mFirst = false; | 1557 | mFirst = false; |
1559 | mFirstLine = true; | 1558 | mFirstLine = true; |
1560 | mPort = port; | 1559 | mPort = port; |
1561 | mHost = host; | 1560 | mHost = host; |
1562 | tlw = cap; | 1561 | tlw = cap; |
1563 | mRetVal = quiet; | 1562 | mRetVal = quiet; |
1564 | mTimerSocket = new QTimer ( this ); | 1563 | mTimerSocket = new QTimer ( this ); |
1565 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); | 1564 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); |
1566 | mConnectProgress.setCaption( i18n("Pi-Sync") ); | 1565 | mConnectProgress.setCaption( i18n("Pi-Sync") ); |
1567 | connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); | 1566 | connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); |
1568 | mConnectCount = -1; | 1567 | mConnectCount = -1; |
1569 | } | 1568 | } |
1570 | void KCommandSocket::sendFileRequest() | 1569 | void KCommandSocket::sendFileRequest() |
1571 | { | 1570 | { |
1572 | if ( tlw ) | 1571 | if ( tlw ) |
1573 | tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); | 1572 | tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); |
1574 | mConnectProgress.hide(); | 1573 | mConnectProgress.hide(); |
1575 | mConnectCount = 300;mConnectMax = 300; | 1574 | mConnectCount = 300;mConnectMax = 300; |
1576 | mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); | 1575 | mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); |
1577 | mConnectProgress.setLabelText( i18n("Waiting for remote file...") ); | 1576 | mConnectProgress.setLabelText( i18n("Waiting for remote file...") ); |
1578 | mTimerSocket->start( 100, true ); | 1577 | mTimerSocket->start( 100, true ); |
1579 | QTextStream os( mSocket ); | 1578 | QTextStream os( mSocket ); |
1580 | os.setEncoding( QTextStream::Latin1 ); | 1579 | os.setEncoding( QTextStream::Latin1 ); |
1581 | 1580 | ||
1582 | QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); | 1581 | QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); |
1583 | os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n"; | 1582 | os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n"; |
1584 | } | 1583 | } |
1585 | 1584 | ||
1586 | void KCommandSocket::readFile( QString fn ) | 1585 | void KCommandSocket::readFile( QString fn ) |
1587 | { | 1586 | { |
1588 | if ( !mSocket ) { | 1587 | if ( !mSocket ) { |
1589 | mSocket = new QSocket( this ); | 1588 | mSocket = new QSocket( this ); |
1590 | //qDebug("KCS: read file - new socket"); | 1589 | //qDebug("KCS: read file - new socket"); |
1591 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 1590 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
1592 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1591 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1593 | connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); | 1592 | connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); |
1594 | } | 1593 | } |
1595 | mFileString = ""; | 1594 | mFileString = ""; |
1596 | mFileName = fn; | 1595 | mFileName = fn; |
1597 | mFirst = true; | 1596 | mFirst = true; |
1598 | if ( tlw ) | 1597 | if ( tlw ) |
1599 | tlw->setCaption( i18n("Trying to connect to remote...") ); | 1598 | tlw->setCaption( i18n("Trying to connect to remote...") ); |
1600 | mConnectCount = 30;mConnectMax = 30; | 1599 | mConnectCount = 30;mConnectMax = 30; |
1601 | mTimerSocket->start( 1000, true ); | 1600 | mTimerSocket->start( 1000, true ); |
1602 | mSocket->connectToHost( mHost, mPort ); | 1601 | mSocket->connectToHost( mHost, mPort ); |
1603 | qDebug("KCS: Waiting for connection"); | 1602 | //qDebug("KCS: Waiting for connection"); |
1604 | } | 1603 | } |
1605 | void KCommandSocket::updateConnectDialog() | 1604 | void KCommandSocket::updateConnectDialog() |
1606 | { | 1605 | { |
1607 | 1606 | ||
1608 | if ( mConnectCount == mConnectMax ) { | 1607 | if ( mConnectCount == mConnectMax ) { |
1609 | //qDebug("MAXX %d", mConnectMax); | 1608 | //qDebug("MAXX %d", mConnectMax); |
1610 | mConnectProgress.setTotalSteps ( 30 ); | 1609 | mConnectProgress.setTotalSteps ( 30 ); |
1611 | mConnectProgress.show(); | 1610 | mConnectProgress.show(); |
1612 | mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); | 1611 | mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); |
1613 | } | 1612 | } |
1614 | //qDebug("updateConnectDialog() %d", mConnectCount); | 1613 | //qDebug("updateConnectDialog() %d", mConnectCount); |
1615 | mConnectProgress.raise(); | 1614 | mConnectProgress.raise(); |
1616 | mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); | 1615 | mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); |
1617 | --mConnectCount; | 1616 | --mConnectCount; |
1618 | if ( mConnectCount > 0 ) | 1617 | if ( mConnectCount > 0 ) |
1619 | mTimerSocket->start( 1000, true ); | 1618 | mTimerSocket->start( 1000, true ); |
1620 | else | 1619 | else |
1621 | deleteSocket(); | 1620 | deleteSocket(); |
1622 | 1621 | ||
1623 | } | 1622 | } |
1624 | void KCommandSocket::writeFile( QString fileName ) | 1623 | void KCommandSocket::writeFile( QString fileName ) |
1625 | { | 1624 | { |
1626 | if ( !mSocket ) { | 1625 | if ( !mSocket ) { |
1627 | mSocket = new QSocket( this ); | 1626 | mSocket = new QSocket( this ); |
1628 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1627 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1629 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | 1628 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); |
1630 | } | 1629 | } |
1631 | mFileName = fileName ; | 1630 | mFileName = fileName ; |
1632 | mConnectCount = 30;mConnectMax = 30; | 1631 | mConnectCount = 30;mConnectMax = 30; |
1633 | mTimerSocket->start( 1000, true ); | 1632 | mTimerSocket->start( 1000, true ); |
1634 | mSocket->connectToHost( mHost, mPort ); | 1633 | mSocket->connectToHost( mHost, mPort ); |
1635 | } | 1634 | } |
1636 | void KCommandSocket::writeFileToSocket() | 1635 | void KCommandSocket::writeFileToSocket() |
1637 | { | 1636 | { |
1638 | mTimerSocket->stop(); | 1637 | mTimerSocket->stop(); |
1639 | QFile file2( mFileName ); | 1638 | QFile file2( mFileName ); |
1640 | if (!file2.open( IO_ReadOnly ) ) { | 1639 | if (!file2.open( IO_ReadOnly ) ) { |
1641 | mConnectProgress.hide(); | 1640 | mConnectProgress.hide(); |
1642 | mConnectCount = -1; | 1641 | mConnectCount = -1; |
1643 | mRetVal= errorW; | 1642 | mRetVal= errorW; |
1644 | mSocket->close(); | 1643 | mSocket->close(); |
1645 | if ( mSocket->state() == QSocket::Idle ) | 1644 | if ( mSocket->state() == QSocket::Idle ) |
1646 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1645 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1647 | return ; | 1646 | return ; |
1648 | } | 1647 | } |
1649 | mConnectProgress.setTotalSteps ( file2.size() ); | 1648 | mConnectProgress.setTotalSteps ( file2.size() ); |
1650 | mConnectProgress.show(); | 1649 | mConnectProgress.show(); |
1651 | int count = 0; | 1650 | int count = 0; |
1652 | mConnectProgress.setLabelText( i18n("Sending back synced file...") ); | 1651 | mConnectProgress.setLabelText( i18n("Sending back synced file...") ); |
1653 | mConnectProgress.setProgress( count ); | 1652 | mConnectProgress.setProgress( count ); |
1654 | mConnectProgress.blockSignals( true ); | 1653 | mConnectProgress.blockSignals( true ); |
1655 | QTextStream ts2( &file2 ); | 1654 | QTextStream ts2( &file2 ); |
1656 | ts2.setEncoding( QTextStream::Latin1 ); | 1655 | ts2.setEncoding( QTextStream::Latin1 ); |
1657 | QTextStream os2( mSocket ); | 1656 | QTextStream os2( mSocket ); |
1658 | os2.setEncoding( QTextStream::Latin1 ); | 1657 | os2.setEncoding( QTextStream::Latin1 ); |
1659 | os2 << "PUT " << mPassWord << " " << mRemoteResource << "\r\n\r\n";; | 1658 | os2 << "PUT " << mPassWord << " " << mRemoteResource << "\r\n\r\n";; |
1660 | int byteCount = 0; | 1659 | int byteCount = 0; |
1661 | int byteMax = file2.size()/53; | 1660 | int byteMax = file2.size()/53; |
1662 | while ( ! ts2.atEnd() ) { | 1661 | while ( ! ts2.atEnd() ) { |
1663 | qApp->processEvents(); | 1662 | qApp->processEvents(); |
1664 | if ( byteCount > byteMax ) { | 1663 | if ( byteCount > byteMax ) { |
1665 | byteCount = 0; | 1664 | byteCount = 0; |
1666 | mConnectProgress.setProgress( count ); | 1665 | mConnectProgress.setProgress( count ); |
1667 | } | 1666 | } |
1668 | QString temp = ts2.readLine(); | 1667 | QString temp = ts2.readLine(); |
1669 | count += temp.length(); | 1668 | count += temp.length(); |
1670 | byteCount += temp.length(); | 1669 | byteCount += temp.length(); |
1671 | os2 << temp << "\r\n"; | 1670 | os2 << temp << "\r\n"; |
1672 | } | 1671 | } |
1673 | file2.close(); | 1672 | file2.close(); |
1674 | mConnectProgress.hide(); | 1673 | mConnectProgress.hide(); |
1675 | mConnectCount = -1; | 1674 | mConnectCount = -1; |
1676 | os2 << "\r\n"; | 1675 | os2 << "\r\n"; |
1677 | mRetVal= successW; | 1676 | mRetVal= successW; |
1678 | mSocket->close(); | 1677 | mSocket->close(); |
1679 | if ( mSocket->state() == QSocket::Idle ) | 1678 | if ( mSocket->state() == QSocket::Idle ) |
1680 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1679 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1681 | mConnectProgress.blockSignals( false ); | 1680 | mConnectProgress.blockSignals( false ); |
1682 | } | 1681 | } |
1683 | void KCommandSocket::sendStop() | 1682 | void KCommandSocket::sendStop() |
1684 | { | 1683 | { |
1685 | if ( !mSocket ) { | 1684 | if ( !mSocket ) { |
1686 | mSocket = new QSocket( this ); | 1685 | mSocket = new QSocket( this ); |
1687 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1686 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1688 | } | 1687 | } |
1689 | mSocket->connectToHost( mHost, mPort ); | 1688 | mSocket->connectToHost( mHost, mPort ); |
1690 | QTextStream os2( mSocket ); | 1689 | QTextStream os2( mSocket ); |
1691 | os2.setEncoding( QTextStream::Latin1 ); | 1690 | os2.setEncoding( QTextStream::Latin1 ); |
1692 | os2 << "STOP\r\n\r\n"; | 1691 | os2 << "STOP\r\n\r\n"; |
1693 | mSocket->close(); | 1692 | mSocket->close(); |
1694 | if ( mSocket->state() == QSocket::Idle ) | 1693 | if ( mSocket->state() == QSocket::Idle ) |
1695 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1694 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1696 | } | 1695 | } |
1697 | 1696 | ||
1698 | void KCommandSocket::startReadFileFromSocket() | 1697 | void KCommandSocket::startReadFileFromSocket() |
1699 | { | 1698 | { |
1700 | if ( ! mFirst ) | 1699 | if ( ! mFirst ) |
1701 | return; | 1700 | return; |
1702 | mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); | 1701 | mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); |
1703 | mFirst = false; | 1702 | mFirst = false; |
1704 | mFileString = ""; | 1703 | mFileString = ""; |
1705 | mTime.start(); | 1704 | mTime.start(); |
1706 | mFirstLine = true; | 1705 | mFirstLine = true; |
1707 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 1706 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
1708 | 1707 | ||
1709 | } | 1708 | } |
1710 | void KCommandSocket::readFileFromSocket() | 1709 | void KCommandSocket::readFileFromSocket() |
1711 | { | 1710 | { |
1712 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 1711 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
1713 | while ( mSocket->canReadLine () ) { | 1712 | while ( mSocket->canReadLine () ) { |
1714 | mTime.restart(); | 1713 | mTime.restart(); |
1715 | QString line = mSocket->readLine (); | 1714 | QString line = mSocket->readLine (); |
1716 | if ( mFirstLine ) { | 1715 | if ( mFirstLine ) { |
1717 | mFirstLine = false; | 1716 | mFirstLine = false; |
1718 | if ( line.left( 6 ) == "ERROR_" ) { | 1717 | if ( line.left( 6 ) == "ERROR_" ) { |
1719 | mTimerSocket->stop(); | 1718 | mTimerSocket->stop(); |
1720 | mConnectCount = -1; | 1719 | mConnectCount = -1; |
1721 | if ( line.left( 8 ) == "ERROR_PW" ) { | 1720 | if ( line.left( 8 ) == "ERROR_PW" ) { |
1722 | mRetVal = errorPW; | 1721 | mRetVal = errorPW; |
1723 | deleteSocket(); | 1722 | deleteSocket(); |
1724 | return ; | 1723 | return ; |
1725 | } | 1724 | } |
1726 | if ( line.left( 8 ) == "ERROR_CA" ) { | 1725 | if ( line.left( 8 ) == "ERROR_CA" ) { |
1727 | mRetVal = errorCA; | 1726 | mRetVal = errorCA; |
1728 | deleteSocket(); | 1727 | deleteSocket(); |
1729 | return ; | 1728 | return ; |
1730 | } | 1729 | } |
1731 | if ( line.left( 8 ) == "ERROR_FI" ) { | 1730 | if ( line.left( 8 ) == "ERROR_FI" ) { |