backupandrestore/backupengine/inc/sbeclientsession.h
changeset 0 d0791faffa3f
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 /**
       
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Declaration of RSBEClientSession
       
    16 * 
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 /**
       
    23  @file
       
    24 */
       
    25 #ifndef __SBECLIENTSESSION_H__
       
    26 #define __SBECLIENTSESSION_H__
       
    27 
       
    28 #include <connect/sbdefs.h>
       
    29 #include <e32std.h>
       
    30 #include <connect/sbtypes.h>
       
    31 #include "sbheapwrapper.h"
       
    32 
       
    33 namespace conn
       
    34 	{
       
    35 	class CSBECallbackHandler;
       
    36 	/** List of Operations for Active Callback execution 
       
    37 	
       
    38 	@internalComponent
       
    39 	*/
       
    40 	enum TState
       
    41 		{
       
    42 		ENone,
       
    43 		EListOfDataOwners,
       
    44 		EPublicFileList,
       
    45 		ELargePublicFileList
       
    46 		};
       
    47 	 
       
    48 	class TServerStart;
       
    49 	class CSBECallbackHandler;
       
    50 
       
    51     /** The client to the Secure Backup Engine
       
    52     
       
    53     This class should be accessed only through the CSBEClient class. These two classes make up 
       
    54     a facade pattern to protect against Binary Compatibility breaks. As large chunks of data are 
       
    55     transferred using the global shared heap, this class owns an instantiation of CHeapWrapper 
       
    56     that wraps access to the Global Shared Heap, providing an easier to use common interface.
       
    57 
       
    58 	@internalComponent
       
    59     */
       
    60 	class RSBEClientSession : public RSessionBase
       
    61     {
       
    62 	public:
       
    63 		static RSBEClientSession* NewL();
       
    64 		TInt Connect();
       
    65 		void Close();
       
    66 		TVersion Version() const;
       
    67 		TPtr8& TransferDataAddressL();
       
    68 		TPtrC8& TransferDataInfoL(CSBGenericTransferType*& aGenericTransferType, TBool& aFinished);
       
    69 		void ListOfDataOwnersL(RPointerArray<CDataOwnerInfo>& aDataOwners);
       
    70 		void PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, RFileArray& aFiles);
       
    71 		void RawPublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, RRestoreFileFilterArray& aFileFilter);
       
    72 		void PublicFileListXMLL(TDriveNumber aDrive, TSecureId aSID, HBufC*& aFileList);
       
    73 		void SetBURModeL(const TDriveList& aDriveList, TBURPartType aBURType, TBackupIncType aBackupIncType);
       
    74 		void SetSIDListForPartialBURL(RSIDArray& aSIDs);
       
    75 		void SIDStatusL(RSIDStatusArray& aSIDStatus);
       
    76 		void RequestDataL(CSBGenericTransferType& aGenericTransferType, TRequestStatus& aStatus);
       
    77 		void RequestDataL(CSBGenericTransferType& aGenericTransferType);
       
    78 		void SupplyDataL(CSBGenericTransferType& aGenericTransferType, TBool aFinished);
       
    79 		void SupplyDataL(CSBGenericTransferType& aGenericTransferType, TBool aFinished, TRequestStatus& aStatus);
       
    80 		TUint ExpectedDataSizeL(CSBGenericTransferType& aGenericTransferType);
       
    81 		void AllSnapshotsSuppliedL();
       
    82 		void AllSystemFilesRestored();
       
    83 	
       
    84 		void ListOfDataOwnersL(RPointerArray<CDataOwnerInfo>& aDataOwners, TRequestStatus& aStatus);
       
    85 		void PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, RFileArray& aFiles, TRequestStatus& aStatus);
       
    86 		void SetBURModeL(const TDriveList& aDriveList, TBURPartType aBURType, 
       
    87 									  TBackupIncType aBackupIncType, TRequestStatus& aStatus);
       
    88 		void AllSnapshotsSuppliedL(TRequestStatus& aStatus);
       
    89 		void AllSystemFilesRestoredL(TRequestStatus& aStatus);
       
    90 	
       
    91 		void PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, RPointerArray<CSBEFileEntry>& aFileList, 
       
    92 			TBool& aFinished, TInt aTotalListCursor, TInt aMaxResponseSize, TRequestStatus& aStatus);
       
    93 
       
    94 		friend class CSBECallbackHandler;
       
    95 
       
    96 		~RSBEClientSession();
       
    97 
       
    98 	private:
       
    99 		RSBEClientSession();
       
   100 		static TInt StartServer();
       
   101 		TInt GetGlobalSharedHeapHandle();
       
   102 		void ConstructL();
       
   103 
       
   104 	protected:	
       
   105 		// callback functions
       
   106 		void PopulateListOfDataOwnersL(TUint aBufferSize);
       
   107 		void PopulatePublicFileListL(TUint aBufferSize);
       
   108 		void PopulateLargePublicFileListL(TInt aResult);
       
   109 	
       
   110 	private:
       
   111 		/** Handle to the Global Shared Heap */
       
   112 		RChunk iGlobalSharedHeap;
       
   113 	
       
   114 		/** Pointer to a CheapWrapper object that marshalls access to the Global Shared Heap */
       
   115 		CHeapWrapper* iGSHInterface;
       
   116 		
       
   117 		/** Pointer to the Client's Data Owners Array */
       
   118 		RPointerArray<CDataOwnerInfo>* 	iDataOwnersArray;
       
   119 		/** Poitner to the Client's File Array */
       
   120 		RFileArray*						iFileArray;
       
   121 	
       
   122 		/** Async callback handler for handling responses from the sbengine */
       
   123 		CSBECallbackHandler* 			iCallbackHandler;
       
   124 		/** Attributes that store parameters passed into async methods */
       
   125 		RPointerArray<CSBEFileEntry>* iFileList;
       
   126 		TBool* iFinished;
       
   127 		TInt* iTotalListCursor;
       
   128     };
       
   129     
       
   130   
       
   131   /** The Callback Handler for the RSBEClientSession
       
   132     
       
   133     This class implements an Active Object interface in order to perform asynchronous calls in a callback manner.
       
   134 
       
   135 	@internalComponent
       
   136    */
       
   137   class CSBECallbackHandler : public CActive
       
   138   	{  	
       
   139   public:
       
   140   
       
   141   	static CSBECallbackHandler* NewL(RSBEClientSession& aClientSession);
       
   142   	~CSBECallbackHandler();
       
   143   	
       
   144   	void StartL(TRequestStatus& aStatus, TState aState);
       
   145   	void CancelRequest();
       
   146   	
       
   147   private:
       
   148 
       
   149   	CSBECallbackHandler(RSBEClientSession& aClientSession);
       
   150   	void ConstructL();
       
   151   	
       
   152   	// From CActive
       
   153 	void RunL();
       
   154 	void DoCancel();
       
   155 	TInt RunError(TInt aError);
       
   156 	void CompleteObserver(TInt aError);
       
   157   private:
       
   158   	/** Reference to the Client Session Class */
       
   159   	RSBEClientSession& 	iClientSession;
       
   160   	/** Observer's TRequestStatus */
       
   161   	TRequestStatus*		iObserver;
       
   162   	/** State to know which function to run */
       
   163   	TState				iState;
       
   164   	};
       
   165   	
       
   166   } // end namespace
       
   167 
       
   168 #endif // __SBECLIENTSESSION_H__