--- apps/app_voicemail.c 1 Jul 2004 21:58:50 -0000 1.126 +++ apps/app_voicemail.c 6 Jul 2004 20:15:51 -0000 @@ -1660,16 +1660,24 @@ notify_new_message(chan, recip, recipmsgnum, duration, fmt, chan->callerid); } -static void run_externnotify(char *context, char *extension, int numvoicemails) +static void run_externnotify(char *context, char *extension) { char arguments[255]; + int newvoicemails = 0, oldvoicemails = 0; + + if (ast_app_messagecount(extension, &newvoicemails, &oldvoicemails)) { + ast_log(LOG_ERROR, "Problem in calculating number of voicemail messages available for extension %s\n", extension); + return; + } if(externnotify[0]) { strncpy(arguments, externnotify, sizeof(arguments)); - snprintf(arguments, sizeof(arguments)-1, "%s %s %s %d&", externnotify, context, extension, numvoicemails); + snprintf(arguments, sizeof(arguments)-1, "%s %s %s %d&", externnotify, context, extension, newvoicemails); ast_log(LOG_DEBUG,"Executing %s\n", arguments); ast_safe_system(arguments); + return; } + return; } @@ -2582,7 +2592,7 @@ /* 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)); - run_externnotify(chan->context, ext_context, ast_app_has_voicemail(ext_context)); + run_externnotify(chan->context, ext_context); return 0; } @@ -2703,7 +2713,7 @@ } /* 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)); - run_externnotify(chan->context, ext_context, ast_app_has_voicemail(ext_context)); + run_externnotify(chan->context, ext_context); saved_messages++; vmfree = vmtmp; @@ -3873,7 +3883,7 @@ 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)); - run_externnotify(chan->context, ext_context, ast_app_has_voicemail(ext_context)); + run_externnotify(chan->context, ext_context); } LOCAL_USER_REMOVE(u);