|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_NCD_SUBSCRIPTION_OPERATION_H |
|
20 #define C_NCD_SUBSCRIPTION_OPERATION_H |
|
21 |
|
22 #include "ncdbaseoperation.h" |
|
23 #include "ncdoperationobserver.h" |
|
24 #include "ncdsubscriptionoperation.h" |
|
25 #include "ncdsubscriptionssourceidentifier.h" |
|
26 #include "ncdsubscriptionmanagerobserver.h" |
|
27 |
|
28 class MCatalogsAccessPointManager; |
|
29 class MNcdProtocol; |
|
30 class CNcdSubscriptionManager; |
|
31 class CNcdSubscription; |
|
32 class CNcdPurchaseOperationImpl; |
|
33 class MNcdConfigurationManager; |
|
34 |
|
35 |
|
36 /** |
|
37 * Subscription operation. |
|
38 */ |
|
39 class CNcdSubscriptionOperation : public CNcdBaseOperation, |
|
40 public MNcdParserObserver, |
|
41 public MNcdParserSubscriptionObserver, |
|
42 public MCatalogsHttpObserver, |
|
43 public MNcdSubscriptionManagerObserver |
|
44 { |
|
45 public: |
|
46 |
|
47 /** |
|
48 * Sub states of subscription operation |
|
49 */ |
|
50 enum TSubscriptionOperationState |
|
51 { |
|
52 EBegin, |
|
53 ERunning, |
|
54 EHandlingQueries, |
|
55 EComplete |
|
56 }; |
|
57 |
|
58 |
|
59 /** |
|
60 * NewL |
|
61 * Used for subscription refreshing. |
|
62 * |
|
63 * @since S60 v3.2 |
|
64 * @param aSubscriptionOperationType Type of the subscription operation. |
|
65 * @param aAccessPointManager Access point manager. |
|
66 * @param aSubscriptionManager Subscription manager. |
|
67 * @param aNodeManager Node manager. |
|
68 * @param aConfigurationManager Configuration manager. |
|
69 * @param aHttpSession HTTP session used for creating subscription |
|
70 * operations. |
|
71 * @param aProtocol Protocol is used to get parser. |
|
72 * @param aRemoveHandler Remove handler. |
|
73 * @param aSession Session. |
|
74 * @return Subscription operation. |
|
75 */ |
|
76 static CNcdSubscriptionOperation* NewL( |
|
77 MNcdSubscriptionOperation::TType aSubscriptionOperationType, |
|
78 CNcdGeneralManager& aGeneralManager, |
|
79 CNcdSubscriptionManager& aSubscriptionManager, |
|
80 MCatalogsHttpSession& aHttpSession, |
|
81 MNcdOperationRemoveHandler& aRemoveHandler, |
|
82 MCatalogsSession& aSession ); |
|
83 |
|
84 /** |
|
85 * NewLC |
|
86 * Used for subscription refreshing. |
|
87 * |
|
88 * @since S60 v3.2 |
|
89 * @param aSubscriptionOperationType Type of the subscription operation. |
|
90 * @param aAccessPointManager Access point manager. |
|
91 * @param aSubscriptionManager Subscription manager. |
|
92 * @param aNodeManager Node manager. |
|
93 * @param aConfigurationManager Configuration manager. |
|
94 * @param aHttpSession HTTP session used for creating subscription |
|
95 * operations. |
|
96 * @param aProtocol Protocol is used to get parser. |
|
97 * @param aRemoveHandler Remove handler. |
|
98 * @param aSession Session. |
|
99 * @return Subscription operation. |
|
100 */ |
|
101 static CNcdSubscriptionOperation* NewLC( |
|
102 MNcdSubscriptionOperation::TType aSubscriptionOperationType, |
|
103 CNcdGeneralManager& aGeneralManager, |
|
104 CNcdSubscriptionManager& aSubscriptionManager, |
|
105 MCatalogsHttpSession& aHttpSession, |
|
106 MNcdOperationRemoveHandler& aRemoveHandler, |
|
107 MCatalogsSession& aSession ); |
|
108 |
|
109 |
|
110 /** |
|
111 * NewL |
|
112 * Used for unsubscribing subscription. |
|
113 * |
|
114 * @since S60 v3.2 |
|
115 * @param aSubscriptionOperationType Type of the subscription operation. |
|
116 * @param aPurchaseOptionId Subscription purchase option ID. |
|
117 * @param aEntityId Subscription entity ID. |
|
118 * @param aNamespace Subscription namespace. |
|
119 * @param aServerUri Subscription server URI. |
|
120 * @param aAccessPointManager Access point manager. |
|
121 * @param aSubscriptionManager Subscription manager. |
|
122 * @param aNodeManager Node manager. |
|
123 * @param aConfigurationManager Configuration manager. |
|
124 * @param aHttpSession HTTP session used for creating subscription |
|
125 * operations. |
|
126 * @param aProtocol Protocol is used to get parser. |
|
127 * @param aRemoveHandler Remove handler. |
|
128 * @param aSession Session. |
|
129 * @return Subscription operation. |
|
130 */ |
|
131 static CNcdSubscriptionOperation* NewL( |
|
132 MNcdSubscriptionOperation::TType aSubscriptionOperationType, |
|
133 const TDesC& aPurchaseOptionId, |
|
134 const TDesC& aEntityId, |
|
135 const TDesC& aNamespace, |
|
136 const TDesC& aServerUri, |
|
137 CNcdGeneralManager& aGeneralManager, |
|
138 CNcdSubscriptionManager& aSubscriptionManager, |
|
139 MCatalogsHttpSession& aHttpSession, |
|
140 MNcdOperationRemoveHandler& aRemoveHandler, |
|
141 MCatalogsSession& aSession ); |
|
142 |
|
143 /** |
|
144 * NewLC |
|
145 * Used for unsubscribing subscription. |
|
146 * |
|
147 * @since S60 v3.2 |
|
148 * @param aSubscriptionOperationType Type of the subscription operation. |
|
149 * @param aPurchaseOptionId Subscription purchase option ID. |
|
150 * @param aEntityId Subscription entity ID. |
|
151 * @param aNamespace Subscription namespace. |
|
152 * @param aServerUri Subscription server URI. |
|
153 * @param aAccessPointManager Access point manager. |
|
154 * @param aSubscriptionManager Subscription manager. |
|
155 * @param aNodeManager Node manager. |
|
156 * @param aConfigurationManager Configuration manager. |
|
157 * @param aHttpSession HTTP session used for creating subscription |
|
158 * operations. |
|
159 * @param aProtocol Protocol is used to get parser. |
|
160 * @param aRemoveHandler Remove handler. |
|
161 * @param aSession Session. |
|
162 * @return Subscription operation. |
|
163 */ |
|
164 static CNcdSubscriptionOperation* NewLC( |
|
165 MNcdSubscriptionOperation::TType aSubscriptionOperationType, |
|
166 const TDesC& aPurchaseOptionId, |
|
167 const TDesC& aEntityId, |
|
168 const TDesC& aNamespace, |
|
169 const TDesC& aServerUri, |
|
170 CNcdGeneralManager& aGeneralManager, |
|
171 CNcdSubscriptionManager& aSubscriptionManager, |
|
172 MCatalogsHttpSession& aHttpSession, |
|
173 MNcdOperationRemoveHandler& aRemoveHandler, |
|
174 MCatalogsSession& aSession ); |
|
175 |
|
176 /** |
|
177 * Destructor |
|
178 */ |
|
179 ~CNcdSubscriptionOperation(); |
|
180 |
|
181 public: // From CNcdBaseOperation |
|
182 |
|
183 TInt RunOperation(); |
|
184 |
|
185 /** |
|
186 * @see CNcdBaseOperation::Cancel |
|
187 */ |
|
188 void Cancel(); |
|
189 |
|
190 |
|
191 /** |
|
192 * @see CNcdBaseOperation::QueryCompletedL |
|
193 */ |
|
194 TBool QueryCompletedL( CNcdQuery* aQuery ); |
|
195 |
|
196 public: // From MCatalogsHttpObserver |
|
197 |
|
198 /** |
|
199 * @see MCatalogsHttpObserver::HandleHttpEventL |
|
200 */ |
|
201 void HandleHttpEventL( |
|
202 MCatalogsHttpOperation& aOperation, |
|
203 TCatalogsHttpEvent aEvent ); |
|
204 |
|
205 /** |
|
206 * @see MCatalogsHttpObserver::HandleHttpError() |
|
207 */ |
|
208 TBool HandleHttpError( |
|
209 MCatalogsHttpOperation& aOperation, |
|
210 TCatalogsHttpError aError ); |
|
211 |
|
212 public: // From MNcdParserObserver |
|
213 |
|
214 /** |
|
215 * @see MNcdParserObserver::ParseError |
|
216 */ |
|
217 void ParseError( TInt aErrorCode ); |
|
218 |
|
219 /** |
|
220 * @see MNcdParserObserver::ParseCompleteL |
|
221 */ |
|
222 void ParseCompleteL( TInt aError ); |
|
223 |
|
224 public: // From MNcdParserSubscriptionObserver |
|
225 |
|
226 /** |
|
227 * see MNcdParserSubscriptionObserver::ValidSubscriptionL |
|
228 */ |
|
229 void ValidSubscriptionL( MNcdPreminetProtocolSubscription* aData ); |
|
230 |
|
231 /** |
|
232 * see MNcdParserSubscriptionObserver::OldSubscriptionL |
|
233 */ |
|
234 void OldSubscriptionL( MNcdPreminetProtocolSubscription* aData ); |
|
235 |
|
236 public: // From MNcdOperationObserver |
|
237 |
|
238 /** |
|
239 * @see MNcdOperationObserver::Progress |
|
240 */ |
|
241 void Progress( CNcdBaseOperation& aOperation ); |
|
242 |
|
243 /** |
|
244 * @see MNcdOperationObserver::QueryReceived |
|
245 */ |
|
246 void QueryReceived( CNcdBaseOperation& aOperation, |
|
247 CNcdQuery* aQuery ); |
|
248 |
|
249 /** |
|
250 * @see MNcdOperationObserver::OperationComplete |
|
251 */ |
|
252 void OperationComplete( CNcdBaseOperation* aOperation, |
|
253 TInt aError ); |
|
254 |
|
255 public: // From MNcdParserErrorObserver |
|
256 |
|
257 /** |
|
258 * @see MNcdParserErrorObserver::ErrorL |
|
259 */ |
|
260 void ErrorL( MNcdPreminetProtocolError* aData ); |
|
261 |
|
262 public: // From MNcdSubscriptionManagerObserver |
|
263 |
|
264 /** |
|
265 * @see MNcdSubscriptionManagerObserver:: |
|
266 * SubscriptionsInternalizeComplete |
|
267 */ |
|
268 void SubscriptionsInternalizeComplete( TInt aError ); |
|
269 |
|
270 private: |
|
271 |
|
272 /** |
|
273 * Creates operation for getting all subscriptions from one server. |
|
274 * |
|
275 * @since S60 v3.2 |
|
276 * @param aSubscriptionOperationType Type of the subscription. |
|
277 * @param aAccessPointManager Access point manager. |
|
278 * @param aSubscriptionManager Subscription manager. |
|
279 * @param aNodeManager Node manager. |
|
280 * @param aConfigurationManager Configuration manager. |
|
281 * @param aHttpSession HTTP session used for creating subscription |
|
282 * operations. |
|
283 * @param aProtocol Protocol is used to get parser. |
|
284 * @param aRemoveHandler Remove handler. |
|
285 * @param aSession Session. |
|
286 * @return Subscription operation. |
|
287 */ |
|
288 static CNcdSubscriptionOperation* CreateSubOperationLC( |
|
289 CNcdSubscriptionsSourceIdentifier* aSource, |
|
290 CNcdGeneralManager& aGeneralManager, |
|
291 CNcdSubscriptionManager& aSubscriptionManager, |
|
292 MCatalogsHttpSession& aHttpSession, |
|
293 MNcdOperationRemoveHandler& aRemoveHandler, |
|
294 MCatalogsSession& aSession ); |
|
295 |
|
296 /** |
|
297 * Start refresh operation. |
|
298 * |
|
299 * @since S60 v3.2 |
|
300 */ |
|
301 void RunRefreshOperationL(); |
|
302 |
|
303 |
|
304 /** |
|
305 * Start unsubscribe operation. |
|
306 * |
|
307 * @since S60 v3.2 |
|
308 */ |
|
309 void RunUnsubscribeOperationL(); |
|
310 |
|
311 /** |
|
312 * This must be called, when completing the operation. |
|
313 * |
|
314 * @since S60 v3.2 |
|
315 * @param aError Error information. |
|
316 * @return Error code. |
|
317 */ |
|
318 TInt SubscriptionOperationComplete( TInt aError ); |
|
319 |
|
320 /** |
|
321 * Completes current iPendingMessage with error value from |
|
322 * iCompletionErrorCode. Sets EStateComplete into |
|
323 * iOperationState. |
|
324 * |
|
325 * @since S60 v3.2 |
|
326 * @return Error code. |
|
327 */ |
|
328 TInt CompletePendingMessage(); |
|
329 |
|
330 /** |
|
331 * Removes the given subscription from phone cache and database. |
|
332 * |
|
333 * @param aSubscripion The subscription. |
|
334 */ |
|
335 void RemoveSubscriptionL(const CNcdSubscription& aSubscription ); |
|
336 |
|
337 |
|
338 /** |
|
339 * @see CNcdBaseOperation::ChangeToPreviousStateL(); |
|
340 */ |
|
341 void CNcdSubscriptionOperation::ChangeToPreviousStateL(); |
|
342 |
|
343 /** |
|
344 * Cancels the suboperations. |
|
345 */ |
|
346 void CancelSuboperations(); |
|
347 |
|
348 protected: |
|
349 |
|
350 /** |
|
351 * Contsructor. |
|
352 * |
|
353 * @since S60 v3.2 |
|
354 * @param aSubscriptionOperationType Type of the subscription. |
|
355 * @param aAccessPointManager Access point manager. |
|
356 * @param aSubscriptionManager Subscription manager. |
|
357 * @param aNodeManager Node manager. |
|
358 * @param aConfigurationManager Configuration manager. |
|
359 * @param aHttpSession HTTP session used for creating subscription |
|
360 * operations. |
|
361 * @param aProtocol Protocol is used to get parser. |
|
362 * @param aRemoveHandler Remove handler. |
|
363 * @param aSession Session. |
|
364 */ |
|
365 CNcdSubscriptionOperation( |
|
366 MNcdSubscriptionOperation::TType aSubscriptionOperationType, |
|
367 CNcdGeneralManager& aGeneralManager, |
|
368 CNcdSubscriptionManager& aSubscriptionManager, |
|
369 MCatalogsHttpSession& aHttpSession, |
|
370 MNcdOperationRemoveHandler& aRemoveHandler, |
|
371 MCatalogsSession& aSession ); |
|
372 |
|
373 /** |
|
374 * Contsructor. |
|
375 * |
|
376 * @param aSource Subscription source information. |
|
377 */ |
|
378 void ConstructL( |
|
379 CNcdSubscriptionsSourceIdentifier* aSource, |
|
380 const TDesC& aPurchaseOptionId, |
|
381 const TDesC& aEntityId, |
|
382 const TDesC& aNamespace, |
|
383 const TDesC& aServerUri ); |
|
384 |
|
385 |
|
386 private: |
|
387 |
|
388 /** |
|
389 * A sub-state of this operation's execution. |
|
390 */ |
|
391 TSubscriptionOperationState iSubscriptionOperationState; |
|
392 |
|
393 MNcdSubscriptionOperation::TType iSubscriptionOperationType; |
|
394 MCatalogsAccessPointManager& iAccessPointManager; |
|
395 CNcdSubscriptionManager& iSubscriptionManager; |
|
396 CNcdNodeManager& iNodeManager; |
|
397 MNcdConfigurationManager& iConfigurationManager; |
|
398 MCatalogsHttpSession& iHttpSession; |
|
399 MNcdProtocol& iProtocol; |
|
400 |
|
401 // Not own. |
|
402 const CNcdSubscription* iSubscription; |
|
403 |
|
404 MCatalogsHttpOperation* iTransaction; |
|
405 |
|
406 CNcdSubscriptionsSourceIdentifier* iSource; |
|
407 HBufC* iPurchaseOptionId; |
|
408 HBufC* iEntityId; |
|
409 HBufC* iNamespace; |
|
410 HBufC* iServerUri; |
|
411 |
|
412 RPointerArray<MNcdPreminetProtocolSubscription> iServersSubscriptions; |
|
413 |
|
414 RPointerArray<CNcdSubscriptionOperation> iSubOps; |
|
415 RPointerArray<CNcdSubscriptionOperation> iFailedSubOps; |
|
416 RPointerArray<CNcdSubscriptionOperation> iCompletedSubOps; |
|
417 |
|
418 TUid iClientUid; |
|
419 |
|
420 TInt iCompletionErrorCode; |
|
421 |
|
422 }; |
|
423 |
|
424 #endif // C_NCD_SUBSCRIPTION_OPERATION_H |