1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-19 20:38:00 +01:00

Added wired auto-connect profile chooser, fixed some bugs in the ralink legacy connection code, reorganized edgy.py and fixed some bugs in it, probably a few other things too

This commit is contained in:
imdano
2007-07-23 07:05:05 +00:00
parent e7fd625617
commit 2d38b8f0d4
4 changed files with 333 additions and 154 deletions

219
daemon.py
View File

@@ -111,6 +111,7 @@ class ConnectionWizard(dbus.service.Object):
self.wifi = networking.Wireless() self.wifi = networking.Wireless()
self.wired = networking.Wired() self.wired = networking.Wired()
self.forced_disconnect = False self.forced_disconnect = False
self.need_profile_chooser = False
#load the config file - it should have most of the stuff we need to run... #load the config file - it should have most of the stuff we need to run...
self.ReadConfig() self.ReadConfig()
@@ -119,7 +120,7 @@ class ConnectionWizard(dbus.service.Object):
#this will speed up the scanning process - if a client doesn't need a fresh scan, just #this will speed up the scanning process - if a client doesn't need a fresh scan, just
#feed them the old one. a fresh scan can be done by calling FreshScan(self,interface) #feed them the old one. a fresh scan can be done by calling FreshScan(self,interface)
self.LastScan = None self.LastScan = ''
#make a variable that will hold the wired network profile #make a variable that will hold the wired network profile
self.WiredNetwork = {} self.WiredNetwork = {}
@@ -184,7 +185,7 @@ class ConnectionWizard(dbus.service.Object):
configfile = open(self.app_conf,"w") configfile = open(self.app_conf,"w")
config.write(configfile) config.write(configfile)
#end function SetWirelessInterface #end function SetWirelessInterface
@dbus.service.method('org.wicd.daemon') @dbus.service.method('org.wicd.daemon')
def SetWPADriver(self,driver): def SetWPADriver(self,driver):
'''sets the wpa driver the wpa_supplicant will use''' '''sets the wpa driver the wpa_supplicant will use'''
@@ -269,12 +270,73 @@ class ConnectionWizard(dbus.service.Object):
configfile = open(self.app_conf,"w") configfile = open(self.app_conf,"w")
config.write(configfile) config.write(configfile)
self.debug_mode = debug self.debug_mode = debug
#end function SetDebugMode
@dbus.service.method('org.wicd.daemon') @dbus.service.method('org.wicd.daemon')
def GetDebugMode(self): def GetDebugMode(self):
'''returns whether debugging is enabled''' '''returns whether debugging is enabled'''
return bool(int(self.debug_mode)) return bool(int(self.debug_mode))
#end function GetDebugMode
@dbus.service.method('org.wicd.daemon')
def AutoConnect(self,fresh):
'''first tries to autoconnect to a wired network, if that fails it tries a wireless connection'''
if self.CheckPluggedIn() == True:
if self.GetWiredAutoConnectMethod() == False:
self.SetNeedWiredProfileChooser(True)
print 'alerting tray to display wired autoconnect wizard'
else:
defaultNetwork = self.GetDefaultWiredNetwork()
if defaultNetwork != None:
self.ReadWiredNetworkProfile(defaultNetwork)
self.ConnectWired()
time.sleep(1)
print "Attempting to autoconnect with wired interface..."
while self.CheckIfWiredConnecting(): # Keeps us from going into an infinite connecting loop
time.sleep(1)
print "...done autoconnecting."
else:
print "couldn't find a default wired connection, wired autoconnect failed"
else:
print "no wired connection present, wired autoconnect failed"
print 'attempting to autoconnect to wireless network'
if fresh:
self.Scan()
if self.GetWirelessInterface() != None:
for x in self.LastScan:
if bool(self.LastScan[x]["has_profile"]):
print str(self.LastScan[x]["essid"]) + ' has profile'
if bool(self.LastScan[x].get('automatic')):
print 'automatically connecting to...',str(self.LastScan[x]["essid"])
self.ConnectWireless(x)
time.sleep(3)
while self.CheckIfWirelessConnecting():
print "autoconnecting... hold"
#not sure why I need to get IPs, but
#it solves the autoconnect problem
#i think it has something to do with
#making IO calls while threads are working...?
#if anyone knows why...email me at compwiz18@gmail.com
#only some people need these statements for autoconnect
#to function properly
self.GetWirelessIP()
###
# removed line below for 1.3.0 - if there is trouble with
# connecting at boot,
# add back to file -- adam
###
# as far as I can tell, it seems fine - what does everyone else
# think? -- adam
###
#self.GetWiredIP()
time.sleep(2)
print "autoconnecting... done"
return
print "unable to autoconnect, you'll have to manually connect"
else:
print 'autoconnect failed because wireless interface == None'
#end function AutoConnect
@dbus.service.method('org.wicd.daemon') @dbus.service.method('org.wicd.daemon')
def GetGlobalDNSAddresses(self): def GetGlobalDNSAddresses(self):
'''returns the global dns addresses''' '''returns the global dns addresses'''
@@ -282,6 +344,25 @@ class ConnectionWizard(dbus.service.Object):
return (self.dns1,self.dns2,self.dns3) return (self.dns1,self.dns2,self.dns3)
#end function GetWirelessInterface #end function GetWirelessInterface
@dbus.service.method('org.wicd.daemon')
def CheckIfConnecting(self):
'''returns if a network connection is being made'''
if self.CheckIfWiredConnecting() == False and self.CheckIfWirelessConnecting() == False:
return False
else:
return True
#end function CheckIfConnecting
@dbus.service.method('org.wicd.daemon')
def SetNeedWiredProfileChooser(self,val):
self.need_profile_chooser = val
#end function SetNeedWiredProfileChooser
@dbus.service.method('org.wicd.daemon')
def GetNeedWiredProfileChooser(self):
return self.need_profile_chooser
#end function GetNeedWiredProfileChooser
########## WIRELESS FUNCTIONS ########## WIRELESS FUNCTIONS
################################# #################################
@@ -313,12 +394,18 @@ class ConnectionWizard(dbus.service.Object):
#end function DisconnectWireless #end function DisconnectWireless
@dbus.service.method('org.wicd.daemon.wireless') @dbus.service.method('org.wicd.daemon.wireless')
def SetWirelessBeforeScript(self,script): def SetWirelessBeforeScript(self,networkid,script):
if script == '':
script = None
self.SetWirelessProperty(networkid,"beforescript",script)
self.wifi.before_script = script self.wifi.before_script = script
#end function SetWirelessBeforeScript #end function SetWirelessBeforeScript
@dbus.service.method('org.wicd.daemon.wireless') @dbus.service.method('org.wicd.daemon.wireless')
def SetWirelessAfterScript(self,script): def SetWirelessAfterScript(self,networkid,script):
if script == '':
script = None
self.SetWirelessProperty(networkid,"afterscript",script)
self.wifi.after_script = script self.wifi.after_script = script
#end function SetWirelessAfterScript #end function SetWirelessAfterScript
@@ -341,7 +428,7 @@ class ConnectionWizard(dbus.service.Object):
'''returns if wicd should automatically try to reconnect is connection is lost''' '''returns if wicd should automatically try to reconnect is connection is lost'''
do = bool(int(self.auto_reconnect)) do = bool(int(self.auto_reconnect))
return self.__printReturn('returning automatically reconnect when connection drops',do) return self.__printReturn('returning automatically reconnect when connection drops',do)
#end function GetAutoReconnect #end function GetAutoReconnect
@dbus.service.method('org.wicd.daemon.wireless') @dbus.service.method('org.wicd.daemon.wireless')
def SetAutoReconnect(self,value): def SetAutoReconnect(self,value):
@@ -354,61 +441,6 @@ class ConnectionWizard(dbus.service.Object):
self.auto_reconnect = value self.auto_reconnect = value
#end function SetAutoReconnect #end function SetAutoReconnect
@dbus.service.method('org.wicd.daemon.wireless')
def AutoConnect(self,fresh):
'''first tries to autoconnect to a wireled network, if that fails it tries a wireless connection'''
if fresh and self.CheckPluggedIn() == True:
defaultNetwork = self.GetDefaultWiredNetwork()
if defaultNetwork != None:
self.ReadWiredNetworkProfile(defaultNetwork)
self.ConnectWired()
time.sleep(1)
print "Attempting to autoconnect with wired interface..."
while self.CheckIfWiredConnecting(): # Keeps us from going into an infinite connecting loop
time.sleep(1)
print "...done autoconnecting."
else:
print "couldn't find a default wired connection, wired autoconnect failed"
else:
print "no wired connection present, wired autoconnect failed"
print 'attempting to autoconnect to wireless network'
if fresh:
self.Scan()
if self.GetWirelessInterface() != None:
for x in self.LastScan:
if bool(self.LastScan[x]["has_profile"]):
print str(self.LastScan[x]["essid"]) + ' has profile'
if bool(self.LastScan[x].get('automatic')):
print 'automatically connecting to...',str(self.LastScan[x]["essid"])
self.ConnectWireless(x)
time.sleep(3)
while self.CheckIfWirelessConnecting():
print "autoconnecting... hold"
#not sure why I need to get IPs, but
#it solves the autoconnect problem
#i think it has something to do with
#making IO calls while threads are working...?
#if anyone knows why...email me at compwiz18@gmail.com
#only some people need these statements for autoconnect
#to function properly
self.GetWirelessIP()
###
# removed line below for 1.3.0 - if there is trouble with
# connecting at boot,
# add back to file -- adam
###
# as far as I can tell, it seems fine - what does everyone else
# think? -- adam
###
#self.GetWiredIP()
time.sleep(2)
print "autoconnecting... done"
return
print "unable to autoconnect, you'll have to manually connect"
else:
print 'autoconnect failed because wireless interface == None'
#end function AutoConnect
@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'''
@@ -558,15 +590,36 @@ class ConnectionWizard(dbus.service.Object):
@dbus.service.method('org.wicd.daemon.wired') @dbus.service.method('org.wicd.daemon.wired')
def SetWiredBeforeScript(self,script): def SetWiredBeforeScript(self,script):
'''sets pre-connection script to run for a wired connection''' '''sets pre-connection script to run for a wired connection'''
if script == '':
script = None
self.SetWiredProperty("beforescript",script)
self.wired.before_script = script self.wired.before_script = script
#end function SetWiredBeforeScript #end function SetWiredBeforeScript
@dbus.service.method('org.wicd.daemon.wired') @dbus.service.method('org.wicd.daemon.wired')
def SetWiredAfterScript(self,script): def SetWiredAfterScript(self,script):
'''sets post-connection script to run for a wired connection''' '''sets post-connection script to run for a wired connection'''
if script == '':
script = None
self.SetWiredProperty("afterscript",script)
self.wired.after_script = script self.wired.after_script = script
#end function SetWiredAfterScript #end function SetWiredAfterScript
@dbus.service.method('org.wicd.daemon.wired')
def SetWiredAutoConnectMethod(self,method):
'''sets which method the user wants to autoconnect to wired networks'''
print 'method = ',method
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.set("Settings","use_default_profile",int(method))
config.write(open(self.app_conf,"w"))
self.use_default_profile = method
def GetWiredAutoConnectMethod(self):
'''returns the wired autoconnect method'''
return bool(int(self.use_default_profile))
#end function GetWiredAutoConnectMethod
@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'''
@@ -856,13 +909,18 @@ class ConnectionWizard(dbus.service.Object):
if config.has_option("Settings","auto_reconnect"): if config.has_option("Settings","auto_reconnect"):
self.auto_reconnect = config.get("Settings","auto_reconnect") self.auto_reconnect = config.get("Settings","auto_reconnect")
else: else:
config.set("Settings","auto_reconnect","False") config.set("Settings","auto_reconnect","0")
self.auto_reconnect = False self.auto_reconnect = False
if config.has_option("Settings","debug_mode"): if config.has_option("Settings","debug_mode"):
self.debug_mode = config.get("Settings","debug_mode") self.debug_mode = config.get("Settings","debug_mode")
else: else:
self.debug_mode = False self.debug_mode = 0
config.set("Settings","debug_mode","False") config.set("Settings","debug_mode","0")
if config.has_option("Settings","use_default_profile"):
self.SetWiredAutoConnectMethod(config.get("Settings","use_default_profile"))
else:
config.set("Settings","use_default_profile","1")
self.SetWiredAutoConnectMethod(config.get("Settings","use_default_profile"))
else: else:
print "configuration file exists, no settings found, adding defaults..." print "configuration file exists, no settings found, adding defaults..."
configfile = open(self.app_conf,"w") configfile = open(self.app_conf,"w")
@@ -870,20 +928,22 @@ class ConnectionWizard(dbus.service.Object):
config.set("Settings","wireless_interface","wlan0") config.set("Settings","wireless_interface","wlan0")
config.set("Settings","wired_interface","eth0") config.set("Settings","wired_interface","eth0")
config.set("Settings","wpa_driver","wext") config.set("Settings","wpa_driver","wext")
config.set("Settings","always_show_wired_interface","False") config.set("Settings","always_show_wired_interface","0")
config.set("Settings","auto_reconnect","False") config.set("Settings","auto_reconnect","0")
config.set("Settings","debug_mode","False") config.set("Settings","debug_mode","0")
config.set("Settings","use_default_profile","1")
config.set("Settings","use_global_dns","False") config.set("Settings","use_global_dns","False")
config.set("Settings","dns1","None") config.set("Settings","dns1","None")
config.set("Settings","dns2","None") config.set("Settings","dns2","None")
config.set("Settings","dns3","None") config.set("Settings","dns3","None")
self.SetGlobalDNS(config.get('Settings','dns1'),config.get('Settings','dns2'),config.get('Settings','dns3')) self.SetGlobalDNS(config.get('Settings','dns1'),config.get('Settings','dns2'),config.get('Settings','dns3'))
self.SetWirelessInterface(config.get("Settings","wireless_interface")) self.SetWirelessInterface("wlan0")
self.SetWiredInterface(config.get("Settings","wired_interface")) self.SetWiredInterface("eth0")
self.SetWPADriver(config.get("Settings","wpa_driver")) self.SetWPADriver("wext")
self.SetAlwaysShowWiredInterface(False) self.SetAlwaysShowWiredInterface(0)
self.SetAutoReconnect(True) self.SetAutoReconnect(1)
self.SetDebugMode(False) self.SetDebugMode(0)
self.SetWiredAutoConnectMethod(1)
config.write(configfile) config.write(configfile)
else: else:
@@ -894,9 +954,10 @@ class ConnectionWizard(dbus.service.Object):
config.add_section("Settings") config.add_section("Settings")
config.set("Settings","wireless_interface","wlan0") config.set("Settings","wireless_interface","wlan0")
config.set("Settings","wired_interface","eth0") config.set("Settings","wired_interface","eth0")
config.set("Settings","always_show_wired_interface","False") config.set("Settings","always_show_wired_interface","0")
config.set("Settings","auto_reconnect","False") config.set("Settings","auto_reconnect","0")
config.set("Settings","debug_mode","False") config.set("Settings","debug_mode","0")
config.set("Settings","use_default_profile","1")
config.set("Settings","dns1","None") config.set("Settings","dns1","None")
config.set("Settings","dns2","None") config.set("Settings","dns2","None")
config.set("Settings","dns3","None") config.set("Settings","dns3","None")
@@ -911,9 +972,11 @@ class ConnectionWizard(dbus.service.Object):
self.SetWirelessInterface(config.get("Settings","wireless_interface")) self.SetWirelessInterface(config.get("Settings","wireless_interface"))
self.SetWiredInterface(config.get("Settings","wired_interface")) self.SetWiredInterface(config.get("Settings","wired_interface"))
self.SetWPADriver(config.get("Settings","wpa_driver")) self.SetWPADriver(config.get("Settings","wpa_driver"))
self.SetAlwaysShowWiredInterface(False) self.SetAlwaysShowWiredInterface(0)
self.SetAutoReconnect(True) self.SetAutoReconnect(1)
self.SetDebugMode(False) self.SetHideDupeAPs(0)
self.SetDebugMode(0)
self.SetWiredAutoConnectMethod(1)
self.SetGlobalDNS(None,None,None) self.SetGlobalDNS(None,None,None)
#end If #end If

61
edgy.py
View File

@@ -77,15 +77,24 @@ def open_wicd_gui():
if ret == 0: if ret == 0:
lastWinId = os.spawnlpe(os.P_NOWAIT, './gui.py', os.environ) lastWinId = os.spawnlpe(os.P_NOWAIT, './gui.py', os.environ)
def wired_profile_chooser():
print 'profile chooser is running'
os.spawnlpe(os.P_WAIT, './gui.py', os.environ)
def set_signal_image(): def set_signal_image():
global LastStrength global LastStrength
global stillWired #keeps us from resetting the wired info over and over global stillWired #keeps us from resetting the wired info over and over
global network #declared as global so it gets initialized before initial use global network #declared as global so it gets initialized before initial use
# Disable logging if debugging isn't on to prevent log spam #Disable logging if debugging isn't on to prevent log spam
if not daemon.GetDebugMode(): if not daemon.GetDebugMode():
config.DisableLogging() config.DisableLogging()
#Check to see we wired profile autoconnect chooser needs to be displayed
if daemon.GetNeedWiredProfileChooser() == True:
wired_profile_chooser()
daemon.SetNeedWiredProfileChooser(False)
wired_ip = wired.GetWiredIP() wired_ip = wired.GetWiredIP()
if wired.CheckPluggedIn() == True and wired_ip != None: if wired.CheckPluggedIn() == True and wired_ip != None:
if stillWired == False: # Only set image/tooltip if it hasn't been set already if stillWired == False: # Only set image/tooltip if it hasn't been set already
@@ -94,7 +103,7 @@ def set_signal_image():
stillWired = True stillWired = True
lock = '' lock = ''
else: else:
if stillWired == True: if stillWired == True: #this only occurs when we were previously using wired but it became unplugged
tr.set_from_file("images/no-signal.png") tr.set_from_file("images/no-signal.png")
tr.set_tooltip(language['not_connected']) tr.set_tooltip(language['not_connected'])
stillWired = False stillWired = False
@@ -107,7 +116,7 @@ def set_signal_image():
#only update if the signal strength has changed because doing I/O calls is expensive, #only update if the signal strength has changed because doing I/O calls is expensive,
#and the icon flickers #and the icon flickers
if (signal != LastStrength or network != wireless.GetCurrentNetwork()) and wireless_ip != None: if (signal != LastStrength or network != wireless.GetCurrentNetwork() or signal == 0) and wireless_ip != None:
LastStrength = signal LastStrength = signal
lock = '' #set the string to '' so that when it is put in "high-signal" + lock + ".png", there will be nothing lock = '' #set the string to '' so that when it is put in "high-signal" + lock + ".png", there will be nothing
curNetID = wireless.GetCurrentNetworkID() #the network ID needs to be checked because a negative value here will break the tray curNetID = wireless.GetCurrentNetworkID() #the network ID needs to be checked because a negative value here will break the tray
@@ -125,32 +134,38 @@ def set_signal_image():
tr.set_from_file("images/bad-signal" + lock + ".png") tr.set_from_file("images/bad-signal" + lock + ".png")
elif signal == 0: elif signal == 0:
tr.set_from_file("images/no-signal.png") tr.set_from_file("images/no-signal.png")
#Auto-reconnect code - not sure how well this works. I know that without the ForcedDisconnect check it reconnects you when auto_reconnect()
#a disconnect is forced. People who have disconnection problems need to test it to determine if it actually works.
#First it will attempt to reconnect to the last known wireless network, and if that fails it should run a scan and try to
#connect to any network set to autoconnect.
if wireless.GetAutoReconnect() == True and wireless.CheckIfWirelessConnecting() == False and wireless.GetForcedDisconnect() == False:
curNetID = wireless.GetCurrentNetworkID()
if curNetID > -1:
wireless.ConnectWireless(wireless.GetCurrentNetworkID())
print 'Trying to autoreconnect'
while wireless.CheckIfWirelessConnecting() == True:
time.sleep(1)
if wireless.GetCurrentSignalStrength() != 0:
print "Successfully autoreconnected."
else:
print "Couldn't reconnect to last used network, scanning for an autoconnect network..."
print wireless.AutoConnect(True)
elif wireless_ip == None: elif wireless_ip == None and wired_ip == None:
tr.set_from_file("images/no-signal.png") tr.set_from_file("images/no-signal.png")
tr.set_tooltip(language['not_connected']) tr.set_tooltip(language['not_connected'])
auto_reconnect()
if not daemon.GetDebugMode(): if not daemon.GetDebugMode():
config.EnableLogging() config.EnableLogging()
return True return True
def auto_reconnect():
#Auto-reconnect code - not sure how well this works. I know that without the ForcedDisconnect check it reconnects you when
#a disconnect is forced. People who have disconnection problems need to test it to determine if it actually works.
#First it will attempt to reconnect to the last known wireless network, and if that fails it should run a scan and try to
#connect to a wired network or any wireless network set to autoconnect.
if wireless.GetAutoReconnect() == True and daemon.CheckIfConnecting() == False and wireless.GetForcedDisconnect() == False:
curNetID = wireless.GetCurrentNetworkID()
print 'Trying to autoreconnect to last used network'
if curNetID > -1:
wireless.ConnectWireless(curNetID)
while wireless.CheckIfWirelessConnecting() == True:
time.sleep(1)
if wireless.GetCurrentSignalStrength() != 0:
print "Successfully autoreconnected."
else:
print "Couldn't reconnect to last used network, scanning for an autoconnect network..."
daemon.AutoConnect(True)
else:
daemon.AutoConnect(True)
class TrackerStatusIcon(gtk.StatusIcon): class TrackerStatusIcon(gtk.StatusIcon):
def __init__(self): def __init__(self):
gtk.StatusIcon.__init__(self) gtk.StatusIcon.__init__(self)
@@ -184,6 +199,8 @@ class TrackerStatusIcon(gtk.StatusIcon):
self.set_visible(True) self.set_visible(True)
self.connect('activate', self.on_activate) self.connect('activate', self.on_activate)
self.connect('popup-menu', self.on_popup_menu) self.connect('popup-menu', self.on_popup_menu)
wireless.SetForcedDisconnect(False)
def on_activate(self, data): def on_activate(self, data):
open_wicd_gui() open_wicd_gui()

167
gui.py
View File

@@ -13,7 +13,7 @@ except:
print 'Missing GTK and gtk.glade. Aborting.' print 'Missing GTK and gtk.glade. Aborting.'
sys.exit(1) sys.exit(1)
import time, os, misc, gettext, locale, gobject, dbus, dbus.service import time, os, misc, gettext, locale, gobject, dbus, dbus.service,pango
if getattr(dbus, 'version', (0,0,0)) >= (0,41,0): if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
import dbus.glib import dbus.glib
@@ -131,6 +131,11 @@ language['use_ics'] = _('Activate Internet Connection Sharing')
language['default_wired'] = _('Use as default profile (overwrites any previous default)') language['default_wired'] = _('Use as default profile (overwrites any previous default)')
language['use_debug_mode'] = _('Enable debug mode') language['use_debug_mode'] = _('Enable debug mode')
language['use_global_dns'] = _('Use global DNS servers') language['use_global_dns'] = _('Use global DNS servers')
language['use_default_profile'] = _('Use default profile on wired auto-connect')
language['show_wired_list'] = _('Prompt for profile on wired auto-connect')
language['choose_wired_profile'] = _('Select or create a wired profile to connect with')
language['wired_network_found'] = _('Wired connection detected')
language['stop_showing_chooser'] = _('Stop Showing Autoconnect pop-up temporarily')
language['0'] = _('0') language['0'] = _('0')
language['1'] = _('1') language['1'] = _('1')
@@ -418,7 +423,6 @@ class NetworkEntry(gtk.Expander):
if stringToNone(netmask.get_text()) == None: #make sure the netmask is blank if stringToNone(netmask.get_text()) == None: #make sure the netmask is blank
netmask.set_text('255.255.255.0') #fill in the most common one netmask.set_text('255.255.255.0') #fill in the most common one
def resetStaticCheckboxes(self): def resetStaticCheckboxes(self):
#enable the right stuff #enable the right stuff
if not stringToNone(self.txtIP.get_text()) == None: if not stringToNone(self.txtIP.get_text()) == None:
@@ -491,14 +495,15 @@ class WiredNetworkEntry(NetworkEntry):
self.set_label(language['wired_network']) self.set_label(language['wired_network'])
self.resetStaticCheckboxes() self.resetStaticCheckboxes()
self.comboProfileNames = gtk.combo_box_entry_new_text() self.comboProfileNames = gtk.combo_box_entry_new_text()
self.isFullGUI = True
profileList = config.GetWiredProfileList() self.profileList = config.GetWiredProfileList()
if profileList: #make sure there is something in it... if self.profileList: #make sure there is something in it...
for x in config.GetWiredProfileList(): #add all the names to the combobox for x in config.GetWiredProfileList(): #add all the names to the combobox
self.comboProfileNames.append_text(x) self.comboProfileNames.append_text(x)
hboxTemp = gtk.HBox(False,0) self.hboxTemp = gtk.HBox(False,0)
hboxDef = gtk.HBox(False,0) hboxDef = gtk.HBox(False,0)
buttonOK = gtk.Button(stock=gtk.STOCK_ADD) self.buttonAdd = gtk.Button(stock=gtk.STOCK_ADD)
self.buttonDelete = gtk.Button(stock=gtk.STOCK_DELETE) self.buttonDelete = gtk.Button(stock=gtk.STOCK_DELETE)
self.profileHelp = gtk.Label(language['wired_network_instructions']) self.profileHelp = gtk.Label(language['wired_network_instructions'])
self.checkboxDefaultProfile = gtk.CheckButton(language['default_wired']) self.checkboxDefaultProfile = gtk.CheckButton(language['default_wired'])
@@ -509,15 +514,15 @@ class WiredNetworkEntry(NetworkEntry):
self.profileHelp.set_line_wrap(True) self.profileHelp.set_line_wrap(True)
self.vboxTop.pack_start(self.profileHelp,fill=False,expand=False) self.vboxTop.pack_start(self.profileHelp,fill=False,expand=False)
hboxTemp.pack_start(self.comboProfileNames,fill=True,expand=True) self.hboxTemp.pack_start(self.comboProfileNames,fill=True,expand=True)
hboxTemp.pack_start(buttonOK,fill=False,expand=False) self.hboxTemp.pack_start(self.buttonAdd,fill=False,expand=False)
hboxTemp.pack_start(self.buttonDelete,fill=False,expand=False) self.hboxTemp.pack_start(self.buttonDelete,fill=False,expand=False)
hboxDef.pack_start(self.checkboxDefaultProfile,fill=False,expand=False) hboxDef.pack_start(self.checkboxDefaultProfile,fill=False,expand=False)
buttonOK.connect("clicked",self.addProfile) #hook up our buttons self.buttonAdd.connect("clicked",self.addProfile) #hook up our buttons
self.buttonDelete.connect("clicked",self.removeProfile) self.buttonDelete.connect("clicked",self.removeProfile)
self.comboProfileNames.connect("changed",self.changeProfile) self.comboProfileNames.connect("changed",self.changeProfile)
self.vboxTop.pack_start(hboxTemp) self.vboxTop.pack_start(self.hboxTemp)
self.vboxTop.pack_start(hboxDef) self.vboxTop.pack_start(hboxDef)
if stringToBoolean(wired.GetWiredProperty("default")) == True: if stringToBoolean(wired.GetWiredProperty("default")) == True:
@@ -528,7 +533,7 @@ class WiredNetworkEntry(NetworkEntry):
self.show_all() self.show_all()
self.profileHelp.hide() self.profileHelp.hide()
if profileList != None: if self.profileList != None:
self.comboProfileNames.set_active(0) self.comboProfileNames.set_active(0)
print "wired profiles found" print "wired profiles found"
self.set_expanded(False) self.set_expanded(False)
@@ -557,9 +562,10 @@ class WiredNetworkEntry(NetworkEntry):
config.CreateWiredNetworkProfile(profileName) config.CreateWiredNetworkProfile(profileName)
self.comboProfileNames.prepend_text(profileName) self.comboProfileNames.prepend_text(profileName)
self.comboProfileNames.set_active(0) self.comboProfileNames.set_active(0)
self.buttonDelete.set_sensitive(True) if self.isFullGUI == True:
self.vboxAdvanced.set_sensitive(True) self.buttonDelete.set_sensitive(True)
self.higherLevel.connectButton.set_sensitive(True) self.vboxAdvanced.set_sensitive(True)
self.higherLevel.connectButton.set_sensitive(True)
def removeProfile(self,widget): def removeProfile(self,widget):
print "removing profile" print "removing profile"
@@ -570,9 +576,10 @@ class WiredNetworkEntry(NetworkEntry):
self.profileHelp.show() self.profileHelp.show()
entry = self.comboProfileNames.child entry = self.comboProfileNames.child
entry.set_text("") entry.set_text("")
self.buttonDelete.set_sensitive(False) if self.isFullGUI == True:
self.vboxAdvanced.set_sensitive(False) self.buttonDelete.set_sensitive(False)
self.higherLevel.connectButton.set_sensitive(False) self.vboxAdvanced.set_sensitive(False)
self.higherLevel.connectButton.set_sensitive(False)
else: else:
self.profileHelp.hide() self.profileHelp.hide()
@@ -585,7 +592,9 @@ class WiredNetworkEntry(NetworkEntry):
def changeProfile(self,widget): def changeProfile(self,widget):
if self.comboProfileNames.get_active() > -1: #this way the name doesn't change if self.comboProfileNames.get_active() > -1: #this way the name doesn't change
# #everytime someone types something in # #everytime someone types something in
if self.isFullGUI == False:
return
print "changing profile..." print "changing profile..."
profileName = self.comboProfileNames.get_active_text() profileName = self.comboProfileNames.get_active_text()
print profileName print profileName
@@ -761,30 +770,80 @@ class appGui:
def __init__(self): def __init__(self):
print "starting..." print "starting..."
gladefile = "data/wicd.glade" #two possibilities here, one is that the normal GUI should be opened, the other is that wired auto-connect
self.windowname = "gtkbench" #is set to prompt the user to select a profile. It's kind of hacked together, but it'll do.
self.wTree = gtk.glade.XML(gladefile) if daemon.GetNeedWiredProfileChooser() == True:
#profile chooser init block
#import and init WiredNetworkEntry to steal some of the functions and widgets it uses
wiredNetEntry = WiredNetworkEntry()
wiredNetEntry.__init__()
dialog = gtk.Dialog(title=language['wired_network_found'], flags = gtk.DIALOG_MODAL, buttons=(gtk.STOCK_CONNECT,1,gtk.STOCK_CANCEL,2))
dialog.set_has_separator(False)
dialog.set_size_request(400,150)
instructLabel = gtk.Label(language['choose_wired_profile'] + ':\n')
stoppopcheckbox = gtk.CheckButton(language['stop_showing_chooser'])
dic = { "refresh_clicked" : self.refresh_networks, "quit_clicked" : self.exit, 'disconnect_clicked' : self.disconnect_wireless, "main_exit" : self.exit, "cancel_clicked" : self.cancel_connect, "connect_clicked" : self.connect_hidden, "preferences_clicked" : self.settings_dialog, "about_clicked" : self.about_dialog, 'create_adhoc_network_button_button' : self.create_adhoc_network} wiredNetEntry.isFullGUI = False
self.wTree.signal_autoconnect(dic) instructLabel.set_alignment(0,0)
stoppopcheckbox.set_active(False)
#remove widgets that were added to the normal WiredNetworkEntry so that they can be added to the pop-up wizard
wiredNetEntry.vboxTop.remove(wiredNetEntry.hboxTemp)
wiredNetEntry.vboxTop.remove(wiredNetEntry.profileHelp)
dialog.vbox.pack_start(instructLabel,fill=False,expand=False)
dialog.vbox.pack_start(wiredNetEntry.profileHelp,fill=False,expand=False)
dialog.vbox.pack_start(wiredNetEntry.hboxTemp,fill=False,expand=False)
dialog.vbox.pack_start(stoppopcheckbox,fill=False,expand=False)
dialog.show_all()
wiredNetEntry.profileHelp.hide()
if wiredNetEntry.profileList != None:
wiredNetEntry.comboProfileNames.set_active(0)
print "wired profiles found"
else:
print "no wired profiles found"
wiredNetEntry.profileHelp.show()
response = dialog.run()
if response == 1:
print 'reading profile ', wiredNetEntry.comboProfileNames.get_active_text()
config.ReadWiredNetworkProfile(wiredNetEntry.comboProfileNames.get_active_text())
wired.ConnectWired()
dialog.destroy()
sys.exit(0)
else:
if stoppopcheckbox.get_active() == True:
wired.use_default_profile = 1 #so that the pop-up doesn't keep appearing if you cancel it
dialog.destroy()
sys.exit(0)
else:
#normal init block
gladefile = "data/wicd.glade"
self.windowname = "gtkbench"
self.wTree = gtk.glade.XML(gladefile)
#set some strings in the GUI - they may be translated dic = { "refresh_clicked" : self.refresh_networks, "quit_clicked" : self.exit, 'disconnect_clicked' : self.disconnect_wireless, "main_exit" : self.exit, "cancel_clicked" : self.cancel_connect, "connect_clicked" : self.connect_hidden, "preferences_clicked" : self.settings_dialog, "about_clicked" : self.about_dialog, 'create_adhoc_network_button_button' : self.create_adhoc_network}
self.wTree.signal_autoconnect(dic)
self.wTree.get_widget("label_instructions").set_label(language['select_a_network']) #set some strings in the GUI - they may be translated
#I don't know how to translate a menu entry
#more specifically, I don't know how to set a menu entry's text
#self.wTree.get_widget("connect_button").modify_text(language['hidden_network'])
self.wTree.get_widget("progressbar").set_text(language['connecting'])
self.network_list = self.wTree.get_widget("network_list_vbox") self.wTree.get_widget("label_instructions").set_label(language['select_a_network'])
self.status_area = self.wTree.get_widget("connecting_hbox") #I don't know how to translate a menu entry
self.status_bar = self.wTree.get_widget("statusbar") #more specifically, I don't know how to set a menu entry's text
self.refresh_networks(fresh=False) #self.wTree.get_widget("connect_button").modify_text(language['hidden_network'])
self.wTree.get_widget("progressbar").set_text(language['connecting'])
self.statusID = None self.network_list = self.wTree.get_widget("network_list_vbox")
self.status_area = self.wTree.get_widget("connecting_hbox")
self.status_bar = self.wTree.get_widget("statusbar")
self.refresh_networks(fresh=False)
gobject.timeout_add(300,self.update_statusbar) self.statusID = None
gobject.timeout_add(100,self.pulse_progress_bar)
gobject.timeout_add(300,self.update_statusbar)
gobject.timeout_add(100,self.pulse_progress_bar)
def create_adhoc_network(self,widget=None): def create_adhoc_network(self,widget=None):
'''shows a dialog that creates a new adhoc network''' '''shows a dialog that creates a new adhoc network'''
@@ -829,7 +888,7 @@ class appGui:
self.keyEntry.set_sensitive(self.useEncryptionCheckbox.get_active()) self.keyEntry.set_sensitive(self.useEncryptionCheckbox.get_active())
def disconnect_wireless(self,widget=None): def disconnect_wireless(self,widget=None):
wireless.DisconnectWireless() wireless.DisconnectWireless()
def about_dialog(self,widget,event=None): def about_dialog(self,widget,event=None):
dialog = gtk.AboutDialog() dialog = gtk.AboutDialog()
@@ -843,14 +902,18 @@ class appGui:
def settings_dialog(self,widget,event=None): def settings_dialog(self,widget,event=None):
dialog = gtk.Dialog(title=language['preferences'], flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_OK,1,gtk.STOCK_CANCEL,2)) dialog = gtk.Dialog(title=language['preferences'], flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_OK,1,gtk.STOCK_CANCEL,2))
dialog.set_has_separator(False) dialog.set_has_separator(False)
dialog.set_size_request(375,-1) dialog.set_size_request(465,-1)
wiredcheckbox = gtk.CheckButton(language['wired_always_on']) wiredcheckbox = gtk.CheckButton(language['wired_always_on'])
wiredcheckbox.set_active(wired.GetAlwaysShowWiredInterface()) wiredcheckbox.set_active(wired.GetAlwaysShowWiredInterface())
reconnectcheckbox = gtk.CheckButton(language['auto_reconnect']) reconnectcheckbox = gtk.CheckButton(language['auto_reconnect'])
reconnectcheckbox.set_active(wireless.GetAutoReconnect()) reconnectcheckbox.set_active(wireless.GetAutoReconnect())
debugmodecheckbox = gtk.CheckButton(language['use_debug_mode']) debugmodecheckbox = gtk.CheckButton(language['use_debug_mode'])
debugmodecheckbox.set_active(daemon.GetDebugMode()) debugmodecheckbox.set_active(daemon.GetDebugMode())
sepline = gtk.HSeparator()
usedefaultradiobutton = gtk.RadioButton(None,language['use_default_profile'],False)
showlistradiobutton = gtk.RadioButton(usedefaultradiobutton,language['show_wired_list'],False)
wpadriverlabel = SmallLabel(language['wpa_supplicant_driver'] + ':') wpadriverlabel = SmallLabel(language['wpa_supplicant_driver'] + ':')
wpadriverlabel.set_size_request(75,-1)
wpadrivercombo = gtk.combo_box_new_text() wpadrivercombo = gtk.combo_box_new_text()
wpadrivercombo.set_size_request(50,-1) wpadrivercombo.set_size_request(50,-1)
wpadrivers = [ "hostap","hermes","madwifi","atmel","wext","ndiswrapper","broadcom","ipw","ralink legacy" ] wpadrivers = [ "hostap","hermes","madwifi","atmel","wext","ndiswrapper","broadcom","ipw","ralink legacy" ]
@@ -875,6 +938,9 @@ class appGui:
entryWirelessInterface = LabelEntry(language['wireless_interface'] + ':') entryWirelessInterface = LabelEntry(language['wireless_interface'] + ':')
entryWiredInterface = LabelEntry(language['wired_interface'] + ':') entryWiredInterface = LabelEntry(language['wired_interface'] + ':')
entryWirelessInterface.label.set_size_request(260,-1)
entryWiredInterface.label.set_size_request(260,-1)
entryWiredAutoMethod = gtk.Label('Wired Autoconnection options:')
entryWirelessInterface.entry.set_text(daemon.GetWirelessInterface()) entryWirelessInterface.entry.set_text(daemon.GetWirelessInterface())
entryWiredInterface.entry.set_text(daemon.GetWiredInterface()) entryWiredInterface.entry.set_text(daemon.GetWiredInterface())
@@ -893,6 +959,13 @@ class appGui:
dns2Entry.set_text(noneToBlankString(dns_addresses[1])) dns2Entry.set_text(noneToBlankString(dns_addresses[1]))
dns3Entry.set_text(noneToBlankString(dns_addresses[2])) dns3Entry.set_text(noneToBlankString(dns_addresses[2]))
entryWiredAutoMethod.set_alignment(0,0)
sepline.set_size_request(2,8)
atrlist = pango.AttrList()
atrlist.insert(pango.AttrUnderline(pango.UNDERLINE_SINGLE,0,28))
atrlist.insert(pango.AttrWeight(pango.WEIGHT_BOLD,0,50))
entryWiredAutoMethod.set_attributes(atrlist)
dialog.vbox.pack_start(wpabox) dialog.vbox.pack_start(wpabox)
dialog.vbox.pack_start(entryWirelessInterface) dialog.vbox.pack_start(entryWirelessInterface)
dialog.vbox.pack_start(entryWiredInterface) dialog.vbox.pack_start(entryWiredInterface)
@@ -905,8 +978,13 @@ class appGui:
dialog.vbox.pack_start(wiredcheckbox) dialog.vbox.pack_start(wiredcheckbox)
dialog.vbox.pack_start(reconnectcheckbox) dialog.vbox.pack_start(reconnectcheckbox)
dialog.vbox.pack_start(debugmodecheckbox) dialog.vbox.pack_start(debugmodecheckbox)
dialog.vbox.pack_start(sepline)
dialog.vbox.pack_start(entryWiredAutoMethod)
dialog.vbox.pack_start(usedefaultradiobutton)
dialog.vbox.pack_start(showlistradiobutton)
dialog.vbox.set_spacing(5) dialog.vbox.set_spacing(5)
dialog.show_all() dialog.show_all()
response = dialog.run() response = dialog.run()
if response == 1: if response == 1:
daemon.SetUseGlobalDNS(useGlobalDNSCheckbox.get_active()) daemon.SetUseGlobalDNS(useGlobalDNSCheckbox.get_active())
@@ -918,6 +996,7 @@ class appGui:
wired.SetAlwaysShowWiredInterface(wiredcheckbox.get_active()) wired.SetAlwaysShowWiredInterface(wiredcheckbox.get_active())
wireless.SetAutoReconnect(reconnectcheckbox.get_active()) wireless.SetAutoReconnect(reconnectcheckbox.get_active())
daemon.SetDebugMode(debugmodecheckbox.get_active()) daemon.SetDebugMode(debugmodecheckbox.get_active())
wired.SetWiredAutoConnectMethod(usedefaultradiobutton.get_active())
dialog.destroy() dialog.destroy()
else: else:
dialog.destroy() dialog.destroy()
@@ -977,7 +1056,7 @@ class appGui:
if self.statusID: if self.statusID:
self.status_bar.remove(1,self.statusID) self.status_bar.remove(1,self.statusID)
#use the chain approach to save calls to external programs #use the chain approach to save calls to external programs
#external programs are quite CPU intensive #external programs are quite CPU intensive
if wireless_ip: if wireless_ip:
network = wireless.GetCurrentNetwork() network = wireless.GetCurrentNetwork()
if network: if network:
@@ -1084,10 +1163,8 @@ class appGui:
# Script info # Script info
before_script = networkentry.expander.txtBeforeScript.get_text() before_script = networkentry.expander.txtBeforeScript.get_text()
after_script = networkentry.expander.txtAfterScript.get_text() after_script = networkentry.expander.txtAfterScript.get_text()
wireless.SetWirelessProperty(networkid,"beforescript",noneToString(before_script)) wireless.SetWirelessBeforeScript(networkid,before_script)
wireless.SetWirelessProperty(networkid,"afterscript",noneToString(after_script)) wireless.SetWirelessAfterScript(networkid,after_script)
wireless.SetWirelessBeforeScript(before_script)
wireless.SetWirelessAfterScript(after_script)
# if it exists. maybe kept as a value in the network entry? Not sure... # if it exists. maybe kept as a value in the network entry? Not sure...
print "connecting to wireless network..." print "connecting to wireless network..."
@@ -1117,8 +1194,6 @@ class appGui:
#Script Info #Script Info
before_script = networkentry.expander.txtBeforeScript.get_text() before_script = networkentry.expander.txtBeforeScript.get_text()
after_script = networkentry.expander.txtAfterScript.get_text() after_script = networkentry.expander.txtAfterScript.get_text()
wired.SetWiredProperty("beforescript",noneToString(before_script))
wired.SetWiredProperty("afterscript",noneToString(after_script))
wired.SetWiredBeforeScript(before_script) wired.SetWiredBeforeScript(before_script)
wired.SetWiredAfterScript(after_script) wired.SetWiredAfterScript(after_script)

View File

@@ -39,15 +39,15 @@ class Wireless:
#init the regex patterns that will be used to search the output of iwlist scan for info #init the regex patterns that will be used to search the output of iwlist scan for info
#these are well tested, should work on most cards #these are well tested, should work on most cards
essid_pattern = re.compile('.*ESSID:"(.*?)"\n',re.DOTALL | re.I | re.M | re.S) essid_pattern = re.compile('.*ESSID:"(.*?)"\n',re.DOTALL | re.I | re.M | re.S)
ap_mac_pattern = re.compile('.*Address: (.*?)\n',re.DOTALL | re.I | re.M | re.S) ap_mac_pattern = re.compile('.*Address: (.*?)\n',re.DOTALL | re.I | re.M | re.S)
channel_pattern = re.compile('.*Channel:? ?(\d\d?)',re.DOTALL | re.I | re.M | re.S) channel_pattern = re.compile('.*Channel:? ?(\d\d?)',re.DOTALL | re.I | re.M | re.S)
strength_pattern = re.compile('.*Quality:?=? ?(\d\d*)',re.DOTALL | re.I | re.M | re.S) strength_pattern = re.compile('.*Quality:?=? ?(\d\d*)',re.DOTALL | re.I | re.M | re.S)
mode_pattern = re.compile('.*Mode:(.*?)\n',re.DOTALL | re.I | re.M | re.S) mode_pattern = re.compile('.*Mode:(.*?)\n',re.DOTALL | re.I | re.M | re.S)
wep_pattern = re.compile('.*Encryption key:(.*?)\n',re.DOTALL | re.I | re.M | re.S) wep_pattern = re.compile('.*Encryption key:(.*?)\n',re.DOTALL | re.I | re.M | re.S)
wpa1_pattern = re.compile('(WPA Version 1)',re.DOTALL | re.I | re.M | re.S) wpa1_pattern = re.compile('(WPA Version 1)',re.DOTALL | re.I | re.M | re.S)
wpa2_pattern = re.compile('(WPA2)',re.DOTALL | re.I | re.M | re.S) wpa2_pattern = re.compile('(WPA2)',re.DOTALL | re.I | re.M | re.S)
##### #####
## PREPARE THE INTERFACE ## PREPARE THE INTERFACE
@@ -139,7 +139,8 @@ class Wireless:
if len(info) < 5 or info == None or info == '': if len(info) < 5 or info == None or info == '':
break; break;
if info[2] == CurrentNetwork["essid"]: if info[2] == CurrentNetwork["essid"]:
if info[5] == 'WEP' or info[5] == 'OPEN': # Needs to be tested CurrentNetwork["encryption"] = True
if info[5] == 'WEP' or ((info[5] == 'OPEN' or info[5] == 'SHARED') and info[4] == 'WEP'): # Needs to be tested
CurrentNetwork["encryption_method"] = 'WEP' CurrentNetwork["encryption_method"] = 'WEP'
elif info[5] == 'WPA-PSK': elif info[5] == 'WPA-PSK':
CurrentNetwork["encrytion_method"] = 'WPA' CurrentNetwork["encrytion_method"] = 'WPA'
@@ -148,7 +149,7 @@ class Wireless:
else: else:
print 'Unknown AuthMode, can\'t assign encryption_method!!' print 'Unknown AuthMode, can\'t assign encryption_method!!'
CurrentNetwork["encryption_method"] = 'Unknown' CurrentNetwork["encryption_method"] = 'Unknown'
CurrentNetwork["quality"] = info[1][1:] #set link strength here CurrentNetwork["quality"] = info[1][1:] #set signal strength here (not link quality! dBm vs %)
else: else:
CurrentNetwork["encryption"] = False CurrentNetwork["encryption"] = False
#end If #end If
@@ -355,9 +356,17 @@ class Wireless:
if len(info) < 5 or info == None or info == '': #probably overkill, but the last 2 won't get run anyways if len(info) < 5 or info == None or info == '': #probably overkill, but the last 2 won't get run anyways
break; break;
if info[2] == network.get("essid"): if info[2] == network.get("essid"):
if info[5] == 'WEP' or info[5] == 'OPEN': # Needs to be tested if info[5] == 'WEP' or (info[5] == 'OPEN' and info[4] == 'WEP'): # Needs to be tested
print 'setting up WEP' print 'setting up WEP'
misc.Run("iwconfig " + self.wireless_interface + " key " + network.get('key')) misc.Run("iwconfig " + self.wireless_interface + " key " + network.get('key'))
elif info[5] == 'SHARED' and info[4] == 'WEP':
print 'setting up WEP'
misc.Run("iwpriv " + self.wireless_interface + " set NetworkType=" + info[6])
misc.Run("iwpriv " + self.wireless_interface + " set AuthMode=SHARED")
misc.Run("iwpriv " + self.wireless_interface + " set EncrypType=" + info[4])
misc.Run("iwpriv " + self.wireless_interface + " set Key1=" + network.get('key'))
misc.Run("iwpriv " + self.wireless_interface + " set DefaultKeyID=1")
misc.Run("iwpriv " + self.wireless_interface + " set SSID=" + info[2])
elif info[5] == 'WPA-PSK': elif info[5] == 'WPA-PSK':
print 'setting up WPA-PSK' print 'setting up WPA-PSK'
misc.Run("iwpriv " + self.wireless_interface + " set NetworkType=" + info[6]) misc.Run("iwpriv " + self.wireless_interface + " set NetworkType=" + info[6])
@@ -386,6 +395,21 @@ class Wireless:
print "setting the broadcast address..." + network["broadcast"] print "setting the broadcast address..." + network["broadcast"]
misc.Run("ifconfig " + self.wireless_interface + " broadcast " + network["broadcast"]) misc.Run("ifconfig " + self.wireless_interface + " broadcast " + network["broadcast"])
if not network.get("dns1") == None:
self.lock.acquire()
self.ConnectingMessage = 'setting_static_dns'
self.lock.release()
print "setting the first dns server...", network["dns1"]
resolv = open("/etc/resolv.conf","w")
misc.WriteLine(resolv,"nameserver " + network["dns1"])
if not network.get("dns2") == None:
print "setting the second dns server...", network["dns2"]
misc.WriteLine(resolv,"nameserver " + network["dns2"])
if not network.get("dns3") == None:
print "setting the third dns server..."
misc.WriteLine(resolv,"nameserver " + network["dns3"])
if not network.get('ip') == None: if not network.get('ip') == None:
self.lock.acquire() self.lock.acquire()
self.ConnectingMessage = 'setting_static_ip' self.ConnectingMessage = 'setting_static_ip'