Index: channels/chan_skinny.c =================================================================== --- channels/chan_skinny.c (revision 108392) +++ channels/chan_skinny.c (working copy) @@ -67,6 +67,7 @@ #include "asterisk/abstract_jb.h" #include "asterisk/threadstorage.h" #include "asterisk/devicestate.h" +#include "asterisk/event.h" /************************************* * Skinny/Asterisk Protocol Settings * @@ -1159,6 +1160,7 @@ int curtone; /* Current tone being played */ ast_group_t callgroup; ast_group_t pickupgroup; + struct ast_event_sub *mwi_event_sub; /* Event based MWI */ int callwaiting; int transfer; int threewaycalling; @@ -2209,15 +2211,44 @@ return 0; } +static void mwi_event_cb(const struct ast_event *event, void *userdata) +{ + /* This module does not handle MWI in an event-based manner. However, it + * subscribes to MWI for each mailbox that is configured so that the core + * knows that we care about it. Then, chan_zap will get the MWI from the + * event cache instead of checking the mailbox directly. */ +} + static int has_voicemail(struct skinny_line *l) { - return ast_app_has_voicemail(l->mailbox, NULL); + int new_msgs; + struct ast_event *event; + char *mailbox, *context; + + context = mailbox = ast_strdupa(l->mailbox); + strsep(&context, "@"); + if (ast_strlen_zero(context)) + context = "default"; + + event = ast_event_get_cached(AST_EVENT_MWI, + AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox, + AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context, + AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS, + AST_EVENT_IE_END); + + if (event) { + new_msgs = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS); + ast_event_destroy(event); + } else + new_msgs = ast_app_has_voicemail(l->mailbox, NULL); + + return new_msgs; + } static void do_housekeeping(struct skinnysession *s) { - int new; - int old; int device_lamp = 0; struct skinny_device *d = s->device; struct skinny_line *l;