1 // Copyright (c) 2001-2010 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 |
|
17 #include <wapmessage.h> |
|
18 #include <in_iface.h> |
|
19 #include <ecom/ecom.h> |
|
20 |
|
21 /** The WAP Messaging API. Four interfaces are defined that provide bound and fully-specified versions of WDP and Connectionless Push. |
|
22 An instantiation of each may be obtained using the CreateImplementationL() function, and must be released using Release() when no |
|
23 longer required. Release() causes the instantiation to be deleted. |
|
24 */ |
|
25 |
|
26 // Use SWS as default WAP stack |
|
27 // If undefined th3em NWSS stack will be used as default |
|
28 #define WAPUSE_SWS // since 8.0 |
|
29 |
|
30 #ifndef WAPUSE_SWS |
|
31 // Symbian OS 7.0 |
|
32 _LIT8(KDefBoundWdpCue, "wdp/bound"); |
|
33 _LIT8(KDefFullSpecWdpCue, "wdp/fullyspec"); |
|
34 _LIT8(KDefBoundCLPushCue, "clpush/bound"); |
|
35 _LIT8(KDefFullSpecCLPushCue, "clpush/fullyspec"); |
|
36 |
|
37 _LIT8(KAltBoundWdpCue, "swswdp/bound"); |
|
38 _LIT8(KAltFullSpecWdpCue, "swswdp/fullyspec"); |
|
39 _LIT8(KAltBoundCLPushCue, "swsclpush/bound"); |
|
40 _LIT8(KAltFullSpecCLPushCue, "swsclpush/fullyspec"); |
|
41 |
|
42 #else |
|
43 // Symbian OS 8.0 |
|
44 _LIT8(KAltBoundWdpCue, "wdp/bound"); |
|
45 _LIT8(KAltFullSpecWdpCue, "wdp/fullyspec"); |
|
46 _LIT8(KAltBoundCLPushCue, "clpush/bound"); |
|
47 _LIT8(KAltFullSpecCLPushCue, "clpush/fullyspec"); |
|
48 |
|
49 _LIT8(KDefBoundWdpCue, "swswdp/bound"); |
|
50 _LIT8(KDefFullSpecWdpCue, "swswdp/fullyspec"); |
|
51 _LIT8(KDefBoundCLPushCue, "swsclpush/bound"); |
|
52 _LIT8(KDefFullSpecCLPushCue, "swsclpush/fullyspec"); |
|
53 #endif |
|
54 |
|
55 _LIT8(KBoundCLWSPCue, "swsclwsp/bound"); |
|
56 _LIT8(KFullSpecCLWSPCue, "swsclwsp/fullyspec"); |
|
57 |
|
58 /** Bound WDP |
|
59 */ |
|
60 |
|
61 EXPORT_C |
|
62 CWapBoundDatagramService* CWapBoundDatagramService::NewL() |
|
63 /** Allocates and creates a new CWapBoundDatagramService object. |
|
64 * |
|
65 * @return A new CWapBoundDatagramService object. |
|
66 * @leave System wide error codes |
|
67 */ |
|
68 { |
|
69 // CWapBoundDatagramService ECOM Interface UID = 101F4471 |
|
70 const TUid KUidBoundWDPInterface = {0x101F4471}; |
|
71 |
|
72 // Set resolving parameters |
|
73 TEComResolverParams resolverParams; |
|
74 resolverParams.SetDataType(KDefBoundWdpCue); |
|
75 resolverParams.SetWildcardMatch(ETrue); |
|
76 |
|
77 // Get the instantiation |
|
78 TInt trapValue(0); |
|
79 TAny* ptr = NULL; |
|
80 TRAP(trapValue, ptr = REComSession::CreateImplementationL(KUidBoundWDPInterface, |
|
81 _FOFF(CWapBoundDatagramService, iDtor_ID_Key), |
|
82 resolverParams)); |
|
83 if(trapValue) |
|
84 { |
|
85 resolverParams.SetDataType(KAltBoundWdpCue); |
|
86 // Trying to load old wapmessage plug-in |
|
87 ptr = REComSession::CreateImplementationL(KUidBoundWDPInterface, |
|
88 _FOFF(CWapBoundDatagramService, iDtor_ID_Key), |
|
89 resolverParams); |
|
90 } |
|
91 |
|
92 return REINTERPRET_CAST(CWapBoundDatagramService*, ptr); |
|
93 } |
|
94 |
|
95 EXPORT_C |
|
96 CWapBoundDatagramService* CWapBoundDatagramService::NewL(const TUid& aImplementation) |
|
97 /** Allocates and creates a new CWapBoundDatagramService object. |
|
98 * |
|
99 * @param aImplementation |
|
100 * @return A new CWapBoundDatagramService object. |
|
101 * @leave System wide error codes |
|
102 */ |
|
103 { |
|
104 TAny* ptr = REComSession::CreateImplementationL(aImplementation, |
|
105 _FOFF(CWapBoundDatagramService, iDtor_ID_Key)); |
|
106 |
|
107 return REINTERPRET_CAST(CWapBoundDatagramService*, ptr); |
|
108 } |
|
109 |
|
110 EXPORT_C |
|
111 CWapBoundDatagramService::~CWapBoundDatagramService() |
|
112 /** Destructor */ |
|
113 { |
|
114 REComSession::DestroyedImplementation(iDtor_ID_Key); |
|
115 } |
|
116 |
|
117 EXPORT_C |
|
118 CWapBoundDatagramService::CWapBoundDatagramService() |
|
119 { |
|
120 } |
|
121 |
|
122 EXPORT_C |
|
123 void CWapBoundDatagramService::ConstructL() |
|
124 { |
|
125 } |
|
126 |
|
127 /** Fully-specified WDP |
|
128 */ |
|
129 |
|
130 EXPORT_C |
|
131 CWapFullySpecDatagramService* CWapFullySpecDatagramService::NewL() |
|
132 /** Allocates and creates a new CWapFullySpecDatagramService object. |
|
133 * |
|
134 * @return A new CWapFullySpecDatagramService object. |
|
135 * @leave System wide error codes. |
|
136 */ |
|
137 { |
|
138 // MWapFullySpecDatagramService ECOM Interface UID = 101F4473 |
|
139 const TUid KUidFullySpecDatagramInterface = {0x101F4473}; |
|
140 |
|
141 // Set resolving parameters |
|
142 TEComResolverParams resolverParams; |
|
143 resolverParams.SetDataType(KDefFullSpecWdpCue); |
|
144 resolverParams.SetWildcardMatch(ETrue); |
|
145 |
|
146 // Get the instantiation |
|
147 TInt trapValue(0); |
|
148 TAny* ptr = NULL; |
|
149 TRAP(trapValue, ptr = REComSession::CreateImplementationL(KUidFullySpecDatagramInterface, |
|
150 _FOFF(CWapFullySpecDatagramService, iDtor_ID_Key), |
|
151 resolverParams)); |
|
152 if(trapValue) |
|
153 { |
|
154 // Trying to load old wapmessage plug-in |
|
155 resolverParams.SetDataType(KAltFullSpecWdpCue); |
|
156 ptr = REComSession::CreateImplementationL(KUidFullySpecDatagramInterface, |
|
157 _FOFF(CWapFullySpecDatagramService, iDtor_ID_Key), |
|
158 resolverParams); |
|
159 } |
|
160 |
|
161 return REINTERPRET_CAST(CWapFullySpecDatagramService*, ptr); |
|
162 } |
|
163 |
|
164 EXPORT_C |
|
165 CWapFullySpecDatagramService* CWapFullySpecDatagramService::NewL(const TUid& aImplementation) |
|
166 /** Allocates and creates a new CWapFullySpecDatagramService object. |
|
167 * |
|
168 * @param aImplementation |
|
169 * @return A new CWapFullySpecDatagramService object. |
|
170 * @leave System wide error codes. |
|
171 */ |
|
172 { |
|
173 TAny* ptr = REComSession::CreateImplementationL(aImplementation, |
|
174 _FOFF(CWapFullySpecDatagramService, iDtor_ID_Key)); |
|
175 |
|
176 return REINTERPRET_CAST(CWapFullySpecDatagramService*, ptr); |
|
177 } |
|
178 |
|
179 EXPORT_C |
|
180 CWapFullySpecDatagramService::~CWapFullySpecDatagramService() |
|
181 /** Destructor */ |
|
182 { |
|
183 REComSession::DestroyedImplementation(iDtor_ID_Key); |
|
184 } |
|
185 |
|
186 EXPORT_C |
|
187 CWapFullySpecDatagramService::CWapFullySpecDatagramService() |
|
188 { |
|
189 } |
|
190 |
|
191 EXPORT_C |
|
192 void CWapFullySpecDatagramService::ConstructL() |
|
193 { |
|
194 } |
|
195 |
|
196 /** Bound Connection-less Push |
|
197 */ |
|
198 |
|
199 EXPORT_C |
|
200 CWapBoundCLPushService* CWapBoundCLPushService::NewL() |
|
201 /** Allocates and creates a new CWapBoundCLPushService object. |
|
202 * |
|
203 * @return A new <code>CWapBoundCLPushService</code> object. |
|
204 * @leave System wide error codes. |
|
205 */ |
|
206 { |
|
207 // MWapBoundCLPushService ECOM Interface UID = 101F4475 |
|
208 const TUid KUidBoundCLPushInterface = {0x101F4475}; |
|
209 |
|
210 // Set resolving parameters |
|
211 TEComResolverParams resolverParams; |
|
212 resolverParams.SetDataType(KDefBoundCLPushCue); |
|
213 resolverParams.SetWildcardMatch(ETrue); |
|
214 |
|
215 // Get the instantiation |
|
216 TInt trapValue(0); |
|
217 TAny* ptr = NULL; |
|
218 TRAP(trapValue, ptr = REComSession::CreateImplementationL(KUidBoundCLPushInterface, |
|
219 _FOFF(CWapBoundCLPushService, iDtor_ID_Key), |
|
220 resolverParams)); |
|
221 if(trapValue) |
|
222 { |
|
223 // Trying to load old wapmessage plug-in |
|
224 resolverParams.SetDataType(KAltBoundCLPushCue); |
|
225 ptr = REComSession::CreateImplementationL(KUidBoundCLPushInterface, |
|
226 _FOFF(CWapBoundCLPushService, iDtor_ID_Key), |
|
227 resolverParams); |
|
228 } |
|
229 return REINTERPRET_CAST(CWapBoundCLPushService*, ptr); |
|
230 } |
|
231 |
|
232 EXPORT_C |
|
233 CWapBoundCLPushService* CWapBoundCLPushService::NewL(const TUid& aImplementation) |
|
234 /** Allocates and creates a new CWapBoundCLPushService object. |
|
235 * |
|
236 * @param aImplementation |
|
237 * @return A new CWapBoundCLPushService object. |
|
238 * @leave System wide error codes. |
|
239 */ |
|
240 { |
|
241 TAny* ptr = REComSession::CreateImplementationL(aImplementation, |
|
242 _FOFF(CWapBoundCLPushService, iDtor_ID_Key)); |
|
243 |
|
244 return REINTERPRET_CAST(CWapBoundCLPushService*, ptr); |
|
245 } |
|
246 |
|
247 EXPORT_C |
|
248 CWapBoundCLPushService::~CWapBoundCLPushService() |
|
249 /** Destructor */ |
|
250 { |
|
251 REComSession::DestroyedImplementation(iDtor_ID_Key); |
|
252 } |
|
253 |
|
254 EXPORT_C |
|
255 CWapBoundCLPushService::CWapBoundCLPushService() |
|
256 { |
|
257 } |
|
258 |
|
259 EXPORT_C |
|
260 void CWapBoundCLPushService::ConstructL() |
|
261 { |
|
262 } |
|
263 |
|
264 /** Fully-specified Connection-less Push |
|
265 */ |
|
266 |
|
267 EXPORT_C |
|
268 CWapFullySpecCLPushService* CWapFullySpecCLPushService::NewL() |
|
269 /** Allocates and creates a new CWapFullySpecCLPushService object. |
|
270 * |
|
271 * @return A new CWapFullySpecCLPushService object. |
|
272 * @leave System wide error codes. |
|
273 */ |
|
274 { |
|
275 // MWapFullySpecCLPushService ECOM Interface UID = 101F4477 |
|
276 const TUid KUidFullySpecCLPushInterface = {0x101F4477}; |
|
277 |
|
278 // Set resolving parameters |
|
279 TEComResolverParams resolverParams; |
|
280 resolverParams.SetDataType(KDefFullSpecCLPushCue); |
|
281 resolverParams.SetWildcardMatch(ETrue); |
|
282 |
|
283 // Get the instantiation |
|
284 TInt trapValue(0); |
|
285 TAny* ptr = NULL; |
|
286 TRAP(trapValue, ptr = REComSession::CreateImplementationL(KUidFullySpecCLPushInterface, |
|
287 _FOFF(CWapFullySpecCLPushService, iDtor_ID_Key), |
|
288 resolverParams)); |
|
289 if(trapValue) |
|
290 { |
|
291 // Trying to load old wapmessage plug-in |
|
292 resolverParams.SetDataType(KAltFullSpecCLPushCue); |
|
293 ptr = REComSession::CreateImplementationL(KUidFullySpecCLPushInterface, |
|
294 _FOFF(CWapFullySpecCLPushService, iDtor_ID_Key), |
|
295 resolverParams); |
|
296 } |
|
297 |
|
298 return REINTERPRET_CAST(CWapFullySpecCLPushService*, ptr); |
|
299 } |
|
300 |
|
301 EXPORT_C |
|
302 CWapFullySpecCLPushService* CWapFullySpecCLPushService::NewL(const TUid& aImplementation) |
|
303 /** Allocates and creates a new CWapFullySpecCLPushService object. |
|
304 * |
|
305 * @param aImplementation |
|
306 * @return A new CWapFullySpecCLPushService object. |
|
307 * @leave System wide error codes. |
|
308 */ |
|
309 { |
|
310 TAny* ptr = REComSession::CreateImplementationL(aImplementation, |
|
311 _FOFF(CWapFullySpecCLPushService, iDtor_ID_Key)); |
|
312 |
|
313 return REINTERPRET_CAST(CWapFullySpecCLPushService*, ptr); |
|
314 } |
|
315 |
|
316 EXPORT_C |
|
317 CWapFullySpecCLPushService::~CWapFullySpecCLPushService() |
|
318 /** Destructor */ |
|
319 { |
|
320 REComSession::DestroyedImplementation(iDtor_ID_Key); |
|
321 } |
|
322 |
|
323 EXPORT_C |
|
324 CWapFullySpecCLPushService::CWapFullySpecCLPushService() |
|
325 { |
|
326 } |
|
327 |
|
328 EXPORT_C |
|
329 void CWapFullySpecCLPushService::ConstructL() |
|
330 { |
|
331 } |
|
332 |
|
333 /** Bound WSP |
|
334 New interface and implementation |
|
335 */ |
|
336 |
|
337 EXPORT_C |
|
338 CWapBoundCLWSPService* CWapBoundCLWSPService::NewL() |
|
339 /** Allocates and creates a new CWapBoundCLWSPService object. |
|
340 * |
|
341 * @return A new CWapBoundCLWSPService object. |
|
342 * @leave System wide error codes. |
|
343 */ |
|
344 { |
|
345 // CWapBoundWSPService ECOM Interface UID = 101FBB3B |
|
346 const TUid KUidBoundCLWSPInterface = {0x101FBB3B}; |
|
347 |
|
348 // Set resolving parameters |
|
349 TEComResolverParams resolverParams; |
|
350 resolverParams.SetDataType(KBoundCLWSPCue); |
|
351 resolverParams.SetWildcardMatch(ETrue); |
|
352 |
|
353 // Get the instantiation |
|
354 TAny* ptr = REComSession::CreateImplementationL(KUidBoundCLWSPInterface, |
|
355 _FOFF(CWapBoundCLWSPService, iDtor_ID_Key), |
|
356 resolverParams); |
|
357 |
|
358 return REINTERPRET_CAST(CWapBoundCLWSPService*, ptr); |
|
359 } |
|
360 |
|
361 EXPORT_C |
|
362 CWapBoundCLWSPService* CWapBoundCLWSPService::NewL(const TUid& aImplementation) |
|
363 /** Allocates and creates a new CWapBoundCLWSPService object. |
|
364 * |
|
365 * @param aImplementation |
|
366 * @return A new CWapBoundCLWSPService object. |
|
367 * @leave System wide error codes. |
|
368 */ |
|
369 { |
|
370 TAny* ptr = REComSession::CreateImplementationL(aImplementation, |
|
371 _FOFF(CWapBoundCLWSPService, iDtor_ID_Key)); |
|
372 |
|
373 return REINTERPRET_CAST(CWapBoundCLWSPService*, ptr); |
|
374 } |
|
375 |
|
376 EXPORT_C |
|
377 CWapBoundCLWSPService::~CWapBoundCLWSPService() |
|
378 /** Destructor */ |
|
379 { |
|
380 REComSession::DestroyedImplementation(iDtor_ID_Key); |
|
381 } |
|
382 |
|
383 EXPORT_C |
|
384 CWapBoundCLWSPService::CWapBoundCLWSPService() |
|
385 { |
|
386 } |
|
387 |
|
388 EXPORT_C |
|
389 void CWapBoundCLWSPService::ConstructL() |
|
390 { |
|
391 } |
|
392 |
|
393 /** Fully-specified Connection-less WSP |
|
394 New interface and implementation |
|
395 */ |
|
396 |
|
397 EXPORT_C |
|
398 CWapFullySpecCLWSPService* CWapFullySpecCLWSPService::NewL() |
|
399 /** Allocates and creates a new CWapFullySpecCLWSPService object. |
|
400 * |
|
401 * @return A new CWapFullySpecCLWSPService object. |
|
402 * @leave System wide error codes. |
|
403 */ |
|
404 { |
|
405 // CWapFullySpecCLWSPService ECOM Interface UID = 101FBB3D |
|
406 const TUid KUidFullySpecCLWSPInterface = {0x101FBB3D}; |
|
407 |
|
408 // Set resolving parameters |
|
409 TEComResolverParams resolverParams; |
|
410 resolverParams.SetDataType(KFullSpecCLWSPCue); |
|
411 resolverParams.SetWildcardMatch(ETrue); |
|
412 |
|
413 // Get the instantiation |
|
414 TAny* ptr = REComSession::CreateImplementationL(KUidFullySpecCLWSPInterface, |
|
415 _FOFF(CWapFullySpecCLWSPService, iDtor_ID_Key), |
|
416 resolverParams); |
|
417 |
|
418 return REINTERPRET_CAST(CWapFullySpecCLWSPService*, ptr); |
|
419 } |
|
420 |
|
421 EXPORT_C |
|
422 CWapFullySpecCLWSPService* CWapFullySpecCLWSPService::NewL(const TUid& aImplementation) |
|
423 /** Allocates and creates a new CWapFullySpecCLWSPService object. |
|
424 * |
|
425 * @param aImplementation |
|
426 * @return A new CWapFullySpecCLWSPService object. |
|
427 * @leave System wide error codes. |
|
428 */ |
|
429 { |
|
430 TAny* ptr = REComSession::CreateImplementationL(aImplementation, |
|
431 _FOFF(CWapFullySpecCLWSPService, iDtor_ID_Key)); |
|
432 |
|
433 return REINTERPRET_CAST(CWapFullySpecCLWSPService*, ptr); |
|
434 } |
|
435 |
|
436 EXPORT_C |
|
437 CWapFullySpecCLWSPService::~CWapFullySpecCLWSPService() |
|
438 /** Destructor */ |
|
439 { |
|
440 REComSession::DestroyedImplementation(iDtor_ID_Key); |
|
441 } |
|
442 |
|
443 EXPORT_C |
|
444 CWapFullySpecCLWSPService::CWapFullySpecCLWSPService() |
|
445 { |
|
446 } |
|
447 |
|
448 EXPORT_C |
|
449 void CWapFullySpecCLWSPService::ConstructL() |
|
450 { |
|
451 } |
|
452 |
|
453 |
|
454 EXPORT_C TInt CWapMessageUtils::GetLocalAddressesL(RArray<Wap::TAddressInfo>& aAddressInfo) |
|
455 /** Gets a list of all the available network interface addresses. |
|
456 * |
|
457 * @param aAddressInfo On return, an array of the available network interface addresses. |
|
458 * @return KErrNone if successful, KErrNotFound if there are no addresses available. */ |
|
459 { |
|
460 Wap::TAddressInfo addrInfo; |
|
461 |
|
462 // Check if the esock ini file has been parsed |
|
463 // User::LeaveIfError(Nifman::CheckIniConfig()); |
|
464 |
|
465 // The list of interfaces is available from a RSocket.GetOpt |
|
466 TAutoClose<RSocketServ> sockServer; |
|
467 User::LeaveIfError(sockServer.iObj.Connect()); |
|
468 sockServer.PushL(); |
|
469 |
|
470 TAutoClose<RSocket> sock; |
|
471 User::LeaveIfError(sock.iObj.Open(sockServer.iObj, _L("udp"))); |
|
472 sock.PushL(); |
|
473 |
|
474 User::LeaveIfError(sock.iObj.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl)); |
|
475 |
|
476 TPckgBuf<TSoInetInterfaceInfo> info, next; |
|
477 |
|
478 TInt res=sock.iObj.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, info); |
|
479 if(res!=KErrNone) |
|
480 User::Leave(res); |
|
481 |
|
482 TInt validAddr = KErrNotFound; |
|
483 |
|
484 while(res==KErrNone) |
|
485 { |
|
486 res=sock.iObj.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, next); |
|
487 |
|
488 // Only consider the address is its up, and is point to point. |
|
489 // (TODO-would it be right to include pending state addresses too????) |
|
490 if ( (info().iState == EIfUp) && |
|
491 (info().iFeatures & KIfIsPointToPoint) ) |
|
492 { |
|
493 // Just want the interface name |
|
494 // = info().iName; |
|
495 // and the address |
|
496 // = info().iAddress; |
|
497 validAddr = KErrNone; |
|
498 |
|
499 addrInfo.iAddress = info().iAddress; |
|
500 addrInfo.iName = info().iName; |
|
501 aAddressInfo.Append(addrInfo); |
|
502 } |
|
503 } |
|
504 |
|
505 sock.Pop(); |
|
506 sockServer.Pop(); |
|
507 |
|
508 return validAddr; |
|
509 } |
|