widgets/widgetapp/src/WidgetUiAppUi.cpp
changeset 10 a359256acfc6
parent 1 7c90e6132015
child 15 60c5402cb945
equal deleted inserted replaced
5:10e98eab6f85 10:a359256acfc6
    30 #include <bautils.h>
    30 #include <bautils.h>
    31 #include <oommonitorplugin.h>
    31 #include <oommonitorplugin.h>
    32 #include <BrowserDialogsProvider.h>
    32 #include <BrowserDialogsProvider.h>
    33 #include <e32property.h>
    33 #include <e32property.h>
    34 
    34 
       
    35 #ifdef BRDO_WRT_HS_FF
       
    36 #include <AknToolbar.h>
       
    37 #endif
       
    38 
    35 // EXTERNAL DATA STRUCTURES
    39 // EXTERNAL DATA STRUCTURES
    36 
    40 
    37 // EXTERNAL FUNCTION PROTOTYPES
    41 // EXTERNAL FUNCTION PROTOTYPES
    38 
    42 
    39 // CONSTANTS
    43 // CONSTANTS
    48 
    52 
    49 // LOCAL FUNCTION PROTOTYPES
    53 // LOCAL FUNCTION PROTOTYPES
    50 
    54 
    51 // FORWARD DECLARATIONS
    55 // FORWARD DECLARATIONS
    52 
    56 
    53 // ============================= LOCAL FUNCTIONS ================================
    57 //LOCAL FUNCTION
    54 
    58 void NotifyCommandHandled()
    55 static void NotifyWidgetRunning()
       
    56     {
    59     {
    57     const TUid KMyPropertyCat = { 0x10282E5A };
    60     const TUid KMyPropertyCat = { 0x10282E5A };
    58     enum TMyPropertyKeys { EMyPropertyState = 109 };
    61     enum TMyPropertyKeys { EMyPropertyState = 109 };
    59     TInt state( 1 );
    62     TInt state( 2 );
    60     RProperty::Set( KMyPropertyCat, EMyPropertyState , state );
    63     RProperty::Set( KMyPropertyCat, EMyPropertyState , state );
    61     }
    64     }
    62 
    65 
    63 // ============================ MEMBER FUNCTIONS ================================
    66 // ============================ MEMBER FUNCTIONS ================================
    64 //
    67 //
   237     TUint32 operation( 0 );
   240     TUint32 operation( 0 );
   238     
   241     
   239     ProcessMessageArgumentsL( aMessage, uid, operation );
   242     ProcessMessageArgumentsL( aMessage, uid, operation );
   240         
   243         
   241     iWindowManager->HandleWidgetCommandL( uid, operation );
   244     iWindowManager->HandleWidgetCommandL( uid, operation );
   242     
   245 
   243     // Widget is up and running, notify that next one can be launched
       
   244     // TODO magic numbers from Launcher.
       
   245     if( operation == LaunchMiniview )
       
   246         {
       
   247         NotifyWidgetRunning();
       
   248         }
       
   249     }
   246     }
   250 
   247 
   251 // ------------------------------------------------------------------------------
   248 // ------------------------------------------------------------------------------
   252 // CWidgetUiAppUi::HandleMessageL
   249 // CWidgetUiAppUi::HandleMessageL
   253 // Called by WidgetLaucher
   250 // Called by WidgetLaucher
   375     CAknAppUi::HandleApplicationSpecificEventL(aEventType, aWsEvent);
   372     CAknAppUi::HandleApplicationSpecificEventL(aEventType, aWsEvent);
   376 
   373 
   377     if ( iWindowManager )
   374     if ( iWindowManager )
   378         {
   375         {
   379         if(aEventType == KAppOomMonitor_FreeRam )
   376         if(aEventType == KAppOomMonitor_FreeRam )
   380             {
   377             {            
       
   378 #ifdef OOM_WIDGET_CLOSEALL            
       
   379             CloseAllWidgetsAndExit();
       
   380 #else if    // OOM_WIDGET_CLOSEALL        
   381             iWindowManager->HandleOOMEventL(iIsForeground);
   381             iWindowManager->HandleOOMEventL(iIsForeground);
   382             }
   382             CloseAndExitIfNoneLeft();
   383         else if(aEventType == KAppOomMonitor_MemoryGood && iWindowManager->ActiveWindow())
   383 #endif            
   384             {
       
   385             iWindowManager->ActiveWindow()->Engine()->HandleCommandL( 
       
   386                                 (TInt)TBrCtlDefs::ECommandMemoryGood + (TInt)TBrCtlDefs::ECommandIdBase);
       
   387             }
   384             }
   388         }
   385         }
   389     }
   386     }
   390 
   387 
   391 
   388 
   484 // CWidgetUiAppUi::AsyncExit()
   481 // CWidgetUiAppUi::AsyncExit()
   485 // start an async exit
   482 // start an async exit
   486 //
   483 //
   487 // -----------------------------------------------------------------------------
   484 // -----------------------------------------------------------------------------
   488 //
   485 //
   489 void CWidgetUiAppUi::AsyncExit( TBool aAllWidgets )
   486 void CWidgetUiAppUi::AsyncExit( TBool /*aAllWidgets*/ )
   490     {
   487     {
   491     if (aAllWidgets && iWindowManager)
       
   492         {
       
   493         iWindowManager->CloseAllWindowsExceptCurrent();
       
   494         }
       
   495     iWidgetUiAsyncExit->Start(); // close current and exits app if no widgets left running
   488     iWidgetUiAsyncExit->Start(); // close current and exits app if no widgets left running
   496     }
   489     }
   497 
   490 
       
   491 // -----------------------------------------------------------------------------
       
   492 // CWidgetUiAppUi::CloseAndExitIfNoneLeft()
       
   493 //
       
   494 // -----------------------------------------------------------------------------
       
   495 //
       
   496 void CWidgetUiAppUi::CloseAndExitIfNoneLeft()
       
   497     {
       
   498     if(iWindowManager)
       
   499         {
       
   500         if(iWindowManager->CloseWindowWithLeastClick())  
       
   501             {
       
   502             //Exit Application
       
   503             NotifyCommandHandled();
       
   504             Exit();
       
   505             }            
       
   506         }
       
   507     }
   498 // -----------------------------------------------------------------------------
   508 // -----------------------------------------------------------------------------
   499 // CWidgetUiAppUi::HandleDelayedForegroundEventCallback()
   509 // CWidgetUiAppUi::HandleDelayedForegroundEventCallback()
   500 // CIdle callback function to handle delayed foreground events for WidgetUI
   510 // CIdle callback function to handle delayed foreground events for WidgetUI
   501 //
   511 //
   502 // -----------------------------------------------------------------------------
   512 // -----------------------------------------------------------------------------
   530     const TDesC8& aLine,
   540     const TDesC8& aLine,
   531     TUid& aUid,
   541     TUid& aUid,
   532     TUint32& aOperation )
   542     TUint32& aOperation )
   533     {
   543     {
   534     __UHEAP_MARK;
   544     __UHEAP_MARK;
   535     CWidgetPropertyValue* value( NULL );
       
   536     TUint32 version( -1 );
   545     TUint32 version( -1 );
   537     TPtrC ptr( NULL, 0 );
   546     TPtrC ptr( NULL, 0 );
   538     HBufC* tmp( NULL );
       
   539     
   547     
   540     RDesReadStream stream( aLine );
   548     RDesReadStream stream( aLine );
   541     CleanupClosePushL( stream );
   549     CleanupClosePushL( stream );
   542     
   550     
   543     version = stream.ReadUint32L();
   551     version = stream.ReadUint32L();
   585             {
   593             {
   586                 CAknViewAppUi::ProcessCommandL(aCommand);
   594                 CAknViewAppUi::ProcessCommandL(aCommand);
   587             }
   595             }
   588     }
   596     }
   589 
   597 
       
   598 #ifdef OOM_WIDGET_CLOSEALL
       
   599 // -----------------------------------------------------------------------------
       
   600 // CWidgetUiAppUi::CloseAllWidgetsAndExit()
       
   601 // Close all widgets and exit in case of OOM
       
   602 //
       
   603 // -----------------------------------------------------------------------------
       
   604 //
       
   605 void CWidgetUiAppUi::CloseAllWidgetsAndExit()
       
   606 {
       
   607     if(iWindowManager->CloseAllWidgetsUnderOOM())
       
   608         {
       
   609         //Exit Application
       
   610         NotifyCommandHandled();
       
   611         Exit();
       
   612         }
       
   613 }
       
   614 
       
   615 #endif
       
   616 
   590 // End of File
   617 // End of File