|
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: Handles the communication with DM Tree Module (client). |
|
15 * Transfers adapter commands to DM Plug In Adapters. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __NSMLDMHOSTSERVERSESSION_H__ |
|
21 #define __NSMLDMHOSTSERVERSESSION_H__ |
|
22 |
|
23 // ------------------------------------------------------------------------------------------------ |
|
24 // Includes |
|
25 // ------------------------------------------------------------------------------------------------ |
|
26 #include <e32base.h> |
|
27 #include <ecom.h> |
|
28 #include <smldmadapter.h> |
|
29 #include "nsmldmclientandserver.h" |
|
30 #include "nsmldmtreedtd.h" |
|
31 #include "nsmldmcmdarghandler.h" |
|
32 #include <nsmldmtreedbclient.h> |
|
33 |
|
34 // ------------------------------------------------------------------------------------------------ |
|
35 // Data fórmats |
|
36 // ------------------------------------------------------------------------------------------------ |
|
37 |
|
38 struct TNSmlDmAdapter |
|
39 { |
|
40 CSmlDmAdapter* adapterPtr; |
|
41 TUint32 adapterId; |
|
42 TBool startAtomicCalled; |
|
43 TBool commandsCalled; |
|
44 TInt streamingLimit; |
|
45 }; |
|
46 |
|
47 struct TNSmlDmCallbackRef |
|
48 { |
|
49 TNSmlDmHostCallbackType callBack; |
|
50 TInt reference; |
|
51 }; |
|
52 |
|
53 struct TNSmlDmWriteStream |
|
54 { |
|
55 RWriteStream* streamPtr; |
|
56 TUint32 adapterId; |
|
57 }; |
|
58 |
|
59 |
|
60 // ------------------------------------------------------------------------------------------------ |
|
61 // Class forwards |
|
62 // ------------------------------------------------------------------------------------------------ |
|
63 class CNSmlDMHostServer; |
|
64 |
|
65 |
|
66 /** |
|
67 * Class CNSmlDMHostSession. Handles communication with the DM TreeModule (client). |
|
68 * Transfers adapter commands to DM Plug In Adapters. |
|
69 * |
|
70 * @lib nsmldmhostserver.lib |
|
71 */ |
|
72 class CNSmlDMHostSession : public CSession2, public MSmlDmCallback |
|
73 { |
|
74 public: |
|
75 enum TNSmlDmResultAnalysis |
|
76 { |
|
77 ENSmlDmAllWillFit = 0, |
|
78 ENSmlDmSomeWillFit, |
|
79 ENSmlDmStreamed, |
|
80 ENSmlDmLargeDoesntFit |
|
81 }; |
|
82 |
|
83 /** |
|
84 * Creates a new session object. |
|
85 * @param aServer. Reference to server is needed in order to increase and decrease session counts. |
|
86 * @return CNSmlDMHostSession*. New instance of this class. |
|
87 */ |
|
88 static CNSmlDMHostSession* NewL ( CNSmlDMHostServer& aServer ); |
|
89 |
|
90 /** |
|
91 * Handles the servicing of client requests. |
|
92 * Entry point for arriving messages. |
|
93 * @param aMessage. An object which encapsulates a client request. |
|
94 */ |
|
95 void ServiceL ( const RMessage2 &aMessage ); |
|
96 |
|
97 /** |
|
98 * Extracts the operation code from the message. |
|
99 * Based on that calls the right private function. |
|
100 * @param aMessage. An object which encapsulates a client request. |
|
101 */ |
|
102 void DispatchMessageL ( const RMessage2 &aMessage ); |
|
103 |
|
104 |
|
105 /** |
|
106 * MSmlDmCallback - callback interface. |
|
107 * For returning fetch results from dm plug-in adapters. |
|
108 * @param aResultsRef. Reference to correct command. |
|
109 * @param aObject. The data which should be returned. |
|
110 * @param aType. MIME type of the object. |
|
111 */ |
|
112 void SetResultsL ( TInt aResultsRef, CBufBase& aObject, const TDesC8& aType ); |
|
113 |
|
114 /** |
|
115 * MSmlDmCallback - callback interface. |
|
116 * For returning fetch results from dm plug-in adapters (using streaming). |
|
117 * @param aResultsRef. Reference to correct command. |
|
118 * @param aStream. Large data which should be returned. |
|
119 * @param aType. MIME type of the object. |
|
120 */ |
|
121 void SetResultsL ( TInt aResultsRef, RReadStream*& aStream, const TDesC8& aType ); |
|
122 |
|
123 /** |
|
124 * MSmlDmCallback - callback interface. |
|
125 * For returning statuses for dm adapter commands. |
|
126 * @param aStatusRef. Reference to correct command. |
|
127 * @param aErrorCode. Information about the command success. |
|
128 */ |
|
129 void SetStatusL ( TInt aStatusRef, MSmlDmAdapter::TError aErrorCode ); |
|
130 |
|
131 /** |
|
132 * MSmlDmCallback - callback interface. |
|
133 * This function is called for a new management object, |
|
134 * both for node objects and for leaf objects by dm adapter. |
|
135 * @param aURI URI of the object. |
|
136 * @param aLUID Typically this is ID for the database table. |
|
137 */ |
|
138 void SetMappingL ( const TDesC8& aURI, const TDesC8& aLUID ); |
|
139 |
|
140 /** |
|
141 * MSmlDmCallback - callback interface. |
|
142 * The function is used to make a fetch to other adapters. |
|
143 * @param aURI. URI of the object. |
|
144 * @param aData. Reference to data, i.e. data is returned here |
|
145 * @param aStatus. The status of fetch command is returned here |
|
146 */ |
|
147 void FetchLinkL ( const TDesC8& aURI, CBufBase& aData, MSmlDmAdapter::TError& aStatus ); |
|
148 |
|
149 /** |
|
150 * MSmlDmCallback - callback interface. |
|
151 * The function returns the LUID which is mapped to aURI. |
|
152 * @param aURI. URI of the object. |
|
153 * @return HBufC8*. If LUID is not found, the function allocates a null length string. |
|
154 */ |
|
155 HBufC8* GetLuidAllocL ( const TDesC8& aURI ); |
|
156 |
|
157 /** |
|
158 * C++ destructor. |
|
159 */ |
|
160 ~CNSmlDMHostSession(); |
|
161 |
|
162 private: |
|
163 |
|
164 /** |
|
165 * Symbian 2nd phase constructor |
|
166 */ |
|
167 void ConstructL(); |
|
168 |
|
169 /** |
|
170 * C++ constructor. |
|
171 * @param aServer. The server instance, owner of session. |
|
172 */ |
|
173 CNSmlDMHostSession ( CNSmlDMHostServer& aServer); |
|
174 |
|
175 /** |
|
176 * Panics the client |
|
177 * @param aMessage. Message from client to panic. |
|
178 * @param aReason. Reason code. |
|
179 */ |
|
180 void PanicClient ( const RMessage2& aMessage, TInt aReason ) const; |
|
181 |
|
182 /** |
|
183 * Empty function. |
|
184 * Kept here for possible future needs. |
|
185 * Freeing of resources is done in the destructor. |
|
186 */ |
|
187 void CloseSessionL() const; |
|
188 |
|
189 |
|
190 /** |
|
191 * Gets DDF structure from the dm adapters. |
|
192 * aMessage parameter contains a list of adapters which are already loaded. |
|
193 * Writes the combined DDF structure to the chunk in the WBXML format. |
|
194 * Returns also a checksum of the DDF structure to the client. |
|
195 * @param aMessage. A list of already loaded adapters, and place for checksum. |
|
196 */ |
|
197 void GetDDFStructureL ( const RMessage2& aMessage ); |
|
198 |
|
199 /** |
|
200 * Auxiliary function called by GetDDFStructureL. |
|
201 * Reads the UIDs of the loaded adapters from the message, |
|
202 * and stores those to internal list. |
|
203 * @param aMessage. An object which encapsulates a client request. |
|
204 * @param aUids. A reference parameter, a place for extracted list of UIDs. |
|
205 */ |
|
206 void ReadUidsL ( const RMessage2& aMessage, RArray<TUint32>& aUids ) const; |
|
207 |
|
208 /** |
|
209 * Auxiliary function called by GetDDFStructureL. |
|
210 * Gets a list of all the potential dm adapters. |
|
211 * Removes from it those which are alreay loaded. |
|
212 * @param aAllAds. A reference parameter, after this function call |
|
213 * contains the acceptable adapters. |
|
214 * @param aUids. A list of adapters which are already loaded. |
|
215 */ |
|
216 void RemoveAlreadyLoadedL ( RImplInfoPtrArray& aAllAds, RArray<TUint32>& aUids ) const; |
|
217 |
|
218 /** |
|
219 * Auxiliary function called by GetDDFStructureL. |
|
220 * Asks initial information from the loaded dm adapter. |
|
221 * E.g. whether the adapter supports streaming or not. |
|
222 * @param aAdapter. A pointer to the just loaded dm plug-in adapter. |
|
223 * @param aVersions. A list of DDF versions collected from the adapters. |
|
224 * @param aUids. A list of adapter UIDs. Note that aVersions and aUids |
|
225 * are always ordered to ascending order in order to prevent |
|
226 * a checksum to change value if ECom framework gives a list |
|
227 * of potential plug-in adapters in different order. |
|
228 * @param aAdapterId. Identifier of the dm plug-in adapter. |
|
229 */ |
|
230 void AskInfoFromAdapterL ( CSmlDmAdapter* aAdapter, RPointerArray<HBufC8>& aVersions, RArray<TInt32>& aUids, TInt32 aAdapterId ); |
|
231 |
|
232 /** |
|
233 * Auxiliary function called by GetDDFStructureL. |
|
234 * Writes a combined DDF stucture to the chunk using DM Utils services. |
|
235 */ |
|
236 void WriteTreeToChunkL(); |
|
237 |
|
238 /** |
|
239 * Auxiliary function called by GetDDFStructureL. |
|
240 * Calculates a CCITT CRC checksum from the collected DDF versions and adapter UIDs |
|
241 * @param aVersions. A collected list from adapters containing versions of the DDF structure. |
|
242 * @param aUids. A list of adapter UIDs. |
|
243 * @return TUint16. Calculated checksum value. |
|
244 */ |
|
245 TUint16 CalcCheckSumL ( RPointerArray<HBufC8>& aVersions, RArray<TInt32>& aUids ) const; |
|
246 |
|
247 |
|
248 /** |
|
249 * Common function for handling UpdateLeafObject and Execute DM commands. |
|
250 * Reads parameters from the chunk. |
|
251 * Loads the requested adapter if this is a first command to it in this session. |
|
252 * Checks the need to inform adapter at atomic command situation. |
|
253 * Decides whether or not use streaming for passing data to dm plug-in adapter. |
|
254 * Informs the client (DM Tree Module) if there are unread statuses, results or mappings. |
|
255 * @param aMessage. An object which encapsulates a client request. |
|
256 * @param aCommand. Needed to choose between Update and Execute commands. |
|
257 */ |
|
258 void UpdateLeafOrExecuteL ( const RMessage2& aMessage, TNSmlDmHostOperationCodes aCommand ); |
|
259 |
|
260 /** |
|
261 * Common function for handling UpdateLeafObject and Execute DM commands for large objects. |
|
262 * Reads parameters from the chunk. |
|
263 * Loads the requested adapter if this is a first command to it in this session. |
|
264 * Checks the need to inform adapter at atomic command situation. |
|
265 * Decides whether or not use streaming for passing data to dm plug-in adapter. |
|
266 * In case this is last package of the large object, closes and commits stream, |
|
267 * provided streaming was used for passing a data. |
|
268 * Informs the client (DM Tree Module) if there are unread statuses, results or mappings. |
|
269 * @param aMessage. An object which encapsulates a client request. |
|
270 * @param aCommand. Needed to choose between Update and Execute commands. |
|
271 */ |
|
272 void UpdateLeafOrExecuteLargeL ( const RMessage2& aMessage, TNSmlDmHostOperationCodes aCommand ); |
|
273 |
|
274 /** |
|
275 * Auxiliary function of UpdateLeafOrExecuteLargeL. |
|
276 * Provided the dm plug-in adapter doesn't support streaming, this function |
|
277 * takes care of appending large object piece by piece. |
|
278 * When the last package arrives, calls the adapter and gives the built-up |
|
279 * large object as a parameter. |
|
280 * @param aMessage. An object which encapsulates a client request. |
|
281 * @param aAdIndex. Identifies the assigned adapter. |
|
282 * @param aCommand. Needed to choose between Update and Execute commands. |
|
283 */ |
|
284 void UpdateOrExecuteLargeNoStreamL ( const RMessage2& aMessage, TInt aAdIndex, TNSmlDmHostOperationCodes aCommand ); |
|
285 |
|
286 /** |
|
287 * Common function for handling Add Interior Node, Copy Node, or Delete Object DM commands. |
|
288 * Reads parameters from the chunk. |
|
289 * Loads the requested adapter if this is a first command to it in this session. |
|
290 * Checks the need to inform adapter at atomic command situation. |
|
291 * Informs the client (DM Tree Module) if there are unread statuses, results or mappings. |
|
292 * @param aMessage. An object which encapsulates a client request. |
|
293 * @param aCommand. Needed to choose between Add, Copy, and Delete commands. |
|
294 */ |
|
295 void AddCopyOrDeleteL ( const RMessage2& aMessage, TNSmlDmHostOperationCodes aCommand ); |
|
296 |
|
297 /** |
|
298 * Common function for handling Fetch Leaf Object, Get Child URI List, or Fetch Leaf Object Size |
|
299 * DM commands. |
|
300 * Reads parameters from the chunk. |
|
301 * Loads the requested adapter if this is a first command to it in this session. |
|
302 * Checks the need to inform adapter at atomic command situation. |
|
303 * Informs the client (DM Tree Module) if there are unread statuses, results or mappings. |
|
304 * @param aMessage. An object which encapsulates a client request. |
|
305 * @param aCommand. Needed to choose between Fetch, Get Child URI List, and Fetch Size commands. |
|
306 */ |
|
307 void FetchLeafChildUrisOrSizeL ( const RMessage2& aMessage, TNSmlDmHostOperationCodes aCommand ); |
|
308 |
|
309 /** |
|
310 * Called only from other DM Host Servers when they need to cross-reference AP -adapter. |
|
311 * Loads the AP dm plug in adapter (i.e. Internet adapter). |
|
312 * Asks the DDF structure from the AP adapter. |
|
313 * Checks that the given URI is found from the DDF structure. |
|
314 * If the above actions are successful, calls the Fetch Leaf Object or Get Child URI List |
|
315 * commands of AP adapter. |
|
316 * Writes the returned result to the chunk. |
|
317 * @param aMessage. An object which encapsulates a client (other DM Host Server in this case) request. |
|
318 */ |
|
319 void FetchLinkL ( const RMessage2& aMessage ); |
|
320 |
|
321 |
|
322 /** |
|
323 * Sets a general atomic command state. |
|
324 * When this state is set, StartAtomicL function of the adapters |
|
325 * is called when the first 'normal' command arrives. |
|
326 * In addition informs the client (DM Tree Module) if there are unread statuses, results or mappings. |
|
327 * @param aMessage. An object which encapsulates a client request. |
|
328 */ |
|
329 void StartAtomicL ( const RMessage2& aMessage ); |
|
330 |
|
331 /** |
|
332 * Resets the general atomic command state (When atomic commands were successful). |
|
333 * This command is forwarded only to those adapters which have received StartAtomicL call. |
|
334 * In addition informs the client (DM Tree Module) if there are unread statuses, results or mappings. |
|
335 * @param aMessage. An object which encapsulates a client request. |
|
336 */ |
|
337 void CommitAtomicL ( const RMessage2& aMessage ); |
|
338 |
|
339 /** |
|
340 * Resets the general atomic command state (When one or more atomic commands failed). |
|
341 * This command is forwarded only to those adapters which have received StartAtomicL call. |
|
342 * In addition informs the client (DM Tree Module) if there are unread statuses, results or mappings. |
|
343 * @param aMessage. An object which encapsulates a client request. |
|
344 */ |
|
345 void RollbackAtomicL ( const RMessage2& aMessage ); |
|
346 |
|
347 /** |
|
348 * Calls CompleteOutstandingCmdsL -function of the DM plug-in adapters. |
|
349 * This command is issued only to those adapters which have received some adapter |
|
350 * commands during the session. |
|
351 * In addition informs the client (DM Tree Module) if there are unread statuses, results or mappings. |
|
352 * @param aMessage. An object which encapsulates a client request. |
|
353 */ |
|
354 void CompleteCommandsL ( const RMessage2& aMessage ); |
|
355 |
|
356 /** |
|
357 * Sets a handle to the global memory chunk. |
|
358 * The chunk is a common data area between the client (DM Tree Module) and the server |
|
359 * (DM Host Server). |
|
360 * Additionally, a server id is sent in the message. |
|
361 * This id tells to the (common) session class which server session is serving. |
|
362 * @param aMessage. An object which encapsulates a client request. |
|
363 */ |
|
364 void SetChunkHandleL ( const RMessage2& aMessage ); |
|
365 |
|
366 |
|
367 /** |
|
368 * Gets the URI / Luid mappings which have been received from the dm adapters |
|
369 * via callback function calls. |
|
370 * These mappings are buffered by the session class, and - during this call, |
|
371 * all written to the chunk at once. |
|
372 * Additionally informs the client (DM Tree Module) if there are also unread statuses or results. |
|
373 * @param aMessage. An object which encapsulates a client request. |
|
374 */ |
|
375 void GetMappingsL ( const RMessage2& aMessage ); |
|
376 |
|
377 /** |
|
378 * Gets the DM command statuses received from the dm adapters via callback function calls. |
|
379 * These statuse are buffered by the session class, and - during this call, |
|
380 * all written to the chunk at once. |
|
381 * Additionally informs the client (DM Tree Module) if there are also unread mappings or results. |
|
382 * @param aMessage. An object which encapsulates a client request. |
|
383 */ |
|
384 void GetStatusesL ( const RMessage2& aMessage ); |
|
385 |
|
386 /** |
|
387 * Gets the DM command results received from the dm adapters via callback function calls. |
|
388 * In practice, these are the results from the 'FetchLeafObject', 'FecthLeafObjectSize', |
|
389 * and 'GetChildURIList' commands. |
|
390 * The results are all written to the chunk at once if they just fit there. |
|
391 * In case of large objects the result item is cut into pieces by writing one 'chunkfull' at time. |
|
392 * Informs the client (DM Tree Module) if the result is cut up and needs thus additional |
|
393 * GetResultsL -function calls. Additionally, informs the client if there are unread mappings |
|
394 * or statuses. |
|
395 * @param aMessage. An object which encapsulates a client request. |
|
396 */ |
|
397 void GetResultsL ( const RMessage2& aMessage ); |
|
398 |
|
399 |
|
400 /** |
|
401 * Auxiliary function called by the command handling functions (e.g. AddCopyOrDeleteL). |
|
402 * Loads the ECom plug-in Dm Adapter. |
|
403 * The adapter is identified with the given implementation UID. |
|
404 * @param aIndex. A place in the internal list where the adpater pointer is stored. |
|
405 * @param aAdapterId. The implementation UID of the requested DM adapter. |
|
406 * @return CSmlDmAdapter*. New instance of the ECom plug-in DM adapter. |
|
407 */ |
|
408 CSmlDmAdapter* LoadNewAdapterL ( TInt aIndex, TUint32 aAdapterId ); |
|
409 |
|
410 /** |
|
411 * Auxiliary function called by the command handling functions (e.g. UpdateLeafOrExecuteL). |
|
412 * Reads the DM command parameters from the message and from the chunk. |
|
413 * Utilizes the DM Utils services for parsing data in the chunk. |
|
414 * @param aMessage. An object which encapsulates a client request. |
|
415 */ |
|
416 void ReadCmdParamsL ( const RMessage2& aMessage ); |
|
417 |
|
418 /** |
|
419 * Auxiliary function called by the FetchLeafChildUrisOrSizeL. |
|
420 * Reads the DM command parameters from the message and from the chunk. |
|
421 * Utilizes the DM Utils services for parsing data in the chunk. |
|
422 * @param aMessage. An object which encapsulates a client request. |
|
423 * @param aPreviousLuids. A reference parameter, needed for freeing the reserved |
|
424 * heap memory when the luids can be destroyed. |
|
425 */ |
|
426 void ReadCmdFetchParamsL ( const RMessage2& aMessage, RPointerArray<HBufC8>& aPreviousLuids ); |
|
427 |
|
428 /** |
|
429 * Auxiliary function called by the AddCopyOrDeleteL. |
|
430 * Reads the DM command parameters from the message and from the chunk. |
|
431 * Utilizes the DM Utils services for parsing data in the chunk. |
|
432 * @param aMessage. An object which encapsulates a client request. |
|
433 */ |
|
434 void ReadCopyCmdParamsL ( const RMessage2& aMessage ); |
|
435 |
|
436 /** |
|
437 * Auxiliary function for deleting previous set of DM command parameters. |
|
438 */ |
|
439 void DeletePrevParams(); |
|
440 |
|
441 /** |
|
442 * Auxiliary function called by the UpdateLeafOrExecuteLargeL. |
|
443 * Checks that the arrived command is not to different adapter, |
|
444 * during the large object update to the other. |
|
445 */ |
|
446 void CheckIfCorrectAdapterL() const; |
|
447 |
|
448 /** |
|
449 * Auxiliary function called by the the command handling functions, |
|
450 * when the streaming is not used. |
|
451 * Calls the chosen DM adapter function of the given adapter. |
|
452 * The function parameters are set from the internal member variables. |
|
453 * @param aCommand. Identifies the chosen adapter command. |
|
454 * @param aAdIndex. Identifies the chosen DM plug-in adapter. |
|
455 * @param aLargeObject. If the data is a large object, a different |
|
456 * internal variable is chosen. |
|
457 */ |
|
458 void CallAdapterCommandL ( TNSmlDmHostOperationCodes aCommand, TInt aAdIndex, TBool aLargeObject = EFalse ); |
|
459 |
|
460 /** |
|
461 * Auxiliary function called by the the command handling functions, |
|
462 * when the streaming is used. |
|
463 * Calls the chosen DM adapter function of the given adapter. |
|
464 * The function parameters are set from the internal member variables. |
|
465 * @param aCommand. Identifies the chosen adapter command. |
|
466 * @param aAdIndex. Identifies the chosen DM plug-in adapter. |
|
467 * @param aWriteStream. A reference parameter. The adapter sets this parameter to point |
|
468 * to the correct place. |
|
469 */ |
|
470 void CallAdapterCommandL ( TNSmlDmHostOperationCodes aCommand, TInt aAdIndex, RWriteStream*& aWriteStream ); |
|
471 |
|
472 /** |
|
473 * Serves the FetchLink callback when the AP adapter is not found from the server. |
|
474 * Issues an IPC -FetchLink command to the other DM Host Server |
|
475 * using RNSmlDMFetchLink -client API. |
|
476 * @param aURI. A path to the requested interior node object or leaf object. |
|
477 * @param aData. A reference parameter, i.e. a place for fetch result. |
|
478 * @param aStatus. A reference parameter telling the command success (e.g. EOk or ENotFound). |
|
479 */ |
|
480 void FetchLinkViaIPCL ( const TDesC8& aURI, CBufBase& aData, MSmlDmAdapter::TError& aStatus ) const; |
|
481 |
|
482 /** |
|
483 * Serves the FetchLink callback when the AP adapter is owned this server. |
|
484 * Asks first a luid from the callback server. |
|
485 * Calls FetchLeafObjectL -function of the DM adapter if the requested object is a leaf. |
|
486 * Calls ChildURIListL -function of the DM adapter if the requested object is an interior node. |
|
487 * @param aURI. A path to the requested interior node object or leaf object. |
|
488 * @param aAdapterId. Identifies the requested adapter. |
|
489 * @param aData. A reference parameter, i.e. a place for fetch result. |
|
490 * @param aStatus. A reference parameter telling the command success (e.g. EOk or ENotFound). |
|
491 * @param aNodeType. Defines whether the object is a leaf or a node. |
|
492 */ |
|
493 void FetchLinkFromAdapterL ( const TDesC8& aURI, TUint32 aAdapterId, CBufBase& aData, MSmlDmAdapter::TError& aStatus, TNSmlDmDDFFormat aNodeType ); |
|
494 |
|
495 /** |
|
496 * Checks if the given URI can be found from the combined DDF structure. |
|
497 * If not, most probably the URI belongs to some other DM adapter which this server |
|
498 * is not capable of loading. |
|
499 * @param aURI. A path to the requested interior node object or leaf object. |
|
500 * @param aAdapterId. A reference parameter, to which DM Utils service writes the implementation |
|
501 * UID of the adapter - if the URI was found. |
|
502 * @param aNodeType. A reference parameter defining whether the object is a leaf or a node. |
|
503 * @return TBool. ETrue if both the URI and the adapter id were found, EFalse otherwise. |
|
504 */ |
|
505 TBool AdapterIdFromUriL ( const TDesC8& aURI, TUint32& aAdapterId, TNSmlDmDDFFormat& aNodeType ); |
|
506 |
|
507 /** |
|
508 * Auxiliary function which is called from FetchLinkFromAdapterL. |
|
509 * Gets a previous URI segment list from the callback server. |
|
510 * This function is called only during the fetchlink callback and when |
|
511 * the requested object is an interior node object. |
|
512 * @param aAdapterId. Identifies the requested adapter. |
|
513 * @param aURI. A path to the requested interior node object. |
|
514 * @param aURISegList. A reference parameter where callback server writes a list of the child nodes. |
|
515 */ |
|
516 void PrevURISegListL ( TUint32 aAdapterId, const TDesC8& aURI, CArrayFixFlat<TSmlDmMappingInfo>& aURISegList ); |
|
517 |
|
518 /** |
|
519 * Auxiliary function for calculating how much memory does one particular result item reserve. |
|
520 * This function is called from AnalyzeResultList. |
|
521 * @param aIndex. The place of the item in the internal result list. |
|
522 * @return TInt. Needed memory area in bytes for the given result item. |
|
523 */ |
|
524 inline TInt ResultItemSize ( TInt aIndex ); |
|
525 |
|
526 /** |
|
527 * Auxiliary function for calculating how much memory do the mappings need. |
|
528 * This function is called from GetMappingsL in order to adjust the chunk |
|
529 * to adequate size before the mappings are written to the chunk. |
|
530 * @return TInt. Needed memory area in bytes for all the unread mappings. |
|
531 */ |
|
532 TInt SizeOfMappings(); |
|
533 |
|
534 /** |
|
535 * Auxiliary function for calculating how much memory do the arrived statuse need. |
|
536 * This function is called from GetStatusesL in order to adjust the chunk |
|
537 * to adequate size before the statuses are written to the chunk. |
|
538 * @return TInt. Needed memory area in bytes for all the unread statuses. |
|
539 */ |
|
540 TInt SizeOfStatuses() const; |
|
541 |
|
542 /** |
|
543 * Auxiliary function called by GetResultsL. |
|
544 * This function analyzes whether all the results will fit into the chunk |
|
545 * or not. |
|
546 * @param aOkToWrite. A reference parameter which is used only in case of |
|
547 * 'some will fit' for telling how many results can be |
|
548 * written at once. |
|
549 * @param aAdjustChunkSize. A reference parameter for adjusting the chunk to |
|
550 * adequate size before writing takes place. |
|
551 * @return TNSmlDmResultAnalysis. Possible return values are: 1) 'all will fit', |
|
552 * 2) 'some will fit', 3) 'large object (streamed) - |
|
553 * won't fit', and 4) 'large object (not streamed) |
|
554 * - won't fit'. |
|
555 */ |
|
556 TNSmlDmResultAnalysis AnalyzeResultList ( TInt& aOkToWrite, TInt& aAdjustChunkSize ); |
|
557 |
|
558 /** |
|
559 * Auxiliary function for removing the 'read' results from the internal list. |
|
560 * This function is called from GetResultsL after some (or all) results |
|
561 * are written to the chunk. |
|
562 * @param aNumber. The number of the results which are needed to be |
|
563 * removed from the internal list. |
|
564 */ |
|
565 void RemoveResultCallbacksL ( TInt aNumber ); |
|
566 |
|
567 /** |
|
568 * Auxiliary function for defining how much there is room in the chunk for actual |
|
569 * data of the large object. |
|
570 * @param aType. MIME type of the result item. |
|
571 * @return TInt. The available size in bytes. |
|
572 */ |
|
573 inline TInt RoomForLargeData ( const TDesC8& aType ) const; |
|
574 |
|
575 // FOTA |
|
576 /** |
|
577 * This function is called only for the FOTA adapter. |
|
578 * Makes a request for the FOTA adapter to mark generic alerts sent. |
|
579 * In other words, the written generic alerts are issued without |
|
580 * errors to the remote server. |
|
581 */ |
|
582 void MarkGenAlertsSentL(); |
|
583 // FOTA end |
|
584 |
|
585 /** |
|
586 * This function is called any adapter for marking GA sent |
|
587 * Makes a request for the required adapter to mark generic alerts sent. |
|
588 * In other words, the written generic alerts are issued without |
|
589 * errors to the remote server. |
|
590 */ |
|
591 void MarkGenAlertsSentL(const RMessage2& aMessage); |
|
592 |
|
593 /** |
|
594 * This function is called for getting the accesspoint implementation uid |
|
595 */ |
|
596 TUint GetAccessPointImplUid(); |
|
597 |
|
598 private: |
|
599 struct TNSmlDmStreamCommitStatus |
|
600 { |
|
601 TBool iStreamingOngoing; |
|
602 TInt iOldStatusRef; |
|
603 TInt iNewStatusRef; |
|
604 TBool iStreamCommitted; |
|
605 }; |
|
606 CNSmlDMHostServer& iServer; |
|
607 CNSmlDmMgmtTree* iMgmtTree; |
|
608 RChunk iChunk; |
|
609 RArray<TNSmlDmStatusElement> iStatusCodeList; |
|
610 RPointerArray<CNSmlDmResultElement> iResultList; |
|
611 CArrayPtrSeg<HBufC8>* iMapUris; |
|
612 CArrayPtrSeg<HBufC8>* iMapLuids; |
|
613 RArray<TNSmlDmAdapter> iAdapters; |
|
614 RArray<TNSmlDmCallbackRef> iCallbackList; |
|
615 TBool iStartAtomic; |
|
616 TNSmlDmWriteStream iLargeWriteStream; |
|
617 HBufC8* iLargeObject; |
|
618 HBufC* iSemaphoreName; |
|
619 TBool iFetchLinkResult; |
|
620 HBufC8* iResultOtherAdapter; |
|
621 MSmlDmAdapter::TError iStatusOtherAdapter; |
|
622 TBool iCbSessConnected; |
|
623 RNSmlDMCallbackSession iCbSession; |
|
624 RReadStream* iResultReadStream; |
|
625 TInt iResultOffset; |
|
626 TInt iOwnId; |
|
627 |
|
628 TUint32 iAdapterId; |
|
629 TInt32 iStatusRef; |
|
630 TInt32 iResultRef; |
|
631 HBufC8* iLuid; |
|
632 HBufC8* iUri; |
|
633 HBufC8* iData; |
|
634 HBufC8* iType; |
|
635 HBufC8* iTargetLuid; |
|
636 HBufC8* iTargetURI; |
|
637 CArrayFixFlat<TSmlDmMappingInfo>* iPrevSegURIList; |
|
638 TNSmlDmStreamCommitStatus iCommitStatus; |
|
639 }; |
|
640 |
|
641 |
|
642 /** |
|
643 * Class RNSmlDMFetchLink. |
|
644 * Simple client for connecting to other DM Host Servers. |
|
645 * During FetchLink callback. |
|
646 * |
|
647 * @lib nsmldmhostserver.lib |
|
648 */ |
|
649 |
|
650 class RNSmlDMFetchLink : public RSessionBase |
|
651 { |
|
652 public: |
|
653 |
|
654 /** |
|
655 * C++ constructor. |
|
656 */ |
|
657 RNSmlDMFetchLink(); |
|
658 |
|
659 /** |
|
660 * Creates a session (i.e. a connection) to the other DM Host Server. |
|
661 * @param aServer. The server name (e.g. "nsmldmhostserver2"). |
|
662 */ |
|
663 void OpenL ( const TDesC& aServer ); |
|
664 |
|
665 /** |
|
666 * Sets a handle to the global memory chunk. |
|
667 * The client DM Host Server will send a handle of the already existing chunk. |
|
668 * In other words, no new chunks are created for the FetchLink IPC command. |
|
669 * Additionally, a server id is sent in the message. |
|
670 * This id tells to the common session class that it is acting as a 'FetchLink server'. |
|
671 * This information is needed in order to avoid destroying the chunk still in use. |
|
672 * @param aHandle. A handle to the existing global memory chunk. |
|
673 */ |
|
674 void SendChunkHandleL ( const RChunk& aChunk ) const; |
|
675 |
|
676 /** |
|
677 * Issues a fetch IPC command to the other DM Host Server. |
|
678 * @param aURI. A path to the requested interior node object or the leaf object. |
|
679 * @param aReadStream. A reference to the stream in the chunk from where the result |
|
680 * can be read. |
|
681 * @return HBufC8*. The result of the fetch link command. |
|
682 */ |
|
683 HBufC8* FetchL ( const TDesC8& aURI, RReadStream& aReadStream ) const; |
|
684 |
|
685 /** |
|
686 * Closes a session to the other DM Host Server. |
|
687 */ |
|
688 void Close(); |
|
689 }; |
|
690 |
|
691 #endif // __NSMLDMHOSTSERVERSESSION_H__ |