|
1 /* |
|
2 * Copyright (c) 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 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: Class for handling mpx collection interactions* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #ifndef VCXNSDOWNLOADCLIENTHANDLER_H_ |
|
21 #define VCXNSDOWNLOADCLIENTHANDLER_H_ |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32std.h> |
|
25 #include <e32base.h> |
|
26 #include "CIptvUtil.h" |
|
27 #include <mpxcollectionobserver.h> |
|
28 |
|
29 #include "vcxnsdownloadupdater.h" |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class CVcxNsUiEngine; |
|
33 class CVcxNsService; |
|
34 class CVcxNsContent; |
|
35 class MMPXCollectionUtility; |
|
36 class CMPXMedia; |
|
37 |
|
38 /** |
|
39 * Class CVcxNsMpxCollectionClientHandler handles mpx collection client interactions. |
|
40 * |
|
41 * @lib vcxnsuiengine.lib |
|
42 */ |
|
43 class CVcxNsMpxCollectionClientHandler : public CBase, |
|
44 public MMPXCollectionObserver, |
|
45 public MVcxNsDownloadUpdaterObserver |
|
46 { |
|
47 |
|
48 public: |
|
49 |
|
50 /** |
|
51 * Two-phased constructor. |
|
52 * |
|
53 * @param aUiEngine Reference to CVcxNsUiEngine. |
|
54 */ |
|
55 static CVcxNsMpxCollectionClientHandler* NewL( CVcxNsUiEngine& aUiEngine ); |
|
56 |
|
57 /** |
|
58 * Destructor. |
|
59 */ |
|
60 virtual ~CVcxNsMpxCollectionClientHandler(); |
|
61 |
|
62 /** |
|
63 * Starts download of given item. |
|
64 * |
|
65 * @param aService Service data for downloaded iten |
|
66 * @param aContent Content data for downloaded item |
|
67 * @return System-wide error code |
|
68 */ |
|
69 TInt DownloadL( CVcxNsService& aService, CVcxNsContent& aContent ); |
|
70 |
|
71 /** |
|
72 * Pauses download of given item. |
|
73 * |
|
74 * @param aContent Content data for downloaded item |
|
75 * @return System-wide error code |
|
76 */ |
|
77 TInt PauseDownloadL( CVcxNsContent& aContent ); |
|
78 |
|
79 /** |
|
80 * Resume download of given item. |
|
81 * |
|
82 * @param aContent Content data for downloaded item |
|
83 * @return System-wide error code |
|
84 */ |
|
85 TInt ResumeDownloadL( CVcxNsContent& aContent ); |
|
86 |
|
87 /** |
|
88 * Cancels download of given item. |
|
89 * |
|
90 * @param aContent Content data for downloaded item |
|
91 * @return System-wide error code |
|
92 */ |
|
93 TInt CancelDownloadL( CVcxNsContent& aContent ); |
|
94 |
|
95 /** |
|
96 * Get mpx data from collection to resolve ongoing or completed downloads. |
|
97 */ |
|
98 void LoadMpxMediaObjectsL(); |
|
99 |
|
100 /** |
|
101 * Fetch single mpx object from collection. |
|
102 */ |
|
103 void LoadMpxMediaObjectL( TUint32 aMpxId ); |
|
104 |
|
105 /** |
|
106 * Store the mpx id to content database. |
|
107 * @param aContentId Target content id |
|
108 * @param aCaIndex Target content index |
|
109 * @param aMpxId Mpx media id |
|
110 */ |
|
111 void StoreMpxIdToEcgDbL( TUint32 aContentId, TUint32 aCaIndex, TUint32 aMpxId ); |
|
112 |
|
113 /** |
|
114 * Get the mpx media object by id. |
|
115 * @param aMpxIds |
|
116 */ |
|
117 void GetMediaByMpxIdReqL( RArray<TUint32>& aMpxIds ); |
|
118 |
|
119 /** |
|
120 * Append the given content to download list. |
|
121 * |
|
122 * @param aContent Content |
|
123 */ |
|
124 void AppendToDownloadList( CVcxNsContent* aContent ); |
|
125 |
|
126 /** |
|
127 * Remove the given content from download list. |
|
128 * |
|
129 * @param aContent Content |
|
130 */ |
|
131 void RemoveFromDownloadList( CVcxNsContent* aContent ); |
|
132 |
|
133 /** |
|
134 * Reset whole download list. |
|
135 * |
|
136 * @param aResetCmdsFromContentItems If ETrue, resets commands |
|
137 * from content items. |
|
138 */ |
|
139 void ResetDownloadList( TBool aResetCmdsFromContentItems ); |
|
140 |
|
141 /** |
|
142 * Find a comntent by url from download list. |
|
143 * @param aUri |
|
144 * @return Found content item or NULL |
|
145 */ |
|
146 CVcxNsContent* SearchFromDownloadList( const TDesC& aUri ); |
|
147 |
|
148 /** |
|
149 * Find a content by mpx id from download list. |
|
150 * @param aMpxId |
|
151 * @return Found content item or NULL |
|
152 */ |
|
153 CVcxNsContent* SearchFromDownloadList( const TUint32 aMpxId ); |
|
154 |
|
155 /** |
|
156 * MarkVideoAsWatchedL |
|
157 * @param aMpxId |
|
158 */ |
|
159 void MarkVideoAsWatchedL( const TUint32 aMpxId ); |
|
160 |
|
161 /** |
|
162 * SetlastPlayPosL |
|
163 * @param aMpxId Media id |
|
164 * @param aPos Play position |
|
165 */ |
|
166 void SetlastPlayPosL( const TUint32 aMpxId, TInt32 aPos ); |
|
167 |
|
168 /** |
|
169 * Gets media object details from collection SYNC |
|
170 * |
|
171 * @param aMpxId MPX Media ID, which to fetch. |
|
172 */ |
|
173 void GetMediaDetailsSyncL( TUint32 aMpxId ); |
|
174 |
|
175 // From Base classes |
|
176 |
|
177 /** |
|
178 * From MMPXCollectionObserver->MMPXCollectionMediaObserver |
|
179 * Handle extended media properties |
|
180 * |
|
181 * @param aMedia media |
|
182 * @param aError error code |
|
183 */ |
|
184 void HandleCollectionMediaL( const CMPXMedia& aMedia, TInt aError ); |
|
185 |
|
186 /** |
|
187 * From MMPXCollectionUtilityObserver. |
|
188 * Handle collection message |
|
189 * NOTE: only one of HandleCollectionMessage callback can be implemented |
|
190 * |
|
191 * @param aMsg collection message, ownership not transferred. |
|
192 * Please check aMsg is not NULL before using it. If aErr is not |
|
193 * KErrNone, plugin might still call back with more info in the aMsg. |
|
194 * @param aErr system error code. |
|
195 */ |
|
196 void HandleCollectionMessage( CMPXMessage* aMsg, TInt aErr ); |
|
197 |
|
198 /** |
|
199 * From MMPXCollectionUtilityObserver. |
|
200 * Handles the collection entries being opened. Typically called |
|
201 * when client has Open()'d a folder |
|
202 * |
|
203 * @param aEntries collection entries opened |
|
204 * @param aIndex focused entry |
|
205 * @param aComplete ETrue no more entries. EFalse more entries |
|
206 * expected |
|
207 * @param aError error code |
|
208 */ |
|
209 void HandleOpenL( const CMPXMedia& aEntries, |
|
210 TInt aIndex, TBool aComplete, TInt aError ); |
|
211 |
|
212 /** |
|
213 * From MMPXCollectionUtilityObserver. |
|
214 * Handles the item being opened. Typically called |
|
215 * when client has Open()'d an item. Client typically responds by |
|
216 * 'playing' the item via the playlist |
|
217 * |
|
218 * @param aPlaylist collection playlist |
|
219 * @param aError error code |
|
220 */ |
|
221 void HandleOpenL( const CMPXCollectionPlaylist& aPlaylist, TInt aError ); |
|
222 |
|
223 /** |
|
224 * From MMPXCollectionUtilityObserver. |
|
225 * Handle completion of a asynchronous command |
|
226 * All clients should implement this callback |
|
227 * @param aCommandResult result of the command, NULL if error |
|
228 * @param aError error code |
|
229 */ |
|
230 void HandleCommandComplete( CMPXCommand* aCommandResult, TInt aError ); |
|
231 |
|
232 /** |
|
233 * From MVcxNsDownloadUpdaterObserver |
|
234 * |
|
235 * Notify, that the object with given mpx id has |
|
236 * changed, and needs to be refreshed. |
|
237 */ |
|
238 void UpdateVideoObject( TUint32 aMpxId ); |
|
239 |
|
240 /** |
|
241 * From MVcxNsDownloadUpdaterObserver |
|
242 * |
|
243 * Notifies that resume has started from beginning. |
|
244 * @param aMpxId MPX Media Id of the video object. |
|
245 */ |
|
246 void ResumeStartedFromBeginningL( TUint32 aMpxId ); |
|
247 |
|
248 /** |
|
249 * Searches given array and marks the item identified by |
|
250 * iMarkAsWatchedId as watched. |
|
251 * |
|
252 * @param aArray media object array to be processed. |
|
253 */ |
|
254 void SearchAndMarkItemAsWatchedL( CMPXMediaArray* aArray ); |
|
255 |
|
256 /** |
|
257 * Marks the given media as watched. |
|
258 * |
|
259 * @param aMedia media object to be marked as watched. |
|
260 */ |
|
261 void MarkItemAsWatchedL( CMPXMedia* aMedia ); |
|
262 |
|
263 /** |
|
264 * Starts to play the given mpx media |
|
265 * |
|
266 * @param aMpxId Mpx Id |
|
267 */ |
|
268 void PlayVideoL( TUint32 aMpxId ); |
|
269 |
|
270 private: |
|
271 |
|
272 /** |
|
273 * Starts download of given item. |
|
274 * |
|
275 * @param aAddress Downloaded content's address |
|
276 * @param aName Downloaded content's name |
|
277 * @param aIapId Download iap id |
|
278 * @param aIsReadOnlyIap Is the given iap readonly |
|
279 * @param aUserName Downloaded content's username |
|
280 * @param aPassword Downloaded content's password |
|
281 * @param aTransactionId Download request transaction id |
|
282 * @return System-wide error code |
|
283 */ |
|
284 TInt DownloadL( const TDesC& aAddress, |
|
285 const TDesC& aName, |
|
286 TUint32 aIapId, |
|
287 TBool aIsReadOnlyIap, |
|
288 const TDesC& aUserName, |
|
289 const TDesC& aPassword, |
|
290 TUint32& aTransactionId ); |
|
291 |
|
292 /** |
|
293 * Links the mpx media objects to contents. |
|
294 * |
|
295 * @param aArray Mpx media array containing the data. |
|
296 */ |
|
297 void LinkMediaObjectsL( CMPXMediaArray* aArray ); |
|
298 |
|
299 /** |
|
300 * Sets the mpx media object to downloaded content |
|
301 * item and refreshes the content view, if visible. |
|
302 * |
|
303 * @param aMedia Mpx media containing the data. |
|
304 */ |
|
305 void SearchAndAddMpxMediaL( CMPXMedia* aMedia ); |
|
306 |
|
307 /** |
|
308 * Calls HandleSingleCollectionMessageL() for every message. |
|
309 * |
|
310 * @param aMessage collection message, ownership not transferred. |
|
311 * Please check aMsg is not NULL before using it. If aErr is not |
|
312 * KErrNone, plugin might still call back with more info in the aMsg. |
|
313 * @param aErr system error code. |
|
314 */ |
|
315 void ExplodeCollectionMessagesL( CMPXMessage* aMsg, TInt aErr ); |
|
316 |
|
317 /** |
|
318 * Handles one sinlgle message |
|
319 * |
|
320 * @param aMessage collection message, ownership not transferred. |
|
321 * Please check aMsg is not NULL before using it. If aErr is not |
|
322 * KErrNone, plugin might still call back with more info in the aMsg. |
|
323 * @param aErr system error code. |
|
324 */ |
|
325 void HandleSingleCollectionMessageL( CMPXMessage* aMsg, TInt aErr ); |
|
326 |
|
327 /** |
|
328 * HandleSingleCollectionMessage's implementation. |
|
329 * |
|
330 * Handle collection message |
|
331 * NOTE: only one of HandleCollectionMessage callback can be implemented |
|
332 * |
|
333 * @param aMessage collection message, ownership not transferred. |
|
334 * Please check aMsg is not NULL before using it. If aErr is not |
|
335 * KErrNone, plugin might still call back with more info in the aMsg. |
|
336 * @param aErr system error code. |
|
337 */ |
|
338 void DoHandleSingleCollectionMessageL( CMPXMessage* aMsg, TInt aErr ); |
|
339 |
|
340 /** |
|
341 * Handle mpx item changed -collection message |
|
342 * |
|
343 * @param aMessage collection message, ownership not transferred. |
|
344 * Please check aMsg is not NULL before using it. If aErr is not |
|
345 * KErrNone, plugin might still call back with more info in the aMsg. |
|
346 * @param aErr system error code. |
|
347 */ |
|
348 void HandleMpxItemChangedL( CMPXMessage* aMsg, TInt aErr ); |
|
349 |
|
350 |
|
351 /** |
|
352 * Copy ecg data to mpx database |
|
353 * |
|
354 * @param aContent Source content, where copy values from. |
|
355 * @param aMpxId Target media object id. |
|
356 */ |
|
357 void CopyEcgDataToMpxColL( CVcxNsContent *aContent, TUint32 aMpxId ); |
|
358 |
|
359 |
|
360 /** |
|
361 * Notify to ui client that a download has |
|
362 * failed and error note needs to be shown. |
|
363 * |
|
364 * @param aMedia media object, which download has failed. |
|
365 * @param aContent Details of the video content which download failed. |
|
366 */ |
|
367 void NotifyDownloadErrorL( CMPXMedia* aMedia, CVcxNsContent& aContent ); |
|
368 |
|
369 /** |
|
370 * Get VC error code out of S60 dmgr error codes. |
|
371 * |
|
372 * @param aMedia media object, which error code to get. |
|
373 * @return VideoCenter specific error code. |
|
374 */ |
|
375 TIptvDlError GetDownloadErrorL( CMPXMedia* aMedia ); |
|
376 |
|
377 /** |
|
378 * Writes given media attribute to mpx collection |
|
379 * |
|
380 * @param aAttribute Attribute |
|
381 * @param aValue Value |
|
382 * @param aMpxId Mpx item id to write |
|
383 */ |
|
384 void WriteAttrToColL( TMPXAttributeData aAttribute, |
|
385 TInt32 aValue, |
|
386 TUint32 aMpxId ); |
|
387 |
|
388 /** |
|
389 * Writes given media attribute to mpx collection |
|
390 * |
|
391 * @param aAttribute Attribute |
|
392 * @param aValue Value |
|
393 * @param aMpxId Mpx item id to write |
|
394 */ |
|
395 void WriteAttrToColL( TMPXAttributeData aAttribute, |
|
396 TReal32 aValue, |
|
397 TUint32 aMpxId ); |
|
398 |
|
399 /** |
|
400 * Writes changed media object attribute data to collection |
|
401 * |
|
402 * @param aMsg Media object containing changes, which to commit. |
|
403 */ |
|
404 void WriteMsgToColL( CMPXMedia* aMsg ); |
|
405 |
|
406 /** |
|
407 * Gets media object details from collection |
|
408 * |
|
409 * @param aMpxId MPX Media ID, which to fetch. |
|
410 */ |
|
411 void GetMediaDetailsL( TUint32 aMpxId ); |
|
412 |
|
413 /** |
|
414 * Constructor. |
|
415 * |
|
416 * @param aUiEngine Reference to CVcxNsUiEngine. |
|
417 */ |
|
418 CVcxNsMpxCollectionClientHandler( CVcxNsUiEngine& aUiEngine ); |
|
419 |
|
420 void ConstructL(); |
|
421 |
|
422 /** |
|
423 * Deletes download from Ui Engine. Called when item deleted event arrives from collection, |
|
424 * or when download cancel command completes (HandleCommandComplete). |
|
425 * |
|
426 * @param itemId Item to delete. |
|
427 */ |
|
428 void DeleteDownload( TMPXItemId itemId ); |
|
429 |
|
430 private: |
|
431 |
|
432 /** |
|
433 * Reference to CVcxNsUiEngine. |
|
434 * Not own. |
|
435 */ |
|
436 CVcxNsUiEngine& iUiEngine; |
|
437 |
|
438 /** |
|
439 * MMPXCollectionUtility* |
|
440 */ |
|
441 MMPXCollectionUtility* iCollectionUtility; |
|
442 |
|
443 /** |
|
444 * Id of most recent command sent to mpx collection. |
|
445 * Incremented after each cmd to keep 'em unique. |
|
446 */ |
|
447 TUint32 iLatestTransactionId; |
|
448 |
|
449 /** |
|
450 * The currently / previously downloaded contents. |
|
451 */ |
|
452 RPointerArray<CVcxNsContent> iDownloadedContents; |
|
453 |
|
454 /** |
|
455 * CVcxNsDownloadUpdater. |
|
456 * Own. |
|
457 */ |
|
458 CVcxNsDownloadUpdater* iDownloadUpdater; |
|
459 |
|
460 /** |
|
461 * Write pending play pos. |
|
462 */ |
|
463 TInt32 iWritePendingPlayPos; |
|
464 |
|
465 /** |
|
466 * Downloading has been resumed for these MPX IDs. Needed for showing |
|
467 * note "Resuming download not possible, download starts from beginning". |
|
468 */ |
|
469 RArray<TUint32> iResumeArray; |
|
470 |
|
471 /** |
|
472 * Last fetched mpx media objects |
|
473 */ |
|
474 RPointerArray<CMPXMedia> iLastFetchedMedias; |
|
475 |
|
476 /** |
|
477 * Wait for the async media fetch |
|
478 */ |
|
479 CActiveSchedulerWait* iGetMediaDetailWait; |
|
480 |
|
481 /** |
|
482 * Id for the media that needs to be marked as watched. |
|
483 */ |
|
484 TInt64 iMarkAsWatchedId; |
|
485 |
|
486 }; |
|
487 |
|
488 #endif // VCXNSDOWNLOADCLIENTHANDLER_H_ |