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 |
// Go to the startup state
|
|
112 |
iStateMachine->ChangeState( EPhoneStateStartup );
|
|
113 |
|
|
114 |
CPhoneMediatorFactory::Instance()->CommandListener( this, iStateMachine,
|
|
115 |
iStateMachine->PhoneEngineInfo() );
|
|
116 |
}
|
|
117 |
|
|
118 |
// -----------------------------------------------------------------------------
|
|
119 |
// CPhoneUIController::NewL
|
|
120 |
// Two-phased constructor.
|
|
121 |
// -----------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
EXPORT_C CPhoneUIController* CPhoneUIController::NewL(
|
|
124 |
MPhoneViewCommandHandle* aViewCommandHandle )
|
|
125 |
{
|
|
126 |
__ASSERT_DEBUG( aViewCommandHandle,
|
|
127 |
Panic( EPhoneCtrlParameterNotInitialized ) );
|
|
128 |
|
|
129 |
CPhoneUIController* self = new( ELeave ) CPhoneUIController;
|
|
130 |
|
|
131 |
CleanupStack::PushL( self );
|
|
132 |
self->ConstructL( aViewCommandHandle );
|
|
133 |
CleanupStack::Pop( self );
|
|
134 |
|
|
135 |
return self;
|
|
136 |
}
|
|
137 |
|
|
138 |
// -----------------------------------------------------------
|
|
139 |
// Destructor
|
|
140 |
//
|
|
141 |
// -----------------------------------------------------------
|
|
142 |
|
|
143 |
EXPORT_C CPhoneUIController::~CPhoneUIController()
|
|
144 |
{
|
|
145 |
__LOGMETHODSTARTEND(EPhoneControl, "CPhoneUIController::~CPhoneUIController()");
|
|
146 |
delete iRemoteControlHandler;
|
|
147 |
delete iSystemEventHandler;
|
|
148 |
delete iEngineHandler;
|
|
149 |
delete iStateHandle;
|
|
150 |
}
|
|
151 |
|
|
152 |
// ---------------------------------------------------------
|
|
153 |
// CPhoneUIController::HandleMessage( TInt aMessage, TInt aCallId )
|
|
154 |
// ---------------------------------------------------------
|
|
155 |
//
|
|
156 |
EXPORT_C void CPhoneUIController::HandleMessage(
|
|
157 |
const TInt aMessage,
|
|
158 |
const TInt aCallId )
|
|
159 |
{
|
|
160 |
__PHONELOGENGINEMSG( aMessage, aCallId );
|
|
161 |
TRAPD( err, iEngineHandler->DoHandleMessageL( aMessage, aCallId ) );
|
|
162 |
|
|
163 |
if ( err != KErrNone )
|
|
164 |
{
|
|
165 |
__PHONELOG2(
|
|
166 |
EOnlyFatal,
|
|
167 |
EPhoneControl,
|
|
168 |
"PHONEUI_ERROR: CPhoneUIController::HandleMessage - Message received in unexpected state (aMessage=%d, err=%d)",
|
|
169 |
aMessage,
|
|
170 |
err);
|
|
171 |
}
|
|
172 |
|
|
173 |
__PHONELOGENGINEMSGEND( aMessage );
|
|
174 |
}
|
|
175 |
|
|
176 |
// ---------------------------------------------------------
|
|
177 |
// CPhoneUIController::HandleError( const TPEErrorInfo& aErrorInfo )
|
|
178 |
// ---------------------------------------------------------
|
|
179 |
//
|
|
180 |
EXPORT_C void CPhoneUIController::HandleError(
|
|
181 |
const TPEErrorInfo& aErrorInfo )
|
|
182 |
{
|
|
183 |
TInt err( KErrNone );
|
|
184 |
|
|
185 |
TRAP( err, iStateMachine->State()->HandleErrorL( aErrorInfo ) );
|
|
186 |
|
|
187 |
if( err != KErrNone )
|
|
188 |
{
|
|
189 |
__PHONELOG1(
|
|
190 |
EOnlyFatal,
|
|
191 |
EPhoneControl,
|
|
192 |
"PHONEUI_ERROR: CPhoneUIController::HandleError - leave (err=%d)",
|
|
193 |
err);
|
|
194 |
__ASSERT_DEBUG( EFalse, Panic( EPhoneCtrlUnknownPanic ) );
|
|
195 |
}
|
|
196 |
}
|
|
197 |
|
|
198 |
// ---------------------------------------------------------
|
|
199 |
// CPhoneUIController::HandleKeyEventL
|
|
200 |
// ---------------------------------------------------------
|
|
201 |
//
|
|
202 |
EXPORT_C TKeyResponse CPhoneUIController::HandleKeyEventL(
|
|
203 |
const TKeyEvent& aKeyEvent,
|
|
204 |
TEventCode aEventCode )
|
|
205 |
{
|
|
206 |
if ( aEventCode == EEventKey )
|
|
207 |
{
|
|
208 |
iStateMachine->State()->HandleKeyMessageL(
|
|
209 |
MPhoneKeyEvents::EPhoneKeyShortPress,
|
|
210 |
TKeyCode( aKeyEvent.iCode ) );
|
|
211 |
|
|
212 |
iStateMachine->State()->HandleDtmfKeyToneL( aKeyEvent, aEventCode );
|
|
213 |
}
|
|
214 |
else if ( aEventCode == EEventLongPress )
|
|
215 |
{
|
|
216 |
iStateMachine->State()->HandleKeyMessageL(
|
|
217 |
MPhoneKeyEvents::EPhoneKeyLongPress,
|
|
218 |
TKeyCode( aKeyEvent.iCode ) );
|
|
219 |
}
|
|
220 |
else
|
|
221 |
{
|
|
222 |
iStateMachine->State()->HandleDtmfKeyToneL( aKeyEvent, aEventCode );
|
|
223 |
}
|
|
224 |
|
|
225 |
return EKeyWasNotConsumed;
|
|
226 |
}
|
|
227 |
|
|
228 |
// ---------------------------------------------------------
|
|
229 |
// CPhoneUIController::HandleSystemEventL
|
|
230 |
// ---------------------------------------------------------
|
|
231 |
//
|
|
232 |
EXPORT_C void CPhoneUIController::HandleSystemEventL( const TWsEvent& aEvent )
|
|
233 |
{
|
|
234 |
__ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) );
|
|
235 |
iSystemEventHandler->HandleSystemEventL( aEvent );
|
|
236 |
}
|
|
237 |
|
|
238 |
// ---------------------------------------------------------
|
|
239 |
// CPhoneUIController::HandleForegroundEventL
|
|
240 |
// ---------------------------------------------------------
|
|
241 |
//
|
|
242 |
EXPORT_C void CPhoneUIController::HandleForegroundEventL( TBool aForeground )
|
|
243 |
{
|
|
244 |
__ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) );
|
|
245 |
iSystemEventHandler->HandleForegroundEventL( aForeground );
|
|
246 |
}
|
|
247 |
|
|
248 |
// ---------------------------------------------------------
|
|
249 |
// CPhoneUIController::HandlePhoneForegroundEventL
|
|
250 |
// ---------------------------------------------------------
|
|
251 |
//
|
|
252 |
EXPORT_C void CPhoneUIController::HandlePhoneForegroundEventL()
|
|
253 |
{
|
|
254 |
__ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) );
|
|
255 |
iSystemEventHandler->HandlePhoneForegroundEventL();
|
|
256 |
}
|
|
257 |
|
|
258 |
// ---------------------------------------------------------
|
|
259 |
// CPhoneUIController::HandlePhoneFocusLostEventL
|
|
260 |
// ---------------------------------------------------------
|
|
261 |
//
|
|
262 |
EXPORT_C void CPhoneUIController::HandlePhoneFocusLostEventL()
|
|
263 |
{
|
|
264 |
__ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) );
|
|
265 |
iSystemEventHandler->HandlePhoneFocusLostEventL();
|
|
266 |
}
|
|
267 |
|
|
268 |
// ---------------------------------------------------------
|
|
269 |
// CPhoneUIController::HandleIdleForegroundEventL
|
|
270 |
// ---------------------------------------------------------
|
|
271 |
//
|
|
272 |
EXPORT_C void CPhoneUIController::HandleIdleForegroundEventL()
|
|
273 |
{
|
|
274 |
__ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) );
|
|
275 |
iSystemEventHandler->HandleIdleForegroundEventL();
|
|
276 |
}
|
|
277 |
|
|
278 |
// ---------------------------------------------------------
|
|
279 |
// CPhoneUIController::HandlePhoneStartupL
|
|
280 |
// ---------------------------------------------------------
|
|
281 |
//
|
|
282 |
EXPORT_C void CPhoneUIController::HandlePhoneStartupL()
|
|
283 |
{
|
|
284 |
__ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) );
|
|
285 |
iSystemEventHandler->HandlePhoneStartupL();
|
|
286 |
}
|
|
287 |
|
|
288 |
// ---------------------------------------------------------
|
|
289 |
// CPhoneUIController::HandleCommandL
|
|
290 |
// ---------------------------------------------------------
|
|
291 |
//
|
|
292 |
EXPORT_C TBool CPhoneUIController::HandleCommandL( TInt aCommand )
|
|
293 |
{
|
|
294 |
__ASSERT_DEBUG( iStateMachine->State(), Panic( EPhoneCtrlInvariant ) );
|
|
295 |
|
|
296 |
return iStateMachine->State()->HandleCommandL( aCommand );
|
|
297 |
}
|
|
298 |
|
|
299 |
// ---------------------------------------------------------
|
|
300 |
// CPhoneUIController::ProcessCommandL
|
|
301 |
// ---------------------------------------------------------
|
|
302 |
//
|
|
303 |
EXPORT_C TBool CPhoneUIController::ProcessCommandL( TInt aCommand )
|
|
304 |
{
|
|
305 |
__ASSERT_DEBUG( iStateMachine->State(), Panic( EPhoneCtrlInvariant ) );
|
|
306 |
return iStateMachine->State()->ProcessCommandL( aCommand );
|
|
307 |
}
|
|
308 |
|
|
309 |
|
|
310 |
// ---------------------------------------------------------
|
|
311 |
// CPhoneUIController::HandleKeyLockEnabled
|
|
312 |
// ---------------------------------------------------------
|
|
313 |
//
|
|
314 |
EXPORT_C void CPhoneUIController::HandleKeyLockEnabled( TBool aKeylockEnabled )
|
|
315 |
{
|
|
316 |
iSystemEventHandler->HandleKeyLockEnabled( aKeylockEnabled );
|
|
317 |
}
|
|
318 |
|
|
319 |
// ---------------------------------------------------------
|
|
320 |
// CPhoneUIController::CreateProtocolDllL
|
|
321 |
// ---------------------------------------------------------
|
|
322 |
//
|
|
323 |
void CPhoneUIController::CreateProtocolDllL(
|
|
324 |
MPhoneViewCommandHandle* aViewCommandHandle )
|
|
325 |
{
|
|
326 |
TBool voipSupported( EFalse );
|
|
327 |
|
|
328 |
if( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
|
|
329 |
{
|
|
330 |
TInt dynamicVoIP( KDynamicVoIPOff );
|
|
331 |
CPhoneCenRepProxy::Instance()->GetInt(
|
|
332 |
KCRUidTelephonySettings, KDynamicVoIP, dynamicVoIP );
|
|
333 |
|
|
334 |
if( dynamicVoIP == KDynamicVoIPOn )
|
|
335 |
{
|
|
336 |
voipSupported = ETrue;
|
|
337 |
}
|
|
338 |
}
|
|
339 |
|
|
340 |
if( voipSupported )
|
|
341 |
{
|
|
342 |
iStateHandle = CPhoneStateHandle::CreateL(
|
|
343 |
aViewCommandHandle,
|
|
344 |
KVoIPExtension,
|
|
345 |
KUidAppVoIPExtensionStates );
|
|
346 |
}
|
|
347 |
else
|
|
348 |
{
|
|
349 |
iStateHandle = CPhoneStateHandle::CreateL(
|
|
350 |
aViewCommandHandle,
|
|
351 |
KGSMProtocol,
|
|
352 |
KUidAppGSMStates );
|
|
353 |
}
|
|
354 |
}
|
|
355 |
|
|
356 |
// ---------------------------------------------------------
|
|
357 |
// CPhoneUIController::HandlePhoneNumberEditorCallBack
|
|
358 |
// ---------------------------------------------------------
|
|
359 |
//
|
|
360 |
TInt CPhoneUIController::HandlePhoneNumberEditorCallBack( TAny* aAny )
|
|
361 |
{
|
|
362 |
CPhoneUIController* aPhoneUiController =
|
|
363 |
static_cast< CPhoneUIController* >( aAny );
|
|
364 |
|
|
365 |
aPhoneUiController->DoHandlePhoneNumberEditorCallBack();
|
|
366 |
|
|
367 |
return 0;
|
|
368 |
}
|
|
369 |
|
|
370 |
// ---------------------------------------------------------
|
|
371 |
// CPhoneUIController::DoHandlePhoneNumberEditorCallBack
|
|
372 |
// ---------------------------------------------------------
|
|
373 |
//
|
|
374 |
void CPhoneUIController::DoHandlePhoneNumberEditorCallBack()
|
|
375 |
{
|
|
376 |
}
|
|
377 |
|
|
378 |
// End of File
|