def __trigger(self): prefs = dbuscache.dbusInterfaceForObjectWithInterface( "org.freesmartphone.opreferencesd", "/org/freesmartphone/Preferences", "org.freesmartphone.Preferences") # First, store the current profile # FIXME: we should use profile push and pop instead self.backup_profile = yield tasklet.WaitDBus(prefs.GetProfile) # Then we can set the profile yield tasklet.WaitDBus(prefs.SetProfile, self.profile)
def __init(self): """ We need to make DBus calls and wait for the result, So we use a tasklet to avoid blocking the mainloop. """ logger.debug("user alert action init from mainloop for %s", self.eventname) # We get the 'phone' preferences service and # retreive the tone and volume config values # We are careful to use 'yield' cause the calls could be blocking. try: prefs = dbuscache.dbusInterfaceForObjectWithInterface( "org.freesmartphone.opreferencesd", "/org/freesmartphone/Preferences", "org.freesmartphone.Preferences") phone_prefs = yield tasklet.WaitDBus(prefs.GetService, "phone") phone_prefs = dbuscache.dbusInterfaceForObjectWithInterface( "org.freesmartphone.opreferencesd", phone_prefs, "org.freesmartphone.Preferences.Service") except dbus.DBusException: # preferences daemon probably not present logger.warning( "org.freesmartphone.opreferencesd not present. Can't get alert tones." ) else: # connect to signal for later notifications phone_prefs.connect_to_signal("Notify", self.cbPreferencesServiceNotify) # FIXME does that still work if (some of) the entries are missing? self.tone = yield tasklet.WaitDBus(phone_prefs.GetValue, "%s-tone" % self.eventname) self.volume = yield tasklet.WaitDBus(phone_prefs.GetValue, "%s-volume" % self.eventname) self.loop = yield tasklet.WaitDBus(phone_prefs.GetValue, "%s-loop" % self.eventname) self.length = yield tasklet.WaitDBus(phone_prefs.GetValue, "%s-length" % self.eventname) self.vibrate = yield tasklet.WaitDBus( phone_prefs.GetValue, "%s-vibration" % self.eventname) self.tone = str(self.tone) self.volume = int(self.volume) self.loop = 1024 if bool(self.loop) else 0 self.length = int(self.length) self.vibrate = int(self.vibrate) self.sound_path = os.path.join(installprefix, "share/sounds/", self.tone) self.audio_action = AudioAction( self.sound_path, self.loop, self.length) if self.volume != 0 else None self.vibrator_action = VibratorAction( mode=self.vibratormode) if self.vibrate != 0 else None logger.debug("user alert action for %s: audio=%s, vibrator=%s", self.eventname, self.audio_action, self.vibrator_action)
def _resume(self): """Simply call the client Resume method""" if self.iface is None: self.iface = dbuscache.dbusInterfaceForObjectWithInterface( self.sender, self.path, "org.freesmartphone.Resource") yield tasklet.WaitDBus(self.iface.Resume)
def _disable(self): proxy = self.bus.get_object( "org.freesmartphone.odeviced", "/org/freesmartphone/Device/PowerControl/" + self.name) iface = dbus.Interface(proxy, "org.freesmartphone.Device.PowerControl") yield tasklet.WaitDBus(iface.SetPower, False)