Сделан пункт "Логин защиты"

pull/11/head
Igor Belitskiy 3 years ago
parent 792eb67355
commit 5de6ad547d

@ -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<string> 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<string> 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<string, string> &map_view, const Gtk::TreeModel::Path& path, Glib::RefPtr<Gtk::ListStore> &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);
}

@ -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<string> get_setting_entry_all(string cmd, Gtk::Entry &entry_text, std::map <string, string> &map_temp);
void cmd_entry_all(string cmd_settings_kernel,string cmd_settings_IPT,string cmd_settings_OTT);

@ -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, нет лога"

Loading…
Cancel
Save