Добавлены флаги компиляции, исправлены ошибки

pull/46/head
Igor Belitskiy 3 years ago
parent 3f04ea1279
commit 088338af37

@ -10,7 +10,10 @@ add_definitions(${GTK_CFLAGS_OTHER})
find_package(ICU REQUIRED COMPONENTS uc dt in io) 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 -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 set(SOURCE_FILES
main.cc main.cc

@ -288,25 +288,25 @@ void MainWindow::wind_close_ntp(){
void MainWindow::stop_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; "; 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}; "; 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}; "; 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}; "; 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; "; 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}; "; 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} "; 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(){ void MainWindow::hardware_clock(){
string cmd = "hwclock --systohc"; string cmd = "hwclock --systohc";
system(cmd.c_str()); response_cmd=system(cmd.c_str());
} }
void MainWindow::gui_mess_close(){ void MainWindow::gui_mess_close(){
@ -354,7 +354,7 @@ void MainWindow::event_entry_cbDhcp(){
if (activ_index==0){ if (activ_index==0){
btnUpdateDateTime->set_sensitive(false); btnUpdateDateTime->set_sensitive(false);
string cmd = "/usr/bin/ubconfig set network NTPSERVERS=default"; string cmd = "/usr/bin/ubconfig set network NTPSERVERS=default";
system(cmd.c_str()); response_cmd=system(cmd.c_str());
txtNtpServer->set_sensitive(false); txtNtpServer->set_sensitive(false);
cbDhcp->set_active(activ_index); cbDhcp->set_active(activ_index);
string response = this->call("/usr/bin/ubconfig --source=default get NTPSERVERS_DEFAULT"); 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){ else if (activ_index==1){
btnUpdateDateTime->set_sensitive(false); btnUpdateDateTime->set_sensitive(false);
string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp"; string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp";
system(cmd.c_str()); response_cmd=system(cmd.c_str());
txtNtpServer->set_sensitive(false); txtNtpServer->set_sensitive(false);
cbDhcp->set_active(activ_index); cbDhcp->set_active(activ_index);
txtNtpServer->set_text(""); txtNtpServer->set_text("");
@ -387,7 +387,7 @@ void MainWindow::event_entry_cbDhcp(){
} }
else if (activ_index==3){ else if (activ_index==3){
string cmd = "/usr/bin/ubconfig remove network NTPSERVERS"; string cmd = "/usr/bin/ubconfig remove network NTPSERVERS";
system(cmd.c_str()); response_cmd=system(cmd.c_str());
txtNtpServer->set_text(""); txtNtpServer->set_text("");
txtNtpServer->set_sensitive(false); txtNtpServer->set_sensitive(false);
btnUpdateDateTime->set_sensitive(true); btnUpdateDateTime->set_sensitive(true);
@ -397,7 +397,7 @@ void MainWindow::event_entry_cbDhcp(){
else{ else{
string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp"; string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp";
system(cmd.c_str()); response_cmd=system(cmd.c_str());
cbDhcp->set_active(0); cbDhcp->set_active(0);
} }
} }
@ -465,7 +465,9 @@ void MainWindow::enry_dhcp_mess(){
else if (str_dhcp=="default"){ else if (str_dhcp=="default"){
btnUpdateDateTime->set_sensitive(false); btnUpdateDateTime->set_sensitive(false);
cbDhcp->set_active(0); 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); txtNtpServer->set_sensitive(false);
} }
else{ else{
@ -551,7 +553,7 @@ void MainWindow::enter_zone(){
str_region=reg_text; str_region=reg_text;
string cmd = ""; string cmd = "";
cmd = " ubconfig --target system set clock ZONE=" + str_region + "/" + str_zone; cmd = " ubconfig --target system set clock ZONE=" + str_region + "/" + str_zone;
system(cmd.c_str()); response_cmd=system(cmd.c_str());
} }
else{ else{
str_zone=""; str_zone="";
@ -589,7 +591,7 @@ void MainWindow::enter_zone_glob(){
if (!(zone_text.empty())){ if (!(zone_text.empty())){
//str_zoneGlob = zone_text.substr(zone_text.find(") ")+2,zone_text.length()); //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; 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{ else{
str_zoneGlob=""; str_zoneGlob="";
@ -709,7 +711,7 @@ void MainWindow::update_time_date(){
if (str_data==str_data_entry){ if (str_data==str_data_entry){
cmd = "date +%Y%m%d -s \"" + to_string(year)+ cmd = "date +%Y%m%d -s \"" + to_string(year)+
str_month+str_day+"\""; str_month+str_day+"\"";
system(cmd.c_str()); response_cmd=system(cmd.c_str());
txtDate->set_text(str_data); txtDate->set_text(str_data);
year=0; year=0;
month=0; month=0;
@ -729,7 +731,7 @@ void MainWindow::update_time_date(){
cmd = "date +%T -s \""+ cmd = "date +%T -s \""+
to_string(hour) + ":" + to_string(minute) to_string(hour) + ":" + to_string(minute)
+ ":" + to_string(ltm->tm_sec) +"\""; + ":" + to_string(ltm->tm_sec) +"\"";
system(cmd.c_str()); response_cmd=system(cmd.c_str());
} }
void MainWindow::post_entry_data(){ void MainWindow::post_entry_data(){

@ -136,6 +136,7 @@ class MainWindow : public Gtk::ApplicationWindow {
string strtxtNtpServer; string strtxtNtpServer;
string str_zone=""; string str_zone="";
string str_zoneGlob; string str_zoneGlob;
int response_cmd;
string array_region[14]={ string array_region[14]={
"Africa", "Africa",
"America", "America",

Loading…
Cancel
Save