26 // user include files go here: |
26 // user include files go here: |
27 #include "mceui.h" |
27 #include "mceui.h" |
28 #include "mceiaupdateutils.h" |
28 #include "mceiaupdateutils.h" |
29 #include "MceLogText.h" |
29 #include "MceLogText.h" |
30 |
30 |
|
31 // CONSTANT |
|
32 |
|
33 // Defines the time span in hours for the next IAD update check event |
|
34 // which will be trigered. |
|
35 const TInt KMceIADUpdateCheckRetryInterval = 24; |
|
36 |
31 // ======== MEMBER FUNCTIONS ======== |
37 // ======== MEMBER FUNCTIONS ======== |
32 |
38 |
33 // --------------------------------------------------------------------------- |
39 // --------------------------------------------------------------------------- |
34 // C++ default constructor. |
40 // C++ default constructor. |
35 // --------------------------------------------------------------------------- |
41 // --------------------------------------------------------------------------- |
45 // Symbian 2nd phase constructor. |
51 // Symbian 2nd phase constructor. |
46 // --------------------------------------------------------------------------- |
52 // --------------------------------------------------------------------------- |
47 // |
53 // |
48 void CMceIAUpdateUtils::ConstructL() |
54 void CMceIAUpdateUtils::ConstructL() |
49 { |
55 { |
50 if( FeatureManager::FeatureSupported( KFeatureIdIAUpdate ) ) |
56 iUpdate = NULL; |
51 { |
57 iParameters = NULL; |
52 iUpdate = CIAUpdate::NewL( *this ); |
58 // set it to current time. |
53 if( iUpdate ) |
59 iPrevIADUpdateCheckTry.UniversalTime(); |
54 { |
|
55 iParameters = CIAUpdateParameters::NewL(); |
|
56 } |
|
57 } |
|
58 } |
60 } |
59 |
61 |
60 |
62 |
61 // --------------------------------------------------------------------------- |
63 // --------------------------------------------------------------------------- |
62 // Two-phased constructor. |
64 // Two-phased constructor. |
85 // Start IA update process. |
87 // Start IA update process. |
86 // --------------------------------------------------------------------------- |
88 // --------------------------------------------------------------------------- |
87 // |
89 // |
88 void CMceIAUpdateUtils::DoStartL( const TUid aAppUid ) |
90 void CMceIAUpdateUtils::DoStartL( const TUid aAppUid ) |
89 { |
91 { |
|
92 if(!iUpdate) |
|
93 { |
|
94 iUpdate = CIAUpdate::NewL( *this ); |
|
95 } |
|
96 |
|
97 if( !iParameters ) |
|
98 { |
|
99 iParameters = CIAUpdateParameters::NewL(); |
|
100 } |
|
101 |
90 if( iUpdate && iParameters ) |
102 if( iUpdate && iParameters ) |
91 { |
103 { |
92 iParameters->SetUid( aAppUid ); |
104 iParameters->SetUid( aAppUid ); |
93 |
105 |
94 // Don't want any wait dialog. |
106 // Don't want any wait dialog. |
96 |
108 |
97 // Check the updates |
109 // Check the updates |
98 MCELOGGER_WRITE("StartL --- check updates"); |
110 MCELOGGER_WRITE("StartL --- check updates"); |
99 iUpdate->CheckUpdates( *iParameters ); |
111 iUpdate->CheckUpdates( *iParameters ); |
100 } |
112 } |
|
113 else |
|
114 { |
|
115 Delete(); //Delete session with IAD server |
|
116 } |
101 } |
117 } |
102 |
118 |
103 // --------------------------------------------------------------------------- |
119 // --------------------------------------------------------------------------- |
104 // Cleanup function. |
120 // Cleanup function. |
105 // --------------------------------------------------------------------------- |
121 // --------------------------------------------------------------------------- |
125 // ----------------------------------------------------------------------------- |
141 // ----------------------------------------------------------------------------- |
126 // |
142 // |
127 void CMceIAUpdateUtils::CheckUpdatesComplete( TInt aErrorCode, |
143 void CMceIAUpdateUtils::CheckUpdatesComplete( TInt aErrorCode, |
128 TInt aAvailableUpdates ) |
144 TInt aAvailableUpdates ) |
129 { |
145 { |
|
146 TBool bContinue = EFalse; |
|
147 |
130 if ( aErrorCode == KErrNone ) |
148 if ( aErrorCode == KErrNone ) |
131 { |
149 { |
132 if ( aAvailableUpdates > 0 ) |
150 if ( aAvailableUpdates > 0 ) |
133 { |
151 { |
134 if((iMceUi.IsForeground())&&(iMceUi.MceViewActive(EMceMainViewActive))) |
152 if((iMceUi.IsForeground())&&(iMceUi.MceViewActive(EMceMainViewActive))) |
135 { |
153 { |
136 // There were some updates available. |
154 // There were some updates available. |
137 MCELOGGER_WRITE("CheckUpdatesComplete --- updates available"); |
155 MCELOGGER_WRITE("CheckUpdatesComplete --- updates available"); |
138 iUpdate->UpdateQuery(); |
156 iUpdate->UpdateQuery(); |
|
157 bContinue = ETrue; |
139 } |
158 } |
140 else |
159 else |
141 { |
160 { |
142 MCELOGGER_WRITE("CheckUpdatesComplete --- But MessageView or Delivery Reports View is active"); |
161 MCELOGGER_WRITE("CheckUpdatesComplete --- But MessageView or Delivery Reports View is active"); |
143 } |
162 } |
146 { |
165 { |
147 // No updates available. |
166 // No updates available. |
148 MCELOGGER_WRITE("CheckUpdatesComplete --- no updates available"); |
167 MCELOGGER_WRITE("CheckUpdatesComplete --- no updates available"); |
149 } |
168 } |
150 } |
169 } |
|
170 if(!bContinue) |
|
171 { |
|
172 Delete(); //Delete session with IAD server |
|
173 } |
|
174 |
151 } |
175 } |
152 |
176 |
153 // ----------------------------------------------------------------------------- |
177 // ----------------------------------------------------------------------------- |
154 // From class MIAUpdateObserver. |
178 // From class MIAUpdateObserver. |
155 // This callback function is called when an update operation has completed. |
179 // This callback function is called when an update operation has completed. |
182 // This callback function is called when an update query operation has completed. |
206 // This callback function is called when an update query operation has completed. |
183 // ----------------------------------------------------------------------------- |
207 // ----------------------------------------------------------------------------- |
184 // |
208 // |
185 void CMceIAUpdateUtils::UpdateQueryComplete( TInt aErrorCode, TBool aUpdateNow ) |
209 void CMceIAUpdateUtils::UpdateQueryComplete( TInt aErrorCode, TBool aUpdateNow ) |
186 { |
210 { |
|
211 TBool bContinue = EFalse; |
187 if ( aErrorCode == KErrNone ) |
212 if ( aErrorCode == KErrNone ) |
188 { |
213 { |
189 if ( aUpdateNow ) |
214 if ( aUpdateNow ) |
190 { |
215 { |
191 // User choosed to update now, so let's launch the IAUpdate UI. |
216 // User choosed to update now, so let's launch the IAUpdate UI. |
192 MCELOGGER_WRITE("UpdateQueryComplete --- now"); |
217 MCELOGGER_WRITE("UpdateQueryComplete --- now"); |
193 iUpdate->ShowUpdates( *iParameters ); |
218 iUpdate->ShowUpdates( *iParameters ); |
|
219 bContinue = ETrue; |
194 } |
220 } |
195 else |
221 else |
196 { |
222 { |
197 // The answer was 'Later'. |
223 // The answer was 'Later'. |
198 MCELOGGER_WRITE("UpdateQueryComplete --- later"); |
224 MCELOGGER_WRITE("UpdateQueryComplete --- later"); |
199 } |
225 } |
200 } |
226 } |
|
227 if(!bContinue) |
|
228 { |
|
229 Delete(); //Delete session with IAD server |
|
230 } |
201 } |
231 } |
202 // ----------------------------------------------------------------------------- |
232 // ----------------------------------------------------------------------------- |
203 // From class MIAUpdateObserver. |
233 // From class MIAUpdateObserver. |
204 // This callback function is called when an update query operation has completed. |
234 // This callback function is called when an update query operation has completed. |
205 // ----------------------------------------------------------------------------- |
235 // ----------------------------------------------------------------------------- |
242 void CMceIAUpdateUtils::DoCancel() |
272 void CMceIAUpdateUtils::DoCancel() |
243 { |
273 { |
244 |
274 |
245 } |
275 } |
246 |
276 |
|
277 // --------------------------------------------------------------------------- |
|
278 // Is IAD Update requried to do now |
|
279 // YES, If the KMceIADUpdateCheckRetryInterval is over after the previous try |
|
280 // NO, If the KMceIADUpdateCheckRetryInterval is not over after the previous retry |
|
281 // --------------------------------------------------------------------------- |
|
282 // |
|
283 TBool CMceIAUpdateUtils::IsUpdateRequired() |
|
284 { |
|
285 TBool required = EFalse; |
|
286 TTime currTime; |
|
287 TTimeIntervalHours hourInterval; |
|
288 TInt err = KErrNone; |
|
289 |
|
290 currTime.UniversalTime(); |
|
291 |
|
292 err = currTime.HoursFrom(iPrevIADUpdateCheckTry,hourInterval); |
|
293 |
|
294 // KErrNone-> successful case, |
|
295 // reset the iPrevIADUpdateCheckTry to current time, |
|
296 // start IAD check update |
|
297 |
|
298 // KErrOverflow -> if the calculated interval |
|
299 // is too large for a 32-bit integer |
|
300 // reset the iPrevIADUpdateCheckTry to current time |
|
301 // start IAD check update |
|
302 |
|
303 // in all other cases don't do any thing. |
|
304 |
|
305 if(((err == KErrNone)&& |
|
306 (hourInterval.Int() >= KMceIADUpdateCheckRetryInterval )) |
|
307 ||(err == KErrOverflow)) |
|
308 { |
|
309 iPrevIADUpdateCheckTry.UniversalTime(); |
|
310 required = ETrue; |
|
311 } |
|
312 |
|
313 return required; |
|
314 } |
247 // EOF |
315 // EOF |