[asterisk-commits] rmudgett: branch rmudgett/mwi r255115 - /team/rmudgett/mwi/channels/sig_pri.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 26 18:41:58 CDT 2010


Author: rmudgett
Date: Fri Mar 26 18:41:55 2010
New Revision: 255115

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=255115
Log:
Send the initial ISDN MWI indications from the event cache.

Modified:
    team/rmudgett/mwi/channels/sig_pri.c

Modified: team/rmudgett/mwi/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/mwi/channels/sig_pri.c?view=diff&rev=255115&r1=255114&r2=255115
==============================================================================
--- team/rmudgett/mwi/channels/sig_pri.c (original)
+++ team/rmudgett/mwi/channels/sig_pri.c Fri Mar 26 18:41:55 2010
@@ -4998,18 +4998,38 @@
 	}
 
 #if defined(HAVE_PRI_MWI)
-	/* Send the initial MWI indications for this span. */
+	/*
+	 * Send the initial MWI indications from the event cache for this span.
+	 *
+	 * If we were loaded after app_voicemail the event would already be in
+	 * the cache.  If we were loaded before app_voicemail the event would not
+	 * be in the cache yet and app_voicemail will send the event when it
+	 * gets loaded.
+	 */
 	for (i = 0; i < SIG_PRI_MAX_MWI_MAILBOXES; ++i) {
 		int num_messages;
+		struct ast_event *event;
 
 		if (!pri->mbox[i].sub) {
 			/* There are no more mailboxes on this span. */
 			break;
 		}
-		num_messages = ast_app_messagecount(pri->mbox[i].context, pri->mbox[i].number,
-			NULL);
+
+		event = ast_event_get_cached(AST_EVENT_MWI,
+			AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, pri->mbox[i].number,
+			AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, pri->mbox[i].context,
+			AST_EVENT_IE_END);
+		if (!event) {
+			/*
+			 * No cached event so we were loaded before app_voicemail
+			 * for this mailbox.
+			 */
+			continue;
+		}
+		num_messages = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
 		sig_pri_send_mwi_indication(pri, pri->mbox[i].number, pri->mbox[i].context,
 			num_messages);
+		ast_event_destroy(event);
 	}
 #endif	/* defined(HAVE_PRI_MWI) */
 




More information about the asterisk-commits mailing list