From 7ed96aa34e3e40db4da371ca5b48bb21120871c5 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Fri, 10 Feb 2023 11:24:48 +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=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=BD=D0=B5=D0=B4=D0=BE=D0=BF=D1=83=D1=81=D1=82=D0=B8=D0=BC?= =?UTF-8?q?=D1=8B=D1=85=20=D1=81=D0=B8=D0=BC=D0=B2=D0=BE=D0=BB=D0=BE=D0=B2?= =?UTF-8?q?=20=D0=BF=D1=80=D0=B8=20=D0=B2=D0=B2=D0=BE=D0=B4=D0=B5=20ntp,?= =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BB=D0=BE=D0=BA=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ubl-settings-datetime.cc | 36 +++++++++++++++++++++++++-------- ubl-settings-datetime.glade | 2 +- ubl-settings-datetime_ru.po | 11 ++++++---- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index 87ca41d..9639378 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -122,11 +122,11 @@ int MainWindow::check_root(){ } void MainWindow::lacalization(){ txtDate->set_tooltip_text(_("Date of\nFormat: DD.MM.YYYY")); - txtNtpServer->set_tooltip_text(_("Enter the name of the ntp server or its ip address.\nWhen entering multiple addresses, separate them with spaces.")); + txtNtpServer->set_tooltip_text(_("Enter the name of the ntp-server or its ip-address.\nWhen entering multiple addresses, separate them with commas.")); lblSynchronizebChkGLob->set_text(_("Synchronize via NTP")); - cbDhcp->append(_("By default")); + cbDhcp->append(_("Default")); cbDhcp->append(_("DHCP")); - cbDhcp->append(_("Manually")); + cbDhcp->append(_("Manual")); lblDateTimeSetting->set_text(_("Local Configuration")); lblHead->set_text(_("Settings the date and time")); lblTime->set_text(_("Time")); @@ -327,8 +327,28 @@ bool MainWindow::focus_ntp(GdkEventFocus* event){ } else{ string cmd = ""; - cmd = "/usr/bin/ubconfig set network NTPSERVERS=" + txtNtpServer->get_text(); - this->call(cmd.c_str()); + string array_simvol[]={ + "!","\"","#","$","%","^","'","*","(",")","+",":",";","=","<",">","?", + "@","[","]","\\","{","}","|","~", " " + }; + bool flag_error = false; + string str_ntp = txtNtpServer->get_text(); + for (const auto &simvol: array_simvol){ + if (str_ntp.find(simvol)!=std::string::npos){ + cout << simvol << 2222 << endl; + flag_error=true; + break; + + } + } + if (flag_error==false){ + cmd = "/usr/bin/ubconfig set network NTPSERVERS=\"" + str_ntp + "\""; + this->call(cmd.c_str()); + } + else{ + lblMessage->set_text(_("An invalid character is entered")); + mess_dchp->show(); + } } return true; @@ -364,7 +384,7 @@ void MainWindow::event_entry_cbDhcp(){ str_dhcp = str_dhcp.substr(str_dhcp.find("=")+1,str_dhcp.length()); str_dhcp = str_dhcp.substr(0,str_dhcp.find("\n")); if (str_dhcp!="dhcp" && str_dhcp!="(null)"){ - txtNtpServer->set_text(str_dhcp); + txtNtpServer->set_text(""); } cbDhcp->set_active(activ_index); } @@ -439,7 +459,7 @@ void MainWindow::enry_dhcp_mess(){ } else if (str_dhcp=="default"){ cbDhcp->set_active(0); - txtNtpServer->set_text(str_dhcp); + txtNtpServer->set_text(""); txtNtpServer->set_sensitive(false); } else{ @@ -656,7 +676,7 @@ void MainWindow::append_zone_glob(){ cbZoneGlob->set_active(0); } void MainWindow::wrapper_update_time_date(){ - string cmd = "pidof systemd-timesyncd ntpd chronyd"; + string cmd = "pidof systemd-timesyncd ntpd chronyd ntpdate openntpd ptp4l phc2sys"; string response = this->call(cmd); if (response.length()==0){ this->update_time_date(); diff --git a/ubl-settings-datetime.glade b/ubl-settings-datetime.glade index 0c04dfe..32570d0 100644 --- a/ubl-settings-datetime.glade +++ b/ubl-settings-datetime.glade @@ -218,7 +218,7 @@ - + diff --git a/ubl-settings-datetime_ru.po b/ubl-settings-datetime_ru.po index 5b04ae9..caecef2 100644 --- a/ubl-settings-datetime_ru.po +++ b/ubl-settings-datetime_ru.po @@ -6,6 +6,9 @@ msgid "" msgstr "" +msgid "An invalid character is entered" +msgstr "Введён недопустимый символ" + msgid "Longyearbyen" msgstr "Лонгйир" @@ -18,13 +21,13 @@ msgstr "Закрыть" msgid "Active service detected\nAutomatic time and date synchronization service detected" msgstr "Обнаружен активный сервис\nавтоматической синхронизации времени и даты" -msgid "By default" +msgid "Default" msgstr "По умолчанию" msgid "The program must be run with \nsuperuser privileges!" msgstr "Программа должна быть запущена с правами \nсуперпользователя!" -msgid "Manually" +msgid "Manual" msgstr "Вручную" msgid "Enter DHCP!" @@ -1593,6 +1596,6 @@ msgstr "Майотта" msgid "BajaSur" msgstr "Южная Нижняя Калифорния" -msgid "Enter the name of the ntp server or its ip address.\nWhen entering multiple addresses, separate them with spaces." -msgstr "Введите имя ntp-сервера или его ip-адрес.\nПри вводе нескольких адресов, разделяйте их пробелами." +msgid "Enter the name of the ntp-server or its ip-address.\nWhen entering multiple addresses, separate them with commas." +msgstr "Введите имя ntp-сервера или его ip-адрес.\nПри вводе нескольких адресов, разделяйте их запятыми."