|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * Application class for Mce. |
|
16 * |
|
17 */ |
|
18 |
|
19 // system include files go here: |
|
20 |
|
21 #include <iaupdate.h> |
|
22 #include <iaupdateparameters.h> |
|
23 #include <iaupdateresult.h> |
|
24 #include <featmgr.h> |
|
25 |
|
26 // user include files go here: |
|
27 |
|
28 #include "mceiaupdateutils.h" |
|
29 #include "MceLogText.h" |
|
30 |
|
31 // ======== MEMBER FUNCTIONS ======== |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // C++ default constructor. |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CMceIAUpdateUtils::CMceIAUpdateUtils() |
|
38 : iUpdate( NULL ), iParameters( NULL ) |
|
39 { |
|
40 } |
|
41 |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // Symbian 2nd phase constructor. |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 void CMceIAUpdateUtils::ConstructL() |
|
48 { |
|
49 if( FeatureManager::FeatureSupported( KFeatureIdIAUpdate ) ) |
|
50 { |
|
51 iUpdate = CIAUpdate::NewL( *this ); |
|
52 if( iUpdate ) |
|
53 { |
|
54 iParameters = CIAUpdateParameters::NewL(); |
|
55 } |
|
56 } |
|
57 } |
|
58 |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // Two-phased constructor. |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 CMceIAUpdateUtils* CMceIAUpdateUtils::NewL() |
|
65 { |
|
66 CMceIAUpdateUtils* self = new( ELeave ) CMceIAUpdateUtils; |
|
67 CleanupStack::PushL( self ); |
|
68 self->ConstructL(); |
|
69 CleanupStack::Pop( self ); |
|
70 return self; |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // Destructor |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 CMceIAUpdateUtils::~CMceIAUpdateUtils() |
|
78 { |
|
79 Delete(); |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // Start IA update process. |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void CMceIAUpdateUtils::StartL( const TUid aAppUid ) |
|
87 { |
|
88 if( iUpdate && iParameters ) |
|
89 { |
|
90 iParameters->SetUid( aAppUid ); |
|
91 |
|
92 // Don't want any wait dialog. |
|
93 iParameters->SetShowProgress( EFalse ); |
|
94 |
|
95 // Check the updates |
|
96 MCELOGGER_WRITE("StartL --- check updates"); |
|
97 iUpdate->CheckUpdates( *iParameters ); |
|
98 } |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // Cleanup function. |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 void CMceIAUpdateUtils::Delete() |
|
106 { |
|
107 if( iUpdate ) |
|
108 { |
|
109 delete iUpdate; |
|
110 iUpdate = NULL; |
|
111 } |
|
112 if( iParameters ) |
|
113 { |
|
114 delete iParameters; |
|
115 iParameters = NULL; |
|
116 } |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // From class MIAUpdateObserver. |
|
121 // This callback function is called when the update checking operation has |
|
122 // completed. |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 void CMceIAUpdateUtils::CheckUpdatesComplete( TInt aErrorCode, |
|
126 TInt aAvailableUpdates ) |
|
127 { |
|
128 if ( aErrorCode == KErrNone ) |
|
129 { |
|
130 if ( aAvailableUpdates > 0 ) |
|
131 { |
|
132 // There were some updates available. |
|
133 MCELOGGER_WRITE("CheckUpdatesComplete --- updates available"); |
|
134 iUpdate->UpdateQuery(); |
|
135 } |
|
136 else |
|
137 { |
|
138 // No updates available. |
|
139 MCELOGGER_WRITE("CheckUpdatesComplete --- no updates available"); |
|
140 } |
|
141 } |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // From class MIAUpdateObserver. |
|
146 // This callback function is called when an update operation has completed. |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 void CMceIAUpdateUtils::UpdateComplete( TInt aErrorCode, CIAUpdateResult* aResult ) |
|
150 { |
|
151 if ( aErrorCode == KErrNone ) |
|
152 { |
|
153 // The update process that the user started from IAUpdate UI is now |
|
154 // completed. |
|
155 // If the client application itself was updated in the update process, |
|
156 // this callback is never called, since the client is not running anymore. |
|
157 MCELOGGER_WRITE("UpdateComplete ---"); |
|
158 TInt successCount = aResult->SuccessCount(); |
|
159 } |
|
160 |
|
161 if( aResult ) |
|
162 { |
|
163 // Ownership was transferred, so this must be deleted by the client. |
|
164 delete aResult; |
|
165 } |
|
166 |
|
167 // We do not need the client-server session anymore. |
|
168 Delete(); |
|
169 } |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // From class MIAUpdateObserver. |
|
173 // This callback function is called when an update query operation has completed. |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 void CMceIAUpdateUtils::UpdateQueryComplete( TInt aErrorCode, TBool aUpdateNow ) |
|
177 { |
|
178 if ( aErrorCode == KErrNone ) |
|
179 { |
|
180 if ( aUpdateNow ) |
|
181 { |
|
182 // User choosed to update now, so let's launch the IAUpdate UI. |
|
183 MCELOGGER_WRITE("UpdateQueryComplete --- now"); |
|
184 iUpdate->ShowUpdates( *iParameters ); |
|
185 } |
|
186 else |
|
187 { |
|
188 // The answer was 'Later'. |
|
189 MCELOGGER_WRITE("UpdateQueryComplete --- later"); |
|
190 } |
|
191 } |
|
192 } |
|
193 |
|
194 // EOF |