|
1 /* |
|
2 * Copyright (c) 2008 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: Haptic service header file. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_HWRMHAPTICSSERVICE_H |
|
20 #define C_HWRMHAPTICSSERVICE_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include "hwrmhapticsgenerictimer.h" |
|
24 #include "hwrmhapticscommondata.h" |
|
25 |
|
26 class MHWRMHapticsPacketizer; |
|
27 class CHWRMHapticsPluginManager; |
|
28 class CHWRMHapticsReservationHandler; |
|
29 class CHWRMHapticsPluginTransactionList; |
|
30 |
|
31 /** |
|
32 * Haptics server side service object. Each session has one service object. |
|
33 * |
|
34 * @since S60 5.1 |
|
35 */ |
|
36 class CHWRMHapticsService : public CBase |
|
37 { |
|
38 public: |
|
39 |
|
40 /** |
|
41 * Symbian two-phased constructor. |
|
42 * |
|
43 * @param aPluginHandler The plugin handler to use with this service. |
|
44 * @param aReservationHandler The reservation handler to use with |
|
45 * this service. |
|
46 * @param aHapticsCommonData Haptics common data. |
|
47 * @param aMessage Message used to instantiate this service instance. |
|
48 * @return A pointer to the created instance. |
|
49 */ |
|
50 IMPORT_C static CHWRMHapticsService* NewL( |
|
51 CHWRMHapticsPluginManager* aPluginHandler, |
|
52 CHWRMHapticsReservationHandler* aReservationHandler, |
|
53 CHWRMHapticsCommonData& aHapticsCommonData, |
|
54 const RMessage2& aMessage ); |
|
55 |
|
56 /** |
|
57 * Destructor. |
|
58 */ |
|
59 virtual ~CHWRMHapticsService(); |
|
60 |
|
61 public: |
|
62 |
|
63 /** |
|
64 * CHWRMHapticsSession calls this method to handle plugin related messages. |
|
65 * |
|
66 * @param aMessage Service message to be completed in ProcessResponseL. |
|
67 * @return ETrue if completion is needed for message, EFalse otherwise. |
|
68 */ |
|
69 IMPORT_C TBool ExecuteMessageL( const RMessage2& aMessage ); |
|
70 |
|
71 /** |
|
72 * Callback method for plugin handlers to notify this service |
|
73 * that request has been processed. |
|
74 * This method is not called in case request is canceled. |
|
75 * |
|
76 * @param aCommandId The command id for which the response came |
|
77 * @param aTransId Related transaction Id |
|
78 * @param aData Response data |
|
79 */ |
|
80 void ProcessResponseL( TInt aCommandId, TUint8 aTransId, |
|
81 const TDesC8& aData ); |
|
82 |
|
83 /** |
|
84 * Method to suspend the use of resource of service. Used by the |
|
85 * reservation handler. |
|
86 */ |
|
87 void SuspendResource(); |
|
88 |
|
89 /** |
|
90 * Method to resume suspended resource. Used by the reservation handler. |
|
91 */ |
|
92 void ResumeResource(); |
|
93 |
|
94 /** |
|
95 * Method for cancelling outstanding request |
|
96 * |
|
97 * @param aTransId Related transaction Id |
|
98 */ |
|
99 void CancelRequest( TUint8 aTransId ); |
|
100 |
|
101 private: |
|
102 |
|
103 /** |
|
104 * C++ constructor. |
|
105 * |
|
106 * @param aHapticsCommonData Haptics common data. |
|
107 * @param aMessage Message used to instantiate this service instance. |
|
108 */ |
|
109 CHWRMHapticsService( CHWRMHapticsCommonData& aHapticsCommonData, |
|
110 const RMessage2& aMessage ); |
|
111 |
|
112 /** |
|
113 * Second phase construction. |
|
114 * |
|
115 * @param aPluginManager The plugin handler to use with this service. |
|
116 * @param aReservationHandler The reservation handler to use with |
|
117 * this service. |
|
118 */ |
|
119 void ConstructL( CHWRMHapticsPluginManager* aPluginManager, |
|
120 CHWRMHapticsReservationHandler* aReservationHandler ); |
|
121 |
|
122 /** |
|
123 * CompleteRequest can be called from ProcessResponseL to |
|
124 * complete any outstanding request and remove transaction |
|
125 * from transaction list. |
|
126 * |
|
127 * @param aTransId Transaction identifier |
|
128 * @param aData Request response data. |
|
129 * @return Error code if the transaction is not found. |
|
130 */ |
|
131 TInt CompleteRequestL( TUint8 aTransId, |
|
132 const TDesC8& aData ); |
|
133 |
|
134 /** |
|
135 * Checks that no transaction for this message still remains in transaction list |
|
136 * |
|
137 * @param aHandle Message handle. |
|
138 * @return ETrue if list still contains transaction data for checked message. |
|
139 */ |
|
140 TBool CheckForMessage( TInt aHandle ); |
|
141 |
|
142 /** |
|
143 * Cleans up the haptics state |
|
144 */ |
|
145 void CleanupHaptics(); |
|
146 |
|
147 /** |
|
148 * Send the message to pluginManager.This method is used by the |
|
149 * ExecuteMessageL() to handle plugin related messages. |
|
150 * |
|
151 * @param aMessage Service message to be completed in ProcessResponseL. |
|
152 */ |
|
153 void SendMsgToPluginManagerL( const RMessage2& aMessage ); |
|
154 |
|
155 /** |
|
156 * Send the message to close device to pluginManager. |
|
157 * |
|
158 * @param aMessage Service message to be completed in ProcessResponseL. |
|
159 */ |
|
160 void SendCloseActuatorMsgL( const RMessage2& aMessage ); |
|
161 |
|
162 /** |
|
163 * Reserves haptics. |
|
164 * |
|
165 * @param aMessage Command message received from the client. |
|
166 */ |
|
167 void ReserveHapticsL( const RMessage2& aMessage ); |
|
168 |
|
169 /** |
|
170 * Releases haptics. |
|
171 */ |
|
172 void ReleaseHaptics(); |
|
173 |
|
174 /** |
|
175 * Sets given haptics status to iLastStatus. |
|
176 * |
|
177 * @param aHapticStatus Status to be stored. |
|
178 */ |
|
179 void SetHapticsStatus( |
|
180 MHWRMHapticsObserver::THWRMHapticsStatus aHapticStatus ); |
|
181 |
|
182 private: // data |
|
183 |
|
184 /** |
|
185 * Reference to plugin handler, not owned. |
|
186 */ |
|
187 CHWRMHapticsPluginManager* iPluginManager; |
|
188 |
|
189 /** |
|
190 * List of open transactions. |
|
191 */ |
|
192 CHWRMHapticsPluginTransactionList* iTransactionList; |
|
193 |
|
194 /** |
|
195 * Reservation handler, not owned |
|
196 */ |
|
197 CHWRMHapticsReservationHandler* iReservationHandler; |
|
198 |
|
199 /** |
|
200 * Haptic packetizer. |
|
201 */ |
|
202 MHWRMHapticsPacketizer* iPacketizer; |
|
203 |
|
204 /** |
|
205 * Pointer to haptics data object common to all sessions. Not owned. |
|
206 */ |
|
207 CHWRMHapticsCommonData& iHapticsCommonData; |
|
208 |
|
209 /** |
|
210 * Flag to indicate if this session is suspended. |
|
211 */ |
|
212 TBool iSuspended; |
|
213 |
|
214 /** |
|
215 * Flag to indicate if this session is reserved. |
|
216 */ |
|
217 TBool iReserved; |
|
218 |
|
219 /** |
|
220 * Flag to indicate if cleanup has been done. |
|
221 */ |
|
222 TBool iCleanupDone; |
|
223 |
|
224 /** |
|
225 * Secure ID identifying the client. |
|
226 */ |
|
227 TSecureId iSid; |
|
228 |
|
229 /** |
|
230 * Pointer to the session, which created this instance. |
|
231 * Used to identify the session. |
|
232 */ |
|
233 const CSession2* iSession; |
|
234 }; |
|
235 |
|
236 #endif // C_HWRMHAPTICSSERVICE_H |
|
237 |
|
238 // End of File |