return 0;
}
+static int kick_conference_participant(struct conference_bridge *bridge, const char *channel)
+{
+ struct conference_bridge_user *participant = NULL;
+
+ ao2_lock(bridge);
+ AST_LIST_TRAVERSE(&bridge->active_list, participant, list) {
+ if (!strcasecmp(ast_channel_name(participant->chan), channel)) {
+ participant->kicked = 1;
+ ast_bridge_remove(bridge->bridge, participant->chan);
+ ao2_unlock(bridge);
+ return 0;
+ }
+ }
+ AST_LIST_TRAVERSE(&bridge->waiting_list, participant, list) {
+ if (!strcasecmp(ast_channel_name(participant->chan), channel)) {
+ participant->kicked = 1;
+ ast_bridge_remove(bridge->bridge, participant->chan);
+ ao2_unlock(bridge);
+ return 0;
+ }
+ }
+ ao2_unlock(bridge);
+
+ return -1;
+}
+
static char *complete_confbridge_name(const char *line, const char *word, int pos, int state)
{
int which = 0;
return res;
}
+static char *complete_confbridge_participant(const char *bridge_name, const char *line, const char *word, int pos, int state)
+{
+ int which = 0;
+ RAII_VAR(struct conference_bridge *, bridge, NULL, ao2_cleanup);
+ struct conference_bridge tmp;
+ struct conference_bridge_user *participant;
+ char *res = NULL;
+ int wordlen = strlen(word);
+
+ ast_copy_string(tmp.name, bridge_name, sizeof(tmp.name));
+ bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+ if (!bridge) {
+ return NULL;
+ }
+
+ ao2_lock(bridge);
+ AST_LIST_TRAVERSE(&bridge->active_list, participant, list) {
+ if (!strncasecmp(ast_channel_name(participant->chan), word, wordlen) && ++which > state) {
+ res = ast_strdup(ast_channel_name(participant->chan));
+ ao2_unlock(bridge);
+ return res;
+ }
+ }
+
+ AST_LIST_TRAVERSE(&bridge->waiting_list, participant, list) {
+ if (!strncasecmp(ast_channel_name(participant->chan), word, wordlen) && ++which > state) {
+ res = ast_strdup(ast_channel_name(participant->chan));
+ ao2_unlock(bridge);
+ return res;
+ }
+ }
+ ao2_unlock(bridge);
+
+ return NULL;
+}
+
static char *handle_cli_confbridge_kick(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct conference_bridge *bridge = NULL;
struct conference_bridge tmp;
- struct conference_bridge_user *participant = NULL;
switch (cmd) {
case CLI_INIT:
if (a->pos == 2) {
return complete_confbridge_name(a->line, a->word, a->pos, a->n);
}
- /*
if (a->pos == 3) {
- return complete_confbridge_channel(a->line, a->word, a->pos, a->n);
+ return complete_confbridge_participant(a->argv[2], a->line, a->word, a->pos, a->n);
}
- */
return NULL;
}
ast_cli(a->fd, "No conference bridge named '%s' found!\n", a->argv[2]);
return CLI_SUCCESS;
}
- ao2_lock(bridge);
- AST_LIST_TRAVERSE(&bridge->active_list, participant, list) {
- if (!strncmp(a->argv[3], ast_channel_name(participant->chan), strlen(ast_channel_name(participant->chan)))) {
- break;
- }
- }
- if (participant) {
- ast_cli(a->fd, "Kicking %s from confbridge %s\n", ast_channel_name(participant->chan), bridge->name);
- participant->kicked = 1;
- ast_bridge_remove(bridge->bridge, participant->chan);
+ if (kick_conference_participant(bridge, a->argv[3])) {
+ ast_cli(a->fd, "No participant named '%s' found!\n", a->argv[3]);
+ return CLI_SUCCESS;
}
- ao2_unlock(bridge);
ao2_ref(bridge, -1);
+ ast_cli(a->fd, "Participant '%s' kicked out of conference '%s'\n", a->argv[3], a->argv[2]);
return CLI_SUCCESS;
}
+static void handle_cli_confbridge_list_item(struct ast_cli_args *a, struct conference_bridge_user *participant)
+{
+ ast_cli(a->fd, "%-29s ", ast_channel_name(participant->chan));
+ 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);
+ ast_cli(a->fd, "%-17s", S_COR(ast_channel_caller(participant->chan)->id.number.valid, ast_channel_caller(participant->chan)->id.number.str, "<unknown>"));
+ ast_cli(a->fd, "\n");
+}
+
static char *handle_cli_confbridge_list(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct ao2_iterator i;
ast_cli(a->fd, "================================ ====== ====== ========\n");
i = ao2_iterator_init(conference_bridges, 0);
while ((bridge = ao2_iterator_next(&i))) {
- ast_cli(a->fd, "%-32s %6i %6i %s\n", bridge->name, bridge->activeusers, bridge->markedusers, (bridge->locked ? "locked" : "unlocked"));
+ ast_cli(a->fd, "%-32s %6i %6i %s\n", bridge->name, bridge->activeusers + bridge->waitingusers, bridge->markedusers, (bridge->locked ? "locked" : "unlocked"));
ao2_ref(bridge, -1);
}
ao2_iterator_destroy(&i);
ast_cli(a->fd, "============================= ================ ================ ================ ================\n");
ao2_lock(bridge);
AST_LIST_TRAVERSE(&bridge->active_list, participant, list) {
- ast_cli(a->fd, "%-29s ", ast_channel_name(participant->chan));
- 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);
- ast_cli(a->fd, "%-17s", S_COR(ast_channel_caller(participant->chan)->id.number.valid, ast_channel_caller(participant->chan)->id.number.str, "<unknown>"));
- ast_cli(a->fd, "\n");
+ handle_cli_confbridge_list_item(a, participant);
+ }
+ AST_LIST_TRAVERSE(&bridge->waiting_list, participant, list) {
+ handle_cli_confbridge_list_item(a, participant);
}
ao2_unlock(bridge);
ao2_ref(bridge, -1);
case CLI_INIT:
e->command = "confbridge mute";
e->usage =
- "Usage: confbridge mute <conference> <channel>\n";
+ "Usage: confbridge mute <conference> <channel>\n"
+ " Mute a channel in a conference.\n";
return NULL;
case CLI_GENERATE:
if (a->pos == 2) {
return complete_confbridge_name(a->line, a->word, a->pos, a->n);
}
+ if (a->pos == 3) {
+ return complete_confbridge_participant(a->argv[2], a->line, a->word, a->pos, a->n);
+ }
return NULL;
}
if (a->argc != 4) {
case CLI_INIT:
e->command = "confbridge unmute";
e->usage =
- "Usage: confbridge unmute <conference> <channel>\n";
+ "Usage: confbridge unmute <conference> <channel>\n"
+ " Unmute a channel in a conference.\n";
return NULL;
case CLI_GENERATE:
if (a->pos == 2) {
return complete_confbridge_name(a->line, a->word, a->pos, a->n);
}
+ if (a->pos == 3) {
+ return complete_confbridge_participant(a->argv[2], a->line, a->word, a->pos, a->n);
+ }
return NULL;
}
if (a->argc != 4) {
case CLI_INIT:
e->command = "confbridge lock";
e->usage =
- "Usage: confbridge lock <conference>\n";
+ "Usage: confbridge lock <conference>\n"
+ " Lock a conference. While locked, no new non-admins\n"
+ " may join the conference.\n";
return NULL;
case CLI_GENERATE:
if (a->pos == 2) {
case CLI_INIT:
e->command = "confbridge unlock";
e->usage =
- "Usage: confbridge unlock <conference>\n";
+ "Usage: confbridge unlock <conference>\n"
+ " Unlock a previously locked conference.\n";
return NULL;
case CLI_GENERATE:
if (a->pos == 2) {
case CLI_INIT:
e->command = "confbridge record stop";
e->usage =
- "Usage: confbridge record stop <conference>\n";
+ "Usage: confbridge record stop <conference>\n"
+ " Stop a previously started recording.\n";
return NULL;
case CLI_GENERATE:
if (a->pos == 3) {
.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)
+{
+ astman_append(s,
+ "Event: ConfbridgeList\r\n"
+ "%s"
+ "Conference: %s\r\n"
+ "CallerIDNum: %s\r\n"
+ "CallerIDName: %s\r\n"
+ "Channel: %s\r\n"
+ "Admin: %s\r\n"
+ "MarkedUser: %s\r\n"
+ "\r\n",
+ id_text,
+ bridge->name,
+ S_COR(ast_channel_caller(participant->chan)->id.number.valid, ast_channel_caller(participant->chan)->id.number.str, "<unknown>"),
+ 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");
+}
+
static int action_confbridgelist(struct mansession *s, const struct message *m)
{
const char *actionid = astman_get_header(m, "ActionID");
ao2_lock(bridge);
AST_LIST_TRAVERSE(&bridge->active_list, participant, list) {
total++;
- astman_append(s,
- "Event: ConfbridgeList\r\n"
- "%s"
- "Conference: %s\r\n"
- "CallerIDNum: %s\r\n"
- "CallerIDName: %s\r\n"
- "Channel: %s\r\n"
- "Admin: %s\r\n"
- "MarkedUser: %s\r\n"
- "\r\n",
- id_text,
- bridge->name,
- S_COR(ast_channel_caller(participant->chan)->id.number.valid, ast_channel_caller(participant->chan)->id.number.str, "<unknown>"),
- 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");
+ action_confbridgelist_item(s, id_text, bridge, participant);
+ }
+ AST_LIST_TRAVERSE(&bridge->waiting_list, participant, list) {
+ total++;
+ action_confbridgelist_item(s, id_text, bridge, participant);
}
ao2_unlock(bridge);
ao2_ref(bridge, -1);
"\r\n",
id_text,
bridge->name,
- bridge->activeusers,
+ bridge->activeusers + bridge->waitingusers,
bridge->markedusers,
bridge->locked ? "Yes" : "No");
ao2_unlock(bridge);
{
const char *conference = astman_get_header(m, "Conference");
const char *channel = astman_get_header(m, "Channel");
- struct conference_bridge_user *participant = NULL;
struct conference_bridge *bridge = NULL;
struct conference_bridge tmp;
int found = 0;
astman_send_error(s, m, "No active conferences.");
return 0;
}
+
ast_copy_string(tmp.name, conference, sizeof(tmp.name));
bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
if (!bridge) {
return 0;
}
- ao2_lock(bridge);
- AST_LIST_TRAVERSE(&bridge->active_list, participant, list) {
- if (!strcasecmp(ast_channel_name(participant->chan), channel)) {
- participant->kicked = 1;
- ast_bridge_remove(bridge->bridge, participant->chan);
- found = 1;
- break;
- }
- }
- ao2_unlock(bridge);
+ found = !kick_conference_participant(bridge, channel);
ao2_ref(bridge, -1);
if (found) {
AST_LIST_TRAVERSE(&bridge->active_list, participant, list) {
count++;
}
+ AST_LIST_TRAVERSE(&bridge->waiting_list, participant, list) {
+ count++;
+ }
} else if (!strncasecmp(args.type, "admins", 6)) {
AST_LIST_TRAVERSE(&bridge->active_list, participant, list) {
if (ast_test_flag(&participant->u_profile, USER_OPT_ADMIN)) {