[asterisk-commits] irroot: branch irroot/distrotech-customers-10 r338495 - in /team/irroot/distr...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 29 14:11:11 CDT 2011


Author: irroot
Date: Thu Sep 29 14:11:07 2011
New Revision: 338495

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=338495
Log:
Redo pickup macro patch to use channel datastore
Add documentation

Modified:
    team/irroot/distrotech-customers-10/apps/app_directed_pickup.c
    team/irroot/distrotech-customers-10/configs/features.conf.sample
    team/irroot/distrotech-customers-10/include/asterisk/global_datastores.h
    team/irroot/distrotech-customers-10/main/channel.c
    team/irroot/distrotech-customers-10/main/features.c
    team/irroot/distrotech-customers-10/main/global_datastores.c

Modified: team/irroot/distrotech-customers-10/apps/app_directed_pickup.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-10/apps/app_directed_pickup.c?view=diff&rev=338495&r1=338494&r2=338495
==============================================================================
--- team/irroot/distrotech-customers-10/apps/app_directed_pickup.c (original)
+++ team/irroot/distrotech-customers-10/apps/app_directed_pickup.c Thu Sep 29 14:11:07 2011
@@ -73,7 +73,10 @@
 			tries to find a channel which has defined a <variable>PICKUPMARK</variable>
 			channel variable with the same value as <replaceable>extension</replaceable>
 			(in this example, <literal>10</literal>). When no parameter is specified, the application
-			will pickup a channel matching the pickup group of the active channel.</para>
+			will pickup a channel matching the pickup group of the active channel.
+			If the channel variable <variable>PICKUP_BRIDGE_MACRO</variable> is set this macro will run
+			on the picked up channel using the channel variable <variable>PICKUP_BRIDGE_MACRO_ARGS</variable>
+			as arguments.</para>
 		</description>
 	</application>
 	<application name="PickupChan" language="en_US">
@@ -94,7 +97,10 @@
 			</parameter>
 		</syntax>
 		<description>
-			<para>This will pickup a specified <replaceable>channel</replaceable> if ringing.</para>
+			<para>This will pickup a specified <replaceable>channel</replaceable> if ringing.
+			If the channel variable <variable>PICKUP_BRIDGE_MACRO</variable> is set this macro will run
+			on the picked up channel using the channel variable <variable>PICKUP_BRIDGE_MACRO_ARGS</variable>
+			as arguments.</para>
 		</description>
 	</application>
  ***/

Modified: team/irroot/distrotech-customers-10/configs/features.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-10/configs/features.conf.sample?view=diff&rev=338495&r1=338494&r2=338495
==============================================================================
--- team/irroot/distrotech-customers-10/configs/features.conf.sample (original)
+++ team/irroot/distrotech-customers-10/configs/features.conf.sample Thu Sep 29 14:11:07 2011
@@ -79,6 +79,10 @@
 ;xfersound = beep               ; to indicate an attended transfer is complete
 ;xferfailsound = beeperr        ; to indicate a failed transfer
 ;pickupexten = *8               ; Configure the pickup extension. (default is *8)
+                                ; You can set a channel variable PICKUP_BRIDGE_MACRO
+                                ; to run a macro on a channel that is been picked up
+                                ; arguments can be passed to it by setting PICKUP_BRIDGE_MACRO_ARGS.
+                                ;
 ;pickupsound = beep             ; to indicate a successful pickup (default: no sound)
 ;pickupfailsound = beeperr      ; to indicate that the pickup failed (default: no sound)
 ;featuredigittimeout = 1000     ; Max time (ms) between digits for

Modified: team/irroot/distrotech-customers-10/include/asterisk/global_datastores.h
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-10/include/asterisk/global_datastores.h?view=diff&rev=338495&r1=338494&r2=338495
==============================================================================
--- team/irroot/distrotech-customers-10/include/asterisk/global_datastores.h (original)
+++ team/irroot/distrotech-customers-10/include/asterisk/global_datastores.h Thu Sep 29 14:11:07 2011
@@ -28,6 +28,7 @@
 
 extern const struct ast_datastore_info dialed_interface_info;
 extern const struct ast_datastore_info secure_call_info;
+extern const struct ast_datastore_info pickup_target_info;
 
 struct ast_dialed_interface {
 	AST_LIST_ENTRY(ast_dialed_interface) list;

Modified: team/irroot/distrotech-customers-10/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-10/main/channel.c?view=diff&rev=338495&r1=338494&r2=338495
==============================================================================
--- team/irroot/distrotech-customers-10/main/channel.c (original)
+++ team/irroot/distrotech-customers-10/main/channel.c Thu Sep 29 14:11:07 2011
@@ -7446,6 +7446,7 @@
 	char callee_warning = 0;
 	const char *bridge_macro;
 	const char *bridge_macro_args;
+	struct ast_datastore *ds_bridge_macro;
 
 	*fo = NULL;
 
@@ -7526,15 +7527,29 @@
 	ast_indicate(c0, AST_CONTROL_SRCUPDATE);
 	ast_indicate(c1, AST_CONTROL_SRCUPDATE);
 
-	bridge_macro = pbx_builtin_getvar_helper(c0, "PICKUP_BRIDGE_MACRO");
-	if (!ast_strlen_zero(bridge_macro)) {
-		bridge_macro_args = pbx_builtin_getvar_helper(c0, "PICKUP_BRIDGE_MACRO_ARGS");
-		ast_app_run_macro(c0, c1, bridge_macro, bridge_macro_args);
-	}
-	bridge_macro = pbx_builtin_getvar_helper(c1, "PICKUP_BRIDGE_MACRO");
-	if (!ast_strlen_zero(bridge_macro)) {
-		bridge_macro_args = pbx_builtin_getvar_helper(c1, "PICKUP_BRIDGE_MACRO_ARGS");
-		ast_app_run_macro(c1, c0, bridge_macro, bridge_macro_args);
+	if ((ds_bridge_macro = ast_channel_datastore_find(c0, &pickup_target_info, NULL))) {
+		bridge_macro = pbx_builtin_getvar_helper(c0, "PICKUP_BRIDGE_MACRO");
+		if (!ast_strlen_zero(bridge_macro)) {
+			bridge_macro_args = pbx_builtin_getvar_helper(c0, "PICKUP_BRIDGE_MACRO_ARGS");
+			ast_app_run_macro(c0, c1, bridge_macro, bridge_macro_args);
+		}
+		ast_channel_lock(c0);
+		if (!ast_channel_datastore_remove(c0, ds_bridge_macro)) {
+			ast_datastore_free(ds_bridge_macro);
+		}
+		ast_channel_unlock(c0);
+	}
+	if ((ds_bridge_macro = ast_channel_datastore_find(c1, &pickup_target_info, NULL))) {
+		bridge_macro = pbx_builtin_getvar_helper(c1, "PICKUP_BRIDGE_MACRO");
+		if (!ast_strlen_zero(bridge_macro)) {
+			bridge_macro_args = pbx_builtin_getvar_helper(c1, "PICKUP_BRIDGE_MACRO_ARGS");
+			ast_app_run_macro(c1, c0, bridge_macro, bridge_macro_args);
+		}
+		ast_channel_lock(c1);
+		if (!ast_channel_datastore_remove(c1, ds_bridge_macro)) {
+			ast_datastore_free(ds_bridge_macro);
+		}
+		ast_channel_unlock(c1);
 	}
 
 	for (/* ever */;;) {

Modified: team/irroot/distrotech-customers-10/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-10/main/features.c?view=diff&rev=338495&r1=338494&r2=338495
==============================================================================
--- team/irroot/distrotech-customers-10/main/features.c (original)
+++ team/irroot/distrotech-customers-10/main/features.c Thu Sep 29 14:11:07 2011
@@ -7053,6 +7053,7 @@
 	struct ast_party_connected_line connected_caller;
 	struct ast_channel *chans[2] = { chan, target };
 	struct ast_datastore *ds_pickup;
+	struct ast_datastore *ds_bridge_macro;
 	const char *chan_name;/*!< A masquerade changes channel names. */
 	const char *target_name;/*!< A masquerade changes channel names. */
 	int res = -1;
@@ -7068,6 +7069,15 @@
 		return -1;
 	}
 	ast_channel_datastore_add(target, ds_pickup);
+
+	/* Mark the target so a macro can be run on it if needed. */
+	ds_bridge_macro = ast_datastore_alloc(&pickup_target_info, NULL);
+	if (ds_bridge_macro) {
+		ast_channel_datastore_add(target, ds_bridge_macro);
+	} else {
+		ast_log(LOG_WARNING,
+			"Unable to create channel datastore on '%s' for running macro\n", target_name);
+	}
 
 	ast_party_connected_line_init(&connected_caller);
 	ast_party_connected_line_copy(&connected_caller, &target->connected);
@@ -7121,6 +7131,9 @@
 	ast_channel_lock(target);
 	if (!ast_channel_datastore_remove(target, ds_pickup)) {
 		ast_datastore_free(ds_pickup);
+	}
+	if (res && ds_bridge_macro && !ast_channel_datastore_remove(target, ds_bridge_macro)) {
+		ast_datastore_free(ds_bridge_macro);
 	}
 
 	return res;

Modified: team/irroot/distrotech-customers-10/main/global_datastores.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-10/main/global_datastores.c?view=diff&rev=338495&r1=338494&r2=338495
==============================================================================
--- team/irroot/distrotech-customers-10/main/global_datastores.c (original)
+++ team/irroot/distrotech-customers-10/main/global_datastores.c Thu Sep 29 14:11:07 2011
@@ -110,3 +110,7 @@
 	.destroy = secure_call_store_destroy,
 	.duplicate = secure_call_store_duplicate,
 };
+
+const struct ast_datastore_info pickup_target_info = {
+	.type = "pickup-call",
+};




More information about the asterisk-commits mailing list