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

Merged r237 of mainline.

This commit is contained in:
Robby Workman
2009-01-02 20:57:47 -06:00
6 changed files with 86 additions and 88 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -579,7 +579,7 @@ class appGui(object):
"""
if fresh:
# Even if it is None, it can still be passed.
if hidden:
wireless.SetHiddenNetworkESSID(noneToString(hidden))
self.refresh_clicked()
return
@@ -665,91 +665,15 @@ class appGui(object):
# Now save the settings.
if nettype == "wireless":
if not self.save_wireless_settings(networkid, entry, networkentry):
if not networkentry.save_wireless_settings(networkid):
return False
elif nettype == "wired":
if not self.save_wired_settings(entry):
if not networkentry.save_wired_settings():
return False
return True
def _save_gen_settings(self, entry):
""" Save settings common to wired and wireless settings dialogs. """
if entry.chkbox_static_ip.get_active():
entry.set_net_prop("ip", noneToString(entry.txt_ip.get_text()))
entry.set_net_prop("netmask", noneToString(entry.txt_netmask.get_text()))
entry.set_net_prop("gateway", noneToString(entry.txt_gateway.get_text()))
else:
entry.set_net_prop("ip", '')
entry.set_net_prop("netmask", '')
entry.set_net_prop("gateway", '')
if entry.chkbox_static_dns.get_active() and \
not entry.chkbox_global_dns.get_active():
entry.set_net_prop('use_static_dns', True)
entry.set_net_prop('use_global_dns', False)
entry.set_net_prop('dns_domain', noneToString(entry.txt_domain.get_text()))
entry.set_net_prop("search_domain", noneToString(entry.txt_search_dom.get_text()))
entry.set_net_prop("dns1", noneToString(entry.txt_dns_1.get_text()))
entry.set_net_prop("dns2", noneToString(entry.txt_dns_2.get_text()))
entry.set_net_prop("dns3", noneToString(entry.txt_dns_3.get_text()))
elif entry.chkbox_static_dns.get_active() and \
entry.chkbox_global_dns.get_active():
entry.set_net_prop('use_static_dns', True)
entry.set_net_prop('use_global_dns', True)
else:
entry.set_net_prop('use_static_dns', False)
entry.set_net_prop('use_global_dns', False)
entry.set_net_prop('dns_domain', '')
entry.set_net_prop("search_domain", '')
entry.set_net_prop("dns1", '')
entry.set_net_prop("dns2", '')
entry.set_net_prop("dns3", '')
def save_wired_settings(self, entry):
""" Save wired network settings. """
self._save_gen_settings(entry)
wired.SaveWiredNetworkProfile(entry.prof_name)
return True
def save_wireless_settings(self, networkid, entry, netent):
""" Save wireless network settings. """
# Check encryption info
if entry.chkbox_encryption.get_active():
print "setting encryption info..."
encryption_info = entry.encryption_info
encrypt_methods = misc.LoadEncryptionMethods()
entry.set_net_prop("enctype",
encrypt_methods[entry.combo_encryption.get_active()][1])
for x in encryption_info:
if encryption_info[x].get_text() == "":
error(self.window, language['encrypt_info_missing'])
return False
entry.set_net_prop(x, noneToString(encryption_info[x].
get_text()))
elif not entry.chkbox_encryption.get_active() and \
wireless.GetWirelessProperty(networkid, "encryption"):
error(self.window, language['enable_encryption'])
return False
else:
print 'encryption is ' + str(wireless.GetWirelessProperty(networkid,
"encryption"))
print "no encryption specified..."
entry.set_net_prop("enctype", "None")
self._save_gen_settings(entry)
entry.set_net_prop("automatic",
noneToString(netent.chkbox_autoconnect.get_active()))
if entry.chkbox_global_settings.get_active():
entry.set_net_prop('use_settings_globally', True)
else:
entry.set_net_prop('use_settings_globally', False)
wireless.RemoveGlobalEssidEntry(networkid)
wireless.SaveWirelessNetworkProfile(networkid)
return True
def edit_advanced(self, widget, event, ttype, networkid, networkentry):
""" Display the advanced settings dialog.

View File

@@ -238,6 +238,39 @@ class AdvancedSettingsDialog(gtk.Dialog):
self.destroy()
del self
def save_settings(self):
""" Save settings common to wired and wireless settings dialogs. """
if self.chkbox_static_ip.get_active():
self.set_net_prop("ip", noneToString(self.txt_ip.get_text()))
self.set_net_prop("netmask", noneToString(self.txt_netmask.get_text()))
self.set_net_prop("gateway", noneToString(self.txt_gateway.get_text()))
else:
self.set_net_prop("ip", '')
self.set_net_prop("netmask", '')
self.set_net_prop("gateway", '')
if self.chkbox_static_dns.get_active() and \
not self.chkbox_global_dns.get_active():
self.set_net_prop('use_static_dns', True)
self.set_net_prop('use_global_dns', False)
self.set_net_prop('dns_domain', noneToString(self.txt_domain.get_text()))
self.set_net_prop("search_domain", noneToString(self.txt_search_dom.get_text()))
self.set_net_prop("dns1", noneToString(self.txt_dns_1.get_text()))
self.set_net_prop("dns2", noneToString(self.txt_dns_2.get_text()))
self.set_net_prop("dns3", noneToString(self.txt_dns_3.get_text()))
elif self.chkbox_static_dns.get_active() and \
self.chkbox_global_dns.get_active():
self.set_net_prop('use_static_dns', True)
self.set_net_prop('use_global_dns', True)
else:
self.set_net_prop('use_static_dns', False)
self.set_net_prop('use_global_dns', False)
self.set_net_prop('dns_domain', '')
self.set_net_prop("search_domain", '')
self.set_net_prop("dns1", '')
self.set_net_prop("dns2", '')
self.set_net_prop("dns3", '')
class WiredSettingsDialog(AdvancedSettingsDialog):
def __init__(self, name):
@@ -264,6 +297,11 @@ class WiredSettingsDialog(AdvancedSettingsDialog):
self.chkbox_global_dns.set_active(bool(wired.GetWiredProperty("use_global_dns")))
self.reset_static_checkboxes()
def save_settings(self):
AdvancedSettingsDialog.save_settings(self)
wired.SaveWiredNetworkProfile(self.prof_name)
return True
def format_entry(self, label):
""" Helper method to fetch and format wired properties. """
return noneToBlankString(wired.GetWiredProperty(label))
@@ -353,7 +391,6 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
self.chkbox_global_settings.set_active(bool(wireless.GetWirelessProperty(networkID,
'use_settings_globally')))
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):
@@ -369,6 +406,40 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
self.combo_encryption.set_active(0)
self.change_encrypt_method()
def save_settings(self, networkid):
# Check encryption info
if self.chkbox_encryption.get_active():
print "setting encryption info..."
encryption_info = self.encryption_info
encrypt_methods = misc.LoadEncryptionMethods()
self.set_net_prop("enctype",
encrypt_methods[self.combo_encryption.get_active()][1])
for x in encryption_info:
if encryption_info[x].get_text() == "":
error(self, language['encrypt_info_missing'])
return False
self.set_net_prop(x, noneToString(encryption_info[x].
get_text()))
elif not self.chkbox_encryption.get_active() and \
wireless.GetWirelessProperty(networkid, "encryption"):
error(self, language['enable_encryption'])
return False
else:
print 'encryption is ' + str(wireless.GetWirelessProperty(networkid,
"encryption"))
print "no encryption specified..."
self.set_net_prop("enctype", "None")
AdvancedSettingsDialog.save_settings(self)
if self.chkbox_global_settings.get_active():
self.set_net_prop('use_settings_globally', True)
else:
self.set_net_prop('use_settings_globally', False)
wireless.RemoveGlobalEssidEntry(networkid)
wireless.SaveWirelessNetworkProfile(networkid)
return True
def format_entry(self, networkid, label):
""" Helper method for fetching/formatting wireless properties. """
return noneToBlankString(wireless.GetWirelessProperty(networkid, label))
@@ -575,6 +646,10 @@ class WiredNetworkEntry(NetworkEntry):
self.destroy()
del self
def save_wired_settings(self):
""" Save wired network settings. """
return self.advanced_dialog.save_settings()
def edit_scripts(self, widget=None, event=None):
""" Launch the script editting dialog. """
profile = self.combo_profile_names.get_active_text()
@@ -757,6 +832,10 @@ class WirelessNetworkEntry(NetworkEntry):
return val.replace("&", "&amp;").replace("<", "&lt;").\
replace(">","&gt;").replace("'", "&apos;").replace('"', "&quot;")
def save_wireless_settings(self, networkid):
""" Save wireless network settings. """
return self.advanced_dialog.save_settings(networkid)
def destroy_called(self, *args):
""" Clean up everything. """
self.disconnect(self.wifides)

View File

@@ -411,12 +411,7 @@ class ConnectThread(threading.Thread):
BACKEND.StopDHCP()
def connect_aborted(self, reason):
""" Sets the thread status to aborted in a thread-safe way.
Sets the status to aborted, and also delays returning for
a few seconds to make sure the message is readable
"""
""" Sets the thread status to aborted. """
if self.abort_reason:
reason = self.abort_reason
self.connecting_message = reason

View File

@@ -2,7 +2,7 @@
""" Suspends the wicd daemon.
Sets a flag in the daemon that will stop it from monitoring networkg status.
Sets a flag in the daemon that will stop it from monitoring network status.
Used for when a laptop enters hibernation/suspension.
"""