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