17 |
17 |
18 |
18 |
19 // INCLUDE FILES |
19 // INCLUDE FILES |
20 #include <featmgr.h> // for FeatureManager |
20 #include <featmgr.h> // for FeatureManager |
21 #include <settingsinternalcrkeys.h> |
21 #include <settingsinternalcrkeys.h> |
|
22 #include <phoneappcommands.hrh> |
22 |
23 |
23 #include "cphoneuicontroller.h" |
24 #include "cphoneuicontroller.h" |
24 #include "pevirtualengine.h" |
25 #include "pevirtualengine.h" |
25 #include "cphonestatehandle.h" |
26 #include "cphonestatehandle.h" |
26 #include "cphoneenginehandler.h" |
27 #include "cphoneenginehandler.h" |
27 #include "cphonesystemeventhandler.h" |
28 #include "cphonesystemeventhandler.h" |
28 #include "cphoneremotecontrolhandler.h" |
29 #include "cphoneremotecontrolhandler.h" |
29 #include "mphoneviewcommandhandle.h" |
|
30 #include "phonestatedefinitions.h" |
30 #include "phonestatedefinitions.h" |
31 #include "phonelogger.h" |
31 #include "phonelogger.h" |
32 #include "phoneconstants.h" |
32 #include "phoneconstants.h" |
33 #include "phoneui.pan" |
33 #include "phoneui.pan" |
|
34 #include "cphonekeyeventforwarder.h" |
34 #include "cphonecenrepproxy.h" |
35 #include "cphonecenrepproxy.h" |
35 #include "cphonemediatorfactory.h" |
36 #include "cphonemediatorfactory.h" |
36 #include "tphonecmdparamnumberentryobserver.h" |
37 #include "tphonecmdparamnumberentryobserver.h" |
|
38 #include "cphonesecuritymodeobserver.h" |
|
39 #include "cphoneviewcontroller.h" |
37 |
40 |
38 // ================= MEMBER FUNCTIONS ======================= |
41 // ================= MEMBER FUNCTIONS ======================= |
39 |
42 |
40 // ----------------------------------------------------------- |
43 // ----------------------------------------------------------- |
41 // CPhoneUIController::CPhoneUIController |
44 // CPhoneUIController::CPhoneUIController |
50 // ----------------------------------------------------------- |
53 // ----------------------------------------------------------- |
51 // CPhoneUIController::ConstructL() |
54 // CPhoneUIController::ConstructL() |
52 // (other items were commented in a header). |
55 // (other items were commented in a header). |
53 // ----------------------------------------------------------- |
56 // ----------------------------------------------------------- |
54 // |
57 // |
55 void CPhoneUIController::ConstructL( |
58 void CPhoneUIController::ConstructL( CPhoneViewController& aViewController ) |
56 MPhoneViewCommandHandle* aViewCommandHandle ) |
|
57 { |
59 { |
58 __LOGMETHODSTARTEND(EPhoneControl, "CPhoneUIController::ConstructL()"); |
60 __LOGMETHODSTARTEND(EPhoneControl, "CPhoneUIController::ConstructL()"); |
59 // Creates correct protocol DLL |
61 // Creates correct protocol DLL |
60 CreateProtocolDllL( aViewCommandHandle ); |
62 CreateProtocolDllL( aViewController ); |
61 |
63 |
62 // Reference the phone state machine |
64 // Reference the phone state machine |
63 iStateMachine = CPhoneStateHandle::Instance()->StateMachine(); |
65 iStateMachine = CPhoneStateHandle::Instance()->StateMachine(); |
64 |
66 |
65 // Create the phone engine handler |
67 // Create the phone engine handler |
66 iEngineHandler = CPhoneEngineHandler::NewL( iStateMachine ); |
68 iEngineHandler = CPhoneEngineHandler::NewL( iStateMachine ); |
67 // Create the system event handler |
69 // Create the system event handler |
68 iSystemEventHandler = CPhoneSystemEventHandler::NewL( iStateMachine ); |
70 iSystemEventHandler = CPhoneSystemEventHandler::NewL( iStateMachine ); |
69 // Create the remote control handler |
71 |
70 iRemoteControlHandler = CPhoneRemoteControlHandler::NewL( iStateMachine ); |
72 // Create the key event forwarder |
|
73 iKeyEventForwarder = CPhoneKeyEventForwarder::NewL( |
|
74 CEikonEnv::Static()->EikAppUi()->ClientRect(), iStateMachine, &aViewController ); // codescanner::eikonenvstatic |
71 |
75 |
72 TInt leaveCode( 0 ); |
76 TInt leaveCode( 0 ); |
73 TInt retry( 0 ); |
77 TInt retry( 0 ); |
74 RTimer timer; |
78 RTimer timer; |
75 TRequestStatus timerReady; |
79 TRequestStatus timerReady; |
105 ( CCoeEnv::Static( KUidPhoneUILoggerSingleton ) ); |
109 ( CCoeEnv::Static( KUidPhoneUILoggerSingleton ) ); |
106 phoneLogger->SetPhoneEngine( iPhoneEngine ); |
110 phoneLogger->SetPhoneEngine( iPhoneEngine ); |
107 |
111 |
108 // Store the phone engine information in the state machine |
112 // Store the phone engine information in the state machine |
109 iStateMachine->SetPhoneEngine( iPhoneEngine ); |
113 iStateMachine->SetPhoneEngine( iPhoneEngine ); |
110 |
114 |
|
115 // Set up security mode observer. |
|
116 iSecurityModeObserver = CPhoneSecurityModeObserver::NewL(); |
|
117 iSecurityModeObserver->SetPhoneEngineInfo( iPhoneEngine->EngineInfo() ); |
|
118 iStateMachine->SetSecurityModeObserver( iSecurityModeObserver ); |
|
119 iStateMachine->SetSecurityMessageHandler( iSecurityModeObserver ); |
|
120 |
|
121 // Set Number Entry observer |
|
122 TPhoneCmdParamNumberEntryObserver cmdParamNumberEntryObserver; |
|
123 cmdParamNumberEntryObserver.SetObserver( TCallBack( HandlePhoneNumberEditorCallBack, this ) ); |
|
124 aViewController.ExecuteCommand( EPhoneViewSetNumberEntryObserver, |
|
125 &cmdParamNumberEntryObserver); |
|
126 |
|
127 // Set up controller to observe security mode state changes. |
|
128 iStateMachine->SecurityMode()->RegisterStateObserver( aViewController ); |
|
129 |
111 // Go to the startup state |
130 // Go to the startup state |
112 iStateMachine->ChangeState( EPhoneStateStartup ); |
131 iStateMachine->ChangeState( EPhoneStateStartup ); |
113 |
132 |
114 CPhoneMediatorFactory::Instance()->CommandListener( this, iStateMachine, |
133 CPhoneMediatorFactory::Instance()->CommandListener( this, iStateMachine, |
115 iStateMachine->PhoneEngineInfo() ); |
134 iStateMachine->PhoneEngineInfo() ); |
116 } |
135 } |
117 |
136 |
118 // ----------------------------------------------------------------------------- |
137 // ----------------------------------------------------------------------------- |
119 // CPhoneUIController::NewL |
138 // CPhoneUIController::NewL |
120 // Two-phased constructor. |
139 // Two-phased constructor. |
121 // ----------------------------------------------------------------------------- |
140 // ----------------------------------------------------------------------------- |
122 // |
141 // |
123 EXPORT_C CPhoneUIController* CPhoneUIController::NewL( |
142 EXPORT_C CPhoneUIController* CPhoneUIController::NewL( |
124 MPhoneViewCommandHandle* aViewCommandHandle ) |
143 CPhoneViewController& aViewCommandHandle ) |
125 { |
144 { |
126 __ASSERT_DEBUG( aViewCommandHandle, |
145 |
127 Panic( EPhoneCtrlParameterNotInitialized ) ); |
146 CPhoneUIController* self = new( ELeave ) CPhoneUIController(); |
128 |
|
129 CPhoneUIController* self = new( ELeave ) CPhoneUIController; |
|
130 |
147 |
131 CleanupStack::PushL( self ); |
148 CleanupStack::PushL( self ); |
132 self->ConstructL( aViewCommandHandle ); |
149 self->ConstructL( aViewCommandHandle ); |
133 CleanupStack::Pop( self ); |
150 CleanupStack::Pop( self ); |
134 |
151 |
141 // ----------------------------------------------------------- |
158 // ----------------------------------------------------------- |
142 |
159 |
143 EXPORT_C CPhoneUIController::~CPhoneUIController() |
160 EXPORT_C CPhoneUIController::~CPhoneUIController() |
144 { |
161 { |
145 __LOGMETHODSTARTEND(EPhoneControl, "CPhoneUIController::~CPhoneUIController()"); |
162 __LOGMETHODSTARTEND(EPhoneControl, "CPhoneUIController::~CPhoneUIController()"); |
146 delete iRemoteControlHandler; |
163 delete iSecurityModeObserver; |
147 delete iSystemEventHandler; |
164 delete iRemoteControlHandler; |
148 delete iEngineHandler; |
165 delete iSystemEventHandler; |
149 delete iStateHandle; |
166 delete iEngineHandler; |
|
167 delete iKeyEventForwarder; |
|
168 // delete iStateHandle; <-- CCoeStatic objects are destroyed outside application |
150 } |
169 } |
151 |
170 |
152 // --------------------------------------------------------- |
171 // --------------------------------------------------------- |
153 // CPhoneUIController::HandleMessage( TInt aMessage, TInt aCallId ) |
172 // CPhoneUIController::HandleMessage( TInt aMessage, TInt aCallId ) |
154 // --------------------------------------------------------- |
173 // --------------------------------------------------------- |
156 EXPORT_C void CPhoneUIController::HandleMessage( |
175 EXPORT_C void CPhoneUIController::HandleMessage( |
157 const TInt aMessage, |
176 const TInt aMessage, |
158 const TInt aCallId ) |
177 const TInt aCallId ) |
159 { |
178 { |
160 __PHONELOGENGINEMSG( aMessage, aCallId ); |
179 __PHONELOGENGINEMSG( aMessage, aCallId ); |
|
180 |
|
181 // PhoneCmdHandler is using Call information API so |
|
182 // Remote Control Handler can be constructed only after CCCE is constructed. |
|
183 if ( aMessage == EPEMessagePEConstructionReady ) |
|
184 { |
|
185 TRAP_IGNORE( ConstructRemoteControlHandlerL() ); |
|
186 } |
|
187 |
161 TRAPD( err, iEngineHandler->DoHandleMessageL( aMessage, aCallId ) ); |
188 TRAPD( err, iEngineHandler->DoHandleMessageL( aMessage, aCallId ) ); |
162 |
189 |
163 if ( err != KErrNone ) |
190 if ( err != KErrNone ) |
164 { |
191 { |
165 __PHONELOG2( |
192 __PHONELOG2( |
180 EXPORT_C void CPhoneUIController::HandleError( |
207 EXPORT_C void CPhoneUIController::HandleError( |
181 const TPEErrorInfo& aErrorInfo ) |
208 const TPEErrorInfo& aErrorInfo ) |
182 { |
209 { |
183 TInt err( KErrNone ); |
210 TInt err( KErrNone ); |
184 |
211 |
185 TRAP( err, iStateMachine->State()->HandleErrorL( aErrorInfo ) ); |
212 TRAP( err, iStateMachine->State()->HandleErrorL( aErrorInfo ) ); |
186 |
213 |
187 if( err != KErrNone ) |
214 if( err != KErrNone ) |
188 { |
215 { |
189 __PHONELOG1( |
216 __PHONELOG1( |
190 EOnlyFatal, |
217 EOnlyFatal, |
191 EPhoneControl, |
218 EPhoneControl, |
192 "PHONEUI_ERROR: CPhoneUIController::HandleError - leave (err=%d)", |
219 "PHONEUI_ERROR: CPhoneUIController::HandleError - leave (err=%d)", |
193 err); |
220 err); |
194 __ASSERT_DEBUG( EFalse, Panic( EPhoneCtrlUnknownPanic ) ); |
221 __ASSERT_DEBUG( EFalse, Panic( EPhoneCtrlUnknownPanic ) ); |
195 } |
222 } |
196 } |
223 } |
197 |
224 |
198 // --------------------------------------------------------- |
225 // --------------------------------------------------------- |
199 // CPhoneUIController::HandleKeyEventL |
226 // CPhoneUIController::HandleKeyEventL |
201 // |
228 // |
202 EXPORT_C TKeyResponse CPhoneUIController::HandleKeyEventL( |
229 EXPORT_C TKeyResponse CPhoneUIController::HandleKeyEventL( |
203 const TKeyEvent& aKeyEvent, |
230 const TKeyEvent& aKeyEvent, |
204 TEventCode aEventCode ) |
231 TEventCode aEventCode ) |
205 { |
232 { |
206 if ( aEventCode == EEventKey ) |
233 __ASSERT_DEBUG( iKeyEventForwarder, Panic( EPhoneCtrlInvariant ) ); |
207 { |
234 return iKeyEventForwarder->OfferKeyEventAfterControlStackL( |
208 iStateMachine->State()->HandleKeyMessageL( |
235 aKeyEvent, |
209 MPhoneKeyEvents::EPhoneKeyShortPress, |
236 aEventCode ); |
210 TKeyCode( aKeyEvent.iCode ) ); |
237 } |
211 |
238 |
212 iStateMachine->State()->HandleDtmfKeyToneL( aKeyEvent, aEventCode ); |
239 // --------------------------------------------------------- |
213 } |
240 // CPhoneUIController::DynInitMenuPaneL |
214 else if ( aEventCode == EEventLongPress ) |
241 // --------------------------------------------------------- |
215 { |
242 // |
216 iStateMachine->State()->HandleKeyMessageL( |
243 EXPORT_C void CPhoneUIController::DynInitMenuPaneL( |
217 MPhoneKeyEvents::EPhoneKeyLongPress, |
244 TInt aResourceId, |
218 TKeyCode( aKeyEvent.iCode ) ); |
245 CEikMenuPane* aMenuPane ) |
219 } |
246 { |
220 else |
247 __ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) ); |
221 { |
248 iSystemEventHandler->DynInitMenuPaneL( aResourceId, aMenuPane ); |
222 iStateMachine->State()->HandleDtmfKeyToneL( aKeyEvent, aEventCode ); |
249 } |
223 } |
250 |
224 |
251 // --------------------------------------------------------- |
225 return EKeyWasNotConsumed; |
252 // CPhoneUIController::DynInitMenuBarL |
|
253 // --------------------------------------------------------- |
|
254 // |
|
255 EXPORT_C void CPhoneUIController::DynInitMenuBarL( |
|
256 TInt aResourceId, |
|
257 CEikMenuBar* aMenuBar ) |
|
258 { |
|
259 __ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) ); |
|
260 iSystemEventHandler->DynInitMenuBarL( aResourceId, aMenuBar ); |
226 } |
261 } |
227 |
262 |
228 // --------------------------------------------------------- |
263 // --------------------------------------------------------- |
229 // CPhoneUIController::HandleSystemEventL |
264 // CPhoneUIController::HandleSystemEventL |
230 // --------------------------------------------------------- |
265 // --------------------------------------------------------- |
302 // |
337 // |
303 EXPORT_C TBool CPhoneUIController::HandleCommandL( TInt aCommand ) |
338 EXPORT_C TBool CPhoneUIController::HandleCommandL( TInt aCommand ) |
304 { |
339 { |
305 __ASSERT_DEBUG( iStateMachine->State(), Panic( EPhoneCtrlInvariant ) ); |
340 __ASSERT_DEBUG( iStateMachine->State(), Panic( EPhoneCtrlInvariant ) ); |
306 |
341 |
|
342 // Send key up message to engine so that we wouldn't accidentally play |
|
343 // any DTMF tone. |
|
344 |
|
345 // DTMF tone is not ended if command is EPhoneDialerValidNumber or |
|
346 // EPhoneDialerInvalidNumber. These commands result from |
|
347 // user pressing numbers, and they must not interfere with tones. |
|
348 if ( ! ( aCommand == EPhoneDialerValidNumber || aCommand == EPhoneDialerInvalidNumber ) ) |
|
349 { |
|
350 iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF ); |
|
351 } |
|
352 |
307 return iStateMachine->State()->HandleCommandL( aCommand ); |
353 return iStateMachine->State()->HandleCommandL( aCommand ); |
308 } |
354 } |
309 |
355 |
310 // --------------------------------------------------------- |
356 // --------------------------------------------------------- |
311 // CPhoneUIController::ProcessCommandL |
357 // CPhoneUIController::ProcessCommandL |
315 { |
361 { |
316 __ASSERT_DEBUG( iStateMachine->State(), Panic( EPhoneCtrlInvariant ) ); |
362 __ASSERT_DEBUG( iStateMachine->State(), Panic( EPhoneCtrlInvariant ) ); |
317 return iStateMachine->State()->ProcessCommandL( aCommand ); |
363 return iStateMachine->State()->ProcessCommandL( aCommand ); |
318 } |
364 } |
319 |
365 |
320 |
|
321 // --------------------------------------------------------- |
|
322 // CPhoneUIController::HandleKeyLockEnabled |
|
323 // --------------------------------------------------------- |
|
324 // |
|
325 EXPORT_C void CPhoneUIController::HandleKeyLockEnabled( TBool aKeylockEnabled ) |
|
326 { |
|
327 iSystemEventHandler->HandleKeyLockEnabled( aKeylockEnabled ); |
|
328 } |
|
329 |
|
330 // --------------------------------------------------------- |
366 // --------------------------------------------------------- |
331 // CPhoneUIController::CreateProtocolDllL |
367 // CPhoneUIController::CreateProtocolDllL |
332 // --------------------------------------------------------- |
368 // --------------------------------------------------------- |
333 // |
369 // |
334 void CPhoneUIController::CreateProtocolDllL( |
370 void CPhoneUIController::CreateProtocolDllL( CPhoneViewController& aViewController ) |
335 MPhoneViewCommandHandle* aViewCommandHandle ) |
371 { |
336 { |
372 TBool voipSupported( EFalse ); |
337 TBool voipSupported( EFalse ); |
|
338 |
373 |
339 if( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) ) |
374 if( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) ) |
340 { |
375 { |
341 TInt dynamicVoIP( KDynamicVoIPOff ); |
376 TInt dynamicVoIP( KDynamicVoIPOff ); |
342 CPhoneCenRepProxy::Instance()->GetInt( |
377 CPhoneCenRepProxy::Instance()->GetInt( |
343 KCRUidTelephonySettings, KDynamicVoIP, dynamicVoIP ); |
378 KCRUidTelephonySettings, KDynamicVoIP, dynamicVoIP ); |
344 |
379 |
345 if( dynamicVoIP == KDynamicVoIPOn ) |
380 if( dynamicVoIP == KDynamicVoIPOn ) |
346 { |
381 { |
347 voipSupported = ETrue; |
382 voipSupported = ETrue; |
348 } |
383 } |
349 } |
384 } |
350 |
385 |
351 if( voipSupported ) |
386 if( voipSupported ) |
352 { |
387 { |
353 iStateHandle = CPhoneStateHandle::CreateL( |
388 iStateHandle = CPhoneStateHandle::CreateL( |
354 aViewCommandHandle, |
389 &aViewController, |
355 KVoIPExtension, |
390 KVoIPExtension, |
356 KUidAppVoIPExtensionStates ); |
391 KUidAppVoIPExtensionStates ); |
357 } |
392 } |
358 else |
393 else |
359 { |
394 { |
360 iStateHandle = CPhoneStateHandle::CreateL( |
395 iStateHandle = CPhoneStateHandle::CreateL( |
361 aViewCommandHandle, |
396 &aViewController, |
362 KGSMProtocol, |
397 KGSMProtocol, |
363 KUidAppGSMStates ); |
398 KUidAppGSMStates ); |
364 } |
399 } |
365 } |
400 } |
366 |
401 |
367 // --------------------------------------------------------- |
402 // --------------------------------------------------------- |
368 // CPhoneUIController::HandlePhoneNumberEditorCallBack |
403 // CPhoneUIController::HandlePhoneNumberEditorCallBack |
369 // --------------------------------------------------------- |
404 // --------------------------------------------------------- |
370 // |
405 // |
382 // CPhoneUIController::DoHandlePhoneNumberEditorCallBack |
417 // CPhoneUIController::DoHandlePhoneNumberEditorCallBack |
383 // --------------------------------------------------------- |
418 // --------------------------------------------------------- |
384 // |
419 // |
385 void CPhoneUIController::DoHandlePhoneNumberEditorCallBack() |
420 void CPhoneUIController::DoHandlePhoneNumberEditorCallBack() |
386 { |
421 { |
|
422 iStateMachine->State()->HandleNumberEntryEdited(); |
|
423 } |
|
424 |
|
425 // --------------------------------------------------------- |
|
426 // CPhoneUIController::ConstructRemoteControlHandlerL |
|
427 // --------------------------------------------------------- |
|
428 // |
|
429 void CPhoneUIController::ConstructRemoteControlHandlerL() |
|
430 { |
|
431 // Create the remote control handler |
|
432 iRemoteControlHandler = CPhoneRemoteControlHandler::NewL( iStateMachine ); |
387 } |
433 } |
388 |
434 |
389 // End of File |
435 // End of File |