diff --git a/Makefile b/Makefile index 1399ffb..e333928 100644 --- a/Makefile +++ b/Makefile @@ -132,6 +132,7 @@ install: check uninstall @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.increase-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.decrease-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.profile-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.edit-symbolic.svg" @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" diff --git a/gresource.xml b/gresource.xml index 1914fde..f7a9968 100644 --- a/gresource.xml +++ b/gresource.xml @@ -3,9 +3,11 @@ ubl-settings-logging.glade ubl-settings-logging-add.glade + ubl-settings-logging-add-path.glade ubl-settings-logging-inspector.glade ubl-settings-logging-logrotate.glade ubl-settings-logging-journald.glade + ubl-settings-logging-rules.glade ubl-settings-logging-logrotate-table.glade diff --git a/icons/com.ublinux.ubl-settings-logging.edit-symbolic.svg b/icons/com.ublinux.ubl-settings-logging.edit-symbolic.svg new file mode 100644 index 0000000..baba3f9 --- /dev/null +++ b/icons/com.ublinux.ubl-settings-logging.edit-symbolic.svg @@ -0,0 +1,4 @@ + + + + diff --git a/journals_list.csv b/journals_list.csv index be0612f..c939ad6 100644 --- a/journals_list.csv +++ b/journals_list.csv @@ -1,12 +1,12 @@ -Журнал Acpid;/var/log/acpid;Журнал работы и обращений к Acpid -Журнал веб-сервера;/var/log/apache2/error.log,/var/log/apache2/access.log;Журнал работы и обращений к веб-серверу -Журнал аудита;/var/log/audit/audit.log;Журнал аудита (audit) -Журнал авторизации;/var/log/auth.log;Журнал процедур авторизации -Журнал планировщика заданий;/var/log/syslog;Журнал работы планировщика заданий (cron) -Журнал сервера печати;/var/log/cups/access_log,/var/log/cups/page_log,/var/log/cups/cups-pdf_log;Журнал работы и обращений к серверу печати (cups) -Журналы служб;/var/log/daemon.log;Журнал работы и обращения к службам системы -Журнал Samba;/var/log/samba/log.smbd,/var/log/samba/log.localhost,/var/log/samba/log.127.0.0.1,/var/log/samba/log.nmbd;Журнал работы и обращения к Samba -Журнал почтового сервера;/var/log/mail.log,/var/log/mail.info,/var/log/mail.warn,/var/log/mail.err;Журнал почтового сервера Postfix -Системный журнал;/var/log/syslog;Системный журнал -Журнал дисплейного сервера;/var/log/Xorg.0.log;Журнал работы дисплейного сервера X.org -Журнал сеансов графической системы X;~/.xsession-errors/;Журнал сеансов графической системы X \ No newline at end of file +Acpid;/var/log/acpid;Журнал работы и обращений к Acpid +Apache2;/var/log/apache2/error.log,/var/log/apache2/access.log;Журнал работы и обращений к веб-серверу +Audit;/var/log/audit/audit.log;Журнал аудита (audit) +Authlog;/var/log/auth.log;Журнал процедур авторизации +Cron;/var/log/syslog;Журнал работы планировщика заданий (cron) +CUPS;/var/log/cups/access_log,/var/log/cups/page_log,/var/log/cups/cups-pdf_log;Журнал работы и обращений к серверу печати (cups) +Daemonlog;/var/log/daemon.log;Журнал работы и обращения к службам системы +Samba;/var/log/samba/log.smbd,/var/log/samba/log.localhost,/var/log/samba/log.127.0.0.1,/var/log/samba/log.nmbd;Журнал работы и обращения к Samba +Postfix;/var/log/mail.log,/var/log/mail.info,/var/log/mail.warn,/var/log/mail.err;Журнал почтового сервера Postfix +Syslog;/var/log/syslog;Системный журнал +Xorg;/var/log/Xorg.0.log;Журнал работы дисплейного сервера X.org +Xsession;~/.xsession-errors;Журнал сеансов графической системы X \ No newline at end of file diff --git a/logging_services.csv b/logging_services.csv index ccc34a9..e9d43a8 100644 --- a/logging_services.csv +++ b/logging_services.csv @@ -1,4 +1,4 @@ journald;Системный журнал событий;systemctl start;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;Служба ротации системных журналов событий;systemctl start logrotate.service;systemctl stop logrotate.service;ubconfig set config SERVICESSTART+=logrotate.service;ubconfig set config SERVICESSTART-=logrotate.service;systemctl status logrotate.service -metalog;Системный журнал событий;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;Сервис сбора сообщений системных событий активных сетевых устройств;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 +#metalog;Системный журнал событий;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;Сервис сбора сообщений системных событий активных сетевых устройств;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 diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index c9220c0..24aa362 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -37,6 +37,8 @@ add_custom_target(GLADE ubl-settings-logging.glade) set(DEPENDFILES ../ubl-settings-logging.glade ../ubl-settings-logging-add.glade + ../ubl-settings-logging-add-path.glade + ../ubl-settings-logging-rules.glade ../ubl-settings-logging-inspector.glade ../ubl-settings-logging-journald.glade ../ubl-settings-logging-logrotate.glade diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 3b35ba2..a4d8b0e 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -93,6 +93,7 @@ void on_about(){ gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(window),version_application); gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(window),PROJECT_HOME_LABEL); gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(window),TITLE_LABEL); + gtk_window_set_title(GTK_WINDOW(window),TITLE_LABEL); gtk_label_set_text(GTK_LABEL(title),TITLE_LABEL); g_signal_connect(G_OBJECT(window),"activate-link",G_CALLBACK(on_link),NULL); gtk_widget_set_visible(hideButtonBox,0); @@ -100,72 +101,152 @@ void on_about(){ gtk_widget_show(window); } +char *yon_size_get_letter_from_int(int size){ + switch (size){ + case 0: return "K"; + break; + case 1: return "M"; + break; + case 2: return "G"; + break; + } +} + +int yon_size_get_int_from_letter(char size){ + switch (size){ + case 'K': return 0; + break; + case 'M': return 1; + break; + case 'G': return 2; + break; + } +} + //functions -void yon_load_proceed(char *command){ - yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + +void update_loaded_logrotate(){ + int size=0; + gtk_list_store_clear(main_config.logrotate_list); + GtkTreeIter iter; + config_str loaded = yon_config_get_all_by_key("LOGROTATE[",&size); + for (int i=0;iMainWindow=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->LogAddingBox=yon_gtk_builder_get_widget(builder,"LogAddingBox"); - window->LogTypeCombo=yon_gtk_builder_get_widget(builder,"LogTypeCombo"); - window->LogPathEntry=yon_gtk_builder_get_widget(builder,"LogPathEntry"); - window->LogFindButton=yon_gtk_builder_get_widget(builder,"LogFindButton"); - window->LogDescriptionEntry=yon_gtk_builder_get_widget(builder,"LogDescriptionEntry"); - window->LogrotateButton=yon_gtk_builder_get_widget(builder,"LogrotateButton"); - window->MetalogButton=yon_gtk_builder_get_widget(builder,"MetalogButton"); - window->SyslogButton=yon_gtk_builder_get_widget(builder,"SyslogButton"); - window->JournaldButton=yon_gtk_builder_get_widget(builder,"JournaldButton"); - window->LogSizeLabel=yon_gtk_builder_get_widget(builder,"LogSizeLabel"); - window->StatisticsFrame=yon_gtk_builder_get_widget(builder,"StatisticsFrame"); - gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked", G_CALLBACK(on_close_subwindow),NULL); - return window; +void on_load_global(){ + yon_load_proceed(YON_CONFIG_GLOBAL); + main_config.load_mode=0; + yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + update_loaded_logrotate(); } +void on_load_local(){ + yon_load_proceed(YON_CONFIG_LOCAL); + main_config.load_mode=1; + yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + update_loaded_logrotate(); + +} + +void yon_save_proceed(char *path,YON_CONFIG_TYPE type){ + if (!path||((type==YON_CONFIG_LOCAL&& main_config.load_mode==1)||(type==YON_CONFIG_GLOBAL&& main_config.load_mode==0))) + yon_config_save_registered(path); + else{ + if (type==YON_CONFIG_BOTH) + yon_launch("ubconfig remove system LOGROTATE[*] JOURNALD[*]"); + else if (type==YON_CONFIG_LOCAL) + yon_launch("ubconfig --target system remove system LOGROTATE[*] JOURNALD[*]"); + else if (type==YON_CONFIG_GLOBAL) + yon_launch("ubconfig --target global remove system LOGROTATE[*] JOURNALD[*]"); + yon_config_force_save_registered(path); + } + +} + +void on_save_global_local(){ + yon_save_proceed(NULL,YON_CONFIG_BOTH); + yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + +} + +void on_save_global(){ + yon_save_proceed("global",YON_CONFIG_LOCAL); + yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + +} + +void on_save_local(){ + yon_save_proceed("system",YON_CONFIG_GLOBAL); + yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + +} + +// Inspector functions + void on_inspector_update(GtkWidget *self, inspector_window *window){ int size; GtkTextIter titer,titerend; gtk_text_buffer_get_bounds(window->textbuffer1,&titer,&titerend); gtk_text_buffer_delete(window->textbuffer1,&titer,&titerend); config_str output; - if (self==window->UpdateButton){ - switch(window->last_mode){ - case 0: output = yon_config_load(get_journal_output_command, &size); - break; - case 1: output = yon_config_load(get_journal_output_since_boot_command, &size); - break; - case 2: output = yon_config_load(get_journal_output_followed_command, &size); - break; - case 3: output = yon_config_load(get_journal_output_kernel_command, &size); - break; - case 4: output = yon_config_load(get_journal_output_prioritied_command, &size); - break; + if (!strcmp(window->journal_name,"journald")){ + if (self==window->UpdateButton){ + switch(window->last_mode){ + case 0: output = yon_config_load(get_journal_output_command, &size); + break; + case 1: output = yon_config_load(get_journal_output_since_boot_command, &size); + break; + case 2: output = yon_config_load(get_journal_output_followed_command, &size); + break; + case 3: output = yon_config_load(get_journal_output_kernel_command, &size); + break; + case 4: output = yon_config_load(get_journal_output_prioritied_command, &size); + break; + } } - } - if (self==window->ShowSinceBootButton){ - window->last_mode=1; - output = yon_config_load(get_journal_output_since_boot_command, &size); - } - if (self==window->NewMessagesButton){ - window->last_mode=2; - output = yon_config_load(get_journal_output_followed_command, &size); - } - if (self==window->ShowKernelButton){ - window->last_mode=3; - output = yon_config_load(get_journal_output_kernel_command, &size); - } - if (self==window->ShowPriorityButton){ - window->last_mode=4; - output = yon_config_load(get_journal_output_prioritied_command, &size); - } - if (output){ + if (self==window->ShowSinceBootButton){ + window->last_mode=1; + output = yon_config_load(get_journal_output_since_boot_command, &size); + } + if (self==window->NewMessagesButton){ + window->last_mode=2; + output = yon_config_load(get_journal_output_followed_command, &size); + } + if (self==window->ShowKernelButton){ + window->last_mode=3; + output = yon_config_load(get_journal_output_kernel_command, &size); + } + if (self==window->ShowPriorityButton){ + window->last_mode=4; + output = yon_config_load(get_journal_output_prioritied_command, &size); + } + if (output){ + for (int i=0;itextbuffer1,&titer); + gtk_text_buffer_insert(window->textbuffer1,&titer,output[i],-1); + } + gtk_text_buffer_get_end_iter(window->textbuffer1,&titer); + gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(window->LoggingTextView),&titer,0.25,0,1,0); + } + } else { + window->journal_paths = yon_char_replace(window->journal_paths,"\n"," "); + output = yon_config_load(yon_char_unite("cat ",window->journal_paths,NULL),&size); for (int i=0;itextbuffer1,&titer); gtk_text_buffer_insert(window->textbuffer1,&titer,output[i],-1); @@ -187,22 +268,26 @@ void on_inspector_open(GtkWidget *self, main_window *widgets){ window->UpdateButton=yon_gtk_builder_get_widget(builder,"UpdateButton"); window->LoggingTextView=yon_gtk_builder_get_widget(builder,"LoggingTextView"); window->JournalActionsBox=yon_gtk_builder_get_widget(builder,"JournalActionsBox"); + gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); GtkTreeIter iter; char *name; + char *paths; 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); g_signal_connect(G_OBJECT(window->ShowPriorityButton),"clicked", G_CALLBACK(on_inspector_update),window); g_signal_connect(G_OBJECT(window->ShowSinceBootButton),"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); + gtk_tree_model_get(model,&iter,0,&name,1,&paths,-1); if (strcmp(name,"journald")){ window->last_mode=-1; gtk_widget_hide(window->JournalActionsBox); } else { window->last_mode=0; } + window->journal_name=name; + window->journal_paths=paths; on_inspector_update(window->UpdateButton,window); gtk_widget_show(window->MainWindow); } @@ -225,14 +310,298 @@ void on_log_choose(GtkWidget *self,add_log_window *window){ gtk_widget_destroy(dialog); } -logrotate_configure_window *yon_logrotate_window_new(){ +// Logrotate window + +void on_logrotate_configuration_path_add(GtkWidget *self, logrotate_configure_window *window){ + GtkTreeModel *model = GTK_TREE_MODEL(window->list); + GtkTreeIter iter; + gtk_list_store_append(window->list, &iter); + GtkTreeViewColumn *column = gtk_tree_view_get_column(GTK_TREE_VIEW(window->LogPathsTree),0); + GList *list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column)); + GValue *val = g_malloc0(sizeof(GValue)); + g_object_get_property(G_OBJECT(list->data),"editable",val); + g_value_set_boolean(val,1); + g_object_set_property(G_OBJECT(list->data),"editable",val); + free(val); + gtk_tree_view_set_cursor(GTK_TREE_VIEW(window->LogPathsTree),gtk_tree_model_get_path(model,&iter),column,1); +} + +void on_path_editing_done(GtkCellRendererText* self,gchar* path,gchar* new_text,logrotate_configure_window *window){ + GtkTreeIter iter; + 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,"")) + 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); + GValue *val = g_malloc0(sizeof(GValue)); + g_object_get_property(G_OBJECT(self),"editable",val); + g_value_set_boolean(val,0); + g_object_set_property(G_OBJECT(self),"editable",val); + free(val); +} + +void on_path_editing_cancel(GtkCellRendererText* self,logrotate_configure_window *window){ + GtkTreeModel *model = GTK_TREE_MODEL(window->list); + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->LogPathsTree)),&model,&iter)){ + char *path; + gtk_tree_model_get(model,&iter,0,&path,-1); + if (!path||!strcmp(path,"")) + gtk_list_store_remove(window->list,&iter); + } +} + +void on_logrotate_configuration_path_edit(GtkWidget *self, logrotate_configure_window *window){ + GtkTreeModel *model = GTK_TREE_MODEL(window->list); + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->LogPathsTree)),&model,&iter)){ + GtkTreeViewColumn *column = gtk_tree_view_get_column(GTK_TREE_VIEW(window->LogPathsTree),0); + GList *list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column)); + GValue *val = g_malloc0(sizeof(GValue)); + g_object_get_property(G_OBJECT(list->data),"editable",val); + g_value_set_boolean(val,1); + g_object_set_property(G_OBJECT(list->data),"editable",val); + free(val); + gtk_tree_view_set_cursor(GTK_TREE_VIEW(window->LogPathsTree),gtk_tree_model_get_path(model,&iter),column,1); + } +} + +void on_logrotate_configuration_path_remove(GtkWidget *self, logrotate_configure_window *window){ + GtkTreeModel *model = GTK_TREE_MODEL(window->list); + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->LogPathsTree)),&model,&iter)){ + gtk_list_store_remove(window->list,&iter); + } +} + +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 *paths=""; + char *period=""; + char *size=""; + char *rotate_count=""; + char *olddir=""; + char *su=""; + char *missingok=""; + char *ifempty=""; + char *notifempty=""; + char *minage=""; + char *maxage=""; + char *minsize=""; + char *maxsize=""; + char *create=""; + char *copytruncate=""; + char *compress=""; + char *delaycompress=""; + char *extension=""; + char *dateext=""; + char *start=""; + char *mail=""; + char *mailfirst=""; + char *sharedscripts=""; + char *firstaction=""; + char *lastaction=""; + char *prerotate=""; + char *postrotate=""; + char *preremove=""; + char *endscript=""; + + GtkTreeIter iter; + int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&iter); + 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); + paths = yon_char_unite(paths,strcmp(paths,"") ? "," : "", cur_path,NULL); + } + 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){ + case 0: period = "hourly"; + break; + case 1: period = "daily"; + break; + case 2: period = "weekly"; + int weekday = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotationPeriodAdditionalCombo)); + weekday++; + if (weekday==7) weekday=0; + period = yon_char_unite(period,", ",yon_char_from_int(weekday),NULL); + break; + case 3: period = "monthly"; + break; + case 4: period = "yearly"; + break; + } + } + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->JournalMaxSizeCheck))){ + int last = gtk_combo_box_get_active(GTK_COMBO_BOX(window->JournalMaxSizeCombo)); + long maxsize = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->JournalMaxSizeSpin)); + size = yon_char_unite("size ",yon_char_from_long(maxsize),yon_size_get_letter_from_int(last),NULL); + } + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->FileAmountCheck))){ + long fileamount = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->FileAmountSpin)); + int active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->FileAmountCombo)); + rotate_count = yon_char_append("rotate ",yon_char_from_long(fileamount)); + if (active==2){ + const char *text = gtk_entry_get_text(GTK_ENTRY(window->FileAmountEntry)); + olddir=yon_char_unite("olddir ",text,NULL); + } + } + + char *user_rotate = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->RotationAtUserCombo)); + char *group_rotate = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->RotationAtGroupCombo)); + if (!yon_char_is_empty(user_rotate)&&!yon_char_is_empty(group_rotate)){ + if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotationAtUserCombo))==0) user_rotate = "root"; + if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotationAtGroupCombo))==0) group_rotate = "root"; + su = yon_char_unite("su ",user_rotate," ",group_rotate,NULL); + } + + int error_processing = gtk_combo_box_get_active(GTK_COMBO_BOX(window->ErrorProcessingCombo)); + if (error_processing==0|| error_processing==1) { + error_processing=1; + missingok = "missingok"; + } else { + missingok = "nomissingok"; + } + + int empty_journal = gtk_combo_box_get_active(GTK_COMBO_BOX(window->JournalEmptyCombo)); + if (empty_journal==0||empty_journal==1) { + empty_journal = 1; + ifempty = "ifempty"; + } + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DoNotRotateYoungerCheck))){ + long younger = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DoNotRotateYoungerSpin)); + minage = yon_char_append("minage ",yon_char_from_long(younger)); + } + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeleteOlderCheck))){ + long older = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeleteOlderSpin)); + maxage = yon_char_append("maxage ", yon_char_from_long(older)); + } + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->RotateSizeMaxAfterTimeCheck))){ + long value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->RotateSizeMaxAfterTimeSpin)); + int last = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotateSizeMaxAfterTimeCombo)); + minsize = yon_char_unite("minsize ",yon_char_from_long(value),yon_size_get_letter_from_int(last),NULL); + } + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->RotateSizeMaxBeforeTimeCheck))){ + long value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->RotateSizeMaxBeforeTimeSpin)); + int last = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotateSizeMaxBeforeTimeCombo)); + 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)); + if (compression_active){ + switch (compression_active){ + case 1: compress = "compress"; + break; + case 2: compress = "nocompress"; + break; + } + } + + int compression_delay_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->QueueCombo)); + if (compression_delay_active){ + switch (compression_delay_active){ + case 1: delaycompress = "delaycompress"; + break; + case 2: delaycompress = "nodelaycompress"; + break; + } + } + + int original_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->SaveOriginalCombo)); + if (original_active==1){ + char *ext_file = (char*)gtk_entry_get_text(GTK_ENTRY(window->SaveOriginalEntry)); + extension = yon_char_append("extension ",ext_file); + } + + if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->AddDateCombo))==1){ + dateext = "dateext"; + } + + if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->OldNumberCombo))==1){ + long value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->OldNumberEntry)); + if (value>0) + start = yon_char_append("start ",yon_char_from_long(value)); + } + + int email_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->EmailCombo)); + if (email_active){ + switch(email_active){ + case 1: + char *adress = (char*)gtk_entry_get_text(GTK_ENTRY(window->EmailEntry)); + if (!yon_char_is_empty(adress)) + mail=yon_char_append("mail ", adress); + int contents_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->EmailContentsCombo)); + if (contents_active==1) + mailfirst = "mailfirst"; + else if (contents_active==2) + mailfirst = "maillast"; + break; + case 2: mail = "nomail"; + break; + } + } + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->SharedScenariosCheck))){ + char *before_once = (char*)gtk_entry_get_text(GTK_ENTRY(window->CommandBeforeOnceEntry)); + char *after_once = (char*)gtk_entry_get_text(GTK_ENTRY(window->CommandAfterOnceEntry)); + char *before = (char*)gtk_entry_get_text(GTK_ENTRY(window->CommandBeforeEntry)); + char *after = (char*)gtk_entry_get_text(GTK_ENTRY(window->CommandAfterEntry)); + char *endwork = (char*)gtk_entry_get_text(GTK_ENTRY(window->EndworkCommandEntry)); + sharedscripts = "sharedscripts"; + if (!yon_char_is_empty(before_once)) + firstaction = yon_char_append("firstaction ",before_once); + if (!yon_char_is_empty(after_once)) + lastaction = yon_char_append("lastaction ",after_once); + if (!yon_char_is_empty(before)) + prerotate = yon_char_append("prerotate ",before); + if (!yon_char_is_empty(after)) + postrotate = yon_char_append("postrotate ",after); + if (!yon_char_is_empty(endwork)) + endscript = yon_char_append("endscript ",endwork); + } + + char *commandline = yon_char_unite(period,yon_add_space_if_exists(size),yon_add_space_if_exists(rotate_count),yon_add_space_if_exists(olddir),yon_add_space_if_exists(su),yon_add_space_if_exists(missingok),yon_add_space_if_exists(ifempty),yon_add_space_if_exists(notifempty),yon_add_space_if_exists(minage),yon_add_space_if_exists(maxage),yon_add_space_if_exists(minsize),yon_add_space_if_exists(maxsize),yon_add_space_if_exists(create),yon_add_space_if_exists(copytruncate),yon_add_space_if_exists(compress),yon_add_space_if_exists(delaycompress),yon_add_space_if_exists(extension),yon_add_space_if_exists(dateext),yon_add_space_if_exists(start),yon_add_space_if_exists(mail),yon_add_space_if_exists(mailfirst),yon_add_space_if_exists(sharedscripts),yon_add_space_if_exists(firstaction),yon_add_space_if_exists(lastaction),yon_add_space_if_exists(prerotate),yon_add_space_if_exists(postrotate),yon_add_space_if_exists(preremove),yon_add_space_if_exists(endscript),NULL); + if (commandline[0]==' '){ + free(yon_char_divide_search(commandline," ",-1)); + } + if(!yon_char_is_empty(paths)){ + GtkTreeIter iter; + yon_config_register(LOGROTATE(paths),"logging",commandline); + 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); + } + 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); + on_close_subwindow(window->MainWindow); + } +} + +logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_window *dialog){ logrotate_configure_window *window = malloc(sizeof(logrotate_configure_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_logrotate_path); 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->LogNamelabel=yon_gtk_builder_get_widget(builder,"LogNamelabel"); - window->LogNameButton=yon_gtk_builder_get_widget(builder,"LogNameButton"); + window->LogNameEntry=yon_gtk_builder_get_widget(builder,"LogNameEntry"); + window->LogDescriptionEntry=yon_gtk_builder_get_widget(builder,"LogDescriptionEntry"); window->RotationPeriodCheck=yon_gtk_builder_get_widget(builder,"RotationPeriodCheck"); window->RotationPeriodMainCombo=yon_gtk_builder_get_widget(builder,"RotationPeriodMainCombo"); window->RotationPeriodAdditionalCombo=yon_gtk_builder_get_widget(builder,"RotationPeriodAdditionalCombo"); @@ -277,49 +646,300 @@ logrotate_configure_window *yon_logrotate_window_new(){ window->ManualInputEntry=yon_gtk_builder_get_widget(builder,"ManualInputEntry"); window->LogSizeLabel=yon_gtk_builder_get_widget(builder,"LogSizeLabel"); window->headerTopic=yon_gtk_builder_get_widget(builder,"headerTopic"); - window->LogNameDescriptionLabel=yon_gtk_builder_get_widget(builder,"LogNameDescriptionLabel"); + window->LogPathsTree=yon_gtk_builder_get_widget(builder,"LogPathsTree"); + window->LogPathEditButton=yon_gtk_builder_get_widget(builder,"LogPathEditButton"); + window->LogPathAddButton=yon_gtk_builder_get_widget(builder,"LogPathAddButton"); + window->LogPathRemoveButton=yon_gtk_builder_get_widget(builder,"LogPathRemoveButton"); window->list=GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1")); + window->PathCell=GTK_CELL_RENDERER(gtk_builder_get_object(builder,"PathCell")); + window->SharedScenariosCheck=yon_gtk_builder_get_widget(builder,"SharedScenariosCheck"); + window->CommandBeforeOnceEntry=yon_gtk_builder_get_widget(builder,"CommandBeforeOnceEntry"); + window->CommandAfterOnceEntry=yon_gtk_builder_get_widget(builder,"CommandAfterOnceEntry"); + window->CommandBeforeEntry=yon_gtk_builder_get_widget(builder,"CommandBeforeEntry"); + window->CommandAfterEntry=yon_gtk_builder_get_widget(builder,"CommandAfterEntry"); + window->EndworkCommandEntry=yon_gtk_builder_get_widget(builder,"EndworkCommandEntry"); + gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); + + dictionary *dict=NULL; + yon_dictionary_add_or_create_if_exists_with_data(dict,"dialog",dialog); + 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_close_subwindow),NULL); + g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_logrotate_save),dict); + g_signal_connect(G_OBJECT(window->PathCell),"edited",G_CALLBACK(on_path_editing_done),window); + g_signal_connect(G_OBJECT(window->PathCell),"editing-canceled",G_CALLBACK(on_path_editing_cancel),window); + g_signal_connect(G_OBJECT(window->LogPathAddButton),"clicked",G_CALLBACK(on_logrotate_configuration_path_add),window); + g_signal_connect(G_OBJECT(window->LogPathEditButton),"clicked",G_CALLBACK(on_logrotate_configuration_path_edit),window); + g_signal_connect(G_OBJECT(window->LogPathRemoveButton),"clicked",G_CALLBACK(on_logrotate_configuration_path_remove),window); + + g_signal_connect(G_OBJECT(window->RotationPeriodCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotationPeriodAdditionalCombo); + g_signal_connect(G_OBJECT(window->RotationPeriodCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotationPeriodMainCombo); + + g_signal_connect(G_OBJECT(window->JournalMaxSizeCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->JournalMaxSizeCombo); + g_signal_connect(G_OBJECT(window->JournalMaxSizeCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->JournalMaxSizeSpin); + + g_signal_connect(G_OBJECT(window->FileAmountCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountSpin); + g_signal_connect(G_OBJECT(window->FileAmountCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountCombo); + g_signal_connect(G_OBJECT(window->FileAmountCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountEntry); + g_signal_connect(G_OBJECT(window->FileAmountCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountButton); + + g_signal_connect(G_OBJECT(window->DoNotRotateYoungerCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DoNotRotateYoungerSpin); + + g_signal_connect(G_OBJECT(window->DeleteOlderCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeleteOlderSpin); + g_signal_connect(G_OBJECT(window->RotateSizeMaxAfterTimeCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxAfterTimeSpin); + g_signal_connect(G_OBJECT(window->RotateSizeMaxAfterTimeCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxAfterTimeCombo); + + g_signal_connect(G_OBJECT(window->RotateSizeMaxBeforeTimeCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxBeforeTimeSpin); + g_signal_connect(G_OBJECT(window->RotateSizeMaxBeforeTimeCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxBeforeTimeCombo); + + g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box_inversed),window->CreateLogUserCombo); + g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box_inversed),window->CreateGroupCombo); + g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box_inversed),window->CreateLogEntry); + g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box_inversed),window->CreateLogButton); + + int usize=0; + config_str users = yon_ubl_get_all_users(&usize); + yon_gtk_combo_box_fill(window->CreateLogUserCombo,users,usize); + yon_gtk_combo_box_fill(window->RotationAtUserCombo,users,usize); + + if (paths){ + int size; + GtkTreeIter iter; + config_str parsed = yon_char_parse(paths,&size,","); + for (int i=0; ilist,&iter); + gtk_list_store_set(window->list,&iter,0,parsed[i],-1); + } + yon_char_parsed_free(parsed,size); + char *parameters = yon_config_get_by_key(LOGROTATE(paths)); + if (parameters){ + parsed = yon_char_parse(parameters,&size,","); + for (int i=0;iRotationPeriodMainCombo),0); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotationPeriodCheck),1); + } else if (!strcmp(parsed[i],"daily")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),1); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotationPeriodCheck),1); + }else if (!strcmp(parsed[i],"weekly")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),2); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotationPeriodCheck),1); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodAdditionalCombo),atoi(parsed[i+1])); + }else if (!strcmp(parsed[i],"monthly")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),3); + }else if (!strcmp(parsed[i],"yearly")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),4); + }else if (!strcmp(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(parsed[i])); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalMaxSizeCombo),sizemod); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->JournalMaxSizeCheck),1); + }else if (!strcmp(parsed[i],"rotate")){ + char *value = strstr(parsed[i]," ")+1; + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->FileAmountSpin),atol(value)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->FileAmountCheck),1); + }else if (!strcmp(parsed[i],"olddir")){ + char *value = strstr(parsed[i]," ")+1; + gtk_entry_set_text(GTK_ENTRY(window->FileAmountEntry),value); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->FileAmountCombo),1); + }else if (!strcmp(parsed[i],"noolddir")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->FileAmountCombo),2); + }else if (!strcmp(parsed[i],"su")){ + char *value = strstr(parsed[i]," ")+1; + char *nvalue = yon_char_divide_search(value," ",-1); + int us = yon_gtk_combo_box_text_find(window->RotationAtUserCombo,nvalue); + int gr = yon_gtk_combo_box_text_find(window->RotationAtGroupCombo,value); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationAtUserCombo),us); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationAtGroupCombo),gr); + }else if (!strcmp(parsed[i],"missingok")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->ErrorProcessingCombo),1); + }else if (!strcmp(parsed[i],"nomissingok")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->ErrorProcessingCombo),2); + }else if (!strcmp(parsed[i],"ifempty")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalEmptyCombo),1); + }else if (!strcmp(parsed[i],"notifempty")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalEmptyCombo),2); + }else if (!strcmp(parsed[i],"minage")){ + char *value = strstr(parsed[i]," ")+1; + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DoNotRotateYoungerSpin),atol(value)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DoNotRotateYoungerCheck),1); + }else if (!strcmp(parsed[i],"maxage")){ + char *value = strstr(parsed[i]," ")+1; + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeleteOlderSpin),atol(value)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeleteOlderCheck),1); + }else if (!strcmp(parsed[i],"minsize")){ + char *value = strstr(parsed[i]," ")+1; + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->RotateSizeMaxAfterTimeSpin),atol(value)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotateSizeMaxAfterTimeCheck),1); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotateSizeMaxAfterTimeCombo),yon_size_get_int_from_letter(value[strlen(value)-1])); + }else if (!strcmp(parsed[i],"maxsize")){ + char *value = strstr(parsed[i]," ")+1; + 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 (!strcmp(parsed[i],"copytruncate")){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->CutCheck),1); + }else if (!strcmp(parsed[i],"compress")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->CompressionCombo),1); + }else if (!strcmp(parsed[i],"nocompress")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->CompressionCombo),2); + }else if (!strcmp(parsed[i],"delaycompress")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->QueueCombo),1); + + }else if (!strcmp(parsed[i],"nodelaycompress")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->QueueCombo),2); + }else if (!strcmp(parsed[i],"extension")){ + char *value = strstr(parsed[i]," ")+1; + gtk_combo_box_set_active(GTK_COMBO_BOX(window->SaveOriginalCombo),1); + gtk_entry_set_text(GTK_ENTRY(window->SaveOriginalEntry),value); + }else if (!strcmp(parsed[i],"dateext")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->AddDateCombo),1); + }else if (!strcmp(parsed[i],"start")){ + char *value = strstr(parsed[i]," ")+1; + gtk_combo_box_set_active(GTK_COMBO_BOX(window->OldNumberCombo),1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->OldNumberEntry),atol(value)); + }else if (!strcmp(parsed[i],"mail")){ + char *value = strstr(parsed[i]," ")+1; + gtk_entry_set_text(GTK_ENTRY(window->EmailEntry),value); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailCombo),1); + }else if (!strcmp(parsed[i],"nomail")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailCombo),2); + }else if (!strcmp(parsed[i],"mailfirst")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailContentsCombo),1); + }else if (!strcmp(parsed[i],"maillast")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailContentsCombo),2); + }else if (!strcmp(parsed[i],"sharedscripts")){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->SharedScenariosCheck),1); + }else if (!strcmp(parsed[i],"firstaction")){ + char *value = parsed[i+1]; + gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeOnceEntry),value); + i++; + }else if (!strcmp(parsed[i],"lastaction")){ + char *value = parsed[i+1]; + gtk_entry_set_text(GTK_ENTRY(window->CommandAfterOnceEntry),value); + i++; + }else if (!strcmp(parsed[i],"prerotate")){ + char *value = parsed[i+1]; + gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeEntry),value); + i++; + }else if (!strcmp(parsed[i],"postrotate")){ + char *value = parsed[i+1]; + gtk_entry_set_text(GTK_ENTRY(window->CommandAfterEntry),value); + i++; + // }else if (!strcmp(parsed[i],"preremove")){ + // char *value = parsed[i+1]; + // gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeOnceEntry),value); + // i++; + }else if (!strcmp(parsed[i],"endscript")){ + } + } + } + } + return window; } -void on_logrotate_add(GtkWidget *self, main_window *widgets){ - logrotate_configure_window *window = yon_logrotate_window_new(); +void on_logrotate_add(GtkWidget *self, logrotate_window *dialog){ + logrotate_configure_window *window = yon_logrotate_window_new(NULL,NULL); + gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->MainTree))); gtk_widget_show(window->MainWindow); - add_log_window *dialog = on_add_open(); - gtk_widget_hide(dialog->StatisticsFrame); - gtk_widget_hide(dialog->JournaldButton); - gtk_label_set_text(GTK_LABEL(window->LogNamelabel),""); - gtk_label_set_text(GTK_LABEL(window->LogNameDescriptionLabel),""); + gtk_widget_set_sensitive(window->LogNameEntry,1); + gtk_widget_set_sensitive(window->LogDescriptionEntry,1); gtk_label_set_text(GTK_LABEL(window->LogSizeLabel),""); - gtk_window_present(GTK_WINDOW(dialog->MainWindow)); } -void on_logrotate_edit(GtkWidget *self, logrotate_tab_window *window){ +void on_logrotate_edit(GtkWidget *self, logrotate_window *window){ GtkTreeModel *model = GTK_TREE_MODEL(main_config.logrotate_list); - GtkTreeIter iter; + GtkTreeIter iter,itar; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->MainTree)),&model, &iter)){ - logrotate_configure_window *dialog = yon_logrotate_window_new(); - - gtk_widget_show(dialog->MainWindow); + char *name; + int size=0; + char *paths; + char *description; + gtk_tree_model_get(gtk_tree_view_get_model(GTK_TREE_VIEW(window->MainTree)),&iter,1,&paths,-1); + config_str path_parsed = yon_char_parse(paths,&size,"\n"); + paths=NULL; + for (int i=0;iMainWindow); + gtk_tree_model_get(model,&iter,0,&name,1,&paths,2,&description,-1); + gtk_entry_set_text(GTK_ENTRY(dialog->LogNameEntry),name); + gtk_entry_set_text(GTK_ENTRY(dialog->LogDescriptionEntry),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"); } } -void on_logrotate_remove(GtkWidget *self, logrotate_tab_window *window){ +void on_logrotate_remove(GtkWidget *self, logrotate_window *window){ GtkTreeModel *model = GTK_TREE_MODEL(main_config.logrotate_list); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->MainTree)),&model, &iter)){ + char *paths; + gtk_tree_model_get(model,&iter,1,&paths,-1); gtk_list_store_remove(main_config.logrotate_list,&iter); + yon_char_replace(paths,"\n",","); + yon_config_remove_by_key(LOGROTATE(paths)); } } -void on_logrotate_apps_configure(){ +void on_logrotate_apps_configure(GtkWidget *self, logrotate_window *window){ + GtkTreeModel *model = GTK_TREE_MODEL(main_config.logrotate_apps_list); + GtkTreeIter iter,itar; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->AppsMainTree)),&model,&iter)){ + char *paths; + char *name; + char *settings; + gtk_list_store_append(main_config.logrotate_list,&itar); + gtk_tree_model_get(model,&iter,0,&name,1,&paths,2,&settings,-1); + settings = yon_char_replace(settings,",\t",","); + if (settings[0]==',') yon_char_divide_search(settings,",",-1); + yon_config_register(LOGROTATE(yon_char_replace(paths,"\n",",")),"logging",settings); + gtk_list_store_set(main_config.logrotate_list,&itar,0,name,1,paths,-1); + } +} +void on_log_edit_logrotate_settings(GtkWidget *self, dictionary *dict){ + main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); + add_log_window *window = yon_dictionary_get_data(dict->first->next,add_log_window*); + GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); + GtkTreeIter iter,itar; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ + char *name; + char *description; + gtk_tree_model_get(model,&iter,0,&name,2,&description,-1); + GList *list = gtk_container_get_children(GTK_CONTAINER(window->LogPathsBox)); + char *pathse=NULL; + for (int i=0;iMainWindow); + gtk_entry_set_text(GTK_ENTRY(dialog->LogNameEntry),name); + gtk_entry_set_text(GTK_ENTRY(dialog->LogDescriptionEntry),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"); + + } } +// Logrotate tab window + void on_logrotate_tab_open(GtkWidget *self, main_window *widgets){ logrotate_window *window = malloc(sizeof(logrotate_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_logrotate_table_path); @@ -342,21 +962,161 @@ void on_logrotate_tab_open(GtkWidget *self, main_window *widgets){ 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); - g_signal_connect(G_OBJECT(window->AppsConfigureButton),"clicked",G_CALLBACK(on_logrotate_apps_configure),NULL); + g_signal_connect(G_OBJECT(window->AppsConfigureButton),"clicked",G_CALLBACK(on_logrotate_apps_configure),window); gtk_widget_show(window->Window); } -void on_journald_open(GtkWidget *self, main_window *widgets){ +// Journald window + +void yon_combo_compress_check(GtkComboBox *self, journald_window *window){ + if (gtk_combo_box_get_active(self)==3){ + gtk_widget_set_sensitive(window->LogCompressionSizeCombo,1); + gtk_widget_set_sensitive(window->LogCompressionEntry,1); + } else { + gtk_widget_set_sensitive(window->LogCompressionSizeCombo,0); + gtk_widget_set_sensitive(window->LogCompressionEntry,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)); + switch (storage_active){ + case 1: storage="volatile"; + break; + case 2: storage="persistent"; + break; + case 3: storage="auto"; + break; + case 4: storage="none"; + break; + + } + char *compress; + int compress_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->LogCompressionCombo)); + if (compress_active==1) compress = "yes"; + else if (compress_active==2) compress = "no"; + else if (compress_active==3) { + int compress_size_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->LogCompressionSizeCombo)); + int compress_size = atoi(gtk_entry_get_text(GTK_ENTRY(window->LogCompressionEntry))); + compress=yon_char_from_int(compress_size); + if (compress_size==0) + compress_active=0; + switch (compress_size_active){ + case 0: compress = yon_char_append(compress,"K"); + break; + case 1: compress = yon_char_append(compress,"M"); + break; + case 2: compress = yon_char_append(compress,"G"); + break; + } + } + char *splitmode; + int splitmode_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->DivideJournalFilesCombo)); + if (splitmode_active == 1) splitmode = "uid"; + else if (splitmode_active == 2 ) splitmode = "none"; + + long interval=-1; + long amount=-1; + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->LogIntervalCheck))){ + interval = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->LogIntervalSpin)); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->LogIntervalAmountCheck))){ + amount = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->LogIntervalAmountSpin)); + if (amount>0) + yon_config_register(JOURNALD("RateLimitBurst"),"logging",yon_char_from_long(amount)); + } + if (interval>0) + yon_config_register(JOURNALD("RateLimitIntervalSec"),"logging",yon_char_from_long(interval)); + } else { + yon_config_remove_by_key(JOURNALD("RateLimitBurst")); + yon_config_remove_by_key(JOURNALD("RateLimitIntervalSec")); + + } + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->LogSizeMaxCheck))){ + long logssize=-1; + 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) + yon_config_register(JOURNALD("SystemMaxUse"),"logging",yon_char_from_long(logssize)); + } else + yon_config_remove_by_key(JOURNALD("SystemMaxUse")); + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->RotationSizeMaxCheck))){ + char * rotationMaxSize; + long maxsize = 0; + maxsize=gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->RotationSizeMaxSpin)); + char *modif = yon_size_get_letter_from_int(gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotationSizeMaxCombo))); + rotationMaxSize = yon_char_append(yon_char_from_long(maxsize),modif); + if (maxsize>0) + yon_config_register(JOURNALD("SystemMaxFileSize"),"logging",rotationMaxSize); + } else + yon_config_remove_by_key(JOURNALD("SystemMaxFileSize")); + + long storagefree; + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->LogFreeSpaceCheck))){ + char *storagespace; + storagefree = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->LogFreeSpaceSpin)); + char *modif = yon_size_get_letter_from_int(gtk_combo_box_get_active(GTK_COMBO_BOX(window->LogFreeSpaceCombo))); + storagespace = yon_char_append(yon_char_from_long(storagefree),modif); + + if (storagefree>0) + yon_config_register(JOURNALD("SystemKeepFree"),"logging",storagespace); + } else + yon_config_remove_by_key(JOURNALD("SystemKeepFree")); + + int consoleforwardactive = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RedirectCombo)); + char *confor=NULL; + char *TTY=NULL; + if (consoleforwardactive == 1){ + confor = "yes"; + TTY = (char*)gtk_entry_get_text(GTK_ENTRY(window->RedirectTTYEntry)); + if (yon_char_is_empty(TTY)) + consoleforwardactive=0; + } + else if (consoleforwardactive == 2){ + confor = "no"; + } + + int forwardempty = gtk_combo_box_get_active(GTK_COMBO_BOX(window->ForwardedTypeCombo)); + + if (storage_active!=0) + yon_config_register(JOURNALD("Storage"),"logging",storage); + else + yon_config_remove_by_key(JOURNALD("Storage")); + if (compress_active!=0) + yon_config_register(JOURNALD("Compress"),"logging",compress); + else + yon_config_remove_by_key(JOURNALD("Compress")); + if (splitmode_active!=0) + yon_config_register(JOURNALD("SplitMode"),"logging",splitmode); + else + yon_config_remove_by_key(JOURNALD("SplitMode")); + if (consoleforwardactive != 0) + yon_config_register(JOURNALD("ForwardToConsole"),"logging",confor); + else + yon_config_remove_by_key(JOURNALD("ForwardToConsole")); + if (forwardempty!=0) + 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); +} + +journald_window *yon_journald_open(GtkWidget *self, main_window *widgets){ journald_window *window = malloc(sizeof(journald_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_journald_path); 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->LogNameLabel=yon_gtk_builder_get_widget(builder,"LogNameLabel"); - window->LogDescriptionLabel=yon_gtk_builder_get_widget(builder,"LogDescriptionLabel"); + 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"); window->LogCompressionCombo=yon_gtk_builder_get_widget(builder,"LogCompressionCombo"); - window->LogCompressionEntry=yon_gtk_builder_get_widget(builder,"LogCompressionEntry"); + window->LogCompressionEntry=yon_gtk_builder_get_widget(builder,"LogCompressionSpin"); window->LogCompressionSizeCombo=yon_gtk_builder_get_widget(builder,"LogCompressionSizeCombo"); window->DivideJournalFilesCombo=yon_gtk_builder_get_widget(builder,"DivideJournalFilesCombo"); window->LogIntervalCheck=yon_gtk_builder_get_widget(builder,"LogIntervalCheck"); @@ -376,10 +1136,10 @@ void on_journald_open(GtkWidget *self, main_window *widgets){ window->RedirectTTYEntry=yon_gtk_builder_get_widget(builder,"RedirectTTYEntry"); window->ForwardedTypeCombo=yon_gtk_builder_get_widget(builder,"ForwardedTypeCombo"); window->LogSizeLabel=yon_gtk_builder_get_widget(builder,"LogSizeLabel"); - window->LowerSizeEntry=yon_gtk_builder_get_widget(builder,"LowerSizeEntry"); + window->LowerSizeEntry=yon_gtk_builder_get_widget(builder,"LowerSizeSpin"); window->LowerSizeCombo=yon_gtk_builder_get_widget(builder,"LowerSizeCombo"); window->LowerSizeButton=yon_gtk_builder_get_widget(builder,"LowerSizeButton"); - window->LowerTimeEntry=yon_gtk_builder_get_widget(builder,"LowerTimeEntry"); + window->LowerTimeEntry=yon_gtk_builder_get_widget(builder,"LowerTimeSpin"); window->LowerTimeCombo=yon_gtk_builder_get_widget(builder,"LowerTimeCombo"); window->LowerTimeButton=yon_gtk_builder_get_widget(builder,"LowerTimeButton"); window->headerTopic=yon_gtk_builder_get_widget(builder,"headerTopic"); @@ -387,23 +1147,133 @@ void on_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->SaveButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); - gtk_widget_show(window->MainWindow); + 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); + g_signal_connect(G_OBJECT(window->LogIntervalCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogIntervalAmountCheck); + g_signal_connect(G_OBJECT(window->LogIntervalAmountCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogIntervalAmountSpin); + + g_signal_connect(G_OBJECT(window->LogSizeMaxCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogSizeMaxSpin); + g_signal_connect(G_OBJECT(window->LogSizeMaxCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogSizeMaxCombo); + + g_signal_connect(G_OBJECT(window->RotationSizeMaxCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotationSizeMaxSpin); + g_signal_connect(G_OBJECT(window->RotationSizeMaxCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotationSizeMaxCombo); + + g_signal_connect(G_OBJECT(window->LogFreeSpaceCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogFreeSpaceSpin); + g_signal_connect(G_OBJECT(window->LogFreeSpaceCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogFreeSpaceCombo); + + g_signal_connect(G_OBJECT(window->RedirectCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box_inversed),window->RedirectTTYEntry); + int size=0; + config_str settings = yon_config_get_all_by_key("JOURNALD",&size); + for (int i=0;iLogStorageCombo),1); + else if (!strcmp(settings[i],"persistent")) gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogStorageCombo),2); + else if (!strcmp(settings[i],"auto")) gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogStorageCombo),3); + else if (!strcmp(settings[i],"none")) gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogStorageCombo),4); + + }else if (!strcmp(JOURNALD("Compress"),name)){ + if (!strcmp(settings[i],"yes")) gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogCompressionCombo),1); + else if (!strcmp(settings[i],"no")) gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogCompressionCombo),2); + else { + gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogCompressionCombo),3); + char last = settings[i][strlen(settings[i])-1]; + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->LogCompressionEntry),atoi(settings[i])); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogCompressionSizeCombo),yon_size_get_int_from_letter(last)); + } + + }else if (!strcmp(JOURNALD("SplitMode"),name)){ + if (!strcmp(settings[i],"uid")) gtk_combo_box_set_active(GTK_COMBO_BOX(window->DivideJournalFilesCombo),1); + else if (!strcmp(settings[i],"none")) gtk_combo_box_set_active(GTK_COMBO_BOX(window->DivideJournalFilesCombo),2); + }else if (!strcmp(JOURNALD("RateLimitIntervalSec"),name)){ + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->LogIntervalSpin),atol(settings[i])); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->LogIntervalCheck),1); + }else if (!strcmp(JOURNALD("RateLimitBurst"),name)){ + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->LogIntervalAmountSpin),atol(settings[i])); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->LogIntervalAmountCheck),1); + }else if (!strcmp(JOURNALD("SystemMaxUse"),name)){ + char last = settings[i][strlen(settings[i])-1]; + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->LogSizeMaxSpin),atol(settings[i])); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogSizeMaxCombo),yon_size_get_int_from_letter(last)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->LogSizeMaxCheck),1); + }else if (!strcmp(JOURNALD("SystemKeepFree"),name)){ + char last = settings[i][strlen(settings[i])-1]; + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->LogFreeSpaceSpin),atol(settings[i])); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogFreeSpaceCombo),yon_size_get_int_from_letter(last)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->LogFreeSpaceCheck),1); + }else if (!strcmp(JOURNALD("SystemMaxFileSize"),name)){ + char last = settings[i][strlen(settings[i])-1]; + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->RotationSizeMaxSpin),atol(settings[i])); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationSizeMaxCombo),yon_size_get_int_from_letter(last)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotationSizeMaxCheck),1); + }else if (!strcmp(JOURNALD("ForwardToConsole"),name)){ + if (!strcmp(settings[i],"yes")) gtk_combo_box_set_active(GTK_COMBO_BOX(window->RedirectCombo),1); + else if (!strcmp(settings[i],"no")) gtk_combo_box_set_active(GTK_COMBO_BOX(window->RedirectCombo),2); + }else if (!strcmp(JOURNALD("TTYPath"),name)){ + gtk_entry_set_text(GTK_ENTRY(window->RedirectTTYEntry), settings[i]); + }else if (!strcmp(JOURNALD("MaxLevelConsole"),name)){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->ForwardedTypeCombo),atoi(settings[i])+1); + } + } + + g_signal_connect(G_OBJECT(window->LogCompressionCombo),"changed",G_CALLBACK(yon_combo_compress_check),window); + return window; } -void on_serivces_open(GtkWidget *self,main_window *widgets){ - GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); +void on_journald_open(GtkWidget *self, main_window *widgets){ + journald_window *window = yon_journald_open(self,widgets); GtkTreeIter iter; - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model, &iter)){ - char *service_name; - gtk_tree_model_get(model,&iter,1,&service_name,-1); - if (!strcmp(service_name,"journald")){ - on_journald_open(NULL,widgets); - } else { - on_logrotate_tab_open(NULL,widgets); - } + GtkTreeModel *model; + GtkWidget *tree_view; + char *name, *description; + int name_col, desc_col; + if (self == widgets->ServicesEditButton){ + model = GTK_TREE_MODEL(widgets->ServicesList); + tree_view = widgets->ServicesTree; + name_col = 2; + desc_col = 3; + } else { + model = GTK_TREE_MODEL(widgets->list); + tree_view = widgets->MainTree; + name_col = 0; + desc_col = 2; } + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view)),&model,&iter)){ + gtk_tree_model_get(model,&iter,name_col,&name,desc_col,&description,-1); + gtk_entry_set_text(GTK_ENTRY(window->LogDescriptionLabel),description); + gtk_entry_set_text(GTK_ENTRY(window->LogNameLabel),name); + } + int jsize; + config_str journald_parameters = yon_config_get_all_by_key("JOURNALD[",&jsize); + gtk_widget_show(window->MainWindow); +} + +// Log adding menu +add_log_window *on_add_open(){ + add_log_window *window = malloc(sizeof(add_log_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_add_path); + 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->LogAddingBox=yon_gtk_builder_get_widget(builder,"LogAddingBox"); + window->LogTypeCombo=yon_gtk_builder_get_widget(builder,"LogTypeCombo"); + window->LogPathEntry=yon_gtk_builder_get_widget(builder,"LogPathEntry"); + window->LogFindButton=yon_gtk_builder_get_widget(builder,"LogFindButton"); + window->LogDescriptionEntry=yon_gtk_builder_get_widget(builder,"LogDescriptionEntry"); + window->LogrotateButton=yon_gtk_builder_get_widget(builder,"LogrotateButton"); + window->MetalogButton=yon_gtk_builder_get_widget(builder,"MetalogButton"); + window->SyslogButton=yon_gtk_builder_get_widget(builder,"SyslogButton"); + window->JournaldButton=yon_gtk_builder_get_widget(builder,"JournaldButton"); + window->LogSizeLabel=yon_gtk_builder_get_widget(builder,"LogSizeLabel"); + window->StatisticsFrame=yon_gtk_builder_get_widget(builder,"StatisticsFrame"); + window->ControlSectionBox=yon_gtk_builder_get_widget(builder,"ControlSectionBox"); + window->LogPathsBox=yon_gtk_builder_get_widget(builder,"LogPathsBox"); + 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->SaveButton),"clicked", G_CALLBACK(on_close_subwindow),NULL); + return window; } void on_log_add(GtkWidget *self, main_window *widgets){ @@ -412,8 +1282,62 @@ void on_log_add(GtkWidget *self, main_window *widgets){ add_log_window *window = on_add_open(); gtk_widget_show(window->MainWindow); gtk_widget_hide(window->StatisticsFrame); - gtk_widget_hide(window->JournaldButton); - g_signal_connect(G_OBJECT(window->SaveButton),"clicked", G_CALLBACK(on_close_subwindow),NULL); + gtk_widget_hide(window->ControlSectionBox); +} + +void on_log_path_choose(GtkWidget *self,add_log_window *window){ + GtkWidget *dialog = gtk_file_chooser_dialog_new(TITLE_LABEL,GTK_WINDOW(window->MainWindow),GTK_FILE_CHOOSER_ACTION_OPEN,CANCEL_LABEL,GTK_RESPONSE_CANCEL,ACCEPT_LABEL,GTK_RESPONSE_ACCEPT,NULL); + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),"/"); + int response = gtk_dialog_run(GTK_DIALOG(dialog)); + if (response == GTK_RESPONSE_ACCEPT){ + GtkWidget *parent = gtk_widget_get_parent(self); + GList *list = gtk_container_get_children(GTK_CONTAINER(parent)); + gtk_entry_set_text((GtkEntry*)g_list_nth_data(list,1),gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog))); + } + gtk_widget_destroy(dialog); +} + +void on_log_path_remove(GtkWidget *self, add_log_window *window){ + GList *paths = gtk_container_get_children(GTK_CONTAINER(window->LogPathsBox)); + for (int i=0;i1&>k_widget_get_sensitive(g_list_nth_data(list,3))){ + GtkWidget *prevbox = (GtkWidget*)g_list_nth_data(paths,i-1); + GList *prevlist = gtk_container_get_children(GTK_CONTAINER(prevbox)); + gtk_widget_show(g_list_nth_data(prevlist,3)); + g_list_free(prevlist); + gtk_widget_destroy(box); + } + } + g_list_free(list); + } + g_list_free(paths); +} + +void on_log_path_append(GtkWidget *self, add_log_window *window){ + GList *paths = gtk_container_get_children(GTK_CONTAINER(window->LogPathsBox)); + GtkWidget *box = (GtkWidget*)g_list_nth_data(paths,g_list_length(paths)-1); + GList *path_widgets = gtk_container_get_children(GTK_CONTAINER(box)); + GtkWidget *entry = (GtkWidget*)g_list_nth_data(path_widgets,1); + if (gtk_widget_get_sensitive(box)&&strcmp(gtk_entry_get_text(GTK_ENTRY(entry)),"")){ + GtkBuilder *builder = gtk_builder_new_from_resource(glade_add_path_path); + GtkWidget *box = yon_gtk_builder_get_widget(builder,"PathBox"); + GtkWidget *entry = yon_gtk_builder_get_widget(builder,"PathEntry"); + GtkWidget *AppendButton = yon_gtk_builder_get_widget(builder,"AppendButton"); + GtkWidget *SearchButton = yon_gtk_builder_get_widget(builder,"SearchButton"); + GtkWidget *RemoveButton = yon_gtk_builder_get_widget(builder,"RemoveButton"); + g_signal_connect(G_OBJECT(AppendButton),"clicked",G_CALLBACK(on_log_path_append),window); + 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); + gtk_widget_show(AppendButton); + gtk_widget_hide(self); + gtk_box_pack_start(GTK_BOX(window->LogPathsBox),box,0,0,5); + } + g_list_free(paths); + g_list_free(path_widgets); } void on_log_edit(GtkWidget *self,main_window *widgets){ @@ -424,7 +1348,10 @@ void on_log_edit(GtkWidget *self,main_window *widgets){ gtk_widget_show(window->MainWindow); gtk_widget_hide(window->StatisticsFrame); char *name; - gtk_tree_model_get(model,&iter,0,&name,-1); + char *paths; + int size; + char *description; + gtk_tree_model_get(model,&iter,0,&name,1,&paths,2,&description,-1); if (!strcmp(name,"journald")){ gtk_widget_hide(window->LogrotateButton); gtk_widget_hide(window->MetalogButton); @@ -432,12 +1359,34 @@ void on_log_edit(GtkWidget *self,main_window *widgets){ g_signal_connect(G_OBJECT(window->JournaldButton),"clicked", G_CALLBACK(on_journald_open),widgets); } else { gtk_widget_hide(window->JournaldButton); - // g_signal_connect(G_OBJECT(window->JournaldButton),"clicked", G_CALLBACK(on_journald_open),widgets); - // g_signal_connect(G_OBJECT(window->JournaldButton),"clicked", G_CALLBACK(on_log),widgets); - // g_signal_connect(G_OBJECT(window->JournaldButton),"clicked", G_CALLBACK(on_journald_open),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->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); } - gtk_widget_set_sensitive(window->LogAddingBox,0); - g_signal_connect(G_OBJECT(window->SaveButton),"clicked", G_CALLBACK(on_close_subwindow),NULL); + window->log_name=name; + gtk_entry_set_text(GTK_ENTRY(window->LogDescriptionEntry),description); + config_str paths_parsed = yon_char_parse(paths,&size,"\n"); + GtkWidget *last=NULL; + for (int i=0;iLogPathsBox),box,0,0,5); + last = AppendButton; + } + gtk_widget_show(last); + g_signal_connect(G_OBJECT(last),"clicked",G_CALLBACK(on_log_path_append),window); + gtk_widget_set_sensitive(window->LogTypeCombo,0); + gtk_widget_set_sensitive(window->LogDescriptionEntry,0); } } @@ -449,14 +1398,17 @@ void on_log_remove(GtkWidget *self, main_window *widgets){ } } +// Main window + + void on_service_edit(GtkWidget *self,main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->ServicesList); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->ServicesTree)),&model,&iter)){ char *name; - gtk_tree_model_get(model,&iter,1,&name,-1); + gtk_tree_model_get(model,&iter,2,&name,-1); if (!strcmp(name,"journald")){ - on_journald_open(NULL,widgets); + on_journald_open(self,widgets); } else { on_logrotate_tab_open(NULL,widgets); } @@ -555,19 +1507,20 @@ main_window *setup_window(){ int log_size; journals[i]=yon_char_divide_search(journals[i],"\n",-1); 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); gtk_list_store_set(widgets->list,&iter,0,log[0],1,log[1],2,log[2],3,-1,4,-1,5,-1,6,-1,7,-1,-1); } config_str services = yon_file_open(services_list_path,&service_size); for (int i=0;iServicesList,&iter); - gtk_list_store_set(widgets->ServicesList,&iter,0,0,1,log[0],2,log[1],-1); - // yon_char_parsed_free(log,log_size); + if (services[i][0]!='#'){ + int log_size; + 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); + gtk_list_store_set(widgets->ServicesList,&iter,0,1,1,1,2,log[0],3,log[1],-1); + } } - // yon_char_parsed_free(services,service_size); config_str dirs = yon_config_load(logrotate_config_command,&dirs_size); for (int i=0;iConfigureButton),"clicked",G_CALLBACK(on_log_edit),widgets); g_signal_connect(G_OBJECT(widgets->RemoveButton),"clicked",G_CALLBACK(on_log_remove),widgets); g_signal_connect(G_OBJECT(widgets->ServicesEditButton),"clicked",G_CALLBACK(on_service_edit),widgets); + + g_signal_connect(G_OBJECT(widgets->SaveMenuItem),"activate",G_CALLBACK(on_save_global_local),NULL); + g_signal_connect(G_OBJECT(widgets->SaveGlobalMenuItem),"activate",G_CALLBACK(on_save_global),NULL); + g_signal_connect(G_OBJECT(widgets->SaveLocalMenuItem),"activate",G_CALLBACK(on_save_local),NULL); + + 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); gtk_widget_show(widgets->Window); @@ -705,10 +1666,13 @@ int main(int argc, char *argv[]){ if (getuid()!=0) yon_ubl_status_box_render(ROOT_WARNING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); else - yon_ubl_status_box_render(TITLE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); yon_ubl_setup_sockets(widgets->PlugBox,widgets->LeftBox,widgets->RightBox,main_config.socket_id,main_config.load_socket_id,main_config.save_socket_id); yon_window_config_setup(GTK_WINDOW(widgets->Window)); + yon_load_proceed(YON_CONFIG_LOCAL); yon_window_config_load(config_path); + yon_load_proceed(YON_CONFIG_LOCAL); + update_loaded_logrotate(); GtkCssProvider *css=gtk_css_provider_new(); gtk_css_provider_load_from_resource(css,CssPath); gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), diff --git a/source/ubl-settings-logging.h b/source/ubl-settings-logging.h index 68bfa6a..b560b95 100644 --- a/source/ubl-settings-logging.h +++ b/source/ubl-settings-logging.h @@ -20,6 +20,7 @@ #define glade_path "/com/ublinux/ui/ubl-settings-logging.glade" #define glade_add_path "/com/ublinux/ui/ubl-settings-logging-add.glade" +#define glade_add_path_path "/com/ublinux/ui/ubl-settings-logging-add-path.glade" #define glade_inspector_path "/com/ublinux/ui/ubl-settings-logging-inspector.glade" #define glade_journald_path "/com/ublinux/ui/ubl-settings-logging-journald.glade" #define glade_logrotate_path "/com/ublinux/ui/ubl-settings-logging-logrotate.glade" @@ -35,12 +36,16 @@ #define LocalePath "/usr/share/locale" #define LocaleName "ubl-settings-logging" +#define JOURNALD(key) yon_char_unite("JOURNALD[",key,"]",NULL) +#define LOGROTATE(key) yon_char_unite("LOGROTATE[",key,"]",NULL) #define get_journal_output_command "journalctl --no-pager" #define get_journal_output_since_boot_command "journalctl --no-pager -b" #define get_journal_output_followed_command "journalctl --no-pager -f" #define get_journal_output_kernel_command "journalctl --no-pager -k" #define get_journal_output_prioritied_command "journalctl --no-pager -p err..alert" + +#define yon_add_space_if_exists(string) yon_char_is_empty(string) ? "" : yon_char_append(",",string) typedef char* string; string version_application; @@ -62,6 +67,8 @@ typedef struct { int lock_save_global; int lock_load_global; + int load_mode; + GtkListStore *logrotate_list; GtkListStore *logrotate_apps_list; } config; @@ -102,6 +109,7 @@ typedef struct { GtkWidget *AddButton; GtkWidget *RemoveButton; + GtkWidget *Notebook; GtkWidget *ServicesTree; GtkWidget *ServicesEditButton; @@ -161,6 +169,10 @@ typedef struct { GtkWidget *JournaldButton; GtkWidget *LogSizeLabel; GtkWidget *StatisticsFrame; + GtkWidget *ControlSectionBox; + GtkWidget *LogPathsBox; + + char *log_name; } add_log_window; typedef struct { @@ -175,6 +187,8 @@ GtkWidget *UpdateButton; GtkWidget *LoggingTextView; GtkWidget *JournalActionsBox; int last_mode; +char *journal_name; +char *journal_paths; } inspector_window; @@ -241,9 +255,12 @@ typedef struct { GtkWidget *MainWindow; GtkWidget *CancelButton; GtkWidget *SaveButton; - GtkWidget *LogNamelabel; - GtkWidget *LogNameButton; - GtkWidget *LogNameDescriptionLabel; + GtkWidget *LogNameEntry; + GtkWidget *LogDescriptionEntry; + GtkWidget *LogPathsTree; + GtkWidget *LogPathEditButton; + GtkWidget *LogPathAddButton; + GtkWidget *LogPathRemoveButton; GtkWidget *RotationPeriodCheck; GtkWidget *RotationPeriodMainCombo; GtkWidget *RotationPeriodAdditionalCombo; @@ -289,6 +306,13 @@ typedef struct { GtkWidget *LogSizeLabel; GtkWidget *headerTopic; GtkListStore *list; + GtkCellRenderer *PathCell; + GtkWidget *SharedScenariosCheck; + GtkWidget *CommandBeforeOnceEntry; + GtkWidget *CommandAfterOnceEntry; + GtkWidget *CommandBeforeEntry; + GtkWidget *CommandAfterEntry; + GtkWidget *EndworkCommandEntry; } logrotate_configure_window; main_window *setup_window(); \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 58c1749..4c834c2 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -12,7 +12,7 @@ #define SAVE_LOCAL_LABEL _("Save to local configuration") #define SAVE_GLOBAL_LABEL _("Save to global configuration") -#define SAVE_CONFIGURATION_LABEL _("Save configuration") +#define SAVE_CONFIGURATION_LABEL _("Save to global and local configuration") #define SAVE_LABEL _("Save") #define LOAD_LOCAL_LABEL _("Load local configuration") @@ -36,4 +36,148 @@ #define GLOBAL_LOCAL_SAVE_SUCCESS_LABEL _("Local and global configuration saving succseeded.") #define GLOBAL_SAVE_SUCCESS_LABEL _("Global configuration saving succseeded.") #define LOCAL_SAVE_SUCCESS_LABEL _("Local configuration saving succseeded.") -#define ACCEPT_LABEL _("Accept") \ No newline at end of file +#define ACCEPT_LABEL _("Accept") +//ubl-settings-logging.glade +#define JOURNALS_LABEL _("Journals") +#define SERVICES_LABEL _("Services") +#define LOG_JOURNAL_TAB_LABEL _("Log/Journal") +#define PATH_LABEL _("Path") +#define DESCRIPTION_LABEL _("Description") +#define INSPECT_LABEL _("Inspect log") +#define CONFIGURE_LOG_LABEL _("Configure log") +#define ADD_LOG_LABEL _("Add log") +#define REMOVE_LOG_LABEL _("Remove log") +#define STOP_SERVICE_LABEL _("Stop service") +#define START_SERVICE_LABEL _("Start service") +#define CONFIGURE_SERVICE_LABEL _("Configure service") +#define STATUS_LABEL _("Status") +#define SERVICE_LABEL _("Service") +#define AUTOSTART_LABEL _("Autostart") + +//ubl-settings-logging-inspector.glade +#define TOOLTIP_BOOT_LABEL _("Show messages since the current system boot") +#define TOOLTIP_FOLLOW_LABEL _("Follow for new messages") +#define TOOLTIP_KERNEL_LABEL _("Show kernel ring buffer") +#define TOOLTIP_PRIORITY_LABEL _("Show only priority error messages, critical messages and warnings") +// #define LABEL _("Cancel") +// #define LABEL _("Cancel") +// #define LABEL _("Cancel") +#define UPDATE_LABEL _("Update") + +//ubl-settings-logging-journald.glade +#define JOURNAL_DESCRIPTION_LABEL _("Description:") +#define JOURNAL_STORAGE_LABEL _("Journal storage place:") +#define COMPRESSION_LABEL _("Use compression:") +#define COMPRESSION_LABEL _("Use compression:") +#define DIVIDE_LABEL _("Split journal files:") +#define INTERVAL_LABEL _("Log recording journal interval:") +#define RECORDS_COUNT_LABEL _("Records amount:") +#define MAX_SIZE_LABEL _("Maximum size of all logs:") +#define MAX_ROTATION_SIZE_LABEL _("Maximum size of rotation journal:") +#define FREE_SPACE_LABEL _("Leave free space at storage:") +#define REDIRECT_LABEL _("Redirect to console:") +#define TTY_LABEL _("TTY:") +#define MESSAGES_TYPE_LABEL _("Type of forwarded messages:") +#define COURNAL_CONFIGURATION_LABEL _("Journal configuration") +#define TOTAL_SIZE_LABEL _("Total log size:") +#define LOWER_SIZE_LABEL _("Lower size to:") +#define APPLY_LABEL _("Apply") +#define STATISTICS_LABEL _("Statistics") +#define DEFAULT_LABEL _("Default") +#define RAM_LABEL _("RAM") +#define DRIVE_LABEL _("Drive") +#define AUTO_LABEL _("Auto") +#define NONE_LABEL _("None") +#define YES_LABEL _("Yes") +#define NO_LABEL _("No") +#define AFTER_LABEL _("After") +#define KB_LABEL _("Kb") +#define MB_LABEL _("Mb") +#define GB_LABEL _("Gb") +#define MINUTES_LABEL _("Minutes") +#define HOURS_LABEL _("Hours") +#define DAYS_LABEL _("Days") +#define WEEKS_LABEL _("Weeks") +#define YEARS_LABEL _("Years") + +//ubl-settings-logging-logrotate.glade +#define LOGROTATE_LOG_JOURNAL_TAB_LABEL _("Log/Journal:") +#define PATHS_LABEL _("Paths to log and journals files") +#define ON_LABEL _("On") +#define OFF_LABEL _("Off") +#define SCENARIOS_LABEL _("Scenarios") +#define SCENARIO_RUN_LABEL _("Scenarios are running for each rotated journal") +#define COMMAND_SINGLE_BEFORE_LABEL _("Command before rotation (one time):") +#define COMMAND_SINGLE_AFTER_LABEL _("Command after rotation (one time):") +#define COMMAND_BEFORE_LABEL _("Command before rotation:") +#define COMMAND_AFTER_LABEL _("Command after rotation:") +#define ROTATION_LABEL _("Rotation period:") +#define FILE_SIZE_LABEL _("Maximum size of file:") +#define FREQUENCY_LABEL _("Checking frequency configuration") +#define FILE_AMOUNT_LABEL _("File amount:") +#define STORE_LABEL _("Store at:") +#define ROTATION_USER_LABEL _("Rotation as user:") +#define ROTATION_GROUP_LABEL _("Rotation as group:") +#define ROTATION_CONFIGURATION_LABEL _("Rotation configuration") +#define ERROR_LABEL _("Error processing:") +#define ROTATION_EMPTY_LABEL _("Rotation of jurnal even when it is empty:") +#define DONT_ROTATE_YOUNGER_LABEL _("Do not rotate journal younger than") +#define DAYS_text_LABEL _("days") +#define DELETE_ROTATED_LABEL _("Delete rotated journals older than") +#define ROTATE_SIZE_LABEL _("Rotate journals if size more than") +#define ROTATE_TIME_LABEL _("but not earlier than the specified time interval") +#define ROTATE_BEFORE_LABEL _("before specified time interval") +#define FILE_CHOOSE_LABEL _("File choosing configuration") +#define CREATE_LOG_LABEL _("Create log") +#define AS_USER_LABEL _("as user:") +#define AS_GROUP_LABEL _("as group:") +#define RULES_LABEL _("rules:") +#define CUT_SOURCE_LABEL _("Cut source journal fileafter copy creating instead of moving old journal file and creating new one") +#define FILES_DIRS_CONFIGURATION_LABEL _("Files and directories configuration") +#define DELAY_LABEL _("Delay compression by one journal in queue:") +#define COMPRESSION_CONFIGURATION_LABEL _("Compression configuration") +#define SAVE_ORIGINAL_LABEL _("Save original log file after rotation if it has specified extension:") +#define ADD_DATE_LABEL _("Add date of rotation before log header") +#define START_NUMBER_LABEL _("Number from which numbering of old logs will begin") +#define FILENAME_CONFIGURATION_LABEL _("Filename configuration") +#define EMAIL_AT_ROTATION_LABEL _("Email after rotation:") +#define ADRESS_LABEL _("adress:") +#define CONTENTS_LABEL _("contents:") +#define MESSAGE_CONFIGURATION_LABEL _("Message configuration") +#define MANUAL_LABEL _("Manual input:") +#define LOG_SIZE_LABEL _("Log (-s) size:") +#define SAME_DIR_LABEL _("Same directory") +#define SEPARATE_DIR_LABEL _("Separate directory") +#define OUTPUT_ERRORS_LABEL _("Output errors if log file does not exist*") +#define NO_OUTPUT_ERRORS_LABEL _("Do not output errors if log file does not exist") +#define NO_OUTPUT_LABEL _("Do not output") +#define OURPUT_LABEL _("Output errors") +#define SEND_EMAIL_LABEL _("Send Email") +#define NO_SEND_EMAIL_LABEL _("Don't send Email") +#define FIRST_ROTATED_LABEL _("First rotated copy") +#define LAST_ROTATED_LABEL _("Last rotated copy") +#define MESSAGE_CONFIGURATION_LABEL _("Message configuration") +#define ENDWORK_LABEL _("Endwork command:") +#define SCENARIOS_ROTATE_LABEL _("Scenarios are running for each rotated journal") +#define SCENARIOS_LABEL _("Scenarios") +#define HOURLY_LABEL _("Hourly") +#define DAILY_LABEL _("Daily") +#define WEEKLY_LABEL _("Weekly*") +#define MONTHLY_LABEL _("Monthly") +#define YEARLY_LABEL _("Yearly") +#define MONDAY_LABEL _("Monday") +#define TUESDAY_LABEL _("Tuesday") +#define WEDNESDAY_LABEL _("Wednesday") +#define THURSDAY_LABEL _("Thursday") +#define FRIDAY_LABEL _("Friday") +#define SATURDAY_LABEL _("Saturday") +#define SUNDAY_LABEL _("Sunday*") + +//ubl-settings-logging-logrotate-table.glade +#define SYSTEM_CONFIGURATION_LABEL _("System configuration") +#define APPLITATIONS_CONFIGURATION_LABEL _("Applications configuration") + +//ubl-settings-logging-add.glade +#define ADD_PATHS_LABEL _("Path (-s):") +#define CONTROL_LABEL _("Control:") +#define LOG_LABEL _("Log file") \ No newline at end of file diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 8cc0436..29373da 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -455,9 +455,9 @@ char *yon_char_append(char *source, char *append) int size = strlen(source) + strlen(append) + 1; char *final = malloc(size); memset(final, 0, size); - if (strstr(source, "%%")) - sprintf(final, source, append); - else + // if (strstr(source, "%%")) + // sprintf(final, source, append); + // else sprintf(final, "%s%s", source, append); return final; } @@ -607,6 +607,26 @@ char *yon_char_from_int(int int_to_convert) return ch; } +/**yon_char_from_long(int int_to_convert) + * [EN] + * converts int to char*. + * + * [RU] + * Конвертирует int в char* + */ +char *yon_char_from_long(long int_to_convert) +{ + int i = 1; + double convert_check = (double)int_to_convert; + for (i = 1; convert_check >= 10; i++) + { + convert_check = convert_check / 10; + } + char *ch = g_malloc0(i * sizeof(char) + 1); + sprintf(ch, "%ld", int_to_convert); + return ch; +} + /**yon_char_replace(char *source, char *find, char*replace) * [EN] * @@ -621,11 +641,11 @@ char *yon_char_replace(char *source, char *find, char*replace){ char *temp=NULL; if(!strstr(replace,find)){ while ((final=strstr(source,find))){ - temp=malloc(strlen(source)-strlen(final)); + temp=malloc(strlen(source)-strlen(final)+strlen(replace)); memset(temp,0,strlen(source)-strlen(final)+strlen(replace)); memcpy(temp,source,strlen(source)-strlen(final)); temp=yon_char_append(temp,replace); - source=yon_char_append(temp,final+1); + source=yon_char_append(temp,final+strlen(find)); } } @@ -646,14 +666,14 @@ char **yon_char_parse(char *parameters, int *size, char *divider){ char *paramline=yon_char_new(parameters); char *param; while ((param=yon_char_divide_search(paramline,divider,1))){ - if (strcmp(param,paramline)==0) break; 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++; + // string=realloc(string,sizeof(char*)*i); + // string[i-1]=yon_char_new(paramline); + // i++; // printf("%d\n",i); *size=i-1; return string; @@ -765,7 +785,7 @@ void yon_char_parsed_free(config_str source, int size){ * Копирует массив строк [to_copy] в [source] */ void yon_char_parsed_copy(config_str *source, config_str *to_copy){ - if (source&&!*source&&to_copy&&*to_copy){ + if (source&&!*source&&to_copy){ int size=0; config_str new_char = yon_char_parsed_new(&size,(*to_copy)[0]); for (int i=0;(*to_copy)[i];i++){ @@ -831,6 +851,20 @@ char *yon_ubl_user_get_home_directory(){ return ret; } +config_str yon_ubl_get_all_users(int *user_size){ + struct passwd *user = NULL; + config_str user_list = NULL; + while ((user = getpwent())) { + if (!user_list) + user_list = yon_char_parsed_new(user_size,user->pw_name,NULL); + else { + user_list = yon_char_parsed_append(user_list,user_size,user->pw_name); + } + } + endpwent(); + return user_list; +} + // parsing functions @@ -949,18 +983,6 @@ apps *yon_apps_get_by_name(apps *applist, char *name, int size) return NULL; }; -config_str yon_file_open(char *file_path, int *size){ - *size=0; - FILE *file = fopen(file_path,"r"); - if (file){ - char str_loaded[4098]; - config_str final_string = NULL; - while (fgets(str_loaded,4098,file)){ - final_string = final_string ? yon_char_parsed_append(final_string,size,str_loaded) : yon_char_parsed_new(size,str_loaded,NULL); - } - return final_string; - } -} /** * yon_dir_get_contents(char *dir_path, int *size) @@ -1096,26 +1118,6 @@ int yon_config_remove_by_key(char *key){ return 0; } -/**yon_config_remove_by_data(void *data) - * [EN] - * - * [RU] - * Производит поиск по конфигу на наличие параметра со значением [data] и удаляет найденное значение из конфига. -*/ -int yon_config_remove_by_data(void *data){ - check_config{ - dictionary *dict = NULL; - for_dictionaries(dict,(dictionary*)__yon__config__strings){ - if (dict->data==data){ - yon_dictionary_rip(dict); - return 1; - } - } - return 0; - } - return 0; -} - /**yon_config_remove_element(char *key, char *deleted) * [EN] * @@ -1161,6 +1163,21 @@ void *yon_config_get_by_key(char *key){ return NULL; } +void *yon_config_get_all_by_key(char *key, int *size){ + check_config{ + config_str ret_data=NULL; + dictionary *dict = NULL; + for_dictionaries(dict, (dictionary*)__yon__config__strings){ + if (strstr(dict->key,key)) { + 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); + } + } + return ret_data; + } +} + /**yon_config_get_key_by_data(char *data) * [EN] * @@ -1296,12 +1313,50 @@ 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); - 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)); + 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; 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); else yon_dictionary_add_or_create_if_exists_with_data(sections_remove,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " remove ", ((yon_config_parameter*)dct)->section, " ",dct->key,NULL)); + yon_dictionary_rip(dct); + } + } + } + if (sections_add) + for_dictionaries(dct,sections_add){ + char *command = yon_dictionary_get_data(dct,char*); + yon_launch(command); + } + if (sections_remove) + for_dictionaries(dct,sections_remove){ + char *command = yon_dictionary_get_data(dct,char*); + yon_launch(command); + } + return 1; + } else return 1; +} + +/**int yon_config_force_save_registered(char *path, char *section) + * [EN] + * Saves config with [command] + * [RU] + * Выполняет команду [command], добавляя в конец все записи конфига в таком виде: + * [ПАРАМЕТР1]="[значения1]" [ПАРАМЕТР2]="[значения2]" +*/ +int yon_config_force_save_registered(char *path){ + check_config{ + dictionary *dct; + dictionary *sections_add=NULL; + dictionary *sections_remove=NULL; + 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); + 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); + else yon_dictionary_add_or_create_if_exists_with_data(sections_remove,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " remove ", ((yon_config_parameter*)dct)->section, " ",dct->key,NULL)); } } } @@ -1317,24 +1372,6 @@ int yon_config_save_registered(char *path){ } - // char *command = yon_char_unite(ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " set ", section, " ", yon_dictionary_get_data(dct,char*),NULL); - // char *remove_command = yon_char_unite(ubconfig_save_command, path ? yon_char_append(" --target ",path):"", " remove "," ", yon_dictionary_get_data(dct,char*), section,NULL); - // dictionary *dict = NULL; - // int any_add = 0; - // int any_remove = 0; - // for_dictionaries(dict,(dictionary*)__yon__config__strings){ - // char *data = yon_dictionary_get_data(dict,char*); - // if (((yon_config_parameter*)dict)->flag1==1&&strcmp(data,"")!=0){ - // command = yon_char_unite(command, " ", dict->key,"=\"", yon_dictionary_get_data(dict,char*),"\"", NULL); - // any_add=1; - // } - // if (strcmp(data,"")==0){ - // remove_command = yon_char_unite(remove_command, " ", dict->key, NULL); - // any_remove=1; - // } - // } - // if (any_add) yon_launch(command); - // if (any_remove) yon_launch(remove_command); return 1; } else return 1; } @@ -1358,6 +1395,7 @@ config_str yon_config_get_all(int *size){ } conf = yon_remalloc(conf,sizeof(char*)*(*size)); conf[*size-1] = NULL; + (*size)=(*size)-1; return conf; } else return NULL; } @@ -1395,7 +1433,18 @@ char *yon_config_get_parameter(config_str parameters, int size, char *param) return NULL; } - +config_str yon_file_open(char *file_path, int *size){ + *size=0; + FILE *file = fopen(file_path,"r"); + if (file){ + char str_loaded[4098]; + config_str final_string = NULL; + while (fgets(str_loaded,4098,file)){ + final_string = final_string ? yon_char_parsed_append(final_string,size,str_loaded) : yon_char_parsed_new(size,str_loaded,NULL); + } + return final_string; + } +} // terminal-using functions @@ -1783,7 +1832,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end param->section=section; yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.deleted_parameters,param->parameter_name,param); } - + int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type){ GError *err=NULL; switch (type){ @@ -1825,7 +1874,7 @@ GtkWidget *yon_ubl_menu_item_about_new(char *buttonname){ GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname){ GtkWidget *menu_item = gtk_menu_item_new(); - gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitemtop"); + gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitemmiddle"); GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); GtkWidget *label = gtk_label_new(buttonname); GtkWidget *image = gtk_image_new_from_icon_name("dialog-question-symbolic",GTK_ICON_SIZE_BUTTON); @@ -1840,13 +1889,13 @@ GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname){ // other Gtk functions -/**yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size) +/**yon_gtk_combo_box_fill(GtkWidget *combo, config_str parameters,int size) * [EN] * * [RU] * Добавляет в Комбобокс [combo] все строки из массива строк [parameters] размера [size] */ -int yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size){ +int yon_gtk_combo_box_fill(GtkWidget *combo, config_str parameters,int size){ if (combo&¶meters){ for (int i=0;i=0 ? 1 : 0); + gtk_widget_set_sensitive(target,gtk_combo_box_get_active(toggle)>0 ? 1 : 0); } -void yon_gtk_widget_set_sensitive_from_toggle_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target){ - gtk_widget_set_sensitive(target,!gtk_combo_box_get_active(toggle)>=0 ? 0 : 1); +void yon_gtk_widget_set_sensitive_from_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target){ + gtk_widget_set_sensitive(target,!gtk_combo_box_get_active(toggle)>0 ? 0 : 1); } void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path) diff --git a/source/ubl-utils.h b/source/ubl-utils.h index db8ade7..0ed953b 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -123,6 +123,8 @@ void *yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(vo #define yon_char_divide_search_self(str,find,delete_divider) {char *temp = str; str = yon_char_divide_search(str,find,delete_divider); free(temp);} +#define yon_char_is_empty(string) !(string&&strcmp(string,"")) + int yon_char_find_last(char *source, char find); char *yon_char_append(char *source, char *append); @@ -139,6 +141,8 @@ char *yon_char_divide_search(char *source, char *dividepos, int delete_divider); char *yon_char_from_int(int int_to_convert); +char *yon_char_from_long(long int_to_convert); + char *yon_char_replace(char *source, char *find, char*replace); char **yon_char_parse(char *parameters, int *size, char *divider); @@ -165,6 +169,8 @@ char *yon_ubl_root_user_get(); char *yon_ubl_user_get_home_directory(); +config_str yon_ubl_get_all_users(int *user_size); + // parsing functions config_str philos_list_user(int* size); @@ -194,6 +200,8 @@ config_str yon_config_load(char *command, int *str_len); int yon_config_save_registered(char *path); +int yon_config_force_save_registered(char *path); + char *yon_config_get_parameter(config_str parameters, int size, char *param); int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *parameter, ...); @@ -206,6 +214,8 @@ int yon_config_remove_element(char *key, char *deleted); void *yon_config_get_by_key(char *key); +void *yon_config_get_all_by_key(char *key, int *size); + char *yon_config_get_key_by_data(char *data); int yon_config_set(char *key, void *data); diff --git a/ubl-settings-logging-add-path.glade b/ubl-settings-logging-add-path.glade new file mode 100644 index 0000000..b3f0a35 --- /dev/null +++ b/ubl-settings-logging-add-path.glade @@ -0,0 +1,96 @@ + + + + + + True + False + 5 + + + True + False + Path (-s): + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + True + True + True + image4 + + + + False + True + 2 + + + + + True + True + image3 + + + + False + True + 3 + + + + + True + True + True + image9 + + + + False + True + 4 + + + + + True + False + com.ublinux.ubl-settings-logging.increase-symbolic + + + True + False + com.ublinux.ubl-settings-logging.zoom-symbolic + + + True + False + com.ublinux.ubl-settings-logging.decrease-symbolic + + diff --git a/ubl-settings-logging-add.glade b/ubl-settings-logging-add.glade index dcba07a..f7d8eec 100644 --- a/ubl-settings-logging-add.glade +++ b/ubl-settings-logging-add.glade @@ -28,16 +28,6 @@ False emblem-ok-symbolic - - True - False - com.ublinux.ubl-settings-logging.increase-symbolic - - - True - False - com.ublinux.ubl-settings-logging.zoom-symbolic - True False @@ -135,6 +125,7 @@ True False Log/Journal: + 0 False @@ -166,85 +157,34 @@ - + True - False - 5 + True + never + in - + True False - Path (-s): - 0 + 5 + 5 + 5 + 5 + + + True + False + vertical + + + + + - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - - - True - True - True - image4 - - - - False - True - 2 - - - - - True - True - True - image3 - - - - False - True - 3 - - - - - True - True - True - image9 - - - - False - True - 4 - - False + True True 1 @@ -259,6 +199,7 @@ True False Description: + 0 False @@ -286,14 +227,14 @@ - False + True True 0 - False + True True 0 @@ -312,7 +253,7 @@ - + True False 5 @@ -321,6 +262,7 @@ True False Control: + 0 False @@ -409,7 +351,7 @@ True False - 0 + 0.019999999552965164 in @@ -429,6 +371,7 @@ True False Log size: + 0 False @@ -513,13 +456,7 @@ - - - True - False - com.ublinux.ubl-settings-logging.decrease-symbolic - diff --git a/ubl-settings-logging-journald.glade b/ubl-settings-logging-journald.glade index 28c9956..43c4722 100644 --- a/ubl-settings-logging-journald.glade +++ b/ubl-settings-logging-journald.glade @@ -9,6 +9,16 @@ 1 10 + + 100 + 1 + 10 + + + 100 + 1 + 10 + 1024 1 @@ -44,6 +54,11 @@ 1 10 + + 100 + 1 + 10 + True False @@ -128,16 +143,19 @@ True False + vertical + 5 True False 5 - + True False Log/Journal: + 0 False @@ -146,15 +164,15 @@ - + True - False - logname + True + journald - False + True True - 1 + 2 @@ -170,10 +188,11 @@ False 5 - + True False Description: + 0 False @@ -182,15 +201,15 @@ - + True - False - logdescription + False + True - False + True True - 1 + 2 @@ -212,7 +231,7 @@ True False - 0 + 0.019999999552965164 in @@ -251,6 +270,10 @@ 0 Default + RAM + Drive + Auto + None @@ -290,6 +313,9 @@ 0 Default + Yes + No + After @@ -299,9 +325,11 @@ - + True + False True + adjustment11 False @@ -312,13 +340,13 @@ True + False False 0 Kb Mb Gb - Tb @@ -343,7 +371,7 @@ True False - Divide journal files: + Split journal files: False @@ -358,6 +386,8 @@ 0 Default + UID + No @@ -395,6 +425,7 @@ True + False True adjustment4 @@ -408,6 +439,7 @@ Records amount: True + False True False True @@ -421,6 +453,7 @@ True + False True adjustment5 @@ -459,6 +492,7 @@ True + False True adjustment6 @@ -471,13 +505,13 @@ True + False False 0 Kb Mb Gb - Tb @@ -515,6 +549,7 @@ True + False True adjustment7 @@ -527,12 +562,13 @@ True + False False + 0 Kb Mb Gb - Tb @@ -555,7 +591,7 @@ 5 - Leave free space at storage: + Leave free space at storage: True True False @@ -570,6 +606,7 @@ True + False True adjustment8 @@ -582,12 +619,13 @@ True + False False + 0 Kb Mb Gb - Tb @@ -624,8 +662,11 @@ True False + 0 Default + Yes + No @@ -649,7 +690,9 @@ True + False True + alpha False @@ -685,8 +728,17 @@ True False + 0 Default + emerg + alert + crit + err + warning + notice + info + debug @@ -724,7 +776,7 @@ True False - 0 + 0.019999999552965164 in @@ -793,9 +845,10 @@ - + True True + adjustment9 False @@ -807,11 +860,11 @@ True False + 0 Kb Mb Gb - Tb @@ -859,9 +912,10 @@ - + True True + adjustment10 False @@ -873,12 +927,13 @@ True False + 0 Minutes Hours Days Weeks - Months + Years @@ -975,4 +1030,10 @@ + + + + + + diff --git a/ubl-settings-logging-logrotate-table.glade b/ubl-settings-logging-logrotate-table.glade index 5eeb2c1..7177eaa 100644 --- a/ubl-settings-logging-logrotate-table.glade +++ b/ubl-settings-logging-logrotate-table.glade @@ -195,6 +195,9 @@ Log/Journal + + 0 + @@ -203,6 +206,9 @@ Path + + 1 + @@ -211,6 +217,9 @@ Description + + 2 + diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index ce37634..637791d 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -3,12 +3,16 @@ - 1024 1 10 + + 100 + 1 + 10 + 1024 1 @@ -62,7 +66,7 @@ True False - document-edit-symbolic + com.ublinux.ubl-settings-logging.edit-symbolic True @@ -74,6 +78,22 @@ False com.ublinux.ubl-settings-logging.profile-symbolic + + True + False + com.ublinux.ubl-settings-logging.decrease-symbolic + + + True + False + com.ublinux.ubl-settings-logging.increase-symbolic + + + + + + + 800 600 @@ -160,10 +180,11 @@ False 5 - + True False Log/Journal: + 0 False @@ -172,28 +193,15 @@ - - True - False - Logname - - - False - True - 1 - - - - + True + False True - True - image3 - False + True True - 2 + 1 @@ -209,10 +217,11 @@ False 5 - + True False Description: + 0 False @@ -221,13 +230,13 @@ - + True - False - logdescription + False + True - False + True True 1 @@ -239,1342 +248,1758 @@ 1 - - - False - True - 0 - - - - - True - False - 0 - in - + True False - 5 - 5 - 5 + 0.019999999552965164 + in - + True False - vertical - 5 + 5 + 5 + 5 - + True False - 0 - in + 5 - + True False - 5 - 5 - 5 + vertical + 5 - + True - False - vertical - 5 - - - True - False - 5 - - - Rotation period: - True - True - False - True - - - False - True - 0 - - - - - True - False - - Week - Month - Year - - - - False - True - 1 - - - - - True - False - - - False - True - 2 - - - - - False - True - 0 - + True + True + image3 + + + + False + True + 0 + + + + + True + True + True + image7 + + + + False + True + 1 + + + + + True + True + True + image6 + + + + False + True + 2 + + + + + False + True + 0 + + + + + True + True + in + + + True + True + liststore1 + False + + - - True - False - 5 - - - Maximum size of file: - True - True - False - True - - - False - True - 0 - - - - - True - True - adjustment4 - - - False - True - 1 - - + + Path - - True - False - - Kb - Mb - Gb - Tb - - - - False - True - 2 - + + + 0 + - - False - True - 1 - - - - - True - False - Checking frequency configuration - + + True + True + 1 + - - False - True - 0 - + + + + + True + False + Paths to log and journals files + + + + + False + True + 2 + + + + + False + True + 0 + + + + + True + False + vertical + 5 + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 - + True False - 0 - in + vertical + 5 - + True False - 5 - 5 - 5 + 5 + + + Rotation period: + True + True + False + True + + + False + True + 0 + + - + True + False False - vertical - 5 - - - True - False - 5 - - - File amount: - True - True - False - True - - - False - True - 0 - - - - - True - True - adjustment6 - - - False - True - 1 - - - - - True - False - Store at: - - - False - True - 2 - - - - - True - False - - Default - - - - False - True - 3 - - - - - True - True - - - False - True - 4 - - - - - True - True - True - image4 - - - False - True - 5 - - - - - False - True - 0 - - - - - True - False - 5 - - - True - False - Rotation as user: - - - False - True - 0 - - - - - True - False - - - False - True - 1 - - - - - True - False - Rotation as group: - - - False - True - 2 - - - - - True - False - - - False - True - 3 - - - - - False - True - 1 - - + 0 + + Hourly + Daily + Weekly* + Monthly + Yearly + + + + False + True + 1 + + + + + True + False + False + 0 + + Monday + Tuesday + Wednesday + Thursday + Friday + Saturday + Sunday* + + + False + True + 2 + + + False + True + 0 + - - + + True False - Rotation configuration + 5 + + + Maximum size of file: + True + True + False + True + + + False + True + 0 + + + + + True + False + True + adjustment4 + + + False + True + 1 + + + + + True + False + False + 0 + + Kb + Mb + Gb + + + + False + True + 2 + + + + False + True + 1 + - - False - True - 1 - + + + + + True + False + Checking frequency configuration + + + + + False + True + 0 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 - + True False - 0 - in + vertical + 5 - + True False - 5 - 5 - 5 + 5 + + + File amount: + True + True + False + True + + + False + True + 0 + + + + + True + False + True + adjustment6 + + + False + True + 1 + + - + True False - vertical - 5 - - - True - False - 5 - - - True - False - Error processing: - - - False - True - 0 - - - - - True - False - - Output errors if log file does not exist - - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - 5 - - - True - False - Rotation of jurnal even when it is empty: - - - False - True - 0 - - - - - True - False - - - False - True - 1 - - - - - False - True - 1 - - - - - True - False - 5 - - - Do not rotate journal younger than - True - True - False - True - - - False - True - 0 - - - - - True - True - adjustment7 - - - False - True - 1 - - - - - True - False - days - - - False - True - 2 - - - - - False - True - 2 - - - - - True - False - 5 - - - Delete rotated journals older than - True - True - False - True - - - False - True - 0 - - - - - True - True - adjustment5 - - - False - True - 1 - - - - - True - False - days - - - False - True - 2 - - - - - False - True - 3 - - - - - True - False - 5 - - - Rotate journals if size more than - True - True - False - True - - - False - True - 0 - - - - - True - True - adjustment8 - - - False - True - 1 - - - - - True - False - - Kb - Mb - Gb - - - - False - True - 2 - - - - - True - False - but not earlier than the specified time interval - - - False - True - 3 - - - - - False - True - 4 - - - - - True - False - 5 - - - Rotate journals if size more than - True - True - False - True - - - False - True - 0 - - - - - True - True - adjustment9 - - - False - True - 1 - - - - - True - False - - Kb - Mb - Gb - - - - False - True - 2 - - - - - True - False - before specified time interval - - - False - True - 3 - - - - - False - True - 5 - - + Store at: + + + False + True + 2 + + + + + True + False + False + 0 + + Default + Same directory + Separate directory + + + + False + True + 3 + + + + + True + False + True + + False + True + 4 + + + + + True + False + True + True + image4 + + + False + True + 5 + + + False + True + 0 + - - + + True False - File choosing configuration + 5 + + + True + False + Rotation as user: + + + False + True + 0 + + + + + True + False + 0 + + root* + + + + False + True + 1 + + + + + True + False + Rotation as group: + + + False + True + 2 + + + + + True + False + 0 + + root* + + + + False + True + 3 + + + + False + True + 1 + - - False - True - 2 - + + + + + True + False + Rotation configuration + + + + + False + True + 1 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 - + True False - 0 - in + vertical + 5 - + True False - 5 - 5 - 5 + 5 - + True False - vertical - 5 - - - True - False - 5 - - - True - False - Create log - - - False - True - 0 - - - - - True - False - - Default - - - - False - True - 1 - - - - - True - False - as user: - - - False - True - 2 - - - - - True - False - - Default - - - - False - True - 3 - - - - - True - False - as group: - - - False - True - 4 - - - - - True - False - - Default - - - - False - True - 5 - - - - - True - False - rules: - - - False - True - 6 - - - - - True - True - - - False - True - 7 - - - - - True - True - True - image5 - - - False - True - 8 - - - - - False - True - 0 - - - - - True - False - 5 - - - Cut source journal fileafter copy creating instead of moving old journal file and creating new one - True - True - False - True - - - False - True - 0 - - - - - False - True - 1 - - + Error processing: + + False + True + 0 + + + + + True + False + 0 + + Default + Output errors if log file does not exist* + Do not output errors if log file does not exist + + + + False + True + 1 + + + False + True + 0 + + + + + True + False + 5 + + + True + False + Rotation of jurnal even when it is empty: + + + False + True + 0 + + + + + True + False + 0 + + Default + On + Off + + + + False + True + 1 + + + + + False + True + 1 + + + + + True + False + 5 + + + Do not rotate journal younger than + True + True + False + True + + + False + True + 0 + + + + + True + False + True + adjustment7 + + + False + True + 1 + + + + + True + False + days + + + False + True + 2 + + + + + False + True + 2 + + + + + True + False + 5 + + + Delete rotated journals older than + True + True + False + True + + + False + True + 0 + + + + + True + False + True + adjustment5 + + + False + True + 1 + + + + + True + False + days + + + False + True + 2 + + + + + False + True + 3 + + + + + True + False + 5 + + + Rotate journals if size more than + True + True + False + True + + + False + True + 0 + + + + + True + False + True + adjustment8 + + + False + True + 1 + + + + + True + False + False + 0 + + Kb + Mb + Gb + + + + False + True + 2 + + + + + True + False + but not earlier than the specified time interval + True + + + False + True + 3 + + + + + False + True + 4 + - - + + True False - Files and directories configuration + 5 + + + Rotate journals if size more than + True + True + False + True + + + False + True + 0 + + + + + True + False + True + adjustment9 + + + False + True + 1 + + + + + True + False + False + 0 + + Kb + Mb + Gb + + + + False + True + 2 + + + + + True + False + before specified time interval + True + + + False + True + 3 + + + + False + True + 5 + + + + + + + + + True + False + File choosing configuration + + + + + False + True + 2 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + Create log + + + False + True + 0 + + + + + True + False + 0 + + Default + Do not output + Output errors + Off + + + + False + True + 1 + + + + + True + False + as user: + + + False + True + 2 + + + + + True + False + False + 0 + + Default + + + + False + True + 3 + + + + + True + False + as group: + + + False + True + 4 + + + + + True + False + False + 0 + + Default + + + + False + True + 5 + + + + + True + False + rules: + + + False + True + 6 + + + + + True + False + True + + + False + True + 7 + + + + + True + False + True + True + image5 + + + False + True + 8 + + + + + False + True + 0 + + + + + True + False + 5 + + + Cut source journal fileafter copy creating instead of moving old journal file and creating new one + True + True + False + True + + + False + True + 0 + + + + + False + True + 1 + - - False - True - 3 - + + + + + True + False + Files and directories configuration + + + + + False + True + 3 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + Use compression: + + + False + True + 0 + + + + + True + False + 0 + + Default + On + Off + + + + False + True + 1 + + + + + True + False + Delay compression by one journal in queue: + + + False + True + 2 + + + + + True + False + False + 0 + + Default + Yes + No + + + + False + True + 3 + + + + + False + True + 0 + + + + + + + + + True + False + Compression configuration + + + + + False + True + 4 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + Save original log file after rotation if it has specified extension: + + + False + True + 0 + + + + + True + False + 0 + + Default + On + Off + + + + False + True + 1 + + + + + True + False + True + + + False + True + 2 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + Add date of rotation before log header + + + False + True + 0 + + + + + True + False + 0 + + Default + On + Off + + + + False + True + 1 + + + + + False + True + 1 + + + + + True + False + 5 + + + True + False + Number from which numbering of old logs will begin + + + False + True + 0 + + + + + True + False + 0 + + Default + On + Off + + + + False + True + 1 + + + + + True + True + adjustment10 + + + False + True + 2 + + + + + False + True + 2 + + + + + + + + + True + False + Filename configuration + + + + + False + True + 5 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 - + True False - 0 - in + vertical + 5 - + True False - 5 - 5 - 5 + 5 - + True False - vertical - 5 - - - True - False - 5 - - - True - False - Use compression: - - - False - True - 0 - - - - - True - False - 0 - - On - Off - - - - False - True - 1 - - - - - True - False - Delay compressin by one journal in queue: - - - False - True - 2 - - - - - True - False - 0 - - Default - - - - False - True - 3 - - - - - False - True - 0 - - + Email after rotation: + + False + True + 0 + + + + + True + False + 0 + + Default + Send Email + Don't send Email + + + + False + True + 1 + + + + + True + False + adress: + + + False + True + 2 + + + + + True + False + True + + + False + True + 3 + + + + + True + False + contents: + + + False + True + 4 + + + + + True + False + False + 0 + + Default + First rotated copy + Last rotated copy + + + + False + True + 5 + - - - - True - False - Compression configuration - + + False + True + 0 + - - False - True - 4 - + + + + + True + False + Message configuration + + + + + False + True + 6 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 - + True False - 0 - in + vertical + 5 + + + Scenarios are running for each rotated journal + True + True + False + True + + + False + True + 0 + + - + True False - 5 - 5 - 5 + 5 - + True False - vertical - 5 - - - True - False - 5 - - - True - False - Save original log file after rotation if it has specified extension: - - - False - True - 0 - - - - - True - False - 0 - - Default - - - - False - True - 1 - - - - - True - True - - - False - True - 2 - - - - - False - True - 0 - - - - - True - False - 5 - - - True - False - Add date of rotation before log header - - - False - True - 0 - - - - - True - False - 0 - - Default - - - - False - True - 1 - - - - - False - True - 1 - - - - - True - False - 5 - - - True - False - Number from which numbering of old logs will begin - - - False - True - 0 - - - - - True - False - 0 - - Default - - - - False - True - 1 - - - - - True - True - - - False - True - 2 - - - - - False - True - 2 - - + Command before rotation (one time): + 0 + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + False + True + 1 + - - - True - False - Filename configuration - - - - - False - True - 5 - - - - - True - False - 0 - in - + True False - 5 - 5 - 5 + 5 - + True False - vertical - 5 - - - True - False - 5 - - - True - False - Email after rotation: - - - False - True - 0 - - - - - True - False - 0 - - Default - - - - False - True - 1 - - - - - True - False - adress: - - - False - True - 2 - - - - - True - True - - - False - True - 3 - - - - - True - False - contents: - - - False - True - 4 - - - - - True - False - 0 - - Default - - - - False - True - 5 - - - - - False - True - 0 - - + Command after rotation (one time): + 0 + + + False + True + 0 + + + + + True + True + + True + True + 1 + + + False + True + 2 + - - + + True False - Message configuration + 5 + + + True + False + Command before rotation: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + False + True + 3 + - - - False - True - 6 - - - - - True - False - 5 - + True False - Manual input: + 5 + + + True + False + Command after rotation: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + False True - 0 + 4 - + True - True + False + 5 + + + True + False + Endwork command: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + - True + False True - 1 + 5 - - False - True - 7 - + + + True + False + Scenarios + + + + False + True + 7 + - - - True + + False - Rotation configuration + 5 + + + True + False + Manual input: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + False + True + 8 + @@ -1587,7 +2012,7 @@ True False - 0 + 0.019999999552965164 in @@ -1605,7 +2030,7 @@ True False - Log size: + Log (-s) size: False @@ -1696,5 +2121,22 @@ - + + + + + + + + + + + + + + + + + + diff --git a/ubl-settings-logging-rules.glade b/ubl-settings-logging-rules.glade new file mode 100644 index 0000000..c3fd858 --- /dev/null +++ b/ubl-settings-logging-rules.glade @@ -0,0 +1,383 @@ + + + + + + True + False + process-stop-symbolic + + + True + False + emblem-ok-symbolic + + + False + 550 + 450 + com.ublinux.ubl-settings-logging + + + True + False + 5 + 5 + 5 + 5 + vertical + 5 + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + 5 + + + Read + True + True + False + True + + + False + True + 0 + + + + + Write + True + True + False + True + + + False + True + 1 + + + + + Execute + True + True + False + True + + + False + True + 2 + + + + + + + + + True + False + Owner rules + + + + + False + True + 0 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + 5 + + + Read + True + True + False + True + + + False + True + 0 + + + + + Write + True + True + False + True + + + False + True + 1 + + + + + Execute + True + True + False + True + + + False + True + 2 + + + + + + + + + True + False + Group rules + + + + + False + True + 1 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + 5 + + + Read + True + True + False + True + + + False + True + 0 + + + + + Write + True + True + False + True + + + False + True + 1 + + + + + Execute + True + True + False + True + + + False + True + 2 + + + + + + + + + True + False + Public rules + + + + + False + True + 2 + + + + + True + False + 5 + + + True + False + Value: + + + False + True + 0 + + + + + True + False + + + False + True + 1 + + + + + False + True + 3 + + + + + True + False + end + 5 + + + Cancel + True + True + True + image1 + + + False + True + 0 + + + + + Accept + True + True + True + image2 + + + False + True + 1 + + + + + False + True + end + 4 + + + + + + + True + False + True + + + True + False + 5 + 5 + 5 + 5 + 2 + Logs and events + + + + + + + + True + False + 5 + 5 + 5 + 5 + 6 + 6 + 32 + com.ublinux.ubl-settings-logging + + + + + + + diff --git a/ubl-settings-logging.glade b/ubl-settings-logging.glade index 2247491..3f720ec 100644 --- a/ubl-settings-logging.glade +++ b/ubl-settings-logging.glade @@ -201,6 +201,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + @@ -514,7 +516,7 @@ translated and supported by community. True False - Save configuration + Save to global and local configuration @@ -592,6 +594,7 @@ translated and supported by community. 6 6 True + 0 @@ -681,6 +684,7 @@ translated and supported by community. True True True + Inspect log image1