[asterisk-commits] mvanbaak: trunk r145915 - /trunk/apps/app_meetme.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 2 13:02:27 CDT 2008


Author: mvanbaak
Date: Thu Oct  2 13:02:26 2008
New Revision: 145915

URL: http://svn.digium.com/view/asterisk?view=rev&rev=145915
Log:
fix the 'meetme list', 'meetme list concise', 'meetme list $confno' and 'meetme list $confno concise' CLI commands

(closes issue #13586)
Reported by: john8675309
Help and feedback from eliel, thanks!

Modified:
    trunk/apps/app_meetme.c

Modified: trunk/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_meetme.c?view=diff&rev=145915&r1=145914&r2=145915
==============================================================================
--- trunk/apps/app_meetme.c (original)
+++ trunk/apps/app_meetme.c Thu Oct  2 13:02:26 2008
@@ -947,8 +947,7 @@
 			}
 			AST_LIST_UNLOCK(&confs);
 			return usr ? ast_strdup(usrno) : NULL;
-		} else if (strstr(line, "list") && (state == 0))
-			return ast_strdup("concise");
+		}
 	}
 
 	return NULL;
@@ -957,6 +956,7 @@
 static char *meetme_show_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	/* Process the command */
+	struct ast_conf_user *user;
 	struct ast_conference *cnf;
 	int hr, min, sec;
 	int i = 0, total = 0;
@@ -987,9 +987,9 @@
 		return CLI_FAILURE;
 	}
 
-	if (a->argc == 1 || (a->argc == 2 && !strcasecmp(a->argv[1], "concise"))) {
-		/* 'MeetMe': List all the conferences */	
-		int concise = (a->argc == 2 && !strcasecmp(a->argv[1], "concise"));
+	if (a->argc == 2 || (a->argc == 3 && !strcasecmp(a->argv[2], "concise"))) {
+		/* List all the conferences */	
+		int concise = (a->argc == 3 && !strcasecmp(a->argv[2], "concise"));
 		now = time(NULL);
 		AST_LIST_LOCK(&confs);
 		if (AST_LIST_EMPTY(&confs)) {
@@ -1032,107 +1032,12 @@
 		}
 		ast_free(cmdline);
 		return CLI_SUCCESS;
-	}
-	if (a->argc < 2) {
-		ast_free(cmdline);
-		return CLI_SHOWUSAGE;
-	}
-
-	ast_debug(1, "Cmdline: %s\n", cmdline->str);
-
-	admin_exec(NULL, cmdline->str);
-	ast_free(cmdline);
-
-	return CLI_SUCCESS;
-}
-
-
-static char *meetme_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-	/* Process the command */
-	struct ast_conference *cnf;
-	struct ast_conf_user *user;
-	int hr, min, sec;
-	int i = 0;
-	time_t now;
-	struct ast_str *cmdline = NULL;
-
-	switch (cmd) {
-	case CLI_INIT:
-		e->command = "meetme {lock|unlock|mute|unmute|kick}";
-		e->usage =
-			"Usage: meetme (un)lock|(un)mute|kick <confno> <usernumber>\n"
-			"       Executes a command for the conference or on a conferee\n";
-		return NULL;
-	case CLI_GENERATE:
-		return complete_meetmecmd(a->line, a->word, a->pos, a->n);
-	}
-
-	if (a->argc > 8)
-		ast_cli(a->fd, "Invalid Arguments.\n");
-	/* Check for length so no buffer will overflow... */
-	for (i = 0; i < a->argc; i++) {
-		if (strlen(a->argv[i]) > 100)
-			ast_cli(a->fd, "Invalid Arguments.\n");
-	}
-
-	/* Max confno length */
-	if (!(cmdline = ast_str_create(MAX_CONFNUM))) {
-		return CLI_FAILURE;
-	}
-
-	if (a->argc < 1) {
-		ast_free(cmdline);
-		return CLI_SHOWUSAGE;
-	}
-
-	ast_str_set(&cmdline, 0, "%s", a->argv[2]);	/* Argv 2: conference number */
-	if (strstr(a->argv[1], "lock")) {
-		if (strcmp(a->argv[1], "lock") == 0) {
-			/* Lock */
-			ast_str_append(&cmdline, 0, ",L");
-		} else {
-			/* Unlock */
-			ast_str_append(&cmdline, 0, ",l");
-		}
-	} else if (strstr(a->argv[1], "mute")) { 
-		if (a->argc < 4) {
-			ast_free(cmdline);
-			return CLI_SHOWUSAGE;
-		}
-		if (strcmp(a->argv[1], "mute") == 0) {
-			/* Mute */
-			if (strcmp(a->argv[3], "all") == 0) {
-				ast_str_append(&cmdline, 0, ",N");
-			} else {
-				ast_str_append(&cmdline, 0, ",M,%s", a->argv[3]);	
-			}
-		} else {
-			/* Unmute */
-			if (strcmp(a->argv[3], "all") == 0) {
-				ast_str_append(&cmdline, 0, ",n");
-			} else {
-				ast_str_append(&cmdline, 0, ",m,%s", a->argv[3]);
-			}
-		}
-	} else if (strcmp(a->argv[1], "kick") == 0) {
-		if (a->argc < 4) {
-			ast_free(cmdline);
-			return CLI_SHOWUSAGE;
-		}
-		if (strcmp(a->argv[3], "all") == 0) {
-			/* Kick all */
-			ast_str_append(&cmdline, 0, ",K");
-		} else {
-			/* Kick a single user */
-			ast_str_append(&cmdline, 0, ",k,%s", a->argv[3]);
-		}
 	} else if (strcmp(a->argv[1], "list") == 0) {
 		int concise = (a->argc == 4 && (!strcasecmp(a->argv[3], "concise")));
 		/* List all the users in a conference */
 		if (AST_LIST_EMPTY(&confs)) {
 			if (!concise) {
-				ast_cli(a->fd, "No active conferences.\n");
+				ast_cli(a->fd, "No active MeetMe conferences.\n");
 			}
 			ast_free(cmdline);
 			return CLI_SUCCESS;	
@@ -1187,6 +1092,97 @@
 		AST_LIST_UNLOCK(&confs);
 		ast_free(cmdline);
 		return CLI_SUCCESS;
+	}
+	if (a->argc < 2) {
+		ast_free(cmdline);
+		return CLI_SHOWUSAGE;
+	}
+
+	ast_debug(1, "Cmdline: %s\n", cmdline->str);
+
+	admin_exec(NULL, cmdline->str);
+	ast_free(cmdline);
+
+	return CLI_SUCCESS;
+}
+
+
+static char *meetme_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	/* Process the command */
+	struct ast_str *cmdline = NULL;
+	int i = 0;
+
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "meetme {lock|unlock|mute|unmute|kick}";
+		e->usage =
+			"Usage: meetme (un)lock|(un)mute|kick <confno> <usernumber>\n"
+			"       Executes a command for the conference or on a conferee\n";
+		return NULL;
+	case CLI_GENERATE:
+		return complete_meetmecmd(a->line, a->word, a->pos, a->n);
+	}
+
+	if (a->argc > 8)
+		ast_cli(a->fd, "Invalid Arguments.\n");
+	/* Check for length so no buffer will overflow... */
+	for (i = 0; i < a->argc; i++) {
+		if (strlen(a->argv[i]) > 100)
+			ast_cli(a->fd, "Invalid Arguments.\n");
+	}
+
+	/* Max confno length */
+	if (!(cmdline = ast_str_create(MAX_CONFNUM))) {
+		return CLI_FAILURE;
+	}
+
+	if (a->argc < 1) {
+		ast_free(cmdline);
+		return CLI_SHOWUSAGE;
+	}
+
+	ast_str_set(&cmdline, 0, "%s", a->argv[2]);	/* Argv 2: conference number */
+	if (strstr(a->argv[1], "lock")) {
+		if (strcmp(a->argv[1], "lock") == 0) {
+			/* Lock */
+			ast_str_append(&cmdline, 0, ",L");
+		} else {
+			/* Unlock */
+			ast_str_append(&cmdline, 0, ",l");
+		}
+	} else if (strstr(a->argv[1], "mute")) { 
+		if (a->argc < 4) {
+			ast_free(cmdline);
+			return CLI_SHOWUSAGE;
+		}
+		if (strcmp(a->argv[1], "mute") == 0) {
+			/* Mute */
+			if (strcmp(a->argv[3], "all") == 0) {
+				ast_str_append(&cmdline, 0, ",N");
+			} else {
+				ast_str_append(&cmdline, 0, ",M,%s", a->argv[3]);	
+			}
+		} else {
+			/* Unmute */
+			if (strcmp(a->argv[3], "all") == 0) {
+				ast_str_append(&cmdline, 0, ",n");
+			} else {
+				ast_str_append(&cmdline, 0, ",m,%s", a->argv[3]);
+			}
+		}
+	} else if (strcmp(a->argv[1], "kick") == 0) {
+		if (a->argc < 4) {
+			ast_free(cmdline);
+			return CLI_SHOWUSAGE;
+		}
+		if (strcmp(a->argv[3], "all") == 0) {
+			/* Kick all */
+			ast_str_append(&cmdline, 0, ",K");
+		} else {
+			/* Kick a single user */
+			ast_str_append(&cmdline, 0, ",k,%s", a->argv[3]);
+		}
 	} else {
 		ast_free(cmdline);
 		return CLI_SHOWUSAGE;




More information about the asterisk-commits mailing list