Mon, 21 Oct 2024 13:22:45 +0200
add menu items to open resource properties
--- a/application/application.c Mon Oct 21 11:14:26 2024 +0200 +++ b/application/application.c Mon Oct 21 13:22:45 2024 +0200 @@ -99,6 +99,8 @@ ui_menuitem("Download", .onclick = action_download); ui_menuitem("Upload Files", .onclick = action_upload_file); ui_menuitem("Upload Directory", .onclick = action_upload_dir); + ui_menuitem("Open Properties", .onclick = action_open_properties); + ui_menuitem("Open as Text File", .onclick = action_open_properties, .onclickdata = "text/plain"); ui_menuseparator(); ui_menuitem("Settings", .onclick = action_open_settings); } @@ -236,6 +238,8 @@ } else { ui_openfiledialog(event->obj, UI_FILEDIALOG_SELECT_FOLDER, download_location_selected, first); } + + ui_listselection_free(sel); } } @@ -305,3 +309,17 @@ void action_open_settings(UiEvent *event, void *data) { } + +void action_open_properties(UiEvent *event, void *data) { + char *type = data; + DavBrowser *browser = event->document; + + UiListSelection sel = ui_list_getselection(browser->resources); + for(int i=0;i<sel.count;i++) { + DavResource *res = ui_list_get(browser->resources, sel.rows[i]); + if(res) { + davbrowser_open_resource(event->obj, browser, res, type); + } + } + ui_listselection_free(sel); +}
--- a/application/application.h Mon Oct 21 11:14:26 2024 +0200 +++ b/application/application.h Mon Oct 21 13:22:45 2024 +0200 @@ -171,6 +171,8 @@ void action_open_settings(UiEvent *event, void *data); +void action_open_properties(UiEvent *event, void *data); + #ifdef __cplusplus } #endif
--- a/application/davcontroller.c Mon Oct 21 11:14:26 2024 +0200 +++ b/application/davcontroller.c Mon Oct 21 13:22:45 2024 +0200 @@ -201,31 +201,28 @@ } } -void davbrowser_open_resource(UiObject *ui, DavBrowser *browser, DavResource *res) { - char *url = util_concat_path(browser->sn->base_url, res->path); - void *x = cxMapGet(browser->res_open_inprogress, url); - free(url); - if(x) { - return; // open resource already in progress +void davbrowser_open_resource(UiObject *ui, DavBrowser *browser, DavResource *res, const char *contenttype) { + DavResourceViewType type = DAV_RESOURCE_VIEW_PROPERTIES; + if(!contenttype) { + contenttype = res->contenttype; } - DavResourceViewType type = DAV_RESOURCE_VIEW_PROPERTIES; if(res->iscollection) { // default type - } else if(res->contenttype) { - cxstring contenttype = cx_str(res->contenttype); - if(cx_strprefix(contenttype, CX_STR("text/"))) { + } else if(contenttype) { + cxstring ctype = cx_str(contenttype); + if(cx_strprefix(ctype, CX_STR("text/"))) { type = DAV_RESOURCE_VIEW_TEXT; - } else if(cx_strprefix(contenttype, CX_STR("image/"))) { + } else if(cx_strprefix(ctype, CX_STR("image/"))) { type = DAV_RESOURCE_VIEW_IMAGE; - } else if(cx_strprefix(contenttype, CX_STR("application/"))) { - if(cx_strsuffix(contenttype, CX_STR("json"))) { + } else if(cx_strprefix(ctype, CX_STR("application/"))) { + if(cx_strsuffix(ctype, CX_STR("json"))) { type = DAV_RESOURCE_VIEW_TEXT; - } else if(cx_strsuffix(contenttype, CX_STR("/xml"))) { + } else if(cx_strsuffix(ctype, CX_STR("/xml"))) { type = DAV_RESOURCE_VIEW_TEXT; - } else if(cx_strsuffix(contenttype, CX_STR("+xml"))) { + } else if(cx_strsuffix(ctype, CX_STR("+xml"))) { type = DAV_RESOURCE_VIEW_TEXT; - } else if(cx_strsuffix(contenttype, CX_STR("/xml"))) { + } else if(cx_strsuffix(ctype, CX_STR("/xml"))) { type = DAV_RESOURCE_VIEW_TEXT; } }
--- a/application/davcontroller.h Mon Oct 21 11:14:26 2024 +0200 +++ b/application/davcontroller.h Mon Oct 21 13:22:45 2024 +0200 @@ -53,7 +53,7 @@ void davbrowser_query_url(UiObject *ui, DavBrowser *browser, const char *url); -void davbrowser_open_resource(UiObject *ui, DavBrowser *browser, DavResource *res); +void davbrowser_open_resource(UiObject *ui, DavBrowser *browser, DavResource *res, const char *contenttype); void davbrowser_add2navstack(DavBrowser *browser, const char *base, const char *path);
--- a/application/window.c Mon Oct 21 11:14:26 2024 +0200 +++ b/application/window.c Mon Oct 21 13:22:45 2024 +0200 @@ -303,7 +303,7 @@ if (res->iscollection) { davbrowser_query_path(event->obj, browser, res->path); } else { - davbrowser_open_resource(event->obj, browser, res); + davbrowser_open_resource(event->obj, browser, res, NULL); } } }
--- a/libidav/webdav.c Mon Oct 21 11:14:26 2024 +0200 +++ b/libidav/webdav.c Mon Oct 21 13:22:45 2024 +0200 @@ -50,7 +50,7 @@ if(!context) { return NULL; } - context->sessions = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_intptr, CX_STORE_POINTERS); + context->sessions = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_ptr, CX_STORE_POINTERS); cxDefineDestructor(context->sessions, dav_session_destructor); context->http_proxy = calloc(1, sizeof(DavProxy)); if(!context->http_proxy) {