messagingfw/msgtestfw/TestActions/Capabilities/src/cmtftestactionsendemsvcreatestore.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2004-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: Implementation of CMtfTestActionSendEMsvCreateStore
       
    14 //
       
    15 
       
    16 #include "cmtftestactionsendemsvcreatestore.h"
       
    17 
       
    18 #include <e32std.h>
       
    19 #include <e32base.h>
       
    20 
       
    21 #include <msvipc.h>
       
    22 #include "MCLIENT.H"
       
    23 #include "MSERVER.H"
       
    24 
       
    25 #include "CMtfTestCase.h"
       
    26 #include "CMtfTestActionParameters.h"
       
    27 
       
    28 #include "IPCCommandForCapsPermissions.h"
       
    29 #include "SendProxyClient.h"
       
    30 #include "SendProxyserver.h"
       
    31 
       
    32 /**
       
    33   Function : NewL
       
    34   Description :
       
    35   @internalTechnology
       
    36   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    37   @param : aActionParams - CMtfTestActionParameters
       
    38   @return : CMtfTestAction* - a base class pointer to the newly created CMtfTestActionSendEMsvCreateStore object
       
    39   @pre none
       
    40   @post none
       
    41 */
       
    42 CMtfTestAction* CMtfTestActionSendEMsvCreateStore::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    43 	{
       
    44 	CMtfTestActionSendEMsvCreateStore* self = new (ELeave) CMtfTestActionSendEMsvCreateStore(aTestCase);
       
    45 	CleanupStack::PushL(self);
       
    46 	self->ConstructL(aActionParameters);
       
    47 	CleanupStack::Pop(self);
       
    48 	return self;
       
    49 	}
       
    50 
       
    51 /**
       
    52   Function : CMtfTestActionSendEMsvCreateStore
       
    53   Description : Constructor
       
    54   @internalTechnology
       
    55   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    56   @return : N/A
       
    57   @pre none
       
    58   @post none
       
    59 */
       
    60 CMtfTestActionSendEMsvCreateStore::CMtfTestActionSendEMsvCreateStore(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase)
       
    61 	{
       
    62 	}
       
    63 
       
    64 /**
       
    65   Function : ~CMtfTestActionSendEMsvCreateStore
       
    66   Description : Destructor
       
    67   @internalTechnology
       
    68   @param :
       
    69   @return :
       
    70   @pre
       
    71   @post
       
    72 */
       
    73 CMtfTestActionSendEMsvCreateStore::~CMtfTestActionSendEMsvCreateStore()
       
    74 	{}
       
    75 
       
    76 /**
       
    77   Function : ExecuteActionL
       
    78   Description : Entry point for the this test action in the test framework
       
    79   @internalTechnology
       
    80   @param : none
       
    81   @return : void
       
    82   @pre none
       
    83   @post none
       
    84 */
       
    85 void CMtfTestActionSendEMsvCreateStore::ExecuteActionL()
       
    86 	{
       
    87 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendEMsvCreateStore);
       
    88 	// input params
       
    89 	TUid mtmUid = KUidMsgTypeIMAP4 ; 
       
    90 	TInt pass = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(1) );
       
    91 
       
    92 	RProxyServerSession RPSS;
       
    93 	TInt error = RPSS.Connect();
       
    94 	CleanupClosePushL(RPSS);
       
    95 
       
    96 	// Will auto start the server if not started.
       
    97 	if (error!=KErrNone)
       
    98 		{
       
    99 		TestCase().ERR_PRINTF1(_L("CMtfTestActionSendEMsvCreateStore :: Unable to start proxy server. !"));
       
   100 		TestCase().SetTestStepResult(EFail);
       
   101 		}
       
   102 	else
       
   103 		{
       
   104 		TInt32 serverCaps;
       
   105 		RPSS.GetServerCapabilities(serverCaps);
       
   106 		TestCase().INFO_PRINTF2(_L("Proxy Server has capabilities: %x"), serverCaps);
       
   107 
       
   108 		RPointerArray<CFieldPair> fieldPairList;
       
   109 		CleanupClosePushL(fieldPairList);
       
   110 
       
   111 		CFieldPair *fieldPair = new(ELeave) CFieldPair();
       
   112 		CleanupStack::PushL(fieldPair);
       
   113 
       
   114 		fieldPair->iFieldType = ETextField;
       
   115 
       
   116 		_LIT16(KFrom, "From");
       
   117 		fieldPair->iFieldName = KFrom().AllocL();
       
   118 		_LIT16(KTo, "To");
       
   119 		fieldPair->iFieldName = KTo().AllocL();
       
   120 		_LIT16(KCc, "CC");
       
   121 		fieldPair->iFieldName = KCc().AllocL();
       
   122 		_LIT16(KBcc, "BCC");
       
   123 		fieldPair->iFieldName = KBcc().AllocL();
       
   124 		_LIT16(KSubject, "Subject");
       
   125 		fieldPair->iFieldName = KSubject().AllocL();
       
   126 
       
   127 		fieldPairList.AppendL(fieldPair);
       
   128 
       
   129 		HBufC8* buffer = HBufC8::New(KMsvSessionBufferLength);
       
   130 
       
   131 		TMsvPackedHeaderStructure packedHeaderStruct(buffer);
       
   132 		TInt error = packedHeaderStruct.Pack(fieldPairList);
       
   133 		while(error!=KErrNone)
       
   134 			{
       
   135 			// increase the size of the buffer and try again
       
   136 			buffer->Des().SetLength(0); // to avoid copying contents
       
   137 			buffer = buffer->ReAllocL(buffer->Des().MaxSize() + KMsvSessionBufferLength);
       
   138 			error = packedHeaderStruct.Pack(fieldPairList);
       
   139 		}
       
   140 
       
   141 		TInt err = RPSS.SendReceive(EMsvCreateStore, TIpcArgs(mtmUid.iUid, buffer));
       
   142 		IPCCommandReportPassOrFailForCapsPermissions( TestCase(), KMsvServerName, err , pass );
       
   143 
       
   144 		CleanupStack::Pop(); // CFieldPair
       
   145 		delete fieldPair;
       
   146 		CleanupStack::PopAndDestroy();
       
   147 		}
       
   148 
       
   149 	CleanupStack::Check(&RPSS);
       
   150 	CleanupStack::PopAndDestroy(); // RPSS
       
   151 
       
   152 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendEMsvCreateStore);
       
   153 	TestCase().ActionCompletedL(*this);
       
   154 	}