71 // C++ default constructor can NOT contain any code, that |
71 // C++ default constructor can NOT contain any code, that |
72 // might leave. |
72 // might leave. |
73 // ----------------------------------------------------------------------------- |
73 // ----------------------------------------------------------------------------- |
74 // |
74 // |
75 CAccSrvSettingsHandler::CAccSrvSettingsHandler( CAccSrvConnectionController* aConCtrl, |
75 CAccSrvSettingsHandler::CAccSrvSettingsHandler( CAccSrvConnectionController* aConCtrl, |
76 CAccSrvServerModel& aModel ) |
76 CAccSrvServerModel& aModel, |
|
77 CAccPolAccessoryPolicy* aPolicy ) |
77 : iConCtrl( aConCtrl ), |
78 : iConCtrl( aConCtrl ), |
78 iModel( aModel ), |
79 iModel( aModel ), |
79 iLightsOn( EAccSettingsLightsNotSet ) |
80 iLightsOn( EAccSettingsLightsNotSet ), |
|
81 iPolicy( aPolicy ) |
80 { |
82 { |
81 COM_TRACE_( "[AccFW:AccServer] CAccSrvSettingsHandler::CAccSrvSettingsHandler()" ); |
83 COM_TRACE_( "[AccFW:AccServer] CAccSrvSettingsHandler::CAccSrvSettingsHandler()" ); |
82 |
84 |
83 COM_TRACE_( "[AccFW:AccServer] CAccSrvSettingsHandler::CAccSrvSettingsHandler - return" ); |
85 COM_TRACE_( "[AccFW:AccServer] CAccSrvSettingsHandler::CAccSrvSettingsHandler - return" ); |
84 } |
86 } |
120 // Two-phased constructor. |
122 // Two-phased constructor. |
121 // ----------------------------------------------------------------------------- |
123 // ----------------------------------------------------------------------------- |
122 // |
124 // |
123 CAccSrvSettingsHandler* CAccSrvSettingsHandler::NewL( |
125 CAccSrvSettingsHandler* CAccSrvSettingsHandler::NewL( |
124 CAccSrvConnectionController* aConCtrl, |
126 CAccSrvConnectionController* aConCtrl, |
125 CAccSrvServerModel& aModel ) |
127 CAccSrvServerModel& aModel, |
|
128 CAccPolAccessoryPolicy* aPolicy ) |
126 { |
129 { |
127 COM_TRACE_( "[AccFW:AccServer] CAccSrvSettingsHandler::NewL()" ); |
130 COM_TRACE_( "[AccFW:AccServer] CAccSrvSettingsHandler::NewL()" ); |
128 |
131 |
129 CAccSrvSettingsHandler* self = new( ELeave ) CAccSrvSettingsHandler( |
132 CAccSrvSettingsHandler* self = new( ELeave ) CAccSrvSettingsHandler( |
130 aConCtrl, |
133 aConCtrl, |
131 aModel ); |
134 aModel, |
|
135 aPolicy ); |
132 CleanupStack::PushL( self ); |
136 CleanupStack::PushL( self ); |
133 self->ConstructL(); |
137 self->ConstructL(); |
134 CleanupStack::Pop( self ); |
138 CleanupStack::Pop( self ); |
135 |
139 |
136 COM_TRACE_( "[AccFW:AccServer] CAccSrvSettingsHandler::NewL - return self" ); |
140 COM_TRACE_( "[AccFW:AccServer] CAccSrvSettingsHandler::NewL - return self" ); |
283 { |
287 { |
284 COM_TRACE_3( "[AccFW:AccServer] CAccSrvSettingsHandler::SetHWDeviceSettingsL( %d, %d, %d )", aSettings, aEnable, aForce ); |
288 COM_TRACE_3( "[AccFW:AccServer] CAccSrvSettingsHandler::SetHWDeviceSettingsL( %d, %d, %d )", aSettings, aEnable, aForce ); |
285 |
289 |
286 // Valid settings |
290 // Valid settings |
287 TUint32 settings = ResolveNewSettingsL( aSettings, aEnable, aForce ); |
291 TUint32 settings = ResolveNewSettingsL( aSettings, aEnable, aForce ); |
288 |
292 TUint32 iOldDeviceType = iModel.DeviceType(); |
|
293 |
289 // Update model |
294 // Update model |
290 iModel.SetDeviceType( settings ); |
295 iModel.SetDeviceType( settings ); |
291 |
296 |
292 // Update setting to CR |
297 // Update setting to CR |
293 CRepository* repository = CRepository::NewL( KCRUidAccServer ); |
298 CRepository* repository = CRepository::NewL( KCRUidAccServer ); |
294 TInt crSettings = static_cast<TInt>( settings ); |
299 TInt crSettings = static_cast<TInt>( settings ); |
295 repository->Set( KAccServerHWDevices, crSettings ); |
300 repository->Set( KAccServerHWDevices, crSettings ); |
296 delete repository; |
301 delete repository; |
297 repository = NULL; |
302 repository = NULL; |
298 |
303 |
|
304 //Check default selection. The newly set device-type after the model update. |
|
305 TInt defaultSelection( iModel.DeviceType() ); |
|
306 TInt iReplyValue = KASNoDevice; |
|
307 TAccPolGenericID iGenericID; |
|
308 |
|
309 // get the last connected wired accessory |
|
310 if(iModel.GetLastConnectedWiredAccessory(iGenericID)) |
|
311 { |
|
312 // Device Type Supplied |
|
313 if( iGenericID.DeviceTypeCaps(KDTHeadset) ) |
|
314 { |
|
315 // This is a Headset |
|
316 if( iPolicy->IsCapabilityDefinedL(iGenericID, KAccIntegratedAudioInput) ) |
|
317 { |
|
318 if(KASTTY == defaultSelection) |
|
319 { |
|
320 iReplyValue = defaultSelection; |
|
321 } |
|
322 else |
|
323 { |
|
324 iReplyValue = KASHeadset; |
|
325 } |
|
326 } |
|
327 // This is a Headphone |
|
328 else |
|
329 { |
|
330 if(KASMusicStand == defaultSelection) |
|
331 { |
|
332 iReplyValue = defaultSelection; |
|
333 } |
|
334 else |
|
335 { |
|
336 iReplyValue = KASHeadphones; |
|
337 } |
|
338 } |
|
339 } |
|
340 else if( iGenericID.DeviceTypeCaps(KDTTTY) ) |
|
341 { |
|
342 if( iPolicy->IsCapabilityDefinedL(iGenericID, KAccIntegratedAudioInput) ) |
|
343 { |
|
344 if(KASHeadset == defaultSelection) |
|
345 { |
|
346 iReplyValue = defaultSelection; |
|
347 } |
|
348 else |
|
349 { |
|
350 iReplyValue = KASTTY; |
|
351 } |
|
352 } |
|
353 } |
|
354 else if( iGenericID.DeviceTypeCaps(KDTOffice) ) |
|
355 { |
|
356 if(KASHeadphones == defaultSelection) |
|
357 { |
|
358 iReplyValue = defaultSelection; |
|
359 } |
|
360 else |
|
361 { |
|
362 iReplyValue = KASMusicStand; |
|
363 } |
|
364 } |
|
365 // Device Type Not Supplied |
|
366 else if( iGenericID.DeviceTypeCaps() == KASNoDevice ) |
|
367 { |
|
368 iReplyValue = defaultSelection; |
|
369 } |
|
370 |
|
371 if( (KASNoDevice != iReplyValue) && (iReplyValue != iOldDeviceType) ) |
|
372 { |
|
373 //update generic id |
|
374 iPolicy->UpdateGenericIDL( iGenericID, iReplyValue); |
|
375 // Update the "iConnectionArray" of CAccSrvServerModel, |
|
376 // to reflect the update on generic-id done earlier. |
|
377 TAccPolGenericID oldGenericId; |
|
378 iModel.FindWithUniqueIDL( iGenericID.UniqueID(), oldGenericId ); |
|
379 |
|
380 iConCtrl->HandleConnectionUpdateValidationL( |
|
381 iGenericID, oldGenericId, this, KErrNone ); |
|
382 |
|
383 TASYCommandParamRecord asyCommandParamRecord; |
|
384 asyCommandParamRecord.iCmdValue = 0;//Not used in update command |
|
385 asyCommandParamRecord.iGenericID = iGenericID; |
|
386 |
|
387 //Send request to ASY Proxy Handler |
|
388 COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionHandler::RunL() - Send update request"); |
|
389 TInt trId = iConCtrl->HandleASYCommsL( ECmdAccessoryUpdated, |
|
390 asyCommandParamRecord ); |
|
391 |
|
392 iConCtrl->HandleAccessoryModeChangedL(); |
|
393 |
|
394 } |
|
395 } |
|
396 |
299 COM_TRACE_( "[AccFW:AccServer] CAccSrvSettingsHandler::SetHWDeviceSettingsL() - return" ); |
397 COM_TRACE_( "[AccFW:AccServer] CAccSrvSettingsHandler::SetHWDeviceSettingsL() - return" ); |
300 } |
398 } |
301 |
399 |
302 // ----------------------------------------------------------------------------- |
400 // ----------------------------------------------------------------------------- |
303 // CAccSrvSettingsHandler::GetHWDeviceSettings |
401 // CAccSrvSettingsHandler::GetHWDeviceSettings |