williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
3 |
* All rights reserved.
|
williamr@2
|
4 |
* This component and the accompanying materials are made available
|
williamr@2
|
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
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@2
|
7 |
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
|
williamr@2
|
8 |
*
|
williamr@2
|
9 |
* Initial Contributors:
|
williamr@2
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@2
|
11 |
*
|
williamr@2
|
12 |
* Contributors:
|
williamr@2
|
13 |
*
|
williamr@2
|
14 |
* Description:
|
williamr@2
|
15 |
* Name : SdpKeyField.h
|
williamr@2
|
16 |
* Part of : SDP Codec
|
williamr@2
|
17 |
* Interface : SDK API, SDP Codec API
|
williamr@2
|
18 |
* Version : 1.0
|
williamr@2
|
19 |
*
|
williamr@2
|
20 |
*/
|
williamr@2
|
21 |
|
williamr@2
|
22 |
|
williamr@2
|
23 |
|
williamr@2
|
24 |
#ifndef CSDPKEYFIELD_H
|
williamr@2
|
25 |
#define CSDPKEYFIELD_H
|
williamr@2
|
26 |
|
williamr@2
|
27 |
// INCLUDES
|
williamr@2
|
28 |
#include <e32base.h>
|
williamr@2
|
29 |
#include <stringpool.h>
|
williamr@2
|
30 |
#include "_sdpdefs.h"
|
williamr@2
|
31 |
|
williamr@2
|
32 |
// FORWARD DECLARATIONS
|
williamr@2
|
33 |
class RReadStream;
|
williamr@2
|
34 |
class RWriteStream;
|
williamr@2
|
35 |
|
williamr@2
|
36 |
// CLASS DECLARATION
|
williamr@2
|
37 |
/**
|
williamr@2
|
38 |
* @publishedAll
|
williamr@2
|
39 |
* @released
|
williamr@2
|
40 |
*
|
williamr@2
|
41 |
* This class encapsulates the encryption key field of
|
williamr@2
|
42 |
* the Session Description Protocol.
|
williamr@2
|
43 |
*
|
williamr@2
|
44 |
* The normative reference for correct formatting and values is
|
williamr@2
|
45 |
* draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
|
williamr@2
|
46 |
* member documentation. The implementation supports this normative
|
williamr@2
|
47 |
* reference, but does not enforce it fully.
|
williamr@2
|
48 |
*
|
williamr@2
|
49 |
* @lib sdpcodec.lib
|
williamr@2
|
50 |
*/
|
williamr@2
|
51 |
class CSdpKeyField : public CBase
|
williamr@2
|
52 |
{
|
williamr@2
|
53 |
public: // Constructors and destructor
|
williamr@2
|
54 |
/**
|
williamr@2
|
55 |
* Constructs a new encryption key field.
|
williamr@2
|
56 |
*
|
williamr@2
|
57 |
* @param aFieldValue A string containing a correctly
|
williamr@2
|
58 |
* formatted field value terminated by a CRLF.
|
williamr@2
|
59 |
* @return a new instance.
|
williamr@2
|
60 |
*/
|
williamr@2
|
61 |
IMPORT_C static CSdpKeyField* DecodeL(const TDesC8& aFieldValue);
|
williamr@2
|
62 |
|
williamr@2
|
63 |
/**
|
williamr@2
|
64 |
* Constructs a new encryption key field and adds the pointer to
|
williamr@2
|
65 |
* the cleanup stack.
|
williamr@2
|
66 |
*
|
williamr@2
|
67 |
* @param aFieldValue A string containing a correctly
|
williamr@2
|
68 |
* formatted field value terminated by a CRLF.
|
williamr@2
|
69 |
* @return a new instance.
|
williamr@2
|
70 |
* @leave In error case function leaves.
|
williamr@2
|
71 |
*/
|
williamr@2
|
72 |
IMPORT_C static CSdpKeyField* DecodeLC(const TDesC8& aFieldValue);
|
williamr@2
|
73 |
|
williamr@2
|
74 |
/**
|
williamr@2
|
75 |
* Constructs a new encryption key field.
|
williamr@2
|
76 |
*
|
williamr@2
|
77 |
* @param aMethod Encryption method from the pre-defined
|
williamr@2
|
78 |
* SDP string table. User defined values are not accepted.
|
williamr@2
|
79 |
* @param aEncryptionKey A valid encryption key value
|
williamr@2
|
80 |
* or an empty descriptor to omit the key part.
|
williamr@2
|
81 |
* @return a new instance.
|
williamr@2
|
82 |
*/
|
williamr@2
|
83 |
IMPORT_C static CSdpKeyField* NewL(RStringF aMethod,
|
williamr@2
|
84 |
const TDesC8& aEncryptionKey);
|
williamr@2
|
85 |
|
williamr@2
|
86 |
/**
|
williamr@2
|
87 |
* Constructs a new encryption key field and adds the pointer to
|
williamr@2
|
88 |
* the cleanup stack.
|
williamr@2
|
89 |
*
|
williamr@2
|
90 |
* @param aMethod Encryption method from the pre-defined
|
williamr@2
|
91 |
* SDP string table. User defined values are not accepted.
|
williamr@2
|
92 |
* @param aEncryptionKey A valid encryption key value
|
williamr@2
|
93 |
* or an empty descriptor to omit the key part.
|
williamr@2
|
94 |
* @return a new instance.
|
williamr@2
|
95 |
*/
|
williamr@2
|
96 |
IMPORT_C static CSdpKeyField* NewLC(RStringF aMethod,
|
williamr@2
|
97 |
const TDesC8& aEncryptionKey);
|
williamr@2
|
98 |
|
williamr@2
|
99 |
/**
|
williamr@2
|
100 |
* Deletes the resources held by the instance.
|
williamr@2
|
101 |
*/
|
williamr@2
|
102 |
IMPORT_C ~CSdpKeyField();
|
williamr@2
|
103 |
|
williamr@2
|
104 |
public: // New functions
|
williamr@2
|
105 |
/**
|
williamr@2
|
106 |
* Writes the instance as a complete SDP field encoded as UTF-8
|
williamr@2
|
107 |
* and formatted as defined in draft-ietf-mmusic-sdp-new-14.
|
williamr@2
|
108 |
*
|
williamr@2
|
109 |
* @param aStream Stream used for output. On return
|
williamr@2
|
110 |
* the stream includes correctly formatted key field.
|
williamr@2
|
111 |
*/
|
williamr@2
|
112 |
IMPORT_C void EncodeL(RWriteStream& aStream) const;
|
williamr@2
|
113 |
|
williamr@2
|
114 |
/**
|
williamr@2
|
115 |
* Creates a new instance that is equal to the target.
|
williamr@2
|
116 |
*
|
williamr@2
|
117 |
* @return a new instance.
|
williamr@2
|
118 |
*/
|
williamr@2
|
119 |
IMPORT_C CSdpKeyField * CloneL() const;
|
williamr@2
|
120 |
|
williamr@2
|
121 |
/**
|
williamr@2
|
122 |
* Compares this instance to another for equality.
|
williamr@2
|
123 |
*
|
williamr@2
|
124 |
* @param aObj The instance to compare to.
|
williamr@2
|
125 |
* @return ETrue if equal, EFalse if not.
|
williamr@2
|
126 |
*/
|
williamr@2
|
127 |
IMPORT_C TBool operator == (const CSdpKeyField& aObj) const;
|
williamr@2
|
128 |
|
williamr@2
|
129 |
/**
|
williamr@2
|
130 |
* Gets the encryption method.
|
williamr@2
|
131 |
*
|
williamr@2
|
132 |
* @return The method.
|
williamr@2
|
133 |
*/
|
williamr@2
|
134 |
IMPORT_C RStringF Method() const;
|
williamr@2
|
135 |
|
williamr@2
|
136 |
/**
|
williamr@2
|
137 |
* Gets the encryption key.
|
williamr@2
|
138 |
*
|
williamr@2
|
139 |
* @return The key or an empty descriptor if there is no key part.
|
williamr@2
|
140 |
*/
|
williamr@2
|
141 |
IMPORT_C const TDesC8& EncryptionKey() const;
|
williamr@2
|
142 |
|
williamr@2
|
143 |
/**
|
williamr@2
|
144 |
* Sets the encryption method and key.
|
williamr@2
|
145 |
*
|
williamr@2
|
146 |
* @param aMethod Encryption method from the pre-defined
|
williamr@2
|
147 |
* SDP string table. User defined values are not accepted.
|
williamr@2
|
148 |
* @param aEncryptionKey A valid encryption key value
|
williamr@2
|
149 |
* or an empty descriptor to omit the key part.
|
williamr@2
|
150 |
*/
|
williamr@2
|
151 |
IMPORT_C void SetL(RStringF aMethod,
|
williamr@2
|
152 |
const TDesC8& aEncryptionKey);
|
williamr@2
|
153 |
|
williamr@2
|
154 |
public:
|
williamr@2
|
155 |
/**
|
williamr@2
|
156 |
* Externalizes the object to stream
|
williamr@2
|
157 |
*
|
williamr@2
|
158 |
* @param aStream Stream where the object's state will be stored
|
williamr@2
|
159 |
*/
|
williamr@2
|
160 |
void ExternalizeL(RWriteStream& aStream) const;
|
williamr@2
|
161 |
|
williamr@2
|
162 |
/**
|
williamr@2
|
163 |
* Creates object from the stream data
|
williamr@2
|
164 |
*
|
williamr@2
|
165 |
* @param aStream Stream where the object's state will be read
|
williamr@2
|
166 |
* @return Initialized object
|
williamr@2
|
167 |
*/
|
williamr@2
|
168 |
static CSdpKeyField* InternalizeL(RReadStream& aStream);
|
williamr@2
|
169 |
|
williamr@2
|
170 |
private:
|
williamr@2
|
171 |
CSdpKeyField();
|
williamr@2
|
172 |
void ConstructL(const TDesC8& aText);
|
williamr@2
|
173 |
void ConstructL(RStringF aMethod, const TDesC8& aEncryptionKey);
|
williamr@2
|
174 |
void DoInternalizeL(RReadStream& aStream);
|
williamr@2
|
175 |
void SetMethodAndKeyL(RStringF aMethod,
|
williamr@2
|
176 |
const TDesC8& aEncryptionKey,
|
williamr@2
|
177 |
TBool aAllowEmptyKeyValue);
|
williamr@2
|
178 |
void SetMethodClearAndKeyL(RStringF aMethod, const TDesC8& aEncryptionKey);
|
williamr@2
|
179 |
void SetMethodBase64AndKeyL(RStringF aMethod, const TDesC8& aText);
|
williamr@2
|
180 |
void SetMethodUriAndKeyL(RStringF aMethod, const TDesC8& aText);
|
williamr@2
|
181 |
void SetMethodPromptL(RStringF aMethod, const TDesC8& aText);
|
williamr@2
|
182 |
RArray<TPtrC8> GetElementsFromLineL( TLex8& aLexer);
|
williamr@2
|
183 |
|
williamr@2
|
184 |
private: // Data
|
williamr@2
|
185 |
RStringF iMethod;
|
williamr@2
|
186 |
TBool iMethodOpen;
|
williamr@2
|
187 |
HBufC8* iEncryptionKey;
|
williamr@2
|
188 |
RStringPool iStringPool;
|
williamr@2
|
189 |
|
williamr@2
|
190 |
__DECLARE_TEST;
|
williamr@2
|
191 |
};
|
williamr@2
|
192 |
|
williamr@2
|
193 |
#endif // CSDPKEYFIELD_H
|