X-Git-Url: https://git.distorted.org.uk/~mdw/tripe/blobdiff_plain/2079efa1cb6a46e8917329f52306e6629f31fd58..0c614d591a785cdd6de98064582fcef596155fa5:/svc/conntrack.in diff --git a/svc/conntrack.in b/svc/conntrack.in index 8564a619..95a46867 100644 --- a/svc/conntrack.in +++ b/svc/conntrack.in @@ -10,19 +10,18 @@ ### ### This file is part of Trivial IP Encryption (TrIPE). ### -### TrIPE is free software; you can redistribute it and/or modify -### it under the terms of the GNU General Public License as published by -### the Free Software Foundation; either version 2 of the License, or -### (at your option) any later version. +### TrIPE is free software: you can redistribute it and/or modify it under +### the terms of the GNU General Public License as published by the Free +### Software Foundation; either version 3 of the License, or (at your +### option) any later version. ### -### TrIPE 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. +### TrIPE 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 TrIPE; if not, write to the Free Software Foundation, -### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +### along with TrIPE. If not, see . VERSION = '@VERSION@' @@ -398,6 +397,38 @@ class NetworkManagerMonitor (object): if props.get('Default', False): netupdown(True, ['nm', 'default-connection-change']) +##-------------------------------------------------------------------------- +### Connman monitor. + +CM_NAME = 'net.connman' +CM_PATH = '/' +CM_IFACE = 'net.connman.Manager' + +class ConnManMonitor (object): + """ + Watch ConnMan signls for changes in network state. + """ + + ## Strategy. Everything seems to be usefully encoded in the `State' + ## property. If it's `offline', `idle' or `ready' then we don't expect a + ## network connection. During handover from one network to another, the + ## property passes through `ready' to `online'. + + def attach(me, bus): + try: + cm = bus.get_object(CM_NAME, CM_PATH) + props = cm.GetProperties(dbus_interface = CM_IFACE) + state = props['State'] + netupdown(state == 'online', ['connman', 'initially-%s' % state]) + except D.DBusException: + pass + bus.add_signal_receiver(me._cm_state, 'PropertyChanged', + CM_IFACE, CM_NAME, CM_PATH) + + def _cm_state(me, prop, value): + if prop != 'State': return + netupdown(value == 'online', ['connman', value]) + ###-------------------------------------------------------------------------- ### Maemo monitor. @@ -549,6 +580,7 @@ def init(): T.Coroutine(kickpeers, name = 'kickpeers').switch() DBM = DBusMonitor() DBM.addmon(NetworkManagerMonitor()) + DBM.addmon(ConnManMonitor()) DBM.addmon(MaemoICdMonitor()) G.timeout_add_seconds(30, lambda: (netupdown(True, ['interval-timer']) or True))