[asterisk-commits] kmoore: branch kmoore/channel_event_refactor r391559 - /team/kmoore/channel_e...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 12 15:36:24 CDT 2013


Author: kmoore
Date: Wed Jun 12 15:36:22 2013
New Revision: 391559

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=391559
Log:
Refactor DNDState and correct an event flag

Modified:
    team/kmoore/channel_event_refactor/channels/chan_dahdi.c
    team/kmoore/channel_event_refactor/channels/chan_dahdi.h
    team/kmoore/channel_event_refactor/channels/sig_analog.c

Modified: team/kmoore/channel_event_refactor/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/channel_event_refactor/channels/chan_dahdi.c?view=diff&rev=391559&r1=391558&r2=391559
==============================================================================
--- team/kmoore/channel_event_refactor/channels/chan_dahdi.c (original)
+++ team/kmoore/channel_event_refactor/channels/chan_dahdi.c Wed Jun 12 15:36:22 2013
@@ -314,6 +314,22 @@
 			<syntax>
 				<parameter name="Span">
 					<para>The span on which the alarm was cleared.</para>
+				</parameter>
+			</syntax>
+		</managerEventInstance>
+	</managerEvent>
+	<managerEvent language="en_US" name="DNDState">
+		<managerEventInstance class="EVENT_FLAG_SYSTEM">
+			<synopsis>Raised when the Do Not Disturb state is changed on a DAHDI channel.</synopsis>
+			<syntax>
+				<parameter name="Channel">
+					<para>The DAHDI channel on which DND status changed prefixed with <literal>DAHDI/</literal>.</para>
+				</parameter>
+				<parameter name="Status">
+					<enumlist>
+						<enum name="enabled"/>
+						<enum name="disabled"/>
+					</enumlist>
 				</parameter>
 			</syntax>
 		</managerEventInstance>
@@ -3987,7 +4003,7 @@
 	ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", channel);
 	json_object = ast_json_pack("{s: s, s: i, s: {s: i}}",
 		"type", "AlarmClear",
-		"class_type", EVENT_FLAG_CALL,
+		"class_type", EVENT_FLAG_SYSTEM,
 		"event",
 			"Channel", channel);
 
@@ -10153,6 +10169,40 @@
 	return 0;
 }
 
+void dahdi_publish_dnd_state(int channel, const char *status)
+{
+	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_json_payload *, payload, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_json *, json_object, NULL, ast_json_unref);
+	RAII_VAR(struct ast_str *, dahdichan, ast_str_create(32), ast_free);
+
+	ast_str_set(&dahdichan, 0, "DAHDI/%d", channel);
+
+	ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", channel);
+	json_object = ast_json_pack("{s: s, s: i, s: {s: s, s: s}}",
+		"type", "DNDState",
+		"class_type", EVENT_FLAG_SYSTEM,
+		"event",
+			"Channel", ast_str_buffer(dahdichan),
+			"Status", status);
+
+	if (!json_object) {
+		return;
+	}
+
+	payload = ast_json_payload_create(json_object);
+	if (!payload) {
+		return;
+	}
+
+	message = stasis_message_create(ast_manager_get_generic_type(), payload);
+	if (!message) {
+		return;
+	}
+
+	stasis_publish(ast_manager_get_topic(), message);
+}
+
 /*! \brief enable or disable the chan_dahdi Do-Not-Disturb mode for a DAHDI channel
  * \param dahdichan "Physical" DAHDI channel (e.g: DAHDI/5)
  * \param flag on 1 to enable, 0 to disable, -1 return dnd value
@@ -10177,19 +10227,7 @@
 	ast_verb(3, "%s DND on channel %d\n",
 			flag? "Enabled" : "Disabled",
 			dahdichan->channel);
-	/*** DOCUMENTATION
-		<managerEventInstance>
-			<synopsis>Raised when the Do Not Disturb state is changed on a DAHDI channel.</synopsis>
-			<syntax>
-				<parameter name="Status">
-					<enumlist>
-						<enum name="enabled"/>
-						<enum name="disabled"/>
-					</enumlist>
-				</parameter>
-			</syntax>
-		</managerEventInstance>
-	***/
+	dahdi_publish_dnd_state(dahdichan->channel, flag ? "enabled" : "disabled");
 	manager_event(EVENT_FLAG_SYSTEM, "DNDState",
 			"Channel: DAHDI/%d\r\n"
 			"Status: %s\r\n", dahdichan->channel,

Modified: team/kmoore/channel_event_refactor/channels/chan_dahdi.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/channel_event_refactor/channels/chan_dahdi.h?view=diff&rev=391559&r1=391558&r2=391559
==============================================================================
--- team/kmoore/channel_event_refactor/channels/chan_dahdi.h (original)
+++ team/kmoore/channel_event_refactor/channels/chan_dahdi.h Wed Jun 12 15:36:22 2013
@@ -27,4 +27,6 @@
 
 void dahdi_publish_channel_alarm_clear(int channel);
 
+void dahdi_publish_dnd_state(int channel, const char *status);
+
 #endif /* _CHAN_DAHDI_H */

Modified: team/kmoore/channel_event_refactor/channels/sig_analog.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/channel_event_refactor/channels/sig_analog.c?view=diff&rev=391559&r1=391558&r2=391559
==============================================================================
--- team/kmoore/channel_event_refactor/channels/sig_analog.c (original)
+++ team/kmoore/channel_event_refactor/channels/sig_analog.c Wed Jun 12 15:36:22 2013
@@ -3943,23 +3943,7 @@
 	ast_verb(3, "%s DND on channel %d\n",
 			flag ? "Enabled" : "Disabled",
 			p->channel);
-	/*** DOCUMENTATION
-		<managerEventInstance>
-			<synopsis>Raised when the Do Not Disturb state is changed on an Analog channel.</synopsis>
-			<syntax>
-				<parameter name="Status">
-					<enumlist>
-						<enum name="enabled"/>
-						<enum name="disabled"/>
-					</enumlist>
-				</parameter>
-			</syntax>
-		</managerEventInstance>
-	***/
-	manager_event(EVENT_FLAG_SYSTEM, "DNDState",
-			"Channel: DAHDI/%d\r\n"
-			"Status: %s\r\n", p->channel,
-			flag ? "enabled" : "disabled");
+	dahdi_publish_dnd_state(p->channel, flag ? "enabled" : "disabled");
 
 	return 0;
 }




More information about the asterisk-commits mailing list