aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-03-29 20:53:12 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-03-29 20:53:12 +0000
commitb3d3b48310108d066117dbdf5ee9d34c264e22e7 (patch)
tree755537ffdf1eadc34ac51570dc899cdb9d443c20
parente6e52d12f35ad1053cd12598e73aca81fd61fa58 (diff)
Add the ability for the "voicemail show users" CLI command to show users
configured in realtime. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@59414 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--CHANGES9
-rw-r--r--apps/app_voicemail.c55
2 files changed, 57 insertions, 7 deletions
diff --git a/CHANGES b/CHANGES
index 3f62445d4..f0aeab7d5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -6,8 +6,6 @@ Miscellaneous
-------------
* Added the bindaddr option to gtalk.conf.
- * Added the ability to customize which sound files are used for some of the
- prompts within the Voicemail application by changing them in voicemail.conf
* Argument support for Gosub application
* Ability to set process limits without restarting Asterisk
* SS7 support in chan_zap (via libss7 library)
@@ -124,3 +122,10 @@ DUNDi changes
done using a global variable or a dialplan function. Using the SHELL()
function would allow you to have an external script set the weight for
each response.
+
+Voicemail Changes
+-----------------
+ * Added the ability to customize which sound files are used for some of the
+ prompts within the Voicemail application by changing them in voicemail.conf
+ * Added the ability for the "voicemail show users" CLI command to show users
+ configured by the dynamic realtime configuration method.
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index e665d29e1..b0f17079b 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -7031,16 +7031,61 @@ static const char voicemail_show_zones_help[] =
"Usage: voicemail show zones\n"
" Lists zone message formats\n";
+static int show_users_realtime(int fd, const char *context)
+{
+ struct ast_config *cfg;
+ const char *cat = NULL;
+
+ if (!(cfg = ast_load_realtime_multientry("voicemail",
+ "context", context, NULL))) {
+ return RESULT_FAILURE;
+ }
+
+ ast_cli(fd, "\n"
+ "=============================================================\n"
+ "=== Configured Voicemail Users ==============================\n"
+ "=============================================================\n"
+ "===\n");
+
+ while ((cat = ast_category_browse(cfg, cat))) {
+ struct ast_variable *var = NULL;
+ ast_cli(fd, "=== Mailbox ...\n"
+ "===\n");
+ for (var = ast_variable_browse(cfg, cat); var; var = var->next)
+ ast_cli(fd, "=== ==> %s: %s\n", var->name, var->value);
+ ast_cli(fd, "===\n"
+ "=== ---------------------------------------------------------\n"
+ "===\n");
+ }
+
+ ast_cli(fd, "=============================================================\n"
+ "\n");
+
+ return RESULT_SUCCESS;
+}
+
/*! \brief Show a list of voicemail users in the CLI */
static int handle_voicemail_show_users(int fd, int argc, char *argv[])
{
struct ast_vm_user *vmu;
char *output_format = "%-10s %-5s %-25s %-10s %6s\n";
+ const char *context = NULL;
if ((argc < 3) || (argc > 5) || (argc == 4))
return RESULT_SHOWUSAGE;
- if ((argc == 5) && strcmp(argv[3],"for"))
- return RESULT_SHOWUSAGE;
+ if (argc == 5) {
+ if (strcmp(argv[3],"for"))
+ return RESULT_SHOWUSAGE;
+ context = argv[4];
+ }
+
+ if (ast_check_realtime("voicemail")) {
+ if (!context) {
+ ast_cli(fd, "You must specify a specific context to show users from realtime!\n");
+ return RESULT_SHOWUSAGE;
+ }
+ return show_users_realtime(fd, context);
+ }
AST_LIST_LOCK(&users);
if (AST_LIST_EMPTY(&users)) {
@@ -7053,13 +7098,13 @@ static int handle_voicemail_show_users(int fd, int argc, char *argv[])
else {
int count = 0;
AST_LIST_TRAVERSE(&users, vmu, list) {
- if (!strcmp(argv[4],vmu->context))
+ if (!strcmp(context, vmu->context))
count++;
}
if (count) {
ast_cli(fd, output_format, "Context", "Mbox", "User", "Zone", "NewMsg");
} else {
- ast_cli(fd, "No such voicemail context \"%s\"\n", argv[4]);
+ ast_cli(fd, "No such voicemail context \"%s\"\n", context);
AST_LIST_UNLOCK(&users);
return RESULT_FAILURE;
}
@@ -7068,7 +7113,7 @@ static int handle_voicemail_show_users(int fd, int argc, char *argv[])
int newmsgs = 0, oldmsgs = 0;
char count[12], tmp[256] = "";
- if ((argc == 3) || ((argc == 5) && !strcmp(argv[4],vmu->context))) {
+ if ((argc == 3) || ((argc == 5) && !strcmp(context, vmu->context))) {
snprintf(tmp, sizeof(tmp), "%s@%s", vmu->mailbox, ast_strlen_zero(vmu->context) ? "default" : vmu->context);
inboxcount(tmp, &newmsgs, &oldmsgs);
snprintf(count,sizeof(count),"%d",newmsgs);