backupandrestore/backupengine/src/sbeclientsession.cpp
changeset 47 63cf70d3ecd8
parent 33 883e91c086aa
equal deleted inserted replaced
44:a5deb6b96675 47:63cf70d3ecd8
    21 
    21 
    22 #include "sbeclientsession.h"
    22 #include "sbeclientsession.h"
    23 #include "sbeclientserver.h"
    23 #include "sbeclientserver.h"
    24 #include <connect/sbtypes.h>
    24 #include <connect/sbtypes.h>
    25 #include "sbepanic.h"
    25 #include "sbepanic.h"
       
    26 #include "OstTraceDefinitions.h"
       
    27 #include "sbtrace.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "sbeclientsessionTraces.h"
       
    30 #endif
    26 
    31 
    27 namespace conn
    32 namespace conn
    28 	{
    33 	{
    29 
       
    30 	RSBEClientSession* RSBEClientSession::NewL()
    34 	RSBEClientSession* RSBEClientSession::NewL()
    31 	/** Symbian OS constructor 
    35 	/** Symbian OS constructor 
    32 	@return pointer to an instantiated RSBEClientSession object */
    36 	@return pointer to an instantiated RSBEClientSession object */
    33 		{
    37 		{
       
    38 		OstTraceFunctionEntry0( RSBECLIENTSESSION_NEWL_ENTRY );
    34 		RSBEClientSession* self = new (ELeave) RSBEClientSession();
    39 		RSBEClientSession* self = new (ELeave) RSBEClientSession();
    35 		CleanupStack::PushL(self);
    40 		CleanupStack::PushL(self);
    36 		self->ConstructL();
    41 		self->ConstructL();
    37 		CleanupStack::Pop(self);
    42 		CleanupStack::Pop(self);
       
    43 		OstTraceFunctionExit0( RSBECLIENTSESSION_NEWL_EXIT );
    38 		return self;
    44 		return self;
    39 		}
    45 		}
    40 
    46 
    41 	void RSBEClientSession::ConstructL()
    47 	void RSBEClientSession::ConstructL()
    42 	/** Symbian second phase constructor */
    48 	/** Symbian second phase constructor */
    43 		{
    49 		{
       
    50         OstTraceFunctionEntry0( RSBECLIENTSESSION_CONSTRUCTL_ENTRY );
    44         iGSHInterface = CHeapWrapper::NewL();
    51         iGSHInterface = CHeapWrapper::NewL();
       
    52 		OstTraceFunctionExit0( RSBECLIENTSESSION_CONSTRUCTL_EXIT );
    45 		}
    53 		}
    46 		
    54 		
    47 	RSBEClientSession::RSBEClientSession() : iCallbackHandler(NULL)
    55 	RSBEClientSession::RSBEClientSession() : iCallbackHandler(NULL)
    48 	/** Class constructor. */
    56 	/** Class constructor. */
    49 		{
    57 		{
       
    58 		OstTraceFunctionEntry0( RSBECLIENTSESSION_RSBECLIENTSESSION_CONS_ENTRY );
       
    59 		OstTraceFunctionExit0( RSBECLIENTSESSION_RSBECLIENTSESSION_CONS_EXIT );
    50 		}
    60 		}
    51 
    61 
    52 	RSBEClientSession::~RSBEClientSession()
    62 	RSBEClientSession::~RSBEClientSession()
    53 	/** Class destructor. */
    63 	/** Class destructor. */
    54 		{
    64 		{
       
    65 		OstTraceFunctionEntry0( RSBECLIENTSESSION_RSBECLIENTSESSION_DES_ENTRY );
    55 		delete iGSHInterface;
    66 		delete iGSHInterface;
    56 		delete iCallbackHandler;
    67 		delete iCallbackHandler;
       
    68 		OstTraceFunctionExit0( RSBECLIENTSESSION_RSBECLIENTSESSION_DES_EXIT );
    57 		}
    69 		}
    58 
    70 
    59 	void RSBEClientSession::Close()
    71 	void RSBEClientSession::Close()
    60 	/** Closes the Secure Backup Engine handle. */
    72 	/** Closes the Secure Backup Engine handle. */
    61 		{
    73 		{
       
    74 		OstTraceFunctionEntry0( RSBECLIENTSESSION_CLOSE_ENTRY );
    62 		iGlobalSharedHeap.Close();
    75 		iGlobalSharedHeap.Close();
    63 		RSessionBase::Close();
    76 		RSessionBase::Close();
       
    77 		OstTraceFunctionExit0( RSBECLIENTSESSION_CLOSE_EXIT );
    64 		}
    78 		}
    65 
    79 
    66 	TInt RSBEClientSession::Connect()
    80 	TInt RSBEClientSession::Connect()
    67 	/** Connects the handle to the Secure Backup Engine.
    81 	/** Connects the handle to the Secure Backup Engine.
    68 
    82 
    69 	@return KErrNone if successful, KErrCouldNotConnect otherwise
    83 	@return KErrNone if successful, KErrCouldNotConnect otherwise
    70 	*/
    84 	*/
    71 		{
    85 		{
       
    86         OstTraceFunctionEntry0( RSBECLIENTSESSION_CONNECT_ENTRY );
    72         TInt nRetry = KSBERetryCount;
    87         TInt nRetry = KSBERetryCount;
    73 		TInt nRet = KErrNotFound;
    88 		TInt nRet = KErrNotFound;
    74 
    89 
    75 		while(nRetry > 0 && nRet != KErrNone)
    90 		while(nRetry > 0 && nRet != KErrNone)
    76 			{
    91 			{
    87 		if (nRet == KErrNone)
   102 		if (nRet == KErrNone)
    88 			{
   103 			{
    89 			nRet = GetGlobalSharedHeapHandle();
   104 			nRet = GetGlobalSharedHeapHandle();
    90 			}
   105 			}
    91 
   106 
       
   107 		OstTraceFunctionExit0( RSBECLIENTSESSION_CONNECT_EXIT );
    92 		return nRet;
   108 		return nRet;
    93 		}
   109 		}
    94 
   110 
    95 	TVersion RSBEClientSession::Version() const
   111 	TVersion RSBEClientSession::Version() const
    96 	/** Returns the version of this API
   112 	/** Returns the version of this API
   112 	with the SBE server (as its not running).
   128 	with the SBE server (as its not running).
   113 
   129 
   114 	@return Standard Symbian OS code from RProcess/RThread create.
   130 	@return Standard Symbian OS code from RProcess/RThread create.
   115 	*/
   131 	*/
   116 		{
   132 		{
       
   133         OstTraceFunctionEntry0( RSBECLIENTSESSION_STARTSERVER_ENTRY );
   117         //
   134         //
   118 		// Servers UID
   135 		// Servers UID
   119 		const TUidType serverUid(KNullUid, KNullUid, KSBServerUID3);
   136 		const TUidType serverUid(KNullUid, KNullUid, KSBServerUID3);
   120 		
   137 		
   121 	
   138 	
   122 		RProcess server;
   139 		RProcess server;
   123     	TInt nRet=server.Create(KSBImageName,KNullDesC,serverUid);
   140     	TInt nRet=server.Create(KSBImageName,KNullDesC,serverUid);
   124     	if (nRet != KErrNone)
   141     	if (nRet != KErrNone)
   125     	    {
   142     	    {
       
   143     		OstTraceFunctionExit0( RSBECLIENTSESSION_STARTSERVER_EXIT );
   126     		return nRet;
   144     		return nRet;
   127     		}
   145     		}
   128     		
   146     		
   129     	TRequestStatus stat;
   147     	TRequestStatus stat;
   130     	server.Rendezvous(stat);
   148     	server.Rendezvous(stat);
   135     	else
   153     	else
   136     		{
   154     		{
   137     		server.Resume();
   155     		server.Resume();
   138     		}
   156     		}
   139     	User::WaitForRequest(stat);
   157     	User::WaitForRequest(stat);
   140     	return (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
   158     	nRet = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
       
   159     	OstTraceFunctionExit0( DUP1_RSBECLIENTSESSION_STARTSERVER_EXIT );
       
   160     	return nRet;
   141 		
   161 		
   142 		}
   162 		}
   143 
   163 
   144 
   164 
   145 	void RSBEClientSession::ListOfDataOwnersL(RPointerArray<CDataOwnerInfo>& aDataOwners)
   165 	void RSBEClientSession::ListOfDataOwnersL(RPointerArray<CDataOwnerInfo>& aDataOwners)
   149 	
   169 	
   150 	@param aDataOwners Pointer array holding the list of Data owners requiring backup functionality.
   170 	@param aDataOwners Pointer array holding the list of Data owners requiring backup functionality.
   151 			Any items present in this array will be lost
   171 			Any items present in this array will be lost
   152 	*/
   172 	*/
   153 		{
   173 		{
       
   174 		OstTraceFunctionEntry0( RSBECLIENTSESSION_LISTOFDATAOWNERSL_ENTRY );
   154 		// Get the server to construct the flattened array and return the size of it		
   175 		// Get the server to construct the flattened array and return the size of it		
   155 		TInt result = SendReceive(ESBEMsgPrepDataOwnerInfo);
   176 		TInt result = SendReceive(ESBEMsgPrepDataOwnerInfo);
   156 		
   177 		
   157 		User::LeaveIfError(result);
   178 		LEAVEIFERROR(result, OstTrace1(TRACE_ERROR, RSBECLIENTSESSION_LISTOFDATAOWNERSL, "Leave: %d", result));
   158 		
   179 		
   159 		iDataOwnersArray = &aDataOwners;
   180 		iDataOwnersArray = &aDataOwners;
   160 		
   181 		
   161 		PopulateListOfDataOwnersL(result);
   182 		PopulateListOfDataOwnersL(result);
       
   183 		OstTraceFunctionExit0( RSBECLIENTSESSION_LISTOFDATAOWNERSL_EXIT );
   162 		}
   184 		}
   163 		
   185 		
   164 	void RSBEClientSession::PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, 
   186 	void RSBEClientSession::PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, 
   165 												RFileArray& aFiles)
   187 												RFileArray& aFiles)
   166 	/**
   188 	/**
   170 	@param aGenericDataType Reference to the generic data type that is being passed to the SBEngine.
   192 	@param aGenericDataType Reference to the generic data type that is being passed to the SBEngine.
   171 	@param aFiles An empty array of file information that will be filled with details of the public files
   193 	@param aFiles An empty array of file information that will be filled with details of the public files
   172 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   194 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   173 	*/
   195 	*/
   174 		{
   196 		{
       
   197 		OstTraceFunctionEntry0( RSBECLIENTSESSION_PUBLICFILELISTL_ENTRY );
   175 		// request the public file list
   198 		// request the public file list
   176 		TInt result = SendReceive(ESBEMsgPrepPublicFiles, TIpcArgs(aDrive, 
   199 		TInt result = SendReceive(ESBEMsgPrepPublicFiles, TIpcArgs(aDrive, 
   177 						&(aGenericDataType.Externalise())));
   200 						&(aGenericDataType.Externalise())));
   178 		
   201 		
   179 		User::LeaveIfError(result);
   202 		LEAVEIFERROR(result, OstTrace1(TRACE_ERROR, RSBECLIENTSESSION_PUBLICFILELISTL, "Leave: %d", result));
   180 
   203 
   181 		iFileArray = &aFiles;
   204 		iFileArray = &aFiles;
   182 		
   205 		
   183 		PopulatePublicFileListL(result);
   206 		PopulatePublicFileListL(result);
       
   207 		OstTraceFunctionExit0( RSBECLIENTSESSION_PUBLICFILELISTL_EXIT );
   184 		}
   208 		}
   185 		
   209 		
   186 	void RSBEClientSession::RawPublicFileListL(	TDriveNumber aDrive, 
   210 	void RSBEClientSession::RawPublicFileListL(	TDriveNumber aDrive, 
   187 												CSBGenericDataType& aGenericDataType, 
   211 												CSBGenericDataType& aGenericDataType, 
   188 												RRestoreFileFilterArray& aFileFilter)
   212 												RRestoreFileFilterArray& aFileFilter)
   195 	@param aFileFilter Empty array that will be filled with the files/directories to be backed up 
   219 	@param aFileFilter Empty array that will be filled with the files/directories to be backed up 
   196 	on return
   220 	on return
   197 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   221 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   198 	*/
   222 	*/
   199 		{
   223 		{
       
   224         OstTraceFunctionEntry0( RSBECLIENTSESSION_RAWPUBLICFILELISTL_ENTRY );
   200         // ensure that the array is cleared out before populating with externalised data
   225         // ensure that the array is cleared out before populating with externalised data
   201 		aFileFilter.Reset();
   226 		aFileFilter.Reset();
   202 		
   227 		
   203 		TPckgC<TDriveNumber> drive(aDrive);
   228 		TPckgC<TDriveNumber> drive(aDrive);
   204 
   229 
   205 		// request the public file list
   230 		// request the public file list
   206 		TInt result = SendReceive(ESBEMsgPrepPublicFilesRaw, TIpcArgs(&drive, 
   231 		TInt result = SendReceive(ESBEMsgPrepPublicFilesRaw, TIpcArgs(&drive, 
   207 				&(aGenericDataType.Externalise())));
   232 				&(aGenericDataType.Externalise())));
   208 		
   233 		
   209 		User::LeaveIfError(result);
   234 		LEAVEIFERROR(result, OstTrace1(TRACE_ERROR, RSBECLIENTSESSION_RAWPUBLICFILELISTL, "Leave: %d", result));
   210 
   235 
   211 		// Create a descriptor big enough for the array to be externalised into
   236 		// Create a descriptor big enough for the array to be externalised into
   212 		HBufC8* pFileArray = HBufC8::NewL(result);
   237 		HBufC8* pFileArray = HBufC8::NewL(result);
   213 		CleanupStack::PushL(pFileArray);
   238 		CleanupStack::PushL(pFileArray);
   214 		
   239 		
   215 		TPtr8 fileArray(pFileArray->Des());
   240 		TPtr8 fileArray(pFileArray->Des());
   216 		User::LeaveIfError(SendReceive(ESBEMsgGetPublicFilesRaw, TIpcArgs(&fileArray)));
   241 		result = SendReceive(ESBEMsgGetPublicFilesRaw, TIpcArgs(&fileArray));
       
   242 		LEAVEIFERROR(result, OstTrace1(TRACE_ERROR, DUP1_RSBECLIENTSESSION_RAWPUBLICFILELISTL, "Leave: %d", result));
   217 		
   243 		
   218 		RRestoreFileFilterArray* pFileFilter = RRestoreFileFilterArray::InternaliseL(fileArray);
   244 		RRestoreFileFilterArray* pFileFilter = RRestoreFileFilterArray::InternaliseL(fileArray);
   219 		CleanupStack::PushL(pFileFilter);
   245 		CleanupStack::PushL(pFileFilter);
   220 		CleanupClosePushL(*pFileFilter);
   246 		CleanupClosePushL(*pFileFilter);
   221 		
   247 		
   226 			} // for x
   252 			} // for x
   227 
   253 
   228 		CleanupStack::PopAndDestroy(pFileFilter); // CleanupClosePushL(*pFileFilter)
   254 		CleanupStack::PopAndDestroy(pFileFilter); // CleanupClosePushL(*pFileFilter)
   229 		CleanupStack::PopAndDestroy(pFileFilter); // CleanupStack::PushL(pFileFilter)
   255 		CleanupStack::PopAndDestroy(pFileFilter); // CleanupStack::PushL(pFileFilter)
   230 		CleanupStack::PopAndDestroy(pFileArray);
   256 		CleanupStack::PopAndDestroy(pFileArray);
       
   257 		OstTraceFunctionExit0( RSBECLIENTSESSION_RAWPUBLICFILELISTL_EXIT );
   231 		}
   258 		}
   232 	
   259 	
   233 	void RSBEClientSession::PublicFileListXMLL(TDriveNumber aDrive, TSecureId aSID, HBufC*& aFileList)
   260 	void RSBEClientSession::PublicFileListXMLL(TDriveNumber aDrive, TSecureId aSID, HBufC*& aFileList)
   234 	/**
   261 	/**
   235 	Get the list of public files in XML format
   262 	Get the list of public files in XML format
   238 	@param aSID The SID of the data owner to get the public files for
   265 	@param aSID The SID of the data owner to get the public files for
   239 	@param aFileList The descriptor to populate on return should be NULL
   266 	@param aFileList The descriptor to populate on return should be NULL
   240 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   267 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   241 	*/
   268 	*/
   242 		{
   269 		{
       
   270         OstTraceFunctionEntry0( RSBECLIENTSESSION_PUBLICFILELISTXMLL_ENTRY );
   243         TPckgC<TDriveNumber> drive(aDrive);
   271         TPckgC<TDriveNumber> drive(aDrive);
   244 		TPckgC<TSecureId> sid(aSID);
   272 		TPckgC<TSecureId> sid(aSID);
   245 
   273 
   246 		// request the public file list
   274 		// request the public file list
   247 		TInt result = SendReceive(ESBEMsgPrepPublicFilesXML, TIpcArgs(&drive, &sid));
   275 		TInt result = SendReceive(ESBEMsgPrepPublicFilesXML, TIpcArgs(&drive, &sid));
   248 		
   276 		
   249 		User::LeaveIfError(result);
   277 		LEAVEIFERROR(result, OstTrace1(TRACE_ERROR, RSBECLIENTSESSION_PUBLICFILELISTXMLL, "Leave: %d", result));
   250 
   278 
   251 		// Create a descriptor big enough for the array to be externalised into
   279 		// Create a descriptor big enough for the array to be externalised into
   252 		aFileList = HBufC::NewL(result);
   280 		aFileList = HBufC::NewL(result);
   253 	
   281 	
   254 		TPtr fileList(aFileList->Des());
   282 		TPtr fileList(aFileList->Des());
   255 		User::LeaveIfError(SendReceive(ESBEMsgPrepPublicFilesXML, TIpcArgs(&fileList)));
   283 		result = SendReceive(ESBEMsgPrepPublicFilesXML, TIpcArgs(&fileList));
       
   284 		LEAVEIFERROR(result, OstTrace1(TRACE_ERROR, DUP1_RSBECLIENTSESSION_PUBLICFILELISTXMLL, "Leave: %d", result));
       
   285 		OstTraceFunctionExit0( RSBECLIENTSESSION_PUBLICFILELISTXMLL_EXIT );
   256 		}
   286 		}
   257 	
   287 	
   258 	void RSBEClientSession::SetBURModeL(const TDriveList& aDriveList, TBURPartType aBURType, 
   288 	void RSBEClientSession::SetBURModeL(const TDriveList& aDriveList, TBURPartType aBURType, 
   259 						  TBackupIncType aBackupIncType)
   289 						  TBackupIncType aBackupIncType)
   260 	/**
   290 	/**
   264 	@param aBURType Set the device into Full/Partial BUR or normal operation
   294 	@param aBURType Set the device into Full/Partial BUR or normal operation
   265 	@param aBackupIncType Base/Incremental backup
   295 	@param aBackupIncType Base/Incremental backup
   266 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   296 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   267 	*/
   297 	*/
   268 		{
   298 		{
   269 		User::LeaveIfError(SendReceive(ESBEMsgSetBURMode, TIpcArgs(&aDriveList, aBURType, aBackupIncType)));
   299 		OstTraceFunctionEntry0( RSBECLIENTSESSION_SETBURMODEL_ENTRY );
       
   300 		TInt result = SendReceive(ESBEMsgSetBURMode, TIpcArgs(&aDriveList, aBURType, aBackupIncType));
       
   301 		LEAVEIFERROR(result, OstTrace1(TRACE_ERROR, RSBECLIENTSESSION_SETBURMODEL, "Leave: %d", result));
       
   302 		OstTraceFunctionExit0( RSBECLIENTSESSION_SETBURMODEL_EXIT );
   270 		}
   303 		}
   271 		
   304 		
   272 	void RSBEClientSession::SetSIDListForPartialBURL(RSIDArray& aSIDs)
   305 	void RSBEClientSession::SetSIDListForPartialBURL(RSIDArray& aSIDs)
   273 	/**
   306 	/**
   274 	If a partial backup is required then this sets the list of data owners.
   307 	If a partial backup is required then this sets the list of data owners.
   277 
   310 
   278 	@param aSIDs array of affected data owners.
   311 	@param aSIDs array of affected data owners.
   279 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   312 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   280 	*/
   313 	*/
   281 		{
   314 		{
       
   315         OstTraceFunctionEntry0( RSBECLIENTSESSION_SETSIDLISTFORPARTIALBURL_ENTRY );
   282         HBufC8* pFlattenedArray = aSIDs.ExternaliseL();
   316         HBufC8* pFlattenedArray = aSIDs.ExternaliseL();
   283 		CleanupStack::PushL(pFlattenedArray);
   317 		CleanupStack::PushL(pFlattenedArray);
   284 		
   318 		
   285 		TPtrC8 flatArray(pFlattenedArray->Des());
   319 		TPtrC8 flatArray(pFlattenedArray->Des());
   286 		
   320 		
   287 		User::LeaveIfError(SendReceive(ESBEMsgSetSIDListPartial, TIpcArgs(&flatArray)));
   321 		TInt result = SendReceive(ESBEMsgSetSIDListPartial, TIpcArgs(&flatArray));
       
   322 		LEAVEIFERROR(result, OstTrace1(TRACE_ERROR, RSBECLIENTSESSION_SETSIDLISTFORPARTIALBURL, "Leave: %d", result));
   288 
   323 
   289 		CleanupStack::PopAndDestroy(pFlattenedArray);
   324 		CleanupStack::PopAndDestroy(pFlattenedArray);
       
   325 		OstTraceFunctionExit0( RSBECLIENTSESSION_SETSIDLISTFORPARTIALBURL_EXIT );
   290 		}
   326 		}
   291 		
   327 		
   292 	void RSBEClientSession::SIDStatusL(RSIDStatusArray& aSIDStatus)
   328 	void RSBEClientSession::SIDStatusL(RSIDStatusArray& aSIDStatus)
   293 	/**
   329 	/**
   294 	Gets the status of a set of data owners.
   330 	Gets the status of a set of data owners.
   297 	@param aSIDStatus an array of structures for information about data owners. On return
   333 	@param aSIDStatus an array of structures for information about data owners. On return
   298 	the status information is filled in.
   334 	the status information is filled in.
   299 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   335 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   300 	*/
   336 	*/
   301 		{
   337 		{
       
   338         OstTraceFunctionEntry0( RSBECLIENTSESSION_SIDSTATUSL_ENTRY );
   302         HBufC8* pExternalisedArray = aSIDStatus.ExternaliseL();
   339         HBufC8* pExternalisedArray = aSIDStatus.ExternaliseL();
   303 		CleanupStack::PushL(pExternalisedArray);
   340 		CleanupStack::PushL(pExternalisedArray);
   304 		
   341 		
   305 		TPtr8 externArray(pExternalisedArray->Des());
   342 		TPtr8 externArray(pExternalisedArray->Des());
   306 		User::LeaveIfError(SendReceive(ESBEMsgPrepSIDStatus, TIpcArgs(&externArray)));
   343 		TInt result = SendReceive(ESBEMsgPrepSIDStatus, TIpcArgs(&externArray));
       
   344 		LEAVEIFERROR(result, OstTrace1(TRACE_ERROR, RSBECLIENTSESSION_SIDSTATUSL, "Leave: %d", result));
   307 		
   345 		
   308 		// Reset the descriptor, ready for getting the returned externalised array
   346 		// Reset the descriptor, ready for getting the returned externalised array
   309 		externArray.Zero();
   347 		externArray.Zero();
   310 		
   348 		
   311 		User::LeaveIfError(SendReceive(ESBEMsgGetSIDStatus, TIpcArgs(&externArray)));
   349 		result = SendReceive(ESBEMsgGetSIDStatus, TIpcArgs(&externArray));
       
   350 		LEAVEIFERROR(result, OstTrace1(TRACE_ERROR, DUP1_RSBECLIENTSESSION_SIDSTATUSL, "Leave: %d", result));
   312 		RSIDStatusArray* pInternalisedArray = RSIDStatusArray::InternaliseL(externArray);
   351 		RSIDStatusArray* pInternalisedArray = RSIDStatusArray::InternaliseL(externArray);
   313 
   352 
   314 		CleanupStack::PopAndDestroy(pExternalisedArray); // pExternalisedArray
   353 		CleanupStack::PopAndDestroy(pExternalisedArray); // pExternalisedArray
   315 		
   354 		
   316 		CleanupStack::PushL(pInternalisedArray);
   355 		CleanupStack::PushL(pInternalisedArray);
   324 			{
   363 			{
   325 			aSIDStatus.AppendL((*pInternalisedArray)[index]);
   364 			aSIDStatus.AppendL((*pInternalisedArray)[index]);
   326 			}
   365 			}
   327 		CleanupStack::PopAndDestroy(pInternalisedArray);	// pInternalisedArray->Close()
   366 		CleanupStack::PopAndDestroy(pInternalisedArray);	// pInternalisedArray->Close()
   328 		CleanupStack::PopAndDestroy(pInternalisedArray); // pInternalisedArray
   367 		CleanupStack::PopAndDestroy(pInternalisedArray); // pInternalisedArray
       
   368 		OstTraceFunctionExit0( RSBECLIENTSESSION_SIDSTATUSL_EXIT );
   329 		}
   369 		}
   330 	
   370 	
   331 	TPtr8& RSBEClientSession::TransferDataAddressL()
   371 	TPtr8& RSBEClientSession::TransferDataAddressL()
   332 	/**
   372 	/**
   333 	Provides access to the base of the global chunk used to transfer data between
   373 	Provides access to the base of the global chunk used to transfer data between
   361 	@param aGenericTransferType Pointer reference that a Generic Transfer Type is allocated to
   401 	@param aGenericTransferType Pointer reference that a Generic Transfer Type is allocated to
   362 	@param aFinished Flag that will be set to ETrue if the data on the GSH is the last in the series
   402 	@param aFinished Flag that will be set to ETrue if the data on the GSH is the last in the series
   363 	@return Pointer to the start of the buffer for reading
   403 	@return Pointer to the start of the buffer for reading
   364 	*/
   404 	*/
   365 		{
   405 		{
       
   406         OstTraceFunctionEntry0( RSBECLIENTSESSION_TRANSFERDATAINFOL_ENTRY );
   366         TPtrC8& returnedBuf = iGSHInterface->ReadBufferL(iGlobalSharedHeap);
   407         TPtrC8& returnedBuf = iGSHInterface->ReadBufferL(iGlobalSharedHeap);
   367 		
   408 		
   368 		TDesC8& genTypeBuffer = iGSHInterface->Header(iGlobalSharedHeap).GenericTransferTypeBuffer();
   409 		TDesC8& genTypeBuffer = iGSHInterface->Header(iGlobalSharedHeap).GenericTransferTypeBuffer();
   369 		if (genTypeBuffer.Size() == 0)
   410 		if (genTypeBuffer.Size() == 0)
   370 			{
   411 			{
       
   412 		    OstTrace0(TRACE_ERROR, RSBECLIENTSESSION_TRANSFERDATAINFOL, "Leave: KErrNotReady");
   371 			User::Leave(KErrNotReady);
   413 			User::Leave(KErrNotReady);
   372 			}
   414 			}
   373 		
   415 		
   374 		// Create a new client-side transfer type and pass ownership
   416 		// Create a new client-side transfer type and pass ownership
   375 		aGenericTransferType = CSBGenericTransferType::NewL(genTypeBuffer);
   417 		aGenericTransferType = CSBGenericTransferType::NewL(genTypeBuffer);
   377 		
   419 		
   378 		aFinished = iGSHInterface->Header(iGlobalSharedHeap).iFinished;
   420 		aFinished = iGSHInterface->Header(iGlobalSharedHeap).iFinished;
   379 
   421 
   380 		CleanupStack::Pop(aGenericTransferType);
   422 		CleanupStack::Pop(aGenericTransferType);
   381 		
   423 		
       
   424 		OstTraceFunctionExit0( RSBECLIENTSESSION_TRANSFERDATAINFOL_EXIT );
   382 		return returnedBuf;
   425 		return returnedBuf;
   383 		}
   426 		}
   384 
   427 
   385 	TInt RSBEClientSession::GetGlobalSharedHeapHandle()
   428 	TInt RSBEClientSession::GetGlobalSharedHeapHandle()
   386 	/**
   429 	/**
   388 	sets the member RChunk with it.
   431 	sets the member RChunk with it.
   389 	
   432 	
   390 	@return An error code resulting from the server request for the handle, KErrNone if ok
   433 	@return An error code resulting from the server request for the handle, KErrNone if ok
   391 	*/
   434 	*/
   392 		{
   435 		{
       
   436         OstTraceFunctionEntry0( RSBECLIENTSESSION_GETGLOBALSHAREDHEAPHANDLE_ENTRY );
   393         TInt ret = SendReceive(ESBEMsgGetGSHHandle);
   437         TInt ret = SendReceive(ESBEMsgGetGSHHandle);
   394 		
   438 		
   395 		// ret is negative if an error has ocurred
   439 		// ret is negative if an error has ocurred
   396 		if (ret > KErrNone)
   440 		if (ret > KErrNone)
   397 			{
   441 			{
   399 			
   443 			
   400 			// Since a handle was returned, there were no errors
   444 			// Since a handle was returned, there were no errors
   401 			ret = KErrNone;
   445 			ret = KErrNone;
   402 			}
   446 			}
   403 		
   447 		
       
   448 		OstTraceFunctionExit0( RSBECLIENTSESSION_GETGLOBALSHAREDHEAPHANDLE_EXIT );
   404 		return ret;
   449 		return ret;
   405 		}
   450 		}
   406 		
   451 		
   407 	void RSBEClientSession::RequestDataL(CSBGenericTransferType& aGenericTransferType, 
   452 	void RSBEClientSession::RequestDataL(CSBGenericTransferType& aGenericTransferType, 
   408 		TRequestStatus& aStatus)
   453 		TRequestStatus& aStatus)
   414 	@param aGenericTransferType Reference to the identifier of the data requested
   459 	@param aGenericTransferType Reference to the identifier of the data requested
   415 	@param aStatus TRequestStatus object used by the server to signal the client that a response 
   460 	@param aStatus TRequestStatus object used by the server to signal the client that a response 
   416 	is ready
   461 	is ready
   417 	*/
   462 	*/
   418 		{
   463 		{
       
   464         OstTraceFunctionEntry0( RSBECLIENTSESSION_REQUESTDATAL_ENTRY );
   419         const TDesC8& transBuf = aGenericTransferType.Externalise();
   465         const TDesC8& transBuf = aGenericTransferType.Externalise();
   420 		SendReceive(ESBEMsgRequestDataAsync, TIpcArgs(&transBuf), aStatus);
   466 		SendReceive(ESBEMsgRequestDataAsync, TIpcArgs(&transBuf), aStatus);
       
   467 		OstTraceFunctionExit0( RSBECLIENTSESSION_REQUESTDATAL_EXIT );
   421 		}
   468 		}
   422 
   469 
   423 	void RSBEClientSession::RequestDataL(CSBGenericTransferType& aGenericTransferType)
   470 	void RSBEClientSession::RequestDataL(CSBGenericTransferType& aGenericTransferType)
   424 	/**
   471 	/**
   425 	Synchronous request of the Secure Backup Engine to supply data for a particular data owner.
   472 	Synchronous request of the Secure Backup Engine to supply data for a particular data owner.
   428 	
   475 	
   429 	@param aGenericTransferType Reference to the identifier of the data requested
   476 	@param aGenericTransferType Reference to the identifier of the data requested
   430 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   477 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   431 	*/
   478 	*/
   432 		{
   479 		{
   433         User::LeaveIfError(SendReceive(ESBEMsgRequestDataSync, 
   480         OstTraceFunctionEntry0( DUP1_RSBECLIENTSESSION_REQUESTDATAL_ENTRY );
   434 			TIpcArgs(&(aGenericTransferType.Externalise()))));
   481         TInt result = SendReceive(ESBEMsgRequestDataSync, TIpcArgs(&(aGenericTransferType.Externalise())));
       
   482         LEAVEIFERROR(result, OstTrace1(TRACE_ERROR, DUP1_RSBECLIENTSESSION_REQUESTDATAL, "Leave: %d", result));
       
   483 		OstTraceFunctionExit0( DUP1_RSBECLIENTSESSION_REQUESTDATAL_EXIT );
   435 		}
   484 		}
   436 		
   485 		
   437 	void RSBEClientSession::SupplyDataL(CSBGenericTransferType& aGenericTransferType, 
   486 	void RSBEClientSession::SupplyDataL(CSBGenericTransferType& aGenericTransferType, 
   438 		TBool aFinished, TRequestStatus& aStatus)
   487 		TBool aFinished, TRequestStatus& aStatus)
   439 	/**
   488 	/**
   444 	@param aFinished ETrue indicates that additional SupplyDataL calls will be made as 
   493 	@param aFinished ETrue indicates that additional SupplyDataL calls will be made as 
   445 	part of this transfer operation
   494 	part of this transfer operation
   446 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   495 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   447 	*/
   496 	*/
   448 		{
   497 		{
       
   498         OstTraceFunctionEntry0( RSBECLIENTSESSION_SUPPLYDATAL_ENTRY );
   449         iGSHInterface->Header(iGlobalSharedHeap).GenericTransferTypeBuffer() 
   499         iGSHInterface->Header(iGlobalSharedHeap).GenericTransferTypeBuffer() 
   450 			= aGenericTransferType.Externalise();
   500 			= aGenericTransferType.Externalise();
   451 
   501 
   452 		SendReceive(ESBEMsgSupplyDataSync, TIpcArgs(aFinished), aStatus);
   502 		SendReceive(ESBEMsgSupplyDataSync, TIpcArgs(aFinished), aStatus);
       
   503 		OstTraceFunctionExit0( RSBECLIENTSESSION_SUPPLYDATAL_EXIT );
   453 		}
   504 		}
   454 
   505 
   455 	void RSBEClientSession::SupplyDataL(CSBGenericTransferType& aGenericTransferType, 
   506 	void RSBEClientSession::SupplyDataL(CSBGenericTransferType& aGenericTransferType, 
   456 		TBool aFinished)
   507 		TBool aFinished)
   457 	/**
   508 	/**
   462 	@param aFinished ETrue indicates that additional SupplyDataL calls will be made as 
   513 	@param aFinished ETrue indicates that additional SupplyDataL calls will be made as 
   463 	part of this transfer operation
   514 	part of this transfer operation
   464 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   515 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   465 	*/
   516 	*/
   466 		{
   517 		{
       
   518         OstTraceFunctionEntry0( DUP1_RSBECLIENTSESSION_SUPPLYDATAL_ENTRY );
   467         iGSHInterface->Header(iGlobalSharedHeap).GenericTransferTypeBuffer() 
   519         iGSHInterface->Header(iGlobalSharedHeap).GenericTransferTypeBuffer() 
   468 			= aGenericTransferType.Externalise();
   520 			= aGenericTransferType.Externalise();
   469 			
   521 
   470 		User::LeaveIfError(SendReceive(ESBEMsgSupplyDataSync, TIpcArgs(aFinished)));
   522         TInt result = SendReceive(ESBEMsgSupplyDataSync, TIpcArgs(aFinished));
       
   523 		LEAVEIFERROR(result, OstTrace1(TRACE_ERROR, DUP1_RSBECLIENTSESSION_SUPPLYDATAL, "Leave: %d", result));
       
   524 		OstTraceFunctionExit0( DUP1_RSBECLIENTSESSION_SUPPLYDATAL_EXIT );
   471 		}
   525 		}
   472 		
   526 		
   473 	void RSBEClientSession::AllSnapshotsSuppliedL()
   527 	void RSBEClientSession::AllSnapshotsSuppliedL()
   474 	/**
   528 	/**
   475 	This methods informs the data owner that all snapshots have been supplied.
   529 	This methods informs the data owner that all snapshots have been supplied.
   476 
   530 
   477 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   531 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   478 	*/
   532 	*/
   479 		{
   533 		{
   480         User::LeaveIfError(SendReceive(ESBEMsgAllSnapshotsSupplied));
   534         OstTraceFunctionEntry0( RSBECLIENTSESSION_ALLSNAPSHOTSSUPPLIEDL_ENTRY );
   481 	
   535         TInt result = SendReceive(ESBEMsgAllSnapshotsSupplied);
       
   536         LEAVEIFERROR(result, OstTrace1(TRACE_ERROR, RSBECLIENTSESSION_ALLSNAPSHOTSSUPPLIEDL, "Leave: %d", result));
       
   537 	
       
   538 		OstTraceFunctionExit0( RSBECLIENTSESSION_ALLSNAPSHOTSSUPPLIEDL_EXIT );
   482 		}
   539 		}
   483 		
   540 		
   484 	TUint RSBEClientSession::ExpectedDataSizeL(CSBGenericTransferType& aGenericTransferType)
   541 	TUint RSBEClientSession::ExpectedDataSizeL(CSBGenericTransferType& aGenericTransferType)
   485 	/**
   542 	/**
   486 	Get the expected total size of the data to be returned by the SBE for the purposes 
   543 	Get the expected total size of the data to be returned by the SBE for the purposes 
   488 	
   545 	
   489 	@param aGenericTransferType Reference to the identifier of the data to be retrieved
   546 	@param aGenericTransferType Reference to the identifier of the data to be retrieved
   490 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   547 	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
   491 	*/
   548 	*/
   492 		{
   549 		{
       
   550         OstTraceFunctionEntry0( RSBECLIENTSESSION_EXPECTEDDATASIZEL_ENTRY );
   493         TPckgBuf<TUint> sizePkg;
   551         TPckgBuf<TUint> sizePkg;
   494 
   552 
   495 		TPtrC8 genType(aGenericTransferType.Externalise());
   553 		TPtrC8 genType(aGenericTransferType.Externalise());
   496 		
   554 		
   497 		User::LeaveIfError(SendReceive(ESBEMsgGetExpectedDataSize, TIpcArgs(&genType, &sizePkg)));
   555 		TInt result = SendReceive(ESBEMsgGetExpectedDataSize, TIpcArgs(&genType, &sizePkg));
       
   556 		LEAVEIFERROR(result, OstTrace1(TRACE_ERROR, RSBECLIENTSESSION_EXPECTEDDATASIZEL, "Leave: %d", result));
   498 			
   557 			
   499 		return sizePkg();
   558 		TUint size = sizePkg();
       
   559 		OstTraceFunctionExit0( RSBECLIENTSESSION_EXPECTEDDATASIZEL_EXIT );
       
   560 		return size;
   500 		}
   561 		}
   501 		
   562 		
   502 	void RSBEClientSession::AllSystemFilesRestored()
   563 	void RSBEClientSession::AllSystemFilesRestored()
   503 	/**
   564 	/**
   504 	Signal the Secure Backup Engine that registration files are to be parsed and Active data owners 
   565 	Signal the Secure Backup Engine that registration files are to be parsed and Active data owners 
   505 	are to be started
   566 	are to be started
   506 	*/
   567 	*/
   507 		{
   568 		{
       
   569         OstTraceFunctionEntry0( RSBECLIENTSESSION_ALLSYSTEMFILESRESTORED_ENTRY );
   508         SendReceive(ESBEMsgAllSystemFilesRestored);
   570         SendReceive(ESBEMsgAllSystemFilesRestored);
       
   571 		OstTraceFunctionExit0( RSBECLIENTSESSION_ALLSYSTEMFILESRESTORED_EXIT );
   509 		}
   572 		}
   510 	
   573 	
   511 	/**
   574 	/**
   512 	Return the list of private data owners on the device that have backup registration files.
   575 	Return the list of private data owners on the device that have backup registration files.
   513 	If a leave does occur, then aDataOwners
   576 	If a leave does occur, then aDataOwners
   516 			Any items present in this array will be lost
   579 			Any items present in this array will be lost
   517 	@param aStatus is TRequestStatus&
   580 	@param aStatus is TRequestStatus&
   518 	*/
   581 	*/
   519 	void RSBEClientSession::ListOfDataOwnersL(RPointerArray<CDataOwnerInfo>& aDataOwners, TRequestStatus& aStatus)
   582 	void RSBEClientSession::ListOfDataOwnersL(RPointerArray<CDataOwnerInfo>& aDataOwners, TRequestStatus& aStatus)
   520 		{
   583 		{
       
   584 		OstTraceFunctionEntry0( DUP1_RSBECLIENTSESSION_LISTOFDATAOWNERSL_ENTRY );
   521 		if (iCallbackHandler == NULL)
   585 		if (iCallbackHandler == NULL)
   522 			{
   586 			{
   523 			iCallbackHandler = CSBECallbackHandler::NewL(*this);				
   587 			iCallbackHandler = CSBECallbackHandler::NewL(*this);				
   524 			}
   588 			}
   525 
   589 
   526 		if (iCallbackHandler->IsActive())
   590 		if (iCallbackHandler->IsActive())
   527 			{
   591 			{
       
   592 		    OstTrace0(TRACE_ERROR, DUP1_RSBECLIENTSESSION_LISTOFDATAOWNERSL, "Leave: KErrInUse");
   528 			User::Leave(KErrInUse);
   593 			User::Leave(KErrInUse);
   529 			}
   594 			}
   530 		else
   595 		else
   531 			{
   596 			{
   532 			iDataOwnersArray = &aDataOwners;
   597 			iDataOwnersArray = &aDataOwners;
   533 			SendReceive(ESBEMsgPrepDataOwnerInfo, iCallbackHandler->iStatus);
   598 			SendReceive(ESBEMsgPrepDataOwnerInfo, iCallbackHandler->iStatus);
   534 			iCallbackHandler->StartL(aStatus, EListOfDataOwners);
   599 			iCallbackHandler->StartL(aStatus, EListOfDataOwners);
   535 			}
   600 			}
       
   601 		OstTraceFunctionExit0( DUP1_RSBECLIENTSESSION_LISTOFDATAOWNERSL_EXIT );
   536 		}
   602 		}
   537 	
   603 	
   538 	/**
   604 	/**
   539 	Get the list of public files to backup for a particular Data Owner on a particular drive
   605 	Get the list of public files to backup for a particular Data Owner on a particular drive
   540 	
   606 	
   544 	@param aStatus A reference to TRequestStatus
   610 	@param aStatus A reference to TRequestStatus
   545 	
   611 	
   546 	*/	
   612 	*/	
   547 	void RSBEClientSession::PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, RFileArray& aFiles, TRequestStatus& aStatus)
   613 	void RSBEClientSession::PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, RFileArray& aFiles, TRequestStatus& aStatus)
   548 		{
   614 		{
       
   615 		OstTraceFunctionEntry0( DUP1_RSBECLIENTSESSION_PUBLICFILELISTL_ENTRY );
   549 		if (iCallbackHandler == NULL)
   616 		if (iCallbackHandler == NULL)
   550 			{
   617 			{
   551 			iCallbackHandler = CSBECallbackHandler::NewL(*this);				
   618 			iCallbackHandler = CSBECallbackHandler::NewL(*this);				
   552 			}
   619 			}
   553 	
   620 	
   554 		if (iCallbackHandler->IsActive())
   621 		if (iCallbackHandler->IsActive())
   555 			{
   622 			{
       
   623 		    OstTrace0(TRACE_ERROR, DUP1_RSBECLIENTSESSION_PUBLICFILELISTL, "Leave: KErrInUse");
   556 			User::Leave(KErrInUse);
   624 			User::Leave(KErrInUse);
   557 			}
   625 			}
   558 		else
   626 		else
   559 			{
   627 			{
   560 			iFileArray = &aFiles;
   628 			iFileArray = &aFiles;
   561 			// request the public file list
   629 			// request the public file list
   562 			SendReceive(ESBEMsgPrepPublicFiles, TIpcArgs(aDrive, &(aGenericDataType.Externalise())), iCallbackHandler->iStatus);
   630 			SendReceive(ESBEMsgPrepPublicFiles, TIpcArgs(aDrive, &(aGenericDataType.Externalise())), iCallbackHandler->iStatus);
   563 			iCallbackHandler->StartL(aStatus,EPublicFileList);
   631 			iCallbackHandler->StartL(aStatus,EPublicFileList);
   564 			}
   632 			}
       
   633 		OstTraceFunctionExit0( DUP1_RSBECLIENTSESSION_PUBLICFILELISTL_EXIT );
   565 		}
   634 		}
   566 		
   635 		
   567 	void RSBEClientSession::SetBURModeL(const TDriveList& aDriveList, TBURPartType aBURType, 
   636 	void RSBEClientSession::SetBURModeL(const TDriveList& aDriveList, TBURPartType aBURType, 
   568 								  TBackupIncType aBackupIncType, TRequestStatus& aStatus)
   637 								  TBackupIncType aBackupIncType, TRequestStatus& aStatus)
   569 	/**
   638 	/**
   574 	@param aBackupIncType Base/Incremental backup
   643 	@param aBackupIncType Base/Incremental backup
   575 	@param aStatus A reference to TRequestStatus
   644 	@param aStatus A reference to TRequestStatus
   576 	*/
   645 	*/
   577 
   646 
   578 		{
   647 		{
       
   648 		OstTraceFunctionEntry0( DUP1_RSBECLIENTSESSION_SETBURMODEL_ENTRY );
   579 		SendReceive(ESBEMsgSetBURMode, TIpcArgs(&aDriveList, aBURType, aBackupIncType), aStatus);
   649 		SendReceive(ESBEMsgSetBURMode, TIpcArgs(&aDriveList, aBURType, aBackupIncType), aStatus);
       
   650 		OstTraceFunctionExit0( DUP1_RSBECLIENTSESSION_SETBURMODEL_EXIT );
   580 		}
   651 		}
   581 	
   652 	
   582 	/**
   653 	/**
   583 	This methods informs the data owner that all snapshots have been supplied.
   654 	This methods informs the data owner that all snapshots have been supplied.
   584 
   655 
   585 	@param aStatus A reference to TRequestStatus
   656 	@param aStatus A reference to TRequestStatus
   586 	*/	
   657 	*/	
   587 	void RSBEClientSession::AllSnapshotsSuppliedL(TRequestStatus& aStatus)
   658 	void RSBEClientSession::AllSnapshotsSuppliedL(TRequestStatus& aStatus)
   588 		{
   659 		{
       
   660 		OstTraceFunctionEntry0( DUP1_RSBECLIENTSESSION_ALLSNAPSHOTSSUPPLIEDL_ENTRY );
   589 		SendReceive(ESBEMsgAllSnapshotsSupplied, aStatus);
   661 		SendReceive(ESBEMsgAllSnapshotsSupplied, aStatus);
       
   662 		OstTraceFunctionExit0( DUP1_RSBECLIENTSESSION_ALLSNAPSHOTSSUPPLIEDL_EXIT );
   590 		}
   663 		}
   591 	
   664 	
   592 	/**
   665 	/**
   593 	Signal the Secure Backup Engine that registration files are to be parsed and Active data owners 
   666 	Signal the Secure Backup Engine that registration files are to be parsed and Active data owners 
   594 	are to be started
   667 	are to be started
   595 	
   668 	
   596 	@param aStatus A reference to TRequestStatus
   669 	@param aStatus A reference to TRequestStatus
   597 	*/	
   670 	*/	
   598 	void RSBEClientSession::AllSystemFilesRestoredL(TRequestStatus& aStatus)
   671 	void RSBEClientSession::AllSystemFilesRestoredL(TRequestStatus& aStatus)
   599 		{
   672 		{
       
   673 		OstTraceFunctionEntry0( RSBECLIENTSESSION_ALLSYSTEMFILESRESTOREDL_ENTRY );
   600 		SendReceive(ESBEMsgAllSystemFilesRestored, aStatus);
   674 		SendReceive(ESBEMsgAllSystemFilesRestored, aStatus);
       
   675 		OstTraceFunctionExit0( RSBECLIENTSESSION_ALLSYSTEMFILESRESTOREDL_EXIT );
   601 		}
   676 		}
   602 				
   677 				
   603 	
   678 	
   604 	/**
   679 	/**
   605 	Method to perform and IPC call to populate list of data owners.
   680 	Method to perform and IPC call to populate list of data owners.
   607 	
   682 	
   608 	@InternalTechnology
   683 	@InternalTechnology
   609 	*/
   684 	*/
   610 	void RSBEClientSession::PopulateListOfDataOwnersL(TUint aBufferSize)
   685 	void RSBEClientSession::PopulateListOfDataOwnersL(TUint aBufferSize)
   611 		{
   686 		{
       
   687 		OstTraceFunctionEntry0( RSBECLIENTSESSION_POPULATELISTOFDATAOWNERSL_ENTRY );
   612 		__ASSERT_DEBUG(iDataOwnersArray, Panic(KErrBadHandle));
   688 		__ASSERT_DEBUG(iDataOwnersArray, Panic(KErrBadHandle));
   613 		iDataOwnersArray->ResetAndDestroy();
   689 		iDataOwnersArray->ResetAndDestroy();
   614 					
   690 					
   615 		// Create a descriptor that's appropriate to hold the buffer to be returned		
   691 		// Create a descriptor that's appropriate to hold the buffer to be returned		
   616 		HBufC8* pReturnedBuf = HBufC8::NewL(aBufferSize);
   692 		HBufC8* pReturnedBuf = HBufC8::NewL(aBufferSize);
   618 		CleanupStack::PushL(pReturnedBuf);
   694 		CleanupStack::PushL(pReturnedBuf);
   619 
   695 
   620 		TPtr8 returnedBuf(pReturnedBuf->Des());
   696 		TPtr8 returnedBuf(pReturnedBuf->Des());
   621 		// Request that the server returns the previously packed array
   697 		// Request that the server returns the previously packed array
   622 		TInt result = SendReceive(ESBEMsgGetDataOwnerInfo, TIpcArgs(&returnedBuf));
   698 		TInt result = SendReceive(ESBEMsgGetDataOwnerInfo, TIpcArgs(&returnedBuf));
   623 		User::LeaveIfError(result);
   699 		LEAVEIFERROR(result, OstTrace1(TRACE_ERROR, RSBECLIENTSESSION_POPULATELISTOFDATAOWNERSL, "Leave: %d", result));
   624 		
   700 		
   625 		TInt offset = 0;
   701 		TInt offset = 0;
   626 		
   702 		
   627 		for (TInt index = 0; index < result; index++)
   703 		for (TInt index = 0; index < result; index++)
   628 			{
   704 			{
   635 			
   711 			
   636 			offset += (*iDataOwnersArray)[index]->Size();
   712 			offset += (*iDataOwnersArray)[index]->Size();
   637 			}
   713 			}
   638 			
   714 			
   639 		CleanupStack::PopAndDestroy(pReturnedBuf);
   715 		CleanupStack::PopAndDestroy(pReturnedBuf);
       
   716 		OstTraceFunctionExit0( RSBECLIENTSESSION_POPULATELISTOFDATAOWNERSL_EXIT );
   640 		}
   717 		}
   641 	
   718 	
   642 	/**
   719 	/**
   643 	Method to perform and IPC call to populate list of public files.
   720 	Method to perform and IPC call to populate list of public files.
   644 	@param aBufferSize Size of the buffer needed to be allocated for the IPC call
   721 	@param aBufferSize Size of the buffer needed to be allocated for the IPC call
   645 	
   722 	
   646 	@InternalTechnology
   723 	@InternalTechnology
   647 	*/	
   724 	*/	
   648 	void RSBEClientSession::PopulatePublicFileListL(TUint aBufferSize)
   725 	void RSBEClientSession::PopulatePublicFileListL(TUint aBufferSize)
   649 		{
   726 		{
       
   727 		OstTraceFunctionEntry0( RSBECLIENTSESSION_POPULATEPUBLICFILELISTL_ENTRY );
   650 		__ASSERT_DEBUG(iFileArray, Panic(KErrBadHandle));
   728 		__ASSERT_DEBUG(iFileArray, Panic(KErrBadHandle));
   651 		iFileArray->Reset();
   729 		iFileArray->Reset();
   652 		
   730 		
   653 		// Create a descriptor big enough for the array to be externalised into
   731 		// Create a descriptor big enough for the array to be externalised into
   654 		HBufC8* pFileArray = HBufC8::NewL(aBufferSize);
   732 		HBufC8* pFileArray = HBufC8::NewL(aBufferSize);
   655 		CleanupStack::PushL(pFileArray);
   733 		CleanupStack::PushL(pFileArray);
   656 		
   734 		
   657 		TPtr8 fileArray(pFileArray->Des());
   735 		TPtr8 fileArray(pFileArray->Des());
   658 		User::LeaveIfError(SendReceive(ESBEMsgGetPublicFiles, TIpcArgs(&fileArray)));
   736 		TInt result = SendReceive(ESBEMsgGetPublicFiles, TIpcArgs(&fileArray));
       
   737 		LEAVEIFERROR(result, OstTrace1(TRACE_ERROR, RSBECLIENTSESSION_POPULATEPUBLICFILELISTL, "Leave: %d", result));
   659 		
   738 		
   660 		RFileArray* pFiles = RFileArray::InternaliseL(fileArray);
   739 		RFileArray* pFiles = RFileArray::InternaliseL(fileArray);
   661 		CleanupStack::PopAndDestroy(pFileArray);
   740 		CleanupStack::PopAndDestroy(pFileArray);
   662 		CleanupStack::PushL(pFiles);
   741 		CleanupStack::PushL(pFiles);
   663 		CleanupClosePushL(*pFiles);
   742 		CleanupClosePushL(*pFiles);
   669 			pFiles->Remove(0);					// We're running out of memory, hence be frugal
   748 			pFiles->Remove(0);					// We're running out of memory, hence be frugal
   670 			} // for x
   749 			} // for x
   671 		
   750 		
   672 		CleanupStack::PopAndDestroy(pFiles); // CleanupClosePushL(*pFiles)
   751 		CleanupStack::PopAndDestroy(pFiles); // CleanupClosePushL(*pFiles)
   673 		CleanupStack::PopAndDestroy(pFiles); // CleanupStack::PushL(pFiles)
   752 		CleanupStack::PopAndDestroy(pFiles); // CleanupStack::PushL(pFiles)
       
   753 		OstTraceFunctionExit0( RSBECLIENTSESSION_POPULATEPUBLICFILELISTL_EXIT );
   674 		}
   754 		}
   675 
   755 
   676 	void RSBEClientSession::PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, 
   756 	void RSBEClientSession::PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, 
   677 								RPointerArray<CSBEFileEntry>& aFileList, TBool& aFinished,
   757 								RPointerArray<CSBEFileEntry>& aFileList, TBool& aFinished,
   678 								TInt aTotalListCursor, TInt aMaxResponseSize, TRequestStatus& aStatus)
   758 								TInt aTotalListCursor, TInt aMaxResponseSize, TRequestStatus& aStatus)
   689 						method can be determined by querying the count of aFileList
   769 						method can be determined by querying the count of aFileList
   690 	@param aMaxResponseSize The maximum total size in bytes of externalised CSBEFileEntry objects that will be returned
   770 	@param aMaxResponseSize The maximum total size in bytes of externalised CSBEFileEntry objects that will be returned
   691 	@param aStatus The TRequestStatus that will be completed once the engine has fully processed this request
   771 	@param aStatus The TRequestStatus that will be completed once the engine has fully processed this request
   692 	*/
   772 	*/
   693 		{
   773 		{
       
   774 		OstTraceFunctionEntry0( DUP2_RSBECLIENTSESSION_PUBLICFILELISTL_ENTRY );
   694 		if (iCallbackHandler == NULL)
   775 		if (iCallbackHandler == NULL)
   695 			{
   776 			{
   696 			iCallbackHandler = CSBECallbackHandler::NewL(*this);				
   777 			iCallbackHandler = CSBECallbackHandler::NewL(*this);				
   697 			}
   778 			}
   698 	
   779 	
   699 		if (iCallbackHandler->IsActive())
   780 		if (iCallbackHandler->IsActive())
   700 			{
   781 			{
       
   782 		    OstTrace0(TRACE_ERROR, DUP2_RSBECLIENTSESSION_PUBLICFILELISTL, "Leave: KErrInUse");
   701 			User::Leave(KErrInUse);
   783 			User::Leave(KErrInUse);
   702 			}
   784 			}
   703 		else
   785 		else
   704 			{
   786 			{
   705 			iFileList = &aFileList;
   787 			iFileList = &aFileList;
   711 			SendReceive(ESBEMsgPrepLargePublicFiles, TIpcArgs(static_cast<TInt>(aDrive), 
   793 			SendReceive(ESBEMsgPrepLargePublicFiles, TIpcArgs(static_cast<TInt>(aDrive), 
   712 				&(aGenericDataType.Externalise()), aTotalListCursor, aMaxResponseSize), 
   794 				&(aGenericDataType.Externalise()), aTotalListCursor, aMaxResponseSize), 
   713 				iCallbackHandler->iStatus);
   795 				iCallbackHandler->iStatus);
   714 			iCallbackHandler->StartL(aStatus,ELargePublicFileList);
   796 			iCallbackHandler->StartL(aStatus,ELargePublicFileList);
   715 			}
   797 			}
       
   798 		OstTraceFunctionExit0( DUP2_RSBECLIENTSESSION_PUBLICFILELISTL_EXIT );
   716 		}
   799 		}
   717 	
   800 	
   718 	void RSBEClientSession::PopulateLargePublicFileListL(TInt aResult)
   801 	void RSBEClientSession::PopulateLargePublicFileListL(TInt aResult)
   719 	/** 
   802 	/** 
   720 	Callback following the asynchronous completion of the request for the public file list
   803 	Callback following the asynchronous completion of the request for the public file list
   721 	@param aResult The error code returned by the engine as a result of the initial request
   804 	@param aResult The error code returned by the engine as a result of the initial request
   722 	*/
   805 	*/
   723 		{
   806 		{
       
   807 		OstTraceFunctionEntry0( RSBECLIENTSESSION_POPULATELARGEPUBLICFILELISTL_ENTRY );
   724 		// Retrieve the return parameters (finished flag and entry count) from SBE
   808 		// Retrieve the return parameters (finished flag and entry count) from SBE
   725 		if (KErrNone == aResult)
   809 		if (KErrNone == aResult)
   726 			{
   810 			{
   727 			TBool finishedFlag;
   811 			TBool finishedFlag;
   728 			TInt numEntries;
   812 			TInt numEntries;
   729 			TPckg<TBool> finishPkg(finishedFlag);
   813 			TPckg<TBool> finishPkg(finishedFlag);
   730 			TPckg<TInt> numEntriesPkg(numEntries);
   814 			TPckg<TInt> numEntriesPkg(numEntries);
   731 			User::LeaveIfError(SendReceive(ESBEMsgGetLargePublicFiles, TIpcArgs(&finishPkg, &numEntriesPkg)));
   815 			TInt result = SendReceive(ESBEMsgGetLargePublicFiles, TIpcArgs(&finishPkg, &numEntriesPkg));
       
   816 			LEAVEIFERROR(result, OstTrace1(TRACE_ERROR, RSBECLIENTSESSION_POPULATELARGEPUBLICFILELISTL, "Leave: %d", result));
   732 			
   817 			
   733 			*iFinished = finishPkg();
   818 			*iFinished = finishPkg();
   734 			TInt numberOfReturnedEntries = numEntriesPkg();
   819 			TInt numberOfReturnedEntries = numEntriesPkg();
   735 			
   820 			
   736 			iFileList->ResetAndDestroy();
   821 			iFileList->ResetAndDestroy();
   750 			}
   835 			}
   751 		else
   836 		else
   752 			{
   837 			{
   753 			*iFinished = EFalse;
   838 			*iFinished = EFalse;
   754 			}
   839 			}
       
   840 		OstTraceFunctionExit0( RSBECLIENTSESSION_POPULATELARGEPUBLICFILELISTL_EXIT );
   755 		}
   841 		}
   756 
   842 
   757 
   843 
   758 	//
   844 	//
   759 	// CSBECallbackHandler //
   845 	// CSBECallbackHandler //
   763 	@param aClientSession reference to a ClientSession to call callbacks on
   849 	@param aClientSession reference to a ClientSession to call callbacks on
   764 	@return pointer to an instantiated RSBEClientSession object 
   850 	@return pointer to an instantiated RSBEClientSession object 
   765 	*/
   851 	*/
   766 	CSBECallbackHandler* CSBECallbackHandler::NewL(RSBEClientSession& aClientSession)
   852 	CSBECallbackHandler* CSBECallbackHandler::NewL(RSBEClientSession& aClientSession)
   767 		{
   853 		{
       
   854 		OstTraceFunctionEntry0( CSBECALLBACKHANDLER_NEWL_ENTRY );
   768 		CSBECallbackHandler* self = new (ELeave) CSBECallbackHandler(aClientSession);
   855 		CSBECallbackHandler* self = new (ELeave) CSBECallbackHandler(aClientSession);
   769 		CleanupStack::PushL(self);
   856 		CleanupStack::PushL(self);
   770 		self->ConstructL();
   857 		self->ConstructL();
   771 		CleanupStack::Pop(self);
   858 		CleanupStack::Pop(self);
       
   859 		OstTraceFunctionExit0( CSBECALLBACKHANDLER_NEWL_EXIT );
   772 		return self;
   860 		return self;
   773 		}
   861 		}
   774 		
   862 		
   775 	/** Symbian second phase constructor */
   863 	/** Symbian second phase constructor */
   776 	void CSBECallbackHandler::ConstructL()
   864 	void CSBECallbackHandler::ConstructL()
   777 		{
   865 		{
       
   866 		OstTraceFunctionEntry0( CSBECALLBACKHANDLER_CONSTRUCTL_ENTRY );
       
   867 		OstTraceFunctionExit0( CSBECALLBACKHANDLER_CONSTRUCTL_EXIT );
   778 		}
   868 		}
   779 		
   869 		
   780 	/** Class constructor. */
   870 	/** Class constructor. */
   781 	CSBECallbackHandler::CSBECallbackHandler(RSBEClientSession& aClientSession)
   871 	CSBECallbackHandler::CSBECallbackHandler(RSBEClientSession& aClientSession)
   782 		: CActive(EPriorityNormal), iClientSession(aClientSession)
   872 		: CActive(EPriorityNormal), iClientSession(aClientSession)
   783 		{
   873 		{
       
   874 		OstTraceFunctionEntry0( CSBECALLBACKHANDLER_CSBECALLBACKHANDLER_CONS_ENTRY );
   784 		CActiveScheduler::Add(this);
   875 		CActiveScheduler::Add(this);
       
   876 		OstTraceFunctionExit0( CSBECALLBACKHANDLER_CSBECALLBACKHANDLER_CONS_EXIT );
   785 		}
   877 		}
   786 	/** Class destructor. */
   878 	/** Class destructor. */
   787 	CSBECallbackHandler::~CSBECallbackHandler()
   879 	CSBECallbackHandler::~CSBECallbackHandler()
   788 		{
   880 		{
       
   881 		OstTraceFunctionEntry0( CSBECALLBACKHANDLER_CSBECALLBACKHANDLER_DES_ENTRY );
   789 		Cancel();
   882 		Cancel();
       
   883 		OstTraceFunctionExit0( CSBECALLBACKHANDLER_CSBECALLBACKHANDLER_DES_EXIT );
   790 		}
   884 		}
   791 	
   885 	
   792 	/** Starts Callback Handler
   886 	/** Starts Callback Handler
   793 	
   887 	
   794 	@param aStatus Reference to the Client's request Status
   888 	@param aStatus Reference to the Client's request Status
   795 	@param aState State in order to make a relevant callback
   889 	@param aState State in order to make a relevant callback
   796 	
   890 	
   797 	*/	
   891 	*/	
   798 	void CSBECallbackHandler::StartL(TRequestStatus& aStatus, TState aState)
   892 	void CSBECallbackHandler::StartL(TRequestStatus& aStatus, TState aState)
   799 		{	
   893 		{	
       
   894 		OstTraceFunctionEntry0( CSBECALLBACKHANDLER_STARTL_ENTRY );
   800 		aStatus = KRequestPending;
   895 		aStatus = KRequestPending;
   801 		iObserver = &aStatus;
   896 		iObserver = &aStatus;
   802 		iState = aState;
   897 		iState = aState;
   803 		SetActive();
   898 		SetActive();
       
   899 		OstTraceFunctionExit0( CSBECALLBACKHANDLER_STARTL_EXIT );
   804 		}
   900 		}
   805 		
   901 		
   806 	/**
   902 	/**
   807 	Cancels outsanding request
   903 	Cancels outsanding request
   808 	*/
   904 	*/
   809   	void CSBECallbackHandler::CancelRequest()
   905   	void CSBECallbackHandler::CancelRequest()
   810   		{
   906   		{
       
   907   		OstTraceFunctionEntry0( CSBECALLBACKHANDLER_CANCELREQUEST_ENTRY );
   811   		Cancel();
   908   		Cancel();
       
   909   		OstTraceFunctionExit0( CSBECALLBACKHANDLER_CANCELREQUEST_EXIT );
   812   		}
   910   		}
   813 	/**
   911 	/**
   814 	CActive::RunL() implementation
   912 	CActive::RunL() implementation
   815 	*/	
   913 	*/	
   816 	void CSBECallbackHandler::RunL()
   914 	void CSBECallbackHandler::RunL()
   817 		{
   915 		{
       
   916 		OstTraceFunctionEntry0( CSBECALLBACKHANDLER_RUNL_ENTRY );
   818 		TInt result = iStatus.Int();
   917 		TInt result = iStatus.Int();
   819 		if (result >= KErrNone)
   918 		if (result >= KErrNone)
   820 			{			
   919 			{			
   821 			switch (iState)
   920 			switch (iState)
   822 				{
   921 				{
   833 				result = KErrNotSupported;
   932 				result = KErrNotSupported;
   834 				break;
   933 				break;
   835 				} //switch
   934 				} //switch
   836 			} // if
   935 			} // if
   837 			
   936 			
   838 		User::LeaveIfError(result);
   937 		LEAVEIFERROR(result, OstTrace1(TRACE_ERROR, CSBECALLBACKHANDLER_RUNL, "Leave: %d", result));
   839 		
   938 		
   840 		CompleteObserver(KErrNone);
   939 		CompleteObserver(KErrNone);
       
   940 		OstTraceFunctionExit0( CSBECALLBACKHANDLER_RUNL_EXIT );
   841 		}
   941 		}
   842 	
   942 	
   843 	/**
   943 	/**
   844 	CActive::DoCancel() implmenation
   944 	CActive::DoCancel() implmenation
   845 	Completes observer's status with KErrCancel and sets the state to None
   945 	Completes observer's status with KErrCancel and sets the state to None
   846 	*/	
   946 	*/	
   847 	void CSBECallbackHandler::DoCancel()
   947 	void CSBECallbackHandler::DoCancel()
   848 		{
   948 		{
       
   949 		OstTraceFunctionEntry0( CSBECALLBACKHANDLER_DOCANCEL_ENTRY );
   849 		iState = ENone;
   950 		iState = ENone;
   850 		// just to avoid repeating the code
   951 		// just to avoid repeating the code
   851 		CompleteObserver(KErrCancel);
   952 		CompleteObserver(KErrCancel);
       
   953 		OstTraceFunctionExit0( CSBECALLBACKHANDLER_DOCANCEL_EXIT );
   852 		}
   954 		}
   853 	
   955 	
   854 	/**
   956 	/**
   855 	Method for completing Client's request status
   957 	Method for completing Client's request status
   856 	@param aError Completion Error
   958 	@param aError Completion Error
   857 	*/
   959 	*/
   858 	void CSBECallbackHandler::CompleteObserver(TInt aError)
   960 	void CSBECallbackHandler::CompleteObserver(TInt aError)
   859 		{
   961 		{
       
   962 		OstTraceFunctionEntry0( CSBECALLBACKHANDLER_COMPLETEOBSERVER_ENTRY );
   860 		if(iObserver)
   963 		if(iObserver)
   861 			{
   964 			{
   862 			User::RequestComplete(iObserver, aError);
   965 			User::RequestComplete(iObserver, aError);
   863 			iObserver = NULL;
   966 			iObserver = NULL;
   864 			}
   967 			}
       
   968 		OstTraceFunctionExit0( CSBECALLBACKHANDLER_COMPLETEOBSERVER_EXIT );
   865 		}
   969 		}
   866 		
   970 		
   867 	/**
   971 	/**
   868 	If RunL() leaves a CompleteObserver() method called
   972 	If RunL() leaves a CompleteObserver() method called
   869 	
   973 	
   870 	@aError Error code
   974 	@aError Error code
   871 	*/
   975 	*/
   872 	TInt CSBECallbackHandler::RunError(TInt aError)
   976 	TInt CSBECallbackHandler::RunError(TInt aError)
   873 		{
   977 		{
       
   978 		OstTraceFunctionEntry0( CSBECALLBACKHANDLER_RUNERROR_ENTRY );
   874 		CompleteObserver(aError);
   979 		CompleteObserver(aError);
       
   980 		OstTraceFunctionExit0( CSBECALLBACKHANDLER_RUNERROR_EXIT );
   875 		return KErrNone;
   981 		return KErrNone;
   876 		}
   982 		}
   877 		
   983 		
   878 
   984 
   879 	} // conn namespace
   985 	} // conn namespace