|
|
|
|
@ -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 <string, string> &map_temp) {
|
|
|
|
|
struct Result<string> 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 <string, string> &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 <string, string> &map_temp) {
|
|
|
|
|
// TODO:
|
|
|
|
|
// Не работает
|
|
|
|
|
struct Result<string> 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<string> 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 <string, string> &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 <string, string>:: iterator iter_map_data;
|
|
|
|
|
std::map <string, string>:: iterator iter_map_data_old;
|
|
|
|
|
std::map <string, string> 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<Gtk::StyleContext> 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<Gtk::StyleContext> lblInfoHead_css = lblInfoHead->get_style_context();
|
|
|
|
|
Glib::RefPtr<Gtk::StyleContext> boxButton_css = boxButton->get_style_context();
|
|
|
|
|
Glib::RefPtr<Gtk::StyleContext> 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");
|
|
|
|
|
|