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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 3 11:46:36 CST 2011


Author: dvossel
Date: Thu Mar  3 11:46:32 2011
New Revision: 309343

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=309343
Log:
Shell for parsing and applying custom DTMF menu's to ConfBridge users

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

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=309343&r1=309342&r2=309343
==============================================================================
--- team/dvossel/hd_confbridge/apps/app_confbridge.c (original)
+++ team/dvossel/hd_confbridge/apps/app_confbridge.c Thu Mar  3 11:46:32 2011
@@ -546,7 +546,6 @@
 	char *parse;
 	const char *b_profile_name = "default_bridge";
 	const char *u_profile_name = "default_user";
-	const char *menu_name = "default_menu";
 	struct conference_bridge *conference_bridge = NULL;
 	struct conference_bridge_user conference_bridge_user = {
 		.chan = chan,
@@ -581,11 +580,18 @@
 	}
 	conf_find_user_profile(u_profile_name, &conference_bridge_user.u_profile);
 
+	/* Always initialize the features structure, we are in most cases always going to need it. */
+	ast_bridge_features_init(&conference_bridge_user.features);
 	/* menu name */
 	if (args.argc > 3 && !ast_strlen_zero(args.menu_name)) {
-		menu_name = args.menu_name;
-	}
-	conf_find_menu(menu_name, &conference_bridge_user.dtmf_menu);
+		ast_copy_string(conference_bridge_user.menu_name, args.menu_name, sizeof(conference_bridge_user.menu_name));
+		if (conf_set_menu_to_user(conference_bridge_user.menu_name, &conference_bridge_user)) {
+			ast_log(LOG_WARNING, "Conference menu %s does not exist and can not be applied to confbridge user.\n",
+				args.menu_name);
+			ast_bridge_features_cleanup(&conference_bridge_user.features);
+			return -1;
+		}
+	}
 
 	/* Look for a conference bridge matching the provided name */
 	if (!(conference_bridge = join_conference_bridge(args.conf_name, &conference_bridge_user))) {
@@ -596,16 +602,7 @@
 	volume_adjustments[0] = ast_audiohook_volume_get(chan, AST_AUDIOHOOK_DIRECTION_READ);
 	volume_adjustments[1] = ast_audiohook_volume_get(chan, AST_AUDIOHOOK_DIRECTION_WRITE);
 
-	/* Always initialize the features structure, we are in most cases always going to need it. */
-	ast_bridge_features_init(&conference_bridge_user.features);
-
-	/* If the menu option is enabled provide a user or admin menu as a custom feature hook */
-//todohere once the custom menu is created, add the hooks here
-//	if (ast_test_flag(&conference_bridge_user.flags, OPTION_MENU)) {
-//		ast_bridge_features_hook(&conference_bridge_user.features, "#", menu_callback, &conference_bridge_user);
-//	}
-
-	/* If the caller should be joined already muted, make it so */
+		/* If the caller should be joined already muted, make it so */
 	if (ast_test_flag(&conference_bridge_user.u_profile, USER_OPT_STARTMUTED)) {
 		conference_bridge_user.features.mute = 1;
 	}
@@ -780,7 +777,7 @@
 			ast_cli(a->fd, "%-29s ", participant->chan->name);
 			ast_cli(a->fd, "%-17s", participant->u_profile.name);
 			ast_cli(a->fd, "%-17s", participant->b_profile.name);
-			ast_cli(a->fd, "%-17s", participant->dtmf_menu.name);
+			ast_cli(a->fd, "%-17s", participant->menu_name);
 			ast_cli(a->fd, "\n");
 		}
 		ao2_unlock(bridge);

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=309343&r1=309342&r2=309343
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c Thu Mar  3 11:46:32 2011
@@ -2,6 +2,8 @@
  * Asterisk -- An open source telephony toolkit.
  *
  * Copyright (C) 2011, Digium, Inc.
+ *
+ * David Vossel <dvossel at digium.com>
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact
@@ -12,6 +14,13 @@
  * This program is free software, distributed under the terms of
  * the GNU General Public License Version 2. See the LICENSE file
  * at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief ConfBridge config parser
+ *
+ * \author David Vossel <dvossel at digium.com>
  */
 
 #include "asterisk.h"
@@ -220,6 +229,14 @@
 	return 0;
 }
 
+static int add_menu_item(struct conf_menu *menu, const char *dtmf, const char *action)
+{
+//todohere parse the dtmf and action
+	if (!strcasecmp(action, "toggle_mute")) {
+
+	}
+	return 0;
+}
 static int parse_menu(const char *cat, struct ast_config *cfg)
 {
 	struct ast_variable *var;
@@ -237,12 +254,12 @@
 	}
 
 	ao2_lock(menu);
-	/* set defaults */
-	//todohere put default settings
+	/* this isn't freeing the menu, just destroying the menu list so it can be rebuilt.*/
+	menu_destructor(menu);
 	for (var = ast_variable_browse(cfg, cat); var; var = var->next) {
 		if (!strcasecmp(var->name, "type")) {
 			continue;
-		} else {
+		} else if (add_menu_item(menu, var->name, var->value)) {
 			ast_log(LOG_WARNING, "Unknown option '%s' at line %d of %s is not supported.\n",
 				var->name, var->lineno, CONF_CONFIG);
 		}
@@ -413,7 +430,8 @@
 }
 static char *handle_cli_confbridge_list_menus(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	struct conf_menu menu;
+	struct conf_menu tmp;
+	struct conf_menu *menu;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -432,13 +450,18 @@
 		return CLI_SHOWUSAGE;
 	}
 
-	if (!(conf_find_menu(a->argv[3], &menu))) {
+	ast_copy_string(tmp.name, a->argv[3], sizeof(tmp.name));
+	if (!(menu = ao2_find(menus, &tmp, OBJ_POINTER))) {
 		ast_cli(a->fd, "No conference menu named '%s' found!\n", a->argv[3]);
 		return CLI_SUCCESS;
 	}
-	ast_cli(a->fd,"Name: %s\n", menu.name);
+	ao2_lock(menu);
+
+	ast_cli(a->fd,"Name: %s\n", menu->name);
 	ast_cli(a->fd,"\n");
 
+	ao2_unlock(menu);
+	ao2_ref(menu, -1);
 	return CLI_SUCCESS;
 }
 
@@ -573,19 +596,21 @@
 	return result;
 }
 
-const struct conf_menu *conf_find_menu(const char *menu_name, struct conf_menu *result)
+int conf_set_menu_to_user(const char *menu_name, struct conference_bridge_user *conference_bridge_user)
 {
 	struct conf_menu tmp;
 	struct conf_menu *tmp2;
 	ast_copy_string(tmp.name, menu_name, sizeof(tmp.name));
 
 	if (!(tmp2 = ao2_find(menus, &tmp, OBJ_POINTER))) {
-		return NULL;
+		return -1;
 	}
 	ao2_lock(tmp2);
-	memcpy(result, tmp2, sizeof(*result));
+//todohere add feature hooks to user.
+
+
 	ao2_unlock(tmp2);
 	ao2_ref(tmp2, -1);
 
-	return result;
-}
+	return 0;
+}

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=309343&r1=309342&r2=309343
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h Thu Mar  3 11:46:32 2011
@@ -87,8 +87,8 @@
 struct conference_bridge_user {
 	struct conference_bridge *conference_bridge; /*!< Conference bridge they are participating in */
 	struct bridge_profile b_profile;             /*!< The Bridge Configuration Profile */
-	struct user_profile u_profile;             /*!< The User Configuration Profile */
-	struct conf_menu dtmf_menu;                  /*!< The User's DTMF menu */
+	struct user_profile u_profile;               /*!< The User Configuration Profile */
+	char menu_name[64];                          /*!< The name of the DTMF menu assigned to this user */
 	struct ast_channel *chan;                    /*!< Asterisk channel participating */
 	char *opt_args[OPTION_ARRAY_SIZE];           /*!< Arguments to options passed when application was called */
 	struct ast_bridge_features features;         /*!< Bridge features structure */
@@ -120,10 +120,10 @@
 const struct bridge_profile *conf_find_bridge_profile(const char *bridge_profile_name, struct bridge_profile *result);
 
 /*!
- * \brief find a conference DTMF menu given the menu's name
+ * \brief Set a DTMF menu to a conference user by menu name.
  *
- * \retval menu on success
- * \retval NULL on failure
+ * \retval 0 on success, menu was found and set
+ * \retval -1 on error, menu was not found
  */
-const struct conf_menu *conf_find_menu(const char *menu_name, struct conf_menu *result);
+int conf_set_menu_to_user(const char *menu_name, struct conference_bridge_user *conference_bridge_user);
 #endif




More information about the asterisk-commits mailing list