From 2fca6f8589b20e99b924bc42bb84e9604bfd09c9 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Tue, 18 Jul 2023 15:29:22 +0600 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=BE=D1=81=D0=BD=D0=BE=D0=B2=D0=BD=D0=BE?= =?UTF-8?q?=D0=B5=20=D0=BE=D0=BA=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 37 +++++-------- gdb.policy | 24 +++++++++ source/controler.c | 93 +++++++++++++++++++++++++++++---- source/controler.h | 3 +- source/model/model.c | 16 +++--- source/model/philos_utils.c | 6 ++- source/model/philos_utils.h | 3 +- source/ubl-settings-diskquota.c | 7 +++ source/ubl-settings-diskquota.h | 1 + ubl-settings-diskquota.glade | 26 ++------- 10 files changed, 148 insertions(+), 68 deletions(-) create mode 100644 gdb.policy diff --git a/Makefile b/Makefile index 82325bb..9e329df 100644 --- a/Makefile +++ b/Makefile @@ -8,13 +8,10 @@ MAKEFILE_PATH := $(dir $(MAKEFILE_FILEPATH)) CMAKE_COMMAND = cmake CMAKE_SOURCE_DIR = $(MAKEFILE_PATH)source CMAKE_BUILD_DIR = $(MAKEFILE_PATH)compile -#CMAKE_SOURCE_DIR = ./source -#CMAKE_BUILD_DIR = ./compile DEPENDS = /bin/cmake PREFIX ?= /usr PKGNAME = $(MAKEFILE_DIR) -#PKGNAME = ubl-settings-diskquota -LATEST_TAG= + default_target: all .PHONY: all init depend debug prepare check build uninstall install clean help @@ -39,16 +36,15 @@ depend: exit 1; \ fi; \ done; \ + $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B${CMAKE_BUILD_DIR} --check-build-system CMakeFiles/Makefile.cmake 1 || exit 1; \ echo "Check depends: OK" -# $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 -debug: init build - @echo "Debug ..."; \ +debug: + @echo "Debug ..." if [ ! -d ${CMAKE_BUILD_DIR} ]; then \ $(CMAKE_COMMAND) -S${CMAKE_SOURCE_DIR} -B${CMAKE_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="${PREFIX}"; \ + @gcc source/ubl-settings-cmake.h compile/ubl-cmake.h source/ubl-settings-multiseat.c source/ubl-settings-multiseat.h source/ubl-settings-multiseat-strings.h source/ubl-utils.c source/ubl-utils.h -o ubl-settings-multiseat `pkg-config --cflags --libs gtk+-3.0 vte-2.91 webkit2gtk-4.0 webkit2gtk-web-extension-4.0` -g fi; \ - echo "${CMAKE_BUILD_DIR}/${PKGNAME}"; \ - cp ${CMAKE_BUILD_DIR}/${PKGNAME} ./; \ echo "Debug: OK" prepare: @@ -92,8 +88,8 @@ uninstall: @$(RM) "${DESTDIR}${PREFIX}/bin/${PKGNAME}" @$(RM) "${DESTDIR}${PREFIX}/share/applications/${PKGNAME}.desktop" @$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.svg" - @$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.checked.svg" - @$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.warning.svg" + @$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/com.ublinux.${PKGNAME}.checked.svg" + @$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/com.ublinux.${PKGNAME}.warning.svg" @$(RM) "${DESTDIR}${PREFIX}/share/polkit-1/actions/com.ublinux.${PKGNAME}.policy" @if [ -z ${DESTDIR} ]; then \ [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ @@ -121,15 +117,16 @@ install: check uninstall done @install -dm755 "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.checked.svg" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.warning.svg" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.funnel.svg" @install -dm755 "${DESTDIR}${PREFIX}/share/polkit-1/actions" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/polkit-1/actions/" "com.ublinux.${PKGNAME}.policy" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/polkit-1/actions/" "gdb.policy" @install -Dm755 -t "${DESTDIR}${PREFIX}/bin/" "${CMAKE_BUILD_DIR}/${PKGNAME}" @install -dm755 "${DESTDIR}/etc/xdg" @install -dm755 "${DESTDIR}${PREFIX}/share/applications" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.checked.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.warning.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.funnel.svg" @if [ -z ${DESTDIR} ]; then \ [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ update-desktop-database --quiet &>/dev/null || true; \ @@ -147,14 +144,6 @@ clean: echo "Clean: OK"; \ fi -up_ver: - @CURRENT=$$(grep 'VERSION' ${FILE_VERSION} | cut -d" " -f2); \ - MAJOR=$$(cut -d. -f1 <<< $${CURRENT}); \ - MINOR=$$(cut -d. -f2 <<< $${CURRENT}); \ - VER="$${MAJOR}.$$(($${MINOR}+1))"; \ - sed "s/VERSION *[[:digit:]]*.*/VERSION $${VER}/" -i ${FILE_VERSION}; \ - echo "Updated version to VERSION.md: $${CURRENT} to $${VER}" - help: @echo "The following are some of the valid targets for this Makefile:"; \ echo "... all (the default if no target is provided)"; \ @@ -164,5 +153,5 @@ help: echo "... compile"; \ echo "... install"; \ echo "... uninstall"; \ - echo "... clean"; \ - echo "... up_ver" + echo "... clean" + diff --git a/gdb.policy b/gdb.policy new file mode 100644 index 0000000..c1a7da0 --- /dev/null +++ b/gdb.policy @@ -0,0 +1,24 @@ + + + + + UBLinux + https://ublinux.ru + + + Run ubl-settings-diskquota as root + Запуск утилиты ubl-settings-diskquota с правами root + Authentication is required to run ubl-settings-diskquota + Требуется авторизация для запуска утилиты ubl-settings-diskquota с правами root + + auth_admin + auth_admin + auth_admin + + /usr/bin/gdb + true + + + diff --git a/source/controler.c b/source/controler.c index 42497cf..a8fecfa 100644 --- a/source/controler.c +++ b/source/controler.c @@ -34,7 +34,9 @@ void wrapper_add_user_show() { } void wrapper_edit_user_show() { int index = wrapper_select_tree_view(&cfg_custom_gui.user); - printf("%d\n", index); + char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(cfg_custom_gui.user.comboBox)); + activ_text= yon_char_divide_search(activ_text, " ", -1); + set_disk(activ_text); set_temp_menu("usrquota", "edit"); temp_set_index(index); set_all_config(all_config); @@ -58,6 +60,9 @@ void wrapper_add_group_show() { } void wrapper_edit_group_show() { int index = wrapper_select_tree_view(&cfg_custom_gui.group); + 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); + set_disk(activ_text); set_temp_menu("grpquota", "edit"); temp_set_index(index); set_all_config(all_config); @@ -111,9 +116,13 @@ void unlock_spin_time(hotebook* widgets,void (*f)()) { } void entry_user_disk(GtkWidget *self,int* flag_update) { + block_spin_time(&cfg_custom_gui.user, wrapper_get_spin_time_gui_user); if (flag_update) { + all_config->flag_set_data = 1; + all_config->flag_save = 3; temp_on_destroy_subwindow(self); } + get_status_disk(&cfg_custom_gui.user); char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(cfg_custom_gui.user.comboBox)); activ_text= yon_char_divide_search(activ_text, " ", -1); int find = fill_tree_view_user_group(all_config, activ_text, &cfg_custom_gui.user,"usrquota", 0); @@ -121,11 +130,18 @@ void entry_user_disk(GtkWidget *self,int* flag_update) { g_object_ref(cfg_custom_gui.user.liststore); gtk_list_store_clear(cfg_custom_gui.user.liststore); } + unlock_spin_time(&cfg_custom_gui.user, wrapper_get_spin_time_gui_user); + + } void entry_groups_disk(GtkWidget *self,int* flag_update) { + block_spin_time(&cfg_custom_gui.group, wrapper_get_spin_time_gui_group); if (flag_update) { + all_config->flag_set_data = 1; + all_config->flag_save = 3; temp_on_destroy_subwindow(self); } + get_status_disk(&cfg_custom_gui.group); 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); int find = fill_tree_view_user_group(all_config, activ_text, &cfg_custom_gui.group,"grpquota", 0); @@ -133,9 +149,13 @@ void entry_groups_disk(GtkWidget *self,int* flag_update) { g_object_ref(cfg_custom_gui.group.liststore); gtk_list_store_clear(cfg_custom_gui.group.liststore); } + unlock_spin_time(&cfg_custom_gui.group, wrapper_get_spin_time_gui_group); } -void entry_project_disk(GtkWidget *self,int* flag_update) { +void entry_project_disk(GtkWidget *self,int* flag_update) { + block_spin_time(&cfg_custom_gui.project, wrapper_get_spin_time_gui_project); if (flag_update) { + all_config->flag_set_data = 1; + all_config->flag_save = 3; temp_on_destroy_subwindow(self); } int find = fill_tree_view_project(all_config, &cfg_custom_gui.project,"prjquota", 0); @@ -143,6 +163,7 @@ void entry_project_disk(GtkWidget *self,int* flag_update) { g_object_ref(cfg_custom_gui.project.liststore); gtk_list_store_clear(cfg_custom_gui.project.liststore); } + unlock_spin_time(&cfg_custom_gui.project, wrapper_get_spin_time_gui_project); } void tree_view_select_user(GtkWidget* self) { @@ -218,10 +239,12 @@ void template_remove(vector* vec_temp, hotebook* widgets) { int index = wrapper_select_tree_view(widgets); if (index!=-1) { config_u_g_p* _config = (config_u_g_p*)vec_temp->pfVectorGet(vec_temp, index); + char* load_key = yon_char_new(_config->loaded_keys); + all_config->v_remove.pfVectorAdd(&all_config->v_remove, load_key); model_clear_cfg(_config); vec_temp->pfVectorDelete(vec_temp, index); - } - + all_config->flag_save = 1; + } } void user_remove() { @@ -231,7 +254,7 @@ void user_remove() { if(gtk_tree_selection_get_selected(selection, &model, &iter)) { gtk_list_store_remove(cfg_custom_gui.user.liststore, &iter); } - template_remove(&all_config->v_user , &cfg_custom_gui.user); + template_remove(&all_config->v_user, &cfg_custom_gui.user); } void group_remove() { @@ -255,9 +278,7 @@ void project_remove() { } int wrapper_select_tree_view(hotebook* widgets) { - block_spin_time(widgets, wrapper_get_spin_time_gui_user); - block_spin_time(widgets, wrapper_get_spin_time_gui_group); - block_spin_time(widgets, wrapper_get_spin_time_gui_project); + int index = 0; GtkTreeIter iter; GtkTreeModel *model = GTK_TREE_MODEL(widgets->liststore); @@ -270,9 +291,6 @@ int wrapper_select_tree_view(hotebook* widgets) { else { //index_selected = -1; } - unlock_spin_time(widgets, wrapper_get_spin_time_gui_user); - unlock_spin_time(widgets, wrapper_get_spin_time_gui_group); - unlock_spin_time(widgets, wrapper_get_spin_time_gui_project); return index; } @@ -377,6 +395,59 @@ void control_event(main_window* _config_main_gui, custom_window* _config_custom_ g_signal_connect(G_OBJECT(_config_custom_gui->project.spinDaysFile), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_project), NULL); g_signal_connect(G_OBJECT(_config_custom_gui->project.spinHoursFile), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_project), NULL); g_signal_connect(G_OBJECT(_config_custom_gui->project.spinMinutesFile), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_project), NULL); + + g_signal_connect(G_OBJECT(_config_custom_gui->user.cmbSetStatusDisk), "changed", G_CALLBACK(template_set_status_disk), &_config_custom_gui->user); + g_signal_connect(G_OBJECT(_config_custom_gui->group.cmbSetStatusDisk), "changed", G_CALLBACK(template_set_status_disk), &_config_custom_gui->group); +} + + +void template_set_status_disk(GtkWidget* self,hotebook* widgets) { + int menu_id_disk = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->comboBox)); + int menu_id = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cmbSetStatusDisk)); + char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->comboBox)); + activ_text = yon_char_divide_search(activ_text, " ", -1); + vector* v_disk_status = &all_config->v_disk_status; + int flag = 0; + if (v_disk_status->vectorList.total> 0 && menu_id_disk >= 0 && menu_id >= 0) { + for (int i = 0; i < v_disk_status->pfVectorTotal(v_disk_status); i++) { + disk_status* _config = (disk_status*)v_disk_status->pfVectorGet(v_disk_status, i); + if (strstr(_config->device, activ_text) && strstr(_config->device,widgets->name)) { + flag = 1; + _config->status = menu_id; + all_config->flag_set_data = 1; + } + } + } + if (flag == 0) { + disk_status* disk_cfg = malloc(sizeof(disk_status)); + disk_cfg->device = yon_char_unite("DISK_QUOTA[",widgets->name,":",activ_text, "]",NULL); + disk_cfg->status = menu_id; + v_disk_status->pfVectorAdd(v_disk_status, disk_cfg); + all_config->flag_set_data = 1; + } +} + +void get_status_disk(hotebook* widgets) { + int menu_id_disk = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->comboBox)); + vector* v_disk_status = &all_config->v_disk_status; + if (v_disk_status->vectorList.total> 0 && menu_id_disk>=0) { + char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->comboBox)); + activ_text = yon_char_divide_search(activ_text, " ", -1); + int status = 0; + for (int i = 0; i < v_disk_status->pfVectorTotal(v_disk_status); i++) { + disk_status* _config = (disk_status*)v_disk_status->pfVectorGet(v_disk_status, i); + if (strstr(_config->device, activ_text) && strstr(_config->device,widgets->name)) { + status = 1; + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cmbSetStatusDisk), _config->status); + } + if (!status) { + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cmbSetStatusDisk), -1); + } + } + } + else { + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cmbSetStatusDisk), -1); + } } /* diff --git a/source/controler.h b/source/controler.h index acdb57e..e046f10 100644 --- a/source/controler.h +++ b/source/controler.h @@ -31,4 +31,5 @@ void get_spin_time_gui(vector* vec_u_g_p, hotebook* widgets); void tree_view_select(GtkWidget* self, vector* vec_temp, hotebook* widgets); void block_spin_time(hotebook* widgets,void (*f)()); void unlock_spin_time(hotebook* widgets,void (*f)()); - +void template_set_status_disk(GtkWidget* self, hotebook* widgets); +void get_status_disk(hotebook* widgets); diff --git a/source/model/model.c b/source/model/model.c index 2d1f083..65209cc 100644 --- a/source/model/model.c +++ b/source/model/model.c @@ -24,16 +24,16 @@ void model_null_str_writing(config_u_g_p* _config) { _config->files = yon_char_new(empty_str); _config->loaded_keys = yon_char_new(empty_str); _config->type_arr = yon_char_new(empty_str); - _config->id = -3; - _config->soft_restriction_size = -3; - _config->soft_restriction_file = -3; - _config->severe_limitation_size = -3; - _config->severe_limitation_file = -3; + _config->id = 0; + _config->soft_restriction_size = 0; + _config->soft_restriction_file = 0; + _config->severe_limitation_size = 0; + _config->severe_limitation_file = 0; _config->deferring_size = 0; _config->deferring_file = 0; - _config->size_memory_pow = -3; - _config->soft_restriction_size_pow = -3; - _config->severe_limitation_size_pow = -3; + _config->size_memory_pow = 0; + _config->soft_restriction_size_pow = 0; + _config->severe_limitation_size_pow = 0; vector_init(&_config->actors); } diff --git a/source/model/philos_utils.c b/source/model/philos_utils.c index 49d3d74..498f38c 100644 --- a/source/model/philos_utils.c +++ b/source/model/philos_utils.c @@ -263,6 +263,9 @@ char* philos_format_cfg_str_size_memory(char* str_key, int value, int pow_size_m return yon_char_new("-"); } char* str_value = yon_char_from_int(value); + if (value == 0) { + return str_value; + } if (pow_size_memory==0) { return yon_char_unite(str_key, str_value, "K" ,NULL); } @@ -717,7 +720,8 @@ void yon_int_array_append(int **source, int append){ * [RU] */ int philos_config_save(char *command) -{ +{ + puts(command); FILE *output = popen(command, "r"); return 1; } diff --git a/source/model/philos_utils.h b/source/model/philos_utils.h index 01268e5..1c755cb 100644 --- a/source/model/philos_utils.h +++ b/source/model/philos_utils.h @@ -76,6 +76,7 @@ typedef struct { } temp_set_window; typedef struct { + char* name; GtkListStore *liststore; GtkWidget* tree_view; GtkWidget* btnAdd; @@ -93,7 +94,7 @@ typedef struct { GtkWidget* spinDaysFile; GtkWidget* spinHoursFile; GtkWidget* spinMinutesFile; - + GtkWidget* cmbSetStatusDisk; GtkWidget* lblSetNameDevice; } hotebook; typedef struct { diff --git a/source/ubl-settings-diskquota.c b/source/ubl-settings-diskquota.c index 8257b02..8deca91 100644 --- a/source/ubl-settings-diskquota.c +++ b/source/ubl-settings-diskquota.c @@ -200,6 +200,10 @@ custom_window *setup_window_custom(custom_window* custom_widgets, GtkBuilder *bu custom_widgets->group.comboBox = yon_gtk_builder_get_widget(builder,"groupsDeviceCombo"); device_fill_disk(custom_widgets->user.comboBox); device_fill_disk(custom_widgets->group.comboBox); + custom_widgets->user.name = yon_char_new("usrquota"); + custom_widgets->group.name = yon_char_new("grpquota"); + custom_widgets->project.name = yon_char_new("grpquota"); + custom_widgets->user.btnAdd = yon_gtk_builder_get_widget(builder,"btnAddUsers"); custom_widgets->user.btnEdit = yon_gtk_builder_get_widget(builder,"btnEditUsers"); custom_widgets->user.btnDel = yon_gtk_builder_get_widget(builder,"btnDelUsers"); @@ -255,6 +259,9 @@ custom_window *setup_window_custom(custom_window* custom_widgets, GtkBuilder *bu custom_widgets->user.spinMinutesFile = yon_gtk_builder_get_widget(builder,"generalUsersFilesMinutesSpin"); custom_widgets->group.spinMinutesFile = yon_gtk_builder_get_widget(builder,"generalGroupsFilesMinuteSpin"); custom_widgets->project.spinMinutesFile = yon_gtk_builder_get_widget(builder,"generalProjectFilesMinutesSpin"); + + custom_widgets->user.cmbSetStatusDisk = yon_gtk_builder_get_widget(builder,"cmbUserSetStatus"); + custom_widgets->group.cmbSetStatusDisk = yon_gtk_builder_get_widget(builder,"cmbGroupSetStatus"); return custom_widgets; } diff --git a/source/ubl-settings-diskquota.h b/source/ubl-settings-diskquota.h index b325d67..baf9a8e 100755 --- a/source/ubl-settings-diskquota.h +++ b/source/ubl-settings-diskquota.h @@ -127,4 +127,5 @@ void config_init(config_settings_gui* main_config); int wrapper_select_tree_view(hotebook* widgets); int tree_view_edit(config_all* _all_config, vector* vec_temp, hotebook* widgets); void set_time_spin(hotebook* widgets, size_t seconds_file, size_t seconds_size); +void template_set_status_disk(GtkWidget* self,hotebook* widgets); #endif diff --git a/ubl-settings-diskquota.glade b/ubl-settings-diskquota.glade index a8bffe8..aba303d 100644 --- a/ubl-settings-diskquota.glade +++ b/ubl-settings-diskquota.glade @@ -379,6 +379,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False 5 5 + 0 True @@ -415,7 +416,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + True False 5 @@ -2271,7 +2272,7 @@ limitation - + True False 5 @@ -3190,7 +3191,7 @@ limitation - + True False 5 @@ -4069,25 +4070,6 @@ limitation True False vertical - - - True - False - 5 - 5 - 5 - 5 - - Off - Not set - - - - False - True - 0 - - True