summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2005-01-26 00:32:18 (UTC)
committer zautrix <zautrix>2005-01-26 00:32:18 (UTC)
commitc3ec0a5a43fb328f2d190b8adee1ef662746fb41 (patch) (unidiff)
treedd34f587205f8567a59bf7abb6161e1ba6667444 /kaddressbook
parenteeb9059d1cbf2ffb13300d0491b4b61126507373 (diff)
downloadkdepimpi-c3ec0a5a43fb328f2d190b8adee1ef662746fb41.zip
kdepimpi-c3ec0a5a43fb328f2d190b8adee1ef662746fb41.tar.gz
kdepimpi-c3ec0a5a43fb328f2d190b8adee1ef662746fb41.tar.bz2
debug fixes
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 590cc82..ae0a068 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -334,334 +334,334 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const
334 // values can be "female" or "male" or "". An empty field represents undefined. 334 // values can be "female" or "male" or "". An empty field represents undefined.
335 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 335 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
336 "X-Gender", "KADDRESSBOOK" ); 336 "X-Gender", "KADDRESSBOOK" );
337 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 337 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
338 "X-Children", "KADDRESSBOOK" ); 338 "X-Children", "KADDRESSBOOK" );
339 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 339 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
340 "X-FreeBusyUrl", "KADDRESSBOOK" ); 340 "X-FreeBusyUrl", "KADDRESSBOOK" );
341#endif 341#endif
342 initGUI(); 342 initGUI();
343 343
344 mIncSearchWidget->setFocus(); 344 mIncSearchWidget->setFocus();
345 345
346 346
347 connect( mViewManager, SIGNAL( selected( const QString& ) ), 347 connect( mViewManager, SIGNAL( selected( const QString& ) ),
348 SLOT( setContactSelected( const QString& ) ) ); 348 SLOT( setContactSelected( const QString& ) ) );
349 connect( mViewManager, SIGNAL( executed( const QString& ) ), 349 connect( mViewManager, SIGNAL( executed( const QString& ) ),
350 SLOT( executeContact( const QString& ) ) ); 350 SLOT( executeContact( const QString& ) ) );
351 351
352 connect( mViewManager, SIGNAL( deleteRequest( ) ), 352 connect( mViewManager, SIGNAL( deleteRequest( ) ),
353 SLOT( deleteContacts( ) ) ); 353 SLOT( deleteContacts( ) ) );
354 connect( mViewManager, SIGNAL( modified() ), 354 connect( mViewManager, SIGNAL( modified() ),
355 SLOT( setModified() ) ); 355 SLOT( setModified() ) );
356 356
357 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 357 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
358 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 358 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
359 359
360 connect( mXXPortManager, SIGNAL( modified() ), 360 connect( mXXPortManager, SIGNAL( modified() ),
361 SLOT( setModified() ) ); 361 SLOT( setModified() ) );
362 362
363 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 363 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
364 SLOT( incrementalSearch( const QString& ) ) ); 364 SLOT( incrementalSearch( const QString& ) ) );
365 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 365 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
366 mJumpButtonBar, SLOT( recreateButtons() ) ); 366 mJumpButtonBar, SLOT( recreateButtons() ) );
367 367
368 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 368 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
369 SLOT( sendMail( const QString& ) ) ); 369 SLOT( sendMail( const QString& ) ) );
370 370
371 371
372 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 372 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
373 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 373 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
374 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 374 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
375 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 375 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
376 376
377 377
378#ifndef KAB_EMBEDDED 378#ifndef KAB_EMBEDDED
379 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 379 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
380 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 380 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
381 381
382 connect( mDetails, SIGNAL( browse( const QString& ) ), 382 connect( mDetails, SIGNAL( browse( const QString& ) ),
383 SLOT( browse( const QString& ) ) ); 383 SLOT( browse( const QString& ) ) );
384 384
385 385
386 mAddressBookService = new KAddressBookService( this ); 386 mAddressBookService = new KAddressBookService( this );
387 387
388#endif //KAB_EMBEDDED 388#endif //KAB_EMBEDDED
389 389
390 mMessageTimer = new QTimer( this ); 390 mMessageTimer = new QTimer( this );
391 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 391 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
392 mEditorDialog = 0; 392 mEditorDialog = 0;
393 createAddresseeEditorDialog( this ); 393 createAddresseeEditorDialog( this );
394 setModified( false ); 394 setModified( false );
395 mBRdisabled = false; 395 mBRdisabled = false;
396#ifndef DESKTOP_VERSION 396#ifndef DESKTOP_VERSION
397 infrared = 0; 397 infrared = 0;
398#endif 398#endif
399 //toggleBeamReceive( ); 399 //toggleBeamReceive( );
400 //mMainWindow->toolBar()->show(); 400 //mMainWindow->toolBar()->show();
401 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 401 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
402 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 402 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
403} 403}
404 404
405void KABCore::updateToolBar() 405void KABCore::updateToolBar()
406{ 406{
407 static int iii = 0; 407 static int iii = 0;
408 ++iii; 408 ++iii;
409 mMainWindow->toolBar()->repaintMe(); 409 mMainWindow->toolBar()->repaintMe();
410 if ( iii < 3 ) 410 if ( iii < 3 )
411 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 411 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
412} 412}
413KABCore::~KABCore() 413KABCore::~KABCore()
414{ 414{
415 // save(); 415 // save();
416 //saveSettings(); 416 //saveSettings();
417 //KABPrefs::instance()->writeConfig(); 417 //KABPrefs::instance()->writeConfig();
418 delete AddresseeConfig::instance(); 418 delete AddresseeConfig::instance();
419 mAddressBook = 0; 419 mAddressBook = 0;
420 KABC::StdAddressBook::close(); 420 KABC::StdAddressBook::close();
421 421
422 delete syncManager; 422 delete syncManager;
423#ifndef DESKTOP_VERSION 423#ifndef DESKTOP_VERSION
424 if ( infrared ) 424 if ( infrared )
425 delete infrared; 425 delete infrared;
426#endif 426#endif
427} 427}
428void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 428void KABCore::receive( const QCString& cmsg, const QByteArray& data )
429{ 429{
430 qDebug("KA: QCOP message received: %s ", cmsg.data() ); 430 //qDebug("KA: QCOP message received: %s ", cmsg.data() );
431 if ( cmsg == "setDocument(QString)" ) { 431 if ( cmsg == "setDocument(QString)" ) {
432 QDataStream stream( data, IO_ReadOnly ); 432 QDataStream stream( data, IO_ReadOnly );
433 QString fileName; 433 QString fileName;
434 stream >> fileName; 434 stream >> fileName;
435 recieve( fileName ); 435 recieve( fileName );
436 return; 436 return;
437 } 437 }
438} 438}
439void KABCore::toggleBeamReceive( ) 439void KABCore::toggleBeamReceive( )
440{ 440{
441 if ( mBRdisabled ) 441 if ( mBRdisabled )
442 return; 442 return;
443#ifndef DESKTOP_VERSION 443#ifndef DESKTOP_VERSION
444 if ( infrared ) { 444 if ( infrared ) {
445 qDebug("AB disable BeamReceive "); 445 qDebug("KA: AB disable BeamReceive ");
446 delete infrared; 446 delete infrared;
447 infrared = 0; 447 infrared = 0;
448 mActionBR->setChecked(false); 448 mActionBR->setChecked(false);
449 return; 449 return;
450 } 450 }
451 qDebug("AB enable BeamReceive "); 451 qDebug("KA: AB enable BeamReceive ");
452 mActionBR->setChecked(true); 452 mActionBR->setChecked(true);
453 453
454 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 454 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
455 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 455 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
456#endif 456#endif
457} 457}
458 458
459 459
460void KABCore::disableBR(bool b) 460void KABCore::disableBR(bool b)
461{ 461{
462#ifndef DESKTOP_VERSION 462#ifndef DESKTOP_VERSION
463 if ( b ) { 463 if ( b ) {
464 if ( infrared ) { 464 if ( infrared ) {
465 toggleBeamReceive( ); 465 toggleBeamReceive( );
466 } 466 }
467 mBRdisabled = true; 467 mBRdisabled = true;
468 } else { 468 } else {
469 if ( mBRdisabled ) { 469 if ( mBRdisabled ) {
470 mBRdisabled = false; 470 mBRdisabled = false;
471 //toggleBeamReceive( ); 471 //toggleBeamReceive( );
472 } 472 }
473 } 473 }
474#endif 474#endif
475 475
476} 476}
477void KABCore::recieve( QString fn ) 477void KABCore::recieve( QString fn )
478{ 478{
479 //qDebug("KABCore::recieve "); 479 //qDebug("KABCore::recieve ");
480 int count = mAddressBook->importFromFile( fn, true ); 480 int count = mAddressBook->importFromFile( fn, true );
481 if ( count ) 481 if ( count )
482 setModified( true ); 482 setModified( true );
483 mViewManager->refreshView(); 483 mViewManager->refreshView();
484 message(i18n("%1 contact(s) received!").arg( count )); 484 message(i18n("%1 contact(s) received!").arg( count ));
485 topLevelWidget()->showMaximized(); 485 topLevelWidget()->showMaximized();
486 topLevelWidget()->raise(); 486 topLevelWidget()->raise();
487} 487}
488void KABCore::restoreSettings() 488void KABCore::restoreSettings()
489{ 489{
490 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 490 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
491 491
492 bool state; 492 bool state;
493 493
494 if (mMultipleViewsAtOnce) 494 if (mMultipleViewsAtOnce)
495 state = KABPrefs::instance()->mDetailsPageVisible; 495 state = KABPrefs::instance()->mDetailsPageVisible;
496 else 496 else
497 state = false; 497 state = false;
498 498
499 mActionDetails->setChecked( state ); 499 mActionDetails->setChecked( state );
500 setDetailsVisible( state ); 500 setDetailsVisible( state );
501 501
502 state = KABPrefs::instance()->mJumpButtonBarVisible; 502 state = KABPrefs::instance()->mJumpButtonBarVisible;
503 503
504 mActionJumpBar->setChecked( state ); 504 mActionJumpBar->setChecked( state );
505 setJumpButtonBarVisible( state ); 505 setJumpButtonBarVisible( state );
506/*US 506/*US
507 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 507 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
508 if ( splitterSize.count() == 0 ) { 508 if ( splitterSize.count() == 0 ) {
509 splitterSize.append( width() / 2 ); 509 splitterSize.append( width() / 2 );
510 splitterSize.append( width() / 2 ); 510 splitterSize.append( width() / 2 );
511 } 511 }
512 mMiniSplitter->setSizes( splitterSize ); 512 mMiniSplitter->setSizes( splitterSize );
513 if ( mExtensionBarSplitter ) { 513 if ( mExtensionBarSplitter ) {
514 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 514 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
515 if ( splitterSize.count() == 0 ) { 515 if ( splitterSize.count() == 0 ) {
516 splitterSize.append( width() / 2 ); 516 splitterSize.append( width() / 2 );
517 splitterSize.append( width() / 2 ); 517 splitterSize.append( width() / 2 );
518 } 518 }
519 mExtensionBarSplitter->setSizes( splitterSize ); 519 mExtensionBarSplitter->setSizes( splitterSize );
520 520
521 } 521 }
522*/ 522*/
523 mViewManager->restoreSettings(); 523 mViewManager->restoreSettings();
524 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 524 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
525 mExtensionManager->restoreSettings(); 525 mExtensionManager->restoreSettings();
526#ifdef DESKTOP_VERSION 526#ifdef DESKTOP_VERSION
527 int wid = width(); 527 int wid = width();
528 if ( wid < 10 ) 528 if ( wid < 10 )
529 wid = 400; 529 wid = 400;
530#else 530#else
531 int wid = QApplication::desktop()->width(); 531 int wid = QApplication::desktop()->width();
532 if ( wid < 640 ) 532 if ( wid < 640 )
533 wid = QApplication::desktop()->height(); 533 wid = QApplication::desktop()->height();
534#endif 534#endif
535 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 535 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
536 if ( true /*splitterSize.count() == 0*/ ) { 536 if ( true /*splitterSize.count() == 0*/ ) {
537 splitterSize.append( wid / 2 ); 537 splitterSize.append( wid / 2 );
538 splitterSize.append( wid / 2 ); 538 splitterSize.append( wid / 2 );
539 } 539 }
540 mMiniSplitter->setSizes( splitterSize ); 540 mMiniSplitter->setSizes( splitterSize );
541 if ( mExtensionBarSplitter ) { 541 if ( mExtensionBarSplitter ) {
542 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 542 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
543 if ( true /*splitterSize.count() == 0*/ ) { 543 if ( true /*splitterSize.count() == 0*/ ) {
544 splitterSize.append( wid / 2 ); 544 splitterSize.append( wid / 2 );
545 splitterSize.append( wid / 2 ); 545 splitterSize.append( wid / 2 );
546 } 546 }
547 mExtensionBarSplitter->setSizes( splitterSize ); 547 mExtensionBarSplitter->setSizes( splitterSize );
548 548
549 } 549 }
550 550
551 551
552} 552}
553 553
554void KABCore::saveSettings() 554void KABCore::saveSettings()
555{ 555{
556 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 556 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
557 if ( mExtensionBarSplitter ) 557 if ( mExtensionBarSplitter )
558 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 558 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
559 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 559 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
560 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 560 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
561#ifndef KAB_EMBEDDED 561#ifndef KAB_EMBEDDED
562 562
563 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 563 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
564 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 564 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
565#endif //KAB_EMBEDDED 565#endif //KAB_EMBEDDED
566 mExtensionManager->saveSettings(); 566 mExtensionManager->saveSettings();
567 mViewManager->saveSettings(); 567 mViewManager->saveSettings();
568 568
569 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 569 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
570 KABPrefs::instance()->writeConfig(); 570 KABPrefs::instance()->writeConfig();
571 qDebug("KABCore::saveSettings() "); 571 qDebug("KA: KABCore::saveSettings() ");
572} 572}
573 573
574KABC::AddressBook *KABCore::addressBook() const 574KABC::AddressBook *KABCore::addressBook() const
575{ 575{
576 return mAddressBook; 576 return mAddressBook;
577} 577}
578 578
579KConfig *KABCore::config() 579KConfig *KABCore::config()
580{ 580{
581#ifndef KAB_EMBEDDED 581#ifndef KAB_EMBEDDED
582 return KABPrefs::instance()->config(); 582 return KABPrefs::instance()->config();
583#else //KAB_EMBEDDED 583#else //KAB_EMBEDDED
584 return KABPrefs::instance()->getConfig(); 584 return KABPrefs::instance()->getConfig();
585#endif //KAB_EMBEDDED 585#endif //KAB_EMBEDDED
586} 586}
587 587
588KActionCollection *KABCore::actionCollection() const 588KActionCollection *KABCore::actionCollection() const
589{ 589{
590 return mGUIClient->actionCollection(); 590 return mGUIClient->actionCollection();
591} 591}
592 592
593KABC::Field *KABCore::currentSearchField() const 593KABC::Field *KABCore::currentSearchField() const
594{ 594{
595 if (mIncSearchWidget) 595 if (mIncSearchWidget)
596 return mIncSearchWidget->currentField(); 596 return mIncSearchWidget->currentField();
597 else 597 else
598 return 0; 598 return 0;
599} 599}
600 600
601QStringList KABCore::selectedUIDs() const 601QStringList KABCore::selectedUIDs() const
602{ 602{
603 return mViewManager->selectedUids(); 603 return mViewManager->selectedUids();
604} 604}
605 605
606KABC::Resource *KABCore::requestResource( QWidget *parent ) 606KABC::Resource *KABCore::requestResource( QWidget *parent )
607{ 607{
608 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 608 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
609 609
610 QPtrList<KRES::Resource> kresResources; 610 QPtrList<KRES::Resource> kresResources;
611 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 611 QPtrListIterator<KABC::Resource> resIt( kabcResources );
612 KABC::Resource *resource; 612 KABC::Resource *resource;
613 while ( ( resource = resIt.current() ) != 0 ) { 613 while ( ( resource = resIt.current() ) != 0 ) {
614 ++resIt; 614 ++resIt;
615 if ( !resource->readOnly() ) { 615 if ( !resource->readOnly() ) {
616 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 616 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
617 if ( res ) 617 if ( res )
618 kresResources.append( res ); 618 kresResources.append( res );
619 } 619 }
620 } 620 }
621 621
622 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 622 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
623 return static_cast<KABC::Resource*>( res ); 623 return static_cast<KABC::Resource*>( res );
624} 624}
625 625
626#ifndef KAB_EMBEDDED 626#ifndef KAB_EMBEDDED
627KAboutData *KABCore::createAboutData() 627KAboutData *KABCore::createAboutData()
628#else //KAB_EMBEDDED 628#else //KAB_EMBEDDED
629void KABCore::createAboutData() 629void KABCore::createAboutData()
630#endif //KAB_EMBEDDED 630#endif //KAB_EMBEDDED
631{ 631{
632#ifndef KAB_EMBEDDED 632#ifndef KAB_EMBEDDED
633 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 633 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
634 "3.1", I18N_NOOP( "The KDE Address Book" ), 634 "3.1", I18N_NOOP( "The KDE Address Book" ),
635 KAboutData::License_GPL_V2, 635 KAboutData::License_GPL_V2,
636 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 636 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
637 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 637 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
638 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 638 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
639 about->addAuthor( "Cornelius Schumacher", 639 about->addAuthor( "Cornelius Schumacher",
640 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 640 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
641 "schumacher@kde.org" ); 641 "schumacher@kde.org" );
642 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 642 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
643 "mpilone@slac.com" ); 643 "mpilone@slac.com" );
644 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 644 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
645 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 645 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
646 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 646 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
647 "michel@klaralvdalens-datakonsult.se" ); 647 "michel@klaralvdalens-datakonsult.se" );
648 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 648 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
649 "hansen@kde.org" ); 649 "hansen@kde.org" );
650 650
651 return about; 651 return about;
652#endif //KAB_EMBEDDED 652#endif //KAB_EMBEDDED
653 653
654 QString version; 654 QString version;
655#include <../version> 655#include <../version>
656 QMessageBox::about( this, "About KAddressbook/Pi", 656 QMessageBox::about( this, "About KAddressbook/Pi",
657 "KAddressbook/Platform-independent\n" 657 "KAddressbook/Platform-independent\n"
658 "(KA/Pi) " +version + " - " + 658 "(KA/Pi) " +version + " - " +
659#ifdef DESKTOP_VERSION 659#ifdef DESKTOP_VERSION
660 "Desktop Edition\n" 660 "Desktop Edition\n"
661#else 661#else
662 "PDA-Edition\n" 662 "PDA-Edition\n"
663 "for: Zaurus 5500 / 7x0 / 8x0\n" 663 "for: Zaurus 5500 / 7x0 / 8x0\n"
664#endif 664#endif
665 665
666 "(c) 2004 Ulf Schenk\n" 666 "(c) 2004 Ulf Schenk\n"
667 "(c) 2004 Lutz Rogowski\n" 667 "(c) 2004 Lutz Rogowski\n"
@@ -813,264 +813,264 @@ void KABCore::beamMySelf()
813 beamVCard(uids); 813 beamVCard(uids);
814 } else { 814 } else {
815 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 815 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
816 816
817 817
818 } 818 }
819} 819}
820void KABCore::updateMainWindow() 820void KABCore::updateMainWindow()
821{ 821{
822 822
823 mMainWindow->showMaximized(); 823 mMainWindow->showMaximized();
824 mMainWindow->update(); 824 mMainWindow->update();
825} 825}
826void KABCore::resizeEvent(QResizeEvent* e ) 826void KABCore::resizeEvent(QResizeEvent* e )
827{ 827{
828 if ( !mMiniSplitter ) 828 if ( !mMiniSplitter )
829 return; 829 return;
830 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); 830 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) ");
831 if ( QApplication::desktop()->width() >= 480 ) { 831 if ( QApplication::desktop()->width() >= 480 ) {
832 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 832 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
833 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 833 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
834 mMiniSplitter->setOrientation( Qt::Horizontal); 834 mMiniSplitter->setOrientation( Qt::Horizontal);
835 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 835 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
836 if ( QApplication::desktop()->width() <= 640 ) { 836 if ( QApplication::desktop()->width() <= 640 ) {
837 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 837 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
838 mViewManager->getFilterAction()->setComboWidth( 150 ); 838 mViewManager->getFilterAction()->setComboWidth( 150 );
839 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 839 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
840 } 840 }
841 } 841 }
842 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 842 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
843 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 843 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
844 mMiniSplitter->setOrientation( Qt::Vertical ); 844 mMiniSplitter->setOrientation( Qt::Vertical );
845 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 845 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
846 if ( QApplication::desktop()->width() <= 640 ) { 846 if ( QApplication::desktop()->width() <= 640 ) {
847 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 847 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
848 mMainWindow->showMinimized(); 848 mMainWindow->showMinimized();
849 mViewManager->getFilterAction()->setComboWidth( 0 ); 849 mViewManager->getFilterAction()->setComboWidth( 0 );
850 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 850 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
851 } 851 }
852 } 852 }
853 } 853 }
854 } 854 }
855 855
856} 856}
857void KABCore::export2phone() 857void KABCore::export2phone()
858{ 858{
859 859
860 QStringList uids; 860 QStringList uids;
861 XXPortSelectDialog dlg( this, false, this ); 861 XXPortSelectDialog dlg( this, false, this );
862 if ( dlg.exec() ) 862 if ( dlg.exec() )
863 uids = dlg.uids(); 863 uids = dlg.uids();
864 else 864 else
865 return; 865 return;
866 if ( uids.isEmpty() ) 866 if ( uids.isEmpty() )
867 return; 867 return;
868 // qDebug("count %d ", uids.count()); 868 // qDebug("count %d ", uids.count());
869 869
870 KAex2phonePrefs ex2phone; 870 KAex2phonePrefs ex2phone;
871 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 871 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
872 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 872 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
873 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 873 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
874 874
875 if ( !ex2phone.exec() ) { 875 if ( !ex2phone.exec() ) {
876 return; 876 return;
877 } 877 }
878 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 878 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
879 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 879 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
880 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 880 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
881 881
882 882
883 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 883 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
884 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 884 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
885 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 885 KPimGlobalPrefs::instance()->mEx2PhoneModel );
886 886
887 QString fileName = getPhoneFile(); 887 QString fileName = getPhoneFile();
888 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 888 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
889 return; 889 return;
890 890
891 message(i18n("Exporting to phone...")); 891 message(i18n("Exporting to phone..."));
892 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 892 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
893 893
894} 894}
895QString KABCore::getPhoneFile() 895QString KABCore::getPhoneFile()
896{ 896{
897#ifdef DESKTOP_VERSION 897#ifdef DESKTOP_VERSION
898 return locateLocal("tmp", "phonefile.vcf"); 898 return locateLocal("tmp", "phonefile.vcf");
899#else 899#else
900 return "/tmp/phonefile.vcf"; 900 return "/tmp/phonefile.vcf";
901#endif 901#endif
902 902
903} 903}
904void KABCore::writeToPhone( ) 904void KABCore::writeToPhone( )
905{ 905{
906 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 906 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
907 message(i18n("Export to phone finished!")); 907 message(i18n("Export to phone finished!"));
908 else 908 else
909 qDebug(i18n("Error exporting to phone")); 909 qDebug(i18n("KA: Error exporting to phone"));
910} 910}
911void KABCore::beamVCard() 911void KABCore::beamVCard()
912{ 912{
913 QStringList uids; 913 QStringList uids;
914 XXPortSelectDialog dlg( this, false, this ); 914 XXPortSelectDialog dlg( this, false, this );
915 if ( dlg.exec() ) 915 if ( dlg.exec() )
916 uids = dlg.uids(); 916 uids = dlg.uids();
917 else 917 else
918 return; 918 return;
919 if ( uids.isEmpty() ) 919 if ( uids.isEmpty() )
920 return; 920 return;
921 beamVCard( uids ); 921 beamVCard( uids );
922} 922}
923 923
924 924
925void KABCore::beamVCard(const QStringList& uids) 925void KABCore::beamVCard(const QStringList& uids)
926{ 926{
927 927
928 // LR: we should use the /tmp dir on the Zaurus, 928 // LR: we should use the /tmp dir on the Zaurus,
929 // because: /tmp = RAM, (HOME)/kdepim = flash memory 929 // because: /tmp = RAM, (HOME)/kdepim = flash memory
930 930
931#ifdef DESKTOP_VERSION 931#ifdef DESKTOP_VERSION
932 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 932 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
933#else 933#else
934 QString fileName = "/tmp/kapibeamfile.vcf"; 934 QString fileName = "/tmp/kapibeamfile.vcf";
935#endif 935#endif
936 936
937 KABC::VCardConverter converter; 937 KABC::VCardConverter converter;
938 QString description; 938 QString description;
939 QString datastream; 939 QString datastream;
940 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 940 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
941 KABC::Addressee a = mAddressBook->findByUid( *it ); 941 KABC::Addressee a = mAddressBook->findByUid( *it );
942 942
943 if ( a.isEmpty() ) 943 if ( a.isEmpty() )
944 continue; 944 continue;
945 945
946 if (description.isEmpty()) 946 if (description.isEmpty())
947 description = a.formattedName(); 947 description = a.formattedName();
948 948
949 QString vcard; 949 QString vcard;
950 converter.addresseeToVCard( a, vcard ); 950 converter.addresseeToVCard( a, vcard );
951 int start = 0; 951 int start = 0;
952 int next; 952 int next;
953 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 953 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
954 int semi = vcard.find(";", next); 954 int semi = vcard.find(";", next);
955 int dopp = vcard.find(":", next); 955 int dopp = vcard.find(":", next);
956 int sep; 956 int sep;
957 if ( semi < dopp && semi >= 0 ) 957 if ( semi < dopp && semi >= 0 )
958 sep = semi ; 958 sep = semi ;
959 else 959 else
960 sep = dopp; 960 sep = dopp;
961 datastream +=vcard.mid( start, next - start); 961 datastream +=vcard.mid( start, next - start);
962 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 962 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
963 start = sep; 963 start = sep;
964 } 964 }
965 datastream += vcard.mid( start,vcard.length() ); 965 datastream += vcard.mid( start,vcard.length() );
966 } 966 }
967#ifndef DESKTOP_VERSION 967#ifndef DESKTOP_VERSION
968 QFile outFile(fileName); 968 QFile outFile(fileName);
969 if ( outFile.open(IO_WriteOnly) ) { 969 if ( outFile.open(IO_WriteOnly) ) {
970 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 970 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
971 QTextStream t( &outFile ); // use a text stream 971 QTextStream t( &outFile ); // use a text stream
972 //t.setEncoding( QTextStream::UnicodeUTF8 ); 972 //t.setEncoding( QTextStream::UnicodeUTF8 );
973 t.setEncoding( QTextStream::Latin1 ); 973 t.setEncoding( QTextStream::Latin1 );
974 t <<datastream.latin1(); 974 t <<datastream.latin1();
975 outFile.close(); 975 outFile.close();
976 Ir *ir = new Ir( this ); 976 Ir *ir = new Ir( this );
977 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 977 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
978 ir->send( fileName, description, "text/x-vCard" ); 978 ir->send( fileName, description, "text/x-vCard" );
979 } else { 979 } else {
980 qDebug("Error open temp beam file "); 980 qDebug("KA: Error open temp beam file ");
981 return; 981 return;
982 } 982 }
983#endif 983#endif
984 984
985} 985}
986 986
987void KABCore::beamDone( Ir *ir ) 987void KABCore::beamDone( Ir *ir )
988{ 988{
989#ifndef DESKTOP_VERSION 989#ifndef DESKTOP_VERSION
990 delete ir; 990 delete ir;
991#endif 991#endif
992 topLevelWidget()->raise(); 992 topLevelWidget()->raise();
993 message( i18n("Beaming finished!") ); 993 message( i18n("Beaming finished!") );
994} 994}
995 995
996 996
997void KABCore::browse( const QString& url ) 997void KABCore::browse( const QString& url )
998{ 998{
999#ifndef KAB_EMBEDDED 999#ifndef KAB_EMBEDDED
1000 kapp->invokeBrowser( url ); 1000 kapp->invokeBrowser( url );
1001#else //KAB_EMBEDDED 1001#else //KAB_EMBEDDED
1002 qDebug("KABCore::browse must be fixed"); 1002 qDebug("KABCore::browse must be fixed");
1003#endif //KAB_EMBEDDED 1003#endif //KAB_EMBEDDED
1004} 1004}
1005 1005
1006void KABCore::selectAllContacts() 1006void KABCore::selectAllContacts()
1007{ 1007{
1008 mViewManager->setSelected( QString::null, true ); 1008 mViewManager->setSelected( QString::null, true );
1009} 1009}
1010 1010
1011void KABCore::deleteContacts() 1011void KABCore::deleteContacts()
1012{ 1012{
1013 QStringList uidList = mViewManager->selectedUids(); 1013 QStringList uidList = mViewManager->selectedUids();
1014 deleteContacts( uidList ); 1014 deleteContacts( uidList );
1015} 1015}
1016 1016
1017void KABCore::deleteContacts( const QStringList &uids ) 1017void KABCore::deleteContacts( const QStringList &uids )
1018{ 1018{
1019 if ( uids.count() > 0 ) { 1019 if ( uids.count() > 0 ) {
1020 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1020 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1021 UndoStack::instance()->push( command ); 1021 UndoStack::instance()->push( command );
1022 RedoStack::instance()->clear(); 1022 RedoStack::instance()->clear();
1023 1023
1024 // now if we deleted anything, refresh 1024 // now if we deleted anything, refresh
1025 setContactSelected( QString::null ); 1025 setContactSelected( QString::null );
1026 setModified( true ); 1026 setModified( true );
1027 } 1027 }
1028} 1028}
1029 1029
1030void KABCore::copyContacts() 1030void KABCore::copyContacts()
1031{ 1031{
1032 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1032 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1033 1033
1034 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1034 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1035 1035
1036 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1036 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1037 1037
1038 QClipboard *cb = QApplication::clipboard(); 1038 QClipboard *cb = QApplication::clipboard();
1039 cb->setText( clipText ); 1039 cb->setText( clipText );
1040} 1040}
1041 1041
1042void KABCore::cutContacts() 1042void KABCore::cutContacts()
1043{ 1043{
1044 QStringList uidList = mViewManager->selectedUids(); 1044 QStringList uidList = mViewManager->selectedUids();
1045 1045
1046//US if ( uidList.size() > 0 ) { 1046//US if ( uidList.size() > 0 ) {
1047 if ( uidList.count() > 0 ) { 1047 if ( uidList.count() > 0 ) {
1048 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1048 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1049 UndoStack::instance()->push( command ); 1049 UndoStack::instance()->push( command );
1050 RedoStack::instance()->clear(); 1050 RedoStack::instance()->clear();
1051 1051
1052 setModified( true ); 1052 setModified( true );
1053 } 1053 }
1054} 1054}
1055 1055
1056void KABCore::pasteContacts() 1056void KABCore::pasteContacts()
1057{ 1057{
1058 QClipboard *cb = QApplication::clipboard(); 1058 QClipboard *cb = QApplication::clipboard();
1059 1059
1060 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1060 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1061 1061
1062 pasteContacts( list ); 1062 pasteContacts( list );
1063} 1063}
1064 1064
1065void KABCore::pasteContacts( KABC::Addressee::List &list ) 1065void KABCore::pasteContacts( KABC::Addressee::List &list )
1066{ 1066{
1067 KABC::Resource *resource = requestResource( this ); 1067 KABC::Resource *resource = requestResource( this );
1068 KABC::Addressee::List::Iterator it; 1068 KABC::Addressee::List::Iterator it;
1069 for ( it = list.begin(); it != list.end(); ++it ) 1069 for ( it = list.begin(); it != list.end(); ++it )
1070 (*it).setResource( resource ); 1070 (*it).setResource( resource );
1071 1071
1072 PwPasteCommand *command = new PwPasteCommand( this, list ); 1072 PwPasteCommand *command = new PwPasteCommand( this, list );
1073 UndoStack::instance()->push( command ); 1073 UndoStack::instance()->push( command );
1074 RedoStack::instance()->clear(); 1074 RedoStack::instance()->clear();
1075 1075
1076 setModified( true ); 1076 setModified( true );
@@ -2591,372 +2591,372 @@ void KABCore::requestForDetails(const QString& sourceChannel, const QString& ses
2591 if ( email == "sendbacklist" ) 2591 if ( email == "sendbacklist" )
2592 return; 2592 return;
2593 if (foundUid.isEmpty()) 2593 if (foundUid.isEmpty())
2594 { 2594 {
2595 //find the uid of the person first 2595 //find the uid of the person first
2596 Addressee::List namelist; 2596 Addressee::List namelist;
2597 Addressee::List emaillist; 2597 Addressee::List emaillist;
2598 2598
2599 if (!name.isEmpty()) 2599 if (!name.isEmpty())
2600 namelist = mAddressBook->findByName( name ); 2600 namelist = mAddressBook->findByName( name );
2601 2601
2602 if (!email.isEmpty()) 2602 if (!email.isEmpty())
2603 emaillist = mAddressBook->findByEmail( email ); 2603 emaillist = mAddressBook->findByEmail( email );
2604 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2604 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2605 //check if we have a match in Namelist and Emaillist 2605 //check if we have a match in Namelist and Emaillist
2606 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2606 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2607 foundUid = emaillist[0].uid(); 2607 foundUid = emaillist[0].uid();
2608 } 2608 }
2609 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2609 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2610 foundUid = namelist[0].uid(); 2610 foundUid = namelist[0].uid();
2611 else 2611 else
2612 { 2612 {
2613 for (int i = 0; i < namelist.count(); i++) 2613 for (int i = 0; i < namelist.count(); i++)
2614 { 2614 {
2615 for (int j = 0; j < emaillist.count(); j++) 2615 for (int j = 0; j < emaillist.count(); j++)
2616 { 2616 {
2617 if (namelist[i] == emaillist[j]) 2617 if (namelist[i] == emaillist[j])
2618 { 2618 {
2619 foundUid = namelist[i].uid(); 2619 foundUid = namelist[i].uid();
2620 } 2620 }
2621 } 2621 }
2622 } 2622 }
2623 } 2623 }
2624 } 2624 }
2625 else 2625 else
2626 { 2626 {
2627 foundUid = uid; 2627 foundUid = uid;
2628 } 2628 }
2629 2629
2630 if (!foundUid.isEmpty()) 2630 if (!foundUid.isEmpty())
2631 { 2631 {
2632 2632
2633 // raise Ka/Pi if it is in the background 2633 // raise Ka/Pi if it is in the background
2634#ifndef DESKTOP_VERSION 2634#ifndef DESKTOP_VERSION
2635#ifndef KORG_NODCOP 2635#ifndef KORG_NODCOP
2636 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2636 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2637#endif 2637#endif
2638#endif 2638#endif
2639 2639
2640 mMainWindow->showMaximized(); 2640 mMainWindow->showMaximized();
2641 mMainWindow-> raise(); 2641 mMainWindow-> raise();
2642 2642
2643 mViewManager->setSelected( "", false); 2643 mViewManager->setSelected( "", false);
2644 mViewManager->refreshView( "" ); 2644 mViewManager->refreshView( "" );
2645 mViewManager->setSelected( foundUid, true ); 2645 mViewManager->setSelected( foundUid, true );
2646 mViewManager->refreshView( foundUid ); 2646 mViewManager->refreshView( foundUid );
2647 2647
2648 if ( !mMultipleViewsAtOnce ) 2648 if ( !mMultipleViewsAtOnce )
2649 { 2649 {
2650 setDetailsVisible( true ); 2650 setDetailsVisible( true );
2651 mActionDetails->setChecked(true); 2651 mActionDetails->setChecked(true);
2652 } 2652 }
2653 } 2653 }
2654} 2654}
2655 2655
2656void KABCore::whatsnew() 2656void KABCore::whatsnew()
2657{ 2657{
2658 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2658 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2659} 2659}
2660void KABCore::synchowto() 2660void KABCore::synchowto()
2661{ 2661{
2662 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2662 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2663} 2663}
2664void KABCore::kdesynchowto() 2664void KABCore::kdesynchowto()
2665{ 2665{
2666 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2666 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2667} 2667}
2668void KABCore::multisynchowto() 2668void KABCore::multisynchowto()
2669{ 2669{
2670 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2670 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2671} 2671}
2672void KABCore::faq() 2672void KABCore::faq()
2673{ 2673{
2674 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2674 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2675} 2675}
2676 2676
2677#include <libkcal/syncdefines.h> 2677#include <libkcal/syncdefines.h>
2678 2678
2679KABC::Addressee KABCore::getLastSyncAddressee() 2679KABC::Addressee KABCore::getLastSyncAddressee()
2680{ 2680{
2681 Addressee lse; 2681 Addressee lse;
2682 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2682 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2683 2683
2684 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2684 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2685 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2685 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2686 if (lse.isEmpty()) { 2686 if (lse.isEmpty()) {
2687 qDebug("Creating new last-syncAddressee "); 2687 qDebug("KA: Creating new last-syncAddressee ");
2688 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2688 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2689 QString sum = ""; 2689 QString sum = "";
2690 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2690 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2691 sum = "E: "; 2691 sum = "E: ";
2692 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2692 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2693 lse.setRevision( mLastAddressbookSync ); 2693 lse.setRevision( mLastAddressbookSync );
2694 lse.setCategories( i18n("SyncEvent") ); 2694 lse.setCategories( i18n("SyncEvent") );
2695 mAddressBook->insertAddressee( lse ); 2695 mAddressBook->insertAddressee( lse );
2696 } 2696 }
2697 return lse; 2697 return lse;
2698} 2698}
2699int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2699int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2700{ 2700{
2701 2701
2702 //void setZaurusId(int id); 2702 //void setZaurusId(int id);
2703 // int zaurusId() const; 2703 // int zaurusId() const;
2704 // void setZaurusUid(int id); 2704 // void setZaurusUid(int id);
2705 // int zaurusUid() const; 2705 // int zaurusUid() const;
2706 // void setZaurusStat(int id); 2706 // void setZaurusStat(int id);
2707 // int zaurusStat() const; 2707 // int zaurusStat() const;
2708 // 0 equal 2708 // 0 equal
2709 // 1 take local 2709 // 1 take local
2710 // 2 take remote 2710 // 2 take remote
2711 // 3 cancel 2711 // 3 cancel
2712 QDateTime lastSync = mLastAddressbookSync; 2712 QDateTime lastSync = mLastAddressbookSync;
2713 QDateTime localMod = local->revision(); 2713 QDateTime localMod = local->revision();
2714 QDateTime remoteMod = remote->revision(); 2714 QDateTime remoteMod = remote->revision();
2715 2715
2716 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2716 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2717 2717
2718 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2718 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2719 bool remCh, locCh; 2719 bool remCh, locCh;
2720 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2720 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2721 if ( remCh ) 2721 //if ( remCh )
2722 qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2722 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2723 locCh = ( localMod > mLastAddressbookSync ); 2723 locCh = ( localMod > mLastAddressbookSync );
2724 //qDebug("cahnged rem %d loc %d",remCh, locCh ); 2724 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2725 if ( !remCh && ! locCh ) { 2725 if ( !remCh && ! locCh ) {
2726 //qDebug("both not changed "); 2726 //qDebug("both not changed ");
2727 lastSync = localMod.addDays(1); 2727 lastSync = localMod.addDays(1);
2728 if ( mode <= SYNC_PREF_ASK ) 2728 if ( mode <= SYNC_PREF_ASK )
2729 return 0; 2729 return 0;
2730 } else { 2730 } else {
2731 if ( locCh ) { 2731 if ( locCh ) {
2732 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2732 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2733 lastSync = localMod.addDays( -1 ); 2733 lastSync = localMod.addDays( -1 );
2734 if ( !remCh ) 2734 if ( !remCh )
2735 remoteMod =( lastSync.addDays( -1 ) ); 2735 remoteMod =( lastSync.addDays( -1 ) );
2736 } else { 2736 } else {
2737 //qDebug(" not loc changed "); 2737 //qDebug(" not loc changed ");
2738 lastSync = localMod.addDays( 1 ); 2738 lastSync = localMod.addDays( 1 );
2739 if ( remCh ) { 2739 if ( remCh ) {
2740 //qDebug("rem changed "); 2740 //qDebug("rem changed ");
2741 remoteMod =( lastSync.addDays( 1 ) ); 2741 remoteMod =( lastSync.addDays( 1 ) );
2742 } 2742 }
2743 2743
2744 } 2744 }
2745 } 2745 }
2746 full = true; 2746 full = true;
2747 if ( mode < SYNC_PREF_ASK ) 2747 if ( mode < SYNC_PREF_ASK )
2748 mode = SYNC_PREF_ASK; 2748 mode = SYNC_PREF_ASK;
2749 } else { 2749 } else {
2750 if ( localMod == remoteMod ) 2750 if ( localMod == remoteMod )
2751 return 0; 2751 return 0;
2752 2752
2753 } 2753 }
2754 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2754 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2755 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2755 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2756 //full = true; //debug only 2756 //full = true; //debug only
2757 if ( full ) { 2757 if ( full ) {
2758 bool equ = ( (*local) == (*remote) ); 2758 bool equ = ( (*local) == (*remote) );
2759 if ( equ ) { 2759 if ( equ ) {
2760 //qDebug("equal "); 2760 //qDebug("equal ");
2761 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2761 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2762 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2762 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2763 } 2763 }
2764 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2764 if ( mode < SYNC_PREF_FORCE_LOCAL )
2765 return 0; 2765 return 0;
2766 2766
2767 }//else //debug only 2767 }//else //debug only
2768 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2768 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2769 } 2769 }
2770 int result; 2770 int result;
2771 bool localIsNew; 2771 bool localIsNew;
2772 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2772 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2773 2773
2774 if ( full && mode < SYNC_PREF_NEWEST ) 2774 if ( full && mode < SYNC_PREF_NEWEST )
2775 mode = SYNC_PREF_ASK; 2775 mode = SYNC_PREF_ASK;
2776 2776
2777 switch( mode ) { 2777 switch( mode ) {
2778 case SYNC_PREF_LOCAL: 2778 case SYNC_PREF_LOCAL:
2779 if ( lastSync > remoteMod ) 2779 if ( lastSync > remoteMod )
2780 return 1; 2780 return 1;
2781 if ( lastSync > localMod ) 2781 if ( lastSync > localMod )
2782 return 2; 2782 return 2;
2783 return 1; 2783 return 1;
2784 break; 2784 break;
2785 case SYNC_PREF_REMOTE: 2785 case SYNC_PREF_REMOTE:
2786 if ( lastSync > remoteMod ) 2786 if ( lastSync > remoteMod )
2787 return 1; 2787 return 1;
2788 if ( lastSync > localMod ) 2788 if ( lastSync > localMod )
2789 return 2; 2789 return 2;
2790 return 2; 2790 return 2;
2791 break; 2791 break;
2792 case SYNC_PREF_NEWEST: 2792 case SYNC_PREF_NEWEST:
2793 if ( localMod > remoteMod ) 2793 if ( localMod > remoteMod )
2794 return 1; 2794 return 1;
2795 else 2795 else
2796 return 2; 2796 return 2;
2797 break; 2797 break;
2798 case SYNC_PREF_ASK: 2798 case SYNC_PREF_ASK:
2799 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2799 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2800 if ( lastSync > remoteMod ) 2800 if ( lastSync > remoteMod )
2801 return 1; 2801 return 1;
2802 if ( lastSync > localMod ) { 2802 if ( lastSync > localMod ) {
2803 return 2; 2803 return 2;
2804 } 2804 }
2805 localIsNew = localMod >= remoteMod; 2805 localIsNew = localMod >= remoteMod;
2806 //qDebug("conflict! ************************************** "); 2806 //qDebug("conflict! ************************************** ");
2807 { 2807 {
2808 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2808 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2809 result = acd.executeD(localIsNew); 2809 result = acd.executeD(localIsNew);
2810 return result; 2810 return result;
2811 } 2811 }
2812 break; 2812 break;
2813 case SYNC_PREF_FORCE_LOCAL: 2813 case SYNC_PREF_FORCE_LOCAL:
2814 return 1; 2814 return 1;
2815 break; 2815 break;
2816 case SYNC_PREF_FORCE_REMOTE: 2816 case SYNC_PREF_FORCE_REMOTE:
2817 return 2; 2817 return 2;
2818 break; 2818 break;
2819 2819
2820 default: 2820 default:
2821 // SYNC_PREF_TAKE_BOTH not implemented 2821 // SYNC_PREF_TAKE_BOTH not implemented
2822 break; 2822 break;
2823 } 2823 }
2824 return 0; 2824 return 0;
2825} 2825}
2826 2826
2827 2827
2828bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2828bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2829{ 2829{
2830 bool syncOK = true; 2830 bool syncOK = true;
2831 int addedAddressee = 0; 2831 int addedAddressee = 0;
2832 int addedAddresseeR = 0; 2832 int addedAddresseeR = 0;
2833 int deletedAddresseeR = 0; 2833 int deletedAddresseeR = 0;
2834 int deletedAddresseeL = 0; 2834 int deletedAddresseeL = 0;
2835 int changedLocal = 0; 2835 int changedLocal = 0;
2836 int changedRemote = 0; 2836 int changedRemote = 0;
2837 int filteredIN = 0; 2837 int filteredIN = 0;
2838 int filteredOUT = 0; 2838 int filteredOUT = 0;
2839 2839
2840 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2840 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2841 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2841 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2842 2842
2843 //QPtrList<Addressee> el = local->rawAddressees(); 2843 //QPtrList<Addressee> el = local->rawAddressees();
2844 Addressee addresseeR; 2844 Addressee addresseeR;
2845 QString uid; 2845 QString uid;
2846 int take; 2846 int take;
2847 Addressee addresseeL; 2847 Addressee addresseeL;
2848 Addressee addresseeRSync; 2848 Addressee addresseeRSync;
2849 Addressee addresseeLSync; 2849 Addressee addresseeLSync;
2850 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2850 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2851 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2851 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2852 bool fullDateRange = false; 2852 bool fullDateRange = false;
2853 local->resetTempSyncStat(); 2853 local->resetTempSyncStat();
2854 mLastAddressbookSync = QDateTime::currentDateTime(); 2854 mLastAddressbookSync = QDateTime::currentDateTime();
2855 if ( syncManager->syncWithDesktop() ) { 2855 if ( syncManager->syncWithDesktop() ) {
2856 // remote->removeSyncInfo( QString());//remove all info 2856 // remote->removeSyncInfo( QString());//remove all info
2857 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2857 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2858 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2858 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2859 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2859 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2860 } else { 2860 } else {
2861 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2861 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime ");
2862 } 2862 }
2863 } 2863 }
2864 QDateTime modifiedCalendar = mLastAddressbookSync; 2864 QDateTime modifiedCalendar = mLastAddressbookSync;
2865 addresseeLSync = getLastSyncAddressee(); 2865 addresseeLSync = getLastSyncAddressee();
2866 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2866 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1());
2867 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2867 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2868 if ( !addresseeR.isEmpty() ) { 2868 if ( !addresseeR.isEmpty() ) {
2869 addresseeRSync = addresseeR; 2869 addresseeRSync = addresseeR;
2870 remote->removeAddressee(addresseeR ); 2870 remote->removeAddressee(addresseeR );
2871 2871
2872 } else { 2872 } else {
2873 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2873 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2874 addresseeRSync = addresseeLSync ; 2874 addresseeRSync = addresseeLSync ;
2875 } else { 2875 } else {
2876 //qDebug("FULLDATE 1"); 2876 //qDebug("FULLDATE 1");
2877 fullDateRange = true; 2877 fullDateRange = true;
2878 Addressee newAdd; 2878 Addressee newAdd;
2879 addresseeRSync = newAdd; 2879 addresseeRSync = newAdd;
2880 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2880 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2881 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2881 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2882 addresseeRSync.setRevision( mLastAddressbookSync ); 2882 addresseeRSync.setRevision( mLastAddressbookSync );
2883 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2883 addresseeRSync.setCategories( i18n("SyncAddressee") );
2884 } 2884 }
2885 } 2885 }
2886 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2886 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2887 // qDebug("FULLDATE 2"); 2887 // qDebug("FULLDATE 2");
2888 fullDateRange = true; 2888 fullDateRange = true;
2889 } 2889 }
2890 if ( ! fullDateRange ) { 2890 if ( ! fullDateRange ) {
2891 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2891 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2892 2892
2893 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2893 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2894 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2894 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2895 fullDateRange = true; 2895 fullDateRange = true;
2896 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2896 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2897 } 2897 }
2898 } 2898 }
2899 // fullDateRange = true; // debug only! 2899 // fullDateRange = true; // debug only!
2900 if ( fullDateRange ) 2900 if ( fullDateRange )
2901 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2901 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2902 else 2902 else
2903 mLastAddressbookSync = addresseeLSync.revision(); 2903 mLastAddressbookSync = addresseeLSync.revision();
2904 // for resyncing if own file has changed 2904 // for resyncing if own file has changed
2905 // PENDING fixme later when implemented 2905 // PENDING fixme later when implemented
2906#if 0 2906#if 0
2907 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2907 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2908 mLastAddressbookSync = loadedFileVersion; 2908 mLastAddressbookSync = loadedFileVersion;
2909 qDebug("setting mLastAddressbookSync "); 2909 qDebug("setting mLastAddressbookSync ");
2910 } 2910 }
2911#endif 2911#endif
2912 2912
2913 2913
2914 // ********** setting filters **************** 2914 // ********** setting filters ****************
2915 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); 2915 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
2916 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); 2916 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
2917 2917
2918 //qDebug("*************************** "); 2918 //qDebug("*************************** ");
2919 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2919 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2920 QStringList er = remote->uidList(); 2920 QStringList er = remote->uidList();
2921 Addressee inR ;//= er.first(); 2921 Addressee inR ;//= er.first();
2922 Addressee inL; 2922 Addressee inL;
2923 2923
2924 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2924 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2925 2925
2926 int modulo = (er.count()/10)+1; 2926 int modulo = (er.count()/10)+1;
2927 int incCounter = 0; 2927 int incCounter = 0;
2928 while ( incCounter < er.count()) { 2928 while ( incCounter < er.count()) {
2929 if (syncManager->isProgressBarCanceled()) 2929 if (syncManager->isProgressBarCanceled())
2930 return false; 2930 return false;
2931 if ( incCounter % modulo == 0 ) 2931 if ( incCounter % modulo == 0 )
2932 syncManager->showProgressBar(incCounter); 2932 syncManager->showProgressBar(incCounter);
2933 2933
2934 uid = er[ incCounter ]; 2934 uid = er[ incCounter ];
2935 bool skipIncidence = false; 2935 bool skipIncidence = false;
2936 if ( uid.left(19) == QString("last-syncAddressee-") ) 2936 if ( uid.left(19) == QString("last-syncAddressee-") )
2937 skipIncidence = true; 2937 skipIncidence = true;
2938 QString idS,OidS; 2938 QString idS,OidS;
2939 qApp->processEvents(); 2939 qApp->processEvents();
2940 if ( !skipIncidence ) { 2940 if ( !skipIncidence ) {
2941 inL = local->findByUid( uid ); 2941 inL = local->findByUid( uid );
2942 inR = remote->findByUid( uid ); 2942 inR = remote->findByUid( uid );
2943 //inL.setResource( 0 ); 2943 //inL.setResource( 0 );
2944 //inR.setResource( 0 ); 2944 //inR.setResource( 0 );
2945 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2945 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2946 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2946 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2947 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 2947 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
2948 //qDebug("take %d %s ", take, inL.summary().latin1()); 2948 //qDebug("take %d %s ", take, inL.summary().latin1());
2949 if ( take == 3 ) 2949 if ( take == 3 )
2950 return false; 2950 return false;
2951 if ( take == 1 ) {// take local ********************** 2951 if ( take == 1 ) {// take local **********************
2952 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2952 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2953 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2953 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2954 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2954 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2955 local->insertAddressee( inL, false ); 2955 local->insertAddressee( inL, false );
2956 idS = inR.externalUID(); 2956 idS = inR.externalUID();
2957 OidS = inR.originalExternalUID(); 2957 OidS = inR.originalExternalUID();
2958 } 2958 }
2959 else 2959 else
2960 idS = inR.IDStr(); 2960 idS = inR.IDStr();
2961 remote->removeAddressee( inR ); 2961 remote->removeAddressee( inR );
2962 inR = inL; 2962 inR = inL;
@@ -3032,290 +3032,290 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
3032 } 3032 }
3033 ++incCounter; 3033 ++incCounter;
3034 } 3034 }
3035 er.clear(); 3035 er.clear();
3036 QStringList el = local->uidList(); 3036 QStringList el = local->uidList();
3037 modulo = (el.count()/10)+1; 3037 modulo = (el.count()/10)+1;
3038 3038
3039 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3039 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3040 incCounter = 0; 3040 incCounter = 0;
3041 while ( incCounter < el.count()) { 3041 while ( incCounter < el.count()) {
3042 qApp->processEvents(); 3042 qApp->processEvents();
3043 if (syncManager->isProgressBarCanceled()) 3043 if (syncManager->isProgressBarCanceled())
3044 return false; 3044 return false;
3045 if ( incCounter % modulo == 0 ) 3045 if ( incCounter % modulo == 0 )
3046 syncManager->showProgressBar(incCounter); 3046 syncManager->showProgressBar(incCounter);
3047 uid = el[ incCounter ]; 3047 uid = el[ incCounter ];
3048 bool skipIncidence = false; 3048 bool skipIncidence = false;
3049 if ( uid.left(19) == QString("last-syncAddressee-") ) 3049 if ( uid.left(19) == QString("last-syncAddressee-") )
3050 skipIncidence = true; 3050 skipIncidence = true;
3051 if ( !skipIncidence ) { 3051 if ( !skipIncidence ) {
3052 inL = local->findByUid( uid ); 3052 inL = local->findByUid( uid );
3053 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3053 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3054 inR = remote->findByUid( uid ); 3054 inR = remote->findByUid( uid );
3055 if ( inR.isEmpty() ){ 3055 if ( inR.isEmpty() ){
3056 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3056 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3057 // no conflict ********** add or delete local 3057 // no conflict ********** add or delete local
3058 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3058 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3059 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3059 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3060 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3060 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3061 local->removeAddressee( inL ); 3061 local->removeAddressee( inL );
3062 ++deletedAddresseeL; 3062 ++deletedAddresseeL;
3063 } else { 3063 } else {
3064 if ( ! syncManager->mWriteBackExistingOnly ) { 3064 if ( ! syncManager->mWriteBackExistingOnly ) {
3065 inL.removeID(mCurrentSyncDevice ); 3065 inL.removeID(mCurrentSyncDevice );
3066 ++addedAddresseeR; 3066 ++addedAddresseeR;
3067 inL.setRevision( modifiedCalendar ); 3067 inL.setRevision( modifiedCalendar );
3068 local->insertAddressee( inL, false ); 3068 local->insertAddressee( inL, false );
3069 inR = inL; 3069 inR = inL;
3070 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3070 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3071 inR.setResource( 0 ); 3071 inR.setResource( 0 );
3072 remote->insertAddressee( inR, false ); 3072 remote->insertAddressee( inR, false );
3073 } 3073 }
3074 } 3074 }
3075 } else { 3075 } else {
3076 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3076 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3077 //qDebug("data %s ", inL.revision().toString().latin1()); 3077 //qDebug("data %s ", inL.revision().toString().latin1());
3078 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3078 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3079 local->removeAddressee( inL ); 3079 local->removeAddressee( inL );
3080 ++deletedAddresseeL; 3080 ++deletedAddresseeL;
3081 } else { 3081 } else {
3082 if ( ! syncManager->mWriteBackExistingOnly ) { 3082 if ( ! syncManager->mWriteBackExistingOnly ) {
3083 ++addedAddresseeR; 3083 ++addedAddresseeR;
3084 inL.setRevision( modifiedCalendar ); 3084 inL.setRevision( modifiedCalendar );
3085 local->insertAddressee( inL, false ); 3085 local->insertAddressee( inL, false );
3086 inR = inL; 3086 inR = inL;
3087 inR.setIDStr( ":" ); 3087 inR.setIDStr( ":" );
3088 inR.setResource( 0 ); 3088 inR.setResource( 0 );
3089 remote->insertAddressee( inR, false ); 3089 remote->insertAddressee( inR, false );
3090 } 3090 }
3091 } 3091 }
3092 } 3092 }
3093 } else { 3093 } else {
3094 ++filteredOUT; 3094 ++filteredOUT;
3095 } 3095 }
3096 } 3096 }
3097 } 3097 }
3098 } 3098 }
3099 ++incCounter; 3099 ++incCounter;
3100 } 3100 }
3101 el.clear(); 3101 el.clear();
3102 syncManager->hideProgressBar(); 3102 syncManager->hideProgressBar();
3103 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3103 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3104 // get rid of micro seconds 3104 // get rid of micro seconds
3105 QTime t = mLastAddressbookSync.time(); 3105 QTime t = mLastAddressbookSync.time();
3106 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3106 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3107 addresseeLSync.setRevision( mLastAddressbookSync ); 3107 addresseeLSync.setRevision( mLastAddressbookSync );
3108 addresseeRSync.setRevision( mLastAddressbookSync ); 3108 addresseeRSync.setRevision( mLastAddressbookSync );
3109 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3109 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3110 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3110 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3111 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3111 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3112 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3112 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3113 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3113 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3114 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3114 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3115 addresseeRSync.setNote( "" ) ; 3115 addresseeRSync.setNote( "" ) ;
3116 addresseeLSync.setNote( "" ); 3116 addresseeLSync.setNote( "" );
3117 3117
3118 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3118 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3119 remote->insertAddressee( addresseeRSync, false ); 3119 remote->insertAddressee( addresseeRSync, false );
3120 local->insertAddressee( addresseeLSync, false ); 3120 local->insertAddressee( addresseeLSync, false );
3121 QString mes; 3121 QString mes;
3122 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); 3122 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT );
3123 qDebug( mes ); 3123 qDebug( mes );
3124 mes = i18n("Local addressbook changed!\n") +mes; 3124 mes = i18n("Local addressbook changed!\n") +mes;
3125 if ( syncManager->mShowSyncSummary ) { 3125 if ( syncManager->mShowSyncSummary ) {
3126 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3126 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3127 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3127 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3128 qDebug("cancelled "); 3128 qDebug("KA: WB cancelled ");
3129 return false; 3129 return false;
3130 } 3130 }
3131 } 3131 }
3132 return syncOK; 3132 return syncOK;
3133} 3133}
3134 3134
3135 3135
3136//this is a overwritten callbackmethods from the syncinterface 3136//this is a overwritten callbackmethods from the syncinterface
3137bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3137bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3138{ 3138{
3139 3139
3140 //pending prepare addresseeview for output 3140 //pending prepare addresseeview for output
3141 //pending detect, if remote file has REV field. if not switch to external sync 3141 //pending detect, if remote file has REV field. if not switch to external sync
3142 mGlobalSyncMode = SYNC_MODE_NORMAL; 3142 mGlobalSyncMode = SYNC_MODE_NORMAL;
3143 if ( manager != syncManager ) 3143 if ( manager != syncManager )
3144 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3144 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3145 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3145 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3146 3146
3147 AddressBook abLocal(filename,"syncContact"); 3147 AddressBook abLocal(filename,"syncContact");
3148 bool syncOK = false; 3148 bool syncOK = false;
3149 if ( abLocal.load() ) { 3149 if ( abLocal.load() ) {
3150 qDebug("Sync:AB loaded %s,sync mode %d",filename.latin1(), mode ); 3150 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode );
3151 bool external = false; 3151 bool external = false;
3152 bool isXML = false; 3152 bool isXML = false;
3153 if ( filename.right(4) == ".xml") { 3153 if ( filename.right(4) == ".xml") {
3154 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3154 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3155 isXML = true; 3155 isXML = true;
3156 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3156 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3157 } else { 3157 } else {
3158 external = !manager->mIsKapiFile; 3158 external = !manager->mIsKapiFile;
3159 if ( external ) { 3159 if ( external ) {
3160 qDebug("Sync:Setting vcf mode to external "); 3160 qDebug("KA: Sync::Setting vcf mode to external ");
3161 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3161 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3162 AddressBook::Iterator it; 3162 AddressBook::Iterator it;
3163 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3163 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3164 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3164 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3165 (*it).computeCsum( mCurrentSyncDevice ); 3165 (*it).computeCsum( mCurrentSyncDevice );
3166 } 3166 }
3167 } 3167 }
3168 } 3168 }
3169 //AddressBook::Iterator it; 3169 //AddressBook::Iterator it;
3170 //QStringList vcards; 3170 //QStringList vcards;
3171 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3171 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3172 // qDebug("Name %s ", (*it).familyName().latin1()); 3172 // qDebug("Name %s ", (*it).familyName().latin1());
3173 //} 3173 //}
3174 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3174 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3175 if ( syncOK ) { 3175 if ( syncOK ) {
3176 if ( syncManager->mWriteBackFile ) 3176 if ( syncManager->mWriteBackFile )
3177 { 3177 {
3178 if ( external ) 3178 if ( external )
3179 abLocal.removeSyncAddressees( !isXML); 3179 abLocal.removeSyncAddressees( !isXML);
3180 qDebug("Sync:Saving remote AB "); 3180 qDebug("KA: Sync::Saving remote AB ");
3181 if ( ! abLocal.saveAB()) 3181 if ( ! abLocal.saveAB())
3182 qDebug("Error writing back AB to file "); 3182 qDebug("KA: sync::Error writing back AB to file ");
3183 if ( external ) { 3183 if ( external ) {
3184 // afterwrite processing 3184 // afterwrite processing
3185 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3185 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3186 } 3186 }
3187 } 3187 }
3188 } 3188 }
3189 setModified(); 3189 setModified();
3190 3190
3191 } 3191 }
3192 abLocal.removeResources(); 3192 abLocal.removeResources();
3193 if ( syncOK ) 3193 if ( syncOK )
3194 mViewManager->refreshView(); 3194 mViewManager->refreshView();
3195 return syncOK; 3195 return syncOK;
3196 3196
3197} 3197}
3198void KABCore::removeSyncInfo( QString syncProfile) 3198void KABCore::removeSyncInfo( QString syncProfile)
3199{ 3199{
3200 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3200 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3201 mAddressBook->removeSyncInfo( syncProfile ); 3201 mAddressBook->removeSyncInfo( syncProfile );
3202 setModified(); 3202 setModified();
3203} 3203}
3204 3204
3205 3205
3206//this is a overwritten callbackmethods from the syncinterface 3206//this is a overwritten callbackmethods from the syncinterface
3207bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3207bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3208{ 3208{
3209 if ( resource == "phone" ) 3209 if ( resource == "phone" )
3210 return syncPhone(); 3210 return syncPhone();
3211 disableBR( true ); 3211 disableBR( true );
3212 if ( manager != syncManager ) 3212 if ( manager != syncManager )
3213 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3213 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3214 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3214 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3215 3215
3216 AddressBook abLocal( resource,"syncContact"); 3216 AddressBook abLocal( resource,"syncContact");
3217 bool syncOK = false; 3217 bool syncOK = false;
3218 message(i18n("Loading DTM address data..."), false); 3218 message(i18n("Loading DTM address data..."), false);
3219 if ( abLocal.load() ) { 3219 if ( abLocal.load() ) {
3220 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3220 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3221 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3221 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3222 message(i18n("Sync preprocessing..."),false); 3222 message(i18n("Sync preprocessing..."),false);
3223 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3223 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3224 message(i18n("Synchronizing..."),false); 3224 message(i18n("Synchronizing..."),false);
3225 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3225 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3226 if ( syncOK ) { 3226 if ( syncOK ) {
3227 if ( syncManager->mWriteBackFile ) { 3227 if ( syncManager->mWriteBackFile ) {
3228 abLocal.removeSyncAddressees( false ); 3228 abLocal.removeSyncAddressees( false );
3229 message(i18n("Saving DTM address data..."),false); 3229 message(i18n("Saving DTM address data..."),false);
3230 abLocal.saveAB(); 3230 abLocal.saveAB();
3231 message(i18n("Sync postprocessing..."),false); 3231 message(i18n("Sync postprocessing..."),false);
3232 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3232 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3233 } 3233 }
3234 } else 3234 } else
3235 message( i18n("Sync cancelled or failed.") ); 3235 message( i18n("Sync cancelled or failed.") );
3236 setModified(); 3236 setModified();
3237 } 3237 }
3238 abLocal.removeResources(); 3238 abLocal.removeResources();
3239 if ( syncOK ) { 3239 if ( syncOK ) {
3240 mViewManager->refreshView(); 3240 mViewManager->refreshView();
3241 message(i18n("DTM syncing finished.")); 3241 message(i18n("DTM syncing finished."));
3242 } 3242 }
3243 disableBR( false ); 3243 disableBR( false );
3244 return syncOK; 3244 return syncOK;
3245 3245
3246} 3246}
3247void KABCore::message( QString m, bool startTimer) 3247void KABCore::message( QString m, bool startTimer)
3248{ 3248{
3249 topLevelWidget()->setCaption( m ); 3249 topLevelWidget()->setCaption( m );
3250 qApp->processEvents(); 3250 qApp->processEvents();
3251 if ( startTimer ) 3251 if ( startTimer )
3252 mMessageTimer->start( 15000, true ); 3252 mMessageTimer->start( 15000, true );
3253 else 3253 else
3254 mMessageTimer->stop(); 3254 mMessageTimer->stop();
3255} 3255}
3256bool KABCore::syncPhone() 3256bool KABCore::syncPhone()
3257{ 3257{
3258 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3258 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3259 QString fileName = getPhoneFile(); 3259 QString fileName = getPhoneFile();
3260 if ( !PhoneAccess::readFromPhone( fileName) ) { 3260 if ( !PhoneAccess::readFromPhone( fileName) ) {
3261 message(i18n("Phone access failed!")); 3261 message(i18n("Phone access failed!"));
3262 return false; 3262 return false;
3263 } 3263 }
3264 AddressBook abLocal( fileName,"syncContact"); 3264 AddressBook abLocal( fileName,"syncContact");
3265 bool syncOK = false; 3265 bool syncOK = false;
3266 { 3266 {
3267 abLocal.importFromFile( fileName ); 3267 abLocal.importFromFile( fileName );
3268 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3268 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3269 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3269 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3270 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3270 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3271 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3271 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3272 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3272 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3273 if ( syncOK ) { 3273 if ( syncOK ) {
3274 if ( syncManager->mWriteBackFile ) { 3274 if ( syncManager->mWriteBackFile ) {
3275 abLocal.removeSyncAddressees( true ); 3275 abLocal.removeSyncAddressees( true );
3276 abLocal.saveABphone( fileName ); 3276 abLocal.saveABphone( fileName );
3277 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3277 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3278 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3278 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3279 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3279 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3280 } 3280 }
3281 } 3281 }
3282 setModified(); 3282 setModified();
3283 } 3283 }
3284 abLocal.removeResources(); 3284 abLocal.removeResources();
3285 if ( syncOK ) 3285 if ( syncOK )
3286 mViewManager->refreshView(); 3286 mViewManager->refreshView();
3287 return syncOK; 3287 return syncOK;
3288} 3288}
3289void KABCore::getFile( bool success ) 3289void KABCore::getFile( bool success )
3290{ 3290{
3291 if ( ! success ) { 3291 if ( ! success ) {
3292 message( i18n("Error receiving file. Nothing changed!") ); 3292 message( i18n("Error receiving file. Nothing changed!") );
3293 return; 3293 return;
3294 } 3294 }
3295 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3295 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3296 if ( count ) 3296 if ( count )
3297 setModified( true ); 3297 setModified( true );
3298 message( i18n("Pi-Sync successful!") ); 3298 message( i18n("Pi-Sync successful!") );
3299 mViewManager->refreshView(); 3299 mViewManager->refreshView();
3300} 3300}
3301void KABCore::syncFileRequest() 3301void KABCore::syncFileRequest()
3302{ 3302{
3303 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3303 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3304 syncManager->slotSyncMenu( 999 ); 3304 syncManager->slotSyncMenu( 999 );
3305 } 3305 }
3306 mAddressBook->export2File( sentSyncFile() ); 3306 mAddressBook->export2File( sentSyncFile() );
3307} 3307}
3308QString KABCore::sentSyncFile() 3308QString KABCore::sentSyncFile()
3309{ 3309{
3310#ifdef DESKTOP_VERSION 3310#ifdef DESKTOP_VERSION
3311 return locateLocal( "tmp", "copysyncab.vcf" ); 3311 return locateLocal( "tmp", "copysyncab.vcf" );
3312#else 3312#else
3313 return QString( "/tmp/copysyncab.vcf" ); 3313 return QString( "/tmp/copysyncab.vcf" );
3314#endif 3314#endif
3315} 3315}
3316 3316
3317void KABCore::setCaptionBack() 3317void KABCore::setCaptionBack()
3318{ 3318{
3319 mMessageTimer->stop(); 3319 mMessageTimer->stop();
3320 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3320 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
3321} 3321}