diff --git a/boot-options.csv b/boot-options.csv index d755699..1aba2df 100644 --- a/boot-options.csv +++ b/boot-options.csv @@ -1,4 +1,4 @@ -Get,Set=1,Set=0,Option,Description +Option,Description quiet,Downloading without text messages splash,Show welcome window noplymouth,Disable Plymouth diff --git a/input-options.csv b/input-options.csv index f90c724..4bd7f47 100644 --- a/input-options.csv +++ b/input-options.csv @@ -1,4 +1,4 @@ -Get,Set=1,Set=0,Option,Description +Option,Description console,PC BIOS & EFI console serial,Serial terminal ofconsole,Open Firmware Console diff --git a/output-options.csv b/output-options.csv index 3af14be..30453d6 100644 --- a/output-options.csv +++ b/output-options.csv @@ -1,4 +1,4 @@ -Get,Set=1,Set=0,Option,Description +Option,Description console,PC BIOS & EFI console serial,Serial terminal ofconsole,Open Firmware Console diff --git a/source/ubl-settings-bootloader.cc b/source/ubl-settings-bootloader.cc index 543d475..ddd4367 100755 --- a/source/ubl-settings-bootloader.cc +++ b/source/ubl-settings-bootloader.cc @@ -81,12 +81,11 @@ void MainWindow::settings(){ spbSecond->set_range(1, 60); spbSecond->set_increments(1.0, 1.0); this->fill_in_view(); - this->download_local_cfg(); - this->download_globl_cfg(); - entrySecurityLogin->set_sensitive(false); - this->set_active_boot_second(); this->change_password_protecc(); this->change_security_login(); + this->set_active_boot_second(); + this->download_local_cfg(); + this->download_globl_cfg(); this->event(); } @@ -237,14 +236,14 @@ void MainWindow::set_security_login(string cmd="") { } else if (index == 1) { - key = string(getlogin()); + key = entrySecurityLogin->get_text(); } - else { + else if (index == -1) { return; } if (cmd.length() != 0) { entrySecurityLogin->set_text(key); - cmd = cmd + key; + cmd = cmd + "\"" + key + "\""; wrapper_system(cmd, ""); } map_cmd_selection["GRUB_USER"] = key; @@ -252,20 +251,27 @@ void MainWindow::set_security_login(string cmd="") { void MainWindow::get_security_login(string cmd, std::map &map_temp) { struct Result res_response = this->wrapper_call(cmd); + // TODO: + // Убрать в будущем + string default_login = "superadmin"; if (res_response.error == 0) { + str_replace_all(res_response.response, " ",""); str_replace_all(res_response.response, "\"",""); entrySecurityLogin->set_text(res_response.response); - if (res_response.response == getlogin()) { + if (res_response.response != default_login) { chbSecurityLogin->set_active(1); - map_temp["GRUB_USER"] = getlogin(); + entrySecurityLogin->set_sensitive(true); + + map_temp["GRUB_USER"] = res_response.response; } - else if (res_response.response.length() != 0) { + else if (res_response.response == default_login) { chbSecurityLogin->set_active(0); - map_temp["GRUB_USER"] = res_response.response; + map_temp["GRUB_USER"] = default_login; } - else{ + else { chbSecurityLogin->set_active(-1); map_temp["GRUB_USER"] = ""; + } } else if (res_response.error == 3) { @@ -278,30 +284,30 @@ void MainWindow::get_security_login(string cmd, std::map &map_t } } -void MainWindow::set_password_protec(string cmd = "", string cmd_remove= "") { +void MainWindow::set_password_protec(string cmd = "", string cmd_remove = "") { // TODO: // Не работает - int index = chbSecurityLogin->get_active_row_number(); + int index = chbPasswordProtecc->get_active_row_number(); string key = ""; if (index == 0){ key = ""; } else if (index == 1) { key = entryPasswordProtecc->get_text(); - } else if (index == 2) { key = "remove"; - if (cmd.length() != 0 && cmd_remove.length() != 0) { + if (cmd_remove.length() != 0) { wrapper_system(cmd_remove, ""); + } cmd = ""; } - else { + else if (index == -1){ return; } if (cmd.length() != 0 && cmd_remove.length() != 0) { - entrySecurityLogin->set_text(key); + entryPasswordProtecc->set_text(key); cmd = cmd + key; wrapper_system(cmd, ""); } @@ -309,36 +315,35 @@ void MainWindow::set_password_protec(string cmd = "", string cmd_remove= "") { } void MainWindow::get_password_protec(string cmd, std::map &map_temp) { - // TODO: - // Не работает struct Result res_response = this->wrapper_call(cmd); + cout << res_response.response << " " << res_response.error << endl; if (res_response.error == 0) { str_replace_all(res_response.response, "\"",""); - entrySecurityLogin->set_text(res_response.response); + entryPasswordProtecc->set_text(res_response.response); + // TODO: + // Не работает if (res_response.response == getlogin()) { - chbSecurityLogin->set_active(0); + chbPasswordProtecc->set_active(0); map_temp["GRUB_PASSWORD"] = ""; } else if (res_response.response.length() != 0) { - chbSecurityLogin->set_active(1); - map_temp["GRUB_PASSWORD"] = ""; - } - else if (res_response.response.length() != 0) { - chbSecurityLogin->set_active(2); + chbPasswordProtecc->set_active(1); map_temp["GRUB_PASSWORD"] = ""; + entryPasswordProtecc->set_sensitive(true); } else{ map_temp["GRUB_PASSWORD"] = ""; - chbSecurityLogin->set_active(-1); + chbPasswordProtecc->set_active(-1); } } - else if (res_response.error == 3) { + else if (res_response.error == 3 && res_response.response.find("null") != string::npos) { + chbPasswordProtecc->set_active(2); map_temp["GRUB_PASSWORD"] = ""; - chbSecurityLogin->set_active(-1); + entryPasswordProtecc->set_text(""); } else { map_temp["GRUB_PASSWORD"] = ""; - chbSecurityLogin->set_active(-1); + chbPasswordProtecc->set_active(-1); } } @@ -530,8 +535,17 @@ vector MainWindow::get_setting_entry_all(string cmd, Gtk::Entry &entry_t } bool MainWindow::focus_out_txt_password(GdkEventFocus*) { - info_status_app("boxInfoMessError"); - lblWarning->set_text(gettext("Enter your password")); + if (entryPasswordProtecc->get_text().length() == 0) { + info_status_app("boxInfoMessError"); + lblWarning->set_text(gettext("Enter your password")); + } + return true; +} +bool MainWindow::focus_out_txt_login(GdkEventFocus*) { + if (entrySecurityLogin->get_text().length() == 0) { + info_status_app("boxInfoMessError"); + lblWarning->set_text(gettext("Enter login")); + } return true; } @@ -580,9 +594,8 @@ void MainWindow::get_menu_boot(string cmd, std::map &map_temp) void MainWindow::set_menu_boot(string cmd="") { int value = spbSecond->get_value(); - std::string seconds = to_string(value); - cmd += seconds; if (cmd.length() != 0) { + cmd += to_string(value); this->wrapper_system(cmd, ""); } map_cmd_selection["GRUB_TIMEOUT"] = to_string(value); @@ -608,6 +621,7 @@ void MainWindow::event(){ entryKernel->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_kernel)); entryIPT->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_IPT)); entryOTT->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_OTT)); + entrySecurityLogin->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_login)); entryPasswordProtecc->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_password)); chbPasswordProtecc->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::change_password_protecc)); chbSecurityLogin->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::change_security_login)); @@ -627,22 +641,28 @@ void MainWindow::event(){ void MainWindow::change_security_login() { int index = chbSecurityLogin->get_active_row_number(); - if (index == 0 || index == -1) { + if (index == 0) { entrySecurityLogin->set_sensitive(false); // TODO: // Добавить заполнение логина по умолчанию - entrySecurityLogin->set_text(""); + string default_login = "superadmin"; + entrySecurityLogin->set_text(default_login); } else if (index == 1) { entrySecurityLogin->set_sensitive(true); entrySecurityLogin->set_text(""); } + else { + entrySecurityLogin->set_sensitive(false); + entrySecurityLogin->set_text(""); + } } void MainWindow::change_password_protecc() { int index = chbPasswordProtecc->get_active_row_number(); if (index == 0 || index == 2 || index == -1) { entryPasswordProtecc->set_sensitive(false); + entryPasswordProtecc->set_text(""); } else if (index == 1) { entryPasswordProtecc->set_sensitive(true); @@ -657,8 +677,7 @@ void MainWindow::set_active_boot_second() { void MainWindow::wrapper_save_all_cfg() { if (this->save_global_cfg() && this->save_local_cfg()) { - info_status_app("boxInfoMessOK"); - lblWarning->set_text(gettext("Nothing to save!")); + this->info_warning_error(5); } else { info_warning_error(4); @@ -668,8 +687,7 @@ void MainWindow::wrapper_save_all_cfg() { void MainWindow::wrapper_save_global_cfg() { if (this->save_global_cfg()) { - info_status_app("boxInfoMessOK"); - lblWarning->set_text(gettext("Nothing to save!")); + this->info_warning_error(5); } else { info_warning_error(3); @@ -714,7 +732,7 @@ bool MainWindow::save_global_cfg() { } if (this->check_save(flag_save, "GRUB_PASSWORD")) { string cmd_password = "ubconfig --target global set boot GRUB_PASSWORD="; - string cmd_password_remove = "ubconfig --target global remove boot GRUB_PASSWORD="; + string cmd_password_remove = "ubconfig --target global remove boot GRUB_PASSWORD"; this->set_password_protec(cmd_password, cmd_password_remove); flag_no_save = false; } @@ -726,8 +744,7 @@ bool MainWindow::save_global_cfg() { void MainWindow::wrapper_save_local_cfg() { if (this->save_local_cfg()){ - info_status_app("boxInfoMessOK"); - lblWarning->set_text(gettext("Nothing to save!")); + this->info_warning_error(5); } else { info_warning_error(2); @@ -772,7 +789,7 @@ bool MainWindow::save_local_cfg() { } if (this->check_save(flag_save, "GRUB_PASSWORD")) { string cmd_password = "ubconfig --target system set boot GRUB_PASSWORD="; - string cmd_password_remove = "ubconfig --target system remove boot GRUB_PASSWORD="; + string cmd_password_remove = "ubconfig --target system remove boot GRUB_PASSWORD"; this->set_password_protec(cmd_password, cmd_password_remove); flag_no_save = false; } @@ -853,6 +870,8 @@ void MainWindow::download_local_cfg() { } bool MainWindow::check_save(string flag_save, string key_name="") { + if (flag_save.empty() && key_name.empty()) {} + /* std::map :: iterator iter_map_data; std::map :: iterator iter_map_data_old; std::map map_config_data_old; @@ -890,6 +909,7 @@ bool MainWindow::check_save(string flag_save, string key_name="") { return true; } cout << 7 << endl; + */ return true; } @@ -935,7 +955,7 @@ void MainWindow::wrapper_system(string cmd, string thread_str = "") { } void MainWindow::info_status_app(string stule) { - Glib::RefPtr boxInfo = boxInfoError->get_style_context(); + boxInfo->remove_class("boxInfoMessOK"); boxInfo->remove_class("boxInfoMessError"); boxInfo->add_class(stule); @@ -987,6 +1007,9 @@ void MainWindow::info_warning_error(int mess) { else if (mess == 4) { lblWarning->set_text(gettext("Successfully saved local and global configuration")); } + else if (mess == 5) { + lblWarning->set_text(gettext("Nothing to save!")); + } } } @@ -1061,6 +1084,7 @@ void MainWindow::add_CSS(){ Glib::RefPtr lblInfoHead_css = lblInfoHead->get_style_context(); Glib::RefPtr boxButton_css = boxButton->get_style_context(); Glib::RefPtr boxSave_css = boxSave->get_style_context(); + boxInfo = boxInfoError->get_style_context(); imgBG->set(path_img_head_background); if (socket_trd_id_I == 0 && socket_ext_id_I == 0){ boxButton_css->add_class("bkim_no_plug"); diff --git a/source/ubl-settings-bootloader.h b/source/ubl-settings-bootloader.h index 44e7fe7..05b4bbd 100644 --- a/source/ubl-settings-bootloader.h +++ b/source/ubl-settings-bootloader.h @@ -125,6 +125,7 @@ class MainWindow : public Gtk::ApplicationWindow { size_t size_IPT = 0; size_t size_OTT = 0; int index_error = 0; + Glib::RefPtr boxInfo; string str_cmd_error = ""; template struct Result{ @@ -176,6 +177,7 @@ class MainWindow : public Gtk::ApplicationWindow { bool check_flag_save(string flag_save); void set_download_mode(string cmd); void change_password_protecc(); + bool focus_out_txt_login(GdkEventFocus*); void change_security_login(); bool focus_out_txt_password(GdkEventFocus*); void get_password_protec(string cmd, std::map &map_temp); diff --git a/ubl-settings-bootloader.glade b/ubl-settings-bootloader.glade index 72ff405..f51a50b 100644 --- a/ubl-settings-bootloader.glade +++ b/ubl-settings-bootloader.glade @@ -385,6 +385,7 @@ specified priority 6 Default download start + 0 False @@ -454,6 +455,7 @@ specified priority 6 Download mode start + 0 False @@ -502,6 +504,7 @@ specified priority 6 Security login: start + 0 False @@ -567,6 +570,7 @@ specified priority 6 Password protection: start + 0 False @@ -1212,6 +1216,15 @@ specified priority + + both + True + + + + + + False Внимание! diff --git a/ubl-settings-bootloader_ru.po b/ubl-settings-bootloader_ru.po index f74bcd5..4e58ae2 100644 --- a/ubl-settings-bootloader_ru.po +++ b/ubl-settings-bootloader_ru.po @@ -16,6 +16,9 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +msgid "Enter login" +msgstr "Введите логин" + msgid "Enter your password" msgstr "Введите пароль"