Исправил сохранение

pull/24/head
Igor Belitskiy 2 years ago
parent 04143b0e28
commit 457c6e834a

@ -47,7 +47,7 @@ void wrapper_edit_user_show() {
void wrapper_add_group_show() {
char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(cfg_custom_gui.group.comboBox));
activ_text= yon_char_divide_search(activ_text, " ", -1);
activ_text = yon_char_divide_search(activ_text, " ", -1);
set_disk(activ_text);
set_temp_menu("grpquota", "add");
set_all_config(all_config);
@ -277,44 +277,40 @@ int wrapper_select_tree_view(hotebook* widgets) {
}
void wrapper_all_save() {
/*
int flag_mess_save = 0;
if (main_config.flag_load == 0) {
flag_mess_save = template_format_str_save(CMD_ALL_SAVE, CMD_ALL_REMOVE);
if (all_config->flag_load == 0) {
flag_mess_save = wrapper_template_save(all_config, CMD_ALL_SAVE, CMD_ALL_REMOVE);
}
else {
flag_mess_save = template_format_str_save(CMD_ALL_SAVE, CMD_ALL_REMOVE);
flag_mess_save = wrapper_template_save(all_config, CMD_ALL_SAVE, CMD_ALL_REMOVE);
}
if (flag_mess_save) {
yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE);
main_config.flag_save=0;
yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
all_config->flag_load=0;
}
else {
yon_ubl_status_box_render(MESS_NOTHING_SAVE, BACKGROUND_IMAGE_SUCCESS_TYPE);
}
*/
}
void wrapper_global_save() {
/*
if (template_format_str_save(CMD_SAVE_GLOBAL, CMD_REMOVE_GLOBAL)) {
yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE);
main_config.flag_save-=1;
if (wrapper_template_save(all_config, CMD_SAVE_GLOBAL, CMD_REMOVE_GLOBAL)) {
yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
all_config->flag_load-=1;
}
else {
yon_ubl_status_box_render(MESS_NOTHING_SAVE, BACKGROUND_IMAGE_SUCCESS_TYPE);
}*/
}
}
void wrapper_system_save() {
/*
if (template_format_str_save(CMD_SAVE_SYSTEM, CMD_REMOVE_SYSTEM)) {
yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE);
main_config.flag_save-=1;
if (wrapper_template_save(all_config, CMD_SAVE_SYSTEM, CMD_REMOVE_SYSTEM)) {
yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
all_config->flag_load-=1;
}
else {
yon_ubl_status_box_render(MESS_NOTHING_SAVE, BACKGROUND_IMAGE_SUCCESS_TYPE);
}
*/
}
void load_system_cfg() {
all_config->flag_load = 0;

@ -1,5 +1,5 @@
#include "ubl-settings-diskquota.h"
#include "ubl-strings.h"
char *local;

@ -35,6 +35,7 @@ typedef struct {
vector v_group;
vector v_project;
vector v_disk_status;
vector v_remove;
int flag_set_data;
int flag_save;
int flag_load;

@ -851,4 +851,15 @@ char* fill_tree_view_id(int id) {
}
char *philos_char_from_size_t(size_t int_to_convert) {
int i = 1;
float convert_check = (float)int_to_convert;
for (i = 1; convert_check >= 10; i++)
{
convert_check = convert_check / 10;
}
char *ch = g_malloc0(i * sizeof(char) + 1);
sprintf(ch, "%d", int_to_convert);
return ch;
}

@ -159,5 +159,6 @@ char** philos_char_parsed_append(char** parsed, int *size, char *string);
void philos_set_size_memory_integer(char* str_find, size_t* array_data);
me_time time_convert(size_t seconds);
char* fill_tree_view_id(int id);
char *philos_char_from_size_t(size_t int_to_convert);
#endif

@ -2,51 +2,65 @@
#define SAVE_H
#include "save.h"
/*
char* template_format_save(config_all* _all_config, char* source_set_cmd) {
char* save_str_users(config_u_g_p* config, int index) {
char* cmd = yon_char_new("");
char split_simvol[2] = {0};
split_simvol[0] = 0;
split_simvol[1] = 0;
vector* vec_actors = &config->actors;
char* str_actors = NULL;
if (vec_actors->vectorList.total> 0) {
for (int i = 0; i < vec_actors->vectorList.total; i++) {
str_actors = (char*)vec_actors->pfVectorGet(vec_actors, i);
cmd = yon_char_unite(",", str_actors, NULL);
}
}
}
char* template_format_save(vector* vec_temp) {
char* cmd = yon_char_new("");
for (int i = 0; i < _all_config->v_u_g_p.pfVectorTotal(&_all_config->v_u_g_p); i++) {
config_u_g_p* _config = (config_u_g_p*)_all_config->v_u_g_p.pfVectorGet(&_all_config->v_u_g_p, i);
char* key = save_format_key(_config, i);
char* value = save_format_str_value(_config, i);
//char* value_status = save_format_status_cmd(_config, i);
if (key!= NULL) {
// key = yon_char_unite(cmd, " " , key, "=\"" , value, "\" ", NULL);
cmd = yon_char_unite(cmd, key, "=" , value, " ", NULL);
//cmd = yon_char_unite(cmd, key, "=" , value_status, " ", NULL);
free(key);
free(value);
//free(value_status);
if (vec_temp->vectorList.total> 0) {
for (int i = 0; i < vec_temp->pfVectorTotal(vec_temp); i++) {
config_u_g_p* _config = (config_u_g_p*)vec_temp->pfVectorGet(vec_temp, i);
char* key = save_format_key(_config, i);
char* value = save_format_str_value(_config, i);
if (key!= NULL) {
cmd = yon_char_unite(cmd, key, "=" , value, " ", NULL);
free(key);
free(value);
}
}
}
if (strlen(cmd) > 8 && save_check_save(_all_config)== 0) {
cmd = yon_char_unite(source_set_cmd, " " ,cmd, NULL);
return cmd;
return cmd;
}
char* wrapper_template_format_save(config_all* _all_config, char* source_set_cmd) {
char* cmd_user = template_format_save(&_all_config->v_user);
char* cmd_group = template_format_save(&_all_config->v_group);
char* cmd_project = template_format_save(&_all_config->v_project);
if ((strlen(cmd_user) > 3 || strlen(cmd_group) > 3 || strlen(cmd_project) > 3) && !save_check_save(_all_config)) {
return yon_char_unite(source_set_cmd," ", cmd_user, " ", cmd_group, " ", cmd_project, NULL);
}
free(cmd);
return NULL;
}
char* template_format_remove_save(config_all* _all_config, char* source_remove_cmd) {
char* cmd = yon_char_new(source_remove_cmd);
if (_all_config->count_remove == 0) {
return NULL;
}
for (int i = 0; i < _all_config->v_u_g_p.pfVectorTotal(&_all_config->v_u_g_p); i++) {
config_u_g_p* _config = (config_u_g_p*)_all_config->v_u_g_p.pfVectorGet(&_all_config->v_u_g_p, i);
if (_config->status_set >= 0) {
cmd = yon_char_unite(cmd, " " , _config->loaded_keys, " ", NULL);
if (_all_config->v_remove.vectorList.total > 0) {
char* cmd = yon_char_new(source_remove_cmd);
for (int i = 0; i < _all_config->v_remove.vectorList.total; i++) {
char* str_remove = (char*)_all_config->v_remove.pfVectorGet(&_all_config->v_remove, i);
cmd = yon_char_unite(cmd, " " , str_remove, " ", NULL);
}
if (strlen(cmd) > strlen(source_remove_cmd) && save_check_save(_all_config)== 0) {
return cmd;
}
}
if (strlen(cmd) > strlen(source_remove_cmd) && save_check_save(_all_config)== 0) {
return cmd;
}
return cmd;
return NULL;
}
int wrapper_template_save(config_all* _all_config, char* source_set_cmd, char* source_remove_cmd) {
char* str_cmd_remove = template_format_remove_save(_all_config,source_remove_cmd);
char* str_cmd_set = template_format_save(_all_config,source_set_cmd);
char* str_cmd_set = wrapper_template_format_save(_all_config,source_set_cmd);
if (str_cmd_set != NULL && str_cmd_remove != NULL) {
philos_config_save(yon_char_unite(str_cmd_remove, "; " , str_cmd_set, NULL));
}
@ -70,14 +84,10 @@ int wrapper_template_save(config_all* _all_config, char* source_set_cmd, char* s
}
char* save_format_key(config_u_g_p* config, int index) {
if (config->status_set == 1) {
return NULL;
}
char* cmd = yon_char_new("");
char* value = yon_char_new("");
char* key = yon_char_new("");
int number = config->id;
key = yon_char_unite("CGROUP_QUOTA[", config->type_arr, ":", NULL);
if (strstr(config->type_arr, "prjquota")) {
if (number!=-1) {
@ -90,63 +100,26 @@ char* save_format_key(config_u_g_p* config, int index) {
else {
key = yon_char_unite(config->UNIX_file, NULL);
}
key = yon_char_unite(key, save_str_users(config, index) , "]", NULL);
return cmd;
}
char* save_format_str_value(config_u_g_p* config, int index) {
if (config->status_set == 1) {
return NULL;
}
char* value = yon_char_new("");
value = philos_format_cfg_str_size_memory(value, config->soft_restriction_size,config->soft_restriction_size_pow);
value = yon_char_unite(value, ",");
philos_format_cfg_str_size_memory(value, config->soft_restriction_file,config->soft_restriction_file_pow);
value = yon_char_unite(value, ",");
philos_format_cfg_str_size_memory(value, config->severe_limitation_size,config->severe_limitation_size_pow);
value = yon_char_unite(value, ",");
philos_format_cfg_str_size_memory(value, config->severe_limitation_file, config->severe_limitation_file_pow);
value = yon_char_unite(value, ",");
//philos_format_cfg_str_size_memory(value, config->deferring_size, config->deferring_size_pow);
value = yon_char_unite(value, ",");
//value = philos_format_cfg_str_size_memory(value, config->deferring_file, config->deferring_file_pow);
value = yon_char_unite(value, ",", NULL);
value = yon_char_unite(value, yon_char_from_int(config->soft_restriction_file));
value = yon_char_unite(value, ",", NULL);
value = philos_format_cfg_str_size_memory(value, config->severe_limitation_size,config->severe_limitation_size_pow);
value = yon_char_unite(value, ",", NULL);
value = yon_char_unite(value, yon_char_from_int(config->severe_limitation_file), NULL);
value = yon_char_unite(value, ",", NULL);
value = yon_char_unite(value, philos_char_from_size_t(config->deferring_size), ",", NULL);
value = yon_char_unite(value, philos_char_from_size_t(config->deferring_file), NULL);
return value;
}
char* save_str_users(config_u_g_p* config, int index) {
char* cmd = yon_char_new("");
char split_simvol[2] = {0};
split_simvol[0] = 0;
split_simvol[1] = 0;
if (strstr(config->type_arr, "prjquota")) {
//for (int i=0; config->actors[i]; i++) {
// cmd = yon_char_unite(":", split_simvol, config->actors[i], NULL);
// split_simvol[0] = ',';
// split_simvol[1] = '\0';
//}
}
else {
}
}
char* save_format_status_cmd(config_u_g_p* config, int index) {
if (config->status_set == 1) {
return NULL;
}
if (config->status) {
return yon_char_new("enable");
}
else {
return yon_char_new("disable");
}
return yon_char_new("disable");
}
int save_check_save(config_all* _all_config) {
if (_all_config->flag_set_data == 1 || _all_config->flag_save>0) {
return 0;
@ -156,18 +129,15 @@ int save_check_save(config_all* _all_config) {
}
return 0;
}
void save_remove_array(config_all* _all_config) {
for (int i = 0; i < _all_config->v_u_g_p.pfVectorTotal(&_all_config->v_u_g_p); i++) {
config_u_g_p* _config = (config_u_g_p*)_all_config->v_u_g_p.pfVectorGet(&_all_config->v_u_g_p, i);
if (_config->status_set == 1) {
_all_config->v_u_g_p.pfVectorDelete(&_all_config->v_u_g_p, i);
}
if (_config->status_set == 2) {
_config->status_set = 0;
}
char* save_format_status_cmd(config_u_g_p* config, int index) {
/*if (config->status) {
return yon_char_new("enable");
}
else {
return yon_char_new("disable");
}
*/
return yon_char_new("disable");
}
*/
#endif

@ -2,13 +2,12 @@
#define SAVE
#include "ubl-utils.h"
#include "model.h"
char* template_format_save(config_all* _all_config, char* source_set_cmd);
char* template_format_save(vector* vec_temp);
char* save_format_key(config_u_g_p* _config, int index);
char* save_str_users(config_u_g_p* _config, int index);
char* save_format_str_value(config_u_g_p* config, int index);
char* save_format_status_cmd(config_u_g_p* config, int index);
char* template_format_remove_save(config_all* _all_config, char* source_remove_cmd);
char* template_format_remove_save(config_all* _all_config, char* source_remove_cmd);
void save_remove_array(config_all* _all_config);
int save_check_save(config_all* _all_config);
int wrapper_template_save(config_all* _all_config, char* source_set_cmd, char* source_remove_cmd);

@ -595,6 +595,7 @@ char *yon_char_from_int(int int_to_convert)
return ch;
}
/**yon_char_replace(char *source, char *find, char*replace)
* [EN]
*

@ -13,6 +13,7 @@
#include "ubl-cmake.h"
#include "model/model.h"
#include "model/load.h"
#include "model/save.h"
#include "ubl-strings.h"
#include "model/philos_utils.h"
#ifdef WEBKIT_FOUND

@ -44,7 +44,7 @@
#define GLOBAL_LOCAL_SAVE_SUCCESS_LABEL _("Local and global configuration saving succseeded.")
#define GLOBAL_SAVE_SUCCESS_LABEL _("Global configuration saving succseeded.")
#define LOCAL_SAVE_SUCCESS_LABEL _("Local configuration saving succseeded.")
#define SAVE_FAILED_LABEL
#define MESS_NOTHING_SAVE _("Nothing to save!")
#define STR_KB _("Kb")
#define STR_MB _("Mb")
@ -66,3 +66,4 @@
#define DAYS _("d ")
#define HOURS _("h ")
#define MINUTES _("m ")
#define SAVE_FAILED_LABEL

@ -83,4 +83,6 @@ void table_u_g_on_hide_subwindow(GtkWidget *self) {
table_u_g *table_u_g_get_widget_filters() {
return table_widgets;
}
}

@ -367,7 +367,7 @@ config_u_g_p* get_temp_gui_data_base(config_u_g_p* _config) {
);
_config->type_arr = yon_char_new(flag_temp_u_g_p);
// _config->status_set= 0;
if (strcmp(flag_temp_u_g_p,"prjquota") == 0) {
if (strstr(flag_temp_u_g_p,"prjquota")) {
_config->UNIX_file = (char*)gtk_entry_get_text(GTK_ENTRY(temp_widgets->entryCatalogProject));
char* actors = (char*)gtk_entry_get_text(GTK_ENTRY(temp_widgets->entryProjectName));
if (strlen(actors)>1) {

Loading…
Cancel
Save