|
1 /* |
|
2 * Copyright (c) 2002 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: Defines a class, which holds proxy port information. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 |
|
24 #include "CWPAPPort.h" // Own header |
|
25 #include "WPAPAdapter.pan" |
|
26 #include "CWPLog.h" |
|
27 #include "WPAPDefs.h" |
|
28 |
|
29 #include <CWPCharacteristic.h> |
|
30 #include <CWPParameter.h> |
|
31 |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CWPAPPort::NewL |
|
37 // Two-phased constructor. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CWPAPPort* CWPAPPort::NewLC( CWPCharacteristic& aCharacteristic ) |
|
41 { |
|
42 CWPAPPort* self = new(ELeave) CWPAPPort(); |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL(); |
|
45 aCharacteristic.AcceptL( *self ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CWPAPPort::CWPAPPort |
|
51 // C++ default constructor can NOT contain any code, that |
|
52 // might leave. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CWPAPPort::CWPAPPort() : CWPAPItemBase( KNullDesC ) |
|
56 { |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // Destructor |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CWPAPPort::~CWPAPPort() |
|
64 { |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CWPAPPort::Validate |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 TBool CWPAPPort::ValidateL() |
|
72 { |
|
73 // If we got either service or portnumber and |
|
74 // Those we successfully interpreted the port |
|
75 // information is valid. |
|
76 if ( IsReceived( EWPParameterService_id ) || |
|
77 IsReceived( EWPParameterPortNbr_id )) |
|
78 { |
|
79 return ETrue; |
|
80 } |
|
81 LOG("CWPAP ERROR! Port not valid"); |
|
82 return EFalse; // Nothing received so this is invalid. |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CWPAPPort::AddData |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CWPAPPort::AddDataL( RCmConnectionMethodExt& aCmItem ) |
|
90 { |
|
91 LOG("--CWPAP CWPAPPort::AddDataL begin--"); |
|
92 TInt err(KErrNone); |
|
93 |
|
94 // CMManager |
|
95 TRAP (err, aCmItem.SetBoolAttributeL( CMManager::ECmWapIPSecurity, iConnectionSecurity )); |
|
96 LOG2("CWPAP EApWapSecurity, value: %d, err: %d", iConnectionSecurity, err); |
|
97 |
|
98 // CMManager |
|
99 TRAP (err, aCmItem.SetIntAttributeL( CMManager::ECmWapIPWSPOption, iSessionMode )); |
|
100 LOG2("CWPAP EApWapWspOption, value: %d, err: %d", iSessionMode, err); |
|
101 |
|
102 if ( iPortNbr ) |
|
103 { |
|
104 const TDesC& value = iPortNbr->Value(); |
|
105 TLex lex( value ); |
|
106 TUint32 intValue=0; |
|
107 err = lex.Val( intValue, EDecimal ); |
|
108 if ( err == KErrNone ) |
|
109 { |
|
110 if( intValue > 65535 ) |
|
111 { |
|
112 intValue = 0; |
|
113 } |
|
114 |
|
115 // CMManager |
|
116 TRAP (err, aCmItem.SetIntAttributeL( CMManager::ECmProxyPortNumber, intValue )); |
|
117 LOG2("CWPAP EApProxyPortNumber, value: %d, err: %d", |
|
118 intValue, err); |
|
119 } |
|
120 } |
|
121 LOG("--CWPAP CWPAPPort::AddDataL end--"); |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CWPAPPort::Name |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 const TDesC& CWPAPPort::Name() |
|
129 { |
|
130 return KNullDesC; |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CWPAPPort::AddItemsL |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 TInt CWPAPPort::AddItemsL( RPointerArray<CWPAPAccesspointItem>& /*aItems*/, |
|
138 CWPAPItemBase* /*aLogicalProxy*/, |
|
139 CWPAPItemBase* /*aPhysicalProxy*/ ) |
|
140 { |
|
141 return KErrNone; |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CWPAPPort::VisitL |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 void CWPAPPort::VisitL( CWPCharacteristic& /*aCharacteristic*/ ) |
|
149 { |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CWPAPPort::VisitL |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void CWPAPPort::VisitL( CWPParameter& aParameter ) |
|
157 { |
|
158 TInt id = aParameter.ID(); |
|
159 const TDesC& value = aParameter.Value(); |
|
160 |
|
161 if ( value.Length() == 0 ) |
|
162 { |
|
163 // No use of checking the zero legth parameter. |
|
164 return; |
|
165 } |
|
166 |
|
167 switch ( id ) |
|
168 { |
|
169 case EWPParameterService: // iConnectionSecurity and iSessionMode |
|
170 { |
|
171 // If EWPParameterService value have already received |
|
172 // or service type has been solved from EWPParameterPortNbr value |
|
173 // don't accept this anymore. |
|
174 if ( IsReceived( EWPParameterService_id ) ) |
|
175 { |
|
176 break; |
|
177 } |
|
178 |
|
179 if ( value == KCLWSP) |
|
180 { |
|
181 // CMManager |
|
182 SetValues( EFalse, CMManager::ECmWapWspOptionConnectionless, |
|
183 EWPParameterPortNbr_id ); |
|
184 } |
|
185 else if ( value == KCOWSP) |
|
186 { |
|
187 // CMManager |
|
188 SetValues( EFalse, CMManager::ECmWapWspOptionConnectionOriented, |
|
189 EWPParameterPortNbr_id ); |
|
190 |
|
191 } |
|
192 else if ( value == KCLSECWSP) |
|
193 { |
|
194 // CMManager |
|
195 SetValues( ETrue, CMManager::ECmWapWspOptionConnectionless, |
|
196 EWPParameterPortNbr_id ); |
|
197 } |
|
198 else if ( value == KCOSECWSP) |
|
199 { |
|
200 // CMManager |
|
201 SetValues( ETrue, CMManager::ECmWapWspOptionConnectionOriented, |
|
202 EWPParameterPortNbr_id ); |
|
203 } |
|
204 else |
|
205 { |
|
206 // Not supported... |
|
207 } |
|
208 break; |
|
209 } |
|
210 case EWPParameterPortNbr: // iConnectionSecurity and iSessionMode |
|
211 { |
|
212 // If EWPParameterPortNbr value have already handled |
|
213 // don't accept it anymore. |
|
214 if ( IsReceived( EWPParameterPortNbr_id ) ) |
|
215 { |
|
216 break; |
|
217 } |
|
218 |
|
219 // Store the pointer to port parameter |
|
220 iPortNbr = &aParameter; |
|
221 MarkReceived( EWPParameterPortNbr_id ); |
|
222 |
|
223 if ( value == K9200 ) |
|
224 { |
|
225 // CMManager |
|
226 SetValues( EFalse, CMManager::ECmWapWspOptionConnectionless, |
|
227 EWPParameterPortNbr_id ); |
|
228 |
|
229 // Type of service identified. |
|
230 // No need for Service parameter anymore. |
|
231 MarkReceived( EWPParameterService_id ); |
|
232 } |
|
233 else if ( value == K9201 || value == K80 || value == K8080) |
|
234 { |
|
235 // CMManager |
|
236 SetValues( EFalse, CMManager::ECmWapWspOptionConnectionOriented, |
|
237 EWPParameterPortNbr_id ); |
|
238 MarkReceived( EWPParameterService_id ); |
|
239 } |
|
240 else if ( value == K9202 ) |
|
241 { |
|
242 // CMManager |
|
243 SetValues( ETrue, CMManager::ECmWapWspOptionConnectionless, |
|
244 EWPParameterPortNbr_id ); |
|
245 MarkReceived( EWPParameterService_id ); |
|
246 } |
|
247 else if ( value == K9203 || value == K443 ) |
|
248 { |
|
249 // CMManager |
|
250 SetValues( ETrue, CMManager::ECmWapWspOptionConnectionOriented, |
|
251 EWPParameterPortNbr_id ); |
|
252 MarkReceived( EWPParameterService_id ); |
|
253 } |
|
254 else |
|
255 { |
|
256 // Not supported... |
|
257 } |
|
258 break; |
|
259 } |
|
260 default: |
|
261 { |
|
262 // Just let through |
|
263 } |
|
264 } |
|
265 } |
|
266 |
|
267 // ----------------------------------------------------------------------------- |
|
268 // CWPAPPort::SetValues |
|
269 // ----------------------------------------------------------------------------- |
|
270 // |
|
271 void CWPAPPort::SetValues( TBool aConnectionSecurity, |
|
272 TInt aSessionMode, |
|
273 TMarkedField aReceivedField ) |
|
274 { |
|
275 __ASSERT_DEBUG( aReceivedField == EWPParameterService_id || |
|
276 aReceivedField == EWPParameterPortNbr_id, |
|
277 Panic( EPreConditionFail ) ); |
|
278 |
|
279 iConnectionSecurity = aConnectionSecurity; |
|
280 iSessionMode = aSessionMode; |
|
281 |
|
282 MarkReceived( aReceivedField ); |
|
283 } |
|
284 |
|
285 // ----------------------------------------------------------------------------- |
|
286 // CWPAPPort::ConstructL |
|
287 // Symbian 2nd phase constructor can leave. |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 void CWPAPPort::ConstructL() |
|
291 { |
|
292 } |
|
293 |
|
294 // End of File |