From 7e25023e37ab323433f86bc168735a017c97eee9 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Mon, 13 Mar 2023 12:25:38 +0600 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=B2=20=D0=BE=D0=BA=D0=BD=D0=BE=20=D1=81=D0=BE?= =?UTF-8?q?=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=BE=D0=B1=20?= =?UTF-8?q?=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=D1=85=20=D0=B2=20=D0=BA?= =?UTF-8?q?=D0=B0=D0=BA=D0=BE=D0=BC=20=D0=BF=D0=BE=D0=BB=D0=B5=20=D0=BE?= =?UTF-8?q?=D1=88=D0=B8=D0=B1=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ubl-settings-datetime.cc | 82 +++++++++++++++++++++++---------- source/ubl-settings-datetime.h | 5 +- ubl-settings-datetime_ru.po | 11 ++++- 3 files changed, 70 insertions(+), 28 deletions(-) diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index f865d09..0f3375b 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -55,6 +55,32 @@ MainWindow::MainWindow(Glib::RefPtr const& builder) { } void MainWindow::settings() { + map_error["xdg-open https://wiki.ublinux.ru/ru/home"] = string(_(" : xdg-open")); + map_error["/usr/bin/ubconfig --default --source system get clock ZONE"] = string(_(" : Time Zone")); + map_error["hwclock --systohc"] = string(_(" : Hardware time")); + map_error["/usr/bin/ubconfig --default --source system get network NTPSERVERS"] = string(_(" : NTP")); + map_error["/usr/bin/ubconfig --source=default get NTPSERVERS_DEFAULT"] = string(_(" : NTP")); + map_error["/usr/bin/ubconfig --default --source system get clock HWCLOCK_SYNC"] = string(_(" : Hardware time")); + map_error["/usr/bin/ubconfig --default --source global get network NTPSERVERS"] = string(_(" : NTP")); + map_error["/usr/bin/ubconfig --default --source global get clock ZONE"] = string(_(" : Time Zone")); + map_error["/usr/bin/ubconfig --default --source global get clock HWCLOCK_SYNC"] = string(_(" : Hardware time")); + map_error["/usr/bin/ubconfig --source global get clock HWCLOCK_SYNC"] = string(_(" : Hardware time")); + map_error["/usr/bin/ubconfig --target system set clock ZONE="] = string(_(" : Time Zone")); + map_error["/usr/bin/ubconfig --target system set network NTPSERVERS=default"] = string(_(" : NTP")); + map_error["/usr/bin/ubconfig --target system set network NTPSERVERS=dhcp"] = string(_(" : NTP")); + map_error["/usr/bin/ubconfig --target system set network NTPSERVERS=\""] = string(_(" : NTP")); + map_error["/usr/bin/ubconfig --target system remove network NTPSERVERS"] = string(_(" : NTP")); + map_error["/usr/bin/ubconfig --target system set clock HWCLOCK_SYNC=localtime"] = string(_(" : Hardware time")); + map_error["/usr/bin/ubconfig --target system set clock HWCLOCK_SYNC=utc"] = string(_(" : Hardware time")); + map_error["/usr/bin/ubconfig --target global set clock ZONE="] = string(_(" : Time Zone")); + map_error["/usr/bin/ubconfig --target global set network NTPSERVERS=default"] = string(_(" : NTP")); + map_error["/usr/bin/ubconfig --target global set network NTPSERVERS=dhcp"] = string(_(" : NTP")); + map_error["/usr/bin/ubconfig --target global set network NTPSERVERS=\""] = string(_(" : NTP")); + map_error["/usr/bin/ubconfig --target global remove network NTPSERVERS"] = string(_(" : NTP")); + map_error["/usr/bin/ubconfig --target global set clock HWCLOCK_SYNC=localtime"] = string(_(" : Hardware time")); + map_error["/usr/bin/ubconfig --target global set clock HWCLOCK_SYNC=utc"] = string(_(" : Hardware time")); + map_error["date +%Y%m%d -s \""] = string(_(" : Date")); + map_error["date +%T -s \""] = ""; this->get_builder(); this->add_CSS(); ubl_make_plugs(boxSave,boxButton, socket_ext_id_I, socket_trd_id_I); @@ -72,7 +98,7 @@ void MainWindow::settings() { btnBoxAboutDialog->set_visible(false); this->event(); this->parse_text_date(); - this->download_local_cfg(); + this->download_local_cfg(); } else { lblHW->set_sensitive(false); @@ -182,7 +208,6 @@ void MainWindow::flag_block_gui() { if (flag_save_global == true) { btnSaveGlob->set_sensitive(false); } - } void MainWindow::add_CSS() { @@ -335,7 +360,7 @@ void MainWindow::download_globl_cfg() { this->entry_dhcp_mess(cmd_get_dhcp, cmd_default_get_dhcp); string cmd_zone = "/usr/bin/ubconfig --default --source global get clock ZONE"; this->fill_in_reg_zone(cmd_zone); - string hw = "/usr/bin/ubconfig --default --source global get clock HWCLOCK_SYNC"; + string hw = "/usr/bin/ubconfig --source global get clock HWCLOCK_SYNC"; string hw_default = "/usr/bin/ubconfig --default --source global get clock HWCLOCK_SYNC"; this->entry_hardware_clock(hw, hw_default); info_warning_error(1); @@ -386,45 +411,32 @@ void MainWindow::save_global_local_cfg() { void MainWindow::info_warning_error(int mess) { if (error_info > 0 || warning_info > 0) { - if (cmd_error.length()!=0){ - vector vec_cmd_prob; - vec_cmd_prob = this->find_all(cmd_error, " "); - size_t size_vec_prob = vec_cmd_prob.size(); - if (size_vec_prob > 1){ - int index = size_vec_prob - 1; - index = vec_cmd_prob[index]; - if (index){ - cmd_error = cmd_error.substr(index, cmd_error.length()); - } - } - } info_status_app("boxInfoMessError"); imgInfo->set("warning.svg"); error_info = 0; warning_info = 0; string mess_error = ""; if (mess == 0) { - mess_error = string(_("Local configuration reading error")) + " " + cmd_error; + mess_error = string(_("Local configuration reading error")) + cmd_error; lblWarning->set_text(mess_error); } else if (mess == 1) { - mess_error = string(_("Global configuration read error")) + " " + cmd_error; + mess_error = string(_("Global configuration read error")) + cmd_error; lblWarning->set_text(mess_error); } else if (mess == 2) { - mess_error = string(_("Local configuration write error")) + " " + cmd_error; + mess_error = string(_("Local configuration write error")) + cmd_error; lblWarning->set_text(mess_error); } else if (mess == 3) { - mess_error = string(_("Global configuration write error")) + " " + cmd_error; + mess_error = string(_("Global configuration write error")) + cmd_error; lblWarning->set_text(mess_error); } else if (mess == 4) { - mess_error = string(_("Error saved local and global configuration")) + " " + cmd_error; + mess_error = string(_("Error saved local and global configuration")) + cmd_error; lblWarning->set_text(mess_error); } cmd_error = ""; - cmd_error_write = ""; } else { info_status_app("boxInfoMessOK"); @@ -449,11 +461,27 @@ void MainWindow::info_warning_error(int mess) { void MainWindow::wrapper_system(string cmd, string thread_str = "") { - cmd = cmd + " " + thread_str; - int response_cmd = system(cmd.c_str()); + string cmd_new = cmd + " " + thread_str; + int response_cmd = system(cmd_new.c_str()); if (response_cmd != 0) { error_info += 1; - cmd_error_write = cmd; + this->log_mess_error(cmd); + } +} + +void MainWindow::log_mess_error(string &cmd){ + string key = ""; + if (map_error.find(cmd) != map_error.end()){ + cmd_error = map_error[cmd]; + } + else { + for ( const auto &map_iter: map_error ) { + key = map_iter.first; + if (cmd.find(key) != std::string::npos){ + cmd_error = map_iter.second; + break; + } + } } } @@ -649,7 +677,7 @@ struct MainWindow::Result MainWindow::wrapper_call(string cmd) { obj_result.response = response; obj_result.error = 1; warning_info += 1; - cmd_error = cmd; + this->log_mess_error(cmd); } } else { @@ -657,6 +685,7 @@ struct MainWindow::Result MainWindow::wrapper_call(string cmd) { obj_result.error = 2; warning_info += 1; cmd_error = cmd; + this->log_mess_error(cmd); } } else { @@ -664,10 +693,13 @@ struct MainWindow::Result MainWindow::wrapper_call(string cmd) { obj_result.error = 3; warning_info += 1; cmd_error = cmd; + this->log_mess_error(cmd); } return obj_result; } + + void MainWindow::event_entry_cbDhcp() { string str_dhcp = cbDhcp->get_active_text(); string cmd = ""; diff --git a/source/ubl-settings-datetime.h b/source/ubl-settings-datetime.h index a44284c..f35ccef 100755 --- a/source/ubl-settings-datetime.h +++ b/source/ubl-settings-datetime.h @@ -15,6 +15,7 @@ #include #include #include +#include #include "ubl-util-standard.c" @@ -121,12 +122,10 @@ class MainWindow : public Gtk::ApplicationWindow { int error_info = 0; int warning_info = 0; string cmd_error = ""; - string cmd_error_write = ""; int hour; int minute; string str_region = ""; string str_zone = ""; - bool bool_close_banner_info = true; template struct Result{ Type response; @@ -134,11 +133,13 @@ class MainWindow : public Gtk::ApplicationWindow { }; vector array_region_local; vector array_region; + std::map map_error; public: MainWindow(BaseObjectType* obj, Glib::RefPtr const& builder); MainWindow(Glib::RefPtr const& builder); virtual ~MainWindow() = default; + void log_mess_error(string &cmd); void hardware_clock_global(string &local, string &etc); void info_warning_error(int mess); void synopsis_show(); diff --git a/ubl-settings-datetime_ru.po b/ubl-settings-datetime_ru.po index aa10928..be9efbf 100644 --- a/ubl-settings-datetime_ru.po +++ b/ubl-settings-datetime_ru.po @@ -74,7 +74,7 @@ msgid "Successfully saved local and global configuration" msgstr "Успешно сохранена локальная и глобальная конфигурация" msgid "Error saved local and global configuration" -msgstr "Ошибка сохранена локальной и глобальной конфигурации" +msgstr "Ошибка сохранения локальной и глобальной конфигурации" msgid "Settings the date and time" msgstr "Настройки даты и времени" @@ -1768,6 +1768,15 @@ msgstr "О программе" msgid "Help" msgstr "Справка" +msgid " : Hardware time" +msgstr " : Аппаратного времени" + +msgid " : Time Zone" +msgstr " : Временной зоны " + +msgid " : Date" +msgstr " : Даты " + msgid "Local configuration reading error" msgstr "Ошибка чтения локальной конфигурации"