You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ubl-settings-diskquota/source/ubl-settings-diskquota.h

398 lines
18 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef UBL_SETTINGS_QUOTAS_H
#define UBL_SETTINGS_QUOTAS_H
#include "util.h"
#include "load.h"
#include "save.h"
#include "my_process.h"
#include "my_type.h"
#include "my_device.h"
#include "system_quotas.h"
#include "ubconfig_quotas.h"
#include <dlfcn.h>
#include "ubl-settings-diskquota-cm.h"
#ifdef WEBKIT_FOUND
#include <webkit2/webkit2.h>
#endif
#define copyright _("Copyright © UBSoft LLC, 2022 - ")
#define name_app _("ubl-settings-diskquota")
#define website _("https://wiki.ublinux.com")
#define project_Home_page _("Project Home Page")
#define configuring_system_boot _("Configuring system boot parameters")
#define system_boot _("System boot")
#define str_about _("About ubl-settings-diskquota")
#define command_line_parameters _("Command line parameters:")
#define load_default _("Load default:")
#define seconds _("seconds")
#define download_menu _("Download menu")
#define terminal_for_input _("Terminal for input")
#define terminal_for_output _("Terminal for output")
#define boot_selection_menu_timer _("Boot selection menu timer")
#define str_help _("Help")
#define str_about_1 _("About")
#define str_save_local _("Save")
#define str_load_local _("Load")
#define save_all _("Save to global and local configuration")
#define save_local _("Save local configuration")
#define save_global _("Save global configuration")
#define load_global _("Load global configuration")
#define load_local _("Load local configuration")
#define read_online _("Read online")
#define cancel _("Cancel")
#define always_redirect _("Always redirect")
#define boot_screen_display_mode _("Boot screen display mode:")
#define no_loading_animation _("No loading animation, full log")
#define boot_menu_user_name _("Boot menu user name:")
#define boot_menu_user_password _("Boot menu user password:")
#define last_successful_upload _("Last successful upload")
#define read_documentation_web _("Would you like to read documentation in the Web?")
#define redirected_documentation _("You will be redirected to documentation site, where user help pages are ""translated and supported by community.")
#define local_read_error _("Local configuration reading error")
#define global_read_error _("Global configuration read error")
#define local_write_error _("Local configuration write error")
#define global_write_error _("Global configuration write error")
#define error_save_all _("Error saved local and global configuration")
#define local_load_ok _("Local configuration downloaded successfully")
#define global_load_ok _("Global configuration downloaded successfully")
#define local_ok_written _("Local configuration successfully written")
#define global_ok_written _("Global configuration successfully written")
#define successfully_save_all _("Successfully saved local and global configuration")
#define nothing_save _("Nothing to save!")
#define program_as_root _("The program must be run as root")
#define str_weeks _("weeks")
#define str_days _("days")
#define str_hours _("hours")
#define str_minutes _("minutes")
#define str_device _("Device:")
#define str_setting_user _("Setting user quotas")
#define str_users _("Users")
#define str_groups _("Groups")
#define str_files _("files")
#define str_hard_limit _("Hard limit")
#define str_file_system _("File system:")
#define str_name _("Name")
#define str_size _("Size")
#define str_lb_head _("Configuration of disk quotas parameters for system groups and users")
#define str_soft_limit _("Soft limit")
#define str_currently_using _("Currently using:")
#define str_currently_using_space _("Currently using: ")
#define str_filters _("Filters")
#define str_projects _("Projects")
#define str_quotas _("Quotas")
#define str_help_h _("GTK settings quotas. for UBLinux\n\n""Usage: ubl-settings-diskquota [OPTIONS...]\n""Options:\n"" -h, --help Show this help\n"" -V, --version Show package version\n")
#define str_version _("ubl-settings-diskquota version: ")
#define str_user _("User")
#define str_group _("Group")
#define str_device_project _("Device\nProject")
#define str_quota _("Quota type")
#define str_status _("Status")
#define str_excess_size_delay _("Excess size delay period")
#define str_excess_files_delay _("Excess files delay period")
#define str_disk_quotas_device _("Disk quotas for this device:")
#define str_user_quotas_device _("User quotas for this device: ")
#define str_soft_limit_size _("Soft limit (size)")
#define str_hard_limit_size _("Hard limit (size)")
#define str_deferring_hard_limit_size _("Deferring a hard limit (size)")
#define str_hard_activation_size _("Hard limit activation time (size)")
#define str_soft_restriction_files _("Soft Restriction (files)")
#define str_severe_limitation_files _("Severe limitation (files)")
#define str_deferring_limit_files _("Deferring a hard limit (files)")
#define str_hard_limit_time _("Hard limit (file) activation time")
#define str_group_quotas_device _("Group quotas for this device:")
#define str_general_settings _("General settings")
#define str_tw_soft_limit _("Soft limit\n(size)")
#define str_tw_severe_limitation _("Severe\nlimitation\n(size)")
#define str_tw_deferring_size _("Deferring\na hard\nlimit\n(size)")
#define str_tw_soft_limit_files _("Soft limit\n(files)")
#define str_tw_severe_limitation_files _("Severe\nlimitation\n(files)")
#define str_tw_deferring_limit_files _("Deferring\na hard\nlimit\n(files)")
#define info_box_ok_css "boxInfoMessOK"
#define info_box_error_css "boxInfoMessError"
#define icon_checked "com.ublinux.ubl-settings-diskquota.checked"
#define icon_warning "com.ublinux.ubl-settings-diskquota.warning"
#define link_doc "https://wiki.ublinux.com/ru/Программное_обеспечениерограммы_и_утилиты/Все/ubl-settings-diskquota"
#define cmd_xdg "xdg-open "
#define cmd_execute "su -l %s -c \" DISPLAY=$DISPLAY %s \""
#define path_app "/usr/bin/"
#define path_glade "/usr/share/ubl-settings-diskquota/ui/ubl-settings-diskquota.glade"
#define path_css "/usr/share/ubl-settings-diskquota/css/ubl-settings-diskquota.css"
#define app_name "ubl-settings-diskquota"
#define path_resources "/usr/share/ubl-settings-diskquota"
#define path_img_head_background "/usr/share/ubl-settings-diskquota/images/logo-background.png"
using namespace std;
extern string version_application;
extern int socket_ext_id_I;
extern int socket_trd_id_I;
class MainWindow : public Gtk::ApplicationWindow {
public:
class ModelColumns : public Gtk::TreeModel::ColumnRecord {
public:
ModelColumns() {add(name), add(quotas); add(size),
add(soft_limit_size), add(hard_limit_size); add(hard_limit_size_delay),
add(files); add(soft_limit_files),
add(hard_limit_files), add(hard_limit_delay); }
Gtk::TreeModelColumn<Glib::ustring> name;
Gtk::TreeModelColumn<bool> quotas;
Gtk::TreeModelColumn<Glib::ustring> size;
Gtk::TreeModelColumn<Glib::ustring> soft_limit_size;
Gtk::TreeModelColumn<Glib::ustring> hard_limit_size;
Gtk::TreeModelColumn<Glib::ustring> hard_limit_size_delay;
Gtk::TreeModelColumn<Glib::ustring> files;
Gtk::TreeModelColumn<Glib::ustring> soft_limit_files;
Gtk::TreeModelColumn<Glib::ustring> hard_limit_files;
Gtk::TreeModelColumn<Glib::ustring> hard_limit_delay;
};
class ModelColumnsGeneral : public Gtk::TreeModel::ColumnRecord {
public:
ModelColumnsGeneral() {add(status), add(type_quotas); add(device),
add(user), add(group); add(soft_limit_size),
add(hard_limit_size); add(hard_limit_size_delay);
add(soft_limit_files), add(hard_limit_files), add(hard_limit_delay); }
Gtk::TreeModelColumn<bool> status;
Gtk::TreeModelColumn<Glib::ustring> type_quotas;
Gtk::TreeModelColumn<Glib::ustring> device;
Gtk::TreeModelColumn<Glib::ustring> user;
Gtk::TreeModelColumn<Glib::ustring> group;
Gtk::TreeModelColumn<Glib::ustring> soft_limit_size;
Gtk::TreeModelColumn<Glib::ustring> hard_limit_size;
Gtk::TreeModelColumn<Glib::ustring> hard_limit_size_delay;
Gtk::TreeModelColumn<Glib::ustring> soft_limit_files;
Gtk::TreeModelColumn<Glib::ustring> hard_limit_files;
Gtk::TreeModelColumn<Glib::ustring> hard_limit_delay;
};
ModelColumns m_columns;
ModelColumnsGeneral m_columnsGeneral;
Glib::RefPtr<Gtk::Builder> builder;
template<typename Type>
struct Result{
Type response;
int error;
};
Gtk::Label *headerTopic;
Gtk::AboutDialog *aboutWindows;
Gtk::Overlay *HeadOverlay;
Gtk::HeaderBar *headerBar;
Gtk::Box *boxSave;
Gtk::Box *boxButton;
Gtk::Box *boxFuncs;
Gtk::MenuButton *btnSave;
Gtk::MenuButton *btnLoad;
Gtk::MenuButton *btnSettings;
Gtk::ButtonBox *btnBoxAboutDialog;
Gtk::Image *HeadBackgroundImage;
Gtk::Image *imgInfo;
Gtk::Box *boxInfoError;
Gtk::Label *lblWarning;
Gtk::Label *generalTabLabel;
Gtk::Label *UsersTabLabel;
Gtk::Label *GroupsTabLabel;
Gtk::Label *generalGroupsSizeLabel;
Gtk::Label *generalGroupsFilesLabel;
Gtk::Label *generalUsersSizeLabel;
Gtk::Label *generalUsersFilesLabel;
Gtk::Label *generalGroupsSizeWeeksLabel;
Gtk::Label *generalGroupsFilesWeeksLabel;
Gtk::Label *generalUsersSizeWeeksLabel;
Gtk::Label *generalUsersFilesWeeksLabel;
Gtk::Label *generalGroupsSizeDaysLabel;
Gtk::Label *generalGroupsFilesDaysLabel;
Gtk::Label *generalUsersSizeDaysLabel;
Gtk::Label *generalUsersFilesDaysLabel;
Gtk::Label *generalGroupsSizeHoursLabel;
Gtk::Label *generalGroupsFilesHoursLabel;
Gtk::Label *generalUsersSizeHoursLabel;
Gtk::Label *generalUsersFilesHoursLabel;
Gtk::Label *generalGroupsSizeMinutesLabel;
Gtk::Label *generalGroupsFilesMinutesLabel;
Gtk::Label *generalUsersSizeMinutesLabel;
Gtk::Label *generalUsersFilesMinutesLabel;
Gtk::Label *ProjectTabLabel;
Gtk::Label *usersProjectLabel;
Gtk::Label *lblLoad;
Gtk::Label *lblSave;
Gtk::MenuItem *btnLoadGlob;
Gtk::MenuItem *btnLoadLocal;
Gtk::MenuItem *btnSynopsis;
Gtk::MenuItem *btnAbout;
Gtk::MenuItem *btnSaveLocalGlob;
Gtk::MenuItem *btnSaveGlob;
Gtk::MenuItem *btnSaveLocal;
Gtk::Label *groupsDeviceLabel;
Gtk::Label *usersDeviceLabel;
Gtk::Label *headLabel;
Gtk::Window *FiltersWindow;
Gtk::CheckButton *filtersNameFilterCheckbox;
Gtk::CheckButton *filtersQuotasFilterCheckbox;
Gtk::CheckButton *filtersSizeFilterCheckbox;
Gtk::CheckButton *filtersSoftSizeFilterCheckbox;
Gtk::CheckButton *filtersHardSizeFilterCheckbox;
Gtk::CheckButton *filtersHardSizeDelayFilterCheckbox;
Gtk::CheckButton *filtersHardSizeActivationFilterCheckbox;
Gtk::CheckButton *filtersFilesFilterCheckbox;
Gtk::CheckButton *filtersSoftFilesFilterCheckbox;
Gtk::CheckButton *filtersHardFilesFilterCheckbox;
Gtk::CheckButton *filtersHardFilesDelayFilterCheckbox;
Gtk::CheckButton *filtersHardFilesActivationFilterCheckbox;
Gtk::TreeView *groupsQuotasTree;
Gtk::TreeView *usersQuotasTree;
Gtk::TreeView *ProjectQuotasTree;
Gtk::TreeView *GeneralQuotasTree;
Gtk::Label *quotegroupDeviceLabel;
Gtk::Label *quotegroupFileSystemLabel;
Gtk::Label *quotegroupDiskQuotasLabel;
Gtk::Label *quotegroupGroupQuotasLabel;
Gtk::Label *quotegroupSizeFrameLabel;
Gtk::Label *quotegroupSizeCurrentlyLabel;
Gtk::Label *quoteSizeHardLimitLabel;
Gtk::Label *quotegroupFilesFrameLabel;
Gtk::Label *quotegroupFilesCurrentlyLabel;
Gtk::Label *quotegroupFilesSoftLimitLabel;
Gtk::Label *quoteFilesHardLimitLabel;
Gtk::Label *quotegroupFilesHarLimitLabel;
Gtk::Label *quoteuserDeviceLabel;
Gtk::Label *quoteuserDiskQuotasLabel;
Gtk::Label *quoteuserFileSystemLabel;
Gtk::Label *quoteuserGroupQuotasLabel;
Gtk::Label *quoteuserSizeFrameLabel;
Gtk::Label *quoteuserSizeCurrentlyLabel;
Gtk::Label *quoteuserSizeSoftLimitLabel;
Gtk::Label *quoteuserSizeHardLimitLabel1;
Gtk::Label *quoteuserFilesCurrentlyLabel;
Gtk::Label *quoteuserFilesSoftLimitLabel;
Gtk::Label *quoteFilesHardLimitLabel1;
Gtk::Label *quoteuserFilesHarLimitLabel;
Gtk::Label *quoteuserFilesFrameLabel;
Gtk::Label *quotegroupSizeSoftLimitLabel;
Gtk::Label *quoteuserFilesSoftLimitlabel;
Gtk::Window *QuotasUserEditWindow;
Gtk::Window *QuotasEditWindow;
Gtk::Label *headerAboutTopic;
Gtk::Label *lblHeadQuotasUserEditWindow;
Gtk::Label *lblHeadQuotasEditWindow;
Gtk::Label *lblHeadFiltersWindow;
Gtk::ComboBoxText *usersDeviceCombo;
Gtk::ComboBoxText *groupsDeviceCombo;
Gtk::ComboBoxText *generalDeviceCombo;
Gtk::Label *lblFstypeGroups;
Gtk::SpinButton *generalGroupsSizeWeeksSpi;
Gtk::SpinButton *generalGroupsFileWeeksSpin;
Gtk::SpinButton *generalGroupsSizeDaySpin;
Gtk::SpinButton *generalGroupsFilesDaySpin;
Gtk::SpinButton *generalGroupsSizeHourSpin;
Gtk::SpinButton *generalGroupsFilesHourSpin;
Gtk::SpinButton *generalGroupsSizeMinuteSpin;
Gtk::SpinButton *generalGroupsFilesMinuteSpin;
Gtk::SpinButton *generalUsersSizWeeksSpin;
Gtk::SpinButton *generalUsersFileWeeksSpin;
Gtk::SpinButton *generalUsersSizeDaySpin;
Gtk::SpinButton *generalUsersFilesDaySpin;
Gtk::SpinButton *generalUsersSizeHourSpin;
Gtk::SpinButton *generalUsersFilesHoursSpin;
Gtk::SpinButton *generalUsersSizeMinuteSpin;
Gtk::SpinButton *generalUsersFilesMinutesSpin;
Gtk::Label *lblEditWndFsys;
Gtk::CheckButton *quotegroupSizeSoftLimitCheck;
Gtk::CheckButton *quotegroupSizeHardLimitCheck;
Gtk::CheckButton *quotegroupFilesSoftLimitCheck;
Gtk::CheckButton *quotegroupFilesHardLimitCheck;
Gtk::SpinButton *quotegroupSizeSoftLimitSpin;
Gtk::SpinButton *quotegroupSizeHardLimitSpin;
Gtk::SpinButton *quotegroupFilesSoftLimitSpin;
Gtk::SpinButton *quotegroupFilesHardLimitSpin;
Gtk::Label *quotegroupFilesSoftLimitlabel;
Gtk::ComboBoxText *quotegroupSizeSoftLimitCombo;
Gtk::ComboBoxText *quotegroupSizeHardLimitCombo;
Gtk::Button *quotegroupCancelButton;
Gtk::Button *quotegroupSaveButton;
Gtk::Button *btnFilterGroups;
Gtk::Button *btnFilterUsers;
Gtk::Button *btnFilterProject;
Gtk::ComboBoxText *quotegroupDeviceCombo;
Gtk::Label *lblHeadeWndWeb;
Gtk::Label *lblwebHeaderName;
Gtk::Label *lblhelpText;
Gtk::Label *lblhelpHeader;
Gtk::CheckButton *chkAlwaysOpenHelp;
Gtk::Button *btnReadHelp;
Gtk::Button *btnCancelHelp;
Gtk::Window *wndShowWeb;
#ifdef WEBKIT_FOUND
Gtk::Window *wndWeb;
Gtk::Widget *three;
WebKitWebView *one;
#endif
public:
Lib_save::Save obj_save = Lib_save::Save();
Lib_Load::Load obj_load = Lib_Load::Load();
Devices::Parted obj_device = Devices::Parted();
Quotas_sys::Quotas_sys obj_quotas_sys = Quotas_sys::Quotas_sys();
Quotas_ubconfig::Quotas_ubconfig obj_quotas_ubconfig = Quotas_ubconfig::Quotas_ubconfig();
My_Process::My_Process_system obj_process_system = My_Process::My_Process_system();
My_Process::My_Process_call obj_process_call = My_Process::My_Process_call();
map_str_str map_gui_cfg;
map_str_str map_global_cfg;
map_str_str map_system_cfg;
vector<string> vec_param_names;
map_str_str map_device;
string str_cmd_error;
string save_user_or_group;
string sys_or_ubconfig;
string hw_or_sw = "";
bool flag_open_browser = false;
public:
MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder);
MainWindow(Glib::RefPtr<Gtk::Builder> const& builder);
~MainWindow();
void settings();
void lacalization();
void add_CSS();
void get_builder();
void event();
void init_tree_view_general();
void entry_combo_box_temp(Gtk::ComboBoxText *combo_box, Gtk::Label *label);
void synopsis_show();
void info_status_app(string stule);
void groupsFilters_show();
void init_tree_view();
void template_open_browser();
void open_browser();
void load_template(map_str_str* map_temp, string str_load);
void info_warning_error(int mess);
void off_quota_system(Gtk::ComboBoxText* combo_box, string quota_type);
void wrapper_save_system_cfg();
void wrapper_save_global_cfg();
void wrapper_save_all_cfg();
void init_dict(string flag_load);
void set_data_cfg();
void save_quotegroupSaveButton();
void wrapper_settings_quotas_temp(string save_user_or_group);
void off_quota_ubconfig(Gtk::ComboBoxText* combo_box, string quota_type);
void init_spin_all();
void format_cmd_quotas_system(struct struct_quotas& _struct_quota);
void format_cmd_quotas_ubconfig(struct struct_quotas& _struct_quota);
void load_global_cfg();
void load_system_cfg();
struct partition_cmd wrapper_settings_quotas();
void filling_device_combo_box_template(Gtk::ComboBoxText *combo_box, map_str_str &map_device);
bool save_template(string section, string flag_save);
void view_add_columns(Gtk::TreeView &treeView);
void check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::ComboBoxText *combo_box);
void check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::Label *combo_box);
};
void help();
#endif