Webdar 1.0.0
Web user interface to libdar
html_entrepot_landing.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_ENTREPOT_LANDING_HPP
25#define HTML_ENTREPOT_LANDING_HPP
26
27#include "my_config.h"
28
29 // C system header files
30extern "C"
31{
32
33}
34
35 // C++ system header files
36#include <libthreadar/libthreadar.hpp>
37
38 // webdar headers
39#include "body_builder.hpp"
40#include "actor.hpp"
41#include "events.hpp"
42#include "jsoner.hpp"
43#include "html_entrepot.hpp"
44#include "html_form_input_file.hpp"
45#include "html_form.hpp"
46#include "html_libdar_running_popup.hpp"
47
49
51 public actor,
52 public events,
53 public libthreadar::thread_signal,
54 public jsoner
55{
56public:
57
59 static const std::string changed;
60
62 static const std::string entrepot_only_changed;
63
66 static const std::string landing_path_only_changed;
67
69 html_entrepot_landing(const html_entrepot_landing & ref) = delete;
70 html_entrepot_landing(html_entrepot_landing && ref) noexcept = delete;
71 html_entrepot_landing & operator = (const html_entrepot_landing & ref) = delete;
72 html_entrepot_landing & operator = (html_entrepot_landing && ref) noexcept = delete;
73 ~html_entrepot_landing() { cancel(); join(); };
74
76 std::shared_ptr<libdar::entrepot> & get_entrepot(std::shared_ptr<html_web_user_interaction> & webui) const;
77
79 const std::string & get_landing_path() const { return landing_path.get_value(); };
80
82 virtual void on_event(const std::string & event_name) override;
83
85 void set_event_entrepot(const std::string & name);
86
88 void set_event_landing_path(const std::string & name);
89
91 virtual void load_json(const json & source) override;
92
94 virtual json save_json() const override;
95
97 virtual void clear_json() override;
98
101
102
104 virtual void bind_to_anchor(const std::string & val) override { form.bind_to_anchor(val); };
105
106protected:
107
109 virtual std::string inherited_get_body_part(const chemin & path,
110 const request & req) override;
111
113 virtual void css_classes_have_changed() override;
114
116 virtual void new_css_library_available() override;
117
119 virtual void inherited_run() override;
120
122 virtual void signaled_inherited_cancel() override;
123
124private:
125 std::string custom_event_entrepot;
126 std::string custom_event_landing_path;
127 bool ignore_events;
128 mutable libthreadar::mutex entrep_ctrl;
129 mutable bool entrepot_changed;
130 mutable std::shared_ptr<libdar::entrepot> libdar_entrep;
131
132 // warning, custom_event need to be declared before the html_libdar_running_popup
133 // because at destruction time of this object, the html_libdar_running_popup destructor
134 // may lead to an event 'this' is acting on and requires the custom_event_* string
135 // object to be defined. In this order the destructor of 'this' will not
136 // destroy the custom_event_* std::string objects before repoxfer below.
137
138 html_form form;
140 html_entrepot entrep;
141 html_form_input use_landing_path;
142 html_form_input_file landing_path;
144
145 void start_updating_landing();
146
147 static constexpr const unsigned int format_version = 1;
148 static constexpr const char* myclass_id = "html_entrepot_landing";
149
150 static constexpr const char* jlabel_entrepot = "entrepot";
151 static constexpr const char* jlabel_use_landing_path = "use-landing-path";
152 static constexpr const char* jlabel_landing_path = "landing-path";
153
154};
155
156#endif
class of object that are pointed/triggered to by others
Definition: actor.hpp:55
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 html_entrepot_landing add a landing path to an entrepot object
Definition: html_entrepot_landing.hpp:55
static const std::string entrepot_only_changed
the use case is for the caller to know when to call get_entrepot()
Definition: html_entrepot_landing.hpp:62
static const std::string landing_path_only_changed
Definition: html_entrepot_landing.hpp:66
const std::string & get_landing_path() const
fetch current landing path for the entrepot
Definition: html_entrepot_landing.hpp:79
void set_to_webdar_defaults()
set the object to webdar defaults
Definition: html_entrepot_landing.cpp:261
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
inherited from body_builder
Definition: html_entrepot_landing.cpp:268
virtual void clear_json() override
inherited from jsoner
Definition: html_entrepot_landing.cpp:237
virtual void signaled_inherited_cancel() override
inherited from libthreadar::thread
Definition: html_entrepot_landing.cpp:318
virtual void load_json(const json &source) override
inherited from jsoner
Definition: html_entrepot_landing.cpp:178
virtual json save_json() const override
inherited from jsoner
Definition: html_entrepot_landing.cpp:224
void set_event_landing_path(const std::string &name)
change landing_path_only_changed event name
Definition: html_entrepot_landing.cpp:172
virtual void new_css_library_available() override
inherited from body_builder
Definition: html_entrepot_landing.cpp:285
virtual void css_classes_have_changed() override
inherited from body_builder
Definition: html_entrepot_landing.cpp:274
virtual void on_event(const std::string &event_name) override
inherited from actor parent class
Definition: html_entrepot_landing.cpp:124
std::shared_ptr< libdar::entrepot > & get_entrepot(std::shared_ptr< html_web_user_interaction > &webui) const
provide an libdar entrepot object build from Web fields values
Definition: html_entrepot_landing.cpp:103
void set_event_entrepot(const std::string &name)
change the change event name
Definition: html_entrepot_landing.cpp:166
virtual void bind_to_anchor(const std::string &val) override
inherited from body_builder
Definition: html_entrepot_landing.hpp:104
static const std::string changed
event triggered for any change (entrepot and / or landing_path)
Definition: html_entrepot_landing.hpp:59
virtual void inherited_run() override
inherited from libthreadar::thread
Definition: html_entrepot_landing.cpp:295
class html_entrepot let user define an entrepot parameters
Definition: html_entrepot.hpp:58
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 implements HTML input feature
Definition: html_form_input.hpp:57
class html_form implements HTML form feature
Definition: html_form.hpp:51
virtual void bind_to_anchor(const std::string &value) override
inherited from body_builder
Definition: html_form.hpp:83
html_libdar_running_popup wraps up an html_web_user_interaction in a html_popup component
Definition: html_libdar_running_popup.hpp:48
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