2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
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
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Name : SdpKeyField.h
17 * Interface : SDK API, SDP Codec API
24 #ifndef CSDPKEYFIELD_H
25 #define CSDPKEYFIELD_H
29 #include <stringpool.h>
32 // FORWARD DECLARATIONS
41 * This class encapsulates the encryption key field of
42 * the Session Description Protocol.
44 * The normative reference for correct formatting and values is
45 * draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
46 * member documentation. The implementation supports this normative
47 * reference, but does not enforce it fully.
51 class CSdpKeyField : public CBase
53 public: // Constructors and destructor
55 * Constructs a new encryption key field.
57 * @param aFieldValue A string containing a correctly
58 * formatted field value terminated by a CRLF.
59 * @return a new instance.
61 IMPORT_C static CSdpKeyField* DecodeL(const TDesC8& aFieldValue);
64 * Constructs a new encryption key field and adds the pointer to
67 * @param aFieldValue A string containing a correctly
68 * formatted field value terminated by a CRLF.
69 * @return a new instance.
70 * @leave In error case function leaves.
72 IMPORT_C static CSdpKeyField* DecodeLC(const TDesC8& aFieldValue);
75 * Constructs a new encryption key field.
77 * @param aMethod Encryption method from the pre-defined
78 * SDP string table. User defined values are not accepted.
79 * @param aEncryptionKey A valid encryption key value
80 * or an empty descriptor to omit the key part.
81 * @return a new instance.
83 IMPORT_C static CSdpKeyField* NewL(RStringF aMethod,
84 const TDesC8& aEncryptionKey);
87 * Constructs a new encryption key field and adds the pointer to
90 * @param aMethod Encryption method from the pre-defined
91 * SDP string table. User defined values are not accepted.
92 * @param aEncryptionKey A valid encryption key value
93 * or an empty descriptor to omit the key part.
94 * @return a new instance.
96 IMPORT_C static CSdpKeyField* NewLC(RStringF aMethod,
97 const TDesC8& aEncryptionKey);
100 * Deletes the resources held by the instance.
102 IMPORT_C ~CSdpKeyField();
104 public: // New functions
106 * Writes the instance as a complete SDP field encoded as UTF-8
107 * and formatted as defined in draft-ietf-mmusic-sdp-new-14.
109 * @param aStream Stream used for output. On return
110 * the stream includes correctly formatted key field.
112 IMPORT_C void EncodeL(RWriteStream& aStream) const;
115 * Creates a new instance that is equal to the target.
117 * @return a new instance.
119 IMPORT_C CSdpKeyField * CloneL() const;
122 * Compares this instance to another for equality.
124 * @param aObj The instance to compare to.
125 * @return ETrue if equal, EFalse if not.
127 IMPORT_C TBool operator == (const CSdpKeyField& aObj) const;
130 * Gets the encryption method.
132 * @return The method.
134 IMPORT_C RStringF Method() const;
137 * Gets the encryption key.
139 * @return The key or an empty descriptor if there is no key part.
141 IMPORT_C const TDesC8& EncryptionKey() const;
144 * Sets the encryption method and key.
146 * @param aMethod Encryption method from the pre-defined
147 * SDP string table. User defined values are not accepted.
148 * @param aEncryptionKey A valid encryption key value
149 * or an empty descriptor to omit the key part.
151 IMPORT_C void SetL(RStringF aMethod,
152 const TDesC8& aEncryptionKey);
156 * Externalizes the object to stream
158 * @param aStream Stream where the object's state will be stored
160 void ExternalizeL(RWriteStream& aStream) const;
163 * Creates object from the stream data
165 * @param aStream Stream where the object's state will be read
166 * @return Initialized object
168 static CSdpKeyField* InternalizeL(RReadStream& aStream);
172 void ConstructL(const TDesC8& aText);
173 void ConstructL(RStringF aMethod, const TDesC8& aEncryptionKey);
174 void DoInternalizeL(RReadStream& aStream);
175 void SetMethodAndKeyL(RStringF aMethod,
176 const TDesC8& aEncryptionKey,
177 TBool aAllowEmptyKeyValue);
178 void SetMethodClearAndKeyL(RStringF aMethod, const TDesC8& aEncryptionKey);
179 void SetMethodBase64AndKeyL(RStringF aMethod, const TDesC8& aText);
180 void SetMethodUriAndKeyL(RStringF aMethod, const TDesC8& aText);
181 void SetMethodPromptL(RStringF aMethod, const TDesC8& aText);
182 RArray<TPtrC8> GetElementsFromLineL( TLex8& aLexer);
187 HBufC8* iEncryptionKey;
188 RStringPool iStringPool;
193 #endif // CSDPKEYFIELD_H