iaupdate/IAD/backgroundchecker/src/iaupdatebgrefreshtimer.cpp
changeset 29 26b6f0522fd8
parent 6 aba6b8104af3
child 33 8110bf1194d1
equal deleted inserted replaced
25:98b66e4fb0be 29:26b6f0522fd8
     1 /*
     1 /*
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    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>
    28 #include <data_caging_path_literals.hrh>
    32 #include <bautils.h>
    29 #include <bautils.h>
    33 #include <apgtask.h>
    30 #include <apgtask.h>
    34 #include <sysversioninfo.h>  //sysversioninfo
    31 #include <sysversioninfo.h>  //sysversioninfo
    35 #include <featurecontrol.h>
    32 #include <featurecontrol.h>
    43 #include "iaupdatebginternalfilehandler.h"
    40 #include "iaupdatebginternalfilehandler.h"
    44 #include "iaupdatebgconst.h"
    41 #include "iaupdatebgconst.h"
    45 
    42 
    46 //MACROS
    43 //MACROS
    47 _LIT8( KRefreshFromNetworkDenied, "1" );
    44 _LIT8( KRefreshFromNetworkDenied, "1" );
    48 _LIT(KIAUpdateResourceFile, "iaupdate.rsc");
    45 // _LIT(KIAUpdateResourceFile, "iaupdate.rsc");
    49 _LIT(KIAUpdateLauncherExe, "iaupdatelauncher.exe" );
    46 _LIT(KIAUpdateLauncherExe, "iaupdatelauncher.exe" );
    50 _LIT(KImageFile, "qgn_note_swupdate_notification.svg");
    47 _LIT(KImageFile, "qgn_note_swupdate_notification.svg");
       
    48 _LIT8( KFirstTimeCase, "0" );
    51 
    49 
    52 //CONSTANTS
    50 //CONSTANTS
    53 const TUint KIADUpdateLauncherUid( 0x2001FE2F );
    51 const TUint KIADUpdateLauncherUid( 0x2001FE2F );
    54 
    52 
    55 // ----------------------------------------------------------
    53 // ----------------------------------------------------------
    82 
    80 
    83     iControllerFile = CIAUpdateBGControllerFile::NewL();
    81     iControllerFile = CIAUpdateBGControllerFile::NewL();
    84     
    82     
    85     iInternalFile = CIAUpdateBGInternalFileHandler::NewL();
    83     iInternalFile = CIAUpdateBGInternalFileHandler::NewL();
    86     
    84     
    87     iSoftNotification = CIAUpdateBGSoftNotification::NewL( this, iInternalFile );
    85     iSoftNotification = CIAUpdateBGSoftNotification::NewL( this ); //, iInternalFile );
    88     iSoftNotification->StartObservingIfNeededL();
    86     // HLa: iSoftNotification->StartObservingIfNeededL();
    89     
    87     
    90     // Get resource file path
    88     // Get resource file path
       
    89     /* HLa
    91     TFileName fileName;
    90     TFileName fileName;
    92     fileName.Copy(TParsePtrC(RProcess().FileName()).Drive());
    91     fileName.Copy(TParsePtrC(RProcess().FileName()).Drive());
    93     fileName.Append(KDC_APP_RESOURCE_DIR);
    92     fileName.Append(KDC_APP_RESOURCE_DIR);
    94     fileName.Append(KIAUpdateResourceFile);
    93     fileName.Append(KIAUpdateResourceFile);
    95 
    94     */
       
    95     
    96     User::LeaveIfError(iFs.Connect());
    96     User::LeaveIfError(iFs.Connect());
    97 
    97 
    98     // Get language of resource file        
    98     // Get language of resource file        
    99     BaflUtils::NearestLanguageFile( iFs, fileName );
    99     //BaflUtils::NearestLanguageFile( iFs, fileName );
   100 
   100 
   101     // Open resource file
   101     // Open resource file
   102     iResourceFile.OpenL( iFs, fileName );
   102     //iResourceFile.OpenL( iFs, fileName );
   103     iResourceFile.ConfirmSignatureL();    
   103     //iResourceFile.ConfirmSignatureL();    
   104     }
   104     }
   105     
   105     
   106     
   106     
   107 // ----------------------------------------------------------
   107 // ----------------------------------------------------------
   108 // CIAUpdateBGTimer::~CIAUpdateBGTimer()
   108 // CIAUpdateBGTimer::~CIAUpdateBGTimer()
   123     delete iIAUpdateCRSession; 
   123     delete iIAUpdateCRSession; 
   124     delete iControllerFile;
   124     delete iControllerFile;
   125     delete iInternalFile;
   125     delete iInternalFile;
   126     delete iSoftNotification;
   126     delete iSoftNotification;
   127     
   127     
   128     iResourceFile.Close();
   128     // iResourceFile.Close();
   129     iFs.Close();
   129     iFs.Close();
   130     }
   130     }
   131 
   131 
   132 
   132 
   133 // ----------------------------------------------------------
   133 // ----------------------------------------------------------
   137     {
   137     {
   138     FLOG("[bgchecker] StartProcessL");
   138     FLOG("[bgchecker] StartProcessL");
   139         
   139         
   140     iMode = ModeL();
   140     iMode = ModeL();
   141     
   141     
       
   142     //HLa
       
   143     TBool test1 = IsAgreementAcceptedL();
       
   144     TBool test2 = ReminderOnL();
       
   145     
       
   146     int test = 0;
   142     switch ( iMode )
   147     switch ( iMode )
   143         {
   148         {
   144         case EFirstTimeMode:
   149         case EFirstTimeMode:
   145         case EFirstTimeRemindMode:    
   150          
       
   151         // while not released keep in sleep mode
       
   152         //int test = 1;
       
   153         if ( test == 0 )
       
   154             {
       
   155             ListenAutoUpdateSettingsL();
       
   156             iMode = ESleepMode;
       
   157             SetModeL( iMode );
       
   158             return;
       
   159             }
       
   160         
       
   161         //case EFirstTimeRemindMode:    
   146             {
   162             {
   147             if ( IsFirstTimeDialogDisabledL() )
   163             if ( IsFirstTimeDialogDisabledL() )
   148                 {
   164                 {
   149                 //this should only happen in testing
   165                 //this should only happen in testing
   150                 FLOG("[bgchecker] StartProcessL Firs time dialog is disabled, this should only happen in testing");
   166                 FLOG("[bgchecker] StartProcessL Firs time dialog is disabled, this should only happen in testing");
   215                 }    
   231                 }    
   216                                 
   232                                 
   217                                                   
   233                                                   
   218             break;
   234             break;
   219             }
   235             }
   220 
   236 /*
   221         case EFirstTimeMode2:
   237         case EFirstTimeMode2:
   222             {
   238             {
   223             FLOG("[bgchecker] StartProcessL EFirstTimeMode2");
   239             FLOG("[bgchecker] StartProcessL EFirstTimeMode2");
   224             RunL();
   240             RunL();
   225             break;
   241             break;
   226             }
   242             }
   227 
   243 */
   228         case EFirstTimeMode3:
   244         case EFirstTimeMode2:
   229             {
   245             {
   230             FLOG("[bgchecker] StartProcessL EFirstTimeMode 3");
   246             FLOG("[bgchecker] StartProcessL EFirstTimeMode 3");
   231             //if user accepted the disclaimer already and reboot the phone, 
   247             //if user accepted the disclaimer already and reboot the phone, 
   232             //this mode could go to network immediately after boot
   248             //this mode could go to network immediately after boot
   233             //We put one min delay here to wait for network ready.
   249             //We put one min delay here to wait for network ready.
   248                 {
   264                 {
   249                 iNotifyHandler = CCenRepNotifyHandler::NewL( *this, *iIAUpdateCRSession ); 
   265                 iNotifyHandler = CCenRepNotifyHandler::NewL( *this, *iIAUpdateCRSession ); 
   250                 }
   266                 }
   251                     
   267                     
   252             iNotifyHandler->StartListeningL();  
   268             iNotifyHandler->StartListeningL();  
       
   269             
       
   270 
       
   271             if ( !IsAgreementAcceptedL() )
       
   272                 {
       
   273                 FLOG("[bgchecker] EFirstTimeMode4 ShowIndicator");
       
   274                 // Set number of updates; zero for first case
       
   275                 iSoftNotification->SetNrOfUpdates( 0 );
       
   276                 
       
   277                 // do not show indicator when testing
       
   278                 int test = 0;
       
   279                 if ( test == 1)
       
   280                   iSoftNotification->ShowIndicatorL();
       
   281                 
       
   282                 }
       
   283             
       
   284             
   253             break;
   285             break;
   254             }
   286             }
   255 
   287 
   256         case ENormalMode:
   288         case ENormalMode:
   257         case ERetryMode:
   289         case ERetryMode:
   332             StartL( timetowait );
   364             StartL( timetowait );
   333             
   365             
   334             //start reminder timer also if user choose later before reboot
   366             //start reminder timer also if user choose later before reboot
   335             //check the value from private folder
   367             //check the value from private folder
   336              
   368              
       
   369             
   337               if ( ReminderOnL() )
   370               if ( ReminderOnL() )
   338                   {
   371                   {
   339                   TTime currenttime;
   372                   TTime currenttime;
   340                   currenttime.UniversalTime();
   373                   currenttime.UniversalTime();
   341                   
   374                   
   358                   else
   391                   else
   359                       {
   392                       {
   360                       iReminderTimer->StartReminderTimerL( timetogo );
   393                       iReminderTimer->StartReminderTimerL( timetogo );
   361                       }
   394                       }
   362                   }
   395                   }
       
   396                   
   363             }
   397             }
   364     }
   398     }
   365 
   399 
   366 
   400 
   367 // ----------------------------------------------------------
   401 // ----------------------------------------------------------
   586     {   
   620     {   
   587     FLOG( "DoUpdatesCheckingL update");
   621     FLOG( "DoUpdatesCheckingL update");
   588     //turn off the reminder, user will decide whether to turn if on or off
   622     //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
   623     //The user's decision will be checked in soft notification callback function
   590     
   624     
       
   625     
   591     if ( ReminderOnL())
   626     if ( ReminderOnL())
   592         {
   627         {
   593         FLOG( "Do CheckUpdates 3");
   628         FLOG( "Do CheckUpdates 3");
   594         iReminderTimer->CancelReminderTimerL();
   629         iReminderTimer->CancelReminderTimerL();
   595         SetReminderL( EFalse );
   630         SetReminderL( EFalse );
   596         }
   631         }
       
   632     
   597     
   633     
   598     if( !iUpdate )
   634     if( !iUpdate )
   599         {
   635         {
   600         iUpdate = CIAUpdate::NewL( *this );
   636         iUpdate = CIAUpdate::NewL( *this );
   601         }
   637         }
   642 // ----------------------------------------------------------
   678 // ----------------------------------------------------------
   643 void CIAUpdateBGTimer::DoCheckUpdatesCompleteL( TInt aErrorCode, TInt aAvailableUpdates )
   679 void CIAUpdateBGTimer::DoCheckUpdatesCompleteL( TInt aErrorCode, TInt aAvailableUpdates )
   644     {
   680     {
   645     FLOG_NUM( "CheckUpdatesComplete aErrorCode = %d", aErrorCode );
   681     FLOG_NUM( "CheckUpdatesComplete aErrorCode = %d", aErrorCode );
   646     FLOG_NUM( "CheckUpdatesComplete aAvailableUpdates = %d", aAvailableUpdates );
   682     FLOG_NUM( "CheckUpdatesComplete aAvailableUpdates = %d", aAvailableUpdates );
       
   683     
       
   684     //HLa
       
   685     int test = 0;
       
   686     if ( test == 0 )
       
   687         {
       
   688         aErrorCode = 0;
       
   689         aAvailableUpdates = 0;
       
   690         }
       
   691     
   647     if ( !IAUpdateEnabledL() )
   692     if ( !IAUpdateEnabledL() )
   648         {
   693         {
   649         Shutdown();
   694         Shutdown();
   650         return;
   695         return;
   651         }
   696         }
   686         
   731         
   687         if ( aAvailableUpdates > 0 )
   732         if ( aAvailableUpdates > 0 )
   688             {             
   733             {             
   689             FLOG( "CheckUpdatesComplete 4");
   734             FLOG( "CheckUpdatesComplete 4");
   690     
   735     
   691             LaunchSoftNotificationL(R_IAUPDATE_UPDATE_AVAILABLE,
   736             LaunchNotificationL( aAvailableUpdates );
   692                         R_TEXT_SOFTKEY_SHOW, R_TEXT_SOFTKEY_LATER );
   737             //LaunchSoftNotificationL(R_IAUPDATE_UPDATE_AVAILABLE,
       
   738             //            R_TEXT_SOFTKEY_SHOW, R_TEXT_SOFTKEY_LATER );
   693             }
   739             }
   694 
   740 
   695             FLOG( "CheckUpdatesComplete 5");
   741             FLOG( "CheckUpdatesComplete 5");
   696         
   742         
   697         // if update checking is from server, restart the refresh timer 
   743         // if update checking is from server, restart the refresh timer 
   818 CIAUpdateBGTimer::CIAUpdateBGTimer():CTimer( EPriorityStandard )
   864 CIAUpdateBGTimer::CIAUpdateBGTimer():CTimer( EPriorityStandard )
   819     {
   865     {
   820     }
   866     }
   821 
   867 
   822 
   868 
       
   869 // ----------------------------------------------------------
       
   870 // CIAUpdateBGTimer::RunL()
       
   871 // ----------------------------------------------------------
       
   872 void CIAUpdateBGTimer::RunL()
       
   873     {
       
   874     FLOG("[bgchecker]RunL() ");
       
   875     if ( !IAUpdateEnabledL() )
       
   876         {
       
   877         Shutdown();
       
   878         return;
       
   879         }
       
   880     User::LeaveIfError( iStatus.Int() );
       
   881     //Check the mode again, in case the mode is changed while waiting.
       
   882     iMode = ModeL();
       
   883     
       
   884     switch ( iMode )
       
   885         {
       
   886         case ENormalMode:
       
   887         case ERetryMode:
       
   888             {     
       
   889             FLOG("[bgchecker]RunL() ENormalMode");                                    
       
   890             //roaming case is checked in IAUpdate server side
       
   891             if ( IsAutoUpdateDisabledL() )
       
   892                 {
       
   893                 ListenAutoUpdateSettingsL();
       
   894                 
       
   895                 iMode = ESleepMode;
       
   896                 SetModeL( iMode );
       
   897                 
       
   898                 //the program is waked up when automatic checking is changed by user.
       
   899                 //cenrep call back will be used.
       
   900                 return;
       
   901                 }                        
       
   902             
       
   903             FLOG("[bgchecker]RunL() ENormalMode 1");
       
   904             
       
   905             if(iRuns == 0)
       
   906                 {
       
   907                 FLOG("[bgchecker]RunL() ENormalMode 2");
       
   908                 // if user did the refresh from server while waiting, restart the timer.
       
   909                 // the last refresh time is read from the private file of IAUpdate server.
       
   910                 TTimeIntervalMinutes timetowait =
       
   911                         TimeIntervalFromNextRefreshL();
       
   912 
       
   913                 if (timetowait.Int() <= 0 )
       
   914                     {
       
   915                     DoUpdatesCheckingL( ETrue );
       
   916                     }
       
   917                 else
       
   918                     {
       
   919                     StartL( timetowait );
       
   920                     }
       
   921                 FLOG("[bgchecker]RunL() ENormalMode 3");
       
   922                 }
       
   923             else
       
   924                 {
       
   925                 FLOG("[bgchecker]RunL() ENormalMode 4");
       
   926                 TTimeIntervalMinutes timetowait = TimeIntervalFromNextRefreshL();
       
   927                    
       
   928                    if ( timetowait.Int() <= 0 )
       
   929                        {
       
   930                        StartL( StartNow );
       
   931                        }
       
   932                    else
       
   933                        {
       
   934                        StartL( timetowait );
       
   935                        }
       
   936                    FLOG("[bgchecker]RunL() ENormalMode 5");
       
   937                  }        
       
   938             }
       
   939             break;
       
   940             
       
   941         case EFirstTimeMode:
       
   942         //case EFirstTimeRemindMode:
       
   943             {
       
   944             FLOG("[bgchecker] runl EFirstTimeMode");
       
   945             
       
   946             if ( iRuns == 0 )
       
   947                 {
       
   948                 FLOG("[bgchecker] runl run = 0");
       
   949                 HandlerFirstTimeL();
       
   950                 }
       
   951             else
       
   952                 {
       
   953                 FLOG("[bgchecker] runl still wait");
       
   954                 TTimeIntervalMinutes timetowait = TimeIntervalFromNextShowOfNewFeatureDialogL();
       
   955                                    
       
   956                 if ( timetowait.Int() <= 0 )
       
   957                     {
       
   958                     StartL( StartNow );
       
   959                     }
       
   960                  else
       
   961                     {
       
   962                     StartL( timetowait );
       
   963                     } 
       
   964                 }
       
   965             }
       
   966             break;
       
   967         /*
       
   968         case EFirstTimeMode2:
       
   969             {
       
   970             FLOG("[bgchecker] runl EFirstTimeMode2");
       
   971             LaunchNotificationL( 1 );
       
   972             //LaunchSoftNotificationL(R_IAUPDATE_REMIND_LATER, R_TEXT_SOFTKEY_YES, R_TEXT_SOFTKEY_NO );
       
   973             }
       
   974             break;
       
   975         */
       
   976         case EFirstTimeMode2:
       
   977             {
       
   978             FLOG("[bgchecker] runl EFirstTimeMode3");                 
       
   979             //disclaimer is not accepted  
       
   980            
       
   981             if ( !IsAgreementAcceptedL()  )
       
   982                 {
       
   983                 FLOG("[bgchecker] runl EFirstTimeMode reject disclaimer");
       
   984                 //user accepte the new feature dialog but user reject sthe disclaimer
       
   985                 //in sleep mode now
       
   986                 iMode = ESleepMode;
       
   987                 SetModeL( iMode );
       
   988                 //subscribe to cenrep key for automatic checking for wake up from sleep mode
       
   989                 ListenAutoUpdateSettingsL(); 
       
   990                 }
       
   991             else
       
   992                 {
       
   993                 FLOG("[bgchecker] runl EFirstTimeMode go to normal mode");
       
   994                 //Set to Normal mode
       
   995                 //check autochecksetting in Runl later
       
   996                 iMode = ENormalMode;
       
   997                 SetModeL( iMode );
       
   998                 StartL( StartNow );
       
   999                 }
       
  1000             }
       
  1001             break;
       
  1002             
       
  1003         default:
       
  1004             break;
       
  1005         };
       
  1006        
       
  1007     }
       
  1008 
       
  1009 /*
   823 // ----------------------------------------------------------
  1010 // ----------------------------------------------------------
   824 // CIAUpdateBGTimer::RunL()
  1011 // CIAUpdateBGTimer::RunL()
   825 // ----------------------------------------------------------
  1012 // ----------------------------------------------------------
   826 void CIAUpdateBGTimer::RunL()
  1013 void CIAUpdateBGTimer::RunL()
   827     {
  1014     {
   920             break;
  1107             break;
   921 
  1108 
   922         case EFirstTimeMode2:
  1109         case EFirstTimeMode2:
   923             {
  1110             {
   924             FLOG("[bgchecker] runl EFirstTimeMode2");
  1111             FLOG("[bgchecker] runl EFirstTimeMode2");
   925             LaunchSoftNotificationL(R_IAUPDATE_REMIND_LATER, R_TEXT_SOFTKEY_YES, R_TEXT_SOFTKEY_NO );
  1112             LaunchNotificationL( 1 );
       
  1113             //LaunchSoftNotificationL(R_IAUPDATE_REMIND_LATER, R_TEXT_SOFTKEY_YES, R_TEXT_SOFTKEY_NO );
   926             }
  1114             }
   927             break;
  1115             break;
   928 
  1116 
   929         case EFirstTimeMode3:
  1117         case EFirstTimeMode3:
   930             {
  1118             {
   955             
  1143             
   956         default:
  1144         default:
   957             break;
  1145             break;
   958         };
  1146         };
   959        
  1147        
   960     }
  1148     }*/
   961 
       
   962 
  1149 
   963 // ----------------------------------------------------------
  1150 // ----------------------------------------------------------
   964 // CIAUpdateBGTimer::HandlerFirstTimeL()
  1151 // CIAUpdateBGTimer::HandlerFirstTimeL()
   965 // ----------------------------------------------------------
  1152 // ----------------------------------------------------------
   966 void CIAUpdateBGTimer::HandlerFirstTimeL()
  1153 void CIAUpdateBGTimer::HandlerFirstTimeL()
   982         }
  1169         }
   983     else
  1170     else
   984         {
  1171         {
   985         //this is first time mode
  1172         //this is first time mode
   986         FLOG("[bgchecker]HandlerFirstTimeL 3 ");
  1173         FLOG("[bgchecker]HandlerFirstTimeL 3 ");
   987         LaunchSoftNotificationL( R_IAUPDATE_FEATURES_AVAILABLE,
  1174         LaunchNotificationL( 0 );
   988                     R_TEXT_SOFTKEY_OK, R_TEXT_SOFTKEY_CANCEL );
  1175         // LaunchSoftNotificationL( R_IAUPDATE_FEATURES_AVAILABLE,
       
  1176         //            R_TEXT_SOFTKEY_OK, R_TEXT_SOFTKEY_CANCEL );
   989         }
  1177         }
   990     }
  1178     }
   991 
  1179 
   992 
  1180 
   993 // ----------------------------------------------------------
  1181 // ----------------------------------------------------------
  1250     if ( ModeL() == EFirstTimeMode )
  1438     if ( ModeL() == EFirstTimeMode )
  1251         {
  1439         {
  1252         FLOG(" current mode is FirstTimeMode ");
  1440         FLOG(" current mode is FirstTimeMode ");
  1253         interval = FirstTimeDialogDelayInMinutesL();
  1441         interval = FirstTimeDialogDelayInMinutesL();
  1254         }
  1442         }
       
  1443     /*
  1255     else if ( ModeL() == EFirstTimeRemindMode )
  1444     else if ( ModeL() == EFirstTimeRemindMode )
  1256         {
  1445         {
  1257         FLOG(" current mode is FirstTimeRemindMode");
  1446         FLOG(" current mode is FirstTimeRemindMode");
  1258         interval = FirstTimeDialogReminderIntervalInMinutesL();
  1447         interval = FirstTimeDialogReminderIntervalInMinutesL();
  1259         }
  1448         }*/
  1260     else
  1449     else
  1261         {
  1450         {
  1262         //nothing
  1451         //nothing
  1263         FLOG(" current mode is wrong!!");
  1452         FLOG(" current mode is wrong!!");
  1264         User::LeaveIfError( KErrArgument );
  1453         User::LeaveIfError( KErrArgument );
  1272     FLOG("[bgchecker] TimeIntervalFromNextShowOfNewFeatureDialogL 6");
  1461     FLOG("[bgchecker] TimeIntervalFromNextShowOfNewFeatureDialogL 6");
  1273     return timetowait;
  1462     return timetowait;
  1274     }
  1463     }
  1275 
  1464 
  1276 
  1465 
       
  1466 // ----------------------------------------------------------
       
  1467 // CIAUpdateBGTimer::DoSoftNotificationCallBackL()
       
  1468 // ----------------------------------------------------------
       
  1469 void CIAUpdateBGTimer::DoSoftNotificationCallBackL( TBool aIsAccepted )
       
  1470     {
       
  1471     FLOG("[bgchecker] SoftNotificationCallBack");
       
  1472     if ( !IAUpdateEnabledL() )
       
  1473         {
       
  1474         Shutdown();
       
  1475         return;
       
  1476         }
       
  1477     iMode = ModeL(); 
       
  1478     
       
  1479       switch ( iMode )
       
  1480           {
       
  1481           case EFirstTimeMode:
       
  1482           // case EFirstTimeRemindMode:     
       
  1483                  {
       
  1484                  
       
  1485                  FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode");
       
  1486                  if ( !aIsAccepted )
       
  1487                      {
       
  1488                      FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode, not accepted");
       
  1489                      //in sleep mode now
       
  1490                      iMode = ESleepMode;
       
  1491                      SetModeL( iMode );
       
  1492                      
       
  1493                      //subscribe to cenrep key for automatic checking for wake up from sleep mode
       
  1494                      ListenAutoUpdateSettingsL();
       
  1495                      
       
  1496                      /*
       
  1497                      FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode not accepted");
       
  1498                      iMode = EFirstTimeMode2;
       
  1499                      SetModeL( iMode );
       
  1500                      StartL( StartNow );
       
  1501                      */
       
  1502                      }
       
  1503                  else
       
  1504                      {
       
  1505                      FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMod accepeted");
       
  1506                      StartIaupdateL();
       
  1507                      //iaupdate is launched
       
  1508                      //check the disclaimer acceptance and automatic checking setting in 10mins
       
  1509 
       
  1510                      StartL( KDelayForUserToAcceptDisclaimer );
       
  1511                      iMode = EFirstTimeMode2;     
       
  1512                      SetModeL( iMode );
       
  1513 
       
  1514                      
       
  1515                      //Still in first time mode, 
       
  1516                      //check user's setting and disclamier after 10mins.
       
  1517                      }
       
  1518                  break;
       
  1519                  }
       
  1520                  
       
  1521                  
       
  1522           /*       
       
  1523           case EFirstTimeMode2:  // reminder 
       
  1524               {
       
  1525               FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode2 ");
       
  1526               if ( aIsAccepted ) // reminder accepted ?
       
  1527                   {
       
  1528                   FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode2, accepted");
       
  1529                   //user wants to be reminder so remind in 4 weeks
       
  1530                   //set to first time remind mode
       
  1531                   iMode = EFirstTimeRemindMode;
       
  1532                   SetModeL( iMode );
       
  1533                   TTimeIntervalMinutes fourweeks( FirstTimeDialogReminderIntervalInMinutesL() );            
       
  1534                   TTime currenttime;
       
  1535                   currenttime.UniversalTime();
       
  1536                         
       
  1537                   //save the next show new feature dialog time
       
  1538                   //in case use switch off the device and restarted.      
       
  1539                   User::LeaveIfError( SetLastTimeShowNewFeatureDialogL( currenttime ) );
       
  1540                         
       
  1541                   StartL( fourweeks );
       
  1542                   return;
       
  1543                   }
       
  1544               else
       
  1545                   {
       
  1546                   FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode2, not accepted");
       
  1547                   //in sleep mode now
       
  1548                   iMode = ESleepMode;
       
  1549                   SetModeL( iMode );
       
  1550                   
       
  1551                   //subscribe to cenrep key for automatic checking for wake up from sleep mode
       
  1552                   ListenAutoUpdateSettingsL(); 
       
  1553                   }
       
  1554               break;
       
  1555               }
       
  1556           */    
       
  1557           case ENormalMode:
       
  1558               {
       
  1559               FLOG("[bgchecker] SoftNotificationCallBack ENormalMode");
       
  1560               if ( !aIsAccepted )
       
  1561                   {
       
  1562                   FLOG("[bgchecker] SoftNotificationCallBack ENormalMode not accpeted");
       
  1563                   //user wants to be reminded later
       
  1564                   TTimeIntervalMinutes oneweek( UpdateAvailableReminderIntervalInMinutesL() );   
       
  1565                   TTime currenttime;
       
  1566                   currenttime.UniversalTime();
       
  1567                   TTime nextRemindTime = currenttime + oneweek;
       
  1568 
       
  1569                   SetReminderL( ETrue );
       
  1570                   SetNextRemindTimeL( nextRemindTime );
       
  1571                   
       
  1572                   iReminderTimer->StartReminderTimerL( oneweek );
       
  1573                   
       
  1574                   //the reminder call back function will be called when reminder timer expires.
       
  1575                   }
       
  1576               else
       
  1577                   {
       
  1578                   //accepted, launch iad
       
  1579                   StartIaupdateL();
       
  1580                   }
       
  1581               break;
       
  1582               }
       
  1583 
       
  1584           case ESleepMode:
       
  1585               {
       
  1586               FLOG("[bgchecker] SoftNotificationCallBack ESleepMode");
       
  1587               //donothing
       
  1588               break;
       
  1589               }
       
  1590 
       
  1591           default:
       
  1592               break;
       
  1593           }
       
  1594     }
       
  1595 
       
  1596 /*
  1277 // ----------------------------------------------------------
  1597 // ----------------------------------------------------------
  1278 // CIAUpdateBGTimer::DoSoftNotificationCallBackL()
  1598 // CIAUpdateBGTimer::DoSoftNotificationCallBackL()
  1279 // ----------------------------------------------------------
  1599 // ----------------------------------------------------------
  1280 void CIAUpdateBGTimer::DoSoftNotificationCallBackL( TBool aIsAccepted )
  1600 void CIAUpdateBGTimer::DoSoftNotificationCallBackL( TBool aIsAccepted )
  1281     {
  1601     {
  1319                  break;
  1639                  break;
  1320                  }
  1640                  }
  1321                  
  1641                  
  1322                  
  1642                  
  1323                  
  1643                  
  1324           case EFirstTimeMode2:
  1644           case EFirstTimeMode2:  // reminder 
  1325               {
  1645               {
  1326               FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode2 ");
  1646               FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode2 ");
  1327               if ( aIsAccepted )
  1647               if ( aIsAccepted ) // reminder accepted ?
  1328                   {
  1648                   {
  1329                   FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode2, accepted");
  1649                   FLOG("[bgchecker] SoftNotificationCallBack EFirstTimeMode2, accepted");
  1330                   //user wants to be reminder so remind in 4 weeks
  1650                   //user wants to be reminder so remind in 4 weeks
  1331                   //set to first time remind mode
  1651                   //set to first time remind mode
  1332                   iMode = EFirstTimeRemindMode;
  1652                   iMode = EFirstTimeRemindMode;
  1390               }
  1710               }
  1391 
  1711 
  1392           default:
  1712           default:
  1393               break;
  1713               break;
  1394           }
  1714           }
  1395     }
  1715     } */
  1396 
  1716 
  1397 // ----------------------------------------------------------
  1717 // ----------------------------------------------------------
  1398 // CIAUpdateBGTimer::SoftNotificationCallBack()
  1718 // CIAUpdateBGTimer::SoftNotificationCallBack()
  1399 // ----------------------------------------------------------
  1719 // ----------------------------------------------------------
  1400 void CIAUpdateBGTimer::SoftNotificationCallBack( TBool aIsAccepted )
  1720 void CIAUpdateBGTimer::SoftNotificationCallBack( TBool aIsAccepted )
  1408 // ----------------------------------------------------------
  1728 // ----------------------------------------------------------
  1409 TIAUpdateBGMode CIAUpdateBGTimer::CurrentMode()
  1729 TIAUpdateBGMode CIAUpdateBGTimer::CurrentMode()
  1410     {
  1730     {
  1411     return iMode;
  1731     return iMode;
  1412     }
  1732     }
       
  1733 
  1413 
  1734 
  1414 
  1735 
  1415 // ----------------------------------------------------------
  1736 // ----------------------------------------------------------
  1416 // CIAUpdateBGTimer::DoReminderTimerCallBack()
  1737 // CIAUpdateBGTimer::DoReminderTimerCallBack()
  1417 // ----------------------------------------------------------
  1738 // ----------------------------------------------------------
  1459 // ----------------------------------------------------------
  1780 // ----------------------------------------------------------
  1460 void CIAUpdateBGTimer::ReminderTimerCallBack()
  1781 void CIAUpdateBGTimer::ReminderTimerCallBack()
  1461     {
  1782     {
  1462     TRAP_IGNORE( DoReminderTimerCallBackL() );
  1783     TRAP_IGNORE( DoReminderTimerCallBackL() );
  1463     }
  1784     }
  1464 
  1785    
       
  1786 // ----------------------------------------------------------
       
  1787 // CIAUpdateBGTimer::LaunchNotificationL( const int aNrOfUpdates )
       
  1788 // ----------------------------------------------------------
       
  1789 void CIAUpdateBGTimer::LaunchNotificationL( const int aNrOfUpdates )
       
  1790     {
       
  1791     
       
  1792     _LIT( KIcon, "C:\\qgn_note_swupdate_notification.svg" );
       
  1793     _LIT( KFirstTimeText, "Check for updates ?" );
       
  1794     _LIT( KNormalText, "Updates available" );
       
  1795     _LIT( KSecondText, "Tap to view" );
       
  1796     
       
  1797     FLOG("[bgchecker] LaunchNotificationL ");
       
  1798         
       
  1799     iMode = ModeL();
       
  1800     
       
  1801     //text for 1st line
       
  1802      if ( iMode == ENormalMode )
       
  1803          {
       
  1804          
       
  1805          }
       
  1806     
       
  1807     //TBuf<256> iconPath;
       
  1808     TBuf<128> titleText;
       
  1809     TBuf<128> secondText;
       
  1810     
       
  1811     //title text (normal/first time)
       
  1812     if ( iMode == ENormalMode )
       
  1813         {
       
  1814         titleText.Append(KNormalText);
       
  1815         }
       
  1816     else
       
  1817         {
       
  1818         titleText.Append(KFirstTimeText);
       
  1819         }
       
  1820     
       
  1821     //text for 2nd line
       
  1822     secondText.Append(KSecondText);
       
  1823             
       
  1824     // icon
       
  1825     if ( iMode == ENormalMode )
       
  1826         {
       
  1827         TFileName path;
       
  1828         TInt err = GetPrivatePathL( path ); 
       
  1829         
       
  1830         if ( err == KErrNone )
       
  1831             {
       
  1832             iSoftNotification->SetImagePathL( path );
       
  1833             //HBufC8* image = LoadFileLC( path );   
       
  1834             //iSoftNotification->SetImageL( *image );
       
  1835             //CleanupStack::PopAndDestroy( image );
       
  1836             }
       
  1837         }
       
  1838   
       
  1839     // Set texts
       
  1840     iSoftNotification->SetTextL( titleText, secondText );
       
  1841     
       
  1842     // Set number of updates
       
  1843     iSoftNotification->SetNrOfUpdates( aNrOfUpdates );
       
  1844    
       
  1845     iSoftNotification->ShowNotificationL();
       
  1846     FLOG("[bgchecker] LaunchSoftNotificationL 1");
       
  1847     // CleanupStack::PopAndDestroy( 3 ); //text, sk1, sk2
       
  1848     
       
  1849     return;
       
  1850     }
  1465 // ----------------------------------------------------------
  1851 // ----------------------------------------------------------
  1466 // CIAUpdateBGTimer::LaunchSoftNotificationL()
  1852 // CIAUpdateBGTimer::LaunchSoftNotificationL()
  1467 // ----------------------------------------------------------
  1853 // ----------------------------------------------------------
       
  1854 /*
  1468 void CIAUpdateBGTimer::LaunchSoftNotificationL( const TInt& aResourceId, const TInt& SK1, const TInt& SK2 )
  1855 void CIAUpdateBGTimer::LaunchSoftNotificationL( const TInt& aResourceId, const TInt& SK1, const TInt& SK2 )
  1469     {     
  1856     {     
  1470     iInternalFile->ReadControllerDataL(); 
  1857     iInternalFile->ReadControllerDataL(); 
  1471     TInt snid = iInternalFile->SoftNotificationID();
  1858     TInt snid = iInternalFile->SoftNotificationID();
  1472     if ( snid ) 
  1859     if ( snid ) 
  1490         
  1877         
  1491         if ( err == KErrNone )
  1878         if ( err == KErrNone )
  1492             {
  1879             {
  1493             HBufC8* image = LoadFileLC( path );   
  1880             HBufC8* image = LoadFileLC( path );   
  1494             iSoftNotification->SetImageL( *image );
  1881             iSoftNotification->SetImageL( *image );
       
  1882             //iSoftNotification->SetImagePathL( *image );
  1495             CleanupStack::PopAndDestroy( image );
  1883             CleanupStack::PopAndDestroy( image );
  1496             }
  1884             }
  1497         }
  1885         }
  1498   
  1886   
  1499     
  1887     
  1500     iSoftNotification->SetTextL( *text, *text );
  1888     iSoftNotification->SetTextL( *text, *text );
  1501     iSoftNotification->SetSoftkeyLabelsL( *sk1, *sk2 );
       
  1502    
  1889    
  1503     iSoftNotification->ShowSoftNotificationL();
  1890     iSoftNotification->ShowSoftNotificationL();
  1504     FLOG("[bgchecker] LaunchSoftNotificationL 1");
  1891     FLOG("[bgchecker] LaunchSoftNotificationL 1");
  1505     CleanupStack::PopAndDestroy( 3 ); //text, sk1, sk2
  1892     CleanupStack::PopAndDestroy( 3 ); //text, sk1, sk2
  1506     }
  1893     }
  1507 
  1894 */
  1508 
  1895 
  1509 // ----------------------------------------------------------
  1896 // ----------------------------------------------------------
  1510 // CIAUpdateBGTimer::GetPrivatePathL()
  1897 // CIAUpdateBGTimer::GetPrivatePathL()
  1511 // ----------------------------------------------------------
  1898 // ----------------------------------------------------------
  1512 TInt CIAUpdateBGTimer::GetPrivatePathL( TFileName& aPath )
  1899 TInt CIAUpdateBGTimer::GetPrivatePathL( TFileName& aPath )
  1644      }
  2031      }
  1645 
  2032 
  1646 // ----------------------------------------------------------
  2033 // ----------------------------------------------------------
  1647 // CIAUpdateBGTimer::ReadResourceLC()
  2034 // CIAUpdateBGTimer::ReadResourceLC()
  1648 // ----------------------------------------------------------
  2035 // ----------------------------------------------------------
       
  2036  /* HLa
  1649 HBufC* CIAUpdateBGTimer::ReadResourceLC( TInt aResourceId )
  2037 HBufC* CIAUpdateBGTimer::ReadResourceLC( TInt aResourceId )
  1650     {
  2038     {
  1651     TResourceReader reader;
  2039     TResourceReader reader;
  1652     HBufC8* buff = iResourceFile.AllocReadLC( aResourceId );
  2040     HBufC8* buff = iResourceFile.AllocReadLC( aResourceId );
  1653     reader.SetBuffer( buff );
  2041     reader.SetBuffer( buff );
  1654     HBufC* text = reader.ReadHBufCL();
  2042     HBufC* text = reader.ReadHBufCL();
  1655     CleanupStack::PopAndDestroy( buff );
  2043     CleanupStack::PopAndDestroy( buff );
  1656     CleanupStack::PushL( text );
  2044     CleanupStack::PushL( text );
  1657     return text;
  2045     return text;
  1658     }
  2046     } */
  1659 
  2047 
  1660 
  2048 
  1661 // ----------------------------------------------------------
  2049 // ----------------------------------------------------------
  1662 // CIAUpdateBGTimer::IsAutoUpdateDisabledL()
  2050 // CIAUpdateBGTimer::IsAutoUpdateDisabledL()
  1663 // ----------------------------------------------------------
  2051 // ----------------------------------------------------------
  1795         iNotifyHandler = NULL;
  2183         iNotifyHandler = NULL;
  1796         }
  2184         }
  1797     
  2185     
  1798     if ( iSoftNotification )
  2186     if ( iSoftNotification )
  1799         {
  2187         {
  1800         TRAP_IGNORE( iSoftNotification->RemoveSoftNotificationL( iSoftNotification->Id() ) );    
  2188         // TRAP_IGNORE( iSoftNotification->RemoveSoftNotificationL( iSoftNotification->Id() ) );    
  1801         delete iSoftNotification;
  2189         delete iSoftNotification;
  1802         iSoftNotification = NULL;
  2190         iSoftNotification = NULL;
  1803         }
  2191         }
  1804     
  2192     
  1805     CActiveScheduler::Stop();
  2193     CActiveScheduler::Stop();