Commit 133fe997 authored by Brendan Long's avatar Brendan Long

Add icons and better example config file.

parent b904a4ab
......@@ -5,9 +5,19 @@
"id": "767cc58a-47d2-4fb3-b27e-f6c0d54f26b6",
"name": "CableLabs Remote UI Discovery Server",
"url": "http://10.43.0.93:8080"
}, {
"id": "252703FB-A447-4659-B4CD-E15BC57B7B43",
"name": "CableLabs HTTP Discovery Server (GitHub)",
"url": "https://github.com/cablelabs/rui-http-server",
"icons": [{
"url": "https://github.global.ssl.fastly.net/images/modules/logos_page/GitHub-Mark.png"
}]
}, {
"id": "64D5C5A0-8CB1-476F-976D-9038C27A7EFE",
"name": "Brendan Test",
"url": "https://www.brendanlong.com"
"name": "CableLabs RemoteUI Server Service (GitHub)",
"url": "https://github.com/cablelabs/gupnp-rui-server",
"icons": [{
"url": "https://github.global.ssl.fastly.net/images/modules/logos_page/GitHub-Mark.png"
}]
}]
}
......@@ -3,17 +3,19 @@ errordomain RUIError {
}
struct RemoteUI {
public RemoteUI(string id, string name, string? description, string url)
{
public RemoteUI(string id, string name, string? description, string url,
string[]? icons) {
this.id = id;
this.name = name;
this.description = description;
this.url = url;
this.icons = icons;
}
string id;
string name;
string? description;
string url;
string[]? icons;
}
class RemoteUIServer {
......@@ -71,6 +73,15 @@ class RemoteUIServer {
builder.append(ui.description);
builder.append("</description>");
}
if (ui.icons != null && ui.icons.length > 0) {
builder.append("<iconList>");
foreach (string url in ui.icons) {
builder.append("<icon><url>");
builder.append(url);
builder.append("</url></icon>");
}
builder.append("</iconList>");
}
builder.append("<protocol shortName=\"DLNA-HTML5-1.0\"><uri>");
builder.append(ui.url);
builder.append("</uri></protocol>");
......@@ -160,7 +171,25 @@ static int main(string[] args) {
if (ui_node.has_member("description")) {
description = ui_node.get_string_member("description");
}
remoteUIs += RemoteUI(id, name, description, url);
string[]? icons = null;
if (ui_node.has_member("icons")) {
icons = {};
Json.Array icons_node = ui_node.get_array_member("icons");
for (var j = 0; j < icons_node.get_length(); ++j) {
Json.Object icon_node = icons_node.get_element(j).get_object();
if (!icon_node.has_member("url")) {
stderr.printf("Ignoring icon with missing require attribute \"url\" for UI %s.\n", name);
continue;
}
icons += icon_node.get_string_member("url");
}
if (icons.length == 0) {
stderr.printf("Ignoring invalid 0-length icons list for UI %s.\n",
name);
icons = null;
}
}
remoteUIs += RemoteUI(id, name, description, url, icons);
}
} catch (Error e) {
stderr.printf("Error reading config file %s.\n", config_file);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment