--- app_meetme.c 2004-08-09 11:34:35.000000000 +0200 +++ app_meetme.c.new 2004-08-09 11:33:52.000000000 +0200 @@ -129,6 +129,7 @@ AST_MUTEX_DEFINE_STATIC(conflock); +static int conf_exec(struct ast_channel *chan, void *data); static int admin_exec(struct ast_channel *chan, void *data); @@ -283,6 +284,7 @@ struct ast_conference *cnf; struct ast_conf_user *user; int hr, min, sec; + int res; int i = 0, total = 0; time_t now; char *header_format = "%-14s %-14s %-10s %-8s %-8s\n"; @@ -322,6 +324,11 @@ ast_cli(fd, "* Total number of MeetMe users: %d\n", total); return RESULT_SUCCESS; } + if (strcmp(argv[1], "create") == 0) { + res = conf_exec(NULL, "|ed"); + ast_cli(fd, "Create conference %d\n", res); + return RESULT_SUCCESS; + } if (argc < 3) return RESULT_SHOWUSAGE; strncpy(cmdline, argv[2], sizeof(cmdline) - 1); /* Argv 2: conference number */ @@ -389,13 +396,13 @@ } static char *complete_confcmd(char *line, char *word, int pos, int state) { - #define CONF_COMMANDS 6 + #define CONF_COMMANDS 7 int which = 0, x = 0; struct ast_conference *cnf = NULL; struct ast_conf_user *usr = NULL; char *confno = NULL; char usrno[50] = ""; - char cmds[CONF_COMMANDS][20] = {"lock", "unlock", "mute", "unmute", "kick", "list"}; + char cmds[CONF_COMMANDS][20] = {"lock", "unlock", "mute", "unmute", "kick", "list", "create"}; char *myline; if (pos == 1) { @@ -407,7 +414,7 @@ } } } - } else if (pos == 2) { + } else if (pos == 2 && (!strstr(line, cmds[6]))) { /* Conference Number */ ast_mutex_lock(&conflock); cnf = confs; @@ -420,7 +427,7 @@ } ast_mutex_unlock(&conflock); return cnf ? strdup(cnf->confno) : NULL; - } else if (pos == 3) { + } else if (pos == 3 && (!strstr(line, cmds[6]))) { /* User Number || Conf Command option*/ if (strstr(line, "mute") || strstr(line, "kick")) { if ((state == 0) && (strstr(line, "kick")) && !(strncasecmp(word, "all", strlen(word)))) { @@ -464,6 +471,7 @@ static char conf_usage[] = "Usage: meetme (un)lock|(un)mute|kick|list \n" +" create\n" " Executes a command for the conference or on a conferee\n"; static struct ast_cli_entry cli_conf = { @@ -1175,7 +1182,7 @@ notdata = data; } LOCAL_USER_ADD(u); - if (chan->_state != AST_STATE_UP) + if (chan && chan->_state != AST_STATE_UP) ast_answer(chan); info = ast_strdupa((char *)notdata); @@ -1320,21 +1327,23 @@ } /* Not found? */ - if (ast_strlen_zero(confno)) { - res = ast_streamfile(chan, "conf-noempty", chan->language); - if (!res) - ast_waitstream(chan, ""); - } else { - if (sscanf(confno, "%d", &confno_int) == 1) { - res = ast_streamfile(chan, "conf-enteringno", chan->language); - if (!res) { - ast_waitstream(chan, ""); - res = ast_say_digits(chan, confno_int, "", chan->language); - } - } else { - ast_log(LOG_ERROR, "Could not scan confno '%s'\n", confno); - } - } + if (chan) { + if (ast_strlen_zero(confno)) { + res = ast_streamfile(chan, "conf-noempty", chan->language); + if (!res) + ast_waitstream(chan, ""); + } else { + if (sscanf(confno, "%d", &confno_int) == 1) { + res = ast_streamfile(chan, "conf-enteringno", chan->language); + if (!res) { + ast_waitstream(chan, ""); + res = ast_say_digits(chan, confno_int, "", chan->language); + } + } else { + ast_log(LOG_ERROR, "Could not scan confno '%s'\n", confno); + } + } + } } while (allowretry && (ast_strlen_zero(confno)) && (++retrycnt < 4)) { /* Prompt user for conference number */ @@ -1349,6 +1358,15 @@ if (!ast_strlen_zero(confno)) { /* Check the validity of the conference */ cnf = find_conf(chan, confno, 1, dynamic, the_pin); + if (!chan) { + if (!cnf) { + ast_log(LOG_WARNING, "Unable to create a new conference\n"); + res = -1; + break; + } + res = atoi(confno); + break; + } if (!cnf) { res = ast_streamfile(chan, "conf-invalid", chan->language); if (!res)