diff options
Diffstat (limited to 'apps/app_voicemail.c')
-rw-r--r-- | apps/app_voicemail.c | 113 |
1 files changed, 82 insertions, 31 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 72e3e59c1..c4df4dcbb 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -63,7 +63,6 @@ </member> <member name="ODBC_STORAGE" displayname="Storage of Voicemail using ODBC"> <depend>generic_odbc</depend> - <depend>ltdl</depend> <conflict>IMAP_STORAGE</conflict> <conflict>FILE_STORAGE</conflict> <defaultenabled>no</defaultenabled> @@ -3657,7 +3656,7 @@ static void set_update(MAILSTREAM * stream) char buf[1024] = ""; if (!(user = get_user_by_mailbox(mailbox, buf, sizeof(buf))) || !(vms = get_vm_state_by_imapuser(user, 0))) { - if (user && option_debug > 2) + if (user && DEBUG_ATLEAST(3)) ast_log(AST_LOG_WARNING, "User %s mailbox not found for update.\n", user); return; } @@ -6089,22 +6088,33 @@ static int has_voicemail(const char *mailbox, const char *folder) return 0; } - +/*! + * \brief Check the given mailbox's message count. + * \param mailbox The @ delimited string for user@context. If no context is found, uses 'default' for the context. + * \param urgentmsgs urgent message count. + * \param newmsgs new message count. + * \param oldmsgs old message count pointer + * \return -1 if error occurred, 0 otherwise. + */ static int inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs) { char tmp[256]; char *context; /* If no mailbox, return immediately */ - if (ast_strlen_zero(mailbox)) + if (ast_strlen_zero(mailbox)) { return 0; + } - if (newmsgs) + if (newmsgs) { *newmsgs = 0; - if (oldmsgs) + } + if (oldmsgs) { *oldmsgs = 0; - if (urgentmsgs) + } + if (urgentmsgs) { *urgentmsgs = 0; + } if (strchr(mailbox, ',')) { int tmpnew, tmpold, tmpurgent; @@ -6114,15 +6124,18 @@ static int inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int * mb = tmp; while ((cur = strsep(&mb, ", "))) { if (!ast_strlen_zero(cur)) { - if (inboxcount2(cur, urgentmsgs ? &tmpurgent : NULL, newmsgs ? &tmpnew : NULL, oldmsgs ? &tmpold : NULL)) + if (inboxcount2(cur, urgentmsgs ? &tmpurgent : NULL, newmsgs ? &tmpnew : NULL, oldmsgs ? &tmpold : NULL)) { return -1; - else { - if (newmsgs) + } else { + if (newmsgs) { *newmsgs += tmpnew; - if (oldmsgs) + } + if (oldmsgs) { *oldmsgs += tmpold; - if (urgentmsgs) + } + if (urgentmsgs) { *urgentmsgs += tmpurgent; + } } } } @@ -6131,17 +6144,21 @@ static int inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int * ast_copy_string(tmp, mailbox, sizeof(tmp)); - if ((context = strchr(tmp, '@'))) + if ((context = strchr(tmp, '@'))) { *context++ = '\0'; - else + } else { context = "default"; + } - if (newmsgs) + if (newmsgs) { *newmsgs = __has_voicemail(context, tmp, "INBOX", 0); - if (oldmsgs) + } + if (oldmsgs) { *oldmsgs = __has_voicemail(context, tmp, "Old", 0); - if (urgentmsgs) + } + if (urgentmsgs) { *urgentmsgs = __has_voicemail(context, tmp, "Urgent", 0); + } return 0; } @@ -7854,7 +7871,8 @@ static int get_folder2(struct ast_channel *chan, char *fn, int start) ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", '#', '#'); return '#'; } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", res, res); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(res) ? res : '?', isprint(res) ? res : '?'); return res; } @@ -8017,7 +8035,8 @@ static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu, if (retries > 3) { cmd = '*'; /* Let's cancel this beast */ } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?'); } } @@ -8245,7 +8264,8 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st cmd = 't'; done = 1; } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?'); } } if (cmd < 0 || cmd == 't') @@ -8910,7 +8930,8 @@ static int play_message(struct ast_channel *chan, struct ast_vm_user *vmu, struc ast_log(AST_LOG_WARNING, "Playback of message %s failed\n", vms->fn); res = 0; } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", res, res); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(res) ? res : '?', isprint(res) ? res : '?'); } DISPOSE(vms->curdir, vms->curmsg); return res; @@ -10765,7 +10786,8 @@ static int vm_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct if (retries > 3) { cmd = 't'; } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?'); } } if (cmd == 't') @@ -10845,7 +10867,8 @@ static int vm_tempgreeting(struct ast_channel *chan, struct ast_vm_user *vmu, st if (retries > 3) { cmd = 't'; } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?'); } } DISPOSE(prefile, -1); @@ -11667,7 +11690,8 @@ static int vm_execmain(struct ast_channel *chan, const char *data) } else { cmd = vm_intro(chan, vmu, &vms); } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?'); vms.repeats = 0; vms.starting = 1; @@ -11687,7 +11711,8 @@ static int vm_execmain(struct ast_channel *chan, const char *data) adsi_folders(chan, 0, "Change to folder..."); cmd = get_folder2(chan, "vm-changeto", 0); - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?'); if (cmd == '#') { cmd = 0; } else if (cmd > 0) { @@ -11819,7 +11844,8 @@ static int vm_execmain(struct ast_channel *chan, const char *data) if (vms.repeats > 3) { cmd = 't'; } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?'); } } if (cmd == 't') { @@ -11997,7 +12023,8 @@ static int vm_execmain(struct ast_channel *chan, const char *data) if (useadsi) adsi_folders(chan, 1, "Save to folder..."); cmd = get_folder2(chan, "vm-savefolder", 1); - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?'); box = 0; /* Shut up compiler */ if (cmd == '#') { cmd = 0; @@ -13241,7 +13268,10 @@ static void stop_poll_thread(void) poll_thread = AST_PTHREADT_NULL; } -/*! \brief Append vmu info string into given astman with event_name. */ +/*! + * \brief Append vmu info string into given astman with event_name. + * \return 0 failed. 1 otherwise. +*/ static int append_vmu_info_astman( struct mansession *s, struct ast_vm_user *vmu, @@ -13251,14 +13281,33 @@ static int append_vmu_info_astman( { int new; int old; + char *mailbox; + int ret; if((s == NULL) || (vmu == NULL) || (event_name == NULL) || (actionid == NULL)) { ast_log(LOG_ERROR, "Wrong input parameter."); return 0; } + /* create mailbox string */ + if (!ast_strlen_zero(vmu->context)) { + ret = ast_asprintf(&mailbox, "%s@%s", vmu->mailbox, vmu->context); + } else { + ret = ast_asprintf(&mailbox, "%s", vmu->mailbox); + } + if (ret == -1) { + ast_log(LOG_ERROR, "Could not create mailbox string. err[%s]\n", strerror(errno)); + return 0; + } + /* get mailbox count */ - inboxcount(vmu->mailbox, &new, &old); + ret = inboxcount(mailbox, &new, &old); + ast_free(mailbox); + if (ret == -1) { + ast_log(LOG_ERROR, "Could not get mailbox count. user[%s], context[%s]\n", + vmu->mailbox ?: "", vmu->context ?: ""); + return 0; + } astman_append(s, "Event: %s\r\n" @@ -15141,7 +15190,8 @@ static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num, else cmd = 't'; } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?'); } if (retries >= 3) { return 0; @@ -15306,7 +15356,8 @@ static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, s res = 't'; } } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", res, res); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(res) ? res : '?', isprint(res) ? res : '?'); break; } |