iaupdate/IAD/ui/src/iaupdateappui.cpp
branchRCL_3
changeset 25 7333d7932ef7
parent 24 5cc91383ab1e
child 26 8b7f4e561641
equal deleted inserted replaced
24:5cc91383ab1e 25:7333d7932ef7
     1 /*
       
     2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   This module contains the implementation of CIAUpdateAppUi class 
       
    15 *                member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDES
       
    22 #include <avkon.hrh>
       
    23 #include <StringLoader.h> 
       
    24 #include <iaupdate.rsg>
       
    25 #include <centralrepository.h>
       
    26 #include <apgwgnam.h>
       
    27 #include <f32file.h>
       
    28 #include <ErrorUI.h>
       
    29 #include <starterclient.h>
       
    30 #include <iaupdateresult.h>
       
    31 #include <iaupdateparameters.h>
       
    32 
       
    33 #include <cmmanagerext.h>
       
    34 #include <cmconnectionmethodext.h>
       
    35 #include <cmconnectionmethoddef.h>
       
    36 #include <cmpluginpacketdatadef.h>
       
    37 #include <cmdestinationext.h>
       
    38 #include <cmmanagerdef.h>
       
    39 #include <rconnmon.h>
       
    40 
       
    41 #include <hlplch.h>                   
       
    42           
       
    43 
       
    44 #include "iaupdateappui.h"
       
    45 #include "iaupdatemainview.h"
       
    46 #include "iaupdatehistoryview.h"
       
    47 #include "iaupdate.hrh"
       
    48 #include "iaupdatenode.h"
       
    49 #include "iaupdatefwnode.h"
       
    50 #include "iaupdatebasenode.h"
       
    51 #include "iaupdateuicontroller.h"
       
    52 #include "iaupdaterequestobserver.h"
       
    53 #include "iaupdateserver.h"
       
    54 #include "iaupdatestatusdialog.h"
       
    55 #include "iaupdatedetailsdialog.h"
       
    56 #include "iaupdatefwdetailsdialog.h"
       
    57 #include "iaupdatesettingdialog.h"
       
    58 #include "iaupdateprivatecrkeys.h"
       
    59 #include "iaupdatestarter.h"
       
    60 #include "iaupdateuiconfigdata.h"
       
    61 #include "iaupdateagreement.h"
       
    62 #include "iaupdateautomaticcheck.h"
       
    63 #include "iaupdatequeryhistory.h"
       
    64 #include "iaupdatedialogutil.h"
       
    65 #include "iaupdategloballockhandler.h"
       
    66 #include "iaupdatenodefilter.h"
       
    67 #include "iaupdateuitimer.h"
       
    68 #include "iaupdateagreement.h"
       
    69 #include "iaupdatedebug.h"
       
    70 
       
    71 
       
    72 const TUint KSWInstSvrUid = 0x101F875A;
       
    73 
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CIAUpdateAppUi::ConstructL
       
    77 // Symbian 2nd phase constructor can leave.
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 void CIAUpdateAppUi::ConstructL()
       
    81     {    
       
    82     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ConstructL() begin");
       
    83      
       
    84     TInt ownWgId = iEikonEnv->RootWin().Identifier();
       
    85     RArray<RWsSession::TWindowGroupChainInfo> wgList;
       
    86     iEikonEnv->WsSession().WindowGroupList( &wgList );
       
    87     TBool chained = EFalse;
       
    88     for ( TInt i = 0; i < wgList.Count() && !chained ; i++ )
       
    89         {
       
    90         if ( wgList[i].iId == ownWgId && wgList[i].iParentId > 0 )
       
    91             {
       
    92             chained = ETrue;
       
    93             }
       
    94         }
       
    95     wgList.Reset();
       
    96     if ( chained )
       
    97         {
       
    98         BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible );
       
    99         }
       
   100     else
       
   101         {
       
   102         iEikonEnv->RootWin().SetOrdinalPosition( -1, ECoeWinPriorityNeverAtFront );
       
   103         BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible );
       
   104         StatusPane()->MakeVisible( EFalse );
       
   105         }
       
   106     
       
   107     iController = CIAUpdateUiController::NewL( *this ); 
       
   108         
       
   109     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ConstructL() end");   
       
   110     }
       
   111 
       
   112 // -----------------------------------------------------------------------------
       
   113 // CIAUpdateAppUi::CIAUpdateAppUi
       
   114 // C++ default constructor can NOT contain any code, that
       
   115 // might leave.
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 CIAUpdateAppUi::CIAUpdateAppUi(): iIsDMSet( EFalse ), iUiRefreshAllowed( ETrue )                              
       
   119     { 
       
   120     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::CIAUpdateAppUi()");   
       
   121     }
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // CIAUpdateAppUi::~CIAUpdateAppUi
       
   125 // Destructor
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 CIAUpdateAppUi::~CIAUpdateAppUi()
       
   129     {    
       
   130     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::~CIAUpdateAppUi() begin");
       
   131     iShowStatusDialogAgain = EFalse;
       
   132     delete iGlobalLockHandler;
       
   133     iDestIdArray.Reset();
       
   134 	delete iController;
       
   135 	delete iIdle;
       
   136 	delete iIdleAutCheck;
       
   137 	delete iForegroundTimer;
       
   138 	delete iBackgroundTimer;
       
   139 	delete iDialogParam;
       
   140 		        
       
   141 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::~CIAUpdateAppUi() end");
       
   142     }        
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // CIAUpdateAppUi::StartedByLauncherL
       
   146 // 
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 void CIAUpdateAppUi::StartedByLauncherL( MIAUpdateRequestObserver& aObserver, 
       
   150                                          TBool aRefreshFromNetworkDenied )
       
   151     {
       
   152     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::StartedByLauncherL() begin");
       
   153     iRequestObserver = &aObserver;
       
   154     iRequestType = IAUpdateUiDefines::ENoRequest;
       
   155     iController->SetRequestType( iRequestType );
       
   156     SetVisibleL( ETrue );
       
   157     CIAUpdateParameters* params = iController->ParamsReadAndRemoveFileL();
       
   158     iController->CheckUpdatesDeferredL( params, aRefreshFromNetworkDenied );
       
   159     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::StartedByLauncherL() end");
       
   160     }
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CIAUpdateAppUi::CheckUpdatesRequestL
       
   164 // 
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 void CIAUpdateAppUi::CheckUpdatesRequestL( MIAUpdateRequestObserver& aObserver,
       
   168                                            CIAUpdateParameters* aFilterParams,
       
   169                                            TBool aForcedRefresh )
       
   170                                            
       
   171     {
       
   172     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::CheckUpdatesRequestL() begin");
       
   173     iStartedFromApplication  = ETrue;
       
   174     CleanupStack::PushL( aFilterParams );
       
   175     if ( iWgId > 0 )
       
   176         {
       
   177         HideApplicationInFSWL( ETrue );
       
   178         }
       
   179     CleanupStack::Pop( aFilterParams );
       
   180     
       
   181     if ( !aFilterParams->ShowProgress() )
       
   182         {
       
   183         iEikonEnv->RootWin().SetOrdinalPosition( -1, ECoeWinPriorityNeverAtFront );	
       
   184         }
       
   185            
       
   186     iRequestObserver = &aObserver;
       
   187     iRequestType = IAUpdateUiDefines::ECheckUpdates; 
       
   188     iController->SetRequestType( iRequestType );
       
   189     IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateAppUi::CheckUpdatesRequestL() Forced refresh: %d", aForcedRefresh );
       
   190     iController->SetForcedRefresh( aForcedRefresh ); 
       
   191     iController->CheckUpdatesDeferredL( aFilterParams, EFalse );
       
   192     
       
   193 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::CheckUpdatesRequestL() end");
       
   194     }
       
   195 
       
   196 // -----------------------------------------------------------------------------
       
   197 // CIAUpdateAppUi::ShowUpdatesRequestL
       
   198 // 
       
   199 // -----------------------------------------------------------------------------
       
   200 // 
       
   201 void CIAUpdateAppUi::ShowUpdatesRequestL( MIAUpdateRequestObserver& aObserver,
       
   202                                           CIAUpdateParameters* aFilterParams )
       
   203     {
       
   204     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowUpdatesRequestL() begin"); 
       
   205     delete iBackgroundTimer;
       
   206     iBackgroundTimer = NULL;
       
   207     iStartedFromApplication  = ETrue;
       
   208     CleanupStack::PushL( aFilterParams );
       
   209     if ( iWgId > 0 )
       
   210         {
       
   211         HideApplicationInFSWL( ETrue );
       
   212         }
       
   213    
       
   214     StatusPane()->MakeVisible( ETrue );
       
   215     iEikonEnv->RootWin().SetOrdinalPosition( 0, ECoeWinPriorityNormal );
       
   216     
       
   217     iRequestObserver = &aObserver;
       
   218     iRequestType = IAUpdateUiDefines::EShowUpdates;
       
   219     iController->SetRequestType( iRequestType );
       
   220      
       
   221 
       
   222     if ( !iMainView )
       
   223         {
       
   224     	iMainView  = CIAUpdateMainView::NewL( ClientRect() ); 
       
   225     	AddViewL( iMainView );
       
   226         }
       
   227     
       
   228       
       
   229     // by pushing object to cleanup stack its destructor is called if leave happens
       
   230     // so global lock issued by this instance can be released in destructor of CIAUpdateGlobalLockHandler
       
   231     CIAUpdateGlobalLockHandler* globalLockHandler = CIAUpdateGlobalLockHandler::NewLC();
       
   232     if ( !globalLockHandler->InUseByAnotherInstanceL() )
       
   233         {
       
   234         globalLockHandler->SetToInUseForAnotherInstancesL( ETrue );
       
   235         CleanupStack::Pop( globalLockHandler );
       
   236         CleanupStack::Pop( aFilterParams );
       
   237         CleanupStack::PushL( globalLockHandler );
       
   238         iController->CheckUpdatesDeferredL( aFilterParams, EFalse );
       
   239         CleanupStack::Pop( globalLockHandler );	
       
   240         delete iGlobalLockHandler;
       
   241         iGlobalLockHandler = globalLockHandler;
       
   242         //now possible deletion of iGlobalLockHandler in leave situation is handled
       
   243         //in HandleLeaveErrorL() and HandleLeaveErrorWithoutLeave methods. 
       
   244         }
       
   245     else
       
   246         {
       
   247         CleanupStack::PopAndDestroy( globalLockHandler );
       
   248         CleanupStack::PopAndDestroy( aFilterParams );
       
   249         // locked by another IAD instance, nothing else to do than just complete client's request.	
       
   250         InformRequestObserver( KErrNone );
       
   251         }  
       
   252   	
       
   253 
       
   254     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowUpdatesRequestL() end"); 
       
   255     }
       
   256     
       
   257 
       
   258 // -----------------------------------------------------------------------------
       
   259 // CIAUpdateAppUi::ShowUpdateQueryRequestL
       
   260 // 
       
   261 // -----------------------------------------------------------------------------
       
   262 //     
       
   263 void CIAUpdateAppUi::ShowUpdateQueryRequestL( MIAUpdateRequestObserver& aObserver, 
       
   264                                               TUint aUid )
       
   265     {
       
   266     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowUpdateQueryRequestL begin");
       
   267     iStartedFromApplication  = ETrue;
       
   268     iUpdatequeryUid = aUid;
       
   269     iUpdateNow = EFalse;
       
   270     if ( iWgId > 0 )
       
   271         {
       
   272         HideApplicationInFSWL( ETrue );
       
   273         }
       
   274     
       
   275     iRequestObserver = &aObserver;
       
   276     iRequestType = IAUpdateUiDefines::EUpdateQuery;
       
   277     
       
   278     
       
   279     delete iIdle;
       
   280     iIdle = NULL;
       
   281 	iIdle = CIdle::NewL( CActive::EPriorityIdle ); 
       
   282     iIdle->Start( TCallBack( UpdateQueryCallbackL, this ) ); 
       
   283     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowUpdateQueryRequestL end")
       
   284     }
       
   285     
       
   286     
       
   287 // -----------------------------------------------------------------------------
       
   288 // CIAUpdateAppUi::HandleObserverRemoval
       
   289 // 
       
   290 // -----------------------------------------------------------------------------
       
   291 // 
       
   292 void CIAUpdateAppUi::HandleObserverRemoval()
       
   293     {
       
   294     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleObserverRemoval() begin");
       
   295 	iRequestObserver = NULL;
       
   296 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleObserverRemoval() end");
       
   297     }
       
   298 
       
   299 
       
   300 // -----------------------------------------------------------------------------
       
   301 // CIAUpdateAppUi::TextLinkL
       
   302 // 
       
   303 // -----------------------------------------------------------------------------
       
   304 // 
       
   305 void CIAUpdateAppUi::TextLinkL( TInt /*aLinkId*/ )
       
   306     {
       
   307     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::TextLinkL() begin");
       
   308     TRAPD( err, HandleTextLinkL() );
       
   309     if ( err != KErrNone )
       
   310         {
       
   311     	HandleLeaveErrorL( err );
       
   312         }
       
   313     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::TextLinkL() end");
       
   314     }
       
   315     
       
   316 // -----------------------------------------------------------------------------
       
   317 // CIAUpdateAppUi::HandleCommandL
       
   318 // 
       
   319 // -----------------------------------------------------------------------------
       
   320 //         
       
   321 void CIAUpdateAppUi::HandleCommandL( TInt aCommand )
       
   322     {
       
   323     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleCommandL() begin");   
       
   324     IAUPDATE_TRACE_1("[IAUPDATE] command id: %d", aCommand );
       
   325 
       
   326     switch(aCommand)
       
   327         {
       
   328         case EIAUpdateCmdStartUpdate:
       
   329             {
       
   330             IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleCommandL() EIAUpdateCmdStartUpdate");
       
   331     
       
   332 
       
   333             // by pushing object to cleanup stack it's destructor is called if leave happens
       
   334             // so global lock issued by this instance can be released in destructor of CIAUpdateGlobalLockHandler
       
   335             CIAUpdateGlobalLockHandler* globalLockHandler = CIAUpdateGlobalLockHandler::NewLC();
       
   336             if ( !globalLockHandler->InUseByAnotherInstanceL() )
       
   337                 {
       
   338             	globalLockHandler->SetToInUseForAnotherInstancesL( ETrue );
       
   339             	// No need to be totally silent since the updating is started
       
   340             	// by user.
       
   341             	SetDefaultConnectionMethodL( EFalse );
       
   342             	iController->StartUpdateL();
       
   343             	CleanupStack::Pop( globalLockHandler );	
       
   344             	delete iGlobalLockHandler;
       
   345             	iGlobalLockHandler = globalLockHandler;
       
   346             	//now possible deletion of iGlobalLockHandler in leave situation is handled
       
   347             	//in HandleLeaveErrorL() and HandleLeaveErrorWithoutLeave methods. 
       
   348                 }
       
   349             else
       
   350                 {
       
   351                 CleanupStack::PopAndDestroy( globalLockHandler ); 	
       
   352                 }
       
   353             break;	
       
   354             } 
       
   355             
       
   356        	case EIAUpdateCmdSettings:
       
   357        	    {
       
   358        	    IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleCommandL() EIAUpdateCmdSettings");
       
   359             CIAUpdateSettingDialog::ShowDialogL();
       
   360             break;	
       
   361        	    } 
       
   362        	    
       
   363        	case EIAUpdateCmdUpdateDetails:
       
   364        	     {
       
   365        	     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleCommandL() EIAUpdateCmdUpdateDetails");
       
   366        	            
       
   367        	     if ( iMainView->GetCurrentNode()->NodeType() == MIAUpdateAnyNode::ENodeTypeNormal )
       
   368        	         {
       
   369        	         TIAUpdateDialogParam param;
       
   370        	         param.iNode = static_cast<MIAUpdateNode*>( iMainView->GetCurrentNode() );
       
   371        	         CIAUpdateDetailsDialog::ShowDialogL( &param );
       
   372        	         }
       
   373        	            
       
   374        	     if (iMainView->GetCurrentNode()->NodeType() == MIAUpdateAnyNode::ENodeTypeFw )
       
   375        	         {
       
   376        	         //this is changed because of the new requirement: when both NSU and FOTA available, only show FOTA in details
       
   377        	  
       
   378        	         MIAUpdateFwNode* node = static_cast<MIAUpdateFwNode*>( iMainView->GetCurrentNode() );
       
   379        	         CIAUpdateFwDetailsDialog::ShowDialogL( node );
       
   380        	         }
       
   381 
       
   382        	      break;      
       
   383        	      }
       
   384        	    
       
   385         case EIAUpdateCmdMarkedUpdateDetails:
       
   386             {
       
   387             IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleCommandL() EIAUpdateCmdUpdateDetails");
       
   388             
       
   389             if ( iMainView->GetSelectedNode()->NodeType() == MIAUpdateAnyNode::ENodeTypeNormal )
       
   390                 {
       
   391                 TIAUpdateDialogParam param;
       
   392                 param.iNode = static_cast<MIAUpdateNode*>( iMainView->GetSelectedNode() );
       
   393                 CIAUpdateDetailsDialog::ShowDialogL( &param );
       
   394                 }
       
   395             
       
   396             if (iMainView->GetSelectedNode()->NodeType() == MIAUpdateAnyNode::ENodeTypeFw )
       
   397                 {
       
   398                 //this is changed because of the new requirement: when both NSU and FOTA available, only show FOTA in details
       
   399   
       
   400                 MIAUpdateFwNode* node = static_cast<MIAUpdateFwNode*>( iMainView->GetSelectedNode() );
       
   401                 CIAUpdateFwDetailsDialog::ShowDialogL( node );
       
   402                 }
       
   403 
       
   404             break;		
       
   405             }
       
   406        	    
       
   407                 
       
   408         // History view
       
   409         case EIAUpdateCmdUpdateHistory:
       
   410             {
       
   411             IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleCommandL() EIAUpdateCmdUpdateHistory");
       
   412             if ( !iHistoryView )
       
   413                 {
       
   414                 iHistoryView = 
       
   415                     CIAUpdateHistoryView::NewL( iController->HistoryL() );
       
   416                 AddViewL( iHistoryView );
       
   417                 }
       
   418             ActivateLocalViewL( TUid::Uid( EIAUpdateHistoryViewId ) );
       
   419             break;	
       
   420             }
       
   421         
       
   422         case EIAUpdateCmdDisclaimer:
       
   423             {
       
   424             IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleCommandL() EIAUpdateCmdDisclaimer");
       
   425             CIAUpdateAgreement* agreement = CIAUpdateAgreement::NewLC();
       
   426             agreement->ShowAgreementL();
       
   427             CleanupStack::PopAndDestroy( agreement);
       
   428             break;	
       
   429             }
       
   430             
       
   431         case EAknCmdHelp:
       
   432             {
       
   433             IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleCommandL() EAknCmdHelp");
       
   434             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), AppHelpContextL() );
       
   435             break;
       
   436             }
       
   437                       
       
   438         case EEikCmdExit:
       
   439         case EAknCmdExit:
       
   440         case EAknSoftkeyExit:
       
   441             {
       
   442             IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleCommandL() Exit");
       
   443             if (iController )
       
   444                 {
       
   445                 iController->CancelOperation();
       
   446                 if ( iController->Starter() )
       
   447                 	 {
       
   448                 	 iController->Starter()->BringToForegroundL();
       
   449                 	 }
       
   450                 }
       
   451             if ( iRequestObserver )
       
   452                 {
       
   453    	            InformRequestObserver( KErrCancel );
       
   454                 }
       
   455             Exit();	
       
   456             break;
       
   457             }
       
   458             
       
   459         case EIAUpdateCmdHistoryViewExit:
       
   460             IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleCommandL() EIAUpdateCmdHistoryViewExit");
       
   461             ActivateLocalViewL( TUid::Uid( EIAUpdateMainViewId ) );
       
   462             break;
       
   463 
       
   464         default:
       
   465             {
       
   466             break;
       
   467             }
       
   468         }
       
   469        
       
   470     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleCommandL() end")    
       
   471     }
       
   472 
       
   473 // -----------------------------------------------------------------------------
       
   474 // CIAUpdateppUi::HandleWsEventL
       
   475 // 
       
   476 // -----------------------------------------------------------------------------
       
   477 // 
       
   478 void CIAUpdateAppUi::HandleWsEventL( const TWsEvent& aEvent, CCoeControl* aDestination )
       
   479     {
       
   480     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleWsEventL() begin");   
       
   481     CAknViewAppUi::HandleWsEventL( aEvent, aDestination );
       
   482   	if ( aEvent.Type() == EEventWindowGroupListChanged )
       
   483 	    {
       
   484         IAUPDATE_TRACE("[IAUPDATE] Window group list changed"); 
       
   485           
       
   486 		RWindowGroup owngroup;
       
   487 		TInt ownWgId = iEikonEnv->RootWin().Identifier();
       
   488   		TApaTaskList tasklist( iEikonEnv->WsSession() );   
       
   489         
       
   490         TApaTask task = tasklist.FindApp( TUid::Uid( KSWInstSvrUid ) );
       
   491         
       
   492         if ( task.Exists() )
       
   493             {
       
   494             IAUPDATE_TRACE("[IAUPDATE] Installer task exists");
       
   495             
       
   496             TInt instUiWgId = task.WgId();
       
   497             TInt ownPosition = KErrNotFound;
       
   498             TInt instUiPosition = KErrNotFound;
       
   499             CArrayFixFlat<TInt>*  wgArray = new(ELeave)CArrayFixFlat<TInt>(10);  
       
   500             CleanupStack::PushL( wgArray );
       
   501             User::LeaveIfError( iEikonEnv->WsSession().WindowGroupList( 0, wgArray ) );   
       
   502             for ( TInt i = 0; i < wgArray->Count(); i++ )
       
   503                 {
       
   504                 if ( wgArray->At(i) == ownWgId )
       
   505                     {
       
   506                     IAUPDATE_TRACE_1("[IAUPDATE] ownPosition: %d", i);
       
   507                 	ownPosition = i;
       
   508                     }
       
   509                 else if ( wgArray->At(i) == instUiWgId )
       
   510                     {
       
   511                     IAUPDATE_TRACE_1("[IAUPDATE] instUiPosition: %d", i);
       
   512                 	instUiPosition = i;
       
   513                     }
       
   514                 }
       
   515             CleanupStack::PopAndDestroy( wgArray );
       
   516           	if ( ownPosition == 0 && iInstUiOnTop )
       
   517                 {
       
   518                 // IAD is now topmost. In the case Installer UI was previously on the top of IAD 
       
   519                 // bring Installer UI foreground 
       
   520                 IAUPDATE_TRACE("[IAUPDATE] instUi to foreground");
       
   521             	task.BringToForeground();
       
   522             	iInstUiOnTop = EFalse;
       
   523                 }
       
   524             else
       
   525                 {
       
   526                 if ( instUiPosition < ownPosition  && 
       
   527                     instUiPosition != KErrNotFound && 
       
   528                     ownPosition != KErrNotFound )
       
   529         	        {
       
   530         	        // Installer UI is on the top of IAD, i.e. it's showing FILETEXT dialog 
       
   531                     IAUPDATE_TRACE("[IAUPDATE] instUi is on top of IAD");
       
   532         		    iInstUiOnTop = ETrue;
       
   533         	        }
       
   534         	    else
       
   535         	        {
       
   536                     IAUPDATE_TRACE("[IAUPDATE] iInstUiOnTop false");
       
   537         	        iInstUiOnTop = EFalse;	
       
   538         	        }
       
   539                 }    
       
   540             }
       
   541         else
       
   542             {
       
   543             IAUPDATE_TRACE("[IAUPDATE] No task. iInstUiOnTop false.");
       
   544             iInstUiOnTop = EFalse;	
       
   545             }
       
   546         }
       
   547     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleWsEventL() end");           
       
   548     }
       
   549 
       
   550 // -----------------------------------------------------------------------------
       
   551 // CIAUpdateAppUi::StartupComplete
       
   552 // 
       
   553 // -----------------------------------------------------------------------------
       
   554 //    
       
   555 void CIAUpdateAppUi::StartupComplete( TInt aError )
       
   556     {
       
   557     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::StartupComplete() begin"); 
       
   558     IAUPDATE_TRACE_1("[IAUPDATE] error code: %d", aError);
       
   559     
       
   560     if( aError != KErrNone ) 
       
   561         {  
       
   562         HandleLeaveErrorWithoutLeave( aError );
       
   563         }
       
   564     else
       
   565         {
       
   566         TRAPD( err, StartupCompleteL() );
       
   567         if( err != KErrNone ) 
       
   568            {  
       
   569            HandleLeaveErrorWithoutLeave( err );
       
   570            }
       
   571         }
       
   572  
       
   573     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::StartupComplete() end");    
       
   574     }
       
   575     
       
   576 // -----------------------------------------------------------------------------
       
   577 // CIAUpdateAppUi::StartupCompleteL
       
   578 // 
       
   579 // -----------------------------------------------------------------------------
       
   580 //    
       
   581 void CIAUpdateAppUi::StartupCompleteL()
       
   582     {
       
   583     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::StartupCompleteL() begin"); 
       
   584     
       
   585     delete iGlobalLockHandler;
       
   586     iGlobalLockHandler = NULL;
       
   587     iGlobalLockHandler = CIAUpdateGlobalLockHandler::NewL();
       
   588     if ( !iGlobalLockHandler->InUseByAnotherInstanceL() )
       
   589         {
       
   590         TBool totalSilent( EFalse );
       
   591         if ( iRequestType == IAUpdateUiDefines::ECheckUpdates )
       
   592             {
       
   593             if ( iController->Filter() )
       
   594                 {
       
   595                 if ( iController->Filter()->FilterParams() )
       
   596                     {
       
   597                     if ( iController->Filter()->FilterParams()->Refresh() )
       
   598                         {
       
   599                         if ( !iController->ForcedRefresh() )
       
   600                             {
       
   601                             //from bgchecker, make it silent
       
   602                             totalSilent = ETrue;
       
   603                             }
       
   604                         }
       
   605                     }
       
   606                 }
       
   607             }
       
   608         SetDefaultConnectionMethodL( totalSilent );
       
   609         iGlobalLockHandler->SetToInUseForAnotherInstancesL( ETrue );
       
   610         iController->StartRefreshL();  
       
   611         }
       
   612     else
       
   613         {
       
   614         RefreshCompleteL( ETrue, KErrServerBusy );
       
   615         }    
       
   616  
       
   617        
       
   618     
       
   619     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::StartupCompleteL() end");    
       
   620     }
       
   621     
       
   622  
       
   623 // -----------------------------------------------------------------------------
       
   624 // CIAUpdateAppUi::HandleLeaveErrorL
       
   625 // 
       
   626 // -----------------------------------------------------------------------------
       
   627 //        
       
   628 void CIAUpdateAppUi::HandleLeaveErrorL( TInt aError )
       
   629     {
       
   630     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleLeaveErrorL() begin");
       
   631     //removal of iGlobalLockHandler releases possible global operation lock to other IAD instances
       
   632     delete iGlobalLockHandler;
       
   633     iGlobalLockHandler = NULL;
       
   634     // client request is completed before leave in case of leave error
       
   635     if ( aError != KErrNone ) 
       
   636         { 	
       
   637     	InformRequestObserver( aError );
       
   638     	User::Leave( aError );
       
   639         }
       
   640     
       
   641     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleLeaveErrorL() end");
       
   642     }
       
   643 
       
   644 
       
   645 // -----------------------------------------------------------------------------
       
   646 // CIAUpdateAppUi::HandleLeaveErrorWithoutLeave
       
   647 // 
       
   648 // -----------------------------------------------------------------------------
       
   649 //  
       
   650 void CIAUpdateAppUi::HandleLeaveErrorWithoutLeave( TInt aError )
       
   651     {
       
   652 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleLeaveErrorWithoutLeave() begin");
       
   653 	//removal of iGlobalLockHandler releases possible global operation lock to other IAD instances
       
   654     delete iGlobalLockHandler;
       
   655     iGlobalLockHandler = NULL;
       
   656 	if ( aError != KErrNone ) 
       
   657         {
       
   658     	InformRequestObserver( aError );
       
   659         }
       
   660     if ( aError == KErrDiskFull )
       
   661         {
       
   662         TRAP_IGNORE( ShowGlobalErrorNoteL( aError ) );
       
   663         }
       
   664 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleLeaveErrorWithoutLeave end");
       
   665     }
       
   666 
       
   667 
       
   668 // -----------------------------------------------------------------------------
       
   669 // CIAUpdateAppUi::RefreshCompleteL
       
   670 // 
       
   671 // -----------------------------------------------------------------------------
       
   672 //      
       
   673 void CIAUpdateAppUi::RefreshCompleteL( TBool aWithViewActivation, TInt aError )
       
   674     {
       
   675     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::RefreshCompleteL() begin");
       
   676     IAUPDATE_TRACE_1("[IAUPDATE] error code: %d", aError );
       
   677     //removal of iGlobalLockHandler releases possible global operation lock to other IAD instances
       
   678     delete iGlobalLockHandler;
       
   679     iGlobalLockHandler = NULL;   
       
   680    
       
   681     if ( iRequestType == IAUpdateUiDefines::ECheckUpdates )
       
   682         {
       
   683   	    InformRequestObserver( aError );
       
   684         }
       
   685     else 
       
   686         {    
       
   687         RefreshL( aError );   
       
   688         if ( aWithViewActivation)
       
   689             {
       
   690         	ActivateLocalViewL( TUid::Uid( EIAUpdateMainViewId ) );
       
   691             }
       
   692         CIAUpdateAgreement* agreement = CIAUpdateAgreement::NewLC();
       
   693         TBool agreementAccepted = agreement->AgreementAcceptedL();
       
   694         if ( iController->ForcedRefresh() )    
       
   695             {
       
   696             if ( !agreementAccepted )
       
   697                 {
       
   698                 agreement->SetAgreementAcceptedL();
       
   699                 }
       
   700             }
       
   701         CleanupStack::PopAndDestroy( agreement );
       
   702         // By calling CIdle possible waiting dialog can be closed before
       
   703         // automatic check where a new dialog may be launched
       
   704         delete iIdleAutCheck;
       
   705         iIdleAutCheck = NULL;
       
   706         iIdleAutCheck = CIdle::NewL( CActive::EPriorityIdle ); 
       
   707         iIdleAutCheck->Start( TCallBack( AutomaticCheckCallbackL, this ) );
       
   708         } 
       
   709  
       
   710   
       
   711     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::RefreshCompleteL() end");        
       
   712     }
       
   713 
       
   714 // -----------------------------------------------------------------------------
       
   715 // CIAUpdateAppUi::UpdateCompleteL
       
   716 // 
       
   717 // -----------------------------------------------------------------------------
       
   718 //     
       
   719 void CIAUpdateAppUi::UpdateCompleteL( TInt aError )    
       
   720     {
       
   721     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::UpdateCompleteL begin");
       
   722     IAUPDATE_TRACE_1("[IAUPDATE] error code: %d", aError );
       
   723     //removal of iGlobalLockHandler releases possible global operation lock to other IAD instances
       
   724     delete iGlobalLockHandler;
       
   725     iGlobalLockHandler = NULL;  
       
   726     if ( iRequestType != IAUpdateUiDefines::ENoRequest )
       
   727         {
       
   728         InformRequestObserver( aError );
       
   729         }
       
   730     
       
   731     RefreshL( KErrNone ); 
       
   732       
       
   733     ShowStatusDialogDeferredL();
       
   734                 
       
   735     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::UpdateCompleteL end");
       
   736     }
       
   737 
       
   738    
       
   739 // -----------------------------------------------------------------------------
       
   740 // CIAUpdateAppUi::ShowStatusDialogL
       
   741 // 
       
   742 // -----------------------------------------------------------------------------
       
   743 //   
       
   744 void CIAUpdateAppUi::ShowStatusDialogL()
       
   745     {
       
   746     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowStatusDialogL() begin");
       
   747  
       
   748      
       
   749     if ( !iDialogParam )
       
   750         {
       
   751         iDialogParam = new( ELeave ) TIAUpdateDialogParam;
       
   752         }
       
   753     
       
   754     if ( !iShowStatusDialogAgain )
       
   755         {
       
   756         TIAUpdateResultsInfo resultsInfo( iController->ResultsInfo() );
       
   757         iDialogParam->iCountCancelled = resultsInfo.iCountCancelled;
       
   758         iDialogParam->iCountFailed = resultsInfo.iCountFailed;
       
   759         iDialogParam->iCountSuccessfull = resultsInfo.iCountSuccessfull;
       
   760         iDialogParam->iShowCloseAllText = resultsInfo.iFileInUseError;
       
   761         iRebootAfterInstall = resultsInfo.iRebootAfterInstall;
       
   762         iDialogParam->iLinkObserver = this;
       
   763         }
       
   764          
       
   765     iShowStatusDialogAgain = EFalse;
       
   766     iUiRefreshAllowed = ETrue;
       
   767     TInt ret = CIAUpdateStatusDialog::ShowDialogL( iDialogParam );
       
   768     if ( ret == EAknSoftkeyOk && iRebootAfterInstall )
       
   769         {
       
   770         TInt rebootRet = IAUpdateDialogUtil::ShowConfirmationQueryL( 
       
   771                                            R_IAUPDATE_PHONE_RESTART_QUERY, 
       
   772                                            R_AVKON_SOFTKEYS_OK_CANCEL__OK );
       
   773         if ( rebootRet == EAknSoftkeyOk )
       
   774             {
       
   775             RStarterSession startersession;
       
   776             if( startersession.Connect() == KErrNone )
       
   777                 {
       
   778                 startersession.Reset( RStarterSession::EUnknownReset );
       
   779                 startersession.Close();
       
   780                 return;
       
   781                 }
       
   782             }
       
   783         }
       
   784     if ( ret == EAknSoftkeyOk && 
       
   785          iStartedFromApplication && 
       
   786          iDialogParam->iCountCancelled == 0 &&
       
   787          iDialogParam->iCountFailed == 0 )
       
   788         {
       
   789     	HandleCommandL( EEikCmdExit );
       
   790         }
       
   791     
       
   792     IAUPDATE_TRACE_1("[IAUPDATE] nodes count: %d", iController->Nodes().Count() );
       
   793     IAUPDATE_TRACE_1("[IAUPDATE] fw nodes: %d", iController->FwNodes().Count() );
       
   794     //exit from result view if there are no update left
       
   795     if ( ret == EAknSoftkeyOk && (iController->Nodes().Count() == 0) && (iController->FwNodes().Count() == 0) )
       
   796         {
       
   797         HandleCommandL( EEikCmdExit );
       
   798         }
       
   799     
       
   800     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowStatusDialogL() end");
       
   801     }
       
   802 
       
   803 // -----------------------------------------------------------------------------
       
   804 // CIAUpdateAppUi::ShowStatusDialogDeferredL
       
   805 // 
       
   806 // -----------------------------------------------------------------------------
       
   807 //       
       
   808 void CIAUpdateAppUi::ShowStatusDialogDeferredL()
       
   809     {
       
   810     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowStatusDialogDeferredL() begin");
       
   811     delete iIdle;
       
   812     iIdle = NULL;
       
   813 	iIdle = CIdle::NewL( CActive::EPriorityIdle ); 
       
   814     iIdle->Start( TCallBack( ShowStatusDialogCallbackL, this ) ); 
       
   815     iUiRefreshAllowed = EFalse;
       
   816     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowStatusDialogDeferredL() end");
       
   817     }
       
   818  
       
   819 
       
   820 
       
   821                        
       
   822 // -----------------------------------------------------------------------------
       
   823 // CIAUpdateAppUi::RefreshL
       
   824 // 
       
   825 // -----------------------------------------------------------------------------
       
   826 //  
       
   827 void CIAUpdateAppUi::RefreshL( TInt aError ) 
       
   828     {
       
   829     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::RefreshL() begin");
       
   830     IAUPDATE_TRACE_1("[IAUPDATE] Error code: %d", aError );
       
   831     iMainView->RefreshL( iController->Nodes(), iController->FwNodes(), aError );                    
       
   832     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::RefreshL() end");
       
   833     }
       
   834     
       
   835 
       
   836 // -----------------------------------------------------------------------------
       
   837 // CIAUpdateAppUi::InformRequestObserver
       
   838 // 
       
   839 // -----------------------------------------------------------------------------
       
   840 //      
       
   841 void CIAUpdateAppUi::InformRequestObserver( TInt aError )
       
   842     {
       
   843     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::InformRequestObserver() begin");
       
   844         
       
   845     if ( iRequestObserver )
       
   846         {
       
   847         if ( iController->ClosingAllowedByClient() )
       
   848             {
       
   849             if ( iRequestType != IAUpdateUiDefines::ENoRequest )
       
   850                 {
       
   851                 if ( iRequestType == IAUpdateUiDefines::EUpdateQuery && iUpdateNow )
       
   852                     {
       
   853                     if ( !iBackgroundTimer )
       
   854                         {
       
   855                         iBackgroundTimer = CIAUpdateUITimer::NewL( *this, CIAUpdateUITimer::EBackgroundDelay );
       
   856                         }
       
   857                     if ( !iBackgroundTimer->IsActive() )
       
   858                         {
       
   859                         iBackgroundTimer->After( 500000 );
       
   860                         }
       
   861                     }
       
   862                 else
       
   863                     {
       
   864                     iEikonEnv->RootWin().SetOrdinalPosition( -1, ECoeWinPriorityNeverAtFront );
       
   865                     }
       
   866                 }
       
   867             }
       
   868         CIAUpdateResult* details( NULL );
       
   869         TRAPD( error, details = CIAUpdateResult::NewL() )
       
   870         if ( details )
       
   871             {
       
   872             TIAUpdateResultsInfo resultsInfo(
       
   873                 iController->ResultsInfo() );
       
   874             IAUPDATE_TRACE_3("[IAUPDATE] succeed: %d failed: %d  cancelled: %d", 
       
   875                               resultsInfo.iCountSuccessfull, 
       
   876                               resultsInfo.iCountFailed, 
       
   877                               resultsInfo.iCountCancelled );
       
   878             IAUPDATE_TRACE_2("[IAUPDATE] update now: %d available updates: %d", 
       
   879                               iUpdateNow, iController->CountOfAvailableUpdates() );
       
   880             details->SetSuccessCount( resultsInfo.iCountSuccessfull );
       
   881             details->SetFailCount( resultsInfo.iCountFailed );
       
   882             details->SetCancelCount( resultsInfo.iCountCancelled );    
       
   883             
       
   884             // Ownership of details is transferred here.
       
   885             iRequestObserver->RequestCompleted( details, 
       
   886                                                 iController->CountOfAvailableUpdates(), 
       
   887                                                 iUpdateNow, 
       
   888                                                 aError );
       
   889             details = NULL;        
       
   890             }
       
   891         else
       
   892             {
       
   893             iRequestObserver->RequestCompleted( details, 
       
   894                                                 iController->CountOfAvailableUpdates(),
       
   895                                                 iUpdateNow, 
       
   896                                                 error );            
       
   897             }
       
   898         iRequestObserver = NULL;
       
   899         }
       
   900         
       
   901     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::InformRequestObserver() end");
       
   902     }
       
   903 
       
   904 
       
   905 // ---------------------------------------------------------------------------
       
   906 // CIAUpdateAppUi::SetDefaultConnectionMethodL
       
   907 // Sets the connection method for the update network connection.
       
   908 // ---------------------------------------------------------------------------
       
   909 //
       
   910 void CIAUpdateAppUi::SetDefaultConnectionMethodL(TBool aTotalSilent )
       
   911     {
       
   912     if ( aTotalSilent )
       
   913         {
       
   914         // from back ground checker, choose the IAP to make the internet access silent
       
   915         IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::SetDefaultConnectionMethodL() begin");
       
   916 
       
   917            TUint32 connectionMethodId( 0 );
       
   918            TInt connMethodId( 0 );
       
   919 
       
   920            // Let's first check whether cenrep contains SNAP id other than zero
       
   921            CRepository* cenrep( CRepository::NewLC( KCRUidIAUpdateSettings ) );
       
   922            User::LeaveIfError(  
       
   923                cenrep->Get( KIAUpdateAccessPoint, connMethodId ) );
       
   924            CleanupStack::PopAndDestroy( cenrep ); 
       
   925            cenrep = NULL;
       
   926 
       
   927            RCmManagerExt cmManagerExt;
       
   928            cmManagerExt.OpenL();
       
   929            CleanupClosePushL( cmManagerExt );
       
   930            
       
   931            if ( connMethodId == -1 )
       
   932                {
       
   933                IAUPDATE_TRACE("[IAUPDATE] user chooses default connection, use IAP logic");
       
   934                
       
   935                //check what is the default connection by users     
       
   936                
       
   937                TCmDefConnValue DCSetting;
       
   938                cmManagerExt.ReadDefConnL( DCSetting );
       
   939               
       
   940                
       
   941                switch ( DCSetting.iType )
       
   942                    {
       
   943                    case ECmDefConnAlwaysAsk:
       
   944                    case ECmDefConnAskOnce:
       
   945                        {
       
   946                        //go with the best IAP under internet snap
       
   947                        connectionMethodId = GetBestIAPInAllSNAPsL( cmManagerExt );
       
   948                        break;
       
   949                        }
       
   950                    case ECmDefConnDestination:
       
   951                        {
       
   952                        //go with the best IAP under this snap
       
   953                        connectionMethodId = GetBestIAPInThisSNAPL( cmManagerExt, DCSetting.iId );
       
   954                        break;
       
   955                        }
       
   956                    case ECmDefConnConnectionMethod:
       
   957                        {
       
   958                        //go with the best IAP under this snap
       
   959                        connectionMethodId = DCSetting.iId;
       
   960                        break;
       
   961                        }
       
   962                    }
       
   963                }
       
   964            else if ( connMethodId == 0 )
       
   965                {
       
   966                //no choice from user, we go with the best IAP under Internent SNAP
       
   967                connectionMethodId = GetBestIAPInAllSNAPsL( cmManagerExt );
       
   968                }
       
   969            else
       
   970                {
       
   971                IAUPDATE_TRACE("[IAUPDATE] use chooses a snap");
       
   972                // It was some SNAP value
       
   973                connectionMethodId = GetBestIAPInThisSNAPL( cmManagerExt, connMethodId );
       
   974                }
       
   975 
       
   976            CleanupStack::PopAndDestroy( &cmManagerExt ); 
       
   977            
       
   978            if ( connectionMethodId != 0 )
       
   979                {
       
   980                TIAUpdateConnectionMethod connectionMethod( 
       
   981                    connectionMethodId, 
       
   982                    TIAUpdateConnectionMethod::EConnectionMethodTypeAccessPoint );
       
   983 
       
   984                iController->SetDefaultConnectionMethodL( connectionMethod );
       
   985                }
       
   986            else
       
   987                {
       
   988                //In the totally silent case, if no usable IAP, we complete the check update with 0 updates.
       
   989                //the bgchecker will try again later after 1 month. 
       
   990                //The LEAVE will be catched up later and complete the request from background checker.
       
   991                User::LeaveIfError( KErrNotFound );
       
   992                }
       
   993            
       
   994 
       
   995 
       
   996            IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::SetDefaultConnectionMethodL() end");
       
   997         }
       
   998     else
       
   999         {
       
  1000         // from grid, use the old logic
       
  1001         IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::SetDefaultConnectionMethodL() begin");
       
  1002                   TUint32 connectionMethodId( 0 );
       
  1003                   TInt connMethodId( 0 );
       
  1004 
       
  1005                   // Set initial value to always ask
       
  1006                   TInt connectionMethodType( TIAUpdateConnectionMethod::EConnectionMethodTypeAlwaysAsk );
       
  1007                   TBool needSaving(EFalse);
       
  1008 
       
  1009                   // Let's first check whether cenrep contains SNAP id other than zero
       
  1010                   CRepository* cenrep( CRepository::NewLC( KCRUidIAUpdateSettings ) );
       
  1011                   User::LeaveIfError(  
       
  1012                       cenrep->Get( KIAUpdateAccessPoint, connMethodId ) );
       
  1013                   CleanupStack::PopAndDestroy( cenrep ); 
       
  1014                   cenrep = NULL;
       
  1015                     
       
  1016                   if ( connMethodId == -1 )
       
  1017                       {
       
  1018                       IAUPDATE_TRACE("[IAUPDATE] user chooses default connection, use IAP logic");
       
  1019                                             
       
  1020                       connectionMethodId = 0;
       
  1021                       connectionMethodType = TIAUpdateConnectionMethod::EConnectionMethodTypeDefault;
       
  1022                       }
       
  1023                   else if ( connMethodId == 0 )
       
  1024                       {
       
  1025                       
       
  1026                       IAUPDATE_TRACE("[IAUPDATE] use chooses nothing, use internal IAP logic");
       
  1027                       //if nothing is set by user, use our new logic
       
  1028                       //SetDefaultConnectionMethod2L();
       
  1029                       //return;
       
  1030                       // CenRep didn't contain any SNAP id. Let's try Internet SNAP then.
       
  1031                           
       
  1032                       RCmManagerExt cmManagerExt;
       
  1033                       cmManagerExt.OpenL();
       
  1034                       CleanupClosePushL( cmManagerExt );
       
  1035                       iDestIdArray.Reset();
       
  1036                       cmManagerExt.AllDestinationsL( iDestIdArray );
       
  1037 
       
  1038                       for ( TInt i = 0; i< iDestIdArray.Count(); i++ )
       
  1039                           {
       
  1040                           RCmDestinationExt dest = cmManagerExt.DestinationL( iDestIdArray[i] );
       
  1041                           CleanupClosePushL( dest );
       
  1042                            
       
  1043                           if ( dest.MetadataL( CMManager::ESnapMetadataInternet ) )
       
  1044                               {
       
  1045                               // Check whether Internet SNAP contains any IAP.
       
  1046                               if ( dest.ConnectionMethodCount() > 0 )
       
  1047                                   {
       
  1048                                   connectionMethodId = iDestIdArray[i];
       
  1049                                   needSaving = ETrue;
       
  1050                                   IAUPDATE_TRACE_1("[IAUPDATE] connectionMethodId: %d", connectionMethodId );
       
  1051                                   }
       
  1052                               CleanupStack::PopAndDestroy( &dest ); 
       
  1053                               break;
       
  1054                               }
       
  1055                                
       
  1056                           CleanupStack::PopAndDestroy( &dest ); 
       
  1057                           }
       
  1058                       iDestIdArray.Reset();
       
  1059                       CleanupStack::PopAndDestroy( &cmManagerExt ); 
       
  1060                       }
       
  1061                   else
       
  1062                       {
       
  1063                       IAUPDATE_TRACE("[IAUPDATE] use chooses a snap");
       
  1064                       // It was some SNAP value
       
  1065                       connectionMethodId = connMethodId;
       
  1066                       }
       
  1067                   
       
  1068                   if ( connectionMethodId > 0)
       
  1069                       {
       
  1070                       // We have now some valid SNAP id, either from CenRep or Internet SNAP
       
  1071                       connectionMethodType = TIAUpdateConnectionMethod::EConnectionMethodTypeDestination;
       
  1072                       // Save to cenrep if needed
       
  1073                       if ( needSaving )
       
  1074                           {
       
  1075                           cenrep = CRepository::NewLC( KCRUidIAUpdateSettings );
       
  1076                           TInt err = cenrep->StartTransaction( CRepository::EReadWriteTransaction );
       
  1077                           User::LeaveIfError( err );
       
  1078                           cenrep->CleanupCancelTransactionPushL();
       
  1079                           
       
  1080                           connMethodId = connectionMethodId;
       
  1081                           err = cenrep->Set( KIAUpdateAccessPoint, connMethodId );
       
  1082                           User::LeaveIfError( err );
       
  1083                           TUint32 ignore = KErrNone;
       
  1084                           User::LeaveIfError( cenrep->CommitTransaction( ignore ) );
       
  1085                           CleanupStack::PopAndDestroy(); // CleanupCancelTransactionPushL()
       
  1086                           CleanupStack::PopAndDestroy( cenrep );            
       
  1087                           }
       
  1088                       }
       
  1089 
       
  1090                   TIAUpdateConnectionMethod connectionMethod( 
       
  1091                       connectionMethodId, 
       
  1092                       static_cast< TIAUpdateConnectionMethod::TConnectionMethodType >( connectionMethodType ) );
       
  1093 
       
  1094                   iController->SetDefaultConnectionMethodL( connectionMethod );
       
  1095 
       
  1096                   IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::SetDefaultConnectionMethodL() end");
       
  1097         }
       
  1098 
       
  1099     }
       
  1100 
       
  1101 
       
  1102 // ---------------------------------------------------------------------------
       
  1103 // CIAUpdateAppUi::GetBestIAPInAllSNAPsL
       
  1104 // Sets the best IAP from all snaps
       
  1105 // ---------------------------------------------------------------------------
       
  1106 //
       
  1107 TUint32 CIAUpdateAppUi::GetBestIAPInAllSNAPsL( RCmManagerExt& aCmManagerExt  )
       
  1108     { 
       
  1109     //go with internet SNAP first.
       
  1110     TUint32 IAPID = 0;
       
  1111     IAPID = GetBestIAPInInternetSNAPL( aCmManagerExt );
       
  1112     
       
  1113     if ( IAPID )
       
  1114         {
       
  1115         return IAPID;
       
  1116         }
       
  1117     
       
  1118     //select IAP from rest of the SNAPs
       
  1119     iDestIdArray.Reset();
       
  1120     aCmManagerExt.AllDestinationsL( iDestIdArray );
       
  1121     
       
  1122     for ( TInt i = 0; i< iDestIdArray.Count(); i++ )
       
  1123         {
       
  1124         TUint32 SNAPID = iDestIdArray[i];                   
       
  1125         IAPID = GetBestIAPInThisSNAPL( aCmManagerExt, SNAPID );
       
  1126         if ( IAPID )
       
  1127             {
       
  1128             break;
       
  1129             }
       
  1130          }
       
  1131     iDestIdArray.Reset();
       
  1132     return IAPID;
       
  1133     }
       
  1134 
       
  1135 
       
  1136 
       
  1137 // ---------------------------------------------------------------------------
       
  1138 // CIAUpdateAppUi::GetBestIAPInInternetSNAPL
       
  1139 // Sets the best IAP from internet snap
       
  1140 // ---------------------------------------------------------------------------
       
  1141 //
       
  1142 TUint32 CIAUpdateAppUi::GetBestIAPInInternetSNAPL( RCmManagerExt& aCmManagerExt  )
       
  1143     {
       
  1144     //select IAP from Internet SNAP
       
  1145     iDestIdArray.Reset();
       
  1146     aCmManagerExt.AllDestinationsL( iDestIdArray );
       
  1147     TUint32 InternetSNAPID = 0;
       
  1148     for ( TInt i = 0; i< iDestIdArray.Count(); i++ )
       
  1149         {
       
  1150         RCmDestinationExt dest = aCmManagerExt.DestinationL( iDestIdArray[i] );
       
  1151         CleanupClosePushL( dest );
       
  1152                                      
       
  1153         if ( dest.MetadataL( CMManager::ESnapMetadataInternet ) )
       
  1154             {
       
  1155             InternetSNAPID = iDestIdArray[i];
       
  1156             CleanupStack::PopAndDestroy( &dest ); 
       
  1157             break;
       
  1158             }                     
       
  1159          CleanupStack::PopAndDestroy( &dest ); 
       
  1160          }
       
  1161     iDestIdArray.Reset();
       
  1162     
       
  1163     return GetBestIAPInThisSNAPL( aCmManagerExt, InternetSNAPID );
       
  1164     }
       
  1165 
       
  1166 
       
  1167 
       
  1168 // ---------------------------------------------------------------------------
       
  1169 // CIAUpdateAppUi::GetBestIAPInThisSNAPL
       
  1170 // Sets the best IAP from the given snap
       
  1171 // ---------------------------------------------------------------------------
       
  1172 //
       
  1173 TUint32 CIAUpdateAppUi::GetBestIAPInThisSNAPL( RCmManagerExt& aCmManagerExt, TUint32 aSNAPID  )
       
  1174     {
       
  1175     //get all usable IAPs
       
  1176     TConnMonIapInfoBuf iapInfo;
       
  1177     TRequestStatus status;
       
  1178                        
       
  1179     RConnectionMonitor connMon;
       
  1180     connMon.ConnectL();
       
  1181     CleanupClosePushL( connMon );
       
  1182     
       
  1183     connMon.GetPckgAttribute( EBearerIdAll, 0, KIapAvailability,iapInfo, status );
       
  1184     User::WaitForRequest( status );
       
  1185     User::LeaveIfError( status.Int() );
       
  1186     
       
  1187     CleanupStack::PopAndDestroy( &connMon ); 
       
  1188     
       
  1189     RCmDestinationExt dest = aCmManagerExt.DestinationL( aSNAPID );
       
  1190     CleanupClosePushL( dest );
       
  1191     
       
  1192     // Check whether the SNAP contains any IAP.
       
  1193     for  (TInt i = 0; i < dest.ConnectionMethodCount(); i++ )
       
  1194         {
       
  1195         RCmConnectionMethodExt cm =  dest.ConnectionMethodL( i );
       
  1196         CleanupClosePushL( cm );
       
  1197         
       
  1198         TUint32 iapid= cm.GetIntAttributeL( CMManager::ECmIapId );
       
  1199         
       
  1200         for ( TInt i = 0; i < iapInfo().iCount; i++ )
       
  1201             {
       
  1202             if ( iapInfo().iIap[i].iIapId == iapid )
       
  1203                 {
       
  1204                 CleanupStack::PopAndDestroy( 2 ); //cm & dest;
       
  1205                 return iapid;
       
  1206                 }
       
  1207             }    
       
  1208                                                                                  
       
  1209         CleanupStack::PopAndDestroy( &cm );
       
  1210         }
       
  1211     
       
  1212     CleanupStack::PopAndDestroy( &dest ); 
       
  1213     return 0;
       
  1214     }
       
  1215 
       
  1216 
       
  1217 
       
  1218 // ---------------------------------------------------------------------------
       
  1219 // CIAUpdateAppUi::ShowStatusDialogCallbackL
       
  1220 // ---------------------------------------------------------------------------
       
  1221 //
       
  1222 TInt CIAUpdateAppUi::ShowStatusDialogCallbackL( TAny* aPtr )
       
  1223     {
       
  1224     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowStatusDialogCallbackL() begin");
       
  1225     CIAUpdateAppUi* appUI= static_cast<CIAUpdateAppUi*>( aPtr ); 
       
  1226     TRAPD( err, appUI->ShowStatusDialogL() );
       
  1227     appUI->HandleLeaveErrorL( err );
       
  1228     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowStatusDialogCallbackL() end");
       
  1229     return KErrNone;
       
  1230     }
       
  1231 
       
  1232 
       
  1233 // -----------------------------------------------------------------------------
       
  1234 // CIAUpdateAppUi::SetVisibleL
       
  1235 // 
       
  1236 // -----------------------------------------------------------------------------
       
  1237 //  
       
  1238 void CIAUpdateAppUi::SetVisibleL( TBool aVisible )
       
  1239     {
       
  1240     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::SetVisibleL() begin");
       
  1241     IAUPDATE_TRACE_1("[IAUPDATE] visible: %d", aVisible );
       
  1242     if ( aVisible )
       
  1243         {
       
  1244         if ( iEikonEnv->RootWin().OrdinalPosition() != 0 || iEikonEnv->RootWin().OrdinalPriority() != ECoeWinPriorityNormal )
       
  1245             {
       
  1246             iEikonEnv->RootWin().SetOrdinalPosition( 0, ECoeWinPriorityNormal );
       
  1247             }
       
  1248         
       
  1249     	StatusPane()->MakeVisible( ETrue );
       
  1250         iMainView  = CIAUpdateMainView::NewL( ClientRect() ); 
       
  1251         AddViewL( iMainView );
       
  1252         ActivateLocalViewL( TUid::Uid( EIAUpdateMainViewId ) );
       
  1253         }
       
  1254     else
       
  1255         {
       
  1256         iEikonEnv->RootWin().SetOrdinalPosition( -1, ECoeWinPriorityNeverAtFront );
       
  1257         StatusPane()->MakeVisible( EFalse );
       
  1258         }
       
  1259     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::SetVisibleL() end");
       
  1260     }
       
  1261 
       
  1262 // -----------------------------------------------------------------------------
       
  1263 // CIAUpdateAppUi::Controller()
       
  1264 // 
       
  1265 // -----------------------------------------------------------------------------
       
  1266 //      
       
  1267 CIAUpdateUiController* CIAUpdateAppUi::Controller() const
       
  1268     {
       
  1269 	return iController;
       
  1270     }
       
  1271 
       
  1272 // -----------------------------------------------------------------------------
       
  1273 // CIAUpdateAppUi::PotentialCancel
       
  1274 // 
       
  1275 // -----------------------------------------------------------------------------
       
  1276 //
       
  1277 void CIAUpdateAppUi::PotentialCancel() 
       
  1278     {
       
  1279     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::PotentialCancel() begin");
       
  1280     iController->DoCancelIfAllowed();
       
  1281     HandleObserverRemoval();
       
  1282     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::PotentialCancel() end");
       
  1283     }
       
  1284     
       
  1285 // -----------------------------------------------------------------------------
       
  1286 // CIAUpdateAppUi::HandleClientToForegroundL
       
  1287 // 
       
  1288 // -----------------------------------------------------------------------------
       
  1289 //    
       
  1290 void CIAUpdateAppUi::HandleClientToForegroundL()
       
  1291     {
       
  1292     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleClientToForegroundL() begin");
       
  1293     if ( !iForegroundTimer )
       
  1294         {
       
  1295         iForegroundTimer = CIAUpdateUITimer::NewL( *this, CIAUpdateUITimer::EForegroundDelay );
       
  1296         }
       
  1297     if ( !iForegroundTimer->IsActive() )
       
  1298         {
       
  1299         iForegroundTimer->After( 700000 );
       
  1300         }
       
  1301 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleClientToForegroundL() end");
       
  1302     }
       
  1303     
       
  1304 // -----------------------------------------------------------------------------
       
  1305 // CIAUpdateAppUi::HandleAllClientsClosedL
       
  1306 // 
       
  1307 // -----------------------------------------------------------------------------
       
  1308 //    
       
  1309 void CIAUpdateAppUi::HandleAllClientsClosedL()
       
  1310     {
       
  1311     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleAllClientsClosedL() begin");
       
  1312 	HideApplicationInFSWL( EFalse );
       
  1313 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleAllClientsClosedL() end");
       
  1314     }
       
  1315     
       
  1316     
       
  1317 // -----------------------------------------------------------------------------
       
  1318 // CIAUpdateAppUi::ShowStatusDialogAgain
       
  1319 // 
       
  1320 // -----------------------------------------------------------------------------
       
  1321 //  
       
  1322 TBool CIAUpdateAppUi::ShowStatusDialogAgain() const
       
  1323     {
       
  1324     return iShowStatusDialogAgain;	
       
  1325     }
       
  1326 
       
  1327 
       
  1328 // -----------------------------------------------------------------------------
       
  1329 // CIAUpdateAppUi::StartWGListChangeMonitoring
       
  1330 // 
       
  1331 // -----------------------------------------------------------------------------
       
  1332 // 
       
  1333 void CIAUpdateAppUi::StartWGListChangeMonitoring()
       
  1334     {
       
  1335     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::StartWGListChangeMonitoring() begin");
       
  1336     iInstUiOnTop = EFalse;
       
  1337 	iEikonEnv->RootWin().EnableGroupListChangeEvents();
       
  1338 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::StartWGListChangeMonitoring() end");
       
  1339     }
       
  1340  
       
  1341 // -----------------------------------------------------------------------------
       
  1342 // CIAUpdateAppUi::StopWGListChangeMonitoring
       
  1343 // 
       
  1344 // -----------------------------------------------------------------------------
       
  1345 // 
       
  1346 void CIAUpdateAppUi::StopWGListChangeMonitoring()
       
  1347     {
       
  1348     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::StopWGListChangeMonitoring() begin");
       
  1349 	iEikonEnv->RootWin().DisableGroupListChangeEvents();
       
  1350 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::StopWGListChangeMonitoring() end");
       
  1351     }
       
  1352 
       
  1353 // -----------------------------------------------------------------------------
       
  1354 // CIAUpdateAppUi::SetClientWgId
       
  1355 // 
       
  1356 // -----------------------------------------------------------------------------
       
  1357 // 
       
  1358 void CIAUpdateAppUi::SetClientWgId( TInt aWgId )
       
  1359     {
       
  1360 	IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateAppUi::SetClientWgId() wgId %d", aWgId );
       
  1361 	iWgId = aWgId;
       
  1362     }
       
  1363 
       
  1364 // -----------------------------------------------------------------------------
       
  1365 // CIAUpdateAppUi::ClientInBackgroundL
       
  1366 // 
       
  1367 // -----------------------------------------------------------------------------
       
  1368 // 
       
  1369 TInt CIAUpdateAppUi::ClientInBackgroundL() const
       
  1370     {
       
  1371 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ClientInBackgroundL() begin");
       
  1372 	TBool inBackground = EFalse;
       
  1373 	if ( iWgId > 0 )
       
  1374 	    {
       
  1375 		CArrayFixFlat<TInt>*  wgArray = new( ELeave ) CArrayFixFlat<TInt>(10);  
       
  1376         CleanupStack::PushL( wgArray );
       
  1377         User::LeaveIfError( iEikonEnv->WsSession().WindowGroupList( 0, wgArray ) );  
       
  1378         TInt ownWgId = iEikonEnv->RootWin().Identifier();
       
  1379         if ( ( wgArray->At( 0 ) != ownWgId ) && ( wgArray->At( 0 ) != iWgId  ) )
       
  1380             {
       
  1381         	inBackground = ETrue;
       
  1382             }
       
  1383         CleanupStack::PopAndDestroy( wgArray );  
       
  1384 	    }
       
  1385 	IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateAppUi::ClientInBackgroundL() inBackground: %d", inBackground );
       
  1386     return inBackground;  
       
  1387     }
       
  1388 
       
  1389 
       
  1390 
       
  1391 // -----------------------------------------------------------------------------
       
  1392 // CIAUpdateAppUi::ShowUpdateQueryL
       
  1393 // 
       
  1394 // -----------------------------------------------------------------------------
       
  1395 //    
       
  1396 void CIAUpdateAppUi::ShowUpdateQueryL()
       
  1397     {
       
  1398     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowUpdateQueryL() begin");
       
  1399 	CIAUpdateQueryHistory* updateQueryHistory = CIAUpdateQueryHistory::NewL();
       
  1400 	// Get the delay information from the controller that has read it from
       
  1401 	// the config file.
       
  1402 	updateQueryHistory->SetDelay( iController->ConfigData().QueryHistoryDelayHours() );
       
  1403     CleanupStack::PushL( updateQueryHistory );
       
  1404     if ( !updateQueryHistory->IsDelayedL( iUpdatequeryUid ) )
       
  1405         {
       
  1406         if ( ClientInBackgroundL() )
       
  1407             {
       
  1408     	    iEikonEnv->RootWin().SetOrdinalPosition( -1, ECoeWinPriorityNormal );
       
  1409             }
       
  1410         else
       
  1411             {
       
  1412             iEikonEnv->RootWin().SetOrdinalPosition( 0, ECoeWinPriorityNormal );	
       
  1413             }
       
  1414    	    TInt ret = IAUpdateDialogUtil::ShowConfirmationQueryL( 
       
  1415    	                                  R_IAUPDATE_PROGRAM_UPDATE, 
       
  1416 	                                  R_IAUPDATE_SOFTKEYS_NOW_LATER__NOW );
       
  1417 	    switch ( ret )
       
  1418 	        {
       
  1419 	        case EIAUpdateSoftkeyNow:
       
  1420 	            IAUPDATE_TRACE("[IAUPDATE] EIAUpdateSoftkeyNow");
       
  1421 	            iUpdateNow = ETrue;
       
  1422 	            break;
       
  1423 
       
  1424 	        case EIAUpdateSoftkeyLater:
       
  1425 	            IAUPDATE_TRACE("[IAUPDATE] EIAUpdateSoftkeyLater");
       
  1426 	        	updateQueryHistory->SetTimeL( iUpdatequeryUid );
       
  1427 	            break;
       
  1428 	            
       
  1429 	        default: //case of cancel (eq. End key)
       
  1430 	            break;
       
  1431 	        }     
       
  1432         }
       
  1433     CleanupStack::PopAndDestroy( updateQueryHistory );
       
  1434 	InformRequestObserver( KErrNone );	
       
  1435 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowUpdateQueryL() end");
       
  1436     }
       
  1437 
       
  1438 
       
  1439 // -----------------------------------------------------------------------------
       
  1440 // CIAUpdateAppUi::HideApplicationInFSWL
       
  1441 // 
       
  1442 // -----------------------------------------------------------------------------
       
  1443 //  
       
  1444 void CIAUpdateAppUi::HideApplicationInFSWL( TBool aHide )
       
  1445     {
       
  1446     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HideApplicationInFSW() begin");
       
  1447     IAUPDATE_TRACE_1("[IAUPDATE] hide: %d", aHide );
       
  1448     TInt id = iEikonEnv->RootWin().Identifier();
       
  1449 
       
  1450     CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC( 
       
  1451                                                     iEikonEnv->WsSession(), id );
       
  1452     
       
  1453     wgName->SetHidden( aHide );
       
  1454     wgName->SetWindowGroupName( iEikonEnv->RootWin() );    
       
  1455     CleanupStack::PopAndDestroy( wgName ); 
       
  1456     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HideApplicationInFSW() end");
       
  1457     }
       
  1458  
       
  1459 // -----------------------------------------------------------------------------
       
  1460 // CIAUpdateAppUi::ShowGlobalErrorNoteL
       
  1461 // 
       
  1462 // -----------------------------------------------------------------------------
       
  1463 //     
       
  1464 void CIAUpdateAppUi::ShowGlobalErrorNoteL( TInt aError ) const
       
  1465     {
       
  1466     CErrorUI* errorUI = CErrorUI::NewLC( );     
       
  1467     errorUI->ShowGlobalErrorNoteL( aError );        
       
  1468     CleanupStack::PopAndDestroy( errorUI ); 	
       
  1469     }
       
  1470 
       
  1471 
       
  1472 
       
  1473 // ---------------------------------------------------------------------------
       
  1474 // CIAUpdateAppUi::UpdateQueryCallbackL
       
  1475 // ---------------------------------------------------------------------------
       
  1476 //
       
  1477 TInt CIAUpdateAppUi::UpdateQueryCallbackL( TAny* aPtr )
       
  1478     {
       
  1479     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::UpdateQueryCallbackL() begin");
       
  1480     CIAUpdateAppUi* appUI= static_cast<CIAUpdateAppUi*>( aPtr ); 
       
  1481     TRAPD( err, appUI->ShowUpdateQueryL() );
       
  1482     if ( err != KErrNone )
       
  1483         {
       
  1484     	appUI->HandleLeaveErrorL( err );
       
  1485         }
       
  1486     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::UpdateQueryCallbackL() end");
       
  1487     return KErrNone;
       
  1488     }    
       
  1489 
       
  1490     
       
  1491 // ---------------------------------------------------------------------------
       
  1492 // CIAUpdateAppUi::AutomaticCheckCallbackL
       
  1493 // ---------------------------------------------------------------------------
       
  1494 //    
       
  1495     
       
  1496 TInt CIAUpdateAppUi::AutomaticCheckCallbackL( TAny* aPtr )    
       
  1497     {
       
  1498 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::AutomaticCheckCallbackL() begin");
       
  1499 	CIAUpdateAppUi* appUI= static_cast<CIAUpdateAppUi*>( aPtr ); 
       
  1500 	
       
  1501 	TInt err = KErrNone;
       
  1502 	CIAUpdateAutomaticCheck* automaticCheck = NULL;
       
  1503 	TRAP( err, automaticCheck = CIAUpdateAutomaticCheck::NewL() ); 
       
  1504     if ( err != KErrNone )
       
  1505         {
       
  1506     	appUI->HandleLeaveErrorL( err );
       
  1507         }
       
  1508     else
       
  1509         {
       
  1510         CleanupStack::PushL( automaticCheck );
       
  1511         TRAP( err, automaticCheck->AcceptAutomaticCheckL() );
       
  1512         if ( err != KErrNone )
       
  1513             {
       
  1514     	    appUI->HandleLeaveErrorL( err );
       
  1515             }	
       
  1516         } 
       
  1517     
       
  1518     CleanupStack::PopAndDestroy( automaticCheck );
       
  1519 	
       
  1520 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::AutomaticCheckCallbackL() end");
       
  1521 	return KErrNone;
       
  1522     }
       
  1523     
       
  1524     
       
  1525     
       
  1526 // -----------------------------------------------------------------------------
       
  1527 // CIAUpdateAppUi::HandleTextLinkL
       
  1528 // 
       
  1529 // -----------------------------------------------------------------------------
       
  1530 // 
       
  1531 void CIAUpdateAppUi::HandleTextLinkL()
       
  1532     {
       
  1533     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleTextLinkL() begin");
       
  1534     if ( !iHistoryView )
       
  1535         {
       
  1536         iHistoryView = CIAUpdateHistoryView::NewL( iController->HistoryL() );
       
  1537          
       
  1538         AddViewL( iHistoryView );
       
  1539         }
       
  1540     ActivateLocalViewL( TUid::Uid( EIAUpdateHistoryViewId ) );
       
  1541     iShowStatusDialogAgain = ETrue;
       
  1542     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleTextLinkL() end");
       
  1543     }
       
  1544 
       
  1545 
       
  1546 
       
  1547 // -----------------------------------------------------------------------------
       
  1548 // CIAUpdateAppUi::SetDMSupport
       
  1549 // 
       
  1550 // -----------------------------------------------------------------------------
       
  1551 // 
       
  1552 void CIAUpdateAppUi::SetDMSupport( TBool aDMSupport )
       
  1553     {
       
  1554     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::SetDMSupport begin");
       
  1555     iIsDMSupported  = aDMSupport;
       
  1556     iIsDMSet = ETrue;;
       
  1557     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::SetDMSupport end");
       
  1558     }
       
  1559 
       
  1560 
       
  1561 // -----------------------------------------------------------------------------
       
  1562 // CIAUpdateAppUi::IsDMSupport
       
  1563 // 
       
  1564 // -----------------------------------------------------------------------------
       
  1565 //
       
  1566 TBool CIAUpdateAppUi::IsDMSupport()
       
  1567     {
       
  1568     return iIsDMSupported;
       
  1569     }
       
  1570 
       
  1571 
       
  1572 // -----------------------------------------------------------------------------
       
  1573 // CIAUpdateAppUi::IsDMSupportSet
       
  1574 // 
       
  1575 // -----------------------------------------------------------------------------
       
  1576 //
       
  1577 TBool CIAUpdateAppUi::IsDMSupportSet()
       
  1578     {
       
  1579     return iIsDMSet;
       
  1580     }
       
  1581 
       
  1582 TBool CIAUpdateAppUi::UiRefreshAllowed()
       
  1583     {
       
  1584     return iUiRefreshAllowed;
       
  1585     }
       
  1586 
       
  1587 // ---------------------------------------------------------------------------
       
  1588 // CIAUpdateAppUi::ForegroundDelayComplete
       
  1589 // 
       
  1590 // ---------------------------------------------------------------------------
       
  1591 //
       
  1592 void CIAUpdateAppUi::ForegroundDelayComplete( TInt aError )
       
  1593     {
       
  1594     IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateAppUi::ForegroundDelayComplete() begin: %d",
       
  1595                      aError);
       
  1596 
       
  1597     delete iForegroundTimer;
       
  1598     iForegroundTimer = NULL;
       
  1599     
       
  1600     iEikonEnv->RootWin().SetOrdinalPosition( 0 );
       
  1601 
       
  1602     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ForegroundDelayComplete() end");
       
  1603     }
       
  1604 
       
  1605 // ---------------------------------------------------------------------------
       
  1606 // CIAUpdateAppUi::BackgroundDelayComplete
       
  1607 // 
       
  1608 // ---------------------------------------------------------------------------
       
  1609 //
       
  1610 void CIAUpdateAppUi::BackgroundDelayComplete( TInt aError )
       
  1611     {
       
  1612     IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateAppUi::BackgroundDelayComplete() begin: %d",
       
  1613                      aError);
       
  1614 
       
  1615    delete iBackgroundTimer;
       
  1616     iBackgroundTimer = NULL;
       
  1617     
       
  1618     iEikonEnv->RootWin().SetOrdinalPosition( -1, ECoeWinPriorityNeverAtFront );
       
  1619 
       
  1620     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::BackgroundDelayComplete() end");
       
  1621     }
       
  1622 
       
  1623 // ---------------------------------------------------------------------------
       
  1624 // CIAUpdateAppUi::ProcessStartDelayComplete
       
  1625 // 
       
  1626 // ---------------------------------------------------------------------------
       
  1627 //
       
  1628 void CIAUpdateAppUi::ProcessStartDelayComplete( TInt /*aError*/ )
       
  1629     {
       
  1630     }
       
  1631     
       
  1632 
       
  1633 // End of File