[asterisk-commits] oej: branch oej/pinequeue-trunk r363307 - in /team/oej/pinequeue-trunk: ./ apps/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Apr 23 15:11:18 CDT 2012
Author: oej
Date: Mon Apr 23 15:11:15 2012
New Revision: 363307
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=363307
Log:
Reset automerge
Modified:
team/oej/pinequeue-trunk/ (props changed)
team/oej/pinequeue-trunk/apps/app_dial.c
team/oej/pinequeue-trunk/apps/app_queue.c
Propchange: team/oej/pinequeue-trunk/
------------------------------------------------------------------------------
automerge = Is-there-life-off-net?
Propchange: team/oej/pinequeue-trunk/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Apr 23 15:11:15 2012
@@ -1,1 +1,1 @@
-/trunk:1-363255
+/trunk:1-363306
Modified: team/oej/pinequeue-trunk/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinequeue-trunk/apps/app_dial.c?view=diff&rev=363307&r1=363306&r2=363307
==============================================================================
--- team/oej/pinequeue-trunk/apps/app_dial.c (original)
+++ team/oej/pinequeue-trunk/apps/app_dial.c Mon Apr 23 15:11:15 2012
@@ -2626,39 +2626,25 @@
}
if (ast_test_flag64(&opts, OPT_CALLEE_MACRO) && !ast_strlen_zero(opt_args[OPT_ARG_CALLEE_MACRO])) {
- struct ast_app *theapp;
- const char *macro_result;
-
- res = ast_autoservice_start(chan);
- if (res) {
- ast_log(LOG_ERROR, "Unable to start autoservice on calling channel\n");
- res = -1;
- }
-
- theapp = pbx_findapp("Macro");
-
- if (theapp && !res) { /* XXX why check res here ? */
- /* Set peer->exten and peer->context so that MACRO_EXTEN and MACRO_CONTEXT get set */
- ast_channel_context_set(peer, ast_channel_context(chan));
- ast_channel_exten_set(peer, ast_channel_exten(chan));
-
- ast_replace_subargument_delimiter(opt_args[OPT_ARG_CALLEE_MACRO]);
- res = pbx_exec(peer, theapp, opt_args[OPT_ARG_CALLEE_MACRO]);
- ast_debug(1, "Macro exited with status %d\n", res);
- res = 0;
- } else {
- ast_log(LOG_ERROR, "Could not find application Macro\n");
- res = -1;
- }
-
- if (ast_autoservice_stop(chan) < 0) {
- res = -1;
- }
+ const char *macro_result_peer;
+
+ /* Set peer->exten and peer->context so that MACRO_EXTEN and MACRO_CONTEXT get set */
+ ast_channel_lock_both(chan, peer);
+ ast_channel_context_set(peer, ast_channel_context(chan));
+ ast_channel_exten_set(peer, ast_channel_exten(chan));
+ ast_channel_unlock(peer);
+ ast_channel_unlock(chan);
+
+ ast_replace_subargument_delimiter(opt_args[OPT_ARG_CALLEE_MACRO]);
+ res = ast_app_exec_macro(chan, peer, opt_args[OPT_ARG_CALLEE_MACRO]);
ast_channel_lock(peer);
- if (!res && (macro_result = pbx_builtin_getvar_helper(peer, "MACRO_RESULT"))) {
+ if (!res && (macro_result_peer = pbx_builtin_getvar_helper(peer, "MACRO_RESULT"))) {
+ char *macro_result = ast_strdupa(macro_result_peer);
char *macro_transfer_dest;
+
+ ast_channel_unlock(peer);
if (!strcasecmp(macro_result, "BUSY")) {
ast_copy_string(pa.status, macro_result, sizeof(pa.status));
@@ -2678,7 +2664,8 @@
} else if (!strcasecmp(macro_result, "ABORT")) {
/* Hangup both ends unless the caller has the g flag */
res = -1;
- } else if (!strncasecmp(macro_result, "GOTO:", 5) && (macro_transfer_dest = ast_strdupa(macro_result + 5))) {
+ } else if (!strncasecmp(macro_result, "GOTO:", 5)) {
+ macro_transfer_dest = macro_result + 5;
res = -1;
/* perform a transfer to a new extension */
if (strchr(macro_transfer_dest, '^')) { /* context^exten^priority*/
@@ -2687,92 +2674,63 @@
ast_set_flag64(peerflags, OPT_GO_ON);
}
}
- }
-
- ast_channel_unlock(peer);
+ } else {
+ ast_channel_unlock(peer);
+ }
}
if (ast_test_flag64(&opts, OPT_CALLEE_GOSUB) && !ast_strlen_zero(opt_args[OPT_ARG_CALLEE_GOSUB])) {
- struct ast_app *theapp;
- const char *gosub_result;
- char *gosub_args, *gosub_argstart;
+ const char *gosub_result_peer;
+ char *gosub_argstart;
+ char *gosub_args = NULL;
int res9 = -1;
- res9 = ast_autoservice_start(chan);
- if (res9) {
- ast_log(LOG_ERROR, "Unable to start autoservice on calling channel\n");
- res9 = -1;
- }
-
- theapp = pbx_findapp("Gosub");
-
- if (theapp && !res9) {
- ast_replace_subargument_delimiter(opt_args[OPT_ARG_CALLEE_GOSUB]);
-
- /* Set where we came from */
- ast_channel_context_set(peer, "app_dial_gosub_virtual_context");
- ast_channel_exten_set(peer, "s");
- ast_channel_priority_set(peer, 0);
-
- gosub_argstart = strchr(opt_args[OPT_ARG_CALLEE_GOSUB], ',');
- if (gosub_argstart) {
- const char *what_is_s = "s";
- *gosub_argstart = 0;
- if (!ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "s", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL)) &&
- ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "~~s~~", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL))) {
- what_is_s = "~~s~~";
- }
- if (asprintf(&gosub_args, "%s,%s,1(%s)", opt_args[OPT_ARG_CALLEE_GOSUB], what_is_s, gosub_argstart + 1) < 0) {
- ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
- gosub_args = NULL;
- }
- *gosub_argstart = ',';
- } else {
- const char *what_is_s = "s";
- if (!ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "s", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL)) &&
- ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "~~s~~", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL))) {
- what_is_s = "~~s~~";
- }
- if (asprintf(&gosub_args, "%s,%s,1", opt_args[OPT_ARG_CALLEE_GOSUB], what_is_s) < 0) {
- ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
- gosub_args = NULL;
- }
+ ast_replace_subargument_delimiter(opt_args[OPT_ARG_CALLEE_GOSUB]);
+ gosub_argstart = strchr(opt_args[OPT_ARG_CALLEE_GOSUB], ',');
+ if (gosub_argstart) {
+ const char *what_is_s = "s";
+ *gosub_argstart = 0;
+ if (!ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "s", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL)) &&
+ ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "~~s~~", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL))) {
+ what_is_s = "~~s~~";
}
-
- if (gosub_args) {
- res9 = pbx_exec(peer, theapp, gosub_args);
- if (!res9) {
- struct ast_pbx_args pbx_args;
- /* A struct initializer fails to compile for this case ... */
- memset(&pbx_args, 0, sizeof(pbx_args));
- pbx_args.no_hangup_chan = 1;
- ast_pbx_run_args(peer, &pbx_args);
- }
- ast_free(gosub_args);
- ast_debug(1, "Gosub exited with status %d\n", res9);
- } else {
- ast_log(LOG_ERROR, "Could not Allocate string for Gosub arguments -- Gosub Call Aborted!\n");
+ if (asprintf(&gosub_args, "%s,%s,1(%s)", opt_args[OPT_ARG_CALLEE_GOSUB], what_is_s, gosub_argstart + 1) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ gosub_args = NULL;
}
-
- } else if (!res9) {
- ast_log(LOG_ERROR, "Could not find application Gosub\n");
- res9 = -1;
- }
-
- if (ast_autoservice_stop(chan) < 0) {
- res9 = -1;
- }
-
- ast_channel_lock(peer);
-
- if (!res9 && (gosub_result = pbx_builtin_getvar_helper(peer, "GOSUB_RESULT"))) {
+ *gosub_argstart = ',';
+ } else {
+ const char *what_is_s = "s";
+ if (!ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "s", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL)) &&
+ ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "~~s~~", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL))) {
+ what_is_s = "~~s~~";
+ }
+ if (asprintf(&gosub_args, "%s,%s,1", opt_args[OPT_ARG_CALLEE_GOSUB], what_is_s) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ gosub_args = NULL;
+ }
+ }
+ if (gosub_args) {
+ res9 = ast_app_exec_sub(chan, peer, gosub_args);
+ ast_free(gosub_args);
+ } else {
+ ast_log(LOG_ERROR, "Could not Allocate string for Gosub arguments -- Gosub Call Aborted!\n");
+ }
+
+ ast_channel_lock_both(chan, peer);
+
+ if (!res9 && (gosub_result_peer = pbx_builtin_getvar_helper(peer, "GOSUB_RESULT"))) {
char *gosub_transfer_dest;
+ char *gosub_result = ast_strdupa(gosub_result_peer);
const char *gosub_retval = pbx_builtin_getvar_helper(peer, "GOSUB_RETVAL");
/* Inherit return value from the peer, so it can be used in the master */
if (gosub_retval) {
pbx_builtin_setvar_helper(chan, "GOSUB_RETVAL", gosub_retval);
}
+
+ ast_channel_unlock(peer);
+ ast_channel_unlock(chan);
if (!strcasecmp(gosub_result, "BUSY")) {
ast_copy_string(pa.status, gosub_result, sizeof(pa.status));
@@ -2783,16 +2741,14 @@
ast_set_flag64(peerflags, OPT_GO_ON);
res = -1;
} else if (!strcasecmp(gosub_result, "CONTINUE")) {
- /* hangup peer and keep chan alive assuming the macro has changed
- the context / exten / priority or perhaps
- the next priority in the current exten is desired.
- */
+ /* Hangup peer and continue with the next extension priority. */
ast_set_flag64(peerflags, OPT_GO_ON);
res = -1;
} else if (!strcasecmp(gosub_result, "ABORT")) {
/* Hangup both ends unless the caller has the g flag */
res = -1;
- } else if (!strncasecmp(gosub_result, "GOTO:", 5) && (gosub_transfer_dest = ast_strdupa(gosub_result + 5))) {
+ } else if (!strncasecmp(gosub_result, "GOTO:", 5)) {
+ gosub_transfer_dest = gosub_result + 5;
res = -1;
/* perform a transfer to a new extension */
if (strchr(gosub_transfer_dest, '^')) { /* context^exten^priority*/
@@ -2801,9 +2757,10 @@
ast_set_flag64(peerflags, OPT_GO_ON);
}
}
- }
-
- ast_channel_unlock(peer);
+ } else {
+ ast_channel_unlock(peer);
+ ast_channel_unlock(chan);
+ }
}
if (!res) {
@@ -3091,15 +3048,9 @@
static int unload_module(void)
{
int res;
- struct ast_context *con;
res = ast_unregister_application(app);
res |= ast_unregister_application(rapp);
-
- if ((con = ast_context_find("app_dial_gosub_virtual_context"))) {
- ast_context_remove_extension2(con, "s", 1, NULL, 0);
- ast_context_destroy(con, "app_dial"); /* leave nothing behind */
- }
return res;
}
@@ -3107,13 +3058,6 @@
static int load_module(void)
{
int res;
- struct ast_context *con;
-
- con = ast_context_find_or_create(NULL, NULL, "app_dial_gosub_virtual_context", "app_dial");
- if (!con)
- ast_log(LOG_ERROR, "Dial virtual context 'app_dial_gosub_virtual_context' does not exist and unable to create\n");
- else
- ast_add_extension2(con, 1, "s", 1, NULL, NULL, "NoOp", ast_strdup(""), ast_free_ptr, "app_dial");
res = ast_register_application_xml(app, dial_exec);
res |= ast_register_application_xml(rapp, retrydial_exec);
Modified: team/oej/pinequeue-trunk/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinequeue-trunk/apps/app_queue.c?view=diff&rev=363307&r1=363306&r2=363307
==============================================================================
--- team/oej/pinequeue-trunk/apps/app_queue.c (original)
+++ team/oej/pinequeue-trunk/apps/app_queue.c Mon Apr 23 15:11:15 2012
@@ -5123,28 +5123,7 @@
if (!ast_strlen_zero(macroexec)) {
ast_debug(1, "app_queue: macro=%s.\n", macroexec);
-
- res = ast_autoservice_start(qe->chan);
- if (res) {
- ast_log(LOG_ERROR, "Unable to start autoservice on calling channel %s\n", ast_channel_name(qe->chan));
- res = -1;
- }
-
- application = pbx_findapp("Macro");
-
- if (application) {
- res = pbx_exec(peer, application, macroexec);
- ast_debug(1, "Macro exited with status %d\n", res);
- res = 0;
- } else {
- ast_log(LOG_ERROR, "Could not find application Macro\n");
- res = -1;
- }
-
- if (ast_autoservice_stop(qe->chan) < 0) {
- ast_log(LOG_ERROR, "Could not stop autoservice on calling channel\n");
- res = -1;
- }
+ ast_app_exec_macro(qe->chan, peer, macroexec);
}
/* run a gosub for this connection if defined. The gosub simply returns, no action is taken on the result */
@@ -5157,69 +5136,40 @@
}
if (!ast_strlen_zero(gosubexec)) {
+ char *gosub_args = NULL;
+ char *gosub_argstart;
+
ast_debug(1, "app_queue: gosub=%s.\n", gosubexec);
-
- res = ast_autoservice_start(qe->chan);
- if (res) {
- ast_log(LOG_ERROR, "Unable to start autoservice on calling channel\n");
- res = -1;
- }
-
- application = pbx_findapp("Gosub");
-
- if (application) {
- char *gosub_args, *gosub_argstart;
-
- /* Set where we came from */
- ast_channel_context_set(peer, "app_queue_gosub_virtual_context");
- ast_channel_exten_set(peer, "s");
- ast_channel_priority_set(peer, 0);
-
- gosub_argstart = strchr(gosubexec, ',');
- if (gosub_argstart) {
- const char *what_is_s = "s";
- *gosub_argstart = 0;
- if (!ast_exists_extension(peer, gosubexec, "s", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL)) &&
- ast_exists_extension(peer, gosubexec, "~~s~~", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL))) {
- what_is_s = "~~s~~";
- }
- if (asprintf(&gosub_args, "%s,%s,1(%s)", gosubexec, what_is_s, gosub_argstart + 1) < 0) {
- ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
- gosub_args = NULL;
- }
- *gosub_argstart = ',';
- } else {
- const char *what_is_s = "s";
- if (!ast_exists_extension(peer, gosubexec, "s", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL)) &&
- ast_exists_extension(peer, gosubexec, "~~s~~", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL))) {
- what_is_s = "~~s~~";
- }
- if (asprintf(&gosub_args, "%s,%s,1", gosubexec, what_is_s) < 0) {
- ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
- gosub_args = NULL;
- }
+
+ gosub_argstart = strchr(gosubexec, ',');
+ if (gosub_argstart) {
+ const char *what_is_s = "s";
+ *gosub_argstart = 0;
+ if (!ast_exists_extension(peer, gosubexec, "s", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL)) &&
+ ast_exists_extension(peer, gosubexec, "~~s~~", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL))) {
+ what_is_s = "~~s~~";
}
- if (gosub_args) {
- res = pbx_exec(peer, application, gosub_args);
- if (!res) {
- struct ast_pbx_args args;
- memset(&args, 0, sizeof(args));
- args.no_hangup_chan = 1;
- ast_pbx_run_args(peer, &args);
- }
- ast_free(gosub_args);
- ast_debug(1, "Gosub exited with status %d\n", res);
- } else {
- ast_log(LOG_ERROR, "Could not Allocate string for Gosub arguments -- Gosub Call Aborted!\n");
+ if (asprintf(&gosub_args, "%s,%s,1(%s)", gosubexec, what_is_s, gosub_argstart + 1) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ gosub_args = NULL;
}
+ *gosub_argstart = ',';
} else {
- ast_log(LOG_ERROR, "Could not find application Gosub\n");
- res = -1;
- }
-
- if (ast_autoservice_stop(qe->chan) < 0) {
- ast_log(LOG_ERROR, "Could not stop autoservice on calling channel\n");
- res = -1;
+ const char *what_is_s = "s";
+ if (!ast_exists_extension(peer, gosubexec, "s", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL)) &&
+ ast_exists_extension(peer, gosubexec, "~~s~~", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL))) {
+ what_is_s = "~~s~~";
+ }
+ if (asprintf(&gosub_args, "%s,%s,1", gosubexec, what_is_s) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ gosub_args = NULL;
+ }
+ }
+ if (gosub_args) {
+ ast_app_exec_sub(qe->chan, peer, gosub_args);
+ ast_free(gosub_args);
+ } else {
+ ast_log(LOG_ERROR, "Could not Allocate string for Gosub arguments -- Gosub Call Aborted!\n");
}
}
@@ -9113,7 +9063,6 @@
static int unload_module(void)
{
int res;
- struct ast_context *con;
struct ao2_iterator q_iter;
struct call_queue *q = NULL;
@@ -9148,11 +9097,6 @@
ast_extension_state_del(0, extension_state_cb);
- if ((con = ast_context_find("app_queue_gosub_virtual_context"))) {
- ast_context_remove_extension2(con, "s", 1, NULL, 0);
- ast_context_destroy(con, "app_queue"); /* leave no trace */
- }
-
q_iter = ao2_iterator_init(queues, 0);
while ((q = ao2_t_iterator_next(&q_iter, "Iterate through queues"))) {
queues_t_unlink(queues, q, "Remove queue from container due to unload");
@@ -9168,7 +9112,6 @@
static int load_module(void)
{
int res;
- struct ast_context *con;
struct ast_flags mask = {AST_FLAGS_ALL, };
queues = ao2_container_alloc(MAX_QUEUE_BUCKETS, queue_hash_cb, queue_cmp_cb);
@@ -9177,12 +9120,6 @@
if (reload_handler(0, &mask, NULL))
return AST_MODULE_LOAD_DECLINE;
-
- con = ast_context_find_or_create(NULL, NULL, "app_queue_gosub_virtual_context", "app_queue");
- if (!con)
- ast_log(LOG_ERROR, "Queue virtual context 'app_queue_gosub_virtual_context' does not exist and unable to create\n");
- else
- ast_add_extension2(con, 1, "s", 1, NULL, NULL, "NoOp", ast_strdup(""), ast_free_ptr, "app_queue");
if (queue_persistent_members)
reload_queue_members();
More information about the asterisk-commits
mailing list