openzap: callwaiting disable

This commit is contained in:
Moises Silva 2010-05-25 16:49:54 -04:00
parent 6c8f0d499f
commit e1b60b4ca3
4 changed files with 26 additions and 7 deletions

View File

@ -2107,6 +2107,7 @@ static switch_status_t load_config(void)
char *hold_music = NULL; char *hold_music = NULL;
char *fail_dial_regex = NULL; char *fail_dial_regex = NULL;
const char *enable_callerid = "true"; const char *enable_callerid = "true";
int callwaiting = 1;
uint32_t span_id = 0, to = 0, max = 0; uint32_t span_id = 0, to = 0, max = 0;
zap_span_t *span = NULL; zap_span_t *span = NULL;
@ -2136,6 +2137,8 @@ static switch_status_t load_config(void)
max_digits = val; max_digits = val;
} else if (!strcasecmp(var, "hotline")) { } else if (!strcasecmp(var, "hotline")) {
hotline = val; hotline = val;
} else if (!strcasecmp(var, "callwaiting")) {
callwaiting = switch_true(var) ? 1 : 0;
} else if (!strcasecmp(var, "enable-analog-option")) { } else if (!strcasecmp(var, "enable-analog-option")) {
analog_options = enable_analog_option(val, analog_options); analog_options = enable_analog_option(val, analog_options);
} }
@ -2186,8 +2189,9 @@ static switch_status_t load_config(void)
"tonemap", tonegroup, "tonemap", tonegroup,
"digit_timeout", &to, "digit_timeout", &to,
"max_dialstr", &max, "max_dialstr", &max,
"hotline", hotline, "hotline", hotline ? hotline : "",
"enable_callerid", enable_callerid, "enable_callerid", enable_callerid,
"callwaiting", &callwaiting,
TAG_END) != ZAP_SUCCESS) { TAG_END) != ZAP_SUCCESS) {
zap_log(ZAP_LOG_ERROR, "Error starting OpenZAP span %d\n", span_id); zap_log(ZAP_LOG_ERROR, "Error starting OpenZAP span %d\n", span_id);
continue; continue;

View File

@ -330,7 +330,8 @@ typedef enum {
ZAP_CHANNEL_FEATURE_CODECS = (1 << 2), ZAP_CHANNEL_FEATURE_CODECS = (1 << 2),
ZAP_CHANNEL_FEATURE_INTERVAL = (1 << 3), ZAP_CHANNEL_FEATURE_INTERVAL = (1 << 3),
ZAP_CHANNEL_FEATURE_CALLERID = (1 << 4), ZAP_CHANNEL_FEATURE_CALLERID = (1 << 4),
ZAP_CHANNEL_FEATURE_PROGRESS = (1 << 5) ZAP_CHANNEL_FEATURE_PROGRESS = (1 << 5),
ZAP_CHANNEL_FEATURE_CALLWAITING = (1 << 6)
} zap_channel_feature_t; } zap_channel_feature_t;
typedef enum { typedef enum {

View File

@ -114,6 +114,8 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_analog_configure_span)
const char *var, *val; const char *var, *val;
int *intval; int *intval;
uint32_t flags = ZAP_ANALOG_CALLERID; uint32_t flags = ZAP_ANALOG_CALLERID;
int callwaiting = 1;
unsigned i = 0;
assert(sig_cb != NULL); assert(sig_cb != NULL);
@ -157,6 +159,11 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_analog_configure_span)
break; break;
} }
hotline = val; hotline = val;
} else if (!strcasecmp(var, "callwaiting")) {
if (!(intval = va_arg(ap, int *))) {
break;
}
callwaiting = *intval;
} else { } else {
snprintf(span->last_error, sizeof(span->last_error), "Unknown parameter [%s]", var); snprintf(span->last_error, sizeof(span->last_error), "Unknown parameter [%s]", var);
return ZAP_FAIL; return ZAP_FAIL;
@ -171,6 +178,12 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_analog_configure_span)
if ((max_dialstr < 1 && !strlen(hotline)) || max_dialstr > MAX_DTMF) { if ((max_dialstr < 1 && !strlen(hotline)) || max_dialstr > MAX_DTMF) {
max_dialstr = MAX_DTMF; max_dialstr = MAX_DTMF;
} }
if (callwaiting) {
for (i = 1; i <= span->chan_count; i++) {
zap_channel_set_feature(span->channels[i], ZAP_CHANNEL_FEATURE_CALLWAITING);
}
}
span->start = zap_analog_start; span->start = zap_analog_start;
analog_data->flags = flags; analog_data->flags = flags;

View File

@ -1287,7 +1287,7 @@ OZ_DECLARE(zap_status_t) zap_channel_open(uint32_t span_id, uint32_t chan_id, za
zap_status_t status = ZAP_FAIL; zap_status_t status = ZAP_FAIL;
zap_span_t *span = NULL; zap_span_t *span = NULL;
zap_mutex_unlock(globals.mutex); zap_mutex_lock(globals.mutex);
zap_span_find(span_id, &span); zap_span_find(span_id, &span);
if (!span || !zap_test_flag(span, ZAP_SPAN_CONFIGURED) || chan_id >= ZAP_MAX_CHANNELS_SPAN) { if (!span || !zap_test_flag(span, ZAP_SPAN_CONFIGURED) || chan_id >= ZAP_MAX_CHANNELS_SPAN) {
@ -1313,11 +1313,12 @@ OZ_DECLARE(zap_status_t) zap_channel_open(uint32_t span_id, uint32_t chan_id, za
*zchan = NULL; *zchan = NULL;
goto done; goto done;
} }
status = ZAP_FAIL;
if (zap_test_flag(check, ZAP_CHANNEL_READY) && (!zap_test_flag(check, ZAP_CHANNEL_INUSE) || status = ZAP_FAIL;
(check->type == ZAP_CHAN_TYPE_FXS && check->token_count == 1))) { if ((!zap_test_flag(check, ZAP_CHANNEL_INUSE)) ||
(check->type == ZAP_CHAN_TYPE_FXS &&
check->token_count == 1 &&
zap_channel_test_feature(check, ZAP_CHANNEL_FEATURE_CALLWAITING))) {
if (!zap_test_flag(check, ZAP_CHANNEL_OPEN)) { if (!zap_test_flag(check, ZAP_CHANNEL_OPEN)) {
status = check->zio->open(check); status = check->zio->open(check);
if (status == ZAP_SUCCESS) { if (status == ZAP_SUCCESS) {