|
1 /* |
|
2 * Copyright (c) 2004 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 class CCodDownloadImpl. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef COD_DOWNLOAD_IMPL_H |
|
20 #define COD_DOWNLOAD_IMPL_H |
|
21 |
|
22 // FORWARD DECLARATION |
|
23 |
|
24 class CCodEngBase; |
|
25 class CCodUiResource; |
|
26 class CDocumentHandler; |
|
27 class CErrorUI; |
|
28 class CBodyPart; |
|
29 class CAiwGenericParamList; |
|
30 |
|
31 // INCLUDES |
|
32 |
|
33 #include <e32std.h> |
|
34 #include <f32file.h> |
|
35 #include <CodDownload.h> |
|
36 #include <CodLoadObserver.h> |
|
37 #include <AknServerApp.h> |
|
38 |
|
39 // CONSTANTS |
|
40 const TUid KDRMHelperUid = {0x101F85C7}; |
|
41 |
|
42 /** |
|
43 * Cod Download implementation (behind proxy CCodDownload). |
|
44 */ |
|
45 NONSHARABLE_CLASS( CCodDownloadImpl ) |
|
46 : public CActive, |
|
47 public MCodLoadObserver, |
|
48 public MAknServerAppExitObserver |
|
49 { |
|
50 public: // Constructors and destructor |
|
51 |
|
52 /** |
|
53 * Two-phased constructor. Leaves on failure. |
|
54 * @param aProxy Proxy owning this object. |
|
55 * @param aBuf The descriptor. |
|
56 * @param aType Descriptor data type. |
|
57 * @param aObserver Observer. |
|
58 * @param aEikEnv Eikon environment or NULL. Can be NULL if download |
|
59 * does not require UI functionality. |
|
60 * @param aMultipartBoundary Multipart boundary or NULL. |
|
61 * Required for processing multipart. |
|
62 * @param aMultipartUrl Multipart URL or NULL. |
|
63 * Required for processing multipart. |
|
64 * @return The constructed object. |
|
65 */ |
|
66 IMPORT_C static CCodDownloadImpl* NewL |
|
67 ( |
|
68 CCodDownload& aProxy, |
|
69 const TDesC8& aBuf, |
|
70 const TDesC8& aType, |
|
71 MCodDownloadObserver& aObserver, |
|
72 CEikonEnv* aEikEnv, |
|
73 const TDesC8* aMultipartBoundary, |
|
74 const TDesC16* aMultipartUrl |
|
75 ); |
|
76 |
|
77 /** |
|
78 * Destructor. |
|
79 */ |
|
80 IMPORT_C virtual ~CCodDownloadImpl(); |
|
81 |
|
82 public: // New methods |
|
83 |
|
84 /** |
|
85 * Start download. Panics if already active. |
|
86 * Restart is OK for completed downloads. |
|
87 * @param aParams Parameters or NULL. |
|
88 */ |
|
89 IMPORT_C void StartL( const CAiwGenericParamList* aParams ); |
|
90 |
|
91 /** |
|
92 * Stop (cancel) download. Safe to call in any state. |
|
93 * Some processing still follows (e.g. install-notify). |
|
94 */ |
|
95 IMPORT_C void Stop(); |
|
96 |
|
97 /** |
|
98 * Get progress. |
|
99 * @return Progress. |
|
100 */ |
|
101 IMPORT_C const TCodDownloadProgress& Progress() const; |
|
102 |
|
103 /** |
|
104 * Get name attribute. This may be empty string, if attribute is |
|
105 * empty or not available. Do not store pointer (data may change as |
|
106 * download proceeds). |
|
107 */ |
|
108 IMPORT_C TPtrC Name(); |
|
109 |
|
110 /** |
|
111 * Get data type of content (or empty string: type may not be |
|
112 * available). |
|
113 * @return Data type. |
|
114 */ |
|
115 IMPORT_C TPtrC8 Type() const; |
|
116 |
|
117 /** |
|
118 * Get path of saved content (or empty string). |
|
119 * Available only after successful download. |
|
120 * @return Path of saved content. Fits to KMaxFileName. |
|
121 */ |
|
122 IMPORT_C TPtrC GetPath() const; |
|
123 |
|
124 /** |
|
125 * Perform service flow after a successful or failed download. |
|
126 * This consists of zero, one or both of |
|
127 * - launching dwonloaded content |
|
128 * - activating Next-URL. |
|
129 * Load may also be retried. |
|
130 * Call this in response to EEndLoad event. |
|
131 */ |
|
132 IMPORT_C void ServiceFlowL(); |
|
133 |
|
134 /** |
|
135 * Get Next-URL. |
|
136 * @return Next-URL. Owner is the caller. |
|
137 */ |
|
138 IMPORT_C HBufC8* NextUrlL() const; |
|
139 |
|
140 |
|
141 /** |
|
142 * Get PostResponse-URL. |
|
143 * @return PostResponse-URL. Owner is the caller. |
|
144 */ |
|
145 IMPORT_C HBufC8* GetPostResponseUrlL() const; |
|
146 |
|
147 /** |
|
148 * Check if downloading to removable media. |
|
149 * Available after EAccept event. |
|
150 * @return ETrue if downloading to removable media. |
|
151 */ |
|
152 IMPORT_C TBool RemovableMedia() const; |
|
153 |
|
154 /** |
|
155 * Set COD download attached |
|
156 * @param aValue If equals ETrue - download is attached |
|
157 */ |
|
158 IMPORT_C void SetCodDlAttached(const TBool aValue); |
|
159 |
|
160 /** |
|
161 * Get updated DD URi |
|
162 * @return Updated DD-URL. |
|
163 */ |
|
164 IMPORT_C HBufC8* UpdatedDDUriL() const; |
|
165 |
|
166 /** |
|
167 * Pause COD Download. |
|
168 */ |
|
169 IMPORT_C void Pause(); |
|
170 |
|
171 /** |
|
172 * Two-phased constructor. Leaves on failure. |
|
173 * @param aProxy Proxy owning this object. |
|
174 * @param aDownloadId The download id. |
|
175 * @param aDlUid The app UID. |
|
176 * @param aType Descriptor data type. |
|
177 * @param aObserver Observer. |
|
178 * @param aEikEnv Eikon environment or NULL. Can be NULL if download |
|
179 * does not require UI functionality. |
|
180 * @param aMultipartBoundary Multipart boundary or NULL. |
|
181 * Required for processing multipart. |
|
182 * @param aMultipartUrl Multipart URL or NULL. |
|
183 * Required for processing multipart. |
|
184 * @return The constructed object. |
|
185 */ |
|
186 |
|
187 IMPORT_C static CCodDownloadImpl* NewL |
|
188 ( |
|
189 CCodDownload& aProxy, |
|
190 const TInt aDownloadId, |
|
191 const TUid aDlUid, |
|
192 const TDesC8& aType, |
|
193 MCodDownloadObserver& aObserver, |
|
194 CEikonEnv* aEikEnv, |
|
195 const TDesC8* aMultipartBoundary, |
|
196 const TDesC16* aMultipartUrl |
|
197 ); |
|
198 |
|
199 /** |
|
200 * Get Destination file name |
|
201 * @param aMOIndex media object index between 1 to 'n' |
|
202 * @return NULL if index out of range |
|
203 */ |
|
204 IMPORT_C TPtrC GetDestFilePath (TInt aMOIndex ) const; |
|
205 |
|
206 /** |
|
207 * Set the CodData stream descriptor. |
|
208 * @param aDesStream. |
|
209 */ |
|
210 IMPORT_C HBufC8* UpdatedDownloadDataL() const; |
|
211 |
|
212 /** |
|
213 * Set the stream descriptor for single mediaq object (track). |
|
214 * @param aDesStream. |
|
215 */ |
|
216 IMPORT_C HBufC8* UpdatedTrackDataL(TInt& aValue) const; |
|
217 |
|
218 /** |
|
219 * Currently active COD download |
|
220 */ |
|
221 IMPORT_C TInt ActiveDownload(); |
|
222 |
|
223 public: // Transparent user data |
|
224 |
|
225 /** |
|
226 * Get tansparent user data. |
|
227 * @return User data. |
|
228 */ |
|
229 IMPORT_C TAny* UserData() const; |
|
230 |
|
231 /** |
|
232 * Set tansparent user data. |
|
233 * @param aUserData User data. |
|
234 */ |
|
235 IMPORT_C void SetUserData( TAny* aUserData ); |
|
236 |
|
237 private: // Constructor |
|
238 |
|
239 /** |
|
240 * Constructor. |
|
241 * @param aProxy Proxy owning this object. |
|
242 * @param aObserver Observer. |
|
243 * @param aEikEnv Eikon environment or NULL. Can be NULL if download |
|
244 * does not require UI functionality. |
|
245 */ |
|
246 inline CCodDownloadImpl |
|
247 ( |
|
248 CCodDownload& aProxy, |
|
249 MCodDownloadObserver& aObserver, |
|
250 CEikonEnv* aEikEnv |
|
251 ); |
|
252 |
|
253 /** |
|
254 * Second phase constructor. Leaves on failure. |
|
255 * @param aBuf The descriptor. |
|
256 * @param aType Data type. |
|
257 * @param aMultipartBoundary Multipart boundary or NULL. |
|
258 * Required for processing multipart. |
|
259 * @param aMultipartUrl Multipart URL or NULL. |
|
260 * Required for processing multipart. |
|
261 */ |
|
262 void ConstructL |
|
263 ( |
|
264 const TDesC8& aBuf, |
|
265 const TDesC8& aType, |
|
266 const TDesC8* aMultipartBoundary, |
|
267 const TDesC16* aMultipartUrl |
|
268 ); |
|
269 |
|
270 /** |
|
271 * Second phase constructor. Leaves on failure. |
|
272 * @param aDownloadId The download id. |
|
273 * @param aDlUid The app uid. |
|
274 * @param aType Data type. |
|
275 * @param aMultipartBoundary Multipart boundary or NULL. |
|
276 * Required for processing multipart. |
|
277 * @param aMultipartUrl Multipart URL or NULL. |
|
278 * Required for processing multipart. |
|
279 */ |
|
280 void ConstructL |
|
281 ( |
|
282 const TInt aDownloadId, |
|
283 const TUid aDlUid, |
|
284 const TDesC8& aType, |
|
285 const TDesC8* aMultipartBoundary, |
|
286 const TDesC16* aMultipartUrl |
|
287 ); |
|
288 |
|
289 |
|
290 private: // from CActive |
|
291 |
|
292 /** |
|
293 * Cancel protocol implementation. |
|
294 */ |
|
295 virtual void DoCancel(); |
|
296 |
|
297 /** |
|
298 * Outstanding request completed. |
|
299 */ |
|
300 virtual void RunL(); |
|
301 |
|
302 /** |
|
303 * Handle error. |
|
304 * @param aError Error code. |
|
305 * @return KErrNone. |
|
306 */ |
|
307 virtual TInt RunError( TInt aError ); |
|
308 |
|
309 private: // processing completion |
|
310 |
|
311 /** |
|
312 * SetL succeeded. |
|
313 */ |
|
314 void SetOkL(); |
|
315 |
|
316 /** |
|
317 * Load done. |
|
318 */ |
|
319 void LoadDoneL(); |
|
320 |
|
321 /** |
|
322 * Perform service flow after a successful or failed download. |
|
323 * This consists of zero, one or both of |
|
324 * - launching dwonloaded content |
|
325 * - activating Next-URL. |
|
326 * Load may also be retried. |
|
327 * @return ETrue if application should exit. |
|
328 */ |
|
329 TBool DoServiceFlowL(); |
|
330 |
|
331 /** |
|
332 * Handle successful load. |
|
333 * @return ETrue if application should exit. |
|
334 */ |
|
335 TBool LoadOkL(); |
|
336 |
|
337 /** |
|
338 * Handle failed load. |
|
339 * @return ETrue if application should exit. |
|
340 */ |
|
341 TBool LoadFailedL(); |
|
342 |
|
343 /** |
|
344 * Handle successful ROAP. |
|
345 * @return ETrue if application should exit. |
|
346 */ |
|
347 TBool RoapOkL(); |
|
348 |
|
349 /** |
|
350 * Handle successful RoAcq ROAP. |
|
351 * @return ETrue if application should exit. |
|
352 */ |
|
353 TBool RoAcqOkL(); |
|
354 |
|
355 /** |
|
356 * Handle failed ROAP. |
|
357 * @return ETrue if application should exit. |
|
358 */ |
|
359 TBool RoapFailedL(); |
|
360 |
|
361 /** |
|
362 * Service flow: launch browser and (optionally) activate Next-URL, |
|
363 * if exists. |
|
364 */ |
|
365 void ActivateNextUrlL(); |
|
366 |
|
367 /** |
|
368 * Finished. |
|
369 */ |
|
370 void Done(); |
|
371 |
|
372 private: // from MCodLoadObserver |
|
373 |
|
374 /** |
|
375 * Get download root path. |
|
376 * Leave with KErrCancel if query is cancelled. |
|
377 * @param aRootPath Root path returned here. |
|
378 */ |
|
379 virtual void GetRootPathL( TDes& aRootPath ); |
|
380 |
|
381 /** |
|
382 * Starting load (fetch content or error-notify). |
|
383 * @param aStatusCode HTTP status code. |
|
384 * - 900 (Success) indicates start of content load. |
|
385 * - Other values indicate start of error report. |
|
386 */ |
|
387 virtual void StartLoadL( TInt aStatusCode ); |
|
388 |
|
389 /** |
|
390 * Cancelling content load started. Not called if cancelling error |
|
391 * report. |
|
392 */ |
|
393 virtual void StartCancelL(); |
|
394 |
|
395 /** |
|
396 * Load progress update. |
|
397 * @param aFinalValue Final progress value. |
|
398 * @param aCurrentValue Current progress value. |
|
399 */ |
|
400 virtual void ProgressL( TInt aFinalValue, TInt aCurrentValue ); |
|
401 |
|
402 /** |
|
403 * Processing ended. |
|
404 * Note that if processing does not include loading, this method can be |
|
405 * called without a preceding StartLoadL call. |
|
406 * @param aStatusCode HTTP status code (aError mapped to HTTP status |
|
407 * code). |
|
408 * @param aError Error code of result. (The Set(), Accept() or Reject() |
|
409 * request to CodEng will also complete with this value.) |
|
410 */ |
|
411 virtual void Done( TInt aStatusCode, TInt aError ); |
|
412 |
|
413 /** |
|
414 * Get confirmation for creating network connection. |
|
415 * @return ETrue if connection can be created. |
|
416 */ |
|
417 virtual TBool ConfirmConnectL(); |
|
418 |
|
419 /** |
|
420 * Opening a connection. |
|
421 * @param aIap AP to be used for creating the connection. |
|
422 */ |
|
423 virtual void StartConnect( TUint32 aIap ); |
|
424 |
|
425 /** |
|
426 * Connected. |
|
427 */ |
|
428 virtual void EndConnect(); |
|
429 |
|
430 /** |
|
431 * Authenticate user. |
|
432 * @param aHost Host. |
|
433 * @param aRealm Realm. |
|
434 * @param aProxyAuth ETrue if this is a proxy authentication. |
|
435 * @param aUsername Return username here. |
|
436 * @param aPassword Return password here. |
|
437 * @return ETrue if auth is OK, EFalse if cancelled. |
|
438 */ |
|
439 virtual TBool UserAuthL |
|
440 ( |
|
441 const TDesC& aHost, |
|
442 const TDesC& aRealm, |
|
443 TBool aProxyAuth, |
|
444 TDes& aUsername, |
|
445 TDes& aPassword |
|
446 ); |
|
447 |
|
448 /** |
|
449 * ROAP Trigger parsed (success or error). |
|
450 * @param aData ROAP Trigger data. |
|
451 */ |
|
452 virtual void RoapTriggerParsedL( const CRoapData& aData ); |
|
453 /** |
|
454 * Connection Error |
|
455 * return: Connection Error . |
|
456 */ |
|
457 |
|
458 inline virtual void SetConnError( TInt aError) {iConnError = aError;} |
|
459 |
|
460 /** |
|
461 * Connection Error |
|
462 * return: Connection Error . |
|
463 */ |
|
464 inline virtual TInt ConnError () {return iConnError;} |
|
465 |
|
466 /** |
|
467 * Progresive download "Play" is available |
|
468 * return: Connection Error . |
|
469 */ |
|
470 virtual void PdPlayAvailable(); |
|
471 |
|
472 /** |
|
473 * Inform DownloadMgrClntSrv about updated media info |
|
474 * return: Connection Error . |
|
475 */ |
|
476 virtual void UpdateMediaInfoL(); |
|
477 |
|
478 /** |
|
479 * SetActive Download |
|
480 */ |
|
481 virtual void SetActiveDownload( ); |
|
482 /** |
|
483 * Inform DownloadMgrClntSrv about updated track |
|
484 * return: Connection Error . |
|
485 */ |
|
486 virtual void UpdateTrackInfoL(); |
|
487 |
|
488 /** |
|
489 * Displays Info message "Waiting for license" |
|
490 */ |
|
491 virtual void WaitForLicenseL(); |
|
492 |
|
493 /** |
|
494 * To indicate the download is paused |
|
495 */ |
|
496 inline virtual void DownloadPaused() {iDownloadPaused = ETrue;} |
|
497 |
|
498 /** |
|
499 * To indicate the download is resumed and ready for PD |
|
500 */ |
|
501 inline virtual void DownloadResumedPdAvailable() |
|
502 { |
|
503 iObserver.CodEventL( iProxy, MCodDownloadObserver::EResumed ); |
|
504 } |
|
505 |
|
506 /** |
|
507 * To update the server about whether or not download is pausable |
|
508 */ |
|
509 virtual void UpdatePausable( TBool aPausable ); |
|
510 |
|
511 |
|
512 /** |
|
513 * To update the server about next media object being downloaded. |
|
514 */ |
|
515 virtual void MediaObjectNameChanged(); |
|
516 |
|
517 /** |
|
518 * To update the server about content type. |
|
519 */ |
|
520 virtual void ContentTypeChanged(); |
|
521 |
|
522 /** |
|
523 * |
|
524 * To handle PostResponseUrlL as part of metering response |
|
525 * @param aPrUrl: The PostResponseURL |
|
526 * @return void |
|
527 * |
|
528 */ |
|
529 virtual void HandleRoapPostResponseUrlL( const TDesC8& aPrUrl ); |
|
530 |
|
531 |
|
532 private: // from MAknServerAppExitObserver |
|
533 |
|
534 /** |
|
535 * Embedded document viewing has ended. |
|
536 * @param aReason Exit reason (unused). |
|
537 */ |
|
538 void HandleServerAppExit( TInt aReason ); |
|
539 |
|
540 private: // types |
|
541 |
|
542 enum TState ///< State. |
|
543 { |
|
544 EInit, ///< Initial state. |
|
545 ESet, ///< Set. |
|
546 ELoad, ///< Loading. |
|
547 ELoadDone, ///< Load done. |
|
548 EServiceFlow ///< Service flow. |
|
549 }; |
|
550 |
|
551 private: // New methods |
|
552 |
|
553 /** |
|
554 * Reset progress. |
|
555 */ |
|
556 inline void ResetProgress(); |
|
557 |
|
558 /** |
|
559 * Get Next-URL (possibly relative) attribute. |
|
560 * @param aBack Etrue is returned here if Next-URL is 'back'. |
|
561 * @return Next-URL atttribute. |
|
562 */ |
|
563 TPtrC8 NextUrlAttr( TBool& aBack ) const; |
|
564 |
|
565 /** |
|
566 * Call back function to launch the help |
|
567 */ |
|
568 static TInt ShowRoapCallback( TAny* aPtr ); |
|
569 |
|
570 /** |
|
571 * Launch help dialog |
|
572 * @param TDesC aContext |
|
573 * @return void |
|
574 */ |
|
575 void LaunchHelpL( const TDesC& aContext ); |
|
576 |
|
577 private: // Data |
|
578 |
|
579 TState iState; ///< State. |
|
580 CCodDownload& iProxy; ///< Proxy object. Not owned. |
|
581 TBool iCod; ///< COD or DD? |
|
582 TBool iRoap; ///< ROAP involved? |
|
583 HBufC8* iBuf; ///< Data buffer. Owned. |
|
584 TPtrC8 iDescriptor; ///< Descriptor. |
|
585 MCodDownloadObserver& iObserver; ///< Observer. Not owned. |
|
586 CEikonEnv* iEikEnv; ///< Eikon env or NULL. Not own. |
|
587 CCodUiResource* iUiResource; ///< UI Resource or NULL. Owned. |
|
588 CErrorUI* iErrorUi; ///< Error UI or NULL. Owned. |
|
589 CCodEngBase* iEng; ///< Engine. Owned. |
|
590 TCodDownloadProgress iProgress; ///< Progress. |
|
591 TAny* iUserData; ///< User data. Not own. |
|
592 TBool iAutoAccept; ///< Suppress download conf. |
|
593 TBool iSilentMode; ///< Silent mode. |
|
594 TBool iSuppressNextUrl; ///< Suppress Next-URL. |
|
595 TBool iSuppressLaunch; ///< Suppress launch. |
|
596 TBool iFota; ///< FOTA download? |
|
597 CDocumentHandler* iDocHandler; ///< DocumentHandler or NULL. |
|
598 CAiwGenericParamList* iDocParams; ///< DocHandler params. Owned. |
|
599 RFs iFs; ///< File Server Session. Own. |
|
600 RPointerArray<CBodyPart> iParts; ///< Multipart body parts. Owned. |
|
601 CAiwGenericParamList* iParams; ///< Copy of received params. Own |
|
602 TInt iConnError; ///< Connection Error . |
|
603 TBool iAttached; ///< Cod download attached (playing progressively) |
|
604 |
|
605 TUint32 iDownloadId; ///< Download Id |
|
606 TUid iAppUId; ///< Client Application Uid |
|
607 TBool iDownloadPaused; ///< Download paused |
|
608 HBufC8* iPostResponseURL; ///< PostResponseURL from RoapSaver |
|
609 }; |
|
610 |
|
611 #include "CodDownloadImpl.inl" |
|
612 |
|
613 #endif /* def COD_DOWNLOAD_IMPL_H */ |