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

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

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

@ -35,6 +35,7 @@ typedef struct {
vector v_group; vector v_group;
vector v_project; vector v_project;
vector v_disk_status; vector v_disk_status;
vector v_remove;
int flag_set_data; int flag_set_data;
int flag_save; int flag_save;
int flag_load; 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); void philos_set_size_memory_integer(char* str_find, size_t* array_data);
me_time time_convert(size_t seconds); me_time time_convert(size_t seconds);
char* fill_tree_view_id(int id); char* fill_tree_view_id(int id);
char *philos_char_from_size_t(size_t int_to_convert);
#endif #endif

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

@ -2,13 +2,12 @@
#define SAVE #define SAVE
#include "ubl-utils.h" #include "ubl-utils.h"
#include "model.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_format_key(config_u_g_p* _config, int index);
char* save_str_users(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_str_value(config_u_g_p* config, int index);
char* save_format_status_cmd(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);
char* template_format_remove_save(config_all* _all_config, char* source_remove_cmd);
void save_remove_array(config_all* _all_config); void save_remove_array(config_all* _all_config);
int save_check_save(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); 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; return ch;
} }
/**yon_char_replace(char *source, char *find, char*replace) /**yon_char_replace(char *source, char *find, char*replace)
* [EN] * [EN]
* *

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

@ -44,7 +44,7 @@
#define GLOBAL_LOCAL_SAVE_SUCCESS_LABEL _("Local and global configuration saving succseeded.") #define GLOBAL_LOCAL_SAVE_SUCCESS_LABEL _("Local and global configuration saving succseeded.")
#define GLOBAL_SAVE_SUCCESS_LABEL _("Global configuration saving succseeded.") #define GLOBAL_SAVE_SUCCESS_LABEL _("Global configuration saving succseeded.")
#define LOCAL_SAVE_SUCCESS_LABEL _("Local 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_KB _("Kb")
#define STR_MB _("Mb") #define STR_MB _("Mb")
@ -66,3 +66,4 @@
#define DAYS _("d ") #define DAYS _("d ")
#define HOURS _("h ") #define HOURS _("h ")
#define MINUTES _("m ") #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() { table_u_g *table_u_g_get_widget_filters() {
return table_widgets; 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->type_arr = yon_char_new(flag_temp_u_g_p);
// _config->status_set= 0; // _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)); _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)); char* actors = (char*)gtk_entry_get_text(GTK_ENTRY(temp_widgets->entryProjectName));
if (strlen(actors)>1) { if (strlen(actors)>1) {

Loading…
Cancel
Save