UNIXworkcode

1 /* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 * 4 * Copyright 2024 Olaf Wintermann. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef IDAV_DAV_CONTROLLER_H 30 #define IDAV_DAV_CONTROLLER_H 31 32 #include <ui/ui.h> 33 #include <libidav/webdav.h> 34 #include <libidav/config.h> 35 36 #include "application.h" 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 #define DAVBROWSER_MAX_NAVLIST 128 43 44 typedef struct TransferProgress { 45 size_t total_bytes; 46 size_t total_files; 47 size_t total_directories; 48 size_t transferred_bytes; 49 size_t transferred_files; 50 size_t transferred_directories; 51 52 size_t current_file_size; 53 size_t current_file_transferred; 54 55 time_t speedtest_start; 56 size_t speedtest_bytes; 57 } TransferProgress; 58 59 DavBrowser* davbrowser_create(UiObject *toplevel); 60 61 int jobthr_davbrowser_auth(DavSession *sn, void *data); 62 void davbrowser_auth_set_user_pwd(SessionAuthData *auth, const char *user, const char *password); 63 64 void davbrowser_set_collection(UiObject *ui, DavBrowser *browser, DavResource *collection); 65 66 int davbrowser_connect2repo(UiObject *ui, DavBrowser *browser, DavCfgRepository *repo, const char *path); 67 68 void davbrowser_query_path(UiObject *ui, DavBrowser *browser, const char *path); 69 70 void davbrowser_query_url(UiObject *ui, DavBrowser *browser, const char *url); 71 72 void davbrowser_open_resource(UiObject *ui, DavBrowser *browser, DavResource *res, const char *contenttype); 73 74 void davbrowser_add2navstack(DavBrowser *browser, const char *base, const char *path); 75 76 void davbrowser_navigation_parent(UiObject *ui, DavBrowser *browser); 77 void davbrowser_navigation_back(UiObject *ui, DavBrowser *browser); 78 void davbrowser_navigation_forward(UiObject *ui, DavBrowser *browser); 79 80 void davbrowser_upload_files(UiObject *ui, DavBrowser *browser, UiFileList files); 81 82 void davbrowser_download(UiObject *ui, DavBrowser *browser, DavResource *reslist, const char *local_path); 83 84 void davbrowser_delete(UiObject *ui, DavBrowser *browser, UiListSelection selection); 85 86 void davbrowser_create_resource(UiObject *ui, DavBrowser *browser, const char *name, DavBool iscollection); 87 88 void davbrowser_mkcol(UiObject *ui, DavBrowser *browser, const char *name); 89 void davbrowser_newfile(UiObject *ui, DavBrowser *browser, const char *name); 90 91 void davbrowser_rename(UiObject *ui, DavBrowser *browser, UiListSelection selection); 92 93 94 DavResourceViewer* dav_resourceviewer_create(UiObject *toplevel, DavSession *sn, const char *path, DavResourceViewType type); 95 96 void dav_resourceviewer_load(UiObject *ui, DavResourceViewer *res); 97 98 void dav_resourceviewer_save(UiObject *ui, DavResourceViewer *res); 99 100 void dav_resourceviewer_destroy(DavResourceViewer *res); 101 102 void dav_resourceviewer_property_remove(DavResourceViewer *res, DavPropertyList *prop); 103 void dav_resourceviewer_property_update_text(DavResourceViewer *res, DavPropertyList *prop, const char *text); 104 void dav_resourceviewer_property_update_xml(DavResourceViewer *res, DavPropertyList *prop, DavXmlNode *xml); 105 void dav_resourceviewer_property_add_text(DavResourceViewer *res, const char *ns, const char *name, const char *text); 106 void dav_resourceviewer_property_add_xml(DavResourceViewer *res, const char *ns, const char *name, const char *nsdef, DavXmlNode *xml); 107 108 109 uint64_t dav_transfer_speed(TransferProgress *progress, time_t current); 110 111 #ifdef __cplusplus 112 } 113 #endif 114 115 #endif /* IDAV_DAV_CONTROLLER_H */ 116 117