hotspotfw/hsbrowser/src/hsbrowsercontainer.cpp
branchRCL_3
changeset 54 63be7eb3fc78
parent 52 b852595f5cbe
child 55 f28ada11abbf
equal deleted inserted replaced
52:b852595f5cbe 54:63be7eb3fc78
     1 /*
       
     2 * Copyright (c) 2007 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:   Implementation of the container control for HotSpot Browser Application.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <eiklabel.h>
       
    20 #include <avkon.hrh>
       
    21 #include <hsbrowser.rsg>
       
    22 #include <brctlinterface.h>
       
    23 #include <charconv.h>
       
    24 #include <gdi.h>
       
    25 #include <bitdev.h>
       
    26 #include <eikenv.h> 
       
    27 #include <AknDef.h>
       
    28 #include <AknUtils.h>
       
    29 #include <apgtask.h>
       
    30 #include <es_enum.h>
       
    31 #include <coecobs.h>
       
    32 #include <coecntrl.h>
       
    33 #include <apgwgnam.h>
       
    34 #include <aknnavi.h> 
       
    35 #include <AknIndicatorContainer.h>
       
    36 #include <aknnavilabel.h> 
       
    37 #include <aknnavide.h>
       
    38 #include <aknappui.h>
       
    39 #include <aknnotewrappers.h> 
       
    40 #include <StringLoader.h>
       
    41 #include <bautils.h>
       
    42 #include <data_caging_path_literals.hrh>
       
    43 #include <AknGlobalNote.h>
       
    44 #include <hlplch.h>
       
    45 
       
    46 #include "hotspotclientserver.h"
       
    47 #include "hsbrowsercontainer.h"
       
    48 #include "hsbrowserloadeventobserver.h"
       
    49 #include "hsbrowserloadeventobserver.h"
       
    50 #include "hsbrowserspecialloadobserver.h"
       
    51 #include "hsbrowserictsobserver.h"
       
    52 #include "hsbrowserhssrvnotifs.h"
       
    53 #include "hsbrowsermodel.h"
       
    54 #include "hsbrowsercommon.h"
       
    55 #include "am_debug.h"
       
    56 
       
    57 // ================= MEMBER FUNCTIONS =======================
       
    58 
       
    59 // ---------------------------------------------------------
       
    60 // CHsBrowserContainer::CHsBrowserContainer()
       
    61 // Constructor.
       
    62 // ---------------------------------------------------------
       
    63 //
       
    64 CHsBrowserContainer::CHsBrowserContainer( CHsBrowserModel* aModel ) :
       
    65     iModel( aModel ),
       
    66     iNaviPane( NULL ),
       
    67     iEditorIndicatorContainer( NULL),
       
    68     iIndiContainer( NULL ),
       
    69     iResource( 0 ),
       
    70     iActiveInputBox( EFalse )
       
    71 	{
       
    72 	DEBUG( "CHsBrowserContainer::CHsBrowserContainer()" );
       
    73 	}
       
    74 
       
    75 
       
    76 // ---------------------------------------------------------
       
    77 // CHsBrowserContainer::ConstructL(const TRect& aRect)
       
    78 // EPOC two phased constructor
       
    79 // ---------------------------------------------------------
       
    80 //
       
    81 void CHsBrowserContainer::ConstructL( const TRect& aRect )
       
    82     {
       
    83     DEBUG( "CHsBrowserContainer::ConstructL()" );
       
    84     CreateWindowL();
       
    85         
       
    86     // create observers
       
    87     iHsBrowserSpecialLoadObserver = CHsBrowserSpecialLoadObserver::NewL();
       
    88     iHsBrowserLoadEventObserver = CHsBrowserLoadEventObserver::NewL( this );
       
    89     iHsBrowserIctsObserver = CHsBrowserIctsObserver::NewL( this );
       
    90     iHsBrowserHsSrvNotifs = CHsBrowserHsSrvNotifs::NewL( this );
       
    91     
       
    92     iCommandBase = TBrCtlDefs::ECommandIdBase;
       
    93     TUint brCtlCapabilities = TBrCtlDefs::ECapabilityLoadHttpFw |
       
    94                               TBrCtlDefs::ECapabilityDisplayScrollBar |
       
    95                               TBrCtlDefs::ECapabilityCursorNavigation;
       
    96     iBrCtlInterface = CreateBrowserControlL(
       
    97         this, 
       
    98         aRect, 
       
    99         brCtlCapabilities,
       
   100         iCommandBase, 
       
   101         NULL,  // softkey observer
       
   102         NULL,  // link resolver
       
   103         iHsBrowserSpecialLoadObserver,
       
   104         NULL,  // layout observer
       
   105         NULL,  // dialog provider
       
   106         NULL,  // window observer
       
   107         NULL );// download observer 
       
   108       
       
   109     // disable ESettingsSecurityWarnings setting,
       
   110     // or implement MBrCtlDialogsProvider interface
       
   111     // reason: default implementation of MBrCtlDialogsProvider::DialogConfirmL
       
   112     // returns EFalse and page is not loaded.
       
   113     iBrCtlInterface->SetBrowserSettingL(
       
   114         TBrCtlDefs::ESettingsSecurityWarnings, EFalse );
       
   115    
       
   116     // auto load on
       
   117     iBrCtlInterface->SetBrowserSettingL ( 
       
   118             TBrCtlDefs::ESettingsAutoLoadImages, 
       
   119             ETrue);
       
   120 
       
   121     iBrCtlInterface->SetBrowserSettingL ( 
       
   122             TBrCtlDefs::ESettingsCookiesEnabled, 
       
   123             ETrue);
       
   124     
       
   125     iBrCtlInterface->SetBrowserSettingL ( 
       
   126             TBrCtlDefs::ESettingsCSSFetchEnabled, 
       
   127             ETrue);
       
   128      
       
   129      iBrCtlInterface->SetBrowserSettingL ( 
       
   130             TBrCtlDefs::ESettingsECMAScriptEnabled, 
       
   131             ETrue);
       
   132 
       
   133     // this observer can be added and removed dynamically
       
   134     iBrCtlInterface->AddLoadEventObserverL( iHsBrowserLoadEventObserver );     
       
   135     
       
   136     // init navi pane indicators
       
   137     InitNaviPaneL();
       
   138             
       
   139     // load resource file
       
   140     TFileName fileName;           
       
   141     fileName.Append( KDriveZ );
       
   142     fileName.Append( KDC_APP_RESOURCE_DIR );   
       
   143     fileName.Append( KResourceFile );
       
   144     BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(),
       
   145                                     fileName );
       
   146     iResource = CCoeEnv::Static()->AddResourceFileL( fileName );
       
   147     
       
   148     HBufC* title = StringLoader::LoadL( R_QTN_NETW_CONSET_WBA_STATIC_TITLE );
       
   149 
       
   150     iModel->SetStaticTitle( *title );
       
   151     delete title;
       
   152     
       
   153     // activate WLAN MGMT API notifications,
       
   154     // we need to know when network is lost
       
   155     iMgtClient = CWlanMgmtClient::NewL();
       
   156     iMgtClient->ActivateNotificationsL( *iHsBrowserHsSrvNotifs );
       
   157     
       
   158     SetRect( aRect ); // set the size
       
   159     ActivateL(); // activate the window
       
   160     SetFocus( ETrue );
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------
       
   164 // CHsBrowserContainer::~CHsBrowserContainer()
       
   165 // Destructor.
       
   166 // ---------------------------------------------------------
       
   167 //
       
   168 CHsBrowserContainer::~CHsBrowserContainer()
       
   169     {
       
   170     DEBUG( "CHsBrowserContainer::~CHsBrowserContainer()" );
       
   171     if ( iMgtClient )
       
   172         {
       
   173         iMgtClient->CancelNotifications();
       
   174         delete iMgtClient;
       
   175         }
       
   176     
       
   177     iBrCtlInterface->RemoveLoadEventObserver( iHsBrowserLoadEventObserver );
       
   178     delete iBrCtlInterface;
       
   179     
       
   180     // delete observers
       
   181     delete iHsBrowserSpecialLoadObserver;
       
   182     delete iHsBrowserLoadEventObserver;
       
   183     delete iHsBrowserIctsObserver;
       
   184     
       
   185     // cancels also notifications
       
   186     delete iHsBrowserHsSrvNotifs;
       
   187     
       
   188     if ( iResource )
       
   189         {
       
   190         CCoeEnv::Static()->DeleteResourceFile( iResource );        
       
   191         }
       
   192     
       
   193     delete iEditorIndicatorContainer;      
       
   194     DEBUG( "CHsBrowserContainer::~CHsBrowserContainer() DONE" );
       
   195     }
       
   196 
       
   197 
       
   198 // ---------------------------------------------------------
       
   199 // CHsBrowserContainer::InitNaviPaneL()
       
   200 // Initializes the indicators in the navi pane.
       
   201 // ---------------------------------------------------------
       
   202 //
       
   203 void CHsBrowserContainer::InitNaviPaneL()
       
   204 	{
       
   205     DEBUG( "CHsBrowserContainer::InitNaviPaneL()" );
       
   206     if ( !iEditorIndicatorContainer )
       
   207         {
       
   208         CEikStatusPane* statusPane = iAvkonAppUi->StatusPane();        
       
   209         if ( statusPane )
       
   210             {
       
   211             iNaviPane = (CAknNavigationControlContainer*)
       
   212                 statusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) );
       
   213             if ( iNaviPane )
       
   214             	{
       
   215             	iEditorIndicatorContainer =
       
   216             	    iNaviPane->CreateEditorIndicatorContainerL();
       
   217             	}
       
   218             }
       
   219         }
       
   220 
       
   221    	if ( !iIndiContainer && iEditorIndicatorContainer )
       
   222         {
       
   223         iIndiContainer = (CAknIndicatorContainer*) iEditorIndicatorContainer->DecoratedControl();
       
   224     	}
       
   225     
       
   226     if ( iNaviPane && iEditorIndicatorContainer )
       
   227     	{
       
   228     	iNaviPane->PushL( *iEditorIndicatorContainer );
       
   229     	}
       
   230         	
       
   231 	}
       
   232 
       
   233 // ---------------------------------------------------------
       
   234 // CHsBrowserContainer::SizeChanged()
       
   235 // Called by framework when the view size is changed
       
   236 // ---------------------------------------------------------
       
   237 //
       
   238 void CHsBrowserContainer::SizeChanged()
       
   239     {
       
   240     DEBUG( "CHsBrowserContainer::SizeChanged()" );
       
   241     iBrCtlInterface->SetRect(Rect());
       
   242     }
       
   243 
       
   244 // ---------------------------------------------------------
       
   245 // CHsBrowserContainer::CountComponentControls() const
       
   246 // ---------------------------------------------------------
       
   247 //
       
   248 TInt CHsBrowserContainer::CountComponentControls() const
       
   249     {
       
   250     return KComponentsNumber;
       
   251     }
       
   252 
       
   253 // ---------------------------------------------------------
       
   254 // CHsBrowserContainer::ComponentControl(TInt aIndex) const
       
   255 // ---------------------------------------------------------
       
   256 //
       
   257 CCoeControl* CHsBrowserContainer::ComponentControl(TInt aIndex) const
       
   258     {
       
   259     switch ( aIndex )
       
   260         {
       
   261         case KBrCtlComponentIndex:
       
   262             return iBrCtlInterface;
       
   263         default:
       
   264             return NULL;
       
   265         }
       
   266     }
       
   267 
       
   268 
       
   269 // ------------------------------------------------------------------
       
   270 // CHsBrowserContainer::UpdateNaviPane( TNaviPaneEvent aUpdateEvent )
       
   271 // ------------------------------------------------------------------
       
   272 //
       
   273 void CHsBrowserContainer::UpdateNaviPane( TNaviPaneEvent aUpdateEvent )
       
   274 	{
       
   275 	DEBUG( "CHsBrowserContainer::UpdateNaviPane()" );
       
   276 	
       
   277     iIndiContainer->SetIndicatorState(
       
   278         TUid::Uid( EAknNaviPaneEditorIndicatorMessageInfo ),
       
   279         EAknIndicatorStateOn );
       
   280                 
       
   281 	switch( aUpdateEvent )
       
   282         {
       
   283         case ELoadingLoginPage:
       
   284             {
       
   285             TRAP_IGNORE( iIndiContainer->SetIndicatorValueL(
       
   286                 TUid::Uid( EAknNaviPaneEditorIndicatorMessageInfo ),
       
   287                 *iModel->StaticTitle() ) );
       
   288             iIndiContainer->SetIndicatorState(
       
   289                 TUid::Uid( EAknNaviPaneEditorIndicatorWaitBar ),  
       
   290                 EAknIndicatorStateAnimate );
       
   291             break;
       
   292             }
       
   293         case ELoadingUrl:
       
   294             {
       
   295             iIndiContainer->SetIndicatorState(
       
   296                 TUid::Uid( EAknNaviPaneEditorIndicatorWaitBar ),  
       
   297                 EAknIndicatorStateAnimate );
       
   298             break;
       
   299             }
       
   300         case EPageTitleAvailable:
       
   301             {
       
   302             TRAP_IGNORE( iIndiContainer->SetIndicatorValueL(
       
   303                 TUid::Uid( EAknNaviPaneEditorIndicatorMessageInfo ),
       
   304                 *iModel->PageTitle() ) );
       
   305             break;
       
   306             }
       
   307         case ELoadingFinished:
       
   308             {
       
   309             iIndiContainer->SetIndicatorState(
       
   310                 TUid::Uid( EAknNaviPaneEditorIndicatorWaitBar ),  
       
   311                 EAknIndicatorStateOff );
       
   312             break;
       
   313             }
       
   314         }
       
   315         
       
   316         iIndiContainer->DrawNow();
       
   317 	}
       
   318 
       
   319 // ----------------------------------------------------
       
   320 // CHsBrowserContainer::HandleCommandL(TInt aCommand)
       
   321 // ----------------------------------------------------
       
   322 //
       
   323 void CHsBrowserContainer::HandleCommandL(TInt aCommand)
       
   324     {
       
   325     DEBUG1( "CHsBrowserContainer::HandleCommandL() aCommand=%d", aCommand );
       
   326     switch ( aCommand )
       
   327         {
       
   328         case EAknSoftkeyNext:
       
   329             ShowLoginCompleteNote();
       
   330             SendToBackground();
       
   331             break;
       
   332         case EAknSoftkeyCancel:
       
   333         case EAknSoftkeyBack:
       
   334         case EAknSoftkeyExit:
       
   335         case EEikCmdExit:
       
   336             {
       
   337             iBrCtlInterface->HandleCommandL( 
       
   338                     TBrCtlDefs::ECommandCancelFetch + 
       
   339                     TBrCtlDefs::ECommandIdBase );
       
   340             iModel->SetState( EHsBrowserUiClosed, ETrue );
       
   341             break;
       
   342             }
       
   343         case EAknCmdHelp:
       
   344             {
       
   345             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   346                     iEikonEnv->EikAppUi()->AppHelpContextL());
       
   347             break;
       
   348             }
       
   349         default:
       
   350             if ( aCommand >= iCommandBase &&
       
   351                     aCommand < iCommandBase + TBrCtlDefs::ECommandIdRange )
       
   352                 {
       
   353                 iBrCtlInterface->HandleCommandL( aCommand );
       
   354                 }              
       
   355             break;      
       
   356         }    
       
   357     }
       
   358 
       
   359 // ----------------------------------------------------
       
   360 // CHsBrowserContainer::HandleKeyEventL(
       
   361 //     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
       
   362 // ----------------------------------------------------
       
   363 //
       
   364 TKeyResponse CHsBrowserContainer::HandleKeyEventL(
       
   365     const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
       
   366     {
       
   367     return EKeyWasNotConsumed;
       
   368     }
       
   369 
       
   370 // ----------------------------------------------------
       
   371 // CHsBrowserContainer::SendToForeground()
       
   372 // ----------------------------------------------------
       
   373 //
       
   374 void CHsBrowserContainer::SendToForeground()
       
   375 	{
       
   376 	DEBUG( "CHsBrowserContainer::SendToForeground()" );
       
   377 	    
       
   378     // because "Connecting via..." note hides hsbrowser,
       
   379     // send hsbrowser to foreground
       
   380     CCoeEnv::Static()->RootWin().SetOrdinalPosition( 0,
       
   381     		ECoeWinPriorityNormal );
       
   382     CCoeEnv::Static()->WsSession().Flush();  
       
   383 	}
       
   384 
       
   385 // ----------------------------------------------------
       
   386 // CHsBrowserContainer::RestorePositionAndPriority()
       
   387 // ----------------------------------------------------
       
   388 //
       
   389 void CHsBrowserContainer::RestorePositionAndPriority()
       
   390 	{
       
   391 	DEBUG( "CHsBrowserContainer::RestorePositionAndPriority()" );
       
   392 
       
   393     RWindowGroup& wg = CEikonEnv::Static()->RootWin();
       
   394 	
       
   395     // because "Connecting via..." note hides hsbrowser,
       
   396     // it was assigned ECoeWinPriorityAlwaysAtFront priority,
       
   397     // restore original now
       
   398     if ( wg.OrdinalPriority() == ECoeWinPriorityAlwaysAtFront )
       
   399     	{	
       
   400     	CCoeEnv::Static()->RootWin().SetOrdinalPosition(
       
   401     	        iModel->Position(), iModel->Priority() ); 	    	
       
   402 	    }
       
   403 	}
       
   404 
       
   405 // ---------------------------------------------------------
       
   406 // CHsBrowserContainer::SendToBackground
       
   407 // ---------------------------------------------------------
       
   408 //
       
   409 void CHsBrowserContainer::SendToBackground()
       
   410 	{
       
   411 	DEBUG( "CHsBrowserContainer::SendToBackground()" );
       
   412 
       
   413     RWindowGroup& wg = CEikonEnv::Static()->RootWin();
       
   414     
       
   415     // Construct en empty TApaTask object
       
   416     // giving it a reference to the Window Server session    
       
   417     TApaTask task( CEikonEnv::Static()->WsSession() );
       
   418                 
       
   419     // Initialise the object with the window group id of
       
   420     // our application (so that it represent our app)
       
   421     task.SetWgId( wg.Identifier() );
       
   422 
       
   423     // Request window server to bring our application
       
   424     // to foreground
       
   425     DEBUG("CHsBrowserContainer::SendToBackground() sending to background" );
       
   426     task.SendToBackground();	  
       
   427 	}
       
   428 
       
   429 // ----------------------------------------------------
       
   430 // CHsBrowserContainer::ProcessForegroundEvent()
       
   431 // ----------------------------------------------------
       
   432 //
       
   433 void CHsBrowserContainer::ProcessForegroundEvent( TBool aForeground )
       
   434 	{
       
   435 	DEBUG1( "CHsBrowserContainer::ProcessForegroundEvent() aForeground = %d", aForeground );
       
   436 	iModel->SetForeground( aForeground );
       
   437 	UpdateSoftkeys();
       
   438 	}
       
   439 
       
   440 // ----------------------------------------------------
       
   441 // CHsBrowserContainer::OfferKeyEventL(const 
       
   442 //               TKeyEvent& aKeyEvent,TEventCode aType)
       
   443 // ----------------------------------------------------
       
   444 //
       
   445 TKeyResponse 
       
   446 CHsBrowserContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
   447     {
       
   448     DEBUG( "CHsBrowserContainer::OfferKeyEventL()" );
       
   449   
       
   450     TUint state = iModel->State();
       
   451     TBrCtlDefs::TBrCtlElementType elem = iBrCtlInterface->FocusedElementType();
       
   452     DEBUG1( "CHsBrowserContainer::OfferKeyEventL() type: %d", elem);
       
   453 
       
   454     if ( elem == TBrCtlDefs::EElementActivatedInputBox || elem == TBrCtlDefs::EElementInputBox )
       
   455     {
       
   456         if ( !iActiveInputBox && state != EHsBrowserUiAuthenticatedOk )
       
   457         {
       
   458             // change softkey
       
   459             CEikButtonGroupContainer* cba = CEikonEnv::Static()->
       
   460             AppUiFactory()->Cba();
       
   461             if ( cba )
       
   462             {
       
   463                 cba->SetCommandSetL( R_HSBROWSER_SOFTKEYS_CANCEL );
       
   464                 cba->DrawNow();
       
   465             }
       
   466         }
       
   467         iActiveInputBox = EFalse;
       
   468     }
       
   469     else 
       
   470     {
       
   471         CEikButtonGroupContainer* cba = CEikonEnv::Static()->
       
   472         AppUiFactory()->Cba();
       
   473         if ( cba && state != EHsBrowserUiAuthenticatedOk )
       
   474         {
       
   475             cba->SetCommandSetL( R_AVKON_SOFTKEYS_CANCEL );
       
   476             cba->DrawNow();
       
   477         }
       
   478     }
       
   479     DEBUG( "CHsBrowserContainer::OfferKeyEventL() done to iBrCtl" );
       
   480     return iBrCtlInterface->OfferKeyEventL(aKeyEvent, aType);
       
   481     }
       
   482 
       
   483 // ----------------------------------------------------
       
   484 // CHsBrowserContainer::HandleResourceChange()
       
   485 // ----------------------------------------------------
       
   486 //
       
   487 void CHsBrowserContainer::HandleResourceChange( TInt aType )
       
   488     {
       
   489     DEBUG( "CHsBrowserContainer::HandleResourceChange" );
       
   490     CCoeControl::HandleResourceChange( aType );
       
   491  
       
   492     // Adjust Browser size to screen when screen layout is changed
       
   493     // Vertical vs. horizontal
       
   494     if ( aType == KEikDynamicLayoutVariantSwitch )
       
   495         {
       
   496         DEBUG( "CHsBrowserContainer::HandleResourceChange = KEikDynamicLayoutVariantSwitch" );
       
   497         TRect mainPaneRect;
       
   498         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, 
       
   499                                            mainPaneRect );
       
   500         SetRect( mainPaneRect );
       
   501         DrawDeferred();
       
   502         }
       
   503     }
       
   504 
       
   505 
       
   506 // ----------------------------------------------------
       
   507 // CHsBrowserContainer::UpdateSoftkeys()
       
   508 // ----------------------------------------------------
       
   509 //
       
   510 void CHsBrowserContainer::UpdateSoftkeys()
       
   511 	{
       
   512 	DEBUG( "CHsBrowserContainer::UpdateSoftkeys()" );
       
   513 	
       
   514 	TBool foreground = iModel->Foreground();
       
   515 	TUint state = iModel->State();
       
   516 
       
   517 	if ( !foreground && state == EHsBrowserUiAuthenticatedOk )
       
   518 	    {
       
   519 	    // R_HSBROWSER_SOFTKEYS_CONTINUE_EXIT
       
   520 	    CEikButtonGroupContainer* cba = CEikonEnv::Static()->AppUiFactory()->Cba();
       
   521 	    if ( cba )
       
   522 	        {
       
   523 	        TRAP_IGNORE( cba->SetCommandSetL( R_HSBROWSER_SOFTKEYS_CONTINUE_EXIT ) );
       
   524 	        cba->DrawNow();
       
   525 	        }
       
   526 	    }        
       
   527 	}
       
   528 
       
   529 // ----------------------------------------------------
       
   530 // CHsBrowserContainer::LoadRedirect
       
   531 // ----------------------------------------------------
       
   532 //
       
   533 TInt CHsBrowserContainer::LoadRedirect( const TPtrC& aUrl,
       
   534     TInt aIapId, TInt aNetId )
       
   535     {
       
   536     DEBUG( "CHsBrowserContainer::LoadRedirect()" );
       
   537     
       
   538     TInt err = KErrNone;
       
   539     
       
   540     UpdateNaviPane( ELoadingLoginPage );
       
   541     
       
   542     // init model
       
   543     iModel->SetIapId( aIapId );
       
   544     iModel->SetNetId( aNetId );
       
   545     iModel->SetUrl( aUrl ); 	
       
   546     // attach
       
   547     err = iModel->Attach();
       
   548     if ( err != KErrNone )
       
   549         {
       
   550         DEBUG1( "CHsBrowserContainer::LoadRedirect() Attach() err=%d", err );	
       
   551         }        
       
   552     else    
       
   553         {
       
   554         TInt connPtr = REINTERPRET_CAST( TInt, &iModel->Connection() );
       
   555         if ( iHsBrowserSpecialLoadObserver )
       
   556             {
       
   557             iHsBrowserSpecialLoadObserver->SetConnectionPtr( connPtr );
       
   558             iHsBrowserSpecialLoadObserver->SetSockSvrHandle(
       
   559                     iModel->SocketServ().Handle() );            	
       
   560             }
       
   561         }
       
   562 
       
   563     if ( err == KErrNone )
       
   564     	{
       
   565     	TRAP( err, iBrCtlInterface->LoadUrlL( aUrl ) );
       
   566     	DEBUG1( "CHsBrowserContainer::LoadRedirect() iBrCtlInterface->\
       
   567             LoadUrlL() err=%d", err );
       
   568     	}
       
   569     return err;
       
   570     }
       
   571     
       
   572 // ---------------------------------------------------------
       
   573 // CHsBrowserContainer::ProcessWlanConnModeNotConnected
       
   574 // ---------------------------------------------------------
       
   575 //
       
   576 void CHsBrowserContainer::ProcessWlanConnModeNotConnected()
       
   577 	{
       
   578 	DEBUG( "CHsBrowserContainer::ProcessWlanConnModeNotConnected()" );
       
   579 	
       
   580 	// Workaround for "WLAN login application closed" error:
       
   581 	TRAP_IGNORE( iBrCtlInterface->HandleCommandL( 
       
   582             TBrCtlDefs::ECommandCancelFetch + 
       
   583             TBrCtlDefs::ECommandIdBase ));
       
   584 
       
   585 	ShowConnClosedNote();
       
   586 	iAvkonAppUi->Exit();
       
   587 	}
       
   588     
       
   589 // ---------------------------------------------------------
       
   590 // CHsBrowserContainer::ShowLoginCompleteNote
       
   591 // ---------------------------------------------------------
       
   592 //
       
   593 void CHsBrowserContainer::ShowLoginCompleteNote()
       
   594     {
       
   595     TBool noteShown = iModel->LoginCompleteNoteShown();
       
   596     DEBUG1( "CHsBrowserContainer::ShowLoginCompleteNote() noteShown=%d", noteShown );
       
   597 
       
   598     TInt pos = CCoeEnv::Static()->RootWin().OrdinalPosition();
       
   599     DEBUG1( "CHsBrowserContainer::ShowLoginCompleteNote() pos=%d", pos );
       
   600 
       
   601     if ( !noteShown && pos == 0 )		
       
   602         {
       
   603         DEBUG( "CHsBrowserContainer::ShowLoginCompleteNote() showing note" );
       
   604 
       
   605         HBufC* message = NULL;
       
   606         TRAPD( err, message = StringLoader::LoadLC( R_QTN_NETW_CONSET_WBA_INFO_COMPLETE ); CleanupStack::Pop( message ) ); 
       
   607         if (err == KErrNone)
       
   608             {
       
   609             // Global note needed here, because CAknInformationNote was sometimes causing chrashes
       
   610             CAknGlobalNote* note = NULL;
       
   611             TRAP( err, note = CAknGlobalNote::NewLC(); CleanupStack::Pop( note ) );
       
   612             if (err == KErrNone)
       
   613                 {            
       
   614                 TRAP( err, note->ShowNoteL( EAknGlobalInformationNote, *message ) );
       
   615                 if (err == KErrNone)
       
   616                     {
       
   617                     DEBUG( "CHsBrowserContainer::ShowLoginCompleteNote(): Showing note DONE" );
       
   618                     }
       
   619                 delete note;
       
   620                 }
       
   621             delete message;
       
   622             }
       
   623         iModel->SetLoginCompleteNoteShown( ETrue );
       
   624         }
       
   625     }
       
   626 
       
   627 // ----------------------------------------------------
       
   628 // CHsBrowserContainer::ShowConnClosedNote
       
   629 // ----------------------------------------------------
       
   630 //
       
   631 void CHsBrowserContainer::ShowConnClosedNote()
       
   632 	{
       
   633 	DEBUG( "CHsBrowserContainer::ShowConnClosedNote()" );
       
   634     if ( IsForeground() )
       
   635         {
       
   636         DEBUG( "CHsBrowserContainer::ShowConnClosedNote() Foreground" );
       
   637 	    HBufC* message = NULL;
       
   638         TRAPD( err, message = StringLoader::LoadLC( R_QTN_NETW_CONSET_WBA_INFO_CLOSED ); CleanupStack::Pop( message ) );
       
   639  	    if (err == KErrNone)
       
   640  	        {
       
   641  	        // use global note here, otherwise overlap problem
       
   642  	        // appears with "Wlan network lost" note, which is
       
   643  	        // also a global note.
       
   644  	        CAknGlobalNote* note = NULL;
       
   645  	        TRAP( err, note = CAknGlobalNote::NewLC(); CleanupStack::Pop( note ) );
       
   646  	        if (err == KErrNone)
       
   647  	            { 	        
       
   648  	            TRAP( err, note->ShowNoteL( EAknGlobalInformationNote, *message ) );
       
   649  	            if (err == KErrNone)
       
   650  	                {
       
   651  	                DEBUG( "CHsBrowserContainer::ShowConnClosedNote(): Showing note DONE" );
       
   652  	                }
       
   653  	            delete note;
       
   654  	            }
       
   655  	        delete message;
       
   656  	        }
       
   657 		}
       
   658 	}
       
   659 
       
   660 // ----------------------------------------------------
       
   661 // CHsBrowserContainer::IsForeground()
       
   662 // ----------------------------------------------------
       
   663 //
       
   664 TBool CHsBrowserContainer::IsForeground()
       
   665 	{
       
   666 	DEBUG( "CHsBrowserContainer::IsForeground()" );
       
   667 	TInt32 foregroundUid(0);
       
   668     RWsSession ws;
       
   669     TInt ret = ws.Connect();
       
   670     if ( KErrNone == ret )
       
   671     	{
       
   672     	TApaTaskList taskList = TApaTaskList( ws );
       
   673     	TApaTask foregroundTask = taskList.FindByPos( 0 );
       
   674     
       
   675     	CApaWindowGroupName* wgName = NULL;
       
   676     	TRAPD( err, wgName = CApaWindowGroupName::NewLC( ws, foregroundTask.WgId() ); CleanupStack::Pop( wgName ) );
       
   677     	if (err == KErrNone)
       
   678     	    {
       
   679             foregroundUid = wgName->AppUid().iUid;
       
   680             delete wgName;
       
   681     	    }
       
   682         ws.Close();
       
   683     	}
       
   684     return foregroundUid == KUidHsBrowserApp.iUid;
       
   685 	}
       
   686 
       
   687 // End of File