Ubl-settings-logging fixes for library usage

pull/129/head
Ivan Yartsev 7 months ago
parent 7a242ae64b
commit dd306c4017

@ -29,10 +29,6 @@ if(WEBKIT_LIBRARIES_FOUND)
add_definitions(${WEBKIT_CFLAGS_OTHER}) add_definitions(${WEBKIT_CFLAGS_OTHER})
endif() endif()
configure_file(ubl-cmake.in ubl-cmake.h)
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h DESTINATION ./)
set(GRESOURCE_C resources.c) set(GRESOURCE_C resources.c)
set(GRESOURCE_XML gresource.xml) set(GRESOURCE_XML gresource.xml)
@ -76,21 +72,21 @@ add_custom_target(
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}
) )
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -std=c++2a") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -lm")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \
-O2 -pipe -fno-plt -fexceptions \ -O2 -pipe -fno-plt -fexceptions \
-Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \ -Wformat -Werror=format-security \
-fstack-clash-protection -fcf-protection") -fstack-clash-protection -fcf-protection")
string(FIND "${CMAKE_CXX_FLAGS}" "-D_FORTIFY_SOURCE" FORTIFY_FOUND)
if(FORTIFY_FOUND EQUAL -1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wp,-D_FORTIFY_SOURCE=2")
endif()
set(SOURCE_FILES set(SOURCE_FILES
ubl-settings-logging.c ubl-settings-logging.c
ubl-settings-logging.h ubl-settings-logging.h
ubl-strings.h ubl-strings.h
ubl-utils.h
ubl-utils.c
${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h
) )
set(LIBRARIES set(LIBRARIES
@ -98,7 +94,10 @@ set(LIBRARIES
${WEBKIT_LIBRARIES} ${WEBKIT_LIBRARIES}
${VTE291_LIBRARIES} ${VTE291_LIBRARIES}
${POLKIT_LIBRARIES} ${POLKIT_LIBRARIES}
pthread) pthread
ublsettings
ublsettings-gtk3
ublsettingsui-gtk3)
add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}) add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C})

@ -1 +0,0 @@
#cmakedefine WEBKIT_FOUND

File diff suppressed because it is too large Load Diff

@ -1,6 +1,5 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gtk/gtkx.h> #include <gtk/gtkx.h>
#include "ubl-utils.h"
#include <locale.h> #include <locale.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
@ -12,7 +11,9 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/select.h> #include <sys/select.h>
#include <pwd.h> #include <pwd.h>
#include "../compile/ubl-cmake.h" #include <libublsettings.h>
#include <libublsettings-gtk3.h>
#include <libublsettingsui-gtk3.h>
#ifdef WEBKIT_FOUND #ifdef WEBKIT_FOUND
#include <webkit2/webkit2.h> #include <webkit2/webkit2.h>
#endif #endif
@ -39,6 +40,7 @@
#define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) #define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL)
#define journals_list_path "/usr/share/ubl-settings-logging/csv/journals_list.csv" #define journals_list_path "/usr/share/ubl-settings-logging/csv/journals_list.csv"
#define services_list_path "/usr/share/ubl-settings-logging/csv/logging_services.csv" #define services_list_path "/usr/share/ubl-settings-logging/csv/logging_services.csv"
#define icon_path "com.ublinux.ubl-settings-logging"
#define logrotate_config_command "ls /etc/logrotate.d/ |sed -e 's/ */\\n/g'" #define logrotate_config_command "ls /etc/logrotate.d/ |sed -e 's/ */\\n/g'"
#define journald_size_command "journalctl --disk-usage | grep -oE \"[0-9]{1,}.[0-9]{1,}[A-Z]\"" #define journald_size_command "journalctl --disk-usage | grep -oE \"[0-9]{1,}.[0-9]{1,}[A-Z]\""
@ -49,6 +51,12 @@
#define LocalePath "/usr/share/locale" #define LocalePath "/usr/share/locale"
#define LocaleName "ubl-settings-logging" #define LocaleName "ubl-settings-logging"
#define config_get_command(source) yon_char_unite("ubconfig --source ",source," get logging LOGROTATE[*] JOURNALD[*]",NULL)
#define config_get_default_command ""
#define config_get_global_only_parameters ""
#define config_get_local_only_parameters ""
#define JOURNALD(key) yon_char_unite("JOURNALD[",key,"]",NULL) #define JOURNALD(key) yon_char_unite("JOURNALD[",key,"]",NULL)
#define LOGROTATE(key) yon_char_unite("LOGROTATE[",key,"]",NULL) #define LOGROTATE(key) yon_char_unite("LOGROTATE[",key,"]",NULL)
@ -75,23 +83,12 @@ string version_application;
char *local; char *local;
typedef struct { typedef struct {
template_config_fields
config_str launch_arguments;
int launch_size;
char **envp; char **envp;
int always_open_documentation;
int win_pos_x;
int win_pos_y;
int win_width;
int win_height;
int socket_id;
int load_socket_id;
int save_socket_id;
int lock_help;
int lock_save_local;
int lock_save_global;
int lock_load_global;
int load_mode; int save_config;
GtkListStore *logrotate_list; GtkListStore *logrotate_list;
GtkListStore *logrotate_apps_list; GtkListStore *logrotate_apps_list;
@ -109,33 +106,7 @@ typedef struct {
typedef struct { typedef struct {
//Standard //Standard
GtkWidget *Window; template_window_fields
GtkWidget *HatLabel;
GtkWidget *PlugBox;
GtkWidget *HeadOverlay;
GtkWidget *HeadImage;
GtkWidget *HeadBox;
GtkWidget *HeadTitleLabel;
GtkWidget *HeadInfoLabel;
GtkWidget *StatusBox;
GtkWidget *StatusIcon;
GtkWidget *StatusLabel;
GtkWidget *SaveLabel;
GtkWidget *SaveMenuItem;
GtkWidget *SaveGlobalMenuItem;
GtkWidget *SaveLocalMenuItem;
GtkWidget *RightBox;
GtkWidget *LoadLabel;
GtkWidget *LoadGlobalMenuItem;
GtkWidget *LoadLocalMenuItem;
GtkWidget *LeftBox;
GtkWidget *DocumentationMenuItem;
GtkWidget *AboutMenuItem;
GtkWidget *MainTree; GtkWidget *MainTree;
GtkWidget *InspectButton; GtkWidget *InspectButton;
@ -372,4 +343,83 @@ typedef struct {
YON_CONFIG_TYPE type; YON_CONFIG_TYPE type;
} saving_window; } saving_window;
main_window *setup_window(); main_window *setup_window();
void on_save_window_parameter_switched(GtkCellRendererToggle *self, gchar *path, saving_window *window);
char *yon_size_get_letter_from_int(int size);
int yon_size_get_int_from_letter(char size);
// void yon_polkit_authorized_action(GCallback *func);
void yon_logs_custom_save(main_window *widgets);
void update_loaded_logrotate();
int yon_load_proceed(YON_CONFIG_TYPE type);
void on_load_global();
void on_load_local();
void on_config_custom_load(GtkWidget *,main_window *widgets);
void on_save_global_local();
void on_save_global();
void on_save_local();
void on_config_custom_save(GtkWidget *, main_window *);
void on_save_done(main_window *widgets, config_str output, int size);
void on_save_failed(main_window *, config_str , int );
void on_inspector_jornald_read_async(inspector_window *window);
void on_inspector_update(GtkWidget *self, inspector_window *window);
GtkWidget *yon_inspector_add_terminal(inspector_window *window,char *page_name,int mode);
void on_inspector_close(GtkWidget *self, inspector_window *window);
void on_inspector_open(GtkWidget *self, main_window *widgets);
void on_logrotate_configuration_path_filechooser_selection_changed(GtkWidget *self, logrotate_filechooser_window *dialog);
void on_logrotate_filechooser_file_dir_toggled(GtkWidget *self, logrotate_filechooser_window *dialog);
void on_logrotate_configuration_path_filechooser_save_edit(GtkWidget *self, dictionary *dict);
void on_logrotate_configuration_path_filechooser_save(GtkWidget *self, dictionary *dict);
void on_logrotate_configuration_path_filechooser_open(GtkWidget *self, logrotate_configure_window *window);
void on_logrotate_configuration_path_add(GtkWidget *self, logrotate_configure_window *window);
void on_path_editing_done(GtkCellRendererText* self,gchar* gtkpath,gchar* new_text,logrotate_configure_window *window);
void on_path_editing_cancel(GtkCellRendererText* self,logrotate_configure_window *window);
void on_logrotate_configuration_path_edit(GtkWidget *self, logrotate_configure_window *window);
void on_logrotate_configuration_path_remove(GtkWidget *self, logrotate_configure_window *window);
void on_combo_activate_first(GtkComboBox *self, GtkWidget *target);
void on_combo_activate_second(GtkComboBox *self, GtkWidget *target);
void on_file_amount_checked(GtkToggleButton *self, logrotate_configure_window *window);
void on_rules_accept(GtkWidget *self, dictionary *dict);
void on_rules_update(GtkWidget *self, logrotate_rules_window *window);
void on_rules_open(GtkWidget *self,GtkEntry *entry);
void on_filechooser_mode_switch(GtkWidget *self, logrotate_filechooser_window *window);
void on_filechooser_save(GtkWidget *self, dictionary *dict);
void on_filechooser_open(GtkWidget *self, logrotate_configure_window *window);
void on_logrotate_period_check_toggled(GtkToggleButton *self,logrotate_configure_window *window);
void on_logrotate_paths_cursor_changed(GtkWidget *self, logrotate_configure_window *window);
int on_logrotate_check_repeats(GtkWidget *self, logrotate_configure_window *window);
void on_logrotate_save(GtkWidget *self, dictionary *dict);
logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_window *dialog, char *log_name);
void on_logrotate_add(GtkWidget *self, logrotate_window *dialog);
void on_logrotate_edit(GtkWidget *self, logrotate_window *window);
void on_logrotate_remove(GtkWidget *self, logrotate_window *window);
void on_logrotate_apps_configure(GtkWidget *self, logrotate_window *window);
void on_log_edit_logrotate_settings(GtkWidget *self, dictionary *dict);
void on_logrotate_tab_selection_changed(GtkWidget *self, logrotate_window *window);
void on_logrotate_applications_tab_selection_changed(GtkWidget *self, logrotate_window *window);
void on_logrotate_tab_open(GtkWidget *self, main_window *widgets);
void yon_combo_compress_check(GtkComboBox *self, journald_window *window);
void on_journald_reset(GtkWidget *self, journald_window *window);
void on_journald_save(GtkWidget *self, journald_window *window);
journald_window *yon_journald_open(GtkWidget *self, main_window *widgets);
void on_journald_open(GtkWidget *self, main_window *widgets);
void on_log_save(GtkWidget *self, dictionary *dict);
add_log_window *on_add_open(main_window *widgets);
void on_log_path_remove(GtkWidget *self, add_log_window *window);
void on_log_path_filechooser_selection_changed(GtkWidget *self, logrotate_filechooser_window *dialog);
void on_log_path_filechooser_toggled(GtkWidget *self, logrotate_filechooser_window *dialog);
void on_log_path_filechooser_save(GtkWidget *self, dictionary *dict);
void on_log_path_filechooser_open(GtkWidget *self, GtkEntry *entry);
void on_log_path_choose(GtkWidget *self,add_log_window *window);
void on_log_path_append(GtkWidget *self, add_log_window *window);
void on_log_add(GtkWidget *self, main_window *widgets);
void on_log_edit(GtkWidget *self,main_window *widgets);
void on_log_remove(GtkWidget *self, main_window *widgets);
void on_service_edit(GtkWidget *self,main_window *widgets);
void on_main_window_tree_selection_changed(GtkWidget *self,main_window *widgets);
void on_main_window_services_tree_selection_changed(GtkWidget *self,main_window *widgets);
void on_start_stop_clicked(GtkButton *self, main_window *widgets);
void on_enable_disable_clicked(GtkButton *self, main_window *widgets);
void on_permissions_changed();
void config_init();
void yon_main_window_complete(template_main_window **window);
int main(int argc, char *argv[]);

@ -1,41 +1,14 @@
#define VERSION_LABEL yon_char_unite(_("Version:")," ",version_application,"\n",NULL)
#define HELP_LABEL yon_char_unite(_("ubl-settings-loggign version:")," ", version_application,"\n",_("Logs and events"),"\n",_("Usage:"), " ubl-settings-logging ",_("[OPTIONS]"),"\n",_("Options:"),"\n\t--help, -h\t\t\t",_("Show this help"),"\n\t--version, -V\t\t\t",_("Show package version"),"\n\t--lock-help\t\t\t",_("Lock this help menu"),"\n\t--lock-save\t\t\t",_("Lock configuration saving"),"\n\t--lock-save-local\t\t",_("Lock local configration saving"),"\n\t--lock-save-global\t\t",_("Lock global configration saving"),"\n\t--lock-load-global\t\t",_("Lock global configration loading"),"\n\t--clear-config\t\t\t",_("Clear application configuration"),"\n",NULL)
#define TITLE_LABEL _("Logs and events") #define TITLE_LABEL _("Logs and events")
#define TITLE_INFO_LABEL _("Logs and events configuration") #define TITLE_INFO_LABEL _("Logs and events configuration")
#define SUCCESS_LABEL _("Operation succeeded")
#define ROOT_WARNING_LABEL _("Warning! Application was launched without root - root-dependent actions are locked")
#define ABOUT_LABEL _("About")
#define DOCUMENTATION_LABEL _("Documentation")
#define SAVE_LOCAL_LABEL _("Save to local configuration")
#define SAVE_GLOBAL_LABEL _("Save to global configuration")
#define SAVE_CONFIGURATION_LABEL _("Save to global and local configuration")
#define SAVE_LABEL _("Save")
#define LOAD_LOCAL_LABEL _("Load local configuration")
#define LOAD_GLOBAL_LABEL _("Load global configuration")
#define LOAD_LABEL _("Load")
#define CANCEL_LABEL _("Cancel") #define CANCEL_LABEL _("Cancel")
#define HELP_TITLE_LABEL _("Would you like to read documentation in the Web?")
#define HELP_INFO_LABEL _("You will be redirected to documentation website where documentation is\ntranslated and supported by community.")
#define HELP_ALWAYS_OPEN_LABEL _("Always redirect to online documentation")
#define OPEN_HELP_LABEL _("Open documentation")
#define PROJECT_HOME_LABEL _("Project Home Page")
#define NOTHING_CHOSEN_LABEL _("Nothing were chosen") #define NOTHING_CHOSEN_LABEL _("Nothing were chosen")
#define FILTER_NAME_CONFIG_LABEL yon_char_append(_("Configuration file")," *.ini")
#define CHOOSE_CUSTOM_CONFIG_LABEL _("Choose custom configuration file")
#define GLOBAL_LOAD_SUCCESS_LABEL _("Global configuration loading succseeded.")
#define LOCAL_LOAD_SUCCESS_LABEL _("Local configuration loading succseeded.")
#define LOAD_FAILED_LABEL _("Config loading failed")
#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") #define ACCEPT_LABEL _("Accept")
#define CHOOSE_DIR_NOT_FILE_LABEL _("Choose directory instead of file") #define CHOOSE_DIR_NOT_FILE_LABEL _("Choose directory instead of file")

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save