|
|
#include <gtk/gtk.h>
|
|
|
#include <gdk/gdk.h>
|
|
|
#include <gtk/gtkx.h>
|
|
|
#include <locale.h>
|
|
|
#include <stdio.h>
|
|
|
#include <unistd.h>
|
|
|
#include <stdlib.h>
|
|
|
#include <libintl.h>
|
|
|
#include <getopt.h>
|
|
|
#include <libintl.h>
|
|
|
#include <vte/vte.h>
|
|
|
#include <libublsettings.h>
|
|
|
#include <libublsettings-gtk3.h>
|
|
|
#include <libublsettingsui-gtk3.h>
|
|
|
#include <time.h>
|
|
|
#include <json-c/json.h>
|
|
|
#ifdef WEBKIT_FOUND
|
|
|
#include <webkit2/webkit2.h>
|
|
|
#endif
|
|
|
#include "ubl-strings.h"
|
|
|
|
|
|
#define WIKI_LINK "https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-services"
|
|
|
|
|
|
#define _(String) gettext(String)
|
|
|
|
|
|
#define glade_path "/com/ublinux/ui/ubl-settings-services.glade"
|
|
|
#define glade_path_log "/com/ublinux/ui/ubl-settings-services-terminal.glade"
|
|
|
|
|
|
#define banner_path "/com/ublinux/images/ubl-settings-services-banner.png"
|
|
|
#define CssPath "/com/ublinux/css/ubl-settings-services.css"
|
|
|
#define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL)
|
|
|
|
|
|
#define LocalePath "/usr/share/locale"
|
|
|
#define LocaleName "ubl-settings-services"
|
|
|
|
|
|
#define load_services_command "systemctl list-units --no-pager --all --plain --no-legend |sed -E 's/(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(.*)/\\1;\\2;\\3;\\4;\\5/'"
|
|
|
#define load_user_services_command yon_char_unite("systemctl --user --machine=",yon_ubl_root_user_get(),"@ list-units --no-pager --all --plain --no-legend |sed -E 's/(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(.*)/\\1;\\2;\\3;\\4;\\5/'",NULL)
|
|
|
#define load_system_services_command "systemctl --system list-units --no-pager --all |grep -E \"^ \" |grep -v \"UNIT\" |sed -e 's/ */;/g' -e 's/^;//g' |cut -f1 -d';'"
|
|
|
#define load_enabled_command "systemctl list-unit-files --no-pager --state=enabled --all |sed -e 's/ */:/g' -e 's/ *: */:/g'|cut -f1 -d:"
|
|
|
#define load_launched_command "systemctl list-units --no-pager --state=active --all --no-legend|sed -e 's/^ //g' -e 's/ */:/g' |cut -f1 -d:"
|
|
|
#define service_start_command(target) yon_char_append("systemctl start --no-pager ",target)
|
|
|
#define service_stop_command(target) yon_char_append("systemctl stop --no-pager ",target)
|
|
|
#define service_enable_command(target) yon_char_append("systemctl enable --no-pager ",target)
|
|
|
#define service_disable_command(target) yon_char_append("systemctl disable --no-pager ",target)
|
|
|
#define service_kill_command(target) yon_char_append("systemctl kill ",target)
|
|
|
#define service_check_active_command(target) yon_char_append("systemctl is-active ",target)
|
|
|
|
|
|
#define service_info_command(target) yon_char_append("systemctl status -l --no-pager ",target)
|
|
|
#define get_log_command(target) yon_char_append("journalctl --all --no-pager --unit ",target)
|
|
|
#define show_source_command(target) yon_char_append("systemctl edit --full ",target)
|
|
|
#define properties_command(target) yon_char_append("systemctl show --no-pager ",target)
|
|
|
|
|
|
#define user_service_info_command(target) yon_char_unite("systemctl --user --machine=",yon_ubl_root_user_get(),"@ status -l --no-pager ",target,NULL)
|
|
|
#define user_get_log_command(target) yon_char_unite("usermod -a -G systemd-journal ",yon_ubl_root_user_get(),";journalctl --user -u --all --no-pager --unit ",target,NULL)
|
|
|
#define user_show_source_command(target) yon_char_unite("systemctl edit --full ",target,NULL)
|
|
|
#define user_properties_command(target) yon_char_unite("systemctl --user --machine=",yon_ubl_root_user_get(),"@ show --no-pager ",target,NULL)
|
|
|
|
|
|
#define get_config_files_command "find /etc/systemd -iname *.conf -exec du -sh --time {} \\;|sed -e 's/\t/;/g'"
|
|
|
|
|
|
#define system_services_status_command "systemctl status --no-pager"
|
|
|
#define user_services_status_command yon_char_unite("systemctl --user --machine=",yon_ubl_root_user_get()," status --no-pager",NULL)
|
|
|
#define installed_units_states_command "systemctl list-unit-files --no-pager"
|
|
|
#define list_of_units_states_command "systemctl list-units --all --no-pager"
|
|
|
#define list_of_sockets_states_command "systemctl list-sockets --all --no-pager"
|
|
|
#define list_of_timers_states_command "systemctl list-timers --all --no-pager"
|
|
|
#define get_timers_command "systemctl list-timers --all --no-pager --plain --no-legend --output=json"
|
|
|
|
|
|
#define installed_units_command "systemctl list-unit-files --no-pager| sed -e 's/ */;/g'"
|
|
|
#define list_of_units_command "systemctl list-units --all --no-pager| sed -e 's/ */;/g'"
|
|
|
#define list_of_sockets_command "systemctl list-sockets --all --no-pager| sed -e 's/ */;/g'"
|
|
|
#define list_of_timers_command "systemctl list-timers --all --no-pager| sed -e 's/ */;/g'"
|
|
|
#define list_of_session_command "while IFS=\" \" read -r GET_SESSION GET_UID GET_USER GET_SEAT GET_TTY; do echo -e \"${GET_SESSION} $(loginctl session-status ${GET_SESSION} --no-page | sed -Enr \"s/^\\s*State: (.*)$/\1/p\") ${GET_UID} ${GET_USER} ${GET_SEAT} ${GET_TTY}\"; done < <(loginctl list-sessions --no-legend)"
|
|
|
|
|
|
#define config_get_command(target) yon_char_append("cat ",target)
|
|
|
|
|
|
#define yon_config_get_custom_command(target) yon_char_unite("ubconfig --source ",target," get system SERVICES_ENABLE SERVICES_DISABLE SERVICES_MASK",NULL)
|
|
|
#define config_get_local_command "ubconfig --source system get system SERVICES_ENABLE SERVICES_DISABLE SERVICES_MASK"
|
|
|
#define config_get_global_command yon_char_new("ubconfig --source global get system SERVICES_ENABLE SERVICES_DISABLE SERVICES_MASK")
|
|
|
#define config_get_default_command ""
|
|
|
|
|
|
#define config_get_global_only_parameters ""
|
|
|
#define config_get_local_only_parameters ""
|
|
|
|
|
|
#define SERVICES_ENABLE_get_command "ubconfig --source global get [system] SERVICES_ENABLE"
|
|
|
#define SERVICES_DISABLE_get_command "ubconfig --source global get [system] SERVICES_DISABLE"
|
|
|
#define SERVICES_MASK_get_command "ubconfig --source global get [system] SERVICES_MASK"
|
|
|
#define CONSOLE_FONT_get_command "ubconfig --source global get [locale] CONSOLE_FONT"
|
|
|
|
|
|
#define play_icon_path "com.ublinux.ubl-settings-services.play-symbolic"
|
|
|
#define stop_icon_path "com.ublinux.ubl-settings-services.stop-symbolic"
|
|
|
#define block_icon_path "com.ublinux.ubl-settings-services.cancel-symbolic"
|
|
|
#define start_icon_path "com.ublinux.ubl-settings-services.launch-symbolic"
|
|
|
#define update_icon_path "com.ublinux.ubl-settings-services.sync-symbolic"
|
|
|
#define launch_icon_path "com.ublinux.ubl-settings-services.check-symbolic"
|
|
|
#define log_icon_path "com.ublinux.ubl-settings-services.lookup-symbolic"
|
|
|
#define source_icon_path "com.ublinux.ubl-settings-services.source-symbolic"
|
|
|
#define properties_icon_path "com.ublinux.ubl-settings-services.properties-symbolic"
|
|
|
#define status_icon_path "com.ublinux.ubl-settings-services.important-symbolic"
|
|
|
|
|
|
#define reload_systemd_root_command "systemctl daemon-reload"
|
|
|
#define reexec_systemd_root_command "systemctl daemon-reexec"
|
|
|
|
|
|
#define reload_systemd_user_command "systemctl --user daemon-reload"
|
|
|
#define reexec_systemd_user_command "systemctl --user daemon-reexec"
|
|
|
|
|
|
#define session_activate_session(target) yon_char_append("loginctl activate ",target)
|
|
|
#define session_terminate_session(target) yon_char_append("loginctl terminate-session ",target)
|
|
|
#define session_lock_session(target) yon_char_append("loginctl lock-session ",target)
|
|
|
#define session_unlock_session(target) yon_char_append("loginctl unlock-session ",target)
|
|
|
|
|
|
#define SERVICES_ENABLE_PARAMETER "SERVICES_ENABLE"
|
|
|
#define SERVICES_DISABLE_PARAMETER "SERVICES_DISABLE"
|
|
|
#define SERVICES_MASK_PARAMETER "SERVICES_MASK"
|
|
|
|
|
|
typedef char* string;
|
|
|
string version_application;
|
|
|
|
|
|
char *local;
|
|
|
|
|
|
typedef struct {
|
|
|
template_config_fields
|
|
|
int rmb_clicked;
|
|
|
GtkTreeModel *ServiceFilter;
|
|
|
GtkTreeModel *SocketFilter;
|
|
|
GtkTreeModel *AutolaunchFilter;
|
|
|
GtkTreeModel *StoppedFilter;
|
|
|
GtkTreeModel *BlockedFilter;
|
|
|
|
|
|
GtkTreeModel *SourceFilter;
|
|
|
int update_thread_active;
|
|
|
|
|
|
} config;
|
|
|
|
|
|
typedef struct {
|
|
|
template_window_fields
|
|
|
GtkListStore *UserList;
|
|
|
GtkListStore *TimersList;
|
|
|
GtkListStore *SessionsList;
|
|
|
GtkListStore *ConfigList;
|
|
|
GtkListStore *SystemList;
|
|
|
GtkWidget *BoxMain;
|
|
|
|
|
|
GtkWidget *SystemSearchEntry;
|
|
|
GtkWidget *SystemFiltersCombo;
|
|
|
GtkWidget *SystemInactiveShowCheck;
|
|
|
GtkWidget *SystemUnloadedShowCheck;
|
|
|
GtkWidget *SystemUpperTree;
|
|
|
GtkWidget *SystemUnitsTree;
|
|
|
GtkWidget *SystemPrevButton;
|
|
|
GtkWidget *SystemUpdateButton;
|
|
|
GtkWidget *SystemInfoButton;
|
|
|
GtkWidget *SystemLogButton;
|
|
|
GtkWidget *SystemEditButton;
|
|
|
GtkWidget *SystemPropertiesButton;
|
|
|
GtkWidget *SystemStatusButton;
|
|
|
rmb_menu_window *SystemMenu;
|
|
|
GtkWidget *SystemServiceLabel;
|
|
|
GtkWidget *SystemDescriptionLabel;
|
|
|
|
|
|
GtkWidget *UserSearchEntry;
|
|
|
GtkWidget *UserFiltersCombo;
|
|
|
GtkWidget *UserInactiveShowCheck;
|
|
|
GtkWidget *UserUnloadedShowCheck;
|
|
|
GtkWidget *UsersUpperTree;
|
|
|
GtkWidget *UserUnitsTree;
|
|
|
GtkWidget *UserPrevButton;
|
|
|
GtkWidget *UserUpdateButton;
|
|
|
GtkWidget *UserInfoButton;
|
|
|
GtkWidget *UserLogButton;
|
|
|
GtkWidget *UserEditButton;
|
|
|
GtkWidget *UserStatusButton;
|
|
|
rmb_menu_window *UserMenu;
|
|
|
GtkWidget *UserServiceLabel;
|
|
|
GtkWidget *UserDescriptionLabel;
|
|
|
|
|
|
GtkWidget *ConfigEditButton;
|
|
|
GtkWidget *ConfigMainTree;
|
|
|
|
|
|
GtkWidget *SessionMainTree;
|
|
|
GtkWidget *SessionStartButton;
|
|
|
GtkWidget *SessionStopButton;
|
|
|
GtkWidget *SessionBlockButton;
|
|
|
rmb_menu_window *SessionMenu;
|
|
|
|
|
|
GtkWidget *TimersMainTree;
|
|
|
GtkWidget *MainNotebook;
|
|
|
|
|
|
GtkWidget *SystemServicesStatusMenuItem;
|
|
|
GtkWidget *UserServicesStatusMenuItem;
|
|
|
GtkWidget *InstalledUnitsStatusMenuItem;
|
|
|
GtkWidget *UnitsStatusListMenuItem;
|
|
|
GtkWidget *SocketsStatusListMenuItem;
|
|
|
GtkWidget *TimersStatusListMenuItem;
|
|
|
GtkTreeModelFilter *SystemFilter;
|
|
|
GtkTreeModelFilter *UserFilter;
|
|
|
|
|
|
} main_window;
|
|
|
|
|
|
typedef struct {
|
|
|
GtkWidget *Window;
|
|
|
|
|
|
GtkWidget *AlwaysOpenCheck;
|
|
|
|
|
|
GtkWidget *CloseButton;
|
|
|
GtkWidget *AcceptButton;
|
|
|
} documentation_confirmation_window;
|
|
|
|
|
|
typedef struct{
|
|
|
GtkListStore *liststore1;
|
|
|
GtkListStore *liststore2;
|
|
|
GtkWidget *BoxMain;
|
|
|
GtkWidget *ServiceSourceCombo;
|
|
|
GtkWidget *ServiceTypeCombo;
|
|
|
GtkWidget *SearchEntry;
|
|
|
GtkWidget *UpdateButton;
|
|
|
GtkWidget *ConfigAutostartButton;
|
|
|
GtkWidget *ConfigAutostopButton;
|
|
|
GtkWidget *ConfigBlockButton;
|
|
|
GtkWidget *SystemAutostartButton;
|
|
|
GtkWidget *SystemLaunchButton;
|
|
|
GtkWidget *InfoButton;
|
|
|
GtkWidget *LogButton;
|
|
|
GtkWidget *MainUpperTree;
|
|
|
GtkWidget *MainTree;
|
|
|
} bl_settings_services_window;
|
|
|
|
|
|
typedef struct {
|
|
|
GtkWidget *Window;
|
|
|
GtkWidget *SystemTerminal;
|
|
|
GtkWidget *TerminalScroll;
|
|
|
GtkWidget *TextEditor;
|
|
|
GtkWidget *webHeaderNameLabel;
|
|
|
GtkWidget *UpdateButton;
|
|
|
GtkWidget *SaveButton;
|
|
|
GtkWidget *StatusBox;
|
|
|
GtkAdjustment *adjustment;
|
|
|
char *target;
|
|
|
} log_window;
|
|
|
|
|
|
void on_config_local_load(GtkWidget *self,main_window *widgets);
|
|
|
|
|
|
void on_config_global_load(GtkWidget *self,main_window *widgets);
|
|
|
|
|
|
void on_config_custom_load(GtkWidget *self,main_window *widgets);
|
|
|
|
|
|
void on_config_global_local_save();
|
|
|
|
|
|
void on_config_local_save();
|
|
|
|
|
|
void on_config_global_save();
|
|
|
|
|
|
void on_config_custom_save(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_service_constant_update();
|
|
|
|
|
|
log_window *yon_log_window_new();
|
|
|
|
|
|
gboolean yon_filter(GtkTreeModel* model, GtkTreeIter *iter, main_window *widgets);
|
|
|
void on_filter_changed(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_system_services_status(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_user_services_status(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_units_status(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_units_list_status(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_sockets_list_status(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_timers_list_status(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
gboolean yon_interface_update(main_window *widgets);
|
|
|
|
|
|
GtkWidget *yon_menu_button_create(char *icon_name, char *text);
|
|
|
|
|
|
void on_column_resize(GtkTreeViewColumn *self,GParamSpec *pspec,main_window *widgets);
|
|
|
|
|
|
gboolean on_context_menu_open(GtkWidget *self,GdkEventButton *event, main_window *widgets);
|
|
|
|
|
|
GtkWidget *yon_menu_separator_create();
|
|
|
|
|
|
void on_config_autostart_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_activate(GtkTreeView *self, main_window *widgets);
|
|
|
|
|
|
void on_config_autostop_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_config_block_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_system_autostart_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_system_kill_confirmed(GtkWidget *self,char *service_name);
|
|
|
|
|
|
void on_system_launch_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_system_restart_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_source_show();
|
|
|
|
|
|
void on_properties_show();
|
|
|
|
|
|
void yon_sessions_update(main_window *widgets);
|
|
|
|
|
|
void on_session_activate();
|
|
|
|
|
|
void on_session_end();
|
|
|
|
|
|
void on_session_block();
|
|
|
|
|
|
void yon_system_systemd_restart(GtkWidget *self, main_window *widgets);
|
|
|
void yon_user_systemd_restart(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_system_update_hz_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void yon_system_systemd_reexec(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_system_update_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_system_info_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_system_log_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void *on_terminal_relaunch(log_window *window);
|
|
|
void on_save_clicked(GtkWidget *self, log_window *window);
|
|
|
void on_update_clicked(GtkWidget *self, log_window *window);
|
|
|
void on_system_edit_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_filter_changed(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_system_status_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_user_update_hz_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_user_update_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_user_info_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_user_log_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_user_edit_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_user_status_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_config_log_save(GtkWidget *self, log_window *window);
|
|
|
void on_config_edit_clicked(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
gboolean yon_service_source_check(GtkTreeModel *model, GtkTreeIter *iter, void *data);
|
|
|
|
|
|
gboolean yon_service_type_check(GtkTreeModel *model, GtkTreeIter *iter,void *data);
|
|
|
|
|
|
void on_type_changed(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void on_search();
|
|
|
|
|
|
void on_info_clicked();
|
|
|
|
|
|
void *yon_unthreaded_config_load(void *widgets);
|
|
|
|
|
|
void on_update();
|
|
|
|
|
|
void on_status_show();
|
|
|
|
|
|
void yon_load_proceed(YON_CONFIG_TYPE type);
|
|
|
|
|
|
void config_init();
|
|
|
|
|
|
void on_tree_selection_changed(GtkWidget *self, main_window *widgets);
|
|
|
|
|
|
void yon_main_window_complete(main_window *widgets);
|
|
|
|
|
|
void on_log_show();
|
|
|
|
|
|
void *update_delay(main_window *widgets);
|
|
|
|
|
|
gboolean on_service_filter(GtkTreeModel *model, GtkTreeIter *iter,void *data);
|
|
|
|
|
|
gboolean on_socket_filter(GtkTreeModel *model, GtkTreeIter *iter,void *data);
|
|
|
|
|
|
gboolean on_autostart_filter(GtkTreeModel *model, GtkTreeIter *iter,void *data);
|
|
|
|
|
|
gboolean on_stopped_filter(GtkTreeModel *model, GtkTreeIter *iter,void *data);
|
|
|
|
|
|
gboolean on_blocked_filter(GtkTreeModel *model, GtkTreeIter *iter,void *data);
|
|
|
|
|
|
gboolean on_source_user_filter(GtkTreeModel *model, GtkTreeIter *iter,void *data);
|
|
|
|
|
|
gboolean on_source_system_filter(GtkTreeModel *model, GtkTreeIter *iter,void *data); |