diff options
author | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-07-02 16:12:41 +0000 |
---|---|---|
committer | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-07-02 16:12:41 +0000 |
commit | f8f4f1bdb8e7601de30b6529d6e4017e0e3b0d3d (patch) | |
tree | dd2a35ece802e9b36d8af1873488bfa58468af5f /main/pbx.c | |
parent | f470e155642172031d6446af35598c0f8bd98ef2 (diff) |
Merged revisions 204710 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r204710 | dvossel | 2009-07-02 11:03:44 -0500 (Thu, 02 Jul 2009) | 21 lines
Merged revisions 204681 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r204681 | dvossel | 2009-07-02 10:05:57 -0500 (Thu, 02 Jul 2009) | 14 lines
Improved mapping of extension states from combined device states.
This fixes a few issues with incorrect extension states and adds
a cli command, core show device2extenstate, to display all possible
state mappings.
(closes issue #15413)
Reported by: legart
Patches:
exten_helper.diff uploaded by dvossel (license 671)
Tested by: dvossel, legart, amilcar
Review: https://reviewboard.asterisk.org/r/301/
........
................
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@204711 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/pbx.c')
-rw-r--r-- | main/pbx.c | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/main/pbx.c b/main/pbx.c index 18a12ae4e..ca84d4301 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -22,7 +22,6 @@ * * \author Mark Spencer <markster@digium.com> */ - #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") @@ -3752,7 +3751,6 @@ static int ast_extension_state2(struct ast_exten *e) struct ast_str *hint = ast_str_thread_get(&extensionstate_buf, 16); char *cur, *rest; struct ast_devstate_aggregate agg; - enum ast_device_state state; if (!e) return -1; @@ -3767,28 +3765,7 @@ static int ast_extension_state2(struct ast_exten *e) ast_devstate_aggregate_add(&agg, ast_device_state(cur)); } - state = ast_devstate_aggregate_result(&agg); - - switch (state) { - case AST_DEVICE_ONHOLD: - return AST_EXTENSION_ONHOLD; - case AST_DEVICE_BUSY: - return AST_EXTENSION_BUSY; - case AST_DEVICE_UNAVAILABLE: - case AST_DEVICE_UNKNOWN: - case AST_DEVICE_INVALID: - return AST_EXTENSION_UNAVAILABLE; - case AST_DEVICE_RINGINUSE: - return (AST_EXTENSION_INUSE | AST_EXTENSION_RINGING); - case AST_DEVICE_RINGING: - return AST_EXTENSION_RINGING; - case AST_DEVICE_INUSE: - return AST_EXTENSION_INUSE; - case AST_DEVICE_NOT_INUSE: - return AST_EXTENSION_NOT_INUSE; - } - - return AST_EXTENSION_NOT_INUSE; + return ast_devstate_to_extenstate(ast_devstate_aggregate_result(&agg)); } /*! \brief Return extension_state as string */ @@ -6152,6 +6129,36 @@ static char *handle_show_globals(struct ast_cli_entry *e, int cmd, struct ast_cl return CLI_SUCCESS; } +#ifdef AST_DEVMODE +static char *handle_show_device2extenstate(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +{ + struct ast_devstate_aggregate agg; + int i, j, exten, combined; + + switch (cmd) { + case CLI_INIT: + e->command = "core show device2extenstate"; + e->usage = + "Usage: core show device2extenstate\n" + " Lists device state to extension state combinations.\n"; + case CLI_GENERATE: + return NULL; + } + for (i = 0; i < AST_DEVICE_TOTAL; i++) { + for (j = 0; j < AST_DEVICE_TOTAL; j++) { + ast_devstate_aggregate_init(&agg); + ast_devstate_aggregate_add(&agg, i); + ast_devstate_aggregate_add(&agg, j); + combined = ast_devstate_aggregate_result(&agg); + exten = ast_devstate_to_extenstate(combined); + ast_cli(a->fd, "\n Exten:%14s CombinedDevice:%12s Dev1:%12s Dev2:%12s", ast_extension_state2str(exten), ast_devstate_str(combined), ast_devstate_str(j), ast_devstate_str(i)); + } + } + ast_cli(a->fd, "\n"); + return CLI_SUCCESS; +} +#endif + /*! \brief CLI support for listing chanvar's variables in a parseable way */ static char *handle_show_chanvar(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { @@ -6308,6 +6315,9 @@ static struct ast_cli_entry pbx_cli[] = { AST_CLI_DEFINE(handle_show_hints, "Show dialplan hints"), AST_CLI_DEFINE(handle_show_hint, "Show dialplan hint"), AST_CLI_DEFINE(handle_show_globals, "Show global dialplan variables"), +#ifdef AST_DEVMODE + AST_CLI_DEFINE(handle_show_device2extenstate, "Show expected exten state from multiple device states"), +#endif AST_CLI_DEFINE(handle_show_chanvar, "Show channel variables"), AST_CLI_DEFINE(handle_show_function, "Describe a specific dialplan function"), AST_CLI_DEFINE(handle_show_application, "Describe a specific dialplan application"), |