application/upload.h

Thu, 28 Nov 2024 18:03:12 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 28 Nov 2024 18:03:12 +0100
changeset 97
5a3d27b8e6b0
parent 95
e92c72705da4
permissions
-rw-r--r--

implement UI for editing properties, relates to #497

87
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2024 Olaf Wintermann. All rights reserved.
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #ifndef UPLOAD_H
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #define UPLOAD_H
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #include "application.h"
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "davcontroller.h"
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35 #ifdef __cplusplus
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 extern "C" {
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #endif
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 typedef struct DavFileUpload {
95
e92c72705da4 add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 87
diff changeset
40 DavTransfer trans;
87
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 DavBrowser *browser;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 DavSession *sn;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 UiFileList files;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 char *base_path;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 UiThreadpool *queue;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 TransferProgress progress;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 DavBool upload_file;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 char *current_file_name;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 UiObject *dialog;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 UiDouble *progressbar;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 UiString *label_top_left;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 UiString *label_top_right;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 UiString *label_bottom_left;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 UiString *label_bottom_right;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 // The collection, the files are uploaded to
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 // It is only safe to access the collection ptr, if
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 // collection == browser->current && collection_ctn == browser->res_counter
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 // and obviously it can only be accessed from the UI thread
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 DavResource *collection;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 // copy of browser->res_counter, used for integrity check
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 int64_t collection_ctn;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 // current uploaded resource, created as part of the browser session
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 // only if collection == browser->current && collection_ctn == browser->res_counter
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 DavResource *current_resource;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 DavBool cancel;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 } DavFileUpload;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 typedef struct DUFile {
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 FILE *fd;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 char *path;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 char *upload_path;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 size_t bytes;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 DavBool isdirectory;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 DavFileUpload *upload;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 DavError error;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 } DUFile;
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 DavFileUpload* dav_upload_create(DavBrowser *browser, UiObject *obj, UiFileList files);
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 void dav_upload_start(DavFileUpload *upload);
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 void action_upload_cancel(UiEvent *event, void *data);
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 #ifdef __cplusplus
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 }
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 #endif
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 #endif /* UPLOAD_H */
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96

mercurial