[asterisk-commits] russell: branch russell/console_devices r99224 - /team/russell/console_device...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jan 22 10:39:04 CST 2008
Author: russell
Date: Sat Jan 19 23:06:46 2008
New Revision: 99224
URL: http://svn.digium.com/view/asterisk?view=rev&rev=99224
Log:
Add a CLI command to list all currently configure devices. Also, fix a few little bugs.
Modified:
team/russell/console_devices/channels/chan_console.c
Change Statistics:
team/russell/console_devices/channels/chan_console.c | 73 +++++++++-
1 file changed, 67 insertions(+), 6 deletions(-)
Modified: team/russell/console_devices/channels/chan_console.c
URL: http://svn.digium.com/view/asterisk/team/russell/console_devices/channels/chan_console.c?view=diff&rev=99224&r1=99223&r2=99224
==============================================================================
--- team/russell/console_devices/channels/chan_console.c (original)
+++ team/russell/console_devices/channels/chan_console.c Sat Jan 19 23:06:46 2008
@@ -955,6 +955,62 @@
return CLI_SUCCESS;
}
+static char *cli_list_devices(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ struct ao2_iterator i;
+ struct console_pvt *pvt;
+
+ if (cmd == CLI_INIT) {
+ e->command = "console list devices";
+ e->usage =
+ "Usage: console list devices\n"
+ " List all configured devices.\n";
+ return NULL;
+ } else if (cmd == CLI_GENERATE)
+ return NULL;
+
+ if (a->argc != e->args)
+ return CLI_SHOWUSAGE;
+
+ ast_cli(a->fd, "\n"
+ "=============================================================\n"
+ "=== Configured Devices ======================================\n"
+ "=============================================================\n"
+ "===\n");
+
+ i = ao2_iterator_init(pvts, 0);
+ while ((pvt = ao2_iterator_next(&i))) {
+ console_pvt_lock(pvt);
+
+ ast_cli(a->fd, "=== ---------------------------------------------------------\n"
+ "=== Device Name: %s\n"
+ "=== ---> Active: %s\n"
+ "=== ---> Input Device: %s\n"
+ "=== ---> Output Device: %s\n"
+ "=== ---> Context: %s\n"
+ "=== ---> Extension: %s\n"
+ "=== ---> CallerID Num: %s\n"
+ "=== ---> CallerID Name: %s\n"
+ "=== ---> MOH Interpret: %s\n"
+ "=== ---> Language: %s\n"
+ "=== ---> Muted: %s\n"
+ "=== ---> Auto-Answer: %s\n"
+ "=== ---> Override Context: %s\n"
+ "=== ---------------------------------------------------------\n===\n",
+ pvt->name, (pvt == active_pvt) ? "Yes" : "No",
+ pvt->input_device, pvt->output_device, pvt->context,
+ pvt->exten, pvt->cid_num, pvt->cid_name, pvt->mohinterpret,
+ pvt->language, pvt->muted ? "Yes" : "No", pvt->autoanswer ? "Yes" : "No",
+ pvt->overridecontext ? "Yes" : "No");
+
+ console_pvt_unlock(pvt);
+ unref_pvt(pvt);
+ }
+
+ ast_cli(a->fd, "=============================================================\n\n");
+
+ return CLI_SUCCESS;
+}
/*!
* \brief answer command from the console
*/
@@ -1070,6 +1126,7 @@
AST_CLI_DEFINE(cli_console_flash, "Send a flash to the connected party"),
AST_CLI_DEFINE(cli_console_autoanswer, "Turn autoanswer on or off"),
AST_CLI_DEFINE(cli_list_available, "List available devices"),
+ AST_CLI_DEFINE(cli_list_devices, "List configured devices"),
};
/*!
@@ -1169,13 +1226,15 @@
ast_string_field_free_memory(pvt);
}
-static int init_pvt(struct console_pvt *pvt)
+static int init_pvt(struct console_pvt *pvt, const char *name)
{
pvt->thread = AST_PTHREADT_NULL;
if (ast_string_field_init(pvt, 32))
return -1;
-
+
+ ast_string_field_set(pvt, name, S_OR(name, ""));
+
return 0;
}
@@ -1192,7 +1251,7 @@
} else {
if (!(pvt = ao2_alloc(sizeof(*pvt), pvt_destructor)))
return;
- init_pvt(pvt);
+ init_pvt(pvt, name);
set_pvt_defaults(pvt);
new = 1;
}
@@ -1262,8 +1321,10 @@
store_config_core(&globals, v->name, v->value);
ast_mutex_unlock(&globals_lock);
- while ((context = ast_category_browse(cfg, context)))
- build_device(cfg, context);
+ while ((context = ast_category_browse(cfg, context))) {
+ if (strcasecmp(context, "general"))
+ build_device(cfg, context);
+ }
ast_config_destroy(cfg);
@@ -1320,7 +1381,7 @@
{
PaError res;
- init_pvt(&globals);
+ init_pvt(&globals, NULL);
if (!(pvts = ao2_container_alloc(NUM_PVT_BUCKETS, pvt_hash_cb, pvt_cmp_cb)))
goto return_error;
More information about the asterisk-commits
mailing list