[asterisk-commits] igorg: trunk r368688 - /trunk/channels/chan_unistim.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 8 03:32:56 CDT 2012


Author: igorg
Date: Fri Jun  8 03:32:49 2012
New Revision: 368688

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=368688
Log:

Fix MWI update so LED display correct voicemail state after phone usage. Also fixes few warnings.
(closes issue #19675)
 Reported by: dbohling
 Patches: 
       fixmwi.patch uploaded by dbohling (license 6378)


Modified:
    trunk/channels/chan_unistim.c

Modified: trunk/channels/chan_unistim.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_unistim.c?view=diff&rev=368688&r1=368687&r2=368688
==============================================================================
--- trunk/channels/chan_unistim.c (original)
+++ trunk/channels/chan_unistim.c Fri Jun  8 03:32:49 2012
@@ -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 */
@@ -415,8 +413,10 @@
 	int output;				     /*!< Handset, headphone or speaker */
 	int previous_output;	    /*!< Previous output */
 	int volume;				     /*!< Default volume */
-        int selected;                           /*!< softkey selected */
+	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 */
@@ -780,7 +780,7 @@
 			 USTM_LANG_DIR, lang->lang_short);
 		f = fopen(tmp, "r");
 		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;
 		}
 		while (fgets(tmp, sizeof(tmp), f)) {
@@ -2924,6 +2924,7 @@
 	send_icon(TEXT_LINE0, FAV_ICON_NONE, pte);
 	pte->device->missed_call = 0;
 	send_led_update(pte, 0);
+	pte->device->lastmsgssent = -1;
 	return;
 }
 
@@ -3197,11 +3198,6 @@
 	if (unistimdebug) {
 		ast_verb(0, "Handle Call Incoming for %s@%s\n", sub->parent->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) {
 		ast_queue_control(sub->owner, AST_CONTROL_ANSWER);
@@ -3998,6 +3994,8 @@
 	}
 
 	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 */
@@ -5520,15 +5518,15 @@
 	} else { /* Fall back on checking the mailbox directly */
 		new = ast_app_has_voicemail(peer->mailbox, "INBOX");
 	}
-
-	peer->nextmsgcheck = tick + TIMER_MWI;
+	ast_debug(3, "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;
@@ -5682,7 +5680,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;
@@ -5818,6 +5816,12 @@
 	if (unistimdebug) {
 		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();
 
 	/* and finish */




More information about the asterisk-commits mailing list