1 sdpkeyfield.h |
1 /* |
|
2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Name : SdpKeyField.h |
|
16 * Part of : SDP Codec |
|
17 * Interface : SDK API, SDP Codec API |
|
18 * Version : 1.0 |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 |
|
24 #ifndef CSDPKEYFIELD_H |
|
25 #define CSDPKEYFIELD_H |
|
26 |
|
27 // INCLUDES |
|
28 #include <e32base.h> |
|
29 #include <stringpool.h> |
|
30 #include "_sdpdefs.h" |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class RReadStream; |
|
34 class RWriteStream; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 /** |
|
38 * @publishedAll |
|
39 * @released |
|
40 * |
|
41 * This class encapsulates the encryption key field of |
|
42 * the Session Description Protocol. |
|
43 * |
|
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. |
|
48 * |
|
49 * @lib sdpcodec.lib |
|
50 */ |
|
51 class CSdpKeyField : public CBase |
|
52 { |
|
53 public: // Constructors and destructor |
|
54 /** |
|
55 * Constructs a new encryption key field. |
|
56 * |
|
57 * @param aFieldValue A string containing a correctly |
|
58 * formatted field value terminated by a CRLF. |
|
59 * @return a new instance. |
|
60 */ |
|
61 IMPORT_C static CSdpKeyField* DecodeL(const TDesC8& aFieldValue); |
|
62 |
|
63 /** |
|
64 * Constructs a new encryption key field and adds the pointer to |
|
65 * the cleanup stack. |
|
66 * |
|
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. |
|
71 */ |
|
72 IMPORT_C static CSdpKeyField* DecodeLC(const TDesC8& aFieldValue); |
|
73 |
|
74 /** |
|
75 * Constructs a new encryption key field. |
|
76 * |
|
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. |
|
82 */ |
|
83 IMPORT_C static CSdpKeyField* NewL(RStringF aMethod, |
|
84 const TDesC8& aEncryptionKey); |
|
85 |
|
86 /** |
|
87 * Constructs a new encryption key field and adds the pointer to |
|
88 * the cleanup stack. |
|
89 * |
|
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. |
|
95 */ |
|
96 IMPORT_C static CSdpKeyField* NewLC(RStringF aMethod, |
|
97 const TDesC8& aEncryptionKey); |
|
98 |
|
99 /** |
|
100 * Deletes the resources held by the instance. |
|
101 */ |
|
102 IMPORT_C ~CSdpKeyField(); |
|
103 |
|
104 public: // New functions |
|
105 /** |
|
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. |
|
108 * |
|
109 * @param aStream Stream used for output. On return |
|
110 * the stream includes correctly formatted key field. |
|
111 */ |
|
112 IMPORT_C void EncodeL(RWriteStream& aStream) const; |
|
113 |
|
114 /** |
|
115 * Creates a new instance that is equal to the target. |
|
116 * |
|
117 * @return a new instance. |
|
118 */ |
|
119 IMPORT_C CSdpKeyField * CloneL() const; |
|
120 |
|
121 /** |
|
122 * Compares this instance to another for equality. |
|
123 * |
|
124 * @param aObj The instance to compare to. |
|
125 * @return ETrue if equal, EFalse if not. |
|
126 */ |
|
127 IMPORT_C TBool operator == (const CSdpKeyField& aObj) const; |
|
128 |
|
129 /** |
|
130 * Gets the encryption method. |
|
131 * |
|
132 * @return The method. |
|
133 */ |
|
134 IMPORT_C RStringF Method() const; |
|
135 |
|
136 /** |
|
137 * Gets the encryption key. |
|
138 * |
|
139 * @return The key or an empty descriptor if there is no key part. |
|
140 */ |
|
141 IMPORT_C const TDesC8& EncryptionKey() const; |
|
142 |
|
143 /** |
|
144 * Sets the encryption method and key. |
|
145 * |
|
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. |
|
150 */ |
|
151 IMPORT_C void SetL(RStringF aMethod, |
|
152 const TDesC8& aEncryptionKey); |
|
153 |
|
154 public: |
|
155 /** |
|
156 * Externalizes the object to stream |
|
157 * |
|
158 * @param aStream Stream where the object's state will be stored |
|
159 */ |
|
160 void ExternalizeL(RWriteStream& aStream) const; |
|
161 |
|
162 /** |
|
163 * Creates object from the stream data |
|
164 * |
|
165 * @param aStream Stream where the object's state will be read |
|
166 * @return Initialized object |
|
167 */ |
|
168 static CSdpKeyField* InternalizeL(RReadStream& aStream); |
|
169 |
|
170 private: |
|
171 CSdpKeyField(); |
|
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); |
|
183 |
|
184 private: // Data |
|
185 RStringF iMethod; |
|
186 TBool iMethodOpen; |
|
187 HBufC8* iEncryptionKey; |
|
188 RStringPool iStringPool; |
|
189 |
|
190 __DECLARE_TEST; |
|
191 }; |
|
192 |
|
193 #endif // CSDPKEYFIELD_H |