- Timestamp:
- Mar 16, 2016 7:17:22 PM (9 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r60065 r60067 159 159 { "convertfromraw", USAGE_CONVERTFROMRAW, VBMG_CMD_TODO, handleConvertFromRaw, VBMG_CMD_F_NO_COM }, 160 160 { "convertdd", USAGE_CONVERTFROMRAW, VBMG_CMD_TODO, handleConvertFromRaw, VBMG_CMD_F_NO_COM }, 161 { "usbdevsource", USAGE_USBDEVSOURCE, VBMG_CMD_TODO, handleUSBDevSource, 0 } 161 162 }; 162 163 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r56349 r60067 112 112 #define USAGE_ENCRYPTMEDIUM RT_BIT_64(61) 113 113 #define USAGE_MEDIUMENCCHKPWD RT_BIT_64(62) 114 #define USAGE_USBDEVSOURCE RT_BIT_64(63) 114 115 #define USAGE_ALL (~(uint64_t)0) 115 116 /** @} */ … … 308 309 /* VBoxManageUSB.cpp */ 309 310 RTEXITCODE handleUSBFilter(HandlerArg *a); 311 RTEXITCODE handleUSBDevSource(HandlerArg *a); 310 312 311 313 /* VBoxManageHostonly.cpp */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r58447 r60067 1380 1380 } 1381 1381 1382 if (fCategory & USAGE_USBDEVSOURCE) 1383 { 1384 RTStrmPrintf(pStrm, 1385 "%s usbdevsource %s add <source name>\n" 1386 " --backend <backend>\n" 1387 " --address <address>\n" 1388 "%s usbdevsource %s remove <source name>\n" 1389 "\n", SEP, SEP); 1390 } 1391 1382 1392 #ifndef VBOX_ONLY_DOCS /* Converted to man page, not needed. */ 1383 1393 if (fCategory == USAGE_ALL) -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp
r56118 r60067 547 547 return SUCCEEDED(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 548 548 } 549 550 RTEXITCODE handleUSBDevSource(HandlerArg *a) 551 { 552 HRESULT rc = S_OK; 553 554 /* at least: 0: command, 1: source id */ 555 if (a->argc < 2) 556 return errorSyntax(USAGE_USBDEVSOURCE, "Not enough parameters"); 557 558 ComPtr<IHost> host; 559 if (!strcmp(a->argv[0], "add")) 560 { 561 Bstr strBackend; 562 Bstr strAddress; 563 if (a->argc != 6) 564 return errorSyntax(USAGE_USBDEVSOURCE, "Invalid number of parameters"); 565 566 for (int i = 2; i < a->argc; i++) 567 { 568 if (!strcmp(a->argv[i], "--backend")) 569 { 570 i++; 571 strBackend = a->argv[i]; 572 } 573 else if (!strcmp(a->argv[i], "--address")) 574 { 575 i++; 576 strAddress = a->argv[i]; 577 } 578 else 579 return errorSyntax(USAGE_USBDEVSOURCE, "Parameter \"%s\" is invalid", a->argv[i]); 580 } 581 582 SafeArray<BSTR> usbSourcePropNames; 583 SafeArray<BSTR> usbSourcePropValues; 584 585 CHECK_ERROR_RET(a->virtualBox, COMGETTER(Host)(host.asOutParam()), RTEXITCODE_FAILURE); 586 CHECK_ERROR_RET(host, AddUSBDeviceSource(strBackend.raw(), Bstr(a->argv[1]).raw(), strAddress.raw(), 587 ComSafeArrayAsInParam(usbSourcePropNames), ComSafeArrayAsInParam(usbSourcePropValues)), 588 RTEXITCODE_FAILURE); 589 } 590 else if (!strcmp(a->argv[0], "remove")) 591 { 592 CHECK_ERROR_RET(a->virtualBox, COMGETTER(Host)(host.asOutParam()), RTEXITCODE_FAILURE); 593 CHECK_ERROR_RET(host, RemoveUSBDeviceSource(Bstr(a->argv[1]).raw()), RTEXITCODE_FAILURE); 594 } 595 596 return SUCCEEDED(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 597 } 598 549 599 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r59387 r60067 8600 8600 uuid="afca788c-4477-787d-60b2-3fa70e56fbbc" 8601 8601 wsmap="managed" 8602 reservedMethods=" 2" reservedAttributes="12"8602 reservedMethods="0" reservedAttributes="12" 8603 8603 > 8604 8604 <desc> … … 9062 9062 <desc>List of currently available host video capture devices.</desc> 9063 9063 </attribute> 9064 9065 <method name="addUSBDeviceSource"> 9066 <desc> 9067 Adds a new USB device source. 9068 </desc> 9069 <param name="backend" type="wstring" dir="in"> 9070 <desc>The backend to use as the new device source.</desc> 9071 </param> 9072 <param name="id" type="wstring" dir="in"> 9073 <desc>Unique ID to identify the source.</desc> 9074 </param> 9075 <param name="address" type="wstring" dir="in"> 9076 <desc> 9077 Address to use, the format is dependent on the backend. 9078 For USB/IP backends for example the notation is host[:port]. 9079 </desc> 9080 </param> 9081 <param name="propertyNames" type="wstring" safearray="yes" dir="in"> 9082 <desc>Array of property names for more detailed configuration. Not used at the moment.</desc> 9083 </param> 9084 <param name="propertyValues" type="wstring" safearray="yes" dir="in"> 9085 <desc>Array of property values for more detailed configuration. Not used at the moment.</desc> 9086 </param> 9087 </method> 9088 9089 <method name="removeUSBDeviceSource"> 9090 <desc> 9091 Removes a previously added USB device source. 9092 </desc> 9093 <param name="id" type="wstring" dir="in"> 9094 <desc>The identifier used when the source was added.</desc> 9095 </param> 9096 </method> 9064 9097 9065 9098 </interface> … … 18460 18493 Action performed by the host when an attached USB device 18461 18494 matches this filter. 18495 </desc> 18496 </attribute> 18497 18498 </interface> 18499 18500 18501 <!-- 18502 // IUSBProxyBackend 18503 ///////////////////////////////////////////////////////////////////////// 18504 --> 18505 18506 <interface 18507 name="IUSBProxyBackend" extends="$unknown" 18508 uuid="dfe56449-6989-4002-80cf-3607f377d40c" 18509 wsmap="managed" 18510 reservedAttributes="8" 18511 > 18512 <desc> 18513 The USBProxyBackend interface represents a source for USB devices available 18514 to the host for attaching to the VM. 18515 </desc> 18516 18517 <attribute name="name" type="wstring" readonly="yes"> 18518 <desc> 18519 The unique name of the proxy backend. 18520 </desc> 18521 </attribute> 18522 18523 <attribute name="type" type="wstring" readonly="yes"> 18524 <desc> 18525 The type of the backend. 18462 18526 </desc> 18463 18527 </attribute> -
trunk/src/VBox/Main/include/HostImpl.h
r52159 r60067 145 145 HRESULT generateMACAddress(com::Utf8Str &aAddress); 146 146 147 HRESULT addUSBDeviceSource(const com::Utf8Str &aBackend, const com::Utf8Str &aId, const com::Utf8Str &aAddress, 148 const std::vector<com::Utf8Str> &aPropertyNames, const std::vector<com::Utf8Str> &aPropertyValues); 149 150 HRESULT removeUSBDeviceSource(const com::Utf8Str &aId); 151 147 152 // Internal Methods. 148 153 -
trunk/src/VBox/Main/include/USBProxyBackend.h
r59117 r60067 30 30 #include "VirtualBoxImpl.h" 31 31 #include "HostUSBDeviceImpl.h" 32 #include "USBProxyBackendWrap.h" 32 33 class USBProxyService; 33 34 … … 36 37 */ 37 38 class USBProxyBackend 38 : public VirtualBoxTranslatable39 { 40 public: 41 USBProxyBackend(USBProxyService *pUsbProxyService );42 virtual int init( void);39 : public USBProxyBackendWrap 40 { 41 public: 42 USBProxyBackend(USBProxyService *pUsbProxyService, const com::Utf8Str &strId); 43 virtual int init(const com::Utf8Str &strAddress); 43 44 virtual ~USBProxyBackend(); 44 45 45 /**46 * Override of the default locking class to be used for validating lock47 * order with the standard member lock handle.48 */49 virtual VBoxLockingClass getLockingClass() const50 {51 // the USB proxy service uses the Host object lock, so return the52 // same locking class as the host53 return LOCKCLASS_HOSTOBJECT;54 }55 56 46 bool isActive(void); 57 58 RWLockHandle *lockHandle() const;47 const com::Utf8Str &i_getId(); 48 uint32_t i_getRefCount(); 59 49 60 50 /** @name Interface for the USBController and the Host object. … … 96 86 virtual PUSBDEVICE getDevices(void); 97 87 bool updateDeviceStateFake(HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice, bool *aRunFilters, SessionMachine **aIgnoreMachine); 88 uint32_t incRef(); 89 uint32_t decRef(); 98 90 99 91 static HRESULT setError(HRESULT aResultCode, const char *aText, ...); … … 104 96 private: 105 97 98 // wrapped IUSBProxyBackend properties 99 HRESULT getName(com::Utf8Str &aName); 100 HRESULT getType(com::Utf8Str &aType); 101 106 102 static DECLCALLBACK(int) serviceThread(RTTHREAD Thread, void *pvUser); 107 103 108 104 protected: 109 105 /** Pointer to the owning USB Proxy Service object. */ 110 USBProxyService *m_pUsbProxyService;106 USBProxyService *m_pUsbProxyService; 111 107 /** Thread handle of the service thread. */ 112 RTTHREAD mThread;108 RTTHREAD mThread; 113 109 /** Flag which stop() sets to cause serviceThread to return. */ 114 bool volatile mTerminate; 110 bool volatile mTerminate; 111 /** Id of the instance. */ 112 const com::Utf8Str m_strId; 113 /** Reference counter which prevents the backend instance from being removed. */ 114 uint32_t m_cRefs; 115 115 }; 116 116 … … 130 130 { 131 131 public: 132 USBProxyBackendDarwin(USBProxyService *pUsbProxyService );133 int init( void);132 USBProxyBackendDarwin(USBProxyService *pUsbProxyService, const com::Utf8Str &strId); 133 int init(const com::Utf8Str &strAddress); 134 134 ~USBProxyBackendDarwin(); 135 135 … … 179 179 { 180 180 public: 181 USBProxyBackendLinux(USBProxyService *pUsbProxyService );182 int init( void);181 USBProxyBackendLinux(USBProxyService *pUsbProxyService, const com::Utf8Str &strId); 182 int init(const com::Utf8Str &strAddress); 183 183 ~USBProxyBackendLinux(); 184 184 … … 230 230 { 231 231 public: 232 USBProxyBackendOs2 (USBProxyService *pUsbProxyService );233 /// @todo virtual int init( void);232 USBProxyBackendOs2 (USBProxyService *pUsbProxyService, const com::Utf8Str &strId); 233 /// @todo virtual int init(const com::Utf8Str &strAddress); 234 234 ~USBProxyBackendOs2(); 235 235 … … 272 272 { 273 273 public: 274 USBProxyBackendSolaris(USBProxyService *pUsbProxyService );275 int init( void);274 USBProxyBackendSolaris(USBProxyService *pUsbProxyService, const com::Utf8Str &strId); 275 int init(const com::Utf8Str &strAddress); 276 276 ~USBProxyBackendSolaris(); 277 277 … … 305 305 { 306 306 public: 307 USBProxyBackendWindows(USBProxyService *pUsbProxyService );308 int init( void);307 USBProxyBackendWindows(USBProxyService *pUsbProxyService, const com::Utf8Str &strId); 308 int init(const com::Utf8Str &strAddress); 309 309 ~USBProxyBackendWindows(); 310 310 … … 334 334 { 335 335 public: 336 USBProxyBackendFreeBSD(USBProxyService *pUsbProxyService );337 int init( void);336 USBProxyBackendFreeBSD(USBProxyService *pUsbProxyService, const com::Utf8Str &strId); 337 int init(const com::Utf8Str &strAddress); 338 338 ~USBProxyBackendFreeBSD(); 339 339 … … 369 369 /** Waiting for the complete reception of a UsbIpExportedDevice structure. */ 370 370 kUsbIpRecvState_ExportedDevice, 371 /** Waiting for a complete reception a UsbIpDeviceInterface strucutre to skip. */371 /** Waiting for a complete reception of a UsbIpDeviceInterface structure to skip. */ 372 372 kUsbIpRecvState_DeviceInterface, 373 373 /** 32bit hack. */ … … 385 385 { 386 386 public: 387 USBProxyBackendUsbIp(USBProxyService *pUsbProxyService );388 int init( void);387 USBProxyBackendUsbIp(USBProxyService *pUsbProxyService, const com::Utf8Str &strId); 388 int init(const com::Utf8Str &strAddress); 389 389 ~USBProxyBackendUsbIp(); 390 390 -
trunk/src/VBox/Main/include/USBProxyService.h
r59117 r60067 51 51 } 52 52 53 void uninit(void); 54 53 55 bool isActive(void); 54 56 int getLastError(void); … … 65 67 * @{ */ 66 68 HRESULT getDeviceCollection(std::vector<ComPtr<IHostUSBDevice> > &aUSBDevices); 69 HRESULT addUSBDeviceSource(const com::Utf8Str &aBackend, const com::Utf8Str &aId, const com::Utf8Str &aAddress, 70 const std::vector<com::Utf8Str> &aPropertyNames, const std::vector<com::Utf8Str> &aPropertyValues); 71 HRESULT removeUSBDeviceSource(const com::Utf8Str &aId); 67 72 /** @} */ 68 73 … … 78 83 79 84 void i_updateDeviceList(USBProxyBackend *pUsbProxyBackend, PUSBDEVICE pDevices); 80 void i_getUSBFilters(USBDeviceFilterList *pGlobalFilte s);85 void i_getUSBFilters(USBDeviceFilterList *pGlobalFilters); 81 86 82 87 protected: … … 84 89 85 90 static HRESULT setError(HRESULT aResultCode, const char *aText, ...); 91 92 USBProxyBackend *findUsbProxyBackendById(const com::Utf8Str &strId); 86 93 87 94 private: -
trunk/src/VBox/Main/src-server/HostImpl.cpp
r59117 r60067 1704 1704 1705 1705 return S_OK; 1706 } 1707 1708 HRESULT Host::addUSBDeviceSource(const com::Utf8Str &aBackend, const com::Utf8Str &aId, const com::Utf8Str &aAddress, 1709 const std::vector<com::Utf8Str> &aPropertyNames, const std::vector<com::Utf8Str> &aPropertyValues) 1710 { 1711 #ifdef VBOX_WITH_USB 1712 /* The USB proxy service will do the locking. */ 1713 return m->pUSBProxyService->addUSBDeviceSource(aBackend, aId, aAddress, aPropertyNames, aPropertyValues); 1714 #else 1715 ReturnComNotImplemented(); 1716 #endif 1717 } 1718 1719 HRESULT Host::removeUSBDeviceSource(const com::Utf8Str &aId) 1720 { 1721 #ifdef VBOX_WITH_USB 1722 /* The USB proxy service will do the locking. */ 1723 return m->pUSBProxyService->removeUSBDeviceSource(aId); 1724 #else 1725 ReturnComNotImplemented(); 1726 #endif 1706 1727 } 1707 1728 -
trunk/src/VBox/Main/src-server/USBProxyBackend.cpp
r59117 r60067 38 38 * Initialize data members. 39 39 */ 40 USBProxyBackend::USBProxyBackend(USBProxyService *pUsbProxyService) 41 : m_pUsbProxyService(pUsbProxyService), mThread(NIL_RTTHREAD), mTerminate(false) 42 { 43 LogFlowThisFunc(("pUsbProxyService=%p\n", pUsbProxyService)); 40 USBProxyBackend::USBProxyBackend(USBProxyService *pUsbProxyService, const com::Utf8Str &strId) 41 : m_pUsbProxyService(pUsbProxyService), mThread(NIL_RTTHREAD), mTerminate(false), m_strId(strId), 42 m_cRefs(0) 43 { 44 LogFlowThisFunc(("pUsbProxyService=%p strId=%s\n", pUsbProxyService, strId.c_str())); 44 45 } 45 46 … … 48 49 * Stub needed as long as the class isn't virtual 49 50 */ 50 int USBProxyBackend::init(void) 51 { 51 int USBProxyBackend::init(const com::Utf8Str &strAddress) 52 { 53 NOREF(strAddress); 52 54 return VINF_SUCCESS; 53 55 } … … 79 81 80 82 /** 81 * We're using the Host object lock. 82 * 83 * This is just a temporary measure until all the USB refactoring is 84 * done, probably... For now it help avoiding deadlocks we don't have 85 * time to fix. 86 * 87 * @returns Lock handle. 88 */ 89 RWLockHandle *USBProxyBackend::lockHandle() const 90 { 91 return m_pUsbProxyService->lockHandle(); 83 * Returns the ID of the instance. 84 * 85 * @returns ID string for the instance. 86 */ 87 const com::Utf8Str &USBProxyBackend::i_getId() 88 { 89 return m_strId; 90 } 91 92 93 /** 94 * Returns the current reference counter for the backend. 95 */ 96 uint32_t USBProxyBackend::i_getRefCount() 97 { 98 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 99 return m_cRefs; 92 100 } 93 101 … … 125 133 AssertReturn(!isWriteLockOnCurrentThread(), E_FAIL); 126 134 AssertReturn(!aDevice->isWriteLockOnCurrentThread(), E_FAIL); 135 136 /* 137 * Get the lists we'll iterate. 138 */ 139 Host::USBDeviceFilterList globalFilters; 140 m_pUsbProxyService->i_getUSBFilters(&globalFilters); 141 127 142 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 128 143 AutoWriteLock devLock(aDevice COMMA_LOCKVAL_SRC_POS); 129 144 AssertMsgReturn(aDevice->i_isCapturableOrHeld(), ("{%s} %s\n", aDevice->i_getName().c_str(), 130 145 aDevice->i_getStateName()), E_FAIL); 131 132 /*133 * Get the lists we'll iterate.134 */135 Host::USBDeviceFilterList globalFilters;136 137 m_pUsbProxyService->i_getUSBFilters(&globalFilters);138 146 139 147 /* … … 308 316 NOREF(aDevice); 309 317 NOREF(aSuccess); 318 319 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 320 incRef(); 310 321 } 311 322 … … 350 361 NOREF(aDevice); 351 362 NOREF(aSuccess); 363 364 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 365 decRef(); 352 366 } 353 367 … … 430 444 LogFlowThisFunc(("not active\n")); 431 445 446 /* Make sure there is no device from us in the list anymore. */ 447 m_pUsbProxyService->i_updateDeviceList(this, NULL); 448 432 449 return rc; 433 450 } … … 621 638 } 622 639 640 /** 641 * Increments the reference counter. 642 * 643 * @returns New reference count value. 644 */ 645 uint32_t USBProxyBackend::incRef() 646 { 647 Assert(isWriteLockOnCurrentThread()); 648 649 return ++m_cRefs; 650 } 651 652 /** 653 * Decrements the reference counter. 654 * 655 * @returns New reference count value. 656 */ 657 uint32_t USBProxyBackend::decRef() 658 { 659 Assert(isWriteLockOnCurrentThread()); 660 661 return --m_cRefs; 662 } 623 663 624 664 /** … … 764 804 } 765 805 766 767 /*static*/ 768 HRESULT USBProxyBackend::setError(HRESULT aResultCode, const char *aText, ...) 769 { 770 va_list va; 771 va_start(va, aText); 772 HRESULT rc = VirtualBoxBase::setErrorInternal(aResultCode, 773 COM_IIDOF(IHost), 774 "USBProxyBackend", 775 Utf8StrFmt(aText, va), 776 false /* aWarning*/, 777 true /* aLogIt*/); 778 va_end(va); 779 return rc; 806 HRESULT USBProxyBackend::getName(com::Utf8Str &aName) 807 { 808 /* strId is constant during life time, no need to lock */ 809 aName = m_strId; 810 return S_OK; 811 } 812 813 HRESULT USBProxyBackend::getType(com::Utf8Str &aType) 814 { 815 aType = Utf8Str(""); 816 return S_OK; 780 817 } 781 818 -
trunk/src/VBox/Main/src-server/USBProxyService.cpp
r59475 r60067 67 67 USBProxyBackend *pUsbProxyBackendHost; 68 68 # if defined(RT_OS_DARWIN) 69 pUsbProxyBackendHost = new USBProxyBackendDarwin(this );69 pUsbProxyBackendHost = new USBProxyBackendDarwin(this, Utf8Str("host")); 70 70 # elif defined(RT_OS_LINUX) 71 pUsbProxyBackendHost = new USBProxyBackendLinux(this );71 pUsbProxyBackendHost = new USBProxyBackendLinux(this, Utf8Str("host")); 72 72 # elif defined(RT_OS_OS2) 73 pUsbProxyBackendHost = new USBProxyBackendOs2(this );73 pUsbProxyBackendHost = new USBProxyBackendOs2(this, Utf8Str("host")); 74 74 # elif defined(RT_OS_SOLARIS) 75 pUsbProxyBackendHost = new USBProxyBackendSolaris(this );75 pUsbProxyBackendHost = new USBProxyBackendSolaris(this, Utf8Str("host")); 76 76 # elif defined(RT_OS_WINDOWS) 77 pUsbProxyBackendHost = new USBProxyBackendWindows(this );77 pUsbProxyBackendHost = new USBProxyBackendWindows(this, Utf8Str("host")); 78 78 # elif defined(RT_OS_FREEBSD) 79 pUsbProxyBackendHost = new USBProxyBackendFreeBSD(this );79 pUsbProxyBackendHost = new USBProxyBackendFreeBSD(this, Utf8Str("host")); 80 80 # else 81 pUsbProxyBackendHost = new USBProxyBackend(this );81 pUsbProxyBackendHost = new USBProxyBackend(this, Utf8Str("host")); 82 82 # endif 83 int vrc = pUsbProxyBackendHost->init( );83 int vrc = pUsbProxyBackendHost->init(Utf8Str("")); 84 84 if (RT_FAILURE(vrc)) 85 85 { … … 221 221 } 222 222 223 224 HRESULT USBProxyService::addUSBDeviceSource(const com::Utf8Str &aBackend, const com::Utf8Str &aId, const com::Utf8Str &aAddress, 225 const std::vector<com::Utf8Str> &aPropertyNames, const std::vector<com::Utf8Str> &aPropertyValues) 226 { 227 HRESULT hrc = S_OK; 228 229 /* Check whether the ID is used first. */ 230 for (USBProxyBackendList::iterator it = mBackends.begin(); 231 it != mBackends.end(); 232 ++it) 233 { 234 USBProxyBackend *pUsbProxyBackend = *it; 235 236 if (aId.equals(pUsbProxyBackend->i_getId())) 237 return setError(VBOX_E_OBJECT_IN_USE, 238 tr("The USB device source \"%s\" exists already"), aId.c_str()); 239 } 240 241 /* Create appropriate proxy backend. */ 242 if (aBackend.equalsIgnoreCase("USBIP")) 243 { 244 USBProxyBackend *pUsbProxyBackend = new USBProxyBackendUsbIp(this, aId); 245 246 int vrc = pUsbProxyBackend->init(aAddress); 247 if (RT_FAILURE(vrc)) 248 { 249 delete pUsbProxyBackend; 250 mLastError = vrc; 251 } 252 else 253 mBackends.push_back(pUsbProxyBackend); 254 } 255 else 256 hrc = setError(VBOX_E_OBJECT_NOT_FOUND, 257 tr("The USB backend \"%s\" is not supported"), aBackend.c_str()); 258 259 return hrc; 260 } 261 262 HRESULT USBProxyService::removeUSBDeviceSource(const com::Utf8Str &aId) 263 { 264 for (USBProxyBackendList::iterator it = mBackends.begin(); 265 it != mBackends.end(); 266 ++it) 267 { 268 USBProxyBackend *pUsbProxyBackend = *it; 269 270 if (aId.equals(pUsbProxyBackend->i_getId())) 271 { 272 mBackends.erase(it); 273 delete pUsbProxyBackend; 274 return S_OK; 275 } 276 } 277 278 return setError(VBOX_E_OBJECT_NOT_FOUND, 279 tr("The USB device source \"%s\" could not be found"), aId.c_str()); 280 } 223 281 224 282 /** -
trunk/src/VBox/Main/src-server/darwin/USBProxyBackendDarwin.cpp
r59123 r60067 20 20 * Header Files * 21 21 *********************************************************************************************************************************/ 22 #define LOG_GROUP LOG_GROUP_MAIN 22 23 #include "USBProxyBackend.h" 23 24 #include "Logging.h" … … 39 40 * Initialize data members. 40 41 */ 41 USBProxyBackendDarwin::USBProxyBackendDarwin(USBProxyService *aUsbProxyService )42 : USBProxyBackend(aUsbProxyService ), mServiceRunLoopRef(NULL), mNotifyOpaque(NULL), mWaitABitNextTime(false), mUSBLibInitialized(false)42 USBProxyBackendDarwin::USBProxyBackendDarwin(USBProxyService *aUsbProxyService, const com::Utf8Str &strId) 43 : USBProxyBackend(aUsbProxyService, strId), mServiceRunLoopRef(NULL), mNotifyOpaque(NULL), mWaitABitNextTime(false), mUSBLibInitialized(false) 43 44 { 44 45 LogFlowThisFunc(("aUsbProxyService=%p\n", aUsbProxyService)); … … 51 52 * @returns VBox status code. 52 53 */ 53 int USBProxyBackendDarwin::init(void) 54 { 54 int USBProxyBackendDarwin::init(const com::Utf8Str &strAddress) 55 { 56 NOREF(strAddress); 57 55 58 /* 56 59 * Initialize the USB library. … … 155 158 USBLibRemoveFilter(aDevice->i_getBackendUserData()); 156 159 aDevice->i_setBackendUserData(NULL); 160 USBProxyBackend::captureDeviceCompleted(aDevice, aSuccess); 157 161 } 158 162 … … 209 213 USBLibRemoveFilter(aDevice->i_getBackendUserData()); 210 214 aDevice->i_setBackendUserData(NULL); 215 USBProxyBackend::releaseDeviceCompleted(aDevice, aSuccess); 211 216 } 212 217 -
trunk/src/VBox/Main/src-server/freebsd/USBProxyBackendFreeBSD.cpp
r59122 r60067 60 60 * Initialize data members. 61 61 */ 62 USBProxyBackendFreeBSD::USBProxyBackendFreeBSD(USBProxyService *aUsbProxyService )63 : USBProxyBackend(a Host)62 USBProxyBackendFreeBSD::USBProxyBackendFreeBSD(USBProxyService *aUsbProxyService, const com::Utf8Str &strId) 63 : USBProxyBackend(aUsbProxyService, strId) 64 64 { 65 65 LogFlowThisFunc(("aUsbProxyService=%p\n", aUsbProxyService)); … … 72 72 * @returns S_OK on success and non-fatal failures, some COM error otherwise. 73 73 */ 74 int USBProxyBackendFreeBSD::init(void) 75 { 74 int USBProxyBackendFreeBSD::init(const com::Utf8Str &strAddress) 75 { 76 NOREF(strAddress); 77 76 78 /* 77 79 * Create semaphore. -
trunk/src/VBox/Main/src-server/generic/USBProxyBackendUsbIp.cpp
r59117 r60067 265 265 * Initialize data members. 266 266 */ 267 USBProxyBackendUsbIp::USBProxyBackendUsbIp(USBProxyService *aUsbProxyService )268 : USBProxyBackend(aUsbProxyService )267 USBProxyBackendUsbIp::USBProxyBackendUsbIp(USBProxyService *aUsbProxyService, const com::Utf8Str &strId) 268 : USBProxyBackend(aUsbProxyService, strId) 269 269 { 270 270 LogFlowThisFunc(("aUsbProxyService=%p\n", aUsbProxyService)); … … 276 276 * @returns S_OK on success and non-fatal failures, some COM error otherwise. 277 277 */ 278 int USBProxyBackendUsbIp::init( void)278 int USBProxyBackendUsbIp::init(const com::Utf8Str &strAddress) 279 279 { 280 280 int rc = VINF_SUCCESS; … … 282 282 m = new Data; 283 283 284 /** @todo: Pass in some config like host and port to connect to. */ 284 /* Split address into hostname and port. */ 285 RTCList<RTCString> lstAddress = strAddress.split(":"); 286 if (lstAddress.size() < 1) 287 return VERR_INVALID_PARAMETER; 288 m->pszHost = RTStrDup(lstAddress[0].c_str()); 289 if (!m->pszHost) 290 return VERR_NO_STR_MEMORY; 291 if (lstAddress.size() == 2) 292 { 293 m->uPort = lstAddress[1].toUInt32(); 294 if (!m->uPort) 295 return VERR_INVALID_PARAMETER; 296 } 285 297 286 298 /* Setup wakeup pipe and poll set first. */ -
trunk/src/VBox/Main/src-server/linux/USBProxyBackendLinux.cpp
r59117 r60067 60 60 * Initialize data members. 61 61 */ 62 USBProxyBackendLinux::USBProxyBackendLinux(USBProxyService *aUsbProxyService )63 : USBProxyBackend(aUsbProxyService ), mhFile(NIL_RTFILE), mhWakeupPipeR(NIL_RTPIPE),62 USBProxyBackendLinux::USBProxyBackendLinux(USBProxyService *aUsbProxyService, const com::Utf8Str &strId) 63 : USBProxyBackend(aUsbProxyService, strId), mhFile(NIL_RTFILE), mhWakeupPipeR(NIL_RTPIPE), 64 64 mhWakeupPipeW(NIL_RTPIPE), mUsingUsbfsDevices(true /* see init */), 65 65 mUdevPolls(0), mpWaiter(NULL) … … 73 73 * @returns VBox status code. 74 74 */ 75 int USBProxyBackendLinux::init(void) 76 { 75 int USBProxyBackendLinux::init(const com::Utf8Str &strAddress) 76 { 77 NOREF(strAddress); 78 77 79 const char *pcszDevicesRoot; 78 80 int rc = USBProxyLinuxChooseMethod(&mUsingUsbfsDevices, &pcszDevicesRoot); -
trunk/src/VBox/Main/src-server/os2/USBProxyBackendOs2.cpp
r59119 r60067 38 38 * Initialize data members. 39 39 */ 40 USBProxyBackendOs2::USBProxyBackendOs2(USBProxyService *aUsbProxyService )41 : USBProxyBackend(aUsbProxyService ), mhev(NULLHANDLE), mhmod(NULLHANDLE),40 USBProxyBackendOs2::USBProxyBackendOs2(USBProxyService *aUsbProxyService, const com::Utf8Str &strId) 41 : USBProxyBackend(aUsbProxyService, strId), mhev(NULLHANDLE), mhmod(NULLHANDLE), 42 42 mpfnUsbRegisterChangeNotification(NULL), mpfnUsbDeregisterNotification(NULL), 43 43 mpfnUsbQueryNumberDevices(NULL), mpfnUsbQueryDeviceReport(NULL) -
trunk/src/VBox/Main/src-server/solaris/USBProxyBackendSolaris.cpp
r59125 r60067 55 55 * Initialize data members. 56 56 */ 57 USBProxyBackendSolaris::USBProxyBackendSolaris(USBProxyService *aUsbProxyService )58 : USBProxyBackend(aUsbProxyService ), mUSBLibInitialized(false)57 USBProxyBackendSolaris::USBProxyBackendSolaris(USBProxyService *aUsbProxyService, const com::Utf8Str &strId) 58 : USBProxyBackend(aUsbProxyService, strId), mUSBLibInitialized(false) 59 59 { 60 60 LogFlowThisFunc(("aUsbProxyService=%p\n", aUsbProxyService)); … … 67 67 * @returns VBox status code. 68 68 */ 69 int USBProxyBackendSolaris::init(void) 70 { 69 int USBProxyBackendSolaris::init(const com::Utf8Str &strAddress) 70 { 71 NOREF(strAddress); 72 71 73 /* 72 74 * Create semaphore. … … 384 386 USBLibRemoveFilter(aDevice->i_getBackendUserData()); 385 387 aDevice->i_setBackendUserData(NULL); 388 USBProxyBackend::captureDeviceCompleted(aDevice, aSuccess); 386 389 } 387 390 … … 439 442 USBLibRemoveFilter(aDevice->i_getBackendUserData()); 440 443 aDevice->i_setBackendUserData(NULL); 444 USBProxyBackend::releaseDeviceCompleted(aDevice, aSuccess); 441 445 } 442 446 -
trunk/src/VBox/Main/src-server/win/USBProxyBackendWindows.cpp
r59120 r60067 38 38 * Initialize data members. 39 39 */ 40 USBProxyBackendWindows::USBProxyBackendWindows(USBProxyService *aUsbProxyService )41 : USBProxyBackend(aUsbProxyService ), mhEventInterrupt(INVALID_HANDLE_VALUE)40 USBProxyBackendWindows::USBProxyBackendWindows(USBProxyService *aUsbProxyService, const com::Utf8Str &strId) 41 : USBProxyBackend(aUsbProxyService, strId), mhEventInterrupt(INVALID_HANDLE_VALUE) 42 42 { 43 43 LogFlowThisFunc(("aUsbProxyService=%p\n", aUsbProxyService)); … … 50 50 * @returns S_OK on success and non-fatal failures, some COM error otherwise. 51 51 */ 52 int USBProxyBackendWindows::init(void) 53 { 52 int USBProxyBackendWindows::init(const com::Utf8Str &strAddress) 53 { 54 NOREF(strAddress); 55 54 56 /* 55 57 * Create the semaphore (considered fatal). -
trunk/src/VBox/Main/testcase/Makefile.kmk
r59117 r60067 208 208 tstUSBProxyLinux_SOURCES = \ 209 209 tstUSBProxyLinux.cpp \ 210 ../src-server/linux/USBProxyBackendLinux.cpp \211 210 ../src-server/linux/USBGetDevices.cpp 212 211 tstUSBProxyLinux_INCS = \ -
trunk/src/VBox/Main/testcase/tstUSBProxyLinux.cpp
r59117 r60067 21 21 *********************************************************************************************************************************/ 22 22 23 #include "USBProxyBackend.h"24 23 #include "USBGetDevices.h" 25 24 … … 31 30 32 31 /*** BEGIN STUBS ***/ 33 34 USBProxyBackend::USBProxyBackend(USBProxyService*) {}35 USBProxyBackend::~USBProxyBackend() {}36 int USBProxyBackend::init() { return VINF_SUCCESS; }37 int USBProxyBackend::start() { return VINF_SUCCESS; }38 int USBProxyBackend::stop() { return VINF_SUCCESS; }39 RWLockHandle *USBProxyBackend::lockHandle() const { return NULL; }40 void *USBProxyBackend::insertFilter(USBFILTER const*) { return NULL; }41 void USBProxyBackend::removeFilter(void*) {}42 int USBProxyBackend::captureDevice(HostUSBDevice*) { return VINF_SUCCESS; }43 void USBProxyBackend::captureDeviceCompleted(HostUSBDevice*, bool) {}44 void USBProxyBackend::detachingDevice(HostUSBDevice*) {}45 int USBProxyBackend::releaseDevice(HostUSBDevice*) { return VINF_SUCCESS; }46 void USBProxyBackend::releaseDeviceCompleted(HostUSBDevice*, bool) {}47 void USBProxyBackend::serviceThreadInit() {}48 void USBProxyBackend::serviceThreadTerm() {}49 int USBProxyBackend::wait(unsigned int) { return VINF_SUCCESS; }50 int USBProxyBackend::interruptWait() { return VINF_SUCCESS; }51 PUSBDEVICE USBProxyBackend::getDevices() { return NULL; }52 void USBProxyBackend::deviceAdded(ComObjPtr<HostUSBDevice> &aDevice, SessionMachinesList &llOpenedMachines, PUSBDEVICE aUSBDevice) {}53 void USBProxyBackend::deviceRemoved(ComObjPtr<HostUSBDevice> &aDevice) {}54 void USBProxyBackend::deviceChanged(ComObjPtr<HostUSBDevice> &aDevice, SessionMachinesList*, SessionMachine*) {}55 bool USBProxyBackend::updateDeviceState(HostUSBDevice*, USBDEVICE*, bool*, SessionMachine**) { return true; }56 bool USBProxyBackend::updateDeviceStateFake(HostUSBDevice*, USBDEVICE*, bool*, SessionMachine**) { return true; }57 bool USBProxyBackend::isActive() { return true; }58 59 VBoxMainHotplugWaiter::VBoxMainHotplugWaiter(char const*) {}60 61 com::Utf8Str HostUSBDevice::i_getName()62 {63 return Utf8Str();64 }65 66 void SysFreeString(BSTR bstr)67 {68 Assert(0);69 }70 32 71 33 static struct
Note:
See TracChangeset
for help on using the changeset viewer.