sysstatemgmt/systemstatemgr/sus/inc/susstateadaptation.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "ssmstate.h"
       
    17 #include <e32base.h>
       
    18 #include "ssmadaptation.h"
       
    19 #include "ssmdebug.h"
       
    20 #include "ssmadaptationcmn.h"
       
    21 
       
    22 	
       
    23 #ifndef __SUSSTATEADAPTATION_H__
       
    24 #define __SUSSTATEADAPTATION_H__
       
    25 
       
    26 /**
       
    27 CStateAdaptationRequests
       
    28 CStateAdaptationObservers
       
    29 
       
    30 These classes implement the State Adaptation related functionality as part of 
       
    31 Adaptation server.These classes implement an active object to route the requests
       
    32 and notifications to Adaptation plugins loaded by CSsmAdaptationServer.
       
    33 These classes are also responsible for queueing the requests and pooling
       
    34 the notification requests  when requests are received from multiple clients
       
    35 Adaptation server handles only one request from each session and uses 
       
    36 Cancel() methods to cancel any of the session's requests made before.
       
    37 The queueing mechanism is to handle multiple clients at a time not to handle
       
    38 multiple requests from one particular clients session.
       
    39 
       
    40 @internalComponent
       
    41 */
       
    42 
       
    43 	
       
    44 class CStateAdaptationRequests : public CActive
       
    45 {
       
    46 public:
       
    47     static CStateAdaptationRequests* NewL(MStateAdaptation& aAdaptation);
       
    48  	~CStateAdaptationRequests();
       
    49 
       
    50 
       
    51 	void Release();
       
    52 	void DoRequestCoopSysStateChangeL(const RMessage2& aMessage);
       
    53 	void DoRequestCoopSysSelfTestL(const RMessage2& aMessage);
       
    54 	void DoRequestCoopSysPerformRestartActionsL(const RMessage2& aMessage);
       
    55 	void DoRequestCoopSysPerformShutdownActionsL(const RMessage2& aMessage);
       
    56 	void DoRequestCoopSysPerformRfsActionsL(const RMessage2& aMessage);
       
    57 	void DoRequestCancel(const RMessage2& aMessage);
       
    58 
       
    59 	MStateAdaptation& Adaptation();
       
    60 	
       
    61 protected:
       
    62 	void RunL();
       
    63 	TInt RunError( TInt aError );
       
    64 	void DoCancel();
       
    65 
       
    66 private:
       
    67 	CStateAdaptationRequests(MStateAdaptation& aAdaptation);
       
    68 	void SubmitOrQueueL(const RMessage2 &aMessage);	 	
       
    69 	void Submit(CAdaptationMessage*& aMessage);
       
    70 	
       
    71 private:
       
    72 
       
    73 	CAdaptationMessage *iCurrentMessage;
       
    74 	RSsmAdaptationRequestQueue iPendingRequestsQueue;	
       
    75 
       
    76 	MStateAdaptation& iStateAdaptation;
       
    77 };
       
    78 
       
    79 
       
    80 
       
    81 
       
    82 
       
    83 
       
    84 /**
       
    85 Internal class for maintaining observers for notifications.Whenever a client 
       
    86 registers for  StateAdaptation notifications it will be added to the observers
       
    87 list and it will be notified when CStateAdaptationObservers receives notification
       
    88 from the State Adaptation plugin loaded by CSsmAdaptationServer.Once client receives 
       
    89 the notification it has to register again for getting further notification.  
       
    90 
       
    91 @internalComponent
       
    92 */
       
    93 
       
    94 
       
    95 
       
    96 class RStateAdaptationObserversList
       
    97 	{
       
    98 public:
       
    99 	void AddObserverL(CAdaptationMessage *aNotificationMessage);
       
   100 	void Close();
       
   101 	TInt Count();
       
   102 	void NotifyAndRemoveAll(TSsmCoopSysEventType aEventType,TInt aCompleteCode);
       
   103 	void RemoveObserver(CAdaptationMessage *);
       
   104 private:
       
   105 	RPointerArray<CAdaptationMessage > iObservers;
       
   106 	};
       
   107 	
       
   108 	
       
   109 	
       
   110 	
       
   111 /**
       
   112 CStateAdaptationRequests
       
   113 CStateAdaptationObservers
       
   114 
       
   115 These classes implement the State Adaptation related functionality as part of 
       
   116 Adaptation server.These classes implement an active object to route the requests
       
   117 and notifications to Adaptation plugins loaded by CSsmAdaptationServer.
       
   118 These classes are also responsible for queueing the requests and pooling
       
   119 the notification requests  when requests are received from multiple clients
       
   120 Adaptation server handles only one request from each session and uses 
       
   121 Cancel() methods to cancel any of the session's requests made before.
       
   122 The queueing mechanism is to handle multiple clients at a time not to handle
       
   123 multiple requests from one particular clients session.
       
   124 
       
   125 @internalComponent
       
   126 */
       
   127 
       
   128 
       
   129 
       
   130 
       
   131 class CStateAdaptationObservers : public CActive
       
   132 {
       
   133 public:
       
   134     static CStateAdaptationObservers* NewL(MStateAdaptation& aAdaptation);
       
   135     //static CStateAdaptationObservers* NewLC();
       
   136 	~CStateAdaptationObservers();
       
   137 
       
   138 	//from MStateAdaptation
       
   139 	void DoGetLastCoopSysEvent(const RMessage2& aMessage);	
       
   140 	void DoNotifyCoopSysEventL(const RMessage2& aMessage);
       
   141 	void DoNotifyCoopSysEventCancelL(const RMessage2& aMessage);
       
   142 	
       
   143 protected:
       
   144 	void RunL();
       
   145 	TInt RunError( TInt aError );
       
   146 	void DoCancel();
       
   147 
       
   148 private:
       
   149 	CStateAdaptationObservers(MStateAdaptation& aAdaptation);
       
   150 	
       
   151 	void StartNotification();
       
   152 private:
       
   153 	MStateAdaptation& iStateAdaptation;
       
   154 	RStateAdaptationObserversList iObserversList;
       
   155 	
       
   156 	TPckgBuf<TSsmCoopSysEventType> iEventPckg;
       
   157 };
       
   158 
       
   159 
       
   160 
       
   161 
       
   162 
       
   163 #endif // __SUSSTATEADAPTATION_H__