diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c
index 32eb766..613dbc6 100644
--- a/source/ubl-settings-resourcequota.c
+++ b/source/ubl-settings-resourcequota.c
@@ -260,7 +260,7 @@ void load_global_cfg() {
void template_cfg(char* cmd) {
int size = 0;
- int index = 0;
+ int index_quotas = 0;
char** cfg = yon_config_load(cmd, &size);
for (int index = 0; index < size; index++) {
char* str_key_value = yon_char_new(cfg[index]);
@@ -271,12 +271,73 @@ 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, index_quotas);
str_split_value(str_key_value, index);
- index++;
+ index_quotas++;
}
}
+ if (index_quotas != 0) {
+ fill_tree_view(0, size);
+ }
+
+
+}
+void str_split_key(char* value, int index) {
+ yon_char_divide_search(value, "[", -1);
+ value = yon_char_divide_search(value, "]", -1);
+ if (strstr(value, ".") != NULL) {
+ if (strstr(value, ".slice") != NULL) {
+ 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, 4);
+ index--;
+ main_config.quota_volume = yon_char_parsed_append(main_config.type_quota, &index, STR_PROCESS);
+ index--;
+ }
+ else if (strstr(value, ".service") != NULL) {
+ 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, 3);
+ index--;
+ main_config.quota_volume = yon_char_parsed_append(main_config.type_quota, &index, STR_SLICE);
+ 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.quota_volume = yon_char_parsed_append(main_config.type_quota, &index, "-");
+ index--;
+ }
+
+ }
+ else {
+ int user_size = 0;
+ 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);
+ index--;
+ main_config.quota_volume = yon_char_parsed_append(main_config.quota_volume, &index, value);
+ index--;
+ main_config.quota_volume = yon_char_parsed_append(main_config.type_quota, &index, STR_USER);
+ index--;
+ }
+ // Группа
+ else {
+ 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--;
+ main_config.quota_volume = yon_char_parsed_append(main_config.type_quota, &index, STR_GROUP);
+ index--;
+ }
+ }
+ }
+
}
-
void str_split_value(char* values, int index) {
char* new_value = yon_char_new(values);
int size = 0;
@@ -358,6 +419,11 @@ void set_pow_size(char* str_find, int* array_size, char** array_data , int index
index--;
}
if (strstr(str_find,"-") == NULL) {
+ if (str_find[0] == '\"') {
+ yon_char_divide(str_find, 0);
+ size_t length = strlen(str_find);
+ str_find = yon_char_divide(str_find, length-2);
+ }
size_t length = strlen(str_find);
str_find = yon_char_divide(str_find, length-2);
array_data = yon_char_parsed_append(array_data, &index, str_find);
@@ -365,16 +431,6 @@ void set_pow_size(char* str_find, int* array_size, char** array_data , int index
else {
array_data = yon_char_parsed_append(array_data, &index, "-");
}
- GtkTreeIter iter;
- gtk_list_store_append(main_config.list,&iter);
- gtk_list_store_set(main_config.list,&iter,0,main_config.type_quota[index],
- 1,main_config.quota_volume[index],
- 2,main_config.soft_raw_limit[index],
- 3,main_config.hard_raw_limit[index],
- 4,main_config.swap[index],
- 5,main_config.cpu_limit[index],
- 6,main_config.i_o_limit_read[index],
- 7,main_config.i_o_limit_write[index],-1);
}
@@ -453,6 +509,11 @@ void tree_view_add(int index) {
main_config.i_o_limit_read_size = philos_int_append(main_config.i_o_limit_read_size, &main_config.size_tree_view, add_get_read_device_size());
main_config.size_tree_view--;
main_config.i_o_limit_write_size = philos_int_append(main_config.i_o_limit_write_size, &main_config.size_tree_view, add_get_write_device_size());
+ fill_tree_view(main_config.size_tree_view-1, main_config.size_tree_view);
+}
+
+void fill_tree_view(int start, int size) {
+ for (int index = start; index < size; index++) {
GtkTreeIter iter;
gtk_list_store_append(main_config.list,&iter);
gtk_list_store_set(main_config.list,&iter,0,main_config.type_quota[index],
@@ -463,7 +524,9 @@ void tree_view_add(int index) {
5,main_config.cpu_limit[index],
6,main_config.i_o_limit_read[index],
7,main_config.i_o_limit_write[index],-1);
+ }
}
+
int tree_view_edit() {
int index = 0;
GtkTreeIter iter;
diff --git a/source/ubl-settings-resourcequota.h b/source/ubl-settings-resourcequota.h
index f9e6314..57a56b5 100755
--- a/source/ubl-settings-resourcequota.h
+++ b/source/ubl-settings-resourcequota.h
@@ -181,4 +181,6 @@ void load_system_cfg();
void load_global_cfg();
void template_cfg(char* cmd);
void str_split_value(char* values, int index);
-void set_pow_size(char* str_find, int* array_size, char** array_data, int index);
\ No newline at end of file
+void set_pow_size(char* str_find, int* array_size, char** array_data, int index);
+void str_split_key(char* value, int index);
+void fill_tree_view(int start, int size);
\ No newline at end of file
diff --git a/source/ubl-strings.h b/source/ubl-strings.h
index 2bc0e69..2d732c4 100644
--- a/source/ubl-strings.h
+++ b/source/ubl-strings.h
@@ -23,6 +23,10 @@
#define PROJECT_HOME_LABEL _("Project Home Page")
#define NOTHING_CHOSEN_LABEL _("Nothing were chosen")
+#define STR_USER _("User")
+#define STR_GROUP _("Group")
+#define STR_PROCESS _("Process")
+#define STR_SLICE _("Slice")
#define GLOBAL_LOAD_SUCCESS _("Global configuration loading succseeded.")
#define LOCAL_LOAD_SUCCESS _("Local configuration loading succseeded.")
diff --git a/ubl-settings-resourcequota.glade b/ubl-settings-resourcequota.glade
index f16fa4c..c9045b9 100644
--- a/ubl-settings-resourcequota.glade
+++ b/ubl-settings-resourcequota.glade
@@ -2736,9 +2736,10 @@ translated and supported by community.
640
500
False
- 800
- 600
+ 700
+ 500
com.ublinux.ubl-settings-resourcequota
+ center