kerneltest/f32test/shostmassstorage/msman/server/cusbotgserver.cpp
changeset 9 96e5fb8b040d
equal deleted inserted replaced
-1:000000000000 9:96e5fb8b040d
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Implements a Symbian OS server that exposes the RUsbMassStorage API
       
    15 // 
       
    16 //
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalTechnology
       
    23 */
       
    24 
       
    25 #include <e32svr.h>
       
    26 #include <f32file.h>
       
    27 
       
    28 #include <d32usbdi_hubdriver.h>
       
    29 #include <d32otgdi.h>
       
    30 
       
    31 #include "usbtypes.h"
       
    32 #include "cusbotg.h"
       
    33 
       
    34 #include "msmanclientserver.h"
       
    35 #include "cusbotgserver.h"
       
    36 #include "cusbotgsession.h"
       
    37 
       
    38 #include "tmslog.h"
       
    39 
       
    40 CUsbOtgServer* CUsbOtgServer::NewLC()
       
    41 	{
       
    42     __MSFNSLOG
       
    43 	CUsbOtgServer* r = new (ELeave) CUsbOtgServer();
       
    44 	CleanupStack::PushL(r);
       
    45     r->ConstructL();
       
    46 	return r;
       
    47 	}
       
    48 
       
    49 
       
    50 CUsbOtgServer::CUsbOtgServer()
       
    51 :   CServer2(EPriorityLow)
       
    52 	{
       
    53     __MSFNSLOG
       
    54 	}
       
    55 
       
    56 
       
    57 void CUsbOtgServer::ConstructL()
       
    58     {
       
    59     __MSFNSLOG
       
    60 
       
    61 	iUsbOtg = CUsbOtg::NewL();
       
    62 	StartL(KUsbOtgServerName);
       
    63     }
       
    64 
       
    65 
       
    66 CUsbOtgServer::~CUsbOtgServer()
       
    67 	{
       
    68     __MSFNSLOG
       
    69     delete iUsbOtg;
       
    70 	}
       
    71 
       
    72 
       
    73 CSession2* CUsbOtgServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMessage*/) const
       
    74 	{
       
    75     __MSFNSLOG
       
    76 	TVersion v(KUsbOtgSrvMajorVersionNumber, KUsbOtgSrvMinorVersionNumber, KUsbOtgSrvBuildVersionNumber);
       
    77 
       
    78 	if (!User::QueryVersionSupported(v, aVersion))
       
    79 		User::Leave(KErrNotSupported);
       
    80 
       
    81 	CUsbOtgSession* session = CUsbOtgSession::NewL();
       
    82 
       
    83 	return session;
       
    84 	}
       
    85 
       
    86 
       
    87 
       
    88 TInt CUsbOtgServer::RunError(TInt aError)
       
    89 	{
       
    90     __MSFNSLOG
       
    91 
       
    92 	Message().Complete(aError);
       
    93 	ReStart();
       
    94     return KErrNone;
       
    95 	}
       
    96 
       
    97 
       
    98 void CUsbOtgServer::AddSession()
       
    99     {
       
   100     __MSFNSLOG
       
   101     ++iSessionCount;
       
   102     }
       
   103 
       
   104 void CUsbOtgServer::RemoveSession()
       
   105     {
       
   106     __MSFNSLOG
       
   107     if (--iSessionCount == 0)
       
   108         {
       
   109         User::After(1000000);
       
   110         CActiveScheduler::Stop();
       
   111         }
       
   112     }