kerneltest/f32test/shostmassstorage/msman/server/cusbotgsession.cpp
changeset 0 a41df078684a
child 297 b2826f67641f
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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 Session of a Symbian OS server for the RUsbMassStorage API
       
    15 // 
       
    16 //
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalTechnology
       
    23 */
       
    24 
       
    25 #include <e32cmn.h>
       
    26 #include <e32base.h>
       
    27 
       
    28 #include "tmslog.h"
       
    29 #include "msmanclientserver.h"
       
    30 
       
    31 #include <f32file.h>
       
    32 #include <d32usbdi_hubdriver.h>
       
    33 #include <d32otgdi.h>
       
    34 #include "usbtypes.h"
       
    35 
       
    36 #include "cusbotg.h"
       
    37 
       
    38 #include "cusbotgserver.h"
       
    39 #include "cusbotgsession.h"
       
    40 
       
    41 
       
    42 CUsbOtgSession* CUsbOtgSession::NewL()
       
    43 	{
       
    44     __MSFNSLOG
       
    45 	CUsbOtgSession* r = new (ELeave) CUsbOtgSession();
       
    46 	CleanupStack::PushL(r);
       
    47 	r->ConstructL();
       
    48 	CleanupStack::Pop();
       
    49 	return r;
       
    50 	}
       
    51 
       
    52 
       
    53 CUsbOtgSession::CUsbOtgSession()
       
    54 	{
       
    55     __MSFNSLOG
       
    56 
       
    57 	}
       
    58 
       
    59 void CUsbOtgSession::ConstructL()
       
    60 	{
       
    61     __MSFNSLOG
       
    62  	}
       
    63 
       
    64 
       
    65 void CUsbOtgSession::CreateL()
       
    66 	{
       
    67     __MSFNSLOG
       
    68     Server().AddSession();
       
    69 	}
       
    70 
       
    71 
       
    72 CUsbOtgSession::~CUsbOtgSession()
       
    73 	{
       
    74     __MSFNSLOG
       
    75     Server().RemoveSession();
       
    76 	}
       
    77 
       
    78 
       
    79 void CUsbOtgSession::ServiceL(const RMessage2& aMessage)
       
    80 	{
       
    81     __MSFNSLOG
       
    82 	DispatchMessageL(aMessage);
       
    83 	}
       
    84 
       
    85 
       
    86 void CUsbOtgSession::DispatchMessageL(const RMessage2& aMessage)
       
    87 	{
       
    88     __MSFNSLOG
       
    89 	TInt ret = KErrNone;
       
    90 
       
    91 	switch (aMessage.Function())
       
    92 		{
       
    93     case EUsbOtgDeviceInserted:
       
    94         DeviceInsertedL(aMessage);
       
    95         break;
       
    96     case EUsbOtgNotifyChange:
       
    97         NotifyChange(aMessage);
       
    98         break;
       
    99     case EUsbOtgNotifyChangeCancel:
       
   100         NotifyChangeCancel();
       
   101         break;
       
   102 	case EUsbOtgBusDrop:
       
   103 		ret = BusDrop();
       
   104 		break;
       
   105 	default:
       
   106 		aMessage.Panic(KUsbOtgClientPncCat, EUsbOtgPanicIllegalIPC);
       
   107 		break;
       
   108 		}
       
   109 
       
   110 	aMessage.Complete(ret);
       
   111 	}
       
   112 
       
   113 
       
   114 void CUsbOtgSession::DeviceInsertedL(const RMessage2& aMessage)
       
   115     {
       
   116     __MSFNSLOG
       
   117     TBool inserted = Server().iUsbOtg->DeviceInserted();
       
   118     TPckgBuf<TBool> p(inserted);
       
   119     aMessage.WriteL(0,p);
       
   120     }
       
   121 
       
   122 void CUsbOtgSession::NotifyChange(const RMessage2& aMessage)
       
   123     {
       
   124     __MSFNSLOG
       
   125     Server().iUsbOtg->NotifyChange(aMessage);
       
   126     }
       
   127 
       
   128 
       
   129 void CUsbOtgSession::NotifyChangeCancel()
       
   130     {
       
   131     __MSFNSLOG
       
   132     Server().iUsbOtg->NotifyChangeCancel();
       
   133     }
       
   134 
       
   135 
       
   136 TInt CUsbOtgSession::BusDrop()
       
   137     {
       
   138     __MSFNSLOG
       
   139     return Server().iUsbOtg->BusDrop();
       
   140 	}