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

experimental:

- Merge in changes (prefs.py, dbusmanager.py, clean up in daemon.py) from pluggablebackends.

pluggablebackends:
- Some minor cleanup.
This commit is contained in:
imdano
2008-08-23 14:50:50 +00:00
parent fedd44a5b0
commit 2261b25101
8 changed files with 495 additions and 458 deletions

242
daemon.py
View File

@@ -134,10 +134,7 @@ class ConnectionWizard(dbus.service.Object):
print "setting wired interface %s" % (str(interface))
self.wired.wired_interface = interface
self.wifi.wired_interface = interface
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.set("Settings","wired_interface", interface)
config.write(open(self.app_conf, "w"))
self.set_option("Settings", "wired_interface", interface)
@dbus.service.method('org.wicd.daemon')
def SetWirelessInterface(self, interface):
@@ -145,59 +142,42 @@ class ConnectionWizard(dbus.service.Object):
print "setting wireless interface %s" % (str(interface))
self.wifi.wireless_interface = interface
self.wired.wireless_interface = interface
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.set("Settings","wireless_interface", interface)
configfile = open(self.app_conf, "w")
config.write(configfile)
self.set_option("Settings", "wireless_interface", interface)
@dbus.service.method('org.wicd.daemon')
def SetWPADriver(self, driver):
""" Sets the wpa driver the wpa_supplicant will use. """
print "setting wpa driver", str(driver)
self.wifi.wpa_driver = driver
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.set("Settings","wpa_driver",driver)
configfile = open(self.app_conf, "w")
config.write(configfile)
self.set_option("Settings", "wpa_driver", driver)
@dbus.service.method('org.wicd.daemon')
def SetUseGlobalDNS(self, use):
""" Sets a boolean which determines if global DNS is enabled. """
print 'setting use global dns to', use
use = misc.to_bool(use)
print 'setting use global dns to boolean', use
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.set("Settings", "use_global_dns", use)
self.set_option("Settings", "use_global_dns", use)
self.use_global_dns = use
self.wifi.use_global_dns = use
self.wired.use_global_dns = use
configfile = open(self.app_conf, "w")
config.write(configfile)
@dbus.service.method('org.wicd.daemon')
def SetGlobalDNS(self, dns1=None, dns2=None, dns3=None):
""" Sets the global dns addresses. """
print "setting global dns"
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.set("Settings", "global_dns_1", misc.noneToString(dns1))
self.set_option("Settings", "global_dns_1", misc.noneToString(dns1))
self.dns1 = dns1
self.wifi.global_dns_1 = dns1
self.wired.global_dns_1 = dns1
config.set("Settings", "global_dns_2", misc.noneToString(dns2))
self.set_option("Settings", "global_dns_2", misc.noneToString(dns2))
self.dns2 = dns2
self.wifi.global_dns_2 = dns2
self.wired.global_dns_2 = dns2
config.set("Settings", "global_dns_3", misc.noneToString(dns3))
self.set_option("Settings", "global_dns_3", misc.noneToString(dns3))
self.dns3 = dns3
self.wifi.global_dns_3 = dns3
self.wired.global_dns_3 = dns3
print 'global dns servers are', dns1, dns2, dns3
configfile = open(self.app_conf, "w")
config.write(configfile)
@dbus.service.method('org.wicd.daemon')
def GetUseGlobalDNS(self):
@@ -222,11 +202,7 @@ class ConnectionWizard(dbus.service.Object):
@dbus.service.method('org.wicd.daemon')
def SetDebugMode(self, debug):
""" Sets if debugging mode is on or off. """
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.set("Settings", "debug_mode", debug)
configfile = open(self.app_conf, "w")
config.write(configfile)
self.set_option("Settings", "debug_mode", debug)
self.debug_mode = misc.to_bool(debug)
self.wifi.debug = self.debug_mode
self.wired.debug = self.debug_mode
@@ -257,11 +233,7 @@ class ConnectionWizard(dbus.service.Object):
@dbus.service.method('org.wicd.daemon')
def SetSignalDisplayType(self, value):
""" Sets the signal display type and writes it the wicd config file. """
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.set("Settings", "signal_display_type", value)
configfile = open(self.app_conf, "w")
config.write(configfile)
self.set_option("Settings", "signal_display_type", value)
self.signal_display_type = int(value)
@dbus.service.method('org.wicd.daemon')
@@ -385,10 +357,7 @@ class ConnectionWizard(dbus.service.Object):
"""
print 'setting automatically reconnect when connection drops'
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.set("Settings", "auto_reconnect", misc.to_bool(value))
config.write(open(self.app_conf, "w"))
self.set_option("Settings", "auto_reconnect", misc.to_bool(value))
self.auto_reconnect = misc.to_bool(value)
@dbus.service.method('org.wicd.daemon')
@@ -536,10 +505,7 @@ class ConnectionWizard(dbus.service.Object):
self.dhcp_client = int(client)
self.wifi.dhcp_client = int(client)
self.wired.dhcp_client = int(client)
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.set("Settings", "dhcp_client", client)
config.write(open(self.app_conf, "w"))
self.set_option("Settings", "dhcp_client", client)
@dbus.service.method('org.wicd.daemon')
def GetLinkDetectionTool(self):
@@ -550,10 +516,7 @@ class ConnectionWizard(dbus.service.Object):
def SetLinkDetectionTool(self, link_tool):
self.link_detect_tool = int(link_tool)
self.wired.link_tool = int(link_tool)
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.set("Settings", "link_detect_tool", link_tool)
config.write(open(self.app_conf, "w"))
self.set_option("Settings", "link_detect_tool", link_tool)
@dbus.service.method('org.wicd.daemon')
def GetFlushTool(self):
@@ -564,10 +527,7 @@ class ConnectionWizard(dbus.service.Object):
self.flush_tool = int(flush_tool)
self.wired.flush_tool = int(flush_tool)
self.wifi.flush_tool = int(flush_tool)
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.set("Settings", "flush_tool", flush_tool)
config.write(open(self.app_conf, "w"))
self.set_option("Settings", "flush_tool", flush_tool)
@dbus.service.signal(dbus_interface='org.wicd.daemon', signature='')
def LaunchChooser(self):
@@ -823,10 +783,7 @@ class ConnectionWizard(dbus.service.Object):
# 1 = default profile
# 2 = show list
# 3 = last used profile
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.set("Settings","wired_connect_mode", int(method))
config.write(open(self.app_conf, "w"))
self.set_option("Settings","wired_connect_mode", int(method))
self.wired_connect_mode = int(method)
@dbus.service.method('org.wicd.daemon.wired')
@@ -841,6 +798,16 @@ class ConnectionWizard(dbus.service.Object):
return self.wired.connecting_thread.GetStatus()
else:
return False
@dbus.service.method('org.wicd.daemon.wired')
def DetectWiredInterface(self):
""" Returns an automatically detected wireless interface. """
iface = self.wired.DetectWiredInterface()
if iface:
print 'automatically detected wired interface ' + str(iface)
else:
print "Couldn't detect a wired interface."
return str(iface)
@dbus.service.method('org.wicd.daemon.wired')
def SetWiredProperty(self, property, value):
@@ -883,11 +850,8 @@ class ConnectionWizard(dbus.service.Object):
@dbus.service.method('org.wicd.daemon.wired')
def SetAlwaysShowWiredInterface(self, value):
""" Sets always_show_wired_interface to the given value. """
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.set("Settings", "always_show_wired_interface",
misc.to_bool(value))
config.write(open(self.app_conf, "w"))
self.set_option("Settings", "always_show_wired_interface",
misc.to_bool(value))
self.always_show_wired_interface = misc.to_bool(value)
@dbus.service.method('org.wicd.daemon.wired')
@@ -1224,19 +1188,10 @@ class ConnectionWizard(dbus.service.Object):
default_height = 590
width_str = "pref_width"
height_str = "pref_height"
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
if config.has_section("Settings"):
if config.has_option("Settings", width_str):
width = config.get("Settings", width_str)
else:
width = default_width
if config.has_option("Settings", height_str):
height = config.get("Settings", height_str)
else:
height = default_height
width = self.get_option("Settings", width_str, default_width)
height = self.get_option("Settings", height_str, default_height)
size = []
size.append(int(width))
size.append(int(height))
@@ -1257,6 +1212,14 @@ class ConnectionWizard(dbus.service.Object):
if self.debug_mode:
print ''.join([text, " ", str(value)])
return value
def set_option(self, section, option, value):
""" Sets the given option to the given value. """
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.set(section, option, value)
configfile = open(self.app_conf, "w")
config.write(configfile)
def get_option(self, section, option, default=None):
""" Method for returning an option from manager-settings.conf.
@@ -1285,106 +1248,54 @@ class ConnectionWizard(dbus.service.Object):
values into memory.
"""
if os.path.isfile(self.app_conf):
iface = self.DetectWirelessInterface()
if not iface:
if self.debug_mode:
print "Failed to detect wireless interface, defaulting " + \
"to wlan0, unless a config entry already exists."
iface = "wlan0"
self.SetWirelessInterface(self.get_option("Settings",
"wireless_interface",
default=iface))
self.SetWiredInterface(self.get_option("Settings",
"wired_interface",
default="eth0"))
self.SetWPADriver(self.get_option("Settings", "wpa_driver",
default="wext"))
self.SetAlwaysShowWiredInterface(self.get_option("Settings",
"always_show_wired_interface",
default=False))
self.SetUseGlobalDNS(self.get_option("Settings", "use_global_dns",
default=False))
dns1 = self.get_option("Settings", "global_dns_1", default='None')
dns2 = self.get_option("Settings", "global_dns_2", default='None')
dns3 = self.get_option("Settings", "global_dns_3", default='None')
self.SetGlobalDNS(dns1, dns2, dns3)
self.SetAutoReconnect(self.get_option("Settings", "auto_reconnect",
default=False))
self.SetDebugMode(self.get_option("Settings", "debug_mode",
iface = self.DetectWirelessInterface()
if not iface: iface = 'wlan0'
self.SetWirelessInterface(self.get_option("Settings",
"wireless_interface",
default=iface))
iface = self.DetectWiredInterface()
if not iface: iface = 'eth0'
self.SetWiredInterface(self.get_option("Settings", "wired_interface",
default=iface))
self.SetWPADriver(self.get_option("Settings", "wpa_driver",
default="wext"))
self.SetAlwaysShowWiredInterface(self.get_option("Settings",
"always_show_wired_interface",
default=False))
self.SetUseGlobalDNS(self.get_option("Settings", "use_global_dns",
default=False))
dns1 = self.get_option("Settings", "global_dns_1", default='None')
dns2 = self.get_option("Settings", "global_dns_2", default='None')
dns3 = self.get_option("Settings", "global_dns_3", default='None')
self.SetGlobalDNS(dns1, dns2, dns3)
self.SetAutoReconnect(self.get_option("Settings", "auto_reconnect",
default=True))
self.SetDebugMode(self.get_option("Settings", "debug_mode",
default=False))
self.SetWiredAutoConnectMethod(self.get_option("Settings",
"wired_connect_mode",
default=1))
self.SetSignalDisplayType(self.get_option("Settings",
"signal_display_type",
default=0))
self.SetDHCPClient(self.get_option("Settings", "dhcp_client",
default=0))
self.SetLinkDetectionTool(self.get_option("Settings",
"link_detect_tool",
default=0))
self.SetFlushTool(self.get_option("Settings", "flush_tool",
default=0))
else:
# Write some defaults maybe?
print "Configuration file not found, creating, adding defaults..."
config = ConfigParser.ConfigParser()
config.read(self.app_conf)
config.add_section("Settings")
config.set("Settings", "wireless_interface", "wlan0")
config.set("Settings", "wired_interface", "eth0")
config.set("Settings", "always_show_wired_interface", "False")
config.set("Settings", "auto_reconnect", "False")
config.set("Settings", "debug_mode", "False")
config.set("Settings", "wired_connect_mode", "1")
config.set("Settings", "signal_display_type", "0")
config.set("Settings", "dhcp_client", "0")
config.set("Settings", "link_detect_tool", "0")
config.set("Settings", "flush_tool", "0")
config.set("Settings", "dns1", "None")
config.set("Settings", "dns2", "None")
config.set("Settings", "dns3", "None")
iface = self.DetectWirelessInterface()
if iface is not None:
config.set("Settings", "wireless_interface", iface)
else:
print "Couldn't detect a wireless interface, using wlan0..."
config.set("Settings", "wireless_interface", "wlan0")
config.set("Settings", "wpa_driver", "wext")
config.write(open(self.app_conf, "w"))
self.SetWirelessInterface(config.get("Settings",
"wireless_interface"))
self.SetWiredInterface(config.get("Settings",
"wired_interface"))
self.SetWPADriver(config.get("Settings",
"wpa_driver"))
self.SetDHCPClient(config.get("Settings", "dhcp_client"))
self.SetLinkDetectionTool(config.get("Settings",
"link_detect_tool"))
self.SetFlushTool(config.get("Settings", "flush_tool"))
self.SetAlwaysShowWiredInterface(False)
self.SetAutoReconnect(False)
self.SetDebugMode(False)
self.SetWiredAutoConnectMethod(1)
self.SetSignalDisplayType(0)
self.SetUseGlobalDNS(False)
self.SetGlobalDNS(None, None, None)
self.SetWiredAutoConnectMethod(self.get_option("Settings",
"wired_connect_mode",
default=1))
self.SetSignalDisplayType(self.get_option("Settings",
"signal_display_type",
default=0))
self.SetDHCPClient(self.get_option("Settings", "dhcp_client",
default=0))
self.SetLinkDetectionTool(self.get_option("Settings",
"link_detect_tool",
default=0))
self.SetFlushTool(self.get_option("Settings", "flush_tool", default=0))
if os.path.isfile(self.wireless_conf):
print "Wireless configuration file found..."
# Don't do anything since it is there
pass
else:
# We don't need to put anything in it, so just make it
print "Wireless configuration file not found, creating..."
open(self.wireless_conf, "w").close()
if os.path.isfile(self.wired_conf):
print "Wired configuration file found..."
# Don't do anything since it is there
pass
else:
print "Wired configuration file not found, creating a default..."
# Create the file and a default profile
@@ -1404,15 +1315,16 @@ class ConnectionWizard(dbus.service.Object):
os.chown(self.wired_conf, 0, 0)
print "Using wireless interface..." + self.GetWirelessInterface()
print "Using wired interface..." + self.GetWiredInterface()
def usage():
print """
wicd 1.5.0
wicd 1.6.0
wireless (and wired) connection daemon.
Arguments:
\t-s\t--no-scan\tDon't auto-scan/auto-connect.
\t-a\t--no-autoconnect\tDon't auto-scan/auto-connect.
\t-f\t--no-daemon\tDon't daemonize (run in foreground).
\t-e\t--no-stderr\tDon't redirect stderr.
\t-n\t--no-poll\tDon't monitor network status.

49
dbusmanager.py Normal file
View File

@@ -0,0 +1,49 @@
#!/usr/bin/env python
""" The wicd DBus Manager.
A module for storing wicd's dbus interfaces.
"""
#
# Copyright (C) 2007 Adam Blackburn
# Copyright (C) 2007 Dan O'Reilly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License Version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import dbus
class DBusManager(object):
def __init__(self):
self._bus = dbus.SystemBus()
self._dbus_ifaces = {}
def get_dbus_ifaces(self):
""" Returns a dict of dbus interfaces. """
return self._dbus_ifaces
def get_bus(self):
""" Returns the loaded SystemBus. """
return self._bus
def connect_to_dbus(self):
""" Connects to wicd's dbus interfaces and loads them into a dict. """
proxy_obj = self._bus.get_object("org.wicd.daemon", '/org/wicd/daemon')
daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon')
wireless = dbus.Interface(proxy_obj, 'org.wicd.daemon.wireless')
wired = dbus.Interface(proxy_obj, 'org.wicd.daemon.wired')
config = dbus.Interface(proxy_obj, 'org.wicd.daemon.config')
self._dbus_ifaces = {"daemon" : daemon, "wireless" : wireless,
"wired" : wired, "config" : config}

301
gui.py
View File

@@ -28,16 +28,18 @@ import os
import sys
import time
import gobject
import dbus
import dbus.service
import pango
import gtk
import gtk.glade
from dbus import DBusException
from dbus import version as dbus_version
import misc
import wpath
from misc import noneToString, noneToBlankString, stringToBoolean, checkboxTextboxToggle
from netentry import WiredNetworkEntry, WirelessNetworkEntry
import wpath
from prefs import PreferencesDialog
from dbusmanager import DBusManager
if __name__ == '__main__':
wpath.chdir(__file__)
@@ -48,28 +50,41 @@ try:
except:
pass
if getattr(dbus, 'version', (0, 0, 0)) < (0, 80, 0):
if not dbus_version or (dbus_version < (0, 80, 0)):
import dbus.glib
else:
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
proxy_obj, daemon, wireless, wired, vpn_session, config = [None for x in
proxy_obj, daemon, wireless, wired, bus, config = [None for x in
range(0, 6)]
dbus_ifaces = {}
language = misc.get_language_list_gui()
def setup_dbus():
global proxy_obj, daemon, wireless, wired, vpn_session, config, dbus_ifaces
proxy_obj = bus.get_object("org.wicd.daemon", '/org/wicd/daemon')
daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon')
wireless = dbus.Interface(proxy_obj, 'org.wicd.daemon.wireless')
wired = dbus.Interface(proxy_obj, 'org.wicd.daemon.wired')
vpn_session = dbus.Interface(proxy_obj, 'org.wicd.daemon.vpn')
config = dbus.Interface(proxy_obj, 'org.wicd.daemon.config')
dbus_ifaces = {"daemon" : daemon, "wireless" : wireless, "wired" : wired,
"vpn_session" : vpn_session, "config" : config}
def setup_dbus(dbus_man=None):
global bus, daemon, wireless, wired, config, dbus_manager
if dbus_man:
dbus_manager = dbus_man
else:
dbus_manager = DBusManager()
try:
dbus_manager.connect_to_dbus()
except DBusException:
print "Can't connect to the daemon, trying to start it automatically..."
misc.PromptToStartDaemon()
try:
dbus_manager.connect_to_dbus()
except DBusException:
error(None, "Could not connect to wicd's D-Bus interface. " +
"Make sure the daemon is started.")
sys.exit(1)
bus = dbus_manager.get_bus()
dbus_ifaces = dbus_manager.get_dbus_ifaces()
daemon = dbus_ifaces['daemon']
wireless = dbus_ifaces['wireless']
wired = dbus_ifaces['wired']
config = dbus_ifaces['config']
return True
def error(parent, message):
@@ -149,7 +164,7 @@ class WiredProfileChooser:
""" Initializes and runs the wired profile chooser. """
# Import and init WiredNetworkEntry to steal some of the
# functions and widgets it uses.
wired_net_entry = WiredNetworkEntry(dbus_ifaces)
wired_net_entry = WiredNetworkEntry(dbus_manager.get_dbus_ifaces())
dialog = gtk.Dialog(title = language['wired_network_found'],
flags = gtk.DIALOG_MODAL,
@@ -195,18 +210,15 @@ class WiredProfileChooser:
dialog.destroy()
class appGui:
class appGui(object):
""" The main wicd GUI class. """
def __init__(self, standalone=False):
def __init__(self, dbus_man=None, standalone=False):
""" Initializes everything needed for the GUI. """
if not standalone:
setup_dbus(dbus_man)
gladefile = "data/wicd.glade"
self.windowname = "gtkbench"
self.wTree = gtk.glade.XML(gladefile)
try:
setup_dbus()
except dbus.DBusException:
pass # wicd.py handles this.
dic = { "refresh_clicked" : self.refresh_networks,
"quit_clicked" : self.exit,
@@ -237,7 +249,6 @@ class appGui:
self.status_area.hide_all()
# self.window.set_icon_from_file(wpath.etc + "wicd.png")
if os.path.exists(wpath.etc + "wicd.png"):
self.window.set_icon_from_file(wpath.etc + "wicd.png")
self.statusID = None
@@ -340,228 +351,13 @@ class appGui:
if event.state & gtk.gdk.CONTROL_MASK and \
gtk.gdk.keyval_name(event.keyval) in ["w", "q"]:
self.exit()
def settings_dialog(self, widget, event=None):
""" Displays a general settings dialog. """
def build_combobox(lbl):
""" Sets up a ComboBox using the given widget name. """
liststore = gtk.ListStore(gobject.TYPE_STRING)
combobox = self.wTree.get_widget(lbl)
combobox.clear()
combobox.set_model(liststore)
cell = gtk.CellRendererText()
combobox.pack_start(cell, True)
combobox.add_attribute(cell, 'text', 0)
return combobox
dialog = self.wTree.get_widget("pref_dialog")
dialog.set_title(language['preferences'])
size = config.ReadWindowSize("pref")
width = size[0]
height = size[1]
if width > -1 and height > -1:
dialog.resize(int(width), int(height))
wiredcheckbox = self.wTree.get_widget("pref_always_check")
wiredcheckbox.set_label(language['wired_always_on'])
wiredcheckbox.set_active(wired.GetAlwaysShowWiredInterface())
reconnectcheckbox = self.wTree.get_widget("pref_auto_check")
reconnectcheckbox.set_label(language['auto_reconnect'])
reconnectcheckbox.set_active(daemon.GetAutoReconnect())
debugmodecheckbox = self.wTree.get_widget("pref_debug_check")
debugmodecheckbox.set_label(language['use_debug_mode'])
debugmodecheckbox.set_active(daemon.GetDebugMode())
displaytypecheckbox = self.wTree.get_widget("pref_dbm_check")
displaytypecheckbox.set_label(language['display_type_dialog'])
displaytypecheckbox.set_active(daemon.GetSignalDisplayType())
entryWiredAutoMethod = self.wTree.get_widget("pref_wired_auto_label")
entryWiredAutoMethod.set_label('Wired Autoconnect Setting:')
usedefaultradiobutton = self.wTree.get_widget("pref_use_def_radio")
usedefaultradiobutton.set_label(language['use_default_profile'])
showlistradiobutton = self.wTree.get_widget("pref_prompt_radio")
showlistradiobutton.set_label(language['show_wired_list'])
lastusedradiobutton = self.wTree.get_widget("pref_use_last_radio")
lastusedradiobutton.set_label(language['use_last_used_profile'])
## External Programs tab
self.wTree.get_widget("gen_settings_label").set_label(language["gen_settings"])
self.wTree.get_widget("ext_prog_label").set_label(language["ext_programs"])
self.wTree.get_widget("dhcp_client_label").set_label(language["dhcp_client"])
self.wTree.get_widget("wired_detect_label").set_label(language["wired_detect"])
self.wTree.get_widget("route_flush_label").set_label(language["route_flush"])
# DHCP Clients
dhcpautoradio = self.wTree.get_widget("dhcp_auto_radio")
dhcpautoradio.set_label(language["wicd_auto_config"])
dhclientradio = self.wTree.get_widget("dhclient_radio")
pumpradio = self.wTree.get_widget("pump_radio")
dhcpcdradio = self.wTree.get_widget("dhcpcd_radio")
dhcp_list = [dhcpautoradio, dhclientradio, dhcpcdradio, pumpradio]
dhcp_method = daemon.GetDHCPClient()
dhcp_list[dhcp_method].set_active(True)
# Wired Link Detection Apps
linkautoradio = self.wTree.get_widget("link_auto_radio")
linkautoradio.set_label(language['wicd_auto_config'])
linkautoradio = self.wTree.get_widget("link_auto_radio")
ethtoolradio = self.wTree.get_widget("ethtool_radio")
miitoolradio = self.wTree.get_widget("miitool_radio")
wired_link_list = [linkautoradio, ethtoolradio, miitoolradio]
wired_link_method = daemon.GetLinkDetectionTool()
wired_link_list[wired_link_method].set_active(True)
# Route Flushing Apps
flushautoradio = self.wTree.get_widget("flush_auto_radio")
flushautoradio.set_label(language['wicd_auto_config'])
ipflushradio = self.wTree.get_widget("ip_flush_radio")
routeflushradio = self.wTree.get_widget("route_flush_radio")
flush_list = [flushautoradio, ipflushradio, routeflushradio]
flush_method = daemon.GetFlushTool()
flush_list[flush_method].set_active(True)
if wired.GetWiredAutoConnectMethod() == 1:
usedefaultradiobutton.set_active(True)
elif wired.GetWiredAutoConnectMethod() == 2:
showlistradiobutton.set_active(True)
elif wired.GetWiredAutoConnectMethod() == 3:
lastusedradiobutton.set_active(True)
self.set_label("pref_driver_label", language['wpa_supplicant_driver'] +
':')
# Replacement for the combo box hack
wpadrivercombo = build_combobox("pref_wpa_combobox")
# Hack to get the combo box we need, which you can't do with glade.
#wpa_hbox = self.wTree.get_widget("hbox_wpa")
#if not self.first_dialog_load:
#wpa_hbox.remove(self.wpadrivercombo)
#else:
#self.first_dialog_load = False
#self.wpadrivercombo = gtk.combo_box_new_text()
#wpadrivercombo = self.wpadrivercombo # Just to make my life easier
#wpa_hbox.pack_end(wpadrivercombo)
wpadrivers = ["wext", "hostap", "madwifi", "atmel", "ndiswrapper",
"ipw", "ralink legacy"]
found = False
def_driver = daemon.GetWPADriver()
for i, x in enumerate(wpadrivers):
if x == def_driver: #and not found:
found = True
user_driver_index = i
wpadrivercombo.remove_text(i)
wpadrivercombo.append_text(x)
# Set the active choice here. Doing it before all the items are
# added the combobox causes the choice to be reset.
if found:
wpadrivercombo.set_active(user_driver_index)
else:
# Use wext as default, since normally it is the correct driver.
wpadrivercombo.set_active(0)
self.set_label("pref_wifi_label", language['wireless_interface'] + ':')
self.set_label("pref_wired_label", language['wired_interface'] + ':')
entryWirelessInterface = self.wTree.get_widget("pref_wifi_entry")
entryWirelessInterface.set_text(daemon.GetWirelessInterface())
entryWiredInterface = self.wTree.get_widget("pref_wired_entry")
entryWiredInterface.set_text(daemon.GetWiredInterface())
# Set up global DNS stuff
useGlobalDNSCheckbox = self.wTree.get_widget("pref_global_check")
useGlobalDNSCheckbox.set_label(language['use_global_dns'])
dns1Entry = self.wTree.get_widget("pref_dns1_entry")
dns2Entry = self.wTree.get_widget("pref_dns2_entry")
dns3Entry = self.wTree.get_widget("pref_dns3_entry")
self.set_label("pref_dns1_label", language['dns'] + ' ' + language['1'])
self.set_label("pref_dns2_label", language['dns'] + ' ' + language['2'])
self.set_label("pref_dns3_label", language['dns'] + ' ' + language['3'])
useGlobalDNSCheckbox.connect("toggled", checkboxTextboxToggle,
(dns1Entry, dns2Entry, dns3Entry))
dns_addresses = daemon.GetGlobalDNSAddresses()
useGlobalDNSCheckbox.set_active(daemon.GetUseGlobalDNS())
dns1Entry.set_text(noneToBlankString(dns_addresses[0]))
dns2Entry.set_text(noneToBlankString(dns_addresses[1]))
dns3Entry.set_text(noneToBlankString(dns_addresses[2]))
if not daemon.GetUseGlobalDNS():
dns1Entry.set_sensitive(False)
dns2Entry.set_sensitive(False)
dns3Entry.set_sensitive(False)
# Bold/Align the Wired Autoconnect label.
entryWiredAutoMethod.set_alignment(0, 0)
atrlist = pango.AttrList()
atrlist.insert(pango.AttrWeight(pango.WEIGHT_BOLD, 0, 50))
entryWiredAutoMethod.set_attributes(atrlist)
self.wTree.get_widget("notebook2").set_current_page(0)
dialog.show_all()
response = dialog.run()
if response == 1:
daemon.SetUseGlobalDNS(useGlobalDNSCheckbox.get_active())
daemon.SetGlobalDNS(dns1Entry.get_text(), dns2Entry.get_text(),
dns3Entry.get_text())
daemon.SetWirelessInterface(entryWirelessInterface.get_text())
daemon.SetWiredInterface(entryWiredInterface.get_text())
daemon.SetWPADriver(wpadrivers[wpadrivercombo.get_active()])
wired.SetAlwaysShowWiredInterface(wiredcheckbox.get_active())
daemon.SetAutoReconnect(reconnectcheckbox.get_active())
daemon.SetDebugMode(debugmodecheckbox.get_active())
daemon.SetSignalDisplayType(displaytypecheckbox.get_active())
if showlistradiobutton.get_active():
wired.SetWiredAutoConnectMethod(2)
elif lastusedradiobutton.get_active():
wired.SetWiredAutoConnectMethod(3)
else:
wired.SetWiredAutoConnectMethod(1)
# External Programs Tab
if dhcpautoradio.get_active():
dhcp_client = misc.AUTO
elif dhclientradio.get_active():
dhcp_client = misc.DHCLIENT
elif dhcpcdradio.get_active():
dhcp_client = misc.DHCPCD
else:
dhcp_client = misc.PUMP
daemon.SetDHCPClient(dhcp_client)
if linkautoradio.get_active():
link_tool = misc.AUTO
elif ethtoolradio.get_active():
link_tool = misc.ETHTOOL
else:
link_tool = misc.MIITOOL
daemon.SetLinkDetectionTool(link_tool)
if flushautoradio.get_active():
flush_tool = misc.AUTO
elif ipflushradio.get_active():
flush_tool = misc.IP
else:
flush_tool = misc.ROUTE
daemon.SetFlushTool(flush_tool)
dialog.hide()
[width, height] = dialog.get_size()
config.WriteWindowSize(width, height, "pref")
def set_label(self, glade_str, label):
""" Sets the label for the given widget in wicd.glade. """
self.wTree.get_widget(glade_str).set_label(label)
pref = PreferencesDialog(self.wTree, dbus_manager.get_dbus_ifaces())
if pref.run() == 1:
pref.save_results()
pref.hide()
def connect_hidden(self, widget):
""" Prompts the user for a hidden network, then scans for it. """
@@ -785,7 +581,7 @@ class appGui:
if wired.CheckPluggedIn(self.fast) or wired.GetAlwaysShowWiredInterface():
printLine = True # In this case we print a separator.
wirednet = WiredNetworkEntry(dbus_ifaces)
wirednet = WiredNetworkEntry(dbus_manager.get_dbus_ifaces())
self.network_list.pack_start(wirednet, False, False)
wirednet.connect_button.connect("button-press-event", self.connect,
"wired", 0, wirednet)
@@ -812,7 +608,7 @@ class appGui:
sep.show()
else:
printLine = True
tempnet = WirelessNetworkEntry(x, dbus_ifaces)
tempnet = WirelessNetworkEntry(x, dbus_manager.get_dbus_ifaces())
self.network_list.pack_start(tempnet, False, False)
tempnet.connect_button.connect("button-press-event",
self.connect, "wireless", x,
@@ -1096,12 +892,7 @@ class appGui:
if __name__ == '__main__':
if not proxy_obj:
error("Could not connect to wicd's D-Bus interface. Make sure the " +
"daemon is started. If the error persists, please report the" +
"behavior at wicd.net.")
sys.exit(1)
setup_dbus()
app = appGui(standalone=True)
bus.add_signal_receiver(app.dbus_scan_finished, 'SendEndScanSignal',
'org.wicd.daemon')

View File

@@ -460,6 +460,7 @@ def get_language_list_tray():
language['killswitch_enabled'] = _('Wireless Kill Switch Enabled')
language['connecting'] = _('Connecting')
language['wired'] = _('Wired Network')
language['scanning'] = _('Scanning')
return language

View File

@@ -290,7 +290,7 @@ def main():
"""
monitor = ConnectionStatus()
gobject.timeout_add(2000, monitor.update_connection_status)
gobject.timeout_add(120000, monitor.rescan_networks)
#gobject.timeout_add(120000, monitor.rescan_networks)
mainloop = gobject.MainLoop()
mainloop.run()

View File

@@ -435,11 +435,10 @@ class NetworkEntry(gtk.HBox):
WirelessNetworkEntry classes.
"""
global daemon, wired, wireless, config, vpn_session
global daemon, wired, wireless, config
daemon = dbus_ifaces["daemon"]
wired = dbus_ifaces["wired"]
wireless = dbus_ifaces["wireless"]
vpn_session = dbus_ifaces["vpn_session"]
config = dbus_ifaces["config"]
gtk.HBox.__init__(self, False, 2)
self.expander = gtk.Expander()

268
prefs.py Normal file
View File

@@ -0,0 +1,268 @@
#!/usr/bin/python
""" Wicd Preferences Dialog.
Displays the main settings dialog window for wicd.
"""
#
# Copyright (C) 2007 Adam Blackburn
# Copyright (C) 2007 Dan O'Reilly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License Version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import gtk
import gobject
import pango
import misc
from misc import checkboxTextboxToggle, noneToBlankString
daemon = None
wireless = None
wired = None
config = None
language = misc.get_language_list_gui()
class PreferencesDialog(object):
def __init__(self, wTree, dbus):
global daemon, wireless, wired, config
daemon = dbus['daemon']
wireless = dbus['wireless']
wired = dbus['wired']
config = dbus['config']
self.wTree = wTree
self.prep_settings_diag()
self.build_preferences_diag()
def build_preferences_diag(self):
def build_combobox(lbl):
""" Sets up a ComboBox using the given widget name. """
liststore = gtk.ListStore(gobject.TYPE_STRING)
combobox = self.wTree.get_widget(lbl)
combobox.clear()
combobox.set_model(liststore)
cell = gtk.CellRendererText()
combobox.pack_start(cell, True)
combobox.add_attribute(cell, 'text', 0)
return combobox
def setup_label(name, lbl=""):
widget = self.wTree.get_widget(name)
if lbl:
widget.set_label(language[lbl])
return widget
self.dialog = self.wTree.get_widget("pref_dialog")
self.dialog.set_title(language['preferences'])
size = config.ReadWindowSize("pref")
width = size[0]
height = size[1]
if width > -1 and height > -1:
self.dialog.resize(int(width), int(height))
self.wiredcheckbox = setup_label("pref_always_check",
'wired_always_on')
self.wiredcheckbox.set_active(wired.GetAlwaysShowWiredInterface())
self.reconnectcheckbox = setup_label("pref_auto_check",
'auto_reconnect')
self.reconnectcheckbox.set_active(daemon.GetAutoReconnect())
self.debugmodecheckbox = setup_label("pref_debug_check",
'use_debug_mode')
self.debugmodecheckbox.set_active(daemon.GetDebugMode())
self.displaytypecheckbox = setup_label("pref_dbm_check",
'display_type_dialog')
self.displaytypecheckbox.set_active(daemon.GetSignalDisplayType())
self.usedefaultradiobutton = setup_label("pref_use_def_radio",
'use_default_profile')
self.showlistradiobutton = setup_label("pref_prompt_radio",
'show_wired_list')
self.lastusedradiobutton = setup_label("pref_use_last_radio",
'use_last_used_profile')
# DHCP Clients
self.dhcpautoradio = setup_label("dhcp_auto_radio", "wicd_auto_config")
self.dhclientradio = self.wTree.get_widget("dhclient_radio")
self.pumpradio = self.wTree.get_widget("pump_radio")
self.dhcpcdradio = self.wTree.get_widget("dhcpcd_radio")
dhcp_list = [self.dhcpautoradio, self.dhclientradio, self.dhcpcdradio,
self.pumpradio]
dhcp_method = daemon.GetDHCPClient()
dhcp_list[dhcp_method].set_active(True)
# Wired Link Detection Apps
self.linkautoradio = setup_label("link_auto_radio", 'wicd_auto_config')
self.linkautoradio = setup_label("link_auto_radio")
self.ethtoolradio = setup_label("ethtool_radio")
self.miitoolradio = setup_label("miitool_radio")
wired_link_list = [self.linkautoradio, self.ethtoolradio,
self.miitoolradio]
wired_link_method = daemon.GetLinkDetectionTool()
wired_link_list[wired_link_method].set_active(True)
# Route Flushing Apps
self.flushautoradio = setup_label("flush_auto_radio",
'wicd_auto_config')
self.ipflushradio = setup_label("ip_flush_radio")
self.routeflushradio = setup_label("route_flush_radio")
flush_list = [self.flushautoradio, self.ipflushradio,
self.routeflushradio]
flush_method = daemon.GetFlushTool()
flush_list[flush_method].set_active(True)
if wired.GetWiredAutoConnectMethod() == 1:
self.usedefaultradiobutton.set_active(True)
elif wired.GetWiredAutoConnectMethod() == 2:
self.showlistradiobutton.set_active(True)
elif wired.GetWiredAutoConnectMethod() == 3:
self.lastusedradiobutton.set_active(True)
self.entryWirelessInterface = self.wTree.get_widget("pref_wifi_entry")
self.entryWirelessInterface.set_text(daemon.GetWirelessInterface())
self.entryWiredInterface = self.wTree.get_widget("pref_wired_entry")
self.entryWiredInterface.set_text(daemon.GetWiredInterface())
# Replacement for the combo box hack
self.wpadrivercombo = build_combobox("pref_wpa_combobox")
self.wpadrivers = ["wext", "hostap", "madwifi", "atmel", "ndiswrapper",
"ipw", "ralink legacy"]
found = False
def_driver = daemon.GetWPADriver()
for i, x in enumerate(self.wpadrivers):
if x == def_driver: #and not found:
found = True
user_driver_index = i
self.wpadrivercombo.remove_text(i)
self.wpadrivercombo.append_text(x)
# Set the active choice here. Doing it before all the items are
# added the combobox causes the choice to be reset.
if found:
self.wpadrivercombo.set_active(user_driver_index)
else:
# Use wext as default, since normally it is the correct driver.
self.wpadrivercombo.set_active(0)
# Set up global DNS stuff
self.useGlobalDNSCheckbox = setup_label("pref_global_check",
'use_global_dns')
self.dns1Entry = self.wTree.get_widget("pref_dns1_entry")
self.dns2Entry = self.wTree.get_widget("pref_dns2_entry")
self.dns3Entry = self.wTree.get_widget("pref_dns3_entry")
self.useGlobalDNSCheckbox.connect("toggled", checkboxTextboxToggle,
(self.dns1Entry, self.dns2Entry,
self.dns3Entry))
dns_addresses = daemon.GetGlobalDNSAddresses()
self.useGlobalDNSCheckbox.set_active(daemon.GetUseGlobalDNS())
self.dns1Entry.set_text(noneToBlankString(dns_addresses[0]))
self.dns2Entry.set_text(noneToBlankString(dns_addresses[1]))
self.dns3Entry.set_text(noneToBlankString(dns_addresses[2]))
if not daemon.GetUseGlobalDNS():
self.dns1Entry.set_sensitive(False)
self.dns2Entry.set_sensitive(False)
self.dns3Entry.set_sensitive(False)
self.wTree.get_widget("notebook2").set_current_page(0)
def run(self):
return self.dialog.run()
def hide(self):
self.dialog.hide()
def show_all(self):
self.show_all()
def save_results(self):
daemon.SetUseGlobalDNS(self.useGlobalDNSCheckbox.get_active())
daemon.SetGlobalDNS(self.dns1Entry.get_text(), self.dns2Entry.get_text(),
self.dns3Entry.get_text())
daemon.SetWirelessInterface(self.entryWirelessInterface.get_text())
daemon.SetWiredInterface(self.entryWiredInterface.get_text())
daemon.SetWPADriver(self.wpadrivers[self.wpadrivercombo.get_active()])
wired.SetAlwaysShowWiredInterface(self.wiredcheckbox.get_active())
daemon.SetAutoReconnect(self.reconnectcheckbox.get_active())
daemon.SetDebugMode(self.debugmodecheckbox.get_active())
daemon.SetSignalDisplayType(self.displaytypecheckbox.get_active())
if self.showlistradiobutton.get_active():
wired.SetWiredAutoConnectMethod(2)
elif self.lastusedradiobutton.get_active():
wired.SetWiredAutoConnectMethod(3)
else:
wired.SetWiredAutoConnectMethod(1)
# External Programs Tab
if self.dhcpautoradio.get_active():
dhcp_client = misc.AUTO
elif self.dhclientradio.get_active():
dhcp_client = misc.DHCLIENT
elif self.dhcpcdradio.get_active():
dhcp_client = misc.DHCPCD
else:
dhcp_client = misc.PUMP
daemon.SetDHCPClient(dhcp_client)
if self.linkautoradio.get_active():
link_tool = misc.AUTO
elif self.ethtoolradio.get_active():
link_tool = misc.ETHTOOL
else:
link_tool = misc.MIITOOL
daemon.SetLinkDetectionTool(link_tool)
if self.flushautoradio.get_active():
flush_tool = misc.AUTO
elif self.ipflushradio.get_active():
flush_tool = misc.IP
else:
flush_tool = misc.ROUTE
daemon.SetFlushTool(flush_tool)
[width, height] = self.dialog.get_size()
config.WriteWindowSize(width, height, "pref")
def set_label(self, glade_str, label):
""" Sets the label for the given widget in wicd.glade. """
self.wTree.get_widget(glade_str).set_label(label)
def prep_settings_diag(self):
""" Set up anything that doesn't have to be persisted later. """
# External Programs tab
self.wTree.get_widget("gen_settings_label").set_label(language["gen_settings"])
self.wTree.get_widget("ext_prog_label").set_label(language["ext_programs"])
self.wTree.get_widget("dhcp_client_label").set_label(language["dhcp_client"])
self.wTree.get_widget("wired_detect_label").set_label(language["wired_detect"])
self.wTree.get_widget("route_flush_label").set_label(language["route_flush"])
entryWiredAutoMethod = self.wTree.get_widget("pref_wired_auto_label")
entryWiredAutoMethod.set_label('Wired Autoconnect Setting:')
entryWiredAutoMethod.set_alignment(0, 0)
atrlist = pango.AttrList()
atrlist.insert(pango.AttrWeight(pango.WEIGHT_BOLD, 0, 50))
entryWiredAutoMethod.set_attributes(atrlist)
self.set_label("pref_dns1_label", language['dns'] + ' ' + language['1'])
self.set_label("pref_dns2_label", language['dns'] + ' ' + language['2'])
self.set_label("pref_dns3_label", language['dns'] + ' ' + language['3'])
self.set_label("pref_wifi_label", language['wireless_interface'] + ':')
self.set_label("pref_wired_label", language['wired_interface'] + ':')
self.set_label("pref_driver_label", language['wpa_supplicant_driver'] + ':')

87
wicd.py
View File

@@ -39,16 +39,17 @@ def main() -- Runs the wicd frontend main loop.
import sys
import gtk
import gobject
import dbus
import dbus.service
import getopt
import os
import pango
from dbus import DBusException
from dbus import version as dbus_version
# Wicd specific imports
import wpath
import misc
import gui
from dbusmanager import DBusManager
# Import egg.trayicon if we're using an older gtk version
if not (gtk.gtk_version[0] >= 2 and gtk.gtk_version[1] >= 10):
@@ -61,7 +62,7 @@ if not (gtk.gtk_version[0] >= 2 and gtk.gtk_version[1] >= 10):
else:
USE_EGG = False
if getattr(dbus, 'version', (0, 0, 0)) < (0, 80, 0):
if not dbus_version or (dbus_version < (0, 80, 0)):
import dbus.glib
else:
from dbus.mainloop.glib import DBusGMainLoop
@@ -72,7 +73,7 @@ misc.RenameProcess("wicd-client")
if __name__ == '__main__':
wpath.chdir(__file__)
bus = None
dbus_manager = None
daemon = None
wireless = None
wired = None
@@ -428,8 +429,9 @@ class TrayIcon:
return wireless.GetWirelessProperty(net_id, prop)
net_menuitem = self.manager.get_widget("/Menubar/Menu/Connect/")
net_menuitem.get_submenu().destroy()
net_menu = gtk.Menu()
submenu = net_menuitem.get_submenu()
self._clear_menu(submenu)
is_connecting = daemon.CheckIfConnecting()
num_networks = wireless.GetNumberOfNetworks()
[status, info] = daemon.GetConnectionStatus()
@@ -440,10 +442,10 @@ class TrayIcon:
is_active = True
else:
is_active = False
self._add_item_to_menu(net_menu, "Wired Network", "__wired__",
self._add_item_to_menu(submenu, "Wired Network", "__wired__",
0, is_connecting, is_active)
sep = gtk.SeparatorMenuItem()
net_menu.append(sep)
submenu.append(sep)
sep.show()
if num_networks > 0:
@@ -453,16 +455,33 @@ class TrayIcon:
is_active = True
else:
is_active = False
self._add_item_to_menu(net_menu, essid, "wifi", x,
self._add_item_to_menu(submenu, essid, "wifi", x,
is_connecting, is_active)
net_menuitem.set_submenu(net_menu)
net_menuitem.show()
def init_network_menu(self):
net_menuitem = self.manager.get_widget("/Menubar/Menu/Connect/")
submenu = net_menuitem.get_submenu()
self._clear_menu(submenu)
loading_item = gtk.MenuItem(language['scanning'] + "...")
loading_item.set_sensitive(False)
loading_item.show()
submenu.append(loading_item)
#net_menuitem.set_submenu(net_menu)
net_menuitem.show()
def _clear_menu(self, menu):
for item in menu.get_children():
menu.remove(item)
item.destroy()
def toggle_wicd_gui(self):
""" Toggles the wicd GUI. """
if not self.gui_win:
self.gui_win = gui.appGui()
self.gui_win = gui.appGui(dbus_manager)
bus = dbus_manager.get_bus()
bus.add_signal_receiver(self.gui_win.dbus_scan_finished,
'SendEndScanSignal',
'org.wicd.daemon')
@@ -476,7 +495,7 @@ class TrayIcon:
else:
self.gui_win.exit()
return True
class EggTrayIconGUI(TrayIconGUI):
""" Tray Icon for gtk < 2.10.
@@ -554,7 +573,9 @@ class TrayIcon:
def on_popup_menu(self, status, button, timestamp):
""" Opens the right click menu for the tray icon. """
self.populate_network_menu()
self.init_network_menu()
wireless.Scan(reply_handler=self.populate_network_menu,
error_handler=lambda x: x)
self.menu.popup(None, None, None, button, timestamp)
def set_from_file(self, path = None):
@@ -577,30 +598,26 @@ Arguments:
\t-a\t--no-animate\tRun the tray without network traffic tray animations.
"""
def connect_to_dbus():
global bus, daemon, wireless, wired, config
# Connect to the daemon
bus = dbus.SystemBus()
def setup_dbus():
global bus, daemon, wireless, wired, config, dbus_manager
dbus_manager = DBusManager()
try:
print 'Attempting to connect tray to daemon...'
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
print 'Success.'
except dbus.DBusException:
dbus_manager.connect_to_dbus()
except DBusException:
print "Can't connect to the daemon, trying to start it automatically..."
misc.PromptToStartDaemon()
try:
print 'Attempting to connect tray to daemon...'
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
print 'Success.'
except dbus.DBusException:
dbus_manager.connect_to_dbus()
except DBusException:
gui.error(None, "Could not connect to wicd's D-Bus interface. " +
"Make sure the daemon is started.")
sys.exit(1)
daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon')
wireless = dbus.Interface(proxy_obj, 'org.wicd.daemon.wireless')
wired = dbus.Interface(proxy_obj, 'org.wicd.daemon.wired')
config = dbus.Interface(proxy_obj, 'org.wicd.daemon.config')
dbus_ifaces = dbus_manager.get_dbus_ifaces()
daemon = dbus_ifaces['daemon']
wireless = dbus_ifaces['wireless']
wired = dbus_ifaces['wired']
config = dbus_ifaces['config']
return True
def main(argv):
@@ -634,7 +651,7 @@ def main(argv):
sys.exit(2)
print 'Loading...'
connect_to_dbus()
setup_dbus()
if not use_tray:
the_gui = gui.appGui()
@@ -651,10 +668,10 @@ def main(argv):
if daemon.GetNeedWiredProfileChooser():
daemon.SetNeedWiredProfileChooser(False)
tray_icon.icon_info.wired_profile_chooser()
bus = dbus_manager.get_bus()
bus.add_signal_receiver(tray_icon.icon_info.wired_profile_chooser,
'LaunchChooser', 'org.wicd.daemon')
bus.add_signal_receiver(tray_icon.icon_info.update_tray_icon,
'StatusChanged', 'org.wicd.daemon')
print 'Done.'
@@ -663,12 +680,12 @@ def main(argv):
mainloop = gobject.MainLoop()
try:
mainloop.run()
except dbus.exceptions.DBusException:
except DBusException:
print 'Warning. Caught a D-Bus exception! Connection to daemon lost.'
print 'Trying to reconnect...'
sleep(10)
try:
connect_to_dbus()
setup_dbus()
except:
pass