lowlevellibsandfws/pluginfw/Framework/BackupNotifierTest/BackupNotifierStateAccessor.inl
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // The implementation of the accessor class upon the CBackupNotifier
       
    15 // 
       
    16 //
       
    17 
       
    18 // ______________________________________________________________________________
       
    19 //
       
    20 _LIT(KTBackupNotifier_DumpName,"C:\\System\\Data\\Logs\\TBackupNotifier_StateDump.bin");
       
    21 
       
    22 inline TInt TBackupNotifier_StateAccessor::InvariantTest(TAny* aTestObject)
       
    23 	{
       
    24 	if(aTestObject)
       
    25 		{
       
    26 		CBackupNotifier* theBackupNotifier = REINTERPRET_CAST(CBackupNotifier*, aTestObject);
       
    27 		if(theBackupNotifier->iBackupSession == NULL)
       
    28 			{
       
    29 			return KTestBedFailedInvariant;
       
    30 			}
       
    31 		}
       
    32 	return KErrNone;
       
    33 	}
       
    34 
       
    35 inline TInt TBackupNotifier_StateAccessor::Internalize(TAny* aTestObject)
       
    36 	{
       
    37 	TInt error = KErrNone;
       
    38 	if(aTestObject != NULL)
       
    39 		{
       
    40 		CBackupNotifier* theBackupNotifier = REINTERPRET_CAST(CBackupNotifier*, aTestObject);
       
    41 		TRAP(error,InternalizeL(theBackupNotifier));
       
    42 		}
       
    43 	return error;
       
    44 	}
       
    45 
       
    46 inline TInt TBackupNotifier_StateAccessor::Externalize(TAny* aTestObject)
       
    47 	{
       
    48 	TInt error = KErrNone;
       
    49 	if(aTestObject != NULL)
       
    50 		{
       
    51 		CBackupNotifier* theBackupNotifier = REINTERPRET_CAST(CBackupNotifier*, aTestObject);
       
    52 		TRAP(error,ExternalizeL(theBackupNotifier));
       
    53 		}
       
    54 	return error;
       
    55 	}
       
    56 
       
    57 inline void TBackupNotifier_StateAccessor::InternalizeL(RFileReadStream& /* aStream */, CBackupNotifier* /* aBackupNotifier */)
       
    58 	{
       
    59 	// Has no state to restore
       
    60 	}
       
    61 
       
    62 inline void TBackupNotifier_StateAccessor::ExternalizeL(RFileWriteStream& /* aStream */, CBackupNotifier* /* aBackupNotifier */)
       
    63 	{
       
    64 	// Has no state to persist
       
    65 	}
       
    66 
       
    67 // internal helpers
       
    68 inline void TBackupNotifier_StateAccessor::InternalizeL(CBackupNotifier* aBackupNotifier)
       
    69 	{
       
    70 	// Read in the dumped data
       
    71 	RFs fs;
       
    72 	User::LeaveIfError(fs.Connect());
       
    73 	CleanupClosePushL(fs);
       
    74 	// Read the object dump
       
    75 	TParse filename;
       
    76 	filename.Set(KTBackupNotifier_DumpName(),NULL,NULL);
       
    77 	RFileReadStream stream;
       
    78 	User::LeaveIfError(stream.Open(fs,filename.FullName(), EFileRead));
       
    79 	CleanupClosePushL(stream);
       
    80 	InternalizeL(stream, aBackupNotifier);
       
    81 	CleanupStack::PopAndDestroy(2);	// stream & fs
       
    82 	}
       
    83 
       
    84 inline void TBackupNotifier_StateAccessor::ExternalizeL(CBackupNotifier* aBackupNotifier)
       
    85 	{
       
    86 	RFs fs;
       
    87 	User::LeaveIfError(fs.Connect());
       
    88 	CleanupClosePushL(fs);
       
    89 	// Write out the object dump
       
    90 	TParse filename;
       
    91 	filename.Set(KTBackupNotifier_DumpName(),NULL,NULL);
       
    92 	RFileWriteStream stream;
       
    93 	User::LeaveIfError(stream.Replace(fs,filename.FullName(), EFileWrite));
       
    94 	CleanupClosePushL(stream);
       
    95 	ExternalizeL(stream, aBackupNotifier);
       
    96 	stream.CommitL();
       
    97 	CleanupStack::PopAndDestroy(2);	// stream & fs
       
    98 	}
       
    99