browserui/browser/BrowserAppSrc/BrowserAppUi.cpp
branchRCL_3
changeset 48 8e6fa1719340
equal deleted inserted replaced
47:6385c4c93049 48:8e6fa1719340
       
     1 /*
       
     2 * Copyright (c) 2002 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 the License "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: 
       
    15 *      Implementation of CBrowserAppUi
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 // INCLUDES
       
    21 #include <browser_platform_variant.hrh>
       
    22 #include <BrowserNG.rsg>
       
    23 #include <uri16.h>
       
    24 #include <uri8.h>
       
    25 #include <uriutils.h>
       
    26 #include <ApUtils.h>
       
    27 #include <StringLoader.h>
       
    28 #include <e32def.h>
       
    29 #include <aplistitemlist.h>
       
    30 #include <aplistitem.h>
       
    31 #include <apparc.h>
       
    32 #include <favouritesfile.h>
       
    33 #include <aknmessagequerydialog.h>
       
    34 #include <FeatMgr.h>
       
    35 #include <internetconnectionmanager.h>
       
    36 #include <APSettingsHandlerUi.h>
       
    37 #include <UriUtilsCommon.h>
       
    38 #include <aknnavi.h>
       
    39 #include <AiwGenericParam.h>
       
    40 #include <AknDef.h>
       
    41 #include <DocumentHandler.h>
       
    42 #include <SysUtil.h>
       
    43 
       
    44 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
       
    45 #include <MGXFileManagerFactory.h>
       
    46 #include <CMGXFileManager.h>
       
    47 #endif
       
    48 
       
    49 #include <browserplugininterface.h>
       
    50 #include <oommonitorplugin.h>
       
    51 
       
    52 #include <browseroverriddensettings.h>
       
    53 #include "BrowserLauncherService.h"
       
    54 
       
    55 #include "cookiemanagerclient.h"
       
    56 
       
    57 #ifdef __SERIES60_HELP
       
    58 #include <hlplch.h>
       
    59 #endif //__SERIES60_HELP
       
    60 
       
    61 #include "BrowserAppDocument.h"
       
    62 #include <downloadedcontenthandler.h>
       
    63 #include "BrowserBmOTABinSender.h"
       
    64 #include "BrowserCommandLineParser.h"
       
    65 #include "BrowserApplication.h"
       
    66 #include "BrowserContentView.h"
       
    67 #include "BrowserContentViewContainer.h"
       
    68 #include "BrowserContentViewToolbar.h"
       
    69 #include "BrowserBookmarksView.h"
       
    70 #include "SettingsView.h"
       
    71 #include "BrowserWindowSelectionView.h"
       
    72 #include "BrowserInitialView.h"
       
    73 #include "CommonConstants.h"
       
    74 #include "BrowserDialogs.h"
       
    75 #include "BrowserDisplay.h"
       
    76 #include "BrowserCommsModel.h"
       
    77 #include "BrowserUtil.h"
       
    78 #include "BrowserPreferences.h"
       
    79 #include "SessionAndSecurity.h"
       
    80 #include "BrowserUIVariant.hrh"
       
    81 #include "BrowserWindowQueue.h"
       
    82 #include "Logger.h"
       
    83 #include <data_caging_path_literals.hrh>
       
    84 
       
    85 #include <brctldefs.h>
       
    86 #include <browserdialogsprovider.h>
       
    87 #include "BrowserSoftkeysObserver.h"
       
    88 #include "BrowserLoadObserver.h"
       
    89 #include "BrowserSpecialLoadObserver.h"
       
    90 #include "BrowserAsyncExit.h"
       
    91 #include "CommonConstants.h"
       
    92 
       
    93 
       
    94 // Dialogs Provider
       
    95 #include <browserdialogsproviderobserver.h>
       
    96 #include <brctlinterface.h>
       
    97 #include <browserdialogsprovider.h>
       
    98 
       
    99 // Multiple Windows
       
   100 #include "BrowserPopupEngine.h"
       
   101 #include "BrowserDialogsProviderProxy.h"
       
   102 #include "BrowserWindow.h"
       
   103 #include "BrowserWindowManager.h"
       
   104 #include "AknInfoPopupNoteController.h"
       
   105 
       
   106 #include "BrowserAppUi.h"
       
   107 
       
   108 #include "BrowserPushMtmObserver.h"
       
   109 
       
   110 #ifdef BRDO_IAD_UPDATE_ENABLED_FF
       
   111 #include <iaupdate.h>
       
   112 #include <iaupdateparameters.h>
       
   113 #include <iaupdateresult.h>
       
   114 #endif
       
   115 
       
   116 //CONSTANTS
       
   117 const TUint KBookmarkId = 1;
       
   118 const TUint KUrlId = 4;
       
   119 _LIT8 ( KLongZeroIdString, "5" );
       
   120 const TUint KFolderId = 6;
       
   121 const TUint KLaunchFeeds = 7;
       
   122 
       
   123 const TInt KMaxNumOfOpenedWindows = 5;
       
   124 const TInt KMinNumOfOpenedWindows = 2; // must allow at least 2 windows for most use cases
       
   125 
       
   126 const TUint KDot('.');
       
   127 const TUint KSlash('/');
       
   128 _LIT( KDefaultSchema, "http://" );
       
   129 const TInt KDefaultSchemaLength = 7;
       
   130 
       
   131 const TInt KMinimumCDriveDiskSpace = 512 * 1024;
       
   132 
       
   133 const TInt KRetryConnectivityTimeout( 2*1000*1000 ); // 2 seconds
       
   134 
       
   135 #ifdef BRDO_IAD_UPDATE_ENABLED_FF
       
   136 const TUint KBrowser8xUID = 0x200267CC;
       
   137 _LIT( KUpdateFileName, "lastupdatechecked.txt" );
       
   138 const TInt64 KMaxTimeToPostponeUpdate = 604800000000;
       
   139 #endif
       
   140 
       
   141 //Following array stores Uids for external applications. 
       
   142 //This can be appended. This is used in HandleMessageL to enable Single Window browsing.
       
   143 static TInt mArrayOfExternalAppUid[] = { 0x2001f3a9, 0x200159D0};
       
   144 // ================= MEMBER FUNCTIONS =======================
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CBrowserAppUi::CBrowserAppUi()
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 CBrowserAppUi::CBrowserAppUi():
       
   151 iCalledFromAnotherApp( EFalse ),
       
   152 iIsForeground( EFalse ),
       
   153 iLastViewId( KUidBrowserNullViewId ),
       
   154 iExitInProgress( EFalse ),
       
   155 iShutdownRequested( EFalse ),
       
   156 iParametrizedLaunchInProgress( 0 ),
       
   157 iExitFromEmbeddedMode( EFalse ),
       
   158 iLongZeroPressed( EFalse ),
       
   159 iStartedUp( EFalse ),
       
   160 iFeatureManager( EFalse ),
       
   161 iUserExit( EFalse ),
       
   162 iPgNotFound( EFalse ),
       
   163 iOverriddenLaunchContextId( EBrowserContextIdNormal ),
       
   164 iBrowserAlreadyRunning (EFalse),
       
   165 iSameWinApp( EFalse ),
       
   166 iFeedsClientUtilities( 0 )
       
   167     {
       
   168     iViewToBeActivatedIfNeeded.iUid = 0;
       
   169     iViewToReturnOnClose.iUid = 0;
       
   170 	}
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 // CBrowserAppUi::~CBrowserAppUi()
       
   174 // -----------------------------------------------------------------------------
       
   175 //
       
   176 CBrowserAppUi::~CBrowserAppUi()
       
   177     {
       
   178     LOG_ENTERFN("CBrowserAppUi::~CBrowserAppUi");
       
   179 
       
   180 #ifdef BRDO_IAD_UPDATE_ENABLED_FF
       
   181     delete iDelayedUpdate;
       
   182     iFs.Close();
       
   183 #endif
       
   184     
       
   185     SetExitInProgress( ETrue );
       
   186     if(iBrowserAsyncExit)
       
   187     	{
       
   188     	iBrowserAsyncExit->Cancel();
       
   189     	}
       
   190     if(iIdle)
       
   191     	{
       
   192     	iIdle->Cancel();
       
   193     	}
       
   194 
       
   195 
       
   196     if( iFeatureManager )
       
   197         {
       
   198         FeatureManager::UnInitializeLib();
       
   199         iFeatureManager = EFalse;
       
   200         }
       
   201 
       
   202     //
       
   203     delete iPushMtmObserver;
       
   204 
       
   205 #ifdef __RSS_FEEDS
       
   206     delete iFeedsClientUtilities;
       
   207     LOG_WRITE( "iFeedsClientUtilities deleted" );
       
   208 #endif //__RSS_FEEDS
       
   209 
       
   210     delete iPopupEngine;
       
   211     LOG_WRITE(" iPopupEngine deleted.");
       
   212 
       
   213     // set user exit for 'save launch param' command handling
       
   214     if ( iWindowManager )
       
   215         {
       
   216         iWindowManager->SetUserExit( iUserExit );
       
   217         }
       
   218     delete iWindowManager;
       
   219     LOG_WRITE( " iWindowManager deleted" );
       
   220     
       
   221 #ifdef BRDO_OCC_ENABLED_FF    
       
   222     if(iRetryConnectivity)
       
   223     	iRetryConnectivity->Cancel();
       
   224     	
       
   225     delete iRetryConnectivity;
       
   226     iRetryConnectivity = NULL;
       
   227 #endif    
       
   228 
       
   229     // Delete the inetconman after deleting window manager
       
   230     CInternetConnectionManager* inetconman = (CInternetConnectionManager*)iConnection;
       
   231     delete inetconman;
       
   232     LOG_WRITE( " inetconman deleted" );
       
   233     delete iConnStageNotifier;
       
   234     LOG_WRITE( " iConnStageNotifier deleted" );
       
   235 
       
   236     delete iPreferences;
       
   237     LOG_WRITE( " iPreferences deleted" );
       
   238     delete iCommsModel;
       
   239     LOG_WRITE( " iCommsModel deleted" );
       
   240 
       
   241     delete iLateSendUi;
       
   242 	LOG_WRITE( " iLateSendUi deleted" );
       
   243 
       
   244     delete iSender;
       
   245     LOG_WRITE( " iSender deleted" );
       
   246 
       
   247     delete iIdle;
       
   248     LOG_WRITE( " iIdle deleted" );
       
   249 
       
   250 	delete iRecentUrlStore;
       
   251 	LOG_WRITE( " iRecentUrlStore deleted" );
       
   252 
       
   253     if ( iDoorObserver )
       
   254       {
       
   255         iDoorObserver->NotifyExit(MApaEmbeddedDocObserver::ENoChanges);
       
   256         LOG_WRITE( " NotifyExit deleted" );
       
   257       }
       
   258     delete iDialogsProvider;
       
   259     LOG_WRITE( " iDialogsProvider deleted" );
       
   260 
       
   261 	TBool isStandAlone = !IsEmbeddedModeOn();
       
   262 	LOG_WRITE_FORMAT( " isStandAlone: %d", isStandAlone );
       
   263 
       
   264     delete iBrowserAsyncExit;
       
   265     LOG_WRITE( " iBrowserAsyncExit deleted" );
       
   266 
       
   267     iFavouritesSess.Close();
       
   268     LOG_WRITE( " iFavouritesSess.Close() deleted" );
       
   269 #ifdef BRDO_IAD_UPDATE_ENABLED_FF
       
   270     CleanUpdateParams(); 
       
   271 #endif
       
   272     }
       
   273 
       
   274 // -----------------------------------------------------------------------------
       
   275 // CBrowserAppUi::ConstructL()
       
   276 // -----------------------------------------------------------------------------
       
   277 //
       
   278 void CBrowserAppUi::ConstructL()
       
   279     {
       
   280     LOG_CREATE;
       
   281     LOG_ENTERFN( "CBrowserAppUi::ConstructL" );
       
   282 PERFLOG_CREATE;
       
   283 PERFLOG_LOCAL_INIT;
       
   284 PERFLOG_STOPWATCH_START;
       
   285 
       
   286 
       
   287 #ifdef BRDO_SINGLE_CLICK_ENABLED_FF
       
   288     BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible);
       
   289 #else 
       
   290     BaseConstructL( EAknEnableSkin | EAknEnableMSK );
       
   291 #endif
       
   292 
       
   293 
       
   294     if ( !IsEmbeddedModeOn( ) )
       
   295     	{
       
   296         // This is for handling low phone memory (c:) condition. Just leave in case phone memory is not sufficient.        
       
   297         TBool lowdisk = SysUtil::DiskSpaceBelowCriticalLevelL(&(CCoeEnv::Static()->FsSession()), KMinimumCDriveDiskSpace, EDriveC );
       
   298         if (lowdisk)   User::Leave(KErrDiskFull);
       
   299         
       
   300 #ifdef BRDO_PERF_IMPROVEMENTS_ENABLED_FF     
       
   301         InitBookmarksL();
       
   302 #else
       
   303         InitBrowserL();
       
   304 #endif        
       
   305     	LOG_WRITE( "Browser started standalone" );
       
   306     	}
       
   307 	else
       
   308 		{
       
   309 		iStartedUp = EFalse;
       
   310 		LOG_WRITE( "Browser started embedded" );
       
   311 		}        
       
   312 PERFLOG_STOP_WRITE("BrowserUI::ConstructL");
       
   313 
       
   314     }
       
   315 #ifdef BRDO_IAD_UPDATE_ENABLED_FF
       
   316 // ---------------------------------------------------------
       
   317 // CBrowserAppUi::CheckUpdatesL
       
   318 // ---------------------------------------------------------
       
   319 void CBrowserAppUi::CheckUpdatesL()
       
   320     {
       
   321     LOG_ENTERFN("CBrowserAppUi::CheckUpdatesL");
       
   322     LOG_WRITE( "CBrowserAppUi::CheckUpdatesL() entering" );
       
   323     User::LeaveIfError(iFs.Connect());
       
   324     if ( FeatureManager::FeatureSupported( KFeatureIdIAUpdate ) )
       
   325         {
       
   326         LOG_WRITE( "CBrowserAppUi::CheckUpdatesL() IAD Update supported" );
       
   327         TRAP_IGNORE( iUpdate = CIAUpdate::NewL( *this ) );
       
   328         LOG_WRITE( "CBrowserAppUi::CheckUpdatesL() IAD Update Client Created" );
       
   329         if ( iUpdate )
       
   330             {
       
   331             LOG_WRITE( "CBrowserAppUi::CheckUpdatesL() creating IAD Update paramentes" );
       
   332             iParameters = CIAUpdateParameters::NewL();
       
   333             // Search for updates using SIS package UID
       
   334             iParameters->SetUid( TUid::Uid( KBrowser8xUID ) );
       
   335             //check the updates
       
   336             iUpdate->CheckUpdates( *iParameters );
       
   337             }
       
   338         }
       
   339     LOG_WRITE( "CBrowserAppUi::CheckUpdatesL() exiting" );
       
   340     }
       
   341 
       
   342 // ---------------------------------------------------------
       
   343 // CBrowserAppUi::CheckUpdatesComplete
       
   344 // rest of the details commented in the header
       
   345 // ---------------------------------------------------------
       
   346 //
       
   347 void CBrowserAppUi::CheckUpdatesComplete( TInt aErrorCode, TInt aAvailableUpdates )
       
   348     {
       
   349     LOG_ENTERFN("CBrowserAppUi::CheckUpdatesComplete");
       
   350     LOG_WRITE( "CBrowserAppUi::CheckUpdatesComplete - Entry" );
       
   351 
       
   352     TBool result = EFalse;
       
   353     TBool showDialog = EFalse;
       
   354 
       
   355     if ( aErrorCode == KErrNone )
       
   356         {
       
   357 		if ( aAvailableUpdates > 0 )
       
   358             {
       
   359             LOG_WRITE( "CBrowserAppUi::CheckUpdatesComplete - update available" );
       
   360             //Check if the file is available in folder or not
       
   361             if(CheckUpdateFileAvailable())
       
   362                 {
       
   363                 LOG_WRITE( "CBrowserAppUi::CheckUpdatesComplete - update file available" );
       
   364                 TTime timenow;
       
   365                 timenow.HomeTime();
       
   366                 TInt64 time = timenow.Int64();
       
   367                 TInt64 dataValue = ReadUpdateFile();
       
   368                 //If the diference of the current time and the Previous Check time is more than 1 Week
       
   369                 //then show the dialog
       
   370                 if((time - dataValue)>KMaxTimeToPostponeUpdate)
       
   371                     {
       
   372                     LOG_WRITE( "CBrowserAppUi::CheckUpdatesComplete - diference of the current time and the time available in th file is more than 7 days" );
       
   373                     showDialog = ETrue;
       
   374                     }
       
   375                 }
       
   376             else
       
   377                 {
       
   378                 LOG_WRITE( "CBrowserAppUi::CheckUpdatesComplete - update file is not available" );
       
   379                 showDialog = ETrue;
       
   380                 }
       
   381                     
       
   382             if(showDialog)
       
   383                 {
       
   384                 HBufC* message = StringLoader::LoadLC(R_INSTALL_ADDON_BROWSER);
       
   385                 HBufC* lsc_now = StringLoader::LoadLC(R_INSTALL_BROWSER_NOW);
       
   386                 HBufC* rsc_later = StringLoader::LoadLC(R_INSTALL_BROWSER_LATER);
       
   387                 
       
   388                 TRAPD(err, result = iDialogsProvider->DialogConfirmL(_L(""),
       
   389                 *message,
       
   390                 *lsc_now,
       
   391                 *rsc_later));
       
   392                                    
       
   393                 CleanupStack::PopAndDestroy(3); //message, lsc_now, rsc_later
       
   394                 
       
   395                 if (err != KErrNone)
       
   396                     {
       
   397                     return ;
       
   398                     }
       
   399                 if ( result )  //  user selected NOW
       
   400                     {
       
   401                     LOG_WRITE( "CBrowserAppUi::CheckUpdatesComplete - if file exists, just delete it." );
       
   402                     // if file exists, just delete it.
       
   403                     DeleteUpdateFile();
       
   404                     iUpdate->ShowUpdates( *iParameters );
       
   405                     }
       
   406                 if ( !result )  // user selected LATER
       
   407                     {
       
   408                     LOG_WRITE( "CBrowserAppUi::CheckUpdatesComplete - create the file and store the current time." );
       
   409                     //create the file and store the current time.
       
   410                     WriteUpdateFile();
       
   411                     }
       
   412                 }
       
   413             LOG_WRITE( "CBrowserAppUi::CheckUpdatesComplete - update available" );
       
   414             }
       
   415         else
       
   416             {
       
   417             LOG_WRITE( "CBrowserAppUi::CheckUpdatesComplete - no update available" );
       
   418             // The answer was 'Later'. CIAUpdate object could be deleted
       
   419             CleanUpdateParams();
       
   420             }
       
   421         }
       
   422     LOG_WRITE( "CBrowserAppUi::CheckUpdatesComplete - Exit" );
       
   423     }
       
   424 
       
   425 // -----------------------------------------------------------------------------
       
   426 // CBrowserAppUi::CleanUpdateParams
       
   427 // -----------------------------------------------------------------------------
       
   428 //
       
   429 void CBrowserAppUi::CleanUpdateParams()
       
   430     {
       
   431     LOG_ENTERFN("CBrowserAppUi::CleanUpdateParams");
       
   432     LOG_WRITE( "CBrowserAppUi::CleanUpdateParams() entering" );
       
   433     if(iUpdate)
       
   434         {
       
   435         delete iUpdate;
       
   436         iUpdate = NULL;
       
   437         }
       
   438     if(iParameters)
       
   439         {
       
   440         delete iParameters;
       
   441         iParameters = NULL;
       
   442         }
       
   443     LOG_WRITE( "CBrowserAppUi::CleanUpdateParams() exiting" );
       
   444     }
       
   445 
       
   446 // ---------------------------------------------------------
       
   447 // CBrowserAppUi::UpdateComplete
       
   448 // rest of the details commented in the header
       
   449 // ---------------------------------------------------------
       
   450 //
       
   451 void CBrowserAppUi::UpdateComplete( TInt aErrorCode, CIAUpdateResult* aResult )
       
   452     {
       
   453     LOG_ENTERFN("CBrowserAppUi::UpdateComplete");
       
   454     LOG_WRITE( "CBrowserAppUi::UpdateComplete - Entry" );
       
   455     delete aResult; // Ownership was transferred, so this must be deleted by the client
       
   456     CleanUpdateParams();
       
   457     LOG_WRITE( "CBrowserAppUi::UpdateComplete - Exit" );
       
   458     }
       
   459 #endif
       
   460 
       
   461 
       
   462 // -----------------------------------------------------------------------------
       
   463 // CBrowserAppUi::InitBookmarksL()
       
   464 // Initialize only bookmarks view related dependencies here.
       
   465 // Note - Do not add unnecessary code here, it increases startup time for bookmarks view.
       
   466 // -----------------------------------------------------------------------------
       
   467 //
       
   468 void CBrowserAppUi::InitBookmarksL()
       
   469     {  
       
   470     //New constructor that just replaces the default primary storage size with this one.
       
   471     iRecentUrlStore = CRecentUrlStore::NewL();
       
   472 
       
   473     // Init CommsModel
       
   474     iCommsModel = CBrowserCommsModel::NewL();
       
   475 
       
   476     // check if it can be delayed ??
       
   477 #ifdef BRDO_OCC_ENABLED_FF
       
   478     iConnection = CInternetConnectionManager::NewL( &iCommsModel->CommsDb(), ETrue );
       
   479 #else
       
   480     iConnection = CInternetConnectionManager::NewL( &iCommsModel->CommsDb(), EFalse );
       
   481 #endif    
       
   482 
       
   483     // Creating object to hold application settings
       
   484     CBrowserAppDocument* doc = STATIC_CAST(CBrowserAppDocument*, Document());    
       
   485     iPreferences = CBrowserPreferences::NewL( *iCommsModel, *this, doc->GetOverriddenSettings());
       
   486     
       
   487     // Create bookmarkview
       
   488      CBrowserBookmarksView* bookmarksView = NULL;
       
   489      TInt folderUid = doc->GetFolderToOpen();
       
   490      if ( IsEmbeddedModeOn() && folderUid!= KFavouritesRootUid)
       
   491          {
       
   492          bookmarksView = CBrowserBookmarksView::NewLC( *this, *iRecentUrlStore, folderUid );
       
   493          }
       
   494      else
       
   495          {
       
   496          bookmarksView = CBrowserBookmarksView::NewLC( *this, *iRecentUrlStore );
       
   497          }
       
   498 
       
   499      iBookmarksView = bookmarksView;
       
   500      AddViewL( bookmarksView );  // transfer ownership to CAknViewAppUi    
       
   501      CleanupStack::Pop(); // bookmarksView	           
       
   502     }
       
   503 
       
   504 
       
   505 // -----------------------------------------------------------------------------
       
   506 // CBrowserAppUi::CompleteDelayedInit()
       
   507 // Delayed (async) init callback. This method can be invoked explicitly in case
       
   508 // some early startup cases fail if Browser has not initialized fully. No harm
       
   509 // if called multiple times since there is check in the beginning of thsi function.
       
   510 // -----------------------------------------------------------------------------
       
   511 //
       
   512 TBool CBrowserAppUi::CompleteDelayedInit()
       
   513     { 
       
   514     // Should not be called for other that 9.2 onward devices
       
   515 #ifdef BRDO_PERF_IMPROVEMENTS_ENABLED_FF
       
   516     if ( iStartedUp )
       
   517         return EFalse; // no need to re-invoke automatically
       
   518     // complete initialization
       
   519     TRAP_IGNORE(DelayedInitL());
       
   520     
       
   521 #ifdef BRDO_IAD_UPDATE_ENABLED_FF
       
   522     // complete the IAD check asynchronously
       
   523     iDelayedUpdate = CIdle::NewL( CActive::EPriorityIdle );
       
   524     iDelayedUpdate->Start(TCallBack( CompleteIADUpdateCallback, this ));
       
   525 #endif    
       
   526 #endif    
       
   527     
       
   528     return EFalse; // no need to re-invoke automatically
       
   529     }
       
   530 
       
   531 // -----------------------------------------------------------------------------
       
   532 // CBrowserAppUi::DelayedInitL()
       
   533 // Delayed (Async) initialization - whatever remains after InitBookmarksL(), do it here. 
       
   534 // Note: - Do not add unnecessary code here, it increases startup time for contenview.
       
   535 // -----------------------------------------------------------------------------
       
   536 //
       
   537 void CBrowserAppUi::DelayedInitL()
       
   538     {
       
   539     LOG_ENTERFN("CBrowserAppUi::DelayedInitL");
       
   540     
       
   541     // Create Favengine session
       
   542     User::LeaveIfError( iFavouritesSess.Connect() );
       
   543         
       
   544     // Init FeatureManager
       
   545     FeatureManager::InitializeLibL();
       
   546     iFeatureManager = ETrue;
       
   547     
       
   548     // check flash present
       
   549     iFlashPresent = CheckFlashPresent();    
       
   550 
       
   551     // this is required, browser's connection oberver should be hit first.
       
   552 	// (incase of netscape plgins, transactions will be closed.)
       
   553     iConnStageNotifier = CConnectionStageNotifierWCB::NewL();    
       
   554     iConnStageNotifier->SetPriority(CActive::EPriorityHigh);
       
   555 
       
   556     // Starts a background processing, so it must be started early, to get
       
   557     // finished before the first send operation! Or it must be synchronized!
       
   558     iLateSendUi  = CIdle::NewL( CActive::EPriorityIdle );
       
   559     iLateSendUi ->Start( TCallBack( DelayedSendUiConstructL, this ) );
       
   560     
       
   561     iHTTPSecurityIndicatorSupressed = iPreferences->HttpSecurityWarningsStatSupressed();
       
   562     
       
   563     // set AP to be a default one (for Push messages)
       
   564     SetRequestedAP( Preferences().DefaultAccessPoint() );
       
   565     
       
   566     // Create ContentView
       
   567     TRect rect = ClientRect();
       
   568     CBrowserContentView* contentView = CBrowserContentView::NewLC( *this, rect );
       
   569     AddViewL( contentView ); // transfer ownership to CAknViewAppUi
       
   570     CleanupStack::Pop(); // contentView
       
   571     
       
   572     // proxy will handle dialog events through load observer
       
   573     iDialogsProvider = CBrowserDialogsProvider::NewL( NULL);
       
   574 
       
   575 #ifdef __RSS_FEEDS
       
   576     iFeedsClientUtilities = CFeedsClientUtilities::NewL( *this, *this );
       
   577     BROWSER_LOG( ( _L("Feeds up.") ) );
       
   578 #endif //__RSS_FEEDS
       
   579     
       
   580     // Is Multiple Window feature suported?
       
   581     if ( Preferences().UiLocalFeatureSupported( KBrowserMultipleWindows ) )
       
   582         {
       
   583         if (Preferences().UiLocalFeatureSupported( KBrowserMinimalMultipleWindows ))//midrange
       
   584             {
       
   585             iWindowManager = CBrowserWindowManager::NewL( *this, *contentView, KMinNumOfOpenedWindows );
       
   586             }
       
   587         else
       
   588             {
       
   589             iWindowManager = CBrowserWindowManager::NewL( *this, *contentView, KMaxNumOfOpenedWindows );
       
   590             }
       
   591         LOG_WRITE_FORMAT("WindowManager Up. Max windows number. %d", KMaxNumOfOpenedWindows );            
       
   592         }
       
   593     else
       
   594         {
       
   595         iWindowManager = CBrowserWindowManager::NewL( *this, *contentView, KMinNumOfOpenedWindows );
       
   596         BROWSER_LOG( ( _L( "WindowManager Up. MWs not supported." ) ) );
       
   597         }
       
   598     
       
   599     contentView->SetZoomLevelL();
       
   600     BrCtlInterface().AddLoadEventObserverL(iBookmarksView);        
       
   601     
       
   602     // create settings view
       
   603     CBrowserSettingsView* settingsView = CBrowserSettingsView::NewLC( *this );
       
   604     AddViewL( settingsView );   // transfer ownership to CAknViewAppUi
       
   605     CleanupStack::Pop(); // settingsView
       
   606     BROWSER_LOG( ( _L( "SettingsView up" ) ) );
       
   607 
       
   608     // window selection view
       
   609     CBrowserWindowSelectionView* windowSelectionView = CBrowserWindowSelectionView::NewLC( *this );
       
   610     AddViewL( windowSelectionView );   // transfer ownership to CAknViewAppUi
       
   611     CleanupStack::Pop(); // windowSelectionView
       
   612     BROWSER_LOG( ( _L( "windowSelectionView up" ) ) );
       
   613     
       
   614     // Create asyncronous object to call when exit requires it.
       
   615     iBrowserAsyncExit = CBrowserAsyncExit::NewL( this );
       
   616     iIdle = CIdle::NewL( CActive::EPriorityIdle );
       
   617     
       
   618     iPushMtmObserver = CBrowserPushMtmObserver::NewL( this );
       
   619     iPushMtmObserver->StartObserver();
       
   620     
       
   621 #ifdef BRDO_OCC_ENABLED_FF
       
   622     iRetryConnectivity = CPeriodic::NewL(CActive::EPriorityStandard);
       
   623 #endif
       
   624     
       
   625     // Create two Panes of CBrowserContentViewContainer
       
   626     CBrowserGotoPane* gotoPane = CBrowserGotoPane::NewL( contentView->Container(),
       
   627              EMbmAvkonQgn_indi_find_goto,
       
   628              EMbmAvkonQgn_indi_find_goto_mask,
       
   629              ETrue,
       
   630              contentView );
       
   631                       
       
   632     // Create the find pane with magnifier glass icon, and
       
   633     // without adaptive popup list...
       
   634     CBrowserGotoPane* findKeywordPane = CBrowserGotoPane::NewL( contentView->Container(),
       
   635              EMbmAvkonQgn_indi_find_glass,
       
   636              EMbmAvkonQgn_indi_find_glass_mask,
       
   637              EFalse,
       
   638              contentView,
       
   639              ETrue );
       
   640     contentView->Container()->SetGotoPane(gotoPane);
       
   641     contentView->Container()->SetFindKeywordPane(findKeywordPane);
       
   642     //contentView->Container()->SetRect( rect ); // causes suncRepaint
       
   643     contentView->Container()->GotoPane()->SetGPObserver(contentView);
       
   644     contentView->Container()->FindKeywordPane()->SetGPObserver(contentView);
       
   645     contentView->Container()->FindKeywordPane()->SetOrdinalPosition( 0 );
       
   646     contentView->Container()->GotoPane()->SetOrdinalPosition( 0 );
       
   647     
       
   648     iStartedUp = ETrue;           
       
   649     iSecureSiteVisited = EFalse;
       
   650     
       
   651 #ifdef BRDO_PERF_IMPROVEMENTS_ENABLED_FF
       
   652     if(LastActiveViewId() == KUidBrowserBookmarksViewId)
       
   653         {
       
   654         iBookmarksView->CheckForDownloads();
       
   655         iBookmarksView->UpdateFavIconsL();
       
   656         }
       
   657 #endif    
       
   658     }
       
   659 
       
   660 // -----------------------------------------------------------------------------
       
   661 // CBrowserAppUi::InitBrowserL() - THIS METHOD IS NOT USED FOR NORMAL STARTUP
       
   662 // This method is just for supporting Browser initialization if launched in Embedded mode
       
   663 // Normal initialization if split in BookmarksInit() and DelayedInit(). iStartedUp is FALSE
       
   664 // if BRowser has not initialized or partially initialized.
       
   665 // NOTE: DO NOT ADD ANY CODE HERE. IT IS JUST A WRAPPER.
       
   666 // -----------------------------------------------------------------------------
       
   667 //
       
   668 void CBrowserAppUi::InitBrowserL()
       
   669     {
       
   670     // Bookmarks initialization
       
   671     InitBookmarksL();
       
   672     
       
   673     // 2nd part of initialization
       
   674     DelayedInitL();
       
   675     
       
   676 #ifdef BRDO_IAD_UPDATE_ENABLED_FF
       
   677     // complete the IAD check asynchronously
       
   678     if(!IsEmbeddedModeOn())
       
   679         {
       
   680         iDelayedUpdate = CIdle::NewL( CActive::EPriorityIdle );
       
   681         iDelayedUpdate->Start(TCallBack( CompleteIADUpdateCallback, this ));
       
   682         }
       
   683 #endif
       
   684     }
       
   685 
       
   686 
       
   687 // -----------------------------------------------------------------------------
       
   688 // CBrowserAppUi::ProcessCommandL(TInt aCommand)
       
   689 // -----------------------------------------------------------------------------
       
   690 //
       
   691 void CBrowserAppUi::ProcessCommandL(TInt aCommand)
       
   692     {
       
   693     MEikAppUiFactory* appUiFactory = (iEikonEnv)->AppUiFactory();
       
   694     if (appUiFactory->MenuBar())
       
   695         {
       
   696         StopDisplayingMenuBar();
       
   697         }
       
   698     CAknViewAppUi::ProcessCommandL(aCommand);
       
   699     }
       
   700 
       
   701 // -----------------------------------------------------------------------------
       
   702 // CBrowserAppUi::HandleCommandL()
       
   703 // -----------------------------------------------------------------------------
       
   704 //
       
   705 void CBrowserAppUi::HandleCommandL(TInt aCommand)
       
   706     {
       
   707     // Default handling for all the thingies.
       
   708     switch (aCommand)
       
   709         {
       
   710         case EEikCmdExit:
       
   711 			{
       
   712 			ExitBrowser ( IsAppShutterActive() );
       
   713 			break;
       
   714 			}
       
   715     case EAknSoftkeyExit://  closes the whole application chain if embedded browser
       
   716     case EAknCmdExit:
       
   717 			{
       
   718 			if ( IsEmbeddedModeOn() )
       
   719 				{
       
   720 				CAknEnv::RunAppShutter();
       
   721 				break;
       
   722 				}
       
   723 			else
       
   724 				{
       
   725 				ExitBrowser ( ETrue ) ;
       
   726 				break;
       
   727 				}
       
   728 			}
       
   729 		//Fix for TSW error ICHV-75UFKZ	
       
   730 		case EWmlCmdUserExit://closes the current browser instance only
       
   731 		case EWmlCmdCloseBrowser: 
       
   732 			{
       
   733 			ExitBrowser ( ETrue );
       
   734 			break;
       
   735 			}
       
   736         case EWmlCmdChangeConnection :
       
   737             {
       
   738             ChangeConnectionL();
       
   739             break;
       
   740             }
       
   741         case EWmlCmdPreferences:
       
   742             {
       
   743             SetViewToBeActivatedIfNeededL( KUidBrowserSettingsViewId );
       
   744             break;
       
   745             }
       
   746         case EWmlCmdPreferencesToolbar:
       
   747             {
       
   748             SetViewToBeActivatedIfNeededL( KUidBrowserSettingsViewId, KUidSettingsGotoToolbarGroup.iUid );
       
   749             break;
       
   750             }            
       
   751         case EWmlCmdFavourites:
       
   752             {
       
   753             SetViewToBeActivatedIfNeededL( KUidBrowserBookmarksViewId );
       
   754             break;
       
   755             }
       
   756         case EWmlCmdSearchWeb:
       
   757             {
       
   758             LoadSearchPageL();
       
   759             break;
       
   760             }
       
   761         case EWmlCmdReload:
       
   762             {
       
   763 			BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandReload +
       
   764 												(TInt)TBrCtlDefs::ECommandIdBase );
       
   765             break;
       
   766             }
       
   767 #ifdef BRDO_SINGLE_CLICK_ENABLED_FF			
       
   768         case EWmlCmdSetAsHomePage:
       
   769             {
       
   770             ContentView()->HandleCommandL(EWmlCmdSetAsHomePage);
       
   771             break;
       
   772             }
       
   773 #endif			
       
   774         case EAknSoftkeyBack:
       
   775         case EWmlCmdBack:
       
   776             {
       
   777             HistoryLoadPrevious();
       
   778             break;
       
   779             }
       
   780         case EWmlCmdBackToFeedsView:
       
   781             {
       
   782    			//Note: iPreviousView in this case will always be one of the Feeds view.
       
   783    			//In general iPreviousView holds the UID of the previous view.
       
   784    			SetViewToBeActivatedIfNeededL( iPreviousView );
       
   785             break;
       
   786             }
       
   787         case EWmlCmdClearTheCache:
       
   788             {
       
   789             ClearTheCacheL(ETrue, ETrue);
       
   790             break;
       
   791             }
       
   792         case EWmlCmdDeleteCookies:
       
   793             {
       
   794             DeleteCookiesL();
       
   795             TBrowserDialogs::InfoNoteL(
       
   796                 R_BROWSER_OK_NOTE, R_QTN_BROWSER_NOTE_COOKIES_DELETED );
       
   797             break;
       
   798             }
       
   799 
       
   800         case EWmlCmdClearAllPrivacy:
       
   801             {
       
   802             ClearAllPrivacyL();
       
   803             break;
       
   804             }
       
   805 
       
   806         case EWmlCmdClearHistory:
       
   807             {
       
   808             ClearHistoryWithPromptL();
       
   809             break;
       
   810             }
       
   811 
       
   812         case EWmlCmdClearFormAndPasswd:
       
   813             {
       
   814             ClearFormAndPasswdDataL(ETrue);
       
   815             break;
       
   816             }
       
   817 
       
   818         case EWmlCmdLaunchHomePage:
       
   819             {
       
   820             if (!IsLaunchHomePageDimmedL())
       
   821                 {
       
   822                 LaunchHomePageL( /* EFalse */ );
       
   823                 }
       
   824             break;
       
   825             }
       
   826         case EWmlCmdDisconnect :
       
   827             {
       
   828             DisconnectL();
       
   829             TBrowserDialogs::InfoNoteL(
       
   830 									R_BROWSER_INFO_NOTE, R_WML_DISCONNECT );
       
   831             break;
       
   832             }
       
   833         case EWmlCmdCancelFetch:
       
   834             {
       
   835             if (SpecialLoadObserver().IsConnectionStarted()) // If Connection request is in processing 
       
   836             {                                                // try to Cancel.
       
   837                 SpecialLoadObserver().CancelConnection();
       
   838                 Connection().Disconnect();
       
   839             }
       
   840             else
       
   841             {
       
   842                 CancelFetch( ETrue );
       
   843             }
       
   844             break;
       
   845             }
       
   846         case EWmlCmdPageInfo:
       
   847             {
       
   848             CSessionAndSecurity* security = CSessionAndSecurity::NewLC(*this);
       
   849             security->ShowPageInfoL();
       
   850             CleanupStack::PopAndDestroy(); // security
       
   851             break;
       
   852             }
       
   853         case EWmlCmdInfoSession:
       
   854             {
       
   855             CSessionAndSecurity* session = CSessionAndSecurity::NewLC(*this);
       
   856             session->ShowSessionInfoL();
       
   857             CleanupStack::PopAndDestroy();  // session
       
   858             break;
       
   859             }
       
   860         case EWmlCmdInfoSecurity:
       
   861             {
       
   862             CSessionAndSecurity* security = CSessionAndSecurity::NewLC(*this);
       
   863             security->ShowSecurityInfoL();
       
   864             CleanupStack::PopAndDestroy();  // security
       
   865             break;
       
   866             }
       
   867         // browser engine specific command
       
   868 #ifdef __SERIES60_HELP
       
   869 
       
   870         case EAknCmdHelp:
       
   871             {
       
   872             HlpLauncher::LaunchHelpApplicationL
       
   873                 ( iEikonEnv->WsSession(), AppHelpContextL() );
       
   874             break;
       
   875             }
       
   876 
       
   877 #endif //__SERIES60_HELP
       
   878 
       
   879 		case EWmlCmdForward:
       
   880 			{
       
   881             HistoryLoadNext();
       
   882 			break;
       
   883 			}
       
   884 
       
   885         case EWmlCmdRotateDisplay:
       
   886             {
       
   887             if ( Orientation() == EAppUiOrientationPortrait )
       
   888                 {
       
   889                 SetOrientationL(EAppUiOrientationLandscape);
       
   890                 }
       
   891             else if (Orientation() == EAppUiOrientationLandscape)
       
   892                 {
       
   893                 SetOrientationL(EAppUiOrientationPortrait);
       
   894                 }
       
   895             else // EAppUiOrientationUnspecified
       
   896                 {
       
   897                 TRect rect = ApplicationRect();
       
   898                 TInt width = rect.Width();
       
   899                 TInt height = rect.Height();
       
   900 
       
   901                 if (width > height)
       
   902                     {
       
   903                     SetOrientationL(EAppUiOrientationPortrait);
       
   904                     }
       
   905                 else
       
   906                     {
       
   907                     SetOrientationL(EAppUiOrientationLandscape);
       
   908                     }
       
   909                 }
       
   910              if(ContentView()->KeymapIsUp())
       
   911              	{             	          
       
   912              	ContentView()->RedrawKeymap();
       
   913              	}
       
   914             break;
       
   915             }
       
   916 
       
   917         case EWmlCmdAboutProduct:
       
   918             {
       
   919             // get version info from browser control and display it
       
   920             ShowNameAndVersionL();
       
   921             break;
       
   922             }
       
   923 		case EWmlCmdProductUpdate:
       
   924             {
       
   925     			/*if(!iAppUpdate)
       
   926 				    {
       
   927 				    iAppUpdate = CBrowserAppUpdate::NewL();
       
   928 				    }
       
   929 			    iAppUpdate->CheckUpdates();*/            
       
   930             break;
       
   931             }
       
   932 
       
   933         //=====================================================================
       
   934         // Multiple Windows Support
       
   935         //
       
   936     	case EWmlCmdSwitchWindow:
       
   937             {
       
   938             if(WindowMgr().WindowCount() > 1)
       
   939 	            {
       
   940 #ifdef BRDO_MULTITOUCH_ENABLED_FF
       
   941 	            // use switch window tab view if pageoverview bitmaps are available
       
   942 	            if (Preferences().UiLocalFeatureSupported( KBrowserGraphicalPage ) 
       
   943 	                    || Preferences().UiLocalFeatureSupported( KBrowserGraphicalHistory ))
       
   944 #else	                
       
   945                 // use switch window tab view if pageoverview bitmaps are available
       
   946                 if (Preferences().UiLocalFeatureSupported( KBrowserGraphicalPage ))
       
   947 #endif                    
       
   948 	            	{
       
   949 	            	SetViewToBeActivatedIfNeededL( KUidBrowserWindowSelectionViewId );
       
   950 	            	}
       
   951 	            else
       
   952 	            	{
       
   953 	            	SwitchWindowL();
       
   954 		            }            	
       
   955             	}
       
   956             break;
       
   957             }
       
   958     	case EWmlCmdCloseWindow:
       
   959     		{
       
   960     		if ( IsEmbeddedInOperatorMenu() )
       
   961     			{
       
   962     			ExitBrowser( ETrue );
       
   963     			}
       
   964     		else
       
   965 				{
       
   966     			CloseWindowL();
       
   967 				}
       
   968     		break;
       
   969     		}
       
   970     	case EWmlCmdAllowPopups:
       
   971         	{
       
   972         	// Add url to whitelist
       
   973         	HBufC* url( WindowMgr().CurrentWindow()->BrCtlInterface().
       
   974                 PageInfoLC( TBrCtlDefs::EPageInfoUrl ) );
       
   975             PopupEngine().AddUrlToWhiteListL( *url );
       
   976             CleanupStack::PopAndDestroy( url );
       
   977     		break;
       
   978 	    	}
       
   979     	case EWmlCmdBlockPopups:
       
   980         	{
       
   981         	// Remove from whitelist
       
   982         	HBufC* url( WindowMgr().CurrentWindow()->BrCtlInterface().
       
   983                 PageInfoLC( TBrCtlDefs::EPageInfoUrl ) );
       
   984         	PopupEngine().RemoveUrlFromWhiteListL( *url );
       
   985             CleanupStack::PopAndDestroy( url );
       
   986         	break;
       
   987         	}
       
   988         case EWmlCmdShowAnchorHref:
       
   989             {
       
   990 			BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandIdBase + (TInt)TBrCtlDefs::ECommandShowAnchorHref );
       
   991             break;
       
   992             }
       
   993         case EWmlCmdSaveToGallery:
       
   994             {
       
   995             SaveFocusedImageToGalleryL();
       
   996             break;
       
   997             }
       
   998         case EWmlCmdOpenToViewer:
       
   999             {
       
  1000             TBrCtlImageCarrier* imageCarrier = BrCtlInterface().FocusedImageLC();
       
  1001             if (imageCarrier)
       
  1002                 {
       
  1003                 CArrayFixFlat<TBrCtlImageCarrier>* imageArray = new( ELeave ) CArrayFixFlat<TBrCtlImageCarrier>(1);
       
  1004                 CleanupStack::PushL(imageArray);
       
  1005                 imageArray->AppendL(*imageCarrier);
       
  1006                 iDialogsProvider->DialogDisplayPageImagesL( *imageArray );
       
  1007                 CleanupStack::PopAndDestroy(2); // imageArray, imageCarrier
       
  1008                 }
       
  1009             break;
       
  1010             }
       
  1011         case EWmlCmdSaveUrlAsBookmark:
       
  1012             {
       
  1013             HBufC* url = BrCtlInterface().PageInfoLC(TBrCtlDefs::EPageInfoFocusedNodeUrl);
       
  1014             ContentView()->AddNewBookmarkL(EFalse, url);
       
  1015             CleanupStack::PopAndDestroy(); // url
       
  1016             break;
       
  1017             }
       
  1018         case EWmlCmdSmartLinkMakeCall:
       
  1019             {
       
  1020 			BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandIdBase + (TInt)TBrCtlDefs::ECommandSmartLinkMakeCall );
       
  1021             break;
       
  1022             }
       
  1023         case EWmlCmdSmartLinkSendEmail:
       
  1024             {
       
  1025 			BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandIdBase + (TInt)TBrCtlDefs::ECommandSmartLinkSendEmail );
       
  1026             break;
       
  1027             }
       
  1028         case EWmlCmdSmartLinkSendSms:
       
  1029             {
       
  1030 			BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandIdBase + (TInt)TBrCtlDefs::ECommandSmartLinkSendMessage );
       
  1031             break;
       
  1032             }
       
  1033         case EWmlCmdSmartLinkAddToContacts:
       
  1034             {
       
  1035 			BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandIdBase + (TInt)TBrCtlDefs::ECommandSmartLinkAddToPhoneBook );
       
  1036             break;
       
  1037             }
       
  1038         case EWmlCmdLoadFocusedImage:
       
  1039             {
       
  1040 			BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandIdBase + (TInt)TBrCtlDefs::ECommandLoadFocusedImage );
       
  1041             break;
       
  1042             }
       
  1043         case EWmlCmdLoadImagesOnly:
       
  1044             {
       
  1045             iPreferences->SetAutoLoadContentL(EWmlSettingsAutoloadImagesNoFlash);
       
  1046             break;
       
  1047             }
       
  1048         case EWmlCmdLoadImagesAndFlash:
       
  1049             {
       
  1050             iPreferences->SetAutoLoadContentL(EWmlSettingsAutoloadAll);
       
  1051             break;
       
  1052             }
       
  1053         case EWmlCmdOneStepBack:
       
  1054             {
       
  1055 			BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandIdBase + (TInt)TBrCtlDefs::ECommandOneStepBack );
       
  1056             break;
       
  1057             }
       
  1058         case EEikCmdEditPaste:
       
  1059             {
       
  1060             TKeyEvent keyEvent;
       
  1061             keyEvent.iCode = EKeyF18;  //member of TKeyCode	
       
  1062             keyEvent.iScanCode = EEikCmdEditPaste;	
       
  1063             keyEvent.iModifiers = EModifierCtrl;
       
  1064             keyEvent.iRepeats = 0;
       
  1065             TRAP_IGNORE( BrCtlInterface().OfferKeyEventL(keyEvent, EEventKey));
       
  1066             }
       
  1067             break;
       
  1068 	    //=====================================================================
       
  1069         default:
       
  1070             {
       
  1071             if( iStartedUp )
       
  1072                 {
       
  1073                 // pass to Browser Control
       
  1074                 BrCtlInterface().HandleCommandL( aCommand );
       
  1075                 }
       
  1076             break;
       
  1077             }
       
  1078         }
       
  1079     }
       
  1080 
       
  1081 // -----------------------------------------------------------------------------
       
  1082 // CBrowserAppUi::ActiveView()
       
  1083 // -----------------------------------------------------------------------------
       
  1084 //
       
  1085 CBrowserViewBase* CBrowserAppUi::ActiveView()
       
  1086     {
       
  1087     TVwsViewId activeViewId;
       
  1088     TInt err = GetActiveViewId( activeViewId );
       
  1089 
       
  1090     if ( !err )
       
  1091         {
       
  1092         return STATIC_CAST( CBrowserViewBase*, View(activeViewId.iViewUid) );
       
  1093         }
       
  1094     else
       
  1095         {
       
  1096         //We should not panic
       
  1097         //On 3.0 wk40 it was observed that GetActiveViewId returned with KErrNotFound
       
  1098         //in case Browser was in the background
       
  1099         //Symbian error?
       
  1100         return NULL;
       
  1101         }
       
  1102     }
       
  1103 
       
  1104 // -----------------------------------------------------------------------------
       
  1105 // CBrowserAppUi::SetRequestedAP()
       
  1106 // -----------------------------------------------------------------------------
       
  1107 //
       
  1108 void CBrowserAppUi::SetRequestedAP( TInt aAp )
       
  1109     {
       
  1110     iRequestedAp = aAp;
       
  1111     }
       
  1112 
       
  1113 // -----------------------------------------------------------------------------
       
  1114 // CBrowserAppUi::IsPageLoaded()
       
  1115 // -----------------------------------------------------------------------------
       
  1116 //
       
  1117 TBool CBrowserAppUi::IsPageLoaded()
       
  1118     {
       
  1119 #ifdef BRDO_PERF_IMPROVEMENTS_ENABLED_FF    
       
  1120     if(!iStartedUp) // ContentView/WindowMgr is not yet up => no page loaded
       
  1121         return EFalse;
       
  1122 #endif
       
  1123     
       
  1124     TBool ret( EFalse );
       
  1125     TInt winCount( WindowMgr().WindowCount() );
       
  1126 
       
  1127     // at least 2 window -> there is a page loaded
       
  1128     if( winCount > 1 )
       
  1129         {
       
  1130         ret = ETrue;
       
  1131         }
       
  1132     // 1 window with a loaded content
       
  1133     else if( winCount == 1 )
       
  1134         {
       
  1135         // This checks to see if a dialog is launched and if that is the case, then
       
  1136         // the current window is being used, hence returning true.
       
  1137         if( iDialogsProvider->IsDialogLaunched() )
       
  1138             {
       
  1139             ret = ETrue;
       
  1140             }
       
  1141         else
       
  1142             {
       
  1143             ret = WindowMgr().IsContentExist();
       
  1144             }
       
  1145         }
       
  1146     // else (winCount == 0), no content view -> no page loaded
       
  1147     return ret;
       
  1148     }
       
  1149 
       
  1150 // -----------------------------------------------------------------------------
       
  1151 // CBrowserAppUi::Fetching()
       
  1152 // -----------------------------------------------------------------------------
       
  1153 //
       
  1154 TBool CBrowserAppUi::Fetching() const
       
  1155     {
       
  1156 	// TO DO:
       
  1157 	// use load obs., remove ifetchstate from this class and use from loadobs.
       
  1158 	// iLoadState
       
  1159     //return ( iFetchState == MFetchObserver::ELoadStart );
       
  1160 #ifdef BRDO_PERF_IMPROVEMENTS_ENABLED_FF    
       
  1161     if (!iStartedUp)  // ContentView is not yet started up, so we are not fetching   
       
  1162         return EFalse;
       
  1163     else
       
  1164 #endif        
       
  1165         return ( LoadObserver().LoadState() != CBrowserLoadObserver::ELoadStateIdle );
       
  1166     }
       
  1167 // -----------------------------------------------------------------------------
       
  1168 // CBrowserAppUi::ContentDisplayed()
       
  1169 // -----------------------------------------------------------------------------
       
  1170 //
       
  1171 TBool CBrowserAppUi::ContentDisplayed() const
       
  1172     {
       
  1173     return ( LoadObserver().ContentDisplayed() );
       
  1174     }
       
  1175 
       
  1176 // -----------------------------------------------------------------------------
       
  1177 // CBrowserAppUi::SetContentDisplayed()
       
  1178 // -----------------------------------------------------------------------------
       
  1179 //
       
  1180 void CBrowserAppUi::SetContentDisplayed(TBool aValue) 
       
  1181     {
       
  1182         LoadObserver().SetContentDisplayed( aValue );
       
  1183     }
       
  1184 // -----------------------------------------------------------------------------
       
  1185 // CBrowserAppUi::FetchBookmarkL
       
  1186 // -----------------------------------------------------------------------------
       
  1187 //
       
  1188 void CBrowserAppUi::FetchBookmarkL( TInt aBookmarkUid )
       
  1189     {
       
  1190     // complete initialization if not done yet, can happen if user selects
       
  1191     // a bookmark quickly after launch (within 1 second)
       
  1192     if ( !iStartedUp )
       
  1193         CompleteDelayedInit();
       
  1194         
       
  1195     SetViewToReturnOnClose( KUidBrowserBookmarksViewId );
       
  1196     if ( aBookmarkUid == KFavouritesStartPageUid )
       
  1197         {
       
  1198         TUint defaultAp = Preferences().DefaultAccessPoint();
       
  1199         if ( defaultAp != KWmlNoDefaultAccessPoint ) // There is no access point defined
       
  1200             {
       
  1201             CApAccessPointItem* apItem = Preferences().AllPreferencesL().iDefaultAPDetails;
       
  1202             if ( apItem )
       
  1203                 {
       
  1204                 const HBufC* currentHP = apItem->ReadConstLongTextL( EApWapStartPage );
       
  1205                 //TPtrC currentHP(apItem->StartPage()); // Get the start page of the access point.
       
  1206                 TFavouritesWapAp accessPoint;
       
  1207 
       
  1208                 FetchL( *currentHP, KNullDesC, KNullDesC, accessPoint,
       
  1209                     CBrowserLoadObserver::ELoadUrlTypeStartPage ); // Fetch the start page.
       
  1210 				}
       
  1211             }
       
  1212         }
       
  1213     else
       
  1214         {
       
  1215         RFavouritesDb db;
       
  1216         User::LeaveIfError( db.Open( iFavouritesSess, KBrowserBookmarks ) );
       
  1217         CleanupClosePushL<RFavouritesDb>( db );
       
  1218 
       
  1219         CFavouritesItem* item = CFavouritesItem::NewLC();
       
  1220         User::LeaveIfError( db.Get( aBookmarkUid, *item ) );
       
  1221 
       
  1222         FetchBookmarkL( *item );
       
  1223         CleanupStack::PopAndDestroy( 2 );  // item, db
       
  1224         }
       
  1225     }
       
  1226 
       
  1227 // -----------------------------------------------------------------------------
       
  1228 // CBrowserAppUi::FetchBookmarkL
       
  1229 // -----------------------------------------------------------------------------
       
  1230 //
       
  1231 void CBrowserAppUi::FetchBookmarkL( const CFavouritesItem& aBookmarkItem )
       
  1232     {
       
  1233     // complete initialization if not done yet, can happen if user selects
       
  1234     // a bookmark quickly after launch (within 1 second)
       
  1235     if ( !iStartedUp )
       
  1236         CompleteDelayedInit();
       
  1237     
       
  1238     SetViewToReturnOnClose( KUidBrowserBookmarksViewId );
       
  1239     if ( Util::CheckBookmarkApL( *this, aBookmarkItem.WapAp()) )
       
  1240         FetchL
       
  1241             (
       
  1242             aBookmarkItem.Url() ,
       
  1243             aBookmarkItem.UserName(),
       
  1244             aBookmarkItem.Password(),
       
  1245             aBookmarkItem.WapAp(),
       
  1246             CBrowserLoadObserver::ELoadUrlTypeOther
       
  1247             );
       
  1248     else
       
  1249         TBrowserDialogs::ErrorNoteL( R_WML_INVALID_AP );
       
  1250     }
       
  1251 
       
  1252 // -----------------------------------------------------------------------------
       
  1253 // CBrowserAppUi::SetViewToBeActivatedIfNeededL
       
  1254 // -----------------------------------------------------------------------------
       
  1255 //
       
  1256 void CBrowserAppUi::SetViewToBeActivatedIfNeededL( TUid aUid, TInt aMessageId )
       
  1257     {
       
  1258 	CBrowserAppDocument* doc = STATIC_CAST(CBrowserAppDocument*, Document());
       
  1259 
       
  1260 	if((iCurrentView != aUid) && (aUid != KUidBrowserSettingsViewId))
       
  1261 	{
       
  1262 		iPreviousView = iCurrentView;
       
  1263 		iCurrentView = aUid;
       
  1264 	}
       
  1265 
       
  1266 	//Check view id validity first
       
  1267 	if ( aUid == KUidBrowserNullViewId )
       
  1268 		{
       
  1269 		SetLastActiveViewId( KUidBrowserBookmarksViewId );
       
  1270 		SetViewToBeActivatedIfNeededL( LastActiveViewId() );
       
  1271            return;
       
  1272 		}
       
  1273 
       
  1274 	if ( ( aUid != KUidBrowserContentViewId ) && 
       
  1275 	   ( LastActiveViewId() == KUidBrowserContentViewId ) )
       
  1276 		{
       
  1277 		ContentView()->SetFullScreenOffL();
       
  1278 		}
       
  1279 	
       
  1280 	if ( iWindowManager && iWindowManager->ContentView()->FullScreenMode() )
       
  1281 	    {
       
  1282     	if ( aUid == KUidBrowserFeedsFeedViewId )
       
  1283     	    {
       
  1284     	    BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandIdBase + 
       
  1285     	        (TInt)TBrCtlDefs::ECommandLeaveFullscreenBrowsing );
       
  1286     	    }
       
  1287     	
       
  1288     	else  if ( aUid != KUidBrowserFeedsTopicViewId && 
       
  1289             aUid != KUidBrowserFeedsFolderViewId && 
       
  1290             aUid != KUidBrowserBookmarksViewId )
       
  1291             {
       
  1292             BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandIdBase + 
       
  1293                 (TInt)TBrCtlDefs::ECommandEnterFullscreenBrowsing );
       
  1294             }
       
  1295     	}
       
  1296 
       
  1297 
       
  1298 	if ( iIsForeground )
       
  1299 		{
       
  1300         if ( aUid == KUidBrowserSettingsViewId )
       
  1301 	        {
       
  1302             //complete initialisation 
       
  1303             if( !iStartedUp )
       
  1304                 CompleteDelayedInit();
       
  1305 
       
  1306             CEikStatusPane* sp = STATIC_CAST( CAknAppUi*,
       
  1307 						  CEikonEnv::Static()->EikAppUi() )
       
  1308 			                ->StatusPane();
       
  1309             sp->DrawNow();
       
  1310             }
       
  1311 
       
  1312 		ActivateLocalViewL(  aUid, TUid::Uid( aMessageId ), KNullDesC8 );
       
  1313 		}
       
  1314 	else
       
  1315 		{
       
  1316 		iViewToBeActivatedIfNeeded = aUid;
       
  1317 		}
       
  1318     }
       
  1319 
       
  1320 // -----------------------------------------------------------------------------
       
  1321 // CBrowserAppUi::LastActiveViewId
       
  1322 // -----------------------------------------------------------------------------
       
  1323 //
       
  1324 TUid CBrowserAppUi::LastActiveViewId() const
       
  1325     {
       
  1326     return iLastViewId;
       
  1327     }
       
  1328 
       
  1329 // -----------------------------------------------------------------------------
       
  1330 // CBrowserAppUi::SetLastActiveViewId
       
  1331 // -----------------------------------------------------------------------------
       
  1332 //
       
  1333 void CBrowserAppUi::SetLastActiveViewId( TUid aUid )
       
  1334     {
       
  1335 LOG_ENTERFN("CBrowserAppUi::SetLastActiveViewId");
       
  1336     LOG_WRITE_FORMAT(" SetLastActiveViewId: %d", aUid);
       
  1337     iLastViewId = aUid;
       
  1338     }
       
  1339 
       
  1340 // -----------------------------------------------------------------------------
       
  1341 // CBrowserAppUi::ExitInProgress
       
  1342 // -----------------------------------------------------------------------------
       
  1343 //
       
  1344 TBool CBrowserAppUi::ExitInProgress() const
       
  1345     {
       
  1346     return iExitInProgress;
       
  1347     }
       
  1348 
       
  1349 // -----------------------------------------------------------------------------
       
  1350 // CBrowserAppUi::ExitInProgress
       
  1351 // -----------------------------------------------------------------------------
       
  1352 //
       
  1353 void CBrowserAppUi::SetExitInProgress( TBool aValue )
       
  1354     {
       
  1355     iExitInProgress = aValue;
       
  1356     }
       
  1357 
       
  1358 // -----------------------------------------------------------------------------
       
  1359 // CBrowserAppUi::IsConnecting
       
  1360 // -----------------------------------------------------------------------------
       
  1361 //
       
  1362 TBool CBrowserAppUi::IsConnecting() const
       
  1363     {
       
  1364     return ( LoadObserver().LoadState() != CBrowserLoadObserver::ELoadStateIdle );
       
  1365     }
       
  1366 
       
  1367 // -----------------------------------------------------------------------------
       
  1368 // CBrowserAppUi::HandleForegroundEventL
       
  1369 // -----------------------------------------------------------------------------
       
  1370 //
       
  1371 void CBrowserAppUi::HandleForegroundEventL( TBool aForeground )
       
  1372     {
       
  1373     // Handle this event only if the browser is started up
       
  1374     iIsForeground = IsForeground();
       
  1375     if (!iStartedUp)
       
  1376     	return;
       
  1377 
       
  1378     if( iIsForeground )
       
  1379     	{
       
  1380  	    if (iViewToBeActivatedIfNeeded.iUid)
       
  1381 	        {
       
  1382 	        ActivateLocalViewL( iViewToBeActivatedIfNeeded );
       
  1383 	        }
       
  1384 	    else
       
  1385 	        {
       
  1386 	        TVwsViewId activeViewId;
       
  1387 	        if( ( GetActiveViewId( activeViewId ) == KErrNone ) &&	        		
       
  1388 	            (  LastActiveViewId()  != activeViewId.iViewUid ) )
       
  1389 	             {
       
  1390 	             // LastActiveViewId() might return with 0!
       
  1391 	             TRAP_IGNORE( ActivateLocalViewL( LastActiveViewId() ) );
       
  1392 	             }
       
  1393 	        }
       
  1394     	}
       
  1395 	iViewToBeActivatedIfNeeded.iUid = 0;    
       
  1396     CAknViewAppUi::HandleForegroundEventL( aForeground );
       
  1397             
       
  1398     if( iIsForeground )
       
  1399         {
       
  1400         if ( Preferences().FullScreen() == EWmlSettingsFullScreenFullScreen )
       
  1401             {
       
  1402             ContentView()->UpdateFullScreenL();
       
  1403             }
       
  1404 
       
  1405         if( !Fetching() )
       
  1406             {
       
  1407             Display().StopProgressAnimationL();
       
  1408             }
       
  1409         }
       
  1410 
       
  1411     if (iWindowManager)
       
  1412         {
       
  1413         iWindowManager->SendCommandToAllWindowsL( iIsForeground
       
  1414             ? (TInt)TBrCtlDefs::ECommandAppForeground + (TInt)TBrCtlDefs::ECommandIdBase
       
  1415             : (TInt)TBrCtlDefs::ECommandAppBackground + (TInt)TBrCtlDefs::ECommandIdBase);
       
  1416         }
       
  1417 
       
  1418     // if browser comes to foreground and exit is requested,
       
  1419     // asyncronous exit is started
       
  1420     if( iIsForeground && iExitFromEmbeddedMode && !IsEmbeddedInOperatorMenu() )
       
  1421         {
       
  1422         iBrowserAsyncExit->Start();
       
  1423         } 
       
  1424     }
       
  1425 
       
  1426 // -----------------------------------------------------------------------------
       
  1427 // CBrowserAppUi::FetchL
       
  1428 // -----------------------------------------------------------------------------
       
  1429 //
       
  1430 void CBrowserAppUi::FetchL(
       
  1431 						   const TDesC& aUrl,
       
  1432                            const TDesC& aUsername,
       
  1433                            const TDesC& aPassword,
       
  1434                            const TFavouritesWapAp& aAccessPoint,
       
  1435                            CBrowserLoadObserver::TBrowserLoadUrlType aUrlType )
       
  1436     {
       
  1437 LOG_ENTERFN("CBrowserAppUi::FetchL");
       
  1438     
       
  1439     // complete the initialization if not done yet
       
  1440     if(!iStartedUp)
       
  1441         CompleteDelayedInit();
       
  1442     
       
  1443     // Let's cancel the previous fetch if any
       
  1444     if ( Fetching() )
       
  1445 		{
       
  1446         CancelFetch();
       
  1447 		}
       
  1448 #ifndef __WINS__
       
  1449 //Fix for bookmark specific access point
       
  1450     if( iConnection && iConnection->Connected() )
       
  1451        {
       
  1452        TUint32 passedIap( 0 );
       
  1453        if ( aAccessPoint.ApId() != KWmlNoDefaultAccessPoint )
       
  1454            {
       
  1455            passedIap = Util::IapIdFromWapIdL( *this, aAccessPoint.ApId());
       
  1456            BROWSER_LOG((_L("CBrowserAppUi::FetchL Passed Iap: %d"), passedIap));
       
  1457            TUint32 connectedAp = iConnection->CurrentAPId();
       
  1458            BROWSER_LOG((_L("CBrowserAppUi::FetchL Existing connected Iap: %d"), connectedAp));
       
  1459            if(passedIap != connectedAp)
       
  1460                {
       
  1461                StopConnectionObserving();
       
  1462                BROWSER_LOG((_L("CBrowserAppUi::FetchL Stopped the connection observation.")));
       
  1463                DisconnectL();
       
  1464                BROWSER_LOG((_L("CBrowserAppUi::FetchL Given iap and Connected iap are not same. Disconnected the existing connection.")));
       
  1465                }
       
  1466            }
       
  1467 
       
  1468        }
       
  1469 #endif // __WINS__
       
  1470     // iDoNotRestoreContentFlag = EFalse;
       
  1471 
       
  1472     TInt toPop = 0;
       
  1473     TUriParser uriParser;
       
  1474     TInt err = uriParser.Parse(aUrl);
       
  1475     if ( !err && aUrl.Length() )
       
  1476         {
       
  1477         // check url for missing scheme and add default scheme if needed
       
  1478         HBufC* url = NULL;
       
  1479         HBufC* resultUrlBuf = NULL;
       
  1480         //find ://
       
  1481         TPtrC scheme = uriParser.Extract( EUriScheme );
       
  1482         // add http:// scheme as default if it is missing
       
  1483         if( scheme.Length() == 0 )
       
  1484             { 
       
  1485             //put the "http://" schema before the string
       
  1486             url = HBufC::NewLC( aUrl.Length() + KDefaultSchemaLength );
       
  1487             url->Des().Copy( KDefaultSchema );
       
  1488             url->Des().Append( aUrl );
       
  1489             ++toPop;  // url
       
  1490             resultUrlBuf = CreateFullUrlLC( url->Des(), aUsername, aPassword );
       
  1491 		    LogRequestedPageToRecentUrlL(  url->Des() );
       
  1492             }
       
  1493         else
       
  1494             {
       
  1495             resultUrlBuf = CreateFullUrlLC( aUrl, aUsername, aPassword );
       
  1496 		    LogRequestedPageToRecentUrlL(  aUrl );
       
  1497             }
       
  1498         ++toPop;  // resultUrlBuf
       
  1499     
       
  1500     
       
  1501         if ( aAccessPoint.IsNull() || aAccessPoint.IsDefault() || (!Util::IsValidAPFromParamL( *this, aAccessPoint.ApId() )) )
       
  1502 			{
       
  1503             if ( (Preferences().AccessPointSelectionMode() == EConnectionMethod) || 
       
  1504                  (Preferences().AccessPointSelectionMode() == EAlwaysAsk) )
       
  1505                 {
       
  1506                 iRequestedAp = Preferences().DefaultAccessPoint();
       
  1507                 }
       
  1508             else if ( Preferences().AccessPointSelectionMode() == EDestination ) 
       
  1509                 {
       
  1510                 // for bug fix MLAN-7EKFV4
       
  1511     			iRequestedAp = KWmlNoDefaultAccessPoint;
       
  1512                 }
       
  1513             }
       
  1514 		else
       
  1515 			{
       
  1516 			iRequestedAp = aAccessPoint.ApId();
       
  1517 			}
       
  1518 #ifndef __WINSCW__ //On WINS we don't want this dlg to come up
       
  1519 					//as the ConnMan will present us with a selection
       
  1520         BROWSER_LOG( ( _L( "requestedAp: %d" ), iRequestedAp ) );
       
  1521         // it's ok to assign in the case of EDest, since CBrCtl doesn't use the apId passed in LoadUrlL()
       
  1522         TUint32 IAPid = iRequestedAp;
       
  1523         TUint32 defaultSnap =  iPreferences->DefaultSnapId();
       
  1524 #ifndef BRDO_OCC_ENABLED_FF
       
  1525         // if no AP or SNAP is defined, define it
       
  1526         if( (iRequestedAp == KWmlNoDefaultAccessPoint && iPreferences->AccessPointSelectionMode() == EConnectionMethod) || 
       
  1527             (defaultSnap == KWmlNoDefaultSnapId && iPreferences->AccessPointSelectionMode() == EDestination) )
       
  1528             {
       
  1529             StartPreferencesViewL( EShowAlwaysAsk | EShowDestinations | EShowConnectionMethods );
       
  1530             }
       
  1531         //Check AP and snap if it is still not defined, set always ask mode this case
       
  1532         if ( (iRequestedAp == KWmlNoDefaultAccessPoint && iPreferences->AccessPointSelectionMode() == EConnectionMethod) ||
       
  1533              (defaultSnap == KWmlNoDefaultSnapId && iPreferences->AccessPointSelectionMode() == EDestination) )
       
  1534             {
       
  1535             BROWSER_LOG( ( _L( "AP or SNAP was not added set to Always ask mode" ) ) );
       
  1536             iPreferences->SetAccessPointSelectionModeL(EAlwaysAsk );
       
  1537             }
       
  1538         if ( iRequestedAp != KWmlNoDefaultAccessPoint )
       
  1539             {
       
  1540     		    BROWSER_LOG( ( _L( "AP added" ) ) );
       
  1541             IAPid = Util::IapIdFromWapIdL( *this, iRequestedAp );  // Get currently active ap
       
  1542             BROWSER_LOG( ( _L( "Access point: %d" ), IAPid ) );
       
  1543             }
       
  1544 
       
  1545 #endif // BRDO_OCC_ENABLED_FF
       
  1546 #else	//we can use any numbers here
       
  1547         // alr: snap on emulator should not exist; use cm mode instead?
       
  1548 		iRequestedAp = 2;
       
  1549 		TUint32 IAPid = 2;
       
  1550 #endif //__WINSCW__
       
  1551 
       
  1552 		err = KErrNone;
       
  1553 		BROWSER_LOG( ( _L( "Load the URL" ) ) );
       
  1554 		
       
  1555 		if ( iPreferences->SearchFeature() || iPreferences->ServiceFeature())
       
  1556 		    {
       
  1557     		iSpecialSchemeinAddress = EFalse;
       
  1558             
       
  1559             HBufC* searchScheme = HBufC::NewLC( KMaxHomePgUrlLength );  // cleanupstack
       
  1560             TPtr searchSchemePtr( searchScheme->Des() );
       
  1561             ++toPop;
       
  1562             
       
  1563             HBufC* serviceScheme = HBufC::NewLC( KMaxHomePgUrlLength );  // cleanupstack
       
  1564             TPtr serviceSchemePtr( serviceScheme->Des() );
       
  1565             ++toPop;
       
  1566             
       
  1567             iPreferences->GetStringValueL( KBrowserSearchProviderUrl, KMaxHomePgUrlLength, searchSchemePtr );
       
  1568             iPreferences->GetStringValueL( KBrowserServiceUrl, KMaxHomePgUrlLength, serviceSchemePtr );
       
  1569                     
       
  1570             TInt err = uriParser.Parse(searchSchemePtr);
       
  1571             if (!err)
       
  1572                 searchSchemePtr = uriParser.Extract( EUriScheme );
       
  1573             
       
  1574             err = uriParser.Parse(serviceSchemePtr);
       
  1575             if (!err)
       
  1576                 serviceSchemePtr = uriParser.Extract( EUriScheme );
       
  1577 
       
  1578 
       
  1579             if( scheme.Length() != 0 && (!scheme.Compare(serviceSchemePtr) || !scheme.Compare(searchSchemePtr)) )
       
  1580                 {
       
  1581                 iSpecialSchemeinAddress = ETrue;
       
  1582                 TRAP( err, BrCtlInterface().LoadUrlL( resultUrlBuf->Des(), IAPid ) );
       
  1583                 }
       
  1584             else
       
  1585                 {
       
  1586                 LoadObserver().DoStartLoad( aUrlType );
       
  1587                 TRAP( err, BrCtlInterface().LoadUrlL( resultUrlBuf->Des(), IAPid ) );
       
  1588                 }            
       
  1589 	        }
       
  1590 	    else
       
  1591 	        {
       
  1592 	        LoadObserver().DoStartLoad( aUrlType );
       
  1593 	        BROWSER_LOG( ( _L( "PASSED IAP: %d" ), IAPid ) );
       
  1594             TRAP( err, BrCtlInterface().LoadUrlL( resultUrlBuf->Des(), IAPid ) );
       
  1595 	        }
       
  1596         
       
  1597 		CleanupStack::PopAndDestroy(toPop); //resultUrlBuf and url if needed
       
  1598 		BROWSER_LOG( ( _L( "No AP 4 %d" ), err  ) );
       
  1599 		if ( err != KErrNone )
       
  1600     		{
       
  1601 		    CancelFetch();
       
  1602 	    	}
       
  1603         }
       
  1604 
       
  1605     BROWSER_LOG( ( _L( "Check the result" ) ) );
       
  1606 	switch ( err )
       
  1607 		{
       
  1608 		case KErrNotFound:
       
  1609 			{
       
  1610 			(*(CBrowserBookmarksView*)View( KUidBrowserBookmarksViewId )).UpdateGotoPaneL();
       
  1611 			iCoeEnv->HandleError( KBrsrMalformedUrl );
       
  1612 			BROWSER_LOG( ( _L( "KErrNotFound" ) ) );
       
  1613 			break;
       
  1614 			}
       
  1615 		case KUriUtilsErrInvalidUri: // return value of TUriParser::Parse
       
  1616 			{
       
  1617 			(*(CBrowserBookmarksView*)View( KUidBrowserBookmarksViewId )).UpdateGotoPaneL();
       
  1618 			iCoeEnv->HandleError( KBrsrUnknownScheme );
       
  1619 			BROWSER_LOG( ( _L( "KUriUtilsErrInvalidUri" ) ) );
       
  1620 			break;
       
  1621 			}
       
  1622 		case KErrNone:
       
  1623 		    {
       
  1624 		    BROWSER_LOG( ( _L( "KErrNone" ) ) );
       
  1625             ContentView()->ResetPreviousViewFlag();
       
  1626 		    break;
       
  1627 		    }
       
  1628         case KErrCancel:
       
  1629             {
       
  1630             BROWSER_LOG( ( _L( "KErrCancel" ) ) );
       
  1631             // do nothing, it is already cancelled by CancelFetch().
       
  1632             break;
       
  1633             }
       
  1634         default:
       
  1635 			{
       
  1636 			BROWSER_LOG( ( _L( "default" ) ) );
       
  1637 			User::Leave( err );  // pass error code to caller
       
  1638 			break;
       
  1639 			}
       
  1640 		}
       
  1641 	}
       
  1642 
       
  1643 // -----------------------------------------------------------------------------
       
  1644 // CBrowserAppUi::ExitBrowser()
       
  1645 // -----------------------------------------------------------------------------
       
  1646 //
       
  1647 void CBrowserAppUi::ExitBrowser( TBool aUserInitiated )
       
  1648     {
       
  1649     LOG_ENTERFN("CBrowserAppUi::ExitBrowser");
       
  1650 
       
  1651     TInt err( KErrNone );
       
  1652 	TBool isStandAlone = !IsEmbeddedModeOn();
       
  1653 	BROWSER_LOG( ( _L( " isStandAlone: %d" ), isStandAlone ) );
       
  1654 
       
  1655 	if(isStandAlone && aUserInitiated )
       
  1656 	    {
       
  1657 		if( iStartedUp && !BrCtlInterface().OkToExit() )
       
  1658 		    {
       
  1659 		    return;
       
  1660 		    }
       
  1661 	    }
       
  1662 
       
  1663 	//If launch with parameters is in progress, do not exit now
       
  1664 	//as it can lead to synchronisation problems in embedded mode
       
  1665 	if ( iParametrizedLaunchInProgress == 1 )
       
  1666 		{
       
  1667 		BROWSER_LOG( ( _L( " iParametrizedLaunchInProgress" ) ) );
       
  1668 		return;
       
  1669 		}
       
  1670 
       
  1671     // Operator feature - Display confirmation note on exit only if exit is initiated by user.
       
  1672     // Skip displaying exit confirmation if exit is initiated from fast swap window.
       
  1673     BROWSER_LOG(  ( _L( " iPreferences:  %d" ), iPreferences ) );
       
  1674     if ( iPreferences->QueryOnExit() && aUserInitiated )
       
  1675         {
       
  1676         BROWSER_LOG( ( _L( " iPreferences->QueryOnExit()" ) ) );
       
  1677         TBool confirmdialog( EFalse );
       
  1678         TRAP( err, confirmdialog = TBrowserDialogs::ConfirmQueryYesNoL( R_TEXT_WML_EXIT_CONFIRM ) );
       
  1679         if ( !confirmdialog )
       
  1680         	{
       
  1681             return;
       
  1682         	}
       
  1683 		}
       
  1684 
       
  1685     //delete attacment from mailer if existing
       
  1686 	CCoeEnv::Static()->FsSession().Delete( KAttachment() );
       
  1687 	
       
  1688     BROWSER_LOG( ( _L(" iConnection:  %d"), iConnection ) );
       
  1689     BROWSER_LOG( ( _L(" iExitFromEmbeddedMode:  %d"), iExitFromEmbeddedMode ) );
       
  1690     // if browser is embedded, should not call Exit(),
       
  1691     // just delete the object, otherwise leave occurs.
       
  1692     if( ( IsEmbeddedInOperatorMenu() || IsEmbeddedModeOn() ) &&
       
  1693             !ExitInProgress() && iStartedUp &&
       
  1694              ((LoadObserver().LoadUrlType() == CBrowserLoadObserver::ELoadUrlTypeEmbeddedBrowserWithUrl) ||
       
  1695              (LoadObserver().LoadUrlType() == CBrowserLoadObserver::ELoadUrlTypeOther)   ) )
       
  1696                // ELoadUrlTypeEmbeddedBrowserWithUrl is typical for load via Phonebook, MMS, OperatorMenu
       
  1697                // ELoadUrlTypeOther is typical via Media download since those are via GotoPane entered urls
       
  1698         {
       
  1699         // Simulate an escape key event in order to close any open resources (for example an open dialog)
       
  1700         TKeyEvent keyEvent;
       
  1701         keyEvent.iModifiers = 0;
       
  1702         keyEvent.iRepeats = 0;
       
  1703         keyEvent.iCode = EKeyEscape;
       
  1704         keyEvent.iScanCode = EStdKeyEscape;
       
  1705         TRAP_IGNORE(iCoeEnv->SimulateKeyEventL( keyEvent, EEventKey ));
       
  1706 
       
  1707         // force not to load Exit() when next time call this function,
       
  1708         // just delete the object
       
  1709         SetExitFromEmbeddedMode( ETrue );
       
  1710         SetExitInProgress( ETrue );
       
  1711         BROWSER_LOG( ( _L( " iBrowserAsyncExit->Start()" ) ) );
       
  1712         iBrowserAsyncExit->Start();
       
  1713         }
       
  1714     else if( iExitFromEmbeddedMode )
       
  1715     	{
       
  1716     	BROWSER_LOG( ( _L( " delete this;" ) ) );
       
  1717     	if ( iConnection )
       
  1718     		{
       
  1719             TRAP_IGNORE( SendDisconnectEventL() );
       
  1720     		iConnection->Disconnect();
       
  1721 #ifdef __RSS_FEEDS
       
  1722             BROWSER_LOG( ( _L( " iFeedsClientUtilities->DisconnectFeedsViewL()" ) ) );
       
  1723             if ( iFeedsClientUtilities )
       
  1724                 {
       
  1725             TRAP_IGNORE( iFeedsClientUtilities->DisconnectFeedsViewL() );
       
  1726             //notify feeds engine to close the connection
       
  1727             TRAP_IGNORE( iFeedsClientUtilities->DisconnectManualUpdateConnectionL() );
       
  1728                 } 
       
  1729 #endif
       
  1730     		}
       
  1731         if (iStartedUp && SpecialLoadObserver().IsConnectionStarted()) 
       
  1732             {
       
  1733                BROWSER_LOG( ( _L( " iWindowManager->SetUserExit( iUserExit )" ) ) );
       
  1734                iWindowManager->SetUserExit( iUserExit );
       
  1735                delete iWindowManager;
       
  1736                BROWSER_LOG( ( _L( " User::Exit(KErrNone)" ) ) );
       
  1737                User::Exit(KErrNone);
       
  1738             }
       
  1739         else
       
  1740             {
       
  1741             PrepareToExit();
       
  1742             Exit();
       
  1743             }
       
  1744     	}
       
  1745     else
       
  1746     	{
       
  1747     	BROWSER_LOG( ( _L( " Exit()" ) ) );
       
  1748     	if ( iConnection )
       
  1749     		{
       
  1750             TRAP_IGNORE( SendDisconnectEventL() );
       
  1751     		iConnection->Disconnect();
       
  1752 #ifdef __RSS_FEEDS
       
  1753             if ( iFeedsClientUtilities )
       
  1754                 {
       
  1755     		BROWSER_LOG( ( _L( " iFeedsClientUtilities->DisconnectFeedsViewL()" ) ) );
       
  1756     		TRAP_IGNORE( iFeedsClientUtilities->DisconnectFeedsViewL() );
       
  1757     		//notify feeds engine to close the connection
       
  1758 			TRAP_IGNORE( iFeedsClientUtilities->DisconnectManualUpdateConnectionL() );
       
  1759                 }
       
  1760 #endif
       
  1761     		}
       
  1762     	if (iStartedUp && SpecialLoadObserver().IsConnectionStarted()) // If Connection request is in processing calling CAknAppUI::Exit() causes crash (JSAA-84RG9R)
       
  1763     	    {                                               
       
  1764     	    //ensure that the params are saved in BrCtl            
       
  1765     	    if ( iWindowManager ) 
       
  1766     	       {
       
  1767     	       BROWSER_LOG( ( _L( " iWindowManager->SetUserExit( iUserExit )" ) ) );
       
  1768     	       iWindowManager->SetUserExit( iUserExit );
       
  1769     	       }
       
  1770     	       delete iWindowManager;
       
  1771     	       BROWSER_LOG( ( _L( " User::Exit(KErrNone)" ) ) );
       
  1772     	       User::Exit(KErrNone);                      
       
  1773     	     }
       
  1774         else
       
  1775     	     {      
       
  1776     	     // normal exit
       
  1777              Exit();
       
  1778     	     }
       
  1779     	}
       
  1780     }
       
  1781 
       
  1782 // -----------------------------------------------------------------------------
       
  1783 // CBrowserAppUi::Display
       
  1784 // -----------------------------------------------------------------------------
       
  1785 //
       
  1786 MDisplay& CBrowserAppUi::Display() const
       
  1787     {
       
  1788     CBrowserWindow *window = iWindowManager->CurrentWindow();
       
  1789     __ASSERT_DEBUG( window, Util::Panic( Util::EUninitializedData ) );
       
  1790     return window->Display();
       
  1791     }
       
  1792 
       
  1793 // -----------------------------------------------------------------------------
       
  1794 // CBrowserAppUi::SoftkeysObserver()
       
  1795 // -----------------------------------------------------------------------------
       
  1796 //
       
  1797 CBrowserSoftkeysObserver& CBrowserAppUi::SoftkeysObserver() const
       
  1798     {
       
  1799     CBrowserWindow *window = iWindowManager->CurrentWindow();
       
  1800     __ASSERT_DEBUG( window, Util::Panic( Util::EUninitializedData ) );
       
  1801     return window->SoftkeysObserver();
       
  1802     }
       
  1803 
       
  1804 // -----------------------------------------------------------------------------
       
  1805 // CBrowserAppUi::CommsModel
       
  1806 // -----------------------------------------------------------------------------
       
  1807 //
       
  1808 MCommsModel& CBrowserAppUi::CommsModel() const
       
  1809     {
       
  1810     __ASSERT_DEBUG( iCommsModel,
       
  1811         Util::Panic( Util::EUninitializedData ) );
       
  1812     return *iCommsModel;
       
  1813     }
       
  1814 
       
  1815 // -----------------------------------------------------------------------------
       
  1816 // CBrowserAppUi::Preferences
       
  1817 // -----------------------------------------------------------------------------
       
  1818 //
       
  1819 MPreferences& CBrowserAppUi::Preferences() const
       
  1820     {
       
  1821     __ASSERT_DEBUG( iPreferences,
       
  1822         Util::Panic( Util::EUninitializedData ) );
       
  1823     return *iPreferences;
       
  1824     }
       
  1825 
       
  1826 // -----------------------------------------------------------------------------
       
  1827 // CBrowserAppUi::Connection
       
  1828 // -----------------------------------------------------------------------------
       
  1829 //
       
  1830 MConnection& CBrowserAppUi::Connection() const
       
  1831     {
       
  1832     __ASSERT_DEBUG( iConnection,
       
  1833         Util::Panic( Util::EUninitializedData ) );
       
  1834     return *iConnection;
       
  1835     }
       
  1836 
       
  1837 // -----------------------------------------------------------------------------
       
  1838 // CBrowserAppUi::BrCtlInterface
       
  1839 // -----------------------------------------------------------------------------
       
  1840 CBrCtlInterface& CBrowserAppUi::BrCtlInterface() const
       
  1841     {
       
  1842     CBrowserWindow *window = iWindowManager->CurrentWindow();
       
  1843     __ASSERT_DEBUG( window, Util::Panic( Util::EUninitializedData ) );
       
  1844     return window->BrCtlInterface();
       
  1845     }
       
  1846 
       
  1847 // -----------------------------------------------------------------------------
       
  1848 // CBrowserAppUi::LoadObserver
       
  1849 // -----------------------------------------------------------------------------
       
  1850 //
       
  1851 CBrowserLoadObserver& CBrowserAppUi::LoadObserver() const
       
  1852     {
       
  1853     CBrowserWindow *window = iWindowManager->CurrentWindow();
       
  1854     __ASSERT_DEBUG( window, Util::Panic( Util::EUninitializedData ) );
       
  1855     return window->LoadObserver();
       
  1856     }
       
  1857 
       
  1858 // -----------------------------------------------------------------------------
       
  1859 // CBrowserAppUi::SpecialLoadObserver
       
  1860 // -----------------------------------------------------------------------------
       
  1861 //
       
  1862 CBrowserSpecialLoadObserver& CBrowserAppUi::SpecialLoadObserver() const
       
  1863     {
       
  1864     CBrowserWindow *window = iWindowManager->CurrentWindow();
       
  1865     __ASSERT_DEBUG( window, Util::Panic( Util::EUninitializedData ) );
       
  1866     return window->SpecialLoadObserver();
       
  1867     }
       
  1868 
       
  1869 // -----------------------------------------------------------------------------
       
  1870 // CBrowserAppUi::DialogsProvider
       
  1871 // -----------------------------------------------------------------------------
       
  1872 //
       
  1873 CBrowserDialogsProvider& CBrowserAppUi::DialogsProvider() const
       
  1874 	{
       
  1875 	return *iDialogsProvider;
       
  1876 	}
       
  1877 
       
  1878 // -----------------------------------------------------------------------------
       
  1879 // CBrowserAppUi::PopupEngine
       
  1880 // -----------------------------------------------------------------------------
       
  1881 //
       
  1882 CBrowserPopupEngine& CBrowserAppUi::PopupEngine() const
       
  1883     {
       
  1884     LOG_ENTERFN("CBrowserAppUi::PopupEngine");
       
  1885     if(!iPopupEngine)
       
  1886         { 
       
  1887             if ( Preferences().UiLocalFeatureSupported( KBrowserMultipleWindows ) )
       
  1888                 {
       
  1889                     iPopupEngine = CBrowserPopupEngine::NewL();
       
  1890                     BROWSER_LOG( ( _L( "PopupEngine up" ) ) );
       
  1891                 }
       
  1892         }
       
  1893     return *iPopupEngine;
       
  1894     }
       
  1895 
       
  1896 // -----------------------------------------------------------------------------
       
  1897 // CBrowserAppUi::WindowMgr()
       
  1898 // -----------------------------------------------------------------------------
       
  1899 //
       
  1900 CBrowserWindowManager& CBrowserAppUi::WindowMgr() const
       
  1901     {
       
  1902     return *iWindowManager;
       
  1903     }
       
  1904 
       
  1905 // -----------------------------------------------------------------------------
       
  1906 // CBrowserAppUi::IsCancelFetchAllowed
       
  1907 // -----------------------------------------------------------------------------
       
  1908 //
       
  1909 TBool CBrowserAppUi::IsCancelFetchAllowed() const
       
  1910     {
       
  1911     return ETrue;
       
  1912     }
       
  1913 
       
  1914 // -----------------------------------------------------------------------------
       
  1915 // CBrowserAppUi::UpdateCbaL()
       
  1916 // -----------------------------------------------------------------------------
       
  1917 //
       
  1918 void CBrowserAppUi::UpdateCbaL()
       
  1919     {
       
  1920     if( ActiveView() )
       
  1921         {
       
  1922         ActiveView()->UpdateCbaL();
       
  1923         }
       
  1924     }
       
  1925 
       
  1926 void CBrowserAppUi::LogAccessToRecentUrlL( CBrCtlInterface& aBrCtlInterface )
       
  1927     {
       
  1928     if ((ADAPTIVEBOOKMARKS)&&(!(Preferences().AdaptiveBookmarks()==EWmlSettingsAdaptiveBookmarksOff )))
       
  1929         {
       
  1930         HBufC* url = aBrCtlInterface.PageInfoLC( TBrCtlDefs::EPageInfoUrl );
       
  1931         HBufC* name = aBrCtlInterface.PageInfoLC( TBrCtlDefs::EPageInfoTitle );
       
  1932         if( url && url->Length() )
       
  1933             {
       
  1934             // If url is same as the one in the store delete it because the url will be rewritten 
       
  1935             // along with the name 
       
  1936             iRecentUrlStore->DeleteData(*url);
       
  1937             
       
  1938             TInt index;
       
  1939             index = url->Des().LocateReverse(KSlash);
       
  1940             // If the only difference between the url in the store and the one we are writing is a "/" 
       
  1941             // at the end of the url, delete the one in the store because it will be rewritten along 
       
  1942             // with the name
       
  1943             if (index == url->Length()-1)
       
  1944             	{
       
  1945 	            HBufC* urlwoslash = HBufC::NewLC( url->Length() );
       
  1946 				urlwoslash->Des().Copy( *url );
       
  1947 				urlwoslash->Des().Delete(url->Length() -1, 2);         
       
  1948 	            
       
  1949 	            iRecentUrlStore->DeleteData(*urlwoslash);
       
  1950 
       
  1951 	            CleanupStack::PopAndDestroy(); //urlwoslash            	
       
  1952             	}
       
  1953                         
       
  1954             if (name && name->Length())
       
  1955             	{
       
  1956             	iRecentUrlStore->SaveDataL(*url,*name);
       
  1957             	}
       
  1958             else
       
  1959             	{
       
  1960             	if (url->Length() > KFavouritesMaxName)
       
  1961                 	{
       
  1962                 	// name will be the url but it needs to be compressed to fit max name length
       
  1963                 	HBufC* cname = HBufC::NewLC(KFavouritesMaxName);
       
  1964                 	TInt edgeStringLen = ((KFavouritesMaxName / 2) - 3);
       
  1965                 	TPtrC cnameRight( url->Right( edgeStringLen ) );
       
  1966                 	TPtrC cnameLeft( url->Left( edgeStringLen ));
       
  1967                 	TPtr cnameDes = cname->Des();
       
  1968 
       
  1969                   	cnameDes.Append( cnameLeft );
       
  1970                    	cnameDes.AppendFill( TChar(KDot),5 );   // '.....'
       
  1971                    	cnameDes.Append( cnameRight );
       
  1972                 	iRecentUrlStore->SaveDataL(*url,*cname);
       
  1973                     CleanupStack::PopAndDestroy();//cname
       
  1974                 	}
       
  1975                 else
       
  1976             	    {
       
  1977             	    iRecentUrlStore->SaveDataL(*url,*url);
       
  1978             	    }
       
  1979             	}
       
  1980             }
       
  1981         CleanupStack().PopAndDestroy(2); // url, name
       
  1982         }
       
  1983     }
       
  1984 
       
  1985 void CBrowserAppUi::LogRequestedPageToRecentUrlL( const TDesC& aUrl )
       
  1986     {
       
  1987     if ((ADAPTIVEBOOKMARKS)&&(!(Preferences().AdaptiveBookmarks()==EWmlSettingsAdaptiveBookmarksOff )))
       
  1988         {
       
  1989         HBufC *url = HBufC::NewLC( aUrl.Length() );
       
  1990 		url->Des().Copy( aUrl );
       
  1991 
       
  1992         if( url && url->Length() )
       
  1993             {
       
  1994            	if (url->Length() > KFavouritesMaxName)
       
  1995             	{
       
  1996             	// name will be the url but it needs to be compressed to fit max name length
       
  1997             	HBufC* cname = HBufC::NewLC(KFavouritesMaxName);
       
  1998             	TInt edgeStringLen = ((KFavouritesMaxName / 2) - 3);
       
  1999             	TPtrC cnameRight( url->Right( edgeStringLen ) );
       
  2000             	TPtrC cnameLeft( url->Left( edgeStringLen ));
       
  2001             	TPtr cnameDes = cname->Des();
       
  2002 
       
  2003               	cnameDes.Append( cnameLeft );
       
  2004                	cnameDes.AppendFill( TChar(KDot),5 );   // '.....'
       
  2005                	cnameDes.Append( cnameRight );
       
  2006             	iRecentUrlStore->SaveDataL(*url,*cname);
       
  2007                 CleanupStack::PopAndDestroy();//cname
       
  2008             	}
       
  2009             else
       
  2010         	    {
       
  2011         	    iRecentUrlStore->SaveDataL(*url,*url);
       
  2012         	    }
       
  2013             }
       
  2014         CleanupStack().PopAndDestroy(); // url
       
  2015         }
       
  2016     }
       
  2017 
       
  2018 // -----------------------------------------------------------------------------
       
  2019 // CBrowserAppUi::SwitchWindowL()
       
  2020 // -----------------------------------------------------------------------------
       
  2021 //
       
  2022 void CBrowserAppUi::SwitchWindowL()
       
  2023     {
       
  2024 LOG_ENTERFN("CBrowserAppUi::SwitchWindowL");
       
  2025     CArrayFixFlat<CWindowInfo*>* windowBuf = iWindowManager->GetWindowInfoL( this );
       
  2026     CleanupStack::PushL( windowBuf );
       
  2027 
       
  2028     // Open 'Switch Window' selection dialog
       
  2029     HBufC* title = StringLoader::LoadLC( R_BROWSER_SWITCH_WINDOW_HEADER );
       
  2030 
       
  2031     CArrayFixFlat<TBrCtlSelectOptionData>* optDataArray = new ( ELeave )
       
  2032         CArrayFixFlat<TBrCtlSelectOptionData>( KGranularityMedium );
       
  2033     CleanupStack::PushL( optDataArray );
       
  2034 
       
  2035     TInt i( 0 );
       
  2036     TInt numWindows = windowBuf->Count();
       
  2037 
       
  2038 LOG_WRITE_FORMAT("Window's count: %d", numWindows );
       
  2039     for ( i = 0; i < numWindows; ++i )
       
  2040         {
       
  2041         TBrCtlSelectOptionData optData( *((*windowBuf)[i]->iWindowText),
       
  2042                                         (*windowBuf)[i]->iCurrent,
       
  2043                                         EFalse,
       
  2044                                         EFalse );
       
  2045         optDataArray->AppendL( optData );
       
  2046         }
       
  2047 
       
  2048     TBool ret = DialogsProvider().DialogSelectOptionL( *title,
       
  2049                                                         ESelectTypeSingle,
       
  2050                                                         *optDataArray );
       
  2051     if ( ret )
       
  2052         {
       
  2053         for( i = 0; i < numWindows; ++i)
       
  2054             {
       
  2055             if( (*optDataArray)[i].IsSelected() )
       
  2056                 {
       
  2057                 LOG_WRITE_FORMAT("Selected window: %d", (*windowBuf)[i]->iWindowId );
       
  2058                 iWindowManager->SwitchWindowL( (*windowBuf)[i]->iWindowId );
       
  2059                 break;
       
  2060                 }
       
  2061             }
       
  2062         }
       
  2063     CleanupStack::PopAndDestroy( 3 );           // optDataArray, title, windowBuf
       
  2064     }
       
  2065 
       
  2066 // -----------------------------------------------------------------------------
       
  2067 // CBrowserAppUi::SetCalledFromAnotherApp
       
  2068 // -----------------------------------------------------------------------------
       
  2069 //
       
  2070 void CBrowserAppUi::SetCalledFromAnotherApp( TBool aValue )
       
  2071     {
       
  2072     iCalledFromAnotherApp = aValue;
       
  2073     }
       
  2074 
       
  2075 // -----------------------------------------------------------------------------
       
  2076 // CBrowserAppUi::CalledFromAnotherApp
       
  2077 // -----------------------------------------------------------------------------
       
  2078 //
       
  2079 TBool CBrowserAppUi::CalledFromAnotherApp()
       
  2080     {
       
  2081     return iCalledFromAnotherApp;
       
  2082     }
       
  2083     
       
  2084 // -----------------------------------------------------------------------------
       
  2085 // CBrowserAppUi::NoHomePageToBeLaunchedL
       
  2086 // -----------------------------------------------------------------------------
       
  2087 //
       
  2088 TBool CBrowserAppUi::NoHomePageToBeLaunchedL()
       
  2089     {
       
  2090     LOG_ENTERFN("CBrowserAppUi::NoHomePageToBeLaunchedL");
       
  2091     TWmlSettingsHomePage pgtype = iPreferences->HomePageType();
       
  2092     TBool alwaysAskCase = (( Preferences().AccessPointSelectionMode() == EAlwaysAsk ) &&
       
  2093                            ( EWmlSettingsHomePageAccessPoint == pgtype ));
       
  2094     BROWSER_LOG( ( _L( "pgtype: %d, alwaysAsk: %d" ), pgtype, alwaysAskCase ) );
       
  2095 
       
  2096     if( ( pgtype == EWmlSettingsHomePageBookmarks ) || alwaysAskCase )
       
  2097         {   // Can't load home page since set to Bookmarks or (AlwaysAsk AP and homepage set to AP homepage)
       
  2098         return ETrue;
       
  2099         }
       
  2100     else
       
  2101         {
       
  2102         // now check for other cases where homepage string might be defined and will be used    
       
  2103         HBufC* buf = HBufC::NewLC( KMaxHomePgUrlLength );  // cleanupstack
       
  2104         TPtr ptr( buf->Des() );
       
  2105         TInt pgFound = Preferences().HomePageUrlL( ptr );
       
  2106         CleanupStack::PopAndDestroy( buf );
       
  2107         if (pgFound != KErrNone)
       
  2108             {   // no homepage string found
       
  2109             return ETrue;
       
  2110             }
       
  2111         else
       
  2112             {   // homepage string was found 
       
  2113             return EFalse;
       
  2114             }
       
  2115         }        
       
  2116     }
       
  2117 
       
  2118 // CBrowserAppUi::ProcessCommandParametersL()
       
  2119 // -----------------------------------------------------------------------------
       
  2120 //
       
  2121 TBool CBrowserAppUi::ProcessCommandParametersL( TApaCommand aCommand,
       
  2122                                                TFileName& /*aDocumentName*/ ,
       
  2123                                                const TDesC8& /*aTail*/ )
       
  2124     {
       
  2125     LOG_ENTERFN("CBrowserAppUi::ProcessCommandParametersL");
       
  2126     LOG_WRITE_FORMAT(" aCommand: %d", aCommand);
       
  2127 
       
  2128     // The browser is in embedded mode and it is not initialized yet
       
  2129     if ( IsEmbeddedModeOn() && !iStartedUp)
       
  2130     	{
       
  2131         EnableLocalScreenClearer( EFalse );
       
  2132     	return EFalse;
       
  2133     	}
       
  2134 
       
  2135     if ( aCommand == EApaCommandOpen )
       
  2136         {
       
  2137 		//Startup parameters are given to browser at CBrowserAppDocument::OpenFileL().
       
  2138 		//- a part of shell starting (ConstructAppFromCommandLineL calls OpenFileL)
       
  2139         }
       
  2140 
       
  2141     else if ( aCommand == EApaCommandRun )
       
  2142         {
       
  2143 
       
  2144    	    if ( LastActiveViewId() == KUidBrowserNullViewId )
       
  2145 	        {
       
  2146 	        TBool specialSchemeInHomePageAddress = EFalse;
       
  2147 	        
       
  2148 	        if (NoHomePageToBeLaunchedL())
       
  2149 	            {
       
  2150 	            // No homepage to be launched so start browser in bookmarks view
       
  2151     	        SetLastActiveViewId(KUidBrowserBookmarksViewId);
       
  2152 	            }
       
  2153     	    else if ( iPreferences->SearchFeature() || iPreferences->ServiceFeature())
       
  2154     	        {
       
  2155     	        
       
  2156     	        HBufC* buf = HBufC::NewLC( KMaxHomePgUrlLength );  // cleanupstack
       
  2157     	        TPtr ptr( buf->Des() );
       
  2158     	        TInt pgFound( KErrNotFound );
       
  2159 				pgFound = Preferences().HomePageUrlL( ptr );
       
  2160     			HBufC* searchScheme = HBufC::NewLC( KMaxHomePgUrlLength );  // cleanupstack
       
  2161     			TPtr searchSchemePtr( searchScheme->Des() );
       
  2162     			
       
  2163     			HBufC* serviceScheme = HBufC::NewLC( KMaxHomePgUrlLength );  // cleanupstack
       
  2164     			TPtr serviceSchemePtr( serviceScheme->Des() );
       
  2165     			
       
  2166     	        iPreferences->GetStringValueL( KBrowserSearchProviderUrl, KMaxHomePgUrlLength, searchSchemePtr );
       
  2167     	        iPreferences->GetStringValueL( KBrowserServiceUrl, KMaxHomePgUrlLength, serviceSchemePtr );
       
  2168 
       
  2169     			
       
  2170 	            if( !ptr.Compare(serviceSchemePtr) || !ptr.Compare(searchSchemePtr) )
       
  2171 	            	{    
       
  2172 	            	specialSchemeInHomePageAddress = ETrue;
       
  2173 	            	SetLastActiveViewId(KUidBrowserBookmarksViewId);
       
  2174 	            	SetViewToBeActivatedIfNeededL(KUidBrowserContentViewId, 0);
       
  2175 	            	TRAPD( err, FetchL( ptr, CBrowserLoadObserver::ELoadUrlTypeOther ) );
       
  2176 	            	}
       
  2177 	            else
       
  2178 	                {
       
  2179 	                SetViewToBeActivatedIfNeededL(KUidBrowserContentViewId, 0);
       
  2180                     StartFetchHomePageL();
       
  2181 	            	}
       
  2182     	        CleanupStack::PopAndDestroy( 3,buf );
       
  2183     	        }
       
  2184             else
       
  2185             	{
       
  2186                 SetViewToBeActivatedIfNeededL(KUidBrowserContentViewId, 0);
       
  2187                 StartFetchHomePageL();
       
  2188             	}
       
  2189            
       
  2190 	        if( !specialSchemeInHomePageAddress )
       
  2191 	            {
       
  2192                 if( iCurrentView != iLastViewId )
       
  2193                     ActivateLocalViewL( LastActiveViewId() );
       
  2194 	            }
       
  2195         	}        	   	  
       
  2196         }
       
  2197     else if ( aCommand == EApaCommandViewActivate )
       
  2198     // Get when activated from soft notification (Downloads List).
       
  2199     // Must behave as in case of EApaCommandOpen, but no OpenFileL() is called.
       
  2200         {
       
  2201         ParseAndProcessParametersL( KNullDesC8 );
       
  2202         }
       
  2203     return EFalse;
       
  2204     }
       
  2205 
       
  2206 // -----------------------------------------------------------------------------
       
  2207 // CBrowserAppUi::Static()
       
  2208 // -----------------------------------------------------------------------------
       
  2209 //
       
  2210 CBrowserAppUi* CBrowserAppUi::Static()
       
  2211     {
       
  2212     return REINTERPRET_CAST( CBrowserAppUi*, CEikonEnv::Static()->EikAppUi() );
       
  2213     }
       
  2214 
       
  2215 // -----------------------------------------------------------------------------
       
  2216 // CBrowserAppUi::ParseAndProcessParametersL
       
  2217 // -----------------------------------------------------------------------------
       
  2218 //
       
  2219 void CBrowserAppUi::ParseAndProcessParametersL( const TDesC8& aDocumentName, TBool aDoFetch )
       
  2220     {
       
  2221     LOG_ENTERFN("CBrowserAppUi::ParseAndProcessParametersL");
       
  2222     TInt err = KErrNone;
       
  2223 
       
  2224     TUid ViewToActivate = { 0 };
       
  2225 
       
  2226     HBufC8* params = NULL;
       
  2227     TLex8 parameter(aDocumentName);
       
  2228 
       
  2229     // Here we check if the url contains control characters.
       
  2230     TBool urlError( EFalse );  // If there is a Control caracter in the url.
       
  2231     parameter.Mark(); // Save the start position in the string.
       
  2232     while ( !parameter.Eos() && !urlError )
       
  2233         {
       
  2234         if ( parameter.Get().IsControl() )
       
  2235             {
       
  2236             urlError = ETrue;
       
  2237             }
       
  2238         }
       
  2239     parameter.UnGetToMark(); // Now go back to the beginning of the string.
       
  2240 
       
  2241     //Check for parameter validity
       
  2242     if(	!parameter.Peek().IsDigit() || urlError )    //First char of aDocumentName is NOT a digit
       
  2243         {
       
  2244         if( ( aDocumentName.Locate( ':' ) > 0) && (!urlError) )    //There is a ":" character in aDocumentName (->probably a valid url)
       
  2245             {
       
  2246             //Add "4" + <space> before the given parameter to make the parameter legal for url launch
       
  2247             _LIT8(KUrlId, "4 ");
       
  2248             params = HBufC8::NewL(aDocumentName.Length() + 2 + 1);
       
  2249             params->Des().Copy( KUrlId );
       
  2250             params->Des().Append(aDocumentName);
       
  2251             params->Des().ZeroTerminate();
       
  2252             ViewToActivate = KUidBrowserContentViewId;
       
  2253             }
       
  2254         else
       
  2255             {
       
  2256             //Activate bookmarks view if parameters are invalid and browser is not embedded.
       
  2257             // In embedded mode bookmarks are not shown, so if there is an
       
  2258             // error in the url, we make the browser to pop up a
       
  2259             // "Page not found" note, by defining a not existing url.
       
  2260             if ( IsEmbeddedModeOn() )
       
  2261                 {
       
  2262                 params = HBufC8::NewL( 10 );
       
  2263                 params->Des().Copy(_L8("4 http://") );
       
  2264                 }
       
  2265             else
       
  2266                 {
       
  2267                 params = HBufC8::NewL(aDocumentName.Length() + 1 );
       
  2268                 params->Des().Copy(aDocumentName);
       
  2269                 }
       
  2270             params->Des().ZeroTerminate();
       
  2271             ViewToActivate = KUidBrowserBookmarksViewId;
       
  2272             }
       
  2273         }
       
  2274     else
       
  2275         {
       
  2276         params = HBufC8::NewL(aDocumentName.Length() + 1);
       
  2277         params->Des().Copy(aDocumentName);
       
  2278         params->Des().ZeroTerminate();
       
  2279         ViewToActivate = KUidBrowserContentViewId;
       
  2280         }
       
  2281     CleanupStack::PushL( params );
       
  2282 
       
  2283     //Set view to activate if no view yet activated
       
  2284     if ( LastActiveViewId() == KUidBrowserNullViewId )
       
  2285         {
       
  2286         SetLastActiveViewId(ViewToActivate);
       
  2287         }
       
  2288 
       
  2289     CBrowserCommandLineParser8* command = CBrowserCommandLineParser8::NewL( *params );
       
  2290     CleanupStack::PopAndDestroy( params );
       
  2291     CleanupStack::PushL( command );
       
  2292 
       
  2293 
       
  2294     // complete the delayed initialization if bookmarks view is not the first view
       
  2295     if(ViewToActivate != KUidBrowserBookmarksViewId && !iStartedUp)
       
  2296         CompleteDelayedInit();
       
  2297 
       
  2298 	//wait a while, contentview initializing itself
       
  2299     WaitCVInit();
       
  2300     switch ( command->Count() )
       
  2301         {
       
  2302         case 0:
       
  2303             {
       
  2304             SetViewToBeActivatedIfNeededL( LastActiveViewId() );
       
  2305             break;
       
  2306             }
       
  2307         case 1:
       
  2308             {
       
  2309             if ( !aDocumentName.Compare( KLongZeroIdString ) )
       
  2310                 {
       
  2311                 // Long 0 is pressed and Browser is started up for the first time...
       
  2312                 // if no AP or SNAP is defined, define it
       
  2313                 TUint32 defaultAp = iPreferences->DefaultAccessPoint();
       
  2314                 TUint32 defaultSnap =  iPreferences->DefaultSnapId();
       
  2315                 // AP or SNAP is not defined
       
  2316                 if( (defaultAp == KWmlNoDefaultAccessPoint && iPreferences->AccessPointSelectionMode() == EConnectionMethod) || 
       
  2317                     (defaultSnap == KWmlNoDefaultSnapId && iPreferences->AccessPointSelectionMode() == EDestination) )
       
  2318                     {
       
  2319                     StartPreferencesViewL( EShowAlwaysAsk | EShowDestinations | EShowConnectionMethods );
       
  2320                     }
       
  2321                 // If there is a homepage url then try to fetch it
       
  2322                 if ( !NoHomePageToBeLaunchedL() )
       
  2323                     {
       
  2324                     iLongZeroPressed = ETrue;
       
  2325                     FetchHomePageL();
       
  2326                     }
       
  2327                 else  
       
  2328                     {
       
  2329                     if (iStartedUp)
       
  2330                         ContentView()->SetFullScreenOffL();
       
  2331 
       
  2332                     if ( !IsEmbeddedModeOn() )
       
  2333                         {
       
  2334                         SetLastActiveViewId( KUidBrowserBookmarksViewId );
       
  2335                         }
       
  2336                     }
       
  2337                 }
       
  2338             SetViewToBeActivatedIfNeededL( LastActiveViewId() );
       
  2339             break;
       
  2340             }
       
  2341         case 2:
       
  2342         case 3:
       
  2343             {
       
  2344             // UID and wml adress and optional access point UID
       
  2345 
       
  2346             TUint typeId;
       
  2347             TInt dataId;
       
  2348             TLex8 param0( command->Param( 0 ) );
       
  2349             TLex8 param1( command->Param( 1 ) );
       
  2350             err = param0.Val( typeId );
       
  2351             if ( !err )
       
  2352                 {
       
  2353                 BROWSER_LOG( ( _L( " typeId: %d" ), typeId ) );
       
  2354 
       
  2355                 if ( typeId == KUrlId )
       
  2356                     {  // FIX THIS!
       
  2357                     TUriParser8 uri8;
       
  2358                     err = uri8.Parse(command->Param(1));      // what if parsing fails?
       
  2359                     User::LeaveIfError(err);
       
  2360                     // Url decoding section was removed from here.
       
  2361                     HBufC* url = HBufC::NewL(command->Param(1).Length()+1);
       
  2362                     url->Des().Copy( command->Param(1) );
       
  2363                     CleanupStack::PushL(url);
       
  2364                     BROWSER_LOG( ( _L( " url: %S" ), url ) );
       
  2365 
       
  2366                     TFavouritesWapAp accessPoint;   // Initially "default".
       
  2367                     BROWSER_LOG( ( _L( " Count: %d" ), command->Count() ) );
       
  2368                     if ( command->Count() == 3 )
       
  2369                         {
       
  2370                         // URL Typeid, url, ap
       
  2371                         TUint ap;
       
  2372                         TLex8 param2( command->Param( 2 ) );
       
  2373                         err = param2.Val( ap );
       
  2374                         if ( !err )
       
  2375                             {
       
  2376                             BROWSER_LOG( ( _L( " ap: %d" ), ap ) );
       
  2377                             if (iSuppressAlwaysAsk)
       
  2378                                 {
       
  2379                                 // Always ask was temporarily disabled, enable it again
       
  2380                                 iPreferences->SetAccessPointSelectionModeL(EAlwaysAsk);
       
  2381                                 
       
  2382                                 iSuppressAlwaysAsk = EFalse;
       
  2383                                 }
       
  2384 
       
  2385                             // Note: OTA Provisioning application requires the 
       
  2386                             // KBrowserAccessPointSelectionMode key value to be
       
  2387                             // read directly from cenrep, rather than use the
       
  2388                             // cached cenrep value taken at browser initialization 
       
  2389                             // time. 
       
  2390                             TInt selectionMode;
       
  2391 
       
  2392                             CRepository* repository = CRepository::NewLC( KCRUidBrowser );
       
  2393                             User::LeaveIfError( repository->Get( KBrowserAccessPointSelectionMode, selectionMode ) );
       
  2394                             CleanupStack::PopAndDestroy( repository );
       
  2395 
       
  2396                             // If selectionMode cenrep value is always ask, then 
       
  2397                             // temporarily change selection mode
       
  2398                             if ( EBrowserCenRepApSelModeAlwaysAsk == selectionMode )
       
  2399                                 {
       
  2400                                 iSuppressAlwaysAsk = ETrue;
       
  2401                                 iPreferences->SetAccessPointSelectionModeL(EConnectionMethod);
       
  2402                                 }
       
  2403                             accessPoint.SetApId( ap );
       
  2404                             SetCalledFromAnotherApp( ETrue );
       
  2405                             CBrowserLoadObserver::TBrowserLoadUrlType urlType =
       
  2406                                 IsEmbeddedModeOn() ?
       
  2407                                     CBrowserLoadObserver::ELoadUrlTypeEmbeddedBrowserWithUrl :
       
  2408                                     CBrowserLoadObserver::ELoadUrlTypeOther;
       
  2409                             if( IsPageLoaded() &&
       
  2410                             	!(WindowMgr().CurrentWindow()->HasWMLContent(EFalse)) &&
       
  2411             		            Preferences().UiLocalFeatureSupported( KBrowserMultipleWindows ) &&
       
  2412             	                !Preferences().UiLocalFeatureSupported( KBrowserMinimalMultipleWindows ))
       
  2413                                 {
       
  2414                                 // Cancel history view, mini map, toolbar or any other active control on the current window 
       
  2415                                 BrCtlInterface().HandleCommandL( TBrCtlDefs::ECommandCancel + TBrCtlDefs::ECommandIdBase );
       
  2416                                 // there is already a window, so create a new one
       
  2417                                 CBrowserWindow *win = WindowMgr().CreateWindowL( 0, &KNullDesC );
       
  2418                                 if (win != NULL)
       
  2419                                     {
       
  2420                                         
       
  2421                                     CleanupStack::PushL( win );
       
  2422                                     WindowMgr().SwitchWindowL( win->WindowId() );
       
  2423                                     TRAP( err, FetchL(  *url,
       
  2424                                                                 KNullDesC,
       
  2425                                                                 KNullDesC,
       
  2426                                                                 accessPoint,
       
  2427                                                                 urlType ) );
       
  2428                                     CleanupStack::Pop();  // win
       
  2429                                     SetLastActiveViewId( KUidBrowserContentViewId );
       
  2430                                     }
       
  2431                                 }                          
       
  2432                             else
       
  2433                                 {
       
  2434                                 // Cancel history view, mini map, toolbar or any other active control on the current window
       
  2435                                 if (iStartedUp)
       
  2436                                     BrCtlInterface().HandleCommandL( TBrCtlDefs::ECommandCancel + TBrCtlDefs::ECommandIdBase );
       
  2437                                 TRAP( err, FetchL(  *url,
       
  2438                                                             KNullDesC,
       
  2439                                                             KNullDesC,
       
  2440                                                             accessPoint,
       
  2441                                                             urlType ) );                                
       
  2442                                 SetLastActiveViewId( KUidBrowserContentViewId );                                
       
  2443                                 }                        
       
  2444                             }
       
  2445                         }
       
  2446                     else
       
  2447                         {
       
  2448                         // URL Typeid, url
       
  2449                         SetCalledFromAnotherApp( ETrue );
       
  2450 
       
  2451                         if ( aDoFetch )
       
  2452                             {
       
  2453                             CBrowserLoadObserver::TBrowserLoadUrlType urlType =
       
  2454                                 IsEmbeddedModeOn() ?
       
  2455                                     CBrowserLoadObserver::ELoadUrlTypeEmbeddedBrowserWithUrl :
       
  2456                                     CBrowserLoadObserver::ELoadUrlTypeOther;
       
  2457                             if( IsPageLoaded() &&
       
  2458                             	!(WindowMgr().CurrentWindow()->HasWMLContent(EFalse)) &&                            
       
  2459                         		Preferences().UiLocalFeatureSupported( KBrowserMultipleWindows ) &&
       
  2460                             	!Preferences().UiLocalFeatureSupported( KBrowserMinimalMultipleWindows ))
       
  2461                                 {
       
  2462                                 // Cancel history view, mini map, toolbar or any other active control on the current window 
       
  2463                                 BrCtlInterface().HandleCommandL( TBrCtlDefs::ECommandCancel + TBrCtlDefs::ECommandIdBase );
       
  2464                                 // there is already a window, so create a new one
       
  2465                                 CBrowserWindow *win = NULL; 
       
  2466                                 if(WindowMgr().CurrentWindow()) 
       
  2467                                 {
       
  2468                                     if(iSameWinApp)
       
  2469                                     {
       
  2470                                         //We will be using same/already opened window if call is from external
       
  2471                                         //application. So no new windows will be opened.
       
  2472                                         win = WindowMgr().CurrentWindow();
       
  2473                                         iWindowIdFromFromExternApp = win->WindowId();
       
  2474                                     }
       
  2475                                     if(!win)
       
  2476                                     {
       
  2477                                         //If not called from external app, then create window.
       
  2478                                         win = WindowMgr().CreateWindowL( (WindowMgr().CurrentWindow()->WindowId()) ? WindowMgr().CurrentWindow()->WindowId() : 0, &KNullDesC );
       
  2479                                     }
       
  2480                                 }
       
  2481                                 else
       
  2482                                     win = WindowMgr().CreateWindowL( 0, &KNullDesC );
       
  2483                                 if (win != NULL)
       
  2484                                     {
       
  2485                                         
       
  2486                                     CleanupStack::PushL( win );
       
  2487                                     WindowMgr().SwitchWindowL( win->WindowId() );
       
  2488                                     TRAP( err, FetchL(  *url,
       
  2489                                                                 KNullDesC,
       
  2490                                                                 KNullDesC,
       
  2491                                                                 accessPoint,
       
  2492                                                                 urlType ) );
       
  2493                                     CleanupStack::Pop();  // win
       
  2494                                     }
       
  2495                             }
       
  2496                             else
       
  2497                                 {
       
  2498                                 // Cancel history view, mini map, toolbar or any other active control on the current window
       
  2499                                 if (iStartedUp)
       
  2500                                     BrCtlInterface().HandleCommandL( TBrCtlDefs::ECommandCancel + TBrCtlDefs::ECommandIdBase );
       
  2501                                 TRAP( err, FetchL(  *url,
       
  2502                                                             KNullDesC,
       
  2503                                                             KNullDesC,
       
  2504                                                             accessPoint,
       
  2505                                                             urlType ) );
       
  2506                                 }
       
  2507                             }          
       
  2508                     if (err==KErrNone)
       
  2509                         {
       
  2510                         SetLastActiveViewId(ViewToActivate);
       
  2511                         }
       
  2512                         }
       
  2513                     CleanupStack::PopAndDestroy();  // url
       
  2514                     }
       
  2515                 else if( typeId == KLaunchFeeds )
       
  2516                     {
       
  2517                     // Special facility to launch non-embedded into the feeds view
       
  2518                     if( !iBrowserAlreadyRunning )
       
  2519                     	{
       
  2520                     	SetOverriddenLaunchContextId(EBrowserContextIdFeeds);
       
  2521                     	SetLastActiveViewId( KUidBrowserFeedsFolderViewId );                    	
       
  2522                     	}	
       
  2523                     LaunchIntoFeedsL();          	
       
  2524                     }         
       
  2525                 else
       
  2526                     {
       
  2527                     err = param1.Val( dataId );
       
  2528                     if ( !err )
       
  2529                         {
       
  2530                         switch ( typeId )
       
  2531                             {
       
  2532                             case KBookmarkId:
       
  2533                                 {
       
  2534                                 // Bookmark typeid, uid
       
  2535                                 SetCalledFromAnotherApp( ETrue );
       
  2536 								
       
  2537 	                            if( IsPageLoaded() &&
       
  2538                                	!(WindowMgr().CurrentWindow()->HasWMLContent(EFalse)) &&
       
  2539                         		Preferences().UiLocalFeatureSupported( KBrowserMultipleWindows ) &&
       
  2540                             	!Preferences().UiLocalFeatureSupported( KBrowserMinimalMultipleWindows ))
       
  2541 	                                {
       
  2542 	   	                            // Cancel history view, mini map, toolbar or any other active control on the current window 
       
  2543 	                                BrCtlInterface().HandleCommandL( TBrCtlDefs::ECommandCancel + TBrCtlDefs::ECommandIdBase );
       
  2544 	                                // there is already a window, so create a new one
       
  2545 	                                CBrowserWindow *win = WindowMgr().CreateWindowL( 0, &KNullDesC );
       
  2546 	                                if (win != NULL)
       
  2547     	                                {
       
  2548     	                                CleanupStack::PushL( win );
       
  2549     	                                WindowMgr().SwitchWindowL( win->WindowId() );
       
  2550     	                            	TRAP( err, FetchBookmarkL( dataId ) );
       
  2551     	                                CleanupStack::Pop();  // win                                
       
  2552     	                                }
       
  2553 	                                }
       
  2554 	                            else
       
  2555 	                            	{
       
  2556     	                            // Cancel history view, mini map, toolbar or any other active control on the current window
       
  2557                                     if (iStartedUp)
       
  2558                                         BrCtlInterface().HandleCommandL( TBrCtlDefs::ECommandCancel + TBrCtlDefs::ECommandIdBase );
       
  2559 	                            	TRAP( err, FetchBookmarkL( dataId ) );
       
  2560 	                            	}    
       
  2561 
       
  2562                                 if ( err )
       
  2563                                     {
       
  2564                                     // Unable to fetch bookmark
       
  2565                                     TBrowserDialogs::InfoNoteL(
       
  2566                                         R_BROWSER_INFO_NOTE, R_WML_UNABLE_TO_FETCH_BOOKMARK );
       
  2567                                     }
       
  2568 	                            if (err==KErrNone)
       
  2569     			                    {
       
  2570                 			        SetLastActiveViewId(ViewToActivate);
       
  2571                         			}
       
  2572 
       
  2573                                 break;
       
  2574                                 }
       
  2575                             case KFolderId:
       
  2576                                 {
       
  2577                                 SetCalledFromAnotherApp( EFalse );
       
  2578                                 iIsForeground = IsForeground();
       
  2579                                 CloseContentViewL();
       
  2580                                 SetLastActiveViewId( KUidBrowserBookmarksViewId );
       
  2581                                 break;
       
  2582                                 }
       
  2583                             default:
       
  2584                                 {
       
  2585                                 // Typeid was not readable
       
  2586                                 // TBD: error message!
       
  2587                                 break;
       
  2588                                 }
       
  2589                             }
       
  2590                         }
       
  2591                     else
       
  2592                         {
       
  2593                         // Dataid was not readable
       
  2594                         User::Leave( err );
       
  2595                         }
       
  2596                     }
       
  2597                 }
       
  2598             else
       
  2599                 {
       
  2600                 // Sender Uid was not readable
       
  2601                 User::Leave( err );
       
  2602                 }
       
  2603             if( !iSpecialSchemeinAddress )
       
  2604             	{              
       
  2605             	SetViewToBeActivatedIfNeededL( LastActiveViewId() );
       
  2606             	}
       
  2607             break;
       
  2608             }
       
  2609 
       
  2610         default:
       
  2611             {
       
  2612             SendBrowserToBackground();
       
  2613             break;
       
  2614             }
       
  2615         }
       
  2616         CleanupStack::PopAndDestroy();  // command
       
  2617     }
       
  2618 
       
  2619 // -----------------------------------------------------------------------------
       
  2620 // CBrowserAppUi::WaitCVInit
       
  2621 // -----------------------------------------------------------------------------
       
  2622 //
       
  2623 void CBrowserAppUi::WaitCVInit()
       
  2624     {
       
  2625     if( iParametrizedLaunchInProgress == 0 && iStartedUp)
       
  2626         {
       
  2627         iParametrizedLaunchInProgress = 1;
       
  2628         iIdle->Cancel();
       
  2629         iIdle->Start( TCallBack( StopDelay, this ) );
       
  2630         iWait.Start();
       
  2631         iParametrizedLaunchInProgress = 2;
       
  2632         }
       
  2633     }
       
  2634 void CBrowserAppUi::StopConnectionObserving()
       
  2635     {
       
  2636     LOG_ENTERFN("CBrowserAppUi::StopConnectionObserving");
       
  2637     if ( iConnStageNotifier && iConnStageNotifier->IsActive() )
       
  2638         {
       
  2639         BROWSER_LOG( ( _L( " CBrowserAppUi::StopConnectionObserving Cancelling Observer" ) ) );
       
  2640         iConnStageNotifier->Cancel();
       
  2641         }
       
  2642     }
       
  2643 
       
  2644 // -----------------------------------------------------------------------------
       
  2645 // CBrowserAppUi::ConnNeededStatusL
       
  2646 // -----------------------------------------------------------------------------
       
  2647 //
       
  2648 void CBrowserAppUi::ConnNeededStatusL( TInt aErr )
       
  2649     {
       
  2650     LOG_ENTERFN("CBrowserAppUi::ConnNeededStatusL");
       
  2651     UpdateSoftKeys();
       
  2652     if (iSuppressAlwaysAsk)
       
  2653         {
       
  2654         // Always ask was temporarily disabled, after creating the network connection, enable it again
       
  2655         iPreferences->SetAccessPointSelectionModeL(EAlwaysAsk);
       
  2656         iSuppressAlwaysAsk = EFalse;
       
  2657         }
       
  2658     if ( aErr != KErrNone )
       
  2659         {
       
  2660         if( iCalledFromAnotherApp )
       
  2661             {
       
  2662             // This function call should be replaced by ExitBrowser(ETrue)
       
  2663             // so that the blank content view is not displayed.
       
  2664             // SendBrowserToBackground();
       
  2665             }
       
  2666         // if any error, return Cancel to Kimono.
       
  2667         return;
       
  2668         }
       
  2669 
       
  2670     BROWSER_LOG( ( _L( " CBrowserAppUi::ConnNeededStatusL First Stop Connection Observer" ) ) );
       
  2671     StopConnectionObserving(); //Need to stop the connection observer first
       
  2672 
       
  2673 
       
  2674     if ( !iConnStageNotifier->IsActive() )
       
  2675         {
       
  2676         BROWSER_LOG( ( _L( " CBrowserAppUi::ConnNeededStatusL Starting Connection Observer" ) ) );
       
  2677         TName* connectionName = Connection().ConnectionNameL();
       
  2678         CleanupStack::PushL( connectionName );
       
  2679 
       
  2680         iConnStageNotifier->StartNotificationL(connectionName, KLinkLayerClosed, this);
       
  2681 
       
  2682         CleanupStack::PopAndDestroy();  //connectionName
       
  2683         }
       
  2684     }
       
  2685 
       
  2686 
       
  2687 // -----------------------------------------------------------------------------
       
  2688 // CBrowserAppUi::SendBrowserToBackground
       
  2689 // -----------------------------------------------------------------------------
       
  2690 //
       
  2691 void CBrowserAppUi::SendBrowserToBackground()
       
  2692     {
       
  2693     TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
       
  2694 
       
  2695     // Browser might be embedded. 
       
  2696     TUid appUid;
       
  2697     if ( iEmbeddingApplicationUid != KNullUid )
       
  2698         {
       
  2699         appUid = iEmbeddingApplicationUid;
       
  2700         }
       
  2701     else 
       
  2702         {
       
  2703         appUid = KUidBrowserApplication;
       
  2704         }
       
  2705     TApaTask task = taskList.FindApp( appUid );
       
  2706     task.SendToBackground();
       
  2707     }
       
  2708 
       
  2709 
       
  2710 // -----------------------------------------------------------------------------
       
  2711 // CBrowserAppUi::CreateWindowInfoLC()
       
  2712 // -----------------------------------------------------------------------------
       
  2713 //
       
  2714 HBufC* CBrowserAppUi::CreateWindowInfoLC( const CBrowserWindow& aWindow )
       
  2715     {
       
  2716     HBufC* buf = aWindow.BrCtlInterface().PageInfoLC( TBrCtlDefs::EPageInfoTitle );
       
  2717     if( !buf || !buf->Length() )
       
  2718         {
       
  2719         CleanupStack::PopAndDestroy( buf );
       
  2720         buf = aWindow.BrCtlInterface().PageInfoLC( TBrCtlDefs::EPageInfoUrl );
       
  2721         if( !buf )
       
  2722             {
       
  2723 
       
  2724             CleanupStack::PopAndDestroy( buf );
       
  2725             buf = KNullDesC().AllocLC();
       
  2726             }
       
  2727         }
       
  2728     return buf;
       
  2729     }
       
  2730 	
       
  2731 #ifdef BRDO_OCC_ENABLED_FF
       
  2732 // -----------------------------------------------------------------------------
       
  2733 // CBrowserContentView::SetRetryFlag
       
  2734 // -----------------------------------------------------------------------------
       
  2735 //
       
  2736 void CBrowserAppUi::SetRetryFlag(TBool flag)
       
  2737      {
       
  2738      LOG_ENTERFN("CBrowserAppUi::SetRetryFlag");
       
  2739      BROWSER_LOG( ( _L(" CBrowserAppUi::SetRetryFlag flag: %d"), flag ) );
       
  2740      reConnectivityFlag = flag;
       
  2741      }
       
  2742 
       
  2743 // -----------------------------------------------------------------------------
       
  2744 // CBrowserContentView::GetRetryFlag
       
  2745 // -----------------------------------------------------------------------------
       
  2746 //
       
  2747  TBool CBrowserAppUi::GetRetryFlag()
       
  2748       {
       
  2749       LOG_ENTERFN("CBrowserAppUi::GetRetryFlag");
       
  2750       BROWSER_LOG( ( _L(" CBrowserAppUi::GetRetryFlag flag: %d"), reConnectivityFlag ) );
       
  2751       return reConnectivityFlag;
       
  2752       }
       
  2753 	  
       
  2754 // -----------------------------------------------------------------------------
       
  2755 // CBrowserContentView::RetryConnectivity
       
  2756 // -----------------------------------------------------------------------------
       
  2757 //
       
  2758 TInt CBrowserAppUi::RetryConnectivity(TAny* aCBrowserAppUi)
       
  2759     {
       
  2760     LOG_ENTERFN("CBrowserAppUi::RetryConnectivity");
       
  2761     __ASSERT_DEBUG(aCBrowserAppUi, Util::Panic( Util::EUninitializedData ));
       
  2762   
       
  2763     TInt err = ((CBrowserAppUi*)aCBrowserAppUi)->RetryInternetConnection();
       
  2764     
       
  2765     BROWSER_LOG( ( _L(" CBrowserAppUi::RetryConnectivity Error: %d"), err ) );
       
  2766     return err;
       
  2767     }
       
  2768 	
       
  2769 TInt CBrowserAppUi::RetryInternetConnection()
       
  2770     {
       
  2771     LOG_ENTERFN("CBrowserAppUi::RetryInternetConnection");
       
  2772     //First cancel the timer
       
  2773     if ( iRetryConnectivity && iRetryConnectivity->IsActive() )
       
  2774     {
       
  2775         iRetryConnectivity->Cancel();
       
  2776         BROWSER_LOG( ( _L( "CBrowserAppUi::RetryInternetConnection Timer Cancelled successfully " ) ) );
       
  2777     }
       
  2778     TInt err = KErrNone;
       
  2779     if ( !iConnection->Connected() )
       
  2780        {
       
  2781        TRAP_IGNORE( err = iConnection->StartConnectionL( ETrue ) );
       
  2782        }
       
  2783     if( err == KErrNone )
       
  2784        { 
       
  2785        BROWSER_LOG( ( _L( "CBrowserAppUi::RetryInternetConnection Connection restablished successfully " ) ) );
       
  2786        
       
  2787        BROWSER_LOG( ( _L( "CBrowserAppUi::RetryInternetConnection UNSET retry flags " ) ) );
       
  2788        TRAP_IGNORE( BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandUnSetRetryConnectivityFlag + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  2789        SetRetryFlag(EFalse);
       
  2790        
       
  2791        TRAP_IGNORE(ConnNeededStatusL(err)); //Start the observer again
       
  2792        TRAP_IGNORE( BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandRetryTransactions + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  2793        //Let download manager knows about this new connection
       
  2794        TRAP_IGNORE( BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandConnToDownloadManager + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  2795        }
       
  2796     else
       
  2797         {
       
  2798         BROWSER_LOG( ( _L( "CBrowserAppUi::RetryInternetConnection Connection failed " ) ) );
       
  2799         BROWSER_LOG( ( _L( "CBrowserAppUi::RetryInternetConnection unset retry flags " ) ) );
       
  2800         TRAP_IGNORE( BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandUnSetRetryConnectivityFlag + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  2801         SetRetryFlag(EFalse);
       
  2802         BROWSER_LOG( ( _L( "CBrowserAppUi::RetryInternetConnection clear queued transactions " ) ) );
       
  2803         TRAP_IGNORE( BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandClearQuedTransactions + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  2804         Display().StopProgressAnimationL(); //Stop Progress animation
       
  2805         if ( Fetching() )
       
  2806             {
       
  2807             BROWSER_LOG( ( _L( "CBrowserAppUi::RetryInternetConnection cancel fetch " ) ) );
       
  2808             CancelFetch();
       
  2809             }
       
  2810         iDialogsProvider->UploadProgressNoteL(0, 0, ETrue, (MBrowserDialogsProviderObserver *)this ); //Close the uploading dialog.
       
  2811         iDialogsProvider->CancelAll(); //connection has been lost, so cancel the authentication dialog.
       
  2812         }
       
  2813     
       
  2814     return err;
       
  2815     }
       
  2816 
       
  2817 void CBrowserAppUi::CheckOccConnectionStage()
       
  2818     {
       
  2819     LOG_ENTERFN("CBrowserAppUi::CheckOccConnectionStage");
       
  2820     
       
  2821     //Disconnect first
       
  2822     BROWSER_LOG( ( _L( "CBrowserAppUi::CheckOccConnectionStage Disconnecting..." ) ) );
       
  2823     iConnection->Disconnect();
       
  2824     
       
  2825     TNifProgressBuf buf = iConnStageNotifier->GetProgressBuffer();
       
  2826     if( buf().iError == KErrDisconnected )
       
  2827         {
       
  2828         BROWSER_LOG( ( _L("CBrowserAppUi::CheckOccConnectionStage This is OCC roaming error : %d"), buf().iError ) );
       
  2829         BROWSER_LOG( ( _L( "CBrowserAppUi::CheckOccConnectionStage Set retry flags " ) ) );
       
  2830         TRAP_IGNORE( BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandSetRetryConnectivityFlag + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  2831         SetRetryFlag(ETrue);    
       
  2832         TRAP_IGNORE( BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandCancelQueuedTransactions + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  2833         
       
  2834         if( iRetryConnectivity && iRetryConnectivity->IsActive())
       
  2835             {
       
  2836             iRetryConnectivity->Cancel();
       
  2837             }
       
  2838         iRetryConnectivity->Start(KRetryConnectivityTimeout, 0,TCallBack(RetryConnectivity,this));
       
  2839         }
       
  2840     else
       
  2841         {
       
  2842         BROWSER_LOG( ( _L("CBrowserAppUi::CheckOccConnectionStage This is NOT OCC roaming error : %d"), buf().iError ) );
       
  2843         Display().StopProgressAnimationL();
       
  2844         if ( Fetching() )
       
  2845             {
       
  2846             CancelFetch();
       
  2847             }
       
  2848         iDialogsProvider->UploadProgressNoteL(0, 0, ETrue, (MBrowserDialogsProviderObserver *)this );
       
  2849         iDialogsProvider->CancelAll();
       
  2850         }  
       
  2851     }
       
  2852 #endif
       
  2853 
       
  2854 // -----------------------------------------------------------------------------
       
  2855 // CBrowserAppUi::ConnectionStageAchievedL()
       
  2856 // -----------------------------------------------------------------------------
       
  2857 //
       
  2858 void CBrowserAppUi::ConnectionStageAchievedL()
       
  2859     {
       
  2860 #ifdef BRDO_OCC_ENABLED_FF
       
  2861     LOG_ENTERFN("CBrowserAppUi::ConnectionStageAchievedL");
       
  2862     CheckOccConnectionStage();
       
  2863 #else
       
  2864     // this function is called only when network is lost
       
  2865     // because we set notifier for KAgentUnconnected only
       
  2866     Display().StopProgressAnimationL();
       
  2867 	if ( Fetching() )
       
  2868 		{
       
  2869                  CancelFetch();
       
  2870 		}
       
  2871     //Close the uploading dialog.
       
  2872     iDialogsProvider->UploadProgressNoteL(
       
  2873 	                0, 0, ETrue, (MBrowserDialogsProviderObserver *)this );
       
  2874     //connection has been lost, so cancel the authentication dialog.
       
  2875     iDialogsProvider->CancelAll();
       
  2876     // SendDisconnectEventL();
       
  2877     // not needed as by that point HTTPSession was already shutdown by executing disconnect menu option
       
  2878     // will cause a crash when user tries to quickly reconnect right after disconnecting, as HTTP session
       
  2879     // is starting to initialize, while this call is trying to close it.
       
  2880 #endif
       
  2881     }
       
  2882 
       
  2883 
       
  2884 // -----------------------------------------------------------------------------
       
  2885 // CBrowserAppUi::UpdateSoftKeys
       
  2886 // -----------------------------------------------------------------------------
       
  2887 //
       
  2888 void CBrowserAppUi::UpdateSoftKeys()
       
  2889     {
       
  2890 	TRAP_IGNORE( UpdateCbaL() );
       
  2891     }
       
  2892 
       
  2893 // -----------------------------------------------------------------------------
       
  2894 // CBrowserAppUi::DeleteCookiesL
       
  2895 // -----------------------------------------------------------------------------
       
  2896 //
       
  2897 void CBrowserAppUi::DeleteCookiesL()
       
  2898     {
       
  2899     // stringPool is not needed to initialize
       
  2900     RStringPool stringPool;
       
  2901     RCookieManager cookieManager( stringPool );
       
  2902     TInt num(0);
       
  2903 
       
  2904     User::LeaveIfError( cookieManager.Connect() );
       
  2905     CleanupClosePushL( cookieManager );
       
  2906     User::LeaveIfError( cookieManager.ClearCookies( num ) );
       
  2907     CleanupStack::PopAndDestroy( &cookieManager );
       
  2908 
       
  2909     stringPool.Close();
       
  2910     }
       
  2911 
       
  2912 // -----------------------------------------------------------------------------
       
  2913 // CBrowserAppUi::LaunchHomePageL
       
  2914 // -----------------------------------------------------------------------------
       
  2915 //
       
  2916 void CBrowserAppUi::LaunchHomePageL()
       
  2917     {
       
  2918     LOG_ENTERFN( "CBrowserAppUi::LaunchHomePageL" );
       
  2919     TWmlSettingsHomePage pgtype = iPreferences->HomePageType();
       
  2920     TBool alwaysAskCase = (( Preferences().AccessPointSelectionMode() == EAlwaysAsk ) &&
       
  2921                            ( EWmlSettingsHomePageAccessPoint == pgtype ));
       
  2922     BROWSER_LOG( ( _L( "pgtype: %d, alwaysAsk: %d" ), pgtype, alwaysAskCase ) );
       
  2923 
       
  2924     if( ( pgtype == EWmlSettingsHomePageBookmarks ) || alwaysAskCase )
       
  2925         // Bookmarks is selected as HomePage
       
  2926         // has effect only for startup, otherwise 'Home' command is not shown
       
  2927         {
       
  2928         ContentView()->SetFullScreenOffL();
       
  2929         // view change will be done somewhere else
       
  2930         SetLastActiveViewId( KUidBrowserBookmarksViewId );
       
  2931         SetViewToBeActivatedIfNeededL( LastActiveViewId() );
       
  2932         return;
       
  2933         }
       
  2934 
       
  2935     HBufC* buf = HBufC::NewLC( KMaxHomePgUrlLength );  // cleanupstack
       
  2936     TPtr ptr( buf->Des() );
       
  2937     TInt pgFound( KErrNotFound );
       
  2938 
       
  2939     pgFound = Preferences().HomePageUrlL( ptr );
       
  2940     BROWSER_LOG( ( _L( "pgFound 1: %d" ), pgFound ) );
       
  2941 
       
  2942 
       
  2943     if( pgFound == KErrNone )     // Home page url found, fetch the url
       
  2944         {
       
  2945         SetLastActiveViewId( KUidBrowserContentViewId );
       
  2946         FetchL( ptr );
       
  2947         }
       
  2948     else  // Home page not found, or not defined, go to BookMarksView
       
  2949         {
       
  2950         TVwsViewId activeViewId;
       
  2951         if( ( GetActiveViewId( activeViewId ) != KErrNone ) ||
       
  2952             ( activeViewId.iViewUid == KUidBrowserContentViewId ) )
       
  2953             {
       
  2954             ContentView()->SetFullScreenOffL();
       
  2955             }
       
  2956         SetLastActiveViewId( KUidBrowserBookmarksViewId );
       
  2957         SetViewToBeActivatedIfNeededL( LastActiveViewId() );
       
  2958         }
       
  2959     CleanupStack::PopAndDestroy( buf );
       
  2960     }
       
  2961 
       
  2962 // -----------------------------------------------------------------------------
       
  2963 // CBrowserAppUi::ClearTheCacheL
       
  2964 // -----------------------------------------------------------------------------
       
  2965 //
       
  2966 void CBrowserAppUi::ClearTheCacheL(TBool afterQuery, TBool aShowDoneNote)
       
  2967     {
       
  2968     TUint32 totalBytesFlushed = BrCtlInterface().ClearCache();
       
  2969         if(afterQuery || totalBytesFlushed)
       
  2970     	{
       
  2971 
       
  2972     	HBufC* resultText = NULL;
       
  2973     	HBufC* tempText = NULL;
       
  2974     	TBuf<12> totalText;
       
  2975 
       
  2976     	totalText.Num ((TInt)totalBytesFlushed);
       
  2977 
       
  2978     	resultText = StringLoader::LoadLC( R_TEXT_WML_CACHE_EMPTIED_NOTE);
       
  2979     	//CleanupStack::PushL(resultText);
       
  2980     	tempText = HBufC::NewLC( resultText->Length() + totalText.Length() );
       
  2981     	//CleanupStack::PushL(tempText);
       
  2982 
       
  2983     	tempText->Des().AppendFormat( resultText->Des(), totalBytesFlushed );
       
  2984 
       
  2985 
       
  2986 
       
  2987     	if(aShowDoneNote)
       
  2988     	    {
       
  2989     	    TBrowserDialogs::InfoNoteL ( R_BROWSER_OK_NOTE, tempText->Des() );
       
  2990     	    }
       
  2991      	CleanupStack::PopAndDestroy(2); //resultText, tempText
       
  2992     	}
       
  2993     }
       
  2994 
       
  2995 // ---------------------------------------------------------
       
  2996 // CBrowserAppUi::ClearFormAndPasswdDataL
       
  2997 // ---------------------------------------------------------
       
  2998 //
       
  2999 void CBrowserAppUi::ClearFormAndPasswdDataL(TBool aShowPromptAndComplete)
       
  3000     {
       
  3001     if (aShowPromptAndComplete)
       
  3002         {
       
  3003         CAknQueryDialog* query = CAknQueryDialog::NewL();
       
  3004 	    if ( query->ExecuteLD( R_BROWSER_CLEARFORMPASSWDDATA_QUERY ) )
       
  3005             {
       
  3006             // call brctl to clear form and password data
       
  3007             BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandClearAutoFormFillData +
       
  3008     		       						     (TInt)TBrCtlDefs::ECommandIdBase );
       
  3009 
       
  3010             BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandClearAutoFormFillPasswordData +
       
  3011      		 								 (TInt)TBrCtlDefs::ECommandIdBase );
       
  3012 
       
  3013             TBrowserDialogs::InfoNoteL(
       
  3014                 R_BROWSER_OK_NOTE, R_QTN_BROWSER_NOTE_FORM_AND_PASSWD_DATA_CLEARED );
       
  3015             }
       
  3016 
       
  3017         }
       
  3018     else
       
  3019         {
       
  3020             // call brctl to clear form and password data
       
  3021             BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandClearAutoFormFillData +
       
  3022     		       						     (TInt)TBrCtlDefs::ECommandIdBase );
       
  3023 
       
  3024             BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandClearAutoFormFillPasswordData +
       
  3025      		 								 (TInt)TBrCtlDefs::ECommandIdBase );
       
  3026 
       
  3027         }
       
  3028     }
       
  3029 
       
  3030 
       
  3031 // ---------------------------------------------------------
       
  3032 // CBrowserAppUi::ClearHistoryWithPromptL
       
  3033 // ---------------------------------------------------------
       
  3034 //
       
  3035 void CBrowserAppUi::ClearHistoryWithPromptL()
       
  3036     {
       
  3037     CAknQueryDialog* query = CAknQueryDialog::NewL();
       
  3038 
       
  3039     if ( query->ExecuteLD( R_BROWSER_CLEARHISTORYDATA_QUERY ) )
       
  3040         {
       
  3041         ClearHistoryL();
       
  3042         TBrowserDialogs::InfoNoteL( R_BROWSER_OK_NOTE,
       
  3043                     R_QTN_BROWSER_NOTE_HISTORY_CLEARED );
       
  3044         }
       
  3045     }
       
  3046 
       
  3047 // ---------------------------------------------------------
       
  3048 // CBrowserAppUi::ClearHistoryL
       
  3049 // ---------------------------------------------------------
       
  3050 //
       
  3051 void CBrowserAppUi::ClearHistoryL()
       
  3052     {
       
  3053     if (iWindowManager)
       
  3054         {
       
  3055         iWindowManager->SendCommandToAllWindowsL(
       
  3056         (TInt)TBrCtlDefs::ECommandClearHistory + (TInt)TBrCtlDefs::ECommandIdBase);
       
  3057         }
       
  3058 
       
  3059     if (!(Preferences().AdaptiveBookmarks()==EWmlSettingsAdaptiveBookmarksOff ))
       
  3060         {
       
  3061         // This call will ensure that the bookmarks are cleared when we are
       
  3062         // outside the bookmarksview since the next call doesn't do anything in
       
  3063         // that case due to the unset Container pointer.
       
  3064 		iRecentUrlStore->ClearData();
       
  3065 
       
  3066         // Below will serve for when we are called from BookmarksView to ensure
       
  3067         // thorough clearing and view refresh after clearing adapt bookmarks
       
  3068         iBookmarksView->HandleCommandL(EWmlCmdClearAdaptiveBookmarksNoPrompt);
       
  3069         }
       
  3070 
       
  3071     UpdateCbaL();
       
  3072 
       
  3073     }
       
  3074 
       
  3075 // ---------------------------------------------------------
       
  3076 // CBrowserAppUi::ClearAllPrivacyL
       
  3077 // ---------------------------------------------------------
       
  3078 //
       
  3079 void CBrowserAppUi::ClearAllPrivacyL()
       
  3080     {
       
  3081 
       
  3082     CAknQueryDialog* query = CAknQueryDialog::NewL();
       
  3083 	if ( query->ExecuteLD( R_BROWSER_CLEARPRIVACYDATA_QUERY ) )
       
  3084         {
       
  3085         ClearTheCacheL(EFalse, EFalse);     // false -> no prompt or info note after op
       
  3086         DeleteCookiesL();
       
  3087         ClearHistoryL();
       
  3088         ClearFormAndPasswdDataL(EFalse);    // no prompt or completed info note
       
  3089 
       
  3090         TBrowserDialogs::InfoNoteL(
       
  3091             R_BROWSER_OK_NOTE, R_QTN_BROWSER_NOTE_CLEAR_ALL_PRIVACY_DONE );
       
  3092         }
       
  3093     }
       
  3094 
       
  3095 
       
  3096 // -----------------------------------------------------------------------------
       
  3097 // CBrowserAppUi::DisconnectL
       
  3098 // -----------------------------------------------------------------------------
       
  3099 //
       
  3100 void CBrowserAppUi::DisconnectL()
       
  3101     {
       
  3102 //#pragma message("TODO: inform LoadObserver?")
       
  3103     SendDisconnectEventL();
       
  3104     Connection().Disconnect();
       
  3105 
       
  3106 #ifdef __RSS_FEEDS
       
  3107     iFeedsClientUtilities->DisconnectFeedsViewL();
       
  3108     //notify feeds engine to close the connection
       
  3109 	iFeedsClientUtilities->DisconnectManualUpdateConnectionL();
       
  3110 #endif
       
  3111     }
       
  3112 
       
  3113 
       
  3114 // -----------------------------------------------------------------------------
       
  3115 // CBrowserAppUi::BmOTABinSenderL()
       
  3116 // -----------------------------------------------------------------------------
       
  3117 //
       
  3118 MBmOTABinSender& CBrowserAppUi::BmOTABinSenderL()
       
  3119     {
       
  3120     if (!iSender)
       
  3121     	{
       
  3122 		iLateSendUi->Cancel();
       
  3123     	DoConstructSendUiL();
       
  3124     	}
       
  3125     return *iSender;
       
  3126     }
       
  3127 
       
  3128 
       
  3129 // -----------------------------------------------------------------------------
       
  3130 // CBrowserAppUi::ContentView()
       
  3131 // -----------------------------------------------------------------------------
       
  3132 //
       
  3133 CBrowserContentView* CBrowserAppUi::ContentView() const
       
  3134     {
       
  3135     return (CBrowserContentView*)View( KUidBrowserContentViewId );
       
  3136     }
       
  3137 
       
  3138 
       
  3139 // -----------------------------------------------------------------------------
       
  3140 // CBrowserAppUi::FetchL
       
  3141 // -----------------------------------------------------------------------------
       
  3142 //
       
  3143 void CBrowserAppUi::FetchL( const TDesC& aUrl, CBrowserLoadObserver::TBrowserLoadUrlType aUrlType )
       
  3144     {
       
  3145     TFavouritesWapAp ap;
       
  3146     ap.SetDefault();
       
  3147     FetchL( aUrl, KNullDesC, KNullDesC, ap, aUrlType );
       
  3148     }
       
  3149 
       
  3150 // TO DO: done by BaP
       
  3151 // -----------------------------------------------------------------------------
       
  3152 // CBrowserAppUi::CancelFetch
       
  3153 // -----------------------------------------------------------------------------
       
  3154 //
       
  3155 void CBrowserAppUi::CancelFetch( TBool aIsUserInitiated /*= EFalse*/ )
       
  3156     {
       
  3157     LoadObserver().DoEndLoad( aIsUserInitiated );
       
  3158     TRAP_IGNORE( BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandCancelFetch + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  3159     SetContentDisplayed(ETrue);
       
  3160     }
       
  3161 
       
  3162 
       
  3163 // ----------------------------------------------------------------------------------------
       
  3164 // CBrowserAppUi::HandleMessageL
       
  3165 //
       
  3166 // Changes the URL to another if WAP is running before Wap Url
       
  3167 // is started from Desk
       
  3168 // ----------------------------------------------------------------------------------------
       
  3169 //
       
  3170 MCoeMessageObserver::TMessageResponse CBrowserAppUi::HandleMessageL(
       
  3171 																	TUint32 aClientHandleOfTargetWindowGroup,
       
  3172 																	TUid aMessageUid,
       
  3173 																	const TDesC8& aMessageParameters )
       
  3174     {
       
  3175     iBrowserAlreadyRunning = ETrue;
       
  3176     TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
       
  3177     TUid wapUid = KUidBrowserApplication;
       
  3178     TApaTask task = taskList.FindApp( wapUid );
       
  3179     task.BringToForeground();
       
  3180     //Check for aMessageUid. If it is in array then set iSameWinApp = ETrue
       
  3181     iSameWinApp = IsSameWinApp(aMessageUid); 
       
  3182     if ( aMessageParameters.Compare( KLongZeroIdString ) )
       
  3183         {
       
  3184         ParseAndProcessParametersL( aMessageParameters );
       
  3185         }
       
  3186     return CAknViewAppUi::HandleMessageL(
       
  3187 		aClientHandleOfTargetWindowGroup,
       
  3188         aMessageUid,
       
  3189 		aMessageParameters);
       
  3190     }
       
  3191 
       
  3192 // ----------------------------------------------------------------------------------
       
  3193 // CBrowserAppUi::UpdateNaviPaneL
       
  3194 // ----------------------------------------------------------------------------------
       
  3195 //
       
  3196 void CBrowserAppUi::UpdateNaviPaneL( TDesC& aStatusMsg )
       
  3197     {
       
  3198     ContentView()->UpdateNaviPaneL( aStatusMsg );
       
  3199     }
       
  3200 
       
  3201 // ----------------------------------------------------------------------------------
       
  3202 // CBrowserAppUi::StopDelay
       
  3203 // ----------------------------------------------------------------------------------
       
  3204 //
       
  3205 TInt CBrowserAppUi::StopDelay( TAny* aCBrowserAppUi )
       
  3206     {
       
  3207 	__ASSERT_DEBUG(aCBrowserAppUi, Util::Panic( Util::EUninitializedData ));
       
  3208 
       
  3209     ((CBrowserAppUi*)aCBrowserAppUi)->DoStopDelay();
       
  3210     return 0;
       
  3211     }
       
  3212 
       
  3213 
       
  3214 // ----------------------------------------------------------------------------------
       
  3215 // CBrowserAppUi::DoStopDelay
       
  3216 // ----------------------------------------------------------------------------------
       
  3217 //
       
  3218 void CBrowserAppUi::DoStopDelay()
       
  3219     {
       
  3220     iWait.AsyncStop();
       
  3221     }
       
  3222 
       
  3223 // ----------------------------------------------------------------------------------
       
  3224 // CBrowserAppUi::DelayedSendUiConstructL
       
  3225 // ----------------------------------------------------------------------------------
       
  3226 //
       
  3227 /*static*/ TInt CBrowserAppUi::DelayedSendUiConstructL( TAny* aCBrowserAppUi )
       
  3228 	{
       
  3229 	__ASSERT_DEBUG(aCBrowserAppUi, Util::Panic( Util::EUninitializedData ));
       
  3230 	TRAP_IGNORE(
       
  3231 				((CBrowserAppUi*)aCBrowserAppUi)->DoConstructSendUiL();
       
  3232 				);
       
  3233 	return KErrNone;
       
  3234 	}
       
  3235 
       
  3236 
       
  3237 // ----------------------------------------------------------------------------------
       
  3238 // CBrowserAppUi::DoConstructSendUiL
       
  3239 // ----------------------------------------------------------------------------------
       
  3240 //
       
  3241 void CBrowserAppUi::DoConstructSendUiL()
       
  3242 	{
       
  3243 	__ASSERT_DEBUG(!iSender, Util::Panic( Util::EUnExpected ));
       
  3244 	iSender = CWmlBrowserBmOTABinSender::NewL();
       
  3245 	}
       
  3246 
       
  3247 // -----------------------------------------------------------------------------------
       
  3248 // CBrowserAppUi::SetViewToReturnOnClose
       
  3249 // -----------------------------------------------------------------------------------
       
  3250 //
       
  3251 void CBrowserAppUi::SetViewToReturnOnClose( TUid const &aUid )
       
  3252     {
       
  3253     iViewToReturnOnClose.iUid = aUid.iUid;
       
  3254     }
       
  3255 
       
  3256 // -----------------------------------------------------------------------------------
       
  3257 // CBrowserAppUi::CloseContentViewL
       
  3258 // -----------------------------------------------------------------------------------
       
  3259 //
       
  3260 void CBrowserAppUi::CloseContentViewL()
       
  3261     {
       
  3262 LOG_ENTERFN("CBrowserAppUi::CloseContentViewL");
       
  3263 	CBrowserAppDocument* doc = STATIC_CAST(CBrowserAppDocument*, Document());
       
  3264 
       
  3265     // Close should Exit asynchronously if called from another application 
       
  3266     // & if not in feeds view
       
  3267 #ifdef __RSS_FEEDS
       
  3268 	if(CalledFromAnotherApp() && (!IsEmbeddedModeOn()) 
       
  3269     	&& (GetPreviousViewFromViewHistory() != KUidBrowserFeedsFolderViewId)
       
  3270     	&& (GetPreviousViewFromViewHistory() != KUidBrowserFeedsTopicViewId)
       
  3271     	&& (GetPreviousViewFromViewHistory() != KUidBrowserFeedsFeedViewId ))
       
  3272 	    {
       
  3273         SetExitInProgress( ETrue );
       
  3274         BROWSER_LOG( ( _L( " iBrowserAsyncExit->Start()" ) ) );
       
  3275         iBrowserAsyncExit->Start();
       
  3276 	    }
       
  3277 #else
       
  3278 	if(CalledFromAnotherApp() && !IsEmbeddedModeOn()) 
       
  3279 	    {
       
  3280         SetExitInProgress( ETrue );
       
  3281         BROWSER_LOG( ( _L( " iBrowserAsyncExit->Start()" ) ) );
       
  3282         iBrowserAsyncExit->Start();
       
  3283 	    }
       
  3284 #endif // __RSS_FEEDS
       
  3285    	    
       
  3286 	else
       
  3287 	    {	    
       
  3288 	if ( IsEmbeddedModeOn() &&
       
  3289         doc->GetFolderToOpen() == KFavouritesRootUid )
       
  3290 		{
       
  3291 		ExitBrowser(ETrue);
       
  3292 		}
       
  3293 	else
       
  3294 		{
       
  3295         if ( iStartedUp && ContentView()->GetPreviousViewID() == KUidBrowserBookmarksViewId )
       
  3296             {
       
  3297             if ( GetBookmarksView()->GetAdaptiveBookmarksFolderWasActive() )
       
  3298                 {
       
  3299                 GetBookmarksView()->OpenAdaptiveBookmarksWhenActivated();
       
  3300                 }
       
  3301             SetViewToBeActivatedIfNeededL( KUidBrowserBookmarksViewId );
       
  3302             }
       
  3303         else if ( IsEmbeddedModeOn())
       
  3304         {
       
  3305          if( !iExitInProgress )
       
  3306           {
       
  3307            ExitBrowser( ETrue );
       
  3308           }
       
  3309         }
       
  3310         else
       
  3311             {
       
  3312                	if(CalledFromAnotherApp() && (!IsEmbeddedModeOn()))
       
  3313                	    {
       
  3314                     SetViewToBeActivatedIfNeededL( GetPreviousViewFromViewHistory());
       
  3315   	       	        SetCalledFromAnotherApp(EFalse);
       
  3316                	    SendBrowserToBackground();
       
  3317                	    }                	
       
  3318                 else
       
  3319                     {                  
       
  3320                     SetViewToBeActivatedIfNeededL( iViewToReturnOnClose );
       
  3321                     }
       
  3322                 }
       
  3323             }
       
  3324 		}
       
  3325 	}
       
  3326 
       
  3327 // -----------------------------------------------------------------------------------
       
  3328 // CBrowserAppUi::IsEmbeddedModeOn
       
  3329 // -----------------------------------------------------------------------------------
       
  3330 //
       
  3331 TBool CBrowserAppUi::IsEmbeddedModeOn() const
       
  3332 	{
       
  3333 	return iEikonEnv->StartedAsServerApp();
       
  3334 	}
       
  3335 
       
  3336 // -----------------------------------------------------------------------------------
       
  3337 // CBrowserAppUi::HistoryLoadPrevious
       
  3338 // -----------------------------------------------------------------------------------
       
  3339 //
       
  3340 void CBrowserAppUi::HistoryLoadPrevious()
       
  3341     {
       
  3342     if( BrCtlInterface().NavigationAvailable( TBrCtlDefs::ENavigationBack ) )
       
  3343         {
       
  3344 	    TRAP_IGNORE( BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandBack +
       
  3345 										    (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  3346         }
       
  3347     }
       
  3348 
       
  3349 // -----------------------------------------------------------------------------------
       
  3350 // CBrowserAppUi::HistoryLoadNext
       
  3351 // -----------------------------------------------------------------------------------
       
  3352 //
       
  3353 void CBrowserAppUi::HistoryLoadNext()
       
  3354     {
       
  3355     if( BrCtlInterface().NavigationAvailable( TBrCtlDefs::ENavigationForward ) )
       
  3356         {
       
  3357         LoadObserver().DoStartLoad( CBrowserLoadObserver::ELoadUrlTypeOther );
       
  3358         BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandForward +
       
  3359                                                 (TInt)TBrCtlDefs::ECommandIdBase );
       
  3360         }
       
  3361     }
       
  3362 
       
  3363 
       
  3364 // ---------------------------------------------------------------------------
       
  3365 // CBrowserAppUi::IsShutdownRequested
       
  3366 // ---------------------------------------------------------------------------
       
  3367 //
       
  3368 TBool CBrowserAppUi::IsShutdownRequested() const
       
  3369 	{
       
  3370     return iShutdownRequested;
       
  3371 	}
       
  3372 
       
  3373 // ---------------------------------------------------------------------------
       
  3374 // CBrowserAppUi::IsEmbeddedInOperatorMenu
       
  3375 // ---------------------------------------------------------------------------
       
  3376 //
       
  3377 TBool CBrowserAppUi::IsEmbeddedInOperatorMenu() const
       
  3378 	{
       
  3379 	const TUid KUidOperatorMenuApp = { 0x10008D5E };
       
  3380 	const TUid KUidVideoServicesApp = { 0x10281893 }; 
       
  3381 
       
  3382 	// If the embedding application is the Operator Menu or Video Services
       
  3383 	if ( iEmbeddingApplicationUid == KUidOperatorMenuApp || iEmbeddingApplicationUid == KUidVideoServicesApp )
       
  3384 		{
       
  3385 		return ETrue;
       
  3386 		}
       
  3387 	else
       
  3388 		{
       
  3389 		return EFalse;
       
  3390 		}
       
  3391 	}
       
  3392 
       
  3393 // ---------------------------------------------------------------------------
       
  3394 // CBrowserAppUi::IsAppShutterActive
       
  3395 // ---------------------------------------------------------------------------
       
  3396 //
       
  3397 TBool CBrowserAppUi::IsAppShutterActive() const
       
  3398 	{
       
  3399 	CAknAppUi* shuttingApp = CAknEnv::AppWithShutterRunning();
       
  3400 
       
  3401 	if ( shuttingApp )
       
  3402 		{
       
  3403 		return ETrue;
       
  3404 		}
       
  3405 	else
       
  3406 		{
       
  3407 		return EFalse;
       
  3408 		}
       
  3409 	}
       
  3410 
       
  3411 // ---------------------------------------------------------------------------
       
  3412 // CBrowserAppUi::FetchHomePage
       
  3413 // --------------------------------------------------------------------------
       
  3414 //
       
  3415 void CBrowserAppUi::FetchHomePageL()
       
  3416     {
       
  3417 LOG_ENTERFN( "CBrowserAppUi::FetchHomePageL" );
       
  3418     if(!iStartedUp) // just in case, not done
       
  3419         CompleteDelayedInit();
       
  3420     
       
  3421     if ( !Fetching() )
       
  3422         {
       
  3423         UpdateSoftKeys();
       
  3424 
       
  3425         // If the last active view is content view, return to the bookmark view on close.
       
  3426         // Otherwise if the last active view is bookmark view and we return to the appropriate view on close.
       
  3427         TUid lastViewId = LastActiveViewId();
       
  3428         if( lastViewId == KUidBrowserContentViewId ||
       
  3429             lastViewId == KUidBrowserNullViewId )
       
  3430             {
       
  3431             lastViewId = KUidBrowserBookmarksViewId;
       
  3432             }
       
  3433         SetViewToReturnOnClose( lastViewId );
       
  3434 
       
  3435         if( iLongZeroPressed )
       
  3436             {
       
  3437 			BROWSER_LOG( ( _L( " LongZeroPressed." ) ) );
       
  3438 
       
  3439             // There should only be one special load observer at startup
       
  3440             SpecialLoadObserver().SetLongZeroStartup( iLongZeroPressed );
       
  3441             iLongZeroPressed = EFalse;
       
  3442             HBufC* buf = HBufC::NewLC( KMaxHomePgUrlLength );
       
  3443             TPtr ptr( buf->Des() );
       
  3444             TBool homePgFound( KErrNotFound );
       
  3445 
       
  3446             // try to read Access Points homepage
       
  3447             TUint defaultAp( KWmlNoDefaultAccessPoint );
       
  3448             // 'always ask' feature doesn't let to read the AP
       
  3449             if( Preferences().AccessPointSelectionMode() == EConnectionMethod )
       
  3450                 {
       
  3451                 defaultAp = Preferences().DefaultAccessPoint();
       
  3452                 }
       
  3453             if ( defaultAp != KWmlNoDefaultAccessPoint ) // There is an access point defined
       
  3454                 {
       
  3455                 CApAccessPointItem* apItem = Preferences().AllPreferencesL().iDefaultAPDetails;
       
  3456                 if ( apItem )
       
  3457                     {
       
  3458                     const HBufC* defaultHP = apItem->ReadConstLongTextL( EApWapStartPage );
       
  3459                     if ( defaultHP->Length() )
       
  3460                         {
       
  3461                         ptr.Zero();
       
  3462                         ptr.Append( *defaultHP );
       
  3463                         homePgFound = KErrNone;
       
  3464                         }
       
  3465                     }
       
  3466                 }
       
  3467             // in case of error, read user defined home page from SD
       
  3468             TInt err( KErrNone );
       
  3469             if( homePgFound == KErrNotFound ) 
       
  3470                 {
       
  3471                 // do not let leaving
       
  3472                 if ((Preferences().HomePageType() == EWmlSettingsHomePageAddress)
       
  3473                    ||(Preferences().HomePageType() == EWmlSettingsHomePageUseCurrent))
       
  3474                 	{                         
       
  3475                 	TRAP( err, homePgFound = Preferences().HomePageUrlL( ptr, ETrue ) );
       
  3476                 	}
       
  3477                 	}
       
  3478             // we have a url to load
       
  3479             if( err == KErrNone &&
       
  3480                 homePgFound == KErrNone &&
       
  3481                 ptr.Length() > 0 )
       
  3482                 {
       
  3483                 TRAP( err, FetchL( ptr, CBrowserLoadObserver::ELoadUrlTypeOther ) );
       
  3484                 // in case of any error switch back to BookmarksView
       
  3485                 if( err != KErrNone )
       
  3486                     {
       
  3487                     ContentView()->SetFullScreenOffL();
       
  3488                     SetLastActiveViewId( KUidBrowserBookmarksViewId );
       
  3489                     }
       
  3490                 }
       
  3491             else
       
  3492                 {
       
  3493                 // we already switched to ContentView, so change the layout back
       
  3494                 ContentView()->SetFullScreenOffL();
       
  3495                 SetLastActiveViewId( KUidBrowserBookmarksViewId );
       
  3496                 }
       
  3497             CleanupStack::PopAndDestroy( buf );
       
  3498             }
       
  3499         else
       
  3500             {
       
  3501             // it checks HomePageSettings
       
  3502             LaunchHomePageL( /* EFalse */ );
       
  3503             }
       
  3504         }
       
  3505     }
       
  3506 
       
  3507 // ---------------------------------------------------------------------------
       
  3508 // CBrowserAppUi::StartPreferencesViewL
       
  3509 // ---------------------------------------------------------------------------
       
  3510 //
       
  3511 TBool CBrowserAppUi::StartPreferencesViewL( TUint aListItems )
       
  3512     {
       
  3513     TBool retVal( EFalse );
       
  3514 	TInt retUi( KErrNone );
       
  3515     TInt err(KErrNone);
       
  3516 
       
  3517 	//start the connection  dialog
       
  3518 	CCmApplicationSettingsUi* settings = CCmApplicationSettingsUi::NewL();
       
  3519 	CleanupStack::PushL( settings );
       
  3520 	TCmSettingSelection selection;
       
  3521     // empty filter array because no filtering is wanted
       
  3522     TBearerFilterArray filterArray;
       
  3523 	TRAP ( err, retUi = settings->RunApplicationSettingsL( selection, aListItems, filterArray ) );
       
  3524 	CleanupStack::PopAndDestroy(); // settings
       
  3525     
       
  3526 	//if something has been selected
       
  3527 	if (retUi)	
       
  3528 	    {
       
  3529 	    //set the selection mode
       
  3530         iPreferences->SetAccessPointSelectionModeL( 
       
  3531                 STATIC_CAST( TCmSettingSelectionMode, selection.iResult ) );
       
  3532 
       
  3533 	    //based on the chosen connection type, store the connection identifier(iapid, snap id, always ask)
       
  3534 	    //in the preferences list
       
  3535 	    switch ( iPreferences->AccessPointSelectionMode() )
       
  3536 		    {			
       
  3537 		    case EConnectionMethod:
       
  3538 			    {
       
  3539 			    TUint32 id = iPreferences->DefaultAccessPoint();
       
  3540                 // CMManager gives us IAPid, need to translate to WAPid
       
  3541 			    if (selection.iId != 0)
       
  3542 			        {                   		
       
  3543 			        id = Util::WapIdFromIapIdL( *this, selection.iId ); 
       
  3544 			        }			    			    
       
  3545 			    iPreferences->SetDefaultAccessPointL( id );
       
  3546                 // Requested AP is preset for PushMtm
       
  3547 			    id = iPreferences->DefaultAccessPoint();
       
  3548                 if( id != KWmlNoDefaultAccessPoint )
       
  3549                     {
       
  3550     			    SetRequestedAP( id );
       
  3551                     retVal = ETrue;
       
  3552                     }
       
  3553 			    break;	
       
  3554 			    }
       
  3555 
       
  3556 		    case EDestination:
       
  3557 			    {
       
  3558 			    TUint32 snapId = iPreferences->DefaultSnapId();
       
  3559 			    if (selection.iId != 0)
       
  3560 			        {                   		
       
  3561 			        snapId = selection.iId;
       
  3562 			        }			        
       
  3563 			    iPreferences->SetDefaultSnapId( snapId );
       
  3564                 if( snapId != KWmlNoDefaultSnapId )
       
  3565                     {
       
  3566                     retVal = ETrue;
       
  3567                     }
       
  3568 			    break;	
       
  3569 			    }
       
  3570 
       
  3571 		    case EAlwaysAsk:
       
  3572 		    default:
       
  3573 			    {
       
  3574 			    break;	
       
  3575 			    }
       
  3576 		    }			
       
  3577 	    }
       
  3578 
       
  3579     // alr: is return val needed?  should it be true or false in EAA and default?  check how it's used
       
  3580     return retVal;
       
  3581     }
       
  3582 // ---------------------------------------------------------------------------
       
  3583 // CBrowserAppUi::AhleConnection
       
  3584 // ---------------------------------------------------------------------------
       
  3585 //
       
  3586 CRecentUrlStore* CBrowserAppUi::RecentUrlStore()
       
  3587     {
       
  3588     return iRecentUrlStore;
       
  3589     }
       
  3590 
       
  3591 // ---------------------------------------------------------------------------
       
  3592 // CBrowserAppUi::SomeItemsNotSecure
       
  3593 // ---------------------------------------------------------------------------
       
  3594 //
       
  3595 TBool CBrowserAppUi::SomeItemsNotSecure() const
       
  3596     {
       
  3597     return !( LoadObserver().LoadStatus( CBrowserLoadObserver::ELoadStatusAllItemIsSecure ) );
       
  3598     }
       
  3599 
       
  3600 // ----------------------------------------------------
       
  3601 // CBrowserAppUi::IsProgressShown
       
  3602 // ----------------------------------------------------
       
  3603 //
       
  3604 TBool CBrowserAppUi::IsProgressShown() const
       
  3605     {
       
  3606     return iShowProgress;
       
  3607     }
       
  3608 
       
  3609 // ----------------------------------------------------
       
  3610 // CBrowserAppUi::SetProgressShown
       
  3611 // ----------------------------------------------------
       
  3612 //
       
  3613 void CBrowserAppUi::SetProgressShown( TBool aProgressShown )
       
  3614     {
       
  3615     iShowProgress = aProgressShown;
       
  3616     }
       
  3617 
       
  3618 // ----------------------------------------------------
       
  3619 // CBrowserAppUi::RecognizeUiFileL
       
  3620 // ----------------------------------------------------
       
  3621 //
       
  3622 TBool CBrowserAppUi::RecognizeUiFileL( RFile& aFile, TBuf<KMaxDataTypeLength>& aDataTypeDes  )
       
  3623 	{
       
  3624 	TBool recognized = EFalse;
       
  3625 	HBufC8* buffer = NULL;
       
  3626 
       
  3627 	TFileName fileName;
       
  3628 	User::LeaveIfError(aFile.FullName(fileName));
       
  3629 
       
  3630     TInt fileSize;
       
  3631 
       
  3632 	// Read the file from the beginning into a buffer
       
  3633 	User::LeaveIfError(aFile.Size(fileSize));
       
  3634 	buffer = HBufC8::NewLC(fileSize);
       
  3635     TPtr8 bufferPtr(buffer->Des());
       
  3636     TInt startPos = 0;
       
  3637     User::LeaveIfError(aFile.Read(startPos, bufferPtr, fileSize));
       
  3638     // move the seek position back to start
       
  3639     User::LeaveIfError(aFile.Seek(ESeekStart, startPos));
       
  3640 
       
  3641     _LIT( KDotOPML, ".opml");
       
  3642     _LIT( KDotXML, ".xml");
       
  3643 
       
  3644     // First try the name extension
       
  3645     if ( fileName.Length() >= 3 )
       
  3646         {
       
  3647         TInt dotPos = fileName.LocateReverse( '.' );
       
  3648         if ( dotPos != KErrNotFound )
       
  3649             {
       
  3650             TInt extLength = fileName.Length() - dotPos;
       
  3651             HBufC* ext = fileName.Right( extLength ).AllocL();
       
  3652             CleanupStack::PushL( ext );
       
  3653 
       
  3654             // if .opml return true
       
  3655             if ( ext->CompareF( KDotOPML )  == 0)
       
  3656             	{
       
  3657 				aDataTypeDes = KOPMLMimeType;
       
  3658             	recognized = ETrue;
       
  3659             	}
       
  3660             else if (ext->CompareF( KDotXML ) == 0 )
       
  3661                 {
       
  3662                 _LIT8( dtd, "<opml" );
       
  3663 				if( bufferPtr.FindF( dtd ) != KErrNotFound )
       
  3664 					{
       
  3665 					aDataTypeDes =  KOPMLMimeType;
       
  3666 					recognized = ETrue;
       
  3667 					}
       
  3668                	}
       
  3669             CleanupStack::PopAndDestroy();	// ext
       
  3670             }
       
  3671         }
       
  3672 
       
  3673 		if (!recognized)
       
  3674 			{
       
  3675 			// just check content of buffer
       
  3676         	_LIT8( dtd, "<opml" );
       
  3677 			if( (bufferPtr.Length() > 5) &&
       
  3678 			    (bufferPtr.FindF( dtd ) != KErrNotFound ))
       
  3679 				{
       
  3680 				aDataTypeDes = KOPMLMimeType;
       
  3681 				recognized = ETrue;
       
  3682 				}
       
  3683         	}
       
  3684 
       
  3685 	CleanupStack::PopAndDestroy(); //buffer
       
  3686 
       
  3687 	return recognized;
       
  3688 	}
       
  3689 
       
  3690 
       
  3691 // ---------------------------------------------------------
       
  3692 // CBrowserAppUi::ConfirmUiHandlingL
       
  3693 // ---------------------------------------------------------
       
  3694 //
       
  3695 TBool CBrowserAppUi::ConfirmUiHandlingL( TFileName& aFilename, TBuf<KMaxDataTypeLength>& aDataTypeDes  )
       
  3696 	{
       
  3697 	// switch on data type desc and handle file accordingly
       
  3698 	if(aDataTypeDes.Compare( KOPMLMimeType ) == 0)
       
  3699 		{
       
  3700 		// Display confirmation dialog before activating feeds view
       
  3701 		HBufC* message = StringLoader::LoadLC(R_FEEDS_QUERY_IMPORT_NOW, aFilename);
       
  3702 		HBufC* lsc_yes = StringLoader::LoadLC(R_FEEDS_IMPORT_NOW_YES);
       
  3703 		HBufC* rsc_no = StringLoader::LoadLC(R_FEEDS_IMPORT_NOW_NO);
       
  3704 
       
  3705 		TBool ret(iDialogsProvider->DialogConfirmL( _L(""), *message, *lsc_yes, *rsc_no ));
       
  3706 
       
  3707 		CleanupStack::PopAndDestroy(3); //message, lsc_yes, rsc_no
       
  3708 
       
  3709 		if(ret)
       
  3710 			{
       
  3711 			return ETrue;
       
  3712 			}
       
  3713 		}
       
  3714 
       
  3715 	return EFalse;
       
  3716 	}
       
  3717 
       
  3718 // ---------------------------------------------------------
       
  3719 // CBrowserAppUi::CopyUiRFileToFileL
       
  3720 // ---------------------------------------------------------
       
  3721 //
       
  3722 
       
  3723 void CBrowserAppUi::CopyUiRFileToFileL( RFile& aFile, const TDesC& aFilepath )
       
  3724 	{
       
  3725 	//
       
  3726 	// copy r-file to a temporary file
       
  3727 	//
       
  3728 	RFs tempRFs;
       
  3729 	RFile tempRFile;
       
  3730 	TInt fileSize;
       
  3731 	HBufC8* buffer = NULL;
       
  3732 
       
  3733 	// Connect to file server
       
  3734 	User::LeaveIfError(tempRFs.Connect());
       
  3735     CleanupClosePushL(tempRFs);
       
  3736 
       
  3737 	// Create the filepath to copy to
       
  3738 	// Replace the file if it already exists
       
  3739 	User::LeaveIfError(tempRFile.Replace(tempRFs, aFilepath, EFileWrite));
       
  3740 	CleanupClosePushL(tempRFile);
       
  3741 
       
  3742 	// Copy the file
       
  3743 	User::LeaveIfError(aFile.Size(fileSize));
       
  3744 	buffer = HBufC8::NewLC(fileSize);
       
  3745     TPtr8 bufferPtr(buffer->Des());
       
  3746 
       
  3747 	// Read from the start of the file
       
  3748     User::LeaveIfError(aFile.Read(0, bufferPtr, fileSize));
       
  3749 	User::LeaveIfError(tempRFile.Write(bufferPtr, fileSize));
       
  3750 
       
  3751 	tempRFile.Close();
       
  3752 	tempRFs.Close();
       
  3753 
       
  3754 	// Cleanup Buffer and file copy stuff
       
  3755 	CleanupStack::PopAndDestroy(3); //buffer, tempRFile, tempRFs
       
  3756 	}
       
  3757 
       
  3758 // ---------------------------------------------------------
       
  3759 // CBrowserAppUi::HandleUiFileL
       
  3760 // ---------------------------------------------------------
       
  3761 //
       
  3762 void CBrowserAppUi::HandleUiFileL( TFileName& aFilepath, TBuf<KMaxDataTypeLength>& aDataTypeDes )
       
  3763 	{
       
  3764 	// switch on data type desc and handle file accordingly
       
  3765 	if(aDataTypeDes.Compare(KOPMLMimeType) == 0)
       
  3766 		{
       
  3767 		// Activate Content view first in order to
       
  3768 		// get it's BrowserControl instance ready to go
       
  3769 		// (as opposed to Feeds' BC instance) to be used to render
       
  3770 		// feeds content in case the user wants to read
       
  3771 		// the feed in-page.
       
  3772 		SetLastActiveViewId( KUidBrowserContentViewId );
       
  3773 		SetViewToBeActivatedIfNeededL( LastActiveViewId() );
       
  3774 		ActivateLocalViewL( LastActiveViewId() );
       
  3775 
       
  3776 		// Now activate bookmarks view
       
  3777 		SetLastActiveViewId( KUidBrowserBookmarksViewId );
       
  3778 		SetViewToBeActivatedIfNeededL( LastActiveViewId() );
       
  3779 		ActivateLocalViewL( LastActiveViewId() );
       
  3780 		HandleForegroundEventL( ETrue );
       
  3781 
       
  3782 		// wait until the content view is completely ready
       
  3783 		WaitCVInit();
       
  3784 
       
  3785 		// begin import, pass to feeds view
       
  3786 		iFeedsClientUtilities->BeginImportOPMLFeedsFileL(aFilepath);
       
  3787 		}
       
  3788 	}
       
  3789 
       
  3790 // ---------------------------------------------------------
       
  3791 // CBrowserAppUi::HandleUiDownloadL
       
  3792 // ---------------------------------------------------------
       
  3793 //
       
  3794 void CBrowserAppUi::HandleUiDownloadL( TFileName& aFilepath, TBuf<KMaxDataTypeLength>& aDataTypeDes )
       
  3795 	{
       
  3796 	// switch on data type desc and handle file accordingly
       
  3797 	if(aDataTypeDes.Compare(KOPMLMimeType) == 0)
       
  3798 		{
       
  3799 		SetLastActiveViewId( KUidBrowserFeedsFolderViewId );
       
  3800 		// begin import
       
  3801 		iFeedsClientUtilities->BeginImportOPMLFeedsFileL(aFilepath);
       
  3802         // switch back to FeedsView, so change layout
       
  3803         ContentView()->SetFullScreenOffL();
       
  3804 		}
       
  3805 	}
       
  3806 	
       
  3807 // ---------------------------------------------------------
       
  3808 // CBrowserAppUi::LaunchIntoFeedsL
       
  3809 // ---------------------------------------------------------
       
  3810 //
       
  3811 void CBrowserAppUi::LaunchIntoFeedsL()
       
  3812 {
       
  3813     if(iBrowserAlreadyRunning && (LastActiveViewId() == KUidBrowserContentViewId))
       
  3814 		{
       
  3815 		iFeedsClientUtilities->ShowFolderViewL(KUidBrowserContentViewId);         	
       
  3816 		}
       
  3817 	else
       
  3818 		{
       
  3819 		iFeedsClientUtilities->ShowFolderViewL();
       
  3820 		}
       
  3821 }
       
  3822 	
       
  3823 // ----------------------------------------------------
       
  3824 // CBrowserAppUi::CreateFullUrlLC
       
  3825 // ----------------------------------------------------
       
  3826 //
       
  3827 HBufC* CBrowserAppUi::CreateFullUrlLC(
       
  3828         const TDesC& aUrl,
       
  3829         const TDesC& aUsername,
       
  3830         const TDesC& aPassword )
       
  3831     {
       
  3832     // username[:password]@server/document
       
  3833     TInt lPw = aPassword.Length();
       
  3834     TInt lUn = aUsername.Length();
       
  3835     _LIT( KBrowserScheme, "://" );
       
  3836     TInt index = aUrl.Find( KBrowserScheme );
       
  3837     if( index == KErrNotFound )
       
  3838     	{
       
  3839         index = 0;  // insert at first position
       
  3840     	}
       
  3841     else
       
  3842     	{
       
  3843     	index += 3;  // insert after scheme
       
  3844     	}
       
  3845 
       
  3846     HBufC *fullUrl = HBufC::NewLC( aUrl.Length() + lUn + lPw + 3 );
       
  3847     fullUrl->Des().Copy( aUrl );
       
  3848     if( lPw + lUn )
       
  3849         {
       
  3850         fullUrl->Des().Insert( index, _L( "@" ) );
       
  3851         }
       
  3852     if( lPw )
       
  3853         {
       
  3854         fullUrl->Des().Insert( index, aPassword );
       
  3855         fullUrl->Des().Insert( index, _L( ":" ) );
       
  3856         }
       
  3857     if( lUn )
       
  3858         {
       
  3859         fullUrl->Des().Insert( index, aUsername );
       
  3860         }
       
  3861     // insert scheme???
       
  3862     fullUrl->Des().ZeroTerminate();
       
  3863 
       
  3864     return fullUrl;
       
  3865     }
       
  3866 
       
  3867 // ---------------------------------------------------------
       
  3868 // CBrowserAppUi::HandleResourceChangeL( TInt aType )
       
  3869 // ---------------------------------------------------------
       
  3870 //
       
  3871 void CBrowserAppUi::HandleResourceChangeL( TInt aType )
       
  3872     {
       
  3873     LOG_ENTERFN("CBrowserAppUi::HandleResourceChangeL");
       
  3874     LOG_WRITE_FORMAT(" aType: %d", aType);
       
  3875     if( iExitInProgress )
       
  3876         {
       
  3877         BROWSER_LOG( ( _L(" iExitInProgress ETrue ") ) );
       
  3878         return;
       
  3879         }
       
  3880 
       
  3881     CAknViewAppUi::HandleResourceChangeL( aType );
       
  3882     if ( aType == KEikDynamicLayoutVariantSwitch )
       
  3883         {
       
  3884         CBrowserViewBase* activeView = ActiveView( );
       
  3885         if( activeView != NULL )
       
  3886             {
       
  3887             activeView->HandleClientRectChange();
       
  3888             if ( ContentView() && (activeView != ContentView()) )
       
  3889                 {
       
  3890                 ContentView()->HandleClientRectChange();
       
  3891                 }
       
  3892             }
       
  3893         }
       
  3894     if (aType == KEikMessageFadeAllWindows)
       
  3895         {
       
  3896         if (ContentView() && ContentView()->PenEnabled())
       
  3897             {
       
  3898             if (iCurrentView == KUidBrowserContentViewId)
       
  3899                 {
       
  3900                 ContentView()->Toolbar()->DisableToolbarL(ETrue);
       
  3901                 }
       
  3902             }
       
  3903         }
       
  3904 
       
  3905     if (aType == KEikMessageUnfadeWindows)
       
  3906         {
       
  3907         if (ContentView()&& ContentView()->PenEnabled() && !ExitInProgress())
       
  3908             {
       
  3909             if (iCurrentView == KUidBrowserContentViewId)
       
  3910                 {
       
  3911                 ContentView()->MakeZoomSliderVisibleL(EFalse);
       
  3912                 ContentView()->Toolbar()->DisableToolbarL(EFalse);
       
  3913                 }
       
  3914             }
       
  3915         }
       
  3916     }
       
  3917 
       
  3918 // ---------------------------------------------------------
       
  3919 // CBrowserAppUi::ChangeConnectionL()
       
  3920 // ---------------------------------------------------------
       
  3921 //
       
  3922 void CBrowserAppUi::ChangeConnectionL()
       
  3923     {
       
  3924     TConManChangeConn change;
       
  3925     // This will contain the new IAP as well, but it needs to pass the old one
       
  3926     TUint32 newAp = Util::IapIdFromWapIdL( *this, RequestedAp() );
       
  3927     iConnection->ChangeIapL( change, newAp );
       
  3928     if( EConManDoNothing == change )
       
  3929         {
       
  3930         // Do nothing
       
  3931         }
       
  3932     else
       
  3933         {
       
  3934         //cancel transaction
       
  3935         SendDisconnectEventL();
       
  3936         /* start all */
       
  3937         if( EConManCloseAndStart == change )
       
  3938             {
       
  3939             //close connection
       
  3940             iConnection->Disconnect();
       
  3941 
       
  3942 #ifdef __RSS_FEEDS
       
  3943             //notify feeds engine to close the connection
       
  3944         	iFeedsClientUtilities->DisconnectManualUpdateConnectionL();
       
  3945 #endif
       
  3946             }
       
  3947         iConnection->SetRequestedAP( newAp );
       
  3948         TInt err = iConnection->StartConnectionL( ETrue );
       
  3949         if( err == KErrNone )
       
  3950             {
       
  3951             iConnection->ShowConnectionChangedDlg();
       
  3952             }
       
  3953         }
       
  3954     }
       
  3955 
       
  3956 // ---------------------------------------------------------
       
  3957 // CBrowserAppUi::HandleContentL()
       
  3958 // ---------------------------------------------------------
       
  3959 //
       
  3960 TBool CBrowserAppUi::HandleContentL( const TDesC& aFileName,
       
  3961                                       const CAiwGenericParamList& aParamList,
       
  3962                                       TBool& aContinue )
       
  3963     {
       
  3964     // Put the file name to the generic parameter list, if it is not there yet
       
  3965     TInt index(0);
       
  3966     aParamList.FindFirst( index, EGenericParamFile, EVariantTypeDesC );
       
  3967     if ( index == KErrNotFound )
       
  3968     	{
       
  3969         TAiwVariant paramVariant( aFileName );
       
  3970         TAiwGenericParam genericParam( EGenericParamFile, paramVariant );
       
  3971         CAiwGenericParamList* paramList = (CAiwGenericParamList*)&aParamList;
       
  3972         paramList->AppendL( genericParam );
       
  3973     	}
       
  3974 
       
  3975 	// Set EGenericParamAllowMove - we allow handlers to apply move instead
       
  3976 	// of copy for the file.
       
  3977     aParamList.FindFirst( index, EGenericParamAllowMove, EVariantTypeAny );
       
  3978     if ( index == KErrNotFound )
       
  3979     	{
       
  3980     	TBool allowMove( ETrue );
       
  3981         TAiwVariant allowMoveVariant( allowMove );
       
  3982         TAiwGenericParam genericParamAllowMove( EGenericParamAllowMove, allowMoveVariant );
       
  3983         CAiwGenericParamList* paramList = (CAiwGenericParamList*)&aParamList;
       
  3984         paramList->AppendL( genericParamAllowMove );
       
  3985     	}
       
  3986 
       
  3987     BrowserLauncherService()->DownloadFinishedL( KErrNone, aParamList );
       
  3988 
       
  3989     // Wait until the client sends two TBools (contentHandled & continueBrowsing).
       
  3990     iClientWantsToContinue = EFalse;
       
  3991     iWasContentHandled = EFalse;
       
  3992 
       
  3993     iLauncherServiceWait.Start();
       
  3994 
       
  3995     // iClientWantsToContinue and iWasContentHandled contains the results
       
  3996     aContinue = iClientWantsToContinue;
       
  3997     return iWasContentHandled;
       
  3998     }
       
  3999 
       
  4000 // ---------------------------------------------------------
       
  4001 // CBrowserAppUi::DownloadedContentHandlerReserved1()
       
  4002 // ---------------------------------------------------------
       
  4003 //
       
  4004 TAny* CBrowserAppUi::DownloadedContentHandlerReserved1( TAny* /*aAnyParam*/ )
       
  4005     {
       
  4006     return 0;
       
  4007     }
       
  4008 
       
  4009 // ---------------------------------------------------------
       
  4010 // CBrowserAppUi::SetContentHandlingResult()
       
  4011 // ---------------------------------------------------------
       
  4012 //
       
  4013 void CBrowserAppUi::SetContentHandlingResult
       
  4014     ( TBool aClientWantsToContinue, TBool aWasContentHandled )
       
  4015     {
       
  4016     iClientWantsToContinue = aClientWantsToContinue;
       
  4017     iWasContentHandled = aWasContentHandled;
       
  4018 
       
  4019     // continue handling the content
       
  4020     iLauncherServiceWait.AsyncStop();
       
  4021     }
       
  4022 
       
  4023 // ---------------------------------------------------------
       
  4024 // CBrowserAppUi::LoadSearchPageL()
       
  4025 // ---------------------------------------------------------
       
  4026 //
       
  4027 void CBrowserAppUi::LoadSearchPageL()
       
  4028 	{
       
  4029     TPtrC url = iPreferences->SearchPageUrlL();
       
  4030 
       
  4031     // url undefined
       
  4032     if ( !url.Length() )
       
  4033         {
       
  4034         HBufC* query = StringLoader::LoadLC(
       
  4035                                     R_BROWSER_QUERY_DEF_SEARCHPAGE );
       
  4036         // Ask if user want to define the search web setting now
       
  4037         if (
       
  4038             TBrowserDialogs::DialogQueryReqL( query->Des(),
       
  4039                                                 KNullDesC,
       
  4040                                                 KNullDesC )
       
  4041             )
       
  4042             {
       
  4043             HBufC* prompt = StringLoader::LoadLC(
       
  4044                                         R_BROWSER_PROMPT_SEARCH_URL );
       
  4045             HBufC* retBuf = HBufC::NewLC( KMaxSearchPgUrlLength );
       
  4046             TPtr retString = retBuf->Des();
       
  4047             retString.Copy( KNullDesC );
       
  4048 
       
  4049             TInt result = TBrowserDialogs::DialogPromptReqL(
       
  4050                                              prompt->Des(),
       
  4051                                              &retString,
       
  4052                                              ETrue,
       
  4053                                              KMaxSearchPgUrlLength
       
  4054                                              );
       
  4055 
       
  4056             if( result )  // URL was accepted
       
  4057                 {
       
  4058                 Preferences().SetSearchPageUrlL( retString );
       
  4059                 url.Set( iPreferences->SearchPageUrlL() );
       
  4060                 }
       
  4061             CleanupStack::PopAndDestroy( 2 ); // retBuf, prompt
       
  4062             }
       
  4063         CleanupStack::PopAndDestroy( query );
       
  4064         }
       
  4065 
       
  4066     FetchL( url );
       
  4067 	}
       
  4068 
       
  4069 // ---------------------------------------------------------
       
  4070 // CBrowserAppUi::CloseWindowL()
       
  4071 // ---------------------------------------------------------
       
  4072 //
       
  4073 void CBrowserAppUi::CloseWindowL( TInt aWindowId )
       
  4074     {
       
  4075 LOG_ENTERFN("AppUi::CloseWindowL");
       
  4076 
       
  4077 	//There are only two cases for closing window. One is user initialized and the
       
  4078 	//other is script initialized. For both cases, the window should be deleted.
       
  4079     TBool forceDelete( ETrue );
       
  4080     // this variable is useful to know if the window has a parent window which needs to be activated on closing current window
       
  4081     TBool parentPresent(EFalse);
       
  4082     if ( WindowMgr().CurrentWindowQue() && WindowMgr().CurrentWindowQue()->iParent )
       
  4083         {
       
  4084         parentPresent = ETrue;
       
  4085         }
       
  4086     // delete the current window by default
       
  4087     if( aWindowId == 0 )
       
  4088         {
       
  4089         aWindowId = WindowMgr().CurrentWindow()->WindowId();
       
  4090         // scripts directly pass a real windowId,
       
  4091         // so if user initiated the process, we really delete the window
       
  4092         forceDelete = ETrue;
       
  4093         }
       
  4094     //If this window has been created from Search app
       
  4095     if(aWindowId == iWindowIdFromFromExternApp)
       
  4096     {
       
  4097         //Make it false as window is going to close down
       
  4098         iSameWinApp = EFalse;
       
  4099     }
       
  4100 #ifdef __RSS_FEEDS
       
  4101 	// If we are closing a Feeds Full Story then go back to feeds
       
  4102 	TBool feedsWindow(EFalse);
       
  4103 	CBrowserWindow* win;
       
  4104 	TInt err = WindowMgr().Window(aWindowId, win);
       
  4105 	if (err == KErrNone)
       
  4106 		{
       
  4107 		feedsWindow = win->HasFeedsContent();
       
  4108 		win->SetHasFeedsContent(EFalse);
       
  4109 		}
       
  4110 #endif
       
  4111 
       
  4112 	TInt winId = WindowMgr().DeleteWindowL( aWindowId, forceDelete );
       
  4113 
       
  4114 #ifdef __RSS_FEEDS
       
  4115 	if (feedsWindow)
       
  4116 		{
       
  4117 		SetViewToBeActivatedIfNeededL( KUidBrowserFeedsFeedViewId );
       
  4118 		return;
       
  4119 		}
       
  4120 #endif
       
  4121 
       
  4122     if( winId > 0 )  // still remain a window to be activated
       
  4123         {
       
  4124    	    WindowMgr().SwitchWindowL( winId );
       
  4125         if(CalledFromAnotherApp() && (!IsEmbeddedModeOn()) && !parentPresent)
       
  4126    	        {
       
  4127    	        SetCalledFromAnotherApp(EFalse);
       
  4128    	        SendBrowserToBackground();
       
  4129    	        }
       
  4130    	    }
       
  4131    	else  if( winId == 0) // last window was closed
       
  4132 	    {
       
  4133         if(CalledFromAnotherApp() && (!IsEmbeddedModeOn()))
       
  4134    	        {
       
  4135 #ifdef __RSS_FEEDS
       
  4136    	        if ((GetPreviousViewFromViewHistory() == KUidBrowserFeedsFolderViewId) || 
       
  4137    	            (GetPreviousViewFromViewHistory() == KUidBrowserFeedsTopicViewId) ||
       
  4138    	            (GetPreviousViewFromViewHistory() == KUidBrowserFeedsFeedViewId))
       
  4139    	            {
       
  4140    	            SetViewToBeActivatedIfNeededL( GetPreviousViewFromViewHistory() );
       
  4141    	            SetCalledFromAnotherApp(EFalse);
       
  4142    	            SendBrowserToBackground();
       
  4143    	            }
       
  4144    	        else
       
  4145                 {
       
  4146                	ExitBrowser(ETrue);
       
  4147                 }
       
  4148 #else
       
  4149             ExitBrowser(ETrue);
       
  4150 #endif // __RSS_FEEDS
       
  4151    	        }
       
  4152         else
       
  4153             {
       
  4154         	ExitBrowser(ETrue);        
       
  4155             }
       
  4156     	}
       
  4157     // else a background window was closed
       
  4158 
       
  4159     }
       
  4160 
       
  4161 // ---------------------------------------------------------
       
  4162 // CBrowserAppUi::StartProgressAnimationL
       
  4163 // ---------------------------------------------------------
       
  4164 //
       
  4165 void CBrowserAppUi::StartProgressAnimationL()
       
  4166     {
       
  4167 LOG_ENTERFN("AppUi::StartProgressAnimationL");
       
  4168     }
       
  4169 
       
  4170 // ---------------------------------------------------------
       
  4171 // CBrowserAppUi::StopProgressAnimationL
       
  4172 // ---------------------------------------------------------
       
  4173 //
       
  4174 void CBrowserAppUi::StopProgressAnimationL()
       
  4175     {
       
  4176 LOG_ENTERFN("AppUi::StopProgressAnimationL");
       
  4177     }
       
  4178 
       
  4179 #ifdef __RSS_FEEDS
       
  4180 // ---------------------------------------------------------
       
  4181 // CBrowserAppUi::FeedsClientUtilities
       
  4182 // ---------------------------------------------------------
       
  4183 //
       
  4184 CFeedsClientUtilities& CBrowserAppUi::FeedsClientUtilities() const
       
  4185 	{
       
  4186 	return *iFeedsClientUtilities;
       
  4187 	}
       
  4188 #endif  // __RSS_FEEDS
       
  4189 
       
  4190 // ---------------------------------------------------------
       
  4191 // CBrowserAppUi::OpenLinkInNewWindowL()
       
  4192 // ---------------------------------------------------------
       
  4193 //
       
  4194 void CBrowserAppUi::OpenLinkInNewWindowL( const CFavouritesItem& aBookmarkItem )
       
  4195     {
       
  4196     if( ( aBookmarkItem.IsItem() ) &&
       
  4197         ( aBookmarkItem.Uid() != KFavouritesRSSItemUid ) )
       
  4198         {
       
  4199         // Check if we should/can create a new window
       
  4200         // In most cases when the feature is not allowed option menu items have been dimmed.
       
  4201         // In the case where a long key press on a bookmark happens we fall through to this function
       
  4202         // and check the feature here.  If a new window is not allowed we can open in the current window
       
  4203         if( IsPageLoaded() &&
       
  4204         		Preferences().UiLocalFeatureSupported( KBrowserMultipleWindows ) &&
       
  4205             	!Preferences().UiLocalFeatureSupported( KBrowserMinimalMultipleWindows ))
       
  4206             {
       
  4207             // there is already a window, so create a new one
       
  4208             CBrowserWindow *win = WindowMgr().CreateWindowL( 0, &KNullDesC );
       
  4209             if (win != NULL)
       
  4210                 {
       
  4211                 CleanupStack::PushL( win );
       
  4212                 WindowMgr().SwitchWindowL( win->WindowId() );
       
  4213                 FetchBookmarkL( aBookmarkItem );
       
  4214                 CleanupStack::Pop();  // win
       
  4215                 }
       
  4216             }
       
  4217         else
       
  4218             {
       
  4219             // no page is loaded yet, so do not create new window
       
  4220             FetchBookmarkL( aBookmarkItem );
       
  4221             }
       
  4222         }
       
  4223     }
       
  4224 
       
  4225 // ---------------------------------------------------------
       
  4226 // CBrowserAppUi::SendDisconnectEventL
       
  4227 // ---------------------------------------------------------
       
  4228 //
       
  4229 void CBrowserAppUi::SendDisconnectEventL()
       
  4230     {
       
  4231     LOG_ENTERFN("CBrowserAppUi::SendDisconnectEventL");
       
  4232     
       
  4233     if(!iStartedUp)
       
  4234         return;
       
  4235         
       
  4236     SpecialLoadObserver().CancelConnection();
       
  4237     CArrayFixFlat<CWindowInfo*>* windows = iWindowManager->GetWindowInfoL( this );
       
  4238     if( windows )
       
  4239         {
       
  4240         TInt i;
       
  4241 
       
  4242         for ( i = 0; i < windows->Count(); i++ )
       
  4243             {
       
  4244             CBrowserWindow* window = NULL;
       
  4245             iWindowManager->Window( windows->At( i )->iWindowId, window );
       
  4246             if( window )
       
  4247                 {
       
  4248                 TInt err;
       
  4249            //     BROWSER_LOG( ( _L( " iConnection Connected" ) ) );
       
  4250                 TRAP( err, window->BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandCancelFetch + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  4251            //     BROWSER_LOG( ( _L( " HandleCommandL:  %d"), err ) );
       
  4252                 }
       
  4253             }
       
  4254         
       
  4255         CBrowserWindow* window = NULL;
       
  4256         iWindowManager->Window( windows->At( 0 )->iWindowId, window );
       
  4257                 
       
  4258         // delete the window items before deleting the array
       
  4259         for( i=0; i<windows->Count(); ++i )
       
  4260             delete windows->At( i );
       
  4261 
       
  4262         delete windows;
       
  4263         }
       
  4264     }
       
  4265     /*
       
  4266 
       
  4267 // ----------------------------------------------------
       
  4268 // CBrowserAppUi::IsPgNotFound
       
  4269 // ----------------------------------------------------
       
  4270 //
       
  4271 TBool CBrowserAppUi::IsPgNotFound() const
       
  4272     {
       
  4273     return iPgNotFound;
       
  4274     }
       
  4275 */
       
  4276 // ----------------------------------------------------
       
  4277 // CBrowserAppUi::HandleApplicationSpecificEventL
       
  4278 // ----------------------------------------------------
       
  4279 //
       
  4280 void CBrowserAppUi::HandleApplicationSpecificEventL(TInt aEventType, const TWsEvent& aWsEvent)
       
  4281     {
       
  4282     CAknAppUi::HandleApplicationSpecificEventL(aEventType, aWsEvent);
       
  4283 
       
  4284     /*
       
  4285      * Note:  Even though we get these memory events from the system for handling OOM, and we pass them off
       
  4286      * to the command handler, there is no code further down the line that actually handles them (it would 
       
  4287      * normally be in BrCtl).  We totally ignore these events.  This is because the system has too high of an OOM threshold.
       
  4288      * I.e. the system may only have 6m left and think it's out of memory, however, the browser can still render
       
  4289      * many pages in only 6m.  So, these system events are ignored and the browser handles OOM with its own mechanism.
       
  4290      * (See OOMStopper and OOMHandler)
       
  4291      */
       
  4292 	if(aEventType == KAppOomMonitor_FreeRam )
       
  4293 		{
       
  4294 		iWindowManager->CloseAllWindowsExceptCurrent();
       
  4295             BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandFreeMemory + (TInt)TBrCtlDefs::ECommandIdBase);
       
  4296 		    }
       
  4297 	else if(aEventType == KAppOomMonitor_MemoryGood)
       
  4298 		{
       
  4299         BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandMemoryGood + (TInt)TBrCtlDefs::ECommandIdBase);
       
  4300 		}
       
  4301     else if ( KAknFullOrPartialForegroundGained == aEventType )
       
  4302         {
       
  4303         if ( iViewToBeActivatedIfNeeded.iUid )
       
  4304             {
       
  4305             ActivateLocalViewL( iViewToBeActivatedIfNeeded );
       
  4306             }
       
  4307         else
       
  4308             {
       
  4309             // LastActiveViewId() might return with 0!
       
  4310             TRAP_IGNORE( ActivateLocalViewL( LastActiveViewId() ) );
       
  4311             }
       
  4312         iViewToBeActivatedIfNeeded.iUid = 0;
       
  4313         }
       
  4314     }
       
  4315 
       
  4316 // ----------------------------------------------------
       
  4317 // CBrowserAppUi::OfferApplicationSpecificKeyEventL
       
  4318 //
       
  4319 // Use this function to handle key events that are application wide and not specific to any view
       
  4320 // All views (containers) call this first and should return if key was consumed
       
  4321 // As a note for future reference the red end key shows up as iCode = EKeyNo...though you would
       
  4322 // think it would be EKeyEnd...
       
  4323 // ----------------------------------------------------
       
  4324 //
       
  4325 TKeyResponse CBrowserAppUi::OfferApplicationSpecificKeyEventL(const TKeyEvent& /*aKeyEvent*/,
       
  4326 															  TEventCode /*aType*/)
       
  4327     {
       
  4328     TKeyResponse result( EKeyWasNotConsumed );
       
  4329 
       
  4330     return result;
       
  4331     }
       
  4332 
       
  4333 // -----------------------------------------------------------------------------
       
  4334 // CBrowserAppUi::GetPreviousViewFromViewHistory
       
  4335 // -----------------------------------------------------------------------------
       
  4336 //
       
  4337 TUid CBrowserAppUi::GetPreviousViewFromViewHistory()
       
  4338 {
       
  4339 	return iPreviousView;
       
  4340 }
       
  4341 
       
  4342 // -----------------------------------------------------------------------------
       
  4343 // CBrowserAppUi::SaveFocusedImageToGalleryL
       
  4344 // -----------------------------------------------------------------------------
       
  4345 //
       
  4346 void CBrowserAppUi::SaveFocusedImageToGalleryL()
       
  4347     {
       
  4348     TBrCtlImageCarrier* imageCarrier = BrCtlInterface().FocusedImageLC();
       
  4349     CDocumentHandler* docHandler = CDocumentHandler::NewLC();
       
  4350     TUriParser uriParser;
       
  4351     User::LeaveIfError(uriParser.Parse(imageCarrier->Url()));
       
  4352     TPtrC path;
       
  4353     path.Set( uriParser.Extract( EUriPath ) );
       
  4354     HBufC* fileName = NULL;
       
  4355     if( path.Length() )
       
  4356         {
       
  4357         TInt slash = path.LocateReverse( '/' );
       
  4358         if( slash != KErrNotFound && slash != path.Length() )
       
  4359             {
       
  4360             TPtrC temp( path.Right( path.Length() - slash - 1 ) );
       
  4361             if( temp.Length() )
       
  4362                 {
       
  4363                 fileName = HBufC::NewLC(temp.Length() + 4); // leave room for edding extenstion if needed
       
  4364                 fileName->Des().Copy(temp);
       
  4365                 }
       
  4366             }
       
  4367         }
       
  4368     HBufC8* dataType8 = NULL;
       
  4369     dataType8 = HBufC8::NewLC(imageCarrier->ContentType().Length());
       
  4370     dataType8->Des().Copy(imageCarrier->ContentType());
       
  4371     TDataType dataType(*dataType8);
       
  4372     if (fileName)
       
  4373         {
       
  4374         TPtr fileNamePtr(fileName->Des());
       
  4375         docHandler->CheckFileNameExtension(fileNamePtr, dataType);
       
  4376         docHandler->SaveL(imageCarrier->RawData(), dataType, *fileName, KEntryAttNormal);
       
  4377         }
       
  4378     else
       
  4379         {
       
  4380         docHandler->SaveL(imageCarrier->RawData(), dataType, KEntryAttNormal);
       
  4381         }
       
  4382     if (fileName)
       
  4383         {
       
  4384         CleanupStack::PopAndDestroy(2); // fileName, dataType8
       
  4385         }
       
  4386     else
       
  4387         {
       
  4388         CleanupStack::PopAndDestroy(dataType8); // dataType8
       
  4389         }
       
  4390 
       
  4391     TFileName fName;
       
  4392     User::LeaveIfError(docHandler->GetPath(fName));
       
  4393     
       
  4394     #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
       
  4395     
       
  4396     CMGXFileManager* mgFileManager = MGXFileManagerFactory::NewFileManagerL(CEikonEnv::Static()->FsSession());
       
  4397     CleanupStack::PushL(mgFileManager);
       
  4398     if( fName.Length() > 0 )
       
  4399         {
       
  4400         TRAP_IGNORE( mgFileManager->UpdateL( fName ) );
       
  4401         }
       
  4402     else
       
  4403         {
       
  4404         TRAP_IGNORE( mgFileManager->UpdateL() );
       
  4405         }
       
  4406     CleanupStack::PopAndDestroy(1); // mgFileManager
       
  4407     
       
  4408     #endif
       
  4409     
       
  4410     CleanupStack::PopAndDestroy(1); // imageCarrier
       
  4411     }
       
  4412 
       
  4413 // ---------------------------------------------------------
       
  4414 // CBrowserAppUi::CheckFlashPresent
       
  4415 // ---------------------------------------------------------
       
  4416 //
       
  4417 TBool CBrowserAppUi::CheckFlashPresent()
       
  4418     {
       
  4419     RImplInfoPtrArray animPluginList;
       
  4420 
       
  4421     TRAP_IGNORE( REComSession::ListImplementationsL( KBrowserPluginInterfaceUid,
       
  4422                                         animPluginList ) );
       
  4423 
       
  4424 
       
  4425 	_LIT8(KFlashMimeType,     "application/x-shockwave-flash");
       
  4426 
       
  4427     const TInt count = animPluginList.Count();
       
  4428     TBool found = EFalse;
       
  4429     for ( TInt i = 0; i < count; i++ )
       
  4430         {
       
  4431         CImplementationInformation* implInfo = animPluginList[i];
       
  4432         if (( implInfo->DataType( ) ).Find( KFlashMimeType) != KErrNotFound)
       
  4433             {
       
  4434             found = ETrue;  //flash plugin is present
       
  4435             break;
       
  4436             }
       
  4437         }
       
  4438     animPluginList.ResetAndDestroy();
       
  4439 
       
  4440     return found;
       
  4441 
       
  4442     }
       
  4443 
       
  4444 // ---------------------------------------------------------
       
  4445 // CBrowserAppUi::FlashPresent
       
  4446 // ---------------------------------------------------------
       
  4447 //
       
  4448 TBool CBrowserAppUi::FlashPresent()
       
  4449     {
       
  4450     return iFlashPresent;
       
  4451     }
       
  4452 
       
  4453 // ---------------------------------------------------------
       
  4454 // CBrowserAppUi::ShowNameAndVersionL
       
  4455 // ---------------------------------------------------------
       
  4456 //
       
  4457 void CBrowserAppUi::ShowNameAndVersionL()
       
  4458 {
       
  4459     HBufC* header = StringLoader::LoadLC( R_BROWSER_QUERY_BROWSER_VERSION );
       
  4460     HBufC* browserVersion = BrCtlInterface().VersionInfoLC(TBrCtlDefs::EBrowserVersion);
       
  4461 
       
  4462     // output browser version to dialog
       
  4463     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( *browserVersion );
       
  4464     CleanupStack::PushL(dlg);
       
  4465     dlg->PrepareLC( R_BROWSER_PAGE_VERSION );
       
  4466     CleanupStack::Pop(dlg);
       
  4467     CAknPopupHeadingPane* hPane = dlg->QueryHeading();
       
  4468     if ( hPane )
       
  4469         {
       
  4470         CleanupStack::PushL(hPane);
       
  4471         hPane->SetTextL( *header );
       
  4472 	    CleanupStack::Pop(hPane);
       
  4473         }
       
  4474     dlg->RunLD();
       
  4475 	CleanupStack::PopAndDestroy(2); // browserVersion, header
       
  4476 }
       
  4477 
       
  4478 
       
  4479 // ---------------------------------------------------------
       
  4480 // CBrowserAppUi::IsLaunchHomePageDimmedL
       
  4481 // ---------------------------------------------------------
       
  4482 //
       
  4483 TBool CBrowserAppUi::IsLaunchHomePageDimmedL()
       
  4484 {
       
  4485     
       
  4486     // Set dimmed flag if shortcut key for launch home page is dimmed and was selected
       
  4487     TBool dimmed = EFalse;
       
  4488     TBool homepage = Preferences().UiLocalFeatureSupported( KBrowserUiHomePageSetting );
       
  4489     if( homepage )
       
  4490         {
       
  4491         TWmlSettingsHomePage pgtype = Preferences().HomePageType();
       
  4492         TBool alwaysAskCase = ((Preferences().AccessPointSelectionMode() == EAlwaysAsk ) &&
       
  4493             ( EWmlSettingsHomePageAccessPoint == pgtype ));
       
  4494         
       
  4495         if (alwaysAskCase || (pgtype == EWmlSettingsHomePageBookmarks))
       
  4496             {
       
  4497             dimmed = ETrue;
       
  4498             }
       
  4499         else if (pgtype == EWmlSettingsHomePageAccessPoint)
       
  4500         	{
       
  4501         	// check to see if no home page defined on the access point
       
  4502         	HBufC* buf = HBufC::NewLC( KMaxHomePgUrlLength );  // cleanupstack
       
  4503     		TPtr ptr( buf->Des() );
       
  4504     		TInt pgFound = Preferences().HomePageUrlL( ptr );
       
  4505     		if( pgFound != KErrNone )
       
  4506     			{
       
  4507     			dimmed = ETrue;
       
  4508     			}
       
  4509     		CleanupStack::PopAndDestroy( buf );
       
  4510         	}
       
  4511         }
       
  4512     else
       
  4513         {
       
  4514         dimmed = ETrue;
       
  4515         }
       
  4516         
       
  4517     return(dimmed);
       
  4518 }
       
  4519 
       
  4520 // ---------------------------------------------------------
       
  4521 // CBrowserAppUi::IsDisplayingMenuOrDialog
       
  4522 // ---------------------------------------------------------
       
  4523 //
       
  4524 TBool CBrowserAppUi::IsDisplayingMenuOrDialog()
       
  4525 {
       
  4526 	return CCoeAppUi::IsDisplayingMenuOrDialog();
       
  4527 }
       
  4528 // ---------------------------------------------------------
       
  4529 // CBrowserAppUi::HandleWsEventL
       
  4530 // ---------------------------------------------------------
       
  4531 void CBrowserAppUi::HandleWsEventL(const TWsEvent& aEvent, 
       
  4532                                    CCoeControl* aDestination)
       
  4533 {
       
  4534   /**
       
  4535    * We need a special handling for pointer events to handle the situation 
       
  4536    * when the pointer is crossing the boundaries of plugin window. Browser
       
  4537    * scrolling id done using PointerMove events not a Drag. 
       
  4538    * When PointerMoveBuffer is ready HandlePointerBufferReadyL() is called by
       
  4539    * Symbian framework. By default if Pointer Down event wasn't issued on the 
       
  4540    * current CoeControl Pointer Move events are not sent to this control.
       
  4541    * The code below makes sure that when we entering the Content View window 
       
  4542    * from pluging window we are still getting move events.
       
  4543    * When we are leaving Content window we are generating fake Pointer Up 
       
  4544    * event in order to on-demand scrollbars disapear properly. The later is a
       
  4545    * hack and needs to be re-designed in such way that pluging will pass 
       
  4546    * pointer event back to the browser.
       
  4547    */
       
  4548    if (aDestination != NULL)
       
  4549        {
       
  4550        TInt type=aEvent.Type();
       
  4551        
       
  4552        switch (type)
       
  4553            {
       
  4554            case EEventPointerExit:
       
  4555                {
       
  4556 
       
  4557                break;
       
  4558                }
       
  4559                
       
  4560            case EEventPointerEnter:
       
  4561                {
       
  4562                if (iCurrentView == KUidBrowserContentViewId)
       
  4563                    {
       
  4564                    CCoeControl* ctrl = &(BrCtlInterface());
       
  4565                    ctrl->DrawableWindow()->DiscardPointerMoveBuffer(); 
       
  4566                    const TInt count = ctrl->CountComponentControls();
       
  4567                    for (TInt i = 0; i < count; i++) 
       
  4568                        {
       
  4569                        CCoeControl* c = ctrl->ComponentControl(i);
       
  4570                        if (c) 
       
  4571                           {
       
  4572                           c->ClaimPointerGrab(EFalse);
       
  4573                           }
       
  4574                        }
       
  4575                    ctrl->ClaimPointerGrab(EFalse);
       
  4576                    }
       
  4577                break;
       
  4578                }
       
  4579            
       
  4580            }
       
  4581        }
       
  4582    CAknViewAppUi::HandleWsEventL(aEvent, aDestination);
       
  4583 }
       
  4584 
       
  4585 // ---------------------------------------------------------
       
  4586 // CBrowserAppUi::HandleSystemEventL
       
  4587 // ---------------------------------------------------------
       
  4588 #if defined(__S60_50__)
       
  4589 void CBrowserAppUi::HandleSystemEventL(const TWsEvent& aEvent)
       
  4590    {
       
  4591    
       
  4592    /**
       
  4593     * We need a special handling for System events to handle the situation 
       
  4594     * like when the shut down is done while download is going on.
       
  4595     */
       
  4596    
       
  4597    switch (*(TApaSystemEvent*)(aEvent.EventData()))
       
  4598      {
       
  4599      case EApaSystemEventShutdown:    
       
  4600        // do things here
       
  4601         ExitBrowser ( IsAppShutterActive() );  
       
  4602        break;
       
  4603      default:
       
  4604        break;
       
  4605      }
       
  4606    // call base class implementation
       
  4607    CAknAppUi::HandleSystemEventL(aEvent);
       
  4608    }
       
  4609 #endif  
       
  4610 // ---------------------------------------------------------
       
  4611 // CBrowserAppUi::StartFetchHomePageL
       
  4612 // ---------------------------------------------------------
       
  4613 void CBrowserAppUi::StartFetchHomePageL(void)
       
  4614     {
       
  4615     if(!iStartedUp)
       
  4616         CompleteDelayedInit();
       
  4617     
       
  4618     // There's a homepage to be launched so start in content view
       
  4619     SetLastActiveViewId(KUidBrowserContentViewId);      	    	          
       
  4620    	//wait for contentview to initialize itself
       
  4621     WaitCVInit();
       
  4622     
       
  4623     TInt error( KErrNone );
       
  4624     TRAP( error, FetchHomePageL() );
       
  4625     if( error != KErrNone )
       
  4626         {
       
  4627         CloseContentViewL();
       
  4628         }                
       
  4629     }
       
  4630     
       
  4631 #ifdef BRDO_IAD_UPDATE_ENABLED_FF
       
  4632 // ---------------------------------------------------------
       
  4633 // CBrowserAppUi::CompleteIADUpdateCallback
       
  4634 // ---------------------------------------------------------
       
  4635 TInt CBrowserAppUi::CompleteIADUpdateCallback( TAny* aBrowserAppUi )
       
  4636     {
       
  4637     TRAP_IGNORE( ((CBrowserAppUi*)aBrowserAppUi)->CheckUpdatesL() )
       
  4638     return KErrNone;
       
  4639     }
       
  4640 
       
  4641 
       
  4642 // ---------------------------------------------------------
       
  4643 // CBrowserAppUi::CheckUpdateFileAvailable
       
  4644 // ---------------------------------------------------------
       
  4645 TBool CBrowserAppUi::CheckUpdateFileAvailable()
       
  4646     {
       
  4647     LOG_ENTERFN("CBrowserAppUi::CheckUpdateFileAvailable");
       
  4648     TBuf<KMaxFileName> privatePath;
       
  4649     TBuf<KMaxFileName> updateFileName;
       
  4650     iFs.PrivatePath( privatePath );
       
  4651     updateFileName.Copy( privatePath );
       
  4652     updateFileName.Append( KUpdateFileName );
       
  4653     RFile updatefile;   
       
  4654     TInt err = updatefile.Open( iFs, updateFileName, EFileRead );
       
  4655     if ( err == KErrNotFound ) 
       
  4656         {
       
  4657         LOG_WRITE( "CBrowserAppUi::CheckUpdateFileAvailable - update file not available" );
       
  4658         return EFalse;
       
  4659         }
       
  4660     else
       
  4661         {
       
  4662         LOG_WRITE( "CBrowserAppUi::CheckUpdateFileAvailable - update file available" );
       
  4663         updatefile.Close();
       
  4664         }
       
  4665     return ETrue;       
       
  4666     }
       
  4667 
       
  4668 // ---------------------------------------------------------
       
  4669 // CBrowserAppUi::WriteUpdateFile
       
  4670 // ---------------------------------------------------------
       
  4671 void CBrowserAppUi::WriteUpdateFile()
       
  4672     {
       
  4673     LOG_ENTERFN("CBrowserAppUi::WriteUpdateFile");
       
  4674     TBuf<KMaxFileName> privatePath;
       
  4675     TBuf<KMaxFileName> updateFileName;
       
  4676     iFs.PrivatePath( privatePath );
       
  4677     updateFileName.Copy( privatePath );
       
  4678     updateFileName.Append( KUpdateFileName );
       
  4679     RFile updatefile;
       
  4680     TInt err = updatefile.Open( iFs, updateFileName, EFileWrite | EFileShareExclusive );
       
  4681     if(err == KErrNotFound)
       
  4682         {
       
  4683         LOG_WRITE( "CBrowserAppUi::WriteUpdateFile - update file not available so create it" );
       
  4684         err = updatefile.Create( iFs, updateFileName, EFileWrite | EFileShareExclusive );
       
  4685         }
       
  4686     //Get the current time
       
  4687     TTime timenow;
       
  4688     timenow.HomeTime();
       
  4689     TInt64 time = timenow.Int64();
       
  4690     TBuf8<50> data;
       
  4691     data.AppendNum(time);
       
  4692     LOG_WRITE( "CBrowserAppUi::WriteUpdateFile - write the current time in update file" );
       
  4693     updatefile.Write(data);
       
  4694     updatefile.Close();
       
  4695     }
       
  4696 
       
  4697 // ---------------------------------------------------------
       
  4698 // CBrowserAppUi::DeleteUpdateFile
       
  4699 // ---------------------------------------------------------
       
  4700 void CBrowserAppUi::DeleteUpdateFile()
       
  4701     {
       
  4702     TBuf<KMaxFileName> privatePath;
       
  4703     TBuf<KMaxFileName> updateFileName;
       
  4704     iFs.PrivatePath( privatePath );
       
  4705     updateFileName.Copy( privatePath );
       
  4706     updateFileName.Append( KUpdateFileName );
       
  4707     iFs.Delete(updateFileName);  
       
  4708     }
       
  4709 
       
  4710 // ---------------------------------------------------------
       
  4711 // CBrowserAppUi::ReadUpdateFile
       
  4712 // ---------------------------------------------------------
       
  4713 TInt64 CBrowserAppUi::ReadUpdateFile()
       
  4714     {
       
  4715     TBuf<KMaxFileName> privatePath;
       
  4716     TBuf<KMaxFileName> updateFileName;
       
  4717     //Get the private path then append the filename
       
  4718     iFs.PrivatePath( privatePath );
       
  4719     updateFileName.Copy( privatePath );
       
  4720     updateFileName.Append( KUpdateFileName );
       
  4721     RFile updatefile;
       
  4722     TInt err = updatefile.Open( iFs, updateFileName, EFileRead );
       
  4723     TInt64 dataValue = 0;
       
  4724     //If file is found
       
  4725     if ( err != KErrNotFound ) 
       
  4726         {
       
  4727         TBuf8<50> readBuf;
       
  4728         err = updatefile.Read(readBuf);
       
  4729         updatefile.Close();
       
  4730         if((err == KErrNone) && (readBuf.Length()>NULL))
       
  4731             {
       
  4732             //Convert from TBuf8 to TInt64
       
  4733             TLex8 lex(readBuf);
       
  4734             lex.Val(dataValue);
       
  4735             }
       
  4736         }        
       
  4737     return dataValue;
       
  4738     }
       
  4739 #endif
       
  4740 
       
  4741 TBool CBrowserAppUi::IsSameWinApp(TUid aMessageUid)
       
  4742 {      
       
  4743     TInt nElements = sizeof(mArrayOfExternalAppUid)/sizeof(TInt);
       
  4744     for(TInt nIndex = 0;nIndex < nElements; nIndex++)
       
  4745     {
       
  4746         if(aMessageUid == TUid::Uid(mArrayOfExternalAppUid[nIndex]))
       
  4747         {
       
  4748         return ETrue; 
       
  4749         }
       
  4750     }
       
  4751     return EFalse;
       
  4752 }
       
  4753 // End of File