Начал писать обвертку для бэка

pull/3/head
Igor Belitskiy 2 years ago
parent 79f8a683f2
commit 8c4d8bbf7b

@ -20,6 +20,9 @@ set(SOURCE_FILES
ubl-settings-diskquota.cc ubl-settings-diskquota.cc
system_cmd_quotas.cc system_cmd_quotas.cc
system_cmd_quotas.h system_cmd_quotas.h
controler.h
global_var.h
controler.cc
my_device.h my_device.h
my_device.cc my_device.cc
project_lib.h project_lib.h

@ -0,0 +1,2 @@
#include "controler.h"
Back_Back::Back_Back() {}

@ -0,0 +1,6 @@
#include "system_cmd_quotas.h"
class Back_Back{
public:
Back_Back();
};

@ -1,3 +1,3 @@
#include "project_lib.h" #include "project_lib.h"
#include "my_tupe.h" #include "my_type.h"

@ -1,4 +1,3 @@
#include "ubl-settings-diskquota.h"
#include "my_plug.h" #include "my_plug.h"
void pars_flag(int index_start, int argc, char* argv[]); void pars_flag(int index_start, int argc, char* argv[]);

@ -2,7 +2,7 @@
#define MY_PLUG_H #define MY_PLUG_H
#include "my_plug.h" #include "my_plug.h"
#include "ubl-settings-diskquota.h"
CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help) CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help)
: Glib::OptionGroup{p_name, p_description, p_help} { : Glib::OptionGroup{p_name, p_description, p_help} {

@ -1,5 +1,6 @@
#include "project_lib.h" #include "project_lib.h"
#include "ubl-settings-diskquota.h"
#include "global_var.h"
class CmdArgParser : public Glib::OptionGroup { class CmdArgParser : public Glib::OptionGroup {
public: public:

@ -21,8 +21,7 @@ void Quotas_sys::format_cmd_quotas_system(struct struct_quotas& _struct_quota) {
(*map_gui_cfg)[key] = value; (*map_gui_cfg)[key] = value;
} }
void Quotas_sys::off_quota_ubconfig(Gtk::ComboBoxText* combo_box, string quota_type) { void Quotas_sys::off_quota_ubconfig(string partition, string quota_type) {
string partition = combo_box->get_active_text();
string key = "DISK_QUOTA[" + quota_type + ":" + partition + "]"; string key = "DISK_QUOTA[" + quota_type + ":" + partition + "]";
string value = "disable"; string value = "disable";
(*map_gui_cfg)[key] = value; (*map_gui_cfg)[key] = value;
@ -87,6 +86,7 @@ struct status_quotas Quotas_sys::check_on_quotas_system_2_hw(string params) {
return status; return status;
} }
bool Quotas_sys::on_quota_hw(string partition, string cmd_hw, string cmd_sw) { bool Quotas_sys::on_quota_hw(string partition, string cmd_hw, string cmd_sw) {
if (map_hw_or_sw.find(partition) != map_hw_or_sw.end()) { if (map_hw_or_sw.find(partition) != map_hw_or_sw.end()) {
if (map_hw_or_sw[partition] == "hw") { if (map_hw_or_sw[partition] == "hw") {
@ -103,57 +103,59 @@ bool Quotas_sys::on_quota_hw(string partition, string cmd_hw, string cmd_sw) {
return false; return false;
} }
} }
return false; return false;
} }
bool Quotas_sys::on_quota_sw(string partition, int mode) { bool Quotas_sys::on_quota_sw(string partition, int mode) {
if (map_hw_or_sw.find(partition) != map_hw_or_sw.end()) { if (map_hw_or_sw.find(partition) != map_hw_or_sw.end()) {
string cmd = ""; string cmd = "";
if (mode == 0) { if (mode == 0) {
cmd += "mount -vo remount,usrquota " + partition; cmd += "mount -vo remount,usrquota " + partition;
cmd += "quotacheck -ucm " + partition; cmd += "; quotacheck -ucm " + partition;
cmd += "quotaon -uv " + partition; cmd += "; quotaon -uv " + partition;
} }
else if (mode == 1) { else if (mode == 1) {
cmd += "mount -vo remount,grpquota " + partition; cmd += "; mount -vo remount,grpquota " + partition;
cmd += "quotacheck -gcm " + partition; cmd += "; quotacheck -gcm " + partition;
cmd += "quotaon -gv " + partition; cmd += "; quotaon -gv " + partition;
} }
else if (mode == 2) { else if (mode == 2) {
cmd += "quotaon -ugPv " + partition; cmd += "; quotaon -ugPv " + partition;
} }
else if (mode == 3) { else if (mode == 3) {
cmd += "quotaon -augPv"; cmd += "; quotaon -augPv";
} }
else { else {
return false; return false;
} }
cmd += "ubconfig set config SERVICESSTART+=,quotaon.service"; cmd += "; ubconfig set config SERVICESSTART+=,quotaon.service";
obj_process_system.call(cmd, ""); obj_process_system.call(cmd, "");
return true; return true;
} }
return false; return false;
} }
void Quotas_sys::off_quota_system(Gtk::ComboBoxText* combo_box, string quota_type) { bool Quotas_sys::off_quota_system(string partition, string quota_hw, string quota_sw) {
string partition = combo_box->get_active_text();
string cmd = ""; string cmd = "";
if (map_hw_or_sw.find(partition) != map_hw_or_sw.end()) { if (map_hw_or_sw.find(partition) != map_hw_or_sw.end()) {
if (map_hw_or_sw[partition] == "hw") { if (map_hw_or_sw[partition] == "hw") {
cmd = "tune2fs -Q ^" + quota_type + " " + partition; cmd = quota_hw + " " + partition;
return true;
} }
else if (map_hw_or_sw[partition] == "sw") { else if (map_hw_or_sw[partition] == "sw") {
cmd = "quotaoff -u " + quota_type.substr(0,1) + " " + partition; cmd = quota_sw + " " + partition;
return true;
} }
else { else {
// TODO: // TODO:
// Убрать после тестирования // Убрать после тестирования
throw "Опа цэ!"; throw "Опа цэ!";
return false;
} }
obj_process_system.call(cmd, ""); obj_process_system.call(cmd, "");
} }
return false;
} }
} }

@ -18,8 +18,8 @@ class Quotas_sys {
void set_map_gui(map_str_str &map_gui); void set_map_gui(map_str_str &map_gui);
void format_cmd_quotas_ubconfig(struct struct_quotas& _struct_quota); void format_cmd_quotas_ubconfig(struct struct_quotas& _struct_quota);
void format_cmd_quotas_system(struct struct_quotas& _struct_quota); void format_cmd_quotas_system(struct struct_quotas& _struct_quota);
void off_quota_ubconfig(Gtk::ComboBoxText* combo_box, string quota_type); void off_quota_ubconfig(string partition, string quota_type);
void off_quota_system(Gtk::ComboBoxText* combo_box, string quota_type); bool off_quota_system(string partition, string quota_hw, string quota_sw);
bool check_on_quotas_system(string cmd); bool check_on_quotas_system(string cmd);
struct status_quotas check_on_quotas_system_2_hw(string params); struct status_quotas check_on_quotas_system_2_hw(string params);
bool on_quota_hw(string partition, string cmd_hw, string cmd_sw); bool on_quota_hw(string partition, string cmd_hw, string cmd_sw);

@ -301,6 +301,7 @@ void MainWindow::add_CSS() {
} }
headLabel_css->add_class("textHead"); headLabel_css->add_class("textHead");
} }
/* /*
void init_treeview_user() { void init_treeview_user() {
@ -478,8 +479,8 @@ void MainWindow::get_builder() {
void MainWindow::event() { void MainWindow::event() {
quotegroupSaveButton->signal_clicked().connect([&]() {}); quotegroupSaveButton->signal_clicked().connect([&]() {});
btnDeleteGroupQuota->signal_clicked().connect([&]() {obj_quotas_sys.off_quota_ubconfig(groupsDeviceCombo, "grpquota");}); 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, "usrquota");}); btnDeleteUserQuota->signal_clicked().connect([&]() {obj_quotas_sys.off_quota_ubconfig(usersDeviceCombo->get_active_text(), "usrquota");});
btnLoadGlob->signal_activate().connect([&]() {this->load_global_cfg();}); btnLoadGlob->signal_activate().connect([&]() {this->load_global_cfg();});
btnLoadLocal->signal_activate().connect([&]() {this->load_system_cfg();}); btnLoadLocal->signal_activate().connect([&]() {this->load_system_cfg();});
btnSynopsis->signal_activate().connect([&]() {this->synopsis_show();}); btnSynopsis->signal_activate().connect([&]() {this->synopsis_show();});
@ -516,7 +517,7 @@ void MainWindow::event() {
,quotegroupFilesHarLimitLabel); ,quotegroupFilesHarLimitLabel);
}); });
quotegroupCancelButton->signal_clicked().connect([&]() {QuotasEditWindow->hide();}); quotegroupCancelButton->signal_clicked().connect([&]() {QuotasEditWindow->hide();});
QuotasEditWindow->show(); // QuotasEditWindow->show();
} }
void MainWindow::wrapper_settings_quotas_temp(string save_user_or_group) { void MainWindow::wrapper_settings_quotas_temp(string save_user_or_group) {

@ -7,11 +7,8 @@
#include "my_process.h" #include "my_process.h"
#include "my_type.h" #include "my_type.h"
#include "my_device.h" #include "my_device.h"
#include "system_cmd_quotas.h" #include "controler.h"
#include "global_var.h"
extern int socket_ext_id_I;
extern int socket_trd_id_I;
using namespace std; using namespace std;
@ -23,6 +20,8 @@ extern const string path_css;
extern const string path_img_head_background; extern const string path_img_head_background;
extern string version_application; extern string version_application;
extern int socket_ext_id_I;
extern int socket_trd_id_I;
class MainWindow : public Gtk::ApplicationWindow { class MainWindow : public Gtk::ApplicationWindow {
public: public:
class ModelColumns : public Gtk::TreeModel::ColumnRecord { class ModelColumns : public Gtk::TreeModel::ColumnRecord {

@ -615,7 +615,9 @@
</object> </object>
<object class="GtkWindow" id="MainWindow"> <object class="GtkWindow" id="MainWindow">
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="window-position">center</property>
<property name="icon-name">com.ublinux.ubl-settings-diskquota</property> <property name="icon-name">com.ublinux.ubl-settings-diskquota</property>
<property name="gravity">center</property>
<child> <child>
<object class="GtkBox" id="plugBox"> <object class="GtkBox" id="plugBox">
<property name="visible">True</property> <property name="visible">True</property>

Loading…
Cancel
Save