|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "mcenatsipstatemachine.h" |
|
22 #include "mcenatstateinitializing.h" |
|
23 #include "mcenatstateidle.h" |
|
24 #include "mcenatstatecreateoffer.h" |
|
25 #include "mcenatstatecreateanswer.h" |
|
26 #include "mcenatstatedecodeoffer.h" |
|
27 #include "mcenatstatedecodeanswer.h" |
|
28 #include "mcenatstatewait.h" |
|
29 #include "mcenatstateconnected.h" |
|
30 #include "mcenatstatecreateofferrequested.h" |
|
31 #include "mcesrvlogs.h" |
|
32 |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CMceNatSipStateMachine::NewL |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CMceNatSipStateMachine* CMceNatSipStateMachine::NewL() |
|
39 { |
|
40 CMceNatSipStateMachine* self = CMceNatSipStateMachine::NewLC(); |
|
41 CleanupStack::Pop(self); |
|
42 return self; |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CMceNatSipStateMachine::NewLC |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 CMceNatSipStateMachine* CMceNatSipStateMachine::NewLC() |
|
50 { |
|
51 CMceNatSipStateMachine* self = new (ELeave) CMceNatSipStateMachine(); |
|
52 CleanupStack::PushL(self); |
|
53 self->ConstructL(); |
|
54 return self; |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CMceNatSipStateMachine::CMceNatSipStateMachine |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CMceNatSipStateMachine::CMceNatSipStateMachine() |
|
62 : iCurrentState( KMceNatStateInitializing ) |
|
63 { |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CMceNatSipStateMachine::NewState |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 void CMceNatSipStateMachine::NewStateL( TMceNatStateTransitionEvent& aEvent, |
|
71 TMceNatStateIndex aNewState ) |
|
72 { |
|
73 MCESRV_DEBUG( "*** CMceNatSipStateMachine::NewStateL, Entry" ); |
|
74 MCESRV_DEBUG_DVALUE( "*** new state", aNewState ); |
|
75 |
|
76 iCurrentState = aNewState; |
|
77 |
|
78 TRAPD( error, iStates[iCurrentState]->TransitionHandler().EntryL( aEvent ) ); |
|
79 |
|
80 if ( KErrNone != error ) |
|
81 { |
|
82 User::Leave( error ); |
|
83 } |
|
84 |
|
85 MCESRV_DEBUG( "*** CMceNatSipStateMachine::NewStateL, Exit" ); |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CMceNatSipStateMachine::ConstructL |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CMceNatSipStateMachine::ConstructL() |
|
93 { |
|
94 MCESRV_DEBUG( "*** CMceNatSipStateMachine::ConstructL, Entry" ); |
|
95 |
|
96 CMceNatState* state = NULL; |
|
97 |
|
98 state = new (ELeave) CMceNatStateInitializing(); |
|
99 CleanupStack::PushL( state ); |
|
100 iStates.InsertL( state, KMceNatStateInitializing ); |
|
101 CleanupStack::Pop( state ); |
|
102 |
|
103 state = new (ELeave) CMceNatStateIdle(); |
|
104 CleanupStack::PushL( state ); |
|
105 iStates.InsertL( state, KMceNatStateIdle ); |
|
106 CleanupStack::Pop( state ); |
|
107 |
|
108 state = new (ELeave) CMceNatStateCreateOffer(); |
|
109 CleanupStack::PushL( state ); |
|
110 iStates.InsertL( state, KMceNatStateCreateOffer ); |
|
111 CleanupStack::Pop( state ); |
|
112 |
|
113 state = new (ELeave) CMceNatStateCreateAnswer(); |
|
114 CleanupStack::PushL( state ); |
|
115 iStates.InsertL( state, KMceNatStateCreateAnswer ); |
|
116 CleanupStack::Pop( state ); |
|
117 |
|
118 state = new (ELeave) CMceNatStateDecodeOffer(); |
|
119 CleanupStack::PushL( state ); |
|
120 iStates.InsertL( state, KMceNatStateDecodeOffer ); |
|
121 CleanupStack::Pop( state ); |
|
122 |
|
123 state = new (ELeave) CMceNatStateDecodeAnswer(); |
|
124 CleanupStack::PushL( state ); |
|
125 iStates.InsertL( state, KMceNatStateDecodeAnswer ); |
|
126 CleanupStack::Pop( state ); |
|
127 |
|
128 state = new (ELeave) CMceNatStateWait(); |
|
129 CleanupStack::PushL( state ); |
|
130 iStates.InsertL( state, KMceNatStateWait ); |
|
131 CleanupStack::Pop( state ); |
|
132 |
|
133 state = new (ELeave) CMceNatStateConnected(); |
|
134 CleanupStack::PushL( state ); |
|
135 iStates.InsertL( state, KMceNatStateConnected ); |
|
136 CleanupStack::Pop( state ); |
|
137 |
|
138 state = new (ELeave) CMceNatStateCreateOfferRequested(); |
|
139 CleanupStack::PushL( state ); |
|
140 iStates.InsertL( state, KMceNatStateCreateOfferRequested ); |
|
141 CleanupStack::Pop( state ); |
|
142 |
|
143 MCESRV_DEBUG( "*** CMceNatSipStateMachine::ConstructL, Exit" ); |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CMceNatSipStateMachine::~CMceNatSipStateMachine |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 CMceNatSipStateMachine::~CMceNatSipStateMachine() |
|
151 { |
|
152 iStates.ResetAndDestroy(); |
|
153 iStates.Close(); |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CMceNatSipStateMachine::ProcessL |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 void CMceNatSipStateMachine::ProcessL( TMceNatStateTransitionEvent& aEvent ) |
|
161 { |
|
162 iStates[iCurrentState]->TransitionHandler().ExitL( aEvent ); |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CMceNatSipStateMachine::Accept |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 TBool CMceNatSipStateMachine::Accept( TMceNatStateTransitionEvent& aEvent ) |
|
170 { |
|
171 return iStates[iCurrentState]->Accept( aEvent ); |
|
172 } |
|
173 |
|
174 // ----------------------------------------------------------------------------- |
|
175 // CMceNatSipStateMachine::State |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 TInt CMceNatSipStateMachine::State() const |
|
179 { |
|
180 return iCurrentState; |
|
181 } |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // CMceNatSipStateMachine::ErrorOccurred |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 void CMceNatSipStateMachine::ErrorOccurred() |
|
188 { |
|
189 iCurrentState = KMceNatStateIdle; |
|
190 } |