mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Feature: Nicely render per source "Maintenance" section
This commit is contained in:
parent
871d296ab1
commit
210ec6245e
@ -23,6 +23,17 @@
|
||||
<xsl:call-template name="player" />
|
||||
<p><xsl:value-of select="listeners" /> Listener(s)</p>
|
||||
|
||||
<xsl:if test="maintenance/*">
|
||||
<h4>Maintenance</h4>
|
||||
<ul class="maintenance-container">
|
||||
<xsl:for-each select="maintenance/*">
|
||||
<li class="maintenance-level-{@maintenance-level}">
|
||||
<p><xsl:value-of select="text()" /></p>
|
||||
</li>
|
||||
</xsl:for-each>
|
||||
</ul>
|
||||
</xsl:if>
|
||||
|
||||
<!-- Mount Authentication -->
|
||||
<xsl:if test="authentication">
|
||||
<h4>Mount Authentication</h4>
|
||||
|
37
src/admin.c
37
src/admin.c
@ -470,6 +470,32 @@ xmlNodePtr admin_build_rootnode(xmlDocPtr doc, const char *name)
|
||||
return rootnode;
|
||||
}
|
||||
|
||||
static inline void admin_build_sourcelist__add_flag(xmlNodePtr parent, source_flags_t flags, source_flags_t flag, bool invert, const char *name)
|
||||
{
|
||||
xmlNodePtr node;
|
||||
source_flags_t testflags = SOURCE_FLAGS_GOOD|flag;
|
||||
|
||||
if (invert ? (flags & flag) : !(flags & flag))
|
||||
return;
|
||||
|
||||
node = xmlNewTextChild(parent, NULL, XMLSTR("flag"), XMLSTR(name));
|
||||
|
||||
if (invert)
|
||||
testflags &= ~flag;
|
||||
|
||||
switch (source_get_health_by_flags(testflags)) {
|
||||
case HEALTH_OK:
|
||||
xmlSetProp(node, XMLSTR("maintenance-level"), XMLSTR("info"));
|
||||
break;
|
||||
case HEALTH_WARNING:
|
||||
xmlSetProp(node, XMLSTR("maintenance-level"), XMLSTR("warning"));
|
||||
break;
|
||||
case HEALTH_ERROR:
|
||||
xmlSetProp(node, XMLSTR("maintenance-level"), XMLSTR("error"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* build an XML doc containing information about currently running sources.
|
||||
* If a mountpoint is passed then that source will not be added to the XML
|
||||
* doc even if the source is running */
|
||||
@ -531,7 +557,7 @@ xmlDocPtr admin_build_sourcelist(const char *mount, client_t *client, admin_form
|
||||
|
||||
if (source->running) {
|
||||
const source_flags_t flags = source->flags;
|
||||
xmlNodePtr flagsnode;
|
||||
xmlNodePtr maintenancenode;
|
||||
|
||||
if (source->client) {
|
||||
snprintf(buf, sizeof(buf), "%lu",
|
||||
@ -556,11 +582,12 @@ xmlDocPtr admin_build_sourcelist(const char *mount, client_t *client, admin_form
|
||||
xmlNewTextChild(srcnode, NULL, XMLSTR("health"), XMLSTR("red"));
|
||||
break;
|
||||
}
|
||||
flagsnode = xmlNewChild(srcnode, NULL, XMLSTR("flags"), NULL);
|
||||
xmlSetProp(flagsnode, XMLSTR("comment"), XMLSTR("This is an experimental node. Do not use!"));
|
||||
if (flags & SOURCE_FLAG_GOT_DATA)
|
||||
xmlNewTextChild(flagsnode, NULL, XMLSTR("flag"), XMLSTR("got-data"));
|
||||
maintenancenode = xmlNewChild(srcnode, NULL, XMLSTR("maintenance"), NULL);
|
||||
xmlSetProp(maintenancenode, XMLSTR("comment"), XMLSTR("This is an experimental node. Do not use!"));
|
||||
|
||||
admin_build_sourcelist__add_flag(maintenancenode, flags, SOURCE_FLAG_GOT_DATA, true, "no-got-data");
|
||||
admin_build_sourcelist__add_flag(maintenancenode, flags, SOURCE_FLAG_FORMAT_GENERIC, false, "format-generic");
|
||||
admin_build_sourcelist__add_flag(maintenancenode, flags, SOURCE_FLAG_LEGACY_METADATA, false, "legacy-metadata");
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "%"PRIu64, source->dumpfile_written);
|
||||
|
@ -1525,6 +1525,11 @@ void source_kill_dumpfile(source_t *source)
|
||||
health_t source_get_health(source_t *source)
|
||||
{
|
||||
const source_flags_t flags = source->flags;
|
||||
return source_get_health_by_flags(flags);
|
||||
}
|
||||
|
||||
health_t source_get_health_by_flags(source_flags_t flags)
|
||||
{
|
||||
health_t health = HEALTH_OK;
|
||||
|
||||
if (!(flags & SOURCE_FLAG_GOT_DATA))
|
||||
|
@ -35,6 +35,7 @@ typedef uint_least32_t source_flags_t;
|
||||
#define SOURCE_FLAG_LEGACY_METADATA ((source_flags_t)0x00000004U)
|
||||
|
||||
#define SOURCE_FLAGS_CLEARABLE (SOURCE_FLAG_LEGACY_METADATA)
|
||||
#define SOURCE_FLAGS_GOOD (SOURCE_FLAG_GOT_DATA)
|
||||
|
||||
struct source_tag {
|
||||
mutex_t lock;
|
||||
@ -125,6 +126,7 @@ void source_recheck_mounts (int update_all);
|
||||
bool source_write_dumpfile(source_t *source, const void *buffer, size_t len);
|
||||
void source_kill_dumpfile(source_t *source);
|
||||
health_t source_get_health(source_t *source);
|
||||
health_t source_get_health_by_flags(source_flags_t flags);
|
||||
void source_set_flags(source_t *source, source_flags_t flags);
|
||||
|
||||
extern mutex_t move_clients_mutex;
|
||||
|
Loading…
Reference in New Issue
Block a user