--- a/application/upload.c Wed Nov 27 17:14:57 2024 +0100 +++ b/application/upload.c Wed Nov 27 18:45:08 2024 +0100 @@ -57,6 +57,15 @@ double progress = upload_progress(upload); ui_set(upload->progressbar, progress); + upload->trans.progress = progress; + time_t t = time(NULL); + /* + if(t > upload->trans.last_update + 2) { + snprintf(upload->trans.label+upload->trans.label_len, 12, " %d%%", (int)progress); + application_update_transferlist(); + upload->trans.last_update = t; + } + */ cxmutstr label1; if (upload->progress.total_files + upload->progress.total_directories > 1) { @@ -84,7 +93,6 @@ } time_t start = upload->progress.speedtest_start; - time_t t = time(NULL); if(t >= upload->progress.speedtest_start + 4) { uint64_t bytesPerSeconds = dav_transfer_speed(&upload->progress, t); if(start > 0) { @@ -407,13 +415,25 @@ } } +static void dav_file_upload_cleanup(DavFileUpload *upload) { + application_remove_transfer(&upload->trans); + ui_object_unref(upload->browser->window); +} + DavFileUpload* dav_upload_create(DavBrowser *browser, UiObject *obj, UiFileList files) { UiContext *ctx = obj->ctx; + CxMempool *mp = ui_cx_mempool(ctx); DavFileUpload *upload = ui_malloc(ctx, sizeof(DavFileUpload)); memset(upload, 0, sizeof(DavFileUpload)); upload->dialog = obj; obj->window = upload; ui_object_ref(obj); + ui_object_ref(browser->window); + + size_t label_len = strlen(util_resource_name(files.files[0])) + 16; + upload->trans.label = cxCalloc(mp->allocator, label_len, 1); + upload->trans.label_len = snprintf(upload->trans.label, label_len, "> %s%s", util_resource_name(files.files[0]), files.nfiles > 1 ? " ..." : ""); + upload->trans.window = obj; upload->progressbar = ui_double_new(ctx, "progressbar"); upload->label_top_left = ui_string_new(ctx, "label_top_left"); @@ -436,9 +456,9 @@ upload->collection = browser->current; upload->collection_ctn = browser->res_counter; - CxMempool *mp = ui_cx_mempool(ctx); cxMempoolRegister(mp, upload_session, (cx_destructor_func)dav_session_destroy); cxMempoolRegister(mp, upload->queue, (cx_destructor_func)ui_threadpool_destroy); + cxMempoolSetDestructor(upload, (cx_destructor_func)dav_file_upload_cleanup); ui_set(upload->label_top_left, ""); ui_set(upload->label_top_right, "");