From 10ddee279f8191f663745aa311ba20400e72fa9e Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 19 Apr 2024 09:46:41 +0600 Subject: [PATCH 1/4] Fixes and updates --- source/ubl-settings-system.c | 14 +++++++++++++- source/ubl-settings-system.h | 14 ++++++++------ source/ubl-strings.h | 4 +++- ubl-settings-system.pot | 6 +++++- ubl-settings-system_ru.po | 4 ++++ 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index b4b7c6d..f524d0c 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -443,6 +443,7 @@ domain_info_window *yon_information_window_new(){ domain_info_window *window = malloc(sizeof(domain_info_window)); window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); + window->HeadLabel = yon_gtk_builder_get_widget(builder,"HeadLabel"); window->ExecuteTerminal = yon_gtk_builder_get_widget(builder,"ExecuteTerminal"); window->TerminalScroll = yon_gtk_builder_get_widget(builder,"TerminalScroll"); yon_gtk_widget_set_scroll_window_for_scroll(window->Window,GTK_SCROLLBAR(window->TerminalScroll)); @@ -476,6 +477,8 @@ void on_domain_connect(GtkWidget *self, dictionary *dict){ int size; domain_info_window *dialog = yon_information_window_new(); + gtk_window_set_title(GTK_WINDOW(dialog->Window),DOMAIN_CONNECTING_LABEL); + gtk_label_set_text(GTK_LABEL(dialog->HeadLabel),DOMAIN_CONNECTING_LABEL); yon_terminal_integrated_start(dialog->ExecuteTerminal,domain_connect_command(adress,login,password,final),NULL,NULL); gtk_entry_set_text(GTK_ENTRY(widgets->DomainEntry),adress); gtk_widget_show(dialog->Window); @@ -484,7 +487,10 @@ void on_domain_connect(GtkWidget *self, dictionary *dict){ void on_status_clicked(GtkWidget *self, connection_window *window){ domain_info_window *dialog = yon_information_window_new(); - // yon_terminal_integrated_start(dialog->ExecuteTerminal,domain_connect_command(adress,login,password,final),NULL,NULL); + char *target = (char*)gtk_entry_get_text(GTK_ENTRY(window->AdressEntry)); + if (!yon_char_is_empty(target)){ + yon_terminal_integrated_start(dialog->ExecuteTerminal,domain_info(target),NULL,NULL); + } gtk_widget_show(dialog->Window); } @@ -521,6 +527,12 @@ gboolean on_main_window_domain_status_update(connection_window *window){ return 1; } +gboolean yon_update_thread(connection_window *window){ + pthread_t thread_id; + pthread_create(&thread_id, NULL, (void *)on_main_window_domain_status_update,window); + return 1; +} + connection_window *yon_connection_window_new(){ GtkBuilder *builder = gtk_builder_new_from_resource(glade_connection_path); connection_window *window = malloc(sizeof(connection_window)); diff --git a/source/ubl-settings-system.h b/source/ubl-settings-system.h index bc575be..cc98c2e 100644 --- a/source/ubl-settings-system.h +++ b/source/ubl-settings-system.h @@ -67,19 +67,19 @@ #define get_domain_info_command(target) yon_char_append("ubdomain-client list ",target) #define domains_seek_command "ubdomain-client discover" #define domain_connect_command(target,user,password, addition) yon_char_unite("ubdomain-client join",!yon_char_is_empty(user)?" --user \"":"",!yon_char_is_empty(user)?user:"",!yon_char_is_empty(user)?"\"":"",!yon_char_is_empty(password)?" --password \"":"",!yon_char_is_empty(password)?password:"",!yon_char_is_empty(password)?"\"":""," --domain \"",target,"\"", addition,NULL) -#define domain_disconnect_command(target,user,password) yon_char_unite("ubdomain-client join",!yon_char_is_empty(user)?" --user \"":"",!yon_char_is_empty(user)?user:"",!yon_char_is_empty(user)?"\"":"",!yon_char_is_empty(password)?" --password \"":"",!yon_char_is_empty(password)?password:"",!yon_char_is_empty(password)?"\"":""," --domain \"",target,"\"",NULL) -#define kerberos_addition_command(target) yon_char_unite("--domain_server \"",target,"\"",NULL) -#define dns_addition_command(target) yon_char_unite("--dns \"",target,"\"",NULL) -#define client_addition_command(target) yon_char_unite("--domain_client \"",target,"\"",NULL) +#define domain_disconnect_command(target,user,password) yon_char_unite("ubdomain-client leave",!yon_char_is_empty(user)?" --user \"":"",!yon_char_is_empty(user)?user:"",!yon_char_is_empty(user)?"\"":"",!yon_char_is_empty(password)?" --password \"":"",!yon_char_is_empty(password)?password:"",!yon_char_is_empty(password)?"\"":""," --domain \"",target,"\"",NULL) +#define kerberos_addition_command(target) yon_char_unite(" --domain_server \"",target,"\"",NULL) +#define dns_addition_command(target) yon_char_unite(" --dns \"",target,"\"",NULL) +#define client_addition_command(target) yon_char_unite(" --domain_client \"",target,"\"",NULL) -#define domain_info(target) yon_char_append("ubdomain-client discover --domain ",target) +#define domain_info(target) yon_char_unite("ubdomain-client discover --domain \"",target,"\"",NULL) #define domain_connected_icon "com.ublinux.ubl-settings-system.plug-connected-symbolic" #define domain_disconnected_icon "com.ublinux.ubl-settings-system.plug-disconnected-symbolic" #define domain_connect_check "ubdomain-client list|grep -q \"configured\"" -#define domain_check_alive(target) yon_char_unite("dig +time=1 +tries=1 -t SRV _ldap.tcp.",target," @",target," &>/dev/null",NULL) +#define domain_check_alive(target) yon_char_unite("timeout --kill-after=0.1 2 dig +time=1 +tries=1 +noall -t SRV _ldap._tcp.",target," @",target," &>/dev/null",NULL) #define DOMAIN "DOMAIN" #define DOMAIN_ADMANGER "DOMAIN[admanger]" @@ -180,6 +180,8 @@ typedef struct { typedef struct { GtkWidget *Window; + GtkWidget *HeadLabel; + GtkWidget *ExecuteTerminal; GtkWidget *TerminalScroll; } domain_info_window; diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 969e702..8e30f68 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -48,4 +48,6 @@ #define INFO_LABEL _("Domain information") #define CONNECTION_LABEL _("Domain connection") #define CHECK_NAME_LABEL _("Check domain name") -#define LIST_ALL_LABEL _("List all domains") \ No newline at end of file +#define LIST_ALL_LABEL _("List all domains") + +#define DOMAIN_CONNECTING_LABEL _("Connecting to domain") \ No newline at end of file diff --git a/ubl-settings-system.pot b/ubl-settings-system.pot index 3afbc8a..af889ce 100644 --- a/ubl-settings-system.pot +++ b/ubl-settings-system.pot @@ -166,7 +166,7 @@ msgid "Samba client" msgstr "" #: source/ubl-strings.h:47 -msgid "Switch client off or autometically" +msgid "Switch client off or automatically" msgstr "" #: source/ubl-strings.h:48 @@ -184,3 +184,7 @@ msgstr "" #: source/ubl-strings.h:51 msgid "List all domains" msgstr "" + +#: source/ubl-strings.h:53 +msgid "Connecting to domain" +msgstr "" diff --git a/ubl-settings-system_ru.po b/ubl-settings-system_ru.po index d0c0137..51ca3ff 100644 --- a/ubl-settings-system_ru.po +++ b/ubl-settings-system_ru.po @@ -186,6 +186,10 @@ msgstr "Проверить домен" msgid "List all domains" msgstr "Показать все домены" +#: source/ubl-strings.h:53 +msgid "Connecting to domain" +msgstr "Подключение к домену" + msgid "Version:" msgstr "Версия:" From 1f03dfee6f4062fd0047bd0c4a8ee3a9d0911576 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 19 Apr 2024 09:58:23 +0600 Subject: [PATCH 2/4] Changed icon to text at domain button, minor fixes --- source/ubl-settings-system.c | 4 +++- source/ubl-settings-system.h | 2 +- source/ubl-strings.h | 4 +++- ubl-settings-system.glade | 9 ++++----- ubl-settings-system.pot | 8 ++++++++ ubl-settings-system_ru.po | 8 ++++++++ 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index f524d0c..62a2373 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -507,7 +507,7 @@ void on_main_window_domain_status_clicked(GtkWidget *self, GtkEntryIconPosition if (!yon_char_is_empty(target)){ domain_info_window *window = yon_information_window_new(); gtk_widget_show(window->Window); - yon_terminal_integrated_start(window->ExecuteTerminal,domain_info(target),NULL,NULL); + yon_terminal_integrated_start(window->ExecuteTerminal,get_domain_info_command,NULL,NULL); } } } @@ -666,9 +666,11 @@ void config_init(){ void on_check_domain_connected(main_window *widgets){ if (!system(domain_connect_check)){ gtk_entry_set_icon_from_icon_name(GTK_ENTRY(widgets->DomainEntry),GTK_ENTRY_ICON_SECONDARY,domain_connected_icon); + gtk_button_set_label(GTK_BUTTON(widgets->DomainButton),DOMAIN_DISCONNECT_LABEL); main_config.domain_connected=1; } else { gtk_entry_set_icon_from_icon_name(GTK_ENTRY(widgets->DomainEntry),GTK_ENTRY_ICON_SECONDARY,domain_disconnected_icon); + gtk_button_set_label(GTK_BUTTON(widgets->DomainButton),DOMAIN_CONNECT_LABEL); main_config.domain_connected=0; } } diff --git a/source/ubl-settings-system.h b/source/ubl-settings-system.h index cc98c2e..3b16616 100644 --- a/source/ubl-settings-system.h +++ b/source/ubl-settings-system.h @@ -64,7 +64,7 @@ #define DOMAIN_get_command "ubconfig --source global get [network] DOMAIN" #define check_domain_access_command(targeet) yon_char_append("adcli info --domain ",target) -#define get_domain_info_command(target) yon_char_append("ubdomain-client list ",target) +#define get_domain_info_command "ubdomain-client list " #define domains_seek_command "ubdomain-client discover" #define domain_connect_command(target,user,password, addition) yon_char_unite("ubdomain-client join",!yon_char_is_empty(user)?" --user \"":"",!yon_char_is_empty(user)?user:"",!yon_char_is_empty(user)?"\"":"",!yon_char_is_empty(password)?" --password \"":"",!yon_char_is_empty(password)?password:"",!yon_char_is_empty(password)?"\"":""," --domain \"",target,"\"", addition,NULL) #define domain_disconnect_command(target,user,password) yon_char_unite("ubdomain-client leave",!yon_char_is_empty(user)?" --user \"":"",!yon_char_is_empty(user)?user:"",!yon_char_is_empty(user)?"\"":"",!yon_char_is_empty(password)?" --password \"":"",!yon_char_is_empty(password)?password:"",!yon_char_is_empty(password)?"\"":""," --domain \"",target,"\"",NULL) diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 8e30f68..70d26e3 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -50,4 +50,6 @@ #define CHECK_NAME_LABEL _("Check domain name") #define LIST_ALL_LABEL _("List all domains") -#define DOMAIN_CONNECTING_LABEL _("Connecting to domain") \ No newline at end of file +#define DOMAIN_CONNECTING_LABEL _("Connecting to domain") +#define DOMAIN_CONNECT_LABEL _("Connect to domain") +#define DOMAIN_DISCONNECT_LABEL _("Disconnect from domain") \ No newline at end of file diff --git a/ubl-settings-system.glade b/ubl-settings-system.glade index 101de1f..09f2dd0 100644 --- a/ubl-settings-system.glade +++ b/ubl-settings-system.glade @@ -131,10 +131,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False 5 - + True False Domain address: + 0 False @@ -156,14 +157,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + Connect to domain True True True Domain connection - image3 - False @@ -505,6 +503,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + diff --git a/ubl-settings-system.pot b/ubl-settings-system.pot index af889ce..358c17a 100644 --- a/ubl-settings-system.pot +++ b/ubl-settings-system.pot @@ -188,3 +188,11 @@ msgstr "" #: source/ubl-strings.h:53 msgid "Connecting to domain" msgstr "" + +#: source/ubl-strings.h:54 +msgid "Connect to domain" +msgstr "" + +#: source/ubl-strings.h:55 +msgid "Disconnect from domain" +msgstr "" diff --git a/ubl-settings-system_ru.po b/ubl-settings-system_ru.po index 51ca3ff..87fba24 100644 --- a/ubl-settings-system_ru.po +++ b/ubl-settings-system_ru.po @@ -190,6 +190,14 @@ msgstr "Показать все домены" msgid "Connecting to domain" msgstr "Подключение к домену" +#: source/ubl-strings.h:54 +msgid "Connect to domain" +msgstr "Войти в домен" + +#: source/ubl-strings.h:55 +msgid "Disconnect from domain" +msgstr "Выйти из домена" + msgid "Version:" msgstr "Версия:" From 871fa45b8b27728e97ef2db95201f48b1d32e9f6 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 19 Apr 2024 10:07:21 +0600 Subject: [PATCH 3/4] Domain button is inactive when domain address field is empty --- source/ubl-settings-system.c | 10 ++++++++++ ubl-settings-system.glade | 1 + 2 files changed, 11 insertions(+) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index 62a2373..a9ef47e 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -297,6 +297,14 @@ void yon_config_custom_save(){ template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_CUSTOM,config_get_command("system"),NULL); } +void yon_gtk_windget_set_sensitive_from_entry_emptiness(GtkEntry *self, GtkWidget *target){ + if (yon_char_is_empty(gtk_entry_get_text(self))){ + gtk_widget_set_sensitive(target,0); + } else { + gtk_widget_set_sensitive(target,1); + } +} + void on_locale_toggle(GtkCellRendererToggle *self,GtkTreePath* path,GtkTreeViewColumn* column,locals_window *window){ GtkTreeIter iter; GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(window->MainTree)); @@ -733,6 +741,8 @@ main_window *yon_main_window_complete(main_window *widgets){ g_signal_connect(G_OBJECT(widgets->DomainButton),"clicked",G_CALLBACK(on_domain_opened),widgets); g_signal_connect(G_OBJECT(widgets->DomainEntry),"icon-press",G_CALLBACK(on_main_window_domain_status_clicked),widgets); + g_signal_connect(G_OBJECT(widgets->DomainEntry),"changed",G_CALLBACK(yon_gtk_windget_set_sensitive_from_entry_emptiness),widgets->DomainButton); + g_timeout_add(1000,(GSourceFunc)on_check_domain_connected,widgets); gtk_widget_set_size_request(widgets->Window,800,-1); diff --git a/ubl-settings-system.glade b/ubl-settings-system.glade index 09f2dd0..2d6d2a2 100644 --- a/ubl-settings-system.glade +++ b/ubl-settings-system.glade @@ -159,6 +159,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Connect to domain True + False True True Domain connection From ad41d915b248ff22122640182c1e6ade21d5f7b2 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 19 Apr 2024 10:15:59 +0600 Subject: [PATCH 4/4] DOMAIN saving --- source/ubl-settings-system.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index a9ef47e..2cba00a 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -296,6 +296,13 @@ void yon_config_global_save(){ void yon_config_custom_save(){ template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_CUSTOM,config_get_command("system"),NULL); } + + void on_domain_address_save(GtkEntry *self){ + char *adress = (char*)gtk_entry_get_text(self); + if (!yon_char_is_empty(adress)){ + yon_config_register(DOMAIN,DOMAIN_get_command,adress); + } + } void yon_gtk_windget_set_sensitive_from_entry_emptiness(GtkEntry *self, GtkWidget *target){ if (yon_char_is_empty(gtk_entry_get_text(self))){ @@ -743,6 +750,8 @@ main_window *yon_main_window_complete(main_window *widgets){ g_signal_connect(G_OBJECT(widgets->DomainEntry),"icon-press",G_CALLBACK(on_main_window_domain_status_clicked),widgets); g_signal_connect(G_OBJECT(widgets->DomainEntry),"changed",G_CALLBACK(yon_gtk_windget_set_sensitive_from_entry_emptiness),widgets->DomainButton); + g_signal_connect(G_OBJECT(widgets->DomainEntry),"focus-out-event",G_CALLBACK(on_domain_address_save),NULL); + g_timeout_add(1000,(GSourceFunc)on_check_domain_connected,widgets); gtk_widget_set_size_request(widgets->Window,800,-1);