diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index 1ac9386..1abc5f3 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -380,25 +380,45 @@ void MainWindow::save_global_local_cfg() { void MainWindow::info_warning_error(int mess) { if (error_info > 0 || warning_info > 0) { + if (cmd_error.length()!=0){ + vector vec_cmd_prob; + vec_cmd_prob = this->find_all(cmd_error, " "); + size_t size_vec_prob = vec_cmd_prob.size(); + if (size_vec_prob > 1){ + int index = size_vec_prob - 1; + index = vec_cmd_prob[index]; + if (index){ + cmd_error = cmd_error.substr(index, cmd_error.length()); + } + } + } info_status_app("boxInfoMessError"); imgInfo->set("warning.svg"); error_info = 0; warning_info = 0; + string mess_error = ""; if (mess == 0) { - lblWarning->set_text(_("Local configuration reading error")); + mess_error = _("Local configuration reading error") + cmd_error; + lblWarning->set_text(mess_error); } else if (mess == 1) { - lblWarning->set_text(_("Global configuration read error")); + mess_error = _("Global configuration read error") + cmd_error; + lblWarning->set_text(mess_error); } else if (mess == 2) { - lblWarning->set_text(_("Local configuration write error")); + mess_error = _("Local configuration write error") + cmd_error; + lblWarning->set_text(mess_error); } else if (mess == 3) { - lblWarning->set_text(_("Global configuration write error")); + mess_error = _("Global configuration write error") + cmd_error; + lblWarning->set_text(mess_error); } else if (mess == 4) { - lblWarning->set_text(_("Error saved local and global configuration")); + mess_error = _("Error saved local and global configuration") + cmd_error; + lblWarning->set_text(mess_error); } + cmd_error = ""; + cmd_error_write = ""; } else { info_status_app("boxInfoMessOK"); @@ -423,12 +443,12 @@ void MainWindow::info_warning_error(int mess) { void MainWindow::wrapper_system(string cmd, string thread_str = "") { - cmd=cmd + " " + thread_str; + cmd = cmd + " " + thread_str; int response_cmd = system(cmd.c_str()); - if (response_cmd!= 0) { - error_info+= 1; + if (response_cmd != 0) { + error_info += 1; + cmd_error_write = cmd; } - } void MainWindow::hardware_clock_global(string &local, string &etc) { @@ -610,7 +630,7 @@ bool MainWindow::check_ntp(string &str_ntp) { struct MainWindow::Result MainWindow::wrapper_call(string cmd) { struct Result obj_result; - string response=this->call(cmd); + string response = this->call(cmd); if ((response.find("(null)") == std::string::npos) && (response.length() != 0 )) { if (response.find("=") != std::string::npos) { if (response.find("\n") != std::string::npos) { @@ -622,19 +642,22 @@ struct MainWindow::Result MainWindow::wrapper_call(string cmd) { else { obj_result.response = response; obj_result.error = 1; - warning_info+= 1; + warning_info += 1; + cmd_error = cmd; } } else { obj_result.response = response; obj_result.error = 2; - warning_info+= 1; + warning_info += 1; + cmd_error = cmd; } } else { obj_result.response = response; obj_result.error = 3; - warning_info+= 1; + warning_info += 1; + cmd_error = cmd; } return obj_result; } @@ -998,6 +1021,7 @@ void MainWindow::append_zone() { void MainWindow::update_time_date() { string cmd = ""; + string response = ""; if ((year != 0) && (month != 0) && (day != 0)) { string str_month = ""; string str_day = ""; @@ -1045,22 +1069,24 @@ void MainWindow::update_time_date() { void MainWindow::post_entry_data() { string cmd = ""; - string data = txtDate->get_text(); - if (data.length() == 10) { - string str_day = data.substr(0,2); - string str_month = data.substr(3,2); - string str_year = data.substr(6,data.length()); - cmd = "date +%Y%m%d -s \"" + str_year+ - str_month+str_day+"\""; - string str_error_clock = this->call(cmd); - size_t index = str_error_clock.find("date: "); - if (index == std::string::npos) { - } - } - else { + string data = txtDate->get_text(); + if (data.length() == 10) { + string str_day = data.substr(0,2); + string str_month = data.substr(3,2); + string str_year = data.substr(6,data.length()); + cmd = "date +%Y%m%d -s \"" + str_year+ + str_month+str_day+"\""; + string str_error_clock = this->call(cmd); + size_t index = str_error_clock.find("date:"); + if (index != std::string::npos) { lblMessage->set_text(_("Incorrect date format")); - mess_dchp->show(); + mess_dchp->show(); } + } + else { + lblMessage->set_text(_("Incorrect date format")); + mess_dchp->show(); + } } void MainWindow::update_hour_minute() { diff --git a/source/ubl-settings-datetime.h b/source/ubl-settings-datetime.h index ce4b60e..a44284c 100755 --- a/source/ubl-settings-datetime.h +++ b/source/ubl-settings-datetime.h @@ -120,6 +120,8 @@ class MainWindow : public Gtk::ApplicationWindow { string version_application = "1.3"; int error_info = 0; int warning_info = 0; + string cmd_error = ""; + string cmd_error_write = ""; int hour; int minute; string str_region = "";