|
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 HWRMSERVER_H |
|
27 #define HWRMSERVER_H |
|
28 |
|
29 // INCLUDES |
|
30 #include <e32svr.h> |
|
31 #include "HWRMClientServer.h" |
|
32 #include "HWRMClient.h" // THWRMResourceType |
|
33 |
|
34 // CONSTANTS |
|
35 // None |
|
36 |
|
37 // MACROS |
|
38 // None |
|
39 |
|
40 // DATA TYPES |
|
41 // None |
|
42 |
|
43 // FUNCTION PROTOTYPES |
|
44 // None |
|
45 |
|
46 // FORWARD DECLARATIONS |
|
47 class CHWRMPluginHandler; |
|
48 class CHWRMReservationHandler; |
|
49 class CHWRMVibraCommonService; |
|
50 class CHWRMVibraCommonData; |
|
51 class CHWRMLightCommonData; |
|
52 class CHWRMFmTxCommonData; |
|
53 class CHWRMFmTxStateUtility; |
|
54 class CHWRMPowerStatePluginHandler; |
|
55 class CHWRMPowerCommonData; |
|
56 |
|
57 // CLASS DECLARATION |
|
58 |
|
59 /** |
|
60 * Hardware Resource Manager server implementation |
|
61 * |
|
62 */ |
|
63 class CHWRMServer : public CPolicyServer |
|
64 { |
|
65 public: // Constructors and destructor |
|
66 |
|
67 /** |
|
68 * Creates a new server. |
|
69 * @param aPriority Priority of the server. |
|
70 * @return A pointer to the created object. |
|
71 */ |
|
72 static CHWRMServer* NewL( const TInt aPriority ); |
|
73 |
|
74 /** |
|
75 * Creates a new server. Newly created instance is left in the cleanup stack. |
|
76 * @param aPriority Priority of the server. |
|
77 * @return A pointer to the created object. |
|
78 */ |
|
79 static CHWRMServer* NewLC( const TInt aPriority ); |
|
80 |
|
81 /** |
|
82 * Destructor. |
|
83 */ |
|
84 virtual ~CHWRMServer(); |
|
85 |
|
86 /** |
|
87 * Panics client thread. |
|
88 * |
|
89 * @param aMessage Message that is being handled |
|
90 * @param aPanic Panic type |
|
91 */ |
|
92 static void PanicClient(const RMessage2& aMessage, THWRMPanic aPanic); |
|
93 |
|
94 /** |
|
95 * Get pointer to plugin handler of specified type. |
|
96 * Returns NULL if specified handler is not initialized yet. |
|
97 * |
|
98 * @param aType Resource type |
|
99 * @return pointer to correct plugin handler |
|
100 */ |
|
101 CHWRMPluginHandler* GetPluginHandler(THWRMResourceType aType); |
|
102 |
|
103 /** |
|
104 * Get pointer to reservation handler of specified type. |
|
105 * Returns NULL if specified handler is not initialized yet. |
|
106 * |
|
107 * @param aType Resource type |
|
108 * @return pointer to correct reservation handler |
|
109 */ |
|
110 CHWRMReservationHandler* GetReservationHandler(THWRMResourceType aType); |
|
111 |
|
112 /** |
|
113 * Get pointer to vibra common service. |
|
114 * |
|
115 * @return pointer to vibra common service |
|
116 * Returns NULL if resource not supported. |
|
117 */ |
|
118 CHWRMVibraCommonService* GetVibraCommonService(); |
|
119 |
|
120 |
|
121 |
|
122 /** |
|
123 * Get pointer to vibra common data. |
|
124 * |
|
125 * @return pointer to vibra common data |
|
126 * Returns NULL if resource not supported. |
|
127 */ |
|
128 CHWRMVibraCommonData* GetVibraCommonData(); |
|
129 |
|
130 /** |
|
131 * Get pointer to light common data. |
|
132 * |
|
133 * @return pointer to light common data. |
|
134 * Returns NULL if resource not supported. |
|
135 */ |
|
136 CHWRMLightCommonData* GetLightCommonData(); |
|
137 |
|
138 /** |
|
139 * Get pointer to Power common data. |
|
140 * |
|
141 * @return pointer to Power common data. |
|
142 * Returns NULL if resource not supported. |
|
143 */ |
|
144 CHWRMPowerCommonData* GetPowerCommonData(); |
|
145 |
|
146 /** |
|
147 * Get pointer to FmTx common data. |
|
148 * |
|
149 * @return pointer to FmTx common data. |
|
150 * Returns NULL if resource not supported. |
|
151 */ |
|
152 CHWRMFmTxCommonData* GetFmTxCommonData(); |
|
153 |
|
154 /** |
|
155 * This method is called by CActive if RunL leaves. |
|
156 * |
|
157 * @param aError Symbian error code. |
|
158 * @return Returns KErrNone if the error was handled or aError otherwise. |
|
159 */ |
|
160 //TInt RunError(TInt aError); |
|
161 |
|
162 |
|
163 public: // New functions |
|
164 |
|
165 public: // Functions from base classes |
|
166 |
|
167 protected: // New functions |
|
168 |
|
169 protected: // Functions from base classes |
|
170 |
|
171 private: |
|
172 |
|
173 /** |
|
174 * C++ constructor. |
|
175 */ |
|
176 CHWRMServer( const TInt aPriority, |
|
177 const TServerType aType = EUnsharableSessions ); |
|
178 /** |
|
179 * By default Symbian 2nd phase constructor is private. |
|
180 */ |
|
181 void ConstructL(); |
|
182 |
|
183 /** |
|
184 * Creates a new session when client connects. |
|
185 * @param aVersion Version |
|
186 * @param aMessage 'connect' message from the client |
|
187 * @return Pointer to created session or leaves with codes |
|
188 * KErrNotSupported if versions does not match |
|
189 * KErrNoMemory if creation of new session fails. |
|
190 */ |
|
191 CSession2* NewSessionL( const TVersion& aVersion, |
|
192 const RMessage2& aMessage ) const; |
|
193 /** |
|
194 * Panics the server thread |
|
195 * @param aCategory Panicer's id |
|
196 * @param aPanic Reason of panic |
|
197 * @return void |
|
198 */ |
|
199 void Panic( const TDesC& aCategory, const TInt aReason ); |
|
200 |
|
201 /** |
|
202 * Method to initialize vibra. |
|
203 * Vibra is not initialized in ConstructL in order to |
|
204 * speed up the startup. |
|
205 */ |
|
206 void InitVibra(); |
|
207 |
|
208 /** |
|
209 * Method to initialize FM Tx. |
|
210 * FM Tx is not initialized in ConstructL in order to |
|
211 * speed up the startup. |
|
212 */ |
|
213 void InitFmTxL(); |
|
214 |
|
215 /** |
|
216 * Method to initialize Power. |
|
217 * Power is not initialized in ConstructL in order to |
|
218 * speed up the startup. |
|
219 */ |
|
220 void InitPower(); |
|
221 |
|
222 |
|
223 public: // Data |
|
224 |
|
225 protected: // Data |
|
226 |
|
227 private: // Data |
|
228 |
|
229 // Server has one plugin handler for each hardware resource |
|
230 CHWRMPluginHandler* iVibraPluginHandler; |
|
231 CHWRMPluginHandler* iLightPluginHandler; |
|
232 CHWRMPowerStatePluginHandler* iPowerStatePluginHandler; |
|
233 CHWRMPluginHandler* iFmTxPluginHandler; |
|
234 CHWRMPluginHandler* iFmTxWatcherPluginHandler; // Own. |
|
235 CHWRMPluginHandler* iPowerPluginHandler; |
|
236 |
|
237 // Server has one reservation handler for each hardware resource |
|
238 CHWRMReservationHandler* iVibraReservationHandler; |
|
239 CHWRMReservationHandler* iLightReservationHandler; |
|
240 CHWRMReservationHandler* iFmTxReservationHandler; |
|
241 |
|
242 // Server has one common vibra service instance for all vibra sessions |
|
243 CHWRMVibraCommonService* iVibraCommonService; |
|
244 |
|
245 // Server has one common data instance for each hardware resource |
|
246 CHWRMVibraCommonData* iVibraCommonData; |
|
247 CHWRMLightCommonData* iLightCommonData; |
|
248 CHWRMFmTxCommonData* iFmTxCommonData; |
|
249 CHWRMFmTxStateUtility* iFmTxStateUtility; |
|
250 CHWRMPowerCommonData* iPowerCommonData; |
|
251 |
|
252 TBool iVibraInitAttempted; // If ETrue, vibra initialization has been tried before. |
|
253 TBool iFmTxInitAttempted; // If ETrue, FM Tx initialization has been tried before. |
|
254 TBool iPowerInitAttempted; // If ETrue, power initialization has been tried before. |
|
255 TInt iPluginTimeout; // Stores plugin timeout for vibra initialization |
|
256 |
|
257 |
|
258 public: // Friend classes |
|
259 |
|
260 protected: // Friend classes |
|
261 |
|
262 private: // Friend classes |
|
263 //friend class CHWRMSession; |
|
264 //friend class CHWRMPluginHandler; |
|
265 }; |
|
266 |
|
267 #endif // HWRMSERVER_H |
|
268 |
|
269 // End of File |