Skip to content

Commit

Permalink
improvement(dbus): use @dbus_service_signal decorator
Browse files Browse the repository at this point in the history
There is no change in behavior, since @dbus_service_signal currently
plainly delages to @dus.service.signal.
  • Loading branch information
thom311 authored and erig0 committed Jan 12, 2024
1 parent 8822bab commit 07612bd
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 85 deletions.
19 changes: 10 additions & 9 deletions src/firewall/server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
handle_exceptions,
dbus_handle_exceptions,
dbus_service_method,
dbus_service_signal,
dbus_service_method_deprecated,
dbus_service_signal_deprecated,
dbus_polkit_require_auth,
Expand Down Expand Up @@ -891,7 +892,7 @@ def Set(self, interface_name, property_name, new_value, sender=None):
"Interface '%s' does not exist" % interface_name
)

@dbus.service.signal(dbus.PROPERTIES_IFACE, signature="sa{sv}as")
@dbus_service_signal(dbus.PROPERTIES_IFACE, signature="sa{sv}as")
def PropertiesChanged(
self, interface_name, changed_properties, invalidated_properties
):
Expand Down Expand Up @@ -954,7 +955,7 @@ def setLockdownWhitelist(self, settings, sender=None): # pylint: disable=W0613
self.config.get_policies().lockdown_whitelist.write()
self.LockdownWhitelistUpdated()

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_POLICIES)
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_POLICIES)
@dbus_handle_exceptions
def LockdownWhitelistUpdated(self):
log.debug1("config.policies.LockdownWhitelistUpdated()")
Expand Down Expand Up @@ -1177,7 +1178,7 @@ def addIPSet(self, ipset, settings, sender=None):
config_ipset = self._addIPSet(obj)
return config_ipset

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG, signature="s")
@dbus_handle_exceptions
def IPSetAdded(self, ipset):
ipset = dbus_to_python(ipset, str)
Expand Down Expand Up @@ -1231,7 +1232,7 @@ def addIcmpType(self, icmptype, settings, sender=None):
config_icmptype = self._addIcmpType(obj)
return config_icmptype

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG, signature="s")
@dbus_handle_exceptions
def IcmpTypeAdded(self, icmptype):
log.debug1("config.IcmpTypeAdded('%s')" % (icmptype))
Expand Down Expand Up @@ -1298,7 +1299,7 @@ def addService2(self, service, settings, sender=None):
config_service = self._addService(obj)
return config_service

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG, signature="s")
@dbus_handle_exceptions
def ServiceAdded(self, service):
log.debug1("config.ServiceAdded('%s')" % (service))
Expand Down Expand Up @@ -1418,7 +1419,7 @@ def addZone2(self, zone, settings, sender=None):
config_zone = self._addZone(obj)
return config_zone

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG, signature="s")
@dbus_handle_exceptions
def ZoneAdded(self, zone):
log.debug1("config.ZoneAdded('%s')" % (zone))
Expand Down Expand Up @@ -1469,7 +1470,7 @@ def addPolicy(self, policy, settings, sender=None):
config_policy = self._addPolicy(obj)
return config_policy

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG, signature="s")
@dbus_handle_exceptions
def PolicyAdded(self, policy):
log.debug1("config.PolicyAdded('%s')" % (policy))
Expand Down Expand Up @@ -1524,7 +1525,7 @@ def addHelper(self, helper, settings, sender=None):
config_helper = self._addHelper(obj)
return config_helper

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG, signature="s")
@dbus_handle_exceptions
def HelperAdded(self, helper):
helper = dbus_to_python(helper, str)
Expand Down Expand Up @@ -1557,7 +1558,7 @@ def update(self, settings, sender=None): # pylint: disable=W0613
self.Updated()

@dbus_service_signal_deprecated(config.dbus.DBUS_INTERFACE_CONFIG_DIRECT)
@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_DIRECT)
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_DIRECT)
@dbus_handle_exceptions
def Updated(self):
log.debug1("config.direct.Updated()")
Expand Down
9 changes: 5 additions & 4 deletions src/firewall/server/config_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
handle_exceptions,
dbus_handle_exceptions,
dbus_service_method,
dbus_service_signal,
dbus_polkit_require_auth,
)
from firewall import errors
Expand Down Expand Up @@ -147,7 +148,7 @@ def Set(self, interface_name, property_name, new_value, sender=None):
"Property '%s' is read-only" % property_name
)

@dbus.service.signal(dbus.PROPERTIES_IFACE, signature="sa{sv}as")
@dbus_service_signal(dbus.PROPERTIES_IFACE, signature="sa{sv}as")
def PropertiesChanged(
self, interface_name, changed_properties, invalidated_properties
):
Expand Down Expand Up @@ -208,7 +209,7 @@ def loadDefaults(self, sender=None):
self.obj = self.config.load_helper_defaults(self.obj)
self.Updated(self.obj.name)

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_HELPER, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_HELPER, signature="s")
@dbus_handle_exceptions
def Updated(self, name):
log.debug1("%s.Updated('%s')" % (self._log_prefix, name))
Expand All @@ -224,7 +225,7 @@ def remove(self, sender=None):
self.config.remove_helper(self.obj)
self.parent.removeHelper(self.obj)

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_HELPER, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_HELPER, signature="s")
@dbus_handle_exceptions
def Removed(self, name):
log.debug1("%s.Removed('%s')" % (self._log_prefix, name))
Expand All @@ -241,7 +242,7 @@ def rename(self, name, sender=None):
self.obj = self.config.rename_helper(self.obj, name)
self.Renamed(name)

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_HELPER, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_HELPER, signature="s")
@dbus_handle_exceptions
def Renamed(self, name):
log.debug1("%s.Renamed('%s')" % (self._log_prefix, name))
Expand Down
9 changes: 5 additions & 4 deletions src/firewall/server/config_icmptype.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
handle_exceptions,
dbus_handle_exceptions,
dbus_service_method,
dbus_service_signal,
dbus_polkit_require_auth,
)
from firewall import errors
Expand Down Expand Up @@ -147,7 +148,7 @@ def Set(self, interface_name, property_name, new_value, sender=None):
"Property '%s' is read-only" % property_name
)

@dbus.service.signal(dbus.PROPERTIES_IFACE, signature="sa{sv}as")
@dbus_service_signal(dbus.PROPERTIES_IFACE, signature="sa{sv}as")
def PropertiesChanged(
self, interface_name, changed_properties, invalidated_properties
):
Expand Down Expand Up @@ -209,7 +210,7 @@ def loadDefaults(self, sender=None):
self.obj = self.config.load_icmptype_defaults(self.obj)
self.Updated(self.obj.name)

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_ICMPTYPE, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_ICMPTYPE, signature="s")
@dbus_handle_exceptions
def Updated(self, name):
log.debug1("%s.Updated('%s')" % (self._log_prefix, name))
Expand All @@ -225,7 +226,7 @@ def remove(self, sender=None):
self.config.remove_icmptype(self.obj)
self.parent.removeIcmpType(self.obj)

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_ICMPTYPE, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_ICMPTYPE, signature="s")
@dbus_handle_exceptions
def Removed(self, name):
log.debug1("%s.Removed('%s')" % (self._log_prefix, name))
Expand All @@ -242,7 +243,7 @@ def rename(self, name, sender=None):
self.obj = self.config.rename_icmptype(self.obj, name)
self.Renamed(name)

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_ICMPTYPE, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_ICMPTYPE, signature="s")
@dbus_handle_exceptions
def Renamed(self, name):
log.debug1("%s.Renamed('%s')" % (self._log_prefix, name))
Expand Down
9 changes: 5 additions & 4 deletions src/firewall/server/config_ipset.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
handle_exceptions,
dbus_handle_exceptions,
dbus_service_method,
dbus_service_signal,
dbus_polkit_require_auth,
)
from firewall import errors
Expand Down Expand Up @@ -153,7 +154,7 @@ def Set(self, interface_name, property_name, new_value, sender=None):
"Property '%s' is read-only" % property_name
)

@dbus.service.signal(dbus.PROPERTIES_IFACE, signature="sa{sv}as")
@dbus_service_signal(dbus.PROPERTIES_IFACE, signature="sa{sv}as")
def PropertiesChanged(
self, interface_name, changed_properties, invalidated_properties
):
Expand Down Expand Up @@ -216,7 +217,7 @@ def loadDefaults(self, sender=None):
# self.PropertiesChanged(config.dbus.DBUS_INTERFACE_CONFIG_IPSET,
# { "default": True }, [ ])

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_IPSET, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_IPSET, signature="s")
@dbus_handle_exceptions
def Updated(self, name):
log.debug1("%s.Updated('%s')" % (self._log_prefix, name))
Expand All @@ -232,7 +233,7 @@ def remove(self, sender=None):
self.config.remove_ipset(self.obj)
self.parent.removeIPSet(self.obj)

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_IPSET, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_IPSET, signature="s")
@dbus_handle_exceptions
def Removed(self, name):
log.debug1("%s.Removed('%s')" % (self._log_prefix, name))
Expand All @@ -251,7 +252,7 @@ def rename(self, name, sender=None):
# self.PropertiesChanged(config.dbus.DBUS_INTERFACE_CONFIG_IPSET,
# { "name": name }, [ ])

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_IPSET, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_IPSET, signature="s")
@dbus_handle_exceptions
def Renamed(self, name):
log.debug1("%s.Renamed('%s')" % (self._log_prefix, name))
Expand Down
9 changes: 5 additions & 4 deletions src/firewall/server/config_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
handle_exceptions,
dbus_handle_exceptions,
dbus_service_method,
dbus_service_signal,
dbus_polkit_require_auth,
)

Expand Down Expand Up @@ -130,7 +131,7 @@ def Set(self, interface_name, property_name, new_value, sender=None):
"Property '%s' is read-only" % property_name
)

@dbus.service.signal(dbus.PROPERTIES_IFACE, signature="sa{sv}as")
@dbus_service_signal(dbus.PROPERTIES_IFACE, signature="sa{sv}as")
def PropertiesChanged(
self, interface_name, changed_properties, invalidated_properties
):
Expand Down Expand Up @@ -190,7 +191,7 @@ def loadDefaults(self, sender=None):
self.obj = self.config.load_policy_object_defaults(self.obj)
self.Updated(self.obj.name)

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_POLICY, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_POLICY, signature="s")
@dbus_handle_exceptions
def Updated(self, name):
log.debug1("%s.Updated('%s')" % (self._log_prefix, name))
Expand All @@ -206,7 +207,7 @@ def remove(self, sender=None):
self.config.remove_policy_object(self.obj)
self.parent.removePolicy(self.obj)

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_POLICY, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_POLICY, signature="s")
@dbus_handle_exceptions
def Removed(self, name):
log.debug1("%s.Removed('%s')" % (self._log_prefix, name))
Expand All @@ -223,7 +224,7 @@ def rename(self, name, sender=None):
self.obj = self.config.rename_policy_object(self.obj, name)
self.Renamed(name)

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_POLICY, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_POLICY, signature="s")
@dbus_handle_exceptions
def Renamed(self, name):
log.debug1("%s.Renamed('%s')" % (self._log_prefix, name))
9 changes: 5 additions & 4 deletions src/firewall/server/config_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
handle_exceptions,
dbus_handle_exceptions,
dbus_service_method,
dbus_service_signal,
dbus_polkit_require_auth,
)
from firewall import errors
Expand Down Expand Up @@ -146,7 +147,7 @@ def Set(self, interface_name, property_name, new_value, sender=None):
"Property '%s' is read-only" % property_name
)

@dbus.service.signal(dbus.PROPERTIES_IFACE, signature="sa{sv}as")
@dbus_service_signal(dbus.PROPERTIES_IFACE, signature="sa{sv}as")
def PropertiesChanged(
self, interface_name, changed_properties, invalidated_properties
):
Expand Down Expand Up @@ -229,7 +230,7 @@ def loadDefaults(self, sender=None):
self.obj = self.config.load_service_defaults(self.obj)
self.Updated(self.obj.name)

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_SERVICE, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_SERVICE, signature="s")
@dbus_handle_exceptions
def Updated(self, name):
log.debug1("%s.Updated('%s')" % (self._log_prefix, name))
Expand All @@ -245,7 +246,7 @@ def remove(self, sender=None):
self.config.remove_service(self.obj)
self.parent.removeService(self.obj)

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_SERVICE, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_SERVICE, signature="s")
@dbus_handle_exceptions
def Removed(self, name):
log.debug1("%s.Removed('%s')" % (self._log_prefix, name))
Expand All @@ -262,7 +263,7 @@ def rename(self, name, sender=None):
self.obj = self.config.rename_service(self.obj, name)
self.Renamed(name)

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_SERVICE, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_SERVICE, signature="s")
@dbus_handle_exceptions
def Renamed(self, name):
log.debug1("%s.Renamed('%s')" % (self._log_prefix, name))
Expand Down
9 changes: 5 additions & 4 deletions src/firewall/server/config_zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
handle_exceptions,
dbus_handle_exceptions,
dbus_service_method,
dbus_service_signal,
dbus_polkit_require_auth,
)
from firewall import errors
Expand Down Expand Up @@ -156,7 +157,7 @@ def Set(self, interface_name, property_name, new_value, sender=None):
"Property '%s' is read-only" % property_name
)

@dbus.service.signal(dbus.PROPERTIES_IFACE, signature="sa{sv}as")
@dbus_service_signal(dbus.PROPERTIES_IFACE, signature="sa{sv}as")
def PropertiesChanged(
self, interface_name, changed_properties, invalidated_properties
):
Expand Down Expand Up @@ -288,7 +289,7 @@ def loadDefaults(self, sender=None):
self.obj = self.config.load_zone_defaults(self.obj)
self.Updated(self.obj.name)

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_ZONE, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_ZONE, signature="s")
@dbus_handle_exceptions
def Updated(self, name):
log.debug1("%s.Updated('%s')" % (self._log_prefix, name))
Expand All @@ -304,7 +305,7 @@ def remove(self, sender=None):
self.config.remove_zone(self.obj)
self.parent.removeZone(self.obj)

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_ZONE, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_ZONE, signature="s")
@dbus_handle_exceptions
def Removed(self, name):
log.debug1("%s.Removed('%s')" % (self._log_prefix, name))
Expand All @@ -321,7 +322,7 @@ def rename(self, name, sender=None):
self.obj = self.config.rename_zone(self.obj, name)
self.Renamed(name)

@dbus.service.signal(config.dbus.DBUS_INTERFACE_CONFIG_ZONE, signature="s")
@dbus_service_signal(config.dbus.DBUS_INTERFACE_CONFIG_ZONE, signature="s")
@dbus_handle_exceptions
def Renamed(self, name):
log.debug1("%s.Renamed('%s')" % (self._log_prefix, name))
Expand Down
Loading

0 comments on commit 07612bd

Please sign in to comment.