]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
pass cause from originate
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 12 Sep 2006 01:32:04 +0000 (01:32 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 12 Sep 2006 01:32:04 +0000 (01:32 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2647 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_ivr.h
src/mod/applications/mod_bridgecall/mod_bridgecall.c
src/mod/applications/mod_commands/mod_commands.c
src/mod/applications/mod_conference/mod_conference.c
src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
src/switch_ivr.c

index 7d0ff8f226851a50d2fd2e8588e2d166d9dfda76..3d9db37997cff251c79413c29340ceb86d482383 100644 (file)
@@ -189,6 +189,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses
   \brief Make an outgoing call
   \param session originating session
   \param bleg B leg session
+  \param cause a pointer to hold call cause
   \param bridgeto the desired remote callstring
   \param timelimit_sec timeout in seconds for outgoing call
   \param table optional state handler table to install on the channel
@@ -199,6 +200,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *session,
                                                                                                         switch_core_session_t **bleg,
+                                                                                                        switch_call_cause_t *cause,
                                                                                                         char *bridgeto,
                                                                                                         uint32_t timelimit_sec,
                                                                                                         const switch_state_handler_table_t *table,
index b4da03930c564b43f9d1110b32c777089e700550..f2ca02209ec08318c48ef46649ef2f6419e5a13e 100644 (file)
@@ -42,6 +42,7 @@ static void audio_bridge_function(switch_core_session_t *session, char *data)
        switch_core_session_t *peer_session;
        unsigned int timelimit = 60;
        char *var;
+       switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
 
        caller_channel = switch_core_session_get_channel(session);
        assert(caller_channel != NULL);
@@ -50,7 +51,7 @@ static void audio_bridge_function(switch_core_session_t *session, char *data)
                timelimit = atoi(var);
        }
 
-       if (switch_ivr_originate(session, &peer_session, data, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
+       if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n");
                switch_channel_hangup(caller_channel, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL);
                return;
index 45052b1d3e5b90aab4c3ebc3b11892d6fe5893e9..f8a88e1154d8878b3a56280ce2d57a695bea63e6 100644 (file)
@@ -217,7 +217,7 @@ static switch_status_t originate_function(char *cmd, switch_core_session_t *ises
        int x, argc = 0;
        char *aleg, *exten, *dp, *context, *cid_name, *cid_num;
        uint32_t timeout = 60;
-
+       switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
        if (isession) {
                stream->write_function(stream, "Illegal Usage\n");
                return SWITCH_STATUS_SUCCESS;
@@ -260,7 +260,7 @@ static switch_status_t originate_function(char *cmd, switch_core_session_t *ises
                return SWITCH_STATUS_SUCCESS;
        }
 
-       if (switch_ivr_originate(NULL, &caller_session, aleg, timeout, &noop_state_handler, cid_name, cid_num, NULL) != SWITCH_STATUS_SUCCESS) {
+       if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, &noop_state_handler, cid_name, cid_num, NULL) != SWITCH_STATUS_SUCCESS) {
                stream->write_function(stream, "Cannot Create Outgoing Channel! [%s]\n", aleg);
                return SWITCH_STATUS_SUCCESS;
        } 
index 357ed7a74d80dac3bcd41f97dc686c7ea4a27934..74db3e4bc33d4c65ad8a421a59b3d6650dacbb10 100644 (file)
@@ -2044,13 +2044,21 @@ static switch_status_t conference_outcall(conference_obj_t *conference,
        switch_status_t status = SWITCH_STATUS_SUCCESS;
        switch_channel_t *caller_channel = NULL;
        char appdata[512];
-
-
-       if (switch_ivr_originate(session, &peer_session, bridgeto, timeout, &audio_bridge_peer_state_handlers, cid_name, cid_num, NULL) != SWITCH_STATUS_SUCCESS) {
+       switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
+
+       if (switch_ivr_originate(session,
+                                                        &peer_session,
+                                                        &cause,
+                                                        bridgeto,
+                                                        timeout,
+                                                        &audio_bridge_peer_state_handlers,
+                                                        cid_name,
+                                                        cid_num,
+                                                        NULL) != SWITCH_STATUS_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n");
                if (session) {
                        caller_channel = switch_core_session_get_channel(session);
-                       switch_channel_hangup(caller_channel, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL);
+                       switch_channel_hangup(caller_channel, cause);
                }
                goto done;
        } 
index 01c74d3e2822c23d0992d30a1b04b7b9dbafdcd1..fb9e2a0346cfbeba42e76def4604669eb0b20b29 100644 (file)
@@ -1390,6 +1390,7 @@ static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
 {
        switch_memory_pool_t *pool = NULL;
        if (argc > 1) {
+               switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
                struct js_session *jss = NULL;
                JSObject *session_obj;
                switch_core_session_t *session = NULL, *peer_session = NULL;
@@ -1471,7 +1472,7 @@ static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
                                                                                                   context,
                                                                                                   dest);
                
-               if (switch_ivr_originate(session, &peer_session, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile) != SWITCH_STATUS_SUCCESS) {
+               if (switch_ivr_originate(session, &peer_session, &cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile) != SWITCH_STATUS_SUCCESS) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot Create Outgoing Channel! [%s]\n", dest);
                        return JS_TRUE;
                }
index 52c62c4d91e43e2c905d7e4f0e55cb84e5b40796..9690237c46fad740e56f4a260752477b54d8cbb7 100644 (file)
@@ -1534,6 +1534,7 @@ static uint8_t check_channel_status(switch_channel_t **peer_channels,
 #define MAX_PEERS 256
 SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *session,
                                                                                                         switch_core_session_t **bleg,
+                                                                                                        switch_call_cause_t *cause,
                                                                                                         char *bridgeto,
                                                                                                         uint32_t timelimit_sec,
                                                                                                         const switch_state_handler_table_t *table,
@@ -1849,6 +1850,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
 
 
  done:
+       if (caller_channel) {
+               *cause = switch_channel_get_cause(caller_channel);
+       } else {
+               *cause = SWITCH_CAUSE_CHANNEL_UNACCEPTABLE;
+       }
        if (odata) {
                free(odata);
        }