def on_startup(self): opreferencesd = Controller.object("/org/freesmartphone/Preferences") self.preferences = opreferencesd.GetService("phone") address = self.preferences.GetValue("bt-headset-address") self.headset.setAddress(address) self.bus.add_signal_receiver(self.on_preferences_changed, 'Notify', 'org.freesmartphone.Preferences.Service', 'org.freesmartphone.opreferencesd', '/org/freesmartphone/Preferences/phone')
def update(self): """Enable the rules that need to be""" logger.info("Updating the rules") # First we need to get the 'enabled-rules' value from the 'rules' preference service try: prefs = Controller.object("/org/freesmartphone/Preferences") except KeyError: # preferences service not online logger.warning( "Can't access /org/freesmartphone/Preferences. Rules will be limited." ) # FIXME can we do something (limited) without preferences or not? return False rules_prefs = prefs.GetService("rules") enabled_rules = rules_prefs.GetValue("enabled-rules") enabled_rules = [str(x) for x in enabled_rules] for rule in self.rules: if rule.name in enabled_rules: rule.enable() else: rule.disable() return False