backupandrestore/backupengine/src/absession.cpp
changeset 49 c20dd21d1eb4
parent 31 a26669f87b46
equal deleted inserted replaced
41:2c19c7cf5550 49:c20dd21d1eb4
    25 #include <connect/abclientserver.h>
    25 #include <connect/abclientserver.h>
    26 #include "sbedataownermanager.h"
    26 #include "sbedataownermanager.h"
    27 #include "sbedataowner.h"
    27 #include "sbedataowner.h"
    28 #include <connect/sbtypes.h>
    28 #include <connect/sbtypes.h>
    29 #include "sbepanic.h"
    29 #include "sbepanic.h"
    30 #include "sblog.h"
    30 #include "OstTraceDefinitions.h"
       
    31 #include "sbtrace.h"
       
    32 #ifdef OST_TRACE_COMPILER_IN_USE
       
    33 #include "absessionTraces.h"
       
    34 #endif
    31 
    35 
    32 namespace conn
    36 namespace conn
    33 	{
    37 	{
    34 	CABSession* CABSession::NewL(TSecureId aSecureId)
    38 	CABSession* CABSession::NewL(TSecureId aSecureId)
    35 	/**
    39 	/**
    36 	Symbian first phase constructor
    40 	Symbian first phase constructor
    37 	
    41 	
    38 	@param aSecureId The SID of the client that's connecting to this session
    42 	@param aSecureId The SID of the client that's connecting to this session
    39 	*/
    43 	*/
    40 		{
    44 		{
       
    45 		OstTraceFunctionEntry0( CABSESSION_NEWL_ENTRY );
    41 		CABSession* self = new (ELeave) CABSession(aSecureId);
    46 		CABSession* self = new (ELeave) CABSession(aSecureId);
    42 		CleanupStack::PushL(self);
    47 		CleanupStack::PushL(self);
    43 		self->ConstructL();
    48 		self->ConstructL();
    44 		CleanupStack::Pop(self);
    49 		CleanupStack::Pop(self);
       
    50 		OstTraceFunctionExit0( CABSESSION_NEWL_EXIT );
    45 		return self;
    51 		return self;
    46 		}
    52 		}
    47 		
    53 		
    48 	void CABSession::ConstructL()
    54 	void CABSession::ConstructL()
    49 	/**
    55 	/**
    50 	Symbian second phase constructor. Initialise some more of the data members
    56 	Symbian second phase constructor. Initialise some more of the data members
    51 	*/
    57 	*/
    52 		{
    58 		{
       
    59 		OstTraceFunctionEntry0( CABSESSION_CONSTRUCTL_ENTRY );
    53 		iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait;
    60 		iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait;
    54 		__LOG1("CABSession::ConstructL() [0x%08x]", iClientSID.iId);
    61 		OstTrace1(TRACE_NORMAL, CABSESSION_CONSTRUCTL , "[0x%08x]", iClientSID.iId);
       
    62 		OstTraceFunctionExit0( CABSESSION_CONSTRUCTL_EXIT );
    55 		}
    63 		}
    56 		
    64 		
    57 	CABSession::CABSession(TSecureId aSecureId) : iClientSID(aSecureId), 
    65 	CABSession::CABSession(TSecureId aSecureId) : iClientSID(aSecureId), 
    58 		iCallbackWatchdog(NULL), iActiveSchedulerWait(NULL), iABClientLeaveCode(KErrNone), 
    66 		iCallbackWatchdog(NULL), iActiveSchedulerWait(NULL), iABClientLeaveCode(KErrNone), 
    59 		iReceiveFromClientFinished(ETrue), iSendToClientBuffer(NULL, 0), 
    67 		iReceiveFromClientFinished(ETrue), iSendToClientBuffer(NULL, 0), 
    63     Class Constructor
    71     Class Constructor
    64     
    72     
    65 	@param aSecureId The SID of the client that's connecting to this session
    73 	@param aSecureId The SID of the client that's connecting to this session
    66     */
    74     */
    67 		{
    75 		{
       
    76 		OstTraceFunctionEntry0( CABSESSION_CABSESSION_CONS_ENTRY );
       
    77 		OstTraceFunctionExit0( CABSESSION_CABSESSION_CONS_EXIT );
    68 		}
    78 		}
    69 		
    79 		
    70 	CDataOwner& CABSession::DataOwnerL() const
    80 	CDataOwner& CABSession::DataOwnerL() const
    71 	/**
    81 	/**
    72 	Return the active data owner
    82 	Return the active data owner
    97 	session as a result of the callback not being returned from by the client
   107 	session as a result of the callback not being returned from by the client
    98 	
   108 	
    99 	@return An error code
   109 	@return An error code
   100 	*/
   110 	*/
   101 		{
   111 		{
   102 		__LOG1("CABSession::WatchdogExpired() - [0x%08x] Watchdog expired on session", iClientSID.iId);
   112 		OstTraceFunctionEntry0( CABSESSION_WATCHDOGEXPIRED_ENTRY );
       
   113 		OstTrace1(TRACE_NORMAL, CABSESSION_WATCHDOGEXPIRED, "[0x%08x] Watchdog expired on session", iClientSID.iId);
   103 		
   114 		
   104 		iMisbehavingClient = ETrue;			// Flag the client as having not responded
   115 		iMisbehavingClient = ETrue;			// Flag the client as having not responded
   105 		
   116 		
   106 		// Inform the Data Owner of the new status
   117 		// Inform the Data Owner of the new status
   107 		TRAP_IGNORE(DataOwnerL().SetReadyState(EDataOwnerFailed));
   118 		TRAP_IGNORE(DataOwnerL().SetReadyState(EDataOwnerFailed));
   115 			{
   126 			{
   116 			// We should never get here - only a callback call should time out
   127 			// We should never get here - only a callback call should time out
   117 			Panic(KErrTimedOut);
   128 			Panic(KErrTimedOut);
   118 			}
   129 			}
   119 			
   130 			
       
   131 		OstTraceFunctionExit0( CABSESSION_WATCHDOGEXPIRED_EXIT );
   120 		return KErrTimedOut;
   132 		return KErrTimedOut;
   121 		}
   133 		}
   122 
   134 
   123 	TBool CABSession::ConfirmedReadyForBUR() const
   135 	TBool CABSession::ConfirmedReadyForBUR() const
   124 	/** Accessor to get the state from an already existing connection
   136 	/** Accessor to get the state from an already existing connection
   141 	CABSession::~CABSession()
   153 	CABSession::~CABSession()
   142     /**
   154     /**
   143     Class destructor
   155     Class destructor
   144     */
   156     */
   145 		{
   157 		{
   146 		__LOG1("~CABSession for sid:0x%08x", iClientSID.iId);
   158 		OstTraceFunctionEntry0( CABSESSION_CABSESSION_DES_ENTRY );
       
   159 		OstTrace1(TRACE_NORMAL, CABSESSION_CABSESSION, "~CABSession for sid:0x%08x", iClientSID.iId);
   147 		delete iCallbackWatchdog;
   160 		delete iCallbackWatchdog;
   148 		iCallbackWatchdog = NULL;
   161 		iCallbackWatchdog = NULL;
   149 		
   162 		
   150 		// Remove this session from the server's session map
   163 		// Remove this session from the server's session map
   151 		// Use dynamic_cast in case that ABServer is deconstructing 
   164 		// Use dynamic_cast in case that ABServer is deconstructing 
   157 		
   170 		
   158 		// Clear up any outstanding message
   171 		// Clear up any outstanding message
   159 		HandleIPCClosingDownCallback();
   172 		HandleIPCClosingDownCallback();
   160 		
   173 		
   161 		delete iActiveSchedulerWait;
   174 		delete iActiveSchedulerWait;
       
   175 		iActiveSchedulerWait = NULL;
   162 
   176 
   163 		//
   177 		//
   164 		// If the client has detached properly, they should
   178 		// If the client has detached properly, they should
   165 		// have done this - but just in case.
   179 		// have done this - but just in case.
   166 		//DoCancelWaitForCallback();
   180 		//DoCancelWaitForCallback();
   167 		if(pServer)
   181 		if(pServer)
   168 			{
   182 			{
   169 			pServer->DropSession();
   183 			pServer->DropSession();
   170 			}
   184 			}
       
   185 		OstTraceFunctionExit0( CABSESSION_CABSESSION_DES_EXIT );
   171 		}
   186 		}
   172 		
   187 		
   173 	void CABSession::CreateL()
   188 	void CABSession::CreateL()
   174 	/**
   189 	/**
   175 	Creates a connection between active backup server and the active backup session.
   190 	Creates a connection between active backup server and the active backup session.
   176 	Increments the server's session count
   191 	Increments the server's session count
   177 	*/
   192 	*/
   178 		{
   193 		{
       
   194 		OstTraceFunctionEntry0( CABSESSION_CREATEL_ENTRY );
   179 		//
   195 		//
   180 		// Increase the servers session count.
   196 		// Increase the servers session count.
   181 		Server().AddSession();
   197 		Server().AddSession();
       
   198 		OstTraceFunctionExit0( CABSESSION_CREATEL_EXIT );
   182 		}
   199 		}
   183 
   200 
   184 	void CABSession::RestoreCompleteL(TDriveNumber aDriveNumber)
   201 	void CABSession::RestoreCompleteL(TDriveNumber aDriveNumber)
   185 	/**
   202 	/**
   186 	Signal the client that the restore operation is complete
   203 	Signal the client that the restore operation is complete
   187 
   204 
   188 	@param aDriveNumber The drive that has finished being backed up
   205 	@param aDriveNumber The drive that has finished being backed up
   189 	*/
   206 	*/
   190 		{
   207 		{
       
   208 		OstTraceFunctionEntry0( CABSESSION_RESTORECOMPLETEL_ENTRY );
   191 		MakeCallbackRestoreCompleteL(aDriveNumber);
   209 		MakeCallbackRestoreCompleteL(aDriveNumber);
       
   210 		OstTraceFunctionExit0( CABSESSION_RESTORECOMPLETEL_EXIT );
   192 		}
   211 		}
   193 
   212 
   194 	void CABSession::AllSnapshotsSuppliedL()
   213 	void CABSession::AllSnapshotsSuppliedL()
   195 	/**
   214 	/**
   196 	Lets the session know that all snapshots have been supplied.
   215 	Lets the session know that all snapshots have been supplied.
   197 	
   216 	
   198 	*/
   217 	*/
   199 		{
   218 		{
       
   219 		OstTraceFunctionEntry0( CABSESSION_ALLSNAPSHOTSSUPPLIEDL_ENTRY );
   200 		MakeCallbackAllSnapshotsSuppliedL();
   220 		MakeCallbackAllSnapshotsSuppliedL();
       
   221 		OstTraceFunctionExit0( CABSESSION_ALLSNAPSHOTSSUPPLIEDL_EXIT );
   201 		}
   222 		}
   202 
   223 
   203 	void CABSession::GetExpectedDataSizeL(TDriveNumber aDriveNumber, TUint& aSize)
   224 	void CABSession::GetExpectedDataSizeL(TDriveNumber aDriveNumber, TUint& aSize)
   204 	/**
   225 	/**
   205 	Get the expected data size from the active backup client
   226 	Get the expected data size from the active backup client
   206 
   227 
   207 	@param aDriveNumber The drive number of the data
   228 	@param aDriveNumber The drive number of the data
   208 	@param aSize Upon exit, this parameter will indicate the expected data size
   229 	@param aSize Upon exit, this parameter will indicate the expected data size
   209 	*/
   230 	*/
   210 		{
   231 		{
       
   232 		OstTraceFunctionEntry0( CABSESSION_GETEXPECTEDDATASIZEL_ENTRY );
   211 		aSize = MakeCallbackGetExpectedDataSizeL(aDriveNumber);
   233 		aSize = MakeCallbackGetExpectedDataSizeL(aDriveNumber);
       
   234 		OstTraceFunctionExit0( CABSESSION_GETEXPECTEDDATASIZEL_EXIT );
   212 		}
   235 		}
   213 		
   236 		
   214 	void CABSession::SupplyDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, TDesC8& aBuffer,
   237 	void CABSession::SupplyDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, TDesC8& aBuffer,
   215 			TBool aLastSection, TBool aSuppressInitDataOwner, TSecureId aProxySID)
   238 			TBool aLastSection, TBool aSuppressInitDataOwner, TSecureId aProxySID)
   216 	/**
   239 	/**
   222 	@param aLastSection Specifies whether or not additional SupplyDataL calls will be made (multi-part)
   245 	@param aLastSection Specifies whether or not additional SupplyDataL calls will be made (multi-part)
   223 	@param aSuppressInitDataOwner Suppress the initialisation of Data Owner
   246 	@param aSuppressInitDataOwner Suppress the initialisation of Data Owner
   224 	@param aProxySID The secure ID of the proxy
   247 	@param aProxySID The secure ID of the proxy
   225 	*/
   248 	*/
   226 		{
   249 		{
       
   250 		OstTraceFunctionEntry0( CABSESSION_SUPPLYDATAL_ENTRY );
   227 		TInt dataSizeTransferred = 0;
   251 		TInt dataSizeTransferred = 0;
   228 		TInt remainingBlockSize = 0;
   252 		TInt remainingBlockSize = 0;
   229 		TBool lastSection;
   253 		TBool lastSection;
   230 		TPtrC8 transferBlock;
   254 		TPtrC8 transferBlock;
   231 
   255 
   257 			else
   281 			else
   258 				{
   282 				{
   259 				lastSection = aLastSection;
   283 				lastSection = aLastSection;
   260 				}
   284 				}
   261 			
   285 			
   262 			__LOG2("CABSession::SupplyDataL() - [0x%08x] Supplying data to ABClient, %d bytes transferred", iClientSID.iId, dataSizeTransferred);
   286 			OstTraceExt2(TRACE_NORMAL, CABSESSION_SUPPLYDATAL, "[0x%08x] Supplying data to ABClient, %d bytes transferred", iClientSID.iId, static_cast<TInt32>(dataSizeTransferred));
   263 	
   287 	
   264 			switch(aTransferType)
   288 			switch(aTransferType)
   265 				{
   289 				{
   266 				case EActiveSnapshotData:
   290 				case EActiveSnapshotData:
   267 					{
   291 					{
   290 						}
   314 						}
   291 					MakeCallbackRestoreIncrementDataSectionL(transferBlock, lastSection);
   315 					MakeCallbackRestoreIncrementDataSectionL(transferBlock, lastSection);
   292 					} break;
   316 					} break;
   293 				default:
   317 				default:
   294 					{
   318 					{
       
   319 					OstTrace0(TRACE_ERROR, DUP1_CABSESSION_SUPPLYDATAL, "Leave: KErrNotSupported");
   295 					User::Leave(KErrNotSupported);
   320 					User::Leave(KErrNotSupported);
   296 					}
   321 					}
   297 				}
   322 				}
   298 			
   323 			
   299 			// Even if we were supposed to suppress it first time round, for a multipart supply, it 
   324 			// Even if we were supposed to suppress it first time round, for a multipart supply, it 
   300 			// shouldn't be sent again
   325 			// shouldn't be sent again
   301 			aSuppressInitDataOwner = ETrue;
   326 			aSuppressInitDataOwner = ETrue;
   302 			}
   327 			}
       
   328 		OstTraceFunctionExit0( CABSESSION_SUPPLYDATAL_EXIT );
   303 		}
   329 		}
   304 			
   330 			
   305 	void CABSession::RequestDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, TPtr8& aBuffer,
   331 	void CABSession::RequestDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, TPtr8& aBuffer,
   306 			TBool& aLastSection, TBool aSuppressInitDataOwner, TSecureId aProxySID)
   332 			TBool& aLastSection, TBool aSuppressInitDataOwner, TSecureId aProxySID)
   307 	/**
   333 	/**
   313 	@param aLastSection Upon return indicates whether or not additional RequestDataL calls will be made (multi-part)
   339 	@param aLastSection Upon return indicates whether or not additional RequestDataL calls will be made (multi-part)
   314 	@param aSuppressInitDataOwner Suppress the initialisation of Data Owner
   340 	@param aSuppressInitDataOwner Suppress the initialisation of Data Owner
   315 	@param aProxySID The secure ID of the proxy
   341 	@param aProxySID The secure ID of the proxy
   316 	*/
   342 	*/
   317 		{
   343 		{
   318         __LOG5("CABSession::RequestDataL() - START - aDrive: %c, aTType: %d, aBuffer.Ptr(): 0x%08x, aBuffer.Length(): %d, aProxySID: 0x%08x", 
   344         OstTraceFunctionEntry0( CABSESSION_REQUESTDATAL_ENTRY );
   319             aDriveNumber + 'A', aTransferType, aBuffer.Ptr(), aBuffer.Length(), aProxySID.iId );
   345         OstTraceExt5(TRACE_NORMAL, CABSESSION_REQUESTDATAL, "aDrive: %c, aTType: %d, aBuffer.Ptr(): 0x%08x, aBuffer.Length(): %d, aProxySID: 0x%08x", 
       
   346             static_cast<TInt8>(aDriveNumber + 'A'), static_cast<TInt32>(aTransferType), reinterpret_cast<TInt32>(aBuffer.Ptr()), static_cast<TInt32>(aBuffer.Length()), aProxySID.iId );
   320 
   347 
   321         TInt dataSizeTransferred = 0;
   348         TInt dataSizeTransferred = 0;
   322 		TInt remainingBlockSize = 0;
   349 		TInt remainingBlockSize = 0;
   323 		TBool lastSection = EFalse;
   350 		TBool lastSection = EFalse;
   324 		TPtr8 transferBlock(NULL, 0);
   351 		TPtr8 transferBlock(NULL, 0);
   328 			{
   355 			{
   329 			// Set max for the MidTPtr call to work. Length of this buffer is reset after each data transfer
   356 			// Set max for the MidTPtr call to work. Length of this buffer is reset after each data transfer
   330 			aBuffer.SetMax();
   357 			aBuffer.SetMax();
   331 
   358 
   332 			remainingBlockSize = aBuffer.MaxSize() - dataSizeTransferred;
   359 			remainingBlockSize = aBuffer.MaxSize() - dataSizeTransferred;
   333 			__LOG2("CABSession::RequestDataL() - dataSizeTransferred: %d, remainingBlockSize: %d", dataSizeTransferred, remainingBlockSize);
   360 			OstTraceExt2(TRACE_NORMAL, DUP1_CABSESSION_REQUESTDATAL, "dataSizeTransferred: %d, remainingBlockSize: %d", dataSizeTransferred, remainingBlockSize);
   334 
   361 
   335 			if (remainingBlockSize > KIPCMessageSize)
   362 			if (remainingBlockSize > KIPCMessageSize)
   336 				{
   363 				{
   337 				remainingBlockSize = KIPCMessageSize;
   364 				remainingBlockSize = KIPCMessageSize;
   338 				}
   365 				}
   339 				
   366 				
   340 			transferBlock.Set(aBuffer.MidTPtr(dataSizeTransferred, remainingBlockSize));
   367 			transferBlock.Set(aBuffer.MidTPtr(dataSizeTransferred, remainingBlockSize));
   341 			__LOG2("CABSession::RequestDataL() - transferBlock: 0x%08x (%d)", transferBlock.Ptr(), transferBlock.Length());
   368 			OstTraceExt2(TRACE_NORMAL, DUP2_CABSESSION_REQUESTDATAL, "transferBlock: 0x%08x (%d)", reinterpret_cast<TInt32>(transferBlock.Ptr()), static_cast<TInt32>(transferBlock.Length()));
   342 
   369 
   343 			switch(aTransferType)
   370 			switch(aTransferType)
   344 				{
   371 				{
   345 				case EActiveSnapshotData:
   372 				case EActiveSnapshotData:
   346 					{
   373 					{
   362 						}
   389 						}
   363 					MakeCallbackGetBackupDataSectionL(transferBlock, lastSection);
   390 					MakeCallbackGetBackupDataSectionL(transferBlock, lastSection);
   364 					} break;
   391 					} break;
   365 				default:
   392 				default:
   366 					{
   393 					{
       
   394 					OstTrace0(TRACE_ERROR, DUP5_CABSESSION_REQUESTDATAL, "Leave: KErrNotSupported");
   367 					User::Leave(KErrNotSupported);
   395 					User::Leave(KErrNotSupported);
   368 					}
   396 					}
   369 				}
   397 				}
   370 			
   398 			
   371 			// Even if we were supposed to suppress it first time round, for a multipart get, it 
   399 			// Even if we were supposed to suppress it first time round, for a multipart get, it 
   373 			aSuppressInitDataOwner = ETrue;
   401 			aSuppressInitDataOwner = ETrue;
   374 
   402 
   375 			// update our count to reflect the new data supplied by the client
   403 			// update our count to reflect the new data supplied by the client
   376 			dataSizeTransferred += transferBlock.Size();
   404 			dataSizeTransferred += transferBlock.Size();
   377 
   405 
   378             __LOG2("CABSession::RequestDataL() - received data so far: %d, buffer start address: 0x%08x", dataSizeTransferred, aBuffer.Ptr());
   406 			OstTraceExt2(TRACE_NORMAL, DUP3_CABSESSION_REQUESTDATAL, "received data so far: %d, buffer start address: 0x%08x", static_cast<TInt32>(dataSizeTransferred), reinterpret_cast<TInt32>(aBuffer.Ptr()));
   379             //__LOGDATA("CABSession::RequestDataL() - total received data - %S", aBuffer.Ptr(), dataSizeTransferred);
   407 
   380 
   408 			OstTraceExt2(TRACE_NORMAL, DUP4_CABSESSION_REQUESTDATAL, "[0x%08x] Requesting data from ABClient %d bytes so far)", iClientSID.iId, static_cast<TInt32>(dataSizeTransferred));
   381 			__LOG2("CABSession::RequestDataL() - [0x%08x] Requesting data from ABClient %d bytes so far)", iClientSID.iId, dataSizeTransferred);
       
   382 			
   409 			
   383 			aBuffer.SetLength(dataSizeTransferred);
   410 			aBuffer.SetLength(dataSizeTransferred);
   384 			} while (!lastSection && (dataSizeTransferred < aBuffer.MaxSize()));
   411 			} while (!lastSection && (dataSizeTransferred < aBuffer.MaxSize()));
   385 		
   412 		
   386 		aLastSection = lastSection;
   413 		aLastSection = lastSection;
       
   414 		OstTraceFunctionExit0( CABSESSION_REQUESTDATAL_EXIT );
   387 		}
   415 		}
   388 		
   416 		
   389 	void CABSession::TerminateMultiStageOperationL()
   417 	void CABSession::TerminateMultiStageOperationL()
   390 	/**
   418 	/**
   391 	Instruct the client that copying of data has been aborted and it should clean up
   419 	Instruct the client that copying of data has been aborted and it should clean up
   392 	*/
   420 	*/
   393 		{
   421 		{
       
   422 		OstTraceFunctionEntry0( CABSESSION_TERMINATEMULTISTAGEOPERATIONL_ENTRY );
   394 		MakeCallbackTerminateMultiStageOperationL();
   423 		MakeCallbackTerminateMultiStageOperationL();
       
   424 		OstTraceFunctionExit0( CABSESSION_TERMINATEMULTISTAGEOPERATIONL_EXIT );
   395 		}
   425 		}
   396 		
   426 		
   397 	TUint CABSession::GetDataChecksumL(TDriveNumber aDrive)
   427 	TUint CABSession::GetDataChecksumL(TDriveNumber aDrive)
   398 	/**
   428 	/**
   399 	Test method for validating data
   429 	Test method for validating data
   421 	the call from the Data Owner requesting an operation
   451 	the call from the Data Owner requesting an operation
   422 	
   452 	
   423 	@see CDataOwner::ReturnFromActiveCall()
   453 	@see CDataOwner::ReturnFromActiveCall()
   424 	*/
   454 	*/
   425 		{
   455 		{
       
   456 		OstTraceFunctionEntry0( CABSESSION_MADECALLBACK_ENTRY );
   426 		// Reset the leave flag
   457 		// Reset the leave flag
   427 		iABClientLeaveCode = KErrNone;
   458 		iABClientLeaveCode = KErrNone;
   428 		
   459 		
   429 		
   460 		
   430 		#ifndef _DEBUG
   461 		#ifndef _DEBUG
   438 		
   469 		
   439 		
   470 		
   440 		// Send the message back to the callback handler
   471 		// Send the message back to the callback handler
   441 		iMessage.Complete(KErrNone);
   472 		iMessage.Complete(KErrNone);
   442 		
   473 		
   443 		__LOG1("CABSession::MadeCallback() - [0x%08x] Calling ABClient to process callback", iClientSID.iId);
   474 		OstTrace1(TRACE_NORMAL, CABSESSION_MADECALLBACK, "[0x%08x] Calling ABClient to process callback", iClientSID.iId);
   444 
   475 
   445 		// Set the timeout for the callback
   476 		// Set the timeout for the callback
   446 		iActiveSchedulerWait->Start();
   477 		iActiveSchedulerWait->Start();
       
   478 		OstTraceFunctionExit0( CABSESSION_MADECALLBACK_EXIT );
   447 		}
   479 		}
   448 		
   480 		
   449 	void CABSession::ReturnFromCallback()
   481 	void CABSession::ReturnFromCallback()
   450 	/**
   482 	/**
   451 	This method is called by the ABServer once it's completed it's request from the Active Backup Client 
   483 	This method is called by the ABServer once it's completed it's request from the Active Backup Client 
   452 	so that the Data Owner appears to have made a synchronous call into the ABServer
   484 	so that the Data Owner appears to have made a synchronous call into the ABServer
   453 	*/
   485 	*/
   454 		{
   486 		{
       
   487 		OstTraceFunctionEntry0( CABSESSION_RETURNFROMCALLBACK_ENTRY );
   455 		if (iCallbackWatchdog)
   488 		if (iCallbackWatchdog)
   456 			{
   489 			{
   457 			if (iCallbackWatchdog->IsActive())
   490 			if (iCallbackWatchdog->IsActive())
   458 				{
   491 				{
   459 				iCallbackWatchdog->Cancel();
   492 				iCallbackWatchdog->Cancel();
   463 				}
   496 				}
   464 			}
   497 			}
   465 
   498 
   466 		if (iActiveSchedulerWait->IsStarted())
   499 		if (iActiveSchedulerWait->IsStarted())
   467 			{
   500 			{
   468 			__LOG1("CABSession::MadeCallback() - [0x%08x] has returned from callback - CASW::AsyncStop()", iClientSID.iId);
   501 		    OstTrace1(TRACE_NORMAL, CABSESSION_RETURNFROMCALLBACK, "[0x%08x] has returned from callback - CASW::AsyncStop()", iClientSID.iId);
   469 			iActiveSchedulerWait->AsyncStop();
   502 			iActiveSchedulerWait->AsyncStop();
   470 			}
   503 			}
       
   504 		OstTraceFunctionExit0( CABSESSION_RETURNFROMCALLBACK_EXIT );
   471 		}
   505 		}
   472 
   506 
   473 	void CABSession::TakeOwnershipOfIPCMessage(const RMessage2& aMessage)
   507 	void CABSession::TakeOwnershipOfIPCMessage(const RMessage2& aMessage)
   474 	/**
   508 	/**
   475 	Take ownership of the IPC message so that we're able to signal the Active Backup Callback Handler
   509 	Take ownership of the IPC message so that we're able to signal the Active Backup Callback Handler
   485 	Return information about the backup and restore mode to the active backup client
   519 	Return information about the backup and restore mode to the active backup client
   486 
   520 
   487 	@param aMessage The IPC message
   521 	@param aMessage The IPC message
   488 	*/
   522 	*/
   489 		{
   523 		{
   490 		__LOG1("CABSession::HandleIPCBURModeInfoL() - [0x%08x] Received IPC IPCBURModeInfo", iClientSID.iId);
   524 		OstTraceFunctionEntry0( CABSESSION_HANDLEIPCBURMODEINFOL_ENTRY );
       
   525 		OstTrace1(TRACE_NORMAL, CABSESSION_HANDLEIPCBURMODEINFOL, "[0x%08x] Received IPC IPCBURModeInfo", iClientSID.iId);
   491 
   526 
   492 		TPckgC<TBURPartType> partType(Server().DataOwnerManager().BURType());
   527 		TPckgC<TBURPartType> partType(Server().DataOwnerManager().BURType());
   493 		TPckgC<TBackupIncType> incType(Server().DataOwnerManager().IncType());
   528 		TPckgC<TBackupIncType> incType(Server().DataOwnerManager().IncType());
   494 		
   529 		
   495 		// Return the backup and restore settings to the client
   530 		// Return the backup and restore settings to the client
   496 		aMessage.WriteL(0, Server().DataOwnerManager().DriveList());
   531 		aMessage.WriteL(0, Server().DataOwnerManager().DriveList());
   497 		aMessage.WriteL(1, partType);
   532 		aMessage.WriteL(1, partType);
   498 		aMessage.WriteL(2, incType);
   533 		aMessage.WriteL(2, incType);
       
   534 		OstTraceFunctionExit0( CABSESSION_HANDLEIPCBURMODEINFOL_EXIT );
   499 		}
   535 		}
   500 		
   536 		
   501 	void CABSession::HandleIPCDoesPartialBURAffectMeL(const RMessage2& aMessage)
   537 	void CABSession::HandleIPCDoesPartialBURAffectMeL(const RMessage2& aMessage)
   502 	/**
   538 	/**
   503 	Return information about the backup and restore mode to the active backup client
   539 	Return information about the backup and restore mode to the active backup client
   504 
   540 
   505 	@param aMessage The IPC message
   541 	@param aMessage The IPC message
   506 	*/
   542 	*/
   507 		{
   543 		{
   508 		__LOG1("CABSession::HandleIPCDoesPartialBURAffectMeL() - [0x%08x] Received IPC DoesPartialBURAffectMe", iClientSID.iId);
   544 		OstTraceFunctionEntry0( CABSESSION_HANDLEIPCDOESPARTIALBURAFFECTMEL_ENTRY );
       
   545 		OstTrace1(TRACE_NORMAL, CABSESSION_HANDLEIPCDOESPARTIALBURAFFECTMEL, "[0x%08x] Received IPC DoesPartialBURAffectMe", iClientSID.iId);
   509 
   546 
   510 		TPckgC<TBool> resultPkg(Server().DataOwnerManager().IsSetForPartialL(iClientSID));
   547 		TPckgC<TBool> resultPkg(Server().DataOwnerManager().IsSetForPartialL(iClientSID));
   511 		aMessage.WriteL(0, resultPkg);
   548 		aMessage.WriteL(0, resultPkg);
       
   549 		OstTraceFunctionExit0( CABSESSION_HANDLEIPCDOESPARTIALBURAFFECTMEL_EXIT );
   512 		}
   550 		}
   513 
   551 
   514 	void CABSession::HandleIPCConfirmReadyForBURL(const RMessage2& aMessage)
   552 	void CABSession::HandleIPCConfirmReadyForBURL(const RMessage2& aMessage)
   515 	/**
   553 	/**
   516 	Respond to an event from abclient informing us that it's prepared it's data and is ready for backup
   554 	Respond to an event from abclient informing us that it's prepared it's data and is ready for backup
   517 
   555 
   518 	@param aMessage The IPC message
   556 	@param aMessage The IPC message
   519 	*/
   557 	*/
   520 		{
   558 		{
       
   559 		OstTraceFunctionEntry0( CABSESSION_HANDLEIPCCONFIRMREADYFORBURL_ENTRY );
   521 		TInt errorCode = aMessage.Int0();
   560 		TInt errorCode = aMessage.Int0();
   522 		__LOG2("CABSession::HandleIPCConfirmReadyForBURL() - [0x%08x] Received IPC ConfirmReadyForBUR, errorCode: %d", iClientSID.iId, errorCode);
   561 		OstTraceExt2(TRACE_NORMAL, CABSESSION_HANDLEIPCCONFIRMREADYFORBURL, "[0x%08x] Received IPC ConfirmReadyForBUR, errorCode: %d", iClientSID.iId, static_cast<TInt32>(errorCode));
   523 		
   562 		
   524 		// Set our internal state to indicate that the client has confirmed ready for BUR
   563 		// Set our internal state to indicate that the client has confirmed ready for BUR
   525 		iConfirmedReadyForBUR = ETrue;
   564 		iConfirmedReadyForBUR = ETrue;
   526 
   565 
   527 		TDataOwnerStatus status;
   566 		TDataOwnerStatus status;
   542 			status = EDataOwnerFailed;
   581 			status = EDataOwnerFailed;
   543 			}
   582 			}
   544 		
   583 		
   545 		// Inform the Data Owner of the new status
   584 		// Inform the Data Owner of the new status
   546 		TRAP_IGNORE(DataOwnerL().SetReadyState(status));
   585 		TRAP_IGNORE(DataOwnerL().SetReadyState(status));
       
   586 		OstTraceFunctionExit0( CABSESSION_HANDLEIPCCONFIRMREADYFORBURL_EXIT );
   547 		}
   587 		}
   548 
   588 
   549 	void CABSession::HandleIPCPropagateLeaveL(const RMessage2& aMessage)
   589 	void CABSession::HandleIPCPropagateLeaveL(const RMessage2& aMessage)
   550 	/** Leave with the propagated leave code
   590 	/** Leave with the propagated leave code
   551 
   591 
   552 	@param aMessage The IPC message
   592 	@param aMessage The IPC message
   553 	*/
   593 	*/
   554 		{
   594 		{
       
   595 		OstTraceFunctionEntry0( CABSESSION_HANDLEIPCPROPAGATELEAVEL_ENTRY );
   555 		// Leave with the propagated leave code, but not inside this ServiceL, it'll leave to the client again 
   596 		// Leave with the propagated leave code, but not inside this ServiceL, it'll leave to the client again 
   556 		// We need to ensure that it leaves through SBEngine back to SBEClient. Leave code will be checked 
   597 		// We need to ensure that it leaves through SBEngine back to SBEClient. Leave code will be checked 
   557 		// after the callback has been made and leave will be made then if necessary
   598 		// after the callback has been made and leave will be made then if necessary
   558 		iABClientLeaveCode = aMessage.Int0();
   599 		iABClientLeaveCode = aMessage.Int0();
   559 
   600 
   560 		__LOG2("CABSession::HandleIPCPropagateLeaveL() - [0x%08x] Received IPC Leave(%d)", iClientSID.iId, iABClientLeaveCode);
   601 		OstTraceExt2(TRACE_NORMAL, CABSESSION_HANDLEIPCPROPAGATELEAVEL, "[0x%08x] Received IPC Leave(%d)", iClientSID.iId, static_cast<TInt32>(iABClientLeaveCode));
       
   602 		OstTraceFunctionExit0( CABSESSION_HANDLEIPCPROPAGATELEAVEL_EXIT );
   561 		}
   603 		}
   562 
   604 
   563 	TInt CABSession::HandleIPCGetDataSyncL(const RMessage2& aMessage)
   605 	TInt CABSession::HandleIPCGetDataSyncL(const RMessage2& aMessage)
   564 	/**
   606 	/**
   565 	Handles the synchronous method called by the client to get it's data transferred
   607 	Handles the synchronous method called by the client to get it's data transferred
   566 
   608 
   567 	@param aMessage The IPC message
   609 	@param aMessage The IPC message
   568 	@return KErrNone if OK, standard error code otherwise
   610 	@return KErrNone if OK, standard error code otherwise
   569 	*/
   611 	*/
   570 		{
   612 		{
   571 		__LOG1("CABSession::HandleIPCGetDataSyncL() - [0x%08x] has requested data over IPC", iClientSID.iId);
   613 		OstTraceFunctionEntry0( CABSESSION_HANDLEIPCGETDATASYNCL_ENTRY );
       
   614 		OstTrace1(TRACE_NORMAL, CABSESSION_HANDLEIPCGETDATASYNCL, "[0x%08x] has requested data over IPC", iClientSID.iId);
   572 
   615 
   573 		TInt completionCode = KErrNone;
   616 		TInt completionCode = KErrNone;
   574 		
   617 		
   575 		if (iCallbackInProgress == static_cast<TABCallbackCommands>(aMessage.Int0()))
   618 		if (iCallbackInProgress == static_cast<TABCallbackCommands>(aMessage.Int0()))
   576 			{
   619 			{
   580 		else
   623 		else
   581 			{
   624 			{
   582 			completionCode = KErrCorrupt;
   625 			completionCode = KErrCorrupt;
   583 			}
   626 			}
   584 			
   627 			
   585 		__LOG2("CABSession::HandleIPCGetDataSyncL() - [0x%08x] completion code: %d", iClientSID.iId, completionCode);
   628 		OstTraceExt2(TRACE_NORMAL, DUP1_CABSESSION_HANDLEIPCGETDATASYNCL, "[0x%08x] completion code: %d", iClientSID.iId, static_cast<TInt32>(completionCode));
       
   629 		OstTraceFunctionExit0( CABSESSION_HANDLEIPCGETDATASYNCL_EXIT );
   586 		return completionCode;
   630 		return completionCode;
   587 		}
   631 		}
   588 
   632 
   589 	TInt CABSession::HandleIPCSendDataLengthL(const RMessage2& aMessage)
   633 	TInt CABSession::HandleIPCSendDataLengthL(const RMessage2& aMessage)
   590 	/**
   634 	/**
   592 
   636 
   593 	@param aMessage The IPC message
   637 	@param aMessage The IPC message
   594 	@return KErrNone if OK, standard error code otherwise
   638 	@return KErrNone if OK, standard error code otherwise
   595 	*/
   639 	*/
   596 		{
   640 		{
   597 		__LOG1("CABSession::HandleIPCSendDataLengthL() - [0x%08x] is informing server of the data length coming back", iClientSID.iId);
   641 		OstTraceFunctionEntry0( CABSESSION_HANDLEIPCSENDDATALENGTHL_ENTRY );
       
   642 		OstTrace1(TRACE_NORMAL, CABSESSION_HANDLEIPCSENDDATALENGTHL, "[0x%08x] is informing server of the data length coming back", iClientSID.iId);
   598 
   643 
   599 		TInt completionCode = KErrNone;
   644 		TInt completionCode = KErrNone;
   600 
   645 
   601 		// Check that this operation is as part of our expected callback
   646 		// Check that this operation is as part of our expected callback
   602 		if (iCallbackInProgress == static_cast<TABCallbackCommands>(aMessage.Int2()))
   647 		if (iCallbackInProgress == static_cast<TABCallbackCommands>(aMessage.Int2()))
   608 		else
   653 		else
   609 			{
   654 			{
   610 			completionCode = KErrCorrupt;
   655 			completionCode = KErrCorrupt;
   611 			}
   656 			}
   612 			
   657 			
       
   658 		OstTraceFunctionExit0( CABSESSION_HANDLEIPCSENDDATALENGTHL_EXIT );
   613 		return completionCode;
   659 		return completionCode;
   614 		}
   660 		}
   615 
   661 
   616 	TInt CABSession::HandleIPCClosingDownCallback()
   662 	TInt CABSession::HandleIPCClosingDownCallback()
   617 	/**
   663 	/**
   618 	Respond to the client, informing it that the server is closing down the callback interface
   664 	Respond to the client, informing it that the server is closing down the callback interface
   619 
   665 
   620 	@return KErrNone if OK, standard error code otherwise
   666 	@return KErrNone if OK, standard error code otherwise
   621 	*/
   667 	*/
   622 		{
   668 		{
       
   669 		OstTraceFunctionEntry0( CABSESSION_HANDLEIPCCLOSINGDOWNCALLBACK_ENTRY );
   623 		TInt completionCode = KErrNotFound;
   670 		TInt completionCode = KErrNotFound;
   624 		__LOG1("CABSession::HandleIPCClosingDownCallback() - [0x%08x] is closing down the callback interface", iClientSID.iId);
   671 		OstTrace1(TRACE_NORMAL, CABSESSION_HANDLEIPCCLOSINGDOWNCALLBACK, "[0x%08x] is closing down the callback interface", iClientSID.iId);
   625 		if (!iMessage.IsNull())
   672 		if (!iMessage.IsNull())
   626 			{
   673 			{
   627 			completionCode = KErrNone;
   674 			completionCode = KErrNone;
   628 			iMessage.Complete(KErrCancel);
   675 			iMessage.Complete(KErrCancel);
   629 			}
   676 			}
   630 
   677 
       
   678 		OstTraceFunctionExit0( CABSESSION_HANDLEIPCCLOSINGDOWNCALLBACK_EXIT );
   631 		return completionCode;
   679 		return completionCode;
   632 		}
   680 		}
   633 
   681 
   634 	void CABSession::ServiceL(const RMessage2& aMessage)
   682 	void CABSession::ServiceL(const RMessage2& aMessage)
   635 	/**
   683 	/**
   637 	from a client.
   685 	from a client.
   638 
   686 
   639     @param aMessage  Reference to a RMessage2 object
   687     @param aMessage  Reference to a RMessage2 object
   640 	*/
   688 	*/
   641 		{
   689 		{
       
   690  		OstTraceFunctionEntry0( CABSESSION_SERVICEL_ENTRY );
   642  		const TInt ipcMessageFn = aMessage.Function();
   691  		const TInt ipcMessageFn = aMessage.Function();
   643  		TInt completionCode = KErrNone;			// Complete the aMessage with this code
   692  		TInt completionCode = KErrNone;			// Complete the aMessage with this code
   644 
   693 
   645 	#if defined(SBE_LOGGING_ENABLED)
       
   646 		RThread client;
   694 		RThread client;
   647 		aMessage.Client(client);
   695 		aMessage.Client(client);
   648 		const TFullName name(client.FullName());
   696 		const TFullName name(client.FullName());
   649 		client.Close();
   697 		client.Close();
   650 		__LOG5("CABSession::ServiceL() - START - [0x%08x] function: %d from client: %S, iMisbehavingClient: %d, iConfirmedReadyForBUR: %d", iClientSID.iId, ipcMessageFn, &name, iMisbehavingClient, iConfirmedReadyForBUR);
   698 		OstTraceExt5(TRACE_NORMAL, CABSESSION_SERVICEL, "[0x%08x] function: %d from client: %S, iMisbehavingClient: %d, iConfirmedReadyForBUR: %d", iClientSID.iId, static_cast<TInt32>(ipcMessageFn), name, static_cast<TInt32>(iMisbehavingClient), static_cast<TInt32>(iConfirmedReadyForBUR));
   651 	#endif
       
   652 		
   699 		
   653 		switch(ipcMessageFn)
   700 		switch(ipcMessageFn)
   654 			{
   701 			{
   655 			case EABMsgBURModeInfo:
   702 			case EABMsgBURModeInfo:
   656 	            __LOG("CABSession::ServiceL() - EABMsgBURModeInfo");
   703 			    OstTrace0(TRACE_NORMAL, DUP1_CABSESSION_SERVICEL, "EABMsgBURModeInfo");
   657 				{
   704 				{
   658 				HandleIPCBURModeInfoL(aMessage);
   705 				HandleIPCBURModeInfoL(aMessage);
   659 				break;
   706 				break;
   660 				}
   707 				}
   661 			case EABMsgDoesPartialAffectMe:
   708 			case EABMsgDoesPartialAffectMe:
   662 	            __LOG("CABSession::ServiceL() - EABMsgDoesPartialAffectMe");
   709 			    OstTrace0(TRACE_NORMAL, DUP2_CABSESSION_SERVICEL, "EABMsgDoesPartialAffectMe");
   663 				{
   710 				{
   664 				HandleIPCDoesPartialBURAffectMeL(aMessage);
   711 				HandleIPCDoesPartialBURAffectMeL(aMessage);
   665 				break;
   712 				break;
   666 				}
   713 				}
   667 			case EABMsgConfirmReadyForBUR:
   714 			case EABMsgConfirmReadyForBUR:
   668 	            __LOG("CABSession::ServiceL() - EABMsgConfirmReadyForBUR");
   715 			    OstTrace0(TRACE_NORMAL, DUP3_CABSESSION_SERVICEL, "EABMsgConfirmReadyForBUR");
   669 				{
   716 				{
   670 				if (iMisbehavingClient)
   717 				if (iMisbehavingClient)
   671 					{
   718 					{
   672 					completionCode = KErrTimedOut;
   719 					completionCode = KErrTimedOut;
   673 					}
   720 					}
   679 				break;
   726 				break;
   680 				}
   727 				}
   681 			case EABMsgPrimeForCallback:
   728 			case EABMsgPrimeForCallback:
   682 			case EABMsgPrimeForCallbackAndResponse:
   729 			case EABMsgPrimeForCallbackAndResponse:
   683 			case EABMsgPrimeForCallbackAndResponseDes:
   730 			case EABMsgPrimeForCallbackAndResponseDes:
   684 	            __LOG("CABSession::ServiceL() - EABMsgPrimeForCallback/EABMsgPrimeForCallbackAndResponse/EABMsgPrimeForCallbackAndResponseDes");
   731 			    OstTrace0(TRACE_NORMAL, DUP4_CABSESSION_SERVICEL, "EABMsgPrimeForCallback/EABMsgPrimeForCallbackAndResponse/EABMsgPrimeForCallbackAndResponseDes");
   685 				{
   732 				{
   686 				CDataOwner* dataOwner = NULL;
   733 				CDataOwner* dataOwner = NULL;
   687 				TRAPD(err, dataOwner = &DataOwnerL());
   734 				TRAPD(err, dataOwner = &DataOwnerL());
   688 				// Close down the entire callback interface on a misbehaving client
   735 				// Close down the entire callback interface on a misbehaving client
   689 				if (iMisbehavingClient)
   736 				if (iMisbehavingClient)
   695 						}
   742 						}
   696 					else
   743 					else
   697 						{
   744 						{
   698 						if (err != KErrNotFound)
   745 						if (err != KErrNotFound)
   699 							{
   746 							{
       
   747 						    OstTrace1(TRACE_ERROR, DUP12_CABSESSION_SERVICEL, "Leave: %d", err);
   700 							User::Leave(err);
   748 							User::Leave(err);
   701 							}
   749 							}
   702 						}
   750 						}
   703 					}
   751 					}
   704 				else
   752 				else
   713 						}
   761 						}
   714 					else
   762 					else
   715 						{
   763 						{
   716 						if (err != KErrNotFound)
   764 						if (err != KErrNotFound)
   717 							{
   765 							{
       
   766 						    OstTrace1(TRACE_ERROR, DUP13_CABSESSION_SERVICEL, "Leave: %d", err);
   718 							User::Leave(err);
   767 							User::Leave(err);
   719 							}
   768 							}
   720 						}
   769 						}
   721 						
   770 						
   722 					// Return to the method that initiated the callback
   771 					// Return to the method that initiated the callback
   724 					}
   773 					}
   725 
   774 
   726 				break;
   775 				break;
   727 				}
   776 				}
   728 			case EABMsgPropagateLeave:
   777 			case EABMsgPropagateLeave:
   729 	            __LOG("CABSession::ServiceL() - EABMsgPropagateLeave");
   778 			    OstTrace0(TRACE_NORMAL, DUP5_CABSESSION_SERVICEL, "EABMsgPropagateLeave");
   730 				{
   779 				{
   731 				if (iMisbehavingClient)
   780 				if (iMisbehavingClient)
   732 					{
   781 					{
   733 					completionCode = KErrTimedOut;
   782 					completionCode = KErrTimedOut;
   734 					}
   783 					}
   737 					HandleIPCPropagateLeaveL(aMessage);
   786 					HandleIPCPropagateLeaveL(aMessage);
   738 					}
   787 					}
   739 				break;
   788 				break;
   740 				}
   789 				}
   741 			case EABMsgGetDataSync:
   790 			case EABMsgGetDataSync:
   742 	            __LOG("CABSession::ServiceL() - EABMsgGetDataSync");
   791 			    OstTrace0(TRACE_NORMAL, DUP6_CABSESSION_SERVICEL, "EABMsgGetDataSync");
   743 				{
   792 				{
   744 				if (iMisbehavingClient)
   793 				if (iMisbehavingClient)
   745 					{
   794 					{
   746 					completionCode = KErrTimedOut;
   795 					completionCode = KErrTimedOut;
   747 					}
   796 					}
   750 					completionCode = HandleIPCGetDataSyncL(aMessage);
   799 					completionCode = HandleIPCGetDataSyncL(aMessage);
   751 					}
   800 					}
   752 				break;
   801 				break;
   753 				}
   802 				}
   754 			case EABMsgSendDataLength:
   803 			case EABMsgSendDataLength:
   755 	            __LOG("CABSession::ServiceL() - EABMsgSendDataLength");
   804 			    OstTrace0(TRACE_NORMAL, DUP7_CABSESSION_SERVICEL, "EABMsgSendDataLength");
   756 				{
   805 				{
   757 				if (iMisbehavingClient)
   806 				if (iMisbehavingClient)
   758 					{
   807 					{
   759 					completionCode = KErrTimedOut;
   808 					completionCode = KErrTimedOut;
   760 					}
   809 					}
   763 					completionCode = HandleIPCSendDataLengthL(aMessage);
   812 					completionCode = HandleIPCSendDataLengthL(aMessage);
   764 					}
   813 					}
   765 				break;
   814 				break;
   766 				}
   815 				}
   767 			case EABMsgClosingDownCallback:
   816 			case EABMsgClosingDownCallback:
   768 	            __LOG("CABSession::ServiceL() - EABMsgClosingDownCallback");
   817 			    OstTrace0(TRACE_NORMAL, DUP8_CABSESSION_SERVICEL, "EABMsgClosingDownCallback");
   769 				{
   818 				{
   770 				completionCode = HandleIPCClosingDownCallback();
   819 				completionCode = HandleIPCClosingDownCallback();
   771 
   820 
   772 				CDataOwner* dataOwner = NULL;
   821 				CDataOwner* dataOwner = NULL;
   773 				TRAPD(err, dataOwner = &DataOwnerL());
   822 				TRAPD(err, dataOwner = &DataOwnerL());
   776 					dataOwner->SetReadyState(EDataOwnerNotConnected);
   825 					dataOwner->SetReadyState(EDataOwnerNotConnected);
   777 					}
   826 					}
   778 				break;
   827 				break;
   779 				}
   828 				}
   780 			case EABMsgGetDriveNumForSuppliedSnapshot:
   829 			case EABMsgGetDriveNumForSuppliedSnapshot:
   781 	            __LOG("CABSession::ServiceL() - EABMsgGetDriveNumForSuppliedSnapshot");
   830 			    OstTrace0(TRACE_NORMAL, DUP9_CABSESSION_SERVICEL, "EABMsgGetDriveNumForSuppliedSnapshot");
   782 				{
   831 				{
   783 				// Return the drive number to the client
   832 				// Return the drive number to the client
   784 				completionCode = static_cast<TInt>(iSuppliedSnapshotDriveNum);
   833 				completionCode = static_cast<TInt>(iSuppliedSnapshotDriveNum);
   785 				break;
   834 				break;
   786 				}
   835 				}
   799 			{
   848 			{
   800 			// If the message was a synchrnous one and has not already been completed, then complete
   849 			// If the message was a synchrnous one and has not already been completed, then complete
   801 			if (!aMessage.IsNull())
   850 			if (!aMessage.IsNull())
   802 				{
   851 				{
   803 				aMessage.Complete(completionCode);
   852 				aMessage.Complete(completionCode);
   804 		        __LOG3("CABSession::ServiceL() - END - function: %d from client: %S - COMPLETED (%d)", aMessage.Function(), &name, completionCode);
   853 				OstTraceExt3(TRACE_NORMAL, DUP10_CABSESSION_SERVICEL, "function: %d from client: %S - COMPLETED (%d)", aMessage.Function(), name, completionCode);
   805 				}
   854 				}
   806 			}
   855 			}
   807 
   856 
   808 	#if defined(SBE_LOGGING_ENABLED)
       
   809 		if	(!aMessage.IsNull())
   857 		if	(!aMessage.IsNull())
   810 			{
   858 			{
   811 			__LOG2("CABSession::ServiceL() - END - function: %d from client: %S - ASYNCH -> NOT COMPLETED", aMessage.Function(), &name);
   859 		    OstTraceExt2(TRACE_NORMAL, DUP11_CABSESSION_SERVICEL, "function: %d from client: %S - ASYNCH -> NOT COMPLETED", aMessage.Function(), name);
   812 			}
   860 			}
   813 	#endif
   861 
       
   862 		OstTraceFunctionExit0( CABSESSION_SERVICEL_EXIT );
   814 		}
   863 		}
   815 
   864 
   816 	inline CABServer& CABSession::Server() const
   865 	inline CABServer& CABSession::Server() const
   817 	/**
   866 	/**
   818 	Returns a non-cost reference to this CServer object.
   867 	Returns a non-cost reference to this CServer object.
   819 
   868 
   820 	@return The non-const reference to this.
   869 	@return The non-const reference to this.
   821 	*/
   870 	*/
   822 		{
   871 		{
       
   872 		OstTraceFunctionEntry0( CABSESSION_SERVER_ENTRY );
   823 		return *static_cast<CABServer*>(const_cast<CServer2*>(CSession2::Server()));
   873 		return *static_cast<CABServer*>(const_cast<CServer2*>(CSession2::Server()));
   824 		}
   874 		}
   825 
   875 
   826 	void CABSession::CheckCallbackAvailableL()
   876 	void CABSession::CheckCallbackAvailableL()
   827 	/**
   877 	/**
   828 	Leave if the callback is not available
   878 	Leave if the callback is not available
   829 	
   879 	
   830 	@leave KErrNotReady if the callback hasn't been primed
   880 	@leave KErrNotReady if the callback hasn't been primed
   831 	*/
   881 	*/
   832 		{
   882 		{
       
   883 		OstTraceFunctionEntry0( CABSESSION_CHECKCALLBACKAVAILABLEL_ENTRY );
   833 		TBool primed = !iMessage.IsNull();
   884 		TBool primed = !iMessage.IsNull();
   834 		
   885 		
   835 		__LOG2("CABSession::CheckCallbackAvailableL() - [0x%08x] primed: %d", iClientSID.iId, static_cast<TInt>(primed));
   886 		OstTraceExt2(TRACE_NORMAL, CABSESSION_CHECKCALLBACKAVAILABLEL, "[0x%08x] primed: %d", iClientSID.iId, static_cast<TInt32>(primed));
   836 		
   887 		
   837 		if (iMisbehavingClient)
   888 		if (iMisbehavingClient)
   838 			{
   889 			{
       
   890 		    OstTrace0(TRACE_ERROR, DUP1_CABSESSION_CHECKCALLBACKAVAILABLEL, "Leave: KErrAccessDenied");
   839 			User::Leave(KErrAccessDenied);
   891 			User::Leave(KErrAccessDenied);
   840 			}
   892 			}
   841 
   893 
   842 		if (!primed)
   894 		if (!primed)
   843 			{
   895 			{
       
   896 		    OstTrace0(TRACE_ERROR, DUP2_CABSESSION_CHECKCALLBACKAVAILABLEL, "Leave: KErrNotReady");
   844 			User::Leave(KErrNotReady);
   897 			User::Leave(KErrNotReady);
   845 			}
   898 			}
       
   899 		OstTraceFunctionExit0( CABSESSION_CHECKCALLBACKAVAILABLEL_EXIT );
   846 		}
   900 		}
   847 		
   901 		
   848 	void CABSession::MakeCallbackAllSnapshotsSuppliedL()
   902 	void CABSession::MakeCallbackAllSnapshotsSuppliedL()
   849 	/**
   903 	/**
   850 	Synchronous call to make the callback on the active backup client
   904 	Synchronous call to make the callback on the active backup client
   851 	
   905 	
   852 	*/
   906 	*/
   853 		{
   907 		{
   854 		__LOG1("CABSession::MakeCallbackAllSnapshotsSuppliedL() - [0x%08x] Calling AllSnapshotsSuppliedL", iClientSID.iId);
   908 		OstTraceFunctionEntry0( CABSESSION_MAKECALLBACKALLSNAPSHOTSSUPPLIEDL_ENTRY );
       
   909 		OstTrace1(TRACE_NORMAL, CABSESSION_MAKECALLBACKALLSNAPSHOTSSUPPLIEDL, "[0x%08x] Calling AllSnapshotsSuppliedL", iClientSID.iId);
   855 
   910 
   856 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackAllSnapshotsSupplied);
   911 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackAllSnapshotsSupplied);
   857 
   912 
   858 		CheckCallbackAvailableL();
   913 		CheckCallbackAvailableL();
   859 		
   914 		
   860 		// Make the callback
   915 		// Make the callback
   861 		iMessage.WriteL(0, callbackPkg);
   916 		iMessage.WriteL(0, callbackPkg);
   862 		MadeCallback();
   917 		MadeCallback();
       
   918 		OstTraceFunctionExit0( CABSESSION_MAKECALLBACKALLSNAPSHOTSSUPPLIEDL_EXIT );
   863 		}
   919 		}
   864 	
   920 	
   865 	void CABSession::MakeCallbackReceiveSnapshotDataL(TDriveNumber aDrive, TDesC8& aBuffer, 
   921 	void CABSession::MakeCallbackReceiveSnapshotDataL(TDriveNumber aDrive, TDesC8& aBuffer, 
   866 		TBool aLastSection)
   922 		TBool aLastSection)
   867 	/**
   923 	/**
   870 	@param aDrive Drive number that the snapshot relates to
   926 	@param aDrive Drive number that the snapshot relates to
   871 	@param aBuffer The snapshot
   927 	@param aBuffer The snapshot
   872 	@param aLastSection Flag to indicate to the client whether this is the last of a multipart snapshot
   928 	@param aLastSection Flag to indicate to the client whether this is the last of a multipart snapshot
   873 	*/
   929 	*/
   874 		{
   930 		{
   875 		__LOG1("CABSession::MakeCallbackReceiveSnapshotDataL() - [0x%08x] Calling ReceiveSnapshotData", iClientSID.iId);
   931 		OstTraceFunctionEntry0( CABSESSION_MAKECALLBACKRECEIVESNAPSHOTDATAL_ENTRY );
       
   932 		OstTrace1(TRACE_NORMAL, CABSESSION_MAKECALLBACKRECEIVESNAPSHOTDATAL, "[0x%08x] Calling ReceiveSnapshotData", iClientSID.iId);
   876 		
   933 		
   877 		iSuppliedSnapshotDriveNum = aDrive;
   934 		iSuppliedSnapshotDriveNum = aDrive;
   878 
   935 
   879 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackReceiveSnapshotData);
   936 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackReceiveSnapshotData);
   880 		TPckgC<TInt> sizePkg(aBuffer.Size());
   937 		TPckgC<TInt> sizePkg(aBuffer.Size());
   888 		iMessage.WriteL(0, callbackPkg);
   945 		iMessage.WriteL(0, callbackPkg);
   889 		iMessage.WriteL(1, sizePkg);
   946 		iMessage.WriteL(1, sizePkg);
   890 		iMessage.WriteL(2, lastSectionPkg);
   947 		iMessage.WriteL(2, lastSectionPkg);
   891 		MadeCallback();
   948 		MadeCallback();
   892 
   949 
   893 		User::LeaveIfError(iABClientLeaveCode);
   950 		LEAVEIFERROR(iABClientLeaveCode, OstTrace1(TRACE_ERROR, DUP1_CABSESSION_MAKECALLBACKRECEIVESNAPSHOTDATAL, "Leave: %d", iABClientLeaveCode));
       
   951 		OstTraceFunctionExit0( CABSESSION_MAKECALLBACKRECEIVESNAPSHOTDATAL_EXIT );
   894 		}
   952 		}
   895 
   953 
   896 	TUint CABSession::MakeCallbackGetExpectedDataSizeL(TDriveNumber aDrive)
   954 	TUint CABSession::MakeCallbackGetExpectedDataSizeL(TDriveNumber aDrive)
   897 	/**
   955 	/**
   898 	Synchronous call to make the callback on the active backup client
   956 	Synchronous call to make the callback on the active backup client
   899 	
   957 	
   900 	@param aDrive The drive to get the expected data size for
   958 	@param aDrive The drive to get the expected data size for
   901 	@return The size of the data that will be transferred
   959 	@return The size of the data that will be transferred
   902 	*/
   960 	*/
   903 		{
   961 		{
   904 		__LOG1("CABSession::MakeCallbackGetExpectedDataSizeL() - [0x%08x] Calling GetExpectedDataSize", iClientSID.iId);
   962 		OstTraceFunctionEntry0( CABSESSION_MAKECALLBACKGETEXPECTEDDATASIZEL_ENTRY );
       
   963 		OstTrace1(TRACE_NORMAL, CABSESSION_MAKECALLBACKGETEXPECTEDDATASIZEL, "[0x%08x] Calling GetExpectedDataSize", iClientSID.iId);
   905 
   964 
   906 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackGetExpectedDataSize);
   965 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackGetExpectedDataSize);
   907 		TPckgC<TDriveNumber> drivePkg(aDrive);
   966 		TPckgC<TDriveNumber> drivePkg(aDrive);
   908 		TUint returnedSize;
   967 		TUint returnedSize;
   909 
   968 
   916 		
   975 		
   917 		// Check that a response has been received
   976 		// Check that a response has been received
   918 		CheckCallbackAvailableL();
   977 		CheckCallbackAvailableL();
   919 		returnedSize = iMessage.Int3();
   978 		returnedSize = iMessage.Int3();
   920 		
   979 		
       
   980 		OstTraceFunctionExit0( CABSESSION_MAKECALLBACKGETEXPECTEDDATASIZEL_EXIT );
   921 		return returnedSize;
   981 		return returnedSize;
   922 		}
   982 		}
   923 
   983 
   924 	void CABSession::MakeCallbackGetSnapshotDataL(TDriveNumber aDrive, TPtr8& aBuffer, TBool& aFinished)
   984 	void CABSession::MakeCallbackGetSnapshotDataL(TDriveNumber aDrive, TPtr8& aBuffer, TBool& aFinished)
   925 	/**
   985 	/**
   928 	@param aDrive Drive number that the snapshot is required for
   988 	@param aDrive Drive number that the snapshot is required for
   929 	@param aBuffer The snapshot
   989 	@param aBuffer The snapshot
   930 	@param aFinished Flag to indicate to the client whether this is the last of a multipart snapshot
   990 	@param aFinished Flag to indicate to the client whether this is the last of a multipart snapshot
   931 	*/
   991 	*/
   932 		{
   992 		{
   933 		__LOG1("CABSession::MakeCallbackGetSnapshotDataL() - [0x%08x] Calling GetSnapshotData", iClientSID.iId);
   993 		OstTraceFunctionEntry0( CABSESSION_MAKECALLBACKGETSNAPSHOTDATAL_ENTRY );
       
   994 		OstTrace1(TRACE_NORMAL, CABSESSION_MAKECALLBACKGETSNAPSHOTDATAL, "[0x%08x] Calling GetSnapshotData", iClientSID.iId);
   934 
   995 
   935 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackGetSnapshotData);
   996 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackGetSnapshotData);
   936 		TPckgC<TDriveNumber> drivePkg(aDrive);
   997 		TPckgC<TDriveNumber> drivePkg(aDrive);
   937 		TPckgC<TInt> size(aBuffer.Size());
   998 		TPckgC<TInt> size(aBuffer.Size());
   938 		
   999 		
   942 		iMessage.WriteL(0, callbackPkg);
  1003 		iMessage.WriteL(0, callbackPkg);
   943 		iMessage.WriteL(1, size);
  1004 		iMessage.WriteL(1, size);
   944 		iMessage.WriteL(2, drivePkg);
  1005 		iMessage.WriteL(2, drivePkg);
   945 		MadeCallback();
  1006 		MadeCallback();
   946 
  1007 
   947 		User::LeaveIfError(iABClientLeaveCode);
  1008 		LEAVEIFERROR(iABClientLeaveCode, OstTrace1(TRACE_ERROR, DUP1_CABSESSION_MAKECALLBACKGETSNAPSHOTDATAL, "Leave: %d", iABClientLeaveCode));
   948 		
  1009 		
   949 		// Read the buffer from the client
  1010 		// Read the buffer from the client
   950 		CheckCallbackAvailableL();
  1011 		CheckCallbackAvailableL();
   951 
  1012 
   952 		TInt bufLength = iMessage.GetDesLengthL(3);
  1013 		TInt bufLength = iMessage.GetDesLengthL(3);
   953 		aBuffer.SetLength(bufLength);
  1014 		aBuffer.SetLength(bufLength);
   954 
  1015 
   955 		iMessage.ReadL(3, aBuffer);
  1016 		iMessage.ReadL(3, aBuffer);
   956 		aFinished = iReceiveFromClientFinished;
  1017 		aFinished = iReceiveFromClientFinished;
       
  1018 		OstTraceFunctionExit0( CABSESSION_MAKECALLBACKGETSNAPSHOTDATAL_EXIT );
   957 		}
  1019 		}
   958 
  1020 
   959 	void CABSession::MakeCallbackInitialiseGetBackupDataL(TDriveNumber aDrive)
  1021 	void CABSession::MakeCallbackInitialiseGetBackupDataL(TDriveNumber aDrive)
   960 	/**
  1022 	/**
   961 	Synchronous call to make the callback on the active backup client
  1023 	Synchronous call to make the callback on the active backup client
   962 	
  1024 	
   963 	@param aDrive the Drive Number
  1025 	@param aDrive the Drive Number
   964 	*/
  1026 	*/
   965 		{
  1027 		{
   966 		__LOG1("CABSession::MakeCallbackInitialiseGetBackupDataL() - [0x%08x] Calling InitGetBackupData", iClientSID.iId);
  1028 		OstTraceFunctionEntry0( CABSESSION_MAKECALLBACKINITIALISEGETBACKUPDATAL_ENTRY );
       
  1029 		OstTrace1(TRACE_NORMAL, CABSESSION_MAKECALLBACKINITIALISEGETBACKUPDATAL, "[0x%08x] Calling InitGetBackupData", iClientSID.iId);
   967 
  1030 
   968 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackInitialiseGetBackupData);
  1031 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackInitialiseGetBackupData);
   969 		TPckgC<TDriveNumber> drivePkg(aDrive);
  1032 		TPckgC<TDriveNumber> drivePkg(aDrive);
   970 		
  1033 		
   971 		iCallbackInProgress = EABCallbackInitialiseGetBackupData;
  1034 		iCallbackInProgress = EABCallbackInitialiseGetBackupData;
   973 		CheckCallbackAvailableL();
  1036 		CheckCallbackAvailableL();
   974 		iMessage.WriteL(0, callbackPkg);
  1037 		iMessage.WriteL(0, callbackPkg);
   975 		iMessage.WriteL(1, drivePkg);
  1038 		iMessage.WriteL(1, drivePkg);
   976 		MadeCallback();
  1039 		MadeCallback();
   977 
  1040 
   978 		User::LeaveIfError(iABClientLeaveCode);
  1041 		LEAVEIFERROR(iABClientLeaveCode, OstTrace1(TRACE_ERROR, DUP1_CABSESSION_MAKECALLBACKINITIALISEGETBACKUPDATAL, "Leave: %d", iABClientLeaveCode));
       
  1042 		OstTraceFunctionExit0( CABSESSION_MAKECALLBACKINITIALISEGETBACKUPDATAL_EXIT );
   979 		}
  1043 		}
   980 
  1044 
   981 	void CABSession::MakeCallbackGetBackupDataSectionL(TPtr8& aBuffer, TBool& aFinished)
  1045 	void CABSession::MakeCallbackGetBackupDataSectionL(TPtr8& aBuffer, TBool& aFinished)
   982 	/**
  1046 	/**
   983 	Synchronous call to make the callback on the active backup client
  1047 	Synchronous call to make the callback on the active backup client
   984 	
  1048 	
   985 	@param aBuffer Data returned from the client 
  1049 	@param aBuffer Data returned from the client 
   986 	@param aFinished Does the client have more data to send? 
  1050 	@param aFinished Does the client have more data to send? 
   987 	*/
  1051 	*/
   988 		{
  1052 		{
   989         __LOG2("CABSession::MakeCallbackGetBackupDataSectionL() - START - aBuffer.Ptr(): 0x%08x, aBuffer.Length(): %d", aBuffer.Ptr(), aBuffer.Length());
  1053         OstTraceFunctionEntry0( CABSESSION_MAKECALLBACKGETBACKUPDATASECTIONL_ENTRY );
   990 
  1054         OstTraceExt2(TRACE_NORMAL, CABSESSION_MAKECALLBACKGETBACKUPDATASECTIONL, "aBuffer.Ptr(): 0x%08x, aBuffer.Length(): %d", reinterpret_cast<TInt32>(aBuffer.Ptr()), static_cast<TInt32>(aBuffer.Length()));
   991         __LOG1("CABSession::MakeCallbackGetBackupDataSectionL() - [0x%08x] Calling GetBackupDataSection", iClientSID.iId);
  1055 
       
  1056         OstTrace1(TRACE_NORMAL, DUP1_CABSESSION_MAKECALLBACKGETBACKUPDATASECTIONL, "[0x%08x] Calling GetBackupDataSection", iClientSID.iId);
   992 
  1057 
   993 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackGetBackupDataSection);
  1058 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackGetBackupDataSection);
   994 		TPckgC<TInt> sizePkg(aBuffer.Size());
  1059 		TPckgC<TInt> sizePkg(aBuffer.Size());
   995 		
  1060 		
   996 		iCallbackInProgress = EABCallbackGetBackupDataSection;
  1061 		iCallbackInProgress = EABCallbackGetBackupDataSection;
   998 		CheckCallbackAvailableL();
  1063 		CheckCallbackAvailableL();
   999 		iMessage.WriteL(0, callbackPkg);
  1064 		iMessage.WriteL(0, callbackPkg);
  1000 		iMessage.WriteL(1, sizePkg);
  1065 		iMessage.WriteL(1, sizePkg);
  1001 		MadeCallback();
  1066 		MadeCallback();
  1002 
  1067 
  1003 		User::LeaveIfError(iABClientLeaveCode);
  1068 		LEAVEIFERROR(iABClientLeaveCode, OstTrace1(TRACE_ERROR, DUP3_CABSESSION_MAKECALLBACKGETBACKUPDATASECTIONL, "Leave: %d", iABClientLeaveCode));
  1004 		CheckCallbackAvailableL();
  1069 		CheckCallbackAvailableL();
  1005 		
  1070 		
  1006 		TInt bufLength = iMessage.GetDesLengthL(3);
  1071 		TInt bufLength = iMessage.GetDesLengthL(3);
  1007 		aBuffer.SetLength(bufLength);
  1072 		aBuffer.SetLength(bufLength);
  1008         iMessage.ReadL(3, aBuffer);
  1073         iMessage.ReadL(3, aBuffer);
  1009 		aFinished = iReceiveFromClientFinished;
  1074 		aFinished = iReceiveFromClientFinished;
  1010  
  1075 
  1011         //__LOGDATA("CABSession::MakeCallbackGetBackupDataSectionL() - received %S", aBuffer.Ptr(), aBuffer.Length());
  1076 		OstTraceExt2(TRACE_NORMAL, DUP2_CABSESSION_MAKECALLBACKGETBACKUPDATASECTIONL, "aBuffer.Ptr(): 0x%08x, aBuffer.Length(): %d", reinterpret_cast<TInt32>(aBuffer.Ptr()), static_cast<TInt32>(aBuffer.Length()));
  1012 
  1077         OstTraceFunctionExit0( CABSESSION_MAKECALLBACKGETBACKUPDATASECTIONL_EXIT );
  1013         __LOG2("CABSession::MakeCallbackGetBackupDataSectionL() - END - aBuffer.Ptr(): 0x%08x, aBuffer.Length(): %d", aBuffer.Ptr(), aBuffer.Length());
       
  1014         }
  1078         }
  1015 
  1079 
  1016 	void CABSession::MakeCallbackInitialiseRestoreBaseDataL(TDriveNumber aDrive)
  1080 	void CABSession::MakeCallbackInitialiseRestoreBaseDataL(TDriveNumber aDrive)
  1017 	/**
  1081 	/**
  1018 	Synchronous call to make the callback on the active backup client
  1082 	Synchronous call to make the callback on the active backup client
  1019 	
  1083 	
  1020 	@param aDrive The drive that's affected by the operation
  1084 	@param aDrive The drive that's affected by the operation
  1021 	*/
  1085 	*/
  1022 		{
  1086 		{
  1023 		__LOG1("CABSession::MakeCallbackInitialiseRestoreBaseDataL() - [0x%08x] Calling InitRestoreBaseData", iClientSID.iId);
  1087 		OstTraceFunctionEntry0( CABSESSION_MAKECALLBACKINITIALISERESTOREBASEDATAL_ENTRY );
       
  1088 		OstTrace1(TRACE_NORMAL, CABSESSION_MAKECALLBACKINITIALISERESTOREBASEDATAL, "[0x%08x] Calling InitRestoreBaseData", iClientSID.iId);
  1024 
  1089 
  1025 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackInitialiseRestoreBaseDataSection);
  1090 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackInitialiseRestoreBaseDataSection);
  1026 		TPckgC<TDriveNumber> drivePkg(aDrive);
  1091 		TPckgC<TDriveNumber> drivePkg(aDrive);
  1027 
  1092 
  1028 		iCallbackInProgress = EABCallbackInitialiseRestoreBaseDataSection;
  1093 		iCallbackInProgress = EABCallbackInitialiseRestoreBaseDataSection;
  1030 		CheckCallbackAvailableL();
  1095 		CheckCallbackAvailableL();
  1031 		iMessage.WriteL(0, callbackPkg);
  1096 		iMessage.WriteL(0, callbackPkg);
  1032 		iMessage.WriteL(1, drivePkg);
  1097 		iMessage.WriteL(1, drivePkg);
  1033 		MadeCallback();
  1098 		MadeCallback();
  1034 
  1099 
  1035 		User::LeaveIfError(iABClientLeaveCode);
  1100 		LEAVEIFERROR(iABClientLeaveCode, OstTrace1(TRACE_ERROR, DUP1_CABSESSION_MAKECALLBACKINITIALISERESTOREBASEDATAL, "Leave: %d", iABClientLeaveCode));
       
  1101 		OstTraceFunctionExit0( CABSESSION_MAKECALLBACKINITIALISERESTOREBASEDATAL_EXIT );
  1036 		}
  1102 		}
  1037 
  1103 
  1038 	void CABSession::MakeCallbackRestoreBaseDataSectionL(TDesC8& aBuffer, TBool aFinished)
  1104 	void CABSession::MakeCallbackRestoreBaseDataSectionL(TDesC8& aBuffer, TBool aFinished)
  1039 	/**
  1105 	/**
  1040 	Synchronous call to make the callback on the active backup client
  1106 	Synchronous call to make the callback on the active backup client
  1041 	
  1107 	
  1042 	@param aBuffer The data to restore
  1108 	@param aBuffer The data to restore
  1043 	@param aFinished Is this the last of a multi-part data call
  1109 	@param aFinished Is this the last of a multi-part data call
  1044 	*/
  1110 	*/
  1045 		{
  1111 		{
  1046 		__LOG1("CABSession::MakeCallbackRestoreBaseDataSectionL() - [0x%08x] Calling RestoreBaseDataSection", iClientSID.iId);
  1112 		OstTraceFunctionEntry0( CABSESSION_MAKECALLBACKRESTOREBASEDATASECTIONL_ENTRY );
       
  1113 		OstTrace1(TRACE_NORMAL, CABSESSION_MAKECALLBACKRESTOREBASEDATASECTIONL, "[0x%08x] Calling RestoreBaseDataSection", iClientSID.iId);
  1047 
  1114 
  1048 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackRestoreBaseDataSection);
  1115 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackRestoreBaseDataSection);
  1049 		TPckgC<TInt> sizePkg(aBuffer.Size());
  1116 		TPckgC<TInt> sizePkg(aBuffer.Size());
  1050 		TPckgC<TBool> lastSectionPkg(aFinished);
  1117 		TPckgC<TBool> lastSectionPkg(aFinished);
  1051 		
  1118 		
  1057 		iMessage.WriteL(0, callbackPkg);
  1124 		iMessage.WriteL(0, callbackPkg);
  1058 		iMessage.WriteL(1, sizePkg);
  1125 		iMessage.WriteL(1, sizePkg);
  1059 		iMessage.WriteL(2, lastSectionPkg);
  1126 		iMessage.WriteL(2, lastSectionPkg);
  1060 		MadeCallback();
  1127 		MadeCallback();
  1061 
  1128 
  1062 		User::LeaveIfError(iABClientLeaveCode);
  1129 		LEAVEIFERROR(iABClientLeaveCode, OstTrace1(TRACE_ERROR, DUP1_CABSESSION_MAKECALLBACKRESTOREBASEDATASECTIONL, "Leave: %d", iABClientLeaveCode));
       
  1130 		OstTraceFunctionExit0( CABSESSION_MAKECALLBACKRESTOREBASEDATASECTIONL_EXIT );
  1063 		}
  1131 		}
  1064 
  1132 
  1065 	void CABSession::MakeCallbackInitialiseRestoreIncrementDataL(TDriveNumber aDrive)
  1133 	void CABSession::MakeCallbackInitialiseRestoreIncrementDataL(TDriveNumber aDrive)
  1066 	/**
  1134 	/**
  1067 	Synchronous call to make the callback on the active backup client
  1135 	Synchronous call to make the callback on the active backup client
  1068 	
  1136 	
  1069 	@param aDrive The drive that's affected by the operation
  1137 	@param aDrive The drive that's affected by the operation
  1070 	*/
  1138 	*/
  1071 		{
  1139 		{
  1072 		__LOG1("CABSession::MakeCallbackInitialiseRestoreIncrementDataL() - [0x%08x] Calling InitRestoreIncrementData", iClientSID.iId);
  1140 		OstTraceFunctionEntry0( CABSESSION_MAKECALLBACKINITIALISERESTOREINCREMENTDATAL_ENTRY );
       
  1141 		OstTrace1(TRACE_NORMAL, CABSESSION_MAKECALLBACKINITIALISERESTOREINCREMENTDATAL, "[0x%08x] Calling InitRestoreIncrementData", iClientSID.iId);
  1073 
  1142 
  1074 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackInitialiseRestoreIncrementData);
  1143 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackInitialiseRestoreIncrementData);
  1075 		TPckgC<TDriveNumber> drivePkg(aDrive);
  1144 		TPckgC<TDriveNumber> drivePkg(aDrive);
  1076 
  1145 
  1077 		iCallbackInProgress = EABCallbackInitialiseRestoreIncrementData;
  1146 		iCallbackInProgress = EABCallbackInitialiseRestoreIncrementData;
  1079 		CheckCallbackAvailableL();
  1148 		CheckCallbackAvailableL();
  1080 		iMessage.WriteL(0, callbackPkg);
  1149 		iMessage.WriteL(0, callbackPkg);
  1081 		iMessage.WriteL(1, drivePkg);
  1150 		iMessage.WriteL(1, drivePkg);
  1082 		MadeCallback();
  1151 		MadeCallback();
  1083 
  1152 
  1084 		User::LeaveIfError(iABClientLeaveCode);
  1153 		LEAVEIFERROR(iABClientLeaveCode, OstTrace1(TRACE_ERROR, DUP1_CABSESSION_MAKECALLBACKINITIALISERESTOREINCREMENTDATAL, "Leave: %d", iABClientLeaveCode));
       
  1154 		OstTraceFunctionExit0( CABSESSION_MAKECALLBACKINITIALISERESTOREINCREMENTDATAL_EXIT );
  1085 		}
  1155 		}
  1086 
  1156 
  1087 	void CABSession::MakeCallbackRestoreIncrementDataSectionL(TDesC8& aBuffer, TBool aFinished)
  1157 	void CABSession::MakeCallbackRestoreIncrementDataSectionL(TDesC8& aBuffer, TBool aFinished)
  1088 	/**
  1158 	/**
  1089 	Synchronous call to make the callback on the active backup client
  1159 	Synchronous call to make the callback on the active backup client
  1090 	
  1160 	
  1091 	@param aBuffer The data to restore
  1161 	@param aBuffer The data to restore
  1092 	@param aFinished Is this the last of a multi-part data call
  1162 	@param aFinished Is this the last of a multi-part data call
  1093 	*/
  1163 	*/
  1094 		{
  1164 		{
  1095 		__LOG1("CABSession::MakeCallbackRestoreIncrementDataSectionL() - [0x%08x] Calling RestoreIncrementData", iClientSID.iId);
  1165 		OstTraceFunctionEntry0( CABSESSION_MAKECALLBACKRESTOREINCREMENTDATASECTIONL_ENTRY );
       
  1166 		OstTrace1(TRACE_NORMAL, CABSESSION_MAKECALLBACKRESTOREINCREMENTDATASECTIONL, "[0x%08x] Calling RestoreIncrementData", iClientSID.iId);
  1096 
  1167 
  1097 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackRestoreIncrementDataSection);
  1168 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackRestoreIncrementDataSection);
  1098 		TPckgC<TInt> sizePkg(aBuffer.Size());
  1169 		TPckgC<TInt> sizePkg(aBuffer.Size());
  1099 		TPckgC<TBool> lastSectionPkg(aFinished);
  1170 		TPckgC<TBool> lastSectionPkg(aFinished);
  1100 
  1171 
  1106 		iMessage.WriteL(0, callbackPkg);
  1177 		iMessage.WriteL(0, callbackPkg);
  1107 		iMessage.WriteL(1, sizePkg);
  1178 		iMessage.WriteL(1, sizePkg);
  1108 		iMessage.WriteL(2, lastSectionPkg);
  1179 		iMessage.WriteL(2, lastSectionPkg);
  1109 		MadeCallback();
  1180 		MadeCallback();
  1110 
  1181 
  1111 		User::LeaveIfError(iABClientLeaveCode);
  1182 		LEAVEIFERROR(iABClientLeaveCode, OstTrace1(TRACE_ERROR, DUP1_CABSESSION_MAKECALLBACKRESTOREINCREMENTDATASECTIONL, "Leave: %d", iABClientLeaveCode));
       
  1183 		OstTraceFunctionExit0( CABSESSION_MAKECALLBACKRESTOREINCREMENTDATASECTIONL_EXIT );
  1112 		}
  1184 		}
  1113 
  1185 
  1114 	void CABSession::MakeCallbackRestoreCompleteL(TDriveNumber aDrive)
  1186 	void CABSession::MakeCallbackRestoreCompleteL(TDriveNumber aDrive)
  1115 	/**
  1187 	/**
  1116 	Synchronous call to make the callback on the active backup client
  1188 	Synchronous call to make the callback on the active backup client
  1117 	
  1189 	
  1118 	@param aDrive The drive that's affected by the operation
  1190 	@param aDrive The drive that's affected by the operation
  1119 	*/
  1191 	*/
  1120 		{
  1192 		{
  1121 		__LOG1("CABSession::MakeCallbackRestoreCompleteL() - [0x%08x] Calling RestoreComplete", iClientSID.iId);
  1193 		OstTraceFunctionEntry0( CABSESSION_MAKECALLBACKRESTORECOMPLETEL_ENTRY );
       
  1194 		OstTrace1(TRACE_NORMAL, CABSESSION_MAKECALLBACKRESTORECOMPLETEL, "[0x%08x] Calling RestoreComplete", iClientSID.iId);
  1122 
  1195 
  1123 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackRestoreComplete);
  1196 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackRestoreComplete);
  1124 		TPckgC<TDriveNumber> drivePkg(aDrive);
  1197 		TPckgC<TDriveNumber> drivePkg(aDrive);
  1125 
  1198 
  1126 		iCallbackInProgress = EABCallbackRestoreComplete;
  1199 		iCallbackInProgress = EABCallbackRestoreComplete;
  1127 
  1200 
  1128 		CheckCallbackAvailableL();
  1201 		CheckCallbackAvailableL();
  1129 		iMessage.WriteL(0, callbackPkg);
  1202 		iMessage.WriteL(0, callbackPkg);
  1130 		iMessage.WriteL(1, drivePkg);
  1203 		iMessage.WriteL(1, drivePkg);
  1131 		MadeCallback();
  1204 		MadeCallback();
       
  1205 		OstTraceFunctionExit0( CABSESSION_MAKECALLBACKRESTORECOMPLETEL_EXIT );
  1132 		}
  1206 		}
  1133 
  1207 
  1134 	void CABSession::MakeCallbackInitialiseGetProxyBackupDataL(TSecureId aSID, TDriveNumber aDrive)
  1208 	void CABSession::MakeCallbackInitialiseGetProxyBackupDataL(TSecureId aSID, TDriveNumber aDrive)
  1135 	/**
  1209 	/**
  1136 	Synchronous call to make the callback on the active backup client
  1210 	Synchronous call to make the callback on the active backup client
  1137 	
  1211 	
  1138 	@param aSID The SecureId of the Proxy
  1212 	@param aSID The SecureId of the Proxy
  1139 	@param aDrive The drive that's affected by the operation
  1213 	@param aDrive The drive that's affected by the operation
  1140 	*/
  1214 	*/
  1141 		{
  1215 		{
  1142 		__LOG1("CABSession::MakeCallbackInitialiseGetProxyBackupDataL() - [0x%08x] Calling InitGetProxyBackupData", iClientSID.iId);
  1216 		OstTraceFunctionEntry0( CABSESSION_MAKECALLBACKINITIALISEGETPROXYBACKUPDATAL_ENTRY );
       
  1217 		OstTrace1(TRACE_NORMAL, CABSESSION_MAKECALLBACKINITIALISEGETPROXYBACKUPDATAL, "[0x%08x] Calling InitGetProxyBackupData", iClientSID.iId);
  1143 
  1218 
  1144 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackInitialiseGetProxyBackupData);
  1219 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackInitialiseGetProxyBackupData);
  1145 		TPckgC<TSecureId> sidPkg(aSID);
  1220 		TPckgC<TSecureId> sidPkg(aSID);
  1146 		TPckgC<TDriveNumber> drivePkg(aDrive);
  1221 		TPckgC<TDriveNumber> drivePkg(aDrive);
  1147 
  1222 
  1151 		iMessage.WriteL(0, callbackPkg);
  1226 		iMessage.WriteL(0, callbackPkg);
  1152 		iMessage.WriteL(1, sidPkg);
  1227 		iMessage.WriteL(1, sidPkg);
  1153 		iMessage.WriteL(2, drivePkg);
  1228 		iMessage.WriteL(2, drivePkg);
  1154 		MadeCallback();
  1229 		MadeCallback();
  1155 
  1230 
  1156 		User::LeaveIfError(iABClientLeaveCode);
  1231 		LEAVEIFERROR(iABClientLeaveCode, OstTrace1(TRACE_ERROR, DUP1_CABSESSION_MAKECALLBACKINITIALISEGETPROXYBACKUPDATAL, "Leave: %d", iABClientLeaveCode));
       
  1232 		OstTraceFunctionExit0( CABSESSION_MAKECALLBACKINITIALISEGETPROXYBACKUPDATAL_EXIT );
  1157 		}
  1233 		}
  1158 
  1234 
  1159 	void CABSession::MakeCallbackInitialiseRestoreProxyBaseDataL(TSecureId aSID, TDriveNumber aDrive)
  1235 	void CABSession::MakeCallbackInitialiseRestoreProxyBaseDataL(TSecureId aSID, TDriveNumber aDrive)
  1160 	/**
  1236 	/**
  1161 	Synchronous call to make the callback on the active backup client
  1237 	Synchronous call to make the callback on the active backup client
  1162 	
  1238 	
  1163 	@param aSID The SecureId of the Proxy
  1239 	@param aSID The SecureId of the Proxy
  1164 	@param aDrive The drive that's affected by the operation
  1240 	@param aDrive The drive that's affected by the operation
  1165 	*/
  1241 	*/
  1166 		{
  1242 		{
  1167 		__LOG1("CABSession::MakeCallbackInitialiseRestoreProxyBaseDataL() - [0x%08x] Calling InitRestoreProxyBaseData", iClientSID.iId);
  1243 		OstTraceFunctionEntry0( CABSESSION_MAKECALLBACKINITIALISERESTOREPROXYBASEDATAL_ENTRY );
       
  1244 		OstTrace1(TRACE_NORMAL, CABSESSION_MAKECALLBACKINITIALISERESTOREPROXYBASEDATAL, "[0x%08x] Calling InitRestoreProxyBaseData", iClientSID.iId);
  1168 
  1245 
  1169 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackInitialiseRestoreProxyBaseData);
  1246 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackInitialiseRestoreProxyBaseData);
  1170 		TPckgC<TSecureId> sidPkg(aSID);
  1247 		TPckgC<TSecureId> sidPkg(aSID);
  1171 		TPckgC<TDriveNumber> drivePkg(aDrive);
  1248 		TPckgC<TDriveNumber> drivePkg(aDrive);
  1172 
  1249 
  1176 		iMessage.WriteL(0, callbackPkg);
  1253 		iMessage.WriteL(0, callbackPkg);
  1177 		iMessage.WriteL(1, sidPkg);
  1254 		iMessage.WriteL(1, sidPkg);
  1178 		iMessage.WriteL(2, drivePkg);
  1255 		iMessage.WriteL(2, drivePkg);
  1179 		MadeCallback();
  1256 		MadeCallback();
  1180 
  1257 
  1181 		User::LeaveIfError(iABClientLeaveCode);
  1258 		LEAVEIFERROR(iABClientLeaveCode, OstTrace1(TRACE_ERROR, DUP1_CABSESSION_MAKECALLBACKINITIALISERESTOREPROXYBASEDATAL, "Leave: %d", iABClientLeaveCode));
       
  1259 		OstTraceFunctionExit0( CABSESSION_MAKECALLBACKINITIALISERESTOREPROXYBASEDATAL_EXIT );
  1182 		}
  1260 		}
  1183 
  1261 
  1184 	void CABSession::MakeCallbackTerminateMultiStageOperationL()
  1262 	void CABSession::MakeCallbackTerminateMultiStageOperationL()
  1185 	/**
  1263 	/**
  1186 	Synchronous call to make the callback on the active backup client
  1264 	Synchronous call to make the callback on the active backup client
  1187 	
  1265 	
  1188 	*/
  1266 	*/
  1189 		{
  1267 		{
  1190 		__LOG1("CABSession::MakeCallbackTerminateMultiStageOperationL() - [0x%08x] Calling TermiateMultiStageOp", iClientSID.iId);
  1268 		OstTraceFunctionEntry0( CABSESSION_MAKECALLBACKTERMINATEMULTISTAGEOPERATIONL_ENTRY );
       
  1269 		OstTrace1(TRACE_NORMAL, CABSESSION_MAKECALLBACKTERMINATEMULTISTAGEOPERATIONL, "[0x%08x] Calling TermiateMultiStageOp", iClientSID.iId);
  1191 
  1270 
  1192 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackTerminateMultiStageOperation);
  1271 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackTerminateMultiStageOperation);
  1193 
  1272 
  1194 		iCallbackInProgress = EABCallbackTerminateMultiStageOperation;
  1273 		iCallbackInProgress = EABCallbackTerminateMultiStageOperation;
  1195 
  1274 
  1196 		CheckCallbackAvailableL();
  1275 		CheckCallbackAvailableL();
  1197 		iMessage.WriteL(0, callbackPkg);
  1276 		iMessage.WriteL(0, callbackPkg);
  1198 		MadeCallback();
  1277 		MadeCallback();
       
  1278 		OstTraceFunctionExit0( CABSESSION_MAKECALLBACKTERMINATEMULTISTAGEOPERATIONL_EXIT );
  1199 		}
  1279 		}
  1200 
  1280 
  1201 	TUint CABSession::MakeCallbackGetDataChecksumL(TDriveNumber aDrive)
  1281 	TUint CABSession::MakeCallbackGetDataChecksumL(TDriveNumber aDrive)
  1202 	/**
  1282 	/**
  1203 	Synchronous call to make the callback on the active backup client
  1283 	Synchronous call to make the callback on the active backup client
  1204 	
  1284 	
  1205 	@param aDrive The drive that's affected by the operation
  1285 	@param aDrive The drive that's affected by the operation
  1206 	@return The checksum of the data
  1286 	@return The checksum of the data
  1207 	*/
  1287 	*/
  1208 		{
  1288 		{
  1209 		__LOG1("CABSession::MakeCallbackGetDataChecksumL() - [0x%08x] Calling GetDataChecksum", iClientSID.iId);
  1289 		OstTraceFunctionEntry0( CABSESSION_MAKECALLBACKGETDATACHECKSUML_ENTRY );
       
  1290 		OstTrace1(TRACE_NORMAL, CABSESSION_MAKECALLBACKGETDATACHECKSUML, "[0x%08x] Calling GetDataChecksum", iClientSID.iId);
  1210 
  1291 
  1211 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackGetDataChecksum);
  1292 		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackGetDataChecksum);
  1212 		TPckgC<TDriveNumber> drivePkg(aDrive);
  1293 		TPckgC<TDriveNumber> drivePkg(aDrive);
  1213 		TPckgBuf<TUint> returnPkg;
  1294 		TPckgBuf<TUint> returnPkg;
  1214 
  1295 
  1219 		iMessage.WriteL(1, drivePkg);
  1300 		iMessage.WriteL(1, drivePkg);
  1220 		MadeCallback();
  1301 		MadeCallback();
  1221 		
  1302 		
  1222 		iMessage.ReadL(3, returnPkg);
  1303 		iMessage.ReadL(3, returnPkg);
  1223 		
  1304 		
  1224 		return returnPkg();
  1305 		TUint ret = returnPkg();
       
  1306 		OstTraceFunctionExit0( CABSESSION_MAKECALLBACKGETDATACHECKSUML_EXIT );
       
  1307 		return ret;
  1225 		}
  1308 		}
  1226 	
  1309 	
  1227 	void CABSession::SetInvalid()
  1310 	void CABSession::SetInvalid()
  1228 	/** 
  1311 	/** 
  1229 	Invalidate this session, so that this session can not be 
  1312 	Invalidate this session, so that this session can not be