|
|
|
@ -104,6 +104,7 @@ void MainWindow::settings() {
|
|
|
|
this->flag_block_gui();
|
|
|
|
this->flag_block_gui();
|
|
|
|
this->event();
|
|
|
|
this->event();
|
|
|
|
this->parse_text_date();
|
|
|
|
this->parse_text_date();
|
|
|
|
|
|
|
|
this->load_globl_cfg();
|
|
|
|
this->load_local_cfg();
|
|
|
|
this->load_local_cfg();
|
|
|
|
string cmd = "ubconfig --source default get [] NTPSERVERS_DEFAULT";
|
|
|
|
string cmd = "ubconfig --source default get [] NTPSERVERS_DEFAULT";
|
|
|
|
default_get_dhcp = this->get_ubconfig_value(cmd);
|
|
|
|
default_get_dhcp = this->get_ubconfig_value(cmd);
|
|
|
|
@ -396,6 +397,7 @@ void MainWindow::synopsis_show() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::load_local_cfg() {
|
|
|
|
void MainWindow::load_local_cfg() {
|
|
|
|
|
|
|
|
flag_local_global_load = 0;
|
|
|
|
flag_load = false;
|
|
|
|
flag_load = false;
|
|
|
|
string cmd_zone = "ubconfig --default --source system get clock ZONE";
|
|
|
|
string cmd_zone = "ubconfig --default --source system get clock ZONE";
|
|
|
|
this->fill_in_reg_zone(cmd_zone);
|
|
|
|
this->fill_in_reg_zone(cmd_zone);
|
|
|
|
@ -407,12 +409,13 @@ void MainWindow::load_local_cfg() {
|
|
|
|
string hw = "ubconfig --default --source system get clock HWCLOCK_SYNC";
|
|
|
|
string hw = "ubconfig --default --source system get clock HWCLOCK_SYNC";
|
|
|
|
this->get_hardware_clock(hw);
|
|
|
|
this->get_hardware_clock(hw);
|
|
|
|
info_warning_error(0);
|
|
|
|
info_warning_error(0);
|
|
|
|
map_config_data_global_local_old = map_config_data_global_local;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
flag_local_global_load = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::load_globl_cfg() {
|
|
|
|
void MainWindow::load_globl_cfg() {
|
|
|
|
|
|
|
|
flag_local_global_load = 1;
|
|
|
|
flag_load = true;
|
|
|
|
flag_load = true;
|
|
|
|
string cmd_get_dhcp = "ubconfig --default --source global get network NTPSERVERS";
|
|
|
|
string cmd_get_dhcp = "ubconfig --default --source global get network NTPSERVERS";
|
|
|
|
string cmd_default_get_dhcp = "ubconfig --source default get [] NTPSERVERS_DEFAULT";
|
|
|
|
string cmd_default_get_dhcp = "ubconfig --source default get [] NTPSERVERS_DEFAULT";
|
|
|
|
@ -422,14 +425,15 @@ void MainWindow::load_globl_cfg() {
|
|
|
|
string hw = "ubconfig --source global get clock HWCLOCK_SYNC";
|
|
|
|
string hw = "ubconfig --source global get clock HWCLOCK_SYNC";
|
|
|
|
this->get_hardware_clock(hw);
|
|
|
|
this->get_hardware_clock(hw);
|
|
|
|
info_warning_error(1);
|
|
|
|
info_warning_error(1);
|
|
|
|
map_config_data_global_local_old = map_config_data_global_local;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
flag_local_global_load = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::save_local_cfg() {
|
|
|
|
void MainWindow::save_local_cfg() {
|
|
|
|
if ((this->check_config("region", 0) && this->check_config("zone", 0) &&
|
|
|
|
if ((this->check_config("region", 0) && this->check_config("zone", 0) &&
|
|
|
|
this->check_config("dhcp", 0) && this->check_config("hw", 0))) {
|
|
|
|
this->check_config("dhcp", 0) && this->check_config("hw", 0))) {
|
|
|
|
|
|
|
|
info_status_app("boxInfoMessOK");
|
|
|
|
lblWarning->set_text(gettext("Nothing to save!"));
|
|
|
|
lblWarning->set_text(gettext("Nothing to save!"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
@ -452,15 +456,13 @@ void MainWindow::save_local_cfg() {
|
|
|
|
info_warning_error(2);
|
|
|
|
info_warning_error(2);
|
|
|
|
map_config_data_local_old = map_config_data_local;
|
|
|
|
map_config_data_local_old = map_config_data_local;
|
|
|
|
flag_local = true;
|
|
|
|
flag_local = true;
|
|
|
|
if (flag_global and flag_local){
|
|
|
|
|
|
|
|
map_config_data_global_local_old = map_config_data_global_local;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::save_global_cfg() {
|
|
|
|
void MainWindow::save_global_cfg() {
|
|
|
|
if ((this->check_config("region", 1) && this->check_config("zone", 1) &&
|
|
|
|
if ((this->check_config("region", 1) && this->check_config("zone", 1) &&
|
|
|
|
this->check_config("dhcp", 1) && this->check_config("hw", 1))) {
|
|
|
|
this->check_config("dhcp", 1) && this->check_config("hw", 1))) {
|
|
|
|
|
|
|
|
info_status_app("boxInfoMessOK");
|
|
|
|
lblWarning->set_text(gettext("Nothing to save!"));
|
|
|
|
lblWarning->set_text(gettext("Nothing to save!"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
@ -483,14 +485,15 @@ void MainWindow::save_global_cfg() {
|
|
|
|
info_warning_error(3);
|
|
|
|
info_warning_error(3);
|
|
|
|
map_config_data_global_old = map_config_data_global;
|
|
|
|
map_config_data_global_old = map_config_data_global;
|
|
|
|
flag_global = true;
|
|
|
|
flag_global = true;
|
|
|
|
if (flag_global and flag_local){
|
|
|
|
|
|
|
|
map_config_data_global_local_old = map_config_data_global_local;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::save_global_local_cfg() {
|
|
|
|
void MainWindow::save_global_local_cfg() {
|
|
|
|
if ((this->check_config("region", 2) && this->check_config("zone", 2) &&
|
|
|
|
if ((this->check_config("region", 0) && this->check_config("zone", 0) &&
|
|
|
|
this->check_config("dhcp", 2) && this->check_config("hw", 2))) {
|
|
|
|
this->check_config("dhcp", 0) && this->check_config("hw", 0)) &&
|
|
|
|
|
|
|
|
(this->check_config("region", 1) && this->check_config("zone", 1) &&
|
|
|
|
|
|
|
|
this->check_config("dhcp", 1) && this->check_config("hw", 1))) {
|
|
|
|
|
|
|
|
info_status_app("boxInfoMessOK");
|
|
|
|
lblWarning->set_text(gettext("Nothing to save!"));
|
|
|
|
lblWarning->set_text(gettext("Nothing to save!"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
@ -503,17 +506,22 @@ void MainWindow::save_global_local_cfg() {
|
|
|
|
string hw = "";
|
|
|
|
string hw = "";
|
|
|
|
string remove_ntp = "";
|
|
|
|
string remove_ntp = "";
|
|
|
|
string cmd_zone = "";
|
|
|
|
string cmd_zone = "";
|
|
|
|
if ((this->check_config("region", 2) == false || this->check_config("zone", 2) == false)) {
|
|
|
|
if (flag_local == false) {}
|
|
|
|
|
|
|
|
if (flag_global == 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 = "ubconfig --target system set clock 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 (flag_global == false) {
|
|
|
|
if (flag_global == false) {
|
|
|
|
cmd_zone = "ubconfig --target global set clock ZONE=";
|
|
|
|
cmd_zone = "ubconfig --target global set clock ZONE=";
|
|
|
|
this->enter_zone(cmd_zone);
|
|
|
|
this->enter_zone(cmd_zone);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (this->check_config("dhcp", 2) == 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 = "ubconfig --target system set network NTPSERVERS=default";
|
|
|
|
cmd_dhcp = "ubconfig --target system set network NTPSERVERS=dhcp";
|
|
|
|
cmd_dhcp = "ubconfig --target system set network NTPSERVERS=dhcp";
|
|
|
|
@ -521,6 +529,8 @@ void MainWindow::save_global_local_cfg() {
|
|
|
|
remove_ntp = "ubconfig --target system remove network NTPSERVERS";
|
|
|
|
remove_ntp = "ubconfig --target system remove network 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 (flag_global == false) {
|
|
|
|
if (flag_global == false) {
|
|
|
|
cmd_default = "ubconfig --target global set network NTPSERVERS=default";
|
|
|
|
cmd_default = "ubconfig --target global set network NTPSERVERS=default";
|
|
|
|
cmd_dhcp = "ubconfig --target global set network NTPSERVERS=dhcp";
|
|
|
|
cmd_dhcp = "ubconfig --target global set network NTPSERVERS=dhcp";
|
|
|
|
@ -529,19 +539,20 @@ void MainWindow::save_global_local_cfg() {
|
|
|
|
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", 2) == 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 = "ubconfig --target system set clock HWCLOCK_SYNC=localtime";
|
|
|
|
hw = "ubconfig --target system set clock HWCLOCK_SYNC=utc";
|
|
|
|
hw = "ubconfig --target system set clock HWCLOCK_SYNC=utc";
|
|
|
|
this->set_hardware_clock(local, hw);
|
|
|
|
this->set_hardware_clock(local, hw);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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 = "ubconfig --target global set clock HWCLOCK_SYNC=localtime";
|
|
|
|
hw = "ubconfig --target global set clock HWCLOCK_SYNC=utc";
|
|
|
|
hw = "ubconfig --target global set clock HWCLOCK_SYNC=utc";
|
|
|
|
this->set_hardware_clock(local, hw);
|
|
|
|
this->set_hardware_clock(local, hw);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
map_config_data_global_local_old = map_config_data_global_local;
|
|
|
|
|
|
|
|
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;
|
|
|
|
info_warning_error(4);
|
|
|
|
info_warning_error(4);
|
|
|
|
@ -551,25 +562,37 @@ void MainWindow::save_global_local_cfg() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::write_config(string data, string key) {
|
|
|
|
void MainWindow::write_config(string data, string key) {
|
|
|
|
|
|
|
|
|
|
|
|
std::map <string, string>:: iterator it, it2, it3;
|
|
|
|
std::map <string, string>:: iterator it, it2, it3;
|
|
|
|
it3 = map_config_data_global_local.find(key);
|
|
|
|
|
|
|
|
it2 = map_config_data_global.find(key);
|
|
|
|
it2 = map_config_data_global.find(key);
|
|
|
|
it = map_config_data_local.find(key);
|
|
|
|
it = map_config_data_local.find(key);
|
|
|
|
if (it != map_config_data_local.end() || it2 != map_config_data_global.end() || it3 != map_config_data_global_local.end()) {
|
|
|
|
if (it != map_config_data_local.end() || it2 != map_config_data_global.end()) {
|
|
|
|
if (map_config_data_local[key] != data) {
|
|
|
|
if (flag_local_global_load == 2) {
|
|
|
|
map_config_data_global[key] = data;
|
|
|
|
map_config_data_global[key] = data;
|
|
|
|
map_config_data_local[key] = data;
|
|
|
|
map_config_data_local[key] = data;
|
|
|
|
map_config_data_global_local[key] = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (flag_local_global_load == 1) {
|
|
|
|
|
|
|
|
map_config_data_global[key] = data;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (flag_local_global_load == 0) {
|
|
|
|
|
|
|
|
map_config_data_local[key] = data;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
flag_local = false;
|
|
|
|
flag_local = false;
|
|
|
|
flag_global = false;
|
|
|
|
flag_global = false;
|
|
|
|
flag_global_local = false;
|
|
|
|
flag_global_local = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (it == map_config_data_local.end() || it2 == map_config_data_global.end() || it3 == map_config_data_global_local.end()) {
|
|
|
|
else if (it == map_config_data_local.end() || it2 == map_config_data_global.end()) {
|
|
|
|
map_config_data_global[key] = data;
|
|
|
|
if (flag_local_global_load == 2) {
|
|
|
|
map_config_data_local[key] = data;
|
|
|
|
map_config_data_global[key] = data;
|
|
|
|
map_config_data_global_local[key] = data;
|
|
|
|
map_config_data_local[key] = data;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (flag_local_global_load == 1) {
|
|
|
|
|
|
|
|
map_config_data_global[key] = data;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (flag_local_global_load == 0) {
|
|
|
|
|
|
|
|
map_config_data_local[key] = data;
|
|
|
|
|
|
|
|
}
|
|
|
|
flag_local = false;
|
|
|
|
flag_local = false;
|
|
|
|
flag_global = false;
|
|
|
|
flag_global = false;
|
|
|
|
flag_global_local = false;
|
|
|
|
flag_global_local = false;
|
|
|
|
@ -581,8 +604,21 @@ bool MainWindow::check_config(string key, int key_save) {
|
|
|
|
std::map <string, string>:: iterator iter_map_config_data_old;
|
|
|
|
std::map <string, string>:: iterator iter_map_config_data_old;
|
|
|
|
std::map <string, string> map_config_data;
|
|
|
|
std::map <string, string> map_config_data;
|
|
|
|
std::map <string, string> map_config_data_old;
|
|
|
|
std::map <string, string> map_config_data_old;
|
|
|
|
|
|
|
|
if (map_config_data_global.find(key) != map_config_data_global.end() &&
|
|
|
|
|
|
|
|
map_config_data_local.find(key) != map_config_data_local.end() &&
|
|
|
|
|
|
|
|
map_config_data_global_old.find(key) != map_config_data_global_old.end() &&
|
|
|
|
|
|
|
|
map_config_data_local_old.find(key) != map_config_data_local_old.end()) {
|
|
|
|
|
|
|
|
if (map_config_data_global[key] != map_config_data_local_old[key] ||
|
|
|
|
|
|
|
|
map_config_data_global_old[key] != map_config_data_local[key]) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (map_config_data_global[key] != map_config_data_local[key]) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((key_save == 0 || key_save == 1) && flag_global_local == true) {
|
|
|
|
if ((key_save == 0 || key_save == 1) && flag_global_local == true) {
|
|
|
|
map_config_data_global_local_old = map_config_data_global_local;
|
|
|
|
|
|
|
|
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;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
@ -609,14 +645,9 @@ bool MainWindow::check_config(string key, int key_save) {
|
|
|
|
map_config_data = map_config_data_global;
|
|
|
|
map_config_data = map_config_data_global;
|
|
|
|
map_config_data_old = map_config_data_global_old;
|
|
|
|
map_config_data_old = map_config_data_global_old;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key_save == 2) {
|
|
|
|
|
|
|
|
iter_map_config_data = map_config_data_global_local.find(key);
|
|
|
|
|
|
|
|
map_config_data = map_config_data_global_local;
|
|
|
|
|
|
|
|
map_config_data_old = map_config_data_global_local_old;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
iter_map_config_data = map_config_data.find(key);
|
|
|
|
iter_map_config_data = map_config_data.find(key);
|
|
|
|
iter_map_config_data_old = map_config_data_old.find(key);
|
|
|
|
iter_map_config_data_old = map_config_data_old.find(key);
|
|
|
|
if (iter_map_config_data == map_config_data.end()) {;
|
|
|
|
if (iter_map_config_data == map_config_data.end()) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (iter_map_config_data_old == map_config_data_old.end()) {
|
|
|
|
else if (iter_map_config_data_old == map_config_data_old.end()) {
|
|
|
|
@ -778,8 +809,17 @@ void MainWindow::get_hardware_clock(string &cmd) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::hardware_clock() {
|
|
|
|
void MainWindow::hardware_clock() {
|
|
|
|
|
|
|
|
int error_hw = error_info;
|
|
|
|
string cmd = "hwclock --systohc";
|
|
|
|
string cmd = "hwclock --systohc";
|
|
|
|
wrapper_system(cmd);
|
|
|
|
wrapper_system(cmd);
|
|
|
|
|
|
|
|
if (error_hw != error_info){
|
|
|
|
|
|
|
|
lblWarning->set_text(gettext("Hardware clock synchronization error"));
|
|
|
|
|
|
|
|
info_status_app("boxInfoMessError");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
lblWarning->set_text(gettext("Hardware clock successfully synchronized"));
|
|
|
|
|
|
|
|
info_status_app("boxInfoMessOK");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::gui_mess_close() {
|
|
|
|
void MainWindow::gui_mess_close() {
|
|
|
|
@ -788,8 +828,10 @@ void MainWindow::gui_mess_close() {
|
|
|
|
|
|
|
|
|
|
|
|
bool MainWindow::focus_ntp_text() {
|
|
|
|
bool MainWindow::focus_ntp_text() {
|
|
|
|
if (txtNtpServer->get_text() == "" || txtNtpServer->get_text() == " ") {
|
|
|
|
if (txtNtpServer->get_text() == "" || txtNtpServer->get_text() == " ") {
|
|
|
|
lblMessage->set_text(gettext("Enter DHCP!"));
|
|
|
|
lblWarning->set_text(gettext("Enter a list of NTP servers"));
|
|
|
|
windowMessDchp->show();
|
|
|
|
info_status_app("boxInfoMessError");
|
|
|
|
|
|
|
|
btnSave->set_sensitive(false);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
string cmd = "";
|
|
|
|
string cmd = "";
|
|
|
|
@ -810,20 +852,26 @@ bool MainWindow::focus_ntp_text() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((flag_error == false) && (flag_error_check_ntp == false)) {
|
|
|
|
if ((flag_error == false) && (flag_error_check_ntp == false)) {
|
|
|
|
this->write_config(str_ntp, "dhcp");
|
|
|
|
this->write_config(str_ntp, "dhcp");
|
|
|
|
|
|
|
|
lblWarning->set_text(gettext("NTP server name is correct"));
|
|
|
|
|
|
|
|
info_status_app("boxInfoMessOK");
|
|
|
|
|
|
|
|
btnSave->set_sensitive(true);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
if (flag_error == true) {
|
|
|
|
if (flag_error == true) {
|
|
|
|
lblMessage->set_text(gettext("An invalid character is entered"));
|
|
|
|
lblWarning->set_text(gettext("An invalid character is entered"));
|
|
|
|
windowMessDchp->show();
|
|
|
|
info_status_app("boxInfoMessError");
|
|
|
|
|
|
|
|
btnSave->set_sensitive(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (flag_error_check_ntp == true) {
|
|
|
|
else if (flag_error_check_ntp == true) {
|
|
|
|
lblMessage->set_text(gettext("Error in the ntp name"));
|
|
|
|
lblWarning->set_text(gettext("Error in the NTP server name"));
|
|
|
|
windowMessDchp->show();
|
|
|
|
info_status_app("boxInfoMessError");
|
|
|
|
|
|
|
|
btnSave->set_sensitive(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
btnSave->set_sensitive(true);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -935,6 +983,7 @@ struct MainWindow::Result<string> MainWindow::wrapper_call(string cmd) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::event_entry_cbDhcp() {
|
|
|
|
void MainWindow::event_entry_cbDhcp() {
|
|
|
|
|
|
|
|
btnSave->set_sensitive(true);
|
|
|
|
string str_dhcp = cbDhcp->get_active_text();
|
|
|
|
string str_dhcp = cbDhcp->get_active_text();
|
|
|
|
string cmd = "";
|
|
|
|
string cmd = "";
|
|
|
|
int activ_index = cbDhcp->get_active_row_number();
|
|
|
|
int activ_index = cbDhcp->get_active_row_number();
|
|
|
|
@ -1051,8 +1100,9 @@ void MainWindow::entry_dhcp_mess(string cmd_get_dhcp, string cmd_default_get_dhc
|
|
|
|
// btnUpdateDateTime->set_sensitive(false);
|
|
|
|
// btnUpdateDateTime->set_sensitive(false);
|
|
|
|
if (str_dhcp == "") {
|
|
|
|
if (str_dhcp == "") {
|
|
|
|
this->write_config("", "dhcp");
|
|
|
|
this->write_config("", "dhcp");
|
|
|
|
lblMessage->set_text(gettext("Enter DHCP!"));
|
|
|
|
lblWarning->set_text(gettext("Enter a list of NTP servers"));
|
|
|
|
windowMessDchp->show();
|
|
|
|
info_status_app("boxInfoMessError");
|
|
|
|
|
|
|
|
btnSave->set_sensitive(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (str_dhcp == "(null)") {
|
|
|
|
else if (str_dhcp == "(null)") {
|
|
|
|
cbDhcp->set_active(0);
|
|
|
|
cbDhcp->set_active(0);
|
|
|
|
@ -1340,12 +1390,13 @@ void MainWindow::append_zone() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::update_time_date() {
|
|
|
|
void MainWindow::update_time_date() {
|
|
|
|
|
|
|
|
bool flag_error_time = false;
|
|
|
|
string cmd = "";
|
|
|
|
string cmd = "";
|
|
|
|
string response = "";
|
|
|
|
string response = "";
|
|
|
|
if ((year != 0) && (month != 0) && (day != 0)) {
|
|
|
|
if (((year != 0) && (month != 0) && (day != 0))) {
|
|
|
|
string str_month = "";
|
|
|
|
string str_month = "";
|
|
|
|
string str_day = "";
|
|
|
|
string str_day = "";
|
|
|
|
month+= 2;
|
|
|
|
month += 2;
|
|
|
|
if (month < 10) {
|
|
|
|
if (month < 10) {
|
|
|
|
str_month = "0"+to_string(month);
|
|
|
|
str_month = "0"+to_string(month);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1369,25 +1420,39 @@ void MainWindow::update_time_date() {
|
|
|
|
year = 0;
|
|
|
|
year = 0;
|
|
|
|
month = 0;
|
|
|
|
month = 0;
|
|
|
|
day = 0;
|
|
|
|
day = 0;
|
|
|
|
|
|
|
|
lblWarning->set_text(gettext("Date and time are successfully synchronized"));
|
|
|
|
|
|
|
|
info_status_app("boxInfoMessOK");
|
|
|
|
|
|
|
|
flag_error_time = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
this->post_entry_data();
|
|
|
|
flag_error_time = this->post_entry_data();
|
|
|
|
|
|
|
|
year = 0;
|
|
|
|
|
|
|
|
month = 0;
|
|
|
|
|
|
|
|
day = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
this->post_entry_data();
|
|
|
|
flag_error_time = this->post_entry_data();
|
|
|
|
|
|
|
|
year = 0;
|
|
|
|
|
|
|
|
month = 0;
|
|
|
|
|
|
|
|
day = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
hour = numTimeHrs->get_value_as_int();
|
|
|
|
if (flag_error_time == false) {
|
|
|
|
minute = numTimeMin->get_value_as_int();
|
|
|
|
lblWarning->set_text(gettext("Date and time are successfully synchronized"));
|
|
|
|
time_t now = time(0);
|
|
|
|
info_status_app("boxInfoMessOK");
|
|
|
|
tm *ltm = localtime(&now);
|
|
|
|
hour = numTimeHrs->get_value_as_int();
|
|
|
|
cmd = "date +%T -s \"" +
|
|
|
|
minute = numTimeMin->get_value_as_int();
|
|
|
|
to_string(hour) + ":" + to_string(minute)
|
|
|
|
time_t now = time(0);
|
|
|
|
+ ":" + to_string(ltm->tm_sec) +"\"";
|
|
|
|
tm *ltm = localtime(&now);
|
|
|
|
wrapper_system(cmd);
|
|
|
|
cmd = "date +%T -s \"" +
|
|
|
|
|
|
|
|
to_string(hour) + ":" + to_string(minute)
|
|
|
|
|
|
|
|
+ ":" + to_string(ltm->tm_sec) +"\"";
|
|
|
|
|
|
|
|
wrapper_system(cmd);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::post_entry_data() {
|
|
|
|
bool MainWindow::post_entry_data() {
|
|
|
|
string cmd = "";
|
|
|
|
string cmd = "";
|
|
|
|
string data = txtDate->get_text();
|
|
|
|
string data = txtDate->get_text();
|
|
|
|
if (data.length() == 10) {
|
|
|
|
if (data.length() == 10) {
|
|
|
|
@ -1399,13 +1464,20 @@ void MainWindow::post_entry_data() {
|
|
|
|
string str_error_clock = this->call(cmd);
|
|
|
|
string str_error_clock = this->call(cmd);
|
|
|
|
size_t index = str_error_clock.find("date:");
|
|
|
|
size_t index = str_error_clock.find("date:");
|
|
|
|
if (index != std::string::npos) {
|
|
|
|
if (index != std::string::npos) {
|
|
|
|
lblMessage->set_text(gettext("Incorrect date format"));
|
|
|
|
lblWarning->set_text(gettext("Incorrect date format"));
|
|
|
|
windowMessDchp->show();
|
|
|
|
info_status_app("boxInfoMessError");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
lblWarning->set_text(gettext("Date and time are successfully synchronized"));
|
|
|
|
|
|
|
|
info_status_app("boxInfoMessOK");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
lblMessage->set_text(gettext("Incorrect date format"));
|
|
|
|
lblWarning->set_text(gettext("Incorrect date format"));
|
|
|
|
windowMessDchp->show();
|
|
|
|
info_status_app("boxInfoMessError");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|