application/application.c

changeset 6
09ac07345656
parent 5
83263002816f
child 7
905ac52c910f
--- a/application/application.c	Sun Jan 28 20:47:40 2024 +0100
+++ b/application/application.c	Mon Jan 29 10:41:00 2024 +0100
@@ -31,15 +31,26 @@
 #include <string.h>
 #include <stdbool.h>
 
+#include <libidav/webdav.h>
+
 #include "window.h"
+#include "config.h"
 
+static DavContext* davctx;
 
 void application_init(void) {
+	davctx = dav_context_new();
+
 	application_create_menu();
 }
 
 
 void application_startup(UiEvent* event, void* data) {
+	if (load_config(davctx)) {
+		// TODO: error
+		exit(-1);
+	}
+
 	UiObject* win = window_create();
 
 	DavApp* app = application_create_app_document();
@@ -88,14 +99,27 @@
 }
 
 
+
 DavApp* application_create_app_document(void) {
 	DavApp* doc = ui_document_new(sizeof(DavApp));
 	UiContext* ctx = ui_document_context(doc);
 	doc->repos = ui_list_new(ctx, "repolist");
 
-	ui_list_append(doc->repos, "test");
-	
-
+	// create repo list
+	application_update_repolist(doc);
 
 	return doc;
 }
+
+void application_update_repolist(DavApp* app) {
+	DavConfig* config = get_config();
+	DavCfgRepository* repo = config->repositories;
+
+	// TODO: free list content ptr
+	ui_list_clear(app->repos);
+
+	for (DavCfgRepository* repo = config->repositories; repo; repo = repo->next) {
+		// TODO: copy repo name
+		ui_list_append(app->repos, repo->name.value.ptr);
+	}
+}

mercurial