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;
char *mb, *cur;
char *context;
int ret;
+ if (!folder)
+ folder = "INBOX";
/* If no mailbox, return immediately */
if (ast_strlen_zero(mailbox))
return 0;
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;
}
}
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;
}
/* 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;
}
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++;
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)
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;
}
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)
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)
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)
#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);
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);
}
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"