Ejemplo n.º 1
0
static void *attempt_thread(void *data)
{
	struct outgoing *o = (struct outgoing *) data;
	int res, reason;
	if (!cw_strlen_zero(o->app)) {
		if (option_verbose > 2)
			cw_verbose(VERBOSE_PREFIX_3 "Attempting call on %s/%s for application %s(%s) (Retry %d)\n", o->tech, o->dest, o->app, o->data, o->retries);
		res = cw_pbx_outgoing_app(o->tech, CW_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->app, o->data, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, NULL);
	} else {
		if (option_verbose > 2)
			cw_verbose(VERBOSE_PREFIX_3 "Attempting call on %s/%s for %s@%s:%d (Retry %d)\n", o->tech, o->dest, o->exten, o->context,o->priority, o->retries);
		res = cw_pbx_outgoing_exten(o->tech, CW_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, NULL);
	}
	if (res) {
		cw_log(LOG_NOTICE, "Call failed to go through, reason %d\n", reason);
		if (o->retries >= o->maxretries + 1) {
			/* Max retries exceeded */
			cw_log(LOG_EVENT, "Queued call to %s/%s expired without completion after %d attempt%s\n", o->tech, o->dest, o->retries - 1, ((o->retries - 1) != 1) ? "s" : "");
			unlink(o->fn);
		} else {
			/* Notate that the call is still active */
			safe_append(o, time(NULL), "EndRetry");
		}
	} else {
		cw_log(LOG_NOTICE, "Call completed to %s/%s\n", o->tech, o->dest);
		cw_log(LOG_EVENT, "Queued call to %s/%s completed\n", o->tech, o->dest);
		unlink(o->fn);
	}
	free_outgoing(o);
	return NULL;
}
Ejemplo n.º 2
0
static void *originate(void *arg) {
	struct fast_originate_helper *in = arg;
	int reason=0;
	int res;
	struct cw_channel *chan = NULL;

	res = cw_pbx_outgoing_exten(in->tech, CW_FORMAT_SLINEAR, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1, !cw_strlen_zero(in->cid_num) ? in->cid_num : NULL, !cw_strlen_zero(in->cid_name) ? in->cid_name : NULL, NULL, &chan);
	manager_event(EVENT_FLAG_CALL, "Originate", 
			"ChannelRequested: %s/%s\r\n"
			"Context: %s\r\n"
			"Extension: %s\r\n"
			"Priority: %d\r\n"
			"Result: %d\r\n"
			"Reason: %d\r\n"
			"Reason-txt: %s\r\n",
			in->tech,
			in->data,
			in->context, 
			in->exten, 
			in->priority, 
			res,
			reason,
			cw_control2str(reason)
	);

	/* Locked by cw_pbx_outgoing_exten or cw_pbx_outgoing_app */
	if (chan) {
		cw_mutex_unlock(&chan->lock);
	}
	free(in);
	return NULL;
}
Ejemplo n.º 3
0
static void *fast_originate(void *data)
{
    int res = 0,
	reason;
    struct fast_originate_helper *in = data;
    struct cw_channel *chan = NULL;

    cw_indicate(in->frommember->chan, CW_CONTROL_RINGING);


    if (1) {
		res = cw_pbx_outgoing_app(
			in->tech, CW_FORMAT_SLINEAR, 
			in->data, in->timeout, 
			in->app, in->appdata, 
			&reason, 1, 
			!cw_strlen_zero(in->cid_num) ? in->cid_num : NULL, 
			!cw_strlen_zero(in->cid_name) ? in->cid_name : NULL,
			in->vars, &chan );
    } else {
		res = cw_pbx_outgoing_exten(
			in->tech, CW_FORMAT_SLINEAR, 
			in->data, in->timeout, 
			in->context, in->exten, in->priority, 
			&reason, 1, 
			!cw_strlen_zero(in->cid_num) ? in->cid_num : NULL, 
			!cw_strlen_zero(in->cid_name) ? in->cid_name : NULL,
			in->vars, NULL );
    }   

    cw_log(CW_CONF_DEBUG,"Originate returned %d \n",reason);
    cw_indicate(in->frommember->chan, -1);

    if ( reason == CW_CONTROL_ANSWER ) {
	conference_queue_sound( in->frommember, "beep" );
    } 
    else {
	conference_queue_sound( in->frommember, "beeperr" );
    }

    if (chan)
	cw_mutex_unlock(&chan->lock);
    free(in);
    return NULL;
}