|
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: ?description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_NCD_NODE_PURCHASE_PROXY |
|
20 #define C_NCD_NODE_PURCHASE_PROXY |
|
21 |
|
22 #include <s32mem.h> |
|
23 #include <badesca.h> |
|
24 |
|
25 #include "ncdinterfacebaseproxy.h" |
|
26 #include "ncdnodepurchase.h" |
|
27 |
|
28 class CNcdNodeMetadataProxy; |
|
29 class CNcdPurchaseOptionProxy; |
|
30 class CNcdClientSubscribableContent; |
|
31 |
|
32 /** |
|
33 * Implementation of purchase-interface |
|
34 * |
|
35 * @see MNcdNodePurchase |
|
36 * Implementation of purchase-interface which acts also as |
|
37 * a proxy. |
|
38 * |
|
39 * @lib ?library |
|
40 * @since S60 ?S60_version *** for example, S60 v3.0 |
|
41 */ |
|
42 class CNcdNodePurchaseProxy : public CNcdInterfaceBaseProxy, |
|
43 public MNcdNodePurchase |
|
44 { |
|
45 |
|
46 |
|
47 |
|
48 public: |
|
49 |
|
50 |
|
51 /** |
|
52 * @param aSession The session between the client proxy and the |
|
53 * corresponding server object. |
|
54 * @param aHandle The handle which identifies the server object |
|
55 * that this proxy uses. |
|
56 * @param aMetadata Owns and uses the information of this proxy. |
|
57 * The metadata also keeps track of the refence counts of its objects. |
|
58 * And handles the deletion of these objects when the total reference |
|
59 * count reaches zero. |
|
60 * @return CNcdNodePurchaseProxy* Pointer to the created object |
|
61 * of this class. |
|
62 */ |
|
63 static CNcdNodePurchaseProxy* NewL( |
|
64 MCatalogsClientServer& aSession, |
|
65 TInt aHandle, |
|
66 CNcdNodeMetadataProxy& aMetadata ); |
|
67 |
|
68 /** |
|
69 * @param aSession The session between the client proxy and the |
|
70 * corresponding server object. |
|
71 * @param aHandle The handle which identifies the server object |
|
72 * that this proxy uses. |
|
73 * @param aMetadata Owns and uses the information of this proxy. |
|
74 * The metadata also keeps track of the refence counts of its objects. |
|
75 * And handles the deletion of these objects when the total reference |
|
76 * count reaches zero. |
|
77 * @return CNcdNodePurchaseProxy* Pointer to the created object |
|
78 * of this class. |
|
79 */ |
|
80 static CNcdNodePurchaseProxy* NewLC( |
|
81 MCatalogsClientServer& aSession, |
|
82 TInt aHandle, |
|
83 CNcdNodeMetadataProxy& aMetadata ); |
|
84 |
|
85 /** |
|
86 * Destructor. |
|
87 * The destructor is set public. So, the node that owns the PurchaseProxy may |
|
88 * delete it directly when the reference count of the node reaches zero |
|
89 * and the destructor of the node is called. |
|
90 */ |
|
91 virtual ~CNcdNodePurchaseProxy(); |
|
92 |
|
93 |
|
94 /** |
|
95 * This function is called to update proxy data. |
|
96 * The function uses the internalize functions. |
|
97 * |
|
98 * @since S60 ?S60_version |
|
99 */ |
|
100 void InternalizeL(); |
|
101 |
|
102 /** |
|
103 * This function is called to update proxy data related to |
|
104 * purchaseoptions. |
|
105 * The function uses the protected virtual internalize functions. |
|
106 * So, the child classes may provide their own implementations |
|
107 * for internalizations of certain data. |
|
108 * |
|
109 * @since S60 ?S60_version |
|
110 */ |
|
111 void InternalizeMeansL(); |
|
112 |
|
113 /** |
|
114 * This function is called to update proxy data related to |
|
115 * purchasehistory. |
|
116 * The function uses the protected virtual internalize functions. |
|
117 * So, the child classes may provide their own implementations |
|
118 * for internalizations of certain data. |
|
119 * |
|
120 * @since S60 ?S60_version |
|
121 */ |
|
122 void InternalizeHistoryL(); |
|
123 |
|
124 /** |
|
125 * @return CNcdNodeMetadataProxy& Gives the proxy that owns this class object. |
|
126 */ |
|
127 CNcdNodeMetadataProxy& Metadata() const; |
|
128 |
|
129 /** |
|
130 * Function to get subscribable content related to this |
|
131 * NodePurchase. |
|
132 * |
|
133 * @return Subscribable content if node is subscribable. |
|
134 * NULL otherwise. |
|
135 * |
|
136 * @since S60 ?S60_version |
|
137 */ |
|
138 const CNcdClientSubscribableContent* SubscribableContent() const; |
|
139 |
|
140 |
|
141 |
|
142 public: // from base class MNcdNodePurchase |
|
143 |
|
144 /** |
|
145 * From MNcdNodePurchase. |
|
146 * @see MNcdNodePurchase::PurchaseOptionsL |
|
147 */ |
|
148 virtual RCatalogsArray< MNcdPurchaseOption > PurchaseOptionsL() const; |
|
149 |
|
150 |
|
151 /** |
|
152 * From MNcdNodePurchase. |
|
153 * @see MNcdNodePurchase::PurchaseOptionL |
|
154 */ |
|
155 virtual MNcdPurchaseOption* PurchaseOptionL( |
|
156 const TDesC& aPurchaseOptionId ) const; |
|
157 |
|
158 |
|
159 /** |
|
160 * From MNcdNodePurchase. |
|
161 * @see MNcdNodePurchase::PurchaseL |
|
162 */ |
|
163 virtual MNcdPurchaseOperation* PurchaseL( |
|
164 MNcdPurchaseOption& aPurchaseOption, |
|
165 MNcdPurchaseOperationObserver& aObserver ); |
|
166 |
|
167 /** |
|
168 * From MNcdNodePurchase. |
|
169 * @see MNcdNodePurchase::IsPurchased |
|
170 */ |
|
171 virtual TBool IsPurchased() const; |
|
172 |
|
173 |
|
174 /** |
|
175 * From MNcdNodePurchase. |
|
176 * @see MNcdNodePurchase::PurchasedOptionL |
|
177 */ |
|
178 virtual MNcdPurchaseOption* PurchasedOptionL() const; |
|
179 |
|
180 |
|
181 /** |
|
182 * From MNcdNodePurchase. |
|
183 * @see MNcdNodePurchase::TimeOfPurchaseL |
|
184 */ |
|
185 virtual TTime TimeOfPurchaseL() const; |
|
186 |
|
187 |
|
188 /** |
|
189 * From MNcdNodePurchase. |
|
190 * @see MNcdNodePurchase::PurchasedPriceL |
|
191 */ |
|
192 virtual const TDesC& PurchasedPriceL() const; |
|
193 |
|
194 |
|
195 protected: |
|
196 |
|
197 /** |
|
198 * Constructor |
|
199 * |
|
200 * @param aSession The session between the client proxy and the |
|
201 * corresponding server object. |
|
202 * @param aHandle The handle which identifies the server object |
|
203 * that this proxy uses. |
|
204 * @param aMetadata Owns and uses the information of this proxy. |
|
205 * The metadata also keeps track of the refence counts of its objects. |
|
206 * And handles the deletion of these objects when the total reference |
|
207 * count reaches zero. |
|
208 * @return CNcdNodePurchaseProxy* Pointer to the created object |
|
209 * of this class. |
|
210 */ |
|
211 CNcdNodePurchaseProxy( |
|
212 MCatalogsClientServer& aSession, |
|
213 TInt aHandle, |
|
214 CNcdNodeMetadataProxy& aMetadata ); |
|
215 |
|
216 virtual void ConstructL(); |
|
217 |
|
218 /** |
|
219 * Function that does the actual internalization of |
|
220 * purchaseoption-related data for this proxy. |
|
221 * |
|
222 * @since S60 ?S60_version |
|
223 * @param aStream Stream where from data is internalized. |
|
224 */ |
|
225 virtual void InternalizeMeansDataL( RReadStream& aStream ); |
|
226 |
|
227 /** |
|
228 * Function that does the actual internalization of |
|
229 * purchasehistory-related data for this proxy. |
|
230 * |
|
231 * @since S60 ?S60_version |
|
232 * @param aStream Stream where from data is internalized. |
|
233 */ |
|
234 virtual void InternalizeHistoryDataL( RReadStream& aStream ); |
|
235 |
|
236 |
|
237 private: // new methods |
|
238 |
|
239 /** |
|
240 * Calls delete to purchaseoptions stored into this |
|
241 * class if there are no references left to them. |
|
242 * If references are left changes purchaseoption's state |
|
243 * to obsolete and removes the purchaseoption from the |
|
244 * purchaseoptions stored to this class. After this |
|
245 * the one that holds the reference to the |
|
246 * purchaseoption should destroy it by calling release. |
|
247 * |
|
248 * In the end resets the purchaseoption array. |
|
249 * |
|
250 * @since S60 ?S60_version |
|
251 */ |
|
252 void DeletePurchaseOptions(); |
|
253 |
|
254 /** |
|
255 * Resets purchasehistory related member variables. |
|
256 * |
|
257 * @since S60 ?S60_version |
|
258 */ |
|
259 void ResetHistoryData(); |
|
260 |
|
261 /** |
|
262 * Request the purchase option ids that exist in server side. |
|
263 * |
|
264 * @return Array of the purchase option ids. |
|
265 * @since S60 ?S60_version |
|
266 */ |
|
267 CDesCArray* RequestPurchaseOptionIdsL(); |
|
268 |
|
269 /** |
|
270 * Releases the purchase options that don't exist in the given |
|
271 * array. |
|
272 * |
|
273 * @param aPurchaseOptionIds Array of purchase option ids. |
|
274 * @since S60 ?S60_version |
|
275 */ |
|
276 void ReleaseMissingPurchaseOptions( |
|
277 const CDesCArray& aPurchaseOptionIds ); |
|
278 |
|
279 /** |
|
280 * Calls InternalizeL() for the current purchase options. |
|
281 * |
|
282 * @since S60 ?S60_version |
|
283 */ |
|
284 void InternalizeExistingPurchaseOptionsL(); |
|
285 |
|
286 /** |
|
287 * Internalizes the subscribable content and purchase options |
|
288 * defined in the given array. |
|
289 * |
|
290 * @param aPurchaseOptionIds Array of purchase option ids. |
|
291 * @since S60 ?S60_version |
|
292 */ |
|
293 void InternalizeMeansL( const CDesCArray& aPurchaseOptionIds ); |
|
294 |
|
295 /** |
|
296 * Tells whether there is a purchase option with the given id. |
|
297 * |
|
298 * @param aId The purchase option id. |
|
299 * @return True if the id exists, otherwise false. |
|
300 * @since S60 ?S60_version |
|
301 */ |
|
302 TBool HasPurchaseOption( const TDesC& aId ) const; |
|
303 |
|
304 private: // data |
|
305 |
|
306 /** |
|
307 * Array that holds purchaseOptions of related dataentity. |
|
308 * Because we use internal reference counting, we |
|
309 * don't use CatalogsArray which calls Release for the |
|
310 * objects stored in it when ResetAndRelease is called. |
|
311 */ |
|
312 RPointerArray<CNcdPurchaseOptionProxy> iPurchaseOptions; |
|
313 |
|
314 /** |
|
315 * Container for possible subscribable content info. Found |
|
316 * if this node has a purchase option for buying a subscription. |
|
317 * Used when buying a subscription. |
|
318 * Own. |
|
319 */ |
|
320 CNcdClientSubscribableContent* iSubscribableContent; |
|
321 |
|
322 /** |
|
323 * Whether the node is purchased or not. |
|
324 */ |
|
325 TBool iIsPurchased; |
|
326 |
|
327 /** |
|
328 * Purchase option id that identifies the purchase option |
|
329 * that was used to make the most recent purchase. |
|
330 */ |
|
331 HBufC* iPurchasedOptionId; |
|
332 |
|
333 /** |
|
334 * The time of the purchase if the node has been purchased. |
|
335 */ |
|
336 TTime iTimeOfPurchase; |
|
337 |
|
338 /** |
|
339 * The final price which was paid when the node was |
|
340 * purchased. That is, if it was purchased. |
|
341 */ |
|
342 HBufC* iPurchasedPrice; |
|
343 |
|
344 CNcdNodeMetadataProxy& iMetadata; |
|
345 |
|
346 }; |
|
347 |
|
348 |
|
349 |
|
350 #endif // C_NCD_NODE_PURCHASE_PROXY |