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

Merged with r247 of mainline experimental (1.6) branch.

-------------- This line and the following will be ignored ---------
added:
  wicd/guiutil.py
modified:
  encryption/templates/ttls
  setup.py
  wicd/configmanager.py
  wicd/dbusmanager.py
  wicd/gui.py
  wicd/misc.py
  wicd/monitor.py
  wicd/netentry.py
  wicd/networking.py
  wicd/prefs.py
  wicd/wicd-client.py
  wicd/wicd-daemon.py
  wicd/wnettools.py
unknown:
  build/
  install.log
  uninstall.log
  vcsinfo.py
  wpath.py
  curses/bzr_commit
  curses/configscript.py
  curses/current.diff
  init/arch/wicd
  init/debian/wicd
  init/default/wicd
  init/gentoo/wicd
  init/pld/wicd
  init/redhat/wicd
  init/slackware/rc.wicd
  init/suse/wicd
  man/wicd-curses.8
  man/wicd-manager-settings.conf.5
  man/wicd-wired-settings.conf.5
  man/wicd-wireless-settings.conf.5
  man/wicd.8
  other/50-wicd-suspend.sh
  other/55wicd
  other/80-wicd-connect.sh
  other/WHEREAREMYFILES
  other/postinst
  other/wicd.conf
  scripts/wicd
  scripts/wicd-client
  scripts/wicd-curses
  wicd/wpath.py
pending merges:
  Dan O'Reilly 2009-01-20 Add missing guiutil module
    Dan O'Reilly 2009-01-20 Add support for writing config data with whitespace kep...
    Dan O'Reilly 2009-01-19 Fix a few typos in the option gateway code.
    Dan O'Reilly 2009-01-19 Fix bug that was keeping DHCP release from working.
    Dan O'Reilly 2009-01-19 Fix ttls template
This commit is contained in:
Andrew Psaltis
2009-01-21 00:09:45 -05:00
14 changed files with 252 additions and 226 deletions

View File

@@ -1,7 +1,7 @@
name = TTLS with WEP name = TTLS with WEP
author = Adam Blackburn author = Adam Blackburn
version = 1 version = 1
require anonymous_identity *Anonymous_Identity identity *Identity password *Password auth *Authentication require identity *Identity password *Password auth *Authentication
----- -----
ctrl_interface=/var/run/wpa_supplicant ctrl_interface=/var/run/wpa_supplicant
network={ network={
@@ -9,7 +9,7 @@ network={
scan_ssid=$_SCAN scan_ssid=$_SCAN
eap=TTLS eap=TTLS
key_mgmt=IEEE8021X key_mgmt=IEEE8021X
identity="$_USERNAME" identity="$_IDENTITY"
password="$_PASSWORD" password="$_PASSWORD"
phase2="auth=$_AUTH" phase2="auth=$_AUTH"
} }

View File

@@ -126,32 +126,32 @@ class configure(Command):
self.distro_detect_failed = False self.distro_detect_failed = False
self.initfile = 'init/default/wicd' self.initfile = 'init/default/wicd'
if os.access('/etc/redhat-release', os.F_OK): if os.path.exists('/etc/redhat-release'):
self.init = '/etc/rc.d/init.d/' self.init = '/etc/rc.d/init.d/'
self.initfile = 'init/redhat/wicd' self.initfile = 'init/redhat/wicd'
elif os.access('/etc/SuSE-release', os.F_OK): elif os.path.exists('/etc/SuSE-release'):
self.init = '/etc/init.d/' self.init = '/etc/init.d/'
self.initfile = 'init/suse/wicd' self.initfile = 'init/suse/wicd'
elif os.access('/etc/fedora-release', os.F_OK): elif os.path.exists('/etc/fedora-release'):
self.init = '/etc/rc.d/init.d/' self.init = '/etc/rc.d/init.d/'
self.initfile = 'init/redhat/wicd' self.initfile = 'init/redhat/wicd'
elif os.access('/etc/gentoo-release', os.F_OK): elif os.path.exists('/etc/gentoo-release'):
self.init = '/etc/init.d/' self.init = '/etc/init.d/'
self.initfile = 'init/gentoo/wicd' self.initfile = 'init/gentoo/wicd'
elif os.access('/etc/debian_version', os.F_OK): elif os.path.exists('/etc/debian_version'):
self.init = '/etc/init.d/' self.init = '/etc/init.d/'
self.initfile = 'init/debian/wicd' self.initfile = 'init/debian/wicd'
elif os.access('/etc/arch-release', os.F_OK): elif os.path.exists('/etc/arch-release'):
self.init = '/etc/rc.d/' self.init = '/etc/rc.d/'
self.initfile = 'init/arch/wicd' self.initfile = 'init/arch/wicd'
elif os.access('/etc/slackware-version', os.F_OK) or \ elif os.path.exists('/etc/slackware-version') or \
os.access('/etc/slamd64-version', os.F_OK): os.path.exists('/etc/slamd64-version'):
self.init = '/etc/rc.d/' self.init = '/etc/rc.d/'
self.initfile = 'init/slackware/rc.wicd' self.initfile = 'init/slackware/rc.wicd'
self.docdir = '/usr/doc/wicd-%s' % VERSION_NUM self.docdir = '/usr/doc/wicd-%s' % VERSION_NUM
self.mandir = '/usr/man/' self.mandir = '/usr/man/'
self.no_install_acpi = True self.no_install_acpi = True
elif os.access('/etc/pld-release', os.F_OK): elif os.path.exists('/etc/pld-release'):
self.init = '/etc/rc.d/init.d/' self.init = '/etc/rc.d/init.d/'
self.initfile = 'init/pld/wicd' self.initfile = 'init/pld/wicd'
else: else:
@@ -475,7 +475,10 @@ connect at startup to any preferred network within range.
url="http://wicd.net", url="http://wicd.net",
license="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html", license="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html",
## scripts=['configscript.py', 'autoconnect.py', 'gui.py', 'wicd.py', 'daemon.py', 'suspend.py', 'monitor.py'], ## scripts=['configscript.py', 'autoconnect.py', 'gui.py', 'wicd.py', 'daemon.py', 'suspend.py', 'monitor.py'],
py_modules=['wicd.networking', 'wicd.misc', 'wicd.gui', 'wicd.wnettools', 'wicd.wpath', 'wicd.prefs', 'wicd.netentry', 'wicd.dbusmanager', 'wicd.logfile', 'wicd.backend', 'wicd.configmanager'], ext_modules=[iwscan_ext, wpactrl_ext], py_modules=['wicd.networking', 'wicd.misc', 'wicd.gui', 'wicd.wnettools', 'wicd.wpath',
'wicd.prefs', 'wicd.netentry', 'wicd.dbusmanager', 'wicd.logfile', 'wicd.backend',
'wicd.configmanager', 'wicd.guiutil'],
ext_modules=[iwscan_ext, wpactrl_ext],
data_files=data data_files=data
) )
##print "Running post-install configuration..." ##print "Running post-install configuration..."

View File

@@ -31,10 +31,11 @@ from wicd.misc import stringToNone, Noneify, to_unicode
class ConfigManager(RawConfigParser): class ConfigManager(RawConfigParser):
""" A class that can be used to manage a given configuration file. """ """ A class that can be used to manage a given configuration file. """
def __init__(self, path, debug=False): def __init__(self, path, debug=False, mark_whitespace="`'`"):
RawConfigParser.__init__(self) RawConfigParser.__init__(self)
self.config_file = path self.config_file = path
self.debug = debug self.debug = debug
self.mrk_ws = mark_whitespace
self.read(path) self.read(path)
def __repr__(self): def __repr__(self):
@@ -60,6 +61,9 @@ class ConfigManager(RawConfigParser):
self.add_section(section) self.add_section(section)
if isinstance(value, basestring): if isinstance(value, basestring):
value = to_unicode(value) value = to_unicode(value)
if value.startswith(' ') or value.endswith(' '):
value = "%(ws)s%(value)s%(ws)s" % {"value" : value,
"ws" : self.mrk_ws}
RawConfigParser.set(self, section, str(option), value) RawConfigParser.set(self, section, str(option), value)
if save: if save:
self.write() self.write()
@@ -77,17 +81,22 @@ class ConfigManager(RawConfigParser):
""" """
if not self.has_section(section): if not self.has_section(section):
if default != "__None__":
self.add_section(section) self.add_section(section)
else:
return None
if self.has_option(section, option): if self.has_option(section, option):
ret = RawConfigParser.get(self, section, option) ret = RawConfigParser.get(self, section, option)
if (isinstance(ret, basestring) and ret.startswith(self.mrk_ws)
and ret.endswith(self.mrk_ws)):
ret = ret[3:-3]
if default: if default:
if self.debug: if self.debug:
print ''.join(['found ', option, ' in configuration ', print ''.join(['found ', option, ' in configuration ',
str(ret)]) str(ret)])
else: else:
if default != "__None__": if default != "__None__":
if self.debug:
print 'did not find %s in configuration, setting default %s' % (option, str(default)) print 'did not find %s in configuration, setting default %s' % (option, str(default))
self.set(section, option, str(default), save=True) self.set(section, option, str(default), save=True)
ret = default ret = default

View File

@@ -24,6 +24,7 @@ A module for managing wicd's dbus interfaces.
# #
import dbus import dbus
from dbus import DBusException
if getattr(dbus, "version", (0, 0, 0)) < (0, 80, 0): if getattr(dbus, "version", (0, 0, 0)) < (0, 80, 0):
import dbus.glib import dbus.glib
else: else:

View File

@@ -40,6 +40,7 @@ from wicd import dbusmanager
from wicd.misc import noneToString from wicd.misc import noneToString
from wicd.netentry import WiredNetworkEntry, WirelessNetworkEntry from wicd.netentry import WiredNetworkEntry, WirelessNetworkEntry
from wicd.prefs import PreferencesDialog from wicd.prefs import PreferencesDialog
from wicd.guiutil import error, GreyLabel, LabelEntry, SmallLabel
if __name__ == '__main__': if __name__ == '__main__':
wpath.chdir(__file__) wpath.chdir(__file__)
@@ -87,92 +88,6 @@ def handle_no_dbus(from_tray=False):
error(None, language['lost_dbus'], block=False) error(None, language['lost_dbus'], block=False)
return False return False
def error(parent, message, block=True):
""" Shows an error dialog """
def delete_event(dialog, id):
dialog.destroy()
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
gtk.BUTTONS_OK)
dialog.set_markup(message)
if not block:
dialog.present()
dialog.connect("response", delete_event)
else:
dialog.run()
dialog.destroy()
def alert(parent, message):
""" Shows an warning dialog """
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING,
gtk.BUTTONS_OK)
dialog.set_markup(message)
dialog.present()
dialog.connect("response", lambda *args: dialog.destroy())
def dummy(x=None):pass
########################################
##### GTK EXTENSION CLASSES
########################################
class SmallLabel(gtk.Label):
def __init__(self, text=''):
gtk.Label.__init__(self, text)
self.set_size_request(50, -1)
class LabelEntry(gtk.HBox):
""" A label on the left with a textbox on the right. """
def __init__(self,text):
gtk.HBox.__init__(self)
self.entry = gtk.Entry()
self.entry.set_size_request(200, -1)
self.label = SmallLabel()
self.label.set_text(text)
self.label.set_size_request(170, -1)
self.pack_start(self.label, fill=False, expand=False)
self.pack_start(self.entry, fill=False, expand=False)
self.label.show()
self.entry.show()
self.entry.connect('focus-out-event', self.hide_characters)
self.entry.connect('focus-in-event', self.show_characters)
self.auto_hide_text = False
self.show()
def set_text(self, text):
# For compatibility...
self.entry.set_text(text)
def get_text(self):
return self.entry.get_text()
def set_auto_hidden(self, value):
self.entry.set_visibility(False)
self.auto_hide_text = value
def show_characters(self, widget=None, event=None):
# When the box has focus, show the characters
if self.auto_hide_text and widget:
self.entry.set_visibility(True)
def set_sensitive(self, value):
self.entry.set_sensitive(value)
self.label.set_sensitive(value)
def hide_characters(self, widget=None, event=None):
# When the box looses focus, hide them
if self.auto_hide_text and widget:
self.entry.set_visibility(False)
class GreyLabel(gtk.Label):
""" Creates a grey gtk.Label. """
def __init__(self):
gtk.Label.__init__(self)
def set_label(self, text):
self.set_markup("<span color=\"#666666\"><i>" + text + "</i></span>")
self.set_alignment(0, 0)
class WiredProfileChooser: class WiredProfileChooser:
""" Class for displaying the wired profile chooser. """ """ Class for displaying the wired profile chooser. """
@@ -291,6 +206,7 @@ class appGui(object):
self.wait_for_events(0.2) self.wait_for_events(0.2)
self.window.connect('delete_event', self.exit) self.window.connect('delete_event', self.exit)
self.window.connect('key-release-event', self.key_event) self.window.connect('key-release-event', self.key_event)
daemon.SetGUIOpen(True)
bus.add_signal_receiver(self.dbus_scan_finished, 'SendEndScanSignal', bus.add_signal_receiver(self.dbus_scan_finished, 'SendEndScanSignal',
'org.wicd.daemon.wireless') 'org.wicd.daemon.wireless')
bus.add_signal_receiver(self.dbus_scan_started, 'SendStartScanSignal', bus.add_signal_receiver(self.dbus_scan_started, 'SendStartScanSignal',
@@ -645,26 +561,36 @@ class appGui(object):
def save_settings(self, nettype, networkid, networkentry): def save_settings(self, nettype, networkid, networkentry):
""" Verifies and saves the settings for the network entry. """ """ Verifies and saves the settings for the network entry. """
entry = networkentry.advanced_dialog entry = networkentry.advanced_dialog
entlist = [] opt_entlist = []
req_entlist = []
# First make sure all the Addresses entered are valid. # First make sure all the Addresses entered are valid.
if entry.chkbox_static_ip.get_active(): if entry.chkbox_static_ip.get_active():
entlist = [ent for ent in [entry.txt_ip, entry.txt_netmask, req_entlist = [entry.txt_ip, entry.txt_netmask]
entry.txt_gateway]] opt_entlist = [entry.txt_gateway]
if entry.chkbox_static_dns.get_active() and \ if entry.chkbox_static_dns.get_active() and \
not entry.chkbox_global_dns.get_active(): not entry.chkbox_global_dns.get_active():
entlist.append(entry.txt_dns_1) req_entlist.append(entry.txt_dns_1)
# Only append additional dns entries if they're entered. # Only append additional dns entries if they're entered.
for ent in [entry.txt_dns_2, entry.txt_dns_3]: for ent in [entry.txt_dns_2, entry.txt_dns_3]:
if ent.get_text() != "": if ent.get_text() != "":
entlist.append(ent) opt_entlist.append(ent)
for lblent in entlist:
# Required entries.
for lblent in req_entlist:
if not misc.IsValidIP(lblent.get_text()): if not misc.IsValidIP(lblent.get_text()):
error(self.window, language['invalid_address']. error(self.window, language['invalid_address'].
replace('$A', lblent.label.get_label())) replace('$A', lblent.label.get_label()))
return False return False
# Optional entries, only check for validity if they're entered.
for lblent in opt_entlist:
if lblent.get_text() and not misc.IsValidIP(lblent.get_text()):
error(self.window, language['invalid_address'].
replace('$A', lblent.label.get_label()))
return False
# Now save the settings. # Now save the settings.
if nettype == "wireless": if nettype == "wireless":
if not networkentry.save_wireless_settings(networkid): if not networkentry.save_wireless_settings(networkid):

111
wicd/guiutil.py Normal file
View File

@@ -0,0 +1,111 @@
""" guiutil - A collection of commonly used gtk/gui functions and classes. """
#
# Copyright (C) 2007 - 2008 Adam Blackburn
# Copyright (C) 2007 - 2008 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
def error(parent, message, block=True):
""" Shows an error dialog. """
def delete_event(dialog, id):
dialog.destroy()
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
gtk.BUTTONS_OK)
dialog.set_markup(message)
if not block:
dialog.present()
dialog.connect("response", delete_event)
else:
dialog.run()
dialog.destroy()
def alert(parent, message, block=True):
""" Shows an warning dialog. """
def delete_event(dialog, id):
dialog.destroy()
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING,
gtk.BUTTONS_OK)
dialog.set_markup(message)
if not block:
dialog.present()
dialog.connect("response", delete_event)
else:
dialog.run()
dialog.destroy()
class SmallLabel(gtk.Label):
def __init__(self, text=''):
gtk.Label.__init__(self, text)
self.set_size_request(50, -1)
class LeftAlignedLabel(gtk.Label):
def __init__(self, label=None):
gtk.Label.__init__(self, label)
self.set_alignment(0.0, 0.5)
class LabelEntry(gtk.HBox):
""" A label on the left with a textbox on the right. """
def __init__(self,text):
gtk.HBox.__init__(self)
self.entry = gtk.Entry()
self.entry.set_size_request(200, -1)
self.label = SmallLabel()
self.label.set_text(text)
self.label.set_size_request(170, -1)
self.pack_start(self.label, fill=False, expand=False)
self.pack_start(self.entry, fill=False, expand=False)
self.label.show()
self.entry.show()
self.entry.connect('focus-out-event', self.hide_characters)
self.entry.connect('focus-in-event', self.show_characters)
self.auto_hide_text = False
self.show()
def set_text(self, text):
# For compatibility...
self.entry.set_text(text)
def get_text(self):
return self.entry.get_text()
def set_auto_hidden(self, value):
self.entry.set_visibility(False)
self.auto_hide_text = value
def show_characters(self, widget=None, event=None):
# When the box has focus, show the characters
if self.auto_hide_text and widget:
self.entry.set_visibility(True)
def set_sensitive(self, value):
self.entry.set_sensitive(value)
self.label.set_sensitive(value)
def hide_characters(self, widget=None, event=None):
# When the box looses focus, hide them
if self.auto_hide_text and widget:
self.entry.set_visibility(False)
class GreyLabel(gtk.Label):
""" Creates a grey gtk.Label. """
def __init__(self):
gtk.Label.__init__(self)
def set_label(self, text):
self.set_markup("<span color=\"#666666\"><i>" + text + "</i></span>")
self.set_alignment(0, 0)

View File

@@ -399,7 +399,7 @@ def choose_sudo_prog():
for p in env_path: for p in env_path:
paths.extend([p + '/gksudo', p + "/gksu", p + '/ktsuss']) paths.extend([p + '/gksudo', p + "/gksu", p + '/ktsuss'])
for path in paths: for path in paths:
if os.access(path, os.F_OK): if os.path.exists(path):
return path return path
return None return None
@@ -414,7 +414,7 @@ def find_path(cmd):
""" """
paths = os.getenv("PATH", default="/usr/bin:/usr/local/bin").split(':') paths = os.getenv("PATH", default="/usr/bin:/usr/local/bin").split(':')
for path in paths: for path in paths:
if os.access(os.path.join(path, cmd), os.F_OK): if os.path.exists(os.path.join(path, cmd)):
return os.path.join(path, cmd) return os.path.join(path, cmd)
return None return None

View File

@@ -268,16 +268,16 @@ class ConnectionStatus(object):
error_handler=err_handle) error_handler=err_handle)
self.reconnecting = False self.reconnecting = False
def rescan_networks(self): #def rescan_networks(self):
""" Calls a wireless scan. """ # """ Calls a wireless scan. """
try: # try:
if daemon.GetSuspend() or daemon.CheckIfConnecting(): # if daemon.GetSuspend() or daemon.CheckIfConnecting():
return True # return True
wireless.Scan() # wireless.Scan()
except dbus.exceptions.DBusException, e: # except dbus.exceptions.DBusException, e:
print 'dbus exception while attempting rescan: %s' % str(e) # print 'dbus exception while attempting rescan: %s' % str(e)
finally: # finally:
return True # return True
def reply_handle(): def reply_handle():
""" Just a dummy function needed for asynchronous dbus calls. """ """ Just a dummy function needed for asynchronous dbus calls. """

View File

@@ -19,8 +19,9 @@ import gtk
import os import os
import misc import misc
from misc import noneToString, stringToNone, noneToBlankString, to_bool
import wpath import wpath
from misc import noneToString, stringToNone, noneToBlankString, to_bool
from guiutil import error, SmallLabel, LabelEntry, GreyLabel, LeftAlignedLabel
language = misc.get_language_list_gui() language = misc.get_language_list_gui()
@@ -29,78 +30,6 @@ daemon = None
wired = None wired = None
wireless = None wireless = None
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()
class SmallLabel(gtk.Label):
def __init__(self, text=''):
gtk.Label.__init__(self, text)
self.set_size_request(50, -1)
class LeftAlignedLabel(gtk.Label):
def __init__(self, label=None):
gtk.Label.__init__(self, label)
self.set_alignment(0.0, 0.5)
class LabelEntry(gtk.HBox):
""" A label on the left with a textbox on the right. """
def __init__(self, text):
gtk.HBox.__init__(self)
self.entry = gtk.Entry()
self.entry.set_size_request(200, -1)
self.label = SmallLabel()
self.label.set_text(text)
self.label.set_size_request(170, -1)
self.pack_start(self.label, fill=False, expand=False)
self.pack_start(self.entry, fill=False, expand=False)
self.label.show()
self.entry.show()
self.entry.connect('focus-out-event', self.hide_characters)
self.entry.connect('focus-in-event', self.show_characters)
self.auto_hide_text = False
self.show()
def set_text(self, text):
# For compatibility...
self.entry.set_text(text)
def get_text(self):
return self.entry.get_text()
def set_auto_hidden(self, value):
self.entry.set_visibility(False)
self.auto_hide_text = value
def show_characters(self, widget=None, event=None):
# When the box has focus, show the characters
if self.auto_hide_text and widget:
self.entry.set_visibility(True)
def set_sensitive(self, value):
self.entry.set_sensitive(value)
self.label.set_sensitive(value)
def hide_characters(self, widget=None, event=None):
# When the box looses focus, hide them
if self.auto_hide_text and widget:
self.entry.set_visibility(False)
class GreyLabel(gtk.Label):
""" Creates a grey gtk.Label. """
def __init__(self):
gtk.Label.__init__(self)
def set_label(self, text):
self.set_markup("<span color=\"#666666\"><i>" + text + "</i></span>")
self.set_alignment(0, 0)
class AdvancedSettingsDialog(gtk.Dialog): class AdvancedSettingsDialog(gtk.Dialog):
def __init__(self): def __init__(self):
""" Build the base advanced settings dialog. """ Build the base advanced settings dialog.
@@ -651,7 +580,6 @@ class WiredNetworkEntry(NetworkEntry):
self.chkbox_default_profile.connect("toggled", self.chkbox_default_profile.connect("toggled",
self.toggle_default_profile) self.toggle_default_profile)
self.combo_profile_names.connect("changed", self.change_profile) self.combo_profile_names.connect("changed", self.change_profile)
self.script_button.connect("button-press-event", self.edit_scripts)
# Toggle the default profile checkbox to the correct state. # Toggle the default profile checkbox to the correct state.
if to_bool(wired.GetWiredProperty("default")): if to_bool(wired.GetWiredProperty("default")):
@@ -701,7 +629,6 @@ class WiredNetworkEntry(NetworkEntry):
self.button_delete.set_sensitive(False) self.button_delete.set_sensitive(False)
self.connect_button.set_sensitive(False) self.connect_button.set_sensitive(False)
self.advanced_button.set_sensitive(False) self.advanced_button.set_sensitive(False)
self.script_button.set_sensitive(False)
def update_connect_button(self, state, apbssid=None): def update_connect_button(self, state, apbssid=None):
""" Update the connection/disconnect button for this entry. """ """ Update the connection/disconnect button for this entry. """
@@ -730,7 +657,6 @@ class WiredNetworkEntry(NetworkEntry):
self.button_delete.set_sensitive(True) self.button_delete.set_sensitive(True)
self.connect_button.set_sensitive(True) self.connect_button.set_sensitive(True)
self.advanced_button.set_sensitive(True) self.advanced_button.set_sensitive(True)
self.script_button.set_sensitive(True)
def remove_profile(self, widget): def remove_profile(self, widget):
""" Remove a profile from the profile list. """ """ Remove a profile from the profile list. """
@@ -748,7 +674,6 @@ class WiredNetworkEntry(NetworkEntry):
if self.is_full_gui: if self.is_full_gui:
self.button_delete.set_sensitive(False) self.button_delete.set_sensitive(False)
self.advanced_button.set_sensitive(False) self.advanced_button.set_sensitive(False)
self.script_button.set_sensitive(False)
self.connect_button.set_sensitive(False) self.connect_button.set_sensitive(False)
else: else:
self.profile_help.hide() self.profile_help.hide()

View File

@@ -393,6 +393,7 @@ class ConnectThread(threading.Thread):
self.SetStatus('setting_static_ip') self.SetStatus('setting_static_ip')
print 'Setting static IP : ' + self.network['ip'] print 'Setting static IP : ' + self.network['ip']
iface.SetAddress(self.network['ip'], self.network['netmask']) iface.SetAddress(self.network['ip'], self.network['netmask'])
if self.network.get('gateway'):
print 'Setting default gateway : ' + self.network['gateway'] print 'Setting default gateway : ' + self.network['gateway']
iface.SetDefaultRoute(self.network['gateway']) iface.SetDefaultRoute(self.network['gateway'])
else: else:

View File

@@ -40,14 +40,6 @@ wired = None
language = misc.get_language_list_gui() language = misc.get_language_list_gui()
def alert(parent, message):
""" Shows an alert dialog """
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING,
gtk.BUTTONS_OK)
dialog.set_markup(message)
dialog.run()
dialog.destroy()
class PreferencesDialog(object): class PreferencesDialog(object):
""" Class for handling the wicd preferences dialog window. """ """ Class for handling the wicd preferences dialog window. """
def __init__(self, wTree, dbus): def __init__(self, wTree, dbus):

View File

@@ -43,13 +43,14 @@ import getopt
import os import os
import pango import pango
import time import time
from dbus import DBusException import atexit
# Wicd specific imports # Wicd specific imports
from wicd import wpath from wicd import wpath
from wicd import misc from wicd import misc
from wicd import gui from wicd import gui
from wicd import dbusmanager from wicd import dbusmanager
from wicd.guiutil import error
ICON_AVAIL = True ICON_AVAIL = True
USE_EGG = False USE_EGG = False
@@ -364,7 +365,7 @@ class TrayIcon(object):
if DBUS_AVAIL: if DBUS_AVAIL:
self.toggle_wicd_gui() self.toggle_wicd_gui()
else: else:
# gui.error(None, language["daemon_unavailable"]) # error(None, language["daemon_unavailable"])
pass pass
def on_quit(self, widget=None): def on_quit(self, widget=None):
@@ -652,8 +653,8 @@ def setup_dbus(force=True):
misc.PromptToStartDaemon() misc.PromptToStartDaemon()
try: try:
dbusmanager.connect_to_dbus() dbusmanager.connect_to_dbus()
except DBusException: except dbusmanager.DBusException:
gui.error(None, "Could not connect to wicd's D-Bus interface. " + error(None, "Could not connect to wicd's D-Bus interface. " +
"Check the wicd log for error messages.") "Check the wicd log for error messages.")
return False return False
else: else:
@@ -669,12 +670,19 @@ def setup_dbus(force=True):
return True return True
def on_exit():
if DBUS_AVAIL:
try:
daemon.SetGUIOpen(False)
except dbusmanager.DBusException:
pass
def handle_no_dbus(): def handle_no_dbus():
global DBUS_AVAIL global DBUS_AVAIL
DBUS_AVAIL = False DBUS_AVAIL = False
gui.handle_no_dbus(from_tray=True) gui.handle_no_dbus(from_tray=True)
print "Wicd daemon is shutting down!" print "Wicd daemon is shutting down!"
gui.error(None, language['lost_dbus'], block=False) error(None, language['lost_dbus'], block=False)
return False return False
def main(argv): def main(argv):
@@ -709,6 +717,7 @@ def main(argv):
print 'Loading...' print 'Loading...'
setup_dbus() setup_dbus()
atexit.register(on_exit)
if not use_tray or not ICON_AVAIL: if not use_tray or not ICON_AVAIL:
the_gui = gui.appGui(standalone=True) the_gui = gui.appGui(standalone=True)

View File

@@ -91,10 +91,11 @@ class WicdDaemon(dbus.service.Object):
self.vpn_session = None self.vpn_session = None
self.gui_open = False self.gui_open = False
self.suspended = False self.suspended = False
self.debug_mode = False self._debug_mode = False
self.connection_state = misc.NOT_CONNECTED self.connection_state = misc.NOT_CONNECTED
self.connection_info = [""] self.connection_info = [""]
self.auto_connecting = False self.auto_connecting = False
self.prefer_wired = False
self.dhcp_client = 0 self.dhcp_client = 0
self.link_detect_tool = 0 self.link_detect_tool = 0
self.flush_tool = 0 self.flush_tool = 0
@@ -123,6 +124,13 @@ class WicdDaemon(dbus.service.Object):
self.SetForcedDisconnect(True) self.SetForcedDisconnect(True)
print "--no-autoconnect detected, not autoconnecting..." print "--no-autoconnect detected, not autoconnecting..."
def get_debug_mode(self):
return self._debug_mode
def set_debug_mode(self, mode):
self._debug_mode = mode
self.config.debug = mode
debug_mode = property(get_debug_mode, set_debug_mode)
@dbus.service.method('org.wicd.daemon') @dbus.service.method('org.wicd.daemon')
def Hello(self): def Hello(self):
""" Returns the version number. """ Returns the version number.
@@ -320,6 +328,10 @@ class WicdDaemon(dbus.service.Object):
fails it tries a wireless connection. fails it tries a wireless connection.
""" """
# We don't want to rescan/connect if the gui is open.
if self.gui_open:
return
if fresh: if fresh:
self.wireless_bus.Scan() self.wireless_bus.Scan()
if self.wired_bus.CheckPluggedIn(): if self.wired_bus.CheckPluggedIn():
@@ -401,7 +413,8 @@ class WicdDaemon(dbus.service.Object):
def ShouldAutoReconnect(self): def ShouldAutoReconnect(self):
""" Returns True if it's the right time to try autoreconnecting. """ """ Returns True if it's the right time to try autoreconnecting. """
if self.GetAutoReconnect() and not self.CheckIfConnecting() and \ if self.GetAutoReconnect() and not self.CheckIfConnecting() and \
not self.GetForcedDisconnect() and not self.auto_connecting: not self.GetForcedDisconnect() and not self.auto_connecting and \
not self.gui_open:
return True return True
else: else:
return False return False
@@ -495,6 +508,22 @@ class WicdDaemon(dbus.service.Object):
""" Returns the wired autoconnect method. """ """ Returns the wired autoconnect method. """
return int(self.wired_connect_mode) return int(self.wired_connect_mode)
@dbus.service.method('org.wicd.dameon')
def GetPreferWiredNetwork(self):
""" Returns True if wired network preference is set.
If this is True, wicd will switch from a wireless connection
to a wired one if an ethernet connection is available.
"""
return self.prefer_wired
@dbus.service.method('org.wicd.daemon')
def SetPreferWiredNetwork(self, value):
""" Sets the prefer_wired state. """
self.prefer_wired = value
@dbus.service.method('org.wicd.daemon') @dbus.service.method('org.wicd.daemon')
def SetConnectionStatus(self, state, info): def SetConnectionStatus(self, state, info):
""" Sets the connection status. """ Sets the connection status.
@@ -825,6 +854,8 @@ class WicdDaemon(dbus.service.Object):
self.SetLinkDetectionTool(app_conf.get("Settings", "link_detect_tool", self.SetLinkDetectionTool(app_conf.get("Settings", "link_detect_tool",
default=0)) default=0))
self.SetFlushTool(app_conf.get("Settings", "flush_tool", default=0)) self.SetFlushTool(app_conf.get("Settings", "flush_tool", default=0))
self.SetPreferWiredNetwork(app_conf.get("Settings", "prefer_wired",
default=False))
app_conf.write() app_conf.write()
if os.path.isfile(wireless_conf): if os.path.isfile(wireless_conf):
@@ -869,10 +900,18 @@ class WirelessDaemon(dbus.service.Object):
self.hidden_essid = None self.hidden_essid = None
self.daemon = daemon self.daemon = daemon
self.wifi = wifi self.wifi = wifi
self.debug_mode = debug self._debug_mode = debug
self.forced_disconnect = False self.forced_disconnect = False
self.config = ConfigManager(os.path.join(wpath.etc, self.config = ConfigManager(os.path.join(wpath.etc,
"wireless-settings.conf")) "wireless-settings.conf"),
debug=debug)
def get_debug_mode(self):
return self._debug_mode
def set_debug_mode(self, mode):
self._debug_mode = mode
self.config.debug = mode
debug_mode = property(get_debug_mode, set_debug_mode)
@dbus.service.method('org.wicd.daemon.wireless') @dbus.service.method('org.wicd.daemon.wireless')
def SetHiddenNetworkESSID(self, essid): def SetHiddenNetworkESSID(self, essid):
@@ -1218,11 +1257,19 @@ class WiredDaemon(dbus.service.Object):
object_path="/org/wicd/daemon/wired") object_path="/org/wicd/daemon/wired")
self.daemon = daemon self.daemon = daemon
self.wired = wired self.wired = wired
self.debug_mode = debug self._debug_mode = debug
self.forced_disconnect = False self.forced_disconnect = False
self.WiredNetwork = {} self.WiredNetwork = {}
self.config = ConfigManager(os.path.join(wpath.etc, self.config = ConfigManager(os.path.join(wpath.etc,
"wired-settings.conf")) "wired-settings.conf"),
debug=debug)
def get_debug_mode(self):
return self._debug_mode
def set_debug_mode(self, mode):
self._debug_mode = mode
self.config.debug = mode
debug_mode = property(get_debug_mode, set_debug_mode)
@dbus.service.method('org.wicd.daemon.wired') @dbus.service.method('org.wicd.daemon.wired')
def GetWiredIP(self, ifconfig=""): def GetWiredIP(self, ifconfig=""):

View File

@@ -33,6 +33,7 @@ class WirelessInterface() -- Control a wireless network interface.
import os import os
import re import re
import random
from string import maketrans, translate, punctuation from string import maketrans, translate, punctuation
import wpath import wpath
@@ -138,8 +139,8 @@ def NeedsExternalCalls():
def IsValidWpaSuppDriver(driver): def IsValidWpaSuppDriver(driver):
""" Returns True if given string is a valid wpa_supplicant driver. """ """ Returns True if given string is a valid wpa_supplicant driver. """
output = misc.Run(["wpa_supplicant", "-D%s" % driver, "-iwlan9", output = misc.Run(["wpa_supplicant", "-D%s" % driver, "-iolan19",
"-c/etc/zzzzzzzz.confzzz"]) "-c/etc/abcd%sdefzz.zconfz" % random.randint(1, 1000)])
if re.match("Unsupported driver", output): if re.match("Unsupported driver", output):
return False return False
else: else:
@@ -195,7 +196,7 @@ class BaseInterface(object):
paths = ['/sbin/', '/usr/sbin/', '/bin/', '/usr/bin/', paths = ['/sbin/', '/usr/sbin/', '/bin/', '/usr/bin/',
'/usr/local/sbin/', '/usr/local/bin/'] '/usr/local/sbin/', '/usr/local/bin/']
for path in paths: for path in paths:
if os.access("%s%s" % (path, client), os.F_OK): if os.path.exists("%s%s" % (path, client)):
return "%s%s" % (path, client) return "%s%s" % (path, client)
if self.verbose: if self.verbose:
print "WARNING: No path found for %s" % (client) print "WARNING: No path found for %s" % (client)
@@ -416,7 +417,7 @@ class BaseInterface(object):
pipe -- stdout pipe to the dhcpcd process. pipe -- stdout pipe to the dhcpcd process.
Returns: Returns:
'success' if succesful', an error code string otherwise. 'success' if succesful, an error code string otherwise.
""" """
dhcpcd_complete = False dhcpcd_complete = False
@@ -475,7 +476,8 @@ class BaseInterface(object):
def ReleaseDHCP(self): def ReleaseDHCP(self):
""" Release the DHCP lease for this interface. """ """ Release the DHCP lease for this interface. """
if not self.iface: return False if not self.iface: return False
cmd = self.DHCP_RELEASE + " " + self.iface + " 2>/dev/null" cmd = self.DHCP_RELEASE + " " + self.iface
if self.verbose: print cmd
misc.Run(cmd) misc.Run(cmd)
def FlushRoutes(self): def FlushRoutes(self):