|
1 /* |
|
2 * Copyright (c) 2005 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: DM Tree module |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __NSMLDMMODULE_H |
|
20 #define __NSMLDMMODULE_H |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <e32base.h> |
|
24 |
|
25 class MNSmlDmModuleCallBack; |
|
26 class CNSmlDmDDF; |
|
27 class CNSmlDmCommandBuffer; |
|
28 |
|
29 |
|
30 |
|
31 enum TNSmlDmProperty |
|
32 { |
|
33 EPropACL = 0, |
|
34 EPropFormat, |
|
35 EPropName, |
|
36 EPropSize, |
|
37 EPropTitle, |
|
38 EPropTStamp, |
|
39 EPropType, |
|
40 EPropVerNo, |
|
41 EPropCaseSense |
|
42 }; |
|
43 |
|
44 |
|
45 struct CNSmlGetPropertyElement : public CBase |
|
46 { |
|
47 ~CNSmlGetPropertyElement(); |
|
48 TNSmlDmProperty iProp; |
|
49 TInt iResultsRef; |
|
50 TInt iStatusRef; |
|
51 TInt iStatusCode; |
|
52 HBufC8* iUri; |
|
53 }; |
|
54 |
|
55 |
|
56 // ---------------------------------------------------------------------------- |
|
57 // CSmlDmModule provides basic interface for DM tree operations |
|
58 // |
|
59 // @lib nsmldmmodule.dll |
|
60 // ---------------------------------------------------------------------------- |
|
61 |
|
62 |
|
63 |
|
64 // =========================================================================== |
|
65 // CSmlDmModule |
|
66 // =========================================================================== |
|
67 |
|
68 class CNSmlDmModule : public CBase |
|
69 { |
|
70 public: |
|
71 |
|
72 /** |
|
73 * Two-phased constructor. |
|
74 * @param aCallBack Callback pointer |
|
75 * @return Pointer to newly created module instance |
|
76 */ |
|
77 IMPORT_C static CNSmlDmModule* NewL( MNSmlDmModuleCallBack* aCallBack); |
|
78 |
|
79 /** |
|
80 * Destructor |
|
81 */ |
|
82 IMPORT_C ~CNSmlDmModule(); |
|
83 |
|
84 /** |
|
85 * Sets the server identifier |
|
86 * @param aServer The server id of current session |
|
87 */ |
|
88 IMPORT_C void SetServerL( const TDesC8& aServer ); |
|
89 |
|
90 /** |
|
91 * Add operation in DM protocoll |
|
92 * @param aURI Target URI in command |
|
93 * @param aObject Data |
|
94 * @param aType Mime type |
|
95 * @param aStatusRef Reference to status element |
|
96 * @param aLargeItem Indicates if object comes in multiple messages |
|
97 * or not |
|
98 */ |
|
99 IMPORT_C void AddObjectL( const TDesC8& aURI, |
|
100 const TDesC8& aObject, const TDesC8& aType, |
|
101 TInt aStatusRef, |
|
102 TBool aLargeItem=EFalse); |
|
103 |
|
104 /** |
|
105 * Replace operation in DM protocoll |
|
106 * @param aURI Target URI in command |
|
107 * @param aObject Data |
|
108 * @param aType Mime type |
|
109 * @param aStatusRef Reference to status element |
|
110 * @param aLargeItem Indicates if object comes in multiple messages |
|
111 * or not |
|
112 * @param aTotSizeOfLarge The overall size of the large object. |
|
113 * Sent with the first chunk. |
|
114 */ |
|
115 IMPORT_C void UpdateObjectL( const TDesC8& aURI, |
|
116 const TDesC8& aObject, |
|
117 const TDesC8& aType, |
|
118 TInt aStatusRef, |
|
119 TBool aLargeItem=EFalse, |
|
120 // FOTA |
|
121 TInt aTotSizeOfLarge=0 |
|
122 // FOTA end |
|
123 ); |
|
124 |
|
125 /** |
|
126 * Get operation in DM protocoll |
|
127 * @param aURI Target URI in command |
|
128 * @param aType Mime type |
|
129 * @param aResultsRef Reference to result element |
|
130 * @param aStatusRef Reference to status element |
|
131 * @param aAclPass Passes acl checking if true |
|
132 */ |
|
133 IMPORT_C void FetchObjectL( const TDesC8& aURI, |
|
134 const TDesC8& aType, |
|
135 TInt aResultsRef, |
|
136 TInt aStatusRef, |
|
137 TBool aAclPass = EFalse ); |
|
138 |
|
139 /** |
|
140 * Delete operation in DM protocoll |
|
141 * @param aURI Target URI in command |
|
142 * @param aStatusRef Reference to status element |
|
143 */ |
|
144 IMPORT_C void DeleteObjectL( const TDesC8& aURI, TInt aStatusRef ); |
|
145 |
|
146 /** |
|
147 * Execute operation in DM protocoll |
|
148 * @param aURI Target URI in command |
|
149 * @param aObject Data |
|
150 * @param aType Mime type |
|
151 * @param aStatusRef Reference to status element |
|
152 * @param aCorrelator Correlator received as an argument in |
|
153 * the exec command. |
|
154 * @param aLargeItem Indicates if object comes in multiple messages |
|
155 * or not |
|
156 */ |
|
157 IMPORT_C void ExecuteObjectL( const TDesC8& aURI, |
|
158 const TDesC8& aObject, |
|
159 const TDesC8& aType, |
|
160 TInt aStatusRef, |
|
161 // FOTA |
|
162 const TDesC8& aCorrelator, |
|
163 // FOTA end |
|
164 TBool aLargeItem=EFalse); |
|
165 |
|
166 /** |
|
167 * Copy operation in DM protocoll. |
|
168 * @param aTargetURI Target URI in command |
|
169 * @param aSourceURI Source URI in command |
|
170 * @param aType Mime type |
|
171 * @param aStatusRef Reference to status element |
|
172 * or not |
|
173 */ |
|
174 IMPORT_C void CopyObjectL( const TDesC8& aTargetURI, |
|
175 const TDesC8& aSourceURI, |
|
176 const TDesC8& aType, |
|
177 TInt aStatusRef); |
|
178 |
|
179 /** |
|
180 * Start Atomic operation |
|
181 */ |
|
182 IMPORT_C void StartTransactionL( ); |
|
183 |
|
184 /** |
|
185 * Commit Atomic operation |
|
186 */ |
|
187 IMPORT_C void CommitTransactionL(); |
|
188 |
|
189 /** |
|
190 * Rollback Atomic operation |
|
191 */ |
|
192 IMPORT_C void RollBackL( ); |
|
193 |
|
194 /** |
|
195 * Indicates message ending |
|
196 */ |
|
197 IMPORT_C void EndMessageL(); |
|
198 |
|
199 /** |
|
200 * Returns a checksum of ddf versions. Checksum changes if the ddf changes |
|
201 * @return Checksum of plugin adapter ddf versions |
|
202 */ |
|
203 IMPORT_C TInt IsDDFChangedL(); |
|
204 |
|
205 /** |
|
206 * Gets more data in case of largeobject |
|
207 * @param aData Reference to buffer where to add more data |
|
208 */ |
|
209 IMPORT_C void MoreDataL(CBufBase*& aData); |
|
210 |
|
211 |
|
212 /** |
|
213 * Replace property operation in DM protocoll |
|
214 * @param aURI Target URI in command |
|
215 * @param aObject Data |
|
216 * @param aType Mime type |
|
217 * @param aOffset Property start offset in aURI |
|
218 * @param aStatusRef Reference to status element |
|
219 */ |
|
220 void UpdatePropertyL(const TDesC8& aURI, |
|
221 const TDesC8& aObject, |
|
222 const TDesC8& aType, |
|
223 TInt aOffset, |
|
224 TInt aStatusRef); |
|
225 |
|
226 /** |
|
227 * Get property operation in DM protocoll |
|
228 * @param aURI Target URI in command |
|
229 * @param aType Mime type |
|
230 * @param aOffset Property start offset in aURI |
|
231 * @param aResultsRef Reference to result element |
|
232 * @param aStatusRef Reference to status element |
|
233 */ |
|
234 void GetPropertyL(const TDesC8& aURI, |
|
235 const TDesC8& aType, |
|
236 TInt aOffset, |
|
237 TInt aResultsRef, |
|
238 TInt aStatusRef); |
|
239 |
|
240 /** |
|
241 * Deletes te items added inside the atomic, in case that atomic fails |
|
242 * @param aURI Target URI to be deleted |
|
243 * @param aCallBack Temporary callback interface for internal |
|
244 * commands -> status not given to agent |
|
245 */ |
|
246 void DeleteInTransactionL(const TDesC8& aURI, |
|
247 MNSmlDmModuleCallBack *aCallBack); |
|
248 |
|
249 /** |
|
250 * The status is provided throug this function to caller |
|
251 * @param aStatusRef Reference to status element |
|
252 * @param aStatusCode Status code to be given |
|
253 * @param aSkipCmdBuf Indicates that status is given to agent |
|
254 * despite existance of command buffer |
|
255 */ |
|
256 void DoSetStatusL(TInt aStatusRef, |
|
257 TInt aStatusCode, |
|
258 TBool aSkipCmdBuf = EFalse); |
|
259 |
|
260 /** |
|
261 * Sets the result to caller by using callback interface |
|
262 * @param aResultsRef Reference to result element |
|
263 * @param aObject Result data to be given |
|
264 * @param aType Mime type of object |
|
265 * @param aFormat Format of object, got from ddf |
|
266 * @param aTotalSize Total size of object, in case of large |
|
267 * object, this is different from aObject |
|
268 * size |
|
269 * @param aSkipCmdBuf Indicates that status is given to agent |
|
270 * despite existance of command buffer |
|
271 */ |
|
272 void DoSetResultsL(TInt aResultsRef, |
|
273 CBufBase& aObject, |
|
274 const TDesC8& aType, |
|
275 const TDesC8& aFormat, |
|
276 TInt aTotalSize, |
|
277 TBool aSkipCmdBuf = EFalse); |
|
278 |
|
279 /** |
|
280 * Closes the connections to callback server and host servers. |
|
281 * Separate function is needed, since the disconnecting cannot |
|
282 * be made after the active scheduler of the thread is stopped. |
|
283 */ |
|
284 IMPORT_C void DisconnectFromOtherServers(); |
|
285 |
|
286 // FOTA |
|
287 /** |
|
288 * When the generic alerts are successfully sent to the remote |
|
289 * server, the FOTA adapter needs to be informed about this. |
|
290 * This command is chained through the DM engine. |
|
291 */ |
|
292 IMPORT_C void MarkGenAlertsSentL(); |
|
293 // FOTA end |
|
294 |
|
295 |
|
296 IMPORT_C void MarkGenAlertsSentL(const TDesC8& aURI); |
|
297 private: |
|
298 /** |
|
299 * Sets the real property result in case that property fetched |
|
300 * @param aIndex Index in property result buffer |
|
301 * @param aObject Result data to be given |
|
302 * @return Status code |
|
303 */ |
|
304 TInt HandlePropertyResultsL(TInt aIndex, CBufBase& aObject); |
|
305 |
|
306 /** |
|
307 * Second phase constructor. |
|
308 */ |
|
309 void ConstructL(); |
|
310 |
|
311 private: |
|
312 /** |
|
313 * Atomic operation is going on or not |
|
314 */ |
|
315 TBool iInTransaction; |
|
316 |
|
317 /** |
|
318 * Pointer to DDF |
|
319 */ |
|
320 CNSmlDmDDF *iDDF; |
|
321 |
|
322 /** |
|
323 * Pointer to module callback interface |
|
324 */ |
|
325 MNSmlDmModuleCallBack* iCallBack; |
|
326 |
|
327 /** |
|
328 * This is set true when command is internal, i.e. status not given |
|
329 * to agent |
|
330 */ |
|
331 TBool iInternalCommand; |
|
332 |
|
333 /** |
|
334 * Property result buffer, new element is created for each get to |
|
335 * prperty element |
|
336 */ |
|
337 RPointerArray<CNSmlGetPropertyElement> iPropResults; |
|
338 |
|
339 /** |
|
340 * DDF checsum |
|
341 */ |
|
342 TInt iDDFCrc; |
|
343 |
|
344 /** |
|
345 * Internal status ref |
|
346 */ |
|
347 TInt iInternalStatusRef; |
|
348 |
|
349 /** |
|
350 * Pointer to command buffer. This is created when atomic starts |
|
351 */ |
|
352 CNSmlDmCommandBuffer* iCommandBuffer; |
|
353 }; |
|
354 |
|
355 |
|
356 |
|
357 // =========================================================================== |
|
358 // MNSmlDmModuleCallBack |
|
359 // =========================================================================== |
|
360 /** |
|
361 * DmModule callback interface. Status and Result information is given through |
|
362 * this interface to caller of the module (agent) |
|
363 * |
|
364 * @since |
|
365 */ |
|
366 class MNSmlDmModuleCallBack |
|
367 { |
|
368 public: |
|
369 /** |
|
370 * Function for setting result in callback interface |
|
371 * @param aResultsRef Reference to result element |
|
372 * @param aObject Data |
|
373 * @param aType Mime type |
|
374 * @param aFormat Format of the object |
|
375 * @param aTotalSize Total size |
|
376 */ |
|
377 virtual void SetResultsL( TInt aResultsRef, |
|
378 const CBufBase& aObject, |
|
379 const TDesC8& aType, |
|
380 const TDesC8& aFormat, |
|
381 TInt aTotalSize ) = 0; |
|
382 |
|
383 /** |
|
384 * Function for setting status in callback interface |
|
385 * @param aStatusRef Reference to result element |
|
386 * @param aStatusCode Status of command |
|
387 */ |
|
388 virtual void SetStatusL( TInt aStatusRef, TInt aStatusCode ) = 0; |
|
389 }; |
|
390 |
|
391 |
|
392 #endif // __NSMLDMMODULE_H |