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

Added mhenze's patch to add last used wired profile

This commit is contained in:
compwiz18
2007-10-04 03:31:07 +00:00
parent 2aa36c7329
commit 8f2dfb5361
3 changed files with 64 additions and 2 deletions

View File

@@ -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 '''