contextframework/cfwplugins/ApplicationStateSourcePlugIn/inc/ApplicationStateSourcePlugin.h
changeset 21 c4cbaa4fb734
parent 0 2e3d3ce01487
child 13 096dad6e50a9
equal deleted inserted replaced
0:2e3d3ce01487 21:c4cbaa4fb734
    27 #include <viewclipartner.h>
    27 #include <viewclipartner.h>
    28 #endif
    28 #endif
    29 #include <cfcontextsourceplugin.h>
    29 #include <cfcontextsourceplugin.h>
    30 #include <cfcontextobject.h>
    30 #include <cfcontextobject.h>
    31 #include <cenrepnotifyhandler.h>
    31 #include <cenrepnotifyhandler.h>
    32 
    32 #include <w32std.h>
       
    33 #include <apgwgnam.h>
    33 #include "cfapplicationstatesettings.h"
    34 #include "cfapplicationstatesettings.h"
    34 #include "uidorientationpair.h"
    35 #include "uidorientationpair.h"
    35 
    36 
    36 // FORWARD DECLARATIONS
    37 // FORWARD DECLARATIONS
    37 class CRepository;
    38 class CRepository;
    38 class CCenRepNotifyHandler;
    39 class CCenRepNotifyHandler;
    39 
    40 // FORWARD DECLARATIONS
       
    41 class CWsEventHandler;
       
    42 
       
    43 NONSHARABLE_CLASS( MWsEventObserver )
       
    44     {
       
    45 public:
       
    46 
       
    47     /**
       
    48      * Handles window server event.
       
    49      * 
       
    50      * @since S60 5.0
       
    51      * @param aEvent New window server event.
       
    52      * @return None.
       
    53      */
       
    54     virtual void HandleWsEventL( RWsSession& aWsSession ) = 0;    
       
    55     };
    40 // CLASS DECLARATION
    56 // CLASS DECLARATION
    41 
    57 
    42 /**
    58 /**
    43  * Application state source plugin.
    59  * Application state source plugin.
    44  * Application state source plugin is responsible for listening view activations
    60  * Application state source plugin is responsible for listening view activations
    48  * @lib -
    64  * @lib -
    49  * @since S60 4.0
    65  * @since S60 4.0
    50  */
    66  */
    51 NONSHARABLE_CLASS( CApplicationStateSourcePlugIn ): 
    67 NONSHARABLE_CLASS( CApplicationStateSourcePlugIn ): 
    52 	public CCFContextSourcePlugIn,
    68 	public CCFContextSourcePlugIn,
    53 	public MVwsSessionWrapperObserver,
    69 	public MWsEventObserver,
    54 	public MCenRepNotifyHandlerCallback
    70 	public MCenRepNotifyHandlerCallback
    55     {
    71     {
    56 public: // Constructors and destructor
    72 public: // Constructors and destructor
    57 
    73 
    58     // Two phased constructors
    74     // Two phased constructors
    73     void DefineContextsL();
    89     void DefineContextsL();
    74 
    90 
    75     // @see CCFContextSourcePlugIn
    91     // @see CCFContextSourcePlugIn
    76     void InitializeL();
    92     void InitializeL();
    77 
    93 
    78 public: // From MVwsSessionWrapperObserver
    94 
    79 
       
    80     // @see MVwsSessionWrapperObserver
       
    81     void HandleViewEventL( const TVwsViewEvent& aEvent );
       
    82 
    95 
    83 public: // From MCenRepNotifyHandlerCallback
    96 public: // From MCenRepNotifyHandlerCallback
    84 
    97 
    85     // @see MCenRepNotifyHandlerCallback
    98     // @see MCenRepNotifyHandlerCallback
    86     void HandleNotifyGeneric( TUint32 aId );
    99     void HandleNotifyGeneric( TUint32 aId );
   108     // Initialize application settings from XML
   121     // Initialize application settings from XML
   109     void InitializeApplicationsFromXMLL();
   122     void InitializeApplicationsFromXMLL();
   110     
   123     
   111     // Initialize the fg application context
   124     // Initialize the fg application context
   112     void InitializeFgApplicationL();
   125     void InitializeFgApplicationL();
   113     
   126     void HandleWsEventL( RWsSession& aWsSession );
   114     // Handles the view server event
   127     // Handles the view server event
   115     void DoHandleViewEventL( const TVwsViewEvent& aEvent );
   128     void DoHandleViewEventL( const TVwsViewEvent& aEvent );
   116     
   129     
   117     // Resolve fg app orientation
   130     // Resolve fg app orientation
   118     TPtrC ResolveFgAppOrientation( const TUid& aUid );
   131     TPtrC ResolveFgAppOrientation( const TUid& aUid );
   146     // My settings.
   159     // My settings.
   147     CCFContextSourceSettingArray* iSettings;
   160     CCFContextSourceSettingArray* iSettings;
   148 
   161 
   149     // Foreground application setting list
   162     // Foreground application setting list
   150     RApplicationStateSettingsPointerArray iApplicationSettings;
   163     RApplicationStateSettingsPointerArray iApplicationSettings;
       
   164     CWsEventHandler* iWsEventHandler;
   151     
   165     
   152     // Previous foreground application orientation
   166     // Previous foreground application orientation
   153     TPtrC iPreviousOrientation;
   167     TPtrC iPreviousOrientation;
   154     
   168     
   155     // KCRUidDefaultAppOrientation cenrep
   169     // KCRUidDefaultAppOrientation cenrep
   162     RUidOrientationList iUidOrientationList;
   176     RUidOrientationList iUidOrientationList;
   163     
   177     
   164     // KCRUidDefaultAppOrientation listener
   178     // KCRUidDefaultAppOrientation listener
   165     CCenRepNotifyHandler* iCRAppOrientationListener;
   179     CCenRepNotifyHandler* iCRAppOrientationListener;
   166     };
   180     };
   167 
   181 /**
       
   182  * Listens events from window server and forwards them to observer.
       
   183  */
       
   184 NONSHARABLE_CLASS( CWsEventHandler ): public CActive
       
   185     {
       
   186 public:
       
   187 
       
   188     /**
       
   189      * Symbian two phased constructors.
       
   190      *
       
   191      * @since S60 5.0
       
   192      * @param None.
       
   193      * @return CDisplayServiceUILayout
       
   194      */
       
   195     static CWsEventHandler* NewL( MWsEventObserver& aObserver );
       
   196     static CWsEventHandler* NewLC( MWsEventObserver& aObserver );
       
   197 
       
   198     /**
       
   199      * C++ destructor.
       
   200      */
       
   201     virtual ~CWsEventHandler();
       
   202     
       
   203 public:
       
   204     
       
   205     /**
       
   206      * Start event listening.
       
   207      * 
       
   208      * @since S60 5.0
       
   209      * @param None.
       
   210      * @return None.
       
   211      */
       
   212     void IssueRequest();
       
   213     
       
   214 protected:
       
   215     
       
   216     // @see CActive
       
   217     virtual void RunL();
       
   218     
       
   219     // @see CActive
       
   220     virtual void DoCancel(); 
       
   221     
       
   222     // @see CActive
       
   223     virtual TInt RunError( TInt aError ); 
       
   224     
       
   225 private:
       
   226 
       
   227     CWsEventHandler( MWsEventObserver& aObserver );
       
   228     void ConstructL();
       
   229 
       
   230 private: // Data
       
   231     
       
   232     /** Observer */
       
   233     MWsEventObserver& iObserver;
       
   234 
       
   235     /** Window server session */
       
   236     RWsSession iWsSession;
       
   237     
       
   238     /** Window group for receiving window server events */
       
   239     RWindowGroup* iWindowGroup;
       
   240     
       
   241     /** Window group name to hide it from the task manager */
       
   242     CApaWindowGroupName* iWindowGroupName;
       
   243     };
   168 #endif // C_APPLICATIONSTATESOURCEPLUGIN_H
   244 #endif // C_APPLICATIONSTATESOURCEPLUGIN_H