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 "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: Swupd downloader. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef ___DOWNLOADER_H_ |
|
21 #define ___DOWNLOADER_H_ |
|
22 |
|
23 #include <DownloadMgrClient.h> |
|
24 #include <etelpckt.h> //To read GSM Error codes from symbian |
|
25 #include <exterror.h> //To read GSM Error codes from symbian |
|
26 #include <wlanerrorcodes.h> //To read WLAN Error codes from s60 |
|
27 #include <AknWaitDialog.h> |
|
28 #include "FotaServer.h" |
|
29 #include "FotaSrvDebug.h" |
|
30 #include "FotaDLProgressDlg.h" |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CFotaServer; |
|
34 class CAknWaitDialog; |
|
35 class CFotaDownloadNotifHandler; |
|
36 class CFotaNetworkRegStatus; //To know the network connectivity status while resuming suspended download |
|
37 // CONSTANTS |
|
38 // from coderror.h |
|
39 #define KErrCodInvalidDescriptor -1000 |
|
40 #define KErrCodInsufficientSpace -1001 |
|
41 #define KErrCodWapConnectionDropped -20041 |
|
42 |
|
43 // If download times out, it must be tried again |
|
44 #define KFotaDownloadTimeoutRestartCount 5 |
|
45 |
|
46 // For reading connecting resource from DM UI |
|
47 _LIT( KSCPResourceFilename, "\\Resource\\Apps\\NsmlDMSync.rsc" ); |
|
48 _LIT( KDriveZ,"z:" ); |
|
49 _LIT( KDDDirPath, "c:\\system\\fota\\" ); |
|
50 _LIT( KDDFilename, "fotadownload.dd" ); |
|
51 |
|
52 //Constants when SAN Bits are set |
|
53 enum { |
|
54 ESanNotSpecified=0, |
|
55 ESanSilent, |
|
56 ESanInformative, |
|
57 ESanInteractive |
|
58 }; |
|
59 |
|
60 //Contants when SAN is Off. It refers to Accepted state in DM Profile Settings |
|
61 enum { |
|
62 EAcceptedNo=0, |
|
63 EAcceptedYes |
|
64 }; |
|
65 |
|
66 // Constants for KSilentOmaDlUIBehavior cenrep key |
|
67 enum { |
|
68 EOmacdOffdlprgOff=0, //OMA CD View = Off, Download Progress Bar = Off |
|
69 EOmacdOffdlprgOn, //OMA CD View = Off, Download Progress Bar = On |
|
70 EOmacdOndlprgOff, //OMA CD View = On, Download Progress Bar = Off |
|
71 EOmacdOndlprgOn, //OMA CD View = On, Download Progress Bar = On |
|
72 EChooseFromSan //Choose behavior from SAN bits set during DM Session |
|
73 }; |
|
74 /** |
|
75 * Downloader |
|
76 * |
|
77 * Starts download and observes it. |
|
78 * |
|
79 * @lib fotaserver |
|
80 * @since S60 v3.1 |
|
81 */ |
|
82 NONSHARABLE_CLASS (CFotaDownload ) |
|
83 : public CActive |
|
84 , MHttpDownloadMgrObserver |
|
85 , MDLProgressDlgObserver |
|
86 { |
|
87 friend class CFotaDownloadNotifHandler; |
|
88 |
|
89 |
|
90 enum TFotaDLProgress |
|
91 { |
|
92 EStarted, |
|
93 EDescriptorDownloaded, |
|
94 ESizeChecked |
|
95 }; |
|
96 |
|
97 |
|
98 public: // new functions |
|
99 |
|
100 CFotaDownload (); |
|
101 |
|
102 virtual ~CFotaDownload (); |
|
103 |
|
104 static CFotaDownload* NewL (CFotaServer* aServer); |
|
105 |
|
106 public: // Functions from base classes: |
|
107 |
|
108 |
|
109 /** |
|
110 * Schedule update to be carried out after download |
|
111 * |
|
112 * @since S60 v3.1 |
|
113 * @param aButtonId Button pressed |
|
114 * @return None |
|
115 */ |
|
116 TBool HandleDLProgressDialogExitL( TInt aButtonId ); |
|
117 |
|
118 protected: // Functions from base classes: |
|
119 |
|
120 /** |
|
121 * Handle user action |
|
122 * |
|
123 * @since S60 v3.1 |
|
124 * @param None |
|
125 * @return None |
|
126 */ |
|
127 virtual void RunL(); |
|
128 |
|
129 |
|
130 /** |
|
131 * Handle leaving Runl |
|
132 * |
|
133 * @since S60 v3.1 |
|
134 * @param aError error code |
|
135 * @return Error code |
|
136 */ |
|
137 virtual TInt RunError(TInt aError); |
|
138 |
|
139 |
|
140 /** |
|
141 * Handle cancel of active object |
|
142 * |
|
143 * @since S60 v3.1 |
|
144 * @param none |
|
145 * @return none |
|
146 */ |
|
147 void DoCancel(); |
|
148 |
|
149 public: |
|
150 |
|
151 |
|
152 /** |
|
153 * Handle Download manager event |
|
154 * |
|
155 * @since S60 v3.1 |
|
156 * @param aDownload download |
|
157 * @param aEvent event |
|
158 * @return none |
|
159 */ |
|
160 virtual void HandleDMgrEventL( RHttpDownload& aDownload |
|
161 , THttpDownloadEvent aEvent ); |
|
162 |
|
163 |
|
164 /** |
|
165 * Handle Download manager event |
|
166 * |
|
167 * @since S60 v3.1 |
|
168 * @param aDownload download |
|
169 * @param aEvent event |
|
170 * @return none |
|
171 */ |
|
172 void DoHandleDMgrEventL( RHttpDownload* aDownload |
|
173 ,THttpDownloadEvent aEvent ); |
|
174 |
|
175 |
|
176 /** |
|
177 * Start download of swupd |
|
178 * |
|
179 * @since S60 v3.1 |
|
180 * @param aParams download parameters |
|
181 * @param aPkgURL Url of swupd |
|
182 * @param aUpdateAfterDownload Is update needed |
|
183 * @param aIapid Iap |
|
184 * @param aRestartDownload Is this a retry download (counter)? |
|
185 * If yes, don't show descriptor. |
|
186 * @return none |
|
187 */ |
|
188 void DownloadL(TDownloadIPCParams aParams,const TDesC8& aPkgURL |
|
189 ,TBool aUpdateAfterDownload,const TInt aIapid=KErrNotFound |
|
190 ,const TInt aRestartDownload=0 ); |
|
191 |
|
192 |
|
193 /** |
|
194 * Cancel |
|
195 * |
|
196 * @since S60 v3.1 |
|
197 * @param aCancelProgressBar Cancel progress bar also? |
|
198 * @return none |
|
199 */ |
|
200 void CancelDownload( const TBool aCancelProgressBar ); |
|
201 |
|
202 /** |
|
203 * Tries to resume any suspended fota download by quering the user. When the DM session is |
|
204 * Silent, this method directly starts resuming of download by calling ResumeDownloadL. |
|
205 * |
|
206 * @since S60 v3.2 |
|
207 * @param aUserInitiated Is user initiated resume? |
|
208 * @return none |
|
209 */ |
|
210 void TryResumeDownloadL(TBool aUserInitiated); |
|
211 |
|
212 /** |
|
213 * Resumes any suspended fota download. Firstly, it retrieves the RHttpDownload download object from Download Manager |
|
214 * and then performs the following - |
|
215 * - sets the IAP ID to use |
|
216 * - checks whether the connection is possible with that IAP ID |
|
217 * - sets download ui behavior |
|
218 * |
|
219 * @since S60 v3.2 |
|
220 * @return none |
|
221 */ |
|
222 void ResumeDownloadL(); |
|
223 /** |
|
224 * Finds whether the download is resumable or not. |
|
225 * |
|
226 * @since S60 v3.2 |
|
227 * @return ETrue if download is resumable, else EFalse. |
|
228 */ |
|
229 TBool IsDownloadResumable(); |
|
230 |
|
231 /** |
|
232 * Finds whether Fota Monitory Service is enabled or not. |
|
233 * |
|
234 * @since S60 v3.2 |
|
235 * @return ETrue if FMS is enabled, else EFalse. |
|
236 */ |
|
237 TBool IsFMSEnabled(); |
|
238 |
|
239 /** |
|
240 * Sets the download activity state to the P&S Key used to sync with DM UI. |
|
241 * |
|
242 * @since S60 v3.2 |
|
243 * @param aValue ETrue when download is active, else EFalse. |
|
244 * @return None |
|
245 */ |
|
246 void SetDownloadActive(TBool aValue); |
|
247 |
|
248 /** |
|
249 * Returns the download activity state |
|
250 * |
|
251 * @since S60 v3.2 |
|
252 * @return aValue ETrue when download is active, else EFalse. |
|
253 */ |
|
254 |
|
255 TBool IsDownloadActive(); |
|
256 |
|
257 /** |
|
258 * Starts to suspend the ongoing download |
|
259 * |
|
260 * @since S60 v3.2 |
|
261 * @param aReason Reason to suspend the download. Value is one of RFotaEngineSession::TResult. |
|
262 * @param aSilent Is suspend operation to be silent? |
|
263 * @return None |
|
264 */ |
|
265 void RunDownloadSuspendL(const TInt aReason, TBool aSilent=EFalse); |
|
266 |
|
267 /** |
|
268 * Starts to cancel the ongoing download |
|
269 * |
|
270 * @since S60 v3.2 |
|
271 * @param aReason Reason to cancel the download. Value is one of RFotaEngineSession::TResult. |
|
272 * @param aSilent Is cancel operation to be silent? |
|
273 * @return None |
|
274 */ |
|
275 void RunDownloadCancelL(const TInt aReason, TBool aSilent=EFalse); |
|
276 |
|
277 /** |
|
278 * Should update be started after download completes |
|
279 */ |
|
280 TBool iUpdateAfterDownload; |
|
281 |
|
282 /** |
|
283 * Download is to be restarted. (counter) |
|
284 */ |
|
285 TInt iRestartCounter; |
|
286 |
|
287 /** |
|
288 * Download state |
|
289 */ |
|
290 TPackageState iDLState; |
|
291 |
|
292 |
|
293 /** |
|
294 * Download URL |
|
295 */ |
|
296 HBufC8* iUrl; |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 private: |
|
302 |
|
303 |
|
304 /** |
|
305 * Launch notifier. Also used to end download silently. |
|
306 * |
|
307 * @since S60 v3.1 |
|
308 * @param aNotetype Notetype |
|
309 * @param aIntParam int param |
|
310 * @param aMemoryneeded How much disk space needed for download |
|
311 * @param aFinishOnly finish only, do not launch notifier |
|
312 * @return none |
|
313 */ |
|
314 |
|
315 void LaunchNotifierL( const TSyncMLFwUpdNoteTypes aNotetype |
|
316 ,const TInt aIntParam |
|
317 ,const TInt aMemoryNeeded |
|
318 ,TBool aFinishOnly=EFalse ); |
|
319 |
|
320 /** |
|
321 * Reads the download variations from the Cenrep keys into instance variables. |
|
322 * They include - Fota Suspend & Resume feature state (on/off) & |
|
323 * Fota Monitory Service feature state (on/off) |
|
324 * |
|
325 * @since S60 v3.2 |
|
326 * @return none |
|
327 */ |
|
328 void CheckDownloadVariations(); |
|
329 |
|
330 /** |
|
331 * Retrieves the RHttpDownload object from Download Manager for the suspended download. |
|
332 * Since concurrent downloads are not possible, there will be always zero or one suspended download. |
|
333 * |
|
334 * @since S60 v3.2 |
|
335 * @return RHttpDownload object. If NULL, it means that there is no suspended download or the retrieval has fails. |
|
336 */ |
|
337 RHttpDownload* RetrieveDownloadL(); |
|
338 |
|
339 /** |
|
340 * Sets the IAP Id to use during download. The same API is used for fresh or resuming download. |
|
341 * During resuming of download, the selection of IAP logic varies as below: |
|
342 * 1. If IAP is always ask in DM profile, uses the earlier set during FMS trigger |
|
343 * 2. If IAP is always ask in DM profile, query user for IAP during user trigger |
|
344 * 3. If IAP has changed in DM profile after suspend, use the newer one during resume |
|
345 * |
|
346 * @since S60 v3.2 |
|
347 * @param aParams contains the download operation details |
|
348 * @param aIapid Out param, the IAP Id is set here. |
|
349 * @return None |
|
350 */ |
|
351 void SetIapToUseL(TPackageState aParams,const TInt aIapid); |
|
352 |
|
353 /** |
|
354 * Sets the Download UI behavior for fresh or resuming download. |
|
355 * |
|
356 * @since S60 v3.2 |
|
357 * @param aFreshDL ETrue if the download is fresh, else EFalse. |
|
358 * @return None |
|
359 */ |
|
360 void SetDownloadUiBehavior(TBool aFreshDL); |
|
361 |
|
362 /** |
|
363 * Creates a fresh download |
|
364 * |
|
365 * @since S60 v3.1 |
|
366 * @param |
|
367 * @return none |
|
368 */ |
|
369 void CreateDownloadL(); |
|
370 /** |
|
371 * SetDLResultdlErrorId Set the appropriate error codes. |
|
372 * |
|
373 * @since S60 v5.0 |
|
374 * @param adlErrorId error id from DlMgr |
|
375 * @param asysErrorId error id from system |
|
376 * @return none |
|
377 */ |
|
378 void SetDLResultdlErrorId( THttpDownloadMgrError adlErrorId, TInt32 asysErrorId); |
|
379 |
|
380 /** |
|
381 * ReSetDownloadL Reset the Fota state to Download failed |
|
382 * |
|
383 * @since S60 v5.0 |
|
384 * @param atoresetdl Bool value if ETrue the set the state to Download Failed |
|
385 * @return none |
|
386 */ |
|
387 void ReSetDownloadL(TBool atoresetdl); |
|
388 |
|
389 /** |
|
390 * DetermineUISANOFF Determine UI behavior when SAN is OFF |
|
391 * |
|
392 * @since S60 v5.0 |
|
393 * @param aBehavior behavior depending upon whether SAN is supported or not |
|
394 * @return none |
|
395 */ |
|
396 void DetermineUISANOFF(TInt aBehavior); |
|
397 |
|
398 /** |
|
399 * DetermineUISANOFF Determine UI behavior when SAN is OFF |
|
400 * |
|
401 * @since S60 v5.0 |
|
402 * @param aBehavior behavior depending upon whether SAN is supported or not |
|
403 * @return none |
|
404 */ |
|
405 void DetermineUISANON(TInt aBehavior); |
|
406 /** |
|
407 * Reference to fotaserver. |
|
408 * Not own |
|
409 */ |
|
410 CFotaServer* iFotaServer; |
|
411 |
|
412 /** |
|
413 * Reference to download mgr. |
|
414 */ |
|
415 RHttpDownloadMgr iDownloadMgr; |
|
416 |
|
417 /** |
|
418 * The download object for the current download. |
|
419 */ |
|
420 RHttpDownload* iDownload; |
|
421 |
|
422 /** |
|
423 * The downloaded content size in bytes. |
|
424 */ |
|
425 TInt iDownloadedContentSize; |
|
426 |
|
427 /** |
|
428 * Download progress dialog. |
|
429 */ |
|
430 CFotaDLProgressDlg* iDLProgressDlg; |
|
431 |
|
432 /** |
|
433 * Content size received in previous event |
|
434 */ |
|
435 TInt iPreviousContentSize; |
|
436 |
|
437 /** |
|
438 * handles notifier completion |
|
439 */ |
|
440 CFotaDownloadNotifHandler* iNotifHandler; |
|
441 |
|
442 |
|
443 /** |
|
444 * Indicates that this download should be reset. (could be inclded in progress) |
|
445 */ |
|
446 TBool iDLNeedsReset; |
|
447 |
|
448 /** |
|
449 * Progress state. |
|
450 */ |
|
451 TFotaDLProgress iDLProgress; |
|
452 |
|
453 /** |
|
454 * Showing OMA Content Descriptor |
|
455 */ |
|
456 TBool iShowOMACDUI; |
|
457 |
|
458 /** |
|
459 * Showing Progress bar |
|
460 */ |
|
461 TBool iShowDLPrgUI; |
|
462 |
|
463 /** |
|
464 * Is download resumable? |
|
465 */ |
|
466 TBool iDownloadResumable; |
|
467 |
|
468 /** |
|
469 * Is Fota Monitory service enabled? |
|
470 */ |
|
471 TBool iFMSEnabled; |
|
472 |
|
473 /** |
|
474 * Is Fota download active? |
|
475 */ |
|
476 TBool iDownloadActive; |
|
477 /** |
|
478 * Iap id to be used in download |
|
479 */ |
|
480 TInt iIapid; |
|
481 |
|
482 /** |
|
483 * Is download fresh? |
|
484 */ |
|
485 TBool iFreshDL; |
|
486 |
|
487 /** |
|
488 * Is user initiated resume? |
|
489 */ |
|
490 TBool iUserInitiatedResume; |
|
491 |
|
492 /** |
|
493 * Is fota operation started by user? |
|
494 */ |
|
495 TBool iIsjobStartedFromUI; |
|
496 |
|
497 /** |
|
498 * Value of SAN bit set by the remote Server |
|
499 */ |
|
500 TInt iSanValue; |
|
501 |
|
502 /** |
|
503 * Is suspend/cancel of download operation to be silent? |
|
504 */ |
|
505 TBool iSilentOpn; |
|
506 |
|
507 /** |
|
508 * to check whether downlaod is finalized or not |
|
509 */ |
|
510 TBool iDownloadFinalized; |
|
511 /** |
|
512 * Class that checks for network availability |
|
513 */ |
|
514 CFotaNetworkRegStatus* iMonitor; |
|
515 |
|
516 }; |
|
517 |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 NONSHARABLE_CLASS ( CFotaDownloadNotifHandler ) |
|
523 : public CActive |
|
524 { |
|
525 public: // new functions |
|
526 static CFotaDownloadNotifHandler* NewL (CFotaDownload* aDownload); |
|
527 |
|
528 CFotaDownloadNotifHandler(); |
|
529 |
|
530 ~CFotaDownloadNotifHandler(); |
|
531 /** |
|
532 * Handle user action |
|
533 * |
|
534 * @since S60 v3.1 |
|
535 * @param None |
|
536 * @return None |
|
537 */ |
|
538 virtual void RunL(); |
|
539 |
|
540 |
|
541 /** |
|
542 * Handle leaving Runl |
|
543 * |
|
544 * @since S60 v3.1 |
|
545 * @param aError error code |
|
546 * @return Error code |
|
547 */ |
|
548 virtual TInt RunError(TInt aError); |
|
549 |
|
550 |
|
551 /** |
|
552 * Handle cancel of active object |
|
553 * |
|
554 * @since S60 v3.1 |
|
555 * @param none |
|
556 * @return none |
|
557 */ |
|
558 void DoCancel(); |
|
559 |
|
560 /** |
|
561 * Shows notifier and/or ends download |
|
562 * |
|
563 * @since S60 v3.1 |
|
564 * @param aNotetype type of the note as defined in syncmlnotifier |
|
565 * @param aIntParam Generic parameter, defined in syncmlnotifier |
|
566 * @param aMemoryNeeded Amount of disk space needed. Only one notifier |
|
567 * type consumes this. |
|
568 * @param aFinishOnly Do not show notifier, finish download only |
|
569 * @return none |
|
570 */ |
|
571 void LaunchNotifierL( const TSyncMLFwUpdNoteTypes aNotetype |
|
572 ,const TInt aIntParam |
|
573 ,const TInt aMemoryNeeded |
|
574 ,TBool aFinishOnly=EFalse ); |
|
575 |
|
576 /** |
|
577 * Is any notifier displayed? |
|
578 * |
|
579 * @since S60 v3.2 |
|
580 * @param none |
|
581 * @return ETrue if yes, otherwise EFalse |
|
582 */ |
|
583 TBool IsOpen(); |
|
584 private: |
|
585 |
|
586 CFotaDownload* iDownload; |
|
587 |
|
588 /** |
|
589 * Notifier for showing notes |
|
590 */ |
|
591 RNotifier iNotifier; |
|
592 |
|
593 /** |
|
594 * Notifier input parameters |
|
595 */ |
|
596 TSyncMLFwUpdNotifParams iNotifParams; |
|
597 |
|
598 /** |
|
599 * Notifier response |
|
600 */ |
|
601 TSyncMLFwUpdNotifRetValPckg iDummyResponsePckg; |
|
602 |
|
603 |
|
604 }; |
|
605 |
|
606 |
|
607 |
|
608 #endif |
|