|
|
|
|
@ -31,6 +31,7 @@
|
|
|
|
|
|
|
|
|
|
#include <unicode/timezone.h>
|
|
|
|
|
#include <unicode/calendar.h>
|
|
|
|
|
#include <array>
|
|
|
|
|
#include "ubl-settings-datetime.h"
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
@ -492,21 +493,41 @@ 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 get clock ZONE");
|
|
|
|
|
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);
|
|
|
|
|
this->append_region_zone(arr_reg_zone_glob[0],arr_reg_zone_glob[1],cbRegionGlob,cbZoneGlob);
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this->append_region_zone("Africa","Abidjan", cbRegion, cbZone);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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"));
|
|
|
|
|
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"));
|
|
|
|
|
string str_zone_check = "";
|
|
|
|
|
this->append_region_zone(str_filling_reg,str_filling_zon);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this->append_region_zone("Africa","Abidjan");
|
|
|
|
|
}
|
|
|
|
|
array<string, 2> arr;
|
|
|
|
|
arr[0] = str_filling_reg;
|
|
|
|
|
arr[1] = str_filling_zon;
|
|
|
|
|
return arr;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::enter_zone(){
|
|
|
|
|
int activ_index_reg = cbRegion->get_active_row_number();
|
|
|
|
|
string reg_text=array_region[activ_index_reg];
|
|
|
|
|
@ -523,10 +544,9 @@ void MainWindow::enter_zone(){
|
|
|
|
|
if (!(zone_text.empty())){
|
|
|
|
|
str_zone=zone_text;
|
|
|
|
|
str_region=reg_text;
|
|
|
|
|
string cmd = "rm -f /etc/localtime";
|
|
|
|
|
string cmd = "";
|
|
|
|
|
cmd = " ubconfig --target system set clock ZONE=" + str_region + "/" + str_zone;
|
|
|
|
|
system(cmd.c_str());
|
|
|
|
|
string cmd1 = "ln -s /usr/share/zoneinfo/" + str_region + "/" + str_zone+" /etc/localtime";
|
|
|
|
|
system(cmd1.c_str());
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
str_zone="";
|
|
|
|
|
@ -563,7 +583,7 @@ void MainWindow::enter_zone_glob(){
|
|
|
|
|
}
|
|
|
|
|
if (!(zone_text.empty())){
|
|
|
|
|
//str_zoneGlob = zone_text.substr(zone_text.find(") ")+2,zone_text.length());
|
|
|
|
|
string cmd = "/usr/bin/ubconfig set clock ZONE=" +reg_text +"/" + zone_text;
|
|
|
|
|
string cmd = "/usr/bin/ubconfig --target global set clock ZONE=" +reg_text +"/" + zone_text;
|
|
|
|
|
system(cmd.c_str());
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
@ -594,7 +614,7 @@ void MainWindow::set_ntp_toggle_glob(){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::append_region_zone(string region, string zone){
|
|
|
|
|
void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxText *tmpCbReg, Gtk::ComboBoxText *tmpCbZone){
|
|
|
|
|
str_region=region;
|
|
|
|
|
str_region_glob=region;
|
|
|
|
|
int index = 0;
|
|
|
|
|
@ -602,11 +622,9 @@ void MainWindow::append_region_zone(string region, string zone){
|
|
|
|
|
for (const auto &text : array_region) {
|
|
|
|
|
reg_local = text;
|
|
|
|
|
reg_local = string(_(reg_local.c_str()));
|
|
|
|
|
cbRegion->append(Glib::ustring(reg_local));
|
|
|
|
|
cbRegionGlob->append(Glib::ustring(reg_local));
|
|
|
|
|
tmpCbReg->append(Glib::ustring(reg_local));
|
|
|
|
|
if (text == region){
|
|
|
|
|
cbRegionGlob->set_active_text(reg_local);
|
|
|
|
|
cbRegion->set_active_text(reg_local);
|
|
|
|
|
tmpCbReg->set_active_text(reg_local);
|
|
|
|
|
}
|
|
|
|
|
index+=1;
|
|
|
|
|
}
|
|
|
|
|
@ -618,12 +636,10 @@ void MainWindow::append_region_zone(string region, string zone){
|
|
|
|
|
path_reg_zone=region+"/"+zone;
|
|
|
|
|
zone_offest = this->zone_file_read(path_reg_zone) + _(zone.c_str());
|
|
|
|
|
for (string &_str_zone : time_reg_map_local.at(region)){
|
|
|
|
|
cbZone->append(_str_zone);
|
|
|
|
|
cbZoneGlob->append(_str_zone);
|
|
|
|
|
tmpCbZone->append(_str_zone);
|
|
|
|
|
if (_str_zone!=""){
|
|
|
|
|
if (zone_offest == _str_zone){
|
|
|
|
|
cbZone->set_active(index);
|
|
|
|
|
cbZoneGlob->set_active(index);
|
|
|
|
|
tmpCbZone->set_active(index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
index+=1;
|
|
|
|
|
@ -894,3 +910,4 @@ void help(){
|
|
|
|
|
g_print(" --lock-datetime Disable datetime field editing\n");
|
|
|
|
|
g_print(" --lock-update Disable save changes\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|