|
|
|
|
@ -55,6 +55,32 @@ MainWindow::MainWindow(Glib::RefPtr<Gtk::Builder> const& builder) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::settings() {
|
|
|
|
|
map_error["xdg-open https://wiki.ublinux.ru/ru/home"] = string(_(" : xdg-open"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --default --source system get clock ZONE"] = string(_(" : Time Zone"));
|
|
|
|
|
map_error["hwclock --systohc"] = string(_(" : Hardware time"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --default --source system get network NTPSERVERS"] = string(_(" : NTP"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --source=default get NTPSERVERS_DEFAULT"] = string(_(" : NTP"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --default --source system get clock HWCLOCK_SYNC"] = string(_(" : Hardware time"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --default --source global get network NTPSERVERS"] = string(_(" : NTP"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --default --source global get clock ZONE"] = string(_(" : Time Zone"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --default --source global get clock HWCLOCK_SYNC"] = string(_(" : Hardware time"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --source global get clock HWCLOCK_SYNC"] = string(_(" : Hardware time"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --target system set clock ZONE="] = string(_(" : Time Zone"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --target system set network NTPSERVERS=default"] = string(_(" : NTP"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --target system set network NTPSERVERS=dhcp"] = string(_(" : NTP"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --target system set network NTPSERVERS=\""] = string(_(" : NTP"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --target system remove network NTPSERVERS"] = string(_(" : NTP"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --target system set clock HWCLOCK_SYNC=localtime"] = string(_(" : Hardware time"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --target system set clock HWCLOCK_SYNC=utc"] = string(_(" : Hardware time"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --target global set clock ZONE="] = string(_(" : Time Zone"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --target global set network NTPSERVERS=default"] = string(_(" : NTP"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --target global set network NTPSERVERS=dhcp"] = string(_(" : NTP"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --target global set network NTPSERVERS=\""] = string(_(" : NTP"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --target global remove network NTPSERVERS"] = string(_(" : NTP"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --target global set clock HWCLOCK_SYNC=localtime"] = string(_(" : Hardware time"));
|
|
|
|
|
map_error["/usr/bin/ubconfig --target global set clock HWCLOCK_SYNC=utc"] = string(_(" : Hardware time"));
|
|
|
|
|
map_error["date +%Y%m%d -s \""] = string(_(" : Date"));
|
|
|
|
|
map_error["date +%T -s \""] = "";
|
|
|
|
|
this->get_builder();
|
|
|
|
|
this->add_CSS();
|
|
|
|
|
ubl_make_plugs(boxSave,boxButton, socket_ext_id_I, socket_trd_id_I);
|
|
|
|
|
@ -72,7 +98,7 @@ void MainWindow::settings() {
|
|
|
|
|
btnBoxAboutDialog->set_visible(false);
|
|
|
|
|
this->event();
|
|
|
|
|
this->parse_text_date();
|
|
|
|
|
this->download_local_cfg();
|
|
|
|
|
this->download_local_cfg();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
lblHW->set_sensitive(false);
|
|
|
|
|
@ -182,7 +208,6 @@ void MainWindow::flag_block_gui() {
|
|
|
|
|
if (flag_save_global == true) {
|
|
|
|
|
btnSaveGlob->set_sensitive(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::add_CSS() {
|
|
|
|
|
@ -335,7 +360,7 @@ void MainWindow::download_globl_cfg() {
|
|
|
|
|
this->entry_dhcp_mess(cmd_get_dhcp, cmd_default_get_dhcp);
|
|
|
|
|
string cmd_zone = "/usr/bin/ubconfig --default --source global get clock ZONE";
|
|
|
|
|
this->fill_in_reg_zone(cmd_zone);
|
|
|
|
|
string hw = "/usr/bin/ubconfig --default --source global get clock HWCLOCK_SYNC";
|
|
|
|
|
string hw = "/usr/bin/ubconfig --source global get clock HWCLOCK_SYNC";
|
|
|
|
|
string hw_default = "/usr/bin/ubconfig --default --source global get clock HWCLOCK_SYNC";
|
|
|
|
|
this->entry_hardware_clock(hw, hw_default);
|
|
|
|
|
info_warning_error(1);
|
|
|
|
|
@ -386,45 +411,32 @@ 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<int> 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) {
|
|
|
|
|
mess_error = string(_("Local configuration reading error")) + " " + cmd_error;
|
|
|
|
|
mess_error = string(_("Local configuration reading error")) + cmd_error;
|
|
|
|
|
lblWarning->set_text(mess_error);
|
|
|
|
|
}
|
|
|
|
|
else if (mess == 1) {
|
|
|
|
|
mess_error = string(_("Global configuration read error")) + " " + cmd_error;
|
|
|
|
|
mess_error = string(_("Global configuration read error")) + cmd_error;
|
|
|
|
|
lblWarning->set_text(mess_error);
|
|
|
|
|
}
|
|
|
|
|
else if (mess == 2) {
|
|
|
|
|
mess_error = string(_("Local configuration write error")) + " " + cmd_error;
|
|
|
|
|
mess_error = string(_("Local configuration write error")) + cmd_error;
|
|
|
|
|
lblWarning->set_text(mess_error);
|
|
|
|
|
}
|
|
|
|
|
else if (mess == 3) {
|
|
|
|
|
mess_error = string(_("Global configuration write error")) + " " + cmd_error;
|
|
|
|
|
mess_error = string(_("Global configuration write error")) + cmd_error;
|
|
|
|
|
lblWarning->set_text(mess_error);
|
|
|
|
|
}
|
|
|
|
|
else if (mess == 4) {
|
|
|
|
|
mess_error = string(_("Error saved local and global configuration")) + " " + cmd_error;
|
|
|
|
|
mess_error = string(_("Error saved local and global configuration")) + cmd_error;
|
|
|
|
|
lblWarning->set_text(mess_error);
|
|
|
|
|
}
|
|
|
|
|
cmd_error = "";
|
|
|
|
|
cmd_error_write = "";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
info_status_app("boxInfoMessOK");
|
|
|
|
|
@ -449,11 +461,27 @@ void MainWindow::info_warning_error(int mess) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::wrapper_system(string cmd, string thread_str = "") {
|
|
|
|
|
cmd = cmd + " " + thread_str;
|
|
|
|
|
int response_cmd = system(cmd.c_str());
|
|
|
|
|
string cmd_new = cmd + " " + thread_str;
|
|
|
|
|
int response_cmd = system(cmd_new.c_str());
|
|
|
|
|
if (response_cmd != 0) {
|
|
|
|
|
error_info += 1;
|
|
|
|
|
cmd_error_write = cmd;
|
|
|
|
|
this->log_mess_error(cmd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::log_mess_error(string &cmd){
|
|
|
|
|
string key = "";
|
|
|
|
|
if (map_error.find(cmd) != map_error.end()){
|
|
|
|
|
cmd_error = map_error[cmd];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for ( const auto &map_iter: map_error ) {
|
|
|
|
|
key = map_iter.first;
|
|
|
|
|
if (cmd.find(key) != std::string::npos){
|
|
|
|
|
cmd_error = map_iter.second;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -649,7 +677,7 @@ struct MainWindow::Result<string> MainWindow::wrapper_call(string cmd) {
|
|
|
|
|
obj_result.response = response;
|
|
|
|
|
obj_result.error = 1;
|
|
|
|
|
warning_info += 1;
|
|
|
|
|
cmd_error = cmd;
|
|
|
|
|
this->log_mess_error(cmd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
@ -657,6 +685,7 @@ struct MainWindow::Result<string> MainWindow::wrapper_call(string cmd) {
|
|
|
|
|
obj_result.error = 2;
|
|
|
|
|
warning_info += 1;
|
|
|
|
|
cmd_error = cmd;
|
|
|
|
|
this->log_mess_error(cmd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
@ -664,10 +693,13 @@ struct MainWindow::Result<string> MainWindow::wrapper_call(string cmd) {
|
|
|
|
|
obj_result.error = 3;
|
|
|
|
|
warning_info += 1;
|
|
|
|
|
cmd_error = cmd;
|
|
|
|
|
this->log_mess_error(cmd);
|
|
|
|
|
}
|
|
|
|
|
return obj_result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::event_entry_cbDhcp() {
|
|
|
|
|
string str_dhcp = cbDhcp->get_active_text();
|
|
|
|
|
string cmd = "";
|
|
|
|
|
|