contentmgmt/referencedrmagent/RefTestAgent/localsdp/api/sdpattributefield.h
changeset 72 de46a57f75fb
equal deleted inserted replaced
65:970c0057d9bc 72:de46a57f75fb
       
     1 /*
       
     2 * Copyright (c) 2010 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 * Name          : SdpAttributeField.h
       
    16 * Part of       : Local SDP Codec
       
    17 * Interface     : SDK API, Local SDP Codec API
       
    18 * Version       : 1.0
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 #ifndef CSDPATTRIBUTEFIELD_H
       
    25 #define CSDPATTRIBUTEFIELD_H
       
    26 
       
    27 //  INCLUDES
       
    28 #include <e32base.h>
       
    29 #include <stringpool.h>
       
    30 #include "sdpcodecstringconstants.h"
       
    31 #include "_sdpdefs.h"
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 class RReadStream;
       
    35 class RWriteStream;
       
    36 class CSdpFmtAttributeField;
       
    37 class CSdpAttributeFieldPtrs;
       
    38 
       
    39 // CLASS DECLARATION
       
    40 /**
       
    41  *  @publishedAll
       
    42  *  @released
       
    43  *
       
    44  *	This class encapsulates the attribute field of Session Description Protocol
       
    45  *	for media and session level attributes. Media format/payload type level
       
    46  *  attributes are supported by the CSdpFmtAttributeField class. 
       
    47  * 
       
    48  *	The normative reference for correct formatting and values is
       
    49  *	draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
       
    50  *  member documentation. The implementation supports this normative
       
    51  *  reference, but does not enforce it fully. 
       
    52  *
       
    53  *  @lib localsdpcodec.lib
       
    54  */
       
    55 class CSdpAttributeField : public CBase
       
    56 	{
       
    57     public:     // Constructors and destructor
       
    58 
       
    59         /**
       
    60          *	Constructs a new attribute field.
       
    61 		 *			 
       
    62          *	@param aText A string containing a correctly 
       
    63          *         formatted field value terminated by a CRLF.
       
    64          *	@return a new instance.
       
    65          */
       
    66 		IMPORT_C static CSdpAttributeField* DecodeL( const TDesC8& aText );
       
    67 
       
    68         /**
       
    69          *	Constructs a new attribute field and adds the pointer to the 
       
    70          *  cleanup stack.
       
    71 		 *		 
       
    72          *	@param aTest A string containing a correctly 
       
    73          *         formatted field value terminated by a CRLF.
       
    74          *	@return a new instance.
       
    75          */
       
    76 		IMPORT_C static CSdpAttributeField* DecodeLC( const TDesC8& aText );
       
    77 
       
    78         /**
       
    79          *	Constructs a new attribute field. 
       
    80 		 *
       
    81          *	@param aAttribute The attribute name. It can be a pre-
       
    82          *         defined name in the SDP string pool or defined by the 
       
    83          *         client.
       
    84          *	@param aValue A valid attribute value or an empty 
       
    85          *         descriptor to omit the value part.
       
    86          *	@return a new instance.
       
    87 		 */
       
    88 		IMPORT_C static CSdpAttributeField* NewL(
       
    89             RStringF aAttribute, const TDesC8& aValue );
       
    90 
       
    91         /**
       
    92          *	Constructs a new attribute field and adds the pointer to the 
       
    93          *  cleanup stack. 
       
    94 		 *
       
    95          *	@param aAttribute The attribute name. It can be a pre-defined 
       
    96          *         name in the SDP string pool or defined by the client.
       
    97          *	@param aValue A valid attribute value or an empty 
       
    98          *         descriptor to omit the value part.
       
    99          *	@return a new instance.
       
   100 		 */
       
   101 		IMPORT_C static CSdpAttributeField* NewLC(
       
   102             RStringF aAttribute, const TDesC8& aValue );
       
   103 
       
   104  		/**
       
   105 		 *	Deletes the resources held by the instance.
       
   106 		 */
       
   107 		IMPORT_C ~CSdpAttributeField();
       
   108 
       
   109     public:     // New functions
       
   110 	
       
   111     	/**
       
   112 		 *	Outputs the field formatted according to SDP syntax and including
       
   113 		 *  the terminating CRLF.
       
   114 		 * 
       
   115 		 *	@param aStream Stream used for output. On return the 
       
   116          *         stream includes correctly formatted attribute field.
       
   117 		 */
       
   118 		IMPORT_C void EncodeL( RWriteStream& aStream ) const;
       
   119 
       
   120 		/**
       
   121 		 *	Creates a new instance that is equal to the target.
       
   122 		 *
       
   123 		 *	@return a new instance.
       
   124 		 */
       
   125 		IMPORT_C CSdpAttributeField* CloneL() const;
       
   126 
       
   127 		/**	
       
   128 		 *	Compares this instance to another for equality.
       
   129 		 *
       
   130 		 *	@param aObj: The instance to compare to.
       
   131 		 *	@return ETrue if equal, EFalse if not.
       
   132 		 */
       
   133 		IMPORT_C TBool operator == ( const CSdpAttributeField& aObj ) const;
       
   134 
       
   135 		/**
       
   136 		 *	Gets the attribute name.
       
   137 		 *	
       
   138 		 *	@return	The attribute name. The name can be pre-defined 
       
   139          *          name in the SDP string table or defined by the client.
       
   140 		 */
       
   141 		IMPORT_C RStringF Attribute() const;
       
   142 
       
   143 		/**
       
   144 		 *	Gets the attribute.
       
   145 		 *
       
   146  		 *	@return	The value or an empty descriptor if there is no value part.
       
   147 		 */
       
   148 		IMPORT_C const TDesC8& Value() const;
       
   149 
       
   150 		/**
       
   151 		 *	Sets the attribute and attribute value.
       
   152 		 *
       
   153          *	@param aAttribute A valid attribute name. It can be a 
       
   154          *         pre-defined name in the SDP string pool or 
       
   155          *         defined by the client.
       
   156          *	@param aValue A valid attribute value or an empty 
       
   157          *         descriptor to omit the value part.
       
   158 		 *  @leave KErrSdpCodecAttributeField if the attribute part is not 
       
   159 		 *         pre-defined EAttributeFmtp or EAttributeRtpmap.
       
   160 		 */
       
   161 		IMPORT_C void SetL( RStringF aAttribute, const TDesC8& aValue );
       
   162 		
       
   163 		/**
       
   164  		 *	Assigns attribute to the format level attribute.
       
   165  		 *  In the final output the attribute will placed after format level
       
   166 		 *  attribute.
       
   167  		 *
       
   168  		 *	@param aFmtAttribute A format level 
       
   169  		 *         attribute this attribute is assigned to.
       
   170  		 */
       
   171  		IMPORT_C void AssignTo(const CSdpFmtAttributeField& aFmtAttribute);
       
   172 		
       
   173 		/**
       
   174 		 *	Test if the attribute belongs to the given format level attribute.
       
   175 		 *  Note, that the check can be true for the media level paremeter if
       
   176 		 *  it appears after the last format level attribute.
       
   177 		 *
       
   178 		 *	@param  aFmtAttribute: A format level 
       
   179 		 *          attribute this attribute belongs to.
       
   180 		 *	@return	ETrue if attribute belongs to the format level attribute, 
       
   181 		 *          EFalse otherwise.
       
   182 		 */
       
   183 		IMPORT_C TBool BelongsTo(const CSdpFmtAttributeField& aFmtAttribute) const;
       
   184 
       
   185     public:     // Internal to codec
       
   186 
       
   187         /**
       
   188          *  Externalizes the object to stream
       
   189          *
       
   190          *  @param aStream Stream where the object's state will be stored
       
   191          */
       
   192 		void ExternalizeL( RWriteStream& aStream ) const;
       
   193 
       
   194         /**
       
   195          *  Creates object from the stream data
       
   196          *
       
   197          *  @param aStream Stream where the object's state will be read
       
   198          *  @return Initialized object
       
   199          */
       
   200         static CSdpAttributeField* InternalizeL( RReadStream& aStream );
       
   201         
       
   202         /**
       
   203          *  Informs if the attribute belongs to any format level attribute.
       
   204          *
       
   205          *  @return ETrue if attribute belongs to any format level 
       
   206 		 *			attribute, EFalse otherwise.
       
   207          */
       
   208         TBool IsFmtAttribute();
       
   209     
       
   210 	private:    // Constructors
       
   211 
       
   212         /**
       
   213          *  Constructor
       
   214          */
       
   215 		CSdpAttributeField();
       
   216 
       
   217         /**
       
   218          *  Second phase constructor
       
   219          *
       
   220          *  @param aText Text string ending to LF character
       
   221          */
       
   222         void ConstructL( const TDesC8& aText );
       
   223 
       
   224         /**
       
   225          *  Second phase constructor
       
   226          *
       
   227          *  @param aAttribute Attribute identifier
       
   228          *  @param aValue Value of the attribute of KNullDesC8
       
   229          */
       
   230         void ConstructL( RStringF aAttribute, const TDesC8& aValue );
       
   231     
       
   232     private:    // Internal
       
   233 
       
   234         /**
       
   235          *  Verifies that attribute is valid property attribute and initializes
       
   236          *  the member variables of class accordingly
       
   237          *
       
   238          *  @param aAttribute Attribute in descriptor
       
   239          */
       
   240         void FormatProperyAttributeL( const TDesC8& aAttribute );
       
   241 
       
   242         /**
       
   243          *  Verifies that attribute is valid value attribute and initializes
       
   244          *  the member variables of class accordingly
       
   245          *
       
   246          *  @param aArray Array of the attributes
       
   247          */
       
   248         void FormatValueAttributeL( const TDesC8& aAttribute,
       
   249                                     const TDesC8& aValue );
       
   250 
       
   251         /**
       
   252          *  Verifies that the value is valid for the attribute
       
   253          *
       
   254          *  @param aAttribute The attribute
       
   255          *  @param aArray Array containing the values (and attribute)
       
   256          */
       
   257         void VerifyValueAttributeL( SdpCodecStringConstants::TStrings aString,
       
   258                                     const TDesC8& aValue );
       
   259                                     
       
   260         /**
       
   261          *  Forms attribute and value strings out of the token array
       
   262          *  and pushes both (aAttribute & aValue) into cleanup stack
       
   263          *
       
   264          *  @param aArray Token array
       
   265          *  @param aAttribute Attribute string (in cleanup stack)
       
   266          *  @param aValue Value string (in cleanup stack)
       
   267          */
       
   268         void CreateAttributeAndValueStringsLC( RArray<TPtrC8>& aArray,
       
   269                                                HBufC8*& aAttribute,
       
   270                                                HBufC8*& aValue );
       
   271 
       
   272         /**
       
   273          *  Checks if the value is among the valid orient attributes
       
   274          *
       
   275          *  @param aValue Value string
       
   276          */
       
   277         void CheckValidOrientL( const TDesC8& aValue );
       
   278 
       
   279         /**
       
   280          *  Checks if the value is valid language attribute as
       
   281          *  specified in RFC 3066
       
   282          *
       
   283          *  @param aValue Value string
       
   284          */
       
   285         void CheckValidLangStrL( const TDesC8& aValue );
       
   286 
       
   287         /**
       
   288          *  Checks if the value is valid framerate attribute
       
   289          *
       
   290          *  @param aValue Value string
       
   291          */
       
   292         void CheckValidFrameRateL( const TDesC8& aValue );
       
   293         
       
   294         /**
       
   295          *  Checks if the value is among valid uri value for control attribute
       
   296          *
       
   297          *  @param aValue Value string
       
   298          */       
       
   299         void CheckValidControlL( const TDesC8& aValue );
       
   300 
       
   301         /**
       
   302          *  Checks if the value is valid value for group attribute as
       
   303          *  specified in RFC 3388
       
   304          *
       
   305          *  @param aValue Value string
       
   306          */       
       
   307         void CheckValidGroupL( const TDesC8& aValue );
       
   308 
       
   309         /**
       
   310          *  Checks if the value is valid value for des attribute as
       
   311          *  specified in RFC 3312
       
   312          *
       
   313          *  @param aValue Value string
       
   314          */       
       
   315         void CheckValidDesL( const TDesC8& aValue );
       
   316 
       
   317         /**
       
   318          *  Checks if the value is valid value for curr and conf attribute as
       
   319          *  specified in RFC 3312
       
   320          *
       
   321          *  @param aValue Value string
       
   322          */       
       
   323         void CheckValidCurrAndConfL( const TDesC8& aValue );
       
   324 
       
   325         /**
       
   326          *  Checks if value is included in the list of predefined values
       
   327          *
       
   328          *  @param aItemsCount Predefined values count
       
   329          *  @param aValuesList List of predefined values
       
   330          *  @param aValue Value string
       
   331          */       
       
   332         void ValidValueInListL( TInt aItemsCount, 
       
   333                                 const TText8* const aValuesList[], 
       
   334                                 const TDesC8& aValue );
       
   335 
       
   336         /**
       
   337          *  Checks if the value is valid value for range attribute as
       
   338          *  specified in RFC 2326
       
   339          *
       
   340          *  @param aValue Value string
       
   341          */       
       
   342         void CheckValidRangeL( const TDesC8& aValue );
       
   343 
       
   344 
       
   345         /**
       
   346          *  Checks if the value is valid rtpmap string
       
   347          *
       
   348          *  @param aValue Value string
       
   349          */   
       
   350         void CheckValidRtpmapL( const TDesC8& aValue );
       
   351 
       
   352         /**
       
   353          *  Checks if the value is valid fmtp string
       
   354          *
       
   355          *  @param aValue Value string
       
   356          */   
       
   357         void CheckValidFmtpL( const TDesC8& aValue );
       
   358         
       
   359         /**
       
   360          *  Set attribute and values. Attribute is not one of predefined ones.
       
   361          *
       
   362          *  @param aAttribute Attribute string (in cleanup stack)
       
   363          *  @param aValue Value string
       
   364          */   
       
   365         void SetNotPredefinedAttributeL( const TDesC8& aAttribute, 
       
   366                                          const TDesC8& aValue );
       
   367         
       
   368         void CreateAttributeFieldPtrsL();
       
   369         
       
   370         inline CSdpAttributeFieldPtrs& AttributeFieldPtrs();      
       
   371         
       
   372         inline const CSdpAttributeFieldPtrs& AttributeFieldPtrs() const;
       
   373 	   
       
   374 		void __DbgTestInvariant() const;
       
   375 
       
   376 
       
   377     private:    // Data
       
   378 
       
   379         // String pool
       
   380         RStringPool iPool;
       
   381 
       
   382         // Attribute name
       
   383         RStringF iAttribute;
       
   384 
       
   385         // Flag indicating if the attribute is a property attribute
       
   386         TBool iPropertyAttribute;
       
   387 
       
   388         // Value field
       
   389         HBufC8* iValue;
       
   390 	};
       
   391 
       
   392 #endif // CSDPATTRIBUTEFIELD_H