blob: 3c51018973343ef056d9210a7895750826514f36 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
public class AstalNetwork.AccessPoint : Object {
private Wifi wifi;
private NM.AccessPoint ap;
public uint bandwidth { get { return ap.bandwidth; } }
public string bssid { owned get { return ap.bssid; } }
public uint frequency { get { return ap.frequency; } }
public int last_seen { get { return ap.last_seen; } }
public uint max_bitrate { get { return ap.max_bitrate; } }
public uint8 strength { get { return ap.strength; } }
public string icon_name { get; private set; }
public NM.80211Mode mode { get { return ap.mode; } }
public NM.80211ApFlags flags { get { return ap.flags; } }
public NM.80211ApSecurityFlags rsn_flags { get { return ap.rsn_flags; } }
public NM.80211ApSecurityFlags wpa_flags { get { return ap.wpa_flags; } }
public string? ssid {
owned get {
if (ap.ssid == null)
return null;
return (string)NM.Utils.ssid_to_utf8(ap.ssid.get_data());
}
}
internal AccessPoint(Wifi wifi, NM.AccessPoint ap) {
this.wifi = wifi;
this.ap = ap;
ap.notify.connect((pspec) => {
if (get_class().find_property(pspec.name) != null)
notify_property(pspec.name);
if (pspec.name == "strength")
icon_name = _icon();
});
icon_name = _icon();
}
private string _icon() {
if (strength >= 80) return Wifi.ICON_EXCELLENT;
if (strength >= 60) return Wifi.ICON_GOOD;
if (strength >= 40) return Wifi.ICON_OK;
if (strength >= 20) return Wifi.ICON_WEAK;
return Wifi.ICON_NONE;
}
// TODO: connect to ap
// public signal void auth();
// public void try_connect(string? password) { }
}
|