First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include <simulprocserver.h>
18 EXPORT_C void CSimulProcServer::SessionClosed()
21 if (iSessionCount == 0)
22 CActiveScheduler::Stop();
26 EXPORT_C CSimulProcServer::CSimulProcServer()
27 : CServer2(EPriorityNormal)
32 EXPORT_C CSimulProcServer::~CSimulProcServer()
37 EXPORT_C CSimulProcSession::CSimulProcSession()
44 EXPORT_C CSimulProcSession::~CSimulProcSession()
49 const CSimulProcServer* p=reinterpret_cast<const CSimulProcServer*>(Server());
50 // // Shuts Down the server if this is the last open session
51 const_cast<CSimulProcServer*>(p)->SessionClosed();
58 EXPORT_C CSession2* CSimulProcServer::NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMessage*/) const
60 * @param RMessage - RMessage for the session open
64 CSimulProcSession* session = new (ELeave) CSimulProcSession();
65 const_cast<CSimulProcServer*>(this)->iSessionCount++;
71 EXPORT_C void CSimulProcSession::ServiceL(const RMessage2& aMessage)
73 * @param aMessage - Function and data for the session
74 * Session was created by pure virtual CTestServer::NewSessionL()
75 * Message Functions defined in TestExecuteClient.h
77 * EOpenTestStep - Creates a new subsession
78 * ERunTestStep - Executes the test step asynchronously
79 * EAbortTestStep - Kill()'s the executing test step
80 * ECloseTestStep - Free's the resource
82 * Secure and non-secure variants
83 * There are two modes of operation:
84 * Test step is opened with the shared data boolean set to FALSE:
85 * Create a new CStepControl instance and hence a new thread in its own heap
86 * Consecutive or Concurrent operation
87 * Test step is opened with the shared data boolean set to TRUE:
88 * Create a CPersistentStepControl and keep reusing it, and its thread
89 * Consecutive operation only
92 switch(aMessage.Function())
94 case EMMTSOpenTestStep :
97 // Read the step name from the descriptor
98 aMessage.ReadL(0,stepName);
99 const CSimulProcServer* p=reinterpret_cast<const CSimulProcServer*>(Server());
100 iTestStep = p->CreateTestStep(stepName);
101 aMessage.Complete(KErrNone);
105 case EMMTSStartProcessing:
108 aMessage.Complete(KErrNotReady);
112 iActiveCallback->Cancel();
113 delete iActiveCallback;
114 iActiveCallback = NULL;
115 iActiveCallback = new (ELeave) CActiveCallback(aMessage);
116 iTestStep->StartProcessing(iActiveCallback->ActiveStatus());
121 case EMMTSStopProcessing :
124 aMessage.Complete(KErrNotReady);
128 TVerdict verdict = iTestStep->EndProcessingAndReturnResult(message);
129 TPckgBuf<TVerdict> v(verdict);
130 aMessage.WriteL(0,v);
131 aMessage.WriteL(1,message);
132 aMessage.Complete(KErrNone);
138 aMessage.Complete(KErrNone);
147 void CSimulProcSession::CActiveCallback::RunL()
149 iMessage.Complete(iStatus.Int());
152 void CSimulProcSession::CActiveCallback::DoCancel()
157 CSimulProcSession::CActiveCallback::CActiveCallback(const RMessage2& aMessage)
158 : CActive(EPriorityNormal), iMessage(aMessage)
160 CActiveScheduler::Add(this);
163 TRequestStatus& CSimulProcSession::CActiveCallback::ActiveStatus()
166 iStatus = KRequestPending;
171 EXPORT_C CSimulProcTestStep::CSimulProcTestStep()
175 EXPORT_C CSimulProcTestStep::~CSimulProcTestStep()