From 33a69e539ee3ce06ee7288bac93b8299320100af Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 21 Apr 2008 20:15:50 +0000 Subject: [PATCH] add hold/unhold dialplan apps git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8138 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../applications/mod_dptools/mod_dptools.c | 16 +++++++ .../mod_spidermonkey/mod_spidermonkey.c | 42 ++++--------------- 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 6f6b6b262d..c7fac09369 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -1844,6 +1844,19 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session, return cause; } + +#define HOLD_SYNTAX "[]" +SWITCH_STANDARD_APP(hold_function) +{ + switch_ivr_hold_uuid(switch_core_session_get_uuid(session), data); +} + +#define UNHOLD_SYNTAX "" +SWITCH_STANDARD_APP(unhold_function) +{ + switch_ivr_unhold_uuid(switch_core_session_get_uuid(session)); +} + #define SPEAK_DESC "Speak text to a channel via the tts interface" #define DISPLACE_DESC "Displace audio from a file to the channels input" #define SESS_REC_DESC "Starts a background recording of the entire session" @@ -1876,6 +1889,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_API(api_interface, "strftime", "strftime", strftime_api_function, ""); SWITCH_ADD_API(api_interface, "presence", "presence", presence_api_function, " "); SWITCH_ADD_APP(app_interface, "privacy", "Set privacy on calls", "Set caller privacy on calls.", privacy_function, "off|on|name|full|number", SAF_SUPPORT_NOMEDIA); + + SWITCH_ADD_APP(app_interface, "hold", "Send a hold message", "Send a hold message", hold_function, HOLD_SYNTAX, SAF_SUPPORT_NOMEDIA); + SWITCH_ADD_APP(app_interface, "unhold", "Send a un-hold message", "Send a un-hold message", unhold_function, UNHOLD_SYNTAX, SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "transfer", "Transfer a channel", TRANSFER_LONG_DESC, transfer_function, " [ ]", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "check_acl", "Check an ip against an ACL list", "Check an ip against an ACL list", check_acl_function, " ", SAF_SUPPORT_NOMEDIA); diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c index 278951bd7d..1fe29942f2 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c @@ -2281,14 +2281,10 @@ static JSBool js_fetchurl_hash(JSContext * cx, JSObject * obj, uintN argc, jsval CURL *curl_handle = NULL; struct config_data config_data; int saveDepth = 0; - int32 disable_wait = 0; if (argc > 1) { url = JS_GetStringBytes(JS_ValueToString(cx, argv[0])); name = JS_GetStringBytes(JS_ValueToString(cx, argv[1])); - if (argc > 2) { - JS_ValueToInt32(cx, argv[2], &disable_wait); - } curl_handle = curl_easy_init(); if (!strncasecmp(url, "https", 5)) { @@ -2305,13 +2301,9 @@ static JSBool js_fetchurl_hash(JSContext * cx, JSObject * obj, uintN argc, jsval curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) &config_data); curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-js/1.0"); - if (disable_wait) { - saveDepth = JS_SuspendRequest(cx); - curl_easy_perform(curl_handle); - JS_ResumeRequest(cx, saveDepth); - } else { - curl_easy_perform(curl_handle); - } + saveDepth = JS_SuspendRequest(cx); + curl_easy_perform(curl_handle); + JS_ResumeRequest(cx, saveDepth); curl_easy_cleanup(curl_handle); } else { @@ -2330,14 +2322,10 @@ static JSBool js_fetchurl_file(JSContext * cx, JSObject * obj, uintN argc, jsval CURL *curl_handle = NULL; struct config_data config_data; int saveDepth = 0; - int32 disable_wait = 0; if (argc > 1) { url = JS_GetStringBytes(JS_ValueToString(cx, argv[0])); filename = JS_GetStringBytes(JS_ValueToString(cx, argv[1])); - if (argc > 2) { - JS_ValueToInt32(cx, argv[2], &disable_wait); - } curl_global_init(CURL_GLOBAL_ALL); curl_handle = curl_easy_init(); @@ -2355,13 +2343,9 @@ static JSBool js_fetchurl_file(JSContext * cx, JSObject * obj, uintN argc, jsval curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) &config_data); curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-js/1.0"); - if (disable_wait) { - saveDepth = JS_SuspendRequest(cx); - curl_easy_perform(curl_handle); - JS_ResumeRequest(cx, saveDepth); - } else { - curl_easy_perform(curl_handle); - } + saveDepth = JS_SuspendRequest(cx); + curl_easy_perform(curl_handle); + JS_ResumeRequest(cx, saveDepth); curl_easy_cleanup(curl_handle); close(config_data.fd); @@ -2383,15 +2367,11 @@ static JSBool js_fetchurl(JSContext * cx, JSObject * obj, uintN argc, jsval * ar int32 buffer_size = 65535; CURLcode code = 0; int saveDepth = 0; - int32 disable_wait = 0; if (argc >= 1) { url = JS_GetStringBytes(JS_ValueToString(cx, argv[0])); if (argc > 1) { JS_ValueToInt32(cx, argv[1], &buffer_size); - if (argc > 2) { - JS_ValueToInt32(cx, argv[2], &disable_wait); - } } curl_global_init(CURL_GLOBAL_ALL); @@ -2414,13 +2394,9 @@ static JSBool js_fetchurl(JSContext * cx, JSObject * obj, uintN argc, jsval * ar curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) &config_data); curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-js/1.0"); - if (disable_wait) { - saveDepth = JS_SuspendRequest(cx); - code = curl_easy_perform(curl_handle); - JS_ResumeRequest(cx, saveDepth); - } else { - code = curl_easy_perform(curl_handle); - } + saveDepth = JS_SuspendRequest(cx); + code = curl_easy_perform(curl_handle); + JS_ResumeRequest(cx, saveDepth); curl_easy_cleanup(curl_handle);