|
|
|
@ -251,12 +251,12 @@ void main_update_information() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void load_system_cfg() {
|
|
|
|
|
template_cfg(CMD_LOAD_SYSTEM);
|
|
|
|
|
template_cfg(CMD_LOAD_SYSTEM, main_config.load_system_cfg);
|
|
|
|
|
yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS, BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void load_global_cfg() {
|
|
|
|
|
template_cfg(CMD_LOAD_GLOBAL);
|
|
|
|
|
template_cfg(CMD_LOAD_GLOBAL, main_config.load_global_cfg);
|
|
|
|
|
yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -283,7 +283,7 @@ void clear_array() {
|
|
|
|
|
main_config.size_tree_view = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void template_cfg(char* cmd) {
|
|
|
|
|
void template_cfg(char* cmd, dictionary* load_cfg) {
|
|
|
|
|
clear_array();
|
|
|
|
|
int size = 0;
|
|
|
|
|
char** cfg = yon_config_load(cmd, &size);
|
|
|
|
@ -296,11 +296,13 @@ void template_cfg(char* cmd) {
|
|
|
|
|
size_t length = strlen(str_key_value);
|
|
|
|
|
str_key_value = yon_char_divide(str_key_value, length-2);
|
|
|
|
|
}
|
|
|
|
|
str_split_key(str_key, main_config.size_tree_view);
|
|
|
|
|
load_cfg = yon_dictionary_create_with_data_connected(load_cfg, str_key, str_key_value);
|
|
|
|
|
str_split_value(str_key_value, main_config.size_tree_view);
|
|
|
|
|
str_split_key(str_key, main_config.size_tree_view);
|
|
|
|
|
main_config.size_tree_view++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (main_config.size_tree_view != 0) {
|
|
|
|
|
fill_tree_view(0, main_config.size_tree_view, 0);
|
|
|
|
|
}
|
|
|
|
@ -309,6 +311,8 @@ void template_cfg(char* cmd) {
|
|
|
|
|
void init_cfg_array(int index) {
|
|
|
|
|
main_config.disk = yon_char_parsed_append(main_config.disk, &index, "-");
|
|
|
|
|
index--;
|
|
|
|
|
set_pow_size("-", &main_config.type_quota_size, &main_config.type_quota, index);
|
|
|
|
|
set_pow_size("-", &main_config.quota_volume_size, &main_config.quota_volume, index);
|
|
|
|
|
set_pow_size("-", &main_config.cpu_limit_size, &main_config.cpu_limit, index);
|
|
|
|
|
set_pow_size("-", &main_config.cpu_limit_size, &main_config.cpu_limit, index);
|
|
|
|
|
set_pow_size("-", &main_config.soft_raw_limit_size, &main_config.soft_raw_limit, index);
|
|
|
|
@ -317,7 +321,9 @@ void init_cfg_array(int index) {
|
|
|
|
|
set_pow_size("-", &main_config.i_o_limit_read_size, &main_config.i_o_limit_read, index);
|
|
|
|
|
set_pow_size("-", &main_config.i_o_limit_write_size, &main_config.i_o_limit_write, index);
|
|
|
|
|
}
|
|
|
|
|
void str_split_key(char* value, int index) {
|
|
|
|
|
|
|
|
|
|
void str_split_key(char* source_value, int index) {
|
|
|
|
|
char* value = yon_char_new(source_value);
|
|
|
|
|
yon_char_divide_search(value, "[", -1);
|
|
|
|
|
value = yon_char_divide_search(value, "]", -1);
|
|
|
|
|
if (strstr(value, ".") != NULL) {
|
|
|
|
@ -340,8 +346,6 @@ void str_split_key(char* value, int index) {
|
|
|
|
|
else {
|
|
|
|
|
main_config.quota_volume = yon_char_parsed_append(main_config.quota_volume, &index, value);
|
|
|
|
|
index--;
|
|
|
|
|
main_config.type_quota_size = philos_int_append(main_config.type_quota_size, &index, -1);
|
|
|
|
|
index--;
|
|
|
|
|
main_config.type_quota = yon_char_parsed_append(main_config.type_quota, &index, "-");
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
@ -352,8 +356,8 @@ void str_split_key(char* value, int index) {
|
|
|
|
|
char** arr_users = philos_list_user(&user_size);
|
|
|
|
|
for (int user_index = 0; user_index < user_size; user_index++) {
|
|
|
|
|
// Пользователь
|
|
|
|
|
if (strcmp(arr_users[user_index], value) != 0) {
|
|
|
|
|
main_config.type_quota_size = philos_int_append(main_config.type_quota_size, &index, 0);
|
|
|
|
|
if (strstr(arr_users[user_index], value) != NULL) {
|
|
|
|
|
main_config.type_quota_size = philos_int_append(main_config.type_quota_size, &index, -1);
|
|
|
|
|
index--;
|
|
|
|
|
main_config.quota_volume = yon_char_parsed_append(main_config.quota_volume, &index, value);
|
|
|
|
|
index--;
|
|
|
|
@ -372,6 +376,7 @@ void str_split_key(char* value, int index) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
void str_split_value(char* values, int index) {
|
|
|
|
|
char* new_value = yon_char_new(values);
|
|
|
|
@ -425,25 +430,25 @@ void set_pow_size(char* str_find, int** array_size, char*** array_data , int ind
|
|
|
|
|
if (strstr(str_find,"K") != NULL) {
|
|
|
|
|
*array_size = philos_int_append(*array_size, &index, 0);
|
|
|
|
|
str_find = yon_char_divide(str_find, length-1);
|
|
|
|
|
str_find = yon_char_unite(str_find, " ", STR_KB);
|
|
|
|
|
str_find = yon_char_unite(str_find, " ", STR_KB, NULL);
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
else if (strstr(str_find,"M") != NULL) {
|
|
|
|
|
*array_size = philos_int_append(*array_size, &index, 1);
|
|
|
|
|
str_find = yon_char_divide(str_find, length-1);
|
|
|
|
|
str_find = yon_char_unite(str_find," ", STR_MB);
|
|
|
|
|
str_find = yon_char_unite(str_find," ", STR_MB, NULL);
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
else if (strstr(str_find,"G") != NULL) {
|
|
|
|
|
*array_size = philos_int_append(*array_size, &index, 2);
|
|
|
|
|
str_find = yon_char_divide(str_find, length-1);
|
|
|
|
|
str_find = yon_char_unite(str_find," ", STR_GB);
|
|
|
|
|
str_find = yon_char_unite(str_find," ", STR_GB, NULL);
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
else if (strstr(str_find,"T") != NULL) {
|
|
|
|
|
*array_size = philos_int_append(*array_size, &index, 3);
|
|
|
|
|
str_find = yon_char_divide(str_find, length-1);
|
|
|
|
|
str_find = yon_char_unite(str_find," ", STR_TB);
|
|
|
|
|
str_find = yon_char_unite(str_find," ", STR_TB, NULL);
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
else if (strstr(str_find,"\%") != NULL) {
|
|
|
|
@ -720,8 +725,13 @@ void tree_view_del_line() {
|
|
|
|
|
GtkTreeModel *model = GTK_TREE_MODEL(main_config.list);
|
|
|
|
|
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->treeViewMain));
|
|
|
|
|
if(gtk_tree_selection_get_selected(selection, &model, &iter)) {
|
|
|
|
|
char* str_iter = gtk_tree_model_get_string_from_iter(model, &iter);
|
|
|
|
|
char* str_iter = yon_char_new(gtk_tree_model_get_string_from_iter(model, &iter));
|
|
|
|
|
index = atoi(str_iter);
|
|
|
|
|
g_object_ref(main_config.list);
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->treeViewMain), NULL);
|
|
|
|
|
gtk_list_store_clear(main_config.list);
|
|
|
|
|
main_fill_tree_view_after_remove();
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->treeViewMain), model);
|
|
|
|
|
main_config.type_quota = yon_char_parsed_shrink(main_config.type_quota, &main_config.size_tree_view,index);
|
|
|
|
|
main_config.size_tree_view++;
|
|
|
|
|
main_config.quota_volume = yon_char_parsed_shrink(main_config.quota_volume, &main_config.size_tree_view,index);
|
|
|
|
@ -754,13 +764,58 @@ void tree_view_del_line() {
|
|
|
|
|
main_config.i_o_limit_read_size = remove_element_int_array(main_config.i_o_limit_read_size, &main_config.size_tree_view,index);
|
|
|
|
|
main_config.size_tree_view++;
|
|
|
|
|
main_config.i_o_limit_write_size = remove_element_int_array(main_config.i_o_limit_write_size, &main_config.size_tree_view,index);
|
|
|
|
|
g_object_ref(main_config.list);
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->treeViewMain), NULL);
|
|
|
|
|
gtk_list_store_clear(main_config.list);
|
|
|
|
|
main_fill_tree_view_after_remove();
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->treeViewMain), model);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void template_format_save(dictionary* load_temp_cfg) {
|
|
|
|
|
if (load_temp_cfg == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (size_t i = 0; i < main_config.size_tree_view; i++) {
|
|
|
|
|
char* key = NULL;
|
|
|
|
|
char* value = "";
|
|
|
|
|
char split_simvol[2] = {0};
|
|
|
|
|
if (strstr(main_config.quota_volume[i], "-") == NULL) {
|
|
|
|
|
key = yon_char_unite("CGROUP_QUOTA[", &main_config.type_quota[i] , "]", NULL);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
key = yon_char_unite("CGROUP_QUOTA[", &main_config.type_quota[i], ".", &main_config.quota_volume[i], "]", NULL);
|
|
|
|
|
}
|
|
|
|
|
split_simvol[0] = 0;
|
|
|
|
|
split_simvol[1] = 0;
|
|
|
|
|
if (strstr(main_config.soft_raw_limit[i], "-") != NULL) {
|
|
|
|
|
value = yon_char_unite(value, main_config.soft_raw_limit[i], NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
if (strstr(main_config.hard_raw_limit[i], "-") != NULL) {
|
|
|
|
|
value = yon_char_unite(value, split_simvol, main_config.hard_raw_limit[i], NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
if (strstr(main_config.swap[i], "-") != NULL) {
|
|
|
|
|
value = yon_char_unite(value, split_simvol, main_config.swap[i], NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
if (strstr(main_config.cpu_limit[i], "-") != NULL) {
|
|
|
|
|
value = yon_char_unite(value, split_simvol, main_config.cpu_limit[i], NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
if (strstr(main_config.i_o_limit_read[i], "-") != NULL) {
|
|
|
|
|
value = yon_char_unite(value, split_simvol, main_config.i_o_limit_read[i], NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
if (strstr(main_config.i_o_limit_write[i], "-") != NULL) {
|
|
|
|
|
value = yon_char_unite(value, split_simvol, main_config.i_o_limit_write[i], NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
main_config.save_cfg_gui = yon_dictionary_create_with_data_connected(main_config.save_cfg_gui, key, yon_char_new(value));
|
|
|
|
|
free(key);
|
|
|
|
|
free(value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -866,6 +921,8 @@ int main(int argc, char *argv[]){
|
|
|
|
|
gtk_init(&argc,&argv);
|
|
|
|
|
device_disk_parsed();
|
|
|
|
|
main_window *widgets = setup_window();
|
|
|
|
|
main_config.load_global_cfg = yon_dictionary_create_empty();
|
|
|
|
|
main_config.load_system_cfg = yon_dictionary_create_empty();
|
|
|
|
|
main_update_information();
|
|
|
|
|
filters_init_flag();
|
|
|
|
|
filters_setup_window(glade_path);
|
|
|
|
|