diff -r 7333d7932ef7 -r 8b7f4e561641 iaupdate/IAD/ui/src/iaupdateuicontroller.cpp --- a/iaupdate/IAD/ui/src/iaupdateuicontroller.cpp Tue Aug 31 15:21:33 2010 +0300 +++ b/iaupdate/IAD/ui/src/iaupdateuicontroller.cpp Wed Sep 01 12:22:02 2010 +0100 @@ -19,18 +19,23 @@ // INCLUDES +#include +#include #include +#include #include +#include #include #include -#include -#include -#include +#include #include #include "iaupdateuicontroller.h" #include "iaupdateuicontrollerobserver.h" +#include "iaupdateappui.h" #include "iaupdate.hrh" +#include "iaupdatewaitdialog.h" +#include "iaupdateprogressdialog.h" #include "iaupdatenode.h" #include "iaupdatefwnode.h" #include "iaupdatebasenode.h" @@ -40,6 +45,7 @@ #include "iaupdateprivatecrkeys.h" #include "iaupdatecontrollerfile.h" #include "iaupdateuiconfigdata.h" +#include "iaupdatedialogutil.h" #include "iaupdateutils.h" #include "iaupdateagreement.h" #include "iaupdateautomaticcheck.h" @@ -51,14 +57,13 @@ #include "iaupdateridentifier.h" #include "iaupdateruids.h" #include "iaupdaterdefs.h" +#include "iaupdatetools.h" #include "iaupdateparametersfilemanager.h" #include "iaupdateerrorcodes.h" #include "iaupdatefileconsts.h" #include "iaupdatefirsttimeinfo.h" #include "iaupdaterefreshhandler.h" #include "iaupdatenodeid.h" -#include "iaupdatewaitdialog.h" -#include "iaupdatedialogutil.h" #include "iaupdatedebug.h" @@ -247,7 +252,6 @@ IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::~CIAUpdateUiController() begin"); CancelOperation(); - delete mWaitDialog; delete iController; iNodes.Reset(); iFwNodes.Reset(); @@ -262,14 +266,13 @@ delete iRoamingHandler; delete iParams; delete iRefreshHandler; - delete mDialogUtil; // If dialogs have not been released yet, release them now. // ProcessFinishedL() should normally be used for dialogs but // here just use non-leaving delete. In normal cases, dialogs should // already be released in the end of the update flow before coming here. - //delete iWaitDialog; - //delete iProgressDialog; + delete iWaitDialog; + delete iProgressDialog; IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::~CIAUpdateUiController() end"); } @@ -310,7 +313,7 @@ void CIAUpdateUiController::CheckUpdatesL() { IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::CheckUpdatesL() begin"); - + iCountOfAvailableUpdates = 0; if ( iParams ) @@ -319,7 +322,7 @@ iParams = NULL; } - TBool agreementAccepted( EFalse ); + TBool agreementAccepted( EFalse ); if ( !ForcedRefresh() ) { CIAUpdateAgreement* agreement = CIAUpdateAgreement::NewLC(); @@ -331,47 +334,10 @@ // Refresh from network is allowed when first time case iRefreshFromNetworkDenied = EFalse; agreementAccepted = agreement->AcceptAgreementL(); - if (!agreementAccepted) - { - if ( !mDialogUtil ) - { - mDialogUtil = new IAUpdateDialogUtil(NULL, this); - } - if ( mDialogUtil ) - { - mPrimaryAction = NULL; - //mPrimaryAction = new HbAction(hbTrId("txt_software_button_accept")); - mPrimaryAction = new HbAction("Accept"); - HbAction *secondaryAction = NULL; - //secondaryAction = new HbAction(hbTrId("txt_software_button_decline")); - secondaryAction = new HbAction("Decline"); - mDialogUtil->showAgreement(mPrimaryAction,secondaryAction); - iDialogState = EAgreement; - } - } } CleanupStack::PopAndDestroy( agreement ); } - if ( iDialogState != EAgreement ) - { - AgreementHandledL(); - } - IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::CheckUpdatesL() end"); - return; - } - -// --------------------------------------------------------------------------- -// CIAUpdateUiController:: AgreementHandledL -// Updates the update item list. -// --------------------------------------------------------------------------- -// -void CIAUpdateUiController::AgreementHandledL() - { - IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::AgreementHandledL() begin"); - TBool agreementAccepted( EFalse ); - CIAUpdateAgreement* agreement = CIAUpdateAgreement::NewLC(); - agreementAccepted = agreement->AgreementAcceptedL(); - CleanupStack::PopAndDestroy( agreement ); + if ( !agreementAccepted && !ForcedRefresh() ) { if ( iRequestType == IAUpdateUiDefines::ECheckUpdates ) @@ -392,7 +358,9 @@ } else { - qApp->quit(); + CIAUpdateAppUi* appUi = + static_cast< CIAUpdateAppUi* >( iEikEnv->EikAppUi() ); + appUi->Exit(); return; } } @@ -433,7 +401,7 @@ } } - IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::AgreementHandledL() end"); + IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::CheckUpdatesL() end"); } @@ -455,18 +423,10 @@ if ( !IAUpdateUtils::SpaceAvailableInInternalDrivesL( iSelectedNodesArray ) ) { - if ( !mDialogUtil ) - { - mDialogUtil = new IAUpdateDialogUtil(NULL, this); - } - if ( mDialogUtil ) - { - mPrimaryAction = NULL; - mPrimaryAction = new HbAction(hbTrId("txt_common_button_ok")); - //mDialogUtil->showInformation(hbTrId("txt_software_info_insufficient_memory_free_some_m"), mPrimaryAction); - mDialogUtil->showInformation(QString("Insufficient memory. Free some memory and try again."), mPrimaryAction); - iDialogState = EInsufficientMemory; - } + HBufC* noteText = NULL; + noteText = StringLoader::LoadLC( R_IAUPDATE_INSUFFICIENT_MEMORY ); + IAUpdateDialogUtil::ShowInformationQueryL( *noteText ); + CleanupStack::PopAndDestroy( noteText ); } else { @@ -485,12 +445,7 @@ // controller can handle situations as a whole and not as one item at the // time. iController->StartingUpdatesL(); - - //Store current node list before update - iFilter->StoreNodeListL( iNodes ); - - iFilter->SortSelectedNodesFirstL( iSelectedNodesArray, iNodes ); - + iFileInUseError = EFalse; // Set the node index to -1 because ContinueUpdateL increases it by one // in the beginning of the function. So, we can use the ContinueUpdateL @@ -554,8 +509,7 @@ // Only update items that have not been installed yet. if ( !selectedNode->IsInstalled() ) { - IAUPDATE_TRACE("[IAUPDATE] Item not installed yet"); - iFilter->SortThisNodeFirstL( selectedNode, iNodes ); + IAUPDATE_TRACE("[IAUPDATE] Item not installed yet"); if ( !selectedNode->IsDownloaded() ) { // Because content has not been downloaded or installed yet, @@ -564,8 +518,10 @@ selectedNode->DownloadL( *this ); iState = EDownloading; iClosingAllowedByClient = ETrue; - selectedNode->SetUiState( MIAUpdateNode::EDownloading ); - iObserver.RefreshUI(); + ShowUpdatingDialogL( R_IAUPDATE_DOWNLOADING_NOTE, + selectedNode->Base().Name(), + iNodeIndex + 1, + iSelectedNodesArray.Count() ); nextUpdate = EFalse; } else @@ -576,8 +532,13 @@ selectedNode->InstallL( *this ); iState = EInstalling; iClosingAllowedByClient = EFalse; - selectedNode->SetUiState( MIAUpdateNode::EInstalling ); - iObserver.RefreshUI(); + CIAUpdateAppUi* appUi = + static_cast< CIAUpdateAppUi* >( iEikEnv->EikAppUi() ); + appUi->StartWGListChangeMonitoring(); + ShowUpdatingDialogL( R_IAUPDATE_INSTALLING_NOTE, + selectedNode->Base().Name(), + iNodeIndex + 1, + iSelectedNodesArray.Count() ); nextUpdate = EFalse; } } @@ -611,9 +572,14 @@ aNode.InstallL( *this ); iState = EInstalling; - aNode.SetUiState( MIAUpdateNode::EInstalling ); - iObserver.RefreshUI(); - + CIAUpdateAppUi* appUi = static_cast( iEikEnv->EikAppUi() ); + appUi->StartWGListChangeMonitoring(); + iClosingAllowedByClient = EFalse; + ShowUpdatingDialogL( R_IAUPDATE_INSTALLING_NOTE, + aNode.Base().Name(), + iNodeIndex + 1, + iSelectedNodesArray.Count() ); + IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::StartInstallL() end"); } @@ -648,13 +614,17 @@ if ( allowNetworkRefresh ) { iEikEnv->RootWin().SetOrdinalPosition( 0, ECoeWinPriorityNormal ); - ShowWaitDialogL( "Refreshing updates list", ETrue ); + HBufC* noteText = StringLoader::LoadLC( R_IAUPDATE_REFRESHING_UPDATE_LIST ); + ShowWaitDialogL( *noteText, ETrue ); + CleanupStack::PopAndDestroy( noteText ); } } } else { - ShowWaitDialogL( "Refreshing updates list", ETrue ); + HBufC* noteText = StringLoader::LoadLC( R_IAUPDATE_REFRESHING_UPDATE_LIST ); + ShowWaitDialogL( *noteText, EFalse ); + CleanupStack::PopAndDestroy( noteText ); } } @@ -1333,8 +1303,8 @@ if ( aErrorCode == IAUpdaterDefs::KIAUpdaterShutdownRequest ) { - //CIAUpdateAppUi* appUi = static_cast( iEikEnv->EikAppUi() ); - //appUi->Exit(); + CIAUpdateAppUi* appUi = static_cast( iEikEnv->EikAppUi() ); + appUi->Exit(); } IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::SelfUpdaterComplete() end"); @@ -1386,15 +1356,15 @@ // ----------------------------------------------------------------------------- // void CIAUpdateUiController::DownloadProgress( MIAUpdateNode& /*aNode*/, - TUint /*aProgress*/, - TUint /*aMaxProgress*/ ) + TUint aProgress, + TUint aMaxProgress ) { IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::DownloadProgress() begin"); if ( iProgressDialog ) { - //TRAP_IGNORE ( iProgressDialog->SetProgressDialogFinalValueL( aMaxProgress ) ); - //TRAP_IGNORE ( iProgressDialog->UpdateProgressDialogValueL( aProgress ) ); + TRAP_IGNORE ( iProgressDialog->SetProgressDialogFinalValueL( aMaxProgress ) ); + TRAP_IGNORE ( iProgressDialog->UpdateProgressDialogValueL( aProgress ) ); } IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::DownloadProgress() end"); @@ -1450,8 +1420,8 @@ IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::InstallComplete() begin"); iState = EIdle; - //CIAUpdateAppUi* appUi = static_cast( iEikEnv->EikAppUi() ); - //appUi->StopWGListChangeMonitoring(); + CIAUpdateAppUi* appUi = static_cast( iEikEnv->EikAppUi() ); + appUi->StopWGListChangeMonitoring(); if ( aError == SwiUI::KSWInstErrFileInUse ) { iFileInUseError = ETrue; @@ -1565,52 +1535,29 @@ // ----------------------------------------------------------------------------- -// CIAUpdateUiController::HandleWaitDialogCancel -// Called when wait dialog is cancelled. +// CIAUpdateUiController::HandleDialogExitL +// Called when wait/progress dialog is about to be cancelled. // (other items were commented in a header). // ----------------------------------------------------------------------------- // -void CIAUpdateUiController::HandleWaitDialogCancel() - { - IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::HandleWaitDialogCancel() begin"); - - TRAPD ( err, HandleUserCancelL() ); - if ( err != KErrNone ) - { - iObserver.HandleLeaveErrorL( err ); - } - - IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::HandleWaitDialogCancel() end"); - - } - -// ----------------------------------------------------------------------------- -// CIAUpdateUiController::dialogFinished -// Called when dialog is finished. -// ----------------------------------------------------------------------------- -// -void CIAUpdateUiController::dialogFinished(HbAction *action) +TBool CIAUpdateUiController::HandleDialogExitL( TInt aButtonId ) { - TDialogState dialogState = iDialogState; - iDialogState = ENoDialog; + IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::HandleDialogExitL() begin"); + IAUPDATE_TRACE_1("[IAUPDATE] button id: %d", aButtonId ); - switch ( dialogState ) - { - case EAgreement: - if ( action == mPrimaryAction ) - { - CIAUpdateAgreement* agreement = CIAUpdateAgreement::NewLC(); - agreement->SetAgreementAcceptedL(); + TInt ret( ETrue ); + if ( aButtonId == EAknSoftkeyCancel ) + { + TRAPD ( err, HandleUserCancelL() ); + if ( err != KErrNone ) + { + iObserver.HandleLeaveErrorL( err ); + } + } - CleanupStack::PopAndDestroy(agreement); - } - AgreementHandledL(); - break; - case EInsufficientMemory: - break; - default: - break; - } + IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::HandleDialogExitL() end"); + + return ret; } // ----------------------------------------------------------------------------- @@ -1628,8 +1575,8 @@ } else if ( iState == EIdle ) { - //CIAUpdateAppUi* appUi = static_cast< CIAUpdateAppUi* >( iEikEnv->EikAppUi() ); - //if ( appUi->UiRefreshAllowed() ) + CIAUpdateAppUi* appUi = static_cast< CIAUpdateAppUi* >( iEikEnv->EikAppUi() ); + if ( appUi->UiRefreshAllowed() ) { iState = EUiRefreshing; // store node identification (Id and namespace) of currently selected nodes @@ -1647,10 +1594,10 @@ CleanupStack::Pop( nodeId ); } - - for ( TInt j = 0; j < iFwNodes.Count(); ++j ) + + if ( iFwNodes.Count() > 0 ) { - MIAUpdateFwNode* fwNode( iFwNodes[ j ] ); + MIAUpdateFwNode* fwNode( iFwNodes[ 0 ] ); CIAUpdateNodeId* nodeId = CIAUpdateNodeId::NewLC(); nodeId->SetIdL( fwNode->Base().MetaId() ); nodeId->SetNamespaceL( fwNode->Base().MetaNamespace() ); @@ -1933,16 +1880,10 @@ IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::InstallCompleteL() begin"); IAUPDATE_TRACE_1("[IAUPDATE] error code: %d", aError ); - if ( aError == KErrNone ) - { - aNode.SetUiState( MIAUpdateNode::EUpdated ); - iObserver.RefreshUI(); - } - else - { - aNode.SetUiState( MIAUpdateNode::EFailed ); - iObserver.RefreshUI(); - } + // In release mode, we do not need the aError info, because + // success counters are counted by using the last operation error info + // when counter info is asked. In debug mode the error code is logged above. + (void)aError; // pass UID of installed package to starter if ( iStarter ) @@ -1987,7 +1928,17 @@ iState = EIdle; iClosingAllowedByClient = EFalse; - + + // Remove installed nodes from the node array. + for ( TInt i = iNodes.Count() - 1; i >= 0; --i ) + { + MIAUpdateNode* node = iNodes[ i ]; + if ( node->IsInstalled() ) + { + iNodes.Remove( i ); + } + } + TInt error( aError ); TBool selfUpdaterStarted( EFalse ); @@ -2046,12 +1997,9 @@ // completion or timer will call the callback later. But, that callback // will be ignored in CIAUpdateUiController::ServerReportSent because // iState is already then changed from ESendingReport to something else. - - //const TInt KServerReportMaxWaitTime( 10000000 ); //Commented TEMP - //iController->FinishedUpdatesL( ETrue, KServerReportMaxWaitTime ); //Commented TEMP - //iState = ESendingReport; //Commented temporarily - EndUpdateFlowL( KErrNone ); //TEMP - return; //TEMP + const TInt KServerReportMaxWaitTime( 10000000 ); + iController->FinishedUpdatesL( ETrue, KServerReportMaxWaitTime ); + iState = ESendingReport; } // When reports are sent, EndUpdateFlowL is called via the callback functions @@ -2149,7 +2097,6 @@ // // --------------------------------------------------------------------------- // -/* void CIAUpdateUiController::ShowUpdatingDialogL( TInt aTextResourceId, const TDesC& aName, TInt aNumber, @@ -2170,18 +2117,18 @@ numberArray->AppendL( aNumber ); numberArray->AppendL( aTotalCount ); HBufC* noteText = NULL; - //noteText = StringLoader::LoadLC( aTextResourceId, - // *stringArray, - // *numberArray ); + noteText = StringLoader::LoadLC( aTextResourceId, + *stringArray, + *numberArray ); TPtr ptr = noteText->Des(); - //AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); + AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); if ( iState == EDownloading ) { ShowProgressDialogL( *noteText, ETrue ); } else { - //ShowWaitDialogL( *noteText, ETrue ); + ShowWaitDialogL( *noteText, ETrue ); } CleanupStack::PopAndDestroy( noteText ); @@ -2189,7 +2136,7 @@ CleanupStack::PopAndDestroy( stringArray ); IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::ShowUpdatingDialogL() end"); - }*/ + } // --------------------------------------------------------------------------- @@ -2197,48 +2144,39 @@ // // --------------------------------------------------------------------------- // -void CIAUpdateUiController::ShowWaitDialogL( const QString& aDisplayString, - TBool /*aVisibilityDelayOff*/ ) +void CIAUpdateUiController::ShowWaitDialogL( const TDesC& aDisplayString, + TBool aVisibilityDelayOff ) { IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::ShowWaitDialogL() begin"); - if ( !mWaitDialog ) - { - mWaitDialog = new IAUpdateWaitDialog(); - mWaitDialog->SetCallback( this ); - mWaitDialog->showDialog( aDisplayString ); - } - - - - - /*if ( iWaitDialog ) + + if ( iWaitDialog ) { IAUPDATE_TRACE("[IAUPDATE] Wait dialog already existed. Remove it first"); // in some rare cases previous dialog still exists // it's now just deleted (not recommended way) to avoid forwarding problem(s). - //delete iWaitDialog; + delete iWaitDialog; iWaitDialog = NULL; - }*/ - /* iWaitDialog = + } + iWaitDialog = new( ELeave ) CIAUpdateWaitDialog( reinterpret_cast< CEikDialog** >( &iWaitDialog ), aVisibilityDelayOff ); iWaitDialog->SetTextL( aDisplayString ); iWaitDialog->SetCallback( this ); - iWaitDialog->ExecuteLD( R_IAUPDATE_WAIT_DIALOG ); */ + iWaitDialog->ExecuteLD( R_IAUPDATE_WAIT_DIALOG ); IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::ShowWaitDialogL() end"); } -// -------------------------------------------------------------------------- +// --------------------------------------------------------------------------- // CIAUpdateUiController::ShowProgressDialogL // // --------------------------------------------------------------------------- // -void CIAUpdateUiController::ShowProgressDialogL( const TDesC& /*aDisplayString*/, - TBool /*aVisibilityDelayOff*/ ) +void CIAUpdateUiController::ShowProgressDialogL( const TDesC& aDisplayString, + TBool aVisibilityDelayOff ) { IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::ShowProgressDialogL() begin"); @@ -2247,17 +2185,17 @@ IAUPDATE_TRACE("[IAUPDATE] Progress dialog already existed. Remove it first"); // in some rare cases previous dialog still exists // it's now just deleted (not recommended way) to avoid forwarding problem(s). - //delete iProgressDialog; + delete iProgressDialog; iProgressDialog = NULL; } -/* iProgressDialog = + iProgressDialog = new( ELeave ) CIAUpdateProgressDialog( reinterpret_cast< CEikDialog** >( &iProgressDialog ), aVisibilityDelayOff ); iProgressDialog->SetTextL( aDisplayString ); iProgressDialog->SetCallback( this ); - iProgressDialog->ExecuteLD( R_IAUPDATE_PROGRESS_DIALOG ); */ + iProgressDialog->ExecuteLD( R_IAUPDATE_PROGRESS_DIALOG ); IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::ShowProgressDialogL() end"); } @@ -2287,18 +2225,15 @@ void CIAUpdateUiController::RemoveWaitDialogL() { IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::RemoveWaitDialogL() begin"); - if ( mWaitDialog ) - { - mWaitDialog->close(); - } - /*if ( !iCancelling ) //that's needed because AVKON in 3.2.3 wk12, returning + + if ( !iCancelling ) //that's needed because AVKON in 3.2.3 wk12, returning //EFalse in TryToExitL() causes a crash { if ( iWaitDialog ) { iWaitDialog->ProcessFinishedL(); } - }*/ + } IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::RemoveWaitDialogL() end"); } @@ -2318,7 +2253,7 @@ { if ( iProgressDialog ) { - //iProgressDialog->ProcessFinishedL(); + iProgressDialog->ProcessFinishedL(); } } @@ -2722,32 +2657,6 @@ } // --------------------------------------------------------------------------- -// CIAUpdateUiController::RefreshNodeList -// -// --------------------------------------------------------------------------- -// -void CIAUpdateUiController::RefreshNodeList() - { - // Restore list after update, that nodes are shown in original sequence - iFilter->RestoreNodeListL( iNodes ); - // Remove installed nodes from the node array. - // Set temp UI state to normal for remaining nodes - for ( TInt i = iNodes.Count() - 1; i >= 0; --i ) - { - MIAUpdateNode* node = iNodes[ i ]; - if ( node->IsInstalled() ) - { - iNodes.Remove( i ); - } - else - { - node->SetUiState( MIAUpdateNode::ENormal ); - } - } - } - - -// --------------------------------------------------------------------------- // CIAUpdateUiController::ParamsWriteFileL // // ---------------------------------------------------------------------------