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