]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
move code from uuid_kill into core
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 25 Oct 2011 16:53:22 +0000 (11:53 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 25 Oct 2011 16:53:22 +0000 (11:53 -0500)
src/include/switch_ivr.h
src/mod/applications/mod_commands/mod_commands.c
src/switch_ivr.c

index 6df083bca6e3b67d34ccdc0e3989607be2e2f6b6..03bbc2d7539aada67210d05c2acebc792fd56d45 100644 (file)
@@ -934,6 +934,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_insert_file(switch_core_session_t *se
 
 SWITCH_DECLARE(switch_status_t) switch_ivr_create_message_reply(switch_event_t **reply, switch_event_t *message, const char *new_proto);
 SWITCH_DECLARE(char *) switch_ivr_check_presence_mapping(const char *exten_name, const char *domain_name);
+SWITCH_DECLARE(switch_status_t) switch_ivr_kill_uuid(const char *uuid, switch_call_cause_t cause);
 
 /** @} */
 
index 988893a39f9bb44bac368ce654f2661c6d360dbf..d01adc658a951ff1c4659cef00f9d455189850ac 100644 (file)
@@ -2128,7 +2128,6 @@ SWITCH_STANDARD_API(reload_xml_function)
 #define KILL_SYNTAX "<uuid> [cause]"
 SWITCH_STANDARD_API(kill_function)
 {
-       switch_core_session_t *ksession = NULL;
        char *mycmd = NULL, *kcause = NULL;
        switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
 
@@ -2139,17 +2138,14 @@ SWITCH_STANDARD_API(kill_function)
 
        if ((kcause = strchr(mycmd, ' '))) {
                *kcause++ = '\0';
+               if (!zstr(kcause)) {
+                       cause = switch_channel_str2cause(kcause);
+               }               
        }
 
-       if (zstr(mycmd) || !(ksession = switch_core_session_locate(mycmd))) {
+       if (switch_ivr_kill_uuid(mycmd, cause) != SWITCH_STATUS_SUCCESS) {
                stream->write_function(stream, "-ERR No Such Channel!\n");
        } else {
-               switch_channel_t *channel = switch_core_session_get_channel(ksession);
-               if (!zstr(kcause)) {
-                       cause = switch_channel_str2cause(kcause);
-               }
-               switch_channel_hangup(channel, cause);
-               switch_core_session_rwunlock(ksession);
                stream->write_function(stream, "+OK\n");
        }
 
index 608e34d191e1d96c50453a6d8bd7d60654663712..0721639bb9116dae9c2f8937e47d2e38ee61c226 100644 (file)
@@ -3201,6 +3201,20 @@ SWITCH_DECLARE(char *) switch_ivr_check_presence_mapping(const char *exten_name,
        
 }
 
+SWITCH_DECLARE(switch_status_t) switch_ivr_kill_uuid(const char *uuid, switch_call_cause_t cause)
+{
+       switch_core_session_t *session;
+
+       if (zstr(uuid) || !(session = switch_core_session_locate(uuid))) {
+               return SWITCH_STATUS_FALSE;
+       } else {
+               switch_channel_t *channel = switch_core_session_get_channel(session);
+               switch_channel_hangup(channel, cause);
+               switch_core_session_rwunlock(session);
+               return SWITCH_STATUS_SUCCESS;
+       }
+}
+
 
 /* For Emacs:
  * Local Variables: