1
0
Fork 0

Feature: Added support to give navigation direction via admin call for command_move_clients()

This commit is contained in:
Philipp Schafft 2020-11-09 20:19:01 +00:00
parent 7474fb8d8d
commit 704df45ce5
4 changed files with 33 additions and 4 deletions

View File

@ -26,9 +26,9 @@
</xsl:otherwise>
</xsl:choose>
<form method="post" action="/admin/moveclients.xsl">
<label for="moveto" class="hidden">
Move from <code><xsl:value-of select="current_source" /></code> to
</label>
Move from
<code><xsl:value-of select="current_source" /></code>
to
<select name="destination" id="moveto">
<xsl:for-each select="source">
<option value="{@mount}">
@ -36,6 +36,13 @@
</option>
</xsl:for-each>
</select>
with direction
<select name="direction">
<option value="up">up</option>
<option value="down">down</option>
<option value="replace-current">replace</option>
<option value="replace-all">forget and replace</option>
</select>
<input type="hidden" name="mount" value="{current_source}" />
&#160;
<input type="submit" value="Move listeners" />

View File

@ -716,6 +716,7 @@ static void command_move_clients(client_t *client,
{
const char *dest_source;
const char *idtext = NULL;
const char *directiontext = NULL;
connection_id_t id;
source_t *dest;
char buf[255];
@ -730,6 +731,8 @@ static void command_move_clients(client_t *client,
} else {
idtext = NULL;
}
COMMAND_OPTIONAL(client, "direction", directiontext);
ICECAST_LOG_DEBUG("Done optional check (%d)", parameters_passed);
if (!parameters_passed) {
xmlDocPtr doc = admin_build_sourcelist(source->mount, client, response);
@ -766,7 +769,7 @@ static void command_move_clients(client_t *client,
ICECAST_LOG_INFO("source is \"%s\", destination is \"%s\"", source->mount, dest->mount);
source_move_clients(source, dest, idtext ? &id : NULL);
source_move_clients(source, dest, idtext ? &id : NULL, navigation_str_to_direction(directiontext, NAVIGATION_DIRECTION_DOWN));
snprintf(buf, sizeof(buf), "Clients moved from %s to %s",
source->mount, dest_source);

View File

@ -36,6 +36,24 @@ const char * navigation_direction_to_str(navigation_direction_t dir)
return NULL;
}
navigation_direction_t navigation_str_to_direction(const char *str, navigation_direction_t def)
{
if (!str || !*str)
return def;
if (strcasecmp(str, "up") == 0) {
return NAVIGATION_DIRECTION_UP;
} else if (strcasecmp(str, "down") == 0) {
return NAVIGATION_DIRECTION_DOWN;
} else if (strcasecmp(str, "replace_current") == 0 || strcasecmp(str, "replace-current") == 0) {
return NAVIGATION_DIRECTION_REPLACE_CURRENT;
} else if (strcasecmp(str, "replace_all") == 0 || strcasecmp(str, "replace-all") == 0) {
return NAVIGATION_DIRECTION_REPLACE_ALL;
} else {
return def;
}
}
static int mount_identifier_compare__for_tree(void *compare_arg, void *a, void *b)
{
const char *id_a, *id_b;

View File

@ -30,6 +30,7 @@ typedef enum {
REFOBJECT_FORWARD_TYPE(mount_identifier_t);
const char * navigation_direction_to_str(navigation_direction_t dir);
navigation_direction_t navigation_str_to_direction(const char *str, navigation_direction_t def);
void navigation_initialize(void);
void navigation_shutdown(void);