From d543938160a5679a723d85e041e9b29b3c39fc9d Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Fri, 23 Aug 2019 16:22:16 -0300 Subject: [PATCH] Fixing use of deprecated methods. --- src/dialogs/hostselect.c | 49 +++++++++++++++++++++++++++++++++++++++++++++---- src/include/v3270.h | 1 - src/terminal/widget.c | 12 +++--------- src/trace/trace.c | 8 +++++++- 4 files changed, 55 insertions(+), 15 deletions(-) diff --git a/src/dialogs/hostselect.c b/src/dialogs/hostselect.c index c729599..1435285 100644 --- a/src/dialogs/hostselect.c +++ b/src/dialogs/hostselect.c @@ -30,6 +30,7 @@ #include "private.h" #include #include + #include /*--[ Widget definition ]----------------------------------------------------------------------------*/ @@ -241,12 +242,37 @@ LIB3270_EXPORT void v3270_host_select_set_session(GtkWidget *w, GtkWidget *sessi V3270HostSelectWidget *widget = GTK_V3270HostSelectWidget(w); widget->hSession = v3270_get_session(session); - gtk_entry_set_text(widget->input.entry[ENTRY_HOSTNAME],lib3270_get_hostname(widget->hSession)); - gtk_entry_set_text(widget->input.entry[ENTRY_SRVCNAME],lib3270_get_srvcname(widget->hSession)); + g_autofree gchar * url = g_strdup(lib3270_get_url(widget->hSession)); + debug("URL=[%s]",url); + + gchar *hostname = strstr(url,"://"); + if(!hostname) + { + g_message("Invalid URL: \"%s\" (no scheme)",url); + } + else + { + hostname += 3; + + gchar *srvcname = strchr(hostname,':'); + + if(srvcname) + { + *(srvcname++) = 0; + } + else + { + srvcname = "telnet"; + } + + gtk_entry_set_text(widget->input.entry[ENTRY_HOSTNAME],hostname); + gtk_entry_set_text(widget->input.entry[ENTRY_SRVCNAME],srvcname); + + } LIB3270_HOST_TYPE type = lib3270_get_host_type(widget->hSession); - gtk_toggle_button_set_active(widget->input.ssl,lib3270_get_secure_host(widget->hSession) != 0); + gtk_toggle_button_set_active(widget->input.ssl,g_str_has_prefix(url,"tn3270s://") != 0); // Set host type { @@ -349,10 +375,25 @@ int v3270_host_select_apply(GtkWidget *w) V3270HostSelectWidget *widget = GTK_V3270HostSelectWidget(w); + g_autofree gchar * url = + g_strconcat( + (gtk_toggle_button_get_active(widget->input.ssl) ? "tn3270s://" : "tn3270://"), + gtk_entry_get_text(widget->input.entry[ENTRY_HOSTNAME]), + ":", + gtk_entry_get_text(widget->input.entry[ENTRY_SRVCNAME]), + NULL + ); + + debug("URL=[%s]",url); + lib3270_set_url(widget->hSession,url); + + /* lib3270_set_hostname(widget->hSession,gtk_entry_get_text(widget->input.entry[ENTRY_HOSTNAME])); lib3270_set_srvcname(widget->hSession,gtk_entry_get_text(widget->input.entry[ENTRY_SRVCNAME])); - lib3270_set_host_type(widget->hSession,widget->type); + */ + lib3270_set_host_type(widget->hSession,widget->type); return lib3270_reconnect(widget->hSession,0); + } diff --git a/src/include/v3270.h b/src/include/v3270.h index 48e335d..6b3e29c 100644 --- a/src/include/v3270.h +++ b/src/include/v3270.h @@ -240,7 +240,6 @@ LIB3270_EXPORT int v3270_set_host_type_by_name(GtkWidget *widget, const char *name); LIB3270_EXPORT void v3270_set_url(GtkWidget *widget, const gchar *uri); - LIB3270_EXPORT const gchar * v3270_get_hostname(GtkWidget *widget); LIB3270_EXPORT const char * v3270_get_luname(GtkWidget *widget); LIB3270_EXPORT GtkWidget * v3270_get_default_widget(void); diff --git a/src/terminal/widget.c b/src/terminal/widget.c index c40503d..77a9b2d 100644 --- a/src/terminal/widget.c +++ b/src/terminal/widget.c @@ -868,10 +868,10 @@ static void v3270_activate(GtkWidget *widget) if(lib3270_connected(terminal->host)) lib3270_enter(terminal->host); - else if(lib3270_get_hostname(terminal->host)) + else if(lib3270_get_url(terminal->host)) v3270_reconnect(widget); else - g_warning("Terminal widget %p activated without connection or valid hostname",terminal); + g_warning("Terminal widget %p activated without connection or valid url",terminal); } const GtkWidgetClass * v3270_get_parent_class(void) @@ -900,13 +900,7 @@ LIB3270_EXPORT void v3270_set_url(GtkWidget *widget, const gchar *uri) lib3270_set_url(GTK_V3270(widget)->host,uri); } -LIB3270_EXPORT const gchar * v3270_get_hostname(GtkWidget *widget) -{ - g_return_val_if_fail(GTK_IS_V3270(widget),""); - return lib3270_get_hostname(GTK_V3270(widget)->host); -} - -LIB3270_EXPORT const gchar * v3270_get_luname(GtkWidget *widget) +LIB3270_EXPORT const gchar * v3270_get_luname(GtkWidget *widget) { g_return_val_if_fail(GTK_IS_V3270(widget),""); return lib3270_get_luname(GTK_V3270(widget)->host); diff --git a/src/trace/trace.c b/src/trace/trace.c index 563469b..ceb61dd 100644 --- a/src/trace/trace.c +++ b/src/trace/trace.c @@ -355,7 +355,13 @@ { size_t ix; - static const LIB3270_TOGGLE toggles[] = { LIB3270_TOGGLE_DS_TRACE, LIB3270_TOGGLE_NETWORK_TRACE, LIB3270_TOGGLE_EVENT_TRACE, LIB3270_TOGGLE_SSL_TRACE, LIB3270_TOGGLE_SCREEN_TRACE}; + static const LIB3270_TOGGLE toggles[] = { + LIB3270_TOGGLE_DS_TRACE, + LIB3270_TOGGLE_NETWORK_TRACE, + LIB3270_TOGGLE_EVENT_TRACE, + LIB3270_TOGGLE_SSL_TRACE, + LIB3270_TOGGLE_SCREEN_TRACE + }; for(ix = 0; ix < G_N_ELEMENTS(toggles); ix++) { -- libgit2 0.21.2