diff -r 78684a24dc52 -r f2e79b69d233 application/davcontroller.c --- a/application/davcontroller.c Tue Jan 30 16:01:44 2024 +0100 +++ b/application/davcontroller.c Tue Jan 30 16:58:03 2024 +0100 @@ -31,6 +31,9 @@ #include +#include "config.h" + +#include #include DavBrowser* davbrowser_create(UiObject *toplevel) { @@ -67,7 +70,7 @@ // ------------------------------ davbrowser_connect2repo ------------------------------ -void davbrowser_connect2repo(UiObject *ui, DavBrowser *browser, DavCfgRepository *repo) { +void davbrowser_connect2repo(UiObject *ui, DavBrowser *browser, DavCfgRepository *repo, const char *path) { 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); @@ -75,11 +78,17 @@ free(decodedpw.ptr); } browser->sn = sn; - browser->repo_base = cx_strdup(cx_strn(repo->name.value.ptr, repo->name.value.length)).ptr; + if (repo->name.value.length > 0) { + browser->repo_base = cx_strdup(cx_strn(repo->name.value.ptr, repo->name.value.length)).ptr; + } else { + browser->repo_base = cx_strdup(cx_strn(repo->url.value.ptr, repo->url.value.length)).ptr; + } - ui_set(browser->path, repo->name.value.ptr); + char *dav_path = util_concat_path(browser->repo_base, path); + ui_set(browser->path, dav_path); + free(dav_path); - davbrowser_query_path(ui, browser, ""); + davbrowser_query_path(ui, browser, path); } @@ -96,7 +105,7 @@ DavBrowserQueryPath *query = data; DavSession *sn = query->browser->sn; - DavResource *res = dav_query(sn, "select `idav:crypto-name`,`idav:crypto-key`,D:lockdiscovery,D:getcontenttype from %s with depth = 1 order by iscollection desc, name", query->path); + DavResource *res = dav_query(sn, "select `idav:crypto-name`,`idav:crypto-key`,D:lockdiscovery from %s with depth = 1 order by iscollection desc, name", query->path); query->result = res; return 0; @@ -169,7 +178,16 @@ } } - // TODO: + char *path = NULL; + DavCfgRepository *repo = dav_config_url2repo(get_config(), url, &path); + davbrowser_connect2repo(ui, browser, repo, path); + + if (path) { + free(path); + } + if (!repo->node) { + dav_repository_free(get_config(), repo); + } } void davbrowser_add2navstack(DavBrowser *browser, const char *base, const char *path) {