diff options
author | Guido Günther <agx@sigxcpu.org> | 2020-04-06 15:37:53 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2020-04-06 15:38:53 +0200 |
commit | 4480d9de3823a2c223b02bb8ad516947d0854986 (patch) | |
tree | cafff2376c73a2d71f9769042bc0aa1388bcf2b7 /src/ppm/modemproxy.py | |
parent | 4501f4ce81cf10152808282fd669e9b6653e5c93 (diff) |
Fix modem enablement
This got broken when switching to the ModemManager1 API. Instead
of checking the error, check state upfront.
Diffstat (limited to 'src/ppm/modemproxy.py')
-rw-r--r-- | src/ppm/modemproxy.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/ppm/modemproxy.py b/src/ppm/modemproxy.py index 31aa802..3943b7f 100644 --- a/src/ppm/modemproxy.py +++ b/src/ppm/modemproxy.py @@ -25,7 +25,6 @@ MM_DBUS_TIMEOUT = 5000 MM_DBUS_FLAGS = (Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES | Gio.DBusProxyFlags.DO_NOT_CONNECT_SIGNALS) - class ModemError(Exception): def __init__(self, msg): self.msg = msg @@ -41,6 +40,8 @@ class Modem(GObject.GObject): MM_DBUS_INTERFACE_MODEM = 'org.freedesktop.ModemManager1.Modem' MM_DBUS_INTERFACE_MODEM_GSM_USSD = "{}.Modem3gpp.Ussd".format(MM_DBUS_INTERFACE_MODEM) + MM_STATE_ENABLED = 6 + def on_new_proxy_done(self, proxy, res, iface_name): try: _proxy = proxy.new_for_bus_finish(res) @@ -55,7 +56,7 @@ class Modem(GObject.GObject): self._modem_proxy = None Gio.DBusProxy.new_for_bus(Gio.BusType.SYSTEM, - MM_DBUS_FLAGS, + Gio.DBusProxyFlags.DO_NOT_CONNECT_SIGNALS, None, MM_DBUS_SERVICE, self.path, @@ -87,6 +88,11 @@ class Modem(GObject.GObject): def ussd_proxy(self): return self._ussd_proxy + @property + def enabled(self): + variant = self.modem_proxy.get_cached_property("State") + return variant.get_int32() >= self.MM_STATE_ENABLED + class ModemManagerProxy(GObject.GObject): """Interface to ModemManager DBus API |