1 /* |
|
2 * Copyright (c) 2002 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 the License "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: Declaration of PushMtmAutoFetchOperation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef PUSHMTMAUTOFETCHOPERATION_H |
|
21 #define PUSHMTMAUTOFETCHOPERATION_H |
|
22 |
|
23 // INCLUDE FILES |
|
24 |
|
25 #include <e32base.h> |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 |
|
29 class CPushMtmFetchOperation; |
|
30 |
|
31 // CLASS DECLARATION |
|
32 |
|
33 /** |
|
34 * Asynchronous fetch operation that runs in silent mode and in addition to the |
|
35 * services of CPushMtmFetchOperation it retries downloading of the indicated |
|
36 * service if the first try fails. |
|
37 */ |
|
38 class CPushMtmAutoFetchOperation : public CActive |
|
39 { |
|
40 public: // Constructors and destructor |
|
41 |
|
42 /** |
|
43 * Two-phased constructor. Leaves on failure. |
|
44 * @param aRequestedUrl The requested URL. |
|
45 * @param aTimeDelayInSec Time delay between fetches in seconds. |
|
46 * @param aObserverRequestStatus Completion status. |
|
47 * @return The constructed client. |
|
48 */ |
|
49 static CPushMtmAutoFetchOperation* NewL |
|
50 ( |
|
51 const TDesC& aRequestedUrl, |
|
52 TInt aTimeDelayInSec, |
|
53 TRequestStatus& aObserverRequestStatus |
|
54 ); |
|
55 |
|
56 /** |
|
57 * Destructor. |
|
58 */ |
|
59 virtual ~CPushMtmAutoFetchOperation(); |
|
60 |
|
61 public: // Functions from base classes |
|
62 |
|
63 /** |
|
64 * Start or restart the operation. |
|
65 */ |
|
66 void StartL(); |
|
67 |
|
68 protected: // Constructors |
|
69 |
|
70 /** |
|
71 * Constructor. |
|
72 * @param aTimeDelayInSec Time delay between fetches in seconds. |
|
73 * @param aObserverRequestStatus Completion status. |
|
74 */ |
|
75 CPushMtmAutoFetchOperation( TInt aTimeDelayInSec, |
|
76 TRequestStatus& aObserverRequestStatus ); |
|
77 |
|
78 /** |
|
79 * Second phase constructor. |
|
80 * @param aRequestedUrl The requested URL. |
|
81 */ |
|
82 void ConstructL( const TDesC& aRequestedUrl ); |
|
83 |
|
84 protected: // New functions |
|
85 |
|
86 /** |
|
87 * Issue fetching. |
|
88 */ |
|
89 void FetchL(); |
|
90 |
|
91 protected: // Functions from base classes |
|
92 |
|
93 /** |
|
94 * Cancel fetching. |
|
95 * @return None. |
|
96 */ |
|
97 void DoCancel(); |
|
98 |
|
99 /** |
|
100 * Start fetching and make an entry into the operation mapper. |
|
101 * @return None. |
|
102 */ |
|
103 void RunL(); |
|
104 |
|
105 /** |
|
106 * Leave handler protocol implementation: it is called when |
|
107 * RunL leaves. |
|
108 */ |
|
109 TInt RunError( TInt aError ); |
|
110 |
|
111 protected: // Data |
|
112 |
|
113 TRequestStatus& iObserver; ///< Observer's status. |
|
114 HBufC* iRequestedUrl; ///< Request URI or NULL. Owned. |
|
115 |
|
116 enum TState ///< State. |
|
117 { |
|
118 EInit, ///< Initial state. |
|
119 EFetch, ///< Fetch. |
|
120 ECheck, ///< Check the result of the fetching. |
|
121 EDone ///< Operation done. |
|
122 }; |
|
123 |
|
124 TState iState; ///< Current state of the state machine. |
|
125 |
|
126 /// The operation that does downloading. Owned. |
|
127 CPushMtmFetchOperation* iFetchOp; |
|
128 RTimer iTimer; ///< Timer for waiting. |
|
129 TInt iTimeDelayInSec; ///< Time delay between downloadings in seconds. |
|
130 TInt iTry; ///< How many times we have tried downloading so far? |
|
131 }; |
|
132 |
|
133 #endif // PUSHMTMAUTOFETCHOPERATION_H |
|
134 |
|
135 // End of file. |
|