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