|
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 "mcenatstatedecodeanswer.h" |
|
21 #include "mcenatsipsession.h" |
|
22 #include "mceactionset.h" |
|
23 #include "mceclientserver.h" |
|
24 #include "mcenatevents.h" |
|
25 #include "mcesrvlogs.h" |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CMceNatStateDecodeAnswer::CMceNatStateDecodeAnswer |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CMceNatStateDecodeAnswer::CMceNatStateDecodeAnswer() |
|
32 { |
|
33 } |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CMceNatStateDecodeAnswer::~CMceNatStateDecodeAnswer |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CMceNatStateDecodeAnswer::~CMceNatStateDecodeAnswer() |
|
40 { |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CMceNatStateDecodeAnswer::Accept |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 TBool CMceNatStateDecodeAnswer::Accept( TMceNatStateTransitionEvent& aEvent ) |
|
48 { |
|
49 if ( EMceNatAnswer == aEvent.NatCode() || |
|
50 EMceNatError == aEvent.NatCode() || |
|
51 ( ( EMceAck == aEvent.Code() ) && |
|
52 MceSip::HasContent( aEvent.Session().Request() )) || |
|
53 EMceNatICMPError == aEvent.NatCode() ) |
|
54 |
|
55 { |
|
56 return ETrue; |
|
57 } |
|
58 else |
|
59 { |
|
60 return EFalse; |
|
61 } |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CMceNatStateDecodeAnswer::EntryL |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void CMceNatStateDecodeAnswer::EntryL( TMceNatStateTransitionEvent& aEvent ) |
|
69 { |
|
70 MCESRV_DEBUG( "*** CMceNatStateDecodeAnswer::EntryL, Entry" ); |
|
71 |
|
72 TMceReturnStatus status = KMceAsync; |
|
73 status = aEvent.NatActions().DecodeAnswerL(); |
|
74 |
|
75 if ( KMceReady == status ) |
|
76 { |
|
77 aEvent.NatActions().StateChangedL( aEvent, KMceNatStateConnected ); |
|
78 } |
|
79 else |
|
80 { |
|
81 aEvent.ParamStatus() = status; |
|
82 } |
|
83 |
|
84 MCESRV_DEBUG( "*** CMceNatStateDecodeAnswer::EntryL, Exit" ); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CMceNatStateDecodeAnswer::ExitL |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CMceNatStateDecodeAnswer::ExitL( TMceNatStateTransitionEvent& aEvent ) |
|
92 { |
|
93 MCESRV_DEBUG( "*** CMceNatStateDecodeAnswer::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( "*** CMceNatStateDecodeAnswer::ExitL, Exit" ); |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CMceNatStateDecodeAnswer::ExitErrorL |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CMceNatStateDecodeAnswer::ExitErrorL( TMceNatStateTransitionEvent& aEvent ) |
|
118 { |
|
119 TMceStateIndex sipState = aEvent.Session().CurrentState().Id(); |
|
120 |
|
121 if (( aEvent.NatCode() == EMceNatICMPError && |
|
122 KMceStateEstablished == sipState ) || |
|
123 aEvent.NatCode() == EMceNatError ) |
|
124 |
|
125 { |
|
126 aEvent.Session().Actions().ClientErrorOccured( aEvent.ParamStatus() ); |
|
127 aEvent.NatActions().Continue(); |
|
128 User::Leave( aEvent.ParamStatus() ); |
|
129 } |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CMceNatStateDecodeAnswer::ExitDefaultL |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 void CMceNatStateDecodeAnswer::ExitDefaultL( TMceNatStateTransitionEvent& aEvent ) |
|
137 { |
|
138 User::LeaveIfNull( aEvent.Document() ); |
|
139 CMceSipSession& session = aEvent.Session(); |
|
140 |
|
141 CSdpDocument* previous = session.Offer(); |
|
142 aEvent.Session().SetOffer( aEvent.Document() ); |
|
143 aEvent.NatActions().SetOffered( KMceNatOfferSdp ); |
|
144 aEvent.NatActions().SdpCleanup( previous, session.Offer() ); |
|
145 aEvent.NatActions().StateChangedL( aEvent, KMceNatStateConnected ); |
|
146 } |
|
147 |
|
148 |
|
149 // End of File |
|
150 |