Пример #1
0
SWITCH_DECLARE(void) bridge(CoreSession &session_a, CoreSession &session_b)
{
	switch_input_callback_function_t dtmf_func = NULL;
	switch_input_args_t args;
	switch_channel_t *channel_a = NULL, *channel_b = NULL;
	const char *err = "Channels not ready\n";
	
	if (session_a.allocated && session_a.session && session_b.allocated && session_b.session) {
		channel_a = switch_core_session_get_channel(session_a.session);
		channel_b = switch_core_session_get_channel(session_b.session);

		if (switch_channel_ready(channel_a) && switch_channel_ready(channel_b)) {
			session_a.begin_allow_threads();
			if (!switch_channel_test_flag(channel_a, CF_OUTBOUND) && !switch_channel_media_ready(channel_a)) {
				switch_channel_pre_answer(channel_a);
			}

			if (switch_channel_ready(channel_a) && switch_channel_ready(channel_b)) {
				args = session_a.get_cb_args();  // get the cb_args data structure for session a
				dtmf_func = args.input_callback;   // get the call back function
				err = NULL;
				switch_ivr_multi_threaded_bridge(session_a.session, session_b.session, dtmf_func, args.buf, args.buf);
			}
			session_a.end_allow_threads();
		}
	}

	if (err) {
		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_a.session), SWITCH_LOG_ERROR, "%s", err);
	}


}
Пример #2
0
void CoreNetworkConfig::save()
{
    CoreSession *session = qobject_cast<CoreSession *>(parent());
    if (!session) {
        qWarning() << Q_FUNC_INFO << "No CoreSession set, cannot save network configuration!";
        return;
    }

    Core::setUserSetting(session->user(), objectName(), toVariantMap());
}
Пример #3
0
void CoreHighlightRuleManager::save() const
{
    CoreSession *session = qobject_cast<CoreSession *>(parent());
    if (!session) {
        qWarning() << "CoreHighlightRuleManager: unable to save HighlightRuleList. Parent is not a Coresession!";
        return;
    }

    Core::setUserSetting(session->user(), "HighlightRuleList", initHighlightRuleList());
}
Пример #4
0
void CoreAliasManager::save() const
{
    CoreSession *session = qobject_cast<CoreSession *>(parent());
    if (!session) {
        qWarning() << "CoreAliasManager: unable to save Aliases. Parent is not a Coresession!";
        return;
    }

    Core::setUserSetting(session->user(), "Aliases", initAliases());
}
Пример #5
0
static switch_status_t python_hanguphook(switch_core_session_t *session_hungup)
{
	switch_channel_t *channel = switch_core_session_get_channel(session_hungup);
	CoreSession *coresession = NULL;
	switch_channel_state_t state = switch_channel_get_state(channel);

	if ((coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession"))) {
		if (coresession->hook_state != state) {
			coresession->hook_state = state;
			coresession->check_hangup_hook();
		}
	}

	return SWITCH_STATUS_SUCCESS;
}
Пример #6
0
CoreHighlightRuleManager::CoreHighlightRuleManager(CoreSession *parent)
    : HighlightRuleManager(parent)
{
    CoreSession *session = qobject_cast<CoreSession*>(parent);
    if (!session) {
        qWarning() << "CoreHighlightRuleManager: unable to load HighlightRuleList. Parent is not a Coresession!";
        //loadDefaults();
        return;
    }

    initSetHighlightRuleList(Core::getUserSetting(session->user(), "HighlightRuleList").toMap());

    // we store our settings whenever they change
    connect(this, SIGNAL(updatedRemotely()), SLOT(save()));
}
Пример #7
0
SWITCH_DECLARE_NONSTD(switch_status_t) dtmf_callback(switch_core_session_t *session_cb, 
													 void *input, 
													 switch_input_type_t itype, 
													 void *buf,  
													 unsigned int buflen) {
	
	switch_channel_t *channel = switch_core_session_get_channel(session_cb);
	CoreSession *coresession = NULL;

	coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession");

	if (!coresession) {
		return SWITCH_STATUS_FALSE;
	}

	return coresession->run_dtmf_callback(input, itype);
}
Пример #8
0
CoreAliasManager::CoreAliasManager(CoreSession *parent)
    : AliasManager(parent)
{
    CoreSession *session = qobject_cast<CoreSession *>(parent);
    if (!session) {
        qWarning() << "CoreAliasManager: unable to load Aliases. Parent is not a Coresession!";
        loadDefaults();
        return;
    }

    initSetAliases(Core::getUserSetting(session->user(), "Aliases").toMap());
    if (isEmpty())
        loadDefaults();

    // we store our settings whenever they change
    connect(this, SIGNAL(updatedRemotely()), SLOT(save()));
}
Пример #9
0
SWITCH_DECLARE_NONSTD(switch_status_t) hanguphook(switch_core_session_t *session_hungup) 
{
	if (session_hungup) {
		switch_channel_t *channel = switch_core_session_get_channel(session_hungup);
		CoreSession *coresession = NULL;
		switch_channel_state_t state = switch_channel_get_state(channel);

		if ((coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession"))) {
			if (coresession->hook_state != state) {
				coresession->cause = switch_channel_get_cause(channel);
				coresession->hook_state = state;
				coresession->check_hangup_hook();
			}
		}

		return SWITCH_STATUS_SUCCESS;
	} else {
		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "hangup hook called with null session, something is horribly wrong\n");
		return SWITCH_STATUS_FALSE;
	}
}