[svn-commits] dvossel: branch dvossel/hd_confbridge r311553 - /team/dvossel/hd_confbridge/a...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Mar 22 16:38:35 CDT 2011


Author: dvossel
Date: Tue Mar 22 16:38:31 2011
New Revision: 311553

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=311553
Log:
mute and unmute cli commands for ConfBridge

Modified:
    team/dvossel/hd_confbridge/apps/app_confbridge.c

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=311553&r1=311552&r2=311553
==============================================================================
--- team/dvossel/hd_confbridge/apps/app_confbridge.c (original)
+++ team/dvossel/hd_confbridge/apps/app_confbridge.c Tue Mar 22 16:38:31 2011
@@ -1470,14 +1470,14 @@
 	struct conference_bridge tmp;
 	struct conference_bridge_user *participant = NULL;
 
-        switch (cmd) {
-        case CLI_INIT:
-                e->command = "confbridge kick";
-                e->usage =
-                        "Usage: confbridge kick <name> <channel>\n"
-                        "       Kicks a channel out of the conference bridge.\n";
-                return NULL;
-        case CLI_GENERATE:
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "confbridge kick";
+		e->usage =
+			"Usage: confbridge kick <conference> <channel>\n"
+			"       Kicks a channel out of the conference bridge.\n";
+		return NULL;
+	case CLI_GENERATE:
 		if (a->pos == 2) {
 			return complete_confbridge_name(a->line, a->word, a->pos, a->n);
 		}
@@ -1486,8 +1486,8 @@
 			return complete_confbridge_channel(a->line, a->word, a->pos, a->n);
 		}
 		*/
-                return NULL;
-        }
+		return NULL;
+	}
 
 	if (a->argc != 4) {
 		return CLI_SHOWUSAGE;
@@ -1522,19 +1522,19 @@
 	struct conference_bridge tmp;
 	struct conference_bridge_user *participant = NULL;
 
-        switch (cmd) {
-        case CLI_INIT:
-                e->command = "confbridge list";
-                e->usage =
-                        "Usage: confbridge list [<name>]\n"
-                        "       Lists all currently active conference bridges.\n";
-                return NULL;
-        case CLI_GENERATE:
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "confbridge list";
+		e->usage =
+			"Usage: confbridge list [<name>]\n"
+			"       Lists all currently active conference bridges.\n";
+		return NULL;
+	case CLI_GENERATE:
 		if (a->pos == 2) {
 			return complete_confbridge_name(a->line, a->word, a->pos, a->n);
 		}
-                return NULL;
-        }
+		return NULL;
+	}
 
 	if (a->argc == 2) {
 		ast_cli(a->fd, "Conference Bridge Name           Users  Marked Locked?\n");
@@ -1573,9 +1573,87 @@
 	return CLI_SHOWUSAGE;
 }
 
+static int cli_mute_unmute_helper(int mute, struct ast_cli_args *a)
+{
+	struct conference_bridge *bridge = NULL;
+	struct conference_bridge tmp;
+	struct conference_bridge_user *participant = NULL;
+
+	ast_copy_string(tmp.name, a->argv[2], sizeof(tmp.name));
+	bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	if (!bridge) {
+		ast_cli(a->fd, "No conference bridge named '%s' found!\n", a->argv[2]);
+		return -1;
+	}
+	ao2_lock(bridge);
+	AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
+		if (!strncmp(a->argv[3], participant->chan->name, strlen(participant->chan->name))) {
+			break;
+		}
+	}
+	if (participant) {
+		ast_cli(a->fd, "%s %s from confbridge %s\n", mute ? "Muting" : "Unmuting", participant->chan->name, bridge->name);
+		participant->features.mute = mute;
+	} else {
+		ast_cli(a->fd, "No channel named '%s' found in conference %s\n", a->argv[3], a->argv[2]);
+	}
+	ao2_unlock(bridge);
+	ao2_ref(bridge, -1);
+
+	return 0;
+}
+
+static char *handle_cli_confbridge_mute(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "confbridge mute";
+		e->usage =
+			"Usage: confbridge mute <conference> <channel>\n";
+		return NULL;
+	case CLI_GENERATE:
+		if (a->pos == 2) {
+			return complete_confbridge_name(a->line, a->word, a->pos, a->n);
+		}
+		return NULL;
+	}
+	if (a->argc != 4) {
+		return CLI_SHOWUSAGE;
+	}
+
+	cli_mute_unmute_helper(1, a);
+
+	return CLI_SUCCESS;
+}
+
+static char *handle_cli_confbridge_unmute(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "confbridge unmute";
+		e->usage =
+			"Usage: confbridge unmute <conference> <channel>\n";
+		return NULL;
+	case CLI_GENERATE:
+		if (a->pos == 2) {
+			return complete_confbridge_name(a->line, a->word, a->pos, a->n);
+		}
+		return NULL;
+	}
+	if (a->argc != 4) {
+		return CLI_SHOWUSAGE;
+	}
+
+	cli_mute_unmute_helper(0, a);
+
+	return CLI_SUCCESS;
+}
+
 static struct ast_cli_entry cli_confbridge[] = {
 	AST_CLI_DEFINE(handle_cli_confbridge_list, "List conference bridges and participants."),
 	AST_CLI_DEFINE(handle_cli_confbridge_kick, "Kick participants out of conference bridges."),
+	AST_CLI_DEFINE(handle_cli_confbridge_mute, "Mute a participant."),
+	AST_CLI_DEFINE(handle_cli_confbridge_unmute, "Mute a participant."),
 };
 static struct ast_custom_function confbridge_function = {
 	.name = "CONFBRIDGE",




More information about the svn-commits mailing list