diff options
author | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-06-20 21:38:49 +0000 |
---|---|---|
committer | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-06-20 21:38:49 +0000 |
commit | 5d0ac5c2e193a26b32a7f6061a893e2781cc2c6a (patch) | |
tree | c340b3907d7eb60d75551488a478f3dcb66d0f22 | |
parent | c346de7673a83232ae20417094e01d6c692a6fe8 (diff) |
As per 9228, now app_queue should have the proper machinery to do gosubs.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@70531 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | apps/app_dial.c | 6 | ||||
-rw-r--r-- | apps/app_queue.c | 53 |
2 files changed, 50 insertions, 9 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c index 8bec88b76..7d92d6d8c 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -1637,7 +1637,6 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags struct ast_app *theapp; const char *gosub_result; char *gosub_args, *gosub_argstart; - ast_log(LOG_ERROR, "In OPT_CALLEE_GOSUB code!\n"); res = ast_autoservice_start(chan); if (res) { @@ -1655,7 +1654,6 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags ast_copy_string(peer->exten, "s", sizeof(peer->exten)); peer->priority = 0; - ast_log(LOG_ERROR, "Gosub stuff is: %s\n", opt_args[OPT_ARG_CALLEE_GOSUB]); gosub_argstart = strchr(opt_args[OPT_ARG_CALLEE_GOSUB], '|'); if (gosub_argstart) { *gosub_argstart = 0; @@ -1664,12 +1662,10 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags } else { asprintf(&gosub_args, "%s|s|1", opt_args[OPT_ARG_CALLEE_GOSUB]); } - ast_log(LOG_DEBUG, "Gosub_args is: %s\n", gosub_args); + if (gosub_args) { - ast_log(LOG_ERROR, "About to pbx_exec!\n"); res = pbx_exec(peer, theapp, gosub_args); ast_pbx_run(peer); - ast_log(LOG_ERROR, "pbx_exec returns %d!\n", res); free(gosub_args); if (option_debug) ast_log(LOG_DEBUG, "Gosub exited with status %d\n", res); diff --git a/apps/app_queue.c b/apps/app_queue.c index 0f425a2c2..ac07a4018 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -2797,9 +2797,30 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce app = pbx_findapp("Gosub"); if (app) { - res = pbx_exec(qe->chan, app, gosubexec); - if (option_debug) - ast_log(LOG_DEBUG, "Gosub exited with status %d\n", res); + char *gosub_args, *gosub_argstart; + + /* Set where we came from */ + ast_copy_string(qe->chan->context, "app_dial_gosub_virtual_context", sizeof(qe->chan->context)); + ast_copy_string(qe->chan->exten, "s", sizeof(qe->chan->exten)); + qe->chan->priority = 0; + + gosub_argstart = strchr(gosubexec, '|'); + if (gosub_argstart) { + *gosub_argstart = 0; + asprintf(&gosub_args, "%s|s|1(%s)", gosubexec, gosub_argstart + 1); + *gosub_argstart = '|'; + } else { + asprintf(&gosub_args, "%s|s|1", gosubexec); + } + if (gosub_args) { + res = pbx_exec(qe->chan, app, gosub_args); + ast_pbx_run(qe->chan); + free(gosub_args); + if (option_debug) + ast_log(LOG_DEBUG, "Gosub exited with status %d\n", res); + } else + ast_log(LOG_ERROR, "Could not Allocate string for Gosub arguments -- Gosub Call Aborted!\n"); + res = 0; } else { ast_log(LOG_ERROR, "Could not find application Gosub\n"); @@ -4696,9 +4717,19 @@ static struct ast_cli_entry cli_queue[] = { qrm_cmd_usage, complete_queue_remove_member, NULL }, }; +static char *kapp = "KeepAlive"; +static char *ksynopsis = "DO NOT USE"; +static char *kdescrip = ""; + +static int keepalive_exec(struct ast_channel *chan, void *data) +{ + return AST_PBX_KEEPALIVE; +} + static int unload_module(void) { int res; + struct ast_context *con; if (device_state.thread != AST_PTHREADT_NULL) { device_state.stop = 1; @@ -4723,6 +4754,7 @@ static int unload_module(void) res |= ast_unregister_application(app_upqm); res |= ast_unregister_application(app_ql); res |= ast_unregister_application(app); + res |= ast_unregister_application(kapp); res |= ast_custom_function_unregister(&queuevar_function); res |= ast_custom_function_unregister(&queuemembercount_function); res |= ast_custom_function_unregister(&queuememberlist_function); @@ -4731,6 +4763,10 @@ static int unload_module(void) if (device_state_sub) ast_event_unsubscribe(device_state_sub); + if ((con = ast_context_find("app_queue_gosub_virtual_context"))) { + ast_context_remove_extension2(con, "s", 1, NULL); + } + ast_module_user_hangup_all(); clear_and_free_interfaces(); @@ -4741,10 +4777,19 @@ static int unload_module(void) static int load_module(void) { int res; + struct ast_context *con; if (!reload_queues()) return AST_MODULE_LOAD_DECLINE; + con = ast_context_find("app_dial_queue_virtual_context"); + if (!con) + con = ast_context_create(NULL, "app_queue_gosub_virtual_context", "app_dial"); + 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, "KeepAlive", ast_strdup(""), ast_free, "app_queue"); + if (queue_persistent_members) reload_queue_members(); @@ -4759,6 +4804,7 @@ static int load_module(void) res |= ast_register_application(app_pqm, pqm_exec, app_pqm_synopsis, app_pqm_descrip); res |= ast_register_application(app_upqm, upqm_exec, app_upqm_synopsis, app_upqm_descrip); res |= ast_register_application(app_ql, ql_exec, app_ql_synopsis, app_ql_descrip); + res |= ast_register_application(kapp, keepalive_exec, ksynopsis, kdescrip); res |= ast_manager_register("Queues", 0, manager_queues_show, "Queues"); res |= ast_manager_register("QueueStatus", 0, manager_queues_status, "Queue Status"); res |= ast_manager_register("QueueSummary", 0, manager_queues_summary, "Queue Summary"); @@ -4770,7 +4816,6 @@ static int load_module(void) res |= ast_custom_function_register(&queuemembercount_function); res |= ast_custom_function_register(&queuememberlist_function); res |= ast_custom_function_register(&queuewaitingcount_function); - if (!(device_state_sub = ast_event_subscribe(AST_EVENT_DEVICE_STATE, device_state_cb, NULL, AST_EVENT_IE_END))) res = -1; |