sl@0: // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // The implementation of the accessor class upon the CTransition sl@0: // sl@0: // sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KTTransition_DumpName,"C:\\System\\Data\\Logs\\TTransition_StateDump.bin"); sl@0: sl@0: inline TInt TTransition_StateAccessor::InvariantTest(TAny* aTestObject) sl@0: { sl@0: if(aTestObject) sl@0: { sl@0: CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject); sl@0: if(theTransition->iTransitionId.Length() == 0) sl@0: return KErrArgument; sl@0: } sl@0: return KErrNone; sl@0: } sl@0: sl@0: inline TInt TTransition_StateAccessor::Internalize(TAny* aTestObject) sl@0: { sl@0: TInt error = KErrNone; sl@0: if(aTestObject != NULL) sl@0: { sl@0: CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject); sl@0: TRAP(error,InternalizeL(theTransition)); sl@0: } sl@0: return error; sl@0: } sl@0: sl@0: inline TInt TTransition_StateAccessor::Externalize(TAny* aTestObject) sl@0: { sl@0: TInt error = KErrNone; sl@0: if(aTestObject != NULL) sl@0: { sl@0: CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject); sl@0: TRAP(error,ExternalizeL(theTransition)); sl@0: } sl@0: return error; sl@0: } sl@0: sl@0: inline TBool TTransition_StateAccessor::IsRepeated(TAny* aTestObject) const sl@0: { sl@0: if(aTestObject != NULL) sl@0: { sl@0: CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject); sl@0: return theTransition->iRepeatThis; sl@0: } sl@0: return EFalse; sl@0: } sl@0: sl@0: inline const TDesC* TTransition_StateAccessor::TransitionId(TAny* aTestObject) const sl@0: { sl@0: if(aTestObject != NULL) sl@0: { sl@0: CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject); sl@0: return &(theTransition->iTransitionId); sl@0: } sl@0: return NULL; sl@0: } sl@0: sl@0: inline const TTransitionInfo* TTransition_StateAccessor::TransitionInfo(TAny* aTestObject) const sl@0: { sl@0: if(aTestObject != NULL) sl@0: { sl@0: CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject); sl@0: return &(theTransition->iTransitionInfo); sl@0: } sl@0: return NULL; sl@0: } sl@0: sl@0: inline TBool TTransition_StateAccessor::BlockingFlag(TAny* aTestObject) const sl@0: { sl@0: if(aTestObject != NULL) sl@0: { sl@0: CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject); sl@0: return theTransition->iBlockingTransition; sl@0: } sl@0: return EFalse; sl@0: } sl@0: sl@0: inline TInt TTransition_StateAccessor::ErrorCode(TAny* aTestObject) const sl@0: { sl@0: if(aTestObject != NULL) sl@0: { sl@0: CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject); sl@0: return theTransition->iLeaveError; sl@0: } sl@0: return EFalse; sl@0: } sl@0: sl@0: inline TRequestStatus TTransition_StateAccessor::Status(const TAny* aTestObject) const sl@0: { sl@0: TRequestStatus status; sl@0: Mem::FillZ(&status, sizeof(status)); sl@0: if(aTestObject != NULL) sl@0: { sl@0: status = (reinterpret_cast (aTestObject))->iStatus; sl@0: } sl@0: return status; sl@0: } sl@0: sl@0: inline void TTransition_StateAccessor::InternalizeL(RFileReadStream& aStream, CTransition* aTransition) sl@0: { sl@0: aTransition->iRepeatThis = aStream.ReadInt32L(); sl@0: aTransition->iTransitionFinished = aStream.ReadInt32L(); sl@0: aTransition->iLeaveError = aStream.ReadInt32L(); sl@0: aTransition->iBlockingTransition = aStream.ReadInt32L(); sl@0: TPckg info(aTransition->iTransitionInfo); sl@0: aStream.ReadL(info); sl@0: } sl@0: sl@0: inline void TTransition_StateAccessor::ExternalizeL(RFileWriteStream& aStream, CTransition* aTransition) sl@0: { sl@0: aStream.WriteInt32L(aTransition->iRepeatThis); sl@0: aStream.WriteInt32L(aTransition->iTransitionFinished); sl@0: aStream.WriteInt32L(aTransition->iLeaveError); sl@0: aStream.WriteInt32L(aTransition->iBlockingTransition); sl@0: TPckg info(aTransition->iTransitionInfo); sl@0: aStream.WriteL(info); sl@0: } sl@0: sl@0: // internal helpers sl@0: inline void TTransition_StateAccessor::InternalizeL(CTransition* aTransition) sl@0: { sl@0: // Read in the dumped data sl@0: RFs fs; sl@0: User::LeaveIfError(fs.Connect()); sl@0: CleanupClosePushL(fs); sl@0: // Read the object dump sl@0: TParse filename; sl@0: filename.Set(KTTransition_DumpName(),NULL,NULL); sl@0: RFileReadStream stream; sl@0: User::LeaveIfError(stream.Open(fs,filename.FullName(), EFileRead)); sl@0: CleanupClosePushL(stream); sl@0: InternalizeL(stream, aTransition); sl@0: CleanupStack::PopAndDestroy(2); // stream & fs sl@0: } sl@0: sl@0: inline void TTransition_StateAccessor::ExternalizeL(CTransition* aTransition) sl@0: { sl@0: RFs fs; sl@0: User::LeaveIfError(fs.Connect()); sl@0: CleanupClosePushL(fs); sl@0: // Write out the object dump sl@0: TParse filename; sl@0: filename.Set(KTTransition_DumpName(),NULL,NULL); sl@0: RFileWriteStream stream; sl@0: User::LeaveIfError(stream.Replace(fs,filename.FullName(), EFileWrite)); sl@0: CleanupClosePushL(stream); sl@0: ExternalizeL(stream, aTransition); sl@0: stream.CommitL(); sl@0: CleanupStack::PopAndDestroy(2); // stream & fs sl@0: } sl@0: