Функционал для работы с квотами вынесен отдельный файл

pull/3/head
Igor Belitskiy 2 years ago
parent 68426f9c7e
commit fd1001e359

@ -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

@ -1,4 +1,5 @@
#include "system_cmd_quotas.h"
#include "system_quotas.h"
#include "ubconfig_quotas.h"
class Back_Back{
public:

@ -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<data_all_quotas> 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) {

@ -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);

@ -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";
}
}

@ -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

@ -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);
}

@ -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;

Loading…
Cancel
Save