|
1 /* |
|
2 * Copyright (c) 2002-2006 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: Accessory connection handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CACCSRVCONNECTIONHANDLER_H |
|
21 #define CACCSRVCONNECTIONHANDLER_H |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include "AccClientServerMessages.h" |
|
25 #include "AccSrvHandlerBase.h" |
|
26 #include "AccSrvQueueObserver.h" // MQueueObserver |
|
27 #include <AccPolGenericID.h> |
|
28 #include <AccPolValueRecord.h> //TAccPolValueType |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 // MACROS |
|
33 |
|
34 // DATA TYPES |
|
35 struct TAccSrvRequestData |
|
36 { |
|
37 TAccPolNameRecord iName; //GetValue operation is made for this name |
|
38 TInt iTrId; //Corresponding transaction id |
|
39 TBool iUpdateNotification; //response for accessory update notification |
|
40 }; |
|
41 |
|
42 enum TConnectionHandlerStates |
|
43 { |
|
44 EGetSelectionFromUser = 0, |
|
45 EInitializeConnection, |
|
46 EWaitForUINotifier |
|
47 }; |
|
48 |
|
49 |
|
50 // FUNCTION PROTOTYPES |
|
51 |
|
52 // FORWARD DECLARATIONS |
|
53 class MAccSrvConnectionControllerObserver; |
|
54 class CAccPolAccessoryPolicy; |
|
55 class CAccSrvASYProxyHandler; |
|
56 class CAccPolicyDB; |
|
57 class CAccSrvServerModel; |
|
58 |
|
59 // CLASS DECLARATION |
|
60 |
|
61 /** |
|
62 * Accessory connection and disconnection related tasks are handled here. |
|
63 * |
|
64 * @lib AccServer.lib |
|
65 * @since S60 3.1 |
|
66 */ |
|
67 NONSHARABLE_CLASS( CAccSrvConnectionHandler ) : public CAccSrvHandlerBase, |
|
68 public MQueueObserver |
|
69 { |
|
70 public: // Constructors and destructor |
|
71 |
|
72 /** |
|
73 * Two-phased constructor. |
|
74 */ |
|
75 static CAccSrvConnectionHandler* NewL( MAccSrvConnectionControllerObserver* aCallback, |
|
76 CAccSrvServerModel * aModel, |
|
77 CAccPolAccessoryPolicy* aPolicy ); |
|
78 |
|
79 /** |
|
80 * Destructor. |
|
81 */ |
|
82 virtual ~CAccSrvConnectionHandler(); |
|
83 |
|
84 public: // New functions |
|
85 |
|
86 /** |
|
87 * Starts Accessory connection handling asynchronously. |
|
88 * @since S60 3.1 |
|
89 * @param aGenericID Generic ID in question. |
|
90 * @param aEvaluateConnectionRules If true evaluate connection rules |
|
91 * @param aUpdateConnection Indicates new connection or update for existing connection |
|
92 * @return void |
|
93 */ |
|
94 void StartConnectionHandlingL( TAccPolGenericID& aGenericID, |
|
95 TBool aEvaluateConnectionRules, |
|
96 TBool aUpdatedConnection ); |
|
97 |
|
98 /** |
|
99 * Get connection handling generic id unique id |
|
100 * @since S60 3.1 |
|
101 * @return Unique id for connection handler |
|
102 */ |
|
103 TInt UniqueIDForConnectionHandler(); |
|
104 |
|
105 /** |
|
106 * Cancel connection handling |
|
107 * @since S60 3.1 |
|
108 * @return void |
|
109 */ |
|
110 void CancelConnectionHandling(); |
|
111 |
|
112 /** |
|
113 * Resets all values. After completion this handler is |
|
114 * available for handing next connection |
|
115 * @since S60 3.1 |
|
116 * @return void |
|
117 */ |
|
118 void ResetHandler(); |
|
119 |
|
120 /** |
|
121 * Indicates is this handler available for connection handling |
|
122 * @since S60 3.1 |
|
123 * @return EFalse if currently handling a connection, otherwise ETrue |
|
124 */ |
|
125 TBool IsFree(); |
|
126 |
|
127 public: // Functions from base classes |
|
128 |
|
129 protected: // New functions |
|
130 |
|
131 protected: // Functions from base classes |
|
132 |
|
133 /** |
|
134 * From CActive |
|
135 * Handles an active object's request completion event. |
|
136 * Asynchronous connection handling is processed. |
|
137 * |
|
138 * @since S60 3.1 |
|
139 * @return void |
|
140 */ |
|
141 void RunL(); |
|
142 |
|
143 /** |
|
144 * From CActive |
|
145 * The active scheduler calls this function if this active object's |
|
146 * RunL() function leaves. |
|
147 * |
|
148 * @since S60 3.1 |
|
149 * @param aError The leave code |
|
150 * @return KErrNone, when error has been handled |
|
151 */ |
|
152 TInt RunError(TInt aError); |
|
153 |
|
154 /** |
|
155 * From MQueueObserver |
|
156 * Provides empty definition for base class pure virtual declaration. |
|
157 */ |
|
158 TBool CompleteMessageL( TMsgID aMsgID, |
|
159 TInt aErrorCode, |
|
160 TInt aUniqueID ); |
|
161 |
|
162 /** |
|
163 * From MQueueObserver |
|
164 * Provides empty definition for base class pure virtual declaration. |
|
165 */ |
|
166 TBool CompleteProcessCommandL( TProcessCmdId aCmdn, |
|
167 TInt aTrId, |
|
168 TASYCommandParamRecord& aASYCommandParamRecord, |
|
169 TPtr8* aPtrBuf=NULL ); |
|
170 |
|
171 /** |
|
172 * From MQueueObserver |
|
173 * Called when Queue passes message completion handling to registered observers. |
|
174 * This is meant for GetValue() and SetValue() type of operations. |
|
175 * Critical capabilities are queried from ASY during accessory connection. |
|
176 * response from ASY for these queries are handled here. |
|
177 * |
|
178 * @since S60 3.1 |
|
179 * @param aMsgID Message in question. |
|
180 * @param aCmdResponse Value of the operation, used in GetValue() |
|
181 * type of operations. |
|
182 * @param aErrorCode Error Code of the operation. |
|
183 * @param aTrId Transaction Id of the operation. |
|
184 * @return void |
|
185 */ |
|
186 void HandleValueMessageL( TMsgID aMsgID, |
|
187 TAccValueTypeTBool aValue, |
|
188 TInt aErrorCode, |
|
189 TInt aTrId ); |
|
190 |
|
191 /** |
|
192 * From MQueueObserver |
|
193 * Called when Queue passes message completion handling to registered observers. |
|
194 * This is meant for GetValue() and SetValue() type of operations. |
|
195 * Critical capabilities are queried from ASY during accessory connection. |
|
196 * response from ASY for these queries are handled here. |
|
197 * |
|
198 * @since S60 3.1 |
|
199 * @param aMsgID Message in question. |
|
200 * @param aCmdResponse Value of the operation, used in GetValue() |
|
201 * type of operations. |
|
202 * @param aErrorCode Error Code of the operation. |
|
203 * @param aTrId Transaction Id of the operation. |
|
204 * @return void |
|
205 */ |
|
206 void HandleValueMessageL( TMsgID aMsgID, |
|
207 TAccValueTypeTInt aValue, |
|
208 TInt aErrorCode, |
|
209 TInt aTrId ); |
|
210 |
|
211 /** |
|
212 * From MQueueObserver |
|
213 * Called when Queue passes message completion handling to registered observers. |
|
214 * This is meant for GetValue() and SetValue() type of operations. |
|
215 * Critical capabilities are queried from ASY during accessory connection. |
|
216 * response from ASY for these queries are handled here. |
|
217 * |
|
218 * @since S60 3.1 |
|
219 * @param aMsgID Message in question. |
|
220 * @param aCmdResponse Value of the operation, used in GetValue() |
|
221 * type of operations. |
|
222 * @param aErrorCode Error Code of the operation. |
|
223 * @param aTrId Transaction Id of the operation. |
|
224 * @return void |
|
225 */ |
|
226 void HandleValueMessageL( TMsgID aMsgID, |
|
227 TDesC8& aValue, |
|
228 TInt aErrorCode, |
|
229 TInt aTrId ); |
|
230 /** |
|
231 * From MQueueObserver |
|
232 * Called when Queue passes message completion handling to registered observers. |
|
233 * This is meant for GetValue() and SetValue() type of operations. |
|
234 * Critical capabilities are queried from ASY during accessory connection. |
|
235 * response from ASY for these queries are handled here. |
|
236 * |
|
237 * @param aMsgID Message in question. |
|
238 * @param aPtrBuf Value of the operation, used in GetValue() |
|
239 * type of operations. |
|
240 * @param aErrorCode Error Code of the operation. |
|
241 * @param aTrId Transaction Id of the operation. |
|
242 * @return void |
|
243 */ |
|
244 void HandleValueMessageL( TMsgID aMsgID, |
|
245 TInt aTrId, |
|
246 TPtr8* aPtrBuf, |
|
247 TInt aErrorCode ); |
|
248 private: |
|
249 |
|
250 /** |
|
251 * Constructor with notify handling. |
|
252 */ |
|
253 CAccSrvConnectionHandler( MAccSrvConnectionControllerObserver* aCallback, |
|
254 CAccSrvServerModel * aModel, |
|
255 CAccPolAccessoryPolicy* aPolicy ); |
|
256 |
|
257 /** |
|
258 * By default Symbian 2nd phase constructor is private. |
|
259 */ |
|
260 void ConstructL(); |
|
261 |
|
262 /** |
|
263 * Initializes critical capabilities and supported BT-profilies. |
|
264 */ |
|
265 TBool InitializeCriticalCapsL(); |
|
266 |
|
267 /** |
|
268 * Sends GetValue-command towards ASY. |
|
269 */ |
|
270 void StartASYCommandHandlingL( TAccPolValueType aValueType, |
|
271 TASYCommandParamRecord& aASYCommandParam ); |
|
272 |
|
273 /** |
|
274 * Stores name and transaction ID while ASY query is ongoing. |
|
275 * During response handling name in question can be retrieved from here |
|
276 * according to the transaction Id with FindRequestData() method. |
|
277 */ |
|
278 void StoreRequestData( TAccPolNameRecord aName, |
|
279 TInt aTrId, |
|
280 TBool aUpdateConnectionNotification ); |
|
281 |
|
282 /** |
|
283 * Find stored request data. See StoreRequestData() |
|
284 */ |
|
285 TInt FindRequestData( TInt aTrId ); |
|
286 |
|
287 /** |
|
288 * Common HandleValueMessageL() implementation for TAccValueTypeTInt and |
|
289 * TAccValueTypeTBool types. |
|
290 */ |
|
291 void HandleValueMessagesL( TMsgID aMsgID, |
|
292 TInt aValue, |
|
293 TInt aErrorCode, |
|
294 TInt aTrId ); |
|
295 |
|
296 /** |
|
297 * Generic ID is updated according supported profiles received from BT-ASY. |
|
298 */ |
|
299 void ResolveGenericIDL( TDesC8& aValue ); |
|
300 |
|
301 /** |
|
302 * Common capabilities for all profiles are updated here. |
|
303 */ |
|
304 void ResolveGidL(); |
|
305 |
|
306 /** |
|
307 * Headset Profile (HSP) specific parts of Generic ID are updated. |
|
308 */ |
|
309 void ResolveHSPSpecificGidL( TUint16 aSupportedFeatures ); |
|
310 |
|
311 /** |
|
312 * Handsfree Profile (HFP) specific parts of Generic ID are updated. |
|
313 */ |
|
314 void ResolveHFPSpecificGidL( TUint16 aSupportedFeatures ); |
|
315 |
|
316 /** |
|
317 * Audio Video Remote Control Profile (AVRCP) specific parts of Generic ID are updated. |
|
318 */ |
|
319 void ResolveAVRCPSpecificGidL( TUint16 aSupportedFeatures ); |
|
320 |
|
321 /** |
|
322 * Advanced Audio Distribution Profile (A2DP) specific parts of Generic ID are updated. |
|
323 */ |
|
324 void ResolveA2DPSpecificGidL( TUint16 aSupportedFeatures ); |
|
325 |
|
326 /** |
|
327 * Update KAccSetVolumeLevel capability value. |
|
328 */ |
|
329 void UpdateSetVolumeLevelCapabilityL( TInt32 aCapability ); |
|
330 |
|
331 /** |
|
332 * Setup selection dialog with selection list |
|
333 */ |
|
334 void SetupSelectionDialogL( TUint32 aSelectionListBitmask); |
|
335 |
|
336 /** |
|
337 * Open selection dialog with selection list |
|
338 */ |
|
339 void OpenSelectionDialogL(); |
|
340 |
|
341 |
|
342 |
|
343 public: // Data |
|
344 |
|
345 protected: // Data |
|
346 |
|
347 private: // Data |
|
348 |
|
349 //Generic ID is stored here during connection handling asynchronous operatrion(s) |
|
350 TAccPolGenericID iGenericID; |
|
351 |
|
352 //Handle to the Accessory Policy |
|
353 CAccPolAccessoryPolicy* iPolicy;//Not owned |
|
354 |
|
355 //Name and corresponding Transaction ID for each ASY request is stored here. |
|
356 RArray<TAccSrvRequestData> iRequestDataArray; |
|
357 |
|
358 //pointer to server model |
|
359 CAccSrvServerModel * iModel; |
|
360 |
|
361 //connection handler state... |
|
362 TConnectionHandlerStates iState; |
|
363 |
|
364 //user selection reply |
|
365 TInt iReplyValue; |
|
366 |
|
367 //user selection reply package |
|
368 TPckg<TInt> iReplyPck; |
|
369 |
|
370 //ui notifier |
|
371 RNotifier iNotifier; |
|
372 |
|
373 //is connection handling update for old connection |
|
374 TBool iConnectionUpdate; |
|
375 |
|
376 //selection bitmask |
|
377 TInt iSelectionListBitmask; |
|
378 |
|
379 public: // Friend classes |
|
380 |
|
381 protected: // Friend classes |
|
382 |
|
383 private: // Friend classes |
|
384 |
|
385 }; |
|
386 |
|
387 #endif // CACCSRVCONNECTIONHANDLER_H |
|
388 |
|
389 // End of File |