]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Add ability to check voicemail from multiple folders (bug #2561)
authorMark Spencer <markster@digium.com>
Sun, 3 Oct 2004 21:18:27 +0000 (21:18 +0000)
committerMark Spencer <markster@digium.com>
Sun, 3 Oct 2004 21:18:27 +0000 (21:18 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3905 65c4cc65-6c06-0410-ace0-fbb531ad65f3

app.c
apps/app_voicemail.c
channels/chan_iax2.c
channels/chan_mgcp.c
channels/chan_skinny.c
channels/chan_zap.c
include/asterisk/app.h
manager.c

diff --git a/app.c b/app.c
index 4428de3c8e348fc04200ddc78c7039cd37fa6270..0b277b5ceb41e697017d4f41a9721cd7d86406ea 100755 (executable)
--- a/app.c
+++ b/app.c
@@ -150,7 +150,7 @@ int ast_app_getvoice(struct ast_channel *c, char *dest, char *dstfmt, char *prom
        return 0;
 }
 
-int ast_app_has_voicemail(const char *mailbox)
+int ast_app_has_voicemail(const char *mailbox, const char *folder)
 {
        DIR *dir;
        struct dirent *de;
@@ -159,6 +159,8 @@ int ast_app_has_voicemail(const char *mailbox)
        char *mb, *cur;
        char *context;
        int ret;
+       if (!folder)
+               folder = "INBOX";
        /* If no mailbox, return immediately */
        if (ast_strlen_zero(mailbox))
                return 0;
@@ -168,7 +170,7 @@ int ast_app_has_voicemail(const char *mailbox)
                ret = 0;
                while((cur = strsep(&mb, ","))) {
                        if (!ast_strlen_zero(cur)) {
-                               if (ast_app_has_voicemail(cur))
+                               if (ast_app_has_voicemail(cur, folder))
                                        return 1; 
                        }
                }
@@ -181,7 +183,7 @@ int ast_app_has_voicemail(const char *mailbox)
                context++;
        } else
                context = "default";
-       snprintf(fn, sizeof(fn), "%s/voicemail/%s/%s/INBOX", (char *)ast_config_AST_SPOOL_DIR, context, tmp);
+       snprintf(fn, sizeof(fn), "%s/voicemail/%s/%s/%s", (char *)ast_config_AST_SPOOL_DIR, context, tmp, folder);
        dir = opendir(fn);
        if (!dir)
                return 0;
index 791978faca8a7847f243e94ef5c53f27867e4220..6ea59bf7c89ca960dc18311b62f41140761d1b30 100755 (executable)
@@ -2217,7 +2217,7 @@ static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu,
        }
 
        /* Leave voicemail for someone */
-       manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s@%s\r\nWaiting: %d\r\n", vmu->mailbox, vmu->context, ast_app_has_voicemail(ext_context));
+       manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s@%s\r\nWaiting: %d\r\n", vmu->mailbox, vmu->context, ast_app_has_voicemail(ext_context, NULL));
        run_externnotify(chan->context, ext_context);
        return 0;
 }
@@ -2343,7 +2343,7 @@ static int forward_message(struct ast_channel *chan, char *context, char *dir, i
                                        ast_destroy(mif); /* or here */
                                }
                                /* Leave voicemail for someone */
-                               manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s\r\nWaiting: %d\r\n", ext_context, ast_app_has_voicemail(ext_context));
+                               manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s\r\nWaiting: %d\r\n", ext_context, ast_app_has_voicemail(ext_context, NULL));
                                run_externnotify(chan->context, ext_context);
        
                                saved_messages++;
@@ -3730,7 +3730,7 @@ out:
                close_mailbox(&vms, vmu);
        if (valid) {
                snprintf(ext_context, sizeof(ext_context), "%s@%s", vms.username, vmu->context);
-               manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s\r\nWaiting: %d\r\n", ext_context, ast_app_has_voicemail(ext_context));
+               manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s\r\nWaiting: %d\r\n", ext_context, ast_app_has_voicemail(ext_context, NULL));
                run_externnotify(chan->context, ext_context);
        }
        if (vmu)
index b828719b814067d30b4014d0c5541bbd4a7e69d1..c495f53d9ff0c5087b45650748ecd1a41efc7c36 100755 (executable)
@@ -4475,7 +4475,7 @@ static int update_registry(char *name, struct sockaddr_in *sin, int callno, char
                                                old = 255;
                                        msgcount = (old << 8) | new;
                                } else {
-                                       msgcount = ast_app_has_voicemail(p->mailbox);
+                                       msgcount = ast_app_has_voicemail(p->mailbox, NULL);
                                        if (msgcount)
                                                msgcount = 65535;
                                }
index 309283b77bca1e4fb236641af5f33d5bf48935ed..e1e1e76c1d0389d66d33893c1add58fa92a592da 100755 (executable)
@@ -460,7 +460,7 @@ static int mgcp_reload(int fd, int argc, char *argv[]);
 
 static int has_voicemail(struct mgcp_endpoint *p)
 {
-       return ast_app_has_voicemail(p->mailbox);
+       return ast_app_has_voicemail(p->mailbox, NULL);
 }
 
 static int unalloc_sub(struct mgcp_subchannel *sub)
index 727d427e039ce33269fdb818ba801c4b79c8564b..3a37ea2135110311862adc7ab7480a392978b90e 100755 (executable)
@@ -1197,7 +1197,7 @@ static struct skinny_device *build_device(char *cat, struct ast_variable *v)
 
 static int has_voicemail(struct skinny_line *l)
 {
-       return ast_app_has_voicemail(l->mailbox);
+       return ast_app_has_voicemail(l->mailbox, NULL);
 }
 
 static int skinny_register(skinny_req *req, struct skinnysession *s)
index 8ef934a93d24e06fb67b5faad90de01c91bfc71a..a42edc7dd85b8b684715dfcc94ee4af3e083fe62 100755 (executable)
@@ -1404,7 +1404,7 @@ int send_cwcidspill(struct zt_pvt *p)
 static int has_voicemail(struct zt_pvt *p)
 {
 
-       return ast_app_has_voicemail(p->mailbox);
+       return ast_app_has_voicemail(p->mailbox, NULL);
 }
 
 static int send_callerid(struct zt_pvt *p)
@@ -5831,7 +5831,7 @@ static void *do_monitor(void *data)
 #if 0
                                                        printf("Channel %d has mailbox %s\n", last->channel, last->mailbox);
 #endif                                                 
-                                                       res = ast_app_has_voicemail(last->mailbox);
+                                                       res = ast_app_has_voicemail(last->mailbox, NULL);
                                                        if (last->msgstate != res) {
                                                                int x;
                                                                ast_log(LOG_DEBUG, "Message status for %s changed from %d to %d on %d\n", last->mailbox, last->msgstate, res, last->channel);
index 6b11c650b04d2f537e6dc262345a99f393f38007..dc77489f29580e25de2d1550171252a0bc69acb0 100755 (executable)
@@ -40,7 +40,7 @@ extern int ast_app_getdata_full(struct ast_channel *c, char *prompt, char *s, in
 int ast_app_getvoice(struct ast_channel *c, char *dest, char *dstfmt, char *prompt, int silence, int maxsec);
 
 //! Determine if a given mailbox has any voicemail
-extern int ast_app_has_voicemail(const char *mailbox);
+extern int ast_app_has_voicemail(const char *mailbox, const char *folder);
 
 //! Determine number of new/old messages in a mailbox
 extern int ast_app_messagecount(const char *mailbox, int *newmsgs, int *oldmsgs);
index 02f730f57b314c742ba4d555ee8f280d280c2ae0..29f46c86b80463b0e89e1b744963a8e9f1ad8c25 100755 (executable)
--- a/manager.c
+++ b/manager.c
@@ -981,7 +981,7 @@ static int action_mailboxstatus(struct mansession *s, struct message *m)
        }
         if (id && !ast_strlen_zero(id))
                 snprintf(idText,256,"ActionID: %s\r\n",id);
-       ret = ast_app_has_voicemail(mailbox);
+       ret = ast_app_has_voicemail(mailbox, NULL);
        ast_mutex_lock(&s->lock);
        ast_cli(s->fd, "Response: Success\r\n"
                                   "%s"