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; |
|
160 } |
|
161 |
|
162 return iState; |
|
163 } |
|
164 |
|
165 |
|
166 // --------------------------------------------------------------------------- |
|
167 // CPhoneStateMachineVoIP::SetVoipErrorMessageHandler |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 void CPhoneStateMachineVoIP::SetVoipErrorMessageHandler( |
|
171 CPhoneVoIPErrorMessagesHandler& iErrorHandler ) |
|
172 { |
|
173 iVoipErrorMessageHandler = &iErrorHandler; |
|
174 } |
|
175 |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // CPhoneStateMachineVoIP::VoipErrorMessageHandler |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 CPhoneVoIPErrorMessagesHandler& |
|
182 CPhoneStateMachineVoIP::VoipErrorMessageHandler() const |
|
183 { |
|
184 __ASSERT_DEBUG( NULL != iVoipErrorMessageHandler, User::Invariant() ); |
|
185 return *iVoipErrorMessageHandler; |
|
186 } |
|
187 |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // CPhoneStateMachineVoIP::StateUtils |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 CPhoneStateUtilsVoip& CPhoneStateMachineVoIP::StateUtils() |
|
194 { |
|
195 return *iStateUtils; |
|
196 } |
|
197 |
|
198 |
|
199 // --------------------------------------------------------------------------- |
|
200 // CPhoneStateMachineVoIP::NewL() |
|
201 // Constructor |
|
202 // (other items were commented in a header). |
|
203 // --------------------------------------------------------------------------- |
|
204 // |
|
205 CPhoneStateMachineVoIP* CPhoneStateMachineVoIP::NewL( |
|
206 MPhoneViewCommandHandle* aViewCommandHandle ) |
|
207 { |
|
208 __LOGMETHODSTARTEND( |
|
209 PhoneUIVoIPExtension, "CPhoneStateMachineVoIP::NewL()" ); |
|
210 |
|
211 CPhoneStateMachineVoIP* self = |
|
212 new (ELeave) CPhoneStateMachineVoIP( aViewCommandHandle ); |
|
213 |
|
214 CleanupStack::PushL( self ); |
|
215 self->ConstructL(); |
|
216 CleanupStack::Pop( self ); |
|
217 |
|
218 return self; |
|
219 } |
|
220 |
|
221 // End of File |
|