[asterisk-commits] rmudgett: trunk r381644 - /trunk/apps/app_confbridge.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Feb 18 13:12:14 CST 2013


Author: rmudgett
Date: Mon Feb 18 13:12:11 2013
New Revision: 381644

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=381644
Log:
confbridge: Add flags column to CLI "confbridge list <conference>"

* Added the following flags to the CLI "confbridge list <conference>" output:
A - The user is an admin
M - The user is a marked user
W - The user must wait for a marked user to join
E - The user will be kicked after the last marked user leaves the conference
w - The user is waiting for a marked user to join

* Added the following header to the AMI ConfbridgeList events:
WaitMarked, EndMarked, and Waiting.

(closes issue AST-1101)
Reported by: John Bigelow
Patches:
      confbridge-show-admin3.txt (license #5091) patch uploaded by John Bigelow
      Modified

Modified:
    trunk/apps/app_confbridge.c

Modified: trunk/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_confbridge.c?view=diff&rev=381644&r1=381643&r2=381644
==============================================================================
--- trunk/apps/app_confbridge.c (original)
+++ trunk/apps/app_confbridge.c Mon Feb 18 13:12:11 2013
@@ -2224,9 +2224,31 @@
 	return CLI_SUCCESS;
 }
 
-static void handle_cli_confbridge_list_item(struct ast_cli_args *a, struct conference_bridge_user *participant)
-{
+static void handle_cli_confbridge_list_item(struct ast_cli_args *a, struct conference_bridge_user *participant, int waiting)
+{
+	char flag_str[5 + 1];/* Max flags + terminator */
+	int pos = 0;
+
+	/* Build flags column string. */
+	if (ast_test_flag(&participant->u_profile, USER_OPT_ADMIN)) {
+		flag_str[pos++] = 'A';
+	}
+	if (ast_test_flag(&participant->u_profile, USER_OPT_MARKEDUSER)) {
+		flag_str[pos++] = 'M';
+	}
+	if (ast_test_flag(&participant->u_profile, USER_OPT_WAITMARKED)) {
+		flag_str[pos++] = 'W';
+	}
+	if (ast_test_flag(&participant->u_profile, USER_OPT_ENDMARKED)) {
+		flag_str[pos++] = 'E';
+	}
+	if (waiting) {
+		flag_str[pos++] = 'w';
+	}
+	flag_str[pos] = '\0';
+
 	ast_cli(a->fd, "%-29s ", ast_channel_name(participant->chan));
+	ast_cli(a->fd, "%-5s ", flag_str);
 	ast_cli(a->fd, "%-17s", participant->u_profile.name);
 	ast_cli(a->fd, "%-17s", participant->b_profile.name);
 	ast_cli(a->fd, "%-17s", participant->menu_name);
@@ -2243,7 +2265,17 @@
 		e->command = "confbridge list";
 		e->usage =
 			"Usage: confbridge list [<name>]\n"
-			"       Lists all currently active conference bridges.\n";
+			"       Lists all currently active conference bridges or a specific conference bridge.\n"
+			"\n"
+			"       When a conference bridge name is provided, flags may be shown for users. Below\n"
+			"       are the flags and what they represent.\n" 
+			"\n"
+			"       Flags:\n"
+			"         A - The user is an admin\n"
+			"         M - The user is a marked user\n"
+			"         W - The user must wait for a marked user to join\n"
+			"         E - The user will be kicked after the last marked user leaves the conference\n"
+			"         w - The user is waiting for a marked user to join\n";
 		return NULL;
 	case CLI_GENERATE:
 		if (a->pos == 2) {
@@ -2276,14 +2308,14 @@
 			ast_cli(a->fd, "No conference bridge named '%s' found!\n", a->argv[2]);
 			return CLI_SUCCESS;
 		}
-		ast_cli(a->fd, "Channel                       User Profile     Bridge Profile   Menu             CallerID\n");
-		ast_cli(a->fd, "============================= ================ ================ ================ ================\n");
+		ast_cli(a->fd, "Channel                       Flags User Profile     Bridge Profile   Menu             CallerID\n");
+		ast_cli(a->fd, "============================= ===== ================ ================ ================ ================\n");
 		ao2_lock(bridge);
 		AST_LIST_TRAVERSE(&bridge->active_list, participant, list) {
-			handle_cli_confbridge_list_item(a, participant);
+			handle_cli_confbridge_list_item(a, participant, 0);
 		}
 		AST_LIST_TRAVERSE(&bridge->waiting_list, participant, list) {
-			handle_cli_confbridge_list_item(a, participant);
+			handle_cli_confbridge_list_item(a, participant, 1);
 		}
 		ao2_unlock(bridge);
 		ao2_ref(bridge, -1);
@@ -2582,7 +2614,7 @@
 	.read = func_confbridge_info,
 };
 
-static void action_confbridgelist_item(struct mansession *s, const char *id_text, struct conference_bridge *bridge, struct conference_bridge_user *participant)
+static void action_confbridgelist_item(struct mansession *s, const char *id_text, struct conference_bridge *bridge, struct conference_bridge_user *participant, int waiting)
 {
 	astman_append(s,
 		"Event: ConfbridgeList\r\n"
@@ -2593,6 +2625,9 @@
 		"Channel: %s\r\n"
 		"Admin: %s\r\n"
 		"MarkedUser: %s\r\n"
+		"WaitMarked: %s\r\n"
+		"EndMarked: %s\r\n"
+		"Waiting: %s\r\n"
 		"\r\n",
 		id_text,
 		bridge->name,
@@ -2600,19 +2635,23 @@
 		S_COR(ast_channel_caller(participant->chan)->id.name.valid, ast_channel_caller(participant->chan)->id.name.str, "<no name>"),
 		ast_channel_name(participant->chan),
 		ast_test_flag(&participant->u_profile, USER_OPT_ADMIN) ? "Yes" : "No",
-		ast_test_flag(&participant->u_profile, USER_OPT_MARKEDUSER) ? "Yes" : "No");
+		ast_test_flag(&participant->u_profile, USER_OPT_MARKEDUSER) ? "Yes" : "No",
+		ast_test_flag(&participant->u_profile, USER_OPT_WAITMARKED) ? "Yes" : "No",
+		ast_test_flag(&participant->u_profile, USER_OPT_ENDMARKED) ? "Yes" : "No",
+		waiting ? "Yes" : "No");
 }
 
 static int action_confbridgelist(struct mansession *s, const struct message *m)
 {
 	const char *actionid = astman_get_header(m, "ActionID");
 	const char *conference = astman_get_header(m, "Conference");
-	struct conference_bridge_user *participant = NULL;
-	struct conference_bridge *bridge = NULL;
+	struct conference_bridge_user *participant;
+	struct conference_bridge *bridge;
 	struct conference_bridge tmp;
-	char id_text[80] = "";
+	char id_text[80];
 	int total = 0;
 
+	id_text[0] = '\0';
 	if (!ast_strlen_zero(actionid)) {
 		snprintf(id_text, sizeof(id_text), "ActionID: %s\r\n", actionid);
 	}
@@ -2636,11 +2675,11 @@
 	ao2_lock(bridge);
 	AST_LIST_TRAVERSE(&bridge->active_list, participant, list) {
 		total++;
-		action_confbridgelist_item(s, id_text, bridge, participant);
+		action_confbridgelist_item(s, id_text, bridge, participant, 0);
 	}
 	AST_LIST_TRAVERSE(&bridge->waiting_list, participant, list) {
 		total++;
-		action_confbridgelist_item(s, id_text, bridge, participant);
+		action_confbridgelist_item(s, id_text, bridge, participant, 1);
 	}
 	ao2_unlock(bridge);
 	ao2_ref(bridge, -1);




More information about the asterisk-commits mailing list