More fixes, nearly there but not quite yet.

This commit is contained in:
Marco Pesenti Gritti 2006-11-13 00:10:49 +01:00
parent 4cd09ed5f8
commit a3d9a93d82
2 changed files with 21 additions and 18 deletions

View File

@ -775,7 +775,7 @@ class NMClientApp:
self._popdown() self._popdown()
def get_key_for_network(self, wep_auth_alg=IW_AUTH_ALG_OPEN_SYSTEM): def get_key_for_network(self, async_cb, async_err_cb, wep_auth_alg=IW_AUTH_ALG_OPEN_SYSTEM):
# Throw up a dialog asking for the key here, and set # Throw up a dialog asking for the key here, and set
# the authentication algorithm to the given one, if any # the authentication algorithm to the given one, if any
# #
@ -788,13 +788,15 @@ class NMClientApp:
dialog = WEPKeyDialog() dialog = WEPKeyDialog()
response = dialog.run() response = dialog.run()
key = dialog.get_key()
dialog.destroy() dialog.destroy()
if response == gtk.RESPONSE_OK: if response == gtk.RESPONSE_OK:
key = dialog.get_key() self.nminfo.get_key_for_network_cb(
self.nminfo.get_key_for_network_cb(key, wep_auth_alg, canceled=False) key, wep_auth_alg, async_cb, async_err_cb, canceled=False)
else: else:
self.nminfo.get_key_for_network_cb(None, None, canceled=True) self.nminfo.get_key_for_network_cb(
None, None, async_cb, async_err_cb, canceled=True)
def cancel_get_key_for_network(self): def cancel_get_key_for_network(self):
# Close the wireless key dialog and just have it return # Close the wireless key dialog and just have it return

View File

@ -120,7 +120,7 @@ class Security(object):
return security return security
new_from_config = staticmethod(new_from_config) new_from_config = staticmethod(new_from_config)
def new_from_args(cfg, we_cipher, args): def new_from_args(we_cipher, key, auth_alg):
security = None security = None
try: try:
if we_cipher == IW_AUTH_CIPHER_NONE: if we_cipher == IW_AUTH_CIPHER_NONE:
@ -131,7 +131,7 @@ class Security(object):
# FIXME: find a way to make WPA config option matrix not # FIXME: find a way to make WPA config option matrix not
# make you want to throw up # make you want to throw up
raise ValueError("Unsupported security combo") raise ValueError("Unsupported security combo")
security.read_from_args(args) security.read_from_args(key, auth_alg)
except (NoOptionError, ValueError), e: except (NoOptionError, ValueError), e:
del security del security
return None return None
@ -146,15 +146,15 @@ class Security(object):
class WEPSecurity(Security): class WEPSecurity(Security):
def read_from_args(self, *args): def read_from_args(self, key, auth_alg):
if len(args) != 2: # if len(args) != 2:
raise ValueError("not enough arguments") # raise ValueError("not enough arguments")
if not isinstance(args[0], str): # if not isinstance(args[0], str):
raise ValueError("wrong argument type for key") # raise ValueError("wrong argument type for key")
if not isinstance(args[1], int): # if not isinstance(args[1], int):
raise ValueError("wrong argument type for auth_alg") # raise ValueError("wrong argument type for auth_alg")
self._key = args[0] self._key = key
self._auth_alg = args[1] self._auth_alg = auth_alg
def read_from_config(self, cfg, name): def read_from_config(self, cfg, name):
# Key should be a hex encoded string # Key should be a hex encoded string
@ -392,9 +392,9 @@ class NMInfo(object):
if not net: if not net:
async_err_cb(NotFoundError("Network was unknown.")) async_err_cb(NotFoundError("Network was unknown."))
self._nmclient.get_key_for_network(net) self._nmclient.get_key_for_network(async_cb, async_err_cb, net)
def get_key_for_network_cb(self, key, auth_alg, canceled=False): def get_key_for_network_cb(self, key, auth_alg, async_cb, async_err_cb, canceled=False):
""" """
Called by the NMClient when the Wireless Network Key dialog Called by the NMClient when the Wireless Network Key dialog
is closed. is closed.
@ -422,7 +422,8 @@ class NMInfo(object):
# Stuff the returned key and auth algorithm into a security object # Stuff the returned key and auth algorithm into a security object
# and return it to NetworkManager # and return it to NetworkManager
sec = Security.new_from_args(we_cipher, key, auth_alg) sec = Security.new_from_args(we_cipher, key, auth_alg)
async_cb(tuple(sec.get_properties())) props = sec.get_properties()
async_cb(tuple(props))
def cancel_get_key_for_network(self): def cancel_get_key_for_network(self):
# Tell the NMClient to close the key request dialog # Tell the NMClient to close the key request dialog