usbmgmt/usbmgr/host/functiondrivers/ms/msmm/server/src/msmmserver.cpp
changeset 25 4ddb65515edd
parent 0 c9bc50fca66e
child 29 59aa7d6e3e0f
equal deleted inserted replaced
14:4285b54b0d2c 25:4ddb65515edd
    19  @file
    19  @file
    20  @internalComponent
    20  @internalComponent
    21 */
    21 */
    22 
    22 
    23 #include "msmmserver.h"
    23 #include "msmmserver.h"
    24 #include <usb/hostms/msmmpolicypluginbase.h>
       
    25 #include "msmm_internal_def.h"
    24 #include "msmm_internal_def.h"
    26 #include "msmmsession.h"
    25 #include "msmmsession.h"
    27 #include "msmmengine.h"
    26 #include "msmmengine.h"
    28 #include "eventqueue.h"
    27 #include "eventqueue.h"
    29 #include "msmmterminator.h"
    28 #include "msmmterminator.h"
    30 
    29 #include "msmmdismountusbdrives.h"
       
    30 
       
    31 #include <usb/hostms/msmmpolicypluginbase.h>
    31 #include <usb/usblogger.h>
    32 #include <usb/usblogger.h>
    32 
    33 
    33 #ifdef __FLOG_ACTIVE
    34 #ifdef __FLOG_ACTIVE
    34 _LIT8(KLogComponent, "UsbHostMsmmServer");
    35 _LIT8(KLogComponent, "UsbHostMsmmServer");
    35 #endif
    36 #endif
    95 
    96 
    96     // Free the server and active scheduler.
    97     // Free the server and active scheduler.
    97     CleanupStack::PopAndDestroy(2, scheduler);
    98     CleanupStack::PopAndDestroy(2, scheduler);
    98     }
    99     }
    99 
   100 
       
   101 CPolicyServer::TCustomResult CMsmmServer::CustomSecurityCheckL(
       
   102     const RMessage2&  aMsg,
       
   103      TInt&  /*aAction*/,
       
   104      TSecurityInfo&  /*aMissing*/)
       
   105  {
       
   106      CPolicyServer::TCustomResult returnValue = CPolicyServer::EFail;    
       
   107      
       
   108      TSecureId ClientSID = aMsg.SecureId();
       
   109  
       
   110      if (KFDFWSecureId == ClientSID)
       
   111          {
       
   112          returnValue = CPolicyServer::EPass;
       
   113          }     
       
   114      else if ((KSidHbDeviceDialogAppServer == ClientSID) && SessionNumber() > 0)
       
   115          {
       
   116          returnValue = CPolicyServer::EPass;
       
   117          }
       
   118      return returnValue;
       
   119  }
       
   120 
   100 // Public functions
   121 // Public functions
   101 // Construction and destruction
   122 // Construction and destruction
   102 CMsmmServer* CMsmmServer::NewLC()
   123 CMsmmServer* CMsmmServer::NewLC()
   103     {
   124     {
   104     LOG_STATIC_FUNC_ENTRY
   125     LOG_STATIC_FUNC_ENTRY
   117     LOG_FUNC
   138     LOG_FUNC
   118     delete iPolicyPlugin;
   139     delete iPolicyPlugin;
   119     delete iEventQueue;
   140     delete iEventQueue;
   120     delete iEngine;
   141     delete iEngine;
   121     delete iTerminator;
   142     delete iTerminator;
       
   143     delete iDismountErrData;
       
   144     delete iDismountManager;
   122     REComSession::FinalClose();
   145     REComSession::FinalClose();
   123 
   146 
   124 #ifndef __OVER_DUMMYCOMPONENT__
   147 #ifndef __OVER_DUMMYCOMPONENT__
   125     iFs.RemoveProxyDrive(KPROXYDRIVENAME);
   148     iFs.RemoveProxyDrive(KPROXYDRIVENAME);
   126     iFs.Close();
   149     iFs.Close();
   134     LOG_FUNC
   157     LOG_FUNC
   135     
   158     
   136     if (KMaxClientCount <= SessionNumber())
   159     if (KMaxClientCount <= SessionNumber())
   137         {
   160         {
   138         // There is a connection to MSMM server already.
   161         // There is a connection to MSMM server already.
   139         // Currently design of MSMM allows only one activated client 
   162         // Currently design of MSMM can have two clients, one FDF and the other Indicator UI 
   140         // at any time.
   163         // at any time.
   141         User::Leave(KErrInUse);
   164         User::Leave(KErrInUse);
   142         }
   165         }
   143     
   166     
   144     // Check the client-side API version number against the server version 
   167     // Check the client-side API version number against the server version 
   186         iTerminator->Cancel();
   209         iTerminator->Cancel();
   187         iTerminator->Start();
   210         iTerminator->Start();
   188         }
   211         }
   189     }
   212     }
   190 
   213 
       
   214 void CMsmmServer::DismountUsbDrivesL(TUSBMSDeviceDescription& aDevice)
       
   215     {
       
   216     LOG_FUNC
       
   217     delete iDismountManager;
       
   218     iDismountManager = NULL;
       
   219     iDismountManager= CMsmmDismountUsbDrives::NewL();
       
   220     
       
   221     //Also notify the MSMM plugin of beginning of dismounting     
       
   222     iDismountErrData->iError = EHostMsEjectInProgress;
       
   223     iDismountErrData->iE32Error = KErrNone;
       
   224     iDismountErrData->iManufacturerString = aDevice.iManufacturerString;
       
   225     iDismountErrData->iProductString = aDevice.iProductString;
       
   226     iDismountErrData->iDriveName = 0x0;
       
   227    
       
   228     TRAP_IGNORE(iPolicyPlugin->SendErrorNotificationL(*iDismountErrData));
       
   229 
       
   230     // Start dismounting
       
   231     iDismountManager->DismountUsbDrives(*iPolicyPlugin, aDevice);
       
   232     }
       
   233 
   191 //  Private functions 
   234 //  Private functions 
   192 // CMsmmServer Construction
   235 // CMsmmServer Construction
   193 CMsmmServer::CMsmmServer(TInt aPriority)
   236 CMsmmServer::CMsmmServer(TInt aPriority)
   194     :CPolicyServer(aPriority, KMsmmServerSecurityPolicy, EUnsharableSessions)
   237     :CPolicyServer(aPriority, KMsmmServerSecurityPolicy, EUnsharableSessions)
   195     {
   238     {
   203     
   246     
   204     iEngine = CMsmmEngine::NewL();
   247     iEngine = CMsmmEngine::NewL();
   205     iEventQueue = CDeviceEventQueue::NewL(*this);
   248     iEventQueue = CDeviceEventQueue::NewL(*this);
   206     iTerminator = CMsmmTerminator::NewL(*iEventQueue);
   249     iTerminator = CMsmmTerminator::NewL(*iEventQueue);
   207     iPolicyPlugin = CMsmmPolicyPluginBase::NewL();
   250     iPolicyPlugin = CMsmmPolicyPluginBase::NewL();
       
   251     iDismountErrData = new (ELeave) THostMsErrData;
   208     if (!iPolicyPlugin)
   252     if (!iPolicyPlugin)
   209         {
   253         {
   210         // Not any policy plugin implementation available
   254         // Not any policy plugin implementation available
   211         PanicServer(ENoPolicyPlugin);
   255         PanicServer(ENoPolicyPlugin);
   212         }
   256         }