Skip to content

Commit 3543787

Browse files
InterLinked1gtjoseph
authored andcommitted
app_confbridge: New ConfKick() application
Adds a new ConfKick() application, which may be used to kick a specific channel, all channels, or all non-admin channels from a specified conference bridge, similar to existing CLI and AMI commands. ASTERISK-29446 Change-Id: I5d96b683880bfdd27b2ab1c3f2e897c5046ded9b
1 parent 1b38e89 commit 3543787

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

Diff for: apps/app_confbridge.c

+81
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,37 @@
124124
</variable>
125125
</variablelist>
126126
</description>
127+
<see-also>
128+
<ref type="application">ConfKick</ref>
129+
<ref type="function">CONFBRIDGE</ref>
130+
<ref type="function">CONFBRIDGE_INFO</ref>
131+
</see-also>
132+
</application>
133+
<application name="ConfKick" language="en_US">
134+
<synopsis>
135+
Kicks channel(s) from the requested ConfBridge.
136+
</synopsis>
137+
<syntax>
138+
<parameter name="conference" required="true" />
139+
<parameter name="channel">
140+
<para>The channel to kick, <literal>all</literal>
141+
to kick all users, or <literal>participants</literal>
142+
to kick all non-admin participants. Default is all.</para>
143+
</parameter>
144+
</syntax>
145+
<description>
146+
<para>Kicks the requested channel(s) from a conference bridge.</para>
147+
<variablelist>
148+
<variable name="CONFKICKSTATUS">
149+
<value name="FAILURE">
150+
Could not kick any users with the provided arguments.
151+
</value>
152+
<value name="SUCCESS">
153+
Successfully kicked users from specified conference bridge.
154+
</value>
155+
</variable>
156+
</variablelist>
157+
</description>
127158
<see-also>
128159
<ref type="application">ConfBridge</ref>
129160
<ref type="function">CONFBRIDGE</ref>
@@ -426,6 +457,7 @@
426457
*/
427458

428459
static const char app[] = "ConfBridge";
460+
static const char app2[] = "ConfKick";
429461

430462
/*! Number of buckets our conference bridges container can have */
431463
#define CONFERENCE_BRIDGE_BUCKETS 53
@@ -4221,6 +4253,53 @@ static int func_confbridge_info(struct ast_channel *chan, const char *cmd, char
42214253
return 0;
42224254
}
42234255

4256+
static int confkick_exec(struct ast_channel *chan, const char *data)
4257+
{
4258+
char *parse;
4259+
struct confbridge_conference *conference;
4260+
int not_found;
4261+
4262+
AST_DECLARE_APP_ARGS(args,
4263+
AST_APP_ARG(confbridge);
4264+
AST_APP_ARG(channel);
4265+
);
4266+
4267+
if (ast_strlen_zero(data)) {
4268+
ast_log(LOG_WARNING, "No conference bridge specified.\n");
4269+
pbx_builtin_setvar_helper(chan, "CONFKICKSTATUS", "FAILURE");
4270+
return 0;
4271+
}
4272+
4273+
parse = ast_strdupa(data);
4274+
AST_STANDARD_APP_ARGS(args, parse);
4275+
4276+
conference = ao2_find(conference_bridges, args.confbridge, OBJ_KEY);
4277+
if (!conference) {
4278+
ast_log(LOG_WARNING, "No conference bridge named '%s' found!\n", args.confbridge);
4279+
pbx_builtin_setvar_helper(chan, "CONFKICKSTATUS", "FAILURE");
4280+
return 0;
4281+
}
4282+
if (ast_strlen_zero(args.channel)) {
4283+
not_found = kick_conference_participant(conference, "all");
4284+
} else {
4285+
not_found = kick_conference_participant(conference, args.channel);
4286+
}
4287+
4288+
ao2_ref(conference, -1);
4289+
if (not_found) {
4290+
if (ast_strlen_zero(args.channel) || !strcasecmp("all", args.channel) || !strcasecmp("participants", args.channel)) {
4291+
ast_log(LOG_WARNING, "No participants found in conference bridge '%s'!\n", args.confbridge);
4292+
} else {
4293+
ast_log(LOG_WARNING, "No participant named '%s' found in conference bridge '%s'!\n", args.channel, args.confbridge);
4294+
}
4295+
pbx_builtin_setvar_helper(chan, "CONFKICKSTATUS", "FAILURE");
4296+
return 0;
4297+
}
4298+
ast_debug(1, "Kicked '%s' out of conference '%s'\n", args.channel, args.confbridge);
4299+
pbx_builtin_setvar_helper(chan, "CONFKICKSTATUS", "SUCCESS");
4300+
return 0;
4301+
}
4302+
42244303
void conf_add_user_active(struct confbridge_conference *conference, struct confbridge_user *user)
42254304
{
42264305
AST_LIST_INSERT_TAIL(&conference->active_list, user, list);
@@ -4314,6 +4393,7 @@ static int register_channel_tech(struct ast_channel_tech *tech)
43144393
static int unload_module(void)
43154394
{
43164395
ast_unregister_application(app);
4396+
ast_unregister_application(app2);
43174397

43184398
ast_custom_function_unregister(&confbridge_function);
43194399
ast_custom_function_unregister(&confbridge_info_function);
@@ -4384,6 +4464,7 @@ static int load_module(void)
43844464
res |= manager_confbridge_init();
43854465

43864466
res |= ast_register_application_xml(app, confbridge_exec);
4467+
res |= ast_register_application_xml(app2, confkick_exec);
43874468

43884469
res |= ast_custom_function_register_escalating(&confbridge_function, AST_CFE_WRITE);
43894470
res |= ast_custom_function_register(&confbridge_info_function);

Diff for: doc/CHANGES-staging/app_confkick.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Subject: New ConfKick application
2+
3+
Adds a ConfKick() application, which allows
4+
a specific channel, all users, or all non-admin
5+
users to be kicked from a conference bridge.
6+

0 commit comments

Comments
 (0)