sysstatemgmt/systemstatemgr/inc/ssmstateawaresession.h
changeset 76 cb32bcc88bad
parent 0 4e1aa6a622a0
equal deleted inserted replaced
73:d38941471f1c 76:cb32bcc88bad
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    16 #ifndef __SSMSTATEAWARESESSION_H__
    16 #ifndef __SSMSTATEAWARESESSION_H__
    17 #define __SSMSTATEAWARESESSION_H__
    17 #define __SSMSTATEAWARESESSION_H__
    18 
    18 
    19 #include <e32base.h>
    19 #include <e32base.h>
    20 #include <domaindefs.h>
    20 #include <domaindefs.h>
       
    21 #include <domainmember.h>
    21 
    22 
    22 #include <ssm/ssmstate.h>
    23 #include <ssm/ssmstate.h>
    23 
    24 
    24 class CSsmStateMonitor;
    25 class CSsmStateMonitor;
       
    26 class CSsmDeferralMonitor;
       
    27 
    25 
    28 
    26 /**
    29 /**
    27 Read-only client interface to receive notifications when the
    30 Read-only client interface to receive notifications when the
    28 System State changes.
    31 System State changes.
    29 
    32 
    42 	IMPORT_C TSsmState State() const;
    45 	IMPORT_C TSsmState State() const;
    43 	IMPORT_C void RequestStateNotification(TRequestStatus& aStatus);
    46 	IMPORT_C void RequestStateNotification(TRequestStatus& aStatus);
    44 	IMPORT_C void RequestStateNotificationCancel();
    47 	IMPORT_C void RequestStateNotificationCancel();
    45 	IMPORT_C void AcknowledgeStateNotification(TInt aError);
    48 	IMPORT_C void AcknowledgeStateNotification(TInt aError);
    46 	IMPORT_C void AcknowledgeAndRequestStateNotification(TInt aError, TRequestStatus& aStatus);
    49 	IMPORT_C void AcknowledgeAndRequestStateNotification(TInt aError, TRequestStatus& aStatus);
       
    50 	IMPORT_C void DeferAcknowledgement(TRequestStatus& aStatus);
       
    51 	IMPORT_C void CancelDeferral();
       
    52 
    47 private:
    53 private:
    48 	RSsmStateAwareSession(const RSsmStateAwareSession& aState);
    54 	RSsmStateAwareSession(const RSsmStateAwareSession& aState);
    49 	
    55 	
    50 private:
    56 private:
    51 	//The main reason for this class is to hide implementation details that might change
    57 	//The main reason for this class is to hide implementation details that might change
   101 private:
   107 private:
   102 	RPointerArray<MStateChangeNotificationSubscriber> iSubscribers; // Elements of the array are not owned.
   108 	RPointerArray<MStateChangeNotificationSubscriber> iSubscribers; // Elements of the array are not owned.
   103 	CSsmStateMonitor* iMonitor;
   109 	CSsmStateMonitor* iMonitor;
   104 	TInt iSpare[4];
   110 	TInt iSpare[4];
   105 	};
   111 	};
       
   112 
       
   113 
       
   114 /**
       
   115 Interface to implement for clients that want to use the @c CExtendedSsmStateAwareSession 
       
   116 utility class.
       
   117 
       
   118 @publishedPartner
       
   119 @released
       
   120 */
       
   121 class MStateChangeNotificationSubscriber2
       
   122     {
       
   123 public:
       
   124     /*HandleTransition() will be called when the transition notification
       
   125     comes in. Thereafter, the active object will contineouslly defer the transition.
       
   126     
       
   127     The implementation of this function should be used first to call
       
   128     RequestTransitionNotification() again if required, and then to initiate the
       
   129     response to the transition. It should be kept as quick as possible.
       
   130     
       
   131     Once the Domain Member's transition operations are complete, it should call
       
   132     AcknowledgeLastState() on this active object, to indicate it is ready to be
       
   133     transitioned*/
       
   134     
       
   135     virtual void HandleTransition(TInt aError) = 0;
       
   136     
       
   137     virtual TInt HandleDeferralError(TInt aError) = 0;
       
   138     };
       
   139 
       
   140 /**
       
   141 This class automatically deferrs transitions as long as possible after the original notification
       
   142 is received.
       
   143 
       
   144 To make use of this class, one has to implement the implement the HandleTransition()
       
   145 in MStateChangeNotificationSubscriber2. HandleTransition() will be called when the transition notification
       
   146 comes in. Thereafter, the active object will continually defer the transition.
       
   147 
       
   148 This object is intended to simplify the handling of notifications and
       
   149 deferrals. The member must ensure that other active objects do not block or
       
   150 have long-running RunL()s; this is to ensure that the Active Scheduler will
       
   151 remain responsive to the completion of deadline deferrals.
       
   152 
       
   153 The capabilities needed are the same as those needed for RDmDomain::DeferAcknowledgement()
       
   154 @capability WriteDeviceData
       
   155 @capability ProtServ
       
   156 @see 
       
   157 */
       
   158 NONSHARABLE_CLASS(CSsmStateAwareSession2):public CActive 
       
   159 	{
       
   160 public:	
       
   161 	IMPORT_C static CSsmStateAwareSession2* NewL(TDmDomainId aDomainId, MStateChangeNotificationSubscriber2& aSubscriber );
       
   162 	IMPORT_C ~CSsmStateAwareSession2();
       
   163 	IMPORT_C void RequestStateNotification();
       
   164     IMPORT_C void RequestStateNotificationCancel();
       
   165     IMPORT_C void AcknowledgeStateNotification(TInt aError);
       
   166     IMPORT_C void AcknowledgeAndRequestStateNotification(TInt aError);	  
       
   167 	IMPORT_C TSsmState GetState();    
       
   168 	TInt HandleDeferralError(TInt aError);
       
   169     
       
   170 private:
       
   171 	CSsmStateAwareSession2(MStateChangeNotificationSubscriber2& aSubscriber);
       
   172     void RunL();
       
   173     void DoCancel();
       
   174 	void ConstructL(TDmDomainId aDomainId);  
       
   175 	
       
   176 	
       
   177 private:
       
   178 	RSsmStateAwareSession iSsmStateAwareSession;
       
   179 	//For deferring the notification.
       
   180 	CSsmDeferralMonitor* iDeferNotification;	
       
   181 	MStateChangeNotificationSubscriber2* iSubscriber;
       
   182 	};
   106 	
   183 	
   107 #endif
   184 #endif