usbmgmt/usbmgr/host/functiondrivers/ms/msmm/server/src/msmmsession.cpp
branchRCL_3
changeset 15 f92a4f87e424
parent 0 c9bc50fca66e
child 16 012cc2ee6408
equal deleted inserted replaced
14:d3e8e7d462dd 15:f92a4f87e424
     1 /*
     1 /*
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008-2010 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 "msmmsession.h"
    23 #include "msmmsession.h"
    24 #include "msmmserver.h"
    24 #include "msmmserver.h"
    25 #include "msmmengine.h"
    25 #include "msmmengine.h"
    26 #include "eventqueue.h"
    26 #include "eventqueue.h"
       
    27 #include "msmmnodebase.h"
    27 #include <usb/hostms/srverr.h>
    28 #include <usb/hostms/srverr.h>
    28 #include <usb/hostms/msmmpolicypluginbase.h>
    29 #include <usb/hostms/msmmpolicypluginbase.h>
    29 #include "msmmnodebase.h"
    30 
    30 #include <usb/usblogger.h>
    31 #include <usb/usblogger.h>
    31 
    32 #include "OstTraceDefinitions.h"
    32 #ifdef __FLOG_ACTIVE
    33 #ifdef OST_TRACE_COMPILER_IN_USE
    33 _LIT8(KLogComponent, "UsbHostMsmmServer");
    34 #include "msmmsessionTraces.h"
    34 #endif
    35 #endif
    35 
    36 
       
    37 
       
    38 
    36 CMsmmSession::~CMsmmSession()
    39 CMsmmSession::~CMsmmSession()
    37     {
    40     {
    38     LOG_FUNC
    41     OstTraceFunctionEntry0( CMSMMSESSION_CMSMMSESSION_DES_ENTRY );
       
    42     
    39     delete iErrData;
    43     delete iErrData;
    40     iServer.RemoveSession();
    44     iServer.RemoveSession();
       
    45     OstTraceFunctionExit0( CMSMMSESSION_CMSMMSESSION_DES_EXIT );
    41     }
    46     }
    42 
    47 
    43 CMsmmSession* CMsmmSession::NewL(CMsmmServer& aServer, 
    48 CMsmmSession* CMsmmSession::NewL(CMsmmServer& aServer, 
    44         CDeviceEventQueue& anEventQueue)
    49         CDeviceEventQueue& anEventQueue)
    45     {
    50     {
    46     LOG_STATIC_FUNC_ENTRY
    51     OstTraceFunctionEntry0( CMSMMSESSION_NEWL_ENTRY );
       
    52     
    47     CMsmmSession* self = new(ELeave) CMsmmSession(aServer, anEventQueue);
    53     CMsmmSession* self = new(ELeave) CMsmmSession(aServer, anEventQueue);
    48     CleanupStack::PushL(self);
    54     CleanupStack::PushL(self);
    49     self->ConstructL();
    55     self->ConstructL();
    50     CleanupStack::Pop(self);
    56     CleanupStack::Pop(self);
       
    57     OstTraceFunctionExit0( CMSMMSESSION_NEWL_EXIT );
    51     return self;
    58     return self;
    52     }
    59     }
    53 
    60 
    54 void CMsmmSession::ServiceL(const RMessage2& aMessage)
    61 void CMsmmSession::ServiceL(const RMessage2& aMessage)
    55     {
    62     {
    56     LOG_STATIC_FUNC_ENTRY
    63     OstTraceFunctionEntry0( CMSMMSESSION_SERVICEL_ENTRY );
       
    64     
    57     TInt ret(KErrNone);
    65     TInt ret(KErrNone);
    58 
    66 
    59 #ifdef _DEBUG
    67 #ifdef _DEBUG
    60     TInt* heapObj= NULL;
    68     TInt* heapObj= NULL;
    61 #endif // _DEBUG
    69 #endif // _DEBUG
    90 #ifdef _DEBUG
    98 #ifdef _DEBUG
    91         TRAP(ret, heapObj = new (ELeave) TInt);
    99         TRAP(ret, heapObj = new (ELeave) TInt);
    92         delete heapObj;
   100         delete heapObj;
    93 #endif // _DEBUG
   101 #endif // _DEBUG
    94         break;
   102         break;
    95 
   103         
       
   104     case EHostMsmmServerEjectUsbDrives:
       
   105         iServer.DismountUsbDrivesL(iDevicePkg());
       
   106         break;
    96     default:
   107     default:
    97         // Unsupported function number - panic the client
   108         // Unsupported function number - panic the client
    98         PanicClient(aMessage, EBadRequest);
   109         PanicClient(aMessage, EBadRequest);
    99         }
   110         }
   100         
   111         
   101     // Complete the request
   112     // Complete the request
   102     aMessage.Complete(ret);
   113     aMessage.Complete(ret);
       
   114     OstTraceFunctionExit0( CMSMMSESSION_SERVICEL_EXIT );
   103     }
   115     }
   104 
   116 
   105 void CMsmmSession::ServiceError(const RMessage2 &aMessage, TInt aError)
   117 void CMsmmSession::ServiceError(const RMessage2 &aMessage, TInt aError)
   106     {
   118     {
   107     LOG_FUNC
   119     OstTraceFunctionEntry0( CMSMMSESSION_SERVICEERROR_ENTRY );
       
   120     
   108     CMsmmPolicyPluginBase* plugin = iServer.PolicyPlugin();    
   121     CMsmmPolicyPluginBase* plugin = iServer.PolicyPlugin();    
   109     TUSBMSDeviceDescription& device = iDevicePkg();
   122     TUSBMSDeviceDescription& device = iDevicePkg();
   110        
   123        
   111     switch (aError)
   124     switch (aError)
   112         {
   125         {
   126     iErrData->iE32Error = aError;
   139     iErrData->iE32Error = aError;
   127     iErrData->iManufacturerString = device.iManufacturerString;
   140     iErrData->iManufacturerString = device.iManufacturerString;
   128     iErrData->iProductString = device.iProductString;
   141     iErrData->iProductString = device.iProductString;
   129     iErrData->iDriveName = 0x0;
   142     iErrData->iDriveName = 0x0;
   130    
   143    
       
   144     OstTrace1( TRACE_DUMP, CMSMMSESSION_SERVICEERROR, "iErrData->iE32Error = %d", aError );
       
   145     OstTraceExt1( TRACE_DUMP, CMSMMSESSION_SERVICEERROR_DUP1, "iErrData->iManufacturerString=\"%S\"", device.iManufacturerString );
       
   146     OstTraceExt1( TRACE_DUMP, CMSMMSESSION_SERVICEERROR_DUP2, "iErrData->iProductString=\"%S\"", device.iProductString );
       
   147 
       
   148         
   131     TInt err(KErrNone);
   149     TInt err(KErrNone);
   132     TRAP(err, plugin->SendErrorNotificationL(*iErrData));
   150     TRAP(err, plugin->SendErrorNotificationL(*iErrData));
   133     aMessage.Complete(aError);
   151     aMessage.Complete(aError);
       
   152     OstTraceFunctionExit0( CMSMMSESSION_SERVICEERROR_EXIT );
   134     }
   153     }
   135 
   154 
   136 CMsmmSession::CMsmmSession(CMsmmServer& aServer, 
   155 CMsmmSession::CMsmmSession(CMsmmServer& aServer, 
   137         CDeviceEventQueue& anEventQueue) :
   156         CDeviceEventQueue& anEventQueue) :
   138 iServer(aServer),
   157 iServer(aServer),
   139 iEngine(aServer.Engine()),
   158 iEngine(aServer.Engine()),
   140 iEventQueue(anEventQueue)
   159 iEventQueue(anEventQueue)
   141     {
   160     {
   142     LOG_FUNC
   161     OstTraceFunctionEntry0( CMSMMSESSION_CMSMMSESSION_CONS_ENTRY );
       
   162     
   143     aServer.AddSession();
   163     aServer.AddSession();
       
   164     OstTraceFunctionExit0( CMSMMSESSION_CMSMMSESSION_CONS_EXIT );
   144     }
   165     }
   145 
   166 
   146 void CMsmmSession::ConstructL()
   167 void CMsmmSession::ConstructL()
   147     {
   168     {
   148     LOG_FUNC
   169     OstTraceFunctionEntry0( CMSMMSESSION_CONSTRUCTL_ENTRY );
       
   170     
   149     iErrData = new (ELeave) THostMsErrData;
   171     iErrData = new (ELeave) THostMsErrData;
       
   172     OstTraceFunctionExit0( CMSMMSESSION_CONSTRUCTL_EXIT );
   150     }
   173     }
   151 
   174 
   152 void CMsmmSession::AddUsbMsInterfaceL(const RMessage2& aMessage)
   175 void CMsmmSession::AddUsbMsInterfaceL(const RMessage2& aMessage)
   153     {
   176     {
   154     LOG_FUNC
   177     OstTraceFunctionEntry0( CMSMMSESSION_ADDUSBMSINTERFACEL_ENTRY );
       
   178     
   155     aMessage.Read(0, iDevicePkg);
   179     aMessage.Read(0, iDevicePkg);
   156     iInterfaceNumber = aMessage.Int1();
   180     iInterfaceNumber = aMessage.Int1();
   157     iInterfaceToken = static_cast<TInt32>(aMessage.Int2());
   181     iInterfaceToken = static_cast<TInt32>(aMessage.Int2());
   158     TUSBMSDeviceDescription& device = iDevicePkg();
   182     TUSBMSDeviceDescription& device = iDevicePkg();
   159     
   183     
   163     
   187     
   164     // Put device event into queue
   188     // Put device event into queue
   165     TDeviceEvent event(EDeviceEventAddFunction, 
   189     TDeviceEvent event(EDeviceEventAddFunction, 
   166             device.iDeviceId, iInterfaceNumber, iInterfaceToken);
   190             device.iDeviceId, iInterfaceNumber, iInterfaceToken);
   167     iEventQueue.PushL(event);
   191     iEventQueue.PushL(event);
       
   192     OstTraceFunctionExit0( CMSMMSESSION_ADDUSBMSINTERFACEL_EXIT );
   168     }
   193     }
   169 
   194 
   170 void CMsmmSession::RemoveUsbMsDeviceL(const RMessage2& aMessage)
   195 void CMsmmSession::RemoveUsbMsDeviceL(const RMessage2& aMessage)
   171     {
   196     {
   172     LOG_FUNC
   197     OstTraceFunctionEntry0( CMSMMSESSION_REMOVEUSBMSDEVICEL_ENTRY );
       
   198     
   173     iDeviceID = aMessage.Int0();
   199     iDeviceID = aMessage.Int0();
   174        
   200        
   175     // Put device event into queue
   201     // Put device event into queue
   176     TDeviceEvent event(EDeviceEventRemoveDevice, iDeviceID, 0, 0);
   202     TDeviceEvent event(EDeviceEventRemoveDevice, iDeviceID, 0, 0);
   177     iEventQueue.PushL(event);
   203     iEventQueue.PushL(event);
       
   204     OstTraceFunctionExit0( CMSMMSESSION_REMOVEUSBMSDEVICEL_EXIT );
   178     }
   205     }
   179 
   206 
   180 // End of file
   207 // End of file