00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00033
00034
00036
00037
00039 #include "infinint.hpp"
00041
00042
00043
00044 #ifndef USER_INTERACTION_HPP
00045 #define USER_INTERACTION_HPP
00046
00047 #include "../my_config.h"
00048
00049 #include <string>
00050 #include "erreurs.hpp"
00051 #include "integers.hpp"
00052
00053 namespace libdar
00054 {
00055
00057
00091 class user_interaction
00092 {
00093 public:
00094
00096 user_interaction();
00097
00099
00103 virtual void pause(const std::string & message)
00104 {
00105 if(!pause2(message))
00106 throw Euser_abort(message);
00107 };
00108
00110
00117 virtual bool pause2(const std::string & message)
00118 { throw Elibcall("user_interaction::pause2", "user_interaction::pause() or pause2() must be overwritten !"); };
00119
00120
00126 void warning(const std::string & message);
00127
00129
00133 virtual std::string get_string(const std::string & message, bool echo) = 0;
00134
00141
00153 virtual void listing(const std::string & flag,
00154 const std::string & perm,
00155 const std::string & uid,
00156 const std::string & gid,
00157 const std::string & size,
00158 const std::string & date,
00159 const std::string & filename,
00160 bool is_dir,
00161 bool has_children);
00162
00163
00164
00171
00176 virtual void dar_manager_show_files(const std::string & filename,
00177 bool available_data,
00178 bool available_ea);
00179
00180
00187
00192 virtual void dar_manager_contents(U_I number,
00193 const std::string & chemin,
00194 const std::string & archive_name);
00195
00202
00209 virtual void dar_manager_statistics(U_I number,
00210 const infinint & data_count,
00211 const infinint & total_data,
00212 const infinint & ea_count,
00213 const infinint & total_ea);
00214
00221
00226 virtual void dar_manager_show_version(U_I number,
00227 const std::string & data_date,
00228 const std::string & ea_date);
00229
00231
00239 void printf(char *format, ...);
00240
00244
00246 bool get_use_listing() const { return use_listing; };
00248 bool get_use_dar_manager_show_files() const { return use_dar_manager_show_files; };
00250 bool get_use_dar_manager_contents() const { return use_dar_manager_contents; };
00252 bool get_use_dar_manager_statistics() const { return use_dar_manager_statistics; };
00254 bool get_use_dar_manager_show_version() const { return use_dar_manager_show_version; };
00255
00256
00258
00264 virtual user_interaction *clone() const = 0;
00265
00267
00272 void warning_with_more(U_I num) { at_once = num; count = 0; };
00273
00274 protected:
00275
00277
00282 void set_use_listing(bool val) { use_listing = val; };
00283
00285 void set_use_dar_manager_show_files(bool val) { use_dar_manager_show_files = val; };
00286
00288 void set_use_dar_manager_contents(bool val) { use_dar_manager_contents = val; };
00289
00291 void set_use_dar_manager_statistics(bool val) { use_dar_manager_statistics = val; };
00292
00294 void set_use_dar_manager_show_version(bool val) { use_dar_manager_show_version = val; };
00295
00297
00300 virtual void inherited_warning(const std::string & message) = 0;
00301
00302 private:
00303 bool use_listing;
00304 bool use_dar_manager_show_files;
00305 bool use_dar_manager_contents;
00306 bool use_dar_manager_statistics;
00307 bool use_dar_manager_show_version;
00308 U_I at_once, count;
00309
00310 };
00311
00312
00314
00318 class user_interaction_callback : public user_interaction
00319 {
00320 public:
00321
00323
00333 user_interaction_callback(void (*x_warning_callback)(const std::string &x, void *context),
00334 bool (*x_answer_callback)(const std::string &x, void *context),
00335 std::string (*x_string_callback)(const std::string &x, bool echo, void *context),
00336 void *context_value);
00337
00338
00340 void pause(const std::string & message);
00342 std::string get_string(const std::string & message, bool echo);
00343
00345 void listing(const std::string & flag,
00346 const std::string & perm,
00347 const std::string & uid,
00348 const std::string & gid,
00349 const std::string & size,
00350 const std::string & date,
00351 const std::string & filename,
00352 bool is_dir,
00353 bool has_children);
00354
00356 void dar_manager_show_files(const std::string & filename,
00357 bool available_data,
00358 bool available_ea);
00359
00361 void dar_manager_contents(U_I number,
00362 const std::string & chemin,
00363 const std::string & archive_name);
00364
00366 void dar_manager_statistics(U_I number,
00367 const infinint & data_count,
00368 const infinint & total_data,
00369 const infinint & ea_count,
00370 const infinint & total_ea);
00371
00373 void dar_manager_show_version(U_I number,
00374 const std::string & data_date,
00375 const std::string & ea_date);
00376
00378
00382 void set_listing_callback(void (*callback)(const std::string & flag,
00383 const std::string & perm,
00384 const std::string & uid,
00385 const std::string & gid,
00386 const std::string & size,
00387 const std::string & date,
00388 const std::string & filename,
00389 bool is_dir,
00390 bool has_children,
00391 void *context))
00392 {
00393 tar_listing_callback = callback;
00394 set_use_listing(true);
00395 };
00396
00397
00398
00399 void set_dar_manager_show_files_callback(void (*callback)(const std::string & filename,
00400 bool available_data,
00401 bool available_ea,
00402 void *context))
00403 {
00404 dar_manager_show_files_callback = callback;
00405 set_use_dar_manager_show_files(true);
00406 };
00407
00408 void set_dar_manager_contents_callback(void (*callback)(U_I number,
00409 const std::string & chemin,
00410 const std::string & archive_name,
00411 void *context))
00412 {
00413 dar_manager_contents_callback = callback;
00414 set_use_dar_manager_contents(true);
00415 };
00416
00417 void set_dar_manager_statistics_callback(void (*callback)(U_I number,
00418 const infinint & data_count,
00419 const infinint & total_data,
00420 const infinint & ea_count,
00421 const infinint & total_ea,
00422 void *context))
00423 {
00424 dar_manager_statistics_callback = callback;
00425 set_use_dar_manager_statistics(true);
00426 };
00427
00428 void set_dar_manager_show_version_callback(void (*callback)(U_I number,
00429 const std::string & data_date,
00430 const std::string & ea_date,
00431 void *context))
00432 {
00433 dar_manager_show_version_callback = callback;
00434 set_use_dar_manager_show_version(true);
00435 };
00436
00437
00439 virtual user_interaction *clone() const;
00440
00441 protected:
00443 void inherited_warning(const std::string & message);
00444
00445 private:
00446 void (*warning_callback)(const std::string & x, void *context);
00447 bool (*answer_callback)(const std::string & x, void *context);
00448 std::string (*string_callback)(const std::string & x, bool echo, void *context);
00449 void (*tar_listing_callback)(const std::string & flags,
00450 const std::string & perm,
00451 const std::string & uid,
00452 const std::string & gid,
00453 const std::string & size,
00454 const std::string & date,
00455 const std::string & filename,
00456 bool is_dir,
00457 bool has_children,
00458 void *context);
00459 void (*dar_manager_show_files_callback)(const std::string & filename,
00460 bool available_data,
00461 bool available_ea,
00462 void *context);
00463 void (*dar_manager_contents_callback)(U_I number,
00464 const std::string & chemin,
00465 const std::string & archive_name,
00466 void *context);
00467 void (*dar_manager_statistics_callback)(U_I number,
00468 const infinint & data_count,
00469 const infinint & total_data,
00470 const infinint & ea_count,
00471 const infinint & total_ea,
00472 void *context);
00473 void (*dar_manager_show_version_callback)(U_I number,
00474 const std::string & data_date,
00475 const std::string & ea_date,
00476 void *context);
00477
00478 void *context_val;
00479 };
00480
00481 }
00482
00483 #endif
00484