|
|
|
|
@ -336,7 +336,7 @@ bool MainWindow::focus_ntp(GdkEventFocus* event){
|
|
|
|
|
}
|
|
|
|
|
if (flag_error==false){
|
|
|
|
|
cmd = "/usr/bin/ubconfig set network NTPSERVERS=\"" + str_ntp + "\"";
|
|
|
|
|
this->call(cmd.c_str());
|
|
|
|
|
response_cmd = system(cmd.c_str());
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
lblMessage->set_text(_("An invalid character is entered"));
|
|
|
|
|
@ -347,6 +347,34 @@ bool MainWindow::focus_ntp(GdkEventFocus* event){
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct MainWindow::Result<string> MainWindow::wrapper_call(string cmd){
|
|
|
|
|
struct Result<string> obj_result;
|
|
|
|
|
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){
|
|
|
|
|
response = response.substr(response.find("=")+1,response.length());
|
|
|
|
|
response = response.substr(0,response.find("\n"));
|
|
|
|
|
obj_result.response = response;
|
|
|
|
|
obj_result.error = 0;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
obj_result.response = response;
|
|
|
|
|
obj_result.error = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
obj_result.response = response;
|
|
|
|
|
obj_result.error = 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
obj_result.response = response;
|
|
|
|
|
obj_result.error = 3;
|
|
|
|
|
}
|
|
|
|
|
return obj_result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::event_entry_cbDhcp(){
|
|
|
|
|
Glib::ustring str_dhcp = cbDhcp->get_active_text();
|
|
|
|
|
int activ_index = cbDhcp->get_active_row_number();
|
|
|
|
|
@ -357,9 +385,17 @@ void MainWindow::event_entry_cbDhcp(){
|
|
|
|
|
response_cmd=system(cmd.c_str());
|
|
|
|
|
txtNtpServer->set_sensitive(false);
|
|
|
|
|
cbDhcp->set_active(activ_index);
|
|
|
|
|
string response = this->call("/usr/bin/ubconfig --source=default get NTPSERVERS_DEFAULT");
|
|
|
|
|
this->str_remove(response, "\n");
|
|
|
|
|
txtNtpServer->set_text(response);
|
|
|
|
|
cmd = "/usr/bin/ubconfig --source=default get NTPSERVERS_DEFAULT";
|
|
|
|
|
struct Result<string> obj_result = this->wrapper_call(cmd);
|
|
|
|
|
if (obj_result.error==0){
|
|
|
|
|
txtNtpServer->set_text(obj_result.response);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
//string error = "";
|
|
|
|
|
//error = string(_("ERROR")) + "\n" + obj_result.response;
|
|
|
|
|
//lblMessage->set_text(error);
|
|
|
|
|
//mess_dchp->show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (activ_index==1){
|
|
|
|
|
btnUpdateDateTime->set_sensitive(false);
|
|
|
|
|
@ -375,16 +411,24 @@ void MainWindow::event_entry_cbDhcp(){
|
|
|
|
|
if (txtNtpServer->get_text().find("default")!=std::string::npos){
|
|
|
|
|
txtNtpServer->set_text("");
|
|
|
|
|
}
|
|
|
|
|
string str_dhcp = this->call("/usr/bin/ubconfig get network NTPSERVERS");
|
|
|
|
|
if ((str_dhcp.find("(null)")==std::string::npos) && (str_dhcp.find("default")==std::string::npos)){
|
|
|
|
|
str_dhcp = str_dhcp.substr(str_dhcp.find("=")+1,str_dhcp.length());
|
|
|
|
|
str_dhcp = str_dhcp.substr(0,str_dhcp.find("\n"));
|
|
|
|
|
if (str_dhcp!="dhcp" && str_dhcp!="(null)"){
|
|
|
|
|
txtNtpServer->set_text(str_dhcp);
|
|
|
|
|
string cmd = "/usr/bin/ubconfig get network NTPSERVERS";
|
|
|
|
|
struct Result<string> obj_result = this->wrapper_call(cmd);
|
|
|
|
|
if (obj_result.error==0){
|
|
|
|
|
if (obj_result.response.find("default")==std::string::npos){
|
|
|
|
|
if (obj_result.response.find("dhcp")==std::string::npos){
|
|
|
|
|
txtNtpServer->set_text(obj_result.response);
|
|
|
|
|
}
|
|
|
|
|
cbDhcp->set_active(activ_index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (obj_result.error==3){}
|
|
|
|
|
else{
|
|
|
|
|
string error = "";
|
|
|
|
|
error = string(_("ERROR")) + "\n" + obj_result.response;
|
|
|
|
|
lblMessage->set_text(error);
|
|
|
|
|
mess_dchp->show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (activ_index==3){
|
|
|
|
|
string cmd = "/usr/bin/ubconfig remove network NTPSERVERS";
|
|
|
|
|
response_cmd=system(cmd.c_str());
|
|
|
|
|
@ -433,6 +477,7 @@ void MainWindow::get_calendar(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::calendar_show(){
|
|
|
|
|
cout << 2222 << endl;
|
|
|
|
|
if (year==0){
|
|
|
|
|
time_t now = time(0);
|
|
|
|
|
tm *ltm = localtime(&now);
|
|
|
|
|
@ -451,13 +496,14 @@ void MainWindow::calendar_show(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::enry_dhcp_mess(){
|
|
|
|
|
string str_dhcp = this->call("/usr/bin/ubconfig get network NTPSERVERS");
|
|
|
|
|
if (str_dhcp.find("(null)")==std::string::npos){
|
|
|
|
|
string cmd = "/usr/bin/ubconfig get network NTPSERVERS";
|
|
|
|
|
struct Result<string> obj_result = this->wrapper_call(cmd);
|
|
|
|
|
if (obj_result.error==0){
|
|
|
|
|
string str_dhcp = obj_result.response;
|
|
|
|
|
btnUpdateDateTime->set_sensitive(false);
|
|
|
|
|
str_dhcp = str_dhcp.substr(str_dhcp.find("=")+1,str_dhcp.length());
|
|
|
|
|
str_dhcp = str_dhcp.substr(0,str_dhcp.find("\n"));
|
|
|
|
|
if (str_dhcp=="dhcp"){
|
|
|
|
|
|
|
|
|
|
cbDhcp->set_active(1);
|
|
|
|
|
txtNtpServer->set_text("");
|
|
|
|
|
txtNtpServer->set_sensitive(false);
|
|
|
|
|
@ -465,10 +511,18 @@ void MainWindow::enry_dhcp_mess(){
|
|
|
|
|
else if (str_dhcp=="default"){
|
|
|
|
|
btnUpdateDateTime->set_sensitive(false);
|
|
|
|
|
cbDhcp->set_active(0);
|
|
|
|
|
string response = this->call("/usr/bin/ubconfig --source=default get NTPSERVERS_DEFAULT");
|
|
|
|
|
this->str_remove(response, "\n");
|
|
|
|
|
txtNtpServer->set_text(response);
|
|
|
|
|
string cmd = "/usr/bin/ubconfig --source=default get NTPSERVERS_DEFAULT";
|
|
|
|
|
struct Result<string> obj_result = this->wrapper_call(cmd);
|
|
|
|
|
txtNtpServer->set_sensitive(false);
|
|
|
|
|
if (obj_result.error==0){
|
|
|
|
|
txtNtpServer->set_text(obj_result.response);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
//string error = "";
|
|
|
|
|
//error = string(_("ERROR")) + "\n" + obj_result.response;
|
|
|
|
|
//lblMessage->set_text(error);
|
|
|
|
|
//mess_dchp->show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
btnUpdateDateTime->set_sensitive(false);
|
|
|
|
|
@ -500,21 +554,31 @@ void MainWindow::get_config(){
|
|
|
|
|
this->update_hour_minute();
|
|
|
|
|
this->update_calendar();
|
|
|
|
|
this->enry_dhcp_mess();
|
|
|
|
|
string read_reg_zon_cfg = this->call("/usr/bin/ubconfig --source global get clock ZONE");
|
|
|
|
|
if ((read_reg_zon_cfg != "") && (strstr(read_reg_zon_cfg.c_str() ,"(null)")==NULL)){
|
|
|
|
|
|
|
|
|
|
auto arr_reg_zone_glob = this->split_region_zone(read_reg_zon_cfg);
|
|
|
|
|
string cmd = "/usr/bin/ubconfig --source global get clock ZONE";
|
|
|
|
|
struct Result<string> obj_result = this->wrapper_call(cmd);
|
|
|
|
|
if (obj_result.error==0){
|
|
|
|
|
auto arr_reg_zone_glob = this->split_region_zone(obj_result.response);
|
|
|
|
|
if (arr_reg_zone_glob[0].length()!=0){
|
|
|
|
|
this->append_region_zone(arr_reg_zone_glob[0],arr_reg_zone_glob[1],cbRegionGlob,cbZoneGlob);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
this->append_region_zone("Africa","Abidjan", cbRegion, cbZone);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this->append_region_zone("Africa","Abidjan",cbRegionGlob,cbZoneGlob);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
read_reg_zon_cfg = this->call("/usr/bin/ubconfig --source system get clock ZONE");
|
|
|
|
|
if ((read_reg_zon_cfg != "") && (strstr(read_reg_zon_cfg.c_str() ,"(null)")==NULL)){
|
|
|
|
|
|
|
|
|
|
auto arr_reg_zone_glob = this->split_region_zone(read_reg_zon_cfg);
|
|
|
|
|
this->append_region_zone(arr_reg_zone_glob[0],arr_reg_zone_glob[1], cbRegion, cbZone);
|
|
|
|
|
cmd = "/usr/bin/ubconfig --source system get clock ZONE";
|
|
|
|
|
struct Result<string> obj_result_1 = this->wrapper_call(cmd);
|
|
|
|
|
if (obj_result_1.error==0){
|
|
|
|
|
auto arr_reg_zone = this->split_region_zone(obj_result_1.response);
|
|
|
|
|
if (arr_reg_zone[0].length()!=0){
|
|
|
|
|
this->append_region_zone(arr_reg_zone[0],arr_reg_zone[1], cbRegion, cbZone);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
this->append_region_zone("Africa","Abidjan", cbRegion, cbZone);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this->append_region_zone("Africa","Abidjan", cbRegion, cbZone);
|
|
|
|
|
@ -522,14 +586,18 @@ void MainWindow::get_config(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
array<string, 2> MainWindow::split_region_zone(string read_reg_zon_cfg){
|
|
|
|
|
read_reg_zon_cfg = read_reg_zon_cfg.substr(read_reg_zon_cfg.find("=")+1,read_reg_zon_cfg.length());
|
|
|
|
|
read_reg_zon_cfg = read_reg_zon_cfg.substr(0,read_reg_zon_cfg.find("\n"));
|
|
|
|
|
array<string, 2> arr;
|
|
|
|
|
if (read_reg_zon_cfg.find("/")!=std::string::npos){
|
|
|
|
|
string str_filling_reg = read_reg_zon_cfg.substr(0,read_reg_zon_cfg.find("/"));
|
|
|
|
|
string str_filling_zon = read_reg_zon_cfg.substr(read_reg_zon_cfg.find("/")+1,read_reg_zon_cfg.length());
|
|
|
|
|
str_filling_zon = str_filling_zon.substr(0,str_filling_zon.find("\n"));
|
|
|
|
|
array<string, 2> arr;
|
|
|
|
|
|
|
|
|
|
arr[0] = str_filling_reg;
|
|
|
|
|
arr[1] = str_filling_zon;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
arr[0] = "";
|
|
|
|
|
arr[1] = "";
|
|
|
|
|
}
|
|
|
|
|
return arr;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|