]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
openzap: callwaiting disable
authorMoises Silva <moy@sangoma.com>
Tue, 25 May 2010 20:49:54 +0000 (16:49 -0400)
committerMoises Silva <moy@sangoma.com>
Tue, 25 May 2010 20:50:06 +0000 (16:50 -0400)
libs/openzap/mod_openzap/mod_openzap.c
libs/openzap/src/include/zap_types.h
libs/openzap/src/ozmod/ozmod_analog/ozmod_analog.c
libs/openzap/src/zap_io.c

index bb9d6172360511091eecfab6b5c413eae861d359..4741b24e424ed2102749935ae053e587270cf910 100644 (file)
@@ -2107,6 +2107,7 @@ static switch_status_t load_config(void)
                        char *hold_music = NULL;
                        char *fail_dial_regex = NULL;
                        const char *enable_callerid = "true";
+                       int callwaiting = 1;
 
                        uint32_t span_id = 0, to = 0, max = 0;
                        zap_span_t *span = NULL;
@@ -2136,6 +2137,8 @@ static switch_status_t load_config(void)
                                        max_digits = val;
                                } else if (!strcasecmp(var, "hotline")) {
                                        hotline = val;
+                               } else if (!strcasecmp(var, "callwaiting")) {
+                                       callwaiting = switch_true(var) ? 1 : 0;
                                } else if (!strcasecmp(var, "enable-analog-option")) {
                                        analog_options = enable_analog_option(val, analog_options);
                                }
@@ -2186,8 +2189,9 @@ static switch_status_t load_config(void)
                                                                   "tonemap", tonegroup, 
                                                                   "digit_timeout", &to,
                                                                   "max_dialstr", &max,
-                                                                  "hotline", hotline,
+                                                                  "hotline", hotline ? hotline : "",
                                                                   "enable_callerid", enable_callerid,
+                                                                  "callwaiting", &callwaiting,
                                                                   TAG_END) != ZAP_SUCCESS) {
                                zap_log(ZAP_LOG_ERROR, "Error starting OpenZAP span %d\n", span_id);
                                continue;
index 810a365e19be76c7775de272a81d36492c11d4af..165533ff2256f17a3a59eb86ccdcec99a7d4ab2f 100644 (file)
@@ -330,7 +330,8 @@ typedef enum {
        ZAP_CHANNEL_FEATURE_CODECS = (1 << 2),
        ZAP_CHANNEL_FEATURE_INTERVAL = (1 << 3),
        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;
 
 typedef enum {
index 943badb1dd53b25dc7a5ddc2127a26f7caecfb8c..bfbc52f46fd2c01669799434147fda8a5d7dc130 100644 (file)
@@ -114,6 +114,8 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_analog_configure_span)
        const char *var, *val;
        int *intval;
        uint32_t flags = ZAP_ANALOG_CALLERID;
+       int callwaiting = 1;
+       unsigned i = 0;
 
        assert(sig_cb != NULL);
 
@@ -157,6 +159,11 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_analog_configure_span)
                                break;
                        }
                        hotline = val;
+               } else if (!strcasecmp(var, "callwaiting")) {
+                       if (!(intval = va_arg(ap, int *))) {
+                               break;
+                       }
+                       callwaiting = *intval;
                } else {
                        snprintf(span->last_error, sizeof(span->last_error), "Unknown parameter [%s]", var);
                        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) {
                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;
        analog_data->flags = flags;
index 058cbc921c74bd401663f28d84e8ca2a7e2caf4f..b43f60586bafcbdb3ee37f9e1ee815642aff6ada 100644 (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_span_t *span = NULL;
 
-       zap_mutex_unlock(globals.mutex);
+       zap_mutex_lock(globals.mutex);
        zap_span_find(span_id, &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;
                goto done;
        }
-       
-       status = ZAP_FAIL;
 
-       if (zap_test_flag(check, ZAP_CHANNEL_READY) && (!zap_test_flag(check, ZAP_CHANNEL_INUSE) || 
-                                                                                                       (check->type == ZAP_CHAN_TYPE_FXS && check->token_count == 1))) {
+       status = ZAP_FAIL;      
+       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)) {
                        status = check->zio->open(check);
                        if (status == ZAP_SUCCESS) {