widgets/widgetapp/src/WidgetUiAppUi.cpp
changeset 16 a359256acfc6
parent 8 7c90e6132015
child 27 60c5402cb945
--- a/widgets/widgetapp/src/WidgetUiAppUi.cpp	Fri Jul 03 15:54:40 2009 +0100
+++ b/widgets/widgetapp/src/WidgetUiAppUi.cpp	Thu Aug 27 07:44:59 2009 +0300
@@ -32,6 +32,10 @@
 #include <BrowserDialogsProvider.h>
 #include <e32property.h>
 
+#ifdef BRDO_WRT_HS_FF
+#include <AknToolbar.h>
+#endif
+
 // EXTERNAL DATA STRUCTURES
 
 // EXTERNAL FUNCTION PROTOTYPES
@@ -50,13 +54,12 @@
 
 // FORWARD DECLARATIONS
 
-// ============================= LOCAL FUNCTIONS ================================
-
-static void NotifyWidgetRunning()
+//LOCAL FUNCTION
+void NotifyCommandHandled()
     {
     const TUid KMyPropertyCat = { 0x10282E5A };
     enum TMyPropertyKeys { EMyPropertyState = 109 };
-    TInt state( 1 );
+    TInt state( 2 );
     RProperty::Set( KMyPropertyCat, EMyPropertyState , state );
     }
 
@@ -239,13 +242,7 @@
     ProcessMessageArgumentsL( aMessage, uid, operation );
         
     iWindowManager->HandleWidgetCommandL( uid, operation );
-    
-    // Widget is up and running, notify that next one can be launched
-    // TODO magic numbers from Launcher.
-    if( operation == LaunchMiniview )
-        {
-        NotifyWidgetRunning();
-        }
+
     }
 
 // ------------------------------------------------------------------------------
@@ -377,13 +374,13 @@
     if ( iWindowManager )
         {
         if(aEventType == KAppOomMonitor_FreeRam )
-            {
+            {            
+#ifdef OOM_WIDGET_CLOSEALL            
+            CloseAllWidgetsAndExit();
+#else if    // OOM_WIDGET_CLOSEALL        
             iWindowManager->HandleOOMEventL(iIsForeground);
-            }
-        else if(aEventType == KAppOomMonitor_MemoryGood && iWindowManager->ActiveWindow())
-            {
-            iWindowManager->ActiveWindow()->Engine()->HandleCommandL( 
-                                (TInt)TBrCtlDefs::ECommandMemoryGood + (TInt)TBrCtlDefs::ECommandIdBase);
+            CloseAndExitIfNoneLeft();
+#endif            
             }
         }
     }
@@ -486,16 +483,29 @@
 //
 // -----------------------------------------------------------------------------
 //
-void CWidgetUiAppUi::AsyncExit( TBool aAllWidgets )
+void CWidgetUiAppUi::AsyncExit( TBool /*aAllWidgets*/ )
     {
-    if (aAllWidgets && iWindowManager)
-        {
-        iWindowManager->CloseAllWindowsExceptCurrent();
-        }
     iWidgetUiAsyncExit->Start(); // close current and exits app if no widgets left running
     }
 
 // -----------------------------------------------------------------------------
+// CWidgetUiAppUi::CloseAndExitIfNoneLeft()
+//
+// -----------------------------------------------------------------------------
+//
+void CWidgetUiAppUi::CloseAndExitIfNoneLeft()
+    {
+    if(iWindowManager)
+        {
+        if(iWindowManager->CloseWindowWithLeastClick())  
+            {
+            //Exit Application
+            NotifyCommandHandled();
+            Exit();
+            }            
+        }
+    }
+// -----------------------------------------------------------------------------
 // CWidgetUiAppUi::HandleDelayedForegroundEventCallback()
 // CIdle callback function to handle delayed foreground events for WidgetUI
 //
@@ -532,10 +542,8 @@
     TUint32& aOperation )
     {
     __UHEAP_MARK;
-    CWidgetPropertyValue* value( NULL );
     TUint32 version( -1 );
     TPtrC ptr( NULL, 0 );
-    HBufC* tmp( NULL );
     
     RDesReadStream stream( aLine );
     CleanupClosePushL( stream );
@@ -587,4 +595,23 @@
             }
     }
 
+#ifdef OOM_WIDGET_CLOSEALL
+// -----------------------------------------------------------------------------
+// CWidgetUiAppUi::CloseAllWidgetsAndExit()
+// Close all widgets and exit in case of OOM
+//
+// -----------------------------------------------------------------------------
+//
+void CWidgetUiAppUi::CloseAllWidgetsAndExit()
+{
+    if(iWindowManager->CloseAllWidgetsUnderOOM())
+        {
+        //Exit Application
+        NotifyCommandHandled();
+        Exit();
+        }
+}
+
+#endif
+
 // End of File