|
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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_NCDPURCHASEOPERATIONIMPL_H |
|
20 #define C_NCDPURCHASEOPERATIONIMPL_H |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 #include "ncdbaseoperation.h" |
|
25 #include "ncdparserobserver.h" |
|
26 #include "catalogshttpobserver.h" |
|
27 #include "catalogssmsobserver.h" |
|
28 |
|
29 class MNcdParser; |
|
30 class MNcdProtocol; |
|
31 class CNcdNodeManager; |
|
32 class CNcdPurchaseHistoryDb; |
|
33 class MCatalogsSmsSession; |
|
34 class CNcdNode; |
|
35 class CNcdPreminetProtocolPurchaseInformationImpl; |
|
36 class CNcdPreminetProtocolPurchaseProcessedImpl; |
|
37 class MCatalogsAccessPointManager; |
|
38 |
|
39 class CNcdPurchaseOptionImpl; |
|
40 |
|
41 class MNcdPreminetProtocolPayment; |
|
42 class MNcdOperationRemoveHandler; |
|
43 |
|
44 class CNcdSubscriptionManager; |
|
45 class CNcdDelay; |
|
46 class MNcdConfigurationProtocolQuery; |
|
47 class CNcdNodeIdentifier; |
|
48 class CNcdDownloadInfo; |
|
49 class CNcdPurchaseDetails; |
|
50 class CNcdNodeMetaData; |
|
51 class CNcdKeyValuePair; |
|
52 |
|
53 |
|
54 /** |
|
55 * Purchase operation implementation. |
|
56 * |
|
57 * @lib ?library |
|
58 * @since S60 ?S60_version *** for example, S60 v3.0 |
|
59 */ |
|
60 class CNcdPurchaseOperationImpl : public CNcdBaseOperation, |
|
61 public MNcdParserObserver, |
|
62 public MNcdParserPurchaseObserver, |
|
63 public MCatalogsHttpObserver, |
|
64 public MCatalogsSmsObserver |
|
65 { |
|
66 |
|
67 public: |
|
68 |
|
69 /** |
|
70 * Sub states of purchase operation |
|
71 */ |
|
72 enum TPurchaseOperationState |
|
73 { |
|
74 EBegin, |
|
75 EPurchaseRequestSent, |
|
76 EPurchaseInformationReceived, |
|
77 EPurchaseRequestResent, |
|
78 EDisclaimerQueried, |
|
79 EPaymentMethodsQueried, |
|
80 EPaymentInformationQueried, |
|
81 EPaymentProcessed, |
|
82 EPurchaseConfirmationSent, |
|
83 EDownloadDetailsReceived, |
|
84 EPurchaseComplete, |
|
85 EFailed |
|
86 }; |
|
87 |
|
88 enum TPurchaseRequestType |
|
89 { |
|
90 EPurchaseRequest, |
|
91 EPurchaseConfirmation |
|
92 }; |
|
93 |
|
94 |
|
95 static CNcdPurchaseOperationImpl* NewL( |
|
96 const TDesC& aNameSpace, |
|
97 const TDesC& aNodeId, |
|
98 const TUid& aClientUid, |
|
99 const TDesC& aPurchaseOptionId, |
|
100 CNcdGeneralManager& aGeneralManager, |
|
101 MCatalogsHttpSession& aHttpSession, |
|
102 MCatalogsSmsSession& aSmsSession, |
|
103 CNcdSubscriptionManager& aSubscriptionManager, |
|
104 MNcdOperationRemoveHandler* aRemoveHandler, |
|
105 MCatalogsSession& aSession ); |
|
106 |
|
107 static CNcdPurchaseOperationImpl* NewLC( |
|
108 const TDesC& aNameSpace, |
|
109 const TDesC& aNodeId, |
|
110 const TUid& aClientUid, |
|
111 const TDesC& aPurchaseOptionId, |
|
112 CNcdGeneralManager& aGeneralManager, |
|
113 MCatalogsHttpSession& aHttpSession, |
|
114 MCatalogsSmsSession& aSmsSession, |
|
115 CNcdSubscriptionManager& aSubscriptionManager, |
|
116 MNcdOperationRemoveHandler* aRemoveHandler, |
|
117 MCatalogsSession& aSession ); |
|
118 |
|
119 virtual ~CNcdPurchaseOperationImpl(); |
|
120 |
|
121 public: // New functions |
|
122 |
|
123 /** |
|
124 * Call back function used in resend after case. |
|
125 * |
|
126 * @param aOperation The operation called in the function. |
|
127 */ |
|
128 static TInt ResendAfterCallBack( TAny* aOperation ); |
|
129 |
|
130 /** |
|
131 * Returns the identifier of the node that this operation relates to. |
|
132 * |
|
133 * @return Node identifier. |
|
134 */ |
|
135 const CNcdNodeIdentifier& NodeIdentifier() const; |
|
136 |
|
137 |
|
138 public: // from base class CNcdBaseOperation |
|
139 |
|
140 /** |
|
141 * @see CNcdBaseOperation::Cancel |
|
142 */ |
|
143 virtual void Cancel(); |
|
144 |
|
145 /** |
|
146 * @see CNcdBaseOperation::QueryCompletedL |
|
147 */ |
|
148 virtual TBool QueryCompletedL( CNcdQuery* aQuery ); |
|
149 |
|
150 public: // from base class MCatalogsHttpObserver |
|
151 |
|
152 /** |
|
153 * @see MCatalogsHttpObserver::HandleHttpEventL |
|
154 */ |
|
155 |
|
156 virtual void HandleHttpEventL( |
|
157 MCatalogsHttpOperation& aOperation, |
|
158 TCatalogsHttpEvent aEvent ); |
|
159 |
|
160 /** |
|
161 * @see MCatalogsHttpObserver::HandleHttpError() |
|
162 */ |
|
163 virtual TBool HandleHttpError( |
|
164 MCatalogsHttpOperation& aOperation, |
|
165 TCatalogsHttpError aError ); |
|
166 |
|
167 public: // from base class MCatalogsSmsObserver |
|
168 |
|
169 /** |
|
170 * @see MCatalogsSmsObserver::HandleSmsEvent() |
|
171 */ |
|
172 virtual TInt HandleSmsEvent( |
|
173 MCatalogsSmsOperation& aOperation, |
|
174 TCatalogsSmsEvent aEvent ); |
|
175 |
|
176 public: // from MNcdParserQueryObserver |
|
177 |
|
178 /** |
|
179 * @see MNcdParserQueryObserver |
|
180 */ |
|
181 virtual void QueryL( MNcdConfigurationProtocolQuery* aData ); |
|
182 |
|
183 |
|
184 |
|
185 public: // from base class MNcdParserObserver |
|
186 |
|
187 /** |
|
188 * @see MNcdParserObserver |
|
189 */ |
|
190 virtual void ParseError( TInt aErrorCode ); |
|
191 |
|
192 /** |
|
193 * @see MNcdParserObserver |
|
194 */ |
|
195 virtual void ParseCompleteL( TInt aError ); |
|
196 |
|
197 public: // from base class MNcdParserPurchaseObserver |
|
198 |
|
199 /** |
|
200 * @see MNcdParserPurchaseObserver::InformationL |
|
201 */ |
|
202 virtual void InformationL( MNcdPreminetProtocolPurchaseInformation* aData ); |
|
203 |
|
204 /** |
|
205 * @see MNcdParserPurchaseObserver::ProcessedL |
|
206 */ |
|
207 virtual void ProcessedL( MNcdPreminetProtocolPurchaseProcessed* aData ); |
|
208 |
|
209 public: // from base class MNcdParserInformationObserver |
|
210 |
|
211 virtual void InformationL( |
|
212 MNcdPreminetProtocolInformation* aData ); |
|
213 |
|
214 public: // from base class MNcdParserErrorObserver |
|
215 |
|
216 virtual void ErrorL( MNcdPreminetProtocolError* aData ); |
|
217 |
|
218 |
|
219 |
|
220 protected: |
|
221 |
|
222 CNcdPurchaseOperationImpl( |
|
223 CNcdGeneralManager& aGeneralManager, |
|
224 MCatalogsHttpSession& aHttpSession, |
|
225 MCatalogsSmsSession& aSmsSession, |
|
226 CNcdSubscriptionManager& aSubscriptionManager, |
|
227 MNcdOperationRemoveHandler* aRemoveHandler, |
|
228 MCatalogsSession& aSession ); |
|
229 |
|
230 |
|
231 void ConstructL( |
|
232 const TDesC& aNameSpace, |
|
233 const TDesC& aNodeId, |
|
234 const TUid& aClientUid, |
|
235 const TDesC& aPurchaseOptionId ); |
|
236 |
|
237 |
|
238 public: // from base class CNcdBaseOperation |
|
239 |
|
240 /** |
|
241 * @see CNcdBaseOperation::RunOperation |
|
242 */ |
|
243 virtual TInt RunOperation(); |
|
244 |
|
245 void DoRunOperationL(); |
|
246 |
|
247 /** |
|
248 * @see CNcdBaseOperation::RunOperation |
|
249 */ |
|
250 virtual void ChangeToPreviousStateL(); |
|
251 |
|
252 |
|
253 private: |
|
254 |
|
255 HBufC8* CreatePurchaseRequestLC( TPurchaseRequestType aType, |
|
256 const TDesC& aServerUri ); |
|
257 |
|
258 void SendRequestL( const TDesC& aServerUri, const TDesC8& aData ); |
|
259 |
|
260 void ProcessSmsPaymentL(); |
|
261 |
|
262 void UpdatePurchaseHistoryL(); |
|
263 |
|
264 // Copies relevant info from CNcdNodeContentInfo to given purchase details |
|
265 void SetContentInfoToPurchaseDetailsL( |
|
266 CNcdPurchaseDetails& aDetails, |
|
267 const CNcdNodeMetaData& aMetadata ) const; |
|
268 |
|
269 void HandleDependenciesL( CNcdPurchaseDetails& aDetails ); |
|
270 |
|
271 void AddDownloadInfosToDetailsL( CNcdPurchaseDetails& aDetails, |
|
272 const RPointerArray<CNcdDownloadInfo>& aInfos ); |
|
273 |
|
274 TInt RemovePendingSmsOp( const TCatalogsTransportOperationId& aId ); |
|
275 |
|
276 TInt StartResendAfterTimer(); |
|
277 |
|
278 private: // data |
|
279 |
|
280 /** |
|
281 * A sub-state of this operation's execution. |
|
282 */ |
|
283 TPurchaseOperationState iPurchaseOperationState; |
|
284 |
|
285 /** |
|
286 * Reference to the access point manager. |
|
287 * Not owned by the purchase operation. |
|
288 */ |
|
289 MCatalogsAccessPointManager& iAccessPointManager; |
|
290 |
|
291 /** |
|
292 * Not own. |
|
293 */ |
|
294 CNcdPurchaseHistoryDb* iPurchaseHistory; |
|
295 |
|
296 /** |
|
297 * Http session for sending requests and receiving responses. |
|
298 * Not owned by the purchase operation. |
|
299 */ |
|
300 MCatalogsHttpSession& iHttpSession; |
|
301 |
|
302 /** |
|
303 * Sms session for sending requests and receiving responses. |
|
304 * Not owned by the purchase operation. |
|
305 */ |
|
306 MCatalogsSmsSession* iSmsSession; |
|
307 |
|
308 /** |
|
309 * Protocol. |
|
310 * Not owned by the purchase operation. |
|
311 */ |
|
312 MNcdProtocol& iProtocol; |
|
313 |
|
314 /** |
|
315 * Http operation for current transaction. |
|
316 * Not owned by the purchase operation. |
|
317 */ |
|
318 MCatalogsHttpOperation* iHttpTransaction; |
|
319 |
|
320 /** |
|
321 * Subscription manager. |
|
322 * Not owned by the purchase operation. |
|
323 */ |
|
324 CNcdSubscriptionManager& iSubscriptionManager; |
|
325 |
|
326 |
|
327 CNcdPurchaseOptionImpl* iSelectedPurchaseOption; |
|
328 const MNcdPreminetProtocolPayment* iSelectedPaymentMethod; |
|
329 |
|
330 |
|
331 /** |
|
332 * |
|
333 * Not own. |
|
334 */ |
|
335 CNcdNode* iNode; |
|
336 |
|
337 /** |
|
338 * Node identifier of the node to purchase. |
|
339 */ |
|
340 CNcdNodeIdentifier* iNodeIdentifier; |
|
341 |
|
342 /** |
|
343 * Purchase option id. Used in subscription renew. |
|
344 */ |
|
345 HBufC* iPurchaseOptionId; |
|
346 |
|
347 |
|
348 MNcdPreminetProtocolPurchaseInformation* iPurchaseInformationData; |
|
349 MNcdPreminetProtocolPurchaseProcessed* iPurchaseProcessedData; |
|
350 |
|
351 RPointerArray<MCatalogsSmsOperation> iPendingSmsOperations; |
|
352 |
|
353 /** |
|
354 * Purchase query. |
|
355 */ |
|
356 CNcdQuery* iPurchaseQuery; |
|
357 |
|
358 TBool iLocked; |
|
359 |
|
360 CNcdDelay* iDelay; |
|
361 |
|
362 // Key() is address and Value() is message |
|
363 CNcdKeyValuePair* iSmsRegistrationRequest; |
|
364 |
|
365 HBufC* iRedirectUri; |
|
366 |
|
367 // Time after which the purchase request is resent |
|
368 TInt iResendAfter; |
|
369 }; |
|
370 |
|
371 #endif // C_NCDPURCHASEOPERATIONIMPL_H |