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