Fix MWI update so LED display correct voicemail state after phone usage. Also fixes few warnings.


			
			
				certified/11.2
			
			
		
Igor Goncharovskiy 13 years ago
parent d979399071
commit 4ca35e0907

@ -354,8 +354,6 @@ struct unistim_line {
char exten[AST_MAX_EXTENSION]; /*! Extension where to start */ char exten[AST_MAX_EXTENSION]; /*! Extension where to start */
char cid_num[AST_MAX_EXTENSION]; /*! CallerID Number */ char cid_num[AST_MAX_EXTENSION]; /*! CallerID Number */
char mailbox[AST_MAX_EXTENSION]; /*! Mailbox for MWI */ 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 */ char musicclass[MAX_MUSICCLASS]; /*! MusicOnHold class */
ast_group_t callgroup; /*! Call group */ ast_group_t callgroup; /*! Call group */
ast_group_t pickupgroup; /*! Pickup group */ ast_group_t pickupgroup; /*! Pickup group */
@ -417,6 +415,8 @@ static struct unistim_device {
int volume; /*!< Default volume */ int volume; /*!< Default volume */
int selected; /*!< softkey selected */ int selected; /*!< softkey selected */
int mute; /*!< Mute mode */ int mute; /*!< Mute mode */
int lastmsgssent; /*! Used by MWI */
time_t nextmsgcheck; /*! Used by MWI */
int nat; /*!< Used by the obscure ast_rtp_setnat */ int nat; /*!< Used by the obscure ast_rtp_setnat */
enum autoprov_extn extension; /*!< See ifdef EXTENSION for valid values */ enum autoprov_extn extension; /*!< See ifdef EXTENSION for valid values */
char extension_number[11]; /*!< Extension number entered by the user */ char extension_number[11]; /*!< Extension number entered by the user */
@ -780,7 +780,7 @@ static const char *ustmtext(const char *str, struct unistimsession *pte)
USTM_LANG_DIR, lang->lang_short); USTM_LANG_DIR, lang->lang_short);
f = fopen(tmp, "r"); f = fopen(tmp, "r");
if (!f) { if (!f) {
ast_log(LOG_ERROR, "There is no translation file for '%s'\n", pte->device->language); ast_log(LOG_WARNING, "There is no translation file for '%s'\n", lang->lang_short);
return str; return str;
} }
while (fgets(tmp, sizeof(tmp), f)) { while (fgets(tmp, sizeof(tmp), f)) {
@ -2924,6 +2924,7 @@ static void handle_dial_page(struct unistimsession *pte)
send_icon(TEXT_LINE0, FAV_ICON_NONE, pte); send_icon(TEXT_LINE0, FAV_ICON_NONE, pte);
pte->device->missed_call = 0; pte->device->missed_call = 0;
send_led_update(pte, 0); send_led_update(pte, 0);
pte->device->lastmsgssent = -1;
return; return;
} }
@ -3198,11 +3199,6 @@ static void handle_call_incoming(struct unistimsession *s)
ast_verb(0, "Handle Call Incoming for %s@%s\n", sub->parent->name, ast_verb(0, "Handle Call Incoming for %s@%s\n", sub->parent->name,
s->device->name); s->device->name);
} }
start_rtp(sub);
if (!sub->rtp) {
ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", sub->parent->name,
s->device->name);
}
if (sub->owner) { if (sub->owner) {
ast_queue_control(sub->owner, AST_CONTROL_ANSWER); ast_queue_control(sub->owner, AST_CONTROL_ANSWER);
} }
@ -3998,6 +3994,8 @@ static void show_main_page(struct unistimsession *pte)
} }
pte->state = STATE_MAINPAGE; pte->state = STATE_MAINPAGE;
send_led_update(pte, 0);
pte->device->lastmsgssent = -1;
send_tone(pte, 0, 0); send_tone(pte, 0, 0);
send_stop_timer(pte); /* case of holding call */ send_stop_timer(pte); /* case of holding call */
@ -5520,15 +5518,15 @@ static int unistim_send_mwi_to_peer(struct unistim_line *peer, unsigned int tick
} else { /* Fall back on checking the mailbox directly */ } else { /* Fall back on checking the mailbox directly */
new = ast_app_has_voicemail(peer->mailbox, "INBOX"); new = ast_app_has_voicemail(peer->mailbox, "INBOX");
} }
ast_debug(3, "MWI Status for mailbox %s is %d, lastmsgsent:%d\n",mailbox,new,peer->parent->lastmsgssent);
peer->nextmsgcheck = tick + TIMER_MWI; peer->parent->nextmsgcheck = tick + TIMER_MWI;
/* Return now if it's the same thing we told them last time */ /* 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; return 0;
} }
peer->lastmsgssent = new; peer->parent->lastmsgssent = new;
send_led_update(peer->parent->session, (new > 0)); send_led_update(peer->parent->session, (new > 0));
return 0; return 0;
@ -5682,7 +5680,7 @@ static void *do_monitor(void *data)
struct unistim_line *l; struct unistim_line *l;
AST_LIST_LOCK(&cur->device->lines); AST_LIST_LOCK(&cur->device->lines);
AST_LIST_TRAVERSE(&cur->device->lines, l, list) { 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"); DEBUG_TIMER("Checking mailbox for MWI\n");
unistim_send_mwi_to_peer(l, tick); unistim_send_mwi_to_peer(l, tick);
break; break;
@ -5818,6 +5816,12 @@ static struct ast_channel *unistim_request(const char *type, struct ast_format_c
if (unistimdebug) { if (unistimdebug) {
ast_verb(0, "unistim_request owner = %p\n", sub->owner); ast_verb(0, "unistim_request owner = %p\n", sub->owner);
} }
start_rtp(sub);
if (!sub->rtp) {
ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", sub->parent->name, d->name);
return NULL;
}
restart_monitor(); restart_monitor();
/* and finish */ /* and finish */

Loading…
Cancel
Save