From 5de6ad547d7cf4781e2be24da5fd8f6cd744f851 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Thu, 30 Mar 2023 15:38:09 +0600 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD=20=D0=BF?= =?UTF-8?q?=D1=83=D0=BD=D0=BA=D1=82=20"=D0=9B=D0=BE=D0=B3=D0=B8=D0=BD=20?= =?UTF-8?q?=D0=B7=D0=B0=D1=89=D0=B8=D1=82=D1=8B"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ubl-settings-bootloader.cc | 79 +++++++++++++++++++++++++++++-- source/ubl-settings-bootloader.h | 2 + ubl-settings-bootloader_ru.po | 6 +++ 3 files changed, 84 insertions(+), 3 deletions(-) diff --git a/source/ubl-settings-bootloader.cc b/source/ubl-settings-bootloader.cc index c5e4f1e..b60f861 100755 --- a/source/ubl-settings-bootloader.cc +++ b/source/ubl-settings-bootloader.cc @@ -78,14 +78,13 @@ void MainWindow::settings(){ btnBoxAboutDialog->set_visible(false); ubl_make_plugs(boxSave,boxButton, socket_ext_id_I, socket_trd_id_I); if (this->check_root() == 0) { - spbSecond->set_range(0, 100000000000); + 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->event(); - - } else{ boxWidgetAll->set_sensitive(false); @@ -192,6 +191,7 @@ void MainWindow::get_download_mode(string cmd) { cmbDownloadMode->set_active(-1); } } + void MainWindow::set_download_mode(string cmd) { int index = cmbDownloadMode->get_active_row_number(); string key = ""; @@ -215,6 +215,70 @@ void MainWindow::set_download_mode(string cmd) { } +void MainWindow::set_security_login(string cmd) { + int index = chbSecurityLogin->get_active_row_number(); + string key = ""; + if (index == 0){ + key = "superadmin"; + } + else if (index == 1) { + key = string(getlogin()); + } + else { + return; + } + entrySecurityLogin->set_text(key); + cmd = cmd + key; + wrapper_system(cmd, ""); +} +void MainWindow::get_security_login(string cmd) { + struct Result res_response = this->wrapper_call(cmd); + if (res_response.error == 0) { + cout << res_response.response << endl; + str_replace_all(res_response.response, "\"",""); + entrySecurityLogin->set_text(res_response.response); + if (res_response.response == getlogin()) { + chbSecurityLogin->set_active(1); + } + else if (res_response.response.length() != 0) { + chbSecurityLogin->set_active(0); + } + else{ + chbSecurityLogin->set_active(-1); + } + } + else if (res_response.error == 3) { + chbSecurityLogin->set_active(-1); + } + else { + chbSecurityLogin->set_active(-1); + } +} + +void MainWindow::set_password_protec(string cmd) { + struct Result res_response = this->wrapper_call(cmd); + if (res_response.error == 0) { + cout << res_response.response << endl; + str_replace_all(res_response.response, "\"",""); + entrySecurityLogin->set_text(res_response.response); + if (res_response.response == getlogin()) { + chbSecurityLogin->set_active(1); + } + else if (res_response.response.length() != 0) { + chbSecurityLogin->set_active(0); + } + else{ + chbSecurityLogin->set_active(-1); + } + } + else if (res_response.error == 3) { + chbSecurityLogin->set_active(-1); + } + else { + chbSecurityLogin->set_active(-1); + } +} + void MainWindow::template_item_selected(std::map &map_view, const Gtk::TreeModel::Path& path, Glib::RefPtr &list_store) { const auto iter = list_store->get_iter(path); if(iter) { @@ -367,6 +431,9 @@ void MainWindow::localization(){ lblSecurityLogin->set_text(gettext("Security login:")); lblPasswordProtec->set_text(gettext("Password protection:")); + chbSecurityLogin->append(gettext("Default")); + chbSecurityLogin->append(gettext("Mine")); + cmbDownloadMode->append(gettext("Plymouth graphics, full log")); cmbDownloadMode->append(gettext("Plymouth graphics, no log")); cmbDownloadMode->append(gettext("No plymouth, minimal log")); @@ -506,6 +573,7 @@ void MainWindow::save_global_local_cfg() { string cmd_settings_OTT = "ubconfig --target global set boot GRUB_TERMINAL_INPUT="; this->cmd_entry_all(cmd_settings_kernel,cmd_settings_IPT,cmd_settings_OTT); this->set_download_mode("ubconfig --target global set boot GRUB_BOOT_SILENT="); + this->set_security_login("ubconfig --target global set boot GRUB_USER="); flag_save_all = false; } if (flag_save_local) { @@ -517,6 +585,7 @@ void MainWindow::save_global_local_cfg() { string cmd_settings_OTT = "ubconfig --target system set boot GRUB_TERMINAL_INPUT="; this->cmd_entry_all(cmd_settings_kernel,cmd_settings_IPT,cmd_settings_OTT); this->set_download_mode("ubconfig --target system set boot GRUB_BOOT_SILENT="); + this->set_security_login("ubconfig --target system set boot GRUB_USER="); flag_save_all = false; } else if (flag_save_local == false && flag_save_local == false) { @@ -538,6 +607,7 @@ void MainWindow::save_global_cfg() { string cmd_settings_OTT = "ubconfig --target global set boot GRUB_TERMINAL_INPUT="; this->cmd_entry_all(cmd_settings_kernel,cmd_settings_IPT,cmd_settings_OTT); this->set_download_mode("ubconfig --target global set boot GRUB_BOOT_SILENT="); + this->set_security_login("ubconfig --target global set boot GRUB_USER="); flag_save_global = false; } } @@ -558,6 +628,7 @@ void MainWindow::save_local_cfg() { string cmd_settings_OTT = "ubconfig --target system set boot GRUB_TERMINAL_INPUT="; this->cmd_entry_all(cmd_settings_kernel,cmd_settings_IPT,cmd_settings_OTT); this->set_download_mode("ubconfig --target system set boot GRUB_BOOT_SILENT="); + this->set_security_login("ubconfig --target system set boot GRUB_USER="); flag_save_local = true; } } @@ -588,6 +659,7 @@ void MainWindow::download_globl_cfg() { this->set_row_all(map_global_cmd_selection, list_store_IPT, vec_Option_IPT, size_IPT); this->set_row_all(map_global_cmd_selection, list_store_OTT, vec_Option_OTT, size_OTT); this->get_download_mode("ubconfig --default --source global get boot GRUB_BOOT_SILENT"); + this->get_security_login("ubconfig --default --source global get boot GRUB_USER"); info_warning_error(1); } @@ -611,6 +683,7 @@ void MainWindow::download_local_cfg() { this->set_row_all(map_local_cmd_selection, list_store_IPT, vec_Option_IPT, size_IPT); this->set_row_all(map_local_cmd_selection, list_store_OTT, vec_Option_OTT, size_OTT); this->get_download_mode("ubconfig --default --source system get boot GRUB_BOOT_SILENT"); + this->get_security_login("ubconfig --default --source system get boot GRUB_USER"); info_warning_error(0); } diff --git a/source/ubl-settings-bootloader.h b/source/ubl-settings-bootloader.h index 99595ac..8a3dbb6 100644 --- a/source/ubl-settings-bootloader.h +++ b/source/ubl-settings-bootloader.h @@ -166,6 +166,8 @@ class MainWindow : public Gtk::ApplicationWindow { bool focus_out_txt_IPT(GdkEventFocus*); bool focus_out_txt_OTT(GdkEventFocus*); void fill_in_view(); + void set_security_login(string cmd); + void get_security_login(string cmd); void set_download_mode(string cmd); vector get_setting_entry_all(string cmd, Gtk::Entry &entry_text, std::map &map_temp); void cmd_entry_all(string cmd_settings_kernel,string cmd_settings_IPT,string cmd_settings_OTT); diff --git a/ubl-settings-bootloader_ru.po b/ubl-settings-bootloader_ru.po index 7e8af3c..b48e630 100644 --- a/ubl-settings-bootloader_ru.po +++ b/ubl-settings-bootloader_ru.po @@ -19,6 +19,12 @@ msgstr "" msgid "Plymouth graphics, full log" msgstr "Графика plymouth, полный лог" +msgid "Mine" +msgstr "Свой" + +msgid "Default" +msgstr "По умолчанию" + msgid "Plymouth graphics, no log" msgstr "Графика plymouth, нет лога"