author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 00:16:48 +0300 | |
changeset 77 | 2be0b271d017 |
parent 72 | c76a0b1755b9 |
permissions | -rw-r--r-- |
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::HandlePhoneStartupL |
|
230 |
// --------------------------------------------------------- |
|
231 |
// |
|
232 |
EXPORT_C void CPhoneUIController::HandlePhoneStartupL() |
|
233 |
{ |
|
234 |
__ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) ); |
|
235 |
iSystemEventHandler->HandlePhoneStartupL(); |
|
236 |
} |
|
237 |
||
238 |
// --------------------------------------------------------- |
|
239 |
// CPhoneUIController::HandleCommandL |
|
240 |
// --------------------------------------------------------- |
|
241 |
// |
|
242 |
EXPORT_C TBool CPhoneUIController::HandleCommandL( TInt aCommand ) |
|
243 |
{ |
|
244 |
__ASSERT_DEBUG( iStateMachine->State(), Panic( EPhoneCtrlInvariant ) ); |
|
245 |
||
246 |
return iStateMachine->State()->HandleCommandL( aCommand ); |
|
247 |
} |
|
248 |
||
249 |
// --------------------------------------------------------- |
|
250 |
// CPhoneUIController::ProcessCommandL |
|
251 |
// --------------------------------------------------------- |
|
252 |
// |
|
253 |
EXPORT_C TBool CPhoneUIController::ProcessCommandL( TInt aCommand ) |
|
254 |
{ |
|
255 |
__ASSERT_DEBUG( iStateMachine->State(), Panic( EPhoneCtrlInvariant ) ); |
|
256 |
return iStateMachine->State()->ProcessCommandL( aCommand ); |
|
257 |
} |
|
258 |
||
259 |
// --------------------------------------------------------- |
|
77
2be0b271d017
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
72
diff
changeset
|
260 |
// CPhoneUIController::EngineInfo |
37 | 261 |
// --------------------------------------------------------- |
262 |
// |
|
77
2be0b271d017
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
72
diff
changeset
|
263 |
EXPORT_C MPEEngineInfo* CPhoneUIController::EngineInfo() |
37 | 264 |
{ |
77
2be0b271d017
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
72
diff
changeset
|
265 |
return iEngineInfo; |
37 | 266 |
} |
267 |
||
268 |
// --------------------------------------------------------- |
|
269 |
// CPhoneUIController::CreateProtocolDllL |
|
270 |
// --------------------------------------------------------- |
|
271 |
// |
|
272 |
void CPhoneUIController::CreateProtocolDllL( |
|
273 |
MPhoneViewCommandHandle* aViewCommandHandle ) |
|
274 |
{ |
|
275 |
TBool voipSupported( EFalse ); |
|
276 |
||
277 |
if( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) ) |
|
278 |
{ |
|
279 |
TInt dynamicVoIP( KDynamicVoIPOff ); |
|
280 |
CPhoneCenRepProxy::Instance()->GetInt( |
|
281 |
KCRUidTelephonySettings, KDynamicVoIP, dynamicVoIP ); |
|
282 |
||
283 |
if( dynamicVoIP == KDynamicVoIPOn ) |
|
284 |
{ |
|
285 |
voipSupported = ETrue; |
|
286 |
} |
|
287 |
} |
|
288 |
||
289 |
if( voipSupported ) |
|
290 |
{ |
|
291 |
iStateHandle = CPhoneStateHandle::CreateL( |
|
292 |
aViewCommandHandle, |
|
293 |
KVoIPExtension, |
|
294 |
KUidAppVoIPExtensionStates ); |
|
295 |
} |
|
296 |
else |
|
297 |
{ |
|
298 |
iStateHandle = CPhoneStateHandle::CreateL( |
|
299 |
aViewCommandHandle, |
|
300 |
KGSMProtocol, |
|
301 |
KUidAppGSMStates ); |
|
302 |
} |
|
303 |
} |
|
304 |
||
305 |
// --------------------------------------------------------- |
|
306 |
// CPhoneUIController::HandlePhoneNumberEditorCallBack |
|
307 |
// --------------------------------------------------------- |
|
308 |
// |
|
309 |
TInt CPhoneUIController::HandlePhoneNumberEditorCallBack( TAny* aAny ) |
|
310 |
{ |
|
311 |
CPhoneUIController* aPhoneUiController = |
|
312 |
static_cast< CPhoneUIController* >( aAny ); |
|
313 |
||
314 |
aPhoneUiController->DoHandlePhoneNumberEditorCallBack(); |
|
315 |
||
316 |
return 0; |
|
317 |
} |
|
318 |
||
319 |
// --------------------------------------------------------- |
|
320 |
// CPhoneUIController::DoHandlePhoneNumberEditorCallBack |
|
321 |
// --------------------------------------------------------- |
|
322 |
// |
|
323 |
void CPhoneUIController::DoHandlePhoneNumberEditorCallBack() |
|
324 |
{ |
|
325 |
} |
|
326 |
||
327 |
// End of File |