VirtualBox

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

Last change on this file since 59989 was 59117, checked in by vboxsync, 9 years ago

USB,Main: Rework USBProxyService. Split it into a USBProxyService and USBProxyBackend class, USBProxyService can use multiple USBProxyBackend instances as sources for USB devices to attach to a VM which will be used for USB/IP support. Change the PDM USB API to contain a backend parameter instead of a remote flag to indicate the USB backend to use for the given device.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1/* $Id: USBProxyService.h 59117 2015-12-14 14:04:37Z 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
25#include "VirtualBoxBase.h"
26#include "VirtualBoxImpl.h"
27#include "HostUSBDeviceImpl.h"
28#include "USBProxyBackend.h"
29class Host;
30
31/**
32 * Base class for the USB Proxy service.
33 */
34class USBProxyService
35 : public VirtualBoxTranslatable
36{
37public:
38 USBProxyService(Host *aHost);
39 virtual HRESULT init(void);
40 virtual ~USBProxyService();
41
42 /**
43 * Override of the default locking class to be used for validating lock
44 * order with the standard member lock handle.
45 */
46 virtual VBoxLockingClass getLockingClass() const
47 {
48 // the USB proxy service uses the Host object lock, so return the
49 // same locking class as the host
50 return LOCKCLASS_HOSTOBJECT;
51 }
52
53 bool isActive(void);
54 int getLastError(void);
55
56 RWLockHandle *lockHandle() const;
57
58 /** @name Interface for the USBController and the Host object.
59 * @{ */
60 void *insertFilter(PCUSBFILTER aFilter);
61 void removeFilter(void *aId);
62 /** @} */
63
64 /** @name Host Interfaces
65 * @{ */
66 HRESULT getDeviceCollection(std::vector<ComPtr<IHostUSBDevice> > &aUSBDevices);
67 /** @} */
68
69 /** @name SessionMachine Interfaces
70 * @{ */
71 HRESULT captureDeviceForVM(SessionMachine *aMachine, IN_GUID aId, const com::Utf8Str &aCaptureFilename);
72 HRESULT detachDeviceFromVM(SessionMachine *aMachine, IN_GUID aId, bool aDone);
73 HRESULT autoCaptureDevicesForVM(SessionMachine *aMachine);
74 HRESULT detachAllDevicesFromVM(SessionMachine *aMachine, bool aDone, bool aAbnormal);
75 /** @} */
76
77 typedef std::list< ComObjPtr<HostUSBDeviceFilter> > USBDeviceFilterList;
78
79 void i_updateDeviceList(USBProxyBackend *pUsbProxyBackend, PUSBDEVICE pDevices);
80 void i_getUSBFilters(USBDeviceFilterList *pGlobalFiltes);
81
82protected:
83 ComObjPtr<HostUSBDevice> findDeviceById(IN_GUID aId);
84
85 static HRESULT setError(HRESULT aResultCode, const char *aText, ...);
86
87private:
88
89 /** Pointer to the Host object. */
90 Host *mHost;
91 /** List of smart HostUSBDevice pointers. */
92 typedef std::list<ComObjPtr<HostUSBDevice> > HostUSBDeviceList;
93 /** List of the known USB devices. */
94 HostUSBDeviceList mDevices;
95 /** List of USBProxyBackend pointers. */
96 typedef std::list<USBProxyBackend *> USBProxyBackendList;
97 /** List of active USB backends. */
98 USBProxyBackendList mBackends;
99 int mLastError;
100};
101
102#endif /* !____H_USBPROXYSERVICE */
103/* 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