From 6e4d70c4ea918b052ffc777f0b44e86b851a25b0 Mon Sep 17 00:00:00 2001 From: Dan O'Reilly Date: Sat, 13 Dec 2008 13:28:05 -0500 Subject: [PATCH] Fix saving scripts not working correctly. --- init/slackware/rc.wicd | 9 --------- wicd/configmanager.py | 3 +++ wicd/configscript.py | 3 +++ wicd/wicd-daemon.py | 19 +++++++++++++++---- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/init/slackware/rc.wicd b/init/slackware/rc.wicd index 343051e..aef7d58 100755 --- a/init/slackware/rc.wicd +++ b/init/slackware/rc.wicd @@ -17,10 +17,6 @@ wicd_start() { else echo "Starting wicd daemon..." wicd 2>/dev/null 1>&2 - # Activate the pm-utils sleep hook - if [ ! -x /usr/lib/pm-utils/sleep.d/55wicd ]; then - chmod +x /usr/lib/pm-utils/sleep.d/55wicd - fi fi } @@ -32,11 +28,6 @@ wicd_stop() { else pkill -f python.*wicd-daemon.py 2>/dev/null fi - # Deactivate the pm-utils sleep hook - if [ -x /usr/lib/pm-utils/sleep.d/55wicd ]; then - chmod -x /usr/lib/pm-utils/sleep.d/55wicd - fi - } # See how we were called and take appropriate action diff --git a/wicd/configmanager.py b/wicd/configmanager.py index d688506..4b2844a 100644 --- a/wicd/configmanager.py +++ b/wicd/configmanager.py @@ -113,3 +113,6 @@ class ConfigManager(ConfigParser): """ if self.has_section(section): ConfigParser.remove_section(self, section) + + def reload(self): + self.read(self.config_file) diff --git a/wicd/configscript.py b/wicd/configscript.py index 43845e1..9e1a7c5 100755 --- a/wicd/configscript.py +++ b/wicd/configscript.py @@ -122,6 +122,7 @@ def write_scripts(network, network_type, script_info): con.set(network, "afterscript", script_info["post_entry"]) con.set(network, "disconnectscript", script_info["disconnect_entry"]) con.write(open(wired_conf, "w")) + wired.ReloadConfig() wired.ReadWiredNetworkProfile(network) wired.SaveWiredNetworkProfile(network) else: @@ -133,9 +134,11 @@ def write_scripts(network, network_type, script_info): con.set(bssid, "afterscript", script_info["post_entry"]) con.set(bssid, "disconnectscript", script_info["disconnect_entry"]) con.write(open(wireless_conf, "w")) + wireless.ReloadConfig() wireless.ReadWirelessNetworkProfile(int(network)) wireless.SaveWirelessNetworkProfile(int(network)) + def main (argv): """ Runs the script configuration dialog. """ if len(argv) < 2: diff --git a/wicd/wicd-daemon.py b/wicd/wicd-daemon.py index d40ee8a..87b6ab3 100644 --- a/wicd/wicd-daemon.py +++ b/wicd/wicd-daemon.py @@ -1066,7 +1066,8 @@ class WirelessDaemon(dbus.service.Object): def SaveWirelessNetworkProfile(self, id): """ Writes a wireless profile to disk. """ def write_script_ent(prof, script): - self.config.set(prof, script, None) + if not self.config.has_option(prof, script): + self.config.set(prof, script, None) cur_network = self.LastScan[id] bssid_key = cur_network["bssid"] @@ -1088,12 +1089,12 @@ class WirelessDaemon(dbus.service.Object): write_script_ent(bssid_key, "beforescript") write_script_ent(bssid_key, "afterscript") - write_script_ent(bssid_key, "disconnect") + write_script_ent(bssid_key, "disconnectscript") if cur_network["use_settings_globally"]: write_script_ent(essid_key, "beforescript") write_script_ent(essid_key, "afterscript") - write_script_ent(essid_key, "disconnect") + write_script_ent(essid_key, "disconnectscript") self.config.write() @@ -1120,7 +1121,12 @@ class WirelessDaemon(dbus.service.Object): """ Removes the global entry for the networkid provided. """ essid_key = "essid:" + str(self.LastScan[networkid]) self.config.remove_section(essid_key) - + + @dbus.service.method('org.wicd.daemon.wireless') + def ReloadConfig(self): + """ Reloads the active config file. """ + self.config.reload() + @dbus.service.signal(dbus_interface='org.wicd.daemon.wireless', signature='') def SendStartScanSignal(self): """ Emits a signal announcing a scan has started. """ @@ -1395,6 +1401,11 @@ class WiredDaemon(dbus.service.Object): if not sections: sections = [""] return sections + + @dbus.service.method('org.wicd.daemon.wired') + def ReloadConfig(self): + """ Reloads the active config file. """ + self.config.reload() def usage():