-rw-r--r-- | libkdepim/ksyncmanager.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index db815d6..038e032 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -332,392 +332,394 @@ void KSyncManager::slotSyncMenu( int action ) | |||
332 | qApp->processEvents(); | 332 | qApp->processEvents(); |
333 | } | 333 | } |
334 | } else | 334 | } else |
335 | syncRemote( temp ); | 335 | syncRemote( temp ); |
336 | 336 | ||
337 | } | 337 | } |
338 | } | 338 | } |
339 | delete temp; | 339 | delete temp; |
340 | setBlockSave(false); | 340 | setBlockSave(false); |
341 | } | 341 | } |
342 | 342 | ||
343 | void KSyncManager::enableQuick( bool ask ) | 343 | void KSyncManager::enableQuick( bool ask ) |
344 | { | 344 | { |
345 | bool autoStart; | 345 | bool autoStart; |
346 | bool changed = false; | 346 | bool changed = false; |
347 | if ( ask ) { | 347 | if ( ask ) { |
348 | QDialog dia ( 0, "input-dialog", true ); | 348 | QDialog dia ( 0, "input-dialog", true ); |
349 | QLineEdit lab ( &dia ); | 349 | QLineEdit lab ( &dia ); |
350 | QVBoxLayout lay( &dia ); | 350 | QVBoxLayout lay( &dia ); |
351 | lab.setText( mPrefs->mPassiveSyncPort ); | 351 | lab.setText( mPrefs->mPassiveSyncPort ); |
352 | lay.setMargin(7); | 352 | lay.setMargin(7); |
353 | lay.setSpacing(7); | 353 | lay.setSpacing(7); |
354 | int po = 9197+mTargetApp; | 354 | int po = 9197+mTargetApp; |
355 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); | 355 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); |
356 | lay.addWidget( &label); | 356 | lay.addWidget( &label); |
357 | lay.addWidget( &lab); | 357 | lay.addWidget( &lab); |
358 | 358 | ||
359 | QLineEdit lepw ( &dia ); | 359 | QLineEdit lepw ( &dia ); |
360 | lepw.setText( mPrefs->mPassiveSyncPw ); | 360 | lepw.setText( mPrefs->mPassiveSyncPw ); |
361 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 361 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
362 | lay.addWidget( &label2); | 362 | lay.addWidget( &label2); |
363 | lay.addWidget( &lepw); | 363 | lay.addWidget( &lepw); |
364 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); | 364 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); |
365 | lay.addWidget( &autostart); | 365 | lay.addWidget( &autostart); |
366 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); | 366 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); |
367 | #ifdef DESKTOP_VERSION | 367 | #ifdef DESKTOP_VERSION |
368 | #ifdef _WIN32_ | 368 | #ifdef _WIN32_ |
369 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); | 369 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); |
370 | syncdesktop.hide();// not implemented! | 370 | syncdesktop.hide();// not implemented! |
371 | #else | 371 | #else |
372 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); | 372 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); |
373 | #endif | 373 | #endif |
374 | lay.addWidget( &syncdesktop); | 374 | lay.addWidget( &syncdesktop); |
375 | #else | 375 | #else |
376 | mPrefs->mPassiveSyncWithDesktop = false; | 376 | mPrefs->mPassiveSyncWithDesktop = false; |
377 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); | 377 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); |
378 | syncdesktop.hide(); | 378 | syncdesktop.hide(); |
379 | #endif | 379 | #endif |
380 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); | 380 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); |
381 | 381 | ||
382 | QPushButton pb ( "OK", &dia); | 382 | QPushButton pb ( "OK", &dia); |
383 | lay.addWidget( &pb ); | 383 | lay.addWidget( &pb ); |
384 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 384 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
385 | dia.resize( 230,120 ); | 385 | dia.resize( 230,120 ); |
386 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 386 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
387 | dia.show(); | 387 | dia.show(); |
388 | #ifndef DESKTOP_VERSION | 388 | #ifndef DESKTOP_VERSION |
389 | int dw = QApplication::desktop()->width(); | 389 | int dw = QApplication::desktop()->width(); |
390 | int dh = QApplication::desktop()->height(); | 390 | int dh = QApplication::desktop()->height(); |
391 | dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); | 391 | dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); |
392 | #endif | 392 | #endif |
393 | if ( ! dia.exec() ) | 393 | if ( ! dia.exec() ) |
394 | return; | 394 | return; |
395 | dia.hide(); | 395 | dia.hide(); |
396 | qApp->processEvents(); | 396 | qApp->processEvents(); |
397 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { | 397 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { |
398 | changed = true; | 398 | changed = true; |
399 | mPrefs->mPassiveSyncPw = lepw.text(); | 399 | mPrefs->mPassiveSyncPw = lepw.text(); |
400 | } | 400 | } |
401 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { | 401 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { |
402 | mPrefs->mPassiveSyncPort = lab.text(); | 402 | mPrefs->mPassiveSyncPort = lab.text(); |
403 | changed = true; | 403 | changed = true; |
404 | } | 404 | } |
405 | autoStart = autostart.isChecked(); | 405 | autoStart = autostart.isChecked(); |
406 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { | 406 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { |
407 | changed = true; | 407 | changed = true; |
408 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); | 408 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); |
409 | } | 409 | } |
410 | } | 410 | } |
411 | else | 411 | else |
412 | autoStart = mPrefs->mPassiveSyncAutoStart; | 412 | autoStart = mPrefs->mPassiveSyncAutoStart; |
413 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) | 413 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) |
414 | changed = true; | 414 | changed = true; |
415 | bool ok; | 415 | bool ok; |
416 | mPrefs->mPassiveSyncAutoStart = false; | 416 | mPrefs->mPassiveSyncAutoStart = false; |
417 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); | 417 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); |
418 | if ( ! ok ) { | 418 | if ( ! ok ) { |
419 | KMessageBox::information( 0, i18n("No valid port")); | 419 | KMessageBox::information( 0, i18n("No valid port")); |
420 | return; | 420 | return; |
421 | } | 421 | } |
422 | //qDebug("port %d ", port); | 422 | //qDebug("port %d ", port); |
423 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 423 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
424 | mServerSocket->setFileName( defaultFileName() );//bbb | 424 | mServerSocket->setFileName( defaultFileName() );//bbb |
425 | if ( !mServerSocket->ok() ) { | 425 | if ( !mServerSocket->ok() ) { |
426 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); | 426 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); |
427 | delete mServerSocket; | 427 | delete mServerSocket; |
428 | mServerSocket = 0; | 428 | mServerSocket = 0; |
429 | return; | 429 | return; |
430 | } | 430 | } |
431 | mPrefs->mPassiveSyncAutoStart = autoStart; | 431 | mPrefs->mPassiveSyncAutoStart = autoStart; |
432 | if ( changed ) { | 432 | if ( changed ) { |
433 | mPrefs->writeConfig(); | 433 | mPrefs->writeConfig(); |
434 | } | 434 | } |
435 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 435 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
436 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 436 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
437 | } | 437 | } |
438 | 438 | ||
439 | void KSyncManager::syncLocalFile() | 439 | void KSyncManager::syncLocalFile() |
440 | { | 440 | { |
441 | 441 | ||
442 | QString fn =mPrefs->mLastSyncedLocalFile; | 442 | QString fn =mPrefs->mLastSyncedLocalFile; |
443 | QString ext; | 443 | QString ext; |
444 | 444 | ||
445 | switch(mTargetApp) | 445 | switch(mTargetApp) |
446 | { | 446 | { |
447 | case (KAPI): | 447 | case (KAPI): |
448 | ext = "(*.vcf)"; | 448 | ext = "(*.vcf)"; |
449 | break; | 449 | break; |
450 | case (KOPI): | 450 | case (KOPI): |
451 | ext = "(*.ics/*.vcs)"; | 451 | ext = "(*.ics/*.vcs)"; |
452 | break; | 452 | break; |
453 | case (PWMPI): | 453 | case (PWMPI): |
454 | ext = "(*.pwm)"; | 454 | ext = "(*.pwm)"; |
455 | break; | 455 | break; |
456 | default: | 456 | default: |
457 | qDebug("KSM::syncLocalFile: invalid apptype selected"); | 457 | qDebug("KSM::syncLocalFile: invalid apptype selected"); |
458 | break; | 458 | break; |
459 | 459 | ||
460 | } | 460 | } |
461 | 461 | ||
462 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 462 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
463 | if ( fn == "" ) | 463 | if ( fn == "" ) |
464 | return; | 464 | return; |
465 | if ( syncWithFile( fn, false ) ) { | 465 | if ( syncWithFile( fn, false ) ) { |
466 | qDebug("KSM::syncLocalFile() successful "); | 466 | qDebug("KSM::syncLocalFile() successful "); |
467 | } | 467 | } |
468 | 468 | ||
469 | } | 469 | } |
470 | 470 | ||
471 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 471 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
472 | { | 472 | { |
473 | bool ret = false; | 473 | bool ret = false; |
474 | QFileInfo info; | 474 | QFileInfo info; |
475 | info.setFile( fn ); | 475 | info.setFile( fn ); |
476 | QString mess; | 476 | QString mess; |
477 | if ( !info. exists() ) { | 477 | if ( !info. exists() ) { |
478 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 478 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
479 | QMessageBox::warning( mParent, i18n("Warning!"), | 479 | QMessageBox::warning( mParent, i18n("Warning!"), |
480 | mess ); | 480 | mess ); |
481 | return ret; | 481 | return ret; |
482 | } | 482 | } |
483 | int result = 0; | 483 | int result = 0; |
484 | if ( !quick ) { | 484 | if ( !quick ) { |
485 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 485 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
486 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 486 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
487 | mess, | 487 | mess, |
488 | i18n("Sync"), i18n("Cancel"), 0, | 488 | i18n("Sync"), i18n("Cancel"), 0, |
489 | 0, 1 ); | 489 | 0, 1 ); |
490 | if ( result ) | 490 | if ( result ) |
491 | return false; | 491 | return false; |
492 | } | 492 | } |
493 | if ( mAskForPreferences ) | 493 | if ( mAskForPreferences ) |
494 | if ( !edit_sync_options()) { | 494 | if ( !edit_sync_options()) { |
495 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 495 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
496 | return false; | 496 | return false; |
497 | } | 497 | } |
498 | if ( result == 0 ) { | 498 | if ( result == 0 ) { |
499 | //qDebug("Now sycing ... "); | 499 | //qDebug("Now sycing ... "); |
500 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 500 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
501 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 501 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
502 | else | 502 | else |
503 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 503 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
504 | if ( ! quick ) | 504 | if ( ! quick ) |
505 | mPrefs->mLastSyncedLocalFile = fn; | 505 | mPrefs->mLastSyncedLocalFile = fn; |
506 | } | 506 | } |
507 | return ret; | 507 | return ret; |
508 | } | 508 | } |
509 | 509 | ||
510 | void KSyncManager::quickSyncLocalFile() | 510 | void KSyncManager::quickSyncLocalFile() |
511 | { | 511 | { |
512 | 512 | ||
513 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 513 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
514 | qDebug("KSM::quick syncLocalFile() successful "); | 514 | qDebug("KSM::quick syncLocalFile() successful "); |
515 | 515 | ||
516 | } | 516 | } |
517 | } | 517 | } |
518 | 518 | ||
519 | void KSyncManager::multiSync( bool askforPrefs ) | 519 | void KSyncManager::multiSync( bool askforPrefs ) |
520 | { | 520 | { |
521 | if (blockSave()) | 521 | if (blockSave()) |
522 | return; | 522 | return; |
523 | setBlockSave(true); | 523 | setBlockSave(true); |
524 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 524 | if ( askforPrefs ) { |
525 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 525 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
526 | question, | 526 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
527 | i18n("Yes"), i18n("No"), | 527 | question, |
528 | 0, 0 ) != 0 ) { | 528 | i18n("Yes"), i18n("No"), |
529 | setBlockSave(false); | 529 | 0, 0 ) != 0 ) { |
530 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 530 | setBlockSave(false); |
531 | return; | 531 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
532 | return; | ||
533 | } | ||
532 | } | 534 | } |
533 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 535 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
534 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 536 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
535 | if ( askforPrefs ) { | 537 | if ( askforPrefs ) { |
536 | if ( !edit_sync_options()) { | 538 | if ( !edit_sync_options()) { |
537 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); | 539 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); |
538 | return; | 540 | return; |
539 | } | 541 | } |
540 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 542 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
541 | } | 543 | } |
542 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 544 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
543 | qApp->processEvents(); | 545 | qApp->processEvents(); |
544 | int num = ringSync() ; | 546 | int num = ringSync() ; |
545 | if ( num > 1 ) | 547 | if ( num > 1 ) |
546 | ringSync(); | 548 | ringSync(); |
547 | setBlockSave(false); | 549 | setBlockSave(false); |
548 | if ( num ) | 550 | if ( num ) |
549 | emit save(); | 551 | emit save(); |
550 | if ( num ) | 552 | if ( num ) |
551 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 553 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
552 | else | 554 | else |
553 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 555 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
554 | return; | 556 | return; |
555 | } | 557 | } |
556 | 558 | ||
557 | int KSyncManager::ringSync() | 559 | int KSyncManager::ringSync() |
558 | { | 560 | { |
559 | 561 | ||
560 | int syncedProfiles = 0; | 562 | int syncedProfiles = 0; |
561 | unsigned int i; | 563 | unsigned int i; |
562 | QTime timer; | 564 | QTime timer; |
563 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 565 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
564 | QStringList syncProfileNames = mSyncProfileNames; | 566 | QStringList syncProfileNames = mSyncProfileNames; |
565 | KSyncProfile* temp = new KSyncProfile (); | 567 | KSyncProfile* temp = new KSyncProfile (); |
566 | mAskForPreferences = false; | 568 | mAskForPreferences = false; |
567 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 569 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
568 | mCurrentSyncProfile = i; | 570 | mCurrentSyncProfile = i; |
569 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 571 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
570 | temp->readConfig(&config); | 572 | temp->readConfig(&config); |
571 | 573 | ||
572 | bool includeInRingSync = false; | 574 | bool includeInRingSync = false; |
573 | switch(mTargetApp) | 575 | switch(mTargetApp) |
574 | { | 576 | { |
575 | case (KAPI): | 577 | case (KAPI): |
576 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 578 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
577 | break; | 579 | break; |
578 | case (KOPI): | 580 | case (KOPI): |
579 | includeInRingSync = temp->getIncludeInRingSync(); | 581 | includeInRingSync = temp->getIncludeInRingSync(); |
580 | break; | 582 | break; |
581 | case (PWMPI): | 583 | case (PWMPI): |
582 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 584 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
583 | break; | 585 | break; |
584 | default: | 586 | default: |
585 | qDebug("KSM::ringSync: invalid apptype selected"); | 587 | qDebug("KSM::ringSync: invalid apptype selected"); |
586 | break; | 588 | break; |
587 | 589 | ||
588 | } | 590 | } |
589 | 591 | ||
590 | 592 | ||
591 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 593 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
592 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 594 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
593 | ++syncedProfiles; | 595 | ++syncedProfiles; |
594 | mSyncWithDesktop = false; | 596 | mSyncWithDesktop = false; |
595 | // mAskForPreferences = temp->getAskForPreferences(); | 597 | // mAskForPreferences = temp->getAskForPreferences(); |
596 | mWriteBackFile = temp->getWriteBackFile(); | 598 | mWriteBackFile = temp->getWriteBackFile(); |
597 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 599 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
598 | mIsKapiFile = temp->getIsKapiFile(); | 600 | mIsKapiFile = temp->getIsKapiFile(); |
599 | mWriteBackInFuture = 0; | 601 | mWriteBackInFuture = 0; |
600 | if ( temp->getWriteBackFuture() ) { | 602 | if ( temp->getWriteBackFuture() ) { |
601 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 603 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
602 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 604 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
603 | } | 605 | } |
604 | mFilterInCal = temp->getFilterInCal(); | 606 | mFilterInCal = temp->getFilterInCal(); |
605 | mFilterOutCal = temp->getFilterOutCal(); | 607 | mFilterOutCal = temp->getFilterOutCal(); |
606 | mFilterInAB = temp->getFilterInAB(); | 608 | mFilterInAB = temp->getFilterInAB(); |
607 | mFilterOutAB = temp->getFilterOutAB(); | 609 | mFilterOutAB = temp->getFilterOutAB(); |
608 | mShowSyncSummary = false; | 610 | mShowSyncSummary = false; |
609 | mCurrentSyncDevice = syncProfileNames[i] ; | 611 | mCurrentSyncDevice = syncProfileNames[i] ; |
610 | mCurrentSyncName = mLocalMachineName; | 612 | mCurrentSyncName = mLocalMachineName; |
611 | if ( i == 0 ) { | 613 | if ( i == 0 ) { |
612 | mIsKapiFile = false; | 614 | mIsKapiFile = false; |
613 | #ifdef DESKTOP_VERSION | 615 | #ifdef DESKTOP_VERSION |
614 | syncKDE(); | 616 | syncKDE(); |
615 | #else | 617 | #else |
616 | syncSharp(); | 618 | syncSharp(); |
617 | #endif | 619 | #endif |
618 | } else { | 620 | } else { |
619 | if ( temp->getIsLocalFileSync() ) { | 621 | if ( temp->getIsLocalFileSync() ) { |
620 | switch(mTargetApp) | 622 | switch(mTargetApp) |
621 | { | 623 | { |
622 | case (KAPI): | 624 | case (KAPI): |
623 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 625 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
624 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 626 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
625 | break; | 627 | break; |
626 | case (KOPI): | 628 | case (KOPI): |
627 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 629 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
628 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 630 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
629 | break; | 631 | break; |
630 | case (PWMPI): | 632 | case (PWMPI): |
631 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 633 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
632 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 634 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
633 | break; | 635 | break; |
634 | default: | 636 | default: |
635 | qDebug("KSM: invalid apptype selected"); | 637 | qDebug("KSM: invalid apptype selected"); |
636 | break; | 638 | break; |
637 | } | 639 | } |
638 | } else { | 640 | } else { |
639 | if ( temp->getIsPhoneSync() ) { | 641 | if ( temp->getIsPhoneSync() ) { |
640 | mPhoneDevice = temp->getPhoneDevice( ) ; | 642 | mPhoneDevice = temp->getPhoneDevice( ) ; |
641 | mPhoneConnection = temp->getPhoneConnection( ); | 643 | mPhoneConnection = temp->getPhoneConnection( ); |
642 | mPhoneModel = temp->getPhoneModel( ); | 644 | mPhoneModel = temp->getPhoneModel( ); |
643 | syncPhone(); | 645 | syncPhone(); |
644 | } else if ( temp->getIsPiSync() ) { | 646 | } else if ( temp->getIsPiSync() ) { |
645 | if ( mTargetApp == KAPI ) { | 647 | if ( mTargetApp == KAPI ) { |
646 | mPassWordPiSync = temp->getRemotePwAB(); | 648 | mPassWordPiSync = temp->getRemotePwAB(); |
647 | mActiveSyncPort = temp->getRemotePortAB(); | 649 | mActiveSyncPort = temp->getRemotePortAB(); |
648 | mActiveSyncIP = temp->getRemoteIPAB(); | 650 | mActiveSyncIP = temp->getRemoteIPAB(); |
649 | } else if ( mTargetApp == KOPI ) { | 651 | } else if ( mTargetApp == KOPI ) { |
650 | mPassWordPiSync = temp->getRemotePw(); | 652 | mPassWordPiSync = temp->getRemotePw(); |
651 | mActiveSyncPort = temp->getRemotePort(); | 653 | mActiveSyncPort = temp->getRemotePort(); |
652 | mActiveSyncIP = temp->getRemoteIP(); | 654 | mActiveSyncIP = temp->getRemoteIP(); |
653 | } else { | 655 | } else { |
654 | mPassWordPiSync = temp->getRemotePwPWM(); | 656 | mPassWordPiSync = temp->getRemotePwPWM(); |
655 | mActiveSyncPort = temp->getRemotePortPWM(); | 657 | mActiveSyncPort = temp->getRemotePortPWM(); |
656 | mActiveSyncIP = temp->getRemoteIPPWM(); | 658 | mActiveSyncIP = temp->getRemoteIPPWM(); |
657 | } | 659 | } |
658 | syncPi(); | 660 | syncPi(); |
659 | while ( !mPisyncFinished ) { | 661 | while ( !mPisyncFinished ) { |
660 | //qDebug("waiting "); | 662 | //qDebug("waiting "); |
661 | qApp->processEvents(); | 663 | qApp->processEvents(); |
662 | } | 664 | } |
663 | timer.start(); | 665 | timer.start(); |
664 | while ( timer.elapsed () < 2000 ) { | 666 | while ( timer.elapsed () < 2000 ) { |
665 | qApp->processEvents(); | 667 | qApp->processEvents(); |
666 | } | 668 | } |
667 | } else | 669 | } else |
668 | syncRemote( temp, false ); | 670 | syncRemote( temp, false ); |
669 | 671 | ||
670 | } | 672 | } |
671 | } | 673 | } |
672 | timer.start(); | 674 | timer.start(); |
673 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 675 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
674 | while ( timer.elapsed () < 2000 ) { | 676 | while ( timer.elapsed () < 2000 ) { |
675 | qApp->processEvents(); | 677 | qApp->processEvents(); |
676 | #ifndef _WIN32_ | 678 | #ifndef _WIN32_ |
677 | sleep (1); | 679 | sleep (1); |
678 | #endif | 680 | #endif |
679 | } | 681 | } |
680 | 682 | ||
681 | } | 683 | } |
682 | 684 | ||
683 | } | 685 | } |
684 | delete temp; | 686 | delete temp; |
685 | return syncedProfiles; | 687 | return syncedProfiles; |
686 | } | 688 | } |
687 | 689 | ||
688 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 690 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
689 | { | 691 | { |
690 | QString question; | 692 | QString question; |
691 | if ( ask ) { | 693 | if ( ask ) { |
692 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 694 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
693 | if ( QMessageBox::information( mParent, i18n("Sync"), | 695 | if ( QMessageBox::information( mParent, i18n("Sync"), |
694 | question, | 696 | question, |
695 | i18n("Yes"), i18n("No"), | 697 | i18n("Yes"), i18n("No"), |
696 | 0, 0 ) != 0 ) | 698 | 0, 0 ) != 0 ) |
697 | return; | 699 | return; |
698 | } | 700 | } |
699 | 701 | ||
700 | QString preCommand; | 702 | QString preCommand; |
701 | QString localTempFile; | 703 | QString localTempFile; |
702 | QString postCommand; | 704 | QString postCommand; |
703 | 705 | ||
704 | switch(mTargetApp) | 706 | switch(mTargetApp) |
705 | { | 707 | { |
706 | case (KAPI): | 708 | case (KAPI): |
707 | preCommand = prof->getPreSyncCommandAB(); | 709 | preCommand = prof->getPreSyncCommandAB(); |
708 | postCommand = prof->getPostSyncCommandAB(); | 710 | postCommand = prof->getPostSyncCommandAB(); |
709 | localTempFile = prof->getLocalTempFileAB(); | 711 | localTempFile = prof->getLocalTempFileAB(); |
710 | break; | 712 | break; |
711 | case (KOPI): | 713 | case (KOPI): |
712 | preCommand = prof->getPreSyncCommand(); | 714 | preCommand = prof->getPreSyncCommand(); |
713 | postCommand = prof->getPostSyncCommand(); | 715 | postCommand = prof->getPostSyncCommand(); |
714 | localTempFile = prof->getLocalTempFile(); | 716 | localTempFile = prof->getLocalTempFile(); |
715 | break; | 717 | break; |
716 | case (PWMPI): | 718 | case (PWMPI): |
717 | preCommand = prof->getPreSyncCommandPWM(); | 719 | preCommand = prof->getPreSyncCommandPWM(); |
718 | postCommand = prof->getPostSyncCommandPWM(); | 720 | postCommand = prof->getPostSyncCommandPWM(); |
719 | localTempFile = prof->getLocalTempFilePWM(); | 721 | localTempFile = prof->getLocalTempFilePWM(); |
720 | break; | 722 | break; |
721 | default: | 723 | default: |
722 | qDebug("KSM::syncRemote: invalid apptype selected"); | 724 | qDebug("KSM::syncRemote: invalid apptype selected"); |
723 | break; | 725 | break; |