|
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 CNcdNodeManagerProxy class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef NCD_NODE_MANAGER_PROXY_H |
|
20 #define NCD_NODE_MANAGER_PROXY_H |
|
21 |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <e32cmn.h> |
|
25 |
|
26 #include "ncdbaseproxy.h" |
|
27 #include "ncdschemenodetype.h" |
|
28 |
|
29 |
|
30 class CNcdNodeProxy; |
|
31 class CNcdRootNodeProxy; |
|
32 class CNcdNodeFolderProxy; |
|
33 class CNcdOperationManagerProxy; |
|
34 class CNcdSubscriptionManagerProxy; |
|
35 class CNcdNodeIdentifier; |
|
36 class CNcdSearchRootNodeProxy; |
|
37 class CNcdProviderProxy; |
|
38 class CNcdExpiredNode; |
|
39 class MNcdPurchaseDetails; |
|
40 class CNcdFavoriteManagerProxy; |
|
41 |
|
42 /** |
|
43 * CNodeManagerProxy provides functions to ... |
|
44 * @lib ?library |
|
45 * @since S60 ?S60_version *** for example, S60 v3.0 |
|
46 */ |
|
47 class CNcdNodeManagerProxy : public CNcdBaseProxy |
|
48 { |
|
49 |
|
50 public: |
|
51 |
|
52 /** |
|
53 * NewL |
|
54 * |
|
55 * @return CNcdNodeManagerProxy* Pointer to the created object |
|
56 * of this class. |
|
57 */ |
|
58 static CNcdNodeManagerProxy* NewL( |
|
59 MCatalogsClientServer& aSession, |
|
60 TInt aHandle, |
|
61 CNcdOperationManagerProxy& aOperationManager, |
|
62 CNcdSubscriptionManagerProxy& aSubscriptionManager, |
|
63 CNcdProviderProxy& aProvider ); |
|
64 |
|
65 /** |
|
66 * NewLC |
|
67 * |
|
68 * @return CNcdNodeManagerProxy* Pointer to the created object |
|
69 * of this class. |
|
70 */ |
|
71 static CNcdNodeManagerProxy* NewLC( |
|
72 MCatalogsClientServer& aSession, |
|
73 TInt aHandle, |
|
74 CNcdOperationManagerProxy& aOperationManager, |
|
75 CNcdSubscriptionManagerProxy& aSubscriptionManager, |
|
76 CNcdProviderProxy& aProvider ); |
|
77 |
|
78 |
|
79 /** |
|
80 * Destructor |
|
81 * |
|
82 * Deletes the nodes from the node cache. |
|
83 */ |
|
84 virtual ~CNcdNodeManagerProxy(); |
|
85 |
|
86 |
|
87 public: // Functions to get nodes if they exist in the server side |
|
88 |
|
89 /** |
|
90 * Creates a node according to the given id. |
|
91 * If corresponding node has already been created, the old |
|
92 * one will be returned and new one is not created. |
|
93 * |
|
94 * @note If server side does not contain the node this function |
|
95 * will leave with KErrNotFound and does not return NULL in that case. |
|
96 * |
|
97 * @param |
|
98 * @return |
|
99 * @exeption Leaves with KErrNotFound If node did not exist. |
|
100 */ |
|
101 CNcdNodeProxy& NodeL( const CNcdNodeIdentifier& aNodeIdentifier ); |
|
102 |
|
103 |
|
104 public: // Functions that will create nodes in the server side if they do not |
|
105 // already exist. |
|
106 |
|
107 /** |
|
108 * Creates the root node. |
|
109 * If corresponding node has already been created, the old |
|
110 * one will be returned and new one is not created. |
|
111 * |
|
112 * @return |
|
113 */ |
|
114 CNcdRootNodeProxy& RootNodeL(); |
|
115 |
|
116 /** |
|
117 * Creates the search root node. |
|
118 * If corresponding node has already been created, the old |
|
119 * one will be returned and new one is not created. |
|
120 * |
|
121 * @return CNcdSearchRootNodeProxy& |
|
122 */ |
|
123 CNcdSearchRootNodeProxy& SearchRootNodeL(); |
|
124 |
|
125 |
|
126 /** |
|
127 * When aForceCreate is ETrue, function forces the server side to create a node |
|
128 * with the given id if the node is not found from the cache. |
|
129 * The node will not have any parent. If aForceCreate is EFalse, then |
|
130 * scheme node is returned only if it already exists or if the metadata exists |
|
131 * in RAM or database cache. The scheme node is added to favourites. |
|
132 * |
|
133 * @note If the corresponding node already exists, then instead of creating a |
|
134 * new node, the existing node is returned. |
|
135 * |
|
136 * @param aMetadataIdentifier |
|
137 * @param aRemoveOnDisconnect If true, the node is removed from favorites when the |
|
138 * client-server session is closed. |
|
139 * @param aType Type of the scheme node to create. |
|
140 * @param aForceCreate Determines if the node will always be created. |
|
141 * @return CNcdNodeProxy& |
|
142 * @exception Leave KErrNotFound if aForceCreate has been set as EFalse, |
|
143 * and the node was not created. |
|
144 */ |
|
145 CNcdNodeProxy& CNcdNodeManagerProxy::CreateSchemeNodeL( |
|
146 const CNcdNodeIdentifier& aMetadataIdentifier, |
|
147 TNcdSchemeNodeType aType, |
|
148 TBool aRemoveOnDisconnect, |
|
149 TBool aForceCreate ); |
|
150 |
|
151 |
|
152 /** |
|
153 * Forces the server side to create a temporary node by using the purchase details |
|
154 * information. If the node already exists in the cache then that node will be |
|
155 * returned. |
|
156 * This node will not be a child of any other node. So, it is up to user |
|
157 * what to do with the node. |
|
158 * |
|
159 * @note This function assumes that purchase details contain the information that |
|
160 * is required to initialize the metadata if it can not be found from the database or |
|
161 * from the cache. |
|
162 * |
|
163 * @param aDetails Purchase details are used to create correct form of the node. |
|
164 * @return CNcdNodeProxy& |
|
165 */ |
|
166 CNcdNodeProxy& CreateTemporaryNodeL( const MNcdPurchaseDetails& aDetails ); |
|
167 |
|
168 /** |
|
169 * Forces the server side to create a temporary node folder and inserts a metadata for it. |
|
170 * This node will not be a child of any other node. So, it is up to user |
|
171 * what to do with the node. |
|
172 * |
|
173 * @param aMetadataIdentifier |
|
174 * @param aCreateMetaData If true, this function will create a dummy metadata if the |
|
175 * metadata does not already exist. The dummy metadata initializes itself from the |
|
176 * purchase history if the purchase history contains corresponding info. |
|
177 * @return CNcdNodeProxy& |
|
178 */ |
|
179 CNcdNodeProxy& CreateTemporaryNodeFolderL( |
|
180 const CNcdNodeIdentifier& aMetadataIdentifier, |
|
181 TBool aCreateMetaData ); |
|
182 |
|
183 /** |
|
184 * This function works like CreateTemporaryNodeFolderL but cretes a bundle folder |
|
185 * instead. |
|
186 * |
|
187 * @see CNcdNodeManagerProxy::CreateTemporaryNodeFolderL |
|
188 */ |
|
189 CNcdNodeProxy& CreateTemporaryBundleFolderL( |
|
190 const CNcdNodeIdentifier& aMetadataIdentifier, |
|
191 TBool aCreateMetaData ); |
|
192 |
|
193 /** |
|
194 * This function works like CreateTemporaryNodeFolderL but cretes an item |
|
195 * instead. |
|
196 * |
|
197 * @see CNcdNodeManagerProxy::CreateTemporaryNodeFolderL |
|
198 */ |
|
199 CNcdNodeProxy& CreateTemporaryNodeItemL( |
|
200 const CNcdNodeIdentifier& aMetadataIdentifier, |
|
201 TBool aCreateMetaData ); |
|
202 |
|
203 /** |
|
204 * This function checks the node cache for the old temporary node. If the node exists it |
|
205 * will be used. If the node does not exist, the node will be created to server side |
|
206 * if the metadata exists there already. Correct type of the node is concluded from the |
|
207 * type of the metadata. If the metadata does not exist, the node is not created and |
|
208 * the function will leave. |
|
209 * |
|
210 * @param aMetadataIdentifier The metadata identifier. |
|
211 * @return The node. |
|
212 * @leave KErrNotFound If the node cannot be created since metadata does not exist. |
|
213 */ |
|
214 CNcdNodeProxy& CreateTemporaryNodeIfMetadataExistsL( |
|
215 const CNcdNodeIdentifier& aMetadataIdentifier ); |
|
216 |
|
217 /** |
|
218 * This function checks the node cache for the old node. If the node exists it will be used. |
|
219 * If the node does not exist, the node will be asked from the server side node manager. |
|
220 * Then, supplier node or temporary item or temporary folder proxy will be created. |
|
221 * |
|
222 * @note This function creates the supplier if the temporary node or corresponding metadata |
|
223 * did not exist in the server side cache or in db. Unlike temporary node functions above, |
|
224 * this function does not create the metadata if it does not exist in database. |
|
225 * |
|
226 * @note Supplier node will use CNcdNodeManagerProxy::ReplaceCacheNodeL to replace |
|
227 * the supplier node in cache, when temporary node can be created and used. |
|
228 * |
|
229 * @param aMetadataIdentifier |
|
230 */ |
|
231 CNcdNodeProxy& CreateTemporaryOrSupplierNodeL( const CNcdNodeIdentifier& aMetadataIdentifier ); |
|
232 |
|
233 /** |
|
234 * This function can be used if some node in cache list is |
|
235 * wanted to be replaced by the new proxy node. |
|
236 * This may the case if the original node type was not known |
|
237 * when the node was created as a supplier node. |
|
238 * After loading the node data from the web server, |
|
239 * a temporary node of the correct type is created in server side. |
|
240 * Then, that temporary node can be used instead. |
|
241 * |
|
242 * @note If the node is found from the server side, old node object is removed |
|
243 * from the proxy ram cache and replaced by the new node object of the same |
|
244 * node identifier. UI may still use the old node object |
|
245 * if it owns it but after calling this function the manager will |
|
246 * return pointer directly to the new node object instead. |
|
247 * |
|
248 * @param aNodeIdentifier The identifier of the node that will be replaced by the new |
|
249 * node object. |
|
250 * @return CNcdNodeProxy& |
|
251 * @exception Leaves with KErrNotFound if the node did not exist in |
|
252 * the server side. |
|
253 */ |
|
254 CNcdNodeProxy& ReplaceCacheNodeL( const CNcdNodeIdentifier& aNodeIdentifier ); |
|
255 |
|
256 |
|
257 public: |
|
258 |
|
259 /** |
|
260 * Checks if the node exists in the cache. |
|
261 * @param aNodeIdentifier identifies the node that is looked for. |
|
262 * @return CNcdNodeProxy* pointer to the node that can be found from |
|
263 * the cache. NULL if the node was not found. Ownership is NOT transferred. |
|
264 */ |
|
265 CNcdNodeProxy* NodeExists( const CNcdNodeIdentifier& aNodeIdentifier ) const; |
|
266 |
|
267 |
|
268 /** |
|
269 * This informs the manager that the given node is deleted. |
|
270 * Because the node is deleted, it has to be removed from the cache. |
|
271 * |
|
272 * @param aNode The node that was or will be deleted. |
|
273 */ |
|
274 void NodeDeleted( CNcdNodeProxy* aNode ); |
|
275 |
|
276 /** |
|
277 * This function internalizes the given node and all the nodes |
|
278 * whose metadata part of the identifier matches the given node. |
|
279 * The related nodes are gotten from the node cache of this |
|
280 * node manager proxy. This function is provided to make sure |
|
281 * that if operations use temporary nodes and the API user may |
|
282 * still have the handle to the original node, the operation may |
|
283 * also update the original nodes instead of just the temporary |
|
284 * one. |
|
285 * |
|
286 * @param aNode Node that will be internalized and used to |
|
287 * search for other related nodes for internalization. |
|
288 */ |
|
289 void InternalizeRelatedNodesL( CNcdNodeProxy& aNode ) const; |
|
290 |
|
291 /** |
|
292 * Getter for subscription manager. |
|
293 * |
|
294 * @return Reference to subscription manager. |
|
295 */ |
|
296 CNcdSubscriptionManagerProxy& SubscriptionManager() const; |
|
297 |
|
298 /** |
|
299 * Setter for favorite manager. This must be set always! |
|
300 * |
|
301 * @param aFavoriteManager The favorite manager. |
|
302 */ |
|
303 void SetFavoriteManager( CNcdFavoriteManagerProxy& aFavoriteManager ); |
|
304 |
|
305 /** |
|
306 * Clears all search result nodes. |
|
307 */ |
|
308 void ClearSearchResultsL(); |
|
309 |
|
310 |
|
311 /** |
|
312 * |
|
313 * @param aServerUri Server URI |
|
314 * @param aNamespace Namespace |
|
315 */ |
|
316 TBool IsCapabilitySupportedL( const CNcdNodeIdentifier& aNode, |
|
317 const TDesC& aCapability ); |
|
318 |
|
319 /** |
|
320 * Internalizes expired nodes and notifies api users via provider. |
|
321 * |
|
322 * @param aExpiredNodes A list of expired nodes in need of re-loading. |
|
323 */ |
|
324 void HandleExpiredNodesL( RPointerArray< CNcdExpiredNode >& aExpiredNodes ); |
|
325 |
|
326 |
|
327 /** |
|
328 * @return CNcdProviderProxy& Reference to the provider. |
|
329 */ |
|
330 CNcdProviderProxy& Provider() const; |
|
331 |
|
332 |
|
333 protected: |
|
334 |
|
335 /** |
|
336 * Constructor |
|
337 */ |
|
338 CNcdNodeManagerProxy( |
|
339 MCatalogsClientServer& aSession, |
|
340 TInt aHandle, |
|
341 CNcdOperationManagerProxy& aOperationManager, |
|
342 CNcdSubscriptionManagerProxy& aSubscriptionManager, |
|
343 CNcdProviderProxy& aProvider ); |
|
344 |
|
345 /** |
|
346 * ConstructL |
|
347 */ |
|
348 virtual void ConstructL(); |
|
349 |
|
350 |
|
351 private: |
|
352 |
|
353 // Prevent if not implemented |
|
354 CNcdNodeManagerProxy( const CNcdNodeManagerProxy& aObject ); |
|
355 CNcdNodeManagerProxy& operator =( const CNcdNodeManagerProxy& aObject ); |
|
356 |
|
357 /* |
|
358 CNcdNodeProxy& CNcdNodeManagerProxy::CreateSchemeNodeL( |
|
359 const CNcdNodeIdentifier& aMetadataIdentifier, |
|
360 TInt aFunctionId ); |
|
361 */ |
|
362 CNcdNodeProxy& CreateNodeL( const CNcdNodeIdentifier& aNodeIdentifier ); |
|
363 |
|
364 |
|
365 private: // data |
|
366 |
|
367 // This manager is required when nodes are created. |
|
368 // Because they should now the operation manager which |
|
369 // they use to ask and create operations. |
|
370 CNcdOperationManagerProxy& iOperationManager; |
|
371 |
|
372 // This manager is required when nodes are created. |
|
373 // Because their purchase should know the manager. |
|
374 CNcdSubscriptionManagerProxy& iSubscriptionManager; |
|
375 |
|
376 // This manager is required when nodes are create since |
|
377 // it must be given to all the nodes. Not own. |
|
378 CNcdFavoriteManagerProxy* iFavoriteManager; |
|
379 |
|
380 // This array contains all the nodes that have been created. |
|
381 RPointerArray<CNcdNodeProxy> iNodeCache; |
|
382 |
|
383 // Root node under which everything else is located. |
|
384 CNcdRootNodeProxy* iRootNode; |
|
385 |
|
386 // Search root node under which all search results are located. |
|
387 CNcdSearchRootNodeProxy* iSearchRootNode; |
|
388 |
|
389 // Needed for expiration callback |
|
390 CNcdProviderProxy& iProvider; |
|
391 }; |
|
392 |
|
393 |
|
394 #endif // NCD_NODE_MANAGER_PROXY_H |