|
1 /* |
|
2 * Copyright (c) 2002-2006 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 "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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Header declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 #ifndef M_SEN_CONTEXT_H |
|
26 #define M_SEN_CONTEXT_H |
|
27 |
|
28 |
|
29 // INCLUDES |
|
30 #include <e32std.h> |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CSenElement; |
|
34 class CSenXmlReader; |
|
35 |
|
36 // CONSTANTS |
|
37 namespace SenContext |
|
38 { |
|
39 // COMMON CONTEXT KEYS |
|
40 _LIT8(KSenCtxKeyCoreServiceManager, "urn:com.nokia.serene:core:service-manager"); |
|
41 _LIT8(KSenCtxKeySessionInitializer, "urn:com.nokia.serene:framework:session-initializer"); |
|
42 _LIT8(KSenCtxKeyServiceSession, "urn:com.nokia.serene:framework:service-session"); |
|
43 _LIT8(KSenCtxKeyTransportProperties, "urn:com.nokia.serene:framework:transport-properties"); |
|
44 |
|
45 _LIT8(KSenCtxKeyMessage, "urn:com.nokia.serene:framework:message"); |
|
46 _LIT8(KSenCtxKeyChunk, "urn:com.nokia.serene:framework:chunk"); |
|
47 _LIT8(KSenCtxKeyMessageProperties, "urn:com.nokia.serene:framework:message:properties"); |
|
48 // _LIT8(KSenCtxKeyXmlParser, "urn:com.nokia.serene:framework:xml-parser"); |
|
49 |
|
50 |
|
51 // DEPRECATED KEYS, |
|
52 _LIT8(KSenCtxKeyCurrentSoapMessage, "urn:com.nokia.serene:framework:current-soap-msg"); |
|
53 _LIT8(KSenCtxKeyCurrentMessageAsDesc,"urn:com.nokia.serene:framework:current-msg-desc"); |
|
54 |
|
55 |
|
56 enum TContextType |
|
57 { |
|
58 EContextBase = 0, |
|
59 EHandlerContext, |
|
60 ESessionContext, |
|
61 EMessageContext, |
|
62 ETransportContext |
|
63 }; |
|
64 |
|
65 enum TContextDirection |
|
66 { |
|
67 EOutgoing = 1, |
|
68 EIncoming, |
|
69 EBoth |
|
70 }; |
|
71 } |
|
72 |
|
73 |
|
74 // CLASS DECLARATION |
|
75 /** |
|
76 * This is the abstract super class for all WSF context classes, providing |
|
77 * convenience methods for basic, excessively used data types, and some |
|
78 * foundation methods for general context properties, like context type and |
|
79 * direction. |
|
80 * |
|
81 */ |
|
82 class MSenContext |
|
83 { |
|
84 public: |
|
85 |
|
86 // New functions |
|
87 |
|
88 /** |
|
89 * Method is used to resolve concrete type (class) |
|
90 * for this context. |
|
91 * |
|
92 * @return the class type of this handler |
|
93 */ |
|
94 virtual SenContext::TContextType Type() const = 0; |
|
95 |
|
96 /** |
|
97 * Indicates the direction this context is serving. |
|
98 * |
|
99 * @return enum, which tells where this handler will |
|
100 * be applied - outgoing, incoming, or on both directions. |
|
101 */ |
|
102 virtual SenContext::TContextDirection Direction() const = 0; |
|
103 |
|
104 /** |
|
105 * Adds new const TDesC8& type value into context, identified by given key. |
|
106 * |
|
107 * @param aKey identifies new value |
|
108 * @param aValue is the value being added. |
|
109 * |
|
110 * @return KErrNone on success, |
|
111 * KErrAlreadyExists, if the key is reserved, |
|
112 * or some other system-wide error code. |
|
113 */ |
|
114 virtual TInt Add(const TDesC8& aKey, const TDesC8& aValue) = 0; |
|
115 |
|
116 /** |
|
117 * Updates new const TDesC8& type value into context, identified by given key. |
|
118 * If some value for the same key already exists, it is destroyed and replaced |
|
119 * by the new value. If key does not already exist, a new one will be added. |
|
120 * |
|
121 * @param aKey identifies new value |
|
122 * @param aValue is the updated value, which may replace |
|
123 * any existing value, which used same key. |
|
124 * Ownership is transferred to this context. |
|
125 * |
|
126 * @return KErrNone on success, |
|
127 * or some other system-wide error code. |
|
128 */ |
|
129 virtual TInt Update(const TDesC8& aKey, const TDesC8& aValue) = 0; |
|
130 |
|
131 /** |
|
132 * Method returns TDesC8* type value. |
|
133 * |
|
134 * @param aKey identifies descriptor object |
|
135 * |
|
136 * @return value behind given key, or NULL, if |
|
137 * not found. |
|
138 * Ownership is not transferred, but remains |
|
139 * to be held by this context. |
|
140 * NOTE: Method leaves with KErrSenTypeMismatch error code, |
|
141 * if value behind this key of UCS8 descriptor type. |
|
142 */ |
|
143 virtual const TDesC8* GetDesC8L(const TDesC8& aKey) = 0; |
|
144 |
|
145 /** |
|
146 * Adds new TInt type value into context, identified by given key. |
|
147 * |
|
148 * @param aKey identifies new value |
|
149 * @param aValue is the value being added. |
|
150 * @return KErrNone on success, |
|
151 * KErrAlreadyExists, if the key is reserved, |
|
152 * or some other system-wide error code. |
|
153 */ |
|
154 virtual TInt Add(const TDesC8& aKey, TInt aValue) = 0; |
|
155 |
|
156 /** |
|
157 * Updates new TInt type value into context, identified by given key. |
|
158 * If some value for the same key already exists, it is destroyed and |
|
159 * replaced by the new value. |
|
160 * |
|
161 * @param aKey identifies new value |
|
162 * @param aValue is the updated value, which may replace |
|
163 * any existing value, which used same key. |
|
164 * |
|
165 * @return KErrNone on success, |
|
166 * or some other system-wide error code. |
|
167 */ |
|
168 virtual TInt Update(const TDesC8& aKey, TInt aValue) = 0; |
|
169 |
|
170 /** |
|
171 * Method returns TInt* type value. |
|
172 * |
|
173 * @param aKey identifies integer object |
|
174 * |
|
175 * @return value behind given key, or NULL, if |
|
176 * not found. |
|
177 * Ownership is not transferred, but remains |
|
178 * to be held by this context. |
|
179 * Method leaves with KErrSenTypeMismatch error code, |
|
180 * if value behind this descriptor is not TInt* type. |
|
181 */ |
|
182 virtual const TInt* GetIntL(const TDesC8& aKey) = 0; |
|
183 |
|
184 /** |
|
185 * Adds new CSenElement* type value into context, identified by given key. |
|
186 * |
|
187 * @param aKey identifies new value |
|
188 * @param aValue is the value being added. Ownership is transferred |
|
189 * to this context. |
|
190 * |
|
191 * @return KErrNone on success, |
|
192 * KErrAlreadyExists, if the key is reserved, |
|
193 * or some other system-wide error code. |
|
194 */ |
|
195 virtual TInt Add(const TDesC8& aKey, CSenElement* aValue) = 0; |
|
196 |
|
197 /** |
|
198 * Updates new CSenElement* type value into context, identified by given key. |
|
199 * If some value for the same key already exists, it is destroyed and replaced |
|
200 * by the new value. |
|
201 * |
|
202 * @param aKey identifies new value |
|
203 * @param aValue is the updated value, which may replace |
|
204 * any existing value, which used same key. |
|
205 * Ownership is transferred to this context. |
|
206 * |
|
207 * @return KErrNone on success, |
|
208 * or some other system-wide error code. |
|
209 */ |
|
210 virtual TInt Update(const TDesC8& aKey, CSenElement* aValue) = 0; |
|
211 |
|
212 /** |
|
213 * Method returns CSenElement* type value. |
|
214 * |
|
215 * @param aKey identifies the XML element object |
|
216 * |
|
217 * @return value behind given key, or NULL, if |
|
218 * not found. |
|
219 * Ownership is not transferred, but remains |
|
220 * to be held by this context. |
|
221 * Method leaves with KErrSenTypeMismatch error code, |
|
222 * if value behind this descriptor is not CSenElement* type. |
|
223 */ |
|
224 virtual const CSenElement* GetSenElementL(const TDesC8& aKey) = 0; |
|
225 |
|
226 /** |
|
227 * Adds new TAny* type value into context, identified by given key. |
|
228 * |
|
229 * @param aKey identifies new value |
|
230 * @param aValue is the value being added. Ownership is NOT transferred |
|
231 * to this context. |
|
232 * |
|
233 * @return KErrNone on success, |
|
234 * KErrAlreadyExists, if the key is reserved, |
|
235 * or some other system-wide error code. |
|
236 */ |
|
237 virtual TInt Add(const TDesC8& aKey, TAny* aValue) = 0; |
|
238 |
|
239 /** |
|
240 * Updates new TAny* type value into context, identified by given key. |
|
241 * If some value for the same key already exists, it is replaced with |
|
242 * the new value. |
|
243 * |
|
244 * @param aKey identifies new value |
|
245 * @param aValue is the updated value, which may replace |
|
246 * any existing value, which used same key. |
|
247 * Ownership is NOT transferred this context. |
|
248 * |
|
249 * @return KErrNone on success, |
|
250 * or some other system-wide error code. |
|
251 */ |
|
252 virtual TInt Update(const TDesC8& aKey, TAny* aValue) = 0; |
|
253 |
|
254 /** |
|
255 * Method returns TAny* type value. |
|
256 * |
|
257 * @param aKey identifying the requested value |
|
258 * |
|
259 * @return value behind given key, or NULL, if |
|
260 * not found. |
|
261 * Ownership can NOT be transferred, since it was NEVER |
|
262 * held by this context. |
|
263 * Caller is supposed to know the type (class) of returned |
|
264 * value from the pre-defined binding to certain key. |
|
265 */ |
|
266 virtual TAny* GetAnyL(const TDesC8& aKey) = 0; //codescannerwarnings |
|
267 |
|
268 // virtual TInt AddParser(CSenXmlReader* aValue) = 0; // protected context |
|
269 // virtual TInt UpdateParser(CSenXmlReader* aValue) = 0; // protected context |
|
270 /** |
|
271 * Method returns XML parser (CSenXmlReader*) |
|
272 * |
|
273 * @return pointer to parser or NULL, if not |
|
274 * found. |
|
275 * Ownership of returned pointer is NOT transferred. |
|
276 * Method leaves with KErrSenTypeMismatch error code, |
|
277 * if value behind this descriptor is not CSenXmlReader* type. |
|
278 */ |
|
279 virtual const CSenXmlReader* GetParser() = 0; |
|
280 |
|
281 /** |
|
282 * Removes value from the context, possibly destroying the |
|
283 * value, too - if it is owned by this context. |
|
284 * |
|
285 * @param aKey used to identify value which needs to be removed |
|
286 * |
|
287 * @return the index of removed key-value pair, or |
|
288 * KErrNotFound, if such key was not found |
|
289 */ |
|
290 virtual TInt Remove(const TDesC8& aKey) = 0; |
|
291 |
|
292 /** |
|
293 * Methods tells the count of context items (key-value pairs). |
|
294 * |
|
295 * @return count of current items in this context. |
|
296 */ |
|
297 virtual TInt Count() const = 0; |
|
298 |
|
299 /** |
|
300 * Resolves key at certain index, if it is |
|
301 * not out of bounds of the current context. |
|
302 * |
|
303 * @return the key at certain index. |
|
304 * Method can be used to interate through |
|
305 * context values. |
|
306 * If index is out of bounds, method leaves |
|
307 * with either KErrUnderflow (negative index), |
|
308 * or KErrOverflow(index>count-1) |
|
309 */ |
|
310 virtual TPtrC8 KeyAtL(TInt aIndex) = 0; |
|
311 |
|
312 /** |
|
313 * Method clears (possibly destroys) the current contents |
|
314 * of this context, making it possible to re-use this instance. |
|
315 */ |
|
316 virtual void Reset() = 0; |
|
317 |
|
318 |
|
319 |
|
320 /** |
|
321 * Sets the direction (inbound or outbound for this context). |
|
322 * @return KErrNone or error code (KErrNotSupported is expected, |
|
323 * if method is not implemented). |
|
324 */ |
|
325 virtual TInt SetDirection( SenContext::TContextDirection aDirection ) = 0; |
|
326 |
|
327 |
|
328 }; |
|
329 |
|
330 #endif // M_SEN_CONTEXT_H |
|
331 |
|
332 // End of File |