1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-20 04:48:00 +01:00

Merge encryption template changes for curses.

This commit is contained in:
Dan O'Reilly
2009-03-08 18:38:16 -04:00
3 changed files with 63 additions and 47 deletions

View File

@@ -270,7 +270,7 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
def __init__(self,networkID): def __init__(self,networkID):
global wireless, daemon global wireless, daemon
AdvancedSettingsDialog.__init__(self) AdvancedSettingsDialog.__init__(self)
self.networkID = networkID self.networkid = networkID
global_settings_t = language['global_settings'] global_settings_t = language['global_settings']
encryption_t = language['use_encryption'] encryption_t = language['use_encryption']
autoconnect_t = language['automatic_connect'] autoconnect_t = language['automatic_connect']
@@ -301,7 +301,7 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
def set_values(self): def set_values(self):
""" Set the various network settings to the right values. """ """ Set the various network settings to the right values. """
networkID = self.networkID networkID = self.networkid
self.ip_edit.set_edit_text(self.format_entry(networkID,"ip")) self.ip_edit.set_edit_text(self.format_entry(networkID,"ip"))
self.netmask_edit.set_edit_text(self.format_entry(networkID,"netmask")) self.netmask_edit.set_edit_text(self.format_entry(networkID,"netmask"))
self.gateway_edit.set_edit_text(self.format_entry(networkID,"gateway")) self.gateway_edit.set_edit_text(self.format_entry(networkID,"gateway"))
@@ -327,17 +327,13 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
# Throw the encryption stuff into a list # Throw the encryption stuff into a list
list = [] list = []
activeID = -1 # Set the menu to this item when we are done
for x, enc_type in enumerate(self.encrypt_types): for x, enc_type in enumerate(self.encrypt_types):
list.append(enc_type[0]) list.append(enc_type['name'])
if enc_type['type'] == wireless.GetWirelessProperty(networkID, "enctype"):
activeID = x
self.encryption_combo.set_list(list) self.encryption_combo.set_list(list)
self.change_encrypt_method()
activeID = -1 # Set the menu to this item when we are done
user_enctype = wireless.GetWirelessProperty(networkID, "enctype")
for x, enc_type in enumerate(self.encrypt_types):
if enc_type[1] == user_enctype:
activeID = x
self.encryption_combo.set_focus(activeID) self.encryption_combo.set_focus(activeID)
if activeID != -1: if activeID != -1:
self.encryption_chkbox.set_state(True,do_callback=False) self.encryption_chkbox.set_state(True,do_callback=False)
@@ -346,9 +342,12 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
else: else:
self.encryption_combo.set_focus(0) self.encryption_combo.set_focus(0)
self.change_encrypt_method()
def set_net_prop(self, option, value): def set_net_prop(self, option, value):
""" Sets the given option to the given value for this network. """ """ Sets the given option to the given value for this network. """
wireless.SetWirelessProperty(self.networkID, option, value) wireless.SetWirelessProperty(self.networkid, option, value)
def format_entry(self, networkid, label): def format_entry(self, networkid, label):
""" Helper method for fetching/formatting wireless properties. """ """ Helper method for fetching/formatting wireless properties. """
@@ -359,25 +358,32 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
# Check encryption info # Check encryption info
if self.encryption_chkbox.get_state(): if self.encryption_chkbox.get_state():
#print "setting encryption info..." #print "setting encryption info..."
encryption_info = self.encryption_info encrypt_info = self.encryption_info
encrypt_methods = misc.LoadEncryptionMethods() encrypt_methods = self.encrypt_types
self.set_net_prop("enctype", self.set_net_prop("enctype",
encrypt_methods[self.encryption_combo.get_focus()[1] ][1]) encrypt_methods[self.encryption_combo.get_focus()[1] ]['type'])
for x in encryption_info: # Make sure all required fields are filled in.
if encryption_info[x].get_edit_text() == "": for entry_info in encrypt_info.itervalues():
error(self.ui, self.overlay,language['encrypt_info_missing']) if entry_info[0].get_edit_text() == "" \
and entry_info[1] == 'required':
error(self.ui, self.overlay,"%s (%s)" \
% (language['encrypt_info_missing'],
entry_info[0].get_captionabel() )
)
return False return False
self.set_net_prop(x, noneToString(encryption_info[x].
for entry_key, entry_info in encrypt_info.iteritems():
self.set_net_prop(entry_key, noneToString(entry_info[0].
get_edit_text())) get_edit_text()))
elif not self.encryption_chkbox.get_state() and \ elif not self.encryption_chkbox.get_state() and \
wireless.GetWirelessProperty(self.networkID, "encryption"): wireless.GetWirelessProperty(self.networkid, "encryption"):
# Encrypt checkbox is off, but the network needs it.
error(self.ui, self.overlay, language['enable_encryption']) error(self.ui, self.overlay, language['enable_encryption'])
return False return False
else: else:
#print 'encryption is ' + str(wireless.GetWirelessProperty(self.networkID,
# "encryption"))
#print "no encryption specified..."
self.set_net_prop("enctype", "None") self.set_net_prop("enctype", "None")
for entry in encrypt_info.iterkeys():
self.set_net_prop(entry[0].entry, "")
AdvancedSettingsDialog.save_settings(self) AdvancedSettingsDialog.save_settings(self)
# Save the autoconnect setting. This is not where it originally was # Save the autoconnect setting. This is not where it originally was
@@ -388,9 +394,9 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
self.set_net_prop('use_settings_globally', True) self.set_net_prop('use_settings_globally', True)
else: else:
self.set_net_prop('use_settings_globally', False) self.set_net_prop('use_settings_globally', False)
wireless.RemoveGlobalEssidEntry(self.networkID) wireless.RemoveGlobalEssidEntry(self.networkid)
wireless.SaveWirelessNetworkProfile(self.networkID) wireless.SaveWirelessNetworkProfile(self.networkid)
return True return True
# More or less ripped from netentry.py # More or less ripped from netentry.py
@@ -405,26 +411,29 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
# If nothing is selected, select the first entry. # If nothing is selected, select the first entry.
if ID == -1: if ID == -1:
self.encryption_combo.set_active(0) self.encryption_combo.set_focus(0)
ID = 0 ID = 0
opts = methods[ID][2]
theList = [] theList = []
for x in opts: for type_ in ['required', 'optional']:
edit = None fields = methods[ID][type_]
if language.has_key(opts[x][0]): for field in fields:
edit = MaskingEdit(('editcp',language[opts[x][0].lower().replace(' ','_')]+': '),mask_mode='no_focus') if language.has_key(field[1]):
else: edit = MaskingEdit(('editcp',language[field[1].lower().replace(' ','_')]+': '))
edit = MaskingEdit(('editcp',opts[x][0].replace('_',' ')+': '),mask_mode='no_focus') else:
theList.append(edit) edit = MaskingEdit(('editcp',field[1].replace('_',' ')+': '))
# Add the data to any array, so that the information edit.set_mask_mode('no_focus')
# can be easily accessed by giving the name of the wanted theList.append(edit)
# data. # Add the data to any array, so that the information
self.encryption_info[opts[x][1]] = edit # can be easily accessed by giving the name of the wanted
# data.
self.encryption_info[field[0]] = [edit, type_]
edit.set_edit_text(noneToBlankString( edit.set_edit_text(noneToBlankString(
wireless.GetWirelessProperty(self.networkID, opts[x][1]))) wireless.GetWirelessProperty(self.networkid, field[0])))
#FIXME: This causes the entire pile to light up upon use.
# Make this into a listbox?
self.pile_encrypt = DynWrap(urwid.Pile(theList),attrs=('editbx','editnfc')) self.pile_encrypt = DynWrap(urwid.Pile(theList),attrs=('editbx','editnfc'))
self._w.body.body.insert(self._w.body.body.__len__(),self.pile_encrypt) self._w.body.body.insert(self._w.body.body.__len__(),self.pile_encrypt)
#self._w.body.body.append(self.pile_encrypt) #self._w.body.body.append(self.pile_encrypt)

View File

@@ -797,13 +797,18 @@ class appGUI():
about_dialog(self.frame) about_dialog(self.frame)
if "C" in keys: if "C" in keys:
focus = self.thePile.get_focus() focus = self.thePile.get_focus()
if focus == self.wiredCB: try:
WiredSettingsDialog(self.wiredCB.get_body(). if focus == self.wiredCB:
get_selected_profile()).run(ui,self.size,self.frame) WiredSettingsDialog(self.wiredCB.get_body().
else: get_selected_profile()).run(ui,self.size,self.frame)
# wireless list only other option else:
wid,pos = self.thePile.get_focus().get_focus() # wireless list only other option
WirelessSettingsDialog(pos).run(ui,self.size,self.frame) wid,pos = self.thePile.get_focus().get_focus()
WirelessSettingsDialog(pos).run(ui,self.size,self.frame)
except:
# wtf do I need this?
loop.quit()
raise
#self.netentry = NetEntryBase(dbusmanager.get_dbus_ifaces()) #self.netentry = NetEntryBase(dbusmanager.get_dbus_ifaces())
#self.netentry.run(ui,self.size,self.frame) #self.netentry.run(ui,self.size,self.frame)
if "I" in keys: if "I" in keys:

View File

@@ -1,7 +1,9 @@
name = EAP-TLS name = EAP-TLS
author = Dan O'Reilly author = Dan O'Reilly
version = 1 version = 1
require identity *Identity ca_cert *Path_to_CA_Cert client_cert *Path_to_Client_Cert private_key *Private_Key private_key_passwd *Private_Key_Password require identity *Identity private_key *Private_Key private_key_passwd *Private_Key_Password
optional ca_cert *Path_to_CA_Cert client_cert *Path_to_Client_Cert
----- -----
ctrl_interface=/var/run/wpa_supplicant ctrl_interface=/var/run/wpa_supplicant
network={ network={