|
|
|
|
@ -1,37 +1,18 @@
|
|
|
|
|
#include <gtkmm/window.h>
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <cstddef>
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <glibmm/i18n.h>
|
|
|
|
|
#include <gtkmm/plug.h>
|
|
|
|
|
#include <gtkmm/stock.h>
|
|
|
|
|
#include <gtkmm.h>
|
|
|
|
|
#include <ostream>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <ctime>
|
|
|
|
|
#include <array>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <fstream>
|
|
|
|
|
#include <filesystem>
|
|
|
|
|
#include <glibmm/i18n.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <gtkmm/plug.h>
|
|
|
|
|
#include <gtkmm/stock.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <sstream>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <unicode/unistr.h>
|
|
|
|
|
#include <unicode/ustdio.h>
|
|
|
|
|
#include <unicode/uloc.h>
|
|
|
|
|
#include <unicode/uldnames.h>
|
|
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
#include "unicode/utext.h"
|
|
|
|
|
|
|
|
|
|
#include <unicode/timezone.h>
|
|
|
|
|
#include <unicode/calendar.h>
|
|
|
|
|
#include <array>
|
|
|
|
|
#include "ubl-settings-datetime.h"
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
@ -477,7 +458,6 @@ void MainWindow::get_calendar(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::calendar_show(){
|
|
|
|
|
cout << 2222 << endl;
|
|
|
|
|
if (year==0){
|
|
|
|
|
time_t now = time(0);
|
|
|
|
|
tm *ltm = localtime(&now);
|
|
|
|
|
@ -554,7 +534,7 @@ void MainWindow::get_config(){
|
|
|
|
|
this->update_hour_minute();
|
|
|
|
|
this->update_calendar();
|
|
|
|
|
this->enry_dhcp_mess();
|
|
|
|
|
string cmd = "/usr/bin/ubconfig --source global get clock ZONE";
|
|
|
|
|
string cmd = "/usr/bin/ubconfig --default --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);
|
|
|
|
|
@ -562,14 +542,14 @@ void MainWindow::get_config(){
|
|
|
|
|
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);
|
|
|
|
|
this->append_region_zone("","",cbRegionGlob,cbZoneGlob);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this->append_region_zone("Africa","Abidjan",cbRegionGlob,cbZoneGlob);
|
|
|
|
|
this->append_region_zone("","",cbRegionGlob,cbZoneGlob);
|
|
|
|
|
}
|
|
|
|
|
cmd = "/usr/bin/ubconfig --source system get clock ZONE";
|
|
|
|
|
cmd = "/usr/bin/ubconfig --default --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);
|
|
|
|
|
@ -577,12 +557,13 @@ void MainWindow::get_config(){
|
|
|
|
|
this->append_region_zone(arr_reg_zone[0],arr_reg_zone[1], cbRegion, cbZone);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
this->append_region_zone("Africa","Abidjan", cbRegion, cbZone);
|
|
|
|
|
this->append_region_zone("","",cbRegion,cbZone);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this->append_region_zone("Africa","Abidjan", cbRegion, cbZone);
|
|
|
|
|
this->append_region_zone("","",cbRegion,cbZone);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
array<string, 2> MainWindow::split_region_zone(string read_reg_zon_cfg){
|
|
|
|
|
@ -678,14 +659,35 @@ void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxTex
|
|
|
|
|
str_region_glob=region;
|
|
|
|
|
int index = 0;
|
|
|
|
|
Glib::ustring reg_local = "";
|
|
|
|
|
for (const auto &text : array_region) {
|
|
|
|
|
reg_local = text;
|
|
|
|
|
reg_local = string(_(reg_local.c_str()));
|
|
|
|
|
tmpCbReg->append(Glib::ustring(reg_local));
|
|
|
|
|
if (text == region){
|
|
|
|
|
tmpCbReg->set_active_text(reg_local);
|
|
|
|
|
int size_vec = array_region_local.size();
|
|
|
|
|
if (size_vec==0){
|
|
|
|
|
for (auto& [key, value]: time_reg_map){
|
|
|
|
|
array_region_local.push_back(string(_(key.c_str())));
|
|
|
|
|
array_region.push_back(key);
|
|
|
|
|
index+=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Cортировка пузырьком
|
|
|
|
|
if (size_vec==0){
|
|
|
|
|
size_vec = array_region_local.size();
|
|
|
|
|
for (int i = 0; i < size_vec; i++) {
|
|
|
|
|
for (int j = 0; j < size_vec-1; j++) {
|
|
|
|
|
if (array_region_local[j] > array_region_local[j + 1]) {
|
|
|
|
|
auto b = array_region_local[j];
|
|
|
|
|
array_region_local[j] = array_region_local[j + 1];
|
|
|
|
|
array_region_local[j + 1] = b;
|
|
|
|
|
b = array_region[j];
|
|
|
|
|
array_region[j] = array_region[j + 1];
|
|
|
|
|
array_region[j + 1] = b;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (string ® : array_region_local){
|
|
|
|
|
tmpCbReg->append(Glib::ustring(reg));
|
|
|
|
|
if (reg == string(_(region.c_str()))){
|
|
|
|
|
tmpCbReg->set_active_text(reg);
|
|
|
|
|
}
|
|
|
|
|
index+=1;
|
|
|
|
|
}
|
|
|
|
|
index = 0;
|
|
|
|
|
string zone_mixing = "";
|
|
|
|
|
@ -693,14 +695,25 @@ void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxTex
|
|
|
|
|
string zone_offest = "";
|
|
|
|
|
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)){
|
|
|
|
|
tmpCbZone->append(_str_zone);
|
|
|
|
|
if (_str_zone!=""){
|
|
|
|
|
if (zone_offest == _str_zone){
|
|
|
|
|
tmpCbZone->set_active(index);
|
|
|
|
|
if (region==""){
|
|
|
|
|
tmpCbZone->append(" ");
|
|
|
|
|
tmpCbZone->set_active(0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (time_reg_map_local.find(region) == time_reg_map_local.end()){
|
|
|
|
|
tmpCbZone->append(" ");
|
|
|
|
|
tmpCbZone->set_active(0);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
for (string &_str_zone : time_reg_map_local.at(region)){
|
|
|
|
|
tmpCbZone->append(_str_zone);
|
|
|
|
|
if (_str_zone!=""){
|
|
|
|
|
if (zone_offest == _str_zone){
|
|
|
|
|
tmpCbZone->set_active(index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
index+=1;
|
|
|
|
|
index+=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@ -867,11 +880,10 @@ void MainWindow::read_file(){
|
|
|
|
|
if (fs::is_directory(path_dir)){
|
|
|
|
|
if (key_reg!="Pacific"){
|
|
|
|
|
if (key_reg!="posix"){
|
|
|
|
|
if (key_reg!="Etc"){
|
|
|
|
|
//if (key_reg!="Etc"){
|
|
|
|
|
if (key_reg!="right"){
|
|
|
|
|
vector<string> zone;
|
|
|
|
|
vector<string> zone_local;
|
|
|
|
|
//zone.push_back("");
|
|
|
|
|
for (const auto & entry_zone : fs::directory_iterator(path_dir)){
|
|
|
|
|
std::ifstream in1(entry_zone.path()); // окрываем файл для чтения
|
|
|
|
|
if (in1.is_open()){
|
|
|
|
|
@ -888,7 +900,7 @@ void MainWindow::read_file(){
|
|
|
|
|
this->sort_zone(&zone_local, &zone);
|
|
|
|
|
time_reg_map.insert({key_reg, zone});
|
|
|
|
|
time_reg_map_local.insert({key_reg, zone_local});
|
|
|
|
|
}}}}
|
|
|
|
|
}}}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
in.close();
|
|
|
|
|
@ -901,46 +913,47 @@ void MainWindow::sort_zone(vector<string> *time_reg_map_local,vector<string> *ti
|
|
|
|
|
string str_j_1 = "";
|
|
|
|
|
int j_i_1;
|
|
|
|
|
int size_vec = time_reg_map_local->size();
|
|
|
|
|
for (int i = 0; i < size_vec; i++) {
|
|
|
|
|
for (int j = 0; j < size_vec-1; j++) {
|
|
|
|
|
for (int i = 1; i < size_vec; i++) {
|
|
|
|
|
for (int j = 1; j < size_vec-1; j++) {
|
|
|
|
|
str_j=(*time_reg_map_local)[j];
|
|
|
|
|
str_j = str_j.substr(5,str_j.find(")")-5);
|
|
|
|
|
if (str_j[1]=='0'){
|
|
|
|
|
str_j.replace(1,1,"0");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (str_j.find("+") != std::string::npos){
|
|
|
|
|
str_j.replace(0,1,"+");
|
|
|
|
|
j_i = stoi(str_j);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
str_j.replace(0,1,"-");
|
|
|
|
|
j_i = stoi(str_j);
|
|
|
|
|
j_i=-j_i;
|
|
|
|
|
}
|
|
|
|
|
str_j_1=(*time_reg_map_local)[j+1];
|
|
|
|
|
str_j_1 = str_j_1.substr(5,str_j_1.find(")")-5);
|
|
|
|
|
if (str_j_1[1]=='0'){
|
|
|
|
|
str_j_1.replace(1,1,"0");
|
|
|
|
|
}
|
|
|
|
|
if (str_j_1.find("+") != std::string::npos){
|
|
|
|
|
str_j_1.replace(0,1,"+");
|
|
|
|
|
j_i_1 = stoi(str_j_1);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
str_j_1.replace(0,1,"-");
|
|
|
|
|
j_i_1 = stoi(str_j_1);
|
|
|
|
|
j_i_1 = -j_i_1;
|
|
|
|
|
}
|
|
|
|
|
if (j_i > j_i_1) {
|
|
|
|
|
string b = (*time_reg_map_local)[j];
|
|
|
|
|
(*time_reg_map_local)[j] = (*time_reg_map_local)[j + 1];
|
|
|
|
|
(*time_reg_map_local)[j + 1] = b;
|
|
|
|
|
if (str_j!=" "){
|
|
|
|
|
str_j = str_j.substr(5,str_j.find(")")-5);
|
|
|
|
|
if (str_j[1]=='0'){
|
|
|
|
|
str_j.replace(1,1,"0");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (str_j.find("+") != std::string::npos){
|
|
|
|
|
str_j.replace(0,1,"+");
|
|
|
|
|
j_i = stoi(str_j);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
str_j.replace(0,1,"-");
|
|
|
|
|
j_i = stoi(str_j);
|
|
|
|
|
j_i=-j_i;
|
|
|
|
|
}
|
|
|
|
|
str_j_1=(*time_reg_map_local)[j+1];
|
|
|
|
|
str_j_1 = str_j_1.substr(5,str_j_1.find(")")-5);
|
|
|
|
|
if (str_j_1[1]=='0'){
|
|
|
|
|
str_j_1.replace(1,1,"0");
|
|
|
|
|
}
|
|
|
|
|
if (str_j_1.find("+") != std::string::npos){
|
|
|
|
|
str_j_1.replace(0,1,"+");
|
|
|
|
|
j_i_1 = stoi(str_j_1);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
str_j_1.replace(0,1,"-");
|
|
|
|
|
j_i_1 = stoi(str_j_1);
|
|
|
|
|
j_i_1 = -j_i_1;
|
|
|
|
|
}
|
|
|
|
|
if (j_i > j_i_1) {
|
|
|
|
|
string b = (*time_reg_map_local)[j];
|
|
|
|
|
(*time_reg_map_local)[j] = (*time_reg_map_local)[j + 1];
|
|
|
|
|
(*time_reg_map_local)[j + 1] = b;
|
|
|
|
|
|
|
|
|
|
b = (*time_reg_map)[j];
|
|
|
|
|
(*time_reg_map)[j] = (*time_reg_map)[j + 1];
|
|
|
|
|
(*time_reg_map)[j + 1] = b;
|
|
|
|
|
}
|
|
|
|
|
b = (*time_reg_map)[j];
|
|
|
|
|
(*time_reg_map)[j] = (*time_reg_map)[j + 1];
|
|
|
|
|
(*time_reg_map)[j + 1] = b;
|
|
|
|
|
} }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|