[svn-commits] qwell: branch qwell/queue_events r390857 - in /team/qwell/queue_events: ./ ap...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jun 7 11:19:23 CDT 2013


Author: qwell
Date: Fri Jun  7 11:19:20 2013
New Revision: 390857

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390857
Log:
Multiple revisions 390848-390849

........
  r390848 | jrose | 2013-06-07 10:54:26 -0500 (Fri, 07 Jun 2013) | 6 lines
  
  app_meetme: Refactor manager events to use stasis
  
  (closes issue ASTERISK-21467)
  Reported by: Matt Jordan
  Review: https://reviewboard.asterisk.org/r/2564/
........
  r390849 | jrose | 2013-06-07 11:07:18 -0500 (Fri, 07 Jun 2013) | 6 lines
  
  res_parking: Automatically generate extensions, hints, etc.
  
  (closes issue ASTERISK-21645)
  Reported by: Matt Jordan
  Review: https://reviewboard.asterisk.org/r/2545/
........

Merged revisions 390848-390849 from http://svn.asterisk.org/svn/asterisk/trunk

Modified:
    team/qwell/queue_events/   (props changed)
    team/qwell/queue_events/CHANGES
    team/qwell/queue_events/apps/app_meetme.c
    team/qwell/queue_events/apps/confbridge/confbridge_manager.c
    team/qwell/queue_events/include/asterisk/manager.h
    team/qwell/queue_events/include/asterisk/pbx.h
    team/qwell/queue_events/main/features.c
    team/qwell/queue_events/main/manager.c
    team/qwell/queue_events/main/pbx.c
    team/qwell/queue_events/res/parking/parking_bridge.c
    team/qwell/queue_events/res/parking/parking_bridge_features.c
    team/qwell/queue_events/res/parking/parking_controller.c
    team/qwell/queue_events/res/parking/res_parking.h
    team/qwell/queue_events/res/res_parking.c

Propchange: team/qwell/queue_events/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Jun  7 11:19:20 2013
@@ -1,1 +1,1 @@
-/trunk:1-390845
+/trunk:1-390855

Modified: team/qwell/queue_events/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/CHANGES?view=diff&rev=390857&r1=390856&r2=390857
==============================================================================
--- team/qwell/queue_events/CHANGES (original)
+++ team/qwell/queue_events/CHANGES Fri Jun  7 11:19:20 2013
@@ -193,6 +193,11 @@
    The preferred way to configure parking is now through res_parking.conf while
    configuration through features.conf is not currently supported.
 
+ * res_parking uses the configuration framework. If an invalid configuration is
+   supplied, res_parking will fail to load or fail to reload. Previously parking
+   lots that were misconfigured would generally be accepted with certain
+   configuration problems leading to individual disabled parking lots.
+
  * Parked calls are now placed in bridges. This is a largely architectural change,
    but it could have some implications in allowing for new parked call retrieval
    methods and the contents of parking lots will be visible though certain bridge
@@ -231,6 +236,11 @@
  * ParkAndAnnounce will no longer go to the next position in dialplan on timeout
    by default. Instead, it will follow the timeout rules of the parking lot. The
    old behavior can be reproduced by using the 'c' option.
+
+ * Added a channel variable PARKER_FLAT which stores the name of the extension
+   that would be used to come back to if comebacktoorigin was set to use. This can
+   be useful when comebacktoorigin is off if you still want to use the extensions
+   in the park-dial context that are generated to redial the parker on timeout.
 
 Queue
 -------------------

Modified: team/qwell/queue_events/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/apps/app_meetme.c?view=diff&rev=390857&r1=390856&r2=390857
==============================================================================
--- team/qwell/queue_events/apps/app_meetme.c (original)
+++ team/qwell/queue_events/apps/app_meetme.c Fri Jun  7 11:19:20 2013
@@ -73,6 +73,10 @@
 #include "asterisk/paths.h"
 #include "asterisk/data.h"
 #include "asterisk/test.h"
+#include "asterisk/stasis.h"
+#include "asterisk/stasis_channels.h"
+#include "asterisk/stasis_message_router.h"
+#include "asterisk/json.h"
 
 #include "enter.h"
 #include "leave.h"
@@ -553,6 +557,88 @@
 				MeetmeListRoomsComplete.</para>
 		</description>
 	</manager>
+	<managerEvent language="en_US" name="MeetmeJoin">
+		<managerEventInstance class="EVENT_FLAG_CALL">
+			<synopsis>Raised when a user joins a MeetMe conference.</synopsis>
+			<syntax>
+				<parameter name="Meetme">
+					<para>The identifier for the MeetMe conference.</para>
+				</parameter>
+				<parameter name="Usernum">
+					<para>The identifier of the MeetMe user who joined.</para>
+				</parameter>
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+			</syntax>
+			<see-also>
+				<ref type="managerEvent">MeetmeLeave</ref>
+				<ref type="application">MeetMe</ref>
+			</see-also>
+		</managerEventInstance>
+	</managerEvent>
+	<managerEvent language="en_US" name="MeetmeLeave">
+		<managerEventInstance class="EVENT_FLAG_CALL">
+			<synopsis>Raised when a user leaves a MeetMe conference.</synopsis>
+			<syntax>
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='MeetmeJoin']/managerEventInstance/syntax/parameter)" />
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+				<parameter name="Duration">
+					<para>The length of time in seconds that the Meetme user was in the conference.</para>
+				</parameter>
+			</syntax>
+			<see-also>
+				<ref type="managerEvent">MeetmeJoin</ref>
+			</see-also>
+		</managerEventInstance>
+	</managerEvent>
+	<managerEvent language="en_US" name="MeetmeEnd">
+		<managerEventInstance class="EVENT_FLAG_CALL">
+			<synopsis>Raised when a MeetMe conference ends.</synopsis>
+			<syntax>
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='MeetmeJoin']/managerEventInstance/syntax/parameter[@name='Meetme'])" />
+			</syntax>
+			<see-also>
+				<ref type="managerEvent">MeetmeJoin</ref>
+			</see-also>
+		</managerEventInstance>
+	</managerEvent>
+	<managerEvent language="en_US" name="MeetmeTalkRequest">
+		<managerEventInstance class="EVENT_FLAG_CALL">
+			<synopsis>Raised when a MeetMe user has started talking.</synopsis>
+			<syntax>
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='MeetmeJoin']/managerEventInstance/syntax/parameter)" />
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+				<parameter name="Duration">
+					<para>The length of time in seconds that the Meetme user has been in the conference at the time of this event.</para>
+				</parameter>
+				<parameter name="Status">
+					<enumlist>
+						<enum name="on"/>
+						<enum name="off"/>
+					</enumlist>
+				</parameter>
+			</syntax>
+		</managerEventInstance>
+	</managerEvent>
+	<managerEvent language="en_US" name="MeetmeTalking">
+		<managerEventInstance class="EVENT_FLAG_CALL">
+			<synopsis>Raised when a MeetMe user begins or ends talking.</synopsis>
+			<syntax>
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='MeetmeJoin']/managerEventInstance/syntax/parameter)" />
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='MeetmeTalkRequest']/managerEventInstance/syntax/parameter)" />
+			</syntax>
+		</managerEventInstance>
+	</managerEvent>
+	<managerEvent language="en_US" name="MeetmeMute">
+		<managerEventInstance class="EVENT_FLAG_CALL">
+			<synopsis>Raised when a MeetMe user is muted or unmuted.</synopsis>
+			<syntax>
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='MeetmeJoin']/managerEventInstance/syntax/parameter)" />
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='MeetmeTalkRequest']/managerEventInstance/syntax/parameter)" />
+			</syntax>
+		</managerEventInstance>
+	</managerEvent>
  ***/
 
 #define CONFIG_FILE_NAME	"meetme.conf"
@@ -1031,6 +1117,330 @@
 	15,
 };
 
+/*!
+ * \internal
+ * \brief accessor for join message type
+ * \since 12.0.0
+ *
+ * \retval pointer to the stasis message type
+ * \retval NULL if not initialized
+ */
+static struct stasis_message_type *meetme_join_type(void);
+
+/*!
+ * \internal
+ * \brief accessor for leave message type
+ * \since 12.0.0
+ *
+ * \retval pointer to the stasis message type
+ * \retval NULL if not initialized
+ */
+static struct stasis_message_type *meetme_leave_type(void);
+
+/*!
+ * \internal
+ * \brief accessor for end message type
+ * \since 12.0.0
+ *
+ * \retval pointer to the stasis message type
+ * \retval NULL if not initialized
+ */
+static struct stasis_message_type *meetme_end_type(void);
+
+/*!
+ * \internal
+ * \brief accessor for mute message type
+ * \since 12.0.0
+ *
+ * \retval pointer to the stasis message type
+ * \retval NULL if not initialized
+ */
+static struct stasis_message_type *meetme_mute_type(void);
+
+/*!
+ * \internal
+ * \brief accessor for talking message type
+ * \since 12.0.0
+ *
+ * \retval pointer to the stasis message type
+ * \retval NULL if not initialized
+ */
+static struct stasis_message_type *meetme_talking_type(void);
+
+/*!
+ * \internal
+ * \brief accessor for talk request message type
+ * \since 12.0.0
+ *
+ * \retval pointer to the stasis message type
+ * \retval NULL if not initialized
+ */
+static struct stasis_message_type *meetme_talk_request_type(void);
+
+/* Routes the various meetme message types to the meetme stasis callback function to turn them into events */
+static struct stasis_message_router *meetme_event_message_router;
+
+STASIS_MESSAGE_TYPE_DEFN(meetme_join_type);
+STASIS_MESSAGE_TYPE_DEFN(meetme_leave_type);
+STASIS_MESSAGE_TYPE_DEFN(meetme_end_type);
+STASIS_MESSAGE_TYPE_DEFN(meetme_mute_type);
+STASIS_MESSAGE_TYPE_DEFN(meetme_talking_type);
+STASIS_MESSAGE_TYPE_DEFN(meetme_talk_request_type);
+
+static void meetme_stasis_cb(void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic, struct stasis_message *message);
+
+static void meetme_stasis_cleanup(void)
+{
+	if (meetme_event_message_router) {
+		stasis_message_router_unsubscribe(meetme_event_message_router);
+		meetme_event_message_router = NULL;
+	}
+
+	STASIS_MESSAGE_TYPE_CLEANUP(meetme_join_type);
+	STASIS_MESSAGE_TYPE_CLEANUP(meetme_leave_type);
+	STASIS_MESSAGE_TYPE_CLEANUP(meetme_end_type);
+	STASIS_MESSAGE_TYPE_CLEANUP(meetme_mute_type);
+	STASIS_MESSAGE_TYPE_CLEANUP(meetme_talking_type);
+	STASIS_MESSAGE_TYPE_CLEANUP(meetme_talk_request_type);
+}
+
+static int meetme_stasis_init(void)
+{
+
+	STASIS_MESSAGE_TYPE_INIT(meetme_join_type);
+	STASIS_MESSAGE_TYPE_INIT(meetme_leave_type);
+	STASIS_MESSAGE_TYPE_INIT(meetme_end_type);
+	STASIS_MESSAGE_TYPE_INIT(meetme_mute_type);
+	STASIS_MESSAGE_TYPE_INIT(meetme_talking_type);
+	STASIS_MESSAGE_TYPE_INIT(meetme_talk_request_type);
+
+	meetme_event_message_router = stasis_message_router_create(
+		stasis_caching_get_topic(ast_channel_topic_all_cached()));
+
+	if (!meetme_event_message_router) {
+		meetme_stasis_cleanup();
+		return -1;
+	}
+
+	if (stasis_message_router_add(meetme_event_message_router,
+			meetme_join_type(),
+			meetme_stasis_cb,
+			NULL)) {
+		meetme_stasis_cleanup();
+		return -1;
+	}
+
+	if (stasis_message_router_add(meetme_event_message_router,
+			meetme_leave_type(),
+			meetme_stasis_cb,
+			NULL)) {
+		meetme_stasis_cleanup();
+		return -1;
+	}
+
+	if (stasis_message_router_add(meetme_event_message_router,
+			meetme_end_type(),
+			meetme_stasis_cb,
+			NULL)) {
+		meetme_stasis_cleanup();
+		return -1;
+	}
+
+	if (stasis_message_router_add(meetme_event_message_router,
+			meetme_mute_type(),
+			meetme_stasis_cb,
+			NULL)) {
+		meetme_stasis_cleanup();
+		return -1;
+	}
+
+	if (stasis_message_router_add(meetme_event_message_router,
+			meetme_talking_type(),
+			meetme_stasis_cb,
+			NULL)) {
+		meetme_stasis_cleanup();
+		return -1;
+	}
+
+	if (stasis_message_router_add(meetme_event_message_router,
+			meetme_talk_request_type(),
+			meetme_stasis_cb,
+			NULL)) {
+		meetme_stasis_cleanup();
+		return -1;
+	}
+
+	return 0;
+}
+
+static void meetme_stasis_cb(void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic, struct stasis_message *message)
+{
+	struct ast_channel_blob *channel_blob = stasis_message_data(message);
+	struct stasis_message_type *message_type;
+	const char *event;
+	const char *conference_num;
+	const char *status;
+	struct ast_json *json_cur;
+	RAII_VAR(struct ast_str *, channel_text, NULL, ast_free);
+	RAII_VAR(struct ast_str *, extra_text, NULL, ast_free);
+
+	if (!channel_blob) {
+		ast_assert(0);
+		return;
+	}
+
+	message_type = stasis_message_type(message);
+
+	if (!message_type) {
+		ast_assert(0);
+		return;
+	}
+
+	if (message_type == meetme_join_type()) {
+		event = "MeetmeJoin";
+	} else if (message_type == meetme_leave_type()) {
+		event = "MeetmeLeave";
+	} else if (message_type == meetme_end_type()) {
+		event = "MeetmeEnd";
+	} else if (message_type == meetme_mute_type()) {
+		event = "MeetmeMute";
+	} else if (message_type == meetme_talking_type()) {
+		event = "MeetmeTalking";
+	} else if (message_type == meetme_talk_request_type()) {
+		event = "MeetmeTalkRequest";
+	} else {
+		ast_assert(0);
+		return;
+	}
+
+	if (!event) {
+		ast_assert(0);
+		return;
+	}
+
+	conference_num = ast_json_string_get(ast_json_object_get(channel_blob->blob, "Meetme"));
+	if (!conference_num) {
+		ast_assert(0);
+		return;
+	}
+
+	status = ast_json_string_get(ast_json_object_get(channel_blob->blob, "status"));
+	if (status) {
+		ast_str_append_event_header(&extra_text, "Status", status);
+	}
+
+	if (channel_blob->snapshot) {
+		channel_text = ast_manager_build_channel_state_string(channel_blob->snapshot);
+	}
+
+	if ((json_cur = ast_json_object_get(channel_blob->blob, "user"))) {
+		int user_number = ast_json_integer_get(json_cur);
+		RAII_VAR(struct ast_str *, user_prop_str, ast_str_create(32), ast_free);
+		if (!user_prop_str) {
+			return;
+		}
+
+		ast_str_set(&user_prop_str, 0, "%d", user_number);
+		ast_str_append_event_header(&extra_text, "User", ast_str_buffer(user_prop_str));
+
+		if ((json_cur = ast_json_object_get(channel_blob->blob, "duration"))) {
+			int duration = ast_json_integer_get(json_cur);
+			ast_str_set(&user_prop_str, 0, "%d", duration);
+			ast_str_append_event_header(&extra_text, "Duration", ast_str_buffer(user_prop_str));
+		}
+
+		json_cur = NULL;
+	}
+
+	manager_event(EVENT_FLAG_CALL, event,
+		"Meetme: %s\r\n"
+		"%s"
+		"%s",
+		conference_num,
+		channel_text ? ast_str_buffer(channel_text) : "",
+		extra_text ? ast_str_buffer(extra_text) : "");
+}
+
+/*!
+ * \internal
+ * \brief Build a json object from a status value for inclusion in json extras for meetme_stasis_generate_msg
+ * \since 12.0.0
+ *
+ * \param on if true, then status is on. Otherwise status is off
+ * \retval NULL on failure to allocate the JSON blob.
+ * \retval pointer to the JSON blob if successful.
+ */
+static struct ast_json *status_to_json(int on)
+{
+	struct ast_json *json_object = ast_json_pack("{s: s}",
+		"status", on ? "on" : "off");
+
+	return json_object;
+}
+
+/*!
+ * \internal
+ * \brief Generate a stasis message associated with a meetme event
+ * \since 12.0.0
+ *
+ * \param meetme_confere The conference responsible for generating this message
+ * \param chan The channel involved in the message (NULL allowed)
+ * \param user The conference user involved in the message (NULL allowed)
+ * \param message_type the type the stasis message being generated
+ * \param extras Additional json fields desired for inclusion
+ */
+static void meetme_stasis_generate_msg(struct ast_conference *meetme_conference, struct ast_channel *chan,
+	struct ast_conf_user *user, struct stasis_message_type *message_type, struct ast_json *extras)
+{
+	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_json *, json_object, NULL, ast_json_unref);
+
+	json_object = ast_json_pack("{s: s}",
+		"Meetme", meetme_conference->confno);
+
+	if (!json_object) {
+		return;
+	}
+
+	if (extras) {
+		ast_json_object_update(json_object, extras);
+	}
+
+	if (user) {
+		struct timeval now = ast_tvnow();
+		long duration = (long)(now.tv_sec - user->jointime);
+		RAII_VAR(struct ast_json *, json_user, ast_json_integer_create(user->user_no), ast_json_unref);
+		RAII_VAR(struct ast_json *, json_user_duration, NULL, ast_json_unref);
+
+		if (ast_json_object_set(json_object, "user", json_user)) {
+			return;
+		}
+		json_user = NULL;
+
+		if (duration > 0) {
+			json_user_duration = ast_json_integer_create(duration);
+
+			if (!json_user_duration) {
+				return;
+			}
+
+			if (ast_json_object_set(json_object, "duration", json_user_duration)) {
+				return;
+			}
+			json_user_duration = NULL;
+		}
+	}
+
+	msg = ast_channel_blob_create(chan, message_type, json_object);
+
+	if (!msg) {
+		return;
+	}
+
+	stasis_publish(ast_channel_topic(chan), msg);
+}
 
 static int admin_exec(struct ast_channel *chan, const char *data);
 static void *recordthread(void *args);
@@ -1951,20 +2361,10 @@
 {
 	int x;
 	struct announce_listitem *item;
-	
+
 	AST_LIST_REMOVE(&confs, conf, list);
-	/*** DOCUMENTATION
-		<managerEventInstance>
-			<synopsis>Raised when a MeetMe conference ends.</synopsis>
-			<syntax>
-				<xi:include xpointer="xpointer(/docs/managerEvent[@name='MeetmeJoin']/managerEventInstance/syntax/parameter[@name='Meetme'])" />
-			</syntax>
-			<see-also>
-				<ref type="managerEvent">MeetmeJoin</ref>
-			</see-also>
-		</managerEventInstance>
-	***/
-	manager_event(EVENT_FLAG_CALL, "MeetmeEnd", "Meetme: %s\r\n", conf->confno);
+
+	meetme_stasis_generate_msg(conf, NULL, NULL, meetme_end_type(), NULL);
 
 	if (conf->recording == MEETME_RECORD_ACTIVE) {
 		conf->recording = MEETME_RECORD_TERMINATE;
@@ -2298,30 +2698,8 @@
 
 static void send_talking_event(struct ast_channel *chan, struct ast_conference *conf, struct ast_conf_user *user, int talking)
 {
-	/*** DOCUMENTATION
-		<managerEventInstance>
-			<synopsis>Raised when a MeetMe user begins or ends talking.</synopsis>
-			<syntax>
-				<xi:include xpointer="xpointer(/docs/managerEvent[@name='MeetmeJoin']/managerEventInstance/syntax/parameter[@name='Meetme'])" />
-				<xi:include xpointer="xpointer(/docs/managerEvent[@name='MeetmeJoin']/managerEventInstance/syntax/parameter[@name='Usernum'])" />
-				<parameter name="Status">
-					<enumlist>
-						<enum name="on"/>
-						<enum name="off"/>
-					</enumlist>
-				</parameter>
-			</syntax>
-		</managerEventInstance>
-	***/
-	ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeTalking",
-		"Channel: %s\r\n"
-		"Uniqueid: %s\r\n"
-		"Meetme: %s\r\n"
-		"Usernum: %d\r\n"
-		"Status: %s\r\n",
-		ast_channel_name(chan), ast_channel_uniqueid(chan),
-		conf->confno,
-		user->user_no, talking ? "on" : "off");
+	RAII_VAR(struct ast_json *, status_blob, status_to_json(talking), ast_json_unref);
+	meetme_stasis_generate_msg(conf, chan, user, meetme_talking_type(), status_blob);
 }
 
 static void set_user_talking(struct ast_channel *chan, struct ast_conference *conf, struct ast_conf_user *user, int talking, int monitor)
@@ -3335,39 +3713,7 @@
 	ast_debug(1, "Placed channel %s in DAHDI conf %d\n", ast_channel_name(chan), conf->dahdiconf);
 
 	if (!sent_event) {
-		/*** DOCUMENTATION
-			<managerEventInstance>
-				<synopsis>Raised when a user joins a MeetMe conference.</synopsis>
-				<syntax>
-					<parameter name="Meetme">
-						<para>The identifier for the MeetMe conference.</para>
-					</parameter>
-					<parameter name="Usernum">
-						<para>The identifier of the MeetMe user who joined.</para>
-					</parameter>
-				</syntax>
-				<see-also>
-					<ref type="managerEvent">MeetmeLeave</ref>
-					<ref type="application">MeetMe</ref>
-				</see-also>
-			</managerEventInstance>
-		***/
-		ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeJoin",
-			"Channel: %s\r\n"
-			"Uniqueid: %s\r\n"
-			"Meetme: %s\r\n"
-			"Usernum: %d\r\n"
-			"CallerIDnum: %s\r\n"
-			"CallerIDname: %s\r\n"
-			"ConnectedLineNum: %s\r\n"
-			"ConnectedLineName: %s\r\n",
-			ast_channel_name(chan), ast_channel_uniqueid(chan), conf->confno,
-			user->user_no,
-			S_COR(ast_channel_caller(user->chan)->id.number.valid, ast_channel_caller(user->chan)->id.number.str, "<unknown>"),
-			S_COR(ast_channel_caller(user->chan)->id.name.valid, ast_channel_caller(user->chan)->id.name.str, "<unknown>"),
-			S_COR(ast_channel_connected(user->chan)->id.number.valid, ast_channel_connected(user->chan)->id.number.str, "<unknown>"),
-			S_COR(ast_channel_connected(user->chan)->id.name.valid, ast_channel_connected(user->chan)->id.name.str, "<unknown>")
-			);
+		meetme_stasis_generate_msg(conf, chan, user, meetme_join_type(), NULL);
 		sent_event = 1;
 	}
 
@@ -3716,6 +4062,7 @@
 
 			/* If I should be muted but am still talker, mute me */
 			if ((user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) && (dahdic.confmode & DAHDI_CONF_TALKER)) {
+				RAII_VAR(struct ast_json *, status_blob, status_to_json(1), ast_json_unref);
 				dahdic.confmode ^= DAHDI_CONF_TALKER;
 				if (ioctl(fd, DAHDI_SETCONF, &dahdic)) {
 					ast_log(LOG_WARNING, "Error setting conference - Un/Mute \n");
@@ -3727,95 +4074,34 @@
 				if (ast_test_flag64(confflags,  (CONFFLAG_MONITORTALKER | CONFFLAG_OPTIMIZETALKER))) {
 					set_user_talking(chan, conf, user, -1, ast_test_flag64(confflags, CONFFLAG_MONITORTALKER));
 				}
-				/*** DOCUMENTATION
-				<managerEventInstance>
-					<synopsis>Raised when a MeetMe user is muted.</synopsis>
-					<syntax>
-						<xi:include xpointer="xpointer(/docs/managerEvent[@name='MeetmeJoin']/managerEventInstance/syntax/parameter[@name='Meetme'])" />
-						<xi:include xpointer="xpointer(/docs/managerEvent[@name='MeetmeJoin']/managerEventInstance/syntax/parameter[@name='Usernum'])" />
-						<parameter name="Status">
-							<enumlist>
-								<enum name="on"/>
-								<enum name="off"/>
-							</enumlist>
-						</parameter>
-					</syntax>
-				</managerEventInstance>
-				***/
-				ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeMute",
-					"Channel: %s\r\n"
-					"Uniqueid: %s\r\n"
-					"Meetme: %s\r\n"
-					"Usernum: %d\r\n"
-					"Status: on\r\n",
-					ast_channel_name(chan), ast_channel_uniqueid(chan), conf->confno, user->user_no);
+				meetme_stasis_generate_msg(conf, chan, user, meetme_mute_type(), status_blob);
 			}
 
 			/* If I should be un-muted but am not talker, un-mute me */
 			if (!(user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) && !ast_test_flag64(confflags, CONFFLAG_MONITOR) && !(dahdic.confmode & DAHDI_CONF_TALKER)) {
+				RAII_VAR(struct ast_json *, status_blob, status_to_json(0), ast_json_unref);
 				dahdic.confmode |= DAHDI_CONF_TALKER;
 				if (ioctl(fd, DAHDI_SETCONF, &dahdic)) {
 					ast_log(LOG_WARNING, "Error setting conference - Un/Mute \n");
 					ret = -1;
 					break;
 				}
-				/*** DOCUMENTATION
-				<managerEventInstance>
-					<synopsis>Raised when a MeetMe user is unmuted.</synopsis>
-				</managerEventInstance>
-				***/
-				ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeMute",
-					"Channel: %s\r\n"
-					"Uniqueid: %s\r\n"
-					"Meetme: %s\r\n"
-					"Usernum: %d\r\n"
-					"Status: off\r\n",
-					ast_channel_name(chan), ast_channel_uniqueid(chan), conf->confno, user->user_no);
-			}
-			
+				meetme_stasis_generate_msg(conf, chan, user, meetme_mute_type(), status_blob);
+			}
+
 			if ((user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) && 
 				(user->adminflags & ADMINFLAG_T_REQUEST) && !(talkreq_manager)) {
+
+				RAII_VAR(struct ast_json *, status_blob, status_to_json(1), ast_json_unref);
 				talkreq_manager = 1;
-
-				/*** DOCUMENTATION
-				<managerEventInstance>
-					<synopsis>Raised when a MeetMe user has started talking.</synopsis>
-					<syntax>
-						<xi:include xpointer="xpointer(/docs/managerEvent[@name='MeetmeJoin']/managerEventInstance/syntax/parameter[@name='Meetme'])" />
-						<xi:include xpointer="xpointer(/docs/managerEvent[@name='MeetmeJoin']/managerEventInstance/syntax/parameter[@name='Usernum'])" />
-						<parameter name="Status">
-							<enumlist>
-								<enum name="on"/>
-								<enum name="off"/>
-							</enumlist>
-						</parameter>
-					</syntax>
-				</managerEventInstance>
-				***/
-				ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeTalkRequest",
-					"Channel: %s\r\n"
-					"Uniqueid: %s\r\n"
-					"Meetme: %s\r\n"
-					"Usernum: %d\r\n"
-					"Status: on\r\n",
-					ast_channel_name(chan), ast_channel_uniqueid(chan), conf->confno, user->user_no);
+				meetme_stasis_generate_msg(conf, chan, user, meetme_talk_request_type(), status_blob);
 			}
 
 			if (!(user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) && 
 				!(user->adminflags & ADMINFLAG_T_REQUEST) && (talkreq_manager)) {
+				RAII_VAR(struct ast_json *, status_blob, status_to_json(0), ast_json_unref);
 				talkreq_manager = 0;
-				/*** DOCUMENTATION
-				<managerEventInstance>
-					<synopsis>Raised when a MeetMe user has finished talking.</synopsis>
-				</managerEventInstance>
-				***/
-				ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeTalkRequest",
-					"Channel: %s\r\n"
-					"Uniqueid: %s\r\n"
-					"Meetme: %s\r\n"
-					"Usernum: %d\r\n"
-					"Status: off\r\n",
-					ast_channel_name(chan), ast_channel_uniqueid(chan), conf->confno, user->user_no);
+				meetme_stasis_generate_msg(conf, chan, user, meetme_talk_request_type(), status_blob);
 			}
 
 			/* If user have been hung up, exit the conference */
@@ -4169,38 +4455,7 @@
 		now = ast_tvnow();
 
 		if (sent_event) {
-			/*** DOCUMENTATION
-			<managerEventInstance>
-				<synopsis>Raised when a user leaves a MeetMe conference.</synopsis>
-				<syntax>
-					<xi:include xpointer="xpointer(/docs/managerEvent[@name='MeetmeJoin']/managerEventInstance/syntax/parameter[@name='Meetme'])" />
-					<xi:include xpointer="xpointer(/docs/managerEvent[@name='MeetmeJoin']/managerEventInstance/syntax/parameter[@name='Usernum'])" />
-					<parameter name="Duration">
-						<para>The length of time in seconds that the Meetme user was in the conference.</para>
-					</parameter>
-				</syntax>
-				<see-also>
-					<ref type="managerEvent">MeetmeJoin</ref>
-				</see-also>
-			</managerEventInstance>
-			***/
-			ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeLeave",
-				"Channel: %s\r\n"
-				"Uniqueid: %s\r\n"
-				"Meetme: %s\r\n"
-				"Usernum: %d\r\n"
-				"CallerIDNum: %s\r\n"
-				"CallerIDName: %s\r\n"
-				"ConnectedLineNum: %s\r\n"
-				"ConnectedLineName: %s\r\n"
-				"Duration: %ld\r\n",
-				ast_channel_name(chan), ast_channel_uniqueid(chan), conf->confno,
-				user->user_no,
-				S_COR(ast_channel_caller(user->chan)->id.number.valid, ast_channel_caller(user->chan)->id.number.str, "<unknown>"),
-				S_COR(ast_channel_caller(user->chan)->id.name.valid, ast_channel_caller(user->chan)->id.name.str, "<unknown>"),
-				S_COR(ast_channel_connected(user->chan)->id.number.valid, ast_channel_connected(user->chan)->id.number.str, "<unknown>"),
-				S_COR(ast_channel_connected(user->chan)->id.name.valid, ast_channel_connected(user->chan)->id.name.str, "<unknown>"),
-				(long)(now.tv_sec - user->jointime));
+			meetme_stasis_generate_msg(conf, chan, user, meetme_leave_type(), NULL);
 		}
 
 		if (setusercount) {
@@ -7739,6 +7994,8 @@
 	res |= ast_custom_function_unregister(&meetme_info_acf);
 	ast_unload_realtime("meetme");
 
+	meetme_stasis_cleanup();
+
 	return res;
 }
 
@@ -7758,6 +8015,8 @@
 
 	res |= load_config(0);
 
+	res |= meetme_stasis_init();
+
 	ast_cli_register_multiple(cli_meetme, ARRAY_LEN(cli_meetme));
 	res |= ast_manager_register_xml("MeetmeMute", EVENT_FLAG_CALL, action_meetmemute);
 	res |= ast_manager_register_xml("MeetmeUnmute", EVENT_FLAG_CALL, action_meetmeunmute);

Modified: team/qwell/queue_events/apps/confbridge/confbridge_manager.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/apps/confbridge/confbridge_manager.c?view=diff&rev=390857&r1=390856&r2=390857
==============================================================================
--- team/qwell/queue_events/apps/confbridge/confbridge_manager.c (original)
+++ team/qwell/queue_events/apps/confbridge/confbridge_manager.c Fri Jun  7 11:19:20 2013
@@ -187,24 +187,6 @@
 
 static struct stasis_message_router *bridge_state_router;
 static struct stasis_message_router *channel_state_router;
-
-static void append_event_header(struct ast_str **fields_string,
-					const char *header, const char *value)
-{
-	struct ast_str *working_str = *fields_string;
-
-	if (!working_str) {
-		working_str = ast_str_create(128);
-		if (!working_str) {
-			return;
-		}
-		*fields_string = working_str;
-	}
-
-	ast_str_append(&working_str, 0,
-		"%s: %s\r\n",
-		header, value);
-}
 
 static void confbridge_publish_manager_event(
 	struct stasis_message *message,
@@ -306,7 +288,7 @@
 		return;
 	}
 
-	append_event_header(&extra_text, "TalkingStatus", talking_status);
+	ast_str_append_event_header(&extra_text, "TalkingStatus", talking_status);
 	if (!extra_text) {
 		return;
 	}

Modified: team/qwell/queue_events/include/asterisk/manager.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/include/asterisk/manager.h?view=diff&rev=390857&r1=390856&r2=390857
==============================================================================
--- team/qwell/queue_events/include/asterisk/manager.h (original)
+++ team/qwell/queue_events/include/asterisk/manager.h Fri Jun  7 11:19:20 2013
@@ -316,6 +316,21 @@
  */
 struct ast_datastore *astman_datastore_find(struct mansession *s, const struct ast_datastore_info *info, const char *uid);
 
+/*!
+ * \brief append an event header to an ast string
+ * \since 12
+ *
+ * \param fields_string pointer to an ast_string pointer. It may be a pointer to a
+ *        NULL ast_str pointer, in which case the ast_str will be initialized.
+ * \param header The header being applied
+ * \param value the value of the header
+ *
+ * \retval 0 if successful
+ * \retval non-zero on failure
+ */
+int ast_str_append_event_header(struct ast_str **fields_string,
+	const char *header, const char *value);
+
 /*! \brief Struct representing a snapshot of channel state */
 struct ast_channel_snapshot;
 

Modified: team/qwell/queue_events/include/asterisk/pbx.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/include/asterisk/pbx.h?view=diff&rev=390857&r1=390856&r2=390857
==============================================================================
--- team/qwell/queue_events/include/asterisk/pbx.h (original)
+++ team/qwell/queue_events/include/asterisk/pbx.h Fri Jun  7 11:19:20 2013
@@ -470,6 +470,17 @@
 	const char *application, void *data, void (*datad)(void *), const char *registrar);
 
 /*!
+ * \brief Same as ast_add_extension2, but assumes you have already locked context
+ * \since 12.0.0
+ *
+ * \note con must be write locked prior to calling. For details about the arguments,
+ *       check ast_add_extension2()
+ */
+int ast_add_extension2_nolock(struct ast_context *con, int replace, const char *extension,
+	int priority, const char *label, const char *callerid,
+	const char *application, void *data, void (*datad)(void *), const char *registrar);
+
+/*!
  * \brief Map devstate to an extension state.
  *
  * \param[in] devstate device state

Modified: team/qwell/queue_events/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/main/features.c?view=diff&rev=390857&r1=390856&r2=390857
==============================================================================
--- team/qwell/queue_events/main/features.c (original)
+++ team/qwell/queue_events/main/features.c Fri Jun  7 11:19:20 2013
@@ -362,8 +362,6 @@
 	FEATURE_INTERPRET_CHECK,  /* Used by feature_check */
 } feature_interpret_op;
 
-static const char *parkedcall = "ParkedCall";
-
 /*! Parking lot access ramp dialplan usage entry. */
 struct parking_dp_ramp {
 	/*! Next node in the parking lot spaces dialplan list. */
@@ -1482,13 +1480,6 @@
 
 	snprintf(app_data, sizeof(app_data), "%s,%s", pu->parkingexten,
 		pu->parkinglot->name);
-	if (ast_add_extension(pu->parkinglot->cfg.parking_con, 1, pu->parkingexten, 1,
-		NULL, NULL, parkedcall, ast_strdup(app_data), ast_free_ptr, registrar)) {
-		ast_log(LOG_ERROR, "Could not create parked call exten: %s@%s\n",
-			pu->parkingexten, pu->parkinglot->cfg.parking_con);
-	} else {
-		notify_metermaids(pu->parkingexten, pu->parkinglot->cfg.parking_con, AST_DEVICE_INUSE);
-	}
 
 	AST_LIST_UNLOCK(&pu->parkinglot->parkings);
 
@@ -3939,12 +3930,6 @@
 
 				pbx_builtin_setvar_helper(chan, "PARKER", peername);
 
-				if (ast_add_extension(parking_con_dial, 1, peername_flat, 1, NULL, NULL,
-					"Dial", ast_strdup(returnexten), ast_free_ptr, registrar)) {
-					ast_log(LOG_ERROR,
-						"Could not create parking return dial exten: %s@%s\n",
-						peername_flat, parking_con_dial);
-				}
 			}
 
 			snprintf(parkingslot, sizeof(parkingslot), "%d", pu->parkingnum);
@@ -4274,25 +4259,6 @@
 	return newlot;
 }
 
-/*!
- * \brief Add parking hints for all defined parking spaces.
- * \param context Dialplan context to add the hints.
- * \param start Starting space in parkinglot.
- * \param stop Ending space in parkinglot.
- */
-static void park_add_hints(const char *context, int start, int stop)
-{
-	int numext;
-	char device[AST_MAX_EXTENSION];
-	char exten[10];
-
-	for (numext = start; numext <= stop; numext++) {
-		snprintf(exten, sizeof(exten), "%d", numext);
-		snprintf(device, sizeof(device), "park:%s@%s", exten, context);
-		ast_add_extension(context, 1, exten, PRIORITY_HINT, NULL, NULL, device, NULL, NULL, registrar);
-	}
-}
-
 /*! Default configuration for default parking lot. */
 static const struct parkinglot_cfg parkinglot_cfg_default_default = {
 	.mohclass = "default",
@@ -4330,50 +4296,9 @@
  */
 static int parkinglot_activate(struct ast_parkinglot *parkinglot)
 {
-	int disabled = 0;
-	char app_data[5 + AST_MAX_CONTEXT];
-
-	/* Create Park option list.  Must match with struct park_app_args options. */
-	if (parkinglot->cfg.parkext_exclusive) {
-		/* Specify the parking lot this parking extension parks calls. */
-		snprintf(app_data, sizeof(app_data), ",,,,,%s", parkinglot->name);
-	} else {
-		/* The dialplan must specify which parking lot to use. */
-		app_data[0] = '\0';
-	}
-
-	/* Create context */
-	if (!ast_context_find_or_create(NULL, NULL, parkinglot->cfg.parking_con, registrar)) {
-		ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n",
-			parkinglot->cfg.parking_con);
-		disabled = 1;
-
-	/* Add a parking extension into the context */
-	} else if (ast_add_extension(parkinglot->cfg.parking_con, 1, parkinglot->cfg.parkext,
-		1, NULL, NULL, parkcall, ast_strdup(app_data), ast_free_ptr, registrar)) {
-		ast_log(LOG_ERROR, "Could not create parking lot %s access exten %s@%s\n",
-			parkinglot->name, parkinglot->cfg.parkext, parkinglot->cfg.parking_con);
-		disabled = 1;
-	} else {
-		/* Add parking hints */
-		if (parkinglot->cfg.parkaddhints) {
-			park_add_hints(parkinglot->cfg.parking_con, parkinglot->cfg.parking_start,
-				parkinglot->cfg.parking_stop);
-		}
-
-		/*
-		 * XXX Not sure why we should need to notify the metermaids for
-		 * this exten.  It was originally done for the default parking
-		 * lot entry exten only but should be done for all entry extens
-		 * if we do it for one.
-		 */
-		/* Notify metermaids about parking lot entry exten state. */
-		notify_metermaids(parkinglot->cfg.parkext, parkinglot->cfg.parking_con,
-			AST_DEVICE_INUSE);
-	}
-
-	parkinglot->disabled = disabled;
-	return disabled ? -1 : 0;
+	/* XXX All parking stuff is being replaced by res_parking */
+	parkinglot->disabled = 1;
+	return -1;
 }
 
 int ast_features_reload(void)

Modified: team/qwell/queue_events/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/main/manager.c?view=diff&rev=390857&r1=390856&r2=390857
==============================================================================
--- team/qwell/queue_events/main/manager.c (original)
+++ team/qwell/queue_events/main/manager.c Fri Jun  7 11:19:20 2013
@@ -89,6 +89,7 @@
 #include "asterisk/security_events.h"
 #include "asterisk/event.h"
 #include "asterisk/aoc.h"
+#include "asterisk/strings.h"
 #include "asterisk/stringfields.h"
 #include "asterisk/presencestate.h"
 #include "asterisk/stasis.h"
@@ -8259,6 +8260,26 @@
 	return datastore;
 }
 
+int ast_str_append_event_header(struct ast_str **fields_string,
+					const char *header, const char *value)
+{
+	struct ast_str *working_str = *fields_string;
+
+	if (!working_str) {
+		working_str = ast_str_create(128);
+		if (!working_str) {
+			return -1;
+		}
+		*fields_string = working_str;
+	}
+
+	ast_str_append(&working_str, 0,
+		"%s: %s\r\n",
+		header, value);
+
+	return 0;
+}
+
 static void manager_event_blob_dtor(void *obj)
 {
 	struct ast_manager_event_blob *ev = obj;

Modified: team/qwell/queue_events/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/main/pbx.c?view=diff&rev=390857&r1=390856&r2=390857
==============================================================================
--- team/qwell/queue_events/main/pbx.c (original)
+++ team/qwell/queue_events/main/pbx.c Fri Jun  7 11:19:20 2013
@@ -9612,6 +9612,16 @@
 		application, data, datad, registrar, 1);
 }
 
+int ast_add_extension2_nolock(struct ast_context *con,
+	int replace, const char *extension, int priority, const char *label, const char *callerid,
+	const char *application, void *data, void (*datad)(void *),
+	const char *registrar)
+{
+	return ast_add_extension2_lockopt(con, replace, extension, priority, label, callerid,
+		application, data, datad, registrar, 0);
+}
+
+
 /*!
  * \brief Same as ast_add_extension2() but controls the context locking.
  *

Modified: team/qwell/queue_events/res/parking/parking_bridge.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/res/parking/parking_bridge.c?view=diff&rev=390857&r1=390856&r2=390857
==============================================================================
--- team/qwell/queue_events/res/parking/parking_bridge.c (original)
+++ team/qwell/queue_events/res/parking/parking_bridge.c Fri Jun  7 11:19:20 2013
@@ -290,6 +290,8 @@
 		COLORIZE(COLOR_BRMAGENTA, 0, self->lot->name),
 		pu->parking_space);
 
+	parking_notify_metermaids(pu->parking_space, self->lot->cfg->parking_con, AST_DEVICE_INUSE);
+
 	return 0;
 }
 
@@ -327,6 +329,8 @@
 		pu->resolution = PARK_ABANDON;
 	}
 	ao2_unlock(pu);
+
+	parking_notify_metermaids(pu->parking_space, self->lot->cfg->parking_con, AST_DEVICE_NOT_INUSE);
 
 	switch (pu->resolution) {
 	case PARK_UNSET:

Modified: team/qwell/queue_events/res/parking/parking_bridge_features.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/res/parking/parking_bridge_features.c?view=diff&rev=390857&r1=390856&r2=390857
==============================================================================
--- team/qwell/queue_events/res/parking/parking_bridge_features.c (original)
+++ team/qwell/queue_events/res/parking/parking_bridge_features.c Fri Jun  7 11:19:20 2013
@@ -367,6 +367,23 @@
 	ao2_ref(user, -1);
 }
 
+/*!
+ * \brief Removes the identification information from a channel name string
+ * \since 12.0
+ *
+ * \param channel name string that you wish to turn into a dial string. This will be edited in place.
+ */
+static void channel_name_to_dial_string(char *peername)
+{
+	char *dash;
+
+	/* Truncate after the dash */
+	dash = strrchr(peername, '-');
+	if (dash) {
+		*dash = '\0';
+	}
+}
+
 /*! \internal
  * \brief Interval hook. Pulls a parked call from the parking bridge after the timeout is passed and sets the resolution to timeout.
  *
@@ -378,8 +395,16 @@
 {
 	struct parked_user *user = hook_pvt;

[... 776 lines stripped ...]



More information about the svn-commits mailing list