convergedcallengine/spsettings/backuphelper/src/spsbackuphelpermonitor.cpp
branchRCL_3
changeset 19 7d48bed6ce0c
parent 0 ff3b6d0fd310
child 20 987c9837762f
equal deleted inserted replaced
18:594d59766373 19:7d48bed6ce0c
    42 CSpsBackupHelperMonitor::~CSpsBackupHelperMonitor()
    42 CSpsBackupHelperMonitor::~CSpsBackupHelperMonitor()
    43     {
    43     {
    44     Cancel();
    44     Cancel();
    45     iProperty.Close();
    45     iProperty.Close();
    46     delete iPerformer;
    46     delete iPerformer;
       
    47     delete iABClient;
    47     }
    48     }
    48 
    49 
    49 // ---------------------------------------------------------------------------
    50 // ---------------------------------------------------------------------------
    50 // 
    51 // 
    51 // ---------------------------------------------------------------------------
    52 // ---------------------------------------------------------------------------
    71     TInt backupStateValue = 0;
    72     TInt backupStateValue = 0;
    72     iProperty.Attach( KUidSystemCategory, conn::KUidBackupRestoreKey );
    73     iProperty.Attach( KUidSystemCategory, conn::KUidBackupRestoreKey );
    73 
    74 
    74     // Check current state to see if we were started for backup purposes
    75     // Check current state to see if we were started for backup purposes
    75     iProperty.Get(backupStateValue);
    76     iProperty.Get(backupStateValue);
       
    77     
       
    78     if (!NoBackupRestore(backupStateValue))
       
    79         {
       
    80         iABClient = CActiveBackupClient::NewL();
       
    81             
       
    82         // Confirm that this data owner is ready for backup/restore operations
       
    83         iABClient->ConfirmReadyForBURL(KErrNone);
       
    84         }
    76     
    85     
    77     // Subscribe to the P&S flag to catch transitions
    86     // Subscribe to the P&S flag to catch transitions
    78     Subscribe();
    87     Subscribe();
    79     
    88     
    80     // Construct performer
    89     // Construct performer
   141 //
   150 //
   142 TBool CSpsBackupHelperMonitor::NoBackupRestore( TInt aBackupStateValue )
   151 TBool CSpsBackupHelperMonitor::NoBackupRestore( TInt aBackupStateValue )
   143     {
   152     {
   144     // Not set or no backup or restore ongoing
   153     // Not set or no backup or restore ongoing
   145     TBool ret = 
   154     TBool ret = 
   146         ( ( aBackupStateValue == conn::EBURUnset ) ||
   155         ( ( aBackupStateValue & KBURPartTypeMask ) == conn::EBURUnset ||
   147         ( aBackupStateValue == conn::EBURNormal ) );
   156         ( aBackupStateValue & KBURPartTypeMask ) == conn::EBURNormal );
   148     
   157     
   149     return ret;
   158     return ret;
   150     }
   159     }
   151 
   160 
   152 // ---------------------------------------------------------------------------
   161 // ---------------------------------------------------------------------------
   172     TInt backupStateValue = 0;  // To store the P&S value
   181     TInt backupStateValue = 0;  // To store the P&S value
   173 
   182 
   174     // re-subscribe to the flag to monitor future changes
   183     // re-subscribe to the flag to monitor future changes
   175     Subscribe();
   184     Subscribe();
   176 
   185 
   177     iProperty.Get(backupStateValue);
   186     CheckStatusL();
   178 
   187 
   179     // Process the mode change accordingly
       
   180     ProcessBackupStateL(backupStateValue);
       
   181     XSPSLOGSTRING( "CSpsBackupHelperMonitor::RunL OUT" );
   188     XSPSLOGSTRING( "CSpsBackupHelperMonitor::RunL OUT" );
   182     }
   189     }
   183 
   190 
   184 // ---------------------------------------------------------------------------
   191 // ---------------------------------------------------------------------------
   185 // 
   192 // 
   198 void CSpsBackupHelperMonitor::DoCancel()
   205 void CSpsBackupHelperMonitor::DoCancel()
   199     {
   206     {
   200     iProperty.Cancel();
   207     iProperty.Cancel();
   201     }
   208     }
   202 
   209 
       
   210 void CSpsBackupHelperMonitor::CheckStatusL()
       
   211     {
       
   212     TInt backupInfo =0;
       
   213     iProperty.Get(backupInfo);
       
   214     
       
   215     // Process the mode change accordingly
       
   216     ProcessBackupStateL(backupInfo);
       
   217 
       
   218     if (NoBackupRestore(backupInfo))
       
   219         {
       
   220         delete iABClient;
       
   221         iABClient = NULL;
       
   222         }
       
   223     else 
       
   224         {
       
   225         if (iABClient == NULL)
       
   226             {
       
   227             iABClient = CActiveBackupClient::NewL();
       
   228             }
       
   229         
       
   230         TDriveList driveList;
       
   231         TBURPartType partType;
       
   232         TBackupIncType incType;
       
   233         TInt err;
       
   234         TRAP(err, iABClient->BURModeInfoL(driveList, partType, incType));
       
   235         if (err != KErrNone)
       
   236             {
       
   237             XSPSLOGSTRING("BURModeInfoL error");
       
   238             }
       
   239         
       
   240         TBool amIaffected = ETrue;
       
   241         
       
   242         if (partType == EBURRestorePartial || partType == EBURBackupPartial)
       
   243             {
       
   244             TRAP(err, amIaffected = iABClient->DoesPartialBURAffectMeL());
       
   245             if (err != KErrNone)
       
   246                 {
       
   247                 User::After(5000000);
       
   248                 TRAP(err, amIaffected = iABClient->DoesPartialBURAffectMeL());
       
   249                 }
       
   250             }
       
   251         
       
   252         if (amIaffected)
       
   253             {
       
   254             // Confirm that this data owner is ready for backup/restore operations
       
   255             iABClient->ConfirmReadyForBURL(KErrNone);
       
   256             }
       
   257         }
       
   258     }
       
   259 
       
   260 
   203 // End of file
   261 // End of file
   204 
   262