|
1 /* |
|
2 * Copyright (c) 2005 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: A task to update a Feed. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef UPDATE_FEED_TASK_H |
|
20 #define UPDATE_FEED_TASK_H |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 |
|
26 #include "FeedParserObserver.h" |
|
27 #include "LeakTracker.h" |
|
28 #include "LoadObserver.h" |
|
29 #include "Task.h" |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 // MACROS |
|
34 |
|
35 // DATA TYPES |
|
36 |
|
37 // FUNCTION PROTOTYPES |
|
38 |
|
39 // FORWARD DECLARATIONS |
|
40 class CIdle; |
|
41 class CFeedHandler; |
|
42 class CHttpConnection; |
|
43 class CPackedFeed; |
|
44 class CUrlHandler; |
|
45 |
|
46 // CLASS DECLARATION |
|
47 |
|
48 |
|
49 /** |
|
50 * The UpdateFeedTask's observer. |
|
51 * |
|
52 * \b Library: FeedsEngine.lib |
|
53 * |
|
54 * @since 3.0 |
|
55 */ |
|
56 class MUpdateFeedTaskObserver |
|
57 { |
|
58 public: |
|
59 /** |
|
60 * Notifies the observer that the task is about to start a lengthy |
|
61 * operation. In response the observer could display somekind of |
|
62 * status indicator. |
|
63 * |
|
64 * @since 3.0 |
|
65 * @return void. |
|
66 */ |
|
67 virtual void StartWait() = 0; |
|
68 |
|
69 /** |
|
70 * Called upon completion of the task. |
|
71 * |
|
72 * @since 3.0 |
|
73 * @param aPackedFeed The resulting feed. aPackedFeed is adopted by the |
|
74 * implementing class. |
|
75 * @param aFeedUrl The feed's url. |
|
76 * @param aStatusCode The completion status of the request. |
|
77 * @return Void |
|
78 */ |
|
79 virtual void Completed(CPackedFeed* aPackedFeed, const TDesC& aFeedUrl,TInt aFeedId, TInt aStatusCode) = 0; |
|
80 |
|
81 /** |
|
82 * Called upon start of the task. |
|
83 * |
|
84 * @since 3.1 |
|
85 * @param . |
|
86 * @return connection |
|
87 */ |
|
88 virtual CHttpConnection& HttpConnection() = 0; |
|
89 }; |
|
90 |
|
91 |
|
92 /** |
|
93 * A task to update a Feed. |
|
94 * |
|
95 * \b Library: FeedsEngine.lib |
|
96 * |
|
97 * @since 3.0 |
|
98 */ |
|
99 class CUpdateFeedTask: public CTask, public MLoadObserver, public MFeedParserObserver |
|
100 { |
|
101 public: // Constructors and destructor |
|
102 /** |
|
103 * Two-phased constructor. |
|
104 */ |
|
105 static CUpdateFeedTask* NewL(CFeedsServer& aFeedsServer, |
|
106 const TDesC& aUrl,TInt aFeedId, MUpdateFeedTaskObserver& aObserver); |
|
107 |
|
108 /** |
|
109 * Two-phased constructor. |
|
110 */ |
|
111 static CUpdateFeedTask* NewL(CFeedsServer& aFeedsServer, const TDesC& aUrl,TInt aFeedId, |
|
112 TDesC8* aFeedBuffer, MUpdateFeedTaskObserver& aObserver); |
|
113 |
|
114 /** |
|
115 * Destructor. |
|
116 */ |
|
117 virtual ~CUpdateFeedTask(); |
|
118 |
|
119 |
|
120 public: // From CTask |
|
121 /** |
|
122 * Starts the task. |
|
123 * |
|
124 * @since 3.0 |
|
125 * @return Void |
|
126 */ |
|
127 virtual void StartTaskL(); |
|
128 |
|
129 |
|
130 public: // From MLoadObserver |
|
131 /** |
|
132 * Notifies the observer that the UrlHandler is about to start a lengthy |
|
133 * operation. In response the observer could display somekind of |
|
134 * status indicator. |
|
135 * |
|
136 * @since 3.0 |
|
137 * @return void. |
|
138 */ |
|
139 virtual void StartWait(); |
|
140 |
|
141 /** |
|
142 * Passes the status code and responseBody to the observer. The observer |
|
143 * adopts aResponseBody. |
|
144 * |
|
145 * @since 3.0 |
|
146 * @param aStatusCode The status code - normalized to the http response codes. |
|
147 * @param aResponseBody The response body or NULL. |
|
148 * @param aContentType The content-type. |
|
149 * @param aCharSet The char-encoding. |
|
150 * @return void. |
|
151 */ |
|
152 virtual void LoadCompleted(TInt aStatusCode, TDesC8* aResponseBody, |
|
153 const TDesC& aContentType, const TDesC& aCharSet); |
|
154 |
|
155 |
|
156 public: // From MFeedParserObserver |
|
157 /** |
|
158 * The beginning of a feed was found. |
|
159 * |
|
160 * @since 3.1 |
|
161 * @return void. |
|
162 */ |
|
163 virtual void FeedBeginsL(); |
|
164 |
|
165 /** |
|
166 * The end of a feed was found. |
|
167 * |
|
168 * @since 3.1 |
|
169 * @return void. |
|
170 */ |
|
171 virtual void FeedEndsL(); |
|
172 |
|
173 /** |
|
174 * The beginning of a item was found. |
|
175 * |
|
176 * @since 3.1 |
|
177 * @return void. |
|
178 */ |
|
179 virtual void ItemBeginsL(); |
|
180 |
|
181 /** |
|
182 * The end of a item was found. |
|
183 * |
|
184 * @since 3.1 |
|
185 * @return void. |
|
186 */ |
|
187 virtual void ItemEndsL(); |
|
188 |
|
189 /** |
|
190 * The beginning of a enclosure was found. |
|
191 * |
|
192 * @since 3.1 |
|
193 * @return void. |
|
194 */ |
|
195 virtual void EnclosureBeginsL(); |
|
196 |
|
197 /** |
|
198 * The end of a enclosure was found. |
|
199 * |
|
200 * @since 3.1 |
|
201 * @return void. |
|
202 */ |
|
203 virtual void EnclosureEndsL(); |
|
204 |
|
205 /** |
|
206 * A attribute was found. This attribute should be applied to |
|
207 * the enclosing entity (Feed, Item, or Enclosure). |
|
208 * |
|
209 * @since 3.1 |
|
210 * @param aAttribute The attribute. |
|
211 * @param aValue The attribute's value. |
|
212 * @return void. |
|
213 */ |
|
214 virtual void AddAttributeL(TInt aAttribute, const TDesC& aValue); |
|
215 |
|
216 /** |
|
217 * An unimportant element was found. The client can use this |
|
218 * information for feed validation. |
|
219 * |
|
220 * @since 3.1 |
|
221 * @return void. |
|
222 */ |
|
223 virtual void OtherTitleL(); |
|
224 |
|
225 /** |
|
226 * An unimportant element was found. The client can use this |
|
227 * information for feed validation. |
|
228 * |
|
229 * @since 3.1 |
|
230 * @return void. |
|
231 */ |
|
232 virtual void OtherDescriptionL(); |
|
233 |
|
234 /** |
|
235 * An unimportant element was found. The client can use this |
|
236 * information for feed validation. |
|
237 * |
|
238 * @since 3.1 |
|
239 * @return void. |
|
240 */ |
|
241 virtual void OtherLinkL(); |
|
242 |
|
243 |
|
244 private: |
|
245 /** |
|
246 * C++ default constructor. |
|
247 */ |
|
248 CUpdateFeedTask(CFeedsServer& aFeedsServer, MUpdateFeedTaskObserver& aObserver); |
|
249 |
|
250 /** |
|
251 * By default Symbian 2nd phase constructor is private. |
|
252 */ |
|
253 void ConstructL(const TDesC& aUrl,TInt aFeedId); |
|
254 |
|
255 /** |
|
256 * Parses the buffer to the observer now that the callstack has unrolled. |
|
257 * |
|
258 * @since 3.0 |
|
259 * @param aPtr The this pointer. |
|
260 * @return Always returns EFalse. |
|
261 */ |
|
262 static TInt DelayedParse(TAny* aPtr); |
|
263 |
|
264 |
|
265 private: |
|
266 TLeakTracker iLeakTracker; |
|
267 |
|
268 MUpdateFeedTaskObserver& iObserver; |
|
269 CIdle* iIdle; |
|
270 |
|
271 CUrlHandler* iUrlHandler; |
|
272 TDesC* iUrl; |
|
273 TDesC8* iFileBuffer; |
|
274 |
|
275 CPackedFeed* iPackedFeed; |
|
276 TInt iFeedId; |
|
277 }; |
|
278 |
|
279 |
|
280 #endif // UPDATE_FEED_TASK_H |
|
281 |
|
282 // End of File |