Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    def __init(self, device):
        self.device = device

        self.interface = dbuscache.dbusInterfaceForObjectWithInterface(
            "org.freesmartphone.odeviced",
            "/org/freesmartphone/Device/LED/%s" % device,
            "org.freesmartphone.Device.LED")
        self.users = {}
Ejemplo n.º 3
0
 def trigger(self, **kargs):
     iface = dbuscache.dbusInterfaceForObjectWithInterface(
         self.service, self.obj, self.interface)
     logger.info("queued call dbus method %s %s(%s)", self.obj, self.method,
                 self.args)
     method = getattr(iface, self.method)
     self.enqueue(
         method, self.args,
         dict(reply_handler=self.on_reply, error_handler=self.on_error))
     logger.debug("method enqueued...")
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
    def __init__(self, resource):
        self.resource = resource

        if self.usageiface is None:
            self.__class__.usageiface = dbuscache.dbusInterfaceForObjectWithInterface( \
                    "org.freesmartphone.ousaged",
                    "/org/freesmartphone/Usage",
                    "org.freesmartphone.Usage" )
            self.__class__.usageiface.connect_to_signal(
                "ResourceAvailable", self.__class__.onResourceAvailable)
Ejemplo n.º 6
0
 def trigger(self, **kargs):
     iface = dbuscache.dbusInterfaceForObjectWithInterface(
         self.service, self.obj, self.interface)
     logger.info("call dbus method %s %s(%s)", self.obj, self.method,
                 self.args)
     # Get the method
     method = getattr(iface, self.method)
     # We make the call asynchronous, cause we don't want to block the main loop
     method(
         *self.args,
         **dict(reply_handler=self.on_reply, error_handler=self.on_error))
     logger.debug("method called...")
Ejemplo n.º 7
0
    def __init__(self, bus):
        self.interface = self.DBUS_INTERFACE
        self.path = DBUS_PATH_PREFIX
        dbus.service.Object.__init__(self, bus, self.path)
        self.resources = {}
        bus.add_signal_receiver(self._nameOwnerChangedHandler,
                                "NameOwnerChanged", dbus.BUS_DAEMON_IFACE,
                                dbus.BUS_DAEMON_NAME, dbus.BUS_DAEMON_PATH)
        logger.info("%s initialized. Serving %s at %s",
                    self.__class__.__name__, self.interface, self.path)

        self.idlenotifier = dbuscache.dbusInterfaceForObjectWithInterface(
            "org.freesmartphone.odeviced",
            "/org/freesmartphone/Device/IdleNotifier/0",
            "org.freesmartphone.Device.IdleNotifier")
Ejemplo n.º 8
0
 def __init__(self, bus):
     self.zonetab = []
     self.zone = None
     self.mccmnc = None
     self.mccmnc_ts = 0.0
     self.isocode = None
     self.offset = None
     self.offset_ts = 0.0
     self.bus = bus
     self.bus.add_signal_receiver(self._handleNetworkStatusChanged,
                                  "Status",
                                  "org.freesmartphone.GSM.Network", None,
                                  None)
     self.bus.add_signal_receiver(self._handleTimeZoneReport,
                                  "TimeZoneReport",
                                  "org.freesmartphone.GSM.Network", None,
                                  None)
     self.gsmdata = dbuscache.dbusInterfaceForObjectWithInterface(
         "org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Server",
         "org.freesmartphone.GSM.Data")
Ejemplo n.º 9
0
 def _getInterfaceForObject(self, object, interface):
     return dbuscache.dbusInterfaceForObjectWithInterface(
         "org.freesmartphone.frameworkd", object, interface)
Ejemplo n.º 10
0
 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)