mirror of
https://github.com/gryf/wicd.git
synced 2025-12-19 12:28:08 +01:00
Testing/Experimental:
- Move process renaming code to the misc module, and fix process ranming for 64 bit systems. (Thanks to Helber Maciel) - Move the error gtk method to the gui module. (Thanks to Helber Maciel) - Removed a debugging print statement from monitor.py - Fixed up a few docstrings/comments. Testing: - Fix bug where Connect button would become inactive after disconnecting from a network.
This commit is contained in:
10
daemon.py
10
daemon.py
@@ -57,15 +57,7 @@ import misc
|
||||
if __name__ == '__main__':
|
||||
wpath.chdir(__file__)
|
||||
|
||||
if sys.platform == 'linux2':
|
||||
# Set process name. Only works on Linux >= 2.1.57.
|
||||
try:
|
||||
import dl
|
||||
libc = dl.open('/lib/libc.so.6')
|
||||
libc.call('prctl', 15, 'wicd-daemon\0', 0, 0, 0) # 15 is PR_SET_NAME
|
||||
except:
|
||||
pass
|
||||
|
||||
misc.RenameProcess("wicd-daemon")
|
||||
|
||||
logging_enabled = True
|
||||
|
||||
|
||||
31
gui.py
31
gui.py
@@ -299,6 +299,15 @@ def checkboxTextboxToggle(checkbox, textboxes):
|
||||
# Really bad practice, but checkbox == self
|
||||
for textbox in textboxes:
|
||||
textbox.set_sensitive(checkbox.get_active())
|
||||
|
||||
|
||||
def error(parent, message):
|
||||
""" Shows an error dialog """
|
||||
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
|
||||
gtk.BUTTONS_OK)
|
||||
dialog.set_markup(message)
|
||||
dialog.run()
|
||||
dialog.destroy()
|
||||
|
||||
########################################
|
||||
##### NETWORK LIST CLASSES
|
||||
@@ -364,7 +373,7 @@ class AdvancedSettingsDialog(gtk.Dialog):
|
||||
if stringToNone(netmask.get_text()) is None: # Make sure the netmask is blank
|
||||
netmask.set_text('255.255.255.0') # Fill in the most common one
|
||||
elif ipAddress != "":
|
||||
misc.error(None, "Invalid IP Address Entered.")
|
||||
error(None, "Invalid IP Address Entered.")
|
||||
|
||||
def reset_static_checkboxes(self):
|
||||
# Enable the right stuff
|
||||
@@ -1517,7 +1526,7 @@ class appGui:
|
||||
enable_item.hide()
|
||||
disable_item.show()
|
||||
else:
|
||||
misc.error(self.window, "Failed to enable wireless interface.")
|
||||
error(self.window, "Failed to enable wireless interface.")
|
||||
|
||||
def on_disable_wireless(self, widget):
|
||||
""" Called when the Disable Wireless Interface button is clicked. """
|
||||
@@ -1528,7 +1537,7 @@ class appGui:
|
||||
enable_item.show()
|
||||
disable_item.hide()
|
||||
else:
|
||||
misc.error(self.window, "Failed to disable wireless interface.")
|
||||
error(self.window, "Failed to disable wireless interface.")
|
||||
|
||||
def on_enable_wired(self, widget):
|
||||
""" Called when the Enable Wired Interface button is clicked. """
|
||||
@@ -1539,7 +1548,7 @@ class appGui:
|
||||
enable_item.hide()
|
||||
disable_item.show()
|
||||
else:
|
||||
misc.error(self.window, "Failed to enable wired interface.")
|
||||
error(self.window, "Failed to enable wired interface.")
|
||||
|
||||
def on_disable_wired(self, widget):
|
||||
""" Called when the Disable Wired Interface button is clicked. """
|
||||
@@ -1550,7 +1559,7 @@ class appGui:
|
||||
enable_item.show()
|
||||
disable_item.hide()
|
||||
else:
|
||||
misc.error(self.window, "Failed to disable wired interface.")
|
||||
error(self.window, "Failed to disable wired interface.")
|
||||
|
||||
def cancel_connect(self, widget):
|
||||
""" Alerts the daemon to cancel the connection process. """
|
||||
@@ -1773,8 +1782,8 @@ class appGui:
|
||||
|
||||
for lblent in entlist:
|
||||
if not misc.IsValidIP(lblent.get_text()):
|
||||
misc.error(self.window, language['invalid_address'].
|
||||
replace('$A', lblent.label.get_label()))
|
||||
error(self.window, language['invalid_address'].
|
||||
replace('$A', lblent.label.get_label()))
|
||||
return False
|
||||
|
||||
# Now save the settings.
|
||||
@@ -1833,13 +1842,13 @@ class appGui:
|
||||
get_active()][1])
|
||||
for x in encryption_info:
|
||||
if encryption_info[x].get_text() == "":
|
||||
misc.error(self.window, language['encrypt_info_missing'])
|
||||
error(self.window, language['encrypt_info_missing'])
|
||||
return False
|
||||
entry.set_net_prop(x, noneToString(encryption_info[x].
|
||||
get_text()))
|
||||
elif not entry.chkbox_encryption.get_active() and \
|
||||
wireless.GetWirelessProperty(networkid, "encryption"):
|
||||
misc.error(self.window, language['enable_encryption'])
|
||||
error(self.window, language['enable_encryption'])
|
||||
return False
|
||||
else:
|
||||
print 'encryption is ' + str(wireless.GetWirelessProperty(networkid,
|
||||
@@ -1929,12 +1938,12 @@ class appGui:
|
||||
encryption_info = entry.encryption_info
|
||||
for x in encryption_info:
|
||||
if encryption_info[x].get_text() == "":
|
||||
misc.error(self.window, language['encrypt_info_missing'])
|
||||
error(self.window, language['encrypt_info_missing'])
|
||||
return False
|
||||
# Make sure the checkbox is checked when it should be
|
||||
elif not entry.chkbox_encryption.get_active() and \
|
||||
wireless.GetWirelessProperty(networkid, "encryption"):
|
||||
misc.error(self.window, language['enable_encryption'])
|
||||
error(self.window, language['enable_encryption'])
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
25
misc.py
25
misc.py
@@ -23,7 +23,6 @@ import locale
|
||||
import gettext
|
||||
import time
|
||||
import sys
|
||||
import gtk
|
||||
from subprocess import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
@@ -268,12 +267,20 @@ def to_unicode(x):
|
||||
else: # Just guess UTF-8
|
||||
ret = x.decode('utf-8', 'replace').encode('utf-8')
|
||||
return ret
|
||||
|
||||
def error(parent, message):
|
||||
""" Shows an error dialog """
|
||||
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
|
||||
gtk.BUTTONS_OK)
|
||||
dialog.set_markup(message)
|
||||
dialog.run()
|
||||
dialog.destroy()
|
||||
|
||||
def RenameProcess(new_name):
|
||||
if sys.platform != 'linux2':
|
||||
print 'Unsupported platform'
|
||||
return False
|
||||
try:
|
||||
import ctypes
|
||||
is_64 = os.path.exists('/lib64/libc.so.6')
|
||||
if is_64:
|
||||
libc = ctypes.CDLL('/lib64/libc.so.6')
|
||||
else:
|
||||
libc = ctypes.CDLL('/lib/libc.so.6')
|
||||
libc.prctl(15, new_name, 0, 0, 0)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
10
monitor.py
10
monitor.py
@@ -34,14 +34,7 @@ from dbus.mainloop.glib import DBusGMainLoop
|
||||
import wpath
|
||||
import misc
|
||||
|
||||
if sys.platform == 'linux2':
|
||||
# Set process name. Only works on Linux >= 2.1.57.
|
||||
try:
|
||||
import dl
|
||||
libc = dl.open('/lib/libc.so.6')
|
||||
libc.call('prctl', 15, 'wicd-monitor\0', 0, 0, 0) # 15 is PR_SET_NAME
|
||||
except:
|
||||
print 'Failed to set the process name'
|
||||
misc.RenameProcess("wicd-monitor")
|
||||
|
||||
if __name__ == '__main__':
|
||||
wpath.chdir(__file__)
|
||||
@@ -248,7 +241,6 @@ class ConnectionStatus():
|
||||
self.reconnecting = True
|
||||
daemon.SetCurrentInterface('')
|
||||
|
||||
print 'autoreconnect'
|
||||
if daemon.ShouldAutoReconnect():
|
||||
print 'Starting automatic reconnect process'
|
||||
self.last_reconnect_time = time.time()
|
||||
|
||||
7
setup.py
7
setup.py
@@ -19,9 +19,7 @@ from distutils.core import setup
|
||||
import os
|
||||
|
||||
data=[
|
||||
('/etc/acpi/resume.d', ['other/80-wicd-connect.sh']),
|
||||
('/etc/dbus-1/system.d', ['other/wicd.conf']),
|
||||
('/etc/acpi/suspend.d', ['other/50-wicd-suspend.sh']),
|
||||
('/usr/share/applications', ['other/hammer-00186ddbac.desktop']),
|
||||
('', ['launchdaemon.sh']),
|
||||
('/usr/share/pixmaps', ['other/wicd.png']),
|
||||
@@ -59,6 +57,11 @@ elif os.access('/etc/arch-release', os.F_OK):
|
||||
data.append(('/etc/rc.d', ['other/initscripts/arch/wicd']))
|
||||
elif os.access('/etc/slackware-version', os.F_OK):
|
||||
data.append(('/etc/rc.d', ['other/initscripts/slackware/wicd']))
|
||||
|
||||
# pm-utils and acpi stuff
|
||||
if os.access('/etc/acpi/', os.F_OK):
|
||||
data.append(('/etc/acpi/resume.d', ['other/80-wicd-connect.sh']))
|
||||
data.append(('/etc/acpi/suspend.d', ['other/50-wicd-suspend.sh']))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1027,7 +1027,7 @@ class WirelessInterface(Interface):
|
||||
process was successful.
|
||||
|
||||
NOTE: It's possible this could return False,
|
||||
even though in actuality wpa_supplicant just isn't
|
||||
though in reality wpa_supplicant just isn't
|
||||
finished yet.
|
||||
|
||||
Keyword arguments:
|
||||
|
||||
Reference in New Issue
Block a user