[asterisk-commits] pabelanger: branch pabelanger/gtalk_show_settings r292664 - /team/pabelanger/...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Oct 21 15:57:26 CDT 2010
Author: pabelanger
Date: Thu Oct 21 15:57:22 2010
New Revision: 292664
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=292664
Log:
Add new CLI command 'gtalk show settings'
Modified:
team/pabelanger/gtalk_show_settings/channels/chan_gtalk.c
Modified: team/pabelanger/gtalk_show_settings/channels/chan_gtalk.c
URL: http://svnview.digium.com/svn/asterisk/team/pabelanger/gtalk_show_settings/channels/chan_gtalk.c?view=diff&rev=292664&r1=292663&r2=292664
==============================================================================
--- team/pabelanger/gtalk_show_settings/channels/chan_gtalk.c (original)
+++ team/pabelanger/gtalk_show_settings/channels/chan_gtalk.c Thu Oct 21 15:57:22 2010
@@ -192,6 +192,7 @@
static int gtalk_update_stun(struct gtalk *client, struct gtalk_pvt *p);
/* static char *gtalk_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); */
static char *gtalk_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
+static char *gtalk_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
static int gtalk_update_externip(void);
/*! \brief PBX interface structure for channel registration */
@@ -228,9 +229,13 @@
static struct ast_cli_entry gtalk_cli[] = {
/* AST_CLI_DEFINE(gtalk_do_reload, "Reload GoogleTalk configuration"), XXX TODO reloads are not possible yet. */
AST_CLI_DEFINE(gtalk_show_channels, "Show GoogleTalk channels"),
+ AST_CLI_DEFINE(gtalk_show_settings, "Show GoogleTalk global settings"),
};
static char externip[16];
+static char default_context[AST_MAX_CONTEXT];
+static char default_parkinglot[AST_MAX_CONTEXT];
+static int default_allowguest = 1;
static struct sockaddr_in stunaddr; /*!< the stun server we get the externip from */
static struct gtalk_container gtalk_list;
@@ -1912,6 +1917,40 @@
#undef FORMAT
}
+/*! \brief List global settings for the GoogleTalk channel */
+static char *gtalk_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "gtalk show settings";
+ e->usage =
+ "Usage: gtalk show settings\n"
+ " Provides detailed list of the configuration on the GoogleTalk channel.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != 3) {
+ return CLI_SHOWUSAGE;
+ }
+
+#define FORMAT " %-25.25s %-15.15s\n"
+
+ ast_cli(a->fd, "\nGlobal Settings:\n");
+ ast_cli(a->fd, "----------------\n");
+ ast_cli(a->fd, FORMAT, "UDP Bindaddress:", ast_inet_ntoa(bindaddr.sin_addr));
+ ast_cli(a->fd, FORMAT, "Default Context:", default_context);
+ ast_cli(a->fd, FORMAT, "External IP:", externip);
+ ast_cli(a->fd, FORMAT, "Allow Guest:", AST_CLI_YESNO(default_allowguest));
+ ast_cli(a->fd, FORMAT, "Parking Lot:", default_parkinglot);
+ ast_cli(a->fd, FORMAT, "Stun Address:", ast_inet_ntoa(stunaddr.sin_addr));
+ ast_cli(a->fd, "\n----\n");
+
+ return CLI_SUCCESS;
+#undef FORMAT
+}
+
/*! \brief CLI command "gtalk reload"
* \todo XXX TODO make this work. */
#if 0
@@ -2022,9 +2061,6 @@
{
char *cat = NULL;
struct ast_config *cfg = NULL;
- char context[AST_MAX_CONTEXT];
- char parkinglot[AST_MAX_CONTEXT];
- int allowguest = 1;
struct ast_variable *var;
struct gtalk *member;
struct ast_codec_pref prefs;
@@ -2055,17 +2091,17 @@
continue;
if (!strcasecmp(var->name, "allowguest")) {
- allowguest = (ast_true(ast_variable_retrieve(cfg, "general", "allowguest"))) ? 1 : 0;
+ default_allowguest = (ast_true(ast_variable_retrieve(cfg, "general", "allowguest"))) ? 1 : 0;
} else if (!strcasecmp(var->name, "disallow")) {
ast_parse_allow_disallow(&prefs, &global_capability, var->value, 0);
} else if (!strcasecmp(var->name, "allow")) {
ast_parse_allow_disallow(&prefs, &global_capability, var->value, 1);
} else if (!strcasecmp(var->name, "context")) {
- ast_copy_string(context, var->value, sizeof(context));
+ ast_copy_string(default_context, var->value, sizeof(default_context));
} else if (!strcasecmp(var->name, "externip")) {
ast_copy_string(externip, var->value, sizeof(externip));
} else if (!strcasecmp(var->name, "parkinglot")) {
- ast_copy_string(parkinglot, var->value, sizeof(parkinglot));
+ ast_copy_string(default_parkinglot, var->value, sizeof(default_parkinglot));
} else if (!strcasecmp(var->name, "bindaddr")) {
if (!(hp = ast_gethostbyname(var->value, &ahp))) {
ast_log(LOG_WARNING, "Invalid address: %s\n", var->value);
@@ -2088,9 +2124,9 @@
if (!strcasecmp(cat, "guest")) {
ast_copy_string(member->name, "guest", sizeof(member->name));
ast_copy_string(member->user, "guest", sizeof(member->user));
- ast_copy_string(member->context, context, sizeof(member->context));
- ast_copy_string(member->parkinglot, parkinglot, sizeof(member->parkinglot));
- member->allowguest = allowguest;
+ ast_copy_string(member->context, default_context, sizeof(member->context));
+ ast_copy_string(member->parkinglot, default_parkinglot, sizeof(member->parkinglot));
+ member->allowguest = default_allowguest;
member->prefs = prefs;
while (var) {
if (!strcasecmp(var->name, "disallow")) {
@@ -2128,8 +2164,9 @@
}
} else {
ASTOBJ_UNLOCK(member);
- if (gtalk_create_member(cat, var, allowguest, prefs, context, member))
+ if (gtalk_create_member(cat, var, default_allowguest, prefs, default_context, member)) {
ASTOBJ_CONTAINER_LINK(>alk_list, member);
+ }
ASTOBJ_UNREF(member, gtalk_member_destroy);
}
}
More information about the asterisk-commits
mailing list