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