mirror of
https://github.com/gryf/wicd.git
synced 2026-02-19 00:15:47 +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.
|
# Build the profile list.
|
||||||
self.combo_profile_names = gtk.combo_box_new_text()
|
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.
|
# Format the profile help label.
|
||||||
self.profile_help.set_justify(gtk.JUSTIFY_LEFT)
|
self.profile_help.set_justify(gtk.JUSTIFY_LEFT)
|
||||||
@@ -588,6 +576,20 @@ class WiredNetworkEntry(NetworkEntry):
|
|||||||
self.chkbox_default_profile.connect("toggled",
|
self.chkbox_default_profile.connect("toggled",
|
||||||
self.toggle_default_profile)
|
self.toggle_default_profile)
|
||||||
self.combo_profile_names.connect("changed", self.change_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.
|
# Show everything, but hide the profile help label.
|
||||||
self.show_all()
|
self.show_all()
|
||||||
@@ -700,17 +702,11 @@ class WiredNetworkEntry(NetworkEntry):
|
|||||||
return
|
return
|
||||||
|
|
||||||
profile_name = self.combo_profile_names.get_active_text()
|
profile_name = self.combo_profile_names.get_active_text()
|
||||||
self.advanced_dialog.prof_name = profile_name
|
|
||||||
wired.ReadWiredNetworkProfile(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.prof_name = profile_name
|
||||||
|
self.advanced_dialog.set_values()
|
||||||
|
|
||||||
is_default = wired.GetWiredProperty("default")
|
is_default = wired.GetWiredProperty("default")
|
||||||
self.chkbox_default_profile.set_active(to_bool(is_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):
|
if self.config.has_section(profilename):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for option in ["ip", "broadcast", "netmask","gateway", "dns1", "dns2",
|
for option in ["ip", "broadcast", "netmask","gateway", "search_domain",
|
||||||
"dns3", "beforescript", "afterscript", "disconnectscript"]:
|
"dns_domain", "dns1", "dns2", "dns3", "beforescript",
|
||||||
|
"afterscript", "disconnectscript"]:
|
||||||
self.config.set(profilename, option, None)
|
self.config.set(profilename, option, None)
|
||||||
self.config.set(profilename, "default", default)
|
self.config.set(profilename, "default", default)
|
||||||
self.config.write()
|
self.config.write()
|
||||||
@@ -1428,29 +1429,24 @@ class WiredDaemon(dbus.service.Object):
|
|||||||
""" Finds the previous lastused network, and sets lastused to False. """
|
""" Finds the previous lastused network, and sets lastused to False. """
|
||||||
profileList = self.config.sections()
|
profileList = self.config.sections()
|
||||||
for profile in profileList:
|
for profile in profileList:
|
||||||
if self.config.has_option(profile, "lastused"):
|
if misc.to_bool(self.config.get(profile, "lastused")):
|
||||||
if misc.to_bool(self.config.get(profile, "lastused")):
|
self.config.set(profile, "lastused", False, write=True)
|
||||||
self.config.set(profile, "lastused", False)
|
|
||||||
self.SaveWiredNetworkProfile(profile)
|
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wired')
|
@dbus.service.method('org.wicd.daemon.wired')
|
||||||
def UnsetWiredDefault(self):
|
def UnsetWiredDefault(self):
|
||||||
""" Unsets the default option in the current default wired profile. """
|
""" Unsets the default option in the current default wired profile. """
|
||||||
profileList = self.config.sections()
|
profileList = self.config.sections()
|
||||||
for profile in profileList:
|
for profile in profileList:
|
||||||
if self.config.has_option(profile, "default"):
|
if misc.to_bool(self.config.get(profile, "default")):
|
||||||
if misc.to_bool(self.config.get(profile, "default")):
|
self.config.set(profile, "default", False, write=True)
|
||||||
self.config.set(profile, "default", False)
|
|
||||||
self.SaveWiredNetworkProfile(profile)
|
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wired')
|
@dbus.service.method('org.wicd.daemon.wired')
|
||||||
def GetDefaultWiredNetwork(self):
|
def GetDefaultWiredNetwork(self):
|
||||||
""" Returns the current default wired network. """
|
""" Returns the current default wired network. """
|
||||||
profileList = self.config.sections()
|
profileList = self.config.sections()
|
||||||
for profile in profileList:
|
for profile in profileList:
|
||||||
if self.config.has_option(profile, "default"):
|
if misc.to_bool(self.config.get(profile, "default")):
|
||||||
if misc.to_bool(self.config.get(profile, "default")):
|
return profile
|
||||||
return profile
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wired')
|
@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. """
|
""" Returns the profile of the last used wired network. """
|
||||||
profileList = self.config.sections()
|
profileList = self.config.sections()
|
||||||
for profile in profileList:
|
for profile in profileList:
|
||||||
if self.config.has_option(profile, "lastused"):
|
if misc.to_bool(self.config.get(profile, "lastused")):
|
||||||
if misc.to_bool(self.config.get(profile, "lastused")):
|
return profile
|
||||||
return profile
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wired')
|
@dbus.service.method('org.wicd.daemon.wired')
|
||||||
@@ -1481,6 +1476,8 @@ class WiredDaemon(dbus.service.Object):
|
|||||||
if profilename == "":
|
if profilename == "":
|
||||||
self.config.write()
|
self.config.write()
|
||||||
return "500: Bad Profile name"
|
return "500: Bad Profile name"
|
||||||
|
if self.debug_mode:
|
||||||
|
print "saving wired profile %s" % profilename
|
||||||
profilename = misc.to_unicode(profilename)
|
profilename = misc.to_unicode(profilename)
|
||||||
self.config.remove_section(profilename)
|
self.config.remove_section(profilename)
|
||||||
self.config.add_section(profilename)
|
self.config.add_section(profilename)
|
||||||
@@ -1499,6 +1496,8 @@ class WiredDaemon(dbus.service.Object):
|
|||||||
profile = {}
|
profile = {}
|
||||||
profilename = misc.to_unicode(profilename)
|
profilename = misc.to_unicode(profilename)
|
||||||
if self.config.has_section(profilename):
|
if self.config.has_section(profilename):
|
||||||
|
if self.debug_mode:
|
||||||
|
print "Reading wired profile %s" % profilename
|
||||||
for x in self.config.options(profilename):
|
for x in self.config.options(profilename):
|
||||||
profile[x] = misc.Noneify(self.config.get(profilename, x))
|
profile[x] = misc.Noneify(self.config.get(profilename, x))
|
||||||
profile['use_global_dns'] = bool(profile.get('use_global_dns'))
|
profile['use_global_dns'] = bool(profile.get('use_global_dns'))
|
||||||
|
|||||||
Reference in New Issue
Block a user