|
|
|
|
@ -15,9 +15,11 @@ int socket_ext_id_I = 0;
|
|
|
|
|
int socket_trd_id_I = 0;
|
|
|
|
|
string version_application = "2.1";
|
|
|
|
|
MainWindow* obj_main;
|
|
|
|
|
void wrapper_synopsis_show() {
|
|
|
|
|
void wrapper_help_show(GtkWidget *self, char* link, gpointer user_data) {
|
|
|
|
|
if (self && user_data) {}
|
|
|
|
|
obj_main->global_lick_doc = link;
|
|
|
|
|
obj_main->aboutWindows->hide();
|
|
|
|
|
obj_main->synopsis_show();
|
|
|
|
|
obj_main->temp_help_show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help)
|
|
|
|
|
@ -300,7 +302,7 @@ void MainWindow::get_builder() {
|
|
|
|
|
builder->get_widget("btnSave", btnSave);
|
|
|
|
|
builder->get_widget("btnSettings", btnSettings);
|
|
|
|
|
builder->get_widget("btnLoad", btnLoad);
|
|
|
|
|
builder->get_widget("btnSynopsis", btnSynopsis);
|
|
|
|
|
builder->get_widget("btnhelp", btnhelp);
|
|
|
|
|
builder->get_widget("btnAbout", btnAbout);
|
|
|
|
|
builder->get_widget("btnLoadLocal", btnLoadLocal);
|
|
|
|
|
builder->get_widget("btnLoadGlob", btnLoadGlob);
|
|
|
|
|
@ -340,11 +342,11 @@ void MainWindow::get_builder() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::event() {
|
|
|
|
|
g_signal_connect(G_OBJECT(aboutWindows->gobj()), "activate-link", G_CALLBACK(wrapper_synopsis_show), this);
|
|
|
|
|
g_signal_connect(G_OBJECT(aboutWindows->gobj()), "activate-link", G_CALLBACK(wrapper_help_show), this);
|
|
|
|
|
btnCancelHelp->signal_clicked().connect([&]() {wndShowWeb->hide();});
|
|
|
|
|
chkAlwaysOpenHelp->signal_toggled().connect([&]() {flag_open_browser = true;});
|
|
|
|
|
btnReadHelp->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::open_browser));
|
|
|
|
|
btnSynopsis->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::synopsis_show));
|
|
|
|
|
btnhelp->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::open_help));
|
|
|
|
|
btnHardwareTime->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::hardware_clock));
|
|
|
|
|
btnMessClose->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::gui_mess_close));
|
|
|
|
|
//cldrDate->signal_day_selected().connect(sigc::mem_fun(*this, &MainWindow::get_calendar));
|
|
|
|
|
@ -354,7 +356,7 @@ void MainWindow::event() {
|
|
|
|
|
cbRegion->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::append_zone));
|
|
|
|
|
cldrDate->signal_day_selected_double_click().connect(sigc::mem_fun(*this, &MainWindow::get_calendar));
|
|
|
|
|
btnAbout->signal_activate().connect([&]() {aboutWindows->show();});
|
|
|
|
|
btnSynopsis->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::synopsis_show));
|
|
|
|
|
btnhelp->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::open_help));
|
|
|
|
|
btnLoadLocal->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::load_local_cfg));
|
|
|
|
|
btnLoadGlob->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::load_globl_cfg));
|
|
|
|
|
btnSaveLocalGlob->signal_activate().connect([&]() {save_global_local_cfg();});
|
|
|
|
|
@ -411,7 +413,7 @@ void MainWindow::event_zone() {
|
|
|
|
|
this->write_config(zone_text, "zone");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::synopsis_show() {
|
|
|
|
|
void MainWindow::temp_help_show() {
|
|
|
|
|
if (flag_open_browser == true) {
|
|
|
|
|
this->open_browser();
|
|
|
|
|
}
|
|
|
|
|
@ -421,26 +423,31 @@ void MainWindow::synopsis_show() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::open_help() {
|
|
|
|
|
global_lick_doc = const_link_doc;
|
|
|
|
|
temp_help_show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::open_browser() {
|
|
|
|
|
#ifdef WEBKIT_FOUND
|
|
|
|
|
webkit_web_view_load_uri(one, link_doc);
|
|
|
|
|
webkit_web_view_load_uri(one, _(global_lick_doc.c_str()));
|
|
|
|
|
wndWeb->show_all();
|
|
|
|
|
#else
|
|
|
|
|
this->template_open_browser();
|
|
|
|
|
this->template_open_browser(global_lick_doc);
|
|
|
|
|
#endif
|
|
|
|
|
wndShowWeb->hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::template_open_browser() {
|
|
|
|
|
string cmd = cmd_xdg + string(_(link_doc)) + " &";
|
|
|
|
|
void MainWindow::template_open_browser(string link_doc) {
|
|
|
|
|
string cmd = cmd_xdg + string(_(link_doc.c_str())) + " &";
|
|
|
|
|
string buf = "";
|
|
|
|
|
if (geteuid() == 0) {
|
|
|
|
|
string response_user = getlogin();
|
|
|
|
|
int size_s = std::snprintf(nullptr, 0, cmd_execute, response_user.c_str(), cmd.c_str()) + 1;
|
|
|
|
|
auto size = static_cast<size_t>(size_s);
|
|
|
|
|
std::unique_ptr<char[]> buf(new char[ size ]);
|
|
|
|
|
std::snprintf( buf.get(), size, cmd_execute, response_user.c_str(), cmd.c_str() );
|
|
|
|
|
cmd = std::string( buf.get(), buf.get() + size - 1 );
|
|
|
|
|
std::snprintf(buf.get(), size, cmd_execute, response_user.c_str(), cmd.c_str());
|
|
|
|
|
cmd = string(buf.get(), buf.get() + size - 1);
|
|
|
|
|
}
|
|
|
|
|
index_error = system(cmd.c_str());
|
|
|
|
|
}
|
|
|
|
|
@ -843,7 +850,7 @@ bool MainWindow::focus_ntp_text() {
|
|
|
|
|
bool flag_error = false;
|
|
|
|
|
bool flag_error_check_ntp = false;
|
|
|
|
|
string str_ntp = txtNtpServer->get_text();
|
|
|
|
|
flag_error_check_ntp = this->check_ntp(str_ntp);
|
|
|
|
|
flag_error_check_ntp = this->wrapper_check_ntp(str_ntp);
|
|
|
|
|
for (const auto &simvol: array_simvol) {
|
|
|
|
|
if (str_ntp.find(simvol) != std::string::npos) {
|
|
|
|
|
flag_error= true;
|
|
|
|
|
@ -886,19 +893,35 @@ vector<int> MainWindow::find_all(string &str_ntp, string substr) {
|
|
|
|
|
return sub_index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MainWindow::check_ntp(string &str_ntp) {
|
|
|
|
|
vector<int> sub_index = this->find_all(str_ntp, ".");
|
|
|
|
|
if (sub_index.size() == 1) {
|
|
|
|
|
int index_point = sub_index[0];
|
|
|
|
|
int len_str_ntp = str_ntp.length();
|
|
|
|
|
if (((len_str_ntp-index_point) >= 2) && (index_point > 2)) {
|
|
|
|
|
return false;
|
|
|
|
|
bool MainWindow::check_is_num_ntp(string &str_ntp) {
|
|
|
|
|
int code_ascii = 0;
|
|
|
|
|
bool flag_is_num = false;
|
|
|
|
|
for (size_t index = 0; index < str_ntp.length(); index++) {
|
|
|
|
|
code_ascii = static_cast<int>(str_ntp[index]);
|
|
|
|
|
if (code_ascii >= 48 && code_ascii <= 57 ) {
|
|
|
|
|
flag_is_num = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return flag_is_num;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MainWindow::check_is_string_ntp(string &str_ntp) {
|
|
|
|
|
int code_ascii = 0;
|
|
|
|
|
bool flag_is_str = false;
|
|
|
|
|
for (size_t index = 0; index < str_ntp.length(); index++) {
|
|
|
|
|
code_ascii = static_cast<int>(str_ntp[index]);
|
|
|
|
|
if ((code_ascii >= 65 && code_ascii <= 90) || (code_ascii >= 97 && code_ascii <= 122)) {
|
|
|
|
|
flag_is_str = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (sub_index.size() == 3) {
|
|
|
|
|
return flag_is_str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MainWindow::validate_ip_address(string &str_ntp) {
|
|
|
|
|
vector<int> sub_index = this->find_all(str_ntp, ".");
|
|
|
|
|
if (sub_index.size() == 3) {
|
|
|
|
|
int index_str_ntp = sub_index[0];
|
|
|
|
|
int index_str_ntp_1 = sub_index[1];
|
|
|
|
|
int index_str_ntp_2 = sub_index[2];
|
|
|
|
|
@ -942,7 +965,60 @@ bool MainWindow::check_ntp(string &str_ntp) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MainWindow::validate_domen(string &str_ntp) {
|
|
|
|
|
vector<int> sub_index = this->find_all(str_ntp, ".");
|
|
|
|
|
if (sub_index.size() != 0) {
|
|
|
|
|
int index_point = sub_index[sub_index.size()-1];
|
|
|
|
|
int len_str_ntp = str_ntp.length();
|
|
|
|
|
if (((len_str_ntp-index_point) >= 2) && (index_point > 2)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MainWindow::check_ntp(string &str_ntp) {
|
|
|
|
|
bool flag_is_str = this->check_is_string_ntp(str_ntp);
|
|
|
|
|
bool flag_is_num = this->check_is_num_ntp(str_ntp);
|
|
|
|
|
if (flag_is_str) {
|
|
|
|
|
return this->validate_domen(str_ntp);
|
|
|
|
|
}
|
|
|
|
|
else if (flag_is_str && flag_is_num == false) {
|
|
|
|
|
return this->validate_ip_address(str_ntp);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MainWindow::wrapper_check_ntp(string &str_ntp) {
|
|
|
|
|
bool flag_check_error_ntp = false;
|
|
|
|
|
if (str_ntp.find(",") != string::npos) {
|
|
|
|
|
vector<string> vec_ntp = split(str_ntp, ',');
|
|
|
|
|
for (string& str_split_ntp: vec_ntp) {
|
|
|
|
|
if (str_split_ntp.length() == 0) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
flag_check_error_ntp = this->check_ntp(str_split_ntp);
|
|
|
|
|
if (flag_check_error_ntp) {
|
|
|
|
|
return flag_check_error_ntp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return this->check_ntp(str_ntp);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct MainWindow::Result<string> MainWindow::wrapper_call(string cmd) {
|
|
|
|
|
|