|
|
|
@ -169,7 +169,7 @@ void MainWindow::get_download_mode(string cmd, std::map <string, string> &map_te
|
|
|
|
int start_error = index_error;
|
|
|
|
int start_error = index_error;
|
|
|
|
struct Result<string> res_response = this->wrapper_call(cmd);
|
|
|
|
struct Result<string> res_response = this->wrapper_call(cmd);
|
|
|
|
if (res_response.error == 0) {
|
|
|
|
if (res_response.error == 0) {
|
|
|
|
str_replace_all(res_response.response, "\"","");
|
|
|
|
Utils::str_replace_all(res_response.response, "\"","");
|
|
|
|
if (res_response.response == "splash") {
|
|
|
|
if (res_response.response == "splash") {
|
|
|
|
cmbDownloadMode->set_active(0);
|
|
|
|
cmbDownloadMode->set_active(0);
|
|
|
|
map_temp["GRUB_BOOT_SILENT"] = "splash";
|
|
|
|
map_temp["GRUB_BOOT_SILENT"] = "splash";
|
|
|
|
@ -274,8 +274,8 @@ void MainWindow::get_security_login(string cmd, std::map <string, string> &map_t
|
|
|
|
// Убрать в будущем
|
|
|
|
// Убрать в будущем
|
|
|
|
string default_login = "superadmin";
|
|
|
|
string default_login = "superadmin";
|
|
|
|
if (res_response.error == 0) {
|
|
|
|
if (res_response.error == 0) {
|
|
|
|
str_replace_all(res_response.response, " ","");
|
|
|
|
Utils::str_replace_all(res_response.response, " ","");
|
|
|
|
str_replace_all(res_response.response, "\"","");
|
|
|
|
Utils::str_replace_all(res_response.response, "\"","");
|
|
|
|
if (res_response.response.length() > 0) {
|
|
|
|
if (res_response.response.length() > 0) {
|
|
|
|
chbSecurityLogin->set_active(1);
|
|
|
|
chbSecurityLogin->set_active(1);
|
|
|
|
map_temp["GRUB_USER"] = res_response.response;
|
|
|
|
map_temp["GRUB_USER"] = res_response.response;
|
|
|
|
@ -343,7 +343,7 @@ void MainWindow::get_password_protec(string cmd, std::map <string, string> &map_
|
|
|
|
int start_error = index_error;
|
|
|
|
int start_error = index_error;
|
|
|
|
struct Result<string> res_response = this->wrapper_call(cmd);
|
|
|
|
struct Result<string> res_response = this->wrapper_call(cmd);
|
|
|
|
if (res_response.error == 0) {
|
|
|
|
if (res_response.error == 0) {
|
|
|
|
str_replace_all(res_response.response, "\"","");
|
|
|
|
Utils::str_replace_all(res_response.response, "\"","");
|
|
|
|
if (res_response.response.length() != 0) {
|
|
|
|
if (res_response.response.length() != 0) {
|
|
|
|
chbPasswordProtecc->set_active(1);
|
|
|
|
chbPasswordProtecc->set_active(1);
|
|
|
|
map_temp["GRUB_PASSWORD"] = res_response.response;
|
|
|
|
map_temp["GRUB_PASSWORD"] = res_response.response;
|
|
|
|
@ -402,7 +402,7 @@ string MainWindow::dynamic_update_entry(std::map<string, string> &map_view, vect
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vector<string> MainWindow::read_file_and_view(string file_name ,Gtk::TreeModel::Row &row, Glib::RefPtr<Gtk::ListStore> list_store_m) {
|
|
|
|
vector<string> MainWindow::read_file_and_view(string file_name ,Gtk::TreeModel::Row &row, Glib::RefPtr<Gtk::ListStore> list_store_m) {
|
|
|
|
std::array<std::vector<std::string>, 5> arr_view = read_csv(path_resources + "/" + file_name);
|
|
|
|
std::array<std::vector<std::string>, 5> arr_view = Utils::read_csv(path_resources + "/" + file_name);
|
|
|
|
std::vector<std::string> vec_Option = arr_view[0];
|
|
|
|
std::vector<std::string> vec_Option = arr_view[0];
|
|
|
|
for (size_t index = 0; index < vec_Option.size(); index++) {
|
|
|
|
for (size_t index = 0; index < vec_Option.size(); index++) {
|
|
|
|
|
|
|
|
|
|
|
|
@ -540,15 +540,15 @@ vector<string> MainWindow::get_setting_entry_all(string key, string cmd, Gtk::En
|
|
|
|
vector<string> vec_params;
|
|
|
|
vector<string> vec_params;
|
|
|
|
struct Result<string> res_response = this->wrapper_call(cmd);
|
|
|
|
struct Result<string> res_response = this->wrapper_call(cmd);
|
|
|
|
if (res_response.error == 0) {
|
|
|
|
if (res_response.error == 0) {
|
|
|
|
str_replace_all(res_response.response, "\"", "");
|
|
|
|
Utils::str_replace_all(res_response.response, "\"", "");
|
|
|
|
vec_params = split(res_response.response, ' ');
|
|
|
|
vec_params = Utils::split(res_response.response, ' ');
|
|
|
|
str_replace_all(res_response.response, " ", ", ");
|
|
|
|
Utils::str_replace_all(res_response.response, " ", ", ");
|
|
|
|
entry_text.set_text(res_response.response);
|
|
|
|
entry_text.set_text(res_response.response);
|
|
|
|
for (auto ¶m: vec_params) {
|
|
|
|
for (auto ¶m: vec_params) {
|
|
|
|
map_cmd_selection[param] = "1";
|
|
|
|
map_cmd_selection[param] = "1";
|
|
|
|
map_temp[param] = "1";
|
|
|
|
map_temp[param] = "1";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
str_remove(res_response.response, ",");
|
|
|
|
Utils::str_remove(res_response.response, ",");
|
|
|
|
map_temp[key] = res_response.response;
|
|
|
|
map_temp[key] = res_response.response;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (res_response.error == 3) {
|
|
|
|
else if (res_response.error == 3) {
|
|
|
|
@ -609,8 +609,8 @@ void MainWindow::set_entry_to_tree_view(Glib::RefPtr<Gtk::ListStore> &list_store
|
|
|
|
flag_blocked_tree_view = true;
|
|
|
|
flag_blocked_tree_view = true;
|
|
|
|
vector<string> vec_params;
|
|
|
|
vector<string> vec_params;
|
|
|
|
std::string text = entry.get_text();
|
|
|
|
std::string text = entry.get_text();
|
|
|
|
str_replace_all(text, " ", "");
|
|
|
|
Utils::str_replace_all(text, " ", "");
|
|
|
|
vec_params = split(text, ',');
|
|
|
|
vec_params = Utils::split(text, ',');
|
|
|
|
for (auto &name: vec_Option) {
|
|
|
|
for (auto &name: vec_Option) {
|
|
|
|
this->set_row(list_store, size, name, false);
|
|
|
|
this->set_row(list_store, size, name, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -680,10 +680,10 @@ void MainWindow::set_menu_boot(string cmd = "", string cmd_remove = "") {
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::cmd_entry_all(Gtk::Entry &entry, string cmd_settings, string cmd_remove) {
|
|
|
|
void MainWindow::cmd_entry_all(Gtk::Entry &entry, string cmd_settings, string cmd_remove) {
|
|
|
|
string cmds = entry.get_text();
|
|
|
|
string cmds = entry.get_text();
|
|
|
|
str_remove(cmds, ",");
|
|
|
|
Utils::str_remove(cmds, ",");
|
|
|
|
if (cmds.length() != 0) {
|
|
|
|
if (cmds.length() != 0) {
|
|
|
|
cmd_settings += "\"" + cmds + "\"";
|
|
|
|
cmd_settings += "\"" + cmds + "\"";
|
|
|
|
str_replace_all(cmd_settings, " \"", "\"");
|
|
|
|
Utils::str_replace_all(cmd_settings, " \"", "\"");
|
|
|
|
this->wrapper_system(cmd_settings, "");
|
|
|
|
this->wrapper_system(cmd_settings, "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
@ -709,6 +709,7 @@ void MainWindow::event(){
|
|
|
|
chbSecurityLogin->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::change_security_login));
|
|
|
|
chbSecurityLogin->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::change_security_login));
|
|
|
|
cmbDownloadMode->signal_changed().connect([&]() {set_download_mode();});
|
|
|
|
cmbDownloadMode->signal_changed().connect([&]() {set_download_mode();});
|
|
|
|
chbSecurityLogin->signal_changed().connect([&]() {set_security_login();});
|
|
|
|
chbSecurityLogin->signal_changed().connect([&]() {set_security_login();});
|
|
|
|
|
|
|
|
cmbDefaultDonw->signal_changed().connect([&]() {set_default_load("","");});
|
|
|
|
spbSecond->signal_changed().connect([&]() {set_menu_boot();});
|
|
|
|
spbSecond->signal_changed().connect([&]() {set_menu_boot();});
|
|
|
|
if (this->check_root() == 0) {
|
|
|
|
if (this->check_root() == 0) {
|
|
|
|
Glib::RefPtr<Gtk::TreeModel> treeViewKernelModel = treeViewKernel->get_model();
|
|
|
|
Glib::RefPtr<Gtk::TreeModel> treeViewKernelModel = treeViewKernel->get_model();
|
|
|
|
@ -742,6 +743,55 @@ void MainWindow::change_security_login() {
|
|
|
|
boxSave->set_sensitive(true);
|
|
|
|
boxSave->set_sensitive(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::set_default_load(string cmd = "", string cmd_remove = "") {
|
|
|
|
|
|
|
|
int index = cmbDefaultDonw->get_active_row_number();
|
|
|
|
|
|
|
|
if (index == 0) {
|
|
|
|
|
|
|
|
if (cmd.length() != 0) {
|
|
|
|
|
|
|
|
wrapper_system(cmd, "");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
flag_save_local = true;
|
|
|
|
|
|
|
|
flag_save_global = true;
|
|
|
|
|
|
|
|
flag_save_all = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (index > 0) {
|
|
|
|
|
|
|
|
if (cmd_remove.length() != 0) {
|
|
|
|
|
|
|
|
wrapper_system(cmd_remove, "");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
flag_save_local = true;
|
|
|
|
|
|
|
|
flag_save_global = true;
|
|
|
|
|
|
|
|
flag_save_all = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index != 0 && index != -1) {
|
|
|
|
|
|
|
|
map_cmd_selection["GRUB_DEFAULT"] = cmbDefaultDonw->get_active_text();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
map_cmd_selection["GRUB_DEFAULT"] = "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::get_default_load(string cmd, std::map <string, string> &map_temp) {
|
|
|
|
|
|
|
|
int start_error = index_error;
|
|
|
|
|
|
|
|
struct Result<string> res_response = this->wrapper_call(cmd);
|
|
|
|
|
|
|
|
if (res_response.error == 0) {
|
|
|
|
|
|
|
|
map_temp["GRUB_DEFAULT"] = res_response.response;
|
|
|
|
|
|
|
|
cmbDefaultDonw->set_active_text(res_response.response);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (res_response.error == 3) {
|
|
|
|
|
|
|
|
if (start_error != index_error) {
|
|
|
|
|
|
|
|
index_error = start_error;
|
|
|
|
|
|
|
|
cmbDefaultDonw->set_active(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
map_temp["GRUB_DEFAULT"] = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
map_temp["GRUB_DEFAULT"] = "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::change_password_protecc() {
|
|
|
|
void MainWindow::change_password_protecc() {
|
|
|
|
int index = chbPasswordProtecc->get_active_row_number();
|
|
|
|
int index = chbPasswordProtecc->get_active_row_number();
|
|
|
|
@ -835,6 +885,12 @@ bool MainWindow::save_global_cfg() {
|
|
|
|
this->set_password_protec(cmd_password, cmd_password_remove);
|
|
|
|
this->set_password_protec(cmd_password, cmd_password_remove);
|
|
|
|
flag_no_save = false;
|
|
|
|
flag_no_save = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this->check_save(flag_save, "GRUB_DEFAULT")) {
|
|
|
|
|
|
|
|
string cmd_load = "ubconfig --target global set boot GRUB_DEFAULT=";
|
|
|
|
|
|
|
|
string cmd_load_remove = "ubconfig --target global remove boot GRUB_DEFAULT";
|
|
|
|
|
|
|
|
this->set_default_load(cmd_load, cmd_load_remove);
|
|
|
|
|
|
|
|
flag_no_save = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
map_global_cmd_selection = map_cmd_selection;
|
|
|
|
map_global_cmd_selection = map_cmd_selection;
|
|
|
|
@ -897,6 +953,13 @@ bool MainWindow::save_local_cfg() {
|
|
|
|
this->set_password_protec(cmd_password, cmd_password_remove);
|
|
|
|
this->set_password_protec(cmd_password, cmd_password_remove);
|
|
|
|
flag_no_save = false;
|
|
|
|
flag_no_save = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this->check_save(flag_save, "GRUB_DEFAULT")) {
|
|
|
|
|
|
|
|
string cmd_load = "ubconfig --target system set boot GRUB_DEFAULT=";
|
|
|
|
|
|
|
|
string cmd_load_remove = "ubconfig --target system remove boot GRUB_DEFAULT";
|
|
|
|
|
|
|
|
this->set_default_load(cmd_load, cmd_load_remove);
|
|
|
|
|
|
|
|
flag_no_save = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
map_local_cmd_selection = map_cmd_selection;
|
|
|
|
map_local_cmd_selection = map_cmd_selection;
|
|
|
|
@ -905,16 +968,16 @@ bool MainWindow::save_local_cfg() {
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::set_data_cfg() {
|
|
|
|
void MainWindow::set_data_cfg() {
|
|
|
|
string str_flags = entryKernel->get_text();
|
|
|
|
string str_flags = entryKernel->get_text();
|
|
|
|
str_remove(str_flags, ",");
|
|
|
|
Utils::str_remove(str_flags, ",");
|
|
|
|
str_replace_all(str_flags, " \"", "\"");
|
|
|
|
Utils::str_replace_all(str_flags, " \"", "\"");
|
|
|
|
map_cmd_selection["GRUB_CMDLINE_LINUX"] = str_flags;
|
|
|
|
map_cmd_selection["GRUB_CMDLINE_LINUX"] = str_flags;
|
|
|
|
str_flags = entryIPT->get_text();
|
|
|
|
str_flags = entryIPT->get_text();
|
|
|
|
str_remove(str_flags, ",");
|
|
|
|
Utils::str_remove(str_flags, ",");
|
|
|
|
str_replace_all(str_flags, " \"", "\"");
|
|
|
|
Utils::str_replace_all(str_flags, " \"", "\"");
|
|
|
|
map_cmd_selection["GRUB_TERMINAL_INPUT"] = str_flags;
|
|
|
|
map_cmd_selection["GRUB_TERMINAL_INPUT"] = str_flags;
|
|
|
|
str_flags = entryOTT->get_text();
|
|
|
|
str_flags = entryOTT->get_text();
|
|
|
|
str_remove(str_flags, ",");
|
|
|
|
Utils::str_remove(str_flags, ",");
|
|
|
|
str_replace_all(str_flags, " \"", "\"");
|
|
|
|
Utils::str_replace_all(str_flags, " \"", "\"");
|
|
|
|
map_cmd_selection["GRUB_TERMINAL_OUTPUT"] = str_flags;
|
|
|
|
map_cmd_selection["GRUB_TERMINAL_OUTPUT"] = str_flags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -940,6 +1003,7 @@ void MainWindow::download_globl_cfg() {
|
|
|
|
this->get_download_mode("ubconfig --default --source global get boot GRUB_BOOT_SILENT", map_global_cmd_selection);
|
|
|
|
this->get_download_mode("ubconfig --default --source global get boot GRUB_BOOT_SILENT", map_global_cmd_selection);
|
|
|
|
this->get_security_login("ubconfig --default --source global get boot GRUB_USER", map_global_cmd_selection);
|
|
|
|
this->get_security_login("ubconfig --default --source global get boot GRUB_USER", map_global_cmd_selection);
|
|
|
|
this->get_password_protec("ubconfig --default --source global get boot GRUB_PASSWORD", map_global_cmd_selection);
|
|
|
|
this->get_password_protec("ubconfig --default --source global get boot GRUB_PASSWORD", map_global_cmd_selection);
|
|
|
|
|
|
|
|
this->get_default_load("ubconfig --default --source global get boot GRUB_DEFAULT", map_global_cmd_selection);
|
|
|
|
info_warning_error(1);
|
|
|
|
info_warning_error(1);
|
|
|
|
map_cmd_selection = map_global_cmd_selection;
|
|
|
|
map_cmd_selection = map_global_cmd_selection;
|
|
|
|
|
|
|
|
|
|
|
|
@ -967,6 +1031,7 @@ void MainWindow::download_local_cfg() {
|
|
|
|
this->get_download_mode("ubconfig --default --source system get boot GRUB_BOOT_SILENT", map_local_cmd_selection);
|
|
|
|
this->get_download_mode("ubconfig --default --source system get boot GRUB_BOOT_SILENT", map_local_cmd_selection);
|
|
|
|
this->get_security_login("ubconfig --default --source system get boot GRUB_USER", map_local_cmd_selection);
|
|
|
|
this->get_security_login("ubconfig --default --source system get boot GRUB_USER", map_local_cmd_selection);
|
|
|
|
this->get_password_protec("ubconfig --default --source system get boot GRUB_PASSWORD", map_local_cmd_selection);
|
|
|
|
this->get_password_protec("ubconfig --default --source system get boot GRUB_PASSWORD", map_local_cmd_selection);
|
|
|
|
|
|
|
|
this->get_default_load("ubconfig --default --source system get boot GRUB_DEFAULT", map_local_cmd_selection);
|
|
|
|
info_warning_error(0);
|
|
|
|
info_warning_error(0);
|
|
|
|
map_cmd_selection = map_local_cmd_selection;
|
|
|
|
map_cmd_selection = map_local_cmd_selection;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1051,7 +1116,6 @@ void MainWindow::wrapper_system(string cmd, string thread_str = "") {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::info_status_app(string stule) {
|
|
|
|
void MainWindow::info_status_app(string stule) {
|
|
|
|
|
|
|
|
|
|
|
|
boxInfo->remove_class("boxInfoMessOK");
|
|
|
|
boxInfo->remove_class("boxInfoMessOK");
|
|
|
|
boxInfo->remove_class("boxInfoMessError");
|
|
|
|
boxInfo->remove_class("boxInfoMessError");
|
|
|
|
boxInfo->add_class(stule);
|
|
|
|
boxInfo->add_class(stule);
|
|
|
|
@ -1111,7 +1175,7 @@ void MainWindow::info_warning_error(int mess) {
|
|
|
|
|
|
|
|
|
|
|
|
struct MainWindow::Result<string> MainWindow::wrapper_call(string cmd) {
|
|
|
|
struct MainWindow::Result<string> MainWindow::wrapper_call(string cmd) {
|
|
|
|
struct Result<string> obj_result;
|
|
|
|
struct Result<string> obj_result;
|
|
|
|
string response = call(cmd);
|
|
|
|
string response = Utils::call(cmd);
|
|
|
|
if ((response.find("(null)") == std::string::npos) && (response.length() != 0 )) {
|
|
|
|
if ((response.find("(null)") == std::string::npos) && (response.length() != 0 )) {
|
|
|
|
if (response.find("=") != std::string::npos) {
|
|
|
|
if (response.find("=") != std::string::npos) {
|
|
|
|
if (response.find("\n") != std::string::npos) {
|
|
|
|
if (response.find("\n") != std::string::npos) {
|
|
|
|
@ -1152,7 +1216,7 @@ void MainWindow::log_mess_error(string &cmd) {
|
|
|
|
str_cmd_error = map_cmd_error[cmd];
|
|
|
|
str_cmd_error = map_cmd_error[cmd];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
for ( const auto &map_iter: map_cmd_error ) {
|
|
|
|
for (const auto &map_iter: map_cmd_error) {
|
|
|
|
key = map_iter.first;
|
|
|
|
key = map_iter.first;
|
|
|
|
if (cmd.find(key) != std::string::npos){
|
|
|
|
if (cmd.find(key) != std::string::npos){
|
|
|
|
str_cmd_error = map_iter.second;
|
|
|
|
str_cmd_error = map_iter.second;
|
|
|
|
|