|
1 /* |
|
2 * Copyright (c) 2008-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: Implementation of background checker |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32std.h> |
|
20 //IAD API |
|
21 #include <iaupdate.h> |
|
22 #include <iaupdateparameters.h> |
|
23 #include <iaupdateresult.h> |
|
24 #include <W32STD.H> |
|
25 #include <APGWGNAM.H> |
|
26 #include <apgcli.h> |
|
27 #include <APACMDLN.H> |
|
28 #include <avkon.hrh> |
|
29 #include <stringloader.h> |
|
30 #include <iaupdate.rsg> |
|
31 #include <data_caging_path_literals.hrh> |
|
32 #include <bautils.h> |
|
33 #include <apgtask.h> |
|
34 #include <sysversioninfo.h> //sysversioninfo |
|
35 #include <FeatureControl.h> |
|
36 |
|
37 #include "iaupdateprivatecrkeys.h" |
|
38 #include "iaupdate.hrh" |
|
39 |
|
40 #include "iaupdatebgrefreshtimer.h" |
|
41 #include "iaupdatebglogger.h" |
|
42 #include "iaupdatebgfirsttimehandler.h" |
|
43 #include "iaupdatebginternalfilehandler.h" |
|
44 #include "iaupdatebgconst.h" |
|
45 |
|
46 //MACROS |
|
47 _LIT8( KRefreshFromNetworkDenied, "1" ); |
|
48 _LIT(KIAUpdateResourceFile, "iaupdate.rsc"); |
|
49 _LIT(KIAUpdateLauncherExe, "iaupdatelauncher.exe" ); |
|
50 _LIT(KImageFile, "qgn_note_swupdate_notification.svg"); |
|
51 |
|
52 //CONSTANTS |
|
53 const TUint KIADUpdateLauncherUid( 0x2001FE2F ); |
|
54 |
|
55 // ---------------------------------------------------------- |
|
56 // CIAUpdateBGTimer::NewL() |
|
57 // ---------------------------------------------------------- |
|
58 CIAUpdateBGTimer* CIAUpdateBGTimer::NewL() |
|
59 { |
|
60 CIAUpdateBGTimer* self = new(ELeave)CIAUpdateBGTimer(); |
|
61 CleanupStack::PushL(self); |
|
62 self->ConstructL(); |
|
63 CleanupStack::Pop(self); |
|
64 return self; |
|
65 } |
|
66 |
|
67 |
|
68 // ---------------------------------------------------------- |
|
69 // CIAUpdateBGTimer::ConstructL() |
|
70 // ---------------------------------------------------------- |
|
71 void CIAUpdateBGTimer::ConstructL() |
|
72 { |
|
73 CTimer::ConstructL(); |
|
74 CActiveScheduler::Add( this ); |
|
75 |
|
76 iReminderTimer = CIAUpdateBGReminderTimer::NewL( this ); |
|
77 iUpdate = NULL; |
|
78 iParameters = NULL; |
|
79 |
|
80 iIAUpdateCRSession = NULL; |
|
81 iNotifyHandler = NULL; |
|
82 |
|
83 iControllerFile = CIAUpdateBGControllerFile::NewL(); |
|
84 |
|
85 iInternalFile = CIAUpdateBGInternalFileHandler::NewL(); |
|
86 |
|
87 iSoftNotification = CIAUpdateBGSoftNotification::NewL( this, iInternalFile ); |
|
88 iSoftNotification->StartObservingIfNeededL(); |
|
89 |
|
90 // Get resource file path |
|
91 TFileName fileName; |
|
92 fileName.Copy(TParsePtrC(RProcess().FileName()).Drive()); |
|
93 fileName.Append(KDC_APP_RESOURCE_DIR); |
|
94 fileName.Append(KIAUpdateResourceFile); |
|
95 |
|
96 User::LeaveIfError(iFs.Connect()); |
|
97 |
|
98 // Get language of resource file |
|
99 BaflUtils::NearestLanguageFile( iFs, fileName ); |
|
100 |
|
101 // Open resource file |
|
102 iResourceFile.OpenL( iFs, fileName ); |
|
103 iResourceFile.ConfirmSignatureL(); |
|
104 } |
|
105 |
|
106 |
|
107 // ---------------------------------------------------------- |
|
108 // CIAUpdateBGTimer::~CIAUpdateBGTimer() |
|
109 // ---------------------------------------------------------- |
|
110 CIAUpdateBGTimer::~CIAUpdateBGTimer() |
|
111 { |
|
112 Cancel(); |
|
113 delete iUpdate; |
|
114 delete iParameters; |
|
115 delete iReminderTimer; |
|
116 |
|
117 if ( iNotifyHandler ) |
|
118 { |
|
119 iNotifyHandler->StopListening(); |
|
120 delete iNotifyHandler; |
|
121 } |
|
122 |
|
123 delete iIAUpdateCRSession; |
|
124 delete iControllerFile; |
|
125 delete iInternalFile; |
|
126 delete iSoftNotification; |
|
127 |
|
128 iResourceFile.Close(); |
|
129 iFs.Close(); |
|
130 } |
|
131 |
|
132 |
|
133 // ---------------------------------------------------------- |
|
134 // CIAUpdateBGTimer::StartProcessL() |
|
135 // ---------------------------------------------------------- |
|
136 void CIAUpdateBGTimer::StartProcessL() |
|
137 { |
|
138 FLOG("[bgchecker] StartProcessL"); |
|
139 |
|
140 iMode = ModeL(); |
|
141 |
|
142 switch ( iMode ) |
|
143 { |
|
144 case EFirstTimeMode: |
|
145 case EFirstTimeRemindMode: |
|
146 { |
|
147 if ( IsFirstTimeDialogDisabledL() ) |
|
148 { |
|
149 //this should only happen in testing |
|
150 FLOG("[bgchecker] StartProcessL Firs time dialog is disabled, this should only happen in testing"); |
|
151 |
|
152 //subscribe to automatic checking settings |
|
153 //subscribe to cenrep key for automatic checking for wake up from sleep mode |
|
154 if (iIAUpdateCRSession == NULL ) |
|
155 { |
|
156 iIAUpdateCRSession = CRepository::NewL( KCRUidIAUpdateSettings ); |
|
157 } |
|
158 if (iNotifyHandler == NULL ) |
|
159 { |
|
160 iNotifyHandler = CCenRepNotifyHandler::NewL( *this, *iIAUpdateCRSession ); |
|
161 } |
|
162 FLOG("[bgchecker] StartProcessL go to sleep mode directly"); |
|
163 iNotifyHandler->StartListeningL(); |
|
164 |
|
165 |
|
166 iMode = ESleepMode; |
|
167 SetModeL( iMode ); |
|
168 return; |
|
169 } |
|
170 |
|
171 |
|
172 FLOG("[bgchecker] StartProcessL EFirstTimeMode"); |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 //Wait for some days before activate the first time mode |
|
178 TTimeIntervalMinutes timetowait = |
|
179 TimeIntervalFromNextShowOfNewFeatureDialogL(); |
|
180 FLOG_NUM( " time to wait = %d", timetowait.Int() ); |
|
181 if (timetowait.Int() <= 0) |
|
182 { |
|
183 FLOG("[bgchecker] StartProcessL now"); |
|
184 //start immediately |
|
185 //if agreement is not accepted but auto update is enabled, |
|
186 //jump to normal mode |
|
187 if (!IsAgreementAcceptedL() && !IsAutoUpdateDisabledL()) |
|
188 { |
|
189 iMode = ENormalMode; |
|
190 SetModeL(iMode); |
|
191 FLOG("[bgchecker] Agreement is NOT accepted but AutoUpdate is enabled, Go to Normal mode"); |
|
192 StartUpdatesCheckingL(); |
|
193 return; |
|
194 } |
|
195 |
|
196 TTimeIntervalMinutes timetowait = |
|
197 TimeIntervalFromNextRefreshL(); |
|
198 |
|
199 if (IsAgreementAcceptedL() && !IsAutoUpdateDisabledL() |
|
200 && timetowait.Int() <= 0 ) |
|
201 { |
|
202 //in this case, background checker will connect to server for refreshing |
|
203 //put one minute delay here. |
|
204 StartL(StartAfterOneMin ); |
|
205 } |
|
206 else |
|
207 { |
|
208 StartL( StartNow ); |
|
209 } |
|
210 } |
|
211 else |
|
212 { |
|
213 FLOG("[bgchecker] StartProcessL later"); |
|
214 StartL( timetowait ); |
|
215 } |
|
216 |
|
217 |
|
218 break; |
|
219 } |
|
220 |
|
221 case EFirstTimeMode2: |
|
222 { |
|
223 FLOG("[bgchecker] StartProcessL EFirstTimeMode2"); |
|
224 RunL(); |
|
225 break; |
|
226 } |
|
227 |
|
228 case EFirstTimeMode3: |
|
229 { |
|
230 FLOG("[bgchecker] StartProcessL EFirstTimeMode 3"); |
|
231 //if user accepted the disclaimer already and reboot the phone, |
|
232 //this mode could go to network immediately after boot |
|
233 //We put one min delay here to wait for network ready. |
|
234 StartL(StartAfterOneMin); |
|
235 break; |
|
236 } |
|
237 |
|
238 case ESleepMode: |
|
239 { |
|
240 FLOG("[bgchecker] StartProcessL EFirstTimeMode 4"); |
|
241 //subscribe to automatic checking settings |
|
242 //subscribe to cenrep key for automatic checking for wake up from sleep mode |
|
243 if (iIAUpdateCRSession == NULL ) |
|
244 { |
|
245 iIAUpdateCRSession = CRepository::NewL( KCRUidIAUpdateSettings ); |
|
246 } |
|
247 if (iNotifyHandler == NULL ) |
|
248 { |
|
249 iNotifyHandler = CCenRepNotifyHandler::NewL( *this, *iIAUpdateCRSession ); |
|
250 } |
|
251 |
|
252 iNotifyHandler->StartListeningL(); |
|
253 break; |
|
254 } |
|
255 |
|
256 case ENormalMode: |
|
257 case ERetryMode: |
|
258 { |
|
259 StartUpdatesCheckingL(); |
|
260 break; |
|
261 } |
|
262 |
|
263 default: |
|
264 break; |
|
265 } |
|
266 |
|
267 } |
|
268 |
|
269 |
|
270 // ---------------------------------------------------------- |
|
271 // CIAUpdateBGTimer::IsAgreementAcceptedL() |
|
272 // ---------------------------------------------------------- |
|
273 TBool CIAUpdateBGTimer::IsAgreementAcceptedL() |
|
274 { |
|
275 CIAUpdateBGFirstTimeHandler* fthandler = CIAUpdateBGFirstTimeHandler::NewL(); |
|
276 CleanupStack::PushL( fthandler ); |
|
277 TBool result = fthandler->AgreementAcceptedL(); |
|
278 |
|
279 CleanupStack::PopAndDestroy( fthandler ); |
|
280 |
|
281 return result; |
|
282 } |
|
283 |
|
284 |
|
285 // ---------------------------------------------------------- |
|
286 // CIAUpdateBGTimer::IsAskedAlreadyL() |
|
287 // ---------------------------------------------------------- |
|
288 TBool CIAUpdateBGTimer::IsAskedAlreadyL() |
|
289 { |
|
290 CIAUpdateBGFirstTimeHandler* fthandler = CIAUpdateBGFirstTimeHandler::NewL(); |
|
291 CleanupStack::PushL( fthandler ); |
|
292 TBool result = fthandler->AgreementAskedL(); |
|
293 CleanupStack::PopAndDestroy( fthandler ); |
|
294 return result; |
|
295 } |
|
296 |
|
297 |
|
298 // ---------------------------------------------------------- |
|
299 // CIAUpdateBGTimer::StartUpdatesCheckingL() |
|
300 // ---------------------------------------------------------- |
|
301 void CIAUpdateBGTimer::StartUpdatesCheckingL() |
|
302 { |
|
303 // check what is current setting from user. |
|
304 //if user disable the auto checking, we simply start the cenrep listener |
|
305 if ( IsAutoUpdateDisabledL() ) |
|
306 { |
|
307 ListenAutoUpdateSettingsL(); |
|
308 iMode = ESleepMode; |
|
309 SetModeL( iMode ); |
|
310 return; |
|
311 } |
|
312 |
|
313 FLOG("[bgchecker] checking frequency is set by user"); |
|
314 |
|
315 TTimeIntervalMinutes timetowait = TimeIntervalFromNextRefreshL(); |
|
316 FLOG_NUM(" Next checking update starts after %d minuts", timetowait.Int() ); |
|
317 |
|
318 if ( timetowait.Int() <= 0 ) |
|
319 { |
|
320 FLOG( "Start checking update now."); |
|
321 |
|
322 //this supposes to start immediately but we put 1 min delay here to wait for network registration |
|
323 StartL( StartAfterOneMin ); |
|
324 |
|
325 //don't turn on the reminder since the refresh is started right now |
|
326 //if there is new update, the dialog will pop up. User can start remind timer |
|
327 //via the dialog |
|
328 } |
|
329 else |
|
330 { |
|
331 FLOG_NUM( "Start checking update after %d minutes", timetowait.Int()); |
|
332 StartL( timetowait ); |
|
333 |
|
334 //start reminder timer also if user choose later before reboot |
|
335 //check the value from private folder |
|
336 |
|
337 if ( ReminderOnL() ) |
|
338 { |
|
339 TTime currenttime; |
|
340 currenttime.UniversalTime(); |
|
341 |
|
342 FTIME( currenttime ); |
|
343 |
|
344 TTime nextremindtime = NextRemindTimeL(); |
|
345 |
|
346 FTIME( nextremindtime ); |
|
347 |
|
348 TTimeIntervalMinutes timetogo; |
|
349 nextremindtime.MinutesFrom( currenttime, timetogo ); |
|
350 |
|
351 FLOG_NUM("time to go = %d", timetogo.Int() ); |
|
352 |
|
353 if ( timetogo.Int() <= 0 ) |
|
354 { |
|
355 //pop up the reminder directly |
|
356 ReminderTimerCallBack(); |
|
357 } |
|
358 else |
|
359 { |
|
360 iReminderTimer->StartReminderTimerL( timetogo ); |
|
361 } |
|
362 } |
|
363 } |
|
364 } |
|
365 |
|
366 |
|
367 // ---------------------------------------------------------- |
|
368 // CIAUpdateBGTimer::DoHandleNotifyGeneric() |
|
369 // ---------------------------------------------------------- |
|
370 void CIAUpdateBGTimer::DoHandleNotifyGenericL( TUint32 aId ) |
|
371 { |
|
372 FLOG("[bgchecker] HandleNotifyGeneric"); |
|
373 if ( !IAUpdateEnabledL() ) |
|
374 { |
|
375 Shutdown(); |
|
376 return; |
|
377 } |
|
378 switch ( iMode ) |
|
379 { |
|
380 case ESleepMode: |
|
381 { |
|
382 FLOG_NUM("[bgchecker] HandleNotifyGeneric ESleepMode with Id = %d", aId ); |
|
383 |
|
384 if ( aId == KIAUpdateAutoUpdateCheck ) |
|
385 { |
|
386 if ( IsAutoUpdateDisabledL() ) |
|
387 { |
|
388 FLOG("[bgchecker] HandleNotifyGeneric ESleepMode: Autoupdate is disabled"); |
|
389 iMode = ESleepMode; |
|
390 SetModeL( iMode ); |
|
391 ListenAutoUpdateSettingsL(); |
|
392 } |
|
393 else |
|
394 { |
|
395 FLOG("[bgchecker] HandleNotifyGeneric ESleepMode: Autoupdate is enabled"); |
|
396 //restart the refresh timer according to checking frequency |
|
397 StopListeningAutoUpdateSettingsL(); |
|
398 FLOG("[bgchecker] HandleNotifyGeneric ESleepMode: Stop listenning"); |
|
399 |
|
400 TTimeIntervalMinutes interval( TimeIntervalFromNextRefreshL() ); |
|
401 |
|
402 FLOG("[bgchecker] HandleNotifyGeneric ESleepMode: Start the timer according to interval counted from last refresh"); |
|
403 if ( interval.Int() <= 0 ) |
|
404 { |
|
405 FLOG("[bgchecker] HandleNotifyGeneric ESleepMode: Start now"); |
|
406 StartL( StartNow ); |
|
407 } |
|
408 else |
|
409 { |
|
410 FLOG("[bgchecker] HandleNotifyGeneric ESleepMode: Start later"); |
|
411 StartL( interval ); |
|
412 } |
|
413 |
|
414 FLOG("[bgchecker] HandleNotifyGeneric ESleepMode: Set Normal mode"); |
|
415 //in normal mode now |
|
416 iMode = ENormalMode; |
|
417 SetModeL( ENormalMode ); |
|
418 |
|
419 if ( iNotifyHandler ) |
|
420 { |
|
421 delete iNotifyHandler; |
|
422 iNotifyHandler = NULL; |
|
423 } |
|
424 |
|
425 if ( iIAUpdateCRSession ) |
|
426 { |
|
427 delete iIAUpdateCRSession; |
|
428 iIAUpdateCRSession = NULL; |
|
429 } |
|
430 } |
|
431 } |
|
432 } |
|
433 break; |
|
434 |
|
435 default: |
|
436 break; |
|
437 }; |
|
438 } |
|
439 |
|
440 // ---------------------------------------------------------- |
|
441 // CIAUpdateBGTimer::HandleNotifyGeneric() |
|
442 // ---------------------------------------------------------- |
|
443 void CIAUpdateBGTimer::HandleNotifyGeneric( TUint32 aId ) |
|
444 { |
|
445 TRAP_IGNORE( DoHandleNotifyGenericL( aId ) ); |
|
446 } |
|
447 |
|
448 |
|
449 // ---------------------------------------------------------- |
|
450 // CIAUpdateBGTimer::GetLastUpdateTimeL() |
|
451 // ---------------------------------------------------------- |
|
452 TTime CIAUpdateBGTimer::GetLastRefreshTimeL() |
|
453 { |
|
454 iControllerFile->ReadControllerDataL(); |
|
455 return iControllerFile->RefreshTime(); |
|
456 } |
|
457 |
|
458 // ---------------------------------------------------------- |
|
459 // CIAUpdateBGTimer::SetLastUpdateTime() |
|
460 // ---------------------------------------------------------- |
|
461 TInt CIAUpdateBGTimer::SetLastRefreshTime() |
|
462 { |
|
463 iControllerFile->SetCurrentRefreshTime(); |
|
464 TRAPD( err, iControllerFile->WriteControllerDataL() ); |
|
465 FLOG_NUM("SetLastRefreshTime err = %d", err ); |
|
466 return err; |
|
467 } |
|
468 |
|
469 // ---------------------------------------------------------- |
|
470 // CIAUpdateBGTimer::GetLastTimeShowNewFeatureDialogL() |
|
471 // ---------------------------------------------------------- |
|
472 TTime CIAUpdateBGTimer::GetLastTimeShowNewFeatureDialogL() |
|
473 { |
|
474 iInternalFile->ReadControllerDataL(); |
|
475 return iInternalFile->LastTimeShowNewFeatureDialog(); |
|
476 } |
|
477 |
|
478 // ---------------------------------------------------------- |
|
479 // CIAUpdateBGTimer::SetTimeShowNewFeatureDialogL() |
|
480 // ---------------------------------------------------------- |
|
481 TInt CIAUpdateBGTimer::SetLastTimeShowNewFeatureDialogL( TTime aTime ) |
|
482 { |
|
483 iInternalFile->SetLastTimeShowNewFeatureDialog( aTime ); |
|
484 TRAPD( err,iInternalFile->WriteControllerDataL() ); |
|
485 return err; |
|
486 } |
|
487 |
|
488 |
|
489 // ---------------------------------------------------------- |
|
490 // CIAUpdateBGTimer::NextRemindTimeL() |
|
491 // ---------------------------------------------------------- |
|
492 TTime CIAUpdateBGTimer::NextRemindTimeL() |
|
493 { |
|
494 iInternalFile->ReadControllerDataL(); |
|
495 return iInternalFile->NextRemindTime(); |
|
496 } |
|
497 |
|
498 |
|
499 // ---------------------------------------------------------- |
|
500 // CIAUpdateBGTimer::SetNextRemindTimeL() |
|
501 // ---------------------------------------------------------- |
|
502 TInt CIAUpdateBGTimer::SetNextRemindTimeL( TTime aTime ) |
|
503 { |
|
504 iInternalFile->SetNextRemindTime( aTime ); |
|
505 TRAPD( err,iInternalFile->WriteControllerDataL() ); |
|
506 return err; |
|
507 } |
|
508 |
|
509 |
|
510 // ---------------------------------------------------------- |
|
511 // CIAUpdateBGTimer::ReminderOnL() |
|
512 // ---------------------------------------------------------- |
|
513 TBool CIAUpdateBGTimer::ReminderOnL() |
|
514 { |
|
515 iInternalFile->ReadControllerDataL(); |
|
516 return iInternalFile->ReminderOn(); |
|
517 } |
|
518 |
|
519 |
|
520 // ---------------------------------------------------------- |
|
521 // CIAUpdateBGTimer::SetReminderL() |
|
522 // ---------------------------------------------------------- |
|
523 TInt CIAUpdateBGTimer::SetReminderL( TBool aOn ) |
|
524 { |
|
525 iInternalFile->SetReminder( aOn ); |
|
526 TRAPD( err,iInternalFile->WriteControllerDataL() ); |
|
527 return err; |
|
528 } |
|
529 |
|
530 |
|
531 // ---------------------------------------------------------- |
|
532 // CIAUpdateBGTimer::ModeL() |
|
533 // ---------------------------------------------------------- |
|
534 TIAUpdateBGMode CIAUpdateBGTimer::ModeL() |
|
535 { |
|
536 iInternalFile->ReadControllerDataL(); |
|
537 return iInternalFile->Mode(); |
|
538 } |
|
539 |
|
540 |
|
541 // ---------------------------------------------------------- |
|
542 // CIAUpdateBGTimer::SetModeL() |
|
543 // ---------------------------------------------------------- |
|
544 TInt CIAUpdateBGTimer::SetModeL( TIAUpdateBGMode aMode ) |
|
545 { |
|
546 iInternalFile->SetMode( aMode ); |
|
547 TRAPD( err,iInternalFile->WriteControllerDataL() ); |
|
548 return err; |
|
549 } |
|
550 |
|
551 |
|
552 // ---------------------------------------------------------- |
|
553 // CIAUpdateBGTimer::RetryTimesL() |
|
554 // ---------------------------------------------------------- |
|
555 TInt CIAUpdateBGTimer::RetryTimesL() |
|
556 { |
|
557 iInternalFile->ReadControllerDataL(); |
|
558 return iInternalFile->RetryTimes(); |
|
559 } |
|
560 |
|
561 |
|
562 // ---------------------------------------------------------- |
|
563 // CIAUpdateBGTimer::SetRetryTimesL() |
|
564 // ---------------------------------------------------------- |
|
565 TInt CIAUpdateBGTimer::SetRetryTimesL( TInt aRetry ) |
|
566 { |
|
567 iInternalFile->SetRetryTimes( aRetry ); |
|
568 TRAPD( err,iInternalFile->WriteControllerDataL() ); |
|
569 return err; |
|
570 } |
|
571 |
|
572 |
|
573 // ---------------------------------------------------------- |
|
574 // CIAUpdateBGTimer::ConvertToMicroseconds() |
|
575 // ---------------------------------------------------------- |
|
576 TTimeIntervalMicroSeconds32 CIAUpdateBGTimer::ConvertToMicroseconds( TTimeIntervalMinutes aInterval ) |
|
577 { |
|
578 return aInterval.Int()*60*1000*1000; |
|
579 } |
|
580 |
|
581 |
|
582 // ---------------------------------------------------------- |
|
583 // CIAUpdateBGTimer::DoUpdatesCheckingL() |
|
584 // ---------------------------------------------------------- |
|
585 void CIAUpdateBGTimer::DoUpdatesCheckingL( const TBool& aUpdateFromServer ) |
|
586 { |
|
587 FLOG( "DoUpdatesCheckingL update"); |
|
588 //turn off the reminder, user will decide whether to turn if on or off |
|
589 //The user's decision will be checked in soft notification callback function |
|
590 |
|
591 if ( ReminderOnL()) |
|
592 { |
|
593 FLOG( "Do CheckUpdates 3"); |
|
594 iReminderTimer->CancelReminderTimerL(); |
|
595 SetReminderL( EFalse ); |
|
596 } |
|
597 |
|
598 if( !iUpdate ) |
|
599 { |
|
600 iUpdate = CIAUpdate::NewL( *this ); |
|
601 } |
|
602 if ( !iParameters ) |
|
603 { |
|
604 iParameters = CIAUpdateParameters::NewL(); |
|
605 } |
|
606 |
|
607 if ( aUpdateFromServer ) |
|
608 { |
|
609 iParameters->SetRefresh( ETrue ); |
|
610 |
|
611 FLOG("Polling from Server!"); |
|
612 if ( !IsAgreementAcceptedL() ) |
|
613 { |
|
614 FLOG("First time, bigger searching scale"); |
|
615 //The bigger searching scale will be used until user see the searching result |
|
616 // meaning open IAD maiview |
|
617 iParameters->SetImportance( CIAUpdateParameters::ECritical | |
|
618 CIAUpdateParameters::EMandatory | |
|
619 CIAUpdateParameters::ERecommended | |
|
620 CIAUpdateParameters::ENormal ); |
|
621 } |
|
622 else |
|
623 { |
|
624 FLOG("Not first time, smaller searching scale"); |
|
625 iParameters->SetImportance( CIAUpdateParameters::ECritical | CIAUpdateParameters::EMandatory ); |
|
626 } |
|
627 } |
|
628 else |
|
629 { |
|
630 FLOG("Use cache, use smaller searching scale!"); |
|
631 iParameters->SetRefresh( EFalse ); |
|
632 iParameters->SetImportance( CIAUpdateParameters::ECritical | CIAUpdateParameters::EMandatory ); |
|
633 } |
|
634 |
|
635 iUpdate->CheckUpdates( *iParameters ); |
|
636 //call back function will be called when checking is done |
|
637 } |
|
638 |
|
639 |
|
640 // ---------------------------------------------------------- |
|
641 // CIAUpdateBGTimer::DoCheckUpdatesComplete() |
|
642 // ---------------------------------------------------------- |
|
643 void CIAUpdateBGTimer::DoCheckUpdatesCompleteL( TInt aErrorCode, TInt aAvailableUpdates ) |
|
644 { |
|
645 FLOG_NUM( "CheckUpdatesComplete aErrorCode = %d", aErrorCode ); |
|
646 FLOG_NUM( "CheckUpdatesComplete aAvailableUpdates = %d", aAvailableUpdates ); |
|
647 if ( !IAUpdateEnabledL() ) |
|
648 { |
|
649 Shutdown(); |
|
650 return; |
|
651 } |
|
652 TBool checkupdatefromserver = EFalse; |
|
653 |
|
654 if ( iUpdate ) |
|
655 { |
|
656 delete iUpdate; |
|
657 iUpdate = NULL; |
|
658 } |
|
659 |
|
660 if ( iParameters ) |
|
661 { |
|
662 checkupdatefromserver = iParameters->Refresh(); |
|
663 delete iParameters; |
|
664 iParameters = NULL; |
|
665 } |
|
666 |
|
667 if ( ModeL() == ERetryMode ) |
|
668 { |
|
669 TInt retry = RetryTimesL(); |
|
670 //increasing the retry times |
|
671 retry++; |
|
672 SetRetryTimesL( retry ); |
|
673 } |
|
674 |
|
675 FLOG( "CheckUpdatesComplete"); |
|
676 |
|
677 if ( aErrorCode == KErrNone ) |
|
678 { |
|
679 FLOG( "CheckUpdatesComplete 1"); |
|
680 |
|
681 //Set to normal mode |
|
682 iMode = ENormalMode; |
|
683 SetModeL( ENormalMode ); |
|
684 //clear the retry times |
|
685 SetRetryTimesL( 0 ); |
|
686 |
|
687 if ( aAvailableUpdates > 0 ) |
|
688 { |
|
689 FLOG( "CheckUpdatesComplete 4"); |
|
690 |
|
691 LaunchSoftNotificationL(R_IAUPDATE_UPDATE_AVAILABLE, |
|
692 R_TEXT_SOFTKEY_SHOW, R_TEXT_SOFTKEY_LATER ); |
|
693 } |
|
694 |
|
695 FLOG( "CheckUpdatesComplete 5"); |
|
696 |
|
697 // if update checking is from server, restart the refresh timer |
|
698 // if update checking is from cache, do nothing |
|
699 if ( checkupdatefromserver ) |
|
700 { |
|
701 // for firmware changed case, we also refresh after 1 month |
|
702 TTimeIntervalMinutes interval( CheckingFrequencyInMinutesL() ); |
|
703 |
|
704 FLOG_NUM("interval = %d", interval.Int()); |
|
705 |
|
706 FLOG( "CheckUpdatesComplete 6"); |
|
707 |
|
708 //recheck after the interval |
|
709 StartL( interval ); |
|
710 |
|
711 FLOG( "CheckUpdatesComplete 7"); |
|
712 //update the last-checking time in iaupdate private file |
|
713 SetLastRefreshTime(); |
|
714 } |
|
715 } |
|
716 else |
|
717 { |
|
718 FLOG( "CheckUpdatesComplete Complete with error"); |
|
719 |
|
720 iMode = ERetryMode; |
|
721 SetModeL( ERetryMode ); |
|
722 |
|
723 TInt retry = RetryTimesL(); |
|
724 |
|
725 if ( retry >= KMaxRetry ) |
|
726 { |
|
727 //if 4 tries failed, stop retrymode and back to normal mode |
|
728 //just start a new interval |
|
729 iMode = ENormalMode; |
|
730 SetModeL( ENormalMode ); |
|
731 |
|
732 FLOG( "CheckUpdatesComplete reach the max retry times"); |
|
733 if ( checkupdatefromserver ) |
|
734 { |
|
735 TTimeIntervalMinutes interval( CheckingFrequencyInMinutesL() ); |
|
736 StartL( interval ); |
|
737 SetLastRefreshTime(); |
|
738 } |
|
739 else |
|
740 { |
|
741 //don't show soft notification and restart the timer. |
|
742 TTimeIntervalMinutes oneweek( UpdateAvailableReminderIntervalInMinutesL() ); |
|
743 TTime currenttime; |
|
744 currenttime.UniversalTime(); |
|
745 TTime nextRemindTime = currenttime + oneweek; |
|
746 |
|
747 SetReminderL( ETrue ); |
|
748 SetNextRemindTimeL( nextRemindTime ); |
|
749 |
|
750 iReminderTimer->StartReminderTimerL( oneweek ); |
|
751 } |
|
752 //clear the retry time |
|
753 SetRetryTimesL( 0 ); |
|
754 } |
|
755 else |
|
756 { |
|
757 FLOG( "CheckUpdatesComplete doesn't reach the max retry times, continue.."); |
|
758 //continue retrying |
|
759 switch ( retry ) |
|
760 { |
|
761 case 0: |
|
762 case 1: |
|
763 { |
|
764 //first or second failure, retry after 30mins |
|
765 TTimeIntervalMinutes halfhour( KFirstSecondRetryInterval ); |
|
766 StartL( halfhour ); |
|
767 } |
|
768 break; |
|
769 |
|
770 case 2: |
|
771 case 3: |
|
772 { |
|
773 //third failure, retry after 24 hours |
|
774 TTimeIntervalMinutes oneday( KThirdFourthRetryInterval ); |
|
775 StartL( oneday ); |
|
776 } |
|
777 break; |
|
778 |
|
779 default: |
|
780 break; |
|
781 }; |
|
782 } |
|
783 } |
|
784 } |
|
785 |
|
786 // ---------------------------------------------------------- |
|
787 // CIAUpdateBGTimer::CheckUpdatesComplete() |
|
788 // ---------------------------------------------------------- |
|
789 void CIAUpdateBGTimer::CheckUpdatesComplete( TInt aErrorCode, TInt aAvailableUpdates ) |
|
790 { |
|
791 TRAP_IGNORE( DoCheckUpdatesCompleteL( aErrorCode, aAvailableUpdates ) ); |
|
792 } |
|
793 |
|
794 |
|
795 // ---------------------------------------------------------- |
|
796 // CIAUpdateBGTimer::UpdateComplete() |
|
797 // ---------------------------------------------------------- |
|
798 void CIAUpdateBGTimer::UpdateComplete( TInt /*aErrorCode*/, CIAUpdateResult* /*aResult*/ ) |
|
799 { |
|
800 FLOG( "UpdateComplete"); |
|
801 //no implementation |
|
802 } |
|
803 |
|
804 |
|
805 // ---------------------------------------------------------- |
|
806 // CIAUpdateBGTimer::UpdateQueryComplete() |
|
807 // ---------------------------------------------------------- |
|
808 void CIAUpdateBGTimer::UpdateQueryComplete( TInt /*aErrorCode*/, TBool /*aUpdateNow*/ ) |
|
809 { |
|
810 FLOG( "UpdateQueryComplete"); |
|
811 //no implementation |
|
812 } |
|
813 |
|
814 |
|
815 // ---------------------------------------------------------- |
|
816 // CIAUpdateBGTimer::CIAUpdateBGTimer() |
|
817 // ---------------------------------------------------------- |
|
818 CIAUpdateBGTimer::CIAUpdateBGTimer():CTimer( EPriorityStandard ) |
|
819 { |
|
820 } |
|
821 |
|
822 |
|
823 // ---------------------------------------------------------- |
|
824 // CIAUpdateBGTimer::RunL() |
|
825 // ---------------------------------------------------------- |
|
826 void CIAUpdateBGTimer::RunL() |
|
827 { |
|
828 FLOG("[bgchecker]RunL() "); |
|
829 if ( !IAUpdateEnabledL() ) |
|
830 { |
|
831 Shutdown(); |
|
832 return; |
|
833 } |
|
834 User::LeaveIfError( iStatus.Int() ); |
|
835 //Check the mode again, in case the mode is changed while waiting. |
|
836 iMode = ModeL(); |
|
837 |
|
838 switch ( iMode ) |
|
839 { |
|
840 case ENormalMode: |
|
841 case ERetryMode: |
|
842 { |
|
843 FLOG("[bgchecker]RunL() ENormalMode"); |
|
844 //roaming case is checked in IAUpdate server side |
|
845 if ( IsAutoUpdateDisabledL() ) |
|
846 { |
|
847 ListenAutoUpdateSettingsL(); |
|
848 |
|
849 iMode = ESleepMode; |
|
850 SetModeL( iMode ); |
|
851 |
|
852 //the program is waked up when automatic checking is changed by user. |
|
853 //cenrep call back will be used. |
|
854 return; |
|
855 } |
|
856 |
|
857 FLOG("[bgchecker]RunL() ENormalMode 1"); |
|
858 |
|
859 if(iRuns == 0) |
|
860 { |
|
861 FLOG("[bgchecker]RunL() ENormalMode 2"); |
|
862 // if user did the refresh from server while waiting, restart the timer. |
|
863 // the last refresh time is read from the private file of IAUpdate server. |
|
864 TTimeIntervalMinutes timetowait = |
|
865 TimeIntervalFromNextRefreshL(); |
|
866 |
|
867 if (timetowait.Int() <= 0 ) |
|
868 { |
|
869 DoUpdatesCheckingL( ETrue ); |
|
870 } |
|
871 else |
|
872 { |
|
873 StartL( timetowait ); |
|
874 } |
|
875 FLOG("[bgchecker]RunL() ENormalMode 3"); |
|
876 } |
|
877 else |
|
878 { |
|
879 FLOG("[bgchecker]RunL() ENormalMode 4"); |
|
880 TTimeIntervalMinutes timetowait = TimeIntervalFromNextRefreshL(); |
|
881 |
|
882 if ( timetowait.Int() <= 0 ) |
|
883 { |
|
884 StartL( StartNow ); |
|
885 } |
|
886 else |
|
887 { |
|
888 StartL( timetowait ); |
|
889 } |
|
890 FLOG("[bgchecker]RunL() ENormalMode 5"); |
|
891 } |
|
892 } |
|
893 break; |
|
894 |
|
895 case EFirstTimeMode: |
|
896 case EFirstTimeRemindMode: |
|
897 { |
|
898 FLOG("[bgchecker] runl EFirstTimeMode"); |
|
899 |
|
900 if ( iRuns == 0 ) |
|
901 { |
|
902 FLOG("[bgchecker] runl run = 0"); |
|
903 HandlerFirstTimeL(); |
|
904 } |
|
905 else |
|
906 { |
|
907 FLOG("[bgchecker] runl still wait"); |
|
908 TTimeIntervalMinutes timetowait = TimeIntervalFromNextShowOfNewFeatureDialogL(); |
|
909 |
|
910 if ( timetowait.Int() <= 0 ) |
|
911 { |
|
912 StartL( StartNow ); |
|
913 } |
|
914 else |
|
915 { |
|
916 StartL( timetowait ); |
|
917 } |
|
918 } |
|
919 } |
|
920 break; |
|
921 |
|
922 case EFirstTimeMode2: |
|
923 { |
|
924 FLOG("[bgchecker] runl EFirstTimeMode2"); |
|
925 LaunchSoftNotificationL(R_IAUPDATE_REMIND_LATER, R_TEXT_SOFTKEY_YES, R_TEXT_SOFTKEY_NO ); |
|
926 } |
|
927 break; |
|
928 |
|
929 case EFirstTimeMode3: |
|
930 { |
|
931 FLOG("[bgchecker] runl EFirstTimeMode3"); |
|
932 //disclaimer is not accepted |
|
933 |
|
934 if ( !IsAgreementAcceptedL() ) |
|
935 { |
|
936 FLOG("[bgchecker] runl EFirstTimeMode reject disclaimer"); |
|
937 //user accepte the new feature dialog but user reject sthe disclaimer |
|
938 //in sleep mode now |
|
939 iMode = ESleepMode; |
|
940 SetModeL( iMode ); |
|
941 //subscribe to cenrep key for automatic checking for wake up from sleep mode |
|
942 ListenAutoUpdateSettingsL(); |
|
943 } |
|
944 else |
|
945 { |
|
946 FLOG("[bgchecker] runl EFirstTimeMode go to normal mode"); |
|
947 //Set to Normal mode |
|
948 //check autochecksetting in Runl later |
|
949 iMode = ENormalMode; |
|
950 SetModeL( iMode ); |
|
951 StartL( StartNow ); |
|
952 } |
|
953 } |
|
954 break; |
|
955 |
|
956 default: |
|
957 break; |
|
958 }; |
|
959 |
|
960 } |
|
961 |
|
962 |
|
963 // ---------------------------------------------------------- |
|
964 // CIAUpdateBGTimer::HandlerFirstTimeL() |
|
965 // ---------------------------------------------------------- |
|
966 void CIAUpdateBGTimer::HandlerFirstTimeL() |
|
967 { |
|
968 // this checking is in case when accept disclaimer from grid or application |
|
969 // during the waiting time. |
|
970 |
|
971 if (IsAgreementAcceptedL() || !IsAutoUpdateDisabledL()) |
|
972 { |
|
973 //user accepted the disclamier during the waiting time |
|
974 //out of firsttime mode, check auto check setting in runl and |
|
975 //do update check as normal. |
|
976 // If autoUpdate is enabled ==> always to normal mode |
|
977 |
|
978 //In normal mode now. |
|
979 iMode = ENormalMode; |
|
980 SetModeL(iMode); |
|
981 StartL(StartNow); |
|
982 } |
|
983 else |
|
984 { |
|
985 //this is first time mode |
|
986 FLOG("[bgchecker]HandlerFirstTimeL 3 "); |
|
987 LaunchSoftNotificationL( R_IAUPDATE_FEATURES_AVAILABLE, |
|
988 R_TEXT_SOFTKEY_OK, R_TEXT_SOFTKEY_CANCEL ); |
|
989 } |
|
990 } |
|
991 |
|
992 |
|
993 // ---------------------------------------------------------- |
|
994 // CIAUpdateBGTimer::DoCancel() |
|
995 // ---------------------------------------------------------- |
|
996 void CIAUpdateBGTimer::DoCancel() |
|
997 { |
|
998 } |
|
999 |
|
1000 |
|
1001 // ---------------------------------------------------------- |
|
1002 // CIAUpdateBGTimer::RunError() |
|
1003 // ---------------------------------------------------------- |
|
1004 TInt CIAUpdateBGTimer::RunError(TInt /*aError*/) |
|
1005 { |
|
1006 return KErrNone; |
|
1007 } |
|
1008 |
|
1009 // ---------------------------------------------------------- |
|
1010 // CIAUpdateBGTimer::CheckingFrequencyInMinutesL() |
|
1011 // ---------------------------------------------------------- |
|
1012 TInt CIAUpdateBGTimer::CheckingFrequencyInMinutesL() |
|
1013 { |
|
1014 FLOG("[bgchecker]CheckingFrequencyInMinutesL begin "); |
|
1015 |
|
1016 #ifdef _DEMO |
|
1017 return KCheckingUpdateInterval; |
|
1018 #else |
|
1019 TInt CheckingFrequency = 0; |
|
1020 CRepository* cenrep = CRepository::NewL( KCRUidIAUpdateSettings ); |
|
1021 CleanupStack::PushL( cenrep ); |
|
1022 TInt err = cenrep->Get( KIAUpdateCheckingFrequency, CheckingFrequency ); |
|
1023 |
|
1024 if ( err != KErrNone ) |
|
1025 { |
|
1026 FLOG("[bgchecker]CheckingFrequencyInMinutesL Getting checking frequency from Cenrep failed "); |
|
1027 } |
|
1028 |
|
1029 CleanupStack::PopAndDestroy( cenrep ); |
|
1030 |
|
1031 return CheckingFrequency*24*60; // convert into minutes |
|
1032 #endif |
|
1033 } |
|
1034 |
|
1035 |
|
1036 // ---------------------------------------------------------- |
|
1037 // CIAUpdateBGTimer::UpdateAvailableReminderIntervalInMinutesL() |
|
1038 // ---------------------------------------------------------- |
|
1039 TInt CIAUpdateBGTimer::UpdateAvailableReminderIntervalInMinutesL() |
|
1040 { |
|
1041 FLOG("[bgchecker]UpdateAvailableReminderIntervalInMinutesL begin "); |
|
1042 |
|
1043 #ifdef _DEMO |
|
1044 return KUpdateAvailableReminderInterval; |
|
1045 #else |
|
1046 TInt updateAvailableReminderIntervel = 0; |
|
1047 CRepository* cenrep = CRepository::NewL( KCRUidIAUpdateSettings ); |
|
1048 CleanupStack::PushL( cenrep ); |
|
1049 TInt err = cenrep->Get( KIAUpdateUpdateAvailableReminderInterval, updateAvailableReminderIntervel ); |
|
1050 |
|
1051 if ( err != KErrNone ) |
|
1052 { |
|
1053 FLOG("[bgchecker]UpdateAvailableReminderIntervalInMinutesL interval for update available reminder from Cenrep failed "); |
|
1054 } |
|
1055 |
|
1056 CleanupStack::PopAndDestroy( cenrep ); |
|
1057 |
|
1058 return updateAvailableReminderIntervel*24*60; // convert into minutes |
|
1059 #endif |
|
1060 } |
|
1061 |
|
1062 |
|
1063 // ---------------------------------------------------------- |
|
1064 // CIAUpdateBGTimer::FirstTimeDialogDelayInMinutesL() |
|
1065 // ---------------------------------------------------------- |
|
1066 TInt CIAUpdateBGTimer::FirstTimeDialogDelayInMinutesL() |
|
1067 { |
|
1068 FLOG("[bgchecker]FirstTimeDialogDelayInMinutesL begin "); |
|
1069 |
|
1070 #ifdef _DEMO |
|
1071 return KFirstTimeDialogDelay; |
|
1072 #else |
|
1073 TInt firstTimeDialogDelay = 0; |
|
1074 CRepository* cenrep = CRepository::NewL( KCRUidIAUpdateSettings ); |
|
1075 CleanupStack::PushL( cenrep ); |
|
1076 TInt err = cenrep->Get( KIAUpdateFirstTimeDialogDelay, firstTimeDialogDelay ); |
|
1077 |
|
1078 if ( err != KErrNone ) |
|
1079 { |
|
1080 FLOG("[bgchecker]FirstTimeDialogDelayInMinutesL Getting first time dialog delay from Cenrep failed "); |
|
1081 } |
|
1082 |
|
1083 CleanupStack::PopAndDestroy( cenrep ); |
|
1084 |
|
1085 return firstTimeDialogDelay*24*60; // convert into minutes |
|
1086 #endif |
|
1087 } |
|
1088 |
|
1089 |
|
1090 // ---------------------------------------------------------- |
|
1091 // CIAUpdateBGTimer::FirstTimeDialogReminderIntervalInMinutesL() |
|
1092 // ---------------------------------------------------------- |
|
1093 TInt CIAUpdateBGTimer::FirstTimeDialogReminderIntervalInMinutesL() |
|
1094 { |
|
1095 FLOG("[bgchecker]FirstTimeDialogDelayInMinutesL begin "); |
|
1096 |
|
1097 #ifdef _DEMO |
|
1098 return KFirstTimeDialogReminderInterval; |
|
1099 #else |
|
1100 TInt firstTimeDialogReminderInterval = 0; |
|
1101 CRepository* cenrep = CRepository::NewL( KCRUidIAUpdateSettings ); |
|
1102 CleanupStack::PushL( cenrep ); |
|
1103 TInt err = cenrep->Get( KIAUpdateFirstTimeDialogReminderInterval, firstTimeDialogReminderInterval ); |
|
1104 |
|
1105 if ( err != KErrNone ) |
|
1106 { |
|
1107 FLOG("[bgchecker]FirstTimeDialogReminderIntervalInMinutesL Getting first time dialog reminder interval from Cenrep failed "); |
|
1108 } |
|
1109 |
|
1110 CleanupStack::PopAndDestroy( cenrep ); |
|
1111 |
|
1112 return firstTimeDialogReminderInterval*24*60; // convert into minutes |
|
1113 #endif |
|
1114 } |
|
1115 |
|
1116 |
|
1117 |
|
1118 |
|
1119 // ---------------------------------------------------------- |
|
1120 // CIAUpdateBGTimer::IsFirstTimeDialogDisabledL() |
|
1121 // ---------------------------------------------------------- |
|
1122 TBool CIAUpdateBGTimer::IsFirstTimeDialogDisabledL() |
|
1123 { |
|
1124 FLOG("[bgchecker]IsFirstTimeDialogDisabledL begin "); |
|
1125 |
|
1126 TBool isDisabled = EFalse; |
|
1127 |
|
1128 CRepository* cenrep = CRepository::NewL( KCRUidIAUpdateSettings ); |
|
1129 CleanupStack::PushL( cenrep ); |
|
1130 |
|
1131 TInt err = cenrep->Get( KIAUpdateFirstTimeDialogDisabled, isDisabled ); |
|
1132 |
|
1133 FLOG_NUM("[bgchecker] err = %d", err ); |
|
1134 FLOG_NUM("[bgchecker] isDisabled = %d", isDisabled ); |
|
1135 |
|
1136 if ( err != KErrNone ) |
|
1137 { |
|
1138 FLOG("[bgchecker]IsFirstTimeDialogDisabledL get value from cenrep failed "); |
|
1139 } |
|
1140 |
|
1141 CleanupStack::PopAndDestroy( cenrep ); |
|
1142 |
|
1143 return isDisabled; |
|
1144 } |
|
1145 |
|
1146 |
|
1147 |
|
1148 // ---------------------------------------------------------- |
|
1149 // CIAUpdateBGTimer::StartL() |
|
1150 // ---------------------------------------------------------- |
|
1151 void CIAUpdateBGTimer::StartL( TTimeIntervalMinutes aWaitTime ) |
|
1152 { |
|
1153 Cancel(); |
|
1154 /* |
|
1155 RTimer::After maximum delay is 35 minutes, 47 seconds this is because it is 32bit integer. |
|
1156 Thats why aWaitTime is divided to 30min runs. |
|
1157 */ |
|
1158 |
|
1159 iRuns = 0; |
|
1160 |
|
1161 if(aWaitTime.Int() > HalfHourInMinuts ) |
|
1162 { |
|
1163 iRuns = aWaitTime.Int() / HalfHourInMinuts; |
|
1164 TTimeIntervalMinutes halfhour( HalfHourInMinuts ); |
|
1165 After( ConvertToMicroseconds( halfhour ) ); |
|
1166 } |
|
1167 else{ |
|
1168 After(ConvertToMicroseconds( aWaitTime ) ); |
|
1169 } |
|
1170 } |
|
1171 |
|
1172 // ---------------------------------------------------------- |
|
1173 // CIAUpdateBGTimer::TimeIntervalFromNextRefreshL() |
|
1174 // ---------------------------------------------------------- |
|
1175 TTimeIntervalMinutes CIAUpdateBGTimer::TimeIntervalFromNextRefreshL() |
|
1176 { |
|
1177 FLOG("[bgchecker] TimeIntervalFromNextRefreshL 1"); |
|
1178 TTime lastrefreshtime = GetLastRefreshTimeL(); |
|
1179 |
|
1180 FTIME( lastrefreshtime ); |
|
1181 |
|
1182 TTime currenttime; |
|
1183 currenttime.UniversalTime(); |
|
1184 |
|
1185 FTIME ( currenttime ); |
|
1186 |
|
1187 //get current gap |
|
1188 TTimeIntervalMinutes timepast; |
|
1189 currenttime.MinutesFrom( lastrefreshtime, timepast ); |
|
1190 FLOG("[bgchecker] TimeIntervalFromNextRefreshL 2"); |
|
1191 if ( timepast.Int() < 0 ) |
|
1192 { |
|
1193 FLOG("[bgchecker] TimeIntervalFromNextRefreshL 3"); |
|
1194 //user set its clock backward, refresh anyway. |
|
1195 return timepast; |
|
1196 } |
|
1197 FLOG("[bgchecker] TimeIntervalFromNextRefreshL 4"); |
|
1198 TTimeIntervalMinutes interval( CheckingFrequencyInMinutesL() ); |
|
1199 FLOG_NUM(" interval %d ", interval.Int() ); |
|
1200 FLOG_NUM(" timepast %d ", timepast.Int() ); |
|
1201 FLOG("[bgchecker] TimeIntervalFromNextRefreshL 5"); |
|
1202 //check if the interval is bigger than the value defined by user |
|
1203 TTimeIntervalMinutes timetowait(interval.Int() - timepast.Int()); |
|
1204 FLOG("[bgchecker] TimeIntervalFromNextRefreshL 6"); |
|
1205 return timetowait; |
|
1206 } |
|
1207 |
|
1208 |
|
1209 // ---------------------------------------------------------- |
|
1210 // CIAUpdateBGTimer::TimeIntervalFromNextShowOfNewFeatureDialogL() |
|
1211 // ---------------------------------------------------------- |
|
1212 TTimeIntervalMinutes CIAUpdateBGTimer::TimeIntervalFromNextShowOfNewFeatureDialogL() |
|
1213 { |
|
1214 FLOG("[bgchecker] TimeIntervalFromNextShowOfNewFeatureDialogL 1"); |
|
1215 TTime lastshowtime = GetLastTimeShowNewFeatureDialogL(); |
|
1216 FLOG("[bgchecker] TimeIntervalFromNextShowOfNewFeatureDialogL 2"); |
|
1217 if( lastshowtime.Int64() == 0 ) |
|
1218 { |
|
1219 FLOG("[bgchecker] TimeIntervalFromNextShowOfNewFeatureDialogL 3"); |
|
1220 //first time |
|
1221 //wait for some days |
|
1222 |
|
1223 TTimeIntervalMinutes firstTimeDelay(FirstTimeDialogDelayInMinutesL()); |
|
1224 TTime currenttime; |
|
1225 currenttime.UniversalTime(); |
|
1226 |
|
1227 FLOG("[bgchecker] TimeIntervalFromNextShowOfNewFeatureDialogL 4"); |
|
1228 //save the next show new feature dialog time |
|
1229 //in case use switch off the device and restarted. |
|
1230 User::LeaveIfError(SetLastTimeShowNewFeatureDialogL(currenttime)); |
|
1231 FLOG("[bgchecker] TimeIntervalFromNextShowOfNewFeatureDialogL 5"); |
|
1232 return firstTimeDelay; |
|
1233 } |
|
1234 FLOG("[bgchecker] TimeIntervalFromNextShowOfNewFeatureDialogL 6"); |
|
1235 TTime currenttime; |
|
1236 currenttime.UniversalTime(); |
|
1237 |
|
1238 TTimeIntervalMinutes timepass; |
|
1239 currenttime.MinutesFrom( lastshowtime, timepass ); |
|
1240 |
|
1241 if ( timepass.Int() < 0 ) |
|
1242 { |
|
1243 FLOG("[bgchecker] TimeIntervalFromNextRefreshL 3"); |
|
1244 //clock is set back. |
|
1245 return timepass; |
|
1246 } |
|
1247 FLOG("[bgchecker] TimeIntervalFromNextShowOfNewFeatureDialogL 7"); |
|
1248 |
|
1249 TTimeIntervalMinutes interval; |
|
1250 if ( ModeL() == EFirstTimeMode ) |
|
1251 { |
|
1252 FLOG(" current mode is FirstTimeMode "); |
|
1253 interval = FirstTimeDialogDelayInMinutesL(); |
|
1254 } |
|
1255 else if ( ModeL() == EFirstTimeRemindMode ) |
|
1256 { |
|
1257 FLOG(" current mode is FirstTimeRemindMode"); |
|
1258 interval = FirstTimeDialogReminderIntervalInMinutesL(); |
|
1259 } |
|
1260 else |
|
1261 { |
|
1262 //nothing |
|
1263 FLOG(" current mode is wrong!!"); |
|
1264 User::LeaveIfError( KErrArgument ); |
|
1265 } |
|
1266 |
|
1267 FLOG_NUM(" interval %d ", interval.Int() ); |
|
1268 FLOG_NUM(" timepast %d ", timepass.Int() ); |
|
1269 FLOG("[bgchecker] TimeIntervalFromNextShowOfNewFeatureDialogL 5"); |
|
1270 //check if the interval is bigger than the value defined by user |
|
1271 TTimeIntervalMinutes timetowait(interval.Int() - timepass.Int()); |
|
1272 FLOG("[bgchecker] TimeIntervalFromNextShowOfNewFeatureDialogL 6"); |
|
1273 return timetowait; |
|
1274 } |
|
1275 |
|
1276 |
|
1277 // ---------------------------------------------------------- |
|
1278 // CIAUpdateBGTimer::DoSoftNotificationCallBackL() |
|
1279 // ---------------------------------------------------------- |
|
1280 void CIAUpdateBGTimer::DoSoftNotificationCallBackL( TBool aIsAccepted ) |
|
1281 { |
|
1282 FLOG("[bgchecker] SoftNotificationCallBack"); |
|
1283 if ( !IAUpdateEnabledL() ) |
|
1284 { |
|
1285 Shutdown(); |
|
1286 return; |
|
1287 } |
|
1288 iMode = ModeL(); |
|
1289 |
|
1290 switch ( iMode ) |
|
1291 { |
|
1292 case EFirstTimeMode: |
|
1293 case EFirstTimeRemindMode: |
|
1294 { |
|
1295 |
|
1296 FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode"); |
|
1297 if ( !aIsAccepted ) |
|
1298 { |
|
1299 FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode not accepted"); |
|
1300 iMode = EFirstTimeMode2; |
|
1301 SetModeL( iMode ); |
|
1302 StartL( StartNow ); |
|
1303 } |
|
1304 else |
|
1305 { |
|
1306 FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMod accepeted"); |
|
1307 StartIaupdateL(); |
|
1308 //iaupdate is launched |
|
1309 //check the disclaimer acceptance and automatic checking setting in 10mins |
|
1310 |
|
1311 StartL( KDelayForUserToAcceptDisclaimer ); |
|
1312 iMode = EFirstTimeMode3; |
|
1313 SetModeL( iMode ); |
|
1314 |
|
1315 |
|
1316 //Still in first time mode, |
|
1317 //check user's setting and disclamier after 10mins. |
|
1318 } |
|
1319 break; |
|
1320 } |
|
1321 |
|
1322 |
|
1323 |
|
1324 case EFirstTimeMode2: |
|
1325 { |
|
1326 FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode2 "); |
|
1327 if ( aIsAccepted ) |
|
1328 { |
|
1329 FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode2, accepted"); |
|
1330 //user wants to be reminder so remind in 4 weeks |
|
1331 //set to first time remind mode |
|
1332 iMode = EFirstTimeRemindMode; |
|
1333 SetModeL( iMode ); |
|
1334 TTimeIntervalMinutes fourweeks( FirstTimeDialogReminderIntervalInMinutesL() ); |
|
1335 TTime currenttime; |
|
1336 currenttime.UniversalTime(); |
|
1337 |
|
1338 //save the next show new feature dialog time |
|
1339 //in case use switch off the device and restarted. |
|
1340 User::LeaveIfError( SetLastTimeShowNewFeatureDialogL( currenttime ) ); |
|
1341 |
|
1342 StartL( fourweeks ); |
|
1343 return; |
|
1344 } |
|
1345 else |
|
1346 { |
|
1347 FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode2, not accepted"); |
|
1348 //in sleep mode now |
|
1349 iMode = ESleepMode; |
|
1350 SetModeL( iMode ); |
|
1351 |
|
1352 //subscribe to cenrep key for automatic checking for wake up from sleep mode |
|
1353 ListenAutoUpdateSettingsL(); |
|
1354 } |
|
1355 break; |
|
1356 } |
|
1357 |
|
1358 case ENormalMode: |
|
1359 { |
|
1360 FLOG("[bgchecker] SoftNotificationCallBack ENormalMode"); |
|
1361 if ( !aIsAccepted ) |
|
1362 { |
|
1363 FLOG("[bgchecker] SoftNotificationCallBack ENormalMode not accpeted"); |
|
1364 //user wants to be reminded later |
|
1365 TTimeIntervalMinutes oneweek( UpdateAvailableReminderIntervalInMinutesL() ); |
|
1366 TTime currenttime; |
|
1367 currenttime.UniversalTime(); |
|
1368 TTime nextRemindTime = currenttime + oneweek; |
|
1369 |
|
1370 SetReminderL( ETrue ); |
|
1371 SetNextRemindTimeL( nextRemindTime ); |
|
1372 |
|
1373 iReminderTimer->StartReminderTimerL( oneweek ); |
|
1374 |
|
1375 //the reminder call back function will be called when reminder timer expires. |
|
1376 } |
|
1377 else |
|
1378 { |
|
1379 //accepted, launch iad |
|
1380 StartIaupdateL(); |
|
1381 } |
|
1382 break; |
|
1383 } |
|
1384 |
|
1385 case ESleepMode: |
|
1386 { |
|
1387 FLOG("[bgchecker] SoftNotificationCallBack ESleepMode"); |
|
1388 //donothing |
|
1389 break; |
|
1390 } |
|
1391 |
|
1392 default: |
|
1393 break; |
|
1394 } |
|
1395 } |
|
1396 |
|
1397 // ---------------------------------------------------------- |
|
1398 // CIAUpdateBGTimer::SoftNotificationCallBack() |
|
1399 // ---------------------------------------------------------- |
|
1400 void CIAUpdateBGTimer::SoftNotificationCallBack( TBool aIsAccepted ) |
|
1401 { |
|
1402 TRAP_IGNORE( DoSoftNotificationCallBackL( aIsAccepted ) ); |
|
1403 } |
|
1404 |
|
1405 |
|
1406 // ---------------------------------------------------------- |
|
1407 // CIAUpdateBGTimer::CurrentMode() |
|
1408 // ---------------------------------------------------------- |
|
1409 TIAUpdateBGMode CIAUpdateBGTimer::CurrentMode() |
|
1410 { |
|
1411 return iMode; |
|
1412 } |
|
1413 |
|
1414 |
|
1415 // ---------------------------------------------------------- |
|
1416 // CIAUpdateBGTimer::DoReminderTimerCallBack() |
|
1417 // ---------------------------------------------------------- |
|
1418 void CIAUpdateBGTimer::DoReminderTimerCallBackL() |
|
1419 { |
|
1420 FLOG("[bgchecker] ReminderTimerCallBack begin"); |
|
1421 if ( !IAUpdateEnabledL() ) |
|
1422 { |
|
1423 Shutdown(); |
|
1424 return; |
|
1425 } |
|
1426 //Check the automatic update setting, if it has been disabled, |
|
1427 //then go to sleep mode. |
|
1428 if ( IsAutoUpdateDisabledL() ) |
|
1429 { |
|
1430 FLOG("[bgchecker] ReminderTimerCallBack autoupdate is disabled, switch to sleep mode"); |
|
1431 ListenAutoUpdateSettingsL(); |
|
1432 iMode = ESleepMode; |
|
1433 SetModeL( iMode ); |
|
1434 return; |
|
1435 } |
|
1436 |
|
1437 TTimeIntervalMinutes timetowait = TimeIntervalFromNextRefreshL(); |
|
1438 |
|
1439 if ( timetowait.Int() <= KRefreshTimerReminderTimerGap ) |
|
1440 { |
|
1441 FLOG("[bgchecker] ReminderTimerCallBack refresh is about to come in one day. We don't show reminder then"); |
|
1442 return; |
|
1443 } |
|
1444 |
|
1445 //if reminder is still on which means the BGTimer is not expired |
|
1446 //and checkupdate() is not called yet, then go ahead to call DoupdatesChecking |
|
1447 //this is to avoid DoUpdateChecking being called at the same time. |
|
1448 |
|
1449 if ( ReminderOnL() ) |
|
1450 { |
|
1451 FLOG("[bgchecker] ReminderTimerCallBack Reminder is still ON"); |
|
1452 DoUpdatesCheckingL( EFalse ); |
|
1453 } |
|
1454 FLOG("[bgchecker] ReminderTimerCallBack end"); |
|
1455 } |
|
1456 |
|
1457 // ---------------------------------------------------------- |
|
1458 // CIAUpdateBGTimer::ReminderTimerCallBack() |
|
1459 // ---------------------------------------------------------- |
|
1460 void CIAUpdateBGTimer::ReminderTimerCallBack() |
|
1461 { |
|
1462 TRAP_IGNORE( DoReminderTimerCallBackL() ); |
|
1463 } |
|
1464 |
|
1465 // ---------------------------------------------------------- |
|
1466 // CIAUpdateBGTimer::LaunchSoftNotificationL() |
|
1467 // ---------------------------------------------------------- |
|
1468 void CIAUpdateBGTimer::LaunchSoftNotificationL( const TInt& aResourceId, const TInt& SK1, const TInt& SK2 ) |
|
1469 { |
|
1470 iInternalFile->ReadControllerDataL(); |
|
1471 TInt snid = iInternalFile->SoftNotificationID(); |
|
1472 if ( snid ) |
|
1473 { |
|
1474 //there is a soft notification buffered, remove it |
|
1475 iSoftNotification->RemoveSoftNotificationL( snid ); |
|
1476 } |
|
1477 |
|
1478 FLOG("[bgchecker] LaunchSoftNotificationL "); |
|
1479 HBufC* text = ReadResourceLC( aResourceId ); |
|
1480 HBufC* sk1 = ReadResourceLC( SK1 ); |
|
1481 HBufC* sk2 = ReadResourceLC( SK2 ); |
|
1482 |
|
1483 |
|
1484 iMode = ModeL(); |
|
1485 |
|
1486 if ( iMode == ENormalMode ) |
|
1487 { |
|
1488 TFileName path; |
|
1489 TInt err = GetPrivatePathL( path ); |
|
1490 |
|
1491 if ( err == KErrNone ) |
|
1492 { |
|
1493 HBufC8* image = LoadFileLC( path ); |
|
1494 iSoftNotification->SetImageL( *image ); |
|
1495 CleanupStack::PopAndDestroy( image ); |
|
1496 } |
|
1497 } |
|
1498 |
|
1499 |
|
1500 iSoftNotification->SetTextL( *text, *text ); |
|
1501 iSoftNotification->SetSoftkeyLabelsL( *sk1, *sk2 ); |
|
1502 |
|
1503 iSoftNotification->ShowSoftNotificationL(); |
|
1504 FLOG("[bgchecker] LaunchSoftNotificationL 1"); |
|
1505 CleanupStack::PopAndDestroy( 3 ); //text, sk1, sk2 |
|
1506 } |
|
1507 |
|
1508 |
|
1509 // ---------------------------------------------------------- |
|
1510 // CIAUpdateBGTimer::GetPrivatePathL() |
|
1511 // ---------------------------------------------------------- |
|
1512 TInt CIAUpdateBGTimer::GetPrivatePathL( TFileName& aPath ) |
|
1513 { |
|
1514 RFs fsSession; |
|
1515 User::LeaveIfError( fsSession.Connect() ); |
|
1516 CleanupClosePushL( fsSession ); |
|
1517 |
|
1518 // This will set the correct drive and private path |
|
1519 // for the file server session. |
|
1520 TInt err = KErrNone; |
|
1521 TRAP( err, SetPrivateDriveL( fsSession, KImageFile ) ); |
|
1522 |
|
1523 if ( err != KErrNone ) |
|
1524 { |
|
1525 CleanupStack::PopAndDestroy( &fsSession ); |
|
1526 return err; |
|
1527 } |
|
1528 |
|
1529 err = fsSession.SessionPath( aPath ); |
|
1530 aPath.Append( KImageFile ); |
|
1531 |
|
1532 CleanupStack::PopAndDestroy( &fsSession ); |
|
1533 return err; |
|
1534 } |
|
1535 |
|
1536 // ---------------------------------------------------------- |
|
1537 // CIAUpdateBGTimer::LoadFileLC() |
|
1538 // ---------------------------------------------------------- |
|
1539 HBufC8* CIAUpdateBGTimer::LoadFileLC(const TDesC& aFile) |
|
1540 { |
|
1541 RFs fs; |
|
1542 User::LeaveIfError( fs.Connect() ); |
|
1543 CleanupClosePushL( fs ); |
|
1544 RFile file; |
|
1545 User::LeaveIfError(file.Open(fs, aFile, EFileRead)); |
|
1546 CleanupClosePushL(file); |
|
1547 TInt size; |
|
1548 User::LeaveIfError(file.Size(size)); |
|
1549 HBufC8* imagebuf = HBufC8::NewL(size); |
|
1550 TPtr8 imageptr(imagebuf->Des()); |
|
1551 file.Read(imageptr); |
|
1552 CleanupStack::PopAndDestroy( &file ); |
|
1553 CleanupStack::PopAndDestroy( &fs ); |
|
1554 CleanupDeletePushL(imagebuf); |
|
1555 return imagebuf; |
|
1556 } |
|
1557 |
|
1558 |
|
1559 // ---------------------------------------------------------- |
|
1560 // CIAUpdateBGTimer::SetPrivateDriveL() |
|
1561 // ---------------------------------------------------------- |
|
1562 void CIAUpdateBGTimer::SetPrivateDriveL( |
|
1563 RFs& aFs, |
|
1564 const TDesC& aFileName ) const |
|
1565 { |
|
1566 // First try to find the file from the private directory |
|
1567 // of the drive where the process exists. |
|
1568 RProcess process; |
|
1569 |
|
1570 // Set the session private path according to |
|
1571 // the process file name drive. |
|
1572 TInt driveNum( |
|
1573 SetSessionPrivatePathL( aFs, process.FileName() ) ); |
|
1574 |
|
1575 // Get the session path that was set above. |
|
1576 TFileName sessionPath; |
|
1577 User::LeaveIfError( aFs.SessionPath( sessionPath ) ); |
|
1578 |
|
1579 // Use the file finder to check if the file actually exists |
|
1580 // in the given drive path. If it does not, the file finder |
|
1581 // will automatically check from other drives. So, here we |
|
1582 // should always find the file if any exists. |
|
1583 TFindFile finder( aFs ); |
|
1584 User::LeaveIfError( finder.FindByDir( aFileName, sessionPath ) ); |
|
1585 |
|
1586 // The drive may have changed if the file was not found from |
|
1587 // the first suggested drive. So, be sure to have the correct |
|
1588 // private path. |
|
1589 driveNum = SetSessionPrivatePathL( aFs, finder.File() ); |
|
1590 |
|
1591 // Use the drive info to check if the drive is ROM drive. |
|
1592 // We prefer non ROM drives. But, accept ROM if nothing else is |
|
1593 // available. |
|
1594 TDriveInfo info; |
|
1595 User::LeaveIfError( aFs.Drive( info, driveNum ) ); |
|
1596 TBool isRomDrive( info.iDriveAtt & KDriveAttRom ); |
|
1597 if ( !isRomDrive ) |
|
1598 { |
|
1599 // The current file is not in ROM drive so use that. |
|
1600 return; |
|
1601 } |
|
1602 |
|
1603 // Because previous finding was ROM file, try to find a non ROM file. |
|
1604 TInt findErrorCode( finder.Find() ); |
|
1605 if ( findErrorCode == KErrNotFound ) |
|
1606 { |
|
1607 // Because no new file is found, use the current settings. |
|
1608 return; |
|
1609 } |
|
1610 User::LeaveIfError( findErrorCode ); |
|
1611 |
|
1612 // Update the session path for the correct file. |
|
1613 SetSessionPrivatePathL( aFs, finder.File() ); |
|
1614 } |
|
1615 |
|
1616 |
|
1617 // ---------------------------------------------------------- |
|
1618 // CIAUpdateBGTimer::SetSessionPrivatePathL() |
|
1619 // ---------------------------------------------------------- |
|
1620 TInt CIAUpdateBGTimer::SetSessionPrivatePathL( |
|
1621 RFs& aFs, |
|
1622 const TDesC& aPath ) const |
|
1623 { |
|
1624 // Use the parser to get the drive information from the path. |
|
1625 TParsePtrC parser( aPath ); |
|
1626 |
|
1627 if ( !parser.DrivePresent() ) |
|
1628 { |
|
1629 User::Leave( KErrArgument ); |
|
1630 } |
|
1631 |
|
1632 // Drive check was passed above. |
|
1633 // So, drive information is safe to use. |
|
1634 const TDesC& drive( parser.Drive() ); |
|
1635 const TChar driveChar( drive[ 0 ] ); |
|
1636 TInt driveNum( EDriveA ); |
|
1637 User::LeaveIfError( |
|
1638 RFs::CharToDrive( driveChar, driveNum ) ); |
|
1639 |
|
1640 // Set the file drive to be file session private path drive. |
|
1641 User::LeaveIfError( aFs.SetSessionToPrivate( driveNum ) ); |
|
1642 |
|
1643 return driveNum; |
|
1644 } |
|
1645 |
|
1646 // ---------------------------------------------------------- |
|
1647 // CIAUpdateBGTimer::ReadResourceLC() |
|
1648 // ---------------------------------------------------------- |
|
1649 HBufC* CIAUpdateBGTimer::ReadResourceLC( TInt aResourceId ) |
|
1650 { |
|
1651 TResourceReader reader; |
|
1652 HBufC8* buff = iResourceFile.AllocReadLC( aResourceId ); |
|
1653 reader.SetBuffer( buff ); |
|
1654 HBufC* text = reader.ReadHBufCL(); |
|
1655 CleanupStack::PopAndDestroy( buff ); |
|
1656 CleanupStack::PushL( text ); |
|
1657 return text; |
|
1658 } |
|
1659 |
|
1660 |
|
1661 // ---------------------------------------------------------- |
|
1662 // CIAUpdateBGTimer::IsAutoUpdateDisabledL() |
|
1663 // ---------------------------------------------------------- |
|
1664 TBool CIAUpdateBGTimer::IsAutoUpdateDisabledL() |
|
1665 { |
|
1666 TInt autochecksetting; |
|
1667 CRepository* cenrep = CRepository::NewL( KCRUidIAUpdateSettings ); |
|
1668 CleanupStack::PushL( cenrep ); |
|
1669 User::LeaveIfError( cenrep->Get( KIAUpdateAutoUpdateCheck, autochecksetting ) ); |
|
1670 CleanupStack::PopAndDestroy( cenrep ); |
|
1671 return (autochecksetting == EIAUpdateSettingValueDisable) ? ETrue : EFalse; |
|
1672 } |
|
1673 |
|
1674 |
|
1675 // ---------------------------------------------------------- |
|
1676 // CIAUpdateBGTimer::ListenAutoUpdateSettingsL() |
|
1677 // ---------------------------------------------------------- |
|
1678 void CIAUpdateBGTimer::ListenAutoUpdateSettingsL() |
|
1679 { |
|
1680 FLOG("[bgchecker] ListenAutoUpdateSettingsL() begin"); |
|
1681 if (iIAUpdateCRSession == NULL ) |
|
1682 { |
|
1683 iIAUpdateCRSession = CRepository::NewL( KCRUidIAUpdateSettings ); |
|
1684 } |
|
1685 if (iNotifyHandler == NULL ) |
|
1686 { |
|
1687 iNotifyHandler = CCenRepNotifyHandler::NewL( *this, *iIAUpdateCRSession ); |
|
1688 } |
|
1689 iNotifyHandler->StartListeningL(); |
|
1690 } |
|
1691 |
|
1692 |
|
1693 // ---------------------------------------------------------- |
|
1694 // CIAUpdateBGTimer::StopListeningAutoUpdateSettingsL() |
|
1695 // ---------------------------------------------------------- |
|
1696 void CIAUpdateBGTimer::StopListeningAutoUpdateSettingsL() |
|
1697 { |
|
1698 FLOG("[bgchecker] StopListeningAutoUpdateSettingsL() begin"); |
|
1699 if (iIAUpdateCRSession == NULL ) |
|
1700 { |
|
1701 iIAUpdateCRSession = CRepository::NewL( KCRUidIAUpdateSettings ); |
|
1702 } |
|
1703 if (iNotifyHandler == NULL ) |
|
1704 { |
|
1705 iNotifyHandler = CCenRepNotifyHandler::NewL( *this, *iIAUpdateCRSession ); |
|
1706 } |
|
1707 iNotifyHandler->StopListening(); |
|
1708 } |
|
1709 |
|
1710 // ---------------------------------------------------------- |
|
1711 // CIAUpdateBGTimer::StartIaupdateL() |
|
1712 // ---------------------------------------------------------- |
|
1713 void CIAUpdateBGTimer::StartIaupdateL() const |
|
1714 { |
|
1715 FLOG("[bgchecker] StartIaupdateL() begin"); |
|
1716 RWsSession ws; |
|
1717 User::LeaveIfError( ws.Connect() == KErrNone ); |
|
1718 TApaTaskList tasklist(ws); |
|
1719 TApaTask task = tasklist.FindApp( TUid::Uid( KIADUpdateLauncherUid ) ); |
|
1720 if ( task.Exists() ) |
|
1721 { |
|
1722 FLOG("[bgchecker] StartIaupdateL() IAD launcher process found"); |
|
1723 task.BringToForeground(); |
|
1724 FLOG("[bgchecker] StartIaupdateL() after task.BringToForeground()"); |
|
1725 ws.Close(); |
|
1726 } |
|
1727 else |
|
1728 { |
|
1729 ws.Close(); |
|
1730 RProcess process; |
|
1731 CleanupClosePushL( process ); |
|
1732 User::LeaveIfError( |
|
1733 process.Create( KIAUpdateLauncherExe, KNullDesC ) ); |
|
1734 |
|
1735 CApaCommandLine* commandLine = CApaCommandLine::NewLC(); |
|
1736 commandLine->SetDocumentNameL( KNullDesC ); |
|
1737 commandLine->SetExecutableNameL( _L("iaupdatelauncher.exe") ); |
|
1738 commandLine->SetTailEndL( KRefreshFromNetworkDenied ); |
|
1739 commandLine->SetProcessEnvironmentL( process ); |
|
1740 CleanupStack::PopAndDestroy( commandLine ); |
|
1741 |
|
1742 process.Resume(); |
|
1743 CleanupStack::PopAndDestroy( &process ); |
|
1744 } |
|
1745 FLOG("[bgchecker] StartIaupdateL() end"); |
|
1746 } |
|
1747 |
|
1748 // --------------------------------------------------------------------------- |
|
1749 // CIAUpdateBGTimer::IAUpdateEnabledL() |
|
1750 // --------------------------------------------------------------------------- |
|
1751 // |
|
1752 TBool CIAUpdateBGTimer::IAUpdateEnabledL() const |
|
1753 { |
|
1754 FLOG("[bgchecker] CIAUpdateBGTimer::IAUpdateEnabledL() begin"); |
|
1755 TBool enabled = EFalse; |
|
1756 RFeatureControl featureControl; |
|
1757 TInt error( KErrNone ); |
|
1758 |
|
1759 error = featureControl.Connect(); |
|
1760 FLOG_NUM("[bgchecker] CIAUpdateBGTimer::IAUpdateEnabledL() Connection to the Feature Manager Server: %d", error ); |
|
1761 |
|
1762 User::LeaveIfError( error ); |
|
1763 |
|
1764 TUid iaupdatefeature; |
|
1765 iaupdatefeature.iUid = KFeatureIdIAUpdate; |
|
1766 |
|
1767 TInt ret = featureControl.FeatureSupported( iaupdatefeature ); |
|
1768 if ( ret == KFeatureSupported ) |
|
1769 { |
|
1770 enabled = ETrue; |
|
1771 } |
|
1772 featureControl.Close(); |
|
1773 FLOG_NUM("[bgchecker] CIAUpdateBGTimer::IAUpdateEnabledL() enabled: %d", enabled ); |
|
1774 return enabled; |
|
1775 } |
|
1776 |
|
1777 // --------------------------------------------------------------------------- |
|
1778 // CIAUpdateBGTimer::Shutdown() |
|
1779 // --------------------------------------------------------------------------- |
|
1780 // |
|
1781 void CIAUpdateBGTimer::Shutdown() |
|
1782 { |
|
1783 FLOG("[bgchecker] Shutdown() begin"); |
|
1784 Cancel(); |
|
1785 delete iUpdate; |
|
1786 iUpdate = NULL; |
|
1787 |
|
1788 delete iReminderTimer; |
|
1789 iReminderTimer = NULL; |
|
1790 |
|
1791 if ( iNotifyHandler ) |
|
1792 { |
|
1793 iNotifyHandler->StopListening(); |
|
1794 delete iNotifyHandler; |
|
1795 iNotifyHandler = NULL; |
|
1796 } |
|
1797 |
|
1798 if ( iSoftNotification ) |
|
1799 { |
|
1800 TRAP_IGNORE( iSoftNotification->RemoveSoftNotificationL( iSoftNotification->Id() ) ); |
|
1801 delete iSoftNotification; |
|
1802 iSoftNotification = NULL; |
|
1803 } |
|
1804 |
|
1805 CActiveScheduler::Stop(); |
|
1806 |
|
1807 FLOG("[bgchecker] Shutdown() end"); |
|
1808 } |
|
1809 |
|
1810 |
|
1811 |
|
1812 // End of file |
|
1813 |
|
1814 |