236 TAccPolGenericID& aGenericID, |
236 TAccPolGenericID& aGenericID, |
237 TBool aEvaluateConnectionRules, |
237 TBool aEvaluateConnectionRules, |
238 TBool aUpdatedConnection ) |
238 TBool aUpdatedConnection ) |
239 { |
239 { |
240 COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionHandler::StartConnectionHandling()" ); |
240 COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionHandler::StartConnectionHandling()" ); |
241 #define UNMASK_LINE_OUT(selectionListBitmask) (selectionListBitmask & (~KASLineOut)) |
|
242 |
241 |
243 iGenericID = aGenericID; |
242 iGenericID = aGenericID; |
244 iConnectionUpdate = aUpdatedConnection; |
243 iConnectionUpdate = aUpdatedConnection; |
245 |
244 |
246 //evaluate connection rules |
245 //evaluate connection rules |
247 if ( aEvaluateConnectionRules ) |
246 if ( aEvaluateConnectionRules ) |
248 { |
247 { |
249 COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionHandler::StartConnectionHandling() - Evaluate connection rules" ); |
248 COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionHandler::StartConnectionHandling() - Evaluate connection rules" ); |
250 |
249 |
251 //check rules |
|
252 TUint32 selectionListBitmask( 0 ); |
|
253 iPolicy->EvaluateConnectionRulesL( iGenericID, selectionListBitmask ); |
|
254 |
|
255 if ( selectionListBitmask ) |
|
256 { |
|
257 COM_TRACE_1( "[AccFW:AccServer] CAccSrvConnectionHandler::StartConnectionHandling() - Selection bitmask: 0x%bb", selectionListBitmask); |
|
258 |
|
259 //remove not supported items... |
|
260 selectionListBitmask = selectionListBitmask & iModel->SupportedDevicesL(); |
|
261 |
|
262 //Check default selection |
|
263 TInt defaultSelection( iModel->DeviceType() ); |
|
264 |
|
265 if ( selectionListBitmask == ( KASTTY | KASHeadset ) ) |
|
266 { |
|
267 if ( defaultSelection != KASTTY ) |
|
268 { |
|
269 defaultSelection = KASHeadset; |
|
270 } |
|
271 else |
|
272 { |
|
273 defaultSelection = KASTTY; |
|
274 } |
|
275 } |
|
276 else |
|
277 { |
|
278 if ( defaultSelection == KASHeadset ) |
|
279 { |
|
280 defaultSelection = 0; |
|
281 } |
|
282 |
|
283 defaultSelection = selectionListBitmask & defaultSelection; |
|
284 } |
|
285 |
|
286 if ( defaultSelection ) |
|
287 { |
|
288 iReplyValue = defaultSelection; |
|
289 iCallback->SetDefaultAccessoryInformation( iGenericID, defaultSelection ); |
|
290 CAccSrvHandlerBase::IssueRequest(); |
|
291 } |
|
292 else |
|
293 { |
|
294 //check that more than one accessories in the selection list |
|
295 TUint32 bitmask( 1 ); |
|
296 TInt accCount( 0 ); |
|
297 for ( TInt i( 0 ); i < 32; i++ ) |
|
298 { |
|
299 if ( selectionListBitmask & bitmask ) |
|
300 { |
|
301 if ( ++accCount > 1 ) |
|
302 { |
|
303 //more than one accessories, stop the loop |
|
304 break; |
|
305 } |
|
306 } |
|
307 bitmask <<= 1; |
|
308 } |
|
309 |
|
310 if ( accCount > 1 ) |
|
311 { |
|
312 //if there is possible selection show UI |
|
313 selectionListBitmask = UNMASK_LINE_OUT(selectionListBitmask); |
|
314 SetupSelectionDialogL( selectionListBitmask ); |
|
315 } |
|
316 else |
|
317 { |
|
318 //only one selection, don't show selection dialog |
|
319 iState = EGetSelectionFromUser; |
|
320 iReplyValue = selectionListBitmask; |
|
321 iCallback->SetDefaultAccessoryInformation( iGenericID, selectionListBitmask ); |
|
322 CAccSrvHandlerBase::IssueRequest(); |
|
323 } |
|
324 } |
|
325 |
|
326 } |
|
327 else |
|
328 { |
|
329 iState = EInitializeConnection; |
|
330 } |
|
331 |
|
332 } |
250 } |
333 else |
251 else |
334 { |
252 { |
335 COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionHandler::StartConnectionHandling() - No connection rules" ); |
253 COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionHandler::StartConnectionHandling() - No connection rules" ); |
336 iState = EInitializeConnection; |
254 |
337 } |
255 //Check default selection |
338 |
256 TInt defaultSelection( iModel->DeviceType() ); |
|
257 |
|
258 // Device Type Supplied |
|
259 if( (iGenericID.PhysicalConnectionCaps() & KPCWired) && |
|
260 (iGenericID.DeviceTypeCaps(KDTHeadset)) && |
|
261 (iPolicy->IsCapabilityDefinedL(iGenericID,KAccIntegratedAudioInput)) ) |
|
262 { |
|
263 // This is a Headset |
|
264 if(KASTTY == defaultSelection) |
|
265 { |
|
266 iReplyValue = defaultSelection; |
|
267 } |
|
268 else |
|
269 { |
|
270 iReplyValue = KASHeadset; |
|
271 } |
|
272 |
|
273 if(KASHeadset != iReplyValue) |
|
274 { |
|
275 COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionHandler::StartConnectionHandling- TTY Case" ); |
|
276 //only one selection, don't show selection dialog |
|
277 iState = EGetSelectionFromUser; |
|
278 iCallback->SetDefaultAccessoryInformation( iGenericID, iReplyValue ); |
|
279 CAccSrvHandlerBase::IssueRequest(); |
|
280 } |
|
281 else |
|
282 { |
|
283 COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionHandler::StartConnectionHandling- Headset Case" ); |
|
284 iState = EInitializeConnection; |
|
285 } |
|
286 } |
|
287 else if( (iGenericID.PhysicalConnectionCaps() & KPCWired) && |
|
288 (iGenericID.DeviceTypeCaps(KDTHeadset)) && |
|
289 !(iPolicy->IsCapabilityDefinedL(iGenericID,KAccIntegratedAudioInput)) ) |
|
290 { |
|
291 // This is a Headphone |
|
292 if((KASLineOut == defaultSelection) || |
|
293 (KASMusicStand == defaultSelection) || |
|
294 (KASHeadphones == defaultSelection)) |
|
295 { |
|
296 iReplyValue = defaultSelection; |
|
297 } |
|
298 else |
|
299 { |
|
300 iReplyValue = KASHeadphones; |
|
301 } |
|
302 |
|
303 if(KASHeadphones != iReplyValue) |
|
304 { |
|
305 COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionHandler::StartConnectionHandling- LineOut/MusicStand Case" ); |
|
306 //only one selection, don't show selection dialog |
|
307 iState = EGetSelectionFromUser; |
|
308 iCallback->SetDefaultAccessoryInformation( iGenericID, iReplyValue ); |
|
309 CAccSrvHandlerBase::IssueRequest(); |
|
310 |
|
311 } |
|
312 else |
|
313 { |
|
314 COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionHandler::StartConnectionHandling- Headphone Case" ); |
|
315 iState = EInitializeConnection; |
|
316 } |
|
317 } |
|
318 |
|
319 else |
|
320 { |
|
321 iState = EInitializeConnection; |
|
322 } |
|
323 } |
339 |
324 |
340 // Atleas one Asynchronous request is made for ourselves, |
325 // Atleas one Asynchronous request is made for ourselves, |
341 // clients ConnectAccessory asynchronous request will be completed |
326 // clients ConnectAccessory asynchronous request will be completed |
342 // during it. |
327 // during it. |
343 if ( iState == EInitializeConnection ) |
328 if ( iState == EInitializeConnection ) |