37
|
1 |
/*
|
|
2 |
* Copyright (c) 2005 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 CPhoneStateMachineGSM class.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <cpephonemodelif.h>
|
|
21 |
#include "cphonestatemachinegsm.h"
|
|
22 |
#include "phonelogger.h"
|
|
23 |
#include "phonestatedefinitions.h"
|
|
24 |
#include "phonestatedefinitionsgsm.h"
|
|
25 |
#include "cphonecallsetup.h"
|
|
26 |
#include "cphonealerting.h"
|
|
27 |
#include "cphonesinglecall.h"
|
|
28 |
#include "cphonesingleandcallsetup.h"
|
|
29 |
#include "cphonesingleandalerting.h"
|
|
30 |
#include "cphonesingleandwaiting.h"
|
|
31 |
#include "cphonetwosingles.h"
|
|
32 |
#include "cphoneconference.h"
|
|
33 |
#include "cphoneconferenceandcallsetup.h"
|
|
34 |
#include "cphoneconferenceandsingle.h"
|
|
35 |
#include "cphoneconferenceandwaiting.h"
|
|
36 |
#include "cphonesingleandcallsetupandwaiting.h"
|
|
37 |
#include "cphonecallsetupandwaiting.h"
|
|
38 |
#include "cphonetwosinglesandwaiting.h"
|
|
39 |
#include "cphoneconferenceandsingleandwaiting.h"
|
|
40 |
#include "cphoneemergency.h"
|
|
41 |
#include "cphoneconferenceandwaitingandcallsetup.h"
|
|
42 |
#include "cphoneidle.h"
|
|
43 |
#include "cphoneincoming.h"
|
|
44 |
#include "cphonestartup.h"
|
|
45 |
|
|
46 |
// ================= MEMBER FUNCTIONS =======================
|
|
47 |
|
|
48 |
// -----------------------------------------------------------------------------
|
|
49 |
// CPhoneStateMachineGSM::CPhoneStateMachineGSM
|
|
50 |
// C++ default constructor can NOT contain any code, that
|
|
51 |
// might leave.
|
|
52 |
// -----------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
EXPORT_C CPhoneStateMachineGSM::CPhoneStateMachineGSM(
|
|
55 |
MPhoneViewCommandHandle* aViewCommandHandle ) :
|
|
56 |
CPhoneStateMachine( aViewCommandHandle )
|
|
57 |
{
|
|
58 |
}
|
|
59 |
|
|
60 |
// -----------------------------------------------------------
|
|
61 |
// CPhoneStateMachineGSM::~CPhoneStateMachineGSM()
|
|
62 |
// Destructor
|
|
63 |
// (other items were commented in a header).
|
|
64 |
// -----------------------------------------------------------
|
|
65 |
//
|
|
66 |
EXPORT_C CPhoneStateMachineGSM::~CPhoneStateMachineGSM()
|
|
67 |
{
|
|
68 |
__LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneStateMachineGSM::~CPhoneStateMachineGSM() ");
|
|
69 |
if( iEmergencyState )
|
|
70 |
{
|
|
71 |
delete iEmergencyState;
|
|
72 |
iEmergencyState = NULL;
|
|
73 |
}
|
|
74 |
Dll::FreeTls();
|
|
75 |
}
|
|
76 |
|
|
77 |
// ---------------------------------------------------------
|
|
78 |
// CPhoneStateMachineGSM::State
|
|
79 |
// ---------------------------------------------------------
|
|
80 |
EXPORT_C MPhoneState* CPhoneStateMachineGSM::State()
|
|
81 |
{
|
|
82 |
__LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneStateMachineGSM::State() ");
|
|
83 |
__PHONELOG1( EBasic, EPhoneUIStates,
|
|
84 |
"CPhoneStateMachineGSM::State() = %d ", iNewStateId );
|
|
85 |
|
|
86 |
TBool madeStateTransition = EFalse;
|
|
87 |
TBool deleteOldState( ETrue );
|
|
88 |
TInt err( KErrNone );
|
|
89 |
|
|
90 |
if( iOldStateId != iNewStateId )
|
|
91 |
{
|
|
92 |
if( iOldStateId == EPhoneStateIdle ||
|
|
93 |
iOldStateId == EPhoneStateEmergency )
|
|
94 |
{
|
|
95 |
deleteOldState = EFalse;
|
|
96 |
}
|
|
97 |
if ( deleteOldState )
|
|
98 |
{
|
|
99 |
// Possible that derived class has been deleted iState,
|
|
100 |
// so this delete statement may be useless.
|
|
101 |
delete iState;
|
|
102 |
iState = NULL;
|
|
103 |
}
|
|
104 |
|
|
105 |
// State transition need to be made - construct new state and
|
|
106 |
// destruct old
|
|
107 |
switch( iNewStateId )
|
|
108 |
{
|
|
109 |
case EPhoneStateCallSetup:
|
|
110 |
TRAP( err, iState = CPhoneCallSetup::NewL(
|
|
111 |
this, iViewCommandHandle, iCustomization ));
|
|
112 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
113 |
madeStateTransition = ETrue;
|
|
114 |
break;
|
|
115 |
|
|
116 |
case EPhoneStateAlerting:
|
|
117 |
TRAP( err, iState = CPhoneAlerting::NewL(
|
|
118 |
this, iViewCommandHandle, iCustomization ));
|
|
119 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
120 |
madeStateTransition = ETrue;
|
|
121 |
break;
|
|
122 |
|
|
123 |
case EPhoneStateSingle:
|
|
124 |
TRAP( err, iState = CPhoneSingleCall::NewL(
|
|
125 |
this, iViewCommandHandle, iCustomization ));
|
|
126 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
127 |
madeStateTransition = ETrue;
|
|
128 |
break;
|
|
129 |
|
|
130 |
case EPhoneStateWaitingInSingle:
|
|
131 |
TRAP( err, iState = CPhoneSingleAndWaiting::NewL(
|
|
132 |
this, iViewCommandHandle, iCustomization ));
|
|
133 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
134 |
madeStateTransition = ETrue;
|
|
135 |
break;
|
|
136 |
|
|
137 |
case EPhoneStateTwoSingles:
|
|
138 |
TRAP( err, iState = CPhoneTwoSingles::NewL(
|
|
139 |
this, iViewCommandHandle, iCustomization ));
|
|
140 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
141 |
madeStateTransition = ETrue;
|
|
142 |
break;
|
|
143 |
|
|
144 |
case EPhoneStateCallSetupInSingle:
|
|
145 |
TRAP( err, iState = CPhoneSingleAndCallSetup::NewL(
|
|
146 |
this, iViewCommandHandle, iCustomization ));
|
|
147 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
148 |
madeStateTransition = ETrue;
|
|
149 |
break;
|
|
150 |
|
|
151 |
case EPhoneStateAlertingInSingle:
|
|
152 |
TRAP( err, iState = CPhoneSingleAndAlerting::NewL(
|
|
153 |
this, iViewCommandHandle, iCustomization ));
|
|
154 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
155 |
madeStateTransition = ETrue;
|
|
156 |
break;
|
|
157 |
|
|
158 |
case EPhoneStateConference:
|
|
159 |
TRAP( err, iState = CPhoneConference::NewL(
|
|
160 |
this, iViewCommandHandle, iCustomization ));
|
|
161 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
162 |
madeStateTransition = ETrue;
|
|
163 |
break;
|
|
164 |
|
|
165 |
case EPhoneStateConferenceAndCallSetup:
|
|
166 |
TRAP( err, iState = CPhoneConferenceAndCallSetup::NewL(
|
|
167 |
this, iViewCommandHandle, iCustomization ) );
|
|
168 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
169 |
madeStateTransition = ETrue;
|
|
170 |
break;
|
|
171 |
|
|
172 |
case EPhoneStateConferenceAndSingle:
|
|
173 |
TRAP( err, iState = CPhoneConferenceAndSingle::NewL(
|
|
174 |
this, iViewCommandHandle, iCustomization ) );
|
|
175 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
176 |
madeStateTransition = ETrue;
|
|
177 |
break;
|
|
178 |
|
|
179 |
case EPhoneStateConferenceAndWaiting:
|
|
180 |
TRAP( err, iState = CPhoneConferenceAndWaiting::NewL(
|
|
181 |
this, iViewCommandHandle, iCustomization ) );
|
|
182 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
183 |
madeStateTransition = ETrue;
|
|
184 |
break;
|
|
185 |
|
|
186 |
case EPhoneStateSingleAndCallSetupAndWaiting:
|
|
187 |
TRAP( err, iState = CPhoneSingleAndCallSetupAndWaiting::NewL(
|
|
188 |
this, iViewCommandHandle, iCustomization ) );
|
|
189 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
190 |
madeStateTransition = ETrue;
|
|
191 |
break;
|
|
192 |
|
|
193 |
case EPhoneStateCallSetupAndWaiting:
|
|
194 |
TRAP( err, iState = CPhoneCallSetupAndWaiting::NewL(
|
|
195 |
this, iViewCommandHandle, iCustomization ) );
|
|
196 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
197 |
madeStateTransition = ETrue;
|
|
198 |
break;
|
|
199 |
|
|
200 |
case EPhoneStateTwoSinglesAndWaiting:
|
|
201 |
TRAP( err, iState = CPhoneTwoSinglesAndWaiting::NewL(
|
|
202 |
this, iViewCommandHandle, iCustomization ) );
|
|
203 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
204 |
madeStateTransition = ETrue;
|
|
205 |
break;
|
|
206 |
|
|
207 |
case EPhoneStateConferenceAndSingleAndWaiting:
|
|
208 |
TRAP( err, iState = CPhoneConferenceAndSingleAndWaiting::NewL(
|
|
209 |
this, iViewCommandHandle, iCustomization ));
|
|
210 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
211 |
madeStateTransition = ETrue;
|
|
212 |
break;
|
|
213 |
|
|
214 |
case EPhoneStateEmergency:
|
|
215 |
if( !iEmergencyStateConstructed )
|
|
216 |
{
|
|
217 |
TRAP( err, iEmergencyState = CPhoneEmergency::NewL(
|
|
218 |
this, iViewCommandHandle, iCustomization ) );
|
|
219 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
220 |
iEmergencyStateConstructed = ETrue;
|
|
221 |
}
|
|
222 |
static_cast< CPhoneEmergency* >( iEmergencyState )->
|
|
223 |
SetStartupInterrupted( iOldStateId == EPhoneStateStartup );
|
|
224 |
iState = iEmergencyState;
|
|
225 |
madeStateTransition = ETrue;
|
|
226 |
break;
|
|
227 |
|
|
228 |
case EPhoneStateConferenceAndWaitingAndCallSetup:
|
|
229 |
TRAP( err, iState =
|
|
230 |
CPhoneConferenceAndWaitingAndCallSetup::NewL(
|
|
231 |
this, iViewCommandHandle, iCustomization ) );
|
|
232 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
233 |
madeStateTransition = ETrue;
|
|
234 |
break;
|
|
235 |
|
|
236 |
case EPhoneStateIdle:
|
|
237 |
if ( iOldStateId != EPhoneStateEmergency )
|
|
238 |
{
|
|
239 |
if( !iEmergencyStateConstructed )
|
|
240 |
{
|
|
241 |
TRAP( err, iEmergencyState = CPhoneEmergency::NewL(
|
|
242 |
this, iViewCommandHandle, iCustomization ) );
|
|
243 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
244 |
iEmergencyStateConstructed = ETrue;
|
|
245 |
}
|
|
246 |
}
|
|
247 |
if( iIdleState == NULL )
|
|
248 |
{
|
|
249 |
TRAP( err, iIdleState =
|
|
250 |
CPhoneIdle::NewL( this, iViewCommandHandle, iCustomization ) );
|
|
251 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
252 |
}
|
|
253 |
iState = iIdleState;
|
|
254 |
madeStateTransition = ETrue;
|
|
255 |
break;
|
|
256 |
|
|
257 |
case EPhoneStateIncoming:
|
|
258 |
TRAP( err, iState =
|
|
259 |
CPhoneIncoming::NewL( this, iViewCommandHandle, iCustomization ) );
|
|
260 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
261 |
madeStateTransition = ETrue;
|
|
262 |
break;
|
|
263 |
|
|
264 |
case EPhoneStateStartup:
|
|
265 |
TRAP( err, iState =
|
|
266 |
CPhoneStartup::NewL( this, iViewCommandHandle,
|
|
267 |
iOldStateId == EPhoneStateEmergency ) );
|
|
268 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
|
|
269 |
madeStateTransition = ETrue;
|
|
270 |
break;
|
|
271 |
|
|
272 |
default:
|
|
273 |
iState = CPhoneStateMachine::State();
|
|
274 |
break;
|
|
275 |
}
|
|
276 |
}
|
|
277 |
|
|
278 |
if ( madeStateTransition )
|
|
279 |
{
|
|
280 |
__PHONELOGSTATECHANGE( iOldStateId, iNewStateId );
|
|
281 |
iOldStateId = iNewStateId;
|
74
|
282 |
|
|
283 |
// Needs to be set or any attempts to access eikon env handle
|
|
284 |
// will fail
|
|
285 |
iState->SetEikonEnv( EikonEnv() );
|
37
|
286 |
}
|
|
287 |
|
|
288 |
return iState;
|
|
289 |
}
|
|
290 |
|
|
291 |
// -----------------------------------------------------------
|
|
292 |
// CPhoneStateMachineGSM::NewL()
|
|
293 |
// Constructor
|
|
294 |
// (other items were commented in a header).
|
|
295 |
// -----------------------------------------------------------
|
|
296 |
//
|
|
297 |
CPhoneStateMachineGSM* CPhoneStateMachineGSM::NewL(
|
|
298 |
MPhoneViewCommandHandle* aViewCommandHandle )
|
|
299 |
{
|
|
300 |
__LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneStateMachineGSM::NewL() ");
|
|
301 |
CPhoneStateMachineGSM* self =
|
|
302 |
new (ELeave) CPhoneStateMachineGSM( aViewCommandHandle );
|
|
303 |
|
|
304 |
return self;
|
|
305 |
}
|
|
306 |
|
|
307 |
// -----------------------------------------------------------
|
|
308 |
// CPhoneStateMachineGSM::CreatePhoneEngineL
|
|
309 |
// -----------------------------------------------------------
|
|
310 |
//
|
|
311 |
EXPORT_C MPEPhoneModel* CPhoneStateMachineGSM::CreatePhoneEngineL(
|
|
312 |
MEngineMonitor& aEngineMonitor )
|
|
313 |
{
|
|
314 |
return CPEPhoneModelIF::CreateL( aEngineMonitor );
|
|
315 |
}
|
|
316 |
|
|
317 |
// End of File
|