aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-10-03 21:18:27 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-10-03 21:18:27 +0000
commitf0aa373808ed959a85ef4a4ec62e92e45c578675 (patch)
tree520372d4f6c2d6b36c53eb276f151684e18f660a
parent38d817b90e611437bf28742ef0f234429bf2882a (diff)
Add ability to check voicemail from multiple folders (bug #2561)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3905 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xapp.c8
-rwxr-xr-xapps/app_voicemail.c6
-rwxr-xr-xchannels/chan_iax2.c2
-rwxr-xr-xchannels/chan_mgcp.c2
-rwxr-xr-xchannels/chan_skinny.c2
-rwxr-xr-xchannels/chan_zap.c4
-rwxr-xr-xinclude/asterisk/app.h2
-rwxr-xr-xmanager.c2
8 files changed, 15 insertions, 13 deletions
diff --git a/app.c b/app.c
index 4428de3c8..0b277b5ce 100755
--- 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;
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 791978fac..6ea59bf7c 100755
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -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)
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index b828719b8..c495f53d9 100755
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -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;
}
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 309283b77..e1e1e76c1 100755
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -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)
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index 727d427e0..3a37ea213 100755
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -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)
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index 8ef934a93..a42edc7dd 100755
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -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);
diff --git a/include/asterisk/app.h b/include/asterisk/app.h
index 6b11c650b..dc77489f2 100755
--- a/include/asterisk/app.h
+++ b/include/asterisk/app.h
@@ -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);
diff --git a/manager.c b/manager.c
index 02f730f57..29f46c86b 100755
--- 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"