| Disk ARchive 2.6.12 Full featured and portable backup and archiving tool

user_interaction_callback5.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2020 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21
25
26 #ifndef USER_INTERACTION_CALLBACK5_HPP
27 #define USER_INTERACTION_CALLBACK5_HPP
28
29 #include "../my_config.h"
30
31 #include "user_interaction5.hpp"
32
33 namespace libdar5
34 {
35
38
39
41
45
46 class user_interaction_callback : public user_interaction
47 {
48 public:
49
51
62 user_interaction_callback(void (*x_warning_callback)(const std::string &x, void *context),
63 bool (*x_answer_callback)(const std::string &x, void *context),
64 std::string (*x_string_callback)(const std::string &x, bool echo, void *context),
65 secu_string (*x_secu_string_callback)(const std::string &x, bool echo, void *context),
66 void *context_value);
67 user_interaction_callback(const user_interaction_callback & ref) = default;
68 user_interaction_callback(user_interaction_callback && ref) noexcept = default;
69 user_interaction_callback & operator = (const user_interaction_callback & ref) = default;
70 user_interaction_callback & operator = (user_interaction_callback && ref) noexcept = default;
71 ~user_interaction_callback() = default;
72
74 virtual void pause(const std::string & message) override;
76 virtual std::string get_string(const std::string & message, bool echo) override;
78 virtual secu_string get_secu_string(const std::string & message, bool echo) override;
80 virtual void listing(const std::string & flag,
81 const std::string & perm,
82 const std::string & uid,
83 const std::string & gid,
84 const std::string & size,
85 const std::string & date,
86 const std::string & filename,
87 bool is_dir,
88 bool has_children) override;
89
91 virtual void dar_manager_show_files(const std::string & filename,
92 bool available_data,
93 bool available_ea) override;
94
96 virtual void dar_manager_contents(U_I number,
97 const std::string & chemin,
98 const std::string & archive_name) override;
99
101 virtual void dar_manager_statistics(U_I number,
102 const infinint & data_count,
103 const infinint & total_data,
104 const infinint & ea_count,
105 const infinint & total_ea) override;
106
108 virtual void dar_manager_show_version(U_I number,
109 const std::string & data_date,
110 const std::string & data_presence,
111 const std::string & ea_date,
112 const std::string & ea_presence) override;
113
115
119 void set_listing_callback(void (*callback)(const std::string & flag,
120 const std::string & perm,
121 const std::string & uid,
122 const std::string & gid,
123 const std::string & size,
124 const std::string & date,
125 const std::string & filename,
126 bool is_dir,
127 bool has_children,
128 void *context))
129 {
130 tar_listing_callback = callback;
131 set_use_listing(true); // this is to inform libdar to use listing()
132 };
133
135 void set_dar_manager_show_files_callback(void (*callback)(const std::string & filename,
136 bool available_data,
137 bool available_ea,
138 void *context))
139 {
140 dar_manager_show_files_callback = callback;
141 set_use_dar_manager_show_files(true); // this is to inform libdar to use the dar_manager_show_files() method
142 };
143
144 void set_dar_manager_contents_callback(void (*callback)(U_I number,
145 const std::string & chemin,
146 const std::string & archive_name,
147 void *context))
148 {
149 dar_manager_contents_callback = callback;
150 set_use_dar_manager_contents(true); // this is to inform libdar to use the dar_manager_contents() method
151 };
152
153 void set_dar_manager_statistics_callback(void (*callback)(U_I number,
154 const infinint & data_count,
155 const infinint & total_data,
156 const infinint & ea_count,
157 const infinint & total_ea,
158 void *context))
159 {
160 dar_manager_statistics_callback = callback;
161 set_use_dar_manager_statistics(true); // this is to inform libdar to use the dar_manager_statistics() method
162 };
163
164 void set_dar_manager_show_version_callback(void (*callback)(U_I number,
165 const std::string & data_date,
166 const std::string & data_presence,
167 const std::string & ea_date,
168 const std::string & ea_presence,
169 void *context))
170 {
171 dar_manager_show_version_callback = callback;
172 set_use_dar_manager_show_version(true); // this is to inform libdar to use the dar_manager_show_version() method
173 };
174
175
177 virtual user_interaction *clone() const override;
178
179 protected:
181 void change_context_value(void *new_value) { context_val = new_value; };
182
184 virtual void inherited_warning(const std::string & message) override;
185
186 private:
187 void (*warning_callback)(const std::string & x, void *context); // pointer to function
188 bool (*answer_callback)(const std::string & x, void *context); // pointer to function
189 std::string (*string_callback)(const std::string & x, bool echo, void *context); // pointer to function
190 secu_string (*secu_string_callback)(const std::string & x, bool echo, void *context); // pointer to function
191 void (*tar_listing_callback)(const std::string & flags,
192 const std::string & perm,
193 const std::string & uid,
194 const std::string & gid,
195 const std::string & size,
196 const std::string & date,
197 const std::string & filename,
198 bool is_dir,
199 bool has_children,
200 void *context);
201 void (*dar_manager_show_files_callback)(const std::string & filename,
202 bool available_data,
203 bool available_ea,
204 void *context);
205 void (*dar_manager_contents_callback)(U_I number,
206 const std::string & chemin,
207 const std::string & archive_name,
208 void *context);
209 void (*dar_manager_statistics_callback)(U_I number,
210 const infinint & data_count,
211 const infinint & total_data,
212 const infinint & ea_count,
213 const infinint & total_ea,
214 void *context);
215 void (*dar_manager_show_version_callback)(U_I number,
216 const std::string & data_date,
217 const std::string & data_presence,
218 const std::string & ea_date,
219 const std::string & ea_presence,
220 void *context);
221
222 void *context_val;
223 };
224
226
227 } // end of namespace
228
229 #endif
libdar5::user_interaction_callback::get_secu_string
virtual secu_string get_secu_string(const std::string &message, bool echo) override
overwritting method from parent class.
libdar5::user_interaction_callback::user_interaction_callback
user_interaction_callback(void(*x_warning_callback)(const std::string &x, void *context), bool(*x_answer_callback)(const std::string &x, void *context), std::string(*x_string_callback)(const std::string &x, bool echo, void *context), secu_string(*x_secu_string_callback)(const std::string &x, bool echo, void *context), void *context_value)
constructor which receive the callback functions.
libdar5::user_interaction_callback::clone
virtual user_interaction * clone() const override
overwritting method from parent class.
libdar5::user_interaction_callback::pause
virtual void pause(const std::string &message) override
overwritting method from parent class.
libdar5::user_interaction::set_use_dar_manager_show_files
void set_use_dar_manager_show_files(bool val)
method to be called with true as argument if you have defined a dar_manager_show_files() method.
Definition: user_interaction5.hpp:289
libdar::infinint
the arbitrary large positive integer class
Definition: real_infinint.hpp:62
libdar5::user_interaction::set_use_dar_manager_contents
void set_use_dar_manager_contents(bool val)
method to be called with true as argument if you have defined a dar_manager_contents() method.
Definition: user_interaction5.hpp:292
libdar5::user_interaction_callback::change_context_value
void change_context_value(void *new_value)
change the context value of the object that will be given to callback functions
Definition: user_interaction_callback5.hpp:181
libdar5::user_interaction_callback::dar_manager_contents
virtual void dar_manager_contents(U_I number, const std::string &chemin, const std::string &archive_name) override
overwritting method from parent class
libdar5::user_interaction_callback::get_string
virtual std::string get_string(const std::string &message, bool echo) override
overwritting method from parent class.
libdar5::user_interaction_callback::dar_manager_show_version
virtual void dar_manager_show_version(U_I number, const std::string &data_date, const std::string &data_presence, const std::string &ea_date, const std::string &ea_presence) override
overwritting method from parent class
libdar5::user_interaction::set_use_dar_manager_statistics
void set_use_dar_manager_statistics(bool val)
method to be called with true as argument if you have defined a dar_manager_statistics() method.
Definition: user_interaction5.hpp:295
libdar5::user_interaction
This is a pure virtual class that is used by libdar when interaction with the user is required.
Definition: user_interaction5.hpp:88
libdar5::user_interaction_callback::inherited_warning
virtual void inherited_warning(const std::string &message) override
overwritting method from parent class.
libdar5
libdar5 namespace encapsulate all libdar symbols
Definition: archive5.hpp:37
libdar5::user_interaction::set_use_dar_manager_show_version
void set_use_dar_manager_show_version(bool val)
method to be called with true as argument if you have defined a dar_manager_show_version() method.
Definition: user_interaction5.hpp:298
libdar5::user_interaction_callback
full implemented class for user_interaction based on callback functions.
Definition: user_interaction_callback5.hpp:47
libdar5::user_interaction_callback::set_dar_manager_show_files_callback
void set_dar_manager_show_files_callback(void(*callback)(const std::string &filename, bool available_data, bool available_ea, void *context))
You can set a dar_manager_show_files callback thanks to this method.
Definition: user_interaction_callback5.hpp:135
libdar5::user_interaction_callback::dar_manager_show_files
virtual void dar_manager_show_files(const std::string &filename, bool available_data, bool available_ea) override
overwritting method from parent class
libdar::secu_string
class secu_string
Definition: secu_string.hpp:58
libdar5::user_interaction::set_use_listing
void set_use_listing(bool val)
method to be called with true as argument if you have defined a listing() method.
Definition: user_interaction5.hpp:286
user_interaction5.hpp
API v5 backward compatible class user_interaction.
libdar5::user_interaction_callback::set_listing_callback
void set_listing_callback(void(*callback)(const std::string &flag, const std::string &perm, const std::string &uid, const std::string &gid, const std::string &size, const std::string &date, const std::string &filename, bool is_dir, bool has_children, void *context))
You can set a listing callback thanks to this method.
Definition: user_interaction_callback5.hpp:119
libdar5::user_interaction_callback::dar_manager_statistics
virtual void dar_manager_statistics(U_I number, const infinint &data_count, const infinint &total_data, const infinint &ea_count, const infinint &total_ea) override
overwritting method from parent class
libdar5::user_interaction_callback::listing
virtual void listing(const std::string &flag, const std::string &perm, const std::string &uid, const std::string &gid, const std::string &size, const std::string &date, const std::string &filename, bool is_dir, bool has_children) override
overwritting method from parent class.