-rw-r--r-- | libkdepim/ksyncmanager.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index e615cbe..7197b30 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -252,386 +252,386 @@ void KSyncManager::slotSyncMenu( int action ) | |||
252 | mWriteBackFile = true; | 252 | mWriteBackFile = true; |
253 | mSyncAlgoPrefs = 2;// take newest | 253 | mSyncAlgoPrefs = 2;// take newest |
254 | } | 254 | } |
255 | else { | 255 | else { |
256 | mAskForPreferences = temp->getAskForPreferences(); | 256 | mAskForPreferences = temp->getAskForPreferences(); |
257 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 257 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
258 | mWriteBackFile = temp->getWriteBackFile(); | 258 | mWriteBackFile = temp->getWriteBackFile(); |
259 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 259 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
260 | } | 260 | } |
261 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 261 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
262 | mIsKapiFile = temp->getIsKapiFile(); | 262 | mIsKapiFile = temp->getIsKapiFile(); |
263 | mWriteBackInFuture = 0; | 263 | mWriteBackInFuture = 0; |
264 | if ( temp->getWriteBackFuture() ) { | 264 | if ( temp->getWriteBackFuture() ) { |
265 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 265 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
266 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 266 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
267 | } | 267 | } |
268 | mFilterInCal = temp->getFilterInCal(); | 268 | mFilterInCal = temp->getFilterInCal(); |
269 | mFilterOutCal = temp->getFilterOutCal(); | 269 | mFilterOutCal = temp->getFilterOutCal(); |
270 | mFilterInAB = temp->getFilterInAB(); | 270 | mFilterInAB = temp->getFilterInAB(); |
271 | mFilterOutAB = temp->getFilterOutAB(); | 271 | mFilterOutAB = temp->getFilterOutAB(); |
272 | 272 | ||
273 | if ( action == 1000 ) { | 273 | if ( action == 1000 ) { |
274 | mIsKapiFile = false; | 274 | mIsKapiFile = false; |
275 | #ifdef DESKTOP_VERSION | 275 | #ifdef DESKTOP_VERSION |
276 | syncKDE(); | 276 | syncKDE(); |
277 | #else | 277 | #else |
278 | syncSharp(); | 278 | syncSharp(); |
279 | #endif | 279 | #endif |
280 | 280 | ||
281 | } else if ( action == 1001 ) { | 281 | } else if ( action == 1001 ) { |
282 | syncLocalFile(); | 282 | syncLocalFile(); |
283 | 283 | ||
284 | } else if ( action == 1002 ) { | 284 | } else if ( action == 1002 ) { |
285 | mWriteBackFile = false; | 285 | mWriteBackFile = false; |
286 | mAskForPreferences = false; | 286 | mAskForPreferences = false; |
287 | mShowSyncSummary = false; | 287 | mShowSyncSummary = false; |
288 | mSyncAlgoPrefs = 3; | 288 | mSyncAlgoPrefs = 3; |
289 | quickSyncLocalFile(); | 289 | quickSyncLocalFile(); |
290 | 290 | ||
291 | } else if ( action >= 1003 ) { | 291 | } else if ( action >= 1003 ) { |
292 | if ( temp->getIsLocalFileSync() ) { | 292 | if ( temp->getIsLocalFileSync() ) { |
293 | switch(mTargetApp) | 293 | switch(mTargetApp) |
294 | { | 294 | { |
295 | case (KAPI): | 295 | case (KAPI): |
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 | if ( temp->getIsPiSyncSpec() ) | 321 | if ( temp->getIsPiSyncSpec() ) |
322 | mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true ); | 322 | mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true ); |
323 | mPassWordPiSync = temp->getRemotePwAB(); | 323 | mPassWordPiSync = temp->getRemotePwAB(); |
324 | mActiveSyncPort = temp->getRemotePortAB(); | 324 | mActiveSyncPort = temp->getRemotePortAB(); |
325 | mActiveSyncIP = temp->getRemoteIPAB(); | 325 | mActiveSyncIP = temp->getRemoteIPAB(); |
326 | } else if ( mTargetApp == KOPI ) { | 326 | } else if ( mTargetApp == KOPI ) { |
327 | if ( temp->getIsPiSyncSpec() ) | 327 | if ( temp->getIsPiSyncSpec() ) |
328 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); | 328 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); |
329 | mPassWordPiSync = temp->getRemotePw(); | 329 | mPassWordPiSync = temp->getRemotePw(); |
330 | mActiveSyncPort = temp->getRemotePort(); | 330 | mActiveSyncPort = temp->getRemotePort(); |
331 | mActiveSyncIP = temp->getRemoteIP(); | 331 | mActiveSyncIP = temp->getRemoteIP(); |
332 | } else { | 332 | } else { |
333 | mPassWordPiSync = temp->getRemotePwPWM(); | 333 | mPassWordPiSync = temp->getRemotePwPWM(); |
334 | mActiveSyncPort = temp->getRemotePortPWM(); | 334 | mActiveSyncPort = temp->getRemotePortPWM(); |
335 | mActiveSyncIP = temp->getRemoteIPPWM(); | 335 | mActiveSyncIP = temp->getRemoteIPPWM(); |
336 | } | 336 | } |
337 | syncPi(); | 337 | syncPi(); |
338 | while ( !mPisyncFinished ) { | 338 | while ( !mPisyncFinished ) { |
339 | //qDebug("waiting "); | 339 | //qDebug("waiting "); |
340 | qApp->processEvents(); | 340 | qApp->processEvents(); |
341 | } | 341 | } |
342 | } else | 342 | } else |
343 | syncRemote( temp ); | 343 | syncRemote( temp ); |
344 | 344 | ||
345 | } | 345 | } |
346 | } | 346 | } |
347 | delete temp; | 347 | delete temp; |
348 | setBlockSave(false); | 348 | setBlockSave(false); |
349 | } | 349 | } |
350 | 350 | ||
351 | void KSyncManager::enableQuick( bool ask ) | 351 | void KSyncManager::enableQuick( bool ask ) |
352 | { | 352 | { |
353 | bool autoStart; | 353 | bool autoStart; |
354 | bool changed = false; | 354 | bool changed = false; |
355 | if ( ask ) { | 355 | if ( ask ) { |
356 | QDialog dia ( 0, "input-dialog", true ); | 356 | QDialog dia ( 0, "input-dialog", true ); |
357 | QLineEdit lab ( &dia ); | 357 | QLineEdit lab ( &dia ); |
358 | QVBoxLayout lay( &dia ); | 358 | QVBoxLayout lay( &dia ); |
359 | lab.setText( mPrefs->mPassiveSyncPort ); | 359 | lab.setText( mPrefs->mPassiveSyncPort ); |
360 | lay.setMargin(7); | 360 | lay.setMargin(7); |
361 | lay.setSpacing(7); | 361 | lay.setSpacing(7); |
362 | int po = 9197+mTargetApp; | 362 | int po = 9197+mTargetApp; |
363 | QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); | 363 | QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); |
364 | lay.addWidget( &label); | 364 | lay.addWidget( &label); |
365 | lay.addWidget( &lab); | 365 | lay.addWidget( &lab); |
366 | 366 | ||
367 | QLineEdit lepw ( &dia ); | 367 | QLineEdit lepw ( &dia ); |
368 | lepw.setText( mPrefs->mPassiveSyncPw ); | 368 | lepw.setText( mPrefs->mPassiveSyncPw ); |
369 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 369 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
370 | lay.addWidget( &label2); | 370 | lay.addWidget( &label2); |
371 | lay.addWidget( &lepw); | 371 | lay.addWidget( &lepw); |
372 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); | 372 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); |
373 | lay.addWidget( &autostart); | 373 | lay.addWidget( &autostart); |
374 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); | 374 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); |
375 | #ifdef DESKTOP_VERSION | 375 | #ifdef DESKTOP_VERSION |
376 | #ifdef _WIN32_ | 376 | #ifdef _WIN32_ |
377 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); | 377 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); |
378 | syncdesktop.hide();// not implemented! | 378 | syncdesktop.hide();// not implemented! |
379 | #else | 379 | #else |
380 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); | 380 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); |
381 | #endif | 381 | #endif |
382 | lay.addWidget( &syncdesktop); | 382 | lay.addWidget( &syncdesktop); |
383 | #else | 383 | #else |
384 | mPrefs->mPassiveSyncWithDesktop = false; | 384 | mPrefs->mPassiveSyncWithDesktop = false; |
385 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); | 385 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); |
386 | syncdesktop.hide(); | 386 | syncdesktop.hide(); |
387 | #endif | 387 | #endif |
388 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); | 388 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); |
389 | 389 | ||
390 | QPushButton pb ( "OK", &dia); | 390 | QPushButton pb ( "OK", &dia); |
391 | lay.addWidget( &pb ); | 391 | lay.addWidget( &pb ); |
392 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 392 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
393 | dia.resize( 230,120 ); | 393 | dia.resize( 230,120 ); |
394 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 394 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
395 | dia.show(); | 395 | dia.show(); |
396 | #ifndef DESKTOP_VERSION | 396 | #ifndef DESKTOP_VERSION |
397 | int dw = QApplication::desktop()->width(); | 397 | int dw = QApplication::desktop()->width(); |
398 | int dh = QApplication::desktop()->height(); | 398 | int dh = QApplication::desktop()->height(); |
399 | dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); | 399 | dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); |
400 | #endif | 400 | #endif |
401 | if ( ! dia.exec() ) | 401 | if ( ! dia.exec() ) |
402 | return; | 402 | return; |
403 | dia.hide(); | 403 | dia.hide(); |
404 | qApp->processEvents(); | 404 | qApp->processEvents(); |
405 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { | 405 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { |
406 | changed = true; | 406 | changed = true; |
407 | mPrefs->mPassiveSyncPw = lepw.text(); | 407 | mPrefs->mPassiveSyncPw = lepw.text(); |
408 | } | 408 | } |
409 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { | 409 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { |
410 | mPrefs->mPassiveSyncPort = lab.text(); | 410 | mPrefs->mPassiveSyncPort = lab.text(); |
411 | changed = true; | 411 | changed = true; |
412 | } | 412 | } |
413 | autoStart = autostart.isChecked(); | 413 | autoStart = autostart.isChecked(); |
414 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { | 414 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { |
415 | changed = true; | 415 | changed = true; |
416 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); | 416 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); |
417 | } | 417 | } |
418 | } | 418 | } |
419 | else | 419 | else |
420 | autoStart = mPrefs->mPassiveSyncAutoStart; | 420 | autoStart = mPrefs->mPassiveSyncAutoStart; |
421 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) | 421 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) |
422 | changed = true; | 422 | changed = true; |
423 | bool ok; | 423 | bool ok; |
424 | mPrefs->mPassiveSyncAutoStart = false; | 424 | mPrefs->mPassiveSyncAutoStart = false; |
425 | Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); | 425 | Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); |
426 | if ( ! ok || port_t > 65535 ) { | 426 | if ( ! ok || port_t > 65535 ) { |
427 | KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); | 427 | KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); |
428 | return; | 428 | return; |
429 | } | 429 | } |
430 | Q_UINT16 port = port_t; | 430 | Q_UINT16 port = port_t; |
431 | //qDebug("port %d ", port); | 431 | //qDebug("port %d ", port); |
432 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 432 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
433 | mServerSocket->setFileName( defaultFileName() );//bbb | 433 | mServerSocket->setFileName( defaultFileName() );//bbb |
434 | if ( !mServerSocket->ok() ) { | 434 | if ( !mServerSocket->ok() ) { |
435 | QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); | 435 | QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); |
436 | delete mServerSocket; | 436 | delete mServerSocket; |
437 | mServerSocket = 0; | 437 | mServerSocket = 0; |
438 | return; | 438 | return; |
439 | } | 439 | } |
440 | mPrefs->mPassiveSyncAutoStart = autoStart; | 440 | mPrefs->mPassiveSyncAutoStart = autoStart; |
441 | if ( changed ) { | 441 | if ( changed ) { |
442 | mPrefs->writeConfig(); | 442 | mPrefs->writeConfig(); |
443 | } | 443 | } |
444 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 444 | //connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
445 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 445 | //connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
446 | connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) ); | 446 | connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) ); |
447 | connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) ); | 447 | connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) ); |
448 | } | 448 | } |
449 | void KSyncManager::displayErrorPort() | 449 | void KSyncManager::displayErrorPort() |
450 | { | 450 | { |
451 | 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 | 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")); |
452 | } | 452 | } |
453 | void KSyncManager::syncLocalFile() | 453 | void KSyncManager::syncLocalFile() |
454 | { | 454 | { |
455 | 455 | ||
456 | QString fn =mPrefs->mLastSyncedLocalFile; | 456 | QString fn =mPrefs->mLastSyncedLocalFile; |
457 | QString ext; | 457 | QString ext; |
458 | 458 | ||
459 | switch(mTargetApp) | 459 | switch(mTargetApp) |
460 | { | 460 | { |
461 | case (KAPI): | 461 | case (KAPI): |
462 | ext = "(*.vcf)"; | 462 | ext = "(*.vcf)"; |
463 | break; | 463 | break; |
464 | case (KOPI): | 464 | case (KOPI): |
465 | ext = "(*.ics/*.vcs)"; | 465 | ext = "(*.ics/*.vcs)"; |
466 | break; | 466 | break; |
467 | case (PWMPI): | 467 | case (PWMPI): |
468 | ext = "(*.pwm)"; | 468 | ext = "(*.pwm)"; |
469 | break; | 469 | break; |
470 | default: | 470 | default: |
471 | qDebug("KSM::syncLocalFile: invalid apptype selected"); | 471 | qDebug("KSM::syncLocalFile: invalid apptype selected"); |
472 | break; | 472 | break; |
473 | 473 | ||
474 | } | 474 | } |
475 | 475 | ||
476 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 476 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
477 | if ( fn == "" ) | 477 | if ( fn == "" ) |
478 | return; | 478 | return; |
479 | if ( syncWithFile( fn, false ) ) { | 479 | if ( syncWithFile( fn, false ) ) { |
480 | qDebug("KSM::syncLocalFile() successful "); | 480 | qDebug("KSM::syncLocalFile() successful "); |
481 | } | 481 | } |
482 | 482 | ||
483 | } | 483 | } |
484 | 484 | ||
485 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 485 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
486 | { | 486 | { |
487 | bool ret = false; | 487 | bool ret = false; |
488 | QFileInfo info; | 488 | QFileInfo info; |
489 | info.setFile( fn ); | 489 | info.setFile( fn ); |
490 | QString mess; | 490 | QString mess; |
491 | if ( !info. exists() ) { | 491 | if ( !info. exists() ) { |
492 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 492 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
493 | QMessageBox::warning( mParent, i18n("Warning!"), | 493 | QMessageBox::warning( mParent, i18n("Warning!"), |
494 | mess ); | 494 | mess ); |
495 | return ret; | 495 | return ret; |
496 | } | 496 | } |
497 | int result = 0; | 497 | int result = 0; |
498 | if ( !quick ) { | 498 | if ( !quick ) { |
499 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 499 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
500 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 500 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
501 | mess, | 501 | mess, |
502 | i18n("Sync"), i18n("Cancel"), 0, | 502 | i18n("Sync"), i18n("Cancel"), 0, |
503 | 0, 1 ); | 503 | 0, 1 ); |
504 | if ( result ) | 504 | if ( result ) |
505 | return false; | 505 | return false; |
506 | } | 506 | } |
507 | if ( mAskForPreferences ) | 507 | if ( mAskForPreferences ) |
508 | if ( !edit_sync_options()) { | 508 | if ( !edit_sync_options()) { |
509 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 509 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
510 | return false; | 510 | return false; |
511 | } | 511 | } |
512 | if ( result == 0 ) { | 512 | if ( result == 0 ) { |
513 | //qDebug("Now sycing ... "); | 513 | //qDebug("Now sycing ... "); |
514 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) ) | 514 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) ) |
515 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 515 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
516 | else | 516 | else |
517 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 517 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
518 | if ( ! quick ) | 518 | if ( ! quick ) |
519 | mPrefs->mLastSyncedLocalFile = fn; | 519 | mPrefs->mLastSyncedLocalFile = fn; |
520 | } | 520 | } |
521 | return ret; | 521 | return ret; |
522 | } | 522 | } |
523 | 523 | ||
524 | void KSyncManager::quickSyncLocalFile() | 524 | void KSyncManager::quickSyncLocalFile() |
525 | { | 525 | { |
526 | 526 | ||
527 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 527 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
528 | qDebug("KSM::quick syncLocalFile() successful "); | 528 | qDebug("KSM::quick syncLocalFile() successful "); |
529 | 529 | ||
530 | } | 530 | } |
531 | } | 531 | } |
532 | 532 | ||
533 | void KSyncManager::multiSync( bool askforPrefs ) | 533 | void KSyncManager::multiSync( bool askforPrefs ) |
534 | { | 534 | { |
535 | if (blockSave()) | 535 | if (blockSave()) |
536 | return; | 536 | return; |
537 | setBlockSave(true); | 537 | setBlockSave(true); |
538 | mCurrentResourceLocal = ""; | 538 | mCurrentResourceLocal = ""; |
539 | if ( askforPrefs ) { | 539 | if ( askforPrefs ) { |
540 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 540 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
541 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 541 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
542 | question, | 542 | question, |
543 | i18n("Yes"), i18n("No"), | 543 | i18n("Yes"), i18n("No"), |
544 | 0, 0 ) != 0 ) { | 544 | 0, 0 ) != 0 ) { |
545 | setBlockSave(false); | 545 | setBlockSave(false); |
546 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 546 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
547 | return; | 547 | return; |
548 | } | 548 | } |
549 | } | 549 | } |
550 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 550 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
551 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 551 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
552 | if ( askforPrefs ) { | 552 | if ( askforPrefs ) { |
553 | if ( !edit_sync_options()) { | 553 | if ( !edit_sync_options()) { |
554 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); | 554 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); |
555 | return; | 555 | return; |
556 | } | 556 | } |
557 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 557 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
558 | } | 558 | } |
559 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 559 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
560 | qApp->processEvents(); | 560 | qApp->processEvents(); |
561 | int num = ringSync() ; | 561 | int num = ringSync() ; |
562 | if ( num > 1 ) | 562 | if ( num > 1 ) |
563 | ringSync(); | 563 | ringSync(); |
564 | setBlockSave(false); | 564 | setBlockSave(false); |
565 | if ( num ) | 565 | if ( num ) |
566 | emit save(); | 566 | emit save(); |
567 | if ( num ) | 567 | if ( num ) |
568 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 568 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
569 | else | 569 | else |
570 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 570 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
571 | return; | 571 | return; |
572 | } | 572 | } |
573 | 573 | ||
574 | int KSyncManager::ringSync() | 574 | int KSyncManager::ringSync() |
575 | { | 575 | { |
576 | emit multiResourceSyncStart( false ); | 576 | emit multiResourceSyncStart( false ); |
577 | int syncedProfiles = 0; | 577 | int syncedProfiles = 0; |
578 | unsigned int i; | 578 | unsigned int i; |
579 | QTime timer; | 579 | QTime timer; |
580 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 580 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
581 | QStringList syncProfileNames = mSyncProfileNames; | 581 | QStringList syncProfileNames = mSyncProfileNames; |
582 | KSyncProfile* temp = new KSyncProfile (); | 582 | KSyncProfile* temp = new KSyncProfile (); |
583 | mAskForPreferences = false; | 583 | mAskForPreferences = false; |
584 | mCurrentResourceLocal = ""; | 584 | mCurrentResourceLocal = ""; |
585 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 585 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
586 | mCurrentSyncProfile = i; | 586 | mCurrentSyncProfile = i; |
587 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 587 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
588 | temp->readConfig(&config); | 588 | temp->readConfig(&config); |
589 | 589 | ||
590 | bool includeInRingSync = false; | 590 | bool includeInRingSync = false; |
591 | switch(mTargetApp) | 591 | switch(mTargetApp) |
592 | { | 592 | { |
593 | case (KAPI): | 593 | case (KAPI): |
594 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 594 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
595 | break; | 595 | break; |
596 | case (KOPI): | 596 | case (KOPI): |
597 | includeInRingSync = temp->getIncludeInRingSync(); | 597 | includeInRingSync = temp->getIncludeInRingSync(); |
598 | break; | 598 | break; |
599 | case (PWMPI): | 599 | case (PWMPI): |
600 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 600 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
601 | break; | 601 | break; |
602 | default: | 602 | default: |
603 | qDebug("KSM::ringSync: invalid apptype selected"); | 603 | qDebug("KSM::ringSync: invalid apptype selected"); |
604 | break; | 604 | break; |
605 | 605 | ||
606 | } | 606 | } |
607 | 607 | ||
608 | 608 | ||
609 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 609 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
610 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 610 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
611 | ++syncedProfiles; | 611 | ++syncedProfiles; |
612 | mSyncWithDesktop = false; | 612 | mSyncWithDesktop = false; |
613 | // mAskForPreferences = temp->getAskForPreferences(); | 613 | // mAskForPreferences = temp->getAskForPreferences(); |
614 | mWriteBackFile = temp->getWriteBackFile(); | 614 | mWriteBackFile = temp->getWriteBackFile(); |
615 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 615 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
616 | mIsKapiFile = temp->getIsKapiFile(); | 616 | mIsKapiFile = temp->getIsKapiFile(); |
617 | mWriteBackInFuture = 0; | 617 | mWriteBackInFuture = 0; |
618 | if ( temp->getWriteBackFuture() ) { | 618 | if ( temp->getWriteBackFuture() ) { |
619 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 619 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
620 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 620 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
621 | } | 621 | } |
622 | mFilterInCal = temp->getFilterInCal(); | 622 | mFilterInCal = temp->getFilterInCal(); |
623 | mFilterOutCal = temp->getFilterOutCal(); | 623 | mFilterOutCal = temp->getFilterOutCal(); |
624 | mFilterInAB = temp->getFilterInAB(); | 624 | mFilterInAB = temp->getFilterInAB(); |
625 | mFilterOutAB = temp->getFilterOutAB(); | 625 | mFilterOutAB = temp->getFilterOutAB(); |
626 | mShowSyncSummary = false; | 626 | mShowSyncSummary = false; |
627 | mCurrentSyncDevice = syncProfileNames[i] ; | 627 | mCurrentSyncDevice = syncProfileNames[i] ; |
628 | mCurrentSyncName = mLocalMachineName; | 628 | mCurrentSyncName = mLocalMachineName; |
629 | if ( i == 0 ) { | 629 | if ( i == 0 ) { |
630 | mIsKapiFile = false; | 630 | mIsKapiFile = false; |
631 | #ifdef DESKTOP_VERSION | 631 | #ifdef DESKTOP_VERSION |
632 | syncKDE(); | 632 | syncKDE(); |
633 | #else | 633 | #else |
634 | syncSharp(); | 634 | syncSharp(); |
635 | #endif | 635 | #endif |
636 | } else { | 636 | } else { |
637 | if ( temp->getIsLocalFileSync() ) { | 637 | if ( temp->getIsLocalFileSync() ) { |