|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <e32cons.h> |
|
22 #include <e32debug.h> |
|
23 #include <badesca.h> |
|
24 |
|
25 #include "natsettingstest.h" |
|
26 #include <cnatfwsettingsapi.h> |
|
27 #include <mnatfwserversettings.h> |
|
28 #include <mnatfwstunsettings.h> |
|
29 #include <mnatfwturnsettings.h> |
|
30 #include "natfwdefaultsettingsvalues.h" |
|
31 |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // CNATSettingsTest::NewL |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CNATSettingsTest* CNATSettingsTest::NewL( const TDesC8& aDomain, TUint aIapId ) |
|
38 { |
|
39 CNATSettingsTest* self = new ( ELeave ) CNATSettingsTest( aIapId ); |
|
40 CleanupStack::PushL( self ); |
|
41 self->ConstructL( aDomain ); |
|
42 CleanupStack::Pop( self ); |
|
43 return self; |
|
44 } |
|
45 |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CNATSettingsTest::CNATSettingsTest |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CNATSettingsTest::CNATSettingsTest( TUint aIapId ) : |
|
52 iIapId( aIapId ) |
|
53 { |
|
54 |
|
55 } |
|
56 |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CNATSettingsTest::ConstructL |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 void CNATSettingsTest::ConstructL( const TDesC8& aDomain ) |
|
63 { |
|
64 iDomain = aDomain.AllocL(); |
|
65 iSettings = CNATFWNatSettingsApi::NewL( *iDomain ); |
|
66 } |
|
67 |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CNATSettingsTest::~CNATSettingsTest |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 CNATSettingsTest::~CNATSettingsTest() |
|
74 { |
|
75 delete iSettings; |
|
76 delete iDomain; |
|
77 } |
|
78 |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CNATSettingsTest::PrintSettings |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 void CNATSettingsTest::PrintSettingsL( CConsoleBase& aConsole ) |
|
85 { |
|
86 _LIT8( KProtocolFormat, "%S " ); |
|
87 TBuf16<160> buffer16; |
|
88 TBuf8<160> buf; |
|
89 TBuf8<20> protocol; |
|
90 |
|
91 aConsole.Printf( _L( "DOMAIN SETTINGS \n" ) ); |
|
92 |
|
93 buffer16.Copy( iSettings->Domain() ); |
|
94 aConsole.Printf( _L( "Domain name: %S\n" ), &buffer16 ); |
|
95 |
|
96 const CDesC8Array& array = iSettings->AvailableNatProtocols(); |
|
97 |
|
98 for ( TInt i( 0 ); i < array.Count(); i++ ) |
|
99 { |
|
100 protocol.Copy( array.MdcaPoint( i ) ); |
|
101 buf.AppendFormat( KProtocolFormat, &protocol ); |
|
102 } |
|
103 buffer16.Copy( buf ); |
|
104 aConsole.Printf( _L( "\nPriorityOrder = %S\n" ), &buffer16 ); |
|
105 |
|
106 if ( KNATFWDefaultUseSharedSecret == iSettings->UseSharedSecret() ) |
|
107 { |
|
108 aConsole.Printf( _L( "STUN Sharedsecret: %d - default\n" ), |
|
109 iSettings->UseSharedSecret() ); |
|
110 } |
|
111 else |
|
112 { |
|
113 aConsole.Printf( _L( "STUN Sharedsecret: %d\n" ), |
|
114 iSettings->UseSharedSecret() ); |
|
115 } |
|
116 |
|
117 aConsole.Printf( _L( " STUN SETTINGS\n" ) ); |
|
118 |
|
119 PrintStunServerSettings( aConsole ); |
|
120 |
|
121 aConsole.Printf( _L( " TURN SETTINGS \n" ) ); |
|
122 |
|
123 PrintTurnServerSettings( aConsole ); |
|
124 /* |
|
125 if( KNATFWDefaultTURNLifeTime == iSettings->TURNLifetime() ) |
|
126 { |
|
127 aConsole.Printf( _L( " Life time: %d -default\n" ), iSettings->TURNLifetime() ); |
|
128 } |
|
129 else |
|
130 { |
|
131 aConsole.Printf( _L( " Life time: %d\n" ), iSettings->TURNLifetime() ); |
|
132 } |
|
133 |
|
134 if( KNATFWDefaultTURNTimerValue == iSettings->TURNTimerValue() ) |
|
135 { |
|
136 aConsole.Printf( _L( " Timervalue: %d -default\n" ), iSettings->TURNTimerValue() ); |
|
137 } |
|
138 else |
|
139 { |
|
140 aConsole.Printf( _L( " Timervalue: %d\n" ), iSettings->TURNTimerValue() ); |
|
141 } |
|
142 |
|
143 aConsole.Printf( _L( " ICE SETTINGS \n" ) ); |
|
144 |
|
145 if( KNATFWDefaultICECanditateTimer == iSettings->ChooseAnotherCandidateTimer() ) |
|
146 { |
|
147 aConsole.Printf( _L( " anot.candid.timer: %d -default\n" ), iSettings->ChooseAnotherCandidateTimer() ); |
|
148 } |
|
149 else |
|
150 { |
|
151 aConsole.Printf( _L( " anot.candid.timer: %d\n" ), iSettings->ChooseAnotherCandidateTimer() ); |
|
152 } |
|
153 */ |
|
154 } |
|
155 |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // CNATSettingsTest::PrintStunServerSettings |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 void CNATSettingsTest::PrintStunServerSettings( CConsoleBase& aConsole ) |
|
162 { |
|
163 RPointerArray<MNATFWServerSettings> serverSettings; |
|
164 |
|
165 MNATFWStunSettings* stunSettings = &iSettings->StunSettingsL(); |
|
166 |
|
167 stunSettings->GetStunServerArrayL( serverSettings ); |
|
168 |
|
169 TUint count = serverSettings.Count(); |
|
170 TBuf<40> buffer; |
|
171 |
|
172 aConsole.Printf( _L( " Server settings found %d\n" ), count ); |
|
173 |
|
174 for( TUint i = 0; i < count; ++i ) |
|
175 { |
|
176 aConsole.Printf( _L( " Server %d settings\n" ), i ); |
|
177 buffer.Copy( serverSettings[i]->Address() ); |
|
178 aConsole.Printf( _L( " Address: %S\n" ), &buffer ); |
|
179 |
|
180 if ( KNATFWDefaultSTUNServerPort == serverSettings[i]->Port() ) |
|
181 { |
|
182 aConsole.Printf( _L( " Port: %d -default\n" ), serverSettings[i]->Port() ); |
|
183 } |
|
184 else |
|
185 { |
|
186 aConsole.Printf( _L( " Port: %d\n" ), serverSettings[i]->Port() ); |
|
187 } |
|
188 /* |
|
189 if ( KNATFWDefaultTCPTimeout == serverSettings[i]->TCPTimeout() ) |
|
190 { |
|
191 aConsole.Printf( _L( " TCP Refresh: %d -default\n" ), stunSettings->TCPTimeout() ); |
|
192 } |
|
193 else |
|
194 { |
|
195 aConsole.Printf( _L( " TCP Refresh: %d\n" ), serverSettings-[i]->TCPTimeout() ); |
|
196 } |
|
197 |
|
198 |
|
199 if ( KNATFWDefaultUDPTimeout == serverSettings->At( i ).UDPTimeout() ) |
|
200 { |
|
201 aConsole.Printf( _L( " UDP Refresh: %d -default\n " ), stunSettings->UDPTimeout() ); |
|
202 } |
|
203 else |
|
204 { |
|
205 aConsole.Printf( _L( " UDP Refresh: %d\n" ), serverSettings[i]->UDPTimeout() ); |
|
206 } |
|
207 |
|
208 if ( KNATFWDefaultConnectivityCheckTimeout == serverSettings[i]->ConnectivityCheckTimeout() ) |
|
209 { |
|
210 aConsole.Printf( _L( " ConnectivityCheckTimeout: %d -default\n" ), serverSettings[i]->ConnectivityCheckTimeout() ); |
|
211 } |
|
212 else |
|
213 { |
|
214 aConsole.Printf( _L( " ConnectivityCheckTimeout: %d\n" ), serverSettings[i]->ConnectivityCheckTimeout() ); |
|
215 } |
|
216 |
|
217 |
|
218 if ( KNATFWDefaultCRLFRefreshEnabled == serverSettings->At( i ).CRLFRefreshEnabled() ) |
|
219 { |
|
220 aConsole.Printf( _L( " CRLFRefreshEnabled: %d -default\n" ), serverSettings[i]->CRLFRefreshEnabled() ); |
|
221 } |
|
222 else |
|
223 { |
|
224 aConsole.Printf( _L( " CRLFRefreshEnabled: %d\n" ), serverSettings[i]->CRLFRefreshEnabled() ); |
|
225 } |
|
226 */ |
|
227 |
|
228 buffer.Copy( serverSettings[i]->Username() ); |
|
229 aConsole.Printf( _L( " Username: %S\n" ), &buffer ); |
|
230 |
|
231 buffer.Copy( serverSettings[i]->Password() ); |
|
232 aConsole.Printf( _L( " Password: %S\n" ), &buffer ); |
|
233 } |
|
234 |
|
235 serverSettings.Close(); |
|
236 } |
|
237 |
|
238 |
|
239 // --------------------------------------------------------------------------- |
|
240 // CNATSettingsTest::PrintTurnServerSettings |
|
241 // --------------------------------------------------------------------------- |
|
242 // |
|
243 void CNATSettingsTest::PrintTurnServerSettings( CConsoleBase& aConsole ) |
|
244 { |
|
245 RPointerArray<MNATFWServerSettings> serverSettings; |
|
246 |
|
247 MNATFWTurnSettings* turnSettings = &iSettings->TurnSettingsL(); |
|
248 |
|
249 turnSettings->GetTurnServerArrayL( serverSettings ); |
|
250 |
|
251 TUint count = serverSettings.Count(); |
|
252 TBuf<40> buffer; |
|
253 |
|
254 aConsole.Printf( _L( " Server settings found %d\n" ), count ); |
|
255 |
|
256 for( TUint i = 0; i < count; ++i ) |
|
257 { |
|
258 aConsole.Printf( _L( " Server %d settings\n" ), i ); |
|
259 buffer.Copy( serverSettings[i]->Address() ); |
|
260 aConsole.Printf( _L( " Address: %S\n" ), &buffer ); |
|
261 |
|
262 if ( KNATFWDefaultTURNServerPort == serverSettings[i]->Port() ) |
|
263 { |
|
264 aConsole.Printf( _L( " Port: %d -default\n" ), serverSettings[i]->Port() ); |
|
265 } |
|
266 else |
|
267 { |
|
268 aConsole.Printf( _L( " Port: %d\n" ), serverSettings[i]->Port() ); |
|
269 } |
|
270 /* |
|
271 if ( KNATFWDefaultTCPTimeout == serverSettings->At( i ).TCPTimeout() ) |
|
272 { |
|
273 aConsole.Printf( _L( " TCP Refresh: %d -default\n" ), serverSettings->At( i ).TCPTimeout() ); |
|
274 } |
|
275 else |
|
276 { |
|
277 aConsole.Printf( _L( " TCP Refresh: %d\n" ), serverSettings->At( i ).TCPTimeout() ); |
|
278 } |
|
279 |
|
280 |
|
281 if ( KNATFWDefaultUDPTimeout == serverSettings->At( i ).UDPTimeout() ) |
|
282 { |
|
283 aConsole.Printf( _L( " UDP Refresh: %d -default\n " ), serverSettings->At( i ).UDPTimeout() ); |
|
284 } |
|
285 else |
|
286 { |
|
287 aConsole.Printf( _L( " UDP Refresh: %d\n" ), serverSettings->At( i ).UDPTimeout() ); |
|
288 } |
|
289 |
|
290 |
|
291 if ( KNATFWDefaultConnectivityCheckTimeout == serverSettings->At( i ).ConnectivityCheckTimeout() ) |
|
292 { |
|
293 aConsole.Printf( _L( " ConnectivityCheckTimeout: %d -default\n" ), serverSettings->At( i ).ConnectivityCheckTimeout() ); |
|
294 } |
|
295 else |
|
296 { |
|
297 aConsole.Printf( _L( " ConnectivityCheckTimeout: %d\n" ), serverSettings->At( i ).ConnectivityCheckTimeout() ); |
|
298 } |
|
299 |
|
300 |
|
301 |
|
302 if ( KNATFWDefaultCRLFRefreshEnabled == serverSettings->At( i ).CRLFRefreshEnabled() ) |
|
303 { |
|
304 aConsole.Printf( _L( " CRLFRefreshEnabled: %d -default\n" ), serverSettings->At( i ).CRLFRefreshEnabled() ); |
|
305 } |
|
306 else |
|
307 { |
|
308 aConsole.Printf( _L( " CRLFRefreshEnabled: %d\n" ), serverSettings->At( i ).CRLFRefreshEnabled() ); |
|
309 } |
|
310 */ |
|
311 } |
|
312 |
|
313 serverSettings.Close(); |
|
314 } |