diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 6f07a84..9a7a9cb 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -18,8 +18,10 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissin set(SOURCE_FILES ubl-settings-diskquota.h ubl-settings-diskquota.cc - system_cmd_quotas.cc - system_cmd_quotas.h + ubconfig_quotas.h + ubconfig_quotas.cc + system_quotas.h + system_quotas.cc controler.h controler.cc my_device.h diff --git a/source/controler.h b/source/controler.h index eeacf19..aac6bb1 100644 --- a/source/controler.h +++ b/source/controler.h @@ -1,4 +1,5 @@ -#include "system_cmd_quotas.h" +#include "system_quotas.h" +#include "ubconfig_quotas.h" class Back_Back{ public: diff --git a/source/system_cmd_quotas.cc b/source/system_quotas.cc similarity index 90% rename from source/system_cmd_quotas.cc rename to source/system_quotas.cc index e7de561..13b5c81 100644 --- a/source/system_cmd_quotas.cc +++ b/source/system_quotas.cc @@ -1,32 +1,14 @@ -#include "system_cmd_quotas.h" +#include "system_quotas.h" #include "my_type.h" namespace Quotas_sys { + Quotas_sys::Quotas_sys() { map_hw_or_sw["ext2"] = "hw"; map_hw_or_sw["ext3"] = "hw"; map_hw_or_sw["nfs"] = "sw"; map_hw_or_sw["NFS"] = "sw"; } -void Quotas_sys::format_cmd_quotas_ubconfig(struct struct_quotas& _struct_quota) { - string key = "DISK_QUOTA["; - key += ":" + _struct_quota.device + "]"; - string value = _struct_quota.name + ":" + _struct_quota.cmd; - (*map_gui_cfg)[key] = value; -} - -void Quotas_sys::format_cmd_quotas_system(struct struct_quotas& _struct_quota) { - string key = "DISK_QUOTA["; - key += ":" + _struct_quota.device + "]"; - string value = _struct_quota.name + ":" + _struct_quota.cmd; - (*map_gui_cfg)[key] = value; -} - -void Quotas_sys::off_quota_ubconfig(string partition, string quota_type) { - string key = "DISK_QUOTA[" + quota_type + ":" + partition + "]"; - string value = "disable"; - (*map_gui_cfg)[key] = value; -} void Quotas_sys::set_map_gui(map_str_str &map_gui) { map_gui_cfg = &map_gui; @@ -182,6 +164,7 @@ vector Quotas_sys::pars_data(string cmd) { vec_struct_data.push_back(struct_data); } } + return vec_struct_data; } struct data_all_quotas Quotas_sys::part_quotas_line(string line) { diff --git a/source/system_cmd_quotas.h b/source/system_quotas.h similarity index 87% rename from source/system_cmd_quotas.h rename to source/system_quotas.h index 7ff0809..5362407 100644 --- a/source/system_cmd_quotas.h +++ b/source/system_quotas.h @@ -16,9 +16,7 @@ class Quotas_sys { public: Quotas_sys(); void set_map_gui(map_str_str &map_gui); - void format_cmd_quotas_ubconfig(struct struct_quotas& _struct_quota); void format_cmd_quotas_system(struct struct_quotas& _struct_quota); - void off_quota_ubconfig(string partition, string quota_type); bool off_quota_system(string partition, string quota_hw, string quota_sw); bool check_on_quotas_system(string cmd); struct status_quotas check_on_quotas_system_2_hw(string params); diff --git a/source/ubconfig_quotas.cc b/source/ubconfig_quotas.cc new file mode 100644 index 0000000..2471cdd --- /dev/null +++ b/source/ubconfig_quotas.cc @@ -0,0 +1,26 @@ +#include "ubconfig_quotas.h" + +namespace Quotas_ubconfig { + +void Quotas_ubconfig::format_cmd_quotas_ubconfig(struct struct_quotas& _struct_quota) { + string key = "DISK_QUOTA["; + key += ":" + _struct_quota.device + "]"; + string value = _struct_quota.name + ":" + _struct_quota.cmd; + (*map_gui_cfg)[key] = value; +} + +void Quotas_ubconfig::off_quota_ubconfig(string partition, string quota_type) { + string key = "DISK_QUOTA[" + quota_type + ":" + partition + "]"; + string value = "disable"; + (*map_gui_cfg)[key] = value; +} +void Quotas_ubconfig::set_map_gui(map_str_str &map_gui) { + map_gui_cfg = &map_gui; +} +Quotas_ubconfig::Quotas_ubconfig() { + map_hw_or_sw["ext2"] = "hw"; + map_hw_or_sw["ext3"] = "hw"; + map_hw_or_sw["nfs"] = "sw"; + map_hw_or_sw["NFS"] = "sw"; +} +} \ No newline at end of file diff --git a/source/ubconfig_quotas.h b/source/ubconfig_quotas.h new file mode 100644 index 0000000..b108ff1 --- /dev/null +++ b/source/ubconfig_quotas.h @@ -0,0 +1,25 @@ +#ifndef UBCONFIG_QUOTAS +#define UBCONFIG_QUOTAS + +#include "project_lib.h" +#include "my_type.h" +#include "my_process.h" +#include "util.h" + +namespace Quotas_ubconfig { + + +class Quotas_ubconfig{ + public: + map_str_str map_hw_or_sw; + + map_str_str* map_gui_cfg; + 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(); + Quotas_ubconfig(); + void off_quota_ubconfig(string partition, string quota_type); + void format_cmd_quotas_ubconfig(struct struct_quotas& _struct_quota); + void set_map_gui(map_str_str &map_gui); +}; +} +#endif diff --git a/source/ubl-settings-diskquota.cc b/source/ubl-settings-diskquota.cc index 2dcdcaa..a65586b 100755 --- a/source/ubl-settings-diskquota.cc +++ b/source/ubl-settings-diskquota.cc @@ -55,11 +55,11 @@ void MainWindow::settings() { ,quotegroupFilesHardLimitSpin ,quotegroupFilesHarLimitLabel); obj_quotas_sys.set_map_gui(map_gui_cfg); + obj_quotas_ubconfig.set_map_gui(map_gui_cfg); if (geteuid() == 0) { this->load_system_cfg(); this->load_global_cfg(); this->event(); - obj_quotas_sys.pars_data("repquota -pu /mnt/ext4"); } else { boxFuncs->set_sensitive(false); @@ -480,8 +480,8 @@ void MainWindow::get_builder() { void MainWindow::event() { quotegroupSaveButton->signal_clicked().connect([&]() {}); - btnDeleteGroupQuota->signal_clicked().connect([&]() {obj_quotas_sys.off_quota_ubconfig(groupsDeviceCombo->get_active_text(), "grpquota");}); - btnDeleteUserQuota->signal_clicked().connect([&]() {obj_quotas_sys.off_quota_ubconfig(usersDeviceCombo->get_active_text(), "usrquota");}); + btnDeleteGroupQuota->signal_clicked().connect([&]() {obj_quotas_ubconfig.off_quota_ubconfig(groupsDeviceCombo->get_active_text(), "grpquota");}); + btnDeleteUserQuota->signal_clicked().connect([&]() {obj_quotas_ubconfig.off_quota_ubconfig(usersDeviceCombo->get_active_text(), "usrquota");}); btnLoadGlob->signal_activate().connect([&]() {this->load_global_cfg();}); btnLoadLocal->signal_activate().connect([&]() {this->load_system_cfg();}); btnSynopsis->signal_activate().connect([&]() {this->synopsis_show();}); @@ -532,7 +532,7 @@ void MainWindow::wrapper_settings_quotas_temp(string save_user_or_group) { _struct_quota.cmd = cmd; _struct_quota.type_quotas = type_quotas; _struct_quota.name = user; - obj_quotas_sys.format_cmd_quotas_ubconfig(_struct_quota); + obj_quotas_ubconfig.format_cmd_quotas_ubconfig(_struct_quota); } diff --git a/source/ubl-settings-diskquota.h b/source/ubl-settings-diskquota.h index 9a2307d..24dea4a 100644 --- a/source/ubl-settings-diskquota.h +++ b/source/ubl-settings-diskquota.h @@ -7,7 +7,9 @@ #include "my_process.h" #include "my_type.h" #include "my_device.h" -#include "controler.h" +#include "system_quotas.h" +#include "ubconfig_quotas.h" + using namespace std; @@ -204,6 +206,7 @@ class MainWindow : public Gtk::ApplicationWindow { 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;