Tue, 30 Jan 2024 08:49:35 +0100
create DavSession in the main GUI thread
application/application.h | file | annotate | diff | comparison | revisions | |
application/davcontroller.c | file | annotate | diff | comparison | revisions |
--- a/application/application.h Tue Jan 30 08:43:34 2024 +0100 +++ b/application/application.h Tue Jan 30 08:49:35 2024 +0100 @@ -55,7 +55,7 @@ DavSession *sn; UiThreadpool *dav_queue; - DavCfgRepository *repository; + char *repo_base; DavResource *current;
--- a/application/davcontroller.c Tue Jan 30 08:43:34 2024 +0100 +++ b/application/davcontroller.c Tue Jan 30 08:49:35 2024 +0100 @@ -59,11 +59,7 @@ // ------------------------------ davbrowser_connect2repo ------------------------------ -static int connect2repo(void *data) { - DavBrowser *browser = data; - DavCfgRepository *repo = browser->repository; - - // TODO: cleanup current session +void davbrowser_connect2repo(UiObject *ui, DavBrowser *browser, DavCfgRepository *repo) { DavSession *sn = dav_session_new(application_dav_context(), repo->url.value.ptr); if (repo->user.value.ptr && repo->password.value.ptr) { cxmutstr decodedpw = dav_repository_get_decodedpassword(repo); @@ -71,20 +67,11 @@ free(decodedpw.ptr); } browser->sn = sn; - - return 0; -} + browser->repo_base = cx_strdup(cx_strn(repo->name.value.ptr, repo->name.value.length)).ptr; -static void repo_connected(UiEvent *event, void *data) { - DavBrowser *browser = event->document; - ui_set(browser->path, browser->repository->name.value.ptr); + ui_set(browser->path, repo->name.value.ptr); - davbrowser_query_path(event->obj, browser, "/"); -} - -void davbrowser_connect2repo(UiObject *ui, DavBrowser *browser, DavCfgRepository *repo) { - browser->repository = repo; - ui_threadpool_job(browser->dav_queue, ui, connect2repo, browser, repo_connected, NULL); + davbrowser_query_path(ui, browser, ""); } @@ -128,7 +115,7 @@ if (len == 1 && *path == '/') { path = ""; } - char *full_path = util_concat_path(browser->repository->name.value.ptr, path); + char *full_path = util_concat_path(browser->repo_base, path); // compare new path with current path // in theory we could always set path, but maybe this is faster char *current_path = ui_get(browser->path);