Add mailbox count to mangement interface
authorMark Spencer <markster@digium.com>
Sat, 21 Jun 2003 20:05:16 +0000 (20:05 +0000)
committerMark Spencer <markster@digium.com>
Sat, 21 Jun 2003 20:05:16 +0000 (20:05 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1111 65c4cc65-6c06-0410-ace0-fbb531ad65f3

manager.c

index fbb678f..19cc345 100755 (executable)
--- a/manager.c
+++ b/manager.c
@@ -454,6 +454,25 @@ static int action_mailboxstatus(struct mansession *s, struct message *m)
        return 0;
 }
 
+static int action_mailboxcount(struct mansession *s, struct message *m)
+{
+       char *mailbox = astman_get_header(m, "Mailbox");
+       int newmsgs = 0, oldmsgs = 0;
+       if (!mailbox || !strlen(mailbox)) {
+               astman_send_error(s, "Mailbox not specified");
+               return 0;
+       }
+       ast_app_messagecount(mailbox, &newmsgs, &oldmsgs);
+       ast_cli(s->fd, "Response: Success\r\n"
+                                  "Message: Mailbox Message Count\r\n"
+                                  "Mailbox: %s\r\n"
+                                  "NewMessages: %d\r\n"
+                                  "OldMessages: %d\r\n" 
+                                  "\r\n",
+                                   mailbox, newmsgs, oldmsgs);
+       return 0;
+}
+
 static int action_extensionstate(struct mansession *s, struct message *m)
 {
        char *exten = astman_get_header(m, "Exten");
@@ -796,6 +815,7 @@ int init_manager(void)
                ast_manager_register( "Command", EVENT_FLAG_COMMAND, action_command, "Execute Command" );
                ast_manager_register( "ExtensionState", EVENT_FLAG_CALL, action_extensionstate, "Check Extension Status" );
                ast_manager_register( "AbsoluteTimeout", EVENT_FLAG_CALL, action_timeout, "Set Absolute Timeout" );
+               ast_manager_register( "MailboxCount", EVENT_FLAG_CALL, action_mailboxcount, "Check Mailbox Message Count" );
 
                ast_cli_register(&show_mancmds_cli);
                ast_cli_register(&show_manconn_cli);