Webdar 1.0.0
Web user interface to libdar
html_form_overwrite_base_criterium.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_FORM_OVERWRITE_BASE_CRITERIUM_HPP
25#define HTML_FORM_OVERWRITE_BASE_CRITERIUM_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31
32}
33
34 // C++ system header files
35
36 // webdar headers
37#include "html_overwrite_criterium.hpp"
38#include "actor.hpp"
39#include "body_builder.hpp"
40#include "html_form_input.hpp"
41#include "html_datetime.hpp"
42#include "html_form_select.hpp"
43#include "html_form_fieldset.hpp"
44#include "jsoner.hpp"
45#include "events.hpp"
46
48
50 public actor,
51 public jsoner,
52 public events
53{
54public:
55
56 // events
57
58 static const std::string changed;
59
60 // base modes for see set_mode()
61
62 static constexpr const char* crit_in_place_is_inode = "in place entry is an inode";
63 static constexpr const char* crit_in_place_is_dir = "in place entry is a directory";
64 static constexpr const char* crit_in_place_is_file = "in place entry is a plain file";
65 static constexpr const char* crit_in_place_is_hardlinked_inode = "in place entry is a hard linked inode";
66 static constexpr const char* crit_in_place_is_new_hardlinked_inode = "in place entry is a hard linked inode we meet for the first time";
67 static constexpr const char* crit_in_place_data_more_recent = "in place inode has more recent data";
68 static constexpr const char* crit_in_place_data_more_recent_or_equal_to = "in place inode a data more recent than or equal to: ";
69 static constexpr const char* crit_in_place_data_bigger = "both are plain files and in place one is bigger file";
70 static constexpr const char* crit_in_place_data_saved = "in place has its data saved or is not an inode";
71 static constexpr const char* crit_in_place_data_dirty = "in place entry is a dirty file";
72 static constexpr const char* crit_in_place_data_sparse = "in place entry is a sparse file";
73 static constexpr const char* crit_in_place_has_delta_sig = "in place entry has a delta signature attached";
74 static constexpr const char* crit_same_inode_data = "both entry are of the same type and have the same metadata";
75 static constexpr const char* crit_in_place_EA_present = "in place entry has Extended Attributes";
76 static constexpr const char* crit_in_place_EA_more_recent = "in place entry has more recent Extended Attributes";
77 static constexpr const char* crit_in_place_EA_more_recent_or_equal_to = "in place entry has EA more recent than or equal to:";
78 static constexpr const char* crit_in_place_more_EA = "in place entry has more Extended Attributes";
79 static constexpr const char* crit_in_place_EA_bigger = "in place entry has bigger Extended Attributes";
80 static constexpr const char* crit_in_place_EA_saved = "in place entry has Extended Attributes saved";
81 static constexpr const char* crit_same_type = "both entries are of the same type";
82
83
88 html_form_overwrite_base_criterium & operator = (html_form_overwrite_base_criterium && ref) noexcept = delete;
90
92
94 void set_mode(const std::string & mode) { base.set_selected_id(mode); };
95
97
99 void set_invert(bool val) { invert.set_value_as_bool(val); };
100
102
104 void set_negate(bool val) { negate.set_value_as_bool(val); };
105
107
109 void set_date(const libdar::infinint & val) { date.set_value(val); };
110
112
114 void set_hourshift(unsigned int shift) { hourshift.set_value_as_int(shift); };
115
116
118 virtual std::unique_ptr<libdar::criterium> get_overwriting_criterium() const override;
119
121 virtual void load_json(const json & source) override;
122
124 virtual json save_json() const override;
125
127 virtual void clear_json() override;
128
130 virtual void on_event(const std::string & event_name) override;
131
132protected:
133
135 virtual std::string inherited_get_body_part(const chemin & path,
136 const request & req) override;
137
138private:
139 bool trigger_change;
140
141 html_form_fieldset crit_fs;
142 html_form_input negate;
143 html_form_input invert;
144 html_form_select base;
146 html_form_input hourshift;
147
148 static constexpr const unsigned int format_version = 1;
149 static constexpr const char* myclass_id = "html_form_overwrite_base_criterium";
150
151 static constexpr const char* jlabel_negate = "negate";
152 static constexpr const char* jlabel_invert = "invert";
153 static constexpr const char* jlabel_base = "base";
154 static constexpr const char* jlabel_date = "date";
155 static constexpr const char* jlabel_hourshift = "hourshift";
156
157
158};
159
160#endif
class of object that are pointed/triggered to by others
Definition: actor.hpp:55
class chemin definition
Definition: chemin.hpp:51
stores and manipulates date-time and its formatting to human representation
Definition: date.hpp:49
class events
Definition: events.hpp:52
class html_datetime is a html_form_field object
Definition: html_datetime.hpp:55
class html_form_fieldset implements HTML fieldset feature
Definition: html_form_fieldset.hpp:51
class html_form_input implements HTML input feature
Definition: html_form_input.hpp:57
html component to be adopted by an html_form that implements atomic/base actions for overwriting poli...
Definition: html_form_overwrite_base_criterium.hpp:53
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
inherited from body_builder from html_overwrite_criterium
Definition: html_form_overwrite_base_criterium.cpp:267
virtual void clear_json() override
inherited from jsoner
Definition: html_form_overwrite_base_criterium.cpp:227
void set_negate(bool val)
set invert value
Definition: html_form_overwrite_base_criterium.hpp:104
virtual json save_json() const override
inherited from jsoner
Definition: html_form_overwrite_base_criterium.cpp:212
void set_date(const libdar::infinint &val)
set date
Definition: html_form_overwrite_base_criterium.hpp:109
void set_mode(const std::string &mode)
set the base mode (use crit_* static char* above)
Definition: html_form_overwrite_base_criterium.hpp:94
virtual void load_json(const json &source) override
inherited from jsoner
Definition: html_form_overwrite_base_criterium.cpp:176
virtual void on_event(const std::string &event_name) override
inherited from actor
Definition: html_form_overwrite_base_criterium.cpp:241
virtual std::unique_ptr< libdar::criterium > get_overwriting_criterium() const override
obtain the crit_base_criterium object for libdar option
Definition: html_form_overwrite_base_criterium.cpp:107
void set_hourshift(unsigned int shift)
set hourshift
Definition: html_form_overwrite_base_criterium.hpp:114
void set_invert(bool val)
set invert value
Definition: html_form_overwrite_base_criterium.hpp:99
void set_selected_id(const std::string &id)
set the radio buttons to the item id given in argument
Definition: html_form_radio.cpp:89
class html_form_select implements HTML input of type "select"
Definition: html_form_select.hpp:53
html ancestor class used for the criterium in html_form_overwrite_conditional_action class
Definition: html_overwrite_criterium.hpp:47
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