[asterisk-commits] dvossel: branch dvossel/hd_confbridge r310286 - in /team/dvossel/hd_confbridg...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 10 16:54:32 CST 2011


Author: dvossel
Date: Thu Mar 10 16:54:29 2011
New Revision: 310286

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=310286
Log:
Introduction of the dialplan_exec ConfBridge menu action.

By using the dialplan_exec menu action, any DTMF sequence
can be mapped to escape the user from the conference and
execute a specific context,exten,priority in the
dialplan.  Once the dialplan escapes, the user is put
back into the conference bridge.

Modified:
    team/dvossel/hd_confbridge/apps/app_confbridge.c
    team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c
    team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h
    team/dvossel/hd_confbridge/configs/confbridge.conf.sample

Modified: team/dvossel/hd_confbridge/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/app_confbridge.c?view=diff&rev=310286&r1=310285&r2=310286
==============================================================================
--- team/dvossel/hd_confbridge/apps/app_confbridge.c (original)
+++ team/dvossel/hd_confbridge/apps/app_confbridge.c Thu Mar 10 16:54:29 2011
@@ -749,6 +749,50 @@
 		conf_menu_entry_destroy(&new_menu_entry);
 	}
 	return 0;
+}
+
+static int action_dialplan_exec(struct ast_bridge_channel *bridge_channel, struct conf_menu_action *menu_action)
+{
+	struct ast_pbx_args args;
+	struct ast_pbx *pbx;
+	char *exten;
+	char *context;
+	int priority;
+	int res;
+
+	memset(&args, 0, sizeof(args));
+	args.no_hangup_chan = 1;
+
+	ast_channel_lock(bridge_channel->chan);
+
+	/*save off*/
+	exten = ast_strdupa(bridge_channel->chan->exten);
+	context = ast_strdupa(bridge_channel->chan->context);
+	priority = bridge_channel->chan->priority;
+	pbx = bridge_channel->chan->pbx;
+	bridge_channel->chan->pbx = NULL;
+
+	/*set new*/
+	ast_copy_string(bridge_channel->chan->exten, menu_action->data.dialplan_args.exten, sizeof(bridge_channel->chan->exten));
+	ast_copy_string(bridge_channel->chan->context, menu_action->data.dialplan_args.context, sizeof(bridge_channel->chan->context));
+	bridge_channel->chan->priority = menu_action->data.dialplan_args.priority;
+
+	ast_channel_unlock(bridge_channel->chan);
+
+	/*execute*/
+	res = ast_pbx_run_args(bridge_channel->chan, &args);
+
+	/*restore*/
+	ast_channel_lock(bridge_channel->chan);
+
+	ast_copy_string(bridge_channel->chan->exten, exten, sizeof(bridge_channel->chan->exten));
+	ast_copy_string(bridge_channel->chan->context, context, sizeof(bridge_channel->chan->context));
+	bridge_channel->chan->priority = priority;
+	bridge_channel->chan->pbx = pbx;
+
+	ast_channel_unlock(bridge_channel->chan);
+
+	return res;
 }
 
 static int execute_menu_entry(struct conference_bridge *conference_bridge,
@@ -794,6 +838,9 @@
 				menu_action->data.playback_file,
 				menu_entry->dtmf);
 			break;
+		case MENU_ACTION_DIALPLAN_EXEC:
+			res |= action_dialplan_exec(bridge_channel, menu_action);
+			break;
 		}
 	}
 	return res;

Modified: team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c?view=diff&rev=310286&r1=310285&r2=310286
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c Thu Mar 10 16:54:29 2011
@@ -259,6 +259,35 @@
 			return -1;
 		}
 		break;
+	case MENU_ACTION_DIALPLAN_EXEC:
+		if (!(ast_strlen_zero(databuf))) {
+			AST_DECLARE_APP_ARGS(args,
+				AST_APP_ARG(context);
+				AST_APP_ARG(exten);
+				AST_APP_ARG(priority);
+			);
+			AST_STANDARD_APP_ARGS(args, databuf);
+			if (!ast_strlen_zero(args.context)) {
+				ast_copy_string(menu_action->data.dialplan_args.context,
+					args.context,
+					sizeof(menu_action->data.dialplan_args.context));
+			}
+			if (!ast_strlen_zero(args.exten)) {
+				ast_copy_string(menu_action->data.dialplan_args.exten,
+					args.exten,
+					sizeof(menu_action->data.dialplan_args.exten));
+			}
+			menu_action->data.dialplan_args.priority = 1; /* 1 by default */
+			if (!ast_strlen_zero(args.priority) &&
+				(sscanf(args.priority, "%30u", &menu_action->data.dialplan_args.priority) != 1)) {
+				/* invalid priority */
+				ast_free(menu_action);
+				return -1;
+			}
+		} else {
+			ast_free(menu_action);
+			return -1;
+		}
 	};
 
 	AST_LIST_INSERT_HEAD(&menu_entry->actions, menu_action, action);
@@ -271,7 +300,7 @@
 	struct conf_menu_entry *menu_entry = ast_calloc(1, sizeof(*menu_entry));
 	int res = 0;
 	unsigned int action_len = strlen(action);
-	char *filename;
+	char *action_args;
 	char *tmp;
 
 	if (!(menu_entry)) {
@@ -288,20 +317,27 @@
 		res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_INCREASE_TALKING, NULL);
 	} else if (!strcasecmp(action, "decrease_talking_volume")) {
 		res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DECREASE_TALKING, NULL);
+	} else if (!strncasecmp(action, "dialplan_exec", 13)) {
+		action_args = ast_strdupa(action);
+		if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
+			*tmp = '\0';
+			action_args++;
+		}
+		res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DIALPLAN_EXEC, action_args);
 	} else if (action_len >= 21 && !strncasecmp(action, "playback_and_continue", 21)) {
-		filename = ast_strdupa(action);
-		if ((filename = strchr(action, '(')) && (tmp = strrchr(filename, ')'))) {
+		action_args = ast_strdupa(action);
+		if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
 			*tmp = '\0';
-			filename++;
-		}
-		res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PLAYBACK_AND_CONTINUE, filename);
+			action_args++;
+		}
+		res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PLAYBACK_AND_CONTINUE, action_args);
 	} else if (action_len >= 8 && !strncasecmp(action, "playback", 8)) {
-		filename = ast_strdupa(action);
-		if ((filename = strchr(action, '(')) && (tmp = strrchr(filename, ')'))) {
+		action_args = ast_strdupa(action);
+		if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
 			*tmp = '\0';
-			filename++;
-		}
-		res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PLAYBACK, filename);
+			action_args++;
+		}
+		res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PLAYBACK, action_args);
 	}
 
 	/* if adding any of the actions failed, bail */
@@ -574,8 +610,13 @@
 			case MENU_ACTION_PLAYBACK_AND_CONTINUE:
 				ast_cli(a->fd, "playback_and_continue(%s)", menu_action->data.playback_file);
 				break;
+			case MENU_ACTION_DIALPLAN_EXEC:
+				ast_cli(a->fd, "dialplan_exec(%s,%s,%d)",
+					menu_action->data.dialplan_args.context,
+					menu_action->data.dialplan_args.exten,
+					menu_action->data.dialplan_args.priority);
+				break;
 			}
-
 			action_num++;
 		}
 		ast_cli(a->fd,"\n");

Modified: team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h?view=diff&rev=310286&r1=310285&r2=310286
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h Thu Mar 10 16:54:29 2011
@@ -49,6 +49,7 @@
 	MENU_ACTION_DECREASE_LISTENING,
 	MENU_ACTION_INCREASE_TALKING,
 	MENU_ACTION_DECREASE_TALKING,
+	MENU_ACTION_DIALPLAN_EXEC,
 };
 
 /*! The conference menu action contains both
@@ -59,6 +60,11 @@
 	enum conf_menu_action_id id;
 	union {
 		char playback_file[256];
+		struct {
+			char context[AST_MAX_CONTEXT];
+			char exten[AST_MAX_EXTENSION];
+			int priority;
+		} dialplan_args;
 	} data;
 	AST_LIST_ENTRY(conf_menu_action) action;
 };

Modified: team/dvossel/hd_confbridge/configs/confbridge.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/configs/confbridge.conf.sample?view=diff&rev=310286&r1=310285&r2=310286
==============================================================================
--- team/dvossel/hd_confbridge/configs/confbridge.conf.sample (original)
+++ team/dvossel/hd_confbridge/configs/confbridge.conf.sample Thu Mar 10 16:54:29 2011
@@ -61,7 +61,12 @@
 ; increase_listening_volume ; Increases the channel's listening volume.
 ; decrease_talking_volume   ; Decreases the channel's talking volume.
 ; increase_talking_volume   ; Increases the channel's talking volume.
-
+;
+; dialplan_exec(context,exten,priority)  ; The dialplan_exec action allows a user
+                                         ; to escape from the conference and execute
+                                         ; commands in the dialplan.  Once the dialplan
+                                         ; exits the user will be put back into the
+                                         ; conference.  The possibilities are endless!
 [sample_user_menu]
 type=menu
 *=playback_and_continue(conf-usermenu)
@@ -71,3 +76,4 @@
 *7=decrease_talking_volume
 *9=increase_talking_volume
 
+




More information about the asterisk-commits mailing list