[asterisk-commits] russell: trunk r59414 - in /trunk: CHANGES
apps/app_voicemail.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu Mar 29 13:53:13 MST 2007
Author: russell
Date: Thu Mar 29 15:53:12 2007
New Revision: 59414
URL: http://svn.digium.com/view/asterisk?view=rev&rev=59414
Log:
Add the ability for the "voicemail show users" CLI command to show users
configured in realtime.
Modified:
trunk/CHANGES
trunk/apps/app_voicemail.c
Modified: trunk/CHANGES
URL: http://svn.digium.com/view/asterisk/trunk/CHANGES?view=diff&rev=59414&r1=59413&r2=59414
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Thu Mar 29 15:53:12 2007
@@ -6,8 +6,6 @@
-------------
* 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 @@
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.
Modified: trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=59414&r1=59413&r2=59414
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Thu Mar 29 15:53:12 2007
@@ -7031,16 +7031,61 @@
"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 @@
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 @@
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);
More information about the asterisk-commits
mailing list