[Asterisk-code-review] app_confbridge: New ConfKick() application (asterisk[16])
N A
asteriskteam at digium.com
Sun May 23 20:19:52 CDT 2021
N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/15930 )
Change subject: app_confbridge: New ConfKick() application
......................................................................
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
---
M apps/app_confbridge.c
A doc/CHANGES-staging/app_confkick.txt
2 files changed, 89 insertions(+), 0 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/30/15930/1
diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c
index 457870a..f048d6c 100644
--- a/apps/app_confbridge.c
+++ b/apps/app_confbridge.c
@@ -126,6 +126,39 @@
</description>
<see-also>
<ref type="application">ConfBridge</ref>
+ <ref type="application">ConfKick</ref>
+ <ref type="function">CONFBRIDGE</ref>
+ <ref type="function">CONFBRIDGE_INFO</ref>
+ </see-also>
+ </application>
+ <application name="ConfKick" language="en_US">
+ <synopsis>
+ Kicks channel(s) from the requested ConfBridge.
+ </synopsis>
+ <syntax>
+ <parameter name="conference" required="true" />
+ <parameter name="channel">
+ <para>The channel to kick, <literal>all</literal>
+ to kick all users, or <literal>participants</literal>
+ to kick all non-admin participants. Default is all.</para>
+ </parameter>
+ </syntax>
+ <description>
+ <para>Kicks the requested channel(s) from a conference bridge.</para>
+ <variablelist>
+ <variable name="CONFKICKSTATUS">
+ <value name="FAILURE">
+ Could not kick any users with the provided arguments.
+ </value>
+ <value name="SUCCESS">
+ Successfully kicked users from specified conference bridge.
+ </value>
+ </variable>
+ </variablelist>
+ </description>
+ <see-also>
+ <ref type="application">ConfBridge</ref>
+ <ref type="application">ConfKick</ref>
<ref type="function">CONFBRIDGE</ref>
<ref type="function">CONFBRIDGE_INFO</ref>
</see-also>
@@ -426,6 +459,7 @@
*/
static const char app[] = "ConfBridge";
+static const char app2[] = "ConfKick";
/*! Number of buckets our conference bridges container can have */
#define CONFERENCE_BRIDGE_BUCKETS 53
@@ -4220,6 +4254,53 @@
return 0;
}
+static int confkick_exec(struct ast_channel *chan, const char *data)
+{
+ char *parse;
+ struct confbridge_conference *conference;
+ int not_found;
+
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(confbridge);
+ AST_APP_ARG(channel);
+ );
+
+ if (ast_strlen_zero(data)) {
+ ast_log(LOG_WARNING, "No conference bridge specified.\n");
+ pbx_builtin_setvar_helper(chan, "CONFKICKSTATUS", "FAILURE");
+ return 0;
+ }
+
+ parse = ast_strdupa(data);
+ AST_STANDARD_APP_ARGS(args, parse);
+
+ conference = ao2_find(conference_bridges, args.confbridge, OBJ_KEY);
+ if (!conference) {
+ ast_log(LOG_WARNING, "No conference bridge named '%s' found!\n", args.confbridge);
+ pbx_builtin_setvar_helper(chan, "CONFKICKSTATUS", "FAILURE");
+ return 0;
+ }
+ if (ast_strlen_zero(args.channel)) {
+ not_found = kick_conference_participant(conference, "all");
+ } else {
+ not_found = kick_conference_participant(conference, args.channel);
+ }
+
+ ao2_ref(conference, -1);
+ if (not_found) {
+ if (ast_strlen_zero(args.channel) || !strcasecmp("all", args.channel) || !strcasecmp("participants", args.channel)) {
+ ast_log(LOG_WARNING, "No participants found in conference bridge '%s'!\n", args.confbridge);
+ } else {
+ ast_log(LOG_WARNING, "No participant named '%s' found in conference bridge '%s'!\n", args.channel, args.confbridge);
+ }
+ pbx_builtin_setvar_helper(chan, "CONFKICKSTATUS", "FAILURE");
+ return 0;
+ }
+ ast_debug(1, "Kicked '%s' out of conference '%s'\n", args.channel, args.confbridge);
+ pbx_builtin_setvar_helper(chan, "CONFKICKSTATUS", "SUCCESS");
+ return 0;
+}
+
void conf_add_user_active(struct confbridge_conference *conference, struct confbridge_user *user)
{
AST_LIST_INSERT_TAIL(&conference->active_list, user, list);
@@ -4313,6 +4394,7 @@
static int unload_module(void)
{
ast_unregister_application(app);
+ ast_unregister_application(app2);
ast_custom_function_unregister(&confbridge_function);
ast_custom_function_unregister(&confbridge_info_function);
@@ -4383,6 +4465,7 @@
res |= manager_confbridge_init();
res |= ast_register_application_xml(app, confbridge_exec);
+ res |= ast_register_application_xml(app2, confkick_exec);
res |= ast_custom_function_register_escalating(&confbridge_function, AST_CFE_WRITE);
res |= ast_custom_function_register(&confbridge_info_function);
diff --git a/doc/CHANGES-staging/app_confkick.txt b/doc/CHANGES-staging/app_confkick.txt
new file mode 100644
index 0000000..4250c7d
--- /dev/null
+++ b/doc/CHANGES-staging/app_confkick.txt
@@ -0,0 +1,6 @@
+Subject: New ConfKick application
+
+Adds a ConfKick() application, which allows
+a specific channel, all users, or all non-admin
+users to be kicked from a conference bridge.
+
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15930
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I5d96b683880bfdd27b2ab1c3f2e897c5046ded9b
Gerrit-Change-Number: 15930
Gerrit-PatchSet: 1
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210523/5410ab55/attachment.html>
More information about the asterisk-code-review
mailing list