contextframework/cfwplugins/ApplicationStateSourcePlugIn/inc/ApplicationStateSourcePlugin.h
changeset 21 c4cbaa4fb734
parent 0 2e3d3ce01487
child 13 096dad6e50a9
--- a/contextframework/cfwplugins/ApplicationStateSourcePlugIn/inc/ApplicationStateSourcePlugin.h	Tue Feb 02 10:12:00 2010 +0200
+++ b/contextframework/cfwplugins/ApplicationStateSourcePlugIn/inc/ApplicationStateSourcePlugin.h	Fri Apr 16 15:08:06 2010 +0300
@@ -29,14 +29,30 @@
 #include <cfcontextsourceplugin.h>
 #include <cfcontextobject.h>
 #include <cenrepnotifyhandler.h>
-
+#include <w32std.h>
+#include <apgwgnam.h>
 #include "cfapplicationstatesettings.h"
 #include "uidorientationpair.h"
 
 // FORWARD DECLARATIONS
 class CRepository;
 class CCenRepNotifyHandler;
+// FORWARD DECLARATIONS
+class CWsEventHandler;
 
+NONSHARABLE_CLASS( MWsEventObserver )
+    {
+public:
+
+    /**
+     * Handles window server event.
+     * 
+     * @since S60 5.0
+     * @param aEvent New window server event.
+     * @return None.
+     */
+    virtual void HandleWsEventL( RWsSession& aWsSession ) = 0;    
+    };
 // CLASS DECLARATION
 
 /**
@@ -50,7 +66,7 @@
  */
 NONSHARABLE_CLASS( CApplicationStateSourcePlugIn ): 
 	public CCFContextSourcePlugIn,
-	public MVwsSessionWrapperObserver,
+	public MWsEventObserver,
 	public MCenRepNotifyHandlerCallback
     {
 public: // Constructors and destructor
@@ -75,10 +91,7 @@
     // @see CCFContextSourcePlugIn
     void InitializeL();
 
-public: // From MVwsSessionWrapperObserver
 
-    // @see MVwsSessionWrapperObserver
-    void HandleViewEventL( const TVwsViewEvent& aEvent );
 
 public: // From MCenRepNotifyHandlerCallback
 
@@ -110,7 +123,7 @@
     
     // Initialize the fg application context
     void InitializeFgApplicationL();
-    
+    void HandleWsEventL( RWsSession& aWsSession );
     // Handles the view server event
     void DoHandleViewEventL( const TVwsViewEvent& aEvent );
     
@@ -148,6 +161,7 @@
 
     // Foreground application setting list
     RApplicationStateSettingsPointerArray iApplicationSettings;
+    CWsEventHandler* iWsEventHandler;
     
     // Previous foreground application orientation
     TPtrC iPreviousOrientation;
@@ -164,5 +178,67 @@
     // KCRUidDefaultAppOrientation listener
     CCenRepNotifyHandler* iCRAppOrientationListener;
     };
+/**
+ * Listens events from window server and forwards them to observer.
+ */
+NONSHARABLE_CLASS( CWsEventHandler ): public CActive
+    {
+public:
 
+    /**
+     * Symbian two phased constructors.
+     *
+     * @since S60 5.0
+     * @param None.
+     * @return CDisplayServiceUILayout
+     */
+    static CWsEventHandler* NewL( MWsEventObserver& aObserver );
+    static CWsEventHandler* NewLC( MWsEventObserver& aObserver );
+
+    /**
+     * C++ destructor.
+     */
+    virtual ~CWsEventHandler();
+    
+public:
+    
+    /**
+     * Start event listening.
+     * 
+     * @since S60 5.0
+     * @param None.
+     * @return None.
+     */
+    void IssueRequest();
+    
+protected:
+    
+    // @see CActive
+    virtual void RunL();
+    
+    // @see CActive
+    virtual void DoCancel(); 
+    
+    // @see CActive
+    virtual TInt RunError( TInt aError ); 
+    
+private:
+
+    CWsEventHandler( MWsEventObserver& aObserver );
+    void ConstructL();
+
+private: // Data
+    
+    /** Observer */
+    MWsEventObserver& iObserver;
+
+    /** Window server session */
+    RWsSession iWsSession;
+    
+    /** Window group for receiving window server events */
+    RWindowGroup* iWindowGroup;
+    
+    /** Window group name to hide it from the task manager */
+    CApaWindowGroupName* iWindowGroupName;
+    };
 #endif // C_APPLICATIONSTATESOURCEPLUGIN_H