1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-22 22:27:59 +01:00

Fixed bug where network entry settings weren't being saved correctly because of overloading the variable "type", which is a built in python function.

Cleaned up some formatting in gui.py and daemon.py
Fixed some bad daemon calls in the setting saving process.
This commit is contained in:
imdano
2008-02-05 13:46:42 +00:00
parent d46da02511
commit 98069ad994
2 changed files with 197 additions and 185 deletions

View File

@@ -554,13 +554,18 @@ class ConnectionWizard(dbus.service.Object):
@dbus.service.method('org.wicd.daemon.wireless')
def SetHiddenNetworkESSID(self, essid):
'''sets the ESSID of a hidden network for use with ConnectionWizard.Scan'''
''' Sets the ESSID of a hidden network for use with Scan(). '''
print 'setting hidden essid: ' + str(essid)
self.hidden_essid = str(misc.Noneify(essid))
@dbus.service.method('org.wicd.daemon.wireless')
def Scan(self):
'''scans for wireless networks, optionally using a (hidden) essid set with SetHiddenNetworkESSID'''
''' Scan for wireless networks.
Scans for wireless networks,optionally using a (hidden) essid
set with SetHiddenNetworkESSID.
'''
print 'scanning start'
scan = self.wifi.Scan(str(self.hidden_essid))
self.LastScan = scan

101
gui.py
View File

@@ -404,8 +404,8 @@ class PrettyWirelessNetworkEntry(PrettyNetworkEntry):
def setMACAddress(self, address):
self.expander.setMACAddress(address)
def setEncryption(self,on,type):
self.expander.setEncryption(on,type)
def setEncryption(self, on, ttype):
self.expander.setEncryption(on, ttype)
def setChannel(self, channel):
self.expander.setChannel(channel)
@@ -710,9 +710,9 @@ class WirelessNetworkEntry(NetworkEntry):
self.networkID = networkID
# Create the data labels
NetworkEntry.__init__(self)
print "ESSID : " + wireless.GetWirelessProperty(networkID,"essid")
self.set_label(wireless.GetWirelessProperty(networkID,"essid"))
self.essid = wireless.GetWirelessProperty(networkID, "essid")
print "ESSID : " + self.essid
self.set_label(self.essid)
# Make the vbox to hold the encryption stuff.
self.vboxEncryptionInformation = gtk.VBox(False, 0)
@@ -853,10 +853,10 @@ class WirelessNetworkEntry(NetworkEntry):
def setMACAddress(self, address):
self.lblMAC.set_label(str(address))
def setEncryption(self,on,type):
if on and type:
self.lblEncryption.set_label(str(type))
if on and not type:
def setEncryption(self, on, ttype):
if on and ttype:
self.lblEncryption.set_label(str(ttype))
if on and not ttype:
self.lblEncryption.set_label(language['secured'])
if not on:
self.lblEncryption.set_label(language['unsecured'])
@@ -1346,7 +1346,7 @@ class appGui:
self.network_list.pack_start(label)
label.show()
def save_settings(self, type, networkid, networkentry):
def save_settings(self, nettype, networkid, networkentry):
""" Verifies and saves the settings for the network entry. """
entry = networkentry.expander
entlist = []
@@ -1371,7 +1371,44 @@ class appGui:
return False
# Now save the settings.
if type == "wireless":
if nettype == "wireless":
self.save_wireless_settings(networkid, entry)
elif nettype == "wired":
self.save_wired_settings(entry)
return True
def save_wired_settings(self, entry):
if entry.checkboxStaticIP.get_active():
wired.SetWiredProperty("ip", noneToString(entry.txtIP.get_text()))
wired.SetWiredProperty("netmask", noneToString(entry.txtNetmask.get_text()))
wired.SetWiredProperty("gateway", noneToString(entry.txtGateway.get_text()))
else:
wired.SetWiredProperty("ip", '')
wired.SetWiredProperty("netmask", '')
wired.SetWiredProperty("gateway", '')
if entry.checkboxStaticDNS.get_active() and \
not entry.checkboxGlobalDNS.get_active():
wired.SetWiredProperty('use_static_dns', True)
wired.SetWiredProperty('use_global_dns', False)
wired.SetWiredProperty("dns1", noneToString(entry.txtDNS1.get_text()))
wired.SetWiredProperty("dns2", noneToString(entry.txtDNS2.get_text()))
wired.SetWiredProperty("dns3", noneToString(entry.txtDNS3.get_text()))
elif entry.checkboxStaticDNS.get_active() and \
entry.checkboxGlobalDNS.get_active():
wired.SetWiredProperty('use_static_dns', True)
wired.SetWiredProperty('use_global_dns', True)
else:
wired.SetWiredProperty('use_static_dns', False)
wired.SetWiredProperty("dns1", '')
wired.SetWiredProperty("dns2", '')
wired.SetWiredProperty("dns3", '')
config.SaveWiredNetworkProfile(entry.comboProfileNames.get_active_text())
def save_wireless_settings(self, networkid, entry):
print 'networkid', networkid
wireless.SetWirelessProperty(networkid, "automatic",
noneToString(entry.checkboxAutoConnect.get_active()))
@@ -1425,36 +1462,6 @@ class appGui:
config.SaveWirelessNetworkProfile(networkid)
elif type == "wired":
if entry.checkboxStaticIP.get_active():
wired.SetWiredProperty("ip", noneToString(entry.txtIP.get_text()))
wired.SetWiredProperty("netmask", noneToString(entry.txtNetmask.get_text()))
wired.SetWiredProperty("gateway", noneToString(entry.txtGateway.get_text()))
else:
wired.SetWiredProperty("ip", '')
wired.SetWiredProperty("netmask", '')
wired.SetWiredProperty("gateway", '')
if entry.checkboxStaticDNS.get_active() and \
not entry.checkboxGlobalDNS.get_active():
wireless.SetWiredProperty('use_static_dns', True)
wireless.SetWiredProperty('use_global_dns', False)
wired.SetWiredProperty("dns1", noneToString(entry.txtDNS1.get_text()))
wired.SetWiredProperty("dns2", noneToString(entry.txtDNS2.get_text()))
wired.SetWiredProperty("dns3", noneToString(entry.txtDNS3.get_text()))
elif entry.checkboxStaticDNS.get_active() and \
entry.checkboxGlobalDNS.get_active():
wireless.SetWiredProperty('use_static_dns', True)
wireless.SetWiredProperty('use_global_dns', True)
else:
wired.SetWiredProperty('use_static_dns', False)
wired.SetWiredProperty("dns1", '')
wired.SetWiredProperty("dns2", '')
wired.SetWiredProperty("dns3", '')
config.SaveWiredNetworkProfile(entry.comboProfileNames.get_active_text())
return True
def edit_advanced(self, widget, event, ttype, networkid, networkentry):
""" Display the advanced settings dialog.
@@ -1472,12 +1479,12 @@ class appGui:
dialog.vbox.pack_start(networkentry.expander.vboxAdvanced)
dialog.show_all()
while True:
if self.run_settings_dialog(dialog, networkid, networkentry):
if self.run_settings_dialog(dialog, ttype, networkid, networkentry):
break
dialog.vbox.remove(networkentry.expander.vboxAdvanced)
dialog.destroy()
def run_settings_dialog(self, dialog, networkid, networkentry):
def run_settings_dialog(self, dialog, nettype, networkid, networkentry):
""" Runs the settings dialog.
Runs the settings dialog and returns True if settings are saved
@@ -1486,23 +1493,23 @@ class appGui:
"""
result = dialog.run()
if result == gtk.RESPONSE_ACCEPT:
if self.save_settings(type, networkid, networkentry):
if self.save_settings(nettype, networkid, networkentry):
return True
else:
return False
return True
def connect(self, widget, event, type, networkid, networkentry):
def connect(self, widget, event, nettype, networkid, networkentry):
""" Initiates the connection process in the daemon. """
cancelButton = self.wTree.get_widget("cancel_button")
cancelButton.set_sensitive(True)
if not self.save_settings(type, networkid, networkentry):
if not self.save_settings(nettype, networkid, networkentry):
return False
if type == "wireless":
if nettype == "wireless":
wireless.ConnectWireless(networkid)
elif type == "wired":
elif nettype == "wired":
wired.ConnectWired()
def exit(self, widget=None, event=None):