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

Made a bunch of small logic improvements.

Fixed some remaining bugs from the gui.py refactoring.
This commit is contained in:
imdano
2008-03-04 20:39:53 +00:00
parent a2dedaaa03
commit cb88439499
6 changed files with 100 additions and 119 deletions

View File

@@ -127,10 +127,6 @@ class LogWriter:
class ConnectionWizard(dbus.service.Object): class ConnectionWizard(dbus.service.Object):
########## VARIABLES AND STUFF
#################################
def __init__(self, bus_name, object_path='/org/wicd/daemon', def __init__(self, bus_name, object_path='/org/wicd/daemon',
auto_connect=True): auto_connect=True):
dbus.service.Object.__init__(self, bus_name, object_path) dbus.service.Object.__init__(self, bus_name, object_path)
@@ -147,7 +143,7 @@ class ConnectionWizard(dbus.service.Object):
self.vpn_session = None self.vpn_session = None
self.gui_open = False self.gui_open = False
self.suspended = False self.suspended = False
self.connection_state = 0 self.connection_state = misc.NOT_CONNECTED
self.connection_info = [""] self.connection_info = [""]
self.auto_connecting = False self.auto_connecting = False
@@ -156,7 +152,7 @@ class ConnectionWizard(dbus.service.Object):
# This will speed up the scanning process - if a client doesn't # This will speed up the scanning process - if a client doesn't
# need a fresh scan, just feed them the old one. A fresh scan # need a fresh scan, just feed them the old one. A fresh scan
# can be done by calling FreshScan(self,interface) # can be done by calling Scan(fresh=True).
self.LastScan = '' self.LastScan = ''
# Make a variable that will hold the wired network profile # Make a variable that will hold the wired network profile
@@ -339,12 +335,6 @@ class ConnectionWizard(dbus.service.Object):
if self.suspended: if self.suspended:
self.Disconnect() self.Disconnect()
@dbus.service.method('org.wicd.daemon')
def StartVPNSession(self):
import vpn
self.vpn_session = vpn.PPTPConnection()
self.vpn_pid = None
@dbus.service.method('org.wicd.daemon') @dbus.service.method('org.wicd.daemon')
def AutoConnect(self, fresh): def AutoConnect(self, fresh):
""" Attempts to autoconnect to a wired or wireless network. """ Attempts to autoconnect to a wired or wireless network.
@@ -680,8 +670,8 @@ class ConnectionWizard(dbus.service.Object):
functions as a way to simply the strength polling process for functions as a way to simply the strength polling process for
the GUI and tray icon, by returning the strength that the user the GUI and tray icon, by returning the strength that the user
has requested to be displayed in wicd preferences. has requested to be displayed in wicd preferences.
"""
"""
if self.GetSignalDisplayType() == 0: if self.GetSignalDisplayType() == 0:
return self.GetCurrentSignalStrength(iwconfig) return self.GetCurrentSignalStrength(iwconfig)
else: else:
@@ -901,7 +891,7 @@ class ConnectionWizard(dbus.service.Object):
@dbus.service.method('org.wicd.daemon.wired') @dbus.service.method('org.wicd.daemon.wired')
def ConnectWired(self): def ConnectWired(self):
"""connects to a wired network. """ """ Connects to a wired network. """
self.SetForcedDisconnect(False) self.SetForcedDisconnect(False)
self.wired.before_script = self.GetWiredProperty("beforescript") self.wired.before_script = self.GetWiredProperty("beforescript")
self.wired.after_script = self.GetWiredProperty("afterscript") self.wired.after_script = self.GetWiredProperty("afterscript")
@@ -1311,7 +1301,7 @@ class ConnectionStatus:
self.connection_lost_counter = 0 self.connection_lost_counter = 0
self.conn = connection self.conn = connection
self.status_changed = False self.status_changed = False
self.state = 0 self.state = misc.NOT_CONNECTED
def check_for_wired_connection(self, wired_ip): def check_for_wired_connection(self, wired_ip):
""" Checks for an active wired connection. """ Checks for an active wired connection.
@@ -1392,9 +1382,13 @@ class ConnectionStatus:
""" """
conn = self.conn conn = self.conn
wired_ip = None
wifi_ip = None
if conn.suspended: if conn.suspended:
print "Suspended." print "Suspended."
self.state = misc.SUSPENDED
self.update_state()
return True return True
# Determine what our current state is. # Determine what our current state is.
@@ -1412,10 +1406,17 @@ class ConnectionStatus:
else: else:
self.state = misc.CONNECTING self.state = misc.CONNECTING
self.status_changed = True self.status_changed = True
self.update_state(wired_ip, wifi_ip)
return True
def update_state(self, wired_ip=None, wifi_ip=None):
""" Set the current connection state. """
conn = self.conn
# Set our connection state/info. # Set our connection state/info.
if self.state == misc.NOT_CONNECTED: if self.state == misc.NOT_CONNECTED:
info = [""] info = [""]
elif self.state == misc.SUSPENDED:
info = [""]
elif self.state == misc.CONNECTING: elif self.state == misc.CONNECTING:
if conn.CheckIfWiredConnecting(): if conn.CheckIfWiredConnecting():
info = ["wired"] info = ["wired"]

113
gui.py
View File

@@ -273,23 +273,23 @@ def noneToString(text):
def noneToBlankString(text): def noneToBlankString(text):
""" Converts NoneType or "None" to a blank string. """ """ Converts NoneType or "None" to a blank string. """
if text == None or text == "None" or text == "": if text in (None, "None"):
return "" return ""
else: else:
return str(text) return str(text)
def stringToNone(text): def stringToNone(text):
""" Performs opposite function of noneToString. """ """ Performs opposite function of noneToString. """
if text == "" or text == "None" or text == None: if text in ("", None, "None"):
return None return None
else: else:
return str(text) return str(text)
def stringToBoolean(text): def stringToBoolean(text):
""" Turns a string representation of a bool to a boolean if needed. """ """ Turns a string representation of a bool to a boolean if needed. """
if text == "True" or text == "1": if text in ("True", "1"):
return True return True
if text == "False" or text == "0": if text in ("False", "0"):
return False return False
return text return text
@@ -355,18 +355,18 @@ class AdvancedSettingsDialog(gtk.Dialog):
gateway = self.txt_gateway gateway = self.txt_gateway
ip_parts = misc.IsValidIP(ipAddress) ip_parts = misc.IsValidIP(ipAddress)
if ip_parts: if ip_parts:
if stringToNone(gateway.get_text()) == None: # Make sure the gateway box is blank if stringToNone(gateway.get_text()) is None: # Make sure the gateway box is blank
# Fill it in with a .1 at the end # Fill it in with a .1 at the end
gateway.set_text('.'.join(ip_parts[0:3]) + '.1') gateway.set_text('.'.join(ip_parts[0:3]) + '.1')
if stringToNone(netmask.get_text()) == None: # Make sure the netmask is blank if stringToNone(netmask.get_text()) is None: # Make sure the netmask is blank
netmask.set_text('255.255.255.0') # Fill in the most common one netmask.set_text('255.255.255.0') # Fill in the most common one
elif ipAddress != "": elif ipAddress != "":
misc.error(None, "Invalid IP Address Entered.") misc.error(None, "Invalid IP Address Entered.")
def reset_static_checkboxes(self): def reset_static_checkboxes(self):
# Enable the right stuff # Enable the right stuff
if not stringToNone(self.txt_ip.get_text()) == None: if stringToNone(self.txt_ip.get_text()) is not None:
self.chkbox_static_ip.set_active(True) self.chkbox_static_ip.set_active(True)
self.chkbox_static_dns.set_active(True) self.chkbox_static_dns.set_active(True)
self.chkbox_static_dns.set_sensitive(False) self.chkbox_static_dns.set_sensitive(False)
@@ -375,7 +375,7 @@ class AdvancedSettingsDialog(gtk.Dialog):
self.chkbox_static_dns.set_active(False) self.chkbox_static_dns.set_active(False)
self.chkbox_static_dns.set_sensitive(True) self.chkbox_static_dns.set_sensitive(True)
if not stringToNone(self.txt_dns_1.get_text()) == None: if stringToNone(self.txt_dns_1.get_text()) is not None:
self.chkbox_static_dns.set_active(True) self.chkbox_static_dns.set_active(True)
else: else:
self.chkbox_static_dns.set_active(False) self.chkbox_static_dns.set_active(False)
@@ -556,11 +556,11 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
if wireless.GetWirelessProperty(networkID,'use_global_dns'): if wireless.GetWirelessProperty(networkID,'use_global_dns'):
self.chkbox_global_dns.set_active(True) self.chkbox_global_dns.set_active(True)
if wireless.GetWirelessProperty(networkID, "dns1") != None: if wireless.GetWirelessProperty(networkID, "dns1") is not None:
self.txt_dns_1.set_text(self.format_entry(networkID, "dns1")) self.txt_dns_1.set_text(self.format_entry(networkID, "dns1"))
if wireless.GetWirelessProperty(networkID, 'dns2') != None: if wireless.GetWirelessProperty(networkID, 'dns2') is not None:
self.txt_dns_2.set_text(self.format_entry(networkID, "dns2")) self.txt_dns_2.set_text(self.format_entry(networkID, "dns2"))
if wireless.GetWirelessProperty(networkID, 'dns3') != None: if wireless.GetWirelessProperty(networkID, 'dns3') is not None:
self.txt_dns_3.set_text(self.format_entry(networkID, "dns3")) self.txt_dns_3.set_text(self.format_entry(networkID, "dns3"))
self.reset_static_checkboxes() self.reset_static_checkboxes()
@@ -634,8 +634,7 @@ class NetworkEntry(gtk.HBox):
self.expander_vbox = gtk.VBox(False, 1) self.expander_vbox = gtk.VBox(False, 1)
self.expander_vbox.show() self.expander_vbox.show()
self.expander_vbox.pack_start(self.expander) self.expander_vbox.pack_start(self.expander)
self.expander_vbox.pack_start(self.connect_hbox, fill=False, self.expander_vbox.pack_start(self.connect_hbox, False, False)
expand=False)
self.pack_end(self.expander_vbox) self.pack_end(self.expander_vbox)
# Set up the advanced settings button # Set up the advanced settings button
@@ -658,13 +657,11 @@ class NetworkEntry(gtk.HBox):
self.settings_hbox = gtk.HBox(False, 3) self.settings_hbox = gtk.HBox(False, 3)
self.settings_hbox.set_border_width(5) self.settings_hbox.set_border_width(5)
self.settings_hbox.pack_start(self.script_button, fill=False, self.settings_hbox.pack_start(self.script_button, False, False)
expand=False) self.settings_hbox.pack_start(self.advanced_button, False, False)
self.settings_hbox.pack_start(self.advanced_button, fill=False,
expand=False)
self.vbox_top = gtk.VBox(False, 0) self.vbox_top = gtk.VBox(False, 0)
self.vbox_top.pack_end(self.settings_hbox, fill=False, expand=False) self.vbox_top.pack_end(self.settings_hbox, False, False)
aligner = gtk.Alignment(xscale=1.0) aligner = gtk.Alignment(xscale=1.0)
aligner.add(self.vbox_top) aligner.add(self.vbox_top)
@@ -731,15 +728,13 @@ class WiredNetworkEntry(NetworkEntry):
# Pack the various VBox objects. # Pack the various VBox objects.
self.hbox_temp = gtk.HBox(False, 0) self.hbox_temp = gtk.HBox(False, 0)
self.hbox_def = gtk.HBox(False, 0) self.hbox_def = gtk.HBox(False, 0)
self.vbox_top.pack_start(self.profile_help, fill=True, expand=True) self.vbox_top.pack_start(self.profile_help, True, True)
self.vbox_top.pack_start(self.hbox_def) self.vbox_top.pack_start(self.hbox_def)
self.vbox_top.pack_start(self.hbox_temp) self.vbox_top.pack_start(self.hbox_temp)
self.hbox_temp.pack_start(self.combo_profile_names, fill=True, self.hbox_temp.pack_start(self.combo_profile_names, True, True)
expand=True) self.hbox_temp.pack_start(self.button_add, False, False)
self.hbox_temp.pack_start(self.button_add, fill=False, expand=False) self.hbox_temp.pack_start(self.button_delete, False, False)
self.hbox_temp.pack_start(self.button_delete, fill=False, expand=False) self.hbox_def.pack_start(self.chkbox_default_profile, False, False)
self.hbox_def.pack_start(self.chkbox_default_profile, fill=False,
expand=False)
# Connect events # Connect events
self.button_add.connect("clicked", self.add_profile) self.button_add.connect("clicked", self.add_profile)
@@ -873,15 +868,13 @@ class WiredNetworkEntry(NetworkEntry):
if self.combo_profile_names.get_active() > -1: if self.combo_profile_names.get_active() > -1:
if self.is_full_gui == False: if self.is_full_gui == False:
return return
print "changing profile..."
profile_name = self.combo_profile_names.get_active_text() profile_name = self.combo_profile_names.get_active_text()
print profile_name
config.ReadWiredNetworkProfile(profile_name) config.ReadWiredNetworkProfile(profile_name)
self.advanced_dialog.txt_ip.set_text(self.format_entry("ip")) self.advanced_dialog.txt_ip.set_text(self.format_entry("ip"))
self.advanced_dialog.txt_netmask.set_text(self.format_entry("netmask")) self.advanced_dialog.txt_netmask.set_text(self.format_entry("netmask"))
self.advanced_dialog.txt_gateway.set_text(self.format_entry("gateway")) self.advanced_dialog.txt_gateway.set_text(self.format_entry("gateway"))
self.advanced_dialog.txt_dns_1.set_text(self.format_entry("dns1")) self.advanced_dialog.txt_dns_1.set_text(self.format_entry("dns1"))
self.advanced_dialog.txt_dns_2.set_text(self.format_entry("dns2")) self.advanced_dialog.txt_dns_2.set_text(self.format_entry("dns2"))
self.advanced_dialog.txt_dns_3.set_text(self.format_entry("dns3")) self.advanced_dialog.txt_dns_3.set_text(self.format_entry("dns3"))
@@ -934,17 +927,16 @@ class WirelessNetworkEntry(NetworkEntry):
+ self.lbl_strength.get_label()) + self.lbl_strength.get_label())
# Pack the network status HBox. # Pack the network status HBox.
self.hbox_status.pack_start(self.lbl_strength, fill=False, expand=True) self.hbox_status.pack_start(self.lbl_strength, False, True)
self.hbox_status.pack_start(self.lbl_encryption, fill=False, expand=True) self.hbox_status.pack_start(self.lbl_encryption, False, True)
self.hbox_status.pack_start(self.lbl_mac, fill=False, expand=True) self.hbox_status.pack_start(self.lbl_mac, False, True)
self.hbox_status.pack_start(self.lbl_mode, fill=False, expand=True) self.hbox_status.pack_start(self.lbl_mode, False, True)
self.hbox_status.pack_start(self.lbl_channel, fill=False, expand=True) self.hbox_status.pack_start(self.lbl_channel, False, True)
# Add the wireless network specific parts to the NetworkEntry # Add the wireless network specific parts to the NetworkEntry
# VBox objects. # VBox objects.
self.vbox_top.pack_start(self.chkbox_autoconnect, fill=False, self.vbox_top.pack_start(self.chkbox_autoconnect, False, False)
expand=False) self.vbox_top.pack_start(self.hbox_status, True, True)
self.vbox_top.pack_start(self.hbox_status, fill=True, expand=True)
if stringToBoolean(self.format_entry(networkID, "automatic")): if stringToBoolean(self.format_entry(networkID, "automatic")):
self.chkbox_autoconnect.set_active(True) self.chkbox_autoconnect.set_active(True)
@@ -1052,7 +1044,6 @@ class WirelessNetworkEntry(NetworkEntry):
""" Launch the script editting dialog. """ """ Launch the script editting dialog. """
result = os.spawnlpe(os.P_WAIT, "gksudo", "gksudo", "./configscript.py", result = os.spawnlpe(os.P_WAIT, "gksudo", "gksudo", "./configscript.py",
str(self.networkID), "wireless", os.environ) str(self.networkID), "wireless", os.environ)
print result
def update_autoconnect(self, widget=None): def update_autoconnect(self, widget=None):
""" Called when the autoconnect checkbox is toggled. """ """ Called when the autoconnect checkbox is toggled. """
@@ -1085,15 +1076,13 @@ class WiredProfileChooser:
# Remove widgets that were added to the normal WiredNetworkEntry # Remove widgets that were added to the normal WiredNetworkEntry
# so that they can be added to the pop-up wizard. # so that they can be added to the pop-up wizard.
wired_net_entry.vboxTop.remove(wired_net_entry.hbox_temp) wired_net_entry.vbox_top.remove(wired_net_entry.hbox_temp)
wired_net_entry.vboxTop.remove(wired_net_entry.profile_help) wired_net_entry.vbox_top.remove(wired_net_entry.profile_help)
dialog.vbox.pack_start(instruct_label, fill=False, expand=False) dialog.vbox.pack_start(instruct_label, fill=False, expand=False)
dialog.vbox.pack_start(wired_net_entry.profile_help, fill=False, dialog.vbox.pack_start(wired_net_entry.profile_help, False, False)
expand=False) dialog.vbox.pack_start(wired_net_entry.hbox_temp, False, False)
dialog.vbox.pack_start(wired_net_entry.hbox_temp, fill=False, dialog.vbox.pack_start(stoppopcheckbox, False, False)
expand=False)
dialog.vbox.pack_start(stoppopcheckbox, fill=False, expand=False)
dialog.show_all() dialog.show_all()
wired_profiles = wired_net_entry.combo_profile_names wired_profiles = wired_net_entry.combo_profile_names
@@ -1176,8 +1165,8 @@ class appGui:
if width > -1 and height > -1: if width > -1 and height > -1:
self.window.resize(int(width), int(height)) self.window.resize(int(width), int(height))
gobject.timeout_add(600, self.update_statusbar) gobject.timeout_add(800, self.update_statusbar)
gobject.timeout_add(100, self.pulse_progress_bar) gobject.timeout_add(250, self.pulse_progress_bar)
def create_adhoc_network(self, widget=None): def create_adhoc_network(self, widget=None):
""" Shows a dialog that creates a new adhoc network. """ """ Shows a dialog that creates a new adhoc network. """
@@ -1205,8 +1194,8 @@ class appGui:
ip_entry.entry.set_text('169.254.12.10') # Just a random IP ip_entry.entry.set_text('169.254.12.10') # Just a random IP
vbox_ah = gtk.VBox(False, 0) vbox_ah = gtk.VBox(False, 0)
vbox_ah.pack_start(self.chkbox_use_encryption, fill=False, expand=False) vbox_ah.pack_start(self.chkbox_use_encryption, False, False)
vbox_ah.pack_start(self.key_entry, fill=False, expand=False) vbox_ah.pack_start(self.key_entry, False, False)
vbox_ah.show() vbox_ah.show()
dialog.vbox.pack_start(essid_entry) dialog.vbox.pack_start(essid_entry)
dialog.vbox.pack_start(ip_entry) dialog.vbox.pack_start(ip_entry)
@@ -1381,14 +1370,14 @@ class appGui:
flags=gtk.DIALOG_MODAL, flags=gtk.DIALOG_MODAL,
buttons=(gtk.STOCK_CONNECT, 1, gtk.STOCK_CANCEL, 2)) buttons=(gtk.STOCK_CONNECT, 1, gtk.STOCK_CANCEL, 2))
dialog.set_has_separator(False) dialog.set_has_separator(False)
dialog.lbl = gtk.Label(language['hidden_network_essid']) lbl = gtk.Label(language['hidden_network_essid'])
dialog.textbox = gtk.Entry() textbox = gtk.Entry()
dialog.vbox.pack_start(dialog.lbl) dialog.vbox.pack_start(lbl)
dialog.vbox.pack_start(dialog.textbox) dialog.vbox.pack_start(textbox)
dialog.show_all() dialog.show_all()
button = dialog.run() button = dialog.run()
if button == 1: if button == 1:
answer = dialog.textbox.get_text() answer = textbox.get_text()
dialog.destroy() dialog.destroy()
self.refresh_networks(None, True, answer) self.refresh_networks(None, True, answer)
else: else:
@@ -1460,7 +1449,7 @@ class appGui:
def update_statusbar(self): def update_statusbar(self):
""" Updates the status bar. """ """ Updates the status bar. """
if self.is_visible == False: if not self.is_visible:
return True return True
iwconfig = wireless.GetIwconfig() iwconfig = wireless.GetIwconfig()
@@ -1555,12 +1544,12 @@ class appGui:
if wired.CheckPluggedIn() or wired.GetAlwaysShowWiredInterface(): if wired.CheckPluggedIn() or wired.GetAlwaysShowWiredInterface():
printLine = True # In this case we print a separator. printLine = True # In this case we print a separator.
wirednet = WiredNetworkEntry() wirednet = WiredNetworkEntry()
self.network_list.pack_start(wirednet, fill=False, expand=False) self.network_list.pack_start(wirednet, False, False)
wirednet.connect_button.connect("button-press-event", self.connect, wirednet.connect_button.connect("button-press-event", self.connect,
"wired", 0, wirednet) "wired", 0, wirednet)
wirednet.advanced_button.connect("button-press-event", wirednet.advanced_button.connect("button-press-event",
self.edit_advanced, self.edit_advanced, "wired", 0,
"wired", 0, wirednet) wirednet)
# Scan # Scan
if fresh: if fresh:
# Even if it is None, it can still be passed. # Even if it is None, it can still be passed.
@@ -1575,20 +1564,20 @@ class appGui:
for x in range(0, num_networks): for x in range(0, num_networks):
if printLine: if printLine:
sep = gtk.HSeparator() sep = gtk.HSeparator()
self.network_list.pack_start(sep, padding=10, expand=False, self.network_list.pack_start(sep, padding=10, fill=False,
fill=False) expand=False)
sep.show() sep.show()
else: else:
printLine = True printLine = True
tempnet = WirelessNetworkEntry(x) tempnet = WirelessNetworkEntry(x)
tempnet.show_all() tempnet.show_all()
self.network_list.pack_start(tempnet, expand=False, fill=False) self.network_list.pack_start(tempnet, False, False)
tempnet.connect_button.connect("button-press-event", tempnet.connect_button.connect("button-press-event",
self.connect, "wireless", x, self.connect, "wireless", x,
tempnet) tempnet)
tempnet.advanced_button.connect("button-press-event", tempnet.advanced_button.connect("button-press-event",
self.edit_advanced, self.edit_advanced, "wireless",
"wireless", x, tempnet) x, tempnet)
else: else:
instruct_label.hide() instruct_label.hide()
if wireless.GetKillSwitchEnabled(): if wireless.GetKillSwitchEnabled():

23
misc.py
View File

@@ -33,6 +33,7 @@ NOT_CONNECTED = 0
CONNECTING = 1 CONNECTING = 1
WIRELESS = 2 WIRELESS = 2
WIRED = 3 WIRED = 3
SUSPENDED = 4
def Run(cmd, include_stderr=False, return_pipe=False): def Run(cmd, include_stderr=False, return_pipe=False):
""" Run a command. """ Run a command.
@@ -116,7 +117,7 @@ def ReadFile(filename):
def to_bool(var): def to_bool(var):
""" Convert a string to type bool, but make "False"/"0" become False. """ """ Convert a string to type bool, but make "False"/"0" become False. """
if var == "False" or var == "0": if var in ("False", "0"):
var = False var = False
else: else:
var = bool(var) var = bool(var)
@@ -125,20 +126,11 @@ def to_bool(var):
def Noneify(variable): def Noneify(variable):
""" Convert string types to either None or booleans""" """ Convert string types to either None or booleans"""
#set string Nones to real Nones #set string Nones to real Nones
if variable == "None" or variable == "": if variable in ("None", "", None):
return None return None
if variable == "True": # or variable == "1": # or variable == 1: if variable in ("False", "0"):
return True
if variable == "False": #or variable == "0": # or variable == 0:
return False return False
#if str(variable).isdigit() == True: return bool(variable)
# return int(variable)
if str(variable) == "1":
return True
if str(variable) == "0":
return False
#otherwise...
return variable
def ParseEncryption(network): def ParseEncryption(network):
""" Parse through an encryption template file """ Parse through an encryption template file
@@ -228,7 +220,7 @@ def noneToString(text):
the box will be blank. the box will be blank.
""" """
if text == None or text == "None" or text == "": if text in (None, ""):
return "None" return "None"
else: else:
return str(text) return str(text)
@@ -248,8 +240,7 @@ def get_gettext():
if (osLanguage): if (osLanguage):
langs += osLanguage.split(":") langs += osLanguage.split(":")
langs += ["en_US"] langs += ["en_US"]
lang = gettext.translation('wicd', local_path, languages=langs, lang = gettext.translation('wicd', local_path, languages=langs, fallback=True)
fallback=True)
_ = lang.gettext _ = lang.gettext
return _ return _

View File

@@ -222,7 +222,7 @@ class Wireless(Controller):
# If there is a hidden essid then set it now, so that when it is # If there is a hidden essid then set it now, so that when it is
# scanned it will be recognized. # scanned it will be recognized.
essid = misc.Noneify(essid) essid = misc.Noneify(essid)
if not essid == None: if essid is not None:
print 'Setting hidden essid' + essid print 'Setting hidden essid' + essid
wiface.SetEssid(essid) wiface.SetEssid(essid)

View File

@@ -177,7 +177,7 @@ class TrayIcon():
cur_network + "...") cur_network + "...")
self.tr.set_from_file(wpath.images + "no-signal.png") self.tr.set_from_file(wpath.images + "no-signal.png")
elif state == misc.NOT_CONNECTED: elif state in (misc.SUSPENDED, misc.NOT_CONNECTED):
self.tr.set_from_file(wpath.images + "no-signal.png") self.tr.set_from_file(wpath.images + "no-signal.png")
if wireless.GetKillSwitchEnabled(): if wireless.GetKillSwitchEnabled():
status = (language['not_connected'] + " (" + status = (language['not_connected'] + " (" +

View File

@@ -60,8 +60,6 @@ wpa2_pattern = re.compile('(WPA2)', re.I | re.M | re.S)
auth_pattern = re.compile('.*wpa_state=(.*?)\n', re.I | re.M | re.S) auth_pattern = re.compile('.*wpa_state=(.*?)\n', re.I | re.M | re.S)
RALINK_DRIVER = 'ralink legacy' RALINK_DRIVER = 'ralink legacy'
DHCP_CLIENT = None
def SetDNS(dns1=None, dns2=None, dns3=None): def SetDNS(dns1=None, dns2=None, dns3=None):
""" Set the DNS of the system to the specified DNS servers. """ Set the DNS of the system to the specified DNS servers.
@@ -566,23 +564,25 @@ class WirelessInterface(Interface):
The channel number, or None if not found. The channel number, or None if not found.
""" """
if freq == '2.412 GHz': return 1 ret = None
elif freq == '2.417 GHz': return 2 if freq == '2.412 GHz': ret = 1
elif freq == '2.422 GHz': return 3 elif freq == '2.417 GHz': ret = 2
elif freq == '2.427 GHz': return 4 elif freq == '2.422 GHz': ret = 3
elif freq == '2.432 GHz': return 5 elif freq == '2.427 GHz': ret = 4
elif freq == '2.437 GHz': return 6 elif freq == '2.432 GHz': ret = 5
elif freq == '2.442 GHz': return 7 elif freq == '2.437 GHz': ret = 6
elif freq == '2.447 GHz': return 8 elif freq == '2.442 GHz': ret = 7
elif freq == '2.452 GHz': return 9 elif freq == '2.447 GHz': ret = 8
elif freq == '2.457 GHz': return 10 elif freq == '2.452 GHz': ret = 9
elif freq == '2.462 GHz': return 11 elif freq == '2.457 GHz': ret = 10
elif freq == '2.467 GHz': return 12 elif freq == '2.462 GHz': ret = 11
elif freq == '2.472 GHz': return 13 elif freq == '2.467 GHz': ret = 12
elif freq == '2.484 GHz': return 14 elif freq == '2.472 GHz': ret = 13
elif freq == '2.484 GHz': ret = 14
else: else:
print 'Couldn\'t determine channel number for current network - ' + freq print 'Couldn\'t determine channel number for current network - ' + freq
return None
return ret
def _GetRalinkInfo(self): def _GetRalinkInfo(self):
""" Get a network info list used for ralink drivers """ Get a network info list used for ralink drivers