messagingfw/msgtestfw/TestActions/Base/src/CMtfTestActionChangeToInternalDrive.cpp
changeset 0 8e480a14352b
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 // ChangeToInternalDrive
       
    17 // [Action Parameters]
       
    18 // CMsvSession& Session   <input>: Reference to the session.
       
    19 // [Action Description]
       
    20 // Changes the current location of the mail server index to reside on the C drive.
       
    21 // Does nothing if C drive is already the one being used.
       
    22 // [APIs Used]
       
    23 // CMsvSession::ChangeDriveL
       
    24 // __ACTION_INFO_END__
       
    25 // 
       
    26 //
       
    27 
       
    28 /**
       
    29  @file
       
    30 */
       
    31 
       
    32 
       
    33 #include "CMtfTestActionChangeToInternalDrive.h"
       
    34 #include "CMtfTestCase.h"
       
    35 #include "CMtfTestActionParameters.h"
       
    36 
       
    37 #include "MSVAPI.H"
       
    38 
       
    39 
       
    40 CMtfTestAction* CMtfTestActionChangeToInternalDrive::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    41 	{
       
    42 	CMtfTestActionChangeToInternalDrive* self = new (ELeave) CMtfTestActionChangeToInternalDrive(aTestCase);
       
    43 	CleanupStack::PushL(self);
       
    44 	self->ConstructL(aActionParameters);
       
    45 	CleanupStack::Pop();
       
    46 	return self;
       
    47 	}
       
    48 	
       
    49 
       
    50 CMtfTestActionChangeToInternalDrive::CMtfTestActionChangeToInternalDrive(CMtfTestCase& aTestCase)
       
    51 	: CMtfTestAction(aTestCase)
       
    52 	{
       
    53 	}
       
    54 
       
    55 
       
    56 CMtfTestActionChangeToInternalDrive::~CMtfTestActionChangeToInternalDrive()
       
    57 	{
       
    58 	delete iOperation;
       
    59 	}
       
    60 
       
    61 void CMtfTestActionChangeToInternalDrive::ExecuteActionL()
       
    62 	{
       
    63 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionChangeToInternalDrive);
       
    64 	CActiveScheduler::Add(this);
       
    65 
       
    66 	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
       
    67 
       
    68 	RFs fs;
       
    69 	User::LeaveIfError(fs.Connect());
       
    70 	CleanupClosePushL(fs);
       
    71 	TInt currentDrive = MessageServer::CurrentDriveL(fs);
       
    72 	CleanupStack::PopAndDestroy(&fs);  // fs
       
    73 	
       
    74 	// only change if not already using the C drive	
       
    75 	if (currentDrive != EDriveC)
       
    76 		{
       
    77 		iOperation = paramSession->ChangeDriveL(TInt(EDriveC), iStatus);
       
    78 		SetActive();
       
    79 		}
       
    80 	else
       
    81 		{
       
    82 		// nothing to do then
       
    83 		TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionChangeToInternalDrive);
       
    84 		TestCase().ActionCompletedL(*this);
       
    85 		}
       
    86 	}
       
    87 
       
    88 
       
    89 void CMtfTestActionChangeToInternalDrive::DoCancel()
       
    90 	{
       
    91 	iOperation->Cancel();
       
    92 	}
       
    93 
       
    94 
       
    95 void CMtfTestActionChangeToInternalDrive::RunL()
       
    96 	{
       
    97 	User::LeaveIfError(iStatus.Int());
       
    98 	
       
    99 	// unpack the final progress
       
   100 	TPckgBuf<TMsvIndexLoadProgress> progressPack;
       
   101 	TMsvIndexLoadProgress progress;
       
   102 	progressPack.Copy(iOperation->ProgressL());
       
   103 	progress = progressPack();
       
   104 	
       
   105 	User::LeaveIfError(progress.iError);
       
   106 
       
   107 	TestCase().ActionCompletedL(*this);
       
   108 	}
       
   109