Commit d543938160a5679a723d85e041e9b29b3c39fc9d

Authored by Perry Werneck
1 parent b64fe560
Exists in master and in 1 other branch develop

Fixing use of deprecated methods.

src/dialogs/hostselect.c
... ... @@ -30,6 +30,7 @@
30 30 #include "private.h"
31 31 #include <hostselect.h>
32 32 #include <v3270/dialogs.h>
  33 + #include <lib3270/log.h>
33 34  
34 35 /*--[ Widget definition ]----------------------------------------------------------------------------*/
35 36  
... ... @@ -241,12 +242,37 @@ LIB3270_EXPORT void v3270_host_select_set_session(GtkWidget *w, GtkWidget *sessi
241 242 V3270HostSelectWidget *widget = GTK_V3270HostSelectWidget(w);
242 243 widget->hSession = v3270_get_session(session);
243 244  
244   - gtk_entry_set_text(widget->input.entry[ENTRY_HOSTNAME],lib3270_get_hostname(widget->hSession));
245   - gtk_entry_set_text(widget->input.entry[ENTRY_SRVCNAME],lib3270_get_srvcname(widget->hSession));
  245 + g_autofree gchar * url = g_strdup(lib3270_get_url(widget->hSession));
  246 + debug("URL=[%s]",url);
  247 +
  248 + gchar *hostname = strstr(url,"://");
  249 + if(!hostname)
  250 + {
  251 + g_message("Invalid URL: \"%s\" (no scheme)",url);
  252 + }
  253 + else
  254 + {
  255 + hostname += 3;
  256 +
  257 + gchar *srvcname = strchr(hostname,':');
  258 +
  259 + if(srvcname)
  260 + {
  261 + *(srvcname++) = 0;
  262 + }
  263 + else
  264 + {
  265 + srvcname = "telnet";
  266 + }
  267 +
  268 + gtk_entry_set_text(widget->input.entry[ENTRY_HOSTNAME],hostname);
  269 + gtk_entry_set_text(widget->input.entry[ENTRY_SRVCNAME],srvcname);
  270 +
  271 + }
246 272  
247 273 LIB3270_HOST_TYPE type = lib3270_get_host_type(widget->hSession);
248 274  
249   - gtk_toggle_button_set_active(widget->input.ssl,lib3270_get_secure_host(widget->hSession) != 0);
  275 + gtk_toggle_button_set_active(widget->input.ssl,g_str_has_prefix(url,"tn3270s://") != 0);
250 276  
251 277 // Set host type
252 278 {
... ... @@ -349,10 +375,25 @@ int v3270_host_select_apply(GtkWidget *w)
349 375  
350 376 V3270HostSelectWidget *widget = GTK_V3270HostSelectWidget(w);
351 377  
  378 + g_autofree gchar * url =
  379 + g_strconcat(
  380 + (gtk_toggle_button_get_active(widget->input.ssl) ? "tn3270s://" : "tn3270://"),
  381 + gtk_entry_get_text(widget->input.entry[ENTRY_HOSTNAME]),
  382 + ":",
  383 + gtk_entry_get_text(widget->input.entry[ENTRY_SRVCNAME]),
  384 + NULL
  385 + );
  386 +
  387 + debug("URL=[%s]",url);
  388 + lib3270_set_url(widget->hSession,url);
  389 +
  390 + /*
352 391 lib3270_set_hostname(widget->hSession,gtk_entry_get_text(widget->input.entry[ENTRY_HOSTNAME]));
353 392 lib3270_set_srvcname(widget->hSession,gtk_entry_get_text(widget->input.entry[ENTRY_SRVCNAME]));
354   - lib3270_set_host_type(widget->hSession,widget->type);
  393 + */
355 394  
  395 + lib3270_set_host_type(widget->hSession,widget->type);
356 396 return lib3270_reconnect(widget->hSession,0);
  397 +
357 398 }
358 399  
... ...
src/include/v3270.h
... ... @@ -240,7 +240,6 @@
240 240 LIB3270_EXPORT int v3270_set_host_type_by_name(GtkWidget *widget, const char *name);
241 241  
242 242 LIB3270_EXPORT void v3270_set_url(GtkWidget *widget, const gchar *uri);
243   - LIB3270_EXPORT const gchar * v3270_get_hostname(GtkWidget *widget);
244 243 LIB3270_EXPORT const char * v3270_get_luname(GtkWidget *widget);
245 244 LIB3270_EXPORT GtkWidget * v3270_get_default_widget(void);
246 245  
... ...
src/terminal/widget.c
... ... @@ -868,10 +868,10 @@ static void v3270_activate(GtkWidget *widget)
868 868  
869 869 if(lib3270_connected(terminal->host))
870 870 lib3270_enter(terminal->host);
871   - else if(lib3270_get_hostname(terminal->host))
  871 + else if(lib3270_get_url(terminal->host))
872 872 v3270_reconnect(widget);
873 873 else
874   - g_warning("Terminal widget %p activated without connection or valid hostname",terminal);
  874 + g_warning("Terminal widget %p activated without connection or valid url",terminal);
875 875 }
876 876  
877 877 const GtkWidgetClass * v3270_get_parent_class(void)
... ... @@ -900,13 +900,7 @@ LIB3270_EXPORT void v3270_set_url(GtkWidget *widget, const gchar *uri)
900 900 lib3270_set_url(GTK_V3270(widget)->host,uri);
901 901 }
902 902  
903   -LIB3270_EXPORT const gchar * v3270_get_hostname(GtkWidget *widget)
904   -{
905   - g_return_val_if_fail(GTK_IS_V3270(widget),"");
906   - return lib3270_get_hostname(GTK_V3270(widget)->host);
907   -}
908   -
909   -LIB3270_EXPORT const gchar * v3270_get_luname(GtkWidget *widget)
  903 +LIB3270_EXPORT const gchar * v3270_get_luname(GtkWidget *widget)
910 904 {
911 905 g_return_val_if_fail(GTK_IS_V3270(widget),"");
912 906 return lib3270_get_luname(GTK_V3270(widget)->host);
... ...
src/trace/trace.c
... ... @@ -355,7 +355,13 @@
355 355 {
356 356 size_t ix;
357 357  
358   - 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};
  358 + static const LIB3270_TOGGLE toggles[] = {
  359 + LIB3270_TOGGLE_DS_TRACE,
  360 + LIB3270_TOGGLE_NETWORK_TRACE,
  361 + LIB3270_TOGGLE_EVENT_TRACE,
  362 + LIB3270_TOGGLE_SSL_TRACE,
  363 + LIB3270_TOGGLE_SCREEN_TRACE
  364 + };
359 365  
360 366 for(ix = 0; ix < G_N_ELEMENTS(toggles); ix++)
361 367 {
... ...