def cb_networkmanager_client_init_done(self, client: NM.Client, res: Gio.AsyncResult): if not client: logger.error('Failed to initialize NetworkManager client') return client.new_finish(res) self.nm_client = client logger.debug('NM client: {}', client)
def on_connection_deactivate(client: NM.Client, result: Gio.AsyncResult) -> None: try: client.deactivate_connection_finish(result) logging.debug(f"Device {self.bdaddr} deactivated sucessfully") self.reply_handler() self.active_connection = None except GLib.Error as e: self.error_handler(e)
def cb_networkmanager_client_init_done(self, client: NM.Client, res: Gio.AsyncResult): if not client: logger.error('Failed to initialize NetworkManager client') return client.new_finish(res) self.nm_client = client logger.debug('NM client: {}', client) connections = client.get_connections() wifis = tuple(c for c in connections if c.get_visible() and c.is_type(NM.SETTING_WIRELESS_SETTING_NAME)) logger.debug('WiFi connections: {}', [c.get_id() for c in wifis])
def add_connection(client: NM.Client, connection: NM.Connection, main_loop: GLib.MainLoop): def add_callback(client, result, data): try: new_con = client.add_connection_finish(result) set_eduvpn_uuid(uuid=new_con.get_uuid()) except Exception as e: logger.error("ERROR: failed to add connection: %s\n" % e) main_loop.quit() client.add_connection_async(connection=connection, save_to_disk=True, cancellable=None, callback=add_callback, user_data=None)
def wifi_connect_done(client: NM.Client, res: Gio.AsyncResult, button: Gtk.Button): created = client.add_connection_finish(res) logger.debug('NetworkManager created connection: {}', created) if created: button.set_label(_('Saved')) button.set_sensitive(False)
def on_connection_activate(client: NM.Client, result: Gio.AsyncResult) -> None: try: self.active_connection = client.activate_connection_finish( result) except GLib.Error as e: self.error_handler(e)
def _on_connection_added(self, client: NM.Client, result: Gio.AsyncResult, conn_uuid: str) -> None: try: self.connection = client.add_connection_finish(result) except GLib.Error as e: self.error_handler(e) self.store_uuid(conn_uuid)
def is_connected_same_wifi(info: WifiInfoMessage, client: NM.Client) -> bool: try: conn = next(c for c in client.get_active_connections() if c.get_connection_type() == NM.SETTING_WIRELESS_SETTING_NAME) except StopIteration: return False # We don't need to compare password, because if we are connected to a wifi network # of the same SSID, the connected's password is more correct. return conn.get_id() == info.ssid