Добавил запись в локальный конфиг

pull/24/head
Igor Belitskiy 2 years ago
parent 4532e68411
commit 555ba367ff

@ -267,6 +267,9 @@ void device_remove() {
if (index!=-1) {
index_selected = -1;
disk_status* _config = (disk_status*)all_config.v_disk_status.pfVectorGet(&all_config.v_disk_status, index);
yon_window_config_erase_custom_parameter(_config->device, "deferring_size");
yon_window_config_erase_custom_parameter(_config->device, "deferring_file");
yon_window_config_erase_custom_parameter(_config->device, _config->device);
all_config.v_disk_remove.pfVectorAdd(&all_config.v_disk_remove, yon_char_new(_config->device));
model_search_disk_remove(&all_config.v_user, &all_config.v_remove, _config->device);
model_search_disk_remove(&all_config.v_group, &all_config.v_remove, _config->device);
@ -556,6 +559,8 @@ int main(int argc, char *argv[]){
yon_ubl_header_setup_resource(widgets->HeadOverlay,widgets->HeadBox,widgets->HeadImage,banner_path);
yon_ubl_status_box_setup(widgets->StatusIcon,widgets->StatusBox,widgets->StatusLabel);
yon_window_config_setup(GTK_WINDOW(widgets->Window));
yon_window_config_load(config_path);
if (getuid()!=0) {
load_system_cfg();
yon_ubl_status_box_render(ROOT_WARNING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
@ -571,8 +576,6 @@ int main(int argc, char *argv[]){
}
yon_ubl_setup_sockets(widgets->PlugBox,widgets->LeftBox,widgets->RightBox,main_config.socket_id,main_config.load_socket_id,main_config.save_socket_id);
yon_window_config_setup(GTK_WINDOW(widgets->Window));
yon_window_config_load(config_path);
GtkCssProvider *css=gtk_css_provider_new();
gtk_css_provider_load_from_resource(css,CssPath);
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),

@ -18,6 +18,37 @@ void load_template_load_cfg(config_all* _all_config, char* cmd) {
vector_init(&_all_config->v_disk_status);
vector_init(&_all_config->v_remove);
vector_init(&_all_config->v_disk_remove);
if (size == 1 && strcmp(cfg[0], "(null)") == 0) {
for (int index_1 = 0; index_1 < get_device_vec()->vectorList.total; index_1++) {
char* device = NULL;
device_config* _config_disk = (device_config*)get_device_vec()->pfVectorGet(get_device_vec(), index_1);
if (yon_window_config_get_parameter(_config_disk->name_disk, _config_disk->name_disk, &device, YON_TYPE_STRING)) {
if (strstr(device, _config_disk->name_disk)) {
size_t deferring_size = 0;
size_t deferring_file = 0;
disk_status* disk_cfg = malloc(sizeof(disk_status));
disk_cfg->status = 1;
_all_config->v_disk_status.pfVectorAdd(&_all_config->v_disk_status, disk_cfg);
disk_cfg->device = yon_char_new(device);
disk_cfg->fs = yon_char_new(_config_disk->file_system);
disk_cfg->mount_point = yon_char_new(_config_disk->mounted);
disk_cfg->name = yon_char_new(_config_disk->type_dick);
if (yon_window_config_get_parameter("deferring_size", _config_disk->name_disk, &deferring_size, YON_TYPE_INT)) {
disk_cfg->deferring_size = deferring_size;
}
else {
disk_cfg->deferring_size = 0;
}
if (yon_window_config_get_parameter("deferring_file", _config_disk->name_disk, &deferring_file, YON_TYPE_INT)) {
disk_cfg->deferring_file = deferring_file;
}
else {
disk_cfg->deferring_file = 0;
}
}
}
}
}
for (int index = 0; index < size; index++) {
char* str_key_value = yon_char_new(cfg[index]);
char* str_key = yon_char_divide_search(str_key_value, "=",-1);
@ -67,23 +98,26 @@ void load_template_load_cfg(config_all* _all_config, char* cmd) {
}
else {
if (yon_char_find_count(str_key, ":") == 1) {
return;
}
config_u_g_p* _config = malloc(sizeof(config_u_g_p));
model_null_str_writing(_config);
_config->loaded_keys = yon_char_new(str_key);
load_pars_keys(_config, yon_char_new(str_key), index);
load_pars_values(_config, _all_config,str_key, yon_char_new(str_value), index);
if (strstr(str_key, "prjquota")) {
_all_config->v_project.pfVectorAdd(&_all_config->v_project,_config);
}
else if (strstr(str_key, "usrquota")) {
_all_config->v_user.pfVectorAdd(&_all_config->v_user,_config);
}
else if (strstr(str_key, "grpquota")){
_all_config->v_group.pfVectorAdd(&_all_config->v_group,_config);
else {
config_u_g_p* _config = malloc(sizeof(config_u_g_p));
model_null_str_writing(_config);
_config->loaded_keys = yon_char_new(str_key);
load_pars_keys(_config, yon_char_new(str_key), index);
load_pars_values(_config, _all_config,str_key, yon_char_new(str_value), index);
if (strstr(str_key, "prjquota")) {
_all_config->v_project.pfVectorAdd(&_all_config->v_project,_config);
}
else if (strstr(str_key, "usrquota")) {
_all_config->v_user.pfVectorAdd(&_all_config->v_user,_config);
}
else if (strstr(str_key, "grpquota")){
_all_config->v_group.pfVectorAdd(&_all_config->v_group,_config);
}
}
}
}

@ -62,7 +62,7 @@ char* save_format_status_cmd_all(vector* vec_temp, vector* vec_status_disk) {
return cmd;
}
char* set_status_and_del(config_all* _all_config) {
char* set_status_and_del(config_all* _all_config, char* key_del) {
char* cmd = yon_char_new("");
for (int j=0; j < _all_config->v_disk_status.vectorList.total;j++) {
disk_status* config_disk_status = (disk_status*)_all_config->v_disk_status.pfVectorGet(&_all_config->v_disk_status, j);
@ -70,28 +70,24 @@ char* set_status_and_del(config_all* _all_config) {
cmd = yon_char_unite(cmd, "DISK_QUOTA[usrquota:" , config_disk_status->device, "]=enable ", NULL);
cmd = yon_char_unite(cmd, "DISK_QUOTA[grpquota:" , config_disk_status->device, "]=enable ", NULL);
cmd = yon_char_unite(cmd, "DISK_QUOTA[prjquota:" , config_disk_status->device, "]=enable ", NULL);
yon_window_config_add_custom_parameter(config_disk_status->device, "deferring_size", NULL, YON_TYPE_INT);
yon_window_config_add_custom_parameter(config_disk_status->device, "deferring_file", NULL, YON_TYPE_INT);
yon_window_config_add_custom_parameter(config_disk_status->device, config_disk_status->device, NULL, YON_TYPE_STRING);
yon_window_config_erase_custom_parameter(config_disk_status->device, "deferring_size");
yon_window_config_erase_custom_parameter(config_disk_status->device, "deferring_file");
yon_window_config_erase_custom_parameter(config_disk_status->device, config_disk_status->device);
}
else if (config_disk_status->status == 1) {
cmd = yon_char_unite(cmd, "DISK_QUOTA[usrquota:" , config_disk_status->device, "]=disable ", NULL);
cmd = yon_char_unite(cmd, "DISK_QUOTA[grpquota:" , config_disk_status->device, "]=disable ", NULL);
cmd = yon_char_unite(cmd, "DISK_QUOTA[prjquota:" , config_disk_status->device, "]=disable ", NULL);
yon_window_config_add_custom_parameter(config_disk_status->device, "deferring_size", NULL, YON_TYPE_INT);
yon_window_config_add_custom_parameter(config_disk_status->device, "deferring_file", NULL, YON_TYPE_INT);
yon_window_config_add_custom_parameter(config_disk_status->device, config_disk_status->device, NULL, YON_TYPE_STRING);
yon_window_config_erase_custom_parameter(config_disk_status->device, "deferring_size");
yon_window_config_erase_custom_parameter(config_disk_status->device, "deferring_file");
yon_window_config_erase_custom_parameter(config_disk_status->device, config_disk_status->device);
}
if (config_disk_status->status == 2 && (config_disk_status->deferring_size != 0 || config_disk_status->deferring_file != 0)) {
cmd = yon_char_unite(cmd, "DISK_QUOTA[usrquota:" , config_disk_status->device, "]=0:0:0:0:",yon_char_from_int(config_disk_status->deferring_size), ":", yon_char_from_int(config_disk_status->deferring_file)," ", NULL);
cmd = yon_char_unite(cmd, "DISK_QUOTA[grpquota:" , config_disk_status->device, "]=0:0:0:0:",yon_char_from_int(config_disk_status->deferring_size), ":", yon_char_from_int(config_disk_status->deferring_file)," ", NULL);
cmd = yon_char_unite(cmd, "DISK_QUOTA[prjquota:" , config_disk_status->device, "]=0:0:0:0:",yon_char_from_int(config_disk_status->deferring_size), ":", yon_char_from_int(config_disk_status->deferring_file)," ", NULL);
yon_window_config_add_custom_parameter(config_disk_status->device, "deferring_size", &config_disk_status->deferring_size, YON_TYPE_INT);
yon_window_config_add_custom_parameter(config_disk_status->device, "deferring_file", &config_disk_status->deferring_file, YON_TYPE_INT);
yon_window_config_add_custom_parameter(config_disk_status->device, config_disk_status->device, config_disk_status->device, YON_TYPE_STRING);
cmd = yon_char_unite(cmd, "DISK_QUOTA[usrquota:", config_disk_status->device, "]=0:0:0:0:",yon_char_from_int(config_disk_status->deferring_size), ":", yon_char_from_int(config_disk_status->deferring_file)," ", NULL);
cmd = yon_char_unite(cmd, "DISK_QUOTA[grpquota:", config_disk_status->device, "]=0:0:0:0:",yon_char_from_int(config_disk_status->deferring_size), ":", yon_char_from_int(config_disk_status->deferring_file)," ", NULL);
cmd = yon_char_unite(cmd, "DISK_QUOTA[prjquota:", config_disk_status->device, "]=0:0:0:0:",yon_char_from_int(config_disk_status->deferring_size), ":", yon_char_from_int(config_disk_status->deferring_file)," ", NULL);
}
}
puts(cmd);
return cmd;
}
@ -103,7 +99,7 @@ char* wrapper_save_format_status_cmd_all(config_all* _all_config) {
// return cmd;
//}
//else {
return set_status_and_del(_all_config);
return set_status_and_del(_all_config);
//}
}
@ -156,6 +152,9 @@ char* template_format_remove_save_device(config_all* _all_config, char* source_r
cmd = yon_char_unite(cmd, " DISK_QUOTA[usrquota:" , str_del, "] ", NULL);
cmd = yon_char_unite(cmd, " DISK_QUOTA[grpquota:" , str_del, "] ", NULL);
cmd = yon_char_unite(cmd, " DISK_QUOTA[prjquota:" , str_del, "] ", NULL);
yon_window_config_erase_custom_parameter(str_del, "deferring_size");
yon_window_config_erase_custom_parameter(str_del, "deferring_file");
yon_window_config_erase_custom_parameter(str_del, str_del);
}
}

@ -220,6 +220,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end
enum YON_TYPE{
YON_TYPE_STRING,
YON_TYPE_INT,
YON_TYPE_STRING_LIST,
YON_TYPE_BOOLEAN,
YON_TYPE_OTHER
};
@ -255,6 +256,8 @@ void yon_window_config_add_custom_parameter(char *param_name, char *section, voi
void yon_window_config_erase_custom_parameter(char *param_name, char *section);
int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type);
int yon_gtk_combo_box_fill(GtkWidget *combo, char **parameters,int size);
int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find);

@ -203,6 +203,9 @@ void view_device_get_gui_data() {
}
else {
if (status_id == 0) {
yon_window_config_erase_custom_parameter(_config->device, "deferring_size");
yon_window_config_erase_custom_parameter(_config->device, "deferring_file");
yon_window_config_erase_custom_parameter(_config->device, _config->device);
model_search_disk_remove(&view_device_all_config_temp->v_user, &view_device_all_config_temp->v_remove, _config->device);
model_search_disk_remove(&view_device_all_config_temp->v_group, &view_device_all_config_temp->v_remove, _config->device);
model_search_disk_remove_project(&view_device_all_config_temp->v_project,&view_device_all_config_temp->v_disk_status, &view_device_all_config_temp->v_remove, _config->device);

Loading…
Cancel
Save