1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/mw/sdpkeyfield.h Wed Mar 31 12:27:01 2010 +0100
1.3 @@ -0,0 +1,193 @@
1.4 +/*
1.5 +* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* 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
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* Name : SdpKeyField.h
1.19 +* Part of : SDP Codec
1.20 +* Interface : SDK API, SDP Codec API
1.21 +* Version : 1.0
1.22 +*
1.23 +*/
1.24 +
1.25 +
1.26 +
1.27 +#ifndef CSDPKEYFIELD_H
1.28 +#define CSDPKEYFIELD_H
1.29 +
1.30 +// INCLUDES
1.31 +#include <e32base.h>
1.32 +#include <stringpool.h>
1.33 +#include "_sdpdefs.h"
1.34 +
1.35 +// FORWARD DECLARATIONS
1.36 +class RReadStream;
1.37 +class RWriteStream;
1.38 +
1.39 +// CLASS DECLARATION
1.40 +/**
1.41 + * @publishedAll
1.42 + * @released
1.43 + *
1.44 + * This class encapsulates the encryption key field of
1.45 + * the Session Description Protocol.
1.46 + *
1.47 + * The normative reference for correct formatting and values is
1.48 + * draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
1.49 + * member documentation. The implementation supports this normative
1.50 + * reference, but does not enforce it fully.
1.51 + *
1.52 + * @lib sdpcodec.lib
1.53 + */
1.54 +class CSdpKeyField : public CBase
1.55 + {
1.56 + public: // Constructors and destructor
1.57 + /**
1.58 + * Constructs a new encryption key field.
1.59 + *
1.60 + * @param aFieldValue A string containing a correctly
1.61 + * formatted field value terminated by a CRLF.
1.62 + * @return a new instance.
1.63 + */
1.64 + IMPORT_C static CSdpKeyField* DecodeL(const TDesC8& aFieldValue);
1.65 +
1.66 + /**
1.67 + * Constructs a new encryption key field and adds the pointer to
1.68 + * the cleanup stack.
1.69 + *
1.70 + * @param aFieldValue A string containing a correctly
1.71 + * formatted field value terminated by a CRLF.
1.72 + * @return a new instance.
1.73 + * @leave In error case function leaves.
1.74 + */
1.75 + IMPORT_C static CSdpKeyField* DecodeLC(const TDesC8& aFieldValue);
1.76 +
1.77 + /**
1.78 + * Constructs a new encryption key field.
1.79 + *
1.80 + * @param aMethod Encryption method from the pre-defined
1.81 + * SDP string table. User defined values are not accepted.
1.82 + * @param aEncryptionKey A valid encryption key value
1.83 + * or an empty descriptor to omit the key part.
1.84 + * @return a new instance.
1.85 + */
1.86 + IMPORT_C static CSdpKeyField* NewL(RStringF aMethod,
1.87 + const TDesC8& aEncryptionKey);
1.88 +
1.89 + /**
1.90 + * Constructs a new encryption key field and adds the pointer to
1.91 + * the cleanup stack.
1.92 + *
1.93 + * @param aMethod Encryption method from the pre-defined
1.94 + * SDP string table. User defined values are not accepted.
1.95 + * @param aEncryptionKey A valid encryption key value
1.96 + * or an empty descriptor to omit the key part.
1.97 + * @return a new instance.
1.98 + */
1.99 + IMPORT_C static CSdpKeyField* NewLC(RStringF aMethod,
1.100 + const TDesC8& aEncryptionKey);
1.101 +
1.102 + /**
1.103 + * Deletes the resources held by the instance.
1.104 + */
1.105 + IMPORT_C ~CSdpKeyField();
1.106 +
1.107 + public: // New functions
1.108 + /**
1.109 + * Writes the instance as a complete SDP field encoded as UTF-8
1.110 + * and formatted as defined in draft-ietf-mmusic-sdp-new-14.
1.111 + *
1.112 + * @param aStream Stream used for output. On return
1.113 + * the stream includes correctly formatted key field.
1.114 + */
1.115 + IMPORT_C void EncodeL(RWriteStream& aStream) const;
1.116 +
1.117 + /**
1.118 + * Creates a new instance that is equal to the target.
1.119 + *
1.120 + * @return a new instance.
1.121 + */
1.122 + IMPORT_C CSdpKeyField * CloneL() const;
1.123 +
1.124 + /**
1.125 + * Compares this instance to another for equality.
1.126 + *
1.127 + * @param aObj The instance to compare to.
1.128 + * @return ETrue if equal, EFalse if not.
1.129 + */
1.130 + IMPORT_C TBool operator == (const CSdpKeyField& aObj) const;
1.131 +
1.132 + /**
1.133 + * Gets the encryption method.
1.134 + *
1.135 + * @return The method.
1.136 + */
1.137 + IMPORT_C RStringF Method() const;
1.138 +
1.139 + /**
1.140 + * Gets the encryption key.
1.141 + *
1.142 + * @return The key or an empty descriptor if there is no key part.
1.143 + */
1.144 + IMPORT_C const TDesC8& EncryptionKey() const;
1.145 +
1.146 + /**
1.147 + * Sets the encryption method and key.
1.148 + *
1.149 + * @param aMethod Encryption method from the pre-defined
1.150 + * SDP string table. User defined values are not accepted.
1.151 + * @param aEncryptionKey A valid encryption key value
1.152 + * or an empty descriptor to omit the key part.
1.153 + */
1.154 + IMPORT_C void SetL(RStringF aMethod,
1.155 + const TDesC8& aEncryptionKey);
1.156 +
1.157 + public:
1.158 + /**
1.159 + * Externalizes the object to stream
1.160 + *
1.161 + * @param aStream Stream where the object's state will be stored
1.162 + */
1.163 + void ExternalizeL(RWriteStream& aStream) const;
1.164 +
1.165 + /**
1.166 + * Creates object from the stream data
1.167 + *
1.168 + * @param aStream Stream where the object's state will be read
1.169 + * @return Initialized object
1.170 + */
1.171 + static CSdpKeyField* InternalizeL(RReadStream& aStream);
1.172 +
1.173 + private:
1.174 + CSdpKeyField();
1.175 + void ConstructL(const TDesC8& aText);
1.176 + void ConstructL(RStringF aMethod, const TDesC8& aEncryptionKey);
1.177 + void DoInternalizeL(RReadStream& aStream);
1.178 + void SetMethodAndKeyL(RStringF aMethod,
1.179 + const TDesC8& aEncryptionKey,
1.180 + TBool aAllowEmptyKeyValue);
1.181 + void SetMethodClearAndKeyL(RStringF aMethod, const TDesC8& aEncryptionKey);
1.182 + void SetMethodBase64AndKeyL(RStringF aMethod, const TDesC8& aText);
1.183 + void SetMethodUriAndKeyL(RStringF aMethod, const TDesC8& aText);
1.184 + void SetMethodPromptL(RStringF aMethod, const TDesC8& aText);
1.185 + RArray<TPtrC8> GetElementsFromLineL( TLex8& aLexer);
1.186 +
1.187 + private: // Data
1.188 + RStringF iMethod;
1.189 + TBool iMethodOpen;
1.190 + HBufC8* iEncryptionKey;
1.191 + RStringPool iStringPool;
1.192 +
1.193 + __DECLARE_TEST;
1.194 + };
1.195 +
1.196 +#endif // CSDPKEYFIELD_H