mirror of
https://github.com/asterisk/asterisk.git
synced 2026-07-03 05:23:26 -07:00
Add ability to check voicemail from multiple folders (bug #2561)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3905 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
+2
-2
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user