diff options
author | Dan Williams <dcbw@redhat.com> | 2014-11-14 16:42:48 -0600 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2014-11-14 16:42:48 -0600 |
commit | dbb8b0b116615b8bd4d925f973174433b52a22c8 (patch) | |
tree | f26c8e51a235fd57903095f4d3b5f4ba9a24f888 | |
parent | f527b2c738fc17e000990830caf78f04f4e7ccf2 (diff) | |
download | NetworkManager-danw/examples-bgo740145.tar.gz |
libnm-core: fix introspection annotations for nm_utils_ssid_to_utf8()danw/examples-bgo740145
Otherwise impossible to use in Python.
-rwxr-xr-x | examples/python/gi/show-wifi-networks.py | 12 | ||||
-rw-r--r-- | libnm-core/nm-utils.c | 2 |
2 files changed, 11 insertions, 3 deletions
diff --git a/examples/python/gi/show-wifi-networks.py b/examples/python/gi/show-wifi-networks.py index edc6f9ab43..7317a76e5e 100755 --- a/examples/python/gi/show-wifi-networks.py +++ b/examples/python/gi/show-wifi-networks.py @@ -35,11 +35,17 @@ from gi.repository import NM def clamp(value, minvalue, maxvalue): return max(minvalue, min(value, maxvalue)) +def ssid_to_utf8(ap): + ssid = ap.get_ssid() + if not ssid: + return "" + return NM.utils_ssid_to_utf8(ap.get_ssid().get_data()) + def print_device_info(device): active_ap = dev.get_active_access_point() ssid = None if active_ap is not None: - ssid = active_ap.get_ssid() + ssid = ssid_to_utf8(active_ap) info = "Device: %s | Driver: %s | Active AP: %s" % (dev.get_iface(), dev.get_driver(), ssid) print info print '=' * len(info) @@ -47,7 +53,7 @@ def print_device_info(device): def print_ap_info(ap): strength = ap.get_strength() frequency = ap.get_frequency() - print "SSID: %s" % (ap.get_ssid()) + print "SSID: %s" % (ssid_to_utf8(ap)) print "BSSID: %s" % (ap.get_bssid()) print "Frequency: %s" % (frequency) print "Channel: %s" % (NM.utils_wifi_freq_to_channel(frequency)) @@ -63,6 +69,8 @@ if __name__ == "__main__": nmc = NM.Client.new(None) devs = nmc.get_devices() + NM.utils_ssid_to_utf8("asd") + for dev in devs: if dev.get_device_type() == NM.DeviceType.WIFI: print_device_info(dev) diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index dce475569e..cc01be096c 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -275,7 +275,7 @@ nm_utils_deinit (void) /** * nm_utils_ssid_to_utf8: - * @ssid: pointer to a buffer containing the SSID data + * @ssid: (array length=len): pointer to a buffer containing the SSID data * @len: length of the SSID data in @ssid * * Wi-Fi SSIDs are byte arrays, they are _not_ strings. Thus, an SSID may |