|
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 #include "mcenatstatedecodeoffer.h" |
|
21 #include "mcenatsipsession.h" |
|
22 #include "mceactionset.h" |
|
23 #include "mceclientserver.h" |
|
24 #include "mcenatevents.h" |
|
25 #include "mcesrvlogs.h" |
|
26 #include "nspplugin.h" |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CMceNatStateDecodeOffer::CMceNatStateDecodeOffer |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CMceNatStateDecodeOffer::CMceNatStateDecodeOffer() |
|
33 { |
|
34 } |
|
35 |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CMceNatStateDecodeOffer::~CMceNatStateDecodeOffer |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CMceNatStateDecodeOffer::~CMceNatStateDecodeOffer() |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CMceNatStateDecodeOffer::Accept |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 TBool CMceNatStateDecodeOffer::Accept( TMceNatStateTransitionEvent& aEvent ) |
|
50 { |
|
51 if ( EMceNatOffer == aEvent.NatCode() || |
|
52 ( EMceNatHandleSIP == aEvent.NatCode() && |
|
53 EMceInvite == aEvent.Code() )|| |
|
54 EMceNatError == aEvent.NatCode() || |
|
55 EMceNatICMPError == aEvent.NatCode() ) |
|
56 { |
|
57 return ETrue; |
|
58 } |
|
59 else |
|
60 { |
|
61 return EFalse; |
|
62 } |
|
63 |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CMceNatStateDecodeOffer::EntryL |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 void CMceNatStateDecodeOffer::EntryL( TMceNatStateTransitionEvent& aEvent ) |
|
71 { |
|
72 MCESRV_DEBUG( "*** CMceNatStateDecodeOffer::EntryL, Entry" ); |
|
73 |
|
74 aEvent.NatActions().Continue(); |
|
75 |
|
76 MCESRV_DEBUG( "*** CMceNatStateDecodeOffer::EntryL, Exit" ); |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CMceNatStateDecodeOffer::ExitL |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 void CMceNatStateDecodeOffer::ExitL( TMceNatStateTransitionEvent& aEvent ) |
|
84 { |
|
85 MCESRV_DEBUG( "*** CMceNatStateDecodeOffer::ExitL, Entry" ); |
|
86 |
|
87 switch ( aEvent.NatCode() ) |
|
88 { |
|
89 case EMceNatError: |
|
90 case EMceNatICMPError: |
|
91 { |
|
92 ExitErrorL( aEvent ); |
|
93 break; |
|
94 } |
|
95 case EMceNatHandleSIP: |
|
96 { |
|
97 ExitHandleInviteL( aEvent ); |
|
98 break; |
|
99 } |
|
100 default: |
|
101 { |
|
102 ExitDefaultL( aEvent ); |
|
103 break; |
|
104 } |
|
105 } |
|
106 |
|
107 MCESRV_DEBUG( "*** CMceNatStateDecodeOffer::ExitL, Exit" ); |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CMceNatStateDecodeOffer::ExitErrorL |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 void CMceNatStateDecodeOffer::ExitErrorL( TMceNatStateTransitionEvent& aEvent ) |
|
115 { |
|
116 |
|
117 TMceStateIndex sipState = aEvent.Session().CurrentState().Id(); |
|
118 |
|
119 if (( aEvent.NatCode() == EMceNatICMPError && |
|
120 KMceStateEstablished == sipState ) || |
|
121 aEvent.NatCode() == EMceNatError ) |
|
122 |
|
123 { |
|
124 aEvent.Session().Actions().ClientErrorOccured( aEvent.ParamStatus() ); |
|
125 if ( aEvent.NatCode() == EMceNatError ) |
|
126 { |
|
127 User::Leave( aEvent.ParamStatus() ); |
|
128 } |
|
129 } |
|
130 } |
|
131 |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CMceNatStateDecodeOffer::ExitHandleInviteL |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 void CMceNatStateDecodeOffer::ExitHandleInviteL( TMceNatStateTransitionEvent& aEvent ) |
|
138 { |
|
139 CMceSipSession& session = aEvent.Session(); |
|
140 |
|
141 if ( MceSip::HasContent( session.Request() ) ) |
|
142 { |
|
143 // Incoming INVITE contained new SDP, which can contain new candidates, |
|
144 // hence it is given to NAT - without state update. |
|
145 User::LeaveIfError( session.Actions().CreateSDP( session.Request() ) ); |
|
146 aEvent.NatActions().UpdateL(); |
|
147 } |
|
148 |
|
149 // Not consumed, done by SIP state machine |
|
150 aEvent.NatActions().Continue(); |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CMceNatStateDecodeOffer::ExitDefaultL |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 void CMceNatStateDecodeOffer::ExitDefaultL( TMceNatStateTransitionEvent& aEvent ) |
|
158 { |
|
159 User::LeaveIfNull( aEvent.Document() ); |
|
160 CMceSipSession& session = aEvent.Session(); |
|
161 |
|
162 aEvent.Session().SetPrevOffer( aEvent.Document() ); |
|
163 aEvent.NatActions().SetOffered( KMceNatPrevOfferSdp ); |
|
164 aEvent.Session().Actions().DecodeL(); |
|
165 aEvent.NatActions().UpdateRemoteAddressL(); |
|
166 |
|
167 CSdpDocument* previous = session.Offer(); |
|
168 aEvent.NatActions().SetOffered( KMceNatOfferSdp ); |
|
169 aEvent.NatActions().SdpCleanup( previous, session.Offer() ); |
|
170 |
|
171 aEvent.NatActions().StateChangedL( aEvent, KMceNatStateConnected ); |
|
172 |
|
173 |
|
174 // MCE should use reserved only when the plugin returns |
|
175 // ENSPResourcesReserved enumeration and only in session initiation. |
|
176 |
|
177 if ( aEvent.NatActions().GetReservationStatus() == KMceAsync && |
|
178 aEvent.NatActions().GetResourceReservationStatus() == |
|
179 CNSPPlugin::ENSPResourcesReserved ) |
|
180 { |
|
181 //iReserveStatus = KMceReady; |
|
182 aEvent.NatActions().SetReservationStatus( KMceReady ); |
|
183 session.Reserved( session.ActiveBody()); |
|
184 } |
|
185 } |