williamr@2: /* williamr@2: * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * 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: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * Name : SdpKeyField.h williamr@2: * Part of : SDP Codec williamr@2: * Interface : SDK API, SDP Codec API williamr@2: * Version : 1.0 williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: #ifndef CSDPKEYFIELD_H williamr@2: #define CSDPKEYFIELD_H williamr@2: williamr@2: // INCLUDES williamr@2: #include williamr@2: #include williamr@2: #include "_sdpdefs.h" williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: class RReadStream; williamr@2: class RWriteStream; williamr@2: williamr@2: // CLASS DECLARATION williamr@2: /** williamr@2: * @publishedAll williamr@2: * @released williamr@2: * williamr@2: * This class encapsulates the encryption key field of williamr@2: * the Session Description Protocol. williamr@2: * williamr@2: * The normative reference for correct formatting and values is williamr@2: * draft-ietf-mmusic-sdp-new-14 unless specified otherwise in williamr@2: * member documentation. The implementation supports this normative williamr@2: * reference, but does not enforce it fully. williamr@2: * williamr@2: * @lib sdpcodec.lib williamr@2: */ williamr@2: class CSdpKeyField : public CBase williamr@2: { williamr@2: public: // Constructors and destructor williamr@2: /** williamr@2: * Constructs a new encryption key field. williamr@2: * williamr@2: * @param aFieldValue A string containing a correctly williamr@2: * formatted field value terminated by a CRLF. williamr@2: * @return a new instance. williamr@2: */ williamr@2: IMPORT_C static CSdpKeyField* DecodeL(const TDesC8& aFieldValue); williamr@2: williamr@2: /** williamr@2: * Constructs a new encryption key field and adds the pointer to williamr@2: * the cleanup stack. williamr@2: * williamr@2: * @param aFieldValue A string containing a correctly williamr@2: * formatted field value terminated by a CRLF. williamr@2: * @return a new instance. williamr@2: * @leave In error case function leaves. williamr@2: */ williamr@2: IMPORT_C static CSdpKeyField* DecodeLC(const TDesC8& aFieldValue); williamr@2: williamr@2: /** williamr@2: * Constructs a new encryption key field. williamr@2: * williamr@2: * @param aMethod Encryption method from the pre-defined williamr@2: * SDP string table. User defined values are not accepted. williamr@2: * @param aEncryptionKey A valid encryption key value williamr@2: * or an empty descriptor to omit the key part. williamr@2: * @return a new instance. williamr@2: */ williamr@2: IMPORT_C static CSdpKeyField* NewL(RStringF aMethod, williamr@2: const TDesC8& aEncryptionKey); williamr@2: williamr@2: /** williamr@2: * Constructs a new encryption key field and adds the pointer to williamr@2: * the cleanup stack. williamr@2: * williamr@2: * @param aMethod Encryption method from the pre-defined williamr@2: * SDP string table. User defined values are not accepted. williamr@2: * @param aEncryptionKey A valid encryption key value williamr@2: * or an empty descriptor to omit the key part. williamr@2: * @return a new instance. williamr@2: */ williamr@2: IMPORT_C static CSdpKeyField* NewLC(RStringF aMethod, williamr@2: const TDesC8& aEncryptionKey); williamr@2: williamr@2: /** williamr@2: * Deletes the resources held by the instance. williamr@2: */ williamr@2: IMPORT_C ~CSdpKeyField(); williamr@2: williamr@2: public: // New functions williamr@2: /** williamr@2: * Writes the instance as a complete SDP field encoded as UTF-8 williamr@2: * and formatted as defined in draft-ietf-mmusic-sdp-new-14. williamr@2: * williamr@2: * @param aStream Stream used for output. On return williamr@2: * the stream includes correctly formatted key field. williamr@2: */ williamr@2: IMPORT_C void EncodeL(RWriteStream& aStream) const; williamr@2: williamr@2: /** williamr@2: * Creates a new instance that is equal to the target. williamr@2: * williamr@2: * @return a new instance. williamr@2: */ williamr@2: IMPORT_C CSdpKeyField * CloneL() const; williamr@2: williamr@2: /** williamr@2: * Compares this instance to another for equality. williamr@2: * williamr@2: * @param aObj The instance to compare to. williamr@2: * @return ETrue if equal, EFalse if not. williamr@2: */ williamr@2: IMPORT_C TBool operator == (const CSdpKeyField& aObj) const; williamr@2: williamr@2: /** williamr@2: * Gets the encryption method. williamr@2: * williamr@2: * @return The method. williamr@2: */ williamr@2: IMPORT_C RStringF Method() const; williamr@2: williamr@2: /** williamr@2: * Gets the encryption key. williamr@2: * williamr@2: * @return The key or an empty descriptor if there is no key part. williamr@2: */ williamr@2: IMPORT_C const TDesC8& EncryptionKey() const; williamr@2: williamr@2: /** williamr@2: * Sets the encryption method and key. williamr@2: * williamr@2: * @param aMethod Encryption method from the pre-defined williamr@2: * SDP string table. User defined values are not accepted. williamr@2: * @param aEncryptionKey A valid encryption key value williamr@2: * or an empty descriptor to omit the key part. williamr@2: */ williamr@2: IMPORT_C void SetL(RStringF aMethod, williamr@2: const TDesC8& aEncryptionKey); williamr@2: williamr@2: public: williamr@2: /** williamr@2: * Externalizes the object to stream williamr@2: * williamr@2: * @param aStream Stream where the object's state will be stored williamr@2: */ williamr@2: void ExternalizeL(RWriteStream& aStream) const; williamr@2: williamr@2: /** williamr@2: * Creates object from the stream data williamr@2: * williamr@2: * @param aStream Stream where the object's state will be read williamr@2: * @return Initialized object williamr@2: */ williamr@2: static CSdpKeyField* InternalizeL(RReadStream& aStream); williamr@2: williamr@2: private: williamr@2: CSdpKeyField(); williamr@2: void ConstructL(const TDesC8& aText); williamr@2: void ConstructL(RStringF aMethod, const TDesC8& aEncryptionKey); williamr@2: void DoInternalizeL(RReadStream& aStream); williamr@2: void SetMethodAndKeyL(RStringF aMethod, williamr@2: const TDesC8& aEncryptionKey, williamr@2: TBool aAllowEmptyKeyValue); williamr@2: void SetMethodClearAndKeyL(RStringF aMethod, const TDesC8& aEncryptionKey); williamr@2: void SetMethodBase64AndKeyL(RStringF aMethod, const TDesC8& aText); williamr@2: void SetMethodUriAndKeyL(RStringF aMethod, const TDesC8& aText); williamr@2: void SetMethodPromptL(RStringF aMethod, const TDesC8& aText); williamr@2: RArray GetElementsFromLineL( TLex8& aLexer); williamr@2: williamr@2: private: // Data williamr@2: RStringF iMethod; williamr@2: TBool iMethodOpen; williamr@2: HBufC8* iEncryptionKey; williamr@2: RStringPool iStringPool; williamr@2: williamr@2: __DECLARE_TEST; williamr@2: }; williamr@2: williamr@2: #endif // CSDPKEYFIELD_H