diff --git a/curses/prefs_curses.py b/curses/prefs_curses.py old mode 100644 new mode 100755 diff --git a/encryption/templates/peap-tkip b/encryption/templates/peap-tkip old mode 100755 new mode 100644 diff --git a/images/signal-25.png b/images/signal-25.png index d6ef732..c4e12d4 100644 Binary files a/images/signal-25.png and b/images/signal-25.png differ diff --git a/images/signal-50.png b/images/signal-50.png index 586213b..198733a 100644 Binary files a/images/signal-50.png and b/images/signal-50.png differ diff --git a/in/other=55wicd.in b/in/other=55wicd.in index 94ca3f1..7a6a120 100755 --- a/in/other=55wicd.in +++ b/in/other=55wicd.in @@ -2,20 +2,29 @@ # pm-utils hook to handle suspend/resume properly for wicd -. "${PM_FUNCTIONS}" || . "${FUNCTIONS}" +if [ -r "${PM_FUNCTIONS}" ]; then + . "${PM_FUNCTIONS}" +elif [ -r "${FUNCTIONS}" ]; then + . "${FUNCTIONS}" +else + # pm-utils version is too old, or something else is wrong + exit $NA +fi + +RETVAL=0 # Set this to 0 initially wicd_suspend() { # Put wifi interface down - %LIB%suspend.py 2>/dev/null - return $NA + %LIB%suspend.py 1>/dev/null 2>/dev/null + RETVAL=$? } wicd_resume() { # Bring wifi interface back up - %LIB%autoconnect.py 2>/dev/null - return $NA + %LIB%autoconnect.py 1>/dev/null 2>/dev/null + RETVAL=$? } case "$1" in @@ -29,3 +38,32 @@ case "$1" in ;; esac +# We can't return a nonzero exit code (aside from $NA, $DX, and $NX) to +# to pm-utils or the entire sleep operation will be inhibited, so... +# No matter what we do, the log prefix and message will conflict a bit. +case "$RETVAL" in + 0) + exit $RETVAL + ;; + 1) + # Probably the daemon isn't running if this happens + echo "Unable to connect to wicd daemon - is it running?" + exit $DX + ;; + 2) + # This will occur if the daemon encounters an error + echo "Wicd daemon was unable to suspend the network." + exit $DX + ;; + 3) + # Will only be returned by autoconnect.py + # This should never happen, but just in case... + echo "Wicd daemon failed to autoconnect on resume." + exit $DX + ;; + *) + echo "Unknown exit code." + exit $NA + ;; +esac + diff --git a/other/wicd.conf b/in/other=wicd.conf.in old mode 100755 new mode 100644 similarity index 77% rename from other/wicd.conf rename to in/other=wicd.conf.in index 4004de1..ac2fa88 --- a/other/wicd.conf +++ b/in/other=wicd.conf.in @@ -2,6 +2,7 @@ + @@ -13,6 +14,7 @@ + @@ -22,8 +24,18 @@ + + + + + + + + + + diff --git a/in/scripts=wicd-curses.in b/in/scripts=wicd-curses.in new file mode 100755 index 0000000..9b56c42 --- /dev/null +++ b/in/scripts=wicd-curses.in @@ -0,0 +1,2 @@ +#!/bin/bash +exec python -O %LIB%wicd-curses.py $@ diff --git a/in/wicd=wpath.py.in b/in/wicd=wpath.py.in index d871d11..33282e7 100755 --- a/in/wicd=wpath.py.in +++ b/in/wicd=wpath.py.in @@ -55,6 +55,7 @@ pidfile = '%PIDFILE%' initfile = '%INITFILE%' # stores only the file name, i.e. wicd initfilename = '%INITFILENAME%' +wicd_group = '%WICDGROUP%' # BOOLEANS no_install_pmutils = %NO_INSTALL_PMUTILS% @@ -63,6 +64,7 @@ no_install_man = %NO_INSTALL_MAN% no_install_kde = %NO_INSTALL_KDE% no_install_acpi = %NO_INSTALL_ACPI% no_install_docs = %NO_INSTALL_DOCS% +no_install_ncurses = %NO_INSTALL_NCURSES% def chdir(file): """Change directory to the location of the specified file. diff --git a/setup.py b/setup.py index cecaf77..a1e2efb 100755 --- a/setup.py +++ b/setup.py @@ -20,6 +20,7 @@ from distutils.extension import Extension import os import shutil import sys +import subprocess # Be sure to keep this updated! # VERSIONNUMBER @@ -41,21 +42,9 @@ except Exception, e: class configure(Command): description = "configure the paths that Wicd will be installed to" - # lib = '/usr/share/wicd/' - # etc = '/etc/wicd/' - # images = '/usr/share/pixmaps/wicd/' - # encryption = etc + 'encryption/templates/' - # bin = current - # networks = '/var/lib/wicd/configurations/' - # log = '/var/log/wicd/' - # - # python = '/usr/bin/python' - user_options = [ - # these first bunch are DIRECTORIES. - # they need to end a slash ("/") - # which will automatically be tacked on - # in the finalize_options method + # The first bunch is DIRECTORIES - they need to end with a slash ("/"), + # which will automatically be tacked on in the finalize_options method ('lib=', None, 'set the lib directory'), ('share=', None, 'set the share directory'), ('etc=', None, 'set the etc directory'), @@ -72,7 +61,6 @@ class configure(Command): ('dbus=', None, 'set the directory the dbus config file is stored in'), ('desktop=', None, 'set the directory the .desktop file is stored in'), ('icons=', None, "set the base directory for the .desktop file's icons"), - # ('pixmaps=', None, 'directory for images'), ('translations=', None, 'set the directory translations are stored in'), ('autostart=', None, 'set the directory that will be autostarted on desktop login'), ('init=', None, 'set the directory for the init file'), @@ -80,23 +68,24 @@ class configure(Command): ('mandir=', None, 'set the directory for the man pages'), ('kdedir=', None, 'set the kde autostart directory'), - # anything after here is a FILE. - # in other words, a slash ("/") will not automatically - # be added to the end of the path. - # do NOT remove the python= entry as it signals the beginning - # of the file section. + # Anything after this is a FILE; in other words, a slash ("/") will + # not automatically be added to the end of the path. + # Do NOT remove the python= entry, as it signals the beginning of + # the file section. ('python=', None, 'set the path to the Python executable'), ('pidfile=', None, 'set the pid file'), ('initfile=', None, 'set the init file to use'), ('initfilename=', None, "set the name of the init file (don't use)"), + ('wicdgroup=', None, "set the name of the group used for wicd"), - # switches + # Configure switches ('no-install-init', None, "do not install the init file"), ('no-install-man', None, 'do not install the man file'), ('no-install-kde', None, 'do not install the kde autostart file'), ('no-install-acpi', None, 'do not install the suspend.d and resume.d acpi scripts'), ('no-install-pmutils', None, 'do not install the pm-utils hooks'), - ('no-install-docs', None, 'do not install the auxiliary documentation') + ('no-install-docs', None, 'do not install the auxiliary documentation'), + ('no-install-ncurses', None, 'do not install the ncurses client') ] @@ -129,9 +118,9 @@ class configure(Command): self.no_install_acpi = False self.no_install_pmutils = False self.no_install_docs = False + self.no_install_ncurses = False - # figure out what the default init file - # location should be on several different distros + # Determine the default init file location on several different distros self.distro_detect_failed = False @@ -173,9 +162,46 @@ class configure(Command): 'If you have specified --init and --initfile, configure will continue. ' + \ 'Please report this warning, along with the name of your ' + \ 'distribution, to the wicd developers.' + + # Try to get the pm-utils sleep hooks directory from pkg-config and + # the kde prefix from kde-config + # Don't run these in a shell because it's not needed and because shell + # swallows the OSError we would get if {pkg,kde}-config do not exist + # If we don't get anything from *-config, or it didn't run properly, + # or the path is not a proper absolute path, raise an error + try: + pmtemp = subprocess.Popen(["pkg-config","--variable=pm_sleephooks","pm-utils"], stdout=subprocess.PIPE) + returncode = pmtemp.wait() # let it finish, and get the exit code + pmutils_candidate = pmtemp.stdout.readline().strip() # read stdout + if len(pmutils_candidate) == 0 or returncode != 0 or not os.path.isabs(pmutils_candidate): + raise ValueError + else: + self.pmutils = pmutils_candidate + except (OSError, ValueError): + pass # use our default + + try: + kdetemp = subprocess.Popen(["kde-config","--prefix"], stdout=subprocess.PIPE) + returncode = kdetemp.wait() # let it finish, and get the exit code + kdedir_candidate = kdetemp.stdout.readline().strip() # read stdout + if len(kdedir_candidate) == 0 or returncode != 0 or not os.path.isabs(kdedir_candidate): + raise ValueError + else: + self.kdedir = kdedir_candidate + '/share/autostart' + except (OSError, ValueError): + # If kde-config isn't present or returns an error, then we can + # assume that kde isn't installed on the user's system + self.no_install_kde = True + # If it turns out that the assumption above is wrong, then we'll + # do this instead: + #pass # use our default + + self.python = '/usr/bin/python' self.pidfile = '/var/run/wicd/wicd.pid' self.initfilename = os.path.basename(self.initfile) + self.wicdgroup = 'users' + def finalize_options(self): if self.distro_detect_failed == True: @@ -368,12 +394,17 @@ try: (wpath.backends, ['wicd/backends/be-external.py', 'wicd/backends/be-ioctl.py']), (wpath.autostart, ['other/wicd-tray.desktop', ]), ] + if not wpath.no_install_ncurses: + data.append(( wpath.lib, ['curses/curses_misc.py'])) + data.append(( wpath.lib, ['curses/prefs_curses.py'])) + data.append(( wpath.lib, ['curses/wicd-curses.py'])) + data.append(( wpath.bin, ['scripts/wicd-curses'])) piddir = os.path.dirname(wpath.pidfile) if not piddir.endswith('/'): piddir += '/' data.append (( piddir, [] )) if not wpath.no_install_docs: - data.append(( wpath.docdir, [ 'INSTALL', 'LICENSE', 'AUTHORS', 'README' ])) + data.append(( wpath.docdir, [ 'INSTALL', 'LICENSE', 'AUTHORS', 'README', 'CHANGES' ])) if not wpath.no_install_kde: data.append(( wpath.kdedir, [ 'other/wicd-tray.desktop' ])) if not wpath.no_install_init: diff --git a/wicd/autoconnect.py b/wicd/autoconnect.py index 472a2d1..787aae5 100755 --- a/wicd/autoconnect.py +++ b/wicd/autoconnect.py @@ -1,8 +1,8 @@ #!/usr/bin/python # -# Copyright (C) 2007 Adam Blackburn -# Copyright (C) 2007 Dan O'Reilly +# 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 @@ -21,22 +21,37 @@ import dbus import time import gobject import sys -from dbus.mainloop.glib import DBusGMainLoop -DBusGMainLoop(set_as_default=True) -bus = dbus.SystemBus() -proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon') -daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon') -loop = gobject.MainLoop() +if getattr(dbus, 'version', (0, 0, 0)) < (0, 80, 0): + import dbus.glib +else: + from dbus.mainloop.glib import DBusGMainLoop + DBusGMainLoop(set_as_default=True) +try: + bus = dbus.SystemBus() + proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon') + daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon') +except Exception, e: + print>>sys.stderr, "Exception caught: %s" % str(e) + print>>sys.stderr, 'Could not connect to daemon.' + sys.exit(1) def handler(*args): loop.quit() -print daemon.Hello() -time.sleep(3) -daemon.SetSuspend(False) -if not daemon.CheckIfConnecting(): - daemon.SetForcedDisconnect(False) - daemon.AutoConnect(True, reply_handler=handler, error_handler=handler) +def error_handler(*args): + print>>sys.stderr, 'Async error autoconnecting.' + sys.exit(3) +if __name__ == '__main__': + try: + time.sleep(3) + daemon.SetSuspend(False) + if not daemon.CheckIfConnecting(): + daemon.SetForcedDisconnect(False) + daemon.AutoConnect(True, reply_handler=handler, error_handler=handler) + except Exception, e: + print>>sys.stderr, "Exception caught: %s" % str(e) + print>>sys.stderr, 'Error autoconnecting.' + sys.exit(2) diff --git a/wicd/gui.py b/wicd/gui.py index 93fbb93..58aefc6 100644 --- a/wicd/gui.py +++ b/wicd/gui.py @@ -579,8 +579,8 @@ class appGui(object): """ if fresh: - # Even if it is None, it can still be passed. - wireless.SetHiddenNetworkESSID(noneToString(hidden)) + if hidden: + wireless.SetHiddenNetworkESSID(noneToString(hidden)) self.refresh_clicked() return print "refreshing..." @@ -665,90 +665,14 @@ class appGui(object): # Now save the settings. if nettype == "wireless": - if not self.save_wireless_settings(networkid, entry, networkentry): + if not networkentry.save_wireless_settings(networkid): return False elif nettype == "wired": - if not self.save_wired_settings(entry): + if not networkentry.save_wired_settings(): return False return True - - def _save_gen_settings(self, entry): - """ Save settings common to wired and wireless settings dialogs. """ - if entry.chkbox_static_ip.get_active(): - entry.set_net_prop("ip", noneToString(entry.txt_ip.get_text())) - entry.set_net_prop("netmask", noneToString(entry.txt_netmask.get_text())) - entry.set_net_prop("gateway", noneToString(entry.txt_gateway.get_text())) - else: - entry.set_net_prop("ip", '') - entry.set_net_prop("netmask", '') - entry.set_net_prop("gateway", '') - - if entry.chkbox_static_dns.get_active() and \ - not entry.chkbox_global_dns.get_active(): - entry.set_net_prop('use_static_dns', True) - entry.set_net_prop('use_global_dns', False) - entry.set_net_prop('dns_domain', noneToString(entry.txt_domain.get_text())) - entry.set_net_prop("search_domain", noneToString(entry.txt_search_dom.get_text())) - entry.set_net_prop("dns1", noneToString(entry.txt_dns_1.get_text())) - entry.set_net_prop("dns2", noneToString(entry.txt_dns_2.get_text())) - entry.set_net_prop("dns3", noneToString(entry.txt_dns_3.get_text())) - elif entry.chkbox_static_dns.get_active() and \ - entry.chkbox_global_dns.get_active(): - entry.set_net_prop('use_static_dns', True) - entry.set_net_prop('use_global_dns', True) - else: - entry.set_net_prop('use_static_dns', False) - entry.set_net_prop('use_global_dns', False) - entry.set_net_prop('dns_domain', '') - entry.set_net_prop("search_domain", '') - entry.set_net_prop("dns1", '') - entry.set_net_prop("dns2", '') - entry.set_net_prop("dns3", '') - - def save_wired_settings(self, entry): - """ Save wired network settings. """ - self._save_gen_settings(entry) - wired.SaveWiredNetworkProfile(entry.prof_name) - return True - - def save_wireless_settings(self, networkid, entry, netent): - """ Save wireless network settings. """ - # Check encryption info - if entry.chkbox_encryption.get_active(): - print "setting encryption info..." - encryption_info = entry.encryption_info - encrypt_methods = misc.LoadEncryptionMethods() - entry.set_net_prop("enctype", - encrypt_methods[entry.combo_encryption.get_active()][1]) - for x in encryption_info: - if encryption_info[x].get_text() == "": - error(self.window, language['encrypt_info_missing']) - return False - entry.set_net_prop(x, noneToString(encryption_info[x]. - get_text())) - elif not entry.chkbox_encryption.get_active() and \ - wireless.GetWirelessProperty(networkid, "encryption"): - error(self.window, language['enable_encryption']) - return False - else: - print 'encryption is ' + str(wireless.GetWirelessProperty(networkid, - "encryption")) - print "no encryption specified..." - entry.set_net_prop("enctype", "None") - self._save_gen_settings(entry) - entry.set_net_prop("automatic", - noneToString(netent.chkbox_autoconnect.get_active())) - - if entry.chkbox_global_settings.get_active(): - entry.set_net_prop('use_settings_globally', True) - else: - entry.set_net_prop('use_settings_globally', False) - wireless.RemoveGlobalEssidEntry(networkid) - - wireless.SaveWirelessNetworkProfile(networkid) - return True def edit_advanced(self, widget, event, ttype, networkid, networkentry): """ Display the advanced settings dialog. diff --git a/wicd/netentry.py b/wicd/netentry.py index 40a5fd3..fca87fb 100644 --- a/wicd/netentry.py +++ b/wicd/netentry.py @@ -237,6 +237,39 @@ class AdvancedSettingsDialog(gtk.Dialog): super(AdvancedSettingsDialog, self).destroy() self.destroy() del self + + def save_settings(self): + """ Save settings common to wired and wireless settings dialogs. """ + if self.chkbox_static_ip.get_active(): + self.set_net_prop("ip", noneToString(self.txt_ip.get_text())) + self.set_net_prop("netmask", noneToString(self.txt_netmask.get_text())) + self.set_net_prop("gateway", noneToString(self.txt_gateway.get_text())) + else: + self.set_net_prop("ip", '') + self.set_net_prop("netmask", '') + self.set_net_prop("gateway", '') + + if self.chkbox_static_dns.get_active() and \ + not self.chkbox_global_dns.get_active(): + self.set_net_prop('use_static_dns', True) + self.set_net_prop('use_global_dns', False) + self.set_net_prop('dns_domain', noneToString(self.txt_domain.get_text())) + self.set_net_prop("search_domain", noneToString(self.txt_search_dom.get_text())) + self.set_net_prop("dns1", noneToString(self.txt_dns_1.get_text())) + self.set_net_prop("dns2", noneToString(self.txt_dns_2.get_text())) + self.set_net_prop("dns3", noneToString(self.txt_dns_3.get_text())) + elif self.chkbox_static_dns.get_active() and \ + self.chkbox_global_dns.get_active(): + self.set_net_prop('use_static_dns', True) + self.set_net_prop('use_global_dns', True) + else: + self.set_net_prop('use_static_dns', False) + self.set_net_prop('use_global_dns', False) + self.set_net_prop('dns_domain', '') + self.set_net_prop("search_domain", '') + self.set_net_prop("dns1", '') + self.set_net_prop("dns2", '') + self.set_net_prop("dns3", '') class WiredSettingsDialog(AdvancedSettingsDialog): @@ -263,6 +296,11 @@ class WiredSettingsDialog(AdvancedSettingsDialog): self.txt_search_dom.set_text(self.format_entry("search_domain")) self.chkbox_global_dns.set_active(bool(wired.GetWiredProperty("use_global_dns"))) self.reset_static_checkboxes() + + def save_settings(self): + AdvancedSettingsDialog.save_settings(self) + wired.SaveWiredNetworkProfile(self.prof_name) + return True def format_entry(self, label): """ Helper method to fetch and format wired properties. """ @@ -353,7 +391,6 @@ class WirelessSettingsDialog(AdvancedSettingsDialog): self.chkbox_global_settings.set_active(bool(wireless.GetWirelessProperty(networkID, 'use_settings_globally'))) - activeID = -1 # Set the menu to this item when we are done user_enctype = wireless.GetWirelessProperty(networkID, "enctype") for x, enc_type in enumerate(self.encrypt_types): @@ -368,6 +405,40 @@ class WirelessSettingsDialog(AdvancedSettingsDialog): else: self.combo_encryption.set_active(0) self.change_encrypt_method() + + def save_settings(self, networkid): + # Check encryption info + if self.chkbox_encryption.get_active(): + print "setting encryption info..." + encryption_info = self.encryption_info + encrypt_methods = misc.LoadEncryptionMethods() + self.set_net_prop("enctype", + encrypt_methods[self.combo_encryption.get_active()][1]) + for x in encryption_info: + if encryption_info[x].get_text() == "": + error(self, language['encrypt_info_missing']) + return False + self.set_net_prop(x, noneToString(encryption_info[x]. + get_text())) + elif not self.chkbox_encryption.get_active() and \ + wireless.GetWirelessProperty(networkid, "encryption"): + error(self, language['enable_encryption']) + return False + else: + print 'encryption is ' + str(wireless.GetWirelessProperty(networkid, + "encryption")) + print "no encryption specified..." + self.set_net_prop("enctype", "None") + AdvancedSettingsDialog.save_settings(self) + + if self.chkbox_global_settings.get_active(): + self.set_net_prop('use_settings_globally', True) + else: + self.set_net_prop('use_settings_globally', False) + wireless.RemoveGlobalEssidEntry(networkid) + + wireless.SaveWirelessNetworkProfile(networkid) + return True def format_entry(self, networkid, label): """ Helper method for fetching/formatting wireless properties. """ @@ -575,6 +646,10 @@ class WiredNetworkEntry(NetworkEntry): self.destroy() del self + def save_wired_settings(self): + """ Save wired network settings. """ + return self.advanced_dialog.save_settings() + def edit_scripts(self, widget=None, event=None): """ Launch the script editting dialog. """ profile = self.combo_profile_names.get_active_text() @@ -756,6 +831,10 @@ class WirelessNetworkEntry(NetworkEntry): """ Escapes special characters so they're displayed correctly. """ return val.replace("&", "&").replace("<", "<").\ replace(">",">").replace("'", "'").replace('"', """) + + def save_wireless_settings(self, networkid): + """ Save wireless network settings. """ + return self.advanced_dialog.save_settings(networkid) def destroy_called(self, *args): """ Clean up everything. """ diff --git a/wicd/networking.py b/wicd/networking.py index 160e3a3..543f524 100644 --- a/wicd/networking.py +++ b/wicd/networking.py @@ -411,12 +411,7 @@ class ConnectThread(threading.Thread): BACKEND.StopDHCP() def connect_aborted(self, reason): - """ Sets the thread status to aborted in a thread-safe way. - - Sets the status to aborted, and also delays returning for - a few seconds to make sure the message is readable - - """ + """ Sets the thread status to aborted. """ if self.abort_reason: reason = self.abort_reason self.connecting_message = reason diff --git a/wicd/suspend.py b/wicd/suspend.py index c43e2a3..217a655 100755 --- a/wicd/suspend.py +++ b/wicd/suspend.py @@ -8,8 +8,8 @@ Used for when a laptop enters hibernation/suspension. """ # -# Copyright (C) 2007 Adam Blackburn -# Copyright (C) 2007 Dan O'Reilly +# 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 @@ -26,13 +26,17 @@ Used for when a laptop enters hibernation/suspension. import dbus import dbus.service +import sys try: bus = dbus.SystemBus() proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon') daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon') except Exception, e: - print "Exception caught: %s" % str(e) + print>>sys.stderr, "Exception caught: %s" % str(e) + print>>sys.stderr, 'Could not connect to daemon.' + sys.exit(1) + if __name__ == '__main__': @@ -41,5 +45,7 @@ if __name__ == '__main__': daemon.SetForcedDisconnect(False) daemon.SetSuspend(True) except Exception, e: - print "Exception caught: %s" % str(e) - + print>>sys.stderr, "Exception caught: %s" % str(e) + print>>sys.stderr, 'Error setting suspend.' + sys.exit(2) +