diff -r ff5437e4337c -r 48e57fb1237e userlibandfileserver/fileserver/smassstorage/cusbmassstoragesession.cpp --- a/userlibandfileserver/fileserver/smassstorage/cusbmassstoragesession.cpp Wed Oct 06 17:13:14 2010 +0100 +++ b/userlibandfileserver/fileserver/smassstorage/cusbmassstoragesession.cpp Mon Oct 11 17:54:41 2010 +0100 @@ -1,4 +1,4 @@ -// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of the License "Eclipse Public License v1.0" @@ -12,7 +12,7 @@ // // Description: // Implements a Session of a Symbian OS server for the RUsbMassStorage API -// +// // /** @@ -20,152 +20,163 @@ @internalTechnology */ -#include "cusbmassstoragesession.h" +#include +#include +#include "usbmsshared.h" + +#include "drivemanager.h" #include "cusbmassstoragecontroller.h" #include "cusbmassstorageserver.h" -#include "usbmsshared.h" +#include "cusbmassstoragesession.h" + +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "cusbmassstoragesessionTraces.h" +#endif + /** Construct a Symbian OS session object. - - @param aServer Service the session will be a member of - @param aMessage The message from the client. - @return A new CUsbMassStorageSession object + + @param aServer Service the session will be a member of + @param aMessage The message from the client. + @return A new CUsbMassStorageSession object */ CUsbMassStorageSession* CUsbMassStorageSession::NewL(CUsbMassStorageServer& aServer) - { - CUsbMassStorageSession* r = new (ELeave) CUsbMassStorageSession(aServer); - CleanupStack::PushL(r); - r->ConstructL(); - CleanupStack::Pop(); - return r; - } + { + CUsbMassStorageSession* r = new (ELeave) CUsbMassStorageSession(aServer); + CleanupStack::PushL(r); + r->ConstructL(); + CleanupStack::Pop(); + return r; + } /** Constructor. - - @param aServer Service the session will be a member of + + @param aServer Service the session will be a member of */ CUsbMassStorageSession::CUsbMassStorageSession(CUsbMassStorageServer& aServer) - : iUsbMsServer(aServer) - { - __PRINT(_L("CUsbMassStorageSession::CUsbMassStorageSession\n")); - } + : iUsbMsServer(aServer) + { + OstTraceFunctionEntry0(CUSBMASSSTORAGESESSION_100); + } /** 2nd Phase Construction. */ void CUsbMassStorageSession::ConstructL() - { - iUsbMsServer.IncrementSessionCount(); + { + iUsbMsServer.IncrementSessionCount(); if (iUsbMsServer.SessionCount() > 1) { - __PRINT1(_L("\tiSessionCount: %d\n"), iUsbMsServer.SessionCount()); + OstTrace1(TRACE_SMASSSTORAGE_FS, CUSBMASSSTORAGESESSION_101, + "iSessionCount: %d", iUsbMsServer.SessionCount()); // Only one session is allowed User::Leave(KErrInUse); - } - } + } + } /** Destructor. */ CUsbMassStorageSession::~CUsbMassStorageSession() - { - iUsbMsServer.DecrementSessionCount(); - } + { + iUsbMsServer.DecrementSessionCount(); + } /** Called when a message is received from the client. - - @param aMessage Message received from the client + + @param aMessage Message received from the client */ void CUsbMassStorageSession::ServiceL(const RMessage2& aMessage) - { - DispatchMessageL(aMessage); - } + { + DispatchMessageL(aMessage); + } /** Handles the request (in the form of a the message) received from the client - + @internalTechnology - @param aMessage The received message + @param aMessage The received message */ void CUsbMassStorageSession::DispatchMessageL(const RMessage2& aMessage) - { - TInt ret = KErrNone; - - switch (aMessage.Function()) - { - case EUsbMsStart: - ret = Start(aMessage); - break; - case EUsbMsStop: - ret = Stop(); - break; - case EUsbMsShutdown: - ret = Shutdown(); - break; + { + TInt ret = KErrNone; - default: - aMessage.Panic(KUsbMsCliPncCat, EUsbMsPanicIllegalIPC); - break; - } + switch (aMessage.Function()) + { + case EUsbMsStart: + ret = Start(aMessage); + break; + case EUsbMsStop: + ret = Stop(); + break; + case EUsbMsShutdown: + ret = Shutdown(); + break; - aMessage.Complete(ret); - } + default: + aMessage.Panic(KUsbMsCliPncCat, EUsbMsPanicIllegalIPC); + break; + } + + aMessage.Complete(ret); + } /** Client request to start the device. - - @return Any error that occurred or KErrNone + + @return Any error that occurred or KErrNone */ TInt CUsbMassStorageSession::Start(const RMessage2& aMessage) - { - __PRINT(_L("CUsbMassStorageSession::Start\n")); + { + OstTraceFunctionEntry0(CUSBMASSSTORAGESESSION_103); + TMassStorageConfig msConfig; + TRAPD(err, GetMsConfigL(aMessage, msConfig)); + if (err != KErrNone) + { + OstTrace1(TRACE_SMASSSTORAGE_FS, CUSBMASSSTORAGESESSION_111, + "Failed to get mass storage configuration data err=%d", err); + return err; + } - TMassStorageConfig msConfig; - TRAPD(err, GetMsConfigL(aMessage, msConfig)); - if (err != KErrNone) - { - __PRINT(_L("Failed to get mass storage configuration data\n")); - return err; - } - - return iUsbMsServer.Controller().Start(msConfig); - } + return iUsbMsServer.Controller().Start(msConfig); + } /** Client request to stop the device. - - @return Any error that occurred or KErrNone + + @return Any error that occurred or KErrNone */ TInt CUsbMassStorageSession::Stop() { - __PRINT(_L("CUsbMassStorageSession::Stop\n")); + OstTraceFunctionEntry0(CUSBMASSSTORAGESESSION_104); TInt err = iUsbMsServer.Controller().Stop(); - return err; - } + return err; + } /** Client request to shut down the server - + @return KErrNone */ TInt CUsbMassStorageSession::Shutdown() { - __PRINT(_L("CUsbMassStorageSession::Shutdown\n")); + OstTraceFunctionEntry0(CUSBMASSSTORAGESESSION_105); CActiveScheduler::Stop(); - return KErrNone; - } + return KErrNone; + } /** Get mass storage configuration data from the received message */ void CUsbMassStorageSession::GetMsConfigL(const RMessage2& aMessage, TMassStorageConfig& aMsStorage) - { - aMessage.ReadL(0,aMsStorage.iVendorId); - aMessage.ReadL(1,aMsStorage.iProductId); - aMessage.ReadL(2,aMsStorage.iProductRev); - } + { + aMessage.ReadL(0,aMsStorage.iVendorId); + aMessage.ReadL(1,aMsStorage.iProductId); + aMessage.ReadL(2,aMsStorage.iProductRev); + }