Index: apps/app_meetme.c =================================================================== --- apps/app_meetme.c (revision 278024) +++ apps/app_meetme.c (working copy) @@ -3436,7 +3436,7 @@ } static struct ast_conference *find_conf_realtime(struct ast_channel *chan, char *confno, int make, int dynamic, - char *dynamic_pin, size_t pin_buf_len, int refcount, struct ast_flags *confflags, int *too_early) + char *dynamic_pin, size_t pin_buf_len, int refcount, struct ast_flags *confflags, int *too_early, char **optargs) { struct ast_variable *var, *origvar; struct ast_conference *cnf; @@ -3550,6 +3550,8 @@ cnf = build_conf(confno, pin ? pin : "", pinadmin ? pinadmin : "", make, dynamic, refcount, chan); if (cnf) { + struct ast_flags tmp_flags; + cnf->maxusers = maxusers; cnf->endalert = endalert; cnf->endtime = endtime.tv_sec; @@ -3559,6 +3561,10 @@ cnf->recordingfilename = ast_strdup(recordingfilename); cnf->recordingformat = ast_strdup(recordingformat); + /* Parse the other options into confflags */ + ast_app_parse_options(meetme_opts, &tmp_flags, optargs, useropts); + ast_copy_flags(confflags, &tmp_flags, tmp_flags.flags); + if (strchr(cnf->useropts, 'r')) { if (ast_strlen_zero(recordingfilename)) { /* If the recordingfilename in the database is empty, use the channel definition or use the default. */ ast_channel_lock(chan); @@ -3853,7 +3859,6 @@ */ ast_copy_string(confno, confno_tmp, sizeof(confno)); break; - /* XXX the map is not complete (but we do have a confno) */ } } } @@ -3862,6 +3867,42 @@ } ast_config_destroy(cfg); } + + if (ast_strlen_zero(confno) && (cfg = ast_load_realtime_multientry("meetme", "confno LIKE", "%", SENTINEL))) { + const char *catg; + for (catg = ast_category_browse(cfg, NULL); catg; catg = ast_category_browse(cfg, catg)) { + const char *confno_tmp = ast_variable_retrieve(cfg, catg, "confno"); + const char *pin_tmp = ast_variable_retrieve(cfg, catg, "pin"); + if (ast_strlen_zero(confno_tmp)) { + continue; + } + if (!dynamic) { + int found = 0; + /* For static: run through the list and see if this conference is empty */ + AST_LIST_LOCK(&confs); + AST_LIST_TRAVERSE(&confs, cnf, list) { + if (!strcmp(confno_tmp, cnf->confno)) { + /* The conference exists, therefore it's not empty */ + found = 1; + break; + } + } + AST_LIST_UNLOCK(&confs); + if (!found) { + /* At this point, we have a confno_tmp (realtime conference) that is empty */ + if ((empty_no_pin && ast_strlen_zero(pin_tmp)) || (!empty_no_pin)) { + /* Case 1: empty_no_pin and pin is nonexistent (NULL) + * Case 2: empty_no_pin and pin is blank (but not NULL) + * Case 3: not empty_no_pin + */ + ast_copy_string(confno, confno_tmp, sizeof(confno)); + break; + } + } + } + } + ast_config_destroy(cfg); + } } /* Select first conference number not in use */ @@ -3915,7 +3956,7 @@ int too_early = 0; cnf = find_conf_realtime(chan, confno, 1, dynamic, - the_pin, sizeof(the_pin), 1, &confflags,&too_early); + the_pin, sizeof(the_pin), 1, &confflags, &too_early, optargs); if (rt_schedule && too_early) allowretry = 0; }