os/kernelhwsrv/kerneltest/f32test/shostmassstorage/testclient/usbtestmsclient/cusbmassstoragesession.cpp
Update contrib.
1 // Copyright (c) 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 the License "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.
14 // Implements a Session of a Symbian OS server for the RUsbMassStorage API
28 #include "usbmsshared.h"
31 #include "cusbmassstoragesession.h"
32 #include "cusbmassstoragecontroller.h"
33 #include "cusbmassstorageserver.h"
39 Construct a Symbian OS session object.
41 @param aServer Service the session will be a member of
42 @param aMessage The message from the client.
43 @return A new CUsbMassStorageSession object
45 CUsbMassStorageSession* CUsbMassStorageSession::NewL(CUsbMassStorageServer& aServer)
48 CUsbMassStorageSession* r = new (ELeave) CUsbMassStorageSession(aServer);
49 CleanupStack::PushL(r);
58 @param aServer Service the session will be a member of
60 CUsbMassStorageSession::CUsbMassStorageSession(CUsbMassStorageServer& aServer)
61 : iUsbMsServer(aServer)
68 2nd Phase Construction.
70 void CUsbMassStorageSession::ConstructL()
73 iUsbMsServer.IncrementSessionCount();
74 if (iUsbMsServer.SessionCount() > 1)
76 __PRINT1(_L("\tiSessionCount: %d\n"), iUsbMsServer.SessionCount());
77 // Only one session is allowed
78 User::Leave(KErrInUse);
86 CUsbMassStorageSession::~CUsbMassStorageSession()
89 iUsbMsServer.DecrementSessionCount();
93 Called when a message is received from the client.
95 @param aMessage Message received from the client
97 void CUsbMassStorageSession::ServiceL(const RMessage2& aMessage)
100 DispatchMessageL(aMessage);
104 Handles the request (in the form of a the message) received from the client
107 @param aMessage The received message
109 void CUsbMassStorageSession::DispatchMessageL(const RMessage2& aMessage)
114 switch (aMessage.Function())
117 ret = Start(aMessage);
127 aMessage.Panic(KUsbMsCliPncCat, EUsbMsPanicIllegalIPC);
131 aMessage.Complete(ret);
135 Client request to start the device.
137 @return Any error that occurred or KErrNone
139 TInt CUsbMassStorageSession::Start(const RMessage2& aMessage)
142 __PRINT(_L("CUsbMassStorageSession::Start\n"));
144 TMassStorageConfig msConfig;
145 TRAPD(err, GetMsConfigL(aMessage, msConfig));
148 __PRINT(_L("Failed to get mass storage configuration data\n"));
152 return iUsbMsServer.Controller().Start(msConfig);
156 Client request to stop the device.
158 @return Any error that occurred or KErrNone
160 TInt CUsbMassStorageSession::Stop()
163 TInt err = iUsbMsServer.Controller().Stop();
168 Client request to shut down the server
172 TInt CUsbMassStorageSession::Shutdown()
175 CActiveScheduler::Stop();
180 Get mass storage configuration data from the received message
182 void CUsbMassStorageSession::GetMsConfigL(const RMessage2& aMessage, TMassStorageConfig& aMsStorage)
185 aMessage.ReadL(0,aMsStorage.iVendorId);
186 aMessage.ReadL(1,aMsStorage.iProductId);
187 aMessage.ReadL(2,aMsStorage.iProductRev);