os/kernelhwsrv/userlibandfileserver/fileserver/smassstorage/cusbmassstoragesession.cpp
Update contrib.
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 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
23 #include "cusbmassstoragesession.h"
24 #include "cusbmassstoragecontroller.h"
25 #include "cusbmassstorageserver.h"
26 #include "usbmsshared.h"
29 Construct a Symbian OS session object.
31 @param aServer Service the session will be a member of
32 @param aMessage The message from the client.
33 @return A new CUsbMassStorageSession object
35 CUsbMassStorageSession* CUsbMassStorageSession::NewL(CUsbMassStorageServer& aServer)
37 CUsbMassStorageSession* r = new (ELeave) CUsbMassStorageSession(aServer);
38 CleanupStack::PushL(r);
47 @param aServer Service the session will be a member of
49 CUsbMassStorageSession::CUsbMassStorageSession(CUsbMassStorageServer& aServer)
50 : iUsbMsServer(aServer)
52 __PRINT(_L("CUsbMassStorageSession::CUsbMassStorageSession\n"));
57 2nd Phase Construction.
59 void CUsbMassStorageSession::ConstructL()
61 iUsbMsServer.IncrementSessionCount();
62 if (iUsbMsServer.SessionCount() > 1)
64 __PRINT1(_L("\tiSessionCount: %d\n"), iUsbMsServer.SessionCount());
65 // Only one session is allowed
66 User::Leave(KErrInUse);
74 CUsbMassStorageSession::~CUsbMassStorageSession()
76 iUsbMsServer.DecrementSessionCount();
80 Called when a message is received from the client.
82 @param aMessage Message received from the client
84 void CUsbMassStorageSession::ServiceL(const RMessage2& aMessage)
86 DispatchMessageL(aMessage);
90 Handles the request (in the form of a the message) received from the client
93 @param aMessage The received message
95 void CUsbMassStorageSession::DispatchMessageL(const RMessage2& aMessage)
99 switch (aMessage.Function())
102 ret = Start(aMessage);
112 aMessage.Panic(KUsbMsCliPncCat, EUsbMsPanicIllegalIPC);
116 aMessage.Complete(ret);
120 Client request to start the device.
122 @return Any error that occurred or KErrNone
124 TInt CUsbMassStorageSession::Start(const RMessage2& aMessage)
126 __PRINT(_L("CUsbMassStorageSession::Start\n"));
128 TMassStorageConfig msConfig;
129 TRAPD(err, GetMsConfigL(aMessage, msConfig));
132 __PRINT(_L("Failed to get mass storage configuration data\n"));
136 return iUsbMsServer.Controller().Start(msConfig);
140 Client request to stop the device.
142 @return Any error that occurred or KErrNone
144 TInt CUsbMassStorageSession::Stop()
146 __PRINT(_L("CUsbMassStorageSession::Stop\n"));
147 TInt err = iUsbMsServer.Controller().Stop();
152 Client request to shut down the server
156 TInt CUsbMassStorageSession::Shutdown()
158 __PRINT(_L("CUsbMassStorageSession::Shutdown\n"));
159 CActiveScheduler::Stop();
164 Get mass storage configuration data from the received message
166 void CUsbMassStorageSession::GetMsConfigL(const RMessage2& aMessage, TMassStorageConfig& aMsStorage)
168 aMessage.ReadL(0,aMsStorage.iVendorId);
169 aMessage.ReadL(1,aMsStorage.iProductId);
170 aMessage.ReadL(2,aMsStorage.iProductRev);