1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-23 14:42:29 +01:00

Added support in the preferences window for specifying which dhcp client, link detection tool, and route flushing tool to use. It can also be left up to wicd to decide automatically.

Made a few logic optimizations.
This commit is contained in:
imdano
2008-03-21 17:07:47 +00:00
parent b5609dc209
commit c055ea0d36
6 changed files with 841 additions and 422 deletions

103
daemon.py
View File

@@ -148,6 +148,9 @@ class ConnectionWizard(dbus.service.Object):
self.connection_state = misc.NOT_CONNECTED self.connection_state = misc.NOT_CONNECTED
self.connection_info = [""] self.connection_info = [""]
self.auto_connecting = False self.auto_connecting = False
self.dhcp_client = 0
self.link_detect_tool = 0
self.flush_tool = 0
# Load the config file # Load the config file
self.ReadConfig() self.ReadConfig()
@@ -376,6 +379,8 @@ class ConnectionWizard(dbus.service.Object):
not self.GetNeedWiredProfileChooser(): not self.GetNeedWiredProfileChooser():
self.LaunchChooser() self.LaunchChooser()
return return
# Default Profile.
elif self.GetWiredAutoConnectMethod() == 1: elif self.GetWiredAutoConnectMethod() == 1:
network = self.GetDefaultWiredNetwork() network = self.GetDefaultWiredNetwork()
if not network: if not network:
@@ -383,6 +388,8 @@ class ConnectionWizard(dbus.service.Object):
" wired autoconnect failed." " wired autoconnect failed."
self._wireless_autoconnect() self._wireless_autoconnect()
return return
# Last-Used.
else: # Assume its last-used. else: # Assume its last-used.
network = self.GetLastUsedWiredNetwork() network = self.GetLastUsedWiredNetwork()
if not network: if not network:
@@ -390,6 +397,7 @@ class ConnectionWizard(dbus.service.Object):
"autoconnect failed." "autoconnect failed."
self._wireless_autoconnect() self._wireless_autoconnect()
return return
self.ReadWiredNetworkProfile(network) self.ReadWiredNetworkProfile(network)
self.ConnectWired() self.ConnectWired()
print "Attempting to autoconnect with wired interface..." print "Attempting to autoconnect with wired interface..."
@@ -454,18 +462,16 @@ class ConnectionWizard(dbus.service.Object):
@dbus.service.method('org.wicd.daemon') @dbus.service.method('org.wicd.daemon')
def GetGlobalDNSAddresses(self): def GetGlobalDNSAddresses(self):
""" Returns the global dns addresses. """ """ Returns the global dns addresses. """
print 'returning global dns addresses to client'
return (misc.noneToString(self.dns1), misc.noneToString(self.dns2), return (misc.noneToString(self.dns1), misc.noneToString(self.dns2),
misc.noneToString(self.dns3)) misc.noneToString(self.dns3))
@dbus.service.method('org.wicd.daemon') @dbus.service.method('org.wicd.daemon')
def CheckIfConnecting(self): def CheckIfConnecting(self):
""" Returns if a network connection is being made. """ """ Returns if a network connection is being made. """
if not self.CheckIfWiredConnecting() and \ if self.CheckIfWiredConnecting() or self.CheckIfWirelessConnecting():
not self.CheckIfWirelessConnecting():
return False
else:
return True return True
else:
return False
@dbus.service.method('org.wicd.daemon') @dbus.service.method('org.wicd.daemon')
def CancelConnect(self): def CancelConnect(self):
@@ -588,6 +594,48 @@ class ConnectionWizard(dbus.service.Object):
""" """
return bool(self.need_profile_chooser) return bool(self.need_profile_chooser)
@dbus.service.method('org.wicd.daemon')
def GetDHCPClient(self):
return self.dhcp_client
@dbus.service.method('org.wicd.daemon')
def SetDHCPClient(self, client):
self.dhcp_client = int(client)
self.wifi.dhcp_client = int(client)
self.wired.dhcp_client = int(client)
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.set("Settings", "dhcp_client", client)
config.write(open(self.app_conf, "w"))
@dbus.service.method('org.wicd.daemon')
def GetLinkDetectionTool(self):
return self.link_detect_tool
@dbus.service.method('org.wicd.daemon')
def SetLinkDetectionTool(self, link_tool):
self.link_detect_tool = int(link_tool)
self.wired.link_tool = int(link_tool)
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.set("Settings", "link_detect_tool", link_tool)
config.write(open(self.app_conf, "w"))
@dbus.service.method('org.wicd.daemon')
def GetFlushTool(self):
return self.flush_tool
@dbus.service.method('org.wicd.daemon')
def SetFlushTool(self, flush_tool):
self.flush_tool = int(flush_tool)
self.wired.flush_tool = int(flush_tool)
self.wifi.flush_tool = int(flush_tool)
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.set("Settings", "flush_tool", flush_tool)
config.write(open(self.app_conf, "w"))
@dbus.service.signal(dbus_interface='org.wicd.daemon', signature='') @dbus.service.signal(dbus_interface='org.wicd.daemon', signature='')
def LaunchChooser(self): def LaunchChooser(self):
""" Emits the wired profile chooser dbus signal. """ """ Emits the wired profile chooser dbus signal. """
@@ -629,7 +677,7 @@ class ConnectionWizard(dbus.service.Object):
self.LastScan = scan self.LastScan = scan
if self.debug_mode: if self.debug_mode:
print 'scanning done' print 'scanning done'
print 'found' + str(len(scan)) + 'networks:' print 'found ' + str(len(scan)) + ' networks:'
for i, network in enumerate(scan): for i, network in enumerate(scan):
self.ReadWirelessNetworkProfile(i) self.ReadWirelessNetworkProfile(i)
@@ -805,11 +853,8 @@ class ConnectionWizard(dbus.service.Object):
@dbus.service.method('org.wicd.daemon.wired') @dbus.service.method('org.wicd.daemon.wired')
def CheckIfWiredConnecting(self): def CheckIfWiredConnecting(self):
""" Returns True if wired interface is connecting, otherwise False. """ """ Returns True if wired interface is connecting, otherwise False. """
if self.wired.connecting_thread is not None: if self.wired.connecting_thread:
#if connecting_thread exists, then check for it's return self.wired.connecting_thread.is_connecting
#status, if it doesn't exist, we aren't connecting
status = self.wired.connecting_thread.is_connecting
return status
else: else:
return False return False
@@ -833,9 +878,8 @@ class ConnectionWizard(dbus.service.Object):
@dbus.service.method('org.wicd.daemon.wired') @dbus.service.method('org.wicd.daemon.wired')
def CheckWiredConnectingMessage(self): def CheckWiredConnectingMessage(self):
""" Returns the wired interface\'s status message. """ """ Returns the wired interface\'s status message. """
if not self.wired.connecting_thread == None: if self.wired.connecting_thread:
status = self.wired.connecting_thread.GetStatus() return self.wired.connecting_thread.GetStatus()
return status
else: else:
return False return False
@@ -898,14 +942,12 @@ class ConnectionWizard(dbus.service.Object):
@dbus.service.method('org.wicd.daemon.wired') @dbus.service.method('org.wicd.daemon.wired')
def EnableWiredInterface(self): def EnableWiredInterface(self):
""" Calls a method to enable the wired interface. """ """ Calls a method to enable the wired interface. """
result = self.wired.EnableInterface() return self.wired.EnableInterface()
return result
@dbus.service.method('org.wicd.daemon.wired') @dbus.service.method('org.wicd.daemon.wired')
def DisableWiredInterface(self): def DisableWiredInterface(self):
""" Calls a method to disable the wired interface. """ """ Calls a method to disable the wired interface. """
result = self.wired.DisableInterface() return self.wired.DisableInterface()
return result
@dbus.service.method('org.wicd.daemon.wired') @dbus.service.method('org.wicd.daemon.wired')
def ConnectWired(self): def ConnectWired(self):
@@ -1075,8 +1117,8 @@ class ConnectionWizard(dbus.service.Object):
config.remove_section(bssid_key) config.remove_section(bssid_key)
config.add_section(bssid_key) config.add_section(bssid_key)
# We want to write the essid and bssid sections if global # We want to write the essid in addition to bssid
# settings are enabled. # sections if global settings are enabled.
if cur_network["use_settings_globally"]: if cur_network["use_settings_globally"]:
if config.has_section(essid_key): if config.has_section(essid_key):
config.remove_section(essid_key) config.remove_section(essid_key)
@@ -1091,10 +1133,10 @@ class ConnectionWizard(dbus.service.Object):
@dbus.service.method('org.wicd.daemon.config') @dbus.service.method('org.wicd.daemon.config')
def SaveWirelessNetworkProperty(self, id, option): def SaveWirelessNetworkProperty(self, id, option):
""" Writes a particular wireless property to disk """ """ Writes a particular wireless property to disk. """
if (option.strip()).endswith("script"): if (option.strip()).endswith("script"):
print 'you cannot save script information to disk through \ print 'You cannot save script information to disk through ' + \
the daemon.' 'the daemon.'
return return
cur_network = self.LastScan[id] cur_network = self.LastScan[id]
essid_key = "essid:" + cur_network["essid"] essid_key = "essid:" + cur_network["essid"]
@@ -1255,7 +1297,6 @@ class ConnectionWizard(dbus.service.Object):
dns2 = self.get_option("Settings", "global_dns_2", default='None') dns2 = self.get_option("Settings", "global_dns_2", default='None')
dns3 = self.get_option("Settings", "global_dns_3", default='None') dns3 = self.get_option("Settings", "global_dns_3", default='None')
self.SetGlobalDNS(dns1, dns2, dns3) self.SetGlobalDNS(dns1, dns2, dns3)
self.SetAutoReconnect(self.get_option("Settings", "auto_reconnect", self.SetAutoReconnect(self.get_option("Settings", "auto_reconnect",
default=False)) default=False))
self.SetDebugMode(self.get_option("Settings", "debug_mode", self.SetDebugMode(self.get_option("Settings", "debug_mode",
@@ -1267,6 +1308,13 @@ class ConnectionWizard(dbus.service.Object):
self.SetSignalDisplayType(self.get_option("Settings", self.SetSignalDisplayType(self.get_option("Settings",
"signal_display_type", "signal_display_type",
default=0)) default=0))
self.SetDHCPClient(self.get_option("Settings", "dhcp_client",
default=0))
self.SetLinkDetectionTool(self.get_option("Settings",
"link_detect_tool",
default=0))
self.SetFlushTool(self.get_option("Settings", "flush_tool",
default=0))
else: else:
# Write some defaults maybe? # Write some defaults maybe?
print "Configuration file not found, creating, adding defaults..." print "Configuration file not found, creating, adding defaults..."
@@ -1280,6 +1328,9 @@ class ConnectionWizard(dbus.service.Object):
config.set("Settings", "debug_mode", "False") config.set("Settings", "debug_mode", "False")
config.set("Settings", "wired_connect_mode", "1") config.set("Settings", "wired_connect_mode", "1")
config.set("Settings", "signal_display_type", "0") config.set("Settings", "signal_display_type", "0")
config.set("Settings", "dhcp_client", "0")
config.set("Settings", "link_detect_tool", "0")
config.set("Settings", "flush_tool", "0")
config.set("Settings", "dns1", "None") config.set("Settings", "dns1", "None")
config.set("Settings", "dns2", "None") config.set("Settings", "dns2", "None")
config.set("Settings", "dns3", "None") config.set("Settings", "dns3", "None")
@@ -1297,6 +1348,10 @@ class ConnectionWizard(dbus.service.Object):
"wired_interface")) "wired_interface"))
self.SetWPADriver(config.get("Settings", self.SetWPADriver(config.get("Settings",
"wpa_driver")) "wpa_driver"))
self.SetDHCPClient(config.get("Settings", "dhcp_client"))
self.SetLinkDetectionTool(config.get("Settings",
"link_detect_tool"))
self.SetFlushTool(config.get("Settings", "flush_tool"))
self.SetAlwaysShowWiredInterface(False) self.SetAlwaysShowWiredInterface(False)
self.SetAutoReconnect(False) self.SetAutoReconnect(False)
self.SetDebugMode(False) self.SetDebugMode(False)

View File

@@ -413,15 +413,12 @@
<child internal-child="action_area"> <child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area2"> <widget class="GtkHButtonBox" id="dialog-action_area2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="layout_style">GTK_BUTTONBOX_END</property> <property name="layout_style">GTK_BUTTONBOX_END</property>
<child> <child>
<widget class="GtkButton" id="button3"> <widget class="GtkButton" id="button3">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="label">gtk-ok</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-ok</property>
<property name="use_stock">True</property> <property name="use_stock">True</property>
<property name="response_id">1</property> <property name="response_id">1</property>
</widget> </widget>
@@ -430,9 +427,7 @@
<widget class="GtkButton" id="button4"> <widget class="GtkButton" id="button4">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="label">gtk-cancel</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-cancel</property>
<property name="use_stock">True</property> <property name="use_stock">True</property>
<property name="response_id">0</property> <property name="response_id">0</property>
</widget> </widget>
@@ -450,28 +445,27 @@
</child> </child>
</widget> </widget>
<widget class="GtkDialog" id="pref_dialog"> <widget class="GtkDialog" id="pref_dialog">
<property name="width_request">465</property> <property name="title" translatable="yes">Preferences</property>
<property name="height_request">525</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Wicd Preferences</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="has_separator">False</property>
<child internal-child="vbox"> <child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox3"> <widget class="GtkVBox" id="dialog-vbox4">
<property name="visible">True</property>
<child>
<widget class="GtkNotebook" id="notebook2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<widget class="GtkVBox" id="vbox6">
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">5</property> <property name="spacing">5</property>
<child> <child>
<widget class="GtkHBox" id="hbox_wpa"> <widget class="GtkHBox" id="hbox_wpa">
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child> <child>
<widget class="GtkLabel" id="pref_driver_label"> <widget class="GtkLabel" id="pref_driver_label">
<property name="width_request">75</property> <property name="width_request">75</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">WPA Supplicant Driver:</property> <property name="label" translatable="yes">WPA Supplicant Driver:</property>
</widget> </widget>
</child> </child>
@@ -483,18 +477,15 @@
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="padding">1</property> <property name="padding">1</property>
<property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkHBox" id="hbox11"> <widget class="GtkHBox" id="hbox16">
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child> <child>
<widget class="GtkLabel" id="pref_wifi_label"> <widget class="GtkLabel" id="pref_wifi_label">
<property name="width_request">260</property> <property name="width_request">260</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Wireless Interface:</property> <property name="label" translatable="yes">Wireless Interface:</property>
</widget> </widget>
</child> </child>
@@ -515,18 +506,16 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">2</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkHBox" id="hbox12"> <widget class="GtkHBox" id="hbox18">
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child> <child>
<widget class="GtkLabel" id="pref_wired_label"> <widget class="GtkLabel" id="pref_wired_label">
<property name="width_request">260</property> <property name="width_request">260</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Wired Interface:</property> <property name="label" translatable="yes">Wired Interface:</property>
</widget> </widget>
</child> </child>
@@ -547,32 +536,30 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">3</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkCheckButton" id="pref_global_check"> <widget class="GtkCheckButton" id="pref_global_check">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Use global DNS servers</property> <property name="label" translatable="yes">Use global DNS servers</property>
<property name="use_underline">True</property>
<property name="response_id">0</property> <property name="response_id">0</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="position">4</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkHBox" id="hbox13"> <widget class="GtkHBox" id="hbox20">
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child> <child>
<widget class="GtkLabel" id="pref_dns1_label"> <widget class="GtkLabel" id="pref_dns1_label">
<property name="width_request">170</property> <property name="width_request">170</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">DNS 1</property> <property name="label" translatable="yes">DNS 1</property>
</widget> </widget>
<packing> <packing>
@@ -597,18 +584,16 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">5</property> <property name="position">4</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkHBox" id="hbox14"> <widget class="GtkHBox" id="hbox22">
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child> <child>
<widget class="GtkLabel" id="pref_dns2_label"> <widget class="GtkLabel" id="pref_dns2_label">
<property name="width_request">170</property> <property name="width_request">170</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">DNS 2</property> <property name="label" translatable="yes">DNS 2</property>
</widget> </widget>
<packing> <packing>
@@ -633,18 +618,16 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">6</property> <property name="position">5</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkHBox" id="hbox15"> <widget class="GtkHBox" id="hbox24">
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child> <child>
<widget class="GtkLabel" id="pref_dns3_label"> <widget class="GtkLabel" id="pref_dns3_label">
<property name="width_request">170</property> <property name="width_request">170</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">DNS 3</property> <property name="label" translatable="yes">DNS 3</property>
</widget> </widget>
<packing> <packing>
@@ -668,15 +651,30 @@
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="position">7</property> <property name="position">6</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkCheckButton" id="pref_always_check"> <widget class="GtkCheckButton" id="pref_always_check">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Always show wired interface</property> <property name="label" translatable="yes">Always show wired interface</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">7</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="pref_auto_check">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Automatically reconnect on connection loss</property>
<property name="use_underline">True</property>
<property name="response_id">0</property> <property name="response_id">0</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
</widget> </widget>
@@ -687,11 +685,11 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkCheckButton" id="pref_auto_check"> <widget class="GtkCheckButton" id="pref_debug_check">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="label" translatable="yes">Enable Debug Mode</property>
<property name="label" translatable="yes">Automatically reconnect on connection loss</property> <property name="use_underline">True</property>
<property name="response_id">0</property> <property name="response_id">0</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
</widget> </widget>
@@ -702,11 +700,11 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkCheckButton" id="pref_debug_check"> <widget class="GtkCheckButton" id="pref_dbm_check">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="label" translatable="yes">Use dBm to measure signal strength</property>
<property name="label" translatable="yes">Enable Debug Mode</property> <property name="use_underline">True</property>
<property name="response_id">0</property> <property name="response_id">0</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
</widget> </widget>
@@ -717,66 +715,65 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkCheckButton" id="pref_dbm_check"> <widget class="GtkHSeparator" id="hseparator5">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Use dBm to measure signal strength</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">11</property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator3">
<property name="width_request">2</property> <property name="width_request">2</property>
<property name="height_request">8</property> <property name="height_request">8</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="position">12</property> <property name="position">11</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkLabel" id="pref_wired_auto_label"> <widget class="GtkLabel" id="pref_wired_auto_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Wired Autoconnect Setting:</property> <property name="label" translatable="yes">Wired Autoconnect Setting:</property>
<property name="single_line_mode">True</property> <property name="single_line_mode">True</property>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">13</property> <property name="position">12</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkRadioButton" id="pref_use_def_radio"> <widget class="GtkRadioButton" id="pref_use_def_radio">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Use default profile on wired autoconnect</property> <property name="label" translatable="yes">Use default profile on wired autoconnect</property>
<property name="use_underline">True</property>
<property name="response_id">0</property> <property name="response_id">0</property>
<property name="active">True</property> <property name="active">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
</widget> </widget>
<packing>
<property name="expand">False</property>
<property name="position">13</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="pref_prompt_radio">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Prompt for profile on wired autoconnect</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">pref_use_def_radio</property>
</widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="position">14</property> <property name="position">14</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkRadioButton" id="pref_prompt_radio"> <widget class="GtkRadioButton" id="pref_use_last_radio">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="label" translatable="yes">Use last profile on wired autoconnect</property>
<property name="label" translatable="yes">Prompt for profile on wired autoconnect</property> <property name="use_underline">True</property>
<property name="response_id">0</property> <property name="response_id">0</property>
<property name="active">True</property> <property name="active">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
@@ -787,47 +784,289 @@
<property name="position">15</property> <property name="position">15</property>
</packing> </packing>
</child> </child>
</widget>
</child>
<child> <child>
<widget class="GtkRadioButton" id="pref_use_last_radio"> <widget class="GtkLabel" id="gen_settings_label">
<property name="visible">True</property>
<property name="label" translatable="yes">General Settings</property>
</widget>
<packing>
<property name="type">tab</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox7">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkVBox" id="vbox8">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">5</property>
<child>
<widget class="GtkLabel" id="dhcp_client_label">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">DHCP Client:</property>
</widget>
</child>
<child>
<widget class="GtkRadioButton" id="dhcp_auto_radio">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Use last profile on wired autoconnect</property> <property name="label" translatable="yes">Automatic (recommended)</property>
<property name="response_id">0</property> <property name="response_id">0</property>
<property name="active">True</property> <property name="active">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<property name="group">pref_use_def_radio</property> </widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="dhclient_radio">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">dhclient</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">dhcp_auto_radio</property>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="dhcpcd_radio">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">dhcpcd</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">dhcp_auto_radio</property>
</widget>
<packing>
<property name="position">3</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="pump_radio">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">pump</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">dhcp_auto_radio</property>
</widget>
<packing>
<property name="position">4</property>
</packing>
</child>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="position">16</property> <property name="fill">False</property>
</packing> </packing>
</child> </child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child> <child>
<widget class="GtkButton" id="button5"> <widget class="GtkHSeparator" id="hseparator6">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-ok</property> </widget>
<property name="use_stock">True</property> <packing>
<property name="response_id">1</property> <property name="expand">False</property>
<property name="padding">4</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox9">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">5</property>
<child>
<widget class="GtkLabel" id="wired_detect_label">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Wired Link Detection:</property>
</widget> </widget>
</child> </child>
<child> <child>
<widget class="GtkButton" id="button6"> <widget class="GtkRadioButton" id="link_auto_radio">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-cancel</property> <property name="label" translatable="yes">Automatic (recommended)</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="ethtool_radio">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">ethtool</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">link_auto_radio</property>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="miitool_radio">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">mii-tool</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">link_auto_radio</property>
</widget>
<packing>
<property name="position">3</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator7">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="padding">4</property>
<property name="position">3</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox10">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkLabel" id="route_flush_label">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Route Table Flushing:</property>
</widget>
</child>
<child>
<widget class="GtkRadioButton" id="flush_auto_radio">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Automatic (recommended)</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="ip_flush_radio">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">ip</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">flush_auto_radio</property>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="route_flush_radio">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">route</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">flush_auto_radio</property>
</widget>
<packing>
<property name="position">3</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="ext_prog_label">
<property name="visible">True</property>
<property name="label" translatable="yes">External Programs</property>
</widget>
<packing>
<property name="type">tab</property>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area4">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="cancelbutton1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property> <property name="use_stock">True</property>
<property name="response_id">2</property> <property name="response_id">0</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="okbutton1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="response_id">1</property>
</widget> </widget>
<packing> <packing>
<property name="position">1</property> <property name="position">1</property>

97
gui.py
View File

@@ -147,6 +147,12 @@ language['invalid_address'] = _('Invalid address in $A entry.')
language['global_settings'] = _('Use these settings for all networks sharing this essid') language['global_settings'] = _('Use these settings for all networks sharing this essid')
language['encrypt_info_missing'] = _('Required encryption information is missing.') language['encrypt_info_missing'] = _('Required encryption information is missing.')
language['enable_encryption'] = _('This network requires encryption to be enabled.') language['enable_encryption'] = _('This network requires encryption to be enabled.')
language['wicd_auto_config'] = _('Automatic (recommended)')
language["gen_settings"] = _("General Settings")
language["ext_programs"] = _("External Programs")
language["dhcp_client"] = _("DHCP Client")
language["wired_detect"] = _("Wired Link Detection")
language["route_flush"] = _("Route Table Flushing")
language['0'] = _('0') language['0'] = _('0')
language['1'] = _('1') language['1'] = _('1')
@@ -1274,6 +1280,43 @@ class appGui:
lastusedradiobutton = self.wTree.get_widget("pref_use_last_radio") lastusedradiobutton = self.wTree.get_widget("pref_use_last_radio")
lastusedradiobutton.set_label(language['use_last_used_profile']) lastusedradiobutton.set_label(language['use_last_used_profile'])
## External Programs tab
self.wTree.get_widget("gen_settings_label").set_label(language["gen_settings"])
self.wTree.get_widget("ext_prog_label").set_label(language["ext_programs"])
self.wTree.get_widget("dhcp_client_label").set_label(language["dhcp_client"])
self.wTree.get_widget("wired_detect_label").set_label(language["wired_detect"])
self.wTree.get_widget("route_flush_label").set_label(language["route_flush"])
# DHCP Clients
dhcpautoradio = self.wTree.get_widget("dhcp_auto_radio")
dhcpautoradio.set_label(language["wicd_auto_config"])
dhclientradio = self.wTree.get_widget("dhclient_radio")
pumpradio = self.wTree.get_widget("pump_radio")
dhcpcdradio = self.wTree.get_widget("dhcpcd_radio")
dhcp_list = [dhcpautoradio, dhclientradio, pumpradio, dhcpcdradio]
dhcp_method = daemon.GetDHCPClient()
dhcp_list[dhcp_method].set_active(True)
# Wired Link Detection Apps
linkautoradio = self.wTree.get_widget("link_auto_radio")
linkautoradio.set_label(language['wicd_auto_config'])
linkautoradio = self.wTree.get_widget("link_auto_radio")
ethtoolradio = self.wTree.get_widget("ethtool_radio")
miitoolradio = self.wTree.get_widget("miitool_radio")
wired_link_list = [linkautoradio, ethtoolradio, miitoolradio]
wired_link_method = daemon.GetLinkDetectionTool()
wired_link_list[wired_link_method].set_active(True)
# Route Flushing Apps
flushautoradio = self.wTree.get_widget("flush_auto_radio")
flushautoradio.set_label(language['wicd_auto_config'])
ipflushradio = self.wTree.get_widget("ip_flush_radio")
routeflushradio = self.wTree.get_widget("route_flush_radio")
flush_list = [flushautoradio, ipflushradio, routeflushradio]
flush_method = daemon.GetFlushTool()
flush_list[flush_method].set_active(True)
if wired.GetWiredAutoConnectMethod() == 1: if wired.GetWiredAutoConnectMethod() == 1:
usedefaultradiobutton.set_active(True) usedefaultradiobutton.set_active(True)
elif wired.GetWiredAutoConnectMethod() == 2: elif wired.GetWiredAutoConnectMethod() == 2:
@@ -1350,6 +1393,8 @@ class appGui:
atrlist = pango.AttrList() atrlist = pango.AttrList()
atrlist.insert(pango.AttrWeight(pango.WEIGHT_BOLD, 0, 50)) atrlist.insert(pango.AttrWeight(pango.WEIGHT_BOLD, 0, 50))
entryWiredAutoMethod.set_attributes(atrlist) entryWiredAutoMethod.set_attributes(atrlist)
self.wTree.get_widget("notebook2").set_current_page(0)
dialog.show_all() dialog.show_all()
response = dialog.run() response = dialog.run()
@@ -1370,6 +1415,34 @@ class appGui:
wired.SetWiredAutoConnectMethod(3) wired.SetWiredAutoConnectMethod(3)
else: else:
wired.SetWiredAutoConnectMethod(1) wired.SetWiredAutoConnectMethod(1)
# External Programs Tab
if dhcpautoradio.get_active():
dhcp_client = misc.AUTO
elif dhclientradio.get_active():
dhcp_client = misc.DHCLIENT
elif dhcpcdradio.get_active():
dhcp_client = misc.DHCPCD
else:
dhcp_client = misc.PUMP
daemon.SetDHCPClient(dhcp_client)
if linkautoradio.get_active():
link_tool = misc.AUTO
elif ethtoolradio.get_active():
link_tool = misc.ETHTOOL
else:
link_tool = misc.MIITOOL
daemon.SetLinkDetectionTool(link_tool)
if flushautoradio.get_active():
flush_tool = misc.AUTO
elif ipflushradio.get_active():
flush_tool = misc.IP
else:
flush_tool = misc.ROUTE
daemon.SetFlushTool(flush_tool)
dialog.hide() dialog.hide()
def set_label(self, glade_str, label): def set_label(self, glade_str, label):
@@ -1523,21 +1596,21 @@ class appGui:
if not network: if not network:
return False return False
strength = wireless.GetCurrentSignalStrength(iwconfig)
dbm_strength = wireless.GetCurrentDBMStrength(iwconfig)
if strength is not None and dbm_strength is not None:
network = str(network) network = str(network)
if daemon.GetSignalDisplayType() == 0: if daemon.GetSignalDisplayType() == 0:
strength = str(strength) strength = wireless.GetCurrentSignalStrength(iwconfig)
else: else:
strength = str(dbm_strength) strength = wireless.GetCurrentDBMStrength(iwconfig)
if strength is None:
return False
strength = str(strength)
ip = str(wireless_ip) ip = str(wireless_ip)
self.set_status(language['connected_to_wireless'].replace self.set_status(language['connected_to_wireless'].replace
('$A', network).replace ('$A', network).replace
('$B', daemon.FormatSignalForPrinting(strength)).replace ('$B', daemon.FormatSignalForPrinting(strength)).replace
('$C', wireless_ip)) ('$C', wireless_ip))
return True return True
return False
def set_status(self, msg): def set_status(self, msg):
""" Sets the status bar message for the GUI. """ """ Sets the status bar message for the GUI. """
@@ -1660,9 +1733,12 @@ class appGui:
not entry.chkbox_global_dns.get_active(): not entry.chkbox_global_dns.get_active():
entry.set_net_prop('use_static_dns', True) entry.set_net_prop('use_static_dns', True)
entry.set_net_prop('use_global_dns', False) entry.set_net_prop('use_global_dns', False)
entry.set_net_prop("dns1", noneToString(entry.txt_dns_1.get_text())) entry.set_net_prop("dns1",
entry.set_net_prop("dns2", noneToString(entry.txt_dns_2.get_text())) noneToString(entry.txt_dns_1.get_text()))
entry.set_net_prop("dns3", noneToString(entry.txt_dns_3.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 \ elif entry.chkbox_static_dns.get_active() and \
entry.chkbox_global_dns.get_active(): entry.chkbox_global_dns.get_active():
entry.set_net_prop('use_static_dns', True) entry.set_net_prop('use_static_dns', True)
@@ -1696,7 +1772,8 @@ class appGui:
misc.error(self.window, language['enable_encryption']) misc.error(self.window, language['enable_encryption'])
return False return False
else: else:
print 'encryption is', wireless.GetWirelessProperty(networkid, "encryption") print 'encryption is ' + str(wireless.GetWirelessProperty(networkid,
"encryption"))
print "no encryption specified..." print "no encryption specified..."
entry.set_net_prop("enctype", "None") entry.set_net_prop("enctype", "None")

11
misc.py
View File

@@ -35,6 +35,17 @@ WIRELESS = 2
WIRED = 3 WIRED = 3
SUSPENDED = 4 SUSPENDED = 4
AUTO = 0
DHCLIENT = 1
DHCPCD = 2
PUMP = 3
ETHTOOL = 1
MIITOOL = 2
IP = 1
ROUTE = 2
def Run(cmd, include_stderr=False, return_pipe=False): def Run(cmd, include_stderr=False, return_pipe=False):
""" Run a command. """ Run a command.

View File

@@ -71,6 +71,8 @@ class Controller(object):
self.global_dns_3 = None self.global_dns_3 = None
self._wired_interface = None self._wired_interface = None
self._wireless_interface = None self._wireless_interface = None
self._dhcp_client = None
self._flush_tool = None
self._debug = None self._debug = None
def set_wireless_iface(self, value): def set_wireless_iface(self, value):
@@ -99,9 +101,31 @@ class Controller(object):
def get_debug(self): def get_debug(self):
return self._debug return self._debug
def set_dhcp_client(self, value):
self._dhcp_client = value
if self.wiface:
self.wiface.DHCP_CLIENT = value
if self.liface:
self.liface.DHCP_CLIENT = value
def get_dhcp_client(self):
return self._dhcp_client
def set_flush_tool(self, value):
self._flush_tool = value
if self.wiface:
self.wiface.flush_tool = value
if self.liface:
self.liface.flush_tool = value
def get_flush_tool(self):
return self._flush_tool
wireless_interface = property(get_wireless_iface, set_wireless_iface) wireless_interface = property(get_wireless_iface, set_wireless_iface)
wired_interface = property(get_wired_iface, set_wired_iface) wired_interface = property(get_wired_iface, set_wired_iface)
debug = property(get_debug, set_debug) debug = property(get_debug, set_debug)
flush_tool = property(get_flush_tool, set_flush_tool)
dhcp_client = property(get_dhcp_client, set_dhcp_client)
def SetWiface(self, iface): def SetWiface(self, iface):
""" Sets the wireless interface for the associated wnettools class. """ """ Sets the wireless interface for the associated wnettools class. """
@@ -266,17 +290,15 @@ class ConnectThread(threading.Thread):
Otherwise do nothing. Otherwise do nothing.
""" """
if (((self.network.get('dns1') or self.network.get('dns2') or
self.network.get('dns3')) and self.network.get('use_static_dns')) or
self.network.get('use_global_dns')):
self.SetStatus('setting_static_dns')
if self.network.get('use_global_dns'): if self.network.get('use_global_dns'):
wnettools.SetDNS(misc.Noneify(self.global_dns_1), wnettools.SetDNS(misc.Noneify(self.global_dns_1),
misc.Noneify(self.global_dns_2), misc.Noneify(self.global_dns_2),
misc.Noneify(self.global_dns_3)) misc.Noneify(self.global_dns_3))
else: elif self.network.get('use_static_dns') and (self.network.get('dns1') or
wnettools.SetDNS(self.network.get('dns1'), self.network.get('dns2') or self.network.get('dns3')):
self.network.get('dns2'), self.network.get('dns3')) self.SetStatus('setting_static_dns')
wnettools.SetDNS(self.network.get('dns1'), self.network.get('dns2'),
self.network.get('dns3'))
def connect_aborted(self, reason): def connect_aborted(self, reason):
""" Sets the thread status to aborted in a thread-safe way. """ Sets the thread status to aborted in a thread-safe way.
@@ -672,10 +694,17 @@ class Wired(Controller):
""" Initialise the class. """ """ Initialise the class. """
Controller.__init__(self) Controller.__init__(self)
self.wpa_driver = None self.wpa_driver = None
self._link_detect = None
self.liface = wnettools.WiredInterface(self.wired_interface, self.debug) self.liface = wnettools.WiredInterface(self.wired_interface, self.debug)
def __setattr__(self, attr, val): def set_link_detect(self, value):
object.__setattr__(self, attr, val) self._link_detect = value
if self.liface:
self.liface.link_detect = value
def get_link_detect(self): return self._link_detect
link_detect = property(get_link_detect, set_link_detect)
def LoadInterfaces(self): def LoadInterfaces(self):
""" Load the wnettools controls for the wired/wireless interfaces. """ """ Load the wnettools controls for the wired/wireless interfaces. """

View File

@@ -129,6 +129,8 @@ class Interface(object):
self.MIITOOL_FOUND = False self.MIITOOL_FOUND = False
self.ETHTOOL_FOUND = False self.ETHTOOL_FOUND = False
self.IP_FOUND = False self.IP_FOUND = False
self.flush_tool = None
self.link_detect = None
self.Check() self.Check()
def SetDebugMode(self, value): def SetDebugMode(self, value):
@@ -142,7 +144,7 @@ class Interface(object):
iface -- the name of the interface. iface -- the name of the interface.
""" """
self.iface = iface self.iface = str(iface)
def CheckDHCP(self): def CheckDHCP(self):
""" Check for a valid DHCP client. """ Check for a valid DHCP client.
@@ -153,6 +155,9 @@ class Interface(object):
warning is printed. warning is printed.
""" """
if self.DHCP_CLIENT:
DHCP_CLIENT = self.DHCP_CLIENT
else:
dhcpclients = ["dhclient", "dhcpcd", "pump"] dhcpclients = ["dhclient", "dhcpcd", "pump"]
for client in dhcpclients: for client in dhcpclients:
if misc.Run("which " + client): if misc.Run("which " + client):
@@ -163,13 +168,16 @@ class Interface(object):
print "WARNING: NO DHCP CLIENT DETECTED! Make sure there is one \ print "WARNING: NO DHCP CLIENT DETECTED! Make sure there is one \
set in your path." set in your path."
return return
elif DHCP_CLIENT == "dhclient": elif DHCP_CLIENT in [misc.DHCLIENT, "dhclient"]:
DHCP_CLIENT = misc.DHCLIENT
DHCP_CMD = "dhclient" DHCP_CMD = "dhclient"
DHCP_RELEASE = "dhclient -r" DHCP_RELEASE = "dhclient -r"
elif DHCP_CLIENT == "pump": elif DHCP_CLIENT in [misc.PUMP, "pump"]:
DHCP_CLIENT = misc.PUMP
DHCP_CMD = "pump -i" DHCP_CMD = "pump -i"
DHCP_RELEASE = "pump -r -i" DHCP_RELEASE = "pump -r -i"
elif DHCP_CLIENT == "dhcpcd": elif DHCP_CLIENT in [misc.DHCPCD, "dhcpcd"]:
DHCP_CLIENT = misc.DHCPCD
DHCP_CMD = "dhcpcd" DHCP_CMD = "dhcpcd"
DHCP_RELEASE = "dhcpcd -r" DHCP_RELEASE = "dhcpcd -r"
@@ -352,11 +360,11 @@ class Interface(object):
pipe = misc.Run(cmd, include_stderr=True, return_pipe=True) pipe = misc.Run(cmd, include_stderr=True, return_pipe=True)
DHCP_CLIENT = self.DHCP_CLIENT DHCP_CLIENT = self.DHCP_CLIENT
if DHCP_CLIENT == "dhclient": if DHCP_CLIENT == misc.DHCLIENT:
return self._parse_dhclient(pipe) return self._parse_dhclient(pipe)
elif DHCP_CLIENT == "pump": elif DHCP_CLIENT == misc.PUMP:
return self._parse_pump(pipe) return self._parse_pump(pipe)
elif DHCP_CLIENT == "dhcpcd": elif DHCP_CLIENT == misc.DHCPCD:
return self._parse_dhcpcd(pipe) return self._parse_dhcpcd(pipe)
def ReleaseDHCP(self): def ReleaseDHCP(self):
@@ -368,7 +376,7 @@ class Interface(object):
""" Flush all network routes. """ """ Flush all network routes. """
if not self.iface: if not self.iface:
return return
if self.IP_FOUND: if self.IP_FOUND and self.flush_tool != misc.ROUTE:
cmd = "ip route flush dev " + self.iface cmd = "ip route flush dev " + self.iface
else: else:
cmd = 'route del dev ' + self.iface cmd = 'route del dev ' + self.iface
@@ -443,7 +451,7 @@ class WiredInterface(Interface):
""" """
if not self.iface: if not self.iface:
return False return False
if self.ETHTOOL_FOUND: if self.ETHTOOL_FOUND and self.link_detect != misc.MIITOOL:
return self._eth_get_plugged_in() return self._eth_get_plugged_in()
elif self.MIITOOL_FOUND: elif self.MIITOOL_FOUND:
return self._mii_get_plugged_in() return self._mii_get_plugged_in()
@@ -839,7 +847,7 @@ class WirelessInterface(Interface):
if self.wpa_driver == RALINK_DRIVER: if self.wpa_driver == RALINK_DRIVER:
return True return True
MAX_TIME = 10 MAX_TIME = 15
MAX_DISCONNECTED_TIME = 3 MAX_DISCONNECTED_TIME = 3
while (time.time() - auth_time) < MAX_TIME: while (time.time() - auth_time) < MAX_TIME:
cmd = 'wpa_cli -i ' + self.iface + ' status' cmd = 'wpa_cli -i ' + self.iface + ' status'