Revision: 200937 PDK_3.0.a
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 24 Sep 2009 12:53:48 +0300
changeset 11 c8a366e56285
parent 10 a359256acfc6
child 12 f177fdcb8b3a
child 15 60c5402cb945
Revision: 200937 Kit: 200939
browserutilities/browserdialogsprovider/Inc/BrowserSelectElementDlg.h
browserutilities/browserdialogsprovider/Src/BrowserSelectElementDlg.cpp
browserutilities/downloadmgr/DownloadMgrServEng/Src/HttpDownload.cpp
browserutilities/downloadmgr/DownloadMgrUiLib/Src/CDownloadMgrUiDownloadsList.cpp
browserutilities/downloadmgr/DownloadMgrUiLib/Src/CDownloadsListDlg.cpp
browserutilities/webutils/conf/webutils.confml
codhandler/codeng/src/CodEngBase.cpp
web_plat/browser_platform_api/inc/Browser_platform_variant.hrh
web_plat/launcher_api/inc/BrowserOverriddenSettings.h
web_plat/widget_registry_api/inc/WidgetRegistryConstants.h
web_pub/browser_control_api/inc/BrCtlDefs.h
web_pub/browser_control_api/inc/BrCtlDialogsProvider.h
web_pub/browser_plugin_api/inc/npapi.h
web_pub/download_mgr_ui_api/inc/CDownloadMgrUiDownloadsList.h
web_pub/download_mgr_ui_api/inc/DownloadsListDlgObserver.h
web_pub/settings_api/inc/BrowserUiSDKCRKeys.h
webengine/device/inc/DeviceLiwBinding.h
webengine/device/src/DeviceLiwBinding.cpp
webengine/memoryplugin/src/memoryplugin.cpp
webengine/osswebengine/DerivedSources/WebCore/HTMLNames.cpp
webengine/osswebengine/DerivedSources/WebCore/XMLNames.cpp
webengine/osswebengine/WebCore/dom/QualifiedName.cpp
webengine/osswebengine/WebCore/loader/FrameLoader.cpp
webengine/osswebengine/WebCore/platform/DeprecatedString.cpp
webengine/osswebengine/WebCore/platform/TextEncoding.cpp
webengine/osswebengine/WebCore/platform/TextEncodingRegistry.cpp
webengine/osswebengine/WebCore/platform/Timer.cpp
webengine/osswebengine/WebCore/platform/Timer.h
webengine/osswebengine/WebCore/platform/network/symbian/HttpDownload.cpp
webengine/osswebengine/WebCore/platform/network/symbian/HttpSessionManager.cpp
webengine/osswebengine/WebCore/platform/network/symbian/HttpUiCallbacks.cpp
webengine/osswebengine/WebCore/platform/network/symbian/SelfDownloadContentHandler.cpp
webengine/osswebengine/WebCore/platform/network/symbian/SelfDownloadContentHandler.h
webengine/osswebengine/WebCore/platform/symbian/OOMHandler.cpp
webengine/osswebengine/WebCore/platform/symbian/OOMHandler.h
webengine/osswebengine/WebCore/platform/symbian/OOMStopper.cpp
webengine/osswebengine/WebCore/platform/symbian/OOMStopper.h
webengine/osswebengine/WebCore/platform/symbian/PlatformKeyEventSymbian.cpp
webengine/osswebengine/WebCore/platform/symbian/PopupMenuSymbian.cpp
webengine/osswebengine/WebCore/platform/symbian/SharedTimerSymbian.cpp
webengine/osswebengine/WebCore/platform/symbian/StaticObjectsContainer.cpp
webengine/osswebengine/WebCore/platform/symbian/StaticObjectsContainer.h
webengine/osswebengine/WebCore/platform/symbian/TemporaryLinkStubsSymbian.cpp
webengine/osswebengine/WebCore/platform/symbian/bitmap/AnimationDecoder.cpp
webengine/osswebengine/WebCore/platform/symbian/bitmap/AnimationDecoder.h
webengine/osswebengine/WebCore/platform/symbian/bitmap/AnimationDecoderWrapped.cpp
webengine/osswebengine/WebCore/platform/symbian/bitmap/AnimationDecoderWrapped.h
webengine/osswebengine/WebCore/platform/symbian/bitmap/MaskedBitmap.cpp
webengine/osswebengine/WebCore/platform/symbian/bitmap/MaskedBitmap.h
webengine/osswebengine/WebCore/rendering/RenderStyle.cpp
webengine/osswebengine/WebKit/s60/data/Webkit.rss
webengine/osswebengine/WebKit/s60/group/webcore/platform/platform.mmp
webengine/osswebengine/WebKit/s60/loc/Webkit.loc
webengine/osswebengine/WebKit/s60/plugins/NpnImplementation.cpp
webengine/osswebengine/WebKit/s60/plugins/PluginSkin.cpp
webengine/osswebengine/WebKit/s60/plugins/PluginSkin.h
webengine/osswebengine/WebKit/s60/plugins/PluginStream.cpp
webengine/osswebengine/WebKit/s60/plugins/PluginStreamLoaderClient.cpp
webengine/osswebengine/WebKit/s60/plugins/PluginWin.cpp
webengine/osswebengine/WebKit/s60/plugins/PluginWin.h
webengine/osswebengine/WebKit/s60/webcoresupport/WebEditorClient.cpp
webengine/osswebengine/WebKit/s60/webcoresupport/WebEditorClient.h
webengine/osswebengine/WebKit/s60/webview/BrCtl.cpp
webengine/osswebengine/WebKit/s60/webview/SettingsContainer.cpp
webengine/osswebengine/WebKit/s60/webview/WebCursor.cpp
webengine/osswebengine/WebKit/s60/webview/WebCursor.h
webengine/osswebengine/WebKit/s60/webview/WebFepTextEditor.cpp
webengine/osswebengine/WebKit/s60/webview/WebPointerEventHandler.cpp
webengine/osswebengine/WebKit/s60/webview/WebPolicyManager.cpp
webengine/osswebengine/WebKit/s60/webview/WebView.cpp
webengine/osswebengine/WebKit/s60/webview/WebView.h
webengine/osswebengine/WebKit/s60/webview/WmlResourceLoaderClient.cpp
webengine/osswebengine/cache/conf/httpcachemanager.confml
webengine/osswebengine/cache/conf/httpcachemanager_101F8557.crml
webengine/osswebengine/cache/group/BrowserCache.mmp
webengine/osswebengine/cache/inc/HttpCacheEntry.h
webengine/osswebengine/cache/inc/HttpCacheFileWriteHandler.h
webengine/osswebengine/cache/inc/HttpCacheHandler.h
webengine/osswebengine/cache/inc/HttpCacheLookupTable.h
webengine/osswebengine/cache/inc/HttpCacheManager.h
webengine/osswebengine/cache/inc/HttpCacheObserver.h
webengine/osswebengine/cache/inc/HttpCachePostponeWriteUtilities.h
webengine/osswebengine/cache/inc/HttpCacheStreamHandler.h
webengine/osswebengine/cache/inc/HttpCacheUtil.h
webengine/osswebengine/cache/src/HttpCacheEntry.cpp
webengine/osswebengine/cache/src/HttpCacheEvictionHandler.cpp
webengine/osswebengine/cache/src/HttpCacheFileWriteHandler.cpp
webengine/osswebengine/cache/src/HttpCacheHandler.cpp
webengine/osswebengine/cache/src/HttpCacheLookupTable.cpp
webengine/osswebengine/cache/src/HttpCacheManager.cpp
webengine/osswebengine/cache/src/HttpCacheObserver.cpp
webengine/osswebengine/cache/src/HttpCachePostponeWriteUtilities.cpp
webengine/osswebengine/cache/src/HttpCacheStreamHandler.cpp
webengine/osswebengine/cache/src/HttpCacheUtil.cpp
webengine/pagescaler/src/minimap.cpp
webengine/widgetinstaller/Inc/WidgetConfigHandler.h
webengine/widgetinstaller/Src/WidgetBackupRegistryXml.cpp
webengine/widgetinstaller/Src/WidgetConfigHandler.cpp
webengine/widgetregistry/Server/src/WidgetEntry.cpp
webengine/widgetregistry/Server/src/WidgetRegistry.cpp
webengine/widgetregistry/Server/src/WidgetRegistryXml.cpp
webengine/wmlengine/src/MVC/include/MVCView.h
webengine/wmlengine/src/MVC/src/MVCView.cpp
webengine/wrtharvester/group/wrtharvester.mmp
webengine/wrtharvester/inc/wrtharvester.h
webengine/wrtharvester/inc/wrtusbhandler.h
webengine/wrtharvester/src/wrtharvester.cpp
webengine/wrtharvester/src/wrtharvesterpsnotifier.cpp
webengine/wrtharvester/src/wrtusbhandler.cpp
widgets/widgetapp/inc/WidgetUiWindow.h
widgets/widgetapp/inc/WidgetUiWindowManager.h
widgets/widgetapp/inc/WidgetUiWindowView.h
widgets/widgetapp/src/WidgetUiObserver.cpp
widgets/widgetapp/src/WidgetUiWindow.cpp
widgets/widgetapp/src/WidgetUiWindowContainer.cpp
widgets/widgetapp/src/WidgetUiWindowManager.cpp
widgets/widgetapp/src/WidgetUiWindowView.cpp
widgets/widgetinstaller/conf/widgetinstaller.confml
widgets/widgetinstaller/conf/widgetinstaller_1028281F.crml
widgets/widgetinstaller/inc/WidgetInstallerInternalCRKeys.h
widgets/widgetinstaller/inc/WidgetUIConfigHandler.h
widgets/widgetinstaller/src/WidgetUIConfigHandler.cpp
widgets/widgetinstaller/src/WidgetUIOperationsWatcher.cpp
--- a/browserutilities/browserdialogsprovider/Inc/BrowserSelectElementDlg.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/browserutilities/browserdialogsprovider/Inc/BrowserSelectElementDlg.h	Thu Sep 24 12:53:48 2009 +0300
@@ -128,6 +128,8 @@
         CArrayFix<TBrCtlSelectOptionData>&  iOptionsOrg;    // not owned
 
         CBrowserDialogsProviderAsyncExit*   iAsyncExit;      // owned
+        
+        TInt iResource;
     };
 
 #endif  //BROWSERSELECTELEMENTDLG_H
--- a/browserutilities/browserdialogsprovider/Src/BrowserSelectElementDlg.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/browserutilities/browserdialogsprovider/Src/BrowserSelectElementDlg.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -79,9 +79,16 @@
     {
     // Create the active object for this object
     iAsyncExit = CBrowserDialogsProviderAsyncExit::NewL( *this );
-
     // Resource
-    TInt resource = R_AVKON_SOFTKEYS_OK_CANCEL__MARK;
+    iResource = R_AVKON_SOFTKEYS_OK_CANCEL__MARK;
+    // Enable find pane
+    TBool bIsFindPaneEnabled = (iBrCtlSelectOptionType & 0x100) ? ETrue : EFalse ;
+    
+    if(bIsFindPaneEnabled)
+        {
+        iBrCtlSelectOptionType = (TBrCtlSelectOptionType )(iBrCtlSelectOptionType & 0xEFF) ;
+        }
+    
     if (iBrCtlSelectOptionType == ESelectTypeSingle )
         {
         // It was decided that Radio Buttons add little value and unnecessary 
@@ -90,7 +97,7 @@
         }
     else if ( iBrCtlSelectOptionType == ESelectTypeOkOnly ) 
         {
-        resource = R_AVKON_SOFTKEYS_OK_EMPTY__OK;
+        iResource = R_AVKON_SOFTKEYS_OK_EMPTY__OK;
         }
 
     // Construct listbox and popup
@@ -100,7 +107,7 @@
             new ( ELeave ) CBrowserSelectElementListBox(
                                                     iBrCtlSelectOptionType, 
                                                     iOptionsOrg );
-        CAknPopupList::ConstructL( iListBox, resource, 
+        CAknPopupList::ConstructL( iListBox, iResource, 
                                                 AknPopupLayouts::EMenuWindow );
         iListBox->ConstructL( *this );
         iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
@@ -120,6 +127,7 @@
                         new ( ELeave ) CDesCArrayFlat ( KGranularityMedium );
 
         CleanupStack::PushL(items);
+        iResource = R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT;
         for ( TInt i = 0; i<iOptionsOrg.Count(); i++ )
             {
             items->AppendL( iOptionsOrg.At(i).Text() );
@@ -129,12 +137,8 @@
         iHistoryList = new ( ELeave ) CAknSinglePopupMenuStyleListBox;
 
         // create popup
-        CAknPopupList::ConstructL( iHistoryList, 
-                                            R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT, 
-                                            AknPopupLayouts::EMenuWindow );
-        
-        
-        
+        CAknPopupList::ConstructL( iHistoryList, iResource, AknPopupLayouts::EMenuWindow );
+                        
         iHistoryList->ConstructL( this, EAknListBoxSelectionList );
         iHistoryList->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
         iHistoryList->CreateScrollBarFrameL( ETrue );
@@ -142,7 +146,7 @@
                     ( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
         
         CTextListBoxModel* model = iHistoryList->Model();
-    TBool hasItems = iOptionsOrg.Count();
+        TBool hasItems = iOptionsOrg.Count();
         if ( hasItems  ) 
             {
             model->SetItemTextArray( items );
@@ -160,8 +164,14 @@
           iHistoryList->SetCurrentItemIndex( 0 );
           }
         SetTitleL( aTitle );
-        EnableFind();
-        }    
+        if (bIsFindPaneEnabled)
+          {
+          EnableFind();
+          STATIC_CAST( CAknFilteredTextListBoxModel*,
+                    ListBox()->Model())->Filter()->SetObserver( this );
+          }        
+        }  
+    
     }
 
 //-----------------------------------------------------------------------------
@@ -202,14 +212,29 @@
                     aEventType == MCoeControlObserver::EEventRequestCancel ) )
         {
         AttemptExitL( EFalse );
-        }
-    //Some text has been written to findbox, in filtered selectioncase 
-    //highlight selectable item.
+        }   
     else if ( aControl == ((CCoeControl*)FindBox()) && 
-        aEventType == MCoeControlObserver::EEventStateChanged)
-        {
-        STATIC_CAST ( CBrowserSelectElementListBox*,
+        aEventType == MCoeControlObserver::EEventStateChanged )
+        {        
+        CEikButtonGroupContainer * cbaGroup = CEikButtonGroupContainer::Current();
+        /*Some text has been written to findbox, in filtered selectioncase 
+          highlight selectable item. */ 
+        if ( iBrCtlSelectOptionType != ESelectTypeNone)
+            {
+            STATIC_CAST ( CBrowserSelectElementListBox*,
                                         ListBox() )->HighlightSelectableItem();
+            }
+        if ( iBrCtlSelectOptionType == ESelectTypeOkOnly ) return;            
+        if ( STATIC_CAST( CAknFilteredTextListBoxModel*, ListBox()->Model())->Filter()->FilteredNumberOfItems() == 0 ) 
+            {
+            cbaGroup->SetCommandSetL(R_AVKON_SOFTKEYS_CANCEL); 
+            cbaGroup->DrawNow();             
+            } 
+        else  
+            {
+            cbaGroup->SetCommandSetL(iResource); 
+            cbaGroup->DrawNow(); 
+            }        
         }
     }
 
--- a/browserutilities/downloadmgr/DownloadMgrServEng/Src/HttpDownload.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/browserutilities/downloadmgr/DownloadMgrServEng/Src/HttpDownload.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -4142,6 +4142,10 @@
     READ_INT_L( inFile, iTargetApp );
     iStorage->LoadStorageInfoL( inFile );
     ReadHBufCL( inFile, iDlName );
+	if ( *iDlName == KNullDesC )
+	   {
+	    User::Leave( KErrNotSupported );
+	   }
     ReadHBufCL( inFile, iHashedMsgBody );
     READ_INT_L( inFile, iCodDownload );
     READ_INT_L( inFile, iNoMedia );
--- a/browserutilities/downloadmgr/DownloadMgrUiLib/Src/CDownloadMgrUiDownloadsList.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/browserutilities/downloadmgr/DownloadMgrUiLib/Src/CDownloadMgrUiDownloadsList.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -406,9 +406,16 @@
         }
     else
         {
-        iDialog = NULL;
-        // Reset owner pointer to this object.
-        if ( iReferer )
+            if( !iDownloadsList.GetDownloadHide() )
+                {
+                delete iDialog;
+                }
+           
+            iDownloadsList.SetDownloadListHide( EFalse );
+      
+            iDialog = NULL;
+            // Reset owner pointer to this object.
+       	    if ( iReferer )
             {
             *iReferer = 0;
             CLOG_WRITE(" referer set was to 0");
@@ -2544,6 +2551,14 @@
         }
     }
 
+// -----------------------------------------------------------------------------
+// CDownloadMgrUiDownloadsList::SetDownloadListHide
+// -----------------------------------------------------------------------------
+//
+void CDownloadMgrUiDownloadsList::SetDownloadListHide( TBool aHide )
+    {
+    iDownloadListHide = aHide;
+    }
 #ifdef __WINS__
 #include <commdb.h>
 #include <AknLists.h>
--- a/browserutilities/downloadmgr/DownloadMgrUiLib/Src/CDownloadsListDlg.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/browserutilities/downloadmgr/DownloadMgrUiLib/Src/CDownloadsListDlg.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -144,7 +144,7 @@
     {
     CLOG_ENTERFN("CDownloadsListDlg::~CDownloadsListDlg");
 
-
+    iDlgObserver.SetDownloadListHide( ETrue );
     if ( iMenuBar )
         {
         HideMenu();
Binary file browserutilities/webutils/conf/webutils.confml has changed
--- a/codhandler/codeng/src/CodEngBase.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/codhandler/codeng/src/CodEngBase.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -641,6 +641,7 @@
             
         case EFetch:
         case ENotify:
+		case EProductNotify:
             {
             // Instant abort, without any further processing
             // (no install, no notify).
--- a/web_plat/browser_platform_api/inc/Browser_platform_variant.hrh	Thu Aug 27 07:44:59 2009 +0300
+++ b/web_plat/browser_platform_api/inc/Browser_platform_variant.hrh	Thu Sep 24 12:53:48 2009 +0300
@@ -64,7 +64,7 @@
 */ 
 // #elif defined(__S60_51__)
 // un-comment following line for 5.1/TB9.1 platforms
-//#define __PLATFORM_VERSION_51__
+// #define __PLATFORM_VERSION_51__
 
 /*
 * ===================
@@ -74,7 +74,7 @@
 // #elif defined(__S60_52__)
 
 // un-comment following line for 5.2/TB9.2 platforms
- #define __PLATFORM_VERSION_52__
+#define __PLATFORM_VERSION_52__
 //
 #endif
 
@@ -148,6 +148,9 @@
 // Enable/Disable compilation of some of Search Integration specific code 
 #define BRDO_SEARCH_INTEGRATION_FF
 
+// Defines whether SAPI Security Manager Prompt Enhancement is available
+#define BRDO_SEC_MGR_PROMPT_ENHANCEMENT_FF
+
 /*
 * ===================
 *        S60 3.23
@@ -176,6 +179,9 @@
 // Disable compilation of some of Search Integration specific code
 #undef BRDO_SEARCH_INTEGRATION_FF
 
+// Defines whether SAPI Security Manager Prompt Enhancement is available
+#undef BRDO_SEC_MGR_PROMPT_ENHANCEMENT_FF
+
 // Missing from 3.23 platform_paths.hrh
 
 // Location, where the middleware layer localization .loc file should be exported
@@ -231,9 +237,15 @@
 // Defines WRT widgets feature to publish on homescreen
 #undef BRDO_WRT_HS_FF
 
+// Gallery App is present
+#define BRDO_APP_GALLERY_SUPPORTED_FF
+
 // Disable compilation of some of Search Integration specific code
 #undef BRDO_SEARCH_INTEGRATION_FF
 
+// Defines whether SAPI Security Manager Prompt Enhancement is available
+#undef BRDO_SEC_MGR_PROMPT_ENHANCEMENT_FF
+
 #if __GNUC__ >= 3
 #define BRDO_ADDED_EXPORT_LOCATION(exported) MW_LAYER_DOMAIN_EXPORT_PATH(../../platform/mw/exported)
 #else
@@ -301,6 +313,9 @@
 */ 
 #elif defined(__PLATFORM_VERSION_51__)
 
+// Defines whether SAPI Security Manager Prompt Enhancement is available
+#undef BRDO_SEC_MGR_PROMPT_ENHANCEMENT_FF
+
 #define BRDO_BROWSER_50_FF
 #define BRDO_BROWSER_51_FF
 
@@ -329,6 +344,9 @@
 */ 
 #elif defined(__PLATFORM_VERSION_52__)
 
+// Defines whether SAPI Security Manager Prompt Enhancement is available
+#undef BRDO_SEC_MGR_PROMPT_ENHANCEMENT_FF
+
 #define BRDO_BROWSER_50_FF
 #define BRDO_BROWSER_51_FF
 #define BRDO_BROWSER_52_FF
--- a/web_plat/launcher_api/inc/BrowserOverriddenSettings.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/web_plat/launcher_api/inc/BrowserOverriddenSettings.h	Thu Sep 24 12:53:48 2009 +0300
@@ -97,10 +97,11 @@
    TUint iFontSize;
    //stores the value for the small screen setting can be 0 or 1
    TUint iFullScreen;
-   // Custom access point provided by the operator. If specified, contains an id of a read only
-   // access point what is then set as default  and it cannot be changed manually. If not 
-   // defined, operator menu works as before.
-   // from operator menu( 0 - not specified, otherwise contains the access point id)
+   // Custom access point provided by the operator. 
+   // If specified, contains a WAP id of a read only access point,  
+   // which is then set as the default and it cannot be changed manually by the user. 
+   // If not defined, operator menu works as before.
+   // From the operator menu( 0 = not specified, otherwise contains the WAP id of the access point.)
    TUint iCustomAp;
    // Allow the contextId of the call to be passed as a parameter
    TUint iContextId;   
--- a/web_plat/widget_registry_api/inc/WidgetRegistryConstants.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/web_plat/widget_registry_api/inc/WidgetRegistryConstants.h	Thu Sep 24 12:53:48 2009 +0300
@@ -127,6 +127,7 @@
     ENokiaWidget,               // int 0 (not Nokia DTD) or 1 (Nokia DTD)
     EMiniViewEnable,            //optional; int internally 0 0r 1
     EBlanketPermGranted,              //optional; int internally 0 0r 1
+    EPreInstalled,              // optional; int internally 0 or 1
 
     // end property list, begin special values
     EWidgetPropertyIdCount,     // must be at end of properties
--- a/web_pub/browser_control_api/inc/BrCtlDefs.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/web_pub/browser_control_api/inc/BrCtlDefs.h	Thu Sep 24 12:53:48 2009 +0300
@@ -466,6 +466,10 @@
             ESettingsZoomLevelMin,          ///< Minimum Zoom level supported
             ESettingsZoomLevelMax,          ///< Maximum Zoom level supported
             ESettingsZoomLevelDefault,      ///< Default Zoom level for new page
+            /*
+            * Browser cursor show mode -- some phone doesn't have cursor inside Browser
+            */
+            ESettingsCursorShowMode,
             ESettingsMaxEnum              ///< Must be last one
             };
 
@@ -816,8 +820,12 @@
         EFormDataOnly,
         EFormDataPlusPassword
         };
+    enum TCursorSettings
+        {
+        ENoCursor = 0,
+        EDefaultCursor
+        };
     };
-
 #endif      // BRCTLDEFS_H
 
 // End of File
--- a/web_pub/browser_control_api/inc/BrCtlDialogsProvider.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/web_pub/browser_control_api/inc/BrCtlDialogsProvider.h	Thu Sep 24 12:53:48 2009 +0300
@@ -36,7 +36,15 @@
     * OK softkey is available
     * Cancel button is not available
     */
-    ESelectTypeOkOnly
+    ESelectTypeOkOnly,
+    /**
+     * Added enumeration ESelectTypeWithFindPane at offset of 0x100 so that
+     * the limit of different types of dialog boxes can be upto 256.
+     * Any user who wants a list with find pane must "|" with a defined type
+     * above like ESelectTypeNone | ESelectTypeWithFindPane to obtain a list
+     * box with find pane.
+     */
+    ESelectTypeWithFindPane = 0x100
     };
 
 /**
--- a/web_pub/browser_plugin_api/inc/npapi.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/web_pub/browser_plugin_api/inc/npapi.h	Thu Sep 24 12:53:48 2009 +0300
@@ -413,7 +413,8 @@
     
     /* Get the id of the currently connected access point */
     NPNNetworkAccess,
-    NPNVGenericParameter        
+    NPNVGenericParameter,
+    NPNVSupportsWindowless
 } NPNVariable;
 
 #ifdef GENERIC_CONTEXTS
--- a/web_pub/download_mgr_ui_api/inc/CDownloadMgrUiDownloadsList.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/web_pub/download_mgr_ui_api/inc/CDownloadMgrUiDownloadsList.h	Thu Sep 24 12:53:48 2009 +0300
@@ -146,6 +146,17 @@
         */
         inline TBool IsProgressiveDownloadEnabled() {return iProgressiveDownload; }
         
+        /**
+        * Gets the value of downloadlist hide
+        * @return TBool 
+        */
+        inline TBool GetDownloadHide() { return iDownloadListHide; }
+
+        /**
+        * Sets the value of downloadlist hide
+        * @return void 
+        */
+        virtual void SetDownloadListHide( TBool aHide );
 
     public: // Functions from CDownloadMgrUiBase
 
@@ -256,6 +267,7 @@
 		TBool						iIsCancelInProgress;
 		TBool                       iPlatformSupportsGallery;
 
+        TBool                       iDownloadListHide;
     private: // Friend classes
 
         friend class CDownloadsListExtension;
--- a/web_pub/download_mgr_ui_api/inc/DownloadsListDlgObserver.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/web_pub/download_mgr_ui_api/inc/DownloadsListDlgObserver.h	Thu Sep 24 12:53:48 2009 +0300
@@ -61,6 +61,10 @@
         */
         virtual TKeyResponse OfferKeyEventL( CDownloadsListDlg& aDialog, const TKeyEvent& aKeyEvent, TEventCode aType ) = 0;
 
+        /**
+        * setting the downloadlist hide to the observer.
+        */
+        virtual void SetDownloadListHide( TBool aHide ) = 0;
     };
 
 #endif /* DOWNLOADSLISTDLGOBSERVER_H */
--- a/web_pub/settings_api/inc/BrowserUiSDKCRKeys.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/web_pub/settings_api/inc/BrowserUiSDKCRKeys.h	Thu Sep 24 12:53:48 2009 +0300
@@ -11,7 +11,7 @@
 *
 * Contributors:
 *
-* Description: 
+* Description:
 *
 */
 #ifndef BROWSERUISDKCRKEYS_H
@@ -69,7 +69,7 @@
 // Any String value
 const TUint32 KBrowserSelfDownloadContentTypes = 0x0000001D;
 
-enum TBrowserCenRepApSelectionModeValues 
+enum TBrowserCenRepApSelectionModeValues
     {
     EBrowserCenRepApSelModeUserDefined = 0, // User defined
     EBrowserCenRepApSelModeAlwaysAsk = 1,   // Always ask
@@ -99,8 +99,8 @@
 *
 */
 
-// Load Content 
-// Valid values: 
+// Load Content
+// Valid values:
 // If flash plugin is present: 0 = Text only, 1 = Images,No flash, 2 = All
 // If flash plugin is not present 0 = Text only, 1 = All
 const TUint32 KBrowserNGImagesEnabled =       	0x00000025;
@@ -139,7 +139,7 @@
      EBrowserCenRepBookmarks = 3            // Bookmarks
 };
 
-// Integer type value to indicate what type of Home Page 
+// Integer type value to indicate what type of Home Page
 // should be launched when "Home" option is activated.
 // Valid values:
 // AccessPoint = 0,
@@ -180,7 +180,7 @@
 // Any String value
 const TUint32 KBrowserNGShortCutFuncHomePg =    0x0000003A;
 
-// Short cut keys for function: Go to bookmark 
+// Short cut keys for function: Go to bookmark
 // Any String value
 const TUint32 KBrowserNGShortCutFuncBkMark =    0x0000003B;
 
@@ -219,12 +219,12 @@
 const TUint32 KBrowserNGRotateDisplay =          0x00000044;
 
 // Setting to enable "Open download" menu item
-// Valid value 0 = no, 1 = yes 
+// Valid value 0 = no, 1 = yes
 const TUint32 KBrowserNGOpenDownloads =          0x00000045;
 
 //DEPRECATED/OBSOLETE: Smart Link.
 // Valid values: 0 = off 1 = on
-const TUint32 KBrowserNGSmartLink = 		  	0x00000046;    
+const TUint32 KBrowserNGSmartLink = 		  	0x00000046;
 
 // Setting to enable updating while roaming
 // Valid values: 0 = off 1 = on
@@ -265,7 +265,7 @@
 
 //Setting for Toolbar Button 2 Command
 const TUint32 KToolbarButton2Cmd =            0x00000057;
-             
+
 //Setting for Toolbar Button 3 Command
 const TUint32 KToolbarButton3Cmd =            0x00000058;
 
@@ -327,24 +327,24 @@
 // Valid values: 0 = disabled 1 = log to file 1 = log to UI console
 const TUint32 KBrowserNGScriptLog =   	0x00000070;
 
-// KBrowserNGZoomMin represents the minimum percentage zoom level to be 
-// supported by the browser. 
+// KBrowserNGZoomMin represents the minimum percentage zoom level to be
+// supported by the browser.
 // Valid values: 10 to 2000, default value for this field 10
 const TUint32 KBrowserNGZoomMin =   	0x00000071;
 
 // The browser supports zoom levels between 10-2000 percent.
-// KBrowserNGZoomMax represents the maximum percentage zoom level to be 
+// KBrowserNGZoomMax represents the maximum percentage zoom level to be
 // supported by the browser.
 // Valid values: 10 to 2000, default value for this field 200
 const TUint32 KBrowserNGZoomMax =   	0x00000072;
 
-// KBrowserNGZoomDefault represents the default percentage zoom level to be 
+// KBrowserNGZoomDefault represents the default percentage zoom level to be
 // supported by the browser when opening a webpage for the first time.
 // Valid values: 10 to 2000, default value for this field 100
 const TUint32 KBrowserNGZoomDefault =  0x00000073;
 
-// KBrowserNGMaxRecentUrls is the number of Recent URLs to be shown in 
-// the pop up list 
+// KBrowserNGMaxRecentUrls is the number of Recent URLs to be shown in
+// the pop up list
 // Valid values: 1 to 10, default value for this field is 6
 const TUint32 KBrowserNGMaxRecentUrls = 0x00000074;
 
@@ -380,22 +380,22 @@
 const TUint32 KBrowserServiceUrl = 0x0000007B;
 
 // KBrowserFirstBoot
-// Valid values: 1 if browser first boot is not done yet, other 0  
+// Valid values: 1 if browser first boot is not done yet, other 0
 const TUint32 KBrowserFirstBoot = 0x0000007C;
 
-// KBrowserSearch TInt if browser search is present 
+// KBrowserSearch TInt if browser search is present
 // Valid values: 0, 1
 const TUint32 KBrowserSearch = 0x0000007D;
 
 // KBrowserServices TInt if browser service is present
-// Valid values: 0,1 
+// Valid values: 0,1
 const TUint32 KBrowserServices = 0x0000007E;
 
 // KBrowserSearchAppUid - browser Search Application UID
 // Valid values:any positive 32-bit integer value
 const TUint32 KBrowserSearchAppUid= 0x0000007F;
 
-// Search Application View UID for selection of Default 
+// Search Application View UID for selection of Default
 // Search Provider.
 // Valid values:any positive 32-bit integer value.
 const TUint32 KBrowserSearchProviderSettingViewId = 0x00000080;
@@ -404,4 +404,6 @@
 // Used by Search Scheme Handler.
 const TUint32 KBrowserSearchProviderUrl = 0x00000081;
 
+// Cursormode which defines the cursor display supported status depends on phones.
+const TUint32 KBrowserCursorShowMode =          0x00000082;
 #endif      // BROWSERUISDKCRKEYS_H
\ No newline at end of file
--- a/webengine/device/inc/DeviceLiwBinding.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/device/inc/DeviceLiwBinding.h	Thu Sep 24 12:53:48 2009 +0300
@@ -114,8 +114,8 @@
             * @since 5.0
             **/
             void SetUid( const TUint& aValue);
-            
-            CRTSecMgrScriptSession* GetSecuritySession () 
+
+            CRTSecMgrScriptSession* GetSecuritySession ()
             {
                 return m_scriptSession;
             }
@@ -165,14 +165,14 @@
             **/
             TBool JsVal2LiwVariant( ExecState* exec, JSValue* value,
                 TLiwVariant& variant );
-#ifdef SECURITYMANAGER_PROMPT_ENHANCEMENT
+#ifdef BRDO_SEC_MGR_PROMPT_ENHANCEMENT_FF
             /**
             * Set Widget Display Name
             * @return none
             * @since 5.0
             **/
             void SetAppName();
-#endif            
+#endif
         private:
 
             CLiwServiceHandler* m_serviceHandler;   // Owned
--- a/webengine/device/src/DeviceLiwBinding.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/device/src/DeviceLiwBinding.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -123,7 +123,7 @@
             {
             User::Leave( KErrGeneral );
             }
-#ifdef SECURITYMANAGER_PROMPT_ENHANCEMENT
+#ifdef BRDO_SEC_MGR_PROMPT_ENHANCEMENT_FF
 		m_scriptSession->SetPromptOption(RTPROMPTUI_PROVIDER);   //  This is for setting the new prompting method
 #endif
         CleanupStack::PopAndDestroy( trust );
@@ -903,9 +903,9 @@
             jsList.append( jsNumber( variant.AsMap()->Count() ) );
             JSObject * rval = new DeviceLiwMap(exec->lexicalInterpreter()->builtinArray()->construct(
                 exec, jsList ), variant.AsMap(), this);
-            
+
             DevicePrivateBase* pMapData = (static_cast<DeviceLiwMap*> (rval))->getMapData();
-            
+
             for ( TInt i = 0; i < variant.AsMap()->Count(); i++ )
                 {
                 TBuf8<KMaxKeySize> name;
@@ -924,12 +924,12 @@
                             DevicePrivateBase* itData = itObj->getIterableData();
                             itData->SetParent( pMapData );
                             pMapData->AddChild( itData );
-                            }                   
-                        else if ( v.TypeId() == EVariantTypeMap )    
+                            }
+                        else if ( v.TypeId() == EVariantTypeMap )
                             {
                             DeviceLiwMap* mapObj = static_cast<DeviceLiwMap*> (jsval);
                             DevicePrivateBase* mapData = mapObj->getMapData();
-                            mapData->SetParent( pMapData ); 
+                            mapData->SetParent( pMapData );
                             pMapData->AddChild( mapData );
                             }
                         }
@@ -1089,23 +1089,23 @@
         {
         TBuf8<KMaxKeySize> name( (*aLiwList)[i].Name() );
         JSValue* jsval = LiwVariant2JsVal( exec, (*aLiwList)[i].Value() );
-        // connect DeviceLiwResult to DeviceLiwIterable  
+        // connect DeviceLiwResult to DeviceLiwIterable
         if ( managed )
-            { 
+            {
             if ( (*aLiwList)[i].Value().TypeId() == EVariantTypeIterable )
                 {
                 DeviceLiwIterable* itObj = static_cast<DeviceLiwIterable*> (jsval);
                 DevicePrivateBase* itData = itObj->getIterableData();
-                itData->SetParent( retData ); 
+                itData->SetParent( retData );
                 retData->AddChild( itData );
                 }
             else if ( (*aLiwList)[i].Value().TypeId() == EVariantTypeMap )
                 {
                 DeviceLiwMap* mapObj = static_cast<DeviceLiwMap*> (jsval);
                 DevicePrivateBase* mapData = mapObj->getMapData();
-                mapData->SetParent( retData ); 
+                mapData->SetParent( retData );
                 retData->AddChild( mapData );
-                }    
+                }
             }
         rval->put( exec, Identifier( (const char*) name.PtrZ() ), jsval);  //??? should call AtL?
         }
@@ -1123,11 +1123,11 @@
 void CDeviceLiwBinding::SetUid( const TUint& aValue)
     {
     m_Uid.iUid = aValue;
-#ifdef SECURITYMANAGER_PROMPT_ENHANCEMENT    
+#ifdef BRDO_SEC_MGR_PROMPT_ENHANCEMENT_FF
     SetAppName();
-#endif    
+#endif
     }
-#ifdef SECURITYMANAGER_PROMPT_ENHANCEMENT
+#ifdef BRDO_SEC_MGR_PROMPT_ENHANCEMENT_FF
 // ----------------------------------------------------------------------------
 // CDeviceLiwBinding::SetAppName
 // Sets the widget display name
@@ -1147,7 +1147,7 @@
         {
         User::Leave( ret );
         }
-    
+
     CWidgetPropertyValue* displayname = widgetregistry.GetWidgetPropertyValueL(m_Uid, EBundleDisplayName );
     User::LeaveIfError(widgetregistry.Disconnect());
     CleanupStack::PopAndDestroy(); //widgetregistry
--- a/webengine/memoryplugin/src/memoryplugin.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/memoryplugin/src/memoryplugin.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -21,6 +21,14 @@
 #include <ecom/implementationproxy.h>
 #include <oommonitorplugin.h>
 
+/*
+ * Note:  Even though we create this plugin to deal with memory events from the system for handling OOM,
+ * there is no code further down the line that actually handles them.  We totally ignore these events.
+ * This is because the system has too high of an OOM threshold.
+ * I.e. the system may only have 6m left and think it's out of memory, however, the browser can still render
+ * many pages in only 6m.  So, these system events are ignored and the browser handles OOM with its own mechanism.
+ * (See OOMStopper and OOMHandler)
+ */
 TAny* CreateBrowserOOMPlugin()
 	{
 	const TUid KBrowserAppUid = { 0x10008d39 };
--- a/webengine/osswebengine/DerivedSources/WebCore/HTMLNames.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/DerivedSources/WebCore/HTMLNames.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -1247,9 +1247,11 @@
     new ((void*)&widthAttr) QualifiedName(nullAtom, widthAttrString, nullAtom);
     new ((void*)&wrapAttr) QualifiedName(nullAtom, wrapAttrString, nullAtom);
 }
+struct cleanupHtmlNames  {
+    ~cleanupHtmlNames() {
+    // This will destroy the AtomicString table
+    // All other atomic string destruction must be done before this call
 
-void remove()
-{
 #ifndef __WINSCW__
     if( initialized ) {
         size_t num(0);
@@ -1563,10 +1565,12 @@
     widthAttrString = "";
     wrapAttrString = "";
 
-	AtomicString::remove();
+    AtomicString::remove();
 
-	initialized = false;
-} //remove()
+    initialized = false;
+    } 
+};
+struct cleanupHtmlNames htmlNames;
 
 } //HTMLNames
 
--- a/webengine/osswebengine/DerivedSources/WebCore/XMLNames.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/DerivedSources/WebCore/XMLNames.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -83,9 +83,8 @@
     new ((void*)&langAttr) QualifiedName(nullAtom, langAttrString, xmlNS);
     new ((void*)&spaceAttr) QualifiedName(nullAtom, spaceAttrString, xmlNS);
 }
-
-void remove()
-{
+struct cleanupXmlNames  {
+    ~cleanupXmlNames() {
 #ifndef __WINSCW__
     if( initialized ) {
         ((AtomicString*)&xmlNamespaceURI)->~AtomicString();
@@ -94,13 +93,15 @@
         ((QualifiedName*)&spaceAttr)->~QualifiedName();
     }
 #endif // __WINSCW__
-    
-	xmlNSString = "";
-	baseAttrString = "";
-	langAttrString = "";
-	spaceAttrString = "";
-	initialized = false;
-}
+ 
+    xmlNSString = "";
+    baseAttrString = "";
+    langAttrString = "";
+    spaceAttrString = "";
+    initialized = false;
+    }
+};
+struct cleanupXmlNames xmlNames;
 
 } }
 
--- a/webengine/osswebengine/WebCore/dom/QualifiedName.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/dom/QualifiedName.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -173,13 +173,16 @@
     }
 }
 
-void QualifiedName::cleanup() 
-{
+
+struct cleanupQualifiedName  {
+    ~cleanupQualifiedName() {
     if( gNameCache ) {
         gNameCache->clear();
         delete gNameCache;
         gNameCache=NULL;
     }
-}
+    }
+};
+struct cleanupQualifiedName qualifiedName;
 
 }
--- a/webengine/osswebengine/WebCore/loader/FrameLoader.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/loader/FrameLoader.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -1961,67 +1961,70 @@
 void FrameLoader::load(const KURL& URL, const String& referrer, FrameLoadType newLoadType,
     const String& frameName, Event* event, PassRefPtr<FormState> formState)
 {
-    bool isFormSubmission = formState;
+    if ( URL != KURL("about:blank") )
+    {
+        bool isFormSubmission = formState;
+        
+        ResourceRequest request(URL);
+        if (!referrer.isEmpty())
+            request.setHTTPReferrer(referrer);
+        addExtraFieldsToRequest(request, true, event || isFormSubmission);
+        if (newLoadType == FrameLoadTypeReload)
+            request.setCachePolicy(ReloadIgnoringCacheData);
     
-    ResourceRequest request(URL);
-    if (!referrer.isEmpty())
-        request.setHTTPReferrer(referrer);
-    addExtraFieldsToRequest(request, true, event || isFormSubmission);
-    if (newLoadType == FrameLoadTypeReload)
-        request.setCachePolicy(ReloadIgnoringCacheData);
-
-    ASSERT(newLoadType != FrameLoadTypeSame);
-
-    NavigationAction action(URL, newLoadType, isFormSubmission, event);
-
-    if (!frameName.isEmpty()) {
-        if (Frame* targetFrame = m_frame->tree()->find(frameName))
-            targetFrame->loader()->load(URL, referrer, newLoadType, String(), event, formState);
-        else
-            checkNewWindowPolicy(action, request, formState, frameName);
-        return;
-    }
-
-    RefPtr<DocumentLoader> oldDocumentLoader = m_documentLoader;
-
-    bool sameURL = shouldTreatURLAsSameAsCurrent(URL);
+        ASSERT(newLoadType != FrameLoadTypeSame);
+    
+        NavigationAction action(URL, newLoadType, isFormSubmission, event);
+    
+        if (!frameName.isEmpty()) {
+            if (Frame* targetFrame = m_frame->tree()->find(frameName))
+                targetFrame->loader()->load(URL, referrer, newLoadType, String(), event, formState);
+            else
+                checkNewWindowPolicy(action, request, formState, frameName);
+            return;
+        }
+    
+        RefPtr<DocumentLoader> oldDocumentLoader = m_documentLoader;
     
-    // Make sure to do scroll to anchor processing even if the URL is
-    // exactly the same so pages with '#' links and DHTML side effects
-    // work properly.
-    if (!isFormSubmission
-        && newLoadType != FrameLoadTypeReload
-        && newLoadType != FrameLoadTypeSame
-        && !shouldReload(URL, url())
-        // We don't want to just scroll if a link from within a
-        // frameset is trying to reload the frameset into _top.
-        && !m_frame->isFrameSet()) {
-
-        // Just do anchor navigation within the existing content.
-        
-        // We don't do this if we are submitting a form, explicitly reloading,
-        // currently displaying a frameset, or if the new URL does not have a fragment.
-        // These rules are based on what KHTML was doing in KHTMLPart::openURL.
+        bool sameURL = shouldTreatURLAsSameAsCurrent(URL);
         
-        // FIXME: What about load types other than Standard and Reload?
-        
-        oldDocumentLoader->setTriggeringAction(action);
-        stopPolicyCheck();
-        checkNavigationPolicy(request, oldDocumentLoader.get(), formState,
-            callContinueFragmentScrollAfterNavigationPolicy, this);
-    } else {
-        // must grab this now, since this load may stop the previous load and clear this flag
-        bool isRedirect = m_quickRedirectComing;
-        load(request, action, newLoadType, formState);
-        if (isRedirect) {
-            m_quickRedirectComing = false;
-            if (m_provisionalDocumentLoader)
-                m_provisionalDocumentLoader->setIsClientRedirect(true);
-        } else if (sameURL)
-            // Example of this case are sites that reload the same URL with a different cookie
-            // driving the generated content, or a master frame with links that drive a target
-            // frame, where the user has clicked on the same link repeatedly.
-            m_loadType = FrameLoadTypeSame;
+        // Make sure to do scroll to anchor processing even if the URL is
+        // exactly the same so pages with '#' links and DHTML side effects
+        // work properly.
+        if (!isFormSubmission
+            && newLoadType != FrameLoadTypeReload
+            && newLoadType != FrameLoadTypeSame
+            && !shouldReload(URL, url())
+            // We don't want to just scroll if a link from within a
+            // frameset is trying to reload the frameset into _top.
+            && !m_frame->isFrameSet()) {
+    
+            // Just do anchor navigation within the existing content.
+            
+            // We don't do this if we are submitting a form, explicitly reloading,
+            // currently displaying a frameset, or if the new URL does not have a fragment.
+            // These rules are based on what KHTML was doing in KHTMLPart::openURL.
+            
+            // FIXME: What about load types other than Standard and Reload?
+            
+            oldDocumentLoader->setTriggeringAction(action);
+            stopPolicyCheck();
+            checkNavigationPolicy(request, oldDocumentLoader.get(), formState,
+                callContinueFragmentScrollAfterNavigationPolicy, this);
+        } else {
+            // must grab this now, since this load may stop the previous load and clear this flag
+            bool isRedirect = m_quickRedirectComing;
+            load(request, action, newLoadType, formState);
+            if (isRedirect) {
+                m_quickRedirectComing = false;
+                if (m_provisionalDocumentLoader)
+                    m_provisionalDocumentLoader->setIsClientRedirect(true);
+            } else if (sameURL)
+                // Example of this case are sites that reload the same URL with a different cookie
+                // driving the generated content, or a master frame with links that drive a target
+                // frame, where the user has clicked on the same link repeatedly.
+                m_loadType = FrameLoadTypeSame;
+        }
     }
 }
 
--- a/webengine/osswebengine/WebCore/platform/DeprecatedString.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/DeprecatedString.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -1803,6 +1803,10 @@
     // Do the format once to get the length.
 #if COMPILER(MSVC) 
     int result = _vscprintf(format, args);
+#elif PLATFORM(SYMBIAN)
+    Vector<char, 256> buffer;
+    buffer.resize(256);
+    int result = vsnprintf(buffer.data(), buffer.size()-1, format, args);
 #else
     char ch;
     int result = vsnprintf(&ch, 1, format, args);
--- a/webengine/osswebengine/WebCore/platform/TextEncoding.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/TextEncoding.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -233,8 +233,8 @@
     return *globalWindowsLatin1Encoding;
 }
 
-void deleteTextEncodings() {
-
+struct cleanupTextEncodings  {
+    ~cleanupTextEncodings() {
     // Delete all encodings and set to NULL
     delete globalASCIIEncoding;
     globalASCIIEncoding = NULL;
@@ -253,6 +253,7 @@
     delete globalWindowsLatin1Encoding;
     globalWindowsLatin1Encoding = NULL;
 
-}
-
+    }
+};
+struct cleanupTextEncodings textEncodings;
 } // namespace WebCore
--- a/webengine/osswebengine/WebCore/platform/TextEncodingRegistry.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/TextEncodingRegistry.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -248,9 +248,10 @@
     return !didExtendTextCodecMaps;
 }
 
+
 #if PLATFORM(SYMBIAN)
-void deleteEncodingMaps()
-{
+struct cleanupEncodingMaps  {
+    ~cleanupEncodingMaps() {
     if( textEncodingNameMap ) {
         textEncodingNameMap->clear();
         delete textEncodingNameMap;
@@ -262,7 +263,9 @@
         textCodecMap = NULL;
     }
     didExtendTextCodecMaps = false;
-}
+    }
+};
+struct cleanupEncodingMaps encodingMaps;
 #endif
 
 } // namespace WebCore
--- a/webengine/osswebengine/WebCore/platform/Timer.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/Timer.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -228,7 +228,13 @@
 {
     ASSERT(m_nextFireTime != 0);
     checkHeapIndex();
-    push_heap(TimerHeapIterator(0), TimerHeapIterator(m_heapIndex + 1));
+    #if PLATFORM(SYMBIAN)
+    // check for valid heap index
+    if(m_heapIndex < static_cast<int>(timerHeap->size()))
+    #endif
+        {
+        push_heap(TimerHeapIterator(0), TimerHeapIterator(m_heapIndex + 1));
+        }
     checkHeapIndex();
 }
 
@@ -377,6 +383,23 @@
     updateSharedTimer();
 }
 
+#if PLATFORM(SYMBIAN)
+void TimerBase::deleteTimerHeap()
+{
+    if (timerHeap)
+    {
+        while (!timerHeap->isEmpty())
+        {
+            TimerBase* timer = timerHeap->first();
+            timer->m_nextFireTime = 0;
+            timer->heapDeleteMin();        
+        }
+        delete timerHeap ;
+        timerHeap = NULL ;
+    }
+}
+#endif
+
 // ----------------
 
 bool isDeferringTimers()
--- a/webengine/osswebengine/WebCore/platform/Timer.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/Timer.h	Thu Sep 24 12:53:48 2009 +0300
@@ -55,6 +55,14 @@
 
     static void fireTimersInNestedEventLoop();
 
+    /*
+     * The method deleteTimerHeap has been added so that when the browser instance is closed, all the pending timers that are added
+     * to the static heap are deleted. This helps when the same heap is reused in the next instance of browser control.
+     */
+#if PLATFORM(SYMBIAN)
+    static void deleteTimerHeap();
+#endif    
+
 private:
     virtual void fired() = 0;
 
--- a/webengine/osswebengine/WebCore/platform/network/symbian/HttpDownload.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/network/symbian/HttpDownload.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -67,7 +67,12 @@
     }
     int master = !m_sessionManager->m_embedded;
     RProcess myProcess;
-    m_downloadMgr.ConnectL( myProcess.Identity(), *this, master );
+    
+    TRAPD( errMngr, m_downloadMgr.ConnectL( myProcess.Identity(), *this, master ));
+    if ( errMngr == KErrAlreadyExists && master ) { 
+        m_downloadMgr.ConnectL( myProcess.Identity(), *this, EFalse );
+    }
+    
     if( !master ){
         // Browser is embedded. Downloads must be paused when the user closes
         // the embedded Browser (that is always started from the Launcher), and
--- a/webengine/osswebengine/WebCore/platform/network/symbian/HttpSessionManager.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/network/symbian/HttpSessionManager.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -312,11 +312,13 @@
 			RHTTPTransactionPropertySet propSet = connTransaction->PropertySet();
 			RStringPool stringPool = m_httpSession.StringPool();
 
-			RStringF selfDownloadCallbackStr = stringPool.OpenFStringL( KSelfDownloadCallback );
 			// Add own adress to the transaction properties		
-			propSet.RemoveProperty(selfDownloadCallbackStr);
-			propSet.SetPropertyL(selfDownloadCallbackStr, ((TInt) (MHTTPTransactionCallback*)m_SelfDownloadContentHandler));
-			if (connection->totalContentSize()) {
+			propSet.RemoveProperty( stringPool.StringF(HttpFilterCommonStringsExt::ESelfDownloadCallback,
+                                    HttpFilterCommonStringsExt::GetTable()) );
+			propSet.SetPropertyL( stringPool.StringF(HttpFilterCommonStringsExt::ESelfDownloadCallback,
+                                    HttpFilterCommonStringsExt::GetTable()), 
+                                    ((TInt) (MHTTPTransactionCallback*)m_SelfDownloadContentHandler));
+            if (connection->totalContentSize()) {
 				m_SelfDownloadContentHandler->HandleResponseBodyL(*connTransaction);
 			}
 		}
--- a/webengine/osswebengine/WebCore/platform/network/symbian/HttpUiCallbacks.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/network/symbian/HttpUiCallbacks.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -246,6 +246,7 @@
         // If the user selected "No" or "Cancel", we are cancelling the load
         if ( !result )
         {
+            brctl->HandleBrowserLoadEventL(TBrCtlDefs::EEventContentFinished,0,0);
             return KErrCancel;
         }
     }   // end of if
--- a/webengine/osswebengine/WebCore/platform/network/symbian/SelfDownloadContentHandler.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/network/symbian/SelfDownloadContentHandler.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -29,6 +29,7 @@
 #include "StaticObjectsContainer.h"
 #include "ResourceLoaderDelegate.h"
 #include "HttpSessionManager.h"
+#include "HttpFilterCommonStringsExt.h"
 #include <Uri8.h>
 #include <http/rhttptransaction.h>
 #include <http/mhttpdatasupplier.h>
@@ -37,7 +38,6 @@
 // CONSTANTS
 _LIT(KTempFilePath, "c:\\system\\temp\\browser\\");
 
-
 // -----------------------------------------------------------------------------
 // CTempFile::CTempFile
 // C++ default constructor can NOT contain any code, that
@@ -405,10 +405,9 @@
 		// remove the selfDownloadCallbackStr property
         RHTTPTransactionPropertySet propSet = httpTransaction.PropertySet();
 		RStringPool strPool = httpTransaction.Session().StringPool();
-		RStringF selfDownloadCallbackStr = strPool.OpenFStringL( KSelfDownloadCallback );
-		CleanupClosePushL<RStringF>( selfDownloadCallbackStr);
-		propSet.RemoveProperty(selfDownloadCallbackStr);
-		CleanupStack::PopAndDestroy(); // selfDownloadCallbackStr
+
+		propSet.RemoveProperty( strPool.StringF(HttpFilterCommonStringsExt::ESelfDownloadCallback,
+                                    HttpFilterCommonStringsExt::GetTable()) );
     }
 	StaticObjectsContainer::instance()->resourceLoaderDelegate()->httpSessionManager()->ResetOutstandingSelfDl();
     return status;
--- a/webengine/osswebengine/WebCore/platform/network/symbian/SelfDownloadContentHandler.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/network/symbian/SelfDownloadContentHandler.h	Thu Sep 24 12:53:48 2009 +0300
@@ -15,7 +15,6 @@
 *
 */
 
-
 #ifndef SELFDOWNLOADCONTENTHANDLER_H
 #define SELFDOWNLOADCONTENTHANDLER_H
 
@@ -26,8 +25,6 @@
 #include <http/MHTTPTransactionCallback.h>
 #include <f32file.h>
 
-_LIT8( KSelfDownloadCallback, "SelfDownloadCallback" );
-
 // FORWARD DECLARATIONS
 class CDocumentHandler;
 class TDataType;
@@ -112,7 +109,6 @@
        
     };
 
-
 /**
 *
 *  @since 5.0
--- a/webengine/osswebengine/WebCore/platform/symbian/OOMHandler.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/symbian/OOMHandler.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -1,19 +1,30 @@
 /*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of the License "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  
-*
-*/
+ * Copyright (C) 2007 Nokia, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
 
 #include "config.h"
 #include "OOMHandler.h"
@@ -58,13 +69,11 @@
 OOMHandler::OOMHandler()
 {
     MemoryManager::AddCollector(this);
-    MemoryManager::AddStopper(this);
 }
 
 OOMHandler::~OOMHandler()
 {
     MemoryManager::RemoveCollector(this);
-    MemoryManager::RemoveStopper(this);
 }
 
 TUint OOMHandler::Collect(TUint aRequired)
@@ -79,13 +88,4 @@
     // tot fixme: do nothing so far.
 }
 
-void OOMHandler::Stop()
-{
-    // the first step is to stop all the active loadings
-    const Vector<CBrCtl*>& ctrls = StaticObjectsContainer::instance()->activeBrowserControls();
-    for (int i=0; i<ctrls.size(); ++i) {
-        ctrls[i]->webView()->mainFrame()->stopLoading();
-    }
 }
-
-}
--- a/webengine/osswebengine/WebCore/platform/symbian/OOMHandler.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/symbian/OOMHandler.h	Thu Sep 24 12:53:48 2009 +0300
@@ -11,7 +11,7 @@
 *
 * Contributors:
 *
-* Description:  
+* Description: 
 *
 */
 
@@ -24,7 +24,15 @@
 
 namespace WebCore {
 
-class OOMHandler : public MMemoryCollector, public MOOMStopper
+/*
+ * This handles collecting memory when OOM occurs, by clearing the cache.
+ * The StopScheduler has two collection modes, low and middle priority.
+ * When memory is at a certain threshold, all collectors low and above are called.
+ * When memory is at a critical threshold, all collectors middle and above are called.
+ * We want the cache to always clear whenever OOM happens so this collector's
+ * priority is high.
+ */
+class OOMHandler : public MMemoryCollector
 {
 public:
     OOMHandler();
@@ -34,9 +42,6 @@
     TUint Collect(TUint aRequired);
     void Restore();
 
-    // from stopper
-    void Stop();
-
     TOOMPriority Priority()     { return EOOM_PriorityHigh; }
 };
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webengine/osswebengine/WebCore/platform/symbian/OOMStopper.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2007 Nokia, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "OOMStopper.h"
+/*
+ * Copyright (C) 2007 Nokia, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <config.h>
+#include "BrCtl.h"
+#include "WebView.h"
+#include "WebFrame.h"
+#include "Cache.h"
+#include "StaticObjectsContainer.h"
+
+namespace WebCore {
+
+OOMStopper::OOMStopper()
+{
+    MemoryManager::AddStopper(this);
+}
+
+OOMStopper::~OOMStopper()
+{
+    MemoryManager::RemoveStopper(this);
+}
+
+void OOMStopper::Stop()
+{
+    // the first step is to stop all the active loadings
+    const Vector<CBrCtl*>& ctrls = StaticObjectsContainer::instance()->activeBrowserControls();
+    for (int i=0; i<ctrls.size(); ++i) {
+        ctrls[i]->webView()->mainFrame()->stopLoading();
+    }
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webengine/osswebengine/WebCore/platform/symbian/OOMStopper.h	Thu Sep 24 12:53:48 2009 +0300
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __OOMSTOPPER_H__
+#define __OOMSTOPPER_H__
+
+#include <e32def.h>
+#include "MemoryManager.h"
+
+namespace WebCore {
+
+/*
+ * This handles stopping things when OOM occurs, by stopping page loading.
+ * The StopScheduler has two OOM modes, Normal and Emergency.  Normal mode 
+ * calls all low priority stoppers.  Emergency mode calls all high priority stoppers.
+ * (For some reason, emergency mode never seems to occur).   This stopper is low 
+ * priority because we want to always stop page loading whenever OOM happens
+ * (not just in emergency OOM situations).
+ */
+class OOMStopper : public MOOMStopper
+{
+public:
+    OOMStopper();
+    virtual ~OOMStopper();
+
+    void Stop();
+
+    // Priority is low because we always want to stop page loading when we're low on memory; not just during an emergency memory situation
+    TOOMPriority Priority()     { return EOOM_PriorityLow; }
+};
+
+}
+
+#endif // END OF FILE
--- a/webengine/osswebengine/WebCore/platform/symbian/PlatformKeyEventSymbian.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/symbian/PlatformKeyEventSymbian.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -74,8 +74,9 @@
             return "End";
         // "Enter"
         case EKeyEnter:
+            return "Enter";
         case EKeyDevice3: // Macintosh calls the one on the main keyboard Return, but Windows calls it Enter, so we'll do the same for the DOM
-            return "Enter";
+            return "MSK";
 
         // "EraseEof"
 
--- a/webengine/osswebengine/WebCore/platform/symbian/PopupMenuSymbian.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/symbian/PopupMenuSymbian.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -84,7 +84,9 @@
         }
     }
     
-    dialogs->DialogSelectOptionL(KNullDesC(), ESelectTypeSingle, *options);
+    
+    dialogs->DialogSelectOptionL(KNullDesC(), (TBrCtlSelectOptionType)(ESelectTypeSingle | ESelectTypeWithFindPane), *options);
+
     int newIndex = index;
     CleanupStack::PopAndDestroy(&items);
 
--- a/webengine/osswebengine/WebCore/platform/symbian/SharedTimerSymbian.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/symbian/SharedTimerSymbian.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -21,6 +21,7 @@
 #include <wtf/Assertions.h>
 #include <e32std.h>
 #include <e32base.h>
+#include <Timer.h>
 
 static TInt64 remainingMicro = 0;
 static bool shutdownInProgress = false;
@@ -110,12 +111,18 @@
         sharedTimer = NULL;
         }
     remainingMicro = 0;
+    /*
+     * The static boolean variable shutdownInProgress, must be reset in scenario's where a browser control instance is deleted and a new
+     * instance is created without actually closing the application.
+     */
+    shutdownInProgress = false ;
     }
 
 void shutdownSharedTimer()
     {
     shutdownInProgress = true;
     stopSharedTimer();
+    TimerBase::deleteTimerHeap();
     }
 
 void initSharedTimer()
--- a/webengine/osswebengine/WebCore/platform/symbian/StaticObjectsContainer.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/symbian/StaticObjectsContainer.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -1,20 +1,30 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of the License "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  
-*
-*/
-
+ * Copyright (C) 2006 Nokia, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
 
 #include "config.h"
 #include <../bidi.h>            // work around for multiple bidi.h files
@@ -34,6 +44,7 @@
 #include "PluginHandler.h"
 #include "WebCannedImages.h"
 #include "OOMHandler.h"
+#include "OOMStopper.h"
 #include "SharedTimer.h"
 #include "TextEncoding.h"
 #include "TextEncodingRegistry.h"
@@ -56,9 +67,9 @@
 #include "RenderBox.h"
 #include "FontCache.h"
 #include "MIMETypeRegistry.h"
-#include "ImageSymbian.h"
 #include "ResourceHandleManagerSymbian.h"
 #include "TextBreakIteratorSymbian.h"
+#include "ImageSymbian.h"
 #include "HTMLElementFactory.h"
 #include <eikenv.h>
 
@@ -88,6 +99,7 @@
     ,m_refcount(0)
     ,m_capabilities(0)
     ,m_oomHandler(0)
+    ,m_oomStopper(0)
     ,m_fullScreenMode(false)
     ,m_pluginFullscreen(false)
     ,m_symbianTheme(NULL)
@@ -110,6 +122,7 @@
         }
     }
     m_oomHandler = new OOMHandler();
+    m_oomStopper = new OOMStopper();
     initSharedTimer();
 }
 
@@ -119,6 +132,7 @@
     // This must be run before Cache::deleteStaticCache to properly free resources
     KJS::Collector::collect();
     delete m_oomHandler;
+    delete m_oomStopper;
     FontCache::deleteFontDataCache();
     delete m_fontCache;
     delete m_formFillController;
@@ -133,14 +147,11 @@
     delete m_symbianTheme;
     gInstance = NULL;
     deletePageStaticData();
+
     CSSStyleSelector::deleteDefaultStyle();
-    deleteTextEncodings();
-    deleteEncodingMaps();
-    RenderStyle::deleteDefaultRenderStyle();
     Cache::deleteStaticCache();
     TextCodecSymbian::deleteStatAvailCharsets();
-    QualifiedName::cleanup();
-    XMLNames::remove();
+
 	cleanupChangedDocuments();
 	mappedAttributeCleaner();
 	cleanupMidpoints();
@@ -152,16 +163,7 @@
 	cleanupIconFileName();
 	cleanupIterators();
 
-#ifndef __WINSCW__    
-    WebCore::MediaFeatureNames::remove();
-    WebCore::EventNames::remove();
-#endif  // __WINSCW__    
-    
-    // HTMLNames::remove() will destroy the AtomicString table
-    // All other atomic string destruction must be done before this call
-    //
-    HTMLNames::remove();
-    XMLTokenizer::cleanupXMLStringParser();
+	XMLTokenizer::cleanupXMLStringParser();
     shutdownSharedTimer();
     m_widgetLibrary.Close();
 #if defined(BRDO_LIW_FF)
@@ -336,5 +338,4 @@
     return m_symbianTheme;
 }
 }
-
 // END OF FILE
--- a/webengine/osswebengine/WebCore/platform/symbian/StaticObjectsContainer.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/symbian/StaticObjectsContainer.h	Thu Sep 24 12:53:48 2009 +0300
@@ -1,20 +1,30 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of the License "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  
-*
-*/
-
+ * Copyright (C) 2006 Nokia, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
 
 #ifndef __STATICOBJECTCONTAINER_H__
 #define __STATICOBJECTCONTAINER_H__
@@ -38,6 +48,7 @@
 class MWidgetEngineBridge;
 class MDeviceBridge;
 
+
 namespace WebCore {
 class RenderThemeSymbian;
 class RenderTheme;
@@ -52,6 +63,7 @@
 class FormFillController;
 class PictographSymbian;
 class OOMHandler;
+class OOMStopper;
 
 class StaticObjectsContainer : public Noncopyable 
 {
@@ -88,7 +100,7 @@
     const Vector<CBrCtl*>& activeBrowserControls() const;
     void setFullScreenMode(bool mode);
     bool fullScreenMode(void);
-
+    
 private:
     static StaticObjectsContainer* gInstance;
     StaticObjectsContainer();
@@ -108,13 +120,14 @@
     unsigned int            m_capabilities;
     Vector<CBrCtl*>         m_activeBrCtls;
     OOMHandler*             m_oomHandler;
+    OOMStopper*             m_oomStopper;
     bool                    m_fullScreenMode;
     bool                    m_pluginFullscreen;
     RLibrary                m_widgetLibrary;
 #if defined(BRDO_LIW_FF)
     RLibrary                m_deviceLibrary;
 #endif
-    RenderThemeSymbian*	    m_symbianTheme;
+		RenderThemeSymbian*			m_symbianTheme;
 };
 
 }
--- a/webengine/osswebengine/WebCore/platform/symbian/TemporaryLinkStubsSymbian.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/symbian/TemporaryLinkStubsSymbian.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -65,6 +65,11 @@
 #include "DragData.h"
 #include "DocumentFragment.h"
 
+#include "../bidi.h"
+#include <stringloader.h>
+#include <webkit.rsg>
+
+
 namespace WebCore {
 
 static void notImplemented() { /*puts("Not yet implemented"); */}
@@ -144,7 +149,14 @@
 void Widget::invalidate() { }
 void Widget::invalidateRect(const IntRect& r) { }
 
-String fileButtonChooseFileLabel() { return "Choose File"; }
+String fileButtonChooseFileLabel() 
+    { 
+    String chooseLabel;
+    HBufC* loadStr = StringLoader::LoadLC(R_QTN_BROWSER_CHOOSE_FILE_SYM);
+    chooseLabel.append(*loadStr);
+    CleanupStack::PopAndDestroy();
+    return chooseLabel;
+    }
 
 // editor
 PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy) { return 0; }
--- a/webengine/osswebengine/WebCore/platform/symbian/bitmap/AnimationDecoder.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/symbian/bitmap/AnimationDecoder.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -11,37 +11,26 @@
 *
 * Contributors:
 *
-* Description:  
+* Description: 
 *
 */
 
 
+/*
+ *  This class is a proxy for CAnimationDecoderWrapped
+ *  
+ *  We needed to wrap animation decoding in a proxy because sometimes the cache gets cleared when decoding
+ *  is in progress; when that happens the animation gets deleted while it's in the middle (which causes all sorts
+ *  of crashes and memory stomping).  Now, the cache can delete the proxy while the animation is decoding; the proxy
+ *  will pass on the delete request to the decoder which will cleanup (delete itself) when it's safe to do so.
+ *  
+ */
+
 // INCLUDE FILES
 #include "config.h"
 #include "AnimationDecoder.h"
-#include "MaskedBitmap.h"
-#include "ImageObserver.h"
-#include "SyncDecodeThread.h"
-#include "Oma2Agent.h"
-using namespace ContentAccess;
-
-namespace TBidirectionalState {
-    class TRunInfo;
-};
-
-#include <eikenv.h>
-
-// constants
-
-// Private namespace for constants and functions
-namespace
-  {
-  // Panic function
-  void Panic( TInt aPanicCode ) { User::Panic( _L("AnimationDecoder"), aPanicCode ); }
-  }
 
 using namespace WebCore;
-CSynDecodeThread *CAnimationDecoder::iSyncDecodeThread  = NULL;
 
 // ============================ MEMBER FUNCTIONS ===============================
 // -----------------------------------------------------------------------------
@@ -49,17 +38,9 @@
 // C++ default constructor can NOT contain any code, that
 // might leave.
 // -----------------------------------------------------------------------------
-CAnimationDecoder::CAnimationDecoder( ImageObserver* aObs )
-    :CActive( CActive::EPriorityIdle )
-    , iObserver(aObs)
-    , iLoopCount( -1 )
-    , iCurLoopCount( -1 )
-    , iSyncBitmapHandle(-1)
-    , iSyncMaskHandle(-1)
-    , iDecodeInProgress(ETrue)
+CAnimationDecoder::CAnimationDecoder( CAnimationDecoderWrapped* aDecoder )
+    : iWrapped(aDecoder)
 {
-    if (CActiveScheduler::Current())
-        CActiveScheduler::Add( this );    
 }
 
 // -----------------------------------------------------------------------------
@@ -68,10 +49,8 @@
 // -----------------------------------------------------------------------------
 CAnimationDecoder* CAnimationDecoder::NewL( ImageObserver* aObs )
 {
-    CAnimationDecoder* self = new (ELeave) CAnimationDecoder( aObs );
-    CleanupStack::PushL( self );
-    self->ConstructL( );
-    CleanupStack::Pop(); // self
+    CAnimationDecoderWrapped* aDecoder = CAnimationDecoderWrapped::NewL( aObs );
+    CAnimationDecoder* self = new (ELeave) CAnimationDecoder( aDecoder );
     return self;
 }
 
@@ -88,601 +67,77 @@
 // -----------------------------------------------------------------------------
 CAnimationDecoder::~CAnimationDecoder()
 {
-    Cancel();
-
-    if( iDecoder ) {
-        // animated images still being decoded.
-        iDecoder->Cancel();
-        delete iDecoder, iDecoder = NULL;
-    }
-
-    delete iAnimationBitmap, iAnimationBitmap = NULL;
-    delete iDestination, iDestination = NULL;
-    if(iDrmContent) 
-    {
-        delete iDrmContent;
-        iDrmContent = NULL;
+    if (iWrapped) {
+        iWrapped->Invalidate();
+        iWrapped = NULL;
     }
 }
 
-// -----------------------------------------------------------------------------
-// OpenL
-// -----------------------------------------------------------------------------
-void CAnimationDecoder::OpenAndDecodeSyncL( const TDesC8& aData )
-{    
-    iSizeAvailable = EFalse;
-    iRawDataComplete = ETrue;
-    delete iDestination;
-    iDestination = NULL;
-    
-    if(!iSyncDecodeThread) { // first time, create decoder thread
-        iSyncDecodeThread = CSynDecodeThread::NewL();
-    }
-    
-    if (iSyncDecodeThread->Decode(aData) == KErrNone) {
-        iSyncDecodeThread->Handle(iSyncBitmapHandle, iSyncMaskHandle); 
-        Destination(); // duplicate bitmap handles
-        iSizeAvailable = ETrue;
-    }        
-}
-
 CMaskedBitmap* CAnimationDecoder::Destination() 
 { 
-    if (iDestination)
-        return iDestination; 
-        
-    if (iSyncBitmapHandle != -1 && iSyncMaskHandle != -1) {
-        CFbsBitmap* bitmap = new CFbsBitmap();
-        bitmap->Duplicate(iSyncBitmapHandle);
-        CFbsBitmap* mask = new CFbsBitmap();
-        mask->Duplicate(iSyncMaskHandle);
-
-        iDestination = new CMaskedBitmap(bitmap, mask);
-        iDestination->SetFrameIndex(0);
-        iDestination->SetFrameDelay(0);
-        iSyncBitmapHandle = -1;
-        iSyncMaskHandle = -1;
-    }
-    
-    return iDestination;
+    if (iWrapped)
+        return(iWrapped->Destination());
+    return(NULL);
 }
-//=============================================================================
-// DecodeDRMImageContentL : Function for handling the DRM image content
-//=============================================================================
-HBufC8* CAnimationDecoder::DecodeDRMImageContentL(const TDesC8& aData)
-{
-    // input buffers for image conversion
-    HBufC8* bufInput = HBufC8::NewLC( aData.Length() + 1 );
-    TPtr8 ptrInput = bufInput->Des();
-    //Reader intends to view content
-    ptrInput.Append( EView );
-    ptrInput.Append( aData );
 
-    // output buffer for image conversion
-    HBufC8* animatedDRMdata = HBufC8::NewLC( aData.Length() + 256 );
-    TPtr8 ptrOutput = animatedDRMdata->Des();
-
-  //Find DRM agent
-    TAgent agentDRM;
-    
-    RArray<ContentAccess::TAgent> agents;
-    ContentAccess::CManager* manager = CManager::NewLC();
-    manager->ListAgentsL( agents );
-    for ( TInt i = 0; i < agents.Count(); i++ )
-      {
-    if ( agents[i].Name().Compare( KOmaDrm2AgentName ) == 0)
-      {
-       agentDRM = agents[i];
-       //convert the DRM image
-       manager->AgentSpecificCommand( agentDRM, EDecryptOma1DcfBuffer, ptrInput,ptrOutput);
-       break;
-      }
-    }
-
-    CleanupStack::PopAndDestroy(manager);
-    //keep animatedDRMdata to return
-    CleanupStack::Pop(animatedDRMdata);
-    CleanupStack::PopAndDestroy(bufInput);
-
-    return animatedDRMdata;
-    }
 // -----------------------------------------------------------------------------
 // OpenL
 // -----------------------------------------------------------------------------
 void CAnimationDecoder::OpenL( const TDesC8& aData, TDesC* aMIMEType, TBool aIsComplete )
 {
-    if(!iObserver) {
-        OpenAndDecodeSyncL(aData);
+    if (!iWrapped) {
         return;
     }
-        
-    
-    delete iDestination;
-    iDestination = NULL;
-    iDestination = CMaskedBitmap::NewL();
-
-    HBufC8* mime = 0;
-    TPtrC8 buffer(aData.Ptr(),aData.Length());
-    if (aMIMEType) {
-        // it is safer to ignore the server supplied mime type and just recognize
-        // the image type from the data headers. this does not work for all formats though
-        if ( *aMIMEType==KMimeWBMP || *aMIMEType==KMimeOTA || *aMIMEType==KMimeWMF){
-            // convert to 8 bit
-            mime = HBufC8::NewLC(aMIMEType->Length());
-            mime->Des().Copy(*aMIMEType);
-        }
-        if( *aMIMEType==KMimeDRM )
-        {
-        iDrmContent = DecodeDRMImageContentL(aData);
-        
-        TInt drmContentLength = iDrmContent->Des().Length();
-        buffer.Set( (const TUint8*)iDrmContent->Des().Ptr(), drmContentLength);
-        }
-    }
-         
-    if( !iDecoder )
-        iDecoder = CBufferedImageDecoder::NewL(CEikonEnv::Static()->FsSession());
-
-    if (mime){
-        iDecoder->OpenL(buffer,*mime,CImageDecoder::EOptionNone);
-        CleanupStack::PopAndDestroy(); // mime
-    }
-    else {
-        iDecoder->OpenL(buffer,CImageDecoder::EOptionNone);
+    TRAPD(err, iWrapped->OpenL(aData, aMIMEType, aIsComplete));
+    if (err != KErrNone) {
+        delete iWrapped;
+        iWrapped = NULL;
     }
-
-    iRawDataComplete = aIsComplete;
-
-    if(iDecoder && iDecoder->ValidDecoder()  && iDecoder->IsImageHeaderProcessingComplete())
-        StartDecodingL();
-    else
-        // remove me when incremental image rendering gets supported
-        User::Leave( KErrCorrupt );
-
-    //If it is an animated image, let's figure out loop count
-    if(IsAnimation()) {
-        // first see if have a netscape 2.0 extension header 
-        const TUint8 extString[] = { 'N', 'E', 'T', 'S', 'C', 'A', 'P','E','2','.','0','\3','\1' };
-        const TInt sizeofextString = sizeof(extString);
-        TPtrC8 rawDataPtr((TUint8*)aData.Ptr(), aData.Length());
-        TInt offset = rawDataPtr.Find(extString, sizeofextString);
-        if(offset != KErrNotFound) {
-            // found a header, get the loop count -
-            // (the loop count is in the 2 bytes following the header string listed above,
-            // stored low byte then high byte)
-            iLoopCount = (TInt16)((rawDataPtr[offset+sizeofextString+1] * 256) + rawDataPtr[offset+sizeofextString]);
-            if(iLoopCount != 0) {
-                ++iLoopCount;  // +1 to make it 1 based rather than 0 based 
-            }
-            else{
-            // 0 indicates infinite - map to internal loop count infinite value 
-                iLoopCount = -1;
-            }
-        }
-        else {
-            // no header found, assume 1x thru loop 
-            iLoopCount = 1;
-        }
-        iCurLoopCount = iLoopCount;
-    }
-}
-
-// -----------------------------------------------------------------------------
-// CAnimationDecoder::AddDataL
-// New chunk of raw data
-//
-// -----------------------------------------------------------------------------
-//
-void CAnimationDecoder::AddDataL(
-    const TDesC8& aNextChunk,
-    TBool aIsComplete )
-{
-    iRawDataComplete = aIsComplete;
-
-    if( iDecoder ) {
-        iDecoder->AppendDataL(aNextChunk);
-        if( iDecoder->ValidDecoder() ) {
-            //  if the image conversion is busy , then just appending the
-            // data should be sufficient
-            if(iStatus == KRequestPending) {
-                // more image data
-                iDecoder->ContinueConvert( &iStatus );
-                SetActive();
-            }
-        }
-        else {
-            iDecoder->ContinueOpenL() ;
-            if(iDecoder->ValidDecoder()  && iDecoder->IsImageHeaderProcessingComplete()){
-                StartDecodingL();
-            }
-        }
-    }
+    User::LeaveIfError(err);
+    
 }
 
-// -----------------------------------------------------------------------------
-// CImageLoader::StartDecodingL
-//
-// -----------------------------------------------------------------------------
-//
-void CAnimationDecoder::StartDecodingL()
+TSize CAnimationDecoder::Size() const
 {
-    // Check frame count
-    iAnimationFrameCount = iDecoder->FrameCount();
-    iAnimation = iAnimationFrameCount > 1;
-    iFrameInfo = iDecoder->FrameInfo( 0 );
-    iSizeAvailable = ETrue;
-
-    if (iFrameInfo.iFlags & TFrameInfo::ETransparencyPossible){
-        // we only support gray2 and gray256 tiling
-        TDisplayMode maskmode = ( (iFrameInfo.iFlags & TFrameInfo::EAlphaChannel) && (iFrameInfo.iFlags & TFrameInfo::ECanDither)) ? EGray256 : EGray2;
-        TInt error = iDestination->Create( iFrameInfo.iOverallSizeInPixels, DisplayMode(), maskmode );
-
-        if (!error)
-            LoadFrame(0);
-        else
-            RunError(KErrNoMemory);
-    }
-    else {
-        TInt error = iDestination->Create( iFrameInfo.iOverallSizeInPixels, DisplayMode() );
-        if (!error)
-            LoadFrame(0);
-        else
-            RunError(KErrNoMemory);
-    }
-}
-
-// -----------------------------------------------------------------------------
-// CAnimationDecoder::MaskDisplayMode
-// -----------------------------------------------------------------------------
-TDisplayMode CAnimationDecoder::MaskDisplayMode() const
-{
-    if( iFrameInfo.iFlags & TFrameInfo::ETransparencyPossible ){
-        if( iFrameInfo.iFlags & TFrameInfo::EAlphaChannel && (iFrameInfo.iFlags & TFrameInfo::ECanDither))
-            return EGray256;
-    return EGray2;
-    }
-    return ENone;
-}
-
-// -----------------------------------------------------------------------------
-// CAnimationDecoder::AnimationFrameDelay
-// -----------------------------------------------------------------------------
-TTimeIntervalMicroSeconds32 CAnimationDecoder::AnimationFrameDelay( TInt aAnimationFrameIndex ) const
-{
-    __ASSERT_ALWAYS( aAnimationFrameIndex >= 0 &&
-    aAnimationFrameIndex < iAnimationFrameCount, Panic( KErrArgument ) );
-
-    return I64INT( iDecoder->FrameInfo( aAnimationFrameIndex ).iDelay.Int64() );
+    if (iWrapped)
+        return(iWrapped->Size());
+    TSize t;
+    return(t);
 }
 
-
-// -----------------------------------------------------------------------------
-// CAnimationDecoder::DoCancel
-// -----------------------------------------------------------------------------
-void CAnimationDecoder::DoCancel()
-{
-    iDecoder->Cancel();
-    // Delete all processed bitmaps
-    ErrorCleanup();
-    // Complete with cancel
-    iImageState = EInactive;
-}
-
-// -----------------------------------------------------------------------------
-// CAnimationDecoder::RunL
-// -----------------------------------------------------------------------------
-void CAnimationDecoder::RunL()
+TInt CAnimationDecoder::AnimationFrameCount() const
 {
-    __ASSERT_DEBUG( iDestination, Panic( KErrGeneral ) );
-    // don't kick off the image decoding until the preview mode is over
-    if (iStatus==KErrUnderflow) {
-        if (!IsAnimation())
-            iObserver->partialImage();
-        return;
-    }
-    else if( iStatus == KErrCorrupt ) {
-        RunError( iStatus.Int() );
-        return;
-    }
-    User::LeaveIfError( iStatus.Int() );
-    switch( iImageState ) {
-        case EStartLoad:
-            {
-            // start loading the bitmaps
-            StartLoadL();
-            break;
-            }
-        case ECompleteLoad:
-            {
-            // complete loading the bitmaps
-            CompleteLoadL();
-            break;
-            }
-        default:
-            {
-            Panic( KErrTotalLossOfPrecision );
-            }
-    }
-}
-
-// -----------------------------------------------------------------------------
-// CAnimationDecoder::RunError
-// -----------------------------------------------------------------------------
-TInt CAnimationDecoder::RunError( TInt aError )
-{
-    // Delete all processed bitmaps
-    ErrorCleanup();
-    // Complete with error
-    iImageState = EInactive;
-    iObserver->decoderError(aError);
-    return KErrNone;
-}
-
-// -----------------------------------------------------------------------------
-// CAnimationDecoder::LoadFrame
-// -----------------------------------------------------------------------------
-TInt CAnimationDecoder::LoadFrame( TInt aFrameIndex )
-{
-    if( IsBusy() )
-        return KErrNotReady;
-
-    if( aFrameIndex < 0 || aFrameIndex >= iDecoder->FrameCount() )
-        return KErrArgument;
-
-    iFrameIndex = aFrameIndex;
-    // Start the active object
-    iImageState = EStartLoad;
-    SelfComplete();
-    return KErrNone;
+    if (iWrapped)
+        return(iWrapped->AnimationFrameCount());
+    return(-1);
 }
 
-// -----------------------------------------------------------------------------
-// CAnimationDecoder::StartLoadL
-// -----------------------------------------------------------------------------
-void CAnimationDecoder::StartLoadL()
+TInt16 CAnimationDecoder::getLoopCount()
 {
-    __ASSERT_DEBUG( !iAnimationBitmap, Panic( KErrGeneral ) );
-
-    if( iAnimation ) {
-        // Start animation from first frame by default
-        iAnimationFrameIndex = 0;
-
-        // Check is animation can be continued on top of destination bitmap
-        if( iDestination->FrameIndex() < iFrameIndex )
-          iAnimationFrameIndex = iDestination->FrameIndex() + 1;
-
-        StartLoadAnimationBitmapL( iAnimationFrameIndex );
-    }
-    else // normal image
-        StartLoadNormalBitmap( iFrameIndex );
-    
-    iDecodeInProgress = EFalse;    
-    iImageState = ECompleteLoad;
-    SetActive();
-}
-
-// -----------------------------------------------------------------------------
-// CAnimationDecoder::StartLoadNormalBitmap
-// -----------------------------------------------------------------------------
-void CAnimationDecoder::StartLoadNormalBitmap( TInt aFrameIndex )
-{
-    CFbsBitmap& dstBitmap = iDestination->BitmapModifyable();
-    CFbsBitmap& dstMask = iDestination->MaskModifyable();
-
-    if( MaskDisplayMode() != ENone && dstMask.Handle() )
-        iDecoder->Convert( &iStatus, dstBitmap, dstMask, aFrameIndex );
-    else {
-        dstMask.Reset();
-        iDecoder->Convert( &iStatus, dstBitmap, aFrameIndex );
-    }
+    if (iWrapped)
+        return(iWrapped->getLoopCount());
+    return(-1);
 }
 
-// -----------------------------------------------------------------------------
-// CAnimationDecoder::StartLoadAnimationBitmapL
-// -----------------------------------------------------------------------------
-void CAnimationDecoder::StartLoadAnimationBitmapL( TInt aFrameIndex )
-{
-    __ASSERT_DEBUG( !iAnimationBitmap, Panic( KErrGeneral ) );
-
-    // Create animation bitmap
-    iAnimationBitmap = CMaskedBitmap::NewL();
-    CFbsBitmap& animBitmap = iAnimationBitmap->BitmapModifyable();
-    CFbsBitmap& animMask = iAnimationBitmap->MaskModifyable();
-
-    TFrameInfo frameInfo( iDecoder->FrameInfo( aFrameIndex ) );
-    User::LeaveIfError( animBitmap.Create(
-    frameInfo.iOverallSizeInPixels, EColor16M ) );
-
-    TDisplayMode maskDisplayMode( ENone );
-
-    if( frameInfo.iFlags & TFrameInfo::ETransparencyPossible ) {
-        if( frameInfo.iFlags & TFrameInfo::EAlphaChannel && (frameInfo.iFlags & TFrameInfo::ECanDither)) 
-            maskDisplayMode = EGray256;
-        maskDisplayMode = EGray2;
-
-        User::LeaveIfError( animMask.Create( frameInfo.iOverallSizeInPixels, maskDisplayMode ) );
-        iDecoder->Convert( &iStatus, animBitmap, animMask, aFrameIndex );
-    }
-    else
-        iDecoder->Convert( &iStatus, animBitmap, aFrameIndex );
-}
-
-// -----------------------------------------------------------------------------
-// CAnimationDecoder::CompleteLoadL
-// -----------------------------------------------------------------------------
-void CAnimationDecoder::CompleteLoadL()
+TBool CAnimationDecoder::isSizeAvailable() const
 {
-    TSize frameSize = iFrameInfo.iOverallSizeInPixels;
-    int sizeinBytes = frameSize.iWidth * frameSize.iHeight * 2;
-    if( iAnimationBitmap ){
-        // Copy animation bitmap to destination
-        BuildAnimationFrameL();
-        delete iAnimationBitmap;
-        iAnimationBitmap = NULL;
-
-        iDestination->SetFrameIndex( iAnimationFrameIndex );
-        iDestination->SetFrameDelay( AnimationFrameDelay( iAnimationFrameIndex ) );
-
-        if( iAnimationFrameIndex < iFrameIndex ) {
-            // re-start the active object and load next frame
-            iAnimationFrameIndex++;
-            iImageState = EStartLoad;
-            SelfComplete();
-        }
-        else {
-            // Animation ready
-            iImageState = EInactive;
-            iObserver->animationFrameReady(sizeinBytes);
-        }
-    }
-    else {
-        // Save source info destination
-        iDestination->SetFrameIndex( iFrameIndex );
-        iDestination->SetFrameDelay( 0 );
-
-        // Normal image ready
-        //iDestination = NULL;
-        iImageState = EInactive;
-        iObserver->imageReady(sizeinBytes);
-        delete iDecoder, iDecoder = NULL;
-    }
+    if (iWrapped)
+        return(iWrapped->isSizeAvailable());
+    return(EFalse);
 }
 
-// -----------------------------------------------------------------------------
-// CAnimationDecoder::BuildAnimationFrameL
-// -----------------------------------------------------------------------------
-void CAnimationDecoder::BuildAnimationFrameL()
-    {
-    __ASSERT_DEBUG( iAnimationBitmap, Panic( KErrGeneral ) );
-    const CFbsBitmap& animBitmap = iAnimationBitmap->Bitmap();
-    const CFbsBitmap& animMask = iAnimationBitmap->Mask();
-    __ASSERT_DEBUG( animBitmap.Handle(), Panic( KErrGeneral ) );
-
-
-		//If the first frame starts from position(0,0), copy directly to the destination bitmap 
-		//otherwise frame has to be appropriately positioned in the destination bitmap  
-    TPoint aStartPoint(0,0);
-    if( (iAnimationFrameIndex==0) && (iFrameInfo.iFrameCoordsInPixels.iTl==aStartPoint) )
-    {
-        // First frame can be directly put into destination
-        User::LeaveIfError( iDestination->Copy( animBitmap, animMask, ETrue ) );
-    }
-    else {
-        CFbsBitmap& prevBitmap = iDestination->BitmapModifyable();
-        CFbsBitmap& prevMask = iDestination->MaskModifyable();
-
-        // Other frames must be build on top of previous frames
-        __ASSERT_DEBUG( prevBitmap.Handle(), Panic( KErrGeneral ) );
-
-        // Create bitmap device to destination bitmap
-        CFbsBitGc* bitGc;
-        CFbsBitmapDevice* bitDevice = CFbsBitmapDevice::NewL( &prevBitmap );
-        CleanupStack::PushL( bitDevice );
-        User::LeaveIfError( bitDevice->CreateContext( bitGc ) );
-        CleanupStack::PushL( bitGc );
-
-        // Restore area in destination bitmap if needed
-        TRect restoreRect;
-        TBool restoreToBackground( EFalse );
-        
-        TInt aFrameNo = (iAnimationFrameIndex >= 1)?(iAnimationFrameIndex):1;
-        TFrameInfo prevFrameInfo(iDecoder->FrameInfo(aFrameNo - 1));
-        
-        //TFrameInfo prevFrameInfo( iDecoder->FrameInfo( iAnimationFrameIndex - 1 ) );
-        
-        if( (prevFrameInfo.iFlags & TFrameInfo::ERestoreToBackground )|| (iAnimationFrameIndex ==0)) 
-        {
-            restoreToBackground = ETrue;
-            restoreRect = prevFrameInfo.iFrameCoordsInPixels;
-            bitGc->SetPenColor( prevFrameInfo.iBackgroundColor );
-            bitGc->SetBrushColor( prevFrameInfo.iBackgroundColor );
-            bitGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
-            if(iAnimationFrameIndex ==0){
-              bitGc->Clear(); 		
-            }
-            else{
-               bitGc->DrawRect( restoreRect ); 	
-            }
-            bitGc->SetBrushStyle( CGraphicsContext::ENullBrush );
-         }
-        // Copy animation frame to destination bitmap
-        TFrameInfo frameInfo( iDecoder->FrameInfo( iAnimationFrameIndex) );
-        if( animMask.Handle() ) {
-            bitGc->BitBltMasked( frameInfo.iFrameCoordsInPixels.iTl, &animBitmap,
-            animBitmap.SizeInPixels(), &animMask, EFalse );
-        }
-        else {
-            bitGc->BitBlt( frameInfo.iFrameCoordsInPixels.iTl, &animBitmap,
-            animBitmap.SizeInPixels() );
-        }
-        CleanupStack::PopAndDestroy( 2 ); // bitmapCtx, bitmapDev
-
-        // Combine masks if any
-        if( prevMask.Handle() && animMask.Handle() ) {
-            bitDevice = CFbsBitmapDevice::NewL( &prevMask );
-            CleanupStack::PushL( bitDevice );
-            User::LeaveIfError( bitDevice->CreateContext( bitGc ) );
-            CleanupStack::PushL( bitGc );
-
-            if( restoreToBackground ) {
-                bitGc->SetBrushColor( KRgbBlack );
-                bitGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
-                if(iAnimationFrameIndex ==0){
-                   bitGc->Clear(); 		
-                 }
-                 else{
-                   bitGc->DrawRect( restoreRect ); 	
-                 }
-                bitGc->SetBrushStyle( CGraphicsContext::ENullBrush );
-            }
-            CFbsBitmap* tmpMask = new(ELeave) CFbsBitmap;
-            CleanupStack::PushL( tmpMask );
-            User::LeaveIfError( tmpMask->Create( prevMask.SizeInPixels(), prevMask.DisplayMode() ) );
-            CFbsBitmapDevice* tmpMaskDev = CFbsBitmapDevice::NewL( tmpMask );
-            CleanupStack::PushL( tmpMaskDev );
-            CFbsBitGc* tmpMaskGc;
-            User::LeaveIfError( tmpMaskDev->CreateContext( tmpMaskGc ) );
-            CleanupStack::PushL( tmpMaskGc );
-
-            tmpMaskGc->BitBlt( TPoint( 0, 0 ), &prevMask, frameInfo.iFrameCoordsInPixels );
-
-            bitGc->BitBltMasked( frameInfo.iFrameCoordsInPixels.iTl, &animMask,
-            animMask.SizeInPixels(), tmpMask, ETrue );
-
-            CleanupStack::PopAndDestroy( 5 ); //tmpMask, tmpMaskDev, tmpMaskGc, bitGc, bitDevice
-        }
-    else
-        prevMask.Reset(); // Mask not valid anymore -> reset
-    }
+TInt CAnimationDecoder::LoadFrame(TInt aFrameIndex)
+{
+    if (iWrapped)
+        return(iWrapped->LoadFrame(aFrameIndex));
+    return(-1);
 }
 
-// -----------------------------------------------------------------------------
-// CAnimationDecoder::ErrorCleanup
-// -----------------------------------------------------------------------------
-void CAnimationDecoder::ErrorCleanup()
+TBool CAnimationDecoder::decodeInProgress() const
 {
-    if( iAnimationBitmap ) {
-        delete iAnimationBitmap;
-        iAnimationBitmap = NULL;
-    }
-
-    if( iDestination ) {
-        delete iDestination;
-        iDestination = NULL;
-    }
+    if (iWrapped)
+        return(iWrapped->decodeInProgress());
+    return(EFalse);
 }
 
-// -----------------------------------------------------------------------------
-// CAnimationDecoder::SelfComplete
-// -----------------------------------------------------------------------------
-void CAnimationDecoder::SelfComplete( TInt aError )
-{
-    SetActive();
-    iStatus = KRequestPending;
-    TRequestStatus* status = &iStatus;
-    User::RequestComplete( status, aError );
-}
-
-
-
 //  End of File
--- a/webengine/osswebengine/WebCore/platform/symbian/bitmap/AnimationDecoder.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/symbian/bitmap/AnimationDecoder.h	Thu Sep 24 12:53:48 2009 +0300
@@ -11,7 +11,7 @@
 *
 * Contributors:
 *
-* Description:  
+* Description: 
 *
 */
 
@@ -20,47 +20,25 @@
 #define ANIMATIONDECODER_H
 
 // INCLUDES
-
-#include <e32base.h>
-#include <imageconversion.h> // TFrameInfo
-
-// FORWARD DECLARATIONS
-class CMaskedBitmap;
-class CBufferedImageDecoder;
-class CSynDecodeThread;
-namespace WebCore {
-    class ImageObserver;
-}
-// CONSTANTS
-
-_LIT(KMimeJPEG, "image/jpeg");
-_LIT(KMimeJPG, "image/jpg");
-_LIT(KMimeGIF, "image/gif");
-_LIT(KMimePNG, "image/png");
-_LIT(KMimeTIFF, "image/tiff");
-_LIT(KMimeBMP, "image/bmp");
-_LIT(KMimeWBMP, "image/vnd.wap.wbmp");
-_LIT(KMimeWMF, "application/x-msmetafile");
-_LIT(KMimeMBM, "image/x-epoc-mbm");
-_LIT(KMimeOTA, "image/vnd.nokia.ota-bitmap");
-_LIT(KMimeICO, "image/x-icon");
-_LIT(KMimeDRM, "application/vnd.oma.drm.content");
-
-//const TDisplayMode KMaxDepth = EColor64K;
-
-// FIXME: we should move this back to EColor64K after Symbian fix their Gif image decoder bug.
-const TDisplayMode KMaxDepth = EColor16M;
+#include "AnimationDecoderWrapped.h"
 
 // CLASS DECLARATION
 /**
 *  CAnimationDecoder
 *
-*  Implementation of file based image class.
+*  Proxy for implementation of file based image class.
 *  @lib IHL.lib
 *  @since 3.0
+*  
+*  This class is a proxy for CAnimationDecoderWrapped
+*  
+*  We needed to wrap animation decoding in a proxy because sometimes the cache gets cleared when decoding
+*  is in progress; when that happens the animation gets deleted while it's in the middle (which causes all sorts
+*  of crashes and memory stomping).  Now, the cache can delete the proxy while the animation is decoding; the proxy
+*  will pass on the delete request to the decoder which will cleanup (delete itself) when it's safe to do so.
 */
 
-class CAnimationDecoder  : public CActive
+class CAnimationDecoder
     {
     public:  // Constructors and destructor
 
@@ -80,152 +58,34 @@
         * From MIHLFileImage, see base class header.
         */
         void OpenL( const TDesC8& aData, TDesC* aMIMEType, TBool aIsComplete );
-        void OpenAndDecodeSyncL( const TDesC8& aData );
-
-        /*
-        * From MIHLFileImage, see base class header.
-        */
-        void AddDataL( const TDesC8& aData, TBool aIsComplete );
-
-        /*
-        * From MIHLFileImage, see base class header.
-        */
-        TSize Size() const { return iFrameInfo.iOverallSizeInPixels; }
-
-        /*
-        * From MIHLFileImage, see base class header.
-        */
-        TDisplayMode DisplayMode() const { return KMaxDepth; }
 
         /*
         * From MIHLFileImage, see base class header.
         */
-        TDisplayMode MaskDisplayMode() const;
-
-        /*
-        * From MIHLFileImage, see base class header.
-        */
-        TRgb BackgroundColor() const { return iFrameInfo.iBackgroundColor; }
+        TSize Size() const;
 
         /*
         * From MIHLFileImage, see base class header.
         */
-        TBool IsAnimation() const { return iAnimation; }
-
-        /*
-        * From MIHLFileImage, see base class header.
-        */
-        TInt AnimationFrameCount() const { return iAnimationFrameCount; }
-
-        /*
-        * From MIHLFileImage, see base class header.
-        */
-        TTimeIntervalMicroSeconds32 AnimationFrameDelay( TInt aAnimationFrameIndex ) const;
-
+        TInt AnimationFrameCount() const;
         /*
         * From MIHLFileImage, see base class header.
         */
         TInt LoadFrame( TInt aFrameIndex );
 
-        /*
-        * From MIHLFileImage, see base class header.
-        */
-        TBool IsBusy() const { return ( iImageState != EInactive ); }
-
-
-        /*
-        * From MIHLFileImage, see base class header.
-        */
-        void CancelLoad() { Cancel(); }
-
-        TBool IsOpen() const { return iDecoder!=0; }
-
         //funtions related to Loop count of animation image.
-        TInt16 getLoopCount(){return iCurLoopCount;};
-        void resetLoopCount(){iCurLoopCount = iLoopCount;};
-        void decreamentLoopCount(){ iCurLoopCount--;};
+        TInt16 getLoopCount();
         CMaskedBitmap* Destination();
-        TBool isSizeAvailable() const { return iSizeAvailable; }
-        TBool decodeInProgress() const { return iDecodeInProgress; }
-
-  private: // From base class CActive
-
-        /*
-        * From CActive, see base class header.
-        */
-        void DoCancel();
-
-        /*
-        * From CActive, see base class header.
-        */
-        void RunL();
-
-        /*
-        * From CActive, see base class header.
-        */
-        TInt RunError( TInt aError );
-
-  private: // Private methods
-
-        void StartDecodingL();
-        void StartLoadL();
-        void StartLoadNormalBitmap( TInt aFrameIndex );
-        void StartLoadAnimationBitmapL( TInt aFrameIndex );
-        void CompleteLoadL();
-        void BuildAnimationFrameL();
-        void ErrorCleanup();
-        void SelfComplete( TInt aError = KErrNone );
-        HBufC8* DecodeDRMImageContentL(const TDesC8& aData);
+        TBool isSizeAvailable() const;
+        TBool decodeInProgress() const;
 
   private: // Private constructors
 
-        CAnimationDecoder(WebCore::ImageObserver* aObs);
+        CAnimationDecoder(CAnimationDecoderWrapped *aDecoder);
         void ConstructL( );
 
-  private: // Private data types
-
-        enum TImageState
-            {
-            EInactive,
-            EStartLoad,
-            ECompleteLoad,
-            };
-
   private: // Data
-
-        // Image status & state
-        TRequestStatus* iImageStatus;
-        TImageState iImageState;
-
-        // Own: Image decoder
-        CBufferedImageDecoder* iDecoder; // owned
-
-        TFrameInfo iFrameInfo;
-        TBool iAnimation;
-        TInt iAnimationFrameCount;
-
-        // Ref: Destination bitmap
-        CMaskedBitmap* iDestination;
-        TInt iFrameIndex;
-
-        // Own: Temporary animation bitmap
-        CMaskedBitmap* iAnimationBitmap; // owned
-        TInt iAnimationFrameIndex;
-
-        WebCore::ImageObserver* iObserver; // not owned
-
-        TBool iRawDataComplete;
-
-        //Loop count for animation image. Default to -1 -- loop forever
-        TInt16 iLoopCount;
-        TInt16 iCurLoopCount;
-
-        TBool iSizeAvailable;
-        TInt iSyncBitmapHandle;
-        TBool iSyncMaskHandle;
-        TBool iDecodeInProgress;
-        static CSynDecodeThread* iSyncDecodeThread; // sync decoder thread
-        HBufC8* iDrmContent;
+      CAnimationDecoderWrapped *iWrapped;
     };
 
 #endif   // CAnimationDecoder_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webengine/osswebengine/WebCore/platform/symbian/bitmap/AnimationDecoderWrapped.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -0,0 +1,747 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+/*
+ *  This class is wrapped by a proxy CAnimationDecoder
+ *  
+ *  We needed to wrap animation decoding in a proxy because sometimes the cache gets cleared when decoding
+ *  is in progress; when that happens the animation gets deleted while it's in the middle (which causes all sorts
+ *  of crashes and memory stomping).  Now, the cache can delete the proxy while the animation is decoding; the proxy
+ *  will pass on the delete request to the decoder which will cleanup (delete itself) when it's safe to do so.
+ *  
+ */
+
+// INCLUDE FILES
+#include "config.h"
+#include "AnimationDecoderWrapped.h"
+#include "MaskedBitmap.h"
+#include "ImageObserver.h"
+#include "SyncDecodeThread.h"
+#include "Oma2Agent.h"
+using namespace ContentAccess;
+
+namespace TBidirectionalState {
+    class TRunInfo;
+};
+
+#include <eikenv.h>
+
+// constants
+
+// Private namespace for constants and functions
+namespace
+  {
+  // Panic function
+  void Panic( TInt aPanicCode ) { User::Panic( _L("AnimationDecoder"), aPanicCode ); }
+  }
+
+using namespace WebCore;
+CSynDecodeThread *CAnimationDecoderWrapped::iSyncDecodeThread  = NULL;
+
+// ============================ MEMBER FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+//
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+CAnimationDecoderWrapped::CAnimationDecoderWrapped( ImageObserver* aObs )
+    :CActive( CActive::EPriorityIdle )
+    , iObserver(aObs)
+    , iLoopCount( -1 )
+    , iCurLoopCount( -1 )
+    , iSyncBitmapHandle(-1)
+    , iSyncMaskHandle(-1)
+    , iDecodeInProgress(ETrue)
+    , iIsInvalid(EFalse)
+    , iCanBeDeleted(ETrue)
+{
+    if (CActiveScheduler::Current())
+        CActiveScheduler::Add( this );    
+}
+
+// -----------------------------------------------------------------------------
+//
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CAnimationDecoderWrapped* CAnimationDecoderWrapped::NewL( ImageObserver* aObs )
+{
+    CAnimationDecoderWrapped* self = new (ELeave) CAnimationDecoderWrapped( aObs );
+    CleanupStack::PushL( self );
+    self->ConstructL( );
+    CleanupStack::Pop(); // self
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+//
+// Symbian constructor can leave.
+// -----------------------------------------------------------------------------
+void CAnimationDecoderWrapped::ConstructL( )
+  {
+  }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CAnimationDecoderWrapped::~CAnimationDecoderWrapped()
+{
+    Cancel();
+
+    if( iDecoder ) {
+        // animated images still being decoded.
+        iDecoder->Cancel();
+        delete iDecoder, iDecoder = NULL;
+    }
+
+    delete iAnimationBitmap, iAnimationBitmap = NULL;
+    delete iDestination, iDestination = NULL;
+    if(iDrmContent) 
+    {
+        delete iDrmContent;
+        iDrmContent = NULL;
+    }
+}
+
+/**
+ * Invalidate
+ * 
+ * Mark the object invalid (to be deleted); used when it gets cleared from the cache
+ */
+void CAnimationDecoderWrapped::Invalidate()
+{
+    iIsInvalid = ETrue;
+    if (iCanBeDeleted)
+        delete this;
+}
+
+// -----------------------------------------------------------------------------
+// OpenAndDecodeSyncL
+// -----------------------------------------------------------------------------
+void CAnimationDecoderWrapped::OpenAndDecodeSyncL( const TDesC8& aData )
+{    
+    iSizeAvailable = EFalse;
+    iRawDataComplete = ETrue;
+    delete iDestination;
+    iDestination = NULL;
+    
+    if(!iSyncDecodeThread) { // first time, create decoder thread
+        iSyncDecodeThread = CSynDecodeThread::NewL();
+    }
+    
+    if (iSyncDecodeThread->Decode(aData) == KErrNone) {
+        iSyncDecodeThread->Handle(iSyncBitmapHandle, iSyncMaskHandle); 
+        Destination(); // duplicate bitmap handles
+        iSizeAvailable = ETrue;
+    }        
+}
+
+CMaskedBitmap* CAnimationDecoderWrapped::Destination() 
+{ 
+    if (iDestination) {
+        return iDestination; 
+    }
+        
+    if (iSyncBitmapHandle != -1 && iSyncMaskHandle != -1) {
+        CFbsBitmap* bitmap = new CFbsBitmap();
+        bitmap->Duplicate(iSyncBitmapHandle);
+        CFbsBitmap* mask = new CFbsBitmap();
+        mask->Duplicate(iSyncMaskHandle);
+
+        iDestination = new CMaskedBitmap(bitmap, mask);
+        iDestination->SetFrameIndex(0);
+        iDestination->SetFrameDelay(0);
+        iSyncBitmapHandle = -1;
+        iSyncMaskHandle = -1;
+    }
+    
+    return iDestination;
+}
+//=============================================================================
+// DecodeDRMImageContentL : Function for handling the DRM image content
+//=============================================================================
+HBufC8* CAnimationDecoderWrapped::DecodeDRMImageContentL(const TDesC8& aData)
+{
+    // input buffers for image conversion
+    HBufC8* bufInput = HBufC8::NewLC( aData.Length() + 1 );
+    TPtr8 ptrInput = bufInput->Des();
+    //Reader intends to view content
+    ptrInput.Append( EView );
+    ptrInput.Append( aData );
+
+    // output buffer for image conversion
+    HBufC8* animatedDRMdata = HBufC8::NewLC( aData.Length() + 256 );
+    TPtr8 ptrOutput = animatedDRMdata->Des();
+
+  //Find DRM agent
+    TAgent agentDRM;
+    
+    RArray<ContentAccess::TAgent> agents;
+    ContentAccess::CManager* manager = CManager::NewLC();
+    manager->ListAgentsL( agents );
+    for ( TInt i = 0; i < agents.Count(); i++ )
+      {
+    if ( agents[i].Name().Compare( KOmaDrm2AgentName ) == 0)
+      {
+       agentDRM = agents[i];
+       //convert the DRM image
+       manager->AgentSpecificCommand( agentDRM, EDecryptOma1DcfBuffer, ptrInput,ptrOutput);
+       break;
+      }
+    }
+
+    CleanupStack::PopAndDestroy(manager);
+    //keep animatedDRMdata to return
+    CleanupStack::Pop(animatedDRMdata);
+    CleanupStack::PopAndDestroy(bufInput);
+
+    return animatedDRMdata;
+    }
+// -----------------------------------------------------------------------------
+// OpenL
+// -----------------------------------------------------------------------------
+void CAnimationDecoderWrapped::OpenL( const TDesC8& aData, TDesC* aMIMEType, TBool aIsComplete )
+{
+    iCanBeDeleted = EFalse;
+    if(!iObserver) {
+        OpenAndDecodeSyncL(aData);
+        iCanBeDeleted = ETrue;
+        if (iIsInvalid)
+            delete this;
+        return;
+    }
+        
+    
+    delete iDestination;
+    iDestination = NULL;
+    iDestination = CMaskedBitmap::NewL();
+
+    HBufC8* mime = 0;
+    TPtrC8 buffer(aData.Ptr(),aData.Length());
+    if (aMIMEType) {
+        // it is safer to ignore the server supplied mime type and just recognize
+        // the image type from the data headers. this does not work for all formats though
+        if ( *aMIMEType==KMimeWBMP || *aMIMEType==KMimeOTA || *aMIMEType==KMimeWMF){
+            // convert to 8 bit
+            mime = HBufC8::NewLC(aMIMEType->Length());
+            mime->Des().Copy(*aMIMEType);
+        }
+        if( *aMIMEType==KMimeDRM )
+        {
+        iDrmContent = DecodeDRMImageContentL(aData);
+        
+        TInt drmContentLength = iDrmContent->Des().Length();
+        buffer.Set( (const TUint8*)iDrmContent->Des().Ptr(), drmContentLength);
+        }
+    }
+         
+    if( !iDecoder )
+        iDecoder = CBufferedImageDecoder::NewL(CEikonEnv::Static()->FsSession());
+
+    if (mime){
+        if (iDecoder) {
+            iDecoder->OpenL(buffer,*mime,CImageDecoder::EOptionNone);
+            CleanupStack::PopAndDestroy(); // mime
+        }
+    }
+    else {
+        if (iDecoder) {
+            iDecoder->OpenL(buffer,CImageDecoder::EOptionNone);
+        }
+    }
+
+    iRawDataComplete = aIsComplete;
+
+    if(iDecoder && iDecoder->ValidDecoder()  && iDecoder->IsImageHeaderProcessingComplete()) {
+        StartDecodingL();
+    }
+    else {
+        // remove me when incremental image rendering gets supported
+        iCanBeDeleted = ETrue;
+        if (iIsInvalid)
+            delete this;
+        User::Leave( KErrCorrupt );
+    }
+
+    //If it is an animated image, let's figure out loop count
+    if(IsAnimation()) {
+        // first see if have a netscape 2.0 extension header 
+        const TUint8 extString[] = { 'N', 'E', 'T', 'S', 'C', 'A', 'P','E','2','.','0','\3','\1' };
+        const TInt sizeofextString = sizeof(extString);
+        TPtrC8 rawDataPtr((TUint8*)aData.Ptr(), aData.Length());
+        TInt offset = rawDataPtr.Find(extString, sizeofextString);
+        if(offset != KErrNotFound) {
+            // found a header, get the loop count -
+            // (the loop count is in the 2 bytes following the header string listed above,
+            // stored low byte then high byte)
+            iLoopCount = (TInt16)((rawDataPtr[offset+sizeofextString+1] * 256) + rawDataPtr[offset+sizeofextString]);
+            if(iLoopCount != 0) {
+                ++iLoopCount;  // +1 to make it 1 based rather than 0 based 
+            }
+            else{
+            // 0 indicates infinite - map to internal loop count infinite value 
+                iLoopCount = -1;
+            }
+        }
+        else {
+            // no header found, assume 1x thru loop 
+            iLoopCount = 1;
+        }
+        iCurLoopCount = iLoopCount;
+    }
+    iCanBeDeleted = ETrue;
+    if (iIsInvalid)
+        delete this;
+}
+
+// -----------------------------------------------------------------------------
+// CAnimationDecoderWrapped::AddDataL
+// New chunk of raw data
+//
+// -----------------------------------------------------------------------------
+//
+void CAnimationDecoderWrapped::AddDataL(
+    const TDesC8& aNextChunk,
+    TBool aIsComplete )
+{
+    iRawDataComplete = aIsComplete;
+
+    if( iDecoder ) {
+        iDecoder->AppendDataL(aNextChunk);
+        if( iDecoder->ValidDecoder() ) {
+            //  if the image conversion is busy , then just appending the
+            // data should be sufficient
+            if(iStatus == KRequestPending) {
+                // more image data
+                iDecoder->ContinueConvert( &iStatus );
+                SetActive();
+            }
+        }
+        else {
+            iDecoder->ContinueOpenL() ;
+            if(iDecoder->ValidDecoder()  && iDecoder->IsImageHeaderProcessingComplete()){
+                StartDecodingL();
+            }
+        }
+    }
+}
+
+// -----------------------------------------------------------------------------
+// CImageLoader::StartDecodingL
+//
+// -----------------------------------------------------------------------------
+//
+void CAnimationDecoderWrapped::StartDecodingL()
+{
+    // Check frame count
+    iAnimationFrameCount = iDecoder->FrameCount();
+    iAnimation = iAnimationFrameCount > 1;
+    iFrameInfo = iDecoder->FrameInfo( 0 );
+    iSizeAvailable = ETrue;
+
+    if (iFrameInfo.iFlags & TFrameInfo::ETransparencyPossible){
+        // we only support gray2 and gray256 tiling
+        TDisplayMode maskmode = ( (iFrameInfo.iFlags & TFrameInfo::EAlphaChannel) && (iFrameInfo.iFlags & TFrameInfo::ECanDither)) ? EGray256 : EGray2;
+        TInt error = iDestination->Create( iFrameInfo.iOverallSizeInPixels, DisplayMode(), maskmode );
+
+        if (!error)
+            LoadFrame(0);
+        else
+            RunError(KErrNoMemory);
+    }
+    else {
+        TInt error = iDestination->Create( iFrameInfo.iOverallSizeInPixels, DisplayMode() );
+        if (!error)
+            LoadFrame(0);
+        else
+            RunError(KErrNoMemory);
+    }
+}
+
+// -----------------------------------------------------------------------------
+// CAnimationDecoderWrapped::MaskDisplayMode
+// -----------------------------------------------------------------------------
+TDisplayMode CAnimationDecoderWrapped::MaskDisplayMode() const
+{
+    if( iFrameInfo.iFlags & TFrameInfo::ETransparencyPossible ){
+        if( iFrameInfo.iFlags & TFrameInfo::EAlphaChannel && (iFrameInfo.iFlags & TFrameInfo::ECanDither))
+            return EGray256;
+    return EGray2;
+    }
+    return ENone;
+}
+
+// -----------------------------------------------------------------------------
+// CAnimationDecoderWrapped::AnimationFrameDelay
+// -----------------------------------------------------------------------------
+TTimeIntervalMicroSeconds32 CAnimationDecoderWrapped::AnimationFrameDelay( TInt aAnimationFrameIndex ) const
+{
+    __ASSERT_ALWAYS( aAnimationFrameIndex >= 0 &&
+    aAnimationFrameIndex < iAnimationFrameCount, Panic( KErrArgument ) );
+
+    return I64INT( iDecoder->FrameInfo( aAnimationFrameIndex ).iDelay.Int64() );
+}
+
+
+// -----------------------------------------------------------------------------
+// CAnimationDecoderWrapped::DoCancel
+// -----------------------------------------------------------------------------
+void CAnimationDecoderWrapped::DoCancel()
+{
+    iDecoder->Cancel();
+    // Delete all processed bitmaps
+    ErrorCleanup();
+    // Complete with cancel
+    iImageState = EInactive;
+}
+
+// -----------------------------------------------------------------------------
+// CAnimationDecoderWrapped::RunL
+// -----------------------------------------------------------------------------
+void CAnimationDecoderWrapped::RunL()
+{
+    // Yeah, we check this a lot in this function but it helps prevent stuff from happening that doesn't need to
+    if (iIsInvalid) {
+        delete this;
+        return;
+    }
+    iCanBeDeleted = EFalse;
+    __ASSERT_DEBUG( iDestination, Panic( KErrGeneral ) );
+    // don't kick off the image decoding until the preview mode is over
+    if (iStatus==KErrUnderflow) {
+        if (!IsAnimation())
+            iObserver->partialImage();
+        iCanBeDeleted = ETrue;
+        if (iIsInvalid)
+            delete this;
+        return;
+    }
+    else if( iStatus == KErrCorrupt ) {
+        RunError( iStatus.Int() );
+        iCanBeDeleted = ETrue;
+        if (iIsInvalid)
+            delete this;
+        return;
+    }
+    User::LeaveIfError( iStatus.Int() );
+    switch( iImageState ) {
+        case EStartLoad:
+            {
+            // start loading the bitmaps
+            StartLoadL();
+            break;
+            }
+        case ECompleteLoad:
+            {
+            // complete loading the bitmaps
+            CompleteLoadL();
+            break;
+            }
+        default:
+            {
+            iCanBeDeleted = ETrue;
+            Panic( KErrTotalLossOfPrecision );
+            }
+    }
+    iCanBeDeleted = ETrue;
+    if (iIsInvalid)
+        delete this;
+}
+
+// -----------------------------------------------------------------------------
+// CAnimationDecoderWrapped::RunError
+// -----------------------------------------------------------------------------
+TInt CAnimationDecoderWrapped::RunError( TInt aError )
+{
+    // Delete all processed bitmaps
+    ErrorCleanup();
+    // Complete with error
+    iImageState = EInactive;
+    iObserver->decoderError(aError);
+    return KErrNone;
+}
+
+// -----------------------------------------------------------------------------
+// CAnimationDecoderWrapped::LoadFrame
+// -----------------------------------------------------------------------------
+TInt CAnimationDecoderWrapped::LoadFrame( TInt aFrameIndex )
+{
+    if( IsBusy() )
+        return KErrNotReady;
+
+    if( aFrameIndex < 0 || aFrameIndex >= iDecoder->FrameCount() )
+        return KErrArgument;
+
+    iFrameIndex = aFrameIndex;
+    // Start the active object
+    iImageState = EStartLoad;
+    SelfComplete();
+    return KErrNone;
+}
+
+// -----------------------------------------------------------------------------
+// CAnimationDecoderWrapped::StartLoadL
+// -----------------------------------------------------------------------------
+void CAnimationDecoderWrapped::StartLoadL()
+{
+    __ASSERT_DEBUG( !iAnimationBitmap, Panic( KErrGeneral ) );
+
+    if( iAnimation ) {
+        // Start animation from first frame by default
+        iAnimationFrameIndex = 0;
+
+        // Check is animation can be continued on top of destination bitmap
+        if( iDestination->FrameIndex() < iFrameIndex )
+          iAnimationFrameIndex = iDestination->FrameIndex() + 1;
+
+        StartLoadAnimationBitmapL( iAnimationFrameIndex );
+    }
+    else // normal image
+        StartLoadNormalBitmap( iFrameIndex );
+    
+    iDecodeInProgress = EFalse;    
+    iImageState = ECompleteLoad;
+    SetActive();
+}
+
+// -----------------------------------------------------------------------------
+// CAnimationDecoderWrapped::StartLoadNormalBitmap
+// -----------------------------------------------------------------------------
+void CAnimationDecoderWrapped::StartLoadNormalBitmap( TInt aFrameIndex )
+{
+    CFbsBitmap& dstBitmap = iDestination->BitmapModifyable();
+    CFbsBitmap& dstMask = iDestination->MaskModifyable();
+
+    if( MaskDisplayMode() != ENone && dstMask.Handle() )
+        iDecoder->Convert( &iStatus, dstBitmap, dstMask, aFrameIndex );
+    else {
+        dstMask.Reset();
+        iDecoder->Convert( &iStatus, dstBitmap, aFrameIndex );
+    }
+}
+
+// -----------------------------------------------------------------------------
+// CAnimationDecoderWrapped::StartLoadAnimationBitmapL
+// -----------------------------------------------------------------------------
+void CAnimationDecoderWrapped::StartLoadAnimationBitmapL( TInt aFrameIndex )
+{
+    __ASSERT_DEBUG( !iAnimationBitmap, Panic( KErrGeneral ) );
+
+    // Create animation bitmap
+    iAnimationBitmap = CMaskedBitmap::NewL();
+    CFbsBitmap& animBitmap = iAnimationBitmap->BitmapModifyable();
+    CFbsBitmap& animMask = iAnimationBitmap->MaskModifyable();
+
+    TFrameInfo frameInfo( iDecoder->FrameInfo( aFrameIndex ) );
+    User::LeaveIfError( animBitmap.Create(
+    frameInfo.iOverallSizeInPixels, EColor16M ) );
+
+    TDisplayMode maskDisplayMode( ENone );
+
+    if( frameInfo.iFlags & TFrameInfo::ETransparencyPossible ) {
+        if( frameInfo.iFlags & TFrameInfo::EAlphaChannel && (frameInfo.iFlags & TFrameInfo::ECanDither)) 
+            maskDisplayMode = EGray256;
+        maskDisplayMode = EGray2;
+
+        User::LeaveIfError( animMask.Create( frameInfo.iOverallSizeInPixels, maskDisplayMode ) );
+        iDecoder->Convert( &iStatus, animBitmap, animMask, aFrameIndex );
+    }
+    else
+        iDecoder->Convert( &iStatus, animBitmap, aFrameIndex );
+}
+
+// -----------------------------------------------------------------------------
+// CAnimationDecoderWrapped::CompleteLoadL
+// -----------------------------------------------------------------------------
+void CAnimationDecoderWrapped::CompleteLoadL()
+{
+    TSize frameSize = iFrameInfo.iOverallSizeInPixels;
+    int sizeinBytes = frameSize.iWidth * frameSize.iHeight * 2;
+    if( iAnimationBitmap ){
+        // Copy animation bitmap to destination
+        BuildAnimationFrameL();
+        delete iAnimationBitmap;
+        iAnimationBitmap = NULL;
+
+        iDestination->SetFrameIndex( iAnimationFrameIndex );
+        iDestination->SetFrameDelay( AnimationFrameDelay( iAnimationFrameIndex ) );
+
+        if( iAnimationFrameIndex < iFrameIndex ) {
+            // re-start the active object and load next frame
+            iAnimationFrameIndex++;
+            iImageState = EStartLoad;
+            SelfComplete();
+        }
+        else {
+            // Animation ready
+            iImageState = EInactive;
+            iObserver->animationFrameReady(sizeinBytes);
+        }
+    }
+    else {
+        // Save source info destination
+        iDestination->SetFrameIndex( iFrameIndex );
+        iDestination->SetFrameDelay( 0 );
+        //Compress non-animated images via FBServ (losslessly, idle priority) 
+        iDestination->CompressInBackground();     
+
+        // Normal image ready
+        //iDestination = NULL;
+        iImageState = EInactive;
+        iObserver->imageReady(sizeinBytes);
+        delete iDecoder, iDecoder = NULL;
+    }
+}
+
+// -----------------------------------------------------------------------------
+// CAnimationDecoderWrapped::BuildAnimationFrameL
+// -----------------------------------------------------------------------------
+void CAnimationDecoderWrapped::BuildAnimationFrameL()
+    {
+    __ASSERT_DEBUG( iAnimationBitmap, Panic( KErrGeneral ) );
+    const CFbsBitmap& animBitmap = iAnimationBitmap->Bitmap();
+    const CFbsBitmap& animMask = iAnimationBitmap->Mask();
+    __ASSERT_DEBUG( animBitmap.Handle(), Panic( KErrGeneral ) );
+
+
+    //If the first frame starts from position(0,0), copy directly to the destination bitmap 
+    //otherwise frame has to be appropriately positioned in the destination bitmap  
+    TPoint aStartPoint(0,0);
+    if( (iAnimationFrameIndex==0) && (iFrameInfo.iFrameCoordsInPixels.iTl==aStartPoint) )
+    {
+        // First frame can be directly put into destination
+        User::LeaveIfError( iDestination->Copy( animBitmap, animMask, ETrue ) );
+    }
+    else {
+        CFbsBitmap& prevBitmap = iDestination->BitmapModifyable();
+        CFbsBitmap& prevMask = iDestination->MaskModifyable();
+
+        // Other frames must be build on top of previous frames
+        __ASSERT_DEBUG( prevBitmap.Handle(), Panic( KErrGeneral ) );
+
+        // Create bitmap device to destination bitmap
+        CFbsBitGc* bitGc;
+        CFbsBitmapDevice* bitDevice = CFbsBitmapDevice::NewL( &prevBitmap );
+        CleanupStack::PushL( bitDevice );
+        User::LeaveIfError( bitDevice->CreateContext( bitGc ) );
+        CleanupStack::PushL( bitGc );
+
+        // Restore area in destination bitmap if needed
+        TRect restoreRect;
+        TBool restoreToBackground( EFalse );
+        
+        TInt aFrameNo = (iAnimationFrameIndex >= 1)?(iAnimationFrameIndex):1;
+        TFrameInfo prevFrameInfo(iDecoder->FrameInfo(aFrameNo - 1));
+        
+        //TFrameInfo prevFrameInfo( iDecoder->FrameInfo( iAnimationFrameIndex - 1 ) );
+        
+        if( (prevFrameInfo.iFlags & TFrameInfo::ERestoreToBackground )|| (iAnimationFrameIndex ==0)) 
+        {
+            restoreToBackground = ETrue;
+            restoreRect = prevFrameInfo.iFrameCoordsInPixels;
+            bitGc->SetPenColor( prevFrameInfo.iBackgroundColor );
+            bitGc->SetBrushColor( prevFrameInfo.iBackgroundColor );
+            bitGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
+            if(iAnimationFrameIndex ==0){
+              bitGc->Clear();     
+            }
+            else{
+               bitGc->DrawRect( restoreRect );  
+            }
+            bitGc->SetBrushStyle( CGraphicsContext::ENullBrush );
+         }
+        // Copy animation frame to destination bitmap
+        TFrameInfo frameInfo( iDecoder->FrameInfo( iAnimationFrameIndex) );
+        if( animMask.Handle() ) {
+            bitGc->BitBltMasked( frameInfo.iFrameCoordsInPixels.iTl, &animBitmap,
+            animBitmap.SizeInPixels(), &animMask, EFalse );
+        }
+        else {
+            bitGc->BitBlt( frameInfo.iFrameCoordsInPixels.iTl, &animBitmap,
+            animBitmap.SizeInPixels() );
+        }
+        CleanupStack::PopAndDestroy( 2 ); // bitmapCtx, bitmapDev
+
+        // Combine masks if any
+        if( prevMask.Handle() && animMask.Handle() ) {
+            bitDevice = CFbsBitmapDevice::NewL( &prevMask );
+            CleanupStack::PushL( bitDevice );
+            User::LeaveIfError( bitDevice->CreateContext( bitGc ) );
+            CleanupStack::PushL( bitGc );
+
+            if( restoreToBackground ) {
+                bitGc->SetBrushColor( KRgbBlack );
+                bitGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
+                if(iAnimationFrameIndex ==0){
+                   bitGc->Clear();    
+                 }
+                 else{
+                   bitGc->DrawRect( restoreRect );  
+                 }
+                bitGc->SetBrushStyle( CGraphicsContext::ENullBrush );
+            }
+            CFbsBitmap* tmpMask = new(ELeave) CFbsBitmap;
+            CleanupStack::PushL( tmpMask );
+            User::LeaveIfError( tmpMask->Create( prevMask.SizeInPixels(), prevMask.DisplayMode() ) );
+            CFbsBitmapDevice* tmpMaskDev = CFbsBitmapDevice::NewL( tmpMask );
+            CleanupStack::PushL( tmpMaskDev );
+            CFbsBitGc* tmpMaskGc;
+            User::LeaveIfError( tmpMaskDev->CreateContext( tmpMaskGc ) );
+            CleanupStack::PushL( tmpMaskGc );
+
+            tmpMaskGc->BitBlt( TPoint( 0, 0 ), &prevMask, frameInfo.iFrameCoordsInPixels );
+
+            bitGc->BitBltMasked( frameInfo.iFrameCoordsInPixels.iTl, &animMask,
+            animMask.SizeInPixels(), tmpMask, ETrue );
+
+            CleanupStack::PopAndDestroy( 5 ); //tmpMask, tmpMaskDev, tmpMaskGc, bitGc, bitDevice
+        }
+    else
+        prevMask.Reset(); // Mask not valid anymore -> reset
+    }
+}
+
+// -----------------------------------------------------------------------------
+// CAnimationDecoderWrapped::ErrorCleanup
+// -----------------------------------------------------------------------------
+void CAnimationDecoderWrapped::ErrorCleanup()
+{
+    if( iAnimationBitmap ) {
+        delete iAnimationBitmap;
+        iAnimationBitmap = NULL;
+    }
+
+    if( iDestination ) {
+        delete iDestination;
+        iDestination = NULL;
+    }
+}
+
+// -----------------------------------------------------------------------------
+// CAnimationDecoderWrapped::SelfComplete
+// -----------------------------------------------------------------------------
+void CAnimationDecoderWrapped::SelfComplete( TInt aError )
+{
+    SetActive();
+    iStatus = KRequestPending;
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete( status, aError );
+}
+
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webengine/osswebengine/WebCore/platform/symbian/bitmap/AnimationDecoderWrapped.h	Thu Sep 24 12:53:48 2009 +0300
@@ -0,0 +1,253 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+/*
+ *  This class is wrapped by a proxy CAnimationDecoder
+ *  
+ *  We needed to wrap animation decoding in a proxy because sometimes the cache gets cleared when decoding
+ *  is in progress; when that happens the animation gets deleted while it's in the middle (which causes all sorts
+ *  of crashes and memory stomping).  Now, the cache can delete the proxy while the animation is decoding; the proxy
+ *  will pass on the delete request to the decoder which will cleanup (delete itself) when it's safe to do so.
+ *  
+ */
+
+#ifndef ANIMATIONDECODERWRAPPED_H_
+#define ANIMATIONDECODERWRAPPED_H_
+
+// INCLUDES
+
+#include <e32base.h>
+#include <imageconversion.h> // TFrameInfo
+
+// FORWARD DECLARATIONS
+class CMaskedBitmap;
+class CBufferedImageDecoder;
+class CSynDecodeThread;
+namespace WebCore {
+    class ImageObserver;
+}
+// CONSTANTS
+
+_LIT(KMimeJPEG, "image/jpeg");
+_LIT(KMimeJPG, "image/jpg");
+_LIT(KMimeGIF, "image/gif");
+_LIT(KMimePNG, "image/png");
+_LIT(KMimeTIFF, "image/tiff");
+_LIT(KMimeBMP, "image/bmp");
+_LIT(KMimeWBMP, "image/vnd.wap.wbmp");
+_LIT(KMimeWMF, "application/x-msmetafile");
+_LIT(KMimeMBM, "image/x-epoc-mbm");
+_LIT(KMimeOTA, "image/vnd.nokia.ota-bitmap");
+_LIT(KMimeICO, "image/x-icon");
+_LIT(KMimeDRM, "application/vnd.oma.drm.content");
+
+//const TDisplayMode KMaxDepth = EColor64K;
+
+// FIXME: we should move this back to EColor64K after Symbian fix their Gif image decoder bug.
+const TDisplayMode KMaxDepth = EColor16M;
+
+// CLASS DECLARATION
+/**
+*  CAnimationDecoderWrapped
+*
+*  Implementation of file based image class.
+*  @lib IHL.lib
+*  @since 3.0
+*/
+
+class CAnimationDecoderWrapped  : public CActive
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CAnimationDecoderWrapped* NewL(WebCore::ImageObserver* aObs);
+
+        /*
+        * Virtual destructor.
+        */
+        virtual ~CAnimationDecoderWrapped();
+
+  public:
+
+        /*
+        * From MIHLFileImage, see base class header.
+        */
+        void OpenL( const TDesC8& aData, TDesC* aMIMEType, TBool aIsComplete );
+        void OpenAndDecodeSyncL( const TDesC8& aData );
+
+        /*
+        * From MIHLFileImage, see base class header.
+        */
+        void AddDataL( const TDesC8& aData, TBool aIsComplete );
+
+        /*
+        * From MIHLFileImage, see base class header.
+        */
+        TSize Size() const { return iFrameInfo.iOverallSizeInPixels; }
+
+        /*
+        * From MIHLFileImage, see base class header.
+        */
+        TDisplayMode DisplayMode() const { return KMaxDepth; }
+
+        /*
+        * From MIHLFileImage, see base class header.
+        */
+        TDisplayMode MaskDisplayMode() const;
+
+        /*
+        * From MIHLFileImage, see base class header.
+        */
+        TRgb BackgroundColor() const { return iFrameInfo.iBackgroundColor; }
+
+        /*
+        * From MIHLFileImage, see base class header.
+        */
+        TBool IsAnimation() const { return iAnimation; }
+
+        /*
+        * From MIHLFileImage, see base class header.
+        */
+        TInt AnimationFrameCount() const { return iAnimationFrameCount; }
+
+        /*
+        * From MIHLFileImage, see base class header.
+        */
+        TTimeIntervalMicroSeconds32 AnimationFrameDelay( TInt aAnimationFrameIndex ) const;
+
+        /*
+        * From MIHLFileImage, see base class header.
+        */
+        TInt LoadFrame( TInt aFrameIndex );
+
+        /*
+        * From MIHLFileImage, see base class header.
+        */
+        TBool IsBusy() const { return ( iImageState != EInactive ); }
+
+
+        /*
+        * From MIHLFileImage, see base class header.
+        */
+        void CancelLoad() { Cancel(); }
+
+        TBool IsOpen() const { return iDecoder!=0; }
+
+        //funtions related to Loop count of animation image.
+        TInt16 getLoopCount(){return iCurLoopCount;};
+        void resetLoopCount(){iCurLoopCount = iLoopCount;};
+        void decreamentLoopCount(){ iCurLoopCount--;};
+        CMaskedBitmap* Destination();
+        TBool isSizeAvailable() const { return iSizeAvailable; }
+        TBool decodeInProgress() const { return iDecodeInProgress; }
+
+        /**
+         * Mark the object invalid (to be deleted); used when it gets cleared from the cache
+         */
+        void Invalidate();
+        
+  private: // From base class CActive
+
+        /*
+        * From CActive, see base class header.
+        */
+        void DoCancel();
+
+        /*
+        * From CActive, see base class header.
+        */
+        void RunL();
+
+        /*
+        * From CActive, see base class header.
+        */
+        TInt RunError( TInt aError );
+
+  private: // Private methods
+
+        void StartDecodingL();
+        void StartLoadL();
+        void StartLoadNormalBitmap( TInt aFrameIndex );
+        void StartLoadAnimationBitmapL( TInt aFrameIndex );
+        void CompleteLoadL();
+        void BuildAnimationFrameL();
+        void ErrorCleanup();
+        void SelfComplete( TInt aError = KErrNone );
+        HBufC8* DecodeDRMImageContentL(const TDesC8& aData);
+
+  private: // Private constructors
+
+        CAnimationDecoderWrapped(WebCore::ImageObserver* aObs);
+        void ConstructL( );
+
+  private: // Private data types
+
+        enum TImageState
+            {
+            EInactive,
+            EStartLoad,
+            ECompleteLoad,
+            };
+
+  private: // Data
+
+        // Image status & state
+        TRequestStatus* iImageStatus;
+        TImageState iImageState;
+
+        // Own: Image decoder
+        CBufferedImageDecoder* iDecoder; // owned
+
+        TFrameInfo iFrameInfo;
+        TBool iAnimation;
+        TInt iAnimationFrameCount;
+
+        // Ref: Destination bitmap
+        CMaskedBitmap* iDestination;
+        TInt iFrameIndex;
+
+        // Own: Temporary animation bitmap
+        CMaskedBitmap* iAnimationBitmap; // owned
+        TInt iAnimationFrameIndex;
+
+        WebCore::ImageObserver* iObserver; // not owned
+
+        TBool iRawDataComplete;
+
+        //Loop count for animation image. Default to -1 -- loop forever
+        TInt16 iLoopCount;
+        TInt16 iCurLoopCount;
+
+        TBool iSizeAvailable;
+        TInt iSyncBitmapHandle;
+        TBool iSyncMaskHandle;
+        TBool iDecodeInProgress;
+        static CSynDecodeThread* iSyncDecodeThread; // sync decoder thread
+        HBufC8* iDrmContent;
+        
+        // Is invalid because the cache got cleared in the middle of decoding
+        TBool iIsInvalid;
+        TBool iCanBeDeleted;
+    };
+
+
+#endif /* ANIMATIONDECODERWRAPPED_H_ */
+
+// End of File
--- a/webengine/osswebengine/WebCore/platform/symbian/bitmap/MaskedBitmap.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/symbian/bitmap/MaskedBitmap.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -23,8 +23,6 @@
 #include <bitstd.h>
 #include <bitdev.h>
 
-// CONSTANTS
-static const TInt KCompressRatioThreshold = 16;
 
 // ======================== STATIC FACTORY FUNCTIONS ===========================
 #define GET_PIX_GRAY2(buf, x, y, w)     (((TUint32*)((TUint8*)buf + y*w))[x>>5] & (1<<(x&0x1f)))
@@ -626,16 +624,15 @@
     return ETrue;
     }
 
-void CMaskedBitmap::CompressIfNeeded( TInt aRawSize )
+void CMaskedBitmap::CompressInBackground( )
     {
-    // check if the image is highly compressed
-    TSize sz = iBitmap->SizeInPixels();
-    if( KCompressRatioThreshold * aRawSize < sz.iWidth * sz.iHeight )
-        {
-        iBitmap->Compress();
-        if( HasMask() )
-            iMask->Compress();
-        }
+    
+		if ( iBitmap && iBitmap->Handle() ) 
+			iBitmap->CompressInBackground();
+		
+        if ( iMask && iMask->Handle() )
+            iMask->CompressInBackground();
+        
     }
 
 CMaskedBitmap* CMaskedBitmap::ScaleImageToSize( TSize newSize )
--- a/webengine/osswebengine/WebCore/platform/symbian/bitmap/MaskedBitmap.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/platform/symbian/bitmap/MaskedBitmap.h	Thu Sep 24 12:53:48 2009 +0300
@@ -136,7 +136,7 @@
 
         void Resize(TSize aSize);
         
-        void CompressIfNeeded( TInt aRawDataSize );
+        void CompressInBackground( );
 
         CMaskedBitmap* ScaleImageToSize( TSize newSize );
 
--- a/webengine/osswebengine/WebCore/rendering/RenderStyle.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebCore/rendering/RenderStyle.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -1443,14 +1443,16 @@
 }
 
 #if PLATFORM(SYMBIAN)
-void RenderStyle::deleteDefaultRenderStyle()
-{
-	//goes to overridden delete operator but calls destructor
-	delete defaultStyle;
-	//release cell allocated because overridder delete does not do that.
-	free(defaultStyle);
-	defaultStyle = NULL;
+struct cleanupDefaultRenderStyle  {
+    ~cleanupDefaultRenderStyle() {
+    //goes to overridden delete operator but calls destructor
+    delete defaultStyle;
+    //release cell allocated because overridder delete does not do that.
+    free(defaultStyle);
+    defaultStyle = NULL;
 }
+};
+struct cleanupDefaultRenderStyle defaultRenderStyle;
 #endif
 
 }
--- a/webengine/osswebengine/WebKit/s60/data/Webkit.rss	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/data/Webkit.rss	Thu Sep 24 12:53:48 2009 +0300
@@ -246,5 +246,7 @@
 RESOURCE TBUF r_qtn_browser_dialog_scriptlog_t1 { buf=qtn_browser_dialog_scriptlog_t1; } 
 RESOURCE TBUF r_qtn_browser_dialog_scriptlog_sk2 { buf=qtn_browser_dialog_scriptlog_sk2; } 
 RESOURCE TBUF r_qtn_browser_dialog_scriptlog_t2 { buf=qtn_browser_dialog_scriptlog_t2; } 
+RESOURCE TBUF r_qtn_browser_choose_file_sym {buf=qtn_browser_choose_file_text;}
 RESOURCE TBUF r_qtn_browser_dialog_scriptlog_disable_msg { buf=qtn_browser_dialog_scriptlog_disable_msg; }     
 
+
--- a/webengine/osswebengine/WebKit/s60/group/webcore/platform/platform.mmp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/group/webcore/platform/platform.mmp	Thu Sep 24 12:53:48 2009 +0300
@@ -143,6 +143,7 @@
 SOURCE KURLSymbian.cpp
 SOURCE MimeTypeRegistrySymbian.cpp
 SOURCE OOMHandler.cpp
+SOURCE OOMStopper.cpp
 SOURCE PasteboardSymbian.cpp
 SOURCE PathSymbian.cpp
 SOURCE PictographSymbian.cpp
@@ -167,6 +168,7 @@
 
 SOURCEPATH ../../../../../WebCore/platform/symbian/bitmap
 SOURCE AnimationDecoder.cpp
+SOURCE AnimationDecoderWrapped.cpp
 SOURCE BitmapTiler.cpp
 SOURCE MaskedBitmap.cpp
 SOURCE SyncDecodeThread.cpp
--- a/webengine/osswebengine/WebKit/s60/loc/Webkit.loc	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/loc/Webkit.loc	Thu Sep 24 12:53:48 2009 +0300
@@ -417,4 +417,6 @@
 //
 #define qtn_browser_dialog_scriptlog_disable_msg     "Are you sure you want to disable the javascript log? You can re-enable it in Browser Settings/General tab."
 
+#define qtn_browser_choose_file_text     "Choose File"
+
 // End of File
--- a/webengine/osswebengine/WebKit/s60/plugins/NpnImplementation.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/plugins/NpnImplementation.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -321,8 +321,8 @@
                 npWindow->y = rect.iTl.iY;
                 npWindow->width = rect.Width();
                 npWindow->height = rect.Height();
-                npWindow->type = NPWindowTypeWindow;
-                npWindow->window = NULL;
+                npWindow->type = pluginWin->Windowed() ? NPWindowTypeWindow : NPWindowTypeDrawable;
+                npWindow->window = pluginWin->Windowed() ? NULL : (MPluginAdapter*) pluginWin;
             
                 NPRect clipRect = {0,0,0,0};
                 npWindow->clipRect = clipRect;
@@ -389,6 +389,17 @@
             }
         }
         break;  // for code consistency
+        
+       case NPNVSupportsWindowless:{
+            PluginWin* pluginWin = (PluginWin*)aInstance->ndata;
+               if (pluginWin) {
+                   *((TBool*) aRetValue) = ETrue;
+               }
+               else {
+                   err = NPERR_GENERIC_ERROR;
+               }
+       }
+       break;		   
         default:
             {
             *((TBool*) aRetValue) = EFalse;
--- a/webengine/osswebengine/WebKit/s60/plugins/PluginSkin.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/plugins/PluginSkin.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -159,7 +159,8 @@
       m_instance(0),    
       m_pluginfuncs(0),
       m_resized(false),
-      m_oldPos(TPoint(-1,-1))
+      m_oldRect(TRect(0,0,0,0)),
+      m_oldViewport(TRect(0,0,0,0))
   {
   }
 
@@ -740,15 +741,16 @@
     if ( !m_pluginwin ) {
         return;
     }
-    TRect rect = m_rect;
-    TPoint newPos = m_frame->frameView()->frameCoordsInViewCoords(rect.iTl);
+    TPoint tl = m_frame->frameView()->frameCoordsInViewCoords(m_rect.iTl);
+    TPoint br = m_frame->frameView()->frameCoordsInViewCoords(m_rect.iBr);      
+    TRect rect = TRect(tl, br);
     TRect newViewport = m_frame->frameView()->topView()->DocumentViewport();
     
-    if (m_oldPos != newPos || m_oldViewport != newViewport) {
-        m_oldPos = newPos;
+    if (m_oldRect != rect || m_oldViewport != newViewport) {
+        m_oldRect = rect;
         m_oldViewport = newViewport;
         TRect clipRect(frameVisibleRect());
-        clipRect.Intersection(rect);
+        clipRect.Intersection(m_rect);
         setClipRect(clipRect);
         setPluginWinClipedRect();
     }
--- a/webengine/osswebengine/WebKit/s60/plugins/PluginSkin.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/plugins/PluginSkin.h	Thu Sep 24 12:53:48 2009 +0300
@@ -472,7 +472,7 @@
         WTF::HashSet<PluginStream*>  m_streams;
         
         RArray<NPN_GenericElement>*  iGenericElementArray;
-        TPoint   m_oldPos;
+        TRect   m_oldRect;
         TRect    m_oldViewport;
         
 
--- a/webengine/osswebengine/WebKit/s60/plugins/PluginStream.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/plugins/PluginStream.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -300,6 +300,11 @@
         if (i >= 0) {
             fileExtPtr.Set(fileExtPtr.Mid(i));
         }
+        else{
+                        TBuf8<KMaxFileName> fileName(fileExtPtr);
+                        fileName.Append(tempFileName.Mid((tempFileName.LocateReverse('.'))));
+                        fileExtPtr.Set(fileName);
+            }
     }
         
             
--- a/webengine/osswebengine/WebKit/s60/plugins/PluginStreamLoaderClient.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/plugins/PluginStreamLoaderClient.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -131,6 +131,8 @@
 void NetscapePlugInStreamLoaderClient::start()
 {
     if (m_loader) {
+        // Protect the loader from being deleted by errors before we finish with it (prevents a crash)
+        RefPtr<ResourceLoader> protector(m_loader);
         m_loader->documentLoader()->addSubresourceLoader(m_loader);
         m_loader->load(*m_request);            
     }
--- a/webengine/osswebengine/WebKit/s60/plugins/PluginWin.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/plugins/PluginWin.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -81,9 +81,8 @@
     } else {
         SetContainerWindowL(*view.brCtl()->CCoeControlParent());
         m_bitmap = new (ELeave) CFbsBitmap();
-        m_bitmap->Create(TSize(0,0),WebCore::StaticObjectsContainer::instance()->webSurface()->displayMode());
-        m_mask = new (ELeave) CFbsBitmap();
-        m_mask->Create(TSize(0,0),EGray2);
+        TDisplayMode mode = m_transparentPlugin ? EColor16MA : WebCore::StaticObjectsContainer::instance()->webSurface()->displayMode();
+        m_bitmap->Create(TSize(0,0), mode);
     }
     // Add the focus/foreground observer
     ControlEnv()->AddForegroundObserverL( *this ) ;
@@ -102,9 +101,6 @@
     // Remove the foreground observer
     ControlEnv()->RemoveForegroundObserver( *this );
     delete m_bitmap;
-    delete m_mask;
-    delete m_bitmapDeviceMask;
-    delete m_bitmapContextMask;
 }
 
 // -----------------------------------------------------------------------------
@@ -145,12 +141,6 @@
     if (ret != KErrNone) {
         delete m_bitmap;
         m_bitmap = NULL;
-        delete m_mask;
-        m_mask = NULL;
-        delete m_bitmapDeviceMask;
-        m_bitmapDeviceMask = NULL;
-        delete m_bitmapContextMask;
-        m_bitmapContextMask = NULL;
     }
     if (m_forceScroll)
     	m_forceScroll = EFalse;
@@ -193,24 +183,7 @@
         if (m_windowedPlugin) {
              window.window =  (MPluginAdapter*)this;
         } else {
-             //m_bitmap->Resize(myRect.Size());
-             // Resize does not work!
-             // Once the bug is fixed we can call Resize() instead of creating a new bitmap every time.
-             if (!m_bitmap || m_bitmap->SizeInPixels() != myRect.Size()) {
-                 delete m_bitmap;
-                 m_bitmap = NULL;
-                 m_bitmap = new (ELeave) CFbsBitmap();
-                 TDisplayMode mode = m_transparentPlugin ? EColor16MA : WebCore::StaticObjectsContainer::instance()->webSurface()->displayMode();
-                 m_bitmap->Create(myRect.Size(), mode);
-                 delete m_mask;
-                 m_mask = NULL;
-                 if (m_transparentPlugin) {
-                     m_mask = new (ELeave) CFbsBitmap();
-                     m_mask->Create(myRect.Size(), mode);
-                     m_bitmapDeviceMask = CFbsBitmapDevice::NewL( m_mask );
-                     User::LeaveIfError(m_bitmapDeviceMask->CreateContext(m_bitmapContextMask));
-                 }
-             }
+             m_bitmap->Resize(rect.Size());
              window.window = (CFbsBitmap*)m_bitmap;
         }
 		if (!m_windowedPlugin || m_windowCreated)
--- a/webengine/osswebengine/WebKit/s60/plugins/PluginWin.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/plugins/PluginWin.h	Thu Sep 24 12:53:48 2009 +0300
@@ -479,6 +479,7 @@
     void PlayPausePluginL ();
     void HandlePointerEventFromPluginL(const TPointerEvent& aEvent);
     TBool HandleGesture(const RT_GestureHelper::TGestureEvent& aEvent);    
+	TBool Windowed() { return m_windowedPlugin;}
     protected: // New functions
 
         /**
@@ -501,9 +502,6 @@
         bool                                m_windowedPlugin;
         bool                                m_transparentPlugin;
         CFbsBitmap*                         m_bitmap;       //The bitmap for windowless plugin
-        CFbsBitmap*                         m_mask;         //The mask for transparent windowless plugin
-        CFbsBitmapDevice*                   m_bitmapDeviceMask;
-        CFbsBitGc*                          m_bitmapContextMask; 
         bool                                m_fullscreen;
         bool                                m_windowCreated;
         bool                                m_forceScroll;
--- a/webengine/osswebengine/WebKit/s60/webcoresupport/WebEditorClient.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/webcoresupport/WebEditorClient.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -104,8 +104,7 @@
 //-----------------------------------------------------------------------------
 bool WebEditorClient::shouldEndEditing(WebCore::Range*)
 {
-    notImplemented();
-    return false;
+    return m_shouldEndEditing;
 }
 
 //-----------------------------------------------------------------------------
@@ -327,6 +326,7 @@
         return;
     }
 
+    m_shouldEndEditing = false;
     // Move to the right frame
     frame = m_webView->page()->focusController()->focusedOrMainFrame();
 
@@ -367,7 +367,18 @@
                 break;
 
             case EKeyLeftArrow:
-                frame->editor()->execCommand("MoveLeft");
+                if (select) //If shift is pressed then highlight the selection
+                {
+                //Webview Passes EEventKeyDown and EEventKey due to which 2 characters are getting selected in one key press
+                //Avoiding one Event so that for each key press it selects 1 character only
+                 if(kevent->isKeyDown())
+                    break;
+                 frame->editor()->execCommand("MoveLeftAndModifySelection");//from createCommandMap()
+                }
+                else
+                {
+                 frame->editor()->execCommand("MoveLeft");
+                }
                 m_webView->fepTextEditor()->HandleUpdateCursor();
                 if (frame->selectionController()->start() != startPos &&
                     frame->selectionController()->end() != endPos) {
@@ -376,7 +387,18 @@
                 break;
 
             case EKeyRightArrow:
-                frame->editor()->execCommand("MoveRight");
+                if (select)//If shift is pressed then highlight the selection
+                {
+                //Webview Passes EEventKeyDown and EEventKey due to which 2 characters are getting selected in one key press
+                //Avoiding one Event so that for each key press it selects 1 character only
+                 if(kevent->isKeyDown())
+                    break;
+                 frame->editor()->execCommand("MoveRightAndModifySelection");
+                }
+                else
+                {
+                 frame->editor()->execCommand("MoveRight");
+                }
                 m_webView->fepTextEditor()->HandleUpdateCursor();
                 if (frame->selectionController()->start() != startPos &&
                     frame->selectionController()->end() != endPos) {
@@ -391,6 +413,9 @@
                     frame->selectionController()->end() != endPos) {
                     event->setDefaultHandled();
                 }
+                else {
+                    m_shouldEndEditing = true;
+                }
                 break;
 
             case EKeyDownArrow:
@@ -400,9 +425,13 @@
                     frame->selectionController()->end() != endPos) {
                     event->setDefaultHandled();
                 }
+                else {
+                    m_shouldEndEditing = true;
+                }
                 break;
                 
             case EKeyEnter:
+            case EKeyDevice3:    
             	// If we are in a textarea, add a newline
                 if (m_webView->fepTextEditor()->IsTextAreaFocused()) {
                     if (m_webView->fepTextEditor()->DocumentLengthForFep() <
--- a/webengine/osswebengine/WebKit/s60/webcoresupport/WebEditorClient.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/webcoresupport/WebEditorClient.h	Thu Sep 24 12:53:48 2009 +0300
@@ -104,6 +104,7 @@
 
 private:
     WebView* m_webView;
+    bool     m_shouldEndEditing;
 };
 
 
--- a/webengine/osswebengine/WebKit/s60/webview/BrCtl.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/webview/BrCtl.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -238,12 +238,15 @@
 }
 
 CFbsBitmap* HistoryHandler::scaledPage()
-{
-    CFbsBitmap* scaledPage = m_brctl->wmlMode() ? m_brctl->wmlPageScaler().ScaledPage() :
-        m_brctl->webView()->pageScaler()->ScaledPage();
-
-    return scaledPage;
-
+{   
+    CFbsBitmap* scaledPage = NULL;   
+    if ( m_brctl->wmlMode() && &m_brctl->wmlPageScaler() ) {
+        scaledPage = m_brctl->wmlPageScaler().ScaledPage();
+    }
+    else if( !m_brctl->wmlMode() && m_brctl->webView()->pageScaler() ) {
+        scaledPage = m_brctl->webView()->pageScaler()->ScaledPage();
+    }
+    return scaledPage;    
 }
 
 void HistoryHandler::makeVisible(bool visible)
@@ -2452,3 +2455,5 @@
 {
     m_webView->HandlePointerBufferReadyL();
 }
+
+
--- a/webengine/osswebengine/WebKit/s60/webview/SettingsContainer.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/webview/SettingsContainer.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -81,6 +81,7 @@
     brctlSettings[TBrCtlDefs::ESettingsToolbarButton6Cmd] = 12;
     brctlSettings[TBrCtlDefs::ESettingsToolbarButton7Cmd] = 13;
     brctlSettings[TBrCtlDefs::ESettingsScriptLog] = 0;
+    brctlSettings[TBrCtlDefs::ESettingsCursorShowMode] = 1;
 
     updatePageSetting(TBrCtlDefs::ESettingsAutoLoadImages);
     updatePageSetting(TBrCtlDefs::ESettingsFontSize);
@@ -246,6 +247,7 @@
         case TBrCtlDefs::ESettingsScriptLog:
         case TBrCtlDefs::ESettingsZoomLevelMin:
         case TBrCtlDefs::ESettingsZoomLevelMax:
+        case TBrCtlDefs::ESettingsCursorShowMode:    
         case TBrCtlDefs::ESettingsZoomLevelDefault:
             {
             retVal = brctlSettings[setting];
--- a/webengine/osswebengine/WebKit/s60/webview/WebCursor.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/webview/WebCursor.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -262,7 +262,12 @@
 // -----------------------------------------------------------------------------
 void WebCursor::cursorUpdate(bool visible)
 {
-    if (!m_view || !m_view->brCtl()->settings())
+    if (!m_view || !m_view->brCtl() || !m_view->brCtl()->settings())
+        return;
+    //If cursor show mode defined inside cenrep key is no cursor shown in non-tab navigation mode,
+    //then no need to update the cursor
+    if (m_view->brCtl()->settings()->getNavigationType() != SettingsContainer:: NavigationTypeTabbed &&
+            (m_view->brCtl()->settings()->brctlSetting(TBrCtlDefs::ESettingsCursorShowMode) == TBrCtlDefs::ENoCursor))
         return;
     if ( m_view->showCursor() ) {
         m_visible = visible && ((m_view->brCtl()->settings()->getNavigationType() == SettingsContainer::NavigationTypeCursor)|| m_view->focusedElementType() == TBrCtlDefs::EElementSelectMultiBox); // check for tabbedNavigation here because it is called from so many places.
@@ -562,6 +567,60 @@
 
 
 //-------------------------------------------------------------------------------
+//-------------------------------------------------------------------------------
+// WebCursor::scrollingDirection()
+//-------------------------------------------------------------------------------
+void WebCursor::scrollingDirection(int dir, int& lr, int& tb)
+{
+     switch (dir)
+       {
+         case EKeyUpArrow:             // North
+           tb = -1;
+           break;
+
+         case EKeyRightUpArrow:        // Northeast
+         case EStdKeyDevice11:         //   : Extra KeyEvent supports diagonal event simulator wedge
+           tb = -1;
+           lr = +2;                    // Make it run closer to 45 degrees
+           break;
+
+         case EKeyRightArrow:          // East
+           lr = +1;
+           break;
+
+         case EKeyRightDownArrow:      // Southeast
+         case EStdKeyDevice12:         //   : Extra KeyEvent supports diagonal event simulator wedge
+           tb = +1;
+           lr = +2;
+           break;
+
+         case EKeyDownArrow:           // South
+           tb = +1;
+           break;
+
+         case EKeyLeftDownArrow:       // Southwest
+         case EStdKeyDevice13:         //   : Extra KeyEvent supports diagonal event simulator wedge
+           tb = +1;
+           lr = -2;
+           break;
+
+         case EKeyLeftArrow:           // West
+           lr = -1;
+           break;
+
+         case EKeyLeftUpArrow:         // Northwest
+         case EStdKeyDevice10:         //   : Extra KeyEvent supports diagonal event simulator wedge
+           tb = -1;
+           lr = -2;
+           break;
+
+         default:
+           break;
+       }
+    }
+
+
+//-------------------------------------------------------------------------------
 // WebCursor::scrollAndMoveCursor
 //
 // Method that scrolls and moves the cursor based on the navigation algorithm
@@ -578,53 +637,7 @@
     int deltaX;
     int deltaY;
 
-    switch (dir)
-      {
-
-        case EKeyUpArrow:             // North
-          tb = -1;
-          break;
-
-        case EKeyRightUpArrow:        // Northeast
-        case EStdKeyDevice11:         //   : Extra KeyEvent supports diagonal event simulator wedge
-          tb = -1;
-          lr = +2;                    // Make it run closer to 45 degrees
-          break;
-
-        case EKeyRightArrow:          // East
-          lr = +1;
-          break;
-
-        case EKeyRightDownArrow:      // Southeast
-        case EStdKeyDevice12:         //   : Extra KeyEvent supports diagonal event simulator wedge
-          tb = +1;
-          lr = +2;
-          break;
-
-        case EKeyDownArrow:           // South
-          tb = +1;
-          break;
-
-        case EKeyLeftDownArrow:       // Southwest
-        case EStdKeyDevice13:         //   : Extra KeyEvent supports diagonal event simulator wedge
-          tb = +1;
-          lr = -2;
-          break;
-
-        case EKeyLeftArrow:           // West
-          lr = -1;
-          break;
-
-        case EKeyLeftUpArrow:         // Northwest
-        case EStdKeyDevice10:         //   : Extra KeyEvent supports diagonal event simulator wedge
-          tb = -1;
-          lr = -2;
-          break;
-
-        default:
-          break;
-
-      }
+    scrollingDirection(dir, lr, tb);
 
     deltaX = lr * scrollRange/2;
     deltaY = tb * scrollRange;
@@ -709,6 +722,47 @@
 }
 
 // -----------------------------------------------------------------------------
+// WebCursor::simpleScroll
+// -----------------------------------------------------------------------------
+void WebCursor::simpleScroll(int dir, int scrollRange, bool autoscroll)
+{
+    if (!m_view)
+        return;
+
+    int lr = 0;
+    int tb = 0;
+
+    scrollingDirection(dir, lr, tb);
+
+    int deltaX = lr * scrollRange/2;
+    int deltaY = tb * scrollRange;
+
+    TPoint delta = TPoint(deltaX, deltaY);
+    WebFrameView* fv = m_view->mainFrame()->frameView();
+    TPoint oldpos = fv->contentPos();
+
+    if (autoscroll || m_view->pageView()) {
+        // just simple scroll
+        fv->scrollTo(oldpos + delta);
+    }
+
+    if (!m_view->pageView()) {
+        TPoint cp = position();
+        if (fv->contentPos() == oldpos) {
+            // not scrolling, move the cursor instead
+            cp.iX += deltaX;
+            cp.iY += deltaY;
+        } else {
+            // move cursor slowly out of the way
+            cp.iX += deltaX/6;
+            cp.iY += deltaY/6;
+        }
+        setPosition(cp);
+        reset();
+    }
+}
+
+// -----------------------------------------------------------------------------
 // WebCursor::updatePositionAndElemType
 // -----------------------------------------------------------------------------
 void WebCursor::updatePositionAndElemType(const TPoint& pt)
--- a/webengine/osswebengine/WebKit/s60/webview/WebCursor.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/webview/WebCursor.h	Thu Sep 24 12:53:48 2009 +0300
@@ -66,6 +66,7 @@
         void increaseTransparencyMoveCount();
         void resetTransparency();
         void scrollAndMoveCursor(int dir, int scrollRange, bool auto);
+        void simpleScroll(int dir, int scrollRange, bool auto=true);
         WebFrame* getFrameUnderCursor();
         bool navigableNodeUnderCursor(WebFrame& webFrame, TPoint& aPoint, TBrCtlDefs::TBrCtlElementType& aElType, TRect& aFocusRect) const;
         WebFrame* getFrameAtPoint(const TPoint& viewPos_);
@@ -82,6 +83,7 @@
         bool frameHasContentToScroll(WebFrame* frame, TPoint& delta);
         WebFrame*  determineScrollingFrame(int border1, int border2, int pos, 
         		                           WebFrame* fr1, WebFrame* fr2, TPoint& delta);
+        void scrollingDirection(int dir, int& lr, int& tb);
     private:
 
         WebCursor();
--- a/webengine/osswebengine/WebKit/s60/webview/WebFepTextEditor.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/webview/WebFepTextEditor.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -445,14 +445,15 @@
 		if ( frame && frame->document()->focusedNode() ) {
 			if ( IsTextAreaFocused() ) {
                 HTMLTextAreaElement* ie = static_cast<HTMLTextAreaElement*>(frame->document()->focusedNode());                                                 
-                while(editNode && !editNode->isTextNode())
+                while(editNode && !editNode->isTextNode()) {
                     editNode = editNode->previousSibling();
+                }
 				TInt len( 0 );
 				if ( editNode ) {
 					findPrevSiblingTextLen( editNode, len );
 				}
 				aCursorSelection.SetSelection( ((sc->baseOffset()+len > ie->value().length()) ? 0 : sc->baseOffset()+len),
-                                                  ((sc->extentOffset()+len > ie->value().length()) ? 0 : sc->baseOffset()+len));
+                                                  ((sc->extentOffset()+len > ie->value().length()) ? 0 : sc->extentOffset()+len));
 			}
 			else {
 				aCursorSelection.SetSelection(sc->baseOffset(), sc->extentOffset());
@@ -744,6 +745,7 @@
     state->SetCurrentInputMode(inputMode);
     state->SetPermittedInputModes(permittedInputModes);
     state->SetNumericKeymap(static_cast<TAknEditorNumericKeymap>(numericKeyMap));
+    state->ReportAknEdStateEventL(MAknEdStateObserver::EAknSyncEdwinState);
     state->ReportAknEdStateEventL(MAknEdStateObserver::EAknEdwinStateInputModeUpdate);
 }
 
@@ -1179,11 +1181,12 @@
 		return ;
     TCursorSelection selection;
     GetCursorSelectionForFep(selection);
+    TInt len = DocumentLengthForFep();
 
-	HBufC* buf = HBufC::NewLC(512);
+	HBufC* buf = HBufC::NewLC(len);
 	TPtr ptr(buf->Des());
 
-    GetEditorContentForFep(ptr,0,DocumentLengthForFep());
+    GetEditorContentForFep(ptr,0,len);
     CPlainText* text = CPlainText::NewL(CPlainText::EFlatStorage);
 
 	text->InsertL(0,*buf);
@@ -1295,18 +1298,19 @@
     GetCursorSelectionForFep(selection);
     const TInt cursorPos=selection.LowerPos();
 
-	HBufC* buf1 = HBufC::NewLC(512);
+    TInt len = DocumentLengthForFep();
+	HBufC* buf1 = HBufC::NewLC(len);
 	TPtr ptr1(buf1->Des());
 
 	CPlainText* text = CPlainText::NewL(CPlainText::EFlatStorage);
 
-    GetEditorContentForFep(ptr1,0,DocumentLengthForFep());
+    GetEditorContentForFep(ptr1,0,len);
 
     text->InsertL(0,*buf1);
 
     TInt charPasted = text->PasteFromStoreL(aStore,aDict,cursorPos);
 
-    HBufC* buf = HBufC::NewLC(512);
+    HBufC* buf = HBufC::NewLC(charPasted);
     TPtr ptr(buf->Des());
     text->Extract(ptr,cursorPos,charPasted);
 
@@ -1393,7 +1397,7 @@
 			WebCore::Text* aText = (WebCore::Text*)aNode;
 			str = aText->data();
 			len +=  str.length();
-			if ( len > aPos ) {
+			if ( len >= aPos ) {
 				// We found the text node at aPos, calculate the length of all
 				// previous text nodes
 				retNode = aNode;
--- a/webengine/osswebengine/WebKit/s60/webview/WebPointerEventHandler.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/webview/WebPointerEventHandler.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -66,6 +66,8 @@
 static const int KDoubleTapMinActivationInterval = 100000;     // 100 ms
 static const int KDoubleTapMaxActivationInterval = 500000;     // 500 ms
 static const int KDoubleTapIdleInterval = 700000;			// 700 ms, to prevent triple-tap effects
+#define IS_NAVIGATION_NONE      (m_webview->brCtl()->settings()->getNavigationType() == SettingsContainer::NavigationTypeNone)
+#define IS_TABBED_NAVIGATION    (m_webview->brCtl()->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed)
 
 //-----------------------------------------------------------------------------
 // WebPointerEventHandler::NewL
@@ -192,7 +194,13 @@
       case EGestureSwipeDown:
       {
           m_ignoreTap = false;
+          if (!IS_NAVIGATION_NONE) {
           handleTouchUp(aEvent);      
+          }
+          else {
+              Frame* frm = m_webview->page()->focusController()->focusedOrMainFrame();
+              m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Up, m_highlightPos, frm);
+          }
           break;    
       }
       // sent on move
@@ -252,12 +260,13 @@
     m_buttonDownEvent = m_currentEvent;
     m_highlightPos = aEvent.CurrentPos();
     
-    if ( !m_buttonDownTimer.isActive() && !m_webview->inPageViewMode() && 
-         !pluginToActivate ){
+    if ( !m_buttonDownTimer.isActive() && !m_webview->inPageViewMode()){
         m_buttonDownTimer.startOneShot(0.1f);        
     }
 
+    if (!IS_NAVIGATION_NONE) {
     m_webview->pageScrollHandler()->handleTouchDownGH(aEvent);
+    }
 
     if ( TBrCtlDefs::EElementActivatedObjectBox == elType) {
         PluginSkin* plugin = m_webview->mainFrame()->focusedPlugin();
@@ -270,10 +279,7 @@
             }
         }
     }
-    if (pluginToActivate) {
-        Frame* coreFrame = core(m_webview->mainFrame());
-        coreFrame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(m_buttonDownEvent));
-    }    
+    
     /*
      * After introducing "link selection" pointer down action is done in 
      * buttondown timer callback. When "down" gesture event is arrived we start 
@@ -298,7 +304,9 @@
     m_highlightedNode = NULL;
     PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
     pluginHandler->setPluginToActivate(NULL);
+    if (!IS_NAVIGATION_NONE) {
     m_webview->pageScrollHandler()->handleTouchUpGH(aEvent);
+    }
 }
 
 // ======================================================================
@@ -311,9 +319,15 @@
     PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
     pluginHandler->setPluginToActivate(NULL);
     m_buttonDownTimer.stop();
+    if (IS_NAVIGATION_NONE) {
+        Frame* frm = m_webview->page()->focusController()->focusedOrMainFrame();
+        m_webview->sendMouseEventToEngine(TPointerEvent::EMove, curPos, frm);
+    }
+    else {
     HandleHighlightChange(curPos);
     
     m_webview->pageScrollHandler()->handleScrollingGH(aEvent);
+    }
 }
 
 
@@ -346,17 +360,9 @@
         else if (aPointerEvent.iType == TPointerEvent::EButton1Up) {
             m_webview->GetContainerWindow().DisablePointerMoveBuffer();
         }
-        if (m_webview->brCtl()->settings()->getNavigationType() == SettingsContainer::NavigationTypeNone) {
-            TPointerEvent event;
-            event.iPosition = aPointerEvent.iPosition;
-            event.iModifiers = 0;
-            event.iType = aPointerEvent.iType;
 
-            if (event.iType == TPointerEvent::EDrag) event.iType = TPointerEvent::EMove;
-            m_webview->sendMouseEventToEngine(event.iType, event.iPosition, core(m_webview->mainFrame()));
-            return;
         }
-    }
+
 
     if (m_webview->brCtl()->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed) {
         m_webview->tabbedNavigation()->updateCursorPosition(aPointerEvent.iPosition);
@@ -407,28 +413,29 @@
     Frame* coreFrame = core(m_webview->mainFrame());
     WebCursor* cursor = StaticObjectsContainer::instance()->webCursor();
     m_webview->page()->chrome()->client()->setElementVisibilityChanged(false);
-    HitTestResult htresult(cursor->position());
     TPointerEvent event;
     TPoint pos = cursor->position();
-    event.iPosition = pos;
-    event.iModifiers = 0;
-    event.iType = TPointerEvent::EMove;
-    coreFrame->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event),&htresult);
-    WebFrame* frm = cursor->getFrameUnderCursor();
-    TPoint pt(frm->frameView()->viewCoordsInFrameCoords(pos));
+    IntPoint point(pos.iX, pos.iY);   
+    HitTestResult htresult = coreFrame->eventHandler()->hitTestResultAtPoint(point, true);
+    Node* eventNode = htresult.innerNode();
+    Frame* frm = eventNode->document()->frame();
+    WebFrame* wfrm = kit(frm);
+    TPoint pt(wfrm->frameView()->viewCoordsInFrameCoords(pos));
     TPoint nodePoint;
     
     m_highlightedNode = NULL;
 
-    cursor->navigableNodeUnderCursor(*(frm), pt, elType, elRect);
+    frm->bridge()->getTypeFromElement(eventNode, elType, elRect);
     if (elType == TBrCtlDefs::EElementNone) {
         
-        Node* n = frm->getClosestAnchorElement(cursor->position(), pos);
+        Node* n = wfrm->getClosestAnchorElement(cursor->position(), pos);
         if (n) {
-            htresult = HitTestResult(pos);
-            event.iPosition = pos;
-            coreFrame->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event),&htresult);
-            coreFrame->bridge()->getTypeFromElement(htresult.innerNode(), elType, elRect);
+            point.setX(pos.iX);
+            point.setY(pos.iY);
+            htresult = coreFrame->eventHandler()->hitTestResultAtPoint(point, true);
+            eventNode = htresult.innerNode();
+            frm = eventNode->document()->frame();
+            frm->bridge()->getTypeFromElement(eventNode, elType, elRect);
             TPoint nodePoint = n->getRect().Rect().Center();
             m_offset = (pt.iX- nodePoint.iX)*(pt.iX- nodePoint.iX) +
                        (pt.iY- nodePoint.iY)*(pt.iY- nodePoint.iY);
@@ -436,7 +443,7 @@
             
         }
     }
-    m_highlightedNode = htresult.innerNode();
+    m_highlightedNode = eventNode;
     if (m_highlightedNode) {
         m_highlightPos = pos;
         m_buttonDownEvent.iPosition = m_highlightPos;
@@ -491,7 +498,8 @@
      // between "up" and "down" that means that some node event 
      // listener (onMouseOver etc) handling happened and we don't 
      // want to send a click (mouse press + mouse release) event.
-     if (m_webview->page()->chrome()->client()->elementVisibilityChanged()) {
+     if (!IS_NAVIGATION_NONE && 
+         m_webview->page()->chrome()->client()->elementVisibilityChanged()) {
          return;
      }
 
@@ -502,7 +510,6 @@
     // don't pass the event if the text input is not in valid format
     if (isHighlitableElement(elType) || m_webview->fepTextEditor()->validateTextFormat()) {
         // because of scrolling we delay sending EButton1Down till we get EButton1Up event and if the content is not scrolling
-        coreFrame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(m_buttonDownEvent));
         coreFrame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(m_lastTapEvent));
     }
 
@@ -531,14 +538,9 @@
     // sending any other pointer value may result in highligh of other links
     m_highlightPos = TPoint(-1, -1);
     m_isHighlighted = EFalse;
-    TPointerEvent event;
-    event.iType = TPointerEvent::EMove;
-    event.iPosition = m_highlightPos;
-    event.iModifiers = 0;
 
-    Frame* coreFrame = core(m_webview->mainFrame());
     Frame* frm = m_webview->page()->focusController()->focusedOrMainFrame();
-    frm->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event));
+    m_webview->sendMouseEventToEngine(TPointerEvent::EMove, m_highlightPos, frm);
 
     
     m_highlightedNode = NULL;
@@ -588,7 +590,6 @@
 {
     m_buttonDownTimer.stop();
 
-    WebCursor*  cursor = StaticObjectsContainer::instance()->webCursor();
     
     Frame* coreFrame = core(m_webview->mainFrame());
     TPointerEvent event;
@@ -600,11 +601,9 @@
     }
     m_isHighlighted = (m_highlightedNode != NULL) && (elType != TBrCtlDefs::EElementNone) ;
     
-    event.iPosition = m_highlightPos;
-    event.iModifiers = 0;
-    event.iType = TPointerEvent::EMove;
+    m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Down, m_highlightPos, coreFrame);
 
-    coreFrame->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event));
+    m_webview->sendMouseEventToEngine(TPointerEvent::EMove, m_highlightPos, coreFrame);
     m_waiter->AsyncStop();
 }
 
--- a/webengine/osswebengine/WebKit/s60/webview/WebPolicyManager.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/webview/WebPolicyManager.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -37,6 +37,7 @@
 
 // CONSTANTS
 const char* typeTextHtml = "text/html";
+const char* typeTextXml = "text/xml";
 const char* typeApplicationXhtml = "application/xhtml+xml";
 const char* typeTextPlain = "text/plain";
 const char* typeApplicationWapXhtml = "application/vnd.wap.xhtml+xml";
@@ -160,7 +161,8 @@
     if (MIMEType == typeTextHtml ||
         MIMEType == typeApplicationXhtml ||
         MIMEType == typeApplicationWapXhtml ||
-        MIMEType == typeMultipartMixed) {
+        MIMEType == typeMultipartMixed || 
+        MIMEType == typeTextXml) {
         found = true;
     }
     //Check if the image type can be handled by the browser. If not
--- a/webengine/osswebengine/WebKit/s60/webview/WebView.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/webview/WebView.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -98,6 +98,7 @@
 #include "eikon.hrh"
 #include "WebScrollbarDrawer.h"
 #include "EventNames.h"
+#include "Editor.h"
 
 using namespace WebCore;
 using namespace EventNames;
@@ -582,7 +583,7 @@
         }
         layoutPending = false;
     }
-    
+
     if ( !layoutPending || !isLoading()) {
         bool needsDraw = false;
         m_repaints.Tidy();
@@ -862,12 +863,12 @@
     if ( !consumed && isNaviKey(keyevent) ) {
         if (m_webfeptexteditor->validateTextFormat() ) {
             setFocusNone();
-        } 
+        }
         else {
             consumed = true;
         }
     }
-    
+
     return consumed;
 }
 
@@ -880,29 +881,40 @@
 }
 
 
+void WebView::sendMouseEventToEngineIfNeeded(TPointerEvent::TType eventType, TPoint pos, Frame* frame)
+{
+    if (m_brctl->settings()->getNavigationType() != SettingsContainer::NavigationTypeTabbed &&
+        (m_brctl->settings()->brctlSetting(TBrCtlDefs::ESettingsCursorShowMode) == TBrCtlDefs::ENoCursor))
+        {
+        return;
+        }
+
+	sendMouseEventToEngine(eventType, pos, frame);
+}
+
 void WebView::sendMouseEventToEngine(TPointerEvent::TType eventType, TPoint pos, Frame* frame)
 {
     TPointerEvent event;
     event.iPosition = pos;
     event.iModifiers = 0;
     event.iType = eventType;
-    
+
     switch (eventType) {
         case TPointerEvent::EButton1Down:
         {
             frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event));
             break;
         }
-    
-        case TPointerEvent::EButton1Up: 
+
+        case TPointerEvent::EButton1Up:
         {
             frame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(event));
             break;
         }
-        
+
         case TPointerEvent::EMove:
         {
-            frame->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event)); 
+            frame->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event));
             break;
         }
     };
@@ -919,26 +931,33 @@
     }
 }
 
-bool WebView::needDeactivateEditable(const TKeyEvent& keyevent, TEventCode eventcode)
+bool WebView::needDeactivateEditable(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame)
 {
-    bool upOrDown = ((keyevent.iCode == EKeyDevice3) ||
-                    (keyevent.iCode == EKeyUpArrow) ||
+    bool upOrDown = ((keyevent.iCode == EKeyUpArrow) ||
                     (keyevent.iCode == EStdKeyUpArrow) ||
                     (keyevent.iCode == EKeyRightUpArrow) ||
                     (keyevent.iCode == EKeyDownArrow) ||
                     (keyevent.iCode == EStdKeyDownArrow) ||
                     (keyevent.iCode == EKeyLeftDownArrow));
+    bool shouldEndEditing = frame->editor()->client()->shouldEndEditing(NULL);
     bool inEditState  = (m_isEditable && (m_focusedElementType == TBrCtlDefs::EElementActivatedInputBox));
     bool isSelectBoxActive = (m_focusedElementType == TBrCtlDefs::EElementSelectBox);
-    bool deactivateInputBox = (inEditState && upOrDown);
+    bool deactivateInputBox = (inEditState && upOrDown && m_webfeptexteditor->validateTextFormat());
     bool deactivateSelectBox = (isSelectBoxActive && isNaviKey(keyevent));
 
-    return deactivateInputBox || deactivateSelectBox; 
+    bool deactivateEditable = (m_isEditable && shouldEndEditing && m_webfeptexteditor->validateTextFormat());
+    return deactivateEditable || deactivateSelectBox; 
 }
 
 
 bool WebView::deactivateEditable()
 {
+    WebCursor* cursor = StaticObjectsContainer::instance()->webCursor();
+    Frame* frame = page()->focusController()->focusedOrMainFrame();
+    SelectionController* sc = frame->selectionController();
+    TRect rect = sc->caretRect().Rect();
+    TPoint pos = kit(frame)->frameView()->frameCoordsInViewCoords(rect.iBr);
+    cursor->setPosition(pos);
     setFocusNone();
     m_prevEditMode = true;
     setEditable( EFalse );
@@ -947,51 +966,33 @@
 
 bool WebView::handleEventKeyL(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame)
 {
-    WebCursor* cursor = StaticObjectsContainer::instance()->webCursor();
     bool consumed = false;
     bool tabbedNavigation = (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed);
-    bool navigationNone = (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeNone); 
+    bool navigationNone = (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeNone);
     TKeyEvent oldKeyEvent(m_currentEventKey);
-    oldKeyEvent.iCode = keyevent.iCode; 
+    oldKeyEvent.iCode = keyevent.iCode;
     TEventCode oldKeyCode = m_currentEventCode;
-    bool downEventConsumed = false;
     m_currentEventKey = keyevent;
     m_currentEventCode = eventcode;
 
     if (navigationNone) {
-        consumed = handleInputElement(keyevent, eventcode, frame);
-        if (!consumed)
-            consumed = sendKeyEventToEngine(keyevent, eventcode, frame);
+        if (oldKeyCode == EEventKeyDown) {
+            consumed = sendKeyEventToEngine(keyevent, EEventKeyDown, frame);
+        }
     }
     else {
-        if (needDeactivateEditable(keyevent, eventcode)) {
-            consumed = deactivateEditable();
-            handleKeyNavigation(keyevent, eventcode, frame);
-        }
-        else if (keyevent.iCode == EKeyDevice3) {
-            sendMouseEventToEngine(TPointerEvent::EButton1Down,
-                                   cursor->position(), frame);
+        if (keyevent.iCode == EKeyDevice3) { //selection key (MSK)
                 // mimic ccb's behavior of onFocus
-            setFocusedNode(frame);
-            if (oldKeyCode == EEventKeyDown && 
-                (m_focusedElementType != TBrCtlDefs::EElementActivatedInputBox)){
-                sendKeyEventToEngine(oldKeyEvent, EEventKeyDown, frame);
-            }
-           
+           consumed = handleMSK(keyevent, oldKeyCode, frame);
+
            // Toolbar is activated on long key press only if the element
            // type is EElementNone during EEventKeyDown and EEventKey.
            // This prevents toolbar from popping up in DHTML pages. Also,
            // toolbar is activated when the user is not in fast scroll
            // mode, or in page overview mode, or on wml page.
-           if ( ( m_focusedElementType == TBrCtlDefs::EElementNone ||
-                  m_focusedElementType == TBrCtlDefs::EElementBrokenImage ) &&
-                  keyevent.iRepeats && !m_brctl->wmlMode() ) {
-               launchToolBarL();
-           }
-           consumed = true;
-        } 
+        }
         else if (isNaviKey(keyevent)) {
-            consumed = handleNaviKeyEvent(oldKeyEvent, oldKeyCode, frame);
+            consumed = handleNaviKeyEvent(keyevent, oldKeyCode, frame);
         } // if (m_brctl->settings()->getNavigationType()
         else { // Not an arrow key..
                  // activate hovered input element by just start typing
@@ -1004,31 +1005,54 @@
     return consumed;
 }
 
-bool WebView::handleNaviKeyEvent(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame)  
+bool WebView::handleMSK(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame)
+{
+    WebCursor* cursor = StaticObjectsContainer::instance()->webCursor();
+    bool prevEditableState = m_isEditable;
+    if (m_focusedElementType != TBrCtlDefs::EElementActivatedInputBox ) {
+        sendMouseEventToEngineIfNeeded(TPointerEvent::EButton1Down,
+                               cursor->position(), frame);
+    }
+    setFocusedNode(frame);
+    bool textAreaJustActivated = (!prevEditableState && m_isEditable &&
+                                  m_focusedElementType == TBrCtlDefs::EElementTextAreaBox);
+    if (eventcode == EEventKeyDown && 
+        m_focusedElementType != TBrCtlDefs::EElementActivatedInputBox &&
+        !textAreaJustActivated) {
+        sendKeyEventToEngine(keyevent, EEventKeyDown, frame);
+    }
+     if ((m_focusedElementType == TBrCtlDefs::EElementNone ||
+          m_focusedElementType == TBrCtlDefs::EElementBrokenImage ) &&
+          keyevent.iRepeats && !m_brctl->wmlMode() ) {
+         launchToolBarL();
+     }
+     return true;
+}
+bool WebView::handleNaviKeyEvent(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame)
 {
     bool downEventConsumed = false;
     bool consumed = false;
     bool tabbedNavigation = (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed);
     /*
-     * For each platform keyDown event EventHandler::keEvent() generates 
+     * For each platform keyDown event EventHandler::keEvent() generates
      * keydown and keypress.
-     * For keypress event we need a char code and since we don't 
-     * have it at the time of EEventKeyDown we pospond it until EEventKey 
+     * For keypress event we need a char code and since we don't
+     * have it at the time of EEventKeyDown we pospond it until EEventKey
      * and send it here.
      */
     if (eventcode == EEventKeyDown){
         downEventConsumed = sendKeyEventToEngine(keyevent, EEventKeyDown, frame);
     }
 
-    if (m_isEditable && !downEventConsumed && m_webfeptexteditor->validateTextFormat()) {
-        setFocusNone();
+    if (!downEventConsumed && needDeactivateEditable(keyevent, eventcode, frame)) {
+        deactivateEditable();
     }
 
     if (tabbedNavigation) {
         consumed = downEventConsumed || handleTabbedNavigation(m_currentEventKey, m_currentEventCode);
     }
-    else {  
-        consumed = (!m_isEditable &&  //avoid showing the cursor when we are in the input box 
+    else {
+        consumed = (!m_isEditable &&  //avoid showing the cursor when we are in the input box
                     handleKeyNavigation(keyevent, eventcode, frame)) ||
                     downEventConsumed;
     }
@@ -1040,23 +1064,23 @@
 {
     WebCursor* cursor = StaticObjectsContainer::instance()->webCursor();
     bool sendMousedEvent = false;
-    if (m_focusedElementType == TBrCtlDefs::EElementInputBox || 
+    if (m_focusedElementType == TBrCtlDefs::EElementInputBox ||
         m_focusedElementType == TBrCtlDefs::EElementTextAreaBox) {
         sendMousedEvent = true;
     }
     else if (m_focusedElementType == TBrCtlDefs::EElementSelectBox ||
         m_focusedElementType == TBrCtlDefs::EElementSelectMultiBox) {
-        if (m_brctl->settings()->getNavigationType() != SettingsContainer::NavigationTypeNone || 
+        if (m_brctl->settings()->getNavigationType() != SettingsContainer::NavigationTypeNone ||
             keyevent.iCode == EKeyDevice3) {
             sendMousedEvent = true;
         }
     }
     if (sendMousedEvent) {
-        sendMouseEventToEngine(TPointerEvent::EButton1Down, cursor->position(), frame);
-        sendMouseEventToEngine(TPointerEvent::EButton1Up, cursor->position(), frame);
+        sendMouseEventToEngineIfNeeded(TPointerEvent::EButton1Down, cursor->position(), frame);
+        sendMouseEventToEngineIfNeeded(TPointerEvent::EButton1Up, cursor->position(), frame);
 
         if (m_focusedElementType == TBrCtlDefs::EElementInputBox ||
-            m_focusedElementType == TBrCtlDefs::EElementTextAreaBox || 
+            m_focusedElementType == TBrCtlDefs::EElementTextAreaBox ||
             m_focusedElementType == TBrCtlDefs::EElementActivatedInputBox) {
             if (!m_fepTimer) {
                 m_fepTimer = new WebCore::Timer<WebView>(this, &WebView::fepTimerFired);
@@ -1088,8 +1112,15 @@
     if(!pageView()) {
        m_savedPosition = mainFrame()->frameView()->contentPos();
     }
-
-    cursor->scrollAndMoveCursor(keyevent.iCode, m_scrollingSpeed, fastscroll);
+    // simple scrolling if no cursor mode
+    if (m_brctl->settings()->getNavigationType() != SettingsContainer::NavigationTypeTabbed &&
+            (m_brctl->settings()->brctlSetting(TBrCtlDefs::ESettingsCursorShowMode) == TBrCtlDefs::ENoCursor)){
+        setFocusNone();
+        cursor->simpleScroll(keyevent.iCode, m_scrollingSpeed);
+    }
+    else{
+        cursor->scrollAndMoveCursor(keyevent.iCode, m_scrollingSpeed, fastscroll);
+    }
     updateScrollbars();
     if (!fastscroll) {
         m_fastScrollTimer->Start(KCursorInitialDelay,KCursorUpdateFrquency,TCallBack(&scrollTimerCb,this));
@@ -1100,9 +1131,9 @@
     consumed = handleMinimapNavigation();
 
     if (!fastscroll) {
-        sendMouseEventToEngine(TPointerEvent::EMove, cursor->position(), frame);
+        sendMouseEventToEngineIfNeeded(TPointerEvent::EMove, cursor->position(), frame);
     }
-    
+
     consumed = true;
     return consumed;
 }
@@ -1111,7 +1142,7 @@
 bool WebView::handleMinimapNavigation()
 {
     int scrollingTime = millisecondsScrolled();
-    if (!AknLayoutUtils::PenEnabled() && m_pageScalerEnabled && 
+    if (!AknLayoutUtils::PenEnabled() && m_pageScalerEnabled &&
           m_pageScaler && !isSmallPage() &&
           m_brctl->settings()->brctlSetting(TBrCtlDefs::ESettingsPageOverview) &&
          (scrollingTime > KPanningPageScalerStart || m_pageScaler->Visible())) {
@@ -1182,13 +1213,13 @@
     bool consumed = false;
     TInt delay = 2 * KCursorInitialDelay;
     WebCursor* cursor = StaticObjectsContainer::instance()->webCursor();
-    
+
     m_fastScrollTimer->Cancel();
     m_scrollingSpeed = KNormalScrollRange*100/scalingFactor();
 
     if (viewIsFastScrolling()) {
         setViewIsFastScrolling(false);
-        sendMouseEventToEngine(TPointerEvent::EMove, cursor->position(), frame);
+        sendMouseEventToEngineIfNeeded(TPointerEvent::EMove, cursor->position(), frame);
         toggleRepaintTimer(true);
         if (!inPageViewMode()) {
             delay = 0;
@@ -1202,19 +1233,19 @@
     //If we adjusted iCode we have to reset it to 0 after we
     //create PlatformKeyEventSymbian when we send the key event.
     //Otherwise the character will be drawn twice - by fep editor and by
-    //WebEditorClient. These two custom eventcodes serves as indicator that 
+    //WebEditorClient. These two custom eventcodes serves as indicator that
     //PlatformKeyEventSymbian::m_symbianEvent.iCode nee to be reset to 0.
     if (correctedKeyEvent.iCode != m_currentEventKey.iCode) {
         eventCodeDown = (TEventCode)(EEventUser + 1);
-        eventCodeUp = (TEventCode)(EEventUser + 2);    
+        eventCodeUp = (TEventCode)(EEventUser + 2);
     }
-    
+
     if ( (keyevent.iScanCode == EStdKeyDevice3) ||
        (keyevent.iScanCode == EStdKeyEnter) ) {
        // pass it to webcore
 
         if (( m_focusedElementType == TBrCtlDefs::EElementInputBox ||
-            m_focusedElementType == TBrCtlDefs::EElementTextAreaBox) && 
+            m_focusedElementType == TBrCtlDefs::EElementTextAreaBox) &&
             m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed ) {
             if (!m_prevEditMode) {
                 setEditable(true);
@@ -1225,7 +1256,7 @@
         }
         if (m_brctl->settings()->getNavigationType() != SettingsContainer::NavigationTypeNone) {
             if (!sendKeyEventToEngine(correctedKeyEvent, eventcode, frame)) {
-                sendMouseEventToEngine(TPointerEvent::EButton1Up, cursor->position(), frame);
+                sendMouseEventToEngineIfNeeded(TPointerEvent::EButton1Up, cursor->position(), frame);
             }
             consumed = true;
         }
@@ -1247,10 +1278,10 @@
 {
     TUint code = m_currentEventKey.iCode;
     // if fep editor was invoked then it consume TKeyEvent and as
-    // result we have KeyEvent.iCode == 0. So we assume here that 
+    // result we have KeyEvent.iCode == 0. So we assume here that
     // if element is editable and no iCode in KeyEvent then fep editor
-    // already put the right character into the input area and we can get 
-    // the correct iCode from the last entered char. 
+    // already put the right character into the input area and we can get
+    // the correct iCode from the last entered char.
     if (m_isEditable && !m_currentEventKey.iCode && m_webfeptexteditor) {
         TInt len = m_webfeptexteditor->DocumentLengthForFep();
         if (len > 0) {
@@ -1261,7 +1292,7 @@
             }
         }
     }
-    
+
     return code;
 }
 
@@ -1270,22 +1301,10 @@
 {
     bool tabbedNavigation = (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed);
     Node* targetNode = frame->document()->focusedNode();
-    bool hasOnKeyDown = false;
-    bool hasOnKeyUp = false;
-    bool hasOnKeyPress = false;    
-    
-    for (Node* n = targetNode; n; n = n->parentNode()) {
-        EventTargetNode* tnode = static_cast<EventTargetNode*>(n);
-        hasOnKeyDown = tnode->getHTMLEventListener(keydownEvent);
-        hasOnKeyUp = tnode->getHTMLEventListener(keyupEvent);
-        hasOnKeyPress = tnode->getHTMLEventListener(keypressEvent);
-        if (hasOnKeyDown || hasOnKeyUp || hasOnKeyPress) {
-            break;
-        }
-    }
-    
-    
-    if (!m_isEditable && !(hasOnKeyDown || hasOnKeyUp || hasOnKeyPress)) {
+    if (!m_isEditable) {
+
+
+
         frame->document()->setFocusedNode(NULL);
     }
     bool consumed = frame->eventHandler()->keyEvent(PlatformKeyboardEvent(keyevent,eventcode));
@@ -1296,7 +1315,7 @@
         TKeyEvent ke = keyevent;
         TChar c(ke.iCode);
         // Not consumed by WebCore, is alphanumeric and does not have any modifier
-        if (c.IsAlphaDigit() && 
+        if (c.IsAlphaDigit() &&
             !(ke.iModifiers & (EModifierCtrl | EModifierAlt | EModifierShift))) {
             ke.iModifiers = EModifierCtrl;
             frame->eventHandler()->keyEvent(PlatformKeyboardEvent(ke,EEventKeyDown));
@@ -1566,10 +1585,14 @@
     Frame* focusedFrame = page()->focusController()->focusedFrame();
 
     if (editable && focusedFrame) {
+        if (!AknLayoutUtils::PenEnabled())
+            notifyFullscreenModeChangeL(EFalse);
         m_webfeptexteditor->UpdateEditingMode();
         focusedNode = focusedFrame->document()->focusedNode();
     }
     else {
+        if (!AknLayoutUtils::PenEnabled())
+            notifyFullscreenModeChangeL(ETrue);
         m_webfeptexteditor->CancelEditingMode();
     }
 
@@ -1617,11 +1640,17 @@
     if (m_pageFullScreenHandler) {
         m_pageFullScreenHandler->SizeChanged();
     }
-    
+
     if (m_pageScrollHandler) {
         m_pageScrollHandler->scrollbarDrawer()->redrawScrollbar();
     }
-    
+
+    if (m_toolbar && m_toolbarinterface) {
+        m_toolbar->AnimateToolBarClosing(EFalse);
+        closeToolBarL();
+        launchToolBarL();
+    }
+
 }
 
 TSize WebView::maxBidiSize() const
@@ -1669,7 +1698,7 @@
                 r.Grow(1, 1);
             m_repaints.AddRect(r);
         }
-        
+
         region.Close();
     }
     else {
@@ -2280,25 +2309,25 @@
 
   // Double Tap Zooming: it toggles between default, maxiZoomLevel.
   // Depending on the current zoom level:
-  //   A. If the current is already the max, it zooms to the max 
+  //   A. If the current is already the max, it zooms to the max
   //   B. If the current is bigger than/equal to the default zoom level zooms to the default, it zooms to the max
-  //   C. Otherwise it zooms to the default level first. 
+  //   C. Otherwise it zooms to the default level first.
   // For the mobile pages, such as google.com and cnn.com, minimum zoom level equals
   // to the default zoom level. Zooming is only possible between default and maximum
   // zoom level, double tap only won't reach logic C
   //
-  // For both mobile and non-mobile pages, it creates the same end user double tap 
-  // experiences 
-  
+  // For both mobile and non-mobile pages, it creates the same end user double tap
+  // experiences
+
     if (m_currentZoomLevel == m_maxZoomLevel ) {
-        zoomLevel = KZoomLevelDefaultValue;    	
+        zoomLevel = KZoomLevelDefaultValue;
     }
     else if (m_currentZoomLevel >= KZoomLevelDefaultValue ) {
         zoomLevel = m_maxZoomLevel;
-    }	
+    }
     else {
-        zoomLevel = KZoomLevelDefaultValue;    	
-    } 
+        zoomLevel = KZoomLevelDefaultValue;
+    }
 
     // move the content
     WebFrameView* view = mainFrame()->frameView();
@@ -2692,8 +2721,8 @@
             event.iPosition = StaticObjectsContainer::instance()->webCursor()->position();
             event.iModifiers = 0;
             event.iType = TPointerEvent::EMove;
-            core(mainFrame())->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event));            
-            
+            core(mainFrame())->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event));
+
         }
         else {
             int x, y;
@@ -2709,11 +2738,11 @@
                 event.iPosition = StaticObjectsContainer::instance()->webCursor()->position();
                 event.iModifiers = 0;
                 event.iType = TPointerEvent::EMove;
-                core(mainFrame())->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event));            
+                core(mainFrame())->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event));
             }
         }
 
-        if (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed) { 
+        if (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed) {
             m_tabbedNavigation->focusedElementChanged(element);
         }
         // onload event on the first page could happen before the view becomes visible
--- a/webengine/osswebengine/WebKit/s60/webview/WebView.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/webview/WebView.h	Thu Sep 24 12:53:48 2009 +0300
@@ -459,10 +459,12 @@
         bool handleEventKeyUp(const TKeyEvent& keyevent, TEventCode eventcode, WebCore::Frame* frame);
         bool handleEditable(const TKeyEvent& keyevent, TEventCode eventcode, WebCore::Frame* frame );
         bool isNaviKey(const TKeyEvent& keyevent);
-        bool needDeactivateEditable(const TKeyEvent& keyevent, TEventCode eventcode);
+        bool needDeactivateEditable(const TKeyEvent& keyevent, TEventCode eventcode, WebCore::Frame* frame);
         bool deactivateEditable();
         TUint correctKeyCode();
         bool handleNaviKeyEvent(const TKeyEvent& keyevent, TEventCode eventcode, WebCore::Frame* frame); 
+        bool handleMSK(const TKeyEvent& keyevent, TEventCode eventcode, WebCore::Frame* frame);
+        void sendMouseEventToEngineIfNeeded(TPointerEvent::TType eventType, TPoint pos, WebCore::Frame* frame);
    
     public:
         void sendMouseEventToEngine(TPointerEvent::TType eventType, TPoint pos, WebCore::Frame* frame);
--- a/webengine/osswebengine/WebKit/s60/webview/WmlResourceLoaderClient.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/WebKit/s60/webview/WmlResourceLoaderClient.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -145,7 +145,7 @@
         chunkIndex++;     
     }
 
-    if (m_contentType && m_charset && m_url) {
+    if (m_contentType && m_charset && m_url && m_wmldispatcher) {
         m_wmldispatcher->WmlParameters( data, length, *m_contentType, *m_charset, m_httpStatus, chunkIndex, *m_url);        
     }
     
@@ -155,20 +155,26 @@
 void WmlResourceLoaderClient::didFinishLoading()
 {
     TInt chunkIndex = -1;      // last chunk
-    if (m_contentType && m_charset && m_url) {
+    if (m_contentType && m_charset && m_url && m_wmldispatcher) {
         m_wmldispatcher->WmlParameters( NULL, 0, *m_contentType, *m_charset, m_httpStatus, chunkIndex, *m_url );
     }
-    m_wmldispatcher->HandleError(0,KErrCompletion);
+    if ( m_wmldispatcher ) {
+        m_wmldispatcher->HandleError(0,KErrCompletion);
+    }
 }
 
 void WmlResourceLoaderClient::didFail(const WebCore::ResourceError& error)
 {    
-    m_wmldispatcher->HandleError(0,error.errorCode());
+    if ( m_wmldispatcher ) {
+        m_wmldispatcher->HandleError(0,error.errorCode());
+    }
 }
 
 void WmlResourceLoaderClient::didCancel(const WebCore::ResourceError& error)
 {
-    m_wmldispatcher->HandleError(0,error.errorCode());
+    if ( m_wmldispatcher ) {
+        m_wmldispatcher->HandleError(0,error.errorCode());
+    }
 }
 
 // End of File
Binary file webengine/osswebengine/cache/conf/httpcachemanager.confml has changed
Binary file webengine/osswebengine/cache/conf/httpcachemanager_101F8557.crml has changed
--- a/webengine/osswebengine/cache/group/BrowserCache.mmp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/group/BrowserCache.mmp	Thu Sep 24 12:53:48 2009 +0300
@@ -28,6 +28,7 @@
 VENDORID  VID_DEFAULT
 CAPABILITY  CAP_GENERAL_DLL
 EPOCALLOWDLLDATA
+//MACRO HTTP_CACHE_LOGGING
 
 
 #if defined(WINSCW)
--- a/webengine/osswebengine/cache/inc/HttpCacheEntry.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/inc/HttpCacheEntry.h	Thu Sep 24 12:53:48 2009 +0300
@@ -38,8 +38,14 @@
 class RFileReadStream;
 class CHttpCacheEvictionHandler;
 class CHttpCacheStreamHandler;
+class CHttpCacheEntry;
 
 // CLASS DECLARATION
+class MHttpCacheEntryDeleteObserver
+    {
+public:
+    virtual void EntryDeleted(CHttpCacheEntry *aEntry) = 0;
+    };
 
 /**
 *
@@ -290,6 +296,24 @@
          */
          void UnsetEvictionCandidate() { iEvictionCandidate = EFalse; };    // this only exists because when EvictL removes an item from the eviction candidate list, it can't tell the entry that this has happened and so the entry then goes on to attempt to remove itself later when it's being deleted.
 
+        /**
+         *
+         * @since 7.1
+         * @param
+         * @return
+         *
+         */
+         void SetDeleteObserver(MHttpCacheEntryDeleteObserver* aObserver);
+
+        /**
+         *
+         * @since 7.1
+         * @param
+         * @return
+         *
+         */
+         void ClearDeleteObserver();
+         
     public :
 
         // support linked list
@@ -388,6 +412,9 @@
         TUint32                         iWriteState;
         //
         CHttpCacheEntryAsyncWriteHelper* iWriteHelper;      //owned
+        //
+        MHttpCacheEntryDeleteObserver* iDeleteObserver;    // NOT owned
+       
     };
 
 #endif      // CHTTPCACHEENTRY_H
--- a/webengine/osswebengine/cache/inc/HttpCacheFileWriteHandler.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/inc/HttpCacheFileWriteHandler.h	Thu Sep 24 12:53:48 2009 +0300
@@ -22,6 +22,7 @@
 #include <e32base.h>
 #include <f32file.h>
 #include "HttpCacheHandler.h"
+#include "HttpCacheEntry.h"
 #include "MemoryManager.h"
 
 // CONSTANTS
@@ -43,7 +44,7 @@
 *  @lib
 *  @since 5.0
 */
-NONSHARABLE_CLASS(CHttpCacheFileWriteHandler) : public CActive, public MMemoryCollector
+NONSHARABLE_CLASS(CHttpCacheFileWriteHandler) : public CActive, public MMemoryCollector, public MHttpCacheEntryDeleteObserver
     {
     public:  // Constructors and destructor
 
@@ -54,7 +55,7 @@
         * @param
         * @return CacheFileWriteHandler object.
         */
-        static CHttpCacheFileWriteHandler* NewL(CHttpCacheHandler* aManager, CHttpCacheStreamHandler* aStreamHandler, RFs& aRfs, const TInt aWriteTimeout);
+        static CHttpCacheFileWriteHandler* NewL(CHttpCacheHandler* aManager, CHttpCacheStreamHandler* aStreamHandler, RFs& aRfs, const THttpCachePostponeParameters& aParams);
 
         /**
         * Destructor.
@@ -97,6 +98,10 @@
          */
         TBool IsCacheEntryPostponed(const CHttpCacheEntry* aEntry);
 
+    public: // from MHttpCacheEntryDeleteObserver
+        virtual void EntryDeleted(CHttpCacheEntry *aEntry); 
+        
+        
     public: // new functions
         enum TAddStatus {
             EAddedOk,
@@ -148,7 +153,7 @@
         /**
         * By default Symbian 2nd phase constructor is private.
         */
-        void ConstructL(const TInt aWriteTimeout);
+        void ConstructL(const THttpCachePostponeParameters& aParams);
 
         /**
          * from CActive
@@ -166,6 +171,7 @@
 
         // sort by size function for arrays of CHttpCacheEntry objects.
         static TInt CompareHttpCacheEntrySize( const CHttpCacheEntry& aFirst, const CHttpCacheEntry& aSecond );
+
         void CollectMemory( TUint aRequired );
 
         /**
--- a/webengine/osswebengine/cache/inc/HttpCacheHandler.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/inc/HttpCacheHandler.h	Thu Sep 24 12:53:48 2009 +0300
@@ -45,6 +45,7 @@
 class THttpCacheEntry;
 class CHttpCacheObserver;
 class CHttpCacheFileWriteHandler;
+class CHttpCacheFileHash;
 
 // CLASS DECLARATION
 
@@ -59,91 +60,6 @@
         TInt    iWriteTimeout;
     };
 
-NONSHARABLE_CLASS( TCompressedEntry )
-    {
-    public:
-        ~TCompressedEntry() { if(!IsCompressed()) delete iName.iNameAsHBuf; };
-        static TCompressedEntry *NewL( const TEntry& aEntry );
-
-    private:
-        TCompressedEntry(){};
-        void ConstructL( const TEntry& aEntry );
-        enum {
-            EFilenameStoredAsUint32 = 0x01
-        };
-
-    public:
-        TBool IsCompressed() { return (iFlags && TCompressedEntry::EFilenameStoredAsUint32); };
-        static TBool ConvertANameToUint32( const TDesC& aName, TUint32& aConverted);
-        static TInt ConvertAsciiToIntSingleHexDigit(const TUint16& aDigitChar);
-        TUint32 GetSize() { return iSize; };
-        HBufC* GetNameL();
-        TUint32 GetCompressedName() { return iName.iNameAsUint32; };
-
-    private:
-        TUint32 iFlags;
-        TUint32 iSize;
-        union {
-            TUint32 iNameAsUint32;
-            HBufC*  iNameAsHBuf;
-        }iName;
-    };
-
-NONSHARABLE_CLASS( CCustomCacheDirList ) : public CBase
-    {
-    public:
-        static CCustomCacheDirList* NewL(CDir *aSrc);
-        ~CCustomCacheDirList() { iDirList.ResetAndDestroy(); };
-
-    public:
-        TBool ValidateCacheEntryL( const CHttpCacheEntry& aEntry );
-        TInt Count();
-        HBufC* NameAtL( TInt aIndex );
-
-    private:
-        CCustomCacheDirList();
-        void ConstructL(CDir *aSrc);
-
-    private:
-        RPointerArray<TCompressedEntry> iDirList;
-    };
-
-NONSHARABLE_CLASS( CCacheDirectoryFiles ) : public CBase
-    {
-    public:
-        static CCacheDirectoryFiles* NewL(RFs aRfs, const TDesC& aDir);
-        static CCacheDirectoryFiles* NewLC(RFs aRfs, const TDesC& aDir);
-
-    public:
-        /*
-         * Check to see if the entry passed in has a valid file in the directory listing
-         * returns ETrue if file present and size matches entry
-         * otherwise EFalse.
-         * Removes matching files from stored list.
-         */
-        TBool ValidateEntryL(const CHttpCacheEntry& aEntry);
-
-        /*
-         * Delete any files in the stored list from the filesystem
-         * Intended to be called after you have validated all the entries
-         * against the list - the content of the list will now only be the
-         * orphan files in the cache subdirectories.
-         * IMPORTANT: only call this once you've looked at all your entries.
-         */
-        void RemoveLeftoverFilesL();
-
-    private:
-        CCacheDirectoryFiles(RFs aRfs, const TDesC& aDir) : iRfs(aRfs), iDir(aDir) {};
-        ~CCacheDirectoryFiles();
-        void ConstructL();
-
-    private:
-        RFs iRfs;
-        const TDesC& iDir;
-
-        RPointerArray<CCustomCacheDirList> iDirContent;
-    };
-
 /**
 *
 *  @lib
@@ -422,13 +338,14 @@
          */
         void GenerateValidationFilename(TDes& aFilename, const TDesC& aIndexFilename) const;
 
+    public:
         /**
          *
          * @since 7.1
          * @param
          * @return
          */
-        void ValidateCacheEntriesL();
+        void ValidateCacheEntriesL(CHttpCacheFileHash *aDiskContent);
 
     private:    // Data
 
@@ -444,8 +361,10 @@
         HBufC*                          iDirectory; // owned
         // name of the index file
         HBufC*                          iIndexFile; // owned
+    public:
         // Observing changes in cache
         CHttpCacheObserver* iHttpCacheObserver; // owned
+    private:
         // An opened and configured file server session
         RFs iRfs;
         //
--- a/webengine/osswebengine/cache/inc/HttpCacheLookupTable.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/inc/HttpCacheLookupTable.h	Thu Sep 24 12:53:48 2009 +0300
@@ -146,7 +146,7 @@
         * @param
         * @return
         */
-        void MergeL( CHttpCacheLookupTable* aHttpCacheLookupTable, RFs aRfs  );
+        void MergeL( CHttpCacheLookupTable* aHttpCacheLookupTable, RFs aRfs, const TDesC& aDirectory );
 
         /**
          *
--- a/webengine/osswebengine/cache/inc/HttpCacheManager.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/inc/HttpCacheManager.h	Thu Sep 24 12:53:48 2009 +0300
@@ -40,6 +40,8 @@
 class RHTTPTransaction;
 class MHTTPDataSupplier;
 class CHttpCacheFileWriteHandler;
+class CHttpCacheFileHash;
+class THttpCachePostponeParameters;
 
 // CLASS DECLARATION
 
@@ -218,13 +220,53 @@
         */
         void CreateCacheHandlersL();
 
-         /**
+        /**
+        *
+        * @since 7.1
+        * @param
+        * @return
+        */
+        void RemoveOrphanedFilesL();    // remove all orphan files.
+        /**
+        *
+        * @since 7.1
+        * @param
+        * @return
+        */
+        // perform phase 2 of orphan file removal. Mark any files 
+        void MarkAllCacheContentAsNoDelete( CHttpCacheFileHash* aOnDiskFilesMap );
+        /**
         *
         * @since 7.1
         * @param
         * @return
         */
-        void RemoveOrphanedFilesL();
+        // perform phase 3 of orphan file removal.
+        // Write an 'empty cache' index file over the top of any unknown index files to let any running clients
+        // prepare for their data to disappear.
+        void WipeAllOtherIndexFilesL( CHttpCacheFileHash* aOnDiskFilesMap, RFs& aRfs );
+        /**
+        *
+        * @since 7.1
+        * @param
+        * @return
+        */
+        // perform phase 4 of orphan file removal. Remove any files not referenced in the loaded caches.
+        void DeleteMarkedFilesL( CHttpCacheFileHash* aOnDiskFilesMap, RFs& aRfs );
+        /**
+        *
+        * @since 7.1
+        * @param
+        * @return
+        */
+        // utility fn for phase 3 of orphan file removal.
+        void GenerateEmptyIndexFileL(const TDesC& aIndexFile, RFs& aRfs );
+
+        /**
+         * @since 7.1
+         * override cache parameters according to application using DLL and any config in Centrep
+         */
+        void ApplyCacheOverridesL(CRepository& aRepository, const TUint32& aSecIdInt, TBool& aCacheEnabled, TInt& aCacheSize, TBool& aOpCacheEnabled, TBool& aVssCacheEnabled, TDes& aPath, const TDesC& aDefaultDrive);
 
         /**
         *
@@ -252,6 +294,61 @@
 
         TBool VSSHeaderCheck(  TDes8*  aHttpHeaderString ) const ;
 
+        /**
+         * @since 7.1
+         * 
+         */
+        void GetPostponeParamsL( TBool& aNewCentrepPresent, THttpCachePostponeParameters& aParams, CRepository* aRepo );
+
+        /**
+         * @since 7.1
+         * 
+         */
+        void GetHttpCacheConfigL( CRepository& aRepository, TBool& aCacheEnabled, TInt& aCacheSize, TDes& aCacheFolder );
+
+        /**
+         * @since 7.1
+         * 
+         */
+        void GetOperatorCacheConfigL( CRepository& aRepository, TBool& aOpCacheEnabled, TInt& aOpCacheSize, TDes& aOpCacheFolder );
+
+        /**
+         * @since 7.1
+         * 
+         */
+        void GetVSSCacheConfigL( CRepository& aRepository, TBool& aVSSCacheEnabled, TInt& aVssCacheSize, TDes& aVssCacheFolder );
+        
+        /**
+         * @since 7.1
+         * 
+         */
+        void GetCriticalDriveLevelsL( CRepository& aRepository, const TDesC& aCacheFolder, TInt& aCriticalLevel );
+
+        /**
+         * @since 7.1
+         * 
+         */
+        void CreateHttpCacheL( const TInt& aSecIdInt, const TInt& aCacheSize, const TInt& aCriticalLevel, const THttpCachePostponeParameters& aPostpone );
+
+        /**
+         * @since 7.1
+         * 
+         */
+        void CreateOperatorCacheL( CRepository& aRepository, const TDesC& aOpCacheFolder, const TInt& aOpCacheSize, const TInt& aCriticalLevel, const THttpCachePostponeParameters& aPostpone );
+
+        /**
+         * @since 7.1
+         * 
+         */
+        void CreateVssCacheL( CRepository& aRepository, const TDesC& aVssCacheFolder, const TInt& aVssCacheSize, const TInt& aCriticalLevel, const THttpCachePostponeParameters& aPostpone );
+
+        /**
+         * @since 7.1
+         * 
+         */
+        void CrashCheckL( const TInt& aSecIdInt );
+
+
     private:    // Data
 
         CHttpCacheHandler*                         iCache;      // owned
--- a/webengine/osswebengine/cache/inc/HttpCacheObserver.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/inc/HttpCacheObserver.h	Thu Sep 24 12:53:48 2009 +0300
@@ -62,6 +62,9 @@
     public: // new functions
         void StartObserver();
 
+        inline TBool Updated() const { return (IsActive() && iStatus != KRequestPending); };
+        void Queue();
+        
     public: // from base class CActive
         void RunL();
         TInt RunError(TInt aError);
--- a/webengine/osswebengine/cache/inc/HttpCachePostponeWriteUtilities.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/inc/HttpCachePostponeWriteUtilities.h	Thu Sep 24 12:53:48 2009 +0300
@@ -56,7 +56,7 @@
     TInt GetResult();   // KRequestPending, or a completion code.
 
 private:
-    CHttpCacheEntryAsyncWriteHelper(TRequestStatus& aStatus, MHttpCacheWriteSource* aSource, TInt aPriority = EPriorityNormal);
+    CHttpCacheEntryAsyncWriteHelper(TRequestStatus& aStatus, MHttpCacheWriteSource* aSource, TInt aPriority = EPriorityIdle);
 
     virtual void DoCancel();
     virtual void RunL();
@@ -86,7 +86,7 @@
     virtual ~CSegmentedHeapBuffer();
     /*
      * aBufferSize is the size of each segment used for storage.
-     * aCompressGranularity is the multiple used when Compress()ing the last block.
+     * aCompressGranularity is used when Compress()ing the last block. If the block has at least this much free space, it is realloced to the correct size.
      */
     static CSegmentedHeapBuffer * NewL(TInt aBufferSize = 32768, TInt aCompressGranularity = 4096);
 
--- a/webengine/osswebengine/cache/inc/HttpCacheStreamHandler.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/inc/HttpCacheStreamHandler.h	Thu Sep 24 12:53:48 2009 +0300
@@ -179,7 +179,7 @@
         * @param
         * @return
         */
-        TBool CreateNewBodyFile( CHttpCacheEntry& aCacheEntry );
+        TBool CreateNewBodyFile( CHttpCacheEntry& aCacheEntry, TBool aUseDirectIO = EFalse );
 
     private:
 
--- a/webengine/osswebengine/cache/inc/HttpCacheUtil.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/inc/HttpCacheUtil.h	Thu Sep 24 12:53:48 2009 +0300
@@ -20,6 +20,7 @@
 
 //  INCLUDES
 #include <e32base.h>
+#include <e32hashtab.h>
 #include <f32file.h>
 #include <http/rhttpheaders.h>
 
@@ -54,7 +55,11 @@
 const TUint32 KFilenameLength = 8;
 _LIT( KHttpCacheHeaderExt, ".h" );
 
-#ifdef _DEBUG
+const TInt KCacheFileNeedsDelete( 1 );    
+const TInt KCacheFileNoDelete( 0 );
+
+
+#ifdef HTTP_CACHE_LOGGING
 #define __CACHELOG__
 #endif
 
@@ -70,7 +75,11 @@
 class MHTTPDataSupplier;
 class RStringPool;
 class CHttpCacheEntry;
+class CHttpCacheFileHash;
+class TFileInfo;
 
+typedef TPtrHashMapIter<TDesC, TFileInfo> THttpCacheFileHashIter;
+typedef RPtrHashMap<TDesC, TFileInfo> RHttpCacheFileHashMap;
 // CLASS DECLARATION
 
 /**
@@ -297,6 +306,25 @@
         */
         static void WriteUrlToLog( TInt aLogLevel, const TDesC& aTxt, const TDesC8& aUrl, TInt aAny = 0xffff );
 
+        /**
+         * @since 7.1
+         * 
+         * example:
+         * CCacheFileHash *hash;
+         * GenerateCacheContentHashMapL(hash, rfs, _L("Cachelocation"), <a TInt you can use for whatever you like>);
+         * When you return, you should push onto the cleanup stack as usual.
+         * When you're finished with the hash just do:
+         * CleanupStack::PopAndDestroy(); to clean up both hash and string array.
+         */
+        static void GenerateCacheContentHashMapL(CHttpCacheFileHash*& aHashMap, RFs& aRfs, const TDesC& aCacheFolder, const TInt aInitialValue);
+
+        /**
+         * @since 7.1
+         * 
+         * Ensure trailing slash on paths
+         */
+        static void EnsureTrailingSlash( TDes& aPath );
+        
     private:
 
         /**
@@ -334,6 +362,37 @@
             char** aExtraValue );
     };
 
+NONSHARABLE_CLASS( TFileInfo )
+    {
+    public:
+        TInt iUserInt;
+        TUint32 iFileSize;
+    };
+
+NONSHARABLE_CLASS( CHttpCacheFileHash ) : public CBase
+    {
+    friend class HttpCacheUtil;
+    protected:
+        static CHttpCacheFileHash* NewLC(const TInt aInitialValue);
+        void InsertAndStoreL(const TEntry& aEntry, const TDesC& aDir);
+        
+    private:
+        void ConstructL();
+        CHttpCacheFileHash(const TInt aInitialValue, const THashFunction32<TDesC>& aHash, const TIdentityRelation<TDesC>& aIdentity);
+        
+    public:
+        ~CHttpCacheFileHash();
+        RHttpCacheFileHashMap& HashMap() { return iHashMap; };
+        
+    private:
+        RHttpCacheFileHashMap   iHashMap;
+        RPointerArray<HBufC> iStringStorage;
+        CArrayFixSeg<TFileInfo>* iFileInfoStorage;
+        const TInt iInitialValue;
+    };
+
+
+
 #endif      // CHTTPCACHEUTIL_H
 
 // End of File
--- a/webengine/osswebengine/cache/src/HttpCacheEntry.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/src/HttpCacheEntry.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -107,12 +107,26 @@
 //
 CHttpCacheEntry::~CHttpCacheEntry()
     {
+#ifdef __CACHELOG__
+    HttpCacheUtil::WriteFormatLog(0, _L("Deleting CHttpCacheEntry %08x"), this);
+#endif
     // Clean up eviction handler
     if ( iEvictionCandidate && iEvictionHandler )
         {
+#ifdef __CACHELOG__
+        HttpCacheUtil::WriteLog(0, _L("Removing from eviction candidate list"));
+#endif
         iEvictionHandler->Remove( *this );
         }
 
+    if( iDeleteObserver )
+        {
+#ifdef __CACHELOG__
+        HttpCacheUtil::WriteFormatLog(0, _L("Notifying delete observer %08x"), this);
+#endif
+        iDeleteObserver->EntryDeleted(this);
+        }
+    
     // Close files, this will commit changes
     iBodyFile.Close();
 
@@ -495,4 +509,13 @@
         }
     }
 
+void CHttpCacheEntry::SetDeleteObserver(MHttpCacheEntryDeleteObserver* aObserver)
+    {
+    iDeleteObserver = aObserver;
+    }
+
+void CHttpCacheEntry::ClearDeleteObserver()
+    {
+    iDeleteObserver = NULL;
+    }
 //  End of File
--- a/webengine/osswebengine/cache/src/HttpCacheEvictionHandler.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/src/HttpCacheEvictionHandler.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -321,7 +321,7 @@
             }
 #endif
             // evacuate nonactive entries only
-            if( entry && entry->State() == CHttpCacheEntry::ECacheComplete )
+            if( entry && entry->State() == CHttpCacheEntry::ECacheComplete && !entry->BodyDataPartiallyWritten())
                 {
                 // watch out for 32 bit. it might overflow secInt.
                 currTime.SecondsFrom( entry->LastAccessed(), secInt );
--- a/webengine/osswebengine/cache/src/HttpCacheFileWriteHandler.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/src/HttpCacheFileWriteHandler.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -22,6 +22,7 @@
 #include "HttpCacheStreamHandler.h"
 #include "HttpCachePostponeWriteUtilities.h"
 #include "HttpCacheUtil.h"
+#include "HttpCacheObserver.h"
 #include <HttpCacheManagerInternalCRKeys.h>
 #include <centralrepository.h>
 #include <hal.h>
@@ -69,7 +70,7 @@
 // -----------------------------------------------------------------------------
 //
 CHttpCacheFileWriteHandler::CHttpCacheFileWriteHandler(CHttpCacheHandler* aHandler, CHttpCacheStreamHandler* aStreamHandler, RFs& aRfs)
-    : CActive(EPriorityHigh),
+    : CActive(EPriorityIdle),
       iCacheHandler( aHandler ),
       iCacheStreamHandler(aStreamHandler),
       iFs(aRfs)
@@ -81,14 +82,17 @@
 // Symbian 2nd phase constructor can leave.
 // -----------------------------------------------------------------------------
 //
-void CHttpCacheFileWriteHandler::ConstructL(const TInt aWriteTimeout)
+void CHttpCacheFileWriteHandler::ConstructL(const THttpCachePostponeParameters& aParams)
     {
     iObjectQueue.Reset();
     iObjectQueue.ReserveL(32);
 
-    iWaitTimer = CHttpCacheWriteTimeout::NewL( aWriteTimeout );
+    iWaitTimer = CHttpCacheWriteTimeout::NewL( aParams.iWriteTimeout );
     CActiveScheduler::Add(this);
 
+    iFreeRamThreshold = aParams.iFreeRamThreshold;
+    iImmediateWriteThreshold = aParams.iImmediateWriteThreshold;
+    
     MemoryManager::AddCollector(this);
     }
 
@@ -97,14 +101,13 @@
 // Two-phased constructor.
 // -----------------------------------------------------------------------------
 //
-CHttpCacheFileWriteHandler* CHttpCacheFileWriteHandler::NewL(CHttpCacheHandler* aHandler, CHttpCacheStreamHandler* aStreamHandler, RFs& aRfs, const TInt aWriteTimeout)
+CHttpCacheFileWriteHandler* CHttpCacheFileWriteHandler::NewL(CHttpCacheHandler* aHandler, CHttpCacheStreamHandler* aStreamHandler, RFs& aRfs, const THttpCachePostponeParameters& aParams)
     {
     CHttpCacheFileWriteHandler* self = new( ELeave ) CHttpCacheFileWriteHandler(aHandler, aStreamHandler, aRfs);
 
     CleanupStack::PushL( self );
-    self->ConstructL(aWriteTimeout);
+    self->ConstructL(aParams);
     CleanupStack::Pop();
-
     return self;
     }
 
@@ -141,6 +144,7 @@
     for ( TInt i=0; i < iObjectQueue.Count(); i++ )
         {
         iCacheStreamHandler->Flush(*iObjectQueue[i]);
+        iObjectQueue[i]->ClearDeleteObserver();
         }
         iObjectQueue.Reset();
 #ifdef __CACHELOG__
@@ -185,15 +189,22 @@
         return;
         }
 
+    TInt skip = 0;
     TInt count = KMaxCollectCount;
     while ( aRequired && count && iObjectQueue.Count() )
         {
-        count--;
-        CHttpCacheEntry* entry = iObjectQueue[0];
-        iObjectQueue.Remove(0);
-        TInt size = entry->BodySize();
-        iCacheStreamHandler->Flush(*entry);
-        aRequired -= size;
+        CHttpCacheEntry* entry = iObjectQueue[skip];
+        if(entry != iObjectFlushing)
+            {
+            count--;
+            iObjectQueue.Remove(skip);
+            entry->ClearDeleteObserver();
+            TInt size = entry->BodySize();
+            iCacheStreamHandler->Flush(*entry);
+            aRequired -= size;
+            }
+        else
+            skip++;
         }
     }
 
@@ -247,29 +258,46 @@
     // if we get here, we're not in low memory state any more.
     iLowMemoryState = EFalse;
 
+    // If we re-request an item on the page which was non-cacheable, we will update it's content
+    // and add it back to the cache here, even though we have reused the same CHttpCache object.
+ 
+    // check for re-adding pre-existing objects with updated content - size may differ, so need to remove and reinsert.
+    TInt index = iObjectQueue.Find( aEntry ); 
+    if( index >= 0)
+        {
+        iObjectQueue.Remove( index );
+        }
     // add entry to queue
-    TInt err = iObjectQueue.InsertInOrderAllowRepeats(aEntry, TLinearOrder<CHttpCacheEntry>(CompareHttpCacheEntrySize));
+    TInt err = iObjectQueue.Append( aEntry );
 
-    #ifdef __CACHELOG__
-    HttpCacheUtil::WriteFormatLog(0, _L("CACHEPOSTPONE: CHttpCacheFileWriteHandler: Added object %08x to postpone queue."), aEntry);
-    OutputQueueContentToDebug();
-#endif
+    // sort by size
+    iObjectQueue.Sort(CompareHttpCacheEntrySize);
+    
+    switch( err )
+        {
+        case KErrNone:
 
-    // reset timer
-    if ( err == KErrNone )
-        {
-        aAddStatus = EAddedOk;
-        iWaitTimer->Start( CHttpCacheFileWriteHandler::WriteTimeout, this );
+            // set up notification of delete operation
+            aEntry->SetDeleteObserver(this);
+            
+        #ifdef __CACHELOG__
+            HttpCacheUtil::WriteFormatLog(0, _L("CACHEPOSTPONE: CHttpCacheFileWriteHandler: Added object %08x to postpone queue."), aEntry);
+            OutputQueueContentToDebug();
+        #endif
+
+            aAddStatus = EAddedOk;
+            iWaitTimer->Start( CHttpCacheFileWriteHandler::WriteTimeout, this );
+            break;
+        case KErrNoMemory:
+            aAddStatus = ENotEnoughFreeMemory;
+            break;
+        default:
+            aAddStatus = ECheckReturn;
+            break;
         }
-    else
-        {
-        aAddStatus = ECheckReturn;
-        }
-
 #ifdef __CACHELOG__
     HttpCacheUtil::WriteLog(0, _L("CACHEPOSTPONE: <<FileWriteHandler::AddEntry"));
 #endif
-
     return err;
     }
 
@@ -305,6 +333,8 @@
         if ( index >= 0 )
             {
             iObjectQueue.Remove( index );
+            aEntry->ClearDeleteObserver();
+            
             if ( !iObjectQueue.Count() )
                 {
 #ifdef __CACHELOG__
@@ -330,6 +360,11 @@
 void CHttpCacheFileWriteHandler::RemoveAll()
     {
     // empty list - note that HttpCacheEntries aren't owned.
+    // deregister for delete events.
+    for(TInt index = 0; index < iObjectQueue.Count(); index++)
+        {
+        iObjectQueue[index]->ClearDeleteObserver();
+        }
     iObjectQueue.Reset();
     // stop us if we're active
     Cancel();
@@ -363,6 +398,19 @@
 
     if ( !IsActive() )
         {
+#ifdef HTTPCACHE_FILEWRITEDEBUG_ALWAYS_FIRE_OBSERVER
+        // trigger index.dat observer
+        RFile tempIndexFile;
+        TInt err = tempIndexFile.Open(iFs, _L("C:\\system\\cache\\index.dat"), EFileWrite);
+        if(err == KErrNone)
+            {
+            tempIndexFile.Seek(ESeekEnd, err);
+            _LIT8(KIndexGarbage, "blahblah");
+            tempIndexFile.Write(KIndexGarbage());
+            tempIndexFile.Flush();
+            tempIndexFile.Close();
+            }
+#endif
 #ifdef __CACHELOG__
         HttpCacheUtil::WriteFormatLog(0, _L("CACHEPOSTPONE:   Setting FileWriteHandler %08x to active."), this);
 #endif
@@ -424,6 +472,8 @@
 #endif
             // the object might not exist in the queue.. how can this happen?
             iObjectQueue.Remove(index);
+            iObjectFlushing->ClearDeleteObserver();
+            
             //
             if ( result != KErrNone )
                 {
@@ -453,21 +503,33 @@
         // remove any items from the top of the queue which have no body data.
         while ( iObjectQueue.Count() && iObjectQueue[0]->BodySize() == 0 )
             {
+            iObjectQueue[0]->ClearDeleteObserver();
             iObjectQueue.Remove(0);
             };
 
+        TBool goIdle = ETrue;
         // check to see if there is anything ready to write out
         if ( iObjectQueue.Count() )
             {
-            SetActive();
-            iStatus = KRequestPending;
-            iCacheStreamHandler->FlushAsync( *iObjectQueue[0], iStatus );
-            iObjectFlushing = iObjectQueue[0];
-#ifdef __CACHELOG__
-            HttpCacheUtil::WriteFormatLog(0, _L("CACHEPOSTPONE:     FileWriteHandler::RunL continue cache flush, Starting object %08x."), iObjectFlushing);
-#endif
+            // merge index if it's changed
+            if(iCacheHandler->iHttpCacheObserver->Updated())
+                iCacheHandler->iHttpCacheObserver->RunL();
+            
+            // check again, merge may have removed all items
+            if( iObjectQueue.Count() && !IsActive() )    // Collect could be triggered during RunL execution and already have made this object active, we can't tell in 'collect' if we were in here or not.
+                {
+                iStatus = KRequestPending;
+                SetActive();
+                iCacheStreamHandler->FlushAsync( *iObjectQueue[0], iStatus );
+                iObjectFlushing = iObjectQueue[0];
+                goIdle = EFalse;
+    #ifdef __CACHELOG__
+                HttpCacheUtil::WriteFormatLog(0, _L("CACHEPOSTPONE:     FileWriteHandler::RunL continue cache flush, Starting object %08x."), iObjectFlushing);
+    #endif
+                }
             }
-        else
+        
+        if(goIdle)
             {   // nothing left to write, go idle.
     #ifdef __CACHELOG__
             HttpCacheUtil::WriteLog(0, _L("CACHEPOSTPONE:     FileWriteHandler::RunL complete with nothing else to write."));
@@ -542,4 +604,9 @@
     return EFalse;
     }
 
+
+void CHttpCacheFileWriteHandler::EntryDeleted(CHttpCacheEntry *aEntry)
+    {
+    RemoveEntry(aEntry);
+    }
 //  End of File
--- a/webengine/osswebengine/cache/src/HttpCacheHandler.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/src/HttpCacheHandler.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -63,10 +63,10 @@
 // ============================ MEMBER FUNCTIONS ===============================
 THttpCachePostponeParameters::THttpCachePostponeParameters()
     {
-    iEnabled = EFalse;
-    iFreeRamThreshold = 0;
-    iImmediateWriteThreshold = 0;
-    iWriteTimeout = 0;
+    iEnabled = ETrue;               // Postpone enabled always
+    iFreeRamThreshold = 6*1024*1024;    // 6MB free required
+    iImmediateWriteThreshold = 0;   // Items below this size always written immediately
+    iWriteTimeout = 30000000;        // 45s timeout
     }
 
 // -----------------------------------------------------------------------------
@@ -127,30 +127,6 @@
 
     // set path for the entries
     iRfs.SetSessionPath( aDirectory );
-#ifdef __USE_VALIDATION_FILES__
-    // create validation file
-    TFileName validateFile;
-    GenerateValidationFilename(validateFile, aIndexFile);
-
-    TBool validateCacheEntries( EFalse );
-    RFile validate;
-    TInt validateErr = validate.Create(iRfs, validateFile, EFileShareExclusive | EFileWrite);
-    if ( validateErr != KErrNone )
-        {
-        if ( validateErr == KErrAlreadyExists )
-            {
-            validateCacheEntries = ETrue;
-            }
-#ifdef _DEBUG
-        else
-            {
-            // oh dear, we failed to create the file for some other reason, something must have gone properly wrong...
-            User::Panic(_L("CacheHandler"), -9999);
-            }
-#endif
-        }
-    validate.Close();
-#endif
     //
     iEvictionHandler = CHttpCacheEvictionHandler::NewL();
     //
@@ -158,7 +134,7 @@
     //
     if ( aPostpone.iEnabled )
         {
-        iPostponeHandler = CHttpCacheFileWriteHandler::NewL(this, iStreamHandler, iRfs, aPostpone.iWriteTimeout);
+        iPostponeHandler = CHttpCacheFileWriteHandler::NewL(this, iStreamHandler, iRfs, aPostpone);
         }
     //
     iLookupTable = CHttpCacheLookupTable::NewL( *iEvictionHandler, *iStreamHandler );
@@ -170,12 +146,6 @@
         iLookupTable = NULL;
         iLookupTable = CHttpCacheLookupTable::NewL( *iEvictionHandler, *iStreamHandler );
         }
-#ifdef __USE_VALIDATION_FILES__
-    if ( validateCacheEntries )
-#endif
-        // ensure that the disk content matches the cache content
-        ValidateCacheEntriesL();
-
     //
     iHttpCacheObserver = CHttpCacheObserver::NewL(iDirectory, iIndexFile, this);
     iHttpCacheObserver->StartObserver();
@@ -1443,7 +1413,6 @@
 void CHttpCacheHandler::UpdateLookupTable()
     {
     TRAP_IGNORE(UpdateLookupTableL());
-    iHttpCacheObserver->StartObserver();
     }
 
 // -----------------------------------------------------------------------------
@@ -1458,33 +1427,11 @@
     CHttpCacheLookupTable* lookupTable = CHttpCacheLookupTable::NewL( *evictionHandler, *iStreamHandler );
     CleanupStack::PushL(lookupTable);
     OpenLookupTableL(lookupTable);
-    iLookupTable->MergeL(lookupTable, iRfs);
+    iLookupTable->MergeL(lookupTable, iRfs, iDirectory->Des() );
     CleanupStack::PopAndDestroy(2); // lookupTable, evictionHandler
     }
 
 // -----------------------------------------------------------------------------
-// CHttpCacheHandler::GenerateValidationFilename
-// -----------------------------------------------------------------------------
-//
-#ifdef __USE_VALIDATION_FILES__
-    void CHttpCacheHandler::GenerateValidationFilename(TDes& aFilename, const TDesC& aIndexFilename) const
-#else
-    void CHttpCacheHandler::GenerateValidationFilename(TDes& /*aFilename*/, const TDesC& /*aIndexFilename*/) const
-#endif
-    {
-#ifdef __USE_VALIDATION_FILES__
-    _LIT(KValidationExtension, ".val");
-    TParse filenameParser;
-    filenameParser.Set(aIndexFilename, NULL, NULL);
-    aFilename.Copy(filenameParser.DriveAndPath());
-    aFilename.Append(filenameParser.Name());
-    aFilename.Append(KValidationExtension);
-#else
-    PanicCacheHandler(KErrNotSupported);
-#endif
-    }
-
-// -----------------------------------------------------------------------------
 // DestroyBadUrlArray
 // -----------------------------------------------------------------------------
 //
@@ -1498,371 +1445,60 @@
 // CHttpCacheHandler::ValidateCacheEntriesL
 // -----------------------------------------------------------------------------
 //
-void CHttpCacheHandler::ValidateCacheEntriesL()
+void CHttpCacheHandler::ValidateCacheEntriesL(CHttpCacheFileHash *aDiskContent)
     {
     // iterate through entries and check if file is present.
     // if not, add URL to a list of bad ones otherwise remove directory entry from list
     // at the end, go through list of bad entries and remove them from cache,
-    // go through list of unreferenced files and delete them too.
     THttpCacheLookupTableEntryIterator iter;
     iLookupTable->BeginEntryIteration(iter);
 #ifdef __CACHELOG__
     HttpCacheUtil::WriteLog(0, _L("CHttpCacheHandler::ValidateCacheEntriesL"));
 #endif
-    // if the cache contains no items, we should still do this so we detect other files.
 
-    // get list of files on disk
-    CCacheDirectoryFiles *dirFiles = CCacheDirectoryFiles::NewLC(iRfs, *iDirectory);
-
+    // mark our index file as 'no delete'
+    RHttpCacheFileHashMap& hashmap = aDiskContent->HashMap();
+    TFileName indexFile;
+    indexFile.Copy( iDirectory->Des() );
+    indexFile.Append( iIndexFile->Des() );
+    TFileInfo *info = hashmap.Find( indexFile );
+    if( info )
+        {
+        info->iUserInt = KCacheFileNoDelete;  
+        }
+    
     // look for bad entries
     RPointerArray<HBufC8> badEntries;
     CleanupStack::PushL(TCleanupItem(DestroyBadUrlArray, &badEntries));
     const CHttpCacheEntry *tmpEntry;
     while(tmpEntry = iLookupTable->NextEntry(iter), tmpEntry)
         {
-        if(!dirFiles->ValidateEntryL(*tmpEntry))
+        // check the files associated with the cache entry are present where they should be
+        // if the file is present AND the size matches the entry, mark the hashmap value with noDelete.
+        // otherwise, mark the hash map with delete and remove the entry.
+        info = hashmap.Find(tmpEntry->Filename());
+        if(info && info->iFileSize == tmpEntry->BodySize())
+            {
+            info->iUserInt = KCacheFileNoDelete; // noDelete
+            }
+        else
             {
 #ifdef __CACHELOG__
             HttpCacheUtil::WriteUrlToLog(0, _L("Bad Entry: "), tmpEntry->Url() );
 #endif
             badEntries.AppendL(tmpEntry->Url().AllocL());
+            if(info)
+                info->iUserInt = KCacheFileNeedsDelete; // needs delete
             }
         }
 
-    // remove bad entries
+    // remove entries from cache where files don't match content on disk, either file is missing or size is incorrect.
+    // needed to save URIs because that's the only interface we have here.
     for(TInt i=0; i < badEntries.Count(); i++)
         {
         iLookupTable->Remove(badEntries[i]->Des());
         }
     CleanupStack::PopAndDestroy(1); // bad entry list
-
-    // remove orphan files
-    dirFiles->RemoveLeftoverFilesL();
-    CleanupStack::PopAndDestroy(dirFiles);
-    }
-
-// -----------------------------------------------------------------------------
-// CCacheDirectoryFiles::NewL
-// -----------------------------------------------------------------------------
-//
-CCacheDirectoryFiles* CCacheDirectoryFiles::NewL(RFs aRfs, const TDesC& aDir)
-    {
-    CCacheDirectoryFiles* me = CCacheDirectoryFiles::NewLC(aRfs, aDir);
-    CleanupStack::Pop(me);
-    return me;
-    }
-
-// -----------------------------------------------------------------------------
-// CCacheDirectoryFiles::NewLC
-// -----------------------------------------------------------------------------
-//
-CCacheDirectoryFiles* CCacheDirectoryFiles::NewLC(RFs aRfs, const TDesC& aDir)
-    {
-    CCacheDirectoryFiles *me = new (ELeave) CCacheDirectoryFiles(aRfs, aDir);
-    CleanupStack::PushL(me);
-    me->ConstructL();
-    return me;
-    }
-
-// -----------------------------------------------------------------------------
-// CCacheDirectoryFiles::ValidateEntryL
-// -----------------------------------------------------------------------------
-//
-TBool CCacheDirectoryFiles::ValidateEntryL(const CHttpCacheEntry& aEntry)
-    {
-    // check the files associated with the cache entry are present where they should be
-    // if the file is present, then remove it from the dir list
-    // if the file is present AND the size matches the entry, then return ETrue in aPresentAndValid
-    // otherwise, return EFalse there.
-    TBool presentAndValid = EFalse;
-
-    TParse tmpParse;
-    tmpParse.Set(aEntry.Filename(), NULL, NULL);
-    // for this file to be part of the cache it must meet the following rules..
-    // length of name is 8 chars
-    if(tmpParse.Name().Length() != 8)
-        return presentAndValid;
-
-    // this filename has a chance of existing and we can assume correct format from now on
-    TUint32 cacheUintName;
-    if(TCompressedEntry::ConvertANameToUint32(tmpParse.Name(), cacheUintName))
-        {
-        TInt arrayIndex = cacheUintName & 0x0000000F;
-        presentAndValid = iDirContent[arrayIndex]->ValidateCacheEntryL( aEntry );
-        }
-    // after all cache entries have been checked against the list, it should only contain orphaned files
-    // files which match but are corrupt will have been removed from this list
-    // however they should be cleaned up when the 'corrupt' entries are removed at a later date.
-    return presentAndValid;
-    }
-
-// -----------------------------------------------------------------------------
-// CCacheDirectoryFiles::RemoveLeftoverFilesL
-// -----------------------------------------------------------------------------
-//
-void CCacheDirectoryFiles::RemoveLeftoverFilesL()
-    {
-    // delete all the files which are still listed.
-    TFileName tempFilename;
-    for (TInt subDir=0; subDir < 16; subDir++)
-        {
-        for (TInt fileIdx = 0; fileIdx < iDirContent[subDir]->Count(); fileIdx++ )
-            {
-            // each file needs to have the full path prepended in order to delete
-            HBufC *name = iDirContent[subDir]->NameAtL(fileIdx);
-            tempFilename.Format(_L("%S%x\\%S"), &iDir, subDir, name);
-#ifdef __CACHELOG__
-            HttpCacheUtil::WriteFormatLog(0, _L("Deleting file %S"), &tempFilename);
-#endif
-            iRfs.Delete(tempFilename);
-            delete name;
-            }
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CCacheDirectoryFiles::~CCacheDirectoryFiles
-// -----------------------------------------------------------------------------
-//
-CCacheDirectoryFiles::~CCacheDirectoryFiles()
-    {
-    iDirContent.ResetAndDestroy();
-    }
-
-// -----------------------------------------------------------------------------
-// CCacheDirectoryFiles::ConstructL
-// -----------------------------------------------------------------------------
-//
-void CCacheDirectoryFiles::ConstructL()
-    {
-    CDir* baseDirs;
-    User::LeaveIfError(iRfs.GetDir(iDir,KEntryAttDir,ESortByName,baseDirs));
-    CleanupStack::PushL(baseDirs);
-
-    // we know that the cache format is a single letter directory from 0-f
-    // so we ignore any other directories - they might belong to other caches
-    // and our cache will not have written any files out into anywhere except the
-    // 0-f dirs, even if we lost track of something.
-    // See HttpCacheUtil::GenerateNameLC
-    iDirContent.ReserveL(16);
-
-    TInt numdirs = baseDirs->Count();
-    // storage for <c:/system/cache/> + '0/'
-    HBufC* currentDir = HBufC::NewLC( iDir.Length() + KSubdirNameLength );
-    for(TInt i=0; i < numdirs; i++)
-        {
-        TInt arrayIndex = -1;
-        const TEntry& entry = (*baseDirs)[i];
-        if(entry.IsDir() && entry.iName.Length()==1)
-            {
-            TUint16 chr = *(entry.iName.Right(1).Ptr());
-            arrayIndex = TCompressedEntry::ConvertAsciiToIntSingleHexDigit(chr);
-            }
-
-        if(arrayIndex >=0 && arrayIndex <= 15)
-            {
-            // initialise subdir name to base directory
-            currentDir->Des().Copy(iDir);
-            currentDir->Des().AppendFormat(_L("%x\\"), arrayIndex); // if base path wasn't terminated with trailing / we would have blown up at creation time.
-
-            // get subdirectory content
-            CDir *dir;
-            iRfs.GetDir(currentDir->Des(), KEntryAttMatchExclude | KEntryAttDir, ESortByName, dir); // only files this time...
-            if(dir)
-                {
-                iDirContent.Insert( CCustomCacheDirList::NewL( dir ), arrayIndex );
-                }
-            delete dir;
-            }
-        }
-        CleanupStack::PopAndDestroy(2); // baseDirs & currentDir
-    }
-
-// -----------------------------------------------------------------------------
-// CCustomCacheDirList::NewL
-// -----------------------------------------------------------------------------
-//
-CCustomCacheDirList* CCustomCacheDirList::NewL(CDir *aSrc)
-    {
-    CCustomCacheDirList *me = new (ELeave) CCustomCacheDirList;
-    CleanupStack::PushL( me );
-    me->ConstructL( aSrc );
-    CleanupStack::Pop( me );
-    return me;
     }
 
-// -----------------------------------------------------------------------------
-// CCustomCacheDirList::ValidateCacheEntryL
-// -----------------------------------------------------------------------------
-//
-TBool CCustomCacheDirList::ValidateCacheEntryL( const CHttpCacheEntry& aEntry )
-    {
-    TBool presentAndValid = EFalse;
-    TUint32 shortName;
-    if( TCompressedEntry::ConvertANameToUint32( aEntry.Filename().Right(8), shortName) )
-        {
-        for(TInt i=0; i<iDirList.Count(); i++)
-            {
-            if(iDirList[i]->IsCompressed() &&
-                    (iDirList[i]->GetCompressedName() == shortName) &&
-                    (iDirList[i]->GetSize() == aEntry.BodySize()))
-                {
-                presentAndValid = ETrue;
-                iDirList.Remove(i);
-                break;
-                }
-            }
-        }
-    return presentAndValid;
-    }
-
-// -----------------------------------------------------------------------------
-// CCustomCacheDirList::Count
-// -----------------------------------------------------------------------------
-//
-TInt CCustomCacheDirList::Count()
-    {
-    return iDirList.Count();
-    }
-
-// -----------------------------------------------------------------------------
-// CCustomCacheDirList::NameAtL
-// -----------------------------------------------------------------------------
-//
-HBufC* CCustomCacheDirList::NameAtL( TInt aIndex )
-    {
-    return iDirList[aIndex]->GetNameL();
-    }
-
-// -----------------------------------------------------------------------------
-// CCustomCacheDirList::CCustomCacheDirList
-// -----------------------------------------------------------------------------
-//
-CCustomCacheDirList::CCustomCacheDirList()
-    {
-    }
-
-// -----------------------------------------------------------------------------
-// CCustomCacheDirList::ConstructL
-// -----------------------------------------------------------------------------
-//
-void CCustomCacheDirList::ConstructL(CDir *aSrc)
-    {
-    TInt items = aSrc->Count();
-    if(items)
-        {
-        iDirList.ReserveL(items);
-        for(TInt i=0; i < items; i++)
-            {
-            TCompressedEntry *newDirEntry = TCompressedEntry::NewL( (*aSrc)[i] );
-            iDirList.AppendL( newDirEntry );
-            }
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// TCompressedEntry::NewL
-// -----------------------------------------------------------------------------
-//
-TCompressedEntry *TCompressedEntry::NewL( const TEntry& aEntry )
-    {
-    TCompressedEntry *newEntry = new (ELeave) TCompressedEntry;
-    CleanupStack::PushL( newEntry );
-    newEntry->ConstructL( aEntry );
-    CleanupStack::Pop( newEntry );
-
-    return newEntry;
-    }
-
-// -----------------------------------------------------------------------------
-// TCompressedEntry::ConstructL
-// -----------------------------------------------------------------------------
-//
-void TCompressedEntry::ConstructL( const TEntry& aEntry )
-    {
-    TUint32 compressedName;
-    if ( ConvertANameToUint32(aEntry.iName, compressedName) )
-        {
-        iFlags |= EFilenameStoredAsUint32;
-        iName.iNameAsUint32 = compressedName;
-        }
-    else
-        {
-        iName.iNameAsHBuf = aEntry.iName.AllocL();
-        }
-    iSize = aEntry.iSize;
-    }
-
-// -----------------------------------------------------------------------------
-// TCompressedEntry::ConvertANameToUint32
-// -----------------------------------------------------------------------------
-//
-TBool TCompressedEntry::ConvertANameToUint32( const TDesC& aName, TUint32& aConverted)
-    {
-    TBool success = EFalse;
-    aConverted = 0;
-
-    if ( aName.Length() == 8 )
-        {
-        TUint32 scratch = 0;
-        for ( TInt i=0; i < 8; i++ )
-            {
-            scratch <<= 4;
-            TInt val = TCompressedEntry::ConvertAsciiToIntSingleHexDigit(aName[i]);
-            if ( val >= 0 )
-                {
-                scratch += val & 0x0F;
-                }
-            else
-                break;
-
-            if ( i==7 )
-                {
-                aConverted = scratch;
-                success = ETrue;
-                }
-            }
-        }
-
-    return success;
-    }
-
-// -----------------------------------------------------------------------------
-// TCompressedEntry::ConvertAsciiToIntSingleHexDigit
-// -----------------------------------------------------------------------------
-//
-TInt TCompressedEntry::ConvertAsciiToIntSingleHexDigit(const TUint16& aDigitChar)
-    {
-    if ( aDigitChar >=48 && aDigitChar <=57 )
-        {
-        return (aDigitChar - 48); //numerals
-        }
-    else if ( aDigitChar >= 65 && aDigitChar <= 70 )
-        {
-        return (aDigitChar - 55); // uppercase hex letters
-        }
-    else if ( aDigitChar >= 97 && aDigitChar <= 102 )
-        {
-        return (aDigitChar - 87); // lowercase hex letters
-        }
-
-    return -1;
-    }
-
-// -----------------------------------------------------------------------------
-// TCompressedEntry::GetNameL
-// -----------------------------------------------------------------------------
-//
-HBufC* TCompressedEntry::GetNameL()
-    {
-    if ( !IsCompressed() )
-        {
-        return iName.iNameAsHBuf->AllocL();
-        }
-
-    HBufC* name = HBufC::NewL(8);
-    name->Des().Format(_L("%08x"), iName.iNameAsUint32);
-
-    return name;
-    }
 //  End of File
--- a/webengine/osswebengine/cache/src/HttpCacheLookupTable.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/src/HttpCacheLookupTable.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -362,6 +362,9 @@
         {
         // read directory stub and validate it
         TInt len = aReadStream.ReadInt32L();
+        if(!len)
+            return;
+            
         HBufC* dirstub = HBufC::NewLC(len);
         TPtr dirstubptr = dirstub->Des();
         aReadStream.ReadL( dirstubptr, len );
@@ -796,8 +799,22 @@
 //
 // -----------------------------------------------------------------------------
 //
-void CHttpCacheLookupTable::MergeL( CHttpCacheLookupTable* aHttpCacheLookupTable, RFs aRfs )
+void CHttpCacheLookupTable::MergeL( CHttpCacheLookupTable* aHttpCacheLookupTable, RFs aRfs, const TDesC& aDirectory )
     {
+    CHttpCacheFileHash *onDiskFilesMap = NULL;
+    
+    // creating this object will use some memory, so this may fail.
+    TRAPD(err, HttpCacheUtil::GenerateCacheContentHashMapL( onDiskFilesMap, aRfs, aDirectory , 0 ));
+    // if it does fail, we fall back to examining the disk.
+    if(err != KErrNone)
+        {
+        onDiskFilesMap = NULL;
+        }
+    else
+        {
+        CleanupStack::PushL( onDiskFilesMap );
+        }
+    
     TInt myCount = iEntries->Count();
     TInt i = 0;
     for (i = myCount - 1; i >= 0; i--)
@@ -824,8 +841,9 @@
             else // (newEntry)
                 {
                 // Entry is not in the new index file
+                // Entry is in RAM index, may not be on disk yet due to postpone operation.
                 TUint att;
-                if (aRfs.Att(entry->Filename(), att) != KErrNone)
+                if ( !entry->BodyDataCached() && (onDiskFilesMap ? onDiskFilesMap->HashMap().Find( entry->Filename() ) == NULL : (aRfs.Att(entry->Filename(), att) != KErrNone)) )
                     {
                     TInt thePos = Probe(entry->Url(), EFalse);
                     if (Valid(thePos))
@@ -845,7 +863,7 @@
             CHttpCacheEntry* newEntry = aHttpCacheLookupTable->iEntries->At(i);
             TInt pos = aHttpCacheLookupTable->Probe(newEntry->Url(), EFalse);
             TUint att;
-            if (aRfs.Att(newEntry->Filename(), att) == KErrNone)
+            if ( onDiskFilesMap ? (onDiskFilesMap->HashMap().Find(newEntry->Filename()) != NULL ) : (aRfs.Att(newEntry->Filename(), att) == KErrNone) )
                 {
                 CHttpCacheEntry* myEntry = InsertL(newEntry->Url());
                 myEntry->SetState( CHttpCacheEntry::ECacheComplete );
@@ -856,6 +874,9 @@
             aHttpCacheLookupTable->iCount--;
             }
         }
+    
+    if( onDiskFilesMap )
+        CleanupStack::PopAndDestroy( onDiskFilesMap );
     }
 
 // -----------------------------------------------------------------------------
--- a/webengine/osswebengine/cache/src/HttpCacheManager.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/src/HttpCacheManager.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -40,19 +40,28 @@
 
 // kbyte
 const TUint KDefaultCacheSize = 1048576; // 1MB = 1024*1024
-_LIT( KDefaultCacheDir, "c:\\cache\\");
-_LIT( KDefaultOperatorCacheDir, "c:\\cache\\op\\");
-_LIT( KDefaultVssCacheDir, "c:\\cache\\vss\\");
+const TUint KDefaultOperatorCacheSize = 300*1024; // 300KB
+_LIT( KDefaultCacheDrive, "c");
+_LIT( KDefaultCacheDir, "c:\\system\\cache\\");
+_LIT( KDefaultOperatorCacheDir, "c:\\system\\cache\\");
+_LIT( KDefaultVssCacheDir, "c:\\system\\cache\\vss\\");
 _LIT( KDefaultIndexFile, "index.dat" );
 _LIT( KDefaultOpIndexFile, "index_op.dat" );
 _LIT( KDefaultVSSIndexFile, "index_vss.dat" );
 _LIT( KIndexFileExtension, ".dat" );
+_LIT( KCrashCheck, "browser.val");
 _LIT( KValidationFileExtension, ".val" );
-_LIT8( KVSSHeaderFileldName, "X-Vodafone-Content" );
-_LIT8( KVSSHeaderFileldValue, "Portal" );
-
+_LIT8( KVSSHeaderFieldName, "X-Vodafone-Content" );
+_LIT8( KVSSHeaderFieldValue, "Portal" );
+// default override string, browser gets 2MB, widgetUI gets 1MB, OVI Store gets 1MB : max 4MB.
+_LIT( KDefaultOverrideString, "10008D39;1;2048;C;10282822;1;1024;C;102829A0;1;1024;C" );
 
 // MACROS
+#define KUIDBROWSERNG 0x10008D39
+#define KUIDWIDGETUI 0x10282822
+#define KUIDBROWSERCACHECLEANER 0x20026777
+#define KUIDOPERATORMENU 0x100039CE
+#define KUIDOVISTORE 0x102829A0
 
 // LOCAL CONSTANTS AND MACROS
 
@@ -62,6 +71,15 @@
 
 // FORWARD DECLARATIONS
 
+TBool IsBrowser()
+    {
+    RProcess process;
+    TSecureId secId = process.SecureId();
+    TUint32 secIdInt = secId;
+    
+    return ( secIdInt == KUIDBROWSERNG );
+    }
+
 
 // ============================ MEMBER FUNCTIONS ===============================
 
@@ -82,7 +100,16 @@
 //
 void CHttpCacheManager::ConstructL()
     {
+#ifdef __CACHELOG__
+    HttpCacheUtil::WriteLog( 0, _L("-------------------------------------------"));
+    HttpCacheUtil::WriteLog( 0, _L("| Creating new CHttpCacheManager Instance |"), (TInt)this);
+    HttpCacheUtil::WriteLog( 0, _L("-------------------------------------------"));
+#endif
+    
     CreateCacheHandlersL();
+#ifdef __CACHELOG__
+    HttpCacheUtil::WriteLog( 0, _L("Created cache handlers"), (TInt)this);
+#endif
 
     // read offline mode
     if( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) )
@@ -124,6 +151,22 @@
 // -----------------------------------------------------------------------------
 CHttpCacheManager::~CHttpCacheManager()
     {
+#ifdef __CACHELOG__
+    HttpCacheUtil::WriteLog( 0, _L("-----------------------------------------"));
+    HttpCacheUtil::WriteLog( 0, _L("| Destroying CHttpCacheManager Instance | "), (TInt)this);
+    HttpCacheUtil::WriteLog( 0, _L("-----------------------------------------"));
+#endif
+    
+    if( IsBrowser() )    // only enabled in browser
+        {
+        // delete crashcheck.dat file
+        RFs rfs;
+        rfs.Connect();
+        rfs.SetSessionPath( iCacheFolder );
+        rfs.Delete(KCrashCheck());
+        rfs.Close();
+        }
+    
     delete iOfflineNotifyHandler;
     delete iOfflineRepository;
     delete iCache;
@@ -165,7 +208,7 @@
             }
 #endif
 
-        TPtrC8 nameStr ( KVSSHeaderFileldName() );
+        TPtrC8 nameStr ( KVSSHeaderFieldName() );
 
         RStringF VSSnameStr = strP.OpenFStringL( nameStr );
         CleanupClosePushL<RStringF>( VSSnameStr);
@@ -173,7 +216,7 @@
         THTTPHdrVal tempVal;
         if ( aHttpHeader.GetField( VSSnameStr, 0, tempVal ) == KErrNone )
             {
-            TPtrC8 valueStr ( KVSSHeaderFileldValue() );
+            TPtrC8 valueStr ( KVSSHeaderFieldValue() );
             RStringF VSSValueStr = strP.OpenFStringL( valueStr );
             CleanupClosePushL<RStringF>( VSSValueStr );
 
@@ -203,7 +246,6 @@
     if( iCacheEnabled || iVSSCacheEnabled )
         {
         CHttpCacheHandler* cache = CacheHandler( aTrans.Request().URI().UriDes(), NULL ) ;
-        __ASSERT_DEBUG( cache, User::Panic( _L("cacheHandler Panic"), KErrCorrupt ) );
         // adjust cache mode in case of offline operation
         if( iOfflineMode )
             {
@@ -368,29 +410,6 @@
     }
 
 // -----------------------------------------------------------------------------
-// FilePathHash
-// Hash function for Symbian file paths: discards case first
-// -----------------------------------------------------------------------------
-static TUint32 FilepathHash(const TDesC& aDes)
-{
-    //since this function is intensively used by the HashMap,
-    //keeping (slow) heap allocation out of it.
-    TBuf<KMaxPath> normalized ( aDes );
-
-    normalized.LowerCase();
-    return DefaultHash::Des16( normalized );
-}
-
-// -----------------------------------------------------------------------------
-// FilepathIdent
-// Comparator for Symbian file paths: Use case-insensitive compare
-// -----------------------------------------------------------------------------
-static TBool FilepathIdent(const TDesC& aL, const TDesC& aR)
-{
-    return ( aL.CompareF(aR) == 0 );
-}
-
-// -----------------------------------------------------------------------------
 // CHttpCacheManager::RemoveOrphanedFilesL
 // Removes header/body files that exist on the file-system, but are not known to the in-memory Cache lookup table(s)
 // We do this because cache performance degrades substantially if there are too many files in a Symbian FAT32 directory.
@@ -399,127 +418,125 @@
 // -----------------------------------------------------------------------------
 void CHttpCacheManager::RemoveOrphanedFilesL()
     {
-    //Map that contains pointers to fully-qualified file paths as Keys, and "to be deleted flag" as Value.
-    RPtrHashMap<TDesC, TInt> onDiskFilesMap(&FilepathHash, &FilepathIdent);
-    CleanupClosePushL( onDiskFilesMap );
-
-    //Pointers to the following TInt are used as VALUES in the HashMap...
-    // so they must be in scope for the lifecycle of the HashMap.
-    const TInt needsDelete( 1 );
-    const TInt noDelete( 0 );
-
-    //collects objects that need to be deleted later on
-    RPointerArray<HBufC> cleanupList;
-    CleanupResetAndDestroyPushL( cleanupList );
+    // Only proceed if we are running the browser configuration, otherwise we will accidentally
+    // remove content we shouldn't.
+    // get our SID.
+    if( !IsBrowser() )
+        return;
+    
+    // Step 1. Get map of disk content
+    RFs rfs;
+    User::LeaveIfError( rfs.Connect() );
+    CleanupClosePushL( rfs );
+    
+    // Map that contains pointers to fully-qualified file paths as Keys, and "to be deleted flag" as Value.
+    // Initially we mark everything as a candidate for deletion.
+    CHttpCacheFileHash *onDiskFilesMap = NULL;
+    HttpCacheUtil::GenerateCacheContentHashMapL( onDiskFilesMap, rfs, iCacheFolder, KCacheFileNeedsDelete );
+    CleanupStack::PushL( onDiskFilesMap );
+    
+    // mark everything in the cache as no delete needed.
+    MarkAllCacheContentAsNoDelete( onDiskFilesMap );
 
-    RFs rfs = CCoeEnv::Static()->FsSession();
-    CDirScan* scanner = CDirScan::NewLC( rfs );
-
-    //Configure CDirScan to tell you all contents of a particular directory hierarchy
-    scanner->SetScanDataL( iCacheFolder, KEntryAttNormal, ESortNone );
-    CDir* matchingFiles( 0 );
+    // tell any other clients that we are about to remove their cached content
+    WipeAllOtherIndexFilesL( onDiskFilesMap, rfs );
+    
+    // delete any remaining marked files
+    DeleteMarkedFilesL( onDiskFilesMap, rfs );
 
-    //Step 1. Find out all files on disk: by walking the directory hierarchy, one directory at a time
-    for (;;)
-        {
-        //1a. Get list of files in current directory, NULL if no directory left in tree
-        scanner->NextL( matchingFiles );
-        if ( !matchingFiles )
-            break;
+    CleanupStack::PopAndDestroy(1, onDiskFilesMap );
+    CleanupStack::PopAndDestroy(1, &rfs );
+    }
 
-        TPtrC dir( scanner->FullPath() );
+void CHttpCacheManager::MarkAllCacheContentAsNoDelete( CHttpCacheFileHash* aOnDiskFilesMap )
+    {
+    //Step 2. Get list of known (non-orphaned) files in each Cache's in-memory lookup table. Flag them as DO NOT DELETE
+    //Ask CacheHandlers to add their KNOWN files to this array. No ownership transfer occurs.
+    //Don't go ahead if any of the cache handlers choke to insure correct deletion of files.
+    if( iCache )
+        iCache->ValidateCacheEntriesL(aOnDiskFilesMap);
+    if( iOperatorCache )
+        iOperatorCache->ValidateCacheEntriesL(aOnDiskFilesMap);
+    if( iphoneSpecificCache )
+        iphoneSpecificCache->ValidateCacheEntriesL(aOnDiskFilesMap);
+    }
 
-        //1b. Add any files found to the HashTable
-        const TInt nMatches = matchingFiles->Count();
-        for ( TInt i = 0; i < nMatches; i++ )
-            {
-            TEntry entry ( (*matchingFiles)[i] ) ;
-            TPtrC ext( entry.iName.Right( KIndexFileExtension().Length() ));
+void CHttpCacheManager::GenerateEmptyIndexFileL(const TDesC& aIndexFile, RFs& aRfs )
+    {
+    // Going to remove non-web client cache files in OrphanedFilesL call,
+    // Signal to these clients by emptying (or creating) an 'empty' index file
+    // do this before we start cleaning up files, to lessen the chances that any
+    // of the files are in use when we're trying to delete them.
+    
+    // 'adopt' code from httpcachelookuptable for dealing with indexes.
+    // save entries to index.dat
+    RFileWriteStream writeStream;
 
-            if ( ext.CompareF( KIndexFileExtension ) != 0 && // ignore any .dat index files
-                 ext.CompareF( KValidationFileExtension ) != 0 ) // ignore any .val index files
-                {
-                HBufC* fullPath = HBufC::NewL( dir.Length() +  entry.iName.Length() );
-                cleanupList.Append( fullPath ); //keep object safe for later destruction
-                fullPath->Des().Append( dir );
-                fullPath->Des().Append( entry.iName ); //a fully qualified file path
-                onDiskFilesMap.Insert( fullPath, &needsDelete ); //add to the hash
-                }
+    TInt ret = KErrNone;
+    TInt tryCount = 0;
+    for (tryCount = 0; tryCount < 5; tryCount++) 
+        {
+        ret = writeStream.Replace( aRfs, aIndexFile, EFileWrite );
+        if (ret == KErrInUse)
+            {
+            // When the cache is full, it takes 65 - 85 miliseconds to write the index.
+            // So wait 50 miliseconds and try again
+            User::After(50000);
+            }
+        else
+            {
+            break;
             }
-
-        delete matchingFiles;
-        } // End of step 1: adding all known files on disk to Map
+        }
+    if( ret == KErrNone )
+        {
+        CleanupClosePushL( writeStream );
+        writeStream.WriteInt32L( KCacheVersionNumber );
+        writeStream.WriteInt32L( 0 ); // no entries in the index.
+        writeStream.CommitL();
+        CleanupStack::PopAndDestroy(); // writeStream
+        }
+    }
 
-    CleanupStack::PopAndDestroy( 1, scanner );
-
-#ifdef __CACHELOG__
+void CHttpCacheManager::WipeAllOtherIndexFilesL( CHttpCacheFileHash* aOnDiskFilesMap, RFs& aRfs )
     {
-    HttpCacheUtil::WriteFormatLog(0, _L("-----------START PRINTING MAP OF SIZE %d---------"), onDiskFilesMap.Count());
-    TPtrHashMapIter<TDesC, TInt> iter(onDiskFilesMap);
+    // look through hashmap for any .dat files which don't belong to the instantiated caches and overwrite them with blank ones.
+    THttpCacheFileHashIter iter( aOnDiskFilesMap->HashMap() );
     const TDesC* key;
     while ((key = iter.NextKey()) != 0)
         {
-        const TInt val = *(iter.CurrentValue());
-        HttpCacheUtil::WriteFormatLog(0, _L("MAP WALK: %S, with value = %d "), key, val);
-        }
-    HttpCacheUtil::WriteFormatLog(0, _L("-----------DONE PRINTING MAP-------------"));
-    }
-#endif
-
-    //Step 2. Get list of known (non-orphaned) files in each Cache's in-memory lookup table. Flag them as DO NOT DELETE
-    RPointerArray<TDesC> knownFiles;
-    CleanupClosePushL( knownFiles );
-    //Ask CacheHandlers to add their KNOWN files to this array. No ownership transfer occurs.
-    //Don't go ahead if any of the cache handlers choke to insure correct deletion of files.
-    if (iCache)
-        User::LeaveIfError( iCache->ListFiles( knownFiles ) );
-    if (iOperatorCache)
-        User::LeaveIfError( iOperatorCache->ListFiles( knownFiles ) );
-    if (iphoneSpecificCache)
-        User::LeaveIfError( iphoneSpecificCache->ListFiles( knownFiles ) );
-
-    //2a. HashTable lookup, and modification of flag
-    for (TInt i = 0; i < knownFiles.Count(); i++)
-        {
-        //lookup filename
-        TInt* ptr = onDiskFilesMap.Find( *(knownFiles[i]) );
-        if (ptr)
+        const TFileInfo* value ( (iter.CurrentValue()) );
+        if( value->iUserInt == KCacheFileNeedsDelete )
             {
-            // Reinsert into Map, this time with NO DELETE
-            onDiskFilesMap.Insert( knownFiles[i], &noDelete );
-#if 0 // no header files any more.
-            // Add the header file to HashMap
-            HBufC* headerFile = HBufC::NewL( KHttpCacheHeaderExt().Length() +  (*(knownFiles[i])).Length() );
-            cleanupList.Append( headerFile ); //keep for later destruction
-            TPtr ptr( headerFile->Des() );
-            HttpCacheUtil::GetHeaderFileName( *(knownFiles[i]), ptr );
-            onDiskFilesMap.Insert( headerFile, &noDelete ); // register Header files as NO DELETE
-#endif
+            TPtrC ext( key->Right(KIndexFileExtension().Length()) );
+            if (    ext.CompareF( KIndexFileExtension ) == 0 ) // find any .dat index files
+                { 
+                GenerateEmptyIndexFileL( *key , aRfs );
+                }
             }
         }
-
-    knownFiles.Close();
-    CleanupStack::Pop( 1, &knownFiles );
+    }
 
+void CHttpCacheManager::DeleteMarkedFilesL( CHttpCacheFileHash* aOnDiskFilesMap, RFs& aRfs )
+    {
     //Step 3. Delete all files on disk that don't belong to any of the Cache Handlers.
-    CFileMan* fileMan = CFileMan::NewL( rfs );
-    TPtrHashMapIter<TDesC, TInt> iter( onDiskFilesMap );
+    CFileMan* fileMan = CFileMan::NewL( aRfs );
+    THttpCacheFileHashIter iter( aOnDiskFilesMap->HashMap() );
     const TDesC* key;
     while ((key = iter.NextKey()) != 0)
         {
-        const TInt value ( *(iter.CurrentValue()) );
-        if ( value == 1 ) { // file needs deletion
-            fileMan->Delete( *key );
-        }
+        const TFileInfo* value ( (iter.CurrentValue()) );
+        if( value->iUserInt == KCacheFileNeedsDelete )
+            {
+            TPtrC ext( key->Right(KIndexFileExtension().Length()) );
+            if (    ext.CompareF( KIndexFileExtension ) != 0 && // ignore any .dat index files
+                    ext.CompareF( KValidationFileExtension ) != 0 ) // ignore any .val files
+                { 
+                fileMan->Delete( *key );
+                }
+            }
         }
     delete fileMan;
-
-    CleanupStack::Pop(1, &cleanupList);
-    cleanupList.ResetAndDestroy(); //should delete all HBufC objects
-
-    CleanupStack::Pop(1, &onDiskFilesMap);
-    onDiskFilesMap.Close(); // doesn't own any K,V object
-
     }
 
 // -----------------------------------------------------------------------------
@@ -552,8 +569,6 @@
     if( iCacheEnabled || iVSSCacheEnabled )
         {
         CHttpCacheHandler* cache = CacheHandler( aUrl, NULL );
-
-        __ASSERT_DEBUG( cache, User::Panic( _L("cacheHandler Panic"), KErrCorrupt ) );
         //
         if( cache )
             {
@@ -578,14 +593,14 @@
     TBool found ( EFalse );
     if( aHttpHeaderString->Size() > 0 )
         {
-        TPtrC8 nameStr8( KVSSHeaderFileldName() );
+        TPtrC8 nameStr8( KVSSHeaderFieldName() );
 
         TInt VSSnameLocation = aHttpHeaderString->FindC( nameStr8 ) ;
 
         if ( VSSnameLocation != KErrNotFound )
             {
-            TPtrC8 valueStr8( KVSSHeaderFileldValue() );
-            TInt VSSvalueLocation = aHttpHeaderString->FindC( KVSSHeaderFileldValue() );
+            TPtrC8 valueStr8( KVSSHeaderFieldValue() );
+            TInt VSSvalueLocation = aHttpHeaderString->FindC( KVSSHeaderFieldValue() );
 
             if ( (VSSvalueLocation != KErrNotFound ) && ( VSSnameLocation < VSSvalueLocation ) )
                 {
@@ -617,7 +632,6 @@
         TPtr8 headerStrPtr8 ( headerStr->Des() ); //Any Type of TPtrc8
         CHttpCacheHandler* cache = CacheHandler( aUrl, &headerStrPtr8 );
         delete headerStr;
-        __ASSERT_DEBUG( cache, User::Panic( _L("cacheHandler Panic"), KErrCorrupt ) );
         //
         if( cache )
             {
@@ -642,7 +656,6 @@
     if( iCacheEnabled || iVSSCacheEnabled )
         {
         CHttpCacheHandler* cache = CacheHandler( aUrl, NULL );
-        __ASSERT_DEBUG( cache, User::Panic( _L("cacheHandler Panic"), KErrCorrupt ) );
         //
         if( cache )
             {
@@ -675,138 +688,147 @@
 //
 void CHttpCacheManager::CreateCacheHandlersL()
     {
-    // read cache settings
-    CRepository* repository = CRepository::NewLC( KCRUidCacheManager );
-    CRepository* repositoryDiskLevel = CRepository::NewLC( KCRUidDiskLevel );
-    TInt err;
+    // get our SID.
+    RProcess process;
+    TSecureId secId = process.SecureId();
+    TUint32 secIdInt = secId;
+
+    CRepository* repository = CRepository::NewLC(KCRUidCacheManager);
+    CRepository* repositoryDiskLevel = CRepository::NewLC(KCRUidDiskLevel);
 
     // Get Cache Postpone Parameters.
-    //
     THttpCachePostponeParameters postpone;
+    TBool newCentrepPresent;
+    GetPostponeParamsL( newCentrepPresent, postpone, repository );
+
+    // apply default cache configuration - no cache for anyone, sizes set to default.
+    iCacheEnabled = EFalse;
+    TInt cacheSize( KDefaultCacheSize );
+    iCacheFolder.Copy( KDefaultCacheDir );
+   
+    TBool opCacheEnabled( EFalse );
+    iOperatorCache = 0;
+    TInt opCacheSize = KDefaultOperatorCacheSize;
+    TFileName opCacheFolder( KDefaultOperatorCacheDir );
+    
+    iVSSCacheEnabled = EFalse;
+    TInt vssCacheSize = KDefaultOperatorCacheSize;
+    TFileName vssCacheFolder( KDefaultVssCacheDir );
 
-    if (KErrNone == repository->Get(KCacheWritePostponeEnabled, postpone.iEnabled) )
+    if(newCentrepPresent)
         {
-        User::LeaveIfError( repository->Get( KCacheWritePostponeFreeRAMThreshold, postpone.iFreeRamThreshold ) );
-        User::LeaveIfError( repository->Get( KCacheWritePostponeImmediateWriteThreshold, postpone.iImmediateWriteThreshold ) );
-        User::LeaveIfError( repository->Get( KCacheWritePostponeWriteTimeout, postpone.iWriteTimeout ) );
+        // if the new Centrep file is present, we trust it's configured properly.
+        GetHttpCacheConfigL( *repository, iCacheEnabled, cacheSize, iCacheFolder );
+        GetOperatorCacheConfigL( *repository, opCacheEnabled, opCacheSize, opCacheFolder );
+        GetVSSCacheConfigL( *repository, iVSSCacheEnabled, vssCacheSize, vssCacheFolder );
+        }
+    
+    // look for per-process overrides in central repository.  Do this before we get drive critical levels so we're on the right
+    // drive.
+    // This has a default string which applies the new per-client default configuration
+    ApplyCacheOverridesL(*repository, secIdInt, iCacheEnabled, cacheSize, opCacheEnabled, iVSSCacheEnabled, iCacheFolder, KDefaultCacheDrive());
+
+    TInt criticalLevel = 0;
+    GetCriticalDriveLevelsL( *repositoryDiskLevel, iCacheFolder, criticalLevel );
+    
+    // Create any caches we should be using.
+    if (iCacheEnabled)
+        {
+        CreateHttpCacheL( secIdInt, cacheSize, criticalLevel, postpone );
+
+        if (opCacheEnabled)
+            {
+            CreateOperatorCacheL( *repository, opCacheFolder, opCacheSize, criticalLevel, postpone );
+            }
+        } //end if( iCacheEnabled )
+
+    if ( iVSSCacheEnabled )
+        {
+        CreateVssCacheL( *repository, vssCacheFolder, vssCacheSize, criticalLevel, postpone );
         }
 
-    // cache on/off
-    TInt cacheEnabled( 0 );
-    err = repository->Get( KCacheManagerHttpCacheEnabled, cacheEnabled );
-
-    iCacheEnabled = cacheEnabled;
-
-        // cache size
-        TInt cacheSize( KDefaultCacheSize );
-        repository->Get( KCacheManagerHttpCacheSize, cacheSize );
-
-         repository->Get( KCacheManagerHttpCacheFolder, iCacheFolder );
-        // fix folder by appending trailing \\ to the end -symbian thing
-        // unless it is already there
-        if( iCacheFolder.LocateReverse( '\\' ) != iCacheFolder.Length() - 1  )
-            {
-            iCacheFolder.Append( _L("\\") );
-            }
-
-    // get drive letter for sysutil
-    TParsePtrC pathParser( iCacheFolder );
-    TDriveUnit drive = pathParser.Drive();
-    // get critical level
-    // RAM drive can have different critical level
-    TVolumeInfo vinfo;
-    User::LeaveIfError( CCoeEnv::Static()->FsSession().Volume( vinfo, drive ) );
-    //
-    TInt criticalLevel;
-    User::LeaveIfError( repositoryDiskLevel->Get( ( vinfo.iDrive.iType == EMediaRam ? KRamDiskCriticalLevel : KDiskCriticalThreshold ),
-        criticalLevel ) );
-
-    if ( (err == KErrNone) && iCacheEnabled )
-        {
-        // create cache handler
-        iCache = CHttpCacheHandler::NewL( cacheSize, iCacheFolder, KDefaultIndexFile(), criticalLevel, postpone);
-
-        // create operator cache. same settings
-        if ( FeatureManager::FeatureSupported( KFeatureIdOperatorCache ) )
-            {
-            TBuf<512> url;
-            // if domain is missing, then no need to read further
-            if ( repository->Get( KOperatorDomainUrl, url ) == KErrNone )
-                {
-
-                HBufC8* opDomain8 = HBufC8::NewL( url.Length() );
-                CleanupStack::PushL(opDomain8);
-                opDomain8->Des().Append( url );
-
-                TInt slashPos = opDomain8->LocateReverse('/');
-                if (slashPos == -1)
-                    {
-                    slashPos = 0;
-                    }
-
-                TPtrC8 temp = opDomain8->Left(slashPos);
-                iOpDomain = temp.AllocL();
-                CleanupStack::PopAndDestroy(opDomain8);
+    CleanupStack::PopAndDestroy(2); // repository, repositoryDiskLevel
+    CrashCheckL( secIdInt );
+    }
 
-                // op cache size
-                TInt opCacheSize( KDefaultCacheSize );
-                repository->Get( KOperatorCacheSize, opCacheSize );
-
-                // op cache folder
-                TFileName opCacheFolder( KDefaultOperatorCacheDir );
-                repository->Get( KOperatorCacheFolder, opCacheFolder );
-
-                if ( opCacheFolder.LocateReverse( '\\' ) != opCacheFolder.Length() - 1  )
-                    {
-                    opCacheFolder.Append( _L("\\") );
-                    }
-
-                // create op cache
-                iOperatorCache = CHttpCacheHandler::NewL( opCacheSize, opCacheFolder, KDefaultOpIndexFile(), criticalLevel, postpone);
-                }
-            } //end if( FeatureManager::FeatureSupported( KFeatureIdOperatorCache ) )
-        } //end if( iCacheEnabled )
-
-    TInt VSScacheEnabled( 0 );
-    err = repository->Get( KPhoneSpecificCacheEnabled, VSScacheEnabled );
-
-    iVSSCacheEnabled = VSScacheEnabled;
-
-    if ( (err == KErrNone) && iVSSCacheEnabled )
+void CHttpCacheManager::ApplyCacheOverridesL(CRepository& aRepository, const TUint32& aSecIdInt, TBool& aCacheEnabled, TInt& aCacheSize, TBool& aOpCacheEnabled, TBool& aVssCacheEnabled, TDes& aPath, const TDesC& aDefaultDrive)
+    {
+    TDriveUnit drive(aDefaultDrive);
+    
+    // set defaults
+    if(aSecIdInt == KUIDBROWSERNG)       // for the browser, force use of Operator and VSS caches
+        {
+        aOpCacheEnabled = ETrue;
+        aVssCacheEnabled = ETrue;
+        }
+    
+    // read override string from centrep
+    HBufC16 *overrideBuf = HBufC16::NewLC(64);
+    TPtr overrideStr(overrideBuf->Des());
+    TInt strLen;
+    TInt err = aRepository.Get(KCacheManagerHttpCacheProcessOverride, overrideStr, strLen);
+    if(strLen > overrideBuf->Length())
+        {
+        overrideBuf = overrideBuf->ReAllocL(strLen);
+        // make sure cleanup stack contains correct pointer since ReAllocL always allocates a new des for larger space.
+        CleanupStack::Pop();
+        CleanupStack::PushL(overrideBuf);
+        // reassign the TPtr
+        overrideStr.Set(overrideBuf->Des());
+        // pull in the whole string
+        aRepository.Get(KCacheManagerHttpCacheProcessOverride, overrideStr, strLen);
+        }
+    // if we failed to load an override string, use the default.
+    if( overrideStr.Length() == 0 )
         {
-        // cache size
-        TInt VSScacheSize( KDefaultCacheSize );
-        repository->Get( KPhoneSpecificCacheSize, VSScacheSize );
+        CleanupStack::PopAndDestroy( overrideBuf );
+        overrideBuf = KDefaultOverrideString().AllocLC();
+        overrideStr.Set( overrideBuf->Des() );
+        }
+    // Built in Lex likes white space to separate strings, but easier to enter with ; separators.  Replace all ; with spaces.
+    TInt pos=0;
+    do{
+        if(overrideStr[pos] == ';')
+            {
+            overrideStr[pos] = ' ';
+            }
+        pos++;
+    }while(pos < overrideStr.Length());
+    
+    TLex overrideLex(overrideStr);
+    do{
+        TUint32 tempId;
+        User::LeaveIfError(overrideLex.BoundedVal(tempId,EHex,KMaxTUint32));
+        if(overrideLex.TokenLength() != 8)  // if we're not pointing at an SID in the string, we are incorrect and the override is broken.
+            User::Leave(KErrCorrupt);
+        overrideLex.SkipSpace();
+        TInt32 tempCacheEnabled;
+        User::LeaveIfError(overrideLex.BoundedVal(tempCacheEnabled,KMaxTInt32));
+        overrideLex.SkipSpace();
+        TInt32 tempCacheSize;
+        User::LeaveIfError(overrideLex.BoundedVal(tempCacheSize,KMaxTInt32));
+        overrideLex.SkipSpace();
+        TDriveUnit tempDrive(overrideLex.NextToken());
+        overrideLex.SkipSpaceAndMark();
+        // found a hex SID matching ours, use the parameters.
+        if(tempId == aSecIdInt)
+            {
+            aCacheEnabled = tempCacheEnabled;
+            aCacheSize = tempCacheSize * 1024; // conf is in KB
+            drive = tempDrive;
+            break;
+            }
+    }while(!overrideLex.Eos());
 
-        // cache folder
-        TFileName VSScacheFolder( KDefaultVssCacheDir );
-        // ignore cache folder. use c:\ to save memory. (same for operator cache. see below)
-        repository->Get( KPhoneSpecificCacheFolder, VSScacheFolder );
-        // fix folder by appending trailing \\ to the end -symbian thing
-        // unless it is already there
-        if( VSScacheFolder.LocateReverse( '\\' ) != VSScacheFolder.Length() - 1  )
-            {
-            VSScacheFolder.Append( _L("\\") );
-            }
-
-        //Get the white list
-        TBuf<2048> whiteList;
-
-        if ( repository->Get( KPhoneSpecificCacheDomainUrl, whiteList ) == KErrNone )
-            {
-            iVSSWhiteList = HBufC8::NewL( whiteList.Length() );
-            iVSSWhiteList->Des().Append( whiteList );
-            }
-        else
-            {
-            iVSSWhiteList = NULL;
-            }
-
-        // create cache handler
-        iphoneSpecificCache = CHttpCacheHandler::NewL( VSScacheSize, VSScacheFolder, KDefaultVSSIndexFile(), criticalLevel, postpone);
-        }
-
-    CleanupStack::PopAndDestroy(2); // repository, , repositoryDiskLevel
+    // Modify drive letter on aPath to match
+    TParsePtr parsePath(aPath);
+    TPtrC pathStr(parsePath.Path());
+    TPath tempPath;
+    tempPath.Format(_L("%c:%S"), TInt(drive)+'A', &pathStr);
+    aPath.Copy(tempPath);
+    HttpCacheUtil::EnsureTrailingSlash( aPath );
+    
+    CleanupStack::PopAndDestroy(overrideBuf);
     }
 
 // -----------------------------------------------------------------------------
@@ -829,4 +851,184 @@
         }
     return cache;
     }
+
+void CHttpCacheManager::GetPostponeParamsL( TBool& aNewCentrepPresent, THttpCachePostponeParameters& aParams, CRepository* aRepo )
+    {
+    aNewCentrepPresent = EFalse;
+    if (KErrNone == aRepo->Get(KCacheWritePostponeEnabled,
+            aParams.iEnabled))
+        {
+        User::LeaveIfError(aRepo->Get(
+                KCacheWritePostponeFreeRAMThreshold,
+                aParams.iFreeRamThreshold));
+        User::LeaveIfError(aRepo->Get(
+                KCacheWritePostponeImmediateWriteThreshold,
+                aParams.iImmediateWriteThreshold));
+        User::LeaveIfError(aRepo->Get(KCacheWritePostponeWriteTimeout,
+                aParams.iWriteTimeout));
+        
+        aNewCentrepPresent = ETrue;
+        }
+    }
+
+void CHttpCacheManager::GetHttpCacheConfigL( CRepository& aRepository, TBool& aCacheEnabled, TInt& aCacheSize, TDes& aCacheFolder )
+    {
+    // General HTTP Cache
+    TBool cacheEnabled( EFalse );
+    aCacheFolder.Copy( KDefaultCacheDir );
+    
+    TInt err = aRepository.Get(KCacheManagerHttpCacheEnabled, cacheEnabled);
+    aCacheEnabled = cacheEnabled;
+    if( err == KErrNone )
+        {
+        // cache size
+        TInt tempCacheSize;
+        if( aRepository.Get(KCacheManagerHttpCacheSize, tempCacheSize) == KErrNone )
+            aCacheSize = tempCacheSize;
+
+        // cache location
+        TFileName tempCacheLocation;
+        if( aRepository.Get(KCacheManagerHttpCacheFolder, tempCacheLocation) == KErrNone )
+            aCacheFolder.Copy( tempCacheLocation );
+        }
+    HttpCacheUtil::EnsureTrailingSlash( aCacheFolder );
+    }
+
+void CHttpCacheManager::GetOperatorCacheConfigL( CRepository& aRepository, TBool& aOpCacheEnabled, TInt& aOpCacheSize, TDes& aOpCacheFolder )
+    {
+    // Operator Cache
+    aOpCacheEnabled = FeatureManager::FeatureSupported(KFeatureIdOperatorCache);
+    if( aOpCacheEnabled )
+        {
+        TInt tempOpCacheSize;
+        if( aRepository.Get(KOperatorCacheSize, tempOpCacheSize) == KErrNone )
+            aOpCacheSize = tempOpCacheSize;
+
+        // op cache folder
+        TFileName tempOpCacheFolder;
+        if( aRepository.Get(KOperatorCacheFolder, tempOpCacheFolder) == KErrNone )
+            aOpCacheFolder.Copy( tempOpCacheFolder );
+        }
+    HttpCacheUtil::EnsureTrailingSlash( aOpCacheFolder );
+    }
+
+void CHttpCacheManager::GetVSSCacheConfigL( CRepository& aRepository, TBool& aVSSCacheEnabled, TInt& aVssCacheSize, TDes& aVssCacheFolder )
+    {
+    // VSS Cache
+    TInt VSScacheEnabled(0);
+    TInt err = aRepository.Get(KPhoneSpecificCacheEnabled, VSScacheEnabled);
+    aVSSCacheEnabled = VSScacheEnabled;
+
+    if ( err == KErrNone && aVSSCacheEnabled )
+        {
+        TInt tempVSSCacheSize;
+        if( aRepository.Get(KPhoneSpecificCacheSize, tempVSSCacheSize) == KErrNone )
+            aVssCacheSize = tempVSSCacheSize;
+
+        TFileName tempVSScacheFolder;
+        if( aRepository.Get(KPhoneSpecificCacheFolder, tempVSScacheFolder) == KErrNone )
+            aVssCacheFolder.Copy( tempVSScacheFolder );
+        }
+    HttpCacheUtil::EnsureTrailingSlash( aVssCacheFolder );
+    }
+
+void CHttpCacheManager::GetCriticalDriveLevelsL( CRepository& aRepository, const TDesC& aCacheFolder, TInt& aCriticalLevel )
+    {
+    // get drive letter for sysutil
+    TParsePtrC pathParser( aCacheFolder );
+    TDriveUnit drive = pathParser.Drive();
+
+    // get critical level
+    // RAM drive can have different critical level
+    TVolumeInfo vinfo;
+    User::LeaveIfError(CCoeEnv::Static()->FsSession().Volume(vinfo, drive));
+    //
+    User::LeaveIfError(aRepository.Get((vinfo.iDrive.iType == EMediaRam ? KRamDiskCriticalLevel : KDiskCriticalThreshold), aCriticalLevel));
+    }
+
+void CHttpCacheManager::CreateHttpCacheL( const TInt& aSecIdInt, const TInt& aCacheSize, const TInt& aCriticalLevel, const THttpCachePostponeParameters& aPostpone )
+    {
+    // browser gets the normal index.dat name, other clients get <SID>.dat
+    TFileName indexFile( KDefaultIndexFile() );
+    if( aSecIdInt != KUIDBROWSERNG )
+        {
+        indexFile.Format(_L("%08x.dat"), aSecIdInt);
+        }
+    // create cache handler
+    iCache = CHttpCacheHandler::NewL( aCacheSize, iCacheFolder, indexFile, aCriticalLevel, aPostpone);
+    }
+
+void CHttpCacheManager::CreateOperatorCacheL( CRepository& aRepository, const TDesC& aOpCacheFolder, const TInt& aOpCacheSize, const TInt& aCriticalLevel, const THttpCachePostponeParameters& aPostpone )
+    {
+    TBuf<512> url;
+    // if domain is missing, then no need to read further
+    if (aRepository.Get(KOperatorDomainUrl, url) == KErrNone)
+        {
+        HBufC8* opDomain8 = HBufC8::NewL(url.Length());
+        CleanupStack::PushL(opDomain8);
+        opDomain8->Des().Append(url);
+    
+        TInt slashPos = opDomain8->LocateReverse('/');
+        if (slashPos == -1)
+            {
+            slashPos = 0;
+            }
+    
+        TPtrC8 temp = opDomain8->Left(slashPos);
+        iOpDomain = temp.AllocL();
+        CleanupStack::PopAndDestroy(opDomain8);
+    
+        // create op cache
+        iOperatorCache = CHttpCacheHandler::NewL( aOpCacheSize, aOpCacheFolder, KDefaultOpIndexFile(), aCriticalLevel, aPostpone);
+        }
+    }
+
+void CHttpCacheManager::CreateVssCacheL( CRepository& aRepository, const TDesC& aVssCacheFolder, const TInt& aVssCacheSize, const TInt& aCriticalLevel, const THttpCachePostponeParameters& aPostpone )
+    {
+    //Get the white list
+    TBuf<2048> whiteList;
+    
+    if (aRepository.Get(KPhoneSpecificCacheDomainUrl, whiteList) == KErrNone)
+        {
+        iVSSWhiteList = HBufC8::NewL(whiteList.Length());
+        iVSSWhiteList->Des().Append(whiteList);
+        }
+    else
+        {
+        iVSSWhiteList = NULL;
+        }
+    
+    // create cache handler
+    iphoneSpecificCache = CHttpCacheHandler::NewL(aVssCacheSize, aVssCacheFolder, KDefaultVSSIndexFile(), aCriticalLevel, aPostpone);
+    }
+
+void CHttpCacheManager::CrashCheckL( const TInt& aSecIdInt )
+    {
+    if( aSecIdInt == KUIDBROWSERNG )
+        {
+        //////////////////////////////////////////////////////////////////////////////////////////////////////
+        // Remove orphan files if browser didn't close cache properly - should only happen very occasionally
+        //
+        // We leave a file on the drive when we are in use and remove it when we close properly
+        // If the file is already there we expect files in the cache which have not been added to the index.
+        //
+        //////////////////////////////////////////////////////////////////////////////////////////////////////
+        RFs rfs;
+        User::LeaveIfError( rfs.Connect() );
+        CleanupClosePushL( rfs );
+        rfs.SetSessionPath( iCacheFolder );
+        RFile crashTest;
+        TInt err = crashTest.Create(rfs,KCrashCheck(),EFileRead);
+        crashTest.Close();  
+        if ( err == KErrAlreadyExists )
+            {
+    #ifdef __CACHELOG__
+            HttpCacheUtil::WriteLog(0, _L("Crash detected - removing orphan files"));
+    #endif
+            RemoveOrphanedFilesL();
+            }
+        CleanupStack::PopAndDestroy( &rfs );
+        }
+    }
+
 //  End of File
--- a/webengine/osswebengine/cache/src/HttpCacheObserver.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/src/HttpCacheObserver.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -88,6 +88,23 @@
     iFsSession.Close();
     }
 
+void CHttpCacheObserver::Queue()
+    {
+    if(IsActive())
+        {
+        User::WaitForAnyRequest();  // consume signal
+        }
+    else
+        {
+        SetActive();
+        }
+
+    // queue next notification
+    iFsSession.NotifyChange(ENotifyWrite, iStatus, *iFileName);
+    }
+
+
+
 // -----------------------------------------------------------------------------
 // CHttpCacheObserver::RunL
 //
@@ -95,6 +112,7 @@
 //
 void CHttpCacheObserver::RunL()
     {
+    Queue();
     iHttpCacheHandler->UpdateLookupTable();
     }
 
--- a/webengine/osswebengine/cache/src/HttpCachePostponeWriteUtilities.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/src/HttpCachePostponeWriteUtilities.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -194,16 +194,17 @@
 void CSegmentedHeapBuffer::AppendL(TInt& aRemainder, const TDesC8& aDes)
     {
     aRemainder = aDes.Length(); // consumed nothing yet.
-    TInt workingLen;
-    TInt workingOffset=0;   // read position in source descriptor
     HBufC8* currentBuffer;
 
+    // 90% of cached objects are less than 4KB.
+    // Lots of them also come in two parts from the http stack.
+#define HTTPSEGMENTEDBUFFER_OPTION_INCREMENT_GRADUALLY
+#ifndef HTTPSEGMENTEDBUFFER_OPTION_INCREMENT_GRADUALLY
     TInt lastBuffer = iBufferList.Count()-1;
     if ( lastBuffer < 0 )
         {
         // TODO: Make the first block only equal to the size of data we need?
         // Take some traces to see what happens.
-
         // no blocks allocated.  May leave here if we can't get space.
         currentBuffer = HBufC8::NewLC(iBufferSize);
         iBufferList.AppendL(currentBuffer);
@@ -215,6 +216,8 @@
         currentBuffer = iBufferList[lastBuffer];
         }
 
+    TInt workingLen;
+    TInt workingOffset=0;   // read position in source descriptor
     // here, currentBuffer always points to a buffer we can use.
     while ( aRemainder )
         {
@@ -236,6 +239,123 @@
             CleanupStack::Pop(currentBuffer);
             }
         }
+#else
+#ifdef __CACHELOG__
+    HttpCacheUtil::WriteFormatLog(0, _L("CHttpCacheSegmentedBuffer::AppendL %08x adding %d bytes to %d"), this, aRemainder, this->Length());
+#endif
+    // because most items are small, increment buffers up to the configured segment size as data is added...
+    TInt workingOffset = 0;
+    TInt lastBuffer = iBufferList.Count()-1;
+    if ( lastBuffer < 0 )
+        {
+        // special case for first allocation.
+        // no blocks allocated.  May leave here if we can't get space.
+        if( aRemainder <= iBufferSize)  // we can fit the first block into a single segment
+            {
+#ifdef __CACHELOG__
+            HttpCacheUtil::WriteFormatLog(0, _L(" First alloc %d into buffer fits inside %d"), aRemainder, iBufferSize );
+#endif
+            // fast path optimisation for first alloc into an empty segmented buffer.
+            currentBuffer = aDes.AllocLC();
+            iBufferList.AppendL( currentBuffer );
+            CleanupStack::Pop( currentBuffer );
+            aRemainder = 0;
+            }
+        else
+            {
+            // the segmented buffer is empty and the first block to add is bigger than the configured block size
+            // fill the first segment and leave the rest for the loop
+#ifdef __CACHELOG__
+            HttpCacheUtil::WriteFormatLog(0, _L(" First alloc %d is bigger than %d"), aRemainder, iBufferSize );
+#endif
+            currentBuffer = HBufC8::NewLC( iBufferSize );
+            iBufferList.AppendL( currentBuffer );
+            CleanupStack::Pop( currentBuffer );
+            currentBuffer->Des().Copy( aDes.Ptr(), iBufferSize );
+            workingOffset = iBufferSize;    // when we add the remaining data, we start from here.
+            aRemainder -= iBufferSize;
+            }
+        }
+    else
+        {
+#ifdef __CACHELOG__
+        HttpCacheUtil::WriteFormatLog(0, _L(" Buffer already contains data"));
+#endif
+        currentBuffer = iBufferList[lastBuffer];
+        }
+    
+    // When we get to here the following state applies.
+    // currentBuffer points to an allocated and filled HBufC8
+    // workingOffset tells us how far into the supplied descriptor the data we want is
+    // aRemainder tells us how much data is left to copy.
+    while( aRemainder )
+        {
+#ifdef __CACHELOG__
+        HttpCacheUtil::WriteFormatLog(0, _L(" %d bytes left to add to buffer"), aRemainder);
+#endif
+        TInt possibleConsumptionInThisBlock = iBufferSize - currentBuffer->Length();
+        if( possibleConsumptionInThisBlock == 0 )
+            {
+#ifdef __CACHELOG__
+            HttpCacheUtil::WriteFormatLog(0, _L(" Buffer cannot be extended."));
+#endif
+            // block cannot extend, alloc a new one
+            // the new one is either the correct length, or iBufferSize if aRemainder is too big.
+            TInt spaceToAlloc = aRemainder < iBufferSize ? aRemainder : iBufferSize;
+            currentBuffer = HBufC8::NewLC( spaceToAlloc );
+            iBufferList.AppendL( currentBuffer );
+            CleanupStack::Pop( currentBuffer );
+            possibleConsumptionInThisBlock = spaceToAlloc;            
+#ifdef __CACHELOG__
+            HttpCacheUtil::WriteFormatLog(0, _L(" New buffer of %d bytes allocated"), spaceToAlloc);
+#endif
+            // fill the block as far as possible
+            currentBuffer->Des().Append( aDes.Mid( workingOffset, possibleConsumptionInThisBlock ));
+            workingOffset += possibleConsumptionInThisBlock;
+            aRemainder -= possibleConsumptionInThisBlock;
+            }
+        else
+            {
+            // block can extend
+            if( possibleConsumptionInThisBlock >= aRemainder )
+                {
+#ifdef __CACHELOG__
+                HttpCacheUtil::WriteFormatLog(0, _L(" Current buffer can be extended to hold all data."));
+#endif
+                // we can realloc this buffer big enough to hold all the remaining data.
+                currentBuffer = currentBuffer->ReAllocL( currentBuffer->Length() + aRemainder );
+                CleanupStack::PushL( currentBuffer );
+                iBufferList.Remove(iBufferList.Count()-1);
+                iBufferList.AppendL( currentBuffer );
+                CleanupStack::Pop( currentBuffer );
+                // copy the data
+                currentBuffer->Des().Append( aDes.Mid( workingOffset, aRemainder ));
+                aRemainder = 0;
+                }
+            else
+                {
+#ifdef __CACHELOG__
+                HttpCacheUtil::WriteFormatLog(0, _L(" Buffer cannot be extended to hold all data, consuming %d bytes."), possibleConsumptionInThisBlock);
+#endif
+                // this buffer cannot extend to hold all the data.
+                // take as much as we can - we will allocate a new buffer next time around.
+                currentBuffer = currentBuffer->ReAllocL( currentBuffer->Length() + possibleConsumptionInThisBlock );
+                CleanupStack::PushL( currentBuffer );
+                iBufferList.Remove(iBufferList.Count()-1);
+                iBufferList.AppendL( currentBuffer );
+                CleanupStack::Pop( currentBuffer );
+                // copy the data
+                currentBuffer->Des().Append( aDes.Mid( workingOffset, possibleConsumptionInThisBlock ));
+                // set up variables for next time around
+                workingOffset += possibleConsumptionInThisBlock;
+                aRemainder -= possibleConsumptionInThisBlock;
+                }
+            }
+        }
+#endif
+#ifdef __CACHELOG__
+    HttpCacheUtil::WriteFormatLog(0, _L(" exiting AppendL. Segmented buffer now contains %d bytes"), this->Length());
+#endif
     // will only exit here if we consumed all data
     }
 
@@ -350,7 +470,7 @@
 // -----------------------------------------------------------------------------
 //
 CHttpCacheWriteTimeout::CHttpCacheWriteTimeout( const TInt aTimeout )
-    : CActive(EPriorityStandard),
+    : CActive(EPriorityIdle),
       iTimeout(aTimeout) // Standard priority
     {
     }
--- a/webengine/osswebengine/cache/src/HttpCacheStreamHandler.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/src/HttpCacheStreamHandler.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -494,7 +494,7 @@
 
     if ( datalen && aEntry.BodyData().Length() ) // don't bother writing files which have no body data
         {
-        if ( IsDiskSpaceAvailable( datalen ) && CreateNewBodyFile( aEntry ) )
+        if ( IsDiskSpaceAvailable( datalen ) && CreateNewBodyFile( aEntry, ETrue ) )
             {
 #ifdef __CACHELOG__
             HttpCacheUtil::WriteFormatLog(0, _L("CACHEPOSTPONE:   Triggering Async write for object 0x%08x."), &aEntry);
@@ -594,12 +594,16 @@
 //
 // -----------------------------------------------------------------------------
 //
-TBool CHttpCacheStreamHandler::CreateNewBodyFile( CHttpCacheEntry& aCacheEntry )
+TBool CHttpCacheStreamHandler::CreateNewBodyFile( CHttpCacheEntry& aCacheEntry, TBool aUseDirectIO )
     {
     TInt statusBody( KErrNotFound );
 
     // Create the body file or replace it, if it exists.
+#ifdef BRDO_RFILE_WRITE_DIRECT_IO_FF
+    statusBody = aCacheEntry.BodyFile().Replace( iRfs, aCacheEntry.Filename(), EFileShareExclusive | EFileWrite | (aUseDirectIO ? EFileWriteDirectIO : 0) );
+#else
     statusBody = aCacheEntry.BodyFile().Replace( iRfs, aCacheEntry.Filename(), EFileShareExclusive | EFileWrite );
+#endif
 
 #ifdef __CACHELOG__
     HttpCacheUtil::WriteUrlToLog( 0, aCacheEntry.Filename(), aCacheEntry.Url() );
--- a/webengine/osswebengine/cache/src/HttpCacheUtil.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/osswebengine/cache/src/HttpCacheUtil.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -1178,12 +1178,9 @@
         {
         VA_LIST args;
         VA_START(args, aBuf);
-        // Be careful of string length when debugging
         TBuf16<1024> string;
-        // TDes16OverflowIgnore, not supported in 3.2.3
-        // TDes16OverflowIgnore overflow;
-        // string.AppendFormatList(aBuf, args, &overflow);
-        string.AppendFormatList(aBuf, args);
+        TDes16IgnoreOverflow overflow;
+        string.AppendFormatList(aBuf, args, &overflow);
         RFileLogger::WriteFormat(_L("Browser"), fileName, EFileLoggingModeAppend, string);
         VA_END(args);
         }
@@ -1833,4 +1830,128 @@
     return status;
     }
 
+
+// -----------------------------------------------------------------------------
+// FilePathHash
+// Hash function for Symbian file paths: discards case first
+// -----------------------------------------------------------------------------
+static TUint32 FilepathHash(const TDesC& aDes)
+{
+    //since this function is intensively used by the HashMap,
+    //keeping (slow) heap allocation out of it.
+    TBuf<KMaxPath> normalized ( aDes );
+
+    normalized.LowerCase();
+    return DefaultHash::Des16( normalized );
+}
+
+// -----------------------------------------------------------------------------
+// FilepathIdent
+// Comparator for Symbian file paths: Use case-insensitive compare
+// -----------------------------------------------------------------------------
+static TBool FilepathIdent(const TDesC& aL, const TDesC& aR)
+{
+    return ( aL.CompareF(aR) == 0 );
+}
+
+
+void HttpCacheUtil::GenerateCacheContentHashMapL(CHttpCacheFileHash*& aHashMap, RFs& aRfs, const TDesC& aCacheFolder, const TInt aInitialValue)
+    {
+    // need to be able to initialise hash here, but use it sensibly in calling function hence rather strange object construction
+    aHashMap = CHttpCacheFileHash::NewLC(aInitialValue);
+    
+    CDirScan* scanner = CDirScan::NewLC( aRfs );
+
+    //Configure CDirScan to tell you all contents of a particular directory hierarchy
+    scanner->SetScanDataL( aCacheFolder, KEntryAttNormal, ESortNone );
+    CDir* matchingFiles( 0 );
+
+    //Step 1. Find out all files on disk: by walking the directory hierarchy, one directory at a time
+    for (;;)
+        {
+        //1a. Get list of files in current directory, NULL if no directory left in tree
+        scanner->NextL( matchingFiles );
+        if ( !matchingFiles )
+            break;
+
+        TPtrC dir( scanner->FullPath() );
+
+        //1b. Add any files found to the HashTable
+        const TInt nMatches = matchingFiles->Count();
+        for ( TInt i = 0; i < nMatches; i++ )
+            {
+            TEntry entry ( (*matchingFiles)[i] ) ;
+            aHashMap->InsertAndStoreL( entry, dir );
+            }
+
+        delete matchingFiles;
+        } // End of step 1: adding all known files on disk to Map
+
+    CleanupStack::PopAndDestroy( 1, scanner );
+    CleanupStack::Pop( aHashMap );
+    
+#ifdef __CACHELOG__
+    {
+    HttpCacheUtil::WriteFormatLog(0, _L("-----------START PRINTING MAP OF SIZE %d---------"), aHashMap->HashMap().Count());
+    THttpCacheFileHashIter iter(aHashMap->HashMap());
+    const TDesC* key;
+    while ((key = iter.NextKey()) != 0)
+        {
+        const TFileInfo* val = iter.CurrentValue();
+        HttpCacheUtil::WriteFormatLog(0, _L("MAP WALK: %S, with size = %d, value = %d "), key, val->iFileSize, val->iUserInt);
+        }
+    HttpCacheUtil::WriteFormatLog(0, _L("-----------DONE PRINTING MAP-------------"));
+    }
+#endif
+    }
+
+void HttpCacheUtil::EnsureTrailingSlash( TDes& aPath )
+    {
+    // fix folder by appending trailing \\ to the end -symbian thing
+    // unless it is already there
+    if (aPath.LocateReverse('\\') != aPath.Length() - 1)
+        {
+        aPath.Append(_L("\\"));
+        }
+    
+    }
+
+
+CHttpCacheFileHash::CHttpCacheFileHash(const TInt aInitialValue, const THashFunction32<TDesC>& aHash, const TIdentityRelation<TDesC>& aIdentity) : iHashMap(aHash, aIdentity), iInitialValue(aInitialValue)
+    {
+    }
+
+CHttpCacheFileHash* CHttpCacheFileHash::NewLC(const TInt iInitialValue)
+    {
+    CHttpCacheFileHash* obj = new (ELeave) CHttpCacheFileHash(iInitialValue, &FilepathHash, &FilepathIdent);
+    CleanupStack::PushL(obj);
+    obj->ConstructL();
+    return obj;
+    }
+
+CHttpCacheFileHash::~CHttpCacheFileHash()
+    {
+    iStringStorage.ResetAndDestroy();
+    delete iFileInfoStorage;
+    iHashMap.Close();
+    }
+
+void CHttpCacheFileHash::ConstructL()
+    {
+    iFileInfoStorage = new (ELeave) CArrayFixSeg<TFileInfo>(64);    // 64 objects at a time
+    }
+
+void CHttpCacheFileHash::InsertAndStoreL(const TEntry& aEntry, const TDesC& aDir)
+    {
+    TFileInfo& info = iFileInfoStorage->ExtendL();
+    info.iFileSize = aEntry.iSize;
+    info.iUserInt = iInitialValue;
+    HBufC* fullPath = HBufC::NewL( aDir.Length() + aEntry.iName.Length() );
+    iStringStorage.AppendL( fullPath ); //keep object safe for later destruction
+    TPtr path(fullPath->Des());
+    path.Copy( aDir );
+    path.Append( aEntry.iName );
+    iHashMap.Insert( fullPath , &info );
+    }
+
 //  End of File
--- a/webengine/pagescaler/src/minimap.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/pagescaler/src/minimap.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -345,8 +345,15 @@
     iDocumentComplete = EFalse;
     iViewportOnDocument = TRect();
     iUpdateTimer->Cancel();
-    iUpdateCbTimer->Cancel();
+    if ( iUpdateCbTimer->IsActive() )
+        {
+        UpdateNow();
+        }
     iVisibilityTimer->Cancel();
+    if ( iFadeDirection )
+        {
+        VisibilityTimerCbL();
+        }
     iGenerator->Clear();
     TRAP_IGNORE(CheckAndCreateMinimapBitmapsL());
     iNeedsUpdate = EFalse;
--- a/webengine/widgetinstaller/Inc/WidgetConfigHandler.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/widgetinstaller/Inc/WidgetConfigHandler.h	Thu Sep 24 12:53:48 2009 +0300
@@ -140,6 +140,7 @@
             EPropertyDescriptionWidth,                     // optional; integer; example: 100
             EPropertyDescriptionNokiaMiniViewEnable,       // optional; bool but int 0/1 internally
             EPropertyDescriptionNokiaPromptNeeded,       //optional; bool but int 0/1 internally
+            EPropertyDescriptionNokiaPreInstalled,         // optional; bool but int 0/1 internally
             // end property description list, begin special values
             EPropertyDescriptionIdCount,     // must be at end of properties
             EPropertyDescriptionIdInvalid    // must be after EPropertyDescriptionIdCount
--- a/webengine/widgetinstaller/Src/WidgetBackupRegistryXml.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/widgetinstaller/Src/WidgetBackupRegistryXml.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -43,6 +43,7 @@
 _LIT( KNokiaWidget,          "NokiaWidget" );
 _LIT( KMiniViewEnabled,      "MiniViewEnabled" );
 _LIT( KBlanketPermGranted,   "BlanketPermissionGranted" );         // optional
+_LIT( KPreInstalled,         "PreInstalled" );                     // optional
 
 // ============================================================================
 // CWidgetBackupRegistryXml::NewL()
@@ -181,6 +182,11 @@
     property.name.Set( KBlanketPermGranted );
     property.type = EWidgetPropTypeInt;
     iProperties.AppendL(property);
+    //
+    property.id = EPreInstalled;
+    property.name.Set( KPreInstalled );
+    property.type = EWidgetPropTypeInt;
+    iProperties.AppendL(property);
     }
 
 // ============================================================================
--- a/webengine/widgetinstaller/Src/WidgetConfigHandler.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/widgetinstaller/Src/WidgetConfigHandler.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -64,6 +64,7 @@
 _LIT( KNokiaVersion,               "Version" );                 // optional
 _LIT( KNokiaMiniViewEnabled,       "MiniViewEnabled" );         // optional
 _LIT( KBlanketPermGranted,          "BlanketPermissionGranted" );// optional 
+_LIT( KPreInstalled,               "PreInstalled" );            // optional
 
 // Apple/Nokia shared key names
 _LIT( KMainHTML,                   "MainHTML" );                // required
@@ -215,6 +216,11 @@
     iProperties[EPropertyDescriptionNokiaPromptNeeded].name.Set( KBlanketPermGranted );
     iProperties[EPropertyDescriptionNokiaPromptNeeded].type = EWidgetPropTypeBool;
     iProperties[EPropertyDescriptionNokiaPromptNeeded].flags = CONFIG_NOKIA_MAY;
+    //
+    iProperties[EPropertyDescriptionNokiaPreInstalled].id = EPreInstalled;
+    iProperties[EPropertyDescriptionNokiaPreInstalled].name.Set( KPreInstalled );
+    iProperties[EPropertyDescriptionNokiaPreInstalled].type = EWidgetPropTypeBool;
+    iProperties[EPropertyDescriptionNokiaPreInstalled].flags = CONFIG_NOKIA_MAY;
 
     }
 
--- a/webengine/widgetregistry/Server/src/WidgetEntry.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/widgetregistry/Server/src/WidgetEntry.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -54,6 +54,8 @@
 _LIT( KXmlDataTypeString, "string" );
 _LIT( KXmlDataTypeUid, "uid" );
 
+static const TInt KWidgetPropertyListVersion32 = 1;
+static const TInt KWidgetPropertyListVersion71 = 3;
 // MODULE DATA STRUCTURES
 
 // LOCAL FUNCTION PROTOTYPES
@@ -165,8 +167,10 @@
 
     // For now, leave if version doesn't match compiled-in version,
     // FUTURE do something smarter
+    //WIDGETPROPERTYLISTVERSION is 1 in case of Tiger engine and 3 in case of Leopard engine. Therefore, modifying the check such that 
+    //when the Version id is 1 or 3, we do not treat the file as corrupt.
     if ( ( EWidgetPropTypeUnknown == (*this)[EWidgetPropertyListVersion].iType )
-         || ( WIDGETPROPERTYLISTVERSION != (*this)[EWidgetPropertyListVersion] ) )
+         || ( (KWidgetPropertyListVersion32 != (*this)[EWidgetPropertyListVersion] ) && (KWidgetPropertyListVersion71 != (*this)[EWidgetPropertyListVersion] )) )
         {
         User::Leave( KErrCorrupt );
         }
@@ -435,9 +439,71 @@
             break;
         case EWidgetPropTypeString:
             {
-            str.Append( (*this)[i] );
-            }
+			// start an encoding process for special characters for xml writing
+			// the special characters are:
+			// '&', Ampersand:   &amp; 
+			// '>', greater-than:   &gt; 
+			// '<', less-than:   &lt; 
+			// ''', apostrophe:   &apos; 
+			// '"', quote:   &quot;
+
+			TBuf<KMaxFileName> orig;
+			orig.Append((*this)[i]);
+			TUint16 * cur = (TUint16 *)orig.Ptr();
+			TUint16 * out = (TUint16 *)str.Ptr();
+			TInt len = orig.Length();
+			for ( TInt i = 0; i < orig.Length(); i++, cur++ )
+			{
+			// By default one have to encode at least '<', '>', '"' and '&' !
+			 if (*cur == '<') {
+				 *out++ = '&';
+				 *out++ = 'l';
+				 *out++ = 't';
+				 *out++ = ';';
+				 len += 3;
+			 } else if (*cur == '>') {
+				 *out++ = '&';
+				 *out++ = 'g';
+				 *out++ = 't';
+				 *out++ = ';';
+				 len += 3;
+			 } else if (*cur == '&') {
+				 *out++ = '&';
+				 *out++ = 'a';
+				 *out++ = 'm';
+				 *out++ = 'p';
+				 *out++ = ';';
+				 len += 4;
+			 } else if (*cur == '"') {
+				 *out++ = '&';
+				 *out++ = 'q';
+				 *out++ = 'u';
+				 *out++ = 'o';
+				 *out++ = 't';
+				 *out++ = ';';
+				 len += 5;
+			 } else if (*cur == '\'') {
+				 *out++ = '&';
+				 *out++ = 'a';
+				 *out++ = 'p';
+				 *out++ = 'o';
+				 *out++ = 's';
+				 *out++ = ';';
+				 len += 5;
+			 } else if (*cur == '\r') {
+				 *out++ = '&';
+				 *out++ = '#';
+				 *out++ = '1';
+				 *out++ = '3';
+				 *out++ = ';';
+				 len += 4;
+			 } else {
+				 *out++ = *cur;
+			 }
+			}
+			str.SetLength(len );
             break;
+			}
         case EWidgetPropTypeUid:
             const TUid& u = (*this)[i];
             TInt l = u.iUid;
--- a/webengine/widgetregistry/Server/src/WidgetRegistry.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/widgetregistry/Server/src/WidgetRegistry.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -1781,6 +1781,10 @@
         {
         aUids.Reset();
         }
+	else 
+		{
+		error = KErrNone;
+		}
     LOG_CODE( if ( aUids.Count() ) )
     LOG1( "AppArchWidgetUids done widget count %d",
               aUids.Count() );
--- a/webengine/widgetregistry/Server/src/WidgetRegistryXml.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/widgetregistry/Server/src/WidgetRegistryXml.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -43,6 +43,7 @@
 _LIT( KNokiaWidget,          "NokiaWidget" );
 _LIT( KMiniViewEnabled,      "MiniViewEnabled" );
 _LIT( KBlanketPermGranted,   "BlanketPermissionGranted" );         // optional
+_LIT( KPreInstalled,         "PreInstalled" );
 
 static void XmlFree( TAny* aPtr )
     {
@@ -187,6 +188,11 @@
     property.name.Set( KBlanketPermGranted );
     property.type = EWidgetPropTypeInt;
     iProperties.AppendL(property);
+    //
+    property.id = EPreInstalled;
+    property.name.Set( KPreInstalled );
+    property.type = EWidgetPropTypeInt;
+    iProperties.AppendL(property);
     }
 
 // ============================================================================
--- a/webengine/wmlengine/src/MVC/include/MVCView.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/wmlengine/src/MVC/include/MVCView.h	Thu Sep 24 12:53:48 2009 +0300
@@ -505,6 +505,7 @@
   CActive::TPriority iFormatPriority;
   CWmlControl*           iWmlControl;
   TBool iShouldActivate;
+  TBool iDrag;
 };
 
 #endif  // EPOC32VIEW_H
--- a/webengine/wmlengine/src/MVC/src/MVCView.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/wmlengine/src/MVC/src/MVCView.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -4222,7 +4222,8 @@
 				currPosition.iY = iDeviceContext->Origin()->y;
 				ScrollTo(currPosition+nextPosition);
 			}
-			break;        							        	
+            iDrag = ETrue;
+            break;
     }
     
     NW_ADT_Vector_Metric_t i;
@@ -4304,9 +4305,16 @@
                 {
                 if (iShouldActivate)
                     {
-                    NW_Evt_ActivateEvent_t actEvent;
-                    NW_Evt_ActivateEvent_Initialize (&actEvent);
-                    ProcessEvent (NW_Evt_EventOf(&actEvent));
+                      if(!iDrag)
+                        {
+                         NW_Evt_ActivateEvent_t actEvent;
+                         NW_Evt_ActivateEvent_Initialize (&actEvent);
+                         ProcessEvent (NW_Evt_EventOf(&actEvent));
+                        }
+                    else
+                        {
+                        iDrag = EFalse;
+                        }
                     }
                 }
             break;
--- a/webengine/wrtharvester/group/wrtharvester.mmp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/wrtharvester/group/wrtharvester.mmp	Thu Sep 24 12:53:48 2009 +0300
@@ -29,6 +29,7 @@
 SOURCE          wrtharvesterpsnotifier.cpp
 SOURCE          wrtharvesterpublisherobserver.cpp
 SOURCE          wrtharvesterregistryaccess.cpp
+SOURCE          wrtusbhandler.cpp
 
 MW_LAYER_SYSTEMINCLUDE
 MW_LAYER_ECOM_SYSTEMINCLUDE
--- a/webengine/wrtharvester/inc/wrtharvester.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/wrtharvester/inc/wrtharvester.h	Thu Sep 24 12:53:48 2009 +0300
@@ -24,7 +24,7 @@
 #include <contentharvesterplugin.h>
 #include <widgetappdefs.rh>
 #include "wrtharvesterregistryaccess.h"
-
+#include "wrtusbhandler.h"
 
 // FORWARD DECLARATIONS
 class CWrtHarvesterPSNotifier;
@@ -32,6 +32,8 @@
 class MLiwInterface;
 class CLiwGenericParamList;
 class CWrtInfo;
+class CWidgetMMCHandler;
+
 
 // CONSTANTS
 
@@ -111,7 +113,11 @@
     	*/
 		void QueueOperationL(  TWidgetOperations aOperation, TUid aUid );	
 		
-		void DialogShown(){ iDialogShown = EFalse; }	
+		void DialogShown(){ iDialogShown = EFalse; }
+		//to check if the device is in mass memory mode
+		TInt IsInMSMode() { return iMSMode; }
+		void  SetMSMode(TInt val)  { iMSMode = val; }
+		 
 		
 	private:
         
@@ -265,7 +271,7 @@
          * Publish & Subscribe listener
          * own
          */        
-        CWrtHarvesterPSNotifier* iWidgetUsbListener;
+        CWidgetMMCHandler* iWidgetUsbListener;
         
 		/**
     	* 
@@ -311,6 +317,18 @@
          *
          */
          TBool        iDialogShown;
+        /**
+         *
+         *
+         */
+         TInt        iMSMode;
+         
+         RFs iFs;
+        /**
+         *
+         *
+         */
+         RPointerArray<HBufC> iHSWidgets;
     };
 
 #endif // C_WRTCONTENTHARVESTER_H 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webengine/wrtharvester/inc/wrtusbhandler.h	Thu Sep 24 12:53:48 2009 +0300
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Acts on MMC card insertion/removal
+*
+*/
+
+
+#ifndef WIDGETMMCHANDLER_H
+#define WIDGETMMCHANDLER_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h>
+#include "wrtharvester.h"
+//hb
+#include "wrtharvesterpsnotifier.h"
+
+// FORWARD DECLARATION
+class CWrtHarvester;
+
+/*
+ * Inherited CActive, performs a asynchronous conversion operation
+ *
+ * @since 3.1
+ */
+class CWidgetMMCHandler : public CActive
+    {
+public:
+
+    static CWidgetMMCHandler* NewL( CWrtHarvester* aHarvester, RFs& aFs );
+
+    virtual ~CWidgetMMCHandler();
+
+    void Start();
+    void ToggleUSBMode();
+
+protected:
+
+    void RunL();
+
+    TInt RunError( TInt aError );
+
+    void DoCancel();
+
+private:
+
+    // no copy constructor
+    CWidgetMMCHandler( const CWidgetMMCHandler& );
+    // no assignment
+    CWidgetMMCHandler& operator=( const CWidgetMMCHandler& );
+
+    CWidgetMMCHandler( CWrtHarvester* aHarvester, RFs& aFs );
+
+    void ConstructL();
+
+    TInt ScanDrives( TInt& aDriveFlags );
+
+   // CWidgetRegistry* iRegistry; // not owned
+    
+    CWrtHarvester* iHarvester;
+    RFs iFs;
+
+    TInt iDriveFlags;
+
+    };
+
+#endif // #ifndef WIDGETMMCHANDLER_H
--- a/webengine/wrtharvester/src/wrtharvester.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/wrtharvester/src/wrtharvester.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -222,8 +222,12 @@
     User::LeaveIfError( iApaSession.Connect() );
     iWidgetUIListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetUIState );
     iWidgetRegListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetRegAltered );
-    iWidgetMMCListener =  CWrtHarvesterPSNotifier::NewL( this, EWidgetMMCAltered );
-    iWidgetUsbListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetMassStorageMode );
+    
+    User::LeaveIfError( iFs.Connect() );
+    iWidgetUsbListener = CWidgetMMCHandler::NewL( this, iFs );
+    
+    iWidgetUsbListener->Start();
+    SetMSMode(0);
     
     TFileName resourceFileName;  
     TParse parse;    
@@ -275,6 +279,7 @@
     delete iWidgetMMCListener;
     delete iWidgetUsbListener;
     iWidgetOperations.Close();
+    iHSWidgets.ResetAndDestroy();
     iApaSession.Close();
     }
     
@@ -293,10 +298,21 @@
 //  
 void CWrtHarvester::HandlePublisherNotificationL( const TDesC& aContentId, const TDesC8& aTrigger )
     {
+    
+    //Do not send the Operations to the Widgets when in Mass storage mode.. . .  
+    if( IsInMSMode() == 1 )
+        {
+         if(aTrigger == KDeActive)
+         RemovePublisherAndObserverL(aContentId);
+         return;              
+        }
+   
     TUid uid( WidgetUid( aContentId ) );
     TWidgetOperations operation( Uninitialized );
     if( aTrigger == KActive )
         {
+        HBufC* temp = aContentId.Alloc();
+        iHSWidgets.Append( temp );
         iHSCount++;	
         // queue the activated state event only for network accessing widgets
         if ( CheckNetworkAccessL( uid) )
@@ -315,6 +331,17 @@
         {
         iHSCount--;
         operation = Deactivate;
+        HBufC *temp = aContentId.Alloc();
+        TPtr ptr (temp->Des());
+        for( TInt i=0; i<iHSWidgets.Count(); i++ )
+          {
+          if( ! ptr.Compare(iHSWidgets[i]->Des()))
+            {
+            iHSWidgets.Remove(i);
+            break;
+            }
+          }
+        delete temp;        
         }
     else if( aTrigger == KSuspend )
         {
@@ -564,6 +591,22 @@
 //
 void CWrtHarvester::RemovePublisherAndObserverL( const TDesC& aBundleId )
     {
+    
+    if( IsInMSMode() == 1 )
+      {
+      HBufC *temp = aBundleId.Alloc();
+      TPtr ptr (temp->Des());
+      for( TInt i=0; i<iHSWidgets.Count(); i++ )
+        {
+
+        if( ptr.Compare(iHSWidgets[i]->Des()) == 0)
+          {
+           return;
+          }
+        }
+
+      }   
+              
     RemoveObserver( aBundleId );
     
     __UHEAP_MARK;
@@ -952,4 +995,3 @@
     }
 
  //  End of File
-
--- a/webengine/wrtharvester/src/wrtharvesterpsnotifier.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/webengine/wrtharvester/src/wrtharvesterpsnotifier.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -132,11 +132,7 @@
     if( iKey != EWidgetMMCAltered && iKey != EWidgetMassStorageMode )
     	{
     	iProperty.Get( KPropertyCat, iKey, value );	
-    	}
-    else if( iKey == EWidgetMMCAltered )
-        {        
-        r = iProperty.Get( KPSUidUikon, KUikMMCInserted , value );   
-        }    
+    	}    
     else
         {        
         r = iProperty.Get( allDrivesStatus );
@@ -154,31 +150,7 @@
             }
         else if( iKey == EWidgetRegAltered && value == 1 )
             {
-            iHarvester->UpdateL();
-            }
-        else if( iKey == EWidgetMMCAltered )
-            {            
-            iHarvester->UpdateL();    
-            } 
-        else if( iKey == EWidgetMassStorageMode )
-            {            
-            TInt count = allDrivesStatus.Length()/2;
-             for ( TInt i = 0; i < count; i++ )
-                 {
-                 TInt driveNumber = allDrivesStatus[2*i];
-                 TInt driveStatus = allDrivesStatus[2*i+1];
-                 switch( driveStatus )
-                     {
-                     case EUsbMsDriveState_Connected:
-                     case EUsbMsDriveState_Disconnected:
-                         {                           
-                         iHarvester->UpdateL();
-                         }
-                         break;                     
-                     default:
-                         break;
-                     }
-                 }            
+             iHarvester->UpdateL();
             }
         }
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webengine/wrtharvester/src/wrtusbhandler.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -0,0 +1,261 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handle notifications of MMC events.
+*
+*
+*
+*/
+
+#include "wrtusbhandler.h"
+#include "wrtharvester.h"
+#include "wrtusbhandler.h"
+
+// CONSTANTS
+
+
+// ============================================================================
+// CWidgetMMCHandler::NewL()
+// two-phase constructor
+//
+// @since 3.1
+// @param aRegistry - Widget registry for callback.
+// @param aFs - file session
+// @return pointer to CWidgetMMCHandler
+// ============================================================================
+//
+CWidgetMMCHandler* CWidgetMMCHandler::NewL(
+    CWrtHarvester* aHarvester,
+    RFs& aFs )
+    {
+    CWidgetMMCHandler* self =
+        new(ELeave) CWidgetMMCHandler( aHarvester , aFs );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ============================================================================
+// CWidgetMMCHandler::CWidgetMMCHandler()
+// C++ default constructor
+//
+// @since 3.1
+// ============================================================================
+//
+CWidgetMMCHandler::CWidgetMMCHandler( CWrtHarvester* aHarvester,
+                                      RFs& aFs )
+    : CActive( CActive::EPriorityUserInput ),
+      iHarvester( aHarvester ),
+      iFs( aFs ),
+      iDriveFlags( 0 )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ============================================================================
+// CWidgetMMCHandler::ConstructL()
+// Symbian default constructor
+//
+// @since 3.1
+// ============================================================================
+//
+void CWidgetMMCHandler::ConstructL()
+    {
+    if ( KErrNone != ScanDrives( iDriveFlags ) )
+        {
+        iDriveFlags = 0;
+        }
+        RDebug::Print(_L("iDriveFlags ConstructL() : %x %d"), iDriveFlags,iDriveFlags);
+    }
+
+// ============================================================================
+// CWidgetMMCHandler::~CWidgetMMCHandler()
+// destructor
+//
+// @since 3.1
+// ============================================================================
+CWidgetMMCHandler::~CWidgetMMCHandler()
+    {
+    Cancel();
+
+    }
+
+// ============================================================================
+// CWidgetMMCHandler::Start()
+// Start monitoring.
+//
+// @since 5.0
+// ============================================================================
+void CWidgetMMCHandler::Start()
+    {
+    iFs.NotifyChange( ENotifyDisk, iStatus );
+    SetActive();
+    }
+
+// ============================================================================
+// CWidgetMMCHandler::RunL()
+// Handle notifications of MMC events.
+//
+// @since 3.1
+// ============================================================================
+void CWidgetMMCHandler::RunL()
+    {
+    if ( iStatus == KErrNone )
+      {
+        TInt driveFlags = 0;
+        TInt deltaDriveFlags = 0;
+      
+
+         User::After( 10000000 );
+         
+       if ( KErrNone == ScanDrives( driveFlags ) )
+         {
+            deltaDriveFlags = iDriveFlags ^ driveFlags;
+            
+            iDriveFlags = driveFlags;
+         }
+        
+       if ( deltaDriveFlags )
+          {
+          //Unpluging USB from Mass storage . . . 
+          if(iHarvester->IsInMSMode() == 1)
+            {
+             iHarvester->SetMSMode(0);
+             iHarvester->ClearAllOperations();
+             iHarvester->UpdateL();
+             
+             iFs.NotifyChange( ENotifyDisk, iStatus );
+             SetActive();
+             return;
+            }
+
+          TVolumeInfo volInfo;
+          TInt temp = deltaDriveFlags;
+          TBool massMemAltered = EFalse;
+          TBool mmcAltered = EFalse;
+          for(TInt DriveNo = EDriveA+1 ; DriveNo<=EDriveY; DriveNo++ )
+            {
+                
+            temp =  temp >> 1;
+            if( temp & 01)
+              {
+                switch (DriveNo)
+                  {
+                    case EDriveE :
+                      {
+                      massMemAltered = ETrue;   
+                      break; 
+                      }
+                    case EDriveF:
+                      {
+                           
+                      mmcAltered = ETrue;
+                      break;
+                      }
+                         
+                   }
+              }
+            
+            }
+                     
+       if( !massMemAltered && mmcAltered)    
+         {
+          iHarvester->UpdateL();   
+         }
+       else if( massMemAltered )
+         {
+          iHarvester->SetMSMode(1);  
+          iHarvester->UpdateL(); 
+         }
+
+        }
+      }
+      
+      
+    iFs.NotifyChange( ENotifyDisk, iStatus );
+    SetActive();
+    }
+
+// ============================================================================
+// CWidgetMMCHandler::RunError()
+// Ignore errors from RunL.
+//
+// @since 5.0
+// ============================================================================
+TInt CWidgetMMCHandler::RunError( TInt /* aError */ )
+    {
+
+    return KErrNone; // indicates error was handled
+    }
+
+// ============================================================================
+// CWidgetMMCHandler::DoCancel()
+// Cancel the MMC event handler
+//
+// @since 3.1
+// ============================================================================
+void CWidgetMMCHandler::DoCancel()
+    {
+
+    iFs.NotifyChangeCancel();
+    }
+
+/* Scans drives and records a bit flag for those that exist and are
+ * suitable for installing widgets to.
+ */
+TInt CWidgetMMCHandler::ScanDrives( TInt& aDriveFlags )
+    {
+
+    // List all drives in the system
+    TDriveList driveList;
+    TInt error = iFs.DriveList( driveList );
+    if ( KErrNone == error )
+        {
+        for ( TInt driveNumber = EDriveY;
+              driveNumber >= EDriveA;
+              driveNumber-- )
+            {
+            // The drives that will be filtered out are the same ones that
+            // WidgetInstaller filters out in CWidgetUIHandler::SelectDriveL()
+            if ( (EDriveD == driveNumber)
+                 || !driveList[driveNumber] )
+                {
+                // EDriveD is a temporary drive usually a RAM disk
+                continue;
+                }
+
+            TVolumeInfo volInfo;
+            if ( iFs.Volume( volInfo, driveNumber ) != KErrNone )
+                {
+                // volume is not usable (e.g. no media card inserted)
+                continue;
+                }
+            if ( (volInfo.iDrive.iType == EMediaNotPresent) ||
+                 (volInfo.iDrive.iType == EMediaRom) ||
+                 (volInfo.iDrive.iType == EMediaRemote) ||
+                 (volInfo.iDrive.iDriveAtt & KDriveAttRom) ||
+                 (volInfo.iDrive.iDriveAtt & KDriveAttSubsted) )
+                {
+                // not a suitable widget install drive
+                continue;
+                }
+
+            // found a usable drive
+            aDriveFlags |= (1 << driveNumber);
+          
+            }
+        }
+
+    return error;
+    }
--- a/widgets/widgetapp/inc/WidgetUiWindow.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/widgets/widgetapp/inc/WidgetUiWindow.h	Thu Sep 24 12:53:48 2009 +0300
@@ -125,7 +125,8 @@
                                  const TDesC& aMimeType);
 
        /**
-        * Called to show or hide softkeys
+        * Called to show or hide softkeys from menu client callback
+        *  -- sets a flag to reflect user preference 
         * @since 3.1
         * @param aVisible ETrue to show softkeys, EFalse when full screen is needed
         */
@@ -482,6 +483,25 @@
         */              
         void DetermineNetworkState();
         
+        
+        /**
+         * MakeSoftkeysVisible
+         * Called to show or hide softkeys 
+         * @since Browser 7.1
+         * @param aVisible ETrue to show softkeys, EFalse when full screen is needed
+         * @param aTextBoxUpdate ETrue when called due to textbox update (via updatestatuspane), else EFalse
+         */
+        void MakeSoftkeysVisible(TBool aVisible, TBool aTextBoxUpdate);
+        
+        /**
+         * NetworkModeWait
+         * returns pointer to NetworkMode wait object
+         * @since 7.1
+         * @return CActiveSchedulerWait*
+         */
+        CActiveSchedulerWait* NetworkModeWait() { return iNetworkModeWait; }
+
+        
     protected:
 
         /**
@@ -578,6 +598,7 @@
         TTime                           iOOMWidgetStartTime; 
         TBool                           iWidgetLoadStarted; // Set to true when widget load starts
         CJpgSaver*                       iJpgSaver; 
+        CActiveSchedulerWait*           iNetworkModeWait;
                             
    };
 
--- a/widgets/widgetapp/inc/WidgetUiWindowManager.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/widgets/widgetapp/inc/WidgetUiWindowManager.h	Thu Sep 24 12:53:48 2009 +0300
@@ -381,6 +381,24 @@
         * @return void
         */        
         void NotifyConnecionChange(TBool aConn);
+        TBrCtlDefs::TCursorSettings CursorShowMode() {return iWidgetCursorMode;}
+
+        /**
+        * AnyWidgetOnHs
+        * Checks to see if any widget is on HS
+        * @since 5.0
+        * @return TBool
+        */		
+		TBool AnyWidgetOnHs();
+		
+        /**
+        * AnyWidgetOnHs
+        * Checks to see if any widget is Publishing on HS
+        * @since 5.0
+        * @return TBool
+        */  		
+		TBool AnyWidgetPublishing();
+        
         
 #ifdef  OOM_WIDGET_CLOSEALL
         /**
@@ -547,6 +565,7 @@
         CInternetConnectionManager*         iConnection;        // owned, responsible for deleting
         TNetworkMode                        iNetworkMode;       // unknown mode =  0, online mode = 1, offline mode = 2
         TBool                               iNetworkConnected;  // ETrue if there is an active network connection, else EFalse
+        TBrCtlDefs::TCursorSettings                     iWidgetCursorMode;
 #ifdef BRDO_WRT_HS_FF       
         CCpsPublisher*                      iCpsPublisher;      // Owned, interface to publish bitmap to CPS
 #endif
--- a/widgets/widgetapp/inc/WidgetUiWindowView.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/widgets/widgetapp/inc/WidgetUiWindowView.h	Thu Sep 24 12:53:48 2009 +0300
@@ -217,7 +217,16 @@
         * @return void
         */
         void Redraw() const;
+        
+      private:
+          
+          /**
+          * IsEditMode check if over an editable element
+          * @return ETrue is over an editable element ; otherwise return EFalse
+          */        
+          TBool IsEditMode();
 
+          
       private :  // Data
 
         CWidgetUiWindowContainer*           iContainer;     // Component container owned
--- a/widgets/widgetapp/src/WidgetUiObserver.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/widgets/widgetapp/src/WidgetUiObserver.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -184,22 +184,6 @@
             }
         }
     
-    if (iWindow->WindowManager().ActiveWindow() && 
-            iWindow->WindowManager().View()->CbaGroup()->IsVisible())
-        {
-        TBrCtlDefs::TBrCtlElementType elementtype =
-                      iWindow->WindowManager().ActiveWindow()->Engine()->FocusedElementType();
-        // Check if focused element type is editing type
-        if ((elementtype == TBrCtlDefs::EElementActivatedInputBox) ||
-                       (elementtype == TBrCtlDefs::EElementActivatedObjectBox))
-            {
-            iWindow->WindowManager().View()->UpdateStatusPane( ETrue );
-            }
-        else 
-            {
-            iWindow->WindowManager().View()->UpdateStatusPane( EFalse );
-            }        
-        }
     }
 
 // -----------------------------------------------------------------------------
--- a/widgets/widgetapp/src/WidgetUiWindow.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/widgets/widgetapp/src/WidgetUiWindow.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -42,6 +42,7 @@
 #include <aknsdrawutils.h>
 #include "SWInstWidgetUid.h"
 
+
 // EXTERNAL DATA STRUCTURES
 
 // EXTERNAL FUNCTION PROTOTYPES
@@ -120,14 +121,32 @@
     iWidgetUiObserver = CWidgetUiObserver::NewL( *this );
 
     iWidgetUiDialogsProviderProxy = CWidgetUiDialogsProviderProxy::NewL(*(iWindowManager.DialogsProvider()), NULL, *this);
+    
+#ifdef BRDO_WRT_HS_FF
+    iNetworkModeWait = new(ELeave) CActiveSchedulerWait();
+#endif
 
+    unsigned int capabilities;
+    if (iWindowManager.CursorShowMode() == TBrCtlDefs::ENoCursor)
+        {
+        //no cursor
+        capabilities = TBrCtlDefs::ECapabilityLoadHttpFw |
+                         TBrCtlDefs::ECapabilityWebKitLite |
+                         TBrCtlDefs::ECapabilityClientResolveEmbeddedURL;
+        }
+    else
+        {
+        //cursor is setting
+        capabilities = TBrCtlDefs::ECapabilityLoadHttpFw |
+                        TBrCtlDefs::ECapabilityCursorNavigation|
+                        TBrCtlDefs::ECapabilityWebKitLite |
+                        TBrCtlDefs::ECapabilityClientResolveEmbeddedURL;
+
+        }
     iEngine = CreateBrowserControlL(
         view->Container(),
         rect,
-        TBrCtlDefs::ECapabilityLoadHttpFw |
-        TBrCtlDefs::ECapabilityCursorNavigation|
-        TBrCtlDefs::ECapabilityWebKitLite |
-        TBrCtlDefs::ECapabilityClientResolveEmbeddedURL,
+            capabilities,
         TBrCtlDefs::ECommandIdBase,
         iWidgetUiObserver, /* softkeys */
         iWidgetUiObserver, /* link resolver */
@@ -136,6 +155,8 @@
         iWidgetUiDialogsProviderProxy,
         iWidgetUiObserver, /* window observer */
         iWidgetUiObserver /* download observer */);
+    //Set the cursor mode inside Widget
+    iEngine->SetBrowserSettingL(TBrCtlDefs::ESettingsCursorShowMode, iWindowManager.CursorShowMode());
 
     iEngine->AddLoadEventObserverL( iWidgetUiObserver );
     iEngine->AddStateChangeObserverL( view );
@@ -199,6 +220,9 @@
     delete iWidgetUiDialogsProviderProxy;
     delete iSchemeHandler;
     delete iMiniviewBitmap;
+#ifdef BRDO_WRT_HS_FF
+    delete iNetworkModeWait;
+#endif
     }
 
 // -----------------------------------------------------------------------------
@@ -319,26 +343,8 @@
     {
     iShowSoftkeys = (aVisible);
 
-    if (CbaGroup())
-        {
-        CbaGroup()->MakeVisible( iShowSoftkeys );
-        iWindowManager.View()->UpdateStatusPane( aVisible );
-        //in case CBA keys are disbaled by javascript ,SetToolbarVisibility EFalse,
-        //Since it would take entire screen.Else SetToolbarVisibility to ETrue in Landscape mode
-        iShowSoftkeys?iWindowManager.View()->UpdateToolbar(ETrue):iWindowManager.View()->UpdateToolbar(EFalse);
-        CbaGroup()->DrawNow();
-        TRect clientRect = iWindowManager.View()->ClientRect();
-        // resize the container to take into account the size of the softkey labels
-        // reduction is only needed for portrait mode (softkey on bottom) since landscape
-        // mode softkeys don't take up screen real estate
-        if (AknLayoutUtils::CbaLocation() == AknLayoutUtils::EAknCbaLocationBottom)
-            {
-            CbaGroup()->ReduceRect(clientRect);
-            }
-        //Check if the container rect needs change and then call setRect
-        if(clientRect != iWindowManager.View()->Container()->Rect())
-           iWindowManager.View()->Container()->SetRect(clientRect);
-        }
+    MakeSoftkeysVisible(aVisible, EFalse);
+
     }
 
 // -----------------------------------------------------------------------------
@@ -523,10 +529,14 @@
             iWindowManager.View()->DeActivateOptionsMenu();
             Engine()->MakeVisible(EFalse);// hide the active widget
             }
-        if ( !aCurrent &&  (EPublishStart != WidgetMiniViewState()))
-            {
+        if ( !aCurrent &&  (EPublishStart != WidgetMiniViewState()) )
+            {			
             iWidgetExtension->HandleCommandL ( (TInt)TBrCtlDefs::ECommandAppBackground + (TInt)TBrCtlDefs::ECommandIdBase );
-            Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandAppBackground + (TInt)TBrCtlDefs::ECommandIdBase);
+            if( iWindowManager.AnyWidgetOnHs() )
+                {
+                //If there is no widget on HS then we should not stop the JS timers
+                Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandAppBackground + (TInt)TBrCtlDefs::ECommandIdBase);
+                }
             }
         if ( aCurrent )
             {
@@ -666,9 +676,13 @@
             {
             iCpsPublisher->NetworkConnectionAllowedL();
             }
+        iNetworkModeWait->Start();
 #endif
-        SetNetworkAccessGrant( EDeny );
-        User::Leave( KErrAccessDenied );
+        if (iWindowManager.GetNetworkMode() == EOfflineMode)
+            {
+            SetNetworkAccessGrant( EDeny );
+            User::Leave( KErrAccessDenied );
+            }
         }
     
     // begin info.plist (declare EAllowNetworkAccess or EAllowFullAccess ?)
@@ -1134,4 +1148,37 @@
         }
     }
 
+
+// -----------------------------------------------------------------------------
+// CWidgetUiWindow::MakeSoftkeysVisible()
+// -----------------------------------------------------------------------------
+//
+void CWidgetUiWindow::MakeSoftkeysVisible(TBool aVisible, TBool aTextBoxUpdate)
+    {
+    if (CbaGroup() && !(aTextBoxUpdate && iShowSoftkeys))
+        {
+        CbaGroup()->MakeVisible( aVisible );
+        //in case CBA keys are disbaled by javascript ,SetToolbarVisibility EFalse,
+        //Since it would take entire screen.Else SetToolbarVisibility to ETrue in Landscape mode
+        aVisible?iWindowManager.View()->UpdateToolbar(ETrue):iWindowManager.View()->UpdateToolbar(EFalse);
+        CbaGroup()->DrawNow();
+        TRect clientRect = iWindowManager.View()->ClientRect();
+        // resize the container to take into account the size of the softkey labels
+        // reduction is only needed for portrait mode (softkey on bottom) since landscape
+        // mode softkeys don't take up screen real estate
+        if (AknLayoutUtils::CbaLocation() == AknLayoutUtils::EAknCbaLocationBottom)
+            {
+            CbaGroup()->ReduceRect(clientRect);
+            }
+        //Check if the container rect needs change and then call setRect
+        if(clientRect != iWindowManager.View()->Container()->Rect())
+           iWindowManager.View()->Container()->SetRect(clientRect);
+        
+        if (!aTextBoxUpdate)
+            {
+            // status pane always off unless in text box
+            iWindowManager.View()->UpdateStatusPane(EFalse);
+            }
+        }
+    }
 // End of file
--- a/widgets/widgetapp/src/WidgetUiWindowContainer.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/widgets/widgetapp/src/WidgetUiWindowContainer.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -331,7 +331,8 @@
         // special case for readonly input box - if not activated then remove status pane and cba
         if( editing && aType == EEventKeyUp &&
             (Engine()->FocusedElementType() != TBrCtlDefs::EElementActivatedInputBox  &&
-             Engine()->FocusedElementType() != TBrCtlDefs::EElementActivatedObjectBox  ))
+             Engine()->FocusedElementType() != TBrCtlDefs::EElementActivatedObjectBox &&
+             Engine()->FocusedElementType() != TBrCtlDefs::EElementTextAreaBox))
             {
             iWindowManager.View()->UpdateStatusPane(EFalse);
             }
--- a/widgets/widgetapp/src/WidgetUiWindowManager.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/widgets/widgetapp/src/WidgetUiWindowManager.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -120,7 +120,8 @@
     iAppUi(aAppUi),
     iStrictMode(ETrue),
     iNetworkMode(EUnknownMode),
-    iNetworkConnected(EFalse)
+    iNetworkConnected(EFalse),
+    iWidgetCursorMode(TBrCtlDefs::EDefaultCursor)
     {
     }
 
@@ -144,10 +145,15 @@
     if (!error)
         {
         TInt strictMode;
+        TInt cursorMode = -1;
         if (cenRep->Get( KWidgetInstallerStrictMode, strictMode ) == KErrNone)
             {
             iStrictMode = strictMode;
             }
+        if (cenRep->Get( KWidgetCursorShowMode, cursorMode ) == KErrNone)
+            {
+            iWidgetCursorMode = (TBrCtlDefs::TCursorSettings) cursorMode;
+            }
         delete cenRep;
         }
         
@@ -328,22 +334,35 @@
         case WidgetOnline:
             {
             iNetworkMode = EOnlineMode;
-            GetWindow( aUid )->DetermineNetworkState();
+            CWidgetUiWindow* wdgt_window( GetWindow( aUid ) );
+#ifdef BRDO_WRT_HS_FF
+            if ( wdgt_window->NetworkModeWait()->IsStarted() )
+                {
+                wdgt_window->NetworkModeWait()->AsyncStop();
+                }
+#endif
+            wdgt_window->DetermineNetworkState();
             }
             break;
        case WidgetOffline:
             {
             iNetworkMode = EOfflineMode;
+            CWidgetUiWindow* wdgt_window( GetWindow( aUid ) );
+#ifdef BRDO_WRT_HS_FF
+            if ( wdgt_window->NetworkModeWait()->IsStarted() )
+                {
+                wdgt_window->NetworkModeWait()->AsyncStop();
+                }
+#endif
             // if no full view widgets open, then close the network connection
             if ( ( !FullViewWidgetsOpen() ) && ( iConnection->Connected() ) )
                 {
-                CWidgetUiWindow* wdgt_window( GetWindow( aUid ) );
                 wdgt_window->Engine()->HandleCommandL( 
                         (TInt)TBrCtlDefs::ECommandIdBase +
                         (TInt)TBrCtlDefs::ECommandDisconnect );
                 iConnection->StopConnectionL();
                 }
-            GetWindow( aUid )->DetermineNetworkState();
+            wdgt_window->DetermineNetworkState();
             }
             break;
        case WidgetRestart:
@@ -546,8 +565,9 @@
     if ( !lastOne )
         {
         // Starting JS timer, since we stopped it for deactivating miniview widget
+        //If there is a widget on HS then the timer will not be started
         CWidgetUiWindow* window = iWindowList[iWindowList.Count() - 1];
-        if ( window)
+        if ( window && AnyWidgetPublishing())
                TRAP_IGNORE ( window->Engine()->HandleCommandL( 
                               (TInt)TBrCtlDefs::ECommandAppForeground + 
                               (TInt)TBrCtlDefs::ECommandIdBase));
@@ -1271,7 +1291,29 @@
     {
     iAppUi.SendAppToBackground();    
     }
-    
+
+TBool CWidgetUiWindowManager::AnyWidgetOnHs()
+    {
+    for ( TInt i = 0; i < iWindowList.Count(); ++i )
+        {
+        CWidgetUiWindow* window( iWindowList[i] );
+        if( window->WidgetMiniViewState() != EMiniViewEnabled && window->WidgetMiniViewState() != EMiniViewNotEnabled )
+            return ETrue;
+        }
+    return EFalse;
+    }
+
+TBool CWidgetUiWindowManager::AnyWidgetPublishing()
+    {
+    for ( TInt i = 0; i < iWindowList.Count(); ++i )
+        {
+        CWidgetUiWindow* window( iWindowList[i] );
+        if( window->WidgetMiniViewState() == EPublishStart )
+            return ETrue;
+        }
+    return EFalse;
+    }
+
 CRequestRAM::CRequestRAM(CWidgetUiWindowManager* aWidgetUiWindowManager, const TUid& aUid, TUint32 aOperation):
     CActive( EPriorityStandard ),
     iOperation(aOperation),
--- a/widgets/widgetapp/src/WidgetUiWindowView.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/widgets/widgetapp/src/WidgetUiWindowView.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -187,11 +187,7 @@
 
     DeActivateOptionsMenu();
 
-    TBrCtlDefs::TBrCtlElementType elementtype =
-            iWindowManager.ActiveWindow()->Engine()->FocusedElementType();
-
-    TBool editing = (elementtype == TBrCtlDefs::EElementActivatedInputBox) ||
-                    (elementtype == TBrCtlDefs::EElementActivatedObjectBox);
+    TBool editing = IsEditMode();
 
     switch( aCommand )
         {
@@ -341,6 +337,13 @@
         StatusPane()->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT);
         StatusPane()->ApplyCurrentSettingsL();
         }
+    
+    // update softkeys display to match status pane visibility
+    if( iWindowManager.ActiveWindow() )
+        {
+        iWindowManager.ActiveWindow()->MakeSoftkeysVisible(visible,ETrue);
+        }
+  
     }
 
 // ---------------------------------------------------------
@@ -378,6 +381,14 @@
                 delete iRepository;
                 iRepository = NULL;
             }
+        case TBrCtlDefs::EStateFullscreenBrowsing:
+            {
+            if (!iPenEnabled && IsEditMode())
+                {
+                UpdateStatusPane(!aValue);
+                }
+            break;
+            }            
         default:
             break;
         }
@@ -415,4 +426,18 @@
         AppUi()->CurrentFixedToolbar()->SetToolbarVisibility(EFalse);
 #endif
     }
+
+// -----------------------------------------------------------------------------
+// CWidgetUiWindowView::IsEditMode
+// -----------------------------------------------------------------------------
+TBool CWidgetUiWindowView::IsEditMode()
+    {
+    TBrCtlDefs::TBrCtlElementType focusedElementType =
+                   iWindowManager.ActiveWindow()->Engine()->FocusedElementType();
+
+    TBool retVal = ((focusedElementType == TBrCtlDefs:: EElementActivatedInputBox) ||
+                    (focusedElementType == TBrCtlDefs:: EElementInputBox) ||
+                    (focusedElementType == TBrCtlDefs:: EElementTextAreaBox));
+    return  (retVal);
+    }
 // End of File
Binary file widgets/widgetinstaller/conf/widgetinstaller.confml has changed
Binary file widgets/widgetinstaller/conf/widgetinstaller_1028281F.crml has changed
--- a/widgets/widgetinstaller/inc/WidgetInstallerInternalCRKeys.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/widgets/widgetinstaller/inc/WidgetInstallerInternalCRKeys.h	Thu Sep 24 12:53:48 2009 +0300
@@ -37,4 +37,7 @@
 // Valid values: 0 = no prompt, 1 = prompt
 const TUint32 KWidgetSecurityPromptUntrustedInstall =   0x00000004;
 
+// The setting to define the cursor show mode inside widgets
+// Valid values: 0 = not showing the cursor, 1 = cursor shown
+const TUint32 KWidgetCursorShowMode =   0x00000005;
 #endif
--- a/widgets/widgetinstaller/inc/WidgetUIConfigHandler.h	Thu Aug 27 07:44:59 2009 +0300
+++ b/widgets/widgetinstaller/inc/WidgetUIConfigHandler.h	Thu Sep 24 12:53:48 2009 +0300
@@ -171,6 +171,7 @@
             EPropertyDescriptionWidth,                     // optional; integer; example: 100
             EPropertyDescriptionNokiaMiniViewEnable,       //optional; bool but int 0/1 internally
             EPropertyDescriptionNokiaPromptNeeded,       //optional; bool but int 0/1 internally
+            EPropertyDescriptionNokiaPreInstalled,         // optional; bool but int 0/1 internally
             // end property description list, begin special values
             EPropertyDescriptionIdCount,     // must be at end of properties
             EPropertyDescriptionIdInvalid    // must be after EPropertyDescriptionIdCount
--- a/widgets/widgetinstaller/src/WidgetUIConfigHandler.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/widgets/widgetinstaller/src/WidgetUIConfigHandler.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -64,6 +64,7 @@
 _LIT( KNokiaVersion,               "Version" );                 // optional
 _LIT( KNokiaMiniViewEnabled,       "MiniViewEnabled" );         // optional
 _LIT( KBlanketPermGranted,         "BlanketPermissionGranted" ); 
+_LIT( KPreInstalled,               "PreInstalled" );            // optional
 
 // Apple/Nokia shared key names
 _LIT( KMainHTML,                   "MainHTML" );                // required
@@ -217,6 +218,11 @@
     iProperties[EPropertyDescriptionNokiaPromptNeeded].name.Set( KBlanketPermGranted );
     iProperties[EPropertyDescriptionNokiaPromptNeeded].type = EWidgetPropTypeInt;
     iProperties[EPropertyDescriptionNokiaPromptNeeded].flags = CONFIG_NOKIA_MAY;
+    //
+    iProperties[EPropertyDescriptionNokiaPreInstalled].id = EPreInstalled;
+    iProperties[EPropertyDescriptionNokiaPreInstalled].name.Set( KPreInstalled );
+    iProperties[EPropertyDescriptionNokiaPreInstalled].type = EWidgetPropTypeBool;
+    iProperties[EPropertyDescriptionNokiaPreInstalled].flags = CONFIG_NOKIA_MAY;
     }
 
 // ============================================================================
--- a/widgets/widgetinstaller/src/WidgetUIOperationsWatcher.cpp	Thu Aug 27 07:44:59 2009 +0300
+++ b/widgets/widgetinstaller/src/WidgetUIOperationsWatcher.cpp	Thu Sep 24 12:53:48 2009 +0300
@@ -19,6 +19,7 @@
 *
 */
 
+// INCLUDE FILES
 #include <f32file.h>
 #include <SWInstDefs.h>
 #include <zipfile.h>
@@ -235,8 +236,11 @@
         // processing.  So here is a good place to put up the displays
         // (before RunL() is invoked) which lets other objects run.
 
-        iUIHandler->DisplayFinalizeDialogL(); // a dialog without a cancel option
-        iUIHandler->DisplayProgressDialogL(); // progress bar
+        if ( !iSilent )
+            {
+            iUIHandler->DisplayFinalizeDialogL(); // a dialog without a cancel option
+            iUIHandler->DisplayProgressDialogL(); // progress bar
+            }
 
         if ( replaceExisting )
             {
@@ -265,7 +269,9 @@
     else
         {
         userCancel = ETrue;
-        iUIHandler->DisplayCancelL();
+
+        if ( !iSilent ) { iUIHandler->DisplayCancelL(); }
+
         TRequestStatus* status = &aRequestStatus;
         User::RequestComplete( status, KErrNone );
         }
@@ -317,7 +323,7 @@
     TRAPD( error, InstallSubfunctionL( aFile, userCancel, aRequestStatus ) );
     if ( KErrNone != error )
         {
-        iUIHandler->DisplayErrorL( error );
+        if ( !iSilent ) { iUIHandler->DisplayErrorL( error ); }
         User::Leave( error );
         }
     else if ( userCancel )
@@ -447,12 +453,12 @@
             RApaLsSession apaLsSession;
             apaLsSession.Connect();
             TApaAppInfo info;
-                        
+
             User::LeaveIfError( apaLsSession.GetAppInfo( info, aUid ) );
             iWidgetName = info.iFullName;
             HBufC *widgetName = iWidgetName.AllocLC();
             HandleWidgetCommandL(apaLsSession, *widgetName, aUid, Deactivate);
-                        
+
             CleanupStack::PopAndDestroy( widgetName );
             apaLsSession.Close();
             }
@@ -630,10 +636,13 @@
                 CleanupStack::PopAndDestroy( 3 ); // file, buffer, stream
                 }
 
-            // more progress!!!
-            if ( member->UncompressedSize() )
+            if ( !iSilent )
                 {
-                iUIHandler->UpdateProgressDialogL( member->UncompressedSize() );
+                // more progress!!!
+                if ( member->UncompressedSize() )
+                    {
+                    iUIHandler->UpdateProgressDialogL( member->UncompressedSize() );
+                    }
                 }
 
             // if this is the icon file, then start icon processing
@@ -665,7 +674,7 @@
             }
         else // done with zip archive
             {
-            iUIHandler->CloseProgressDialogL();
+            if ( !iSilent ) { iUIHandler->CloseProgressDialogL(); }
             // and reveal finalize dialog underneath
 
             // finished unzip
@@ -685,9 +694,12 @@
         }
     else // user cancel (not DoCancel)
         {
-        iUIHandler->CloseProgressDialogL();
-        iUIHandler->CloseFinalizeDialogL();
-        iUIHandler->DisplayCancelL();
+        if ( !iSilent )
+            {
+            iUIHandler->CloseProgressDialogL();
+            iUIHandler->CloseFinalizeDialogL();
+            iUIHandler->DisplayCancelL();
+            }
 
         // stop icon conversion (if there is a converter)
         delete iIconConverter;
@@ -742,6 +754,7 @@
             {
             TUid uid = TUid::Uid( *(iPropertyValues[EUid]) );
             iRegistry.DeRegisterWidgetL( uid );
+            iAppManager->DeregisterWidgetL( uid );
             }
 
         // TODO if registration steps fail does it leave inconsistent state???
@@ -758,13 +771,11 @@
             {
             // delete backup
             (void)iFileMgr->RmDir( iBackupDir );
-            
-            // if widget was in home screen, add it back to home screen
             if ( iWidgetInHS )
                 {
                 RApaLsSession apaLsSession;
                 apaLsSession.Connect();
-       
+
                 HBufC* widgetName = iWidgetName.AllocLC();
                 HandleWidgetCommandL(apaLsSession, *widgetName, TUid::Uid( *(iPropertyValues[EUid]) ), WidgetRestart);
                 CleanupStack::PopAndDestroy( widgetName );
@@ -772,9 +783,11 @@
                 apaLsSession.Close();
                 }
             }
-
-        iUIHandler->CloseFinalizeDialogL();
-        iUIHandler->DisplayCompleteL();
+        if ( !iSilent )
+            {
+            iUIHandler->CloseFinalizeDialogL();
+            iUIHandler->DisplayCompleteL();
+            }
 
         HandleLogsL(*(iPropertyValues[EBundleDisplayName]), TUid::Uid( *(iPropertyValues[EUid]) ), *(iPropertyValues[ENokiaWidget]), SwiUI::ELogTaskActionInstall);
         }
@@ -844,9 +857,12 @@
 
     TRAP_IGNORE(
         {
-        iUIHandler->CloseProgressDialogL();
-        iUIHandler->CloseFinalizeDialogL();
-        iUIHandler->DisplayCancelL();
+        if ( !iSilent )
+            {
+            iUIHandler->CloseProgressDialogL();
+            iUIHandler->CloseFinalizeDialogL();
+            iUIHandler->DisplayCancelL();
+            }
 
         // stop icon conversion (if there is a converter)
         delete iIconConverter;
@@ -877,9 +893,12 @@
 
     TRAP_IGNORE(
         {
-        iUIHandler->CloseProgressDialogL();
-        iUIHandler->CloseFinalizeDialogL();
-        iUIHandler->DisplayErrorL( aError );
+        if ( !iSilent )
+            {
+            iUIHandler->CloseProgressDialogL();
+            iUIHandler->CloseFinalizeDialogL();
+            iUIHandler->DisplayErrorL( aError );
+            }
 
         // stop icon conversion (if there is a converter)
         delete iIconConverter;
@@ -933,7 +952,7 @@
 
     // save client status to use in finish uninstall
     iRequestStatus = &aRequestStatus;
-    
+
     TBuf<KWidgetRegistryVal> bundleName;
     iRegistry.GetWidgetBundleName( aUid, bundleName );
 
@@ -942,31 +961,37 @@
         FinishUninstallL( KErrCorrupt );
         return;
         }
-            
+
     TBool widgetinHomeScreen(EFalse);
-    widgetinHomeScreen = iRegistry.IsWidgetInMiniView( aUid ); 
+    widgetinHomeScreen = iRegistry.IsWidgetInMiniView( aUid );
+
+    TBool uninstall( ETrue );
+    if ( !iSilent )
+        {
+        uninstall = iUIHandler->DisplayUninstallL( bundleName,widgetinHomeScreen );
+        }
     // prompt user to uninstall
-    if( iUIHandler->DisplayUninstallL( bundleName,widgetinHomeScreen ) )
+    if( uninstall )
         {
         if(iRegistry.IsWidgetRunning( aUid ))
-        //Runnning widget should be first closed    
+        //Runnning widget should be first closed
             {
             RApaLsSession apaLsSession;
             apaLsSession.Connect();
             TApaAppInfo info;
-            
+
             User::LeaveIfError( apaLsSession.GetAppInfo( info, aUid ) );
-            HBufC* widgetName = info.iFullName.AllocLC();        
+            HBufC* widgetName = info.iFullName.AllocLC();
             HandleWidgetCommandL(apaLsSession,*widgetName,aUid,Deactivate);
-            
+
             CleanupStack::PopAndDestroy( widgetName );
-            apaLsSession.Close();            
+            apaLsSession.Close();
             }
-        iUIHandler->DisplayUninstallInProgressL();
+        if ( !iSilent ) { iUIHandler->DisplayUninstallInProgressL(); }
         TBuf<KWidgetRegistryVal> widgetPath;
         iRegistry.GetWidgetPath( aUid, widgetPath );
         TBool aVendor = *(iRegistry.GetWidgetPropertyValueL(aUid, ENokiaWidget));
-        
+
 
         // TODO if any of next steps leave does state become inconsistent?
 
@@ -976,11 +1001,11 @@
             {
             iFileMgr->RmDir( widgetPath );
             //Widget should delete any cookie it created
-            HBufC* fileName = HBufC::NewLC(KMaxFileName);            
+            HBufC* fileName = HBufC::NewLC(KMaxFileName);
             TPtr ptr(fileName->Des());
-            TBuf<8> buf1; 
+            TBuf<8> buf1;
             ptr = KCookieFile;
-            TInt pos = ptr.LocateReverse('.');            
+            TInt pos = ptr.LocateReverse('.');
             buf1.AppendNum(aUid.iUid,EHex);
             ptr.Insert(pos,_L("_"));
             ptr.Insert(pos+1,buf1);
@@ -999,7 +1024,7 @@
         }
     else
         {
-        iUIHandler->DisplayCancelL();
+        if ( !iSilent ) { iUIHandler->DisplayCancelL(); }
 
         // must return cancel because upper-levels will take uninstall
         // actions (remove widget from applications list) if we return KErrNone
@@ -1016,13 +1041,13 @@
 //
 void CWidgetUIOperationsWatcher::FinishUninstallL( TInt aErr )
     {
-    iUIHandler->CloseUninstallInProgressDialogL();
+    if ( !iSilent ) { iUIHandler->CloseUninstallInProgressDialogL(); }
     if ( aErr )
         {
-        iUIHandler->DisplayErrorL( aErr );
+        if ( !iSilent ) { iUIHandler->DisplayErrorL( aErr ); }
         User::Leave( aErr );
         }
-    iUIHandler->DisplayCompleteL();
+    if ( !iSilent ) { iUIHandler->DisplayCompleteL(); }
     User::RequestComplete( iRequestStatus, KErrNone );
     iRequestStatus = NULL;
     }
@@ -1164,22 +1189,32 @@
 //
 TBool CWidgetUIOperationsWatcher::PromptUserForInstallL( TBool aOverwrite )
     {
-    TBool userAnswer;
+    TBool userAnswer( ETrue );
 
-    if ( aOverwrite )
+    if ( !iSilent )
         {
-        userAnswer =
-            iUIHandler->DisplayOverwriteL( *(iPropertyValues[EBundleDisplayName]) );
+        if ( aOverwrite )
+            {
+            userAnswer =
+                iUIHandler->DisplayOverwriteL( *(iPropertyValues[EBundleDisplayName]) );
+            }
+        else
+            {
+            userAnswer =
+                iUIHandler->DisplayInstallL( *(iPropertyValues[EBundleDisplayName]) );
+            }
+        if ( userAnswer )
+            {
+            userAnswer = SelectMemoryL();
+            }
         }
     else
-        {
-        userAnswer =
-            iUIHandler->DisplayInstallL( *(iPropertyValues[EBundleDisplayName]) );
-        }
-    if ( userAnswer )
-        {
-        userAnswer = SelectMemoryL();
-        }
+            {
+            TDriveUnit selectedDrive(_L("C"));        // in real should be read from install options which are ignore too at the moment.
+            UpdateWidgetBasePathL( selectedDrive );
+            *(iPropertyValues[EDriveName]) = selectedDrive.Name();
+            }
+
     return userAnswer;
     }
 
@@ -1283,7 +1318,7 @@
     params.iUid = aUid;
     params.iAction = aAction;
     params.iVendor.Copy((aVender ? _L("Nokia") : _L("Non-Nokia")));
-    
+
     TTime time;
     time.UniversalTime();
     params.iTime = time;
@@ -1292,7 +1327,7 @@
     task->SetParameterL( pckg, 0 );
     iTaskManager->AddTaskL( task );
     iTaskManager->CommitL();
-    
+
     CleanupStack::Pop(task);
     }
 
@@ -1304,36 +1339,36 @@
 void CWidgetUIOperationsWatcher::HandleWidgetCommandL( RApaLsSession& aSession,const TDesC& aWidget,const TUid& aUid,TUint32 aOperation )
     {
     const TInt size( 2* aWidget.Length() + 3*sizeof( TUint32 ) );
-    
+
     // Message format is <filenameLength><unicode_filename><someintegervalue>
     CApaCommandLine* cmd( CApaCommandLine::NewLC() );
     HBufC8* opaque( HBufC8::NewLC( size ) );
-    
+
     RDesWriteStream stream;
     TPtr8 des( opaque->Des() );
-    
+
     stream.Open( des );
     CleanupClosePushL( stream );
-    
+
     // Generate the command.
     stream.WriteUint32L( aUid.iUid );
     stream.WriteUint32L( aWidget.Length() );
     stream.WriteL( reinterpret_cast< const TUint8* >( aWidget.Ptr() ),
                    aWidget.Size() );
-    
+
     stream.WriteInt32L( aOperation );
-    
+
     CleanupStack::PopAndDestroy( &stream );
-    
+
     // Generate command.
     cmd->SetCommandL( EApaCommandBackgroundAndWithoutViews );
-    cmd->SetOpaqueDataL( *opaque );    
+    cmd->SetOpaqueDataL( *opaque );
 
     CleanupStack::PopAndDestroy( opaque );
-    
+
     cmd->SetExecutableNameL( KLauncherApp );
-    
+
     User::LeaveIfError( aSession.StartApp( *cmd ) );
-    CleanupStack::PopAndDestroy( cmd );    
+    CleanupStack::PopAndDestroy( cmd );
     }
 //  End of File