iaupdate/IAD/backgroundchecker/src/iaupdatebgrefreshtimer.cpp
changeset 53 ae54820ef82c
parent 42 d17dc5398051
child 50 c6e8afe0ba85
child 60 245df5276b97
equal deleted inserted replaced
52:92f864ef0288 53:ae54820ef82c
    23 #include <iaupdateresult.h>
    23 #include <iaupdateresult.h>
    24 #include <w32std.h>
    24 #include <w32std.h>
    25 #include <apgwgnam.h>
    25 #include <apgwgnam.h>
    26 #include <apgcli.h>
    26 #include <apgcli.h>
    27 #include <apacmdln.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>
    28 #include <bautils.h>
    33 #include <apgtask.h>
    29 #include <apgtask.h>
    34 #include <sysversioninfo.h>  //sysversioninfo
    30 #include <sysversioninfo.h>  //sysversioninfo
    35 #include <featurecontrol.h>
    31 #include <featurecontrol.h>
    36 
    32 
    44 #include "iaupdatebginternalfilehandler.h"
    40 #include "iaupdatebginternalfilehandler.h"
    45 #include "iaupdatebgconst.h"
    41 #include "iaupdatebgconst.h"
    46 
    42 
    47 //MACROS
    43 //MACROS
    48 _LIT8( KRefreshFromNetworkDenied, "1" );
    44 _LIT8( KRefreshFromNetworkDenied, "1" );
    49 // _LIT(KIAUpdateResourceFile, "iaupdate.rsc");
       
    50 _LIT(KIAUpdateLauncherExe, "iaupdatelauncher.exe" );
    45 _LIT(KIAUpdateLauncherExe, "iaupdatelauncher.exe" );
    51 _LIT(KImageFile, "qgn_note_swupdate_notification.svg");
       
    52 _LIT8( KFirstTimeCase, "0" );
    46 _LIT8( KFirstTimeCase, "0" );
    53 
       
    54 
       
    55 
    47 
    56 //CONSTANTS
    48 //CONSTANTS
    57 const TUint KIADUpdateLauncherUid( 0x2001FE2F );
    49 const TUint KIADUpdateLauncherUid( 0x2001FE2F );
    58 
    50 
    59 // ----------------------------------------------------------
    51 // ----------------------------------------------------------
    75 void CIAUpdateBGTimer::ConstructL()
    67 void CIAUpdateBGTimer::ConstructL()
    76     {
    68     {
    77     CTimer::ConstructL();
    69     CTimer::ConstructL();
    78     CActiveScheduler::Add( this );
    70     CActiveScheduler::Add( this );
    79   
    71   
    80     iReminderTimer = CIAUpdateBGReminderTimer::NewL( this );
       
    81     iUpdate = NULL;
    72     iUpdate = NULL;
    82     iParameters = NULL;
    73     iParameters = NULL;
    83     
    74     
    84     iIAUpdateCRSession = NULL; 
    75     iIAUpdateCRSession = NULL; 
    85     iNotifyHandler = NULL;
    76     iNotifyHandler = NULL;
    86 
    77 
    87     iControllerFile = CIAUpdateBGControllerFile::NewL();
    78     iControllerFile = CIAUpdateBGControllerFile::NewL();
    88     
    79     
    89     iInternalFile = CIAUpdateBGInternalFileHandler::NewL();
    80     iInternalFile = CIAUpdateBGInternalFileHandler::NewL();
    90     
    81     
    91     iSoftNotification = CIAUpdateBGSoftNotification::NewL( this ); //, iInternalFile );
    82     iSoftNotification = CIAUpdateBGSoftNotification::NewL( this ); 
    92     // HLa: iSoftNotification->StartObservingIfNeededL();
    83     
    93     
    84     // loc: initialize localisation text loader
    94     // Get resource file path
    85     /*
    95     /* HLa
    86     TBool res = HbTextResolverSymbian::Init(KLocFile, KLocFilePath);
    96     TFileName fileName;
    87     if ( res != KErrNone )
    97     fileName.Copy(TParsePtrC(RProcess().FileName()).Drive());
    88         {
    98     fileName.Append(KDC_APP_RESOURCE_DIR);
    89         // nothing to do
    99     fileName.Append(KIAUpdateResourceFile);
    90         }
   100     */
    91     */
   101     
    92     }
   102     User::LeaveIfError(iFs.Connect());
       
   103 
       
   104     // Get language of resource file        
       
   105     //BaflUtils::NearestLanguageFile( iFs, fileName );
       
   106 
       
   107     // Open resource file
       
   108     //iResourceFile.OpenL( iFs, fileName );
       
   109     //iResourceFile.ConfirmSignatureL();    
       
   110     }
       
   111     
       
   112     
    93     
   113 // ----------------------------------------------------------
    94 // ----------------------------------------------------------
   114 // CIAUpdateBGTimer::~CIAUpdateBGTimer()
    95 // CIAUpdateBGTimer::~CIAUpdateBGTimer()
   115 // ----------------------------------------------------------
    96 // ----------------------------------------------------------
   116 CIAUpdateBGTimer::~CIAUpdateBGTimer()
    97 CIAUpdateBGTimer::~CIAUpdateBGTimer()
   117     {
    98     {
   118     Cancel();
    99     Cancel();
   119     delete iUpdate; 
   100     delete iUpdate; 
   120     delete iParameters;
   101     delete iParameters;
   121     delete iReminderTimer;
       
   122 
   102 
   123     if ( iNotifyHandler ) 
   103     if ( iNotifyHandler ) 
   124         {
   104         {
   125         iNotifyHandler->StopListening();
   105         iNotifyHandler->StopListening();
   126         delete iNotifyHandler;
   106         delete iNotifyHandler;
   129     delete iIAUpdateCRSession; 
   109     delete iIAUpdateCRSession; 
   130     delete iControllerFile;
   110     delete iControllerFile;
   131     delete iInternalFile;
   111     delete iInternalFile;
   132     delete iSoftNotification;
   112     delete iSoftNotification;
   133     
   113     
   134     // iResourceFile.Close();
   114     }
   135     iFs.Close();
       
   136     }
       
   137 
       
   138 
   115 
   139 // ----------------------------------------------------------
   116 // ----------------------------------------------------------
   140 // CIAUpdateBGTimer::StartProcessL()
   117 // CIAUpdateBGTimer::StartProcessL()
   141 // ----------------------------------------------------------
   118 // ----------------------------------------------------------
   142 void CIAUpdateBGTimer::StartProcessL()
   119 void CIAUpdateBGTimer::StartProcessL()
   143     {
   120     {
   144     FLOG("[bgchecker] StartProcessL");
   121     FLOG("[bgchecker] StartProcessL");
   145         
   122         
   146     iMode = ModeL();
   123     iMode = ModeL();
   147     
   124     
   148     //HLa
       
   149     TBool test1 = IsAgreementAcceptedL();
       
   150     TBool test2 = ReminderOnL();
       
   151     
       
   152     int test = 0;
       
   153     switch ( iMode )
   125     switch ( iMode )
   154         {
   126         {
   155         case EFirstTimeMode:
   127         case EFirstTimeMode:
   156          
       
   157         // while not released keep in sleep mode
       
   158         //int test = 1;
       
   159         if ( test == 0 )
       
   160             {
   128             {
   161             ListenAutoUpdateSettingsL();
   129             // while not released keep in sleep mode
   162             iMode = ESleepMode;
   130             int test = 0;
   163             SetModeL( iMode );
   131             if ( test == 0 )
   164             return;
   132                 {
   165             }
   133                 ListenAutoUpdateSettingsL();
       
   134                 iMode = ESleepMode;
       
   135                 SetModeL( iMode );
       
   136                 return;
       
   137                 }
   166         
   138         
   167         //case EFirstTimeRemindMode:    
       
   168             {
       
   169             if ( IsFirstTimeDialogDisabledL() )
   139             if ( IsFirstTimeDialogDisabledL() )
   170                 {
   140                 {
   171                 //this should only happen in testing
   141                 //this should only happen in testing
   172                 FLOG("[bgchecker] StartProcessL Firs time dialog is disabled, this should only happen in testing");
   142                 FLOG("[bgchecker] StartProcessL Firs time dialog is disabled, this should only happen in testing");
   173 
   143 
   191                 }
   161                 }
   192 
   162 
   193                         
   163                         
   194             FLOG("[bgchecker] StartProcessL EFirstTimeMode");
   164             FLOG("[bgchecker] StartProcessL EFirstTimeMode");
   195             
   165             
   196             
       
   197 
       
   198 
       
   199             //Wait for some days before activate the first time mode
   166             //Wait for some days before activate the first time mode
   200             TTimeIntervalMinutes timetowait =
   167             TTimeIntervalMinutes timetowait =
   201                     TimeIntervalFromNextShowOfNewFeatureDialogL();
   168                     TimeIntervalFromNextShowOfNewFeatureDialogL();
   202                 FLOG_NUM( " time to wait = %d", timetowait.Int() );
   169                 FLOG_NUM( " time to wait = %d", timetowait.Int() );
   203             if (timetowait.Int() <= 0)
   170             if (timetowait.Int() <= 0)
   237                 }    
   204                 }    
   238                                 
   205                                 
   239                                                   
   206                                                   
   240             break;
   207             break;
   241             }
   208             }
   242 /*
   209 
   243         case EFirstTimeMode2:
   210         case EFirstTimeMode2:
   244             {
   211             {
   245             FLOG("[bgchecker] StartProcessL EFirstTimeMode2");
   212             FLOG("[bgchecker] StartProcessL EFirstTimeMode 2");
   246             RunL();
       
   247             break;
       
   248             }
       
   249 */
       
   250         case EFirstTimeMode2:
       
   251             {
       
   252             FLOG("[bgchecker] StartProcessL EFirstTimeMode 3");
       
   253             //if user accepted the disclaimer already and reboot the phone, 
   213             //if user accepted the disclaimer already and reboot the phone, 
   254             //this mode could go to network immediately after boot
   214             //this mode could go to network immediately after boot
   255             //We put one min delay here to wait for network ready.
   215             //We put one min delay here to wait for network ready.
   256             StartL(StartAfterOneMin);
   216             StartL(StartAfterOneMin);
   257             break;
   217             break;
   292             }
   252             }
   293 
   253 
   294         case ENormalMode:
   254         case ENormalMode:
   295         case ERetryMode:
   255         case ERetryMode:
   296             {
   256             {
       
   257             
       
   258             // Check if indicator should be shown
       
   259             
       
   260             
   297             StartUpdatesCheckingL();
   261             StartUpdatesCheckingL();
   298             break;
   262             break;
   299             }
   263             }
   300         
   264         
   301         default:
   265         default:
   314     CleanupStack::PushL( fthandler );
   278     CleanupStack::PushL( fthandler );
   315     TBool result = fthandler->AgreementAcceptedL();
   279     TBool result = fthandler->AgreementAcceptedL();
   316     
   280     
   317     CleanupStack::PopAndDestroy( fthandler );
   281     CleanupStack::PopAndDestroy( fthandler );
   318     
   282     
   319     return result;
       
   320     }
       
   321 
       
   322 
       
   323 // ----------------------------------------------------------
       
   324 // CIAUpdateBGTimer::IsAskedAlreadyL()
       
   325 // ----------------------------------------------------------
       
   326 TBool CIAUpdateBGTimer::IsAskedAlreadyL()
       
   327     {
       
   328     CIAUpdateBGFirstTimeHandler* fthandler  = CIAUpdateBGFirstTimeHandler::NewL();
       
   329     CleanupStack::PushL( fthandler );
       
   330     TBool result = fthandler->AgreementAskedL();
       
   331     CleanupStack::PopAndDestroy( fthandler );
       
   332     return result;
   283     return result;
   333     }
   284     }
   334 
   285 
   335 
   286 
   336 // ----------------------------------------------------------
   287 // ----------------------------------------------------------
   367     else
   318     else
   368         {
   319         {
   369             FLOG_NUM( "Start checking update after %d minutes", timetowait.Int());
   320             FLOG_NUM( "Start checking update after %d minutes", timetowait.Int());
   370             StartL( timetowait );
   321             StartL( timetowait );
   371             
   322             
   372             //start reminder timer also if user choose later before reboot
   323          }
   373             //check the value from private folder
       
   374              
       
   375             
       
   376               if ( ReminderOnL() )
       
   377                   {
       
   378                   TTime currenttime;
       
   379                   currenttime.UniversalTime();
       
   380                   
       
   381                   FTIME( currenttime );
       
   382                   
       
   383                   TTime nextremindtime = NextRemindTimeL();
       
   384                   
       
   385                   FTIME( nextremindtime );
       
   386                   
       
   387                   TTimeIntervalMinutes timetogo;
       
   388                   nextremindtime.MinutesFrom( currenttime, timetogo );
       
   389                   
       
   390                   FLOG_NUM("time to go = %d", timetogo.Int() );
       
   391                   
       
   392                   if ( timetogo.Int() <= 0 )
       
   393                       {
       
   394                       //pop up the reminder directly
       
   395                       ReminderTimerCallBack();
       
   396                       }
       
   397                   else
       
   398                       {
       
   399                       iReminderTimer->StartReminderTimerL( timetogo );
       
   400                       }
       
   401                   }
       
   402                   
       
   403             }
       
   404     }
   324     }
   405 
   325 
   406 
   326 
   407 // ----------------------------------------------------------
   327 // ----------------------------------------------------------
   408 // CIAUpdateBGTimer::DoHandleNotifyGeneric()
   328 // CIAUpdateBGTimer::DoHandleNotifyGeneric()
   525     return err;
   445     return err;
   526     }
   446     }
   527 
   447 
   528 
   448 
   529 // ----------------------------------------------------------
   449 // ----------------------------------------------------------
   530 // CIAUpdateBGTimer::NextRemindTimeL()
       
   531 // ----------------------------------------------------------
       
   532 TTime CIAUpdateBGTimer::NextRemindTimeL()
       
   533     {
       
   534     iInternalFile->ReadControllerDataL();
       
   535     return iInternalFile->NextRemindTime();
       
   536     }
       
   537 
       
   538 
       
   539 // ----------------------------------------------------------
       
   540 // CIAUpdateBGTimer::SetNextRemindTimeL()
       
   541 // ----------------------------------------------------------
       
   542 TInt CIAUpdateBGTimer::SetNextRemindTimeL( TTime aTime )
       
   543     {
       
   544     iInternalFile->SetNextRemindTime( aTime );
       
   545     TRAPD( err,iInternalFile->WriteControllerDataL() );
       
   546     return err;
       
   547     }
       
   548 
       
   549 
       
   550 // ----------------------------------------------------------
       
   551 // CIAUpdateBGTimer::ReminderOnL()
       
   552 // ----------------------------------------------------------
       
   553 TBool CIAUpdateBGTimer::ReminderOnL()
       
   554     {
       
   555     iInternalFile->ReadControllerDataL(); 
       
   556     return iInternalFile->ReminderOn();
       
   557     }
       
   558 
       
   559 
       
   560 // ----------------------------------------------------------
       
   561 // CIAUpdateBGTimer::SetReminderL()
       
   562 // ----------------------------------------------------------
       
   563 TInt CIAUpdateBGTimer::SetReminderL( TBool aOn )
       
   564     {
       
   565     iInternalFile->SetReminder( aOn );
       
   566     TRAPD( err,iInternalFile->WriteControllerDataL() );
       
   567     return err;
       
   568     }
       
   569 
       
   570 
       
   571 // ----------------------------------------------------------
       
   572 // CIAUpdateBGTimer::ModeL()
   450 // CIAUpdateBGTimer::ModeL()
   573 // ----------------------------------------------------------
   451 // ----------------------------------------------------------
   574 TIAUpdateBGMode CIAUpdateBGTimer::ModeL()
   452 TIAUpdateBGMode CIAUpdateBGTimer::ModeL()
   575     {
   453     {
   576     iInternalFile->ReadControllerDataL();
   454     iInternalFile->ReadControllerDataL();
   623 // CIAUpdateBGTimer::DoUpdatesCheckingL()
   501 // CIAUpdateBGTimer::DoUpdatesCheckingL()
   624 // ----------------------------------------------------------
   502 // ----------------------------------------------------------
   625 void CIAUpdateBGTimer::DoUpdatesCheckingL( const TBool& aUpdateFromServer )
   503 void CIAUpdateBGTimer::DoUpdatesCheckingL( const TBool& aUpdateFromServer )
   626     {   
   504     {   
   627     FLOG( "DoUpdatesCheckingL update");
   505     FLOG( "DoUpdatesCheckingL update");
   628     //turn off the reminder, user will decide whether to turn if on or off
       
   629     //The user's decision will be checked in soft notification callback function
       
   630     
       
   631     
       
   632     if ( ReminderOnL())
       
   633         {
       
   634         FLOG( "Do CheckUpdates 3");
       
   635         iReminderTimer->CancelReminderTimerL();
       
   636         SetReminderL( EFalse );
       
   637         }
       
   638     
       
   639     
   506     
   640     if( !iUpdate )
   507     if( !iUpdate )
   641         {
   508         {
   642         iUpdate = CIAUpdate::NewL( *this );
   509         iUpdate = CIAUpdate::NewL( *this );
   643         }
   510         }
   738         if ( aAvailableUpdates > 0 )
   605         if ( aAvailableUpdates > 0 )
   739             {             
   606             {             
   740             FLOG( "CheckUpdatesComplete 4");
   607             FLOG( "CheckUpdatesComplete 4");
   741     
   608     
   742             LaunchNotificationL( aAvailableUpdates );
   609             LaunchNotificationL( aAvailableUpdates );
   743             //LaunchSoftNotificationL(R_IAUPDATE_UPDATE_AVAILABLE,
       
   744             //            R_TEXT_SOFTKEY_SHOW, R_TEXT_SOFTKEY_LATER );
       
   745             }
   610             }
   746 
   611 
   747             FLOG( "CheckUpdatesComplete 5");
   612             FLOG( "CheckUpdatesComplete 5");
   748         
   613         
   749         // if update checking is from server, restart the refresh timer 
   614         // if update checking is from server, restart the refresh timer 
   785             if ( checkupdatefromserver )
   650             if ( checkupdatefromserver )
   786                 {
   651                 {
   787                 TTimeIntervalMinutes interval( CheckingFrequencyInMinutesL() );
   652                 TTimeIntervalMinutes interval( CheckingFrequencyInMinutesL() );
   788                 StartL( interval );
   653                 StartL( interval );
   789                 SetLastRefreshTime();
   654                 SetLastRefreshTime();
   790                 }
       
   791             else
       
   792                 {
       
   793                 //don't show soft notification and restart the timer.
       
   794                 TTimeIntervalMinutes oneweek( UpdateAvailableReminderIntervalInMinutesL() );   
       
   795                 TTime currenttime;
       
   796                 currenttime.UniversalTime();
       
   797                 TTime nextRemindTime = currenttime + oneweek;
       
   798 
       
   799                 SetReminderL( ETrue );
       
   800                 SetNextRemindTimeL( nextRemindTime );
       
   801                                        
       
   802                 iReminderTimer->StartReminderTimerL( oneweek );
       
   803                 }
   655                 }
   804             //clear the retry time
   656             //clear the retry time
   805             SetRetryTimesL( 0 ); 
   657             SetRetryTimesL( 0 ); 
   806             }
   658             }
   807         else
   659         else
   943                  }        
   795                  }        
   944             }
   796             }
   945             break;
   797             break;
   946             
   798             
   947         case EFirstTimeMode:
   799         case EFirstTimeMode:
   948         //case EFirstTimeRemindMode:
       
   949             {
   800             {
   950             FLOG("[bgchecker] runl EFirstTimeMode");
   801             FLOG("[bgchecker] runl EFirstTimeMode");
   951             
   802             
   952             if ( iRuns == 0 )
   803             if ( iRuns == 0 )
   953                 {
   804                 {
   968                     StartL( timetowait );
   819                     StartL( timetowait );
   969                     } 
   820                     } 
   970                 }
   821                 }
   971             }
   822             }
   972             break;
   823             break;
   973         /*
   824 
   974         case EFirstTimeMode2:
   825         case EFirstTimeMode2:
   975             {
   826             {
   976             FLOG("[bgchecker] runl EFirstTimeMode2");
   827             FLOG("[bgchecker] runl EFirstTimeMode2");                 
   977             LaunchNotificationL( 1 );
       
   978             //LaunchSoftNotificationL(R_IAUPDATE_REMIND_LATER, R_TEXT_SOFTKEY_YES, R_TEXT_SOFTKEY_NO );
       
   979             }
       
   980             break;
       
   981         */
       
   982         case EFirstTimeMode2:
       
   983             {
       
   984             FLOG("[bgchecker] runl EFirstTimeMode3");                 
       
   985             //disclaimer is not accepted  
   828             //disclaimer is not accepted  
   986            
   829            
   987             if ( !IsAgreementAcceptedL()  )
   830             if ( !IsAgreementAcceptedL()  )
   988                 {
   831                 {
   989                 FLOG("[bgchecker] runl EFirstTimeMode reject disclaimer");
   832                 FLOG("[bgchecker] runl EFirstTimeMode reject disclaimer");
  1010             break;
   853             break;
  1011         };
   854         };
  1012        
   855        
  1013     }
   856     }
  1014 
   857 
  1015 /*
       
  1016 // ----------------------------------------------------------
       
  1017 // CIAUpdateBGTimer::RunL()
       
  1018 // ----------------------------------------------------------
       
  1019 void CIAUpdateBGTimer::RunL()
       
  1020     {
       
  1021     FLOG("[bgchecker]RunL() ");
       
  1022     if ( !IAUpdateEnabledL() )
       
  1023         {
       
  1024         Shutdown();
       
  1025         return;
       
  1026         }
       
  1027     User::LeaveIfError( iStatus.Int() );
       
  1028     //Check the mode again, in case the mode is changed while waiting.
       
  1029     iMode = ModeL();
       
  1030     
       
  1031     switch ( iMode )
       
  1032         {
       
  1033         case ENormalMode:
       
  1034         case ERetryMode:
       
  1035             {     
       
  1036             FLOG("[bgchecker]RunL() ENormalMode");                                    
       
  1037             //roaming case is checked in IAUpdate server side
       
  1038             if ( IsAutoUpdateDisabledL() )
       
  1039                 {
       
  1040                 ListenAutoUpdateSettingsL();
       
  1041                 
       
  1042                 iMode = ESleepMode;
       
  1043                 SetModeL( iMode );
       
  1044                 
       
  1045                 //the program is waked up when automatic checking is changed by user.
       
  1046                 //cenrep call back will be used.
       
  1047                 return;
       
  1048                 }                        
       
  1049             
       
  1050             FLOG("[bgchecker]RunL() ENormalMode 1");
       
  1051             
       
  1052             if(iRuns == 0)
       
  1053                 {
       
  1054                 FLOG("[bgchecker]RunL() ENormalMode 2");
       
  1055                 // if user did the refresh from server while waiting, restart the timer.
       
  1056                 // the last refresh time is read from the private file of IAUpdate server.
       
  1057                 TTimeIntervalMinutes timetowait =
       
  1058                         TimeIntervalFromNextRefreshL();
       
  1059 
       
  1060                 if (timetowait.Int() <= 0 )
       
  1061                     {
       
  1062                     DoUpdatesCheckingL( ETrue );
       
  1063                     }
       
  1064                 else
       
  1065                     {
       
  1066                     StartL( timetowait );
       
  1067                     }
       
  1068                 FLOG("[bgchecker]RunL() ENormalMode 3");
       
  1069                 }
       
  1070             else
       
  1071                 {
       
  1072                 FLOG("[bgchecker]RunL() ENormalMode 4");
       
  1073                 TTimeIntervalMinutes timetowait = TimeIntervalFromNextRefreshL();
       
  1074                    
       
  1075                    if ( timetowait.Int() <= 0 )
       
  1076                        {
       
  1077                        StartL( StartNow );
       
  1078                        }
       
  1079                    else
       
  1080                        {
       
  1081                        StartL( timetowait );
       
  1082                        }
       
  1083                    FLOG("[bgchecker]RunL() ENormalMode 5");
       
  1084                  }        
       
  1085             }
       
  1086             break;
       
  1087             
       
  1088         case EFirstTimeMode:
       
  1089         case EFirstTimeRemindMode:
       
  1090             {
       
  1091             FLOG("[bgchecker] runl EFirstTimeMode");
       
  1092             
       
  1093             if ( iRuns == 0 )
       
  1094                 {
       
  1095                 FLOG("[bgchecker] runl run = 0");
       
  1096                 HandlerFirstTimeL();
       
  1097                 }
       
  1098             else
       
  1099                 {
       
  1100                 FLOG("[bgchecker] runl still wait");
       
  1101                 TTimeIntervalMinutes timetowait = TimeIntervalFromNextShowOfNewFeatureDialogL();
       
  1102                                    
       
  1103                 if ( timetowait.Int() <= 0 )
       
  1104                     {
       
  1105                     StartL( StartNow );
       
  1106                     }
       
  1107                  else
       
  1108                     {
       
  1109                     StartL( timetowait );
       
  1110                     } 
       
  1111                 }
       
  1112             }
       
  1113             break;
       
  1114 
       
  1115         case EFirstTimeMode2:
       
  1116             {
       
  1117             FLOG("[bgchecker] runl EFirstTimeMode2");
       
  1118             LaunchNotificationL( 1 );
       
  1119             //LaunchSoftNotificationL(R_IAUPDATE_REMIND_LATER, R_TEXT_SOFTKEY_YES, R_TEXT_SOFTKEY_NO );
       
  1120             }
       
  1121             break;
       
  1122 
       
  1123         case EFirstTimeMode3:
       
  1124             {
       
  1125             FLOG("[bgchecker] runl EFirstTimeMode3");                 
       
  1126             //disclaimer is not accepted  
       
  1127            
       
  1128             if ( !IsAgreementAcceptedL()  )
       
  1129                 {
       
  1130                 FLOG("[bgchecker] runl EFirstTimeMode reject disclaimer");
       
  1131                 //user accepte the new feature dialog but user reject sthe disclaimer
       
  1132                 //in sleep mode now
       
  1133                 iMode = ESleepMode;
       
  1134                 SetModeL( iMode );
       
  1135                 //subscribe to cenrep key for automatic checking for wake up from sleep mode
       
  1136                 ListenAutoUpdateSettingsL(); 
       
  1137                 }
       
  1138             else
       
  1139                 {
       
  1140                 FLOG("[bgchecker] runl EFirstTimeMode go to normal mode");
       
  1141                 //Set to Normal mode
       
  1142                 //check autochecksetting in Runl later
       
  1143                 iMode = ENormalMode;
       
  1144                 SetModeL( iMode );
       
  1145                 StartL( StartNow );
       
  1146                 }
       
  1147             }
       
  1148             break;
       
  1149             
       
  1150         default:
       
  1151             break;
       
  1152         };
       
  1153        
       
  1154     }*/
       
  1155 
   858 
  1156 // ----------------------------------------------------------
   859 // ----------------------------------------------------------
  1157 // CIAUpdateBGTimer::HandlerFirstTimeL()
   860 // CIAUpdateBGTimer::HandlerFirstTimeL()
  1158 // ----------------------------------------------------------
   861 // ----------------------------------------------------------
  1159 void CIAUpdateBGTimer::HandlerFirstTimeL()
   862 void CIAUpdateBGTimer::HandlerFirstTimeL()
  1176     else
   879     else
  1177         {
   880         {
  1178         //this is first time mode
   881         //this is first time mode
  1179         FLOG("[bgchecker]HandlerFirstTimeL 3 ");
   882         FLOG("[bgchecker]HandlerFirstTimeL 3 ");
  1180         LaunchNotificationL( 0 );
   883         LaunchNotificationL( 0 );
  1181         // LaunchSoftNotificationL( R_IAUPDATE_FEATURES_AVAILABLE,
       
  1182         //            R_TEXT_SOFTKEY_OK, R_TEXT_SOFTKEY_CANCEL );
       
  1183         }
   884         }
  1184     }
   885     }
  1185 
   886 
  1186 
   887 
  1187 // ----------------------------------------------------------
   888 // ----------------------------------------------------------
  1444     if ( ModeL() == EFirstTimeMode )
  1145     if ( ModeL() == EFirstTimeMode )
  1445         {
  1146         {
  1446         FLOG(" current mode is FirstTimeMode ");
  1147         FLOG(" current mode is FirstTimeMode ");
  1447         interval = FirstTimeDialogDelayInMinutesL();
  1148         interval = FirstTimeDialogDelayInMinutesL();
  1448         }
  1149         }
  1449     /*
       
  1450     else if ( ModeL() == EFirstTimeRemindMode )
       
  1451         {
       
  1452         FLOG(" current mode is FirstTimeRemindMode");
       
  1453         interval = FirstTimeDialogReminderIntervalInMinutesL();
       
  1454         }*/
       
  1455     else
  1150     else
  1456         {
  1151         {
  1457         //nothing
  1152         //nothing
  1458         FLOG(" current mode is wrong!!");
  1153         FLOG(" current mode is wrong!!");
  1459         User::LeaveIfError( KErrArgument );
  1154         User::LeaveIfError( KErrArgument );
  1483     iMode = ModeL(); 
  1178     iMode = ModeL(); 
  1484     
  1179     
  1485       switch ( iMode )
  1180       switch ( iMode )
  1486           {
  1181           {
  1487           case EFirstTimeMode:
  1182           case EFirstTimeMode:
  1488           // case EFirstTimeRemindMode:     
       
  1489                  {
  1183                  {
  1490                  
  1184                  
  1491                  FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode");
  1185                  FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode");
  1492                  if ( !aIsAccepted )
  1186                  if ( !aIsAccepted )
  1493                      {
  1187                      {
  1497                      SetModeL( iMode );
  1191                      SetModeL( iMode );
  1498                      
  1192                      
  1499                      //subscribe to cenrep key for automatic checking for wake up from sleep mode
  1193                      //subscribe to cenrep key for automatic checking for wake up from sleep mode
  1500                      ListenAutoUpdateSettingsL();
  1194                      ListenAutoUpdateSettingsL();
  1501                      
  1195                      
  1502                      /*
       
  1503                      FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode not accepted");
       
  1504                      iMode = EFirstTimeMode2;
       
  1505                      SetModeL( iMode );
       
  1506                      StartL( StartNow );
       
  1507                      */
       
  1508                      }
  1196                      }
  1509                  else
  1197                  else
  1510                      {
  1198                      {
  1511                      FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMod accepeted");
  1199                      FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMod accepeted");
  1512                      StartIaupdateL();
  1200                      StartIaupdateL();
  1522                      //check user's setting and disclamier after 10mins.
  1210                      //check user's setting and disclamier after 10mins.
  1523                      }
  1211                      }
  1524                  break;
  1212                  break;
  1525                  }
  1213                  }
  1526                  
  1214                  
  1527                  
       
  1528           /*       
       
  1529           case EFirstTimeMode2:  // reminder 
       
  1530               {
       
  1531               FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode2 ");
       
  1532               if ( aIsAccepted ) // reminder accepted ?
       
  1533                   {
       
  1534                   FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode2, accepted");
       
  1535                   //user wants to be reminder so remind in 4 weeks
       
  1536                   //set to first time remind mode
       
  1537                   iMode = EFirstTimeRemindMode;
       
  1538                   SetModeL( iMode );
       
  1539                   TTimeIntervalMinutes fourweeks( FirstTimeDialogReminderIntervalInMinutesL() );            
       
  1540                   TTime currenttime;
       
  1541                   currenttime.UniversalTime();
       
  1542                         
       
  1543                   //save the next show new feature dialog time
       
  1544                   //in case use switch off the device and restarted.      
       
  1545                   User::LeaveIfError( SetLastTimeShowNewFeatureDialogL( currenttime ) );
       
  1546                         
       
  1547                   StartL( fourweeks );
       
  1548                   return;
       
  1549                   }
       
  1550               else
       
  1551                   {
       
  1552                   FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode2, not accepted");
       
  1553                   //in sleep mode now
       
  1554                   iMode = ESleepMode;
       
  1555                   SetModeL( iMode );
       
  1556                   
       
  1557                   //subscribe to cenrep key for automatic checking for wake up from sleep mode
       
  1558                   ListenAutoUpdateSettingsL(); 
       
  1559                   }
       
  1560               break;
       
  1561               }
       
  1562           */    
       
  1563           case ENormalMode:
  1215           case ENormalMode:
  1564               {
  1216               {
  1565               FLOG("[bgchecker] SoftNotificationCallBack ENormalMode");
  1217               FLOG("[bgchecker] SoftNotificationCallBack ENormalMode");
  1566               if ( !aIsAccepted )
  1218               if ( !aIsAccepted )
  1567                   {
  1219                   {
  1568                   FLOG("[bgchecker] SoftNotificationCallBack ENormalMode not accpeted");
  1220                   FLOG("[bgchecker] SoftNotificationCallBack ENormalMode not accpeted");
  1569                   //user wants to be reminded later
       
  1570                   TTimeIntervalMinutes oneweek( UpdateAvailableReminderIntervalInMinutesL() );   
       
  1571                   TTime currenttime;
       
  1572                   currenttime.UniversalTime();
       
  1573                   TTime nextRemindTime = currenttime + oneweek;
       
  1574 
       
  1575                   SetReminderL( ETrue );
       
  1576                   SetNextRemindTimeL( nextRemindTime );
       
  1577                   
  1221                   
  1578                   iReminderTimer->StartReminderTimerL( oneweek );
       
  1579                   
       
  1580                   //the reminder call back function will be called when reminder timer expires.
       
  1581                   }
  1222                   }
  1582               else
  1223               else
  1583                   {
  1224                   {
  1584                   //accepted, launch iad
  1225                   //accepted, launch iad
  1585                   StartIaupdateL();
  1226                   StartIaupdateL();
  1597           default:
  1238           default:
  1598               break;
  1239               break;
  1599           }
  1240           }
  1600     }
  1241     }
  1601 
  1242 
  1602 /*
       
  1603 // ----------------------------------------------------------
       
  1604 // CIAUpdateBGTimer::DoSoftNotificationCallBackL()
       
  1605 // ----------------------------------------------------------
       
  1606 void CIAUpdateBGTimer::DoSoftNotificationCallBackL( TBool aIsAccepted )
       
  1607     {
       
  1608     FLOG("[bgchecker] SoftNotificationCallBack");
       
  1609     if ( !IAUpdateEnabledL() )
       
  1610         {
       
  1611         Shutdown();
       
  1612         return;
       
  1613         }
       
  1614     iMode = ModeL(); 
       
  1615     
       
  1616       switch ( iMode )
       
  1617           {
       
  1618           case EFirstTimeMode:
       
  1619           case EFirstTimeRemindMode:     
       
  1620                  {
       
  1621                  
       
  1622                  FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode");
       
  1623                  if ( !aIsAccepted )
       
  1624                      {
       
  1625                      FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode not accepted");
       
  1626                      iMode = EFirstTimeMode2;
       
  1627                      SetModeL( iMode );
       
  1628                      StartL( StartNow );
       
  1629                      }
       
  1630                  else
       
  1631                      {
       
  1632                      FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMod accepeted");
       
  1633                      StartIaupdateL();
       
  1634                      //iaupdate is launched
       
  1635                      //check the disclaimer acceptance and automatic checking setting in 10mins
       
  1636 
       
  1637                      StartL( KDelayForUserToAcceptDisclaimer );
       
  1638                      iMode = EFirstTimeMode3;     
       
  1639                      SetModeL( iMode );
       
  1640 
       
  1641                      
       
  1642                      //Still in first time mode, 
       
  1643                      //check user's setting and disclamier after 10mins.
       
  1644                      }
       
  1645                  break;
       
  1646                  }
       
  1647                  
       
  1648                  
       
  1649                  
       
  1650           case EFirstTimeMode2:  // reminder 
       
  1651               {
       
  1652               FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode2 ");
       
  1653               if ( aIsAccepted ) // reminder accepted ?
       
  1654                   {
       
  1655                   FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode2, accepted");
       
  1656                   //user wants to be reminder so remind in 4 weeks
       
  1657                   //set to first time remind mode
       
  1658                   iMode = EFirstTimeRemindMode;
       
  1659                   SetModeL( iMode );
       
  1660                   TTimeIntervalMinutes fourweeks( FirstTimeDialogReminderIntervalInMinutesL() );            
       
  1661                   TTime currenttime;
       
  1662                   currenttime.UniversalTime();
       
  1663                         
       
  1664                   //save the next show new feature dialog time
       
  1665                   //in case use switch off the device and restarted.      
       
  1666                   User::LeaveIfError( SetLastTimeShowNewFeatureDialogL( currenttime ) );
       
  1667                         
       
  1668                   StartL( fourweeks );
       
  1669                   return;
       
  1670                   }
       
  1671               else
       
  1672                   {
       
  1673                   FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode2, not accepted");
       
  1674                   //in sleep mode now
       
  1675                   iMode = ESleepMode;
       
  1676                   SetModeL( iMode );
       
  1677                   
       
  1678                   //subscribe to cenrep key for automatic checking for wake up from sleep mode
       
  1679                   ListenAutoUpdateSettingsL(); 
       
  1680                   }
       
  1681               break;
       
  1682               }
       
  1683               
       
  1684           case ENormalMode:
       
  1685               {
       
  1686               FLOG("[bgchecker] SoftNotificationCallBack ENormalMode");
       
  1687               if ( !aIsAccepted )
       
  1688                   {
       
  1689                   FLOG("[bgchecker] SoftNotificationCallBack ENormalMode not accpeted");
       
  1690                   //user wants to be reminded later
       
  1691                   TTimeIntervalMinutes oneweek( UpdateAvailableReminderIntervalInMinutesL() );   
       
  1692                   TTime currenttime;
       
  1693                   currenttime.UniversalTime();
       
  1694                   TTime nextRemindTime = currenttime + oneweek;
       
  1695 
       
  1696                   SetReminderL( ETrue );
       
  1697                   SetNextRemindTimeL( nextRemindTime );
       
  1698                   
       
  1699                   iReminderTimer->StartReminderTimerL( oneweek );
       
  1700                   
       
  1701                   //the reminder call back function will be called when reminder timer expires.
       
  1702                   }
       
  1703               else
       
  1704                   {
       
  1705                   //accepted, launch iad
       
  1706                   StartIaupdateL();
       
  1707                   }
       
  1708               break;
       
  1709               }
       
  1710 
       
  1711           case ESleepMode:
       
  1712               {
       
  1713               FLOG("[bgchecker] SoftNotificationCallBack ESleepMode");
       
  1714               //donothing
       
  1715               break;
       
  1716               }
       
  1717 
       
  1718           default:
       
  1719               break;
       
  1720           }
       
  1721     } */
       
  1722 
       
  1723 // ----------------------------------------------------------
  1243 // ----------------------------------------------------------
  1724 // CIAUpdateBGTimer::SoftNotificationCallBack()
  1244 // CIAUpdateBGTimer::SoftNotificationCallBack()
  1725 // ----------------------------------------------------------
  1245 // ----------------------------------------------------------
  1726 void CIAUpdateBGTimer::SoftNotificationCallBack( TBool aIsAccepted )
  1246 void CIAUpdateBGTimer::SoftNotificationCallBack( TBool aIsAccepted )
  1727     {
  1247     {
  1735 TIAUpdateBGMode CIAUpdateBGTimer::CurrentMode()
  1255 TIAUpdateBGMode CIAUpdateBGTimer::CurrentMode()
  1736     {
  1256     {
  1737     return iMode;
  1257     return iMode;
  1738     }
  1258     }
  1739 
  1259 
  1740 
       
  1741 
       
  1742 // ----------------------------------------------------------
       
  1743 // CIAUpdateBGTimer::DoReminderTimerCallBack()
       
  1744 // ----------------------------------------------------------
       
  1745 void CIAUpdateBGTimer::DoReminderTimerCallBackL()
       
  1746     {
       
  1747     FLOG("[bgchecker] ReminderTimerCallBack begin");
       
  1748     if ( !IAUpdateEnabledL() )
       
  1749         {
       
  1750         Shutdown();
       
  1751         return;
       
  1752         }
       
  1753     //Check the automatic update setting, if it has been disabled, 
       
  1754     //then go to sleep mode.   
       
  1755     if ( IsAutoUpdateDisabledL() )
       
  1756         {
       
  1757         FLOG("[bgchecker] ReminderTimerCallBack autoupdate is disabled, switch to sleep mode");
       
  1758         ListenAutoUpdateSettingsL();
       
  1759         iMode = ESleepMode;
       
  1760         SetModeL( iMode );
       
  1761         return;
       
  1762         } 
       
  1763     
       
  1764     TTimeIntervalMinutes timetowait = TimeIntervalFromNextRefreshL();
       
  1765     
       
  1766     if ( timetowait.Int() <= KRefreshTimerReminderTimerGap )
       
  1767         {
       
  1768         FLOG("[bgchecker] ReminderTimerCallBack refresh is about to come in one day. We don't show reminder then");
       
  1769         return;
       
  1770         }
       
  1771     
       
  1772     //if reminder is still on which means the BGTimer is not expired 
       
  1773     //and checkupdate() is not called yet, then go ahead to call DoupdatesChecking
       
  1774     //this is to avoid DoUpdateChecking being called at the same time.
       
  1775         
       
  1776     if ( ReminderOnL() )
       
  1777         {
       
  1778         FLOG("[bgchecker] ReminderTimerCallBack Reminder is still ON");
       
  1779         DoUpdatesCheckingL( EFalse );
       
  1780         }
       
  1781     FLOG("[bgchecker] ReminderTimerCallBack end");
       
  1782     }
       
  1783 
       
  1784 // ----------------------------------------------------------
       
  1785 // CIAUpdateBGTimer::ReminderTimerCallBack()
       
  1786 // ----------------------------------------------------------
       
  1787 void CIAUpdateBGTimer::ReminderTimerCallBack()
       
  1788     {
       
  1789     TRAP_IGNORE( DoReminderTimerCallBackL() );
       
  1790     }
       
  1791    
       
  1792 // ----------------------------------------------------------
  1260 // ----------------------------------------------------------
  1793 // CIAUpdateBGTimer::LaunchNotificationL( const int aNrOfUpdates )
  1261 // CIAUpdateBGTimer::LaunchNotificationL( const int aNrOfUpdates )
  1794 // ----------------------------------------------------------
  1262 // ----------------------------------------------------------
  1795 void CIAUpdateBGTimer::LaunchNotificationL( const int aNrOfUpdates )
  1263 void CIAUpdateBGTimer::LaunchNotificationL( const int aNrOfUpdates )
  1796     {
  1264     {
  1872     // HBufC* titleText = HbTextResolverSymbian::LoadL(KTextTitle);
  1340     // HBufC* titleText = HbTextResolverSymbian::LoadL(KTextTitle);
  1873     // CleanupStack::PushL( titleText );
  1341     // CleanupStack::PushL( titleText );
  1874     // HBufC* secondText3 = HbTextResolverSymbian::LoadL(KTextSecond);
  1342     // HBufC* secondText3 = HbTextResolverSymbian::LoadL(KTextSecond);
  1875     // CleanupStack::PushL( titleText );
  1343     // CleanupStack::PushL( titleText );
  1876     
  1344     
  1877     //TBuf<256> iconPath;
       
  1878     
  1345     
  1879     TBuf<128> titleText;
  1346     TBuf<128> titleText;
  1880     TBuf<128> secondText;
  1347     TBuf<128> secondText;
  1881     
  1348     
  1882     //title text (normal/first time)
  1349     //title text (normal/first time)
  1891     
  1358     
  1892     //text for 2nd line
  1359     //text for 2nd line
  1893     secondText.Append(KSecondText);
  1360     secondText.Append(KSecondText);
  1894             
  1361             
  1895     // icon
  1362     // icon
       
  1363     /* HLa-->
  1896     if ( iMode == ENormalMode )
  1364     if ( iMode == ENormalMode )
  1897         {
  1365         {
  1898         TFileName path;
  1366         TFileName path;
  1899         TInt err = GetPrivatePathL( path ); 
  1367         TInt err = GetPrivatePathL( path ); 
  1900         
  1368         
  1904             //HBufC8* image = LoadFileLC( path );   
  1372             //HBufC8* image = LoadFileLC( path );   
  1905             //iSoftNotification->SetImageL( *image );
  1373             //iSoftNotification->SetImageL( *image );
  1906             //CleanupStack::PopAndDestroy( image );
  1374             //CleanupStack::PopAndDestroy( image );
  1907             }
  1375             }
  1908         }
  1376         }
  1909     
  1377     */
  1910     // loc: set image path
  1378     // loc: set image path
  1911     // iSoftNotification->SetImagePathL( KIcon );
  1379     // iSoftNotification->SetImagePathL( KIcon );
  1912   
  1380   
  1913     // Set texts
  1381     // Set texts
  1914     // loc: iSoftNotification->SetTextL( titleText->Des(), secondText->Des() );
  1382     // loc: iSoftNotification->SetTextL( titleText->Des(), secondText->Des() );
  1920     
  1388     
  1921     // Set number of updates
  1389     // Set number of updates
  1922     iSoftNotification->SetNrOfUpdates( aNrOfUpdates );
  1390     iSoftNotification->SetNrOfUpdates( aNrOfUpdates );
  1923    
  1391    
  1924     iSoftNotification->ShowNotificationL();
  1392     iSoftNotification->ShowNotificationL();
  1925     FLOG("[bgchecker] LaunchSoftNotificationL 1");
  1393     FLOG("[bgchecker] LaunchNotificationL 1");
  1926     // CleanupStack::PopAndDestroy( 3 ); //text, sk1, sk2
       
  1927     
  1394     
  1928     return;
  1395     return;
  1929     }
  1396     }
  1930 // ----------------------------------------------------------
       
  1931 // CIAUpdateBGTimer::LaunchSoftNotificationL()
       
  1932 // ----------------------------------------------------------
       
  1933 /* HLa
       
  1934 void CIAUpdateBGTimer::LaunchSoftNotificationL( const TInt& aResourceId, const TInt& SK1, const TInt& SK2 )
       
  1935     {     
       
  1936     iInternalFile->ReadControllerDataL(); 
       
  1937     TInt snid = iInternalFile->SoftNotificationID();
       
  1938     if ( snid ) 
       
  1939         {
       
  1940         //there is a soft notification buffered, remove it
       
  1941         iSoftNotification->RemoveSoftNotificationL( snid );
       
  1942         }
       
  1943     
       
  1944     FLOG("[bgchecker] LaunchSoftNotificationL ");
       
  1945     HBufC* text = ReadResourceLC( aResourceId );    
       
  1946     HBufC* sk1 = ReadResourceLC( SK1 );    
       
  1947     HBufC* sk2 = ReadResourceLC( SK2 );  
       
  1948     
       
  1949         
       
  1950     iMode = ModeL();
       
  1951     
       
  1952     if ( iMode == ENormalMode )
       
  1953         {
       
  1954         TFileName path;
       
  1955         TInt err = GetPrivatePathL( path ); 
       
  1956         
       
  1957         if ( err == KErrNone )
       
  1958             {
       
  1959             HBufC8* image = LoadFileLC( path );   
       
  1960             iSoftNotification->SetImageL( *image );
       
  1961             //iSoftNotification->SetImagePathL( *image );
       
  1962             CleanupStack::PopAndDestroy( image );
       
  1963             }
       
  1964         }
       
  1965   
       
  1966     
       
  1967     iSoftNotification->SetTextL( *text, *text );
       
  1968    
       
  1969     iSoftNotification->ShowSoftNotificationL();
       
  1970     FLOG("[bgchecker] LaunchSoftNotificationL 1");
       
  1971     CleanupStack::PopAndDestroy( 3 ); //text, sk1, sk2
       
  1972     }
       
  1973 */
       
  1974 
       
  1975 
       
  1976 // ----------------------------------------------------------
       
  1977 // CIAUpdateBGTimer::GetPrivatePathL()
       
  1978 // ----------------------------------------------------------
       
  1979 TInt CIAUpdateBGTimer::GetPrivatePathL( TFileName& aPath )
       
  1980     {
       
  1981     RFs fsSession;  
       
  1982     User::LeaveIfError( fsSession.Connect() );
       
  1983     CleanupClosePushL( fsSession );
       
  1984 
       
  1985     // This will set the correct drive and private path 
       
  1986     // for the file server session. 
       
  1987     TInt err = KErrNone;
       
  1988     TRAP( err, SetPrivateDriveL( fsSession, KImageFile ) );
       
  1989     
       
  1990     if ( err != KErrNone )
       
  1991         {
       
  1992         CleanupStack::PopAndDestroy( &fsSession ); 
       
  1993         return err;
       
  1994         }
       
  1995    
       
  1996     err = fsSession.SessionPath( aPath );
       
  1997     aPath.Append( KImageFile );
       
  1998     
       
  1999     CleanupStack::PopAndDestroy( &fsSession ); 
       
  2000     return err;
       
  2001     }
       
  2002 
       
  2003 /*
       
  2004 // ----------------------------------------------------------
       
  2005 // CIAUpdateBGTimer::LoadFileLC()
       
  2006 // ----------------------------------------------------------
       
  2007  HBufC8* CIAUpdateBGTimer::LoadFileLC(const TDesC& aFile)
       
  2008      {
       
  2009      RFs fs;
       
  2010     User::LeaveIfError( fs.Connect() );
       
  2011     CleanupClosePushL( fs );
       
  2012     RFile file;
       
  2013     User::LeaveIfError(file.Open(fs, aFile, EFileRead));
       
  2014     CleanupClosePushL(file);
       
  2015     TInt size;
       
  2016     User::LeaveIfError(file.Size(size));
       
  2017     HBufC8* imagebuf = HBufC8::NewL(size);
       
  2018     TPtr8 imageptr(imagebuf->Des());
       
  2019     file.Read(imageptr);
       
  2020     CleanupStack::PopAndDestroy( &file ); 
       
  2021     CleanupStack::PopAndDestroy( &fs ); 
       
  2022     CleanupDeletePushL(imagebuf);
       
  2023     return imagebuf;
       
  2024      } 
       
  2025 */
       
  2026  
       
  2027  // ----------------------------------------------------------
       
  2028  // CIAUpdateBGTimer::SetPrivateDriveL()
       
  2029  // ----------------------------------------------------------
       
  2030  void CIAUpdateBGTimer::SetPrivateDriveL( 
       
  2031      RFs& aFs,
       
  2032      const TDesC& aFileName ) const
       
  2033      {
       
  2034      // First try to find the file from the private directory
       
  2035      // of the drive where the process exists.
       
  2036      RProcess process;
       
  2037 
       
  2038      // Set the session private path according to 
       
  2039      // the process file name drive.
       
  2040      TInt driveNum( 
       
  2041          SetSessionPrivatePathL( aFs, process.FileName() ) );
       
  2042 
       
  2043      // Get the session path that was set above.
       
  2044      TFileName sessionPath;
       
  2045      User::LeaveIfError( aFs.SessionPath( sessionPath ) );
       
  2046 
       
  2047      // Use the file finder to check if the file actually exists 
       
  2048      // in the given drive path. If it does not, the file finder 
       
  2049      // will automatically check from other drives. So, here we 
       
  2050      // should always find the file if any exists.
       
  2051      TFindFile finder( aFs );
       
  2052      User::LeaveIfError( finder.FindByDir( aFileName, sessionPath ) );
       
  2053 
       
  2054      // The drive may have changed if the file was not found from
       
  2055      // the first suggested drive. So, be sure to have the correct
       
  2056      // private path.
       
  2057      driveNum = SetSessionPrivatePathL( aFs, finder.File() );
       
  2058 
       
  2059      // Use the drive info to check if the drive is ROM drive.
       
  2060      // We prefer non ROM drives. But, accept ROM if nothing else is
       
  2061      // available.
       
  2062      TDriveInfo info;
       
  2063      User::LeaveIfError( aFs.Drive( info, driveNum ) );
       
  2064      TBool isRomDrive( info.iDriveAtt & KDriveAttRom );
       
  2065      if ( !isRomDrive )
       
  2066          {
       
  2067          // The current file is not in ROM drive so use that.
       
  2068          return;
       
  2069          }
       
  2070 
       
  2071      // Because previous finding was ROM file, try to find a non ROM file.
       
  2072      TInt findErrorCode( finder.Find() );
       
  2073      if ( findErrorCode == KErrNotFound )
       
  2074          {
       
  2075          // Because no new file is found, use the current settings.
       
  2076          return;
       
  2077          }
       
  2078      User::LeaveIfError( findErrorCode );
       
  2079 
       
  2080      // Update the session path for the correct file.
       
  2081      SetSessionPrivatePathL( aFs, finder.File() );
       
  2082      }
       
  2083 
       
  2084 
       
  2085  // ----------------------------------------------------------
       
  2086  // CIAUpdateBGTimer::SetSessionPrivatePathL()
       
  2087  // ----------------------------------------------------------
       
  2088  TInt CIAUpdateBGTimer::SetSessionPrivatePathL( 
       
  2089      RFs& aFs,
       
  2090      const TDesC& aPath ) const
       
  2091      {                      
       
  2092      // Use the parser to get the drive information from the path.
       
  2093      TParsePtrC parser( aPath );
       
  2094 
       
  2095      if ( !parser.DrivePresent() )
       
  2096          {
       
  2097          User::Leave( KErrArgument );
       
  2098          }
       
  2099 
       
  2100      // Drive check was passed above.
       
  2101      // So, drive information is safe to use.
       
  2102      const TDesC& drive( parser.Drive() );
       
  2103      const TChar driveChar( drive[ 0 ] );
       
  2104      TInt driveNum( EDriveA );
       
  2105      User::LeaveIfError( 
       
  2106          RFs::CharToDrive( driveChar, driveNum ) );
       
  2107 
       
  2108      // Set the file drive to be file session private path drive.
       
  2109      User::LeaveIfError( aFs.SetSessionToPrivate( driveNum ) );
       
  2110 
       
  2111      return driveNum;
       
  2112      }
       
  2113 
       
  2114  
       
  2115 // ----------------------------------------------------------
       
  2116 // CIAUpdateBGTimer::ReadResourceLC()
       
  2117 // ----------------------------------------------------------
       
  2118  /* HLa
       
  2119 HBufC* CIAUpdateBGTimer::ReadResourceLC( TInt aResourceId )
       
  2120     {
       
  2121     TResourceReader reader;
       
  2122     HBufC8* buff = iResourceFile.AllocReadLC( aResourceId );
       
  2123     reader.SetBuffer( buff );
       
  2124     HBufC* text = reader.ReadHBufCL();
       
  2125     CleanupStack::PopAndDestroy( buff );
       
  2126     CleanupStack::PushL( text );
       
  2127     return text;
       
  2128     } */
       
  2129 
       
  2130 
  1397 
  2131 // ----------------------------------------------------------
  1398 // ----------------------------------------------------------
  2132 // CIAUpdateBGTimer::IsAutoUpdateDisabledL()
  1399 // CIAUpdateBGTimer::IsAutoUpdateDisabledL()
  2133 // ----------------------------------------------------------
  1400 // ----------------------------------------------------------
  2134 TBool CIAUpdateBGTimer::IsAutoUpdateDisabledL()
  1401 TBool CIAUpdateBGTimer::IsAutoUpdateDisabledL()
  2253     FLOG("[bgchecker] Shutdown() begin");
  1520     FLOG("[bgchecker] Shutdown() begin");
  2254     Cancel();
  1521     Cancel();
  2255     delete iUpdate; 
  1522     delete iUpdate; 
  2256     iUpdate = NULL;
  1523     iUpdate = NULL;
  2257     
  1524     
  2258     delete iReminderTimer;
  1525     //delete iReminderTimer;
  2259     iReminderTimer = NULL;
  1526     //iReminderTimer = NULL;
  2260     
  1527     
  2261     if ( iNotifyHandler ) 
  1528     if ( iNotifyHandler ) 
  2262         {
  1529         {
  2263         iNotifyHandler->StopListening();
  1530         iNotifyHandler->StopListening();
  2264         delete iNotifyHandler;
  1531         delete iNotifyHandler;
  2265         iNotifyHandler = NULL;
  1532         iNotifyHandler = NULL;
  2266         }
  1533         }
  2267     
  1534     
  2268     if ( iSoftNotification )
  1535     if ( iSoftNotification )
  2269         {
  1536         {
  2270         // TRAP_IGNORE( iSoftNotification->RemoveSoftNotificationL( iSoftNotification->Id() ) );    
       
  2271         delete iSoftNotification;
  1537         delete iSoftNotification;
  2272         iSoftNotification = NULL;
  1538         iSoftNotification = NULL;
  2273         }
  1539         }
  2274     
  1540     
  2275     CActiveScheduler::Stop();
  1541     CActiveScheduler::Stop();
  2276         
  1542         
  2277     FLOG("[bgchecker] Shutdown() end");
  1543     FLOG("[bgchecker] Shutdown() end");
  2278     }
  1544     }
  2279 
       
  2280 
       
  2281 
       
  2282 // End of file
  1545 // End of file
  2283 
       
  2284