usbmgmt/usbmgr/host/functiondrivers/ms/msmm/server/src/msmmengine.cpp
branchRCL_3
changeset 16 012cc2ee6408
parent 15 f92a4f87e424
equal deleted inserted replaced
15:f92a4f87e424 16:012cc2ee6408
     1 /*
     1 /*
     2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    22 
    22 
    23 #include "msmmengine.h"
    23 #include "msmmengine.h"
    24 #include "msmmnodebase.h"
    24 #include "msmmnodebase.h"
    25 
    25 
    26 #include <usb/usblogger.h>
    26 #include <usb/usblogger.h>
    27 #include "OstTraceDefinitions.h"
    27 
    28 #ifdef OST_TRACE_COMPILER_IN_USE
    28 #ifdef __FLOG_ACTIVE
    29 #include "msmmengineTraces.h"
    29 _LIT8(KLogComponent, "UsbHostMsmmServer");
    30 #endif
    30 #endif
    31 
       
    32 
    31 
    33 CMsmmEngine::~CMsmmEngine()
    32 CMsmmEngine::~CMsmmEngine()
    34     {
    33     {
    35     OstTraceFunctionEntry0( CMSMMENGINE_CMSMMENGINE_DES_ENTRY );
    34     LOG_FUNC
    36     
       
    37     if (iDataEntrys)
    35     if (iDataEntrys)
    38         {
    36         {
    39         delete iDataEntrys;
    37         delete iDataEntrys;
    40         }
    38         }
    41     OstTraceFunctionExit0( CMSMMENGINE_CMSMMENGINE_DES_EXIT );
       
    42     }
    39     }
    43 
    40 
    44 CMsmmEngine* CMsmmEngine::NewL()
    41 CMsmmEngine* CMsmmEngine::NewL()
    45     {
    42     {
    46     OstTraceFunctionEntry0( CMSMMENGINE_NEWL_ENTRY );
    43     LOG_STATIC_FUNC_ENTRY
    47     
       
    48     CMsmmEngine* self = CMsmmEngine::NewLC();
    44     CMsmmEngine* self = CMsmmEngine::NewLC();
    49     CleanupStack::Pop(self);
    45     CleanupStack::Pop(self);
    50     
    46     
    51     OstTraceFunctionExit0( CMSMMENGINE_NEWL_EXIT );
       
    52     return self;
    47     return self;
    53     }
    48     }
    54 
    49 
    55 CMsmmEngine* CMsmmEngine::NewLC()
    50 CMsmmEngine* CMsmmEngine::NewLC()
    56     {
    51     {
    57     OstTraceFunctionEntry0( CMSMMENGINE_NEWLC_ENTRY );
    52     LOG_STATIC_FUNC_ENTRY
    58     
       
    59     CMsmmEngine* self = new (ELeave) CMsmmEngine();
    53     CMsmmEngine* self = new (ELeave) CMsmmEngine();
    60     CleanupStack::PushL(self);
    54     CleanupStack::PushL(self);
    61     self->ConstructL();
    55     self->ConstructL();
    62     
    56     
    63     OstTraceFunctionExit0( CMSMMENGINE_NEWLC_EXIT );
       
    64     return self;
    57     return self;
    65     }
    58     }
    66 
    59 
    67 void CMsmmEngine::AddUsbMsDeviceL(const TUSBMSDeviceDescription& aDevice)
    60 void CMsmmEngine::AddUsbMsDeviceL(const TUSBMSDeviceDescription& aDevice)
    68     {
    61     {
    69     OstTraceFunctionEntry0( CMSMMENGINE_ADDUSBMSDEVICEL_ENTRY );
    62     LOG_FUNC
    70     
       
    71     TUsbMsDevice* device = SearchDevice(aDevice.iDeviceId);
    63     TUsbMsDevice* device = SearchDevice(aDevice.iDeviceId);
    72     if (!device)
    64     if (!device)
    73         {
    65         {
    74         device = new (ELeave) TUsbMsDevice(aDevice);
    66         device = new (ELeave) TUsbMsDevice(aDevice);
    75         iDataEntrys->AddChild(device);
    67         iDataEntrys->AddChild(device);
    76         }
    68         }
    77     OstTraceFunctionExit0( CMSMMENGINE_ADDUSBMSDEVICEL_EXIT );
       
    78     }
    69     }
    79 
    70 
    80 TUsbMsInterface* CMsmmEngine::AddUsbMsInterfaceL(TInt aDeviceId, TUint8 aInterfaceNumber,
    71 TUsbMsInterface* CMsmmEngine::AddUsbMsInterfaceL(TInt aDeviceId, TUint8 aInterfaceNumber,
    81         TInt32 aInterfaceToken)
    72         TInt32 aInterfaceToken)
    82     {
    73     {
    83     OstTraceFunctionEntry0( CMSMMENGINE_ADDUSBMSINTERFACEL_ENTRY );
    74     LOG_FUNC
    84     
       
    85     TUsbMsDevice* device = SearchDevice(aDeviceId);
    75     TUsbMsDevice* device = SearchDevice(aDeviceId);
    86     if (!device)
    76     if (!device)
    87         {
    77         {
    88         User::Leave(KErrArgument);
    78         User::Leave(KErrArgument);
    89         }
    79         }
    95         }
    85         }
    96     else
    86     else
    97         {
    87         {
    98         interface = AddUsbMsInterfaceNodeL(device, aInterfaceNumber, aInterfaceToken);
    88         interface = AddUsbMsInterfaceNodeL(device, aInterfaceNumber, aInterfaceToken);
    99         }
    89         }
   100     OstTraceFunctionExit0( CMSMMENGINE_ADDUSBMSINTERFACEL_EXIT );
       
   101     return interface;
    90     return interface;
   102     }
    91     }
   103 
    92 
   104 void CMsmmEngine::AddUsbMsLogicalUnitL(TInt aDeviceId,
    93 void CMsmmEngine::AddUsbMsLogicalUnitL(TInt aDeviceId,
   105         TInt aInterfaceNumber, TInt aLogicalUnitNumber, TText aDrive)
    94         TInt aInterfaceNumber, TInt aLogicalUnitNumber, TText aDrive)
   106     {
    95     {
   107     OstTraceFunctionEntry0( CMSMMENGINE_ADDUSBMSLOGICALUNITL_ENTRY );
    96     LOG_FUNC
   108     
       
   109     TUsbMsDevice* device = SearchDevice(aDeviceId);
    97     TUsbMsDevice* device = SearchDevice(aDeviceId);
   110     if (!device)
    98     if (!device)
   111         {
    99         {
   112         User::Leave(KErrArgument); // A proper device node can't be found
   100         User::Leave(KErrArgument); // A proper device node can't be found
   113         }
   101         }
   119         }
   107         }
   120     else
   108     else
   121         {
   109         {
   122         User::Leave(KErrArgument); // A proper interface node can't be found
   110         User::Leave(KErrArgument); // A proper interface node can't be found
   123         }
   111         }
   124     OstTraceFunctionExit0( CMSMMENGINE_ADDUSBMSLOGICALUNITL_EXIT );
       
   125     }
   112     }
   126 
   113 
   127 void CMsmmEngine::RemoveUsbMsNode(TMsmmNodeBase* aNodeToBeRemoved)
   114 void CMsmmEngine::RemoveUsbMsNode(TMsmmNodeBase* aNodeToBeRemoved)
   128     {
   115     {
   129     OstTraceFunctionEntry0( CMSMMENGINE_REMOVEUSBMSNODE_ENTRY );
   116     LOG_FUNC
   130     
       
   131     delete aNodeToBeRemoved;
   117     delete aNodeToBeRemoved;
   132     OstTraceFunctionExit0( CMSMMENGINE_REMOVEUSBMSNODE_EXIT );
       
   133     }
   118     }
   134 
   119 
   135 TUsbMsDevice* CMsmmEngine::SearchDevice(TInt aDeviceId) const
   120 TUsbMsDevice* CMsmmEngine::SearchDevice(TInt aDeviceId) const
   136     {
   121     {
   137     OstTraceFunctionEntry0( CMSMMENGINE_SEARCHDEVICE_ENTRY );
   122     LOG_FUNC
   138     
       
   139     return static_cast<TUsbMsDevice*>(
   123     return static_cast<TUsbMsDevice*>(
   140             iDataEntrys->SearchInChildren(aDeviceId));
   124             iDataEntrys->SearchInChildren(aDeviceId));
   141     }
   125     }
   142 
   126 
   143 TUsbMsInterface* CMsmmEngine::SearchInterface(TMsmmNodeBase* aDevice, 
   127 TUsbMsInterface* CMsmmEngine::SearchInterface(TMsmmNodeBase* aDevice, 
   144         TInt aInterfaceNumber) const
   128         TInt aInterfaceNumber) const
   145     {
   129     {
   146     OstTraceFunctionEntry0( CMSMMENGINE_SEARCHINTERFACE_ENTRY );
   130     LOG_FUNC
   147     
       
   148     return static_cast<TUsbMsInterface*>(
   131     return static_cast<TUsbMsInterface*>(
   149             aDevice->SearchInChildren(aInterfaceNumber));
   132             aDevice->SearchInChildren(aInterfaceNumber));
   150     }
   133     }
   151 
   134 
   152 CMsmmEngine::CMsmmEngine()
   135 CMsmmEngine::CMsmmEngine()
   153     {
   136     {
   154     OstTraceFunctionEntry0( CMSMMENGINE_CMSMMENGINE_CONS_ENTRY );
   137     LOG_FUNC
   155 
       
   156     }
   138     }
   157 
   139 
   158 void CMsmmEngine::ConstructL()
   140 void CMsmmEngine::ConstructL()
   159     {
   141     {
   160     OstTraceFunctionEntry0( CMSMMENGINE_CONSTRUCTL_ENTRY );
   142     LOG_FUNC
   161     
       
   162     // Create the root of the whole node tree
   143     // Create the root of the whole node tree
   163     iDataEntrys = new (ELeave) TMsmmNodeBase(0x0);
   144     iDataEntrys = new (ELeave) TMsmmNodeBase(0x0);
   164     OstTraceFunctionExit0( CMSMMENGINE_CONSTRUCTL_EXIT );
       
   165     }
   145     }
   166 
   146 
   167 TUsbMsInterface* CMsmmEngine::AddUsbMsInterfaceNodeL(TUsbMsDevice* iParent,
   147 TUsbMsInterface* CMsmmEngine::AddUsbMsInterfaceNodeL(TUsbMsDevice* iParent,
   168         TInt aInterfaceNumber, TInt aInterfaceToken)
   148         TInt aInterfaceNumber, TInt aInterfaceToken)
   169     {
   149     {
   170        OstTraceFunctionEntry0( CMSMMENGINE_ADDUSBMSINTERFACENODEL_ENTRY );
   150     LOG_FUNC    
   171        
       
   172     TUsbMsInterface* interface = new (ELeave) TUsbMsInterface(
   151     TUsbMsInterface* interface = new (ELeave) TUsbMsInterface(
   173             aInterfaceNumber, aInterfaceToken);
   152             aInterfaceNumber, aInterfaceToken);
   174     iParent->AddChild(interface);
   153     iParent->AddChild(interface);
   175     
   154     
   176     OstTraceFunctionExit0( CMSMMENGINE_ADDUSBMSINTERFACENODEL_EXIT );
       
   177     return interface;
   155     return interface;
   178     }
   156     }
   179 
   157 
   180 TUsbMsLogicalUnit* CMsmmEngine::AddUsbMsLogicalUnitNodeL(
   158 TUsbMsLogicalUnit* CMsmmEngine::AddUsbMsLogicalUnitNodeL(
   181         TUsbMsInterface* iParent, TInt aLogicalUnitNumber, 
   159         TUsbMsInterface* iParent, TInt aLogicalUnitNumber, 
   182         TText aDrive)
   160         TText aDrive)
   183     {
   161     {
   184     OstTraceFunctionEntry0( CMSMMENGINE_ADDUSBMSLOGICALUNITNODEL_ENTRY );
   162     LOG_FUNC
   185     
       
   186     TUsbMsLogicalUnit* logicalUnit = new (ELeave) TUsbMsLogicalUnit(
   163     TUsbMsLogicalUnit* logicalUnit = new (ELeave) TUsbMsLogicalUnit(
   187             aLogicalUnitNumber, aDrive);
   164             aLogicalUnitNumber, aDrive);
   188     iParent->AddChild(logicalUnit);
   165     iParent->AddChild(logicalUnit);
   189     
   166     
   190     OstTraceFunctionExit0( CMSMMENGINE_ADDUSBMSLOGICALUNITNODEL_EXIT );
       
   191     return logicalUnit;
   167     return logicalUnit;
   192     }
   168     }
   193 
   169 
   194 // End of file
   170 // End of file