Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * 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
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Name : SdpOriginField.h
17 * Interface : SDK API, SDP Codec API
24 #ifndef CSDPORIGINFIELD_H
25 #define CSDPORIGINFIELD_H
30 #include <stringpool.h>
34 const TInt KMaxAddressLength = 256;
36 // FORWARD DECLARATIONS
39 class CSdpOriginFieldPtrs;
46 * This class encapsulates the origin field of
47 * the Session Description Protocol.
49 * The normative reference for correct formatting and values is
50 * draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
51 * member documentation. The implementation supports this normative
52 * reference, but does not enforce it fully.
56 class CSdpOriginField : public CBase
58 public: // Constructors and destructor
61 * Constructs a new origin field.
63 * @param aText A string containing a correctly
64 * formatted field value terminated by a CRLF.
65 * @return a new instance.
67 IMPORT_C static CSdpOriginField* DecodeL( const TDesC8& aText );
70 * Constructs a new origin field and adds the pointer to the cleanup
73 * @param aText A string containing a correctly
74 * formatted field value terminated by a CRLF.
75 * @return a new instance.
77 IMPORT_C static CSdpOriginField* DecodeLC( const TDesC8& aText );
80 * Constructs a new origin field.
82 * @param aUserName A valid user name value.
83 * @param aSessionId A valid session id value.
84 * @param aSessionVersion A valid announcement version value.
85 * @param aAddress A unicast IP address from either
86 * KAfInet or KAfInet6 family.
87 * @return a new instance.
89 IMPORT_C static CSdpOriginField* NewL( const TDesC8& aUserName,
91 TInt64 aSessionVersion,
92 TInetAddr& aAddress );
95 * Constructs a new origin field and adds the pointer to the cleanup
98 * @param aUserName A valid user name value.
99 * @param aSessionId A valid session id value.
100 * @param aSessionVersion A valid announcement version value.
101 * @param aAddress A unicast IP address from either
102 * KAfInet or KAfInet6 family.
103 * @return a new instance.
105 IMPORT_C static CSdpOriginField* NewLC( const TDesC8& aUserName,
107 TInt64 aSessionVersion,
108 TInetAddr& aAddress );
111 * Constructs a new origin field.
113 * @param aUserName A valid user name value.
114 * @param aSessionId A valid session id value.
115 * @param aSessionVersion A valid announcement version value.
116 * @param aNetType A valid network type value (typically "IN").
117 * @param aAddressType A valid address type value
118 * (typically "IP4" or "IP6").
119 * @param aAddress A unicast IP Address, Fully
120 * Qualified Domain Name (FQDN), or an other type of
121 * address allowed for the address type.
122 * @return a new instance.
124 IMPORT_C static CSdpOriginField* NewL( const TDesC8& aUserName,
126 TInt64 aSessionVersion,
128 RStringF aAddressType,
129 const TDesC8& aAddress );
132 * Constructs a new origin field and adds the pointer to the cleanup
135 * @param aUserName A valid user name value.
136 * @param aSessionId A valid session id value.
137 * @param aSessionVersion A valid announcement version value.
138 * @param aNetType A valid network type value (typically "IN").
139 * @param aAddressType A valid address type value
140 * (typically "IP4" or "IP6").
141 * @param aAddress A unicast IP Address, Fully Qualified Domain
142 * Name (FQDN), or an other type of address allowed
143 * for the address type.
144 * @return a new instance.
146 IMPORT_C static CSdpOriginField* NewLC( const TDesC8& aUserName,
148 TInt64 aSessionVersion,
150 RStringF aAddressType,
151 const TDesC8& aAddress );
154 * Deletes the resources held by the instance.
156 IMPORT_C ~CSdpOriginField();
158 public: // New functions
161 * Outputs the field formatted according to SDP syntax and including
162 * the terminating CRLF.
164 * @param aStream Stream used for output. On return
165 * the stream includes correctly formatted origin field.
167 IMPORT_C void EncodeL( RWriteStream& aStream ) const;
170 * Creates a new instance that is equal to the target.
172 * @return a new instance.
174 IMPORT_C CSdpOriginField* CloneL() const;
177 * Compares this instance to another for equality.
179 * @param aObj The instance to compare to.
180 * @return ETrue if equal, EFalse if not.
182 IMPORT_C TBool operator == ( const CSdpOriginField& aObj ) const;
185 * Gets the user name.
189 IMPORT_C const TDesC8& UserName() const;
192 * Sets the user name.
194 * @param aValue A valid user name value.
195 * @leave KErrSdpCodecOriginField if aValue is not a valid user name.
197 IMPORT_C void SetUserNameL( const TDesC8& aValue );
200 * Gets the session id of the origin field.
202 * @return Session id.
204 IMPORT_C TInt64 SessionId() const;
207 * Sets the session id.
209 * @param aValue A valid session id value.
211 IMPORT_C void SetSessionId( TInt64 aValue );
214 * Gets the announcement version.
218 IMPORT_C TInt64 Version() const;
221 * Sets the announcement version..
223 * @param aValue A valid version value.
225 IMPORT_C void SetVersion( TInt64 aValue );
228 * Gets the network type.
230 * @return The network type from pre-defined SDP string
231 * table or given by the user.
233 IMPORT_C RStringF NetType() const;
236 * Gets the address type.
238 * @return The address type from pre-defined SDP string
239 * table or given by the user.
241 IMPORT_C RStringF AddressType() const;
246 * @return Address as an IP address or null if it is
247 * not an IP address. This may be e.g. when the address has
248 * been specified as a FQDN. In this case, the address can be
249 * accessed using the other getters.
251 IMPORT_C const TInetAddr* InetAddress() const;
256 * @return Address as a string.
258 IMPORT_C const TDesC8& Address() const;
261 * Sets the address, network and address type.
262 * Also sets the network type to "IN" and address type to "IP4" or
263 * "IP6" depending on the address family of aValue.
265 * @param aValue A unicast IP address from either KAfInet
266 * or KAfInet6 family.
268 IMPORT_C void SetInetAddress( const TInetAddr& aValue );
271 * Sets the address, network and address type.
273 * @param aAddress A unicast IP Address, Fully Qualified Domain
274 * Name (FQDN), or an other type of address allowed for the
276 * @param aNetType A valid network type value (typically "IN").
277 * @param aAddressType A valid address type value
278 * (typically "IP4" or "IP6").
279 * @leave KErrSdpCodecOriginField if aNetType or aAddressType are not
280 * valid tokens, or aAddress is invalid, or aAddress type
281 * is not aligned with the address format
283 IMPORT_C void SetAddressL( const TDesC8& aAddress,
285 RStringF aAddressType );
287 public: // Internal to codec
290 * Externalizes the object to stream
292 * @param aStream Stream where the object's state will be stored
294 void ExternalizeL( RWriteStream& aStream ) const;
297 * Creates object from the stream data
299 * @param aStream Stream where the object's state will be read
300 * @return Initialized object
302 static CSdpOriginField* InternalizeL( RReadStream& aStream );
304 private: // Constructors
312 * Second phase constructor. Parses the text string and initializes
313 * the member variables
315 * @param aText Line of text that will be parsed (ends on the newline)
317 void ConstructL( const TDesC8& aText );
320 * Second phase constructor. Constructs the object.
322 * @param aUserName A valid user name value.
323 * @param aSessionId A valid session id value.
324 * @param aSessionVersion A valid announcement version value.
325 * @param aAddress A unicast IP address from either
326 * KAfInet or KAfInet6 family.
328 void ConstructL( const TDesC8& aUserName,
330 TInt64 aSessionVersion,
331 TInetAddr& aUnicastAddress );
334 * Second phase constructor. Constructs the object.
336 * @param aUserName A valid user name value.
337 * @param aSessionId A valid session id value.
338 * @param aSessionVersion A valid announcement version value.
339 * @param aNetType A valid network type value (typically "IN").
340 * @param aAddressType A valid address type value
341 * (typically "IP4" or "IP6").
342 * @param aAddress A unicast IP Address, Fully Qualified Domain
343 * Name (FQDN), or an other type of address allowed
344 * for the address type.
346 void ConstructL( const TDesC8& aUserName,
348 TInt64 aSessionVersion,
350 RStringF aAddressType,
351 const TDesC8& aAddress );
353 // These are unnecessary? Derived from CBase, prevents the use
354 CSdpOriginField( const CSdpOriginField& ); // Hidden.
355 CSdpOriginField& operator = ( const CSdpOriginField& ); // Hidden
357 private: // New methods
360 * Checks if the given address is valid
362 * @param aAddress Address to be checked
363 * @return Valid address or not
365 TBool IsValidAddress( const TDesC8& aAddress ) const;
368 * Checks if the given address is valid
370 * @param aAddr Address to be checked
371 * @return Valid address or not
373 TBool IsValidAddress( const TInetAddr& addr ) const;
376 * Checks that address type matches with address format
378 * @param aAddress Address
379 * @param aType Address type
380 * @param aPool String pool
381 * @return Type Matches with format or not
383 TBool TypeMatchesWithFormat(
384 const TDesC8& aAddress, const TDesC8& aType,
385 RStringPool aPool ) const;
388 * Checks if the given username is valid
390 * @param aUserName Username
391 * @return Validity of the given username
393 TBool IsValidUserName( const TDesC8& aUserName ) const;
396 * Parses username, initializes iUserName
398 * @param aArray Array containing all the elements
400 void ParseUserNameL( RArray<TPtrC8>& aArray );
403 * Parses session ID and version, initializes iSessionId
404 * and iSessionVersion
406 * @param aArray Array containing all the elements
408 void ParseSessionIDAndVersionL( RArray<TPtrC8>& aArray );
411 * Parses network type and address type, initializes
412 * iNetType and iAddressType
414 * @param aArray Array containing all the elements
416 void ParseNetTypeAndAddressTypeL( RArray<TPtrC8>& aArray );
419 * Parses address, checks address against address type,
420 * initializes iAddress
422 * @param aArray Array containing all the elements
424 void ParseAddressL( RArray<TPtrC8>& aArray );
426 inline CSdpOriginFieldPtrs& OriginFieldPtrs();
428 inline const CSdpOriginFieldPtrs& OriginFieldPtrs() const;
430 TInt64 Get63Msbs( const TDesC8& aDecimalValue ) const;
431 void SetIPAddressType( const TInetAddr& aAddr );
442 TInt64 iSessionVersion;
446 RStringF iAddressType;
448 // Either one is used (this or iAddressType/iAddress combo)
449 // Can be defined as mutable because this variable does not affect
450 // to the state of the object, but it is needed as const pointer
451 // is returned on InetAddr() method
452 mutable TInetAddr iUnicastAddress;
453 TBuf8<KMaxAddressLength> iAddress;
454 // For configuring the address into TInetAddr
455 TBuf<KMaxAddressLength> iAddress16;
460 #endif // CSDPORIGINFIELD_H