Exemple #1
0
bool BoardFXO::KhompPvtFXO::onDisconnect(K3L_EVENT *e)
{
    DBG(FUNC, PVT_FMT(_target, "(FXO) c"));

    bool ret = true;

    try
    {
        ScopedPvtLock lock(this);

        command(KHOMP_LOG, CM_DISCONNECT);

        ret = KhompPvt::onDisconnect(e);

    }
    catch (ScopedLockFailed & err)
    {
        LOG(ERROR, PVT_FMT(target(), "(FXO) r (unable to lock %s!)") % err._msg.c_str() );
        return false;
    }

    DBG(FUNC, PVT_FMT(_target, "(FXO) r"));

    return ret;
}
bool BoardE1::KhompPvtR2::sendPreAudio(int rb_value)
{
    DBG(FUNC,PVT_FMT(_target, "must send R2 preaudio ?"));   
    if(!KhompPvtE1::sendPreAudio(rb_value))
        return false;


    DBG(FUNC,PVT_FMT(_target, "doing the R2 pre_connect wait..."));   

    /* wait some ms, just to be sure the command has been sent. */
    usleep(Opt::_r2_preconnect_wait * 1000);

    if (call()->_flags.check(Kflags::HAS_PRE_AUDIO))
    {
        DBG(FUNC, PVT_FMT(target(), "(p=%p) already pre_connect") % this);
        return true;
    }
    else
    {
        bool result = command(KHOMP_LOG, CM_PRE_CONNECT);

        if (result)
            call()->_flags.set(Kflags::HAS_PRE_AUDIO);

        return result;
    }
}
Exemple #3
0
bool BoardFXO::KhompPvtFXO::onDtmfDetected(K3L_EVENT *e)
{
    DBG(FUNC, PVT_FMT(_target, "(FXO) c"));

    bool ret = true;

    try
    {
        ScopedPvtLock lock(this);

        if (callFXO()->_flags.check(Kflags::WAIT_SEND_DTMF) ||
                callFXO()->_flags.check(Kflags::CALL_WAIT_SEIZE))
        {
            /* waiting digit or seize means DEADLOCK if we try to 
             *  queue something below. */
            DBG(FUNC, PVT_FMT(_target, "not queueing dtmf, waiting stuff!"));
            return true;
        }

        ret = KhompPvt::onDtmfDetected(e);
    }
    catch (ScopedLockFailed & err)
    {
        LOG(ERROR, PVT_FMT(_target, "(FXO) r (unable to lock %s!)") % err._msg.c_str() );
        return false;
    }

    DBG(FUNC, PVT_FMT(_target, "(FXO) r"));

    return ret;
}
Exemple #4
0
bool BoardFXO::KhompPvtFXO::onChannelRelease(K3L_EVENT *e)
{
    DBG(FUNC, PVT_FMT(_target, "(FXO) c"));

    bool ret = true;

    try
    {
        ScopedPvtLock lock(this);

        if (call()->_flags.check(Kflags::FAX_SENDING))
        {
            DBG(FUNC, PVT_FMT(_target, "stopping fax tx"));
            _fax->stopFaxTX();
        }
        else if (call()->_flags.check(Kflags::FAX_RECEIVING))
        {
            DBG(FUNC, PVT_FMT(_target, "stopping fax rx"));
            _fax->stopFaxRX();
        }

        command(KHOMP_LOG, CM_ENABLE_CALL_ANSWER_INFO);
   
        ret = KhompPvt::onChannelRelease(e);
    }
    catch(ScopedLockFailed & err)
    {
        LOG(ERROR, PVT_FMT(target(), "(FXO) r (unable to lock %s!)") % err._msg.c_str() );
        return false;
    }
    
    DBG(FUNC, PVT_FMT(_target, "(FXO) r"));   
    return ret;
}
Exemple #5
0
bool BoardGSM::KhompPvtGSM::doChannelAnswer(CommandRequest &cmd)
{
    DBG(FUNC, PVT_FMT(_target, "(GSM) c"));

    bool ret = true;

    try
    {
        ScopedPvtLock lock(this);

        command(KHOMP_LOG, CM_CONNECT);

        ret = KhompPvt::doChannelAnswer(cmd);

    }
    catch (ScopedLockFailed & err)
    {
        LOG(ERROR, PVT_FMT(_target,"(GSM) r (unable to lock %s!)") % err._msg.c_str() );
        return false;
    }

    DBG(FUNC, PVT_FMT(_target, "(GSM) r"));

    return ret;
}
Exemple #6
0
bool BoardGSM::KhompPvtGSM::doChannelHangup(CommandRequest &cmd)
{
    DBG(FUNC, PVT_FMT(_target, "(GSM) c"));

    bool ret = true;

    try
    {
        ScopedPvtLock lock(this);

        int owner_nr = 0;

        command(KHOMP_LOG, CM_DISCONNECT,
                STG(FMT("gsm_call_ref=%d") % (int)owner_nr).c_str());


        //ret = KhompPvt::doChannelHangup(cmd);

    }
    catch (ScopedLockFailed & err)
    {
        LOG(ERROR, PVT_FMT(_target,"(GSM) r (unable to lock %s!)") % err._msg.c_str() );
        return false;
    }

    DBG(FUNC, PVT_FMT(_target, "(GSM) r"));

    return ret;
}
Exemple #7
0
bool BoardGSM::KhompPvtGSM::indicateBusyUnlocked(int cause, bool sent_signaling)
{
    DBG(FUNC, PVT_FMT(_target, "(GSM) c"));

    if(!KhompPvt::indicateBusyUnlocked(cause, sent_signaling))
    {
        DBG(FUNC, PVT_FMT(_target, "(GSM) r (false)"));
        return false;
    }

    if(call()->_flags.check(Kflags::IS_INCOMING))
    {
        if(!call()->_flags.check(Kflags::CONNECTED) && !sent_signaling)
        {
            /* we are talking about branches, not trunks */
            command(KHOMP_LOG, CM_DISCONNECT);
        }
        else
        {
            /* already connected or sent signaling... */
            mixer(KHOMP_LOG, 1, kmsGenerator, kmtBusy);
        }
    }
    else if(call()->_flags.check(Kflags::IS_OUTGOING))
    {
        /* already connected or sent signaling... */
        mixer(KHOMP_LOG, 1, kmsGenerator, kmtBusy);
    }

    DBG(FUNC,PVT_FMT(_target, "(GSM) r"));

    return true;
}
bool BoardFXO::KhompPvtFXO::indicateBusyUnlocked(int cause, bool sent_signaling)
{
    DBG(FUNC, PVT_FMT(_target, "(FXO) c"));

    if(!KhompPvt::indicateBusyUnlocked(cause, sent_signaling))
    {
        DBG(FUNC, PVT_FMT(_target, "(FXO) r (false)"));
        return false;
    }

    if(call()->_flags.check(Kflags::IS_INCOMING))
    {
        /* already connected or sent signaling... */
        mixer(KHOMP_LOG, 1, kmsGenerator, kmtBusy);
        
        if(!call()->_flags.check(Kflags::CONNECTED) && !sent_signaling)
        {
            /* we are talking about branches, not trunks */ 
            command(KHOMP_LOG, CM_CONNECT);
            callFXO()->_busy_disconnect = Board::board(_target.device)->_timers.add(Opt::_options._fxo_busy_disconnection(), &BoardFXO::KhompPvtFXO::busyDisconnect, this);
        }
    }
    else if(call()->_flags.check(Kflags::IS_OUTGOING))
    {
        /* already connected or sent signaling... */
        mixer(KHOMP_LOG, 1, kmsGenerator, kmtBusy);
    }

    DBG(FUNC,PVT_FMT(_target, "(FXO) r"));
    return true; 
}
Exemple #9
0
bool BoardFXO::KhompPvtFXO::onNewCall(K3L_EVENT *e)
{
    DBG(FUNC,PVT_FMT(_target,"(FXO) c"));
   
    bool ret = true;

    try
    {
        ScopedPvtLock lock(this);

        /* we always have audio */
        call()->_flags.set(Kflags::HAS_PRE_AUDIO);

        ret = KhompPvt::onNewCall(e);

        if(!ret)
            return false;

        startListen();
        startStream();

    }
    catch(ScopedLockFailed & err)
    {
        LOG(ERROR, PVT_FMT(target(), "(FXO) r (unable to lock %s!)") % err._msg.c_str() );
        return false;
    }

    DBG(FUNC, PVT_FMT(_target, "(FXO) r"));

    return ret;
}
Exemple #10
0
bool BoardGSM::KhompPvtGSM::onCallAnswerInfo(K3L_EVENT *e)
{
    DBG(FUNC, PVT_FMT(_target, "(GSM) c"));
    try
    {
        ScopedPvtLock lock(this);

        int info_code = -1;

        switch (e->AddInfo)
        {
        case kcsiCellPhoneMessageBox:
            info_code = CI_MESSAGE_BOX;
            break;
        case kcsiHumanAnswer:
            info_code = CI_HUMAN_ANSWER;
            break;
        case kcsiAnsweringMachine:
            info_code = CI_ANSWERING_MACHINE;
            break;
        case kcsiCarrierMessage:
            info_code = CI_CARRIER_MESSAGE;
            break;
        case kcsiUnknown:
            info_code = CI_UNKNOWN;
            break;
        default:
            DBG(FUNC, PVT_FMT(_target, "got an unknown call answer info '%d', ignoring...") % e->AddInfo);
            break;
        }

        if (info_code != -1)
        {
            if (callGSM()->_call_info_report)
            {
                //TODO: HOW WE TREAT THAT
                // make the channel export this
                setAnswerInfo(info_code);
            }

            if (callGSM()->_call_info_drop & info_code)
            {
                command(KHOMP_LOG, CM_SEND_TO_MODEM, "ATH");
            }
        }
    }
    catch (ScopedLockFailed & err)
    {
        LOG(ERROR, PVT_FMT(_target,"(GSM) r (unable to lock %s!)") % err._msg.c_str() );
        return false;
    }

    DBG(FUNC, PVT_FMT(_target, "(GSM) r"));
    return true;
}
Exemple #11
0
bool BoardFXO::KhompPvtFXO::setupConnection()
{
    if(!call()->_flags.check(Kflags::IS_INCOMING) && !call()->_flags.check(Kflags::IS_OUTGOING))
    {
        DBG(FUNC,PVT_FMT(_target, "Channel already disconnected"));
        return false;
    }

    callFXO()->_flags.clear(Kflags::CALL_WAIT_SEIZE);
    callFXO()->_flags.clear(Kflags::WAIT_SEND_DTMF);

    /* if received some disconnect from 'drop collect call'
       feature of some pbx, then leave the call rock and rolling */
    //Board::board(_target.device)->_timers.del(callFXO()->_idx_disconnect);

    bool fax_detected = callFXO()->_flags.check(Kflags::FAX_DETECTED) || (callFXO()->_var_fax_adjust == T_TRUE);

    bool res_out_of_band_dtmf = (call()->_var_dtmf_state == T_UNKNOWN || fax_detected ?
        Opt::_options._suppression_delay() && Opt::_options._out_of_band_dtmfs() && !fax_detected : (call()->_var_dtmf_state == T_TRUE));

    bool res_echo_cancellator = (call()->_var_echo_state == T_UNKNOWN || fax_detected ?
        Opt::_options._echo_canceller() && !fax_detected : (call()->_var_echo_state == T_TRUE));

    bool res_auto_gain_cntrol = (call()->_var_gain_state == T_UNKNOWN || fax_detected ?
        Opt::_options._auto_gain_control() && !fax_detected : (call()->_var_gain_state == T_TRUE));

    if (!call()->_flags.check(Kflags::REALLY_CONNECTED))
    {
        obtainRX(res_out_of_band_dtmf);

        /* esvazia buffers de leitura/escrita */
        cleanupBuffers();

        if (!call()->_flags.check(Kflags::KEEP_DTMF_SUPPRESSION))
            dtmfSuppression(res_out_of_band_dtmf);

        if (!call()->_flags.check(Kflags::KEEP_ECHO_CANCELLATION))
            echoCancellation(res_echo_cancellator);

        if (!call()->_flags.check(Kflags::KEEP_AUTO_GAIN_CONTROL))
            autoGainControl(res_auto_gain_cntrol);

        startListen(false);

        startStream();

        DBG(FUNC, PVT_FMT(_target, "(FXO) Audio callbacks initialized successfully"));
    }

    return KhompPvt::setupConnection();
}
void BoardFXO::KhompPvtFXO::busyDisconnect(Board::KhompPvt * pvt)
{
    DBG(FUNC, PVT_FMT(pvt->target(), "Disconnecting FXO"));

    try 
    {   
        ScopedPvtLock lock(pvt);
        pvt->command(KHOMP_LOG, CM_DISCONNECT);
    }   
    catch (...)
    {
        LOG(ERROR, PVT_FMT(pvt->target(), "unable to lock the pvt !"));
    }  
}
Exemple #13
0
bool BoardGSM::KhompPvtGSM::validContexts(
    MatchExtension::ContextListType & contexts, std::string extra_context)
{
    DBG(FUNC,PVT_FMT(_target,"(GSM) c"));

    if(!_group_context.empty())
    {
        contexts.push_back(_group_context);
    }

    if (!extra_context.empty())
    {
        if (!_group_context.empty())
        {
            std::string pvt_context(_group_context);
            pvt_context += "-";
            pvt_context += extra_context;
            contexts.push_back(pvt_context);
        }

        if (!Opt::_options._context_gsm_call().empty())
        {
            std::string context(Opt::_options._context_gsm_call());
            context += "-";
            context += extra_context;
            contexts.push_back(_group_context);
        }

        if (!Opt::_options._context2_gsm_call().empty())
        {
            std::string context(Opt::_options._context2_gsm_call());
            context += "-";
            context += extra_context;
            contexts.push_back(_group_context);
        }
    }

    contexts.push_back(Opt::_options._context_gsm_call());
    contexts.push_back(Opt::_options._context2_gsm_call());

    for (MatchExtension::ContextListType::iterator i = contexts.begin(); i != contexts.end(); i++)
        replaceTemplate((*i), "CC", _target.object);

    bool ret = Board::KhompPvt::validContexts(contexts,extra_context);

    DBG(FUNC,PVT_FMT(_target,"(GSM) r"));

    return ret;
}
Exemple #14
0
bool BoardGSM::KhompPvtGSM::isOK()
{
    try
    {
        ScopedPvtLock lock(this);

        K3L_CHANNEL_STATUS status;

        if (k3lGetDeviceStatus (_target.device, _target.object + ksoChannel, &status, sizeof (status)) != ksSuccess)
            return false;

        switch (status.AddInfo)
        {
        case kgsmModemError:
        case kgsmSIMCardError:
        case kgsmNetworkError:
        case kgsmNotReady:
            return false;
        default:
            return true;
        }

    }
    catch (ScopedLockFailed & err)
    {
        LOG(ERROR, PVT_FMT(target(), "unable to lock %s!") % err._msg.c_str() );
    }

    return false;
}
bool BoardE1::KhompPvtISDN::onCallFail(K3L_EVENT *e)
{
    try
    {
        ScopedPvtLock lock(this);

        if(e->AddInfo > 0)
        {
            callISDN()->_isdn_cause = e->AddInfo;
        }

        setHangupCause(causeFromCallFail(e->AddInfo),true);

        lock.unlock();

        KhompPvtE1::onCallFail(e);

    }
    catch (ScopedLockFailed & err)
    {
        K::Logger::Logg(C_ERROR, PVT_FMT(target(), "unable to lock %s!") % err._msg.c_str() );
        return ksFail;
    }

    return ksSuccess;
}
int BoardE1::KhompPvtR2::makeCall(std::string params)
{
    DBG(FUNC,PVT_FMT(_target, "(R2) c"));   

    if (callR2()->_r2_category != -1)
        params += STG(FMT("r2_categ_a=\"%ld\"")
                % callR2()->_r2_category);

    int ret = KhompPvtE1::makeCall(params);

    call()->_cleanup_upon_hangup = (ret == ksInvalidParams);
    
    DBG(FUNC,PVT_FMT(_target, "(R2) r"));   

    return ret;
}
RingbackDefs::RingbackStType BoardE1::KhompPvtR2::sendRingBackStatus(int rb_value)
{
    DBG(FUNC,PVT_FMT(_target, "(p=%p) this is the r2 ringback procedure") % this);   

    std::string cause = (rb_value == -1 ? "" : STG(FMT("r2_cond_b=\"%d\"") % rb_value));
    return (command(KHOMP_LOG, CM_RINGBACK, cause.c_str()) ?
            RingbackDefs::RBST_SUCCESS : RingbackDefs::RBST_FAILURE);
}
RingbackDefs::RingbackStType BoardE1::KhompPvtISDN::sendRingBackStatus(int rb_value)
{
    DBG(FUNC, PVT_FMT(target(), "this is the rdsi ringback procedure"));


    std::string cause = (rb_value == -1 ? "" : STG(FMT("isdn_cause=\"%d\"") % rb_value));
    return (command(KHOMP_LOG, CM_RINGBACK, cause.c_str()) ?
            RingbackDefs::RBST_SUCCESS : RingbackDefs::RBST_FAILURE);
}
Exemple #19
0
bool BoardGSM::KhompPvtGSM::setupConnection()
{
    if(!call()->_flags.check(Kflags::IS_INCOMING) && !call()->_flags.check(Kflags::IS_OUTGOING))
    {
        DBG(FUNC,PVT_FMT(_target, "Channel already disconnected"));
        return false;
    }

    bool res_out_of_band_dtmf = (call()->_var_dtmf_state == T_UNKNOWN ?
                                 Opt::_options._suppression_delay() && Opt::_options._out_of_band_dtmfs() : (call()->_var_dtmf_state == T_TRUE));

    bool res_echo_cancellator = (call()->_var_echo_state == T_UNKNOWN ?
                                 Opt::_options._echo_canceller() : (call()->_var_echo_state == T_TRUE));


    bool res_auto_gain_cntrol = (call()->_var_gain_state == T_UNKNOWN ?
                                 Opt::_options._auto_gain_control() : (call()->_var_gain_state == T_TRUE));


    if (!call()->_flags.check(Kflags::REALLY_CONNECTED))
    {
        obtainRX(res_out_of_band_dtmf);

        /* esvazia buffers de leitura/escrita */
        cleanupBuffers();

        if (!call()->_flags.check(Kflags::KEEP_DTMF_SUPPRESSION))
            dtmfSuppression(res_out_of_band_dtmf);

        if (!call()->_flags.check(Kflags::KEEP_ECHO_CANCELLATION))
            echoCancellation(res_echo_cancellator);

        if (!call()->_flags.check(Kflags::KEEP_AUTO_GAIN_CONTROL))
            autoGainControl(res_auto_gain_cntrol);

        startListen(false);

        startStream();

        DBG(FUNC, PVT_FMT(_target, "(GSM) Audio callbacks initialized successfully"));
    }

    return Board::KhompPvt::setupConnection();
}
int BoardE1::KhompPvtE1::doChannelAnswer(CommandRequest &msg)
{
    DBG(FUNC, PVT_FMT(_target, "(E1) c"));
    /*
    try
    {
        ScopedPvtLock lock(this);
    }
    catch (ScopedLockFailed & err)
    {
        K::Logger::Logg(C_ERROR,PVT_FMT(_target,"unable to lock %s!") % err._msg.c_str() );
        return ksFail;
    }
    */
        
    KhompPvt::doChannelAnswer(msg); 

    DBG(FUNC, PVT_FMT(_target, "(E1) r"));
}
int BoardE1::KhompPvtR2::doChannelAnswer(CommandRequest &cmd)
{
    try
    {
        ScopedPvtLock lock(this);

        // is this a collect call?
        bool has_recv_collect_call = _call->_collect_call;

        // do we have to drop collect calls?
        bool has_drop_collect_call = Opt::_drop_collect_call
            || _call->_flags.check(Kflags::DROP_COLLECT)
            || _call->_flags.check(Kflags::FILTER_COLLECT);

        // do we have to drop THIS call?
        bool do_drop_call = has_drop_collect_call && has_recv_collect_call;

        // do we have to send ringback? yes we need !!!
        if(call()->_flags.check(Kflags::NEEDS_RINGBACK_CMD))
        {       
            call()->_flags.clear(Kflags::NEEDS_RINGBACK_CMD);
            std::string cause = ( do_drop_call ? STG(FMT("r2_cond_b=\"%d\"") % kgbBusy) : "" );
            command(KHOMP_LOG,CM_RINGBACK,cause.c_str());

            usleep(75000);
        }

        if(has_drop_collect_call) 
        {
            DBG(FUNC, PVT_FMT(target(), "dropping collect call"));
            command(KHOMP_LOG, CM_DROP_COLLECT_CALL);
        }

    }
    catch (ScopedLockFailed & err)
    {
        K::Logger::Logg(C_ERROR,PVT_FMT(_target,"unable to lock %s!") % err._msg.c_str() );
        return ksFail;
    }

    KhompPvtE1::doChannelAnswer(cmd);
}
Exemple #22
0
bool BoardFXO::KhompPvtFXO::onSeizeSuccess(K3L_EVENT *e)
{
    DBG(FUNC, PVT_FMT(_target, "(FXO) c"));

    try
    {
        ScopedPvtLock lock(this);

        callFXO()->_flags.clear(Kflags::CALL_WAIT_SEIZE);

    }
    catch (ScopedLockFailed & err)
    {
        LOG(ERROR, PVT_FMT(_target, "(FXO) r (unable to lock %s!)") % err._msg.c_str() );
        return false;
    }

    DBG(FUNC, PVT_FMT(_target, "(FXO) r"));

    return true;
}
Exemple #23
0
int BoardGSM::KhompPvtGSM::makeCall(std::string params)
{
    DBG(FUNC,PVT_FMT(_target, "(GSM) c"));

    if(callGSM()->_call_info_drop == 0 && !callGSM()->_call_info_report)
    {
        command(KHOMP_LOG, CM_DISABLE_CALL_ANSWER_INFO);
    }

    int ret = KhompPvt::makeCall(params);

    if(ret != ksSuccess)
    {
        LOG(ERROR, PVT_FMT(target(), "Fail on make call"));
    }

    call()->_cleanup_upon_hangup = (ret == ksInvalidParams || ret == ksInvalidState);

    DBG(FUNC,PVT_FMT(_target, "(GSM) r"));
    return ret;
}
Exemple #24
0
void BoardGSM::KhompPvtGSM::setAnswerInfo(int answer_info)
{
    const char * value = answerInfoToString(answer_info);

    if (value == NULL)
    {
        DBG(FUNC, PVT_FMT(_target,"signaled unknown call answer info '%d', using 'Unknown'...") % answer_info);
        value = "Unknown";
    }

    DBG(FUNC,PVT_FMT(_target,"KCallAnswerInfo: %s") % value);

    try
    {
        setFSChannelVar("KCallAnswerInfo",value);
    }
    catch(Board::KhompPvt::InvalidSwitchChannel & err)
    {
        LOG(ERROR,PVT_FMT(_target,"Cannot obtain the channel variable: %s") % err._msg.c_str());
    }
}
int BoardE1::KhompPvtISDN::doChannelAnswer(CommandRequest &cmd)
{
    try
    {
        ScopedPvtLock lock(this);

        // is this a collect call?
        bool has_recv_collect_call = _call->_collect_call;

        // do we have to drop collect calls?
        bool has_drop_collect_call = Opt::_drop_collect_call
            || _call->_flags.check(Kflags::DROP_COLLECT)
            || _call->_flags.check(Kflags::FILTER_COLLECT);

        // do we have to drop THIS call?
        bool do_drop_call = has_drop_collect_call && has_recv_collect_call;

        if(has_drop_collect_call) 
        {
            usleep(75000);

            DBG(FUNC, PVT_FMT(target(), "disconnecting collect call"));
            //TODO: Define what is SCE
            //        command(KHOMP_LOG,CM_DISCONNECT,SCE_HIDE);
            command(KHOMP_LOG,CM_DISCONNECT);

            // thou shalt not talk anymore!
            stop_listen();
            stop_stream();
            //TODO: Checar se retorna aqui
        }
    }
    catch (ScopedLockFailed & err)
    {
        K::Logger::Logg(C_ERROR, PVT_FMT(_target, "unable to lock %s!") % err._msg.c_str() );
        return ksFail;
    }

    KhompPvtE1::doChannelAnswer(cmd);
}
bool BoardE1::KhompPvtISDN::onIsdnProgressIndicator(K3L_EVENT *e)
{
    //TODO: Do we need return something ?
    try
    {
        ScopedPvtLock lock(this);

        switch (e->AddInfo)
        {
            case kq931pTonesMaybeAvailable:
            case kq931pTonesAvailable:
                if (!call()->_is_progress_sent)
                {
                    call()->_is_progress_sent = true;
                    //Sinaliza para o Freeswitch PROGRESS
                    switch_channel_t * channel = switch_core_session_get_channel(session());
                    if(channel)
                    {
                        DBG(FUNC, PVT_FMT(_target,"Pre answer"));

                        //pvt->signal_state(SWITCH_CONTROL_PROGRESS);
                        //switch_channel_pre_answer(channel);
                        switch_channel_mark_pre_answered(channel);
                    }
                    
                }
                break;
            case kq931pDestinationIsNonIsdn:
            case kq931pOriginationIsNonIsdn:
            case kq931pCallReturnedToIsdn:
            default:
                break;
        }

    }
    catch (ScopedLockFailed & err)
    {
        K::Logger::Logg(C_ERROR, PVT_FMT(target(), "unable to lock %s!") % err._msg.c_str() );
    }
}
void BoardE1::KhompPvtE1::onChannelRelease(K3L_EVENT *e)
{
    DBG(FUNC, PVT_FMT(_target, "(E1) c"));

    try
    {
        ScopedPvtLock lock(this);

        call()->_flags.clear(Kflags::HAS_PRE_AUDIO);

        command(KHOMP_LOG, CM_ENABLE_CALL_ANSWER_INFO);
    }
    catch(ScopedLockFailed & err)
    {
        K::Logger::Logg(C_ERROR, PVT_FMT(target(), "(E1) r (unable to lock %s!)") % err._msg.c_str() );
        return;
    }
    
    KhompPvt::onChannelRelease(e);
    
    DBG(FUNC, PVT_FMT(_target, "(E1) r"));   
}
bool BoardE1::KhompPvtISDN::onNewCall(K3L_EVENT *e)
{
    DBG(FUNC,PVT_FMT(_target,"(ISDN) c"));   

    bool isdn_reverse_charge = false;
    
    try
    {
        std::string isdn_reverse_charge_str =
            Globals::k3lapi.get_param(e, "isdn_reverse_charge");

        isdn_reverse_charge = Strings::toboolean(isdn_reverse_charge_str);

        if(isdn_reverse_charge)
        {
            ScopedPvtLock lock(this);
            call()->_collect_call = true;
        }
    }
    catch(K3LAPI::get_param_failed & err)
    {
        K::Logger::Logg(C_ERROR, PVT_FMT(_target,"unable to get param '%s': %s") % err.name.c_str() % Verbose::status(err.rc).c_str());
    }
    catch (Strings::invalid_value & err)
    {
        K::Logger::Logg(C_ERROR, PVT_FMT(_target, "unable to get param '%s'") % err.value().c_str());
    }
    catch(ScopedLockFailed & err)
    {
        K::Logger::Logg(C_ERROR, PVT_FMT(target(), "(ISDN) r (unable to lock %s!)") % err._msg.c_str() );
        return ksFail;
    }

    bool ret = KhompPvtE1::onNewCall(e); 

    DBG(FUNC, PVT_FMT(_target, "(ISDN) r"));   

    return ret;
}
void BoardE1::KhompPvtR2::reportFailToReceive(int fail_code)
{
    KhompPvt::reportFailToReceive(fail_code);

    if (Opt::_r2_strict_behaviour && fail_code != -1)
    {
        DBG(FUNC,PVT_FMT(_target,"sending a 'unknown number' message/audio")); 

        if(sendRingBackStatus(fail_code) == RingbackDefs::RBST_UNSUPPORTED)
        {
            sendPreAudio(RingbackDefs::RB_SEND_DEFAULT);
            cadenceStart(Kflags::PLAY_FASTBUSY);
        }
    }
    else
    {
        DBG(FUNC, PVT_FMT(_target, "sending fast busy audio directly"));

        sendPreAudio(RingbackDefs::RB_SEND_DEFAULT);
        cadenceStart(Kflags::PLAY_FASTBUSY);
    }
}
int BoardE1::KhompPvtISDN::makeCall(std::string params)
{
    DBG(FUNC,PVT_FMT(_target, "(ISDN) c"));   

    CallISDN * call = callISDN();

    if(call->_uui_descriptor != -1)
    {
        DBG(FUNC,PVT_FMT(_target, "got userinfo"));   

        /* grab this information first, avoiding latter side-effects */
        const char * info_data = call->_uui_information.c_str();
        size_t       info_size = std::min(call->_uui_information.size(), (size_t)KMAX_USER_USER_LEN);

        KUserInformation info;

        info.ProtocolDescriptor = call->_uui_descriptor;
        info.UserInfoLength = info_size;

        memcpy((void *) info.UserInfo, (const void *) info_data, info_size);

        if (!command(KHOMP_LOG, CM_USER_INFORMATION, (const char *)&info))
        {
            DBG(FUNC,PVT_FMT(_target, "UUI could not be sent before dialing!"));   
        }

        call->_uui_descriptor = -1;
        call->_uui_information.clear();
    }

    int ret = KhompPvtE1::makeCall(params);

    call->_cleanup_upon_hangup = (ret == ksInvalidParams || ret == ksBusy);
    
    DBG(FUNC,PVT_FMT(_target, "(ISDN) r"));   

    return ret;
}