mirror of
https://github.com/gryf/wicd.git
synced 2025-12-23 06:37:59 +01:00
branches/experimental:
- Fix some wired method issues in the daemon. - Make sure stringToBoolean always returns a boolean.
This commit is contained in:
@@ -504,7 +504,7 @@ def stringToBoolean(text):
|
|||||||
return True
|
return True
|
||||||
if text in ("False", "0"):
|
if text in ("False", "0"):
|
||||||
return False
|
return False
|
||||||
return text
|
return bool(text)
|
||||||
|
|
||||||
def checkboxTextboxToggle(checkbox, textboxes):
|
def checkboxTextboxToggle(checkbox, textboxes):
|
||||||
for textbox in textboxes:
|
for textbox in textboxes:
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ class WiredSettingsDialog(AdvancedSettingsDialog):
|
|||||||
self.txt_dns_2.set_text(self.format_entry("dns2"))
|
self.txt_dns_2.set_text(self.format_entry("dns2"))
|
||||||
self.txt_dns_3.set_text(self.format_entry("dns3"))
|
self.txt_dns_3.set_text(self.format_entry("dns3"))
|
||||||
self.txt_search_dom.set_text(self.format_entry("search_domain"))
|
self.txt_search_dom.set_text(self.format_entry("search_domain"))
|
||||||
self.chkbox_global_dns.set_active(bool(wired.GetWiredPropery("use_global_dns")))
|
self.chkbox_global_dns.set_active(bool(wired.GetWiredProperty("use_global_dns")))
|
||||||
self.reset_static_checkboxes()
|
self.reset_static_checkboxes()
|
||||||
|
|
||||||
def format_entry(self, label):
|
def format_entry(self, label):
|
||||||
@@ -678,7 +678,7 @@ class WiredNetworkEntry(NetworkEntry):
|
|||||||
return False
|
return False
|
||||||
if profile_name != "":
|
if profile_name != "":
|
||||||
self.profile_help.hide()
|
self.profile_help.hide()
|
||||||
wired.CreateWiredNetworkProfile(profile_name)
|
wired.CreateWiredNetworkProfile(profile_name, False)
|
||||||
self.combo_profile_names.prepend_text(profile_name)
|
self.combo_profile_names.prepend_text(profile_name)
|
||||||
self.combo_profile_names.set_active(0)
|
self.combo_profile_names.set_active(0)
|
||||||
self.advanced_dialog.prof_name = profile_name
|
self.advanced_dialog.prof_name = profile_name
|
||||||
|
|||||||
@@ -130,11 +130,12 @@ class PreferencesDialog(object):
|
|||||||
flush_method = daemon.GetFlushTool()
|
flush_method = daemon.GetFlushTool()
|
||||||
flush_list[flush_method].set_active(True)
|
flush_list[flush_method].set_active(True)
|
||||||
|
|
||||||
if wired.GetWiredAutoConnectMethod() == 1:
|
auto_conn_meth = daemon.GetWiredAutoConnectMethod()
|
||||||
|
if auto_conn_meth == 1:
|
||||||
self.usedefaultradiobutton.set_active(True)
|
self.usedefaultradiobutton.set_active(True)
|
||||||
elif wired.GetWiredAutoConnectMethod() == 2:
|
elif auto_conn_meth == 2:
|
||||||
self.showlistradiobutton.set_active(True)
|
self.showlistradiobutton.set_active(True)
|
||||||
elif wired.GetWiredAutoConnectMethod() == 3:
|
elif auto_conn_meth == 3:
|
||||||
self.lastusedradiobutton.set_active(True)
|
self.lastusedradiobutton.set_active(True)
|
||||||
|
|
||||||
self.entryWirelessInterface = self.wTree.get_widget("pref_wifi_entry")
|
self.entryWirelessInterface = self.wTree.get_widget("pref_wifi_entry")
|
||||||
@@ -231,11 +232,11 @@ class PreferencesDialog(object):
|
|||||||
daemon.SetDebugMode(self.debugmodecheckbox.get_active())
|
daemon.SetDebugMode(self.debugmodecheckbox.get_active())
|
||||||
daemon.SetSignalDisplayType(self.displaytypecheckbox.get_active())
|
daemon.SetSignalDisplayType(self.displaytypecheckbox.get_active())
|
||||||
if self.showlistradiobutton.get_active():
|
if self.showlistradiobutton.get_active():
|
||||||
wired.SetWiredAutoConnectMethod(2)
|
daemon.SetWiredAutoConnectMethod(2)
|
||||||
elif self.lastusedradiobutton.get_active():
|
elif self.lastusedradiobutton.get_active():
|
||||||
wired.SetWiredAutoConnectMethod(3)
|
daemon.SetWiredAutoConnectMethod(3)
|
||||||
else:
|
else:
|
||||||
wired.SetWiredAutoConnectMethod(1)
|
daemon.SetWiredAutoConnectMethod(1)
|
||||||
|
|
||||||
if self.backends[self.backendcombo.get_active()] != daemon.GetSavedBackend():
|
if self.backends[self.backendcombo.get_active()] != daemon.GetSavedBackend():
|
||||||
alert(self.dialog, language["backend_alert"])
|
alert(self.dialog, language["backend_alert"])
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ class WicdDaemon(dbus.service.Object):
|
|||||||
object_path=object_path)
|
object_path=object_path)
|
||||||
self.wifi = networking.Wireless()
|
self.wifi = networking.Wireless()
|
||||||
self.wired = networking.Wired()
|
self.wired = networking.Wired()
|
||||||
self.config = ConfigManager(wpath.etc + "manager-settings.conf")
|
self.config = ConfigManager(os.path.join(wpath.etc,
|
||||||
|
"manager-settings.conf"))
|
||||||
self.wired_bus= WiredDaemon(bus_name, wired=self.wired, wifi=self.wifi)
|
self.wired_bus= WiredDaemon(bus_name, wired=self.wired, wifi=self.wifi)
|
||||||
self.wireless_bus = WirelessDaemon(bus_name, wired=self.wired,
|
self.wireless_bus = WirelessDaemon(bus_name, wired=self.wired,
|
||||||
wifi=self.wifi)
|
wifi=self.wifi)
|
||||||
@@ -98,9 +99,6 @@ class WicdDaemon(dbus.service.Object):
|
|||||||
# can be done by calling Scan(fresh=True).
|
# can be done by calling Scan(fresh=True).
|
||||||
self.LastScan = ''
|
self.LastScan = ''
|
||||||
|
|
||||||
# Make a variable that will hold the wired network profile
|
|
||||||
self.WiredNetwork = {}
|
|
||||||
|
|
||||||
# Kind of hackish way to set correct wnettools interfaces.
|
# Kind of hackish way to set correct wnettools interfaces.
|
||||||
self.wifi.liface = self.wired.liface
|
self.wifi.liface = self.wired.liface
|
||||||
self.wired.wiface = self.wifi.wiface
|
self.wired.wiface = self.wifi.wiface
|
||||||
@@ -448,6 +446,21 @@ class WicdDaemon(dbus.service.Object):
|
|||||||
def GetAlwaysShowWiredInterface(self):
|
def GetAlwaysShowWiredInterface(self):
|
||||||
""" Returns always_show_wired_interface """
|
""" Returns always_show_wired_interface """
|
||||||
return bool(self.always_show_wired_interface)
|
return bool(self.always_show_wired_interface)
|
||||||
|
|
||||||
|
@dbus.service.method('org.wicd.daemon')
|
||||||
|
def SetWiredAutoConnectMethod(self, method):
|
||||||
|
""" Sets which method to use to autoconnect to wired networks. """
|
||||||
|
# 1 = default profile
|
||||||
|
# 2 = show list
|
||||||
|
# 3 = last used profile
|
||||||
|
self.config.set("Settings","wired_connect_mode", int(method), True)
|
||||||
|
self.wired_connect_mode = int(method)
|
||||||
|
self.wired_bus.connect_mode = int(method)
|
||||||
|
|
||||||
|
@dbus.service.method('org.wicd.daemon')
|
||||||
|
def GetWiredAutoConnectMethod(self):
|
||||||
|
""" Returns the wired autoconnect method. """
|
||||||
|
return int(self.wired_connect_mode)
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon')
|
@dbus.service.method('org.wicd.daemon')
|
||||||
def SetConnectionStatus(self, state, info):
|
def SetConnectionStatus(self, state, info):
|
||||||
@@ -568,19 +581,19 @@ class WicdDaemon(dbus.service.Object):
|
|||||||
def _wired_autoconnect(self):
|
def _wired_autoconnect(self):
|
||||||
""" Attempts to autoconnect to a wired network. """
|
""" Attempts to autoconnect to a wired network. """
|
||||||
wiredb = self.wired_bus
|
wiredb = self.wired_bus
|
||||||
if wiredb.GetWiredAutoConnectMethod() == 3 and \
|
if self.GetWiredAutoConnectMethod() == 3 and \
|
||||||
not self.GetNeedWiredProfileChooser():
|
not self.GetNeedWiredProfileChooser():
|
||||||
# attempt to smartly connect to a wired network
|
# attempt to smartly connect to a wired network
|
||||||
# by using various wireless networks detected
|
# by using various wireless networks detected
|
||||||
# and by using plugged in USB devices
|
# and by using plugged in USB devices
|
||||||
print self.LastScan
|
print self.LastScan
|
||||||
if wiredb.GetWiredAutoConnectMethod() == 2 and \
|
if self.GetWiredAutoConnectMethod() == 2 and \
|
||||||
not self.GetNeedWiredProfileChooser():
|
not self.GetNeedWiredProfileChooser():
|
||||||
self.LaunchChooser()
|
self.LaunchChooser()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# Default Profile.
|
# Default Profile.
|
||||||
elif wiredb.GetWiredAutoConnectMethod() == 1:
|
elif self.GetWiredAutoConnectMethod() == 1:
|
||||||
network = wiredb.GetDefaultWiredNetwork()
|
network = wiredb.GetDefaultWiredNetwork()
|
||||||
if not network:
|
if not network:
|
||||||
print "Couldn't find a default wired connection," + \
|
print "Couldn't find a default wired connection," + \
|
||||||
@@ -685,7 +698,7 @@ class WicdDaemon(dbus.service.Object):
|
|||||||
self.SetAutoReconnect(app_conf.get("Settings", "auto_reconnect",
|
self.SetAutoReconnect(app_conf.get("Settings", "auto_reconnect",
|
||||||
default=True))
|
default=True))
|
||||||
self.SetDebugMode(app_conf.get("Settings", "debug_mode", default=False))
|
self.SetDebugMode(app_conf.get("Settings", "debug_mode", default=False))
|
||||||
b_wired.SetWiredAutoConnectMethod(app_conf.get("Settings",
|
self.SetWiredAutoConnectMethod(app_conf.get("Settings",
|
||||||
"wired_connect_mode",
|
"wired_connect_mode",
|
||||||
default=1))
|
default=1))
|
||||||
self.SetSignalDisplayType(app_conf.get("Settings",
|
self.SetSignalDisplayType(app_conf.get("Settings",
|
||||||
@@ -739,7 +752,8 @@ class WirelessDaemon(dbus.service.Object):
|
|||||||
self.wifi = wifi
|
self.wifi = wifi
|
||||||
self.debug_mode = debug
|
self.debug_mode = debug
|
||||||
self.forced_disconnect = False
|
self.forced_disconnect = False
|
||||||
self.config = ConfigManager(wpath.etc + "wireless-settings.conf")
|
self.config = ConfigManager(os.path.join(wpath.etc,
|
||||||
|
"wireless-settings.conf"))
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
@dbus.service.method('org.wicd.daemon.wireless')
|
||||||
def SetHiddenNetworkESSID(self, essid):
|
def SetHiddenNetworkESSID(self, essid):
|
||||||
@@ -797,7 +811,10 @@ class WirelessDaemon(dbus.service.Object):
|
|||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
@dbus.service.method('org.wicd.daemon.wireless')
|
||||||
def GetWirelessProperty(self, networkid, property):
|
def GetWirelessProperty(self, networkid, property):
|
||||||
""" Retrieves wireless property from the network specified """
|
""" Retrieves wireless property from the network specified """
|
||||||
value = self.LastScan[networkid].get(property)
|
try:
|
||||||
|
value = self.LastScan[networkid].get(property)
|
||||||
|
except IndexError:
|
||||||
|
return ""
|
||||||
try:
|
try:
|
||||||
value = misc.to_unicode(value)
|
value = misc.to_unicode(value)
|
||||||
except:
|
except:
|
||||||
@@ -1070,7 +1087,9 @@ class WiredDaemon(dbus.service.Object):
|
|||||||
self.wifi = wifi
|
self.wifi = wifi
|
||||||
self.debug_mode = debug
|
self.debug_mode = debug
|
||||||
self.forced_disconnect = False
|
self.forced_disconnect = False
|
||||||
self.config = ConfigManager(wpath.etc + "wired-settings")
|
self.WiredNetwork = {}
|
||||||
|
self.config = ConfigManager(os.path.join(wpath.etc,
|
||||||
|
"wired-settings.conf"))
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wired')
|
@dbus.service.method('org.wicd.daemon.wired')
|
||||||
def GetWiredIP(self, ifconfig=""):
|
def GetWiredIP(self, ifconfig=""):
|
||||||
@@ -1086,20 +1105,6 @@ class WiredDaemon(dbus.service.Object):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wired')
|
|
||||||
def SetWiredAutoConnectMethod(self, method):
|
|
||||||
""" Sets which method to use to autoconnect to wired networks. """
|
|
||||||
# 1 = default profile
|
|
||||||
# 2 = show list
|
|
||||||
# 3 = last used profile
|
|
||||||
self.config.set("Settings","wired_connect_mode", int(method), True)
|
|
||||||
self.wired_connect_mode = int(method)
|
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wired')
|
|
||||||
def GetWiredAutoConnectMethod(self):
|
|
||||||
""" Returns the wired autoconnect method. """
|
|
||||||
return int(self.wired_connect_mode)
|
|
||||||
|
|
||||||
@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. """
|
||||||
@@ -1302,13 +1307,16 @@ class WiredDaemon(dbus.service.Object):
|
|||||||
self.WiredNetwork = profile
|
self.WiredNetwork = profile
|
||||||
return "100: Loaded Profile"
|
return "100: Loaded Profile"
|
||||||
else:
|
else:
|
||||||
self.WiredNetwork = None
|
self.WiredNetwork = {}
|
||||||
return "500: Profile Not Found"
|
return "500: Profile Not Found"
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wired')
|
@dbus.service.method('org.wicd.daemon.wired')
|
||||||
def GetWiredProfileList(self):
|
def GetWiredProfileList(self):
|
||||||
""" Returns a list of all wired profiles in wired-settings.conf. """
|
""" Returns a list of all wired profiles in wired-settings.conf. """
|
||||||
return self.config.sections()
|
sections = self.config.sections()
|
||||||
|
if not sections:
|
||||||
|
sections = [""]
|
||||||
|
return sections
|
||||||
|
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
|
|||||||
Reference in New Issue
Block a user