summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp2
-rw-r--r--kaddressbook/views/cardview.cpp10
-rw-r--r--kmicromail/koprefsdialog.cpp7
-rw-r--r--kmicromail/libmailwrapper/generatemail.cpp16
-rw-r--r--kmicromail/libmailwrapper/generatemail.h1
-rw-r--r--kmicromail/libmailwrapper/genericwrapper.cpp3
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp4
-rw-r--r--kmicromail/libmailwrapper/mailwrapper.h2
-rw-r--r--kmicromail/mainwindow.cpp3
-rw-r--r--microkde/kdecore/klocale.cpp27
-rw-r--r--microkde/kidmanager.cpp2
-rw-r--r--microkde/kresources/managerimpl.cpp4
12 files changed, 46 insertions, 35 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index d651224..c339244 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2554,385 +2554,385 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
2554 if ( mode < SYNC_PREF_ASK ) 2554 if ( mode < SYNC_PREF_ASK )
2555 mode = SYNC_PREF_ASK; 2555 mode = SYNC_PREF_ASK;
2556 } else { 2556 } else {
2557 if ( localMod == remoteMod ) 2557 if ( localMod == remoteMod )
2558 return 0; 2558 return 0;
2559 2559
2560 } 2560 }
2561 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2561 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2562 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2562 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2563 //full = true; //debug only 2563 //full = true; //debug only
2564 if ( full ) { 2564 if ( full ) {
2565 bool equ = ( (*local) == (*remote) ); 2565 bool equ = ( (*local) == (*remote) );
2566 if ( equ ) { 2566 if ( equ ) {
2567 //qDebug("equal "); 2567 //qDebug("equal ");
2568 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2568 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2569 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2569 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2570 } 2570 }
2571 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2571 if ( mode < SYNC_PREF_FORCE_LOCAL )
2572 return 0; 2572 return 0;
2573 2573
2574 }//else //debug only 2574 }//else //debug only
2575 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2575 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2576 } 2576 }
2577 int result; 2577 int result;
2578 bool localIsNew; 2578 bool localIsNew;
2579 //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() ); 2579 //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() );
2580 2580
2581 if ( full && mode < SYNC_PREF_NEWEST ) 2581 if ( full && mode < SYNC_PREF_NEWEST )
2582 mode = SYNC_PREF_ASK; 2582 mode = SYNC_PREF_ASK;
2583 2583
2584 switch( mode ) { 2584 switch( mode ) {
2585 case SYNC_PREF_LOCAL: 2585 case SYNC_PREF_LOCAL:
2586 if ( lastSync > remoteMod ) 2586 if ( lastSync > remoteMod )
2587 return 1; 2587 return 1;
2588 if ( lastSync > localMod ) 2588 if ( lastSync > localMod )
2589 return 2; 2589 return 2;
2590 return 1; 2590 return 1;
2591 break; 2591 break;
2592 case SYNC_PREF_REMOTE: 2592 case SYNC_PREF_REMOTE:
2593 if ( lastSync > remoteMod ) 2593 if ( lastSync > remoteMod )
2594 return 1; 2594 return 1;
2595 if ( lastSync > localMod ) 2595 if ( lastSync > localMod )
2596 return 2; 2596 return 2;
2597 return 2; 2597 return 2;
2598 break; 2598 break;
2599 case SYNC_PREF_NEWEST: 2599 case SYNC_PREF_NEWEST:
2600 if ( localMod > remoteMod ) 2600 if ( localMod > remoteMod )
2601 return 1; 2601 return 1;
2602 else 2602 else
2603 return 2; 2603 return 2;
2604 break; 2604 break;
2605 case SYNC_PREF_ASK: 2605 case SYNC_PREF_ASK:
2606 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2606 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2607 if ( lastSync > remoteMod ) 2607 if ( lastSync > remoteMod )
2608 return 1; 2608 return 1;
2609 if ( lastSync > localMod ) 2609 if ( lastSync > localMod )
2610 return 2; 2610 return 2;
2611 localIsNew = localMod >= remoteMod; 2611 localIsNew = localMod >= remoteMod;
2612 //qDebug("conflict! ************************************** "); 2612 //qDebug("conflict! ************************************** ");
2613 { 2613 {
2614 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2614 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2615 result = acd.executeD(localIsNew); 2615 result = acd.executeD(localIsNew);
2616 return result; 2616 return result;
2617 } 2617 }
2618 break; 2618 break;
2619 case SYNC_PREF_FORCE_LOCAL: 2619 case SYNC_PREF_FORCE_LOCAL:
2620 return 1; 2620 return 1;
2621 break; 2621 break;
2622 case SYNC_PREF_FORCE_REMOTE: 2622 case SYNC_PREF_FORCE_REMOTE:
2623 return 2; 2623 return 2;
2624 break; 2624 break;
2625 2625
2626 default: 2626 default:
2627 // SYNC_PREF_TAKE_BOTH not implemented 2627 // SYNC_PREF_TAKE_BOTH not implemented
2628 break; 2628 break;
2629 } 2629 }
2630 return 0; 2630 return 0;
2631} 2631}
2632 2632
2633 2633
2634bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2634bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2635{ 2635{
2636 bool syncOK = true; 2636 bool syncOK = true;
2637 int addedAddressee = 0; 2637 int addedAddressee = 0;
2638 int addedAddresseeR = 0; 2638 int addedAddresseeR = 0;
2639 int deletedAddresseeR = 0; 2639 int deletedAddresseeR = 0;
2640 int deletedAddresseeL = 0; 2640 int deletedAddresseeL = 0;
2641 int changedLocal = 0; 2641 int changedLocal = 0;
2642 int changedRemote = 0; 2642 int changedRemote = 0;
2643 2643
2644 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2644 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2645 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2645 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2646 2646
2647 //QPtrList<Addressee> el = local->rawAddressees(); 2647 //QPtrList<Addressee> el = local->rawAddressees();
2648 Addressee addresseeR; 2648 Addressee addresseeR;
2649 QString uid; 2649 QString uid;
2650 int take; 2650 int take;
2651 Addressee addresseeL; 2651 Addressee addresseeL;
2652 Addressee addresseeRSync; 2652 Addressee addresseeRSync;
2653 Addressee addresseeLSync; 2653 Addressee addresseeLSync;
2654 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2654 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2655 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2655 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2656 bool fullDateRange = false; 2656 bool fullDateRange = false;
2657 local->resetTempSyncStat(); 2657 local->resetTempSyncStat();
2658 mLastAddressbookSync = QDateTime::currentDateTime(); 2658 mLastAddressbookSync = QDateTime::currentDateTime();
2659 if ( syncManager->syncWithDesktop() ) { 2659 if ( syncManager->syncWithDesktop() ) {
2660 // remote->removeSyncInfo( QString());//remove all info 2660 // remote->removeSyncInfo( QString());//remove all info
2661 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2661 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2662 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2662 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2663 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2663 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2664 } else { 2664 } else {
2665 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2665 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
2666 } 2666 }
2667 } 2667 }
2668 QDateTime modifiedCalendar = mLastAddressbookSync; 2668 QDateTime modifiedCalendar = mLastAddressbookSync;
2669 addresseeLSync = getLastSyncAddressee(); 2669 addresseeLSync = getLastSyncAddressee();
2670 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2670 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2671 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2671 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2672 if ( !addresseeR.isEmpty() ) { 2672 if ( !addresseeR.isEmpty() ) {
2673 addresseeRSync = addresseeR; 2673 addresseeRSync = addresseeR;
2674 remote->removeAddressee(addresseeR ); 2674 remote->removeAddressee(addresseeR );
2675 2675
2676 } else { 2676 } else {
2677 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2677 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2678 addresseeRSync = addresseeLSync ; 2678 addresseeRSync = addresseeLSync ;
2679 } else { 2679 } else {
2680 //qDebug("FULLDATE 1"); 2680 //qDebug("FULLDATE 1");
2681 fullDateRange = true; 2681 fullDateRange = true;
2682 Addressee newAdd; 2682 Addressee newAdd;
2683 addresseeRSync = newAdd; 2683 addresseeRSync = newAdd;
2684 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2684 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2685 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2685 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2686 addresseeRSync.setRevision( mLastAddressbookSync ); 2686 addresseeRSync.setRevision( mLastAddressbookSync );
2687 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2687 addresseeRSync.setCategories( i18n("SyncAddressee") );
2688 } 2688 }
2689 } 2689 }
2690 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2690 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2691 // qDebug("FULLDATE 2"); 2691 // qDebug("FULLDATE 2");
2692 fullDateRange = true; 2692 fullDateRange = true;
2693 } 2693 }
2694 if ( ! fullDateRange ) { 2694 if ( ! fullDateRange ) {
2695 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2695 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2696 2696
2697 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2697 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2698 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2698 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2699 fullDateRange = true; 2699 fullDateRange = true;
2700 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2700 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2701 } 2701 }
2702 } 2702 }
2703 // fullDateRange = true; // debug only! 2703 // fullDateRange = true; // debug only!
2704 if ( fullDateRange ) 2704 if ( fullDateRange )
2705 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2705 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2706 else 2706 else
2707 mLastAddressbookSync = addresseeLSync.revision(); 2707 mLastAddressbookSync = addresseeLSync.revision();
2708 // for resyncing if own file has changed 2708 // for resyncing if own file has changed
2709 // PENDING fixme later when implemented 2709 // PENDING fixme later when implemented
2710#if 0 2710#if 0
2711 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2711 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2712 mLastAddressbookSync = loadedFileVersion; 2712 mLastAddressbookSync = loadedFileVersion;
2713 qDebug("setting mLastAddressbookSync "); 2713 qDebug("setting mLastAddressbookSync ");
2714 } 2714 }
2715#endif 2715#endif
2716 2716
2717 //qDebug("*************************** "); 2717 //qDebug("*************************** ");
2718 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2718 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2719 QStringList er = remote->uidList(); 2719 QStringList er = remote->uidList();
2720 Addressee inR ;//= er.first(); 2720 Addressee inR ;//= er.first();
2721 Addressee inL; 2721 Addressee inL;
2722 2722
2723 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2723 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2724 2724
2725 int modulo = (er.count()/10)+1; 2725 int modulo = (er.count()/10)+1;
2726 int incCounter = 0; 2726 int incCounter = 0;
2727 while ( incCounter < er.count()) { 2727 while ( incCounter < er.count()) {
2728 if (syncManager->isProgressBarCanceled()) 2728 if (syncManager->isProgressBarCanceled())
2729 return false; 2729 return false;
2730 if ( incCounter % modulo == 0 ) 2730 if ( incCounter % modulo == 0 )
2731 syncManager->showProgressBar(incCounter); 2731 syncManager->showProgressBar(incCounter);
2732 2732
2733 uid = er[ incCounter ]; 2733 uid = er[ incCounter ];
2734 bool skipIncidence = false; 2734 bool skipIncidence = false;
2735 if ( uid.left(19) == QString("last-syncAddressee-") ) 2735 if ( uid.left(19) == QString("last-syncAddressee-") )
2736 skipIncidence = true; 2736 skipIncidence = true;
2737 QString idS,OidS; 2737 QString idS,OidS;
2738 qApp->processEvents(); 2738 qApp->processEvents();
2739 if ( !skipIncidence ) { 2739 if ( !skipIncidence ) {
2740 inL = local->findByUid( uid ); 2740 inL = local->findByUid( uid );
2741 inR = remote->findByUid( uid ); 2741 inR = remote->findByUid( uid );
2742 //inL.setResource( 0 ); 2742 //inL.setResource( 0 );
2743 //inR.setResource( 0 ); 2743 //inR.setResource( 0 );
2744 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2744 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2745 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2745 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2746 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2746 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
2747 //qDebug("take %d %s ", take, inL.summary().latin1()); 2747 //qDebug("take %d %s ", take, inL.summary().latin1());
2748 if ( take == 3 ) 2748 if ( take == 3 )
2749 return false; 2749 return false;
2750 if ( take == 1 ) {// take local ********************** 2750 if ( take == 1 ) {// take local **********************
2751 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2751 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2752 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2752 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2753 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2753 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2754 local->insertAddressee( inL, false ); 2754 local->insertAddressee( inL, false );
2755 idS = inR.externalUID(); 2755 idS = inR.externalUID();
2756 OidS = inR.originalExternalUID(); 2756 OidS = inR.originalExternalUID();
2757 } 2757 }
2758 else 2758 else
2759 idS = inR.IDStr(); 2759 idS = inR.IDStr();
2760 remote->removeAddressee( inR ); 2760 remote->removeAddressee( inR );
2761 inR = inL; 2761 inR = inL;
2762 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2762 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2763 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2763 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2764 inR.setOriginalExternalUID( OidS ); 2764 inR.setOriginalExternalUID( OidS );
2765 inR.setExternalUID( idS ); 2765 inR.setExternalUID( idS );
2766 if ( syncManager->syncWithDesktop() ) { 2766 if ( syncManager->syncWithDesktop() ) {
2767 inR.setIDStr("changed" ); 2767 inR.setIDStr("changed" );
2768 } 2768 }
2769 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2769 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2770 } else { 2770 } else {
2771 inR.setIDStr( idS ); 2771 inR.setIDStr( idS );
2772 } 2772 }
2773 inR.setResource( 0 ); 2773 inR.setResource( 0 );
2774 remote->insertAddressee( inR , false); 2774 remote->insertAddressee( inR , false);
2775 ++changedRemote; 2775 ++changedRemote;
2776 } else { // take == 2 take remote ********************** 2776 } else { // take == 2 take remote **********************
2777 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2777 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2778 if ( inR.revision().date().year() < 2004 ) 2778 if ( inR.revision().date().year() < 2004 )
2779 inR.setRevision( modifiedCalendar ); 2779 inR.setRevision( modifiedCalendar );
2780 } 2780 }
2781 idS = inL.IDStr(); 2781 idS = inL.IDStr();
2782 local->removeAddressee( inL ); 2782 local->removeAddressee( inL );
2783 inL = inR; 2783 inL = inR;
2784 inL.setIDStr( idS ); 2784 inL.setIDStr( idS );
2785 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2785 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2786 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2786 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2787 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2787 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2788 } 2788 }
2789 inL.setResource( 0 ); 2789 inL.setResource( 0 );
2790 local->insertAddressee( inL , false ); 2790 local->insertAddressee( inL , false );
2791 ++changedLocal; 2791 ++changedLocal;
2792 } 2792 }
2793 } 2793 }
2794 } 2794 }
2795 } else { // no conflict ********** add or delete remote 2795 } else { // no conflict ********** add or delete remote
2796 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2796 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2797 QString des = addresseeLSync.note(); 2797 QString des = addresseeLSync.note();
2798 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2798 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2799 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2799 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2800 remote->insertAddressee( inR, false ); 2800 remote->insertAddressee( inR, false );
2801 ++deletedAddresseeR; 2801 ++deletedAddresseeR;
2802 } else { 2802 } else {
2803 inR.setRevision( modifiedCalendar ); 2803 inR.setRevision( modifiedCalendar );
2804 remote->insertAddressee( inR, false ); 2804 remote->insertAddressee( inR, false );
2805 inL = inR; 2805 inL = inR;
2806 inL.setIDStr( ":" ); 2806 inL.setIDStr( ":" );
2807 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2807 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2808 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2808 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2809 inL.setResource( 0 ); 2809 inL.setResource( 0 );
2810 local->insertAddressee( inL , false); 2810 local->insertAddressee( inL , false);
2811 ++addedAddressee; 2811 ++addedAddressee;
2812 } 2812 }
2813 } else { 2813 } else {
2814 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2814 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2815 inR.setRevision( modifiedCalendar ); 2815 inR.setRevision( modifiedCalendar );
2816 remote->insertAddressee( inR, false ); 2816 remote->insertAddressee( inR, false );
2817 inR.setResource( 0 ); 2817 inR.setResource( 0 );
2818 local->insertAddressee( inR, false ); 2818 local->insertAddressee( inR, false );
2819 ++addedAddressee; 2819 ++addedAddressee;
2820 } else { 2820 } else {
2821 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2821 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2822 remote->removeAddressee( inR ); 2822 remote->removeAddressee( inR );
2823 ++deletedAddresseeR; 2823 ++deletedAddresseeR;
2824 } 2824 }
2825 } 2825 }
2826 } 2826 }
2827 } 2827 }
2828 ++incCounter; 2828 ++incCounter;
2829 } 2829 }
2830 er.clear(); 2830 er.clear();
2831 QStringList el = local->uidList(); 2831 QStringList el = local->uidList();
2832 modulo = (el.count()/10)+1; 2832 modulo = (el.count()/10)+1;
2833 2833
2834 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2834 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2835 incCounter = 0; 2835 incCounter = 0;
2836 while ( incCounter < el.count()) { 2836 while ( incCounter < el.count()) {
2837 qApp->processEvents(); 2837 qApp->processEvents();
2838 if (syncManager->isProgressBarCanceled()) 2838 if (syncManager->isProgressBarCanceled())
2839 return false; 2839 return false;
2840 if ( incCounter % modulo == 0 ) 2840 if ( incCounter % modulo == 0 )
2841 syncManager->showProgressBar(incCounter); 2841 syncManager->showProgressBar(incCounter);
2842 uid = el[ incCounter ]; 2842 uid = el[ incCounter ];
2843 bool skipIncidence = false; 2843 bool skipIncidence = false;
2844 if ( uid.left(19) == QString("last-syncAddressee-") ) 2844 if ( uid.left(19) == QString("last-syncAddressee-") )
2845 skipIncidence = true; 2845 skipIncidence = true;
2846 if ( !skipIncidence ) { 2846 if ( !skipIncidence ) {
2847 inL = local->findByUid( uid ); 2847 inL = local->findByUid( uid );
2848 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2848 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2849 inR = remote->findByUid( uid ); 2849 inR = remote->findByUid( uid );
2850 if ( inR.isEmpty() ) { // no conflict ********** add or delete local 2850 if ( inR.isEmpty() ) { // no conflict ********** add or delete local
2851 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2851 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2852 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2852 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2853 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2853 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2854 local->removeAddressee( inL ); 2854 local->removeAddressee( inL );
2855 ++deletedAddresseeL; 2855 ++deletedAddresseeL;
2856 } else { 2856 } else {
2857 if ( ! syncManager->mWriteBackExistingOnly ) { 2857 if ( ! syncManager->mWriteBackExistingOnly ) {
2858 inL.removeID(mCurrentSyncDevice ); 2858 inL.removeID(mCurrentSyncDevice );
2859 ++addedAddresseeR; 2859 ++addedAddresseeR;
2860 inL.setRevision( modifiedCalendar ); 2860 inL.setRevision( modifiedCalendar );
2861 local->insertAddressee( inL, false ); 2861 local->insertAddressee( inL, false );
2862 inR = inL; 2862 inR = inL;
2863 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2863 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2864 inR.setResource( 0 ); 2864 inR.setResource( 0 );
2865 remote->insertAddressee( inR, false ); 2865 remote->insertAddressee( inR, false );
2866 } 2866 }
2867 } 2867 }
2868 } else { 2868 } else {
2869 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2869 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2870 //qDebug("data %s ", inL.revision().toString().latin1()); 2870 //qDebug("data %s ", inL.revision().toString().latin1());
2871 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2871 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2872 local->removeAddressee( inL ); 2872 local->removeAddressee( inL );
2873 ++deletedAddresseeL; 2873 ++deletedAddresseeL;
2874 } else { 2874 } else {
2875 if ( ! syncManager->mWriteBackExistingOnly ) { 2875 if ( ! syncManager->mWriteBackExistingOnly ) {
2876 ++addedAddresseeR; 2876 ++addedAddresseeR;
2877 inL.setRevision( modifiedCalendar ); 2877 inL.setRevision( modifiedCalendar );
2878 local->insertAddressee( inL, false ); 2878 local->insertAddressee( inL, false );
2879 inR = inL; 2879 inR = inL;
2880 inR.setIDStr( ":" ); 2880 inR.setIDStr( ":" );
2881 inR.setResource( 0 ); 2881 inR.setResource( 0 );
2882 remote->insertAddressee( inR, false ); 2882 remote->insertAddressee( inR, false );
2883 } 2883 }
2884 } 2884 }
2885 } 2885 }
2886 } 2886 }
2887 } 2887 }
2888 } 2888 }
2889 ++incCounter; 2889 ++incCounter;
2890 } 2890 }
2891 el.clear(); 2891 el.clear();
2892 syncManager->hideProgressBar(); 2892 syncManager->hideProgressBar();
2893 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2893 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2894 // get rid of micro seconds 2894 // get rid of micro seconds
2895 QTime t = mLastAddressbookSync.time(); 2895 QTime t = mLastAddressbookSync.time();
2896 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2896 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2897 addresseeLSync.setRevision( mLastAddressbookSync ); 2897 addresseeLSync.setRevision( mLastAddressbookSync );
2898 addresseeRSync.setRevision( mLastAddressbookSync ); 2898 addresseeRSync.setRevision( mLastAddressbookSync );
2899 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2899 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2900 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2900 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2901 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2901 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2902 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2902 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2903 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2903 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2904 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2904 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2905 addresseeRSync.setNote( "" ) ; 2905 addresseeRSync.setNote( "" ) ;
2906 addresseeLSync.setNote( "" ); 2906 addresseeLSync.setNote( "" );
2907 2907
2908 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2908 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2909 remote->insertAddressee( addresseeRSync, false ); 2909 remote->insertAddressee( addresseeRSync, false );
2910 local->insertAddressee( addresseeLSync, false ); 2910 local->insertAddressee( addresseeLSync, false );
2911 QString mes; 2911 QString mes;
2912 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 ); 2912 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 );
2913 qDebug( mes ); 2913 qDebug( mes );
2914 mes = i18n("Local addressbook changed!\n") +mes; 2914 mes = i18n("Local addressbook changed!\n") +mes;
2915 if ( syncManager->mShowSyncSummary ) { 2915 if ( syncManager->mShowSyncSummary ) {
2916 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 2916 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
2917 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 2917 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
2918 qDebug("cancelled "); 2918 qDebug("cancelled ");
2919 return false; 2919 return false;
2920 } 2920 }
2921 } 2921 }
2922 return syncOK; 2922 return syncOK;
2923} 2923}
2924 2924
2925 2925
2926//this is a overwritten callbackmethods from the syncinterface 2926//this is a overwritten callbackmethods from the syncinterface
2927bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2927bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2928{ 2928{
2929 2929
2930 //pending prepare addresseeview for output 2930 //pending prepare addresseeview for output
2931 //pending detect, if remote file has REV field. if not switch to external sync 2931 //pending detect, if remote file has REV field. if not switch to external sync
2932 mGlobalSyncMode = SYNC_MODE_NORMAL; 2932 mGlobalSyncMode = SYNC_MODE_NORMAL;
2933 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2933 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2934 2934
2935 AddressBook abLocal(filename,"syncContact"); 2935 AddressBook abLocal(filename,"syncContact");
2936 bool syncOK = false; 2936 bool syncOK = false;
2937 if ( abLocal.load() ) { 2937 if ( abLocal.load() ) {
2938 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2938 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
diff --git a/kaddressbook/views/cardview.cpp b/kaddressbook/views/cardview.cpp
index da552c3..03df444 100644
--- a/kaddressbook/views/cardview.cpp
+++ b/kaddressbook/views/cardview.cpp
@@ -1,398 +1,398 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program 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 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24//BEGIN Includes 24//BEGIN Includes
25#include "cardview.h" 25#include "cardview.h"
26 26
27#include <limits.h> 27#include <limits.h>
28 28
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qstyle.h> 33#include <qstyle.h>
34#include <qcursor.h> 34#include <qcursor.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36 36
37#include "kabprefs.h" 37#include "kabprefs.h"
38#include <kdebug.h> 38#include <kdebug.h>
39#include <kglobalsettings.h> 39#include <kglobalsettings.h>
40//END includes 40//END includes
41 41
42#define MIN_ITEM_WIDTH 80 42#define MIN_ITEM_WIDTH 80
43 43
44//BEGIN Helpers 44//BEGIN Helpers
45////////////////////////////////////// 45//////////////////////////////////////
46// CardViewTip 46// CardViewTip
47class CardViewTip : public QLabel { 47class CardViewTip : public QLabel {
48 public: 48 public:
49 CardViewTip(QWidget *parent=0, const char *name=0) : QLabel( parent, name ) 49 CardViewTip(QWidget *parent=0, const char *name=0) : QLabel( parent, name )
50 { 50 {
51 setPalette( QToolTip::palette() ); 51 setPalette( QToolTip::palette() );
52 setFrameStyle( Panel|Plain ); 52 setFrameStyle( Panel|Plain );
53 setMidLineWidth(0); 53 setMidLineWidth(0);
54 setIndent(1); 54 setIndent(1);
55 } 55 }
56 56
57 ~CardViewTip() {}; 57 ~CardViewTip() {};
58 protected: 58 protected:
59 void leaveEvent( QEvent * ) 59 void leaveEvent( QEvent * )
60 { 60 {
61 hide(); 61 hide();
62 } 62 }
63}; 63};
64 64
65////////////////////////////////////// 65//////////////////////////////////////
66// CardViewItemList 66// CardViewItemList
67 67
68 68
69// 69//
70// Warning: make sure you use findRef() instead of find() to find an 70// Warning: make sure you use findRef() instead of find() to find an
71// item! Only the pointer value is unique in the list. 71// item! Only the pointer value is unique in the list.
72// 72//
73class CardViewItemList : public QPtrList<CardViewItem> 73class CardViewItemList : public QPtrList<CardViewItem>
74{ 74{
75 protected: 75 protected:
76 virtual int compareItems(QPtrCollection::Item item1, 76 virtual int compareItems(QPtrCollection::Item item1,
77 QPtrCollection::Item item2) 77 QPtrCollection::Item item2)
78 { 78 {
79 CardViewItem *cItem1 = (CardViewItem*)item1; 79 CardViewItem *cItem1 = (CardViewItem*)item1;
80 CardViewItem *cItem2 = (CardViewItem*)item2; 80 CardViewItem *cItem2 = (CardViewItem*)item2;
81 81
82 if ( cItem1 == cItem2 ) 82 if ( cItem1 == cItem2 )
83 return 0; 83 return 0;
84 84
85 if ((cItem1 == 0) || (cItem2 == 0)) 85 if ((cItem1 == 0) || (cItem2 == 0))
86 return cItem1 ? -1 : 1; 86 return cItem1 ? -1 : 1;
87 87
88 if (cItem1->caption() < cItem2->caption()) 88 if (cItem1->caption() < cItem2->caption())
89 return -1; 89 return -1;
90 90
91 else if (cItem1->caption() > cItem2->caption()) 91 else if (cItem1->caption() > cItem2->caption())
92 return 1; 92 return 1;
93 93
94 return 0; 94 return 0;
95 } 95 }
96 96
97 private: 97 private:
98 /*int find( const CardViewItem * ) 98 /*int find( const CardViewItem * )
99 { 99 {
100 qDebug("DON'T USE CardViewItemList::find( item )! Use findRef( item )!"); 100 qDebug("DON'T USE CardViewItemList::find( item )! Use findRef( item )!");
101 }*/ 101 }*/
102}; 102};
103 103
104////////////////////////////////////// 104//////////////////////////////////////
105// CardViewSeparator 105// CardViewSeparator
106class CardViewSeparator 106class CardViewSeparator
107{ 107{
108 friend class CardView; 108 friend class CardView;
109 109
110 public: 110 public:
111 CardViewSeparator(CardView *view) 111 CardViewSeparator(CardView *view)
112 : mView(view) 112 : mView(view)
113 { 113 {
114 mRect = QRect(0, 0, view->separatorWidth(), 0); 114 mRect = QRect(0, 0, view->separatorWidth(), 0);
115 } 115 }
116 116
117 ~CardViewSeparator() {} 117 ~CardViewSeparator() {}
118 118
119 void paintSeparator(QPainter *p, QColorGroup &cg) 119 void paintSeparator(QPainter *p, QColorGroup &cg)
120 { 120 {
121 p->fillRect(0, 0, mRect.width(), mRect.height(), 121 p->fillRect(0, 0, mRect.width(), mRect.height(),
122 cg.brush(QColorGroup::Button)); 122 cg.brush(QColorGroup::Button));
123 } 123 }
124 124
125 void repaintSeparator() 125 void repaintSeparator()
126 { 126 {
127 mView->repaintContents(mRect); 127 mView->repaintContents(mRect);
128 } 128 }
129 129
130 private: 130 private:
131 CardView *mView; 131 CardView *mView;
132 QRect mRect; 132 QRect mRect;
133}; 133};
134 134
135//END Helpers 135//END Helpers
136 136
137//BEGIN Private Data 137//BEGIN Private Data
138 138
139class CardViewPrivate 139class CardViewPrivate
140{ 140{
141 public: 141 public:
142 CardViewPrivate() 142 CardViewPrivate()
143 : mSelectionMode( CardView::Multi ), 143 : mSelectionMode( CardView::Multi ),
144 mDrawCardBorder( true ), 144 mDrawCardBorder( true ),
145 mDrawFieldLabels( true ), 145 mDrawFieldLabels( true ),
146 mDrawSeparators( true), 146 mDrawSeparators( true),
147 mSepWidth( 2 ), 147 mSepWidth( 2 ),
148 mShowEmptyFields( false ), 148 mShowEmptyFields( false ),
149 mLayoutDirty( true ), 149 mLayoutDirty( true ),
150 mLastClickOnItem( false ), 150 mLastClickOnItem( false ),
151 mItemMargin( 0 ), 151 mItemMargin( 0 ),
152 mItemSpacing( 10 ), 152 mItemSpacing( 10 ),
153 mItemWidth( 200 ), 153 mItemWidth( 200 ),
154 mMaxFieldLines( INT_MAX ), 154 mMaxFieldLines( INT_MAX ),
155 mCurrentItem( 0L ), 155 mCurrentItem( 0L ),
156 mLastClickPos( QPoint(0, 0) ), 156 mLastClickPos( QPoint(0, 0) ),
157 mResizeAnchor(0),
157 mRubberBandAnchor( 0 ), 158 mRubberBandAnchor( 0 ),
158 mCompText( QString::null ), 159 mCompText( QString::null )
159 mResizeAnchor(0)
160 {}; 160 {};
161 161
162 CardViewItemList mItemList; 162 CardViewItemList mItemList;
163 QPtrList<CardViewSeparator> mSeparatorList; 163 QPtrList<CardViewSeparator> mSeparatorList;
164 QFontMetrics *mFm; 164 QFontMetrics *mFm;
165 QFontMetrics *mBFm; // bold font 165 QFontMetrics *mBFm; // bold font
166 QFont mHeaderFont; // custom header font 166 QFont mHeaderFont; // custom header font
167 CardView::SelectionMode mSelectionMode; 167 CardView::SelectionMode mSelectionMode;
168 bool mDrawCardBorder; 168 bool mDrawCardBorder;
169 bool mDrawFieldLabels; 169 bool mDrawFieldLabels;
170 bool mDrawSeparators; 170 bool mDrawSeparators;
171 int mSepWidth; 171 int mSepWidth;
172 bool mShowEmptyFields; 172 bool mShowEmptyFields;
173 bool mLayoutDirty; 173 bool mLayoutDirty;
174 bool mLastClickOnItem; 174 bool mLastClickOnItem;
175 uint mItemMargin; // internal margin in items 175 uint mItemMargin; // internal margin in items
176 uint mItemSpacing; // spacing between items, column seperators and border 176 uint mItemSpacing; // spacing between items, column seperators and border
177 int mItemWidth; // width of all items 177 int mItemWidth; // width of all items
178 uint mMaxFieldLines; // Max lines to dispaly pr field 178 uint mMaxFieldLines; // Max lines to dispaly pr field
179 CardViewItem *mCurrentItem; 179 CardViewItem *mCurrentItem;
180 QPoint mLastClickPos; 180 QPoint mLastClickPos;
181 QTimer *mTimer; // times out if mouse rests for more than 500 msecs 181 QTimer *mTimer; // times out if mouse rests for more than 500 msecs
182 CardViewTip *mTip; // passed to the item under a resting cursor to display full text 182 CardViewTip *mTip; // passed to the item under a resting cursor to display full text
183 bool mOnSeparator; // set/reset on mouse movement 183 bool mOnSeparator; // set/reset on mouse movement
184 // for resizing by dragging the separators 184 // for resizing by dragging the separators
185 int mResizeAnchor; // uint, ulong? the mouse down separator left 185 int mResizeAnchor; // uint, ulong? the mouse down separator left
186 int mRubberBandAnchor; // for erasing rubber bands 186 int mRubberBandAnchor; // for erasing rubber bands
187 // data used for resizing. 187 // data used for resizing.
188 // as they are beeded by each mouse move while resizing, we store them here, 188 // as they are beeded by each mouse move while resizing, we store them here,
189 // saving 8 calculations in each mouse move. 189 // saving 8 calculations in each mouse move.
190 int colspace; // amount of space between items pr column 190 int colspace; // amount of space between items pr column
191 uint first; // the first col to anchor at for painting rubber bands 191 uint first; // the first col to anchor at for painting rubber bands
192 int firstX; // X position of first in pixel 192 int firstX; // X position of first in pixel
193 int pressed; // the colummn that was pressed on at resizing start 193 int pressed; // the colummn that was pressed on at resizing start
194 int span; // pressed - first 194 int span; // pressed - first
195 // key completion 195 // key completion
196 QString mCompText; // current completion string 196 QString mCompText; // current completion string
197 QDateTime mCompUpdated; // ...was updated at this time 197 QDateTime mCompUpdated; // ...was updated at this time
198}; 198};
199 199
200class CardViewItemPrivate 200class CardViewItemPrivate
201{ 201{
202 public: 202 public:
203 CardViewItemPrivate() : 203 CardViewItemPrivate() :
204 x( 0 ), 204 mSelected( false ),
205 y( 0 ), 205 x( 0 ),
206 mSelected( false ){}; 206 y( 0 ){};
207 207
208 208
209 QString mCaption; 209 QString mCaption;
210 QPtrList< CardViewItem::Field > mFieldList; 210 QPtrList< CardViewItem::Field > mFieldList;
211 bool mSelected; 211 bool mSelected;
212 int x; // horizontal position, set by the view 212 int x; // horizontal position, set by the view
213 int y; // vertical position, set by the view 213 int y; // vertical position, set by the view
214 int maxLabelWidth; // the width of the widest label, according to the view font. 214 int maxLabelWidth; // the width of the widest label, according to the view font.
215 int hcache; // height cache 215 int hcache; // height cache
216}; 216};
217//END Private Data 217//END Private Data
218 218
219//BEGIN CardViewItem 219//BEGIN CardViewItem
220 220
221CardViewItem::CardViewItem(CardView *parent, QString caption) 221CardViewItem::CardViewItem(CardView *parent, QString caption)
222 : d(new CardViewItemPrivate()), mView(parent) 222 : d(new CardViewItemPrivate()), mView(parent)
223{ 223{
224 d->mCaption = caption; 224 d->mCaption = caption;
225 225
226 initialize(); 226 initialize();
227} 227}
228 228
229CardViewItem::~CardViewItem() 229CardViewItem::~CardViewItem()
230{ 230{
231 // Remove ourself from the view 231 // Remove ourself from the view
232 if (mView != 0) 232 if (mView != 0)
233 mView->takeItem(this); 233 mView->takeItem(this);
234 234
235 delete d; 235 delete d;
236 d = 0; 236 d = 0;
237} 237}
238 238
239void CardViewItem::initialize() 239void CardViewItem::initialize()
240{ 240{
241 d->mSelected = false; 241 d->mSelected = false;
242 d->mFieldList.setAutoDelete(true); 242 d->mFieldList.setAutoDelete(true);
243 d->maxLabelWidth = 0; 243 d->maxLabelWidth = 0;
244 d->hcache=0; 244 d->hcache=0;
245 245
246 //calcRect(); 246 //calcRect();
247 247
248 // Add ourself to the view 248 // Add ourself to the view
249 if (mView != 0) 249 if (mView != 0)
250 mView->insertItem(this); 250 mView->insertItem(this);
251} 251}
252 252
253void CardViewItem::paintCard(QPainter *p, QColorGroup &cg) 253void CardViewItem::paintCard(QPainter *p, QColorGroup &cg)
254{ 254{
255 255
256 if (!mView) 256 if (!mView)
257 return; 257 return;
258 258
259 QPen pen; 259 QPen pen;
260 QBrush brush; 260 QBrush brush;
261 QFontMetrics fm = *(mView->d->mFm); 261 QFontMetrics fm = *(mView->d->mFm);
262 QFontMetrics bFm = *(mView->d->mBFm); 262 QFontMetrics bFm = *(mView->d->mBFm);
263 bool drawLabels = mView->d->mDrawFieldLabels; 263 bool drawLabels = mView->d->mDrawFieldLabels;
264 bool drawBorder = mView->d->mDrawCardBorder; 264 bool drawBorder = mView->d->mDrawCardBorder;
265 int mg = mView->itemMargin(); 265 int mg = mView->itemMargin();
266 int w = mView->itemWidth() - (mg*2); 266 int w = mView->itemWidth() - (mg*2);
267 int h = height() - (mg*2); 267 int h = height() - (mg*2);
268 const int colonWidth( fm.width(":") ); 268 const int colonWidth( fm.width(":") );
269 int labelXPos = 2 + mg; 269 int labelXPos = 2 + mg;
270 int labelWidth = QMIN( w/2 - 4 - mg, d->maxLabelWidth + colonWidth + 4 ); 270 int labelWidth = QMIN( w/2 - 4 - mg, d->maxLabelWidth + colonWidth + 4 );
271 int valueXPos = labelWidth + 4 + mg; 271 int valueXPos = labelWidth + 4 + mg;
272 int valueWidth = w - labelWidth - 4 - mg; 272 int valueWidth = w - labelWidth - 4 - mg;
273 273
274 p->setFont( mView->font() ); 274 p->setFont( mView->font() );
275 labelWidth -= colonWidth; // extra space for the colon 275 labelWidth -= colonWidth; // extra space for the colon
276 276
277 if (!drawLabels) 277 if (!drawLabels)
278 { 278 {
279 valueXPos = labelXPos; 279 valueXPos = labelXPos;
280 valueWidth = w - 4; 280 valueWidth = w - 4;
281 } 281 }
282 282
283 // Draw a simple box 283 // Draw a simple box
284 if (isSelected()) 284 if (isSelected())
285 pen = QPen(cg.highlight(), 1); 285 pen = QPen(cg.highlight(), 1);
286 else 286 else
287 pen = QPen(cg.button(), 1); 287 pen = QPen(cg.button(), 1);
288 p->setPen(pen); 288 p->setPen(pen);
289 289
290 // Draw the border - this is only draw if the user asks for it. 290 // Draw the border - this is only draw if the user asks for it.
291 if (drawBorder) 291 if (drawBorder)
292 p->drawRect( mg, mg, w, h ); 292 p->drawRect( mg, mg, w, h );
293 293
294 // set the proper pen color for the caption box 294 // set the proper pen color for the caption box
295 if (isSelected()) 295 if (isSelected())
296 brush = cg.brush(QColorGroup::Highlight); 296 brush = cg.brush(QColorGroup::Highlight);
297 else 297 else
298 brush = cg.brush(QColorGroup::Button); 298 brush = cg.brush(QColorGroup::Button);
299 299
300 p->fillRect(mg, mg, w, 4 + bFm.height(), brush); 300 p->fillRect(mg, mg, w, 4 + bFm.height(), brush);
301 301
302 // Now paint the caption 302 // Now paint the caption
303 p->save(); 303 p->save();
304 QFont bFont = mView->headerFont(); 304 QFont bFont = mView->headerFont();
305 //bFont.setBold(true); 305 //bFont.setBold(true);
306 p->setFont(bFont); 306 p->setFont(bFont);
307 if (isSelected()) 307 if (isSelected())
308 p->setPen(cg.highlightedText()); 308 p->setPen(cg.highlightedText());
309 else 309 else
310 p->setPen(cg.buttonText()); 310 p->setPen(cg.buttonText());
311 p->drawText(2+mg, 2+mg + bFm.ascent()/*bFm.height()*//*-bFm.descent()*//*-bFm.leading()*/, trimString(d->mCaption, w-4, bFm)); 311 p->drawText(2+mg, 2+mg + bFm.ascent()/*bFm.height()*//*-bFm.descent()*//*-bFm.leading()*/, trimString(d->mCaption, w-4, bFm));
312 p->restore(); 312 p->restore();
313 313
314 // Go through the fields and draw them 314 // Go through the fields and draw them
315 QPtrListIterator< CardViewItem::Field > iter(d->mFieldList); 315 QPtrListIterator< CardViewItem::Field > iter(d->mFieldList);
316 QString label, value; 316 QString label, value;
317 int yPos = mg + 4 + bFm.height()/* + 1*/ + fm.height(); // why the + 1 ??? (anders) 317 int yPos = mg + 4 + bFm.height()/* + 1*/ + fm.height(); // why the + 1 ??? (anders)
318 p->setPen(cg.text()); 318 p->setPen(cg.text());
319 319
320 int fh = fm.height(); 320 int fh = fm.height();
321 int cln( 0 ); 321 int cln( 0 );
322 QString tmp; 322 QString tmp;
323 int maxLines = mView->maxFieldLines(); 323 int maxLines = mView->maxFieldLines();
324 for (iter.toFirst(); iter.current(); ++iter) 324 for (iter.toFirst(); iter.current(); ++iter)
325 { 325 {
326 value = (*iter)->second; 326 value = (*iter)->second;
327 if ( value.isEmpty() && ! mView->d->mShowEmptyFields ) 327 if ( value.isEmpty() && ! mView->d->mShowEmptyFields )
328 continue; 328 continue;
329 329
330 if (drawLabels) 330 if (drawLabels)
331 { 331 {
332 label = trimString((*iter)->first, labelWidth, fm); 332 label = trimString((*iter)->first, labelWidth, fm);
333 p->drawText(labelXPos, yPos, label + ":"); 333 p->drawText(labelXPos, yPos, label + ":");
334 } 334 }
335/* US original 335/* US original
336 for (cln=0; cln <= maxLines; cln++) 336 for (cln=0; cln <= maxLines; cln++)
337 { 337 {
338 tmp = value.section('\n',cln,cln); 338 tmp = value.section('\n',cln,cln);
339 if ( !tmp.isEmpty() ) p->drawText( valueXPos, yPos + cln*fh, trimString( tmp, valueWidth, fm ) ); 339 if ( !tmp.isEmpty() ) p->drawText( valueXPos, yPos + cln*fh, trimString( tmp, valueWidth, fm ) );
340 else break; 340 else break;
341 } 341 }
342*/ 342*/
343 343
344//US new implementation 344//US new implementation
345 QStringList strlst = QStringList::split('\n', value, true); 345 QStringList strlst = QStringList::split('\n', value, true);
346 346
347 for (cln=0; cln <= maxLines && cln <= (int)strlst.count(); cln++) 347 for (cln=0; cln <= maxLines && cln <= (int)strlst.count(); cln++)
348 { 348 {
349 tmp = strlst[cln]; 349 tmp = strlst[cln];
350 350
351 if ( !tmp.isEmpty() ) 351 if ( !tmp.isEmpty() )
352 p->drawText( valueXPos, yPos + cln*fh, trimString( tmp, valueWidth, fm ) ); 352 p->drawText( valueXPos, yPos + cln*fh, trimString( tmp, valueWidth, fm ) );
353 else 353 else
354 break; 354 break;
355 355
356 } 356 }
357 357
358 if ( cln == 0 ) cln = 1; 358 if ( cln == 0 ) cln = 1;
359 yPos += cln * fh + 2; 359 yPos += cln * fh + 2;
360 } 360 }
361 361
362 // if we are the current item and the view has focus, draw focus rect 362 // if we are the current item and the view has focus, draw focus rect
363 if ( mView->currentItem() == this && mView->hasFocus() ) 363 if ( mView->currentItem() == this && mView->hasFocus() )
364 { 364 {
365/*US 365/*US
366 mView->style().drawPrimitive( QStyle::PE_FocusRect, p, 366 mView->style().drawPrimitive( QStyle::PE_FocusRect, p,
367 QRect(0, 0, mView->itemWidth(), h+(2*mg)), cg, 367 QRect(0, 0, mView->itemWidth(), h+(2*mg)), cg,
368 QStyle::Style_FocusAtBorder, 368 QStyle::Style_FocusAtBorder,
369 QStyleOption( isSelected() ? cg.highlight() : cg.base() ) ); 369 QStyleOption( isSelected() ? cg.highlight() : cg.base() ) );
370*/ 370*/
371 371
372 const QColor pHighl = isSelected() ? cg.highlight() : cg.base(); 372 const QColor pHighl = isSelected() ? cg.highlight() : cg.base();
373 const QRect r(0, 0, mView->itemWidth(), h+(2*mg)); 373 const QRect r(0, 0, mView->itemWidth(), h+(2*mg));
374#ifndef DESKTOP_VERSION 374#ifndef DESKTOP_VERSION
375 mView->style().drawFocusRect(p, r, cg, &pHighl, true); 375 mView->style().drawFocusRect(p, r, cg, &pHighl, true);
376#endif 376#endif
377 } 377 }
378} 378}
379 379
380const QString &CardViewItem::caption() const 380const QString &CardViewItem::caption() const
381{ 381{
382 return d->mCaption; 382 return d->mCaption;
383} 383}
384 384
385 385
386int CardViewItem::height( bool allowCache ) const 386int CardViewItem::height( bool allowCache ) const
387{ 387{
388 // use cache 388 // use cache
389 if ( allowCache && d->hcache ) 389 if ( allowCache && d->hcache )
390 return d->hcache; 390 return d->hcache;
391 391
392 // Base height: 392 // Base height:
393 // 2 for line width 393 // 2 for line width
394 // 2 for top caption pad 394 // 2 for top caption pad
395 // 2 for bottom caption pad 395 // 2 for bottom caption pad
396 // 2 pad for the end 396 // 2 pad for the end
397 // + 2 times the advised margin 397 // + 2 times the advised margin
398 int baseHeight = 8 + ( 2 * mView->itemMargin() ); 398 int baseHeight = 8 + ( 2 * mView->itemMargin() );
diff --git a/kmicromail/koprefsdialog.cpp b/kmicromail/koprefsdialog.cpp
index 4abf859..13d6681 100644
--- a/kmicromail/koprefsdialog.cpp
+++ b/kmicromail/koprefsdialog.cpp
@@ -1,400 +1,401 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program 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 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#include <kdialog.h> 23#include <kdialog.h>
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qfont.h> 29#include <qfont.h>
30#include <qslider.h> 30#include <qslider.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qvbox.h> 34#include <qvbox.h>
35#include <qhbox.h> 35#include <qhbox.h>
36#include <qregexp.h> 36#include <qregexp.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qradiobutton.h> 40#include <qradiobutton.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qstrlist.h> 42#include <qstrlist.h>
43#include <qapplication.h> 43#include <qapplication.h>
44 44
45#include <kcolorbutton.h> 45#include <kcolorbutton.h>
46#include <kdebug.h> 46#include <kdebug.h>
47#include <klocale.h> 47#include <klocale.h>
48#include <kglobal.h> 48#include <kglobal.h>
49#include <kfontdialog.h> 49#include <kfontdialog.h>
50#include <kfiledialog.h> 50#include <kfiledialog.h>
51#include <kmessagebox.h> 51#include <kmessagebox.h>
52#include <kcolordialog.h> 52#include <kcolordialog.h>
53#include <kiconloader.h> 53#include <kiconloader.h>
54#include <kemailsettings.h> 54#include <kemailsettings.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56 56
57#include <klineedit.h> 57#include <klineedit.h>
58 58
59 59
60#include "koprefs.h" 60#include "koprefs.h"
61 61
62#include "koprefsdialog.h" 62#include "koprefsdialog.h"
63//#include <kprefswidget.h> 63//#include <kprefswidget.h>
64 64
65 65
66KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) : 66KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) :
67 KPrefsDialog(KOPrefs::instance(),parent,name,true) 67 KPrefsDialog(KOPrefs::instance(),parent,name,true)
68{ 68{
69 69
70 setCaption( i18n("Settings - some need a restart (nr)")); 70 setCaption( i18n("Settings - some need a restart (nr)"));
71 setupGlobalTab(); 71 setupGlobalTab();
72 setupMainTab(); 72 setupMainTab();
73 setupMailTab();; 73 setupMailTab();;
74 setupFontsTab(); 74 setupFontsTab();
75 readConfig(); 75 readConfig();
76 76
77#if 0 77#if 0
78 78
79 setupMainTab(); 79 setupMainTab();
80 setupLocaleTab(); 80 setupLocaleTab();
81 setupTimeZoneTab(); 81 setupTimeZoneTab();
82 setupTimeTab(); 82 setupTimeTab();
83 setupLocaleDateTab(); 83 setupLocaleDateTab();
84 setupFontsTab(); 84 setupFontsTab();
85 setupColorsTab(); 85 setupColorsTab();
86 setupViewsTab(); 86 setupViewsTab();
87 //setupSyncTab(); 87 //setupSyncTab();
88 //setupSyncAlgTab(); 88 //setupSyncAlgTab();
89 //setupPrinterTab(); 89 //setupPrinterTab();
90 //setupGroupSchedulingTab(); 90 //setupGroupSchedulingTab();
91 //setupGroupAutomationTab(); 91 //setupGroupAutomationTab();
92#endif 92#endif
93} 93}
94 94
95#include "kpimglobalprefs.h" 95#include "kpimglobalprefs.h"
96 96
97KOPrefsDialog::~KOPrefsDialog() 97KOPrefsDialog::~KOPrefsDialog()
98{ 98{
99} 99}
100void KOPrefsDialog::setupGlobalTab() 100void KOPrefsDialog::setupGlobalTab()
101{ 101{
102 QFrame *topFrame = addPage(i18n("Global"),0,0); 102 QFrame *topFrame = addPage(i18n("Global"),0,0);
103 kdelibcfg = new KDEPIMConfigWidget( KPimGlobalPrefs::instance(), topFrame, "KCMKdeLibConfig" ); 103 kdelibcfg = new KDEPIMConfigWidget( KPimGlobalPrefs::instance(), topFrame, "KCMKdeLibConfig" );
104 QVBoxLayout *topLayout = new QVBoxLayout(topFrame); 104 QVBoxLayout *topLayout = new QVBoxLayout(topFrame);
105 topLayout->addWidget( kdelibcfg ); 105 topLayout->addWidget( kdelibcfg );
106 106
107 107
108} 108}
109void KOPrefsDialog::setupMainTab() 109void KOPrefsDialog::setupMainTab()
110{ 110{
111 QFrame *topFrame = addPage(i18n("General"),0,0); 111 QFrame *topFrame = addPage(i18n("General"),0,0);
112 112
113 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 113 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
114 topLayout->setSpacing(spacingHint()); 114 topLayout->setSpacing(spacingHint());
115 topLayout->setMargin(marginHint()); 115 topLayout->setMargin(marginHint());
116 116
117 117
118 mNameEdit = new QLineEdit(topFrame); 118 mNameEdit = new QLineEdit(topFrame);
119 mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame); 119 mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame);
120 topLayout->addWidget(mNameLabel,0,0); 120 topLayout->addWidget(mNameLabel,0,0);
121 topLayout->addWidget(mNameEdit,0,1); 121 topLayout->addWidget(mNameEdit,0,1);
122 122
123 mEmailEdit = new QLineEdit(topFrame); 123 mEmailEdit = new QLineEdit(topFrame);
124 mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); 124 mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame);
125 topLayout->addWidget(mEmailLabel,1,0); 125 topLayout->addWidget(mEmailLabel,1,0);
126 topLayout->addWidget(mEmailEdit,1,1); 126 topLayout->addWidget(mEmailEdit,1,1);
127 QLabel *lab = new QLabel( i18n("HINT: Separate multiple\neMail addresses by \";\""), topFrame); 127 QLabel *lab = new QLabel( i18n("HINT: Separate multiple\neMail addresses by \";\""), topFrame);
128 topLayout->addMultiCellWidget(lab,2,2,0,1); 128 topLayout->addMultiCellWidget(lab,2,2,0,1);
129 KPrefsDialogWidBool* ttt = addWidBool(i18n("Ignore above settings and\nuse KA/Pi \"Who am I\" instead!"), 129 KPrefsDialogWidBool* ttt = addWidBool(i18n("Ignore above settings and\nuse KA/Pi \"Who am I\" instead!"),
130 &(KOPrefs::instance()->mUseKapi),topFrame); 130 &(KOPrefs::instance()->mUseKapi),topFrame);
131 topLayout->addMultiCellWidget(ttt->checkBox(),3,3,0,1); 131 topLayout->addMultiCellWidget(ttt->checkBox(),3,3,0,1);
132} 132}
133 133
134void KOPrefsDialog::setupMailTab() 134void KOPrefsDialog::setupMailTab()
135{ 135{
136 QFrame *topFrame = addPage(i18n("Mail"),0,0); 136 QFrame *topFrame = addPage(i18n("Mail"),0,0);
137 137
138 QGridLayout *topLayout = new QGridLayout(topFrame,4,2); 138 QGridLayout *topLayout = new QGridLayout(topFrame,4,2);
139 topLayout->setSpacing(spacingHint()); 139 topLayout->setSpacing(spacingHint());
140 topLayout->setMargin(marginHint()); 140 topLayout->setMargin(marginHint());
141 141
142 KPrefsDialogWidBool* ttt = addWidBool(i18n("View mail as html"), 142 KPrefsDialogWidBool* ttt = addWidBool(i18n("View mail as html"),
143 &(KOPrefs::instance()->mViewAsHtml),topFrame); 143 &(KOPrefs::instance()->mViewAsHtml),topFrame);
144 topLayout->addMultiCellWidget(ttt->checkBox(),0,0,0,1); 144 topLayout->addMultiCellWidget(ttt->checkBox(),0,0,0,1);
145 145
146 146
147 ttt = addWidBool(i18n("Send mails later"), 147 ttt = addWidBool(i18n("Send mails later"),
148 &(KOPrefs::instance()->mSendLater),topFrame); 148 &(KOPrefs::instance()->mSendLater),topFrame);
149 topLayout->addMultiCellWidget(ttt->checkBox(),1,1,0,1); 149 topLayout->addMultiCellWidget(ttt->checkBox(),1,1,0,1);
150 /*
150 mCodecEdit = new QLineEdit(topFrame); 151 mCodecEdit = new QLineEdit(topFrame);
151 topLayout->addMultiCellWidget( new QLabel(mCodecEdit, i18n("User defined codec for new mails:"), topFrame),2,2,0,1); 152 topLayout->addMultiCellWidget( new QLabel(mCodecEdit, i18n("User defined codec for new mails:"), topFrame),2,2,0,1);
152 topLayout->addMultiCellWidget(mCodecEdit,3,3,0,1); 153 topLayout->addMultiCellWidget(mCodecEdit,3,3,0,1);
153 topLayout->addMultiCellWidget( new QLabel(0, i18n("Example: iso-8859-15"), topFrame),4,4,0,1); 154 topLayout->addMultiCellWidget( new QLabel(0, i18n("Example: iso-8859-15"), topFrame),4,4,0,1);
154 155 */
155} 156}
156void KOPrefsDialog::setupFontsTab() 157void KOPrefsDialog::setupFontsTab()
157{ 158{
158 159
159 QFrame *topFrame = addPage(i18n("Fonts"),0,0); 160 QFrame *topFrame = addPage(i18n("Fonts"),0,0);
160 // DesktopIcon("fonts",KIcon::SizeMedium)); 161 // DesktopIcon("fonts",KIcon::SizeMedium));
161 162
162 QGridLayout *topLayout = new QGridLayout(topFrame,7,3); 163 QGridLayout *topLayout = new QGridLayout(topFrame,7,3);
163 topLayout->setSpacing(1); 164 topLayout->setSpacing(1);
164 topLayout->setMargin(3); 165 topLayout->setMargin(3);
165 KPrefsDialogWidFont * tVFont; 166 KPrefsDialogWidFont * tVFont;
166 int i = 0; 167 int i = 0;
167 KPrefsDialogWidFont *timeLabelsFont = 168 KPrefsDialogWidFont *timeLabelsFont =
168 addWidFont(i18n("OK"),i18n("Application(nr)"), 169 addWidFont(i18n("OK"),i18n("Application(nr)"),
169 &(KOPrefs::instance()->mAppFont),topFrame); 170 &(KOPrefs::instance()->mAppFont),topFrame);
170 topLayout->addWidget(timeLabelsFont->label(),i,0); 171 topLayout->addWidget(timeLabelsFont->label(),i,0);
171 topLayout->addWidget(timeLabelsFont->preview(),i,1); 172 topLayout->addWidget(timeLabelsFont->preview(),i,1);
172 topLayout->addWidget(timeLabelsFont->button(),i,2); 173 topLayout->addWidget(timeLabelsFont->button(),i,2);
173 ++i; 174 ++i;
174 175
175 176
176 timeLabelsFont = 177 timeLabelsFont =
177 addWidFont(i18n("Dear Mr."),i18n("Compose mail:"), 178 addWidFont(i18n("Dear Mr."),i18n("Compose mail:"),
178 &(KOPrefs::instance()->mComposeFont),topFrame); 179 &(KOPrefs::instance()->mComposeFont),topFrame);
179 topLayout->addWidget(timeLabelsFont->label(),i,0); 180 topLayout->addWidget(timeLabelsFont->label(),i,0);
180 topLayout->addWidget(timeLabelsFont->preview(),i,1); 181 topLayout->addWidget(timeLabelsFont->preview(),i,1);
181 topLayout->addWidget(timeLabelsFont->button(),i,2); 182 topLayout->addWidget(timeLabelsFont->button(),i,2);
182 ++i; 183 ++i;
183 184
184 KPrefsDialogWidFont *timeBarFont = 185 KPrefsDialogWidFont *timeBarFont =
185 addWidFont(i18n("Hello"),i18n("Read mail:"), 186 addWidFont(i18n("Hello"),i18n("Read mail:"),
186 &(KOPrefs::instance()->mReadFont),topFrame); 187 &(KOPrefs::instance()->mReadFont),topFrame);
187 topLayout->addWidget(timeBarFont->label(),i,0); 188 topLayout->addWidget(timeBarFont->label(),i,0);
188 topLayout->addWidget(timeBarFont->preview(),i,1); 189 topLayout->addWidget(timeBarFont->preview(),i,1);
189 topLayout->addWidget(timeBarFont->button(),i,2); 190 topLayout->addWidget(timeBarFont->button(),i,2);
190 ++i; 191 ++i;
191 192
192 topLayout->setColStretch(1,1); 193 topLayout->setColStretch(1,1);
193 topLayout->setRowStretch(4,1); 194 topLayout->setRowStretch(4,1);
194 195
195} 196}
196void KOPrefsDialog::usrReadConfig() 197void KOPrefsDialog::usrReadConfig()
197{ 198{
198 199
199 mNameEdit->setText(KOPrefs::instance()->mName); 200 mNameEdit->setText(KOPrefs::instance()->mName);
200 mEmailEdit->setText(KOPrefs::instance()->mEmail); 201 mEmailEdit->setText(KOPrefs::instance()->mEmail);
201 mCodecEdit->setText(KOPrefs::instance()->mSendCodec); 202 //mCodecEdit->setText(KOPrefs::instance()->mSendCodec);
202 kdelibcfg->readConfig(); 203 kdelibcfg->readConfig();
203} 204}
204void KOPrefsDialog::usrWriteConfig() 205void KOPrefsDialog::usrWriteConfig()
205{ 206{
206 KOPrefs::instance()->mName = mNameEdit->text(); 207 KOPrefs::instance()->mName = mNameEdit->text();
207 KOPrefs::instance()->mEmail = mEmailEdit->text(); 208 KOPrefs::instance()->mEmail = mEmailEdit->text();
208 KOPrefs::instance()->mSendCodec = mCodecEdit->text(); 209 //KOPrefs::instance()->mSendCodec = mCodecEdit->text();
209 kdelibcfg->writeConfig(); 210 kdelibcfg->writeConfig();
210 211
211 212
212} 213}
213 214
214#if 0 215#if 0
215void KOPrefsDialog::setupLocaleDateTab() 216void KOPrefsDialog::setupLocaleDateTab()
216{ 217{
217QFrame *topFrame = addPage(i18n("Date Format"),0,0); 218QFrame *topFrame = addPage(i18n("Date Format"),0,0);
218 QGridLayout *topLayout = new QGridLayout(topFrame,3,2); 219 QGridLayout *topLayout = new QGridLayout(topFrame,3,2);
219 topLayout->setSpacing(spacingHint()); 220 topLayout->setSpacing(spacingHint());
220 topLayout->setMargin(marginHint()); 221 topLayout->setMargin(marginHint());
221 int iii = 0; 222 int iii = 0;
222 223
223 224
224 KPrefsWidRadios *syncPrefsGroup = 225 KPrefsWidRadios *syncPrefsGroup =
225 addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame); 226 addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame);
226 QString format; 227 QString format;
227 if ( QApplication::desktop()->width() < 480 ) 228 if ( QApplication::desktop()->width() < 480 )
228 format = "(%d.%m.%Y)"; 229 format = "(%d.%m.%Y)";
229 else 230 else
230 format = "(%d.%m.%Y|%A %d %B %Y)"; 231 format = "(%d.%m.%Y|%A %d %B %Y)";
231 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); 232 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format));
232 if ( QApplication::desktop()->width() < 480 ) 233 if ( QApplication::desktop()->width() < 480 )
233 format = "(%m.%d.%Y)"; 234 format = "(%m.%d.%Y)";
234 else 235 else
235 format = "(%m.%d.%Y|%A %B %d %Y)"; 236 format = "(%m.%d.%Y|%A %B %d %Y)";
236 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); 237 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format));
237 if ( QApplication::desktop()->width() < 480 ) 238 if ( QApplication::desktop()->width() < 480 )
238 format = "(%Y-%m-%d)"; 239 format = "(%Y-%m-%d)";
239 else 240 else
240 format = "(%Y-%m-%d|%A %Y %B %d)"; 241 format = "(%Y-%m-%d|%A %Y %B %d)";
241 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); 242 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format));
242 syncPrefsGroup->addRadio(i18n("User defined")); 243 syncPrefsGroup->addRadio(i18n("User defined"));
243 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 244 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
244 ++iii; 245 ++iii;
245 ++iii; 246 ++iii;
246 QLabel * lab; 247 QLabel * lab;
247 mUserDateFormatLong = new QLineEdit(topFrame); 248 mUserDateFormatLong = new QLineEdit(topFrame);
248 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame); 249 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame);
249 topLayout->addWidget(lab ,iii,0); 250 topLayout->addWidget(lab ,iii,0);
250 topLayout->addWidget(mUserDateFormatLong,iii,1); 251 topLayout->addWidget(mUserDateFormatLong,iii,1);
251 ++iii; 252 ++iii;
252 mUserDateFormatShort = new QLineEdit(topFrame); 253 mUserDateFormatShort = new QLineEdit(topFrame);
253 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame); 254 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame);
254 topLayout->addWidget(lab ,iii,0); 255 topLayout->addWidget(lab ,iii,0);
255 topLayout->addWidget(mUserDateFormatShort,iii,1); 256 topLayout->addWidget(mUserDateFormatShort,iii,1);
256 ++iii; 257 ++iii;
257 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame); 258 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame);
258 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 259 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
259 ++iii; 260 ++iii;
260 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame); 261 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame);
261 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 262 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
262 ++iii; 263 ++iii;
263 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame); 264 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame);
264 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 265 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
265 ++iii; 266 ++iii;
266 267
267} 268}
268 269
269void KOPrefsDialog::setupLocaleTab() 270void KOPrefsDialog::setupLocaleTab()
270{ 271{
271 QFrame *topFrame = addPage(i18n("Locale"),0,0); 272 QFrame *topFrame = addPage(i18n("Locale"),0,0);
272 QGridLayout *topLayout = new QGridLayout(topFrame,4,2); 273 QGridLayout *topLayout = new QGridLayout(topFrame,4,2);
273 topLayout->setSpacing(spacingHint()); 274 topLayout->setSpacing(spacingHint());
274 topLayout->setMargin(marginHint()); 275 topLayout->setMargin(marginHint());
275 int iii = 0; 276 int iii = 0;
276 KPrefsWidRadios *syncPrefsGroup = 277 KPrefsWidRadios *syncPrefsGroup =
277 addWidRadios(i18n("Language:(needs restart)"),&(KOPrefs::instance()->mPreferredLanguage),topFrame); 278 addWidRadios(i18n("Language:(needs restart)"),&(KOPrefs::instance()->mPreferredLanguage),topFrame);
278 syncPrefsGroup->addRadio(i18n("English")); 279 syncPrefsGroup->addRadio(i18n("English"));
279 syncPrefsGroup->addRadio(i18n("German")); 280 syncPrefsGroup->addRadio(i18n("German"));
280 syncPrefsGroup->addRadio(i18n("French")); 281 syncPrefsGroup->addRadio(i18n("French"));
281 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)")); 282 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)"));
282 if ( QApplication::desktop()->width() < 300 ) 283 if ( QApplication::desktop()->width() < 300 )
283 ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); 284 ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical);
284 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 285 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
285 ++iii; 286 ++iii;
286 287
287 syncPrefsGroup = 288 syncPrefsGroup =
288 addWidRadios(i18n("Time Format(nr):"),&(KOPrefs::instance()->mPreferredTime),topFrame); 289 addWidRadios(i18n("Time Format(nr):"),&(KOPrefs::instance()->mPreferredTime),topFrame);
289 if ( QApplication::desktop()->width() > 300 ) 290 if ( QApplication::desktop()->width() > 300 )
290 syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); 291 syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical);
291 syncPrefsGroup->addRadio(i18n("24:00")); 292 syncPrefsGroup->addRadio(i18n("24:00"));
292 syncPrefsGroup->addRadio(i18n("12:00am")); 293 syncPrefsGroup->addRadio(i18n("12:00am"));
293 syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); 294 syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical);
294 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 295 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
295 ++iii; 296 ++iii;
296 KPrefsDialogWidBool *sb; 297 KPrefsDialogWidBool *sb;
297 if ( QApplication::desktop()->width() < 300 ) { 298 if ( QApplication::desktop()->width() < 300 ) {
298 sb = 299 sb =
299 addWidBool(i18n("Week starts on Sunday"), 300 addWidBool(i18n("Week starts on Sunday"),
300 &(KOPrefs::instance()->mWeekStartsOnSunday),topFrame); 301 &(KOPrefs::instance()->mWeekStartsOnSunday),topFrame);
301 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 302 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
302 ++iii; 303 ++iii;
303 sb = 304 sb =
304 addWidBool(i18n("Use short date in (WN/E) view"), 305 addWidBool(i18n("Use short date in (WN/E) view"),
305 &(KOPrefs::instance()->mShortDateInViewer),topFrame); 306 &(KOPrefs::instance()->mShortDateInViewer),topFrame);
306 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 307 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
307 } 308 }
308 else { 309 else {
309 QWidget * hb = new QWidget( topFrame ); 310 QWidget * hb = new QWidget( topFrame );
310 QHBoxLayout *hbLayout = new QHBoxLayout(hb); 311 QHBoxLayout *hbLayout = new QHBoxLayout(hb);
311 sb = 312 sb =
312 addWidBool(i18n("Week starts on Sunday"), 313 addWidBool(i18n("Week starts on Sunday"),
313 &(KOPrefs::instance()->mWeekStartsOnSunday),hb); 314 &(KOPrefs::instance()->mWeekStartsOnSunday),hb);
314 hbLayout->addWidget(sb->checkBox() ); 315 hbLayout->addWidget(sb->checkBox() );
315 sb = 316 sb =
316 addWidBool(i18n("Use short date in (WN/E) view"), 317 addWidBool(i18n("Use short date in (WN/E) view"),
317 &(KOPrefs::instance()->mShortDateInViewer),hb); 318 &(KOPrefs::instance()->mShortDateInViewer),hb);
318 hbLayout->addWidget(sb->checkBox() ); 319 hbLayout->addWidget(sb->checkBox() );
319 topLayout->addMultiCellWidget(hb, iii,iii,0,1); 320 topLayout->addMultiCellWidget(hb, iii,iii,0,1);
320 321
321 } 322 }
322 //#ifndef DESKTOP_VERSION 323 //#ifndef DESKTOP_VERSION
323#if 0 324#if 0
324 ++iii; 325 ++iii;
325 sb = 326 sb =
326 addWidBool(i18n("Quick load/save (w/o Unicode)"), 327 addWidBool(i18n("Quick load/save (w/o Unicode)"),
327 &(KOPrefs::instance()->mUseQuicksave),topFrame); 328 &(KOPrefs::instance()->mUseQuicksave),topFrame);
328 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 329 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
329#endif 330#endif
330} 331}
331void KOPrefsDialog::showSyncPage() 332void KOPrefsDialog::showSyncPage()
332{ 333{
333 showPage ( 2 ) ; 334 showPage ( 2 ) ;
334 335
335} 336}
336void KOPrefsDialog::setupSyncAlgTab() 337void KOPrefsDialog::setupSyncAlgTab()
337{ 338{
338#if 0 339#if 0
339 QLabel * lab; 340 QLabel * lab;
340 QFrame *topFrame = addPage(i18n("Sync Prefs"),0,0); 341 QFrame *topFrame = addPage(i18n("Sync Prefs"),0,0);
341 mSetupSyncAlgTab = topFrame; 342 mSetupSyncAlgTab = topFrame;
342 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 343 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
343 topLayout->setSpacing(spacingHint()); 344 topLayout->setSpacing(spacingHint());
344 topLayout->setMargin(marginHint()); 345 topLayout->setMargin(marginHint());
345 int iii = 0; 346 int iii = 0;
346 347
347 KPrefsDialogWidBool *sb = 348 KPrefsDialogWidBool *sb =
348 addWidBool(i18n("Ask for preferences before syncing"), 349 addWidBool(i18n("Ask for preferences before syncing"),
349 &(KOPrefs::instance()->mAskForPreferences),topFrame); 350 &(KOPrefs::instance()->mAskForPreferences),topFrame);
350 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 351 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
351 352
352 ++iii; 353 ++iii;
353 354
354 KPrefsWidRadios *syncPrefsGroup = 355 KPrefsWidRadios *syncPrefsGroup =
355 addWidRadios(i18n("Sync preferences:"),&(KOPrefs::instance()->mSyncAlgoPrefs), 356 addWidRadios(i18n("Sync preferences:"),&(KOPrefs::instance()->mSyncAlgoPrefs),
356 topFrame); 357 topFrame);
357 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 358 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
358 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 359 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
359 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 360 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
360 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 361 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
361 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 362 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
362 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 363 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
363 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 364 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
364 ++iii; 365 ++iii;
365 sb = 366 sb =
366 addWidBool(i18n("Show summary after syncing"), 367 addWidBool(i18n("Show summary after syncing"),
367 &(KOPrefs::instance()->mShowSyncSummary),topFrame); 368 &(KOPrefs::instance()->mShowSyncSummary),topFrame);
368 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 369 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
369 370
370 ++iii; 371 ++iii;
371#endif 372#endif
372 373
373 374
374 375
375} 376}
376 377
377 378
378void KOPrefsDialog::setupSyncTab() 379void KOPrefsDialog::setupSyncTab()
379{ 380{
380#if 0 381#if 0
381 QLabel * lab; 382 QLabel * lab;
382 QFrame *topFrame = addPage(i18n("Sync Network"),0,0); 383 QFrame *topFrame = addPage(i18n("Sync Network"),0,0);
383 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 384 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
384 topLayout->setSpacing(spacingHint()); 385 topLayout->setSpacing(spacingHint());
385 topLayout->setMargin(marginHint()); 386 topLayout->setMargin(marginHint());
386 lab = new QLabel(i18n("Remote syncing (via ssh/scp)\nnetwork settings "), topFrame); 387 lab = new QLabel(i18n("Remote syncing (via ssh/scp)\nnetwork settings "), topFrame);
387 int iii = 0; 388 int iii = 0;
388 topLayout->addMultiCellWidget(lab , iii,iii,0,1); 389 topLayout->addMultiCellWidget(lab , iii,iii,0,1);
389 ++iii; 390 ++iii;
390 391
391 mRemoteIPEdit = new QLineEdit(topFrame); 392 mRemoteIPEdit = new QLineEdit(topFrame);
392 lab = new QLabel(mRemoteIPEdit, i18n("Remote IP:"), topFrame); 393 lab = new QLabel(mRemoteIPEdit, i18n("Remote IP:"), topFrame);
393 topLayout->addWidget(lab ,iii,0); 394 topLayout->addWidget(lab ,iii,0);
394 topLayout->addWidget(mRemoteIPEdit,iii,1); 395 topLayout->addWidget(mRemoteIPEdit,iii,1);
395 ++iii; 396 ++iii;
396 mRemoteUser = new QLineEdit(topFrame); 397 mRemoteUser = new QLineEdit(topFrame);
397 lab = new QLabel(mRemoteUser, i18n("Remote user:"), topFrame); 398 lab = new QLabel(mRemoteUser, i18n("Remote user:"), topFrame);
398 topLayout->addWidget(lab ,iii,0); 399 topLayout->addWidget(lab ,iii,0);
399 topLayout->addWidget(mRemoteUser, iii,1); 400 topLayout->addWidget(mRemoteUser, iii,1);
400 ++iii; 401 ++iii;
diff --git a/kmicromail/libmailwrapper/generatemail.cpp b/kmicromail/libmailwrapper/generatemail.cpp
index 32311d7..2d213fe 100644
--- a/kmicromail/libmailwrapper/generatemail.cpp
+++ b/kmicromail/libmailwrapper/generatemail.cpp
@@ -1,461 +1,467 @@
1#include "generatemail.h" 1#include "generatemail.h"
2#include "mailwrapper.h" 2#include "mailwrapper.h"
3 3
4#include <libetpan/libetpan.h> 4#include <libetpan/libetpan.h>
5 5
6//#include <qt.h> 6//#include <qt.h>
7 7
8#include <stdlib.h> 8#include <stdlib.h>
9#include <qfileinfo.h> 9#include <qfileinfo.h>
10 10
11using namespace Opie::Core; 11using namespace Opie::Core;
12const char* Generatemail::USER_AGENT="KOpieMail 33 1/3"; 12const char* Generatemail::USER_AGENT="KOpieMail 33 1/3";
13 13
14Generatemail::Generatemail() 14Generatemail::Generatemail()
15{ 15{
16 mCharset = "iso-8859-1";
16} 17}
17 18
18Generatemail::~Generatemail() 19Generatemail::~Generatemail()
19{ 20{
20} 21}
21 22
22void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) { 23void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) {
23 clistiter *it, *it2; 24 clistiter *it, *it2;
24 25
25 for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { 26 for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) {
26 mailimf_address *addr; 27 mailimf_address *addr;
27 addr = (mailimf_address *) it->data; 28 addr = (mailimf_address *) it->data;
28 29
29 if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { 30 if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) {
30 esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); 31 esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL );
31 } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { 32 } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) {
32 clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; 33 clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list;
33 for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { 34 for ( it2 = clist_begin( l ); it2; it2 = it2->next ) {
34 mailimf_mailbox *mbox; 35 mailimf_mailbox *mbox;
35 mbox = (mailimf_mailbox *) it2->data; 36 mbox = (mailimf_mailbox *) it2->data;
36 esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); 37 esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL );
37 } 38 }
38 } 39 }
39 } 40 }
40} 41}
41 42
42char *Generatemail::getFrom( mailimf_field *ffrom) { 43char *Generatemail::getFrom( mailimf_field *ffrom) {
43 char *from = NULL; 44 char *from = NULL;
44 if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM) 45 if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM)
45 && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) { 46 && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) {
46 clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list; 47 clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list;
47 clistiter *it; 48 clistiter *it;
48 for ( it = clist_begin( cl ); it; it = it->next ) { 49 for ( it = clist_begin( cl ); it; it = it->next ) {
49 mailimf_mailbox *mb = (mailimf_mailbox *) it->data; 50 mailimf_mailbox *mb = (mailimf_mailbox *) it->data;
50 from = strdup( mb->mb_addr_spec ); 51 from = strdup( mb->mb_addr_spec );
51 } 52 }
52 } 53 }
53 54
54 return from; 55 return from;
55} 56}
56 57
57char *Generatemail::getFrom( mailmime *mail ) { 58char *Generatemail::getFrom( mailmime *mail ) {
58 /* no need to delete - its just a pointer to structure content */ 59 /* no need to delete - its just a pointer to structure content */
59 mailimf_field *ffrom = 0; 60 mailimf_field *ffrom = 0;
60 ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); 61 ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM );
61 return getFrom(ffrom); 62 return getFrom(ffrom);
62} 63}
63 64
64mailimf_field *Generatemail::getField( mailimf_fields *fields, int type ) { 65mailimf_field *Generatemail::getField( mailimf_fields *fields, int type ) {
65 mailimf_field *field; 66 mailimf_field *field;
66 clistiter *it; 67 clistiter *it;
67 68
68 it = clist_begin( fields->fld_list ); 69 it = clist_begin( fields->fld_list );
69 while ( it ) { 70 while ( it ) {
70 field = (mailimf_field *) it->data; 71 field = (mailimf_field *) it->data;
71 if ( field->fld_type == type ) { 72 if ( field->fld_type == type ) {
72 return field; 73 return field;
73 } 74 }
74 it = it->next; 75 it = it->next;
75 } 76 }
76 77
77 return NULL; 78 return NULL;
78} 79}
79 80
80mailimf_address_list *Generatemail::parseAddresses(const QString&addr ) { 81mailimf_address_list *Generatemail::parseAddresses(const QString&addr ) {
81 mailimf_address_list *addresses; 82 mailimf_address_list *addresses;
82 83
83 if ( addr.isEmpty() ) 84 if ( addr.isEmpty() )
84 return NULL; 85 return NULL;
85 86
86 addresses = mailimf_address_list_new_empty(); 87 addresses = mailimf_address_list_new_empty();
87 88
88 bool literal_open = false; 89 bool literal_open = false;
89 unsigned int startpos = 0; 90 unsigned int startpos = 0;
90 QStringList list; 91 QStringList list;
91 QString s; 92 QString s;
92 unsigned int i = 0; 93 unsigned int i = 0;
93 for (; i < addr.length();++i) { 94 for (; i < addr.length();++i) {
94 switch (addr[i]) { 95 switch (addr[i]) {
95 case '\"': 96 case '\"':
96 literal_open = !literal_open; 97 literal_open = !literal_open;
97 break; 98 break;
98 case ',': 99 case ',':
99 if (!literal_open) { 100 if (!literal_open) {
100 s = addr.mid(startpos,i-startpos); 101 s = addr.mid(startpos,i-startpos);
101 if (!s.isEmpty()) { 102 if (!s.isEmpty()) {
102 list.append(s); 103 list.append(s);
103 } 104 }
104 // !!!! this is a MUST BE! 105 // !!!! this is a MUST BE!
105 startpos = ++i; 106 startpos = ++i;
106 } 107 }
107 break; 108 break;
108 default: 109 default:
109 break; 110 break;
110 } 111 }
111 } 112 }
112 s = addr.mid(startpos,i-startpos); 113 s = addr.mid(startpos,i-startpos);
113 if (!s.isEmpty()) { 114 if (!s.isEmpty()) {
114 list.append(s); 115 list.append(s);
115 } 116 }
116 QStringList::Iterator it; 117 QStringList::Iterator it;
117 for ( it = list.begin(); it != list.end(); it++ ) { 118 for ( it = list.begin(); it != list.end(); it++ ) {
118 int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); 119 int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() );
119 if ( err != MAILIMF_NO_ERROR ) { 120 if ( err != MAILIMF_NO_ERROR ) {
120 qDebug(" Error parsing"); // *it 121 qDebug(" Error parsing"); // *it
121 } else { 122 } else {
122 } 123 }
123 } 124 }
124 return addresses; 125 return addresses;
125} 126}
126 127
127mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) { 128mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) {
128 mailmime * filePart = 0; 129 mailmime * filePart = 0;
129 mailmime_fields * fields = 0; 130 mailmime_fields * fields = 0;
130 mailmime_content * content = 0; 131 mailmime_content * content = 0;
131 mailmime_parameter * param = 0; 132 mailmime_parameter * param = 0;
132 char*name = 0; 133 char*name = 0;
133 char*file = 0; 134 char*file = 0;
134 int err; 135 int err;
135 int pos = filename.findRev( '/' ); 136 int pos = filename.findRev( '/' );
136 137
137 if (filename.length()>0) { 138 if (filename.length()>0) {
138 QString tmp = filename.right( filename.length() - ( pos + 1 ) ); 139 QString tmp = filename.right( filename.length() - ( pos + 1 ) );
139 name = strdup( tmp.latin1() ); // just filename 140 name = strdup( tmp.latin1() ); // just filename
140 file = strdup( filename.latin1() ); // full name with path 141 file = strdup( filename.latin1() ); // full name with path
141 } 142 }
142 143
143 int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; 144 int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT;
144 int mechanism = MAILMIME_MECHANISM_BASE64; 145 int mechanism = MAILMIME_MECHANISM_BASE64;
145 146
146 if ( mimetype.startsWith( "text/" ) ) { 147 if ( mimetype.startsWith( "text/" ) ) {
147 param = mailmime_parameter_new( strdup( "charset" ), 148 param = mailmime_parameter_new( strdup( "charset" ),
148 strdup( "iso-8859-1" ) ); 149 strdup( mCharset.latin1() ) );
149 mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; 150 mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
150 } 151 }
151 152
152 fields = mailmime_fields_new_filename( 153 fields = mailmime_fields_new_filename(
153 disptype, name, 154 disptype, name,
154 mechanism ); 155 mechanism );
155 content = mailmime_content_new_with_str( (char*)mimetype.latin1() ); 156 content = mailmime_content_new_with_str( (char*)mimetype.latin1() );
156 if (content!=0 && fields != 0) { 157 if (content!=0 && fields != 0) {
157 if (param) { 158 if (param) {
158 clist_append(content->ct_parameters,param); 159 clist_append(content->ct_parameters,param);
159 param = 0; 160 param = 0;
160 } 161 }
161 if (filename.length()>0) { 162 if (filename.length()>0) {
162 QFileInfo f(filename); 163 QFileInfo f(filename);
163 param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); 164 param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1()));
164 clist_append(content->ct_parameters,param); 165 clist_append(content->ct_parameters,param);
165 param = 0; 166 param = 0;
166 } 167 }
167 filePart = mailmime_new_empty( content, fields ); 168 filePart = mailmime_new_empty( content, fields );
168 } 169 }
169 if (filePart) { 170 if (filePart) {
170 if (filename.length()>0) { 171 if (filename.length()>0) {
171 err = mailmime_set_body_file( filePart, file ); 172 err = mailmime_set_body_file( filePart, file );
172 } else { 173 } else {
173 err = mailmime_set_body_text(filePart,strdup( TextContent.utf8()),TextContent.utf8().length()); 174 err = mailmime_set_body_text(filePart,strdup( TextContent.utf8().data()),TextContent.utf8().length());
175 //err = mailmime_set_body_text(filePart,strdup( TextContent.latin1()),TextContent.length());
174 } 176 }
175 if (err != MAILIMF_NO_ERROR) { 177 if (err != MAILIMF_NO_ERROR) {
176 qDebug("Error setting body with file "); 178 qDebug("Error setting body with file ");
177 mailmime_free( filePart ); 179 mailmime_free( filePart );
178 filePart = 0; 180 filePart = 0;
179 } 181 }
180 } 182 }
181 183
182 if (!filePart) { 184 if (!filePart) {
183 if ( param != NULL ) { 185 if ( param != NULL ) {
184 mailmime_parameter_free( param ); 186 mailmime_parameter_free( param );
185 } 187 }
186 if (content) { 188 if (content) {
187 mailmime_content_free( content ); 189 mailmime_content_free( content );
188 } 190 }
189 if (fields) { 191 if (fields) {
190 mailmime_fields_free( fields ); 192 mailmime_fields_free( fields );
191 } else { 193 } else {
192 if (name) { 194 if (name) {
193 free( name ); 195 free( name );
194 } 196 }
195 if (file) { 197 if (file) {
196 free( file ); 198 free( file );
197 } 199 }
198 } 200 }
199 } 201 }
200 return filePart; // Success :) 202 return filePart; // Success :)
201 203
202} 204}
203 205
204void Generatemail::addFileParts( mailmime *message,const QList<Attachment>&files ) { 206void Generatemail::addFileParts( mailmime *message,const QList<Attachment>&files ) {
205 const Attachment *it; 207 const Attachment *it;
206 unsigned int count = files.count(); 208 unsigned int count = files.count();
207 for ( unsigned int i = 0; i < count; ++i ) { 209 for ( unsigned int i = 0; i < count; ++i ) {
208 mailmime *filePart; 210 mailmime *filePart;
209 int err; 211 int err;
210 it = ((QList<Attachment>)files).at(i); 212 it = ((QList<Attachment>)files).at(i);
211 213
212 filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); 214 filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" );
213 if ( filePart == NULL ) { 215 if ( filePart == NULL ) {
214 continue; 216 continue;
215 } 217 }
216 err = mailmime_smart_add_part( message, filePart ); 218 err = mailmime_smart_add_part( message, filePart );
217 if ( err != MAILIMF_NO_ERROR ) { 219 if ( err != MAILIMF_NO_ERROR ) {
218 mailmime_free( filePart ); 220 mailmime_free( filePart );
219 } 221 }
220 } 222 }
221} 223}
222 224
223mailmime *Generatemail::buildTxtPart(const QString&str ) { 225mailmime *Generatemail::buildTxtPart(const QString&str ) {
224 mailmime *txtPart; 226 mailmime *txtPart;
225 mailmime_fields *fields; 227 mailmime_fields *fields;
226 mailmime_content *content; 228 mailmime_content *content;
227 mailmime_parameter *param; 229 mailmime_parameter *param;
228 int err; 230 int err;
229 QCString __str; 231 QCString __str;
232 //qDebug(" Generatemail::buildTxtPart %s", str.latin1());
230 param = mailmime_parameter_new( strdup( "charset" ), 233 param = mailmime_parameter_new( strdup( "charset" ),
231 strdup( "iso-8859-1" ) ); 234 strdup( mCharset.latin1() ) );
232 if ( param == NULL ) 235 if ( param == NULL )
233 goto err_free; 236 goto err_free;
234 237
235 content = mailmime_content_new_with_str( "text/plain" ); 238 content = mailmime_content_new_with_str( "text/plain" );
236 if ( content == NULL ) 239 if ( content == NULL )
237 goto err_free_param; 240 goto err_free_param;
238 241
239 err = clist_append( content->ct_parameters, param ); 242 err = clist_append( content->ct_parameters, param );
240 if ( err != MAILIMF_NO_ERROR ) 243 if ( err != MAILIMF_NO_ERROR )
241 goto err_free_content; 244 goto err_free_content;
242 245
243 fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); 246 fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT);
244 if ( fields == NULL ) 247 if ( fields == NULL )
245 goto err_free_content; 248 goto err_free_content;
246 249
247 txtPart = mailmime_new_empty( content, fields ); 250 txtPart = mailmime_new_empty( content, fields );
248 if ( txtPart == NULL ) 251 if ( txtPart == NULL )
249 goto err_free_fields; 252 goto err_free_fields;
250 { 253 {
251 __str = str.utf8(); 254 //__str = str.utf8();
252 err = mailmime_set_body_text( txtPart, __str.data(), __str.length() ); 255 __str = QCString (str.latin1());
256 err = mailmime_set_body_text( txtPart, strdup(__str.data()), __str.length() );
253 } 257 }
254 if ( err != MAILIMF_NO_ERROR ) 258 if ( err != MAILIMF_NO_ERROR )
255 goto err_free_txtPart; 259 goto err_free_txtPart;
256 260
257 return txtPart; // Success :) 261 return txtPart; // Success :)
258 262
259err_free_txtPart: 263err_free_txtPart:
260 mailmime_free( txtPart ); 264 mailmime_free( txtPart );
261err_free_fields: 265err_free_fields:
262 mailmime_fields_free( fields ); 266 mailmime_fields_free( fields );
263err_free_content: 267err_free_content:
264 mailmime_content_free( content ); 268 mailmime_content_free( content );
265err_free_param: 269err_free_param:
266 mailmime_parameter_free( param ); 270 mailmime_parameter_free( param );
267err_free: 271err_free:
268 ; 272 ;
269 273
270 return NULL; // Error :( 274 return NULL; // Error :(
271} 275}
272 276
273mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { 277mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) {
274 return mailimf_mailbox_new( strdup( name.latin1() ), 278 return mailimf_mailbox_new( strdup( name.latin1() ),
275 strdup( mail.latin1() ) ); 279 strdup( mail.latin1() ) );
276} 280}
277 281
278mailimf_fields *Generatemail::createImfFields(const Opie::Core::OSmartPointer<Mail>&mail ) 282mailimf_fields *Generatemail::createImfFields(const Opie::Core::OSmartPointer<Mail>&mail )
279{ 283{
280 mailimf_fields *fields = NULL; 284 mailimf_fields *fields = NULL;
281 mailimf_field *xmailer = NULL; 285 mailimf_field *xmailer = NULL;
282 mailimf_mailbox *sender=0,*fromBox=0; 286 mailimf_mailbox *sender=0,*fromBox=0;
283 mailimf_mailbox_list *from=0; 287 mailimf_mailbox_list *from=0;
284 mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; 288 mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0;
285 clist*in_reply_to = 0; 289 clist*in_reply_to = 0;
286 char *subject = strdup( mail->getSubject().latin1() ); 290 char *subject = strdup( mail->getSubject().latin1() );
287 int err; 291 int err;
288 int res = 1; 292 int res = 1;
289 293
290 sender = newMailbox( mail->getName(), mail->getMail() ); 294 sender = newMailbox( mail->getName(), mail->getMail() );
291 if ( sender == NULL ) { 295 if ( sender == NULL ) {
292 res = 0; 296 res = 0;
293 } 297 }
294 298
295 if (res) { 299 if (res) {
296 fromBox = newMailbox( mail->getName(), mail->getMail() ); 300 fromBox = newMailbox( mail->getName(), mail->getMail() );
297 } 301 }
298 if ( fromBox == NULL ) { 302 if ( fromBox == NULL ) {
299 res = 0; 303 res = 0;
300 } 304 }
301 305
302 if (res) { 306 if (res) {
303 from = mailimf_mailbox_list_new_empty(); 307 from = mailimf_mailbox_list_new_empty();
304 } 308 }
305 if ( from == NULL ) { 309 if ( from == NULL ) {
306 res = 0; 310 res = 0;
307 } 311 }
308 312
309 if (res && from) { 313 if (res && from) {
310 err = mailimf_mailbox_list_add( from, fromBox ); 314 err = mailimf_mailbox_list_add( from, fromBox );
311 if ( err != MAILIMF_NO_ERROR ) { 315 if ( err != MAILIMF_NO_ERROR ) {
312 res = 0; 316 res = 0;
313 } 317 }
314 } 318 }
315 319
316 if (res) to = parseAddresses( mail->getTo() ); 320 if (res) to = parseAddresses( mail->getTo() );
317 if (res) cc = parseAddresses( mail->getCC() ); 321 if (res) cc = parseAddresses( mail->getCC() );
318 if (res) bcc = parseAddresses( mail->getBCC() ); 322 if (res) bcc = parseAddresses( mail->getBCC() );
319 if (res) reply = parseAddresses( mail->getReply() ); 323 if (res) reply = parseAddresses( mail->getReply() );
320 324
321 if (res && mail->Inreply().count()>0) { 325 if (res && mail->Inreply().count()>0) {
322 in_reply_to = clist_new(); 326 in_reply_to = clist_new();
323 char*c_reply; 327 char*c_reply;
324 unsigned int nsize = 0; 328 unsigned int nsize = 0;
325 for (QStringList::ConstIterator it=mail->Inreply().begin(); 329 for (QStringList::ConstIterator it=mail->Inreply().begin();
326 it != mail->Inreply().end();++it) { 330 it != mail->Inreply().end();++it) {
327 if ((*it).isEmpty()) 331 if ((*it).isEmpty())
328 continue; 332 continue;
329 QString h((*it)); 333 QString h((*it));
330 while (h.length()>0 && h[0]=='<') { 334 while (h.length()>0 && h[0]=='<') {
331 h.remove(0,1); 335 h.remove(0,1);
332 } 336 }
333 while (h.length()>0 && h[h.length()-1]=='>') { 337 while (h.length()>0 && h[h.length()-1]=='>') {
334 h.remove(h.length()-1,1); 338 h.remove(h.length()-1,1);
335 } 339 }
336 if (h.isEmpty()) continue; 340 if (h.isEmpty()) continue;
337 nsize = strlen(h.latin1()); 341 nsize = strlen(h.latin1());
338 /* yes! must be malloc! */ 342 /* yes! must be malloc! */
339 c_reply = (char*)malloc( (nsize+1)*sizeof(char)); 343 c_reply = (char*)malloc( (nsize+1)*sizeof(char));
340 memset(c_reply,0,nsize+1); 344 memset(c_reply,0,nsize+1);
341 memcpy(c_reply,h.latin1(),nsize); 345 memcpy(c_reply,h.latin1(),nsize);
342 clist_append(in_reply_to,c_reply); 346 clist_append(in_reply_to,c_reply);
343 } 347 }
344 } 348 }
345 349
346 if (res) { 350 if (res) {
347 fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, 351 fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc,
348 in_reply_to, NULL, subject ); 352 in_reply_to, NULL, subject );
349 if ( fields == NULL ) { 353 if ( fields == NULL ) {
350 res = 0; 354 res = 0;
351 } 355 }
352 } 356 }
353 if (res) xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), 357 if (res) xmailer = mailimf_field_new_custom( strdup( "User-Agent" ),
354 strdup( USER_AGENT ) ); 358 strdup( USER_AGENT ) );
355 if ( xmailer == NULL ) { 359 if ( xmailer == NULL ) {
356 res = 0; 360 res = 0;
357 } else { 361 } else {
358 err = mailimf_fields_add( fields, xmailer ); 362 err = mailimf_fields_add( fields, xmailer );
359 if ( err != MAILIMF_NO_ERROR ) { 363 if ( err != MAILIMF_NO_ERROR ) {
360 res = 0; 364 res = 0;
361 } 365 }
362 } 366 }
363 if (!res ) { 367 if (!res ) {
364 if (xmailer) { 368 if (xmailer) {
365 mailimf_field_free( xmailer ); 369 mailimf_field_free( xmailer );
366 xmailer = NULL; 370 xmailer = NULL;
367 } 371 }
368 if (fields) { 372 if (fields) {
369 mailimf_fields_free( fields ); 373 mailimf_fields_free( fields );
370 fields = NULL; 374 fields = NULL;
371 } else { 375 } else {
372 if (reply) 376 if (reply)
373 mailimf_address_list_free( reply ); 377 mailimf_address_list_free( reply );
374 if (bcc) 378 if (bcc)
375 mailimf_address_list_free( bcc ); 379 mailimf_address_list_free( bcc );
376 if (cc) 380 if (cc)
377 mailimf_address_list_free( cc ); 381 mailimf_address_list_free( cc );
378 if (to) 382 if (to)
379 mailimf_address_list_free( to ); 383 mailimf_address_list_free( to );
380 if (fromBox) { 384 if (fromBox) {
381 mailimf_mailbox_free( fromBox ); 385 mailimf_mailbox_free( fromBox );
382 } else if (from) { 386 } else if (from) {
383 mailimf_mailbox_list_free( from ); 387 mailimf_mailbox_list_free( from );
384 } 388 }
385 if (sender) { 389 if (sender) {
386 mailimf_mailbox_free( sender ); 390 mailimf_mailbox_free( sender );
387 } 391 }
388 if (subject) { 392 if (subject) {
389 free( subject ); 393 free( subject );
390 } 394 }
391 } 395 }
392 } 396 }
393 return fields; 397 return fields;
394} 398}
395 399
396mailmime *Generatemail::createMimeMail(const Opie::Core::OSmartPointer<Mail> &mail ) { 400mailmime *Generatemail::createMimeMail(const Opie::Core::OSmartPointer<Mail> &mail ) {
397 mailmime *message, *txtPart; 401 mailmime *message, *txtPart;
398 mailimf_fields *fields; 402 mailimf_fields *fields;
399 int err; 403 int err;
400 404
405 //LR disabled for now
406 //mCharset = mail->getCharset().lower();
401 fields = createImfFields( mail ); 407 fields = createImfFields( mail );
402 if ( fields == NULL ) 408 if ( fields == NULL )
403 goto err_free; 409 goto err_free;
404 410
405 message = mailmime_new_message_data( NULL ); 411 message = mailmime_new_message_data( NULL );
406 if ( message == NULL ) 412 if ( message == NULL )
407 goto err_free_fields; 413 goto err_free_fields;
408 414
409 mailmime_set_imf_fields( message, fields ); 415 mailmime_set_imf_fields( message, fields );
410 416
411 txtPart = buildTxtPart( mail->getMessage() ); 417 txtPart = buildTxtPart( mail->getMessage() );
412 418
413 if ( txtPart == NULL ) 419 if ( txtPart == NULL )
414 goto err_free_message; 420 goto err_free_message;
415 421
416 err = mailmime_smart_add_part( message, txtPart ); 422 err = mailmime_smart_add_part( message, txtPart );
417 if ( err != MAILIMF_NO_ERROR ) 423 if ( err != MAILIMF_NO_ERROR )
418 goto err_free_txtPart; 424 goto err_free_txtPart;
419 425
420 addFileParts( message, mail->getAttachments() ); 426 addFileParts( message, mail->getAttachments() );
421 427
422 return message; // Success :) 428 return message; // Success :)
423 429
424err_free_txtPart: 430err_free_txtPart:
425 mailmime_free( txtPart ); 431 mailmime_free( txtPart );
426err_free_message: 432err_free_message:
427 mailmime_free( message ); 433 mailmime_free( message );
428err_free_fields: 434err_free_fields:
429 mailimf_fields_free( fields ); 435 mailimf_fields_free( fields );
430err_free: 436err_free:
431 ; 437 ;
432 438
433 return NULL; // Error :( 439 return NULL; // Error :(
434} 440}
435 441
436clist *Generatemail::createRcptList( mailimf_fields *fields ) { 442clist *Generatemail::createRcptList( mailimf_fields *fields ) {
437 clist *rcptList; 443 clist *rcptList;
438 mailimf_field *field; 444 mailimf_field *field;
439 445
440 rcptList = esmtp_address_list_new(); 446 rcptList = esmtp_address_list_new();
441 447
442 field = getField( fields, MAILIMF_FIELD_TO ); 448 field = getField( fields, MAILIMF_FIELD_TO );
443 if ( field && (field->fld_type == MAILIMF_FIELD_TO) 449 if ( field && (field->fld_type == MAILIMF_FIELD_TO)
444 && field->fld_data.fld_to->to_addr_list ) { 450 && field->fld_data.fld_to->to_addr_list ) {
445 addRcpts( rcptList, field->fld_data.fld_to->to_addr_list ); 451 addRcpts( rcptList, field->fld_data.fld_to->to_addr_list );
446 } 452 }
447 453
448 field = getField( fields, MAILIMF_FIELD_CC ); 454 field = getField( fields, MAILIMF_FIELD_CC );
449 if ( field && (field->fld_type == MAILIMF_FIELD_CC) 455 if ( field && (field->fld_type == MAILIMF_FIELD_CC)
450 && field->fld_data.fld_cc->cc_addr_list ) { 456 && field->fld_data.fld_cc->cc_addr_list ) {
451 addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list ); 457 addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list );
452 } 458 }
453 459
454 field = getField( fields, MAILIMF_FIELD_BCC ); 460 field = getField( fields, MAILIMF_FIELD_BCC );
455 if ( field && (field->fld_type == MAILIMF_FIELD_BCC) 461 if ( field && (field->fld_type == MAILIMF_FIELD_BCC)
456 && field->fld_data.fld_bcc->bcc_addr_list ) { 462 && field->fld_data.fld_bcc->bcc_addr_list ) {
457 addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list ); 463 addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list );
458 } 464 }
459 465
460 return rcptList; 466 return rcptList;
461} 467}
diff --git a/kmicromail/libmailwrapper/generatemail.h b/kmicromail/libmailwrapper/generatemail.h
index b9f8285..a9fb648 100644
--- a/kmicromail/libmailwrapper/generatemail.h
+++ b/kmicromail/libmailwrapper/generatemail.h
@@ -1,47 +1,48 @@
1#ifndef __GENERATE_MAIL_H 1#ifndef __GENERATE_MAIL_H
2#define __GENERATE_MAIL_H 2#define __GENERATE_MAIL_H
3 3
4//#include <qpe/applnk.h> 4//#include <qpe/applnk.h>
5 5
6#include <qobject.h> 6#include <qobject.h>
7#include <libetpan/clist.h> 7#include <libetpan/clist.h>
8#include "mailwrapper.h" 8#include "mailwrapper.h"
9 9
10#include <opie2/osmartpointer.h> 10#include <opie2/osmartpointer.h>
11 11
12class Mail; 12class Mail;
13class RecMail; 13class RecMail;
14 14
15struct mailimf_fields; 15struct mailimf_fields;
16struct mailimf_field; 16struct mailimf_field;
17struct mailimf_mailbox; 17struct mailimf_mailbox;
18struct mailmime; 18struct mailmime;
19struct mailimf_address_list; 19struct mailimf_address_list;
20class progressMailSend; 20class progressMailSend;
21struct mailsmtp; 21struct mailsmtp;
22 22
23class Generatemail : public QObject 23class Generatemail : public QObject
24{ 24{
25 Q_OBJECT 25 Q_OBJECT
26public: 26public:
27 Generatemail(); 27 Generatemail();
28 virtual ~Generatemail(); 28 virtual ~Generatemail();
29 29
30protected: 30protected:
31 static void addRcpts( clist *list, mailimf_address_list *addr_list ); 31 static void addRcpts( clist *list, mailimf_address_list *addr_list );
32 static char *getFrom( mailmime *mail ); 32 static char *getFrom( mailmime *mail );
33 static char *getFrom( mailimf_field *ffrom); 33 static char *getFrom( mailimf_field *ffrom);
34 static mailimf_field *getField( mailimf_fields *fields, int type ); 34 static mailimf_field *getField( mailimf_fields *fields, int type );
35 mailimf_address_list *parseAddresses(const QString&addr ); 35 mailimf_address_list *parseAddresses(const QString&addr );
36 void addFileParts( mailmime *message,const QList<Attachment>&files ); 36 void addFileParts( mailmime *message,const QList<Attachment>&files );
37 mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); 37 mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content);
38 mailmime *buildTxtPart(const QString&str ); 38 mailmime *buildTxtPart(const QString&str );
39 mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); 39 mailimf_mailbox *newMailbox(const QString&name,const QString&mail );
40 mailimf_fields *createImfFields(const Opie::Core::OSmartPointer<Mail> &mail ); 40 mailimf_fields *createImfFields(const Opie::Core::OSmartPointer<Mail> &mail );
41 mailmime *createMimeMail(const Opie::Core::OSmartPointer<Mail>&mail ); 41 mailmime *createMimeMail(const Opie::Core::OSmartPointer<Mail>&mail );
42 clist *createRcptList( mailimf_fields *fields ); 42 clist *createRcptList( mailimf_fields *fields );
43 43
44 static const char* USER_AGENT; 44 static const char* USER_AGENT;
45 QString mCharset;
45}; 46};
46 47
47#endif 48#endif
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp
index 28d45ce..eac05e5 100644
--- a/kmicromail/libmailwrapper/genericwrapper.cpp
+++ b/kmicromail/libmailwrapper/genericwrapper.cpp
@@ -36,385 +36,386 @@ const QDateTime Genericwrapper::parseDateTime( mailimf_date_time *date )
36 int addsec = -date->dt_zone*36; 36 int addsec = -date->dt_zone*36;
37 //qDebug("adsec1 %d ",addsec ); 37 //qDebug("adsec1 %d ",addsec );
38 dt = dt.addSecs( addsec ); 38 dt = dt.addSecs( addsec );
39 int off = KGlobal::locale()->localTimeOffset( dt ); 39 int off = KGlobal::locale()->localTimeOffset( dt );
40 //qDebug("adsec2 %d ",off*60 ); 40 //qDebug("adsec2 %d ",off*60 );
41 41
42 dt = dt.addSecs( off*60 ); 42 dt = dt.addSecs( off*60 );
43 return dt; 43 return dt;
44#if 0 44#if 0
45 QString ret; 45 QString ret;
46 if ( dt.date() == QDate::currentDate () ) 46 if ( dt.date() == QDate::currentDate () )
47 ret = KGlobal::locale()->formatTime( dt.time(),true); 47 ret = KGlobal::locale()->formatTime( dt.time(),true);
48 48
49 else { 49 else {
50 ret = KGlobal::locale()->formatDateTime( dt,true,true); 50 ret = KGlobal::locale()->formatDateTime( dt,true,true);
51 } 51 }
52#endif 52#endif
53#if 0 53#if 0
54 if ( off < 0 ) 54 if ( off < 0 )
55 ret += " -"; 55 ret += " -";
56 else 56 else
57 ret += " +"; 57 ret += " +";
58 ret += QString::number( off / 60 ); 58 ret += QString::number( off / 60 );
59 ret += "h"; 59 ret += "h";
60#endif 60#endif
61#if 0 61#if 0
62 char tmp[23]; 62 char tmp[23];
63 63
64 // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", 64 // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i",
65 // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); 65 // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
66 snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", 66 snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i",
67 date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); 67 date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
68 68
69 69
70 return QString( tmp ); 70 return QString( tmp );
71#endif 71#endif
72 //return ret; 72 //return ret;
73} 73}
74 74
75void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) 75void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime)
76{ 76{
77 if (!mime) { 77 if (!mime) {
78 return; 78 return;
79 } 79 }
80 mailmime_field*field = 0; 80 mailmime_field*field = 0;
81 mailmime_single_fields fields; 81 mailmime_single_fields fields;
82 memset(&fields, 0, sizeof(struct mailmime_single_fields)); 82 memset(&fields, 0, sizeof(struct mailmime_single_fields));
83 if (mime->mm_mime_fields != NULL) { 83 if (mime->mm_mime_fields != NULL) {
84 mailmime_single_fields_init(&fields, mime->mm_mime_fields, 84 mailmime_single_fields_init(&fields, mime->mm_mime_fields,
85 mime->mm_content_type); 85 mime->mm_content_type);
86 } 86 }
87 87
88 mailmime_content*type = fields.fld_content; 88 mailmime_content*type = fields.fld_content;
89 clistcell*current; 89 clistcell*current;
90 if (!type) { 90 if (!type) {
91 target->setType("text"); 91 target->setType("text");
92 target->setSubtype("plain"); 92 target->setSubtype("plain");
93 } else { 93 } else {
94 target->setSubtype(type->ct_subtype); 94 target->setSubtype(type->ct_subtype);
95 switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { 95 switch(type->ct_type->tp_data.tp_discrete_type->dt_type) {
96 case MAILMIME_DISCRETE_TYPE_TEXT: 96 case MAILMIME_DISCRETE_TYPE_TEXT:
97 target->setType("text"); 97 target->setType("text");
98 break; 98 break;
99 case MAILMIME_DISCRETE_TYPE_IMAGE: 99 case MAILMIME_DISCRETE_TYPE_IMAGE:
100 target->setType("image"); 100 target->setType("image");
101 break; 101 break;
102 case MAILMIME_DISCRETE_TYPE_AUDIO: 102 case MAILMIME_DISCRETE_TYPE_AUDIO:
103 target->setType("audio"); 103 target->setType("audio");
104 break; 104 break;
105 case MAILMIME_DISCRETE_TYPE_VIDEO: 105 case MAILMIME_DISCRETE_TYPE_VIDEO:
106 target->setType("video"); 106 target->setType("video");
107 break; 107 break;
108 case MAILMIME_DISCRETE_TYPE_APPLICATION: 108 case MAILMIME_DISCRETE_TYPE_APPLICATION:
109 target->setType("application"); 109 target->setType("application");
110 break; 110 break;
111 case MAILMIME_DISCRETE_TYPE_EXTENSION: 111 case MAILMIME_DISCRETE_TYPE_EXTENSION:
112 default: 112 default:
113 if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { 113 if (type->ct_type->tp_data.tp_discrete_type->dt_extension) {
114 target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); 114 target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension);
115 } 115 }
116 break; 116 break;
117 } 117 }
118 if (type->ct_parameters) { 118 if (type->ct_parameters) {
119 fillParameters(target,type->ct_parameters); 119 fillParameters(target,type->ct_parameters);
120 } 120 }
121 } 121 }
122 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { 122 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) {
123 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { 123 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) {
124 field = (mailmime_field*)current->data; 124 field = (mailmime_field*)current->data;
125 switch(field->fld_type) { 125 switch(field->fld_type) {
126 case MAILMIME_FIELD_TRANSFER_ENCODING: 126 case MAILMIME_FIELD_TRANSFER_ENCODING:
127 target->setEncoding(getencoding(field->fld_data.fld_encoding)); 127 target->setEncoding(getencoding(field->fld_data.fld_encoding));
128 break; 128 break;
129 case MAILMIME_FIELD_ID: 129 case MAILMIME_FIELD_ID:
130 target->setIdentifier(field->fld_data.fld_id); 130 target->setIdentifier(field->fld_data.fld_id);
131 break; 131 break;
132 case MAILMIME_FIELD_DESCRIPTION: 132 case MAILMIME_FIELD_DESCRIPTION:
133 target->setDescription(field->fld_data.fld_description); 133 target->setDescription(field->fld_data.fld_description);
134 break; 134 break;
135 default: 135 default:
136 break; 136 break;
137 } 137 }
138 } 138 }
139 } 139 }
140} 140}
141 141
142void Genericwrapper::fillParameters(RecPartP&target,clist*parameters) 142void Genericwrapper::fillParameters(RecPartP&target,clist*parameters)
143{ 143{
144 if (!parameters) {return;} 144 if (!parameters) {return;}
145 clistcell*current=0; 145 clistcell*current=0;
146 mailmime_parameter*param; 146 mailmime_parameter*param;
147 for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { 147 for (current=clist_begin(parameters);current!=0;current=clist_next(current)) {
148 param = (mailmime_parameter*)current->data; 148 param = (mailmime_parameter*)current->data;
149 if (param) { 149 if (param) {
150 target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 150 target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
151 } 151 }
152 } 152 }
153} 153}
154 154
155QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) 155QString Genericwrapper::getencoding(mailmime_mechanism*aEnc)
156{ 156{
157 QString enc="7bit"; 157 QString enc="7bit";
158 if (!aEnc) return enc; 158 if (!aEnc) return enc;
159 switch(aEnc->enc_type) { 159 switch(aEnc->enc_type) {
160 case MAILMIME_MECHANISM_7BIT: 160 case MAILMIME_MECHANISM_7BIT:
161 enc = "7bit"; 161 enc = "7bit";
162 break; 162 break;
163 case MAILMIME_MECHANISM_8BIT: 163 case MAILMIME_MECHANISM_8BIT:
164 enc = "8bit"; 164 enc = "8bit";
165 break; 165 break;
166 case MAILMIME_MECHANISM_BINARY: 166 case MAILMIME_MECHANISM_BINARY:
167 enc = "binary"; 167 enc = "binary";
168 break; 168 break;
169 case MAILMIME_MECHANISM_QUOTED_PRINTABLE: 169 case MAILMIME_MECHANISM_QUOTED_PRINTABLE:
170 enc = "quoted-printable"; 170 enc = "quoted-printable";
171 break; 171 break;
172 case MAILMIME_MECHANISM_BASE64: 172 case MAILMIME_MECHANISM_BASE64:
173 enc = "base64"; 173 enc = "base64";
174 break; 174 break;
175 case MAILMIME_MECHANISM_TOKEN: 175 case MAILMIME_MECHANISM_TOKEN:
176 default: 176 default:
177 if (aEnc->enc_token) { 177 if (aEnc->enc_token) {
178 enc = QString(aEnc->enc_token); 178 enc = QString(aEnc->enc_token);
179 } 179 }
180 break; 180 break;
181 } 181 }
182 return enc; 182 return enc;
183} 183}
184 184
185void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) 185void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count)
186{ 186{
187 if (current_rec >= 10) { 187 if (current_rec >= 10) {
188 ; // odebug << "too deep recursion!" << oendl; 188 ; // odebug << "too deep recursion!" << oendl;
189 } 189 }
190 if (!message || !mime) { 190 if (!message || !mime) {
191 return; 191 return;
192 } 192 }
193 int r; 193 int r;
194 char*data = 0; 194 char*data = 0;
195 size_t len; 195 size_t len;
196 clistiter * cur = 0; 196 clistiter * cur = 0;
197 QString b; 197 QString b;
198 RecPartP part = new RecPart(); 198 RecPartP part = new RecPart();
199 199
200 switch (mime->mm_type) { 200 switch (mime->mm_type) {
201 case MAILMIME_SINGLE: 201 case MAILMIME_SINGLE:
202 { 202 {
203 QValueList<int>countlist = recList; 203 QValueList<int>countlist = recList;
204 countlist.append(current_count); 204 countlist.append(current_count);
205 r = mailmessage_fetch_section(message,mime,&data,&len); 205 r = mailmessage_fetch_section(message,mime,&data,&len);
206 part->setSize(len); 206 part->setSize(len);
207 part->setPositionlist(countlist); 207 part->setPositionlist(countlist);
208 b = gen_attachment_id(); 208 b = gen_attachment_id();
209 part->setIdentifier(b); 209 part->setIdentifier(b);
210 fillSingleBody(part,message,mime); 210 fillSingleBody(part,message,mime);
211 if (part->Type()=="text" && target->Bodytext().isNull()) { 211 if (part->Type()=="text" && target->Bodytext().isNull()) {
212 encodedString*rs = new encodedString(); 212 encodedString*rs = new encodedString();
213 rs->setContent(data,len); 213 rs->setContent(data,len);
214 encodedString*res = decode_String(rs,part->Encoding()); 214 encodedString*res = decode_String(rs,part->Encoding());
215 if (countlist.count()>2) { 215 if (countlist.count()>2) {
216 bodyCache[b]=rs; 216 bodyCache[b]=rs;
217 target->addPart(part); 217 target->addPart(part);
218 } else { 218 } else {
219 delete rs; 219 delete rs;
220 } 220 }
221 b = QString(res->Content()); 221 b = QString(res->Content());
222 delete res; 222 delete res;
223 size_t index = 0; 223 size_t index = 0;
224 char*resu = 0; 224 char*resu = 0;
225 int err = MAILIMF_NO_ERROR; 225 int err = MAILIMF_NO_ERROR;
226 QString charset = part->searchParamter( "charset"); 226 QString charset = part->searchParamter( "charset");
227 qDebug("CHARSET %s ",charset.latin1() ); 227 qDebug("CHARSET %s ",charset.latin1() );
228 if ( !charset.isEmpty() ) { 228 if (false ) {
229 //if ( !charset.isEmpty() ) {
229 target->setCharset( charset ); 230 target->setCharset( charset );
230 err = mailmime_encoded_phrase_parse(charset.latin1(), 231 err = mailmime_encoded_phrase_parse(charset.latin1(),
231 b.latin1(), b.length(),&index, "utf-8",&resu); 232 b.latin1(), b.length(),&index, "utf-8",&resu);
232 if (err == MAILIMF_NO_ERROR && resu && strlen(resu)) { 233 if (err == MAILIMF_NO_ERROR && resu && strlen(resu)) {
233 //qDebug("res %d %s ", index, resu); 234 //qDebug("res %d %s ", index, resu);
234 b = QString::fromUtf8(resu); 235 b = QString::fromUtf8(resu);
235 } 236 }
236 if (resu) free(resu); 237 if (resu) free(resu);
237 } 238 }
238 target->setBodytext(b); 239 target->setBodytext(b);
239 target->setDescription(part); 240 target->setDescription(part);
240 } else { 241 } else {
241 bodyCache[b]=new encodedString(data,len); 242 bodyCache[b]=new encodedString(data,len);
242 target->addPart(part); 243 target->addPart(part);
243 } 244 }
244 } 245 }
245 break; 246 break;
246 case MAILMIME_MULTIPLE: 247 case MAILMIME_MULTIPLE:
247 { 248 {
248 unsigned int ccount = 1; 249 unsigned int ccount = 1;
249 mailmime*cbody=0; 250 mailmime*cbody=0;
250 QValueList<int>countlist = recList; 251 QValueList<int>countlist = recList;
251 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { 252 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) {
252 cbody = (mailmime*)clist_content(cur); 253 cbody = (mailmime*)clist_content(cur);
253 if (cbody->mm_type==MAILMIME_MULTIPLE) { 254 if (cbody->mm_type==MAILMIME_MULTIPLE) {
254 RecPartP targetPart = new RecPart(); 255 RecPartP targetPart = new RecPart();
255 targetPart->setType("multipart"); 256 targetPart->setType("multipart");
256 countlist.append(current_count); 257 countlist.append(current_count);
257 targetPart->setPositionlist(countlist); 258 targetPart->setPositionlist(countlist);
258 target->addPart(targetPart); 259 target->addPart(targetPart);
259 } 260 }
260 traverseBody(target,message, cbody,countlist,current_rec+1,ccount); 261 traverseBody(target,message, cbody,countlist,current_rec+1,ccount);
261 if (cbody->mm_type==MAILMIME_MULTIPLE) { 262 if (cbody->mm_type==MAILMIME_MULTIPLE) {
262 countlist = recList; 263 countlist = recList;
263 } 264 }
264 ++ccount; 265 ++ccount;
265 } 266 }
266 } 267 }
267 break; 268 break;
268 case MAILMIME_MESSAGE: 269 case MAILMIME_MESSAGE:
269 { 270 {
270 QValueList<int>countlist = recList; 271 QValueList<int>countlist = recList;
271 countlist.append(current_count); 272 countlist.append(current_count);
272 /* the own header is always at recursion 0 - we don't need that */ 273 /* the own header is always at recursion 0 - we don't need that */
273 if (current_rec > 0) { 274 if (current_rec > 0) {
274 part->setPositionlist(countlist); 275 part->setPositionlist(countlist);
275 r = mailmessage_fetch_section(message,mime,&data,&len); 276 r = mailmessage_fetch_section(message,mime,&data,&len);
276 part->setSize(len); 277 part->setSize(len);
277 part->setPositionlist(countlist); 278 part->setPositionlist(countlist);
278 b = gen_attachment_id(); 279 b = gen_attachment_id();
279 part->setIdentifier(b); 280 part->setIdentifier(b);
280 part->setType("message"); 281 part->setType("message");
281 part->setSubtype("rfc822"); 282 part->setSubtype("rfc822");
282 bodyCache[b]=new encodedString(data,len); 283 bodyCache[b]=new encodedString(data,len);
283 target->addPart(part); 284 target->addPart(part);
284 } 285 }
285 if (mime->mm_data.mm_message.mm_msg_mime != NULL) { 286 if (mime->mm_data.mm_message.mm_msg_mime != NULL) {
286 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); 287 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1);
287 } 288 }
288 } 289 }
289 break; 290 break;
290 } 291 }
291} 292}
292 293
293RecBodyP Genericwrapper::parseMail( mailmessage * msg ) 294RecBodyP Genericwrapper::parseMail( mailmessage * msg )
294{ 295{
295 int err = MAILIMF_NO_ERROR; 296 int err = MAILIMF_NO_ERROR;
296 //mailmime_single_fields fields; 297 //mailmime_single_fields fields;
297 /* is bound to msg and will be freed there */ 298 /* is bound to msg and will be freed there */
298 mailmime * mime=0; 299 mailmime * mime=0;
299 RecBodyP body = new RecBody(); 300 RecBodyP body = new RecBody();
300 //memset(&fields, 0, sizeof(struct mailmime_single_fields)); 301 //memset(&fields, 0, sizeof(struct mailmime_single_fields));
301 err = mailmessage_get_bodystructure(msg,&mime); 302 err = mailmessage_get_bodystructure(msg,&mime);
302 QValueList<int>recList; 303 QValueList<int>recList;
303 traverseBody(body,msg,mime,recList); 304 traverseBody(body,msg,mime,recList);
304 return body; 305 return body;
305} 306}
306 307
307 308
308QString Genericwrapper::parseAddressList( mailimf_address_list *list ) 309QString Genericwrapper::parseAddressList( mailimf_address_list *list )
309{ 310{
310 QString result( "" ); 311 QString result( "" );
311 312
312 bool first = true; 313 bool first = true;
313 if (list == 0) return result; 314 if (list == 0) return result;
314 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { 315 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) {
315 mailimf_address *addr = (mailimf_address *) current->data; 316 mailimf_address *addr = (mailimf_address *) current->data;
316 317
317 if ( !first ) { 318 if ( !first ) {
318 result.append( "," ); 319 result.append( "," );
319 } else { 320 } else {
320 first = false; 321 first = false;
321 } 322 }
322 323
323 switch ( addr->ad_type ) { 324 switch ( addr->ad_type ) {
324 case MAILIMF_ADDRESS_MAILBOX: 325 case MAILIMF_ADDRESS_MAILBOX:
325 result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); 326 result.append( parseMailbox( addr->ad_data.ad_mailbox ) );
326 break; 327 break;
327 case MAILIMF_ADDRESS_GROUP: 328 case MAILIMF_ADDRESS_GROUP:
328 result.append( parseGroup( addr->ad_data.ad_group ) ); 329 result.append( parseGroup( addr->ad_data.ad_group ) );
329 break; 330 break;
330 default: 331 default:
331 ; // odebug << "Generic: unkown mailimf address type" << oendl; 332 ; // odebug << "Generic: unkown mailimf address type" << oendl;
332 break; 333 break;
333 } 334 }
334 } 335 }
335 336
336 return result; 337 return result;
337} 338}
338 339
339QString Genericwrapper::parseGroup( mailimf_group *group ) 340QString Genericwrapper::parseGroup( mailimf_group *group )
340{ 341{
341 QString result( "" ); 342 QString result( "" );
342 343
343 result.append( group->grp_display_name ); 344 result.append( group->grp_display_name );
344 result.append( ": " ); 345 result.append( ": " );
345 346
346 if ( group->grp_mb_list != NULL ) { 347 if ( group->grp_mb_list != NULL ) {
347 result.append( parseMailboxList( group->grp_mb_list ) ); 348 result.append( parseMailboxList( group->grp_mb_list ) );
348 } 349 }
349 350
350 result.append( ";" ); 351 result.append( ";" );
351 352
352 return result; 353 return result;
353} 354}
354 355
355QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) 356QString Genericwrapper::parseMailbox( mailimf_mailbox *box )
356{ 357{
357 QString result( "" ); 358 QString result( "" );
358 359
359 if ( box->mb_display_name == NULL ) { 360 if ( box->mb_display_name == NULL ) {
360 result.append( box->mb_addr_spec ); 361 result.append( box->mb_addr_spec );
361 } else { 362 } else {
362 result.append( convert_String(box->mb_display_name) ); 363 result.append( convert_String(box->mb_display_name) );
363 result.append( " <" ); 364 result.append( " <" );
364 result.append( box->mb_addr_spec ); 365 result.append( box->mb_addr_spec );
365 result.append( ">" ); 366 result.append( ">" );
366 } 367 }
367 368
368 return result; 369 return result;
369} 370}
370 371
371QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) 372QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list )
372{ 373{
373 QString result( "" ); 374 QString result( "" );
374 375
375 bool first = true; 376 bool first = true;
376 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { 377 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) {
377 mailimf_mailbox *box = (mailimf_mailbox *) current->data; 378 mailimf_mailbox *box = (mailimf_mailbox *) current->data;
378 379
379 if ( !first ) { 380 if ( !first ) {
380 result.append( "," ); 381 result.append( "," );
381 } else { 382 } else {
382 first = false; 383 first = false;
383 } 384 }
384 385
385 result.append( parseMailbox( box ) ); 386 result.append( parseMailbox( box ) );
386 } 387 }
387 388
388 return result; 389 return result;
389} 390}
390 391
391encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part) 392encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part)
392{ 393{
393 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); 394 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier());
394 if (it==bodyCache.end()) return new encodedString(); 395 if (it==bodyCache.end()) return new encodedString();
395 encodedString*t = decode_String(it.data(),part->Encoding()); 396 encodedString*t = decode_String(it.data(),part->Encoding());
396 return t; 397 return t;
397} 398}
398 399
399encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part) 400encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part)
400{ 401{
401 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); 402 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier());
402 if (it==bodyCache.end()) return new encodedString(); 403 if (it==bodyCache.end()) return new encodedString();
403 encodedString*t = it.data(); 404 encodedString*t = it.data();
404 return t; 405 return t;
405} 406}
406 407
407QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) 408QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part)
408{ 409{
409 encodedString*t = fetchDecodedPart(mail,part); 410 encodedString*t = fetchDecodedPart(mail,part);
410 QString text=t->Content(); 411 QString text=t->Content();
411 delete t; 412 delete t;
412 return text; 413 return text;
413} 414}
414 415
415void Genericwrapper::cleanMimeCache() 416void Genericwrapper::cleanMimeCache()
416{ 417{
417 QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); 418 QMap<QString,encodedString*>::Iterator it = bodyCache.begin();
418 for (;it!=bodyCache.end();++it) { 419 for (;it!=bodyCache.end();++it) {
419 encodedString*t = it.data(); 420 encodedString*t = it.data();
420 //it.setValue(0); 421 //it.setValue(0);
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index 2a54381..da7065f 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -570,386 +570,386 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
570RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) 570RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail)
571{ 571{
572 RecBodyP body = new RecBody(); 572 RecBodyP body = new RecBody();
573 const char *mb; 573 const char *mb;
574 int err = MAILIMAP_NO_ERROR; 574 int err = MAILIMAP_NO_ERROR;
575 clist *result = 0; 575 clist *result = 0;
576 clistcell *current; 576 clistcell *current;
577 mailimap_fetch_att *fetchAtt = 0; 577 mailimap_fetch_att *fetchAtt = 0;
578 mailimap_fetch_type *fetchType = 0; 578 mailimap_fetch_type *fetchType = 0;
579 mailimap_set *set = 0; 579 mailimap_set *set = 0;
580 mailimap_body*body_desc = 0; 580 mailimap_body*body_desc = 0;
581 581
582 mb = mail->getMbox().latin1(); 582 mb = mail->getMbox().latin1();
583 583
584 login(); 584 login();
585 if (!m_imap) { 585 if (!m_imap) {
586 return body; 586 return body;
587 } 587 }
588 err = selectMbox(mail->getMbox()); 588 err = selectMbox(mail->getMbox());
589 if ( err != MAILIMAP_NO_ERROR ) { 589 if ( err != MAILIMAP_NO_ERROR ) {
590 return body; 590 return body;
591 } 591 }
592 592
593 /* the range has to start at 1!!! not with 0!!!! */ 593 /* the range has to start at 1!!! not with 0!!!! */
594 set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); 594 set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() );
595 fetchAtt = mailimap_fetch_att_new_bodystructure(); 595 fetchAtt = mailimap_fetch_att_new_bodystructure();
596 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); 596 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
597 err = mailimap_fetch( m_imap, set, fetchType, &result ); 597 err = mailimap_fetch( m_imap, set, fetchType, &result );
598 mailimap_set_free( set ); 598 mailimap_set_free( set );
599 mailimap_fetch_type_free( fetchType ); 599 mailimap_fetch_type_free( fetchType );
600 600
601 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { 601 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
602 mailimap_msg_att * msg_att; 602 mailimap_msg_att * msg_att;
603 msg_att = (mailimap_msg_att*)current->data; 603 msg_att = (mailimap_msg_att*)current->data;
604 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; 604 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data;
605 QValueList<int> path; 605 QValueList<int> path;
606 body_desc = item->att_data.att_static->att_data.att_body; 606 body_desc = item->att_data.att_static->att_data.att_body;
607 traverseBody(mail,body_desc,body,0,path); 607 traverseBody(mail,body_desc,body,0,path);
608 } else { 608 } else {
609 //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; 609 //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl;
610 } 610 }
611 if (result) mailimap_fetch_list_free(result); 611 if (result) mailimap_fetch_list_free(result);
612 return body; 612 return body;
613} 613}
614 614
615QStringList IMAPwrapper::address_list_to_stringlist(clist*list) 615QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
616{ 616{
617 QStringList l; 617 QStringList l;
618 QString from; 618 QString from;
619 bool named_from; 619 bool named_from;
620 clistcell *current = NULL; 620 clistcell *current = NULL;
621 mailimap_address * current_address=NULL; 621 mailimap_address * current_address=NULL;
622 if (!list) { 622 if (!list) {
623 return l; 623 return l;
624 } 624 }
625 unsigned int count = 0; 625 unsigned int count = 0;
626 for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { 626 for (current=clist_begin(list);current!= NULL;current=clist_next(current)) {
627 from = ""; 627 from = "";
628 named_from = false; 628 named_from = false;
629 current_address=(mailimap_address*)current->data; 629 current_address=(mailimap_address*)current->data;
630 if (current_address->ad_personal_name){ 630 if (current_address->ad_personal_name){
631 from+=convert_String((const char*)current_address->ad_personal_name); 631 from+=convert_String((const char*)current_address->ad_personal_name);
632 from+=" "; 632 from+=" ";
633 named_from = true; 633 named_from = true;
634 } 634 }
635 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { 635 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
636 from+="<"; 636 from+="<";
637 } 637 }
638 if (current_address->ad_mailbox_name) { 638 if (current_address->ad_mailbox_name) {
639 from+=QString(current_address->ad_mailbox_name); 639 from+=QString(current_address->ad_mailbox_name);
640 from+="@"; 640 from+="@";
641 } 641 }
642 if (current_address->ad_host_name) { 642 if (current_address->ad_host_name) {
643 from+=QString(current_address->ad_host_name); 643 from+=QString(current_address->ad_host_name);
644 } 644 }
645 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { 645 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
646 from+=">"; 646 from+=">";
647 } 647 }
648 l.append(QString(from)); 648 l.append(QString(from));
649 if (++count > 99) { 649 if (++count > 99) {
650 break; 650 break;
651 } 651 }
652 } 652 }
653 return l; 653 return l;
654} 654}
655 655
656encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) 656encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call)
657{ 657{
658 encodedString*res=new encodedString; 658 encodedString*res=new encodedString;
659 int err; 659 int err;
660 mailimap_fetch_type *fetchType; 660 mailimap_fetch_type *fetchType;
661 mailimap_set *set; 661 mailimap_set *set;
662 clistcell*current,*cur; 662 clistcell*current,*cur;
663 mailimap_section_part * section_part = 0; 663 mailimap_section_part * section_part = 0;
664 mailimap_section_spec * section_spec = 0; 664 mailimap_section_spec * section_spec = 0;
665 mailimap_section * section = 0; 665 mailimap_section * section = 0;
666 mailimap_fetch_att * fetch_att = 0; 666 mailimap_fetch_att * fetch_att = 0;
667 667
668 login(); 668 login();
669 if (!m_imap) { 669 if (!m_imap) {
670 return res; 670 return res;
671 } 671 }
672 if (!internal_call) { 672 if (!internal_call) {
673 err = selectMbox(mail->getMbox()); 673 err = selectMbox(mail->getMbox());
674 if ( err != MAILIMAP_NO_ERROR ) { 674 if ( err != MAILIMAP_NO_ERROR ) {
675 return res; 675 return res;
676 } 676 }
677 } 677 }
678 set = mailimap_set_new_single(mail->getNumber()); 678 set = mailimap_set_new_single(mail->getNumber());
679 679
680 clist*id_list = 0; 680 clist*id_list = 0;
681 681
682 /* if path == empty then its a request for the whole rfc822 mail and generates 682 /* if path == empty then its a request for the whole rfc822 mail and generates
683 a "fetch <id> (body[])" statement on imap server */ 683 a "fetch <id> (body[])" statement on imap server */
684 if (path.count()>0 ) { 684 if (path.count()>0 ) {
685 id_list = clist_new(); 685 id_list = clist_new();
686 for (unsigned j=0; j < path.count();++j) { 686 for (unsigned j=0; j < path.count();++j) {
687 uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); 687 uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id));
688 *p_id = path[j]; 688 *p_id = path[j];
689 clist_append(id_list,p_id); 689 clist_append(id_list,p_id);
690 } 690 }
691 section_part = mailimap_section_part_new(id_list); 691 section_part = mailimap_section_part_new(id_list);
692 section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); 692 section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL);
693 } 693 }
694 694
695 section = mailimap_section_new(section_spec); 695 section = mailimap_section_new(section_spec);
696 fetch_att = mailimap_fetch_att_new_body_section(section); 696 fetch_att = mailimap_fetch_att_new_body_section(section);
697 fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); 697 fetchType = mailimap_fetch_type_new_fetch_att(fetch_att);
698 698
699 clist*result = 0; 699 clist*result = 0;
700 700
701 err = mailimap_fetch( m_imap, set, fetchType, &result ); 701 err = mailimap_fetch( m_imap, set, fetchType, &result );
702 mailimap_set_free( set ); 702 mailimap_set_free( set );
703 mailimap_fetch_type_free( fetchType ); 703 mailimap_fetch_type_free( fetchType );
704 704
705 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { 705 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
706 mailimap_msg_att * msg_att; 706 mailimap_msg_att * msg_att;
707 msg_att = (mailimap_msg_att*)current->data; 707 msg_att = (mailimap_msg_att*)current->data;
708 mailimap_msg_att_item*msg_att_item; 708 mailimap_msg_att_item*msg_att_item;
709 for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { 709 for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) {
710 msg_att_item = (mailimap_msg_att_item*)clist_content(cur); 710 msg_att_item = (mailimap_msg_att_item*)clist_content(cur);
711 if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { 711 if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) {
712 if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { 712 if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) {
713 char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; 713 char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part;
714 /* detach - we take over the content */ 714 /* detach - we take over the content */
715 msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; 715 msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L;
716 res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); 716 res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length);
717 } 717 }
718 } 718 }
719 } 719 }
720 } else { 720 } else {
721 ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; 721 ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl;
722 } 722 }
723 if (result) mailimap_fetch_list_free(result); 723 if (result) mailimap_fetch_list_free(result);
724 return res; 724 return res;
725} 725}
726 726
727/* current_recursion is for recursive calls. 727/* current_recursion is for recursive calls.
728 current_count means the position inside the internal loop! */ 728 current_count means the position inside the internal loop! */
729void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, 729void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,
730 int current_recursion,QValueList<int>recList,int current_count) 730 int current_recursion,QValueList<int>recList,int current_count)
731{ 731{
732 if (!body || current_recursion>=10) { 732 if (!body || current_recursion>=10) {
733 return; 733 return;
734 } 734 }
735 switch (body->bd_type) { 735 switch (body->bd_type) {
736 case MAILIMAP_BODY_1PART: 736 case MAILIMAP_BODY_1PART:
737 { 737 {
738 QValueList<int>countlist = recList; 738 QValueList<int>countlist = recList;
739 countlist.append(current_count); 739 countlist.append(current_count);
740 RecPartP currentPart = new RecPart(); 740 RecPartP currentPart = new RecPart();
741 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; 741 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part;
742 QString id(""); 742 QString id("");
743 currentPart->setPositionlist(countlist); 743 currentPart->setPositionlist(countlist);
744 for (unsigned int j = 0; j < countlist.count();++j) { 744 for (unsigned int j = 0; j < countlist.count();++j) {
745 id+=(j>0?" ":""); 745 id+=(j>0?" ":"");
746 id+=QString("%1").arg(countlist[j]); 746 id+=QString("%1").arg(countlist[j]);
747 } 747 }
748 //odebug << "ID = " << id.latin1() << "" << oendl; 748 //odebug << "ID = " << id.latin1() << "" << oendl;
749 currentPart->setIdentifier(id); 749 currentPart->setIdentifier(id);
750 fillSinglePart(currentPart,part1); 750 fillSinglePart(currentPart,part1);
751 /* important: Check for is NULL 'cause a body can be empty! 751 /* important: Check for is NULL 'cause a body can be empty!
752 And we put it only into the mail if it is the FIRST part */ 752 And we put it only into the mail if it is the FIRST part */
753 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { 753 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) {
754 QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); 754 QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding());
755 755
756 size_t index = 0; 756 size_t index = 0;
757 char*res = 0; 757 char*res = 0;
758 int err = MAILIMF_NO_ERROR; 758 int err = MAILIMF_NO_ERROR;
759 759
760 QString charset = currentPart->searchParamter( "charset"); 760 QString charset = currentPart->searchParamter( "charset");
761 qDebug("CHARSET %s ",charset.latin1() ); 761 qDebug("CHARSET %s ",charset.latin1() );
762 //if ( false ) { 762 if ( false ) {
763 if ( !charset.isEmpty() ) { 763 //if ( !charset.isEmpty() ) {
764 target_body->setCharset( charset ); 764 target_body->setCharset( charset );
765 //err = mailmime_encoded_phrase_parse("iso-8859-1", 765 //err = mailmime_encoded_phrase_parse("iso-8859-1",
766 // text, strlen(text),&index, "iso-8859-1",&res); 766 // text, strlen(text),&index, "iso-8859-1",&res);
767 err = mailmime_encoded_phrase_parse(charset.latin1(), 767 err = mailmime_encoded_phrase_parse(charset.latin1(),
768 body_text.latin1(), body_text.length(),&index, "utf-8",&res); 768 body_text.latin1(), body_text.length(),&index, "utf-8",&res);
769 if (err == MAILIMF_NO_ERROR && res && strlen(res)) { 769 if (err == MAILIMF_NO_ERROR && res && strlen(res)) {
770 //qDebug("res %d %s ", index, res); 770 //qDebug("res %d %s ", index, res);
771 body_text = QString::fromUtf8(res); 771 body_text = QString::fromUtf8(res);
772 } 772 }
773 if (res) free(res); 773 if (res) free(res);
774 } 774 }
775 //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() ); 775 //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() );
776 target_body->setDescription(currentPart); 776 target_body->setDescription(currentPart);
777 target_body->setBodytext(body_text); 777 target_body->setBodytext(body_text);
778 if (countlist.count()>1) { 778 if (countlist.count()>1) {
779 target_body->addPart(currentPart); 779 target_body->addPart(currentPart);
780 } 780 }
781 } else { 781 } else {
782 target_body->addPart(currentPart); 782 target_body->addPart(currentPart);
783 } 783 }
784 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { 784 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) {
785 traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); 785 traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist);
786 } 786 }
787 } 787 }
788 break; 788 break;
789 case MAILIMAP_BODY_MPART: 789 case MAILIMAP_BODY_MPART:
790 { 790 {
791 QValueList<int>countlist = recList; 791 QValueList<int>countlist = recList;
792 clistcell*current=0; 792 clistcell*current=0;
793 mailimap_body*current_body=0; 793 mailimap_body*current_body=0;
794 unsigned int ccount = 1; 794 unsigned int ccount = 1;
795 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; 795 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart;
796 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { 796 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) {
797 current_body = (mailimap_body*)current->data; 797 current_body = (mailimap_body*)current->data;
798 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 798 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
799 RecPartP targetPart = new RecPart(); 799 RecPartP targetPart = new RecPart();
800 targetPart->setType("multipart"); 800 targetPart->setType("multipart");
801 fillMultiPart(targetPart,mailDescription); 801 fillMultiPart(targetPart,mailDescription);
802 countlist.append(current_count); 802 countlist.append(current_count);
803 targetPart->setPositionlist(countlist); 803 targetPart->setPositionlist(countlist);
804 target_body->addPart(targetPart); 804 target_body->addPart(targetPart);
805 QString id(""); 805 QString id("");
806 for (unsigned int j = 0; j < countlist.count();++j) { 806 for (unsigned int j = 0; j < countlist.count();++j) {
807 id+=(j>0?" ":""); 807 id+=(j>0?" ":"");
808 id+=QString("%1").arg(countlist[j]); 808 id+=QString("%1").arg(countlist[j]);
809 } 809 }
810 // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; 810 // odebug << "ID(mpart) = " << id.latin1() << "" << oendl;
811 } 811 }
812 traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); 812 traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount);
813 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 813 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
814 countlist = recList; 814 countlist = recList;
815 } 815 }
816 ++ccount; 816 ++ccount;
817 } 817 }
818 } 818 }
819 break; 819 break;
820 default: 820 default:
821 break; 821 break;
822 } 822 }
823} 823}
824 824
825void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) 825void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description)
826{ 826{
827 if (!Description) { 827 if (!Description) {
828 return; 828 return;
829 } 829 }
830 switch (Description->bd_type) { 830 switch (Description->bd_type) {
831 case MAILIMAP_BODY_TYPE_1PART_TEXT: 831 case MAILIMAP_BODY_TYPE_1PART_TEXT:
832 target_part->setType("text"); 832 target_part->setType("text");
833 fillSingleTextPart(target_part,Description->bd_data.bd_type_text); 833 fillSingleTextPart(target_part,Description->bd_data.bd_type_text);
834 break; 834 break;
835 case MAILIMAP_BODY_TYPE_1PART_BASIC: 835 case MAILIMAP_BODY_TYPE_1PART_BASIC:
836 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); 836 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic);
837 break; 837 break;
838 case MAILIMAP_BODY_TYPE_1PART_MSG: 838 case MAILIMAP_BODY_TYPE_1PART_MSG:
839 target_part->setType("message"); 839 target_part->setType("message");
840 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); 840 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg);
841 break; 841 break;
842 default: 842 default:
843 break; 843 break;
844 } 844 }
845} 845}
846 846
847void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) 847void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which)
848{ 848{
849 if (!which) { 849 if (!which) {
850 return; 850 return;
851 } 851 }
852 QString sub; 852 QString sub;
853 sub = which->bd_media_text; 853 sub = which->bd_media_text;
854 //odebug << "Type= text/" << which->bd_media_text << "" << oendl; 854 //odebug << "Type= text/" << which->bd_media_text << "" << oendl;
855 target_part->setSubtype(sub.lower()); 855 target_part->setSubtype(sub.lower());
856 target_part->setLines(which->bd_lines); 856 target_part->setLines(which->bd_lines);
857 fillBodyFields(target_part,which->bd_fields); 857 fillBodyFields(target_part,which->bd_fields);
858} 858}
859 859
860void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) 860void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which)
861{ 861{
862 if (!which) { 862 if (!which) {
863 return; 863 return;
864 } 864 }
865 target_part->setSubtype("rfc822"); 865 target_part->setSubtype("rfc822");
866 //odebug << "Message part" << oendl; 866 //odebug << "Message part" << oendl;
867 /* we set this type to text/plain */ 867 /* we set this type to text/plain */
868 target_part->setLines(which->bd_lines); 868 target_part->setLines(which->bd_lines);
869 fillBodyFields(target_part,which->bd_fields); 869 fillBodyFields(target_part,which->bd_fields);
870} 870}
871 871
872void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) 872void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which)
873{ 873{
874 if (!which) return; 874 if (!which) return;
875 QString sub = which->bd_media_subtype; 875 QString sub = which->bd_media_subtype;
876 target_part->setSubtype(sub.lower()); 876 target_part->setSubtype(sub.lower());
877 if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { 877 if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) {
878 clistcell*cur = 0; 878 clistcell*cur = 0;
879 mailimap_single_body_fld_param*param=0; 879 mailimap_single_body_fld_param*param=0;
880 for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { 880 for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
881 param = (mailimap_single_body_fld_param*)cur->data; 881 param = (mailimap_single_body_fld_param*)cur->data;
882 if (param) { 882 if (param) {
883 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 883 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
884 } 884 }
885 } 885 }
886 } 886 }
887} 887}
888 888
889void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) 889void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which)
890{ 890{
891 if (!which) { 891 if (!which) {
892 return; 892 return;
893 } 893 }
894 QString type,sub; 894 QString type,sub;
895 switch (which->bd_media_basic->med_type) { 895 switch (which->bd_media_basic->med_type) {
896 case MAILIMAP_MEDIA_BASIC_APPLICATION: 896 case MAILIMAP_MEDIA_BASIC_APPLICATION:
897 type = "application"; 897 type = "application";
898 break; 898 break;
899 case MAILIMAP_MEDIA_BASIC_AUDIO: 899 case MAILIMAP_MEDIA_BASIC_AUDIO:
900 type = "audio"; 900 type = "audio";
901 break; 901 break;
902 case MAILIMAP_MEDIA_BASIC_IMAGE: 902 case MAILIMAP_MEDIA_BASIC_IMAGE:
903 type = "image"; 903 type = "image";
904 break; 904 break;
905 case MAILIMAP_MEDIA_BASIC_MESSAGE: 905 case MAILIMAP_MEDIA_BASIC_MESSAGE:
906 type = "message"; 906 type = "message";
907 break; 907 break;
908 case MAILIMAP_MEDIA_BASIC_VIDEO: 908 case MAILIMAP_MEDIA_BASIC_VIDEO:
909 type = "video"; 909 type = "video";
910 break; 910 break;
911 case MAILIMAP_MEDIA_BASIC_OTHER: 911 case MAILIMAP_MEDIA_BASIC_OTHER:
912 default: 912 default:
913 if (which->bd_media_basic->med_basic_type) { 913 if (which->bd_media_basic->med_basic_type) {
914 type = which->bd_media_basic->med_basic_type; 914 type = which->bd_media_basic->med_basic_type;
915 } else { 915 } else {
916 type = ""; 916 type = "";
917 } 917 }
918 break; 918 break;
919 } 919 }
920 if (which->bd_media_basic->med_subtype) { 920 if (which->bd_media_basic->med_subtype) {
921 sub = which->bd_media_basic->med_subtype; 921 sub = which->bd_media_basic->med_subtype;
922 } else { 922 } else {
923 sub = ""; 923 sub = "";
924 } 924 }
925 // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; 925 // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl;
926 target_part->setType(type.lower()); 926 target_part->setType(type.lower());
927 target_part->setSubtype(sub.lower()); 927 target_part->setSubtype(sub.lower());
928 fillBodyFields(target_part,which->bd_fields); 928 fillBodyFields(target_part,which->bd_fields);
929} 929}
930 930
931void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) 931void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which)
932{ 932{
933 if (!which) return; 933 if (!which) return;
934 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { 934 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) {
935 clistcell*cur; 935 clistcell*cur;
936 mailimap_single_body_fld_param*param=0; 936 mailimap_single_body_fld_param*param=0;
937 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { 937 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
938 param = (mailimap_single_body_fld_param*)cur->data; 938 param = (mailimap_single_body_fld_param*)cur->data;
939 if (param) { 939 if (param) {
940 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 940 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
941 } 941 }
942 } 942 }
943 } 943 }
944 mailimap_body_fld_enc*enc = which->bd_encoding; 944 mailimap_body_fld_enc*enc = which->bd_encoding;
945 QString encoding(""); 945 QString encoding("");
946 switch (enc->enc_type) { 946 switch (enc->enc_type) {
947 case MAILIMAP_BODY_FLD_ENC_7BIT: 947 case MAILIMAP_BODY_FLD_ENC_7BIT:
948 encoding = "7bit"; 948 encoding = "7bit";
949 break; 949 break;
950 case MAILIMAP_BODY_FLD_ENC_8BIT: 950 case MAILIMAP_BODY_FLD_ENC_8BIT:
951 encoding = "8bit"; 951 encoding = "8bit";
952 break; 952 break;
953 case MAILIMAP_BODY_FLD_ENC_BINARY: 953 case MAILIMAP_BODY_FLD_ENC_BINARY:
954 encoding="binary"; 954 encoding="binary";
955 break; 955 break;
diff --git a/kmicromail/libmailwrapper/mailwrapper.h b/kmicromail/libmailwrapper/mailwrapper.h
index ea6bf36..3e8b51f 100644
--- a/kmicromail/libmailwrapper/mailwrapper.h
+++ b/kmicromail/libmailwrapper/mailwrapper.h
@@ -1,131 +1,131 @@
1#ifndef MAILWRAPPER_H 1#ifndef MAILWRAPPER_H
2#define MAILWRAPPER_H 2#define MAILWRAPPER_H
3 3
4//#include <qpe/applnk.h> 4//#include <qpe/applnk.h>
5 5
6#include <qbitarray.h> 6#include <qbitarray.h>
7#include <qdatetime.h> 7#include <qdatetime.h>
8#include <qfileinfo.h> 8#include <qfileinfo.h>
9#include <kiconloader.h> 9#include <kiconloader.h>
10 10
11#include "settings.h" 11#include "settings.h"
12 12
13#include <opie2/osmartpointer.h> 13#include <opie2/osmartpointer.h>
14/* 14/*
15class Attachment 15class Attachment
16{ 16{
17public: 17public:
18 Attachment( DocLnk lnk ); 18 Attachment( DocLnk lnk );
19 virtual ~Attachment(){} 19 virtual ~Attachment(){}
20 const QString getFileName()const{ return doc.file(); } 20 const QString getFileName()const{ return doc.file(); }
21 const QString getName()const{ return doc.name(); } 21 const QString getName()const{ return doc.name(); }
22 const QString getMimeType()const{ return doc.type(); } 22 const QString getMimeType()const{ return doc.type(); }
23 const QPixmap getPixmap()const{ return doc.pixmap(); } 23 const QPixmap getPixmap()const{ return doc.pixmap(); }
24 const int getSize()const { return size; } 24 const int getSize()const { return size; }
25 DocLnk getDocLnk() { return doc; } 25 DocLnk getDocLnk() { return doc; }
26 26
27protected: 27protected:
28 DocLnk doc; 28 DocLnk doc;
29 int size; 29 int size;
30 30
31}; 31};
32*/ 32*/
33 33
34class Attachment 34class Attachment
35{ 35{
36public: 36public:
37 Attachment( QString lnk ); 37 Attachment( QString lnk );
38 virtual ~Attachment(){} 38 virtual ~Attachment(){}
39 const QString getFileName()const{ return doc; } 39 const QString getFileName()const{ return doc; }
40 const QString getName()const{ return QFileInfo( doc ).baseName (); } 40 const QString getName()const{ return QFileInfo( doc ).baseName (); }
41 const QString getMimeType()const{ return QFileInfo( doc ).extension(false); } 41 const QString getMimeType()const{ return QFileInfo( doc ).extension(false); }
42 const QPixmap getPixmap()const{ return mPix; } 42 const QPixmap getPixmap()const{ return mPix; }
43 const int getSize()const { return size; } 43 const int getSize()const { return size; }
44 QString getDocLnk() { return doc; } 44 QString getDocLnk() { return doc; }
45 45
46protected: 46protected:
47 QPixmap mPix; 47 QPixmap mPix;
48 QString doc; 48 QString doc;
49 int size; 49 int size;
50 50
51}; 51};
52 52
53class Mail:public Opie::Core::ORefCount 53class Mail:public Opie::Core::ORefCount
54{ 54{
55public: 55public:
56 Mail(); 56 Mail();
57 /* Possible that this destructor must not be declared virtual 57 /* Possible that this destructor must not be declared virtual
58 * 'cause it seems that it will never have some child classes. 58 * 'cause it seems that it will never have some child classes.
59 * in this case this object will not get a virtual table -> memory and 59 * in this case this object will not get a virtual table -> memory and
60 * speed will be a little bit better? 60 * speed will be a little bit better?
61 */ 61 */
62 virtual ~Mail(){} 62 virtual ~Mail(){}
63 void addAttachment( Attachment *att ) { attList.append( att ); } 63 void addAttachment( Attachment *att ) { attList.append( att ); }
64 const QList<Attachment>& getAttachments()const { return attList; } 64 const QList<Attachment>& getAttachments()const { return attList; }
65 void removeAttachment( Attachment *att ) { attList.remove( att ); } 65 void removeAttachment( Attachment *att ) { attList.remove( att ); }
66 const QString&getName()const { return name; } 66 const QString&getName()const { return name; }
67 void setName( QString s ) { name = s; } 67 void setName( QString s ) { name = s; }
68 const QString&getMail()const{ return mail; } 68 const QString&getMail()const{ return mail; }
69 void setMail( const QString&s ) { mail = s; } 69 void setMail( const QString&s ) { mail = s; }
70 const QString&getTo()const{ return to; } 70 const QString&getTo()const{ return to; }
71 void setTo( const QString&s ) { to = s; } 71 void setTo( const QString&s ) { to = s; }
72 const QString&getCC()const{ return cc; } 72 const QString&getCC()const{ return cc; }
73 void setCC( const QString&s ) { cc = s; } 73 void setCC( const QString&s ) { cc = s; }
74 const QString&getBCC()const { return bcc; } 74 const QString&getBCC()const { return bcc; }
75 void setBCC( const QString&s ) { bcc = s; } 75 void setBCC( const QString&s ) { bcc = s; }
76 const QString&getMessage()const { return message; } 76 const QString&getMessage()const { return message; }
77 void setMessage( const QString&s ) { message = s; } 77 void setMessage( const QString&s ) { message = s; }
78 const QString&getSubject()const { return subject; } 78 const QString&getSubject()const { return subject; }
79 void setSubject( const QString&s ) { subject = s; } 79 void setSubject( const QString&s ) { subject = s; }
80 const QString&getReply()const{ return reply; } 80 const QString&getReply()const{ return reply; }
81 void setReply( const QString&a ) { reply = a; } 81 void setReply( const QString&a ) { reply = a; }
82 void setInreply(const QStringList&list){m_in_reply_to = list;} 82 void setInreply(const QStringList&list){m_in_reply_to = list;}
83 const QStringList&Inreply()const{return m_in_reply_to;} 83 const QStringList&Inreply()const{return m_in_reply_to;}
84 84
85 void setCharset( const QString&a ) { charset= a; } 85 void setCharset( const QString&a ) { charset= a; }
86 const QString& getCharset() { return charset; } 86 const QString& getCharset() const { return charset; }
87 87
88private: 88private:
89 QList<Attachment> attList; 89 QList<Attachment> attList;
90 QString name, mail, to, cc, bcc, reply, subject, message, charset; 90 QString name, mail, to, cc, bcc, reply, subject, message, charset;
91 QStringList m_in_reply_to; 91 QStringList m_in_reply_to;
92}; 92};
93 93
94class Folder:public Opie::Core::ORefCount 94class Folder:public Opie::Core::ORefCount
95{ 95{
96public: 96public:
97 Folder( const QString&init_name,const QString&sep ); 97 Folder( const QString&init_name,const QString&sep );
98 virtual ~Folder(); 98 virtual ~Folder();
99 const QString&getDisplayName()const { return nameDisplay; } 99 const QString&getDisplayName()const { return nameDisplay; }
100 const QString&getName()const { return name; } 100 const QString&getName()const { return name; }
101 const QString&getPrefix()const{return prefix; } 101 const QString&getPrefix()const{return prefix; }
102 virtual bool may_select()const{return true;} 102 virtual bool may_select()const{return true;}
103 virtual bool no_inferior()const{return true;} 103 virtual bool no_inferior()const{return true;}
104 const QString&Separator()const; 104 const QString&Separator()const;
105 105
106protected: 106protected:
107 QString nameDisplay, name, separator,prefix; 107 QString nameDisplay, name, separator,prefix;
108}; 108};
109 109
110typedef Opie::Core::OSmartPointer<Folder> FolderP; 110typedef Opie::Core::OSmartPointer<Folder> FolderP;
111 111
112class MHFolder : public Folder 112class MHFolder : public Folder
113{ 113{
114public: 114public:
115 MHFolder(const QString&disp_name,const QString&mbox); 115 MHFolder(const QString&disp_name,const QString&mbox);
116 virtual ~MHFolder(); 116 virtual ~MHFolder();
117}; 117};
118 118
119class IMAPFolder : public Folder 119class IMAPFolder : public Folder
120{ 120{
121 public: 121 public:
122 IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" ); 122 IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" );
123 virtual ~IMAPFolder(); 123 virtual ~IMAPFolder();
124 virtual bool may_select()const{return m_MaySelect;} 124 virtual bool may_select()const{return m_MaySelect;}
125 virtual bool no_inferior()const{return m_NoInferior;} 125 virtual bool no_inferior()const{return m_NoInferior;}
126 static QString decodeFolderName( const QString &name ); 126 static QString decodeFolderName( const QString &name );
127 private: 127 private:
128 bool m_MaySelect,m_NoInferior; 128 bool m_MaySelect,m_NoInferior;
129}; 129};
130 130
131#endif 131#endif
diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp
index 3013931..8c0a4cb 100644
--- a/kmicromail/mainwindow.cpp
+++ b/kmicromail/mainwindow.cpp
@@ -1,302 +1,303 @@
1 1
2// CHANGED 2004-08-06 Lutz Rogowski 2// CHANGED 2004-08-06 Lutz Rogowski
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qvbox.h> 4#include <qvbox.h>
5#include <qheader.h> 5#include <qheader.h>
6#include <qtimer.h> 6#include <qtimer.h>
7#include <qlayout.h> 7#include <qlayout.h>
8//#include <kdialog.h> 8//#include <kdialog.h>
9#include <kiconloader.h> 9#include <kiconloader.h>
10#include <kapplication.h> 10#include <kapplication.h>
11 11
12#ifdef DESKTOP_VERSION 12#ifdef DESKTOP_VERSION
13#include <qapplication.h> 13#include <qapplication.h>
14#include <qstatusbar.h> 14#include <qstatusbar.h>
15#include <kabc/stdaddressbook.h> 15#include <kabc/stdaddressbook.h>
16extern QStatusBar* globalSstatusBarMainWindow; 16extern QStatusBar* globalSstatusBarMainWindow;
17#else 17#else
18#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
19#endif 19#endif
20#include "defines.h" 20#include "defines.h"
21#include "mainwindow.h" 21#include "mainwindow.h"
22#include <KDGanttMinimizeSplitter.h> 22#include <KDGanttMinimizeSplitter.h>
23 23
24#include "koprefs.h" 24#include "koprefs.h"
25 25
26MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 26MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
27 : QMainWindow( parent, name ) //, flags ) 27 : QMainWindow( parent, name ) //, flags )
28{ 28{
29#ifdef DESKTOP_VERSION 29#ifdef DESKTOP_VERSION
30 globalSstatusBarMainWindow = statusBar(); 30 globalSstatusBarMainWindow = statusBar();
31#endif 31#endif
32 setCaption( i18n( "KOpieMail/Pi" ) ); 32 setCaption( i18n( "KOpieMail/Pi" ) );
33 setToolBarsMovable( false ); 33 setToolBarsMovable( false );
34 //KABC::StdAddressBook::self(); 34 //KABC::StdAddressBook::self();
35 toolBar = new QToolBar( this ); 35 toolBar = new QToolBar( this );
36 menuBar = new QPEMenuBar( toolBar ); 36 menuBar = new QPEMenuBar( toolBar );
37 mailMenu = new QPopupMenu( menuBar ); 37 mailMenu = new QPopupMenu( menuBar );
38 menuBar->insertItem( i18n( "Mail" ), mailMenu ); 38 menuBar->insertItem( i18n( "Mail" ), mailMenu );
39 settingsMenu = new QPopupMenu( menuBar ); 39 settingsMenu = new QPopupMenu( menuBar );
40 menuBar->insertItem( i18n( "Settings" ), settingsMenu ); 40 menuBar->insertItem( i18n( "Settings" ), settingsMenu );
41 41
42 addToolBar( toolBar ); 42 addToolBar( toolBar );
43 toolBar->setHorizontalStretchable( true ); 43 toolBar->setHorizontalStretchable( true );
44 QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"), 44 QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"),
45 0, 0, this ); 45 0, 0, this );
46 connect(getMail, SIGNAL( activated() ), 46 connect(getMail, SIGNAL( activated() ),
47 SLOT( slotGetAllMail() ) ); 47 SLOT( slotGetAllMail() ) );
48 getMail->addTo( mailMenu ); 48 getMail->addTo( mailMenu );
49 49
50 getMail = new QAction( i18n( "Get new messages" ), SmallIcon("add"), 50 getMail = new QAction( i18n( "Get new messages" ), SmallIcon("add"),
51 0, 0, this ); 51 0, 0, this );
52 getMail->addTo( toolBar ); 52 getMail->addTo( toolBar );
53 getMail->addTo( mailMenu ); 53 getMail->addTo( mailMenu );
54 connect(getMail, SIGNAL( activated() ), 54 connect(getMail, SIGNAL( activated() ),
55 SLOT( slotGetMail() ) ); 55 SLOT( slotGetMail() ) );
56 56
57 composeMail = new QAction( i18n( "Compose new mail" ), SmallIcon("composemail"), 57 composeMail = new QAction( i18n( "Compose new mail" ), SmallIcon("composemail"),
58 0, 0, this ); 58 0, 0, this );
59 composeMail->addTo( toolBar ); 59 composeMail->addTo( toolBar );
60 composeMail->addTo( mailMenu ); 60 composeMail->addTo( mailMenu );
61 61
62 sendQueued = new QAction( i18n( "Send queued mails" ), SmallIcon("sendqueued") , 62 sendQueued = new QAction( i18n( "Send queued mails" ), SmallIcon("sendqueued") ,
63 0, 0, this ); 63 0, 0, this );
64 sendQueued->addTo( toolBar ); 64 sendQueued->addTo( toolBar );
65 sendQueued->addTo( mailMenu ); 65 sendQueued->addTo( mailMenu );
66 66
67 /* 67 /*
68 syncFolders = new QAction( i18n( "Sync mailfolders" ), ICON_SYNC, 68 syncFolders = new QAction( i18n( "Sync mailfolders" ), ICON_SYNC,
69 0, 0, this ); 69 0, 0, this );
70 syncFolders->addTo( toolBar ); 70 syncFolders->addTo( toolBar );
71 syncFolders->addTo( mailMenu ); 71 syncFolders->addTo( mailMenu );
72 */ 72 */
73 73
74 showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") , 74 showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") ,
75 0, 0, this, 0, true ); 75 0, 0, this, 0, true );
76 showFolders->addTo( toolBar ); 76 showFolders->addTo( toolBar );
77 showFolders->addTo( mailMenu ); 77 showFolders->addTo( mailMenu );
78 showFolders->setOn( true ); 78 showFolders->setOn( true );
79 connect(showFolders, SIGNAL( toggled(bool) ), 79 connect(showFolders, SIGNAL( toggled(bool) ),
80 SLOT( slotShowFolders(bool) ) ); 80 SLOT( slotShowFolders(bool) ) );
81 81
82 /* 82 /*
83 searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ), 83 searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ),
84 0, 0, this ); 84 0, 0, this );
85 searchMails->addTo( toolBar ); 85 searchMails->addTo( toolBar );
86 searchMails->addTo( mailMenu ); 86 searchMails->addTo( mailMenu );
87 */ 87 */
88 88
89 deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this); 89 deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this);
90 deleteMails->addTo( toolBar ); 90 deleteMails->addTo( toolBar );
91 deleteMails->addTo( mailMenu ); 91 deleteMails->addTo( mailMenu );
92 connect( deleteMails, SIGNAL( activated() ), 92 connect( deleteMails, SIGNAL( activated() ),
93 SLOT( slotDeleteMail() ) ); 93 SLOT( slotDeleteMail() ) );
94 94
95 editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") , 95 editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") ,
96 0, 0, this ); 96 0, 0, this );
97 editSettings->addTo( settingsMenu ); 97 editSettings->addTo( settingsMenu );
98 connect( editSettings, SIGNAL( activated() ), 98 connect( editSettings, SIGNAL( activated() ),
99 SLOT( slotEditSettings() ) ); 99 SLOT( slotEditSettings() ) );
100 editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") , 100 editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") ,
101 0, 0, this ); 101 0, 0, this );
102 editAccounts->addTo( settingsMenu ); 102 editAccounts->addTo( settingsMenu );
103 codecMenu = new QPopupMenu( menuBar ); 103 codecMenu = new QPopupMenu( menuBar );
104 codecMenu->insertItem( "Western (iso-8859-1)",0,0); 104 codecMenu->insertItem( "Western (iso-8859-1)",0,0);
105 codecMenu->insertItem( "Cyrillic (iso-8859-5)",1,1); 105 codecMenu->insertItem( "Cyrillic (iso-8859-5)",1,1);
106 codecMenu->insertItem( "Western (iso-8859-15)",2,2); 106 codecMenu->insertItem( "Western (iso-8859-15)",2,2);
107 codecMenu->insertItem( "Chinese (big-5)",3,3); 107 codecMenu->insertItem( "Chinese (big-5)",3,3);
108 codecMenu->insertItem( "Unicode (utf-8)",4,4); 108 codecMenu->insertItem( "Unicode (utf-8)",4,4);
109 codecMenu->insertItem( "Userdefined ("+KOPrefs::instance()->mSendCodec+")",5,5); 109 codecMenu->insertItem( "Userdefined ("+KOPrefs::instance()->mSendCodec+")",5,5);
110 settingsMenu->insertItem( i18n("Codec for new mails"), codecMenu); 110 //disabled
111 //settingsMenu->insertItem( i18n("Codec for new mails"), codecMenu);
111 //setCentralWidget( view ); 112 //setCentralWidget( view );
112 113
113 QVBox* wrapperBox = new QVBox( this ); 114 QVBox* wrapperBox = new QVBox( this );
114 setCentralWidget( wrapperBox ); 115 setCentralWidget( wrapperBox );
115 116
116 // QWidget *view = new QWidget( wrapperBox ); 117 // QWidget *view = new QWidget( wrapperBox );
117 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); 118 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox);
118 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); 119 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left);
119 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); 120 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight );
120 121
121 folderView = new AccountView( split ); 122 folderView = new AccountView( split );
122 folderView->header()->hide(); 123 folderView->header()->hide();
123 folderView->setRootIsDecorated( false ); 124 folderView->setRootIsDecorated( false );
124 folderView->addColumn( i18n( "Mailbox" ) ); 125 folderView->addColumn( i18n( "Mailbox" ) );
125 126
126 //layout->addWidget( folderView ); 127 //layout->addWidget( folderView );
127 128
128 mailView = new QListView( split ); 129 mailView = new QListView( split );
129 mailView->addColumn( i18n( " " ) ); 130 mailView->addColumn( i18n( " " ) );
130 mailView->addColumn( i18n( "Subject" ),QListView::Manual ); 131 mailView->addColumn( i18n( "Subject" ),QListView::Manual );
131 mailView->addColumn( i18n( "Sender" ),QListView::Manual ); 132 mailView->addColumn( i18n( "Sender" ),QListView::Manual );
132 mailView->addColumn( i18n( "Size" ),QListView::Manual); 133 mailView->addColumn( i18n( "Size" ),QListView::Manual);
133 mailView->addColumn( i18n( "Date" ),QListView::Manual); 134 mailView->addColumn( i18n( "Date" ),QListView::Manual);
134 mailView->setAllColumnsShowFocus(true); 135 mailView->setAllColumnsShowFocus(true);
135 //mailView->setSorting(-1); 136 //mailView->setSorting(-1);
136 mailView->setRootIsDecorated( false ); 137 mailView->setRootIsDecorated( false );
137 statusWidget = new StatusWidget( wrapperBox ); 138 statusWidget = new StatusWidget( wrapperBox );
138 statusWidget->hide(); 139 statusWidget->hide();
139 140
140 //layout->addWidget( mailView ); 141 //layout->addWidget( mailView );
141 //layout->setStretchFactor( folderView, 1 ); 142 //layout->setStretchFactor( folderView, 1 );
142 //layout->setStretchFactor( mailView, 2 ); 143 //layout->setStretchFactor( mailView, 2 );
143 144
144 slotAdjustLayout(); 145 slotAdjustLayout();
145#ifndef DESKTOP_VERSION 146#ifndef DESKTOP_VERSION
146 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); 147 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold);
147 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); 148 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold);
148#endif 149#endif
149 connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this, 150 connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this,
150 SLOT( mailLeftClicked(QListViewItem*) ) ); 151 SLOT( mailLeftClicked(QListViewItem*) ) );
151 connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this, 152 connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this,
152 SLOT( mailLeftClicked(QListViewItem*) ) ); 153 SLOT( mailLeftClicked(QListViewItem*) ) );
153 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, 154 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
154 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); 155 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) );
155 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), 156 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)),
156 this,SLOT(refreshMailView(const QValueList<RecMailP>&))); 157 this,SLOT(refreshMailView(const QValueList<RecMailP>&)));
157 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); 158 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) );
158 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); 159 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) );
159// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); 160// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) );
160 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); 161 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) );
161 //mailView->setMultiSelection ( true ); 162 //mailView->setMultiSelection ( true );
162 mailView->setSelectionMode( QListView::Extended ); 163 mailView->setSelectionMode( QListView::Extended );
163 QValueList<int> list; 164 QValueList<int> list;
164 int fw = 100; 165 int fw = 100;
165 if ( QApplication::desktop()->width() > 320 ) 166 if ( QApplication::desktop()->width() > 320 )
166 fw = 50; 167 fw = 50;
167 list.append( fw ); 168 list.append( fw );
168 list.append( 100 ); 169 list.append( 100 );
169 split->setSizes( list ); 170 split->setSizes( list );
170 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 171 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
171 mailView->setShowSortIndicator ( true ); 172 mailView->setShowSortIndicator ( true );
172 QLabel *spacer = new QLabel( toolBar ); 173 QLabel *spacer = new QLabel( toolBar );
173 spacer->setBackgroundMode( QWidget::PaletteButton ); 174 spacer->setBackgroundMode( QWidget::PaletteButton );
174 toolBar->setStretchableWidget( spacer ); 175 toolBar->setStretchableWidget( spacer );
175 176
176 QAction* closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); 177 QAction* closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this);
177 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 178 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
178 if ( QApplication::desktop()->width() > 320 ) 179 if ( QApplication::desktop()->width() > 320 )
179 closeMail->addTo(toolBar); 180 closeMail->addTo(toolBar);
180 closeMail->addTo(mailMenu); 181 closeMail->addTo(mailMenu);
181 182
182 183
183 QPopupMenu* helpMenu = new QPopupMenu( menuBar ); 184 QPopupMenu* helpMenu = new QPopupMenu( menuBar );
184 menuBar->insertItem( i18n( "Help" ), helpMenu ); 185 menuBar->insertItem( i18n( "Help" ), helpMenu );
185 QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this); 186 QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this);
186 connect( li, SIGNAL( activated() ), SLOT( showAbout()) ); 187 connect( li, SIGNAL( activated() ), SLOT( showAbout()) );
187 li->addTo(helpMenu); 188 li->addTo(helpMenu);
188 li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this); 189 li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this);
189 connect( li, SIGNAL( activated() ), SLOT( showLicence()) ); 190 connect( li, SIGNAL( activated() ), SLOT( showLicence()) );
190 li->addTo(helpMenu); 191 li->addTo(helpMenu);
191 li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this); 192 li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this);
192 connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) ); 193 connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) );
193 li->addTo(helpMenu); 194 li->addTo(helpMenu);
194 connect( codecMenu, SIGNAL( activated(int) ), this, SLOT( slotSetCodec( int )) ); 195 connect( codecMenu, SIGNAL( activated(int) ), this, SLOT( slotSetCodec( int )) );
195 slotSetCodec( KOPrefs::instance()->mCurrentCodec ); 196 slotSetCodec( KOPrefs::instance()->mCurrentCodec );
196#ifdef DESKTOP_VERSION 197#ifdef DESKTOP_VERSION
197 resize ( 640, 480 ); 198 resize ( 640, 480 );
198#endif 199#endif
199} 200}
200 201
201MainWindow::~MainWindow() 202MainWindow::~MainWindow()
202{ 203{
203} 204}
204 205
205void MainWindow::slotSetCodec( int codec ) 206void MainWindow::slotSetCodec( int codec )
206{ 207{
207 codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, false ); 208 codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, false );
208 //qDebug("codec %d ", codec); 209 //qDebug("codec %d ", codec);
209 KOPrefs::instance()->mCurrentCodec = codec; 210 KOPrefs::instance()->mCurrentCodec = codec;
210 KOPrefs::instance()->isDirty = true; 211 KOPrefs::instance()->isDirty = true;
211 QString name; 212 QString name;
212 switch ( codec ) { 213 switch ( codec ) {
213 case 0: 214 case 0:
214 name = "iso-8859-1"; 215 name = "iso-8859-1";
215 break; 216 break;
216 case 1: 217 case 1:
217 name = "iso-8859-5"; 218 name = "iso-8859-5";
218 break; 219 break;
219 case 2: 220 case 2:
220 name = "iso-8859-15"; 221 name = "iso-8859-15";
221 break; 222 break;
222 case 3: 223 case 3:
223 name = "big-5"; 224 name = "big-5";
224 break; 225 break;
225 case 4: 226 case 4:
226 name = "utf-8"; 227 name = "utf-8";
227 break; 228 break;
228 case 5: 229 case 5:
229 name = KOPrefs::instance()->mSendCodec.lower(); 230 name = KOPrefs::instance()->mSendCodec.lower();
230 break; 231 break;
231 } 232 }
232 KOPrefs::instance()->mCurrentCodeName = name ; 233 KOPrefs::instance()->mCurrentCodeName = name ;
233 codecMenu->changeItem ( 5, "Userdefined ("+KOPrefs::instance()->mSendCodec+")"); 234 codecMenu->changeItem ( 5, "Userdefined ("+KOPrefs::instance()->mSendCodec+")");
234 codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, true ); 235 codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, true );
235} 236}
236void MainWindow::showLicence() 237void MainWindow::showLicence()
237{ 238{
238 KApplication::showLicence(); 239 KApplication::showLicence();
239} 240}
240void MainWindow::showAbout() 241void MainWindow::showAbout()
241{ 242{
242 QString version; 243 QString version;
243#include <../version> 244#include <../version>
244 245
245 QString cap = "About KOpieMail/Pi"; 246 QString cap = "About KOpieMail/Pi";
246 QString text =i18n("KOpieMail/Platform-independent\n") + 247 QString text =i18n("KOpieMail/Platform-independent\n") +
247 "(OM/Pi) " + version + " - " 248 "(OM/Pi) " + version + " - "
248 249
249#ifdef DESKTOP_VERSION 250#ifdef DESKTOP_VERSION
250 "Desktop Edition\n" 251 "Desktop Edition\n"
251#else 252#else
252 "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n" 253 "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n"
253#endif 254#endif
254 "www.pi-sync.net\n\n" 255 "www.pi-sync.net\n\n"
255 256
256 257
257 258
258"Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n" 259"Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n"
259 "KOpieMail/Pi is based on Opie Mail\n" 260 "KOpieMail/Pi is based on Opie Mail\n"
260 "Copyright (c) Rajko Albrecht and the Opie team\n" 261 "Copyright (c) Rajko Albrecht and the Opie team\n"
261 "KOpieMail/Pi is licensed under the GPL\n" 262 "KOpieMail/Pi is licensed under the GPL\n"
262 "\n" 263 "\n"
263 "KOpieMail/Pi uses LibEtPan - a mail stuff library\n" 264 "KOpieMail/Pi uses LibEtPan - a mail stuff library\n"
264 "Copyright (C) 2001, 2002 - DINH Viet Hoa\n" 265 "Copyright (C) 2001, 2002 - DINH Viet Hoa\n"
265 "libEtPan has its own licence - see LibEtPan licence\n"; 266 "libEtPan has its own licence - see LibEtPan licence\n";
266 267
267 KApplication::showText( cap, text ); 268 KApplication::showText( cap, text );
268} 269}
269void MainWindow::showEtpanLicence() 270void MainWindow::showEtpanLicence()
270{ 271{
271 KApplication::showFile( "LibEtPan licence", "kdepim/kopiemail/COPYRIGHTlibetpan" ); 272 KApplication::showFile( "LibEtPan licence", "kdepim/kopiemail/COPYRIGHTlibetpan" );
272 273
273} 274}
274void MainWindow::appMessage(const QCString &, const QByteArray &) 275void MainWindow::appMessage(const QCString &, const QByteArray &)
275{ 276{
276 qDebug("appMessage implemented by subclass"); 277 qDebug("appMessage implemented by subclass");
277} 278}
278 279
279void MainWindow::slotAdjustLayout() { 280void MainWindow::slotAdjustLayout() {
280 281
281 /* 282 /*
282 QWidget *d = QApplication::desktop(); 283 QWidget *d = QApplication::desktop();
283 284
284 if ( d->width() < d->height() ) { 285 if ( d->width() < d->height() ) {
285 layout->setDirection( QBoxLayout::TopToBottom ); 286 layout->setDirection( QBoxLayout::TopToBottom );
286 } else { 287 } else {
287 layout->setDirection( QBoxLayout::LeftToRight ); 288 layout->setDirection( QBoxLayout::LeftToRight );
288 } 289 }
289 */ 290 */
290} 291}
291 292
292void MainWindow::slotAdjustColumns() 293void MainWindow::slotAdjustColumns()
293{ 294{
294 bool hidden = folderView->isHidden(); 295 bool hidden = folderView->isHidden();
295 if ( hidden ) folderView->show(); 296 if ( hidden ) folderView->show();
296 folderView->setColumnWidth( 0, folderView->visibleWidth() ); 297 folderView->setColumnWidth( 0, folderView->visibleWidth() );
297 if ( hidden ) folderView->hide(); 298 if ( hidden ) folderView->hide();
298 299
299 mailView->setColumnWidth( 0, 10 ); 300 mailView->setColumnWidth( 0, 10 );
300 mailView->setColumnWidth( 1, 100 ); 301 mailView->setColumnWidth( 1, 100 );
301 mailView->setColumnWidth( 2, 100 ); 302 mailView->setColumnWidth( 2, 100 );
302 mailView->setColumnWidth( 3, 50 ); 303 mailView->setColumnWidth( 3, 50 );
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp
index 1da1e99..d7e384c 100644
--- a/microkde/kdecore/klocale.cpp
+++ b/microkde/kdecore/klocale.cpp
@@ -679,401 +679,402 @@ QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const
679QDateTime KLocale::readDateTime(const QString &intstr, 679QDateTime KLocale::readDateTime(const QString &intstr,
680 IntDateFormat intIntDateFormat, 680 IntDateFormat intIntDateFormat,
681 bool* ok) const 681 bool* ok) const
682{ 682{
683 bool ok1, ok2; 683 bool ok1, ok2;
684 684
685 // AT the moment we can not read any other format then ISODate 685 // AT the moment we can not read any other format then ISODate
686 if ( intIntDateFormat != ISODate ) 686 if ( intIntDateFormat != ISODate )
687 { 687 {
688 qDebug("KLocale::readDateTime, only ISODate is supported."); 688 qDebug("KLocale::readDateTime, only ISODate is supported.");
689 return QDateTime(); 689 return QDateTime();
690 } 690 }
691 691
692 int pos = intstr.find("T"); 692 int pos = intstr.find("T");
693 QString date = intstr.left(pos); 693 QString date = intstr.left(pos);
694 QString time = intstr.mid(pos+1); 694 QString time = intstr.mid(pos+1);
695 695
696 QString dformat = dateFormat(intIntDateFormat); 696 QString dformat = dateFormat(intIntDateFormat);
697 QString tformat = timeFormat(intIntDateFormat); 697 QString tformat = timeFormat(intIntDateFormat);
698 698
699 QDate m_date = readDate(date, dformat, &ok1); 699 QDate m_date = readDate(date, dformat, &ok1);
700 QTime m_time = readTime(time, tformat, &ok2); 700 QTime m_time = readTime(time, tformat, &ok2);
701 701
702 QDateTime m_dt; 702 QDateTime m_dt;
703 703
704 if (ok) 704 if (ok)
705 { 705 {
706 if ((ok1 == false) || (ok2 == false)) 706 if ((ok1 == false) || (ok2 == false))
707 *ok = false; 707 *ok = false;
708 else 708 else
709 *ok = true; 709 *ok = true;
710 } 710 }
711 711
712 //only set values if both operations returned true. 712 //only set values if both operations returned true.
713 if ((ok1 == true) && (ok2 == true)) 713 if ((ok1 == true) && (ok2 == true))
714 { 714 {
715 m_dt.setDate(m_date); 715 m_dt.setDate(m_date);
716 m_dt.setTime(m_time); 716 m_dt.setTime(m_time);
717 } 717 }
718 718
719 //qDebug("KLocale::readDateTime() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); 719 //qDebug("KLocale::readDateTime() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2);
720 return m_dt; 720 return m_dt;
721} 721}
722 722
723QDate KLocale::readDate(const QString &intstr, 723QDate KLocale::readDate(const QString &intstr,
724 IntDateFormat intIntDateFormat, 724 IntDateFormat intIntDateFormat,
725 bool* ok) const 725 bool* ok) const
726{ 726{
727 bool ok1; 727 bool ok1;
728 728
729 QString dformat = dateFormat(intIntDateFormat); 729 QString dformat = dateFormat(intIntDateFormat);
730 730
731 QDate m_date = readDate(intstr, dformat, &ok1); 731 QDate m_date = readDate(intstr, dformat, &ok1);
732 732
733 if (ok) 733 if (ok)
734 *ok = ok1; 734 *ok = ok1;
735 735
736 //qDebug("KLocale::readDate() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); 736 //qDebug("KLocale::readDate() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2);
737 return m_date; 737 return m_date;
738} 738}
739 739
740 740
741bool KLocale::use12Clock() const 741bool KLocale::use12Clock() const
742{ 742{
743 return !mHourF24Format ;; 743 return !mHourF24Format ;;
744} 744}
745 745
746bool KLocale::weekStartsMonday() const 746bool KLocale::weekStartsMonday() const
747{ 747{
748 return mWeekStartsMonday; 748 return mWeekStartsMonday;
749} 749}
750 750
751int KLocale::weekStartDay() const 751int KLocale::weekStartDay() const
752{ 752{
753 if ( mWeekStartsMonday ) 753 if ( mWeekStartsMonday )
754 return 1; 754 return 1;
755 return 7; 755 return 7;
756} 756}
757 757
758QString KLocale::weekDayName(int i,bool shortName) const 758QString KLocale::weekDayName(int i,bool shortName) const
759{ 759{
760 if ( shortName ) 760 if ( shortName )
761 switch ( i ) 761 switch ( i )
762 { 762 {
763 case 1: return i18n("Monday", "Mon"); 763 case 1: return i18n("Monday", "Mon");
764 case 2: return i18n("Tuesday", "Tue"); 764 case 2: return i18n("Tuesday", "Tue");
765 case 3: return i18n("Wednesday", "Wed"); 765 case 3: return i18n("Wednesday", "Wed");
766 case 4: return i18n("Thursday", "Thu"); 766 case 4: return i18n("Thursday", "Thu");
767 case 5: return i18n("Friday", "Fri"); 767 case 5: return i18n("Friday", "Fri");
768 case 6: return i18n("Saturday", "Sat"); 768 case 6: return i18n("Saturday", "Sat");
769 case 7: return i18n("Sunday", "Sun"); 769 case 7: return i18n("Sunday", "Sun");
770 } 770 }
771 else 771 else
772 switch ( i ) 772 switch ( i )
773 { 773 {
774 case 1: return i18n("Monday"); 774 case 1: return i18n("Monday");
775 case 2: return i18n("Tuesday"); 775 case 2: return i18n("Tuesday");
776 case 3: return i18n("Wednesday"); 776 case 3: return i18n("Wednesday");
777 case 4: return i18n("Thursday"); 777 case 4: return i18n("Thursday");
778 case 5: return i18n("Friday"); 778 case 5: return i18n("Friday");
779 case 6: return i18n("Saturday"); 779 case 6: return i18n("Saturday");
780 case 7: return i18n("Sunday"); 780 case 7: return i18n("Sunday");
781 } 781 }
782 782
783 return QString::null; 783 return QString::null;
784} 784}
785 785
786QString KLocale::monthName(int i,bool shortName) const 786QString KLocale::monthName(int i,bool shortName) const
787{ 787{
788 if ( shortName ) 788 if ( shortName )
789 switch ( i ) 789 switch ( i )
790 { 790 {
791 case 1: return i18n("January", "Jan"); 791 case 1: return i18n("January", "Jan");
792 case 2: return i18n("February", "Feb"); 792 case 2: return i18n("February", "Feb");
793 case 3: return i18n("March", "Mar"); 793 case 3: return i18n("March", "Mar");
794 case 4: return i18n("April", "Apr"); 794 case 4: return i18n("April", "Apr");
795 case 5: return i18n("May short", "May"); 795 case 5: return i18n("May short", "May");
796 case 6: return i18n("June", "Jun"); 796 case 6: return i18n("June", "Jun");
797 case 7: return i18n("July", "Jul"); 797 case 7: return i18n("July", "Jul");
798 case 8: return i18n("August", "Aug"); 798 case 8: return i18n("August", "Aug");
799 case 9: return i18n("September", "Sep"); 799 case 9: return i18n("September", "Sep");
800 case 10: return i18n("October", "Oct"); 800 case 10: return i18n("October", "Oct");
801 case 11: return i18n("November", "Nov"); 801 case 11: return i18n("November", "Nov");
802 case 12: return i18n("December", "Dec"); 802 case 12: return i18n("December", "Dec");
803 } 803 }
804 else 804 else
805 switch (i) 805 switch (i)
806 { 806 {
807 case 1: return i18n("January"); 807 case 1: return i18n("January");
808 case 2: return i18n("February"); 808 case 2: return i18n("February");
809 case 3: return i18n("March"); 809 case 3: return i18n("March");
810 case 4: return i18n("April"); 810 case 4: return i18n("April");
811 case 5: return i18n("May long", "May"); 811 case 5: return i18n("May long", "May");
812 case 6: return i18n("June"); 812 case 6: return i18n("June");
813 case 7: return i18n("July"); 813 case 7: return i18n("July");
814 case 8: return i18n("August"); 814 case 8: return i18n("August");
815 case 9: return i18n("September"); 815 case 9: return i18n("September");
816 case 10: return i18n("October"); 816 case 10: return i18n("October");
817 case 11: return i18n("November"); 817 case 11: return i18n("November");
818 case 12: return i18n("December"); 818 case 12: return i18n("December");
819 } 819 }
820 820
821 return QString::null; 821 return QString::null;
822} 822}
823 823
824QString KLocale::country() const 824QString KLocale::country() const
825{ 825{
826 return QString::null; 826 return QString::null;
827} 827}
828 828
829QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const 829QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const
830{ 830{
831 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; 831 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat;
832 832
833 if ( dformat == ISODate ) 833 if ( dformat == ISODate )
834 return "%Y-%m-%d"; 834 return "%Y-%m-%d";
835 835
836 if ( QApplication::desktop()->width() < 480 ) { 836 if ( QApplication::desktop()->width() < 480 ) {
837 if ( dformat == Default ) 837 if ( dformat == Default )
838 return "%a %d %b %Y"; 838 return "%a %d %b %Y";
839 else if ( dformat == Format1 ) 839 else if ( dformat == Format1 )
840 return "%a %b %d %Y"; 840 return "%a %b %d %Y";
841 } else { 841 } else {
842 if ( dformat == Default ) 842 if ( dformat == Default )
843 return "%A %d %B %Y"; 843 return "%A %d %B %Y";
844 else if ( dformat == Format1 ) 844 else if ( dformat == Format1 )
845 return "%A %B %d %Y"; 845 return "%A %B %d %Y";
846 846
847 } 847 }
848 return mDateFormat ; 848 return mDateFormat ;
849} 849}
850 850
851QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const 851QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const
852{ 852{
853 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; 853 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat;
854 854
855 if ( dformat == Default ) 855 if ( dformat == Default )
856 return "%d.%m.%Y"; 856 return "%d.%m.%Y";
857 else if ( dformat == Format1 ) 857 else if ( dformat == Format1 )
858 return "%m.%d.%Y"; 858 return "%m.%d.%Y";
859 else if ( dformat == ISODate ) // = Qt::ISODate 859 else if ( dformat == ISODate ) // = Qt::ISODate
860 return "%Y-%m-%d"; 860 return "%Y-%m-%d";
861 return mDateFormatShort ; 861 return mDateFormatShort ;
862 862
863} 863}
864 864
865 865
866QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const 866QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const
867{ 867{
868 const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat; 868 const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat;
869 869
870 if ( tformat == Default ) 870 if ( tformat == Default )
871 if ( mHourF24Format) 871 if ( mHourF24Format)
872 return "%H:%M:%S"; 872 return "%H:%M:%S";
873 else 873 else
874 return "%I:%M:%S%p"; 874 return "%I:%M:%S%p";
875 875
876 else if ( tformat == Format1 ) 876 else if ( tformat == Format1 )
877 if ( mHourF24Format) 877 if ( mHourF24Format)
878 return "%H:%M:%S"; 878 return "%H:%M:%S";
879 else 879 else
880 return "%I:%M:%S%p"; 880 return "%I:%M:%S%p";
881 881
882 else if ( tformat == ISODate ) // = Qt::ISODate 882 else if ( tformat == ISODate ) // = Qt::ISODate
883 if ( mHourF24Format) 883 if ( mHourF24Format)
884 return "%H:%M:%S"; 884 return "%H:%M:%S";
885 else 885 else
886 return "%I:%M:%S%p"; 886 return "%I:%M:%S%p";
887 887 // to satisfy the compiler
888 return "%H:%M:%S";
888} 889}
889 890
890void KLocale::insertCatalogue ( const QString & ) 891void KLocale::insertCatalogue ( const QString & )
891{ 892{
892} 893}
893 894
894KCalendarSystem *KLocale::calendar() 895KCalendarSystem *KLocale::calendar()
895{ 896{
896 if ( !mCalendarSystem ) { 897 if ( !mCalendarSystem ) {
897 mCalendarSystem = new KCalendarSystemGregorian; 898 mCalendarSystem = new KCalendarSystemGregorian;
898 } 899 }
899 900
900 return mCalendarSystem; 901 return mCalendarSystem;
901} 902}
902 903
903int KLocale::timezoneOffset( QString timeZone ) 904int KLocale::timezoneOffset( QString timeZone )
904{ 905{
905 int ret = 1001; 906 int ret = 1001;
906 int index = mTimeZoneList.findIndex( timeZone ); 907 int index = mTimeZoneList.findIndex( timeZone );
907 if ( index < 24 ) 908 if ( index < 24 )
908 ret = ( index-11 ) * 60 ; 909 ret = ( index-11 ) * 60 ;
909 return ret; 910 return ret;
910} 911}
911 912
912QStringList KLocale::timeZoneList() const 913QStringList KLocale::timeZoneList() const
913{ 914{
914 return mTimeZoneList; 915 return mTimeZoneList;
915} 916}
916void KLocale::setTimezone( const QString &timeZone, bool oddTZ ) 917void KLocale::setTimezone( const QString &timeZone, bool oddTZ )
917{ 918{
918 mTimeZoneOffset = timezoneOffset( timeZone ); 919 mTimeZoneOffset = timezoneOffset( timeZone );
919 if ( oddTZ ) 920 if ( oddTZ )
920 mTimeZoneOffset += 30; 921 mTimeZoneOffset += 30;
921} 922}
922 923
923void KLocale::setDaylightSaving( bool b, int start , int end ) 924void KLocale::setDaylightSaving( bool b, int start , int end )
924{ 925{
925 daylightEnabled = b; 926 daylightEnabled = b;
926 daylightStart = start; 927 daylightStart = start;
927 daylightEnd = end; 928 daylightEnd = end;
928 mSouthDaylight = (end < start); 929 mSouthDaylight = (end < start);
929 // qDebug("klocale daylight %d %d %d ", b, start , end ); 930 // qDebug("klocale daylight %d %d %d ", b, start , end );
930} 931}
931 932
932int KLocale::localTimeOffset( const QDateTime &dt ) 933int KLocale::localTimeOffset( const QDateTime &dt )
933{ 934{
934 bool addDaylight = false; 935 bool addDaylight = false;
935 if ( daylightEnabled ) { 936 if ( daylightEnabled ) {
936 int d_end, d_start; 937 int d_end, d_start;
937 int dayofyear = dt.date().dayOfYear(); 938 int dayofyear = dt.date().dayOfYear();
938 int year = dt.date().year(); 939 int year = dt.date().year();
939 int add = 0; 940 int add = 0;
940 if ( QDate::leapYear(year) ) 941 if ( QDate::leapYear(year) )
941 add = 1; 942 add = 1;
942 QDate date ( year,1,1 ); 943 QDate date ( year,1,1 );
943 if ( daylightEnd > 59 ) 944 if ( daylightEnd > 59 )
944 d_end = daylightEnd +add; 945 d_end = daylightEnd +add;
945 else 946 else
946 d_end = daylightEnd; 947 d_end = daylightEnd;
947 if ( daylightStart > 59 ) 948 if ( daylightStart > 59 )
948 d_start = daylightStart +add; 949 d_start = daylightStart +add;
949 else 950 else
950 d_start = daylightStart; 951 d_start = daylightStart;
951 QDate s_date = date.addDays( d_start -1 ); 952 QDate s_date = date.addDays( d_start -1 );
952 QDate e_date = date.addDays( d_end -1 ); 953 QDate e_date = date.addDays( d_end -1 );
953 int dof = s_date.dayOfWeek(); 954 int dof = s_date.dayOfWeek();
954 if ( dof < 7 ) 955 if ( dof < 7 )
955 s_date = s_date.addDays( -dof ); 956 s_date = s_date.addDays( -dof );
956 dof = e_date.dayOfWeek(); 957 dof = e_date.dayOfWeek();
957 if ( dof < 7 ) 958 if ( dof < 7 )
958 e_date = e_date.addDays( -dof ); 959 e_date = e_date.addDays( -dof );
959 QTime startTime ( 3,0,0 ); 960 QTime startTime ( 3,0,0 );
960 QDateTime startDt( s_date, startTime ); 961 QDateTime startDt( s_date, startTime );
961 QDateTime endDt( e_date, startTime ); 962 QDateTime endDt( e_date, startTime );
962 //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( )); 963 //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( ));
963 if ( mSouthDaylight ) { 964 if ( mSouthDaylight ) {
964 if ( ! ( endDt < dt && dt < startDt) ) 965 if ( ! ( endDt < dt && dt < startDt) )
965 addDaylight = true; 966 addDaylight = true;
966 } else { 967 } else {
967 if ( startDt < dt && dt < endDt ) 968 if ( startDt < dt && dt < endDt )
968 addDaylight = true; 969 addDaylight = true;
969 970
970 971
971 } 972 }
972 } 973 }
973 int addMin = 0; 974 int addMin = 0;
974 if ( addDaylight ) 975 if ( addDaylight )
975 addMin = 60; 976 addMin = 60;
976 return mTimeZoneOffset + addMin; 977 return mTimeZoneOffset + addMin;
977} 978}
978// ****************************************************************** 979// ******************************************************************
979// added LR 980// added LR
980QString KLocale::formatNumber(double num, int precision) const 981QString KLocale::formatNumber(double num, int precision) const
981{ 982{
982 bool neg = num < 0; 983 bool neg = num < 0;
983 if (precision == -1) precision = 2; 984 if (precision == -1) precision = 2;
984 QString res = QString::number(neg?-num:num, 'f', precision); 985 QString res = QString::number(neg?-num:num, 'f', precision);
985 int pos = res.find('.'); 986 int pos = res.find('.');
986 if (pos == -1) pos = res.length(); 987 if (pos == -1) pos = res.length();
987 else res.replace(pos, 1, decimalSymbol()); 988 else res.replace(pos, 1, decimalSymbol());
988 989
989 while (0 < (pos -= 3)) 990 while (0 < (pos -= 3))
990 res.insert(pos, thousandsSeparator()); // thousand sep 991 res.insert(pos, thousandsSeparator()); // thousand sep
991 992
992 // How can we know where we should put the sign? 993 // How can we know where we should put the sign?
993 res.prepend(neg?negativeSign():positiveSign()); 994 res.prepend(neg?negativeSign():positiveSign());
994 995
995 return res; 996 return res;
996} 997}
997QString KLocale::formatNumber(const QString &numStr) const 998QString KLocale::formatNumber(const QString &numStr) const
998{ 999{
999 return formatNumber(numStr.toDouble()); 1000 return formatNumber(numStr.toDouble());
1000} 1001}
1001double KLocale::readNumber(const QString &_str, bool * ok) const 1002double KLocale::readNumber(const QString &_str, bool * ok) const
1002{ 1003{
1003 QString str = _str.stripWhiteSpace(); 1004 QString str = _str.stripWhiteSpace();
1004 bool neg = str.find(negativeSign()) == 0; 1005 bool neg = str.find(negativeSign()) == 0;
1005 if (neg) 1006 if (neg)
1006 str.remove( 0, negativeSign().length() ); 1007 str.remove( 0, negativeSign().length() );
1007 1008
1008 /* will hold the scientific notation portion of the number. 1009 /* will hold the scientific notation portion of the number.
1009 Example, with 2.34E+23, exponentialPart == "E+23" 1010 Example, with 2.34E+23, exponentialPart == "E+23"
1010 */ 1011 */
1011 QString exponentialPart; 1012 QString exponentialPart;
1012 int EPos; 1013 int EPos;
1013 1014
1014 EPos = str.find('E', 0, false); 1015 EPos = str.find('E', 0, false);
1015 1016
1016 if (EPos != -1) 1017 if (EPos != -1)
1017 { 1018 {
1018 exponentialPart = str.mid(EPos); 1019 exponentialPart = str.mid(EPos);
1019 str = str.left(EPos); 1020 str = str.left(EPos);
1020 } 1021 }
1021 1022
1022 int pos = str.find(decimalSymbol()); 1023 int pos = str.find(decimalSymbol());
1023 QString major; 1024 QString major;
1024 QString minor; 1025 QString minor;
1025 if ( pos == -1 ) 1026 if ( pos == -1 )
1026 major = str; 1027 major = str;
1027 else 1028 else
1028 { 1029 {
1029 major = str.left(pos); 1030 major = str.left(pos);
1030 minor = str.mid(pos + decimalSymbol().length()); 1031 minor = str.mid(pos + decimalSymbol().length());
1031 } 1032 }
1032 1033
1033 // Remove thousand separators 1034 // Remove thousand separators
1034 int thlen = thousandsSeparator().length(); 1035 int thlen = thousandsSeparator().length();
1035 int lastpos = 0; 1036 int lastpos = 0;
1036 while ( ( pos = major.find( thousandsSeparator() ) ) > 0 ) 1037 while ( ( pos = major.find( thousandsSeparator() ) ) > 0 )
1037 { 1038 {
1038 // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N 1039 // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N
1039 int fromEnd = major.length() - pos; 1040 int fromEnd = major.length() - pos;
1040 if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error 1041 if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error
1041 || pos - lastpos > 3 // More than 3 digits between two separators -> error 1042 || pos - lastpos > 3 // More than 3 digits between two separators -> error
1042 || pos == 0 // Can't start with a separator 1043 || pos == 0 // Can't start with a separator
1043 || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators 1044 || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators
1044 { 1045 {
1045 if (ok) *ok = false; 1046 if (ok) *ok = false;
1046 return 0.0; 1047 return 0.0;
1047 } 1048 }
1048 1049
1049 lastpos = pos; 1050 lastpos = pos;
1050 major.remove( pos, thlen ); 1051 major.remove( pos, thlen );
1051 } 1052 }
1052 if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator 1053 if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator
1053 { 1054 {
1054 if (ok) *ok = false; 1055 if (ok) *ok = false;
1055 return 0.0; 1056 return 0.0;
1056 } 1057 }
1057 1058
1058 QString tot; 1059 QString tot;
1059 if (neg) tot = '-'; 1060 if (neg) tot = '-';
1060 1061
1061 tot += major + '.' + minor + exponentialPart; 1062 tot += major + '.' + minor + exponentialPart;
1062 1063
1063 return tot.toDouble(ok); 1064 return tot.toDouble(ok);
1064} 1065}
1065QString KLocale::decimalSymbol() const 1066QString KLocale::decimalSymbol() const
1066{ 1067{
1067 1068
1068 return m_decimalSymbol; 1069 return m_decimalSymbol;
1069} 1070}
1070 1071
1071QString KLocale::thousandsSeparator() const 1072QString KLocale::thousandsSeparator() const
1072{ 1073{
1073 1074
1074 return m_thousandsSeparator; 1075 return m_thousandsSeparator;
1075} 1076}
1076QString KLocale::positiveSign() const 1077QString KLocale::positiveSign() const
1077{ 1078{
1078 return m_positiveSign; 1079 return m_positiveSign;
1079} 1080}
diff --git a/microkde/kidmanager.cpp b/microkde/kidmanager.cpp
index 8cf486a..e687e5d 100644
--- a/microkde/kidmanager.cpp
+++ b/microkde/kidmanager.cpp
@@ -1,136 +1,136 @@
1#include "kidmanager.h" 1#include "kidmanager.h"
2 2
3KIdManager::KIdManager() 3KIdManager::KIdManager()
4{ 4{
5 5
6} 6}
7// :profilename;12;id_withLen12;123456: 7// :profilename;12;id_withLen12;123456:
8// 123456 is the csum 8// 123456 is the csum
9QString KIdManager::setId (const QString& idString,const QString& prof,const QString& idvalue ) 9QString KIdManager::setId (const QString& idString,const QString& prof,const QString& idvalue )
10{ 10{
11 int startProf; 11 int startProf;
12 int startIDnum; 12 int startIDnum;
13 int startIDnumlen; 13 int startIDnumlen;
14 int startID; 14 int startID;
15 int lenID; 15 int lenID;
16 int startCsum; 16 int startCsum;
17 int lenCsum; 17 int lenCsum;
18 int endall; 18 int endall;
19 QString newIDString; 19 QString newIDString;
20 if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { 20 if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) {
21 newIDString = idString.left(startIDnum ) + QString::number( idvalue.length() ) +";"+idvalue+ ";"+idString.mid( startCsum ); 21 newIDString = idString.left(startIDnum ) + QString::number( idvalue.length() ) +";"+idvalue+ ";"+idString.mid( startCsum );
22 } else { 22 } else {
23 newIDString = idString + prof+";"+ QString::number( idvalue.length() ) +";"+idvalue +";0:"; 23 newIDString = idString + prof+";"+ QString::number( idvalue.length() ) +";"+idvalue +";0:";
24 } 24 }
25 //qDebug("setID:profile:%s*retval:%s*idvalue:%s* ", prof.latin1(), newIDString.latin1() ,idvalue.latin1() ); 25 //qDebug("setID:profile:%s*retval:%s*idvalue:%s* ", prof.latin1(), newIDString.latin1() ,idvalue.latin1() );
26 return newIDString; 26 return newIDString;
27} 27}
28QString KIdManager::getId (const QString& idString,const QString& prof ) 28QString KIdManager::getId (const QString& idString,const QString& prof )
29{ 29{
30 int startProf; 30 int startProf;
31 int startIDnum; 31 int startIDnum;
32 int startIDnumlen; 32 int startIDnumlen;
33 int startID; 33 int startID;
34 int lenID; 34 int lenID;
35 int startCsum; 35 int startCsum;
36 int lenCsum; 36 int lenCsum;
37 int endall; 37 int endall;
38 QString idval = ""; 38 QString idval = "";
39 if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) 39 if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) )
40 idval = idString.mid( startID, lenID ); 40 idval = idString.mid( startID, lenID );
41 41
42 //qDebug("getID:profile:%s*retval:%s*idstring:%s* ", prof.latin1(), idval.latin1() ,idString.latin1() ); 42 //qDebug("getID:profile:%s*retval:%s*idstring:%s* ", prof.latin1(), idval.latin1() ,idString.latin1() );
43 return idval; 43 return idval;
44 44
45} 45}
46 46
47QString KIdManager::removeId (const QString& idString,const QString& prof ) 47QString KIdManager::removeId (const QString& idString,const QString& prof )
48{ 48{
49 int startProf; 49 int startProf;
50 int startIDnum; 50 int startIDnum;
51 int startIDnumlen; 51 int startIDnumlen;
52 int startID; 52 int startID;
53 int lenID; 53 int lenID;
54 int startCsum; 54 int startCsum;
55 int lenCsum; 55 int lenCsum;
56 int endall; 56 int endall;
57 QString newIDString; 57 QString newIDString;
58 if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { 58 if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) {
59 newIDString = idString.left(startProf) + idString.mid( endall+1 ); 59 newIDString = idString.left(startProf) + idString.mid( endall+1 );
60 } else { 60 } else {
61 newIDString = idString; 61 newIDString = idString;
62 } 62 }
63 //qDebug("removeID:profile:%s*retval:%s*oldidstring:%s* ", prof.latin1(), newIDString.latin1() ,idString.latin1() ); 63 //qDebug("removeID:profile:%s*retval:%s*oldidstring:%s* ", prof.latin1(), newIDString.latin1() ,idString.latin1() );
64 return newIDString; 64 return newIDString;
65} 65}
66 66
67QString KIdManager::setCsum (const QString& idString,const QString& prof,const QString& idCsum ) 67QString KIdManager::setCsum (const QString& idString,const QString& prof,const QString& idCsum )
68{ 68{
69 int startProf; 69 int startProf;
70 int startIDnum; 70 int startIDnum;
71 int startIDnumlen; 71 int startIDnumlen;
72 int startID; 72 int startID;
73 int lenID; 73 int lenID;
74 int startCsum; 74 int startCsum;
75 int lenCsum; 75 int lenCsum;
76 int endall; 76 int endall;
77 QString newIDString; 77 QString newIDString;
78 if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { 78 if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) {
79 newIDString = idString.left(startCsum) + idCsum+ idString.mid( endall +1); 79 newIDString = idString.left(startCsum) + idCsum+ idString.mid( endall +1);
80 } else { 80 } else {
81 newIDString = idString + prof + ";3;_u_;"+ idCsum + ":"; 81 newIDString = idString + prof + ";3;_u_;"+ idCsum + ":";
82 } 82 }
83 //qDebug("setCsum:profile:%s*retval:%s*idCsum:%s* ", prof.latin1(), newIDString.latin1() ,idCsum.latin1() ); 83 //qDebug("setCsum:profile:%s*retval:%s*idCsum:%s* ", prof.latin1(), newIDString.latin1() ,idCsum.latin1() );
84 return newIDString; 84 return newIDString;
85} 85}
86QString KIdManager::getCsum (const QString& idString,const QString& prof ) 86QString KIdManager::getCsum (const QString& idString,const QString& prof )
87{ 87{
88 int startProf; 88 int startProf;
89 int startIDnum; 89 int startIDnum;
90 int startIDnumlen; 90 int startIDnumlen;
91 int startID; 91 int startID;
92 int lenID; 92 int lenID;
93 int startCsum; 93 int startCsum;
94 int lenCsum; 94 int lenCsum;
95 int endall; 95 int endall;
96 QString idval = ""; 96 QString idval = "";
97 if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) 97 if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) )
98 idval = idString.mid( startCsum, lenCsum ); 98 idval = idString.mid( startCsum, lenCsum );
99 99
100 //qDebug("getCsum:profile:%s*retval:%s*idstring:%s* ", prof.latin1(), idval.latin1() ,idString.latin1() ); 100 //qDebug("getCsum:profile:%s*retval:%s*idstring:%s* ", prof.latin1(), idval.latin1() ,idString.latin1() );
101 return idval; 101 return idval;
102} 102}
103// :profilename;12;id_withLen12;123456: 103// :profilename;12;id_withLen12;123456:
104bool KIdManager::getNumbers (const QString& idString,const QString& prof, int &startProf, int &startIDnum, int &startIDnumlen,int &startID, int& lenID, int &startCsum, int &lenCsum, int & endall) 104bool KIdManager::getNumbers (const QString& idString,const QString& prof, int &startProf, int &startIDnum, int &startIDnumlen,int &startID, int& lenID, int &startCsum, int &lenCsum, int & endall)
105{ 105{
106 startProf = idString.find( ":"+prof+";" ); 106 startProf = idString.find( ":"+prof+";" );
107 if ( startProf >= 0 ) { 107 if ( startProf >= 0 ) {
108 startIDnum = prof.length()+2+startProf; 108 startIDnum = prof.length()+2+startProf;
109 startID = idString.find( ";", startIDnum ) +1; 109 startID = idString.find( ";", startIDnum ) +1;
110 startIDnumlen = startID - startIDnum - 1; 110 startIDnumlen = startID - startIDnum - 1;
111 if ( startIDnum > 0 ) { 111 if ( startIDnum > 0 ) {
112 bool ok; 112 bool ok;
113 lenID = idString.mid ( startIDnum,startIDnumlen).toInt( &ok ); 113 lenID = idString.mid ( startIDnum,startIDnumlen).toInt( &ok );
114 if (ok) { 114 if (ok) {
115 startCsum = startID+lenID+1; 115 startCsum = startID+lenID+1;
116 endall = idString.find( ":", startCsum )-1; 116 endall = idString.find( ":", startCsum )-1;
117 if ( endall < 0 ) { 117 if ( endall < 0 ) {
118 qDebug("Error getNumbers: andall not found "); 118 qDebug("Error getNumbers: andall not found ");
119 return false; 119 return false;
120 } 120 }
121 lenCsum = endall-startCsum+1; 121 lenCsum = endall-startCsum+1;
122 } 122 }
123 else { 123 else {
124 qDebug("Error getNumbers:length is no number:*%s* ", idString.mid ( startIDnum,startIDnumlen).toInt( &ok )); 124 qDebug("Error getNumbers:length is no number:*%s* ", idString.mid ( startIDnum,startIDnumlen).latin1());
125 return false; 125 return false;
126 } 126 }
127 } else { 127 } else {
128 qDebug("Error in KIdManager::getNumbers.startIDnum <= 0"); 128 qDebug("Error in KIdManager::getNumbers.startIDnum <= 0");
129 return false; 129 return false;
130 } 130 }
131 } else { 131 } else {
132 //qDebug("getnumbers: profile not found *%s* ",prof.latin1() ); 132 //qDebug("getnumbers: profile not found *%s* ",prof.latin1() );
133 return false; 133 return false;
134 } 134 }
135 return true; 135 return true;
136} 136}
diff --git a/microkde/kresources/managerimpl.cpp b/microkde/kresources/managerimpl.cpp
index 5bd9eb7..566b8f4 100644
--- a/microkde/kresources/managerimpl.cpp
+++ b/microkde/kresources/managerimpl.cpp
@@ -1,364 +1,364 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <kglobal.h> 31#include <kglobal.h>
32 32
33#include <kapplication.h> 33#include <kapplication.h>
34#include <kdebug.h> 34#include <kdebug.h>
35#include <kconfig.h> 35#include <kconfig.h>
36#include <kstandarddirs.h> 36#include <kstandarddirs.h>
37#include <qfile.h> 37#include <qfile.h>
38 38
39#include "resource.h" 39#include "resource.h"
40#include "factory.h" 40#include "factory.h"
41#include "managerimpl.h" 41#include "managerimpl.h"
42 42
43using namespace KRES; 43using namespace KRES;
44 44
45ManagerImpl::ManagerImpl( const QString &family ) 45ManagerImpl::ManagerImpl( const QString &family )
46 : mFamily( family ), mConfig( 0 ), mStdConfig( 0 ), mStandard( 0 ), 46 : mFamily( family ), mConfig( 0 ), mStdConfig( 0 ), mStandard( 0 ),
47 mFactory( 0 ) 47 mFactory( 0 )
48 48
49{ 49{
50 kdDebug(5650) << "ManagerImpl::ManagerImpl()" << endl; 50 kdDebug(5650) << "ManagerImpl::ManagerImpl()" << endl;
51 51
52 52
53} 53}
54 54
55ManagerImpl::~ManagerImpl() 55ManagerImpl::~ManagerImpl()
56{ 56{
57 kdDebug(5650) << "ManagerImpl::~ManagerImpl()" << endl; 57 kdDebug(5650) << "ManagerImpl::~ManagerImpl()" << endl;
58 58
59 Resource::List::ConstIterator it; 59 Resource::List::ConstIterator it;
60 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 60 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
61 delete *it; 61 delete *it;
62 } 62 }
63 63
64 delete mStdConfig; 64 delete mStdConfig;
65} 65}
66 66
67void ManagerImpl::createStandardConfig() 67void ManagerImpl::createStandardConfig()
68{ 68{
69 if ( !mStdConfig ) { 69 if ( !mStdConfig ) {
70 QString file = locateLocal( "data", KGlobal::getAppName() 70 QString file = locateLocal( "data", KGlobal::getAppName()
71 + "/kresources/" + mFamily + "rc" ); 71 + "/kresources/" + mFamily + "rc" );
72 if ( mFamily == "tmpcontact" ) { 72 if ( mFamily == "tmpcontact" ) {
73 if (QFile::exists ( file ) ){ 73 if (QFile::exists ( file ) ){
74 QFile::remove ( file ); 74 QFile::remove ( file );
75 qDebug("removed tmp rc file: %s ", file.latin1()); 75 qDebug("removed tmp rc file: %s ", file.latin1());
76 } 76 }
77 } 77 }
78 mStdConfig = new KConfig( file ); 78 mStdConfig = new KConfig( file );
79 } 79 }
80 80
81 mConfig = mStdConfig; 81 mConfig = mStdConfig;
82} 82}
83 83
84void ManagerImpl::readConfig( KConfig *cfg ) 84void ManagerImpl::readConfig( KConfig *cfg )
85{ 85{
86 kdDebug(5650) << "ManagerImpl::readConfig()" << endl; 86 kdDebug(5650) << "ManagerImpl::readConfig()" << endl;
87 87
88 delete mFactory; 88 delete mFactory;
89 mFactory = Factory::self( mFamily ); 89 mFactory = Factory::self( mFamily );
90 90
91 if ( !cfg ) { 91 if ( !cfg ) {
92 createStandardConfig(); 92 createStandardConfig();
93 } else { 93 } else {
94 mConfig = cfg; 94 mConfig = cfg;
95 } 95 }
96 96
97 mStandard = 0; 97 mStandard = 0;
98 98
99 mConfig->setGroup( "General" ); 99 mConfig->setGroup( "General" );
100 100
101 QStringList keys = mConfig->readListEntry( "ResourceKeys" ); 101 QStringList keys = mConfig->readListEntry( "ResourceKeys" );
102 keys += mConfig->readListEntry( "PassiveResourceKeys" ); 102 keys += mConfig->readListEntry( "PassiveResourceKeys" );
103 103
104 QString standardKey = mConfig->readEntry( "Standard" ); 104 QString standardKey = mConfig->readEntry( "Standard" );
105 105
106 for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) { 106 for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) {
107 readResourceConfig( *it, false ); 107 readResourceConfig( *it, false );
108 } 108 }
109 109
110} 110}
111 111
112void ManagerImpl::writeConfig( KConfig *cfg ) 112void ManagerImpl::writeConfig( KConfig *cfg )
113{ 113{
114//USqDebug("ManagerImpl::writeConfig begin this= %ul cfg=%ul", this, cfg); 114//USqDebug("ManagerImpl::writeConfig begin this= %ul cfg=%ul", this, cfg);
115 115
116 116
117 kdDebug(5650) << "ManagerImpl::writeConfig()" << endl; 117 kdDebug(5650) << "ManagerImpl::writeConfig()" << endl;
118 118
119 if ( !cfg ) { 119 if ( !cfg ) {
120 createStandardConfig(); 120 createStandardConfig();
121 } else { 121 } else {
122 mConfig = cfg; 122 mConfig = cfg;
123 } 123 }
124 124
125 QStringList activeKeys; 125 QStringList activeKeys;
126 QStringList passiveKeys; 126 QStringList passiveKeys;
127 127
128 // First write all keys, collect active and passive keys on the way 128 // First write all keys, collect active and passive keys on the way
129 Resource::List::Iterator it; 129 Resource::List::Iterator it;
130 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 130 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
131 writeResourceConfig( *it, false ); 131 writeResourceConfig( *it, false );
132 132
133 QString key = (*it)->identifier(); 133 QString key = (*it)->identifier();
134 if( (*it)->isActive() ) 134 if( (*it)->isActive() )
135 activeKeys.append( key ); 135 activeKeys.append( key );
136 else 136 else
137 passiveKeys.append( key ); 137 passiveKeys.append( key );
138 } 138 }
139 139
140 // And then the general group 140 // And then the general group
141 141
142 kdDebug(5650) << "Saving general info" << endl; 142 kdDebug(5650) << "Saving general info" << endl;
143 mConfig->setGroup( "General" ); 143 mConfig->setGroup( "General" );
144 mConfig->writeEntry( "ResourceKeys", activeKeys ); 144 mConfig->writeEntry( "ResourceKeys", activeKeys );
145 mConfig->writeEntry( "PassiveResourceKeys", passiveKeys ); 145 mConfig->writeEntry( "PassiveResourceKeys", passiveKeys );
146 if ( mStandard ) 146 if ( mStandard )
147 mConfig->writeEntry( "Standard", mStandard->identifier() ); 147 mConfig->writeEntry( "Standard", mStandard->identifier() );
148 else 148 else
149 mConfig->writeEntry( "Standard", "" ); 149 mConfig->writeEntry( "Standard", "" );
150 150
151 mConfig->sync(); 151 mConfig->sync();
152 kdDebug(5650) << "ManagerImpl::save() finished" << endl; 152 kdDebug(5650) << "ManagerImpl::save() finished" << endl;
153 153
154//US qDebug("ManagerImpl::writeConfig end this= %ul cfg=%ul", this, cfg); 154//US qDebug("ManagerImpl::writeConfig end this= %ul cfg=%ul", this, cfg);
155 155
156} 156}
157 157
158void ManagerImpl::add( Resource *resource, bool useDCOP ) 158void ManagerImpl::add( Resource *resource, bool useDCOP )
159{ 159{
160qDebug("ManagerImpl::add begin this= %ul resource=%ul", this, resource); 160 //qDebug("ManagerImpl::add begin this= %ul resource=%ul", this, resource);
161 161
162 resource->setActive( true ); 162 resource->setActive( true );
163 163
164 if ( mResources.isEmpty() ) { 164 if ( mResources.isEmpty() ) {
165 mStandard = resource; 165 mStandard = resource;
166 } 166 }
167 167
168 mResources.append( resource ); 168 mResources.append( resource );
169 169
170 writeResourceConfig( resource, true ); 170 writeResourceConfig( resource, true );
171 171
172 qDebug("ManagerImpl::add end this= %ul resource=%ul", this, resource); 172 //qDebug("ManagerImpl::add end this= %ul resource=%ul", this, resource);
173 173
174} 174}
175 175
176void ManagerImpl::remove( Resource *resource, bool useDCOP ) 176void ManagerImpl::remove( Resource *resource, bool useDCOP )
177{ 177{
178 if ( mStandard == resource ) mStandard = 0; 178 if ( mStandard == resource ) mStandard = 0;
179 removeResource( resource ); 179 removeResource( resource );
180 180
181 mResources.remove( resource ); 181 mResources.remove( resource );
182 182
183 delete resource; 183 delete resource;
184 184
185 kdDebug(5650) << "Finished ManagerImpl::remove()" << endl; 185 kdDebug(5650) << "Finished ManagerImpl::remove()" << endl;
186} 186}
187 187
188void ManagerImpl::setActive( Resource *resource, bool active ) 188void ManagerImpl::setActive( Resource *resource, bool active )
189{ 189{
190 if ( resource && resource->isActive() != active ) { 190 if ( resource && resource->isActive() != active ) {
191 resource->setActive( active ); 191 resource->setActive( active );
192 } 192 }
193} 193}
194 194
195Resource *ManagerImpl::standardResource() 195Resource *ManagerImpl::standardResource()
196{ 196{
197 return mStandard; 197 return mStandard;
198} 198}
199 199
200void ManagerImpl::setStandardResource( Resource *resource ) 200void ManagerImpl::setStandardResource( Resource *resource )
201{ 201{
202 mStandard = resource; 202 mStandard = resource;
203} 203}
204 204
205void ManagerImpl::resourceChanged( Resource *resource ) 205void ManagerImpl::resourceChanged( Resource *resource )
206{ 206{
207 writeResourceConfig( resource, true ); 207 writeResourceConfig( resource, true );
208 208
209 209
210// ManagerIface_stub allManagers( "*", "ManagerIface_" + mFamily.utf8() ); 210// ManagerIface_stub allManagers( "*", "ManagerIface_" + mFamily.utf8() );
211// allManagers.dcopResourceModified( resource->identifier() ); 211// allManagers.dcopResourceModified( resource->identifier() );
212} 212}
213 213
214// DCOP asynchronous functions 214// DCOP asynchronous functions
215//US since we work from inside the application, we call the methods directly. 215//US since we work from inside the application, we call the methods directly.
216 216
217QStringList ManagerImpl::resourceNames() 217QStringList ManagerImpl::resourceNames()
218{ 218{
219 QStringList result; 219 QStringList result;
220 220
221 Resource::List::ConstIterator it; 221 Resource::List::ConstIterator it;
222 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 222 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
223 result.append( (*it)->resourceName() ); 223 result.append( (*it)->resourceName() );
224 } 224 }
225 return result; 225 return result;
226} 226}
227 227
228Resource::List *ManagerImpl::resourceList() 228Resource::List *ManagerImpl::resourceList()
229{ 229{
230 return &mResources; 230 return &mResources;
231} 231}
232 232
233QPtrList<Resource> ManagerImpl::resources() 233QPtrList<Resource> ManagerImpl::resources()
234{ 234{
235 QPtrList<Resource> result; 235 QPtrList<Resource> result;
236 236
237 Resource::List::ConstIterator it; 237 Resource::List::ConstIterator it;
238 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 238 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
239 result.append( *it ); 239 result.append( *it );
240 } 240 }
241 return result; 241 return result;
242} 242}
243 243
244QPtrList<Resource> ManagerImpl::resources( bool active ) 244QPtrList<Resource> ManagerImpl::resources( bool active )
245{ 245{
246 QPtrList<Resource> result; 246 QPtrList<Resource> result;
247 247
248 Resource::List::ConstIterator it; 248 Resource::List::ConstIterator it;
249 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 249 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
250 if ( (*it)->isActive() == active ) { 250 if ( (*it)->isActive() == active ) {
251 result.append( *it ); 251 result.append( *it );
252 } 252 }
253 } 253 }
254 return result; 254 return result;
255} 255}
256 256
257void ManagerImpl::setListener( ManagerImplListener *listener ) 257void ManagerImpl::setListener( ManagerImplListener *listener )
258{ 258{
259 mListener = listener; 259 mListener = listener;
260} 260}
261 261
262Resource* ManagerImpl::readResourceConfig( const QString& identifier, 262Resource* ManagerImpl::readResourceConfig( const QString& identifier,
263 bool checkActive ) 263 bool checkActive )
264{ 264{
265 kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl; 265 kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl;
266 266
267// qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1()); 267// qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1());
268 268
269 mConfig->setGroup( "Resource_" + identifier ); 269 mConfig->setGroup( "Resource_" + identifier );
270#ifdef _WIN32_ 270#ifdef _WIN32_
271 // we use plugins on win32. the group is stored in a static variable 271 // we use plugins on win32. the group is stored in a static variable
272 // such that gourp info not avail on win32 plugins 272 // such that gourp info not avail on win32 plugins
273 // to fix that, it would be a looooot of work 273 // to fix that, it would be a looooot of work
274 mConfig->setTempGroup( "Resource_" + identifier ); 274 mConfig->setTempGroup( "Resource_" + identifier );
275#endif 275#endif
276 QString type = mConfig->readEntry( "ResourceType" ); 276 QString type = mConfig->readEntry( "ResourceType" );
277 QString name = mConfig->readEntry( "ResourceName" ); 277 QString name = mConfig->readEntry( "ResourceName" );
278 Resource *resource = mFactory->resource( type, mConfig ); 278 Resource *resource = mFactory->resource( type, mConfig );
279 if ( !resource ) { 279 if ( !resource ) {
280 qDebug("Failed to create resource with id %s ",identifier.latin1() ); 280 qDebug("Failed to create resource with id %s ",identifier.latin1() );
281 return 0; 281 return 0;
282 } 282 }
283 283
284 if ( resource->identifier().isEmpty() ) 284 if ( resource->identifier().isEmpty() )
285 resource->setIdentifier( identifier ); 285 resource->setIdentifier( identifier );
286 286
287 mConfig->setGroup( "General" ); 287 mConfig->setGroup( "General" );
288 288
289 QString standardKey = mConfig->readEntry( "Standard" ); 289 QString standardKey = mConfig->readEntry( "Standard" );
290 if ( standardKey == identifier ) { 290 if ( standardKey == identifier ) {
291 mStandard = resource; 291 mStandard = resource;
292 } 292 }
293 293
294 if ( checkActive ) { 294 if ( checkActive ) {
295 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); 295 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" );
296 resource->setActive( activeKeys.contains( identifier ) ); 296 resource->setActive( activeKeys.contains( identifier ) );
297 } 297 }
298 mResources.append( resource ); 298 mResources.append( resource );
299 299
300 return resource; 300 return resource;
301} 301}
302 302
303void ManagerImpl::writeResourceConfig( Resource *resource, 303void ManagerImpl::writeResourceConfig( Resource *resource,
304 bool checkActive ) 304 bool checkActive )
305{ 305{
306 QString key = resource->identifier(); 306 QString key = resource->identifier();
307 307
308 kdDebug(5650) << "Saving resource " << key << endl; 308 kdDebug(5650) << "Saving resource " << key << endl;
309 309
310 if ( !mConfig ) createStandardConfig(); 310 if ( !mConfig ) createStandardConfig();
311 311
312 mConfig->setGroup( "Resource_" + key ); 312 mConfig->setGroup( "Resource_" + key );
313 resource->writeConfig( mConfig ); 313 resource->writeConfig( mConfig );
314 314
315 mConfig->setGroup( "General" ); 315 mConfig->setGroup( "General" );
316 QString standardKey = mConfig->readEntry( "Standard" ); 316 QString standardKey = mConfig->readEntry( "Standard" );
317 317
318 if ( resource == mStandard && standardKey != key ) 318 if ( resource == mStandard && standardKey != key )
319 mConfig->writeEntry( "Standard", resource->identifier() ); 319 mConfig->writeEntry( "Standard", resource->identifier() );
320 else if ( resource != mStandard && standardKey == key ) 320 else if ( resource != mStandard && standardKey == key )
321 mConfig->writeEntry( "Standard", "" ); 321 mConfig->writeEntry( "Standard", "" );
322 322
323 if ( checkActive ) { 323 if ( checkActive ) {
324 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); 324 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" );
325 if ( resource->isActive() && !activeKeys.contains( key ) ) { 325 if ( resource->isActive() && !activeKeys.contains( key ) ) {
326 activeKeys.append( resource->identifier() ); 326 activeKeys.append( resource->identifier() );
327 mConfig->writeEntry( "ResourceKeys", activeKeys ); 327 mConfig->writeEntry( "ResourceKeys", activeKeys );
328 } else if ( !resource->isActive() && activeKeys.contains( key ) ) { 328 } else if ( !resource->isActive() && activeKeys.contains( key ) ) {
329 activeKeys.remove( key ); 329 activeKeys.remove( key );
330 mConfig->writeEntry( "ResourceKeys", activeKeys ); 330 mConfig->writeEntry( "ResourceKeys", activeKeys );
331 } 331 }
332 } 332 }
333 333
334 mConfig->sync(); 334 mConfig->sync();
335} 335}
336 336
337void ManagerImpl::removeResource( Resource *resource ) 337void ManagerImpl::removeResource( Resource *resource )
338{ 338{
339 QString key = resource->identifier(); 339 QString key = resource->identifier();
340 340
341 if ( !mConfig ) createStandardConfig(); 341 if ( !mConfig ) createStandardConfig();
342 342
343 mConfig->setGroup( "General" ); 343 mConfig->setGroup( "General" );
344 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); 344 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" );
345 if ( activeKeys.contains( key ) ) { 345 if ( activeKeys.contains( key ) ) {
346 activeKeys.remove( key ); 346 activeKeys.remove( key );
347 mConfig->writeEntry( "ResourceKeys", activeKeys ); 347 mConfig->writeEntry( "ResourceKeys", activeKeys );
348 } else { 348 } else {
349 QStringList passiveKeys = mConfig->readListEntry( "PassiveResourceKeys" ); 349 QStringList passiveKeys = mConfig->readListEntry( "PassiveResourceKeys" );
350 passiveKeys.remove( key ); 350 passiveKeys.remove( key );
351 mConfig->writeEntry( "PassiveResourceKeys", passiveKeys ); 351 mConfig->writeEntry( "PassiveResourceKeys", passiveKeys );
352 } 352 }
353 353
354 QString standardKey = mConfig->readEntry( "Standard" ); 354 QString standardKey = mConfig->readEntry( "Standard" );
355 if ( standardKey == key ) { 355 if ( standardKey == key ) {
356 mConfig->writeEntry( "Standard", "" ); 356 mConfig->writeEntry( "Standard", "" );
357 } 357 }
358 358
359 mConfig->deleteGroup( "Resource_" + resource->identifier() ); 359 mConfig->deleteGroup( "Resource_" + resource->identifier() );
360 360
361 mConfig->sync(); 361 mConfig->sync();
362} 362}
363 363
364Resource* ManagerImpl::getResource( const QString& identifier ) 364Resource* ManagerImpl::getResource( const QString& identifier )