Webdar 1.0.0
Web user interface to libdar
choose.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 CHOOSE_HPP
25#define CHOOSE_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 <string>
36#include <vector>
37#include <libthreadar/libthreadar.hpp>
38
39 // webdar headers
40#include "session.hpp"
41#include "responder.hpp"
42#include "actor.hpp"
43#include "events.hpp"
44#include "html_page.hpp"
45#include "html_static_url.hpp"
46#include "html_form.hpp"
47#include "html_div.hpp"
48#include "html_table.hpp"
49#include "html_form_fieldset.hpp"
50#include "html_form_input.hpp"
51#include "html_form_radio.hpp"
52#include "html_yes_no_box.hpp"
53#include "html_disconnect.hpp"
54
56
60
61class choose : public responder, public actor
62{
63public:
64 // constructor
65 choose();
66 choose(const choose & ref) = delete;
67 choose(choose && ref) noexcept = delete;
68 choose & operator = (const choose & ref) = delete;
69 choose & operator = (choose && ref) noexcept = delete;
70 ~choose() { release_boxes(); };
71
73 void set_owner(const std::string & user);
74
76
78 virtual answer give_answer(const request & req) override;
79
81 virtual void on_event(const std::string & event_name) override;
82
84 bool disconnection_requested() const { bool ret = disconnect_req; disconnect_req = false; return ret; };
85
86private:
87 std::string owner;
88 mutable bool disconnect_req;
89 std::vector<html_form_input *> boxes; //< list of checkboxes in "page"
90 std::vector<session::session_summary> sess; //< list of sessions in page
91
93
94 html_page page;
95 html_disconnect disco;
96 html_table table;
97 html_div box_nouvelle;
98 html_static_url nouvelle;
99 html_form form;
100 html_div div;
101 html_yes_no_box confirmed;
102
103 void regenerate_table_page();
104 void release_boxes();
105 void kill_selected_sessions() const;
106
107 static const std::string css_class_normal_text;
108 static const std::string url_new_session;
109};
110
111#endif
class of object that are pointed/triggered to by others
Definition: actor.hpp:55
class answer provides easy means to set an HTTP answer and means to sent it back to a proto_connexion...
Definition: answer.hpp:49
display current existing user sessions and let user kill or change of session
Definition: choose.hpp:62
bool disconnection_requested() const
whether user has requested to disconnect
Definition: choose.hpp:84
virtual answer give_answer(const request &req) override
inherited from responder
Definition: choose.cpp:165
virtual void on_event(const std::string &event_name) override
inherited from actor
Definition: choose.cpp:205
choose()
Definition: choose.cpp:55
void set_owner(const std::string &user)
mandatory call before using other methods (give_answer() in particular)
Definition: choose.cpp:154
html component used for the user to define a has algorithm
Definition: html_disconnect.hpp:49
class html_div is the implementation of
Definition: html_div.hpp:46
class html_form implements HTML form feature
Definition: html_form.hpp:51
html page root component
Definition: html_page.hpp:45
html component implementing the usual hyperlink component
Definition: html_static_url.hpp:45
html component implementing the html table structure
Definition: html_table.hpp:52
html component for user to answer by yes or no to a provided question
Definition: html_yes_no_box.hpp:51
class holding fields of an HTTP request (method, URI, header, cookies, and so on)
Definition: request.hpp:45
pure virtual class, base class for all classes that can generate an answer to a request
Definition: responder.hpp:46
defines the event class