[svn-commits] mmichelson: branch mmichelson/atxfer_features r393483 - in /team/mmichelson/a...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jul 2 15:23:28 CDT 2013


Author: mmichelson
Date: Tue Jul  2 15:23:27 2013
New Revision: 393483

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=393483
Log:
Move blind transfer over to bridging_basic.c

This allows for copies of certain functions to be removed.


Modified:
    team/mmichelson/atxfer_features/bridges/bridge_builtin_features.c
    team/mmichelson/atxfer_features/main/bridging_basic.c

Modified: team/mmichelson/atxfer_features/bridges/bridge_builtin_features.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/bridges/bridge_builtin_features.c?view=diff&rev=393483&r1=393482&r2=393483
==============================================================================
--- team/mmichelson/atxfer_features/bridges/bridge_builtin_features.c (original)
+++ team/mmichelson/atxfer_features/bridges/bridge_builtin_features.c Tue Jul  2 15:23:27 2013
@@ -54,150 +54,6 @@
 #include "asterisk/mixmonitor.h"
 #include "asterisk/audiohook.h"
 
-/*!
- * \brief Helper function that presents dialtone and grabs extension
- *
- * \retval 0 on success
- * \retval -1 on failure
- */
-static int grab_transfer(struct ast_channel *chan, char *exten, size_t exten_len, const char *context)
-{
-	int res;
-	int digit_timeout;
-	RAII_VAR(struct ast_features_xfer_config *, xfer_cfg, NULL, ao2_cleanup);
-
-	ast_channel_lock(chan);
-	xfer_cfg = ast_get_chan_features_xfer_config(chan);
-	if (!xfer_cfg) {
-		ast_log(LOG_ERROR, "Unable to get transfer configuration\n");
-		ast_channel_unlock(chan);
-		return -1;
-	}
-	digit_timeout = xfer_cfg->transferdigittimeout;
-	ast_channel_unlock(chan);
-
-	/* Play the simple "transfer" prompt out and wait */
-	res = ast_stream_and_wait(chan, "pbx-transfer", AST_DIGIT_ANY);
-	ast_stopstream(chan);
-	if (res < 0) {
-		/* Hangup or error */
-		return -1;
-	}
-	if (res) {
-		/* Store the DTMF digit that interrupted playback of the file. */
-		exten[0] = res;
-	}
-
-	/* Drop to dialtone so they can enter the extension they want to transfer to */
-	res = ast_app_dtget(chan, context, exten, exten_len, exten_len - 1, digit_timeout);
-	if (res < 0) {
-		/* Hangup or error */
-		res = -1;
-	} else if (!res) {
-		/* 0 for invalid extension dialed. */
-		if (ast_strlen_zero(exten)) {
-			ast_debug(1, "%s dialed no digits.\n", ast_channel_name(chan));
-		} else {
-			ast_debug(1, "%s dialed '%s@%s' does not exist.\n",
-				ast_channel_name(chan), exten, context);
-		}
-		ast_stream_and_wait(chan, "pbx-invalid", AST_DIGIT_NONE);
-		res = -1;
-	} else {
-		/* Dialed extension is valid. */
-		res = 0;
-	}
-	return res;
-}
-
-static void copy_caller_data(struct ast_channel *dest, struct ast_channel *caller)
-{
-	ast_channel_lock_both(caller, dest);
-	ast_connected_line_copy_from_caller(ast_channel_connected(dest), ast_channel_caller(caller));
-	ast_channel_inherit_variables(caller, dest);
-	ast_channel_datastore_inherit(caller, dest);
-	ast_channel_unlock(dest);
-	ast_channel_unlock(caller);
-}
-
-/*!
- * \internal
- * \brief Determine the transfer context to use.
- * \since 12.0.0
- *
- * \param transferer Channel initiating the transfer.
- * \param context User supplied context if available.  May be NULL.
- *
- * \return The context to use for the transfer.
- */
-static const char *get_transfer_context(struct ast_channel *transferer, const char *context)
-{
-	if (!ast_strlen_zero(context)) {
-		return context;
-	}
-	context = pbx_builtin_getvar_helper(transferer, "TRANSFER_CONTEXT");
-	if (!ast_strlen_zero(context)) {
-		return context;
-	}
-	context = ast_channel_macrocontext(transferer);
-	if (!ast_strlen_zero(context)) {
-		return context;
-	}
-	context = ast_channel_context(transferer);
-	if (!ast_strlen_zero(context)) {
-		return context;
-	}
-	return "default";
-}
-
-static void blind_transfer_cb(struct ast_channel *new_channel, void *user_data,
-		enum ast_transfer_type transfer_type)
-{
-	struct ast_channel *transferer_channel = user_data;
-
-	if (transfer_type == AST_BRIDGE_TRANSFER_MULTI_PARTY) {
-		copy_caller_data(new_channel, transferer_channel);
-	}
-}
-
-/*! \brief Internal built in feature for blind transfers */
-static int feature_blind_transfer(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *hook_pvt)
-{
-	char exten[AST_MAX_EXTENSION] = "";
-	struct ast_bridge_features_blind_transfer *blind_transfer = hook_pvt;
-	const char *context;
-	char *goto_on_blindxfr;
-
-	ast_bridge_channel_write_hold(bridge_channel, NULL);
-
-	ast_channel_lock(bridge_channel->chan);
-	context = ast_strdupa(get_transfer_context(bridge_channel->chan,
-		blind_transfer ? blind_transfer->context : NULL));
-	goto_on_blindxfr = ast_strdupa(S_OR(pbx_builtin_getvar_helper(bridge_channel->chan,
-		"GOTO_ON_BLINDXFR"), ""));
-	ast_channel_unlock(bridge_channel->chan);
-
-	/* Grab the extension to transfer to */
-	if (grab_transfer(bridge_channel->chan, exten, sizeof(exten), context)) {
-		ast_bridge_channel_write_unhold(bridge_channel);
-		return 0;
-	}
-
-	if (!ast_strlen_zero(goto_on_blindxfr)) {
-		ast_debug(1, "After transfer, transferer %s goes to %s\n",
-				ast_channel_name(bridge_channel->chan), goto_on_blindxfr);
-		ast_after_bridge_set_go_on(bridge_channel->chan, NULL, NULL, 0, goto_on_blindxfr);
-	}
-
-	if (ast_bridge_transfer_blind(0, bridge_channel->chan, exten, context, blind_transfer_cb,
-			bridge_channel->chan) != AST_BRIDGE_TRANSFER_SUCCESS &&
-			!ast_strlen_zero(goto_on_blindxfr)) {
-		ast_after_bridge_goto_discard(bridge_channel->chan);
-	}
-
-	return 0;
-}
-
 static void stop_automonitor(struct ast_bridge_channel *bridge_channel, struct ast_channel *peer_chan, struct ast_features_general_config *features_cfg)
 {
 	const char *stop_message;
@@ -515,7 +371,6 @@
 
 static int load_module(void)
 {
-	ast_bridge_features_register(AST_BRIDGE_BUILTIN_BLINDTRANSFER, feature_blind_transfer, NULL);
 	ast_bridge_features_register(AST_BRIDGE_BUILTIN_HANGUP, feature_hangup, NULL);
 	ast_bridge_features_register(AST_BRIDGE_BUILTIN_AUTOMON, feature_automonitor, NULL);
 	ast_bridge_features_register(AST_BRIDGE_BUILTIN_AUTOMIXMON, feature_automixmonitor, NULL);

Modified: team/mmichelson/atxfer_features/main/bridging_basic.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/main/bridging_basic.c?view=diff&rev=393483&r1=393482&r2=393483
==============================================================================
--- team/mmichelson/atxfer_features/main/bridging_basic.c (original)
+++ team/mmichelson/atxfer_features/main/bridging_basic.c Tue Jul  2 15:23:27 2013
@@ -226,9 +226,6 @@
  *
  * \retval 0 on success
  * \retval -1 on failure
- */
-/* XXX This is a copy of a function in bridges/bridge_builtin_features.c. It likely should not
- * exist in two places
  */
 static int grab_transfer(struct ast_channel *chan, char *exten, size_t exten_len, const char *context)
 {
@@ -280,9 +277,6 @@
 	return res;
 }
 
-/* XXX This is a copy of a function in bridges/bridge_builtin_features.c. It likely should not
- * exist in two places
- */
 static void copy_caller_data(struct ast_channel *dest, struct ast_channel *caller)
 {
 	ast_channel_lock_both(caller, dest);
@@ -324,9 +318,6 @@
  * \param context User supplied context if available.  May be NULL.
  *
  * \return The context to use for the transfer.
- */
-/* XXX This is a copy of a function in bridges/bridge_builtin_features.c. It likely should not
- * exist in two places
  */
 static const char *get_transfer_context(struct ast_channel *transferer, const char *context)
 {
@@ -2528,6 +2519,55 @@
 	return 0;
 }
 
+static void blind_transfer_cb(struct ast_channel *new_channel, void *user_data,
+		enum ast_transfer_type transfer_type)
+{
+	struct ast_channel *transferer_channel = user_data;
+
+	if (transfer_type == AST_BRIDGE_TRANSFER_MULTI_PARTY) {
+		copy_caller_data(new_channel, transferer_channel);
+	}
+}
+
+/*! \brief Internal built in feature for blind transfers */
+static int feature_blind_transfer(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *hook_pvt)
+{
+	char exten[AST_MAX_EXTENSION] = "";
+	struct ast_bridge_features_blind_transfer *blind_transfer = hook_pvt;
+	const char *context;
+	char *goto_on_blindxfr;
+
+	ast_bridge_channel_write_hold(bridge_channel, NULL);
+
+	ast_channel_lock(bridge_channel->chan);
+	context = ast_strdupa(get_transfer_context(bridge_channel->chan,
+		blind_transfer ? blind_transfer->context : NULL));
+	goto_on_blindxfr = ast_strdupa(S_OR(pbx_builtin_getvar_helper(bridge_channel->chan,
+		"GOTO_ON_BLINDXFR"), ""));
+	ast_channel_unlock(bridge_channel->chan);
+
+	/* Grab the extension to transfer to */
+	if (grab_transfer(bridge_channel->chan, exten, sizeof(exten), context)) {
+		ast_bridge_channel_write_unhold(bridge_channel);
+		return 0;
+	}
+
+	if (!ast_strlen_zero(goto_on_blindxfr)) {
+		ast_debug(1, "After transfer, transferer %s goes to %s\n",
+				ast_channel_name(bridge_channel->chan), goto_on_blindxfr);
+		ast_after_bridge_set_go_on(bridge_channel->chan, NULL, NULL, 0, goto_on_blindxfr);
+	}
+
+	if (ast_bridge_transfer_blind(0, bridge_channel->chan, exten, context, blind_transfer_cb,
+			bridge_channel->chan) != AST_BRIDGE_TRANSFER_SUCCESS &&
+			!ast_strlen_zero(goto_on_blindxfr)) {
+		ast_after_bridge_goto_discard(bridge_channel->chan);
+	}
+
+	return 0;
+}
+
+
 struct ast_bridge_methods ast_bridge_basic_v_table;
 struct ast_bridge_methods personality_normal_v_table;
 struct ast_bridge_methods personality_atxfer_v_table;
@@ -2666,5 +2706,6 @@
 	personality_atxfer_v_table.pull = bridge_personality_atxfer_pull;
 
 	ast_bridge_features_register(AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER, feature_attended_transfer, NULL);
-}
-
+	ast_bridge_features_register(AST_BRIDGE_BUILTIN_BLINDTRANSFER, feature_blind_transfer, NULL);
+}
+




More information about the svn-commits mailing list