From 34484f75388b41a55a871cbb9d69368035df7084 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Mon, 27 Feb 2023 10:55:14 +0600 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=B1=D0=B0=D0=B3=D0=B8=20=D1=81=20=D0=B2?= =?UTF-8?q?=D1=8B=D0=B2=D0=BE=D0=B4=D0=BE=D0=BC=20=D0=B8=D0=BD=D1=84=D0=BE?= =?UTF-8?q?=D1=80=D0=BC=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BE=D0=B1=20=D0=BE?= =?UTF-8?q?=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ubl-settings-datetime.cc | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index f51b484..d40ac05 100755 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -308,9 +308,11 @@ void MainWindow::event(){ } void MainWindow::synopsis_show(){ + int start_error = error_info; //wrapper_system("xdg-open https://wiki.ublinux.ru/ru/home"); - error_info=0; - warning_info=0; + if (start_error!=error_info){ + error_info=start_error; + } } void MainWindow::download_local_cfg(){ @@ -336,13 +338,12 @@ void MainWindow::download_globl_cfg(){ void MainWindow::save_local_cfg(){ string cmd = "ubconfig --target system set clock ZONE="; this->enter_zone(cmd); - info_warning_error(2); - string cmd_default = "/usr/bin/ubconfig --target system set network NTPSERVERS=default"; string cmd_dhcp = "/usr/bin/ubconfig --target system set network NTPSERVERS=dhcp"; string cmd_set_ntp = "/usr/bin/ubconfig --target system set network NTPSERVERS=\""; string remove = "/usr/bin/ubconfig --target system remove network NTPSERVERS"; this->save_Dhcp(cmd_default, cmd_dhcp, remove, cmd_set_ntp); + info_warning_error(2); } void MainWindow::save_global_cfg(){ @@ -358,7 +359,6 @@ void MainWindow::save_global_cfg(){ void MainWindow::save_global_local_cfg(){ string cmd = "ubconfig --target system set clock ZONE="; this->enter_zone(cmd); - info_warning_error(4); cmd = "/usr/bin/ubconfig --target global set clock ZONE="; this->enter_zone(cmd); string cmd_default = "/usr/bin/ubconfig --target global set network NTPSERVERS=default"; @@ -366,12 +366,12 @@ void MainWindow::save_global_local_cfg(){ string cmd_set_ntp = "/usr/bin/ubconfig --target global set network NTPSERVERS=\""; string remove = "/usr/bin/ubconfig --target global remove network NTPSERVERS"; this->save_Dhcp(cmd_default, cmd_dhcp, remove, cmd_set_ntp); - cmd_default = "/usr/bin/ubconfig --target system set network NTPSERVERS=default"; cmd_dhcp = "/usr/bin/ubconfig --target system set network NTPSERVERS=dhcp"; cmd_set_ntp = "/usr/bin/ubconfig --target system set network NTPSERVERS=\""; remove = "/usr/bin/ubconfig --target system remove network NTPSERVERS"; this->save_Dhcp(cmd_default, cmd_dhcp, remove, cmd_set_ntp); + info_warning_error(4); } void MainWindow::info_warning_error(int mess){ @@ -419,6 +419,7 @@ void MainWindow::info_warning_error(int mess){ void MainWindow::stop_ntp(){ + int start_error = error_info; string cmd = "SEL_SERVICE=\"systemd-timesyncd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service; "; wrapper_system(cmd); cmd ="SEL_SERVICE=\"ntpd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; "; @@ -433,7 +434,10 @@ void MainWindow::stop_ntp(){ wrapper_system(cmd); cmd ="SEL_SERVICE=\"phc2sys\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE} "; wrapper_system(cmd); - + if (start_error!=error_info){ + error_info=start_error; + } + cout << error_info << endl; } void MainWindow::wrapper_system(string cmd){ @@ -477,7 +481,6 @@ bool MainWindow::focus_ntp(string &cmd_set_ntp){ } if ((flag_error==false) && (flag_error_check_ntp==false)){ cmd = cmd_set_ntp + str_ntp + "\""; - //cmd = "/usr/bin/ubconfig set network NTPSERVERS=\"" + str_ntp + "\""; wrapper_system(cmd); } else{ @@ -635,20 +638,20 @@ void MainWindow::save_Dhcp(string &cmd_default, string &cmd_dhcp, string &remove } else if (activ_index==0){ - //string cmd = "/usr/bin/ubconfig set network NTPSERVERS=default"; wrapper_system(cmd_default); } else if (activ_index==1){ - //string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp"; wrapper_system(cmd_dhcp); } else if (activ_index==2){ this->focus_ntp(cmd_set_ntp); - //this->focus_ntp("/usr/bin/ubconfig set network NTPSERVERS=\""); } else if (activ_index==3){ - //string cmd = "/usr/bin/ubconfig remove network NTPSERVERS"; + int start_error = error_info; wrapper_system(remove); + if (start_error != error_info){ + error_info=start_error; + } } } @@ -678,7 +681,6 @@ void MainWindow::entry_dhcp_mess(string cmd_get_dhcp, string cmd_default_get_dhc } else{ if (obj_result.error==2){ - error_info-=1; warning_info-=1; } //string error = ""; @@ -709,6 +711,7 @@ void MainWindow::entry_dhcp_mess(string cmd_get_dhcp, string cmd_default_get_dhc txtNtpServer->set_text(""); txtNtpServer->set_sensitive(false); btnUpdateDateTime->set_sensitive(true); + warning_info-=1; } } @@ -903,11 +906,10 @@ void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxTex } } if (region=="Etc" && zone==""){ - error_info-=1; warning_info-=1; } else if (region==""){ - error_info+=1; + warning_info+=1; } }