phonebookengines/contactsmodel/cntsrv/inc/CCntBackupRestoreAgent.h
changeset 0 e686773b3f54
child 24 0ba2181d7c28
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __CCNTBACKUPRESTOREAGENT_H__
       
    17 #define __CCNTBACKUPRESTOREAGENT_H__
       
    18 
       
    19 
       
    20 #include <e32base.h> // For CActive.
       
    21 #include <e32property.h> // For RProperty.
       
    22 
       
    23 #include <cntdbobs.h> // for tcontactdbobserverevent 
       
    24 
       
    25 
       
    26 // Forward class references.
       
    27 class CCntDbManagerController;
       
    28 
       
    29 
       
    30 /**
       
    31 	All interaction with the SBEngine component is through this class.  This
       
    32 	class is owned by CCntDbManagerController primarily due to the need to
       
    33 	propagate notification events from the SBEngine to all of the CCntDbManager.
       
    34 
       
    35 	This class implements the behaviours required by the SBEngine component:
       
    36 
       
    37 	- SBEngine Notification Observer
       
    38 	- Registration File Management
       
    39 
       
    40 	In addition the following behaviours are implemented:
       
    41 		
       
    42 	- Store/recall of Contacts Model initialisation file using CIniFileManager
       
    43 	  at appropriate times during Backup/Restore
       
    44 
       
    45 	@internalComponent
       
    46 	@released
       
    47 */
       
    48 class CCntBackupRestoreAgent : public CActive
       
    49 	{
       
    50 public:
       
    51 	static CCntBackupRestoreAgent* NewL(RFs& aFs, CCntDbManagerController& aDbMgrCtrlr);
       
    52 	~CCntBackupRestoreAgent();
       
    53 
       
    54 	void StartL();
       
    55 	
       
    56 	TBool BackupInProgress() const;
       
    57 	TBool RestoreInProgress() const;
       
    58 	
       
    59 	void CreateBackupRegistrationFileL(const TDesC& aFileName);
       
    60 	void DeleteBackupRegistrationFileL(const TDesC& aFileName);
       
    61 	HBufC* CreateBackupRegistrationFileNameLC(const TDesC& aFileName);
       
    62 	
       
    63 private:
       
    64 	CCntBackupRestoreAgent(RFs& aFs, CCntDbManagerController& aDbMgrCtrlr);
       
    65 	
       
    66 	void RunL();
       
    67 	TInt RunError(TInt aError);
       
    68 	void DoCancel();
       
    69 
       
    70 	void ReceivedNotificationL(TInt aNewState);
       
    71 	void ProcessInitialStateL(TInt aNewState);
       
    72 
       
    73 	void BackupBeginningL();
       
    74 	void BackupCompletedL();
       
    75 	void RestoreBeginningL();
       
    76 	void RestoreCompletedL(TInt aRestoreResult);
       
    77 
       
    78 		
       
    79 private:
       
    80 	RFs& iFs;
       
    81 	
       
    82 	/**
       
    83 	Used to subscribe to the SBEngine P&S property KUidBackupRestoreKey.  The
       
    84 	SBEngine uses the property KUidBackupRestoreKey to notify subscribers of
       
    85 	Backup/Restore events.
       
    86 	*/
       
    87 	RProperty iBackupRestoreNotification;
       
    88 
       
    89 	/**
       
    90 	Current state of B&R.  Used to store the B&R flags supplied by the value
       
    91 	of the property KUidBackupRestoreKey.
       
    92 	*/
       
    93 	TInt iCurrentState;
       
    94 
       
    95 	/**
       
    96 	Contacts database observer event.  The event type is changed depending on
       
    97 	the notification received from the SBEngine before being forwarded to all
       
    98 	Contacts Model clients (via the CCntDbManagerController singleton).
       
    99 	*/
       
   100 	TContactDbObserverEvent iEvent;
       
   101 	
       
   102 	/**
       
   103 	Used to broadcast Backup/Restore events to all instances of CCntDbManager
       
   104 	and to access CIniFileManager singleton owned by CCntDbManagerController
       
   105 	singleton so that operations on Contacts Model initialisation file can
       
   106 	be carried out as part of Backup/Restore activity.
       
   107 	*/
       
   108 	CCntDbManagerController& iDbMgrCtrlr;
       
   109 	
       
   110 private:
       
   111 	static const TInt KMaxFileNameLength;
       
   112 	};
       
   113 
       
   114 	
       
   115 #endif //__CCCNTBACKUPRESTOREAGENT_H__