1.1 --- a/epoc32/include/sdpconnectionfield.h Tue Mar 16 16:12:26 2010 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,443 +0,0 @@
1.4 -/*
1.5 -* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 -* All rights reserved.
1.7 -* This component and the accompanying materials are made available
1.8 -* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.9 -* which accompanies this distribution, and is available
1.10 -* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 -*
1.12 -* Initial Contributors:
1.13 -* Nokia Corporation - initial contribution.
1.14 -*
1.15 -* Contributors:
1.16 -*
1.17 -* Description:
1.18 -* Name : SdpConnectionField.h
1.19 -* Part of : SDP Codec
1.20 -* Interface : SDK API, SDP Codec API
1.21 -* Version : 1.0
1.22 -*
1.23 -*/
1.24 -
1.25 -
1.26 -
1.27 -#ifndef CSDPCONNECTIONFIELD_H
1.28 -#define CSDPCONNECTIONFIELD_H
1.29 -
1.30 -// INCLUDES
1.31 -#include <e32base.h>
1.32 -#include <in_sock.h>
1.33 -#include <stringpool.h>
1.34 -#include "_sdpdefs.h"
1.35 -
1.36 -// CONSTANTS
1.37 -const TUint KDefaultNumOfAddress = 1;
1.38 -
1.39 -// FORWARD DECLARATIONS
1.40 -class RReadStream;
1.41 -class RWriteStream;
1.42 -
1.43 -// CLASS DECLARATION
1.44 -/**
1.45 - * @publishedAll
1.46 - * @released
1.47 - *
1.48 - * This class encapsulates the connection information field of
1.49 - * the Session Description Protocol.
1.50 - *
1.51 - * The normative reference for correct formatting and values is
1.52 - * draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
1.53 - * member documentation. The implementation supports this normative
1.54 - * reference, but does not enforce it fully.
1.55 - *
1.56 - * @lib sdpcodec.lib
1.57 - */
1.58 -class CSdpConnectionField : public CBase
1.59 - {
1.60 - public: // Constructors and destructor
1.61 -
1.62 - /**
1.63 - * Constructs a new connection field.
1.64 - *
1.65 - * @param aText A string containing a correctly
1.66 - * formatted field value terminated by a CRLF.
1.67 - * @return a new instance.
1.68 - */
1.69 - IMPORT_C static CSdpConnectionField* DecodeL( const TDesC8& aText );
1.70 -
1.71 - /**
1.72 - * Constructs a new connection field and adds the pointer to the
1.73 - * cleanup stack.
1.74 - *
1.75 - * @param aText A string containing a correctly
1.76 - * formatted field value terminated by a CRLF.
1.77 - * @return a new instance.
1.78 - */
1.79 - IMPORT_C static CSdpConnectionField* DecodeLC( const TDesC8& aText );
1.80 -
1.81 - /**
1.82 - * Constructs a new connection field.
1.83 - * Also sets the network type to "IN" and address type to "IP4" or
1.84 - * "IP6" depending on the address family of aAddress.
1.85 - *
1.86 - * @param aAddress IP address from either KAfInet
1.87 - * or KAfInet6 family
1.88 - * @param aTTL Time-To-Live for IP4 multicasts, set it as
1.89 - * KErrNotFound if IPv6 multicast or IPv4 unicast
1.90 - * @param aNumOfAddress Number of addresses in multicast,
1.91 - * if unicast, must be 1
1.92 - * @return a new instance.
1.93 - */
1.94 - IMPORT_C static CSdpConnectionField* NewL(
1.95 - const TInetAddr& aAddress,
1.96 - TInt aTTL = KErrNotFound,
1.97 - TUint aNumOfAddress = KDefaultNumOfAddress );
1.98 -
1.99 - /**
1.100 - * Constructs a new connection field.
1.101 - *
1.102 - * @param aNetType A valid network type name from the pre-
1.103 - * defined SDP string table or defined by the user.
1.104 - * @paramaAddressType A valid address type name from the
1.105 - * pre-defined SDP string table or defined by the user.
1.106 - * @param const TDesC8& aAddress: A valid address of the address type.
1.107 - * Can contain TTL & number of addresses parameter as well.
1.108 - * @return a new instance.
1.109 - */
1.110 - IMPORT_C static CSdpConnectionField* NewL(
1.111 - RStringF aNetType,
1.112 - RStringF aAddressType,
1.113 - const TDesC8& aAddress );
1.114 -
1.115 - /**
1.116 - * Constructs a new connection field and adds the pointer to the
1.117 - * cleanup stack. Also sets the network type to "IN" and address type
1.118 - * to "IP4" or "IP6" depending on the address family of aAddress.
1.119 - *
1.120 - * @param aAddress IP address from either KAfInet
1.121 - * or KAfInet6 family
1.122 - * @param aTTL Time-To-Live for IP4 multicasts, set it as
1.123 - * KErrNotFound if IPv6 multicast or IPv4 unicast
1.124 - * @param aNumOfAddress Number of addresses in multicast,
1.125 - * if unicast, must be 1
1.126 - * @return a new instance.
1.127 - */
1.128 - IMPORT_C static CSdpConnectionField* NewLC(
1.129 - const TInetAddr& aAddress,
1.130 - TInt aTTL = KErrNotFound,
1.131 - TUint aNumOfAddress = KDefaultNumOfAddress );
1.132 -
1.133 - /**
1.134 - * Construct a new connection field and adds the pointer to the
1.135 - * cleanup stack.
1.136 - *
1.137 - * @param aNetType A valid network type name from the pre-
1.138 - * defined SDP string table or defined by the user
1.139 - * @paramaAddressType A valid address type name from the
1.140 - * pre-defined SDP string table or defined by the user
1.141 - * @param const TDesC8& aAddress: A valid address of the address type.
1.142 - * Can contain TTL & number of addresses parameter as well.
1.143 - * @return a new instance.
1.144 - */
1.145 - IMPORT_C static CSdpConnectionField* NewLC(
1.146 - RStringF aNetType, RStringF aAddressType, const TDesC8& aAddress );
1.147 -
1.148 - /**
1.149 - * Deletes the resources held by the instance.
1.150 - */
1.151 - IMPORT_C ~CSdpConnectionField();
1.152 -
1.153 - public: // New functions
1.154 -
1.155 - /**
1.156 - * Outputs the field formatted according to SDP syntax and including
1.157 - * the terminating CRLF.
1.158 - *
1.159 - * @param aStream: Stream used for output. On return the
1.160 - * stream includes correctly formatted connection field.
1.161 - */
1.162 - IMPORT_C void EncodeL( RWriteStream& aStream ) const;
1.163 -
1.164 - /**
1.165 - * Creates a new instance that is equal to the target.
1.166 - *
1.167 - * @return a new instance.
1.168 - */
1.169 - IMPORT_C CSdpConnectionField* CloneL() const;
1.170 -
1.171 - /**
1.172 - * Compares this instance to another for equality.
1.173 - *
1.174 - * @param const CSdpConnectionField& aObj: The instance to compare to.
1.175 - * @return ETrue if equal, EFalse if not.
1.176 - */
1.177 - IMPORT_C TBool operator== ( const CSdpConnectionField& aObj ) const;
1.178 -
1.179 - /**
1.180 - * Gets the network type that is from the pre-defined SDP string table
1.181 - * or given by the user.
1.182 - *
1.183 - * @return The network type.
1.184 - */
1.185 - IMPORT_C RStringF NetType() const;
1.186 -
1.187 - /**
1.188 - * Gets the address type that is from the pre-defined SDP string table
1.189 - * or given by the user.
1.190 - *
1.191 - * @return The address type.
1.192 - */
1.193 - IMPORT_C RStringF AddressType() const;
1.194 -
1.195 - /**
1.196 - * Gets the address.
1.197 - *
1.198 - * @return Address as an IP address or null if it is
1.199 - * not an IP address. This may be e.g. when the address
1.200 - * has been specified as a FQDN. In this case, the address
1.201 - * can be accessed using the other getters.
1.202 - */
1.203 - IMPORT_C const TInetAddr* InetAddress() const;
1.204 -
1.205 - /**
1.206 - * Gets the address.
1.207 - *
1.208 - * @return Address as a string.
1.209 - */
1.210 - IMPORT_C const TDesC8& Address() const;
1.211 -
1.212 - /**
1.213 - * Sets the address, network and address type. Also sets the network
1.214 - * type to "IN" and address type to "IP4" or "IP6" depending on the
1.215 - * address family of aAddress.
1.216 - *
1.217 - * @param aValue The new address.
1.218 - * @param aTTL Time-To-Live for IP4 multicasts, set it as
1.219 - * KErrNotFound if IPv6 multicast or IPv4 unicast
1.220 - * @param aNumOfAddress Number of addresses in multicast,
1.221 - * if unicast, must be 1.
1.222 - * @leave KErrSdpCodecConnectionField ifaddress to be set is wrongly
1.223 - * formatted.
1.224 - */
1.225 - IMPORT_C void SetInetAddressL( const TInetAddr& aValue,
1.226 - TInt aTTL = KErrNotFound,
1.227 - TUint aNumOfAddress = KDefaultNumOfAddress);
1.228 -
1.229 - /**
1.230 - * Sets the address, network and address type.
1.231 - *
1.232 - * @param aNetType A valid network type name from the pre-
1.233 - * defined SDP string table or defined by the user
1.234 - * @param aAddressType A valid address type name from the
1.235 - * pre-defined SDP string table or defined by the user
1.236 - * @param aAddress A valid address of the address type.
1.237 - */
1.238 - IMPORT_C void SetAddressL( RStringF aNetType,
1.239 - RStringF aAddressType,
1.240 - const TDesC8& aAddress );
1.241 -
1.242 - /**
1.243 - * Gets TTL attribute.
1.244 - *
1.245 - * @return TTL or KErrNotFound, if one is not available for the address
1.246 - */
1.247 - IMPORT_C TInt TTLValue() const;
1.248 -
1.249 - /**
1.250 - * Sets TTL attribute (only valid for IP4 multicasts).
1.251 - * Leaves if trying to set TTL to address that doesn't support it.
1.252 - *
1.253 - * @param aTTL Time-To-Live for IP4 multicasts
1.254 - * @leave KErrSdpCodecConnectionField if aTTL is invalid.
1.255 - */
1.256 - IMPORT_C void SetTTLL( TInt aTTL );
1.257 -
1.258 - /**
1.259 - * Gets the number of addresses (can be more than 1 for multicasts).
1.260 - * Multicast addresses are contiguously allocated above the base
1.261 - * address.
1.262 - *
1.263 - * @return Number of addresses
1.264 - */
1.265 - IMPORT_C TInt NumOfAddress() const;
1.266 -
1.267 - /**
1.268 - * Sets the number of addreses allocated for multicast.
1.269 - *
1.270 - * @param aNumOfAddress Number of addresses in multicast
1.271 - * @leave KErrSdpCodecConnectionField if the address is unicast.
1.272 - */
1.273 - IMPORT_C void SetNumOfAddressL( TUint aNumOfAddress );
1.274 -
1.275 - public: // Internal to codec
1.276 -
1.277 - /**
1.278 - * Externalizes the object to stream
1.279 - *
1.280 - * @param aStream Stream where the object's state will be stored
1.281 - */
1.282 - void ExternalizeL( RWriteStream& aStream ) const;
1.283 -
1.284 - /**
1.285 - * Creates object from the stream data
1.286 - *
1.287 - * @param aStream Stream where the object's state will be read
1.288 - * @return Initialized object
1.289 - */
1.290 - static CSdpConnectionField* InternalizeL( RReadStream& aStream );
1.291 -
1.292 - private: // Internal
1.293 -
1.294 - /**
1.295 - * Constructor
1.296 - */
1.297 - CSdpConnectionField();
1.298 -
1.299 - /**
1.300 - * 2nd phase constructor
1.301 - *
1.302 - * @param aText A string containing a correctly formatted field value
1.303 - * terminated by a CRLF.
1.304 - */
1.305 - void ConstructL( const TDesC8& aText );
1.306 -
1.307 - /**
1.308 - * 2nd phase constructor
1.309 - *
1.310 - * @param aAddress IP address from either KAfInet or KAfInet6 family
1.311 - * @param aTTL Time-To-Live for IP4 multicasts
1.312 - * @param aNumOfAddress Nubmer of addresses in multicast
1.313 - */
1.314 - void ConstructL( const TInetAddr& aAddress,
1.315 - TInt aTTL, TUint aNumOfAddress );
1.316 -
1.317 - /**
1.318 - * 2nd phase constructor
1.319 - *
1.320 - * @param aNetType A valid network type name from the pre-defined
1.321 - * SDP string table or defined by the user
1.322 - * @param aAddressType A valid address type name from the pre-defined
1.323 - * SDP string table or defined by the user
1.324 - * @param aAddress A valid address of the address type
1.325 - */
1.326 - void ConstructL( RStringF aNetType, RStringF aAddressType,
1.327 - const TDesC8& aAddress );
1.328 -
1.329 - /**
1.330 - * Checks if the address is valid against given arguments
1.331 - *
1.332 - * @param aAddressTypeIP4 The given type of address (EFalse = IP6)
1.333 - * @param aAddress Address with possibly TTL & number of addresses
1.334 - * @return error code (KErrNone if valid)
1.335 - */
1.336 - TInt IsValidAddress( TBool aAddressTypeIP4,
1.337 - const TDesC8& aAddress ) const;
1.338 -
1.339 - /**
1.340 - * Checks if the address is valid against given arguments
1.341 - *
1.342 - * @param aAddress Address in TInetAddr format
1.343 - * @param aTTL TTL attribute
1.344 - * @param aNumOfAddress Number off addresses
1.345 - * @return error code (KErrNone if valid)
1.346 - */
1.347 - TInt IsValidAddress( const TInetAddr& aAddress,
1.348 - TInt aTTL, TUint aNumOfAddress ) const;
1.349 -
1.350 - /**
1.351 - * Parses address field
1.352 - *
1.353 - * @param aAddressTypeIP4 The given type of address (EFalse = IP6)
1.354 - * @param aAddress Address with possibly TTL & number of addresses
1.355 - * @param aTTL TTL value is stored here (or KErrNotFound)
1.356 - * @param aNumberOfAddresses Range of addreses
1.357 - * @return The address
1.358 - */
1.359 - HBufC8* ParseAddressFieldL( TBool aAddressTypeIP4,
1.360 - const TDesC8& aAddress,
1.361 - TInt& aTTL,
1.362 - TUint& aNumberOfAddresses ) const;
1.363 -
1.364 - /**
1.365 - * Parses IP4 address
1.366 - *
1.367 - * @param aPos Position of the (first) separation mark
1.368 - * @param aTTL TTL value is stored here (or KErrNotFound)
1.369 - * @param aAddr Addres in TInetAddr format
1.370 - * @param aAddress The whole address field
1.371 - * @param aNumberOfAddresses Range of addreses
1.372 - * @return The address
1.373 - */
1.374 - HBufC8* ParseIP4AddressL( TInt aPos,
1.375 - TInetAddr& aAddr,
1.376 - const TDesC8& aAddress,
1.377 - TInt& aTTL,
1.378 - TUint& aNumberOfAddresses ) const;
1.379 -
1.380 - /**
1.381 - * Parses IP6 address
1.382 - *
1.383 - * @param aPos Position of the (first) separation mark
1.384 - * @param aTTL TTL value is stored here (or KErrNotFound)
1.385 - * @param aAddr Addres in TInetAddr format
1.386 - * @param aAddress The whole address field
1.387 - * @param aNumberOfAddresses Range of addreses
1.388 - * @return The address
1.389 - */
1.390 - HBufC8* ParseIP6AddressL( TInt aPos,
1.391 - TInetAddr& aAddr,
1.392 - const TDesC8& aAddress,
1.393 - TInt& aTTL,
1.394 - TUint& aNumberOfAddresses ) const;
1.395 -
1.396 - /**
1.397 - * Copies given network type to iNetType and verifies aNetType to
1.398 - * be valid
1.399 - *
1.400 - * @param aNetType Given network type
1.401 - */
1.402 - void CopyNetTypeL( const TDesC8& aNetType );
1.403 -
1.404 - /**
1.405 - * Copies given address type to iAddressType and verifies aAddrType
1.406 - * to be valid
1.407 - *
1.408 - * @param aAddrType Given address type
1.409 - */
1.410 - void CopyAddressTypeL( const TDesC8& aAddrType );
1.411 -
1.412 - /**
1.413 - * Copies address to iAddress, and initalizes TTL & number of addresses,
1.414 - * leaves on error
1.415 - *
1.416 - * @param aAddress Address string, which can also contain TTL
1.417 - * and number of addresses attributes
1.418 - */
1.419 - void CopyAddressL( const TDesC8& aAddress, RStringPool aPool );
1.420 -
1.421 - private: // Data
1.422 -
1.423 - // <network type>
1.424 - RStringF iNetType;
1.425 -
1.426 - // <address type>
1.427 - RStringF iAddressType;
1.428 -
1.429 - // mutable TInetAddr for InetAddress()
1.430 - mutable TInetAddr iInetAddress;
1.431 -
1.432 - // Address in text format
1.433 - HBufC8* iAddress;
1.434 -
1.435 - // TTL for IP4 multicast addresses
1.436 - TInt iTTL;
1.437 - // Number of addresses
1.438 - TUint iNumOfAddress;
1.439 -
1.440 - // String pool
1.441 - RStringPool iPool;
1.442 -
1.443 - __DECLARE_TEST;
1.444 - };
1.445 -
1.446 -#endif // CSDPCONNECTIONFIELD_H