VirtualBox

source: vbox/trunk/src/VBox/Main/include/USBProxyService.h@ 60742

Last change on this file since 60742 was 60742, checked in by vboxsync, 8 years ago

Main/USBProxy{Service|Backend}: Rework interaction between thos two to be more sane than it currently is (calling into each other back and forth)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1/* $Id: USBProxyService.h 60742 2016-04-28 13:55:03Z vboxsync $ */
2/** @file
3 * VirtualBox USB Proxy Service (base) class.
4 */
5
6/*
7 * Copyright (C) 2005-2012 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19#ifndef ____H_USBPROXYSERVICE
20#define ____H_USBPROXYSERVICE
21
22#include <VBox/usb.h>
23#include <VBox/usbfilter.h>
24#include <VBox/settings.h>
25
26#include "VirtualBoxBase.h"
27#include "VirtualBoxImpl.h"
28#include "HostUSBDeviceImpl.h"
29#include "USBProxyBackend.h"
30class Host;
31
32/**
33 * Base class for the USB Proxy service.
34 */
35class USBProxyService
36 : public VirtualBoxTranslatable
37{
38public:
39 USBProxyService(Host *aHost);
40 virtual HRESULT init(void);
41 virtual ~USBProxyService();
42
43 /**
44 * Override of the default locking class to be used for validating lock
45 * order with the standard member lock handle.
46 */
47 virtual VBoxLockingClass getLockingClass() const
48 {
49 // the USB proxy service uses the Host object lock, so return the
50 // same locking class as the host
51 return LOCKCLASS_HOSTOBJECT;
52 }
53
54 void uninit(void);
55
56 bool isActive(void);
57 int getLastError(void);
58
59 RWLockHandle *lockHandle() const;
60
61 /** @name Interface for the USBController and the Host object.
62 * @{ */
63 void *insertFilter(PCUSBFILTER aFilter);
64 void removeFilter(void *aId);
65 /** @} */
66
67 /** @name Host Interfaces
68 * @{ */
69 HRESULT getDeviceCollection(std::vector<ComPtr<IHostUSBDevice> > &aUSBDevices);
70 HRESULT addUSBDeviceSource(const com::Utf8Str &aBackend, const com::Utf8Str &aId, const com::Utf8Str &aAddress,
71 const std::vector<com::Utf8Str> &aPropertyNames, const std::vector<com::Utf8Str> &aPropertyValues);
72 HRESULT removeUSBDeviceSource(const com::Utf8Str &aId);
73 /** @} */
74
75 /** @name SessionMachine Interfaces
76 * @{ */
77 HRESULT captureDeviceForVM(SessionMachine *aMachine, IN_GUID aId, const com::Utf8Str &aCaptureFilename);
78 HRESULT detachDeviceFromVM(SessionMachine *aMachine, IN_GUID aId, bool aDone);
79 HRESULT autoCaptureDevicesForVM(SessionMachine *aMachine);
80 HRESULT detachAllDevicesFromVM(SessionMachine *aMachine, bool aDone, bool aAbnormal);
81 /** @} */
82
83 typedef std::list< ComObjPtr<HostUSBDeviceFilter> > USBDeviceFilterList;
84
85 HRESULT i_loadSettings(const settings::USBDeviceSourcesList &llUSBDeviceSources);
86 HRESULT i_saveSettings(settings::USBDeviceSourcesList &llUSBDeviceSources);
87
88 void i_deviceAdded(ComObjPtr<HostUSBDevice> &aDevice, PUSBDEVICE aUSBDevice);
89 void i_deviceRemoved(ComObjPtr<HostUSBDevice> &aDevice);
90 void i_updateDeviceState(ComObjPtr<HostUSBDevice> &aDevice, PUSBDEVICE aUSBDevice, bool fFakeUpdate);
91
92protected:
93 ComObjPtr<HostUSBDevice> findDeviceById(IN_GUID aId);
94
95 static HRESULT setError(HRESULT aResultCode, const char *aText, ...);
96
97 USBProxyBackend *findUsbProxyBackendById(const com::Utf8Str &strId);
98
99 HRESULT createUSBDeviceSource(const com::Utf8Str &aBackend, const com::Utf8Str &aId,
100 const com::Utf8Str &aAddress, const std::vector<com::Utf8Str> &aPropertyNames,
101 const std::vector<com::Utf8Str> &aPropertyValues);
102
103private:
104
105 HRESULT runAllFiltersOnDevice(ComObjPtr<HostUSBDevice> &aDevice,
106 SessionMachinesList &llOpenedMachines,
107 SessionMachine *aIgnoreMachine);
108 bool runMachineFilters(SessionMachine *aMachine, ComObjPtr<HostUSBDevice> &aDevice);
109
110 void deviceChanged(ComObjPtr<HostUSBDevice> &aDevice, bool fRunFilters, SessionMachine *aIgnoreMachine);
111
112 /** Pointer to the Host object. */
113 Host *mHost;
114 /** List of smart HostUSBDevice pointers. */
115 typedef std::list<ComObjPtr<HostUSBDevice> > HostUSBDeviceList;
116 /** List of the known USB devices. */
117 HostUSBDeviceList mDevices;
118 /** List of USBProxyBackend pointers. */
119 typedef std::list<ComObjPtr<USBProxyBackend> > USBProxyBackendList;
120 /** List of active USB backends. */
121 USBProxyBackendList mBackends;
122 int mLastError;
123};
124
125#endif /* !____H_USBPROXYSERVICE */
126/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette