ifconfig & Network preferences: Actually trigger scans using BNetworkDevice.
Fixes #12034, and a variety of other strange "no wireless networks appear" bugs that have plagued Haiku for years. Change-Id: I734cb8084e8a626b8e03511519609bf80c1559eb Reviewed-on: https://review.haiku-os.org/552 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
4e5aaaa700
commit
45bc01d2f7
@@ -281,6 +281,7 @@ configure_wireless(const char* name, char* const* args, int32 argCount)
|
|||||||
{
|
{
|
||||||
enum {
|
enum {
|
||||||
NONE,
|
NONE,
|
||||||
|
SCAN,
|
||||||
LIST,
|
LIST,
|
||||||
JOIN,
|
JOIN,
|
||||||
LEAVE,
|
LEAVE,
|
||||||
@@ -290,7 +291,9 @@ configure_wireless(const char* name, char* const* args, int32 argCount)
|
|||||||
int controlOption = -1;
|
int controlOption = -1;
|
||||||
int controlValue = -1;
|
int controlValue = -1;
|
||||||
|
|
||||||
if (!strcmp(args[0], "list") || !strcmp(args[0], "scan"))
|
if (!strcmp(args[0], "scan"))
|
||||||
|
mode = SCAN;
|
||||||
|
else if (!strcmp(args[0], "list"))
|
||||||
mode = LIST;
|
mode = LIST;
|
||||||
else if (!strcmp(args[0], "join"))
|
else if (!strcmp(args[0], "join"))
|
||||||
mode = JOIN;
|
mode = JOIN;
|
||||||
@@ -324,6 +327,16 @@ configure_wireless(const char* name, char* const* args, int32 argCount)
|
|||||||
argCount--;
|
argCount--;
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
|
case SCAN:
|
||||||
|
{
|
||||||
|
status_t status = device.Scan(true, true);
|
||||||
|
if (status != B_OK) {
|
||||||
|
fprintf(stderr, "%s: Scan on \"%s\" failed: %s\n", kProgramName,
|
||||||
|
name, strerror(status));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
// fall through
|
||||||
|
}
|
||||||
case LIST:
|
case LIST:
|
||||||
{
|
{
|
||||||
// list wireless network(s)
|
// list wireless network(s)
|
||||||
|
|||||||
@@ -262,6 +262,23 @@ InterfaceView::_Update(bool updateWirelessNetworks)
|
|||||||
|
|
||||||
wireless_network network;
|
wireless_network network;
|
||||||
int32 count = 0;
|
int32 count = 0;
|
||||||
|
cookie = 0;
|
||||||
|
if ((fPulseCount % 15) == 0
|
||||||
|
&& device.GetNextNetwork(cookie, network) != B_OK) {
|
||||||
|
// We don't seem to know of any networks, and it's been long
|
||||||
|
// enough since the last scan, so trigger one to try and
|
||||||
|
// find some networks.
|
||||||
|
device.Scan(false, false);
|
||||||
|
|
||||||
|
// We don't want to block for the full length of the scan, but
|
||||||
|
// 50ms is often more than enough to find at least one network,
|
||||||
|
// and the increase in perceived QoS to the user of not seeing
|
||||||
|
// "no wireless networks" if we can avoid it is great enough
|
||||||
|
// to merit such a wait. It's only just over ~4 vertical
|
||||||
|
// retraces, anyway.
|
||||||
|
snooze(50 * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
cookie = 0;
|
cookie = 0;
|
||||||
while (device.GetNextNetwork(cookie, network) == B_OK) {
|
while (device.GetNextNetwork(cookie, network) == B_OK) {
|
||||||
BMessage* message = new BMessage(kMsgJoinNetwork);
|
BMessage* message = new BMessage(kMsgJoinNetwork);
|
||||||
|
|||||||
Reference in New Issue
Block a user