Migrate in-tree consumers of BNetworkDevice::GetNextNetwork to GetNetworks.
GetNextNetwork is very inefficient as it fetches all networks but only returns one of them. GetNetworks was introduced to compensate for that, but only the most regular consumers were initially migrated. Now, the remaining consumers of the old API are converted to the new one.
This commit is contained in:
@@ -8,5 +8,5 @@ UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_wlan ] : true ;
|
||||
BinCommand ifconfig :
|
||||
ifconfig.cpp
|
||||
MediaTypes.cpp
|
||||
: be network bnetapi
|
||||
: be network bnetapi [ TargetLibstdc++ ]
|
||||
;
|
||||
|
||||
@@ -367,10 +367,16 @@ configure_wireless(const char* name, char* const* args, int32 argCount)
|
||||
}
|
||||
} else {
|
||||
// list them all
|
||||
wireless_network network;
|
||||
uint32 cookie = 0;
|
||||
while (device.GetNextNetwork(cookie, network) == B_OK)
|
||||
show_wireless_network(network, verbose);
|
||||
uint32 networksCount = 0;
|
||||
wireless_network* networks = NULL;
|
||||
status_t status = device.GetNetworks(networks, networksCount);
|
||||
if (status != B_OK) {
|
||||
fprintf(stderr, "%s: Getting networks failed: %s\n",
|
||||
kProgramName, strerror(status));
|
||||
}
|
||||
for (uint32 i = 0; i < networksCount; i++)
|
||||
show_wireless_network(networks[i], verbose);
|
||||
delete[] networks;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -81,13 +81,14 @@ BGeolocation::LocateSelf(float& latitude, float& longitude)
|
||||
int32 count = 0;
|
||||
|
||||
while (roster.GetNextInterface(&interfaceCookie, interface) == B_OK) {
|
||||
uint32 networkCookie = 0;
|
||||
wireless_network network;
|
||||
|
||||
BNetworkDevice device(interface.Name());
|
||||
// TODO is that the correct way to enumerate devices?
|
||||
|
||||
while (device.GetNextNetwork(networkCookie, network) == B_OK) {
|
||||
uint32 networksCount = 0;
|
||||
wireless_network* networks = NULL;
|
||||
device.GetNetworks(networks, networksCount);
|
||||
for (uint32 i = 0; i < networksCount; i++) {
|
||||
const wireless_network& network = networks[i];
|
||||
if (count != 0)
|
||||
query += ',';
|
||||
|
||||
@@ -101,7 +102,7 @@ BGeolocation::LocateSelf(float& latitude, float& longitude)
|
||||
query << (int)network.noise_level;
|
||||
query += " }";
|
||||
}
|
||||
|
||||
delete[] networks;
|
||||
}
|
||||
|
||||
query += "\n\t]\n}\n";
|
||||
|
||||
@@ -8,7 +8,7 @@ SimpleTest NetAddressTest : NetAddressTest.cpp
|
||||
SimpleTest NetEndpointTest : NetEndpointTest.cpp
|
||||
: $(TARGET_NETWORK_LIBS) $(HAIKU_NETAPI_LIB) be [ TargetLibsupc++ ] ;
|
||||
|
||||
SimpleTest wlan_test : wlan_test.cpp : $(TARGET_NETWORK_LIBS) bnetapi be ;
|
||||
SimpleTest wlan_test : wlan_test.cpp : $(TARGET_NETWORK_LIBS) bnetapi be [ TargetLibstdc++ ] ;
|
||||
|
||||
SubInclude HAIKU_TOP src tests kits net cookie ;
|
||||
HaikuSubInclude libnetapi ;
|
||||
|
||||
@@ -108,10 +108,12 @@ main(int argc, char** argv)
|
||||
show(network);
|
||||
} else {
|
||||
// list all
|
||||
wireless_network network;
|
||||
uint32 cookie = 0;
|
||||
while (device.GetNextNetwork(cookie, network) == B_OK)
|
||||
show(network);
|
||||
uint32 networksCount = 0;
|
||||
wireless_network* networks = NULL;
|
||||
device.GetNetworks(networks, networksCount);
|
||||
for (uint32 i = 0; i < networksCount; i++)
|
||||
show(networks[i]);
|
||||
delete[] networks;
|
||||
}
|
||||
} else
|
||||
usage();
|
||||
|
||||
Reference in New Issue
Block a user