diff -r 0410b3201a77 -r afe7195bb6c3 iaupdate/IAD/ui/src/iaupdateuicontroller.cpp --- a/iaupdate/IAD/ui/src/iaupdateuicontroller.cpp Tue Jun 15 13:36:10 2010 +0100 +++ b/iaupdate/IAD/ui/src/iaupdateuicontroller.cpp Thu Jul 22 16:35:01 2010 +0100 @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -59,6 +58,7 @@ #include "iaupdaterefreshhandler.h" #include "iaupdatenodeid.h" #include "iaupdatewaitdialog.h" +#include "iaupdatedialogutil.h" #include "iaupdatedebug.h" @@ -262,6 +262,7 @@ 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 @@ -309,7 +310,7 @@ void CIAUpdateUiController::CheckUpdatesL() { IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::CheckUpdatesL() begin"); - + iCountOfAvailableUpdates = 0; if ( iParams ) @@ -318,7 +319,7 @@ iParams = NULL; } - TBool agreementAccepted( EFalse ); + TBool agreementAccepted( EFalse ); if ( !ForcedRefresh() ) { CIAUpdateAgreement* agreement = CIAUpdateAgreement::NewLC(); @@ -330,10 +331,45 @@ // 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("Accept"); + HbAction *secondaryAction = NULL; + 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 ) @@ -395,7 +431,7 @@ } } - IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::CheckUpdatesL() end"); + IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::AgreementHandledL() end"); } @@ -417,13 +453,17 @@ if ( !IAUpdateUtils::SpaceAvailableInInternalDrivesL( iSelectedNodesArray ) ) { - HbMessageBox messageBox(HbMessageBox::MessageTypeInformation); - messageBox.setText(QString("Insufficient memory. Free some memory and try again.")); - HbAction action("OK"); - messageBox.setPrimaryAction(&action); - messageBox.setTimeout(HbPopup::NoTimeout); - messageBox.show(); - //messageBox.exec(); + if ( !mDialogUtil ) + { + mDialogUtil = new IAUpdateDialogUtil(NULL, this); + } + if ( mDialogUtil ) + { + mPrimaryAction = NULL; + mPrimaryAction = new HbAction("OK"); + mDialogUtil->showInformation(QString("Insufficient memory. Free some memory and try again."), mPrimaryAction); + iDialogState = EInsufficientMemory; + } } else { @@ -442,7 +482,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 @@ -506,7 +551,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, @@ -515,11 +561,8 @@ selectedNode->DownloadL( *this ); iState = EDownloading; iClosingAllowedByClient = ETrue; - selectedNode->SetDownloading( ETrue); - /*ShowUpdatingDialogL( R_IAUPDATE_DOWNLOADING_NOTE, - selectedNode->Base().Name(), - iNodeIndex + 1, - iSelectedNodesArray.Count() );*/ + selectedNode->SetUiState( MIAUpdateNode::EDownloading ); + iObserver.RefreshUI(); nextUpdate = EFalse; } else @@ -530,13 +573,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; } } @@ -570,14 +608,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"); } @@ -1549,6 +1582,35 @@ } // ----------------------------------------------------------------------------- +// 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(); + + CleanupStack::PopAndDestroy(agreement); + } + AgreementHandledL(); + break; + case EInsufficientMemory: + break; + default: + break; + } + } + +// ----------------------------------------------------------------------------- // CIAUpdateUiController::HandleUiRefreshL // // ----------------------------------------------------------------------------- @@ -1582,10 +1644,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() ); @@ -1868,10 +1930,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 ) @@ -1916,17 +1984,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 ); @@ -1985,9 +2043,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 @@ -2085,7 +2146,8 @@ // // --------------------------------------------------------------------------- // -void CIAUpdateUiController::ShowUpdatingDialogL( TInt /*aTextResourceId*/, +/* +void CIAUpdateUiController::ShowUpdatingDialogL( TInt aTextResourceId, const TDesC& aName, TInt aNumber, TInt aTotalCount ) @@ -2124,7 +2186,7 @@ CleanupStack::PopAndDestroy( stringArray ); IAUPDATE_TRACE("[IAUPDATE] CIAUpdateUiController::ShowUpdatingDialogL() end"); - } + }*/ // --------------------------------------------------------------------------- @@ -2657,6 +2719,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 // // ---------------------------------------------------------------------------