pimappservices/calendar/server/src/agsbackuprestoreagent.cpp
branchRCL_3
changeset 31 97232defd20e
parent 0 f979ecb2b13e
equal deleted inserted replaced
30:bd7edf625bdd 31:97232defd20e
    14 //
    14 //
    15 
    15 
    16 #include "agsbackuprestoreagent.h"
    16 #include "agsbackuprestoreagent.h"
    17 #include <connect/sbdefs.h> // For conn::EBURNormal etc.
    17 #include <connect/sbdefs.h> // For conn::EBURNormal etc.
    18 
    18 
    19 CAgnServBackupRestoreAgent* CAgnServBackupRestoreAgent::NewL(CAgnServFileMgr& aFileMgr)
    19 CAgnServBackupRestoreAgent* CAgnServBackupRestoreAgent::NewL(CAgnServFileMgr& aFileMgr,TBool& aBackupRestoreInProgress)
    20 	{
    20 	{
    21 	CAgnServBackupRestoreAgent* self = new(ELeave) CAgnServBackupRestoreAgent(aFileMgr);
    21 	CAgnServBackupRestoreAgent* self = new(ELeave) CAgnServBackupRestoreAgent(aFileMgr,aBackupRestoreInProgress);
    22 	return self;
    22 	return self;
    23 	}
    23 	}
    24 
    24 
    25 CAgnServBackupRestoreAgent::~CAgnServBackupRestoreAgent()
    25 CAgnServBackupRestoreAgent::~CAgnServBackupRestoreAgent()
    26 	{
    26 	{
    27 	Cancel();
    27 	Cancel();
    28 	iBackupRestoreNotification.Close();
    28 	iBackupRestoreNotification.Close();
    29 	}
    29 	}
    30 
    30 
    31 CAgnServBackupRestoreAgent::CAgnServBackupRestoreAgent(CAgnServFileMgr& aFileMgr)
    31 CAgnServBackupRestoreAgent::CAgnServBackupRestoreAgent(CAgnServFileMgr& aFileMgr, TBool& aBackupRestoreInProgress)
    32 	: CActive(CActive::EPriorityStandard), iFileMgr(aFileMgr)
    32 	: CActive(CActive::EPriorityStandard), iFileMgr(aFileMgr),iBackupRestoreInProgress(aBackupRestoreInProgress)
    33 	{
    33 	{
    34 	CActiveScheduler::Add(this);
    34 	CActiveScheduler::Add(this);
    35 	
    35 	
    36 	// Attach and subscribe to the Backup/Restore property used by the SBEngine
    36 	// Attach and subscribe to the Backup/Restore property used by the SBEngine
    37 	// component.
    37 	// component.
    88 	// Flag updated.
    88 	// Flag updated.
    89 	if (iBackupRestoreNotification.Get(newState) != KErrNotFound)
    89 	if (iBackupRestoreNotification.Get(newState) != KErrNotFound)
    90 		{
    90 		{
    91 		if ( newState& (conn::EBURBackupPartial | conn::EBURBackupFull) && !BackupInProgress())
    91 		if ( newState& (conn::EBURBackupPartial | conn::EBURBackupFull) && !BackupInProgress())
    92             {
    92             {
       
    93             iBackupRestoreInProgress = ETrue;
    93             iFileMgr.CloseScheduledFilesImmediately();
    94             iFileMgr.CloseScheduledFilesImmediately();
    94             iFileMgr.BackupReStoreChanged(MCalChangeCallBack2::EBackupStart);
    95             iFileMgr.BackupReStoreChanged(MCalChangeCallBack2::EBackupStart);
    95             }
    96             }
    96         else if (newState & (conn::EBURRestoreFull | conn::EBURRestorePartial)&& !RestoreInProgress())
    97         else if (newState & (conn::EBURRestoreFull | conn::EBURRestorePartial)&& !RestoreInProgress())
    97             {
    98             {
       
    99             iBackupRestoreInProgress = ETrue;
    98             iFileMgr.CloseScheduledFilesImmediately();
   100             iFileMgr.CloseScheduledFilesImmediately();
    99             iFileMgr.BackupReStoreChanged(MCalChangeCallBack2::ERestoreStart);      
   101             iFileMgr.BackupReStoreChanged(MCalChangeCallBack2::ERestoreStart);      
   100             }
   102             }
   101         else if (newState & (conn::EBURNormal | conn::EBURUnset) && BackupInProgress())
   103         else if (newState & (conn::EBURNormal | conn::EBURUnset) && BackupInProgress())
   102             {
   104             {
       
   105             iBackupRestoreInProgress = EFalse;
   103             iFileMgr.BackupReStoreChanged(MCalChangeCallBack2::EBackupEnd); 
   106             iFileMgr.BackupReStoreChanged(MCalChangeCallBack2::EBackupEnd); 
   104             }
   107             }
   105         else if (newState & (conn::EBURNormal | conn::EBURUnset) && RestoreInProgress())
   108         else if (newState & (conn::EBURNormal | conn::EBURUnset) && RestoreInProgress())
   106             {
   109             {
       
   110             iBackupRestoreInProgress = EFalse;
   107             iFileMgr.BackupReStoreChanged(MCalChangeCallBack2::ERestoreEnd); 
   111             iFileMgr.BackupReStoreChanged(MCalChangeCallBack2::ERestoreEnd); 
   108             }
   112             }
   109 		iCurrentState = newState;
   113 		iCurrentState = newState;
   110 		}
   114 		}
   111 	}
   115 	}