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