|
1 /* |
|
2 * Copyright (c) 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: Contains CNcdNodeManager class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef NCD_NODE_MANAGER_H |
|
20 #define NCD_NODE_MANAGER_H |
|
21 |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <e32cmn.h> |
|
25 #include <f32file.h> |
|
26 |
|
27 #include "catalogscommunicable.h" |
|
28 #include "ncdnodefactory.h" |
|
29 #include "ncdparserobserver.h" |
|
30 #include "ncdnodeclassids.h" |
|
31 #include "ncdprotocoltypes.h" |
|
32 #include "ncd_pp_entityref.h" |
|
33 #include "ncddatabaseitems.h" |
|
34 |
|
35 class CNcdNode; |
|
36 class CNcdNodeItem; |
|
37 class CNcdNodeFolder; |
|
38 class CNcdRootNode; |
|
39 class CNcdBundleFolder; |
|
40 class CNcdNodeTransparentFolder; |
|
41 class CNcdSearchNodeFolder; |
|
42 class CNcdNodeMetaData; |
|
43 class CNcdNodeIdentifier; |
|
44 class CNcdStorageManager; |
|
45 class CNcdNodeDbManager; |
|
46 class CNcdPurchaseHistoryDb; |
|
47 class MCatalogsBaseMessage; |
|
48 class MNcdPreminetProtocolEntityRef; |
|
49 class MNcdPreminetProtocolDataEntity; |
|
50 class MNcdPreminetProtocolDownload; |
|
51 class MNcdStorageDataItem; |
|
52 class CNcdSearchNodeFolder; |
|
53 class MCatalogsContext; |
|
54 class CNcdNodeCacheCleanerManager; |
|
55 class CNcdPreviewManager; |
|
56 class MNcdConfigurationManager; |
|
57 class CNcdExpiredNode; |
|
58 class MNcdPreminetProtocolExpiredCachedData; |
|
59 class CNcdSearchNodeBundle; |
|
60 class CNcdSearchNodeItem; |
|
61 class CNcdFavoriteManager; |
|
62 class CNcdNodeSeenInfo; |
|
63 class CNcdSearchableNode; |
|
64 class CNcdGeneralManager; |
|
65 |
|
66 /** |
|
67 * CNodeManager provides functions to handle creation and deletion |
|
68 * of node related objects. |
|
69 */ |
|
70 class CNcdNodeManager : public CCatalogsCommunicable |
|
71 { |
|
72 |
|
73 public: |
|
74 |
|
75 /** |
|
76 * Defines how ref data is handled. |
|
77 */ |
|
78 enum TNcdRefHandleMode |
|
79 { |
|
80 EUpdate, // Updates a previously existing node |
|
81 EInsert, // Inserts node to a specific index, increases node count |
|
82 EReplace, // Replaces the node at a specific index |
|
83 EAppend // Appends the node |
|
84 }; |
|
85 |
|
86 /** |
|
87 * Different types of temporary nodes. |
|
88 */ |
|
89 enum TNcdTemporaryNodeType |
|
90 { |
|
91 ENcdTemporaryNodeItem, |
|
92 ENcdTemporaryNodeFolder, |
|
93 ENcdTemporaryBundleFolder |
|
94 }; |
|
95 |
|
96 /** |
|
97 * NewL |
|
98 * |
|
99 * @param aStorageManager Storage manager provides means for |
|
100 * the manager to save, load, and remove data in db. |
|
101 * @param aPurchaseHistory Purchase history contains information |
|
102 * about node purchase phases. |
|
103 * @param aConfigurationManager Gives access to server capabilities etc. |
|
104 * @return CNcdNodeManager* Pointer to the created object |
|
105 * of this class. |
|
106 */ |
|
107 static CNcdNodeManager* NewL( |
|
108 CNcdGeneralManager& aGeneralManager ); |
|
109 |
|
110 /** |
|
111 * Destructor |
|
112 * |
|
113 * Deletes the object from caches and releases objects that are |
|
114 * owned by this class object. |
|
115 */ |
|
116 virtual ~CNcdNodeManager(); |
|
117 |
|
118 |
|
119 public: // General getter and setter functions |
|
120 |
|
121 /** |
|
122 * @return CNcdPurchaseHistoryDb& The purchase history class object. |
|
123 */ |
|
124 CNcdPurchaseHistoryDb& PurchaseHistory() const; |
|
125 |
|
126 CNcdPreviewManager& PreviewManager() const; |
|
127 |
|
128 MNcdConfigurationManager& ConfigurationManager() const; |
|
129 |
|
130 /** |
|
131 * @return CNcdNodeCacheCleanerManager& Cleaner Manager may be used |
|
132 * to get db cache cleaners that can be used to clean data |
|
133 * from db. |
|
134 */ |
|
135 CNcdNodeCacheCleanerManager& NodeCacheCleanerManager() const; |
|
136 |
|
137 /** |
|
138 * @return CNcdNodeDbManager& Reference to the db manager |
|
139 * that can be used to save, load, and remove data in db. |
|
140 */ |
|
141 CNcdNodeDbManager& NodeDbManager() const; |
|
142 |
|
143 /** |
|
144 * @return CNcdNodeSeenInfo& Reference to the seen info |
|
145 * which is used to keep track of seen nodes. |
|
146 */ |
|
147 CNcdNodeSeenInfo& SeenInfo() const; |
|
148 |
|
149 /** |
|
150 * Sets the favorite manager. |
|
151 */ |
|
152 void SetFavoriteManager( CNcdFavoriteManager& aManager ); |
|
153 |
|
154 |
|
155 public: // Functions to get node objects from caches or from db. |
|
156 // And, functions to create node objects. |
|
157 |
|
158 /** |
|
159 * Checks if the node is found from the cache or from the database. |
|
160 * If the node is found from the database then the metadata is also |
|
161 * searched for the node and if it is found then it is inserted |
|
162 * for the node. |
|
163 * |
|
164 * @note This uses the actual node identifier which may differ from |
|
165 * the metadata identifier. Be sure that the identifier is correct |
|
166 * when using this function. |
|
167 * |
|
168 * @param aIdentifier Identifies the node that is searched for. |
|
169 * @return CNcdNode& Reference to the node that was found. |
|
170 * @excpetion KErrNotFound if the node was not found from the |
|
171 * cache or from the database. |
|
172 */ |
|
173 CNcdNode& NodeL( const CNcdNodeIdentifier& aIdentifier ); |
|
174 |
|
175 /** |
|
176 * Instead of taking the actual nodeidentifier, uses the parent identifier |
|
177 * and the metadata identifier to create the correct identifier and after that |
|
178 * calls the NodeL above. |
|
179 * |
|
180 * @see CNcdNodeManager::NodeL |
|
181 * |
|
182 * @param aParentIdentifier Identifier of parent node of the node that is searched. |
|
183 * @param aNodeMetaDataIdentifier Metadata identifier of the node that is |
|
184 * searched for. |
|
185 */ |
|
186 CNcdNode& NodeL( const CNcdNodeIdentifier& aParentIdentifier, |
|
187 const CNcdNodeIdentifier& aNodeMetaDataIdentifier ); |
|
188 |
|
189 |
|
190 /** |
|
191 * Checks if the node is found from the cache or from the database. |
|
192 * If the node is found from the database then the metadata is also |
|
193 * searched for the node and if it is found then it is inserted |
|
194 * for the node. |
|
195 * |
|
196 * @note Ownership of the node is not transferred. |
|
197 * |
|
198 * @note This uses the actual node identifier which may differ from |
|
199 * the metadata identifier. Be sure that the identifier is correct |
|
200 * when using this function. |
|
201 * |
|
202 * @param aIdentifier |
|
203 * @return CNcdNode* Node if it is found. Else NULL. |
|
204 */ |
|
205 CNcdNode* NodePtrL( const CNcdNodeIdentifier& aIdentifier ); |
|
206 |
|
207 /** |
|
208 * Instead of taking the actual nodeidentifier, uses the parent identifier |
|
209 * and the metadata identifier to create the correct identifier and after that |
|
210 * calls the NodeL above. |
|
211 * |
|
212 * @see CNcdNodeManager::NodePtrL |
|
213 * |
|
214 * @param aParentIdentifier Identifier of parent node of the node that is searched. |
|
215 * @param aNodeMetaDataIdentifier Metadata identifier of the node that is |
|
216 * searched for. |
|
217 */ |
|
218 CNcdNode* NodePtrL( const CNcdNodeIdentifier& aParentIdentifier, |
|
219 const CNcdNodeIdentifier& aNodeMetaDataIdentifier ); |
|
220 |
|
221 |
|
222 /** |
|
223 * Uses NodeL to get the folder from the cache or from the db. |
|
224 * If the node is of the folder type, then the folder object is |
|
225 * returned. |
|
226 * |
|
227 * @see CNcdNodeManager::NodeL |
|
228 */ |
|
229 CNcdNodeFolder& FolderL( |
|
230 const CNcdNodeIdentifier& aIdentifier ); |
|
231 |
|
232 /** |
|
233 * Uses NodeL to get the folder from the cache or from the db. |
|
234 * |
|
235 * @see CNcdNodeManager::NodeL |
|
236 */ |
|
237 CNcdRootNode& RootNodeL( const TUid& aClientUid ); |
|
238 |
|
239 /** |
|
240 * Uses NodeL to get the folder from the cache or from the db. |
|
241 * |
|
242 * @see CNcdNodeManager::NodeL |
|
243 */ |
|
244 CNcdSearchNodeFolder& SearchFolderL( const CNcdNodeIdentifier& aParentIdentifier, |
|
245 const CNcdNodeIdentifier& aNodeMetaDataIdentifier ); |
|
246 |
|
247 /** |
|
248 * Uses NodeL to get the folder from the cache or from the db. |
|
249 * |
|
250 * @see CNcdNodeManager::NodeL |
|
251 */ |
|
252 CNcdSearchNodeFolder& SearchFolderL( const CNcdNodeIdentifier& aNodeIdentifier ); |
|
253 |
|
254 /** |
|
255 * Uses NodeL to get the folder from the cache or from the db. |
|
256 * |
|
257 * @see CNcdNodeManager::NodeL |
|
258 */ |
|
259 CNcdSearchNodeItem& SearchNodeItemL( const CNcdNodeIdentifier& aNodeIdentifier ); |
|
260 |
|
261 /** |
|
262 * Creates a node accroding to the given type information. |
|
263 * Adds the created node into the cache. If node already exists |
|
264 * in the cache or in the database, then the old node is used. |
|
265 * |
|
266 * @note Be carefull when using this function. Make sure that the node identifier |
|
267 * actually contains all the parts. Should you use CreateNodeL with parent and |
|
268 * metadata identifiers instead? |
|
269 * |
|
270 * @param aNodeType informs if the node should be item or folder |
|
271 * @param aNodePurpose gives the information if the normal or some specific kind |
|
272 * of node should be created. |
|
273 * @param aNodeIdentfier The identifier that identifies the parent of this node. |
|
274 * @return CNcdNode& Reference to the node that was found. |
|
275 */ |
|
276 CNcdNode& CreateNodeL( CNcdNodeFactory::TNcdNodeType aNodeType, |
|
277 CNcdNodeFactory::TNcdNodePurpose aNodePurpose, |
|
278 const CNcdNodeIdentifier& aNodeIdentifier ); |
|
279 |
|
280 |
|
281 /** |
|
282 * Creates a node accroding to the given type information. |
|
283 * Adds the created node into the cache. If node already exists |
|
284 * in the cache or in the database, then the old node is used. |
|
285 * |
|
286 * @param aNodeType informs if the node should be item or folder |
|
287 * @param aNodePurpose gives the information if the normal or some specific kind |
|
288 * of node should be created. |
|
289 * @param aParentNodeIdentfier The identifier that identifies the parent of this node. |
|
290 * @param aMetaDataIdentifier The identifier of metadata of this node. |
|
291 * @return CNcdNode& Reference to the node that was found. |
|
292 */ |
|
293 CNcdNode& CreateNodeL( CNcdNodeFactory::TNcdNodeType aNodeType, |
|
294 CNcdNodeFactory::TNcdNodePurpose aNodePurpose, |
|
295 const CNcdNodeIdentifier& aParentNodeIdentifier, |
|
296 const CNcdNodeIdentifier& aMetaDataIdentifier ); |
|
297 |
|
298 |
|
299 /** |
|
300 * Creates an item node accroding to the given type information. |
|
301 * Adds the created node into the cache. If node already exists |
|
302 * in the cache or in the database, then the old node is used. |
|
303 * |
|
304 * @note Be carefull when using this function. Make sure that the node identifier |
|
305 * actually contains all the parts. Should you use CreateNodeItemL with parent and |
|
306 * metadata identifiers instead? |
|
307 * |
|
308 * @param aNodePurpose gives the information if the normal or some specific kind |
|
309 * of node should be created. |
|
310 * @param aNodeIdentfier The identifier that identifies the parent of this node. |
|
311 * @return CNcdNode& Reference to the node that was found. |
|
312 */ |
|
313 CNcdNodeItem& CNcdNodeManager::CreateNodeItemL( CNcdNodeFactory::TNcdNodePurpose aNodePurpose, |
|
314 const CNcdNodeIdentifier& aNodeIdentifier ); |
|
315 |
|
316 |
|
317 /** |
|
318 * Creates an item node accroding to the given type information. |
|
319 * Adds the created node into the cache. If node already exists |
|
320 * in the cache or in the database, then the old node is used. |
|
321 * |
|
322 * @param aNodePurpose gives the information if the normal or some specific kind |
|
323 * of node should be created. |
|
324 * @param aParentNodeIdentfier The identifier that identifies the parent of this node. |
|
325 * @param aMetaDataIdentifier The identifier of metadata of this node. |
|
326 * @return CNcdNode& Reference to the node that was found. |
|
327 */ |
|
328 CNcdNodeItem& CNcdNodeManager::CreateNodeItemL( CNcdNodeFactory::TNcdNodePurpose aNodePurpose, |
|
329 const CNcdNodeIdentifier& aParentNodeIdentifier, |
|
330 const CNcdNodeIdentifier& aMetaDataIdentifier ); |
|
331 |
|
332 |
|
333 /** |
|
334 * Creates a folder node accroding to the given type information. |
|
335 * Adds the created node into the cache. If node already exists |
|
336 * in the cache or in the database, then the old node is used. |
|
337 * |
|
338 * @note Be carefull when using this function. Make sure that the node identifier |
|
339 * actually contains all the parts. Should you use CreateNodeFolderL with parent and |
|
340 * metadata identifiers instead? |
|
341 * |
|
342 * @param aNodePurpose gives the information if the normal or some specific kind |
|
343 * of node should be created. |
|
344 * @param aNodeIdentfier The identifier that identifies the parent of this node. |
|
345 * @param aFolderType May be used to inform what kind of special folder is used. For example |
|
346 * if root folder should be created. |
|
347 * @return CNcdNode& Reference to the node that was found. |
|
348 */ |
|
349 CNcdNodeFolder& CNcdNodeManager::CreateNodeFolderL( CNcdNodeFactory::TNcdNodePurpose aNodePurpose, |
|
350 const CNcdNodeIdentifier& aNodeIdentifier, |
|
351 CNcdNodeFactory::TNcdNodeType aFolderType |
|
352 = CNcdNodeFactory::ENcdNodeFolder ); |
|
353 /** |
|
354 * Creates a folder node accroding to the given type information. |
|
355 * Adds the created node into the cache. If node already exists |
|
356 * in the cache or in the database, then the old node is used. |
|
357 * |
|
358 * @param aNodePurpose gives the information if the normal or some specific kind |
|
359 * of node should be created. |
|
360 * @param aParentNodeIdentfier The identifier that identifies the parent of this node. |
|
361 * @param aMetaDataIdentifier The identifier of metadata of this node. |
|
362 * @param aFolderType May be used to inform what kind of special folder is used. For example |
|
363 * if root folder should be created. |
|
364 * @return CNcdNode& Reference to the node that was found. |
|
365 */ |
|
366 CNcdNodeFolder& CNcdNodeManager::CreateNodeFolderL( CNcdNodeFactory::TNcdNodePurpose aNodePurpose, |
|
367 const CNcdNodeIdentifier& aParentNodeIdentifier, |
|
368 const CNcdNodeIdentifier& aMetaDataIdentifier, |
|
369 CNcdNodeFactory::TNcdNodeType aFolderType |
|
370 = CNcdNodeFactory::ENcdNodeFolder ); |
|
371 |
|
372 /** |
|
373 * Uses FolderL to search an existing folder. If the folder is not |
|
374 * found then new transparent folder will be created and retured. |
|
375 * |
|
376 * @see CNcdNodeManager::FolderL |
|
377 */ |
|
378 CNcdNodeTransparentFolder& CreateTransparentFolderL( |
|
379 const CNcdNodeIdentifier& aNodeIdentifier ); |
|
380 |
|
381 /** |
|
382 * Getter for root. |
|
383 * Uses FolderL to get the root from the cache or from the db. |
|
384 */ |
|
385 CNcdRootNode& CreateRootL( const TUid& aClientUid ); |
|
386 |
|
387 /** |
|
388 * Getter for root. |
|
389 * Uses CreateRootL above to get the root from the cache or from the db. |
|
390 */ |
|
391 CNcdRootNode& CreateRootL( const MCatalogsContext& aContext ); |
|
392 |
|
393 /** |
|
394 * Getter for search root. |
|
395 * Uses FolderL to get the search root from the cache or from the db. |
|
396 */ |
|
397 CNcdNodeFolder& CreateSearchRootL( const MCatalogsContext& aContext ); |
|
398 |
|
399 /** |
|
400 * Getter for the bundle node. |
|
401 * The parent of the bunlde is always root. |
|
402 * |
|
403 * @note the use of the metadata identifier instead of the node identifier |
|
404 * @note Also, note that this function does not add the created folder to be the child |
|
405 * of the root. It has to be done separately. |
|
406 * |
|
407 * @param aMetaDataIdentifier The metadata identifier of the bundle node is used |
|
408 * when the bundle folder is created. So, note that you have to give meta data identifier |
|
409 * here instead of the node identifier. |
|
410 */ |
|
411 CNcdNodeFolder& CreateBundleFolderL( const CNcdNodeIdentifier& aMetaDataIdentifier ); |
|
412 |
|
413 /** |
|
414 * This function can be used to create temporary nodes. |
|
415 * If corresponding temporary node already exists in RAM cache or |
|
416 * in database, it will be returned. If not, then metadata is checked. |
|
417 * If the metadata for the node exists, a temporary node is created directly |
|
418 * for the node, and the server uri for the node link is set from |
|
419 * the metadata identifier. The type of the node is gotten from the metadata. |
|
420 * If the temporary node could not be created, then the supplier node that will |
|
421 * act as a wrapper is created. |
|
422 * |
|
423 * @note aMetaDataIdentifier has to contain server URI if the node should be able |
|
424 * to load its data from the web. |
|
425 * @note According to the way the node is created. The node identifier will be an |
|
426 * identifier of the temporary node or the identifier of the supplier node. |
|
427 * @note If the metadata is found, it is set to the node |
|
428 * |
|
429 * @param aMetaDataIdentifier Identifies the metadata that the node should contain. |
|
430 * @return CNcdNode& Reference to the node that has been created. |
|
431 */ |
|
432 CNcdNode& CreateTemporaryNodeOrSupplierL( const CNcdNodeIdentifier& aMetaDataIdentifier ); |
|
433 |
|
434 |
|
435 /** |
|
436 * Creates temporary node if the given metadata exists already. The type |
|
437 * of the created node is concluded from the type of the metadata. The |
|
438 * created node has no parent. The metadata is set automatically for the |
|
439 * created node. NULL is returned if the node cannot be created. |
|
440 * |
|
441 * @param aMetaDataIdentifier Identifies the metadata that the node should contain. |
|
442 * @return The node or NULL, ownership is NOT transferred. |
|
443 */ |
|
444 CNcdNode* CreateTemporaryNodeIfMetadataExistsL( |
|
445 const CNcdNodeIdentifier& aMetadataIdentifier ); |
|
446 |
|
447 |
|
448 /** |
|
449 * Creates temporary node. The created node has no parent. The metadata is |
|
450 * set automatically for the created node if it exists or can be created. |
|
451 * NULL is returned if the node cannot be created. |
|
452 * |
|
453 * @param aTempNodeIdentifier Temp node identifier |
|
454 * @param aType Type of the temp node |
|
455 * @param aCreateMetaData If ETrue metadata is created if it doesn't exist |
|
456 * @return The node or NULL, ownership is NOT transferred. |
|
457 */ |
|
458 CNcdNode& CreateTemporaryNodeL( |
|
459 CNcdNodeIdentifier& aTempNodeIdentifier, |
|
460 TNcdTemporaryNodeType aType, |
|
461 TBool aCreateMetaData ); |
|
462 |
|
463 /** |
|
464 * Creates a search bundle folder. |
|
465 * |
|
466 * @note the use of the metadata identifier instead of the node identifier |
|
467 * @note Also, note that this function does not add the created node as a child |
|
468 * for the parent. It has to be done separately. |
|
469 * |
|
470 * @param aMetaDataIdentifier The metadata identifier of the node is used |
|
471 * when the folder is created. So, note that you have to give meta data identifier |
|
472 * here instead of the node identifier. |
|
473 * @param aParentIdentifier The full identifier of the parent, NOT a metadata identifier. |
|
474 */ |
|
475 CNcdSearchNodeBundle& CreateSearchBundleL( const CNcdNodeIdentifier& aMetaDataIdentifier, |
|
476 const CNcdNodeIdentifier& aParentIdentifier ); |
|
477 |
|
478 /** |
|
479 * Creates a search folder. |
|
480 * |
|
481 * @note the use of the metadata identifier instead of the node identifier |
|
482 * @note Also, note that this function does not add the created node as a child |
|
483 * for the parent. It has to be done separately. |
|
484 * |
|
485 * @param aMetaDataIdentifier The metadata identifier of the node is used |
|
486 * when the folder is created. So, note that you have to give meta data identifier |
|
487 * here instead of the node identifier. |
|
488 * @param aParentIdentifier The full identifier of the parent, NOT a metadata identifier. |
|
489 */ |
|
490 CNcdSearchNodeFolder& CreateSearchFolderL( const CNcdNodeIdentifier& aMetaDataIdentifier, |
|
491 const CNcdNodeIdentifier& aParentIdentifier ); |
|
492 |
|
493 /** |
|
494 * Checks if the node metadata is found from the cache or from the database. |
|
495 * |
|
496 * @param aIdentifier Identifies the node metadata that is searched for. |
|
497 * @return CNcdNode& Reference to the node metadata that was found. |
|
498 * @exception KErrNotFound if the node metadata was not found from the |
|
499 * cache or from the database. |
|
500 */ |
|
501 CNcdNodeMetaData& NodeMetaDataL( const CNcdNodeIdentifier& aIdentifier ); |
|
502 |
|
503 /** |
|
504 * Creates an empty node metadata. |
|
505 * |
|
506 * @note That this function does not set the metadata to any node because |
|
507 * the metadata may not be initialized with proper values if it has only |
|
508 * been created after it was not found from db or from cache. |
|
509 * The caller of this function has to set the metadata to the node |
|
510 * itself when it is wanted. |
|
511 * |
|
512 * @param aMetaDataIdentifier Identifies the name of the metadata that is created. |
|
513 * @param aMetaType Gives the type of metadata that will be created. |
|
514 * @return CNcdNodeFolderMetaData& reference to the metadata that was created. |
|
515 * @exception KErrNotFound If the node was not found from the cache or from the |
|
516 * database. |
|
517 */ |
|
518 CNcdNodeMetaData& CreateNodeMetaDataL( |
|
519 const CNcdNodeIdentifier& aMetaDataIdentifier, |
|
520 CNcdNodeFactory::TNcdNodeType aMetaType ); |
|
521 |
|
522 |
|
523 public: // Functions that are used to insert data information |
|
524 // gotten from the data parsers into the correct node |
|
525 // objects. These functions are provided for operations |
|
526 // to update the nodes. The updated information may also be |
|
527 // inserted from the purchase history. |
|
528 |
|
529 /** |
|
530 * This function updates the node and its link information by |
|
531 * using the MNcdPreminetProtocolEntityRef data. A new node will |
|
532 * be created if it does not exists. Also, metadata is inserted into the |
|
533 * node if the corresponding metadata is found. |
|
534 * |
|
535 * @param aParentNodeIdentifier Identifies the parent of the node that is updated. |
|
536 * @param aData Contains the data that is used to internalize the node link. |
|
537 * @param aClientUid This parameter provides the client uid information. Usually, |
|
538 * the information is also included in the parent node identifier but in some |
|
539 * cases the identifier may be empty. So, the client uid is provided here. |
|
540 * @param aMode Identifies the purpose of this function call. |
|
541 * @param aIndex Tells the index that is used when the node is inserted |
|
542 * into its parent's child array. If mode is EAppend, the index is ignored. |
|
543 * @param aParentNodeType Informs what type the parent is. This is used to check |
|
544 * if the parent is normal folder or root. |
|
545 * @param aNodePurpose Informs what kind of node should get this parser data. |
|
546 * @param aCreateParent Creates the parent node if it does not exist. |
|
547 * @return CNcdNode& Node that was updated. |
|
548 */ |
|
549 CNcdNode& RefHandlerL( |
|
550 const CNcdNodeIdentifier& aParentNodeIdentifier, |
|
551 MNcdPreminetProtocolEntityRef& aData, |
|
552 const TUid& aClientUid, |
|
553 TNcdRefHandleMode aMode, |
|
554 TInt aIndex, |
|
555 CNcdNodeFactory::TNcdNodeType aParentNodeType |
|
556 = CNcdNodeFactory::ENcdNodeFolder, |
|
557 CNcdNodeFactory::TNcdNodePurpose aParentNodePurpose |
|
558 = CNcdNodeFactory::ENcdNormalNode, |
|
559 CNcdNodeFactory::TNcdNodePurpose aNodePurpose |
|
560 = CNcdNodeFactory::ENcdNormalNode, |
|
561 TBool aCreateParent = ETrue ); |
|
562 |
|
563 /** |
|
564 * This function updates the node metadata by |
|
565 * using the MNcdPreminetProtocolDataEntity data. A new node metadata will |
|
566 * be created if it does not exists. Also, metadata is inserted into the |
|
567 * node. The node has always been created for the metadata before this function |
|
568 * is called because RefHandlerL is called when the reference data has been loaded |
|
569 * before metadata. |
|
570 * |
|
571 * @param aParentNodeIdentifier Identifies the parent of the node that is updated. |
|
572 * @param aData Contains the data that is used to internalize the node link. |
|
573 * @param aClientUid This parameter provides the client uid information. Usually, |
|
574 * the information is also included in the parent node identifier but in some |
|
575 * cases the identifier may be empty. So, the client uid is provided here. |
|
576 * @return CNcdNode& Node that contains the metadata that was updated. |
|
577 */ |
|
578 CNcdNode& DataHandlerL( |
|
579 const CNcdNodeIdentifier& aParentNodeIdentifier, |
|
580 MNcdPreminetProtocolDataEntity& aData, |
|
581 const TUid& aClientUid ); |
|
582 |
|
583 |
|
584 /** |
|
585 * Sets the preview data for the node. |
|
586 * The metadata of the node actually contains the information. |
|
587 * So, the info is updated eventually into the metadata. |
|
588 * |
|
589 * @param aIdentifier Identifies the node that will be updated. |
|
590 * @param aFileName Name of the file that contains the preview data. |
|
591 * @param aIndex Node may contain multiple previews. Index identifies |
|
592 * the preview of the node. |
|
593 * @param aMimeType MIME type received in HTTP headers. Used only if |
|
594 * none was received in protocol responses |
|
595 */ |
|
596 void PreviewHandlerL( const CNcdNodeIdentifier& aNodeIdentifier, |
|
597 const TDesC& aFileName, |
|
598 TInt aIndex, |
|
599 const TDesC& aMimeType ); |
|
600 |
|
601 /** |
|
602 * Updates the node |
|
603 * The metadata of the node actually contains the information. |
|
604 * So, the info is updated eventually into the metadata. |
|
605 * |
|
606 * @param aIdentifier Identifies the node that will be updated. |
|
607 */ |
|
608 void PurchaseHandlerL( const CNcdNodeIdentifier& aNodeIdentifier ); |
|
609 |
|
610 |
|
611 /** |
|
612 * Sets the download information of a content into the metadata of a node. |
|
613 * This is called when the data has been downloaded. |
|
614 * The metadata of the node actually contains the information. |
|
615 * So, the info is updated eventually into the metadata. |
|
616 * |
|
617 * @param aIdentifier Identifies the node whose content may be downloaded. |
|
618 */ |
|
619 void DownloadDataHandlerL( const CNcdNodeIdentifier& aNodeIdentifier ); |
|
620 |
|
621 |
|
622 /** |
|
623 * Sets the install information for the node. This is called when the downloaded |
|
624 * data has been installed. |
|
625 * The metadata of the node actually contains the information. |
|
626 * So, the info is updated eventually into the metadata. |
|
627 * |
|
628 * @param aIdentifier Identifies the node that will be updated. |
|
629 */ |
|
630 void InstallHandlerL( const CNcdNodeIdentifier& aNodeIdentifier ); |
|
631 |
|
632 |
|
633 /** |
|
634 * Sets the node expired. |
|
635 * |
|
636 * @param aNodeIdentifier The node identifier. |
|
637 * @param recursive If true, all the child nodes are set expired too. |
|
638 * @param aFoundNodes All found nodes are added to this array. |
|
639 */ |
|
640 void SetNodeExpiredL( const CNcdNodeIdentifier& aNodeIdentifier, |
|
641 TBool aRecursive, |
|
642 TBool aForceUpdate, |
|
643 RPointerArray<CNcdExpiredNode>& aFoundNodes ); |
|
644 |
|
645 /** |
|
646 * Sets the node expired. |
|
647 * |
|
648 * @param aNodeIdentifier The node identifier. |
|
649 * @param recursive If true, all the child nodes are set expired too. |
|
650 * @param aFoundNodes All found nodes are added to this array. |
|
651 */ |
|
652 void SetNodeExpiredL( CNcdNode& aNode, |
|
653 TBool aRecursive, |
|
654 TBool aForceUpdate, |
|
655 RPointerArray<CNcdExpiredNode>& aFoundNodes ); |
|
656 |
|
657 /** |
|
658 * Sets all nodes that use the given metadata expired. |
|
659 * |
|
660 * @param aData Expired cached data info. |
|
661 * @param aClientUid Uid of the client. |
|
662 * @param aNameSpace Namespace of the expired nodes. |
|
663 * @param aFoundNodes All found nodes are added to this array. |
|
664 */ |
|
665 void SetNodesExpiredByMetadataL( |
|
666 const MNcdPreminetProtocolExpiredCachedData& aData, |
|
667 const TUid& aClientUid, |
|
668 const TDesC& aNameSpace, |
|
669 RPointerArray<CNcdExpiredNode>& aFoundNodes ); |
|
670 |
|
671 |
|
672 /** |
|
673 * Removes the given node. |
|
674 * This function can be used if the actua node identifier is not known |
|
675 * but the parent identifier and the node metadata are. |
|
676 * |
|
677 * @param aParentIdentifier |
|
678 * @param aNodeMetaDataIdentifier |
|
679 * @ Remove the node from database. |
|
680 */ |
|
681 void RemoveNodeL( const CNcdNodeIdentifier& aParentIdentifier, |
|
682 const CNcdNodeIdentifier& aNodeMetaDataIdentifier ); |
|
683 |
|
684 |
|
685 /** |
|
686 * Removes the given node. |
|
687 * |
|
688 * @param aIdentifier The node. |
|
689 * @ Remove the node from database. |
|
690 */ |
|
691 void RemoveNodeL( const CNcdNodeIdentifier& aIdentifier ); |
|
692 |
|
693 |
|
694 /** |
|
695 * Clears all search results. |
|
696 */ |
|
697 void ClearSearchResultsL( const MCatalogsContext& aContext ); |
|
698 |
|
699 /** |
|
700 * Moves all the child nodes (recursively) of the given root in the RAM cache to temporary cache. |
|
701 * Note! The nodes are not searched from temporary cache ever, but they |
|
702 * can be returned to the main RAM cache if wanted. The children are removed from |
|
703 * the root node's child list. Node database must not be locked when |
|
704 * calling this function. |
|
705 * |
|
706 * @param aRootNode The root node. |
|
707 */ |
|
708 void BackupAndClearCacheL( |
|
709 const CNcdNodeIdentifier& aRootNode ); |
|
710 |
|
711 /** |
|
712 * Reverts the child nodes of the given root from the temporary cache to the main |
|
713 * RAM cache. Internalizes the root node's child list from database. |
|
714 * |
|
715 * @param aRootNode The root node. |
|
716 */ |
|
717 void RevertNodeCacheL( |
|
718 const CNcdNodeIdentifier& aRootNode ); |
|
719 |
|
720 /** |
|
721 * Reverts the given node from the temp cache to the main RAM cache. |
|
722 * |
|
723 * @param aNodeIdentifier The node identifier. |
|
724 */ |
|
725 void RevertNodeFromTempCacheL( const CNcdNodeIdentifier& aNodeIdentifier ); |
|
726 |
|
727 /** |
|
728 * Removes and closes the child nodes of the given root in the temporary |
|
729 * RAM cache. |
|
730 * |
|
731 * @param aRootIdentifier The root node. |
|
732 */ |
|
733 void ClearTempCacheL( const CNcdNodeIdentifier& aRootIdentifier ); |
|
734 |
|
735 |
|
736 public: // Cache cleanup functions. |
|
737 // These functions are called by the node objects when |
|
738 // they are released by the corresponding proxy object. |
|
739 |
|
740 /** |
|
741 * This function is called by the node when the |
|
742 * release request has been made from the proxy node. |
|
743 * When the node is release its reference count is decreased |
|
744 * by one. If the reference count has reached one. It means |
|
745 * that no proxy side object needs the node anymore. So, the |
|
746 * node may be closed if necessary. |
|
747 * |
|
748 * @param aNode The node which got the release request. |
|
749 */ |
|
750 void NodeReleased( CNcdNode& aNode ); |
|
751 |
|
752 /** |
|
753 * This function is called by the metadata when the |
|
754 * release request has been made from the proxy metadata. |
|
755 * When the metadata is release its reference count is decreased |
|
756 * by one. If the reference count has reached one. It means |
|
757 * that no proxy side object needs the node anymore. So, the |
|
758 * metadata may be closed if necessary. |
|
759 * |
|
760 * @param aNode The node which got the release request. |
|
761 */ |
|
762 void MetaDataReleased( CNcdNodeMetaData& aMetaData ); |
|
763 |
|
764 |
|
765 /** |
|
766 * Clears a client's cache (nodes, icons, previews etc.) |
|
767 * |
|
768 * @param aContext Client's context |
|
769 * @param aClearDownloads If ETrue incomplete downloads are deleted |
|
770 */ |
|
771 void ClearClientCacheL( |
|
772 const MCatalogsContext& aContext, |
|
773 TBool aClearDownloads ); |
|
774 |
|
775 |
|
776 public: // Db functions that are needed from other class objects. |
|
777 // The db functions are provided here instead of directly providing |
|
778 // db manager because node manager may want to do some additional checking |
|
779 // before db actions are allowed. |
|
780 |
|
781 |
|
782 /** |
|
783 * Removes the node from the db. |
|
784 * |
|
785 * @param aIdentifier Identifies the node that will be removed from db. |
|
786 */ |
|
787 void DbRemoveNodeL( const CNcdNodeIdentifier& aIdentifier ); |
|
788 |
|
789 |
|
790 /** |
|
791 * Saves the userdata into the db. |
|
792 * |
|
793 * @param aUserDataIdentifier Identifier for the db object. |
|
794 * @param aDataItem UserData class object should implement MNcdStorageDataItem |
|
795 * interface whose externalzie function is called when the data is saved. |
|
796 */ |
|
797 void DbSaveUserDataL( const CNcdNodeIdentifier& aUserDataIdentifier, |
|
798 MNcdStorageDataItem& aDataItem ); |
|
799 |
|
800 /** |
|
801 * Removes the user data corresponding the given identifier from the db. |
|
802 * @param aUserDataIdentifier Identifies the user data from the db. |
|
803 */ |
|
804 void DbRemoveUserDataL( const CNcdNodeIdentifier& aUserDataIdentifier ); |
|
805 |
|
806 /** |
|
807 * Loads the user data from db. |
|
808 * |
|
809 * @param aUserDataIdentifier Identfier for the db object. |
|
810 * @param aDataItem UserData class object should implement MNcdStorageDataItem |
|
811 * interface whose internalize function is called when the data is laoded. |
|
812 */ |
|
813 void DbLoadUserDataL( const CNcdNodeIdentifier& aUserDataIdentifier, |
|
814 MNcdStorageDataItem& aDataItem ); |
|
815 |
|
816 /** |
|
817 * Gets the screenshot data from the db. |
|
818 * |
|
819 * @param aScreenshotIdentifier Identifier for the db object. |
|
820 * @return HBufC8* The descriptor contains the screenshot data. |
|
821 */ |
|
822 HBufC8* DbScreenshotDataLC( const CNcdNodeIdentifier& aScreenshotIdentifier ); |
|
823 |
|
824 /** |
|
825 * Gets the icon data from the db. |
|
826 * |
|
827 * @param aIconIdentifier Identifier for the db object. |
|
828 * @return HBufC8* The descriptor contains the icon data. |
|
829 */ |
|
830 HBufC8* DbIconDataLC( const CNcdNodeIdentifier& aIconIdentifier ); |
|
831 |
|
832 /** |
|
833 * Saves the given icon data into the db. |
|
834 * |
|
835 * @param aIconIdentifier Identifier for the db object. |
|
836 * @param aIconData Data that will be saved into the db. |
|
837 */ |
|
838 void DbSaveIconDataL( const CNcdNodeIdentifier& aIconIdentifier, |
|
839 const TDesC8& aIconData ); |
|
840 |
|
841 |
|
842 /** |
|
843 * Saves the node information to the storage. |
|
844 * The node implements MNcdStorageDataItem interface. |
|
845 * So, it can internalize its data into the db. |
|
846 * |
|
847 * @param aNode |
|
848 */ |
|
849 void DbSaveNodeL( CNcdNode& aNode ); |
|
850 |
|
851 /** |
|
852 * Saves all the child nodes of the given root in the RAM cache to the storage. |
|
853 * Does not save scheme nodes. |
|
854 * |
|
855 * @param aRootNode The root node. |
|
856 */ |
|
857 void DbSaveNodesL( const CNcdNodeIdentifier& aRootNode ); |
|
858 |
|
859 /** |
|
860 * Saves the node metadata information to the storage. |
|
861 * The node metadata implements MNcdStorageDataItem interface. |
|
862 * So, it can internalize its data into the db. |
|
863 * |
|
864 * @param aMetaData |
|
865 */ |
|
866 void DbSaveNodeMetaDataL( CNcdNodeMetaData& aMetaData ); |
|
867 |
|
868 |
|
869 /** |
|
870 * Sets the max db byte size for the given client. |
|
871 * If db exeeds this size, then some cleaning should be done. |
|
872 * |
|
873 * @notice This function takes the max db size value as kilobytes. |
|
874 * Function converts the kB value to byte value |
|
875 * (by multiplying by 1024) and |
|
876 * sets the converted value for the cache cleaner. |
|
877 * |
|
878 * @param aUid the client uid |
|
879 * @param aMaxDbKiloByteSize The maximum kilo byte size of the db. |
|
880 */ |
|
881 void DbSetMaxSizeL( const TUid& aClientUid, |
|
882 const TInt aMaxDbKiloByteSize ); |
|
883 |
|
884 /** |
|
885 * Locks the node database from the given client. That is, nodes are never |
|
886 * stored or searched from database. Only RAM cache is used. |
|
887 * |
|
888 * @param aClientUid The client uid. |
|
889 */ |
|
890 void LockNodeDbL( TUid aClientUid ); |
|
891 |
|
892 /** |
|
893 * Unlocks the node database. |
|
894 * |
|
895 * @see CNcdNodeManager::LockNodeDb |
|
896 * @param aClientUid The client uid. |
|
897 */ |
|
898 void UnlockNodeDb( TUid aClientUid ); |
|
899 |
|
900 |
|
901 public: // General tool functions |
|
902 |
|
903 /** |
|
904 * Inserts the given child into the given parents child array. |
|
905 * Also, updates the cache if new items are created. |
|
906 * |
|
907 * @note This function also inserts the parent identifier into the |
|
908 * child node if the child is added to a parent.SetParentIdentifierL of |
|
909 * the link is used, which means that also the request parent identifier of the node link |
|
910 * is updated. Be careful when calling this function because problems may occur |
|
911 * if the request parent identifier of the transparent child node is not |
|
912 * updated correctly after this function. When RefHandlerL calls this function |
|
913 * it also updates the request parent identifier correctly. So, if possible |
|
914 * use RefHandlerL instead of this function. |
|
915 * |
|
916 * @note Parent id is node identifier and the child id is metadata identifier. |
|
917 * |
|
918 * @param |
|
919 * @param aChildNodeMetaDataIdentifier The metadata identifier of the child |
|
920 * is used to add the child information to the parent node. |
|
921 */ |
|
922 void AddToParentL( const CNcdNodeIdentifier& aParentNodeIdentifier, |
|
923 const CNcdNodeIdentifier& aChildNodeMetaDataIdentifier, |
|
924 CNcdNodeFactory::TNcdNodeType aParentNodeType |
|
925 = CNcdNodeFactory::ENcdNodeFolder, |
|
926 CNcdNodeFactory::TNcdNodePurpose aParentNodePurpose |
|
927 = CNcdNodeFactory::ENcdNormalNode, |
|
928 CNcdNodeFactory::TNcdNodePurpose aNodePurpose |
|
929 = CNcdNodeFactory::ENcdNormalNode, |
|
930 TNcdRefHandleMode aMode = EUpdate, |
|
931 TInt aIndex = 0, |
|
932 TBool aTransparent = EFalse ); |
|
933 |
|
934 TBool IsCapabilitySupportedL( const CNcdNodeIdentifier& aNodeIdentifier, |
|
935 const TDesC& aCapability, MCatalogsContext& aContext ); |
|
936 |
|
937 /** |
|
938 * Tries to get an origin identifier from purchase history for a given node. |
|
939 * |
|
940 * @param aNodeIdentifier The node to get origin identifier for. |
|
941 * @return An origin identifier for the node, NULL if not found. |
|
942 */ |
|
943 CNcdNodeIdentifier* GetOriginIdentifierL( const CNcdNodeIdentifier& aNodeIdentifier ); |
|
944 |
|
945 |
|
946 /** |
|
947 * Removes folder's children from db unless they are favorites, |
|
948 * removes all (immediate) children from RAM cache and empties |
|
949 * the child array and saves the folder to disk |
|
950 */ |
|
951 void RemoveChildrenL( CNcdNodeFolder& aFolder ); |
|
952 |
|
953 /** |
|
954 * Removes folder's children's metadatas from disk |
|
955 */ |
|
956 void RemoveChildrenMetadataL( CNcdNodeFolder& aFolder ); |
|
957 |
|
958 |
|
959 public: // CCatalogsCommunicable |
|
960 |
|
961 /** |
|
962 * @see CCatalogsCommunicable::ReceiveMessage |
|
963 */ |
|
964 virtual void ReceiveMessage( MCatalogsBaseMessage* aMessage, |
|
965 TInt aFunctionNumber ); |
|
966 |
|
967 /** |
|
968 * @see CCatalogsCommunicable::CounterPartLost |
|
969 */ |
|
970 virtual void CounterPartLost( const MCatalogsSession& aSession ); |
|
971 |
|
972 |
|
973 protected: |
|
974 |
|
975 /** |
|
976 * Constructor |
|
977 * |
|
978 * @param aPurchaseHistory Purchase history contains information |
|
979 * about node purchase phases. |
|
980 * @param aConfigurationManager Gives access to server capabilities etc. |
|
981 */ |
|
982 CNcdNodeManager( CNcdGeneralManager& aGeneralManager ); |
|
983 |
|
984 /** |
|
985 * ConstructL |
|
986 * |
|
987 * @param aStorageManager Storage manager provides means for |
|
988 * the manager to save, load, and remove data in db. |
|
989 */ |
|
990 void ConstructL(); |
|
991 |
|
992 |
|
993 protected: // General getter and setter functions |
|
994 |
|
995 /** |
|
996 * @return CNcdNodeFactory& Reference to the node factory |
|
997 * that is used to create node objects. |
|
998 */ |
|
999 CNcdNodeFactory& NodeFactory() const; |
|
1000 |
|
1001 /** |
|
1002 * Sets the metadata for the given node if metadata can be found |
|
1003 * from cache or from db. |
|
1004 * |
|
1005 * @param aNode Node that will have the metadata if it is found. |
|
1006 */ |
|
1007 void SetNodeMetaDataL( CNcdNode& aNode ); |
|
1008 |
|
1009 |
|
1010 protected: // Db functions |
|
1011 |
|
1012 /** |
|
1013 * Searches the db for the given node. And creates the node if it is found. |
|
1014 * |
|
1015 * @return CNcdNode& Node whose data was found from the db. |
|
1016 * @exception KErrNotFound if the node was not found from the db. |
|
1017 */ |
|
1018 CNcdNode& DbNodeL( const CNcdNodeIdentifier& aIdentifier ); |
|
1019 |
|
1020 /** |
|
1021 * Searches the db for the given node metadata. |
|
1022 * And creates the node metadata if it is found. |
|
1023 * |
|
1024 * @return CNcdNodeMetaData& Node metadata whose data was found from the db. |
|
1025 * @exception KErrNotFound if the node metadata was not found from the db. |
|
1026 */ |
|
1027 CNcdNodeMetaData& DbMetaDataL( const CNcdNodeIdentifier& aIdentifier ); |
|
1028 |
|
1029 |
|
1030 protected: // Functions that are called from the ReceiveMessageL, |
|
1031 // which is meant to be used by the client side. |
|
1032 |
|
1033 |
|
1034 /** |
|
1035 * Creates a root node according to the identifier that has |
|
1036 * included into the message. |
|
1037 * If corresponding node has already been created, the old |
|
1038 * one will be returned and new one is not created. |
|
1039 * |
|
1040 * @param aMessage Contains data from the proxy and can be used |
|
1041 * to send data back to proxy. |
|
1042 */ |
|
1043 void RootNodeRequestL( MCatalogsBaseMessage& aMessage ); |
|
1044 |
|
1045 /** |
|
1046 * Creates a search root node according to the identifier that has |
|
1047 * included into the message. |
|
1048 * If corresponding node has already been created, the old |
|
1049 * one will be returned and new one is not created. |
|
1050 * |
|
1051 * @param aMessage Contains data from the proxy and can be used |
|
1052 * to send data back to proxy. |
|
1053 */ |
|
1054 void SearchRootNodeRequestL( MCatalogsBaseMessage& aMessage ); |
|
1055 |
|
1056 /** |
|
1057 * Check RAM cache and DB for the node. |
|
1058 * If corresponding node has already been created in cache, the old |
|
1059 * one will be returned and new one is not created. |
|
1060 * |
|
1061 * @note This does not create the node if it is not found from the |
|
1062 * db. |
|
1063 * |
|
1064 * @param aMessage Contains data from the proxy and can be used |
|
1065 * to send data back to proxy. |
|
1066 */ |
|
1067 void NodeRequestL( MCatalogsBaseMessage& aMessage ); |
|
1068 |
|
1069 /** |
|
1070 * Creates the temporary node that corresponds to the given identifier. |
|
1071 * This node will not be inserted as child to some other folder. |
|
1072 * |
|
1073 * |
|
1074 * @param aMessage Contains data from the proxy and can be used |
|
1075 * to send data back to proxy. |
|
1076 * @param aType Type of the node to create. |
|
1077 * @param aCreateMetaData If true, this function will create the dummy metadata |
|
1078 * for the node if it does not already exist in RAM cache or in db. |
|
1079 * The metadata is initialized normally from the purchase details. |
|
1080 * So, the node created by this function will be initialized even if |
|
1081 * its metadata would not contain any real info. |
|
1082 */ |
|
1083 void TemporaryNodeRequestL( |
|
1084 MCatalogsBaseMessage& aMessage, |
|
1085 TNcdTemporaryNodeType aType, |
|
1086 TBool aCreateMetaData ); |
|
1087 |
|
1088 /** |
|
1089 * Creates temporary folder or item that has metadata that corresponds |
|
1090 * to the given metadata identifier. This node will not be inserted as child |
|
1091 * to some other folder. The node is not created if suitable one already exists. |
|
1092 * If the metadata does not exist yet, it cannot be known whether a node or folder |
|
1093 * should be created, so a supplier node is created. |
|
1094 * |
|
1095 * @param aMessage Contains the node identifier data from the proxy. Notice, |
|
1096 * that this function only returns zero in message and not any usable value. |
|
1097 * NodeRequestL has to be called after this request to get the handle for |
|
1098 * the created node. |
|
1099 */ |
|
1100 void TemporaryOrSupplierNodeRequestL( MCatalogsBaseMessage& aMessage ); |
|
1101 |
|
1102 /** |
|
1103 * Creates temporary folder or item that has metadata that corresponds to |
|
1104 * the given metadata identifier. If the metadata does not exist already, |
|
1105 * the node is not created. |
|
1106 * |
|
1107 * @param aMessage Contains the node identifier data from the proxy. This |
|
1108 * function returns ETrue or EFalse in the message, depending on whether the |
|
1109 * node was created or not. |
|
1110 */ |
|
1111 void TemporaryNodeIfMetadataExistsRequestL( |
|
1112 MCatalogsBaseMessage& aMessage ); |
|
1113 |
|
1114 |
|
1115 /** |
|
1116 * This function is called from the proxy side when the proxy |
|
1117 * is deleted. |
|
1118 * |
|
1119 * @param aMessage Contains data from the proxy and can be used |
|
1120 * to send data back to proxy. |
|
1121 */ |
|
1122 void ReleaseRequest( MCatalogsBaseMessage& aMessage ); |
|
1123 |
|
1124 /** |
|
1125 * Clears all search result nodes. |
|
1126 * |
|
1127 * @param aMessage Contains data from the proxy and can be used |
|
1128 * to send data back to proxy. |
|
1129 */ |
|
1130 void ClearSearchResultsRequestL( MCatalogsBaseMessage& aMessage ); |
|
1131 |
|
1132 /** |
|
1133 * Checks via conf manager whether a capability is supported by a server. |
|
1134 * |
|
1135 * @param aMessage Contains data from the proxy and can be used |
|
1136 * to send data back to proxy. |
|
1137 */ |
|
1138 void IsCapabilitySupportedRequestL( MCatalogsBaseMessage& aMessage ); |
|
1139 |
|
1140 |
|
1141 protected: // Functions that are called from the functions that receive messages. |
|
1142 |
|
1143 /** |
|
1144 * Creates the identifier from the message that has been gotten from the proxy. |
|
1145 * If the identifier does not already contain the UID value, it will be set here. |
|
1146 * |
|
1147 * @param aMessage Contains data from the proxy and can be used |
|
1148 * to send data back to proxy. This function uses the message to get the identifier |
|
1149 * that has been sent from the proxy side. |
|
1150 */ |
|
1151 CNcdNodeIdentifier* RequestNodeIdentifierLC( MCatalogsBaseMessage& aMessage ) const; |
|
1152 |
|
1153 |
|
1154 private: |
|
1155 |
|
1156 // Prevent if not implemented |
|
1157 CNcdNodeManager( const CNcdNodeManager& aObject ); |
|
1158 CNcdNodeManager& operator =( const CNcdNodeManager& aObject ); |
|
1159 |
|
1160 |
|
1161 private: // Cache functions |
|
1162 |
|
1163 // Searches the cache for the node that corresponds to the given identifier. |
|
1164 CNcdNode* FindNodeFromCacheL( const CNcdNodeIdentifier& aIdentifier ); |
|
1165 |
|
1166 // Searches the main cache for the given node. |
|
1167 CNcdNode* FindNodeFromMainCache( const CNcdNodeIdentifier& aIdentifier ); |
|
1168 |
|
1169 // Searches the cache for the metadata that corresponds to the given identifier. |
|
1170 CNcdNodeMetaData* FindNodeMetaDataFromCache( const CNcdNodeIdentifier& aIdentifier ); |
|
1171 |
|
1172 inline TInt FindNodeFromArray( |
|
1173 const CNcdNodeIdentifier& aIdentifier, |
|
1174 const RPointerArray<CNcdNode>& aArray ) const; |
|
1175 |
|
1176 inline TInt InsertNodeInOrder( |
|
1177 CNcdNode* aNode, |
|
1178 RPointerArray<CNcdNode>& aArray ); |
|
1179 |
|
1180 // Closes all the nodes that are not used any more. |
|
1181 // This function is used when node manager things that it is |
|
1182 // a good time to clean unnecessary nodes from the cache. |
|
1183 // ( If access count of node is 1 the manager things that |
|
1184 // the node is not used anymore. ) |
|
1185 void NodeCacheCleanup(); |
|
1186 |
|
1187 // Checks if there are unnecesary meta data objects |
|
1188 // ( no node is using the metadata ) in the cache. |
|
1189 // Deletes unused metadata. |
|
1190 void MetaDataCacheCleanup(); |
|
1191 |
|
1192 // Checks if any cached node uses the metadata |
|
1193 TBool IsMetadataUsed( const CNcdNodeMetaData* aMetadata ) const; |
|
1194 |
|
1195 // Closes all nodes and metadata objects |
|
1196 void FullCacheCleanup(); |
|
1197 |
|
1198 // Closes all metadata objects |
|
1199 void CloseMetadatas(); |
|
1200 |
|
1201 // Appends the given node into the array. |
|
1202 // The cache takes the ownership. So, remember to pop the |
|
1203 // node from the cleanupstack after using this function. |
|
1204 // This function should be used instead of directly appending data |
|
1205 // to the cache because this function also updates info to |
|
1206 // the db cache cleaner. |
|
1207 void AppendNodeToCacheL( CNcdNode* aNode ); |
|
1208 |
|
1209 // This function should be used only in rare cases. |
|
1210 // Usually only if the server has changed the types of the nodes. |
|
1211 // Function will check if the node exists in RAM cache or in db. |
|
1212 // If the node already exists, the type of the old node is compared |
|
1213 // to the values that have been given as parameter. If the old node |
|
1214 // is not of the right type, then the old node is removed from the RAM |
|
1215 // cache and replaced by the new node that will be of the required type. |
|
1216 // Notice, that this function does not replace the old node data in db. |
|
1217 // If db should be updated, it has to be done separately. |
|
1218 CNcdNode& CheckAndCreateNodeL( CNcdNodeFactory::TNcdNodeType aNodeType, |
|
1219 CNcdNodeFactory::TNcdNodePurpose aNodePurpose, |
|
1220 const CNcdNodeIdentifier& aParentNodeIdentifier, |
|
1221 const CNcdNodeIdentifier& aMetaIdentifier ); |
|
1222 |
|
1223 // See description above. |
|
1224 CNcdNode& CheckAndCreateNodeL( CNcdNodeFactory::TNcdNodeType aNodeType, |
|
1225 CNcdNodeFactory::TNcdNodePurpose aNodePurpose, |
|
1226 const CNcdNodeIdentifier& aNodeIdentifier ); |
|
1227 |
|
1228 // Same as CheckAndCreateNodeL but for the metadata |
|
1229 CNcdNodeMetaData& CheckAndCreateMetaDataL( const CNcdNodeIdentifier& aMetaIdentifier, |
|
1230 CNcdNodeFactory::TNcdNodeType aMetaType ); |
|
1231 |
|
1232 |
|
1233 // Clears all client namespaces except subscriptions |
|
1234 // Favorites are not cleared if aClearFavorites is false |
|
1235 // Downloads are not cleared if aClearDownloads is false |
|
1236 void ClearClientNamespacesL( |
|
1237 const TUid& aClientUid, |
|
1238 TBool aClearFavorites, |
|
1239 TBool aClearDownloads ); |
|
1240 |
|
1241 // Clears namespaces that have favorites so that favorites are not cleared |
|
1242 void ClearNamespacesWithFavoritesL( const TUid& aClientUid ); |
|
1243 |
|
1244 // Clears the namespace aSortedArray[aIndex]->NodeNamespace() but |
|
1245 // ignores nodes that are in aSortedArray. Also their metadatas and icons are |
|
1246 // left intact. |
|
1247 // aSortedArray must be sorted by namespaces |
|
1248 // Client UID is taken from a CNcdNodeIdentifier |
|
1249 TInt ClearNamespaceL( |
|
1250 const RPointerArray<CNcdNodeIdentifier>& aSortedArray, |
|
1251 TInt aIndex ); |
|
1252 |
|
1253 // Loads and closes nodes and their metadatas using the identifiers |
|
1254 // in array aNodeIds from index aStart to aEnd - 1 |
|
1255 // Leaves if either node or metadata load fails |
|
1256 void CheckNodesL( |
|
1257 const RPointerArray<CNcdNodeIdentifier>& aNodeIds, |
|
1258 TInt aStart, |
|
1259 TInt aEnd ); |
|
1260 |
|
1261 |
|
1262 void RemoveNodeFromRamCache( |
|
1263 const CNcdNodeIdentifier& aIdentifier ); |
|
1264 |
|
1265 void CommitSeenChanges( const MCatalogsContext& aContext ); |
|
1266 |
|
1267 private: // data |
|
1268 |
|
1269 // Db manager is used to save, load, and remove data in database. |
|
1270 CNcdNodeDbManager* iDbManager; |
|
1271 |
|
1272 // Factory is used to create the nodes. The purpose of the factory |
|
1273 // is to provide one class where all the nodes can be created. Thus, |
|
1274 // when new nodes are implemented they can be always created by |
|
1275 // using one factory class instead of creating nodes all around |
|
1276 // the code. |
|
1277 CNcdNodeFactory* iNodeFactory; |
|
1278 |
|
1279 // This object is used to manage db cache cleaners. |
|
1280 CNcdNodeCacheCleanerManager* iNodeCacheCleanerManager; |
|
1281 |
|
1282 CNcdPreviewManager* iPreviewManager; |
|
1283 |
|
1284 CNcdFavoriteManager* iFavoriteManager; |
|
1285 |
|
1286 // Node seen info is used to keep track of seen nodes. Owned by this class. |
|
1287 CNcdNodeSeenInfo* iSeenInfo; |
|
1288 |
|
1289 // Purchase history is used to load and to save purchase data from |
|
1290 // database. |
|
1291 CNcdPurchaseHistoryDb& iPurchaseHistory; |
|
1292 |
|
1293 // This array contains all the nodes that have been created. |
|
1294 // By checking the id of the nodes, the same node, that contains |
|
1295 // the metadata, can be included to multiple containers without |
|
1296 // copying it. |
|
1297 RPointerArray<CNcdNode> iNodeCache; |
|
1298 |
|
1299 // This array contains all the nodes that have been created. |
|
1300 // By checking the id of the nodes, the same node, that contains |
|
1301 // the metadata, can be included to multiple containers without |
|
1302 // copying it. |
|
1303 RPointerArray<CNcdNodeMetaData> iNodeMetaDataCache; |
|
1304 |
|
1305 // This array is used to store nodes temporarily. |
|
1306 RPointerArray<CNcdNode> iTempNodeCache; |
|
1307 |
|
1308 // Array of client uid whose database is locked. |
|
1309 RArray<TInt32> iClientDatabaseLocks; |
|
1310 |
|
1311 // The message is set when ReceiveMessage is called. The message |
|
1312 // is used in the CounterPartLost-function that informs the message |
|
1313 // if the session has been lost. |
|
1314 MCatalogsBaseMessage* iMessage; |
|
1315 |
|
1316 MNcdConfigurationManager& iConfigurationManager; |
|
1317 |
|
1318 TLinearOrder<CNcdNode> iNodeOrder; |
|
1319 CNcdSearchableNode* iSearchableNode; |
|
1320 CNcdGeneralManager& iGeneralManager; |
|
1321 }; |
|
1322 |
|
1323 |
|
1324 #endif // NCD_NODE_MANAGER_H |