summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-26 20:55:30 (UTC)
committer zautrix <zautrix>2004-10-26 20:55:30 (UTC)
commit13e996beddabc5e88f4f2fe49b2ce6cb8408eb30 (patch) (unidiff)
tree77395039348f3af1b5d1e1673f5638a7f34c0e99
parent8b111ae30fc51a4a580b8d485bef8ad28b0dde84 (diff)
downloadkdepimpi-13e996beddabc5e88f4f2fe49b2ce6cb8408eb30.zip
kdepimpi-13e996beddabc5e88f4f2fe49b2ce6cb8408eb30.tar.gz
kdepimpi-13e996beddabc5e88f4f2fe49b2ce6cb8408eb30.tar.bz2
added removeSyncInfo to KSyncInterface class
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp5
-rw-r--r--kaddressbook/kabcore.h1
-rw-r--r--korganizer/calendarview.cpp6
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--libkdepim/ksyncmanager.h1
-rw-r--r--pwmanager/pwmanager/pwm.cpp6
-rw-r--r--pwmanager/pwmanager/pwm.h3
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp5
-rw-r--r--pwmanager/pwmanager/pwmdoc.h1
9 files changed, 27 insertions, 2 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 2a3334e..efae874 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2429,483 +2429,488 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
2429 bool localIsNew; 2429 bool localIsNew;
2430 //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() ); 2430 //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() );
2431 2431
2432 if ( full && mode < SYNC_PREF_NEWEST ) 2432 if ( full && mode < SYNC_PREF_NEWEST )
2433 mode = SYNC_PREF_ASK; 2433 mode = SYNC_PREF_ASK;
2434 2434
2435 switch( mode ) { 2435 switch( mode ) {
2436 case SYNC_PREF_LOCAL: 2436 case SYNC_PREF_LOCAL:
2437 if ( lastSync > remoteMod ) 2437 if ( lastSync > remoteMod )
2438 return 1; 2438 return 1;
2439 if ( lastSync > localMod ) 2439 if ( lastSync > localMod )
2440 return 2; 2440 return 2;
2441 return 1; 2441 return 1;
2442 break; 2442 break;
2443 case SYNC_PREF_REMOTE: 2443 case SYNC_PREF_REMOTE:
2444 if ( lastSync > remoteMod ) 2444 if ( lastSync > remoteMod )
2445 return 1; 2445 return 1;
2446 if ( lastSync > localMod ) 2446 if ( lastSync > localMod )
2447 return 2; 2447 return 2;
2448 return 2; 2448 return 2;
2449 break; 2449 break;
2450 case SYNC_PREF_NEWEST: 2450 case SYNC_PREF_NEWEST:
2451 if ( localMod > remoteMod ) 2451 if ( localMod > remoteMod )
2452 return 1; 2452 return 1;
2453 else 2453 else
2454 return 2; 2454 return 2;
2455 break; 2455 break;
2456 case SYNC_PREF_ASK: 2456 case SYNC_PREF_ASK:
2457 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2457 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2458 if ( lastSync > remoteMod ) 2458 if ( lastSync > remoteMod )
2459 return 1; 2459 return 1;
2460 if ( lastSync > localMod ) 2460 if ( lastSync > localMod )
2461 return 2; 2461 return 2;
2462 localIsNew = localMod >= remoteMod; 2462 localIsNew = localMod >= remoteMod;
2463 //qDebug("conflict! ************************************** "); 2463 //qDebug("conflict! ************************************** ");
2464 { 2464 {
2465 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2465 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2466 result = acd.executeD(localIsNew); 2466 result = acd.executeD(localIsNew);
2467 return result; 2467 return result;
2468 } 2468 }
2469 break; 2469 break;
2470 case SYNC_PREF_FORCE_LOCAL: 2470 case SYNC_PREF_FORCE_LOCAL:
2471 return 1; 2471 return 1;
2472 break; 2472 break;
2473 case SYNC_PREF_FORCE_REMOTE: 2473 case SYNC_PREF_FORCE_REMOTE:
2474 return 2; 2474 return 2;
2475 break; 2475 break;
2476 2476
2477 default: 2477 default:
2478 // SYNC_PREF_TAKE_BOTH not implemented 2478 // SYNC_PREF_TAKE_BOTH not implemented
2479 break; 2479 break;
2480 } 2480 }
2481 return 0; 2481 return 0;
2482} 2482}
2483 2483
2484 2484
2485bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2485bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2486{ 2486{
2487 bool syncOK = true; 2487 bool syncOK = true;
2488 int addedAddressee = 0; 2488 int addedAddressee = 0;
2489 int addedAddresseeR = 0; 2489 int addedAddresseeR = 0;
2490 int deletedAddresseeR = 0; 2490 int deletedAddresseeR = 0;
2491 int deletedAddresseeL = 0; 2491 int deletedAddresseeL = 0;
2492 int changedLocal = 0; 2492 int changedLocal = 0;
2493 int changedRemote = 0; 2493 int changedRemote = 0;
2494 2494
2495 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2495 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2496 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2496 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2497 2497
2498 //QPtrList<Addressee> el = local->rawAddressees(); 2498 //QPtrList<Addressee> el = local->rawAddressees();
2499 Addressee addresseeR; 2499 Addressee addresseeR;
2500 QString uid; 2500 QString uid;
2501 int take; 2501 int take;
2502 Addressee addresseeL; 2502 Addressee addresseeL;
2503 Addressee addresseeRSync; 2503 Addressee addresseeRSync;
2504 Addressee addresseeLSync; 2504 Addressee addresseeLSync;
2505 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2505 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2506 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2506 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2507 bool fullDateRange = false; 2507 bool fullDateRange = false;
2508 local->resetTempSyncStat(); 2508 local->resetTempSyncStat();
2509 mLastAddressbookSync = QDateTime::currentDateTime(); 2509 mLastAddressbookSync = QDateTime::currentDateTime();
2510 QDateTime modifiedCalendar = mLastAddressbookSync;; 2510 QDateTime modifiedCalendar = mLastAddressbookSync;;
2511 addresseeLSync = getLastSyncAddressee(); 2511 addresseeLSync = getLastSyncAddressee();
2512 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2512 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2513 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2513 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2514 if ( !addresseeR.isEmpty() ) { 2514 if ( !addresseeR.isEmpty() ) {
2515 addresseeRSync = addresseeR; 2515 addresseeRSync = addresseeR;
2516 remote->removeAddressee(addresseeR ); 2516 remote->removeAddressee(addresseeR );
2517 2517
2518 } else { 2518 } else {
2519 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2519 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2520 addresseeRSync = addresseeLSync ; 2520 addresseeRSync = addresseeLSync ;
2521 } else { 2521 } else {
2522 qDebug("FULLDATE 1"); 2522 qDebug("FULLDATE 1");
2523 fullDateRange = true; 2523 fullDateRange = true;
2524 Addressee newAdd; 2524 Addressee newAdd;
2525 addresseeRSync = newAdd; 2525 addresseeRSync = newAdd;
2526 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2526 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2527 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2527 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2528 addresseeRSync.setRevision( mLastAddressbookSync ); 2528 addresseeRSync.setRevision( mLastAddressbookSync );
2529 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2529 addresseeRSync.setCategories( i18n("SyncAddressee") );
2530 } 2530 }
2531 } 2531 }
2532 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2532 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2533 qDebug("FULLDATE 2"); 2533 qDebug("FULLDATE 2");
2534 fullDateRange = true; 2534 fullDateRange = true;
2535 } 2535 }
2536 if ( ! fullDateRange ) { 2536 if ( ! fullDateRange ) {
2537 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2537 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2538 2538
2539 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2539 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2540 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2540 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2541 fullDateRange = true; 2541 fullDateRange = true;
2542 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2542 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2543 } 2543 }
2544 } 2544 }
2545 // fullDateRange = true; // debug only! 2545 // fullDateRange = true; // debug only!
2546 if ( fullDateRange ) 2546 if ( fullDateRange )
2547 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2547 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2548 else 2548 else
2549 mLastAddressbookSync = addresseeLSync.revision(); 2549 mLastAddressbookSync = addresseeLSync.revision();
2550 // for resyncing if own file has changed 2550 // for resyncing if own file has changed
2551 // PENDING fixme later when implemented 2551 // PENDING fixme later when implemented
2552#if 0 2552#if 0
2553 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2553 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2554 mLastAddressbookSync = loadedFileVersion; 2554 mLastAddressbookSync = loadedFileVersion;
2555 qDebug("setting mLastAddressbookSync "); 2555 qDebug("setting mLastAddressbookSync ");
2556 } 2556 }
2557#endif 2557#endif
2558 2558
2559 //qDebug("*************************** "); 2559 //qDebug("*************************** ");
2560 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2560 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2561 QStringList er = remote->uidList(); 2561 QStringList er = remote->uidList();
2562 Addressee inR ;//= er.first(); 2562 Addressee inR ;//= er.first();
2563 Addressee inL; 2563 Addressee inL;
2564 2564
2565 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2565 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2566 2566
2567 int modulo = (er.count()/10)+1; 2567 int modulo = (er.count()/10)+1;
2568 int incCounter = 0; 2568 int incCounter = 0;
2569 while ( incCounter < er.count()) { 2569 while ( incCounter < er.count()) {
2570 if (syncManager->isProgressBarCanceled()) 2570 if (syncManager->isProgressBarCanceled())
2571 return false; 2571 return false;
2572 if ( incCounter % modulo == 0 ) 2572 if ( incCounter % modulo == 0 )
2573 syncManager->showProgressBar(incCounter); 2573 syncManager->showProgressBar(incCounter);
2574 2574
2575 uid = er[ incCounter ]; 2575 uid = er[ incCounter ];
2576 bool skipIncidence = false; 2576 bool skipIncidence = false;
2577 if ( uid.left(19) == QString("last-syncAddressee-") ) 2577 if ( uid.left(19) == QString("last-syncAddressee-") )
2578 skipIncidence = true; 2578 skipIncidence = true;
2579 QString idS,OidS; 2579 QString idS,OidS;
2580 qApp->processEvents(); 2580 qApp->processEvents();
2581 if ( !skipIncidence ) { 2581 if ( !skipIncidence ) {
2582 inL = local->findByUid( uid ); 2582 inL = local->findByUid( uid );
2583 inR = remote->findByUid( uid ); 2583 inR = remote->findByUid( uid );
2584 //inL.setResource( 0 ); 2584 //inL.setResource( 0 );
2585 //inR.setResource( 0 ); 2585 //inR.setResource( 0 );
2586 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2586 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2587 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2587 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2588 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2588 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2589 //qDebug("take %d %s ", take, inL.summary().latin1()); 2589 //qDebug("take %d %s ", take, inL.summary().latin1());
2590 if ( take == 3 ) 2590 if ( take == 3 )
2591 return false; 2591 return false;
2592 if ( take == 1 ) {// take local 2592 if ( take == 1 ) {// take local
2593 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2593 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2594 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2594 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2595 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2595 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2596 local->insertAddressee( inL, false ); 2596 local->insertAddressee( inL, false );
2597 idS = inR.externalUID(); 2597 idS = inR.externalUID();
2598 OidS = inR.originalExternalUID(); 2598 OidS = inR.originalExternalUID();
2599 } 2599 }
2600 else 2600 else
2601 idS = inR.IDStr(); 2601 idS = inR.IDStr();
2602 remote->removeAddressee( inR ); 2602 remote->removeAddressee( inR );
2603 inR = inL; 2603 inR = inL;
2604 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2604 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2605 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2605 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2606 inR.setOriginalExternalUID( OidS ); 2606 inR.setOriginalExternalUID( OidS );
2607 inR.setExternalUID( idS ); 2607 inR.setExternalUID( idS );
2608 } else { 2608 } else {
2609 inR.setIDStr( idS ); 2609 inR.setIDStr( idS );
2610 } 2610 }
2611 inR.setResource( 0 ); 2611 inR.setResource( 0 );
2612 remote->insertAddressee( inR , false); 2612 remote->insertAddressee( inR , false);
2613 ++changedRemote; 2613 ++changedRemote;
2614 } else { // take == 2 take remote 2614 } else { // take == 2 take remote
2615 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2615 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2616 if ( inR.revision().date().year() < 2004 ) 2616 if ( inR.revision().date().year() < 2004 )
2617 inR.setRevision( modifiedCalendar ); 2617 inR.setRevision( modifiedCalendar );
2618 } 2618 }
2619 idS = inL.IDStr(); 2619 idS = inL.IDStr();
2620 local->removeAddressee( inL ); 2620 local->removeAddressee( inL );
2621 inL = inR; 2621 inL = inR;
2622 inL.setIDStr( idS ); 2622 inL.setIDStr( idS );
2623 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2623 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2624 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2624 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2625 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2625 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2626 } 2626 }
2627 inL.setResource( 0 ); 2627 inL.setResource( 0 );
2628 local->insertAddressee( inL , false ); 2628 local->insertAddressee( inL , false );
2629 ++changedLocal; 2629 ++changedLocal;
2630 } 2630 }
2631 } 2631 }
2632 } 2632 }
2633 } else { // no conflict 2633 } else { // no conflict
2634 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2634 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2635 QString des = addresseeLSync.note(); 2635 QString des = addresseeLSync.note();
2636 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2636 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2637 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2637 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2638 remote->insertAddressee( inR, false ); 2638 remote->insertAddressee( inR, false );
2639 ++deletedAddresseeR; 2639 ++deletedAddresseeR;
2640 } else { 2640 } else {
2641 inR.setRevision( modifiedCalendar ); 2641 inR.setRevision( modifiedCalendar );
2642 remote->insertAddressee( inR, false ); 2642 remote->insertAddressee( inR, false );
2643 inL = inR; 2643 inL = inR;
2644 inL.setResource( 0 ); 2644 inL.setResource( 0 );
2645 local->insertAddressee( inL , false); 2645 local->insertAddressee( inL , false);
2646 ++addedAddressee; 2646 ++addedAddressee;
2647 } 2647 }
2648 } else { 2648 } else {
2649 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2649 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2650 inR.setRevision( modifiedCalendar ); 2650 inR.setRevision( modifiedCalendar );
2651 remote->insertAddressee( inR, false ); 2651 remote->insertAddressee( inR, false );
2652 inR.setResource( 0 ); 2652 inR.setResource( 0 );
2653 local->insertAddressee( inR, false ); 2653 local->insertAddressee( inR, false );
2654 ++addedAddressee; 2654 ++addedAddressee;
2655 } else { 2655 } else {
2656 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2656 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2657 remote->removeAddressee( inR ); 2657 remote->removeAddressee( inR );
2658 ++deletedAddresseeR; 2658 ++deletedAddresseeR;
2659 } 2659 }
2660 } 2660 }
2661 } 2661 }
2662 } 2662 }
2663 ++incCounter; 2663 ++incCounter;
2664 } 2664 }
2665 er.clear(); 2665 er.clear();
2666 QStringList el = local->uidList(); 2666 QStringList el = local->uidList();
2667 modulo = (el.count()/10)+1; 2667 modulo = (el.count()/10)+1;
2668 2668
2669 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2669 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2670 incCounter = 0; 2670 incCounter = 0;
2671 while ( incCounter < el.count()) { 2671 while ( incCounter < el.count()) {
2672 qApp->processEvents(); 2672 qApp->processEvents();
2673 if (syncManager->isProgressBarCanceled()) 2673 if (syncManager->isProgressBarCanceled())
2674 return false; 2674 return false;
2675 if ( incCounter % modulo == 0 ) 2675 if ( incCounter % modulo == 0 )
2676 syncManager->showProgressBar(incCounter); 2676 syncManager->showProgressBar(incCounter);
2677 uid = el[ incCounter ]; 2677 uid = el[ incCounter ];
2678 bool skipIncidence = false; 2678 bool skipIncidence = false;
2679 if ( uid.left(19) == QString("last-syncAddressee-") ) 2679 if ( uid.left(19) == QString("last-syncAddressee-") )
2680 skipIncidence = true; 2680 skipIncidence = true;
2681 if ( !skipIncidence ) { 2681 if ( !skipIncidence ) {
2682 inL = local->findByUid( uid ); 2682 inL = local->findByUid( uid );
2683 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2683 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2684 inR = remote->findByUid( uid ); 2684 inR = remote->findByUid( uid );
2685 if ( inR.isEmpty() ) { 2685 if ( inR.isEmpty() ) {
2686 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2686 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2687 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2687 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2688 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2688 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2689 local->removeAddressee( inL ); 2689 local->removeAddressee( inL );
2690 ++deletedAddresseeL; 2690 ++deletedAddresseeL;
2691 } else { 2691 } else {
2692 if ( ! syncManager->mWriteBackExistingOnly ) { 2692 if ( ! syncManager->mWriteBackExistingOnly ) {
2693 inL.removeID(mCurrentSyncDevice ); 2693 inL.removeID(mCurrentSyncDevice );
2694 ++addedAddresseeR; 2694 ++addedAddresseeR;
2695 inL.setRevision( modifiedCalendar ); 2695 inL.setRevision( modifiedCalendar );
2696 local->insertAddressee( inL, false ); 2696 local->insertAddressee( inL, false );
2697 inR = inL; 2697 inR = inL;
2698 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2698 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2699 inR.setResource( 0 ); 2699 inR.setResource( 0 );
2700 remote->insertAddressee( inR, false ); 2700 remote->insertAddressee( inR, false );
2701 } 2701 }
2702 } 2702 }
2703 } else { 2703 } else {
2704 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2704 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2705 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2705 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2706 local->removeAddressee( inL ); 2706 local->removeAddressee( inL );
2707 ++deletedAddresseeL; 2707 ++deletedAddresseeL;
2708 } else { 2708 } else {
2709 if ( ! syncManager->mWriteBackExistingOnly ) { 2709 if ( ! syncManager->mWriteBackExistingOnly ) {
2710 ++addedAddresseeR; 2710 ++addedAddresseeR;
2711 inL.setRevision( modifiedCalendar ); 2711 inL.setRevision( modifiedCalendar );
2712 local->insertAddressee( inL, false ); 2712 local->insertAddressee( inL, false );
2713 inR = inL; 2713 inR = inL;
2714 inR.setResource( 0 ); 2714 inR.setResource( 0 );
2715 remote->insertAddressee( inR, false ); 2715 remote->insertAddressee( inR, false );
2716 } 2716 }
2717 } 2717 }
2718 } 2718 }
2719 } 2719 }
2720 } 2720 }
2721 } 2721 }
2722 ++incCounter; 2722 ++incCounter;
2723 } 2723 }
2724 el.clear(); 2724 el.clear();
2725 syncManager->hideProgressBar(); 2725 syncManager->hideProgressBar();
2726 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2726 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2727 // get rid of micro seconds 2727 // get rid of micro seconds
2728 QTime t = mLastAddressbookSync.time(); 2728 QTime t = mLastAddressbookSync.time();
2729 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2729 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2730 addresseeLSync.setRevision( mLastAddressbookSync ); 2730 addresseeLSync.setRevision( mLastAddressbookSync );
2731 addresseeRSync.setRevision( mLastAddressbookSync ); 2731 addresseeRSync.setRevision( mLastAddressbookSync );
2732 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2732 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2733 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2733 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2734 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2734 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2735 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2735 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2736 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2736 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2737 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2737 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2738 addresseeRSync.setNote( "" ) ; 2738 addresseeRSync.setNote( "" ) ;
2739 addresseeLSync.setNote( "" ); 2739 addresseeLSync.setNote( "" );
2740 2740
2741 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2741 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2742 remote->insertAddressee( addresseeRSync, false ); 2742 remote->insertAddressee( addresseeRSync, false );
2743 local->insertAddressee( addresseeLSync, false ); 2743 local->insertAddressee( addresseeLSync, false );
2744 QString mes; 2744 QString mes;
2745 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"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2745 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"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2746 if ( syncManager->mShowSyncSummary ) { 2746 if ( syncManager->mShowSyncSummary ) {
2747 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2747 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2748 } 2748 }
2749 qDebug( mes ); 2749 qDebug( mes );
2750 return syncOK; 2750 return syncOK;
2751} 2751}
2752 2752
2753 2753
2754//this is a overwritten callbackmethods from the syncinterface 2754//this is a overwritten callbackmethods from the syncinterface
2755bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2755bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2756{ 2756{
2757 2757
2758 //pending prepare addresseeview for output 2758 //pending prepare addresseeview for output
2759 //pending detect, if remote file has REV field. if not switch to external sync 2759 //pending detect, if remote file has REV field. if not switch to external sync
2760 mGlobalSyncMode = SYNC_MODE_NORMAL; 2760 mGlobalSyncMode = SYNC_MODE_NORMAL;
2761 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2761 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2762 2762
2763 AddressBook abLocal(filename,"syncContact"); 2763 AddressBook abLocal(filename,"syncContact");
2764 bool syncOK = false; 2764 bool syncOK = false;
2765 if ( abLocal.load() ) { 2765 if ( abLocal.load() ) {
2766 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2766 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2767 bool external = false; 2767 bool external = false;
2768 bool isXML = false; 2768 bool isXML = false;
2769 if ( filename.right(4) == ".xml") { 2769 if ( filename.right(4) == ".xml") {
2770 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2770 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2771 isXML = true; 2771 isXML = true;
2772 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2772 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2773 } else { 2773 } else {
2774 external = !manager->mIsKapiFile; 2774 external = !manager->mIsKapiFile;
2775 if ( external ) { 2775 if ( external ) {
2776 qDebug("Setting vcf mode to external "); 2776 qDebug("Setting vcf mode to external ");
2777 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2777 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2778 AddressBook::Iterator it; 2778 AddressBook::Iterator it;
2779 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2779 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2780 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2780 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2781 (*it).computeCsum( mCurrentSyncDevice ); 2781 (*it).computeCsum( mCurrentSyncDevice );
2782 } 2782 }
2783 } 2783 }
2784 } 2784 }
2785 //AddressBook::Iterator it; 2785 //AddressBook::Iterator it;
2786 //QStringList vcards; 2786 //QStringList vcards;
2787 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2787 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2788 // qDebug("Name %s ", (*it).familyName().latin1()); 2788 // qDebug("Name %s ", (*it).familyName().latin1());
2789 //} 2789 //}
2790 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2790 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2791 if ( syncOK ) { 2791 if ( syncOK ) {
2792 if ( syncManager->mWriteBackFile ) 2792 if ( syncManager->mWriteBackFile )
2793 { 2793 {
2794 if ( external ) 2794 if ( external )
2795 abLocal.removeSyncAddressees( !isXML); 2795 abLocal.removeSyncAddressees( !isXML);
2796 qDebug("Saving remote AB "); 2796 qDebug("Saving remote AB ");
2797 if ( ! abLocal.saveAB()) 2797 if ( ! abLocal.saveAB())
2798 qDebug("Error writing back AB to file "); 2798 qDebug("Error writing back AB to file ");
2799 if ( isXML ) { 2799 if ( isXML ) {
2800 // afterwrite processing 2800 // afterwrite processing
2801 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2801 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2802 } 2802 }
2803 } 2803 }
2804 } 2804 }
2805 setModified(); 2805 setModified();
2806 2806
2807 } 2807 }
2808 if ( syncOK ) 2808 if ( syncOK )
2809 mViewManager->refreshView(); 2809 mViewManager->refreshView();
2810 return syncOK; 2810 return syncOK;
2811 2811
2812} 2812}
2813void KABCore::removeSyncInfo( QString syncProfile)
2814{
2815 qDebug("removeSyncInfo for profile %s ", syncProfile.latin1());
2816
2817}
2813 2818
2814 2819
2815//this is a overwritten callbackmethods from the syncinterface 2820//this is a overwritten callbackmethods from the syncinterface
2816bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2821bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2817{ 2822{
2818 if ( resource == "phone" ) 2823 if ( resource == "phone" )
2819 return syncPhone(); 2824 return syncPhone();
2820 disableBR( true ); 2825 disableBR( true );
2821 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2826 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2822 2827
2823 AddressBook abLocal( resource,"syncContact"); 2828 AddressBook abLocal( resource,"syncContact");
2824 bool syncOK = false; 2829 bool syncOK = false;
2825 if ( abLocal.load() ) { 2830 if ( abLocal.load() ) {
2826 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2831 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2827 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2832 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2828 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 2833 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
2829 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2834 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2830 if ( syncOK ) { 2835 if ( syncOK ) {
2831 if ( syncManager->mWriteBackFile ) { 2836 if ( syncManager->mWriteBackFile ) {
2832 abLocal.removeSyncAddressees( false ); 2837 abLocal.removeSyncAddressees( false );
2833 abLocal.saveAB(); 2838 abLocal.saveAB();
2834 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2839 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2835 } 2840 }
2836 } 2841 }
2837 setModified(); 2842 setModified();
2838 } 2843 }
2839 if ( syncOK ) 2844 if ( syncOK )
2840 mViewManager->refreshView(); 2845 mViewManager->refreshView();
2841 disableBR( false ); 2846 disableBR( false );
2842 return syncOK; 2847 return syncOK;
2843 2848
2844} 2849}
2845void KABCore::message( QString m ) 2850void KABCore::message( QString m )
2846{ 2851{
2847 topLevelWidget()->setCaption( m ); 2852 topLevelWidget()->setCaption( m );
2848 mMessageTimer->start( 15000, true ); 2853 mMessageTimer->start( 15000, true );
2849} 2854}
2850bool KABCore::syncPhone() 2855bool KABCore::syncPhone()
2851{ 2856{
2852 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2857 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2853 QString fileName = getPhoneFile(); 2858 QString fileName = getPhoneFile();
2854 if ( !PhoneAccess::readFromPhone( fileName) ) { 2859 if ( !PhoneAccess::readFromPhone( fileName) ) {
2855 message(i18n("Phone access failed!")); 2860 message(i18n("Phone access failed!"));
2856 return false; 2861 return false;
2857 } 2862 }
2858 AddressBook abLocal( fileName,"syncContact"); 2863 AddressBook abLocal( fileName,"syncContact");
2859 bool syncOK = false; 2864 bool syncOK = false;
2860 { 2865 {
2861 abLocal.importFromFile( fileName ); 2866 abLocal.importFromFile( fileName );
2862 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2867 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
2863 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2868 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2864 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 2869 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
2865 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2870 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2866 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2871 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2867 if ( syncOK ) { 2872 if ( syncOK ) {
2868 if ( syncManager->mWriteBackFile ) { 2873 if ( syncManager->mWriteBackFile ) {
2869 abLocal.removeSyncAddressees( true ); 2874 abLocal.removeSyncAddressees( true );
2870 abLocal.saveABphone( fileName ); 2875 abLocal.saveABphone( fileName );
2871 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 2876 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
2872 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 2877 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
2873 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2878 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2874 } 2879 }
2875 } 2880 }
2876 setModified(); 2881 setModified();
2877 } 2882 }
2878 if ( syncOK ) 2883 if ( syncOK )
2879 mViewManager->refreshView(); 2884 mViewManager->refreshView();
2880 return syncOK; 2885 return syncOK;
2881} 2886}
2882void KABCore::getFile( bool success ) 2887void KABCore::getFile( bool success )
2883{ 2888{
2884 if ( ! success ) { 2889 if ( ! success ) {
2885 message( i18n("Error receiving file. Nothing changed!") ); 2890 message( i18n("Error receiving file. Nothing changed!") );
2886 return; 2891 return;
2887 } 2892 }
2888 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 2893 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
2889 if ( count ) 2894 if ( count )
2890 setModified( true ); 2895 setModified( true );
2891 message( i18n("Pi-Sync successful!") ); 2896 message( i18n("Pi-Sync successful!") );
2892 mViewManager->refreshView(); 2897 mViewManager->refreshView();
2893} 2898}
2894void KABCore::syncFileRequest() 2899void KABCore::syncFileRequest()
2895{ 2900{
2896 mAddressBook->export2File( sentSyncFile() ); 2901 mAddressBook->export2File( sentSyncFile() );
2897} 2902}
2898QString KABCore::sentSyncFile() 2903QString KABCore::sentSyncFile()
2899{ 2904{
2900#ifdef DESKTOP_VERSION 2905#ifdef DESKTOP_VERSION
2901 return locateLocal( "tmp", "copysyncab.vcf" ); 2906 return locateLocal( "tmp", "copysyncab.vcf" );
2902#else 2907#else
2903 return QString( "/tmp/copysyncab.vcf" ); 2908 return QString( "/tmp/copysyncab.vcf" );
2904#endif 2909#endif
2905} 2910}
2906 2911
2907void KABCore::setCaptionBack() 2912void KABCore::setCaptionBack()
2908{ 2913{
2909 mMessageTimer->stop(); 2914 mMessageTimer->stop();
2910 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2915 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2911} 2916}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index fcbe1e8..a288505 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -101,402 +101,403 @@ class KABCore : public QWidget, public KSyncInterface
101 void saveSettings(); 101 void saveSettings();
102 102
103 /** 103 /**
104 Returns a pointer to the StdAddressBook of the application. 104 Returns a pointer to the StdAddressBook of the application.
105 */ 105 */
106 KABC::AddressBook *addressBook() const; 106 KABC::AddressBook *addressBook() const;
107 107
108 /** 108 /**
109 Returns a pointer to the KConfig object of the application. 109 Returns a pointer to the KConfig object of the application.
110 */ 110 */
111 static KConfig *config(); 111 static KConfig *config();
112 112
113 /** 113 /**
114 Returns a pointer to the global KActionCollection object. So 114 Returns a pointer to the global KActionCollection object. So
115 other classes can register their actions easily. 115 other classes can register their actions easily.
116 */ 116 */
117 KActionCollection *actionCollection() const; 117 KActionCollection *actionCollection() const;
118 118
119 /** 119 /**
120 Returns the current search field of the Incremental Search Widget. 120 Returns the current search field of the Incremental Search Widget.
121 */ 121 */
122 KABC::Field *currentSearchField() const; 122 KABC::Field *currentSearchField() const;
123 123
124 /** 124 /**
125 Returns the uid list of the currently selected contacts. 125 Returns the uid list of the currently selected contacts.
126 */ 126 */
127 QStringList selectedUIDs() const; 127 QStringList selectedUIDs() const;
128 128
129 /** 129 /**
130 Displays the ResourceSelectDialog and returns the selected 130 Displays the ResourceSelectDialog and returns the selected
131 resource or a null pointer if no resource was selected by 131 resource or a null pointer if no resource was selected by
132 the user. 132 the user.
133 */ 133 */
134 KABC::Resource *requestResource( QWidget *parent ); 134 KABC::Resource *requestResource( QWidget *parent );
135 135
136#ifndef KAB_EMBEDDED 136#ifndef KAB_EMBEDDED
137 static KAboutData *createAboutData(); 137 static KAboutData *createAboutData();
138#endif //KAB_EMBEDDED 138#endif //KAB_EMBEDDED
139 139
140#ifdef KAB_EMBEDDED 140#ifdef KAB_EMBEDDED
141 inline QPopupMenu* getImportMenu() { return ImportMenu;} 141 inline QPopupMenu* getImportMenu() { return ImportMenu;}
142 inline QPopupMenu* getExportMenu() { return ExportMenu;} 142 inline QPopupMenu* getExportMenu() { return ExportMenu;}
143#endif //KAB_EMBEDDED 143#endif //KAB_EMBEDDED
144 144
145 public slots: 145 public slots:
146#ifdef KAB_EMBEDDED 146#ifdef KAB_EMBEDDED
147 void createAboutData(); 147 void createAboutData();
148#endif //KAB_EMBEDDED 148#endif //KAB_EMBEDDED
149 149
150 void showLicence(); 150 void showLicence();
151 void faq(); 151 void faq();
152 void whatsnew() ; 152 void whatsnew() ;
153 void synchowto() ; 153 void synchowto() ;
154 void writeToPhone(); 154 void writeToPhone();
155 155
156 /** 156 /**
157 Is called whenever a contact is selected in the view. 157 Is called whenever a contact is selected in the view.
158 */ 158 */
159 void setContactSelected( const QString &uid ); 159 void setContactSelected( const QString &uid );
160 160
161 /** 161 /**
162 Opens the preferred mail composer with all selected contacts as 162 Opens the preferred mail composer with all selected contacts as
163 arguments. 163 arguments.
164 */ 164 */
165 void sendMail(); 165 void sendMail();
166 166
167 /** 167 /**
168 Opens the preferred mail composer with the given contacts as 168 Opens the preferred mail composer with the given contacts as
169 arguments. 169 arguments.
170 */ 170 */
171 void sendMail( const QString& email ); 171 void sendMail( const QString& email );
172 172
173 173
174 void mailVCard(); 174 void mailVCard();
175 void mailVCard(const QStringList& uids); 175 void mailVCard(const QStringList& uids);
176 176
177 /** 177 /**
178 Beams the "WhoAmI contact. 178 Beams the "WhoAmI contact.
179 */ 179 */
180 void beamMySelf(); 180 void beamMySelf();
181 181
182 void beamVCard(); 182 void beamVCard();
183 void export2phone(); 183 void export2phone();
184 void beamVCard(const QStringList& uids); 184 void beamVCard(const QStringList& uids);
185 void beamDone( Ir *ir ); 185 void beamDone( Ir *ir );
186 186
187 187
188 /** 188 /**
189 Starts the preferred web browser with the given URL as argument. 189 Starts the preferred web browser with the given URL as argument.
190 */ 190 */
191 void browse( const QString& url ); 191 void browse( const QString& url );
192 192
193 /** 193 /**
194 Select all contacts in the view. 194 Select all contacts in the view.
195 */ 195 */
196 void selectAllContacts(); 196 void selectAllContacts();
197 197
198 /** 198 /**
199 Deletes all selected contacts from the address book. 199 Deletes all selected contacts from the address book.
200 */ 200 */
201 void deleteContacts(); 201 void deleteContacts();
202 202
203 /** 203 /**
204 Deletes given contacts from the address book. 204 Deletes given contacts from the address book.
205 205
206 @param uids The uids of the contacts, which shall be deleted. 206 @param uids The uids of the contacts, which shall be deleted.
207 */ 207 */
208 void deleteContacts( const QStringList &uids ); 208 void deleteContacts( const QStringList &uids );
209 209
210 /** 210 /**
211 Copys the selected contacts into clipboard for later pasting. 211 Copys the selected contacts into clipboard for later pasting.
212 */ 212 */
213 void copyContacts(); 213 void copyContacts();
214 214
215 /** 215 /**
216 Cuts the selected contacts and stores them for later pasting. 216 Cuts the selected contacts and stores them for later pasting.
217 */ 217 */
218 void cutContacts(); 218 void cutContacts();
219 219
220 /** 220 /**
221 Paste contacts from clipboard into the address book. 221 Paste contacts from clipboard into the address book.
222 */ 222 */
223 void pasteContacts(); 223 void pasteContacts();
224 224
225 /** 225 /**
226 Paste given contacts into the address book. 226 Paste given contacts into the address book.
227 227
228 @param list The list of addressee, which shall be pasted. 228 @param list The list of addressee, which shall be pasted.
229 */ 229 */
230 void pasteContacts( KABC::Addressee::List &list ); 230 void pasteContacts( KABC::Addressee::List &list );
231 231
232 /** 232 /**
233 Sets the whoAmI contact, that is used by many other programs to 233 Sets the whoAmI contact, that is used by many other programs to
234 get personal information about the current user. 234 get personal information about the current user.
235 */ 235 */
236 void setWhoAmI(); 236 void setWhoAmI();
237 237
238 /** 238 /**
239 Displays the category dialog and applies the result to all 239 Displays the category dialog and applies the result to all
240 selected contacts. 240 selected contacts.
241 */ 241 */
242 void setCategories(); 242 void setCategories();
243 243
244 /** 244 /**
245 Sets the field list of the Incremental Search Widget. 245 Sets the field list of the Incremental Search Widget.
246 */ 246 */
247 void setSearchFields( const KABC::Field::List &fields ); 247 void setSearchFields( const KABC::Field::List &fields );
248 248
249 /** 249 /**
250 Search with the current search field for a contact, that matches 250 Search with the current search field for a contact, that matches
251 the given text, and selects it in the view. 251 the given text, and selects it in the view.
252 */ 252 */
253 void incrementalSearch( const QString& text ); 253 void incrementalSearch( const QString& text );
254 254
255 /** 255 /**
256 Marks the address book as modified. 256 Marks the address book as modified.
257 */ 257 */
258 void setModified(); 258 void setModified();
259 /** 259 /**
260 Marks the address book as modified without refreshing the view. 260 Marks the address book as modified without refreshing the view.
261 */ 261 */
262 void setModifiedWOrefresh(); 262 void setModifiedWOrefresh();
263 263
264 /** 264 /**
265 Marks the address book as modified concerning the argument. 265 Marks the address book as modified concerning the argument.
266 */ 266 */
267 void setModified( bool modified ); 267 void setModified( bool modified );
268 268
269 /** 269 /**
270 Returns whether the address book is modified. 270 Returns whether the address book is modified.
271 */ 271 */
272 bool modified() const; 272 bool modified() const;
273 273
274 /** 274 /**
275 Called whenever an contact is modified in the contact editor 275 Called whenever an contact is modified in the contact editor
276 dialog or the quick edit. 276 dialog or the quick edit.
277 */ 277 */
278 void contactModified( const KABC::Addressee &addr ); 278 void contactModified( const KABC::Addressee &addr );
279 279
280 /** 280 /**
281 DCOP METHODS. 281 DCOP METHODS.
282 */ 282 */
283 void addEmail( QString addr ); 283 void addEmail( QString addr );
284 void importVCard( const KURL& url, bool showPreview ); 284 void importVCard( const KURL& url, bool showPreview );
285 void importVCard( const QString& vCard, bool showPreview ); 285 void importVCard( const QString& vCard, bool showPreview );
286 void newContact(); 286 void newContact();
287 QString getNameByPhone( const QString& phone ); 287 QString getNameByPhone( const QString& phone );
288 /** 288 /**
289 END DCOP METHODS 289 END DCOP METHODS
290 */ 290 */
291 291
292 /** 292 /**
293 Saves the contents of the AddressBook back to disk. 293 Saves the contents of the AddressBook back to disk.
294 */ 294 */
295 void save(); 295 void save();
296 296
297 /** 297 /**
298 Undos the last command using the undo stack. 298 Undos the last command using the undo stack.
299 */ 299 */
300 void undo(); 300 void undo();
301 301
302 /** 302 /**
303 Redos the last command that was undone, using the redo stack. 303 Redos the last command that was undone, using the redo stack.
304 */ 304 */
305 void redo(); 305 void redo();
306 306
307 /** 307 /**
308 Shows the edit dialog for the given uid. If the uid is QString::null, 308 Shows the edit dialog for the given uid. If the uid is QString::null,
309 the method will try to find a selected addressee in the view. 309 the method will try to find a selected addressee in the view.
310 */ 310 */
311 void editContact( const QString &uid /*US = QString::null*/ ); 311 void editContact( const QString &uid /*US = QString::null*/ );
312//US added a second method without defaultparameter 312//US added a second method without defaultparameter
313 void editContact2(); 313 void editContact2();
314 314
315 /** 315 /**
316 Shows or edits the detail view for the given uid. If the uid is QString::null, 316 Shows or edits the detail view for the given uid. If the uid is QString::null,
317 the method will try to find a selected addressee in the view. 317 the method will try to find a selected addressee in the view.
318 */ 318 */
319 void executeContact( const QString &uid /*US = QString::null*/ ); 319 void executeContact( const QString &uid /*US = QString::null*/ );
320 320
321 /** 321 /**
322 Launches the configuration dialog. 322 Launches the configuration dialog.
323 */ 323 */
324 void openConfigDialog(); 324 void openConfigDialog();
325 325
326 /** 326 /**
327 Launches the ldap search dialog. 327 Launches the ldap search dialog.
328 */ 328 */
329 void openLDAPDialog(); 329 void openLDAPDialog();
330 330
331 /** 331 /**
332 Creates a KAddressBookPrinter, which will display the print 332 Creates a KAddressBookPrinter, which will display the print
333 dialog and do the printing. 333 dialog and do the printing.
334 */ 334 */
335 void print(); 335 void print();
336 336
337 /** 337 /**
338 Registers a new GUI client, so plugins can register its actions. 338 Registers a new GUI client, so plugins can register its actions.
339 */ 339 */
340 void addGUIClient( KXMLGUIClient *client ); 340 void addGUIClient( KXMLGUIClient *client );
341 341
342 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 342 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
343 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 343 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
344 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); 344 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
345 345
346 346
347 signals: 347 signals:
348 void contactSelected( const QString &name ); 348 void contactSelected( const QString &name );
349 void contactSelected( const QPixmap &pixmap ); 349 void contactSelected( const QPixmap &pixmap );
350 public slots: 350 public slots:
351 void recieve(QString cmsg ); 351 void recieve(QString cmsg );
352 void getFile( bool success ); 352 void getFile( bool success );
353 void syncFileRequest(); 353 void syncFileRequest();
354 void setDetailsVisible( bool visible ); 354 void setDetailsVisible( bool visible );
355 void setDetailsToState(); 355 void setDetailsToState();
356 // void slotSyncMenu( int ); 356 // void slotSyncMenu( int );
357 private slots: 357 private slots:
358 void receive( const QCString& cmsg, const QByteArray& data ); 358 void receive( const QCString& cmsg, const QByteArray& data );
359 void toggleBeamReceive( ); 359 void toggleBeamReceive( );
360 void disableBR(bool); 360 void disableBR(bool);
361 void setJumpButtonBarVisible( bool visible ); 361 void setJumpButtonBarVisible( bool visible );
362 void setCaptionBack(); 362 void setCaptionBack();
363 void importFromOL(); 363 void importFromOL();
364 void extensionModified( const KABC::Addressee::List &list ); 364 void extensionModified( const KABC::Addressee::List &list );
365 void extensionChanged( int id ); 365 void extensionChanged( int id );
366 void clipboardDataChanged(); 366 void clipboardDataChanged();
367 void updateActionMenu(); 367 void updateActionMenu();
368 void configureKeyBindings(); 368 void configureKeyBindings();
369 void removeVoice(); 369 void removeVoice();
370#ifdef KAB_EMBEDDED 370#ifdef KAB_EMBEDDED
371 void configureResources(); 371 void configureResources();
372#endif //KAB_EMBEDDED 372#endif //KAB_EMBEDDED
373 373
374 void slotEditorDestroyed( const QString &uid ); 374 void slotEditorDestroyed( const QString &uid );
375 void configurationChanged(); 375 void configurationChanged();
376 void addressBookChanged(); 376 void addressBookChanged();
377 377
378 private: 378 private:
379 bool mBRdisabled; 379 bool mBRdisabled;
380#ifndef DESKTOP_VERSION 380#ifndef DESKTOP_VERSION
381 QCopChannel* infrared; 381 QCopChannel* infrared;
382#endif 382#endif
383 QTimer *mMessageTimer; 383 QTimer *mMessageTimer;
384 void initGUI(); 384 void initGUI();
385 void initActions(); 385 void initActions();
386 QString getPhoneFile(); 386 QString getPhoneFile();
387 387
388 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 388 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
389 const char *name = 0 ); 389 const char *name = 0 );
390 390
391 KXMLGUIClient *mGUIClient; 391 KXMLGUIClient *mGUIClient;
392 392
393 KABC::AddressBook *mAddressBook; 393 KABC::AddressBook *mAddressBook;
394 394
395 ViewManager *mViewManager; 395 ViewManager *mViewManager;
396 // QSplitter *mDetailsSplitter; 396 // QSplitter *mDetailsSplitter;
397 KDGanttMinimizeSplitter *mExtensionBarSplitter; 397 KDGanttMinimizeSplitter *mExtensionBarSplitter;
398 ViewContainer *mDetails; 398 ViewContainer *mDetails;
399 KDGanttMinimizeSplitter* mMiniSplitter; 399 KDGanttMinimizeSplitter* mMiniSplitter;
400 XXPortManager *mXXPortManager; 400 XXPortManager *mXXPortManager;
401 JumpButtonBar *mJumpButtonBar; 401 JumpButtonBar *mJumpButtonBar;
402 IncSearchWidget *mIncSearchWidget; 402 IncSearchWidget *mIncSearchWidget;
403 ExtensionManager *mExtensionManager; 403 ExtensionManager *mExtensionManager;
404 404
405 KCMultiDialog *mConfigureDialog; 405 KCMultiDialog *mConfigureDialog;
406 406
407#ifndef KAB_EMBEDDED 407#ifndef KAB_EMBEDDED
408 LDAPSearchDialog *mLdapSearchDialog; 408 LDAPSearchDialog *mLdapSearchDialog;
409#endif //KAB_EMBEDDED 409#endif //KAB_EMBEDDED
410 // QDict<AddresseeEditorDialog> mEditorDict; 410 // QDict<AddresseeEditorDialog> mEditorDict;
411 AddresseeEditorDialog *mEditorDialog; 411 AddresseeEditorDialog *mEditorDialog;
412 bool mReadWrite; 412 bool mReadWrite;
413 bool mModified; 413 bool mModified;
414 bool mIsPart; 414 bool mIsPart;
415 bool mMultipleViewsAtOnce; 415 bool mMultipleViewsAtOnce;
416 416
417 417
418 //US file menu 418 //US file menu
419 KAction *mActionMail; 419 KAction *mActionMail;
420 KAction *mActionBeam; 420 KAction *mActionBeam;
421 KToggleAction *mActionBR; 421 KToggleAction *mActionBR;
422 KAction *mActionExport2phone; 422 KAction *mActionExport2phone;
423 KAction* mActionPrint; 423 KAction* mActionPrint;
424 KAction* mActionNewContact; 424 KAction* mActionNewContact;
425 KAction *mActionSave; 425 KAction *mActionSave;
426 KAction *mActionEditAddressee; 426 KAction *mActionEditAddressee;
427 KAction *mActionMailVCard; 427 KAction *mActionMailVCard;
428 KAction *mActionBeamVCard; 428 KAction *mActionBeamVCard;
429 429
430 KAction *mActionQuit; 430 KAction *mActionQuit;
431 431
432 //US edit menu 432 //US edit menu
433 KAction *mActionCopy; 433 KAction *mActionCopy;
434 KAction *mActionCut; 434 KAction *mActionCut;
435 KAction *mActionPaste; 435 KAction *mActionPaste;
436 KAction *mActionSelectAll; 436 KAction *mActionSelectAll;
437 KAction *mActionUndo; 437 KAction *mActionUndo;
438 KAction *mActionRedo; 438 KAction *mActionRedo;
439 KAction *mActionDelete; 439 KAction *mActionDelete;
440 440
441 //US settings menu 441 //US settings menu
442 KAction *mActionConfigResources; 442 KAction *mActionConfigResources;
443 KAction *mActionConfigKAddressbook; 443 KAction *mActionConfigKAddressbook;
444 KAction *mActionConfigShortcuts; 444 KAction *mActionConfigShortcuts;
445 KAction *mActionConfigureToolbars; 445 KAction *mActionConfigureToolbars;
446 KAction *mActionKeyBindings; 446 KAction *mActionKeyBindings;
447 KToggleAction *mActionJumpBar; 447 KToggleAction *mActionJumpBar;
448 KToggleAction *mActionDetails; 448 KToggleAction *mActionDetails;
449 KAction *mActionWhoAmI; 449 KAction *mActionWhoAmI;
450 KAction *mActionCategories; 450 KAction *mActionCategories;
451 KAction *mActionAboutKAddressbook; 451 KAction *mActionAboutKAddressbook;
452 KAction *mActionLicence; 452 KAction *mActionLicence;
453 KAction *mActionFaq; 453 KAction *mActionFaq;
454 KAction *mActionWN; 454 KAction *mActionWN;
455 KAction *mActionSyncHowto; 455 KAction *mActionSyncHowto;
456 456
457 KAction *mActionDeleteView; 457 KAction *mActionDeleteView;
458 458
459 QPopupMenu *viewMenu; 459 QPopupMenu *viewMenu;
460 QPopupMenu *filterMenu; 460 QPopupMenu *filterMenu;
461 QPopupMenu *settingsMenu; 461 QPopupMenu *settingsMenu;
462 QPopupMenu *changeMenu; 462 QPopupMenu *changeMenu;
463//US QAction *mActionSave; 463//US QAction *mActionSave;
464 QPopupMenu *ImportMenu; 464 QPopupMenu *ImportMenu;
465 QPopupMenu *ExportMenu; 465 QPopupMenu *ExportMenu;
466 //LR additional methods 466 //LR additional methods
467 KAction *mActionRemoveVoice; 467 KAction *mActionRemoveVoice;
468 KAction * mActionImportOL; 468 KAction * mActionImportOL;
469 469
470#ifndef KAB_EMBEDDED 470#ifndef KAB_EMBEDDED
471 KAddressBookService *mAddressBookService; 471 KAddressBookService *mAddressBookService;
472#endif //KAB_EMBEDDED 472#endif //KAB_EMBEDDED
473 473
474 class KABCorePrivate; 474 class KABCorePrivate;
475 KABCorePrivate *d; 475 KABCorePrivate *d;
476 //US bool mBlockSaveFlag; 476 //US bool mBlockSaveFlag;
477 477
478#ifdef KAB_EMBEDDED 478#ifdef KAB_EMBEDDED
479 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 479 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
480#endif //KAB_EMBEDDED 480#endif //KAB_EMBEDDED
481 481
482 //this are the overwritten callbackmethods from the syncinterface 482 //this are the overwritten callbackmethods from the syncinterface
483 virtual bool sync(KSyncManager* manager, QString filename, int mode); 483 virtual bool sync(KSyncManager* manager, QString filename, int mode);
484 virtual bool syncExternal(KSyncManager* manager, QString resource); 484 virtual bool syncExternal(KSyncManager* manager, QString resource);
485 virtual void removeSyncInfo( QString syncProfile);
485 bool syncPhone(); 486 bool syncPhone();
486 void message( QString m ); 487 void message( QString m );
487 488
488 // LR ******************************* 489 // LR *******************************
489 // sync stuff! 490 // sync stuff!
490 QString sentSyncFile(); 491 QString sentSyncFile();
491 QPopupMenu *syncMenu; 492 QPopupMenu *syncMenu;
492 KSyncManager* syncManager; 493 KSyncManager* syncManager;
493 int mGlobalSyncMode; 494 int mGlobalSyncMode;
494 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 495 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
495 KABC::Addressee getLastSyncAddressee(); 496 KABC::Addressee getLastSyncAddressee();
496 QDateTime mLastAddressbookSync; 497 QDateTime mLastAddressbookSync;
497 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 498 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
498 // ********************* 499 // *********************
499 500
500}; 501};
501 502
502#endif 503#endif
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 2ccccfa..af01625 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -3383,384 +3383,390 @@ void CalendarView::showDates(const DateList &selectedDates)
3383 } 3383 }
3384 3384
3385 QString selDates; 3385 QString selDates;
3386 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3386 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3387 if (selectedDates.first() < selectedDates.last() ) 3387 if (selectedDates.first() < selectedDates.last() )
3388 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3388 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3389 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3389 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3390 3390
3391} 3391}
3392 3392
3393QPtrList<CalFilter> CalendarView::filters() 3393QPtrList<CalFilter> CalendarView::filters()
3394{ 3394{
3395 return mFilters; 3395 return mFilters;
3396 3396
3397} 3397}
3398void CalendarView::editFilters() 3398void CalendarView::editFilters()
3399{ 3399{
3400 // kdDebug() << "CalendarView::editFilters()" << endl; 3400 // kdDebug() << "CalendarView::editFilters()" << endl;
3401 3401
3402 CalFilter *filter = mFilters.first(); 3402 CalFilter *filter = mFilters.first();
3403 while(filter) { 3403 while(filter) {
3404 kdDebug() << " Filter: " << filter->name() << endl; 3404 kdDebug() << " Filter: " << filter->name() << endl;
3405 filter = mFilters.next(); 3405 filter = mFilters.next();
3406 } 3406 }
3407 3407
3408 mDialogManager->showFilterEditDialog(&mFilters); 3408 mDialogManager->showFilterEditDialog(&mFilters);
3409} 3409}
3410void CalendarView::toggleFilter() 3410void CalendarView::toggleFilter()
3411{ 3411{
3412 showFilter(! mFilterView->isVisible()); 3412 showFilter(! mFilterView->isVisible());
3413} 3413}
3414 3414
3415KOFilterView *CalendarView::filterView() 3415KOFilterView *CalendarView::filterView()
3416{ 3416{
3417 return mFilterView; 3417 return mFilterView;
3418} 3418}
3419void CalendarView::selectFilter( int fil ) 3419void CalendarView::selectFilter( int fil )
3420{ 3420{
3421 mFilterView->setSelectedFilter( fil ); 3421 mFilterView->setSelectedFilter( fil );
3422} 3422}
3423void CalendarView::showFilter(bool visible) 3423void CalendarView::showFilter(bool visible)
3424{ 3424{
3425 if (visible) mFilterView->show(); 3425 if (visible) mFilterView->show();
3426 else mFilterView->hide(); 3426 else mFilterView->hide();
3427} 3427}
3428void CalendarView::toggleFilerEnabled( ) 3428void CalendarView::toggleFilerEnabled( )
3429{ 3429{
3430 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3430 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3431 if ( !mFilterView->filtersEnabled() ) 3431 if ( !mFilterView->filtersEnabled() )
3432 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3432 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3433 3433
3434} 3434}
3435void CalendarView::updateFilter() 3435void CalendarView::updateFilter()
3436{ 3436{
3437 CalFilter *filter = mFilterView->selectedFilter(); 3437 CalFilter *filter = mFilterView->selectedFilter();
3438 if (filter) { 3438 if (filter) {
3439 if (mFilterView->filtersEnabled()) { 3439 if (mFilterView->filtersEnabled()) {
3440 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3440 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3441 filter->setEnabled(true); 3441 filter->setEnabled(true);
3442 } 3442 }
3443 else filter->setEnabled(false); 3443 else filter->setEnabled(false);
3444 mCalendar->setFilter(filter); 3444 mCalendar->setFilter(filter);
3445 updateView(); 3445 updateView();
3446 } 3446 }
3447} 3447}
3448 3448
3449void CalendarView::filterEdited() 3449void CalendarView::filterEdited()
3450{ 3450{
3451 mFilterView->updateFilters(); 3451 mFilterView->updateFilters();
3452 updateFilter(); 3452 updateFilter();
3453 writeSettings(); 3453 writeSettings();
3454} 3454}
3455 3455
3456 3456
3457void CalendarView::takeOverEvent() 3457void CalendarView::takeOverEvent()
3458{ 3458{
3459 Incidence *incidence = currentSelection(); 3459 Incidence *incidence = currentSelection();
3460 3460
3461 if (!incidence) return; 3461 if (!incidence) return;
3462 3462
3463 incidence->setOrganizer(KOPrefs::instance()->email()); 3463 incidence->setOrganizer(KOPrefs::instance()->email());
3464 incidence->recreate(); 3464 incidence->recreate();
3465 incidence->setReadOnly(false); 3465 incidence->setReadOnly(false);
3466 3466
3467 updateView(); 3467 updateView();
3468} 3468}
3469 3469
3470void CalendarView::takeOverCalendar() 3470void CalendarView::takeOverCalendar()
3471{ 3471{
3472 // TODO: Create Calendar::allIncidences() function and use it here 3472 // TODO: Create Calendar::allIncidences() function and use it here
3473 3473
3474 QPtrList<Event> events = mCalendar->events(); 3474 QPtrList<Event> events = mCalendar->events();
3475 for(uint i=0; i<events.count(); ++i) { 3475 for(uint i=0; i<events.count(); ++i) {
3476 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3476 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3477 events.at(i)->recreate(); 3477 events.at(i)->recreate();
3478 events.at(i)->setReadOnly(false); 3478 events.at(i)->setReadOnly(false);
3479 } 3479 }
3480 3480
3481 QPtrList<Todo> todos = mCalendar->todos(); 3481 QPtrList<Todo> todos = mCalendar->todos();
3482 for(uint i=0; i<todos.count(); ++i) { 3482 for(uint i=0; i<todos.count(); ++i) {
3483 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3483 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3484 todos.at(i)->recreate(); 3484 todos.at(i)->recreate();
3485 todos.at(i)->setReadOnly(false); 3485 todos.at(i)->setReadOnly(false);
3486 } 3486 }
3487 3487
3488 QPtrList<Journal> journals = mCalendar->journals(); 3488 QPtrList<Journal> journals = mCalendar->journals();
3489 for(uint i=0; i<journals.count(); ++i) { 3489 for(uint i=0; i<journals.count(); ++i) {
3490 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3490 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3491 journals.at(i)->recreate(); 3491 journals.at(i)->recreate();
3492 journals.at(i)->setReadOnly(false); 3492 journals.at(i)->setReadOnly(false);
3493 } 3493 }
3494 3494
3495 updateView(); 3495 updateView();
3496} 3496}
3497 3497
3498void CalendarView::showIntro() 3498void CalendarView::showIntro()
3499{ 3499{
3500 kdDebug() << "To be implemented." << endl; 3500 kdDebug() << "To be implemented." << endl;
3501} 3501}
3502 3502
3503QWidgetStack *CalendarView::viewStack() 3503QWidgetStack *CalendarView::viewStack()
3504{ 3504{
3505 return mRightFrame; 3505 return mRightFrame;
3506} 3506}
3507 3507
3508QWidget *CalendarView::leftFrame() 3508QWidget *CalendarView::leftFrame()
3509{ 3509{
3510 return mLeftFrame; 3510 return mLeftFrame;
3511} 3511}
3512 3512
3513DateNavigator *CalendarView::dateNavigator() 3513DateNavigator *CalendarView::dateNavigator()
3514{ 3514{
3515 return mNavigator; 3515 return mNavigator;
3516} 3516}
3517 3517
3518KDateNavigator* CalendarView::dateNavigatorWidget() 3518KDateNavigator* CalendarView::dateNavigatorWidget()
3519{ 3519{
3520 return mDateNavigator; 3520 return mDateNavigator;
3521} 3521}
3522void CalendarView::toggleDateNavigatorWidget() 3522void CalendarView::toggleDateNavigatorWidget()
3523{ 3523{
3524 if (mDateNavigator->isVisible()) 3524 if (mDateNavigator->isVisible())
3525 mDateNavigator->hide(); 3525 mDateNavigator->hide();
3526 else 3526 else
3527 mDateNavigator->show(); 3527 mDateNavigator->show();
3528} 3528}
3529void CalendarView::addView(KOrg::BaseView *view) 3529void CalendarView::addView(KOrg::BaseView *view)
3530{ 3530{
3531 mViewManager->addView(view); 3531 mViewManager->addView(view);
3532} 3532}
3533 3533
3534void CalendarView::showView(KOrg::BaseView *view) 3534void CalendarView::showView(KOrg::BaseView *view)
3535{ 3535{
3536 mViewManager->showView(view, mLeftFrame->isVisible()); 3536 mViewManager->showView(view, mLeftFrame->isVisible());
3537} 3537}
3538 3538
3539Incidence *CalendarView::currentSelection() 3539Incidence *CalendarView::currentSelection()
3540{ 3540{
3541 return mViewManager->currentSelection(); 3541 return mViewManager->currentSelection();
3542} 3542}
3543void CalendarView::toggleAllDaySize() 3543void CalendarView::toggleAllDaySize()
3544{ 3544{
3545 /* 3545 /*
3546 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3546 if ( KOPrefs::instance()->mAllDaySize > 47 )
3547 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3547 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3548 else 3548 else
3549 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3549 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3550 */ 3550 */
3551 viewManager()->agendaView()->toggleAllDay(); 3551 viewManager()->agendaView()->toggleAllDay();
3552} 3552}
3553void CalendarView::toggleExpand() 3553void CalendarView::toggleExpand()
3554{ 3554{
3555 // if ( mLeftFrame->isHidden() ) { 3555 // if ( mLeftFrame->isHidden() ) {
3556 // mLeftFrame->show(); 3556 // mLeftFrame->show();
3557 // emit calendarViewExpanded( false ); 3557 // emit calendarViewExpanded( false );
3558 // } else { 3558 // } else {
3559 // mLeftFrame->hide(); 3559 // mLeftFrame->hide();
3560 // emit calendarViewExpanded( true ); 3560 // emit calendarViewExpanded( true );
3561 // } 3561 // }
3562 3562
3563 globalFlagBlockAgenda = 1; 3563 globalFlagBlockAgenda = 1;
3564 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3564 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3565 globalFlagBlockAgenda = 5; 3565 globalFlagBlockAgenda = 5;
3566 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3566 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3567 //mViewManager->showView( 0, true ); 3567 //mViewManager->showView( 0, true );
3568} 3568}
3569 3569
3570void CalendarView::calendarModified( bool modified, Calendar * ) 3570void CalendarView::calendarModified( bool modified, Calendar * )
3571{ 3571{
3572 setModified( modified ); 3572 setModified( modified );
3573} 3573}
3574 3574
3575Todo *CalendarView::selectedTodo() 3575Todo *CalendarView::selectedTodo()
3576{ 3576{
3577 Incidence *incidence = currentSelection(); 3577 Incidence *incidence = currentSelection();
3578 if ( incidence && incidence->type() == "Todo" ) { 3578 if ( incidence && incidence->type() == "Todo" ) {
3579 return static_cast<Todo *>( incidence ); 3579 return static_cast<Todo *>( incidence );
3580 } 3580 }
3581 3581
3582 incidence = mTodoList->selectedIncidences().first(); 3582 incidence = mTodoList->selectedIncidences().first();
3583 if ( incidence && incidence->type() == "Todo" ) { 3583 if ( incidence && incidence->type() == "Todo" ) {
3584 return static_cast<Todo *>( incidence ); 3584 return static_cast<Todo *>( incidence );
3585 } 3585 }
3586 3586
3587 return 0; 3587 return 0;
3588} 3588}
3589 3589
3590void CalendarView::dialogClosing(Incidence *in) 3590void CalendarView::dialogClosing(Incidence *in)
3591{ 3591{
3592 // mDialogList.remove(in); 3592 // mDialogList.remove(in);
3593} 3593}
3594 3594
3595void CalendarView::showIncidence() 3595void CalendarView::showIncidence()
3596{ 3596{
3597 Incidence *incidence = currentSelection(); 3597 Incidence *incidence = currentSelection();
3598 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3598 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3599 if ( incidence ) { 3599 if ( incidence ) {
3600 ShowIncidenceVisitor v; 3600 ShowIncidenceVisitor v;
3601 v.act( incidence, this ); 3601 v.act( incidence, this );
3602 } 3602 }
3603} 3603}
3604void CalendarView::editIncidenceDescription() 3604void CalendarView::editIncidenceDescription()
3605{ 3605{
3606 mFlagEditDescription = true; 3606 mFlagEditDescription = true;
3607 editIncidence(); 3607 editIncidence();
3608 mFlagEditDescription = false; 3608 mFlagEditDescription = false;
3609} 3609}
3610void CalendarView::editIncidence() 3610void CalendarView::editIncidence()
3611{ 3611{
3612 // qDebug("editIncidence() "); 3612 // qDebug("editIncidence() ");
3613 Incidence *incidence = currentSelection(); 3613 Incidence *incidence = currentSelection();
3614 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3614 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3615 if ( incidence ) { 3615 if ( incidence ) {
3616 EditIncidenceVisitor v; 3616 EditIncidenceVisitor v;
3617 v.act( incidence, this ); 3617 v.act( incidence, this );
3618 } 3618 }
3619} 3619}
3620 3620
3621void CalendarView::deleteIncidence() 3621void CalendarView::deleteIncidence()
3622{ 3622{
3623 Incidence *incidence = currentSelection(); 3623 Incidence *incidence = currentSelection();
3624 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3624 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3625 if ( incidence ) { 3625 if ( incidence ) {
3626 deleteIncidence(incidence); 3626 deleteIncidence(incidence);
3627 } 3627 }
3628} 3628}
3629 3629
3630void CalendarView::showIncidence(Incidence *incidence) 3630void CalendarView::showIncidence(Incidence *incidence)
3631{ 3631{
3632 if ( incidence ) { 3632 if ( incidence ) {
3633 ShowIncidenceVisitor v; 3633 ShowIncidenceVisitor v;
3634 v.act( incidence, this ); 3634 v.act( incidence, this );
3635 } 3635 }
3636} 3636}
3637 3637
3638void CalendarView::editIncidence(Incidence *incidence) 3638void CalendarView::editIncidence(Incidence *incidence)
3639{ 3639{
3640 if ( incidence ) { 3640 if ( incidence ) {
3641 3641
3642 EditIncidenceVisitor v; 3642 EditIncidenceVisitor v;
3643 v.act( incidence, this ); 3643 v.act( incidence, this );
3644 3644
3645 } 3645 }
3646} 3646}
3647 3647
3648void CalendarView::deleteIncidence(Incidence *incidence) 3648void CalendarView::deleteIncidence(Incidence *incidence)
3649{ 3649{
3650 //qDebug(" CalendarView::deleteIncidence "); 3650 //qDebug(" CalendarView::deleteIncidence ");
3651 if ( incidence ) { 3651 if ( incidence ) {
3652 DeleteIncidenceVisitor v; 3652 DeleteIncidenceVisitor v;
3653 v.act( incidence, this ); 3653 v.act( incidence, this );
3654 } 3654 }
3655} 3655}
3656 3656
3657 3657
3658void CalendarView::lookForOutgoingMessages() 3658void CalendarView::lookForOutgoingMessages()
3659{ 3659{
3660 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3660 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3661 ogd->loadMessages(); 3661 ogd->loadMessages();
3662} 3662}
3663 3663
3664void CalendarView::lookForIncomingMessages() 3664void CalendarView::lookForIncomingMessages()
3665{ 3665{
3666 IncomingDialog *icd = mDialogManager->incomingDialog(); 3666 IncomingDialog *icd = mDialogManager->incomingDialog();
3667 icd->retrieve(); 3667 icd->retrieve();
3668} 3668}
3669 3669
3670bool CalendarView::removeCompletedSubTodos( Todo* t ) 3670bool CalendarView::removeCompletedSubTodos( Todo* t )
3671{ 3671{
3672 bool deleteTodo = true; 3672 bool deleteTodo = true;
3673 QPtrList<Incidence> subTodos; 3673 QPtrList<Incidence> subTodos;
3674 Incidence *aTodo; 3674 Incidence *aTodo;
3675 subTodos = t->relations(); 3675 subTodos = t->relations();
3676 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3676 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3677 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3677 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3678 deleteTodo = false; 3678 deleteTodo = false;
3679 } 3679 }
3680 if ( deleteTodo ) { 3680 if ( deleteTodo ) {
3681 if ( t->isCompleted() ) { 3681 if ( t->isCompleted() ) {
3682 checkExternalId( t ); 3682 checkExternalId( t );
3683 mCalendar->deleteTodo( t ); 3683 mCalendar->deleteTodo( t );
3684 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3684 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3685 } 3685 }
3686 else 3686 else
3687 deleteTodo = false; 3687 deleteTodo = false;
3688 } 3688 }
3689 return deleteTodo; 3689 return deleteTodo;
3690 3690
3691} 3691}
3692void CalendarView::purgeCompleted() 3692void CalendarView::purgeCompleted()
3693{ 3693{
3694 int result = KMessageBox::warningContinueCancel(this, 3694 int result = KMessageBox::warningContinueCancel(this,
3695 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3695 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3696 3696
3697 if (result == KMessageBox::Continue) { 3697 if (result == KMessageBox::Continue) {
3698 3698
3699 QPtrList<Todo> todoCal; 3699 QPtrList<Todo> todoCal;
3700 QPtrList<Todo> rootTodos; 3700 QPtrList<Todo> rootTodos;
3701 //QPtrList<Incidence> rel; 3701 //QPtrList<Incidence> rel;
3702 Todo *aTodo;//, *rTodo; 3702 Todo *aTodo;//, *rTodo;
3703 Incidence *rIncidence; 3703 Incidence *rIncidence;
3704 bool childDelete = false; 3704 bool childDelete = false;
3705 bool deletedOne = true; 3705 bool deletedOne = true;
3706 todoCal = calendar()->todos(); 3706 todoCal = calendar()->todos();
3707 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3707 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3708 if ( !aTodo->relatedTo() ) 3708 if ( !aTodo->relatedTo() )
3709 rootTodos.append( aTodo ); 3709 rootTodos.append( aTodo );
3710 } 3710 }
3711 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3711 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3712 removeCompletedSubTodos( aTodo ); 3712 removeCompletedSubTodos( aTodo );
3713 } 3713 }
3714 3714
3715 updateView(); 3715 updateView();
3716 } 3716 }
3717} 3717}
3718 3718
3719void CalendarView::slotCalendarChanged() 3719void CalendarView::slotCalendarChanged()
3720{ 3720{
3721 ; 3721 ;
3722} 3722}
3723 3723
3724NavigatorBar *CalendarView::navigatorBar() 3724NavigatorBar *CalendarView::navigatorBar()
3725{ 3725{
3726 return mNavigatorBar; 3726 return mNavigatorBar;
3727} 3727}
3728 3728
3729 3729
3730 3730
3731void CalendarView::keyPressEvent ( QKeyEvent *e) 3731void CalendarView::keyPressEvent ( QKeyEvent *e)
3732{ 3732{
3733 //qDebug(" alendarView::keyPressEvent "); 3733 //qDebug(" alendarView::keyPressEvent ");
3734 e->ignore(); 3734 e->ignore();
3735} 3735}
3736 3736
3737 3737
3738bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3738bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3739{ 3739{
3740 // mSyncManager = manager; 3740 // mSyncManager = manager;
3741 mSyncKDE = false; 3741 mSyncKDE = false;
3742 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3742 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3743 qDebug("SyncKDE request detected!"); 3743 qDebug("SyncKDE request detected!");
3744 mSyncKDE = true; 3744 mSyncKDE = true;
3745 } 3745 }
3746 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3746 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3747 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3747 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3748 return syncCalendar( filename, mode ); 3748 return syncCalendar( filename, mode );
3749} 3749}
3750bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3750bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3751{ 3751{
3752 mSyncKDE = false; 3752 mSyncKDE = false;
3753 //mSyncManager = manager; 3753 //mSyncManager = manager;
3754 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3754 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3755 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3755 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3756 if ( resource == "sharp" ) 3756 if ( resource == "sharp" )
3757 syncExternal( 0 ); 3757 syncExternal( 0 );
3758 if ( resource == "phone" ) 3758 if ( resource == "phone" )
3759 syncExternal( 1 ); 3759 syncExternal( 1 );
3760 // pending setmodified 3760 // pending setmodified
3761 return true; 3761 return true;
3762} 3762}
3763void CalendarView::setSyncManager(KSyncManager* manager) 3763void CalendarView::setSyncManager(KSyncManager* manager)
3764{ 3764{
3765 mSyncManager = manager; 3765 mSyncManager = manager;
3766} 3766}
3767
3768void CalendarView::removeSyncInfo( QString syncProfile)
3769{
3770 qDebug("removeSyncInfo for profile %s ", syncProfile.latin1());
3771
3772}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 2818ee9..acc20d6 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -84,522 +84,523 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
84 Q_OBJECT 84 Q_OBJECT
85 public: 85 public:
86 /** 86 /**
87 Constructs a new calendar view widget. 87 Constructs a new calendar view widget.
88 88
89 @param calendar calendar document 89 @param calendar calendar document
90 @param parent parent window 90 @param parent parent window
91 @param name Qt internal widget object name 91 @param name Qt internal widget object name
92 */ 92 */
93 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 93 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
94 const char *name = 0 ); 94 const char *name = 0 );
95 CalendarView( Calendar *calendar, QWidget *parent = 0, 95 CalendarView( Calendar *calendar, QWidget *parent = 0,
96 const char *name = 0 ); 96 const char *name = 0 );
97 virtual ~CalendarView(); 97 virtual ~CalendarView();
98 98
99 Calendar *calendar() { return mCalendar; } 99 Calendar *calendar() { return mCalendar; }
100 100
101 KOViewManager *viewManager(); 101 KOViewManager *viewManager();
102 KODialogManager *dialogManager(); 102 KODialogManager *dialogManager();
103 103
104 QDate startDate(); 104 QDate startDate();
105 QDate endDate(); 105 QDate endDate();
106 106
107 QWidgetStack *viewStack(); 107 QWidgetStack *viewStack();
108 QWidget *leftFrame(); 108 QWidget *leftFrame();
109 NavigatorBar *navigatorBar(); 109 NavigatorBar *navigatorBar();
110 110
111 DateNavigator *dateNavigator(); 111 DateNavigator *dateNavigator();
112 KDateNavigator *dateNavigatorWidget(); 112 KDateNavigator *dateNavigatorWidget();
113 113
114 void addView(KOrg::BaseView *); 114 void addView(KOrg::BaseView *);
115 void showView(KOrg::BaseView *); 115 void showView(KOrg::BaseView *);
116 KOEventViewerDialog* getEventViewerDialog(); 116 KOEventViewerDialog* getEventViewerDialog();
117 Incidence *currentSelection(); 117 Incidence *currentSelection();
118 118
119 signals: 119 signals:
120 void tempDisableBR(bool); 120 void tempDisableBR(bool);
121 /** This todo has been modified */ 121 /** This todo has been modified */
122 void todoModified(Todo *, int); 122 void todoModified(Todo *, int);
123 123
124 /** when change is made to options dialog, the topwidget will catch this 124 /** when change is made to options dialog, the topwidget will catch this
125 * and emit this signal which notifies all widgets which have registered 125 * and emit this signal which notifies all widgets which have registered
126 * for notification to update their settings. */ 126 * for notification to update their settings. */
127 void configChanged(); 127 void configChanged();
128 /** emitted when the topwidget is closing down, so that any attached 128 /** emitted when the topwidget is closing down, so that any attached
129 child windows can also close. */ 129 child windows can also close. */
130 void closingDown(); 130 void closingDown();
131 /** emitted right before we die */ 131 /** emitted right before we die */
132 void closed(QWidget *); 132 void closed(QWidget *);
133 133
134 /** Emitted when state of modified flag changes */ 134 /** Emitted when state of modified flag changes */
135 void modifiedChanged(bool); 135 void modifiedChanged(bool);
136 void signalmodified(); 136 void signalmodified();
137 137
138 /** Emitted when state of read-only flag changes */ 138 /** Emitted when state of read-only flag changes */
139 void readOnlyChanged(bool); 139 void readOnlyChanged(bool);
140 140
141 /** Emitted when the unit of navigation changes */ 141 /** Emitted when the unit of navigation changes */
142 void changeNavStringPrev(const QString &); 142 void changeNavStringPrev(const QString &);
143 void changeNavStringNext(const QString &); 143 void changeNavStringNext(const QString &);
144 144
145 /** Emitted when state of events selection has changed and user is organizer*/ 145 /** Emitted when state of events selection has changed and user is organizer*/
146 void organizerEventsSelected(bool); 146 void organizerEventsSelected(bool);
147 /** Emitted when state of events selection has changed and user is attendee*/ 147 /** Emitted when state of events selection has changed and user is attendee*/
148 void groupEventsSelected(bool); 148 void groupEventsSelected(bool);
149 /** 149 /**
150 Emitted when an incidence gets selected. If the selection is cleared the 150 Emitted when an incidence gets selected. If the selection is cleared the
151 signal is emitted with 0 as argument. 151 signal is emitted with 0 as argument.
152 */ 152 */
153 void incidenceSelected( Incidence * ); 153 void incidenceSelected( Incidence * );
154 /** Emitted, when a todoitem is selected or deselected. */ 154 /** Emitted, when a todoitem is selected or deselected. */
155 void todoSelected( bool ); 155 void todoSelected( bool );
156 156
157 /** 157 /**
158 Emitted, when clipboard content changes. Parameter indicates if paste 158 Emitted, when clipboard content changes. Parameter indicates if paste
159 is possible or not. 159 is possible or not.
160 */ 160 */
161 void pasteEnabled(bool); 161 void pasteEnabled(bool);
162 162
163 /** Emitted, when the number of incoming messages has changed. */ 163 /** Emitted, when the number of incoming messages has changed. */
164 void numIncomingChanged(int); 164 void numIncomingChanged(int);
165 165
166 /** Emitted, when the number of outgoing messages has changed. */ 166 /** Emitted, when the number of outgoing messages has changed. */
167 void numOutgoingChanged(int); 167 void numOutgoingChanged(int);
168 168
169 /** Send status message, which can e.g. be displayed in the status bar. */ 169 /** Send status message, which can e.g. be displayed in the status bar. */
170 void statusMessage(const QString &); 170 void statusMessage(const QString &);
171 171
172 void calendarViewExpanded( bool ); 172 void calendarViewExpanded( bool );
173 void updateSearchDialog(); 173 void updateSearchDialog();
174 174
175 175
176 public slots: 176 public slots:
177 void showOpenError(); 177 void showOpenError();
178 void watchSavedFile(); 178 void watchSavedFile();
179 void recheckTimerAlarm(); 179 void recheckTimerAlarm();
180 void checkNextTimerAlarm(); 180 void checkNextTimerAlarm();
181 void addAlarm(const QDateTime &qdt, const QString &noti ); 181 void addAlarm(const QDateTime &qdt, const QString &noti );
182 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 182 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
183 void removeAlarm(const QDateTime &qdt, const QString &noti ); 183 void removeAlarm(const QDateTime &qdt, const QString &noti );
184 184
185 /** options dialog made a changed to the configuration. we catch this 185 /** options dialog made a changed to the configuration. we catch this
186 * and notify all widgets which need to update their configuration. */ 186 * and notify all widgets which need to update their configuration. */
187 void updateConfig(); 187 void updateConfig();
188 188
189 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 189 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
190 const QStringList& anniversaryList, const QStringList& realNameList, 190 const QStringList& anniversaryList, const QStringList& realNameList,
191 const QStringList& emailList, const QStringList& assembledNameList, 191 const QStringList& emailList, const QStringList& assembledNameList,
192 const QStringList& uidList); 192 const QStringList& uidList);
193 193
194 /** 194 /**
195 Load calendar from file \a filename. If \a merge is true, load 195 Load calendar from file \a filename. If \a merge is true, load
196 calendar into existing one, if it is false, clear calendar, before 196 calendar into existing one, if it is false, clear calendar, before
197 loading. Return true, if calendar could be successfully loaded. 197 loading. Return true, if calendar could be successfully loaded.
198 */ 198 */
199 bool openCalendar(QString filename, bool merge=false); 199 bool openCalendar(QString filename, bool merge=false);
200 bool syncCalendar(QString filename,int mode = 0 ); 200 bool syncCalendar(QString filename,int mode = 0 );
201 201
202 /** 202 /**
203 Save calendar data to file. Return true if calendar could be 203 Save calendar data to file. Return true if calendar could be
204 successfully saved. 204 successfully saved.
205 */ 205 */
206 bool saveCalendar(QString filename); 206 bool saveCalendar(QString filename);
207 207
208 /** 208 /**
209 Close calendar. Clear calendar data and reset views to display an empty 209 Close calendar. Clear calendar data and reset views to display an empty
210 calendar. 210 calendar.
211 */ 211 */
212 void closeCalendar(); 212 void closeCalendar();
213 213
214 /** Archive old events of calendar */ 214 /** Archive old events of calendar */
215 void archiveCalendar(); 215 void archiveCalendar();
216 216
217 void showIncidence(); 217 void showIncidence();
218 void editIncidence(); 218 void editIncidence();
219 void editIncidenceDescription(); 219 void editIncidenceDescription();
220 void deleteIncidence(); 220 void deleteIncidence();
221 void cloneIncidence(); 221 void cloneIncidence();
222 void moveIncidence(); 222 void moveIncidence();
223 void beamIncidence(); 223 void beamIncidence();
224 void toggleCancelIncidence(); 224 void toggleCancelIncidence();
225 225
226 /** create an editeventwin with supplied date/time, and if bool is true, 226 /** create an editeventwin with supplied date/time, and if bool is true,
227 * make the event take all day. */ 227 * make the event take all day. */
228 void newEvent(QDateTime, QDateTime, bool allDay = false); 228 void newEvent(QDateTime, QDateTime, bool allDay = false);
229 void newEvent(QDateTime fh); 229 void newEvent(QDateTime fh);
230 void newEvent(QDate dt); 230 void newEvent(QDate dt);
231 /** create new event without having a date hint. Takes current date as 231 /** create new event without having a date hint. Takes current date as
232 default hint. */ 232 default hint. */
233 void newEvent(); 233 void newEvent();
234 void newFloatingEvent(); 234 void newFloatingEvent();
235 235
236 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 236 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
237 void showIncidence(Incidence *); 237 void showIncidence(Incidence *);
238 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 238 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
239 void editIncidence(Incidence *); 239 void editIncidence(Incidence *);
240 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 240 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
241 void deleteIncidence(Incidence *); 241 void deleteIncidence(Incidence *);
242 void cloneIncidence(Incidence *); 242 void cloneIncidence(Incidence *);
243 void cancelIncidence(Incidence *); 243 void cancelIncidence(Incidence *);
244 /** Create an editor for the supplied event. */ 244 /** Create an editor for the supplied event. */
245 void editEvent(Event *); 245 void editEvent(Event *);
246 /** Delete the supplied event. */ 246 /** Delete the supplied event. */
247 void deleteEvent(Event *); 247 void deleteEvent(Event *);
248 /** Delete the event with the given unique ID. Returns false, if event wasn't 248 /** Delete the event with the given unique ID. Returns false, if event wasn't
249 found. */ 249 found. */
250 bool deleteEvent(const QString &uid); 250 bool deleteEvent(const QString &uid);
251 /** Create a read-only viewer dialog for the supplied event. */ 251 /** Create a read-only viewer dialog for the supplied event. */
252 void showEvent(Event *); 252 void showEvent(Event *);
253 253
254 void editJournal(Journal *); 254 void editJournal(Journal *);
255 void showJournal(Journal *); 255 void showJournal(Journal *);
256 void deleteJournal(Journal *); 256 void deleteJournal(Journal *);
257 /** Create an editor dialog for a todo */ 257 /** Create an editor dialog for a todo */
258 void editTodo(Todo *); 258 void editTodo(Todo *);
259 /** Create a read-only viewer dialog for the supplied todo */ 259 /** Create a read-only viewer dialog for the supplied todo */
260 void showTodo(Todo *); 260 void showTodo(Todo *);
261 /** create new todo */ 261 /** create new todo */
262 void newTodo(); 262 void newTodo();
263 /** create new todo with a parent todo */ 263 /** create new todo with a parent todo */
264 void newSubTodo(); 264 void newSubTodo();
265 /** create new todo with a parent todo */ 265 /** create new todo with a parent todo */
266 void newSubTodo(Todo *); 266 void newSubTodo(Todo *);
267 /** Delete todo */ 267 /** Delete todo */
268 void deleteTodo(Todo *); 268 void deleteTodo(Todo *);
269 269
270 270
271 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 271 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
272 * emitted as result. */ 272 * emitted as result. */
273 void checkClipboard(); 273 void checkClipboard();
274 274
275 /** using the KConfig associated with the kapp variable, read in the 275 /** using the KConfig associated with the kapp variable, read in the
276 * settings from the config file. 276 * settings from the config file.
277 */ 277 */
278 void readSettings(); 278 void readSettings();
279 279
280 /** write current state to config file. */ 280 /** write current state to config file. */
281 void writeSettings(); 281 void writeSettings();
282 282
283 /** read settings for calendar filters */ 283 /** read settings for calendar filters */
284 void readFilterSettings(KConfig *config); 284 void readFilterSettings(KConfig *config);
285 285
286 /** write settings for calendar filters */ 286 /** write settings for calendar filters */
287 void writeFilterSettings(KConfig *config); 287 void writeFilterSettings(KConfig *config);
288 288
289 /** passes on the message that an event has changed to the currently 289 /** passes on the message that an event has changed to the currently
290 * activated view so that it can make appropriate display changes. */ 290 * activated view so that it can make appropriate display changes. */
291 void changeEventDisplay(Event *, int); 291 void changeEventDisplay(Event *, int);
292 void changeIncidenceDisplay(Incidence *, int); 292 void changeIncidenceDisplay(Incidence *, int);
293 void changeTodoDisplay(Todo *, int); 293 void changeTodoDisplay(Todo *, int);
294 294
295 void eventAdded(Event *); 295 void eventAdded(Event *);
296 void eventChanged(Event *); 296 void eventChanged(Event *);
297 void eventToBeDeleted(Event *); 297 void eventToBeDeleted(Event *);
298 void eventDeleted(); 298 void eventDeleted();
299 299
300 void todoAdded(Todo *); 300 void todoAdded(Todo *);
301 void todoChanged(Todo *); 301 void todoChanged(Todo *);
302 void todoToBeDeleted(Todo *); 302 void todoToBeDeleted(Todo *);
303 void todoDeleted(); 303 void todoDeleted();
304 304
305 void updateView(const QDate &start, const QDate &end); 305 void updateView(const QDate &start, const QDate &end);
306 void updateView(); 306 void updateView();
307 307
308 /** Full update of visible todo views */ 308 /** Full update of visible todo views */
309 void updateTodoViews(); 309 void updateTodoViews();
310 310
311 void updateUnmanagedViews(); 311 void updateUnmanagedViews();
312 312
313 /** cut the current appointment to the clipboard */ 313 /** cut the current appointment to the clipboard */
314 void edit_cut(); 314 void edit_cut();
315 315
316 /** copy the current appointment(s) to the clipboard */ 316 /** copy the current appointment(s) to the clipboard */
317 void edit_copy(); 317 void edit_copy();
318 318
319 /** paste the current vobject(s) in the clipboard buffer into calendar */ 319 /** paste the current vobject(s) in the clipboard buffer into calendar */
320 void edit_paste(); 320 void edit_paste();
321 321
322 /** edit viewing and configuration options. */ 322 /** edit viewing and configuration options. */
323 void edit_options(); 323 void edit_options();
324 /** 324 /**
325 Functions for printing, previewing a print, and setting up printing 325 Functions for printing, previewing a print, and setting up printing
326 parameters. 326 parameters.
327 */ 327 */
328 void print(); 328 void print();
329 void printSetup(); 329 void printSetup();
330 void printPreview(); 330 void printPreview();
331 331
332 /** Export as iCalendar file */ 332 /** Export as iCalendar file */
333 void exportICalendar(); 333 void exportICalendar();
334 334
335 /** Export as vCalendar file */ 335 /** Export as vCalendar file */
336 bool exportVCalendar( QString fn); 336 bool exportVCalendar( QString fn);
337 337
338 /** pop up a dialog to show an existing appointment. */ 338 /** pop up a dialog to show an existing appointment. */
339 void appointment_show(); 339 void appointment_show();
340 /** 340 /**
341 * pop up an Appointment Dialog to edit an existing appointment.Get 341 * pop up an Appointment Dialog to edit an existing appointment.Get
342 * information on the appointment from the list of unique IDs that is 342 * information on the appointment from the list of unique IDs that is
343 * currently in the View, called currIds. 343 * currently in the View, called currIds.
344 */ 344 */
345 void appointment_edit(); 345 void appointment_edit();
346 /** 346 /**
347 * pop up dialog confirming deletion of currently selected event in the 347 * pop up dialog confirming deletion of currently selected event in the
348 * View. 348 * View.
349 */ 349 */
350 void appointment_delete(); 350 void appointment_delete();
351 351
352 /** mails the currently selected event to a particular user as a vCalendar 352 /** mails the currently selected event to a particular user as a vCalendar
353 attachment. */ 353 attachment. */
354 void action_mail(); 354 void action_mail();
355 355
356 /* frees a subtodo from it's relation */ 356 /* frees a subtodo from it's relation */
357 void todo_unsub( Todo * ); 357 void todo_unsub( Todo * );
358 void todo_resub( Todo * parent, Todo * sub ); 358 void todo_resub( Todo * parent, Todo * sub );
359 359
360 /** Take ownership of selected event. */ 360 /** Take ownership of selected event. */
361 void takeOverEvent(); 361 void takeOverEvent();
362 362
363 /** Take ownership of all events in calendar. */ 363 /** Take ownership of all events in calendar. */
364 void takeOverCalendar(); 364 void takeOverCalendar();
365 365
366 /** query whether or not the calendar is "dirty". */ 366 /** query whether or not the calendar is "dirty". */
367 bool isModified(); 367 bool isModified();
368 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 368 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
369 void setModified(bool modified=true); 369 void setModified(bool modified=true);
370 370
371 /** query if the calendar is read-only. */ 371 /** query if the calendar is read-only. */
372 bool isReadOnly(); 372 bool isReadOnly();
373 /** set state of calendar to read-only */ 373 /** set state of calendar to read-only */
374 void setReadOnly(bool readOnly=true); 374 void setReadOnly(bool readOnly=true);
375 375
376 void eventUpdated(Incidence *); 376 void eventUpdated(Incidence *);
377 377
378 /* iTIP scheduling actions */ 378 /* iTIP scheduling actions */
379 void schedule_publish(Incidence *incidence = 0); 379 void schedule_publish(Incidence *incidence = 0);
380 void schedule_request(Incidence *incidence = 0); 380 void schedule_request(Incidence *incidence = 0);
381 void schedule_refresh(Incidence *incidence = 0); 381 void schedule_refresh(Incidence *incidence = 0);
382 void schedule_cancel(Incidence *incidence = 0); 382 void schedule_cancel(Incidence *incidence = 0);
383 void schedule_add(Incidence *incidence = 0); 383 void schedule_add(Incidence *incidence = 0);
384 void schedule_reply(Incidence *incidence = 0); 384 void schedule_reply(Incidence *incidence = 0);
385 void schedule_counter(Incidence *incidence = 0); 385 void schedule_counter(Incidence *incidence = 0);
386 void schedule_declinecounter(Incidence *incidence = 0); 386 void schedule_declinecounter(Incidence *incidence = 0);
387 void schedule_publish_freebusy(int daysToPublish = 30); 387 void schedule_publish_freebusy(int daysToPublish = 30);
388 388
389 void openAddressbook(); 389 void openAddressbook();
390 390
391 void editFilters(); 391 void editFilters();
392 void toggleFilerEnabled(); 392 void toggleFilerEnabled();
393 QPtrList<CalFilter> filters(); 393 QPtrList<CalFilter> filters();
394 void toggleFilter(); 394 void toggleFilter();
395 void showFilter(bool visible); 395 void showFilter(bool visible);
396 void updateFilter(); 396 void updateFilter();
397 void filterEdited(); 397 void filterEdited();
398 void selectFilter( int ); 398 void selectFilter( int );
399 KOFilterView *filterView(); 399 KOFilterView *filterView();
400 400
401 void showIntro(); 401 void showIntro();
402 402
403 /** Move the curdatepient view date to today */ 403 /** Move the curdatepient view date to today */
404 void goToday(); 404 void goToday();
405 405
406 /** Move to the next date(s) in the current view */ 406 /** Move to the next date(s) in the current view */
407 void goNext(); 407 void goNext();
408 408
409 /** Move to the previous date(s) in the current view */ 409 /** Move to the previous date(s) in the current view */
410 void goPrevious(); 410 void goPrevious();
411 /** Move to the next date(s) in the current view */ 411 /** Move to the next date(s) in the current view */
412 void goNextMonth(); 412 void goNextMonth();
413 413
414 /** Move to the previous date(s) in the current view */ 414 /** Move to the previous date(s) in the current view */
415 void goPreviousMonth(); 415 void goPreviousMonth();
416 416
417 void toggleExpand(); 417 void toggleExpand();
418 void toggleDateNavigatorWidget(); 418 void toggleDateNavigatorWidget();
419 void toggleAllDaySize(); 419 void toggleAllDaySize();
420 void dialogClosing(Incidence *); 420 void dialogClosing(Incidence *);
421 421
422 /** Look for new messages in the inbox */ 422 /** Look for new messages in the inbox */
423 void lookForIncomingMessages(); 423 void lookForIncomingMessages();
424 /** Look for new messages in the outbox */ 424 /** Look for new messages in the outbox */
425 void lookForOutgoingMessages(); 425 void lookForOutgoingMessages();
426 426
427 void processMainViewSelection( Incidence * ); 427 void processMainViewSelection( Incidence * );
428 void processTodoListSelection( Incidence * ); 428 void processTodoListSelection( Incidence * );
429 429
430 void processIncidenceSelection( Incidence * ); 430 void processIncidenceSelection( Incidence * );
431 431
432 void purgeCompleted(); 432 void purgeCompleted();
433 bool removeCompletedSubTodos( Todo* ); 433 bool removeCompletedSubTodos( Todo* );
434 void slotCalendarChanged(); 434 void slotCalendarChanged();
435 bool importBday(); 435 bool importBday();
436 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 436 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
437 bool importQtopia( const QString &categoriesFile, 437 bool importQtopia( const QString &categoriesFile,
438 const QString &datebookFile, 438 const QString &datebookFile,
439 const QString &tasklistFile ); 439 const QString &tasklistFile );
440 void syncExternal( int mode ); 440 void syncExternal( int mode );
441 void slotSelectPickerDate( QDate ) ; 441 void slotSelectPickerDate( QDate ) ;
442 void showDatePicker( ) ; 442 void showDatePicker( ) ;
443 void moveIncidence(Incidence *) ; 443 void moveIncidence(Incidence *) ;
444 void beamIncidence(Incidence *) ; 444 void beamIncidence(Incidence *) ;
445 void beamCalendar() ; 445 void beamCalendar() ;
446 void beamFilteredCalendar() ; 446 void beamFilteredCalendar() ;
447 void beamIncidenceList(QPtrList<Incidence>) ; 447 void beamIncidenceList(QPtrList<Incidence>) ;
448 void manageCategories(); 448 void manageCategories();
449 int addCategories(); 449 int addCategories();
450 void removeCategories(); 450 void removeCategories();
451 void setSyncDevice( QString ); 451 void setSyncDevice( QString );
452 void setSyncName( QString ); 452 void setSyncName( QString );
453 protected slots: 453 protected slots:
454 void timerAlarm(); 454 void timerAlarm();
455 void suspendAlarm(); 455 void suspendAlarm();
456 void beamDone( Ir *ir ); 456 void beamDone( Ir *ir );
457 /** Select a view or adapt the current view to display the specified dates. */ 457 /** Select a view or adapt the current view to display the specified dates. */
458 void showDates( const KCal::DateList & ); 458 void showDates( const KCal::DateList & );
459 void selectWeekNum ( int ); 459 void selectWeekNum ( int );
460 460
461 public: 461 public:
462 // show a standard warning 462 // show a standard warning
463 // returns KMsgBox::yesNoCancel() 463 // returns KMsgBox::yesNoCancel()
464 int msgCalModified(); 464 int msgCalModified();
465 virtual bool sync(KSyncManager* manager, QString filename, int mode); 465 virtual bool sync(KSyncManager* manager, QString filename, int mode);
466 466
467 virtual bool syncExternal(KSyncManager* manager, QString resource); 467 virtual bool syncExternal(KSyncManager* manager, QString resource);
468 virtual void removeSyncInfo( QString syncProfile);
468 void setSyncManager(KSyncManager* manager); 469 void setSyncManager(KSyncManager* manager);
469 void setLoadedFileVersion(QDateTime); 470 void setLoadedFileVersion(QDateTime);
470 bool checkFileVersion(QString fn); 471 bool checkFileVersion(QString fn);
471 bool checkFileChanged(QString fn); 472 bool checkFileChanged(QString fn);
472 Event* getLastSyncEvent(); 473 Event* getLastSyncEvent();
473 /** Adapt navigation units correpsonding to step size of navigation of the 474 /** Adapt navigation units correpsonding to step size of navigation of the
474 * current view. 475 * current view.
475 */ 476 */
476 void adaptNavigationUnits(); 477 void adaptNavigationUnits();
477 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 478 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
478 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 479 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
479 //Attendee* getYourAttendee(Event *event); 480 //Attendee* getYourAttendee(Event *event);
480 protected: 481 protected:
481 void schedule(Scheduler::Method, Incidence *incidence = 0); 482 void schedule(Scheduler::Method, Incidence *incidence = 0);
482 483
483 // returns KMsgBox::OKCandel() 484 // returns KMsgBox::OKCandel()
484 int msgItemDelete(); 485 int msgItemDelete();
485 void showEventEditor(); 486 void showEventEditor();
486 void showTodoEditor(); 487 void showTodoEditor();
487 void writeLocale(); 488 void writeLocale();
488 Todo *selectedTodo(); 489 Todo *selectedTodo();
489 490
490 private: 491 private:
491 bool mSyncKDE; 492 bool mSyncKDE;
492 KSyncManager* mSyncManager; 493 KSyncManager* mSyncManager;
493 AlarmDialog * mAlarmDialog; 494 AlarmDialog * mAlarmDialog;
494 QString mAlarmNotification; 495 QString mAlarmNotification;
495 QString mSuspendAlarmNotification; 496 QString mSuspendAlarmNotification;
496 QTimer* mSuspendTimer; 497 QTimer* mSuspendTimer;
497 QTimer* mAlarmTimer; 498 QTimer* mAlarmTimer;
498 QTimer* mRecheckAlarmTimer; 499 QTimer* mRecheckAlarmTimer;
499 void computeAlarm( QString ); 500 void computeAlarm( QString );
500 void startAlarm( QString, QString ); 501 void startAlarm( QString, QString );
501 void setSyncEventsReadOnly(); 502 void setSyncEventsReadOnly();
502 503
503 QDateTime loadedFileVersion; 504 QDateTime loadedFileVersion;
504 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 505 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
505 void checkExternalId( Incidence * inc ); 506 void checkExternalId( Incidence * inc );
506 int mGlobalSyncMode; 507 int mGlobalSyncMode;
507 QString mCurrentSyncDevice; 508 QString mCurrentSyncDevice;
508 QString mCurrentSyncName; 509 QString mCurrentSyncName;
509 KOBeamPrefs* beamDialog; 510 KOBeamPrefs* beamDialog;
510 void init(); 511 void init();
511 int mDatePickerMode; 512 int mDatePickerMode;
512 bool mFlagEditDescription; 513 bool mFlagEditDescription;
513 QDateTime mLastCalendarSync; 514 QDateTime mLastCalendarSync;
514 void createPrinter(); 515 void createPrinter();
515 516
516 void calendarModified( bool, Calendar * ); 517 void calendarModified( bool, Calendar * );
517 518
518 CalPrinter *mCalPrinter; 519 CalPrinter *mCalPrinter;
519 520
520 QSplitter *mPanner; 521 QSplitter *mPanner;
521 QSplitter *mLeftSplitter; 522 QSplitter *mLeftSplitter;
522 QWidget *mLeftFrame; 523 QWidget *mLeftFrame;
523 QWidgetStack *mRightFrame; 524 QWidgetStack *mRightFrame;
524 525
525 KDatePicker* mDatePicker; 526 KDatePicker* mDatePicker;
526 QVBox* mDateFrame; 527 QVBox* mDateFrame;
527 NavigatorBar *mNavigatorBar; 528 NavigatorBar *mNavigatorBar;
528 529
529 KDateNavigator *mDateNavigator; // widget showing small month view. 530 KDateNavigator *mDateNavigator; // widget showing small month view.
530 531
531 KOFilterView *mFilterView; 532 KOFilterView *mFilterView;
532 533
533 ResourceView *mResourceView; 534 ResourceView *mResourceView;
534 535
535 // calendar object for this viewing instance 536 // calendar object for this viewing instance
536 Calendar *mCalendar; 537 Calendar *mCalendar;
537 538
538 CalendarResourceManager *mResourceManager; 539 CalendarResourceManager *mResourceManager;
539 540
540 FileStorage *mStorage; 541 FileStorage *mStorage;
541 542
542 DateNavigator *mNavigator; 543 DateNavigator *mNavigator;
543 544
544 KOViewManager *mViewManager; 545 KOViewManager *mViewManager;
545 KODialogManager *mDialogManager; 546 KODialogManager *mDialogManager;
546 547
547 // Calendar filters 548 // Calendar filters
548 QPtrList<CalFilter> mFilters; 549 QPtrList<CalFilter> mFilters;
549 550
550 // various housekeeping variables. 551 // various housekeeping variables.
551 bool mModified; // flag indicating if calendar is modified 552 bool mModified; // flag indicating if calendar is modified
552 bool mReadOnly; // flag indicating if calendar is read-only 553 bool mReadOnly; // flag indicating if calendar is read-only
553 QDate mSaveSingleDate; 554 QDate mSaveSingleDate;
554 555
555 Incidence *mSelectedIncidence; 556 Incidence *mSelectedIncidence;
556 Incidence *mMoveIncidence; 557 Incidence *mMoveIncidence;
557 KOTodoView *mTodoList; 558 KOTodoView *mTodoList;
558 KOEventEditor * mEventEditor; 559 KOEventEditor * mEventEditor;
559 KOTodoEditor * mTodoEditor; 560 KOTodoEditor * mTodoEditor;
560 KOEventViewerDialog * mEventViewerDialog; 561 KOEventViewerDialog * mEventViewerDialog;
561 void keyPressEvent ( QKeyEvent *e) ; 562 void keyPressEvent ( QKeyEvent *e) ;
562 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 563 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
563}; 564};
564 565
565 566
566class CalendarViewVisitor : public Incidence::Visitor 567class CalendarViewVisitor : public Incidence::Visitor
567{ 568{
568 public: 569 public:
569 CalendarViewVisitor() : mView( 0 ) {} 570 CalendarViewVisitor() : mView( 0 ) {}
570 571
571 bool act( Incidence *incidence, CalendarView *view ) 572 bool act( Incidence *incidence, CalendarView *view )
572 { 573 {
573 mView = view; 574 mView = view;
574 return incidence->accept( *this ); 575 return incidence->accept( *this );
575 } 576 }
576 577
577 protected: 578 protected:
578 CalendarView *mView; 579 CalendarView *mView;
579}; 580};
580 581
581class ShowIncidenceVisitor : public CalendarViewVisitor 582class ShowIncidenceVisitor : public CalendarViewVisitor
582{ 583{
583 protected: 584 protected:
584 bool visit( Event *event ) { mView->showEvent( event ); return true; } 585 bool visit( Event *event ) { mView->showEvent( event ); return true; }
585 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 586 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
586 bool visit( Journal * j ) { mView->showJournal( j );return true; } 587 bool visit( Journal * j ) { mView->showJournal( j );return true; }
587}; 588};
588 589
589class EditIncidenceVisitor : public CalendarViewVisitor 590class EditIncidenceVisitor : public CalendarViewVisitor
590{ 591{
591 protected: 592 protected:
592 bool visit( Event *event ) { mView->editEvent( event ); return true; } 593 bool visit( Event *event ) { mView->editEvent( event ); return true; }
593 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 594 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
594 bool visit( Journal *j ) { mView->editJournal( j); return true; } 595 bool visit( Journal *j ) { mView->editJournal( j); return true; }
595}; 596};
596 597
597class DeleteIncidenceVisitor : public CalendarViewVisitor 598class DeleteIncidenceVisitor : public CalendarViewVisitor
598{ 599{
599 protected: 600 protected:
600 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 601 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
601 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 602 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
602 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 603 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
603}; 604};
604 605
605#endif 606#endif
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 4a610fa..af4f1ab 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,211 +1,212 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
20 $Id$ 20 $Id$
21*/ 21*/
22#ifndef _KSYNCMANAGER_H 22#ifndef _KSYNCMANAGER_H
23#define _KSYNCMANAGER_H 23#define _KSYNCMANAGER_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qsocket.h> 27#include <qsocket.h>
28#include <qdatetime.h> 28#include <qdatetime.h>
29#include <qserversocket.h> 29#include <qserversocket.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qregexp.h> 31#include <qregexp.h>
32 32
33class QPopupMenu; 33class QPopupMenu;
34class KSyncProfile; 34class KSyncProfile;
35class KPimPrefs; 35class KPimPrefs;
36class QWidget; 36class QWidget;
37class KSyncManager; 37class KSyncManager;
38class KSyncInterface; 38class KSyncInterface;
39class QProgressBar; 39class QProgressBar;
40 40
41 41
42class KServerSocket : public QServerSocket 42class KServerSocket : public QServerSocket
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 45
46 public: 46 public:
47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
48 48
49 void newConnection ( int socket ) ; 49 void newConnection ( int socket ) ;
50 void setFileName( QString fn ) {mFileName = fn;}; 50 void setFileName( QString fn ) {mFileName = fn;};
51 signals: 51 signals:
52 void file_received( bool ); 52 void file_received( bool );
53 void request_file(); 53 void request_file();
54 void saveFile(); 54 void saveFile();
55 void endConnect(); 55 void endConnect();
56 private slots: 56 private slots:
57 void discardClient(); 57 void discardClient();
58 void readClient(); 58 void readClient();
59 void readBackFileFromSocket(); 59 void readBackFileFromSocket();
60 private : 60 private :
61 bool blockRC; 61 bool blockRC;
62 void send_file(); 62 void send_file();
63 void get_file(); 63 void get_file();
64 void end_connect(); 64 void end_connect();
65 QDialog* mSyncActionDialog; 65 QDialog* mSyncActionDialog;
66 QSocket* mSocket; 66 QSocket* mSocket;
67 QString mPassWord; 67 QString mPassWord;
68 QString mFileName; 68 QString mFileName;
69 QTime piTime; 69 QTime piTime;
70 QString piFileString; 70 QString piFileString;
71}; 71};
72 72
73class KCommandSocket : public QObject 73class KCommandSocket : public QObject
74{ 74{
75 Q_OBJECT 75 Q_OBJECT
76 public: 76 public:
77 enum state { successR, errorR, successW, errorW, errorTO, quiet }; 77 enum state { successR, errorR, successW, errorW, errorTO, quiet };
78 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); 78 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
79 void readFile( QString ); 79 void readFile( QString );
80 void writeFile( QString ); 80 void writeFile( QString );
81 void sendStop(); 81 void sendStop();
82 82
83 signals: 83 signals:
84 void commandFinished( KCommandSocket*, int ); 84 void commandFinished( KCommandSocket*, int );
85 private slots: 85 private slots:
86 void startReadFileFromSocket(); 86 void startReadFileFromSocket();
87 void readFileFromSocket(); 87 void readFileFromSocket();
88 void deleteSocket(); 88 void deleteSocket();
89 void writeFileToSocket(); 89 void writeFileToSocket();
90 private : 90 private :
91 QSocket* mSocket; 91 QSocket* mSocket;
92 QString mPassWord; 92 QString mPassWord;
93 Q_UINT16 mPort; 93 Q_UINT16 mPort;
94 QString mHost; 94 QString mHost;
95 QString mFileName; 95 QString mFileName;
96 QTimer* mTimerSocket; 96 QTimer* mTimerSocket;
97 int mRetVal; 97 int mRetVal;
98 QTime mTime; 98 QTime mTime;
99 QString mFileString; 99 QString mFileString;
100 bool mFirst; 100 bool mFirst;
101}; 101};
102 102
103 103
104class KSyncManager : public QObject 104class KSyncManager : public QObject
105{ 105{
106 Q_OBJECT 106 Q_OBJECT
107 107
108 public: 108 public:
109 enum TargetApp { 109 enum TargetApp {
110 KOPI = 0, 110 KOPI = 0,
111 KAPI = 1, 111 KAPI = 1,
112 PWMPI = 2 }; 112 PWMPI = 2 };
113 113
114 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 114 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
115 ~KSyncManager() ; 115 ~KSyncManager() ;
116 116
117 void multiSync( bool askforPrefs ); 117 void multiSync( bool askforPrefs );
118 bool blockSave() { return mBlockSaveFlag; } 118 bool blockSave() { return mBlockSaveFlag; }
119 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 119 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
120 void setDefaultFileName( QString s) { mDefFileName = s ;} 120 void setDefaultFileName( QString s) { mDefFileName = s ;}
121 QString defaultFileName() { return mDefFileName ;} 121 QString defaultFileName() { return mDefFileName ;}
122 QString syncFileName(); 122 QString syncFileName();
123 void enableQuick( bool ask = true); 123 void enableQuick( bool ask = true);
124 124
125 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 125 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
126 QString getCurrentSyncName() { return mCurrentSyncName; } 126 QString getCurrentSyncName() { return mCurrentSyncName; }
127 127
128 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 128 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
129 void hideProgressBar(); 129 void hideProgressBar();
130 bool isProgressBarCanceled(); 130 bool isProgressBarCanceled();
131 131
132 // sync stuff 132 // sync stuff
133 QString mLocalMachineName; 133 QString mLocalMachineName;
134 QStringList mExternSyncProfiles; 134 QStringList mExternSyncProfiles;
135 QStringList mSyncProfileNames; 135 QStringList mSyncProfileNames;
136 bool mAskForPreferences; 136 bool mAskForPreferences;
137 bool mShowSyncSummary; 137 bool mShowSyncSummary;
138 bool mIsKapiFile; 138 bool mIsKapiFile;
139 bool mWriteBackExistingOnly; 139 bool mWriteBackExistingOnly;
140 int mSyncAlgoPrefs; 140 int mSyncAlgoPrefs;
141 bool mWriteBackFile; 141 bool mWriteBackFile;
142 int mWriteBackInFuture; 142 int mWriteBackInFuture;
143 QString mPhoneDevice; 143 QString mPhoneDevice;
144 QString mPhoneConnection; 144 QString mPhoneConnection;
145 QString mPhoneModel; 145 QString mPhoneModel;
146 QString mPassWordPiSync; 146 QString mPassWordPiSync;
147 QString mActiveSyncPort; 147 QString mActiveSyncPort;
148 QString mActiveSyncIP ; 148 QString mActiveSyncIP ;
149 149
150 signals: 150 signals:
151 void save(); 151 void save();
152 void request_file(); 152 void request_file();
153 void getFile( bool ); 153 void getFile( bool );
154 154
155 public slots: 155 public slots:
156 void slotSyncMenu( int ); 156 void slotSyncMenu( int );
157 void deleteCommandSocket(KCommandSocket*s, int state); 157 void deleteCommandSocket(KCommandSocket*s, int state);
158 void readFileFromSocket(); 158 void readFileFromSocket();
159 void fillSyncMenu(); 159 void fillSyncMenu();
160 160
161 private: 161 private:
162 void syncPi(); 162 void syncPi();
163 KServerSocket * mServerSocket; 163 KServerSocket * mServerSocket;
164 KPimPrefs* mPrefs; 164 KPimPrefs* mPrefs;
165 QString mDefFileName; 165 QString mDefFileName;
166 QString mCurrentSyncDevice; 166 QString mCurrentSyncDevice;
167 QString mCurrentSyncName; 167 QString mCurrentSyncName;
168 void quickSyncLocalFile(); 168 void quickSyncLocalFile();
169 bool syncWithFile( QString fn , bool quick ); 169 bool syncWithFile( QString fn , bool quick );
170 void syncLocalFile(); 170 void syncLocalFile();
171 void syncPhone(); 171 void syncPhone();
172 void syncSharp(); 172 void syncSharp();
173 void syncKDE(); 173 void syncKDE();
174 bool syncExternalApplication(QString); 174 bool syncExternalApplication(QString);
175 int mCurrentSyncProfile ; 175 int mCurrentSyncProfile ;
176 void syncRemote( KSyncProfile* prof, bool ask = true); 176 void syncRemote( KSyncProfile* prof, bool ask = true);
177 bool edit_sync_options(); 177 bool edit_sync_options();
178 bool edit_pisync_options(); 178 bool edit_pisync_options();
179 int ringSync(); 179 int ringSync();
180 QString getPassword( ); 180 QString getPassword( );
181 bool mPisyncFinished; 181 bool mPisyncFinished;
182 bool mBlockSaveFlag; 182 bool mBlockSaveFlag;
183 QWidget* mParent; 183 QWidget* mParent;
184 KSyncInterface* mImplementation; 184 KSyncInterface* mImplementation;
185 TargetApp mTargetApp; 185 TargetApp mTargetApp;
186 QPopupMenu* mSyncMenu; 186 QPopupMenu* mSyncMenu;
187 QProgressBar* bar; 187 QProgressBar* bar;
188 188
189private slots: 189private slots:
190 void confSync(); 190 void confSync();
191 191
192 192
193}; 193};
194 194
195 195
196class KSyncInterface 196class KSyncInterface
197{ 197{
198 public : 198 public :
199 virtual void removeSyncInfo( QString syncProfile) = 0;
199 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 200 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
200 virtual bool syncExternal(KSyncManager* manager, QString resource) 201 virtual bool syncExternal(KSyncManager* manager, QString resource)
201 { 202 {
202 // empty implementation, because some syncable applications do not 203 // empty implementation, because some syncable applications do not
203 // have an external(sharpdtm) syncmode, like pwmanager. 204 // have an external(sharpdtm) syncmode, like pwmanager.
204 return false; 205 return false;
205 } 206 }
206 207
207 208
208}; 209};
209 210
210 211
211#endif 212#endif
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index 2b8f2fa..6ae6e28 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -1083,390 +1083,396 @@ bool PwM::importCsv()
1083 "opened.)"), 1083 "opened.)"),
1084 i18n("Import into This Document?")) 1084 i18n("Import into This Document?"))
1085 == KMessageBox::No) { 1085 == KMessageBox::No) {
1086 // import the data to a new window. 1086 // import the data to a new window.
1087 PwM *newInstance = init->createMainWnd(); 1087 PwM *newInstance = init->createMainWnd();
1088 bool ok = newInstance->importCsv(); 1088 bool ok = newInstance->importCsv();
1089 if (!ok) { 1089 if (!ok) {
1090 newInstance->setForceQuit(true); 1090 newInstance->setForceQuit(true);
1091 delete_and_null(newInstance); 1091 delete_and_null(newInstance);
1092 } 1092 }
1093 return ok; 1093 return ok;
1094 } 1094 }
1095 } 1095 }
1096 1096
1097 QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this); 1097 QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this);
1098 if (filename.isEmpty()) 1098 if (filename.isEmpty())
1099 return false; 1099 return false;
1100 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1100 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1101 if (!csv.importData(filename, curDoc())) { 1101 if (!csv.importData(filename, curDoc())) {
1102 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1102 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1103 showStatMsg(i18n("CSV file import failed.")); 1103 showStatMsg(i18n("CSV file import failed."));
1104 return false; 1104 return false;
1105 } 1105 }
1106 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1106 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1107 KMessageBox::information(this, 1107 KMessageBox::information(this,
1108 i18n("Successfully imported the CSV data\n" 1108 i18n("Successfully imported the CSV data\n"
1109 "into the current document."), i18n("Successfully Imported")); 1109 "into the current document."), i18n("Successfully Imported"));
1110 showStatMsg(i18n("Successfully imported")); 1110 showStatMsg(i18n("Successfully imported"));
1111 setVirgin(false); 1111 setVirgin(false);
1112 return true; 1112 return true;
1113} 1113}
1114 1114
1115 1115
1116void PwM::exportToKWallet() 1116void PwM::exportToKWallet()
1117{ 1117{
1118#ifdef CONFIG_KWALLETIF 1118#ifdef CONFIG_KWALLETIF
1119 if (!checkAndAskForKWalletEmu()) 1119 if (!checkAndAskForKWalletEmu())
1120 return; 1120 return;
1121 PWM_ASSERT(curDoc()); 1121 PWM_ASSERT(curDoc());
1122 if (curDoc()->isDocEmpty()) { 1122 if (curDoc()->isDocEmpty()) {
1123 KMessageBox::information(this, 1123 KMessageBox::information(this,
1124 i18n 1124 i18n
1125 ("Sorry, there's nothing to export.\n" 1125 ("Sorry, there's nothing to export.\n"
1126 "Please first add some passwords."), 1126 "Please first add some passwords."),
1127 i18n("nothing to do")); 1127 i18n("nothing to do"));
1128 init->initKWalletEmu(); 1128 init->initKWalletEmu();
1129 return; 1129 return;
1130 } 1130 }
1131 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1131 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1132 KWalletIf walletIf(this); 1132 KWalletIf walletIf(this);
1133 if (walletIf.kwalletExport(curDoc())) { 1133 if (walletIf.kwalletExport(curDoc())) {
1134 KMessageBox::information(this, 1134 KMessageBox::information(this,
1135 i18n("Successfully exported the data of the current " 1135 i18n("Successfully exported the data of the current "
1136 "document to KWallet."), 1136 "document to KWallet."),
1137 i18n("Successfully exported data.")); 1137 i18n("Successfully exported data."));
1138 showStatMsg(i18n("Successfully exported data.")); 1138 showStatMsg(i18n("Successfully exported data."));
1139 } 1139 }
1140 init->initKWalletEmu(); 1140 init->initKWalletEmu();
1141 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1141 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1142#endif // CONFIG_KWALLETIF 1142#endif // CONFIG_KWALLETIF
1143} 1143}
1144 1144
1145bool PwM::importFromGpasman() 1145bool PwM::importFromGpasman()
1146{ 1146{
1147 if (!isVirgin()) { 1147 if (!isVirgin()) {
1148 if (KMessageBox::questionYesNo(this, 1148 if (KMessageBox::questionYesNo(this,
1149 i18n("Do you want to import the data\n" 1149 i18n("Do you want to import the data\n"
1150 "into the current document? (If you\n" 1150 "into the current document? (If you\n"
1151 "select \"no\", a new document will be\n" 1151 "select \"no\", a new document will be\n"
1152 "opened.)"), 1152 "opened.)"),
1153 i18n("import into this document?")) 1153 i18n("import into this document?"))
1154 == KMessageBox::No) { 1154 == KMessageBox::No) {
1155 // import the data to a new window. 1155 // import the data to a new window.
1156 PwM *newInstance = init->createMainWnd(); 1156 PwM *newInstance = init->createMainWnd();
1157 bool ok = newInstance->importFromGpasman(); 1157 bool ok = newInstance->importFromGpasman();
1158 if (!ok) { 1158 if (!ok) {
1159 newInstance->setForceQuit(true); 1159 newInstance->setForceQuit(true);
1160 delete_and_null(newInstance); 1160 delete_and_null(newInstance);
1161 } 1161 }
1162 return ok; 1162 return ok;
1163 } 1163 }
1164 } 1164 }
1165 1165
1166 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1166 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1167 PwMerror ret; 1167 PwMerror ret;
1168 QString path(KFileDialog::getOpenFileName(QString::null, 1168 QString path(KFileDialog::getOpenFileName(QString::null,
1169 i18n("*|Gpasman or Kpasman file"), this)); 1169 i18n("*|Gpasman or Kpasman file"), this));
1170 if (path == "") 1170 if (path == "")
1171 goto cancelImport; 1171 goto cancelImport;
1172 ret = curDoc()->importFromGpasman(&path); 1172 ret = curDoc()->importFromGpasman(&path);
1173 if (ret == e_wrongPw) { 1173 if (ret == e_wrongPw) {
1174 if (KMessageBox::questionYesNo(this, 1174 if (KMessageBox::questionYesNo(this,
1175 i18n 1175 i18n
1176 ("This is probably the wrong master-password\n" 1176 ("This is probably the wrong master-password\n"
1177 "you have typed in.\n" 1177 "you have typed in.\n"
1178 "There is no real way to determine the\n" 1178 "There is no real way to determine the\n"
1179 "correctness of the password in the Gpasman\n" 1179 "correctness of the password in the Gpasman\n"
1180 "file-format. But I think this\n" 1180 "file-format. But I think this\n"
1181 "password ist wrong.\n" 1181 "password ist wrong.\n"
1182 "Do you want to continue nevertheless?"), 1182 "Do you want to continue nevertheless?"),
1183 i18n("password error")) 1183 i18n("password error"))
1184 == KMessageBox::No) { 1184 == KMessageBox::No) {
1185 goto cancelImport; 1185 goto cancelImport;
1186 } 1186 }
1187 } else if (ret != e_success) { 1187 } else if (ret != e_success) {
1188 KMessageBox::error(this, 1188 KMessageBox::error(this,
1189 i18n("Could not import file!\n" 1189 i18n("Could not import file!\n"
1190 "Do you have permission to read this file?"), 1190 "Do you have permission to read this file?"),
1191 i18n("import failed")); 1191 i18n("import failed"));
1192 goto cancelImport; 1192 goto cancelImport;
1193 } 1193 }
1194 setVirgin(false); 1194 setVirgin(false);
1195 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1195 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1196 return true; 1196 return true;
1197 1197
1198cancelImport: 1198cancelImport:
1199 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1199 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1200 return false; 1200 return false;
1201} 1201}
1202 1202
1203#ifdef CONFIG_KWALLETIF 1203#ifdef CONFIG_KWALLETIF
1204bool PwM::checkAndAskForKWalletEmu() 1204bool PwM::checkAndAskForKWalletEmu()
1205{ 1205{
1206 if (init->kwalletEmu()) { 1206 if (init->kwalletEmu()) {
1207 /* KWallet emulation is enabled. We can't import/export 1207 /* KWallet emulation is enabled. We can't import/export
1208 * data from/to it, while emulation is active. 1208 * data from/to it, while emulation is active.
1209 */ 1209 */
1210 if (KMessageBox::questionYesNo(this, 1210 if (KMessageBox::questionYesNo(this,
1211 i18n("KWallet emulation is enabled.\n" 1211 i18n("KWallet emulation is enabled.\n"
1212 "You can't import or export data from/to " 1212 "You can't import or export data from/to "
1213 "the original KWallet, while the emulation " 1213 "the original KWallet, while the emulation "
1214 "is active.\n" 1214 "is active.\n"
1215 "Do you want to tempoarly disable the KWallet emulation?"), 1215 "Do you want to tempoarly disable the KWallet emulation?"),
1216 i18n("Tempoarly disable KWallet emulation?")) 1216 i18n("Tempoarly disable KWallet emulation?"))
1217 == KMessageBox::Yes) { 1217 == KMessageBox::Yes) {
1218 init->initKWalletEmu(true); 1218 init->initKWalletEmu(true);
1219 PWM_ASSERT(!init->kwalletEmu()); 1219 PWM_ASSERT(!init->kwalletEmu());
1220 return true; 1220 return true;
1221 } 1221 }
1222 return false; 1222 return false;
1223 } 1223 }
1224 return true; 1224 return true;
1225} 1225}
1226#endif // CONFIG_KWALLETIF 1226#endif // CONFIG_KWALLETIF
1227 1227
1228bool PwM::importKWallet() 1228bool PwM::importKWallet()
1229{ 1229{
1230#ifdef CONFIG_KWALLETIF 1230#ifdef CONFIG_KWALLETIF
1231 if (!checkAndAskForKWalletEmu()) 1231 if (!checkAndAskForKWalletEmu())
1232 return false; 1232 return false;
1233 KWalletIf walletIf(this); 1233 KWalletIf walletIf(this);
1234 if (!isVirgin()) { 1234 if (!isVirgin()) {
1235 if (KMessageBox::questionYesNo(this, 1235 if (KMessageBox::questionYesNo(this,
1236 i18n("Do you want to import the data " 1236 i18n("Do you want to import the data "
1237 "into the current document? (If you " 1237 "into the current document? (If you "
1238 "select \"no\", a new document will be " 1238 "select \"no\", a new document will be "
1239 "opened.)"), 1239 "opened.)"),
1240 i18n("import into this document?")) 1240 i18n("import into this document?"))
1241 == KMessageBox::No) { 1241 == KMessageBox::No) {
1242 // import the data to a new window. 1242 // import the data to a new window.
1243 PwM *newInstance = init->createMainWnd(); 1243 PwM *newInstance = init->createMainWnd();
1244 bool ok = newInstance->importKWallet(); 1244 bool ok = newInstance->importKWallet();
1245 if (!ok) { 1245 if (!ok) {
1246 newInstance->setForceQuit(true); 1246 newInstance->setForceQuit(true);
1247 delete_and_null(newInstance); 1247 delete_and_null(newInstance);
1248 goto exit_fail; 1248 goto exit_fail;
1249 } else { 1249 } else {
1250 goto exit_ok; 1250 goto exit_ok;
1251 } 1251 }
1252 } 1252 }
1253 } 1253 }
1254 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1254 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1255 if (!walletIf.kwalletImport(curDoc())) { 1255 if (!walletIf.kwalletImport(curDoc())) {
1256 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1256 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1257 showStatMsg(i18n("KWallet import failed")); 1257 showStatMsg(i18n("KWallet import failed"));
1258 goto exit_fail; 1258 goto exit_fail;
1259 } 1259 }
1260 KMessageBox::information(this, 1260 KMessageBox::information(this,
1261 i18n("Successfully imported the KWallet data " 1261 i18n("Successfully imported the KWallet data "
1262 "into the current document."), 1262 "into the current document."),
1263 i18n("successfully imported")); 1263 i18n("successfully imported"));
1264 showStatMsg(i18n("successfully imported")); 1264 showStatMsg(i18n("successfully imported"));
1265 setVirgin(false); 1265 setVirgin(false);
1266 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1266 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1267 1267
1268exit_ok: 1268exit_ok:
1269 init->initKWalletEmu(); 1269 init->initKWalletEmu();
1270 return true; 1270 return true;
1271 1271
1272exit_fail: 1272exit_fail:
1273 init->initKWalletEmu(); 1273 init->initKWalletEmu();
1274#endif // CONFIG_KWALLETIF 1274#endif // CONFIG_KWALLETIF
1275 return false; 1275 return false;
1276} 1276}
1277 1277
1278void PwM::print_slot() 1278void PwM::print_slot()
1279{ 1279{
1280 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1280 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1281#ifndef PWM_EMBEDDED 1281#ifndef PWM_EMBEDDED
1282 PwMPrint p(curDoc(), this); 1282 PwMPrint p(curDoc(), this);
1283 p.printNow(); 1283 p.printNow();
1284#else 1284#else
1285 qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED"); 1285 qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED");
1286#endif 1286#endif
1287 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1287 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1288} 1288}
1289 1289
1290void PwM::genNewCard_slot() 1290void PwM::genNewCard_slot()
1291{ 1291{
1292#ifdef CONFIG_KEYCARD 1292#ifdef CONFIG_KEYCARD
1293 init->keycard()->genNewCard(); 1293 init->keycard()->genNewCard();
1294#endif 1294#endif
1295} 1295}
1296 1296
1297void PwM::eraseCard_slot() 1297void PwM::eraseCard_slot()
1298{ 1298{
1299#ifdef CONFIG_KEYCARD 1299#ifdef CONFIG_KEYCARD
1300 init->keycard()->eraseCard(); 1300 init->keycard()->eraseCard();
1301#endif 1301#endif
1302} 1302}
1303 1303
1304void PwM::readCardId_slot() 1304void PwM::readCardId_slot()
1305{ 1305{
1306#ifdef CONFIG_KEYCARD 1306#ifdef CONFIG_KEYCARD
1307 init->keycard()->displayKey(); 1307 init->keycard()->displayKey();
1308#endif 1308#endif
1309} 1309}
1310 1310
1311void PwM::makeCardBackup_slot() 1311void PwM::makeCardBackup_slot()
1312{ 1312{
1313#ifdef CONFIG_KEYCARD 1313#ifdef CONFIG_KEYCARD
1314 init->keycard()->makeBackupImage(); 1314 init->keycard()->makeBackupImage();
1315#endif 1315#endif
1316} 1316}
1317 1317
1318void PwM::replayCardBackup_slot() 1318void PwM::replayCardBackup_slot()
1319{ 1319{
1320#ifdef CONFIG_KEYCARD 1320#ifdef CONFIG_KEYCARD
1321 init->keycard()->replayBackupImage(); 1321 init->keycard()->replayBackupImage();
1322#endif 1322#endif
1323} 1323}
1324 1324
1325void PwM::execLauncher_slot() 1325void PwM::execLauncher_slot()
1326{ 1326{
1327 PWM_ASSERT(curDoc()); 1327 PWM_ASSERT(curDoc());
1328 if (curDoc()->isDeepLocked()) 1328 if (curDoc()->isDeepLocked())
1329 return; 1329 return;
1330 unsigned int curEntryIndex; 1330 unsigned int curEntryIndex;
1331 if (!view->getCurEntryIndex(&curEntryIndex)) 1331 if (!view->getCurEntryIndex(&curEntryIndex))
1332 return; 1332 return;
1333 bool ret = curDoc()->execLauncher(view->getCurrentCategory(), 1333 bool ret = curDoc()->execLauncher(view->getCurrentCategory(),
1334 curEntryIndex); 1334 curEntryIndex);
1335 if (ret) 1335 if (ret)
1336 showStatMsg(i18n("Executed the \"Launcher\".")); 1336 showStatMsg(i18n("Executed the \"Launcher\"."));
1337 else 1337 else
1338 showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!")); 1338 showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!"));
1339} 1339}
1340 1340
1341void PwM::goToURL_slot() 1341void PwM::goToURL_slot()
1342{ 1342{
1343 PWM_ASSERT(curDoc()); 1343 PWM_ASSERT(curDoc());
1344 if (curDoc()->isDeepLocked()) 1344 if (curDoc()->isDeepLocked())
1345 return; 1345 return;
1346 unsigned int curEntryIndex; 1346 unsigned int curEntryIndex;
1347 if (!view->getCurEntryIndex(&curEntryIndex)) 1347 if (!view->getCurEntryIndex(&curEntryIndex))
1348 return; 1348 return;
1349 bool ret = curDoc()->goToURL(view->getCurrentCategory(), 1349 bool ret = curDoc()->goToURL(view->getCurrentCategory(),
1350 curEntryIndex); 1350 curEntryIndex);
1351 if (ret) 1351 if (ret)
1352 showStatMsg(i18n("started browser with current URL.")); 1352 showStatMsg(i18n("started browser with current URL."));
1353 else 1353 else
1354 showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?")); 1354 showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?"));
1355} 1355}
1356 1356
1357void PwM::copyToClipboard(const QString &s) 1357void PwM::copyToClipboard(const QString &s)
1358{ 1358{
1359 QClipboard *cb = QApplication::clipboard(); 1359 QClipboard *cb = QApplication::clipboard();
1360#ifndef PWM_EMBEDDED 1360#ifndef PWM_EMBEDDED
1361 if (cb->supportsSelection()) 1361 if (cb->supportsSelection())
1362 cb->setText(s, QClipboard::Selection); 1362 cb->setText(s, QClipboard::Selection);
1363 cb->setText(s, QClipboard::Clipboard); 1363 cb->setText(s, QClipboard::Clipboard);
1364#else 1364#else
1365 cb->setText(s); 1365 cb->setText(s);
1366 1366
1367#endif 1367#endif
1368 1368
1369} 1369}
1370 1370
1371 1371
1372void PwM::showStatMsg(const QString &msg) 1372void PwM::showStatMsg(const QString &msg)
1373{ 1373{
1374#ifdef DESKTOP_VERSION 1374#ifdef DESKTOP_VERSION
1375 statusBar()->message(msg, STATUSBAR_MSG_TIMEOUT * 1000); 1375 statusBar()->message(msg, STATUSBAR_MSG_TIMEOUT * 1000);
1376#else 1376#else
1377 qDebug("Statusbar : %s",msg.latin1()); 1377 qDebug("Statusbar : %s",msg.latin1());
1378 Global::statusMessage(msg); 1378 Global::statusMessage(msg);
1379#endif 1379#endif
1380} 1380}
1381 1381
1382void PwM::focusInEvent(QFocusEvent *e) 1382void PwM::focusInEvent(QFocusEvent *e)
1383{ 1383{
1384 if (e->gotFocus()) { 1384 if (e->gotFocus()) {
1385 emit gotFocus(this); 1385 emit gotFocus(this);
1386 } else if (e->lostFocus()) { 1386 } else if (e->lostFocus()) {
1387 emit lostFocus(this); 1387 emit lostFocus(this);
1388 } 1388 }
1389} 1389}
1390 1390
1391 1391
1392#ifdef PWM_EMBEDDED 1392#ifdef PWM_EMBEDDED
1393 1393
1394void PwM::whatsnew_slot() 1394void PwM::whatsnew_slot()
1395{ 1395{
1396 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1396 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1397} 1397}
1398 1398
1399void PwM::showLicense_slot() 1399void PwM::showLicense_slot()
1400{ 1400{
1401 KApplication::showLicence(); 1401 KApplication::showLicence();
1402} 1402}
1403 1403
1404void PwM::faq_slot() 1404void PwM::faq_slot()
1405{ 1405{
1406 KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" ); 1406 KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" );
1407} 1407}
1408 1408
1409void PwM::syncHowTo_slot() 1409void PwM::syncHowTo_slot()
1410{ 1410{
1411 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1411 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1412} 1412}
1413 1413
1414 1414
1415void PwM::createAboutData_slot() 1415void PwM::createAboutData_slot()
1416{ 1416{
1417 QString version; 1417 QString version;
1418#include <../version> 1418#include <../version>
1419; 1419;
1420 QMessageBox::about( this, "About PwManager/Pi", 1420 QMessageBox::about( this, "About PwManager/Pi",
1421 "PwManager/Platform-independent\n" 1421 "PwManager/Platform-independent\n"
1422 "(PWM/Pi) " +version + " - " + 1422 "(PWM/Pi) " +version + " - " +
1423#ifdef DESKTOP_VERSION 1423#ifdef DESKTOP_VERSION
1424 "Desktop Edition\n" 1424 "Desktop Edition\n"
1425#else 1425#else
1426 "PDA-Edition\n" 1426 "PDA-Edition\n"
1427 "for: Zaurus 5500 / 7x0 / 8x0\n" 1427 "for: Zaurus 5500 / 7x0 / 8x0\n"
1428#endif 1428#endif
1429 1429
1430 "(c) 2004 Ulf Schenk\n" 1430 "(c) 2004 Ulf Schenk\n"
1431 "(c) 2004 Lutz Rogowski\n" 1431 "(c) 2004 Lutz Rogowski\n"
1432 "(c) 1997-2004, The KDE PIM Team\n" 1432 "(c) 1997-2004, The KDE PIM Team\n"
1433 1433
1434 "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n" 1434 "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n"
1435 "Matt Scifo - mscifo@o1.com\n" 1435 "Matt Scifo - mscifo@o1.com\n"
1436 "Elias Probst - elias.probst@gmx.de\n" 1436 "Elias Probst - elias.probst@gmx.de\n"
1437 "George Staikos - staikos@kde.org\n" 1437 "George Staikos - staikos@kde.org\n"
1438 "Matthew Palmer - mjp16@uow.edu.au\n" 1438 "Matthew Palmer - mjp16@uow.edu.au\n"
1439 "Olivier Sessink - gpasman@nl.linux.org\n" 1439 "Olivier Sessink - gpasman@nl.linux.org\n"
1440 "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n" 1440 "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n"
1441 "Troy Engel - tengel@sonic.net\n" 1441 "Troy Engel - tengel@sonic.net\n"
1442 "Wickey - wickey@gmx.at\n" 1442 "Wickey - wickey@gmx.at\n"
1443 "Ian MacGregor - original documentation author.\n" 1443 "Ian MacGregor - original documentation author.\n"
1444 ); 1444 );
1445} 1445}
1446 1446
1447 1447
1448//this are the overwritten callbackmethods from the syncinterface 1448//this are the overwritten callbackmethods from the syncinterface
1449bool PwM::sync(KSyncManager* manager, QString filename, int mode) 1449bool PwM::sync(KSyncManager* manager, QString filename, int mode)
1450{ 1450{
1451 PWM_ASSERT(curDoc()); 1451 PWM_ASSERT(curDoc());
1452 1452
1453 bool ret = curDoc()->sync(manager, filename, mode); 1453 bool ret = curDoc()->sync(manager, filename, mode);
1454 1454
1455 qDebug("PwM::sync save now: ret=%i", ret); 1455 qDebug("PwM::sync save now: ret=%i", ret);
1456 1456
1457 if (ret == true) { 1457 if (ret == true) {
1458 //US BUG: what can we call here to update the view of the current doc? 1458 //US BUG: what can we call here to update the view of the current doc?
1459 //mViewManager->refreshView(); 1459 //mViewManager->refreshView();
1460 1460
1461 //US curDoc()->sync sets the dirtyFlag in case the sync was successfull. 1461 //US curDoc()->sync sets the dirtyFlag in case the sync was successfull.
1462 save(); 1462 save();
1463 } 1463 }
1464 1464
1465 return ret; 1465 return ret;
1466} 1466}
1467
1468void PwM::removeSyncInfo( QString syncProfile)
1469{
1470 qDebug("PWM::not implemented: removeSyncInfo for profile %s ", syncProfile.latin1());
1471}
1472
1467#endif 1473#endif
1468 1474
1469 1475
1470#ifndef PWM_EMBEDDED 1476#ifndef PWM_EMBEDDED
1471#include "pwm.moc" 1477#include "pwm.moc"
1472#endif 1478#endif
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h
index 5822d59..fb34bca 100644
--- a/pwmanager/pwmanager/pwm.h
+++ b/pwmanager/pwmanager/pwm.h
@@ -1,297 +1,298 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003, 2004 by Michael Buesch * 3 * copyright (C) 2003, 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#ifndef __PWM_H 20#ifndef __PWM_H
21#define __PWM_H 21#define __PWM_H
22 22
23 23
24#include <kpopupmenu.h> 24#include <kpopupmenu.h>
25#include <klistview.h> 25#include <klistview.h>
26#include <kmainwindow.h> 26#include <kmainwindow.h>
27 27
28#ifndef PWM_EMBEDDED 28#ifndef PWM_EMBEDDED
29#include <kwin.h> 29#include <kwin.h>
30#include <kapp.h> 30#include <kapp.h>
31#include <kdeversion.h> 31#include <kdeversion.h>
32#else 32#else
33#include <ksyncmanager.h> 33#include <ksyncmanager.h>
34#endif 34#endif
35 35
36#include <kaction.h> 36#include <kaction.h>
37 37
38#include <qglobal.h> 38#include <qglobal.h>
39 39
40#include "pwmview.h" 40#include "pwmview.h"
41#include "pwmexception.h" 41#include "pwmexception.h"
42 42
43 43
44/** timeout for displaying a message on the status-bar (in seconds) */ 44/** timeout for displaying a message on the status-bar (in seconds) */
45 #define STATUSBAR_MSG_TIMEOUT5 45 #define STATUSBAR_MSG_TIMEOUT5
46 46
47 47
48class PwMInit; 48class PwMInit;
49class KSyncManager; 49class KSyncManager;
50 50
51/** PwM is the base class of the project */ 51/** PwM is the base class of the project */
52#ifndef PWM_EMBEDDED 52#ifndef PWM_EMBEDDED
53//MOC_SKIP_BEGIN 53//MOC_SKIP_BEGIN
54class PwM : public KMainWindow 54class PwM : public KMainWindow
55//MOC_SKIP_END 55//MOC_SKIP_END
56#else 56#else
57class PwM : public KMainWindow, public KSyncInterface 57class PwM : public KMainWindow, public KSyncInterface
58#endif 58#endif
59{ 59{
60 Q_OBJECT 60 Q_OBJECT
61public: 61public:
62 friend class PwMView; 62 friend class PwMView;
63 /** construtor */ 63 /** construtor */
64 PwM(PwMInit *_init, PwMDoc *doc, 64 PwM(PwMInit *_init, PwMDoc *doc,
65 bool virginity = true, 65 bool virginity = true,
66 QWidget* parent = 0, const char *name = 0); 66 QWidget* parent = 0, const char *name = 0);
67 /** destructor */ 67 /** destructor */
68 ~PwM(); 68 ~PwM();
69 69
70 /** copy some text to the global clipboard */ 70 /** copy some text to the global clipboard */
71 static void copyToClipboard(const QString &s); 71 static void copyToClipboard(const QString &s);
72 72
73 /** returns pointer to the view */ 73 /** returns pointer to the view */
74 PwMView * curView() 74 PwMView * curView()
75 { return view; } 75 { return view; }
76 /** returns pointer to the currently using document. */ 76 /** returns pointer to the currently using document. */
77 PwMDoc * curDoc() 77 PwMDoc * curDoc()
78 { return curView()->document(); } 78 { return curView()->document(); }
79 /** open a new doc with the given filename */ 79 /** open a new doc with the given filename */
80 PwMDoc * openDoc(QString filename, bool openDeepLocked = false); 80 PwMDoc * openDoc(QString filename, bool openDeepLocked = false);
81 /** show a message on the global status bar. 81 /** show a message on the global status bar.
82 * The message times out after some seconds. 82 * The message times out after some seconds.
83 */ 83 */
84 void showStatMsg(const QString &msg); 84 void showStatMsg(const QString &msg);
85 /** ask the user where to save the doc (if it has not been saved, yet) 85 /** ask the user where to save the doc (if it has not been saved, yet)
86 * and write the data to disk. 86 * and write the data to disk.
87 */ 87 */
88 bool save(); 88 bool save();
89 /** ask the user where to save the doc 89 /** ask the user where to save the doc
90 * and write the data to disk. 90 * and write the data to disk.
91 */ 91 */
92 bool saveAs(); 92 bool saveAs();
93 /** force quit. Quit this window, always! Don't minimize it */ 93 /** force quit. Quit this window, always! Don't minimize it */
94 bool isForceQuit() 94 bool isForceQuit()
95 { return forceQuit; } 95 { return forceQuit; }
96 /** set forceQuit */ 96 /** set forceQuit */
97 void setForceQuit(bool force) 97 void setForceQuit(bool force)
98 { forceQuit = force; } 98 { forceQuit = force; }
99 /** force minimize this window */ 99 /** force minimize this window */
100 bool isForceMinimizeToTray() 100 bool isForceMinimizeToTray()
101 { return forceMinimizeToTray; } 101 { return forceMinimizeToTray; }
102 /** set forceMinimizeToTray */ 102 /** set forceMinimizeToTray */
103 void setForceMinimizeToTray(bool force) 103 void setForceMinimizeToTray(bool force)
104 { forceMinimizeToTray = force; } 104 { forceMinimizeToTray = force; }
105 105
106public slots: 106public slots:
107 /** file/new triggered */ 107 /** file/new triggered */
108 void new_slot(); 108 void new_slot();
109 /** file/open triggered */ 109 /** file/open triggered */
110//US ENH 110//US ENH
111 void open_slot(); 111 void open_slot();
112 void open_slot(QString fn); 112 void open_slot(QString fn);
113 /** file/close triggered */ 113 /** file/close triggered */
114 void close_slot(); 114 void close_slot();
115 /** file/quit triggered */ 115 /** file/quit triggered */
116 void quitButton_slot(); 116 void quitButton_slot();
117 /** file/save triggered */ 117 /** file/save triggered */
118 void save_slot(); 118 void save_slot();
119 /** file/saveAs triggered */ 119 /** file/saveAs triggered */
120 void saveAs_slot(); 120 void saveAs_slot();
121 /** file/export/text triggered */ 121 /** file/export/text triggered */
122 void exportToText(); 122 void exportToText();
123 /** file/export/gpasman triggered */ 123 /** file/export/gpasman triggered */
124 void exportToGpasman(); 124 void exportToGpasman();
125 /** file/export/kwallet triggered */ 125 /** file/export/kwallet triggered */
126 void exportToKWallet(); 126 void exportToKWallet();
127 /** file/export/csv triggered */ 127 /** file/export/csv triggered */
128 void exportToCsv(); 128 void exportToCsv();
129 /** file/import/text triggered */ 129 /** file/import/text triggered */
130 bool importFromText(); 130 bool importFromText();
131 /** file/import/gpasman triggered */ 131 /** file/import/gpasman triggered */
132 bool importFromGpasman(); 132 bool importFromGpasman();
133 /** file/import/kwallet triggered */ 133 /** file/import/kwallet triggered */
134 bool importKWallet(); 134 bool importKWallet();
135 /** file/import/csv triggered */ 135 /** file/import/csv triggered */
136 bool importCsv(); 136 bool importCsv();
137 /** file/print triggered */ 137 /** file/print triggered */
138 void print_slot(); 138 void print_slot();
139 /** manage/add triggered */ 139 /** manage/add triggered */
140 //US ENH : changed code to run with older MOC 140 //US ENH : changed code to run with older MOC
141 141
142 void addPwd_slot(); 142 void addPwd_slot();
143 void addPwd_slot1(QString *pw, PwMDoc *_doc); 143 void addPwd_slot1(QString *pw, PwMDoc *_doc);
144 /** manage/edit triggered */ 144 /** manage/edit triggered */
145 //US ENH : changed code to run with older MOC 145 //US ENH : changed code to run with older MOC
146 void editPwd_slot(); 146 void editPwd_slot();
147 void editPwd_slot1(const QString *category); 147 void editPwd_slot1(const QString *category);
148 void editPwd_slot3(const QString *category, const int *index ,PwMDoc *_doc ); 148 void editPwd_slot3(const QString *category, const int *index ,PwMDoc *_doc );
149 149
150 /** manage/delete triggered */ 150 /** manage/delete triggered */
151 void deletePwd_slot(); 151 void deletePwd_slot();
152 /** execute the "Launcher" entry */ 152 /** execute the "Launcher" entry */
153 void execLauncher_slot(); 153 void execLauncher_slot();
154 /** open browser with URL entry */ 154 /** open browser with URL entry */
155 void goToURL_slot(); 155 void goToURL_slot();
156 /** manage/changeMasterPwd triggered */ 156 /** manage/changeMasterPwd triggered */
157 void changeMasterPwd_slot(); 157 void changeMasterPwd_slot();
158 /** lock current document */ 158 /** lock current document */
159 void lockWnd_slot(); 159 void lockWnd_slot();
160 /** deeplock current document */ 160 /** deeplock current document */
161 void deepLockWnd_slot(); 161 void deepLockWnd_slot();
162 /** window/unlock triggered */ 162 /** window/unlock triggered */
163 void unlockWnd_slot(); 163 void unlockWnd_slot();
164 /** find item */ 164 /** find item */
165 void find_slot(); 165 void find_slot();
166 /** configure clicked */ 166 /** configure clicked */
167 void config_slot(); 167 void config_slot();
168 /** (de)activate the "change master pw" button in the menu-bar */ 168 /** (de)activate the "change master pw" button in the menu-bar */
169 void activateMpButton(bool activate = true); 169 void activateMpButton(bool activate = true);
170 /** generate a new chipcard */ 170 /** generate a new chipcard */
171 void genNewCard_slot(); 171 void genNewCard_slot();
172 /** completely erase the current card */ 172 /** completely erase the current card */
173 void eraseCard_slot(); 173 void eraseCard_slot();
174 /** returns the ID number of the current card */ 174 /** returns the ID number of the current card */
175 void readCardId_slot(); 175 void readCardId_slot();
176 /** make backup image of the current card */ 176 /** make backup image of the current card */
177 void makeCardBackup_slot(); 177 void makeCardBackup_slot();
178 /** write backup image to current card */ 178 /** write backup image to current card */
179 void replayCardBackup_slot(); 179 void replayCardBackup_slot();
180 180
181#ifdef PWM_EMBEDDED 181#ifdef PWM_EMBEDDED
182 void whatsnew_slot(); 182 void whatsnew_slot();
183 void showLicense_slot(); 183 void showLicense_slot();
184 void faq_slot(); 184 void faq_slot();
185 void createAboutData_slot(); 185 void createAboutData_slot();
186 void syncHowTo_slot(); 186 void syncHowTo_slot();
187#endif 187#endif
188 188
189protected: 189protected:
190 /** is this window virgin? */ 190 /** is this window virgin? */
191 bool isVirgin() 191 bool isVirgin()
192 { return virgin; } 192 { return virgin; }
193 /** add/remove virginity */ 193 /** add/remove virginity */
194 void setVirgin(bool v); 194 void setVirgin(bool v);
195 /** initialize the menubar */ 195 /** initialize the menubar */
196 void initMenubar(); 196 void initMenubar();
197 /** initialize the toolbar */ 197 /** initialize the toolbar */
198 void initToolbar(); 198 void initToolbar();
199 /** initialize the window-metrics */ 199 /** initialize the window-metrics */
200 void initMetrics(); 200 void initMetrics();
201 /** close-event */ 201 /** close-event */
202 void closeEvent(QCloseEvent *e); 202 void closeEvent(QCloseEvent *e);
203 /** creates a new PwM-ListView and returns it */ 203 /** creates a new PwM-ListView and returns it */
204 PwMView * makeNewListView(PwMDoc *doc); 204 PwMView * makeNewListView(PwMDoc *doc);
205 /** Window hide-event */ 205 /** Window hide-event */
206 void hideEvent(QHideEvent *); 206 void hideEvent(QHideEvent *);
207 /** is this window minimized? */ 207 /** is this window minimized? */
208 bool isMinimized() 208 bool isMinimized()
209 { 209 {
210#ifndef PWM_EMBEDDED 210#ifndef PWM_EMBEDDED
211 #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) 211 #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0)
212 return KWin::windowInfo(winId()).isMinimized(); 212 return KWin::windowInfo(winId()).isMinimized();
213 #else // KDE_VERSION 213 #else // KDE_VERSION
214 return KWin::info(winId()).isIconified(); 214 return KWin::info(winId()).isIconified();
215 #endif // KDE_VERSION 215 #endif // KDE_VERSION
216#else 216#else
217 return false; 217 return false;
218#endif 218#endif
219 } 219 }
220 /** window got the focus */ 220 /** window got the focus */
221 void focusInEvent(QFocusEvent *e); 221 void focusInEvent(QFocusEvent *e);
222 /** update the caption string */ 222 /** update the caption string */
223 void updateCaption(); 223 void updateCaption();
224#ifdef CONFIG_KWALLETIF 224#ifdef CONFIG_KWALLETIF
225 /** check if kwalletemu is enabled and ask the user what to do */ 225 /** check if kwalletemu is enabled and ask the user what to do */
226 bool checkAndAskForKWalletEmu(); 226 bool checkAndAskForKWalletEmu();
227#endif // CONFIG_KWALLETIF 227#endif // CONFIG_KWALLETIF
228 228
229protected slots: 229protected slots:
230 /** doc got closed */ 230 /** doc got closed */
231 void docClosed(PwMDoc *doc); 231 void docClosed(PwMDoc *doc);
232 232
233signals: 233signals:
234 /** window got closed (by user or someone else) */ 234 /** window got closed (by user or someone else) */
235 void closed(PwM *wnd); 235 void closed(PwM *wnd);
236 /** window got the focus (was brought to foreground) */ 236 /** window got the focus (was brought to foreground) */
237 void gotFocus(PwM *wnd); 237 void gotFocus(PwM *wnd);
238 /** window lost the focus */ 238 /** window lost the focus */
239 void lostFocus(PwM *wnd); 239 void lostFocus(PwM *wnd);
240 240
241protected: 241protected:
242 /** pointer to the view active in this KMainWindow */ 242 /** pointer to the view active in this KMainWindow */
243 PwMView *view; 243 PwMView *view;
244 /** pointer to the init class */ 244 /** pointer to the init class */
245 PwMInit *init; 245 PwMInit *init;
246 /** has this window already lost its virginity? 246 /** has this window already lost its virginity?
247 * Means is there an open working document 247 * Means is there an open working document
248 */ 248 */
249 bool virgin; 249 bool virgin;
250 /** "file" popup-menu */ 250 /** "file" popup-menu */
251 KPopupMenu *filePopup; 251 KPopupMenu *filePopup;
252 252
253 /** "manage" popup-menu */ 253 /** "manage" popup-menu */
254 KPopupMenu *managePopup; 254 KPopupMenu *managePopup;
255#ifdef CONFIG_KEYCARD 255#ifdef CONFIG_KEYCARD
256 /** "chipcard" popup-menu */ 256 /** "chipcard" popup-menu */
257 KPopupMenu *chipcardPopup; 257 KPopupMenu *chipcardPopup;
258#endif // CONFIG_KEYCARD 258#endif // CONFIG_KEYCARD
259 /** "view" popup-menu */ 259 /** "view" popup-menu */
260 KPopupMenu *viewPopup; 260 KPopupMenu *viewPopup;
261 /** "options" popup-menu */ 261 /** "options" popup-menu */
262 KPopupMenu *optionsPopup; 262 KPopupMenu *optionsPopup;
263 /** "help" popup-menu */ 263 /** "help" popup-menu */
264 KPopupMenu *helpPopup; 264 KPopupMenu *helpPopup;
265 /** "export" popup-menu */ 265 /** "export" popup-menu */
266 KPopupMenu *exportPopup; 266 KPopupMenu *exportPopup;
267 /** "import" popup-menu */ 267 /** "import" popup-menu */
268 KPopupMenu *importPopup; 268 KPopupMenu *importPopup;
269 /** force quit this window? */ 269 /** force quit this window? */
270 bool forceQuit; 270 bool forceQuit;
271 /** force minimize this window to the tray */ 271 /** force minimize this window to the tray */
272 bool forceMinimizeToTray; 272 bool forceMinimizeToTray;
273 273
274 274
275 275
276 276
277 private: 277 private:
278#ifdef PWM_EMBEDDED 278#ifdef PWM_EMBEDDED
279 //this are the overwritten callbackmethods from the syncinterface 279 //this are the overwritten callbackmethods from the syncinterface
280 virtual bool sync(KSyncManager* manager, QString filename, int mode); 280 virtual bool sync(KSyncManager* manager, QString filename, int mode);
281 virtual void removeSyncInfo( QString syncProfile);
281 282
282 // LR ******************************* 283 // LR *******************************
283 // sync stuff! 284 // sync stuff!
284 QPopupMenu *syncPopup; 285 QPopupMenu *syncPopup;
285 KSyncManager* syncManager; 286 KSyncManager* syncManager;
286#endif 287#endif
287 288
288 289
289 290
290 291
291 292
292 293
293 294
294 295
295}; 296};
296 297
297#endif 298#endif
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index cf8690f..fd17ce5 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -2923,576 +2923,579 @@ void PwMDoc::ensureLvp()
2923 //Now start with the sorted and reset listviewpos. 2923 //Now start with the sorted and reset listviewpos.
2924 sortedBegin = sorted.begin(); 2924 sortedBegin = sorted.begin();
2925 sortedEnd = sorted.end(); 2925 sortedEnd = sorted.end();
2926 sortedI = sortedBegin; 2926 sortedI = sortedBegin;
2927 2927
2928 while (sortedI != sortedEnd) { 2928 while (sortedI != sortedEnd) {
2929 // qDebug("reset defined: %s, from pos=%i to pos=%i", (*sortedI)->desc.c_str(), (*sortedI)->listViewPos, lvpTop+1); 2929 // qDebug("reset defined: %s, from pos=%i to pos=%i", (*sortedI)->desc.c_str(), (*sortedI)->listViewPos, lvpTop+1);
2930 (*sortedI)->listViewPos = ++lvpTop; 2930 (*sortedI)->listViewPos = ++lvpTop;
2931 ++sortedI; 2931 ++sortedI;
2932 } 2932 }
2933 2933
2934 /*/debug 2934 /*/debug
2935 entrBegin = catI->d.begin(); 2935 entrBegin = catI->d.begin();
2936 entrEnd = catI->d.end(); 2936 entrEnd = catI->d.end();
2937 entrI = entrBegin; 2937 entrI = entrBegin;
2938 2938
2939 while (entrI != entrEnd) { 2939 while (entrI != entrEnd) {
2940 qDebug("check: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); 2940 qDebug("check: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos);
2941 ++entrI; 2941 ++entrI;
2942 } 2942 }
2943 */ 2943 */
2944 2944
2945 ++catI; 2945 ++catI;
2946 } 2946 }
2947} 2947}
2948 2948
2949QString PwMDoc::getTitle() 2949QString PwMDoc::getTitle()
2950{ 2950{
2951 /* NOTE: We have to ensure, that the returned title 2951 /* NOTE: We have to ensure, that the returned title
2952 * is unique and not reused somewhere else while 2952 * is unique and not reused somewhere else while
2953 * this document is valid (open). 2953 * this document is valid (open).
2954 */ 2954 */
2955 QString title(getFilename()); 2955 QString title(getFilename());
2956 2956
2957 //US ENH: The whole filename on PDAs is too long. So use only the last characters 2957 //US ENH: The whole filename on PDAs is too long. So use only the last characters
2958 if (QApplication::desktop()->width() < 640) 2958 if (QApplication::desktop()->width() < 640)
2959 { 2959 {
2960 if (title.length() > 30) 2960 if (title.length() > 30)
2961 title = "..." + title.right(30); 2961 title = "..." + title.right(30);
2962 2962
2963 } 2963 }
2964 2964
2965 2965
2966 if (title.isEmpty()) { 2966 if (title.isEmpty()) {
2967 if (unnamedNum == 0) { 2967 if (unnamedNum == 0) {
2968 unnamedNum = PwMDocList::getNewUnnamedNumber(); 2968 unnamedNum = PwMDocList::getNewUnnamedNumber();
2969 PWM_ASSERT(unnamedNum != 0); 2969 PWM_ASSERT(unnamedNum != 0);
2970 } 2970 }
2971 title = DEFAULT_TITLE; 2971 title = DEFAULT_TITLE;
2972 title += " "; 2972 title += " ";
2973 title += tostr(unnamedNum).c_str(); 2973 title += tostr(unnamedNum).c_str();
2974 } 2974 }
2975 return title; 2975 return title;
2976} 2976}
2977 2977
2978bool PwMDoc::tryDelete() 2978bool PwMDoc::tryDelete()
2979{ 2979{
2980 2980
2981 if (deleted) 2981 if (deleted)
2982 return true; 2982 return true;
2983 int ret; 2983 int ret;
2984 if (isDirty()) { 2984 if (isDirty()) {
2985 ret = dirtyAskSave(getTitle()); 2985 ret = dirtyAskSave(getTitle());
2986 if (ret == 0) { // save to disk 2986 if (ret == 0) { // save to disk
2987 if (!saveDocUi(this)) 2987 if (!saveDocUi(this))
2988 goto out_ignore; 2988 goto out_ignore;
2989 } else if (ret == 1) { // don't save and delete 2989 } else if (ret == 1) { // don't save and delete
2990 goto out_accept; 2990 goto out_accept;
2991 } else { // cancel operation 2991 } else { // cancel operation
2992 goto out_ignore; 2992 goto out_ignore;
2993 } 2993 }
2994 } 2994 }
2995out_accept: 2995out_accept:
2996 deleted = true; 2996 deleted = true;
2997 delete this; 2997 delete this;
2998 return true; 2998 return true;
2999out_ignore: 2999out_ignore:
3000 return false; 3000 return false;
3001} 3001}
3002 3002
3003 3003
3004 3004
3005#ifdef PWM_EMBEDDED 3005#ifdef PWM_EMBEDDED
3006//US ENH: this is the magic function that syncronizes the this doc with the remote doc 3006//US ENH: this is the magic function that syncronizes the this doc with the remote doc
3007//US it could have been defined as static, but I did not want to. 3007//US it could have been defined as static, but I did not want to.
3008PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode ) 3008PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode )
3009{ 3009{
3010 int addedPasswordsLocal = 0; 3010 int addedPasswordsLocal = 0;
3011 int addedPasswordsRemote = 0; 3011 int addedPasswordsRemote = 0;
3012 int deletedPasswordsRemote = 0; 3012 int deletedPasswordsRemote = 0;
3013 int deletedPasswordsLocal = 0; 3013 int deletedPasswordsLocal = 0;
3014 int changedLocal = 0; 3014 int changedLocal = 0;
3015 int changedRemote = 0; 3015 int changedRemote = 0;
3016 3016
3017 PwMSyncItem* syncItemLocal; 3017 PwMSyncItem* syncItemLocal;
3018 PwMSyncItem* syncItemRemote; 3018 PwMSyncItem* syncItemRemote;
3019 3019
3020 QString mCurrentSyncName = manager->getCurrentSyncName(); 3020 QString mCurrentSyncName = manager->getCurrentSyncName();
3021 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3021 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3022 3022
3023 bool fullDateRange = false; 3023 bool fullDateRange = false;
3024 int take; 3024 int take;
3025 // local->resetTempSyncStat(); 3025 // local->resetTempSyncStat();
3026 QDateTime mLastSync = QDateTime::currentDateTime(); 3026 QDateTime mLastSync = QDateTime::currentDateTime();
3027 QDateTime modifiedSync = mLastSync; 3027 QDateTime modifiedSync = mLastSync;
3028 3028
3029 unsigned int index; 3029 unsigned int index;
3030 //Step 1. Find syncinfo in Local file and create if not existent. 3030 //Step 1. Find syncinfo in Local file and create if not existent.
3031 bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index); 3031 bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index);
3032 if (found == false) 3032 if (found == false)
3033 { 3033 {
3034 PwMSyncItem newSyncItemLocal; 3034 PwMSyncItem newSyncItemLocal;
3035 newSyncItemLocal.syncName = mCurrentSyncDevice.latin1(); 3035 newSyncItemLocal.syncName = mCurrentSyncDevice.latin1();
3036 newSyncItemLocal.lastSyncDate = mLastSync; 3036 newSyncItemLocal.lastSyncDate = mLastSync;
3037 syncLocal->addSyncDataEntry(&newSyncItemLocal, true); 3037 syncLocal->addSyncDataEntry(&newSyncItemLocal, true);
3038 found = syncLocal->findSyncData(mCurrentSyncDevice, &index); 3038 found = syncLocal->findSyncData(mCurrentSyncDevice, &index);
3039 if (found == false) { 3039 if (found == false) {
3040 qDebug("PwMDoc::syncronize : newly created local sync data could not be found"); 3040 qDebug("PwMDoc::syncronize : newly created local sync data could not be found");
3041 return e_syncError; 3041 return e_syncError;
3042 } 3042 }
3043 } 3043 }
3044 3044
3045 syncItemLocal = syncLocal->getSyncDataEntry(index); 3045 syncItemLocal = syncLocal->getSyncDataEntry(index);
3046 qDebug("Last Sync Local %s ", syncItemLocal->lastSyncDate.toString().latin1()); 3046 qDebug("Last Sync Local %s ", syncItemLocal->lastSyncDate.toString().latin1());
3047 3047
3048 //Step 2. Find syncinfo in remote file and create if not existent. 3048 //Step 2. Find syncinfo in remote file and create if not existent.
3049 found = syncRemote->findSyncData(mCurrentSyncName, &index); 3049 found = syncRemote->findSyncData(mCurrentSyncName, &index);
3050 if (found == false) 3050 if (found == false)
3051 { 3051 {
3052 qDebug("FULLDATE 1"); 3052 qDebug("FULLDATE 1");
3053 fullDateRange = true; 3053 fullDateRange = true;
3054 PwMSyncItem newSyncItemRemote; 3054 PwMSyncItem newSyncItemRemote;
3055 newSyncItemRemote.syncName = mCurrentSyncName.latin1(); 3055 newSyncItemRemote.syncName = mCurrentSyncName.latin1();
3056 newSyncItemRemote.lastSyncDate = mLastSync; 3056 newSyncItemRemote.lastSyncDate = mLastSync;
3057 syncRemote->addSyncDataEntry(&newSyncItemRemote, true); 3057 syncRemote->addSyncDataEntry(&newSyncItemRemote, true);
3058 found = syncRemote->findSyncData(mCurrentSyncName, &index); 3058 found = syncRemote->findSyncData(mCurrentSyncName, &index);
3059 if (found == false) { 3059 if (found == false) {
3060 qDebug("PwMDoc::syncronize : newly created remote sync data could not be found"); 3060 qDebug("PwMDoc::syncronize : newly created remote sync data could not be found");
3061 return e_syncError; 3061 return e_syncError;
3062 } 3062 }
3063 } 3063 }
3064 3064
3065 syncItemRemote = syncRemote->getSyncDataEntry(index); 3065 syncItemRemote = syncRemote->getSyncDataEntry(index);
3066 qDebug("Last Sync Remote %s ", syncItemRemote->lastSyncDate.toString().latin1()); 3066 qDebug("Last Sync Remote %s ", syncItemRemote->lastSyncDate.toString().latin1());
3067 //and remove the found entry here. We will reenter it later again. 3067 //and remove the found entry here. We will reenter it later again.
3068 //US syncRemote->delSyncDataEntry(index, true); 3068 //US syncRemote->delSyncDataEntry(index, true);
3069 3069
3070 3070
3071 if ( syncItemLocal->lastSyncDate == mLastSync ) { 3071 if ( syncItemLocal->lastSyncDate == mLastSync ) {
3072 qDebug("FULLDATE 2"); 3072 qDebug("FULLDATE 2");
3073 fullDateRange = true; 3073 fullDateRange = true;
3074 } 3074 }
3075 3075
3076 if ( ! fullDateRange ) { 3076 if ( ! fullDateRange ) {
3077 if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) { 3077 if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) {
3078 3078
3079 fullDateRange = true; 3079 fullDateRange = true;
3080 qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() ); 3080 qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() );
3081 } 3081 }
3082 } 3082 }
3083 // fullDateRange = true; // debug only! 3083 // fullDateRange = true; // debug only!
3084 if ( fullDateRange ) 3084 if ( fullDateRange )
3085 mLastSync = QDateTime::currentDateTime().addDays( -100*365); 3085 mLastSync = QDateTime::currentDateTime().addDays( -100*365);
3086 else 3086 else
3087 mLastSync = syncItemLocal->lastSyncDate; 3087 mLastSync = syncItemLocal->lastSyncDate;
3088 3088
3089 3089
3090 qDebug("*************************** "); 3090 qDebug("*************************** ");
3091 qDebug("mLastSync %s ",mLastSync.toString().latin1() ); 3091 qDebug("mLastSync %s ",mLastSync.toString().latin1() );
3092 QStringList er = syncRemote->getIDEntryList(); 3092 QStringList er = syncRemote->getIDEntryList();
3093 PwMDataItem* inRemote ;//= er.first(); 3093 PwMDataItem* inRemote ;//= er.first();
3094 PwMDataItem* inLocal; 3094 PwMDataItem* inLocal;
3095 unsigned int catLocal, indexLocal; 3095 unsigned int catLocal, indexLocal;
3096 unsigned int catRemote, indexRemote; 3096 unsigned int catRemote, indexRemote;
3097 3097
3098 QString uid; 3098 QString uid;
3099 manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 3099 manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
3100 3100
3101 int modulo = (er.count()/10)+1; 3101 int modulo = (er.count()/10)+1;
3102 unsigned int incCounter = 0; 3102 unsigned int incCounter = 0;
3103 while ( incCounter < er.count()) { 3103 while ( incCounter < er.count()) {
3104 if (manager->isProgressBarCanceled()) 3104 if (manager->isProgressBarCanceled())
3105 return e_syncError; 3105 return e_syncError;
3106 if ( incCounter % modulo == 0 ) 3106 if ( incCounter % modulo == 0 )
3107 manager->showProgressBar(incCounter); 3107 manager->showProgressBar(incCounter);
3108 3108
3109 uid = er[ incCounter ]; 3109 uid = er[ incCounter ];
3110 qDebug("sync uid %s from remote file", uid.latin1()); 3110 qDebug("sync uid %s from remote file", uid.latin1());
3111 3111
3112 qApp->processEvents(); 3112 qApp->processEvents();
3113 3113
3114 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); 3114 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal );
3115 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); 3115 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote );
3116 PWM_ASSERT(inRemote); 3116 PWM_ASSERT(inRemote);
3117 if ( inLocal != 0 ) { // maybe conflict - same uid in both files 3117 if ( inLocal != 0 ) { // maybe conflict - same uid in both files
3118 if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) { 3118 if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) {
3119 qDebug("take %d %s ", take, inLocal->desc.c_str()); 3119 qDebug("take %d %s ", take, inLocal->desc.c_str());
3120 if ( take == 3 ) 3120 if ( take == 3 )
3121 return e_syncError; 3121 return e_syncError;
3122 if ( take == 1 ) {// take local 3122 if ( take == 1 ) {// take local
3123 int oldlistpos = inRemote->listViewPos; 3123 int oldlistpos = inRemote->listViewPos;
3124 (*inRemote) = (*inLocal); 3124 (*inRemote) = (*inLocal);
3125 inRemote->listViewPos = oldlistpos; 3125 inRemote->listViewPos = oldlistpos;
3126 ++changedRemote; 3126 ++changedRemote;
3127 } else { // take == 2 take remote 3127 } else { // take == 2 take remote
3128 int oldlistpos = inLocal->listViewPos; 3128 int oldlistpos = inLocal->listViewPos;
3129 (*inLocal) = (*inRemote); 3129 (*inLocal) = (*inRemote);
3130 inLocal->listViewPos = oldlistpos; 3130 inLocal->listViewPos = oldlistpos;
3131 ++changedLocal; 3131 ++changedLocal;
3132 } 3132 }
3133 } 3133 }
3134 } else { // no conflict 3134 } else { // no conflict
3135 if ( inRemote->meta.update > mLastSync || mode == 5 ) { 3135 if ( inRemote->meta.update > mLastSync || mode == 5 ) {
3136 inRemote->meta.update = modifiedSync; 3136 inRemote->meta.update = modifiedSync;
3137 3137
3138 //first check if we have a matching category in the local file 3138 //first check if we have a matching category in the local file
3139 const string* remotecat = syncRemote->getCategory(catRemote); 3139 const string* remotecat = syncRemote->getCategory(catRemote);
3140 syncLocal->addEntry(remotecat->c_str(), inRemote, true, false); 3140 syncLocal->addEntry(remotecat->c_str(), inRemote, true, false);
3141 3141
3142 ++addedPasswordsLocal; 3142 ++addedPasswordsLocal;
3143 } else { 3143 } else {
3144 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3144 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3145 syncRemote->delEntry(catRemote, indexRemote, true); 3145 syncRemote->delEntry(catRemote, indexRemote, true);
3146 ++deletedPasswordsRemote; 3146 ++deletedPasswordsRemote;
3147 } 3147 }
3148 } 3148 }
3149 3149
3150 ++incCounter; 3150 ++incCounter;
3151 } 3151 }
3152 3152
3153 3153
3154 er.clear(); 3154 er.clear();
3155 QStringList el = syncLocal->getIDEntryList(); 3155 QStringList el = syncLocal->getIDEntryList();
3156 modulo = (el.count()/10)+1; 3156 modulo = (el.count()/10)+1;
3157 3157
3158 manager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3158 manager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3159 incCounter = 0; 3159 incCounter = 0;
3160 while ( incCounter < el.count()) { 3160 while ( incCounter < el.count()) {
3161 qApp->processEvents(); 3161 qApp->processEvents();
3162 if (manager->isProgressBarCanceled()) 3162 if (manager->isProgressBarCanceled())
3163 return e_syncError; 3163 return e_syncError;
3164 if ( incCounter % modulo == 0 ) 3164 if ( incCounter % modulo == 0 )
3165 manager->showProgressBar(incCounter); 3165 manager->showProgressBar(incCounter);
3166 uid = el[ incCounter ]; 3166 uid = el[ incCounter ];
3167 qDebug("sync uid %s from local file", uid.latin1()); 3167 qDebug("sync uid %s from local file", uid.latin1());
3168 3168
3169 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); 3169 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal );
3170 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); 3170 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote );
3171 PWM_ASSERT(inLocal); 3171 PWM_ASSERT(inLocal);
3172 3172
3173 if ( inRemote == 0 ) { 3173 if ( inRemote == 0 ) {
3174 if ( inLocal->meta.update < mLastSync && mode != 4 ) { 3174 if ( inLocal->meta.update < mLastSync && mode != 4 ) {
3175 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3175 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3176 syncLocal->delEntry(catLocal, indexLocal, true); 3176 syncLocal->delEntry(catLocal, indexLocal, true);
3177 ++deletedPasswordsLocal; 3177 ++deletedPasswordsLocal;
3178 } else { 3178 } else {
3179 if ( ! manager->mWriteBackExistingOnly ) { 3179 if ( ! manager->mWriteBackExistingOnly ) {
3180 ++addedPasswordsRemote; 3180 ++addedPasswordsRemote;
3181 inLocal->meta.update = modifiedSync; 3181 inLocal->meta.update = modifiedSync;
3182 3182
3183 //first check if we have a matching category in the remote file 3183 //first check if we have a matching category in the remote file
3184 const string* localcat = syncLocal->getCategory(catLocal); 3184 const string* localcat = syncLocal->getCategory(catLocal);
3185 3185
3186 PwMDataItem newEntry; 3186 PwMDataItem newEntry;
3187 newEntry = *inLocal; 3187 newEntry = *inLocal;
3188 inRemote = &newEntry; 3188 inRemote = &newEntry;
3189 3189
3190 //USsyncRemote->insertAddressee( inRemote, false ); 3190 //USsyncRemote->insertAddressee( inRemote, false );
3191 syncRemote->addEntry(localcat->c_str(), inRemote, true, false); 3191 syncRemote->addEntry(localcat->c_str(), inRemote, true, false);
3192 3192
3193 } 3193 }
3194 } 3194 }
3195 3195
3196 } 3196 }
3197 ++incCounter; 3197 ++incCounter;
3198 } 3198 }
3199 el.clear(); 3199 el.clear();
3200 manager->hideProgressBar(); 3200 manager->hideProgressBar();
3201 3201
3202 // Now write the info back into the sync data space of the files 3202 // Now write the info back into the sync data space of the files
3203 3203
3204 mLastSync = QDateTime::currentDateTime().addSecs( 1 ); 3204 mLastSync = QDateTime::currentDateTime().addSecs( 1 );
3205 // get rid of micro seconds 3205 // get rid of micro seconds
3206 QTime t = mLastSync.time(); 3206 QTime t = mLastSync.time();
3207 mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3207 mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3208 3208
3209 3209
3210 syncItemLocal->lastSyncDate = mLastSync; 3210 syncItemLocal->lastSyncDate = mLastSync;
3211 syncItemRemote->lastSyncDate = mLastSync; 3211 syncItemRemote->lastSyncDate = mLastSync;
3212 3212
3213 QString mes; 3213 QString mes;
3214 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"),addedPasswordsLocal, addedPasswordsRemote, changedLocal, changedRemote, deletedPasswordsLocal, deletedPasswordsRemote ); 3214 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"),addedPasswordsLocal, addedPasswordsRemote, changedLocal, changedRemote, deletedPasswordsLocal, deletedPasswordsRemote );
3215 if ( manager->mShowSyncSummary ) { 3215 if ( manager->mShowSyncSummary ) {
3216 KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") ); 3216 KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") );
3217 } 3217 }
3218 qDebug( mes ); 3218 qDebug( mes );
3219 return e_success; 3219 return e_success;
3220} 3220}
3221 3221
3222 3222
3223int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ) 3223int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full )
3224{ 3224{
3225 // 0 equal 3225 // 0 equal
3226 // 1 take local 3226 // 1 take local
3227 // 2 take remote 3227 // 2 take remote
3228 // 3 cancel 3228 // 3 cancel
3229 QDateTime localMod = local->meta.update; 3229 QDateTime localMod = local->meta.update;
3230 QDateTime remoteMod = remote->meta.update; 3230 QDateTime remoteMod = remote->meta.update;
3231 3231
3232 if ( localMod == remoteMod ) 3232 if ( localMod == remoteMod )
3233 return 0; 3233 return 0;
3234 3234
3235 qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() ); 3235 qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() );
3236 3236
3237 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 3237 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
3238 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 3238 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
3239 //full = true; //debug only 3239 //full = true; //debug only
3240 if ( full ) { 3240 if ( full ) {
3241 bool equ = ( (*local) == (*remote) ); 3241 bool equ = ( (*local) == (*remote) );
3242 if ( equ ) { 3242 if ( equ ) {
3243 //qDebug("equal "); 3243 //qDebug("equal ");
3244 if ( mode < SYNC_PREF_FORCE_LOCAL ) 3244 if ( mode < SYNC_PREF_FORCE_LOCAL )
3245 return 0; 3245 return 0;
3246 3246
3247 }//else //debug only 3247 }//else //debug only
3248 //qDebug("not equal %s %s ", local->desc.c_str(), remote->desc.c_str()); 3248 //qDebug("not equal %s %s ", local->desc.c_str(), remote->desc.c_str());
3249 } 3249 }
3250 3250
3251 int result; 3251 int result;
3252 bool localIsNew; 3252 bool localIsNew;
3253 //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() ); 3253 //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() );
3254 3254
3255 if ( full && mode < SYNC_PREF_NEWEST ) 3255 if ( full && mode < SYNC_PREF_NEWEST )
3256 mode = SYNC_PREF_ASK; 3256 mode = SYNC_PREF_ASK;
3257 3257
3258 switch( mode ) { 3258 switch( mode ) {
3259 case SYNC_PREF_LOCAL: 3259 case SYNC_PREF_LOCAL:
3260 if ( lastSync > remoteMod ) 3260 if ( lastSync > remoteMod )
3261 return 1; 3261 return 1;
3262 if ( lastSync > localMod ) 3262 if ( lastSync > localMod )
3263 return 2; 3263 return 2;
3264 return 1; 3264 return 1;
3265 break; 3265 break;
3266 case SYNC_PREF_REMOTE: 3266 case SYNC_PREF_REMOTE:
3267 if ( lastSync > remoteMod ) 3267 if ( lastSync > remoteMod )
3268 return 1; 3268 return 1;
3269 if ( lastSync > localMod ) 3269 if ( lastSync > localMod )
3270 return 2; 3270 return 2;
3271 return 2; 3271 return 2;
3272 break; 3272 break;
3273 case SYNC_PREF_NEWEST: 3273 case SYNC_PREF_NEWEST:
3274 if ( localMod > remoteMod ) 3274 if ( localMod > remoteMod )
3275 return 1; 3275 return 1;
3276 else 3276 else
3277 return 2; 3277 return 2;
3278 break; 3278 break;
3279 case SYNC_PREF_ASK: 3279 case SYNC_PREF_ASK:
3280 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 3280 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
3281 if ( lastSync > remoteMod ) 3281 if ( lastSync > remoteMod )
3282 return 1; 3282 return 1;
3283 if ( lastSync > localMod ) 3283 if ( lastSync > localMod )
3284 return 2; 3284 return 2;
3285 localIsNew = localMod >= remoteMod; 3285 localIsNew = localMod >= remoteMod;
3286 //qDebug("conflict! ************************************** "); 3286 //qDebug("conflict! ************************************** ");
3287 { 3287 {
3288 PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ ); 3288 PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ );
3289 result = acd.executeD(localIsNew); 3289 result = acd.executeD(localIsNew);
3290 return result; 3290 return result;
3291 } 3291 }
3292 break; 3292 break;
3293 case SYNC_PREF_FORCE_LOCAL: 3293 case SYNC_PREF_FORCE_LOCAL:
3294 return 1; 3294 return 1;
3295 break; 3295 break;
3296 case SYNC_PREF_FORCE_REMOTE: 3296 case SYNC_PREF_FORCE_REMOTE:
3297 return 2; 3297 return 2;
3298 break; 3298 break;
3299 3299
3300 default: 3300 default:
3301 // SYNC_PREF_TAKE_BOTH not implemented 3301 // SYNC_PREF_TAKE_BOTH not implemented
3302 break; 3302 break;
3303 } 3303 }
3304 return 0; 3304 return 0;
3305} 3305}
3306 3306
3307 3307void PwMDoc::removeSyncInfo( QString syncProfile)
3308{
3309 qDebug("PwMDoc::not implemented: removeSyncInfo for profile %s ", syncProfile.latin1());
3310}
3308 3311
3309 3312
3310//this are the overwritten callbackmethods from the syncinterface 3313//this are the overwritten callbackmethods from the syncinterface
3311bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode) 3314bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode)
3312{ 3315{
3313 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3316 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3314 3317
3315 //1) unlock local file first if necessary (ask for password) 3318 //1) unlock local file first if necessary (ask for password)
3316 if (this->isDeepLocked()) { 3319 if (this->isDeepLocked()) {
3317 PwMerror ret = this->deepLock(false); 3320 PwMerror ret = this->deepLock(false);
3318 if (ret != e_success) 3321 if (ret != e_success)
3319 return false; 3322 return false;
3320 } 3323 }
3321 3324
3322 //2) construct and open a new doc on the stack(automatic cleanup of remote file). 3325 //2) construct and open a new doc on the stack(automatic cleanup of remote file).
3323 PwMDoc syncTarget(this, "synctarget"); 3326 PwMDoc syncTarget(this, "synctarget");
3324 PwMDoc* pSyncTarget = &syncTarget; 3327 PwMDoc* pSyncTarget = &syncTarget;
3325 3328
3326 3329
3327 PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/); 3330 PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/);
3328 3331
3329 if (err == e_alreadyOpen) { 3332 if (err == e_alreadyOpen) {
3330 PwMDocList::listItem li; 3333 PwMDocList::listItem li;
3331 if (getOpenDocList()->find(filename.latin1(), &li)) 3334 if (getOpenDocList()->find(filename.latin1(), &li))
3332 pSyncTarget = li.doc; 3335 pSyncTarget = li.doc;
3333 else { 3336 else {
3334 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); 3337 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1());
3335 return false; 3338 return false;
3336 } 3339 }
3337 } 3340 }
3338 else if (err != e_success) { 3341 else if (err != e_success) {
3339 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); 3342 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1());
3340 return false; 3343 return false;
3341 } 3344 }
3342 3345
3343 qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode ); 3346 qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode );
3344 3347
3345 3348
3346 //3) unlock remote file first if necessary (ask for password) 3349 //3) unlock remote file first if necessary (ask for password)
3347 if (pSyncTarget->isDeepLocked()) { 3350 if (pSyncTarget->isDeepLocked()) {
3348 PwMerror ret = pSyncTarget->deepLock(false); 3351 PwMerror ret = pSyncTarget->deepLock(false);
3349 if (ret != e_success) 3352 if (ret != e_success)
3350 return false; 3353 return false;
3351 } 3354 }
3352 3355
3353 3356
3354 err = syncronize(manager, this, pSyncTarget, mode ); 3357 err = syncronize(manager, this, pSyncTarget, mode );
3355 3358
3356 if (err == e_success) { 3359 if (err == e_success) {
3357 if ( manager->mWriteBackFile ){ 3360 if ( manager->mWriteBackFile ){
3358 qDebug("Saving remote PWManager file"); 3361 qDebug("Saving remote PWManager file");
3359 err = pSyncTarget->saveDoc(conf()->confGlobCompression()); 3362 err = pSyncTarget->saveDoc(conf()->confGlobCompression());
3360 if (err != e_success) { 3363 if (err != e_success) {
3361 qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1()); 3364 qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1());
3362 return false; 3365 return false;
3363 } 3366 }
3364 } 3367 }
3365 3368
3366 flagDirty(); 3369 flagDirty();
3367 return true; 3370 return true;
3368 } 3371 }
3369 else { 3372 else {
3370 return false; 3373 return false;
3371 } 3374 }
3372} 3375}
3373 3376
3374#endif 3377#endif
3375 3378
3376 3379
3377bool PwMDoc::findSyncData(const QString &syncname, unsigned int *index) 3380bool PwMDoc::findSyncData(const QString &syncname, unsigned int *index)
3378{ 3381{
3379 vector<PwMSyncItem>::iterator i = dti.syncDta.begin(), 3382 vector<PwMSyncItem>::iterator i = dti.syncDta.begin(),
3380 end = dti.syncDta.end(); 3383 end = dti.syncDta.end();
3381 3384
3382 while (i != end) { 3385 while (i != end) {
3383 if ((*i).syncName == syncname.latin1()) { 3386 if ((*i).syncName == syncname.latin1()) {
3384 if (index) { 3387 if (index) {
3385 *index = i - dti.syncDta.begin(); 3388 *index = i - dti.syncDta.begin();
3386 } 3389 }
3387 return true; 3390 return true;
3388 } 3391 }
3389 ++i; 3392 ++i;
3390 } 3393 }
3391 return false; 3394 return false;
3392}; 3395};
3393 3396
3394/** add new syncdataentry */ 3397/** add new syncdataentry */
3395PwMerror PwMDoc::addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty) 3398PwMerror PwMDoc::addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty)
3396{ 3399{
3397 PWM_ASSERT(d); 3400 PWM_ASSERT(d);
3398 3401
3399 if (isDeepLocked()) { 3402 if (isDeepLocked()) {
3400 PwMerror ret; 3403 PwMerror ret;
3401 ret = deepLock(false); 3404 ret = deepLock(false);
3402 if (ret != e_success) 3405 if (ret != e_success)
3403 return e_lock; 3406 return e_lock;
3404 } 3407 }
3405 unsigned int index; 3408 unsigned int index;
3406 3409
3407 const QString tmp = d->syncName.c_str(); 3410 const QString tmp = d->syncName.c_str();
3408 bool exists = findSyncData(d->syncName.c_str(), &index); 3411 bool exists = findSyncData(d->syncName.c_str(), &index);
3409 3412
3410 if (exists == true) { 3413 if (exists == true) {
3411 // DOH! We found this entry. 3414 // DOH! We found this entry.
3412 return e_entryExists; 3415 return e_entryExists;
3413 } 3416 }
3414 3417
3415 dti.syncDta.push_back(*d); 3418 dti.syncDta.push_back(*d);
3416 3419
3417 if (!dontFlagDirty) 3420 if (!dontFlagDirty)
3418 flagDirty(); 3421 flagDirty();
3419 return e_success; 3422 return e_success;
3420} 3423}
3421 3424
3422 3425
3423 3426
3424/** delete syncdata entry */ 3427/** delete syncdata entry */
3425bool PwMDoc::delSyncDataEntry(unsigned int index, bool dontFlagDirty) 3428bool PwMDoc::delSyncDataEntry(unsigned int index, bool dontFlagDirty)
3426{ 3429{
3427 if (isDeepLocked()) 3430 if (isDeepLocked())
3428 return false; 3431 return false;
3429 if (index > dti.syncDta.size() - 1) 3432 if (index > dti.syncDta.size() - 1)
3430 return false; 3433 return false;
3431 3434
3432 // delete entry 3435 // delete entry
3433 dti.syncDta.erase(dti.syncDta.begin() + index); 3436 dti.syncDta.erase(dti.syncDta.begin() + index);
3434 3437
3435 if (!dontFlagDirty) 3438 if (!dontFlagDirty)
3436 flagDirty(); 3439 flagDirty();
3437 return true; 3440 return true;
3438} 3441}
3439 3442
3440 3443
3441PwMDataItem* PwMDoc::findEntryByID(const QString &uid, unsigned int *category, unsigned int *index) 3444PwMDataItem* PwMDoc::findEntryByID(const QString &uid, unsigned int *category, unsigned int *index)
3442{ 3445{
3443 vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(), 3446 vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(),
3444 catend = dti.dta.end(); 3447 catend = dti.dta.end();
3445 3448
3446 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; 3449 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI;
3447 3450
3448 while (catcounter != catend) { 3451 while (catcounter != catend) {
3449 entrBegin = catcounter->d.begin(); 3452 entrBegin = catcounter->d.begin();
3450 entrEnd = catcounter->d.end(); 3453 entrEnd = catcounter->d.end();
3451 entrI = entrBegin; 3454 entrI = entrBegin;
3452 while (entrI != entrEnd) { 3455 while (entrI != entrEnd) {
3453 if ((*entrI).meta.uniqueid == uid.latin1()) { 3456 if ((*entrI).meta.uniqueid == uid.latin1()) {
3454 if (category) 3457 if (category)
3455 *category = catcounter - dti.dta.begin(); 3458 *category = catcounter - dti.dta.begin();
3456 if (index) 3459 if (index)
3457 *index = entrI - entrBegin; 3460 *index = entrI - entrBegin;
3458 3461
3459 return &(*entrI); 3462 return &(*entrI);
3460 } 3463 }
3461 ++entrI; 3464 ++entrI;
3462 } 3465 }
3463 ++catcounter; 3466 ++catcounter;
3464 } 3467 }
3465 3468
3466 return 0; 3469 return 0;
3467} 3470}
3468 3471
3469QStringList PwMDoc::getIDEntryList() 3472QStringList PwMDoc::getIDEntryList()
3470{ 3473{
3471 QStringList results; 3474 QStringList results;
3472 3475
3473 vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(), 3476 vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(),
3474 catend = dti.dta.end(); 3477 catend = dti.dta.end();
3475 3478
3476 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; 3479 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI;
3477 3480
3478 while (catcounter != catend) { 3481 while (catcounter != catend) {
3479 entrBegin = catcounter->d.begin(); 3482 entrBegin = catcounter->d.begin();
3480 entrEnd = catcounter->d.end(); 3483 entrEnd = catcounter->d.end();
3481 entrI = entrBegin; 3484 entrI = entrBegin;
3482 while (entrI != entrEnd) { 3485 while (entrI != entrEnd) {
3483 results.append( (*entrI).meta.uniqueid.c_str() ); 3486 results.append( (*entrI).meta.uniqueid.c_str() );
3484 ++entrI; 3487 ++entrI;
3485 } 3488 }
3486 ++catcounter; 3489 ++catcounter;
3487 } 3490 }
3488 3491
3489 return results; 3492 return results;
3490} 3493}
3491 3494
3492 3495
3493 3496
3494 3497
3495 3498
3496#ifndef PWM_EMBEDDED 3499#ifndef PWM_EMBEDDED
3497#include "pwmdoc.moc" 3500#include "pwmdoc.moc"
3498#endif 3501#endif
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h
index 55e3231..e419c24 100644
--- a/pwmanager/pwmanager/pwmdoc.h
+++ b/pwmanager/pwmanager/pwmdoc.h
@@ -381,408 +381,409 @@ protected:
381/** Document class for PwM */ 381/** Document class for PwM */
382//US ENH: derived from KSyncInterfaces, to get called by PwM when a sync is required. 382//US ENH: derived from KSyncInterfaces, to get called by PwM when a sync is required.
383// But PwMDoc is handling the sync by itself. 383// But PwMDoc is handling the sync by itself.
384class PwMDoc : public PwMDocUi, public KSyncInterface 384class PwMDoc : public PwMDocUi, public KSyncInterface
385 385
386{ 386{
387 Q_OBJECT 387 Q_OBJECT
388 friend class DocTimer; 388 friend class DocTimer;
389 389
390public: 390public:
391 /** construtor */ 391 /** construtor */
392 PwMDoc(QObject* parent = 0, const char *name = 0); 392 PwMDoc(QObject* parent = 0, const char *name = 0);
393 /** destructor */ 393 /** destructor */
394 ~PwMDoc(); 394 ~PwMDoc();
395 395
396 /** returns a pointer to a list of all open documents */ 396 /** returns a pointer to a list of all open documents */
397 static PwMDocList* getOpenDocList() 397 static PwMDocList* getOpenDocList()
398 { return &openDocList; } 398 { return &openDocList; }
399 399
400 /** flag document dirty. dta changed */ 400 /** flag document dirty. dta changed */
401 void flagDirty() 401 void flagDirty()
402 { 402 {
403 setDocStatFlag(DOC_STAT_DISK_DIRTY); 403 setDocStatFlag(DOC_STAT_DISK_DIRTY);
404 emitDataChanged(this); 404 emitDataChanged(this);
405 } 405 }
406 /** modified? */ 406 /** modified? */
407 bool isDirty() 407 bool isDirty()
408 { return getDocStatFlag(DOC_STAT_DISK_DIRTY); } 408 { return getDocStatFlag(DOC_STAT_DISK_DIRTY); }
409 /** save document to disk */ 409 /** save document to disk */
410 PwMerror saveDoc(char compress, const QString *file = 0); 410 PwMerror saveDoc(char compress, const QString *file = 0);
411 /** read document from file. 411 /** read document from file.
412 * "openLocked is must be set to either of these values: 412 * "openLocked is must be set to either of these values:
413 * 0 == open with all entries unlocked 413 * 0 == open with all entries unlocked
414 * 1 == open with all entries locked 414 * 1 == open with all entries locked
415 * 2 == open deep-locked 415 * 2 == open deep-locked
416 */ 416 */
417 PwMerror openDoc(const QString *file, int openLocked); 417 PwMerror openDoc(const QString *file, int openLocked);
418 /** export document to ascii-textfile */ 418 /** export document to ascii-textfile */
419 PwMerror exportToText(const QString *file); 419 PwMerror exportToText(const QString *file);
420 /** export document to gpasman / kpasman file */ 420 /** export document to gpasman / kpasman file */
421 PwMerror exportToGpasman(const QString *file); 421 PwMerror exportToGpasman(const QString *file);
422 /** import document from ascii-textfile */ 422 /** import document from ascii-textfile */
423 PwMerror importFromText(const QString *file, int format = -1); 423 PwMerror importFromText(const QString *file, int format = -1);
424 /** import document from gpasman / kpasman file */ 424 /** import document from gpasman / kpasman file */
425 PwMerror importFromGpasman(const QString *file); 425 PwMerror importFromGpasman(const QString *file);
426 /** add new entry */ 426 /** add new entry */
427 PwMerror addEntry(const QString &category, PwMDataItem *d, 427 PwMerror addEntry(const QString &category, PwMDataItem *d,
428 bool dontFlagDirty = false, bool updateMeta = true); 428 bool dontFlagDirty = false, bool updateMeta = true);
429 /** add new category. This function doesn't flag the document dirty! */ 429 /** add new category. This function doesn't flag the document dirty! */
430 PwMerror addCategory(const QString &category, unsigned int *categoryIndex, 430 PwMerror addCategory(const QString &category, unsigned int *categoryIndex,
431 bool checkIfExist = true); 431 bool checkIfExist = true);
432 /** rename an existing category */ 432 /** rename an existing category */
433 bool renameCategory(const QString &category, const QString &newName); 433 bool renameCategory(const QString &category, const QString &newName);
434 /** rename an existing category */ 434 /** rename an existing category */
435 bool renameCategory(unsigned int category, const QString &newName, 435 bool renameCategory(unsigned int category, const QString &newName,
436 bool dontFlagDirty = false); 436 bool dontFlagDirty = false);
437 /** delete an existing category */ 437 /** delete an existing category */
438 bool delCategory(const QString &category); 438 bool delCategory(const QString &category);
439 /** delete an existing category */ 439 /** delete an existing category */
440 bool delCategory(unsigned int category, bool dontFlagDirty = false); 440 bool delCategory(unsigned int category, bool dontFlagDirty = false);
441 /** returns a list of all category-names */ 441 /** returns a list of all category-names */
442 void getCategoryList(vector<string> *list); 442 void getCategoryList(vector<string> *list);
443 /** returns a list of all category-names */ 443 /** returns a list of all category-names */
444 void getCategoryList(QStringList *list); 444 void getCategoryList(QStringList *list);
445 /** returns a list of all entry-descs in the given category */ 445 /** returns a list of all entry-descs in the given category */
446 void getEntryList(const QString &category, QStringList *list); 446 void getEntryList(const QString &category, QStringList *list);
447 /** returns a list of all entry-descs in the given category */ 447 /** returns a list of all entry-descs in the given category */
448 void getEntryList(const QString &category, vector<string> *list); 448 void getEntryList(const QString &category, vector<string> *list);
449 /** returns a list of all entry-descs in the given category */ 449 /** returns a list of all entry-descs in the given category */
450 void getEntryList(unsigned int category, vector<string> *list); 450 void getEntryList(unsigned int category, vector<string> *list);
451 /** returns a list of all entry-descs in the given category */ 451 /** returns a list of all entry-descs in the given category */
452 void getEntryList(unsigned int category, QStringList *list); 452 void getEntryList(unsigned int category, QStringList *list);
453 /** delete entry */ 453 /** delete entry */
454 bool delEntry(const QString &category, unsigned int index, bool dontFlagDirty = false); 454 bool delEntry(const QString &category, unsigned int index, bool dontFlagDirty = false);
455 /** delete entry */ 455 /** delete entry */
456 bool delEntry(unsigned int category, unsigned int index, bool dontFlagDirty = false); 456 bool delEntry(unsigned int category, unsigned int index, bool dontFlagDirty = false);
457 /** edit entry */ 457 /** edit entry */
458 bool editEntry(const QString &oldCategory, const QString &newCategory, 458 bool editEntry(const QString &oldCategory, const QString &newCategory,
459 unsigned int index, PwMDataItem *d, bool updateMeta = true); 459 unsigned int index, PwMDataItem *d, bool updateMeta = true);
460 /** edit entry */ 460 /** edit entry */
461 bool editEntry(unsigned int oldCategory, const QString &newCategory, 461 bool editEntry(unsigned int oldCategory, const QString &newCategory,
462 unsigned int index, PwMDataItem *d, bool updateMeta = true); 462 unsigned int index, PwMDataItem *d, bool updateMeta = true);
463 /** finds the category with the "name" and return it's index */ 463 /** finds the category with the "name" and return it's index */
464 bool findCategory(const QString &name, unsigned int *index); 464 bool findCategory(const QString &name, unsigned int *index);
465 /** search for an entry "find" and check while searching only for 465 /** search for an entry "find" and check while searching only for
466 * the data-fields specified by "searchIn". To set the "searchIn" 466 * the data-fields specified by "searchIn". To set the "searchIn"
467 * value, we may use one or more of the SEARCH_IN_* defines at 467 * value, we may use one or more of the SEARCH_IN_* defines at
468 * the top of this header-file. It returns the positions of all 468 * the top of this header-file. It returns the positions of all
469 * matched entries in "foundPositions". If "breakAfterFound" is true, 469 * matched entries in "foundPositions". If "breakAfterFound" is true,
470 * the function terminates after the first occurence of the entry 470 * the function terminates after the first occurence of the entry
471 * and doesn't go on searching. So foundPositions->size() is never 471 * and doesn't go on searching. So foundPositions->size() is never
472 * > 1 if breakAfterFound is true. 472 * > 1 if breakAfterFound is true.
473 */ 473 */
474 void findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, 474 void findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn,
475 vector<unsigned int> *foundPositions, bool breakAfterFound = false, 475 vector<unsigned int> *foundPositions, bool breakAfterFound = false,
476 bool caseSensitive = true, bool exactWordMatch = true, 476 bool caseSensitive = true, bool exactWordMatch = true,
477 bool sortByLvp = false); 477 bool sortByLvp = false);
478 /** see the above funtion. This function allows to set the category by name. */ 478 /** see the above funtion. This function allows to set the category by name. */
479 void findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, 479 void findEntry(const QString &category, PwMDataItem find, unsigned int searchIn,
480 vector<unsigned int> *foundPositions, bool breakAfterFound = false, 480 vector<unsigned int> *foundPositions, bool breakAfterFound = false,
481 bool caseSensitive = true, bool exactWordMatch = true, 481 bool caseSensitive = true, bool exactWordMatch = true,
482 bool sortByLvp = false); 482 bool sortByLvp = false);
483 /** returns number of entries */ 483 /** returns number of entries */
484 unsigned int numEntries(const QString &category); 484 unsigned int numEntries(const QString &category);
485 unsigned int numEntries(unsigned int category) 485 unsigned int numEntries(unsigned int category)
486 { return dti.dta[category].d.size(); } 486 { return dti.dta[category].d.size(); }
487 /** returns number of categories */ 487 /** returns number of categories */
488 unsigned int numCategories() 488 unsigned int numCategories()
489 { return dti.dta.size(); } 489 { return dti.dta.size(); }
490 /** returns the name of the category at "index" */ 490 /** returns the name of the category at "index" */
491 const string* getCategory(unsigned int index) 491 const string* getCategory(unsigned int index)
492 { return (&(dti.dta[index].name)); } 492 { return (&(dti.dta[index].name)); }
493 493
494 /** returns the data of item at "index". 494 /** returns the data of item at "index".
495 * It unlocks the entry if it's locked and unlockIfLocked is true. 495 * It unlocks the entry if it's locked and unlockIfLocked is true.
496 * If the entry is locked, but unlockIfLocked is false, it'll not return 496 * If the entry is locked, but unlockIfLocked is false, it'll not return
497 * the pw. 497 * the pw.
498 */ 498 */
499 bool getEntry(const QString &category, unsigned int index, 499 bool getEntry(const QString &category, unsigned int index,
500 PwMDataItem *d, bool unlockIfLocked = false); 500 PwMDataItem *d, bool unlockIfLocked = false);
501 bool getEntry(unsigned int category, unsigned int index, 501 bool getEntry(unsigned int category, unsigned int index,
502 PwMDataItem *d, bool unlockIfLocked = false); 502 PwMDataItem *d, bool unlockIfLocked = false);
503 /** returns the comment-string by looking at the category 503 /** returns the comment-string by looking at the category
504 * and the listViewPos 504 * and the listViewPos
505 */ 505 */
506 PwMerror getCommentByLvp(const QString &category, int listViewPos, 506 PwMerror getCommentByLvp(const QString &category, int listViewPos,
507 string *foundComment); 507 string *foundComment);
508 /** checks if a password is already available. (currentPw) */ 508 /** checks if a password is already available. (currentPw) */
509 bool isPwAvailable() 509 bool isPwAvailable()
510 { return (currentPw != ""); } 510 { return (currentPw != ""); }
511 /** un/lock entry at "index". If needed, ask for password. */ 511 /** un/lock entry at "index". If needed, ask for password. */
512 bool lockAt(const QString &category, unsigned int index, 512 bool lockAt(const QString &category, unsigned int index,
513 bool lock = true); 513 bool lock = true);
514 bool lockAt(unsigned int category, unsigned int index, 514 bool lockAt(unsigned int category, unsigned int index,
515 bool lock = true); 515 bool lock = true);
516 /** returns the lock-status at "index" */ 516 /** returns the lock-status at "index" */
517 bool isLocked(const QString &category, unsigned int index); 517 bool isLocked(const QString &category, unsigned int index);
518 bool isLocked(unsigned int category, unsigned int index) 518 bool isLocked(unsigned int category, unsigned int index)
519 { return dti.dta[category].d[index].lockStat; } 519 { return dti.dta[category].d[index].lockStat; }
520 /** returns the deeplock status */ 520 /** returns the deeplock status */
521 bool isDeepLocked() 521 bool isDeepLocked()
522 { return getDocStatFlag(DOC_STAT_DEEPLOCKED); } 522 { return getDocStatFlag(DOC_STAT_DEEPLOCKED); }
523 /** (un)lock all entries */ 523 /** (un)lock all entries */
524 bool lockAll(bool lock); 524 bool lockAll(bool lock);
525 /** unlocks all entries tempoarly. 525 /** unlocks all entries tempoarly.
526 * 1st NOTE: Be very careful with this function! :) 526 * 1st NOTE: Be very careful with this function! :)
527 * 2nd NOTE: After you have called unlockAll_Tempoary(); , 527 * 2nd NOTE: After you have called unlockAll_Tempoary(); ,
528 * please DON'T forget to call unlockAll_Tempoary(true); 528 * please DON'T forget to call unlockAll_Tempoary(true);
529 * _before_ the user (or someone else) is able to change 529 * _before_ the user (or someone else) is able to change
530 * the document! 530 * the document!
531 * 3rd NOTE: Please DON'T change "dta" while the data is tempoary 531 * 3rd NOTE: Please DON'T change "dta" while the data is tempoary
532 * unlocked! This will cause corruption. 532 * unlocked! This will cause corruption.
533 */ 533 */
534 bool unlockAll_tempoary(bool revert = false); 534 bool unlockAll_tempoary(bool revert = false);
535 /** deep-(un)locks the document. 535 /** deep-(un)locks the document.
536 * deep-locking writes all data to the file, deletes all data 536 * deep-locking writes all data to the file, deletes all data
537 * in memory, but doesn't close the document. 537 * in memory, but doesn't close the document.
538 * deep-locking is only available, if the user previously saved 538 * deep-locking is only available, if the user previously saved
539 * the doc to a file (with a password). 539 * the doc to a file (with a password).
540 * If "saveToFile" is false, it does NOT write the data to the file! 540 * If "saveToFile" is false, it does NOT write the data to the file!
541 */ 541 */
542 PwMerror deepLock(bool lock = true, bool saveToFile = true); 542 PwMerror deepLock(bool lock = true, bool saveToFile = true);
543 /** is unlockable without pw? */ 543 /** is unlockable without pw? */
544 bool unlockWoPw() 544 bool unlockWoPw()
545 { return getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); } 545 { return getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); }
546 /** get the "currentPassword" */ 546 /** get the "currentPassword" */
547 const QString& getCurrentPw() 547 const QString& getCurrentPw()
548 { return currentPw; } 548 { return currentPw; }
549 /** open a window and request the user to change the mpw */ 549 /** open a window and request the user to change the mpw */
550 void changeCurrentPw(); 550 void changeCurrentPw();
551 /** set the "listViewPos" variable of "dta" */ 551 /** set the "listViewPos" variable of "dta" */
552 void setListViewPos(const QString &category, unsigned int index, 552 void setListViewPos(const QString &category, unsigned int index,
553 int pos); 553 int pos);
554 /** set the "listViewPos" variable of "dta" */ 554 /** set the "listViewPos" variable of "dta" */
555 void setListViewPos(unsigned int category, unsigned int index, 555 void setListViewPos(unsigned int category, unsigned int index,
556 int pos); 556 int pos);
557 /** get the "listViewPos" variable of "dta" */ 557 /** get the "listViewPos" variable of "dta" */
558 int getListViewPos(const QString &category, unsigned int index); 558 int getListViewPos(const QString &category, unsigned int index);
559 /** set the maximum number of entries allowed */ 559 /** set the maximum number of entries allowed */
560 void setMaxNumEntries(unsigned int num = DEFAULT_MAX_ENTRIES) 560 void setMaxNumEntries(unsigned int num = DEFAULT_MAX_ENTRIES)
561 { maxEntries = num; } 561 { maxEntries = num; }
562 /** get the maximum number of entries allowed */ 562 /** get the maximum number of entries allowed */
563 unsigned int getMaxNumEntries() 563 unsigned int getMaxNumEntries()
564 { return maxEntries; } 564 { return maxEntries; }
565 /** ensure all listViewPos of all dta items are set. (are ! -1). 565 /** ensure all listViewPos of all dta items are set. (are ! -1).
566 * If there are some undefined entries, add them to the end of 566 * If there are some undefined entries, add them to the end of
567 * the listViewPos(itions). */ 567 * the listViewPos(itions). */
568 void ensureLvp(); 568 void ensureLvp();
569 /** execute the "launcher" of this entry */ 569 /** execute the "launcher" of this entry */
570 bool execLauncher(const QString &category, unsigned int entryIndex); 570 bool execLauncher(const QString &category, unsigned int entryIndex);
571 /** see above */ 571 /** see above */
572 bool execLauncher(unsigned int category, unsigned int entryIndex); 572 bool execLauncher(unsigned int category, unsigned int entryIndex);
573 /** open a browser with the URL-section of the given entry */ 573 /** open a browser with the URL-section of the given entry */
574 bool goToURL(const QString &category, unsigned int entryIndex); 574 bool goToURL(const QString &category, unsigned int entryIndex);
575 /** see above */ 575 /** see above */
576 bool goToURL(unsigned int category, unsigned int entryIndex); 576 bool goToURL(unsigned int category, unsigned int entryIndex);
577 /** returns true if there is no entry present in the document. 577 /** returns true if there is no entry present in the document.
578 * Note: The "default" Category is present everytime, so 578 * Note: The "default" Category is present everytime, so
579 * it's checked for it's entries. 579 * it's checked for it's entries.
580 */ 580 */
581 bool isDocEmpty() 581 bool isDocEmpty()
582 { 582 {
583 if (numCategories() > 1) 583 if (numCategories() > 1)
584 return false; 584 return false;
585 if (numEntries(0)) 585 if (numEntries(0))
586 return false; 586 return false;
587 return true; 587 return true;
588 } 588 }
589 /** returns the filename of this doc */ 589 /** returns the filename of this doc */
590 const QString& getFilename() 590 const QString& getFilename()
591 { return filename; } 591 { return filename; }
592 /** returns the title of the doc */ 592 /** returns the title of the doc */
593 QString getTitle(); 593 QString getTitle();
594 /** sets the list-view-pointer hold in the doc */ 594 /** sets the list-view-pointer hold in the doc */
595 void setListViewPointer(PwMView *_listView) 595 void setListViewPointer(PwMView *_listView)
596 { listView = _listView; } 596 { listView = _listView; }
597 /** returns the list-view-pointer */ 597 /** returns the list-view-pointer */
598 PwMView * getListViewPointer() 598 PwMView * getListViewPointer()
599 { return listView; } 599 { return listView; }
600 /** try to delete the doc. The user may be asked to save 600 /** try to delete the doc. The user may be asked to save
601 * the data. The user may cancel the whole operation. 601 * the data. The user may cancel the whole operation.
602 * false is returned, then. 602 * false is returned, then.
603 */ 603 */
604 bool tryDelete(); 604 bool tryDelete();
605 /** is the doc deleted? (with tryDelete() ) */ 605 /** is the doc deleted? (with tryDelete() ) */
606 bool isDeleted() 606 bool isDeleted()
607 { return deleted; } 607 { return deleted; }
608 /** returns the document timer object */ 608 /** returns the document timer object */
609 DocTimer * timer() 609 DocTimer * timer()
610 { return _timer; } 610 { return _timer; }
611 /** get a lock on the dataChanged signal. 611 /** get a lock on the dataChanged signal.
612 * If someone is holding a lock, the signal is not emitted. 612 * If someone is holding a lock, the signal is not emitted.
613 */ 613 */
614 void getDataChangedLock() 614 void getDataChangedLock()
615 { ++dataChangedLock; } 615 { ++dataChangedLock; }
616 /** put the dataChanged lock */ 616 /** put the dataChanged lock */
617 void putDataChangedLock() 617 void putDataChangedLock()
618 { --dataChangedLock; } 618 { --dataChangedLock; }
619 /** returns the revision count of the item at cat/index */ 619 /** returns the revision count of the item at cat/index */
620 unsigned int getEntryRevCnt(unsigned int category, unsigned int index) 620 unsigned int getEntryRevCnt(unsigned int category, unsigned int index)
621 { return dti.dta[category].d[index].rev; } 621 { return dti.dta[category].d[index].rev; }
622 /** returns a const pointer to the entries meta */ 622 /** returns a const pointer to the entries meta */
623 const PwMMetaData * getEntryMeta(unsigned int category, unsigned int index) 623 const PwMMetaData * getEntryMeta(unsigned int category, unsigned int index)
624 { return &(dti.dta[category].d[index].meta); } 624 { return &(dti.dta[category].d[index].meta); }
625 /** is the entry at "category" "index" a binary entry? */ 625 /** is the entry at "category" "index" a binary entry? */
626 bool isBinEntry(unsigned int category, unsigned int index) 626 bool isBinEntry(unsigned int category, unsigned int index)
627 { return dti.dta[category].d[index].binary; } 627 { return dti.dta[category].d[index].binary; }
628 628
629public slots: 629public slots:
630 /** wrapper for PwMTray */ 630 /** wrapper for PwMTray */
631 void _deepUnlock(); 631 void _deepUnlock();
632 632
633signals: 633signals:
634 /** the data of the document has changed and must be updated 634 /** the data of the document has changed and must be updated
635 * in all views. 635 * in all views.
636 * NOTE: use emitDataChanged(PwMDoc *document) to emit this signal! 636 * NOTE: use emitDataChanged(PwMDoc *document) to emit this signal!
637 */ 637 */
638 void dataChanged(PwMDoc *document); 638 void dataChanged(PwMDoc *document);
639 /** the document class is going to close. This signal may be 639 /** the document class is going to close. This signal may be
640 * used to nofify all views, that the user closed the document, 640 * used to nofify all views, that the user closed the document,
641 * so the views can go down, too. 641 * so the views can go down, too.
642 */ 642 */
643 void docClosed(PwMDoc *document); 643 void docClosed(PwMDoc *document);
644 /** somebody just opened the document */ 644 /** somebody just opened the document */
645 void docOpened(PwMDoc *document); 645 void docOpened(PwMDoc *document);
646 /** this document object just got created */ 646 /** this document object just got created */
647 void docCreated(PwMDoc *document); 647 void docCreated(PwMDoc *document);
648 648
649public: 649public:
650 /** emit the dataChanged signal after checking for a lock */ 650 /** emit the dataChanged signal after checking for a lock */
651 void emitDataChanged(PwMDoc *document) 651 void emitDataChanged(PwMDoc *document)
652 { 652 {
653 if (!dataChangedLock) 653 if (!dataChangedLock)
654 emit dataChanged(document); 654 emit dataChanged(document);
655 } 655 }
656 656
657protected: 657protected:
658 /** current file for this doc */ 658 /** current file for this doc */
659 QString filename; 659 QString filename;
660//US ENH: we need a place where we keep the syncentries. So I invented 660//US ENH: we need a place where we keep the syncentries. So I invented
661// struct PwMItem, that has a vector of PwMCategoryItem and vector of PwMSyncItem 661// struct PwMItem, that has a vector of PwMCategoryItem and vector of PwMSyncItem
662 /** holds all data */ 662 /** holds all data */
663 PwMItem dti; 663 PwMItem dti;
664 /** maximum number of entries */ 664 /** maximum number of entries */
665 unsigned int maxEntries; 665 unsigned int maxEntries;
666 /** currently used password to encrypt data */ 666 /** currently used password to encrypt data */
667 QString currentPw; 667 QString currentPw;
668 /** current global document status flags */ 668 /** current global document status flags */
669 unsigned int curDocStat; 669 unsigned int curDocStat;
670 /** browser process for goToURL() */ 670 /** browser process for goToURL() */
671 KProcess browserProc; 671 KProcess browserProc;
672 /** pointer to the list-view, using this document. 672 /** pointer to the list-view, using this document.
673 * As there can only be one list-view per doc, we 673 * As there can only be one list-view per doc, we
674 * don't need a list here. 674 * don't need a list here.
675 */ 675 */
676 PwMView *listView; 676 PwMView *listView;
677 /** unnamedNum is used to store the "unnamed counter" 677 /** unnamedNum is used to store the "unnamed counter"
678 * for this document, while it's unnamed. If it's 0, 678 * for this document, while it's unnamed. If it's 0,
679 * we have to get a new unique one. 679 * we have to get a new unique one.
680 */ 680 */
681 unsigned int unnamedNum; 681 unsigned int unnamedNum;
682 /** is this doc going to be deleted (executing in destructor context) */ 682 /** is this doc going to be deleted (executing in destructor context) */
683 bool deleted; 683 bool deleted;
684 /** document timer */ 684 /** document timer */
685 DocTimer *_timer; 685 DocTimer *_timer;
686 /** lock counter for the "dataChanged" signal */ 686 /** lock counter for the "dataChanged" signal */
687 unsigned int dataChangedLock; 687 unsigned int dataChangedLock;
688 688
689 /** list of all open documents */ 689 /** list of all open documents */
690 static PwMDocList openDocList; 690 static PwMDocList openDocList;
691 691
692protected: 692protected:
693 /** serialize "dta" and return it in "d". */ 693 /** serialize "dta" and return it in "d". */
694 bool serializeDta(string *d); 694 bool serializeDta(string *d);
695 /** de-serialize "d" and overwrite "dta" */ 695 /** de-serialize "d" and overwrite "dta" */
696 bool deSerializeDta(const string *d, bool entriesLocked); 696 bool deSerializeDta(const string *d, bool entriesLocked);
697 /** write header to file */ 697 /** write header to file */
698 PwMerror writeFileHeader(char keyHash, char dataHash, char crypt, char compress, 698 PwMerror writeFileHeader(char keyHash, char dataHash, char crypt, char compress,
699 QString *pw, QFile *f); 699 QString *pw, QFile *f);
700 /** write data-hash to file */ 700 /** write data-hash to file */
701 PwMerror writeDataHash(char dataHash, string *d, QFile *f); 701 PwMerror writeDataHash(char dataHash, string *d, QFile *f);
702 /** check header. Read header info and verify key-hash and filever. 702 /** check header. Read header info and verify key-hash and filever.
703 * returns length of header in "headerLength" */ 703 * returns length of header in "headerLength" */
704 PwMerror checkHeader(char *cryptAlgo, QString *pw, char *compress, 704 PwMerror checkHeader(char *cryptAlgo, QString *pw, char *compress,
705 unsigned int *headerLength, char *dataHashType, 705 unsigned int *headerLength, char *dataHashType,
706 string *dataHash, QFile *f); 706 string *dataHash, QFile *f);
707 /** check the data-hash */ 707 /** check the data-hash */
708 PwMerror checkDataHash(char dataHashType, const string *dataHash, const string *dataStream); 708 PwMerror checkDataHash(char dataHashType, const string *dataHash, const string *dataStream);
709 /** encrypt data "d" and write to "filename" */ 709 /** encrypt data "d" and write to "filename" */
710 PwMerror encrypt(string *d, const QString *pw, QFile *f, char algo); 710 PwMerror encrypt(string *d, const QString *pw, QFile *f, char algo);
711 /** read data from file beginning at "pos", decrypt and return it */ 711 /** read data from file beginning at "pos", decrypt and return it */
712 PwMerror decrypt(string *d, unsigned int pos, const QString *pw, char algo, QFile *f); 712 PwMerror decrypt(string *d, unsigned int pos, const QString *pw, char algo, QFile *f);
713 /** compress the data */ 713 /** compress the data */
714 bool compressDta(string *d, char algo); 714 bool compressDta(string *d, char algo);
715 /** uncompress the data */ 715 /** uncompress the data */
716 bool decompressDta(string *d, char algo); 716 bool decompressDta(string *d, char algo);
717 /** internal import function for a text-file generated by PwM. 717 /** internal import function for a text-file generated by PwM.
718 * If this is not a valid PwM-exported file, it returns e_fileFormat */ 718 * If this is not a valid PwM-exported file, it returns e_fileFormat */
719 PwMerror importText_PwM(const QString *file); 719 PwMerror importText_PwM(const QString *file);
720 /** PwM-text-import helper function to extract the name/pw/comment out 720 /** PwM-text-import helper function to extract the name/pw/comment out
721 * of one entry-line */ 721 * of one entry-line */
722 bool textExtractEntry_PwM(const char *in, ssize_t in_size, string *out); 722 bool textExtractEntry_PwM(const char *in, ssize_t in_size, string *out);
723 /** compare two strings */ 723 /** compare two strings */
724 bool compareString(const string &s1, const string &s2, bool caseSensitive, 724 bool compareString(const string &s1, const string &s2, bool caseSensitive,
725 bool exactWordMatch); 725 bool exactWordMatch);
726 /** clears all document-data */ 726 /** clears all document-data */
727 void clearDoc(); 727 void clearDoc();
728 /** delete all empty categories */ 728 /** delete all empty categories */
729 void delAllEmptyCat(bool dontFlagDirty); 729 void delAllEmptyCat(bool dontFlagDirty);
730 /** set a document status flag */ 730 /** set a document status flag */
731 void setDocStatFlag(unsigned int statFlag) 731 void setDocStatFlag(unsigned int statFlag)
732 { curDocStat |= statFlag; } 732 { curDocStat |= statFlag; }
733 /** unset a document status flag */ 733 /** unset a document status flag */
734 void unsetDocStatFlag(unsigned int statFlag) 734 void unsetDocStatFlag(unsigned int statFlag)
735 { curDocStat &= ~statFlag; } 735 { curDocStat &= ~statFlag; }
736 /** get a document status flag */ 736 /** get a document status flag */
737 bool getDocStatFlag(unsigned int statFlag) const 737 bool getDocStatFlag(unsigned int statFlag) const
738 { return (curDocStat & statFlag); } 738 { return (curDocStat & statFlag); }
739 /** set the "currentPassword" */ 739 /** set the "currentPassword" */
740 void setCurrentPw(const QString &pw) 740 void setCurrentPw(const QString &pw)
741 { 741 {
742 currentPw = pw; 742 currentPw = pw;
743 setDocStatFlag(DOC_STAT_DISK_DIRTY); 743 setDocStatFlag(DOC_STAT_DISK_DIRTY);
744 } 744 }
745 /** make a backup-copy of the given file */ 745 /** make a backup-copy of the given file */
746 bool backupFile(const QString &filePath); 746 bool backupFile(const QString &filePath);
747 /** copy a file from src to dst */ 747 /** copy a file from src to dst */
748 bool copyFile(const QString &src, const QString &dst); 748 bool copyFile(const QString &src, const QString &dst);
749 749
750 750
751 public: 751 public:
752#ifdef PWM_EMBEDDED 752#ifdef PWM_EMBEDDED
753 //US ENH: this is the magic function that syncronizes the local doc with the remote doc. 753 //US ENH: this is the magic function that syncronizes the local doc with the remote doc.
754 PwMerror syncronize(KSyncManager* manager, PwMDoc* syncLocal, PwMDoc* syncRemote, int mode ); 754 PwMerror syncronize(KSyncManager* manager, PwMDoc* syncLocal, PwMDoc* syncRemote, int mode );
755 755
756 //takePwMDataItem returns the following values 756 //takePwMDataItem returns the following values
757 // 0 equal 757 // 0 equal
758 // 1 take local 758 // 1 take local
759 // 2 take remote 759 // 2 take remote
760 // 3 cancel 760 // 3 cancel
761 int takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ); 761 int takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full );
762 762
763 //the following methods are the overwritten callbackmethods from the syncinterface 763 //the following methods are the overwritten callbackmethods from the syncinterface
764 virtual bool sync(KSyncManager* manager, QString filename, int mode); 764 virtual bool sync(KSyncManager* manager, QString filename, int mode);
765 virtual void removeSyncInfo( QString syncProfile);
765 766
766#endif 767#endif
767 private: 768 private:
768 //US ENH: helpermethods to access the sync data for a certain syncname. 769 //US ENH: helpermethods to access the sync data for a certain syncname.
769 // It returns the syncdatas index 770 // It returns the syncdatas index
770 bool findSyncData(const QString &syncname, unsigned int *index); 771 bool findSyncData(const QString &syncname, unsigned int *index);
771 772
772 /** add new syncdataentry */ 773 /** add new syncdataentry */
773 PwMerror addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty = false); 774 PwMerror addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty = false);
774 775
775 /** returns a pointer to the syncdata */ 776 /** returns a pointer to the syncdata */
776 PwMSyncItem* getSyncDataEntry(unsigned int index) 777 PwMSyncItem* getSyncDataEntry(unsigned int index)
777 { return &(dti.syncDta[index]); } 778 { return &(dti.syncDta[index]); }
778 779
779 /** delete entry */ 780 /** delete entry */
780 bool delSyncDataEntry(unsigned int index, bool dontFlagDirty = false); 781 bool delSyncDataEntry(unsigned int index, bool dontFlagDirty = false);
781 782
782 PwMDataItem* findEntryByID(const QString &uid, unsigned int *category, unsigned int *index); 783 PwMDataItem* findEntryByID(const QString &uid, unsigned int *category, unsigned int *index);
783 784
784 QStringList getIDEntryList(); 785 QStringList getIDEntryList();
785 786
786}; 787};
787 788
788#endif 789#endif