mirror of
https://github.com/gryf/wicd.git
synced 2025-12-20 12:58:07 +01:00
Added mhenze's patch to add last used wired profile
This commit is contained in:
43
daemon.py
43
daemon.py
@@ -330,6 +330,19 @@ class ConnectionWizard(dbus.service.Object):
|
||||
if self.GetWiredAutoConnectMethod() == 2:
|
||||
#self.SetNeedWiredProfileChooser(True)
|
||||
self.LaunchChooser()
|
||||
elif self.GetWiredAutoConnectMethod() == 3:
|
||||
lastUsedNetwork = self.GetLastUsedWiredNetwork()
|
||||
if lastUsedNetwork != None:
|
||||
self.ReadWiredNetworkProfile(lastUsedNetwork)
|
||||
self.wired.profilename = lastUsedNetwork
|
||||
self.ConnectWired()
|
||||
time.sleep(1)
|
||||
print "Attempting to autoconnect with last used wired interface..."
|
||||
while self.CheckIfWiredConnecting(): #Leaving this for wired since you're probably not going to have DHCP problems
|
||||
time.sleep(1)
|
||||
print "...done autoconnecting with last used wired connection."
|
||||
else:
|
||||
print "there is no last used wired connection, wired autoconnect failed"
|
||||
else:
|
||||
defaultNetwork = self.GetDefaultWiredNetwork()
|
||||
if defaultNetwork != None:
|
||||
@@ -740,6 +753,7 @@ class ConnectionWizard(dbus.service.Object):
|
||||
'''sets which method the user wants to autoconnect to wired networks'''
|
||||
# 1 = default profile
|
||||
# 2 = show list
|
||||
# 3 = last used profile
|
||||
print 'wired autoconnection method is',method
|
||||
config = ConfigParser.ConfigParser()
|
||||
config.read(self.app_conf)
|
||||
@@ -862,6 +876,22 @@ class ConnectionWizard(dbus.service.Object):
|
||||
return True
|
||||
#end function CreateWiredNetworkProfile
|
||||
|
||||
@dbus.service.method('org.wicd.daemon.config')
|
||||
def UnsetWiredLastUsed(self):
|
||||
'''Unsets the last used option in the current default wired profile'''
|
||||
config = ConfigParser.ConfigParser()
|
||||
config.read(self.wired_conf)
|
||||
profileList = config.sections()
|
||||
print "profileList = ",profileList
|
||||
for profile in profileList:
|
||||
print "profile = ", profile
|
||||
if config.has_option(profile,"lastused"):
|
||||
if config.get(profile,"lastused") == "True":
|
||||
print "removing existing lastused"
|
||||
config.set(profile,"lastused", False)
|
||||
self.SaveWiredNetworkProfile(profile)
|
||||
#end function UnsetWiredLastUsed
|
||||
|
||||
@dbus.service.method('org.wicd.daemon.config')
|
||||
def UnsetWiredDefault(self):
|
||||
'''Unsets the default option in the current default wired profile'''
|
||||
@@ -877,6 +907,8 @@ class ConnectionWizard(dbus.service.Object):
|
||||
config.set(profile,"default", False)
|
||||
self.SaveWiredNetworkProfile(profile)
|
||||
#end function UnsetWiredDefault
|
||||
|
||||
|
||||
|
||||
@dbus.service.method('org.wicd.daemon.config')
|
||||
def GetDefaultWiredNetwork(self):
|
||||
@@ -890,6 +922,17 @@ class ConnectionWizard(dbus.service.Object):
|
||||
return profile
|
||||
return None
|
||||
|
||||
@dbus.service.method('org.wicd.daemon.config')
|
||||
def GetLastUsedWiredNetwork(self):
|
||||
config = ConfigParser.ConfigParser()
|
||||
config.read(self.wired_conf)
|
||||
profileList = config.sections()
|
||||
for profile in profileList:
|
||||
if config.has_option(profile,"lastused"):
|
||||
if config.get(profile,"lastused") == "True":
|
||||
return profile
|
||||
return None
|
||||
|
||||
@dbus.service.method('org.wicd.daemon.config')
|
||||
def DeleteWiredNetworkProfile(self,profilename):
|
||||
''' Deletes a wired network profile '''
|
||||
|
||||
17
gui.py
17
gui.py
@@ -137,6 +137,7 @@ language['use_debug_mode'] = _('Enable debug mode')
|
||||
language['use_global_dns'] = _('Use global DNS servers')
|
||||
language['use_default_profile'] = _('Use default profile on wired autoconnect')
|
||||
language['show_wired_list'] = _('Prompt for profile on wired autoconnect')
|
||||
language['use_last_used_profile'] =_ ('Use last used profile on wired autoconnect')
|
||||
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')
|
||||
@@ -986,12 +987,16 @@ class appGui:
|
||||
sepline = gtk.HSeparator()
|
||||
usedefaultradiobutton = gtk.RadioButton(None,language['use_default_profile'],False)
|
||||
showlistradiobutton = gtk.RadioButton(usedefaultradiobutton,language['show_wired_list'],False)
|
||||
lastusedradiobutton = gtk.RadioButton(usedefaultradiobutton,language['use_last_used_profile'],False)
|
||||
if wired.GetWiredAutoConnectMethod() == 1:
|
||||
usedefaultradiobutton.set_active(True)
|
||||
print 'use default profile'
|
||||
elif wired.GetWiredAutoConnectMethod() == 2:
|
||||
print 'show list'
|
||||
showlistradiobutton.set_active(True)
|
||||
elif wired.GetWiredAutoConnectMethod() == 3:
|
||||
print 'use last used profile'
|
||||
lastusedradiobutton.set_active(True)
|
||||
wpadriverlabel = SmallLabel(language['wpa_supplicant_driver'] + ':')
|
||||
wpadriverlabel.set_size_request(75,-1)
|
||||
wpadrivercombo = gtk.combo_box_new_text()
|
||||
@@ -1066,6 +1071,7 @@ class appGui:
|
||||
dialog.vbox.pack_start(entryWiredAutoMethod)
|
||||
dialog.vbox.pack_start(usedefaultradiobutton)
|
||||
dialog.vbox.pack_start(showlistradiobutton)
|
||||
dialog.vbox.pack_start(lastusedradiobutton)
|
||||
dialog.vbox.set_spacing(5)
|
||||
dialog.show_all()
|
||||
|
||||
@@ -1079,10 +1085,17 @@ class appGui:
|
||||
daemon.SetWPADriver(wpadrivers[wpadrivercombo.get_active()])
|
||||
wired.SetAlwaysShowWiredInterface(wiredcheckbox.get_active())
|
||||
wireless.SetAutoReconnect(reconnectcheckbox.get_active())
|
||||
|
||||
daemon.SetDebugMode(debugmodecheckbox.get_active())
|
||||
daemon.SetSignalDisplayType(displaytypecheckbox.get_active())
|
||||
wired.SetWiredAutoConnectMethod(int(showlistradiobutton.get_active())+1) #if option is default profile, showlist will be 0, so 0 + 1 = 1
|
||||
#if option is showlist, showlist will be 1, so 1+1 = 2 :)
|
||||
|
||||
if showlistradiobutton.get_active():
|
||||
wired.SetWiredAutoConnectMethod(2)
|
||||
elif lastusedradiobutton.get_active():
|
||||
wired.SetWiredAutoConnectMethod(3)
|
||||
else:
|
||||
wired.SetWiredAutoConnectMethod(1)
|
||||
|
||||
dialog.destroy()
|
||||
else:
|
||||
dialog.destroy()
|
||||
|
||||
@@ -469,6 +469,12 @@ class WirelessConnectThread(ConnectThread):
|
||||
else:
|
||||
wnettools.SetDNS(self.network.get('dns1'),
|
||||
self.network.get('dns2'), self.network.get('dns3'))
|
||||
|
||||
#save as last used profile
|
||||
print 'Saving last used profile'
|
||||
config.UnsetLastUsedDefault() # Makes sure there is only one last used profile at a time
|
||||
self.network.SetWiredProperty("lastused",True)
|
||||
config.SaveWiredNetworkProfile(self.profilename)
|
||||
|
||||
#execute post-connection script if necessary
|
||||
if misc.Noneify(self.after_script):
|
||||
|
||||
Reference in New Issue
Block a user