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 "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".
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>
31 // FORWARD DECLARATIONS
40 * This class encapsulates the encryption key field of
41 * the Session Description Protocol.
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.
50 class CSdpKeyField : public CBase
52 public: // Constructors and destructor
54 * Constructs a new encryption key field.
56 * @param aFieldValue A string containing a correctly
57 * formatted field value terminated by a CRLF.
58 * @return a new instance.
60 IMPORT_C static CSdpKeyField* DecodeL(const TDesC8& aFieldValue);
63 * Constructs a new encryption key field and adds the pointer to
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.
71 IMPORT_C static CSdpKeyField* DecodeLC(const TDesC8& aFieldValue);
74 * Constructs a new encryption key field.
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.
82 IMPORT_C static CSdpKeyField* NewL(RStringF aMethod,
83 const TDesC8& aEncryptionKey);
86 * Constructs a new encryption key field and adds the pointer to
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.
95 IMPORT_C static CSdpKeyField* NewLC(RStringF aMethod,
96 const TDesC8& aEncryptionKey);
99 * Deletes the resources held by the instance.
101 IMPORT_C ~CSdpKeyField();
103 public: // New functions
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.
108 * @param aStream Stream used for output. On return
109 * the stream includes correctly formatted key field.
111 IMPORT_C void EncodeL(RWriteStream& aStream) const;
114 * Creates a new instance that is equal to the target.
116 * @return a new instance.
118 IMPORT_C CSdpKeyField * CloneL() const;
121 * Compares this instance to another for equality.
123 * @param aObj The instance to compare to.
124 * @return ETrue if equal, EFalse if not.
126 IMPORT_C TBool operator == (const CSdpKeyField& aObj) const;
129 * Gets the encryption method.
131 * @return The method.
133 IMPORT_C RStringF Method() const;
136 * Gets the encryption key.
138 * @return The key or an empty descriptor if there is no key part.
140 IMPORT_C const TDesC8& EncryptionKey() const;
143 * Sets the encryption method and key.
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.
150 IMPORT_C void SetL(RStringF aMethod,
151 const TDesC8& aEncryptionKey);
155 * Externalizes the object to stream
157 * @param aStream Stream where the object's state will be stored
159 void ExternalizeL(RWriteStream& aStream) const;
162 * Creates object from the stream data
164 * @param aStream Stream where the object's state will be read
165 * @return Initialized object
167 static CSdpKeyField* InternalizeL(RReadStream& aStream);
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);
186 HBufC8* iEncryptionKey;
187 RStringPool iStringPool;
189 void __DbgTestInvariant() const;
193 #endif // CSDPKEYFIELD_H