--- a/browserui/browser/BrowserAppSrc/BrowserAppEntryPoint.cpp Thu Jul 15 18:42:04 2010 +0300
+++ b/browserui/browser/BrowserAppSrc/BrowserAppEntryPoint.cpp Thu Aug 19 09:57:56 2010 +0300
@@ -16,7 +16,7 @@
*
*
*/
-
+
#include "BrowserApplication.h"
#include <e32std.h>
@@ -24,13 +24,23 @@
#include <eikapp.h>
#include <eikstart.h>
#include <MemoryManager.h>
-#include <OOMMonitorSession.h>
+#include <avkon.rsg>
+#include <BrowserNG.rsg>
+#include <bautils.h>
+#include <f32file.h>
+#include <data_caging_path_literals.hrh>
+#include <hal.h>
+#include <barsc.h>
+
+_LIT(KBrowserResourceFile, "BrowserNG.rsc");
+
const int KFreeMemoryTarget = 6000000;
+
LOCAL_C CApaApplication* NewApplication( )
{
- return new CBrowserApplication;
+ return new CBrowserApplication;
}
// -----------------------------------------------------------------------------
@@ -63,24 +73,110 @@
return r;
}
+
+// ---------------------------------------------------------------------------
+// GetUiUtilitiesResourceFilenameL
+// ---------------------------------------------------------------------------
+//
+TInt GetCorrectResourceFilenameL(TFileName& aResourceFileName)
+ {
+
+ TParse parse;
+ parse.Set(KBrowserResourceFile, &KDC_APP_RESOURCE_DIR, NULL);
+ aResourceFileName.Copy(parse.FullName());
+
+ RFs fs;
+ User::LeaveIfError(fs.Connect());
+ CleanupClosePushL( fs );
+
+ // Resource File Name on C:
+ aResourceFileName.Insert( 0, TDriveUnit( EDriveC).Name() );
+ // try to locate the localised resource
+ BaflUtils::NearestLanguageFile( fs, aResourceFileName );
+
+ // if the localised resource is found, the file name is changed to the localised name (z:\resources\webkit.r001)
+ if( !BaflUtils::FileExists( fs, aResourceFileName ) ) {
+
+ aResourceFileName.Replace( 0, KMaxDriveName, TDriveUnit( EDriveZ ).Name() );
+ // not found on c drive, try z try to locate the localised resource again
+ BaflUtils::NearestLanguageFile( fs, aResourceFileName );
+
+ // if file was not found this time, there is no localised resource with the name
+ if (!BaflUtils::FileExists( fs, aResourceFileName ) ) {
+ User::Leave(KErrNotFound);
+ }
+ }
+ CleanupStack::PopAndDestroy( &fs );
+ return KErrNone;
+ }
+
+void ShowOOMDialogWithNotifierL()
+ {
+
+ TFileName resourceFileName;
+ User::LeaveIfError(GetCorrectResourceFilenameL(resourceFileName));
+
+ RFs fsSession;
+ User::LeaveIfError(fsSession.Connect());
+ CleanupClosePushL(fsSession);
+
+ RResourceFile resFile;
+ resFile.OpenL(fsSession,resourceFileName );
+ resFile.ConfirmSignatureL(0);
+
+ HBufC8* dataOkButtonBuffer = resFile.AllocReadLC(R_QTN_OK_BUTTON);
+ HBufC8* dataOOMMessageBuffer = resFile.AllocReadLC(R_QTN_BROWSER_DIALOG_OOM);
+
+ TPtrC16 OkButtonBuffer( ( TUint16* ) dataOkButtonBuffer->Ptr(),dataOkButtonBuffer->Length() / 2 );
+ TPtrC16 OOMMessageBuffer( ( TUint16* ) dataOOMMessageBuffer->Ptr(),dataOOMMessageBuffer->Length() / 2 );
+
+ _LIT(KTxtEmptyLine," ");
+ _LIT(KTxtEmptyButton,"");
+
+ RNotifier notifier;
+ TInt err = notifier.Connect();
+ if(err == KErrNone) {
+ TInt whichbutton(-1);
+ TRequestStatus stat;
+ notifier.Notify(OOMMessageBuffer,KTxtEmptyLine,OkButtonBuffer,KTxtEmptyButton,whichbutton,stat);
+ User::WaitForRequest(stat);
+ }
+
+ notifier.Close();
+
+ //this will clear OkButtonBuffer and OOMMessageBuffer
+ CleanupStack::PopAndDestroy(2);
+ resFile.Close();
+ CleanupStack::PopAndDestroy(&fsSession);
+
+ }
+
// -----------------------------------------------------------------------------
// E32Main
// -----------------------------------------------------------------------------
GLDEF_C TInt E32Main()
- {
- ROomMonitorSession oomMs;
- TInt result = oomMs.Connect();
- if ( result == KErrNone )
- {
- result = oomMs.RequestFreeMemory( KFreeMemoryTarget );
- oomMs.Close();
+ {
+ //Initilize memory manager...
+ MemoryManager::InitFastAllocator();
+
+ TInt freeRAM = 0;
+ TInt r = HAL::Get(HAL::EMemoryRAMFree, freeRAM);
+
+ if ((r != KErrNone) || freeRAM < KFreeMemoryTarget)
+ {
+ // create clean-up stack as none is created
+ CTrapCleanup* cleanup=CTrapCleanup::New();
+
+ // Show OOM message through RNotifier ...
+ TRAP_IGNORE(ShowOOMDialogWithNotifierL());
+
+ // destroy clean-up stack
+ delete cleanup;
+ return KErrNoMemory;
}
-
- // initialize MemmoryManager
- MemoryManager::InitFastAllocator();
- // run application event loop
- return EikStart::RunApplication(NewApplication);
+ // Run application event loop
+ return EikStart::RunApplication(NewApplication);
}
// End of File