mirror of
https://github.com/gryf/wicd.git
synced 2025-12-19 20:38:00 +01:00
Made calls to Autoconnect outside the daemon asynchronous.
Removed some unnecessary print statements. Added checks to the daemon and configscript.py to make sure the user opening it is root. Fixed formatting problems in class definitions in wicd.py
This commit is contained in:
@@ -24,8 +24,15 @@ bus = dbus.SystemBus()
|
|||||||
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
||||||
daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon')
|
daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon')
|
||||||
|
|
||||||
|
def reply_handle(r):
|
||||||
|
pass
|
||||||
|
def error_handle(e):
|
||||||
|
pass
|
||||||
|
|
||||||
print daemon.Hello()
|
print daemon.Hello()
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
daemon.SetSuspend(False)
|
daemon.SetSuspend(False)
|
||||||
if daemon.CheckIfConnecting() == False:
|
daemon.SetForcedDisconnect(False)
|
||||||
print daemon.AutoConnect(True)
|
if not daemon.CheckIfConnecting():
|
||||||
|
print daemon.AutoConnect(True, reply_handler=reply_handle,
|
||||||
|
error_handler=error_handle)
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ run as the current user.
|
|||||||
#
|
#
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
import gtk
|
import gtk
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import dbus
|
import dbus
|
||||||
import dbus.service
|
|
||||||
import gtk.glade
|
import gtk.glade
|
||||||
|
|
||||||
import wpath
|
import wpath
|
||||||
@@ -184,4 +184,7 @@ def main (argv):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
if os.getuid() != 0:
|
||||||
|
print "Root priviledges are required to configure scripts. Exiting."
|
||||||
|
sys.exit(0)
|
||||||
main(sys.argv)
|
main(sys.argv)
|
||||||
|
|||||||
26
daemon.py
26
daemon.py
@@ -371,13 +371,15 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
elif self.GetWiredAutoConnectMethod() == 1:
|
elif self.GetWiredAutoConnectMethod() == 1:
|
||||||
network = self.GetDefaultWiredNetwork()
|
network = self.GetDefaultWiredNetwork()
|
||||||
if not network:
|
if not network:
|
||||||
print "Couldn't find a default wired connection, wired autoconnect failed."
|
print "Couldn't find a default wired connection," + \
|
||||||
|
" wired autoconnect failed."
|
||||||
self._wireless_autoconnect()
|
self._wireless_autoconnect()
|
||||||
return
|
return
|
||||||
else: # Assume its last-used.
|
else: # Assume its last-used.
|
||||||
network = self.GetLastUsedWiredNetwork()
|
network = self.GetLastUsedWiredNetwork()
|
||||||
if not network:
|
if not network:
|
||||||
print "no previous wired profile available, wired autoconnect failed."
|
print "no previous wired profile available, wired " + \
|
||||||
|
"autoconnect failed."
|
||||||
self._wireless_autoconnect()
|
self._wireless_autoconnect()
|
||||||
return
|
return
|
||||||
self.ReadWiredNetworkProfile(network)
|
self.ReadWiredNetworkProfile(network)
|
||||||
@@ -393,18 +395,19 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
|
|
||||||
def _wireless_autoconnect(self):
|
def _wireless_autoconnect(self):
|
||||||
""" Attempts to autoconnect to a wireless network. """
|
""" Attempts to autoconnect to a wireless network. """
|
||||||
print "No wired connection present, attempting to autoconnect \
|
print "No wired connection present, attempting to autoconnect" + \
|
||||||
to wireless network"
|
"to wireless network"
|
||||||
if self.GetWirelessInterface() is None:
|
if self.GetWirelessInterface() is None:
|
||||||
print 'autoconnect failed because wireless interface returned None'
|
print 'Autoconnect failed because wireless interface returned None'
|
||||||
return
|
return
|
||||||
|
|
||||||
for x, network in enumerate(self.LastScan):
|
for x, network in enumerate(self.LastScan):
|
||||||
if bool(self.LastScan[x]["has_profile"]):
|
if bool(network["has_profile"]):
|
||||||
print self.LastScan[x]["essid"] + ' has profile'
|
if self.debug_mode:
|
||||||
if bool(self.LastScan[x].get('automatic')):
|
print network["essid"] + ' has profile'
|
||||||
print 'trying to automatically connect to...', \
|
if bool(network.get('automatic')):
|
||||||
self.LastScan[x]["essid"]
|
print 'trying to automatically connect to...' + \
|
||||||
|
network["essid"]
|
||||||
self.ConnectWireless(x)
|
self.ConnectWireless(x)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
return
|
return
|
||||||
@@ -597,7 +600,6 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
@dbus.service.method('org.wicd.daemon.wireless')
|
||||||
def SetHiddenNetworkESSID(self, essid):
|
def SetHiddenNetworkESSID(self, essid):
|
||||||
""" Sets the ESSID of a hidden network for use with 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))
|
self.hidden_essid = str(misc.Noneify(essid))
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
@dbus.service.method('org.wicd.daemon.wireless')
|
||||||
@@ -632,7 +634,6 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
def CreateAdHocNetwork(self, essid, channel, ip, enctype, key, encused,
|
def CreateAdHocNetwork(self, essid, channel, ip, enctype, key, encused,
|
||||||
ics):
|
ics):
|
||||||
""" Creates an ad-hoc network using user inputted settings. """
|
""" Creates an ad-hoc network using user inputted settings. """
|
||||||
print 'attempting to create ad-hoc network...'
|
|
||||||
self.wifi.CreateAdHocNetwork(essid, channel, ip, enctype, key, encused,
|
self.wifi.CreateAdHocNetwork(essid, channel, ip, enctype, key, encused,
|
||||||
ics)
|
ics)
|
||||||
|
|
||||||
@@ -1253,7 +1254,6 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
self.SetSignalDisplayType(self.get_option("Settings",
|
self.SetSignalDisplayType(self.get_option("Settings",
|
||||||
"signal_display_type",
|
"signal_display_type",
|
||||||
default=0))
|
default=0))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Write some defaults maybe?
|
# Write some defaults maybe?
|
||||||
print "Configuration file not found, creating, adding defaults..."
|
print "Configuration file not found, creating, adding defaults..."
|
||||||
|
|||||||
7
gui.py
7
gui.py
@@ -31,6 +31,8 @@ import gobject
|
|||||||
import dbus
|
import dbus
|
||||||
import dbus.service
|
import dbus.service
|
||||||
import pango
|
import pango
|
||||||
|
import gtk
|
||||||
|
import gtk.glade
|
||||||
|
|
||||||
import misc
|
import misc
|
||||||
import wpath
|
import wpath
|
||||||
@@ -42,11 +44,6 @@ try:
|
|||||||
pygtk.require("2.0")
|
pygtk.require("2.0")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
|
||||||
import gtk, gtk.glade
|
|
||||||
except:
|
|
||||||
print 'Missing GTK and gtk.glade. Aborting.'
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
15
monitor.py
15
monitor.py
@@ -216,7 +216,8 @@ class ConnectionStatus():
|
|||||||
# First try connecting through ethernet
|
# First try connecting through ethernet
|
||||||
if wired.CheckPluggedIn():
|
if wired.CheckPluggedIn():
|
||||||
print "Wired connection available, trying to connect..."
|
print "Wired connection available, trying to connect..."
|
||||||
daemon.AutoConnect(False)
|
daemon.AutoConnect(False, reply_handler=reply_handle,
|
||||||
|
error_handler=err_handle)
|
||||||
self.reconnecting = False
|
self.reconnecting = False
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -231,11 +232,19 @@ class ConnectionStatus():
|
|||||||
elif not wireless.CheckIfWirelessConnecting():
|
elif not wireless.CheckIfWirelessConnecting():
|
||||||
print "Couldn't reconnect to last used network, \
|
print "Couldn't reconnect to last used network, \
|
||||||
scanning for an autoconnect network..."
|
scanning for an autoconnect network..."
|
||||||
daemon.AutoConnect(True)
|
daemon.AutoConnect(True, reply_handler=reply_handle,
|
||||||
|
error_handler=err_handle)
|
||||||
else:
|
else:
|
||||||
daemon.AutoConnect(True)
|
daemon.AutoConnect(True, reply_handler=reply_handle,
|
||||||
|
error_handler=err_handle)
|
||||||
self.reconnecting = False
|
self.reconnecting = False
|
||||||
|
|
||||||
|
def reply_handle(r):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def err_handle(e):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
monitor = ConnectionStatus()
|
monitor = ConnectionStatus()
|
||||||
|
|||||||
6
wicd.py
6
wicd.py
@@ -111,7 +111,7 @@ language['killswitch_enabled'] = _('Wireless Kill Switch Enabled')
|
|||||||
language['connecting'] = _('Connecting')
|
language['connecting'] = _('Connecting')
|
||||||
language['wired'] = _('Wired Network')
|
language['wired'] = _('Wired Network')
|
||||||
|
|
||||||
class TrayIcon():
|
class TrayIcon:
|
||||||
""" Base Tray Icon class.
|
""" Base Tray Icon class.
|
||||||
|
|
||||||
Base Class for implementing a tray icon to display network status.
|
Base Class for implementing a tray icon to display network status.
|
||||||
@@ -125,7 +125,7 @@ class TrayIcon():
|
|||||||
self.icon_info = self.TrayConnectionInfo(self.tr, use_tray)
|
self.icon_info = self.TrayConnectionInfo(self.tr, use_tray)
|
||||||
|
|
||||||
|
|
||||||
class TrayConnectionInfo():
|
class TrayConnectionInfo:
|
||||||
""" Class for updating the tray icon status. """
|
""" Class for updating the tray icon status. """
|
||||||
def __init__(self, tr, use_tray=True):
|
def __init__(self, tr, use_tray=True):
|
||||||
""" Initialize variables needed for the icon status methods. """
|
""" Initialize variables needed for the icon status methods. """
|
||||||
@@ -233,7 +233,7 @@ class TrayIcon():
|
|||||||
self.tr.set_from_file(img_file)
|
self.tr.set_from_file(img_file)
|
||||||
|
|
||||||
|
|
||||||
class TrayIconGUI():
|
class TrayIconGUI:
|
||||||
""" Base Tray Icon UI class.
|
""" Base Tray Icon UI class.
|
||||||
|
|
||||||
Implements methods and variables used by both egg/StatusIcon
|
Implements methods and variables used by both egg/StatusIcon
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ class Interface(object):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
cmd = 'ifconfig ' + self.iface + ' up'
|
cmd = 'ifconfig ' + self.iface + ' up'
|
||||||
if self.verbose: print cmd
|
#if self.verbose: print cmd
|
||||||
misc.Run(cmd)
|
misc.Run(cmd)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user