Webdar 1.0.0
Web user interface to libdar
html_options_read.hpp
1/*********************************************************************/
2// webdar - a web server and interface program to libdar
3// Copyright (C) 2013-2025 Denis Corbin
4//
5// This file is part of Webdar
6//
7// Webdar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Webdar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef HTML_OPTIONS_READ_HPP
25#define HTML_OPTIONS_READ_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31
32}
33
34 // C++ system header files
35#include <dar/libdar.hpp>
36#include <memory>
37#include <string>
38
39 // webdar headers
40#include "body_builder.hpp"
41#include "html_div.hpp"
42#include "html_form.hpp"
43#include "html_form_fieldset.hpp"
44#include "html_form_select.hpp"
45#include "html_form_input.hpp"
46#include "html_form_input_file.hpp"
47#include "html_form_input_unit.hpp"
48#include "html_crypto_algo.hpp"
49#include "events.hpp"
50#include "html_derouleur.hpp"
51#include "html_text.hpp"
52#include "html_entrepot_landing.hpp"
53#include "html_libdar_running_popup.hpp"
54#include "bibliotheque.hpp"
55#include "guichet.hpp"
56#include "jsoner.hpp"
57#include "bibliotheque_subconfig.hpp"
58
60
80
82 public actor,
83 public events,
84 public libthreadar::thread_signal,
85 public jsoner,
87{
88public:
89 static const std::string landing_path_changed;
90 static const std::string entrepot_has_changed;
91 static const std::string changed;
92
94 html_options_read(const html_options_read & ref) = delete;
95 html_options_read(html_options_read && ref) noexcept = delete;
96 html_options_read & operator = (const html_options_read & ref) = delete;
97 html_options_read & operator = (html_options_read && ref) noexcept = delete;
98 ~html_options_read() { cancel(); join(); };
99
101 void set_biblio(const std::shared_ptr<bibliotheque> & ptr);
102
104 libdar::archive_options_read get_options(std::shared_ptr<html_web_user_interaction> & webui) const;
105
107 std::shared_ptr<libdar::entrepot> get_entrepot(std::shared_ptr<html_web_user_interaction> webui) const
108 { return entrep->get_entrepot(webui); };
109
111 const std::string & get_landing_path() const { return entrep->get_landing_path(); };
112
114 void set_src_min_digits(const std::string & val);
115
117 virtual void load_json(const json & source) override;
118
120 virtual json save_json() const override;
121
123 virtual void clear_json() override;
124
126 virtual bibliotheque::using_set get_using_set() const override;
127
129 virtual void on_event(const std::string & event_name) override;
130
133
134protected:
135
136 // inherited from body_builder
137 virtual std::string inherited_get_body_part(const chemin & path,
138 const request & req) override;
139
140 // inheroted from body_builder
141 virtual void new_css_library_available() override;
142
143 // inherited from class libthreadar::thread
144 virtual void inherited_run() override;
145
147 virtual void signaled_inherited_cancel() override;
148
149
150private:
151 static const std::string ref_entrepot_has_changed;
152 static const std::string ref_entrepot_landing_path_changed;
153 static constexpr const char* sect_entrep = "entrep";
154 static constexpr const char* sect_opt = "options";
155 static constexpr const char* sect_ref_entrep = "ref_entrep";
156 static constexpr const char* sect_extcat = "externalcat";
157
159 bool ignore_events;
160
162
165 bool need_ref_entrepot_update;
166 bool updating_entrepot;
167 bool update_from_load_json;
168
169 html_derouleur deroule;
170 html_form form_src;
171 html_form_fieldset fs_src;
172 html_form_fieldset fs_ref;
173
174 // archive entrepot fields
175 guichet guichet_entrep;
176 std::shared_ptr<html_entrepot_landing> entrep;
177
178 // archive_options_read fields
179 html_crypto_algo src_crypto_algo;
180 html_form_input src_crypto_pass;
181 html_form_input_unit src_crypto_size;
182 html_form_input src_ignore_sig_failure;
183 html_form_input src_execute;
184 html_form_input src_slice_min_digits;
185 html_form_input info_details;
186 html_form_input lax;
187 html_form_input sequential_read;
188 html_form_input force_first_slice;
189 html_form_input multi_thread_crypto;
190 html_form_input multi_thread_compress;
191
192 // external catalogue entrepot
193 guichet guichet_ref_entrep;
194 std::shared_ptr<html_entrepot_landing> ref_entrep;
195
196 html_form_input ref_use_external_catalogue;
197 html_form form_ref;
198 html_form_input_file ref_path;
199 html_crypto_algo ref_crypto_algo;
200 html_form_input ref_crypto_pass;
201 html_form_input_unit ref_crypto_size;
202 html_form_input ref_execute;
203 html_form_input ref_slice_min_digits;
204
205 // used to create ref_entrep during html interaction
207
208 void update_ref_entrepot();
209 void set_defaults();
210 void set_defaults_for_ref();
211 void trigger_changed();
212
213 static constexpr const unsigned int format_version = 1;
214 static constexpr const char* myclass_id = "html_options_read";
215
216 static constexpr const char* jlabel_entrep = "entrepot";
217 static constexpr const char* jlabel_crypto_algo = "cryto-algo";
218 static constexpr const char* jlabel_crypto_pass = "crypto-pass";
219 static constexpr const char* jlabel_crypto_size = "crytpo-size";
220 static constexpr const char* jlabel_ignore_sig_failure = "ignore-sig-failure";
221 static constexpr const char* jlabel_execute = "execute";
222 static constexpr const char* jlabel_slice_min_digits = "min-digits";
223 static constexpr const char* jlabel_info_details = "info-details";
224 static constexpr const char* jlabel_lax = "lax-mode";
225 static constexpr const char* jlabel_seq_read = "sequential-read";
226 static constexpr const char* jlabel_force_first_slice = "first-slice-reading";
227 static constexpr const char* jlabel_thread_crypto = "cipher-threads";
228 static constexpr const char* jlabel_thread_compress = "compr-threads";
229 static constexpr const char* jlabel_ref_entrep = "ref-entrepot";
230 static constexpr const char* jlabel_ref_used = "ref-used";
231 static constexpr const char* jlabel_ref_path = "ref-path";
232 static constexpr const char* jlabel_ref_crypto_algo = "ref-crypto-algo";
233 static constexpr const char* jlabel_ref_crypto_pass = "ref-crypt-pass";
234 static constexpr const char* jlabel_ref_crypto_size = "ref-crypto-size";
235 static constexpr const char* jlabel_ref_execute = "ref-execute";
236 static constexpr const char* jlabel_ref_slice_min_digits = "ref-min-digits";
237
238};
239
240#endif
defines bibliotheque class
class of object that are pointed/triggered to by others
Definition: actor.hpp:55
class bibliotheque_subconfig is an interface (pure virtual class)
Definition: bibliotheque_subconfig.hpp:50
std::set< coordinates > using_set
list of configs a given config depends on
Definition: bibliotheque.hpp:117
class body_builder is the root class of object generating HTML body
Definition: body_builder.hpp:99
class chemin definition
Definition: chemin.hpp:51
class events
Definition: events.hpp:52
class guichet let one fetch config from a bibliotheque, save as or setup manually for a given compone...
Definition: guichet.hpp:92
html component in the form of a drop-down list used to let the user define the crypto algo
Definition: html_crypto_algo.hpp:46
class html_derouleur is a pure virtual class
Definition: html_derouleur.hpp:55
class html_form_fieldset implements HTML fieldset feature
Definition: html_form_fieldset.hpp:51
class html_form_input_file provides a mean to the user to navigate in a file system to select a file ...
Definition: html_form_input_file.hpp:60
class html_form_input_unit implements HTML input::number feature with added unit box
Definition: html_form_input_unit.hpp:51
class html_form_input implements HTML input feature
Definition: html_form_input.hpp:57
class html_form implements HTML form feature
Definition: html_form.hpp:51
html_libdar_running_popup wraps up an html_web_user_interaction in a html_popup component
Definition: html_libdar_running_popup.hpp:48
class html_options_read implementes the html components to setup optional parameters while reading an...
Definition: html_options_read.hpp:87
virtual json save_json() const override
inherited from jsoner
Definition: html_options_read.cpp:375
virtual bibliotheque::using_set get_using_set() const override
inherited from bibliotheque_subconfig
Definition: html_options_read.cpp:426
virtual void signaled_inherited_cancel() override
inherited from libthreadar::thread
Definition: html_options_read.cpp:568
void set_to_webdar_defaults()
set the object to webdar defaults
Definition: html_options_read.cpp:526
virtual void clear_json() override
inherited from jsoner
Definition: html_options_read.cpp:410
virtual void load_json(const json &source) override
inherited from jsoner
Definition: html_options_read.cpp:303
static const std::string changed
any parameter changed (including entrepot change)
Definition: html_options_read.hpp:91
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
implementation of get_body_part() method for inherited classes
Definition: html_options_read.cpp:537
static const std::string entrepot_has_changed
entrepot parameter changed
Definition: html_options_read.hpp:90
virtual void new_css_library_available() override
Definition: html_options_read.cpp:549
static const std::string landing_path_changed
landing path has changed
Definition: html_options_read.hpp:89
void set_biblio(const std::shared_ptr< bibliotheque > &ptr)
mandatory call to invoke ASAP after constructor
Definition: html_options_read.cpp:223
std::shared_ptr< libdar::entrepot > get_entrepot(std::shared_ptr< html_web_user_interaction > webui) const
obtain just the entrepot object from the option fields
Definition: html_options_read.hpp:107
virtual void on_event(const std::string &event_name) override
inherited from actor
Definition: html_options_read.cpp:436
void set_src_min_digits(const std::string &val)
set min-digits field for the archive to read (not the archive of reference if any)
Definition: html_options_read.cpp:288
const std::string & get_landing_path() const
obtain the entrepot landing path
Definition: html_options_read.hpp:111
libdar::archive_options_read get_options(std::shared_ptr< html_web_user_interaction > &webui) const
obtain the libdar archive_option_read object from the html filled fields
Definition: html_options_read.cpp:240
class jsoner
Definition: jsoner.hpp:73
class holding fields of an HTTP request (method, URI, header, cookies, and so on)
Definition: request.hpp:45
defines the event class
defines jsoner class and class exception_json