|
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: VoD download API* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CIPTVVODDLCLIENT_H |
|
21 #define CIPTVVODDLCLIENT_H |
|
22 |
|
23 #include <e32base.h> |
|
24 #include "CIptvUtil.h" |
|
25 #include "IptvEngineUids.h" |
|
26 |
|
27 #include "CIptvClientBase.h" |
|
28 #include "CIptvMyVideosVideoBriefDetails.h" |
|
29 #include "CIptvVodDlEventListener.h" |
|
30 #include "CIptvVodDlDownloadEvent.h" |
|
31 #include "TIptvVodDlDownloadId.h" |
|
32 #include "CIptvVodDlDownloadList.h" |
|
33 #include "CIptvVodDlDownloadListItem.h" |
|
34 #include "MIptvVodDlClientObserver.h" |
|
35 #include "CIptvService.h" |
|
36 #include "MIptvEventListenerObserver.h" |
|
37 |
|
38 class CIptvVodDlDownloadReq; |
|
39 class CIptvVodDlDownloadList; |
|
40 class CIptvVodDlDownloadWatcher; |
|
41 class CIptvVodDlCancelDownloadReq; |
|
42 class CIptvEventListener; |
|
43 |
|
44 /** |
|
45 * VoD download API |
|
46 * |
|
47 * Notice, if you set SetWaitForFlushInDestructor(ETrue), then when calling this class' |
|
48 * destructor, the destructing might take some time and during that time dl events might arrive. |
|
49 * Client must be able to handle events untill the destruct method has finished. |
|
50 * This is usually achieved by placing this class as a first in destruction chain |
|
51 * of the application. One can also use WaitForFlush() method before deleting the object to achieve |
|
52 * similar functionality. If neither method is used, then all requests which are not sent yet |
|
53 * to server are lost in deletion. |
|
54 * |
|
55 * @lib IptvEngineClient.dll |
|
56 */ |
|
57 class CIptvVodDlClient : public CIptvClientBase, |
|
58 public MIptvEventListenerObserver |
|
59 { |
|
60 |
|
61 public: |
|
62 |
|
63 /** |
|
64 * Two-phased constructor. |
|
65 */ |
|
66 static IMPORT_C CIptvVodDlClient* NewL ( |
|
67 MIptvVodDlClientObserver& aClientObserver ); |
|
68 |
|
69 /** |
|
70 * Two-phased constructor. |
|
71 */ |
|
72 static IMPORT_C CIptvVodDlClient* NewLC( |
|
73 MIptvVodDlClientObserver& aClientObserver ); |
|
74 |
|
75 /** |
|
76 * Destructor. |
|
77 */ |
|
78 virtual IMPORT_C ~CIptvVodDlClient(); |
|
79 |
|
80 /** |
|
81 * Purchase content from service. Not Supported. |
|
82 * @param aServiceId Service provider ID identifier. |
|
83 * @param aContentId Content ID identifier. |
|
84 * @return Error code, KErrNone if no errors, |
|
85 * KErrCouldNotConnect if server needs permission for connection, otherwise one of the system wide error codes. |
|
86 */ |
|
87 IMPORT_C TInt PurchaseL( |
|
88 TIptvServiceId aServiceId, |
|
89 TIptvContentId aContentId ); |
|
90 |
|
91 /** |
|
92 * Download content from service. |
|
93 * @param aIapId |
|
94 * @param aServiceId Service provider ID identifier. |
|
95 * @param aContentId Content ID identifier. |
|
96 * @param aIndex Content access index. |
|
97 * @param aDltype Type of the requested download, currently only EIptvDownloadTypeImmediate |
|
98 * supported. |
|
99 * @return Error code, indicates if download is started successfully. If return code is |
|
100 * EIptvDlNoError, then further download status is reported via events, on error |
|
101 * no further events will arrive. |
|
102 */ |
|
103 IMPORT_C TIptvDlError DownloadL( |
|
104 TUint32 aIapId, |
|
105 TIptvServiceId aServiceId, |
|
106 TIptvContentId aContentId, |
|
107 TUint32 aIndex, |
|
108 TIptvDownloadType aDlType ); |
|
109 |
|
110 /** |
|
111 * Download content from service. Download status is reported via events. |
|
112 * Download requests are buffered on client side. Use WaitForFlush() method |
|
113 * to ensure that requests have been sent to server. |
|
114 * @param aIapId. |
|
115 * @param aServiceId Service provider ID identifier. |
|
116 * @param aContentId Content ID identifier. |
|
117 * @param aContentIndex Content access index. |
|
118 * @param aDltype Type of the requested download, currently only EIptvDownloadTypeImmediate |
|
119 * supported. |
|
120 */ |
|
121 IMPORT_C void DownloadReqL( |
|
122 TUint32 aIapId, |
|
123 TIptvServiceId aServiceId, |
|
124 TIptvContentId aContentId, |
|
125 TUint32 aContentIndex, |
|
126 TIptvDownloadType aDlType ); |
|
127 |
|
128 /** |
|
129 * Cancels download. |
|
130 * Operation includes clean up that removes files from file system, |
|
131 * deletes data related to aGlobalFileId and releases aGlobalFileId identifier. |
|
132 * @param aGlobalFileId Download ID identifier, reference to actual file under download. |
|
133 * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes. |
|
134 */ |
|
135 IMPORT_C TInt CancelDownloadL( |
|
136 CIptvMyVideosGlobalFileId& aGlobalFileId ); |
|
137 |
|
138 /** |
|
139 * Cancels download. |
|
140 * Operation includes clean up that removes files from file system, |
|
141 * deletes data related to FileId and releases FileId identifier. |
|
142 * @param aServiceId |
|
143 * @param aContentId |
|
144 * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes. |
|
145 * KErrNotFound if download was not found from VOD DL Manager, file might still be in |
|
146 * My Videos. |
|
147 */ |
|
148 IMPORT_C TInt CancelDownloadL( |
|
149 TUint32 aServiceId, |
|
150 TUint32 aContentId ); |
|
151 |
|
152 /** |
|
153 * Cancels download asynchronously. See CIptvVodDlDownloadEvent::TEvent for |
|
154 * response events. |
|
155 * Download cancel requests are buffered on client side. Use WaitForFlush() method |
|
156 * to ensure that requests have been sent to server. |
|
157 * Operation includes clean up that removes files from file system, |
|
158 * deletes data related to FileId and releases FileId identifier. |
|
159 * @param aDownloadId For cancel to success, either one of iServiceId/iContentId |
|
160 * OR iFileId&iDriveId pairs must be set. |
|
161 */ |
|
162 IMPORT_C void CancelDownloadReqL( |
|
163 TIptvVodDlDownloadId& aDownloadId ); |
|
164 |
|
165 /** |
|
166 * Pause download. |
|
167 * @param aFileId Download ID identifier, reference to actual file under download. |
|
168 * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes. |
|
169 */ |
|
170 IMPORT_C TInt PauseDownloadL( |
|
171 CIptvMyVideosGlobalFileId& aFileId ); |
|
172 |
|
173 /** |
|
174 * Pauses all downloads. |
|
175 * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes. |
|
176 */ |
|
177 IMPORT_C TInt PauseAllDownloads(); |
|
178 |
|
179 /** |
|
180 * Resume download. |
|
181 * @param aFileId reference to file under download. |
|
182 * @param aUseUserNameAndPassword if EFalse, aUserName and aPassword are ignored. |
|
183 * @param aUserName HTTP user name |
|
184 * @param aPassword HTTP password |
|
185 * @param aIapId |
|
186 * @param aUseIapId if EFalse, aIapId is ignored |
|
187 * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes. |
|
188 */ |
|
189 IMPORT_C TInt ResumeDownloadL( |
|
190 CIptvMyVideosGlobalFileId& aFileId, |
|
191 TBool aUseUserNameAndPassword, |
|
192 const TDesC& aUserName, |
|
193 const TDesC& aPassword, |
|
194 TUint32 aIapId, |
|
195 TBool aUseIapId ); |
|
196 |
|
197 /** |
|
198 * Resume download. This is meant to to be used in early download phaze when global |
|
199 * file ID is not valid yet. |
|
200 * @param aServiceId |
|
201 * @param aContentId |
|
202 * @param aUseUserNameAndPassword if EFalse, aUserName and aPassword are ignored. |
|
203 * @param aUserName HTTP user name, KIptvVodDlUserNameMaxLength is the maximum length |
|
204 * @param aPassword HTTP password, KIptvVodDlPasswordMaxLength is the maximum length |
|
205 * @param aIapId |
|
206 * @param aUseIapId if EFalse, aIapId is ignored |
|
207 * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes. |
|
208 */ |
|
209 IMPORT_C TInt ResumeDownloadL( |
|
210 TUint32 aServiceId, |
|
211 TUint32 aContentId, |
|
212 TBool aUseUserNameAndPassword, |
|
213 const TDesC& aUserName, |
|
214 const TDesC& aPassword, |
|
215 TUint32 aIapId, |
|
216 TBool aUseIapId ); |
|
217 |
|
218 /** |
|
219 * Resumes all downloads. |
|
220 * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes. |
|
221 */ |
|
222 IMPORT_C TInt ResumeAllDownloads(); |
|
223 |
|
224 /** |
|
225 * Gets list of items selected for download. |
|
226 * @param aDownloadList |
|
227 * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes. |
|
228 */ |
|
229 IMPORT_C TInt GetDownloadListL( |
|
230 CIptvVodDlDownloadList& aDownloadList ); |
|
231 |
|
232 /** |
|
233 * Get download progess percentage for selected download file ID. |
|
234 * @since |
|
235 * @param aGlobalFileId Download file ID identifier, reference to actual file under download. |
|
236 * @return Progress in %. Decimal |
|
237 * 0 for not started, |
|
238 * 1-99 for ongoing and |
|
239 * 100 for completed download. |
|
240 * If error, one of the system wide error codes returned. |
|
241 */ |
|
242 IMPORT_C TInt GetDownloadProgressL( |
|
243 CIptvMyVideosGlobalFileId& aGlobalFileId ); |
|
244 |
|
245 /** |
|
246 * From MIptvEventListenerObserver. |
|
247 * Event is routed to Client observer (MIptvVodDlClientObserver). |
|
248 * @param aEvent |
|
249 */ |
|
250 void HandleEvent( MIptvEvent& aEvent ); |
|
251 |
|
252 /** |
|
253 * Configures flush behaviour in destructor. |
|
254 * @param aWaitForFlushInDestructor If ETrue, then this objects destructor will block until |
|
255 * all commands have been passed to server. EFalse will discard |
|
256 * commands and destruct immedetially. EFalse is on as default. |
|
257 */ |
|
258 IMPORT_C void SetWaitForFlushInDestructor( |
|
259 TBool aWaitForFlushInDestructor ); |
|
260 |
|
261 /** |
|
262 * Blocks until all commands have been flushed to server. |
|
263 */ |
|
264 IMPORT_C void WaitForFlush(); |
|
265 |
|
266 /** |
|
267 * Updates existing soft notification. |
|
268 * |
|
269 * @param aMsg Notification information. |
|
270 */ |
|
271 IMPORT_C void UpdateDownloadNotification( const TDesC& aMsg ); |
|
272 |
|
273 private: |
|
274 |
|
275 /** |
|
276 * C++ default constructor. |
|
277 */ |
|
278 CIptvVodDlClient(MIptvVodDlClientObserver& aClientObserver); |
|
279 |
|
280 /** |
|
281 * By default Symbian 2nd phase constructor is private. |
|
282 */ |
|
283 void ConstructL(); |
|
284 |
|
285 /** |
|
286 * From CActive, handles an active object’s request completion event |
|
287 */ |
|
288 void RunL(); |
|
289 |
|
290 /** |
|
291 * From CActive, implements cancellation of an outstanding request. |
|
292 * This function is called as part of the active object’s Cancel(). |
|
293 */ |
|
294 void DoCancel(); |
|
295 |
|
296 /** |
|
297 * Removes Dl request from the queue. |
|
298 * @param aServiceId |
|
299 * @param aContentId |
|
300 * @param aSendEvent If ETrue, (and the dl req was found from queue) |
|
301 * the CIptvVodDlDownloadEvent::ECancelReqSucceeded event is sent |
|
302 * to client. If EFalse, then no event is sent. |
|
303 * @return ETrue if dl req was removed from the queue, EFalse otherwise. |
|
304 */ |
|
305 TBool CancelDlFromQueueL( |
|
306 TUint32 aServiceId, |
|
307 TUint32 aContentId, |
|
308 TBool aSendEvent ); |
|
309 |
|
310 /** |
|
311 * Sends cancel download response event to client. |
|
312 * @param aSuccess if ETrue then CIptvVodDlDownloadEvent::EDownloadReqSucceeded event is sent, |
|
313 * if EFalse then CIptvVodDlDownloadEvent::EDownloadReqFailed event is sent. |
|
314 */ |
|
315 void SendCancelEventL( |
|
316 TUint32 aServiceId, |
|
317 TUint32 aContentId, |
|
318 TBool aSuccess ); |
|
319 |
|
320 #if 0 |
|
321 /** |
|
322 * Gets next download request from the queue. Ownership moves. |
|
323 * Item is removed from the iReqQueue. |
|
324 * @return pointer to download req, NULL if not found. |
|
325 */ |
|
326 CIptvVodDlDownloadReq* GetNextDlReqFromQueueL(); |
|
327 |
|
328 /** |
|
329 * Extracts cancel download req object from request queue. |
|
330 * @return object extracted, NULL if none found. |
|
331 */ |
|
332 CIptvVodDlCancelDownloadReq* GetNextCancelDlReqFromQueueL(); |
|
333 #endif |
|
334 |
|
335 /** |
|
336 * Sends cancel download request. Active object is set active. |
|
337 * @aParam aCancelDlReq request object to send. |
|
338 */ |
|
339 void SendCancelDownloadReqL( |
|
340 CIptvVodDlCancelDownloadReq& aCancelDlReq ); |
|
341 |
|
342 /** |
|
343 * Sends download req. Active object is set active. |
|
344 * @aParam aDownloadReq request object to send. |
|
345 */ |
|
346 void SendDownloadReqL( |
|
347 CIptvVodDlDownloadReq& aDownloadReq ); |
|
348 |
|
349 /** |
|
350 * Sends next request from the queue. |
|
351 */ |
|
352 void HandleNextReqInQueueL(); |
|
353 |
|
354 public: |
|
355 |
|
356 MIptvVodDlClientObserver& iClientObserver; |
|
357 |
|
358 private: // Data |
|
359 |
|
360 /** |
|
361 * Listens events from the server side (CIptvEventGenerator sends them). |
|
362 */ |
|
363 CIptvEventListener* iEventListener; |
|
364 |
|
365 HBufC8* iIpcMsg; |
|
366 TPtr8 iIpcMsgPtr; |
|
367 |
|
368 /** |
|
369 * The last asynchronous message sent. Negative |
|
370 * value means that there is no msg pending. |
|
371 */ |
|
372 TInt iPendingReq; |
|
373 |
|
374 /** |
|
375 * Used to store download id for the asynchronous request. If asynchronous |
|
376 * request fails before download object is created |
|
377 * in VOD DL Manager, this object is used to generate fail event |
|
378 * to client. |
|
379 */ |
|
380 TIptvVodDlDownloadId iReqDownloadId; |
|
381 |
|
382 /** |
|
383 * Asynchronous download requests which can't be sent immedetially are queued here. |
|
384 */ |
|
385 RArray<MIptvStreamObject*> iReqQueue; |
|
386 |
|
387 /** |
|
388 * This is ETrue when this object is flush wait pending. |
|
389 */ |
|
390 TBool iWaitingForFlush; |
|
391 |
|
392 /** |
|
393 * If ETrue, then destructor will block until commands have been flushed |
|
394 * to server. |
|
395 */ |
|
396 TBool iWaitForFlushInDestructor; |
|
397 |
|
398 /** |
|
399 * Used to send requests on the background, allowing client to continue |
|
400 * normal activities. |
|
401 */ |
|
402 CActiveSchedulerWait* iActiveSchedulerWait; |
|
403 |
|
404 }; |
|
405 |
|
406 #endif // CIPTVVODDLCLIENT_H |