From 6460e3d282a3aa2b4f19875273a62150a532cf04 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Mon, 24 Dec 2012 11:46:53 +0000 Subject: [PATCH] Ajustando diálogo e opções de linha de comando para tratar corretamente o tipo de host e número de cores --- src/include/lib3270/filetransfer.h | 2 +- src/include/pw3270.h | 2 +- src/lib3270/ft.c | 8 ++++---- src/pw3270/actions.c | 38 ++++++++++++++++++++++++++------------ src/pw3270/dialog.c | 14 -------------- src/pw3270/filetransfer.c | 2 +- src/pw3270/globals.h | 11 +++++------ src/pw3270/hostdialog.c | 14 ++++++++++++++ src/pw3270/main.c | 22 +++++++++------------- src/pw3270/window.c | 23 +++++++++++++++++++++-- 10 files changed, 82 insertions(+), 54 deletions(-) diff --git a/src/include/lib3270/filetransfer.h b/src/include/lib3270/filetransfer.h index 3bfbba5..2f2e6a6 100644 --- a/src/include/lib3270/filetransfer.h +++ b/src/include/lib3270/filetransfer.h @@ -56,7 +56,7 @@ LIB3270_FT_OPTION_ASCII = 0x0002, LIB3270_FT_OPTION_CRLF = 0x0004, LIB3270_FT_OPTION_APPEND = 0x0008, - LIB3270_FT_OPTION_TSO = 0x0010, +// LIB3270_FT_OPTION_TSO = 0x0010, LIB3270_FT_OPTION_REMAP_ASCII = 0x0020 } LIB3270_FT_OPTION; diff --git a/src/include/pw3270.h b/src/include/pw3270.h index 7f301a3..3728b5a 100644 --- a/src/include/pw3270.h +++ b/src/include/pw3270.h @@ -51,7 +51,7 @@ typedef struct _pw3270Class pw3270Class; - LIB3270_EXPORT GtkWidget * pw3270_new(const gchar *host); + LIB3270_EXPORT GtkWidget * pw3270_new(const gchar *host, const gchar *systype, unsigned short colors); LIB3270_EXPORT void pw3270_set_host(GtkWidget *widget, const gchar *uri); LIB3270_EXPORT gboolean pw3270_get_toggle(GtkWidget *widget, LIB3270_TOGGLE ix); LIB3270_EXPORT H3270 * pw3270_get_session(GtkWidget *widget); diff --git a/src/lib3270/ft.c b/src/lib3270/ft.c index a24320e..7174c4e 100644 --- a/src/lib3270/ft.c +++ b/src/lib3270/ft.c @@ -322,13 +322,13 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); (ft->flags & LIB3270_FT_OPTION_APPEND) ? " append" : "" ); + trace("tso=%s",hSession->options & LIB3270_OPTION_TSO ? "yes" : "No"); + if(!(ft->flags & LIB3270_FT_OPTION_RECEIVE)) { // Sending file - trace("tso=%d",ft->flags & LIB3270_FT_OPTION_TSO); - - if(ft->flags & LIB3270_FT_OPTION_TSO) + if(hSession->options & LIB3270_OPTION_TSO) { // TSO Host if(recfm > 0) @@ -375,7 +375,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); if(*op) { - if(ft->flags & LIB3270_FT_OPTION_TSO) + if(hSession->options & LIB3270_OPTION_TSO) snconcat(buffer,4095," %s",op+1); else snconcat(buffer,4095," (%s",op+1); diff --git a/src/pw3270/actions.c b/src/pw3270/actions.c index 4d96068..17a2cd0 100644 --- a/src/pw3270/actions.c +++ b/src/pw3270/actions.c @@ -67,27 +67,41 @@ static void lib3270_action(GtkAction *action, GtkWidget *widget) static void connect_action(GtkAction *action, GtkWidget *widget) { - gchar *host = (gchar *) g_object_get_data(G_OBJECT(action),"host"); + const gchar * host = (const gchar *) g_object_get_data(G_OBJECT(action),"host"); + const gchar * systype = (const gchar *) g_object_get_data(G_OBJECT(action),"type"); + const gchar * colortype = (const gchar *) g_object_get_data(G_OBJECT(action),"colors"); + unsigned short colors; trace_action(action,widget); + if(!systype) + systype = get_string_from_config("host","systype","S390"); + + if(colortype) + colors = atoi(colortype); + else + colors = (unsigned short) get_integer_from_config("host","colortype",16); + + trace("System type=%s System colors=%d",systype,(int) colors); + + v3270_set_session_color_type(widget,colors); + v3270_set_session_options(widget,pw3270_options_by_hosttype(systype)); + if(host) { - v3270_set_session_options(widget,0); - v3270_set_session_color_type(widget,0); v3270_connect(widget,host); - return; } - - host = get_string_from_config("host","uri",""); - if(*host) + else { - load_3270_options_from_config(widget); - v3270_connect(widget,host); - g_free(host); - return; + gchar *ptr = get_string_from_config("host","uri",""); + if(*ptr) + { + v3270_connect(widget,ptr); + g_free(ptr); + return; + } + g_free(ptr); } - g_free(host); hostname_action(action,widget); } diff --git a/src/pw3270/dialog.c b/src/pw3270/dialog.c index ee5a2b2..34bbb5e 100644 --- a/src/pw3270/dialog.c +++ b/src/pw3270/dialog.c @@ -51,20 +51,6 @@ /*--[ Implement ]------------------------------------------------------------------------------------*/ - void load_3270_options_from_config(GtkWidget *widget) - { - int f; - LIB3270_OPTION opt = 0; - const LIB3270_OPTION_ENTRY *options = lib3270_get_option_list(); - - for(f=0;f - struct option - { - int colors; - }; - - #define ERROR_DOMAIN g_quark_from_static_string(PACKAGE_NAME) +#define ERROR_DOMAIN g_quark_from_static_string(PACKAGE_NAME) /*--[ Statics ]--------------------------------------------------------------------------------------*/ - static struct option cmdline_opt = { LIB3270_OPTION_DEFAULT }; static GtkWidget * toplevel = NULL; + static unsigned int syscolors = 16; + static const gchar * systype = NULL; #ifdef HAVE_GTKMAC GtkOSXApplication * osxapp = NULL; @@ -169,15 +165,15 @@ static gboolean datadir(const gchar *option_name, const gchar *value, gpointer d static gboolean optcolors(const gchar *option_name, const gchar *value, gpointer data, GError **error) { - static const unsigned char valid[] = { 2,8,16 }; + static const unsigned short valid[] = { 2,8,16 }; int f; - unsigned char optval = (unsigned char) atoi(value); + unsigned short optval = (unsigned short) atoi(value); for(f=0;fcolors = optval; + syscolors = optval; return TRUE; } } @@ -255,13 +251,14 @@ int main(int argc, char *argv[]) { "session", 's', 0, G_OPTION_ARG_STRING, &session_name, N_( "Session name" ), PACKAGE_NAME }, { "host", 'h', 0, G_OPTION_ARG_STRING, &host, N_( "Host to connect"), NULL }, { "colors", 'c', 0, G_OPTION_ARG_CALLBACK, optcolors, N_( "Set reported colors (8/16)" ), "16" }, + { "systype", 't', 0, G_OPTION_ARG_STRING, &system, N_( "Host system type" ), "S390" }, { NULL } }; GOptionContext * context = g_option_context_new (_("- 3270 Emulator for Gtk")); GError * error = NULL; - GOptionGroup * group = g_option_group_new( PACKAGE_NAME, NULL, NULL, &cmdline_opt, NULL); + GOptionGroup * group = g_option_group_new( PACKAGE_NAME, NULL, NULL, NULL, NULL); g_option_context_set_main_group(context, group); @@ -342,9 +339,8 @@ int main(int argc, char *argv[]) gtk_settings_set_string_property(settings,"gtk-menu-bar-accel","Menu",""); } - toplevel = pw3270_new(host); + toplevel = pw3270_new(host,systype,syscolors); pw3270_set_session_name(toplevel,session_name); - pw3270_set_session_color_type(toplevel,cmdline_opt.colors); // pw3270_set_session_options(toplevel,cmdline_opt.host); toplevel_setup(GTK_WINDOW(toplevel)); diff --git a/src/pw3270/window.c b/src/pw3270/window.c index 8e12801..87d3f6d 100644 --- a/src/pw3270/window.c +++ b/src/pw3270/window.c @@ -176,9 +176,28 @@ } - GtkWidget * pw3270_new(const gchar *host) + GtkWidget * pw3270_new(const gchar *host, const gchar *systype, unsigned short colors) { - GtkWidget *widget = g_object_new(GTK_TYPE_PW3270, NULL); + GtkWidget * widget = g_object_new(GTK_TYPE_PW3270, NULL); + + if(systype) + { + set_string_to_config("host","uri","%s",systype); + pw3270_set_session_options(widget,pw3270_options_by_hosttype(systype)); + } + else + { + gchar *ptr = get_string_from_config("host","systype","S390"); + pw3270_set_session_options(widget,pw3270_options_by_hosttype(ptr)); + g_free(ptr); + } + + if(colors) + set_integer_to_config("host","colortype",colors); + else + colors = get_integer_from_config("host","colortype",16); + + pw3270_set_session_color_type(widget,colors); if(host) { -- libgit2 0.21.2