diff --git a/data/wicd.glade b/data/wicd.glade index 9ad771a..4a5cf77 100644 --- a/data/wicd.glade +++ b/data/wicd.glade @@ -1,6 +1,6 @@ - + 450 @@ -424,35 +424,100 @@ True - 17 + 18 2 4 4 - + True 24 - + True - 0 - DNS domain: + True + If enabled, the wired network interface will always be displayed in the main window. This can be useful if your wired network card does not detect when the interface is connected to a cable. + Always show wired interface + 0 + True - 6 - 7 + 2 + 3 + 4 - + True True 1 + 2 + 8 + 9 + + + + + + True + True + + + 1 + 2 + 9 + 10 + + + + + + True + True + + + 1 + 2 + 10 + 11 + + + + + + True + 0 + <b>Global DNS Servers</b> + True + + + 2 + 5 + 6 + + + + + + True + 12 + + + True + True + Use global DNS servers + 0 + True + + + + 2 6 7 @@ -460,116 +525,66 @@ - + True - 12 + 24 - + True - True - Automatically reconnect on network connection loss - 0 - True + 0 + Search domain: - 2 - 16 - 17 + 8 + 9 - + True - 0 - <b>Automatic Reconnection</b> - True - - - 2 - 15 - 16 - - - - - - True - 12 + 24 - + True - True - Use last wired network profile - 0 - True - True + 0 + DNS server 1: - 2 - 14 - 15 + 9 + 10 - + True - 12 + 24 - + True - True - Prompt for wired network profile - 0 - True - True - pref_use_last_radio + 0 + DNS server 2: - 2 - 13 - 14 + 10 + 11 - + True - 12 - - - True - True - Use default wired network profile - 0 - True - True - pref_use_last_radio - - - - - 2 - 12 - 13 - - - - - - True - 0 - <b>Wired automatic connection</b> - True + True + 1 2 11 12 @@ -577,18 +592,56 @@ - + True - 12 + 24 - + True 0 - Wired interface: + DNS server 3: + 11 + 12 + + + + + + True + 0 + <b>Network Interfaces</b> + True + + + 2 + + + + + + True + True + + + 1 + 2 + 1 + 2 + + + + + + True + True + + + 1 + 2 2 3 @@ -613,119 +666,162 @@ - + True - True + 12 + + + True + 0 + Wired interface: + + - 1 - 2 2 3 - - True - True - - - 1 - 2 - 1 - 2 - - - - - + True 0 - <b>Network Interfaces</b> + <b>Wired automatic connection</b> True 2 + 12 + 13 - + True - 24 + 12 - + True - 0 - DNS server 3: + True + Use default wired network profile + 0 + True + True + pref_use_last_radio - 10 - 11 + 2 + 13 + 14 - + + True + 12 + + + True + True + Prompt for wired network profile + 0 + True + True + pref_use_last_radio + + + + + 2 + 14 + 15 + + + + + + True + 12 + + + True + True + Use last wired network profile + 0 + True + True + + + + + 2 + 15 + 16 + + + + + + True + 0 + <b>Automatic Reconnection</b> + True + + + 2 + 16 + 17 + + + + + + True + 12 + + + True + True + Automatically reconnect on network connection loss + 0 + True + + + + + 2 + 17 + 18 + + + + + True True 1 2 - 10 - 11 - + 7 + 8 + GTK_FILL - + True 24 - + True 0 - DNS server 2: - - - - - 9 - 10 - - - - - - True - 24 - - - True - 0 - DNS server 1: - - - - - 8 - 9 - - - - - - True - 24 - - - True - 0 - Search domain: + DNS domain: @@ -736,99 +832,27 @@ - + True - 12 - + True True - Use global DNS servers + True + If selected, wicd will automatically connect to a wired network +as soon as a cable is plugged in, even if a wireless connection +is already active. + Always switch to a wired connection when available 0 True - - 2 - 5 - 6 - - - - - - True - 0 - <b>Global DNS Servers</b> - True - 2 4 5 - - - - - - True - True - - - 1 - 2 - 9 - 10 - - - - - - True - True - - - 1 - 2 - 8 - 9 - - - - - - True - True - - - 1 - 2 - 7 - 8 - - - - - - True - 24 - - - True - True - If enabled, the wired network interface will always be displayed in the main window. This can be useful if your wired network card does not detect when the interface is connected to a cable. - Always show wired interface - 0 - True - - - - - 2 - 3 - 4 - + 24 @@ -872,146 +896,13 @@ True 6 - + True 0 - <b>Route Table Flushing</b> + <b>DHCP Client</b> True - 4 - 5 - - - - - - True - 0 - <b>Wired Link Detection</b> - True - - - 2 - 3 - - - - - - True - 12 - - - True - - - True - True - Automatic (recommended) - 0 - True - True - - - False - - - - - True - True - ip - 0 - True - True - flush_auto_radio - - - False - 1 - - - - - True - True - route - 0 - True - True - flush_auto_radio - - - False - 2 - - - - - - - 5 - 6 - - - - - - True - 12 - - - True - - - True - True - Automatic (recommended) - 0 - True - True - - - False - - - - - True - True - ethtool - 0 - True - True - link_auto_radio - - - False - 1 - - - - - True - True - mii-tool - 0 - True - True - link_auto_radio - - - False - 2 - - - - - - - 3 - 4 @@ -1090,13 +981,146 @@ - + + True + 12 + + + True + + + True + True + Automatic (recommended) + 0 + True + True + + + False + + + + + True + True + ethtool + 0 + True + True + link_auto_radio + + + False + 1 + + + + + True + True + mii-tool + 0 + True + True + link_auto_radio + + + False + 2 + + + + + + + 3 + 4 + + + + + + True + 12 + + + True + + + True + True + Automatic (recommended) + 0 + True + True + + + False + + + + + True + True + ip + 0 + True + True + flush_auto_radio + + + False + 1 + + + + + True + True + route + 0 + True + True + flush_auto_radio + + + False + 2 + + + + + + + 5 + 6 + + + + + True 0 - <b>DHCP Client</b> + <b>Wired Link Detection</b> True + 2 + 3 + + + + + + True + 0 + <b>Route Table Flushing</b> + True + + + 4 + 5 @@ -1135,88 +1159,114 @@ 10 2 - + True - 0 - Hover your mouse over the selected backend -to read its description. - True - 1 - 2 5 6 - - - - - - True - - - True - - - False - - - - - 1 - 2 - 1 - 2 - - - - - - True - - - 2 - 3 GTK_FILL - + True - 12 - - - True - 0 - Driver: - - + 0 + You should almost always use wext as the +WPA supplicant driver. + True - 1 - 2 + 1 + 2 + 2 + 3 - + + True + 0 + <b>Backend</b> + True + + + 2 + 3 + 4 + + + + + + True + True + + + 1 + 2 + 4 + 5 + + + + + True 12 - + True - True - Use dBm to measure signal strength - 0 - True + 0 + Backend: + + 4 + 5 + + + + + + True + 0 + <b>Debugging</b> + True + 2 - 9 - 10 + 6 + 7 + + + + + + True + 0 + <b>WPA Supplicant</b> + True + + + 2 + + + + + + True + 0 + <b>Wireless Interface</b> + True + + + 2 + 8 + 9 @@ -1242,114 +1292,88 @@ to read its description. - - True - 0 - <b>Wireless Interface</b> - True - - - 2 - 8 - 9 - - - - - - True - 0 - <b>WPA Supplicant</b> - True - - - 2 - - - - - - True - 0 - <b>Debugging</b> - True - - - 2 - 6 - 7 - - - - - + True 12 - + True - 0 - Backend: + True + Use dBm to measure signal strength + 0 + True - 4 - 5 + 2 + 9 + 10 - + True - True + 12 + + + True + 0 + Driver: + + + + + 1 + 2 + + + + + + True + + + 2 + 3 + GTK_FILL + + + + + + True + + + True + + + False + + 1 2 - 4 - 5 + 1 + 2 - + True 0 - <b>Backend</b> - True - - - 2 - 3 - 4 - - - - - - True - 0 - You should almost always use wext as the -WPA supplicant driver. + Hover your mouse over the selected backend +to read its description. True 1 2 - 2 - 3 - - - - - - True - - 5 6 - GTK_FILL diff --git a/images/wired-gui.svg b/images/wired-gui.svg new file mode 100644 index 0000000..437efcd --- /dev/null +++ b/images/wired-gui.svg @@ -0,0 +1,682 @@ + + + + + + + image/svg+xml + + + + Lapo Calamandrei + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wicd/autoconnect.py b/wicd/autoconnect.py index 310de8b..b21672d 100755 --- a/wicd/autoconnect.py +++ b/wicd/autoconnect.py @@ -49,7 +49,6 @@ def error_handler(*args): if __name__ == '__main__': try: time.sleep(2) - wireless.Scan(True) daemon.SetSuspend(False) if not daemon.CheckIfConnecting(): daemon.AutoConnect(True, reply_handler=handler, error_handler=handler) diff --git a/wicd/backends/be-ioctl.py b/wicd/backends/be-ioctl.py index b261449..08a6a79 100644 --- a/wicd/backends/be-ioctl.py +++ b/wicd/backends/be-ioctl.py @@ -376,9 +376,8 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface): False otherwise. """ - def error(): - print "Unable to find ctrl_interface for wpa_supplicant. " + \ - "Could not validate authentication." + error= "Unable to find ctrl_interface for wpa_supplicant. " + \ + "Could not validate authentication." # Right now there's no way to do this for ralink drivers if self.wpa_driver == RALINK_DRIVER: @@ -389,7 +388,7 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface): socket = [os.path.join(ctrl_iface, s) \ for s in os.listdir(ctrl_iface) if s == self.iface][0] except OSError: - error() + print error return True wpa = wpactrl.WPACtrl(socket) diff --git a/wicd/configmanager.py b/wicd/configmanager.py index 29d4320..b2755cc 100644 --- a/wicd/configmanager.py +++ b/wicd/configmanager.py @@ -48,7 +48,7 @@ class ConfigManager(RawConfigParser): """ Returns the path to the loaded config file. """ return self.config_file - def set_option(self, section, option, value, save=False): + def set_option(self, section, option, value, write=False): """ Wrapper around ConfigParser.set Adds the option to write the config file change right away. @@ -65,7 +65,7 @@ class ConfigManager(RawConfigParser): value = "%(ws)s%(value)s%(ws)s" % {"value" : value, "ws" : self.mrk_ws} RawConfigParser.set(self, section, str(option), value) - if save: + if write: self.write() def set(self, *args, **kargs): @@ -98,7 +98,7 @@ class ConfigManager(RawConfigParser): else: if default != "__None__": print 'did not find %s in configuration, setting default %s' % (option, str(default)) - self.set(section, option, str(default), save=True) + self.set(section, option, str(default), write=True) ret = default else: ret = None diff --git a/wicd/gui.py b/wicd/gui.py index 55f0eda..597e781 100644 --- a/wicd/gui.py +++ b/wicd/gui.py @@ -706,15 +706,14 @@ class appGui(object): [width, height] = self.window.get_size() try: daemon.WriteWindowSize(width, height, "main") - except: + daemon.SetGUIOpen(False) + except dbusmanager.DBusException: pass if self.standalone: sys.exit(0) self.is_visible = False - daemon.SetGUIOpen(False) - self.wait_for_events() return True def show_win(self): diff --git a/wicd/guiutil.py b/wicd/guiutil.py index e84c753..8eea489 100644 --- a/wicd/guiutil.py +++ b/wicd/guiutil.py @@ -46,6 +46,45 @@ def alert(parent, message, block=True): dialog.run() dialog.destroy() +def string_input(prompt, secondary, textbox_label): + # based on a version of a PyGTK text entry from + # http://ardoris.wordpress.com/2008/07/05/pygtk-text-entry-dialog/ + + def dialog_response(entry, dialog, response): + dialog.response(response) + + dialog = gtk.MessageDialog( + None, + gtk.DIALOG_MODAL, + gtk.MESSAGE_QUESTION, + gtk.BUTTONS_OK_CANCEL, + None) + + # set the text + dialog.set_markup("" + prompt + "") + # add the secondary text + dialog.format_secondary_markup(secondary) + + entry = gtk.Entry() + # allow the user to press enter instead of clicking OK + entry.connect("activate", dialog_response, dialog, gtk.RESPONSE_OK) + + # create an hbox and pack the label and entry in + hbox = gtk.HBox() + hbox.pack_start(gtk.Label(textbox_label), False, 4, 4) + hbox.pack_start(entry) + + # pack the boxes and show the dialog + dialog.vbox.pack_end(hbox, True, True, 0) + dialog.show_all() + + if dialog.run() == gtk.RESPONSE_OK: + text = entry.get_text() + dialog.destroy() + return text + else: + dialog.destroy() + return None class SmallLabel(gtk.Label): def __init__(self, text=''): diff --git a/wicd/monitor.py b/wicd/monitor.py index 47fe3b5..0566b9b 100755 --- a/wicd/monitor.py +++ b/wicd/monitor.py @@ -63,20 +63,29 @@ class ConnectionStatus(object): self.last_reconnect_time = time.time() self.signal_changed = False self.iwconfig = "" + self.trigger_reconnect = False bus = dbusmanager.get_bus() bus.add_signal_receiver(self._force_update_connection_status, "UpdateState", "org.wicd.daemon") def check_for_wired_connection(self, wired_ip): - """ Checks for an active wired connection. + """ Checks for a wired connection. - Checks for and updates the tray icon for an active wired connection - Returns True if wired connection is active, false if inactive. + Checks for two states: + 1) A wired connection is not in use, but a cable is plugged + in, and the user has chosen to switch to a wired connection + whenever its available, even if already connected to a + wireless network + + 2) A wired connection is currently active. """ + if not wired_ip and daemon.GetPreferWiredNetwork(): + if not daemon.GetForcedDisconnect() and wired.CheckPluggedIn(): + self.trigger_reconnect = True - if wired_ip and wired.CheckPluggedIn(): + elif wired_ip and wired.CheckPluggedIn(): # Only change the interface if it's not already set for wired if not self.still_wired: daemon.SetCurrentInterface(daemon.GetWiredInterface()) @@ -89,14 +98,17 @@ class ConnectionStatus(object): def check_for_wireless_connection(self, wireless_ip): """ Checks for an active wireless connection. - Checks for and updates the tray icon for an active - wireless connection. Returns True if wireless connection - is active, and False otherwise. + Checks for an active wireless connection. Also notes + if the signal strength is 0, and if it remains there + for too long, triggers a wireless disconnect. + + Returns True if wireless connection is active, and + False otherwise. """ # Make sure we have an IP before we do anything else. - if wireless_ip is None: + if not wireless_ip: return False if daemon.NeedsExternalCalls(): @@ -158,6 +170,15 @@ class ConnectionStatus(object): # Check for wired. wired_ip = wired.GetWiredIP("") wired_found = self.check_for_wired_connection(wired_ip) + # Trigger an AutoConnect if we're plugged in, not connected + # to a wired network, and the "autoswitch to wired" option + # is on. + if self.trigger_reconnect: + self.trigger_reconnect = False + wireless.DisconnectWireless() + daemon.AutoConnect(False, reply_handler=lambda:None, + error_handler=lambda:None) + return True if wired_found: self.update_state(misc.WIRED, wired_ip=wired_ip) return True diff --git a/wicd/netentry.py b/wicd/netentry.py index 4474b99..8f36f13 100644 --- a/wicd/netentry.py +++ b/wicd/netentry.py @@ -21,7 +21,7 @@ import os import misc import wpath from misc import noneToString, stringToNone, noneToBlankString, to_bool -from guiutil import error, SmallLabel, LabelEntry, GreyLabel, LeftAlignedLabel +from guiutil import error, SmallLabel, LabelEntry, GreyLabel, LeftAlignedLabel, string_input language = misc.get_language_list_gui() @@ -234,7 +234,7 @@ class WiredSettingsDialog(AdvancedSettingsDialog): def edit_scripts(self, widget=None, event=None): """ Launch the script editting dialog. """ - profile = self.combo_profile_names.get_active_text() + profile = self.prof_name cmdend = [os.path.join(wpath.lib, "configscript.py"), profile, "wired"] if os.getuid() != 0: cmdbase = misc.get_sudo_cmd(language['scripts_need_pass']) @@ -535,10 +535,10 @@ class WiredNetworkEntry(NetworkEntry): """ Load the wired network entry. """ NetworkEntry.__init__(self, dbus_ifaces) # Center the picture and pad it a bit - self.image.set_alignment(.5, 0) + self.image.set_padding(0, 0) + self.image.set_alignment(.5, .5) self.image.set_size_request(60, -1) - #self.image.set_from_icon_name("network-wired", 6) - self.image.set_from_file(wpath.images + "wired.png") + self.image.set_from_file(wpath.images + "wired-gui.svg") self.image.show() self.connect_button.show() @@ -553,11 +553,19 @@ class WiredNetworkEntry(NetworkEntry): self.chkbox_default_profile = gtk.CheckButton(language['default_wired']) # Build the profile list. - self.combo_profile_names = gtk.combo_box_entry_new_text() + self.combo_profile_names = gtk.combo_box_new_text() self.profile_list = wired.GetWiredProfileList() + default_prof = wired.GetDefaultWiredNetwork() if self.profile_list: - for x in self.profile_list: - self.combo_profile_names.append_text(x) + starting_index = 0 + for x, prof in enumerate(self.profile_list): + self.combo_profile_names.append_text(prof) + if default_prof == prof: + starting_index = x + self.combo_profile_names.set_active(starting_index) + else: + print "no wired profiles found" + self.profile_help.show() # Format the profile help label. self.profile_help.set_justify(gtk.JUSTIFY_LEFT) @@ -580,6 +588,11 @@ class WiredNetworkEntry(NetworkEntry): self.chkbox_default_profile.connect("toggled", self.toggle_default_profile) self.combo_profile_names.connect("changed", self.change_profile) + + # Show everything, but hide the profile help label. + self.show_all() + self.profile_help.hide() + self.advanced_dialog = WiredSettingsDialog(self.combo_profile_names.get_active_text()) # Toggle the default profile checkbox to the correct state. if to_bool(wired.GetWiredProperty("default")): @@ -587,25 +600,6 @@ class WiredNetworkEntry(NetworkEntry): else: self.chkbox_default_profile.set_active(False) - # Show everything, but hide the profile help label. - self.show_all() - self.profile_help.hide() - self.advanced_dialog = WiredSettingsDialog(self.combo_profile_names.get_active_text()) - - # Display the default profile if it exists. - if self.profile_list is not None: - prof = wired.GetDefaultWiredNetwork() - if prof != None: # Make sure the default profile gets displayed. - i = 0 - while self.combo_profile_names.get_active_text() != prof: - self.combo_profile_names.set_active(i) - i += 1 - else: - self.combo_profile_names.set_active(0) - print "wired profiles found" - else: - print "no wired profiles found" - self.profile_help.show() self.check_enable() self.wireddis = self.connect("destroy", self.destroy_called) @@ -642,21 +636,32 @@ class WiredNetworkEntry(NetworkEntry): def add_profile(self, widget): """ Add a profile to the profile list. """ print "adding profile" - profile_name = self.combo_profile_names.get_active_text() + + response = string_input("Enter a profile name", "The profile name " + + "will not be used by the computer. It " + + "allows you to " + + "easily distinguish between different network " + + "profiles.", "Profile name:") + + # if response is "" or None + if not response: + return + + profile_name = response profile_list = wired.GetWiredProfileList() if profile_list: if profile_name in profile_list: return False - if profile_name != "": - self.profile_help.hide() - wired.CreateWiredNetworkProfile(profile_name, False) - self.combo_profile_names.prepend_text(profile_name) - self.combo_profile_names.set_active(0) - self.advanced_dialog.prof_name = profile_name - if self.is_full_gui: - self.button_delete.set_sensitive(True) - self.connect_button.set_sensitive(True) - self.advanced_button.set_sensitive(True) + + self.profile_help.hide() + wired.CreateWiredNetworkProfile(profile_name, False) + self.combo_profile_names.prepend_text(profile_name) + self.combo_profile_names.set_active(0) + self.advanced_dialog.prof_name = profile_name + if self.is_full_gui: + self.button_delete.set_sensitive(True) + self.connect_button.set_sensitive(True) + self.advanced_button.set_sensitive(True) def remove_profile(self, widget): """ Remove a profile from the profile list. """ @@ -695,6 +700,7 @@ class WiredNetworkEntry(NetworkEntry): return profile_name = self.combo_profile_names.get_active_text() + self.advanced_dialog.prof_name = profile_name wired.ReadWiredNetworkProfile(profile_name) self.advanced_dialog.txt_ip.set_text(self.format_entry("ip")) @@ -723,7 +729,6 @@ class WirelessNetworkEntry(NetworkEntry): self.image.set_alignment(.5, .5) self.image.set_size_request(60, -1) self.image.show() - #self.image.set_from_icon_name("network-wired", 6) self.essid = noneToBlankString(wireless.GetWirelessProperty(networkID, "essid")) self.lbl_strength = GreyLabel() diff --git a/wicd/networking.py b/wicd/networking.py index dcecce8..e1a99f7 100644 --- a/wicd/networking.py +++ b/wicd/networking.py @@ -741,7 +741,8 @@ class WirelessConnectThread(ConnectThread): self.is_connecting = True # Run pre-connection script. - self.run_script_if_needed(self.before_script, 'pre-connection', self.network['bssid'], self.network['essid']) + self.run_script_if_needed(self.before_script, 'pre-connection', + self.network['bssid'], self.network['essid']) # Take down interface and clean up previous connections. @@ -783,7 +784,8 @@ class WirelessConnectThread(ConnectThread): self.set_dns_addresses() # Run post-connection script. - self.run_script_if_needed(self.after_script, 'post-connection', self.network['bssid'], self.network['essid']) + self.run_script_if_needed(self.after_script, 'post-connection', + self.network['bssid'], self.network['essid']) self.SetStatus('done') print 'Connecting thread exiting.' @@ -947,7 +949,8 @@ class WiredConnectThread(ConnectThread): self.is_connecting = True # Run pre-connection script. - self.run_script_if_needed(self.before_script, 'pre-connection', 'wired', 'wired') + self.run_script_if_needed(self.before_script, 'pre-connection', 'wired', + 'wired') # Take down interface and clean up previous connections. self.put_iface_down(liface) @@ -965,7 +968,8 @@ class WiredConnectThread(ConnectThread): self.set_dns_addresses() # Run post-connection script. - self.run_script_if_needed(self.after_script, 'post-connection', 'wired', 'wired') + self.run_script_if_needed(self.after_script, 'post-connection', 'wired', + 'wired') self.SetStatus('done') print 'Connecting thread exiting.' diff --git a/wicd/prefs.py b/wicd/prefs.py index b5779fb..bff88bb 100644 --- a/wicd/prefs.py +++ b/wicd/prefs.py @@ -58,6 +58,7 @@ class PreferencesDialog(object): self.reconnectcheckbox.set_active(daemon.GetAutoReconnect()) self.debugmodecheckbox.set_active(daemon.GetDebugMode()) self.displaytypecheckbox.set_active(daemon.GetSignalDisplayType()) + self.preferwiredcheckbox.set_active(daemon.GetPreferWiredNetwork()) dhcp_list = [self.dhcpautoradio, self.dhclientradio, self.dhcpcdradio, self.pumpradio] @@ -148,6 +149,7 @@ class PreferencesDialog(object): daemon.SetAutoReconnect(self.reconnectcheckbox.get_active()) daemon.SetDebugMode(self.debugmodecheckbox.get_active()) daemon.SetSignalDisplayType(int(self.displaytypecheckbox.get_active())) + daemon.SetPreferWiredNetwork(bool(self.preferwiredcheckbox.get_active())) if self.showlistradiobutton.get_active(): daemon.SetWiredAutoConnectMethod(2) elif self.lastusedradiobutton.get_active(): @@ -253,6 +255,8 @@ class PreferencesDialog(object): self.wiredcheckbox = setup_label("pref_always_check", 'wired_always_on') + self.preferwiredcheckbox = setup_label("pref_prefer_wired_check", + "prefer_wired") self.reconnectcheckbox = setup_label("pref_auto_check", 'auto_reconnect') diff --git a/wicd/wicd-daemon.py b/wicd/wicd-daemon.py index 53c9ad2..40e80ea 100644 --- a/wicd/wicd-daemon.py +++ b/wicd/wicd-daemon.py @@ -141,28 +141,28 @@ class WicdDaemon(dbus.service.Object): """ Sets the wired interface for the daemon to use. """ print "setting wired interface %s" % (str(interface)) self.wired.wired_interface = noneToBlankString(interface) - self.config.set("Settings", "wired_interface", interface, True) + self.config.set("Settings", "wired_interface", interface, write=True) @dbus.service.method('org.wicd.daemon') def SetWirelessInterface(self, interface): """ Sets the wireless interface the daemon will use. """ print "setting wireless interface %s" % (str(interface)) self.wifi.wireless_interface = noneToBlankString(interface) - self.config.set("Settings", "wireless_interface", interface, True) + self.config.set("Settings", "wireless_interface", interface, write=True) @dbus.service.method('org.wicd.daemon') def SetWPADriver(self, driver): """ Sets the wpa driver the wpa_supplicant will use. """ print "setting wpa driver", str(driver) self.wifi.wpa_driver = driver - self.config.set("Settings", "wpa_driver", driver, True) + self.config.set("Settings", "wpa_driver", driver, write=True) @dbus.service.method('org.wicd.daemon') def SetUseGlobalDNS(self, use): """ Sets a boolean which determines if global DNS is enabled. """ print 'setting use global dns to', use use = misc.to_bool(use) - self.config.set("Settings", "use_global_dns", use, True) + self.config.set("Settings", "use_global_dns", use, write=True) self.use_global_dns = use self.wifi.use_global_dns = use self.wired.use_global_dns = use @@ -197,12 +197,11 @@ class WicdDaemon(dbus.service.Object): print 'search domain is %s' % search_dom self.config.write() - @dbus.service.method('org.wicd.daemon') def SetBackend(self, backend): """ Sets a new backend. """ print "setting backend to %s" % backend - self.config.set("Settings", "backend", backend, True) + self.config.set("Settings", "backend", backend, write=True) if backend != self.GetCurrentBackend(): self.suspended = True self.wifi.LoadBackend(backend) @@ -272,7 +271,7 @@ class WicdDaemon(dbus.service.Object): @dbus.service.method('org.wicd.daemon') def SetDebugMode(self, debug): """ Sets if debugging mode is on or off. """ - self.config.set("Settings", "debug_mode", debug, True) + self.config.set("Settings", "debug_mode", debug, write=True) self.debug_mode = misc.to_bool(debug) self.wifi.debug = self.debug_mode self.wired.debug = self.debug_mode @@ -352,7 +351,8 @@ class WicdDaemon(dbus.service.Object): """ print 'setting automatically reconnect when connection drops %s' % value - self.config.set("Settings", "auto_reconnect", misc.to_bool(value), True) + self.config.set("Settings", "auto_reconnect", misc.to_bool(value), + write=True) self.auto_reconnect = misc.to_bool(value) @dbus.service.method('org.wicd.daemon') @@ -453,7 +453,7 @@ class WicdDaemon(dbus.service.Object): @dbus.service.method('org.wicd.daemon') def SetSignalDisplayType(self, value): """ Sets the signal display type and writes it the wicd config file. """ - self.config.set("Settings", "signal_display_type", value, True) + self.config.set("Settings", "signal_display_type", value, write=True) self.signal_display_type = int(value) @dbus.service.method('org.wicd.daemon') @@ -483,7 +483,7 @@ class WicdDaemon(dbus.service.Object): def SetAlwaysShowWiredInterface(self, value): """ Sets always_show_wired_interface to the given value. """ self.config.set("Settings", "always_show_wired_interface", - misc.to_bool(value), True) + misc.to_bool(value), write=True) self.always_show_wired_interface = misc.to_bool(value) @dbus.service.method('org.wicd.daemon') @@ -497,7 +497,8 @@ class WicdDaemon(dbus.service.Object): # 1 = default profile # 2 = show list # 3 = last used profile - self.config.set("Settings","wired_connect_mode", int(method), True) + self.config.set("Settings","wired_connect_mode", int(method), + write=True) self.wired_connect_mode = int(method) self.wired_bus.connect_mode = int(method) @@ -505,9 +506,8 @@ class WicdDaemon(dbus.service.Object): def GetWiredAutoConnectMethod(self): """ Returns the wired autoconnect method. """ return int(self.wired_connect_mode) - - - @dbus.service.method('org.wicd.dameon') + + @dbus.service.method('org.wicd.daemon') def GetPreferWiredNetwork(self): """ Returns True if wired network preference is set. @@ -520,6 +520,7 @@ class WicdDaemon(dbus.service.Object): @dbus.service.method('org.wicd.daemon') def SetPreferWiredNetwork(self, value): """ Sets the prefer_wired state. """ + self.config.set("Settings", "prefer_wired", bool(value), write=True) self.prefer_wired = bool(value) @dbus.service.method('org.wicd.daemon') @@ -589,7 +590,7 @@ class WicdDaemon(dbus.service.Object): self.dhcp_client = int(client) self.wifi.dhcp_client = int(client) self.wired.dhcp_client = int(client) - self.config.set("Settings", "dhcp_client", client, True) + self.config.set("Settings", "dhcp_client", client, write=True) @dbus.service.method('org.wicd.daemon') def GetLinkDetectionTool(self): @@ -609,7 +610,7 @@ class WicdDaemon(dbus.service.Object): """ self.link_detect_tool = int(link_tool) self.wired.link_tool = int(link_tool) - self.config.set("Settings", "link_detect_tool", link_tool, True) + self.config.set("Settings", "link_detect_tool", link_tool, write=True) @dbus.service.method('org.wicd.daemon') def GetFlushTool(self): @@ -628,7 +629,7 @@ class WicdDaemon(dbus.service.Object): self.flush_tool = int(flush_tool) self.wired.flush_tool = int(flush_tool) self.wifi.flush_tool = int(flush_tool) - self.config.set("Settings", "flush_tool", flush_tool, True) + self.config.set("Settings", "flush_tool", flush_tool, write=True) @dbus.service.method('org.wicd.daemon') def WriteWindowSize(self, width, height, win_name): @@ -1018,6 +1019,7 @@ class WirelessDaemon(dbus.service.Object): """ Disconnects the wireless network. """ self.SetForcedDisconnect(True) self.wifi.Disconnect() + self.daemon.UpdateState() @dbus.service.method('org.wicd.daemon.wireless') def GetForcedDisconnect(self): @@ -1100,6 +1102,7 @@ class WirelessDaemon(dbus.service.Object): 'disconnectscript') print 'Connecting to wireless network ' + self.LastScan[id]['essid'] conthread = self.wifi.Connect(self.LastScan[id], debug=self.debug_mode) + self.daemon.UpdateState() @dbus.service.method('org.wicd.daemon.wireless') def CheckIfWirelessConnecting(self): @@ -1354,6 +1357,7 @@ class WiredDaemon(dbus.service.Object): """ Disconnects the wired network. """ self.SetForcedDisconnect(True) self.wired.Disconnect() + self.daemon.UpdateState() @dbus.service.method('org.wicd.daemon.wired') def CheckPluggedIn(self): @@ -1402,6 +1406,7 @@ class WiredDaemon(dbus.service.Object): self.wired.after_script = self.GetWiredProperty("afterscript") self.wired.disconnect_script = self.GetWiredProperty("disconnectscript") self.wired.Connect(self.WiredNetwork, debug=self.debug_mode) + self.daemon.UpdateState() @dbus.service.method('org.wicd.daemon.wired') def CreateWiredNetworkProfile(self, profilename, default=False): @@ -1474,6 +1479,7 @@ class WiredDaemon(dbus.service.Object): self.config.set(prof, script, None) if profilename == "": + self.config.write() return "500: Bad Profile name" profilename = misc.to_unicode(profilename) self.config.remove_section(profilename)