Network: Sort network menu items w/o deleting
* Delete dropped out networks. * Add in newly discovered networks. * Add static (aka class) compare method to WirelessNetworkMenuItem that is used to sort items by signal strength descending. Add == operator to wireless_network struct to determine if existing items have a known network attached. Remove the non-network items from the menu, save them, sort network menu items, then add non-network items back into the menu. Update NetworkStatus preflet to use same compare method as Network preflet. signal_strength_compare function had a bool return value instead of int which worked to sort items the first time, but does not work on successive compares. By not deleting and recreating the menu items each Pulse(), the Network preflet no longer crashes on update. The menu flashes on update still but doesn't crash. Fixes #12024 Change-Id: Ie5b22cea4e66350b9c5df8e3b8de266ede50ad6d Reviewed-on: https://review.haiku-os.org/c/haiku/+/4243 Reviewed-by: John Scipione <[email protected]> Reviewed-by: waddlesplash <[email protected]> Reviewed-by: Axel Dörfler <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
0a53cbb3b9
commit
02ad92185d
@@ -7,6 +7,7 @@
|
||||
|
||||
|
||||
#include <net/if.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <NetworkAddress.h>
|
||||
|
||||
@@ -24,6 +25,18 @@ struct wireless_network {
|
||||
uint32 cipher;
|
||||
uint32 group_cipher;
|
||||
uint32 key_mode;
|
||||
|
||||
bool operator==(const wireless_network& other) {
|
||||
return strncmp(name, other.name, 32) == 0
|
||||
// ignore address difference
|
||||
&& noise_level == other.noise_level
|
||||
&& signal_strength == other.signal_strength
|
||||
&& flags == other.flags
|
||||
&& authentication_mode == other.authentication_mode
|
||||
&& cipher == other.cipher
|
||||
&& group_cipher == other.group_cipher
|
||||
&& key_mode == other.key_mode;
|
||||
}
|
||||
};
|
||||
|
||||
// flags
|
||||
|
||||
Reference in New Issue
Block a user