From df37bfa768e90024bcd99f46c185c93ba13b2e6e Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 20 Nov 2023 08:48:33 +0600 Subject: [PATCH 01/39] Fixed allowing of journald log deletion from interface --- ubl-settings-logging.glade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubl-settings-logging.glade b/ubl-settings-logging.glade index f254aa1..0db3ab8 100644 --- a/ubl-settings-logging.glade +++ b/ubl-settings-logging.glade @@ -473,7 +473,7 @@ translated and supported by community. journald /var/log/journal/ System event log - False + True 0 -- 2.35.1 From 4384f60b571527b1292fa8bf5bcba0d94eded6c7 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 20 Nov 2023 09:14:50 +0600 Subject: [PATCH 02/39] Localisation for new status box messages --- source/ubl-settings-logging.c | 23 +++++++++- source/ubl-strings.h | 1 + ubl-settings-logging.pot | 65 ++++++--------------------- ubl-settings-logging_ru.po | 83 +++++++++++++++++++---------------- 4 files changed, 82 insertions(+), 90 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index dce0000..8c4eaae 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -582,6 +582,7 @@ void on_logrotate_period_check_toggled(GtkToggleButton *self,logrotate_configure void on_logrotate_save(GtkWidget *self, dictionary *dict){ logrotate_window *dialog = yon_dictionary_get_data(dict->first,logrotate_window*); logrotate_configure_window *window = yon_dictionary_get_data(dict->first->next,logrotate_configure_window*); + char *log_name=""; char *paths=""; char *period=""; char *size=""; @@ -618,6 +619,13 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ config_str found_paths_list=NULL; int found_paths=0; char *cur_check_paths; + log_name = (char*)gtk_entry_get_text(GTK_ENTRY(window->LogNameEntry)); + if (!strcmp(log_name,"")){ + yon_ubl_status_highlight_incorrect(window->LogNameEntry); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + return; + } + int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(main_config.logrotate_list),&iter); for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(main_config.logrotate_list),&iter)){ gtk_tree_model_get(GTK_TREE_MODEL(main_config.logrotate_list),&iter,1,&cur_check_paths,-1); @@ -625,6 +633,11 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ else found_paths_list = yon_char_parsed_append(found_paths_list,&found_paths,cur_check_paths); } valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&iter); + if (!valid) { + yon_ubl_status_highlight_incorrect(gtk_widget_get_parent(window->LogPathsTree)); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + return; + } for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&iter)){ char *cur_path; gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,0,&cur_path,-1); @@ -634,12 +647,13 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ path_amount++; paths = yon_char_unite(paths,strcmp(paths,"") ? "," : "", cur_path,NULL); } - if(!window->paths) + if(!window->paths) { if (matched==path_amount) { yon_ubl_status_highlight_incorrect(gtk_widget_get_parent(window->LogPathsTree)); yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEATED_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); return; } + } if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->RotationPeriodCheck))){ int active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo)); switch (active){ @@ -789,6 +803,11 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ char *endwork = (char*)gtk_entry_get_text(GTK_ENTRY(window->EndworkCommandEntry)); sharedscripts = "sharedscripts"; if (!yon_char_is_empty(before_once)) { + if (strcmp(before_once,",")){ + yon_ubl_status_highlight_incorrect(window->CommandBeforeOnceEntry); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + return; + } before_once = yon_char_replace(before_once,"\"","=--"); before_once = yon_char_replace(before_once,"=--","\\\""); firstaction = yon_char_append("firstaction,",before_once); @@ -834,7 +853,7 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ gtk_list_store_append(main_config.logrotate_list,&iter); } paths=yon_char_replace(paths,",","\n"); - gtk_list_store_set(main_config.logrotate_list,&iter,0,gtk_entry_get_text(GTK_ENTRY(window->LogNameEntry)),1,paths,2,gtk_entry_get_text(GTK_ENTRY(window->LogDescriptionEntry)),-1); + gtk_list_store_set(main_config.logrotate_list,&iter,0,log_name,1,paths,2,gtk_entry_get_text(GTK_ENTRY(window->LogDescriptionEntry)),-1); on_close_subwindow(window->MainWindow); } } diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 1548a3f..25b3eab 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -175,6 +175,7 @@ #define SATURDAY_LABEL _("Saturday") #define SUNDAY_LABEL _("Sunday*") #define REPEATED_PATHS_LABEL _("Same record already exists") +#define EMPTY_IMPORTANT_LABEL _("Empty important field") //ubl-settings-logging-logrotate-table.glade #define SYSTEM_CONFIGURATION_LABEL _("System configuration") diff --git a/ubl-settings-logging.pot b/ubl-settings-logging.pot index 1601a18..1f8f92a 100644 --- a/ubl-settings-logging.pot +++ b/ubl-settings-logging.pot @@ -687,71 +687,34 @@ msgstr "" msgid "Sunday*" msgstr "" -#: source/ubl-strings.h:179 -msgid "System configuration" +#: source/ubl-strings.h:177 +msgid "Same record already exists" msgstr "" -#: source/ubl-strings.h:180 -msgid "Applications configuration" +#: source/ubl-strings.h:178 +msgid "Empty important field" msgstr "" -#: source/ubl-strings.h:183 -msgid "Path (-s):" +#: source/ubl-strings.h:181 +msgid "System configuration" msgstr "" -#: source/ubl-strings.h:184 -msgid "Control:" +#: source/ubl-strings.h:182 +msgid "Applications configuration" msgstr "" #: source/ubl-strings.h:185 -msgid "Log file" +msgid "Path (-s):" msgstr "" #: source/ubl-strings.h:186 -msgid "Name:" -msgstr "" - -msgid "System event log rotation service" -msgstr "" - -msgid "System event log" -msgstr "" - -msgid "Service for collecting messages from system events of active network devices" -msgstr "" - -msgid "Log of work and requests to Acpid" -msgstr "" - -msgid "Log of work and requests to the web server" -msgstr "" - -msgid "Audit log" -msgstr "" - -msgid "Log of authorization procedures" -msgstr "" - -msgid "Job scheduler log (cron)" -msgstr "" - -msgid "Log of work and calls to the print server (cups)" -msgstr "" - -msgid "Log of operation and access to system services" -msgstr "" - -msgid "Log of work and access to Samba" -msgstr "" - -msgid "Postfix mail server log" -msgstr "" - -msgid "System log" +msgid "Control:" msgstr "" -msgid "X.org display server log" +#: source/ubl-strings.h:187 +msgid "Log file" msgstr "" -msgid "Graphics X session log" +#: source/ubl-strings.h:188 +msgid "Name:" msgstr "" diff --git a/ubl-settings-logging_ru.po b/ubl-settings-logging_ru.po index a6d2aa8..8d273f0 100644 --- a/ubl-settings-logging_ru.po +++ b/ubl-settings-logging_ru.po @@ -701,72 +701,81 @@ msgstr "Суббота" msgid "Sunday*" msgstr "Воскресенье*" -#: source/ubl-strings.h:179 +#: source/ubl-strings.h:177 +msgid "Same record already exists" +msgstr "Журнал с такими путями уже добавлен" + +#: source/ubl-strings.h:178 +msgid "Empty important field" +msgstr "Важное поле не заполнено" + +#: source/ubl-strings.h:181 msgid "System configuration" msgstr "Настройки системы" -#: source/ubl-strings.h:180 +#: source/ubl-strings.h:182 msgid "Applications configuration" msgstr "Настройки приложений" -#: source/ubl-strings.h:183 +#: source/ubl-strings.h:185 msgid "Path (-s):" msgstr "Путь (-и):" -#: source/ubl-strings.h:184 +#: source/ubl-strings.h:186 msgid "Control:" msgstr "Управление:" -#: source/ubl-strings.h:185 +#: source/ubl-strings.h:187 msgid "Log file" msgstr "Файл лога" -#: source/ubl-strings.h:186 +#: source/ubl-strings.h:188 msgid "Name:" msgstr "Имя:" -msgid "System event log rotation service" -msgstr "Служба ротации системных журналов событий" +#~ msgid "System event log rotation service" +#~ msgstr "Служба ротации системных журналов событий" -msgid "System event log" -msgstr "Системный журнал событий" +#~ msgid "System event log" +#~ msgstr "Системный журнал событий" -msgid "" -"Service for collecting messages from system events of active network devices" -msgstr "Сервис сбора сообщений системных событий активных сетевых устройств" +#~ msgid "" +#~ "Service for collecting messages from system events of active network " +#~ "devices" +#~ msgstr "Сервис сбора сообщений системных событий активных сетевых устройств" -msgid "Log of work and requests to Acpid" -msgstr "Журнал работы и обращений к Acpid" +#~ msgid "Log of work and requests to Acpid" +#~ msgstr "Журнал работы и обращений к Acpid" -msgid "Log of work and requests to the web server" -msgstr "Журнал работы и обращений к веб-серверу" +#~ msgid "Log of work and requests to the web server" +#~ msgstr "Журнал работы и обращений к веб-серверу" -msgid "Audit log" -msgstr "Журнал аудита (audit)" +#~ msgid "Audit log" +#~ msgstr "Журнал аудита (audit)" -msgid "Log of authorization procedures" -msgstr "Журнал процедур авторизации" +#~ msgid "Log of authorization procedures" +#~ msgstr "Журнал процедур авторизации" -msgid "Job scheduler log (cron)" -msgstr "Журнал работы планировщика заданий (cron)" +#~ msgid "Job scheduler log (cron)" +#~ msgstr "Журнал работы планировщика заданий (cron)" -msgid "Log of work and calls to the print server (cups)" -msgstr "Журнал работы и обращений к серверу печати (cups)" +#~ msgid "Log of work and calls to the print server (cups)" +#~ msgstr "Журнал работы и обращений к серверу печати (cups)" -msgid "Log of operation and access to system services" -msgstr "Журнал работы и обращения к службам системы" +#~ msgid "Log of operation and access to system services" +#~ msgstr "Журнал работы и обращения к службам системы" -msgid "Log of work and access to Samba" -msgstr "Журнал работы и обращения к Samba" +#~ msgid "Log of work and access to Samba" +#~ msgstr "Журнал работы и обращения к Samba" -msgid "Postfix mail server log" -msgstr "Журнал почтового сервера Postfix" +#~ msgid "Postfix mail server log" +#~ msgstr "Журнал почтового сервера Postfix" -msgid "System log" -msgstr "Системный журнал" +#~ msgid "System log" +#~ msgstr "Системный журнал" -msgid "X.org display server log" -msgstr "Журнал работы дисплейного сервера X.org" +#~ msgid "X.org display server log" +#~ msgstr "Журнал работы дисплейного сервера X.org" -msgid "Graphics X session log" -msgstr "Журнал сеансов графической системы X" +#~ msgid "Graphics X session log" +#~ msgstr "Журнал сеансов графической системы X" -- 2.35.1 From 808d3b631833870c410db41f9cd575c450068107 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 20 Nov 2023 09:17:20 +0600 Subject: [PATCH 03/39] Localisation for new status box messages --- ubl-settings-logging.pot | 45 +++++++++++++++++++++++++++ ubl-settings-logging_ru.po | 64 +++++++++++++++++++------------------- 2 files changed, 77 insertions(+), 32 deletions(-) diff --git a/ubl-settings-logging.pot b/ubl-settings-logging.pot index 1f8f92a..6ddb592 100644 --- a/ubl-settings-logging.pot +++ b/ubl-settings-logging.pot @@ -718,3 +718,48 @@ msgstr "" #: source/ubl-strings.h:188 msgid "Name:" msgstr "" + +msgid "System event log rotation service" +msgstr "" + +msgid "System event log" +msgstr "" + +msgid "Service for collecting messages from system events of active network devices" +msgstr "" + +msgid "Log of work and requests to Acpid" +msgstr "" + +msgid "Log of work and requests to the web server" +msgstr "" + +msgid "Audit log" +msgstr "" + +msgid "Log of authorization procedures" +msgstr "" + +msgid "Job scheduler log (cron)" +msgstr "" + +msgid "Log of work and calls to the print server (cups)" +msgstr "" + +msgid "Log of operation and access to system services" +msgstr "" + +msgid "Log of work and access to Samba" +msgstr "" + +msgid "Postfix mail server log" +msgstr "" + +msgid "System log" +msgstr "" + +msgid "X.org display server log" +msgstr "" + +msgid "Graphics X session log" +msgstr "" diff --git a/ubl-settings-logging_ru.po b/ubl-settings-logging_ru.po index 8d273f0..19cc083 100644 --- a/ubl-settings-logging_ru.po +++ b/ubl-settings-logging_ru.po @@ -733,49 +733,49 @@ msgstr "Файл лога" msgid "Name:" msgstr "Имя:" -#~ msgid "System event log rotation service" -#~ msgstr "Служба ротации системных журналов событий" +msgid "System event log rotation service" +msgstr "Служба ротации системных журналов событий" -#~ msgid "System event log" -#~ msgstr "Системный журнал событий" +msgid "System event log" +msgstr "Системный журнал событий" -#~ msgid "" -#~ "Service for collecting messages from system events of active network " -#~ "devices" -#~ msgstr "Сервис сбора сообщений системных событий активных сетевых устройств" +msgid "" +"Service for collecting messages from system events of active network " +"devices" +msgstr "Сервис сбора сообщений системных событий активных сетевых устройств" -#~ msgid "Log of work and requests to Acpid" -#~ msgstr "Журнал работы и обращений к Acpid" +msgid "Log of work and requests to Acpid" +msgstr "Журнал работы и обращений к Acpid" -#~ msgid "Log of work and requests to the web server" -#~ msgstr "Журнал работы и обращений к веб-серверу" +msgid "Log of work and requests to the web server" +msgstr "Журнал работы и обращений к веб-серверу" -#~ msgid "Audit log" -#~ msgstr "Журнал аудита (audit)" +msgid "Audit log" +msgstr "Журнал аудита (audit)" -#~ msgid "Log of authorization procedures" -#~ msgstr "Журнал процедур авторизации" +msgid "Log of authorization procedures" +msgstr "Журнал процедур авторизации" -#~ msgid "Job scheduler log (cron)" -#~ msgstr "Журнал работы планировщика заданий (cron)" +msgid "Job scheduler log (cron)" +msgstr "Журнал работы планировщика заданий (cron)" -#~ msgid "Log of work and calls to the print server (cups)" -#~ msgstr "Журнал работы и обращений к серверу печати (cups)" +msgid "Log of work and calls to the print server (cups)" +msgstr "Журнал работы и обращений к серверу печати (cups)" -#~ msgid "Log of operation and access to system services" -#~ msgstr "Журнал работы и обращения к службам системы" +msgid "Log of operation and access to system services" +msgstr "Журнал работы и обращения к службам системы" -#~ msgid "Log of work and access to Samba" -#~ msgstr "Журнал работы и обращения к Samba" +msgid "Log of work and access to Samba" +msgstr "Журнал работы и обращения к Samba" -#~ msgid "Postfix mail server log" -#~ msgstr "Журнал почтового сервера Postfix" +msgid "Postfix mail server log" +msgstr "Журнал почтового сервера Postfix" -#~ msgid "System log" -#~ msgstr "Системный журнал" +msgid "System log" +msgstr "Системный журнал" -#~ msgid "X.org display server log" -#~ msgstr "Журнал работы дисплейного сервера X.org" +msgid "X.org display server log" +msgstr "Журнал работы дисплейного сервера X.org" -#~ msgid "Graphics X session log" -#~ msgstr "Журнал сеансов графической системы X" +msgid "Graphics X session log" +msgstr "Журнал сеансов графической системы X" -- 2.35.1 From 718c53320dc6b811aeda5579da79ebc9c6467ccf Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 20 Nov 2023 09:44:00 +0600 Subject: [PATCH 04/39] Fixed Saving --- source/ubl-settings-logging.c | 2 ++ source/ubl-utils.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 8c4eaae..a3b682c 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1439,6 +1439,7 @@ void on_journald_save(GtkWidget *self, journald_window *window){ TTY = (char*)gtk_entry_get_text(GTK_ENTRY(window->RedirectTTYEntry)); if (yon_char_is_empty(TTY)) consoleforwardactive=0; + else } else if (consoleforwardactive == 2){ confor = "no"; @@ -1460,6 +1461,7 @@ void on_journald_save(GtkWidget *self, journald_window *window){ yon_config_remove_by_key(JOURNALD("SplitMode")); if (consoleforwardactive != 0) yon_config_register(JOURNALD("ForwardToConsole"),"logging",confor); + yon_config_register(JOURNALD("TTYPath"),"logging",TTY); else yon_config_remove_by_key(JOURNALD("ForwardToConsole")); if (forwardempty!=0) diff --git a/source/ubl-utils.c b/source/ubl-utils.c index c7b87c4..b405491 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1350,7 +1350,7 @@ int yon_config_save_registered(char *path){ if (dct->data&&strcmp(yon_dictionary_get_data(dct,char*),"")!=0){ if (((yon_config_parameter*)dct)->flag1==1){ ((yon_config_parameter*)dct)->flag1=0; - if (sections_add&&yon_dictionary_get(§ions_add,((yon_config_parameter*)dct)->section)) sections_add->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_add,char*)," ",dct->key,"=",yon_dictionary_get_data(dct,char*),NULL); + if (sections_add&&yon_dictionary_get(§ions_add,((yon_config_parameter*)dct)->section)) sections_add->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_add,char*)," ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL); else yon_dictionary_add_or_create_if_exists_with_data(sections_add,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " set ", ((yon_config_parameter*)dct)->section, " ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL)); } else if (((yon_config_parameter*)dct)->flag1==-1){ ((yon_config_parameter*)dct)->flag1=0; -- 2.35.1 From 3a50336886a8d48aa756033309985396b4109a96 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 20 Nov 2023 09:52:21 +0600 Subject: [PATCH 05/39] Fixed journald configuration loading --- source/ubl-settings-logging.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index a3b682c..cb41a88 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -143,7 +143,7 @@ void update_loaded_logrotate(){ } int yon_load_proceed(YON_CONFIG_TYPE type){ - if (yon_config_load_register(type,"logging",LOGROTATE("*"),JOURNALD("*"),NULL)){ + if (yon_config_load_register(type,"logging",LOGROTATE("*"),"logging",JOURNALD("*"),NULL)){ update_loaded_logrotate(); return 1; } @@ -1439,7 +1439,6 @@ void on_journald_save(GtkWidget *self, journald_window *window){ TTY = (char*)gtk_entry_get_text(GTK_ENTRY(window->RedirectTTYEntry)); if (yon_char_is_empty(TTY)) consoleforwardactive=0; - else } else if (consoleforwardactive == 2){ confor = "no"; @@ -1459,11 +1458,13 @@ void on_journald_save(GtkWidget *self, journald_window *window){ yon_config_register(JOURNALD("SplitMode"),"logging",splitmode); else yon_config_remove_by_key(JOURNALD("SplitMode")); - if (consoleforwardactive != 0) + if (consoleforwardactive != 0){ yon_config_register(JOURNALD("ForwardToConsole"),"logging",confor); yon_config_register(JOURNALD("TTYPath"),"logging",TTY); - else + } else { yon_config_remove_by_key(JOURNALD("ForwardToConsole")); + yon_config_register(JOURNALD("TTYPath"),"logging",TTY); + } if (forwardempty!=0) yon_config_register(JOURNALD("MaxLevelConsole"),"logging",yon_char_from_int(forwardempty-1)); else -- 2.35.1 From 4b8107d63b97d67c9cb4b354fb5bc9201645e7fb Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 20 Nov 2023 10:06:00 +0600 Subject: [PATCH 06/39] Fixed ability to services management without root --- source/ubl-settings-logging.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index cb41a88..3b97510 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1514,7 +1514,8 @@ journald_window *yon_journald_open(GtkWidget *self, main_window *widgets){ { int sz; config_str logsize = yon_config_load(journald_size_command,&sz); - gtk_label_set_text(GTK_LABEL(window->LogSizeLabel),logsize[0]); + if (logsize) + gtk_label_set_text(GTK_LABEL(window->LogSizeLabel),logsize[0]); } gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); @@ -1869,6 +1870,13 @@ void on_main_window_tree_selection_changed(GtkWidget *self,main_window *widgets) void on_main_window_services_tree_selection_changed(GtkWidget *self,main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->ServicesList); GtkTreeIter iter; + if (getuid()!=0){ + gtk_widget_set_sensitive(widgets->ServicesEditButton,0); + gtk_widget_set_sensitive(widgets->ServicesEnableDisableButton,0); + gtk_widget_set_sensitive(widgets->ServicesStartStopButton,0); + return; + } + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->ServicesTree)),&model,&iter)){ gboolean is_active; gboolean is_enabled; -- 2.35.1 From 89de8fe070aadf7cc0865aaceafe8f86d401e284 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 20 Nov 2023 10:08:47 +0600 Subject: [PATCH 07/39] Fixed ability to manage services via journals tab configuration --- source/ubl-settings-logging.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 3b97510..c6b61d9 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1758,14 +1758,22 @@ void on_log_edit(GtkWidget *self,main_window *widgets){ int protect; gtk_tree_model_get(model,&iter,0,&name,1,&paths,2,&description,3,&is_standard,4,&protect,-1); gtk_entry_set_text(GTK_ENTRY(window->NameEntry),name); + if(getuid()!=0){ + gtk_widget_set_sensitive(window->SyslogButton,0); + gtk_widget_set_sensitive(window->MetalogButton,0); + gtk_widget_set_sensitive(window->JournaldButton,0); + gtk_widget_set_sensitive(window->LogrotateButton,0); + } if (!strcmp(name,"journald")){ gtk_widget_hide(window->LogrotateButton); gtk_widget_hide(window->MetalogButton); gtk_widget_hide(window->SyslogButton); gtk_widget_show(window->StatisticsFrame); + int sz; config_str logsize = yon_config_load(journald_size_command,&sz); - gtk_label_set_text(GTK_LABEL(window->LogSizeLabel),logsize[0]); + if (logsize) + gtk_label_set_text(GTK_LABEL(window->LogSizeLabel),logsize[0]); g_signal_connect(G_OBJECT(window->JournaldButton),"clicked", G_CALLBACK(on_journald_open),widgets); } else { gtk_widget_hide(window->JournaldButton); -- 2.35.1 From 3039ea1b55bea50bbc442b8169a91a9859b3a76f Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 20 Nov 2023 10:33:35 +0600 Subject: [PATCH 08/39] Fixed wrong SystemMaxUse journald property saving --- source/ubl-settings-logging.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index c6b61d9..b2fa289 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1393,18 +1393,10 @@ void on_journald_save(GtkWidget *self, journald_window *window){ } if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->LogSizeMaxCheck))){ - long logssize=-1; + long logssize=0; logssize = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->LogSizeMaxSpin)); int log_size_mod = gtk_combo_box_get_active(GTK_COMBO_BOX(window->LogSizeMaxCombo)); - for (int i=0;i0){ - float val; - int size; - val = yon_size_convert_automatic(logssize,&size); - yon_config_register(JOURNALD("SystemMaxUse"),"logging",yon_char_append(yon_char_from_float(val),yon_size_get_letter_from_int(size))); - } + yon_config_register(JOURNALD("SystemMaxUse"),"logging",yon_char_append(yon_char_from_long(logssize),yon_size_get_letter_from_int(log_size_mod))); } else yon_config_remove_by_key(JOURNALD("SystemMaxUse")); -- 2.35.1 From 5f7b86928801839748d561ec4a2d3bccae3c255c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 20 Nov 2023 17:23:34 +0600 Subject: [PATCH 09/39] Added functions for managing parameters for custom windows --- source/ubl-settings-logging.c | 44 ++++++++++---- source/ubl-utils.c | 110 +++++++++++++++++++++++++++++++--- source/ubl-utils.h | 6 ++ 3 files changed, 140 insertions(+), 20 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index b2fa289..58dc974 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -10,7 +10,9 @@ config main_config; * [RU] * Закрывает окно, в котором расположен виджет [self]. */ -void on_close_subwindow(GtkWidget *self){ +void on_close_subwindow(GtkWidget *self, char *window){ + if(window) + yon_window_config_custom_window_set(GTK_WINDOW(gtk_widget_get_toplevel(self)),window); gtk_widget_destroy(gtk_widget_get_toplevel(self)); } @@ -281,6 +283,7 @@ void on_inspector_open(GtkWidget *self, main_window *widgets){ window->UpdateButton=yon_gtk_builder_get_widget(builder,"UpdateButton"); window->LoggingTerminal=yon_gtk_builder_get_widget(builder,"LoggingTerminal"); window->JournalActionsBox=yon_gtk_builder_get_widget(builder,"JournalActionsBox"); + yon_window_config_custom_window_setup(GTK_WINDOW(window->MainWindow),"InspectorWindow"); gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); gtk_window_set_transient_for(GTK_WINDOW(window->MainWindow),GTK_WINDOW(widgets->Window)); GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); @@ -305,6 +308,7 @@ void on_inspector_open(GtkWidget *self, main_window *widgets){ g_signal_connect(G_OBJECT(window->ShowAllBootsButton),"clicked", G_CALLBACK(on_inspector_update),window); g_signal_connect(G_OBJECT(window->ShowAllUnitsButton),"clicked", G_CALLBACK(on_inspector_update),window); g_signal_connect(G_OBJECT(window->ShowInitTreeButton),"clicked", G_CALLBACK(on_inspector_update),window); + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ gtk_tree_model_get(model,&iter,0,&name,1,&paths,-1); if (strcmp(name,"journald")){ @@ -455,7 +459,7 @@ void on_rules_accept(GtkWidget *self, dictionary *dict){ !public_read&&public_write&&public_exec ? 3 : \ 0; gtk_entry_set_text(entry,yon_char_unite(yon_char_from_int(owner),yon_char_from_int(group),yon_char_from_int(public),NULL)); - gtk_widget_destroy(window->Window); + on_close_subwindow(window->Window,"RulesWindow"); } void on_rules_update(GtkWidget *self, logrotate_rules_window *window){ @@ -513,11 +517,12 @@ void on_rules_open(GtkWidget *self,GtkEntry *entry){ window->FinalEntry=yon_gtk_builder_get_widget(builder,"FinalEntry"); window->CancelButton=yon_gtk_builder_get_widget(builder,"CancelButton"); window->SaveButton=yon_gtk_builder_get_widget(builder,"SaveButton"); + yon_window_config_custom_window_set(GTK_WINDOW(window->Window),"RulesWindow"); gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL); dictionary *dict = NULL; yon_dictionary_add_or_create_if_exists_with_data(dict,"entry",entry); yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),"RulesWindow"); g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_rules_accept),dict); g_signal_connect(G_OBJECT(window->UserReadCheck),"toggled",G_CALLBACK(on_rules_update),window); @@ -546,7 +551,7 @@ void on_filechooser_save(GtkWidget *self, dictionary *dict){ logrotate_filechooser_window *dialog = yon_dictionary_get_data(dict->first->next,logrotate_filechooser_window*); char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->FileChooser)); gtk_entry_set_text(GTK_ENTRY(window->FileAmountEntry),filename); - gtk_widget_destroy(dialog->FileChooser); + on_close_subwindow(dialog->FileChooser,"FileDialog"); } void on_filechooser_open(GtkWidget *self, logrotate_configure_window *window){ @@ -556,6 +561,7 @@ void on_filechooser_open(GtkWidget *self, logrotate_configure_window *window){ dialog->FileOrDirCheck = yon_gtk_builder_get_widget(builder,"FileOrDirCheck"); dialog->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); dialog->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); + yon_window_config_custom_window_set(GTK_WINDOW(dialog->FileChooser),"FileDialog"); gtk_window_set_transient_for(GTK_WINDOW(window->MainWindow),GTK_WINDOW(window->MainWindow)); dictionary *dict = NULL; @@ -563,7 +569,7 @@ void on_filechooser_open(GtkWidget *self, logrotate_configure_window *window){ yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); yon_dictionary_add_or_create_if_exists_with_data(dict,"dialog",dialog); g_signal_connect(G_OBJECT(dialog->FileOrDirCheck),"toggled",G_CALLBACK(on_filechooser_mode_switch),dialog); - g_signal_connect(G_OBJECT(dialog->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); + g_signal_connect(G_OBJECT(dialog->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),"FileDialog"); g_signal_connect(G_OBJECT(dialog->AcceptButton),"clicked",G_CALLBACK(on_filechooser_save),dict); gtk_widget_show(dialog->FileChooser); } @@ -854,7 +860,7 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ } paths=yon_char_replace(paths,",","\n"); gtk_list_store_set(main_config.logrotate_list,&iter,0,log_name,1,paths,2,gtk_entry_get_text(GTK_ENTRY(window->LogDescriptionEntry)),-1); - on_close_subwindow(window->MainWindow); + on_close_subwindow(window->MainWindow,"LogrotateWindow"); } } @@ -923,6 +929,8 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind window->CommandAfterEntry=yon_gtk_builder_get_widget(builder,"CommandAfterEntry"); window->EndworkCommandEntry=yon_gtk_builder_get_widget(builder,"EndworkCommandEntry"); window->StatusBox=yon_gtk_builder_get_widget(builder,"StatusBox"); + + yon_window_config_custom_window_get(GTK_WINDOW(window->MainWindow),"LogrotateWindow"); gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); if (dialog) gtk_window_set_transient_for(GTK_WINDOW(window->MainWindow),GTK_WINDOW(dialog->Window)); @@ -1308,13 +1316,14 @@ void on_logrotate_tab_open(GtkWidget *self, main_window *widgets){ window->AddButton = yon_gtk_builder_get_widget(builder,"AddButton"); window->RemoveButton = yon_gtk_builder_get_widget(builder,"RemoveButton"); window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); + yon_window_config_custom_window_get(GTK_WINDOW(window->Window),"LogrotateTabWindow"); gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL); gtk_tree_view_set_model(GTK_TREE_VIEW(window->MainTree),GTK_TREE_MODEL(main_config.logrotate_list)); gtk_tree_view_set_model(GTK_TREE_VIEW(window->AppsMainTree),GTK_TREE_MODEL(main_config.logrotate_apps_list)); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); - g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),"LogrotateTabWindow"); + g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_close_subwindow),"LogrotateTabWindow"); g_signal_connect(G_OBJECT(window->AddButton),"clicked",G_CALLBACK(on_logrotate_add),window); g_signal_connect(G_OBJECT(window->RemoveButton),"clicked",G_CALLBACK(on_logrotate_remove),window); g_signal_connect(G_OBJECT(window->ConfigureButton),"clicked",G_CALLBACK(on_logrotate_edit),window); @@ -1461,7 +1470,7 @@ void on_journald_save(GtkWidget *self, journald_window *window){ yon_config_register(JOURNALD("MaxLevelConsole"),"logging",yon_char_from_int(forwardempty-1)); else yon_config_remove_by_key(JOURNALD("MaxLevelConsole")); - on_close_subwindow(window->MainWindow); + on_close_subwindow(window->MainWindow,"JournaldWindow"); } journald_window *yon_journald_open(GtkWidget *self, main_window *widgets){ @@ -1502,6 +1511,8 @@ journald_window *yon_journald_open(GtkWidget *self, main_window *widgets){ window->LowerTimeButton=yon_gtk_builder_get_widget(builder,"LowerTimeButton"); window->headerTopic=yon_gtk_builder_get_widget(builder,"headerTopic"); + yon_window_config_custom_window_get(GTK_WINDOW(window->MainWindow),"JournaldWindow"); + gtk_window_set_transient_for(GTK_WINDOW(window->MainWindow),GTK_WINDOW(widgets->Window)); { int sz; @@ -1511,7 +1522,7 @@ journald_window *yon_journald_open(GtkWidget *self, main_window *widgets){ } gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),"JournaldWindow"); g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_journald_save),window); g_signal_connect(G_OBJECT(window->LogIntervalCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogIntervalSpin); @@ -1631,11 +1642,15 @@ void on_log_save(GtkWidget *self, dictionary *dict){ if (!yon_char_is_empty(name)){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); GtkTreeIter iter; - if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)) + if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ gtk_list_store_append(widgets->list,&iter); + yon_window_config_custom_window_set(GTK_WINDOW(window->MainWindow),"AddWindow"); + } else { + yon_window_config_custom_window_set(GTK_WINDOW(window->MainWindow),"EditWindow"); + } gtk_list_store_set(widgets->list,&iter,0,name,1,pathse,2,&desc ? desc : "",-1); } - on_close_subwindow(self); + on_close_subwindow(self,NULL); } add_log_window *on_add_open(main_window *widgets){ @@ -1660,7 +1675,6 @@ add_log_window *on_add_open(main_window *widgets){ dictionary *dict = NULL; yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked", G_CALLBACK(on_close_subwindow),NULL); g_signal_connect(G_OBJECT(window->SaveButton),"clicked", G_CALLBACK(on_log_save),dict); return window; } @@ -1728,6 +1742,8 @@ void on_log_add(GtkWidget *self, main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); GtkTreeIter iter; add_log_window *window = on_add_open(widgets); + yon_window_config_custom_window_get(GTK_WINDOW(window->MainWindow),"AddWindow"); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked", G_CALLBACK(on_close_subwindow),"AddWindow"); gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree))); gtk_widget_show(window->MainWindow); gtk_widget_hide(window->StatisticsFrame); @@ -1740,6 +1756,8 @@ void on_log_edit(GtkWidget *self,main_window *widgets){ GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ add_log_window *window = on_add_open(widgets); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked", G_CALLBACK(on_close_subwindow),"EditWindow"); + yon_window_config_custom_window_get(GTK_WINDOW(window->MainWindow),"EditWindow"); gtk_widget_show(window->MainWindow); gtk_widget_hide(window->StatisticsFrame); char *name; diff --git a/source/ubl-utils.c b/source/ubl-utils.c index b405491..89518c8 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1334,12 +1334,17 @@ config_str yon_config_load(char *command, int *str_len){ } } -/**int yon_config_save_registered(char *path, char *section) +/**int yon_config_save_registered(char *path) * [EN] - * Saves config with [command] + * Saves config at [path] config. + * [path] can be: + * system + * global * [RU] - * Выполняет команду [command], добавляя в конец все записи конфига в таком виде: - * [ПАРАМЕТР1]="[значения1]" [ПАРАМЕТР2]="[значения2]" + * Сохраняет конфигурацию в [path] конфиг. + * [path] может быть + * system - локальный конфиг + * global - глобальный конфиг */ int yon_config_save_registered(char *path){ check_config{ @@ -1376,10 +1381,15 @@ int yon_config_save_registered(char *path){ /**int yon_config_force_save_registered(char *path, char *section) * [EN] - * Saves config with [command] + * Force config to save at [path] config ignoring parameter save status. + * [path] can be: + * system + * global * [RU] - * Выполняет команду [command], добавляя в конец все записи конфига в таком виде: - * [ПАРАМЕТР1]="[значения1]" [ПАРАМЕТР2]="[значения2]" + * Принудительно сохраняет конфигурацию в [path] конфиг игнорируя статус параметра. + * [path] может быть + * system - локальный конфиг + * global - глобальный конфиг */ int yon_config_force_save_registered(char *path){ check_config{ @@ -1868,6 +1878,17 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end } } + void yon_window_config_add_instant_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type){ + switch (val_type){ + case YON_TYPE_BOOLEAN: g_key_file_set_boolean(__yon_window_config_file,section,param_name,*((gboolean*)tracked_value)); + break; + case YON_TYPE_INT: g_key_file_set_integer(__yon_window_config_file,section,param_name,*((int*)tracked_value)); + break; + case YON_TYPE_STRING: g_key_file_set_string(__yon_window_config_file,section,param_name,(char*)tracked_value); + break; + } + } + void yon_window_config_erase_custom_parameter(char *param_name, char *section){ __yon_custom_parameter *param = NULL; param = yon_remalloc(param,sizeof(__yon_custom_parameter)); @@ -1901,6 +1922,81 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end } } + void yon_on_window_config_custom_window_destroy(GtkWindow *window, char *window_name){ + if (!gtk_window_is_maximized(window)){ + int height=0; + int width=0; + int X=0; + int Y=0; + gtk_window_get_position(window,&X,&Y); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosX"),"window",&X,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosY"),"window",&Y,YON_TYPE_INT); + + } + } + + void yon_on_window_config_custom_window_resize(GtkWindow *window, char *window_name){ + if (!gtk_window_is_maximized(window)){ + int height=0; + int width=0; + int X=0; + int Y=0; + gtk_window_get_size(window,&width,&height); + gtk_window_get_position(window,&X,&Y); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"Width"),"window",&width,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"Height"),"window",&height,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosX"),"window",&X,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosY"),"window",&Y,YON_TYPE_INT); + } + + } + + void yon_window_config_custom_window_setup(GtkWindow *window, char *window_name){ + int height=0; + int width=0; + int X=0; + int Y=0; + yon_window_config_get_parameter("window",yon_char_append(window_name,"Width"),&width,YON_TYPE_INT); + yon_window_config_get_parameter("window",yon_char_append(window_name,"Height"),&height,YON_TYPE_INT); + yon_window_config_get_parameter("window",yon_char_append(window_name,"PosX"),&X,YON_TYPE_INT); + yon_window_config_get_parameter("window",yon_char_append(window_name,"PosY"),&Y,YON_TYPE_INT); + if (width&&height) + gtk_window_resize(window,width,height); + if (X&&Y) + gtk_window_move(window,X,Y); + char *signals_window_name = yon_char_new(window_name); + g_signal_connect(G_OBJECT(window),"check-resize",G_CALLBACK(yon_on_window_config_custom_window_resize),signals_window_name); + g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(yon_on_window_config_custom_window_destroy),signals_window_name); + } + + void yon_window_config_custom_window_get(GtkWindow *window, char *window_name){ + int height=0; + int width=0; + int X=0; + int Y=0; + yon_window_config_get_parameter("window",yon_char_append(window_name,"Width"),&width,YON_TYPE_INT); + yon_window_config_get_parameter("window",yon_char_append(window_name,"Height"),&height,YON_TYPE_INT); + yon_window_config_get_parameter("window",yon_char_append(window_name,"PosX"),&X,YON_TYPE_INT); + yon_window_config_get_parameter("window",yon_char_append(window_name,"PosY"),&Y,YON_TYPE_INT); + if (width&&height) + gtk_window_resize(window,width,height); + if (X&&Y) + gtk_window_move(window,X,Y); + } + + void yon_window_config_custom_window_set(GtkWindow *window, char *window_name){ + int height=0; + int width=0; + int X=0; + int Y=0; + gtk_window_get_size(window,&width,&height); + gtk_window_get_position(window,&X,&Y); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"Width"),"window",&width,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"Height"),"window",&height,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosX"),"window",&X,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosY"),"window",&Y,YON_TYPE_INT); + } + GtkWidget *yon_ubl_menu_item_about_new(char *buttonname){ GtkWidget *menu_item = gtk_menu_item_new(); gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitembottom"); diff --git a/source/ubl-utils.h b/source/ubl-utils.h index d488149..e01b857 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -288,6 +288,12 @@ 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); +void yon_window_config_custom_window_setup(GtkWindow *window, char *window_name); + +void yon_window_config_custom_window_get(GtkWindow *window, char *window_name); + +void yon_window_config_custom_window_set(GtkWindow *window, char *window_name); + 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); -- 2.35.1 From 505bc0a446768e7b27f4f8ef709d5e837091f5e2 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 20 Nov 2023 17:36:23 +0600 Subject: [PATCH 10/39] Fixed logrotate stopping command --- logging_services.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logging_services.csv b/logging_services.csv index 98be66d..5db9f91 100644 --- a/logging_services.csv +++ b/logging_services.csv @@ -1,5 +1,5 @@ Service_Name;Service_Description;command_start;command_stop;command_enable;command_disable;command_status journald;System event log;systemctl start systemd-journald.service;systemctl stop systemd-journald.service;ubconfig set config SERVICESSTART+=systemd-journald.service;ubconfig set config SERVICESSTART-=systemd-journald.service;systemctl status systemd-journald.service -logrotate;System event log rotation service;systemctl start logrotate.timer;systemctl stop logrotate.timer,systemctl stop logrotate.service;ubconfig set config SERVICESNOSTART-=,logrotate.timer;ubconfig set config SERVICESNOSTART+=,logrotate.timer;systemctl status logrotate.service +logrotate;System event log rotation service;systemctl start logrotate.timer;systemctl stop logrotate.timer logrotate.service;ubconfig set config SERVICESNOSTART-=,logrotate.timer;ubconfig set config SERVICESNOSTART+=,logrotate.timer;systemctl status logrotate.service #metalog;System event log;systemctl start metalog.service;systemctl stop metalog.service;ubconfig set config SERVICESSTART+=metalog.service;ubconfig set config SERVICESSTART-=metalog.service;systemctl status metalog.service #syslog-ng;Service for collecting messages from system events of active network devices;systemctl start syslog-ng.service;systemctl stop syslog-ng.service;ubconfig set config SERVICESSTART+=syslog-ng.service;ubconfig set config SERVICESSTART-=syslog-ng.service;systemctl status syslog-ng.service \ No newline at end of file -- 2.35.1 From 6ccf02ccec04b2fe3fdb8628b4ebeb83ff373bc4 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 20 Nov 2023 17:54:34 +0600 Subject: [PATCH 11/39] Fixed errors --- source/ubl-settings-logging.c | 5 ----- source/ubl-utils.c | 11 ++++++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 58dc974..6fb80a6 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -809,11 +809,6 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ char *endwork = (char*)gtk_entry_get_text(GTK_ENTRY(window->EndworkCommandEntry)); sharedscripts = "sharedscripts"; if (!yon_char_is_empty(before_once)) { - if (strcmp(before_once,",")){ - yon_ubl_status_highlight_incorrect(window->CommandBeforeOnceEntry); - yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); - return; - } before_once = yon_char_replace(before_once,"\"","=--"); before_once = yon_char_replace(before_once,"=--","\\\""); firstaction = yon_char_append("firstaction,",before_once); diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 89518c8..1b38d8a 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1689,6 +1689,11 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end g_key_file_set_integer(__yon_window_config_file,"window","WindowHeight",__yon_main_window_config.height); g_key_file_set_integer(__yon_window_config_file,"window","fullscreen",__yon_main_window_config.fullscreen); dictionary *dict=NULL; + if (__yon_main_window_config.deleted_parameters) + for_dictionaries(dict,__yon_main_window_config.deleted_parameters){ + __yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*); + g_key_file_remove_key(__yon_window_config_file,param->section,param->parameter_name,NULL); + } if (__yon_main_window_config.custom_listeners) for_dictionaries(dict,__yon_main_window_config.custom_listeners){ __yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*); @@ -1724,11 +1729,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end break; } } - if (__yon_main_window_config.deleted_parameters) - for_dictionaries(dict,__yon_main_window_config.deleted_parameters){ - __yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*); - g_key_file_remove_key(__yon_window_config_file,param->section,param->parameter_name,NULL); - } + g_key_file_save_to_file(__yon_window_config_file,__yon_window_config_path,NULL); } -- 2.35.1 From 59f3fcb718df5bb226197043a4c0160eeae0dd94 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 20 Nov 2023 18:01:34 +0600 Subject: [PATCH 12/39] Fixed crash at logrotate logs editing --- source/ubl-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 1b38d8a..27edf24 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1399,7 +1399,7 @@ int yon_config_force_save_registered(char *path){ for_dictionaries(dct,(dictionary*)__yon__config__strings){ if (dct->data&&strcmp(yon_dictionary_get_data(dct,char*),"")!=0){ if (((yon_config_parameter*)dct)->flag1==1||((yon_config_parameter*)dct)->flag1==0){ - if (sections_add&&yon_dictionary_get(§ions_add,((yon_config_parameter*)dct)->section)) sections_add->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_add,char*)," ",dct->key,"=",yon_dictionary_get_data(dct,char*),NULL); + if (sections_add&&yon_dictionary_get(§ions_add,((yon_config_parameter*)dct)->section)) sections_add->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_add,char*)," ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL); else yon_dictionary_add_or_create_if_exists_with_data(sections_add,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " set ", ((yon_config_parameter*)dct)->section, " ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL)); } else if (((yon_config_parameter*)dct)->flag1==-1){ if (sections_remove&&yon_dictionary_get(§ions_remove,((yon_config_parameter*)dct)->section)) sections_remove->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_remove,char*)," ",dct->key,NULL); -- 2.35.1 From 1662e785db08fb1619a2a965cb5cd3a3cf3e81c6 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 20 Nov 2023 18:19:57 +0600 Subject: [PATCH 13/39] Test fix for logrotate configuration crash --- source/ubl-settings-logging.c | 2 -- source/ubl-utils.c | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 6fb80a6..c75f5d5 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -948,8 +948,6 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind int sizenumber=0; finalsize = yon_size_convert_automatic(finalsize,&sizenumber); char *fin = yon_char_from_float(finalsize); - char *unw = strstr(fin,",")+3; - fin = yon_char_divide(fin,strlen(fin)-strlen(unw)); gtk_label_set_text(GTK_LABEL(window->LogSizeLabel),yon_char_append(fin,yon_size_get_letter_from_int(sizenumber))); } diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 27edf24..16e7c87 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -622,8 +622,8 @@ char *yon_char_from_float(float int_to_convert) { convert_check = convert_check / 10; } - char *ch = g_malloc0(i * sizeof(char) + 1); - sprintf(ch, "%f", int_to_convert); + char *ch = g_malloc0((i + 9)* sizeof(char)); + sprintf(ch, "%.2f", int_to_convert); return ch; } -- 2.35.1 From 2e30389079b23fddc2d53c14a2c64c00078af04d Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 21 Nov 2023 09:16:32 +0600 Subject: [PATCH 14/39] Localisation updates --- source/ubl-strings.h | 11 ++++++++++- ubl-settings-logging.pot | 28 ++++++++++++++++++++++++++++ ubl-settings-logging_ru.po | 31 +++++++++++++++++++++++++++++-- 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 25b3eab..2207240 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -185,4 +185,13 @@ #define ADD_PATHS_LABEL _("Path (-s):") #define CONTROL_LABEL _("Control:") #define LOG_LABEL _("Log file") -#define NAME_LABEL _("Name:") \ No newline at end of file +#define NAME_LABEL _("Name:") + +//ubl-settings-logging-rules.glade +#define OWNER_LABEL _("Owner rules") +#define GROUP_LABEL _("Group rules") +#define PUBLIC_LABEL _("Public rules") +#define READ_LABEL _("Read") +#define WRITE_LABEL _("Write") +#define EXECUTE_LABEL _("Execute") +#define VALUE_LABEL _("Value:") \ No newline at end of file diff --git a/ubl-settings-logging.pot b/ubl-settings-logging.pot index 6ddb592..419d0a9 100644 --- a/ubl-settings-logging.pot +++ b/ubl-settings-logging.pot @@ -719,6 +719,34 @@ msgstr "" msgid "Name:" msgstr "" +#: source/ubl-strings.h:191 +msgid "Owner rules" +msgstr "" + +#: source/ubl-strings.h:192 +msgid "Group rules" +msgstr "" + +#: source/ubl-strings.h:193 +msgid "Public rules" +msgstr "" + +#: source/ubl-strings.h:194 +msgid "Read" +msgstr "" + +#: source/ubl-strings.h:195 +msgid "Write" +msgstr "" + +#: source/ubl-strings.h:196 +msgid "Execute" +msgstr "" + +#: source/ubl-strings.h:197 +msgid "Value:" +msgstr "" + msgid "System event log rotation service" msgstr "" diff --git a/ubl-settings-logging_ru.po b/ubl-settings-logging_ru.po index 19cc083..9e3d3f4 100644 --- a/ubl-settings-logging_ru.po +++ b/ubl-settings-logging_ru.po @@ -733,6 +733,34 @@ msgstr "Файл лога" msgid "Name:" msgstr "Имя:" +#: source/ubl-strings.h:191 +msgid "Owner rules" +msgstr "Правила владельца" + +#: source/ubl-strings.h:192 +msgid "Group rules" +msgstr "Правила группы" + +#: source/ubl-strings.h:193 +msgid "Public rules" +msgstr "Правила остальных" + +#: source/ubl-strings.h:194 +msgid "Read" +msgstr "Чтение" + +#: source/ubl-strings.h:195 +msgid "Write" +msgstr "Запись" + +#: source/ubl-strings.h:196 +msgid "Execute" +msgstr "Исполнение" + +#: source/ubl-strings.h:197 +msgid "Value:" +msgstr "Значение:" + msgid "System event log rotation service" msgstr "Служба ротации системных журналов событий" @@ -740,8 +768,7 @@ msgid "System event log" msgstr "Системный журнал событий" msgid "" -"Service for collecting messages from system events of active network " -"devices" +"Service for collecting messages from system events of active network devices" msgstr "Сервис сбора сообщений системных событий активных сетевых устройств" msgid "Log of work and requests to Acpid" -- 2.35.1 From b656a8b2a25828b03de1af9ea9ea04d96a7e64b8 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 21 Nov 2023 09:18:07 +0600 Subject: [PATCH 15/39] Localisation fixes for rules window --- ubl-settings-logging-rules.glade | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ubl-settings-logging-rules.glade b/ubl-settings-logging-rules.glade index 3b1f097..4f3633f 100644 --- a/ubl-settings-logging-rules.glade +++ b/ubl-settings-logging-rules.glade @@ -1,7 +1,8 @@ - + + True False -- 2.35.1 From 2f42349905c10d1e179c8aaaad84e9227a976390 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 22 Nov 2023 12:30:44 +0600 Subject: [PATCH 16/39] Fixes --- source/CMakeLists.txt | 8 +- source/ubl-settings-logging.c | 149 ++++++++++++++++++++++++++-- source/ubl-settings-logging.h | 10 ++ ubl-settings-logging-journald.glade | 1 + ubl-settings-logging.glade | 8 +- 5 files changed, 168 insertions(+), 8 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 87c4d28..37ef092 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -13,6 +13,11 @@ include_directories(${VTE291_INCLUDE_DIRS}) link_directories(${VTE291_LIBRARY_DIRS}) add_definitions(${VTE291_CFLAGS_OTHER}) +pkg_check_modules(POLKIT REQUIRED polkit-agent-1) +include_directories(${POLKIT_INCLUDE_DIRS}) +link_directories(${POLKIT_LIBRARY_DIRS}) +add_definitions(${POLKIT_CFLAGS_OTHER}) + find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0) option(WEBKIT_FOUND "No" OFF) @@ -89,7 +94,8 @@ set(SOURCE_FILES set(LIBRARIES ${GTK_LIBRARIES} ${WEBKIT_LIBRARIES} - ${VTE291_LIBRARIES} + ${VTE291_LIBRARIES} + ${POLKIT_LIBRARIES} pthread) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index c75f5d5..b971224 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -127,20 +127,50 @@ int yon_size_get_int_from_letter(char size){ //functions +void yon_polkit_authorized_action(GCallback *func){ + +} + +void yon_logs_custom_save(main_window *widgets){ + GtkTreeIter iter; + char *name; + char *description; + char *paths; + int standard; + int standard_paths; + int size=0; + int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->list),&iter); + char *final_strings=NULL; + for (;valid;valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->list),&iter)){ + gtk_tree_model_get(GTK_TREE_MODEL(widgets->list),&iter,0,&name,1,&paths,2,&description,3,&standard,4,&standard_paths,-1); + if (standard!=1){ + for (int i=0;iLogDescriptionEntry))),YON_TYPE_STRING); + yon_window_config_add_custom_parameter(paths,"render_name",yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(window->LogNameEntry))),YON_TYPE_STRING); GtkTreeModel *model = GTK_TREE_MODEL(main_config.logrotate_list); if (!dialog||!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->MainTree)),&model,&iter)){ gtk_list_store_append(main_config.logrotate_list,&iter); @@ -1430,7 +1461,7 @@ void on_journald_save(GtkWidget *self, journald_window *window){ char *TTY=NULL; if (consoleforwardactive == 1){ confor = "yes"; - TTY = (char*)gtk_entry_get_text(GTK_ENTRY(window->RedirectTTYEntry)); + TTY = yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(window->RedirectTTYEntry))); if (yon_char_is_empty(TTY)) consoleforwardactive=0; } @@ -1637,12 +1668,16 @@ void on_log_save(GtkWidget *self, dictionary *dict){ GtkTreeIter iter; if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ gtk_list_store_append(widgets->list,&iter); + int stat; + gtk_tree_model_get(GTK_TREE_MODEL(widgets->list),&iter,3,&stat,-1); + gtk_list_store_set(widgets->list,&iter,3,stat==0?1:stat==1?2:2,-1); yon_window_config_custom_window_set(GTK_WINDOW(window->MainWindow),"AddWindow"); } else { yon_window_config_custom_window_set(GTK_WINDOW(window->MainWindow),"EditWindow"); } gtk_list_store_set(widgets->list,&iter,0,name,1,pathse,2,&desc ? desc : "",-1); } + yon_logs_custom_save(widgets); on_close_subwindow(self,NULL); } @@ -1975,6 +2010,57 @@ void on_enable_disable_clicked(GtkButton *self, main_window *widgets){ // standard functions +void on_permissions_changed(){ + if (g_permission_get_allowed(main_config.permissions)){ + PolkitAuthority *auth = polkit_authority_get_sync(NULL,NULL); + PolkitSubject *subject; + pid_t parent_pid; + parent_pid = getppid (); + subject = polkit_unix_process_new_for_owner (parent_pid,0,getuid()); + PolkitDetails *dets = polkit_details_new(); + if (polkit_authority_check_authorization_sync(auth,subject,"com.ublinux.ubl-settings-logging",dets,POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,NULL,NULL)){ + printf("Allowed\n"); + char *command[] = {"/bin/pkexec","/bin/echo","1", NULL}; + gchar *standard_output = NULL; + gchar *standard_error = NULL; + gint exit_status = -1; // Инициализируем переменную для статуса выхода + + GError *error = NULL; + gboolean success = g_spawn_sync( + NULL, + command, + NULL, + G_SPAWN_DEFAULT, + NULL, + NULL, + &standard_output, + &standard_error, + NULL, + &error + ); + + if (success) { + if (standard_output != NULL) { + printf("Output: %s\n", standard_output); + g_free(standard_output); + } + if (standard_error != NULL) { + printf("Error output: %s\n", standard_error); + g_free(standard_error); + } + printf("Exit status: %d\n", exit_status); + } else { + g_printerr("Error running command: %s\n", error->message); + g_error_free(error); + } + } else { + if (g_permission_get_can_acquire(main_config.permissions)){ + g_permission_acquire(main_config.permissions,NULL,NULL); + } + } + } +} + void config_init(){ main_config.always_open_documentation=0; main_config.win_height=0; @@ -1991,6 +2077,22 @@ void config_init(){ main_config.lock_save_local=0; main_config.logrotate_list = gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING); main_config.logrotate_apps_list = gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING); + + PolkitSubject *subject = NULL; + + pid_t parent_pid; + parent_pid = getppid (); + if (parent_pid == 1) + { + g_printerr ("Parent process was reaped by init(1)\n"); + } + subject = polkit_unix_process_new_for_owner (parent_pid,0,getuid()); + main_config.permissions = polkit_permission_new_sync( + "com.ublinux.ubl-settings-logging", + subject, // Пользователь (текущий пользователь) + NULL, // Опции (NULL, если не требуются) + NULL); + g_signal_connect(G_OBJECT(main_config.permissions),"notify::allowed",G_CALLBACK(on_permissions_changed),NULL); } main_window *setup_window(){ @@ -2037,8 +2139,12 @@ main_window *setup_window(){ widgets->list = GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1")); widgets->ServicesList = GTK_LIST_STORE(gtk_builder_get_object(builder,"ServicesList")); + widgets->UpgradePermissionsMenuItem = yon_gtk_builder_get_widget(builder,"UpgradePermissionsMenuItem"); + widgets->PermissionsLock = yon_gtk_builder_get_widget(builder,"PermissionsLock"); + widgets->MainTree = yon_gtk_builder_get_widget(builder,"MainTree"); + gtk_lock_button_set_permission(GTK_LOCK_BUTTON(widgets->PermissionsLock),main_config.permissions); gtk_window_set_title(GTK_WINDOW(widgets->Window),TITLE_LABEL); GtkWidget *menu = yon_gtk_builder_get_widget(builder,"menu2"); @@ -2137,6 +2243,34 @@ main_window *setup_window(){ yon_char_divide_search_self(main_config.groups[i],":",-1); } + size =0; + config_str custom_watchers = yon_file_open(custom_logs_saving_file_path,&size); + if (custom_watchers){ + GtkTreeIter itar; + for (int i=0;ilist),&iter); + for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->list),&iter)){ + gtk_tree_model_get(GTK_TREE_MODEL(widgets->list),&iter,0,&cur_name,-1); + if (!strcmp(cur_name,cur_watcher[0])){ + found=1; + break; + } + } + if (!found) + gtk_list_store_append(widgets->list,&iter); + gtk_list_store_set(widgets->list,&iter,0,cur_watcher[0],1,cur_watcher[1],2,cur_watcher[2],-1); + yon_char_parsed_free(cur_watcher,cur_size); + } + } + } else { + FILE *fl = fopen(custom_logs_saving_file_path,"w"); + fclose(fl); + } /* Widget registration for config monitoring | Регистрация виджетов для мониторинга конфига */ // yon_window_config_add_custom_parameter(widgets->HeadInfoLabel,"head-text","label",YON_TYPE_STRING); @@ -2157,6 +2291,8 @@ main_window *setup_window(){ g_signal_connect(G_OBJECT(widgets->LoadGlobalMenuItem),"activate",G_CALLBACK(on_load_global),NULL); g_signal_connect(G_OBJECT(widgets->LoadLocalMenuItem),"activate",G_CALLBACK(on_load_local),NULL); + g_signal_connect(G_OBJECT(widgets->UpgradePermissionsMenuItem),"activate",G_CALLBACK(on_permissions_changed),NULL); + g_signal_connect(G_OBJECT(widgets->MainTree),"cursor-changed",G_CALLBACK(on_main_window_tree_selection_changed),widgets); g_signal_connect(G_OBJECT(widgets->ServicesTree),"cursor-changed",G_CALLBACK(on_main_window_services_tree_selection_changed),widgets); @@ -2167,10 +2303,11 @@ main_window *setup_window(){ return widgets; } -int main(int argc, char *argv[]){ +int main(int argc, char *argv[], char **envp){ local=setlocale(LC_ALL, ""); textdomain (LocaleName); config_init(); + main_config.envp=envp; int option_index=0; int show_help=0; int debug_mode=0; @@ -2239,9 +2376,9 @@ int main(int argc, char *argv[]){ } if (getuid()!=0){ - main_config.lock_load_global=1; - main_config.lock_save_global=1; - main_config.lock_save_local=1; + // main_config.lock_load_global=1; + // main_config.lock_save_global=1; + // main_config.lock_save_local=1; } gtk_init(&argc,&argv); diff --git a/source/ubl-settings-logging.h b/source/ubl-settings-logging.h index b2da285..80010b8 100644 --- a/source/ubl-settings-logging.h +++ b/source/ubl-settings-logging.h @@ -16,6 +16,7 @@ #include #endif #include "ubl-strings.h" +#include #define WIKI_LINK "https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-logging" @@ -39,6 +40,7 @@ #define journald_size_command "journalctl --disk-usage | grep -oE \"[0-9]{1,}.[0-9]{1,}[A-Z]\"" #define logrotate_size_command(paths) yon_char_unite("du ",paths," |grep -oE '^[0-9]{1,}'",NULL) #define logrotate_config_path "/etc/logrotate.d/" +#define custom_logs_saving_file_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/logwatcher.csv",NULL) #define LocalePath "/usr/share/locale" #define LocaleName "ubl-settings-logging" @@ -69,6 +71,7 @@ string version_application; char *local; typedef struct { + char **envp; int always_open_documentation; int win_pos_x; int win_pos_y; @@ -88,8 +91,13 @@ typedef struct { GtkListStore *logrotate_list; GtkListStore *logrotate_apps_list; + config_str groups; int groups_size; + + config_str *saved_logs; + + GPermission *permissions; } config; typedef struct { @@ -136,6 +144,8 @@ typedef struct { GtkWidget *ServicesEnableDisableButton; GtkListStore *list; GtkListStore *ServicesList; + GtkWidget *UpgradePermissionsMenuItem; + GtkWidget *PermissionsLock; // Custom } main_window; diff --git a/ubl-settings-logging-journald.glade b/ubl-settings-logging-journald.glade index c48b5f4..28726b9 100644 --- a/ubl-settings-logging-journald.glade +++ b/ubl-settings-logging-journald.glade @@ -94,6 +94,7 @@ 5 5 vertical + 5 True diff --git a/ubl-settings-logging.glade b/ubl-settings-logging.glade index 0db3ab8..be7dea7 100644 --- a/ubl-settings-logging.glade +++ b/ubl-settings-logging.glade @@ -508,6 +508,12 @@ translated and supported by community. False False False + + + False + Upgrade permissions to root + + True @@ -719,7 +725,6 @@ translated and supported by community. True - False True True Add log @@ -1043,6 +1048,7 @@ translated and supported by community. True False + 5 True -- 2.35.1 From 1700a22f78006a48fd73ef67ca42136e14d74090 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 22 Nov 2023 15:05:49 +0600 Subject: [PATCH 17/39] Repeated records fixes at monitoring tab --- source/ubl-settings-logging.c | 30 +- source/ubl-settings-logging.h | 1 + ubl-settings-logging-add.glade | 536 +++++++++++++++++---------------- ubl-settings-logging_ru.po | 2 +- 4 files changed, 310 insertions(+), 259 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index b971224..fcaf15f 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1658,7 +1658,9 @@ void on_log_save(GtkWidget *self, dictionary *dict){ char *pathse=NULL; for (int i=0;iNameEntry)); @@ -1667,6 +1669,27 @@ void on_log_save(GtkWidget *self, dictionary *dict){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); GtkTreeIter iter; if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ + int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->list),&iter); + for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->list),&iter)){ + char *paths=NULL; + char *name; + gtk_tree_model_get(GTK_TREE_MODEL(widgets->list),&iter,0,&name,1,&paths,-1); + if (!strcmp(gtk_entry_get_text(GTK_ENTRY(window->NameEntry)),name)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEATED_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->NameEntry); + return; + } + int paths_size=0; + config_str paths_parsed = yon_char_parse(paths,&paths_size,"\n"); + int pathse_size=0; + config_str pathse_parsed = yon_char_parse(pathse,&pathse_size,"\n"); + + if (yon_char_parsed_includes_char_parsed(pathse_parsed,paths_parsed,pathse_size,paths_size)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEATED_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->LogPathsBox); + return; + } + } gtk_list_store_append(widgets->list,&iter); int stat; gtk_tree_model_get(GTK_TREE_MODEL(widgets->list),&iter,3,&stat,-1); @@ -1698,6 +1721,7 @@ add_log_window *on_add_open(main_window *widgets){ window->ControlSectionBox=yon_gtk_builder_get_widget(builder,"ControlSectionBox"); window->LogPathsBox=yon_gtk_builder_get_widget(builder,"LogPathsBox"); window->NameEntry=yon_gtk_builder_get_widget(builder,"NameEntry"); + window->StatusBox=yon_gtk_builder_get_widget(builder,"StatusBox"); gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); gtk_window_set_transient_for(GTK_WINDOW(window->MainWindow),GTK_WINDOW(widgets->Window)); dictionary *dict = NULL; @@ -2140,11 +2164,9 @@ main_window *setup_window(){ widgets->ServicesList = GTK_LIST_STORE(gtk_builder_get_object(builder,"ServicesList")); widgets->UpgradePermissionsMenuItem = yon_gtk_builder_get_widget(builder,"UpgradePermissionsMenuItem"); - widgets->PermissionsLock = yon_gtk_builder_get_widget(builder,"PermissionsLock"); widgets->MainTree = yon_gtk_builder_get_widget(builder,"MainTree"); - - gtk_lock_button_set_permission(GTK_LOCK_BUTTON(widgets->PermissionsLock),main_config.permissions); + gtk_window_set_title(GTK_WINDOW(widgets->Window),TITLE_LABEL); GtkWidget *menu = yon_gtk_builder_get_widget(builder,"menu2"); diff --git a/source/ubl-settings-logging.h b/source/ubl-settings-logging.h index 80010b8..1d338de 100644 --- a/source/ubl-settings-logging.h +++ b/source/ubl-settings-logging.h @@ -164,6 +164,7 @@ typedef struct { typedef struct { GtkWidget *MainWindow; + GtkWidget *StatusBox; GtkWidget *adjustment1; GtkWidget *adjustment2; GtkWidget *CancelButton; diff --git a/ubl-settings-logging-add.glade b/ubl-settings-logging-add.glade index 27a9496..4124d45 100644 --- a/ubl-settings-logging-add.glade +++ b/ubl-settings-logging-add.glade @@ -3,6 +3,13 @@ + + + + + + + 1024 1 @@ -28,26 +35,6 @@ False emblem-ok-symbolic - - True - False - com.ublinux.ubl-settings-logging.sort-symbolic - - - True - False - com.ublinux.ubl-settings-logging.sort-symbolic - - - True - False - com.ublinux.ubl-settings-logging.sort-symbolic - - - True - False - com.ublinux.ubl-settings-logging.sort-symbolic - 450 False @@ -57,9 +44,6 @@ False - 5 - 5 - 5 5 vertical 5 @@ -103,29 +87,160 @@ 0 + + + True + False + vertical + + + + + + False + True + 0 + + True False + 5 + 5 vertical - 5 - + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 12 + 5 + 5 + + + True + False + 5 + + + True + False + Log size: + 0 + + + False + True + 0 + + + + + True + False + 0.0 Mb + + + True + True + 1 + + + + + + + + + True + False + Statistics + + + + + False + True + end + 0 + + + + True False vertical 5 - + True False + vertical 5 - + True False - Log/Journal: - 0 + 5 + + + True + False + Log/Journal: + 0 + + + False + True + 0 + + + + + True + False + 0 + False + + Log file + + + + True + True + 1 + + + + + True + False + Name: + + + False + True + 2 + + + + + True + True + + + False + True + 3 + + False @@ -134,14 +249,34 @@ - + True - False - 0 - False - - Log file - + True + never + in + 150 + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + + + True + False + vertical + + + + + + + True @@ -150,10 +285,34 @@ - + True False - Name: + 5 + + + True + False + Description: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + False @@ -161,80 +320,65 @@ 2 - - - True - True - - - False - True - 3 - - - False + True True 0 + + + True + True + 1 + + + + + True + False + 5 - + True - True - never - in - 150 - - - True - False - 5 - 5 - 5 - 5 - - - True - False - vertical - - - - - - - + False + Control: + 0 - True + False True - 1 + 0 True False - 5 + 19 - + + Logrotate True - False - Description: - 0 + True + True + image5 - False + True True 0 - + + Metalog True + False True + True + image7 True @@ -242,196 +386,67 @@ 1 - - - False - True - 2 - - - - - True - True - 0 - - - - - True - True - 0 - - - - - True - False - 5 - 5 - - - False - True - 1 - - - - - True - False - 5 - - - True - False - Control: - 0 - - - False - True - 0 - - - - - True - False - 19 - - - Logrotate - True - True - True - image5 - - - True - True - 0 - - - - - Metalog - True - False - True - True - image7 - - - True - True - 1 - - - - - Syslog-ng - True - False - True - True - image6 - - - True - True - 2 - - - - - Journald - True - True - True - image8 - - - False - True - 3 - - - - - True - True - 4 - - - - - False - True - 2 - - - - - True - False - 0.019999999552965164 - in - - - True - False - 5 - 12 - 5 - 5 - - - True - False - 5 - + + Syslog-ng True - False - Log size: - 0 + False + True + True + image6 - False + True True - 0 + 2 - + + Journald True - False - 0.0 Mb + True + True + image8 - True + False True - 1 + 3 + + True + True + 4 + + + False + True + 2 + - - + + True False - Statistics + 5 + 5 + + False + True + 3 + False True - end - 4 + 1 @@ -476,11 +491,24 @@ - - - - - - + + True + False + com.ublinux.ubl-settings-logging.sort-symbolic + + + True + False + com.ublinux.ubl-settings-logging.sort-symbolic + + + True + False + com.ublinux.ubl-settings-logging.sort-symbolic + + + True + False + com.ublinux.ubl-settings-logging.sort-symbolic diff --git a/ubl-settings-logging_ru.po b/ubl-settings-logging_ru.po index 9e3d3f4..1ffaaf0 100644 --- a/ubl-settings-logging_ru.po +++ b/ubl-settings-logging_ru.po @@ -703,7 +703,7 @@ msgstr "Воскресенье*" #: source/ubl-strings.h:177 msgid "Same record already exists" -msgstr "Журнал с такими путями уже добавлен" +msgstr "Такая запись уже существует" #: source/ubl-strings.h:178 msgid "Empty important field" -- 2.35.1 From b32294c67959592b4b7d4cc920ca5eca6828ecc8 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 22 Nov 2023 16:08:43 +0600 Subject: [PATCH 18/39] Improved repetition detection and status bar despawn process --- source/ubl-settings-logging.c | 3 ++- source/ubl-utils.c | 7 ++++++- source/ubl-utils.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index fcaf15f..8a70527 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -2273,6 +2273,7 @@ main_window *setup_window(){ int cur_size=0; config_str cur_watcher = yon_char_parse(custom_watchers[i],&cur_size,";"); if (cur_watcher){ + cur_watcher = yon_char_parsed_append(cur_watcher,&cur_size,NULL); char *cur_name; int found=0; int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->list),&iter); @@ -2285,7 +2286,7 @@ main_window *setup_window(){ } if (!found) gtk_list_store_append(widgets->list,&iter); - gtk_list_store_set(widgets->list,&iter,0,cur_watcher[0],1,cur_watcher[1],2,cur_watcher[2],-1); + gtk_list_store_set(widgets->list,&iter,0,cur_watcher[0],1,cur_watcher[1],2,cur_watcher[2]?cur_watcher[2]:"",-1); yon_char_parsed_free(cur_watcher,cur_size); } } diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 16e7c87..8fdd809 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -2196,7 +2196,7 @@ struct temp_statusbox { void _yon_ubl_status_box_timed_remove(struct temp_statusbox *statusstruct){ sleep(statusstruct->times); - if (statusstruct->revealer){ + if (status_thread_busy){ gtk_revealer_set_reveal_child(GTK_REVEALER(statusstruct->revealer),0); sleep(1); gtk_widget_destroy(statusstruct->revealer); @@ -2205,6 +2205,10 @@ void _yon_ubl_status_box_timed_remove(struct temp_statusbox *statusstruct){ status_thread_busy=0; } +void __yon_ubl_status_box_destroyed(){ + status_thread_busy=0; +} + void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type){ if (!status_thread_busy){ GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); @@ -2218,6 +2222,7 @@ void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int ti gtk_widget_show_all(revealer); gtk_revealer_set_reveal_child(GTK_REVEALER(revealer),1); + g_signal_connect(G_OBJECT(revealer),"destroy", G_CALLBACK(__yon_ubl_status_box_destroyed),NULL); gtk_widget_set_margin_bottom(label,9); gtk_widget_set_margin_top(label,9); diff --git a/source/ubl-utils.h b/source/ubl-utils.h index e01b857..fa0faab 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -15,6 +15,7 @@ #include #include #include +#include #include "../compile/ubl-cmake.h" #ifdef WEBKIT_FOUND -- 2.35.1 From 8e390d04a1125dfdb7c946ebf4eee863b32b6e4f Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 22 Nov 2023 17:16:27 +0600 Subject: [PATCH 19/39] Fixed saving of monitoring logs, fixed add window interface spacing --- source/ubl-settings-logging.c | 8 +++++--- ubl-settings-logging-add.glade | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 8a70527..e2815aa 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1668,6 +1668,7 @@ void on_log_save(GtkWidget *self, dictionary *dict){ if (!yon_char_is_empty(name)){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); GtkTreeIter iter; + int stat; if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->list),&iter); for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->list),&iter)){ @@ -1691,12 +1692,13 @@ void on_log_save(GtkWidget *self, dictionary *dict){ } } gtk_list_store_append(widgets->list,&iter); - int stat; - gtk_tree_model_get(GTK_TREE_MODEL(widgets->list),&iter,3,&stat,-1); - gtk_list_store_set(widgets->list,&iter,3,stat==0?1:stat==1?2:2,-1); + gtk_list_store_set(widgets->list,&iter,3,0,-1); + gtk_list_store_set(widgets->list,&iter,0,name,1,pathse,2,&desc ? desc : "",3,0,-1); yon_window_config_custom_window_set(GTK_WINDOW(window->MainWindow),"AddWindow"); } else { yon_window_config_custom_window_set(GTK_WINDOW(window->MainWindow),"EditWindow"); + gtk_tree_model_get(GTK_TREE_MODEL(widgets->list),&iter,3,&stat,-1); + gtk_list_store_set(widgets->list,&iter,3,stat==0?0:stat==1?2:2,-1); } gtk_list_store_set(widgets->list,&iter,0,name,1,pathse,2,&desc ? desc : "",-1); } diff --git a/ubl-settings-logging-add.glade b/ubl-settings-logging-add.glade index 4124d45..17d09b7 100644 --- a/ubl-settings-logging-add.glade +++ b/ubl-settings-logging-add.glade @@ -109,6 +109,7 @@ 5 5 vertical + 5 True -- 2.35.1 From 6dc10bafc806f288e0837e3fa0ea8180d314fa33 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 23 Nov 2023 15:54:23 +0600 Subject: [PATCH 20/39] String parsing function rework --- source/ubl-utils.c | 74 ++++++++++++++++++++++++++++++++++++---------- source/ubl-utils.h | 2 ++ 2 files changed, 61 insertions(+), 15 deletions(-) diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 8fdd809..76c5204 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -673,6 +673,33 @@ char *yon_char_replace(char *source, char *find, char*replace){ return source; } +/**yon_char_parse(char *parameters, int *size, char *divider) + * [EN] + * Parses string [parameters], divided by [divider], + * then returns parsed string array and sets [size] to + * size of returned array +*/ +// char **yon_char_parse(char *parameters, int *size, char *divider){ +// char **string=NULL; +// int i=1; +// string=malloc(sizeof(char*)); +// char *paramline=yon_char_new(parameters); +// char *param; +// while ((param=yon_char_divide_search(paramline,divider,1))){ +// string=realloc(string,sizeof(char*)*i); +// string[i-1]=yon_char_new(param); +// i++; +// if (strcmp(param,paramline)==0) break; +// } +// // string=realloc(string,sizeof(char*)*i); +// // string[i-1]=yon_char_new(paramline); +// // i++; +// // printf("%d\n",i); +// *size=i-1; +// return string; + +// } + /**yon_char_parse(char *parameters, int *size, char *divider) * [EN] * Parses string [parameters], divided by [divider], @@ -681,23 +708,20 @@ char *yon_char_replace(char *source, char *find, char*replace){ */ char **yon_char_parse(char *parameters, int *size, char *divider){ char **string=NULL; - int i=1; - string=malloc(sizeof(char*)); + *size=0; char *paramline=yon_char_new(parameters); - char *param; - while ((param=yon_char_divide_search(paramline,divider,1))){ - string=realloc(string,sizeof(char*)*i); - string[i-1]=yon_char_new(param); - i++; - if (strcmp(param,paramline)==0) break; - } - // string=realloc(string,sizeof(char*)*i); - // string[i-1]=yon_char_new(paramline); - // i++; - // printf("%d\n",i); - *size=i-1; + char *param = strstr(paramline,divider); + for (;param;param=strstr(paramline,divider)){ + string = yon_remalloc(string,sizeof(char*)*((*size)+1)); + string[(*size)]=yon_char_divide(paramline,strlen(paramline)-strlen(param)); + *size=(*size)+1; + } + if (string){ + string = yon_remalloc(string,sizeof(char*)*((*size)+1)); + string[(*size)]=paramline; + (*size)+=1; + } return string; - } /**yon_char_parsed_rip(char **char_string, int *size, int item_to_delete) @@ -746,6 +770,26 @@ int yon_char_parsed_check_exist(char **parameters, int size, char *param){ return -1; } +/**yon_char_parsed_check_repeats(char **parameters, int size) + * [EN] + * Checks if [parameters] string array of length [size] + * has repeated elements; + * [RU] + * Проверяет есть ли в массиве строк [parameters], размера [size] + * повторения +*/ +int yon_char_parsed_check_repeats(char **parameters, int size){ + for (int i=0;i Date: Thu, 23 Nov 2023 15:56:22 +0600 Subject: [PATCH 21/39] Added check for path repetition inside same log; Added 'Reset' button for journald menu --- Makefile | 2 + ...x.ubl-settings-logging.funnel-symbolic.svg | 45 +++++ source/ubl-settings-logging.c | 50 ++++- source/ubl-settings-logging.h | 1 + source/ubl-strings.h | 2 + ubl-settings-logging-filechooser.glade | 1 - ubl-settings-logging-journald.glade | 23 ++- ubl-settings-logging-logrotate.glade | 3 + ubl-settings-logging.pot | 174 +++++++++--------- ubl-settings-logging_ru.po | 174 +++++++++--------- 10 files changed, 305 insertions(+), 170 deletions(-) create mode 100644 icons/com.ublinux.ubl-settings-logging.funnel-symbolic.svg diff --git a/Makefile b/Makefile index 7e06a54..1306447 100644 --- a/Makefile +++ b/Makefile @@ -139,6 +139,7 @@ install: check uninstall @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.trash-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.sort-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.sync-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.funnel-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.generic1-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.generic2-symbolic.svg" @@ -150,6 +151,7 @@ install: check uninstall @install -Dm644 -t "${DESTDIR}/usr/share/${PKGNAME}/csv/" "journals_list.csv" @install -Dm644 -t "${DESTDIR}/usr/share/${PKGNAME}/csv/" "logging_services.csv" @install -Dm644 -t "${DESTDIR}/usr/share/polkit-1/actions/" "${CMAKE_BUILD_DIR}/com.ublinux.${PKGNAME}${PKGIDENT}.policy" + @install -Dm644 -t "${DESTDIR}/usr/share/polkit-1/actions/" "com.ublinux.${PKGNAME}.auth.policy" @if [ -z ${DESTDIR} ]; then \ [ -d "${DESTDIR}/usr/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}/usr/share/icons/hicolor/" &>/dev/null || true; \ update-desktop-database --quiet &>/dev/null || true; \ diff --git a/icons/com.ublinux.ubl-settings-logging.funnel-symbolic.svg b/icons/com.ublinux.ubl-settings-logging.funnel-symbolic.svg new file mode 100644 index 0000000..4aec04a --- /dev/null +++ b/icons/com.ublinux.ubl-settings-logging.funnel-symbolic.svg @@ -0,0 +1,45 @@ + + + + + + + + + + diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index e2815aa..023f30c 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -690,6 +690,15 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ return; } } + if (paths){ + int psize=0; + config_str paths_parsed = yon_char_parse(paths,&psize,","); + if (yon_char_parsed_check_repeats(paths_parsed,psize)){ + yon_ubl_status_highlight_incorrect(gtk_widget_get_parent(window->LogPathsTree)); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEAT_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + return; + } + } if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->RotationPeriodCheck))){ int active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo)); switch (active){ @@ -1370,6 +1379,36 @@ void yon_combo_compress_check(GtkComboBox *self, journald_window *window){ } } +void on_journald_reset(GtkWidget *self, journald_window *window){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogStorageCombo),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogCompressionCombo),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RedirectCombo),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->LowerSizeCombo),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->LowerTimeCombo),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogStorageCombo),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogFreeSpaceCombo),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->ForwardedTypeCombo),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationSizeMaxCombo),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogCompressionSizeCombo),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->DivideJournalFilesCombo),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogSizeMaxCombo),0); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->LogSizeMaxCheck),0); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->LogIntervalCheck),0); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->LogFreeSpaceCheck),0); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotationSizeMaxCheck),0); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->LogIntervalAmountCheck),0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->LogSizeMaxSpin),0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->LogIntervalSpin),0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->LogFreeSpaceSpin),0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->RotationSizeMaxSpin),0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->LogIntervalAmountSpin),0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->LogCompressionEntry),0); + gtk_entry_set_text(GTK_ENTRY(window->RedirectTTYEntry),""); + + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->LowerSizeEntry),0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->LowerTimeEntry),0); +} + void on_journald_save(GtkWidget *self, journald_window *window){ char *storage; int storage_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->LogStorageCombo)); @@ -1503,6 +1542,7 @@ journald_window *yon_journald_open(GtkWidget *self, main_window *widgets){ window->MainWindow=yon_gtk_builder_get_widget(builder,"MainWindow"); window->CancelButton=yon_gtk_builder_get_widget(builder,"CancelButton"); window->SaveButton=yon_gtk_builder_get_widget(builder,"SaveButton"); + window->ResetButton=yon_gtk_builder_get_widget(builder,"ResetButton"); window->LogNameLabel=yon_gtk_builder_get_widget(builder,"LogNameEntry"); window->LogDescriptionLabel=yon_gtk_builder_get_widget(builder,"LogDescriptionEntry"); window->LogStorageCombo=yon_gtk_builder_get_widget(builder,"LogStorageCombo"); @@ -1548,6 +1588,7 @@ journald_window *yon_journald_open(GtkWidget *self, main_window *widgets){ g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),"JournaldWindow"); g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_journald_save),window); + g_signal_connect(G_OBJECT(window->ResetButton),"clicked",G_CALLBACK(on_journald_reset),window); g_signal_connect(G_OBJECT(window->LogIntervalCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogIntervalSpin); g_signal_connect(G_OBJECT(window->LogIntervalCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogIntervalAmountCheck); @@ -1682,6 +1723,11 @@ void on_log_save(GtkWidget *self, dictionary *dict){ } int paths_size=0; config_str paths_parsed = yon_char_parse(paths,&paths_size,"\n"); + if (yon_char_parsed_check_repeats(paths_parsed,paths_size)){ + yon_ubl_status_highlight_incorrect(window->LogPathsBox); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEAT_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + return; + } int pathse_size=0; config_str pathse_parsed = yon_char_parse(pathse,&pathse_size,"\n"); @@ -2200,7 +2246,9 @@ main_window *setup_window(){ config_str log = yon_char_parse(journals[i],&log_size,";"); log[1] = yon_char_replace(log[1],",","\n"); gtk_list_store_append(widgets->list,&iter); - free(yon_char_parse(log[1],&psize,"\n")); + config_str sfafa = yon_char_parse(log[1],&psize,"\n"); + if (sfafa) + free(sfafa); gtk_list_store_set(widgets->list,&iter,0,log[0],1,log[1],2,_(log[2]),3,1,4,psize,-1); } config_str services = yon_file_open(services_list_path,&service_size); diff --git a/source/ubl-settings-logging.h b/source/ubl-settings-logging.h index 1d338de..a518e55 100644 --- a/source/ubl-settings-logging.h +++ b/source/ubl-settings-logging.h @@ -246,6 +246,7 @@ typedef struct { GtkWidget *MainWindow; GtkWidget *CancelButton; GtkWidget *SaveButton; + GtkWidget *ResetButton; GtkWidget *LogNameLabel; GtkWidget *LogDescriptionLabel; GtkWidget *LogStorageCombo; diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 2207240..06bf78e 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -101,6 +101,7 @@ #define DAYS_LABEL _("Days") #define WEEKS_LABEL _("Weeks") #define YEARS_LABEL _("Years") +#define RESET_LABEL _("Reset") //ubl-settings-logging-logrotate.glade #define LOGROTATE_LOG_JOURNAL_TAB_LABEL _("Log/Journal:") @@ -176,6 +177,7 @@ #define SUNDAY_LABEL _("Sunday*") #define REPEATED_PATHS_LABEL _("Same record already exists") #define EMPTY_IMPORTANT_LABEL _("Empty important field") +#define REPEAT_PATHS_LABEL _("Repeating paths") //ubl-settings-logging-logrotate-table.glade #define SYSTEM_CONFIGURATION_LABEL _("System configuration") diff --git a/ubl-settings-logging-filechooser.glade b/ubl-settings-logging-filechooser.glade index 28ddce1..3d0a484 100644 --- a/ubl-settings-logging-filechooser.glade +++ b/ubl-settings-logging-filechooser.glade @@ -33,7 +33,6 @@ Choose directory instead of file - True True False True diff --git a/ubl-settings-logging-journald.glade b/ubl-settings-logging-journald.glade index 28726b9..dd6c3a4 100644 --- a/ubl-settings-logging-journald.glade +++ b/ubl-settings-logging-journald.glade @@ -964,6 +964,20 @@ False end 5 + + + Reset + True + True + True + image5 + + + False + True + 0 + + Cancel @@ -975,7 +989,7 @@ True True - 0 + 1 @@ -989,7 +1003,7 @@ True True - 1 + 2 @@ -1048,4 +1062,9 @@ + + True + False + com.ublinux.ubl-settings-logging.funnel-symbolic + diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index 2b13c77..23fbfb5 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -318,6 +318,9 @@ True liststore1 False + + + Path diff --git a/ubl-settings-logging.pot b/ubl-settings-logging.pot index 419d0a9..21106d4 100644 --- a/ubl-settings-logging.pot +++ b/ubl-settings-logging.pot @@ -413,337 +413,345 @@ msgstr "" msgid "Years" msgstr "" -#: source/ubl-strings.h:106 -msgid "Log/Journal:" +#: source/ubl-strings.h:104 +msgid "Reset" msgstr "" #: source/ubl-strings.h:107 -msgid "Paths to log and journals files" +msgid "Log/Journal:" msgstr "" #: source/ubl-strings.h:108 -msgid "On" +msgid "Paths to log and journals files" msgstr "" #: source/ubl-strings.h:109 +msgid "On" +msgstr "" + +#: source/ubl-strings.h:110 msgid "Off" msgstr "" -#: source/ubl-strings.h:110 source/ubl-strings.h:164 +#: source/ubl-strings.h:111 source/ubl-strings.h:165 msgid "Scenarios" msgstr "" -#: source/ubl-strings.h:111 source/ubl-strings.h:163 +#: source/ubl-strings.h:112 source/ubl-strings.h:164 msgid "Scenarios are running for each rotated journal" msgstr "" -#: source/ubl-strings.h:112 +#: source/ubl-strings.h:113 msgid "Command before rotation (one time):" msgstr "" -#: source/ubl-strings.h:113 +#: source/ubl-strings.h:114 msgid "Command after rotation (one time):" msgstr "" -#: source/ubl-strings.h:114 +#: source/ubl-strings.h:115 msgid "Command before rotation:" msgstr "" -#: source/ubl-strings.h:115 +#: source/ubl-strings.h:116 msgid "Command after rotation:" msgstr "" -#: source/ubl-strings.h:116 +#: source/ubl-strings.h:117 msgid "Rotation period:" msgstr "" -#: source/ubl-strings.h:117 +#: source/ubl-strings.h:118 msgid "Maximum size of file:" msgstr "" -#: source/ubl-strings.h:118 +#: source/ubl-strings.h:119 msgid "Checking frequency configuration" msgstr "" -#: source/ubl-strings.h:119 +#: source/ubl-strings.h:120 msgid "File amount:" msgstr "" -#: source/ubl-strings.h:120 +#: source/ubl-strings.h:121 msgid "Store at:" msgstr "" -#: source/ubl-strings.h:121 +#: source/ubl-strings.h:122 msgid "Rotation as user:" msgstr "" -#: source/ubl-strings.h:122 +#: source/ubl-strings.h:123 msgid "Rotation as group:" msgstr "" -#: source/ubl-strings.h:123 +#: source/ubl-strings.h:124 msgid "Rotation configuration" msgstr "" -#: source/ubl-strings.h:124 +#: source/ubl-strings.h:125 msgid "Error processing:" msgstr "" -#: source/ubl-strings.h:125 +#: source/ubl-strings.h:126 msgid "Rotation of jurnal even when it is empty:" msgstr "" -#: source/ubl-strings.h:126 +#: source/ubl-strings.h:127 msgid "Do not rotate journal younger than" msgstr "" -#: source/ubl-strings.h:127 +#: source/ubl-strings.h:128 msgid "days" msgstr "" -#: source/ubl-strings.h:128 +#: source/ubl-strings.h:129 msgid "Delete rotated journals older than" msgstr "" -#: source/ubl-strings.h:129 +#: source/ubl-strings.h:130 msgid "Rotate journals if size more than" msgstr "" -#: source/ubl-strings.h:130 +#: source/ubl-strings.h:131 msgid "but not earlier than the specified time interval" msgstr "" -#: source/ubl-strings.h:131 +#: source/ubl-strings.h:132 msgid "before specified time interval" msgstr "" -#: source/ubl-strings.h:132 +#: source/ubl-strings.h:133 msgid "File choosing configuration" msgstr "" -#: source/ubl-strings.h:133 +#: source/ubl-strings.h:134 msgid "Create log" msgstr "" -#: source/ubl-strings.h:134 +#: source/ubl-strings.h:135 msgid "as user:" msgstr "" -#: source/ubl-strings.h:135 +#: source/ubl-strings.h:136 msgid "as group:" msgstr "" -#: source/ubl-strings.h:136 +#: source/ubl-strings.h:137 msgid "rules:" msgstr "" -#: source/ubl-strings.h:137 +#: source/ubl-strings.h:138 msgid "" "Cut source journal fileafter copy creating instead of moving old journal " "file and creating new one" msgstr "" -#: source/ubl-strings.h:138 +#: source/ubl-strings.h:139 msgid "Files and directories configuration" msgstr "" -#: source/ubl-strings.h:139 +#: source/ubl-strings.h:140 msgid "Delay compression by one journal in queue:" msgstr "" -#: source/ubl-strings.h:140 +#: source/ubl-strings.h:141 msgid "Compression configuration" msgstr "" -#: source/ubl-strings.h:141 +#: source/ubl-strings.h:142 msgid "Save original log file after rotation if it has specified extension:" msgstr "" -#: source/ubl-strings.h:142 +#: source/ubl-strings.h:143 msgid "Add date of rotation before log header" msgstr "" -#: source/ubl-strings.h:143 +#: source/ubl-strings.h:144 msgid "Number from which numbering of old logs will begin" msgstr "" -#: source/ubl-strings.h:144 +#: source/ubl-strings.h:145 msgid "Filename configuration" msgstr "" -#: source/ubl-strings.h:145 +#: source/ubl-strings.h:146 msgid "Email after rotation:" msgstr "" -#: source/ubl-strings.h:146 +#: source/ubl-strings.h:147 msgid "adress:" msgstr "" -#: source/ubl-strings.h:147 +#: source/ubl-strings.h:148 msgid "contents:" msgstr "" -#: source/ubl-strings.h:148 source/ubl-strings.h:161 +#: source/ubl-strings.h:149 source/ubl-strings.h:162 msgid "Message configuration" msgstr "" -#: source/ubl-strings.h:149 +#: source/ubl-strings.h:150 msgid "Manual input:" msgstr "" -#: source/ubl-strings.h:150 +#: source/ubl-strings.h:151 msgid "Log (-s) size:" msgstr "" -#: source/ubl-strings.h:151 +#: source/ubl-strings.h:152 msgid "Same directory" msgstr "" -#: source/ubl-strings.h:152 +#: source/ubl-strings.h:153 msgid "Separate directory" msgstr "" -#: source/ubl-strings.h:153 +#: source/ubl-strings.h:154 msgid "Output errors if log file does not exist*" msgstr "" -#: source/ubl-strings.h:154 +#: source/ubl-strings.h:155 msgid "Do not output errors if log file does not exist" msgstr "" -#: source/ubl-strings.h:155 +#: source/ubl-strings.h:156 msgid "Do not output" msgstr "" -#: source/ubl-strings.h:156 +#: source/ubl-strings.h:157 msgid "Output errors" msgstr "" -#: source/ubl-strings.h:157 +#: source/ubl-strings.h:158 msgid "Send Email" msgstr "" -#: source/ubl-strings.h:158 +#: source/ubl-strings.h:159 msgid "Don't send Email" msgstr "" -#: source/ubl-strings.h:159 +#: source/ubl-strings.h:160 msgid "First rotated copy" msgstr "" -#: source/ubl-strings.h:160 +#: source/ubl-strings.h:161 msgid "Last rotated copy" msgstr "" -#: source/ubl-strings.h:162 +#: source/ubl-strings.h:163 msgid "Endwork command:" msgstr "" -#: source/ubl-strings.h:165 +#: source/ubl-strings.h:166 msgid "Hourly" msgstr "" -#: source/ubl-strings.h:166 +#: source/ubl-strings.h:167 msgid "Daily" msgstr "" -#: source/ubl-strings.h:167 +#: source/ubl-strings.h:168 msgid "Weekly*" msgstr "" -#: source/ubl-strings.h:168 +#: source/ubl-strings.h:169 msgid "Monthly" msgstr "" -#: source/ubl-strings.h:169 +#: source/ubl-strings.h:170 msgid "Yearly" msgstr "" -#: source/ubl-strings.h:170 +#: source/ubl-strings.h:171 msgid "Monday" msgstr "" -#: source/ubl-strings.h:171 +#: source/ubl-strings.h:172 msgid "Tuesday" msgstr "" -#: source/ubl-strings.h:172 +#: source/ubl-strings.h:173 msgid "Wednesday" msgstr "" -#: source/ubl-strings.h:173 +#: source/ubl-strings.h:174 msgid "Thursday" msgstr "" -#: source/ubl-strings.h:174 +#: source/ubl-strings.h:175 msgid "Friday" msgstr "" -#: source/ubl-strings.h:175 +#: source/ubl-strings.h:176 msgid "Saturday" msgstr "" -#: source/ubl-strings.h:176 +#: source/ubl-strings.h:177 msgid "Sunday*" msgstr "" -#: source/ubl-strings.h:177 +#: source/ubl-strings.h:178 msgid "Same record already exists" msgstr "" -#: source/ubl-strings.h:178 +#: source/ubl-strings.h:179 msgid "Empty important field" msgstr "" -#: source/ubl-strings.h:181 +#: source/ubl-strings.h:180 +msgid "Repeating paths" +msgstr "" + +#: source/ubl-strings.h:183 msgid "System configuration" msgstr "" -#: source/ubl-strings.h:182 +#: source/ubl-strings.h:184 msgid "Applications configuration" msgstr "" -#: source/ubl-strings.h:185 +#: source/ubl-strings.h:187 msgid "Path (-s):" msgstr "" -#: source/ubl-strings.h:186 +#: source/ubl-strings.h:188 msgid "Control:" msgstr "" -#: source/ubl-strings.h:187 +#: source/ubl-strings.h:189 msgid "Log file" msgstr "" -#: source/ubl-strings.h:188 +#: source/ubl-strings.h:190 msgid "Name:" msgstr "" -#: source/ubl-strings.h:191 +#: source/ubl-strings.h:193 msgid "Owner rules" msgstr "" -#: source/ubl-strings.h:192 +#: source/ubl-strings.h:194 msgid "Group rules" msgstr "" -#: source/ubl-strings.h:193 +#: source/ubl-strings.h:195 msgid "Public rules" msgstr "" -#: source/ubl-strings.h:194 +#: source/ubl-strings.h:196 msgid "Read" msgstr "" -#: source/ubl-strings.h:195 +#: source/ubl-strings.h:197 msgid "Write" msgstr "" -#: source/ubl-strings.h:196 +#: source/ubl-strings.h:198 msgid "Execute" msgstr "" -#: source/ubl-strings.h:197 +#: source/ubl-strings.h:199 msgid "Value:" msgstr "" diff --git a/ubl-settings-logging_ru.po b/ubl-settings-logging_ru.po index 1ffaaf0..5a22a2e 100644 --- a/ubl-settings-logging_ru.po +++ b/ubl-settings-logging_ru.po @@ -423,131 +423,135 @@ msgstr "Недель" msgid "Years" msgstr "Лет" -#: source/ubl-strings.h:106 +#: source/ubl-strings.h:104 +msgid "Reset" +msgstr "По умлочанию" + +#: source/ubl-strings.h:107 msgid "Log/Journal:" msgstr "Лог/Журнал:" -#: source/ubl-strings.h:107 +#: source/ubl-strings.h:108 msgid "Paths to log and journals files" msgstr "Пути к файлам лога/журнала" -#: source/ubl-strings.h:108 +#: source/ubl-strings.h:109 msgid "On" msgstr "Включено" -#: source/ubl-strings.h:109 +#: source/ubl-strings.h:110 msgid "Off" msgstr "Выключено" -#: source/ubl-strings.h:110 source/ubl-strings.h:164 +#: source/ubl-strings.h:111 source/ubl-strings.h:165 msgid "Scenarios" msgstr "Сценарии" -#: source/ubl-strings.h:111 source/ubl-strings.h:163 +#: source/ubl-strings.h:112 source/ubl-strings.h:164 msgid "Scenarios are running for each rotated journal" msgstr "Сценарии запускаются для каждого ротируемого журнала" -#: source/ubl-strings.h:112 +#: source/ubl-strings.h:113 msgid "Command before rotation (one time):" msgstr "Команда перед ротацией (один раз):" -#: source/ubl-strings.h:113 +#: source/ubl-strings.h:114 msgid "Command after rotation (one time):" msgstr "Команда после ротации (один раз):" -#: source/ubl-strings.h:114 +#: source/ubl-strings.h:115 msgid "Command before rotation:" msgstr "Команда перед ротацией:" -#: source/ubl-strings.h:115 +#: source/ubl-strings.h:116 msgid "Command after rotation:" msgstr "Команда после ротации:" -#: source/ubl-strings.h:116 +#: source/ubl-strings.h:117 msgid "Rotation period:" msgstr "Период ротации:" -#: source/ubl-strings.h:117 +#: source/ubl-strings.h:118 msgid "Maximum size of file:" msgstr "Максимальный размер файла:" -#: source/ubl-strings.h:118 +#: source/ubl-strings.h:119 msgid "Checking frequency configuration" msgstr "Настройки частоты проверки" -#: source/ubl-strings.h:119 +#: source/ubl-strings.h:120 msgid "File amount:" msgstr "Количество файлов:" -#: source/ubl-strings.h:120 +#: source/ubl-strings.h:121 msgid "Store at:" msgstr "Хранить в:" -#: source/ubl-strings.h:121 +#: source/ubl-strings.h:122 msgid "Rotation as user:" msgstr "Ротация от пользователя:" -#: source/ubl-strings.h:122 +#: source/ubl-strings.h:123 msgid "Rotation as group:" msgstr "Ротация от группы:" -#: source/ubl-strings.h:123 +#: source/ubl-strings.h:124 msgid "Rotation configuration" msgstr "Настройки ротации" -#: source/ubl-strings.h:124 +#: source/ubl-strings.h:125 msgid "Error processing:" msgstr "Обработка ошибок:" -#: source/ubl-strings.h:125 +#: source/ubl-strings.h:126 msgid "Rotation of jurnal even when it is empty:" msgstr "Ротация файла журнала даже если он пуст:" -#: source/ubl-strings.h:126 +#: source/ubl-strings.h:127 msgid "Do not rotate journal younger than" msgstr "Не ротировать журналы, возраст которых меньше" -#: source/ubl-strings.h:127 +#: source/ubl-strings.h:128 msgid "days" msgstr "дней" -#: source/ubl-strings.h:128 +#: source/ubl-strings.h:129 msgid "Delete rotated journals older than" msgstr "Удалить ротированные журналы старше" -#: source/ubl-strings.h:129 +#: source/ubl-strings.h:130 msgid "Rotate journals if size more than" msgstr "Ротация журналов, если размер превышает" -#: source/ubl-strings.h:130 +#: source/ubl-strings.h:131 msgid "but not earlier than the specified time interval" msgstr "но не раньше указанного интервала времени" -#: source/ubl-strings.h:131 +#: source/ubl-strings.h:132 msgid "before specified time interval" msgstr "до истечения указанного интервала времени" -#: source/ubl-strings.h:132 +#: source/ubl-strings.h:133 msgid "File choosing configuration" msgstr "Настройки выбора файла" -#: source/ubl-strings.h:133 +#: source/ubl-strings.h:134 msgid "Create log" msgstr "Создавать лог" -#: source/ubl-strings.h:134 +#: source/ubl-strings.h:135 msgid "as user:" msgstr "от пользователя:" -#: source/ubl-strings.h:135 +#: source/ubl-strings.h:136 msgid "as group:" msgstr "от группы:" -#: source/ubl-strings.h:136 +#: source/ubl-strings.h:137 msgid "rules:" msgstr "права:" -#: source/ubl-strings.h:137 +#: source/ubl-strings.h:138 msgid "" "Cut source journal fileafter copy creating instead of moving old journal " "file and creating new one" @@ -555,209 +559,213 @@ msgstr "" "После создания копии, обрезать исходный файл журнала взамен перемещения " "старого файла журнала и создания нового" -#: source/ubl-strings.h:138 +#: source/ubl-strings.h:139 msgid "Files and directories configuration" msgstr "Настройки файлов и папок" -#: source/ubl-strings.h:139 +#: source/ubl-strings.h:140 msgid "Delay compression by one journal in queue:" msgstr "Отложить сжание на один журнал в очереди:" -#: source/ubl-strings.h:140 +#: source/ubl-strings.h:141 msgid "Compression configuration" msgstr "Настройка сжатия" -#: source/ubl-strings.h:141 +#: source/ubl-strings.h:142 msgid "Save original log file after rotation if it has specified extension:" msgstr "" "Сохранять оригинальный лог после ротации, если у него указано расширение:" -#: source/ubl-strings.h:142 +#: source/ubl-strings.h:143 msgid "Add date of rotation before log header" msgstr "Добавлять дату ротации перед заголовком старого лога:" -#: source/ubl-strings.h:143 +#: source/ubl-strings.h:144 msgid "Number from which numbering of old logs will begin" msgstr "Номер, с которого будет начата нумерация старых логов:" -#: source/ubl-strings.h:144 +#: source/ubl-strings.h:145 msgid "Filename configuration" msgstr "Настройка имени файлов" -#: source/ubl-strings.h:145 +#: source/ubl-strings.h:146 msgid "Email after rotation:" msgstr "Отправка Email после ротации:" -#: source/ubl-strings.h:146 +#: source/ubl-strings.h:147 msgid "adress:" msgstr "на адрес:" -#: source/ubl-strings.h:147 +#: source/ubl-strings.h:148 msgid "contents:" msgstr "содержимое:" -#: source/ubl-strings.h:148 source/ubl-strings.h:161 +#: source/ubl-strings.h:149 source/ubl-strings.h:162 msgid "Message configuration" msgstr "Настройка сообщения" -#: source/ubl-strings.h:149 +#: source/ubl-strings.h:150 msgid "Manual input:" msgstr "Команды настройки" -#: source/ubl-strings.h:150 +#: source/ubl-strings.h:151 msgid "Log (-s) size:" msgstr "Общий размер лога (-ов):" -#: source/ubl-strings.h:151 +#: source/ubl-strings.h:152 msgid "Same directory" msgstr "Той же папке" -#: source/ubl-strings.h:152 +#: source/ubl-strings.h:153 msgid "Separate directory" msgstr "Другой папке" -#: source/ubl-strings.h:153 +#: source/ubl-strings.h:154 msgid "Output errors if log file does not exist*" msgstr "Выводить ошибки, если лог файла не существует*" -#: source/ubl-strings.h:154 +#: source/ubl-strings.h:155 msgid "Do not output errors if log file does not exist" msgstr "Не выводить ошибки, если лог файла не существует" -#: source/ubl-strings.h:155 +#: source/ubl-strings.h:156 msgid "Do not output" msgstr "Не выводить" -#: source/ubl-strings.h:156 +#: source/ubl-strings.h:157 msgid "Output errors" msgstr "Выводить ошибки" -#: source/ubl-strings.h:157 +#: source/ubl-strings.h:158 msgid "Send Email" msgstr "Отправлять Email" -#: source/ubl-strings.h:158 +#: source/ubl-strings.h:159 msgid "Don't send Email" msgstr "Не отправлять Email" -#: source/ubl-strings.h:159 +#: source/ubl-strings.h:160 msgid "First rotated copy" msgstr "Первая ротированная копия" -#: source/ubl-strings.h:160 +#: source/ubl-strings.h:161 msgid "Last rotated copy" msgstr "Последняя ротированная копия" -#: source/ubl-strings.h:162 +#: source/ubl-strings.h:163 msgid "Endwork command:" msgstr "Команда перед удалением файла журнала:" -#: source/ubl-strings.h:165 +#: source/ubl-strings.h:166 #, fuzzy msgid "Hourly" msgstr "Час" -#: source/ubl-strings.h:166 +#: source/ubl-strings.h:167 msgid "Daily" msgstr "День" -#: source/ubl-strings.h:167 +#: source/ubl-strings.h:168 msgid "Weekly*" msgstr "Неделя*" -#: source/ubl-strings.h:168 +#: source/ubl-strings.h:169 msgid "Monthly" msgstr "Месяц" -#: source/ubl-strings.h:169 +#: source/ubl-strings.h:170 msgid "Yearly" msgstr "Год" -#: source/ubl-strings.h:170 +#: source/ubl-strings.h:171 msgid "Monday" msgstr "Понедельник" -#: source/ubl-strings.h:171 +#: source/ubl-strings.h:172 msgid "Tuesday" msgstr "Вторник" -#: source/ubl-strings.h:172 +#: source/ubl-strings.h:173 msgid "Wednesday" msgstr "Среда" -#: source/ubl-strings.h:173 +#: source/ubl-strings.h:174 msgid "Thursday" msgstr "Четверг" -#: source/ubl-strings.h:174 +#: source/ubl-strings.h:175 msgid "Friday" msgstr "Пятница" -#: source/ubl-strings.h:175 +#: source/ubl-strings.h:176 msgid "Saturday" msgstr "Суббота" -#: source/ubl-strings.h:176 +#: source/ubl-strings.h:177 msgid "Sunday*" msgstr "Воскресенье*" -#: source/ubl-strings.h:177 +#: source/ubl-strings.h:178 msgid "Same record already exists" msgstr "Такая запись уже существует" -#: source/ubl-strings.h:178 +#: source/ubl-strings.h:179 msgid "Empty important field" msgstr "Важное поле не заполнено" -#: source/ubl-strings.h:181 +#: source/ubl-strings.h:180 +msgid "Repeating paths" +msgstr "Повторяющиеся пути" + +#: source/ubl-strings.h:183 msgid "System configuration" msgstr "Настройки системы" -#: source/ubl-strings.h:182 +#: source/ubl-strings.h:184 msgid "Applications configuration" msgstr "Настройки приложений" -#: source/ubl-strings.h:185 +#: source/ubl-strings.h:187 msgid "Path (-s):" msgstr "Путь (-и):" -#: source/ubl-strings.h:186 +#: source/ubl-strings.h:188 msgid "Control:" msgstr "Управление:" -#: source/ubl-strings.h:187 +#: source/ubl-strings.h:189 msgid "Log file" msgstr "Файл лога" -#: source/ubl-strings.h:188 +#: source/ubl-strings.h:190 msgid "Name:" msgstr "Имя:" -#: source/ubl-strings.h:191 +#: source/ubl-strings.h:193 msgid "Owner rules" msgstr "Правила владельца" -#: source/ubl-strings.h:192 +#: source/ubl-strings.h:194 msgid "Group rules" msgstr "Правила группы" -#: source/ubl-strings.h:193 +#: source/ubl-strings.h:195 msgid "Public rules" msgstr "Правила остальных" -#: source/ubl-strings.h:194 +#: source/ubl-strings.h:196 msgid "Read" msgstr "Чтение" -#: source/ubl-strings.h:195 +#: source/ubl-strings.h:197 msgid "Write" msgstr "Запись" -#: source/ubl-strings.h:196 +#: source/ubl-strings.h:198 msgid "Execute" msgstr "Исполнение" -#: source/ubl-strings.h:197 +#: source/ubl-strings.h:199 msgid "Value:" msgstr "Значение:" -- 2.35.1 From 325e891bbaa5f1190026593a180350612edc1d65 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 23 Nov 2023 18:17:36 +0600 Subject: [PATCH 22/39] Separate tab for each log file --- gresource.xml | 1 + source/CMakeLists.txt | 1 + source/ubl-settings-logging.c | 84 ++++++++++++++++++---------- source/ubl-settings-logging.h | 7 ++- source/ubl-utils.c | 2 - ubl-settings-logging-inspector.glade | 32 +---------- ubl-settings-logging-terminal.glade | 44 +++++++++++++++ 7 files changed, 108 insertions(+), 63 deletions(-) create mode 100644 ubl-settings-logging-terminal.glade diff --git a/gresource.xml b/gresource.xml index 1f26a40..557ead6 100644 --- a/gresource.xml +++ b/gresource.xml @@ -10,6 +10,7 @@ ubl-settings-logging-rules.glade ubl-settings-logging-filechooser.glade ubl-settings-logging-logrotate-table.glade + ubl-settings-logging-terminal.glade ubl-settings-logging.css diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 37ef092..c09ec59 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -49,6 +49,7 @@ set(DEPENDFILES ../ubl-settings-logging-logrotate.glade ../ubl-settings-logging-logrotate-table.glade ../ubl-settings-logging-filechooser.glade + ../ubl-settings-logging-terminal.glade ../gresource.xml ../ubl-settings-logging-banner.png ../ubl-settings-logging.css diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 023f30c..171a4eb 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -237,66 +237,93 @@ void on_inspector_update(GtkWidget *self, inspector_window *window){ GtkTextIter titer,titerend; config_str output; if (!strcmp(window->journal_name,"journald")){ + GtkWidget *terminal = (GtkWidget*)window->terminals->first->data; if (self==window->UpdateButton){ switch(window->last_mode){ case 0: - yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_command,NULL,NULL); + yon_terminal_integrated_start(terminal, get_journal_output_command,NULL,NULL); break; case 1: - yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_since_boot_command,NULL,NULL); + yon_terminal_integrated_start(terminal, get_journal_output_since_boot_command,NULL,NULL); break; case 2: - yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_followed_command,NULL,NULL); + yon_terminal_integrated_start(terminal, get_journal_output_followed_command,NULL,NULL); break; case 3: - yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_kernel_command,NULL,NULL); + yon_terminal_integrated_start(terminal, get_journal_output_kernel_command,NULL,NULL); break; case 4: - yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_prioritied_command,NULL,NULL); + yon_terminal_integrated_start(terminal, get_journal_output_prioritied_command,NULL,NULL); break; case 5: - yon_terminal_integrated_start(window->LoggingTerminal, get_journal_all_boots_command,NULL,NULL); + yon_terminal_integrated_start(terminal, get_journal_all_boots_command,NULL,NULL); break; case 6: - yon_terminal_integrated_start(window->LoggingTerminal, get_journal_all_units_command,NULL,NULL); + yon_terminal_integrated_start(terminal, get_journal_all_units_command,NULL,NULL); break; case 7: - yon_terminal_integrated_start(window->LoggingTerminal, get_journal_init_tree_command,NULL,NULL); + yon_terminal_integrated_start(terminal, get_journal_init_tree_command,NULL,NULL); break; } } if (self==window->ShowSinceBootButton){ window->last_mode=1; - yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_since_boot_command,NULL,NULL); + yon_terminal_integrated_start(terminal, get_journal_output_since_boot_command,NULL,NULL); } if (self==window->NewMessagesButton){ window->last_mode=2; - yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_followed_command,NULL,NULL); + yon_terminal_integrated_start(terminal, get_journal_output_followed_command,NULL,NULL); } if (self==window->ShowKernelButton){ window->last_mode=3; - yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_kernel_command,NULL,NULL); + yon_terminal_integrated_start(terminal, get_journal_output_kernel_command,NULL,NULL); } if (self==window->ShowPriorityButton){ window->last_mode=4; - yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_prioritied_command,NULL,NULL); + yon_terminal_integrated_start(terminal, get_journal_output_prioritied_command,NULL,NULL); } if (self==window->ShowAllBootsButton){ window->last_mode=5; - yon_terminal_integrated_start(window->LoggingTerminal, get_journal_all_boots_command,NULL,NULL); + yon_terminal_integrated_start(terminal, get_journal_all_boots_command,NULL,NULL); } if (self==window->ShowAllUnitsButton){ window->last_mode=6; - yon_terminal_integrated_start(window->LoggingTerminal, get_journal_all_units_command,NULL,NULL); + yon_terminal_integrated_start(terminal, get_journal_all_units_command,NULL,NULL); } if (self==window->ShowInitTreeButton){ window->last_mode=7; - yon_terminal_integrated_start(window->LoggingTerminal, get_journal_init_tree_command,NULL,NULL); + yon_terminal_integrated_start(terminal, get_journal_init_tree_command,NULL,NULL); } } else { - window->journal_paths = yon_char_replace(window->journal_paths,"\n"," "); - yon_terminal_integrated_start(window->LoggingTerminal,yon_char_unite("cat ",window->journal_paths,NULL),NULL,NULL); + if (window->terminals){ + dictionary *dict=NULL; + for_dictionaries (dict,window->terminals){ + GtkWidget *terminal = (GtkWidget*)dict->data; + // window->journal_paths = yon_char_replace(window->journal_paths,"\n"," "); + yon_terminal_integrated_start(terminal,yon_char_unite("cat ",dict->key,NULL),NULL,NULL); + } } + } + +} + +GtkWidget *yon_inspector_add_terminal(inspector_window *window,char *page_name){ + GtkBuilder *builder = gtk_builder_new_from_resource(glade_terminal_path); + GtkWidget *box = yon_gtk_builder_get_widget(builder,"TerminalBox"); + GtkWidget *terminal = yon_gtk_builder_get_widget(builder,"LoggingTerminal"); + GtkWidget *label = gtk_label_new(page_name); + gtk_notebook_append_page(GTK_NOTEBOOK(window->LoggingNotebook),box,label); + GdkRGBA rgba; + rgba.alpha=1; + rgba.red=0.95; + rgba.green=0.95; + rgba.blue=0.95; + vte_terminal_set_color_background(VTE_TERMINAL(terminal),&rgba); + rgba.red=0; + rgba.green=0; + rgba.blue=0; + vte_terminal_set_color_foreground(VTE_TERMINAL(terminal),&rgba); + return terminal; } void on_inspector_open(GtkWidget *self, main_window *widgets){ @@ -310,8 +337,8 @@ void on_inspector_open(GtkWidget *self, main_window *widgets){ window->ShowAllBootsButton=yon_gtk_builder_get_widget(builder,"ShowAllBootsButton"); window->ShowAllUnitsButton=yon_gtk_builder_get_widget(builder,"ShowAllUnitsButton"); window->ShowInitTreeButton=yon_gtk_builder_get_widget(builder,"ShowInitTreeButton"); + window->LoggingNotebook=yon_gtk_builder_get_widget(builder,"MainNotebook"); window->UpdateButton=yon_gtk_builder_get_widget(builder,"UpdateButton"); - window->LoggingTerminal=yon_gtk_builder_get_widget(builder,"LoggingTerminal"); window->JournalActionsBox=yon_gtk_builder_get_widget(builder,"JournalActionsBox"); yon_window_config_custom_window_setup(GTK_WINDOW(window->MainWindow),"InspectorWindow"); gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); @@ -320,16 +347,6 @@ void on_inspector_open(GtkWidget *self, main_window *widgets){ GtkTreeIter iter; char *name; char *paths; - GdkRGBA rgba; - rgba.alpha=1; - rgba.red=0.95; - rgba.green=0.95; - rgba.blue=0.95; - vte_terminal_set_color_background(VTE_TERMINAL(window->LoggingTerminal),&rgba); - rgba.red=0; - rgba.green=0; - rgba.blue=0; - vte_terminal_set_color_foreground(VTE_TERMINAL(window->LoggingTerminal),&rgba); g_signal_connect(G_OBJECT(window->UpdateButton),"clicked", G_CALLBACK(on_inspector_update),window); g_signal_connect(G_OBJECT(window->ShowKernelButton),"clicked", G_CALLBACK(on_inspector_update),window); g_signal_connect(G_OBJECT(window->NewMessagesButton),"clicked", G_CALLBACK(on_inspector_update),window); @@ -341,14 +358,21 @@ void on_inspector_open(GtkWidget *self, main_window *widgets){ if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ gtk_tree_model_get(model,&iter,0,&name,1,&paths,-1); + window->journal_name=name; + window->journal_paths=yon_char_parse(paths,&window->journal_size,"\n"); + window->terminals = NULL; if (strcmp(name,"journald")){ window->last_mode=-1; + for (int i=0;ijournal_size;i++){ + if (!access(window->journal_paths[i],F_OK)||!window->terminals) + yon_dictionary_add_or_create_if_exists_with_data(window->terminals,window->journal_paths[i],yon_inspector_add_terminal(window,window->journal_paths[i])); + } gtk_widget_hide(window->JournalActionsBox); } else { window->last_mode=0; + yon_dictionary_add_or_create_if_exists_with_data(window->terminals,"Journald",yon_inspector_add_terminal(window,"Journald")); } - window->journal_name=name; - window->journal_paths=paths; + on_inspector_update(window->UpdateButton,window); gtk_widget_show(window->MainWindow); } diff --git a/source/ubl-settings-logging.h b/source/ubl-settings-logging.h index a518e55..a27d996 100644 --- a/source/ubl-settings-logging.h +++ b/source/ubl-settings-logging.h @@ -31,6 +31,7 @@ #define glade_logrotate_table_path "/com/ublinux/ui/ubl-settings-logging-logrotate-table.glade" #define glade_rules_path "/com/ublinux/ui/ubl-settings-logging-rules.glade" #define glade_filechooser_path "/com/ublinux/ui/ubl-settings-logging-filechooser.glade" +#define glade_terminal_path "/com/ublinux/ui/ubl-settings-logging-terminal.glade" #define banner_path "/com/ublinux/images/ubl-settings-logging-banner.png" #define CssPath "/com/ublinux/css/ubl-settings-logging.css" #define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) @@ -197,11 +198,13 @@ GtkWidget *UpdateButton; GtkWidget *ShowAllBootsButton; GtkWidget *ShowAllUnitsButton; GtkWidget *ShowInitTreeButton; -GtkWidget *LoggingTerminal; +GtkWidget *LoggingNotebook; GtkWidget *JournalActionsBox; +dictionary *terminals; int last_mode; char *journal_name; -char *journal_paths; +int journal_size; +config_str journal_paths; } inspector_window; diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 76c5204..6d9e1ce 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -716,11 +716,9 @@ char **yon_char_parse(char *parameters, int *size, char *divider){ string[(*size)]=yon_char_divide(paramline,strlen(paramline)-strlen(param)); *size=(*size)+1; } - if (string){ string = yon_remalloc(string,sizeof(char*)*((*size)+1)); string[(*size)]=paramline; (*size)+=1; - } return string; } diff --git a/ubl-settings-logging-inspector.glade b/ubl-settings-logging-inspector.glade index f935238..bc16007 100644 --- a/ubl-settings-logging-inspector.glade +++ b/ubl-settings-logging-inspector.glade @@ -2,7 +2,6 @@ - 100 @@ -14,11 +13,6 @@ 1 10 - - 100 - 1 - 10 - True False @@ -242,16 +236,10 @@ - + True - False - natural - adjustment3 - natural - UTF-8 - 0 - True - False + True + True True @@ -259,19 +247,6 @@ 1 - - - True - False - vertical - adjustment3 - - - False - True - 2 - - True @@ -321,5 +296,4 @@ - diff --git a/ubl-settings-logging-terminal.glade b/ubl-settings-logging-terminal.glade new file mode 100644 index 0000000..3d2118e --- /dev/null +++ b/ubl-settings-logging-terminal.glade @@ -0,0 +1,44 @@ + + + + + + + True + False + + + True + True + natural + natural + UTF-8 + 0 + True + False + + + True + True + 0 + + + + + True + False + vertical + + + False + True + 1 + + + + + 100 + 1 + 10 + + -- 2.35.1 From c0b1206eded39636494fe64a7de6fb5948eb4177 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 24 Nov 2023 11:37:33 +0600 Subject: [PATCH 23/39] Changed error text for unfound files at inspector window --- source/ubl-settings-logging.c | 61 +++++++++++++++++++---------- source/ubl-strings.h | 5 ++- source/ubl-utils.c | 56 +++++++++++++++++++++++++- source/ubl-utils.h | 4 ++ ubl-settings-logging-terminal.glade | 59 ++++++++++++++++++++++------ ubl-settings-logging.pot | 4 ++ ubl-settings-logging_ru.po | 4 ++ 7 files changed, 158 insertions(+), 35 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 171a4eb..f2a6aa2 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -307,23 +307,34 @@ void on_inspector_update(GtkWidget *self, inspector_window *window){ } -GtkWidget *yon_inspector_add_terminal(inspector_window *window,char *page_name){ +GtkWidget *yon_inspector_add_terminal(inspector_window *window,char *page_name,int mode){ GtkBuilder *builder = gtk_builder_new_from_resource(glade_terminal_path); GtkWidget *box = yon_gtk_builder_get_widget(builder,"TerminalBox"); GtkWidget *terminal = yon_gtk_builder_get_widget(builder,"LoggingTerminal"); + GtkWidget *unfound_label = yon_gtk_builder_get_widget(builder,"UnfoundLabel"); GtkWidget *label = gtk_label_new(page_name); gtk_notebook_append_page(GTK_NOTEBOOK(window->LoggingNotebook),box,label); - GdkRGBA rgba; - rgba.alpha=1; - rgba.red=0.95; - rgba.green=0.95; - rgba.blue=0.95; - vte_terminal_set_color_background(VTE_TERMINAL(terminal),&rgba); - rgba.red=0; - rgba.green=0; - rgba.blue=0; - vte_terminal_set_color_foreground(VTE_TERMINAL(terminal),&rgba); - return terminal; + if (mode){ + GdkRGBA rgba; + rgba.alpha=1; + rgba.red=0.95; + rgba.green=0.95; + rgba.blue=0.95; + vte_terminal_set_color_cursor(VTE_TERMINAL(terminal),&rgba); + vte_terminal_set_color_background(VTE_TERMINAL(terminal),&rgba); + rgba.red=0; + rgba.green=0; + rgba.blue=0; + vte_terminal_set_color_foreground(VTE_TERMINAL(terminal),&rgba); + return terminal; + } else { + gtk_widget_destroy(terminal); + gtk_widget_show(unfound_label); + char *label_text = yon_char_append(page_name,PATH_NOT_FOUND_LABEL); + gtk_label_set_text(GTK_LABEL(unfound_label),label_text); + return NULL; + } + } void on_inspector_open(GtkWidget *self, main_window *widgets){ @@ -364,13 +375,19 @@ void on_inspector_open(GtkWidget *self, main_window *widgets){ if (strcmp(name,"journald")){ window->last_mode=-1; for (int i=0;ijournal_size;i++){ - if (!access(window->journal_paths[i],F_OK)||!window->terminals) - yon_dictionary_add_or_create_if_exists_with_data(window->terminals,window->journal_paths[i],yon_inspector_add_terminal(window,window->journal_paths[i])); + if (!access(window->journal_paths[i],F_OK)){ + yon_dictionary_add_or_create_if_exists_with_data(window->terminals,window->journal_paths[i],yon_inspector_add_terminal(window,window->journal_paths[i],1)); + } + else{ + GtkWidget *terminal = yon_inspector_add_terminal(window,window->journal_paths[i],0); + if (terminal) + yon_dictionary_add_or_create_if_exists_with_data(window->terminals,window->journal_paths[i],terminal); + } } gtk_widget_hide(window->JournalActionsBox); } else { window->last_mode=0; - yon_dictionary_add_or_create_if_exists_with_data(window->terminals,"Journald",yon_inspector_add_terminal(window,"Journald")); + yon_dictionary_add_or_create_if_exists_with_data(window->terminals,"Journald",yon_inspector_add_terminal(window,"Journald",1)); } on_inspector_update(window->UpdateButton,window); @@ -2365,6 +2382,9 @@ main_window *setup_window(){ } } } else { + if (access(custom_logs_saving_file_path,F_OK)){ + yon_file_create_full_path(custom_logs_saving_file_path,0777); + } FILE *fl = fopen(custom_logs_saving_file_path,"w"); fclose(fl); } @@ -2424,7 +2444,7 @@ int main(int argc, char *argv[], char **envp){ { NULL, 0, NULL, 0 } }; for (int i=0;i + + 100 + 1 + 10 + True False - + True - True - natural - natural - UTF-8 - 0 - True - False + False + vertical + + + True + True + natural + adjustment3 + natural + off + underline + UTF-8 + True + 0 + True + False + + + True + True + 0 + + + + + False + Label + 0.019999999552965164 + + + + + + + False + True + 1 + + True @@ -28,6 +65,7 @@ True False vertical + adjustment3 False @@ -36,9 +74,4 @@ - - 100 - 1 - 10 - diff --git a/ubl-settings-logging.pot b/ubl-settings-logging.pot index 21106d4..6f16734 100644 --- a/ubl-settings-logging.pot +++ b/ubl-settings-logging.pot @@ -755,6 +755,10 @@ msgstr "" msgid "Value:" msgstr "" +#: source/ubl-strings.h:202 +msgid ": no such file(s)" +msgstr "" + msgid "System event log rotation service" msgstr "" diff --git a/ubl-settings-logging_ru.po b/ubl-settings-logging_ru.po index 5a22a2e..b4a5675 100644 --- a/ubl-settings-logging_ru.po +++ b/ubl-settings-logging_ru.po @@ -769,6 +769,10 @@ msgstr "Исполнение" msgid "Value:" msgstr "Значение:" +#: source/ubl-strings.h:202 +msgid ": no such file(s)" +msgstr ": файл(ы) не найден(ы)" + msgid "System event log rotation service" msgstr "Служба ротации системных журналов событий" -- 2.35.1 From 499fc99e7aebeee4af3cc1799f5da4c8308c785c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 24 Nov 2023 11:53:19 +0600 Subject: [PATCH 24/39] Added new policy file. Now useless --- com.ublinux.ubl-settings-logging.auth.policy | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 com.ublinux.ubl-settings-logging.auth.policy diff --git a/com.ublinux.ubl-settings-logging.auth.policy b/com.ublinux.ubl-settings-logging.auth.policy new file mode 100644 index 0000000..846ebeb --- /dev/null +++ b/com.ublinux.ubl-settings-logging.auth.policy @@ -0,0 +1,23 @@ + + + + + UBLinux + https://ublinux.ru + + + Run ubl-settings-logging as root + Запуск утилиты ubl-settings-logging с правами root + Authentication is required to run ubl-settings-logging + Требуется авторизация для запуска утилиты ubl-settings-logging с правами root + + auth_admin + auth_admin + auth_admin_keep + + /usr/bin/pkexec + + + -- 2.35.1 From 366aae7da318acabc76b9a46c9c788cf8cc7a777 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 24 Nov 2023 14:30:42 +0600 Subject: [PATCH 25/39] Fixed bug, caused preventing of deleting any log path from monitoring logs --- source/ubl-settings-logging.c | 6 ++++-- source/ubl-utils.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index f2a6aa2..1bf2e31 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1949,14 +1949,16 @@ void on_log_edit(GtkWidget *self,main_window *widgets){ GtkWidget *RemoveButton = yon_gtk_builder_get_widget(builder,"RemoveButton"); if (protectedLogPathsBox),box,0,0,5); last = AppendButton; diff --git a/source/ubl-utils.c b/source/ubl-utils.c index cc174f4..ff83257 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1711,7 +1711,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end vte_terminal_set_size(VTE_TERMINAL(terminal),10,15); VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); - char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL); + char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command," ; sleep 5; stty -echo; unset PS1","\n",NULL); if(endwork_function) g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); vte_terminal_spawn_async(VTE_TERMINAL(terminal), -- 2.35.1 From 927c62dc6ec430802eb69a147581b5c1f34f9318 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 24 Nov 2023 14:43:50 +0600 Subject: [PATCH 26/39] Fixed dividing of monitoring logs --- source/ubl-settings-logging.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 1bf2e31..82d6cc1 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -146,6 +146,7 @@ void yon_logs_custom_save(main_window *widgets){ if (standard!=1){ for (int i=0;ilist,&iter); + cur_watcher[1] = yon_char_replace(cur_watcher[1],",","\n"); gtk_list_store_set(widgets->list,&iter,0,cur_watcher[0],1,cur_watcher[1],2,cur_watcher[2]?cur_watcher[2]:"",-1); yon_char_parsed_free(cur_watcher,cur_size); } -- 2.35.1 From 7566e5e05294f9f65c4e5c0d871d5de1fe825078 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 24 Nov 2023 15:01:41 +0600 Subject: [PATCH 27/39] Fixed return of deleted config parameters --- source/ubl-utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/ubl-utils.c b/source/ubl-utils.c index ff83257..2e7d9d4 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1234,7 +1234,7 @@ void *yon_config_get_by_key(char *key){ check_config{ dictionary *dict = NULL; for_dictionaries(dict, (dictionary*)__yon__config__strings){ - if (strcmp(dict->key,key)==0){ + if (strcmp(dict->key,key)==0&&((yon_config_parameter*)dict)->flag1!=-1){ return dict->data; } } @@ -1247,7 +1247,7 @@ void *yon_config_get_all_by_key(char *key, int *size){ config_str ret_data=NULL; dictionary *dict = NULL; for_dictionaries(dict, (dictionary*)__yon__config__strings){ - if (strstr(dict->key,key)) { + if (strstr(dict->key,key)&&((yon_config_parameter*)dict)->flag1!=-1) { char *ret_string = yon_char_unite(dict->key,"=",(char*)dict->data,NULL); if (ret_data) ret_data = yon_char_parsed_append(ret_data,size,ret_string); else ret_data = yon_char_parsed_new(size,ret_string,NULL); -- 2.35.1 From ac0b6d5a463e9f45ef65d5445d6d6b9956c9592f Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 24 Nov 2023 15:10:39 +0600 Subject: [PATCH 28/39] Fixed deleting of logs paths --- source/ubl-settings-logging.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 82d6cc1..f72b4f9 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1952,9 +1952,10 @@ void on_log_edit(GtkWidget *self,main_window *widgets){ gtk_widget_set_sensitive(RemoveButton,0); gtk_widget_set_sensitive(entry,0); gtk_widget_set_sensitive(SearchButton,0); + protected++; + } else { g_signal_connect(G_OBJECT(RemoveButton),"clicked",G_CALLBACK(on_log_path_remove),window); g_signal_connect(G_OBJECT(SearchButton),"clicked",G_CALLBACK(on_log_path_choose),window); - protected++; } if (!strcmp(name,"journald")) { gtk_widget_hide(AppendButton); -- 2.35.1 From 813a4bd83c32f239cf390a37078f56e89294b82c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 24 Nov 2023 15:35:14 +0600 Subject: [PATCH 29/39] Fixing of repeat paths checking --- source/ubl-settings-logging.c | 22 +++++++++++++++------- source/ubl-utils.c | 12 +++++++----- source/ubl-utils.h | 2 +- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index f72b4f9..8c89468 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -734,8 +734,10 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ } if (paths){ int psize=0; + int fo=0; + int so=0; config_str paths_parsed = yon_char_parse(paths,&psize,","); - if (yon_char_parsed_check_repeats(paths_parsed,psize)){ + if (yon_char_parsed_check_repeats(paths_parsed,psize,&fo,&so)){ yon_ubl_status_highlight_incorrect(gtk_widget_get_parent(window->LogPathsTree)); yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEAT_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); return; @@ -1745,6 +1747,18 @@ void on_log_save(GtkWidget *self, dictionary *dict){ if (strcmp(cur,"")) pathse=yon_char_unite(pathse ? yon_char_append(pathse,"\n"):"",cur,NULL); } + + int fo=0; + int so=0; + int paths_size; + config_str paths_parsed = yon_char_parse(pathse,&paths_size,"\n"); + if (yon_char_parsed_check_repeats(paths_parsed,paths_size,&fo,&so)){ + GList *list = gtk_container_get_children(GTK_CONTAINER(window->LogPathsBox)); + yon_ubl_status_highlight_incorrect((GtkWidget*)g_list_nth_data(list,so)); + yon_ubl_status_highlight_incorrect((GtkWidget*)g_list_nth_data(list,fo)); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEAT_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + return; + } GtkTreeIter iter; char *name = (char*)gtk_entry_get_text(GTK_ENTRY(window->NameEntry)); char *desc = (char*)gtk_entry_get_text(GTK_ENTRY(window->LogDescriptionEntry)); @@ -1765,14 +1779,8 @@ void on_log_save(GtkWidget *self, dictionary *dict){ } int paths_size=0; config_str paths_parsed = yon_char_parse(paths,&paths_size,"\n"); - if (yon_char_parsed_check_repeats(paths_parsed,paths_size)){ - yon_ubl_status_highlight_incorrect(window->LogPathsBox); - yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEAT_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); - return; - } int pathse_size=0; config_str pathse_parsed = yon_char_parse(pathse,&pathse_size,"\n"); - if (yon_char_parsed_includes_char_parsed(pathse_parsed,paths_parsed,pathse_size,paths_size)){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEATED_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); yon_ubl_status_highlight_incorrect(window->LogPathsBox); diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 2e7d9d4..4f3fa2e 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -776,11 +776,13 @@ int yon_char_parsed_check_exist(char **parameters, int size, char *param){ * Проверяет есть ли в массиве строк [parameters], размера [size] * повторения */ -int yon_char_parsed_check_repeats(char **parameters, int size){ - for (int i=0;i Date: Fri, 24 Nov 2023 15:37:21 +0600 Subject: [PATCH 30/39] Fixed inspector window updating --- source/ubl-utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 4f3fa2e..d6cb305 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1659,7 +1659,7 @@ void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, voi VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); gtk_container_add(GTK_CONTAINER(place_to_show),terminal); - char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL); + char *install_command=yon_char_unite("clear;tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL); printf("%s\n",install_command); if(endwork_function) g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); @@ -1713,7 +1713,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end vte_terminal_set_size(VTE_TERMINAL(terminal),10,15); VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); - char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command," ; sleep 5; stty -echo; unset PS1","\n",NULL); + char *install_command=yon_char_unite("clear;tput cup 0 0 && tput ed; ",command," ; sleep 5; stty -echo; unset PS1","\n",NULL); if(endwork_function) g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); vte_terminal_spawn_async(VTE_TERMINAL(terminal), -- 2.35.1 From 224c2278130c024d478ac028d0aedd7ed265ba48 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 24 Nov 2023 16:45:46 +0600 Subject: [PATCH 31/39] Fixed crash --- source/ubl-utils.c | 70 ++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 46 deletions(-) diff --git a/source/ubl-utils.c b/source/ubl-utils.c index d6cb305..5403a4a 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -673,33 +673,6 @@ char *yon_char_replace(char *source, char *find, char*replace){ return source; } -/**yon_char_parse(char *parameters, int *size, char *divider) - * [EN] - * Parses string [parameters], divided by [divider], - * then returns parsed string array and sets [size] to - * size of returned array -*/ -// char **yon_char_parse(char *parameters, int *size, char *divider){ -// char **string=NULL; -// int i=1; -// string=malloc(sizeof(char*)); -// char *paramline=yon_char_new(parameters); -// char *param; -// while ((param=yon_char_divide_search(paramline,divider,1))){ -// string=realloc(string,sizeof(char*)*i); -// string[i-1]=yon_char_new(param); -// i++; -// if (strcmp(param,paramline)==0) break; -// } -// // string=realloc(string,sizeof(char*)*i); -// // string[i-1]=yon_char_new(paramline); -// // i++; -// // printf("%d\n",i); -// *size=i-1; -// return string; - -// } - /**yon_char_parse(char *parameters, int *size, char *divider) * [EN] * Parses string [parameters], divided by [divider], @@ -707,19 +680,22 @@ char *yon_char_replace(char *source, char *find, char*replace){ * size of returned array */ char **yon_char_parse(char *parameters, int *size, char *divider){ - char **string=NULL; - *size=0; - char *paramline=yon_char_new(parameters); - char *param = strstr(paramline,divider); - for (;param;param=strstr(paramline,divider)){ - string = yon_remalloc(string,sizeof(char*)*((*size)+1)); - string[(*size)]=yon_char_divide(paramline,strlen(paramline)-strlen(param)); - *size=(*size)+1; + if (parameters){ + char **string=NULL; + *size=0; + char *paramline=yon_char_new(parameters); + char *param = strstr(paramline,divider); + for (;param;param=strstr(paramline,divider)){ + string = yon_remalloc(string,sizeof(char*)*((*size)+1)); + string[(*size)]=yon_char_divide(paramline,strlen(paramline)-strlen(param)); + *size=(*size)+1; + } + string = yon_remalloc(string,sizeof(char*)*((*size)+1)); + string[(*size)]=paramline; + (*size)+=1; + return string; } - string = yon_remalloc(string,sizeof(char*)*((*size)+1)); - string[(*size)]=paramline; - (*size)+=1; - return string; + return NULL; } /**yon_char_parsed_rip(char **char_string, int *size, int item_to_delete) @@ -777,13 +753,15 @@ int yon_char_parsed_check_exist(char **parameters, int size, char *param){ * повторения */ int yon_char_parsed_check_repeats(char **parameters, int size, int *first_overlap, int *second_overlap){ - *first_overlap=0; - *second_overlap=0; - for ((*first_overlap)=0;(*first_overlap) Date: Fri, 24 Nov 2023 17:08:03 +0600 Subject: [PATCH 32/39] Log monitoring creation window now doesn't close if saving without any data --- source/ubl-settings-logging.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 8c89468..821dff2 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1783,7 +1783,6 @@ void on_log_save(GtkWidget *self, dictionary *dict){ config_str pathse_parsed = yon_char_parse(pathse,&pathse_size,"\n"); if (yon_char_parsed_includes_char_parsed(pathse_parsed,paths_parsed,pathse_size,paths_size)){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEATED_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); - yon_ubl_status_highlight_incorrect(window->LogPathsBox); return; } } @@ -1797,6 +1796,10 @@ void on_log_save(GtkWidget *self, dictionary *dict){ gtk_list_store_set(widgets->list,&iter,3,stat==0?0:stat==1?2:2,-1); } gtk_list_store_set(widgets->list,&iter,0,name,1,pathse,2,&desc ? desc : "",-1); + } else { + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->NameEntry); + return; } yon_logs_custom_save(widgets); on_close_subwindow(self,NULL); -- 2.35.1 From cc51f66b503323d24a48bb040ab5972f7e8fee6d Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 27 Nov 2023 09:16:27 +0600 Subject: [PATCH 33/39] New label and its localisation --- source/ubl-settings-logging.c | 6 +++-- source/ubl-strings.h | 1 + ubl-settings-logging-logrotate.glade | 6 +++++ ubl-settings-logging.pot | 32 +++++++++++++++------------ ubl-settings-logging_ru.po | 33 ++++++++++++++++------------ 5 files changed, 48 insertions(+), 30 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 821dff2..efbd7a2 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -716,6 +716,7 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); return; } + GtkTreeIter *lastiter; for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&iter)){ char *cur_path; gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,0,&cur_path,-1); @@ -724,10 +725,11 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ } path_amount++; paths = yon_char_unite(paths,strcmp(paths,"") ? "," : "", cur_path,NULL); + lastiter=gtk_tree_iter_copy(&iter); } if(!window->paths) { if (matched==path_amount) { - yon_ubl_status_highlight_incorrect(gtk_widget_get_parent(window->LogPathsTree)); + yon_ubl_status_list_store_highlight_incorrect(window->list,lastiter); yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEATED_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); return; } @@ -1797,7 +1799,7 @@ void on_log_save(GtkWidget *self, dictionary *dict){ } gtk_list_store_set(widgets->list,&iter,0,name,1,pathse,2,&desc ? desc : "",-1); } else { - yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),WRITE_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); yon_ubl_status_highlight_incorrect(window->NameEntry); return; } diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 51f82b8..95126f1 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -178,6 +178,7 @@ #define REPEATED_PATHS_LABEL _("Same record already exists") #define EMPTY_IMPORTANT_LABEL _("Empty important field") #define REPEAT_PATHS_LABEL _("Repeating paths") +#define WRITE_IMPORTANT_LABEL _("Write down all important fields") //ubl-settings-logging-logrotate-table.glade #define SYSTEM_CONFIGURATION_LABEL _("System configuration") diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index 23fbfb5..c292f61 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -92,6 +92,10 @@ + + + + @@ -327,6 +331,8 @@ + 2 + 1 0 diff --git a/ubl-settings-logging.pot b/ubl-settings-logging.pot index 6f16734..689c007 100644 --- a/ubl-settings-logging.pot +++ b/ubl-settings-logging.pot @@ -703,59 +703,63 @@ msgstr "" msgid "Repeating paths" msgstr "" -#: source/ubl-strings.h:183 -msgid "System configuration" +#: source/ubl-strings.h:181 +msgid "Write down all important fields" msgstr "" #: source/ubl-strings.h:184 +msgid "System configuration" +msgstr "" + +#: source/ubl-strings.h:185 msgid "Applications configuration" msgstr "" -#: source/ubl-strings.h:187 +#: source/ubl-strings.h:188 msgid "Path (-s):" msgstr "" -#: source/ubl-strings.h:188 +#: source/ubl-strings.h:189 msgid "Control:" msgstr "" -#: source/ubl-strings.h:189 +#: source/ubl-strings.h:190 msgid "Log file" msgstr "" -#: source/ubl-strings.h:190 +#: source/ubl-strings.h:191 msgid "Name:" msgstr "" -#: source/ubl-strings.h:193 +#: source/ubl-strings.h:194 msgid "Owner rules" msgstr "" -#: source/ubl-strings.h:194 +#: source/ubl-strings.h:195 msgid "Group rules" msgstr "" -#: source/ubl-strings.h:195 +#: source/ubl-strings.h:196 msgid "Public rules" msgstr "" -#: source/ubl-strings.h:196 +#: source/ubl-strings.h:197 msgid "Read" msgstr "" -#: source/ubl-strings.h:197 +#: source/ubl-strings.h:198 msgid "Write" msgstr "" -#: source/ubl-strings.h:198 +#: source/ubl-strings.h:199 msgid "Execute" msgstr "" -#: source/ubl-strings.h:199 +#: source/ubl-strings.h:200 msgid "Value:" msgstr "" -#: source/ubl-strings.h:202 +#: source/ubl-strings.h:203 msgid ": no such file(s)" msgstr "" diff --git a/ubl-settings-logging_ru.po b/ubl-settings-logging_ru.po index b4a5675..908cb52 100644 --- a/ubl-settings-logging_ru.po +++ b/ubl-settings-logging_ru.po @@ -717,59 +717,64 @@ msgstr "Важное поле не заполнено" msgid "Repeating paths" msgstr "Повторяющиеся пути" -#: source/ubl-strings.h:183 +#: source/ubl-strings.h:181 +#, fuzzy +msgid "Write down all important fields" +msgstr "Введите все необходимые поля" + +#: source/ubl-strings.h:184 msgid "System configuration" msgstr "Настройки системы" -#: source/ubl-strings.h:184 +#: source/ubl-strings.h:185 msgid "Applications configuration" msgstr "Настройки приложений" -#: source/ubl-strings.h:187 +#: source/ubl-strings.h:188 msgid "Path (-s):" msgstr "Путь (-и):" -#: source/ubl-strings.h:188 +#: source/ubl-strings.h:189 msgid "Control:" msgstr "Управление:" -#: source/ubl-strings.h:189 +#: source/ubl-strings.h:190 msgid "Log file" msgstr "Файл лога" -#: source/ubl-strings.h:190 +#: source/ubl-strings.h:191 msgid "Name:" msgstr "Имя:" -#: source/ubl-strings.h:193 +#: source/ubl-strings.h:194 msgid "Owner rules" msgstr "Правила владельца" -#: source/ubl-strings.h:194 +#: source/ubl-strings.h:195 msgid "Group rules" msgstr "Правила группы" -#: source/ubl-strings.h:195 +#: source/ubl-strings.h:196 msgid "Public rules" msgstr "Правила остальных" -#: source/ubl-strings.h:196 +#: source/ubl-strings.h:197 msgid "Read" msgstr "Чтение" -#: source/ubl-strings.h:197 +#: source/ubl-strings.h:198 msgid "Write" msgstr "Запись" -#: source/ubl-strings.h:198 +#: source/ubl-strings.h:199 msgid "Execute" msgstr "Исполнение" -#: source/ubl-strings.h:199 +#: source/ubl-strings.h:200 msgid "Value:" msgstr "Значение:" -#: source/ubl-strings.h:202 +#: source/ubl-strings.h:203 msgid ": no such file(s)" msgstr ": файл(ы) не найден(ы)" -- 2.35.1 From 1f616f716c1a9aadeae7cce6dc208f8aebd8d5f4 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 27 Nov 2023 10:01:04 +0600 Subject: [PATCH 34/39] Added repeating paths highlight --- source/ubl-settings-logging.c | 9 +++++++-- source/ubl-utils.c | 25 +++++++++++++++++++++++++ source/ubl-utils.h | 2 ++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index efbd7a2..9c089cc 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -717,6 +717,7 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ return; } GtkTreeIter *lastiter; + GtkTreeIter *lastitar; for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&iter)){ char *cur_path; gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,0,&cur_path,-1); @@ -726,10 +727,11 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ path_amount++; paths = yon_char_unite(paths,strcmp(paths,"") ? "," : "", cur_path,NULL); lastiter=gtk_tree_iter_copy(&iter); + lastitar=gtk_tree_iter_copy(&iter); } if(!window->paths) { if (matched==path_amount) { - yon_ubl_status_list_store_highlight_incorrect(window->list,lastiter); + yon_ubl_status_highlight_incorrect(gtk_widget_get_parent(window->LogPathsTree)); yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEATED_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); return; } @@ -740,7 +742,10 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ int so=0; config_str paths_parsed = yon_char_parse(paths,&psize,","); if (yon_char_parsed_check_repeats(paths_parsed,psize,&fo,&so)){ - yon_ubl_status_highlight_incorrect(gtk_widget_get_parent(window->LogPathsTree)); + gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(window->list),lastiter,yon_char_from_int(fo)); + gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(window->list),lastitar,yon_char_from_int(so)); + yon_ubl_status_list_store_highlight_incorrect(window->list,lastiter); + yon_ubl_status_list_store_highlight_incorrect(window->list,lastitar); yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEAT_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); return; } diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 5403a4a..1cf3fd4 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -2265,6 +2265,31 @@ void yon_ubl_status_highlight_incorrect(GtkWidget *widget){ GThread *thread = g_thread_new(NULL,(GThreadFunc)_yon_ubl_status_highlight_incorrect,widget); } +void _yon_ubl_status_list_store_highlight_incorrect(GtkWidget **widget_pack){ + GtkListStore *list = (GtkListStore*)widget_pack[0]; + GtkTreeIter *iter = (GtkTreeIter*)widget_pack[1]; + GdkRGBA rgba,rgba2; + rgba.alpha=1; + rgba.blue=153.0/255.0; + rgba.green=153.0/255.0; + rgba.red=234.0/255.0; + rgba2.alpha=1; + rgba2.blue=0; + rgba2.green=0; + rgba2.red=0; + printf("%s\n",gdk_rgba_to_string(&rgba)); + gtk_list_store_set(list,iter,1,gdk_rgba_to_string(&rgba2),2,gdk_rgba_to_string(&rgba),-1); + sleep(5); + gtk_list_store_set(list,iter,1,NULL,2,NULL,-1); +} + +void yon_ubl_status_list_store_highlight_incorrect(GtkListStore *list, GtkTreeIter *iter){ + GtkWidget **pack = malloc(sizeof(GtkWidget *)*2); + pack[0]=(GtkWidget*)list; + pack[1]=(GtkWidget*)iter; + GThread *thread = g_thread_new(NULL,(GThreadFunc)_yon_ubl_status_list_store_highlight_incorrect,pack); +} + struct temp_statusbox { int times; GtkWidget *revealer; diff --git a/source/ubl-utils.h b/source/ubl-utils.h index 3ef031f..2fef789 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -367,6 +367,8 @@ void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type); void yon_ubl_status_highlight_incorrect(GtkWidget *widget); +void yon_ubl_status_list_store_highlight_incorrect(GtkListStore *list, GtkTreeIter *iter); + static int status_thread_busy; void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type); -- 2.35.1 From f64a4b27a0bad8f0fa7447f6412963b165071a8b Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 27 Nov 2023 10:41:33 +0600 Subject: [PATCH 35/39] Fixed crash --- source/ubl-settings-logging.c | 58 ++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 9c089cc..dd48ac5 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -143,12 +143,15 @@ void yon_logs_custom_save(main_window *widgets){ char *final_strings=NULL; for (;valid;valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->list),&iter)){ gtk_tree_model_get(GTK_TREE_MODEL(widgets->list),&iter,0,&name,1,&paths,2,&description,3,&standard,4,&standard_paths,-1); - if (standard!=1){ - for (int i=0;ilast_mode){ + case 0: + fl = popen(get_journal_output_command,"r"); + break; + case 1: + fl = popen(get_journal_output_since_boot_command,"r"); + break; + case 2: + fl = popen(get_journal_output_followed_command,"r"); + break; + case 3: + fl = popen(get_journal_output_kernel_command,"r"); + break; + case 4: + fl = popen(get_journal_output_prioritied_command,"r"); + break; + case 5: + fl = popen(get_journal_all_boots_command,"r"); + break; + case 6: + fl = popen(get_journal_all_units_command,"r"); + break; + case 7: + fl = popen(get_journal_init_tree_command,"r"); + break; + } + char output[4092]; + GtkTreeIter iter; + // while (1){ + // if(fgets(output,4092,fl)){ + // gtk_list_store_append(window->list, &iter); + + // gtk_list_store_set(window->list,&iter,0,&); + // } + // } +} + void on_inspector_update(GtkWidget *self, inspector_window *window){ int size; GtkTextIter titer,titerend; @@ -1758,6 +1801,11 @@ void on_log_save(GtkWidget *self, dictionary *dict){ int fo=0; int so=0; int paths_size; + if (!pathse){ + yon_ubl_status_highlight_incorrect(window->LogPathsBox); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + return; + } config_str paths_parsed = yon_char_parse(pathse,&paths_size,"\n"); if (yon_char_parsed_check_repeats(paths_parsed,paths_size,&fo,&so)){ GList *list = gtk_container_get_children(GTK_CONTAINER(window->LogPathsBox)); -- 2.35.1 From 181c266213d6de9067f30718c4925798d4934a75 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 27 Nov 2023 10:42:37 +0600 Subject: [PATCH 36/39] Removed prints, start of journald inspector window rework --- source/ubl-utils.c | 2 -- ubl-settings-logging-inspector.glade | 39 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 1cf3fd4..66ed085 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1638,7 +1638,6 @@ void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, voi vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); gtk_container_add(GTK_CONTAINER(place_to_show),terminal); char *install_command=yon_char_unite("clear;tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL); - printf("%s\n",install_command); if(endwork_function) g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); vte_terminal_spawn_async(VTE_TERMINAL(terminal), @@ -2277,7 +2276,6 @@ void _yon_ubl_status_list_store_highlight_incorrect(GtkWidget **widget_pack){ rgba2.blue=0; rgba2.green=0; rgba2.red=0; - printf("%s\n",gdk_rgba_to_string(&rgba)); gtk_list_store_set(list,iter,1,gdk_rgba_to_string(&rgba2),2,gdk_rgba_to_string(&rgba),-1); sleep(5); gtk_list_store_set(list,iter,1,NULL,2,NULL,-1); diff --git a/ubl-settings-logging-inspector.glade b/ubl-settings-logging-inspector.glade index bc16007..16c043c 100644 --- a/ubl-settings-logging-inspector.glade +++ b/ubl-settings-logging-inspector.glade @@ -53,6 +53,7 @@ False com.ublinux.ubl-settings-logging.generic7-symbolic + 800 600 @@ -247,6 +248,44 @@ 1 + + + True + True + liststore1 + False + + + + + + column + + + + 0 + + + + + + + column + + + + 1 + + + + + + + True + True + 2 + + True -- 2.35.1 From c3b63593e72b830df69d2a9ae25bcc0c72d16dc6 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 27 Nov 2023 12:20:51 +0600 Subject: [PATCH 37/39] Repeat paths highlighting redone --- source/ubl-settings-logging.c | 38 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index dd48ac5..efffe58 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -456,15 +456,31 @@ void on_logrotate_configuration_path_add(GtkWidget *self, logrotate_configure_wi } void on_path_editing_done(GtkCellRendererText* self,gchar* path,gchar* new_text,logrotate_configure_window *window){ - GtkTreeIter iter; + GtkTreeIter iter, itar; char *cur_path; gtk_tree_model_get_iter(GTK_TREE_MODEL(window->list),&iter,gtk_tree_path_new_from_string(path)); gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,0,&cur_path,-1); - if (cur_path&&!strcmp(cur_path,"")&&!strcmp(new_text,"")) + if (!strcmp(new_text,"")||cur_path&&!strcmp(cur_path,"")) gtk_list_store_remove(window->list,&iter); - else if (new_text&&strcmp(new_text,"")) - gtk_list_store_set(window->list,&iter,0,new_text,-1); + else if (new_text&&strcmp(new_text,"")){ + int deleted=0; + int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&itar); + for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&itar)){ + char *path; + gtk_tree_model_get(GTK_TREE_MODEL(window->list),&itar,0,&path,-1); + if (path&&new_text) + if (!strcmp(path,new_text)){ + yon_ubl_status_list_store_highlight_incorrect(window->list,gtk_tree_iter_copy(&itar)); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEAT_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + gtk_list_store_remove(window->list,&iter); + deleted=1; + } + } + if (!deleted) + gtk_list_store_set(window->list,&iter,0,new_text,-1); + + } GValue *val = g_malloc0(sizeof(GValue)); g_object_get_property(G_OBJECT(self),"editable",val); g_value_set_boolean(val,0); @@ -779,20 +795,6 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ return; } } - if (paths){ - int psize=0; - int fo=0; - int so=0; - config_str paths_parsed = yon_char_parse(paths,&psize,","); - if (yon_char_parsed_check_repeats(paths_parsed,psize,&fo,&so)){ - gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(window->list),lastiter,yon_char_from_int(fo)); - gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(window->list),lastitar,yon_char_from_int(so)); - yon_ubl_status_list_store_highlight_incorrect(window->list,lastiter); - yon_ubl_status_list_store_highlight_incorrect(window->list,lastitar); - yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEAT_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); - return; - } - } if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->RotationPeriodCheck))){ int active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo)); switch (active){ -- 2.35.1 From 667c7b5c1839d35c4a1b0972282573700cb2b20d Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 27 Nov 2023 17:57:09 +0600 Subject: [PATCH 38/39] First version of table journald overview is done --- source/ubl-settings-logging.c | 89 +++++++++++++++------------- source/ubl-settings-logging.h | 53 +++++++++-------- ubl-settings-logging-inspector.glade | 68 ++++++++++++++------- 3 files changed, 122 insertions(+), 88 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index efffe58..5968842 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -267,13 +267,34 @@ void on_inspector_jornald_read_async(inspector_window *window){ } char output[4092]; GtkTreeIter iter; - // while (1){ - // if(fgets(output,4092,fl)){ - // gtk_list_store_append(window->list, &iter); + main_config.remove_thread=0; + while (main_config.remove_thread==0){ + if(fgets(output,4092,fl)){ + if(strcmp(output,"")){ + gtk_list_store_append(window->list, &iter); + + char *identifier=""; + char *temp = yon_char_new(output); + char *log=temp; + if (strstr(log,"\033[H\033[2J\033[3")) + yon_char_divide(log,strlen("\033[H\033[2J\033[3")); + log = yon_char_divide_search(log,"\n",-1); + if (window->last_mode<5){ + identifier = log; + log=strstr(log,":")+1; + log=strstr(log,":")+1; + log=strstr(log,":")+1; + char *iden = yon_char_new(identifier); + identifier=yon_char_divide(iden,strlen(identifier)-strlen(log)-1); + free(iden); + } - // gtk_list_store_set(window->list,&iter,0,&); - // } - // } + gtk_list_store_set(window->list,&iter,0,identifier,1,log,-1); + free(temp); + } + } + // g_usleep(100); + } } void on_inspector_update(GtkWidget *self, inspector_window *window){ @@ -282,64 +303,42 @@ void on_inspector_update(GtkWidget *self, inspector_window *window){ config_str output; if (!strcmp(window->journal_name,"journald")){ GtkWidget *terminal = (GtkWidget*)window->terminals->first->data; - if (self==window->UpdateButton){ - switch(window->last_mode){ - case 0: - yon_terminal_integrated_start(terminal, get_journal_output_command,NULL,NULL); - break; - case 1: - yon_terminal_integrated_start(terminal, get_journal_output_since_boot_command,NULL,NULL); - break; - case 2: - yon_terminal_integrated_start(terminal, get_journal_output_followed_command,NULL,NULL); - break; - case 3: - yon_terminal_integrated_start(terminal, get_journal_output_kernel_command,NULL,NULL); - break; - case 4: - yon_terminal_integrated_start(terminal, get_journal_output_prioritied_command,NULL,NULL); - break; - case 5: - yon_terminal_integrated_start(terminal, get_journal_all_boots_command,NULL,NULL); - break; - case 6: - yon_terminal_integrated_start(terminal, get_journal_all_units_command,NULL,NULL); - break; - case 7: - yon_terminal_integrated_start(terminal, get_journal_init_tree_command,NULL,NULL); - break; - } - } + gtk_widget_hide(window->LoggingNotebook); + gtk_widget_show(gtk_widget_get_parent(window->JournaldTree)); if (self==window->ShowSinceBootButton){ window->last_mode=1; - yon_terminal_integrated_start(terminal, get_journal_output_since_boot_command,NULL,NULL); } if (self==window->NewMessagesButton){ window->last_mode=2; - yon_terminal_integrated_start(terminal, get_journal_output_followed_command,NULL,NULL); } if (self==window->ShowKernelButton){ window->last_mode=3; - yon_terminal_integrated_start(terminal, get_journal_output_kernel_command,NULL,NULL); } if (self==window->ShowPriorityButton){ window->last_mode=4; - yon_terminal_integrated_start(terminal, get_journal_output_prioritied_command,NULL,NULL); } if (self==window->ShowAllBootsButton){ window->last_mode=5; - yon_terminal_integrated_start(terminal, get_journal_all_boots_command,NULL,NULL); } if (self==window->ShowAllUnitsButton){ window->last_mode=6; - yon_terminal_integrated_start(terminal, get_journal_all_units_command,NULL,NULL); } if (self==window->ShowInitTreeButton){ window->last_mode=7; - yon_terminal_integrated_start(terminal, get_journal_init_tree_command,NULL,NULL); } + main_config.remove_thread++; + gtk_tree_view_set_model(GTK_TREE_VIEW(window->JournaldTree),GTK_TREE_MODEL(window->list)); + gtk_list_store_clear(window->list); + gtk_tree_view_set_model(GTK_TREE_VIEW(window->JournaldTree),GTK_TREE_MODEL(window->list)); + if (main_config.inspector_thread){ + main_config.remove_thread=1; + pthread_join(main_config.inspector_thread,NULL); + } + pthread_create(&main_config.inspector_thread, NULL, (void *)on_inspector_jornald_read_async, window); } else { if (window->terminals){ + gtk_widget_hide(gtk_widget_get_parent(window->JournaldTree)); + gtk_widget_show(window->LoggingNotebook); dictionary *dict=NULL; for_dictionaries (dict,window->terminals){ GtkWidget *terminal = (GtkWidget*)dict->data; @@ -381,6 +380,10 @@ GtkWidget *yon_inspector_add_terminal(inspector_window *window,char *page_name,i } +void on_inspector_close(GtkWidget *self){ + main_config.remove_thread++; +} + void on_inspector_open(GtkWidget *self, main_window *widgets){ inspector_window *window = malloc(sizeof(inspector_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_inspector_path); @@ -395,6 +398,8 @@ void on_inspector_open(GtkWidget *self, main_window *widgets){ window->LoggingNotebook=yon_gtk_builder_get_widget(builder,"MainNotebook"); window->UpdateButton=yon_gtk_builder_get_widget(builder,"UpdateButton"); window->JournalActionsBox=yon_gtk_builder_get_widget(builder,"JournalActionsBox"); + window->JournaldTree=yon_gtk_builder_get_widget(builder,"JournaldTree"); + window->list=GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1")); yon_window_config_custom_window_setup(GTK_WINDOW(window->MainWindow),"InspectorWindow"); gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); gtk_window_set_transient_for(GTK_WINDOW(window->MainWindow),GTK_WINDOW(widgets->Window)); @@ -402,6 +407,7 @@ void on_inspector_open(GtkWidget *self, main_window *widgets){ GtkTreeIter iter; char *name; char *paths; + g_signal_connect(G_OBJECT(window->MainWindow),"destroy", G_CALLBACK(on_inspector_close),window); g_signal_connect(G_OBJECT(window->UpdateButton),"clicked", G_CALLBACK(on_inspector_update),window); g_signal_connect(G_OBJECT(window->ShowKernelButton),"clicked", G_CALLBACK(on_inspector_update),window); g_signal_connect(G_OBJECT(window->NewMessagesButton),"clicked", G_CALLBACK(on_inspector_update),window); @@ -2262,6 +2268,7 @@ void config_init(){ main_config.lock_save_local=0; main_config.logrotate_list = gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING); main_config.logrotate_apps_list = gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING); + main_config.remove_thread=-1; PolkitSubject *subject = NULL; diff --git a/source/ubl-settings-logging.h b/source/ubl-settings-logging.h index a27d996..a84d28a 100644 --- a/source/ubl-settings-logging.h +++ b/source/ubl-settings-logging.h @@ -49,14 +49,14 @@ #define JOURNALD(key) yon_char_unite("JOURNALD[",key,"]",NULL) #define LOGROTATE(key) yon_char_unite("LOGROTATE[",key,"]",NULL) -#define get_journal_output_command "clear;journalctl --no-pager" -#define get_journal_output_since_boot_command "clear;journalctl --no-pager -b" -#define get_journal_output_followed_command "clear;journalctl --no-pager -f" -#define get_journal_output_kernel_command "clear;journalctl --no-pager -k" -#define get_journal_output_prioritied_command "clear;journalctl --no-pager -p err..alert" -#define get_journal_all_boots_command "clear;journalctl --list-boots" -#define get_journal_all_units_command "clear;systemd-analyze blame --no-pager" -#define get_journal_init_tree_command "clear;systemd-analyze critical-chain" +#define get_journal_output_command "clear;SYSTEMD_COLORS=false journalctl --no-pager" +#define get_journal_output_since_boot_command "clear;SYSTEMD_COLORS=false journalctl --no-pager -b" +#define get_journal_output_followed_command "clear;SYSTEMD_COLORS=false journalctl --no-pager -f" +#define get_journal_output_kernel_command "clear;SYSTEMD_COLORS=false journalctl --no-pager -k" +#define get_journal_output_prioritied_command "clear;SYSTEMD_COLORS=false journalctl --no-pager -p err..alert" +#define get_journal_all_boots_command "clear;SYSTEMD_COLORS=false journalctl --no-pager --list-boots" +#define get_journal_all_units_command "clear;SYSTEMD_COLORS=false systemd-analyze blame --no-pager" +#define get_journal_init_tree_command "clear;SYSTEMD_COLORS=false systemd-analyze critical-chain --no-pager" #define group_list_path "/etc/group" @@ -99,6 +99,9 @@ typedef struct { config_str *saved_logs; GPermission *permissions; + + pthread_t inspector_thread; + int remove_thread; } config; typedef struct { @@ -188,22 +191,24 @@ typedef struct { } add_log_window; typedef struct { -GtkWidget *MainWindow; -GtkWidget *plugBox; -GtkWidget *ShowSinceBootButton; -GtkWidget *NewMessagesButton; -GtkWidget *ShowKernelButton; -GtkWidget *ShowPriorityButton; -GtkWidget *UpdateButton; -GtkWidget *ShowAllBootsButton; -GtkWidget *ShowAllUnitsButton; -GtkWidget *ShowInitTreeButton; -GtkWidget *LoggingNotebook; -GtkWidget *JournalActionsBox; -dictionary *terminals; -int last_mode; -char *journal_name; -int journal_size; + GtkWidget *MainWindow; + GtkWidget *plugBox; + GtkWidget *ShowSinceBootButton; + GtkWidget *NewMessagesButton; + GtkWidget *ShowKernelButton; + GtkWidget *ShowPriorityButton; + GtkWidget *UpdateButton; + GtkWidget *ShowAllBootsButton; + GtkWidget *ShowAllUnitsButton; + GtkWidget *ShowInitTreeButton; + GtkWidget *LoggingNotebook; + GtkWidget *JournalActionsBox; + GtkListStore *list; + GtkWidget *JournaldTree; + dictionary *terminals; + int last_mode; + char *journal_name; + int journal_size; config_str journal_paths; } inspector_window; diff --git a/ubl-settings-logging-inspector.glade b/ubl-settings-logging-inspector.glade index 16c043c..930eb37 100644 --- a/ubl-settings-logging-inspector.glade +++ b/ubl-settings-logging-inspector.glade @@ -53,11 +53,19 @@ False com.ublinux.ubl-settings-logging.generic7-symbolic - + + + + + + + + 800 600 False + True 800 600 com.ublinux.ubl-settings-logging @@ -249,33 +257,47 @@ - - True + True - liststore1 - False - - - + in - - column + + True + True + liststore1 + False + both + 0 - - - 0 - + + fixed + 175 + 75 + column + + + end + + + 0 + + + - - - - - column - - - 1 - + + column + True + + + word + 500 + + + 1 + + + -- 2.35.1 From 8b14a1bc6c9fcfbf48a1bfa3656b9a26aab49da7 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 28 Nov 2023 12:46:20 +0600 Subject: [PATCH 39/39] Fixed freeze at inspector window --- source/ubl-settings-logging.c | 95 ++++++++++++++++------------------- source/ubl-settings-logging.h | 1 + 2 files changed, 43 insertions(+), 53 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 5968842..8dc83f3 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -265,36 +265,46 @@ void on_inspector_jornald_read_async(inspector_window *window){ fl = popen(get_journal_init_tree_command,"r"); break; } - char output[4092]; + char *output = g_malloc0(sizeof(char)*4096); GtkTreeIter iter; main_config.remove_thread=0; + fd_set fds; + struct timeval tv; + int fd = fileno(fl); while (main_config.remove_thread==0){ - if(fgets(output,4092,fl)){ - if(strcmp(output,"")){ - gtk_list_store_append(window->list, &iter); - - char *identifier=""; - char *temp = yon_char_new(output); - char *log=temp; - if (strstr(log,"\033[H\033[2J\033[3")) - yon_char_divide(log,strlen("\033[H\033[2J\033[3")); - log = yon_char_divide_search(log,"\n",-1); - if (window->last_mode<5){ - identifier = log; - log=strstr(log,":")+1; - log=strstr(log,":")+1; - log=strstr(log,":")+1; - char *iden = yon_char_new(identifier); - identifier=yon_char_divide(iden,strlen(identifier)-strlen(log)-1); - free(iden); + FD_ZERO(&fds); + FD_SET(fd, &fds); + tv.tv_sec = 1; + tv.tv_usec = 0; + if(select(fd + 1, &fds, NULL, NULL, &tv)){ + output = fgets(output,4092,fl); + if((output)){ + if(strcmp(output,"")){ + gtk_list_store_append(window->list, &iter); + + char *identifier=""; + char *temp = yon_char_new(output); + char *log=temp; + if (strstr(log,"\033[H\033[2J\033[3")) + yon_char_divide(log,strlen("\033[H\033[2J\033[3")); + log = yon_char_divide_search(log,"\n",-1); + if (window->last_mode<5){ + identifier = log; + log=strstr(log,":")+1; + log=strstr(log,":")+1; + log=strstr(log,":")+1; + char *iden = yon_char_new(identifier); + identifier=yon_char_divide(iden,strlen(identifier)-strlen(log)-1); + free(iden); + } + gtk_list_store_set(window->list,&iter,0,identifier,1,log,-1); + free(temp); } - - gtk_list_store_set(window->list,&iter,0,identifier,1,log,-1); - free(temp); } } - // g_usleep(100); } + main_config.inspector_thread=0; + pclose(fl); } void on_inspector_update(GtkWidget *self, inspector_window *window){ @@ -308,25 +318,25 @@ void on_inspector_update(GtkWidget *self, inspector_window *window){ if (self==window->ShowSinceBootButton){ window->last_mode=1; } - if (self==window->NewMessagesButton){ + else if (self==window->NewMessagesButton){ window->last_mode=2; } - if (self==window->ShowKernelButton){ + else if (self==window->ShowKernelButton){ window->last_mode=3; } - if (self==window->ShowPriorityButton){ + else if (self==window->ShowPriorityButton){ window->last_mode=4; } - if (self==window->ShowAllBootsButton){ + else if (self==window->ShowAllBootsButton){ window->last_mode=5; } - if (self==window->ShowAllUnitsButton){ + else if (self==window->ShowAllUnitsButton){ window->last_mode=6; } - if (self==window->ShowInitTreeButton){ + else if (self==window->ShowInitTreeButton){ window->last_mode=7; } - main_config.remove_thread++; + main_config.remove_thread=0; gtk_tree_view_set_model(GTK_TREE_VIEW(window->JournaldTree),GTK_TREE_MODEL(window->list)); gtk_list_store_clear(window->list); gtk_tree_view_set_model(GTK_TREE_VIEW(window->JournaldTree),GTK_TREE_MODEL(window->list)); @@ -342,7 +352,6 @@ void on_inspector_update(GtkWidget *self, inspector_window *window){ dictionary *dict=NULL; for_dictionaries (dict,window->terminals){ GtkWidget *terminal = (GtkWidget*)dict->data; - // window->journal_paths = yon_char_replace(window->journal_paths,"\n"," "); yon_terminal_integrated_start(terminal,yon_char_unite("cat ",dict->key,NULL),NULL,NULL); } } @@ -881,11 +890,6 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ maxsize = yon_char_unite("maxsize ", yon_char_from_long(value),yon_size_get_letter_from_int(last),NULL); } - // int create_log_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->CreateLogCombo)); - // if (create_log_active){ - // if (create_log_active==2) - // } - copytruncate = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->CutCheck)) ? "copytruncate" : ""; int compression_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->CompressionCombo)); @@ -1220,10 +1224,6 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->RotateSizeMaxBeforeTimeSpin),atol(value)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotateSizeMaxBeforeTimeCheck),1); gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotateSizeMaxBeforeTimeCombo),yon_size_get_int_from_letter(value[strlen(value)-1])); - // }else if (!strcmp(parsed[i],"create")){ - // - // }else if (!strcmp(parsed[i],"nocreate")){ - // }else if (strstr(parsed[i],"size")){ int sizemod = yon_size_get_int_from_letter(parsed[i][strlen(parsed[i])-1]); gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->JournalMaxSizeSpin),atol(strstr(parsed[i], " ")+1)); @@ -1325,9 +1325,7 @@ void on_logrotate_edit(GtkWidget *self, logrotate_window *window){ gtk_entry_set_text(GTK_ENTRY(dialog->LogNameEntry),name ? name : ""); gtk_entry_set_text(GTK_ENTRY(dialog->LogDescriptionEntry),description ? description : ""); gtk_widget_set_can_focus(dialog->LogNameEntry,0); - // gtk_widget_set_can_focus(dialog->LogDescriptionEntry,0); gtk_entry_set_has_frame(GTK_ENTRY(dialog->LogNameEntry),0); - // gtk_entry_set_has_frame(GTK_ENTRY(dialog->LogDescriptionEntry),0); gtk_style_context_add_class(gtk_widget_get_style_context(dialog->LogNameEntry),"nobackground"); gtk_style_context_add_class(gtk_widget_get_style_context(dialog->LogDescriptionEntry),"nobackground"); } @@ -2007,8 +2005,6 @@ void on_log_edit(GtkWidget *self,main_window *widgets){ yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); g_signal_connect(G_OBJECT(window->LogrotateButton),"clicked", G_CALLBACK(on_log_edit_logrotate_settings),dict); - // g_signal_connect(G_OBJECT(window->MetalogButton),"clicked", G_CALLBACK(on_log),widgets); - // g_signal_connect(G_OBJECT(window->SyslogButton),"clicked", G_CALLBACK(yon_journald_open),widgets); } window->log_name=name; gtk_entry_set_text(GTK_ENTRY(window->LogDescriptionEntry),description ? description : ""); @@ -2214,7 +2210,7 @@ void on_permissions_changed(){ char *command[] = {"/bin/pkexec","/bin/echo","1", NULL}; gchar *standard_output = NULL; gchar *standard_error = NULL; - gint exit_status = -1; // Инициализируем переменную для статуса выхода + gint exit_status = -1; GError *error = NULL; gboolean success = g_spawn_sync( @@ -2279,11 +2275,7 @@ void config_init(){ g_printerr ("Parent process was reaped by init(1)\n"); } subject = polkit_unix_process_new_for_owner (parent_pid,0,getuid()); - main_config.permissions = polkit_permission_new_sync( - "com.ublinux.ubl-settings-logging", - subject, // Пользователь (текущий пользователь) - NULL, // Опции (NULL, если не требуются) - NULL); + main_config.permissions = polkit_permission_new_sync("com.ublinux.ubl-settings-logging",subject,NULL,NULL); g_signal_connect(G_OBJECT(main_config.permissions),"notify::allowed",G_CALLBACK(on_permissions_changed),NULL); } @@ -2378,7 +2370,6 @@ main_window *setup_window(){ services[i]=yon_char_divide_search(services[i],"\n",-1); config_str log = yon_char_parse(services[i],&log_size,";"); gtk_list_store_append(widgets->ServicesList,&iter); - // yon_config_load gtk_list_store_set(widgets->ServicesList,&iter,0,1,1,1,2,log[0],3,_(log[1]),4,log[2],5,log[3],6,log[4],7,log[5],8,log[6],-1); } } @@ -2421,13 +2412,11 @@ main_window *setup_window(){ GList *list = gtk_tree_view_get_columns(GTK_TREE_VIEW(widgets->MainTree)); for (int i=0; iServicesTree)); for (int i=0; i #include #include +#include #include #include "../compile/ubl-cmake.h" #ifdef WEBKIT_FOUND -- 2.35.1