messagingfw/sendas/test/sendastestmtm/src/csendastestsendoperation.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     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:
       
    14 // csendastestsendoperation.cpp
       
    15 //
       
    16 #include "csendastestsendoperation.h"
       
    17 
       
    18 #include <mtclbase.h>
       
    19 
       
    20 #include "tsendastestmtmprogress.h"
       
    21 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS  
       
    22 #include "msvconsts.h"
       
    23 #endif
       
    24 
       
    25 CSendAsTestSendOperation* CSendAsTestSendOperation::NewL(
       
    26 								CMsvSession&				aMsvSession,
       
    27 								const CMsvEntrySelection&	aSelection, 
       
    28 								const TDesC8& 				aParameter, 
       
    29 								TRequestStatus& 			aRequestStatus)
       
    30 	{
       
    31 	CSendAsTestSendOperation* self = new (ELeave) CSendAsTestSendOperation(aMsvSession, aRequestStatus);
       
    32 	CleanupStack::PushL(self);
       
    33 	self->ConstructL(aSelection, aParameter);
       
    34 	CleanupStack::Pop(self);
       
    35 	return self;	
       
    36 	}
       
    37 	
       
    38 CSendAsTestSendOperation::~CSendAsTestSendOperation()
       
    39 	{
       
    40 	}
       
    41 
       
    42 CSendAsTestSendOperation::CSendAsTestSendOperation(CMsvSession& aMsvSession, TRequestStatus& aRequestStatus)
       
    43 : CMsvSendOperation(aMsvSession, aRequestStatus)
       
    44 	{
       
    45 	}
       
    46 	
       
    47 void CSendAsTestSendOperation::ConstructL(const CMsvEntrySelection& aSelection, const TDesC8& aParameter)
       
    48 	{
       
    49 	CMsvOperation* operation = iMsvSession.TransferCommandL(aSelection, KMTMStandardFunctionsSendMessage, aParameter, iStatus);
       
    50 	// Ownership of operation passed to base class.
       
    51 	Start(operation);
       
    52 	}
       
    53 
       
    54 /*
       
    55  *	Methods from CMsvSendOperation
       
    56  */
       
    57  
       
    58 const TDesC8& CSendAsTestSendOperation::TranslateProgress(const TDesC8& aProgress)
       
    59 	{
       
    60 	TSendAsTestMtmProgressBuf progress;
       
    61 	progress.Copy(aProgress);
       
    62 	TSendAsTestMtmProgress pr = progress();
       
    63 
       
    64 	// Default progress
       
    65 	iProgress().iProgressMax = 0;
       
    66 	iProgress().iProgress = 0;
       
    67 	
       
    68 	// Convert the sendas test MTM progress into the standard send progress.
       
    69 	if( progress().iError != KErrNone )
       
    70 		{
       
    71 		iProgress().iState = ESendStateFailed;
       
    72 		}
       
    73 	else if( progress().iMessageCount == progress().iMessagesDone )
       
    74 		{
       
    75 		iProgress().iState = ESendStateDone;
       
    76 		}
       
    77 	else
       
    78 		{
       
    79 		switch( progress().iState )
       
    80 			{
       
    81 		case TSendAsTestMtmProgress::ESendAsTestInitSend:
       
    82 			{
       
    83 			iProgress().iState = ESendStateInPreparation;
       
    84 			} break;
       
    85 		case TSendAsTestMtmProgress::ESendAsTestSendNext:
       
    86 		case TSendAsTestMtmProgress::ESendAsTestSending:
       
    87 		case TSendAsTestMtmProgress::ESendAsTestMoving:
       
    88 			{
       
    89 			iProgress().iState = ESendStateSending;
       
    90 			} break;
       
    91 		case TSendAsTestMtmProgress::ESendAsTestWaiting:
       
    92 		default:
       
    93 			iProgress().iState = ESendStateWaitingToSend;	
       
    94 			break;			
       
    95 			}	
       
    96 		}
       
    97 	// Set the remaing progress info.
       
    98 	iProgress().iError			= progress().iError;
       
    99 	iProgress().iProgressMax	= progress().iMessageCount;
       
   100 	iProgress().iProgress		= progress().iMessagesDone;
       
   101 
       
   102 	return iProgress;
       
   103 	}