|
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: Class takes care of CBA's. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "cphoneuicommandmanager.h" |
|
19 |
|
20 #include "mpeengineinfo.h" |
|
21 #include "mphoneviewcommandhandle.h" |
|
22 #include "mphonestatemachine.h" |
|
23 #include "phonerssbase.h" |
|
24 #include "phonelogger.h" |
|
25 #include "cphonemainresourceresolver.h" |
|
26 #include "tphonecmdparaminteger.h" |
|
27 #include "tphonecmdparamcallstatedata.h" |
|
28 #include "tphonecmdparamboolean.h" |
|
29 |
|
30 |
|
31 // ======== MEMBER FUNCTIONS ======== |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // CPhoneUiCommandManager::CPhoneUiCommandManager |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CPhoneUiCommandManager::CPhoneUiCommandManager( |
|
38 CPhoneState* aState, |
|
39 MPhoneViewCommandHandle& aViewCommandHandle, |
|
40 MPhoneStateMachine& aStateMachine ) |
|
41 : iState ( aState ), |
|
42 iViewCommandHandle ( aViewCommandHandle ), |
|
43 iStateMachine ( aStateMachine ), |
|
44 iSoftRejectStatus ( ETrue ) |
|
45 { |
|
46 __LOGMETHODSTARTEND( EPhoneControl, "CPhoneUiCommandManager::CPhoneUiCommandManager() "); |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CPhoneUiCommandManager::NewL |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CPhoneUiCommandManager* CPhoneUiCommandManager::NewL( |
|
54 CPhoneState* aState, |
|
55 MPhoneViewCommandHandle& aViewCommandHandle, |
|
56 MPhoneStateMachine& aStateMachine ) |
|
57 { |
|
58 __LOGMETHODSTARTEND( EPhoneControl, "CPhoneUiCommandManager::NewL() "); |
|
59 return new (ELeave) CPhoneUiCommandManager( aState, aViewCommandHandle, aStateMachine ); |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CPhoneUiCommandManager::~CPhoneUiCommandManager |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CPhoneUiCommandManager::~CPhoneUiCommandManager() |
|
67 { |
|
68 __LOGMETHODSTARTEND( EPhoneControl, "CPhoneUiCommandManager::~CPhoneUiCommandManager() "); |
|
69 } |
|
70 |
|
71 // ======== LOCAL FUNCTIONS ======== |
|
72 |
|
73 // ----------------------------------------------------------- |
|
74 // CPhoneUiCommandManager::UpdateUiCommands |
|
75 // ----------------------------------------------------------- |
|
76 // |
|
77 void CPhoneUiCommandManager::UpdateUiCommands() |
|
78 { |
|
79 SetButtonFlags(); |
|
80 |
|
81 SetTouchButtons(); |
|
82 |
|
83 SetToolBarButtons(); |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------- |
|
87 // CPhoneUiCommandManager::SetSoftRejectStatus |
|
88 // ----------------------------------------------------------- |
|
89 // |
|
90 void CPhoneUiCommandManager::SetSoftRejectStatus( TBool aSoftRejectStatus ) |
|
91 { |
|
92 __LOGMETHODSTARTEND(EPhoneControl, "CPhoneUiCommandManager::SetSoftRejectStatus ()" ); |
|
93 // Set the internal TBool variable |
|
94 iSoftRejectStatus = aSoftRejectStatus; |
|
95 __PHONELOG1( |
|
96 EBasic, |
|
97 EPhoneControl, |
|
98 "CPhoneUiCommandManager::SetSoftRejectStatus - iSoftRejectStatus =%d", |
|
99 iSoftRejectStatus ); |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------- |
|
103 // CPhoneUiCommandManager::SoftRejectStatus |
|
104 // ----------------------------------------------------------- |
|
105 // |
|
106 TBool CPhoneUiCommandManager::SoftRejectStatus() |
|
107 { |
|
108 return iSoftRejectStatus; |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------- |
|
112 // CPhoneUiCommandManager::SetSoftRejectDimmedFlag |
|
113 // ----------------------------------------------------------- |
|
114 // |
|
115 void CPhoneUiCommandManager::SetSoftRejectDimmedFlag() |
|
116 { |
|
117 __LOGMETHODSTARTEND(EPhoneControl, "CPhoneUiCommandManager::GetIncomingCallSilenceCBA ()" ); |
|
118 TPhoneCmdParamCallStateData callStateData; |
|
119 callStateData.SetCallState( EPEStateRinging ); |
|
120 TRAPD( err, iViewCommandHandle.HandleCommandL( |
|
121 EPhoneViewGetCallIdByState, &callStateData ) ); |
|
122 TPhoneCmdParamBoolean dimSoftRejectParam; |
|
123 |
|
124 if ( err == KErrNone && callStateData.CallId() > KErrNotFound ) |
|
125 { |
|
126 TBool privateNumber = iStateMachine.PhoneEngineInfo()-> |
|
127 RemotePhoneNumber( callStateData.CallId() ).Length() == 0; |
|
128 |
|
129 TBool voip = iStateMachine.PhoneEngineInfo()-> |
|
130 CallType( callStateData.CallId() ) == EPECallTypeVoIP; |
|
131 |
|
132 dimSoftRejectParam.SetBoolean( privateNumber || !iSoftRejectStatus || voip ); |
|
133 } |
|
134 else |
|
135 { |
|
136 iSoftRejectStatus = ETrue; |
|
137 dimSoftRejectParam.SetBoolean( EFalse ); |
|
138 } |
|
139 iViewCommandHandle.ExecuteCommand( |
|
140 EPhoneViewSetSoftRejectDimmed, &dimSoftRejectParam ); |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------- |
|
144 // CPhoneUiCommandManager::SetButtonFlags |
|
145 // ----------------------------------------------------------- |
|
146 // |
|
147 void CPhoneUiCommandManager::SetButtonFlags() |
|
148 { |
|
149 __LOGMETHODSTARTEND(EPhoneControl, "CPhoneUiCommandManager::SetButtonFlags() "); |
|
150 SetSoftRejectDimmedFlag(); |
|
151 |
|
152 TPhoneCmdParamBoolean muteParam; |
|
153 muteParam.SetBoolean( iStateMachine.PhoneEngineInfo()->AudioMute() ); |
|
154 iViewCommandHandle.ExecuteCommand(EPhoneViewSetMuteFlag,&muteParam); |
|
155 |
|
156 const TPEAudioOutput audioOutput = |
|
157 iStateMachine.PhoneEngineInfo()->AudioOutput(); |
|
158 |
|
159 TBool btAvailable = iStateMachine.PhoneEngineInfo()->AudioOutputAvailable( |
|
160 EPEBTAudioAccessory ); |
|
161 |
|
162 TPhoneCmdParamBoolean btParam; |
|
163 btParam.SetBoolean( audioOutput == EPEBTAudioAccessory ); |
|
164 iViewCommandHandle.ExecuteCommand(EPhoneViewSetBlueToothFlag,&btParam); |
|
165 |
|
166 TPhoneCmdParamBoolean btAvailableParam; |
|
167 btAvailableParam.SetBoolean( btAvailable ); |
|
168 iViewCommandHandle.ExecuteCommand( |
|
169 EPhoneViewSetBluetoothAvailableFlag,&btAvailableParam); |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------- |
|
173 // CPhoneUiCommandManager::SetTouchButtons |
|
174 // ----------------------------------------------------------- |
|
175 // |
|
176 void CPhoneUiCommandManager::SetTouchButtons() |
|
177 { |
|
178 __LOGMETHODSTARTEND(EPhoneControl, "CPhoneUiCommandManager::SetTouchButtons() "); |
|
179 TPhoneCmdParamBoolean booleanParam; |
|
180 booleanParam.SetBoolean( IsEmergency() ); |
|
181 |
|
182 iViewCommandHandle.ExecuteCommand( |
|
183 EPhoneViewSetTouchPaneButtons, |
|
184 &booleanParam ); |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------- |
|
188 // CPhoneUiCommandManager::SetToolBarButtons |
|
189 // ----------------------------------------------------------- |
|
190 // |
|
191 void CPhoneUiCommandManager::SetToolBarButtons() |
|
192 { |
|
193 |
|
194 TInt resource( IsEmergency() ? |
|
195 EPhoneCallHandlingEmergencyCBA : |
|
196 ToolBarResource() ); |
|
197 |
|
198 if ( resource != KErrNotFound ) |
|
199 { |
|
200 TPhoneCmdParamInteger integerParam; |
|
201 integerParam.SetInteger( |
|
202 CPhoneMainResourceResolver::Instance()->ResolveResourceID( |
|
203 resource ) ); |
|
204 iViewCommandHandle.ExecuteCommand( EPhoneViewUpdateCba, |
|
205 &integerParam ); |
|
206 } |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------- |
|
210 // CPhoneUiCommandManager::ToolBarResource |
|
211 // ----------------------------------------------------------- |
|
212 // |
|
213 TInt CPhoneUiCommandManager::ToolBarResource() |
|
214 { |
|
215 TInt ret( KErrNotFound ); |
|
216 TPhoneCmdParamInteger callIdParam; |
|
217 iViewCommandHandle.ExecuteCommand( |
|
218 EPhoneViewGetExpandedBubbleCallId, &callIdParam ); |
|
219 |
|
220 TInt callID = callIdParam.Integer(); |
|
221 |
|
222 if ( callID != KErrNotFound ) |
|
223 { |
|
224 TInt callState = iStateMachine.PhoneEngineInfo()-> |
|
225 CallState( callID ); |
|
226 |
|
227 if ( callState == EPEStateRinging ) |
|
228 { |
|
229 ret = RingingCallResource(); |
|
230 } |
|
231 else |
|
232 { |
|
233 ret = EPhoneCallHandlingInCallCBA; |
|
234 } |
|
235 } |
|
236 |
|
237 return ret; |
|
238 } |
|
239 |
|
240 // ----------------------------------------------------------- |
|
241 // CPhoneUiCommandManager::RingingCallResource |
|
242 // ----------------------------------------------------------- |
|
243 // |
|
244 TInt CPhoneUiCommandManager::RingingCallResource() |
|
245 { |
|
246 TInt ret( KErrNotFound ); |
|
247 TPhoneCmdParamInteger activeCallCountParam; |
|
248 TRAP_IGNORE( iViewCommandHandle.ExecuteCommandL( |
|
249 EPhoneViewGetCountOfActiveCalls, &activeCallCountParam ) ); |
|
250 TInt activeCallCount = activeCallCountParam.Integer(); |
|
251 |
|
252 if ( 0 == activeCallCount ) |
|
253 { |
|
254 ret = SingleRingingCallResource(); |
|
255 } |
|
256 else if ( 2 == activeCallCount ) |
|
257 { |
|
258 ret = ret = EPhoneCallHandlingIncomingRejectCBA; |
|
259 } |
|
260 else |
|
261 { |
|
262 ret = EPhoneCallHandlingCallWaitingCBA; |
|
263 } |
|
264 |
|
265 return ret; |
|
266 } |
|
267 |
|
268 // ----------------------------------------------------------- |
|
269 // CPhoneUiCommandManager::SingleRingingCallResource |
|
270 // ----------------------------------------------------------- |
|
271 // |
|
272 TInt CPhoneUiCommandManager::SingleRingingCallResource() |
|
273 { |
|
274 TInt ret( KErrNotFound ); |
|
275 |
|
276 TPhoneCmdParamBoolean ringingTonePlaying; |
|
277 iViewCommandHandle.ExecuteCommand( |
|
278 EPhoneViewIsRingingTonePlaying, &ringingTonePlaying ); |
|
279 |
|
280 if ( ringingTonePlaying.Boolean() ) |
|
281 { |
|
282 ret = EPhoneCallHandlingIncomingCBA; |
|
283 } |
|
284 else |
|
285 { |
|
286 ret = EPhoneCallHandlingIncomingSoftRejectCBA; |
|
287 } |
|
288 |
|
289 return ret; |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------- |
|
293 // CPhoneUiCommandManager::IsEmergency |
|
294 // ----------------------------------------------------------- |
|
295 // |
|
296 TBool CPhoneUiCommandManager::IsEmergency() |
|
297 { |
|
298 TBool emergency( EPEStateIdle != |
|
299 iStateMachine.PhoneEngineInfo()->CallState( KPEEmergencyCallId ) ); |
|
300 |
|
301 return emergency; |
|
302 } |
|
303 |