37
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 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: Implementation of CPhoneUIController class.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <featmgr.h> // for FeatureManager
|
|
21 |
#include <settingsinternalcrkeys.h>
|
|
22 |
|
|
23 |
#include "cphoneuicontroller.h"
|
|
24 |
#include "pevirtualengine.h"
|
|
25 |
#include "cphonestatehandle.h"
|
|
26 |
#include "cphoneenginehandler.h"
|
|
27 |
#include "cphonesystemeventhandler.h"
|
|
28 |
#include "cphoneremotecontrolhandler.h"
|
|
29 |
#include "mphoneviewcommandhandle.h"
|
|
30 |
#include "phonestatedefinitions.h"
|
|
31 |
#include "phonelogger.h"
|
|
32 |
#include "phoneconstants.h"
|
|
33 |
#include "phoneui.pan"
|
|
34 |
#include "cphonecenrepproxy.h"
|
|
35 |
#include "cphonemediatorfactory.h"
|
|
36 |
#include "tphonecmdparamnumberentryobserver.h"
|
|
37 |
|
|
38 |
// ================= MEMBER FUNCTIONS =======================
|
|
39 |
|
|
40 |
// -----------------------------------------------------------
|
|
41 |
// CPhoneUIController::CPhoneUIController
|
|
42 |
// C++ default constructor can NOT contain any code, that
|
|
43 |
// might leave.
|
|
44 |
// -----------------------------------------------------------
|
|
45 |
//
|
|
46 |
CPhoneUIController::CPhoneUIController()
|
|
47 |
{
|
|
48 |
}
|
|
49 |
|
|
50 |
// -----------------------------------------------------------
|
|
51 |
// CPhoneUIController::ConstructL()
|
|
52 |
// (other items were commented in a header).
|
|
53 |
// -----------------------------------------------------------
|
|
54 |
//
|
|
55 |
void CPhoneUIController::ConstructL(
|
|
56 |
MPhoneViewCommandHandle* aViewCommandHandle )
|
|
57 |
{
|
|
58 |
__LOGMETHODSTARTEND(EPhoneControl, "CPhoneUIController::ConstructL()");
|
|
59 |
// Creates correct protocol DLL
|
|
60 |
CreateProtocolDllL( aViewCommandHandle );
|
|
61 |
|
|
62 |
// Reference the phone state machine
|
|
63 |
iStateMachine = CPhoneStateHandle::Instance()->StateMachine();
|
|
64 |
|
|
65 |
// Create the phone engine handler
|
|
66 |
iEngineHandler = CPhoneEngineHandler::NewL( iStateMachine );
|
|
67 |
// Create the system event handler
|
|
68 |
iSystemEventHandler = CPhoneSystemEventHandler::NewL( iStateMachine );
|
|
69 |
// Create the remote control handler
|
|
70 |
iRemoteControlHandler = CPhoneRemoteControlHandler::NewL( iStateMachine );
|
|
71 |
|
|
72 |
TInt leaveCode( 0 );
|
|
73 |
TInt retry( 0 );
|
|
74 |
RTimer timer;
|
|
75 |
TRequestStatus timerReady;
|
|
76 |
timer.CreateLocal();
|
|
77 |
// Phone Engine is tried to start for KPeRetryCount times
|
|
78 |
do
|
|
79 |
{
|
|
80 |
// Handle the message and trap leaves from message handling functions
|
|
81 |
TRAP( leaveCode, iPhoneEngine = iStateMachine->CreatePhoneEngineL(
|
|
82 |
*this ) );
|
|
83 |
|
|
84 |
if ( leaveCode )
|
|
85 |
{
|
|
86 |
// This thread is suspended for KPeRetryDelay
|
|
87 |
timer.After( timerReady, KPeRetryDelay );
|
|
88 |
User::WaitForRequest( timerReady );
|
|
89 |
retry++;
|
|
90 |
}
|
|
91 |
}while ( leaveCode && retry < KPeRetryCount );
|
|
92 |
timer.Close();
|
|
93 |
|
|
94 |
if ( leaveCode )
|
|
95 |
{
|
|
96 |
// If Phone Engine didn't start
|
|
97 |
User::Leave( leaveCode );
|
|
98 |
}
|
|
99 |
|
|
100 |
// Get the engine info
|
|
101 |
iEngineInfo = iPhoneEngine->EngineInfo();
|
|
102 |
|
|
103 |
// Store the phone engine information in the logger
|
|
104 |
CPhoneLogger* phoneLogger = static_cast<CPhoneLogger*>
|
|
105 |
( CCoeEnv::Static( KUidPhoneUILoggerSingleton ) );
|
|
106 |
phoneLogger->SetPhoneEngine( iPhoneEngine );
|
|
107 |
|
|
108 |
// Store the phone engine information in the state machine
|
|
109 |
iStateMachine->SetPhoneEngine( iPhoneEngine );
|
|
110 |
|
|
111 |
// Set Number Entry observer
|
|
112 |
TPhoneCmdParamNumberEntryObserver cmdParamNumberEntryObserver;
|
|
113 |
cmdParamNumberEntryObserver.SetObserver( TCallBack( HandlePhoneNumberEditorCallBack, this ) );
|
|
114 |
aViewCommandHandle->ExecuteCommand( EPhoneViewSetNumberEntryObserver,
|
|
115 |
&cmdParamNumberEntryObserver);
|
|
116 |
|
|
117 |
// Go to the startup state
|
|
118 |
iStateMachine->ChangeState( EPhoneStateStartup );
|
|
119 |
|
|
120 |
CPhoneMediatorFactory::Instance()->CommandListener( this, iStateMachine,
|
|
121 |
iStateMachine->PhoneEngineInfo() );
|
|
122 |
}
|
|
123 |
|
|
124 |
// -----------------------------------------------------------------------------
|
|
125 |
// CPhoneUIController::NewL
|
|
126 |
// Two-phased constructor.
|
|
127 |
// -----------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
EXPORT_C CPhoneUIController* CPhoneUIController::NewL(
|
|
130 |
MPhoneViewCommandHandle* aViewCommandHandle )
|
|
131 |
{
|
|
132 |
__ASSERT_DEBUG( aViewCommandHandle,
|
|
133 |
Panic( EPhoneCtrlParameterNotInitialized ) );
|
|
134 |
|
|
135 |
CPhoneUIController* self = new( ELeave ) CPhoneUIController;
|
|
136 |
|
|
137 |
CleanupStack::PushL( self );
|
|
138 |
self->ConstructL( aViewCommandHandle );
|
|
139 |
CleanupStack::Pop( self );
|
|
140 |
|
|
141 |
return self;
|
|
142 |
}
|
|
143 |
|
|
144 |
// -----------------------------------------------------------
|
|
145 |
// Destructor
|
|
146 |
//
|
|
147 |
// -----------------------------------------------------------
|
|
148 |
|
|
149 |
EXPORT_C CPhoneUIController::~CPhoneUIController()
|
|
150 |
{
|
|
151 |
__LOGMETHODSTARTEND(EPhoneControl, "CPhoneUIController::~CPhoneUIController()");
|
|
152 |
delete iRemoteControlHandler;
|
|
153 |
delete iSystemEventHandler;
|
|
154 |
delete iEngineHandler;
|
|
155 |
delete iStateHandle;
|
|
156 |
}
|
|
157 |
|
|
158 |
// ---------------------------------------------------------
|
|
159 |
// CPhoneUIController::HandleMessage( TInt aMessage, TInt aCallId )
|
|
160 |
// ---------------------------------------------------------
|
|
161 |
//
|
|
162 |
EXPORT_C void CPhoneUIController::HandleMessage(
|
|
163 |
const TInt aMessage,
|
|
164 |
const TInt aCallId )
|
|
165 |
{
|
|
166 |
__PHONELOGENGINEMSG( aMessage, aCallId );
|
|
167 |
TRAPD( err, iEngineHandler->DoHandleMessageL( aMessage, aCallId ) );
|
|
168 |
|
|
169 |
if ( err != KErrNone )
|
|
170 |
{
|
|
171 |
__PHONELOG2(
|
|
172 |
EOnlyFatal,
|
|
173 |
EPhoneControl,
|
|
174 |
"PHONEUI_ERROR: CPhoneUIController::HandleMessage - Message received in unexpected state (aMessage=%d, err=%d)",
|
|
175 |
aMessage,
|
|
176 |
err);
|
|
177 |
}
|
|
178 |
|
|
179 |
__PHONELOGENGINEMSGEND( aMessage );
|
|
180 |
}
|
|
181 |
|
|
182 |
// ---------------------------------------------------------
|
|
183 |
// CPhoneUIController::HandleError( const TPEErrorInfo& aErrorInfo )
|
|
184 |
// ---------------------------------------------------------
|
|
185 |
//
|
|
186 |
EXPORT_C void CPhoneUIController::HandleError(
|
|
187 |
const TPEErrorInfo& aErrorInfo )
|
|
188 |
{
|
|
189 |
TInt err( KErrNone );
|
|
190 |
|
|
191 |
TRAP( err, iStateMachine->State()->HandleErrorL( aErrorInfo ) );
|
|
192 |
|
|
193 |
if( err != KErrNone )
|
|
194 |
{
|
|
195 |
__PHONELOG1(
|
|
196 |
EOnlyFatal,
|
|
197 |
EPhoneControl,
|
|
198 |
"PHONEUI_ERROR: CPhoneUIController::HandleError - leave (err=%d)",
|
|
199 |
err);
|
|
200 |
__ASSERT_DEBUG( EFalse, Panic( EPhoneCtrlUnknownPanic ) );
|
|
201 |
}
|
|
202 |
}
|
|
203 |
|
|
204 |
// ---------------------------------------------------------
|
|
205 |
// CPhoneUIController::HandleKeyEventL
|
|
206 |
// ---------------------------------------------------------
|
|
207 |
//
|
|
208 |
EXPORT_C TKeyResponse CPhoneUIController::HandleKeyEventL(
|
|
209 |
const TKeyEvent& aKeyEvent,
|
|
210 |
TEventCode aEventCode )
|
|
211 |
{
|
|
212 |
if ( aEventCode == EEventKey )
|
|
213 |
{
|
|
214 |
iStateMachine->State()->HandleKeyMessageL(
|
|
215 |
MPhoneKeyEvents::EPhoneKeyShortPress,
|
|
216 |
TKeyCode( aKeyEvent.iCode ) );
|
|
217 |
|
|
218 |
iStateMachine->State()->HandleDtmfKeyToneL( aKeyEvent, aEventCode );
|
|
219 |
}
|
|
220 |
else if ( aEventCode == EEventLongPress )
|
|
221 |
{
|
|
222 |
iStateMachine->State()->HandleKeyMessageL(
|
|
223 |
MPhoneKeyEvents::EPhoneKeyLongPress,
|
|
224 |
TKeyCode( aKeyEvent.iCode ) );
|
|
225 |
}
|
|
226 |
else
|
|
227 |
{
|
|
228 |
iStateMachine->State()->HandleDtmfKeyToneL( aKeyEvent, aEventCode );
|
|
229 |
}
|
|
230 |
|
|
231 |
|
|
232 |
|
|
233 |
return EKeyWasNotConsumed;
|
|
234 |
}
|
|
235 |
|
|
236 |
// ---------------------------------------------------------
|
|
237 |
// CPhoneUIController::DynInitMenuPaneL
|
|
238 |
// ---------------------------------------------------------
|
|
239 |
//
|
|
240 |
EXPORT_C void CPhoneUIController::DynInitMenuPaneL(
|
|
241 |
TInt aResourceId,
|
|
242 |
CEikMenuPane* aMenuPane )
|
|
243 |
{
|
|
244 |
__ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) );
|
|
245 |
iSystemEventHandler->DynInitMenuPaneL( aResourceId, aMenuPane );
|
|
246 |
}
|
|
247 |
|
|
248 |
// ---------------------------------------------------------
|
|
249 |
// CPhoneUIController::DynInitMenuBarL
|
|
250 |
// ---------------------------------------------------------
|
|
251 |
//
|
|
252 |
EXPORT_C void CPhoneUIController::DynInitMenuBarL(
|
|
253 |
TInt aResourceId,
|
|
254 |
CEikMenuBar* aMenuBar )
|
|
255 |
{
|
|
256 |
__ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) );
|
|
257 |
iSystemEventHandler->DynInitMenuBarL( aResourceId, aMenuBar );
|
|
258 |
}
|
|
259 |
|
|
260 |
// ---------------------------------------------------------
|
|
261 |
// CPhoneUIController::HandleSystemEventL
|
|
262 |
// ---------------------------------------------------------
|
|
263 |
//
|
|
264 |
EXPORT_C void CPhoneUIController::HandleSystemEventL( const TWsEvent& aEvent )
|
|
265 |
{
|
|
266 |
__ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) );
|
|
267 |
iSystemEventHandler->HandleSystemEventL( aEvent );
|
|
268 |
}
|
|
269 |
|
|
270 |
// ---------------------------------------------------------
|
|
271 |
// CPhoneUIController::HandleForegroundEventL
|
|
272 |
// ---------------------------------------------------------
|
|
273 |
//
|
|
274 |
EXPORT_C void CPhoneUIController::HandleForegroundEventL( TBool aForeground )
|
|
275 |
{
|
|
276 |
__ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) );
|
|
277 |
iSystemEventHandler->HandleForegroundEventL( aForeground );
|
|
278 |
}
|
|
279 |
|
|
280 |
// ---------------------------------------------------------
|
|
281 |
// CPhoneUIController::HandlePhoneForegroundEventL
|
|
282 |
// ---------------------------------------------------------
|
|
283 |
//
|
|
284 |
EXPORT_C void CPhoneUIController::HandlePhoneForegroundEventL()
|
|
285 |
{
|
|
286 |
__ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) );
|
|
287 |
iSystemEventHandler->HandlePhoneForegroundEventL();
|
|
288 |
}
|
|
289 |
|
|
290 |
// ---------------------------------------------------------
|
|
291 |
// CPhoneUIController::HandlePhoneFocusLostEventL
|
|
292 |
// ---------------------------------------------------------
|
|
293 |
//
|
|
294 |
EXPORT_C void CPhoneUIController::HandlePhoneFocusLostEventL()
|
|
295 |
{
|
|
296 |
__ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) );
|
|
297 |
iSystemEventHandler->HandlePhoneFocusLostEventL();
|
|
298 |
}
|
|
299 |
|
|
300 |
// ---------------------------------------------------------
|
|
301 |
// CPhoneUIController::HandleIdleForegroundEventL
|
|
302 |
// ---------------------------------------------------------
|
|
303 |
//
|
|
304 |
EXPORT_C void CPhoneUIController::HandleIdleForegroundEventL()
|
|
305 |
{
|
|
306 |
__ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) );
|
|
307 |
iSystemEventHandler->HandleIdleForegroundEventL();
|
|
308 |
}
|
|
309 |
|
|
310 |
// ---------------------------------------------------------
|
|
311 |
// CPhoneUIController::HandleEnvironmentChangeL
|
|
312 |
// ---------------------------------------------------------
|
|
313 |
//
|
|
314 |
EXPORT_C void CPhoneUIController::HandleEnvironmentChangeL(
|
|
315 |
const TInt aChanges )
|
|
316 |
{
|
|
317 |
__ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) );
|
|
318 |
iSystemEventHandler->HandleEnvironmentChangeL( aChanges );
|
|
319 |
}
|
|
320 |
|
|
321 |
// ---------------------------------------------------------
|
|
322 |
// CPhoneUIController::HandlePhoneStartupL
|
|
323 |
// ---------------------------------------------------------
|
|
324 |
//
|
|
325 |
EXPORT_C void CPhoneUIController::HandlePhoneStartupL()
|
|
326 |
{
|
|
327 |
__ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) );
|
|
328 |
iSystemEventHandler->HandlePhoneStartupL();
|
|
329 |
}
|
|
330 |
|
|
331 |
// ---------------------------------------------------------
|
|
332 |
// CPhoneUIController::HandleCommandL
|
|
333 |
// ---------------------------------------------------------
|
|
334 |
//
|
|
335 |
EXPORT_C TBool CPhoneUIController::HandleCommandL( TInt aCommand )
|
|
336 |
{
|
|
337 |
__ASSERT_DEBUG( iStateMachine->State(), Panic( EPhoneCtrlInvariant ) );
|
|
338 |
|
|
339 |
return iStateMachine->State()->HandleCommandL( aCommand );
|
|
340 |
}
|
|
341 |
|
|
342 |
// ---------------------------------------------------------
|
|
343 |
// CPhoneUIController::ProcessCommandL
|
|
344 |
// ---------------------------------------------------------
|
|
345 |
//
|
|
346 |
EXPORT_C TBool CPhoneUIController::ProcessCommandL( TInt aCommand )
|
|
347 |
{
|
|
348 |
__ASSERT_DEBUG( iStateMachine->State(), Panic( EPhoneCtrlInvariant ) );
|
|
349 |
return iStateMachine->State()->ProcessCommandL( aCommand );
|
|
350 |
}
|
|
351 |
|
|
352 |
|
|
353 |
// ---------------------------------------------------------
|
|
354 |
// CPhoneUIController::HandleKeyLockEnabled
|
|
355 |
// ---------------------------------------------------------
|
|
356 |
//
|
|
357 |
EXPORT_C void CPhoneUIController::HandleKeyLockEnabled( TBool aKeylockEnabled )
|
|
358 |
{
|
|
359 |
iSystemEventHandler->HandleKeyLockEnabled( aKeylockEnabled );
|
|
360 |
}
|
|
361 |
|
|
362 |
// ---------------------------------------------------------
|
|
363 |
// CPhoneUIController::CreateProtocolDllL
|
|
364 |
// ---------------------------------------------------------
|
|
365 |
//
|
|
366 |
void CPhoneUIController::CreateProtocolDllL(
|
|
367 |
MPhoneViewCommandHandle* aViewCommandHandle )
|
|
368 |
{
|
|
369 |
TBool voipSupported( EFalse );
|
|
370 |
|
|
371 |
if( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
|
|
372 |
{
|
|
373 |
TInt dynamicVoIP( KDynamicVoIPOff );
|
|
374 |
CPhoneCenRepProxy::Instance()->GetInt(
|
|
375 |
KCRUidTelephonySettings, KDynamicVoIP, dynamicVoIP );
|
|
376 |
|
|
377 |
if( dynamicVoIP == KDynamicVoIPOn )
|
|
378 |
{
|
|
379 |
voipSupported = ETrue;
|
|
380 |
}
|
|
381 |
}
|
|
382 |
|
|
383 |
if( voipSupported )
|
|
384 |
{
|
|
385 |
iStateHandle = CPhoneStateHandle::CreateL(
|
|
386 |
aViewCommandHandle,
|
|
387 |
KVoIPExtension,
|
|
388 |
KUidAppVoIPExtensionStates );
|
|
389 |
}
|
|
390 |
else
|
|
391 |
{
|
|
392 |
iStateHandle = CPhoneStateHandle::CreateL(
|
|
393 |
aViewCommandHandle,
|
|
394 |
KGSMProtocol,
|
|
395 |
KUidAppGSMStates );
|
|
396 |
}
|
|
397 |
}
|
|
398 |
|
|
399 |
// ---------------------------------------------------------
|
|
400 |
// CPhoneUIController::HandlePhoneNumberEditorCallBack
|
|
401 |
// ---------------------------------------------------------
|
|
402 |
//
|
|
403 |
TInt CPhoneUIController::HandlePhoneNumberEditorCallBack( TAny* aAny )
|
|
404 |
{
|
|
405 |
CPhoneUIController* aPhoneUiController =
|
|
406 |
static_cast< CPhoneUIController* >( aAny );
|
|
407 |
|
|
408 |
aPhoneUiController->DoHandlePhoneNumberEditorCallBack();
|
|
409 |
|
|
410 |
return 0;
|
|
411 |
}
|
|
412 |
|
|
413 |
// ---------------------------------------------------------
|
|
414 |
// CPhoneUIController::DoHandlePhoneNumberEditorCallBack
|
|
415 |
// ---------------------------------------------------------
|
|
416 |
//
|
|
417 |
void CPhoneUIController::DoHandlePhoneNumberEditorCallBack()
|
|
418 |
{
|
|
419 |
iStateMachine->State()->HandleNumberEntryEdited();
|
|
420 |
}
|
|
421 |
|
|
422 |
// End of File
|