iaupdate/IAD/ui/src/iaupdateappui.cpp
changeset 29 26b6f0522fd8
parent 25 98b66e4fb0be
child 30 398876c4ffa7
child 33 8110bf1194d1
equal deleted inserted replaced
25:98b66e4fb0be 29:26b6f0522fd8
     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 
       
   330             // by pushing object to cleanup stack it's destructor is called if leave happens
       
   331             // so global lock issued by this instance can be released in destructor of CIAUpdateGlobalLockHandler
       
   332             CIAUpdateGlobalLockHandler* globalLockHandler = CIAUpdateGlobalLockHandler::NewLC();
       
   333             if ( !globalLockHandler->InUseByAnotherInstanceL() )
       
   334                 {
       
   335             	globalLockHandler->SetToInUseForAnotherInstancesL( ETrue );
       
   336             	// No need to be totally silent since the updating is started
       
   337             	// by user.
       
   338             	SetDefaultConnectionMethodL( EFalse );
       
   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     
       
   582     delete iGlobalLockHandler;
       
   583     iGlobalLockHandler = NULL;
       
   584     iGlobalLockHandler = CIAUpdateGlobalLockHandler::NewL();
       
   585     if ( !iGlobalLockHandler->InUseByAnotherInstanceL() )
       
   586         {
       
   587         TBool totalSilent( EFalse );
       
   588         if ( iRequestType == IAUpdateUiDefines::ECheckUpdates )
       
   589             {
       
   590             if ( iController->Filter() )
       
   591                 {
       
   592                 if ( iController->Filter()->FilterParams() )
       
   593                     {
       
   594                     if ( iController->Filter()->FilterParams()->Refresh() )
       
   595                         {
       
   596                         //from bgchecker, make it silent
       
   597                         totalSilent = ETrue;
       
   598                         }
       
   599                     }
       
   600                 }
       
   601             }
       
   602         SetDefaultConnectionMethodL( totalSilent );
       
   603         iGlobalLockHandler->SetToInUseForAnotherInstancesL( ETrue );
       
   604         iController->StartRefreshL();  
       
   605         }
       
   606     else
       
   607         {
       
   608         RefreshCompleteL( ETrue, KErrServerBusy );
       
   609         }    
       
   610  
       
   611        
       
   612     
       
   613     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::StartupCompleteL() end");    
       
   614     }
       
   615     
       
   616  
       
   617 // -----------------------------------------------------------------------------
       
   618 // CIAUpdateAppUi::HandleLeaveErrorL
       
   619 // 
       
   620 // -----------------------------------------------------------------------------
       
   621 //        
       
   622 void CIAUpdateAppUi::HandleLeaveErrorL( TInt aError )
       
   623     {
       
   624     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleLeaveErrorL() begin");
       
   625     //removal of iGlobalLockHandler releases possible global operation lock to other IAD instances
       
   626     delete iGlobalLockHandler;
       
   627     iGlobalLockHandler = NULL;
       
   628     // client request is completed before leave in case of leave error
       
   629     if ( aError != KErrNone ) 
       
   630         { 	
       
   631     	InformRequestObserver( aError );
       
   632     	User::Leave( aError );
       
   633         }
       
   634     
       
   635     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleLeaveErrorL() end");
       
   636     }
       
   637 
       
   638 
       
   639 // -----------------------------------------------------------------------------
       
   640 // CIAUpdateAppUi::HandleLeaveErrorWithoutLeave
       
   641 // 
       
   642 // -----------------------------------------------------------------------------
       
   643 //  
       
   644 void CIAUpdateAppUi::HandleLeaveErrorWithoutLeave( TInt aError )
       
   645     {
       
   646 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleLeaveErrorWithoutLeave() begin");
       
   647 	//removal of iGlobalLockHandler releases possible global operation lock to other IAD instances
       
   648     delete iGlobalLockHandler;
       
   649     iGlobalLockHandler = NULL;
       
   650 	if ( aError != KErrNone ) 
       
   651         {
       
   652     	InformRequestObserver( aError );
       
   653         }
       
   654     if ( aError == KErrDiskFull )
       
   655         {
       
   656         TRAP_IGNORE( ShowGlobalErrorNoteL( aError ) );
       
   657         }
       
   658 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleLeaveErrorWithoutLeave end");
       
   659     }
       
   660 
       
   661 
       
   662 // -----------------------------------------------------------------------------
       
   663 // CIAUpdateAppUi::RefreshCompleteL
       
   664 // 
       
   665 // -----------------------------------------------------------------------------
       
   666 //      
       
   667 void CIAUpdateAppUi::RefreshCompleteL( TBool aWithViewActivation, TInt aError )
       
   668     {
       
   669     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::RefreshCompleteL() begin");
       
   670     IAUPDATE_TRACE_1("[IAUPDATE] error code: %d", aError );
       
   671     //removal of iGlobalLockHandler releases possible global operation lock to other IAD instances
       
   672     delete iGlobalLockHandler;
       
   673     iGlobalLockHandler = NULL;   
       
   674    
       
   675     if ( iRequestType == IAUpdateUiDefines::ECheckUpdates )
       
   676         {
       
   677   	    InformRequestObserver( aError );
       
   678         }
       
   679     else 
       
   680         {    
       
   681         RefreshL( aError );   
       
   682         if ( aWithViewActivation)
       
   683             {
       
   684         	ActivateLocalViewL( TUid::Uid( EIAUpdateMainViewId ) );
       
   685             }
       
   686  
       
   687         // By calling CIdle possible waiting dialog can be closed before
       
   688         // automatic check where a new dialog may be launched
       
   689         delete iIdleAutCheck;
       
   690         iIdleAutCheck = NULL;
       
   691         iIdleAutCheck = CIdle::NewL( CActive::EPriorityIdle ); 
       
   692         iIdleAutCheck->Start( TCallBack( AutomaticCheckCallbackL, this ) );
       
   693         } 
       
   694  
       
   695   
       
   696     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::RefreshCompleteL() end");        
       
   697     }
       
   698 
       
   699 // -----------------------------------------------------------------------------
       
   700 // CIAUpdateAppUi::UpdateCompleteL
       
   701 // 
       
   702 // -----------------------------------------------------------------------------
       
   703 //     
       
   704 void CIAUpdateAppUi::UpdateCompleteL( TInt aError )    
       
   705     {
       
   706     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::UpdateCompleteL begin");
       
   707     IAUPDATE_TRACE_1("[IAUPDATE] error code: %d", aError );
       
   708     //removal of iGlobalLockHandler releases possible global operation lock to other IAD instances
       
   709     delete iGlobalLockHandler;
       
   710     iGlobalLockHandler = NULL;  
       
   711     if ( iRequestType != IAUpdateUiDefines::ENoRequest )
       
   712         {
       
   713         InformRequestObserver( aError );
       
   714         }
       
   715     
       
   716     RefreshL( KErrNone ); 
       
   717       
       
   718     ShowStatusDialogDeferredL();
       
   719                 
       
   720     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::UpdateCompleteL end");
       
   721     }
       
   722 
       
   723    
       
   724 // -----------------------------------------------------------------------------
       
   725 // CIAUpdateAppUi::ShowStatusDialogL
       
   726 // 
       
   727 // -----------------------------------------------------------------------------
       
   728 //   
       
   729 void CIAUpdateAppUi::ShowStatusDialogL()
       
   730     {
       
   731     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowStatusDialogL() begin");
       
   732  
       
   733      
       
   734     if ( !iDialogParam )
       
   735         {
       
   736         iDialogParam = new( ELeave ) TIAUpdateDialogParam;
       
   737         }
       
   738     
       
   739     if ( !iShowStatusDialogAgain )
       
   740         {
       
   741         TIAUpdateResultsInfo resultsInfo( iController->ResultsInfo() );
       
   742         iDialogParam->iCountCancelled = resultsInfo.iCountCancelled;
       
   743         iDialogParam->iCountFailed = resultsInfo.iCountFailed;
       
   744         iDialogParam->iCountSuccessfull = resultsInfo.iCountSuccessfull;
       
   745         iDialogParam->iShowCloseAllText = resultsInfo.iFileInUseError;
       
   746         iRebootAfterInstall = resultsInfo.iRebootAfterInstall;
       
   747         iDialogParam->iLinkObserver = this;
       
   748         }
       
   749          
       
   750     iShowStatusDialogAgain = EFalse;
       
   751     iUiRefreshAllowed = ETrue;
       
   752     TInt ret = CIAUpdateStatusDialog::ShowDialogL( iDialogParam );
       
   753     if ( ret == EAknSoftkeyOk && iRebootAfterInstall )
       
   754         {
       
   755         TInt rebootRet = IAUpdateDialogUtil::ShowConfirmationQueryL( 
       
   756                                            R_IAUPDATE_PHONE_RESTART_QUERY, 
       
   757                                            R_AVKON_SOFTKEYS_OK_CANCEL__OK );
       
   758         if ( rebootRet == EAknSoftkeyOk )
       
   759             {
       
   760             RStarterSession startersession;
       
   761             if( startersession.Connect() == KErrNone )
       
   762                 {
       
   763                 startersession.Reset( RStarterSession::EUnknownReset );
       
   764                 startersession.Close();
       
   765                 return;
       
   766                 }
       
   767             }
       
   768         }
       
   769     if ( ret == EAknSoftkeyOk && 
       
   770          iStartedFromApplication && 
       
   771          iDialogParam->iCountCancelled == 0 &&
       
   772          iDialogParam->iCountFailed == 0 )
       
   773         {
       
   774     	HandleCommandL( EEikCmdExit );
       
   775         }
       
   776     
       
   777     IAUPDATE_TRACE_1("[IAUPDATE] nodes count: %d", iController->Nodes().Count() );
       
   778     IAUPDATE_TRACE_1("[IAUPDATE] fw nodes: %d", iController->FwNodes().Count() );
       
   779     //exit from result view if there are no update left
       
   780     if ( ret == EAknSoftkeyOk && (iController->Nodes().Count() == 0) && (iController->FwNodes().Count() == 0) )
       
   781         {
       
   782         HandleCommandL( EEikCmdExit );
       
   783         }
       
   784     
       
   785     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowStatusDialogL() end");
       
   786     }
       
   787 
       
   788 // -----------------------------------------------------------------------------
       
   789 // CIAUpdateAppUi::ShowStatusDialogDeferredL
       
   790 // 
       
   791 // -----------------------------------------------------------------------------
       
   792 //       
       
   793 void CIAUpdateAppUi::ShowStatusDialogDeferredL()
       
   794     {
       
   795     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowStatusDialogDeferredL() begin");
       
   796     delete iIdle;
       
   797     iIdle = NULL;
       
   798 	iIdle = CIdle::NewL( CActive::EPriorityIdle ); 
       
   799     iIdle->Start( TCallBack( ShowStatusDialogCallbackL, this ) ); 
       
   800     iUiRefreshAllowed = EFalse;
       
   801     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowStatusDialogDeferredL() end");
       
   802     }
       
   803  
       
   804 
       
   805 
       
   806                        
       
   807 // -----------------------------------------------------------------------------
       
   808 // CIAUpdateAppUi::RefreshL
       
   809 // 
       
   810 // -----------------------------------------------------------------------------
       
   811 //  
       
   812 void CIAUpdateAppUi::RefreshL( TInt aError ) 
       
   813     {
       
   814     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::RefreshL() begin");
       
   815     IAUPDATE_TRACE_1("[IAUPDATE] Error code: %d", aError );
       
   816     iMainView->RefreshL( iController->Nodes(), iController->FwNodes(), aError );                    
       
   817     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::RefreshL() end");
       
   818     }
       
   819     
       
   820 
       
   821 // -----------------------------------------------------------------------------
       
   822 // CIAUpdateAppUi::InformRequestObserver
       
   823 // 
       
   824 // -----------------------------------------------------------------------------
       
   825 //      
       
   826 void CIAUpdateAppUi::InformRequestObserver( TInt aError )
       
   827     {
       
   828     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::InformRequestObserver() begin");
       
   829         
       
   830     if ( iRequestObserver )
       
   831         {
       
   832         if ( iController->ClosingAllowedByClient() )
       
   833             {
       
   834             if ( iRequestType != IAUpdateUiDefines::ENoRequest )
       
   835                 {
       
   836                 if ( iRequestType == IAUpdateUiDefines::EUpdateQuery && iUpdateNow )
       
   837                     {
       
   838                     if ( !iBackgroundTimer )
       
   839                         {
       
   840                         iBackgroundTimer = CIAUpdateUITimer::NewL( *this, CIAUpdateUITimer::EBackgroundDelay );
       
   841                         }
       
   842                     if ( !iBackgroundTimer->IsActive() )
       
   843                         {
       
   844                         iBackgroundTimer->After( 500000 );
       
   845                         }
       
   846                     }
       
   847                 else
       
   848                     {
       
   849                     iEikonEnv->RootWin().SetOrdinalPosition( -1, ECoeWinPriorityNeverAtFront );
       
   850                     }
       
   851                 }
       
   852             }
       
   853         CIAUpdateResult* details( NULL );
       
   854         TRAPD( error, details = CIAUpdateResult::NewL() )
       
   855         if ( details )
       
   856             {
       
   857             TIAUpdateResultsInfo resultsInfo(
       
   858                 iController->ResultsInfo() );
       
   859             IAUPDATE_TRACE_3("[IAUPDATE] succeed: %d failed: %d  cancelled: %d", 
       
   860                               resultsInfo.iCountSuccessfull, 
       
   861                               resultsInfo.iCountFailed, 
       
   862                               resultsInfo.iCountCancelled );
       
   863             IAUPDATE_TRACE_2("[IAUPDATE] update now: %d available updates: %d", 
       
   864                               iUpdateNow, iController->CountOfAvailableUpdates() );
       
   865             details->SetSuccessCount( resultsInfo.iCountSuccessfull );
       
   866             details->SetFailCount( resultsInfo.iCountFailed );
       
   867             details->SetCancelCount( resultsInfo.iCountCancelled );    
       
   868             
       
   869             // Ownership of details is transferred here.
       
   870             iRequestObserver->RequestCompleted( details, 
       
   871                                                 iController->CountOfAvailableUpdates(), 
       
   872                                                 iUpdateNow, 
       
   873                                                 aError );
       
   874             details = NULL;        
       
   875             }
       
   876         else
       
   877             {
       
   878             iRequestObserver->RequestCompleted( details, 
       
   879                                                 iController->CountOfAvailableUpdates(),
       
   880                                                 iUpdateNow, 
       
   881                                                 error );            
       
   882             }
       
   883         iRequestObserver = NULL;
       
   884         }
       
   885         
       
   886     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::InformRequestObserver() end");
       
   887     }
       
   888 
       
   889 
       
   890 // ---------------------------------------------------------------------------
       
   891 // CIAUpdateAppUi::SetDefaultConnectionMethodL
       
   892 // Sets the connection method for the update network connection.
       
   893 // ---------------------------------------------------------------------------
       
   894 //
       
   895 void CIAUpdateAppUi::SetDefaultConnectionMethodL(TBool aTotalSilent )
       
   896     {
       
   897     if ( aTotalSilent )
       
   898         {
       
   899         // from back ground checker, choose the IAP to make the internet access silent
       
   900         IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::SetDefaultConnectionMethodL() begin");
       
   901 
       
   902            TUint32 connectionMethodId( 0 );
       
   903            TInt connMethodId( 0 );
       
   904 
       
   905            // Let's first check whether cenrep contains SNAP id other than zero
       
   906            CRepository* cenrep( CRepository::NewLC( KCRUidIAUpdateSettings ) );
       
   907            User::LeaveIfError(  
       
   908                cenrep->Get( KIAUpdateAccessPoint, connMethodId ) );
       
   909            CleanupStack::PopAndDestroy( cenrep ); 
       
   910            cenrep = NULL;
       
   911 
       
   912            RCmManagerExt cmManagerExt;
       
   913            cmManagerExt.OpenL();
       
   914            CleanupClosePushL( cmManagerExt );
       
   915            
       
   916            if ( connMethodId == -1 )
       
   917                {
       
   918                IAUPDATE_TRACE("[IAUPDATE] user chooses default connection, use IAP logic");
       
   919                
       
   920                //check what is the default connection by users     
       
   921                
       
   922                TCmDefConnValue DCSetting;
       
   923                cmManagerExt.ReadDefConnL( DCSetting );
       
   924               
       
   925                
       
   926                switch ( DCSetting.iType )
       
   927                    {
       
   928                    case ECmDefConnAlwaysAsk:
       
   929                    case ECmDefConnAskOnce:
       
   930                        {
       
   931                        //go with the best IAP under internet snap
       
   932                        connectionMethodId = GetBestIAPInAllSNAPsL( cmManagerExt );
       
   933                        break;
       
   934                        }
       
   935                    case ECmDefConnDestination:
       
   936                        {
       
   937                        //go with the best IAP under this snap
       
   938                        connectionMethodId = GetBestIAPInThisSNAPL( cmManagerExt, DCSetting.iId );
       
   939                        break;
       
   940                        }
       
   941                    case ECmDefConnConnectionMethod:
       
   942                        {
       
   943                        //go with the best IAP under this snap
       
   944                        connectionMethodId = DCSetting.iId;
       
   945                        break;
       
   946                        }
       
   947                    }
       
   948                }
       
   949            else if ( connMethodId == 0 )
       
   950                {
       
   951                //no choice from user, we go with the best IAP under Internent SNAP
       
   952                connectionMethodId = GetBestIAPInAllSNAPsL( cmManagerExt );
       
   953                }
       
   954            else
       
   955                {
       
   956                IAUPDATE_TRACE("[IAUPDATE] use chooses a snap");
       
   957                // It was some SNAP value
       
   958                connectionMethodId = GetBestIAPInThisSNAPL( cmManagerExt, connMethodId );
       
   959                }
       
   960 
       
   961            CleanupStack::PopAndDestroy( &cmManagerExt ); 
       
   962            
       
   963            if ( connectionMethodId != 0 )
       
   964                {
       
   965                TIAUpdateConnectionMethod connectionMethod( 
       
   966                    connectionMethodId, 
       
   967                    TIAUpdateConnectionMethod::EConnectionMethodTypeAccessPoint );
       
   968 
       
   969                iController->SetDefaultConnectionMethodL( connectionMethod );
       
   970                }
       
   971            else
       
   972                {
       
   973                //In the totally silent case, if no usable IAP, we complete the check update with 0 updates.
       
   974                //the bgchecker will try again later after 1 month. 
       
   975                //The LEAVE will be catched up later and complete the request from background checker.
       
   976                User::LeaveIfError( KErrNotFound );
       
   977                
       
   978                //the following code will pop up dialog to ask from user, just for proto
       
   979               /* connectionMethodId = 0;               
       
   980                TIAUpdateConnectionMethod connectionMethod( 
       
   981                    connectionMethodId, TIAUpdateConnectionMethod::EConnectionMethodTypeDefault );
       
   982 
       
   983                iController->SetDefaultConnectionMethodL( connectionMethod );*/
       
   984                }
       
   985            
       
   986 
       
   987 
       
   988            IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::SetDefaultConnectionMethodL() end");
       
   989         }
       
   990     else
       
   991         {
       
   992         // from grid, use the old logic
       
   993         IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::SetDefaultConnectionMethodL() begin");
       
   994                   TUint32 connectionMethodId( 0 );
       
   995                   TInt connMethodId( 0 );
       
   996 
       
   997                   // Set initial value to always ask
       
   998                   TInt connectionMethodType( TIAUpdateConnectionMethod::EConnectionMethodTypeAlwaysAsk );
       
   999                   TBool needSaving(EFalse);
       
  1000 
       
  1001                   // Let's first check whether cenrep contains SNAP id other than zero
       
  1002                   CRepository* cenrep( CRepository::NewLC( KCRUidIAUpdateSettings ) );
       
  1003                   User::LeaveIfError(  
       
  1004                       cenrep->Get( KIAUpdateAccessPoint, connMethodId ) );
       
  1005                   CleanupStack::PopAndDestroy( cenrep ); 
       
  1006                   cenrep = NULL;
       
  1007                     
       
  1008                   if ( connMethodId == -1 )
       
  1009                       {
       
  1010                       IAUPDATE_TRACE("[IAUPDATE] user chooses default connection, use IAP logic");
       
  1011                                             
       
  1012                       connectionMethodId = 0;
       
  1013                       connectionMethodType = TIAUpdateConnectionMethod::EConnectionMethodTypeDefault;
       
  1014                       }
       
  1015                   else if ( connMethodId == 0 )
       
  1016                       {
       
  1017                       
       
  1018                       IAUPDATE_TRACE("[IAUPDATE] use chooses nothing, use internal IAP logic");
       
  1019                       //if nothing is set by user, use our new logic
       
  1020                       //SetDefaultConnectionMethod2L();
       
  1021                       //return;
       
  1022                       // CenRep didn't contain any SNAP id. Let's try Internet SNAP then.
       
  1023                           
       
  1024                       RCmManagerExt cmManagerExt;
       
  1025                       cmManagerExt.OpenL();
       
  1026                       CleanupClosePushL( cmManagerExt );
       
  1027                       iDestIdArray.Reset();
       
  1028                       cmManagerExt.AllDestinationsL( iDestIdArray );
       
  1029 
       
  1030                       for ( TInt i = 0; i< iDestIdArray.Count(); i++ )
       
  1031                           {
       
  1032                           RCmDestinationExt dest = cmManagerExt.DestinationL( iDestIdArray[i] );
       
  1033                           CleanupClosePushL( dest );
       
  1034                            
       
  1035                           if ( dest.MetadataL( CMManager::ESnapMetadataInternet ) )
       
  1036                               {
       
  1037                               // Check whether Internet SNAP contains any IAP.
       
  1038                               if ( dest.ConnectionMethodCount() > 0 )
       
  1039                                   {
       
  1040                                   connectionMethodId = iDestIdArray[i];
       
  1041                                   needSaving = ETrue;
       
  1042                                   IAUPDATE_TRACE_1("[IAUPDATE] connectionMethodId: %d", connectionMethodId );
       
  1043                                   }
       
  1044                               CleanupStack::PopAndDestroy( &dest ); 
       
  1045                               break;
       
  1046                               }
       
  1047                                
       
  1048                           CleanupStack::PopAndDestroy( &dest ); 
       
  1049                           }
       
  1050                       iDestIdArray.Reset();
       
  1051                       CleanupStack::PopAndDestroy( &cmManagerExt ); 
       
  1052                       }
       
  1053                   else
       
  1054                       {
       
  1055                       IAUPDATE_TRACE("[IAUPDATE] use chooses a snap");
       
  1056                       // It was some SNAP value
       
  1057                       connectionMethodId = connMethodId;
       
  1058                       }
       
  1059                   
       
  1060                   if ( connectionMethodId > 0)
       
  1061                       {
       
  1062                       // We have now some valid SNAP id, either from CenRep or Internet SNAP
       
  1063                       connectionMethodType = TIAUpdateConnectionMethod::EConnectionMethodTypeDestination;
       
  1064                       // Save to cenrep if needed
       
  1065                       if ( needSaving )
       
  1066                           {
       
  1067                           cenrep = CRepository::NewLC( KCRUidIAUpdateSettings );
       
  1068                           TInt err = cenrep->StartTransaction( CRepository::EReadWriteTransaction );
       
  1069                           User::LeaveIfError( err );
       
  1070                           cenrep->CleanupCancelTransactionPushL();
       
  1071                           
       
  1072                           connMethodId = connectionMethodId;
       
  1073                           err = cenrep->Set( KIAUpdateAccessPoint, connMethodId );
       
  1074                           User::LeaveIfError( err );
       
  1075                           TUint32 ignore = KErrNone;
       
  1076                           User::LeaveIfError( cenrep->CommitTransaction( ignore ) );
       
  1077                           CleanupStack::PopAndDestroy(); // CleanupCancelTransactionPushL()
       
  1078                           CleanupStack::PopAndDestroy( cenrep );            
       
  1079                           }
       
  1080                       }
       
  1081 
       
  1082                   TIAUpdateConnectionMethod connectionMethod( 
       
  1083                       connectionMethodId, 
       
  1084                       static_cast< TIAUpdateConnectionMethod::TConnectionMethodType >( connectionMethodType ) );
       
  1085 
       
  1086                   iController->SetDefaultConnectionMethodL( connectionMethod );
       
  1087 
       
  1088                   IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::SetDefaultConnectionMethodL() end");
       
  1089         }
       
  1090 
       
  1091     }
       
  1092 
       
  1093 
       
  1094 // ---------------------------------------------------------------------------
       
  1095 // CIAUpdateAppUi::GetBestIAPInAllSNAPsL
       
  1096 // Sets the best IAP from all snaps
       
  1097 // ---------------------------------------------------------------------------
       
  1098 //
       
  1099 TUint32 CIAUpdateAppUi::GetBestIAPInAllSNAPsL( RCmManagerExt& aCmManagerExt  )
       
  1100     { 
       
  1101     //go with internet SNAP first.
       
  1102     TUint32 IAPID = 0;
       
  1103     IAPID = GetBestIAPInInternetSNAPL( aCmManagerExt );
       
  1104     
       
  1105     if ( IAPID )
       
  1106         {
       
  1107         return IAPID;
       
  1108         }
       
  1109     
       
  1110     //select IAP from rest of the SNAPs
       
  1111     iDestIdArray.Reset();
       
  1112     aCmManagerExt.AllDestinationsL( iDestIdArray );
       
  1113     
       
  1114     for ( TInt i = 0; i< iDestIdArray.Count(); i++ )
       
  1115         {
       
  1116         TUint32 SNAPID = iDestIdArray[i];                   
       
  1117         IAPID = GetBestIAPInThisSNAPL( aCmManagerExt, SNAPID );
       
  1118         if ( IAPID )
       
  1119             {
       
  1120             break;
       
  1121             }
       
  1122          }
       
  1123     iDestIdArray.Reset();
       
  1124     return IAPID;
       
  1125     }
       
  1126 
       
  1127 
       
  1128 
       
  1129 // ---------------------------------------------------------------------------
       
  1130 // CIAUpdateAppUi::GetBestIAPInInternetSNAPL
       
  1131 // Sets the best IAP from internet snap
       
  1132 // ---------------------------------------------------------------------------
       
  1133 //
       
  1134 TUint32 CIAUpdateAppUi::GetBestIAPInInternetSNAPL( RCmManagerExt& aCmManagerExt  )
       
  1135     {
       
  1136     //select IAP from Internet SNAP
       
  1137     iDestIdArray.Reset();
       
  1138     aCmManagerExt.AllDestinationsL( iDestIdArray );
       
  1139     TUint32 InternetSNAPID = 0;
       
  1140     for ( TInt i = 0; i< iDestIdArray.Count(); i++ )
       
  1141         {
       
  1142         RCmDestinationExt dest = aCmManagerExt.DestinationL( iDestIdArray[i] );
       
  1143         CleanupClosePushL( dest );
       
  1144                                      
       
  1145         if ( dest.MetadataL( CMManager::ESnapMetadataInternet ) )
       
  1146             {
       
  1147             InternetSNAPID = iDestIdArray[i];
       
  1148             CleanupStack::PopAndDestroy( &dest ); 
       
  1149             break;
       
  1150             }                     
       
  1151          CleanupStack::PopAndDestroy( &dest ); 
       
  1152          }
       
  1153     iDestIdArray.Reset();
       
  1154     
       
  1155     return GetBestIAPInThisSNAPL( aCmManagerExt, InternetSNAPID );
       
  1156     }
       
  1157 
       
  1158 
       
  1159 
       
  1160 // ---------------------------------------------------------------------------
       
  1161 // CIAUpdateAppUi::GetBestIAPInThisSNAPL
       
  1162 // Sets the best IAP from the given snap
       
  1163 // ---------------------------------------------------------------------------
       
  1164 //
       
  1165 TUint32 CIAUpdateAppUi::GetBestIAPInThisSNAPL( RCmManagerExt& aCmManagerExt, TUint32 aSNAPID  )
       
  1166     {
       
  1167     //get all usable IAPs
       
  1168     TConnMonIapInfoBuf iapInfo;
       
  1169     TRequestStatus status;
       
  1170                        
       
  1171     RConnectionMonitor connMon;
       
  1172     connMon.ConnectL();
       
  1173     CleanupClosePushL( connMon );
       
  1174     
       
  1175     connMon.GetPckgAttribute( EBearerIdAll, 0, KIapAvailability,iapInfo, status );
       
  1176     User::WaitForRequest( status );
       
  1177     User::LeaveIfError( status.Int() );
       
  1178     
       
  1179     CleanupStack::PopAndDestroy( &connMon ); 
       
  1180     
       
  1181     RCmDestinationExt dest = aCmManagerExt.DestinationL( aSNAPID );
       
  1182     CleanupClosePushL( dest );
       
  1183     
       
  1184     // Check whether the SNAP contains any IAP.
       
  1185     for  (TInt i = 0; i < dest.ConnectionMethodCount(); i++ )
       
  1186         {
       
  1187         RCmConnectionMethodExt cm =  dest.ConnectionMethodL( i );
       
  1188         CleanupClosePushL( cm );
       
  1189         
       
  1190         TUint32 iapid= cm.GetIntAttributeL( CMManager::ECmIapId );
       
  1191         
       
  1192         for ( TInt i = 0; i < iapInfo().iCount; i++ )
       
  1193             {
       
  1194             if ( iapInfo().iIap[i].iIapId == iapid )
       
  1195                 {
       
  1196                 CleanupStack::PopAndDestroy( 2 ); //cm & dest;
       
  1197                 return iapid;
       
  1198                 }
       
  1199             }    
       
  1200                                                                                  
       
  1201         CleanupStack::PopAndDestroy( &cm );
       
  1202         }
       
  1203     
       
  1204     CleanupStack::PopAndDestroy( &dest ); 
       
  1205     return 0;
       
  1206     }
       
  1207 
       
  1208 
       
  1209 
       
  1210 // ---------------------------------------------------------------------------
       
  1211 // CIAUpdateAppUi::ShowStatusDialogCallbackL
       
  1212 // ---------------------------------------------------------------------------
       
  1213 //
       
  1214 TInt CIAUpdateAppUi::ShowStatusDialogCallbackL( TAny* aPtr )
       
  1215     {
       
  1216     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowStatusDialogCallbackL() begin");
       
  1217     CIAUpdateAppUi* appUI= static_cast<CIAUpdateAppUi*>( aPtr ); 
       
  1218     TRAPD( err, appUI->ShowStatusDialogL() );
       
  1219     appUI->HandleLeaveErrorL( err );
       
  1220     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowStatusDialogCallbackL() end");
       
  1221     return KErrNone;
       
  1222     }
       
  1223 
       
  1224 
       
  1225 // -----------------------------------------------------------------------------
       
  1226 // CIAUpdateAppUi::SetVisibleL
       
  1227 // 
       
  1228 // -----------------------------------------------------------------------------
       
  1229 //  
       
  1230 void CIAUpdateAppUi::SetVisibleL( TBool aVisible )
       
  1231     {
       
  1232     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::SetVisibleL() begin");
       
  1233     IAUPDATE_TRACE_1("[IAUPDATE] visible: %d", aVisible );
       
  1234     if ( aVisible )
       
  1235         {
       
  1236         if ( iEikonEnv->RootWin().OrdinalPosition() != 0 || iEikonEnv->RootWin().OrdinalPriority() != ECoeWinPriorityNormal )
       
  1237             {
       
  1238             iEikonEnv->RootWin().SetOrdinalPosition( 0, ECoeWinPriorityNormal );
       
  1239             }
       
  1240         
       
  1241     	StatusPane()->MakeVisible( ETrue );
       
  1242         iMainView  = CIAUpdateMainView::NewL( ClientRect() ); 
       
  1243         AddViewL( iMainView );
       
  1244         ActivateLocalViewL( TUid::Uid( EIAUpdateMainViewId ) );
       
  1245         }
       
  1246     else
       
  1247         {
       
  1248         iEikonEnv->RootWin().SetOrdinalPosition( -1, ECoeWinPriorityNeverAtFront );
       
  1249         StatusPane()->MakeVisible( EFalse );
       
  1250         }
       
  1251     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::SetVisibleL() end");
       
  1252     }
       
  1253 
       
  1254 // -----------------------------------------------------------------------------
       
  1255 // CIAUpdateAppUi::Controller()
       
  1256 // 
       
  1257 // -----------------------------------------------------------------------------
       
  1258 //      
       
  1259 CIAUpdateUiController* CIAUpdateAppUi::Controller() const
       
  1260     {
       
  1261 	return iController;
       
  1262     }
       
  1263 
       
  1264 // -----------------------------------------------------------------------------
       
  1265 // CIAUpdateAppUi::PotentialCancel
       
  1266 // 
       
  1267 // -----------------------------------------------------------------------------
       
  1268 //
       
  1269 void CIAUpdateAppUi::PotentialCancel() 
       
  1270     {
       
  1271     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::PotentialCancel() begin");
       
  1272     iController->DoCancelIfAllowed();
       
  1273     HandleObserverRemoval();
       
  1274     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::PotentialCancel() end");
       
  1275     }
       
  1276     
       
  1277 // -----------------------------------------------------------------------------
       
  1278 // CIAUpdateAppUi::HandleClientToForegroundL
       
  1279 // 
       
  1280 // -----------------------------------------------------------------------------
       
  1281 //    
       
  1282 void CIAUpdateAppUi::HandleClientToForegroundL()
       
  1283     {
       
  1284     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleClientToForegroundL() begin");
       
  1285     if ( !iForegroundTimer )
       
  1286         {
       
  1287         iForegroundTimer = CIAUpdateUITimer::NewL( *this, CIAUpdateUITimer::EForegroundDelay );
       
  1288         }
       
  1289     if ( !iForegroundTimer->IsActive() )
       
  1290         {
       
  1291         iForegroundTimer->After( 700000 );
       
  1292         }
       
  1293 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleClientToForegroundL() end");
       
  1294     }
       
  1295     
       
  1296 // -----------------------------------------------------------------------------
       
  1297 // CIAUpdateAppUi::HandleAllClientsClosedL
       
  1298 // 
       
  1299 // -----------------------------------------------------------------------------
       
  1300 //    
       
  1301 void CIAUpdateAppUi::HandleAllClientsClosedL()
       
  1302     {
       
  1303     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleAllClientsClosedL() begin");
       
  1304 	HideApplicationInFSWL( EFalse );
       
  1305 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleAllClientsClosedL() end");
       
  1306     }
       
  1307     
       
  1308     
       
  1309 // -----------------------------------------------------------------------------
       
  1310 // CIAUpdateAppUi::ShowStatusDialogAgain
       
  1311 // 
       
  1312 // -----------------------------------------------------------------------------
       
  1313 //  
       
  1314 TBool CIAUpdateAppUi::ShowStatusDialogAgain() const
       
  1315     {
       
  1316     return iShowStatusDialogAgain;	
       
  1317     }
       
  1318 
       
  1319 
       
  1320 // -----------------------------------------------------------------------------
       
  1321 // CIAUpdateAppUi::StartWGListChangeMonitoring
       
  1322 // 
       
  1323 // -----------------------------------------------------------------------------
       
  1324 // 
       
  1325 void CIAUpdateAppUi::StartWGListChangeMonitoring()
       
  1326     {
       
  1327     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::StartWGListChangeMonitoring() begin");
       
  1328     iInstUiOnTop = EFalse;
       
  1329 	iEikonEnv->RootWin().EnableGroupListChangeEvents();
       
  1330 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::StartWGListChangeMonitoring() end");
       
  1331     }
       
  1332  
       
  1333 // -----------------------------------------------------------------------------
       
  1334 // CIAUpdateAppUi::StopWGListChangeMonitoring
       
  1335 // 
       
  1336 // -----------------------------------------------------------------------------
       
  1337 // 
       
  1338 void CIAUpdateAppUi::StopWGListChangeMonitoring()
       
  1339     {
       
  1340     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::StopWGListChangeMonitoring() begin");
       
  1341 	iEikonEnv->RootWin().DisableGroupListChangeEvents();
       
  1342 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::StopWGListChangeMonitoring() end");
       
  1343     }
       
  1344 
       
  1345 // -----------------------------------------------------------------------------
       
  1346 // CIAUpdateAppUi::SetClientWgId
       
  1347 // 
       
  1348 // -----------------------------------------------------------------------------
       
  1349 // 
       
  1350 void CIAUpdateAppUi::SetClientWgId( TInt aWgId )
       
  1351     {
       
  1352 	IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateAppUi::SetClientWgId() wgId %d", aWgId );
       
  1353 	iWgId = aWgId;
       
  1354     }
       
  1355 
       
  1356 // -----------------------------------------------------------------------------
       
  1357 // CIAUpdateAppUi::ClientInBackgroundL
       
  1358 // 
       
  1359 // -----------------------------------------------------------------------------
       
  1360 // 
       
  1361 TInt CIAUpdateAppUi::ClientInBackgroundL() const
       
  1362     {
       
  1363 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ClientInBackgroundL() begin");
       
  1364 	TBool inBackground = EFalse;
       
  1365 	if ( iWgId > 0 )
       
  1366 	    {
       
  1367 		CArrayFixFlat<TInt>*  wgArray = new( ELeave ) CArrayFixFlat<TInt>(10);  
       
  1368         CleanupStack::PushL( wgArray );
       
  1369         User::LeaveIfError( iEikonEnv->WsSession().WindowGroupList( 0, wgArray ) );  
       
  1370         TInt ownWgId = iEikonEnv->RootWin().Identifier();
       
  1371         if ( ( wgArray->At( 0 ) != ownWgId ) && ( wgArray->At( 0 ) != iWgId  ) )
       
  1372             {
       
  1373         	inBackground = ETrue;
       
  1374             }
       
  1375         CleanupStack::PopAndDestroy( wgArray );  
       
  1376 	    }
       
  1377 	IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateAppUi::ClientInBackgroundL() inBackground: %d", inBackground );
       
  1378     return inBackground;  
       
  1379     }
       
  1380 
       
  1381 
       
  1382 
       
  1383 // -----------------------------------------------------------------------------
       
  1384 // CIAUpdateAppUi::ShowUpdateQueryL
       
  1385 // 
       
  1386 // -----------------------------------------------------------------------------
       
  1387 //    
       
  1388 void CIAUpdateAppUi::ShowUpdateQueryL()
       
  1389     {
       
  1390     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowUpdateQueryL() begin");
       
  1391 	CIAUpdateQueryHistory* updateQueryHistory = CIAUpdateQueryHistory::NewL();
       
  1392 	// Get the delay information from the controller that has read it from
       
  1393 	// the config file.
       
  1394 	updateQueryHistory->SetDelay( iController->ConfigData().QueryHistoryDelayHours() );
       
  1395     CleanupStack::PushL( updateQueryHistory );
       
  1396     if ( !updateQueryHistory->IsDelayedL( iUpdatequeryUid ) )
       
  1397         {
       
  1398         if ( ClientInBackgroundL() )
       
  1399             {
       
  1400     	    iEikonEnv->RootWin().SetOrdinalPosition( -1, ECoeWinPriorityNormal );
       
  1401             }
       
  1402         else
       
  1403             {
       
  1404             iEikonEnv->RootWin().SetOrdinalPosition( 0, ECoeWinPriorityNormal );	
       
  1405             }
       
  1406    	    TInt ret = IAUpdateDialogUtil::ShowConfirmationQueryL( 
       
  1407    	                                  R_IAUPDATE_PROGRAM_UPDATE, 
       
  1408 	                                  R_IAUPDATE_SOFTKEYS_NOW_LATER__NOW );
       
  1409 	    switch ( ret )
       
  1410 	        {
       
  1411 	        case EIAUpdateSoftkeyNow:
       
  1412 	            IAUPDATE_TRACE("[IAUPDATE] EIAUpdateSoftkeyNow");
       
  1413 	            iUpdateNow = ETrue;
       
  1414 	            break;
       
  1415 
       
  1416 	        case EIAUpdateSoftkeyLater:
       
  1417 	            IAUPDATE_TRACE("[IAUPDATE] EIAUpdateSoftkeyLater");
       
  1418 	        	updateQueryHistory->SetTimeL( iUpdatequeryUid );
       
  1419 	            break;
       
  1420 	            
       
  1421 	        default: //case of cancel (eq. End key)
       
  1422 	            break;
       
  1423 	        }     
       
  1424         }
       
  1425     CleanupStack::PopAndDestroy( updateQueryHistory );
       
  1426 	InformRequestObserver( KErrNone );	
       
  1427 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ShowUpdateQueryL() end");
       
  1428     }
       
  1429 
       
  1430 
       
  1431 // -----------------------------------------------------------------------------
       
  1432 // CIAUpdateAppUi::HideApplicationInFSWL
       
  1433 // 
       
  1434 // -----------------------------------------------------------------------------
       
  1435 //  
       
  1436 void CIAUpdateAppUi::HideApplicationInFSWL( TBool aHide )
       
  1437     {
       
  1438     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HideApplicationInFSW() begin");
       
  1439     IAUPDATE_TRACE_1("[IAUPDATE] hide: %d", aHide );
       
  1440     TInt id = iEikonEnv->RootWin().Identifier();
       
  1441 
       
  1442     CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC( 
       
  1443                                                     iEikonEnv->WsSession(), id );
       
  1444     
       
  1445     wgName->SetHidden( aHide );
       
  1446     wgName->SetWindowGroupName( iEikonEnv->RootWin() );    
       
  1447     CleanupStack::PopAndDestroy( wgName ); 
       
  1448     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HideApplicationInFSW() end");
       
  1449     }
       
  1450  
       
  1451 // -----------------------------------------------------------------------------
       
  1452 // CIAUpdateAppUi::ShowGlobalErrorNoteL
       
  1453 // 
       
  1454 // -----------------------------------------------------------------------------
       
  1455 //     
       
  1456 void CIAUpdateAppUi::ShowGlobalErrorNoteL( TInt aError ) const
       
  1457     {
       
  1458     CErrorUI* errorUI = CErrorUI::NewLC( );     
       
  1459     errorUI->ShowGlobalErrorNoteL( aError );        
       
  1460     CleanupStack::PopAndDestroy( errorUI ); 	
       
  1461     }
       
  1462 
       
  1463 
       
  1464 
       
  1465 // ---------------------------------------------------------------------------
       
  1466 // CIAUpdateAppUi::UpdateQueryCallbackL
       
  1467 // ---------------------------------------------------------------------------
       
  1468 //
       
  1469 TInt CIAUpdateAppUi::UpdateQueryCallbackL( TAny* aPtr )
       
  1470     {
       
  1471     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::UpdateQueryCallbackL() begin");
       
  1472     CIAUpdateAppUi* appUI= static_cast<CIAUpdateAppUi*>( aPtr ); 
       
  1473     TRAPD( err, appUI->ShowUpdateQueryL() );
       
  1474     if ( err != KErrNone )
       
  1475         {
       
  1476     	appUI->HandleLeaveErrorL( err );
       
  1477         }
       
  1478     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::UpdateQueryCallbackL() end");
       
  1479     return KErrNone;
       
  1480     }    
       
  1481 
       
  1482     
       
  1483 // ---------------------------------------------------------------------------
       
  1484 // CIAUpdateAppUi::AutomaticCheckCallbackL
       
  1485 // ---------------------------------------------------------------------------
       
  1486 //    
       
  1487     
       
  1488 TInt CIAUpdateAppUi::AutomaticCheckCallbackL( TAny* aPtr )    
       
  1489     {
       
  1490 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::AutomaticCheckCallbackL() begin");
       
  1491 	CIAUpdateAppUi* appUI= static_cast<CIAUpdateAppUi*>( aPtr ); 
       
  1492 	
       
  1493 	TInt err = KErrNone;
       
  1494 	CIAUpdateAutomaticCheck* automaticCheck = NULL;
       
  1495 	TRAP( err, automaticCheck = CIAUpdateAutomaticCheck::NewL() ); 
       
  1496     if ( err != KErrNone )
       
  1497         {
       
  1498     	appUI->HandleLeaveErrorL( err );
       
  1499         }
       
  1500     else
       
  1501         {
       
  1502         CleanupStack::PushL( automaticCheck );
       
  1503         TRAP( err, automaticCheck->AcceptAutomaticCheckL() );
       
  1504         if ( err != KErrNone )
       
  1505             {
       
  1506     	    appUI->HandleLeaveErrorL( err );
       
  1507             }	
       
  1508         } 
       
  1509     
       
  1510     CleanupStack::PopAndDestroy( automaticCheck );
       
  1511 	
       
  1512 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::AutomaticCheckCallbackL() end");
       
  1513 	return KErrNone;
       
  1514     }
       
  1515     
       
  1516     
       
  1517     
       
  1518 // -----------------------------------------------------------------------------
       
  1519 // CIAUpdateAppUi::HandleTextLinkL
       
  1520 // 
       
  1521 // -----------------------------------------------------------------------------
       
  1522 // 
       
  1523 void CIAUpdateAppUi::HandleTextLinkL()
       
  1524     {
       
  1525     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleTextLinkL() begin");
       
  1526     if ( !iHistoryView )
       
  1527         {
       
  1528         iHistoryView = CIAUpdateHistoryView::NewL( iController->HistoryL() );
       
  1529          
       
  1530         AddViewL( iHistoryView );
       
  1531         }
       
  1532     ActivateLocalViewL( TUid::Uid( EIAUpdateHistoryViewId ) );
       
  1533     iShowStatusDialogAgain = ETrue;
       
  1534     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::HandleTextLinkL() end");
       
  1535     }
       
  1536 
       
  1537 
       
  1538 
       
  1539 // -----------------------------------------------------------------------------
       
  1540 // CIAUpdateAppUi::SetDMSupport
       
  1541 // 
       
  1542 // -----------------------------------------------------------------------------
       
  1543 // 
       
  1544 void CIAUpdateAppUi::SetDMSupport( TBool aDMSupport )
       
  1545     {
       
  1546     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::SetDMSupport begin");
       
  1547     iIsDMSupported  = aDMSupport;
       
  1548     iIsDMSet = ETrue;;
       
  1549     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::SetDMSupport end");
       
  1550     }
       
  1551 
       
  1552 
       
  1553 // -----------------------------------------------------------------------------
       
  1554 // CIAUpdateAppUi::IsDMSupport
       
  1555 // 
       
  1556 // -----------------------------------------------------------------------------
       
  1557 //
       
  1558 TBool CIAUpdateAppUi::IsDMSupport()
       
  1559     {
       
  1560     return iIsDMSupported;
       
  1561     }
       
  1562 
       
  1563 
       
  1564 // -----------------------------------------------------------------------------
       
  1565 // CIAUpdateAppUi::IsDMSupportSet
       
  1566 // 
       
  1567 // -----------------------------------------------------------------------------
       
  1568 //
       
  1569 TBool CIAUpdateAppUi::IsDMSupportSet()
       
  1570     {
       
  1571     return iIsDMSet;
       
  1572     }
       
  1573 
       
  1574 TBool CIAUpdateAppUi::UiRefreshAllowed()
       
  1575     {
       
  1576     return iUiRefreshAllowed;
       
  1577     }
       
  1578 
       
  1579 // ---------------------------------------------------------------------------
       
  1580 // CIAUpdateAppUi::ForegroundDelayComplete
       
  1581 // 
       
  1582 // ---------------------------------------------------------------------------
       
  1583 //
       
  1584 void CIAUpdateAppUi::ForegroundDelayComplete( TInt aError )
       
  1585     {
       
  1586     IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateAppUi::ForegroundDelayComplete() begin: %d",
       
  1587                      aError);
       
  1588 
       
  1589     delete iForegroundTimer;
       
  1590     iForegroundTimer = NULL;
       
  1591     
       
  1592     iEikonEnv->RootWin().SetOrdinalPosition( 0 );
       
  1593 
       
  1594     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::ForegroundDelayComplete() end");
       
  1595     }
       
  1596 
       
  1597 // ---------------------------------------------------------------------------
       
  1598 // CIAUpdateAppUi::BackgroundDelayComplete
       
  1599 // 
       
  1600 // ---------------------------------------------------------------------------
       
  1601 //
       
  1602 void CIAUpdateAppUi::BackgroundDelayComplete( TInt aError )
       
  1603     {
       
  1604     IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateAppUi::BackgroundDelayComplete() begin: %d",
       
  1605                      aError);
       
  1606 
       
  1607    delete iBackgroundTimer;
       
  1608     iBackgroundTimer = NULL;
       
  1609     
       
  1610     iEikonEnv->RootWin().SetOrdinalPosition( -1, ECoeWinPriorityNeverAtFront );
       
  1611 
       
  1612     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::BackgroundDelayComplete() end");
       
  1613     }
       
  1614 
       
  1615 // ---------------------------------------------------------------------------
       
  1616 // CIAUpdateAppUi::ProcessStartDelayComplete
       
  1617 // 
       
  1618 // ---------------------------------------------------------------------------
       
  1619 //
       
  1620 void CIAUpdateAppUi::ProcessStartDelayComplete( TInt /*aError*/ )
       
  1621     {
       
  1622     }
       
  1623     
       
  1624 
       
  1625 // End of File