|
1 /* |
|
2 * Copyright (c) 2006-2008 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 CNcdNodeDependency class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef NCD_NODE_DEPENDENCY_H |
|
20 #define NCD_NODE_DEPENDENCY_H |
|
21 |
|
22 |
|
23 // For streams |
|
24 #include <s32mem.h> |
|
25 // For array |
|
26 #include <e32cmn.h> |
|
27 |
|
28 #include "ncdcommunicable.h" |
|
29 #include "ncdstoragedataitem.h" |
|
30 #include "ncdnodeclassids.h" |
|
31 #include "ncdproviderutils.h" |
|
32 #include "ncdinstallationservice.h" |
|
33 #include "ncdpurchasedownloadinfo.h" |
|
34 |
|
35 class MNcdPreminetProtocolDataEntity; |
|
36 class CNcdDependencyInfo; |
|
37 class CNcdNodeMetaData; |
|
38 class CNcdDownloadInfo; |
|
39 class MNcdPurchaseDetails; |
|
40 class CNcdPurchaseDetails; |
|
41 class MNcdPreminetProtocolEntityDependency; |
|
42 |
|
43 /** |
|
44 * This server side class contains the data and the functionality |
|
45 * that the proxy objects will use to internalize itself. |
|
46 * |
|
47 * This object should be added to the session. So, it will be usable |
|
48 * in the proxy side by using the handle gotten during addition. |
|
49 * The handle is used to identify to what object the proxy directs |
|
50 * the function call. When objects are added to sessions, |
|
51 * multiple handles may be gotten for the same object if addition is |
|
52 * done multiple times. |
|
53 * |
|
54 * @lib ?library |
|
55 * @since S60 ?S60_version *** for example, S60 v3.0 |
|
56 */ |
|
57 class CNcdNodeDependency : public CNcdCommunicable, |
|
58 public MNcdStorageDataItem |
|
59 { |
|
60 |
|
61 public: |
|
62 /** |
|
63 * NewL |
|
64 * |
|
65 * @param aParentMetaData Metadata that owns this class object. |
|
66 * @return CNcdNodeDependency* Pointer to the created object |
|
67 * of this class. |
|
68 */ |
|
69 static CNcdNodeDependency* NewL( CNcdNodeMetaData& aParentMetaData ); |
|
70 |
|
71 /** |
|
72 * NewLC |
|
73 * |
|
74 * @param aParentMetaData Metadata that owns this class object. |
|
75 * @return CNcdNodeDependency* Pointer to the created object |
|
76 * of this class. |
|
77 */ |
|
78 static CNcdNodeDependency* NewLC( CNcdNodeMetaData& aParentMetaData ); |
|
79 |
|
80 |
|
81 /** |
|
82 * Destructor |
|
83 * |
|
84 * @note Because this is CCatalogsCommunicable function the |
|
85 * session that owns this object should delete this class object. |
|
86 * So, instead of directly deleting this object from some other |
|
87 * class. Close-method should be used instead. |
|
88 */ |
|
89 virtual ~CNcdNodeDependency(); |
|
90 |
|
91 |
|
92 /** |
|
93 * Retrieves the data type that informs what class the data is for. |
|
94 * By checking the data type information, an InternalizeL function |
|
95 * of a right class can be called when the object data is set |
|
96 * from the storage. |
|
97 * The data type may be decided and set in a object that creates this |
|
98 * class object. |
|
99 * |
|
100 * @return NcdNodeClassIds::TNcdNodeClassId Describes the data type. |
|
101 */ |
|
102 NcdNodeClassIds::TNcdNodeClassId ClassId() const; |
|
103 |
|
104 |
|
105 /** |
|
106 * @return RPointerArray<CNcdDownloadInfo>& Contains list of content targets. |
|
107 * This list provides objects that contain information about the contents |
|
108 * that this class object may depend from. |
|
109 */ |
|
110 const RPointerArray<CNcdDownloadInfo>& ContentTargets() const; |
|
111 |
|
112 |
|
113 /** |
|
114 * @return RPointerArray<CNcdDependencyInfo>& Contains list of node targets. |
|
115 * This list provides objects that contain metadata ids and other information |
|
116 * of the nodes that this class object may depend on. |
|
117 */ |
|
118 const RPointerArray<CNcdDependencyInfo>& NodeTargets() const; |
|
119 |
|
120 |
|
121 /** |
|
122 * This function is called when the owner of this object |
|
123 * wants to internalize the content according to the data |
|
124 * that has been received from the parser. |
|
125 * |
|
126 * @param aData The data is set in the protocol parser and can |
|
127 * be used to initialize this class object. |
|
128 */ |
|
129 void InternalizeL( MNcdPreminetProtocolDataEntity& aData ); |
|
130 |
|
131 |
|
132 /** |
|
133 * Internalize from purchase history |
|
134 * |
|
135 * @param aDetails Purchase details |
|
136 */ |
|
137 TBool InternalizeFromPurchaseDetailsL( const MNcdPurchaseDetails& aDetails ); |
|
138 |
|
139 |
|
140 |
|
141 /** |
|
142 * Updates dependency states and checks if they are all installed |
|
143 * |
|
144 * @return ETrue if all dependencies are installed (upgrades may be available) |
|
145 */ |
|
146 TBool UpdateDependencyStatesL(); |
|
147 |
|
148 |
|
149 /** |
|
150 * Updates current dependencies to given purchase details |
|
151 */ |
|
152 void UpdateDependenciesL( CNcdPurchaseDetails& aDetails ) const; |
|
153 |
|
154 public: // MNcdStorageDataItem |
|
155 |
|
156 // These functions are used to get the data from and to insert the data |
|
157 // into the database using by the given stream. |
|
158 |
|
159 /** |
|
160 * @see MNcdStorageDataItem::ExternalizeL |
|
161 */ |
|
162 virtual void ExternalizeL( RWriteStream& aStream ); |
|
163 |
|
164 |
|
165 /** |
|
166 * @see MNcdStorageDataItem::InternalizeL |
|
167 */ |
|
168 virtual void InternalizeL( RReadStream& aStream ); |
|
169 |
|
170 |
|
171 public: // CCatalogsCommunicable |
|
172 |
|
173 /** |
|
174 * @see CCatalogsCommunicable::ReceiveMessage |
|
175 */ |
|
176 virtual void ReceiveMessage( MCatalogsBaseMessage* aMessage, |
|
177 TInt aFunctionNumber ); |
|
178 |
|
179 /** |
|
180 * @see CCatalogsCommunicable::CounterPartLost |
|
181 */ |
|
182 virtual void CounterPartLost( const MCatalogsSession& aSession ); |
|
183 |
|
184 |
|
185 protected: |
|
186 |
|
187 /** |
|
188 * Constructor |
|
189 * |
|
190 * @param aParentMetaData Metadata that owns this class object. |
|
191 * @param aClassId Identifies this class. |
|
192 * Is set in the NewLC function |
|
193 */ |
|
194 CNcdNodeDependency( CNcdNodeMetaData& aParentMetaData, |
|
195 NcdNodeClassIds::TNcdNodeClassId aClassId ); |
|
196 |
|
197 /** |
|
198 * ConstructL |
|
199 */ |
|
200 virtual void ConstructL(); |
|
201 |
|
202 |
|
203 // These functions are called from the ReceiveMessage when |
|
204 // the given function id has matched to the function. |
|
205 |
|
206 /** |
|
207 * This function is called when the proxy wants to get the |
|
208 * data from the serverside. This function calls the |
|
209 * InternalizeDataForRequestL which may be overloaded in the |
|
210 * child classes |
|
211 * @param aMessage Contains data from the proxy and can be used |
|
212 * to send data back to proxy |
|
213 */ |
|
214 void InternalizeRequestL( MCatalogsBaseMessage& aMessage ); |
|
215 |
|
216 /** |
|
217 * This function writes the object data to the stream. |
|
218 * The stream content will be sent to the proxy that requested the data. |
|
219 * Child classes should add their own data after this parent data. |
|
220 * @param aStream The data content of this class object will be written |
|
221 * into this stream. |
|
222 */ |
|
223 virtual void ExternalizeDataForRequestL( RWriteStream& aStream ); |
|
224 |
|
225 /** |
|
226 * This function is called from the proxy side when the proxy |
|
227 * is deleted. |
|
228 * @param aMessage Contains data from the proxy and can be used |
|
229 * to send data back to proxy |
|
230 */ |
|
231 void ReleaseRequest( MCatalogsBaseMessage& aMessage ) const; |
|
232 |
|
233 private: |
|
234 |
|
235 // Prevent these two if they are not implemented |
|
236 CNcdNodeDependency( const CNcdNodeDependency& aObject ); |
|
237 CNcdNodeDependency& operator =( const CNcdNodeDependency& aObject ); |
|
238 |
|
239 |
|
240 // Functions to help externalize and internalize data |
|
241 void ExternalizeNodeDependencyArrayL( RWriteStream& aStream ); |
|
242 void InternalizeNodeDependencyArrayL( RReadStream& aStream ); |
|
243 |
|
244 void ExternalizeContentDependencyArrayForRequestL( RWriteStream& aStream ); |
|
245 void ExternalizeContentDependencyArrayL( RWriteStream& aStream ); |
|
246 void InternalizeContentDependencyArrayL( RReadStream& aStream ); |
|
247 |
|
248 |
|
249 void MoveOldContentTargetsToNew(); |
|
250 |
|
251 // Updates the state of the dependency |
|
252 // Returns ETrue if the dependency is installed |
|
253 TBool UpdateDependencyStateL( CNcdDownloadInfo& aContentTarget ); |
|
254 |
|
255 // Sets content targets state |
|
256 // Returns ETrue if the aStatus indicates that the dependency |
|
257 // or a new version of it is installed |
|
258 TBool SetDependencyState( |
|
259 CNcdDownloadInfo& aContentTarget, |
|
260 TNcdApplicationStatus aStatus, |
|
261 TInt aVersionCompResult, |
|
262 TBool aIsUpgrade ); |
|
263 |
|
264 /** |
|
265 * Sets content usage depending on the dependency name |
|
266 * |
|
267 * @return ETrue if the dependency is a launcher application |
|
268 */ |
|
269 TBool SetContentUsage( |
|
270 const MNcdPreminetProtocolEntityDependency& aDependency, |
|
271 CNcdDownloadInfo& aTarget ) const; |
|
272 |
|
273 |
|
274 MNcdPurchaseDownloadInfo::TContentUsage DetermineContentUsage( |
|
275 const TDesC& aDependencyName ) const; |
|
276 |
|
277 private: // data |
|
278 |
|
279 // Metadata that owns this class object. |
|
280 CNcdNodeMetaData& iParentMetaData; |
|
281 |
|
282 // The class id identifies this class. The id may be used to identify |
|
283 // what kind of class object is created when data is gotten from the db. |
|
284 NcdNodeClassIds::TNcdNodeClassId iClassId; |
|
285 |
|
286 // The message is set when ReceiveMessage is called. The message |
|
287 // is used in the CounterPartLost-function that informs the message |
|
288 // if the session has been lost. |
|
289 MCatalogsBaseMessage* iMessage; |
|
290 |
|
291 RPointerArray<CNcdDependencyInfo> iDependencyNodeTargets; |
|
292 RPointerArray<CNcdDownloadInfo> iDependencyContentTargets; |
|
293 |
|
294 // Dependency content targets internalized from purchase history |
|
295 // exist only if the item has been bought before, used for |
|
296 // checking upgrade status |
|
297 RPointerArray<CNcdDownloadInfo> iOldDependencyContentTargets; |
|
298 |
|
299 }; |
|
300 |
|
301 #endif // NCD_NODE_DEPENDENCY_H |