mirror of
https://github.com/gryf/wicd.git
synced 2026-01-06 22:04:19 +01:00
Fix issue where toggling default wired profile could cause settings to get set for multiple profiles.
Remove some no longer needed checks in the daemon.
This commit is contained in:
@@ -554,18 +554,6 @@ class WiredNetworkEntry(NetworkEntry):
|
||||
|
||||
# Build the profile list.
|
||||
self.combo_profile_names = gtk.combo_box_new_text()
|
||||
self.profile_list = wired.GetWiredProfileList()
|
||||
default_prof = wired.GetDefaultWiredNetwork()
|
||||
if self.profile_list:
|
||||
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)
|
||||
@@ -588,6 +576,20 @@ class WiredNetworkEntry(NetworkEntry):
|
||||
self.chkbox_default_profile.connect("toggled",
|
||||
self.toggle_default_profile)
|
||||
self.combo_profile_names.connect("changed", self.change_profile)
|
||||
|
||||
# Build profile list.
|
||||
self.profile_list = wired.GetWiredProfileList()
|
||||
default_prof = wired.GetDefaultWiredNetwork()
|
||||
if self.profile_list:
|
||||
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()
|
||||
|
||||
# Show everything, but hide the profile help label.
|
||||
self.show_all()
|
||||
@@ -700,17 +702,11 @@ 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"))
|
||||
self.advanced_dialog.txt_netmask.set_text(self.format_entry("netmask"))
|
||||
self.advanced_dialog.txt_gateway.set_text(self.format_entry("gateway"))
|
||||
self.advanced_dialog.txt_dns_1.set_text(self.format_entry("dns1"))
|
||||
self.advanced_dialog.txt_dns_2.set_text(self.format_entry("dns2"))
|
||||
self.advanced_dialog.txt_dns_3.set_text(self.format_entry("dns3"))
|
||||
self.advanced_dialog.prof_name = profile_name
|
||||
|
||||
self.advanced_dialog.set_values()
|
||||
|
||||
is_default = wired.GetWiredProperty("default")
|
||||
self.chkbox_default_profile.set_active(to_bool(is_default))
|
||||
|
||||
|
||||
@@ -1416,8 +1416,9 @@ class WiredDaemon(dbus.service.Object):
|
||||
if self.config.has_section(profilename):
|
||||
return False
|
||||
|
||||
for option in ["ip", "broadcast", "netmask","gateway", "dns1", "dns2",
|
||||
"dns3", "beforescript", "afterscript", "disconnectscript"]:
|
||||
for option in ["ip", "broadcast", "netmask","gateway", "search_domain",
|
||||
"dns_domain", "dns1", "dns2", "dns3", "beforescript",
|
||||
"afterscript", "disconnectscript"]:
|
||||
self.config.set(profilename, option, None)
|
||||
self.config.set(profilename, "default", default)
|
||||
self.config.write()
|
||||
@@ -1428,29 +1429,24 @@ class WiredDaemon(dbus.service.Object):
|
||||
""" Finds the previous lastused network, and sets lastused to False. """
|
||||
profileList = self.config.sections()
|
||||
for profile in profileList:
|
||||
if self.config.has_option(profile, "lastused"):
|
||||
if misc.to_bool(self.config.get(profile, "lastused")):
|
||||
self.config.set(profile, "lastused", False)
|
||||
self.SaveWiredNetworkProfile(profile)
|
||||
if misc.to_bool(self.config.get(profile, "lastused")):
|
||||
self.config.set(profile, "lastused", False, write=True)
|
||||
|
||||
@dbus.service.method('org.wicd.daemon.wired')
|
||||
def UnsetWiredDefault(self):
|
||||
""" Unsets the default option in the current default wired profile. """
|
||||
profileList = self.config.sections()
|
||||
for profile in profileList:
|
||||
if self.config.has_option(profile, "default"):
|
||||
if misc.to_bool(self.config.get(profile, "default")):
|
||||
self.config.set(profile, "default", False)
|
||||
self.SaveWiredNetworkProfile(profile)
|
||||
if misc.to_bool(self.config.get(profile, "default")):
|
||||
self.config.set(profile, "default", False, write=True)
|
||||
|
||||
@dbus.service.method('org.wicd.daemon.wired')
|
||||
def GetDefaultWiredNetwork(self):
|
||||
""" Returns the current default wired network. """
|
||||
profileList = self.config.sections()
|
||||
for profile in profileList:
|
||||
if self.config.has_option(profile, "default"):
|
||||
if misc.to_bool(self.config.get(profile, "default")):
|
||||
return profile
|
||||
if misc.to_bool(self.config.get(profile, "default")):
|
||||
return profile
|
||||
return None
|
||||
|
||||
@dbus.service.method('org.wicd.daemon.wired')
|
||||
@@ -1458,9 +1454,8 @@ class WiredDaemon(dbus.service.Object):
|
||||
""" Returns the profile of the last used wired network. """
|
||||
profileList = self.config.sections()
|
||||
for profile in profileList:
|
||||
if self.config.has_option(profile, "lastused"):
|
||||
if misc.to_bool(self.config.get(profile, "lastused")):
|
||||
return profile
|
||||
if misc.to_bool(self.config.get(profile, "lastused")):
|
||||
return profile
|
||||
return None
|
||||
|
||||
@dbus.service.method('org.wicd.daemon.wired')
|
||||
@@ -1481,6 +1476,8 @@ class WiredDaemon(dbus.service.Object):
|
||||
if profilename == "":
|
||||
self.config.write()
|
||||
return "500: Bad Profile name"
|
||||
if self.debug_mode:
|
||||
print "saving wired profile %s" % profilename
|
||||
profilename = misc.to_unicode(profilename)
|
||||
self.config.remove_section(profilename)
|
||||
self.config.add_section(profilename)
|
||||
@@ -1499,6 +1496,8 @@ class WiredDaemon(dbus.service.Object):
|
||||
profile = {}
|
||||
profilename = misc.to_unicode(profilename)
|
||||
if self.config.has_section(profilename):
|
||||
if self.debug_mode:
|
||||
print "Reading wired profile %s" % profilename
|
||||
for x in self.config.options(profilename):
|
||||
profile[x] = misc.Noneify(self.config.get(profilename, x))
|
||||
profile['use_global_dns'] = bool(profile.get('use_global_dns'))
|
||||
|
||||
Reference in New Issue
Block a user