|
1 /* |
|
2 * Copyright (c) 2007-2009 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: This module contains the header file of CIAUpdateUiController |
|
15 * class . |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 //INCLUDES |
|
22 #ifndef IAUPDATEUICONTROLLER_H |
|
23 #define IAUPDATEUICONTROLLER_H |
|
24 |
|
25 #include <e32base.h> |
|
26 #include "iaupdateuidefines.h" |
|
27 #include "iaupdatecontroller.h" |
|
28 #include "iaupdatecontrollerobserver.h" |
|
29 #include "iaupdatenodeobserver.h" |
|
30 #include "iaupdatewaitdialogobserver.h" |
|
31 #include "iaupdatestarterobserver.h" |
|
32 #include "iaupdateroaminghandlerobserver.h" |
|
33 #include "iaupdaterefreshobserver.h" |
|
34 #include "iaupdateresultsinfo.h" |
|
35 #include "iaupdateversion.h" |
|
36 #include "iaupdateanynode.h" |
|
37 |
|
38 // FORWARD DECLARATIONS |
|
39 class CIAUpdateWaitDialog; |
|
40 class CIAUpdateProgressDialog; |
|
41 class CIAUpdateNodeFilter; |
|
42 class CIAUpdateStarter; |
|
43 class CIAUpdateControllerFile; |
|
44 class CIAUpdateUiConfigData; |
|
45 class CIAUpdateRoamingHandler; |
|
46 class CIAUpdateRefreshHandler; |
|
47 class MIAUpdateUiControllerObserver; |
|
48 class MIAUpdateHistory; |
|
49 class MIAUpdateFwNode; |
|
50 |
|
51 |
|
52 struct SIAUpdateNodeId |
|
53 { |
|
54 MIAUpdateAnyNode::TNodeType iNodeType; |
|
55 TUid iPackageUid; |
|
56 TIAUpdateVersion iVersion; |
|
57 TBool iSelected; |
|
58 }; |
|
59 |
|
60 |
|
61 // CLASS DECLARATION |
|
62 /** |
|
63 * CIAUpdateUiController controls update flow in UI |
|
64 * |
|
65 */ |
|
66 class CIAUpdateUiController : |
|
67 public CBase, |
|
68 public MIAUpdateControllerObserver, |
|
69 public MIAUpdateNodeObserver, |
|
70 public MIAUpdateWaitDialogObserver, |
|
71 public MIAUpdateStarterObserver, |
|
72 public MIAUpdateRoamingHandlerObserver, |
|
73 public MIAUpdateRefreshObserver |
|
74 { |
|
75 |
|
76 public: //new functions |
|
77 |
|
78 /** |
|
79 * Symbian two phased constructor. |
|
80 * @param aObserver Observer interface of controller |
|
81 * @return Instance of the created server object. |
|
82 */ |
|
83 static CIAUpdateUiController* NewLC( |
|
84 MIAUpdateUiControllerObserver& aObserver ); |
|
85 |
|
86 /** |
|
87 * Symbian two phased constructor. |
|
88 * @param aObserver Observer interface of controller |
|
89 * @return Instance of the created server object. |
|
90 */ |
|
91 static CIAUpdateUiController* NewL( |
|
92 MIAUpdateUiControllerObserver& aObserver ); |
|
93 |
|
94 /** |
|
95 * Destructor |
|
96 */ |
|
97 virtual ~CIAUpdateUiController(); |
|
98 |
|
99 /** |
|
100 * @return const CIAUpdateUiConfigData& Configuration data |
|
101 * from the configuration file. |
|
102 */ |
|
103 const CIAUpdateUiConfigData& ConfigData() const; |
|
104 |
|
105 /** |
|
106 * @see MIAController::SetDefaultConnectionMethodL |
|
107 */ |
|
108 void SetDefaultConnectionMethodL( |
|
109 const TIAUpdateConnectionMethod& aMethod ); |
|
110 |
|
111 /** |
|
112 * Check updates |
|
113 */ |
|
114 void CheckUpdatesL(); |
|
115 |
|
116 /** |
|
117 * Start refresh |
|
118 */ |
|
119 void StartRefreshL(); |
|
120 |
|
121 /** |
|
122 * Starts installation |
|
123 * @param aNodes An array of nodes to be installed |
|
124 */ |
|
125 void StartInstallL( MIAUpdateNode& aNode ); |
|
126 |
|
127 /** |
|
128 * Starts software updating. |
|
129 */ |
|
130 void StartUpdateL(); |
|
131 |
|
132 /** |
|
133 * Continue software updating, next item is handled. |
|
134 * @param aSelfUpdateFinished ETrue if the update is continued right after |
|
135 * the self update. |
|
136 */ |
|
137 void ContinueUpdateL( TBool aSelfUpdateFinished ); |
|
138 |
|
139 /** |
|
140 * Get list of nodes |
|
141 * @return An array of nodes |
|
142 */ |
|
143 const RPointerArray< MIAUpdateNode >& Nodes() const; |
|
144 |
|
145 /** |
|
146 * Get list of firmware nodes |
|
147 * @return An array of nodes |
|
148 */ |
|
149 const RPointerArray< MIAUpdateFwNode >& FwNodes() const; |
|
150 |
|
151 /** |
|
152 * @see MIAUpdateController::HistoryL |
|
153 */ |
|
154 MIAUpdateHistory& HistoryL(); |
|
155 |
|
156 /** |
|
157 * Sets the request type |
|
158 * @param aRequestType Request type |
|
159 */ |
|
160 void SetRequestType( |
|
161 IAUpdateUiDefines::TIAUpdateUiRequestType aRequestType ); |
|
162 |
|
163 /** |
|
164 * Cancel ongoing async operation |
|
165 **/ |
|
166 void CancelOperation(); |
|
167 |
|
168 /** |
|
169 * Info about success of updates |
|
170 * @return TIAUpdateResultsInfo Describes success |
|
171 * of update operations |
|
172 **/ |
|
173 TIAUpdateResultsInfo ResultsInfo() const; |
|
174 |
|
175 /** |
|
176 * Count of available updates |
|
177 * @return Count of available updates |
|
178 **/ |
|
179 TInt CountOfAvailableUpdates() const; |
|
180 |
|
181 /** |
|
182 * Gives access to starter object |
|
183 * @return Pointer to CIAUpdateStarter instance |
|
184 **/ |
|
185 const CIAUpdateStarter* Starter() const; |
|
186 |
|
187 /** |
|
188 * Gives access to filter object |
|
189 * @return Pointer to CIAUpdateNodeFilte instance |
|
190 **/ |
|
191 const CIAUpdateNodeFilter* Filter() const; |
|
192 |
|
193 /** |
|
194 * Do cancel depending on request type and state |
|
195 * @return True value if possible cancel has been performed |
|
196 * and/or application can be closed by client |
|
197 **/ |
|
198 TBool DoCancelIfAllowed(); |
|
199 |
|
200 /** |
|
201 * Depending on request type and state closing Application update is |
|
202 * allowed or not by a client application |
|
203 * |
|
204 * @return True if closing is allowed by a client |
|
205 **/ |
|
206 TBool ClosingAllowedByClient(); |
|
207 |
|
208 /** |
|
209 * Starts CIdle before update check. That's because waiting dialogs |
|
210 * may be shown before update check, still client's request to be responsed immediately |
|
211 * |
|
212 * @param aParams Update parameters passed from a client |
|
213 **/ |
|
214 void CheckUpdatesDeferredL( CIAUpdateParameters* aParams, TBool aRefreshFromNetworkDenied ); |
|
215 |
|
216 |
|
217 void PrepareRoamingHandlerL(); |
|
218 |
|
219 /** |
|
220 * This function handles situation when the iaupdate has been restarted after |
|
221 * self update. If restart has occurred, then the update operation will be continued |
|
222 * to the end as in normal update case. |
|
223 * |
|
224 * @param aShutdownRequest True value means that update was completed by end key, |
|
225 * only purchase history to be updated in this function |
|
226 * |
|
227 * @return TBool ETrue if the restart has occurred. EFalse if the application was |
|
228 * not started from self updater. |
|
229 */ |
|
230 TBool HandlePossibleSelfUpdateRestartL( TBool aShutdownRequest ); |
|
231 |
|
232 /** |
|
233 * This is used to get information after self update when |
|
234 * IAD is restarted. |
|
235 * |
|
236 * @return CIAUpdateParameters* Parameter object that is read |
|
237 * from the file. NULL if file was not found. |
|
238 * Ownership is not transferred. |
|
239 */ |
|
240 CIAUpdateParameters* ParamsReadAndRemoveFileL(); |
|
241 |
|
242 /** |
|
243 * Is client role "testing" |
|
244 * |
|
245 * @return ETrue when client's role is "testing" |
|
246 **/ |
|
247 TBool TestRole() const; |
|
248 |
|
249 |
|
250 public: // MIAUpdateControllerObserver |
|
251 |
|
252 /** |
|
253 * @see MIAUpdateControllerObserver::StartupComplete |
|
254 **/ |
|
255 void StartupComplete( TInt aError ); |
|
256 |
|
257 /** |
|
258 * @see MIAUpdateControllerObserver::RefreshComplete |
|
259 **/ |
|
260 void RefreshComplete( const RPointerArray< MIAUpdateAnyNode >& aNodes, |
|
261 TInt aError ); |
|
262 |
|
263 /** |
|
264 * @see MIAUpdateControllerObserver::SelfUpdaterComplete |
|
265 **/ |
|
266 void SelfUpdaterComplete( TInt aErrorCode ); |
|
267 |
|
268 /** |
|
269 * @see MIAUpdateControllerObserver::ServerReportSent |
|
270 **/ |
|
271 void ServerReportSent( TInt aError ); |
|
272 |
|
273 /** |
|
274 * @see MIAUpdateControllerObserver::ClientRole |
|
275 **/ |
|
276 void ClientRole( const TDesC& aClientRole ); |
|
277 |
|
278 |
|
279 public: // MIAUpdateNodeObserver |
|
280 |
|
281 /** |
|
282 * @see MIAUpdateNodeObserver::DownloadProgress |
|
283 **/ |
|
284 void DownloadProgress( MIAUpdateNode& aNode, |
|
285 TUint aProgress, |
|
286 TUint aMaxProgress ); |
|
287 |
|
288 /** |
|
289 * @see MIAUpdateNodeObserver::DownloadComplete |
|
290 **/ |
|
291 void DownloadComplete( MIAUpdateNode& aNode, |
|
292 TInt aError ); |
|
293 |
|
294 /** |
|
295 * @see MIAUpdateNodeObserver::InstallProgress |
|
296 **/ |
|
297 void InstallProgress( MIAUpdateNode& aNode, |
|
298 TUint aProgress, |
|
299 TUint aMaxProgress ); |
|
300 |
|
301 /** |
|
302 * @see MIAUpdateNodeObserver::InstallComplete |
|
303 **/ |
|
304 void InstallComplete( MIAUpdateNode& aNode, |
|
305 TInt aError ); |
|
306 |
|
307 |
|
308 private: // MIAUpdateStarterObserver |
|
309 |
|
310 /** |
|
311 * Called when an outstanding request is completed |
|
312 * |
|
313 * @param aError Error code that informs the result |
|
314 * of the start operation. KErrNone if operation was |
|
315 * succesfull. |
|
316 */ |
|
317 void StartExecutableCompletedL( TInt aError ); |
|
318 |
|
319 |
|
320 private: // MIAUpdateRoamingHandlerObserver |
|
321 |
|
322 /** |
|
323 * Called when roaming handler is prepared |
|
324 */ |
|
325 void RoamingHandlerPrepared(); |
|
326 |
|
327 |
|
328 private: // From MIAUpdateWaitDialogObserver |
|
329 |
|
330 /** |
|
331 * This is called when the dialog is about to be closed. |
|
332 * @param aButtonId - Id of the button, which was used to cancel the dialog. |
|
333 * @return ETrue, if it's ok to close the dialog, EFalse otherwise. |
|
334 */ |
|
335 TBool HandleDialogExitL( TInt aButtonId ); |
|
336 |
|
337 |
|
338 private: // From MIAUpdateRefreshObserver |
|
339 |
|
340 void HandleUiRefreshL(); |
|
341 |
|
342 |
|
343 private: // construction |
|
344 |
|
345 /** |
|
346 * Perform the second phase construction of a CIAUpdateUiController object |
|
347 * this needs to be public due to the way the framework constructs the AppUi |
|
348 */ |
|
349 void ConstructL(); |
|
350 |
|
351 /** |
|
352 * Perform the first phase of two phase construction. |
|
353 * This needs to be public due to the way the framework constructs the AppUi |
|
354 * @param aObserver Observer interface of controller |
|
355 */ |
|
356 CIAUpdateUiController( MIAUpdateUiControllerObserver& aObserver ); |
|
357 |
|
358 |
|
359 private: // new functions |
|
360 |
|
361 /** |
|
362 * Called when refreshing updates list is completed. |
|
363 * |
|
364 * @param aNodes An array of nodes |
|
365 * @param aError Error code |
|
366 */ |
|
367 void RefreshCompleteL( const RPointerArray< MIAUpdateAnyNode >& aNodes, |
|
368 TInt aError ); |
|
369 |
|
370 /** |
|
371 * Called when refreshing updates list is completed. |
|
372 * |
|
373 * @param aNodes An array of nodes |
|
374 * @param aError Error code |
|
375 */ |
|
376 void RefreshUiCompleteL( const RPointerArray< MIAUpdateAnyNode >& aNodes, |
|
377 TInt aError ); |
|
378 |
|
379 |
|
380 /** |
|
381 * Called when downloading of an update is completed |
|
382 * |
|
383 * @param aNode Downloaded node |
|
384 * @param aError Error code |
|
385 */ |
|
386 void DownloadCompleteL( MIAUpdateNode& aNode, TInt aError ); |
|
387 |
|
388 /** |
|
389 * Called when installation of an update is completed |
|
390 * |
|
391 * @param aNode Installed node |
|
392 * @param aError Error code |
|
393 */ |
|
394 void InstallCompleteL( MIAUpdateNode& aNode, TInt aError ); |
|
395 |
|
396 /** |
|
397 * Called when updating is completed |
|
398 * |
|
399 * @param aError Error code |
|
400 */ |
|
401 void UpdateCompleteL( TInt aError ); |
|
402 |
|
403 /** |
|
404 * Finishes the update flow after server reports are sent |
|
405 * or when cancel is called while sending. |
|
406 * |
|
407 * @param aError Error code |
|
408 */ |
|
409 void EndUpdateFlowL( TInt aError ); |
|
410 |
|
411 /** |
|
412 * Callback of CIdle, calls CheckUpdates() |
|
413 * |
|
414 * @param aPtr Pointer to this instance |
|
415 */ |
|
416 static TInt CheckUpdatesDeferredCallbackL( TAny* aPtr ); |
|
417 |
|
418 /** |
|
419 * Shows waiting/progress dialog during update process. |
|
420 * |
|
421 * @param aTextResourceId Resource id of text (Downloading or Installing) |
|
422 * @param aName Name of update |
|
423 * @param aNumber Counter of current update |
|
424 * @param aTotalCount Total count of updates to be updated |
|
425 */ |
|
426 void ShowUpdatingDialogL( TInt aTextResourceId, |
|
427 const TDesC& aName, |
|
428 TInt aNumber, |
|
429 TInt aTotalCount ); |
|
430 |
|
431 /** |
|
432 * Shows waiting dialog during update process. |
|
433 * |
|
434 * @param aDisplayString A string to be displayed |
|
435 * @param aVisibilityDelayOff ETrue if visibility delay is off |
|
436 */ |
|
437 void ShowWaitDialogL( const TDesC& aDisplayString, |
|
438 TBool aVisibilityDelayOff ); |
|
439 |
|
440 /** |
|
441 * Shows progress dialog during update process. |
|
442 * |
|
443 * @param aDisplayString A string to be displayed |
|
444 * @param aVisibilityDelayOff ETrue if visibility delay is off |
|
445 */ |
|
446 void ShowProgressDialogL( const TDesC& aDisplayString, |
|
447 TBool aVisibilityDelayOff ); |
|
448 |
|
449 /** |
|
450 * Removes all possible existing update flow dialogs. |
|
451 * This method is a general way to handle removal of |
|
452 * wait or progress dialogs. |
|
453 */ |
|
454 void RemoveUpdatingDialogsL(); |
|
455 |
|
456 /** |
|
457 * Removes waiting dialog. |
|
458 */ |
|
459 void RemoveWaitDialogL(); |
|
460 |
|
461 /** |
|
462 * Removes progress dialog. |
|
463 */ |
|
464 void RemoveProgressDialogL(); |
|
465 |
|
466 /** |
|
467 * Checks if refreshing of update list allowed from a network |
|
468 * @return ETrue if network refresh allowed |
|
469 */ |
|
470 TBool AllowNetworkRefreshL(); |
|
471 |
|
472 /** |
|
473 * Checks if local update list cache is expired |
|
474 * @return ETrue if local cache is expired |
|
475 */ |
|
476 TBool LocalNodesExpiredL(); |
|
477 |
|
478 /** |
|
479 * Updates local update list cache controller file |
|
480 */ |
|
481 void UpdateControllerFileL(); |
|
482 |
|
483 /** |
|
484 * Checks if a phone is connected in a roaming network |
|
485 * @return ETrue if roaming network |
|
486 */ |
|
487 TBool IsRoaming(); |
|
488 |
|
489 /** |
|
490 * Checks how iaupdate is started |
|
491 * @return ETrue if started by iaupdatelauncher, otherwise started by a client application |
|
492 */ |
|
493 TBool IsStartedByLauncher(); |
|
494 |
|
495 /** |
|
496 * Starts the self updater process if there exists updates that require separate |
|
497 * updater. |
|
498 * @return TBool ETrue if the updater is started. |
|
499 * EFalse if updater was not started. |
|
500 */ |
|
501 TBool StartPossibleSelfUpdateL(); |
|
502 |
|
503 /** |
|
504 * Updates self update item error codes into the purchase history |
|
505 * after self updater could not do its job. |
|
506 * @param aErrorCode Error code that self updater has failed with. |
|
507 */ |
|
508 void UpdateFailedSelfUpdaterInfoToPurchaseHistoryL( TInt aErrorCode ); |
|
509 |
|
510 /** |
|
511 * Handles user cancel |
|
512 */ |
|
513 void HandleUserCancelL(); |
|
514 |
|
515 /** |
|
516 * @return TBool ETrue if IAD has been started right after |
|
517 * the self update. In other words, self update related data |
|
518 * has not been handled yet. Else EFalse. |
|
519 */ |
|
520 TBool CIAUpdateUiController::RestartedFromSelfUpdate(); |
|
521 |
|
522 /** |
|
523 * Writes the possible parameter information into the temporary |
|
524 * file. This is used to save paremeter data during self update. |
|
525 */ |
|
526 void ParamsWriteFileL(); |
|
527 |
|
528 /** |
|
529 * Removes the temporary parameters file if it exists. |
|
530 */ |
|
531 void ParamsRemoveFileL(); |
|
532 |
|
533 void CreateSelectedNodesArrayL(); |
|
534 |
|
535 TBool IAUpdateEnabledL() const; |
|
536 |
|
537 private: // data |
|
538 |
|
539 enum TState |
|
540 { |
|
541 EIdle, |
|
542 ERefreshing, |
|
543 EDownloading, |
|
544 EInstalling, |
|
545 ESendingReport, |
|
546 EUiRefreshing, |
|
547 ESelfUpdating |
|
548 }; |
|
549 |
|
550 MIAUpdateUiControllerObserver& iObserver; |
|
551 |
|
552 MIAUpdateController* iController; |
|
553 |
|
554 RPointerArray< MIAUpdateNode > iNodes; |
|
555 |
|
556 RPointerArray< MIAUpdateNode > iSelectedNodesArray; |
|
557 |
|
558 RPointerArray< MIAUpdateFwNode > iFwNodes; |
|
559 |
|
560 CArrayFix<SIAUpdateNodeId>* iPreviousSelections; |
|
561 |
|
562 RPointerArray<MIAUpdateNode> iServicePackNodes; |
|
563 |
|
564 CIAUpdateWaitDialog* iWaitDialog; |
|
565 |
|
566 CIAUpdateProgressDialog* iProgressDialog; |
|
567 |
|
568 CIAUpdateStarter* iStarter; |
|
569 |
|
570 CIAUpdateRoamingHandler* iRoamingHandler; |
|
571 |
|
572 CIAUpdateRefreshHandler* iRefreshHandler; |
|
573 |
|
574 TInt iCountOfAvailableUpdates; |
|
575 |
|
576 TInt iNodeIndex; |
|
577 |
|
578 CIAUpdateNodeFilter* iFilter; |
|
579 |
|
580 CIAUpdateControllerFile* iControllerFile; |
|
581 |
|
582 CIdle* iIdle; |
|
583 |
|
584 CEikonEnv* iEikEnv; //not owned |
|
585 |
|
586 IAUpdateUiDefines::TIAUpdateUiRequestType iRequestType; |
|
587 |
|
588 TState iState; |
|
589 |
|
590 TBool iClosingAllowedByClient; |
|
591 |
|
592 CIAUpdateUiConfigData* iConfigData; |
|
593 |
|
594 CIAUpdateParameters* iParams; |
|
595 |
|
596 TBool iUserRoamingRejection; |
|
597 |
|
598 TBool iCancelling; |
|
599 |
|
600 TBool iFileInUseError; |
|
601 |
|
602 TBool iRefreshed; |
|
603 |
|
604 TBool iRefreshFromNetworkDenied; |
|
605 |
|
606 TBool iOffConfigurated; |
|
607 |
|
608 TBool iTestRole; |
|
609 |
|
610 }; |
|
611 |
|
612 #endif // IAUPDATEUICONTROLLER_H |
|
613 |