|
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: Activating state implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <sdpdocument.h> |
|
19 #include "nspstateactivating.h" |
|
20 #include "nspevents.h" |
|
21 #include "nspsession.h" |
|
22 #include "nspactionset.h" |
|
23 #include "nspsessiondata.h" |
|
24 #include "nspdefs.h" |
|
25 |
|
26 // ======== MEMBER FUNCTIONS ======== |
|
27 // --------------------------------------------------------------------------- |
|
28 // CNSPStateActivating::CNSPStateActivating |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CNSPStateActivating::CNSPStateActivating() |
|
32 { |
|
33 } |
|
34 |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // CNSPStateActivating::NewL |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 CNSPStateActivating* CNSPStateActivating::NewL() |
|
41 { |
|
42 CNSPStateActivating* self = CNSPStateActivating::NewLC(); |
|
43 CleanupStack::Pop( self ); |
|
44 return self; |
|
45 } |
|
46 |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // CNSPStateActivating::NewLC |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CNSPStateActivating* CNSPStateActivating::NewLC() |
|
53 { |
|
54 CNSPStateActivating* self = new ( ELeave ) CNSPStateActivating; |
|
55 CleanupStack::PushL( self ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // CNSPStateActivating::~CNSPStateActivating |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 CNSPStateActivating::~CNSPStateActivating() |
|
65 { |
|
66 } |
|
67 |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CNSPStateActivating::DoAcceptL |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 TBool CNSPStateActivating::DoAcceptL( TNSPStateMachineEvent& aEvent ) |
|
74 { |
|
75 User::LeaveIfError( |
|
76 TNSPStateMachineEvent::ENat == aEvent.Request() || |
|
77 TNSPStateMachineEvent::EUpdate == aEvent.Request() || |
|
78 TNSPStateMachineEvent::EReservationStatus == aEvent.Request() || |
|
79 TNSPStateMachineEvent::ECloseSession == aEvent.Request() ? |
|
80 KErrNone : KErrArgument ); |
|
81 |
|
82 return ETrue; |
|
83 } |
|
84 |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // CNSPStateActivating::DoStateEntryL |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 void CNSPStateActivating::DoStateEntryL( TNSPStateMachineEvent& aEvent ) |
|
91 { |
|
92 CNSPSession& session = aEvent.Session(); |
|
93 CSdpDocument* doc = ( OFFERER( session.Role() ) ? &session.Data().Answer() : |
|
94 ( ANSWERER( session.Role() ) ? &session.Data().Offer() : NULL ) ); |
|
95 |
|
96 __ASSERT_ALWAYS( doc, User::Leave( KErrArgument ) ); |
|
97 |
|
98 session.Actions().ActivateL( *doc ); |
|
99 } |
|
100 |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // CNSPStateActivating::DoReverse |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 void CNSPStateActivating::DoReverse( TNSPStateMachineEvent& /*aEvent*/ ) |
|
107 { |
|
108 } |
|
109 |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // CNSPStateActivating::DoApplyL |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 void CNSPStateActivating::DoApplyL( TNSPStateMachineEvent& aEvent ) |
|
116 { |
|
117 switch( aEvent.Request() ) |
|
118 { |
|
119 case TNSPStateMachineEvent::ENat: |
|
120 { |
|
121 ControlMediaL( aEvent ); |
|
122 break; |
|
123 } |
|
124 |
|
125 case TNSPStateMachineEvent::EUpdate: |
|
126 { |
|
127 ApplyUpdateL( aEvent ); |
|
128 break; |
|
129 } |
|
130 |
|
131 case TNSPStateMachineEvent::EReservationStatus: |
|
132 case TNSPStateMachineEvent::ECloseSession: |
|
133 { |
|
134 aEvent.Status() = KNatReady; |
|
135 break; |
|
136 } |
|
137 |
|
138 default: |
|
139 { |
|
140 User::Leave( KErrArgument ); |
|
141 } |
|
142 } |
|
143 } |
|
144 |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // CNSPStateActivating::DoExitL |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 void CNSPStateActivating::DoExitL( TNSPStateMachineEvent& aEvent ) |
|
151 { |
|
152 switch( aEvent.Request() ) |
|
153 { |
|
154 case TNSPStateMachineEvent::ENat: |
|
155 { |
|
156 break; |
|
157 } |
|
158 |
|
159 default: |
|
160 { |
|
161 User::Leave( KErrArgument ); |
|
162 } |
|
163 } |
|
164 } |
|
165 |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // CNSPStateActivating::ControlMediaL |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 void CNSPStateActivating::ControlMediaL( TNSPStateMachineEvent& aEvent ) const |
|
172 { |
|
173 TNSPStateMachineMediaEvent& event = MEDIAEVENT( aEvent ); |
|
174 TNatReturnStatus status = event.Session().Actions().ControlMediaL( |
|
175 event.StreamId(), event.Event(), event.Status(), event.Data() ); |
|
176 |
|
177 if ( NSP_TRIGGER( status ) ) |
|
178 { |
|
179 ApplyNatL( event ); |
|
180 } |
|
181 else |
|
182 { |
|
183 event.Status() = status; |
|
184 } |
|
185 } |
|
186 |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // CNSPStateActivating::ApplyNatL |
|
190 // --------------------------------------------------------------------------- |
|
191 // |
|
192 void CNSPStateActivating::ApplyNatL( TNSPStateMachineEvent& aEvent ) const |
|
193 { |
|
194 CNSPSession& session = aEvent.Session(); |
|
195 CSdpDocument* doc = ( OFFERER( session.Role() ) ? &session.Data().Answer() : |
|
196 ( ANSWERER( session.Role() ) ? &session.Data().Offer() : NULL ) ); |
|
197 |
|
198 __ASSERT_ALWAYS( doc, User::Leave( KErrArgument ) ); |
|
199 session.Actions().LocalRoundL( *doc ); |
|
200 |
|
201 aEvent.NextState() = KStateIndexConnected; |
|
202 } |
|
203 |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // CNSPStateActivating::ApplyUpdateL |
|
207 // --------------------------------------------------------------------------- |
|
208 // |
|
209 void CNSPStateActivating::ApplyUpdateL( TNSPStateMachineEvent& aEvent ) const |
|
210 { |
|
211 CNSPSession& session = aEvent.Session(); |
|
212 CSdpDocument* offer = aEvent.Offer(); |
|
213 |
|
214 if ( KNatAsync == session.Actions().GetCandidatesL( *offer ) ) |
|
215 { |
|
216 session.Actions().UpdateL(); |
|
217 } |
|
218 |
|
219 aEvent.Status() = KNatAsync; |
|
220 } |
|
221 |
|
222 // end of file |