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 :
|
BinCommand ifconfig :
|
||||||
ifconfig.cpp
|
ifconfig.cpp
|
||||||
MediaTypes.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 {
|
} else {
|
||||||
// list them all
|
// list them all
|
||||||
wireless_network network;
|
uint32 networksCount = 0;
|
||||||
uint32 cookie = 0;
|
wireless_network* networks = NULL;
|
||||||
while (device.GetNextNetwork(cookie, network) == B_OK)
|
status_t status = device.GetNetworks(networks, networksCount);
|
||||||
show_wireless_network(network, verbose);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,13 +81,14 @@ BGeolocation::LocateSelf(float& latitude, float& longitude)
|
|||||||
int32 count = 0;
|
int32 count = 0;
|
||||||
|
|
||||||
while (roster.GetNextInterface(&interfaceCookie, interface) == B_OK) {
|
while (roster.GetNextInterface(&interfaceCookie, interface) == B_OK) {
|
||||||
uint32 networkCookie = 0;
|
|
||||||
wireless_network network;
|
|
||||||
|
|
||||||
BNetworkDevice device(interface.Name());
|
BNetworkDevice device(interface.Name());
|
||||||
// TODO is that the correct way to enumerate devices?
|
// 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)
|
if (count != 0)
|
||||||
query += ',';
|
query += ',';
|
||||||
|
|
||||||
@@ -101,7 +102,7 @@ BGeolocation::LocateSelf(float& latitude, float& longitude)
|
|||||||
query << (int)network.noise_level;
|
query << (int)network.noise_level;
|
||||||
query += " }";
|
query += " }";
|
||||||
}
|
}
|
||||||
|
delete[] networks;
|
||||||
}
|
}
|
||||||
|
|
||||||
query += "\n\t]\n}\n";
|
query += "\n\t]\n}\n";
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ SimpleTest NetAddressTest : NetAddressTest.cpp
|
|||||||
SimpleTest NetEndpointTest : NetEndpointTest.cpp
|
SimpleTest NetEndpointTest : NetEndpointTest.cpp
|
||||||
: $(TARGET_NETWORK_LIBS) $(HAIKU_NETAPI_LIB) be [ TargetLibsupc++ ] ;
|
: $(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 ;
|
SubInclude HAIKU_TOP src tests kits net cookie ;
|
||||||
HaikuSubInclude libnetapi ;
|
HaikuSubInclude libnetapi ;
|
||||||
|
|||||||
@@ -108,10 +108,12 @@ main(int argc, char** argv)
|
|||||||
show(network);
|
show(network);
|
||||||
} else {
|
} else {
|
||||||
// list all
|
// list all
|
||||||
wireless_network network;
|
uint32 networksCount = 0;
|
||||||
uint32 cookie = 0;
|
wireless_network* networks = NULL;
|
||||||
while (device.GetNextNetwork(cookie, network) == B_OK)
|
device.GetNetworks(networks, networksCount);
|
||||||
show(network);
|
for (uint32 i = 0; i < networksCount; i++)
|
||||||
|
show(networks[i]);
|
||||||
|
delete[] networks;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
usage();
|
usage();
|
||||||
|
|||||||
Reference in New Issue
Block a user