--- asterisk-trunkgood/channels/chan_unistim.c 2012-03-21 12:21:49.000000000 -0700 +++ asterisk/channels/chan_unistim.c 2012-03-22 10:40:31.000000000 -0700 @@ -354,8 +354,6 @@ char exten[AST_MAX_EXTENSION]; /*! Extension where to start */ char cid_num[AST_MAX_EXTENSION]; /*! CallerID Number */ char mailbox[AST_MAX_EXTENSION]; /*! Mailbox for MWI */ - int lastmsgssent; /*! Used by MWI */ - time_t nextmsgcheck; /*! Used by MWI */ char musicclass[MAX_MUSICCLASS]; /*! MusicOnHold class */ ast_group_t callgroup; /*! Call group */ ast_group_t pickupgroup; /*! Pickup group */ @@ -417,6 +415,8 @@ int volume; /*!< Default volume */ int selected; /*!< softkey selected */ int mute; /*!< Mute mode */ + int lastmsgssent; /*! Used by MWI */ + time_t nextmsgcheck; /*! Used by MWI */ int nat; /*!< Used by the obscure ast_rtp_setnat */ enum autoprov_extn extension; /*!< See ifdef EXTENSION for valid values */ char extension_number[11]; /*!< Extension number entered by the user */ @@ -2926,6 +2926,7 @@ send_icon(TEXT_LINE0, FAV_ICON_NONE, pte); pte->device->missed_call = 0; send_led_update(pte, 0); + pte->device->lastmsgssent = -1; return; } @@ -3997,7 +3998,10 @@ return; } + pte->state = STATE_MAINPAGE; + send_led_update(pte, 0); + pte->device->lastmsgssent = -1; send_tone(pte, 0, 0); send_stop_timer(pte); /* case of holding call */ @@ -5515,15 +5519,15 @@ } else { /* Fall back on checking the mailbox directly */ new = ast_app_has_voicemail(peer->mailbox, "INBOX"); } - - peer->nextmsgcheck = tick + TIMER_MWI; + /* ast_verb(2, "MWI Status for mailbox %s is %d, lastmsgsent:%d\n",mailbox,new,peer->parent->lastmsgssent); */ + peer->parent->nextmsgcheck = tick + TIMER_MWI; /* Return now if it's the same thing we told them last time */ - if (new == peer->lastmsgssent) { + if ((peer->parent->session->state != STATE_MAINPAGE) || (new == peer->parent->lastmsgssent)) { return 0; } - peer->lastmsgssent = new; + peer->parent->lastmsgssent = new; send_led_update(peer->parent->session, (new > 0)); return 0; @@ -5677,7 +5681,7 @@ struct unistim_line *l; AST_LIST_LOCK(&cur->device->lines); AST_LIST_TRAVERSE(&cur->device->lines, l, list) { - if ((!ast_strlen_zero(l->mailbox)) && (tick >= l->nextmsgcheck)) { + if ((!ast_strlen_zero(l->mailbox)) && (tick >= l->parent->nextmsgcheck)) { DEBUG_TIMER("Checking mailbox for MWI\n"); unistim_send_mwi_to_peer(l, tick); break;