mirror of
https://github.com/gryf/wicd.git
synced 2026-01-07 14:24:22 +01:00
Merged my experimental branch into this.
This commit is contained in:
0
encryption/templates/peap-tkip
Executable file → Normal file
0
encryption/templates/peap-tkip
Executable file → Normal file
@@ -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
|
||||
|
||||
|
||||
12
other/wicd.conf → in/other=wicd.conf.in
Executable file → Normal file
12
other/wicd.conf → in/other=wicd.conf.in
Executable file → Normal file
@@ -2,6 +2,7 @@
|
||||
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
|
||||
<policy user="root">
|
||||
<allow own="org.wicd.daemon"/>
|
||||
<allow send_destination="org.wicd.daemon"/>
|
||||
@@ -13,6 +14,7 @@
|
||||
<allow send_destination="org.wicd.daemon.config"/>
|
||||
<allow send_interface="org.wicd.daemon.config"/>
|
||||
</policy>
|
||||
|
||||
<policy at_console="true">
|
||||
<allow send_destination="org.wicd.daemon"/>
|
||||
<allow send_interface="org.wicd.daemon"/>
|
||||
@@ -22,8 +24,18 @@
|
||||
<allow send_interface="org.wicd.daemon.wired"/>
|
||||
<allow send_destination="org.wicd.daemon.config"/>
|
||||
<allow send_interface="org.wicd.daemon.config"/>
|
||||
<allow send_interface="org.freedesktop.DBus.Introspectable"/>
|
||||
</policy>
|
||||
|
||||
<policy context="default">
|
||||
<deny own="org.wicd.daemon"/>
|
||||
</policy>
|
||||
|
||||
<!-- This Unix group will have permission to use Wicd's gui -->
|
||||
<policy group="%WICDGROUP%">
|
||||
<allow send_interface="org.freedesktop.DBus.Introspectable"/>
|
||||
<allow send_destination="org.wicd.daemon"/>
|
||||
<allow send_interface="org.wicd.daemon"/>
|
||||
</policy>
|
||||
|
||||
</busconfig>
|
||||
@@ -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%
|
||||
|
||||
72
setup.py
72
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,17 +68,17 @@ 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'),
|
||||
@@ -130,8 +118,7 @@ class configure(Command):
|
||||
self.no_install_pmutils = False
|
||||
self.no_install_docs = 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 +160,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:
|
||||
@@ -373,7 +397,7 @@ try:
|
||||
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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
""" Suspends the wicd daemon.
|
||||
|
||||
Sets a flag in the daemon that will stop it from monitoring network status.
|
||||
Sets a flag in the daemon that will stop it from monitoring networkg status.
|
||||
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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user