messagingfw/msgtestfw/TestActions/Base/src/CMtfTestActionDeleteMessageStore.cpp
changeset 0 8e480a14352b
child 58 6c34d0baa0b1
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2003-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 // __ACTION_INFO_BEGIN__ 
       
    15 // [Action Name]
       
    16 // DeleteMessageStore
       
    17 // [Action Parameters]
       
    18 // StorePath <input>: Name of the messaging Store path to be deleted.
       
    19 // [Action Description]
       
    20 // Deletes specified message Store.
       
    21 // [APIs Used]
       
    22 // none.
       
    23 // __ACTION_INFO_END__
       
    24 // 
       
    25 //
       
    26 
       
    27 /**
       
    28  @file
       
    29 */
       
    30 
       
    31 #include "CMtfTestActionDeleteMessageStore.h"
       
    32 #include "CMtfTestCase.h"
       
    33 #include "CMtfTestActionParameters.h"
       
    34 
       
    35 #include <s32file.h>
       
    36 
       
    37 
       
    38 CMtfTestAction* CMtfTestActionDeleteMessageStore::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    39 	{
       
    40 	CMtfTestActionDeleteMessageStore* self = new (ELeave) CMtfTestActionDeleteMessageStore(aTestCase);
       
    41 	CleanupStack::PushL(self);
       
    42 	self->ConstructL(aActionParameters);
       
    43 	CleanupStack::Pop();
       
    44 	return self;
       
    45 	}
       
    46 	
       
    47 
       
    48 CMtfTestActionDeleteMessageStore::CMtfTestActionDeleteMessageStore(CMtfTestCase& aTestCase)
       
    49 	: CMtfSynchronousTestAction(aTestCase)
       
    50 	{
       
    51 	}
       
    52 
       
    53 
       
    54 CMtfTestActionDeleteMessageStore::~CMtfTestActionDeleteMessageStore()
       
    55 	{
       
    56 	}
       
    57 
       
    58 
       
    59 void CMtfTestActionDeleteMessageStore::ExecuteActionL()
       
    60 	{
       
    61 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionDeleteMessageStore);
       
    62 	HBufC* paramStorePath = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(0));
       
    63 
       
    64 	TPtrC Store = paramStorePath->Des();
       
    65 	RFs fs;
       
    66 	fs.Connect();
       
    67 	CDictionaryFileStore* store = CDictionaryFileStore::SystemLC(fs);
       
    68 	const TUid KUidMsvMessageDriveStream = {0x1000163E};
       
    69 	if (store->IsPresentL(KUidMsvMessageDriveStream))
       
    70 		{
       
    71 		store->RemoveL(KUidMsvMessageDriveStream); 
       
    72 		store->CommitL();
       
    73 		}
       
    74 	CleanupStack::PopAndDestroy(store); 
       
    75 
       
    76 	CFileMan* fileMan = CFileMan::NewL(fs); 
       
    77 	CleanupStack::PushL(fileMan);
       
    78 	TInt error;
       
    79 	error = fileMan->RmDir(Store); 
       
    80 	error = fs.RmDir(Store); 
       
    81 	if (!(error==KErrNotFound||error==KErrNone))
       
    82 		{
       
    83 		User::Leave(KErrAccessDenied);
       
    84 		}
       
    85 	CleanupStack::PopAndDestroy(fileMan);
       
    86 	fs.Close();
       
    87 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionDeleteMessageStore);
       
    88 	TestCase().ActionCompletedL(*this);
       
    89 	}
       
    90 
       
    91