КОманды ubconfig вынесены в отдельный файл

pull/107/head
Igor Belitskiy 3 years ago
parent 3de8c6078a
commit d9a7ec1206

@ -4,6 +4,11 @@ project(ubl-settings-datetime)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED gtkmm-3.0) pkg_check_modules(GTK REQUIRED gtkmm-3.0)
pkg_check_modules(WEBKIT REQUIRED webkit2gtk-4.0 webkit2gtk-web-extension-4.0)
include_directories(${WEBKIT_INCLUDE_DIRS})
link_directories(${WEBKIT_LIBRARY_DIRS})
add_definitions(${WEBKIT_CFLAGS_OTHER})
include_directories(${GTK_INCLUDE_DIRS}) include_directories(${GTK_INCLUDE_DIRS})
link_directories(${GTK_LIBRARY_DIRS}) link_directories(${GTK_LIBRARY_DIRS})
add_definitions(${GTK_CFLAGS_OTHER}) add_definitions(${GTK_CFLAGS_OTHER})
@ -18,6 +23,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissin
set(SOURCE_FILES set(SOURCE_FILES
ubl-util-standard.h ubl-util-standard.h
ubl-util-standard.c ubl-util-standard.c
my_cmd.h
main.cc main.cc
ubl-settings-datetime.cc ubl-settings-datetime.cc
ubl-settings-datetime.h) ubl-settings-datetime.h)
@ -27,5 +33,5 @@ set(LIBRARIES
pthread) pthread)
add_executable(ubl-settings-datetime ${SOURCE_FILES}) add_executable(ubl-settings-datetime ${SOURCE_FILES})
target_link_libraries(ubl-settings-datetime ${LIBRARIES} ${ICU_LIBRARIES}) target_link_libraries(ubl-settings-datetime ${LIBRARIES} ${ICU_LIBRARIES} ${WEBKIT_LIBRARIES})
install(TARGETS ubl-settings-datetime DESTINATION bin) install(TARGETS ubl-settings-datetime DESTINATION bin)

@ -0,0 +1,30 @@
#ifndef MY_CMD_H
#define MY_CMD_H
#define link_doc "https://wiki.ublinux.com/ru/Программное_обеспечениерограммы_и_утилиты/Все/ubl-settings-datetime"
#define get_NTPSERVERS_DEFAULT "ubconfig --source default get [] NTPSERVERS_DEFAULT"
#define get_global_NTPSERVERS "ubconfig --default --source global get network NTPSERVERS"
#define get_system_ZONE "ubconfig --default --source system get clock ZONE"
#define get_system_NTPSERVERS "ubconfig --default --source system get network NTPSERVERS"
#define get_system_HWCLOCK_SYNC "ubconfig --default --source system get clock HWCLOCK_SYNC"
#define get_global_ZONE "ubconfig --default --source global get clock ZONE"
#define get_global_HWCLOCK_SYNC "ubconfig --source global get clock HWCLOCK_SYNC"
#define set_system_ZONE "ubconfig --target system set clock ZONE="
#define set_global_HWCLOCK_SYNC_utc "ubconfig --target global set clock HWCLOCK_SYNC=utc"
#define set_global_HWCLOCK_SYNC_localtime "ubconfig --target global set clock HWCLOCK_SYNC=localtime"
#define set_system_HWCLOCK_SYNC_localtime "ubconfig --target system set clock HWCLOCK_SYNC=localtime"
#define set_system_HWCLOCK_SYNC_utc "ubconfig --target system set clock HWCLOCK_SYNC=utc"
#define remove_global_NTPSERVERS "ubconfig --target global remove network NTPSERVERS"
#define set_system_NTPSERVERS_default "ubconfig --target system set network NTPSERVERS=default"
#define set_system_NTPSERVERS_dhcp "ubconfig --target system set network NTPSERVERS=dhcp"
#define set_system_NTPSERVERS "ubconfig --target system set network NTPSERVERS=\""
#define remove_system_NTPSERVERS "ubconfig --target system remove network NTPSERVERS"
#define set_global_ZONE "ubconfig --target global set clock ZONE="
#define set_global_NTPSERVERS_default "ubconfig --target global set network NTPSERVERS=default"
#define set_global_NTPSERVERS_dhcp "ubconfig --target global set network NTPSERVERS=dhcp"
#define set_global_NTPSERVERS "ubconfig --target global set network NTPSERVERS=\""
#define set_hwclock "hwclock --systohc"
#define get_global_defalult_HWCLOCK_SYNC "ubconfig --default --source global get clock HWCLOCK_SYNC"
#endif

@ -19,7 +19,7 @@ bool flag_load_global = false;
bool flag_sync_hwclock = false; bool flag_sync_hwclock = false;
int socket_ext_id_I = 0; int socket_ext_id_I = 0;
int socket_trd_id_I = 0; int socket_trd_id_I = 0;
string version_application = "1.5"; string version_application = "1.6";
CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help) 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} {
@ -55,34 +55,31 @@ MainWindow::MainWindow(Glib::RefPtr<Gtk::Builder> const& builder) {
} }
void MainWindow::settings() { void MainWindow::settings() {
map_error["xdg-open https://wiki.ublinux.ru/ru/home"] = string(gettext(": \"xdg-open\"")); map_error[get_system_ZONE] = string(gettext(": \"Time Zone\""));
map_error["ubconfig --default --source system get clock ZONE"] = string(gettext(": \"Time Zone\"")); map_error[set_hwclock] = string(gettext(": \"Hardware time\""));
map_error["hwclock --systohc"] = string(gettext(": \"Hardware time\"")); map_error[get_system_NTPSERVERS] = string(gettext(": \"NTP\""));
map_error["ubconfig --default --source system get network NTPSERVERS"] = string(gettext(": \"NTP\"")); map_error[get_system_HWCLOCK_SYNC] = string(gettext(": \"Hardware time\""));
map_error["ubconfig --source=default get NTPSERVERS_DEFAULT"] = string(gettext(": \"NTP\"")); map_error[get_global_NTPSERVERS] = string(gettext(": \"NTP\""));
map_error["ubconfig --default --source system get clock HWCLOCK_SYNC"] = string(gettext(": \"Hardware time\"")); map_error[get_global_ZONE] = string(gettext(": \"Time Zone\""));
map_error["ubconfig --default --source global get network NTPSERVERS"] = string(gettext(": \"NTP\"")); map_error[get_global_defalult_HWCLOCK_SYNC] = string(gettext(": \"Hardware time\""));
map_error["ubconfig --default --source global get clock ZONE"] = string(gettext(": \"Time Zone\"")); map_error[get_global_HWCLOCK_SYNC] = string(gettext(": \"Hardware time\""));
map_error["ubconfig --default --source global get clock HWCLOCK_SYNC"] = string(gettext(": \"Hardware time\"")); map_error[set_system_ZONE] = string(gettext(": \"Time Zone\""));
map_error["ubconfig --source global get clock HWCLOCK_SYNC"] = string(gettext(": \"Hardware time\"")); map_error[set_system_NTPSERVERS_default] = string(gettext(": \"NTP\""));
map_error["ubconfig --target system set clock ZONE="] = string(gettext(": \"Time Zone\"")); map_error[set_system_NTPSERVERS_dhcp] = string(gettext(": \"NTP\""));
map_error["ubconfig --target system set network NTPSERVERS=default"] = string(gettext(": \"NTP\"")); map_error[set_system_NTPSERVERS] = string(gettext(": \"NTP\""));
map_error["ubconfig --target system set network NTPSERVERS=dhcp"] = string(gettext(": \"NTP\"")); map_error[remove_system_NTPSERVERS] = string(gettext(": \"NTP\""));
map_error["ubconfig --target system set network NTPSERVERS=\""] = string(gettext(": \"NTP\"")); map_error[set_system_HWCLOCK_SYNC_localtime] = string(gettext(": \"Hardware time\""));
map_error["ubconfig --target system remove network NTPSERVERS"] = string(gettext(": \"NTP\"")); map_error[set_system_HWCLOCK_SYNC_utc] = string(gettext(": \"Hardware time\""));
map_error["ubconfig --target system set clock HWCLOCK_SYNC=localtime"] = string(gettext(": \"Hardware time\"")); map_error[set_global_ZONE] = string(gettext(": \"Time Zone\""));
map_error["ubconfig --target system set clock HWCLOCK_SYNC=utc"] = string(gettext(": \"Hardware time\"")); map_error[set_global_NTPSERVERS_default] = string(gettext(": \"NTP\""));
map_error["ubconfig --target global set clock ZONE="] = string(gettext(": \"Time Zone\"")); map_error[set_global_NTPSERVERS_dhcp] = string(gettext(": \"NTP\""));
map_error["ubconfig --target global set network NTPSERVERS=default"] = string(gettext(": \"NTP\"")); map_error[set_global_NTPSERVERS] = string(gettext(": \"NTP\""));
map_error["ubconfig --target global set network NTPSERVERS=dhcp"] = string(gettext(": \"NTP\"")); map_error[remove_global_NTPSERVERS] = string(gettext(": \"NTP\""));
map_error["ubconfig --target global set network NTPSERVERS=\""] = string(gettext(": \"NTP\"")); map_error[set_global_HWCLOCK_SYNC_localtime] = string(gettext(": \"Hardware time\""));
map_error["ubconfig --target global remove network NTPSERVERS"] = string(gettext(": \"NTP\"")); map_error[set_global_HWCLOCK_SYNC_utc] = string(gettext(": \"Hardware time\""));
map_error["ubconfig --target global set clock HWCLOCK_SYNC=localtime"] = string(gettext(": \"Hardware time\"")); map_error[get_NTPSERVERS_DEFAULT] = string(gettext(": \"NTP\""));
map_error["ubconfig --target global set clock HWCLOCK_SYNC=utc"] = string(gettext(": \"Hardware time\""));
map_error["ubconfig --source default get [] NTPSERVERS_DEFAULT"] = string(gettext(": \"NTP\""));
map_error["date +%Y%m%d -s \""] = string(gettext(": \"Date\"")); map_error["date +%Y%m%d -s \""] = string(gettext(": \"Date\""));
map_error["date +%T -s \""] = string(gettext(": \"Date\"")); map_error["date +%T -s \""] = string(gettext(": \"Date\""));
map_error["ubconfig --source default get clock HWCLOCK_SYNC"] = string(gettext(": \"Hardware time\""));
this->get_builder(); this->get_builder();
this->add_CSS(); this->add_CSS();
Gtk::Widget *boxWidget; Gtk::Widget *boxWidget;
@ -95,6 +92,9 @@ void MainWindow::settings() {
day = 0; day = 0;
this->lacalization(); this->lacalization();
btnBoxAboutDialog->set_visible(false); btnBoxAboutDialog->set_visible(false);
one = WEBKIT_WEB_VIEW( webkit_web_view_new() );
three = Glib::wrap( GTK_WIDGET( one ) );
wndWeb->add( *three );
if (geteuid() == 0) { if (geteuid() == 0) {
numTimeHrs->set_range(0, 23); numTimeHrs->set_range(0, 23);
numTimeMin->set_range(0, 59); numTimeMin->set_range(0, 59);
@ -106,8 +106,7 @@ void MainWindow::settings() {
this->parse_text_date(); this->parse_text_date();
this->load_globl_cfg(); this->load_globl_cfg();
this->load_local_cfg(); this->load_local_cfg();
string cmd = "ubconfig --source default get [] NTPSERVERS_DEFAULT"; default_get_dhcp = this->get_ubconfig_value(get_NTPSERVERS_DEFAULT);
default_get_dhcp = this->get_ubconfig_value(cmd);
this->str_remove(default_get_dhcp, "\""); this->str_remove(default_get_dhcp, "\"");
} }
else { else {
@ -150,6 +149,7 @@ void MainWindow::lacalization() {
lblZone->set_text(gettext("Zone:")); lblZone->set_text(gettext("Zone:"));
lblSynchronizeBtn->set_text(gettext("Sync by")); lblSynchronizeBtn->set_text(gettext("Sync by"));
lblHeader->set_text(gettext("ubl-settings-datetime")); lblHeader->set_text(gettext("ubl-settings-datetime"));
lblHeadeWndWeb->set_text(gettext("ubl-settings-datetime"));
windowMessDchp->set_title(gettext("Attention")); windowMessDchp->set_title(gettext("Attention"));
lblTimeBios->set_text(gettext("Synchronize hardware time")); lblTimeBios->set_text(gettext("Synchronize hardware time"));
lblHW->set_text(gettext("Synchronize hardware time:")); lblHW->set_text(gettext("Synchronize hardware time:"));
@ -313,7 +313,8 @@ void MainWindow::get_builder() {
builder->get_widget("boxWidgetFunc", boxWidgetFunc); builder->get_widget("boxWidgetFunc", boxWidgetFunc);
builder->get_widget("overHead", overHead); builder->get_widget("overHead", overHead);
builder->get_widget("imgHeadBackground", imgHeadBackground); builder->get_widget("imgHeadBackground", imgHeadBackground);
builder->get_widget("wndWeb", wndWeb);
builder->get_widget("lblHeadeWndWeb", lblHeadeWndWeb);
} }
void MainWindow::event() { void MainWindow::event() {
@ -384,30 +385,19 @@ void MainWindow::event_zone() {
} }
void MainWindow::synopsis_show() { void MainWindow::synopsis_show() {
int start_error = error_info; webkit_web_view_load_uri(one, link_doc);
string cmd = "xdg-open " + string(gettext("https://wiki.ublinux.com/ru/Программное_обеспечениерограммы_и_утилиты/Все/")) + app_name; wndWeb->show_all();
if (geteuid() == 0) {
string response_user = getlogin();
cmd = "su -l " + response_user + " -c \" DISPLAY=$DISPLAY " + cmd + " \"";
}
wrapper_system(cmd, "&");
if (start_error != error_info) {
error_info = start_error;
}
} }
void MainWindow::load_local_cfg() { void MainWindow::load_local_cfg() {
flag_local_global_load = 0; flag_local_global_load = 0;
flag_load = false; flag_load = false;
string cmd_zone = "ubconfig --default --source system get clock ZONE"; this->fill_in_reg_zone(get_system_ZONE);
this->fill_in_reg_zone(cmd_zone);
this->update_hour_minute(); this->update_hour_minute();
this->update_calendar(); this->update_calendar();
string cmd_get_dhcp = "ubconfig --default --source system get network NTPSERVERS"; this->entry_dhcp_mess(get_system_NTPSERVERS, get_NTPSERVERS_DEFAULT);
string cmd_default_get_dhcp = "ubconfig --source default get [] NTPSERVERS_DEFAULT"; this->get_hardware_clock(get_system_HWCLOCK_SYNC);
this->entry_dhcp_mess(cmd_get_dhcp, cmd_default_get_dhcp);
string hw = "ubconfig --default --source system get clock HWCLOCK_SYNC";
this->get_hardware_clock(hw);
info_warning_error(0); info_warning_error(0);
map_config_data_global_old = map_config_data_global; map_config_data_global_old = map_config_data_global;
map_config_data_local_old = map_config_data_local; map_config_data_local_old = map_config_data_local;
@ -417,13 +407,9 @@ void MainWindow::load_local_cfg() {
void MainWindow::load_globl_cfg() { void MainWindow::load_globl_cfg() {
flag_local_global_load = 1; flag_local_global_load = 1;
flag_load = true; flag_load = true;
string cmd_get_dhcp = "ubconfig --default --source global get network NTPSERVERS"; this->entry_dhcp_mess(get_global_NTPSERVERS, get_NTPSERVERS_DEFAULT);
string cmd_default_get_dhcp = "ubconfig --source default get [] NTPSERVERS_DEFAULT"; this->fill_in_reg_zone(get_global_ZONE);
this->entry_dhcp_mess(cmd_get_dhcp, cmd_default_get_dhcp); this->get_hardware_clock(get_global_HWCLOCK_SYNC);
string cmd_zone = "ubconfig --default --source global get clock ZONE";
this->fill_in_reg_zone(cmd_zone);
string hw = "ubconfig --source global get clock HWCLOCK_SYNC";
this->get_hardware_clock(hw);
info_warning_error(1); info_warning_error(1);
map_config_data_global_old = map_config_data_global; map_config_data_global_old = map_config_data_global;
map_config_data_local_old = map_config_data_local; map_config_data_local_old = map_config_data_local;
@ -437,13 +423,13 @@ void MainWindow::save_local_cfg() {
lblWarning->set_text(gettext("Nothing to save!")); lblWarning->set_text(gettext("Nothing to save!"));
} }
else { else {
string cmd_zone = "ubconfig --target system set clock ZONE="; string cmd_zone = set_system_ZONE;
string cmd_default = "ubconfig --target system set network NTPSERVERS=default"; string cmd_default = set_system_NTPSERVERS_default;
string cmd_dhcp = "ubconfig --target system set network NTPSERVERS=dhcp"; string cmd_dhcp = set_system_NTPSERVERS_dhcp;
string cmd_set_ntp = "ubconfig --target system set network NTPSERVERS=\""; string cmd_set_ntp = set_system_NTPSERVERS;
string remove_ntp = "ubconfig --target system remove network NTPSERVERS"; string remove_ntp = remove_system_NTPSERVERS;
string local = "ubconfig --target system set clock HWCLOCK_SYNC=localtime"; string local = set_system_HWCLOCK_SYNC_localtime;
string hw = "ubconfig --target system set clock HWCLOCK_SYNC=utc"; string hw = set_system_HWCLOCK_SYNC_utc;
if ((this->check_config("region", 0) == false || this->check_config("zone", 0) == false)) { if ((this->check_config("region", 0) == false || this->check_config("zone", 0) == false)) {
this->enter_zone(cmd_zone); this->enter_zone(cmd_zone);
} }
@ -466,13 +452,13 @@ void MainWindow::save_global_cfg() {
lblWarning->set_text(gettext("Nothing to save!")); lblWarning->set_text(gettext("Nothing to save!"));
} }
else { else {
string cmd = "ubconfig --target global set clock ZONE="; string cmd = set_global_ZONE;
string cmd_default = "ubconfig --target global set network NTPSERVERS=default"; string cmd_default = set_global_NTPSERVERS_default;
string cmd_dhcp = "ubconfig --target global set network NTPSERVERS=dhcp"; string cmd_dhcp = set_global_NTPSERVERS_dhcp;
string cmd_set_ntp = "ubconfig --target global set network NTPSERVERS=\""; string cmd_set_ntp = set_global_NTPSERVERS;
string remove_ntp = "ubconfig --target global remove network NTPSERVERS"; string remove_ntp = remove_global_NTPSERVERS;
string local = "ubconfig --target global set clock HWCLOCK_SYNC=localtime"; string local = set_global_HWCLOCK_SYNC_localtime;
string hw = "ubconfig --target global set clock HWCLOCK_SYNC=utc"; string hw = set_global_HWCLOCK_SYNC_utc;
if ((this->check_config("region", 1) == false || this->check_config("zone", 1) == false)) { if ((this->check_config("region", 1) == false || this->check_config("zone", 1) == false)) {
this->enter_zone(cmd); this->enter_zone(cmd);
} }
@ -510,46 +496,46 @@ void MainWindow::save_global_local_cfg() {
if (flag_global == false) {} if (flag_global == false) {}
if ((this->check_config("region", 0) == false || this->check_config("zone", 0) == false)) { if ((this->check_config("region", 0) == false || this->check_config("zone", 0) == false)) {
if (flag_local == false) { if (flag_local == false) {
cmd_zone = "ubconfig --target system set clock ZONE="; cmd_zone = set_system_ZONE;
this->enter_zone(cmd_zone); this->enter_zone(cmd_zone);
} }
} }
if ((this->check_config("region", 1) == false || this->check_config("zone", 1) == false)) { if ((this->check_config("region", 1) == false || this->check_config("zone", 1) == false)) {
if (flag_global == false) { if (flag_global == false) {
cmd_zone = "ubconfig --target global set clock ZONE="; cmd_zone = set_global_ZONE;
this->enter_zone(cmd_zone); this->enter_zone(cmd_zone);
} }
} }
if (this->check_config("dhcp", 0) == false) { if (this->check_config("dhcp", 0) == false) {
if (flag_local == false) { if (flag_local == false) {
cmd_default = "ubconfig --target system set network NTPSERVERS=default"; cmd_default = set_system_NTPSERVERS_default;
cmd_dhcp = "ubconfig --target system set network NTPSERVERS=dhcp"; cmd_dhcp = set_system_NTPSERVERS_dhcp;
cmd_set_ntp = "ubconfig --target system set network NTPSERVERS=\""; cmd_set_ntp = set_system_NTPSERVERS;
remove_ntp = "ubconfig --target system remove network NTPSERVERS"; remove_ntp = remove_system_NTPSERVERS;
this->save_Dhcp(cmd_default, cmd_dhcp, remove_ntp, cmd_set_ntp); this->save_Dhcp(cmd_default, cmd_dhcp, remove_ntp, cmd_set_ntp);
} }
} }
if (this->check_config("dhcp", 1) == false) { if (this->check_config("dhcp", 1) == false) {
if (flag_global == false) { if (flag_global == false) {
cmd_default = "ubconfig --target global set network NTPSERVERS=default"; cmd_default = set_global_NTPSERVERS_default;
cmd_dhcp = "ubconfig --target global set network NTPSERVERS=dhcp"; cmd_dhcp = set_global_NTPSERVERS_dhcp;
cmd_set_ntp = "ubconfig --target global set network NTPSERVERS=\""; cmd_set_ntp = set_global_NTPSERVERS;
remove_ntp = "ubconfig --target global remove network NTPSERVERS"; remove_ntp = remove_global_NTPSERVERS;
this->save_Dhcp(cmd_default, cmd_dhcp, remove_ntp, cmd_set_ntp); this->save_Dhcp(cmd_default, cmd_dhcp, remove_ntp, cmd_set_ntp);
} }
} }
if (this->check_config("hw", 0) == false) { if (this->check_config("hw", 0) == false) {
if (flag_local == false) { if (flag_local == false) {
local = "ubconfig --target system set clock HWCLOCK_SYNC=localtime"; local = set_system_HWCLOCK_SYNC_localtime;
hw = "ubconfig --target system set clock HWCLOCK_SYNC=utc"; hw = set_system_HWCLOCK_SYNC_utc;
this->set_hardware_clock(local, hw); this->set_hardware_clock(local, hw);
} }
} }
if (this->check_config("hw", 1) == false) { if (this->check_config("hw", 1) == false) {
if (flag_global == false) { if (flag_global == false) {
local = "ubconfig --target global set clock HWCLOCK_SYNC=localtime"; local = set_global_HWCLOCK_SYNC_localtime;
hw = "ubconfig --target global set clock HWCLOCK_SYNC=utc"; hw = set_global_HWCLOCK_SYNC_utc;
this->set_hardware_clock(local, hw); this->set_hardware_clock(local, hw);
} }
} }
@ -668,7 +654,7 @@ bool MainWindow::check_config(string key, int key_save) {
return false; return false;
} }
string MainWindow::get_ubconfig_value(string &cmd){ string MainWindow::get_ubconfig_value(string cmd){
struct Result<string> obj_result = this->wrapper_call(cmd); struct Result<string> obj_result = this->wrapper_call(cmd);
if (obj_result.error == 0) { if (obj_result.error == 0) {
return obj_result.response; return obj_result.response;
@ -735,6 +721,7 @@ void MainWindow::info_warning_error(int mess) {
void MainWindow::wrapper_system(string cmd, string thread_str = "") { void MainWindow::wrapper_system(string cmd, string thread_str = "") {
string cmd_new = cmd + " " + thread_str; string cmd_new = cmd + " " + thread_str;
cout << cmd_new << endl;
int response_cmd = system(cmd_new.c_str()); int response_cmd = system(cmd_new.c_str());
if (response_cmd != 0) { if (response_cmd != 0) {
error_info += 1; error_info += 1;
@ -772,7 +759,7 @@ void MainWindow::set_hardware_clock(string &local, string &etc) {
} }
} }
void MainWindow::get_hardware_clock(string &cmd) { void MainWindow::get_hardware_clock(string cmd) {
int error = warning_info; int error = warning_info;
struct Result<string> obj_result = this->wrapper_call(cmd); struct Result<string> obj_result = this->wrapper_call(cmd);
if (obj_result.error == 0) { if (obj_result.error == 0) {
@ -810,7 +797,7 @@ void MainWindow::get_hardware_clock(string &cmd) {
void MainWindow::hardware_clock() { void MainWindow::hardware_clock() {
int error_hw = error_info; int error_hw = error_info;
string cmd = "hwclock --systohc"; string cmd = set_hwclock;
wrapper_system(cmd); wrapper_system(cmd);
if (error_hw != error_info){ if (error_hw != error_info){
lblWarning->set_text(gettext("Hardware clock synchronization error")); lblWarning->set_text(gettext("Hardware clock synchronization error"));
@ -1009,10 +996,10 @@ void MainWindow::event_entry_cbDhcp() {
txtNtpServer->grab_focus(); txtNtpServer->grab_focus();
string cmd = ""; string cmd = "";
if (flag_load == false) { if (flag_load == false) {
cmd = "ubconfig --default --source system get network NTPSERVERS"; cmd = get_system_NTPSERVERS;
} }
else{ else{
cmd = "ubconfig --default --source global get network NTPSERVERS"; cmd = get_global_NTPSERVERS;
} }
string response = this->get_ubconfig_value(cmd); string response = this->get_ubconfig_value(cmd);
if (response != "dhcp" && response != "default") { if (response != "dhcp" && response != "default") {
@ -1177,7 +1164,7 @@ void MainWindow::calendar_show() {
popCalendar->show(); popCalendar->show();
} }
void MainWindow::fill_in_reg_zone(string &cmd) { void MainWindow::fill_in_reg_zone(string cmd) {
int error = warning_info; int error = warning_info;
struct Result<string> obj_result_1 = this->wrapper_call(cmd); struct Result<string> obj_result_1 = this->wrapper_call(cmd);
if (obj_result_1.error== 0) { if (obj_result_1.error== 0) {

@ -17,7 +17,9 @@
#include <unicode/calendar.h> #include <unicode/calendar.h>
#include <map> #include <map>
#include <pwd.h> #include <pwd.h>
#include <webkit2/webkit2.h>
#include "ubl-util-standard.c" #include "ubl-util-standard.c"
#include "my_cmd.h"
using namespace std; using namespace std;
@ -115,6 +117,10 @@ class MainWindow : public Gtk::ApplicationWindow {
Gtk::Image *imgSettings; Gtk::Image *imgSettings;
Gtk::Overlay *overHead; Gtk::Overlay *overHead;
Gtk::Image *imgHeadBackground; Gtk::Image *imgHeadBackground;
Gtk::Window *wndWeb;
Gtk::Label *lblHeadeWndWeb;
Gtk::Widget *three;
WebKitWebView * one;
string array_hw[2]; string array_hw[2];
string array_hw_local[2]; string array_hw_local[2];
bool flag_load = false; bool flag_load = false;
@ -160,9 +166,9 @@ class MainWindow : public Gtk::ApplicationWindow {
void set_hardware_clock(string &local, string &etc); void set_hardware_clock(string &local, string &etc);
void info_warning_error(int mess); void info_warning_error(int mess);
void synopsis_show(); void synopsis_show();
void get_hardware_clock(string &cmd); void get_hardware_clock(string cmd);
void save_global_local_cfg(); void save_global_local_cfg();
void fill_in_reg_zone(string &cmd); void fill_in_reg_zone(string cmd);
void load_globl_cfg(); void load_globl_cfg();
void save_local_cfg(); void save_local_cfg();
void event_zone(); void event_zone();
@ -170,7 +176,7 @@ class MainWindow : public Gtk::ApplicationWindow {
bool check_config(string key, int key_save); bool check_config(string key, int key_save);
void event_log_hw(); void event_log_hw();
void write_config(string data, string key); void write_config(string data, string key);
string get_ubconfig_value(string &cmd); string get_ubconfig_value(string cmd);
void save_global_cfg(); void save_global_cfg();
void save_Dhcp(string &cmd_default, string &cmd_dhcp, string &remove, string &cmd_set_ntp); void save_Dhcp(string &cmd_default, string &cmd_dhcp, string &remove, string &cmd_set_ntp);
void load_local_cfg(); void load_local_cfg();

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 --> <!-- Generated with glade 3.40.0 -->
<interface> <interface>
<requires lib="gtk+" version="3.24"/> <requires lib="gtk+" version="3.24"/>
<object class="GtkWindow"> <object class="GtkWindow">
@ -1379,4 +1379,37 @@ Format: DD.MM.YYYY</property>
</object> </object>
</child> </child>
</object> </object>
<object class="GtkWindow" id="wndWeb">
<property name="width-request">800</property>
<property name="height-request">600</property>
<property name="can-focus">False</property>
<property name="valign">start</property>
<property name="icon-name">com.ublinux.ubl-settings-datetime</property>
<child>
<placeholder/>
</child>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="show-close-button">True</property>
<child type="title">
<object class="GtkLabel" id="lblHeadeWndWeb">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">ubl-settings-datetime</property>
</object>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">32</property>
<property name="icon-name">com.ublinux.ubl-settings-datetime</property>
<property name="icon_size">5</property>
</object>
</child>
</object>
</child>
</object>
</interface> </interface>

Loading…
Cancel
Save