1.1 --- a/epoc32/include/sdporiginfield.h Tue Mar 16 16:12:26 2010 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,460 +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 : SdpOriginField.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 CSDPORIGINFIELD_H
1.28 -#define CSDPORIGINFIELD_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 TInt KMaxAddressLength = 256;
1.38 -
1.39 -// FORWARD DECLARATIONS
1.40 -class RReadStream;
1.41 -class RWriteStream;
1.42 -class CSdpOriginFieldPtrs;
1.43 -
1.44 -// CLASS DECLARATION
1.45 -/**
1.46 - * @publishedAll
1.47 - * @released
1.48 - *
1.49 - * This class encapsulates the origin field of
1.50 - * the Session Description Protocol.
1.51 - *
1.52 - * The normative reference for correct formatting and values is
1.53 - * draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
1.54 - * member documentation. The implementation supports this normative
1.55 - * reference, but does not enforce it fully.
1.56 - *
1.57 - * @lib sdpcodec.lib
1.58 - */
1.59 -class CSdpOriginField : public CBase
1.60 - {
1.61 - public: // Constructors and destructor
1.62 -
1.63 - /**
1.64 - * Constructs a new origin field.
1.65 - *
1.66 - * @param aText A string containing a correctly
1.67 - * formatted field value terminated by a CRLF.
1.68 - * @return a new instance.
1.69 - */
1.70 - IMPORT_C static CSdpOriginField* DecodeL( const TDesC8& aText );
1.71 -
1.72 - /**
1.73 - * Constructs a new origin field and adds the pointer to the cleanup
1.74 - * stack.
1.75 - *
1.76 - * @param aText A string containing a correctly
1.77 - * formatted field value terminated by a CRLF.
1.78 - * @return a new instance.
1.79 - */
1.80 - IMPORT_C static CSdpOriginField* DecodeLC( const TDesC8& aText );
1.81 -
1.82 - /**
1.83 - * Constructs a new origin field.
1.84 - *
1.85 - * @param aUserName A valid user name value.
1.86 - * @param aSessionId A valid session id value.
1.87 - * @param aSessionVersion A valid announcement version value.
1.88 - * @param aAddress A unicast IP address from either
1.89 - * KAfInet or KAfInet6 family.
1.90 - * @return a new instance.
1.91 - */
1.92 - IMPORT_C static CSdpOriginField* NewL( const TDesC8& aUserName,
1.93 - TInt64 aSessionId,
1.94 - TInt64 aSessionVersion,
1.95 - TInetAddr& aAddress );
1.96 -
1.97 - /**
1.98 - * Constructs a new origin field and adds the pointer to the cleanup
1.99 - * stack.
1.100 - *
1.101 - * @param aUserName A valid user name value.
1.102 - * @param aSessionId A valid session id value.
1.103 - * @param aSessionVersion A valid announcement version value.
1.104 - * @param aAddress A unicast IP address from either
1.105 - * KAfInet or KAfInet6 family.
1.106 - * @return a new instance.
1.107 - */
1.108 - IMPORT_C static CSdpOriginField* NewLC( const TDesC8& aUserName,
1.109 - TInt64 aSessionId,
1.110 - TInt64 aSessionVersion,
1.111 - TInetAddr& aAddress );
1.112 -
1.113 - /**
1.114 - * Constructs a new origin field.
1.115 - *
1.116 - * @param aUserName A valid user name value.
1.117 - * @param aSessionId A valid session id value.
1.118 - * @param aSessionVersion A valid announcement version value.
1.119 - * @param aNetType A valid network type value (typically "IN").
1.120 - * @param aAddressType A valid address type value
1.121 - * (typically "IP4" or "IP6").
1.122 - * @param aAddress A unicast IP Address, Fully
1.123 - * Qualified Domain Name (FQDN), or an other type of
1.124 - * address allowed for the address type.
1.125 - * @return a new instance.
1.126 - */
1.127 - IMPORT_C static CSdpOriginField* NewL( const TDesC8& aUserName,
1.128 - TInt64 aSessionId,
1.129 - TInt64 aSessionVersion,
1.130 - RStringF aNetType,
1.131 - RStringF aAddressType,
1.132 - const TDesC8& aAddress );
1.133 -
1.134 - /**
1.135 - * Constructs a new origin field and adds the pointer to the cleanup
1.136 - * stack.
1.137 - *
1.138 - * @param aUserName A valid user name value.
1.139 - * @param aSessionId A valid session id value.
1.140 - * @param aSessionVersion A valid announcement version value.
1.141 - * @param aNetType A valid network type value (typically "IN").
1.142 - * @param aAddressType A valid address type value
1.143 - * (typically "IP4" or "IP6").
1.144 - * @param aAddress A unicast IP Address, Fully Qualified Domain
1.145 - * Name (FQDN), or an other type of address allowed
1.146 - * for the address type.
1.147 - * @return a new instance.
1.148 - */
1.149 - IMPORT_C static CSdpOriginField* NewLC( const TDesC8& aUserName,
1.150 - TInt64 aSessionId,
1.151 - TInt64 aSessionVersion,
1.152 - RStringF aNetType,
1.153 - RStringF aAddressType,
1.154 - const TDesC8& aAddress );
1.155 -
1.156 - /**
1.157 - * Deletes the resources held by the instance.
1.158 - */
1.159 - IMPORT_C ~CSdpOriginField();
1.160 -
1.161 - public: // New functions
1.162 -
1.163 - /**
1.164 - * Outputs the field formatted according to SDP syntax and including
1.165 - * the terminating CRLF.
1.166 - *
1.167 - * @param aStream Stream used for output. On return
1.168 - * the stream includes correctly formatted origin field.
1.169 - */
1.170 - IMPORT_C void EncodeL( RWriteStream& aStream ) const;
1.171 -
1.172 - /**
1.173 - * Creates a new instance that is equal to the target.
1.174 - *
1.175 - * @return a new instance.
1.176 - */
1.177 - IMPORT_C CSdpOriginField* CloneL() const;
1.178 -
1.179 - /**
1.180 - * Compares this instance to another for equality.
1.181 - *
1.182 - * @param aObj The instance to compare to.
1.183 - * @return ETrue if equal, EFalse if not.
1.184 - */
1.185 - IMPORT_C TBool operator == ( const CSdpOriginField& aObj ) const;
1.186 -
1.187 - /**
1.188 - * Gets the user name.
1.189 - *
1.190 - * @return User name.
1.191 - */
1.192 - IMPORT_C const TDesC8& UserName() const;
1.193 -
1.194 - /**
1.195 - * Sets the user name.
1.196 - *
1.197 - * @param aValue A valid user name value.
1.198 - * @leave KErrSdpCodecOriginField if aValue is not a valid user name.
1.199 - */
1.200 - IMPORT_C void SetUserNameL( const TDesC8& aValue );
1.201 -
1.202 - /**
1.203 - * Gets the session id of the origin field.
1.204 - *
1.205 - * @return Session id.
1.206 - */
1.207 - IMPORT_C TInt64 SessionId() const;
1.208 -
1.209 - /**
1.210 - * Sets the session id.
1.211 - *
1.212 - * @param aValue A valid session id value.
1.213 - */
1.214 - IMPORT_C void SetSessionId( TInt64 aValue );
1.215 -
1.216 - /**
1.217 - * Gets the announcement version.
1.218 - *
1.219 - * @return Version.
1.220 - */
1.221 - IMPORT_C TInt64 Version() const;
1.222 -
1.223 - /**
1.224 - * Sets the announcement version..
1.225 - *
1.226 - * @param aValue A valid version value.
1.227 - */
1.228 - IMPORT_C void SetVersion( TInt64 aValue );
1.229 -
1.230 - /**
1.231 - * Gets the network type.
1.232 - *
1.233 - * @return The network type from pre-defined SDP string
1.234 - * table or given by the user.
1.235 - */
1.236 - IMPORT_C RStringF NetType() const;
1.237 -
1.238 - /**
1.239 - * Gets the address type.
1.240 - *
1.241 - * @return The address type from pre-defined SDP string
1.242 - * table or given by the user.
1.243 - */
1.244 - IMPORT_C RStringF AddressType() const;
1.245 -
1.246 - /**
1.247 - * Gets the address.
1.248 - *
1.249 - * @return Address as an IP address or null if it is
1.250 - * not an IP address. This may be e.g. when the address has
1.251 - * been specified as a FQDN. In this case, the address can be
1.252 - * accessed using the other getters.
1.253 - */
1.254 - IMPORT_C const TInetAddr* InetAddress() const;
1.255 -
1.256 - /**
1.257 - * Gets the address.
1.258 - *
1.259 - * @return Address as a string.
1.260 - */
1.261 - IMPORT_C const TDesC8& Address() const;
1.262 -
1.263 - /**
1.264 - * Sets the address, network and address type.
1.265 - * Also sets the network type to "IN" and address type to "IP4" or
1.266 - * "IP6" depending on the address family of aValue.
1.267 - *
1.268 - * @param aValue A unicast IP address from either KAfInet
1.269 - * or KAfInet6 family.
1.270 - */
1.271 - IMPORT_C void SetInetAddress( const TInetAddr& aValue );
1.272 -
1.273 - /**
1.274 - * Sets the address, network and address type.
1.275 - *
1.276 - * @param aAddress A unicast IP Address, Fully Qualified Domain
1.277 - * Name (FQDN), or an other type of address allowed for the
1.278 - * address type.
1.279 - * @param aNetType A valid network type value (typically "IN").
1.280 - * @param aAddressType A valid address type value
1.281 - * (typically "IP4" or "IP6").
1.282 - * @leave KErrSdpCodecOriginField if aNetType or aAddressType are not
1.283 - * valid tokens, or aAddress is invalid, or aAddress type
1.284 - * is not aligned with the address format
1.285 - */
1.286 - IMPORT_C void SetAddressL( const TDesC8& aAddress,
1.287 - RStringF aNetType,
1.288 - RStringF aAddressType );
1.289 -
1.290 - public: // Internal to codec
1.291 -
1.292 - /**
1.293 - * Externalizes the object to stream
1.294 - *
1.295 - * @param aStream Stream where the object's state will be stored
1.296 - */
1.297 - void ExternalizeL( RWriteStream& aStream ) const;
1.298 -
1.299 - /**
1.300 - * Creates object from the stream data
1.301 - *
1.302 - * @param aStream Stream where the object's state will be read
1.303 - * @return Initialized object
1.304 - */
1.305 - static CSdpOriginField* InternalizeL( RReadStream& aStream );
1.306 -
1.307 - private: // Constructors
1.308 -
1.309 - /**
1.310 - * Constructor
1.311 - */
1.312 - CSdpOriginField();
1.313 -
1.314 - /**
1.315 - * Second phase constructor. Parses the text string and initializes
1.316 - * the member variables
1.317 - *
1.318 - * @param aText Line of text that will be parsed (ends on the newline)
1.319 - */
1.320 - void ConstructL( const TDesC8& aText );
1.321 -
1.322 - /**
1.323 - * Second phase constructor. Constructs the object.
1.324 - *
1.325 - * @param aUserName A valid user name value.
1.326 - * @param aSessionId A valid session id value.
1.327 - * @param aSessionVersion A valid announcement version value.
1.328 - * @param aAddress A unicast IP address from either
1.329 - * KAfInet or KAfInet6 family.
1.330 - */
1.331 - void ConstructL( const TDesC8& aUserName,
1.332 - TInt64 aSessionId,
1.333 - TInt64 aSessionVersion,
1.334 - TInetAddr& aUnicastAddress );
1.335 -
1.336 - /**
1.337 - * Second phase constructor. Constructs the object.
1.338 - *
1.339 - * @param aUserName A valid user name value.
1.340 - * @param aSessionId A valid session id value.
1.341 - * @param aSessionVersion A valid announcement version value.
1.342 - * @param aNetType A valid network type value (typically "IN").
1.343 - * @param aAddressType A valid address type value
1.344 - * (typically "IP4" or "IP6").
1.345 - * @param aAddress A unicast IP Address, Fully Qualified Domain
1.346 - * Name (FQDN), or an other type of address allowed
1.347 - * for the address type.
1.348 - */
1.349 - void ConstructL( const TDesC8& aUserName,
1.350 - TInt64 aSessionId,
1.351 - TInt64 aSessionVersion,
1.352 - RStringF aNetType,
1.353 - RStringF aAddressType,
1.354 - const TDesC8& aAddress );
1.355 -
1.356 - // These are unnecessary? Derived from CBase, prevents the use
1.357 - CSdpOriginField( const CSdpOriginField& ); // Hidden.
1.358 - CSdpOriginField& operator = ( const CSdpOriginField& ); // Hidden
1.359 -
1.360 - private: // New methods
1.361 -
1.362 - /**
1.363 - * Checks if the given address is valid
1.364 - *
1.365 - * @param aAddress Address to be checked
1.366 - * @return Valid address or not
1.367 - */
1.368 - TBool IsValidAddress( const TDesC8& aAddress ) const;
1.369 -
1.370 - /**
1.371 - * Checks if the given address is valid
1.372 - *
1.373 - * @param aAddr Address to be checked
1.374 - * @return Valid address or not
1.375 - */
1.376 - TBool IsValidAddress( const TInetAddr& addr ) const;
1.377 -
1.378 - /**
1.379 - * Checks that address type matches with address format
1.380 - *
1.381 - * @param aAddress Address
1.382 - * @param aType Address type
1.383 - * @param aPool String pool
1.384 - * @return Type Matches with format or not
1.385 - */
1.386 - TBool TypeMatchesWithFormat(
1.387 - const TDesC8& aAddress, const TDesC8& aType,
1.388 - RStringPool aPool ) const;
1.389 -
1.390 - /**
1.391 - * Checks if the given username is valid
1.392 - *
1.393 - * @param aUserName Username
1.394 - * @return Validity of the given username
1.395 - */
1.396 - TBool IsValidUserName( const TDesC8& aUserName ) const;
1.397 -
1.398 - /**
1.399 - * Parses username, initializes iUserName
1.400 - *
1.401 - * @param aArray Array containing all the elements
1.402 - */
1.403 - void ParseUserNameL( RArray<TPtrC8>& aArray );
1.404 -
1.405 - /**
1.406 - * Parses session ID and version, initializes iSessionId
1.407 - * and iSessionVersion
1.408 - *
1.409 - * @param aArray Array containing all the elements
1.410 - */
1.411 - void ParseSessionIDAndVersionL( RArray<TPtrC8>& aArray );
1.412 -
1.413 - /**
1.414 - * Parses network type and address type, initializes
1.415 - * iNetType and iAddressType
1.416 - *
1.417 - * @param aArray Array containing all the elements
1.418 - */
1.419 - void ParseNetTypeAndAddressTypeL( RArray<TPtrC8>& aArray );
1.420 -
1.421 - /**
1.422 - * Parses address, checks address against address type,
1.423 - * initializes iAddress
1.424 - *
1.425 - * @param aArray Array containing all the elements
1.426 - */
1.427 - void ParseAddressL( RArray<TPtrC8>& aArray );
1.428 -
1.429 - inline CSdpOriginFieldPtrs& OriginFieldPtrs();
1.430 -
1.431 - inline const CSdpOriginFieldPtrs& OriginFieldPtrs() const;
1.432 -
1.433 - TInt64 Get63Msbs( const TDesC8& aDecimalValue ) const;
1.434 - void SetIPAddressType( const TInetAddr& aAddr );
1.435 -
1.436 - private: // Data
1.437 -
1.438 - RStringPool iPool;
1.439 -
1.440 - // <username>
1.441 - HBufC8* iUserName;
1.442 - // <session id>
1.443 - TInt64 iSessionId;
1.444 - // <version>
1.445 - TInt64 iSessionVersion;
1.446 - // <net type>
1.447 - RStringF iNetType;
1.448 - // <address type>
1.449 - RStringF iAddressType;
1.450 - // <address>
1.451 - // Either one is used (this or iAddressType/iAddress combo)
1.452 - // Can be defined as mutable because this variable does not affect
1.453 - // to the state of the object, but it is needed as const pointer
1.454 - // is returned on InetAddr() method
1.455 - mutable TInetAddr iUnicastAddress;
1.456 - TBuf8<KMaxAddressLength> iAddress;
1.457 - // For configuring the address into TInetAddr
1.458 - TBuf<KMaxAddressLength> iAddress16;
1.459 -
1.460 - __DECLARE_TEST;
1.461 - };
1.462 -
1.463 -#endif // CSDPORIGINFIELD_H