[asterisk-commits] mmichelson: branch mmichelson/queue_bugbug r395216 - /team/mmichelson/queue_b...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jul 23 16:53:32 CDT 2013
Author: mmichelson
Date: Tue Jul 23 16:53:30 2013
New Revision: 395216
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=395216
Log:
Break bridge callback into smaller subroutines.
Modified:
team/mmichelson/queue_bugbug/apps/app_queue.c
Modified: team/mmichelson/queue_bugbug/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/queue_bugbug/apps/app_queue.c?view=diff&rev=395216&r1=395215&r2=395216
==============================================================================
--- team/mmichelson/queue_bugbug/apps/app_queue.c (original)
+++ team/mmichelson/queue_bugbug/apps/app_queue.c Tue Jul 23 16:53:30 2013
@@ -5273,6 +5273,98 @@
(long) time(NULL) - queue_data->starttime, queue_data->caller_pos);
}
+static void handle_bridge_enter(struct queue_stasis_data *queue_data,
+ struct stasis_message *msg)
+{
+ struct ast_bridge_blob *enter_blob = stasis_message_data(msg);
+
+ if (!ast_strlen_zero(queue_data->bridge_uniqueid)) {
+ return;
+ }
+
+ if (!strcmp(enter_blob->channel->uniqueid, queue_data->caller_uniqueid)) {
+ ast_string_field_set(queue_data, bridge_uniqueid,
+ enter_blob->bridge->uniqueid);
+ ast_debug(3, "Detected entry of caller channel %s into bridge %s\n",
+ enter_blob->channel->name, queue_data->bridge_uniqueid);
+ }
+}
+
+static void handle_blind_transfer(struct queue_stasis_data *queue_data,
+ struct stasis_message *msg)
+{
+ struct ast_bridge_blob *blind_blob = stasis_message_data(msg);
+ RAII_VAR(struct ast_channel_snapshot *, caller, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_channel_snapshot *, agent, NULL, ao2_cleanup);
+
+ if (ast_json_integer_get(ast_json_object_get(blind_blob->blob, "result")) == AST_BRIDGE_TRANSFER_FAIL) {
+ return;
+ }
+
+ ao2_lock(queue_data);
+ if (ast_strlen_zero(queue_data->bridge_uniqueid) ||
+ strcmp(queue_data->bridge_uniqueid, blind_blob->bridge->uniqueid)) {
+ ao2_unlock(queue_data);
+ return;
+ }
+
+ caller = ast_channel_snapshot_get_latest(queue_data->caller_uniqueid);
+ agent = ast_channel_snapshot_get_latest(queue_data->agent_uniqueid);
+
+ ao2_unlock(queue_data);
+
+ ast_debug(3, "Detected blind transfer in queue %s\n", queue_data->queue->name);
+ ast_queue_log(queue_data->queue->name, caller->uniqueid, queue_data->member->membername, "BLINDTRANSFER", "%s|%s|%ld|%ld|%d",
+ ast_json_string_get(ast_json_object_get(blind_blob->blob, "exten")),
+ ast_json_string_get(ast_json_object_get(blind_blob->blob, "context")),
+ (long) queue_data->starttime - queue_data->holdstart,
+ (long) time(NULL) - queue_data->starttime, queue_data->caller_pos);
+
+ send_agent_complete(queue_data->queue->name, caller, agent, queue_data->member,
+ queue_data->holdstart, queue_data->starttime, TRANSFER);
+ update_queue(queue_data->queue, queue_data->member, queue_data->callcompletedinsl,
+ time(NULL) - queue_data->starttime);
+ remove_stasis_subscriptions(queue_data);
+}
+
+static void handle_attended_transfer(struct queue_stasis_data *queue_data,
+ struct stasis_message *msg)
+{
+ struct ast_attended_transfer_message *atxfer_msg = stasis_message_data(msg);
+ RAII_VAR(struct ast_channel_snapshot *, caller, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_channel_snapshot *, agent, NULL, ao2_cleanup);
+
+ if (atxfer_msg->result == AST_BRIDGE_TRANSFER_FAIL ||
+ atxfer_msg->dest_type == AST_ATTENDED_TRANSFER_DEST_THREEWAY) {
+ return;
+ }
+
+ ao2_lock(queue_data);
+
+ if ((!atxfer_msg->to_transferee.bridge_snapshot || strcmp(queue_data->bridge_uniqueid,
+ atxfer_msg->to_transferee.bridge_snapshot->uniqueid)) &&
+ (!atxfer_msg->to_transfer_target.bridge_snapshot || strcmp(queue_data->bridge_uniqueid,
+ atxfer_msg->to_transfer_target.bridge_snapshot->uniqueid))) {
+ ao2_unlock(queue_data);
+ return;
+ }
+
+ caller = ast_channel_snapshot_get_latest(queue_data->caller_uniqueid);
+ agent = ast_channel_snapshot_get_latest(queue_data->agent_uniqueid);
+
+ ao2_unlock(queue_data);
+
+ ast_debug(3, "Detected attended transfer in queue %s\n", queue_data->queue->name);
+
+ log_attended_transfer(queue_data, caller, atxfer_msg);
+
+ send_agent_complete(queue_data->queue->name, caller, agent, queue_data->member,
+ queue_data->holdstart, queue_data->starttime, TRANSFER);
+ update_queue(queue_data->queue, queue_data->member, queue_data->callcompletedinsl,
+ time(NULL) - queue_data->starttime);
+ remove_stasis_subscriptions(queue_data);
+}
+
static void queue_bridge_cb(void *userdata, struct stasis_subscription *sub,
struct stasis_topic *topic, struct stasis_message *msg)
{
@@ -5287,85 +5379,11 @@
}
if (ast_channel_entered_bridge_type() == stasis_message_type(msg)) {
- struct ast_bridge_blob *enter_blob = stasis_message_data(msg);
-
- if (!ast_strlen_zero(queue_data->bridge_uniqueid)) {
- return;
- }
-
- if (!strcmp(enter_blob->channel->uniqueid, queue_data->caller_uniqueid)) {
- ast_string_field_set(queue_data, bridge_uniqueid,
- enter_blob->bridge->uniqueid);
- ast_debug(3, "Detected entry of caller channel %s into bridge %s\n",
- enter_blob->channel->name, queue_data->bridge_uniqueid);
- }
+ handle_bridge_enter(queue_data, msg);
} else if (ast_blind_transfer_type() == stasis_message_type(msg)) {
- struct ast_bridge_blob *blind_blob = stasis_message_data(msg);
- RAII_VAR(struct ast_channel_snapshot *, caller, NULL, ao2_cleanup);
- RAII_VAR(struct ast_channel_snapshot *, agent, NULL, ao2_cleanup);
-
- if (ast_json_integer_get(ast_json_object_get(blind_blob->blob, "result")) == AST_BRIDGE_TRANSFER_FAIL) {
- return;
- }
-
- ao2_lock(queue_data);
- if (ast_strlen_zero(queue_data->bridge_uniqueid) ||
- strcmp(queue_data->bridge_uniqueid, blind_blob->bridge->uniqueid)) {
- ao2_unlock(queue_data);
- return;
- }
-
- caller = ast_channel_snapshot_get_latest(queue_data->caller_uniqueid);
- agent = ast_channel_snapshot_get_latest(queue_data->agent_uniqueid);
-
- ao2_unlock(queue_data);
-
- ast_debug(3, "Detected blind transfer in queue %s\n", queue_data->queue->name);
- ast_queue_log(queue_data->queue->name, caller->uniqueid, queue_data->member->membername, "BLINDTRANSFER", "%s|%s|%ld|%ld|%d",
- ast_json_string_get(ast_json_object_get(blind_blob->blob, "exten")),
- ast_json_string_get(ast_json_object_get(blind_blob->blob, "context")),
- (long) queue_data->starttime - queue_data->holdstart,
- (long) time(NULL) - queue_data->starttime, queue_data->caller_pos);
-
- send_agent_complete(queue_data->queue->name, caller, agent, queue_data->member,
- queue_data->holdstart, queue_data->starttime, TRANSFER);
- update_queue(queue_data->queue, queue_data->member, queue_data->callcompletedinsl,
- time(NULL) - queue_data->starttime);
- remove_stasis_subscriptions(queue_data);
+ handle_blind_transfer(queue_data, msg);
} else if (ast_attended_transfer_type() == stasis_message_type(msg)) {
- struct ast_attended_transfer_message *atxfer_msg = stasis_message_data(msg);
- RAII_VAR(struct ast_channel_snapshot *, caller, NULL, ao2_cleanup);
- RAII_VAR(struct ast_channel_snapshot *, agent, NULL, ao2_cleanup);
-
- if (atxfer_msg->result == AST_BRIDGE_TRANSFER_FAIL ||
- atxfer_msg->dest_type == AST_ATTENDED_TRANSFER_DEST_THREEWAY) {
- return;
- }
-
- ao2_lock(queue_data);
-
- if ((!atxfer_msg->to_transferee.bridge_snapshot || strcmp(queue_data->bridge_uniqueid,
- atxfer_msg->to_transferee.bridge_snapshot->uniqueid)) &&
- (!atxfer_msg->to_transfer_target.bridge_snapshot || strcmp(queue_data->bridge_uniqueid,
- atxfer_msg->to_transfer_target.bridge_snapshot->uniqueid))) {
- ao2_unlock(queue_data);
- return;
- }
-
- caller = ast_channel_snapshot_get_latest(queue_data->caller_uniqueid);
- agent = ast_channel_snapshot_get_latest(queue_data->agent_uniqueid);
-
- ao2_unlock(queue_data);
-
- ast_debug(3, "Detected attended transfer in queue %s\n", queue_data->queue->name);
-
- log_attended_transfer(queue_data, caller, atxfer_msg);
-
- send_agent_complete(queue_data->queue->name, caller, agent, queue_data->member,
- queue_data->holdstart, queue_data->starttime, TRANSFER);
- update_queue(queue_data->queue, queue_data->member, queue_data->callcompletedinsl,
- time(NULL) - queue_data->starttime);
- remove_stasis_subscriptions(queue_data);
+ handle_attended_transfer(queue_data, msg);
}
}
More information about the asterisk-commits
mailing list