author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 00:16:48 +0300 | |
changeset 77 | 2be0b271d017 |
parent 37 | ba76fc04e6c2 |
permissions | -rw-r--r-- |
37 | 1 |
/* |
2 |
* Copyright (c) 2007 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 CPhoneStateMachineVoIP class. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
// INCLUDE FILES |
|
19 |
#include "cphonestatemachinevoip.h" |
|
20 |
#include "phonelogger.h" |
|
21 |
#include "phonestatedefinitionsvoip.h" |
|
22 |
#include "cphonestateidlevoip.h" |
|
23 |
#include "cphonestateincomingvoip.h" |
|
24 |
#include "cphonestatecallsetupvoip.h" |
|
25 |
#include "cphonestatesinglevoip.h" |
|
26 |
#include "cphonestatealertingvoip.h" |
|
27 |
#include "cphonecustomizationvoip.h" |
|
28 |
#include "cphonevoiperrormessageshandler.h" |
|
29 |
#include "cphonestateutilsvoip.h" |
|
30 |
||
31 |
// ================= MEMBER FUNCTIONS ======================= |
|
32 |
||
33 |
// --------------------------------------------------------------------------- |
|
34 |
// CPhoneStateMachineVoIP::CPhoneStateMachineVoIP |
|
35 |
// C++ default constructor can NOT contain any code, that |
|
36 |
// might leave. |
|
37 |
// --------------------------------------------------------------------------- |
|
38 |
// |
|
39 |
CPhoneStateMachineVoIP::CPhoneStateMachineVoIP( |
|
40 |
MPhoneViewCommandHandle* aViewCommandHandle ) : |
|
41 |
CPhoneStateMachineGSM( aViewCommandHandle ) |
|
42 |
{ |
|
43 |
} |
|
44 |
||
45 |
||
46 |
// --------------------------------------------------------------------------- |
|
47 |
// CPhoneStateMachineVoIP::~CPhoneStateMachineVoIP() |
|
48 |
// Destructor |
|
49 |
// (other items were commented in a header). |
|
50 |
// --------------------------------------------------------------------------- |
|
51 |
// |
|
52 |
CPhoneStateMachineVoIP::~CPhoneStateMachineVoIP() |
|
53 |
{ |
|
54 |
__LOGMETHODSTARTEND( PhoneUIVoIPExtension, |
|
55 |
"CPhoneStateMachineVoIP::~CPhoneStateMachineVoIP()" ); |
|
56 |
||
57 |
delete iVoipCustomization; |
|
58 |
delete iStateUtils; |
|
59 |
Dll::FreeTls(); |
|
60 |
} |
|
61 |
||
62 |
||
63 |
// --------------------------------------------------------------------------- |
|
64 |
// CPhoneStateMachineVoIP::ConstructL |
|
65 |
// Constructor |
|
66 |
// (other items were commented in a header). |
|
67 |
// --------------------------------------------------------------------------- |
|
68 |
// |
|
69 |
void CPhoneStateMachineVoIP::ConstructL() |
|
70 |
{ |
|
71 |
__LOGMETHODSTARTEND( |
|
72 |
PhoneUIVoIPExtension, "CPhoneStateMachineVoIP::ConstructL()" ); |
|
73 |
||
74 |
iVoipCustomization = CPhoneCustomizationVoip::NewL( *this, *iViewCommandHandle ); |
|
75 |
iCustomization = iVoipCustomization; |
|
76 |
iStateUtils = CPhoneStateUtilsVoip::NewL( *this, *iViewCommandHandle ); |
|
77 |
} |
|
78 |
||
79 |
||
80 |
// --------------------------------------------------------------------------- |
|
81 |
// CPhoneStateMachineVoIP::State |
|
82 |
// --------------------------------------------------------------------------- |
|
83 |
// |
|
84 |
MPhoneState* CPhoneStateMachineVoIP::State() |
|
85 |
{ |
|
86 |
__LOGMETHODSTARTEND( |
|
87 |
PhoneUIVoIPExtension, "CPhoneStateMachineVoIP::State()" ); |
|
88 |
||
89 |
TInt err( KErrNone ); |
|
90 |
TBool madeStateTransition( EFalse ); |
|
91 |
TBool deleteOldState( ETrue ); |
|
92 |
||
93 |
if( iOldStateId != iNewStateId ) |
|
94 |
{ |
|
95 |
if( iOldStateId == EPhoneStateIdle || |
|
96 |
iOldStateId == EPhoneStateEmergency ) |
|
97 |
{ |
|
98 |
deleteOldState = EFalse; |
|
99 |
} |
|
100 |
if ( deleteOldState ) |
|
101 |
{ |
|
102 |
// Possible that derived class has been deleted iState, |
|
103 |
// so this delete statement may be useless. |
|
104 |
delete iState; |
|
105 |
iState = NULL; |
|
106 |
} |
|
107 |
||
108 |
// State transition need to be made - construct new state and |
|
109 |
// destruct old |
|
110 |
switch( iNewStateId ) |
|
111 |
{ |
|
112 |
case EPhoneStateCallSetup: |
|
113 |
TRAP( err, iState = CPhoneStateCallSetupVoIP::NewL( |
|
114 |
*this, *iViewCommandHandle, *iVoipCustomization ) ); |
|
115 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() ); |
|
116 |
madeStateTransition = ETrue; |
|
117 |
break; |
|
118 |
||
119 |
case EPhoneStateIdle: |
|
120 |
if( iIdleState == NULL ) |
|
121 |
{ |
|
122 |
TRAP( err, iIdleState = CPhoneStateIdleVoIP::NewL( |
|
123 |
*this, *iViewCommandHandle, *iVoipCustomization ) ); |
|
124 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() ); |
|
125 |
} |
|
126 |
iState = iIdleState; |
|
127 |
madeStateTransition = ETrue; |
|
128 |
break; |
|
129 |
||
130 |
case EPhoneStateIncoming: |
|
131 |
TRAP( err, iState = CPhoneStateIncomingVoIP::NewL( |
|
132 |
*this, *iViewCommandHandle, *iVoipCustomization ) ); |
|
133 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() ); |
|
134 |
madeStateTransition = ETrue; |
|
135 |
break; |
|
136 |
||
137 |
case EPhoneStateSingle: |
|
138 |
TRAP( err, iState = CPhoneStateSingleVoIP::NewL( |
|
139 |
*this, *iViewCommandHandle, *iVoipCustomization )); |
|
140 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() ); |
|
141 |
madeStateTransition = ETrue; |
|
142 |
break; |
|
143 |
||
144 |
case EPhoneStateAlerting: |
|
145 |
TRAP( err, iState = CPhoneStateAlertingVoIP::NewL( |
|
146 |
*this, *iViewCommandHandle, *iVoipCustomization )); |
|
147 |
__ASSERT_ALWAYS( KErrNone == err, User::Invariant() ); |
|
148 |
madeStateTransition = ETrue; |
|
149 |
break; |
|
150 |
||
151 |
default: |
|
152 |
iState = CPhoneStateMachineGSM::State(); |
|
153 |
break; |
|
154 |
} |
|
155 |
} |
|
156 |
||
157 |
if ( madeStateTransition ) |
|
158 |
{ |
|
159 |
iOldStateId = iNewStateId; |
|
77
2be0b271d017
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
160 |
|
2be0b271d017
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
161 |
// Needs to be set or any attempts to access eikon env handle |
2be0b271d017
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
162 |
// will fail |
2be0b271d017
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
163 |
iState->SetEikonEnv( EikonEnv() ); |
37 | 164 |
} |
165 |
||
166 |
return iState; |
|
167 |
} |
|
168 |
||
169 |
||
170 |
// --------------------------------------------------------------------------- |
|
171 |
// CPhoneStateMachineVoIP::SetVoipErrorMessageHandler |
|
172 |
// --------------------------------------------------------------------------- |
|
173 |
// |
|
174 |
void CPhoneStateMachineVoIP::SetVoipErrorMessageHandler( |
|
175 |
CPhoneVoIPErrorMessagesHandler& iErrorHandler ) |
|
176 |
{ |
|
177 |
iVoipErrorMessageHandler = &iErrorHandler; |
|
178 |
} |
|
179 |
||
180 |
||
181 |
// --------------------------------------------------------------------------- |
|
182 |
// CPhoneStateMachineVoIP::VoipErrorMessageHandler |
|
183 |
// --------------------------------------------------------------------------- |
|
184 |
// |
|
185 |
CPhoneVoIPErrorMessagesHandler& |
|
186 |
CPhoneStateMachineVoIP::VoipErrorMessageHandler() const |
|
187 |
{ |
|
188 |
__ASSERT_DEBUG( NULL != iVoipErrorMessageHandler, User::Invariant() ); |
|
189 |
return *iVoipErrorMessageHandler; |
|
190 |
} |
|
191 |
||
192 |
||
193 |
// --------------------------------------------------------------------------- |
|
194 |
// CPhoneStateMachineVoIP::StateUtils |
|
195 |
// --------------------------------------------------------------------------- |
|
196 |
// |
|
197 |
CPhoneStateUtilsVoip& CPhoneStateMachineVoIP::StateUtils() |
|
198 |
{ |
|
199 |
return *iStateUtils; |
|
200 |
} |
|
201 |
||
202 |
||
203 |
// --------------------------------------------------------------------------- |
|
204 |
// CPhoneStateMachineVoIP::NewL() |
|
205 |
// Constructor |
|
206 |
// (other items were commented in a header). |
|
207 |
// --------------------------------------------------------------------------- |
|
208 |
// |
|
209 |
CPhoneStateMachineVoIP* CPhoneStateMachineVoIP::NewL( |
|
210 |
MPhoneViewCommandHandle* aViewCommandHandle ) |
|
211 |
{ |
|
212 |
__LOGMETHODSTARTEND( |
|
213 |
PhoneUIVoIPExtension, "CPhoneStateMachineVoIP::NewL()" ); |
|
214 |
||
215 |
CPhoneStateMachineVoIP* self = |
|
216 |
new (ELeave) CPhoneStateMachineVoIP( aViewCommandHandle ); |
|
217 |
||
218 |
CleanupStack::PushL( self ); |
|
219 |
self->ConstructL(); |
|
220 |
CleanupStack::Pop( self ); |
|
221 |
||
222 |
return self; |
|
223 |
} |
|
224 |
||
225 |
// End of File |