[asterisk-commits] mmichelson: branch mmichelson/transfer_stasis r391588 - /team/mmichelson/tran...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jun 12 18:52:19 CDT 2013
Author: mmichelson
Date: Wed Jun 12 18:52:17 2013
New Revision: 391588
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=391588
Log:
Creat to_ami vtable methods for the transfer stasis messages.
Modified:
team/mmichelson/transfer_stasis/main/stasis_bridging.c
Modified: team/mmichelson/transfer_stasis/main/stasis_bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/transfer_stasis/main/stasis_bridging.c?view=diff&rev=391588&r1=391587&r2=391588
==============================================================================
--- team/mmichelson/transfer_stasis/main/stasis_bridging.c (original)
+++ team/mmichelson/transfer_stasis/main/stasis_bridging.c Wed Jun 12 18:52:17 2013
@@ -41,6 +41,9 @@
#define SNAPSHOT_CHANNELS_BUCKETS 13
+static struct ast_manager_event_blob *attended_transfer_to_ami(struct stasis_message *message);
+static struct ast_manager_event_blob *blind_transfer_to_ami(struct stasis_message *message);
+
/*!
* @{ \brief Define bridge message types.
*/
@@ -48,8 +51,8 @@
STASIS_MESSAGE_TYPE_DEFN(ast_bridge_merge_message_type);
STASIS_MESSAGE_TYPE_DEFN(ast_channel_entered_bridge_type);
STASIS_MESSAGE_TYPE_DEFN(ast_channel_left_bridge_type);
-STASIS_MESSAGE_TYPE_DEFN(ast_blind_transfer_type);
-STASIS_MESSAGE_TYPE_DEFN(ast_attended_transfer_type);
+STASIS_MESSAGE_TYPE_DEFN(ast_blind_transfer_type, .to_ami = blind_transfer_to_ami);
+STASIS_MESSAGE_TYPE_DEFN(ast_attended_transfer_type, .to_ami = attended_transfer_to_ami);
/*! @} */
/*! \brief Aggregate topic for bridge messages */
@@ -350,6 +353,32 @@
ao2_cleanup(pair->channel_snapshot);
}
+static const char *result_strs[] = {
+ [AST_BRIDGE_TRANSFER_FAIL] = "Fail",
+ [AST_BRIDGE_TRANSFER_INVALID] = "Invalid",
+ [AST_BRIDGE_TRANSFER_NOT_PERMITTED] = "Not Permitted",
+ [AST_BRIDGE_TRANSFER_SUCCESS] = "Success",
+};
+
+static struct ast_manager_event_blob *blind_transfer_to_ami(struct stasis_message *msg)
+{
+ struct ast_blind_transfer_message * transfer_msg = stasis_message_data(msg);
+
+ return ast_manager_event_blob_create(EVENT_FLAG_CALL, "BlindTransfer",
+ "Result: %s\r\n"
+ "Transferer: %s\r\n"
+ "Bridge: %s\r\n"
+ "IsExternal: %s\r\n"
+ "Context: %s\r\n"
+ "Extension: %s\r\n",
+ result_strs[transfer_msg->result],
+ transfer_msg->transferer.channel_snapshot->name,
+ transfer_msg->transferer.bridge_snapshot->uniqueid,
+ transfer_msg->is_external ? "Yes" : "No",
+ transfer_msg->context,
+ transfer_msg->exten);
+}
+
static void blind_transfer_dtor(void *obj)
{
struct ast_blind_transfer_message *msg = obj;
@@ -399,6 +428,53 @@
}
stasis_publish(ast_bridge_topic_all(), msg);
+}
+
+static struct ast_manager_event_blob *attended_transfer_to_ami(struct stasis_message *msg)
+{
+ RAII_VAR(struct ast_str *, variable_data, ast_str_create(64), ast_free_ptr);
+ struct ast_attended_transfer_message *transfer_msg = stasis_message_data(msg);
+
+ if (!variable_data) {
+ return NULL;
+ }
+
+ switch (transfer_msg->dest_type) {
+ case AST_ATTENDED_TRANSFER_DEST_BRIDGE_MERGE:
+ ast_str_append(&variable_data, 0, "DestType: Bridge\r\n");
+ ast_str_append(&variable_data, 0, "DestBridge: %s\r\n", transfer_msg->dest.bridge);
+ break;
+ case AST_ATTENDED_TRANSFER_DEST_APP:
+ ast_str_append(&variable_data, 0, "DestType: App\r\n");
+ ast_str_append(&variable_data, 0, "DestApp: %s\r\n", transfer_msg->dest.app);
+ break;
+ case AST_ATTENDED_TRANSFER_DEST_LINK:
+ ast_str_append(&variable_data, 0, "DestType: Link\r\n");
+ ast_str_append(&variable_data, 0, "LocalChannel1: %s\r\n", transfer_msg->dest.links[0].local_channel->name);
+ ast_str_append(&variable_data, 0, "LocalBridge1: %s\r\n", transfer_msg->dest.links[0].bridge);
+ ast_str_append(&variable_data, 0, "LocalChannel2: %s\r\n", transfer_msg->dest.links[1].local_channel->name);
+ ast_str_append(&variable_data, 0, "LocalBridge2: %s\r\n", transfer_msg->dest.links[1].bridge);
+ break;
+ case AST_ATTENDED_TRANSFER_DEST_FAIL:
+ ast_str_append(&variable_data, 0, "DestType: Fail\r\n");
+ break;
+ }
+
+ return ast_manager_event_blob_create(EVENT_FLAG_CALL, "AttendedTransfer",
+ "Result: %s\r\n"
+ "Transferer1: %s\r\n"
+ "Bridge1: %s\r\n"
+ "Transferer2: %s\r\n"
+ "Bridge2: %s\r\n"
+ "IsExternal: %s\r\n"
+ "%s\r\n",
+ result_strs[transfer_msg->result],
+ transfer_msg->to_transferee.channel_snapshot->name,
+ transfer_msg->to_transferee.bridge_snapshot ? transfer_msg->to_transferee.bridge_snapshot->uniqueid : "None",
+ transfer_msg->to_transfer_target.channel_snapshot->name,
+ transfer_msg->to_transfer_target.bridge_snapshot ? transfer_msg->to_transfer_target.bridge_snapshot->uniqueid : "None",
+ transfer_msg->is_external ? "Yes" : "No",
+ ast_str_buffer(variable_data));
}
static void attended_transfer_dtor(void *obj)
More information about the asterisk-commits
mailing list