Changeset 15570 in vbox for trunk/src/VBox/Main
- Timestamp:
- Dec 16, 2008 10:39:34 AM (16 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl.cpp
r15448 r15570 4298 4298 ComPtr<IHost> host; 4299 4299 virtualBox->COMGETTER(Host)(host.asOutParam()); 4300 ComPtr<IHostNetworkInterfaceCollection> coll; 4301 host->COMGETTER(NetworkInterfaces)(coll.asOutParam()); 4302 ComPtr<IHostNetworkInterface> hostInterface; 4303 if (!SUCCEEDED(coll->FindByName(hostif, hostInterface.asOutParam()))) 4300 com::SafeIfaceArray <IHostNetworkInterface> hostNetworkInterfaces; 4301 CHECK_ERROR(host, 4302 COMGETTER(NetworkInterfaces) (ComSafeArrayAsOutParam (hostNetworkInterfaces))); 4303 bool found = false; 4304 for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i) 4305 { 4306 Bstr name; 4307 hostNetworkInterfaces[i].COMGETTER(Name) (name.asOutParam()); 4308 if (name == hostif) 4309 { 4310 found = true; 4311 break; 4312 } 4313 } 4314 if (!found) 4304 4315 { 4305 4316 return setError (VBOX_E_HOST_ERROR, -
trunk/src/VBox/Main/ConsoleImpl2.cpp
r15498 r15570 1312 1312 1313 1313 # elif defined(RT_OS_WINDOWS) 1314 ComPtr<IHostNetworkInterfaceCollection> coll;1315 hrc = host->COMGETTER(NetworkInterfaces) (coll.asOutParam());1314 com::SafeIfaceArray <IHostNetworkInterface> hostNetworkInterfaces; 1315 hrc = host->COMGETTER(NetworkInterfaces) (ComSafeArrayAsOutParam (hostNetworkInterfaces))); 1316 1316 if(FAILED(hrc)) 1317 1317 { … … 1320 1320 } 1321 1321 ComPtr<IHostNetworkInterface> hostInterface; 1322 rc = coll->FindByName(HifName, hostInterface.asOutParam()); 1323 if (!SUCCEEDED(rc)) 1322 for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i) 1323 { 1324 Bstr name; 1325 hostNetworkInterfaces[i].COMGETTER(Name) (name.asOutParam()); 1326 if (name == hostif) 1327 { 1328 hostInterface = hostNetworkInterfaces[i]; 1329 break; 1330 } 1331 } 1332 if (hostInterface.IsNull()) 1324 1333 { 1325 1334 AssertBreakpoint(); … … 1499 1508 Bstr hostInterfaceName; 1500 1509 hrc = networkAdapter->COMGETTER(HostInterface)(hostInterfaceName.asOutParam()); H(); 1501 ComPtr<IHostNetworkInterfaceCollection> coll;1502 hrc = host->COMGETTER(NetworkInterfaces) (coll.asOutParam());H();1510 com::SafeIfaceArray <IHostNetworkInterface> hostNetworkInterfaces; 1511 hrc = host->COMGETTER(NetworkInterfaces) (ComSafeArrayAsOutParam (hostNetworkInterfaces))); H(); 1503 1512 ComPtr<IHostNetworkInterface> hostInterface; 1504 rc = coll->FindByName(hostInterfaceName, hostInterface.asOutParam()); 1505 if (!SUCCEEDED(rc)) 1513 for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i) 1514 { 1515 Bstr name; 1516 hostNetworkInterfaces[i].COMGETTER(Name) (name.asOutParam()); 1517 if (name == hostif) 1518 { 1519 hostInterface = hostNetworkInterfaces[i]; 1520 break; 1521 } 1522 } 1523 if (hostInterface.IsNull()) 1506 1524 { 1507 1525 AssertMsgFailed(("Cannot get GUID for host interface '%ls'\n", hostInterfaceName)); -
trunk/src/VBox/Main/HostImpl.cpp
r15455 r15570 751 751 * @param drives address of result pointer 752 752 */ 753 STDMETHODIMP Host::COMGETTER(NetworkInterfaces) ( IHostNetworkInterfaceCollection **networkInterfaces)753 STDMETHODIMP Host::COMGETTER(NetworkInterfaces) (ComSafeArrayOut (IHostNetworkInterface *, aNetworkInterfaces)) 754 754 { 755 755 #if defined(RT_OS_WINDOWS) || defined(VBOX_WITH_NETFLT) /*|| defined(RT_OS_OS2)*/ 756 if ( !networkInterfaces)756 if (ComSafeArrayOutIsNull (aNetworkInterfaces)) 757 757 return E_POINTER; 758 758 759 AutoWriteLock alock (this); 759 760 CHECK_READY(); … … 1056 1057 # endif /* RT_OS_LINUX */ 1057 1058 #endif 1058 ComObjPtr <HostNetworkInterfaceCollection> collection; 1059 collection.createObject(); 1060 collection->init (list); 1061 collection.queryInterfaceTo (networkInterfaces); 1059 SafeIfaceArray <IHostNetworkInterface> networkInterfaces (list); 1060 networkInterfaces.detachTo (ComSafeArrayOutArg (aNetworkInterfaces)); 1061 1062 1062 return S_OK; 1063 1063 … … 1377 1377 /* first check whether an interface with the given name already exists */ 1378 1378 { 1379 ComPtr <IHostNetworkInterfaceCollection> coll;1380 rc = COMGETTER(NetworkInterfaces) (coll.asOutParam());1379 com::SafeIfaceArray <IHostNetworkInterface> hostNetworkInterfaces; 1380 rc = host->COMGETTER(NetworkInterfaces) (ComSafeArrayAsOutParam (hostNetworkInterfaces))); 1381 1381 CheckComRCReturnRC (rc); 1382 ComPtr <IHostNetworkInterface> iface; 1383 if (SUCCEEDED (coll->FindByName (aName, iface.asOutParam()))) 1384 return setError (E_INVALIDARG, 1385 tr ("Host network interface '%ls' already exists"), aName); 1382 for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i) 1383 { 1384 Bstr name; 1385 hostNetworkInterfaces[i].COMGETTER(Name) (name.asOutParam()); 1386 if (name == aName) 1387 { 1388 return setError (E_INVALIDARG, 1389 tr ("Host network interface '%ls' already exists"), aName); 1390 } 1391 } 1386 1392 } 1387 1393 … … 1439 1445 /* first check whether an interface with the given name already exists */ 1440 1446 { 1441 ComPtr <IHostNetworkInterfaceCollection> coll;1442 rc = COMGETTER(NetworkInterfaces) (coll.asOutParam());1447 com::SafeIfaceArray <IHostNetworkInterface> hostNetworkInterfaces; 1448 rc = host->COMGETTER(NetworkInterfaces) (ComSafeArrayAsOutParam (hostNetworkInterfaces))); 1443 1449 CheckComRCReturnRC (rc); 1444 1450 ComPtr <IHostNetworkInterface> iface; 1445 if (FAILED (coll->FindById (aId, iface.asOutParam()))) 1451 for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i) 1452 { 1453 Guid guid; 1454 hostNetworkInterfaces[i].COMGETTER(Id) (guid.asOutParam()); 1455 if (guid == aId) 1456 { 1457 iface = hostNetworkInterfaces[i]; 1458 break; 1459 } 1460 } 1461 if (iface.IsNull()) 1446 1462 return setError (VBOX_E_OBJECT_NOT_FOUND, 1447 1463 tr ("Host network interface with UUID {%RTuuid} does not exist"), -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r15546 r15570 5968 5968 </interface> 5969 5969 5970 <enumerator5971 name="IHostNetworkInterfaceEnumerator" type="IHostNetworkInterface"5972 uuid="7B52FEF7-56E8-4aec-92F5-15E6D11EC630"5973 />5974 5975 <collection5976 name="IHostNetworkInterfaceCollection" type="IHostNetworkInterface"5977 enumerator="IHostNetworkInterfaceEnumerator"5978 uuid="BF1D41F2-B97B-4314-A0FB-D4823AF42FB5"5979 readonly="yes"5980 >5981 <method name="findByName">5982 <desc>5983 Searches this collection for a host network interface with the given name.5984 <note>5985 The method returns an error if the given name does not5986 correspond to any host network interface in the collection.5987 </note>5988 </desc>5989 <param name="name" type="wstring" dir="in">5990 <desc>Name of the host network interface to search for.</desc>5991 </param>5992 <param name="networkInterface" type="IHostNetworkInterface" dir="return">5993 <desc>Found host network interface object.</desc>5994 </param>5995 </method>5996 <method name="findById">5997 <desc>5998 Searches this collection for a host network interface with the given GUID.5999 <note>6000 The method returns an error if the given GUID does not6001 correspond to any host network interface in the collection.6002 </note>6003 </desc>6004 <param name="id" type="uuid" dir="in">6005 <desc>GUID of the host network interface to search for.</desc>6006 </param>6007 <param name="networkInterface" type="IHostNetworkInterface" dir="return">6008 <desc>Found host network interface object.</desc>6009 </param>6010 </method>6011 </collection>6012 6013 5970 <interface 6014 5971 name="IHost" extends="$unknown" 6015 uuid=" 4be2e85f-a54c-4bc7-8bf6-f070f9113940"5972 uuid="f39438d7-abfd-409b-bc80-5f5291d92897" 6016 5973 wsmap="managed" 6017 5974 > … … 6077 6034 </attribute> 6078 6035 6079 <attribute name="networkInterfaces" type="IHostNetworkInterface Collection" readonly="yes">6036 <attribute name="networkInterfaces" type="IHostNetworkInterface" safearray="yes" readonly="yes"> 6080 6037 <desc>List of host network interfaces currently defined on the host.</desc> 6081 6038 </attribute> -
trunk/src/VBox/Main/include/HostImpl.h
r15051 r15570 85 85 STDMETHOD(COMGETTER(USBDevices))(IHostUSBDeviceCollection **aUSBDevices); 86 86 STDMETHOD(COMGETTER(USBDeviceFilters))(IHostUSBDeviceFilterCollection ** aUSBDeviceFilters); 87 STDMETHOD(COMGETTER(NetworkInterfaces))( IHostNetworkInterfaceCollection **networkInterfaces);87 STDMETHOD(COMGETTER(NetworkInterfaces))(ComSafeArrayOut (IHostNetworkInterface *, aNetworkInterfaces)); 88 88 STDMETHOD(COMGETTER(ProcessorCount))(ULONG *count); 89 89 STDMETHOD(COMGETTER(ProcessorOnlineCount))(ULONG *count); -
trunk/src/VBox/Main/include/HostNetworkInterfaceImpl.h
r15442 r15570 99 99 }; 100 100 101 COM_DECL_READONLY_ENUM_AND_COLLECTION_BEGIN (HostNetworkInterface)102 103 STDMETHOD(FindByName) (IN_BSTR name, IHostNetworkInterface **networkInterface)104 {105 if (!name)106 return E_INVALIDARG;107 if (!networkInterface)108 return E_POINTER;109 110 *networkInterface = NULL;111 Vector::value_type found;112 Vector::iterator it = vec.begin();113 while (it != vec.end() && !found)114 {115 Bstr n;116 (*it)->COMGETTER(Name) (n.asOutParam());117 if (n == name)118 found = *it;119 ++ it;120 }121 122 if (!found)123 return setError (E_INVALIDARG, HostNetworkInterfaceCollection::tr (124 "The host network interface with the given name could not be found"));125 126 return found.queryInterfaceTo (networkInterface);127 }128 129 STDMETHOD(FindById) (IN_GUID id, IHostNetworkInterface **networkInterface)130 {131 if (Guid(id).isEmpty())132 return E_INVALIDARG;133 if (!networkInterface)134 return E_POINTER;135 136 *networkInterface = NULL;137 Vector::value_type found;138 Vector::iterator it = vec.begin();139 while (it != vec.end() && !found)140 {141 Guid g;142 (*it)->COMGETTER(Id) (g.asOutParam());143 if (g == Guid(id))144 found = *it;145 ++ it;146 }147 148 if (!found)149 return setError (E_INVALIDARG, HostNetworkInterfaceCollection::tr (150 "The host network interface with the given GUID could not be found"));151 152 return found.queryInterfaceTo (networkInterface);153 }154 155 156 COM_DECL_READONLY_ENUM_AND_COLLECTION_END (HostNetworkInterface)157 158 159 101 #endif // ____H_H_HOSTNETWORKINTERFACEIMPL 160 102 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ -
trunk/src/VBox/Main/xpcom/server.cpp
r14831 r15570 235 235 COM_IMPL_READONLY_ENUM_AND_COLLECTION(HostDVDDrive) 236 236 COM_IMPL_READONLY_ENUM_AND_COLLECTION(HostFloppyDrive) 237 COM_IMPL_READONLY_ENUM_AND_COLLECTION(HostNetworkInterface)238 237 COM_IMPL_READONLY_ENUM_AND_COLLECTION(SharedFolder) 239 238 #ifdef VBOX_WITH_USB
Note:
See TracChangeset
for help on using the changeset viewer.