From df0d0af3eee9106f1c89eaad9a5f96ba601b8772 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Tue, 14 Feb 2023 09:26:10 +0600 Subject: [PATCH 01/10] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=B1=D0=B0=D0=B3=D0=B8=20=D1=81=20?= =?UTF-8?q?=D0=B3=D0=B0=D0=BB=D0=BA=D0=BE=D0=B9=20dhcp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ubl-settings-datetime.cc | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index 89b2d19..ac46b29 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -383,7 +383,7 @@ void MainWindow::event_entry_cbDhcp(){ txtNtpServer->set_text(""); } string str_dhcp = this->call("/usr/bin/ubconfig get network NTPSERVERS"); - if ((str_dhcp!="") && (str_dhcp!="(null)") && (str_dhcp.find("default")==std::string::npos)){ + if ((str_dhcp.find("(null)")==std::string::npos) && (str_dhcp.find("default")==std::string::npos)){ 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)"){ @@ -450,9 +450,11 @@ void MainWindow::calendar_show(){ void MainWindow::enry_dhcp_mess(){ string str_dhcp = this->call("/usr/bin/ubconfig get network NTPSERVERS"); - if ((str_dhcp!="") && (str_dhcp!="(null)")){ - cbxSynchronizeNtpGlob->set_active(1); - this->set_ntp_toggle_glob(); + cout << str_dhcp << endl; + if (str_dhcp.find("(null)")==std::string::npos){ + + cbxSynchronizeNtpGlob->set_active(true); + //this->set_ntp_toggle_glob(); 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"){ @@ -482,9 +484,10 @@ void MainWindow::enry_dhcp_mess(){ } } else{ - cbxSynchronizeNtpGlob->set_active(0); - cbDhcp->set_sensitive(0); - txtNtpServer->set_sensitive(0); + cout << 2222 << endl; + cbxSynchronizeNtpGlob->set_active(false); + cbDhcp->set_sensitive(false); + txtNtpServer->set_sensitive(false); } } @@ -602,14 +605,16 @@ void MainWindow::set_ntp_toggle_glob(){ if (flag==false){ system("/usr/bin/ubconfig remove network NTPSERVERS"); cbDhcp->set_sensitive(false); + txtNtpServer->set_text(""); txtNtpServer->set_sensitive(false); + } else{ cbDhcp->set_sensitive(true); - int activ_index = cbDhcp->get_active_row_number(); - if (activ_index==2){ - txtNtpServer->set_sensitive(true); - } + system("/usr/bin/ubconfig set network NTPSERVERS=dhcp"); + cbDhcp->set_active(1); + txtNtpServer->set_text(""); + txtNtpServer->set_sensitive(false); } } From e3c225dbf1a80790b1298034ff0c77f97bb6ea4f Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Tue, 14 Feb 2023 12:47:23 +0600 Subject: [PATCH 02/10] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=81=D0=BE=D1=80=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=BA?= =?UTF-8?q?=20=D0=B7=D0=BE=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ubl-settings-datetime.cc | 53 +++++++++++++++++++++++++++++++-- source/ubl-settings-datetime.h | 1 + ubl-settings-datetime_ru.po | 3 ++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index ac46b29..51f356d 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -338,7 +338,6 @@ bool MainWindow::focus_ntp(GdkEventFocus* event){ 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; @@ -450,7 +449,6 @@ void MainWindow::calendar_show(){ void MainWindow::enry_dhcp_mess(){ string str_dhcp = this->call("/usr/bin/ubconfig get network NTPSERVERS"); - cout << str_dhcp << endl; if (str_dhcp.find("(null)")==std::string::npos){ cbxSynchronizeNtpGlob->set_active(true); @@ -843,6 +841,7 @@ void MainWindow::read_file(){ } in1.close(); } + this->sort_zone(&zone_local, &zone); time_reg_map.insert({key_reg, zone}); time_reg_map_local.insert({key_reg, zone_local}); }}}} @@ -852,6 +851,56 @@ void MainWindow::read_file(){ } } +void MainWindow::sort_zone(vector *time_reg_map_local,vector *time_reg_map){ + string str_j = ""; + int j_i; + string str_j_1 = ""; + int j_i_1; + int size_vec = time_reg_map_local->size(); + for (int i = 0; i < size_vec; i++) { + for (int j = 0; j < size_vec-1; j++) { + str_j=(*time_reg_map_local)[j]; + str_j = str_j.substr(5,str_j.find(")")-5); + if (str_j[1]=='0'){ + str_j.replace(1,1,"0"); + } + + if (str_j.find("+") != std::string::npos){ + str_j.replace(0,1,"+"); + j_i = stoi(str_j); + } + else{ + str_j.replace(0,1,"-"); + j_i = stoi(str_j); + j_i=-j_i; + } + str_j_1=(*time_reg_map_local)[j+1]; + str_j_1 = str_j_1.substr(5,str_j_1.find(")")-5); + if (str_j_1[1]=='0'){ + str_j_1.replace(1,1,"0"); + } + if (str_j_1.find("+") != std::string::npos){ + str_j_1.replace(0,1,"+"); + j_i_1 = stoi(str_j_1); + } + else{ + str_j_1.replace(0,1,"-"); + j_i_1 = stoi(str_j_1); + j_i_1 = -j_i_1; + } + if (j_i > j_i_1) { + string b = (*time_reg_map_local)[j]; + (*time_reg_map_local)[j] = (*time_reg_map_local)[j + 1]; + (*time_reg_map_local)[j + 1] = b; + + b = (*time_reg_map)[j]; + (*time_reg_map)[j] = (*time_reg_map)[j + 1]; + (*time_reg_map)[j + 1] = b; + } + } + } +} + string MainWindow::zone_file_read(string zone){ if (zone.length()==1){ return ""; diff --git a/source/ubl-settings-datetime.h b/source/ubl-settings-datetime.h index d55f61d..e72a8b1 100644 --- a/source/ubl-settings-datetime.h +++ b/source/ubl-settings-datetime.h @@ -72,6 +72,7 @@ class MainWindow : public Gtk::ApplicationWindow { void wind_close_ntp(); void wrapper_update_time_date(); string zone_file_read(string zone); + void sort_zone(vector *time_reg_map_local,vector *time_reg_map); array split_region_zone(string read_reg_zon_cfg); string str_remove(std::string& source, const std::string to_remove); vector split(const std::string &s, char delim); diff --git a/ubl-settings-datetime_ru.po b/ubl-settings-datetime_ru.po index deadb04..e725dbd 100644 --- a/ubl-settings-datetime_ru.po +++ b/ubl-settings-datetime_ru.po @@ -1609,3 +1609,6 @@ msgstr "Южная Нижняя Калифорния" msgid "Enter the name of the ntp-server or its ip-address.\nWhen entering multiple addresses, separate them with commas." msgstr "Введите имя ntp-сервера или его ip-адрес.\nПри вводе нескольких адресов, разделяйте их запятыми." +msgid "Cape_Verde" +msgstr "Кабо-Верде" + From d4257708369b507d3ec83d128c2f3406ec327fb2 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Tue, 14 Feb 2023 12:59:11 +0600 Subject: [PATCH 03/10] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=20help?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/main.cc | 6 +++--- source/ubl-settings-datetime.cc | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/source/main.cc b/source/main.cc index ec8c69f..6c979b8 100644 --- a/source/main.cc +++ b/source/main.cc @@ -17,13 +17,13 @@ int main(int argc, char* argv[]) { if (argc>1){ str_argv = argv[1]; } - if ((str_argv.find("--lock")!=std::string::npos || argc==1)){ + if (str_argv.find("-")!=std::string::npos){ int len_argv = 1; auto app = Gtk::Application::create(len_argv, argv, "org.gtkmm.example.plug"); auto builder = Gtk::Builder::create_from_file(path_glade + "ubl-settings-datetime.glade"); for (int i=0; iset_active(false); cbDhcp->set_sensitive(false); txtNtpServer->set_sensitive(false); From 4fc3e9f6ed9d2b73e1d3ed2832a38c59a571f3f7 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Tue, 14 Feb 2023 15:30:21 +0600 Subject: [PATCH 04/10] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=20=D0=B4=D0=B8=D0=B7=D0=B0=D0=B9=D0=BD=20?= =?UTF-8?q?=D0=B8=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=20=D0=BD=D0=B5?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=B0=D1=80=D0=B3?= =?UTF-8?q?=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=20=D0=BA=D0=BE=D0=BC=D0=B0?= =?UTF-8?q?=D0=BD=D0=B4=D0=BD=D0=BE=D0=B9=20=D1=81=D1=82=D1=80=D0=BE=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/main.cc | 47 +- source/ubl-settings-datetime.cc | 54 +- ubl-settings-datetime.desktop | 2 +- ubl-settings-datetime.glade | 1205 +++++++++++++++---------------- ubl-settings-datetime_ru.po | 24 + 5 files changed, 672 insertions(+), 660 deletions(-) diff --git a/source/main.cc b/source/main.cc index 6c979b8..f423a3a 100644 --- a/source/main.cc +++ b/source/main.cc @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include "ubl-settings-datetime.h" int main(int argc, char* argv[]) { string str_argv=""; @@ -17,11 +19,31 @@ int main(int argc, char* argv[]) { if (argc>1){ str_argv = argv[1]; } - if (str_argv.find("-")!=std::string::npos){ + + if ((str_argv.find("-s")!=std::string::npos) || (str_argv.find("--socket-id")!=std::string::npos)){ + + auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example.plug"); + auto builder = Gtk::Builder::create_from_file(path_glade + "ubl-settings-datetime.glade"); + Glib::init(); + Glib::OptionContext context; + CmdArgParser parser{ + "Socket ID", + "Command line argument for socket ID communication.", + "No help available, sorry" + }; + context.set_main_group(parser); + context.parse(argc, argv); + ::Window socketID = parser.GetSocketID(); + SettingsPlug plug{socketID, builder}; + plug.show(); + app->run(plug); + return 0; + } + else if (str_argv.find("-")!=std::string::npos || argc==1){ int len_argv = 1; auto app = Gtk::Application::create(len_argv, argv, "org.gtkmm.example.plug"); auto builder = Gtk::Builder::create_from_file(path_glade + "ubl-settings-datetime.glade"); - for (int i=0; irun(plug); + else{ + cout << gettext("Argument not recognized"); return 0; } } \ No newline at end of file diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index ec18f1b..9db3e71 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -53,6 +53,7 @@ CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_descr socketIDArg.set_short_name('s'); socketIDArg.set_flags(Glib::OptionEntry::FLAG_IN_MAIN); socketIDArg.set_description("Settings manager socket"); + cout << m_socketID << endl; add_entry(socketIDArg, m_socketID); } @@ -102,7 +103,6 @@ void MainWindow::settings(){ lblZone->set_sensitive(false); lblTimeZone->set_sensitive(false); lblDateTimeSettingGlob->set_sensitive(false); - cbxSynchronizeNtpGlob->set_sensitive(false); lblSynchronizebChkGLob->set_sensitive(false); cbDhcp->set_sensitive(false); txtNtpServer->set_sensitive(false); @@ -130,6 +130,7 @@ void MainWindow::lacalization(){ cbDhcp->append(_("Default")); cbDhcp->append(_("DHCP")); cbDhcp->append(_("Manual")); + cbDhcp->append(_("Disabled")); lblDateTimeSetting->set_text(_("Local Configuration")); lblHead->set_text(_("Settings the date and time")); lblTime->set_text(_("Time")); @@ -167,7 +168,6 @@ void MainWindow::flag_block_gui(){ btnHardwareTime->set_sensitive(false); lblTime->set_sensitive(false); lblData->set_sensitive(false); - //cbxSynchronizeNtpGlob->set_sensitive(false); } if (flag_timezone==true){ cbRegion->set_sensitive(false); @@ -178,14 +178,12 @@ void MainWindow::flag_block_gui(){ cbDhcp->set_sensitive(false); } if (flag_ntp==true){ - cbxSynchronizeNtpGlob->set_sensitive(false); cbDhcp->set_sensitive(false); txtNtpServer->set_sensitive(false); } if (flag_update==true){ lblDateTimeSettingGlob->set_sensitive(false); //lblSynchronizebChkGLob->set_sensitive(false); - cbxSynchronizeNtpGlob->set_sensitive(false); lblTimeZoneGlob->set_sensitive(false); lblRegGlob->set_sensitive(false); cbRegionGlob->set_sensitive(false); @@ -214,7 +212,6 @@ void MainWindow::get_builder(){ builder->get_widget("btnUpdateDateTime", btnUpdateDateTime); builder->get_widget("btnChooseDate", btnChooseDate); builder->get_widget("btnMessClose", btnMessClose); - builder->get_widget("cbxSynchronizeNtpGlob", cbxSynchronizeNtpGlob); builder->get_widget("popCalendar", popCalendar); builder->get_widget("numTimeHrs", numTimeHrs); builder->get_widget("numTimeMin", numTimeMin); @@ -269,12 +266,10 @@ bool MainWindow::gui_exit_2(GdkEventAny* event){ } void MainWindow::event(){ - //cbxSynchronizeNtpGlob->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::set_ntp_toggle)); btnHardwareTime->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::hardware_clock)); btnMessClose->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::gui_mess_close)); btnMessCloseSudo->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::gui_exit)); //cldrDate->signal_day_selected().connect(sigc::mem_fun(*this, &MainWindow::get_calendar)); - cbxSynchronizeNtpGlob->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::set_ntp_toggle_glob)); btnUpdateDateTime->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::wrapper_update_time_date)); btnChooseDate->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::calendar_show)); cbDhcp->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::event_entry_cbDhcp)); @@ -392,6 +387,11 @@ void MainWindow::event_entry_cbDhcp(){ } } } + else if (activ_index==3){ + system("/usr/bin/ubconfig remove network NTPSERVERS"); + txtNtpServer->set_text(""); + txtNtpServer->set_sensitive(false); + } else{ string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp"; system(cmd.c_str()); @@ -450,9 +450,6 @@ void MainWindow::calendar_show(){ void MainWindow::enry_dhcp_mess(){ string str_dhcp = this->call("/usr/bin/ubconfig get network NTPSERVERS"); if (str_dhcp.find("(null)")==std::string::npos){ - - cbxSynchronizeNtpGlob->set_active(true); - //this->set_ntp_toggle_glob(); 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"){ @@ -482,8 +479,8 @@ void MainWindow::enry_dhcp_mess(){ } } else{ - cbxSynchronizeNtpGlob->set_active(false); - cbDhcp->set_sensitive(false); + cbDhcp->set_active(3); + txtNtpServer->set_text(""); txtNtpServer->set_sensitive(false); } } @@ -597,24 +594,6 @@ void MainWindow::enter_zone_glob(){ } } -void MainWindow::set_ntp_toggle_glob(){ - bool flag = cbxSynchronizeNtpGlob->get_active(); - if (flag==false){ - system("/usr/bin/ubconfig remove network NTPSERVERS"); - cbDhcp->set_sensitive(false); - txtNtpServer->set_text(""); - txtNtpServer->set_sensitive(false); - - } - else{ - cbDhcp->set_sensitive(true); - system("/usr/bin/ubconfig set network NTPSERVERS=dhcp"); - cbDhcp->set_active(1); - txtNtpServer->set_text(""); - txtNtpServer->set_sensitive(false); - } - -} void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxText *tmpCbReg, Gtk::ComboBoxText *tmpCbZone){ str_region=region; @@ -630,7 +609,6 @@ void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxTex } index+=1; } - index = 0; string zone_mixing = ""; string path_reg_zone = ""; @@ -949,18 +927,18 @@ vector MainWindow::split(const std::string &s, char delim){ SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr builder) : Gtk::Plug{p_socketID} { - builder->get_widget("plugBox", plugBox); + builder->get_widget("id_plug", plugBox); plugBox->get_parent()->remove(*plugBox); add(*plugBox); show_all_children(); } void help(){ - g_print("Usage: ubl-settings-datetime [--lock-timezone] [--lock-ntp] [--lock-datetime] [--lock-update]\n"); - g_print("Options:\n"); - g_print(" --lock-timezone Disable timezone field editing\n"); - g_print(" --lock-ntp Disable ntp field editing\n"); - g_print(" --lock-datetime Disable datetime field editing\n"); - g_print(" --lock-update Disable save changes\n"); + g_print(gettext("Usage: ubl-settings-datetime [--lock-timezone] [--lock-ntp] [--lock-datetime] [--lock-update]\n")); + g_print(gettext("Options:\n")); + g_print(gettext(" --lock-timezone Disable timezone field editing\n")); + g_print(gettext(" --lock-ntp Disable ntp field editing\n")); + g_print(gettext(" --lock-datetime Disable datetime field editing\n")); + g_print(gettext(" --lock-update Disable save changes\n")); } diff --git a/ubl-settings-datetime.desktop b/ubl-settings-datetime.desktop index 87d86f7..8e07f0d 100644 --- a/ubl-settings-datetime.desktop +++ b/ubl-settings-datetime.desktop @@ -10,4 +10,4 @@ Type=Application Exec=pkexec ubl-settings-datetime Icon=ubl-settings-datetime Terminal=false -Categories=XFCE;GTK;Settings;DesktopSettings;X-XFCE-SettingsDialog;X-XFCE-SystemSettings; \ No newline at end of file +Categories=XFCE;GTK;Settings;DesktopSettings;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;X-UBL-SettingsManager;X-UBL-SystemSettings; \ No newline at end of file diff --git a/ubl-settings-datetime.glade b/ubl-settings-datetime.glade index 2ddfb98..7370d8c 100644 --- a/ubl-settings-datetime.glade +++ b/ubl-settings-datetime.glade @@ -169,464 +169,229 @@ + + 240 + 185 + False + btnChooseDate + bottom + none + + + True + True + 10 + 10 + 10 + 10 + 10 + 10 + 2023 + 1 + 10 + + + False Настройки даты и времени - + True False vertical - + True False + vertical - - 90 - True - False - 5 - 5 - 5 - 5 - 6 - 6 - 69 - ubl-settings-datetime - - - False - True - 0 - - - - + True False - + + 90 True False - - - True - False - vertical - - - 255 - True - False - Date and time settings - - - - - - - - - True - True - 0 - - - - - False - True - 0 - - + 5 + 5 + 5 + 5 + 6 + 6 + 69 + ubl-settings-datetime - True + False True 0 - - - True - False - - - False - True - 1 - - - - - True - True - 1 - - - - - False - True - 0 - - - - - True - False - vertical - - - True - False - 6 - 5 - 5 - 5 - 0.019999999552965164 - in True False - 6 - 5 - 5 - vertical True False - - 160 - True - False - 5 - 5 - 5 - 5 - 6 - 6 - Time - True - 0 - - - False - True - 0 - - - - - True - True - 5 - 5 - 5 - 5 - 6 - 6 - 2 - 0.099999999776482579 - True - - - False - True - 1 - - - - - True - False - : - - - False - True - 2 - - - - - True - True - 5 - 5 - 5 - 5 - 6 - 6 - 2 - True - - - False - True - 3 - - - - - False - True - 1 - - - - - True - False - - - 160 + True False - 5 - 5 - 5 - 5 - 6 - 6 - Date - True - 0 - - - False - True - 0 - - - - - 191 - True - True - Date -Format: DD.MM.YYYY - 5 - 5 - 5 - 5 - 6 - 6 - - - False - True - 1 - - - - - True - True - True - Интерактивный выбор даты - 5 - 5 - 5 - 5 - 6 - 6 + vertical - + + 255 True False - x-office-calendar + Date and time settings + + + + + + + + True + True + 0 + False True - 2 + 0 - False + True True - 2 + 0 - + True False - - - True - True - True - 5 - 5 - 5 - 5 - 6 - 6 - - - True - False - center - center - - - True - False - 5 - 5 - 5 - 5 - media-playlist-repeat - - - False - True - 0 - - - - - True - False - center - center - Sync by - - - False - True - 1 - - - - - - - False - True - 0 - - - - - True - False - - - False - True - 1 - - - - - True - False - - - False - True - 2 - - - - - True - True - True - 5 - 5 - 5 - 10 - 6 - 6 - - - True - False - center - center - Synchronize hardware time - - - - - True - True - 3 - - False True - 3 + 1 + + + True + True + 1 + + + + + False + True + 0 + + + + + True + False + vertical + + + True + False + 5 + 5 + 5 + 5 + 0.019999999552965164 + in - + True False 5 - 5 5 - 10 - 6 - 0.019999999552965164 - in + 5 + vertical True False - + + 160 True False + 5 + 5 + 5 + 5 + 6 + 6 + Time + True + 0 False True - 1 + 0 - + True - False + True 5 5 - 8 + 5 5 6 - 13 - Region - 0 + 6 + 2 + 0.099999999776482579 + True False True - 2 + 1 - + True False + : + + + False + True + 2 + + + + + True + True 5 5 5 5 6 - 13 + 6 + 2 + True False @@ -634,52 +399,160 @@ Format: DD.MM.YYYY 3 + + + False + True + 1 + + + + + True + False - + + 160 True False 5 5 - 10 + 5 5 6 - 13 - Area + 6 + Date + True 0 False True - 4 + 0 - + + 191 True - False + True + Date +Format: DD.MM.YYYY + 5 + 5 + 5 + 5 + 6 + 6 + + + False + True + 1 + + + + + True + True + True + Интерактивный выбор даты + 5 + 5 + 5 + 5 + 6 + 6 + + + True + False + x-office-calendar + + + + + False + True + 2 + + + + + False + True + 2 + + + + + True + False + + + True + True + True 5 5 5 5 6 - 13 + 6 + + + True + False + center + center + + + True + False + 5 + 5 + 5 + 5 + media-playlist-repeat + + + False + True + 0 + + + + + True + False + center + center + Sync by + + + False + True + 1 + + + + False True - 5 + 0 - 5 True False False True - 6 + 1 @@ -690,87 +563,231 @@ Format: DD.MM.YYYY False True - 7 + 2 + + + + + True + True + True + 5 + 10 + 5 + 10 + 6 + 6 + + + True + False + center + center + Synchronize hardware time + + + + + True + True + 3 + + False + True + 3 + - - + + True False - Time Zone + 5 + 10 + 5 + 10 + 6 + 0.019999999552965164 + in + + + True + False + + + True + False + + + False + True + 1 + + + + + True + False + 8 + 5 + 8 + 5 + 6 + 13 + Region + 0 + + + False + True + 2 + + + + + True + False + 5 + 5 + 5 + 5 + 6 + 13 + + + False + True + 3 + + + + + True + False + 10 + 5 + 10 + 5 + 6 + 13 + Area + 0 + + + False + True + 4 + + + + + True + False + 5 + 5 + 5 + 5 + 6 + 13 + + + False + True + 5 + + + + + 5 + True + False + + + False + True + 6 + + + + + True + False + + + False + True + 7 + + + + + + + True + False + Time Zone + + + + False + True + 5 + - - False - True - 5 - + + + + True + False + Local Configuration + - - - - True - False - Local Configuration - - - - - False - True - 0 - - - - - False - True - 1 - - - - - True - False - vertical + + False + True + 0 + + + + + False + True + 1 + + - + True False - 5 - 5 - 5 - 5 - 0.019999999552965164 - in + vertical - + True False - 6 + 5 + 5 5 - 5 - vertical + 5 + 0.019999999552965164 + in - + True - True - False - Автоматическая синхронизация времени + False 5 - 5 5 - 5 - 6 - True + 5 + vertical True False + start 5 5 5 @@ -779,243 +796,225 @@ Format: DD.MM.YYYY 6 Synchronize via NTP - - - - False - True - 0 - - - - - True - False - - - True - False - 5 - 5 - 5 - 5 - 6 - 5 - False True - 1 - - - - - -1 - True - True - Enter the name of the ntp server or its ip address. When entering multiple addresses, separate them with spaces. - center - 5 - 5 - 5 - 10 - 6 - 5 - - - True - True - 3 + 0 - - - False - True - 1 - - - - - True - False - 5 - 5 - 5 - 10 - 6 - 0.019999999552965164 - in True False - - True - False - - - False - True - 1 - - - - + True False - 8 + 5 5 - 8 + 5 5 6 - 13 - Region - 0 + 5 False True - 2 + 1 - + + -1 True - False + True + Enter the name of the ntp server or its ip address. When entering multiple addresses, separate them with spaces. + center 5 - 5 + 10 5 - 5 + 10 6 - 13 + 5 - False + True True 3 + + + False + True + 1 + + + + + True + False + 5 + 10 + 5 + 10 + 6 + 0.019999999552965164 + in - - True - False - 10 - 5 - 10 - 5 - 5 - 13 - Area - 0 - - - False - True - 4 - - - - + True False - 5 - 5 - 5 - 5 - 6 - 13 + + + True + False + + + False + True + 1 + + + + + True + False + 8 + 5 + 8 + 5 + 6 + 13 + Region + 0 + + + False + True + 2 + + + + + True + False + 5 + 5 + 5 + 5 + 6 + 13 + + + False + True + 3 + + + + + True + False + 10 + 5 + 10 + 5 + 5 + 13 + Area + 0 + + + False + True + 4 + + + + + True + False + 5 + 5 + 5 + 5 + 6 + 13 + + + False + True + 5 + + + + + 5 + True + False + 15 + 5 + 15 + 5 + 5 + 5 + + + False + True + 6 + + - - False - True - 5 - - - - 5 + + True False - 15 - 5 - 15 - 5 - 5 - 5 + Часовой пояс - - False - True - 6 - - - - - True - False - Часовой пояс - + + False + True + 2 + - - False - True - 2 - + + + + True + False + Global customization + - - - - True - False - Global customization - + + False + True + 0 + False True - 0 + 2 False True - 2 + 0 - - 240 - 185 - False - btnChooseDate - bottom - none - - - True - True - 10 - 10 - 10 - 10 - 10 - 10 - 2023 - 1 - 10 - - - False diff --git a/ubl-settings-datetime_ru.po b/ubl-settings-datetime_ru.po index e725dbd..b32e1e6 100644 --- a/ubl-settings-datetime_ru.po +++ b/ubl-settings-datetime_ru.po @@ -1612,3 +1612,27 @@ msgstr "Введите имя ntp-сервера или его ip-адрес.\n msgid "Cape_Verde" msgstr "Кабо-Верде" +msgid "Usage: ubl-settings-datetime [--lock-timezone] [--lock-ntp] [--lock-datetime] [--lock-update]\n" +msgstr "Использование: ubl-settings-datetime [--lock-timezone] [--lock-ntp] [--lock-datetime] [--lock-update]\n" + +msgid " --lock-timezone Disable timezone field editing\n" +msgstr " --lock-timezone Отключить редактирование поля часового пояса\n" + +msgid " --lock-ntp Disable ntp field editing\n" +msgstr " --lock-ntp Отключить редактирование полей ntp\n" + +msgid " --lock-datetime Disable datetime field editing\n" +msgstr " --lock-datetime Отключить редактирование полей даты и времени\n" + +msgid " --lock-update Disable save changes\n" +msgstr " --lock-update Отключить сохранение изменений\n" + +msgid "Options:\n" +msgstr "Опции:\n" + +msgid "Disabled" +msgstr "Отключено" + +msgid "Argument not recognized\n" +msgstr "Не распознанный аргумент\n" + From e68202ce39708e132a105a7047fbcfc70d272035 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Wed, 15 Feb 2023 09:12:22 +0600 Subject: [PATCH 05/10] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B4=20=D0=B2?= =?UTF-8?q?=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC=20=D0=B1=D0=BE?= =?UTF-8?q?=D0=BB=D1=8C=D1=88=D0=B8=D1=85=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nohup.out | 21 ++++++++++++++ source/main.cc | 7 +++++ source/ubl-settings-datetime.cc | 46 +++++++++++++++--------------- source/ubl-settings-datetime.h | 5 ++-- style.css | 2 +- ubl-settings-datetime.desktop | 3 +- ubl-settings-datetime.glade | 50 ++++++++++++++++----------------- ubl-settings-datetime_ru.po | 4 +-- 8 files changed, 85 insertions(+), 53 deletions(-) create mode 100644 nohup.out diff --git a/nohup.out b/nohup.out new file mode 100644 index 0000000..48125d2 --- /dev/null +++ b/nohup.out @@ -0,0 +1,21 @@ +xhost: bad hostname "superadmin" +X Error of failed request: BadValue (integer parameter out of range for operation) + Major opcode of failed request: 109 (X_ChangeHosts) + Value in failed request: 0xa + Serial number of failed request: 7 + Current serial number in output stream: 9 +localuser: being added to access control list +xhost: bad hostname "superadmin" +X Error of failed request: BadValue (integer parameter out of range for operation) + Major opcode of failed request: 109 (X_ChangeHosts) + Value in failed request: 0xa + Serial number of failed request: 7 + Current serial number in output stream: 9 +localuser: being added to access control list +xhost: bad hostname "superadmin" +X Error of failed request: BadValue (integer parameter out of range for operation) + Major opcode of failed request: 109 (X_ChangeHosts) + Value in failed request: 0xa + Serial number of failed request: 7 + Current serial number in output stream: 9 +localuser: being added to access control list diff --git a/source/main.cc b/source/main.cc index f423a3a..4c57ffb 100644 --- a/source/main.cc +++ b/source/main.cc @@ -25,17 +25,24 @@ int main(int argc, char* argv[]) { auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example.plug"); auto builder = Gtk::Builder::create_from_file(path_glade + "ubl-settings-datetime.glade"); Glib::init(); + setlocale(LC_ALL, ""); Glib::OptionContext context; + CmdArgParser parser{ "Socket ID", "Command line argument for socket ID communication.", "No help available, sorry" }; + context.set_main_group(parser); context.parse(argc, argv); + ::Window socketID = parser.GetSocketID(); + + // Handle plug: SettingsPlug plug{socketID, builder}; plug.show(); + app->run(plug); return 0; } diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index 9db3e71..c9a2324 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -46,29 +46,26 @@ bool flag_ntp = false; bool flag_update = false; CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help) -: Glib::OptionGroup{p_name, p_description, p_help} -{ +: Glib::OptionGroup{p_name, p_description, p_help} { Glib::OptionEntry socketIDArg; socketIDArg.set_long_name("socket-id"); socketIDArg.set_short_name('s'); socketIDArg.set_flags(Glib::OptionEntry::FLAG_IN_MAIN); socketIDArg.set_description("Settings manager socket"); - cout << m_socketID << endl; add_entry(socketIDArg, m_socketID); } - -::Window CmdArgParser::GetSocketID() const { +::Window CmdArgParser::GetSocketID() const{ return m_socketID; } MainWindow::MainWindow(BaseObjectType* obj, Glib::RefPtr const& builder) - : Gtk::ApplicationWindow(obj) - , builder{builder} { - this->settings(); + : Gtk::ApplicationWindow(obj), builder{builder} { + this->builder = builder; + this->settings(); } MainWindow::MainWindow(Glib::RefPtr const& builder) { - this->builder = builder; + this->builder = builder; this->settings(); } @@ -126,7 +123,7 @@ 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 commas.")); - lblSynchronizebChkGLob->set_text(_("Synchronize via NTP")); + lblSynchronizebChkGLob->set_text(_("Synchronize via NTP:")); cbDhcp->append(_("Default")); cbDhcp->append(_("DHCP")); cbDhcp->append(_("Manual")); @@ -202,8 +199,10 @@ void MainWindow::add_CSS(){ styleContext->add_provider_for_screen(screen, cssProvider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);//add provider for screen in all application Glib::RefPtr context = boxColor->get_style_context(); Glib::RefPtr context_lbl_head = lblHead->get_style_context(); + //Glib::RefPtr context_button = btnHardwareTime->get_style_context(); context->add_class("cssboxColor1"); context_lbl_head->add_class("textHead"); + //context_button->add_class("textHead"); } void MainWindow::get_builder(){ @@ -385,13 +384,15 @@ void MainWindow::event_entry_cbDhcp(){ } cbDhcp->set_active(activ_index); } - } } else if (activ_index==3){ - system("/usr/bin/ubconfig remove network NTPSERVERS"); + string cmd = "/usr/bin/ubconfig remove network NTPSERVERS"; + system(cmd.c_str()); txtNtpServer->set_text(""); txtNtpServer->set_sensitive(false); + } } + else{ string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp"; system(cmd.c_str()); @@ -865,14 +866,14 @@ void MainWindow::sort_zone(vector *time_reg_map_local,vector *ti j_i_1 = stoi(str_j_1); j_i_1 = -j_i_1; } - if (j_i > j_i_1) { - string b = (*time_reg_map_local)[j]; - (*time_reg_map_local)[j] = (*time_reg_map_local)[j + 1]; - (*time_reg_map_local)[j + 1] = b; + if (j_i > j_i_1) { + string b = (*time_reg_map_local)[j]; + (*time_reg_map_local)[j] = (*time_reg_map_local)[j + 1]; + (*time_reg_map_local)[j + 1] = b; - b = (*time_reg_map)[j]; - (*time_reg_map)[j] = (*time_reg_map)[j + 1]; - (*time_reg_map)[j + 1] = b; + b = (*time_reg_map)[j]; + (*time_reg_map)[j] = (*time_reg_map)[j + 1]; + (*time_reg_map)[j + 1] = b; } } } @@ -925,9 +926,10 @@ vector MainWindow::split(const std::string &s, char delim){ } SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr builder) -: Gtk::Plug{p_socketID} -{ - builder->get_widget("id_plug", plugBox); + : Gtk::Plug{p_socketID} { + MainWindow* wnd = nullptr; + builder->get_widget_derived("window", wnd); + builder->get_widget("plugBox", plugBox); plugBox->get_parent()->remove(*plugBox); add(*plugBox); show_all_children(); diff --git a/source/ubl-settings-datetime.h b/source/ubl-settings-datetime.h index e72a8b1..c4164cc 100644 --- a/source/ubl-settings-datetime.h +++ b/source/ubl-settings-datetime.h @@ -30,6 +30,7 @@ public: ::Window GetSocketID() const; private: int m_socketID = 0; + }; class MainWindow : public Gtk::ApplicationWindow { @@ -152,11 +153,11 @@ class MainWindow : public Gtk::ApplicationWindow { "US"}; }; -class SettingsPlug : public Gtk::Plug -{ +class SettingsPlug : public Gtk::Plug{ public: Gtk::Window *window; SettingsPlug(::Window p_socketID, Glib::RefPtr builder); + private: Gtk::Widget *plugBox; Gtk::Widget *parent; diff --git a/style.css b/style.css index 8c5d210..88c8a58 100644 --- a/style.css +++ b/style.css @@ -3,4 +3,4 @@ } .textHead{ text-shadow: 1px 1px #ffffff; -} \ No newline at end of file +} diff --git a/ubl-settings-datetime.desktop b/ubl-settings-datetime.desktop index 8e07f0d..436b551 100644 --- a/ubl-settings-datetime.desktop +++ b/ubl-settings-datetime.desktop @@ -7,7 +7,8 @@ GenericName[ru]=Настройка даты и времени Comment=Date time settings Comment[ru]=Приложение для настройки даты и времени Type=Application -Exec=pkexec ubl-settings-datetime +Exec=ubl-settings-datetime Icon=ubl-settings-datetime Terminal=false +X-XfcePluggable=true Categories=XFCE;GTK;Settings;DesktopSettings;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;X-UBL-SettingsManager;X-UBL-SystemSettings; \ No newline at end of file diff --git a/ubl-settings-datetime.glade b/ubl-settings-datetime.glade index 7370d8c..b207f15 100644 --- a/ubl-settings-datetime.glade +++ b/ubl-settings-datetime.glade @@ -169,29 +169,6 @@ - - 240 - 185 - False - btnChooseDate - bottom - none - - - True - True - 10 - 10 - 10 - 10 - 10 - 10 - 2023 - 1 - 10 - - - False Настройки даты и времени @@ -201,7 +178,7 @@ False vertical - + True False vertical @@ -794,7 +771,7 @@ Format: DD.MM.YYYY 5 6 6 - Synchronize via NTP + Synchronize via NTP: False @@ -1015,6 +992,29 @@ Format: DD.MM.YYYY + + 240 + 185 + False + btnChooseDate + bottom + none + + + True + True + 10 + 10 + 10 + 10 + 10 + 10 + 2023 + 1 + 10 + + + False diff --git a/ubl-settings-datetime_ru.po b/ubl-settings-datetime_ru.po index b32e1e6..c414d4c 100644 --- a/ubl-settings-datetime_ru.po +++ b/ubl-settings-datetime_ru.po @@ -97,8 +97,8 @@ msgstr "Синхронизировать" msgid "Automatic time synchronization" msgstr "Автоматическая синхронизация времени" -msgid "Synchronize via NTP" -msgstr "Синхронизировать через NTP" +msgid "Synchronize via NTP:" +msgstr "Синхронизировать через NTP:" msgid "Time zone" msgstr "Часовой пояс" From 3f04ea127960a38e36bd17734cd5ec1a7dbf1f21 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Wed, 15 Feb 2023 10:33:52 +0000 Subject: [PATCH 06/10] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=BE=20=D0=BE=D1=82=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20ntp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ubl-settings-datetime.cc | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index c9a2324..0dc4cdd 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -269,7 +269,7 @@ void MainWindow::event(){ btnMessClose->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::gui_mess_close)); btnMessCloseSudo->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::gui_exit)); //cldrDate->signal_day_selected().connect(sigc::mem_fun(*this, &MainWindow::get_calendar)); - btnUpdateDateTime->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::wrapper_update_time_date)); + btnUpdateDateTime->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::update_time_date)); btnChooseDate->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::calendar_show)); cbDhcp->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::event_entry_cbDhcp)); cbRegion->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::append_zone)); @@ -287,7 +287,6 @@ void MainWindow::wind_close_ntp(){ } void MainWindow::stop_ntp(){ - windowsNnpClose->hide(); string cmd = "SEL_SERVICE=\"systemd-timesyncd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service; "; system(cmd.c_str()); cmd ="SEL_SERVICE=\"ntpd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; "; @@ -302,8 +301,6 @@ void MainWindow::stop_ntp(){ system(cmd.c_str()); cmd ="SEL_SERVICE=\"phc2sys\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE} "; system(cmd.c_str()); - - this->update_time_date(); } @@ -355,6 +352,7 @@ void MainWindow::event_entry_cbDhcp(){ int activ_index = cbDhcp->get_active_row_number(); if (str_dhcp.length()!=0){ if (activ_index==0){ + btnUpdateDateTime->set_sensitive(false); string cmd = "/usr/bin/ubconfig set network NTPSERVERS=default"; system(cmd.c_str()); txtNtpServer->set_sensitive(false); @@ -364,6 +362,7 @@ void MainWindow::event_entry_cbDhcp(){ txtNtpServer->set_text(response); } else if (activ_index==1){ + btnUpdateDateTime->set_sensitive(false); string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp"; system(cmd.c_str()); txtNtpServer->set_sensitive(false); @@ -371,6 +370,7 @@ void MainWindow::event_entry_cbDhcp(){ txtNtpServer->set_text(""); } else if (activ_index==2){ + btnUpdateDateTime->set_sensitive(false); txtNtpServer->set_sensitive(true); if (txtNtpServer->get_text().find("default")!=std::string::npos){ txtNtpServer->set_text(""); @@ -390,6 +390,8 @@ void MainWindow::event_entry_cbDhcp(){ system(cmd.c_str()); txtNtpServer->set_text(""); txtNtpServer->set_sensitive(false); + btnUpdateDateTime->set_sensitive(true); + this->stop_ntp(); } } @@ -451,19 +453,23 @@ void MainWindow::calendar_show(){ void MainWindow::enry_dhcp_mess(){ string str_dhcp = this->call("/usr/bin/ubconfig get network NTPSERVERS"); if (str_dhcp.find("(null)")==std::string::npos){ + btnUpdateDateTime->set_sensitive(false); 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"){ + cbDhcp->set_active(1); txtNtpServer->set_text(""); txtNtpServer->set_sensitive(false); } else if (str_dhcp=="default"){ + btnUpdateDateTime->set_sensitive(false); cbDhcp->set_active(0); txtNtpServer->set_text(""); txtNtpServer->set_sensitive(false); } else{ + btnUpdateDateTime->set_sensitive(false); if (str_dhcp==""){ lblMessage->set_text(_("Enter DHCP!")); mess_dchp->show(); @@ -483,6 +489,7 @@ void MainWindow::enry_dhcp_mess(){ cbDhcp->set_active(3); txtNtpServer->set_text(""); txtNtpServer->set_sensitive(false); + btnUpdateDateTime->set_sensitive(true); } } @@ -676,17 +683,6 @@ void MainWindow::append_zone_glob(){ } cbZoneGlob->set_active(0); } -void MainWindow::wrapper_update_time_date(){ - string cmd = "pidof systemd-timesyncd ntpd chronyd ntpdate openntpd ptp4l phc2sys"; - string response = this->call(cmd); - if (response.length()==0){ - this->update_time_date(); - } - else{ - windowsNnpClose->show(); - } - -} void MainWindow::update_time_date(){ //this->enter_zone(); From 088338af37bc3b3c6fa547f0538f6650f54cd77e Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Wed, 15 Feb 2023 14:39:26 +0000 Subject: [PATCH 07/10] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D1=84=D0=BB=D0=B0=D0=B3=D0=B8=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BF=D0=B8=D0=BB=D1=8F=D1=86=D0=B8=D0=B8,=20?= =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20?= =?UTF-8?q?=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/CMakeLists.txt | 5 ++++- source/ubl-settings-datetime.cc | 36 +++++++++++++++++---------------- source/ubl-settings-datetime.h | 1 + 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 13840d1..e4e1133 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -10,7 +10,10 @@ add_definitions(${GTK_CFLAGS_OTHER}) find_package(ICU REQUIRED COMPONENTS uc dt in io) #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -std=c++2a") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \ + -O2 -pipe -fno-plt -fexceptions \ + -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \ + -fstack-clash-protection -fcf-protection") set(SOURCE_FILES main.cc diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index 0dc4cdd..6638135 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -288,25 +288,25 @@ void MainWindow::wind_close_ntp(){ void MainWindow::stop_ntp(){ string cmd = "SEL_SERVICE=\"systemd-timesyncd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service; "; - system(cmd.c_str()); + response_cmd=system(cmd.c_str()); cmd ="SEL_SERVICE=\"ntpd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; "; - system(cmd.c_str()); + response_cmd=system(cmd.c_str()); cmd ="SEL_SERVICE=\"ntpdate\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; "; - system(cmd.c_str()); + response_cmd=system(cmd.c_str()); cmd = "SEL_SERVICE=\"chronyd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; "; - system(cmd.c_str()); + response_cmd=system(cmd.c_str()); cmd ="SEL_SERVICE=\"openntpd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ntpd; "; - system(cmd.c_str()); + response_cmd=system(cmd.c_str()); cmd ="SEL_SERVICE=\"ptp4l\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; "; - system(cmd.c_str()); + response_cmd=system(cmd.c_str()); cmd ="SEL_SERVICE=\"phc2sys\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE} "; - system(cmd.c_str()); + response_cmd=system(cmd.c_str()); } void MainWindow::hardware_clock(){ string cmd = "hwclock --systohc"; - system(cmd.c_str()); + response_cmd=system(cmd.c_str()); } void MainWindow::gui_mess_close(){ @@ -354,7 +354,7 @@ void MainWindow::event_entry_cbDhcp(){ if (activ_index==0){ btnUpdateDateTime->set_sensitive(false); string cmd = "/usr/bin/ubconfig set network NTPSERVERS=default"; - system(cmd.c_str()); + response_cmd=system(cmd.c_str()); txtNtpServer->set_sensitive(false); cbDhcp->set_active(activ_index); string response = this->call("/usr/bin/ubconfig --source=default get NTPSERVERS_DEFAULT"); @@ -364,7 +364,7 @@ void MainWindow::event_entry_cbDhcp(){ else if (activ_index==1){ btnUpdateDateTime->set_sensitive(false); string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp"; - system(cmd.c_str()); + response_cmd=system(cmd.c_str()); txtNtpServer->set_sensitive(false); cbDhcp->set_active(activ_index); txtNtpServer->set_text(""); @@ -387,7 +387,7 @@ void MainWindow::event_entry_cbDhcp(){ } else if (activ_index==3){ string cmd = "/usr/bin/ubconfig remove network NTPSERVERS"; - system(cmd.c_str()); + response_cmd=system(cmd.c_str()); txtNtpServer->set_text(""); txtNtpServer->set_sensitive(false); btnUpdateDateTime->set_sensitive(true); @@ -397,7 +397,7 @@ void MainWindow::event_entry_cbDhcp(){ else{ string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp"; - system(cmd.c_str()); + response_cmd=system(cmd.c_str()); cbDhcp->set_active(0); } } @@ -465,7 +465,9 @@ void MainWindow::enry_dhcp_mess(){ else if (str_dhcp=="default"){ btnUpdateDateTime->set_sensitive(false); cbDhcp->set_active(0); - txtNtpServer->set_text(""); + string response = this->call("/usr/bin/ubconfig --source=default get NTPSERVERS_DEFAULT"); + this->str_remove(response, "\n"); + txtNtpServer->set_text(response); txtNtpServer->set_sensitive(false); } else{ @@ -551,7 +553,7 @@ void MainWindow::enter_zone(){ str_region=reg_text; string cmd = ""; cmd = " ubconfig --target system set clock ZONE=" + str_region + "/" + str_zone; - system(cmd.c_str()); + response_cmd=system(cmd.c_str()); } else{ str_zone=""; @@ -589,7 +591,7 @@ void MainWindow::enter_zone_glob(){ if (!(zone_text.empty())){ //str_zoneGlob = zone_text.substr(zone_text.find(") ")+2,zone_text.length()); string cmd = "/usr/bin/ubconfig --target global set clock ZONE=" +reg_text +"/" + zone_text; - system(cmd.c_str()); + response_cmd=system(cmd.c_str()); } else{ str_zoneGlob=""; @@ -709,7 +711,7 @@ void MainWindow::update_time_date(){ if (str_data==str_data_entry){ cmd = "date +%Y%m%d -s \"" + to_string(year)+ str_month+str_day+"\""; - system(cmd.c_str()); + response_cmd=system(cmd.c_str()); txtDate->set_text(str_data); year=0; month=0; @@ -729,7 +731,7 @@ void MainWindow::update_time_date(){ cmd = "date +%T -s \""+ to_string(hour) + ":" + to_string(minute) + ":" + to_string(ltm->tm_sec) +"\""; - system(cmd.c_str()); + response_cmd=system(cmd.c_str()); } void MainWindow::post_entry_data(){ diff --git a/source/ubl-settings-datetime.h b/source/ubl-settings-datetime.h index c4164cc..a22dc6f 100644 --- a/source/ubl-settings-datetime.h +++ b/source/ubl-settings-datetime.h @@ -136,6 +136,7 @@ class MainWindow : public Gtk::ApplicationWindow { string strtxtNtpServer; string str_zone=""; string str_zoneGlob; + int response_cmd; string array_region[14]={ "Africa", "America", From e482d35939b6aa2672742d46cec30dc726a5b8bb Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Wed, 15 Feb 2023 17:16:22 +0000 Subject: [PATCH 08/10] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D1=91?= =?UTF-8?q?=D0=BD=20Desktop=20=D1=84=D0=B0=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ubl-settings-datetime.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubl-settings-datetime.desktop b/ubl-settings-datetime.desktop index 436b551..1037bf7 100644 --- a/ubl-settings-datetime.desktop +++ b/ubl-settings-datetime.desktop @@ -7,7 +7,7 @@ GenericName[ru]=Настройка даты и времени Comment=Date time settings Comment[ru]=Приложение для настройки даты и времени Type=Application -Exec=ubl-settings-datetime +Exec=pkexec ubl-settings-datetime Icon=ubl-settings-datetime Terminal=false X-XfcePluggable=true From 006f6e4b451941a4f8041a08423e184045ceff1c Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Wed, 15 Feb 2023 17:29:56 +0000 Subject: [PATCH 09/10] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=20=D0=B4=D0=B8=D0=B7=D0=B0=D0=B9=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ubl-settings-datetime.glade | 72 ++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 42 deletions(-) diff --git a/ubl-settings-datetime.glade b/ubl-settings-datetime.glade index b207f15..52dac69 100644 --- a/ubl-settings-datetime.glade +++ b/ubl-settings-datetime.glade @@ -169,6 +169,28 @@ + + 240 + 185 + False + bottom + none + + + True + True + 10 + 10 + 10 + 10 + 10 + 10 + 2023 + 1 + 10 + + + False Настройки даты и времени @@ -306,7 +328,7 @@ False - 160 + 0 True False 5 @@ -376,20 +398,9 @@ 3 - - - False - True - 1 - - - - - True - False - 160 + 20 True False 5 @@ -405,7 +416,7 @@ False True - 0 + 4 @@ -425,7 +436,7 @@ Format: DD.MM.YYYY False True - 1 + 5 @@ -451,14 +462,14 @@ Format: DD.MM.YYYY False True - 2 + 6 False True - 2 + 1 @@ -471,7 +482,7 @@ Format: DD.MM.YYYY True True 5 - 5 + 8 5 5 6 @@ -549,7 +560,7 @@ Format: DD.MM.YYYY True True 5 - 10 + 8 5 10 6 @@ -992,29 +1003,6 @@ Format: DD.MM.YYYY - - 240 - 185 - False - btnChooseDate - bottom - none - - - True - True - 10 - 10 - 10 - 10 - 10 - 10 - 2023 - 1 - 10 - - - False From de61309972fc80731aedea27b7ae8f6bf4284297 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Wed, 15 Feb 2023 18:14:31 +0600 Subject: [PATCH 10/10] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BB=20=D1=84?= =?UTF-8?q?=D0=B0=D0=B9=D0=BB=20nohup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nohup.out | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 nohup.out diff --git a/nohup.out b/nohup.out deleted file mode 100644 index 48125d2..0000000 --- a/nohup.out +++ /dev/null @@ -1,21 +0,0 @@ -xhost: bad hostname "superadmin" -X Error of failed request: BadValue (integer parameter out of range for operation) - Major opcode of failed request: 109 (X_ChangeHosts) - Value in failed request: 0xa - Serial number of failed request: 7 - Current serial number in output stream: 9 -localuser: being added to access control list -xhost: bad hostname "superadmin" -X Error of failed request: BadValue (integer parameter out of range for operation) - Major opcode of failed request: 109 (X_ChangeHosts) - Value in failed request: 0xa - Serial number of failed request: 7 - Current serial number in output stream: 9 -localuser: being added to access control list -xhost: bad hostname "superadmin" -X Error of failed request: BadValue (integer parameter out of range for operation) - Major opcode of failed request: 109 (X_ChangeHosts) - Value in failed request: 0xa - Serial number of failed request: 7 - Current serial number in output stream: 9 -localuser: being added to access control list