epoc32/include/mw/sdpkeyfield.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.
     1 /*
     2 * Copyright (c) 2003-2009 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          : SdpKeyField.h
    16 * Part of       : SDP Codec
    17 * Interface     : SDK API, SDP Codec API
    18 * Version       : 1.0
    19 *
    20 */
    21 
    22 
    23 
    24 #ifndef CSDPKEYFIELD_H
    25 #define CSDPKEYFIELD_H
    26 
    27 //  INCLUDES
    28 #include <e32base.h>
    29 #include <stringpool.h>
    30 
    31 // FORWARD DECLARATIONS
    32 class RReadStream;
    33 class RWriteStream;
    34 
    35 // CLASS DECLARATION
    36 /**
    37  *  @publishedAll
    38  *  @released
    39  *
    40  *	This class encapsulates the encryption key field of 
    41  *  the Session Description Protocol.
    42  * 
    43  *	The normative reference for correct formatting and values is
    44  *	draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
    45  *  member documentation. The implementation supports this normative
    46  *  reference, but does not enforce it fully. 
    47  *
    48  *  @lib sdpcodec.lib
    49  */
    50 class CSdpKeyField : public CBase
    51 	{
    52     public: // Constructors and destructor
    53         /**
    54          *	Constructs a new encryption key field.
    55 		 *	
    56          *	@param aFieldValue A string containing a correctly 
    57          *         formatted field value terminated by a CRLF.
    58          *	@return a new instance.
    59          */
    60 		IMPORT_C static CSdpKeyField* DecodeL(const TDesC8& aFieldValue);
    61 
    62         /**
    63          *	Constructs a new encryption key field and adds the pointer to 
    64          *  the cleanup stack.
    65 		 *	
    66          *	@param aFieldValue A string containing a correctly 
    67          *              formatted field value terminated by a CRLF.
    68          *	@return a new instance.
    69          *  @leave  In error case function leaves.
    70          */
    71 		IMPORT_C static CSdpKeyField* DecodeLC(const TDesC8& aFieldValue);
    72 
    73         /**
    74          *	Constructs a new encryption key field.
    75 		 *	
    76          *	@param aMethod Encryption method from the pre-defined 
    77          *         SDP string table. User defined values are not accepted.
    78 		 *  @param aEncryptionKey A valid encryption key value 
    79          *         or an empty descriptor to omit the key part.
    80          *	@return a new instance.
    81          */
    82 		IMPORT_C static CSdpKeyField* NewL(RStringF aMethod,
    83 											const TDesC8& aEncryptionKey);
    84 
    85         /**
    86          *	Constructs a new encryption key field and adds the pointer to 
    87          *  the cleanup stack.
    88 		 *	
    89          *	@param aMethod Encryption method from the pre-defined 
    90          *         SDP string table. User defined values are not accepted.
    91 		 *  @param aEncryptionKey A valid encryption key value 
    92          *         or an empty descriptor to omit the key part.
    93          *	@return a new instance.
    94          */
    95 		IMPORT_C static CSdpKeyField* NewLC(RStringF aMethod,
    96 											const TDesC8& aEncryptionKey);
    97 
    98 		/**
    99 		 *	Deletes the resources held by the instance.
   100 		 */
   101 		IMPORT_C ~CSdpKeyField();
   102 
   103     public: // New functions
   104 		/**
   105 		 *	Writes the instance as a complete SDP field encoded as UTF-8
   106 		 *	and formatted as defined in draft-ietf-mmusic-sdp-new-14.
   107          *
   108 		 *	@param aStream Stream used for output. On return 
   109          *         the stream includes correctly formatted key field.
   110 		 */
   111 		IMPORT_C void EncodeL(RWriteStream& aStream) const;
   112 
   113 		/**
   114 		 *	Creates a new instance that is equal to the target.
   115 		 *
   116 		 *	@return a new instance.
   117 		 */
   118 		IMPORT_C CSdpKeyField * CloneL() const;
   119 
   120 		/**	
   121 		 *	Compares this instance to another for equality.
   122 		 *
   123 		 *	@param aObj The instance to compare to.
   124 		 *	@return ETrue if equal, EFalse if not.
   125 		 */
   126 		IMPORT_C TBool operator == (const CSdpKeyField& aObj) const;
   127 
   128 		/**
   129 		 *	Gets the encryption method.
   130 		 *
   131 		 *	@return The method.
   132 		 */
   133 		IMPORT_C RStringF Method() const;
   134 
   135 		/**
   136 		 *	Gets the encryption key.
   137 		 *
   138 		 *	@return The key or an empty descriptor if there is no key part.
   139 		 */
   140 		IMPORT_C const TDesC8& EncryptionKey() const;
   141 
   142 		/**
   143 		 *	Sets the encryption method and key.
   144 		 *
   145          *	@param aMethod Encryption method from the pre-defined 
   146          *         SDP string table. User defined values are not accepted.
   147 		 *  @param aEncryptionKey A valid encryption key value 
   148          *         or an empty descriptor to omit the key part.
   149 		 */
   150 		IMPORT_C void SetL(RStringF aMethod,
   151 						   const TDesC8& aEncryptionKey);
   152 
   153     public:
   154     	/**
   155          *  Externalizes the object to stream
   156          *
   157          *  @param aStream Stream where the object's state will be stored
   158          */
   159 		void ExternalizeL(RWriteStream& aStream) const;
   160 		
   161 		/**
   162          *  Creates object from the stream data
   163          *
   164          *  @param aStream Stream where the object's state will be read        
   165          *  @return Initialized object
   166          */
   167 		static CSdpKeyField* InternalizeL(RReadStream& aStream);
   168 
   169 	private:
   170 		CSdpKeyField();
   171 		void ConstructL(const TDesC8& aText);
   172 		void ConstructL(RStringF aMethod, const TDesC8& aEncryptionKey);
   173         void DoInternalizeL(RReadStream& aStream);
   174         void SetMethodAndKeyL(RStringF aMethod, 
   175                               const TDesC8& aEncryptionKey,
   176                               TBool aAllowEmptyKeyValue);
   177         void SetMethodClearAndKeyL(RStringF aMethod, const TDesC8& aEncryptionKey);
   178         void SetMethodBase64AndKeyL(RStringF aMethod, const TDesC8& aText);
   179         void SetMethodUriAndKeyL(RStringF aMethod, const TDesC8& aText);
   180         void SetMethodPromptL(RStringF aMethod, const TDesC8& aText);
   181         RArray<TPtrC8> GetElementsFromLineL( TLex8& aLexer);
   182 
   183     private: // Data
   184 		RStringF iMethod;
   185         TBool iMethodOpen;
   186 		HBufC8* iEncryptionKey;
   187         RStringPool iStringPool;
   188 
   189 		void __DbgTestInvariant() const;
   190 	
   191 	};
   192 
   193 #endif // CSDPKEYFIELD_H