1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmtestenv/mmtestfw/Source/SimulProc/SimulProcSession.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,177 @@
1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <simulprocserver.h>
1.20 +
1.21 +EXPORT_C void CSimulProcServer::SessionClosed()
1.22 + {
1.23 + iSessionCount--;
1.24 + if (iSessionCount == 0)
1.25 + CActiveScheduler::Stop();
1.26 + }
1.27 +
1.28 +
1.29 +EXPORT_C CSimulProcServer::CSimulProcServer()
1.30 + : CServer2(EPriorityNormal)
1.31 + {
1.32 + }
1.33 +
1.34 +
1.35 +EXPORT_C CSimulProcServer::~CSimulProcServer()
1.36 + {
1.37 + }
1.38 +
1.39 +
1.40 +EXPORT_C CSimulProcSession::CSimulProcSession()
1.41 +/**
1.42 + * Constructor
1.43 + */
1.44 + {
1.45 + }
1.46 +
1.47 +EXPORT_C CSimulProcSession::~CSimulProcSession()
1.48 +/**
1.49 + * Destructor
1.50 + */
1.51 + {
1.52 + const CSimulProcServer* p=reinterpret_cast<const CSimulProcServer*>(Server());
1.53 +// // Shuts Down the server if this is the last open session
1.54 + const_cast<CSimulProcServer*>(p)->SessionClosed();
1.55 + }
1.56 +
1.57 +
1.58 +
1.59 +
1.60 +
1.61 +EXPORT_C CSession2* CSimulProcServer::NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMessage*/) const
1.62 +/**
1.63 + * @param RMessage - RMessage for the session open
1.64 + * Secure version
1.65 + */
1.66 + {
1.67 + CSimulProcSession* session = new (ELeave) CSimulProcSession();
1.68 + const_cast<CSimulProcServer*>(this)->iSessionCount++;
1.69 + return session;
1.70 + }
1.71 +
1.72 +
1.73 +
1.74 +EXPORT_C void CSimulProcSession::ServiceL(const RMessage2& aMessage)
1.75 +/**
1.76 + * @param aMessage - Function and data for the session
1.77 + * Session was created by pure virtual CTestServer::NewSessionL()
1.78 + * Message Functions defined in TestExecuteClient.h
1.79 + *
1.80 + * EOpenTestStep - Creates a new subsession
1.81 + * ERunTestStep - Executes the test step asynchronously
1.82 + * EAbortTestStep - Kill()'s the executing test step
1.83 + * ECloseTestStep - Free's the resource
1.84 + *
1.85 + * Secure and non-secure variants
1.86 + * There are two modes of operation:
1.87 + * Test step is opened with the shared data boolean set to FALSE:
1.88 + * Create a new CStepControl instance and hence a new thread in its own heap
1.89 + * Consecutive or Concurrent operation
1.90 + * Test step is opened with the shared data boolean set to TRUE:
1.91 + * Create a CPersistentStepControl and keep reusing it, and its thread
1.92 + * Consecutive operation only
1.93 + */
1.94 + {
1.95 + switch(aMessage.Function())
1.96 + {
1.97 + case EMMTSOpenTestStep :
1.98 + {
1.99 + TBuf<256> stepName;
1.100 + // Read the step name from the descriptor
1.101 + aMessage.ReadL(0,stepName);
1.102 + const CSimulProcServer* p=reinterpret_cast<const CSimulProcServer*>(Server());
1.103 + iTestStep = p->CreateTestStep(stepName);
1.104 + aMessage.Complete(KErrNone);
1.105 + }
1.106 +
1.107 + break;
1.108 + case EMMTSStartProcessing:
1.109 + {
1.110 + if (!iTestStep)
1.111 + aMessage.Complete(KErrNotReady);
1.112 + else
1.113 + {
1.114 + if (iActiveCallback)
1.115 + iActiveCallback->Cancel();
1.116 + delete iActiveCallback;
1.117 + iActiveCallback = NULL;
1.118 + iActiveCallback = new (ELeave) CActiveCallback(aMessage);
1.119 + iTestStep->StartProcessing(iActiveCallback->ActiveStatus());
1.120 + }
1.121 + }
1.122 +
1.123 + break;
1.124 + case EMMTSStopProcessing :
1.125 + {
1.126 + if (!iTestStep)
1.127 + aMessage.Complete(KErrNotReady);
1.128 + else
1.129 + {
1.130 + TBuf8<256> message;
1.131 + TVerdict verdict = iTestStep->EndProcessingAndReturnResult(message);
1.132 + TPckgBuf<TVerdict> v(verdict);
1.133 + aMessage.WriteL(0,v);
1.134 + aMessage.WriteL(1,message);
1.135 + aMessage.Complete(KErrNone);
1.136 + }
1.137 + break;
1.138 + }
1.139 + case EMMTSClose :
1.140 + {
1.141 + aMessage.Complete(KErrNone);
1.142 + }
1.143 +
1.144 + break;
1.145 + default:
1.146 + break;
1.147 + }
1.148 + }
1.149 +
1.150 +void CSimulProcSession::CActiveCallback::RunL()
1.151 + {
1.152 + iMessage.Complete(iStatus.Int());
1.153 + }
1.154 +
1.155 +void CSimulProcSession::CActiveCallback::DoCancel()
1.156 + {
1.157 +
1.158 + }
1.159 +
1.160 +CSimulProcSession::CActiveCallback::CActiveCallback(const RMessage2& aMessage)
1.161 + : CActive(EPriorityNormal), iMessage(aMessage)
1.162 + {
1.163 + CActiveScheduler::Add(this);
1.164 + }
1.165 +
1.166 +TRequestStatus& CSimulProcSession::CActiveCallback::ActiveStatus()
1.167 + {
1.168 + SetActive();
1.169 + iStatus = KRequestPending;
1.170 + return iStatus;
1.171 + }
1.172 +
1.173 +
1.174 +EXPORT_C CSimulProcTestStep::CSimulProcTestStep()
1.175 + {
1.176 + }
1.177 +
1.178 +EXPORT_C CSimulProcTestStep::~CSimulProcTestStep()
1.179 + {
1.180 + }