|
1 /* |
|
2 * Copyright (c) 2003-2004 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 <comms-infras/nifprvar.h> |
|
22 #include <ES_SOCK.H> |
|
23 #include <es_sock_partner.h> |
|
24 //#include "SOCKMES.H" |
|
25 #include "ConnPref.h" |
|
26 //#include "ss_log.h" |
|
27 #include <ecom/ecom.h> |
|
28 #include <networking/qos3gpp_subconparams.h> |
|
29 |
|
30 using Meta::STypeId; |
|
31 |
|
32 //////////////////////////////////////////////////////////////////////////////// |
|
33 // Socket Address |
|
34 //////////////////////////////////////////////////////////////////////////////// |
|
35 |
|
36 EXPORT_C TSockAddr::TSockAddr() |
|
37 : TBuf8<KMaxSockAddrSize>() |
|
38 /** Default constructor initialises the address to be zero-filled. */ |
|
39 { |
|
40 SetLength(KMaxSockAddrSize); |
|
41 SetFamily(KAFUnspec); |
|
42 } |
|
43 |
|
44 EXPORT_C TSockAddr::TSockAddr(TUint aFamily) |
|
45 /** |
|
46 Constructs the address with the family member data specified. |
|
47 |
|
48 @released. |
|
49 @param aFamily, Address family of address object. |
|
50 */ |
|
51 : TBuf8<KMaxSockAddrSize>() |
|
52 /** Constructs the address with the family member data specified. |
|
53 |
|
54 @param aFamily Address family Id. */ |
|
55 { |
|
56 SetLength(KMaxSockAddrSize); |
|
57 SetFamily(aFamily); |
|
58 } |
|
59 |
|
60 EXPORT_C TUint TSockAddr::Family() const |
|
61 /** Gets the address family and thereby the type of address. The family may be |
|
62 used to effect 'down-casting'. |
|
63 |
|
64 @return Address family Id. */ |
|
65 { |
|
66 return BasePtr()->iFamily; |
|
67 } |
|
68 |
|
69 EXPORT_C void TSockAddr::SetFamily(TUint aFamily) |
|
70 /** Sets the address family of an address. |
|
71 |
|
72 @param aFamily Address family Id. */ |
|
73 { |
|
74 BasePtr()->iFamily = aFamily; |
|
75 } |
|
76 |
|
77 EXPORT_C void TSockAddr::SetPort(TUint aPort) |
|
78 // |
|
79 // Set Generic Port |
|
80 // |
|
81 /** Sets the address port of an address. |
|
82 |
|
83 @param aPort New port value for address */ |
|
84 { |
|
85 BasePtr()->iPort = aPort; |
|
86 } |
|
87 |
|
88 EXPORT_C TUint TSockAddr::Port() const |
|
89 // |
|
90 // Get Generic Port |
|
91 // |
|
92 /** Gets the port value. |
|
93 |
|
94 @return Port value */ |
|
95 { |
|
96 return BasePtr()->iPort; |
|
97 } |
|
98 |
|
99 EXPORT_C TBool TSockAddr::CmpPort(const TSockAddr &anAddr) const |
|
100 /** |
|
101 Compare two ports. |
|
102 |
|
103 Compares ports in two addresses |
|
104 |
|
105 @param anAddr, socket address. |
|
106 @return ETrue if the ports match and EFalse if they do not |
|
107 */ |
|
108 { |
|
109 return (BasePtr()->iFamily==anAddr.BasePtr()->iFamily) |
|
110 && (BasePtr()->iPort==anAddr.BasePtr()->iPort); |
|
111 } |
|
112 |
|
113 EXPORT_C void TSockAddr::SetUserLen(TInt aLen) |
|
114 // |
|
115 // Set descriptor length to actual length of |
|
116 // subclass. |
|
117 // |
|
118 /** Sets the length of data it appends after the base class' data. This function |
|
119 is mainly intended for use in derived classes. |
|
120 |
|
121 @param aLen New length for appended data. */ |
|
122 { |
|
123 SetLength(aLen+Align4(sizeof(SSockAddr))); |
|
124 } |
|
125 |
|
126 EXPORT_C TInt TSockAddr::GetUserLen() |
|
127 // |
|
128 // Get length of user part of TSockAddr |
|
129 // |
|
130 /** Gets the number of bytes a derived class has set beyond the SSockAddr part |
|
131 of the address. This function is mainly intended for use in derived classes. |
|
132 |
|
133 @return User length */ |
|
134 { |
|
135 return Length()-Align4(sizeof(SSockAddr)); |
|
136 } |
|
137 |
|
138 //////////////////////////////////////////////////////////////////////////////// |
|
139 // RConnection |
|
140 //////////////////////////////////////////////////////////////////////////////// |
|
141 |
|
142 EXPORT_C RConnection::RConnection() |
|
143 : iNewISPId(0) //lint -esym(1401, RConnection::iReserved) // no BC issue as ctor not inlined |
|
144 /** Empty constructor. */ |
|
145 { |
|
146 } |
|
147 |
|
148 EXPORT_C RConnection::~RConnection() |
|
149 /** Empty destructor. */ |
|
150 { |
|
151 } |
|
152 |
|
153 //////////////////////////////////////////////////////////////////////////////// |
|
154 // RSocketServ |
|
155 //////////////////////////////////////////////////////////////////////////////// |
|
156 |
|
157 EXPORT_C RSocketServ::RSocketServ() |
|
158 /** |
|
159 Default Constructor |
|
160 */ |
|
161 { |
|
162 } |
|
163 |
|
164 //////////////////////////////////////////////////////////////////////////////// |
|
165 // RSocket |
|
166 //////////////////////////////////////////////////////////////////////////////// |
|
167 |
|
168 EXPORT_C RSocket::RSocket() |
|
169 /** |
|
170 Default Constructor |
|
171 */ |
|
172 { |
|
173 } |
|
174 |
|
175 EXPORT_C TInt RSocket::SetOpt(TUint /*anOptionName*/,TUint /*anOptionLevel*/,const TDesC8& /*anOption*/ /*=TPtrC(NULL,0)*/) |
|
176 /** Sets a socket option. The socket server has options which are generic to all |
|
177 sockets and protocols may add specific options. |
|
178 |
|
179 Options available for all protocols can be set with anOptionLevel set to KSOLSocket. |
|
180 See individual protocol notes for other socket options. |
|
181 |
|
182 @param anOptionName An integer constant which identifies an option. |
|
183 @param anOptionLevel An integer constant which identifies level of an option: |
|
184 i.e. an option level groups related options together. |
|
185 @param anOption Option value packaged in a descriptor. |
|
186 @return KErrNone if successful, otherwise another of the system-wide error |
|
187 codes. |
|
188 |
|
189 @capability Dependent on the type of operation so deferred to PRT. See documentation |
|
190 of constant values used in aOptionName and aOptionLevel for more information */ |
|
191 { |
|
192 // return SendReceive(ESoSetOpt,TIpcArgs(anOptionName,&anOption,anOptionLevel)); |
|
193 return KErrNone; |
|
194 } |
|
195 |
|
196 EXPORT_C TInt RSocket::SetOpt(TUint anOptionName,TUint anOptionLevel,TInt anOption) |
|
197 /** Sets a socket option. The socket server has options which are generic to all |
|
198 sockets and protocols may add specific options. |
|
199 |
|
200 Options available for all protocols can be set with anOptionLevel set to KSOLSocket. |
|
201 See individual protocol notes for other socket options. |
|
202 |
|
203 @param anOptionName An integer constant which identifies an option. |
|
204 @param anOptionLevel An integer constant which identifies level of an option: |
|
205 i.e. an option level groups related options together. |
|
206 @param anOption Option value as an integer. |
|
207 @return KErrNone if successful, otherwise another of the system-wide error |
|
208 codes. |
|
209 |
|
210 @capability Dependent on the type of operation so deferred to PRT. See documentation |
|
211 of constant values used in aOptionName and aOptionLevel for more information */ |
|
212 { |
|
213 |
|
214 TPtr8 optionDes((TUint8*)&anOption,sizeof(TInt),sizeof(TInt)); |
|
215 return SetOpt(anOptionName,anOptionLevel,optionDes); |
|
216 } |
|
217 |
|
218 EXPORT_C void RSocket::LocalName(TSockAddr &/*anAddr*/) |
|
219 /** Gets the local address of a bound socket. |
|
220 |
|
221 The local address is set either by calling Bind(), or is automatically set |
|
222 when Connect() is called. |
|
223 |
|
224 If a socket is created through Accept() then a socket will inherit the port |
|
225 of its parent unless otherwise specified by a protocol's behaviour. |
|
226 |
|
227 Depending on a protocol implementation, additional information may be gained |
|
228 through this call. |
|
229 |
|
230 @param anAddr Local address which is filled in on return. */ |
|
231 { |
|
232 // SendReceive(ESoGetLocalName,TIpcArgs(&anAddr)); |
|
233 } |
|
234 |
|
235 EXPORT_C TUint RSocket::LocalPort() |
|
236 /** Gets the local port number of a bound socket. |
|
237 |
|
238 Getting the local port is similar to getting the local name. |
|
239 |
|
240 @see LocalName() for a description. |
|
241 @return The local port of a socket. */ |
|
242 { |
|
243 TSockAddr addr; |
|
244 LocalName(addr); |
|
245 return addr.Port(); |
|
246 } |
|
247 |
|
248 //////////////////////////////////////////////////////////////////////////////// |
|
249 // TNotificationEventBuf |
|
250 //////////////////////////////////////////////////////////////////////////////// |
|
251 |
|
252 EXPORT_C TNotificationEventBuf::TNotificationEventBuf() |
|
253 { |
|
254 SetLength(this->MaxLength()); |
|
255 FillZ(); |
|
256 } |
|
257 |
|
258 EXPORT_C TNotificationEventBuf::~TNotificationEventBuf() |
|
259 { |
|
260 } |
|
261 |
|
262 EXPORT_C TUint32 TNotificationEventBuf::Id() const |
|
263 /** Provides the sub-type Id of the event |
|
264 |
|
265 @return sub-type id |
|
266 */ |
|
267 { |
|
268 return *((TUint32*)(Ptr() + sizeof(TUint32))); |
|
269 } |
|
270 |
|
271 //////////////////////////////////////////////////////////////////////////////// |
|
272 // RSubConParameterBundle |
|
273 //////////////////////////////////////////////////////////////////////////////// |
|
274 |
|
275 EXPORT_C RSubConParameterBundle::RSubConParameterBundle() |
|
276 : iBundle(NULL) |
|
277 /** Empty sub-connection parameter bundle constructor |
|
278 */ |
|
279 { |
|
280 } |
|
281 |
|
282 EXPORT_C void RSubConParameterBundle::Close() |
|
283 /** Close the parameter bundle handle |
|
284 */ |
|
285 { |
|
286 if (iBundle) |
|
287 { |
|
288 iBundle->Close(); |
|
289 iBundle = NULL; |
|
290 } |
|
291 } |
|
292 |
|
293 EXPORT_C void RSubConParameterBundle::AddFamilyL(CSubConParameterFamily* aFamily) |
|
294 /** Add a sub-connection parameter family to the bundle. |
|
295 |
|
296 @param aFamily Family to be added (bundle takes ownership) |
|
297 @exception leaves with KErrNoMemory in out of memory conditions |
|
298 */ |
|
299 { |
|
300 User::LeaveIfError(CheckBundle()); |
|
301 iBundle->AddFamilyL(aFamily); |
|
302 } |
|
303 |
|
304 TInt RSubConParameterBundle::CheckBundle() const |
|
305 /** Check to see if the handle has a heap object. If it hasn't, it creates one |
|
306 |
|
307 @return KErrNone if successful, otherwise a system wide error |
|
308 */ |
|
309 { |
|
310 if (!iBundle) |
|
311 { |
|
312 TRAPD(ret, iBundle = CSubConParameterBundle::NewL()); |
|
313 return ret; |
|
314 } |
|
315 return KErrNone; |
|
316 } |
|
317 |
|
318 //////////////////////////////////////////////////////////////////////////////// |
|
319 // CSubConParameterBundle |
|
320 //////////////////////////////////////////////////////////////////////////////// |
|
321 |
|
322 CSubConParameterBundle::CSubConParameterBundle() |
|
323 /** Empty sub-connection generic parameter bundle constructor |
|
324 */ |
|
325 { |
|
326 } |
|
327 |
|
328 EXPORT_C CSubConParameterBundle::~CSubConParameterBundle() |
|
329 /** Sub-connection parameter bundle destructor, clear up the families |
|
330 */ |
|
331 { |
|
332 iFamilies.ResetAndDestroy(); |
|
333 } |
|
334 |
|
335 EXPORT_C CSubConParameterBundle* CSubConParameterBundle::NewL() |
|
336 /** Creates a new instance of a sub-connection parameter bundle (heap object) |
|
337 Can be used directly as a CObject or via the RSubConParameterBundle handle. |
|
338 |
|
339 @return newly created instance of a sub-connection parameter bundle |
|
340 @exception leaves with KErrNoMemory in out of memory conditions |
|
341 */ |
|
342 { |
|
343 return new (ELeave) CSubConParameterBundle(); |
|
344 } |
|
345 |
|
346 EXPORT_C void CSubConParameterBundle::AddFamilyL(CSubConParameterFamily* aFamily) |
|
347 /** Add a sub-connection parameter family to the bundle. |
|
348 |
|
349 @param aFamily Family to be added (bundle takes ownership) |
|
350 @exception leaves with KErrNoMemory in out of memory conditions |
|
351 */ |
|
352 { |
|
353 iFamilies.AppendL(aFamily); |
|
354 } |
|
355 |
|
356 //////////////////////////////////////////////////////////////////////////////// |
|
357 // CSubConParameterFamily |
|
358 //////////////////////////////////////////////////////////////////////////////// |
|
359 |
|
360 EXPORT_C CSubConParameterFamily* CSubConParameterFamily::NewL(RSubConParameterBundle& aBundle, TUint32 aFamilyId) |
|
361 /** Creates a new sub-connection parameter set family. This class is used as a container for a number of parameter |
|
362 sets (generic and extension) that make up a family. It is a specific instantiatable class and therefore creates |
|
363 an instance of CSubConParameterFamily without using ECOM. |
|
364 |
|
365 @param aBundle Family container (bundle) that this family is to be added to |
|
366 @param aFamilyId identifier for the specific family type, currently only 2, QoS (KSubConQoSFamily) and Authorisation (KSubConAuthorisationFamily), are defined. |
|
367 @return a pointer to a sub-connection parameter family if successful, otherwise leaves with system error code. |
|
368 */ |
|
369 { |
|
370 CSubConParameterFamily* family = new (ELeave) CSubConParameterFamily(aFamilyId); |
|
371 CleanupStack::PushL(family); |
|
372 family->ConstructL(aBundle); |
|
373 CleanupStack::Pop(family); |
|
374 return family; |
|
375 } |
|
376 |
|
377 CSubConParameterFamily::CSubConParameterFamily(TUint32 aFamilyId) |
|
378 : iFamilyId(aFamilyId) |
|
379 /** Empty sub-connection parameter family constructor |
|
380 |
|
381 @param aFamilyId Identity of the family |
|
382 */ |
|
383 { |
|
384 } |
|
385 |
|
386 void CSubConParameterFamily::ConstructL(RSubConParameterBundle& aBundle) |
|
387 /** Set up the sub-connection family with empty sets |
|
388 |
|
389 @param aBundle Bundle (container) the family is to be added to |
|
390 @exception leaves with KErrNoMemory in out of memory conditions |
|
391 */ |
|
392 { |
|
393 iGenericSets.AppendL(NULL); |
|
394 iGenericSets.AppendL(NULL); |
|
395 iGenericSets.AppendL(NULL); |
|
396 aBundle.AddFamilyL(this); |
|
397 } |
|
398 |
|
399 EXPORT_C CSubConParameterFamily::~CSubConParameterFamily() |
|
400 /** Sub-connection parameter family destructor. It cleans up the arrays deleting all |
|
401 the paarmeter sets it ownes |
|
402 */ |
|
403 { |
|
404 iGenericSets.ResetAndDestroy(); |
|
405 iExtensionSets[ERequested].ResetAndDestroy(); |
|
406 iExtensionSets[EAcceptable].ResetAndDestroy(); |
|
407 iExtensionSets[EGranted].ResetAndDestroy(); |
|
408 } |
|
409 |
|
410 EXPORT_C void CSubConParameterFamily::AddExtensionSetL(CSubConExtensionParameterSet& aExtensionSet, TParameterSetType aType) |
|
411 /** |
|
412 Adds an extension parameter set to a sub-connection parameter set family. |
|
413 |
|
414 @param aExtensionSet Extension Parameter Set to be added to the family (family takes ownership) |
|
415 @param aType The type of the set (requested, acceptable or granted) |
|
416 @exception leaves with KErrNoMemory in out of memeory conditions. |
|
417 */ |
|
418 { |
|
419 iExtensionSets[aType].AppendL(&aExtensionSet); |
|
420 } |
|
421 |
|
422 |
|
423 EXPORT_C CSubConParameterSet* CSubConParameterSet::NewL(const STypeId& aTypeId) |
|
424 /** Creates a new sub-connection parameter set using ECOM to load the DLL plugin |
|
425 that implements the set. |
|
426 |
|
427 @param aTypeId Id of the class (Composed of Uid of the implementation and an integer sub-type |
|
428 @return a generic pointer to a specific parameter set if successful, otherwise leaves with system error code. |
|
429 */ |
|
430 { |
|
431 return static_cast<CSubConParameterSet*>(Meta::SMetaDataECom::NewInstanceL(aTypeId)); |
|
432 } |
|
433 |
|
434 CSubConParameterSet::~CSubConParameterSet() |
|
435 /** Empty (virtual) sub-connection parameter set destructor |
|
436 */ |
|
437 { |
|
438 } |
|
439 |
|
440 CSubConParameterSet::CSubConParameterSet() |
|
441 /** Empty sub-connection parameter set constructor |
|
442 */ |
|
443 { |
|
444 } |
|
445 |
|
446 |
|
447 //////////////////////////////////////////////////////////////////////////////// |
|
448 // Meta::RMetaDataContainerBase |
|
449 //////////////////////////////////////////////////////////////////////////////// |
|
450 |
|
451 |
|
452 EXPORT_C Meta::RMetaDataContainerBase::RMetaDataContainerBase() |
|
453 /** |
|
454 * Constructor |
|
455 */ |
|
456 { |
|
457 } |
|
458 |
|
459 |
|
460 //////////////////////////////////////////////////////////////////////////////// |
|
461 // Meta::SMetaDataECom |
|
462 //////////////////////////////////////////////////////////////////////////////// |
|
463 |
|
464 EXPORT_C Meta::SMetaDataECom::SMetaDataECom() |
|
465 /** |
|
466 * Protected and explicit constructor |
|
467 */ |
|
468 { |
|
469 iDestroyUid.iUid = 0; |
|
470 } |
|
471 |
|
472 EXPORT_C Meta::SMetaDataECom::~SMetaDataECom() |
|
473 /** |
|
474 * Destructor |
|
475 */ |
|
476 { |
|
477 if ( iDestroyUid.iUid ) |
|
478 { |
|
479 REComSession::DestroyedImplementation(iDestroyUid); |
|
480 } |
|
481 } |
|
482 |
|
483 EXPORT_C SMetaDataECom* Meta::SMetaDataECom::NewInstanceL(const STypeId& aTypeId) |
|
484 /** |
|
485 * Static, instantiates a meta object based on its Type ID. |
|
486 */ |
|
487 { |
|
488 /* |
|
489 TUid destroyUid; |
|
490 SMetaDataECom* obj = reinterpret_cast<SMetaDataECom*>(REComSession::CreateImplementationL(aTypeId.iUid, destroyUid, (TAny*)aTypeId.iType)); |
|
491 obj->iDestroyUid = destroyUid; |
|
492 */ |
|
493 SMetaDataECom* obj = reinterpret_cast<SMetaDataECom*>(REComSession::CreateImplementationL(aTypeId.iUid, (TInt32)0 )); |
|
494 return obj; |
|
495 } |
|
496 |
|
497 EXPORT_C SMetaDataECom* Meta::SMetaDataECom::LoadL(TPtrC8& aDes) |
|
498 /** |
|
499 * Static, encapsulates instantiation and loading of a content of a meta object |
|
500 * from data contained in a descriptor. |
|
501 * This function must be provided by all meta objects that will be used as a parameter |
|
502 * to TMetaPtr<> template. |
|
503 */ |
|
504 { |
|
505 STypeId typeId; |
|
506 Mem::Copy(&typeId.iUid, aDes.Ptr(), sizeof(TUid)); |
|
507 aDes.Set(aDes.Ptr()+sizeof(TUint32),aDes.Length()-sizeof(TUint32)); //update pointer (uid) |
|
508 Mem::Copy(&typeId.iType, aDes.Ptr(), sizeof(TInt32)); |
|
509 aDes.Set(aDes.Ptr()+sizeof(TUint32),aDes.Length()-sizeof(TUint32)); //update pointer (type) |
|
510 |
|
511 SMetaDataECom* mtd = NewInstanceL(typeId); |
|
512 return mtd; |
|
513 } |
|
514 |
|
515 //////////////////////////////////////////////////////////////////////////////// |
|
516 // Meta::SMetaData |
|
517 //////////////////////////////////////////////////////////////////////////////// |
|
518 |
|
519 EXPORT_C Meta::SMetaData::SMetaData() |
|
520 /** |
|
521 * Protected and explicit constructor |
|
522 */ |
|
523 { |
|
524 } |
|
525 |
|
526 EXPORT_C Meta::SMetaData::~SMetaData() |
|
527 /** |
|
528 * Virtual destructor |
|
529 */ |
|
530 { |
|
531 } |
|
532 |
|
533 CSubConExtensionParameterSet::~CSubConExtensionParameterSet() |
|
534 { |
|
535 |
|
536 } |
|
537 |
|
538 CSubConExtensionParameterSet::CSubConExtensionParameterSet() |
|
539 { |
|
540 |
|
541 } |
|
542 |
|
543 Meta::SVDataTableEntry const* CSubConQosR99ParamSet::GetVDataTable() const |
|
544 { |
|
545 return NULL; |
|
546 } |
|
547 |
|
548 TUint8* CSubConQosR99ParamSet::GetAttribPtr(const TInt /*aOffset*/) const |
|
549 { |
|
550 return NULL; |
|
551 } |
|
552 |