Add the ability for the "voicemail show users" CLI command to show users

configured in realtime.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@59414 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.0
Russell Bryant 18 years ago
parent 5d4e6a480a
commit e94dde199c

@ -6,8 +6,6 @@ Miscellaneous
------------- -------------
* Added the bindaddr option to gtalk.conf. * 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 * Argument support for Gosub application
* Ability to set process limits without restarting Asterisk * Ability to set process limits without restarting Asterisk
* SS7 support in chan_zap (via libss7 library) * 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() 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 function would allow you to have an external script set the weight for
each response. 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.

@ -7031,16 +7031,61 @@ static const char voicemail_show_zones_help[] =
"Usage: voicemail show zones\n" "Usage: voicemail show zones\n"
" Lists zone message formats\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 */ /*! \brief Show a list of voicemail users in the CLI */
static int handle_voicemail_show_users(int fd, int argc, char *argv[]) static int handle_voicemail_show_users(int fd, int argc, char *argv[])
{ {
struct ast_vm_user *vmu; struct ast_vm_user *vmu;
char *output_format = "%-10s %-5s %-25s %-10s %6s\n"; char *output_format = "%-10s %-5s %-25s %-10s %6s\n";
const char *context = NULL;
if ((argc < 3) || (argc > 5) || (argc == 4)) if ((argc < 3) || (argc > 5) || (argc == 4))
return RESULT_SHOWUSAGE; return RESULT_SHOWUSAGE;
if ((argc == 5) && strcmp(argv[3],"for")) if (argc == 5) {
if (strcmp(argv[3],"for"))
return RESULT_SHOWUSAGE; 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); AST_LIST_LOCK(&users);
if (AST_LIST_EMPTY(&users)) { if (AST_LIST_EMPTY(&users)) {
@ -7053,13 +7098,13 @@ static int handle_voicemail_show_users(int fd, int argc, char *argv[])
else { else {
int count = 0; int count = 0;
AST_LIST_TRAVERSE(&users, vmu, list) { AST_LIST_TRAVERSE(&users, vmu, list) {
if (!strcmp(argv[4],vmu->context)) if (!strcmp(context, vmu->context))
count++; count++;
} }
if (count) { if (count) {
ast_cli(fd, output_format, "Context", "Mbox", "User", "Zone", "NewMsg"); ast_cli(fd, output_format, "Context", "Mbox", "User", "Zone", "NewMsg");
} else { } 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); AST_LIST_UNLOCK(&users);
return RESULT_FAILURE; return RESULT_FAILURE;
} }
@ -7068,7 +7113,7 @@ static int handle_voicemail_show_users(int fd, int argc, char *argv[])
int newmsgs = 0, oldmsgs = 0; int newmsgs = 0, oldmsgs = 0;
char count[12], tmp[256] = ""; 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); snprintf(tmp, sizeof(tmp), "%s@%s", vmu->mailbox, ast_strlen_zero(vmu->context) ? "default" : vmu->context);
inboxcount(tmp, &newmsgs, &oldmsgs); inboxcount(tmp, &newmsgs, &oldmsgs);
snprintf(count,sizeof(count),"%d",newmsgs); snprintf(count,sizeof(count),"%d",newmsgs);

Loading…
Cancel
Save