|
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 "mcenatstatewait.h" |
|
21 #include "mcenatevents.h" |
|
22 #include "mcenatsipsession.h" |
|
23 #include "mceactionset.h" |
|
24 #include "mceclientserver.h" |
|
25 #include "mcesrvlogs.h" |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CMceNatStateWait::CMceNatStateWait |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CMceNatStateWait::CMceNatStateWait() |
|
32 { |
|
33 } |
|
34 |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CMceNatStateWait::~CMceNatStateWait |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CMceNatStateWait::~CMceNatStateWait() |
|
41 { |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CMceNatStateWait::Accept |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 TBool CMceNatStateWait::Accept( TMceNatStateTransitionEvent& aEvent ) |
|
49 { |
|
50 if ( ( EMceNatHandleSIP == aEvent.NatCode() && |
|
51 ( EMceResponse == aEvent.Code() || |
|
52 EMceProvisionalResponse == aEvent.Code() ) && |
|
53 MceSip::HasContent( aEvent.Session().Response() ) ) || |
|
54 EMceNatError == aEvent.NatCode() || |
|
55 ( EMceAck == aEvent.Code() && |
|
56 MceSip::HasContent( aEvent.Session().Request())) || |
|
57 EMceNatICMPError == aEvent.NatCode()) |
|
58 { |
|
59 return ETrue; |
|
60 } |
|
61 else |
|
62 { |
|
63 return EFalse; |
|
64 } |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CMceNatStateWait::EntryL |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void CMceNatStateWait::EntryL( TMceNatStateTransitionEvent& aEvent ) |
|
72 { |
|
73 MCESRV_DEBUG( "*** CMceNatStateWait::EntryL, Entry" ); |
|
74 |
|
75 if ( EMceNatSync == aEvent.NatCode() ) |
|
76 { |
|
77 // NOP |
|
78 } |
|
79 else |
|
80 { |
|
81 aEvent.NatActions().Continue(); |
|
82 } |
|
83 |
|
84 MCESRV_DEBUG( "*** CMceNatStateWait::EntryL, Exit" ); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CMceNatStateWait::ExitL |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CMceNatStateWait::ExitL( TMceNatStateTransitionEvent& aEvent ) |
|
92 { |
|
93 MCESRV_DEBUG( "*** CMceNatStateWait::ExitL, Entry" ); |
|
94 |
|
95 switch ( aEvent.NatCode() ) |
|
96 { |
|
97 case EMceNatError: |
|
98 case EMceNatICMPError: |
|
99 { |
|
100 ExitErrorL( aEvent ); |
|
101 break; |
|
102 } |
|
103 default: |
|
104 { |
|
105 ExitDefaultL( aEvent ); |
|
106 break; |
|
107 } |
|
108 } |
|
109 |
|
110 MCESRV_DEBUG( "*** CMceNatStateWait::ExitL, Exit" ); |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CMceNatStateWait::ExitErrorL |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CMceNatStateWait::ExitErrorL( TMceNatStateTransitionEvent& aEvent ) |
|
118 { |
|
119 |
|
120 TMceStateIndex sipState = aEvent.Session().CurrentState().Id(); |
|
121 |
|
122 if (( aEvent.NatCode() == EMceNatICMPError && |
|
123 KMceStateEstablished == sipState ) || |
|
124 aEvent.NatCode() == EMceNatError ) |
|
125 { |
|
126 aEvent.Session().Actions().ClientErrorOccured( aEvent.ParamStatus() ); |
|
127 User::Leave( aEvent.ParamStatus() ); |
|
128 } |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CMceNatStateWait::ExitDefaultL |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void CMceNatStateWait::ExitDefaultL( TMceNatStateTransitionEvent& aEvent ) |
|
136 { |
|
137 CMceSipSession& session = aEvent.Session(); |
|
138 |
|
139 if ( EMceAck == aEvent.Code() && |
|
140 MceSip::HasContent( aEvent.Session().Request())) |
|
141 { |
|
142 User::LeaveIfError( session.Actions().CreateSDP( session.Request() ) ); |
|
143 aEvent.NatActions().UpdateL(); |
|
144 aEvent.NatActions().StateChangedL( aEvent, KMceNatStateDecodeAnswer ); |
|
145 } |
|
146 else |
|
147 { |
|
148 User::LeaveIfError( session.Actions().CreateSDP( session.Response() ) ); |
|
149 aEvent.NatActions().StateChangedL( aEvent, KMceNatStateDecodeAnswer ); |
|
150 } |
|
151 |
|
152 } |
|
153 |
|
154 |
|
155 |
|
156 // End of File |
|
157 |