mirror of
https://github.com/gryf/wicd.git
synced 2025-12-20 04:48: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')
|
||||
daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon')
|
||||
|
||||
def reply_handle(r):
|
||||
pass
|
||||
def error_handle(e):
|
||||
pass
|
||||
|
||||
print daemon.Hello()
|
||||
time.sleep(3)
|
||||
daemon.SetSuspend(False)
|
||||
if daemon.CheckIfConnecting() == False:
|
||||
print daemon.AutoConnect(True)
|
||||
daemon.SetForcedDisconnect(False)
|
||||
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 os
|
||||
import gtk
|
||||
import ConfigParser
|
||||
import dbus
|
||||
import dbus.service
|
||||
import gtk.glade
|
||||
|
||||
import wpath
|
||||
@@ -184,4 +184,7 @@ def main (argv):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if os.getuid() != 0:
|
||||
print "Root priviledges are required to configure scripts. Exiting."
|
||||
sys.exit(0)
|
||||
main(sys.argv)
|
||||
|
||||
26
daemon.py
26
daemon.py
@@ -371,13 +371,15 @@ class ConnectionWizard(dbus.service.Object):
|
||||
elif self.GetWiredAutoConnectMethod() == 1:
|
||||
network = self.GetDefaultWiredNetwork()
|
||||
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()
|
||||
return
|
||||
else: # Assume its last-used.
|
||||
network = self.GetLastUsedWiredNetwork()
|
||||
if not network:
|
||||
print "no previous wired profile available, wired autoconnect failed."
|
||||
print "no previous wired profile available, wired " + \
|
||||
"autoconnect failed."
|
||||
self._wireless_autoconnect()
|
||||
return
|
||||
self.ReadWiredNetworkProfile(network)
|
||||
@@ -393,18 +395,19 @@ class ConnectionWizard(dbus.service.Object):
|
||||
|
||||
def _wireless_autoconnect(self):
|
||||
""" Attempts to autoconnect to a wireless network. """
|
||||
print "No wired connection present, attempting to autoconnect \
|
||||
to wireless network"
|
||||
print "No wired connection present, attempting to autoconnect" + \
|
||||
"to wireless network"
|
||||
if self.GetWirelessInterface() is None:
|
||||
print 'autoconnect failed because wireless interface returned None'
|
||||
print 'Autoconnect failed because wireless interface returned None'
|
||||
return
|
||||
|
||||
for x, network in enumerate(self.LastScan):
|
||||
if bool(self.LastScan[x]["has_profile"]):
|
||||
print self.LastScan[x]["essid"] + ' has profile'
|
||||
if bool(self.LastScan[x].get('automatic')):
|
||||
print 'trying to automatically connect to...', \
|
||||
self.LastScan[x]["essid"]
|
||||
if bool(network["has_profile"]):
|
||||
if self.debug_mode:
|
||||
print network["essid"] + ' has profile'
|
||||
if bool(network.get('automatic')):
|
||||
print 'trying to automatically connect to...' + \
|
||||
network["essid"]
|
||||
self.ConnectWireless(x)
|
||||
time.sleep(1)
|
||||
return
|
||||
@@ -597,7 +600,6 @@ 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 Scan(). """
|
||||
print 'setting hidden essid: ' + str(essid)
|
||||
self.hidden_essid = str(misc.Noneify(essid))
|
||||
|
||||
@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,
|
||||
ics):
|
||||
""" 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,
|
||||
ics)
|
||||
|
||||
@@ -1253,7 +1254,6 @@ class ConnectionWizard(dbus.service.Object):
|
||||
self.SetSignalDisplayType(self.get_option("Settings",
|
||||
"signal_display_type",
|
||||
default=0))
|
||||
|
||||
else:
|
||||
# Write some defaults maybe?
|
||||
print "Configuration file not found, creating, adding defaults..."
|
||||
|
||||
7
gui.py
7
gui.py
@@ -31,6 +31,8 @@ import gobject
|
||||
import dbus
|
||||
import dbus.service
|
||||
import pango
|
||||
import gtk
|
||||
import gtk.glade
|
||||
|
||||
import misc
|
||||
import wpath
|
||||
@@ -42,11 +44,6 @@ try:
|
||||
pygtk.require("2.0")
|
||||
except:
|
||||
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):
|
||||
import dbus.glib
|
||||
|
||||
15
monitor.py
15
monitor.py
@@ -216,7 +216,8 @@ class ConnectionStatus():
|
||||
# First try connecting through ethernet
|
||||
if wired.CheckPluggedIn():
|
||||
print "Wired connection available, trying to connect..."
|
||||
daemon.AutoConnect(False)
|
||||
daemon.AutoConnect(False, reply_handler=reply_handle,
|
||||
error_handler=err_handle)
|
||||
self.reconnecting = False
|
||||
return
|
||||
|
||||
@@ -231,11 +232,19 @@ class ConnectionStatus():
|
||||
elif not wireless.CheckIfWirelessConnecting():
|
||||
print "Couldn't reconnect to last used network, \
|
||||
scanning for an autoconnect network..."
|
||||
daemon.AutoConnect(True)
|
||||
daemon.AutoConnect(True, reply_handler=reply_handle,
|
||||
error_handler=err_handle)
|
||||
else:
|
||||
daemon.AutoConnect(True)
|
||||
daemon.AutoConnect(True, reply_handler=reply_handle,
|
||||
error_handler=err_handle)
|
||||
self.reconnecting = False
|
||||
|
||||
def reply_handle(r):
|
||||
pass
|
||||
|
||||
def err_handle(e):
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
monitor = ConnectionStatus()
|
||||
|
||||
6
wicd.py
6
wicd.py
@@ -111,7 +111,7 @@ language['killswitch_enabled'] = _('Wireless Kill Switch Enabled')
|
||||
language['connecting'] = _('Connecting')
|
||||
language['wired'] = _('Wired Network')
|
||||
|
||||
class TrayIcon():
|
||||
class TrayIcon:
|
||||
""" Base Tray Icon class.
|
||||
|
||||
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)
|
||||
|
||||
|
||||
class TrayConnectionInfo():
|
||||
class TrayConnectionInfo:
|
||||
""" Class for updating the tray icon status. """
|
||||
def __init__(self, tr, use_tray=True):
|
||||
""" Initialize variables needed for the icon status methods. """
|
||||
@@ -233,7 +233,7 @@ class TrayIcon():
|
||||
self.tr.set_from_file(img_file)
|
||||
|
||||
|
||||
class TrayIconGUI():
|
||||
class TrayIconGUI:
|
||||
""" Base Tray Icon UI class.
|
||||
|
||||
Implements methods and variables used by both egg/StatusIcon
|
||||
|
||||
@@ -204,7 +204,7 @@ class Interface(object):
|
||||
|
||||
"""
|
||||
cmd = 'ifconfig ' + self.iface + ' up'
|
||||
if self.verbose: print cmd
|
||||
#if self.verbose: print cmd
|
||||
misc.Run(cmd)
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user