idlehomescreen/xmluicontroller/src/appui.cpp
branchRCL_3
changeset 9 f966699dea19
parent 0 f72a12da539e
child 15 ff572dfe6d86
--- a/idlehomescreen/xmluicontroller/src/appui.cpp	Tue Feb 02 00:04:13 2010 +0200
+++ b/idlehomescreen/xmluicontroller/src/appui.cpp	Fri Feb 19 22:42:37 2010 +0200
@@ -25,20 +25,21 @@
 #include <aknview.h>
 
 // User includes
+#include <hspublisherinfo.h>
+#include <aifwdefs.h>
 #include <activeidle2domaincrkeys.h>
 #include <aifweventhandler.h>
+#include <aifwstatehandler.h>
 #include <ai3xmlui.rsg>
 
 #include "appui.h"
 #include "application.h"
 #include "xmluicontroller.h"
 #include "aixuikoneventhandler.h"
-#include "aiuiframeworkobserver.h"
 #include "aixmluiconstants.h"
 #include "contentrenderer.h"
 #include "psobserver.h"
 
-#include "aipropertyextension.h"
 #include "aicontentmodel.h"
 #include "aiuiidleintegration.h"
 #include "xmluicontrollerpanic.h"
@@ -49,6 +50,11 @@
 #include "xnproperty.h"
 #include "xnuiengineappif.h"
 #include "onlineofflinehelper.h"
+#include "ainativeuiplugins.h"
+
+// Constants
+// EAiDeviceStatusContentNetworkIdentity content id
+_LIT( KNetworkIdentity, "NetworkIdentity" );
 
 using namespace AiXmlUiController;
 
@@ -72,29 +78,28 @@
     AI3_PERF_START(perfdata, "xmluicontroller: CAppUi::ConstructL")
         
     // Always reset the phoneforward P&S key on startup just in case
-    RProperty::Set(KPSUidAiInformation,
-                      KActiveIdleForwardNumericKeysToPhone,
-                      EPSAiForwardNumericKeysToPhone);
-
+    RProperty::Set( KPSUidAiInformation,
+      KActiveIdleForwardNumericKeysToPhone, EPSAiForwardNumericKeysToPhone );
+          
     // Initialize with empty title pane so it's not shown on startup.                  
     __HEAP("XML UI: Init - Construct App UI")
     __TIME("XML UI: XnAppUiAdapted::ConstructL",
         CXnAppUiAdapter::ConstructL();       
     ) 
-    
+        
     // Register for XML UI view activation & deactivation
     AddViewActivationObserverL( this );
     
     // Disable CCoeEnv exit checks.
     // Active Idle Framework will perform the checks.
-    iCoeEnv->DisableExitChecks(ETrue);
+    iCoeEnv->DisableExitChecks( ETrue );
     
     __TIME("XML UI: Construct Content Renderer",
         iContentRenderer = CContentRenderer::NewL( *this );
     )
     __HEAP("XML UI: Construct Content Renderer");
 
-    TXnUiEngineAppIf* uiEngine = UiEngineL();
+    TXnUiEngineAppIf* uiEngine( UiEngineL() );
     __ASSERT_ALWAYS( uiEngine, Panic(ECriticalPointerNull) );
     
     iUiCtl.SetObserver( *iContentRenderer );
@@ -104,29 +109,30 @@
     iUiCtl.SetAppUi( *this );
     
     iEventHandler = iUiCtl.CreateXuikonEventHandlerL( *iContentRenderer );
-
-    iUiFwObserver = iUiCtl.UiFrameworkObserver();
-
+    
     TAiIdleKeySoundConfig keySoundConfig;
     keySoundConfig.iKeySounds = KeySounds();
     keySoundConfig.iContextResId = R_XUI_DEFAULT_SKEY_LIST;
     
     iIdleIntegration = CAiUiIdleIntegration::NewL
         ( *iEikonEnv, keySoundConfig, iUiCtl.FwEventHandler() );
-                 
+                         
+    iUiCtl.NotifyAppEnvReadyL();
+        
+    CAknAppUiBase::SetKeyEventFlags( CAknAppUiBase::EDisableSendKeyShort |
+                                     CAknAppUiBase::EDisableSendKeyLong );
+
     iHelper = COnlineOfflineHelper::NewL( iUiCtl );
     
-    iUiCtl.NotifyAppEnvReadyL();
+    // Load device status plugin here because it is always needed    
+    iDeviceStatusInfo = THsPublisherInfo( KDeviceStatusPluginUid, 
+        KDeviceStatusPluginName, KNullDesC8 ); 
+                
+    iUiCtl.FwStateHandler()->LoadPlugin( 
+            iDeviceStatusInfo, EAiFwSystemStartup );        
     
-    LoadNativeDataPluginsL();
-
-    CAknAppUiBase::SetKeyEventFlags( CAknAppUiBase::EDisableSendKeyShort |
-                                     CAknAppUiBase::EDisableSendKeyLong );
+    __HEAP("XML UI: Done - Construct App UI");
     
-    iIsEditModeActive = EFalse;
-
-   
-    __HEAP("XML UI: Done - Construct App UI");
     AI3_PERF_STOP(perfdata, "xmluicontroller: CAppUi::ConstructL")
     }
 
@@ -161,26 +167,16 @@
 //
 void CAppUi::PrepareToExit()
     {
+    iUiShutdown = ETrue;
+
+    RemoveViewActivationObserver( this );
+    
     iUiCtl.FwEventHandler()->HandleUiShutdown( iUiCtl );
     
     CXnAppUiAdapter::PrepareToExit();
     }
 
 // ----------------------------------------------------------------------------
-// CAppUi::HandleForegroundEventL()
-// ----------------------------------------------------------------------------
-//
-void CAppUi::HandleForegroundEventL( TBool aForeground )
-    {
-    CXnAppUiAdapter::HandleForegroundEventL( aForeground );
-    
-    if( iUiFwObserver )
-        {
-        iUiFwObserver->HandleForegroundEvent( aForeground );
-        }
-    }
-
-// ----------------------------------------------------------------------------
 // CAppUi::HandleCommandL()
 // ----------------------------------------------------------------------------
 //
@@ -210,20 +206,6 @@
     }
 
 // ----------------------------------------------------------------------------
-// CAppUi::HandleResourceChangeL()
-// ----------------------------------------------------------------------------
-//
-void CAppUi::HandleResourceChangeL( TInt aType )
-    {
-    CXnAppUiAdapter::HandleResourceChangeL( aType );
-    
-    if( iUiFwObserver )
-        {
-        iUiFwObserver->HandleResourceChange( aType );
-        }
-    }
-
-// ----------------------------------------------------------------------------
 // CAppUi::HandleWsEventL()
 // ----------------------------------------------------------------------------
 //
@@ -279,92 +261,70 @@
 	    {
 	__TIME("UC: Event Management",
     	iEventHandler->HandleXuikonEventL( aOrigin, 
-                                           aTrigger, 
-                                           aTriggerDefinition, 
-                                           aEvent );
-	);
+           aTrigger, aTriggerDefinition, aEvent ) );	
 	    }
 	__PRINTS("*** UI: Done - Event Management");
     }
+
+// ----------------------------------------------------------------------------
+// CAppUi::HandleEventL()
+// ----------------------------------------------------------------------------
+//
+void CAppUi::HandleEventL( const TDesC& aEvent, CXnNodeAppIf& aDestination )
+    {
+    THsPublisherInfo info;
     
+    iUiCtl.PublisherInfoL( aDestination, info );
+    
+    iUiCtl.FwEventHandler()->HandlePluginEventL( info, aEvent );
+    }
+
 // ----------------------------------------------------------------------------
 // CAppUi::LoadDataPluginsL()
 // ----------------------------------------------------------------------------
 //
-void CAppUi::LoadDataPluginsL( RPointerArray< CXnNodeAppIf >& aList )
+TInt CAppUi::LoadPublisher( CXnNodeAppIf& aPublisher, TInt aReason )
     {
-    for( TInt i = 0; i < aList.Count(); i++ )
+    if ( iUiShutdown )
         {
-        TAiPublisherInfo info;
-        
-        iUiCtl.PublisherInfoL( *aList[i], info );
-                
-        iUiCtl.FwEventHandler()->HandleLoadPluginL( info );
+        // Framework has already destroyed all publishers
+        return KErrNone;
         }
-    }
+    
+    THsPublisherInfo info;
+    
+    TRAP_IGNORE( iUiCtl.PublisherInfoL( aPublisher, info ) );
 
-// ----------------------------------------------------------------------------
-// CAppUi::LoadNativeDataPluginsL()
-// ----------------------------------------------------------------------------
-//
-void CAppUi::LoadNativeDataPluginsL()
-    {
-    if ( !iNativePluginsLoaded )
+    if ( info.Uid() == KDeviceStatusPluginUid )
         {
-        RAiPublisherInfoArray plugins;
-        CleanupClosePushL( plugins );
-        
-        iUiCtl.PublisherInfoL( plugins );
-        
-        for ( TInt i = 0; i < plugins.Count(); i++ )
-            {
-            iUiCtl.FwEventHandler()->HandleLoadPluginL( plugins[i] );
-            }
-        
-        CleanupStack::PopAndDestroy( &plugins );
-        
-        iNativePluginsLoaded = ETrue;
-        }              
+        // Update device status info
+        iDeviceStatusInfo = info;
+        }
+    
+    return iUiCtl.FwStateHandler()->LoadPlugin( 
+        info, (TAiFwLoadReason) aReason );        
     }
 
 // ----------------------------------------------------------------------------
-// CAppUi::DestroyDataPluginsL()
-// ----------------------------------------------------------------------------
-//
-void CAppUi::DestroyDataPluginsL( RPointerArray< CXnNodeAppIf >& aList )
-    {
-    for( TInt i = 0; i < aList.Count(); i++ )
-        {
-        TAiPublisherInfo info;
-        
-        iUiCtl.PublisherInfoL( *aList[i], info );
-                
-        iUiCtl.FwEventHandler()->HandleDestroyPluginL( info );
-        }    
-    }
-
-// ----------------------------------------------------------------------------
-// CAppUi::DestroyNativeDataPluginsL()
+// CAppUi::DestroyPublisher()
 // ----------------------------------------------------------------------------
 //
-void CAppUi::DestroyNativeDataPluginsL()
+TInt CAppUi::DestroyPublisher( CXnNodeAppIf& aPublisher, TInt aReason )
     {
-    if ( iNativePluginsLoaded )
-        {                
-        RAiPublisherInfoArray plugins;
-        CleanupClosePushL( plugins );
-        
-        iUiCtl.PublisherInfoL( plugins );
-        
-        for ( TInt i = 0; i < plugins.Count(); i++ )
-            {
-            iUiCtl.FwEventHandler()->HandleDestroyPluginL( plugins[i] );
-            }
-        
-        CleanupStack::PopAndDestroy( &plugins );
-        
-        iNativePluginsLoaded = EFalse;
+    if ( iUiShutdown )
+        {
+        // Framework has already destroyed all publishers
+        return KErrNone;
         }
+    
+    THsPublisherInfo info;
+           
+    TRAP_IGNORE( iUiCtl.PublisherInfoL( aPublisher, info ) );
+            
+    iUiCtl.FwStateHandler()->DestroyPlugin( 
+        info, (TAiFwDestroyReason) aReason );
+    
+    return KErrNone;
     }
 
 // ----------------------------------------------------------------------------
@@ -374,6 +334,12 @@
 TBool CAppUi::DynInitMenuItemL( const TDesC& aItemType, 
     RPointerArray< CXnNodeAppIf >* aList )
     {
+    if ( iUiShutdown )
+        {
+        // Framework has already destroyed all publishers
+        return EFalse;
+        }
+    
     _LIT( KOnline, "hs_online" );
     _LIT( KOffline, "hs_offline" );
     
@@ -393,7 +359,7 @@
         
         for( TInt i = 0; !retval && i < list.Count(); i++ )
             {
-            TAiPublisherInfo info;
+            THsPublisherInfo info;
                            
             iUiCtl.PublisherInfoL( *list[i], info );
                                    
@@ -406,48 +372,14 @@
 
 // ----------------------------------------------------------------------------
 // CAppUi::SetOnlineStateL()
-// Called always by view manager when view is activated.
-// ----------------------------------------------------------------------------
-//
-void CAppUi::SetOnlineStateL( RPointerArray< CXnNodeAppIf >& aList )
-    {
-    iHelper->ProcessOnlineStateL( aList );
-    }
-
-// ----------------------------------------------------------------------------
-// CAppUi::SetOnlineL()
 // Called always when user changed HS online/offline status from option menu.
 // ----------------------------------------------------------------------------
 //
 void CAppUi::SetOnlineStateL( TBool aOnline )
     {
-    iHelper->ProcessOnlineStateL( aOnline );
-    }
-
-// ----------------------------------------------------------------------------
-// CAppUi::HandleViewActivation()
-// ----------------------------------------------------------------------------
-//
-void CAppUi::HandleViewActivation( const TVwsViewId& aNewlyActivatedViewId, 
-    const TVwsViewId& aViewIdToBeDeactivated )
-    {
-    if ( iIsEditModeActive )
+    if ( !iUiShutdown )
         {
-        return;
-        }
-    
-    // Get Xml Ui view id       
-    TVwsViewId viewId( View().ViewId() );
-    
-    if ( viewId == aNewlyActivatedViewId )
-        {        
-        // Xml Ui view became active
-        TRAP_IGNORE( LoadNativeDataPluginsL() );
-        }
-    else if ( viewId == aViewIdToBeDeactivated )
-        {
-        // Xml Ui view became inactive 
-        TRAP_IGNORE( DestroyNativeDataPluginsL() );
+        iHelper->ProcessOnlineStateL( aOnline );    
         }
     }
 
@@ -461,12 +393,12 @@
     }
 
 // ----------------------------------------------------------------------------
-// CAppUi::HandlePageSwitch()
+// CAppUi::Helper()
 // ----------------------------------------------------------------------------
 //
-void CAppUi::HandlePageSwitch()
+COnlineOfflineHelper* CAppUi::Helper() const
     {
-    iUiCtl.FwEventHandler()->ProcessStateChange( EAifwPageSwitch );
+    return iHelper;
     }
 
 // ----------------------------------------------------------------------------
@@ -475,16 +407,54 @@
 //
 void CAppUi::HandleEnterEditModeL( TBool aEnter )
     {
-    if ( aEnter )
+    if ( iInEditMode != aEnter )
         {
-        DestroyNativeDataPluginsL();
-        iIsEditModeActive = ETrue;
-        }
-    else
-        {
-        LoadNativeDataPluginsL();
-        iIsEditModeActive = EFalse;
-        }
+        if ( aEnter )
+            {            
+            iUiCtl.FwEventHandler()->SuspendContent( 
+                iDeviceStatusInfo, KNetworkIdentity );
+            }
+        else
+            {
+            iUiCtl.FwEventHandler()->RefreshContent( 
+                iDeviceStatusInfo, KNetworkIdentity );            
+            }
+        
+        iInEditMode = aEnter;
+        }    
     }
 
+// ----------------------------------------------------------------------------
+// CAppUi::HandleViewActivation()
+// ----------------------------------------------------------------------------
+//
+void CAppUi::HandleViewActivation( const TVwsViewId& aNewlyActivatedViewId, 
+    const TVwsViewId& aViewIdToBeDeactivated )
+    {
+    TVwsViewId activeViewId;
+    
+    TInt err( GetActiveViewId( activeViewId ) );
+    
+    if ( iInEditMode || err == KErrNotFound )
+        {
+        return;
+        }
+    
+    // Get Xml Ui view id       
+    TVwsViewId xmlViewId( View().ViewId() );
+                     
+    if ( xmlViewId == aNewlyActivatedViewId && activeViewId != xmlViewId )
+          {        
+          // Xml Ui view became active         
+          iUiCtl.FwEventHandler()->RefreshContent( 
+              iDeviceStatusInfo, KNetworkIdentity );                                
+          }    
+    else if ( xmlViewId == aViewIdToBeDeactivated && activeViewId == xmlViewId )
+          {
+          // Xml Ui view became inactive
+          iUiCtl.FwEventHandler()->SuspendContent( 
+              iDeviceStatusInfo, KNetworkIdentity );          
+          }
+      }    
+
 // End of File.