|
1 /* |
|
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 @file |
|
23 @internalTechnology |
|
24 */ |
|
25 |
|
26 #ifndef HWRMSERVICE_H |
|
27 #define HWRMSERVICE_H |
|
28 |
|
29 // INCLUDES |
|
30 #include <e32base.h> |
|
31 #include "HWRMPluginTransactionList.h" |
|
32 |
|
33 // CONSTANTS |
|
34 // None |
|
35 |
|
36 // MACROS |
|
37 // None |
|
38 |
|
39 // DATA TYPES |
|
40 // None |
|
41 |
|
42 // FUNCTION PROTOTYPES |
|
43 // None |
|
44 |
|
45 // FORWARD DECLARATIONS |
|
46 class CHWRMPluginHandler; |
|
47 class CHWRMReservationHandler; |
|
48 |
|
49 // CLASS DECLARATION |
|
50 |
|
51 /** |
|
52 * Data storage class for plugin requests. |
|
53 */ |
|
54 class THWRMPluginRequestData : public THWRMPluginTransactionListItem |
|
55 { |
|
56 public: |
|
57 RMessage2 iRequestMessage; // Can have NULL handle for timer triggered requests. |
|
58 TBool iSplitCommand; // Indicates if command was split to two adaptation calls. |
|
59 TInt iSplitCommandId; //Id of the command to be executed next. |
|
60 TAny* iSplitCommandData; //Owned. Data associated with split command. |
|
61 |
|
62 /** |
|
63 * Convenience constructor |
|
64 */ |
|
65 THWRMPluginRequestData(const RMessage2& aRequestMessage, TUint8 aTransId, TInt aCommandId, |
|
66 TBool aSplitCommand, TInt aSplitCommandId=0, TAny* aSplitCommandData=NULL) |
|
67 : THWRMPluginTransactionListItem(aTransId, aCommandId), |
|
68 iRequestMessage(aRequestMessage), iSplitCommand(aSplitCommand), iSplitCommandId(aSplitCommandId), iSplitCommandData(aSplitCommandData) |
|
69 { |
|
70 }; |
|
71 /** |
|
72 * Virtual destructor. |
|
73 */ |
|
74 virtual ~THWRMPluginRequestData() |
|
75 { |
|
76 }; |
|
77 }; |
|
78 |
|
79 /** |
|
80 * Hardware Resource Manager server side service objects base class. |
|
81 * Each session has one service object. |
|
82 * |
|
83 */ |
|
84 class CHWRMService : public CBase |
|
85 { |
|
86 public: // New functions |
|
87 /** |
|
88 * This function has to be implemented by the derived class. |
|
89 * CHWRMSession calls this method to handle plugin related messages. |
|
90 * |
|
91 * @param aMessage Service message to be completed in ProcessResponseL. |
|
92 * @return ETrue if completion is needed for message, EFalse otherwise. |
|
93 */ |
|
94 virtual TBool ExecuteMessageL(const RMessage2& aMessage)=0; |
|
95 |
|
96 /** |
|
97 * This function has to be implemented by the derived class. |
|
98 * Callback method for plugin handlers to notify this service |
|
99 * that request has been processed. |
|
100 * This method is not called in case request is canceled. |
|
101 * |
|
102 * @param aCommandId The command id for which the response came |
|
103 * @param aTransId Related transaction Id |
|
104 * @param aData Response data |
|
105 * @param aTimeout Request was canceled by timeout. aData parameter |
|
106 * is empty descriptor if aTimeout is ETrue. |
|
107 */ |
|
108 virtual void ProcessResponseL( TInt aCommandId, |
|
109 TUint8 aTransId, |
|
110 TDesC8& aData, |
|
111 TBool aTimeout )=0; |
|
112 |
|
113 /** |
|
114 * Method to suspend the use of subresource of service. |
|
115 * If service only has one subresource, whole service is suspended. |
|
116 * |
|
117 * @param aSubResource Index of the subresource that was suspended. |
|
118 * Note that this is always a single subresource. |
|
119 * Index 0 corresponds to subresource 0x1, |
|
120 * index 1 corresponds to subresource 0x2, |
|
121 * index 2 corresponds to subresource 0x4, |
|
122 * index 3 corresponds to subresource 0x8, etc. |
|
123 */ |
|
124 virtual void SuspendSubResource(TInt aSubResource) = 0; |
|
125 |
|
126 /** |
|
127 * Method to resume suspended resource. |
|
128 * |
|
129 * @param aSubResource Index of the subresource that was resumed. |
|
130 * Note that this is always a single subresource. |
|
131 * Index 0 corresponds to subresource 0x1, |
|
132 * index 1 corresponds to subresource 0x2, |
|
133 * index 2 corresponds to subresource 0x4, |
|
134 * index 3 corresponds to subresource 0x8, etc. |
|
135 */ |
|
136 virtual void ResumeSubResource(TInt aSubResource) = 0; |
|
137 |
|
138 /** |
|
139 * Method for notifying activation/deactivation of reserved subresource |
|
140 * |
|
141 * @param aSubResource Index of the subresource that was activated/deactivated. |
|
142 * Note that this is always a single subresource. |
|
143 * Index 0 corresponds to subresource 0x1, |
|
144 * index 1 corresponds to subresource 0x2, |
|
145 * index 2 corresponds to subresource 0x4, |
|
146 * index 3 corresponds to subresource 0x8, etc. |
|
147 * @param aActivate Indicates if resource was activated or deactivated |
|
148 */ |
|
149 virtual void ActivateSubResource(TInt aSubResource, TBool aActivate) =0; |
|
150 |
|
151 |
|
152 protected: // Construction |
|
153 |
|
154 /** |
|
155 * BaseConstructL must be called by subclasses ConstructL methods. |
|
156 * |
|
157 * @param aPluginHandler The plugin handler to use with this service. |
|
158 * @param aReservationHandler The reservation handler to use with this service. |
|
159 */ |
|
160 void BaseConstructL(CHWRMPluginHandler* aPluginHandler, |
|
161 CHWRMReservationHandler* aReservationHandler); |
|
162 |
|
163 /** |
|
164 * BaseDestruct must be called by subclasses destructors. |
|
165 */ |
|
166 void BaseDestruct(); |
|
167 |
|
168 /** |
|
169 * CompleteRequest can be called from ProcessResponseL to |
|
170 * complete any outstanding request and remove transaction |
|
171 * from transaction list. |
|
172 * |
|
173 * @param aTransId Transaction identifier |
|
174 * @param aCompletionCode Code used to complete message |
|
175 * @return Error code if the transaction is not found. |
|
176 */ |
|
177 TInt CompleteRequest(TUint8 aTransId, TInt aCompletionCode); |
|
178 |
|
179 /** |
|
180 * CompleteRequest can be called from ProcessResponseL to |
|
181 * complete any outstanding request and remove transaction |
|
182 * from transaction list. |
|
183 * |
|
184 * @param aTransId Transaction identifier |
|
185 * @param aCompletionCode Code used to complete message |
|
186 * @param aTransactionList List which contains transaction to remove |
|
187 * @param aCompleteMsg Truth value used for checking whether |
|
188 * message should be completed or not. |
|
189 * @return Error code if the transaction is not found. |
|
190 */ |
|
191 TInt CompleteRequest(TUint8 aTransId, TInt aCompletionCode, |
|
192 CHWRMPluginTransactionList* aTransactionList, TBool aCompleteMsg); |
|
193 |
|
194 /** |
|
195 * Checks that no transaction for this message still remains in transaction list |
|
196 * |
|
197 * @param aHandle Message handle. |
|
198 * @return ETrue if list still contains transaction data for checked message. |
|
199 */ |
|
200 TBool CheckForMessage(TInt aHandle); |
|
201 |
|
202 protected: // data |
|
203 |
|
204 CHWRMPluginHandler* iPluginHandler; // Reference to plugin handler, not owned. |
|
205 // Subclasses must set this in ConstructL |
|
206 |
|
207 CHWRMPluginTransactionList* iTransactionList; // List of open transactions |
|
208 |
|
209 CHWRMReservationHandler* iReservationHandler; // Reservation handler, not owned |
|
210 }; |
|
211 |
|
212 #endif // HWRMSERVICE_H |
|
213 |
|
214 // End of File |