Ejemplo n.º 1
0
    def __init__(self, ari_client, channel, handset_endpoint, asterisk_app_name):
        """
        :param ari_client: the ari client instance
        :param channel: the active channel with the handset_endpoint
        """
        super(IncomingCall, self).__init__(ari_client, channel, asterisk_app_name)
        self.handset_endpoint = handset_endpoint
        self.call_state = CallState.instance()

        self.state_machine = None
        self.setup_state_machine()
Ejemplo n.º 2
0
Archivo: ui.py Proyecto: synox/telewall
def on_button_press():
    """ Callback function the call on button press. try to block a caller.  """

    with AsteriskPersistence(Config.ASTERISK_DATABASE_PATH) as asterisk:
        asterisk_anruf = asterisk.get_last_cdr_callerid()
        LOG.info('last caller in asterisk : %s', asterisk_anruf)

    call_state = CallState.instance()
    if call_state.is_ringing or call_state.is_connected:
        _block_caller(call_state.caller)
        show_callerid_blocked(call_state.caller)
        call_state.refuse_if_connected()

    elif asterisk_anruf:
        caller_phone_number = TelephoneNumber(asterisk_anruf.src)
        _block_caller(caller_phone_number)
        show_callerid_blocked(caller_phone_number)
        call_state.refuse_if_connected()

    else:
        LOG.info('nothing to block')
        main_led.queue(NoAction())
        display.show(8, 'Keine Anrufe', 'innert 15min.', centered=True)