|
|
|
|
|
#include <cstddef>
|
|
|
#include <iostream>
|
|
|
#include <gtkmm.h>
|
|
|
#include <string>
|
|
|
#include <vector>
|
|
|
#include <stdio.h>
|
|
|
#include <gtkmm/stock.h>
|
|
|
#include <gtkmm/window.h>
|
|
|
#include <gtkmm/plug.h>
|
|
|
#include <locale.h>
|
|
|
#include <libintl.h>
|
|
|
#include <glibmm/i18n.h>
|
|
|
#include <map>
|
|
|
#include "ubl-util-standard.c"
|
|
|
#include "util.h"
|
|
|
#include "save.h"
|
|
|
#include "load.h"
|
|
|
#include <dlfcn.h>
|
|
|
#include "ubl-settings-bootloader-cm.h"
|
|
|
#ifdef WEBKIT_FOUND
|
|
|
#include <webkit2/webkit2.h>
|
|
|
#endif
|
|
|
|
|
|
#include "my_process.h"
|
|
|
using namespace std;
|
|
|
|
|
|
extern int socket_ext_id_I;
|
|
|
extern int socket_trd_id_I;
|
|
|
extern string version_application;
|
|
|
extern bool flag_save;
|
|
|
extern bool flag_save_local;
|
|
|
extern bool flag_save_global;
|
|
|
extern bool flag_load_global;
|
|
|
extern bool flag_lock_help;
|
|
|
void me_thread(string cmd);
|
|
|
|
|
|
#define copyright _("Copyright © UBSoft LLC, 2022 - ")
|
|
|
#define name_app _("ubl-settings-bootloader")
|
|
|
#define website _("https://wiki.ublinux.com")
|
|
|
#define project_Home_page _("Project Home Page")
|
|
|
#define configuring_system_boot _("Configuring system boot parameters")
|
|
|
#define system_boot _("System boot")
|
|
|
#define str_about _("About ubl-settings-bootloader")
|
|
|
#define command_line_parameters _("Command line parameters:")
|
|
|
#define load_default _("Load default:")
|
|
|
#define seconds _("seconds")
|
|
|
#define download_menu _("Download menu")
|
|
|
#define terminal_for_input _("Terminal for input")
|
|
|
#define terminal_for_output _("Terminal for output")
|
|
|
#define boot_selection_menu_timer _("Boot selection menu timer")
|
|
|
#define str_help _("Help")
|
|
|
#define str_about_1 _("About")
|
|
|
#define str_save _("Save")
|
|
|
#define str_load _("Load")
|
|
|
#define save_all _("Save in global and local configuration")
|
|
|
#define save_local _("Save in local configuration")
|
|
|
#define save_global _("Save in global configuration")
|
|
|
#define load_global _("Load global configuration")
|
|
|
#define load_local _("Load local configuration")
|
|
|
#define read_online _("Read online")
|
|
|
#define cancel _("Cancel")
|
|
|
#define always_redirect _("Always redirect")
|
|
|
#define boot_screen_display_mode _("Boot screen display mode:")
|
|
|
#define no_loading_animation _("No loading animation, full log")
|
|
|
#define boot_menu_user_name _("Boot menu user name:")
|
|
|
#define boot_menu_user_password _("Boot menu user password:")
|
|
|
#define last_successful_upload _("Last successful upload")
|
|
|
#define read_documentation_web _("Would you like to read documentation in the Web?")
|
|
|
#define redirected_documentation _("You will be redirected to documentation site, where user help pages are ""translated and supported by community.")
|
|
|
#define user_name_configuration_editing_code _("User name to enter boot configuration editing mode")
|
|
|
#define user_password_configuration_edit_mode _("User password to enter boot configuration edit mode")
|
|
|
#define loading_animation_with _("Loading animation with the magazine")
|
|
|
#define loading_animation_without _("Loading animation without a magazine")
|
|
|
#define lack_loading_animation _("Lack of loading animation with the output of the abbreviated log")
|
|
|
#define web_url _("https://wiki.ublinux.com")
|
|
|
#define enter_password _("Enter your password")
|
|
|
#define enter_login _("Enter login")
|
|
|
#define str_version _("ubl-settings-bootloader version: ")
|
|
|
#define local_read_error _("Local configuration reading error")
|
|
|
#define global_read_error _("Global configuration read error")
|
|
|
#define local_write_error _("Local configuration write error")
|
|
|
#define global_write_error _("Global configuration write error")
|
|
|
#define error_save_all _("Error saved local and global configuration")
|
|
|
#define local_load_ok _("Local configuration downloaded successfully")
|
|
|
#define global_load_ok _("Global configuration downloaded successfully")
|
|
|
#define local_ok_written _("Local configuration successfully written")
|
|
|
#define global_ok_written _("Global configuration successfully written")
|
|
|
#define successfully_save_all _("Successfully saved local and global configuration")
|
|
|
#define nothing_save _("Nothing to save!")
|
|
|
#define program_as_root _("The program must be run as root")
|
|
|
#define str_active _("Active")
|
|
|
#define str_option _("Option")
|
|
|
#define str_description _("Description")
|
|
|
#define str_help_h _("GTK settings bootloader for UBLinux\n""\n""Usage: ubl-settings-bootloader [OPTIONS...]\n""Options:\n"" -h, --help\t Show this help\n"" -V, --version\t Show package version\n"" --lock-help Lock utility help\n"" --lock-save Lock saving local and global configuration\n"" --lock-save-local Lock save global configuration\n"" --lock-save-global Lock load global configuration\n"" --lock-load-global Lock load global configuration\n")
|
|
|
#define no_recognized _("Argument not recognized\n")
|
|
|
|
|
|
|
|
|
#define global_load "ubconfig --default --source global get boot"
|
|
|
#define system_load "ubconfig --default --source system get boot"
|
|
|
#define global_save "ubconfig --target global set boot "
|
|
|
#define system_save "ubconfig --target system set boot "
|
|
|
#define global_remove "ubconfig --target global remove boot "
|
|
|
#define system_remove "ubconfig --target system remove boot "
|
|
|
#define link_doc "https://wiki.ublinux.com/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-bootloader"
|
|
|
#define cmd_xdg "xdg-open "
|
|
|
#define cmd_execute "su -l %s -c \" DISPLAY=$DISPLAY %s \""
|
|
|
#define icon_checked "com.ublinux.ubl-settings-bootloader.checked"
|
|
|
#define icon_warning "com.ublinux.ubl-settings-bootloader.warning"
|
|
|
#define kernel_csv "cmdline-linux.csv"
|
|
|
#define IPT_csv "grub-terminal-input.csv"
|
|
|
#define OTT_csv "grub-terminal-output.csv"
|
|
|
#define path_app "/usr/bin/"
|
|
|
#define path_glade "/usr/share/ubl-settings-bootloader/ui/ubl-settings-bootloader.glade"
|
|
|
#define path_css "/usr/share/ubl-settings-bootloader/css/ubl-settings-bootloader.css"
|
|
|
#define app_name "ubl-settings-bootloader"
|
|
|
#define path_resources "/usr/share/ubl-settings-bootloader"
|
|
|
#define path_img_head_background "/usr/share/ubl-settings-bootloader/images/logo-background.png"
|
|
|
#define cmd_pars_list_os "/usr/lib/ublinux/scripts/grub-functions exec_get_all_menuentry"
|
|
|
#define cmd_last_launched_os "/usr/lib/ublinux/scripts/grub-functions exec_get_last_menuentry"
|
|
|
#define info_box_ok_css "boxInfoMessOK"
|
|
|
#define info_box_error_css "boxInfoMessError"
|
|
|
|
|
|
class CmdArgParser : public Glib::OptionGroup
|
|
|
{
|
|
|
public:
|
|
|
CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help);
|
|
|
::Window GetSocketID() const;
|
|
|
|
|
|
private:
|
|
|
int m_socketID = 0;
|
|
|
|
|
|
};
|
|
|
|
|
|
class MainWindow : public Gtk::ApplicationWindow {
|
|
|
public:
|
|
|
class ModelColumns : public Gtk::TreeModel::ColumnRecord {
|
|
|
public:
|
|
|
ModelColumns() {add(check_button), add(name); add(description); }
|
|
|
//Gtk::TreeModelColumn<Gtk::CheckButton> check_button;
|
|
|
Gtk::TreeModelColumn<bool> check_button;
|
|
|
Gtk::TreeModelColumn<Glib::ustring> name;
|
|
|
Gtk::TreeModelColumn<Glib::ustring> description;
|
|
|
};
|
|
|
ModelColumns m_columns;
|
|
|
Glib::RefPtr<Gtk::Builder> builder;
|
|
|
Gtk::SpinButton *spbSecond;
|
|
|
Gtk::Label *lblInfoSeconds;
|
|
|
Gtk::Label *lblInfoDefaultDonw;
|
|
|
Gtk::Label *lblInfoCommand;
|
|
|
Gtk::Label *lblInfoCommand1;
|
|
|
Gtk::Label *lblHeaderAboutTopic;
|
|
|
Gtk::Label *lblInfoCommand2;
|
|
|
Gtk::Label *lblLoadMenu;
|
|
|
Gtk::Label *lblInfoInputTerminal;
|
|
|
Gtk::Label *lblInfoOutputTerminal;
|
|
|
Gtk::Label *lblHeaderName;
|
|
|
Gtk::Label *lblInfoHead;
|
|
|
Gtk::CheckButton *chbVgaText;
|
|
|
Gtk::CheckButton *chbLoadVariantSelectionTimer;
|
|
|
Gtk::Entry *entryKernel;
|
|
|
Gtk::Entry *entryIPT;
|
|
|
Gtk::Entry *entryOTT;
|
|
|
Gtk::Box *boxColor;
|
|
|
Gtk::AboutDialog *aboutWindows;
|
|
|
Gtk::MenuItem *btnAbout;
|
|
|
Gtk::MenuItem *btnSynopsis;
|
|
|
Gtk::MenuItem *btnSaveLocalGlob;
|
|
|
Gtk::MenuItem *btnSaveLocal;
|
|
|
Gtk::MenuItem *btnSaveGlob;
|
|
|
Gtk::MenuItem *btnLoadGlob;
|
|
|
Gtk::MenuItem *btnLoadLocal;
|
|
|
Gtk::Button *btnLoad;
|
|
|
Gtk::Button *btnSave;
|
|
|
Gtk::Button *btnSettings;
|
|
|
Gtk::Widget *boxButton;
|
|
|
Gtk::Widget *boxSave;
|
|
|
Gtk::Box *boxInfoError;
|
|
|
Gtk::Box *boxWidgetAll;
|
|
|
Gtk::Label *lblWarning;
|
|
|
Gtk::Image *imgInfo;
|
|
|
Gtk::ButtonBox *btnBoxAboutDialog;
|
|
|
Gtk::TreeView *treeViewKernel;
|
|
|
Gtk::TreeView *treeViewIPT;
|
|
|
Gtk::TreeView *treeViewOTT;
|
|
|
Gtk::Image *imgBG;
|
|
|
Gtk::Overlay *overHead;
|
|
|
Gtk::ComboBoxText *cmbDefaultDonw;
|
|
|
Gtk::ComboBoxText *cmbDownloadMode;
|
|
|
Gtk::CheckButton *chbSecurityLogin;
|
|
|
Gtk::CheckButton *chbPasswordProtecc;
|
|
|
Gtk::Entry *entrySecurityLogin;
|
|
|
Gtk::Entry *entryPasswordProtecc;
|
|
|
Gtk::Label *lblHeadeWndWeb;
|
|
|
|
|
|
Gtk::Label *lblwebHeaderName;
|
|
|
Gtk::Label *lblhelpText;
|
|
|
Gtk::Label *lblhelpHeader;
|
|
|
Gtk::CheckButton *chkAlwaysOpenHelp;
|
|
|
Gtk::Button *btnReadHelp;
|
|
|
Gtk::Button *btnCancelHelp;
|
|
|
Gtk::Window *wndShowWeb;
|
|
|
|
|
|
std::vector<std::string> vec_Option_kernel;
|
|
|
std::vector<std::string> vec_Option_IPT;
|
|
|
std::vector<std::string> vec_Option_OTT;
|
|
|
|
|
|
Glib::RefPtr<Gtk::ListStore> list_store_kernel;
|
|
|
Glib::RefPtr<Gtk::ListStore> list_store_IPT;
|
|
|
Glib::RefPtr<Gtk::ListStore> list_store_OTT;
|
|
|
#ifdef WEBKIT_FOUND
|
|
|
Gtk::Window *wndWeb;
|
|
|
Gtk::Widget *three;
|
|
|
WebKitWebView *one;
|
|
|
#endif
|
|
|
|
|
|
void set_entry_to_tree_view(Glib::RefPtr<Gtk::ListStore> &list_store, Gtk::Entry &entry, std::vector<std::string> &vec_Option, int size, string key);
|
|
|
Gtk::TreeModel::Row row_kernel;
|
|
|
Gtk::TreeModel::Row row_IPT;
|
|
|
Gtk::TreeModel::Row row_OTT;
|
|
|
std::map <string, string> map_cmd_selection;
|
|
|
std::map <string, string> map_global_cmd_selection;
|
|
|
std::map <string, string> map_local_cmd_selection;
|
|
|
|
|
|
Gtk::Label *lblDownloadMode;
|
|
|
Lib_save::Save obj_save = Lib_save::Save();
|
|
|
Lib_Load::Load obj_load = Lib_Load::Load();
|
|
|
vector<string> vec_param_names;
|
|
|
My_Process::My_Process_system obj_process_system = My_Process::My_Process_system();
|
|
|
My_Process::My_Process_call obj_process_call = My_Process::My_Process_call();
|
|
|
bool flag_load = false;
|
|
|
bool flag_save_all = false;
|
|
|
bool flag_blocked_tree_view = false;
|
|
|
bool flag_save_block = false;
|
|
|
bool flag_open_browser = false;
|
|
|
string str_last_launched_os = "";
|
|
|
int index_error = 0;
|
|
|
string str_flag_load = "";
|
|
|
size_t size_kernel = 0;
|
|
|
size_t size_IPT = 0;
|
|
|
size_t size_OTT = 0;
|
|
|
Glib::RefPtr<Gtk::StyleContext> boxInfo;
|
|
|
string str_cmd_error = "";
|
|
|
template<typename Type>
|
|
|
struct Result{
|
|
|
Type response;
|
|
|
int error;
|
|
|
};
|
|
|
std::map <string, string> map_cmd_error;
|
|
|
|
|
|
MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder);
|
|
|
MainWindow(Glib::RefPtr<Gtk::Builder> const& builder);
|
|
|
~MainWindow();
|
|
|
void open_browser();
|
|
|
void get_menu_boot(std::map <string, string> &map_temp);
|
|
|
void set_row_all(std::map <string, string> &map_cmd, Glib::RefPtr<Gtk::ListStore> &list_store, vector<string> &list_params, size_t size,string key);
|
|
|
void set_row(Glib::RefPtr<Gtk::ListStore> &list_store, int size, std::string name, bool flag_chbox);
|
|
|
void get_builder();
|
|
|
bool gui_exit(GdkEventAny*);
|
|
|
void init_dict(string flag_load);
|
|
|
void add_CSS();
|
|
|
void show_pass();
|
|
|
void localization();
|
|
|
void event();
|
|
|
void settings();
|
|
|
string pars_last_launched_os();
|
|
|
vector<string> pars_os(vector<string> &os_control_list);
|
|
|
void fn_event_intelMax1();
|
|
|
void write_list_entry_os(vector<string> &os_control_list);
|
|
|
void fn_event_intelMax4();
|
|
|
void synopsis_show();
|
|
|
void set_data_cfg();
|
|
|
void set_active_boot_second();
|
|
|
void get_download_mode(std::map <string, string> &map_temp);
|
|
|
void view_add_cell(Gtk::TreeModel::Row &row, Glib::RefPtr<Gtk::ListStore> list_store_m , std::array<std::vector<std::string>, 5> &arr_view, size_t index);
|
|
|
void wrapper_system(string cmd, string thread_str);
|
|
|
struct Result<string> wrapper_call(string cmd);
|
|
|
void log_mess_error(string &cmd);
|
|
|
void wrapper_save_all_cfg();
|
|
|
void wrapper_save_local_cfg();
|
|
|
void wrapper_save_global_cfg();
|
|
|
bool save_template(string cmd, string cmd_remove, string flag_save);
|
|
|
void view_add_colums(Gtk::TreeView &treeView);
|
|
|
vector<string> read_file_and_view(string file_name ,Gtk::TreeModel::Row &row, Glib::RefPtr<Gtk::ListStore> list_store_m);
|
|
|
void download_local_cfg();
|
|
|
void template_open_browser();
|
|
|
void download_globl_cfg();
|
|
|
void flag_block_gui();
|
|
|
void info_status_app(string stule);
|
|
|
bool check_save(string flag_save, string key_name);
|
|
|
void info_warning_error(int mess);
|
|
|
int check_root();
|
|
|
bool focus_out_txt_kernel(GdkEventFocus*);
|
|
|
bool focus_out_txt_IPT(GdkEventFocus*);
|
|
|
bool focus_out_txt_OTT(GdkEventFocus*);
|
|
|
void fill_in_view();
|
|
|
bool focus_tree_view(GdkEventFocus*);
|
|
|
void set_security_login();
|
|
|
void get_security_login(std::map <string, string> &map_temp);
|
|
|
bool check_flag_save(string flag_save);
|
|
|
void set_download_mode();
|
|
|
void change_password_protecc();
|
|
|
bool focus_out_txt_login(GdkEventFocus*);
|
|
|
void change_security_login();
|
|
|
void get_default_load(std::map <string, string> &map_temp);
|
|
|
bool focus_out_txt_password(GdkEventFocus*);
|
|
|
void get_password_protec(std::map <string, string> &map_temp);
|
|
|
void set_password_protec();
|
|
|
void set_entry(Gtk::Entry* entry , std::map<string, string> &map_temp, string key);
|
|
|
void load_template(std::map<string, string>* map_temp, string cmd);
|
|
|
vector<string> get_setting_entry_all(string key, std::map <string, string>* map_temp);
|
|
|
void cmd_entry_all(Gtk::Entry &entry, string cmd_settings, string cmd_remove);
|
|
|
void item_selected_kernel(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&);
|
|
|
void item_selected_OTT(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&);
|
|
|
void item_selected_IPT(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&);
|
|
|
string template_item_selected(int size, Glib::RefPtr<Gtk::ListStore> &list_store, string key);
|
|
|
};
|
|
|
|
|
|
class SettingsPlug : public Gtk::Plug{
|
|
|
public:
|
|
|
Gtk::Window *window;
|
|
|
SettingsPlug(::Window p_socketID, Glib::RefPtr<Gtk::Builder> builder);
|
|
|
|
|
|
private:
|
|
|
Gtk::Widget *plugBox;
|
|
|
Gtk::Widget *parent;
|
|
|
};
|
|
|
|
|
|
void help();
|
|
|
|
|
|
|