[svn-commits] rmudgett: branch rmudgett/mwi r255116 - /team/rmudgett/mwi/channels/sig_pri.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Mar 26 19:22:31 CDT 2010


Author: rmudgett
Date: Fri Mar 26 19:22:28 2010
New Revision: 255116

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=255116
Log:
Extract the initial MWI indication code into its own routine.

It may be desired in the future to periodically refresh the MWI
indications in case phones are connected after asterisk is started.  This
change makes that feature easier to implement.  Just call the function
when it it time to refresh the MWI indications.

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=255116&r1=255115&r2=255116
==============================================================================
--- team/rmudgett/mwi/channels/sig_pri.c (original)
+++ team/rmudgett/mwi/channels/sig_pri.c Fri Mar 26 19:22:28 2010
@@ -4770,6 +4770,7 @@
 	return 1;
 }
 
+#if defined(HAVE_PRI_MWI)
 /*!
  * \internal
  * \brief Send a MWI indication to the given span.
@@ -4799,7 +4800,9 @@
 	pri_mwi_indicate(pri->pri, &mailbox, 1 /* speech */, num_messages, NULL, NULL, -1, 0);
 	ast_mutex_unlock(&pri->lock);
 }
-
+#endif	/* defined(HAVE_PRI_MWI) */
+
+#if defined(HAVE_PRI_MWI)
 /*!
  * \internal
  * \brief MWI subscription event callback.
@@ -4828,6 +4831,45 @@
 	num_messages = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
 	sig_pri_send_mwi_indication(pri, mbox_number, mbox_context, num_messages);
 }
+#endif	/* defined(HAVE_PRI_MWI) */
+
+#if defined(HAVE_PRI_MWI)
+/*!
+ * \internal
+ * \brief Send update MWI indications from the event cache.
+ * \since 1.8
+ *
+ * \param pri Asterisk D channel control structure.
+ *
+ * \return Nothing
+ */
+static void sig_pri_mwi_cache_update(struct sig_pri_pri *pri)
+{
+	int idx;
+	int num_messages;
+	struct ast_event *event;
+
+	for (idx = 0; idx < SIG_PRI_MAX_MWI_MAILBOXES; ++idx) {
+		if (!pri->mbox[idx].sub) {
+			/* There are no more mailboxes on this span. */
+			break;
+		}
+
+		event = ast_event_get_cached(AST_EVENT_MWI,
+			AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, pri->mbox[idx].number,
+			AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, pri->mbox[idx].context,
+			AST_EVENT_IE_END);
+		if (!event) {
+			/* No cached event for this mailbox. */
+			continue;
+		}
+		num_messages = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
+		sig_pri_send_mwi_indication(pri, pri->mbox[idx].number, pri->mbox[idx].context,
+			num_messages);
+		ast_event_destroy(event);
+	}
+}
+#endif	/* defined(HAVE_PRI_MWI) */
 
 /*!
  * \brief Stop PRI span.
@@ -5006,31 +5048,7 @@
 	 * 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;
-		}
-
-		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);
-	}
+	sig_pri_mwi_cache_update(pri);
 #endif	/* defined(HAVE_PRI_MWI) */
 
 	return 0;




More information about the svn-commits mailing list