Changeset 22173 in vbox for trunk/src/VBox/Main/HostImpl.cpp
- Timestamp:
- Aug 11, 2009 3:38:59 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 50951
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HostImpl.cpp
r21885 r22173 1345 1345 //////////////////////////////////////////////////////////////////////////////// 1346 1346 1347 HRESULT Host::loadSettings (const settings::Key &aGlobal) 1348 { 1349 using namespace settings; 1350 1347 HRESULT Host::loadSettings(const settings::Host &data) 1348 { 1351 1349 AutoCaller autoCaller(this); 1352 1350 CheckComRCReturnRC(autoCaller.rc()); … … 1354 1352 AutoWriteLock alock(this); 1355 1353 1356 AssertReturn(!aGlobal.isNull(), E_FAIL);1357 1358 1354 HRESULT rc = S_OK; 1359 1355 1360 1356 #ifdef VBOX_WITH_USB 1361 Key::List filters = aGlobal.key ("USBDeviceFilters").keys ("DeviceFilter"); 1362 for (Key::List::const_iterator it = filters.begin(); 1363 it != filters.end(); ++ it) 1364 { 1365 Bstr name = (*it).stringValue ("name"); 1366 bool active = (*it).value <bool> ("active"); 1367 1368 Bstr vendorId = (*it).stringValue ("vendorId"); 1369 Bstr productId = (*it).stringValue ("productId"); 1370 Bstr revision = (*it).stringValue ("revision"); 1371 Bstr manufacturer = (*it).stringValue ("manufacturer"); 1372 Bstr product = (*it).stringValue ("product"); 1373 Bstr serialNumber = (*it).stringValue ("serialNumber"); 1374 Bstr port = (*it).stringValue ("port"); 1375 1376 USBDeviceFilterAction_T action; 1377 action = USBDeviceFilterAction_Ignore; 1378 const char *actionStr = (*it).stringValue ("action"); 1379 if (strcmp (actionStr, "Ignore") == 0) 1380 action = USBDeviceFilterAction_Ignore; 1381 else 1382 if (strcmp (actionStr, "Hold") == 0) 1383 action = USBDeviceFilterAction_Hold; 1384 else 1385 AssertMsgFailed (("Invalid action: '%s'\n", actionStr)); 1386 1387 ComObjPtr<HostUSBDeviceFilter> filterObj; 1388 filterObj.createObject(); 1389 rc = filterObj->init (this, 1390 name, active, vendorId, productId, revision, 1391 manufacturer, product, serialNumber, port, 1392 action); 1393 /* error info is set by init() when appropriate */ 1357 for (settings::USBDeviceFiltersList::const_iterator it = data.llUSBDeviceFilters.begin(); 1358 it != data.llUSBDeviceFilters.end(); 1359 ++it) 1360 { 1361 const settings::USBDeviceFilter &f = *it; 1362 ComObjPtr<HostUSBDeviceFilter> pFilter; 1363 pFilter.createObject(); 1364 rc = pFilter->init(this, f); 1394 1365 CheckComRCBreakRC (rc); 1395 1366 1396 mUSBDeviceFilters.push_back (filterObj);1397 filterObj->mInList = true;1367 mUSBDeviceFilters.push_back(pFilter); 1368 pFilter->mInList = true; 1398 1369 1399 1370 /* notify the proxy (only when the filter is active) */ 1400 if ( filterObj->data().mActive)1401 { 1402 HostUSBDeviceFilter *flt = filterObj; /* resolve ambiguity */1403 flt->id() = mUSBProxyService->insertFilter (&filterObj->data().mUSBFilter);1371 if (pFilter->data().mActive) 1372 { 1373 HostUSBDeviceFilter *flt = pFilter; /* resolve ambiguity */ 1374 flt->id() = mUSBProxyService->insertFilter(&pFilter->data().mUSBFilter); 1404 1375 } 1405 1376 } … … 1409 1380 } 1410 1381 1411 HRESULT Host::saveSettings (settings::Key &aGlobal) 1412 { 1413 using namespace settings; 1414 1382 HRESULT Host::saveSettings(settings::Host &data) 1383 { 1415 1384 AutoCaller autoCaller(this); 1416 1385 CheckComRCReturnRC(autoCaller.rc()); … … 1418 1387 AutoWriteLock alock(this); 1419 1388 1420 ComAssertRet (!aGlobal.isNull(), E_FAIL);1421 1422 1389 #ifdef VBOX_WITH_USB 1423 /* first, delete the entry */ 1424 Key filters = aGlobal.findKey ("USBDeviceFilters"); 1425 if (!filters.isNull()) 1426 filters.zap(); 1427 /* then, recreate it */ 1428 filters = aGlobal.createKey ("USBDeviceFilters"); 1429 1430 USBDeviceFilterList::const_iterator it = mUSBDeviceFilters.begin(); 1431 while (it != mUSBDeviceFilters.end()) 1432 { 1433 AutoWriteLock filterLock (*it); 1434 const HostUSBDeviceFilter::Data &data = (*it)->data(); 1435 1436 Key filter = filters.appendKey ("DeviceFilter"); 1437 1438 filter.setValue <Bstr> ("name", data.mName); 1439 filter.setValue <bool> ("active", !!data.mActive); 1440 1441 /* all are optional */ 1442 Bstr str; 1443 (*it)->COMGETTER (VendorId) (str.asOutParam()); 1444 if (!str.isNull()) 1445 filter.setValue <Bstr> ("vendorId", str); 1446 1447 (*it)->COMGETTER (ProductId) (str.asOutParam()); 1448 if (!str.isNull()) 1449 filter.setValue <Bstr> ("productId", str); 1450 1451 (*it)->COMGETTER (Revision) (str.asOutParam()); 1452 if (!str.isNull()) 1453 filter.setValue <Bstr> ("revision", str); 1454 1455 (*it)->COMGETTER (Manufacturer) (str.asOutParam()); 1456 if (!str.isNull()) 1457 filter.setValue <Bstr> ("manufacturer", str); 1458 1459 (*it)->COMGETTER (Product) (str.asOutParam()); 1460 if (!str.isNull()) 1461 filter.setValue <Bstr> ("product", str); 1462 1463 (*it)->COMGETTER (SerialNumber) (str.asOutParam()); 1464 if (!str.isNull()) 1465 filter.setValue <Bstr> ("serialNumber", str); 1466 1467 (*it)->COMGETTER (Port) (str.asOutParam()); 1468 if (!str.isNull()) 1469 filter.setValue <Bstr> ("port", str); 1470 1471 /* action is mandatory */ 1472 USBDeviceFilterAction_T action = USBDeviceFilterAction_Null; 1473 (*it)->COMGETTER (Action) (&action); 1474 if (action == USBDeviceFilterAction_Ignore) 1475 filter.setStringValue ("action", "Ignore"); 1476 else if (action == USBDeviceFilterAction_Hold) 1477 filter.setStringValue ("action", "Hold"); 1478 else 1479 AssertMsgFailed (("Invalid action: %d\n", action)); 1480 1481 ++ it; 1390 data.llUSBDeviceFilters.clear(); 1391 1392 for (USBDeviceFilterList::const_iterator it = mUSBDeviceFilters.begin(); 1393 it != mUSBDeviceFilters.end(); 1394 ++it) 1395 { 1396 ComObjPtr<HostUSBDeviceFilter> pFilter = *it; 1397 settings::USBDeviceFilter f; 1398 pFilter->saveSettings(f); 1399 data.llUSBDeviceFilters.push_back(f); 1482 1400 } 1483 1401 #endif /* VBOX_WITH_USB */
Note:
See TracChangeset
for help on using the changeset viewer.