]> git.ipfire.org Git - collecty.git/commitdiff
graphs: Take the object name as first (and only) argument
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 Sep 2025 16:37:51 +0000 (16:37 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 Sep 2025 16:37:51 +0000 (16:37 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/graph-bus.c
src/daemon/graph.c
src/daemon/graph.h

index b26ef6dcdd06c53011e162085ac25dbaab0678c5..f610fe3b1f2a25fb6a0d7b24f9d99b750e3f212c 100644 (file)
@@ -98,18 +98,22 @@ ERROR:
 static int collecty_graph_bus_render(sd_bus_message* m, void* data, sd_bus_error* error) {
        collecty_graph* graph = data;
        sd_bus_message* reply = NULL;
-       const char* format = NULL;
+       const char* object = NULL;
        char* buffer = NULL;
        size_t length = 0;
        int r;
 
        // Parse the arguments
-       r = sd_bus_message_read(m, "s", &format);
+       r = sd_bus_message_read(m, "s", &object);
        if (r < 0)
                goto ERROR;
 
+       // If an empty string has been sent, set it to NULL
+       if (object && !*object)
+               object = NULL;
+
        // Render the graph
-       r = collecty_graph_render(graph, format, &buffer, &length);
+       r = collecty_graph_render(graph, object, &buffer, &length);
        if (r < 0)
                goto ERROR;
 
@@ -140,7 +144,7 @@ static const sd_bus_vtable collecty_graph_vtable[] = {
        SD_BUS_VTABLE_START(0),
 
        // Operations
-       SD_BUS_METHOD_WITH_ARGS("Render", SD_BUS_ARGS("s", format), SD_BUS_RESULT("ay", graph),
+       SD_BUS_METHOD_WITH_ARGS("Render", SD_BUS_ARGS("s", object), SD_BUS_RESULT("ay", graph),
                collecty_graph_bus_render, SD_BUS_VTABLE_UNPRIVILEGED),
 
        SD_BUS_VTABLE_END
index 888a45ed8e8623a4abe42c7550837c47e5a79106..696ad4b414d9618ebe0f21083e9e0471814c8b8c 100644 (file)
@@ -106,7 +106,7 @@ char* collecty_graph_get_bus_path(collecty_graph* self) {
 }
 
 int collecty_graph_render(collecty_graph* self,
-               const char* format, char** buffer, size_t* length) {
+               const char* object, char** buffer, size_t* length) {
        char* p = NULL;
        int r;
 
index 01509be6a58e4e029aa9a36d9979b7ed5b6180d2..da4856cf598a4b1733baa52fb1114e3f3460f34e 100644 (file)
@@ -43,6 +43,6 @@ const char* collecty_graph_get_name(collecty_graph* self);
 char* collecty_graph_get_bus_path(collecty_graph* self);
 
 int collecty_graph_render(collecty_graph* self,
-       const char* format, char** buffer, size_t* length);
+       const char* object, char** buffer, size_t* length);
 
 #endif /* COLLECTY_GRAPH_H */