diff -r 5cc91383ab1e -r 7333d7932ef7 iaupdate/IAD/ui/src/iaupdateuicontroller.cpp --- a/iaupdate/IAD/ui/src/iaupdateuicontroller.cpp Thu Aug 19 10:02:49 2010 +0300 +++ b/iaupdate/IAD/ui/src/iaupdateuicontroller.cpp Tue Aug 31 15:21:33 2010 +0300 @@ -19,23 +19,18 @@ // 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" @@ -45,7 +40,6 @@ #include "iaupdateprivatecrkeys.h" #include "iaupdatecontrollerfile.h" #include "iaupdateuiconfigdata.h" -#include "iaupdatedialogutil.h" #include "iaupdateutils.h" #include "iaupdateagreement.h" #include "iaupdateautomaticcheck.h" @@ -57,13 +51,14 @@ #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" @@ -252,6 +247,7 @@ IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::~CIAUpdateUiController() begin"); CancelOperation(); + delete mWaitDialog; delete iController; iNodes.Reset(); iFwNodes.Reset(); @@ -266,13 +262,14 @@ 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"); } @@ -313,7 +310,7 @@ void CIAUpdateUiController::CheckUpdatesL() { IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::CheckUpdatesL() begin"); - + iCountOfAvailableUpdates = 0; if ( iParams ) @@ -322,7 +319,7 @@ iParams = NULL; } - TBool agreementAccepted( EFalse ); + TBool agreementAccepted( EFalse ); if ( !ForcedRefresh() ) { CIAUpdateAgreement* agreement = CIAUpdateAgreement::NewLC(); @@ -334,10 +331,47 @@ // 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 ) @@ -358,9 +392,7 @@ } else { - CIAUpdateAppUi* appUi = - static_cast< CIAUpdateAppUi* >( iEikEnv->EikAppUi() ); - appUi->Exit(); + qApp->quit(); return; } } @@ -401,7 +433,7 @@ } } - IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::CheckUpdatesL() end"); + IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::AgreementHandledL() end"); } @@ -423,10 +455,18 @@ if ( !IAUpdateUtils::SpaceAvailableInInternalDrivesL( iSelectedNodesArray ) ) { - HBufC* noteText = NULL; - noteText = StringLoader::LoadLC( R_IAUPDATE_INSUFFICIENT_MEMORY ); - IAUpdateDialogUtil::ShowInformationQueryL( *noteText ); - CleanupStack::PopAndDestroy( noteText ); + 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; + } } else { @@ -445,7 +485,12 @@ // 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 @@ -509,7 +554,8 @@ // Only update items that have not been installed yet. if ( !selectedNode->IsInstalled() ) { - IAUPDATE_TRACE("[IAUPDATE] Item not installed yet"); + IAUPDATE_TRACE("[IAUPDATE] Item not installed yet"); + iFilter->SortThisNodeFirstL( selectedNode, iNodes ); if ( !selectedNode->IsDownloaded() ) { // Because content has not been downloaded or installed yet, @@ -518,10 +564,8 @@ selectedNode->DownloadL( *this ); iState = EDownloading; iClosingAllowedByClient = ETrue; - ShowUpdatingDialogL( R_IAUPDATE_DOWNLOADING_NOTE, - selectedNode->Base().Name(), - iNodeIndex + 1, - iSelectedNodesArray.Count() ); + selectedNode->SetUiState( MIAUpdateNode::EDownloading ); + iObserver.RefreshUI(); nextUpdate = EFalse; } else @@ -532,13 +576,8 @@ selectedNode->InstallL( *this ); iState = EInstalling; iClosingAllowedByClient = EFalse; - CIAUpdateAppUi* appUi = - static_cast< CIAUpdateAppUi* >( iEikEnv->EikAppUi() ); - appUi->StartWGListChangeMonitoring(); - ShowUpdatingDialogL( R_IAUPDATE_INSTALLING_NOTE, - selectedNode->Base().Name(), - iNodeIndex + 1, - iSelectedNodesArray.Count() ); + selectedNode->SetUiState( MIAUpdateNode::EInstalling ); + iObserver.RefreshUI(); nextUpdate = EFalse; } } @@ -572,14 +611,9 @@ aNode.InstallL( *this ); iState = EInstalling; - CIAUpdateAppUi* appUi = static_cast( iEikEnv->EikAppUi() ); - appUi->StartWGListChangeMonitoring(); - iClosingAllowedByClient = EFalse; - ShowUpdatingDialogL( R_IAUPDATE_INSTALLING_NOTE, - aNode.Base().Name(), - iNodeIndex + 1, - iSelectedNodesArray.Count() ); - + aNode.SetUiState( MIAUpdateNode::EInstalling ); + iObserver.RefreshUI(); + IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::StartInstallL() end"); } @@ -614,17 +648,13 @@ if ( allowNetworkRefresh ) { iEikEnv->RootWin().SetOrdinalPosition( 0, ECoeWinPriorityNormal ); - HBufC* noteText = StringLoader::LoadLC( R_IAUPDATE_REFRESHING_UPDATE_LIST ); - ShowWaitDialogL( *noteText, ETrue ); - CleanupStack::PopAndDestroy( noteText ); + ShowWaitDialogL( "Refreshing updates list", ETrue ); } } } else { - HBufC* noteText = StringLoader::LoadLC( R_IAUPDATE_REFRESHING_UPDATE_LIST ); - ShowWaitDialogL( *noteText, EFalse ); - CleanupStack::PopAndDestroy( noteText ); + ShowWaitDialogL( "Refreshing updates list", ETrue ); } } @@ -1303,8 +1333,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"); @@ -1356,15 +1386,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"); @@ -1420,8 +1450,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; @@ -1535,29 +1565,52 @@ // ----------------------------------------------------------------------------- -// CIAUpdateUiController::HandleDialogExitL -// Called when wait/progress dialog is about to be cancelled. +// CIAUpdateUiController::HandleWaitDialogCancel +// Called when wait dialog is cancelled. // (other items were commented in a header). // ----------------------------------------------------------------------------- // -TBool CIAUpdateUiController::HandleDialogExitL( TInt aButtonId ) +void CIAUpdateUiController::HandleWaitDialogCancel() { - IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::HandleDialogExitL() begin"); - IAUPDATE_TRACE_1("[IAUPDATE] button id: %d", aButtonId ); + IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::HandleWaitDialogCancel() begin"); - TInt ret( ETrue ); - if ( aButtonId == EAknSoftkeyCancel ) - { - TRAPD ( err, HandleUserCancelL() ); - if ( err != KErrNone ) - { - iObserver.HandleLeaveErrorL( err ); - } - } + TRAPD ( err, HandleUserCancelL() ); + if ( err != KErrNone ) + { + iObserver.HandleLeaveErrorL( err ); + } + + IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::HandleWaitDialogCancel() end"); + + } - IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::HandleDialogExitL() end"); +// ----------------------------------------------------------------------------- +// CIAUpdateUiController::dialogFinished +// Called when dialog is finished. +// ----------------------------------------------------------------------------- +// +void CIAUpdateUiController::dialogFinished(HbAction *action) + { + TDialogState dialogState = iDialogState; + iDialogState = ENoDialog; + + switch ( dialogState ) + { + case EAgreement: + if ( action == mPrimaryAction ) + { + CIAUpdateAgreement* agreement = CIAUpdateAgreement::NewLC(); + agreement->SetAgreementAcceptedL(); - return ret; + CleanupStack::PopAndDestroy(agreement); + } + AgreementHandledL(); + break; + case EInsufficientMemory: + break; + default: + break; + } } // ----------------------------------------------------------------------------- @@ -1575,8 +1628,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 @@ -1594,10 +1647,10 @@ CleanupStack::Pop( nodeId ); } - - if ( iFwNodes.Count() > 0 ) + + for ( TInt j = 0; j < iFwNodes.Count(); ++j ) { - MIAUpdateFwNode* fwNode( iFwNodes[ 0 ] ); + MIAUpdateFwNode* fwNode( iFwNodes[ j ] ); CIAUpdateNodeId* nodeId = CIAUpdateNodeId::NewLC(); nodeId->SetIdL( fwNode->Base().MetaId() ); nodeId->SetNamespaceL( fwNode->Base().MetaNamespace() ); @@ -1880,10 +1933,16 @@ IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::InstallCompleteL() begin"); IAUPDATE_TRACE_1("[IAUPDATE] error code: %d", aError ); - // 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; + if ( aError == KErrNone ) + { + aNode.SetUiState( MIAUpdateNode::EUpdated ); + iObserver.RefreshUI(); + } + else + { + aNode.SetUiState( MIAUpdateNode::EFailed ); + iObserver.RefreshUI(); + } // pass UID of installed package to starter if ( iStarter ) @@ -1928,17 +1987,7 @@ 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 ); @@ -1997,9 +2046,12 @@ // 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 ); - iController->FinishedUpdatesL( ETrue, KServerReportMaxWaitTime ); - iState = ESendingReport; + + //const TInt KServerReportMaxWaitTime( 10000000 ); //Commented TEMP + //iController->FinishedUpdatesL( ETrue, KServerReportMaxWaitTime ); //Commented TEMP + //iState = ESendingReport; //Commented temporarily + EndUpdateFlowL( KErrNone ); //TEMP + return; //TEMP } // When reports are sent, EndUpdateFlowL is called via the callback functions @@ -2097,6 +2149,7 @@ // // --------------------------------------------------------------------------- // +/* void CIAUpdateUiController::ShowUpdatingDialogL( TInt aTextResourceId, const TDesC& aName, TInt aNumber, @@ -2117,18 +2170,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 ); @@ -2136,7 +2189,7 @@ CleanupStack::PopAndDestroy( stringArray ); IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::ShowUpdatingDialogL() end"); - } + }*/ // --------------------------------------------------------------------------- @@ -2144,39 +2197,48 @@ // // --------------------------------------------------------------------------- // -void CIAUpdateUiController::ShowWaitDialogL( const TDesC& aDisplayString, - TBool aVisibilityDelayOff ) +void CIAUpdateUiController::ShowWaitDialogL( const QString& aDisplayString, + TBool /*aVisibilityDelayOff*/ ) { IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::ShowWaitDialogL() begin"); - - if ( iWaitDialog ) + if ( !mWaitDialog ) + { + mWaitDialog = new IAUpdateWaitDialog(); + mWaitDialog->SetCallback( this ); + mWaitDialog->showDialog( aDisplayString ); + } + + + + + /*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"); @@ -2185,17 +2247,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"); } @@ -2225,15 +2287,18 @@ void CIAUpdateUiController::RemoveWaitDialogL() { IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::RemoveWaitDialogL() begin"); - - if ( !iCancelling ) //that's needed because AVKON in 3.2.3 wk12, returning + if ( mWaitDialog ) + { + mWaitDialog->close(); + } + /*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"); } @@ -2253,7 +2318,7 @@ { if ( iProgressDialog ) { - iProgressDialog->ProcessFinishedL(); + //iProgressDialog->ProcessFinishedL(); } } @@ -2657,6 +2722,32 @@ } // --------------------------------------------------------------------------- +// 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 // // ---------------------------------------------------------------------------