mirror of
https://github.com/gryf/wicd.git
synced 2026-03-08 02:26:01 +01:00
Change defaul behaviour: now wicd kills connections when is shutdown. This behaviour can be overriden with -c/--keep-connection (to the daemon).
This commit is contained in:
@@ -80,7 +80,7 @@ class WicdDaemon(dbus.service.Object, object):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, bus_name, object_path="/org/wicd/daemon",
|
def __init__(self, bus_name, object_path="/org/wicd/daemon",
|
||||||
auto_connect=True):
|
auto_connect=True, keep_connection=False):
|
||||||
""" Initializes the daemon DBus object. """
|
""" Initializes the daemon DBus object. """
|
||||||
dbus.service.Object.__init__(self, bus_name=bus_name,
|
dbus.service.Object.__init__(self, bus_name=bus_name,
|
||||||
object_path=object_path)
|
object_path=object_path)
|
||||||
@@ -118,6 +118,7 @@ class WicdDaemon(dbus.service.Object, object):
|
|||||||
self.dns3 = None
|
self.dns3 = None
|
||||||
self.search_dom = None
|
self.search_dom = None
|
||||||
self.auto_reconnect = True
|
self.auto_reconnect = True
|
||||||
|
self.keep_connection = keep_connection
|
||||||
|
|
||||||
# This will speed up the scanning process - if a client doesn't
|
# This will speed up the scanning process - if a client doesn't
|
||||||
# need a fresh scan, just feed them the old one. A fresh scan
|
# need a fresh scan, just feed them the old one. A fresh scan
|
||||||
@@ -841,7 +842,9 @@ class WicdDaemon(dbus.service.Object, object):
|
|||||||
@dbus.service.signal(dbus_interface='org.wicd.daemon', signature='')
|
@dbus.service.signal(dbus_interface='org.wicd.daemon', signature='')
|
||||||
def DaemonClosing(self):
|
def DaemonClosing(self):
|
||||||
""" Emits a signal indicating the daemon will be closing. """
|
""" Emits a signal indicating the daemon will be closing. """
|
||||||
pass
|
# By default, disconnect network links on close.
|
||||||
|
if not self.keep_connection:
|
||||||
|
self.Disconnect()
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon', in_signature='uav')
|
@dbus.service.method('org.wicd.daemon', in_signature='uav')
|
||||||
def EmitStatusChanged(self, state, info):
|
def EmitStatusChanged(self, state, info):
|
||||||
@@ -1704,6 +1707,7 @@ wireless (and wired) connection daemon.
|
|||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
\t-a\t--no-autoconnect\tDon't auto-scan/auto-connect.
|
\t-a\t--no-autoconnect\tDon't auto-scan/auto-connect.
|
||||||
|
\t-c\t--keep-connection\tKeep connection alive when daemon stops.
|
||||||
\t-f\t--no-daemon\tDon't daemonize (run in foreground).
|
\t-f\t--no-daemon\tDon't daemonize (run in foreground).
|
||||||
\t-e\t--no-stderr\tDon't redirect stderr.
|
\t-e\t--no-stderr\tDon't redirect stderr.
|
||||||
\t-n\t--no-poll\tDon't monitor network status.
|
\t-n\t--no-poll\tDon't monitor network status.
|
||||||
@@ -1803,11 +1807,13 @@ def main(argv):
|
|||||||
redirect_stdout = True
|
redirect_stdout = True
|
||||||
auto_connect = True
|
auto_connect = True
|
||||||
kill = False
|
kill = False
|
||||||
|
keep_connection = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:], 'fenoahk',
|
opts, args = getopt.getopt(sys.argv[1:], 'fenoahkc',
|
||||||
['help', 'no-daemon', 'no-poll', 'no-stderr',
|
['help', 'no-daemon', 'no-poll', 'no-stderr',
|
||||||
'no-stdout', 'no-autoconnect', 'kill'])
|
'no-stdout', 'no-autoconnect', 'kill',
|
||||||
|
'keep-connection'])
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
# Print help information and exit
|
# Print help information and exit
|
||||||
usage()
|
usage()
|
||||||
@@ -1830,6 +1836,8 @@ def main(argv):
|
|||||||
no_poll = True
|
no_poll = True
|
||||||
if o in ('-k', '--kill'):
|
if o in ('-k', '--kill'):
|
||||||
kill = True
|
kill = True
|
||||||
|
if o in ('-c', '--keep-connection'):
|
||||||
|
keep_connection = True
|
||||||
|
|
||||||
if kill:
|
if kill:
|
||||||
try:
|
try:
|
||||||
@@ -1908,7 +1916,8 @@ def main(argv):
|
|||||||
# Open the DBUS session
|
# Open the DBUS session
|
||||||
bus = dbus.SystemBus()
|
bus = dbus.SystemBus()
|
||||||
wicd_bus = dbus.service.BusName('org.wicd.daemon', bus=bus)
|
wicd_bus = dbus.service.BusName('org.wicd.daemon', bus=bus)
|
||||||
daemon = WicdDaemon(wicd_bus, auto_connect=auto_connect)
|
daemon = WicdDaemon(wicd_bus, auto_connect=auto_connect,
|
||||||
|
keep_connection=keep_connection)
|
||||||
child_pid = None
|
child_pid = None
|
||||||
if not no_poll:
|
if not no_poll:
|
||||||
child_pid = Popen([wpath.python, "-O",
|
child_pid = Popen([wpath.python, "-O",
|
||||||
|
|||||||
Reference in New Issue
Block a user