mirror of
https://github.com/gryf/wicd.git
synced 2025-12-19 20:38:00 +01:00
Improved GUI opening performance so there is less delay between clicking the icon and the gui actually appearing.
Made network entry list inactive while refreshing networks. Made debugging output less spammy and more helpful (still incomplete).
This commit is contained in:
110
daemon.py
110
daemon.py
@@ -608,11 +608,13 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
set with SetHiddenNetworkESSID.
|
set with SetHiddenNetworkESSID.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
print 'scanning start'
|
if self.debug_mode:
|
||||||
|
print 'scanning start'
|
||||||
scan = self.wifi.Scan(str(self.hidden_essid))
|
scan = self.wifi.Scan(str(self.hidden_essid))
|
||||||
self.LastScan = scan
|
self.LastScan = scan
|
||||||
print 'scanning done'
|
if self.debug_mode:
|
||||||
print 'found', str(len(scan)), 'networks:',
|
print 'scanning done'
|
||||||
|
print 'found' + str(len(scan)) + 'networks:'
|
||||||
for i, network in enumerate(scan):
|
for i, network in enumerate(scan):
|
||||||
self.ReadWirelessNetworkProfile(i)
|
self.ReadWirelessNetworkProfile(i)
|
||||||
|
|
||||||
@@ -624,8 +626,6 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
@dbus.service.method('org.wicd.daemon.wireless')
|
||||||
def GetNumberOfNetworks(self):
|
def GetNumberOfNetworks(self):
|
||||||
""" Returns number of networks. """
|
""" Returns number of networks. """
|
||||||
if self.debug_mode:
|
|
||||||
print 'returned number of networks...', len(self.LastScan)
|
|
||||||
return len(self.LastScan)
|
return len(self.LastScan)
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
@dbus.service.method('org.wicd.daemon.wireless')
|
||||||
@@ -650,10 +650,6 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
value = misc.to_unicode(value)
|
value = misc.to_unicode(value)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
#if self.debug_mode == 1:
|
|
||||||
#return type instead of value for security
|
|
||||||
#print ('returned wireless network', networkid, 'property',
|
|
||||||
# property, 'of type', type(value))
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
@dbus.service.method('org.wicd.daemon.wireless')
|
||||||
@@ -664,9 +660,6 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
print "Setting script properties through the daemon is not \
|
print "Setting script properties through the daemon is not \
|
||||||
permitted."
|
permitted."
|
||||||
return False
|
return False
|
||||||
if self.debug_mode:
|
|
||||||
print 'setting wireless network %s property %s to value %s' % \
|
|
||||||
(networkid, property, value)
|
|
||||||
self.LastScan[networkid][property] = misc.Noneify(value)
|
self.LastScan[networkid][property] = misc.Noneify(value)
|
||||||
#end function SetProperty
|
#end function SetProperty
|
||||||
|
|
||||||
@@ -728,7 +721,8 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
for x in xrange(0, len(self.LastScan)):
|
for x in xrange(0, len(self.LastScan)):
|
||||||
if self.LastScan[x]['essid'] == currentESSID:
|
if self.LastScan[x]['essid'] == currentESSID:
|
||||||
return x
|
return x
|
||||||
print 'returning -1, current network not found'
|
if self.debug_mode:
|
||||||
|
print 'GetCurrentNetworkID: Returning -1, current network not found'
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
@dbus.service.method('org.wicd.daemon.wireless')
|
||||||
@@ -754,30 +748,26 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
self.wifi.after_script = self.GetWirelessProperty(id, 'afterscript')
|
self.wifi.after_script = self.GetWirelessProperty(id, 'afterscript')
|
||||||
self.wifi.disconnect_script = self.GetWirelessProperty(id,
|
self.wifi.disconnect_script = self.GetWirelessProperty(id,
|
||||||
'disconnectscript')
|
'disconnectscript')
|
||||||
print 'connecting to wireless network', self.LastScan[id]['essid']
|
print 'Connecting to wireless network', self.LastScan[id]['essid']
|
||||||
return self.wifi.Connect(self.LastScan[id])
|
return self.wifi.Connect(self.LastScan[id])
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
@dbus.service.method('org.wicd.daemon.wireless')
|
||||||
def CheckIfWirelessConnecting(self):
|
def CheckIfWirelessConnecting(self):
|
||||||
"""Returns True if wireless interface is connecting, otherwise False."""
|
"""Returns True if wireless interface is connecting, otherwise False."""
|
||||||
if not self.wifi.connecting_thread == None:
|
if self.wifi.connecting_thread is not None:
|
||||||
# If connecting_thread exists, then check for it's
|
# If connecting_thread exists, then check for it's
|
||||||
# status, if it doesn't, we aren't connecting.
|
# status, if it doesn't, we aren't connecting.
|
||||||
status = self.wifi.connecting_thread.is_connecting
|
status = self.wifi.connecting_thread.is_connecting
|
||||||
if self.debug_mode == 1:
|
|
||||||
print 'wireless connecting', status
|
|
||||||
return status
|
return status
|
||||||
else:
|
else:
|
||||||
if self.debug_mode == 1:
|
|
||||||
print 'wireless connecting', False
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
@dbus.service.method('org.wicd.daemon.wireless')
|
||||||
def GetWirelessIP(self):
|
def GetWirelessIP(self):
|
||||||
""" Returns the IP associated with the wireless interface. """
|
""" Returns the IP associated with the wireless interface. """
|
||||||
ip = self.wifi.GetIP()
|
ip = self.wifi.GetIP()
|
||||||
if self.debug_mode == 1:
|
#if self.debug_mode == 1:
|
||||||
print 'returning wireless ip', ip
|
#print 'returning wireless ip', ip
|
||||||
return ip
|
return ip
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
@dbus.service.method('org.wicd.daemon.wireless')
|
||||||
@@ -796,23 +786,17 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
def GetWiredIP(self):
|
def GetWiredIP(self):
|
||||||
""" Returns the wired interface's ip address. """
|
""" Returns the wired interface's ip address. """
|
||||||
ip = self.wired.GetIP()
|
ip = self.wired.GetIP()
|
||||||
if self.debug_mode == 1:
|
|
||||||
print 'returning wired ip', ip
|
|
||||||
return ip
|
return ip
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wired')
|
@dbus.service.method('org.wicd.daemon.wired')
|
||||||
def CheckIfWiredConnecting(self):
|
def CheckIfWiredConnecting(self):
|
||||||
""" Returns True if wired interface is connecting, otherwise False. """
|
""" Returns True if wired interface is connecting, otherwise False. """
|
||||||
if not self.wired.connecting_thread == None:
|
if self.wired.connecting_thread is not None:
|
||||||
#if connecting_thread exists, then check for it's
|
#if connecting_thread exists, then check for it's
|
||||||
#status, if it doesn't exist, we aren't connecting
|
#status, if it doesn't exist, we aren't connecting
|
||||||
status = self.wired.connecting_thread.is_connecting
|
status = self.wired.connecting_thread.is_connecting
|
||||||
if self.debug_mode == 1:
|
|
||||||
print 'wired connecting', status
|
|
||||||
return status
|
return status
|
||||||
else:
|
else:
|
||||||
if self.debug_mode == 1:
|
|
||||||
print 'wired connecting', False
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wired')
|
@dbus.service.method('org.wicd.daemon.wired')
|
||||||
@@ -821,7 +805,6 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
# 1 = default profile
|
# 1 = default profile
|
||||||
# 2 = show list
|
# 2 = show list
|
||||||
# 3 = last used profile
|
# 3 = last used profile
|
||||||
print 'wired autoconnection method is', method
|
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
config.read(self.app_conf)
|
config.read(self.app_conf)
|
||||||
config.set("Settings","wired_connect_mode", int(method))
|
config.set("Settings","wired_connect_mode", int(method))
|
||||||
@@ -850,11 +833,9 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
is not permitted."
|
is not permitted."
|
||||||
return False
|
return False
|
||||||
self.WiredNetwork[property] = misc.Noneify(value)
|
self.WiredNetwork[property] = misc.Noneify(value)
|
||||||
if self.debug_mode == 1:
|
|
||||||
print 'set', property, 'to', misc.Noneify(value)
|
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print 'WiredNetwork does not exist'
|
print 'SetWiredProperty: WiredNetwork does not exist'
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wired')
|
@dbus.service.method('org.wicd.daemon.wired')
|
||||||
@@ -862,17 +843,21 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
""" Returns the requested wired property. """
|
""" Returns the requested wired property. """
|
||||||
if self.WiredNetwork:
|
if self.WiredNetwork:
|
||||||
value = self.WiredNetwork.get(property)
|
value = self.WiredNetwork.get(property)
|
||||||
if self.debug_mode == 1:
|
|
||||||
print 'returned %s with value of %s to client' % (property,
|
|
||||||
value)
|
|
||||||
return value
|
return value
|
||||||
else:
|
else:
|
||||||
print 'WiredNetwork does not exist'
|
print 'GetWiredProperty: WiredNetwork does not exist'
|
||||||
|
return False
|
||||||
|
|
||||||
|
@dbus.service.method('org.wicd.daemon.wired')
|
||||||
|
def HasWiredDriver(self):
|
||||||
|
""" Returns True if a driver is associated with this interface. """
|
||||||
|
if self.wired.driver:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wired')
|
@dbus.service.method('org.wicd.daemon.wired')
|
||||||
def SetAlwaysShowWiredInterface(self, value):
|
def SetAlwaysShowWiredInterface(self, value):
|
||||||
print 'Setting always show wired interface'
|
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
config.read(self.app_conf)
|
config.read(self.app_conf)
|
||||||
config.set("Settings", "always_show_wired_interface",
|
config.set("Settings", "always_show_wired_interface",
|
||||||
@@ -882,16 +867,14 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wired')
|
@dbus.service.method('org.wicd.daemon.wired')
|
||||||
def GetAlwaysShowWiredInterface(self):
|
def GetAlwaysShowWiredInterface(self):
|
||||||
do = bool(self.always_show_wired_interface)
|
return bool(self.always_show_wired_interface)
|
||||||
return self.__printReturn('returning always show wired interface', do)
|
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wired')
|
@dbus.service.method('org.wicd.daemon.wired')
|
||||||
def CheckPluggedIn(self):
|
def CheckPluggedIn(self):
|
||||||
if self.wired.wired_interface and self.wired.wired_interface != "None":
|
if self.wired.wired_interface and self.wired.wired_interface != "None":
|
||||||
return self.__printReturn('returning plugged in',
|
return self.wired.CheckPluggedIn()
|
||||||
self.wired.CheckPluggedIn())
|
|
||||||
else:
|
else:
|
||||||
return self.__printReturn("returning plugged in", None)
|
return None
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wired')
|
@dbus.service.method('org.wicd.daemon.wired')
|
||||||
def IsWiredUp(self):
|
def IsWiredUp(self):
|
||||||
@@ -939,7 +922,7 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
def CreateWiredNetworkProfile(self, profilename):
|
def CreateWiredNetworkProfile(self, profilename):
|
||||||
""" Creates a wired network profile. """
|
""" Creates a wired network profile. """
|
||||||
profilename = misc.to_unicode(profilename)
|
profilename = misc.to_unicode(profilename)
|
||||||
print "creating profile for " + profilename
|
print "Creating wired profile for " + profilename
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
config.read(self.wired_conf)
|
config.read(self.wired_conf)
|
||||||
if config.has_section(profilename):
|
if config.has_section(profilename):
|
||||||
@@ -962,16 +945,12 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
@dbus.service.method('org.wicd.daemon.config')
|
@dbus.service.method('org.wicd.daemon.config')
|
||||||
def UnsetWiredLastUsed(self):
|
def UnsetWiredLastUsed(self):
|
||||||
""" Finds the previous lastused network, and sets lastused to False. """
|
""" Finds the previous lastused network, and sets lastused to False. """
|
||||||
print 'unsetting last used'
|
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
config.read(self.wired_conf)
|
config.read(self.wired_conf)
|
||||||
profileList = config.sections()
|
profileList = config.sections()
|
||||||
print "profileList = ", profileList
|
|
||||||
for profile in profileList:
|
for profile in profileList:
|
||||||
print "profile = ", profile
|
|
||||||
if config.has_option(profile, "lastused"):
|
if config.has_option(profile, "lastused"):
|
||||||
if misc.to_bool(config.get(profile, "lastused")):
|
if misc.to_bool(config.get(profile, "lastused")):
|
||||||
print "removing existing lastused"
|
|
||||||
config.set(profile, "lastused", False)
|
config.set(profile, "lastused", False)
|
||||||
self.SaveWiredNetworkProfile(profile)
|
self.SaveWiredNetworkProfile(profile)
|
||||||
|
|
||||||
@@ -984,7 +963,6 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
for profile in profileList:
|
for profile in profileList:
|
||||||
if config.has_option(profile, "default"):
|
if config.has_option(profile, "default"):
|
||||||
if misc.to_bool(config.get(profile, "default")):
|
if misc.to_bool(config.get(profile, "default")):
|
||||||
print "removing existing default", profile
|
|
||||||
config.set(profile, "default", False)
|
config.set(profile, "default", False)
|
||||||
self.SaveWiredNetworkProfile(profile)
|
self.SaveWiredNetworkProfile(profile)
|
||||||
|
|
||||||
@@ -1015,7 +993,7 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
def DeleteWiredNetworkProfile(self, profilename):
|
def DeleteWiredNetworkProfile(self, profilename):
|
||||||
""" Deletes a wired network profile """
|
""" Deletes a wired network profile """
|
||||||
profilename = misc.to_unicode(profilename)
|
profilename = misc.to_unicode(profilename)
|
||||||
print "deleting profile for " + str(profilename)
|
print "Deleting wired profile for " + str(profilename)
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
config.read(self.wired_conf)
|
config.read(self.wired_conf)
|
||||||
if config.has_section(profilename):
|
if config.has_section(profilename):
|
||||||
@@ -1032,7 +1010,6 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
if profilename == "":
|
if profilename == "":
|
||||||
return "500: Bad Profile name"
|
return "500: Bad Profile name"
|
||||||
profilename = misc.to_unicode(profilename)
|
profilename = misc.to_unicode(profilename)
|
||||||
print "setting profile for " + str(profilename)
|
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
config.read(self.wired_conf)
|
config.read(self.wired_conf)
|
||||||
if config.has_section(profilename):
|
if config.has_section(profilename):
|
||||||
@@ -1066,7 +1043,6 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
""" Returns a list of all wired profiles in wired-settings.conf """
|
""" Returns a list of all wired profiles in wired-settings.conf """
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
config.read(self.wired_conf)
|
config.read(self.wired_conf)
|
||||||
print config.sections()
|
|
||||||
if config.sections():
|
if config.sections():
|
||||||
return config.sections()
|
return config.sections()
|
||||||
else:
|
else:
|
||||||
@@ -1075,7 +1051,6 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
@dbus.service.method('org.wicd.daemon.config')
|
@dbus.service.method('org.wicd.daemon.config')
|
||||||
def SaveWirelessNetworkProfile(self, id):
|
def SaveWirelessNetworkProfile(self, id):
|
||||||
""" Writes a wireless profile to disk """
|
""" Writes a wireless profile to disk """
|
||||||
print "setting network profile"
|
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
config.read(self.wireless_conf)
|
config.read(self.wireless_conf)
|
||||||
cur_network = self.LastScan[id]
|
cur_network = self.LastScan[id]
|
||||||
@@ -1109,8 +1084,6 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
return
|
return
|
||||||
cur_network = self.LastScan[id]
|
cur_network = self.LastScan[id]
|
||||||
essid_key = "essid:" + cur_network["essid"]
|
essid_key = "essid:" + cur_network["essid"]
|
||||||
print ''.join(["setting network option ", str(option), " to ",
|
|
||||||
str(cur_network[option])])
|
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
config.read(self.wireless_conf)
|
config.read(self.wireless_conf)
|
||||||
|
|
||||||
@@ -1143,7 +1116,8 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
cur_network = self.LastScan[id]
|
cur_network = self.LastScan[id]
|
||||||
essid_key = "essid:" + cur_network["essid"]
|
essid_key = "essid:" + cur_network["essid"]
|
||||||
bssid_key = cur_network["bssid"]
|
bssid_key = cur_network["bssid"]
|
||||||
print bssid_key
|
if self.debug_mode:
|
||||||
|
print bssid_key
|
||||||
if config.has_section(essid_key):
|
if config.has_section(essid_key):
|
||||||
if config.get(essid_key, 'use_settings_globally'):
|
if config.get(essid_key, 'use_settings_globally'):
|
||||||
return self._read_wireless_profile(config, cur_network,
|
return self._read_wireless_profile(config, cur_network,
|
||||||
@@ -1217,8 +1191,8 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
|
|
||||||
def __printReturn(self, text, value):
|
def __printReturn(self, text, value):
|
||||||
"""prints the specified text and value, then returns the value"""
|
"""prints the specified text and value, then returns the value"""
|
||||||
if self.debug_mode == 1:
|
if self.debug_mode:
|
||||||
print text, value
|
print text + " " + value
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def get_option(self, section, option, default=None):
|
def get_option(self, section, option, default=None):
|
||||||
@@ -1245,6 +1219,9 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
if os.path.isfile(self.app_conf):
|
if os.path.isfile(self.app_conf):
|
||||||
iface = self.DetectWirelessInterface()
|
iface = self.DetectWirelessInterface()
|
||||||
if not iface:
|
if not iface:
|
||||||
|
if self.debug_mode:
|
||||||
|
print "Failed to detect wireless interface, defaulting " + \
|
||||||
|
"to wlan0, unless a config entry already exists."
|
||||||
iface = "wlan0"
|
iface = "wlan0"
|
||||||
self.SetWirelessInterface(self.get_option("Settings",
|
self.SetWirelessInterface(self.get_option("Settings",
|
||||||
"wireless_interface",
|
"wireless_interface",
|
||||||
@@ -1279,7 +1256,7 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
# Write some defaults maybe?
|
# Write some defaults maybe?
|
||||||
print "configuration file not found, creating, adding defaults..."
|
print "Configuration file not found, creating, adding defaults..."
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
config.read(self.app_conf)
|
config.read(self.app_conf)
|
||||||
config.add_section("Settings")
|
config.add_section("Settings")
|
||||||
@@ -1297,7 +1274,7 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
if iface is not None:
|
if iface is not None:
|
||||||
config.set("Settings", "wireless_interface", iface)
|
config.set("Settings", "wireless_interface", iface)
|
||||||
else:
|
else:
|
||||||
print "couldn't detect a wireless interface, using wlan0..."
|
print "Couldn't detect a wireless interface, using wlan0..."
|
||||||
config.set("Settings", "wireless_interface", "wlan0")
|
config.set("Settings", "wireless_interface", "wlan0")
|
||||||
config.set("Settings", "wpa_driver", "wext")
|
config.set("Settings", "wpa_driver", "wext")
|
||||||
config.write(open(self.app_conf, "w"))
|
config.write(open(self.app_conf, "w"))
|
||||||
@@ -1316,20 +1293,20 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
self.SetGlobalDNS(None, None, None)
|
self.SetGlobalDNS(None, None, None)
|
||||||
|
|
||||||
if os.path.isfile(self.wireless_conf):
|
if os.path.isfile(self.wireless_conf):
|
||||||
print "wireless configuration file found..."
|
print "Wireless configuration file found..."
|
||||||
# Don't do anything since it is there
|
# Don't do anything since it is there
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# We don't need to put anything in it, so just make it
|
# We don't need to put anything in it, so just make it
|
||||||
print "wireless configuration file not found, creating..."
|
print "Wireless configuration file not found, creating..."
|
||||||
open(self.wireless_conf, "w").close()
|
open(self.wireless_conf, "w").close()
|
||||||
|
|
||||||
if os.path.isfile(self.wired_conf):
|
if os.path.isfile(self.wired_conf):
|
||||||
print "wired configuration file found..."
|
print "Wired configuration file found..."
|
||||||
# Don't do anything since it is there
|
# Don't do anything since it is there
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
print "wired configuration file not found, creating a default..."
|
print "Wired configuration file not found, creating a default..."
|
||||||
# Create the file and a default profile
|
# Create the file and a default profile
|
||||||
open(self.wired_conf, "w").close()
|
open(self.wired_conf, "w").close()
|
||||||
self.CreateWiredNetworkProfile("wired-default")
|
self.CreateWiredNetworkProfile("wired-default")
|
||||||
@@ -1346,8 +1323,7 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
os.chown(self.wireless_conf, 0, 0)
|
os.chown(self.wireless_conf, 0, 0)
|
||||||
os.chown(self.wired_conf, 0, 0)
|
os.chown(self.wired_conf, 0, 0)
|
||||||
|
|
||||||
print "autodetected wireless interface...", self.DetectWirelessInterface()
|
print "Using wireless interface..." + self.GetWirelessInterface()
|
||||||
print "using wireless interface...", self.GetWirelessInterface()
|
|
||||||
|
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
@@ -1466,5 +1442,9 @@ def sigterm_caught(sig, frame):
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
if os.getuid() != 0:
|
||||||
|
print ("Root priviledges are required for the daemon to run properly." +
|
||||||
|
" Exiting.")
|
||||||
|
sys.exit(1)
|
||||||
DBusGMainLoop(set_as_default=True)
|
DBusGMainLoop(set_as_default=True)
|
||||||
main(sys.argv)
|
main(sys.argv)
|
||||||
|
|||||||
23
gui.py
23
gui.py
@@ -1503,7 +1503,6 @@ class appGui:
|
|||||||
if self.check_for_wireless(wireless.GetIwconfig(),
|
if self.check_for_wireless(wireless.GetIwconfig(),
|
||||||
wireless.GetWirelessIP()):
|
wireless.GetWirelessIP()):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
self.set_status(language['not_connected'])
|
self.set_status(language['not_connected'])
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -1556,6 +1555,8 @@ class appGui:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
print "refreshing..."
|
print "refreshing..."
|
||||||
|
self.network_list.set_sensitive(False)
|
||||||
|
self.wait_for_events()
|
||||||
printLine = False # We don't print a separator by default.
|
printLine = False # We don't print a separator by default.
|
||||||
# Remove stuff already in there.
|
# Remove stuff already in there.
|
||||||
for z in self.network_list:
|
for z in self.network_list:
|
||||||
@@ -1608,6 +1609,7 @@ class appGui:
|
|||||||
label = gtk.Label(language['no_wireless_networks_found'])
|
label = gtk.Label(language['no_wireless_networks_found'])
|
||||||
self.network_list.pack_start(label)
|
self.network_list.pack_start(label)
|
||||||
label.show()
|
label.show()
|
||||||
|
self.network_list.set_sensitive(True)
|
||||||
|
|
||||||
def save_settings(self, nettype, networkid, networkentry):
|
def save_settings(self, nettype, networkid, networkentry):
|
||||||
""" Verifies and saves the settings for the network entry. """
|
""" Verifies and saves the settings for the network entry. """
|
||||||
@@ -1802,6 +1804,18 @@ class appGui:
|
|||||||
elif nettype == "wired":
|
elif nettype == "wired":
|
||||||
wired.ConnectWired()
|
wired.ConnectWired()
|
||||||
self.update_statusbar()
|
self.update_statusbar()
|
||||||
|
|
||||||
|
def wait_for_events(self, amt=0):
|
||||||
|
""" Wait for any pending gtk events to finish before moving on.
|
||||||
|
|
||||||
|
Keyword arguments:
|
||||||
|
amt -- a number specifying the number of ms to wait before checking
|
||||||
|
for pending events.
|
||||||
|
|
||||||
|
"""
|
||||||
|
time.sleep(amt)
|
||||||
|
while gtk.events_pending():
|
||||||
|
gtk.main_iteration()
|
||||||
|
|
||||||
def exit(self, widget=None, event=None):
|
def exit(self, widget=None, event=None):
|
||||||
""" Hide the wicd GUI.
|
""" Hide the wicd GUI.
|
||||||
@@ -1821,8 +1835,7 @@ class appGui:
|
|||||||
|
|
||||||
self.is_visible = False
|
self.is_visible = False
|
||||||
daemon.SetGUIOpen(False)
|
daemon.SetGUIOpen(False)
|
||||||
while gtk.events_pending():
|
self.wait_for_events()
|
||||||
gtk.main_iteration()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def show_win(self):
|
def show_win(self):
|
||||||
@@ -1833,9 +1846,11 @@ class appGui:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
self.window.show()
|
self.window.show()
|
||||||
|
self.wait_for_events()
|
||||||
self.is_visible = True
|
self.is_visible = True
|
||||||
daemon.SetGUIOpen(True)
|
daemon.SetGUIOpen(True)
|
||||||
self.refresh_networks()
|
self.wait_for_events(0.1)
|
||||||
|
gobject.idle_add(self.refresh_networks)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ class ConnectThread(threading.Thread):
|
|||||||
|
|
||||||
def put_iface_down(self, iface):
|
def put_iface_down(self, iface):
|
||||||
""" Puts the given interface down. """
|
""" Puts the given interface down. """
|
||||||
print 'Interface down'
|
print 'Putting interface down'
|
||||||
self.SetStatus('interface_down')
|
self.SetStatus('interface_down')
|
||||||
iface.Down()
|
iface.Down()
|
||||||
|
|
||||||
@@ -292,7 +292,7 @@ class ConnectThread(threading.Thread):
|
|||||||
|
|
||||||
def put_iface_up(self, iface):
|
def put_iface_up(self, iface):
|
||||||
""" Bring up given interface. """
|
""" Bring up given interface. """
|
||||||
print 'Interface up...'
|
print 'Putting interface up...'
|
||||||
self.SetStatus('interface_up')
|
self.SetStatus('interface_up')
|
||||||
iface.Up()
|
iface.Up()
|
||||||
|
|
||||||
@@ -620,6 +620,8 @@ class WirelessConnectThread(ConnectThread):
|
|||||||
|
|
||||||
self.SetStatus('done')
|
self.SetStatus('done')
|
||||||
print 'Connecting thread exiting.'
|
print 'Connecting thread exiting.'
|
||||||
|
if self.debug:
|
||||||
|
print "IP Address is: " + wiface.GetIP()
|
||||||
self.is_connecting = False
|
self.is_connecting = False
|
||||||
|
|
||||||
def generate_psk_and_authenticate(self, wiface):
|
def generate_psk_and_authenticate(self, wiface):
|
||||||
@@ -812,4 +814,6 @@ class WiredConnectThread(ConnectThread):
|
|||||||
|
|
||||||
self.SetStatus('done')
|
self.SetStatus('done')
|
||||||
print 'Connecting thread exiting.'
|
print 'Connecting thread exiting.'
|
||||||
|
if self.debug:
|
||||||
|
print "IP Address is: " + liface.GetIP()
|
||||||
self.is_connecting = False
|
self.is_connecting = False
|
||||||
|
|||||||
2
wicd.py
2
wicd.py
@@ -336,7 +336,7 @@ class TrayIcon():
|
|||||||
""" Handles tray mouse click events. """
|
""" Handles tray mouse click events. """
|
||||||
if event.button == 1:
|
if event.button == 1:
|
||||||
self.toggle_wicd_gui()
|
self.toggle_wicd_gui()
|
||||||
if event.button == 3:
|
elif event.button == 3:
|
||||||
self.menu.popup(None, None, None, event.button, event.time)
|
self.menu.popup(None, None, None, event.button, event.time)
|
||||||
|
|
||||||
def set_from_file(self, val=None):
|
def set_from_file(self, val=None):
|
||||||
|
|||||||
@@ -954,11 +954,11 @@ class WirelessInterface(Interface):
|
|||||||
if max_strength and strength:
|
if max_strength and strength:
|
||||||
return 100 * int(strength) // int(max_strength)
|
return 100 * int(strength) // int(max_strength)
|
||||||
|
|
||||||
if strength == None:
|
if strength is None:
|
||||||
strength = misc.RunRegex(altstrength_pattern, output)
|
strength = misc.RunRegex(altstrength_pattern, output)
|
||||||
|
|
||||||
return strength
|
return strength
|
||||||
|
|
||||||
|
|
||||||
def GetDBMStrength(self, iwconfig=None):
|
def GetDBMStrength(self, iwconfig=None):
|
||||||
""" Get the dBm signal strength of the current network.
|
""" Get the dBm signal strength of the current network.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user