|
| 1 | +"""gsd-rfkill mock template |
| 2 | +
|
| 3 | +This creates the expected properties of the GNOME Settings Daemon's |
| 4 | +rfkill object. You can specify any property such as AirplaneMode in |
| 5 | +"parameters". |
| 6 | +""" |
| 7 | + |
| 8 | +# This program is free software; you can redistribute it and/or modify it under |
| 9 | +# the terms of the GNU Lesser General Public License as published by the Free |
| 10 | +# Software Foundation; either version 3 of the License, or (at your option) any |
| 11 | +# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text |
| 12 | +# of the license. |
| 13 | + |
| 14 | +__author__ = "Guido Günther" |
| 15 | +__copyright__ = "2024 The Phosh Developers" |
| 16 | + |
| 17 | +import dbus |
| 18 | + |
| 19 | +from dbusmock import MOCK_IFACE |
| 20 | + |
| 21 | +SYSTEM_BUS = False |
| 22 | +BUS_NAME = "org.gnome.SettingsDaemon.Rfkill" |
| 23 | +MAIN_OBJ = "/org/gnome/SettingsDaemon/Rfkill" |
| 24 | +MAIN_IFACE = "org.gnome.SettingsDaemon.Rfkill" |
| 25 | + |
| 26 | + |
| 27 | +def load(mock, parameters): |
| 28 | + props = dbus.Dictionary( |
| 29 | + { |
| 30 | + "AirplaneMode": parameters.get("AirplaneMode", False), |
| 31 | + "BluetoothAirplaneMode": parameters.get("BluetoothAirplaneMode", False), |
| 32 | + "BluetoothHardwareAirplaneMode": parameters.get("BluetoothHardwareAirplaneMode", False), |
| 33 | + "BluetoothHasAirplaneMode": parameters.get("BluetoothHasAirplanemode", True), |
| 34 | + "HardwareAirplaneMode": parameters.get("HardwareAirplaneMode", False), |
| 35 | + "HasAirplaneMode": parameters.get("HasAirplaneMode", True), |
| 36 | + "ShouldShowAirplaneMode": parameters.get("ShouldShowAirplaneMode", True), |
| 37 | + "WwanAirplaneMode": parameters.get("WwanAirplaneMode", False), |
| 38 | + "WwanHardwareAirplaneMode": parameters.get("WwanHardwareAirplaneMode", False), |
| 39 | + "WwanHasAirplaneMode": parameters.get("WwanHasAirplaneMode", True), |
| 40 | + }, |
| 41 | + signature="sv", |
| 42 | + ) |
| 43 | + mock.AddProperties(MAIN_IFACE, props) |
| 44 | + |
| 45 | + |
| 46 | +@dbus.service.method(MOCK_IFACE, in_signature="b", out_signature="b") |
| 47 | +def SetAirplaneMode(self, mode): |
| 48 | + """ |
| 49 | + Convenience method to toggle airplane mode |
| 50 | + """ |
| 51 | + self.props[MAIN_IFACE]["AirplaneMode"] = mode |
| 52 | + self.props[MAIN_IFACE]["BluetoothAirplaneMode"] = mode |
| 53 | + self.props[MAIN_IFACE]["WwanAirplaneMode"] = mode |
| 54 | + return mode |
0 commit comments