diff --git a/admin/moveclients.xsl b/admin/moveclients.xsl index 9328998a..f5806f13 100644 --- a/admin/moveclients.xsl +++ b/admin/moveclients.xsl @@ -26,9 +26,9 @@
- + Move from + + to + with direction +   diff --git a/src/admin.c b/src/admin.c index 5923bd96..8373b52e 100644 --- a/src/admin.c +++ b/src/admin.c @@ -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); diff --git a/src/navigation.c b/src/navigation.c index 027f8569..43eb2255 100644 --- a/src/navigation.c +++ b/src/navigation.c @@ -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; diff --git a/src/navigation.h b/src/navigation.h index f59baee5..c38d6d5b 100644 --- a/src/navigation.h +++ b/src/navigation.h @@ -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);