Commit 9edc9bc36aec96d83f963d90a017cc661c96f41f

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

Reactivating spinner

spliting linux & windows I/O calls.
@@ -169,6 +169,12 @@ AC_SUBST(SCCS_USER,$USER) @@ -169,6 +169,12 @@ AC_SUBST(SCCS_USER,$USER)
169 AC_SUBST(SCCS_DATE,$sccs_date) 169 AC_SUBST(SCCS_DATE,$sccs_date)
170 170
171 dnl --------------------------------------------------------------------------- 171 dnl ---------------------------------------------------------------------------
  172 +dnl Check for libm (Required for spinner)
  173 +dnl ---------------------------------------------------------------------------
  174 +
  175 +AC_SEARCH_LIBS( [sin], [m], AC_DEFINE(HAVE_LIBM), AC_MSG_ERROR([libm not present.]))
  176 +
  177 +dnl ---------------------------------------------------------------------------
172 dnl Check for libintl 178 dnl Check for libintl
173 dnl --------------------------------------------------------------------------- 179 dnl ---------------------------------------------------------------------------
174 180
src/include/config.h.in
@@ -35,6 +35,7 @@ @@ -35,6 +35,7 @@
35 #undef PACKAGE_VERSION 35 #undef PACKAGE_VERSION
36 #undef PACKAGE_RELEASE 36 #undef PACKAGE_RELEASE
37 37
  38 + #undef HAVE_LIBM
38 #undef HAVE_GNOME 39 #undef HAVE_GNOME
39 #undef HAVE_GTKMAC 40 #undef HAVE_GTKMAC
40 41
src/v3270/iocallback.c 0 → 100644
@@ -0,0 +1,154 @@ @@ -0,0 +1,154 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como - e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 +#include <config.h>
  31 +#include <lib3270.h>
  32 +#include "private.h"
  33 +
  34 +static void * static_AddSource(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata);
  35 +static void static_RemoveSource(H3270 *session, void *id);
  36 +
  37 +static void * static_AddTimeOut(H3270 *session, unsigned long interval_ms, void (*proc)(H3270 *session));
  38 +static void static_RemoveTimeOut(H3270 *session, void * timer);
  39 +static int static_Sleep(H3270 *hSession, int seconds);
  40 +static int static_RunPendingEvents(H3270 *hSession, int wait);
  41 +
  42 +/*---[ Structs ]-------------------------------------------------------------------------------------------*/
  43 +
  44 + typedef struct _timer
  45 + {
  46 + unsigned char remove;
  47 + void * userdata;
  48 + void (*call)(H3270 *session);
  49 + H3270 * session;
  50 + } TIMER;
  51 +
  52 +/*---[ Implement ]-----------------------------------------------------------------------------------------*/
  53 +
  54 +static void * static_AddSource(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata)
  55 +{
  56 + return (void *) IO_source_new(session, fd, flag, call, userdata);
  57 +}
  58 +
  59 +static void static_RemoveSource(G_GNUC_UNUSED H3270 *session, void *id)
  60 +{
  61 + if(id)
  62 + g_source_destroy((GSource *) id);
  63 +}
  64 +
  65 +static gboolean do_timer(TIMER *t)
  66 +{
  67 + if(!t->remove)
  68 + t->call(t->session);
  69 + return FALSE;
  70 +}
  71 +
  72 +static void * static_AddTimeOut(H3270 *session, unsigned long interval, void (*call)(H3270 *session))
  73 +{
  74 + TIMER *t = g_malloc0(sizeof(TIMER));
  75 +
  76 + t->call = call;
  77 + t->session = session;
  78 +
  79 + g_timeout_add_full(G_PRIORITY_DEFAULT, (guint) interval, (GSourceFunc) do_timer, t, g_free);
  80 +
  81 + return t;
  82 +}
  83 +
  84 +static void static_RemoveTimeOut(G_GNUC_UNUSED H3270 *session, void * timer)
  85 +{
  86 + ((TIMER *) timer)->remove++;
  87 +}
  88 +
  89 +/*
  90 +struct bgParameter
  91 +{
  92 + gboolean running;
  93 + H3270 *session;
  94 + int rc;
  95 + int(*callback)(H3270 *session, void *);
  96 + void *parm;
  97 +
  98 +};
  99 +*/
  100 +
  101 +static int static_Sleep(G_GNUC_UNUSED H3270 *hSession, int seconds)
  102 +{
  103 + time_t end = time(0) + seconds;
  104 +
  105 + while(time(0) < end)
  106 + gtk_main_iteration();
  107 +
  108 + return 0;
  109 +}
  110 +
  111 +static int static_RunPendingEvents(G_GNUC_UNUSED H3270 *hSession, int wait)
  112 +{
  113 + int rc = 0;
  114 + while(gtk_events_pending())
  115 + {
  116 + rc = 1;
  117 + gtk_main_iteration();
  118 + }
  119 +
  120 + if(wait)
  121 + gtk_main_iteration();
  122 +
  123 + return rc;
  124 +}
  125 +
  126 +static void beep(G_GNUC_UNUSED H3270 *session)
  127 +{
  128 + gdk_display_beep(gdk_display_get_default());
  129 +}
  130 +
  131 +void v3270_register_io_handlers(G_GNUC_UNUSED v3270Class *cls)
  132 +{
  133 + static const struct lib3270_callbacks hdl =
  134 + {
  135 + sizeof(struct lib3270_callbacks),
  136 +
  137 + static_AddTimeOut,
  138 + static_RemoveTimeOut,
  139 +
  140 + static_AddSource,
  141 + static_RemoveSource,
  142 +
  143 + static_Sleep,
  144 + static_RunPendingEvents,
  145 + beep
  146 +
  147 + };
  148 +
  149 + if(lib3270_register_handlers(&hdl))
  150 + {
  151 + g_error("%s",_( "Can't set lib3270 I/O handlers" ) );
  152 + }
  153 +
  154 +}
src/v3270/linux/iosource.c
@@ -28,6 +28,7 @@ @@ -28,6 +28,7 @@
28 */ 28 */
29 29
30 #include <config.h> 30 #include <config.h>
  31 + #include <poll.h>
31 #include "../private.h" 32 #include "../private.h"
32 33
33 /*---[ Structs ]-------------------------------------------------------------------------------------------*/ 34 /*---[ Structs ]-------------------------------------------------------------------------------------------*/
@@ -43,8 +44,50 @@ @@ -43,8 +44,50 @@
43 void * userdata; 44 void * userdata;
44 } IO_Source; 45 } IO_Source;
45 46
  47 +static gboolean IO_prepare(GSource *source, gint *timeout);
  48 +static gboolean IO_check(GSource *source);
  49 +static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer user_data);
  50 +static void IO_finalize(GSource *source); /* Can be NULL */
  51 +static gboolean IO_closure(gpointer data);
  52 +
46 /*---[ Implement ]-----------------------------------------------------------------------------------------*/ 53 /*---[ Implement ]-----------------------------------------------------------------------------------------*/
47 54
  55 +GSource * IO_source_new(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata)
  56 +{
  57 + static GSourceFuncs IOSources =
  58 + {
  59 + IO_prepare,
  60 + IO_check,
  61 + IO_dispatch,
  62 + IO_finalize,
  63 + IO_closure,
  64 + NULL
  65 + };
  66 +
  67 + IO_Source *src = (IO_Source *) g_source_new(&IOSources,sizeof(IO_Source));
  68 +
  69 + src->fd = fd;
  70 + src->enabled = TRUE;
  71 + src->call = call;
  72 + src->userdata = userdata;
  73 + src->session = session;
  74 +
  75 + src->poll.fd = (int) fd;
  76 + src->poll.events = G_IO_HUP|G_IO_ERR;
  77 +
  78 + if(flag & LIB3270_IO_FLAG_READ)
  79 + src->poll.events |= G_IO_IN;
  80 +
  81 + if(flag & LIB3270_IO_FLAG_WRITE)
  82 + src->poll.events |= G_IO_OUT;
  83 +
  84 + g_source_attach((GSource *) src,NULL);
  85 + g_source_add_poll((GSource *) src,&src->poll);
  86 +
  87 + return (GSource *) src;
  88 +}
  89 +
  90 +
48 gboolean IO_prepare(G_GNUC_UNUSED GSource *source, G_GNUC_UNUSED gint *timeout) 91 gboolean IO_prepare(G_GNUC_UNUSED GSource *source, G_GNUC_UNUSED gint *timeout)
49 { 92 {
50 /* 93 /*
@@ -72,15 +115,18 @@ gboolean IO_check(GSource *source) @@ -72,15 +115,18 @@ gboolean IO_check(GSource *source)
72 * function was called, so the source should be checked again here. 115 * function was called, so the source should be checked again here.
73 * 116 *
74 */ 117 */
75 - struct pollfd fds; 118 + if(((IO_Source *) source)->enabled)
  119 + {
  120 + struct pollfd fds;
76 121
77 - memset(&fds,0,sizeof(fds)); 122 + memset(&fds,0,sizeof(fds));
78 123
79 - fds.fd = ((IO_Source *) source)->poll.fd;  
80 - fds.events = ((IO_Source *) source)->poll.events; 124 + fds.fd = ((IO_Source *) source)->poll.fd;
  125 + fds.events = ((IO_Source *) source)->poll.events;
81 126
82 - if(poll(&fds,1,0) > 0)  
83 - return TRUE; 127 + if(poll(&fds,1,0) > 0)
  128 + return TRUE;
  129 + }
84 130
85 return FALSE; 131 return FALSE;
86 } 132 }
src/v3270/oia.c
@@ -104,6 +104,8 @@ static gint draw_spinner(cairo_t *cr, GdkRectangle *r, GdkRGBA *color, gint step @@ -104,6 +104,8 @@ static gint draw_spinner(cairo_t *cr, GdkRectangle *r, GdkRGBA *color, gint step
104 step++; 104 step++;
105 step %= num_steps; 105 step %= num_steps;
106 106
  107 + debug("%s step=%d",__FUNCTION__,step);
  108 +
107 for (i = 0; i < num_steps; i++) 109 for (i = 0; i < num_steps; i++)
108 { 110 {
109 gint inset = 0.7 * radius; 111 gint inset = 0.7 * radius;
src/v3270/private.h
@@ -336,10 +336,6 @@ G_GNUC_INTERNAL gboolean v3270_scroll_event(GtkWidget *widget, GdkEventScroll * @@ -336,10 +336,6 @@ G_GNUC_INTERNAL gboolean v3270_scroll_event(GtkWidget *widget, GdkEventScroll *
336 G_GNUC_INTERNAL const struct v3270_ssl_status_msg * v3270_get_ssl_status_msg(GtkWidget *widget); 336 G_GNUC_INTERNAL const struct v3270_ssl_status_msg * v3270_get_ssl_status_msg(GtkWidget *widget);
337 337
338 // I/O Callbacks 338 // I/O Callbacks
339 -G_GNUC_INTERNAL gboolean IO_prepare(GSource *source, gint *timeout);  
340 -G_GNUC_INTERNAL gboolean IO_check(GSource *source);  
341 -G_GNUC_INTERNAL gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer user_data);  
342 -G_GNUC_INTERNAL void IO_finalize(GSource *source); /* Can be NULL */  
343 -G_GNUC_INTERNAL gboolean IO_closure(gpointer data); 339 +G_GNUC_INTERNAL GSource * IO_source_new(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata);
344 340
345 G_END_DECLS 341 G_END_DECLS
src/v3270/widget.c
@@ -940,7 +940,7 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title @@ -940,7 +940,7 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title
940 940
941 941
942 cbk->update = v3270_update_char; 942 cbk->update = v3270_update_char;
943 - cbk->changed = changed; 943 + cbk->changed = changed;
944 cbk->set_timer = set_timer; 944 cbk->set_timer = set_timer;
945 945
946 cbk->set_selection = set_selection; 946 cbk->set_selection = set_selection;
src/v3270/windows/iosource.c
@@ -43,8 +43,49 @@ @@ -43,8 +43,49 @@
43 void * userdata; 43 void * userdata;
44 } IO_Source; 44 } IO_Source;
45 45
  46 +static gboolean IO_prepare(GSource *source, gint *timeout);
  47 +static gboolean IO_check(GSource *source);
  48 +static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer user_data);
  49 +static void IO_finalize(GSource *source); /* Can be NULL */
  50 +static gboolean IO_closure(gpointer data);
  51 +
46 /*---[ Implement ]-----------------------------------------------------------------------------------------*/ 52 /*---[ Implement ]-----------------------------------------------------------------------------------------*/
47 53
  54 +GSource * IO_source_new(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata)
  55 +{
  56 + static GSourceFuncs IOSources =
  57 + {
  58 + IO_prepare,
  59 + IO_check,
  60 + IO_dispatch,
  61 + IO_finalize,
  62 + IO_closure,
  63 + NULL
  64 + };
  65 +
  66 + IO_Source *src = (IO_Source *) g_source_new(&IOSources,sizeof(IO_Source));
  67 +
  68 + src->fd = fd;
  69 + src->enabled = TRUE;
  70 + src->call = call;
  71 + src->userdata = userdata;
  72 + src->session = session;
  73 +
  74 + src->poll.fd = (int) fd;
  75 + src->poll.events = G_IO_HUP|G_IO_ERR;
  76 +
  77 + if(flag & LIB3270_IO_FLAG_READ)
  78 + src->poll.events |= G_IO_IN;
  79 +
  80 + if(flag & LIB3270_IO_FLAG_WRITE)
  81 + src->poll.events |= G_IO_OUT;
  82 +
  83 + g_source_attach((GSource *) src,NULL);
  84 + g_source_add_poll((GSource *) src,&src->poll);
  85 +
  86 + return (GSource *) src;
  87 +}
  88 +
48 static gboolean IO_prepare(G_GNUC_UNUSED GSource *source, G_GNUC_UNUSED gint *timeout) 89 static gboolean IO_prepare(G_GNUC_UNUSED GSource *source, G_GNUC_UNUSED gint *timeout)
49 { 90 {
50 /* 91 /*
@@ -72,27 +113,30 @@ static gboolean IO_check(GSource *source) @@ -72,27 +113,30 @@ static gboolean IO_check(GSource *source)
72 * function was called, so the source should be checked again here. 113 * function was called, so the source should be checked again here.
73 * 114 *
74 */ 115 */
75 - fd_set rfds, wfds;  
76 - struct timeval tm; 116 + if(((IO_Source *) source)->enabled)
  117 + {
  118 + fd_set rfds, wfds;
  119 + struct timeval tm;
77 120
78 - memset(&tm,0,sizeof(tm)); 121 + memset(&tm,0,sizeof(tm));
79 122
80 - FD_ZERO(&rfds);  
81 - FD_ZERO(&wfds);  
82 -// FD_ZERO(&xfds); 123 + FD_ZERO(&rfds);
  124 + FD_ZERO(&wfds);
  125 + // FD_ZERO(&xfds);
83 126
84 - if(((IO_Source *) source)->poll.events & G_IO_IN)  
85 - {  
86 - FD_SET(((IO_Source *) source)->poll.fd, &rfds);  
87 - } 127 + if(((IO_Source *) source)->poll.events & G_IO_IN)
  128 + {
  129 + FD_SET(((IO_Source *) source)->poll.fd, &rfds);
  130 + }
88 131
89 - if(((IO_Source *) source)->poll.events & G_IO_OUT)  
90 - {  
91 - FD_SET(((IO_Source *) source)->poll.fd, &wfds);  
92 - } 132 + if(((IO_Source *) source)->poll.events & G_IO_OUT)
  133 + {
  134 + FD_SET(((IO_Source *) source)->poll.fd, &wfds);
  135 + }
93 136
94 - if(select(((IO_Source *) source)->poll.fd+1, &rfds, &wfds, NULL, &tm) > 0)  
95 - return TRUE; 137 + if(select(((IO_Source *) source)->poll.fd+1, &rfds, &wfds, NULL, &tm) > 0)
  138 + return TRUE;
  139 + }
96 140
97 return FALSE; 141 return FALSE;
98 } 142 }
@@ -47,6 +47,7 @@ @@ -47,6 +47,7 @@
47 </Unit> 47 </Unit>
48 <Unit filename="src/dialogs/private.h" /> 48 <Unit filename="src/dialogs/private.h" />
49 <Unit filename="src/include/config.h" /> 49 <Unit filename="src/include/config.h" />
  50 + <Unit filename="src/include/config.h.in" />
50 <Unit filename="src/include/hostselect.h" /> 51 <Unit filename="src/include/hostselect.h" />
51 <Unit filename="src/include/v3270.h" /> 52 <Unit filename="src/include/v3270.h" />
52 <Unit filename="src/include/v3270/filetransfer.h" /> 53 <Unit filename="src/include/v3270/filetransfer.h" />
@@ -69,6 +70,9 @@ @@ -69,6 +70,9 @@
69 <Unit filename="src/v3270/keyboard.c"> 70 <Unit filename="src/v3270/keyboard.c">
70 <Option compilerVar="CC" /> 71 <Option compilerVar="CC" />
71 </Unit> 72 </Unit>
  73 + <Unit filename="src/v3270/linux/iosource.c">
  74 + <Option compilerVar="CC" />
  75 + </Unit>
72 <Unit filename="src/v3270/macros.c"> 76 <Unit filename="src/v3270/macros.c">
73 <Option compilerVar="CC" /> 77 <Option compilerVar="CC" />
74 </Unit> 78 </Unit>
@@ -88,10 +92,12 @@ @@ -88,10 +92,12 @@
88 <Unit filename="src/v3270/selection.c"> 92 <Unit filename="src/v3270/selection.c">
89 <Option compilerVar="CC" /> 93 <Option compilerVar="CC" />
90 </Unit> 94 </Unit>
91 - <Unit filename="src/v3270/v3270.marshal" />  
92 <Unit filename="src/v3270/widget.c"> 95 <Unit filename="src/v3270/widget.c">
93 <Option compilerVar="CC" /> 96 <Option compilerVar="CC" />
94 </Unit> 97 </Unit>
  98 + <Unit filename="src/v3270/windows/iosource.c">
  99 + <Option compilerVar="CC" />
  100 + </Unit>
95 <Unit filename="src/v3270ft/filelist.c"> 101 <Unit filename="src/v3270ft/filelist.c">
96 <Option compilerVar="CC" /> 102 <Option compilerVar="CC" />
97 </Unit> 103 </Unit>