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: Acessory and Bluetooth handler. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <featmgr.h> |
|
21 #include <StringLoader.h> |
|
22 #include <btengdomainpskeys.h> |
|
23 #include <btengdomaincrkeys.h> |
|
24 #include <mpeengineinfo.h> |
|
25 |
|
26 #include "cphoneaccessorybthandler.h" |
|
27 #include "cphonecenrepproxy.h" |
|
28 #include "cphonemainresourceresolver.h" |
|
29 #include "mphoneneclearedhandler.h" |
|
30 #include "mphonestatemachine.h" |
|
31 #include "mphoneviewcommandhandle.h" |
|
32 #include "phoneconstants.h" |
|
33 #include "phonelogger.h" |
|
34 #include "phoneui.pan" |
|
35 #include "phonerssbase.h" |
|
36 #include "tphonecmdparamnote.h" |
|
37 |
|
38 // CONSTANTS |
|
39 |
|
40 const TInt KPhoneBtAddressTextLength = 64; |
|
41 |
|
42 // ============================ MEMBER FUNCTIONS =============================== |
|
43 |
|
44 CPhoneAccessoryBTHandler::CPhoneAccessoryBTHandler( |
|
45 MPhoneViewCommandHandle* aViewCommandHandle, |
|
46 MPhoneStateMachine* aStateMachine, |
|
47 MPhoneNEClearedHandler* aNEClearedHandler ) : |
|
48 iViewCommandHandle( aViewCommandHandle ), |
|
49 iStateMachine( aStateMachine ), |
|
50 iNEClearedHandler( aNEClearedHandler ) |
|
51 { |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------- |
|
55 // CPhoneAccessoryBTHandler::NewLC() |
|
56 // Constructor |
|
57 // (other items were commented in a header). |
|
58 // ----------------------------------------------------------- |
|
59 // |
|
60 CPhoneAccessoryBTHandler* CPhoneAccessoryBTHandler::NewLC( |
|
61 MPhoneViewCommandHandle* aViewCommandHandle, |
|
62 MPhoneStateMachine* aStateMachine, |
|
63 MPhoneNEClearedHandler* aNEClearedHandler ) |
|
64 { |
|
65 CPhoneAccessoryBTHandler* self = new (ELeave) CPhoneAccessoryBTHandler( |
|
66 aViewCommandHandle, aStateMachine, aNEClearedHandler ); |
|
67 CleanupStack::PushL( self ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CPhoneAccessoryBTHandler::~CPhoneAccessoryBTHandler |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 CPhoneAccessoryBTHandler::~CPhoneAccessoryBTHandler() |
|
76 { |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------- |
|
80 // CPhoneAccessoryBTHandler::SetBTDebugModeL |
|
81 // Handling for message EPEMessageBTDebugMode. |
|
82 // Sets BT debug mode PS key on. |
|
83 // ----------------------------------------------------------- |
|
84 // |
|
85 void CPhoneAccessoryBTHandler::SetBTDebugModeL() |
|
86 { |
|
87 __LOGMETHODSTARTEND(EPhoneControl, "CPhoneAccessoryBTHandler::SetBTDebugModeL( ) "); |
|
88 if ( FeatureManager::FeatureSupported( KFeatureIdOnScreenDialer ) ) |
|
89 { |
|
90 iViewCommandHandle->ExecuteCommandL( EPhoneViewClearNumberEntryContent ); |
|
91 } |
|
92 else |
|
93 { |
|
94 // Remove number entry from screen |
|
95 iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry ); |
|
96 } |
|
97 iNEClearedHandler->HandleNumberEntryClearedL(); |
|
98 if ( RProperty::Set( KPSUidBluetoothDutMode, KBTSspDebugmode, EBTSspDebugModeOn )) |
|
99 { |
|
100 __PHONELOG( EOnlyFatal, EPhoneControl, "CPhoneAccessoryBTHandler::SetBTDebugModeL PS key not defined" ); |
|
101 } |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------- |
|
105 // CPhoneAccessoryBTHandler::SetBTHandsfreeModeL |
|
106 // --------------------------------------------------------- |
|
107 // |
|
108 TBool CPhoneAccessoryBTHandler::SetBTHandsfreeModeL( TBool aHandsfreeMode ) |
|
109 { |
|
110 return DoSetHandsfreeModeL( aHandsfreeMode, aHandsfreeMode ? EPEBTAudioAccessory : EPEHandset ); |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------- |
|
114 // CPhoneAccessoryBTHandler::SetHandsfreeModeL |
|
115 // --------------------------------------------------------- |
|
116 // |
|
117 TBool CPhoneAccessoryBTHandler::SetHandsfreeModeL( TBool aHandsfreeMode ) |
|
118 { |
|
119 return DoSetHandsfreeModeL( aHandsfreeMode, aHandsfreeMode ? EPELoudspeaker : EPEHandset ); |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------- |
|
123 // CPhoneAccessoryBTHandler::ShowBTAddressL |
|
124 // --------------------------------------------------------- |
|
125 // |
|
126 void CPhoneAccessoryBTHandler::ShowBTAddressL() |
|
127 { |
|
128 __LOGMETHODSTARTEND(EPhoneControl, "CPhoneAccessoryBTHandler::ShowBTAddressL( ) "); |
|
129 if ( FeatureManager::FeatureSupported( KFeatureIdOnScreenDialer )) |
|
130 { |
|
131 iViewCommandHandle->ExecuteCommandL( EPhoneViewClearNumberEntryContent ); |
|
132 } |
|
133 else |
|
134 { |
|
135 // Remove number entry from screen |
|
136 iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry ); |
|
137 } |
|
138 |
|
139 // Get BT address |
|
140 TBuf<KPhoneBtAddressTextLength> addressBuffer; |
|
141 |
|
142 CPhoneCenRepProxy::Instance()->GetString( |
|
143 KCRUidBluetoothLocalDeviceAddress, |
|
144 KBTLocalDeviceAddress, |
|
145 addressBuffer ); |
|
146 |
|
147 // BT address was empty. BT is not turned on. |
|
148 if ( addressBuffer.Length() == 0 ) |
|
149 { |
|
150 __PHONELOG( EBasic, EPhoneControl, "CPhoneAccessoryBTHandler::ShowBTAddressL.NoAddress" ); |
|
151 } |
|
152 |
|
153 // So we got the address. Now we need the localised text: |
|
154 HBufC* buf = StringLoader::LoadLC( |
|
155 CPhoneMainResourceResolver::Instance()-> |
|
156 ResolveResourceID( EPhonePhoneBtDevAddress ) , |
|
157 addressBuffer ); |
|
158 |
|
159 TPhoneCmdParamNote noteParam; |
|
160 noteParam.SetType( EPhoneNoteCustom ); |
|
161 noteParam.SetResourceId( CPhoneMainResourceResolver::Instance()-> |
|
162 ResolveResourceID( EPhoneInformationWaitNote ) ); |
|
163 noteParam.SetText( *buf ); |
|
164 |
|
165 // Display note |
|
166 iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNote, ¬eParam ); |
|
167 |
|
168 CleanupStack::PopAndDestroy( buf ); |
|
169 } |
|
170 |
|
171 // ----------------------------------------------------------- |
|
172 // CPhoneAccessoryBTHandler::ShowBTLoopbackL |
|
173 // Handling for message EPEMessageShowBTLoopback. |
|
174 // Shows BT loopback status note. |
|
175 // ----------------------------------------------------------- |
|
176 // |
|
177 void CPhoneAccessoryBTHandler::ShowBTLoopbackL() |
|
178 { |
|
179 __LOGMETHODSTARTEND(EPhoneControl, "CPhoneAccessoryBTHandler::ShowBTLoopbackL( ) "); |
|
180 if ( FeatureManager::FeatureSupported( KFeatureIdOnScreenDialer )) |
|
181 { |
|
182 iViewCommandHandle->ExecuteCommandL( EPhoneViewClearNumberEntryContent ); |
|
183 } |
|
184 else |
|
185 { |
|
186 // Remove number entry from screen |
|
187 iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry ); |
|
188 } |
|
189 TInt btLoopback( EBTDutOff ); |
|
190 |
|
191 // Get current status of BT loopback |
|
192 TInt err = RProperty::Get( KPSUidBluetoothDutMode, KBTDutEnabled, |
|
193 btLoopback ); |
|
194 |
|
195 // If loopback was disabled enable it. According to current knowledge |
|
196 // disabling BT test loop is not possible. If error getting the value |
|
197 // assume that it is disabled. |
|
198 if ( btLoopback == EBTDutOff || err != KErrNone ) |
|
199 { |
|
200 // Safe to overwrite the previous error code since it is nolonger needed |
|
201 err = RProperty::Set( KPSUidBluetoothDutMode, |
|
202 KBTDutEnabled, |
|
203 EBTDutOn ); |
|
204 if( !err ) |
|
205 { |
|
206 btLoopback = EBTDutOn; |
|
207 } |
|
208 } |
|
209 |
|
210 HBufC* btLoopbackString( NULL ); |
|
211 |
|
212 // Get localised text according to setting status |
|
213 btLoopbackString = StringLoader::LoadLC( |
|
214 CPhoneMainResourceResolver::Instance()-> |
|
215 ResolveResourceID( btLoopback == EBTDutOn ? |
|
216 EPhoneBtLoopbackEnabled : EPhoneBtLoopbackDisabled ) ); |
|
217 |
|
218 TPhoneCmdParamNote noteParam; |
|
219 noteParam.SetType( EPhoneNoteCustom ); |
|
220 noteParam.SetResourceId( CPhoneMainResourceResolver::Instance()-> |
|
221 ResolveResourceID( EPhoneInformationWaitNote ) ); |
|
222 noteParam.SetText( *btLoopbackString ); |
|
223 noteParam.SetTone( CAknNoteDialog::EConfirmationTone ); |
|
224 |
|
225 // Display note |
|
226 iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNote, ¬eParam ); |
|
227 |
|
228 CleanupStack::PopAndDestroy( btLoopbackString ); |
|
229 } |
|
230 |
|
231 // ----------------------------------------------------------- |
|
232 // CPhoneAccessoryBTHandler::ShowBTActivatedL |
|
233 // Shows BT activated note. |
|
234 // ----------------------------------------------------------- |
|
235 // |
|
236 void CPhoneAccessoryBTHandler::ShowBTActivatedL() |
|
237 { |
|
238 // Get localised text |
|
239 HBufC* buf = StringLoader::LoadLC( |
|
240 CPhoneMainResourceResolver::Instance()-> |
|
241 ResolveResourceID( EPhoneInfoBTAccActivated ) ); |
|
242 |
|
243 TPhoneCmdParamNote noteParam; |
|
244 noteParam.SetType( EPhoneNoteConfirmation ); |
|
245 noteParam.SetText( *buf ); |
|
246 |
|
247 // Display note |
|
248 iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNote, ¬eParam ); |
|
249 CleanupStack::PopAndDestroy( buf ); |
|
250 } |
|
251 |
|
252 // --------------------------------------------------------- |
|
253 // CPhoneAccessoryBTHandler::DoSetHandsfreeModeL |
|
254 // --------------------------------------------------------- |
|
255 // |
|
256 TBool CPhoneAccessoryBTHandler::DoSetHandsfreeModeL( |
|
257 TBool aHandsfreeMode, TPEAudioOutput aAudioOutput ) |
|
258 { |
|
259 __LOGMETHODSTARTEND(EPhoneControl, "CPhoneAccessoryBTHandler::DoSetHandsfreeModeL( ) "); |
|
260 __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(), |
|
261 Panic( EPhoneCtrlInvariant )); |
|
262 |
|
263 TBool allowed; |
|
264 // Only toggle the handsfree mode if there is no wired accessory connected |
|
265 if( iStateMachine->PhoneEngineInfo()->AudioOutput() != EPEWiredAudioAccessory ) |
|
266 { |
|
267 TBool showNote = aHandsfreeMode || |
|
268 !FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ); |
|
269 |
|
270 iStateMachine->PhoneEngineInfo()->SetAudioOutputCommand( |
|
271 aAudioOutput, showNote ); |
|
272 iStateMachine->SendPhoneEngineMessage( |
|
273 MPEPhoneModel::EPEMessageSetAudioOutput ); |
|
274 allowed = ETrue; |
|
275 } |
|
276 else |
|
277 { |
|
278 allowed = EFalse; |
|
279 } |
|
280 return allowed; |
|
281 } |
|
282 |
|
283 // End of File |
|