def remove_switcher(self): if self.device_tree\ and self.device_tree in self.content_box.get_children(): self.content_box.remove(self.device_tree) self.device_tree = None try: self.focused_device = self.wireless_devices[0] except: log.error("get no wireless devices but try to index") self.focused_device = None self.wireless_redraw(None)
def on_vpn_connecting(self, name, event, data): if not self.vpn.get_active(): self.vpn.set_active(True) return log.debug("vpn start connect", data) self.vpn_path = data try: self.this_setting = nm_module.cache.getobject(data).get_connection().object_path except Exception, e: log.error(e) self.this_setting = None
def on_vpn_connecting(self, name, event, data): if not self.vpn.get_active(): self.vpn.set_active(True) return log.debug("vpn start connect", data) self.vpn_path = data try: self.this_setting = nm_module.cache.getobject( data).get_connection().object_path except Exception, e: log.error(e) self.this_setting = None
def toggle_on_after(self): if self.no_auto_connect: self.no_auto_connect = False pass else: if not self.vpn_path: self.monitor = self.try_active_vpn() else: self.on_vpn_connecting(None, None, self.vpn_path) vpn_active = nm_module.nmclient.get_vpn_active_connection() if vpn_active: # TODO fix for mutiple connection = vpn_active[0].get_connection() try: index = self.connection.index(connection) self.tree.visible_items[index].set_net_state(2) self.vpn_path = vpn_active[0].object_path return except Exception, e: log.error(e)
def reset(self, security=True): ## Add security container_remove_all(self.table) if self.need_ssid: self.table.attach(self.ssid_label_align, 0, 1, 0, 1) self.table.attach(self.ssid_entry_align, 1, 4, 0, 1) self.table.resize(2, 4) self.table.attach(self.security_label_align, 0, 1, 1, 2) self.table.attach(self.security_combo_align, 1, 4, 1, 2) if not security: self.presave_index = self.security_combo.get_select_index() return keys = [None, "none", "none", "wpa-psk"] self.key_mgmt = self.setting.key_mgmt if self.key_mgmt == "none": key_type = self.setting.wep_key_type self.security_combo.set_select_index(key_type) else: self.security_combo.set_select_index(keys.index(self.key_mgmt)) if not self.security_combo.get_current_item()[1] == None: try: (setting_name, method) = self.connection.guess_secret_info() secret = nm_module.secret_agent.agent_get_secrets( self.connection.object_path, setting_name, method) if secret == None: secret = '' log.debug("get secret", setting_name, method, "secret") except Exception, e: log.error("get secret error", e) secret = "" if self.security_combo.get_current_item()[1] == "wpa-psk": self.table.resize(4, 4) self.table.attach(self.password_label_align, 0, 1, 2, 3) self.table.attach(self.password_entry_align, 1, 4, 2, 3) self.table.attach(self.show_key_check_align, 1, 4, 3, 4) self.password_entry.entry.set_text(secret) if secret: #Dispatcher.set_button("save", True) ########### self.settings_obj.wlan_encry_is_valid = True self.settings_obj.set_button("save", True) self.setting.psk = secret elif self.security_combo.get_current_item()[1] == "none": self.table.resize(6, 4) # Add Key self.table.attach(self.key_label_align, 0, 1, 2, 3) self.table.attach(self.key_entry_align, 1, 4, 2, 3) self.table.attach(self.show_key_check_align, 1, 4, 3, 4) # Add wep index self.table.attach(self.wep_index_label_align, 0, 1, 4, 5) self.table.attach(self.wep_index_spin_align, 1, 4, 4, 5) # Add Auth self.table.attach(self.auth_label_align, 0, 1, 5, 6) self.table.attach(self.auth_combo_align, 1, 4, 5, 6) # Retrieve wep properties try: index = self.setting.wep_tx_keyidx auth = self.setting.auth_alg log.debug(auth, index) self.auth_combo.set_select_index(["shared", "open"].index(auth)) except Exception, e: log.error(e) index = 0 auth = "shared" # must convert long int to int index = int(index) #init_key = True #if isinstance(self.connection, NMRemoteConnection): #init_setting = self.connection.get_setting("802-11-wireless-security") #if init_setting.wep_key_type != self.setting.wep_key_type: #init_key = False #if init_key: self.key_entry.entry.set_text(secret) self.setting.set_wep_key(index, secret) self.wep_index_spin.set_value(index + 1) self.auth_combo.set_select_index(["shared", "open"].index(auth))
def reset(self, security=True): ## Add security container_remove_all(self.table) if self.need_ssid: self.table.attach(self.ssid_label_align, 0, 1, 0, 1) self.table.attach(self.ssid_entry_align, 1, 4, 0, 1) self.table.resize(2, 4) self.table.attach(self.security_label_align, 0, 1, 1, 2) self.table.attach(self.security_combo_align, 1, 4, 1, 2) if not security: self.presave_index = self.security_combo.get_select_index() return keys = [None, "none", "none","wpa-psk"] self.key_mgmt = self.setting.key_mgmt if self.key_mgmt == "none": key_type = self.setting.wep_key_type self.security_combo.set_select_index(key_type) else: self.security_combo.set_select_index(keys.index(self.key_mgmt)) if not self.security_combo.get_current_item()[1] == None: try: (setting_name, method) = self.connection.guess_secret_info() secret = nm_module.secret_agent.agent_get_secrets(self.connection.object_path, setting_name, method) if secret == None: secret = '' log.debug("get secret", setting_name, method, "secret") except Exception, e: log.error("get secret error", e) secret = "" if self.security_combo.get_current_item()[1] == "wpa-psk": self.table.resize(4, 4) self.table.attach(self.password_label_align, 0, 1, 2, 3) self.table.attach(self.password_entry_align, 1, 4, 2, 3) self.table.attach(self.show_key_check_align, 1, 4, 3, 4) self.password_entry.entry.set_text(secret) if secret: #Dispatcher.set_button("save", True) ########### self.settings_obj.wlan_encry_is_valid = True self.settings_obj.set_button("save", True) self.setting.psk = secret elif self.security_combo.get_current_item()[1] == "none": self.table.resize(6, 4) # Add Key self.table.attach(self.key_label_align, 0, 1, 2, 3) self.table.attach(self.key_entry_align, 1, 4, 2, 3) self.table.attach(self.show_key_check_align, 1, 4, 3, 4) # Add wep index self.table.attach(self.wep_index_label_align, 0, 1, 4, 5) self.table.attach(self.wep_index_spin_align, 1, 4, 4, 5) # Add Auth self.table.attach(self.auth_label_align, 0, 1, 5, 6) self.table.attach(self.auth_combo_align, 1, 4, 5, 6) # Retrieve wep properties try: index = self.setting.wep_tx_keyidx auth = self.setting.auth_alg log.debug(auth, index) self.auth_combo.set_select_index(["shared", "open"].index(auth)) except Exception, e: log.error(e) index = 0 auth = "shared" # must convert long int to int index = int(index) #init_key = True #if isinstance(self.connection, NMRemoteConnection): #init_setting = self.connection.get_setting("802-11-wireless-security") #if init_setting.wep_key_type != self.setting.wep_key_type: #init_key = False #if init_key: self.key_entry.entry.set_text(secret) self.setting.set_wep_key(index, secret) self.wep_index_spin.set_value(index + 1) self.auth_combo.set_select_index(["shared", "open"].index(auth))