|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 // System includes |
|
17 #include <cdbstore.h> |
|
18 #include <cdbcols.h> |
|
19 #include <httpstringconstants.h> |
|
20 #include <wsperror.h> |
|
21 #include <wsp/wsptypes.h> |
|
22 |
|
23 // User includes |
|
24 #include "wsppanic.h" |
|
25 |
|
26 // Class signature |
|
27 #include "cwspproxyinfoprovider.h" |
|
28 |
|
29 // Constants used in this file |
|
30 const TInt KPortSecureCO = 9203; |
|
31 const TInt KPortInsecureCO = 9201; |
|
32 const TInt KPortSecureCL = 9202; |
|
33 const TInt KPortInsecureCL = 9200; |
|
34 |
|
35 CWspProxyInfoProvider* CWspProxyInfoProvider::NewL(RHTTPSession aSession) |
|
36 { |
|
37 return new (ELeave) CWspProxyInfoProvider(aSession); |
|
38 } |
|
39 |
|
40 CWspProxyInfoProvider::~CWspProxyInfoProvider() |
|
41 { |
|
42 // Cleanup the proxy info |
|
43 iProxyInfo.Close(); |
|
44 } |
|
45 |
|
46 CWspProxyInfoProvider::CWspProxyInfoProvider(RHTTPSession aSession) |
|
47 : CBase(), iSession(aSession) |
|
48 { |
|
49 } |
|
50 |
|
51 void CWspProxyInfoProvider::UpdateProxyInfoL() |
|
52 { |
|
53 // Has a proxy redirection occured? |
|
54 if( iProxyInfoLocked ) |
|
55 { |
|
56 // Yes the current proxy info is the redirected proxy info - don't |
|
57 // change, but reset the redirection flag |
|
58 iProxyInfoLocked = EFalse; |
|
59 } |
|
60 else |
|
61 { |
|
62 // Get the client specified proxy info |
|
63 TProxyInfo proxyInfo = GetProxyInfoL(); |
|
64 |
|
65 // Cleanup the current proxy info |
|
66 iProxyInfo.Close(); |
|
67 |
|
68 // Set the proxy info to its new value |
|
69 iProxyInfo = proxyInfo; |
|
70 } |
|
71 } |
|
72 void CWspProxyInfoProvider::SetTemporaryRedirectedProxyL(TWspRedirectedAddress& aRedirectAddress) |
|
73 { |
|
74 // Change current proxy info to the redirected one |
|
75 ChangeToRedirectedProxyInfoL(aRedirectAddress); |
|
76 } |
|
77 |
|
78 void CWspProxyInfoProvider::SetPermanentRedirectedProxyL(TWspRedirectedAddress& aRedirectAddress) |
|
79 { |
|
80 // Change current proxy info to the redirected one |
|
81 ChangeToRedirectedProxyInfoL(aRedirectAddress); |
|
82 |
|
83 // Set HTTP session properties with the redirected proxy info |
|
84 RHTTPConnectionInfo connInfo = iSession.ConnectionInfo(); |
|
85 RStringPool stringPool = iSession.StringPool(); |
|
86 |
|
87 // Set the proxy address |
|
88 THTTPHdrVal address = iProxyInfo.iProxyAddress; |
|
89 connInfo.SetPropertyL(stringPool.StringF(HTTP::EWspProxyAddress, RHTTPSession::GetTable()), address); |
|
90 |
|
91 // Set the bearer |
|
92 THTTPHdrVal bearer; |
|
93 if( iProxyInfo.iBearer == EIP ) |
|
94 { |
|
95 bearer = THTTPHdrVal(stringPool.StringF(HTTP::EWspIp, RHTTPSession::GetTable())); |
|
96 |
|
97 // Need to set the port as this is an IP bearer |
|
98 THTTPHdrVal port = iProxyInfo.iRemotePort; |
|
99 connInfo.SetPropertyL(stringPool.StringF(HTTP::EWspRemotePort, RHTTPSession::GetTable()), port); |
|
100 } |
|
101 else |
|
102 { |
|
103 __ASSERT_DEBUG( iProxyInfo.iBearer == EWAPSMS, Panic(KWspPanicBadBearerType) ); |
|
104 |
|
105 // Must be an SMS bearer otherwise would have left before this |
|
106 bearer = THTTPHdrVal(stringPool.StringF(HTTP::EWspSMS, RHTTPSession::GetTable())); |
|
107 } |
|
108 connInfo.SetPropertyL(stringPool.StringF(HTTP::EWspBearer, RHTTPSession::GetTable()), bearer); |
|
109 } |
|
110 |
|
111 TBool CWspProxyInfoProvider::ProxyInfoChangedAndUpdateL() |
|
112 { |
|
113 // Get the client specified proxy info |
|
114 TProxyInfo proxyInfo = GetProxyInfoL(); |
|
115 |
|
116 // Compare against current proxy info |
|
117 TBool hasChanged = proxyInfo != iProxyInfo; |
|
118 |
|
119 // Cleanup the current proxy info |
|
120 iProxyInfo.Close(); |
|
121 |
|
122 // Set the proxy info to its new value |
|
123 iProxyInfo = proxyInfo; |
|
124 |
|
125 // Set the locked flag |
|
126 iProxyInfoLocked = ETrue; |
|
127 |
|
128 return hasChanged; |
|
129 } |
|
130 |
|
131 void CWspProxyInfoProvider::UnlockProxyInfo() |
|
132 { |
|
133 // Clear the locked flag |
|
134 iProxyInfoLocked = EFalse; |
|
135 } |
|
136 |
|
137 void CWspProxyInfoProvider::ResetProxyInfo() |
|
138 { |
|
139 // Reset to the state after construction. |
|
140 UnlockProxyInfo(); |
|
141 iProxyInfo.Close(); |
|
142 } |
|
143 |
|
144 void CWspProxyInfoProvider::ChangeToRedirectedProxyInfoL(TWspRedirectedAddress& aRedirectAddress) |
|
145 { |
|
146 // Set the proxy info - first the proxy address, convert the descriptor to an RStringF |
|
147 TProxyInfo proxyInfo; |
|
148 proxyInfo.iProxyAddress = iSession.StringPool().OpenFStringL(aRedirectAddress.iProxyAddress); |
|
149 CleanupStack::PushL(&proxyInfo.iProxyAddress); |
|
150 |
|
151 // Check for bearer type |
|
152 if( aRedirectAddress.iHasBearer ) |
|
153 { |
|
154 // Use the given bearer |
|
155 proxyInfo.iBearer = aRedirectAddress.iBearer; |
|
156 |
|
157 if( proxyInfo.iBearer == ESMS ) |
|
158 { |
|
159 // Get the Service centre number from the Comms DB |
|
160 ReadServiceCentreNumberL(iSession.StringPool(), proxyInfo.iServiceCentreNumber); |
|
161 } |
|
162 } |
|
163 else |
|
164 { |
|
165 // Use the current bearer |
|
166 proxyInfo.iBearer = iProxyInfo.iBearer; |
|
167 |
|
168 if( proxyInfo.iBearer == ESMS ) |
|
169 { |
|
170 // Copy the service centre number |
|
171 proxyInfo.iServiceCentreNumber = iProxyInfo.iServiceCentreNumber.Copy(); |
|
172 } |
|
173 } |
|
174 |
|
175 // Clean up - proxyInfo retains ownership of the RStringF |
|
176 CleanupStack::Pop(&proxyInfo.iProxyAddress); |
|
177 |
|
178 // Check for port number |
|
179 if( aRedirectAddress.iHasPort ) |
|
180 { |
|
181 // Use the given bearer |
|
182 proxyInfo.iRemotePort = aRedirectAddress.iPort; |
|
183 } |
|
184 else |
|
185 { |
|
186 // Use the current bearer |
|
187 proxyInfo.iRemotePort = iProxyInfo.iRemotePort; |
|
188 } |
|
189 // Copy over the other info |
|
190 proxyInfo.iSecureConnection = iProxyInfo.iSecureConnection; |
|
191 proxyInfo.iLocalPort = iProxyInfo.iLocalPort; |
|
192 proxyInfo.iSessionType = iProxyInfo.iSessionType; |
|
193 |
|
194 // Set the current proxy info to the new info. |
|
195 // Cleanup the current proxy info |
|
196 iProxyInfo.Close(); |
|
197 |
|
198 // Set the proxy info to its new value |
|
199 iProxyInfo = proxyInfo; |
|
200 |
|
201 // Set the locked flag |
|
202 iProxyInfoLocked = ETrue; |
|
203 } |
|
204 |
|
205 TProxyInfo CWspProxyInfoProvider::GetProxyInfoL() const |
|
206 { |
|
207 // Check the session properties first... |
|
208 RHTTPConnectionInfo connInfo = iSession.ConnectionInfo(); |
|
209 RStringPool stringPool = iSession.StringPool(); |
|
210 TProxyInfo proxyInfo; |
|
211 |
|
212 // Need to check to see if the proxy address has been specified in the HTTP |
|
213 // session properties, otherwise need to get proxy info from the Comms |
|
214 // Database. |
|
215 THTTPHdrVal namedProxyValue; |
|
216 TBool useNamedProxy = connInfo.Property(stringPool.StringF(HTTP::EWspProxyAddress, RHTTPSession::GetTable()), namedProxyValue); |
|
217 if( useNamedProxy ) |
|
218 { |
|
219 // First, get the session service type - make sure it is not CL |
|
220 proxyInfo.iSessionType = ExtractSessionTypeFromSession(connInfo, stringPool); |
|
221 if( proxyInfo.iSessionType == EWspConnectionLess ) |
|
222 { |
|
223 // Don't support CL at the moment, so leave |
|
224 User::Leave(KErrNotSupported); |
|
225 } |
|
226 |
|
227 // Now get the proxy address... |
|
228 __ASSERT_DEBUG((namedProxyValue.Type() == THTTPHdrVal::KStrFVal), Panic(KWspPanicBadProxyAddressProperty)); |
|
229 proxyInfo.iProxyAddress = namedProxyValue.StrF().Copy(); |
|
230 |
|
231 // ...the bearer... |
|
232 proxyInfo.iBearer = ExtractBearerInfoFromSession(connInfo, stringPool); |
|
233 |
|
234 // ...security type... |
|
235 proxyInfo.iSecureConnection = ExtractSecurityInfoFromSession(connInfo, stringPool); |
|
236 |
|
237 // Get bearer specific stuff |
|
238 if( proxyInfo.iBearer == EIP ) |
|
239 { |
|
240 // For IP, need local and remote ports |
|
241 proxyInfo.iLocalPort = ExtractPortInfoFromSession(HTTP::EWspLocalPort, connInfo, stringPool); |
|
242 proxyInfo.iRemotePort = ExtractPortInfoFromSession(HTTP::EWspRemotePort, connInfo, stringPool); |
|
243 |
|
244 // Check for correct default value |
|
245 if( proxyInfo.iRemotePort == 0 ) |
|
246 proxyInfo.iRemotePort = DefaultRemotePort(proxyInfo.iSecureConnection, ETrue); |
|
247 } |
|
248 else |
|
249 { |
|
250 // For SMS stuff need the Service number - no default, leave if not set |
|
251 THTTPHdrVal serviceNumberValue; |
|
252 TBool hasServiceNumber = connInfo.Property(stringPool.StringF(HTTP::EWspServiceNumber, RHTTPSession::GetTable()), serviceNumberValue); |
|
253 if( hasServiceNumber ) |
|
254 { |
|
255 __ASSERT_DEBUG((serviceNumberValue.Type() == THTTPHdrVal::KStrFVal), Panic(KWspPanicBadServiceNumberProperty)); |
|
256 proxyInfo.iServiceCentreNumber = serviceNumberValue.StrF().Copy(); |
|
257 } |
|
258 else |
|
259 User::Leave(KWspErrServiceNumberNotDefined); |
|
260 } |
|
261 } |
|
262 else |
|
263 { |
|
264 // Read proxy info from CommDB |
|
265 ReadWapAccessPointInfoL(stringPool, proxyInfo.iBearer, |
|
266 proxyInfo.iProxyAddress, |
|
267 proxyInfo.iSecureConnection, |
|
268 proxyInfo.iServiceCentreNumber, |
|
269 proxyInfo.iSessionType); |
|
270 |
|
271 // Check the bearer |
|
272 if( proxyInfo.iBearer == EIP ) |
|
273 { |
|
274 // Initialise the local and remote port values for the IP bearer |
|
275 proxyInfo.iLocalPort = 0; |
|
276 proxyInfo.iRemotePort = DefaultRemotePort(proxyInfo.iSecureConnection, ETrue); |
|
277 } |
|
278 } |
|
279 return proxyInfo; |
|
280 } |
|
281 |
|
282 /* |
|
283 * Methods from MWspProxyInfoProvider |
|
284 */ |
|
285 |
|
286 const TDesC8& CWspProxyInfoProvider::ProxyAddress() const |
|
287 { |
|
288 return iProxyInfo.iProxyAddress.DesC(); |
|
289 } |
|
290 |
|
291 TUint16 CWspProxyInfoProvider::RemotePort() const |
|
292 { |
|
293 return iProxyInfo.iRemotePort; |
|
294 } |
|
295 |
|
296 TUint16 CWspProxyInfoProvider::LocalPort() const |
|
297 { |
|
298 return iProxyInfo.iLocalPort; |
|
299 } |
|
300 |
|
301 TWspBearer CWspProxyInfoProvider::Bearer() const |
|
302 { |
|
303 return iProxyInfo.iBearer; |
|
304 } |
|
305 |
|
306 const TDesC8& CWspProxyInfoProvider::ServiceCentreNumber() const |
|
307 { |
|
308 return iProxyInfo.iServiceCentreNumber.DesC(); |
|
309 } |
|
310 |
|
311 TWspSession CWspProxyInfoProvider::WspSessionService() const |
|
312 { |
|
313 return iProxyInfo.iSessionType; |
|
314 } |
|
315 |
|
316 TBool CWspProxyInfoProvider::SecureConnection() const |
|
317 { |
|
318 return iProxyInfo.iSecureConnection; |
|
319 } |
|
320 |
|
321 TWspSession CWspProxyInfoProvider::ExtractSessionTypeFromSession(RHTTPConnectionInfo aConnInfo, RStringPool aStringPool) |
|
322 { |
|
323 // Check for the Wsp Session Service type, or use default value of |
|
324 // EWspConnectionOriented. |
|
325 TWspSession session = EWspConnectionOriented; |
|
326 |
|
327 THTTPHdrVal sessionType; |
|
328 TBool hasSessionType = aConnInfo.Property(aStringPool.StringF(HTTP::EWspSessionType, RHTTPSession::GetTable()), sessionType); |
|
329 if( hasSessionType ) |
|
330 { |
|
331 __ASSERT_DEBUG((sessionType.Type() == THTTPHdrVal::KStrFVal), Panic(KWspPanicBadWspSessionTypeProperty)); |
|
332 switch (sessionType.StrF().Index(RHTTPSession::GetTable())) |
|
333 { |
|
334 case HTTP::EWspConnectionOriented: |
|
335 { |
|
336 // Nothing to do as session type already set to default |
|
337 } break; |
|
338 case HTTP::EWspConnectionLess: |
|
339 { |
|
340 session = EWspConnectionLess; |
|
341 } break; |
|
342 default: |
|
343 __ASSERT_DEBUG(ETrue, Panic(KWspPanicBadWspSessionTypeProperty)); |
|
344 } |
|
345 } |
|
346 return session; |
|
347 } |
|
348 |
|
349 TWspBearer CWspProxyInfoProvider::ExtractBearerInfoFromSession(RHTTPConnectionInfo aConnInfo, RStringPool aStringPool) |
|
350 { |
|
351 // Check for bearer property, or use default value of EIP |
|
352 TWspBearer bearer = EIP; |
|
353 |
|
354 THTTPHdrVal bearerValue; |
|
355 TBool hasBearer = aConnInfo.Property(aStringPool.StringF(HTTP::EWspBearer, RHTTPSession::GetTable()), bearerValue); |
|
356 if( hasBearer ) |
|
357 { |
|
358 __ASSERT_DEBUG((bearerValue.Type() == THTTPHdrVal::KStrFVal), Panic(KWspPanicBadBearerProperty)); |
|
359 switch (bearerValue.StrF().Index(RHTTPSession::GetTable())) |
|
360 { |
|
361 case HTTP::EWspIp: |
|
362 { |
|
363 // Nothing to do as bearer already set to default |
|
364 } break; |
|
365 case HTTP::EWspSMS: |
|
366 { |
|
367 bearer = EWAPSMS; |
|
368 } |
|
369 default: |
|
370 __ASSERT_DEBUG(ETrue, Panic(KWspPanicBadBearerProperty)); |
|
371 } |
|
372 } |
|
373 return bearer; |
|
374 } |
|
375 |
|
376 TBool CWspProxyInfoProvider::ExtractSecurityInfoFromSession(RHTTPConnectionInfo aConnInfo, RStringPool aStringPool) |
|
377 { |
|
378 // Check for security property, or use default value of unsecured |
|
379 TBool useWtls = EFalse; |
|
380 |
|
381 THTTPHdrVal securityValue; |
|
382 TBool hasSecurityValue = aConnInfo.Property(aStringPool.StringF(HTTP::EWspSecurity, RHTTPSession::GetTable()), securityValue); |
|
383 if( hasSecurityValue ) |
|
384 { |
|
385 __ASSERT_DEBUG((securityValue.Type() == THTTPHdrVal::KStrFVal), Panic(KWspPanicBadSecurityProperty)); |
|
386 switch (securityValue.StrF().Index(RHTTPSession::GetTable())) |
|
387 { |
|
388 case HTTP::EWspUseWtls: |
|
389 { |
|
390 useWtls = ETrue; |
|
391 } break; |
|
392 case HTTP::EWspDoNotUseWtls: |
|
393 { |
|
394 // Nothing to do as security level already set to default |
|
395 } break; |
|
396 default: |
|
397 __ASSERT_DEBUG(ETrue, Panic(KWspPanicBadSecurityProperty)); |
|
398 } |
|
399 } |
|
400 return useWtls; |
|
401 } |
|
402 |
|
403 TUint16 CWspProxyInfoProvider::ExtractPortInfoFromSession(TInt aPortType, RHTTPConnectionInfo aConnInfo, RStringPool aStringPool) |
|
404 { |
|
405 // Check for the specified port property, or use the default value of 0 |
|
406 TUint16 port = 0; |
|
407 |
|
408 THTTPHdrVal portValue; |
|
409 TBool hasPort = aConnInfo.Property(aStringPool.StringF(aPortType, RHTTPSession::GetTable()), portValue); |
|
410 if( hasPort ) |
|
411 { |
|
412 __ASSERT_DEBUG((portValue.Type() == THTTPHdrVal::KTIntVal), Panic(KWspPanicBadPortProperty)); |
|
413 port = STATIC_CAST(TUint16, portValue.Int()); |
|
414 } |
|
415 return port; |
|
416 } |
|
417 |
|
418 TUint16 CWspProxyInfoProvider::DefaultRemotePort(TBool aSecureConnection, TBool aCOConnection) |
|
419 { |
|
420 TUint16 port = 0; |
|
421 if( aCOConnection ) |
|
422 { |
|
423 // Defaults for CO session |
|
424 if( aSecureConnection ) |
|
425 port = KPortSecureCO; |
|
426 else |
|
427 port = KPortInsecureCO; |
|
428 } |
|
429 else |
|
430 { |
|
431 // Defaults for CL session |
|
432 if( aSecureConnection ) |
|
433 port = KPortSecureCL; |
|
434 else |
|
435 port = KPortInsecureCL; |
|
436 } |
|
437 return port; |
|
438 } |
|
439 |
|
440 void CWspProxyInfoProvider::ReadWapAccessPointInfoL( |
|
441 RStringPool aStringPool, |
|
442 TWspBearer& aBearer, |
|
443 RStringF& aProxyAddress, |
|
444 TBool& aSecureConnection, |
|
445 RStringF& aServiceCentreNumber, |
|
446 TWspSession& aSessionServiceType |
|
447 ) |
|
448 { |
|
449 // Open the Comms DB - don't specify whether it should be a IAP or ISP |
|
450 // style DB - this doesn't matter here. |
|
451 CCommsDatabase* db=CCommsDatabase::NewL(EDatabaseTypeUnspecified); |
|
452 CleanupStack::PushL(db); |
|
453 |
|
454 // Find the ID of the WAP Access Point marked in the global settings. This |
|
455 // is the 'default' WAP AP, as marked by the user's most recent selection |
|
456 // of a bookmark in the WAP browser. |
|
457 TUint32 wapAPID; |
|
458 db->GetGlobalSettingL(TPtrC(WAP_ACCESS_POINT), wapAPID); |
|
459 |
|
460 // Open a view on the WAP AP Table, selecting the WAP Access Point that |
|
461 // matches wapAPID. We expect only one record to in the view as we're |
|
462 // selecting against a unique ID! |
|
463 CCommsDbTableView* apView= |
|
464 db->OpenViewMatchingUintLC(TPtrC(WAP_ACCESS_POINT) |
|
465 , TPtrC(COMMDB_ID), wapAPID); |
|
466 if( apView->GotoFirstRecord() != KErrNone ) |
|
467 User::Leave(KWspErrAccessPointNotSetUp); |
|
468 |
|
469 // Read the Bearer name specified in the selected WAP AP record. |
|
470 HBufC* bearer16 = HBufC::NewL(KCommsDbSvrMaxFieldLength); |
|
471 CleanupStack::PushL(bearer16); |
|
472 TPtr bearerPtr16 = bearer16->Des(); |
|
473 apView->ReadTextL(TPtrC(WAP_CURRENT_BEARER), bearerPtr16); |
|
474 |
|
475 // Open a view on the appropriate bearer table according to the bearer |
|
476 // name. Use the WAP AP ID to select a record in the appropriate WAP |
|
477 // bearer table (either WAP_IP_BEARER or WAP_SMS_BEARER). |
|
478 CCommsDbTableView* bearerView = NULL; |
|
479 if( bearerPtr16.Compare(TPtrC(WAP_SMS_BEARER)) == 0 ) // SMS (8-bit WAP SMS) |
|
480 { |
|
481 aBearer = EWAPSMS; |
|
482 bearerView = db->OpenViewMatchingUintLC( |
|
483 TPtrC(WAP_SMS_BEARER), // table name |
|
484 TPtrC(WAP_ACCESS_POINT_ID), // column to match |
|
485 wapAPID // value to match |
|
486 ); |
|
487 } |
|
488 else if( bearerPtr16.Compare(TPtrC(WAP_IP_BEARER)) == 0 ) // IPv4 |
|
489 { |
|
490 aBearer = EIP; |
|
491 bearerView = db->OpenViewMatchingUintLC( |
|
492 TPtrC(WAP_IP_BEARER), // table name |
|
493 TPtrC(WAP_ACCESS_POINT_ID), // column to match |
|
494 wapAPID // value to match |
|
495 ); |
|
496 } |
|
497 else |
|
498 { |
|
499 // Some unknown and unsupported bearer was specified - leave. |
|
500 User::Leave(KWspErrAccessPointNotSetUp); |
|
501 } |
|
502 |
|
503 // Navigate to the first record matching our selection in the view. We |
|
504 // expect only one record to in the view as we don't want more than one IP |
|
505 // or SMS bearer definition per WAP AP. |
|
506 if( bearerView->GotoFirstRecord() != KErrNone ) |
|
507 User::Leave(KWspErrAccessPointNotSetUp); |
|
508 |
|
509 // Read the Secure connection flag from the chosen bearer record. |
|
510 bearerView->ReadBoolL(TPtrC(WAP_SECURITY), aSecureConnection); |
|
511 |
|
512 // Read the Gateway from the WAP AP settings. It is held as a UNICODE |
|
513 // descriptor - convert this to 8-bit before returning |
|
514 // NB the Gateway field in CommDB is actually used to hold the SMS Service |
|
515 // Number when SMS is used as a bearer. However, the field type is |
|
516 // specified separately as an addressing scheme, so read that first and |
|
517 // use it for validation. |
|
518 HBufC* gateway16 = HBufC::NewL(KCommsDbSvrMaxFieldLength); |
|
519 CleanupStack::PushL(gateway16); |
|
520 TPtr gatewayPtr16 = gateway16->Des(); |
|
521 bearerView->ReadTextL(TPtrC(WAP_GATEWAY_ADDRESS), gatewayPtr16); |
|
522 |
|
523 // Copy to 8-bits... |
|
524 HBufC8* gateway8 = HBufC8::NewL(gatewayPtr16.Length()); |
|
525 CleanupStack::PushL(gateway8); |
|
526 TPtr8 gatewayPtr8 = gateway8->Des(); |
|
527 gatewayPtr8.Copy(gatewayPtr16); |
|
528 |
|
529 if( aBearer == EIP ) |
|
530 { |
|
531 // Set gateway as an IPv4 quadruplet; service number is not being used |
|
532 // so clear it. |
|
533 aProxyAddress = aStringPool.OpenFStringL(gatewayPtr8); |
|
534 aServiceCentreNumber = RStringF(); |
|
535 } |
|
536 else // aBearer == EWapSMS |
|
537 { |
|
538 // Set gateway as a service number - this is the proxy address |
|
539 aProxyAddress = aStringPool.OpenFStringL(gatewayPtr8); |
|
540 |
|
541 // Only the SMS bearer has a Service Centre Address |
|
542 |
|
543 // Read the Service Centre Address from the WAP AP settings. This is |
|
544 // in the form of a phone number when SMS is being used as a bearer. |
|
545 // Note: this isn't used by HTTP to configure the WAP stack - it is |
|
546 // used by the WAP stack to configure the SMS stack. HTTP doesn't need |
|
547 // to worry about it. However, store it anyway, just in case... |
|
548 HBufC* svcCentreAddr16 = HBufC::NewL(KCommsDbSvrMaxFieldLength); |
|
549 CleanupStack::PushL(svcCentreAddr16); |
|
550 |
|
551 TPtr svcCentreAddrPtr16 = svcCentreAddr16->Des(); |
|
552 bearerView->ReadTextL(TPtrC(WAP_SERVICE_CENTRE_ADDRESS), |
|
553 svcCentreAddrPtr16); |
|
554 |
|
555 // Copy to 8-bits... |
|
556 HBufC8* svcCentreAddr8 = HBufC8::NewL(svcCentreAddrPtr16.Length()); |
|
557 CleanupStack::PushL(svcCentreAddr8); |
|
558 TPtr8 svcCentreAddrPtr8 = svcCentreAddr8->Des(); |
|
559 svcCentreAddrPtr8.Copy(svcCentreAddrPtr16); |
|
560 |
|
561 aServiceCentreNumber = aStringPool.OpenFStringL(svcCentreAddrPtr8); |
|
562 CleanupStack::PopAndDestroy(2, svcCentreAddr16); // svcCentreAddr16, svcCentreAddr8 |
|
563 } |
|
564 |
|
565 // Read the WSP Option - CO (Connection Oriented) or CL (Connection-less). |
|
566 // Note: this WAP browser isn't going to support a connectionless mode of |
|
567 // operation. |
|
568 TUint32 wspOptionID = 0; |
|
569 bearerView->ReadUintL(TPtrC(WAP_WSP_OPTION), wspOptionID); |
|
570 switch( wspOptionID ) |
|
571 { |
|
572 case EWapWspOptionConnectionless: // Connection-less |
|
573 { |
|
574 aSessionServiceType = EWspConnectionLess; |
|
575 } break; |
|
576 case EWapWspOptionConnectionOriented: // Connection-oriented |
|
577 { |
|
578 aSessionServiceType = EWspConnectionOriented; |
|
579 } break; |
|
580 default: // 'NULL' setting - don't know what this means... leave with |
|
581 // a 'AP Not set up' failure |
|
582 User::Leave(KWspErrAccessPointNotSetUp); |
|
583 break; |
|
584 } |
|
585 // All done - clean up |
|
586 CleanupStack::PopAndDestroy(6, db); // gateway8, gateway16, bearerView, bearer16, |
|
587 // apView, db |
|
588 } |
|
589 void CWspProxyInfoProvider::ReadServiceCentreNumberL(RStringPool aStringPool, RStringF& aServiceCentreNumber) |
|
590 { |
|
591 // Open the Comms DB - don't specify whether it should be a IAP or ISP |
|
592 // style DB - this doesn't matter here. |
|
593 CCommsDatabase* db=CCommsDatabase::NewL(EDatabaseTypeUnspecified); |
|
594 CleanupStack::PushL(db); |
|
595 |
|
596 // Find the ID of the WAP Access Point marked in the global settings. This |
|
597 // is the 'default' WAP AP, as marked by the user's most recent selection |
|
598 // of a bookmark in the WAP browser. |
|
599 TUint32 wapAPID; |
|
600 db->GetGlobalSettingL(TPtrC(WAP_ACCESS_POINT), wapAPID); |
|
601 |
|
602 // Open a view on the SMS Bearer table. Use the WAP AP ID to select a record |
|
603 // in the appropriate WAP bearer table. |
|
604 CCommsDbTableView* bearerView = db->OpenViewMatchingUintLC( |
|
605 TPtrC(WAP_SMS_BEARER), // table name |
|
606 TPtrC(WAP_ACCESS_POINT_ID), // column to match |
|
607 wapAPID // value to match |
|
608 ); |
|
609 if( bearerView == NULL ) |
|
610 { |
|
611 // No SMS bearer table - leave |
|
612 User::Leave(KWspErrSMSBearerNotInCommsDB); |
|
613 } |
|
614 |
|
615 // Read the Service Centre Address from the WAP AP settings. This is |
|
616 // in the form of a phone number when SMS is being used as a bearer. |
|
617 // Note: this isn't used by HTTP to configure the WAP stack - it is |
|
618 // used by the WAP stack to configure the SMS stack. HTTP doesn't need |
|
619 // to worry about it. However, store it anyway, just in case... |
|
620 HBufC* svcCentreAddr16 = HBufC::NewL(KCommsDbSvrMaxFieldLength); |
|
621 CleanupStack::PushL(svcCentreAddr16); |
|
622 |
|
623 TPtr svcCentreAddrPtr16 = svcCentreAddr16->Des(); |
|
624 bearerView->ReadTextL(TPtrC(WAP_SERVICE_CENTRE_ADDRESS), svcCentreAddrPtr16); |
|
625 |
|
626 // Copy to 8-bits... |
|
627 HBufC8* svcCentreAddr8 = HBufC8::NewL(svcCentreAddrPtr16.Length()); |
|
628 CleanupStack::PushL(svcCentreAddr8); |
|
629 TPtr8 svcCentreAddrPtr8 = svcCentreAddr8->Des(); |
|
630 svcCentreAddrPtr8.Copy(svcCentreAddrPtr16); |
|
631 |
|
632 aServiceCentreNumber = aStringPool.OpenFStringL(svcCentreAddrPtr8); |
|
633 |
|
634 // Cleanup... |
|
635 CleanupStack::PopAndDestroy(4, db); |
|
636 } |