Changeset 7852 in vbox for trunk/src/VBox/Main
- Timestamp:
- Apr 9, 2008 5:17:24 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 29460
- Location:
- trunk/src/VBox/Main
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HostImpl.cpp
r7847 r7852 1002 1002 { 1003 1003 ComAssertRet (filter->id() == NULL, E_FAIL); 1004 #ifndef VBOX_WITH_USBFILTER1005 filter->id() =1006 mUSBProxyService->insertFilter (ComPtr <IUSBDeviceFilter> (aFilter));1007 #else1008 1004 filter->id() = mUSBProxyService->insertFilter (&filter->data().mUSBFilter); 1009 #endif1010 1005 } 1011 1006 … … 1095 1090 { 1096 1091 ComAssertRet (aFilter->id() == NULL, E_FAIL); 1097 #ifndef VBOX_WITH_USBFILTER1098 aFilter->id() =1099 mUSBProxyService->insertFilter (ComPtr <IUSBDeviceFilter> (aFilter));1100 #else1101 1092 aFilter->id() = mUSBProxyService->insertFilter (&aFilter->data().mUSBFilter); 1102 #endif1103 1093 } 1104 1094 else … … 1116 1106 ComAssertRet (aFilter->id() != NULL, E_FAIL); 1117 1107 mUSBProxyService->removeFilter (aFilter->id()); 1118 #ifndef VBOX_WITH_USBFILTER1119 aFilter->id() =1120 mUSBProxyService->insertFilter (ComPtr <IUSBDeviceFilter> (aFilter));1121 #else1122 1108 aFilter->id() = mUSBProxyService->insertFilter (&aFilter->data().mUSBFilter); 1123 #endif1124 1109 } 1125 1110 } … … 1186 1171 { 1187 1172 HostUSBDeviceFilter *flt = filterObj; /* resolve ambiguity */ 1188 #ifndef VBOX_WITH_USBFILTER1189 flt->id() =1190 mUSBProxyService->insertFilter (ComPtr <IUSBDeviceFilter> (flt));1191 #else1192 1173 flt->id() = mUSBProxyService->insertFilter (&filterObj->data().mUSBFilter); 1193 #endif1194 1174 } 1195 1175 } … … 1224 1204 filter.setValue <Bstr> ("name", data.mName); 1225 1205 filter.setValue <bool> ("active", !!data.mActive); 1226 1227 #ifndef VBOX_WITH_USBFILTER1228 1229 /* all are optional */1230 if (data.mVendorId.string())1231 filter.setValue <Bstr> ("vendorId", data.mVendorId.string());1232 if (data.mProductId.string())1233 filter.setValue <Bstr> ("productId", data.mProductId.string());1234 if (data.mRevision.string())1235 filter.setValue <Bstr> ("revision", data.mRevision.string());1236 if (data.mManufacturer.string())1237 filter.setValue <Bstr> ("manufacturer", data.mManufacturer.string());1238 if (data.mProduct.string())1239 filter.setValue <Bstr> ("product", data.mProduct.string());1240 if (data.mSerialNumber.string())1241 filter.setValue <Bstr> ("serialNumber", data.mSerialNumber.string());1242 if (data.mPort.string())1243 filter.setValue <Bstr> ("port", data.mPort.string());1244 1245 /* action is mandatory */1246 if (data.mAction == USBDeviceFilterAction_Ignore)1247 filter.setStringValue ("action", "Ignore");1248 else1249 if (data.mAction == USBDeviceFilterAction_Hold)1250 filter.setStringValue ("action", "Hold");1251 else1252 AssertMsgFailed (("Invalid action: %d\n", data.mAction));1253 1254 #else /* VBOX_WITH_USBFILTER */1255 1206 1256 1207 /* all are optional */ … … 1293 1244 else 1294 1245 AssertMsgFailed (("Invalid action: %d\n", action)); 1295 1296 #endif /* VBOX_WITH_USBFILTER */1297 1246 1298 1247 ++ it; … … 2088 2037 if (aDevice->isMatch (data)) 2089 2038 { 2090 #ifndef VBOX_WITH_USBFILTER2091 USBDeviceFilterAction_T action = data.mAction;2092 #else2093 2039 USBDeviceFilterAction_T action = USBDeviceFilterAction_Null; 2094 2040 (*it)->COMGETTER (Action) (&action); 2095 #endif2096 2041 if (action == USBDeviceFilterAction_Ignore) 2097 2042 { -
trunk/src/VBox/Main/HostUSBDeviceImpl.cpp
r7828 r7852 856 856 return false; 857 857 858 #ifndef VBOX_WITH_USBFILTER859 if (!aData.mVendorId.isMatch (mUsb->idVendor))860 {861 LogFlowThisFunc (("vendor not match %04X\n",862 mUsb->idVendor));863 return false;864 }865 if (!aData.mProductId.isMatch (mUsb->idProduct))866 {867 LogFlowThisFunc (("product id not match %04X\n",868 mUsb->idProduct));869 return false;870 }871 if (!aData.mRevision.isMatch (mUsb->bcdDevice))872 {873 LogFlowThisFunc (("rev not match %04X\n",874 mUsb->bcdDevice));875 return false;876 }877 878 #if !defined (RT_OS_WINDOWS)879 // these filters are temporarily ignored on Win32880 if (!aData.mManufacturer.isMatch (Bstr (mUsb->pszManufacturer)))881 return false;882 if (!aData.mProduct.isMatch (Bstr (mUsb->pszProduct)))883 return false;884 if (!aData.mSerialNumber.isMatch (Bstr (mUsb->pszSerialNumber)))885 return false;886 /// @todo (dmik) pusPort is yet absent887 // if (!aData.mPort.isMatch (Bstr (mUsb->pusPort)))888 // return false;889 #endif890 891 // Host USB devices are local, so remote is always FALSE892 if (!aData.mRemote.isMatch (FALSE))893 {894 LogFlowMember (("Host::HostUSBDevice: remote not match FALSE\n"));895 return false;896 }897 898 /// @todo (dmik): bird, I assumed isMatch() is called only for devices899 // that are suitable for holding/capturing (also assuming that when the device900 // is just attached it first goes to our filter driver, and only after applying901 // filters goes back to the system when appropriate). So the below902 // doesn't look too correct; moreover, currently there is no determinable903 // "any match" state for intervalic filters, and it will be not so easy904 // to determine this state for an arbitrary regexp expression...905 // For now, I just check that the string filter is empty (which doesn't906 // actually reflect all possible "any match" filters).907 //908 // bird: This method was called for any device some weeks back, and it most certainly909 // should be called for 'busy' devices still. However, we do *not* want 'busy' devices910 // to match empty filters (because that will for instance capture all USB keyboards & mice).911 // You assumption about a filter driver is not correct on linux. We're racing with912 // everyone else in the system there - see your problem with usbfs access.913 //914 // The customer *requires* a way of matching all devices which the host isn't using,915 // if that is now difficult or the below method opens holes in the matching, this *must*916 // be addresses immediately.917 918 /*919 * If all the criteria is empty, devices which are used by the host will not match.920 */921 if ( mUsb->enmState == USBDEVICESTATE_USED_BY_HOST_CAPTURABLE922 && aData.mVendorId.string().isEmpty()923 && aData.mProductId.string().isEmpty()924 && aData.mRevision.string().isEmpty()925 && aData.mManufacturer.string().isEmpty()926 && aData.mProduct.string().isEmpty()927 && aData.mSerialNumber.string().isEmpty())928 return false;929 930 #else /* VBOX_WITH_USBFILTER */931 858 if (!USBFilterMatchDevice (&aData.mUSBFilter, mUsb)) 932 859 return false; … … 937 864 && !USBFilterHasAnySubstatialCriteria (&aData.mUSBFilter)) 938 865 return false; 939 #endif /* VBOX_WITH_USBFILTER */940 866 941 867 LogFlowThisFunc (("returns true\n")); -
trunk/src/VBox/Main/Makefile.kmk
r7850 r7852 120 120 endif 121 121 ifdef VBOX_WITH_USB 122 VBoxSVC_DEFS += VBOX_WITH_USB VBOX_WITH_USBFILTER122 VBoxSVC_DEFS += VBOX_WITH_USB 123 123 ifdef VBOX_WITH_EHCI 124 124 VBoxSVC_DEFS += VBOX_WITH_EHCI -
trunk/src/VBox/Main/USBControllerImpl.cpp
r7829 r7852 403 403 404 404 ComAssertRet (filter->id() == NULL, E_FAIL); 405 #ifndef VBOX_WITH_USBFILTER406 filter->id() = service->insertFilter (ComPtr <IUSBDeviceFilter> (aFilter));407 #else408 405 filter->id() = service->insertFilter (&filter->data().mUSBFilter); 409 #endif410 406 } 411 407 … … 600 596 601 597 /* all are optional */ 602 #ifndef VBOX_WITH_USBFILTER603 604 if (data.mVendorId.string())605 filter.setValue <Bstr> ("vendorId", data.mVendorId.string());606 if (data.mProductId.string())607 filter.setValue <Bstr> ("productId", data.mProductId.string());608 if (data.mRevision.string())609 filter.setValue <Bstr> ("revision", data.mRevision.string());610 if (data.mManufacturer.string())611 filter.setValue <Bstr> ("manufacturer", data.mManufacturer.string());612 if (data.mProduct.string())613 filter.setValue <Bstr> ("product", data.mProduct.string());614 if (data.mSerialNumber.string())615 filter.setValue <Bstr> ("serialNumber", data.mSerialNumber.string());616 if (data.mPort.string())617 filter.setValue <Bstr> ("port", data.mPort.string());618 if (data.mRemote.string())619 filter.setValue <Bstr> ("remote", data.mRemote.string());620 621 #else /* VBOX_WITH_USBFILTER */622 623 598 Bstr str; 624 599 (*it)->COMGETTER (VendorId) (str.asOutParam()); … … 652 627 if (data.mRemote.string()) 653 628 filter.setValue <Bstr> ("remote", data.mRemote.string()); 654 655 #endif /* VBOX_WITH_USBFILTER */656 629 657 630 if (data.mMaskedIfs) … … 828 801 USBDeviceFilter *flt = *it; /* resolve ambiguity */ 829 802 ComAssertRet (flt->id() == NULL, false); 830 #ifndef VBOX_WITH_USBFILTER831 flt->id() = service->insertFilter832 (ComPtr <IUSBDeviceFilter> (flt));833 #else834 803 flt->id() = service->insertFilter (&flt->data().mUSBFilter); 835 #endif836 804 } 837 805 } … … 1056 1024 { 1057 1025 ComAssertRet (aFilter->id() == NULL, E_FAIL); 1058 #ifndef VBOX_WITH_USBFILTER1059 aFilter->id() = service->insertFilter1060 (ComPtr <IUSBDeviceFilter> (aFilter));1061 #else1062 1026 aFilter->id() = service->insertFilter (&aFilter->data().mUSBFilter); 1063 #endif1064 1027 } 1065 1028 else … … 1077 1040 ComAssertRet (aFilter->id() != NULL, E_FAIL); 1078 1041 service->removeFilter (aFilter->id()); 1079 #ifndef VBOX_WITH_USBFILTER1080 aFilter->id() = service->insertFilter1081 (ComPtr <IUSBDeviceFilter> (aFilter));1082 #else1083 1042 aFilter->id() = service->insertFilter (&aFilter->data().mUSBFilter); 1084 #endif1085 1043 } 1086 1044 } … … 1153 1111 1154 1112 /* query fields */ 1155 #ifdef VBOX_WITH_USBFILTER1156 1113 USBFILTER dev; 1157 1114 USBFilterInit (&dev, USBFILTERTYPE_CAPTURE); 1158 #endif1159 1115 1160 1116 USHORT vendorId = 0; … … 1162 1118 ComAssertComRCRet (rc, false); 1163 1119 ComAssertRet (vendorId, false); 1164 #ifdef VBOX_WITH_USBFILTER1165 1120 int vrc = USBFilterSetNumExact (&dev, USBFILTERIDX_VENDOR_ID, vendorId, true); AssertRC(vrc); 1166 #endif1167 1121 1168 1122 USHORT productId = 0; … … 1170 1124 ComAssertComRCRet (rc, false); 1171 1125 ComAssertRet (productId, false); 1172 #ifdef VBOX_WITH_USBFILTER1173 1126 vrc = USBFilterSetNumExact (&dev, USBFILTERIDX_PRODUCT_ID, productId, true); AssertRC(vrc); 1174 #endif1175 1127 1176 1128 USHORT revision; 1177 1129 rc = aUSBDevice->COMGETTER(Revision) (&revision); 1178 1130 ComAssertComRCRet (rc, false); 1179 #ifdef VBOX_WITH_USBFILTER1180 1131 vrc = USBFilterSetNumExact (&dev, USBFILTERIDX_DEVICE, revision, true); AssertRC(vrc); 1181 #endif1182 1132 1183 1133 Bstr manufacturer; 1184 1134 rc = aUSBDevice->COMGETTER(Manufacturer) (manufacturer.asOutParam()); 1185 1135 ComAssertComRCRet (rc, false); 1186 #ifdef VBOX_WITH_USBFILTER1187 1136 if (!manufacturer.isNull()) 1188 1137 USBFilterSetStringExact (&dev, USBFILTERIDX_MANUFACTURER_STR, Utf8Str(manufacturer), true); 1189 #endif1190 1138 1191 1139 Bstr product; 1192 1140 rc = aUSBDevice->COMGETTER(Product) (product.asOutParam()); 1193 1141 ComAssertComRCRet (rc, false); 1194 #ifdef VBOX_WITH_USBFILTER1195 1142 if (!product.isNull()) 1196 1143 USBFilterSetStringExact (&dev, USBFILTERIDX_PRODUCT_STR, Utf8Str(product), true); 1197 #endif1198 1144 1199 1145 Bstr serialNumber; 1200 1146 rc = aUSBDevice->COMGETTER(SerialNumber) (serialNumber.asOutParam()); 1201 1147 ComAssertComRCRet (rc, false); 1202 #ifdef VBOX_WITH_USBFILTER1203 1148 if (!serialNumber.isNull()) 1204 1149 USBFilterSetStringExact (&dev, USBFILTERIDX_SERIAL_NUMBER_STR, Utf8Str(serialNumber), true); 1205 #endif1206 1150 1207 1151 Bstr address; … … 1212 1156 rc = aUSBDevice->COMGETTER(Port)(&port); 1213 1157 ComAssertComRCRet (rc, false); 1214 #ifdef VBOX_WITH_USBFILTER1215 1158 USBFilterSetNumExact (&dev, USBFILTERIDX_PORT, port, true); 1216 #endif1217 1159 1218 1160 BOOL remote = FALSE; … … 1231 1173 const USBDeviceFilter::Data &aData = (*it)->data(); 1232 1174 1233 1234 1175 if (!aData.mActive) 1235 1176 continue; 1236 1177 if (!aData.mRemote.isMatch (remote)) 1237 1178 continue; 1238 1239 #ifndef VBOX_WITH_USBFILTER1240 if (!aData.mVendorId.isMatch (vendorId))1241 continue;1242 if (!aData.mProductId.isMatch (productId))1243 continue;1244 if (!aData.mRevision.isMatch (revision))1245 continue;1246 1247 # if !defined (RT_OS_WINDOWS)1248 /* these filters are 'temporarily' ignored on Win32 */1249 if (!aData.mManufacturer.isMatch (manufacturer))1250 continue;1251 if (!aData.mProduct.isMatch (product))1252 continue;1253 if (!aData.mSerialNumber.isMatch (serialNumber))1254 continue;1255 if (!aData.mPort.isMatch (port))1256 continue;1257 # endif1258 1259 #else /* VBOX_WITH_USBFILTER */1260 1179 if (!USBFilterMatch (&aData.mUSBFilter, &dev)) 1261 1180 continue; 1262 #endif /* VBOX_WITH_USBFILTER */1263 1181 1264 1182 match = true; … … 1304 1222 { 1305 1223 AssertReturn (flt->id() == NULL, E_FAIL); 1306 #ifndef VBOX_WITH_USBFILTER1307 flt->id() = service->insertFilter1308 (ComPtr <IUSBDeviceFilter> (flt));1309 #else1310 1224 flt->id() = service->insertFilter (&flt->data().mUSBFilter); 1311 #endif1312 1225 } 1313 1226 else -
trunk/src/VBox/Main/USBDeviceFilterImpl.cpp
r7836 r7852 1 /* $Id:$ */ 1 2 /** @file 2 *3 3 * Implementation of VirtualBox COM components: 4 4 * USBDeviceFilter and HostUSBDeviceFilter … … 25 25 #include <iprt/cpputils.h> 26 26 27 #ifdef VBOX_WITH_USBFILTER 27 28 28 //////////////////////////////////////////////////////////////////////////////// 29 29 // Internal Helpers … … 141 141 return S_OK; 142 142 } 143 #endif /* VBOX_WITH_USBFILTER */144 143 145 144 … … 201 200 202 201 /* initialize all filters to any match using null string */ 203 #ifndef VBOX_WITH_USBFILTER204 mData->mVendorId = NULL;205 mData->mProductId = NULL;206 mData->mRevision = NULL;207 mData->mManufacturer = NULL;208 mData->mProduct = NULL;209 mData->mSerialNumber = NULL;210 mData->mPort = NULL;211 #else /* VBOX_WITH_USBFILTER */212 202 USBFilterInit(&mData->mUSBFilter, USBFILTERTYPE_CAPTURE); 213 #endif /* VBOX_WITH_USBFILTER */214 203 mData->mRemote = NULL; 215 204 … … 279 268 280 269 /* initialize all filters to any match using null string */ 281 #ifndef VBOX_WITH_USBFILTER282 mData->mVendorId = NULL;283 mData->mProductId = NULL;284 mData->mRevision = NULL;285 mData->mManufacturer = NULL;286 mData->mProduct = NULL;287 mData->mSerialNumber = NULL;288 mData->mPort = NULL;289 #else /* VBOX_WITH_USBFILTER */290 270 USBFilterInit (&mData->mUSBFilter, USBFILTERTYPE_CAPTURE); 291 #endif /* VBOX_WITH_USBFILTER */292 271 mData->mRemote = NULL; 293 272 … … 519 498 STDMETHODIMP USBDeviceFilter::COMGETTER(VendorId) (BSTR *aVendorId) 520 499 { 521 #ifndef VBOX_WITH_USBFILTER522 if (!aVendorId)523 return E_POINTER;524 525 AutoCaller autoCaller (this);526 CheckComRCReturnRC (autoCaller.rc());527 528 AutoReaderLock alock (this);529 530 mData->mVendorId.string().cloneTo (aVendorId);531 532 return S_OK;533 #else534 500 return usbFilterFieldGetter (USBFILTERIDX_VENDOR_ID, aVendorId); 535 #endif536 501 } 537 502 538 503 STDMETHODIMP USBDeviceFilter::COMSETTER(VendorId) (INPTR BSTR aVendorId) 539 504 { 540 #ifndef VBOX_WITH_USBFILTER541 AutoCaller autoCaller (this);542 CheckComRCReturnRC (autoCaller.rc());543 544 /* the machine needs to be mutable */545 Machine::AutoMutableStateDependency adep (mParent->parent());546 CheckComRCReturnRC (adep.rc());547 548 AutoLock alock (this);549 550 if (mData->mVendorId.string() != aVendorId)551 {552 Data::USHORTFilter flt = aVendorId;553 ComAssertRet (!flt.isNull(), E_FAIL);554 if (!flt.isValid())555 return setError (E_INVALIDARG,556 tr ("Vendor ID filter string '%ls' is not valid (error at position %d)"),557 aVendorId, flt.errorPosition() + 1);558 #if defined (RT_OS_WINDOWS)559 // intervalic filters are temporarily disabled560 if (!flt.first().isNull() && flt.first().isValid())561 return setError (E_INVALIDARG,562 tr ("'%ls': Intervalic filters are not currently available on this platform"),563 aVendorId);564 #endif565 566 mData.backup();567 mData->mVendorId = flt;568 569 /* leave the lock before informing callbacks */570 alock.unlock();571 572 return mParent->onDeviceFilterChange (this);573 }574 575 return S_OK;576 #else /* VBOX_WITH_USBFILTER */577 505 return usbFilterFieldSetter (USBFILTERIDX_VENDOR_ID, aVendorId, tr ("Vendor ID")); 578 #endif /* VBOX_WITH_USBFILTER */579 506 } 580 507 581 508 STDMETHODIMP USBDeviceFilter::COMGETTER(ProductId) (BSTR *aProductId) 582 509 { 583 #ifndef VBOX_WITH_USBFILTER584 if (!aProductId)585 return E_POINTER;586 587 AutoCaller autoCaller (this);588 CheckComRCReturnRC (autoCaller.rc());589 590 AutoReaderLock alock (this);591 592 mData->mProductId.string().cloneTo (aProductId);593 594 return S_OK;595 #else596 510 return usbFilterFieldGetter (USBFILTERIDX_PRODUCT_ID, aProductId); 597 #endif598 511 } 599 512 600 513 STDMETHODIMP USBDeviceFilter::COMSETTER(ProductId) (INPTR BSTR aProductId) 601 514 { 602 #ifndef VBOX_WITH_USBFILTER603 AutoCaller autoCaller (this);604 CheckComRCReturnRC (autoCaller.rc());605 606 /* the machine needs to be mutable */607 Machine::AutoMutableStateDependency adep (mParent->parent());608 CheckComRCReturnRC (adep.rc());609 610 AutoLock alock (this);611 612 if (mData->mProductId.string() != aProductId)613 {614 Data::USHORTFilter flt = aProductId;615 ComAssertRet (!flt.isNull(), E_FAIL);616 if (!flt.isValid())617 return setError (E_INVALIDARG,618 tr ("Product ID filter string '%ls' is not valid (error at position %d)"),619 aProductId, flt.errorPosition() + 1);620 #if defined (RT_OS_WINDOWS)621 // intervalic filters are temporarily disabled622 if (!flt.first().isNull() && flt.first().isValid())623 return setError (E_INVALIDARG,624 tr ("'%ls': Intervalic filters are not currently available on this platform"),625 aProductId);626 #endif627 628 mData.backup();629 mData->mProductId = flt;630 631 /* leave the lock before informing callbacks */632 alock.unlock();633 634 return mParent->onDeviceFilterChange (this);635 }636 637 return S_OK;638 #else /* VBOX_WITH_USBFILTER */639 515 return usbFilterFieldSetter (USBFILTERIDX_PRODUCT_ID, aProductId, tr ("Product ID")); 640 #endif /* VBOX_WITH_USBFILTER */641 516 } 642 517 643 518 STDMETHODIMP USBDeviceFilter::COMGETTER(Revision) (BSTR *aRevision) 644 519 { 645 #ifndef VBOX_WITH_USBFILTER646 if (!aRevision)647 return E_POINTER;648 649 AutoCaller autoCaller (this);650 CheckComRCReturnRC (autoCaller.rc());651 652 AutoReaderLock alock (this);653 654 mData->mRevision.string().cloneTo (aRevision);655 656 return S_OK;657 #else658 520 return usbFilterFieldGetter (USBFILTERIDX_DEVICE, aRevision); 659 #endif660 521 } 661 522 662 523 STDMETHODIMP USBDeviceFilter::COMSETTER(Revision) (INPTR BSTR aRevision) 663 524 { 664 #ifndef VBOX_WITH_USBFILTER665 AutoCaller autoCaller (this);666 CheckComRCReturnRC (autoCaller.rc());667 668 /* the machine needs to be mutable */669 Machine::AutoMutableStateDependency adep (mParent->parent());670 CheckComRCReturnRC (adep.rc());671 672 AutoLock alock (this);673 674 if (mData->mRevision.string() != aRevision)675 {676 Data::USHORTFilter flt = aRevision;677 ComAssertRet (!flt.isNull(), E_FAIL);678 if (!flt.isValid())679 return setError (E_INVALIDARG,680 tr ("Revision filter string '%ls' is not valid (error at position %d)"),681 aRevision, flt.errorPosition() + 1);682 #if defined (RT_OS_WINDOWS)683 // intervalic filters are temporarily disabled684 if (!flt.first().isNull() && flt.first().isValid())685 return setError (E_INVALIDARG,686 tr ("'%ls': Intervalic filters are not currently available on this platform"),687 aRevision);688 #endif689 690 mData.backup();691 mData->mRevision = flt;692 693 /* leave the lock before informing callbacks */694 alock.unlock();695 696 return mParent->onDeviceFilterChange (this);697 }698 699 return S_OK;700 #else /* VBOX_WITH_USBFILTER */701 525 return usbFilterFieldSetter (USBFILTERIDX_DEVICE, aRevision, tr ("Revision")); 702 #endif /* VBOX_WITH_USBFILTER */703 526 } 704 527 705 528 STDMETHODIMP USBDeviceFilter::COMGETTER(Manufacturer) (BSTR *aManufacturer) 706 529 { 707 #ifndef VBOX_WITH_USBFILTER708 if (!aManufacturer)709 return E_POINTER;710 711 AutoCaller autoCaller (this);712 CheckComRCReturnRC (autoCaller.rc());713 714 AutoReaderLock alock (this);715 716 mData->mManufacturer.string().cloneTo (aManufacturer);717 718 return S_OK;719 #else720 530 return usbFilterFieldGetter (USBFILTERIDX_MANUFACTURER_STR, aManufacturer); 721 #endif722 531 } 723 532 724 533 STDMETHODIMP USBDeviceFilter::COMSETTER(Manufacturer) (INPTR BSTR aManufacturer) 725 534 { 726 #ifndef VBOX_WITH_USBFILTER727 AutoCaller autoCaller (this);728 CheckComRCReturnRC (autoCaller.rc());729 730 /* the machine needs to be mutable */731 Machine::AutoMutableStateDependency adep (mParent->parent());732 CheckComRCReturnRC (adep.rc());733 734 AutoLock alock (this);735 736 if (mData->mManufacturer.string() != aManufacturer)737 {738 Data::BstrFilter flt = aManufacturer;739 ComAssertRet (!flt.isNull(), E_FAIL);740 if (!flt.isValid())741 return setError (E_INVALIDARG,742 tr ("Manufacturer filter string '%ls' is not valid (error at position %d)"),743 aManufacturer, flt.errorPosition() + 1);744 745 mData.backup();746 mData->mManufacturer = flt;747 748 /* leave the lock before informing callbacks */749 alock.unlock();750 751 return mParent->onDeviceFilterChange (this);752 }753 754 return S_OK;755 #else /* VBOX_WITH_USBFILTER */756 535 return usbFilterFieldSetter (USBFILTERIDX_MANUFACTURER_STR, aManufacturer, tr ("Manufacturer")); 757 #endif /* VBOX_WITH_USBFILTER */758 536 } 759 537 760 538 STDMETHODIMP USBDeviceFilter::COMGETTER(Product) (BSTR *aProduct) 761 539 { 762 #ifndef VBOX_WITH_USBFILTER763 if (!aProduct)764 return E_POINTER;765 766 AutoCaller autoCaller (this);767 CheckComRCReturnRC (autoCaller.rc());768 769 AutoReaderLock alock (this);770 771 mData->mProduct.string().cloneTo (aProduct);772 773 return S_OK;774 #else775 540 return usbFilterFieldGetter (USBFILTERIDX_PRODUCT_STR, aProduct); 776 #endif777 541 } 778 542 779 543 STDMETHODIMP USBDeviceFilter::COMSETTER(Product) (INPTR BSTR aProduct) 780 544 { 781 #ifndef VBOX_WITH_USBFILTER782 AutoCaller autoCaller (this);783 CheckComRCReturnRC (autoCaller.rc());784 785 /* the machine needs to be mutable */786 Machine::AutoMutableStateDependency adep (mParent->parent());787 CheckComRCReturnRC (adep.rc());788 789 AutoLock alock (this);790 791 if (mData->mProduct.string() != aProduct)792 {793 Data::BstrFilter flt = aProduct;794 ComAssertRet (!flt.isNull(), E_FAIL);795 if (!flt.isValid())796 return setError (E_INVALIDARG,797 tr ("Product filter string '%ls' is not valid (error at position %d)"),798 aProduct, flt.errorPosition() + 1);799 800 mData.backup();801 mData->mProduct = flt;802 803 /* leave the lock before informing callbacks */804 alock.unlock();805 806 return mParent->onDeviceFilterChange (this);807 }808 809 return S_OK;810 #else /* VBOX_WITH_USBFILTER */811 545 return usbFilterFieldSetter (USBFILTERIDX_PRODUCT_STR, aProduct, tr ("Product")); 812 #endif /* VBOX_WITH_USBFILTER */813 546 } 814 547 815 548 STDMETHODIMP USBDeviceFilter::COMGETTER(SerialNumber) (BSTR *aSerialNumber) 816 549 { 817 #ifndef VBOX_WITH_USBFILTER818 if (!aSerialNumber)819 return E_POINTER;820 821 AutoCaller autoCaller (this);822 CheckComRCReturnRC (autoCaller.rc());823 824 AutoReaderLock alock (this);825 826 mData->mSerialNumber.string().cloneTo (aSerialNumber);827 828 return S_OK;829 #else830 550 return usbFilterFieldGetter (USBFILTERIDX_SERIAL_NUMBER_STR, aSerialNumber); 831 #endif832 551 } 833 552 834 553 STDMETHODIMP USBDeviceFilter::COMSETTER(SerialNumber) (INPTR BSTR aSerialNumber) 835 554 { 836 #ifndef VBOX_WITH_USBFILTER837 AutoCaller autoCaller (this);838 CheckComRCReturnRC (autoCaller.rc());839 840 /* the machine needs to be mutable */841 Machine::AutoMutableStateDependency adep (mParent->parent());842 CheckComRCReturnRC (adep.rc());843 844 AutoLock alock (this);845 846 if (mData->mSerialNumber.string() != aSerialNumber)847 {848 Data::BstrFilter flt = aSerialNumber;849 ComAssertRet (!flt.isNull(), E_FAIL);850 if (!flt.isValid())851 return setError (E_INVALIDARG,852 tr ("Serial number filter string '%ls' is not valid (error at position %d)"),853 aSerialNumber, flt.errorPosition() + 1);854 855 mData.backup();856 mData->mSerialNumber = flt;857 858 /* leave the lock before informing callbacks */859 alock.unlock();860 861 return mParent->onDeviceFilterChange (this);862 }863 864 return S_OK;865 #else /* VBOX_WITH_USBFILTER */866 555 return usbFilterFieldSetter (USBFILTERIDX_SERIAL_NUMBER_STR, aSerialNumber, tr ("Serial number")); 867 #endif /* VBOX_WITH_USBFILTER */868 556 } 869 557 870 558 STDMETHODIMP USBDeviceFilter::COMGETTER(Port) (BSTR *aPort) 871 559 { 872 #ifndef VBOX_WITH_USBFILTER873 if (!aPort)874 return E_POINTER;875 876 AutoCaller autoCaller (this);877 CheckComRCReturnRC (autoCaller.rc());878 879 AutoReaderLock alock (this);880 881 mData->mPort.string().cloneTo (aPort);882 883 return S_OK;884 #else885 560 return usbFilterFieldGetter (USBFILTERIDX_PORT, aPort); 886 #endif887 561 } 888 562 889 563 STDMETHODIMP USBDeviceFilter::COMSETTER(Port) (INPTR BSTR aPort) 890 564 { 891 #ifndef VBOX_WITH_USBFILTER892 AutoCaller autoCaller (this);893 CheckComRCReturnRC (autoCaller.rc());894 895 /* the machine needs to be mutable */896 Machine::AutoMutableStateDependency adep (mParent->parent());897 CheckComRCReturnRC (adep.rc());898 899 AutoLock alock (this);900 901 if (mData->mPort.string() != aPort)902 {903 Data::USHORTFilter flt = aPort;904 ComAssertRet (!flt.isNull(), E_FAIL);905 if (!flt.isValid())906 return setError (E_INVALIDARG,907 tr ("Port number filter string '%ls' is not valid (error at position %d)"),908 aPort, flt.errorPosition() + 1);909 #if defined (RT_OS_WINDOWS)910 // intervalic filters are temporarily disabled911 if (!flt.first().isNull() && flt.first().isValid())912 return setError (E_INVALIDARG,913 tr ("'%ls': Intervalic filters are not currently available on this platform"),914 aPort);915 #endif916 917 mData.backup();918 mData->mPort = flt;919 920 /* leave the lock before informing callbacks */921 alock.unlock();922 923 return mParent->onDeviceFilterChange (this);924 }925 926 return S_OK;927 #else /* VBOX_WITH_USBFILTER */928 565 return usbFilterFieldSetter (USBFILTERIDX_PORT, aPort, tr ("Port number")); 929 #endif /* VBOX_WITH_USBFILTER */930 566 } 931 567 … … 1104 740 } 1105 741 1106 #ifdef VBOX_WITH_USBFILTER1107 742 /** 1108 743 * Generic USB filter field getter. … … 1170 805 return S_OK; 1171 806 } 1172 #endif /* VBOX_WITH_USBFILTER */ 807 1173 808 1174 809 //////////////////////////////////////////////////////////////////////////////// … … 1225 860 mData->mName = aName; 1226 861 mData->mActive = aActive; 1227 #ifndef VBOX_WITH_USBFILTER1228 mData->mAction = aAction;1229 1230 /* initialize all filters to any match using null string */1231 mData->mVendorId = NULL;1232 mData->mProductId = NULL;1233 mData->mRevision = NULL;1234 mData->mManufacturer = NULL;1235 mData->mProduct = NULL;1236 mData->mSerialNumber = NULL;1237 mData->mPort = NULL;1238 #else /* VBOX_WITH_USBFILTER */1239 862 USBFilterInit (&mData->mUSBFilter, USBFILTERTYPE_IGNORE); 1240 #endif /* VBOX_WITH_USBFILTER */1241 863 mData->mRemote = NULL; 1242 864 mData->mMaskedIfs = 0; … … 1250 872 do 1251 873 { 1252 #ifndef VBOX_WITH_USBFILTER1253 874 rc = COMSETTER(Action) (aAction); 1254 875 CheckComRCBreakRC (rc); 1255 #endif /* VBOX_WITH_USBFILTER */1256 876 rc = COMSETTER(VendorId) (aVendorId); 1257 877 CheckComRCBreakRC (rc); … … 1303 923 mData->mName = aName; 1304 924 mData->mActive = FALSE; 1305 #ifndef VBOX_WITH_USBFILTER1306 mData->mAction = USBDeviceFilterAction_Ignore;1307 #endif /* !VBOX_WITH_USBFILTER */1308 1309 925 mInList = false; 1310 1311 #ifndef VBOX_WITH_USBFILTER1312 /* initialize all filters to any match using null string */1313 mData->mVendorId = NULL;1314 mData->mProductId = NULL;1315 mData->mRevision = NULL;1316 mData->mManufacturer = NULL;1317 mData->mProduct = NULL;1318 mData->mSerialNumber = NULL;1319 mData->mPort = NULL;1320 #else /* VBOX_WITH_USBFILTER */1321 926 USBFilterInit (&mData->mUSBFilter, USBFILTERTYPE_IGNORE); 1322 #endif /* VBOX_WITH_USBFILTER */1323 927 mData->mRemote = NULL; 1324 928 mData->mMaskedIfs = 0; … … 1430 1034 STDMETHODIMP HostUSBDeviceFilter::COMGETTER(VendorId) (BSTR *aVendorId) 1431 1035 { 1432 #ifndef VBOX_WITH_USBFILTER1433 if (!aVendorId)1434 return E_POINTER;1435 1436 AutoCaller autoCaller (this);1437 CheckComRCReturnRC (autoCaller.rc());1438 1439 AutoReaderLock alock (this);1440 1441 mData->mVendorId.string().cloneTo (aVendorId);1442 1443 return S_OK;1444 #else1445 1036 return usbFilterFieldGetter (USBFILTERIDX_VENDOR_ID, aVendorId); 1446 #endif1447 1037 } 1448 1038 1449 1039 STDMETHODIMP HostUSBDeviceFilter::COMSETTER(VendorId) (INPTR BSTR aVendorId) 1450 1040 { 1451 #ifndef VBOX_WITH_USBFILTER1452 AutoCaller autoCaller (this);1453 CheckComRCReturnRC (autoCaller.rc());1454 1455 AutoLock alock (this);1456 1457 if (mData->mVendorId.string() != aVendorId)1458 {1459 Data::USHORTFilter flt = aVendorId;1460 ComAssertRet (!flt.isNull(), E_FAIL);1461 if (!flt.isValid())1462 return setError (E_INVALIDARG,1463 tr ("Vendor ID filter string '%ls' is not valid (error at position %d)"),1464 aVendorId, flt.errorPosition() + 1);1465 #if defined (RT_OS_WINDOWS)1466 // intervalic filters are temporarily disabled1467 if (!flt.first().isNull() && flt.first().isValid())1468 return setError (E_INVALIDARG,1469 tr ("'%ls': Intervalic filters are not currently available on this platform"),1470 aVendorId);1471 #endif1472 1473 mData->mVendorId = flt;1474 1475 /* leave the lock before informing callbacks */1476 alock.unlock();1477 1478 return mParent->onUSBDeviceFilterChange (this);1479 }1480 1481 return S_OK;1482 #else /* VBOX_WITH_USBFILTER */1483 1041 return usbFilterFieldSetter (USBFILTERIDX_VENDOR_ID, aVendorId, tr ("Vendor ID")); 1484 #endif /* VBOX_WITH_USBFILTER */1485 1042 } 1486 1043 1487 1044 STDMETHODIMP HostUSBDeviceFilter::COMGETTER(ProductId) (BSTR *aProductId) 1488 1045 { 1489 #ifndef VBOX_WITH_USBFILTER1490 if (!aProductId)1491 return E_POINTER;1492 1493 AutoCaller autoCaller (this);1494 CheckComRCReturnRC (autoCaller.rc());1495 1496 AutoReaderLock alock (this);1497 1498 mData->mProductId.string().cloneTo (aProductId);1499 1500 return S_OK;1501 #else1502 1046 return usbFilterFieldGetter (USBFILTERIDX_PRODUCT_ID, aProductId); 1503 #endif1504 1047 } 1505 1048 1506 1049 STDMETHODIMP HostUSBDeviceFilter::COMSETTER(ProductId) (INPTR BSTR aProductId) 1507 1050 { 1508 #ifndef VBOX_WITH_USBFILTER1509 AutoCaller autoCaller (this);1510 CheckComRCReturnRC (autoCaller.rc());1511 1512 AutoLock alock (this);1513 1514 if (mData->mProductId.string() != aProductId)1515 {1516 Data::USHORTFilter flt = aProductId;1517 ComAssertRet (!flt.isNull(), E_FAIL);1518 if (!flt.isValid())1519 return setError (E_INVALIDARG,1520 tr ("Product ID filter string '%ls' is not valid (error at position %d)"),1521 aProductId, flt.errorPosition() + 1);1522 #if defined (RT_OS_WINDOWS)1523 // intervalic filters are temporarily disabled1524 if (!flt.first().isNull() && flt.first().isValid())1525 return setError (E_INVALIDARG,1526 tr ("'%ls': Intervalic filters are not currently available on this platform"),1527 aProductId);1528 #endif1529 1530 mData->mProductId = flt;1531 1532 /* leave the lock before informing callbacks */1533 alock.unlock();1534 1535 return mParent->onUSBDeviceFilterChange (this);1536 }1537 1538 return S_OK;1539 #else /* VBOX_WITH_USBFILTER */1540 1051 return usbFilterFieldSetter (USBFILTERIDX_PRODUCT_ID, aProductId, tr ("Product ID")); 1541 #endif /* VBOX_WITH_USBFILTER */1542 1052 } 1543 1053 1544 1054 STDMETHODIMP HostUSBDeviceFilter::COMGETTER(Revision) (BSTR *aRevision) 1545 1055 { 1546 #ifndef VBOX_WITH_USBFILTER1547 if (!aRevision)1548 return E_POINTER;1549 1550 AutoCaller autoCaller (this);1551 CheckComRCReturnRC (autoCaller.rc());1552 1553 AutoReaderLock alock (this);1554 1555 mData->mRevision.string().cloneTo (aRevision);1556 1557 return S_OK;1558 #else1559 1056 return usbFilterFieldGetter (USBFILTERIDX_DEVICE, aRevision); 1560 #endif1561 1057 } 1562 1058 1563 1059 STDMETHODIMP HostUSBDeviceFilter::COMSETTER(Revision) (INPTR BSTR aRevision) 1564 1060 { 1565 #ifndef VBOX_WITH_USBFILTER1566 AutoCaller autoCaller (this);1567 CheckComRCReturnRC (autoCaller.rc());1568 1569 AutoLock alock (this);1570 1571 if (mData->mRevision.string() != aRevision)1572 {1573 Data::USHORTFilter flt = aRevision;1574 ComAssertRet (!flt.isNull(), E_FAIL);1575 if (!flt.isValid())1576 return setError (E_INVALIDARG,1577 tr ("Revision filter string '%ls' is not valid (error at position %d)"),1578 aRevision, flt.errorPosition() + 1);1579 #if defined (RT_OS_WINDOWS)1580 // intervalic filters are temporarily disabled1581 if (!flt.first().isNull() && flt.first().isValid())1582 return setError (E_INVALIDARG,1583 tr ("'%ls': Intervalic filters are not currently available on this platform"),1584 aRevision);1585 #endif1586 1587 mData->mRevision = flt;1588 1589 /* leave the lock before informing callbacks */1590 alock.unlock();1591 1592 return mParent->onUSBDeviceFilterChange (this);1593 }1594 1595 return S_OK;1596 #else /* VBOX_WITH_USBFILTER */1597 1061 return usbFilterFieldSetter (USBFILTERIDX_DEVICE, aRevision, tr ("Revision")); 1598 #endif /* VBOX_WITH_USBFILTER */1599 1062 } 1600 1063 1601 1064 STDMETHODIMP HostUSBDeviceFilter::COMGETTER(Manufacturer) (BSTR *aManufacturer) 1602 1065 { 1603 #ifndef VBOX_WITH_USBFILTER1604 if (!aManufacturer)1605 return E_POINTER;1606 1607 AutoCaller autoCaller (this);1608 CheckComRCReturnRC (autoCaller.rc());1609 1610 AutoReaderLock alock (this);1611 1612 mData->mManufacturer.string().cloneTo (aManufacturer);1613 1614 return S_OK;1615 #else1616 1066 return usbFilterFieldGetter (USBFILTERIDX_MANUFACTURER_STR, aManufacturer); 1617 #endif1618 1067 } 1619 1068 1620 1069 STDMETHODIMP HostUSBDeviceFilter::COMSETTER(Manufacturer) (INPTR BSTR aManufacturer) 1621 1070 { 1622 #ifndef VBOX_WITH_USBFILTER1623 AutoCaller autoCaller (this);1624 CheckComRCReturnRC (autoCaller.rc());1625 1626 AutoLock alock (this);1627 1628 if (mData->mManufacturer.string() != aManufacturer)1629 {1630 Data::BstrFilter flt = aManufacturer;1631 ComAssertRet (!flt.isNull(), E_FAIL);1632 if (!flt.isValid())1633 return setError (E_INVALIDARG,1634 tr ("Manufacturer filter string '%ls' is not valid (error at position %d)"),1635 aManufacturer, flt.errorPosition() + 1);1636 1637 mData->mManufacturer = flt;1638 1639 /* leave the lock before informing callbacks */1640 alock.unlock();1641 1642 return mParent->onUSBDeviceFilterChange (this);1643 }1644 1645 return S_OK;1646 #else /* VBOX_WITH_USBFILTER */1647 1071 return usbFilterFieldSetter (USBFILTERIDX_MANUFACTURER_STR, aManufacturer, tr ("Manufacturer")); 1648 #endif /* VBOX_WITH_USBFILTER */1649 1072 } 1650 1073 1651 1074 STDMETHODIMP HostUSBDeviceFilter::COMGETTER(Product) (BSTR *aProduct) 1652 1075 { 1653 #ifndef VBOX_WITH_USBFILTER1654 if (!aProduct)1655 return E_POINTER;1656 1657 AutoCaller autoCaller (this);1658 CheckComRCReturnRC (autoCaller.rc());1659 1660 AutoReaderLock alock (this);1661 1662 mData->mProduct.string().cloneTo (aProduct);1663 1664 return S_OK;1665 #else1666 1076 return usbFilterFieldGetter (USBFILTERIDX_PRODUCT_STR, aProduct); 1667 #endif1668 1077 } 1669 1078 1670 1079 STDMETHODIMP HostUSBDeviceFilter::COMSETTER(Product) (INPTR BSTR aProduct) 1671 1080 { 1672 #ifndef VBOX_WITH_USBFILTER1673 AutoCaller autoCaller (this);1674 CheckComRCReturnRC (autoCaller.rc());1675 1676 AutoLock alock (this);1677 1678 if (mData->mProduct.string() != aProduct)1679 {1680 Data::BstrFilter flt = aProduct;1681 ComAssertRet (!flt.isNull(), E_FAIL);1682 if (!flt.isValid())1683 return setError (E_INVALIDARG,1684 tr ("Product filter string '%ls' is not valid (error at position %d)"),1685 aProduct, flt.errorPosition() + 1);1686 1687 mData->mProduct = flt;1688 1689 /* leave the lock before informing callbacks */1690 alock.unlock();1691 1692 return mParent->onUSBDeviceFilterChange (this);1693 }1694 1695 return S_OK;1696 #else /* VBOX_WITH_USBFILTER */1697 1081 return usbFilterFieldSetter (USBFILTERIDX_PRODUCT_STR, aProduct, tr ("Product")); 1698 #endif /* VBOX_WITH_USBFILTER */1699 1082 } 1700 1083 1701 1084 STDMETHODIMP HostUSBDeviceFilter::COMGETTER(SerialNumber) (BSTR *aSerialNumber) 1702 1085 { 1703 #ifndef VBOX_WITH_USBFILTER1704 if (!aSerialNumber)1705 return E_POINTER;1706 1707 AutoCaller autoCaller (this);1708 CheckComRCReturnRC (autoCaller.rc());1709 1710 AutoReaderLock alock (this);1711 1712 mData->mSerialNumber.string().cloneTo (aSerialNumber);1713 1714 return S_OK;1715 #else /* VBOX_WITH_USBFILTER */1716 1086 return usbFilterFieldGetter (USBFILTERIDX_SERIAL_NUMBER_STR, aSerialNumber); 1717 #endif /* VBOX_WITH_USBFILTER */1718 1087 } 1719 1088 1720 1089 STDMETHODIMP HostUSBDeviceFilter::COMSETTER(SerialNumber) (INPTR BSTR aSerialNumber) 1721 1090 { 1722 #ifndef VBOX_WITH_USBFILTER1723 AutoCaller autoCaller (this);1724 CheckComRCReturnRC (autoCaller.rc());1725 1726 AutoLock alock (this);1727 1728 if (mData->mSerialNumber.string() != aSerialNumber)1729 {1730 Data::BstrFilter flt = aSerialNumber;1731 ComAssertRet (!flt.isNull(), E_FAIL);1732 if (!flt.isValid())1733 return setError (E_INVALIDARG,1734 tr ("Serial number filter string '%ls' is not valid (error at position %d)"),1735 aSerialNumber, flt.errorPosition() + 1);1736 1737 mData->mSerialNumber = flt;1738 1739 /* leave the lock before informing callbacks */1740 alock.unlock();1741 1742 return mParent->onUSBDeviceFilterChange (this);1743 }1744 1745 return S_OK;1746 #else /* VBOX_WITH_USBFILTER */1747 1091 return usbFilterFieldSetter (USBFILTERIDX_SERIAL_NUMBER_STR, aSerialNumber, tr ("Serial number")); 1748 #endif /* VBOX_WITH_USBFILTER */1749 1092 } 1750 1093 1751 1094 STDMETHODIMP HostUSBDeviceFilter::COMGETTER(Port) (BSTR *aPort) 1752 1095 { 1753 #ifndef VBOX_WITH_USBFILTER1754 if (!aPort)1755 return E_POINTER;1756 1757 AutoCaller autoCaller (this);1758 CheckComRCReturnRC (autoCaller.rc());1759 1760 AutoReaderLock alock (this);1761 1762 mData->mPort.string().cloneTo (aPort);1763 1764 return S_OK;1765 #else /* VBOX_WITH_USBFILTER */1766 1096 return usbFilterFieldGetter (USBFILTERIDX_PORT, aPort); 1767 #endif /* VBOX_WITH_USBFILTER */1768 1097 } 1769 1098 1770 1099 STDMETHODIMP HostUSBDeviceFilter::COMSETTER(Port) (INPTR BSTR aPort) 1771 1100 { 1772 #ifndef VBOX_WITH_USBFILTER1773 AutoCaller autoCaller (this);1774 CheckComRCReturnRC (autoCaller.rc());1775 1776 AutoLock alock (this);1777 1778 if (mData->mPort.string() != aPort)1779 {1780 Data::USHORTFilter flt = aPort;1781 ComAssertRet (!flt.isNull(), E_FAIL);1782 if (!flt.isValid())1783 return setError (E_INVALIDARG,1784 tr ("Port number filter string '%ls' is not valid (error at position %d)"),1785 aPort, flt.errorPosition() + 1);1786 #if defined (RT_OS_WINDOWS)1787 // intervalic filters are temporarily disabled1788 if (!flt.first().isNull() && flt.first().isValid())1789 return setError (E_INVALIDARG,1790 tr ("'%ls': Intervalic filters are not currently available on this platform"),1791 aPort);1792 #endif1793 1794 mData->mPort = flt;1795 1796 /* leave the lock before informing callbacks */1797 alock.unlock();1798 1799 return mParent->onUSBDeviceFilterChange (this);1800 }1801 1802 return S_OK;1803 #else /* VBOX_WITH_USBFILTER */1804 1101 return usbFilterFieldSetter (USBFILTERIDX_PORT, aPort, tr ("Port number")); 1805 #endif /* VBOX_WITH_USBFILTER */1806 1102 } 1807 1103 … … 1862 1158 AutoReaderLock alock (this); 1863 1159 1864 #ifndef VBOX_WITH_USBFILTER1865 *aAction = mData->mAction;1866 #else /* VBOX_WITH_USBFILTER */1867 1160 switch (USBFilterGetFilterType (&mData->mUSBFilter)) 1868 1161 { … … 1871 1164 default: *aAction = USBDeviceFilterAction_Null; break; 1872 1165 } 1873 #endif /* VBOX_WITH_USBFILTER */1874 1166 1875 1167 return S_OK; … … 1883 1175 AutoLock alock (this); 1884 1176 1885 #ifndef VBOX_WITH_USBFILTER1886 if (mData->mAction != aAction)1887 {1888 mData->mAction = aAction;1889 1890 /* leave the lock before informing callbacks */1891 alock.unlock();1892 1893 return mParent->onUSBDeviceFilterChange (this);1894 }1895 1896 #else /* VBOX_WITH_USBFILTER */1897 1177 USBFILTERTYPE filterType; 1898 1178 switch (aAction) … … 1921 1201 return mParent->onUSBDeviceFilterChange (this); 1922 1202 } 1923 #endif /* VBOX_WITH_USBFILTER */ 1924 1925 return S_OK; 1926 } 1927 1928 1929 #ifdef VBOX_WITH_USBFILTER 1203 1204 return S_OK; 1205 } 1206 1930 1207 /** 1931 1208 * Generic USB filter field getter. … … 1950 1227 return S_OK; 1951 1228 } 1952 1953 1229 1954 1230 /** … … 1990 1266 return S_OK; 1991 1267 } 1992 #endif /* VBOX_WITH_USBFILTER */ 1993 1268 -
trunk/src/VBox/Main/USBProxyService.cpp
r7207 r7852 463 463 464 464 465 #ifdef VBOX_WITH_USBFILTER466 465 /*static*/ void USBProxyService::initFilterFromDevice (PUSBFILTER aFilter, HostUSBDevice *aDevice) 467 466 { … … 493 492 } 494 493 } 495 #endif /* VBOX_WITH_USBFILTER */496 494 497 495 … … 579 577 * for those subclasses that don't reimplement this method. 580 578 */ 581 #ifndef VBOX_WITH_USBFILTER582 void *USBProxyService::insertFilter (IUSBDeviceFilter * /* aFilter */)583 #else584 579 void *USBProxyService::insertFilter (PCUSBFILTER /* aFilter */) 585 #endif586 580 { 587 581 // return non-NULL to prevent failed assertions in Main -
trunk/src/VBox/Main/include/USBDeviceFilterImpl.h
r7829 r7852 24 24 25 25 #include "Matching.h" 26 #ifdef VBOX_WITH_USBFILTER 27 # include <VBox/usbfilter.h> 28 #endif /* VBOX_WITH_USBFILTER */ 26 #include <VBox/usbfilter.h> 29 27 30 28 class USBController; … … 44 42 struct Data 45 43 { 46 #ifndef VBOX_WITH_USBFILTER47 struct ConvForRegexp48 {49 inline static Bstr toBstr (const USHORT &aValue)50 {51 return Bstr (Utf8StrFmt ("%04X", aValue));52 }53 54 inline static const Bstr &toBstr (const Bstr &aValue)55 {56 return aValue;57 }58 };59 60 typedef matching::Matchable61 <matching::TwoParsedFilters <matching::ParsedIntervalFilter <USHORT>,62 matching::ParsedRegexpFilter <ConvForRegexp, true, 4, 4> > >63 USHORTFilter;64 65 typedef matching::Matchable66 <matching::ParsedRegexpFilter <ConvForRegexp, false> > BstrFilter;67 #endif /* !VBOX_WITH_USBFILTER */68 69 44 typedef matching::Matchable <matching::ParsedBoolFilter> BOOLFilter; 70 45 71 46 Data() : mActive (FALSE), mMaskedIfs (0), mId (NULL) {} 72 #ifdef VBOX_WITH_USBFILTER73 47 Data (const Data &aThat) : mName (aThat.mName), mActive (aThat.mActive), 74 48 mRemote (aThat.mRemote), mMaskedIfs (aThat.mMaskedIfs) , mId (aThat.mId) … … 76 50 USBFilterClone (&mUSBFilter, &aThat.mUSBFilter); 77 51 } 78 #endif /* VBOX_WITH_USBFILTER */79 52 80 53 bool operator== (const Data &that) const 81 54 { 82 #ifndef VBOX_WITH_USBFILTER83 return this == &that ||84 (mName == that.mName &&85 mActive == that.mActive &&86 mVendorId.string() == that. mVendorId.string() &&87 mProductId.string() == that. mProductId.string() &&88 mRevision.string() == that. mRevision.string() &&89 mManufacturer.string() == that. mManufacturer.string() &&90 mProduct.string() == that. mProduct.string() &&91 mSerialNumber.string() == that. mSerialNumber.string() &&92 mPort.string() == that. mPort.string() &&93 mRemote.string() == that. mRemote.string() &&94 mMaskedIfs == that. mMaskedIfs);95 #else /* VBOX_WITH_USBFILTER */96 55 return this == &that 97 56 || ( mName == that.mName … … 99 58 && mMaskedIfs == that.mMaskedIfs 100 59 && USBFilterIsIdentical (&mUSBFilter, &that.mUSBFilter)); 101 #endif /* VBOX_WITH_USBFILTER */102 60 } 103 61 62 /** The filter name. */ 104 63 Bstr mName; 64 /** Indicates whether the filter is active or not. */ 105 65 BOOL mActive; 106 107 #ifndef VBOX_WITH_USBFILTER 108 USHORTFilter mVendorId; 109 USHORTFilter mProductId; 110 USHORTFilter mRevision; 111 BstrFilter mManufacturer; 112 BstrFilter mProduct; 113 BstrFilter mSerialNumber; 114 USHORTFilter mPort; 115 #else /* VBOX_WITH_USBFILTER */ 66 /** Remote or local matching criterion. */ 67 BOOLFilter mRemote; 68 /** The filter data blob. */ 116 69 USBFILTER mUSBFilter; 117 #endif /* VBOX_WITH_USBFILTER */ 118 BOOLFilter mRemote; 119 120 /** Config value. */ 70 71 /** Interface masking bit mask that should be applied to matching devices. */ 121 72 ULONG mMaskedIfs; 122 73 … … 202 153 static const wchar_t *getComponentName() { return L"USBDeviceFilter"; } 203 154 204 #ifdef VBOX_WITH_USBFILTER205 155 // tr() wants to belong to a class it seems, thus this one here. 206 156 static HRESULT usbFilterFieldFromString (PUSBFILTER aFilter, USBFILTERIDX aIdx, INPTR BSTR aStr, const char *aName, Utf8Str &aErrStr); 207 #endif208 157 209 158 private: 210 #ifdef VBOX_WITH_USBFILTER211 159 HRESULT usbFilterFieldGetter (USBFILTERIDX aIdx, BSTR *aStr); 212 160 HRESULT usbFilterFieldSetter (USBFILTERIDX aIdx, Bstr aStr, Utf8Str aName); 213 #endif214 161 215 162 const ComObjPtr <USBController, ComWeakRef> mParent; … … 238 185 struct Data : public USBDeviceFilter::Data 239 186 { 240 #ifndef VBOX_WITH_USBFILTER241 Data() : mAction (USBDeviceFilterAction_Ignore) {}242 USBDeviceFilterAction_T mAction;243 #else /* VBOX_WITH_USBFILTER */244 187 Data() {} 245 #endif /* VBOX_WITH_USBFILTER */246 188 }; 247 189 … … 318 260 319 261 private: 320 #ifdef VBOX_WITH_USBFILTER321 262 HRESULT usbFilterFieldGetter (USBFILTERIDX aIdx, BSTR *aStr); 322 263 HRESULT usbFilterFieldSetter (USBFILTERIDX aIdx, Bstr aStr, Utf8Str aName); 323 #endif324 264 325 265 const ComObjPtr <Host, ComWeakRef> mParent; -
trunk/src/VBox/Main/include/USBProxyService.h
r7851 r7852 38 38 * @return ID of the inserted filter 39 39 */ 40 #ifdef VBOX_WITH_USBFILTER41 40 virtual void *insertFilter (PCUSBFILTER aFilter); 42 #else43 virtual void *insertFilter (IUSBDeviceFilter *aFilter);44 #endif45 41 46 42 /** … … 126 122 static uint64_t calcSerialHash (const char *aSerial); 127 123 128 #ifdef VBOX_WITH_USBFILTER129 124 /** 130 125 * Initializes a filter with the data from the specified device. … … 134 129 */ 135 130 static void initFilterFromDevice (PUSBFILTER aFilter, HostUSBDevice *aDevice); 136 #endif137 131 138 132 protected:
Note:
See TracChangeset
for help on using the changeset viewer.