Commit b44182376011d616f819ae3d500845641155eec8

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

Reorganizing modules.

@@ -14,4 +14,6 @@ stamp-h1 @@ -14,4 +14,6 @@ stamp-h1
14 Makefile 14 Makefile
15 *.[0-9] 15 *.[0-9]
16 conf/systemd.service 16 conf/systemd.service
17 -src/windows/resources.rc 17 +src/core/windows/resources.rc
  18 +src/plugin/windows/resources.rc
  19 +
@@ -30,16 +30,16 @@ MODULE_NAME=ipc3270 @@ -30,16 +30,16 @@ MODULE_NAME=ipc3270
30 PACKAGE_NAME=@PACKAGE_NAME@ 30 PACKAGE_NAME=@PACKAGE_NAME@
31 31
32 CORE_SOURCES= \ 32 CORE_SOURCES= \
33 - $(wildcard src/*.c) \  
34 - $(wildcard src/@OSNAME@/*.c) 33 + $(wildcard src/core/*.c) \
  34 + $(wildcard src/core/@OSNAME@/*.c)
35 35
36 PLUGIN_SOURCES= \ 36 PLUGIN_SOURCES= \
37 $(wildcard src/plugin/*.c) \ 37 $(wildcard src/plugin/*.c) \
38 - $(wildcard src/@OSNAME@/*.rc) 38 + $(wildcard src/plugin/@OSNAME@/*.rc)
39 39
40 SERVICE_SOURCES= \ 40 SERVICE_SOURCES= \
41 $(wildcard src/service/*.c) \ 41 $(wildcard src/service/*.c) \
42 - $(wildcard src/@OSNAME@/*.rc) 42 + $(wildcard src/service/@OSNAME@/*.rc)
43 43
44 TEST_SOURCES= \ 44 TEST_SOURCES= \
45 $(wildcard src/testprogram/*.c) 45 $(wildcard src/testprogram/*.c)
@@ -88,8 +88,7 @@ BINRLS=$(BINDIR)/Release @@ -88,8 +88,7 @@ BINRLS=$(BINDIR)/Release
88 DEPENDS= \ 88 DEPENDS= \
89 Makefile \ 89 Makefile \
90 src/include/*.h \ 90 src/include/*.h \
91 - src/include/lib3270/*.h \  
92 - src/linux/*.h 91 + src/include/lib3270/*.h
93 92
94 CFLAGS= \ 93 CFLAGS= \
95 @CFLAGS@ \ 94 @CFLAGS@ \
@@ -195,7 +194,7 @@ $(BINRLS)/lib$(MODULE_NAME).a: \ @@ -195,7 +194,7 @@ $(BINRLS)/lib$(MODULE_NAME).a: \
195 194
196 $(BINRLS)/$(MODULE_NAME)@DLLEXT@: \ 195 $(BINRLS)/$(MODULE_NAME)@DLLEXT@: \
197 $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) \ 196 $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) \
198 - $(foreach SRC, $(basename $(CORE_SOURCES)), $(OBJRLS)/$(SRC).o) 197 + $(BINRLS)/lib$(MODULE_NAME).a
199 198
200 @$(MKDIR) `dirname $@` 199 @$(MKDIR) `dirname $@`
201 @echo $< ... 200 @echo $< ...
@@ -204,8 +203,8 @@ $(BINRLS)/$(MODULE_NAME)@DLLEXT@: \ @@ -204,8 +203,8 @@ $(BINRLS)/$(MODULE_NAME)@DLLEXT@: \
204 -o $@ \ 203 -o $@ \
205 $(LDFLAGS) \ 204 $(LDFLAGS) \
206 $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) \ 205 $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) \
207 - $(foreach SRC, $(basename $(CORE_SOURCES)), $(OBJRLS)/$(SRC).o) \  
208 - $(LIBS) 206 + $(LIBS) \
  207 + -L$(BINRLS) -l$(MODULE_NAME)
209 208
210 #---[ Install Targets ]------------------------------------------------------------------ 209 #---[ Install Targets ]------------------------------------------------------------------
211 210
@@ -247,6 +246,9 @@ Debug-plugin: \ @@ -247,6 +246,9 @@ Debug-plugin: \
247 Debug-service: \ 246 Debug-service: \
248 $(BINDBG)/$(PACKAGE_NAME)d@EXEEXT@ 247 $(BINDBG)/$(PACKAGE_NAME)d@EXEEXT@
249 248
  249 +x:
  250 + @echo $(foreach SRC, $(basename $(CORE_SOURCES)), $(OBJDBG)/$(SRC).o)
  251 +
250 $(BINDBG)/lib$(MODULE_NAME).a: \ 252 $(BINDBG)/lib$(MODULE_NAME).a: \
251 $(foreach SRC, $(basename $(CORE_SOURCES)), $(OBJDBG)/$(SRC).o) 253 $(foreach SRC, $(basename $(CORE_SOURCES)), $(OBJDBG)/$(SRC).o)
252 254
@@ -309,12 +311,9 @@ $(BINDBG)/@DLLPREFIX@$(MODULE_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@: \ @@ -309,12 +311,9 @@ $(BINDBG)/@DLLPREFIX@$(MODULE_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@: \
309 @DLLPREFIX@$(MODULE_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ \ 311 @DLLPREFIX@$(MODULE_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ \
310 $@ 312 $@
311 313
312 -x: \  
313 - $(BINDBG)/@DLLPREFIX@$(MODULE_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@  
314 -  
315 $(BINDBG)/@DLLPREFIX@$(MODULE_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \ 314 $(BINDBG)/@DLLPREFIX@$(MODULE_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \
316 $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) \ 315 $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) \
317 - $(foreach SRC, $(basename $(CORE_SOURCES)), $(OBJDBG)/$(SRC).o) 316 + $(BINDBG)/lib$(MODULE_NAME).a
318 317
319 @$(MKDIR) `dirname $@` 318 @$(MKDIR) `dirname $@`
320 @echo $< ... 319 @echo $< ...
@@ -323,8 +322,8 @@ $(BINDBG)/@DLLPREFIX@$(MODULE_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MIN @@ -323,8 +322,8 @@ $(BINDBG)/@DLLPREFIX@$(MODULE_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MIN
323 -o $@ \ 322 -o $@ \
324 $(LDFLAGS) \ 323 $(LDFLAGS) \
325 $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) \ 324 $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) \
326 - $(foreach SRC, $(basename $(CORE_SOURCES)), $(OBJDBG)/$(SRC).o) \  
327 - $(LIBS) 325 + $(LIBS) \
  326 + -L$(BINDBG) -l$(MODULE_NAME)
328 327
329 #---[ Clean Targets ]-------------------------------------------------------------------- 328 #---[ Clean Targets ]--------------------------------------------------------------------
330 329
@@ -84,7 +84,8 @@ case &quot;$host&quot; in @@ -84,7 +84,8 @@ case &quot;$host&quot; in
84 84
85 app_win32_revision=$(date +%y.%m.%d.%H) 85 app_win32_revision=$(date +%y.%m.%d.%H)
86 AC_SUBST(WIN32_VERSION,$app_win32_revision) 86 AC_SUBST(WIN32_VERSION,$app_win32_revision)
87 - AC_CONFIG_FILES(src/windows/resources.rc) 87 + AC_CONFIG_FILES(src/core/windows/resources.rc)
  88 + AC_CONFIG_FILES(src/plugin/windows/resources.rc)
88 ;; 89 ;;
89 90
90 s390x-*) 91 s390x-*)
pw3270-plugin-ipc.cbp
@@ -69,6 +69,9 @@ @@ -69,6 +69,9 @@
69 </Unit> 69 </Unit>
70 <Unit filename="src/include/config.h.in" /> 70 <Unit filename="src/include/config.h.in" />
71 <Unit filename="src/include/lib3270/ipc.h" /> 71 <Unit filename="src/include/lib3270/ipc.h" />
  72 + <Unit filename="src/inout.c">
  73 + <Option compilerVar="CC" />
  74 + </Unit>
72 <Unit filename="src/linux/gobject.c"> 75 <Unit filename="src/linux/gobject.c">
73 <Option compilerVar="CC" /> 76 <Option compilerVar="CC" />
74 </Unit> 77 </Unit>
src/constants.c
@@ -1,51 +0,0 @@ @@ -1,51 +0,0 @@
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 main.c e possui - linhas de código.  
22 - *  
23 - * Referências:  
24 - *  
25 - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c  
26 - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c  
27 - *  
28 - * Contatos:  
29 - *  
30 - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
31 - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)  
32 - *  
33 - */  
34 -  
35 -#include <lib3270.h>  
36 -#include <lib3270/actions.h>  
37 -#include <lib3270/ipc.h>  
38 -  
39 -const IPC_METHOD_INT_ARG * ipc3270_get_int_arg_methods() {  
40 -  
41 - static const IPC_METHOD_INT_ARG int_arg_methods[] = {  
42 - { "pfkey", lib3270_pfkey },  
43 - { "pakey", lib3270_pakey },  
44 - { NULL, NULL }  
45 - };  
46 -  
47 - return int_arg_methods;  
48 -  
49 -}  
50 -  
51 -  
src/convert.c
@@ -1,59 +0,0 @@ @@ -1,59 +0,0 @@
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 main.c e possui - linhas de código.  
22 - *  
23 - * Referências:  
24 - *  
25 - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c  
26 - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c  
27 - *  
28 - * Contatos:  
29 - *  
30 - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
31 - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)  
32 - *  
33 - */  
34 -  
35 -#include <lib3270.h>  
36 -#include <lib3270/actions.h>  
37 -#include <lib3270/ipc.h>  
38 -  
39 -gchar * ipc3270_convert_output_string(GObject *object, const gchar *string, GError **error) {  
40 - return g_convert_with_fallback(string,-1,ipc3270_get_display_charset(object),"UTF-8","?",NULL,NULL,error);  
41 -}  
42 -  
43 -gchar * ipc3270_convert_input_string(GObject *object, const gchar *string, GError **error) {  
44 - return g_convert_with_fallback(string,-1,"UTF-8",ipc3270_get_display_charset(object),"?",NULL,NULL,error);  
45 -}  
46 -  
47 -GVariant * ipc3270_GVariant_from_input_string(GObject *object, char *string, GError **error) {  
48 -  
49 - if(string) {  
50 - g_autofree gchar * utfstring = ipc3270_convert_input_string(object,string,error);  
51 - lib3270_free(string);  
52 - return g_variant_new("(s)", utfstring);  
53 - }  
54 -  
55 - ipc3270_set_error(object,errno,error);  
56 - return g_variant_new("(s)", "");  
57 -}  
58 -  
59 -  
src/core/constants.c 0 → 100644
@@ -0,0 +1,51 @@ @@ -0,0 +1,51 @@
  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 main.c e possui - linhas de código.
  22 + *
  23 + * Referências:
  24 + *
  25 + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c
  26 + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c
  27 + *
  28 + * Contatos:
  29 + *
  30 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  31 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  32 + *
  33 + */
  34 +
  35 +#include <lib3270.h>
  36 +#include <lib3270/actions.h>
  37 +#include <lib3270/ipc.h>
  38 +
  39 +const IPC_METHOD_INT_ARG * ipc3270_get_int_arg_methods() {
  40 +
  41 + static const IPC_METHOD_INT_ARG int_arg_methods[] = {
  42 + { "pfkey", lib3270_pfkey },
  43 + { "pakey", lib3270_pakey },
  44 + { NULL, NULL }
  45 + };
  46 +
  47 + return int_arg_methods;
  48 +
  49 +}
  50 +
  51 +
src/core/convert.c 0 → 100644
@@ -0,0 +1,59 @@ @@ -0,0 +1,59 @@
  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 main.c e possui - linhas de código.
  22 + *
  23 + * Referências:
  24 + *
  25 + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c
  26 + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c
  27 + *
  28 + * Contatos:
  29 + *
  30 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  31 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  32 + *
  33 + */
  34 +
  35 +#include <lib3270.h>
  36 +#include <lib3270/actions.h>
  37 +#include <lib3270/ipc.h>
  38 +
  39 +gchar * ipc3270_convert_output_string(GObject *object, const gchar *string, GError **error) {
  40 + return g_convert_with_fallback(string,-1,ipc3270_get_display_charset(object),"UTF-8","?",NULL,NULL,error);
  41 +}
  42 +
  43 +gchar * ipc3270_convert_input_string(GObject *object, const gchar *string, GError **error) {
  44 + return g_convert_with_fallback(string,-1,"UTF-8",ipc3270_get_display_charset(object),"?",NULL,NULL,error);
  45 +}
  46 +
  47 +GVariant * ipc3270_GVariant_from_input_string(GObject *object, char *string, GError **error) {
  48 +
  49 + if(string) {
  50 + g_autofree gchar * utfstring = ipc3270_convert_input_string(object,string,error);
  51 + lib3270_free(string);
  52 + return g_variant_new("(s)", utfstring);
  53 + }
  54 +
  55 + ipc3270_set_error(object,errno,error);
  56 + return g_variant_new("(s)", "");
  57 +}
  58 +
  59 +
src/core/getproperties.c 0 → 100644
@@ -0,0 +1,128 @@ @@ -0,0 +1,128 @@
  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 main.c e possui - linhas de código.
  22 + *
  23 + * Referências:
  24 + *
  25 + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c
  26 + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c
  27 + *
  28 + * Contatos:
  29 + *
  30 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  31 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  32 + *
  33 + */
  34 +
  35 +#include <config.h>
  36 +#include <lib3270/ipc.h>
  37 +#include <lib3270.h>
  38 +#include <lib3270/properties.h>
  39 +
  40 +// #include <dbus/dbus-glib.h>
  41 +// #include <dbus/dbus-glib-bindings.h>
  42 +
  43 +GVariant * ipc3270_get_property(GObject *object, const gchar *property_name, GError **error) {
  44 +
  45 + size_t ix;
  46 + errno = 0; // Just in case.
  47 +
  48 + // Boolean properties
  49 + const LIB3270_INT_PROPERTY * boolprop = lib3270_get_boolean_properties_list();
  50 + for(ix = 0; boolprop[ix].name; ix++) {
  51 +
  52 + if(boolprop[ix].get && !g_ascii_strcasecmp(boolprop[ix].name, property_name)) {
  53 +
  54 + // Found it!
  55 + int value = boolprop[ix].get(ipc3270_get_session(object));
  56 +
  57 + debug("%s=%d",property_name,value);
  58 +
  59 + if(value > 0 || errno == 0) {
  60 + return g_variant_new_boolean(value != 0);
  61 + }
  62 +
  63 + // Erro!
  64 + ipc3270_set_error(object,ENOENT,error);
  65 + return NULL;
  66 +
  67 + }
  68 +
  69 + }
  70 +
  71 + // int properties
  72 + const LIB3270_INT_PROPERTY * intprop = lib3270_get_int_properties_list();
  73 + for(ix = 0; intprop[ix].name; ix++) {
  74 +
  75 + if(intprop[ix].get && !g_ascii_strcasecmp(intprop[ix].name, property_name)) {
  76 +
  77 + // Found it!
  78 + int value = intprop[ix].get(ipc3270_get_session(object));
  79 +
  80 + debug("%s=%d",property_name,value);
  81 +
  82 + if(value > 0 || errno == 0) {
  83 + return g_variant_new_int16((gint16) value);
  84 + }
  85 +
  86 + // Erro!
  87 + ipc3270_set_error(object,errno,error);
  88 + return NULL;
  89 +
  90 + }
  91 +
  92 + }
  93 +
  94 + // String properties
  95 + const LIB3270_STRING_PROPERTY * strprop = lib3270_get_string_properties_list();
  96 + for(ix = 0; strprop[ix].name; ix++) {
  97 +
  98 + if(strprop[ix].get && !g_ascii_strcasecmp(strprop[ix].name, property_name)) {
  99 +
  100 + // Found it!
  101 + const char * value = strprop[ix].get(ipc3270_get_session(object));
  102 +
  103 + if(value) {
  104 + debug("%s=%s",property_name,value);
  105 + return g_variant_new_string(value);
  106 + }
  107 +
  108 + // Erro!
  109 + ipc3270_set_error(object,errno,error);
  110 + return NULL;
  111 +
  112 + }
  113 +
  114 + }
  115 +
  116 + // Check for toggle
  117 + LIB3270_TOGGLE toggle = lib3270_get_toggle_id(property_name);
  118 + if(toggle != (LIB3270_TOGGLE) -1) {
  119 +
  120 + // Is a Tn3270 toggle, get it!
  121 + return g_variant_new_boolean(lib3270_get_toggle( (ipc3270_get_session(object)), toggle) != 0);
  122 +
  123 + }
  124 +
  125 + return NULL;
  126 +
  127 +}
  128 +
src/core/linux/dbus-definition.xml 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<node name="/br/com/bb/pw3270">
  3 + <interface name="br.com.bb.pw3270">
  4 + <method name="getRevision">
  5 + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
  6 + <arg type="s" name="revision" direction="out" />
  7 + </method>
  8 + </interface>
  9 +</node>
src/core/linux/gobject.c 0 → 100644
@@ -0,0 +1,351 @@ @@ -0,0 +1,351 @@
  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 main.c e possui - linhas de código.
  22 + *
  23 + * Referências:
  24 + *
  25 + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c
  26 + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c
  27 + *
  28 + * Contatos:
  29 + *
  30 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  31 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  32 + *
  33 + */
  34 +
  35 +#include "gobject.h"
  36 +#include <lib3270.h>
  37 +#include <lib3270/actions.h>
  38 +#include <lib3270/properties.h>
  39 +
  40 +#include <dbus/dbus-glib.h>
  41 +#include <dbus/dbus-glib-bindings.h>
  42 +
  43 +G_DEFINE_TYPE(ipc3270, ipc3270, G_TYPE_OBJECT)
  44 +
  45 +static void ipc3270_finalize(GObject *object) {
  46 +
  47 + ipc3270 * ipc = IPC3270(object);
  48 +
  49 + debug("%s",__FUNCTION__);
  50 + if(ipc->id) {
  51 + g_dbus_connection_unregister_object(ipc->connection,ipc->id);
  52 + }
  53 +
  54 + G_OBJECT_CLASS(ipc3270_parent_class)->finalize(object);
  55 +}
  56 +
  57 +
  58 +static void ipc3270_class_init(ipc3270Class *klass) {
  59 +
  60 + debug("%s",__FUNCTION__);
  61 +
  62 + GObjectClass *object_class;
  63 + object_class = G_OBJECT_CLASS (klass);
  64 + object_class->finalize = ipc3270_finalize;
  65 +
  66 +}
  67 +
  68 +static void ipc3270_init(ipc3270 *object) {
  69 +
  70 + debug("%s",__FUNCTION__);
  71 + object->error_domain = g_quark_from_static_string(PACKAGE_NAME);
  72 +
  73 +}
  74 +
  75 +GObject * ipc3270_new() {
  76 + return g_object_new(GLIB_TYPE_IPC3270, NULL);
  77 +}
  78 +
  79 +static void
  80 + method_call (
  81 + G_GNUC_UNUSED GDBusConnection *connection,
  82 + G_GNUC_UNUSED const gchar *sender,
  83 + G_GNUC_UNUSED const gchar *object_path,
  84 + G_GNUC_UNUSED const gchar *interface_name,
  85 + const gchar *method_name,
  86 + GVariant *parameters,
  87 + GDBusMethodInvocation *invocation,
  88 + gpointer user_data) {
  89 +
  90 + g_autoptr (GError) error = NULL;
  91 +
  92 + GVariant * rc = ipc3270_method_call(G_OBJECT(user_data), method_name, parameters, &error);
  93 +
  94 + if(error) {
  95 +
  96 + if(rc) {
  97 + g_variant_unref(rc);
  98 + }
  99 +
  100 + g_dbus_method_invocation_return_gerror(invocation, error);
  101 +
  102 + } else if(rc) {
  103 +
  104 + g_dbus_method_invocation_return_value(invocation, rc);
  105 +
  106 + } else {
  107 +
  108 + g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Invalid or unexpected method call");
  109 +
  110 + }
  111 +
  112 +
  113 +}
  114 +
  115 +static GVariant *
  116 + get_property (
  117 + G_GNUC_UNUSED GDBusConnection *connection,
  118 + G_GNUC_UNUSED const gchar *sender,
  119 + G_GNUC_UNUSED const gchar *object_path,
  120 + G_GNUC_UNUSED const gchar *interface_name,
  121 + const gchar *property_name,
  122 + GError **error,
  123 + gpointer user_data)
  124 +{
  125 +
  126 + return ipc3270_get_property(G_OBJECT(user_data), property_name, error);
  127 +
  128 +}
  129 +
  130 +static gboolean
  131 + set_property (
  132 + G_GNUC_UNUSED GDBusConnection *connection,
  133 + G_GNUC_UNUSED const gchar *sender,
  134 + G_GNUC_UNUSED const gchar *object_path,
  135 + G_GNUC_UNUSED const gchar *interface_name,
  136 + const gchar *property_name,
  137 + GVariant *value,
  138 + GError **error,
  139 + gpointer user_data)
  140 +{
  141 +
  142 + return ipc3270_set_property(G_OBJECT(user_data), property_name, value, error);
  143 +
  144 +}
  145 +
  146 +
  147 +void ipc3270_set_session(GObject *object, H3270 *hSession, const char *name, GError **error) {
  148 +
  149 + char id;
  150 + int ix;
  151 +
  152 + static const GDBusInterfaceVTable interface_vtable = {
  153 + method_call,
  154 + get_property,
  155 + set_property
  156 + };
  157 +
  158 + ipc3270 * ipc = IPC3270(object);
  159 + ipc->hSession = hSession;
  160 +
  161 + ipc->connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, error);
  162 + if(*error) {
  163 + g_message("Can't get session bus: %s",(*error)->message);
  164 + return;
  165 + }
  166 +
  167 + g_dbus_connection_set_exit_on_close(ipc->connection,FALSE);
  168 +
  169 + for(id='a'; id < 'z' && !ipc->id && !*error; id++) {
  170 +
  171 + gchar *object_name = g_strdup_printf("br.com.bb.%s.%c",name,id);
  172 +
  173 + debug("Requesting \"%s\"",object_name);
  174 +
  175 + // https://dbus.freedesktop.org/doc/dbus-specification.html
  176 + GError *err = NULL;
  177 +
  178 + GVariant * response =
  179 + g_dbus_connection_call_sync (
  180 + ipc->connection,
  181 + DBUS_SERVICE_DBUS,
  182 + DBUS_PATH_DBUS,
  183 + DBUS_INTERFACE_DBUS,
  184 + "RequestName",
  185 + g_variant_new ("(su)", object_name, DBUS_NAME_FLAG_DO_NOT_QUEUE),
  186 + NULL,
  187 + G_DBUS_CALL_FLAGS_NONE,
  188 + -1,
  189 + NULL,
  190 + &err
  191 + );
  192 +
  193 + if(err) {
  194 + g_message("Can't request \"%s\": %s",object_name,err->message);
  195 + g_error_free(err);
  196 + err = NULL;
  197 + }
  198 +
  199 + if(response) {
  200 +
  201 + guint32 reply = 0;
  202 + g_variant_get(response, "(u)", &reply);
  203 + g_variant_unref(response);
  204 +
  205 + if(reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
  206 +
  207 + g_message("Got %s", object_name);
  208 +
  209 + lib3270_set_session_id(ipc->hSession, id);
  210 +
  211 + // Introspection data for the service we are exporting
  212 + GString * introspection = g_string_new(
  213 + "<node>\n"
  214 + " <interface name='br.com.bb.tn3270'>"
  215 + " <method name='connect'>"
  216 + " <arg type='s' name='url' direction='in'/>"
  217 + " <arg type='i' name='result' direction='out' />" \
  218 + " </method>"
  219 + " <method name='pfkey'>" \
  220 + " <arg type='i' name='keycode' direction='in'/>" \
  221 + " <arg type='i' name='result' direction='out' />" \
  222 + " </method>"
  223 + " <method name='pakey'>" \
  224 + " <arg type='i' name='keycode' direction='in'/>" \
  225 + " <arg type='i' name='result' direction='out' />" \
  226 + " </method>"
  227 + " <method name='getString'>" \
  228 + " <arg type='s' name='text' direction='out' />" \
  229 + " </method>" \
  230 + " <method name='setString'>" \
  231 + " <arg type='s' name='text' direction='in' />" \
  232 + " <arg type='i' name='result' direction='out' />" \
  233 + " </method>" \
  234 + " <method name='setStringAt'>" \
  235 + " <arg type='i' name='row' direction='in' />" \
  236 + " <arg type='i' name='col' direction='in' />" \
  237 + " <arg type='s' name='text' direction='in' />" \
  238 + " <arg type='i' name='result' direction='out' />" \
  239 + " </method>" \
  240 + " <method name= 'getStringAt'>" \
  241 + " <arg type='i' name='row' direction='in' />" \
  242 + " <arg type='i' name='col' direction='in' />" \
  243 + " <arg type='i' name='len' direction='in' />" \
  244 + " <arg type='y' name='lf' direction='in' />" \
  245 + " <arg type='s' name='text' direction='out' />" \
  246 + " </method>" \
  247 + " <method name='setStringAtAddress'>" \
  248 + " <arg type='i' name='addr' direction='in' />" \
  249 + " <arg type='s' name='text' direction='in' />" \
  250 + " <arg type='i' name='result' direction='out' />" \
  251 + " </method>" \
  252 + " <method name= 'getStringAtAddress'>" \
  253 + " <arg type='i' name='addr' direction='in' />" \
  254 + " <arg type='i' name='len' direction='in' />" \
  255 + " <arg type='y' name='lf' direction='in' />" \
  256 + " <arg type='s' name='text' direction='out' />" \
  257 + " </method>"
  258 +
  259 + );
  260 +
  261 + // Constrói métodos usando a tabela de controle
  262 + const LIB3270_ACTION_ENTRY * actions = lib3270_get_action_table();
  263 + for(ix = 0; actions[ix].name; ix++)
  264 + {
  265 + g_string_append_printf(
  266 + introspection, \
  267 + " <method name='%s'>" \
  268 + " </method>", actions[ix].name
  269 + );
  270 + }
  271 +
  272 + // Toggle properties
  273 + for(ix = 0; ix < (int) LIB3270_TOGGLE_COUNT; ix++) {
  274 + g_string_append_printf(introspection, " <property type='i' name='%s' access='readwrite'/>", lib3270_get_toggle_name((LIB3270_TOGGLE) ix));
  275 + }
  276 +
  277 + // Boolean properties
  278 + const LIB3270_INT_PROPERTY * bol_props = lib3270_get_boolean_properties_list();
  279 + for(ix = 0; bol_props[ix].name; ix++) {
  280 + debug("Boolean(%s)",bol_props[ix].name);
  281 + g_string_append_printf(introspection, " <property type='b' name='%s' access='%s'/>",
  282 + bol_props[ix].name,
  283 + ((bol_props[ix].set == NULL) ? "read" : "readwrite")
  284 + );
  285 + }
  286 +
  287 + // Integer properties
  288 + const LIB3270_INT_PROPERTY * int_props = lib3270_get_int_properties_list();
  289 + for(ix = 0; int_props[ix].name; ix++) {
  290 + g_string_append_printf(introspection, " <property type='i' name='%s' access='%s'/>",
  291 + int_props[ix].name,
  292 + ((int_props[ix].set == NULL) ? "read" : "readwrite")
  293 + );
  294 + }
  295 +
  296 + // String properties
  297 + const LIB3270_STRING_PROPERTY * str_props = lib3270_get_string_properties_list();
  298 + for(ix = 0; str_props[ix].name; ix++) {
  299 + g_string_append_printf(introspection, " <property type='s' name='%s' access='%s'/>",
  300 + str_props[ix].name,
  301 + ((str_props[ix].set == NULL) ? "read" : "readwrite")
  302 + );
  303 + }
  304 +
  305 + g_string_append(introspection,
  306 + " </interface>"
  307 + "</node>"
  308 + );
  309 +
  310 + gchar * introspection_xml = g_string_free(introspection,FALSE);
  311 +
  312 + debug("\n%s\n",introspection_xml);
  313 +
  314 + GDBusNodeInfo * introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
  315 +
  316 + // Register object-id
  317 + ipc->id = g_dbus_connection_register_object (
  318 + ipc->connection,
  319 + "/br/com/bb/tn3270",
  320 + introspection_data->interfaces[0],
  321 + &interface_vtable,
  322 + ipc,
  323 + NULL,
  324 + error
  325 + );
  326 +
  327 + g_dbus_node_info_unref(introspection_data);
  328 + g_free(introspection_xml);
  329 +
  330 + break;
  331 + }
  332 +
  333 + }
  334 +
  335 + g_free(object_name);
  336 +
  337 + }
  338 +
  339 +}
  340 +
  341 +const gchar * ipc3270_get_display_charset(GObject *object) {
  342 + return lib3270_get_display_charset(IPC3270(object)->hSession);
  343 +}
  344 +
  345 +H3270 * ipc3270_get_session(GObject *object) {
  346 + return IPC3270(object)->hSession;
  347 +}
  348 +
  349 +void ipc3270_set_error(GObject *object, int errcode, GError **error) {
  350 + g_set_error(error,IPC3270(object)->error_domain,errcode,"%s",strerror(errcode));
  351 +}
src/core/linux/gobject.h 0 → 100644
@@ -0,0 +1,77 @@ @@ -0,0 +1,77 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como - e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 + /**
  32 + * @brief Private definitions for pw3270 IPC linux module.
  33 + *
  34 + */
  35 +
  36 +#ifndef LINUX_GOBJECT_H_INCLUDED
  37 +
  38 + #define LINUX_GOBJECT_H_INCLUDED
  39 +
  40 + #include <config.h>
  41 +
  42 + #define ENABLE_NLS
  43 + #define GETTEXT_PACKAGE PACKAGE_NAME
  44 +
  45 + #include <libintl.h>
  46 + #include <glib/gi18n.h>
  47 + #include <gio/gio.h>
  48 +
  49 + #include <lib3270.h>
  50 + #include <lib3270/ipc.h>
  51 +
  52 + G_BEGIN_DECLS
  53 +
  54 + typedef struct _ipc3270 ipc3270;
  55 + typedef struct _ipc3270Class ipc3270Class;
  56 +
  57 + struct _ipc3270 {
  58 + GObject parent;
  59 + GDBusConnection * connection;
  60 + guint id;
  61 + H3270 * hSession;
  62 + GQuark error_domain;
  63 + };
  64 +
  65 + struct _ipc3270Class {
  66 + GObjectClass parent;
  67 + };
  68 +
  69 + /*
  70 + G_GNUC_INTERNAL void ipc3270_method_call (GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *method_name, GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data);
  71 + G_GNUC_INTERNAL gboolean ipc3270_set_property(GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *property_name, GVariant *value, GError **error, gpointer user_data);
  72 + G_GNUC_INTERNAL GVariant * ipc3270_get_property (GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *property_name, GError **error, gpointer user_data);
  73 + */
  74 +
  75 + G_END_DECLS
  76 +
  77 +#endif // LINUX_GOBJECT_H_INCLUDED
src/core/linux/start.c.1 0 → 100644
@@ -0,0 +1,191 @@ @@ -0,0 +1,191 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como testprogram.c e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 +
  32 + /**
  33 + * @brief Plugin startup/stop for linux.
  34 + *
  35 + */
  36 +
  37 + #include "private.h"
  38 +
  39 + #include <dbus/dbus-glib.h>
  40 + #include <dbus/dbus-glib-bindings.h>
  41 +
  42 + static void pw3270_dbus_cleanup(struct DBusSession * dBus) {
  43 +
  44 + if(dBus->proxy) {
  45 + g_object_unref(dBus);
  46 + }
  47 +
  48 + }
  49 +
  50 + int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal) {
  51 +
  52 + struct DBusSession * dBus = g_new0(struct DBusSession,1);
  53 + GError * error = NULL;
  54 + int id;
  55 +
  56 + g_object_set_data_full(G_OBJECT(terminal), "dbus-session-info", dBus, (GDestroyNotify) pw3270_dbus_cleanup);
  57 +
  58 + dBus->connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
  59 +
  60 + if(error) {
  61 + GtkWidget *dialog = gtk_message_dialog_new(
  62 + GTK_WINDOW(window),
  63 + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
  64 + GTK_MESSAGE_ERROR,
  65 + GTK_BUTTONS_OK,
  66 + _( "Can't get D-Bus connection" ));
  67 +
  68 + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message);
  69 + g_error_free(error);
  70 +
  71 + gtk_dialog_run(GTK_DIALOG(dialog));
  72 + gtk_widget_destroy(dialog);
  73 +
  74 + return -1;
  75 + }
  76 +
  77 + g_dbus_connection_set_exit_on_close(dBus->connection,FALSE);
  78 +
  79 + /*
  80 + dBus->proxy = g_dbus_proxy_new_sync(
  81 + dBus->connection,
  82 + G_DBUS_PROXY_FLAGS_NONE,
  83 + NULL, // GDBusInterfaceInfo
  84 + "br.com.bb." PACKAGE_NAME, // name
  85 + "/br/com/bb/" PACKAGE_NAME "/terminal", // object path
  86 + "br.com.bb." PACKAGE_NAME ".terminal", // interface
  87 + NULL, // GCancellable
  88 + &error );
  89 +
  90 + if(error) {
  91 +
  92 + GtkWidget *dialog = gtk_message_dialog_new(
  93 + GTK_WINDOW(window),
  94 + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
  95 + GTK_MESSAGE_ERROR,
  96 + GTK_BUTTONS_OK,
  97 + _( "Can't get D-Bus proxy object" ));
  98 +
  99 + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message);
  100 + g_error_free(error);
  101 +
  102 + gtk_dialog_run(GTK_DIALOG(dialog));
  103 + gtk_widget_destroy(dialog);
  104 +
  105 + return -1;
  106 + }
  107 + */
  108 +
  109 + for(id='a'; id < 'z' && !error && !dBus->proxy; id++) {
  110 +
  111 + gchar *name = g_strdup_printf("br.com.bb.%s.%c",gtk_widget_get_name(window),id);
  112 +
  113 + debug("Requesting \"%s\"",name);
  114 +
  115 + // https://dbus.freedesktop.org/doc/dbus-specification.html
  116 + GVariant * response =
  117 + g_dbus_connection_call_sync (
  118 + dBus->connection,
  119 + DBUS_SERVICE_DBUS,
  120 + DBUS_PATH_DBUS,
  121 + DBUS_INTERFACE_DBUS,
  122 + "RequestName",
  123 + g_variant_new ("(su)", name, DBUS_NAME_FLAG_DO_NOT_QUEUE),
  124 + NULL,
  125 + G_DBUS_CALL_FLAGS_NONE,
  126 + -1,
  127 + NULL,
  128 + &error
  129 + );
  130 +
  131 + if(error) {
  132 + g_message("Can't request \"%s\": %s",name,error->message);
  133 + g_error_free(error);
  134 + error = NULL;
  135 + }
  136 +
  137 + if(response) {
  138 +
  139 + guint32 reply = 0;
  140 + g_variant_get(response, "(u)", &reply);
  141 + g_variant_unref(response);
  142 +
  143 + if(reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
  144 +
  145 + dBus->proxy = g_dbus_proxy_new_sync(
  146 + dBus->connection,
  147 + G_DBUS_PROXY_FLAGS_NONE,
  148 + NULL, // GDBusInterfaceInfo
  149 + name, // name
  150 + "/br/com/bb/" PACKAGE_NAME "/terminal", // object path
  151 + "br.com.bb." PACKAGE_NAME ".terminal", // interface
  152 + NULL, // GCancellable
  153 + &error );
  154 +
  155 + gchar * widget_name = g_strdup_printf("%s:%c",gtk_widget_get_name(window),id);
  156 + v3270_set_session_name(terminal, widget_name);
  157 + g_free(widget_name);
  158 +
  159 + g_message("Got %s - %s", name, v3270_get_session_name(terminal));
  160 +
  161 + }
  162 +
  163 + }
  164 +
  165 + g_free(name);
  166 +
  167 + }
  168 +
  169 + if(!dBus->proxy) {
  170 + GtkWidget *dialog = gtk_message_dialog_new(
  171 + GTK_WINDOW(window),
  172 + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
  173 + GTK_MESSAGE_ERROR,
  174 + GTK_BUTTONS_OK,
  175 + _( "Can't get DBUS object name" ));
  176 +
  177 + gtk_dialog_run(GTK_DIALOG(dialog));
  178 + gtk_widget_destroy(dialog);
  179 +
  180 + return -1;
  181 + }
  182 +
  183 + // Got D-Bus name, register object.
  184 +
  185 + return 0;
  186 +
  187 + }
  188 +
  189 + #endif // !_WIN32
  190 +
  191 +
src/core/methods.c 0 → 100644
@@ -0,0 +1,172 @@ @@ -0,0 +1,172 @@
  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 main.c e possui - linhas de código.
  22 + *
  23 + * Referências:
  24 + *
  25 + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c
  26 + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c
  27 + *
  28 + * Contatos:
  29 + *
  30 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  31 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  32 + *
  33 + */
  34 +
  35 +#include <config.h>
  36 +#include <string.h>
  37 +#include <lib3270/ipc.h>
  38 +#include <lib3270.h>
  39 +#include <lib3270/actions.h>
  40 +
  41 +// #include <dbus/dbus-glib.h>
  42 +// #include <dbus/dbus-glib-bindings.h>
  43 +
  44 +GVariant * ipc3270_method_call(GObject *object, const gchar *method_name, GVariant *parameters, GError **error) {
  45 +
  46 + size_t ix;
  47 +
  48 + debug("%s(%s)",__FUNCTION__,method_name);
  49 +
  50 + if(!g_ascii_strcasecmp(method_name,"getString"))
  51 + {
  52 + return ipc3270_GVariant_from_input_string(object, lib3270_get_string_at_address(ipc3270_get_session(object),0,-1,'\n'), error);
  53 + }
  54 + else if(!g_ascii_strcasecmp(method_name,"setString"))
  55 + {
  56 + gchar *text = NULL;
  57 + g_variant_get(parameters, "(&s)", &text);
  58 +
  59 + g_autofree gchar * converted = ipc3270_convert_output_string(object, text, error);
  60 + if(lib3270_input_string(ipc3270_get_session(object),(const unsigned char *) converted) < 0)
  61 + {
  62 + // Failed!
  63 + ipc3270_set_error(object,errno,error);
  64 + return NULL;
  65 + }
  66 +
  67 + // Suceeded
  68 + return g_variant_new_int16((gint16) 0);
  69 +
  70 + }
  71 + else if(!g_ascii_strcasecmp(method_name,"setStringAt"))
  72 + {
  73 + gint row,col;
  74 + gchar *text = NULL;
  75 + g_variant_get(parameters, "(ii&s)", &row, &col, &text);
  76 +
  77 + g_autofree gchar * converted = ipc3270_convert_output_string(object, text, error);
  78 + if(lib3270_set_string_at(ipc3270_get_session(object),row,col,(const unsigned char *) converted) < 0)
  79 + {
  80 + // Failed!
  81 + ipc3270_set_error(object,errno,error);
  82 + return NULL;
  83 + }
  84 +
  85 + // Suceeded
  86 + return g_variant_new_int16((gint16) 0);
  87 +
  88 + }
  89 + else if(!g_ascii_strcasecmp(method_name,"getStringAt"))
  90 + {
  91 + gint row,col,len;
  92 + guchar lf;
  93 + g_variant_get(parameters, "(iiy)", &row, &col, &len,&lf);
  94 +
  95 + return ipc3270_GVariant_from_input_string(object,lib3270_get_string_at(ipc3270_get_session(object), row, col, len, lf),error);
  96 +
  97 + }
  98 + else if(!g_ascii_strcasecmp(method_name,"setStringAtAddress"))
  99 + {
  100 + gint addr;
  101 + gchar *text = NULL;
  102 + g_variant_get(parameters, "(i&s)", &addr, &text);
  103 +
  104 + g_autofree gchar * converted = ipc3270_convert_output_string(object, text, error);
  105 + if(lib3270_set_string_at_address(ipc3270_get_session(object),addr,(unsigned char *) converted) < 0)
  106 + {
  107 + // Failed!
  108 + ipc3270_set_error(object,errno,error);
  109 + return NULL;
  110 + }
  111 +
  112 + // Suceeded
  113 + return g_variant_new_int16((gint16) 0);
  114 +
  115 + }
  116 + else if(!g_ascii_strcasecmp(method_name,"getStringAtAddress"))
  117 + {
  118 + gint addr,len;
  119 + guchar lf;
  120 + g_variant_get(parameters, "(iiy)", &addr, &len, &lf);
  121 +
  122 + return ipc3270_GVariant_from_input_string(object,lib3270_get_string_at_address(ipc3270_get_session(object), addr, len, lf),error);
  123 +
  124 + }
  125 + // Check action table.
  126 + const LIB3270_ACTION_ENTRY * actions = lib3270_get_action_table();
  127 + for(ix = 0; actions[ix].name; ix++)
  128 + {
  129 + if(!g_ascii_strcasecmp(actions[ix].name,method_name)) {
  130 +
  131 + int rc = actions[ix].call(ipc3270_get_session(object));
  132 + if(rc)
  133 + {
  134 + // Failed
  135 + ipc3270_set_error(object,errno,error);
  136 + return NULL;
  137 + }
  138 +
  139 + // Suceeded
  140 + return g_variant_new_int16((gint16) 0);
  141 +
  142 + }
  143 + }
  144 +
  145 + // Check int methods
  146 + const IPC_METHOD_INT_ARG * int_methods = ipc3270_get_int_arg_methods();
  147 +
  148 + for(ix = 0; int_methods[ix].name; ix++)
  149 + {
  150 + if(!g_ascii_strcasecmp(int_methods[ix].name,method_name)) {
  151 +
  152 + gint value;
  153 + g_variant_get(parameters, "(i)", &value);
  154 +
  155 + int rc = int_methods[ix].call(ipc3270_get_session(object), value);
  156 + if(rc)
  157 + {
  158 + // Failed
  159 + ipc3270_set_error(object,errno,error);
  160 + return NULL;
  161 + }
  162 +
  163 + // Suceeded
  164 + return g_variant_new_int16((gint16) 0);
  165 +
  166 + }
  167 +
  168 + }
  169 +
  170 + return NULL;
  171 +
  172 +}
src/core/setproperties.c 0 → 100644
@@ -0,0 +1,151 @@ @@ -0,0 +1,151 @@
  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 main.c e possui - linhas de código.
  22 + *
  23 + * Referências:
  24 + *
  25 + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c
  26 + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c
  27 + *
  28 + * Contatos:
  29 + *
  30 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  31 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  32 + *
  33 + */
  34 +
  35 +#include <config.h>
  36 +#include <lib3270/ipc.h>
  37 +#include <lib3270.h>
  38 +#include <lib3270/properties.h>
  39 +
  40 +// #include <dbus/dbus-glib.h>
  41 +// #include <dbus/dbus-glib-bindings.h>
  42 +
  43 +gboolean ipc3270_set_property(GObject *object, const gchar *property_name, GVariant *value, GError **error) {
  44 +
  45 + // Check for property
  46 + size_t ix;
  47 +
  48 + // Boolean properties
  49 + const LIB3270_INT_PROPERTY * boolprop = lib3270_get_boolean_properties_list();
  50 + for(ix = 0; boolprop[ix].name; ix++) {
  51 +
  52 + if(boolprop[ix].set && !g_ascii_strcasecmp(boolprop[ix].name, property_name)) {
  53 +
  54 + // Found it!
  55 + if(boolprop[ix].set(ipc3270_get_session(object), (int) (g_variant_get_boolean(value) ? 1 : 0))) {
  56 +
  57 + // Erro!
  58 + g_set_error (error,
  59 + G_IO_ERROR,
  60 + G_IO_ERROR_FAILED,
  61 + g_strerror(errno)
  62 + );
  63 +
  64 + return FALSE;
  65 + }
  66 +
  67 + return TRUE;
  68 +
  69 + }
  70 +
  71 + }
  72 +
  73 + // Integer properties
  74 + const LIB3270_INT_PROPERTY * intprop = lib3270_get_int_properties_list();
  75 + for(ix = 0; intprop[ix].name; ix++) {
  76 +
  77 + if(intprop[ix].set && !g_ascii_strcasecmp(intprop[ix].name, property_name)) {
  78 +
  79 + // Found it!
  80 + if(intprop[ix].set(ipc3270_get_session(object), (int) (g_variant_get_boolean(value) ? 1 : 0))) {
  81 +
  82 + // Erro!
  83 + g_set_error (error,
  84 + G_IO_ERROR,
  85 + G_IO_ERROR_FAILED,
  86 + g_strerror(errno)
  87 + );
  88 +
  89 + return FALSE;
  90 + }
  91 +
  92 + return TRUE;
  93 +
  94 + }
  95 +
  96 + }
  97 +
  98 + // String properties
  99 + const LIB3270_STRING_PROPERTY * strprop = lib3270_get_string_properties_list();
  100 + for(ix = 0; strprop[ix].name; ix++) {
  101 +
  102 + if(strprop[ix].set && !g_ascii_strcasecmp(strprop[ix].name, property_name)) {
  103 +
  104 + // Found it!
  105 + if(strprop[ix].set(ipc3270_get_session(object), g_variant_get_string(value,NULL))) {
  106 +
  107 + // Erro!
  108 + g_set_error (error,
  109 + G_IO_ERROR,
  110 + G_IO_ERROR_FAILED,
  111 + g_strerror(errno)
  112 + );
  113 +
  114 + return FALSE;
  115 + }
  116 +
  117 + return TRUE;
  118 +
  119 + }
  120 +
  121 + }
  122 +
  123 + // Check for toggle
  124 + LIB3270_TOGGLE toggle = lib3270_get_toggle_id(property_name);
  125 + if(toggle != (LIB3270_TOGGLE) -1) {
  126 +
  127 + // Is a Tn3270 toggle, get it!
  128 + if(lib3270_set_toggle(ipc3270_get_session(object),toggle,(int) g_variant_get_int32(value))) {
  129 +
  130 + // Erro!
  131 + g_set_error (error,
  132 + G_IO_ERROR,
  133 + G_IO_ERROR_FAILED,
  134 + g_strerror(errno)
  135 + );
  136 +
  137 + return FALSE;
  138 +
  139 + }
  140 +
  141 + return TRUE;
  142 + }
  143 +
  144 + g_set_error (error,
  145 + G_IO_ERROR,
  146 + G_IO_ERROR_NOT_FOUND,
  147 + "Can't find any property named %s", property_name
  148 + );
  149 +
  150 + return FALSE;
  151 +}
src/core/windows/gobject.c 0 → 100644
@@ -0,0 +1,132 @@ @@ -0,0 +1,132 @@
  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 gobject.c 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 "gobject.h"
  31 +#include <lib3270.h>
  32 +#include <lib3270/actions.h>
  33 +#include <lib3270/properties.h>
  34 +
  35 +G_DEFINE_TYPE(ipc3270, ipc3270, G_TYPE_OBJECT)
  36 +
  37 +static void ipc3270_finalize(GObject *object) {
  38 +
  39 + ipc3270 * ipc = IPC3270(object);
  40 +
  41 +
  42 + G_OBJECT_CLASS(ipc3270_parent_class)->finalize(object);
  43 +}
  44 +
  45 +
  46 +static void ipc3270_class_init(ipc3270Class *klass) {
  47 +
  48 + debug("%s",__FUNCTION__);
  49 +
  50 + GObjectClass *object_class;
  51 + object_class = G_OBJECT_CLASS (klass);
  52 + object_class->finalize = ipc3270_finalize;
  53 +
  54 +}
  55 +
  56 +static void ipc3270_init(ipc3270 *object) {
  57 +
  58 + debug("%s",__FUNCTION__);
  59 + object->error_domain = g_quark_from_static_string(PACKAGE_NAME);
  60 +
  61 +}
  62 +
  63 +GObject * ipc3270_new() {
  64 + return g_object_new(GLIB_TYPE_IPC3270, NULL);
  65 +}
  66 +
  67 +void ipc3270_set_session(GObject *object, H3270 *hSession, const char *name, GError **error) {
  68 +
  69 + char id;
  70 +
  71 + ipc3270 * ipc = IPC3270(object);
  72 + ipc->hSession = hSession;
  73 +
  74 + for(id='A';id < 'Z';id++) {
  75 +
  76 + gchar * pipename = g_strdup_printf("\\\\.\\pipe\\%s\\%c",name,id);
  77 + gchar * ptr;
  78 + HANDLE hPipe;
  79 +
  80 + for(ptr=pipename;*ptr;ptr++)
  81 + *ptr = g_ascii_tolower(*ptr);
  82 +
  83 + hPipe = CreateNamedPipe( TEXT(pipename), // pipe name
  84 + PIPE_ACCESS_DUPLEX | // read/write access
  85 + FILE_FLAG_OVERLAPPED, // overlapped mode
  86 + PIPE_TYPE_MESSAGE | // pipe type
  87 + PIPE_READMODE_MESSAGE | // pipe mode
  88 + PIPE_WAIT, // blocking mode
  89 + 1, // number of instances
  90 + PIPE_BUFFER_LENGTH, // output buffer size
  91 + PIPE_BUFFER_LENGTH, // input buffer size
  92 + NMPWAIT_USE_DEFAULT_WAIT, // client time-out
  93 + NULL); // default security attributes
  94 +
  95 + debug("%s = %p",pipename,hPipe);
  96 + g_free(pipename);
  97 +
  98 + if(hPipe != INVALID_HANDLE_VALUE) {
  99 +
  100 + ipc->source = (IPC3270_PIPE_SOURCE *) g_source_new(&ipc3270_source_funcs,sizeof(IPC3270_PIPE_SOURCE));
  101 +
  102 + lib3270_set_session_id(ipc->hSession, id);
  103 +
  104 + ipc->source->hPipe = hPipe;
  105 + ipc->source->state = PIPE_STATE_WAITING;
  106 + ipc->source->overlap.hEvent = CreateEvent( NULL,TRUE,TRUE,NULL);
  107 +
  108 + g_source_attach((GSource *) ipc->source,NULL);
  109 +
  110 + // IO_accept(source);
  111 + ipc3270_wait_for_client(ipc->source);
  112 +
  113 + break;
  114 + }
  115 +
  116 + }
  117 +
  118 +
  119 +}
  120 +
  121 +const gchar * ipc3270_get_display_charset(GObject *object) {
  122 + return lib3270_get_display_charset(IPC3270(object)->hSession);
  123 +}
  124 +
  125 +H3270 * ipc3270_get_session(GObject *object) {
  126 + return IPC3270(object)->hSession;
  127 +}
  128 +
  129 +void ipc3270_set_error(GObject *object, int errcode, GError **error) {
  130 + g_set_error(error,IPC3270(object)->error_domain,errcode,"%s",strerror(errcode));
  131 +}
  132 +
src/core/windows/gobject.h 0 → 100644
@@ -0,0 +1,95 @@ @@ -0,0 +1,95 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como - e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 + /**
  32 + * @brief Private definitions for pw3270 IPC windows module.
  33 + *
  34 + */
  35 +
  36 +#ifndef WINDOWS_GOBJECT_H_INCLUDED
  37 +
  38 + #define WINDOWS_GOBJECT_H_INCLUDED
  39 +
  40 + #include <windows.h>
  41 + #include <config.h>
  42 +
  43 + #define ENABLE_NLS
  44 + #define GETTEXT_PACKAGE PACKAGE_NAME
  45 +
  46 + #include <libintl.h>
  47 + #include <glib/gi18n.h>
  48 + #include <gio/gio.h>
  49 +
  50 + #include <lib3270.h>
  51 + #include <lib3270/ipc.h>
  52 +
  53 + #define PIPE_BUFFER_LENGTH 8192
  54 +
  55 + G_BEGIN_DECLS
  56 +
  57 + typedef struct _ipc3270 ipc3270;
  58 + typedef struct _ipc3270Class ipc3270Class;
  59 + typedef struct _ipc3270Request ipc3270Request;
  60 +
  61 + typedef enum _ipc3270_pipe_state {
  62 + PIPE_STATE_WAITING,
  63 + PIPE_STATE_READ,
  64 + PIPE_STATE_PENDING_READ,
  65 + PIPE_STATE_UNDEFINED
  66 + } IPC3270_PIPE_STATE;
  67 +
  68 + typedef struct _ipc3270_pipe_source {
  69 + GSource gsrc;
  70 + HANDLE hPipe;
  71 +
  72 + IPC3270_PIPE_STATE state;
  73 +
  74 + OVERLAPPED overlap;
  75 + unsigned char buffer[PIPE_BUFFER_LENGTH+1];
  76 +
  77 + } IPC3270_PIPE_SOURCE;
  78 +
  79 + struct _ipc3270 {
  80 + H3270 * hSession;
  81 + IPC3270_PIPE_SOURCE * source;
  82 + GQuark error_domain;
  83 + };
  84 +
  85 + struct _ipc3270Class {
  86 + GObjectClass parent;
  87 + };
  88 +
  89 + G_GNUC_INTERNAL GSourceFuncs ipc3270_source_funcs;
  90 +
  91 + G_GNUC_INTERNAL void ipc3270_wait_for_client(IPC3270_PIPE_SOURCE *source);
  92 +
  93 + G_END_DECLS
  94 +
  95 +#endif // WINDOWS_GOBJECT_H_INCLUDED
src/core/windows/inout.c 0 → 100644
@@ -0,0 +1,295 @@ @@ -0,0 +1,295 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como inout.c e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 +
  32 + /**
  33 + * @brief Pack/Unpack IPC data block.
  34 + *
  35 + */
  36 +
  37 + #include <config.h>
  38 + #include <lib3270/ipc.h>
  39 + #include <string.h>
  40 + #include <stdlib.h>
  41 +
  42 +/*---[ Implement ]----------------------------------------------------------------------------------*/
  43 +
  44 +unsigned char * ipc3270_pack(const gchar * name, int id, GVariant *values, size_t * szPacket) {
  45 +
  46 + GVariantIter iter;
  47 + gsize count = g_variant_iter_init(&iter, values);
  48 + g_autofree char * types = g_new0(char, count);
  49 + GVariant * child;
  50 + size_t ix = 0;
  51 +
  52 + // Init packet size;
  53 + *szPacket = strlen(name) + 1 + (sizeof(guint16) * 2) ;
  54 +
  55 + g_print("Packaging %u itens for \"%s\"\n", (unsigned int) count, name);
  56 + while ((child = g_variant_iter_next_value (&iter))) {
  57 +
  58 + // g_print("type='%s' size=%u\n", g_variant_get_type_string(child), (unsigned int) g_variant_get_size(child));
  59 +
  60 + types[ix] = g_variant_get_type_string(child)[0];
  61 + *szPacket += (1+g_variant_get_size(child));
  62 +
  63 + g_variant_unref(child);
  64 + ix++;
  65 + }
  66 +
  67 + // Allocate buffer
  68 + unsigned char * outputBuffer = g_malloc0(*szPacket);
  69 + unsigned char * txtptr = outputBuffer;
  70 +
  71 + // Add name
  72 + strcpy((char *) txtptr,name);
  73 + txtptr += strlen((char *) txtptr) + 1;
  74 +
  75 + // Add ID
  76 + *((guint16 *) txtptr) = (guint16) id;
  77 + txtptr += sizeof(guint16);
  78 +
  79 + // Update ptr;
  80 + *((guint16 *) txtptr) = (guint16) count;
  81 + txtptr += sizeof(guint16);
  82 +
  83 + ix = 0;
  84 + g_variant_iter_init(&iter, values);
  85 + while ((child = g_variant_iter_next_value (&iter))) {
  86 +
  87 + debug("type='%s' size=%u index=%u", g_variant_get_type_string(child), (unsigned int) g_variant_get_size(child), (unsigned int) (txtptr - outputBuffer));
  88 +
  89 + *(txtptr++) = types[ix];
  90 +
  91 + switch(types[ix]) {
  92 +
  93 + // https://developer.gnome.org/glib/stable/gvariant-format-strings.html
  94 +
  95 + case 's':
  96 + strcpy((char *) txtptr,g_variant_get_string(child,NULL));
  97 + txtptr += (strlen((char *) txtptr)+1);
  98 + break;
  99 +
  100 + case 'b': // gboolean
  101 + *(txtptr++) = g_variant_get_boolean(child) ? 1 : 0;
  102 + break;
  103 +
  104 + case 'y': // guchar
  105 + *(txtptr++) = g_variant_get_byte(child);
  106 + break;
  107 +
  108 + case 'n': // gint16
  109 + *((gint16 *) txtptr) = g_variant_get_int16(child);
  110 + txtptr += sizeof(gint16);
  111 + break;
  112 +
  113 + case 'q': // guint16
  114 + *((guint16 *) txtptr) = g_variant_get_uint16(child);
  115 + txtptr += sizeof(guint16);
  116 + break;
  117 +
  118 + case 'i': // gint32
  119 + case 'h': // gint32
  120 + *((gint32 *) txtptr) = g_variant_get_int32(child);
  121 + txtptr += sizeof(gint32);
  122 + break;
  123 +
  124 + case 'u': // guint32
  125 + *((guint32 *) txtptr) = g_variant_get_uint32(child);
  126 + txtptr += sizeof(guint32);
  127 + break;
  128 +
  129 + case 'x': // gint64
  130 + *((gint64 *) txtptr) = g_variant_get_int64(child);
  131 + txtptr += sizeof(gint64);
  132 + break;
  133 +
  134 + case 't': // guint64
  135 + *((guint64 *) txtptr) = g_variant_get_uint64(child);
  136 + txtptr += sizeof(guint64);
  137 + break;
  138 +
  139 + default:
  140 + errno = EINVAL;
  141 + g_free(outputBuffer);
  142 + return NULL;
  143 + }
  144 +
  145 + g_variant_unref(child);
  146 + ix++;
  147 + }
  148 +
  149 + return outputBuffer;
  150 +}
  151 +
  152 +GVariant * ipc3270_unpack(const unsigned char *packet, int *id) {
  153 +
  154 + const unsigned char *txtptr;
  155 + size_t ix;
  156 +
  157 + // Skip packet name.
  158 + packet += strlen((const char *) packet)+1;
  159 +
  160 + // Get Packet ID or error code.
  161 + if(id) {
  162 + *id = (int) *((guint16 *) packet);
  163 + }
  164 + packet += sizeof(guint16);
  165 +
  166 + // Get argument count.
  167 + size_t arguments = (size_t) * ((guint16 *) packet);
  168 + packet += sizeof(guint16);
  169 +
  170 + debug("Unpacking package with %u itens", (unsigned int) arguments);
  171 +
  172 + // Scan for argument types.
  173 + g_autofree gchar * descrs = g_malloc0(arguments+3);
  174 + descrs[0] = '(';
  175 + descrs[arguments+1] = ')';
  176 +
  177 + txtptr = packet;
  178 + for(ix = 0; ix < arguments; ix++) {
  179 +
  180 + debug("Format(%u): %c",(unsigned int) ix, *txtptr);
  181 +
  182 + descrs[ix+1] = *(txtptr++);
  183 +
  184 + switch(descrs[ix+1]) {
  185 + case 's':
  186 + txtptr += strlen((char *) txtptr)+1;
  187 + break;
  188 +
  189 + case 'b': // gboolean
  190 + case 'y': // guchar
  191 + txtptr++;
  192 + break;
  193 +
  194 + case 'n': // gint16
  195 + txtptr += sizeof(gint16);
  196 + break;
  197 +
  198 + case 'q': // guint16
  199 + txtptr += sizeof(guint16);
  200 + break;
  201 +
  202 + case 'i': // gint32
  203 + case 'h': // gint32
  204 + txtptr += sizeof(gint32);
  205 + break;
  206 +
  207 + case 'u': // guint32
  208 + txtptr += sizeof(guint32);
  209 + break;
  210 +
  211 + case 'x': // gint64
  212 + txtptr += sizeof(gint64);
  213 + break;
  214 +
  215 + case 't': // guint64
  216 + txtptr += sizeof(guint64);
  217 + break;
  218 +
  219 + default:
  220 + errno = EINVAL;
  221 + return NULL;
  222 + }
  223 + }
  224 +
  225 + debug("Format: \"%s\"\n",descrs);
  226 +
  227 + GVariantBuilder builder;
  228 + g_variant_builder_init(&builder,G_VARIANT_TYPE(descrs));
  229 +
  230 + txtptr = packet;
  231 + for(ix = 0; ix < arguments; ix++) {
  232 +
  233 + debug("Format(%u): %c",(unsigned int) ix, *txtptr);
  234 + txtptr++;
  235 +
  236 + switch(descrs[ix+1]) {
  237 + case 's':
  238 + g_variant_builder_add(&builder, "s", txtptr);
  239 + txtptr += strlen((char *) txtptr)+1;
  240 + break;
  241 +
  242 + case 'b': // gboolean
  243 + g_variant_builder_add(&builder, "b", *((gboolean *) txtptr));
  244 + txtptr++;
  245 + break;
  246 +
  247 + case 'y': // guchar
  248 + g_variant_builder_add(&builder, "y", *((guchar *) txtptr));
  249 + txtptr++;
  250 + break;
  251 +
  252 + case 'n': // gint16
  253 + g_variant_builder_add(&builder, "n", *((gint16 *) txtptr));
  254 + txtptr += sizeof(gint16);
  255 + break;
  256 +
  257 + case 'q': // guint16
  258 + g_variant_builder_add(&builder, "q", *((guint16 *) txtptr));
  259 + txtptr += sizeof(guint16);
  260 + break;
  261 +
  262 + case 'i': // gint32
  263 + g_variant_builder_add(&builder, "i", *((gint32 *) txtptr));
  264 + txtptr += sizeof(gint32);
  265 + break;
  266 +
  267 + case 'h': // gint32
  268 + g_variant_builder_add(&builder, "h", *((gint32 *) txtptr));
  269 + txtptr += sizeof(gint32);
  270 + break;
  271 +
  272 + case 'u': // guint32
  273 + g_variant_builder_add(&builder, "u", *((guint32 *) txtptr));
  274 + txtptr += sizeof(guint32);
  275 + break;
  276 +
  277 + case 'x': // gint64
  278 + g_variant_builder_add(&builder, "x", *((gint64 *) txtptr));
  279 + txtptr += sizeof(gint64);
  280 + break;
  281 +
  282 + case 't': // guint64
  283 + g_variant_builder_add(&builder, "t", *((guint64 *) txtptr));
  284 + txtptr += sizeof(guint64);
  285 + break;
  286 +
  287 + default:
  288 + errno = EINVAL;
  289 + return NULL;
  290 + }
  291 + }
  292 +
  293 + return g_variant_builder_end(&builder);
  294 +
  295 +}
src/core/windows/pipesource.c 0 → 100644
@@ -0,0 +1,214 @@ @@ -0,0 +1,214 @@
  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 pipesource.c 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 "gobject.h"
  31 +
  32 +void ipc3270_wait_for_client(IPC3270_PIPE_SOURCE *source) {
  33 +
  34 + if(ConnectNamedPipe(source->hPipe,&source->overlap)) {
  35 + g_message("Error %u in ConnectNamedPipe",(unsigned int) GetLastError());
  36 + // popup_lasterror("%s",_( "Error in ConnectNamedPipe" ));
  37 + return;
  38 + }
  39 +
  40 + switch(GetLastError()) {
  41 + case ERROR_IO_PENDING: // The overlapped connection in progress.
  42 + source->state = PIPE_STATE_WAITING;
  43 + break;
  44 +
  45 +
  46 + case ERROR_PIPE_CONNECTED: // Client is already connected, so signal an event.
  47 + if(SetEvent(source->overlap.hEvent))
  48 + break;
  49 +
  50 + default:
  51 + g_message("Error %u in ConnectNamedPipe",(unsigned int) GetLastError());
  52 + // popup_lasterror("%s", _( "ConnectNamedPipe failed" ));
  53 + }
  54 +
  55 +}
  56 +
  57 +static gboolean IO_prepare(GSource *source, gint *timeout) {
  58 + /*
  59 + * Called before all the file descriptors are polled.
  60 + * If the source can determine that it is ready here
  61 + * (without waiting for the results of the poll() call)
  62 + * it should return TRUE.
  63 + *
  64 + * It can also return a timeout_ value which should be the maximum
  65 + * timeout (in milliseconds) which should be passed to the poll() call.
  66 + * The actual timeout used will be -1 if all sources returned -1,
  67 + * or it will be the minimum of all the timeout_ values
  68 + * returned which were >= 0.
  69 + *
  70 + */
  71 + if(WaitForSingleObject(((IPC3270_PIPE_SOURCE *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)
  72 + return TRUE;
  73 +
  74 + *timeout = 10;
  75 +
  76 + return FALSE;
  77 +
  78 +}
  79 +
  80 +static gboolean IO_check(GSource *source) {
  81 + /*
  82 + * Called after all the file descriptors are polled.
  83 + * The source should return TRUE if it is ready to be dispatched.
  84 + * Note that some time may have passed since the previous prepare
  85 + * function was called, so the source should be checked again here.
  86 + *
  87 + */
  88 + if(WaitForSingleObject(((IPC3270_PIPE_SOURCE *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)
  89 + return TRUE;
  90 +
  91 + return FALSE;
  92 +}
  93 +
  94 +static void process_input(IPC3270_PIPE_SOURCE *source, DWORD cbRead) {
  95 +
  96 +}
  97 +
  98 +static void read_input_pipe(IPC3270_PIPE_SOURCE *source) {
  99 +
  100 + DWORD cbRead = 0;
  101 +
  102 + if(ReadFile(source->hPipe,source->buffer,PIPE_BUFFER_LENGTH,&cbRead,&source->overlap) && cbRead > 0)
  103 + process_input(source,cbRead);
  104 +
  105 + // The read operation is still pending.
  106 + switch(GetLastError())
  107 + {
  108 + case 0:
  109 + break;
  110 +
  111 + case ERROR_IO_PENDING:
  112 + source->state = PIPE_STATE_PENDING_READ;
  113 + break;
  114 +
  115 + case ERROR_PIPE_LISTENING:
  116 + source->state = PIPE_STATE_READ;
  117 + break;
  118 +
  119 + case ERROR_BROKEN_PIPE:
  120 +
  121 + if(!DisconnectNamedPipe(source->hPipe)) {
  122 +
  123 + g_message("Error %u on DisconnectNamedPipe", (unsigned int) GetLastError());
  124 +
  125 + } else {
  126 +
  127 + ipc3270_wait_for_client(source);
  128 +
  129 + }
  130 + break;
  131 +
  132 + case ERROR_PIPE_NOT_CONNECTED:
  133 + g_message("Cliente was disconnected");
  134 + break;
  135 +
  136 + default:
  137 + if(source->hPipe != INVALID_HANDLE_VALUE) {
  138 + g_message( "Error %u receiving message from pipe", (unsigned int) GetLastError());
  139 + }
  140 + }
  141 +
  142 +}
  143 +
  144 +
  145 +static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer data) {
  146 + /*
  147 + * Called to dispatch the event source,
  148 + * after it has returned TRUE in either its prepare or its check function.
  149 + * The dispatch function is passed in a callback function and data.
  150 + * The callback function may be NULL if the source was never connected
  151 + * to a callback using g_source_set_callback(). The dispatch function
  152 + * should call the callback function with user_data and whatever additional
  153 + * parameters are needed for this type of event source.
  154 + */
  155 + BOOL fSuccess;
  156 + DWORD cbRead = 0;
  157 +
  158 + fSuccess = GetOverlappedResult(((IPC3270_PIPE_SOURCE *) source)->hPipe,&((IPC3270_PIPE_SOURCE *) source)->overlap,&cbRead,FALSE );
  159 +
  160 + switch(((IPC3270_PIPE_SOURCE *) source)->state) {
  161 + case PIPE_STATE_WAITING:
  162 +
  163 + if(fSuccess) {
  164 +
  165 + g_message("Client is connected");
  166 + ((IPC3270_PIPE_SOURCE *) source)->state = PIPE_STATE_READ;
  167 +
  168 + } else {
  169 +
  170 + // popup_lasterror("%s", _( "Pipe connection failed" ));
  171 +
  172 + }
  173 + break;
  174 +
  175 + case PIPE_STATE_READ:
  176 + // trace("Reading pipe (cbRead=%d)",(int) cbRead);
  177 + read_input_pipe( (IPC3270_PIPE_SOURCE *) source);
  178 + break;
  179 +
  180 + case PIPE_STATE_PENDING_READ:
  181 + if(fSuccess && cbRead > 0)
  182 + process_input((IPC3270_PIPE_SOURCE *) source,cbRead);
  183 + ((IPC3270_PIPE_SOURCE *) source)->state = PIPE_STATE_READ;
  184 + break;
  185 +
  186 + case PIPE_STATE_UNDEFINED:
  187 + break;
  188 +
  189 + }
  190 +
  191 + return TRUE;
  192 +}
  193 +
  194 +static gboolean IO_closure(gpointer data) {
  195 + return 0;
  196 +}
  197 +
  198 +static void IO_finalize(GSource *source) {
  199 +
  200 + if( ((IPC3270_PIPE_SOURCE *) source)->hPipe != INVALID_HANDLE_VALUE) {
  201 + CloseHandle(((IPC3270_PIPE_SOURCE *) source)->hPipe);
  202 + ((IPC3270_PIPE_SOURCE *) source)->hPipe = INVALID_HANDLE_VALUE;
  203 + }
  204 +
  205 +}
  206 +
  207 +GSourceFuncs ipc3270_source_funcs = {
  208 + IO_prepare,
  209 + IO_check,
  210 + IO_dispatch,
  211 + IO_finalize,
  212 + IO_closure,
  213 + NULL
  214 +};
src/core/windows/resources.rc.in 0 → 100644
@@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
  1 +#include <windows.h>
  2 +
  3 +VS_VERSION_INFO VERSIONINFO
  4 +FILEVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0
  5 +PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0
  6 +
  7 +BEGIN
  8 +
  9 + BLOCK "StringFileInfo"
  10 + BEGIN
  11 + BLOCK "080904E4"
  12 + BEGIN
  13 + VALUE "FileDescription", "@PACKAGE_DESCRIPTION@\0"
  14 + VALUE "CompanyName", "Banco do Brasil S/A.\0"
  15 + VALUE "FileVersion", "@WIN32_VERSION@\0"
  16 + VALUE "LegalCopyright", "(C) 2017 Banco do Brasil S/A. All Rights Reserved\0"
  17 + VALUE "OriginalFilename", "@PACKAGE_TARNAME@@DLLEXT@\0"
  18 + VALUE "ProductName", "@PACKAGE_NAME@\0"
  19 + VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.0\0"
  20 + END
  21 + END
  22 +
  23 + BLOCK "VarFileInfo"
  24 + BEGIN
  25 + VALUE "Translation", 0x809, 0x04E4
  26 + END
  27 +
  28 +END
  29 +
src/getproperties.c
@@ -1,128 +0,0 @@ @@ -1,128 +0,0 @@
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 main.c e possui - linhas de código.  
22 - *  
23 - * Referências:  
24 - *  
25 - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c  
26 - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c  
27 - *  
28 - * Contatos:  
29 - *  
30 - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
31 - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)  
32 - *  
33 - */  
34 -  
35 -#include <config.h>  
36 -#include <lib3270/ipc.h>  
37 -#include <lib3270.h>  
38 -#include <lib3270/properties.h>  
39 -  
40 -#include <dbus/dbus-glib.h>  
41 -#include <dbus/dbus-glib-bindings.h>  
42 -  
43 -GVariant * ipc3270_get_property(GObject *object, const gchar *property_name, GError **error) {  
44 -  
45 - size_t ix;  
46 - errno = 0; // Just in case.  
47 -  
48 - // Boolean properties  
49 - const LIB3270_INT_PROPERTY * boolprop = lib3270_get_boolean_properties_list();  
50 - for(ix = 0; boolprop[ix].name; ix++) {  
51 -  
52 - if(boolprop[ix].get && !g_ascii_strcasecmp(boolprop[ix].name, property_name)) {  
53 -  
54 - // Found it!  
55 - int value = boolprop[ix].get(ipc3270_get_session(object));  
56 -  
57 - debug("%s=%d",property_name,value);  
58 -  
59 - if(value > 0 || errno == 0) {  
60 - return g_variant_new_boolean(value != 0);  
61 - }  
62 -  
63 - // Erro!  
64 - ipc3270_set_error(object,ENOENT,error);  
65 - return NULL;  
66 -  
67 - }  
68 -  
69 - }  
70 -  
71 - // int properties  
72 - const LIB3270_INT_PROPERTY * intprop = lib3270_get_int_properties_list();  
73 - for(ix = 0; intprop[ix].name; ix++) {  
74 -  
75 - if(intprop[ix].get && !g_ascii_strcasecmp(intprop[ix].name, property_name)) {  
76 -  
77 - // Found it!  
78 - int value = intprop[ix].get(ipc3270_get_session(object));  
79 -  
80 - debug("%s=%d",property_name,value);  
81 -  
82 - if(value > 0 || errno == 0) {  
83 - return g_variant_new_int16((gint16) value);  
84 - }  
85 -  
86 - // Erro!  
87 - ipc3270_set_error(object,errno,error);  
88 - return NULL;  
89 -  
90 - }  
91 -  
92 - }  
93 -  
94 - // String properties  
95 - const LIB3270_STRING_PROPERTY * strprop = lib3270_get_string_properties_list();  
96 - for(ix = 0; strprop[ix].name; ix++) {  
97 -  
98 - if(strprop[ix].get && !g_ascii_strcasecmp(strprop[ix].name, property_name)) {  
99 -  
100 - // Found it!  
101 - const char * value = strprop[ix].get(ipc3270_get_session(object));  
102 -  
103 - if(value) {  
104 - debug("%s=%s",property_name,value);  
105 - return g_variant_new_string(value);  
106 - }  
107 -  
108 - // Erro!  
109 - ipc3270_set_error(object,errno,error);  
110 - return NULL;  
111 -  
112 - }  
113 -  
114 - }  
115 -  
116 - // Check for toggle  
117 - LIB3270_TOGGLE toggle = lib3270_get_toggle_id(property_name);  
118 - if(toggle != (LIB3270_TOGGLE) -1) {  
119 -  
120 - // Is a Tn3270 toggle, get it!  
121 - return g_variant_new_boolean(lib3270_get_toggle( (ipc3270_get_session(object)), toggle) != 0);  
122 -  
123 - }  
124 -  
125 - return NULL;  
126 -  
127 -}  
128 -  
src/include/lib3270/ipc.h
@@ -69,6 +69,10 @@ @@ -69,6 +69,10 @@
69 gboolean ipc3270_set_property(GObject *object, const gchar *property_name, GVariant *value, GError **error); 69 gboolean ipc3270_set_property(GObject *object, const gchar *property_name, GVariant *value, GError **error);
70 GVariant * ipc3270_get_property(GObject *object, const gchar *property_name, GError **error); 70 GVariant * ipc3270_get_property(GObject *object, const gchar *property_name, GError **error);
71 71
  72 + // TODO: Move for windows private.h
  73 + unsigned char * ipc3270_pack(const gchar *name, int id, GVariant *values, size_t * szPacket);
  74 + GVariant * ipc3270_unpack(const unsigned char *packet, int *id);
  75 +
72 G_END_DECLS 76 G_END_DECLS
73 77
74 #ifdef DEBUG 78 #ifdef DEBUG
src/linux/dbus-definition.xml
@@ -1,9 +0,0 @@ @@ -1,9 +0,0 @@
1 -<?xml version="1.0" encoding="UTF-8" ?>  
2 -<node name="/br/com/bb/pw3270">  
3 - <interface name="br.com.bb.pw3270">  
4 - <method name="getRevision">  
5 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
6 - <arg type="s" name="revision" direction="out" />  
7 - </method>  
8 - </interface>  
9 -</node>  
src/linux/gobject.c
@@ -1,351 +0,0 @@ @@ -1,351 +0,0 @@
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 main.c e possui - linhas de código.  
22 - *  
23 - * Referências:  
24 - *  
25 - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c  
26 - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c  
27 - *  
28 - * Contatos:  
29 - *  
30 - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
31 - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)  
32 - *  
33 - */  
34 -  
35 -#include "gobject.h"  
36 -#include <lib3270.h>  
37 -#include <lib3270/actions.h>  
38 -#include <lib3270/properties.h>  
39 -  
40 -#include <dbus/dbus-glib.h>  
41 -#include <dbus/dbus-glib-bindings.h>  
42 -  
43 -G_DEFINE_TYPE(ipc3270, ipc3270, G_TYPE_OBJECT)  
44 -  
45 -static void ipc3270_finalize(GObject *object) {  
46 -  
47 - ipc3270 * ipc = IPC3270(object);  
48 -  
49 - debug("%s",__FUNCTION__);  
50 - if(ipc->id) {  
51 - g_dbus_connection_unregister_object(ipc->connection,ipc->id);  
52 - }  
53 -  
54 - G_OBJECT_CLASS(ipc3270_parent_class)->finalize(object);  
55 -}  
56 -  
57 -  
58 -static void ipc3270_class_init(ipc3270Class *klass) {  
59 -  
60 - debug("%s",__FUNCTION__);  
61 -  
62 - GObjectClass *object_class;  
63 - object_class = G_OBJECT_CLASS (klass);  
64 - object_class->finalize = ipc3270_finalize;  
65 -  
66 -}  
67 -  
68 -static void ipc3270_init(ipc3270 *object) {  
69 -  
70 - debug("%s",__FUNCTION__);  
71 - object->error_domain = g_quark_from_static_string(PACKAGE_NAME);  
72 -  
73 -}  
74 -  
75 -GObject * ipc3270_new() {  
76 - return g_object_new(GLIB_TYPE_IPC3270, NULL);  
77 -}  
78 -  
79 -static void  
80 - method_call (  
81 - G_GNUC_UNUSED GDBusConnection *connection,  
82 - G_GNUC_UNUSED const gchar *sender,  
83 - G_GNUC_UNUSED const gchar *object_path,  
84 - G_GNUC_UNUSED const gchar *interface_name,  
85 - const gchar *method_name,  
86 - GVariant *parameters,  
87 - GDBusMethodInvocation *invocation,  
88 - gpointer user_data) {  
89 -  
90 - g_autoptr (GError) error = NULL;  
91 -  
92 - GVariant * rc = ipc3270_method_call(G_OBJECT(user_data), method_name, parameters, &error);  
93 -  
94 - if(error) {  
95 -  
96 - if(rc) {  
97 - g_variant_unref(rc);  
98 - }  
99 -  
100 - g_dbus_method_invocation_return_gerror(invocation, error);  
101 -  
102 - } else if(rc) {  
103 -  
104 - g_dbus_method_invocation_return_value(invocation, rc);  
105 -  
106 - } else {  
107 -  
108 - g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Invalid or unexpected method call");  
109 -  
110 - }  
111 -  
112 -  
113 -}  
114 -  
115 -static GVariant *  
116 - get_property (  
117 - G_GNUC_UNUSED GDBusConnection *connection,  
118 - G_GNUC_UNUSED const gchar *sender,  
119 - G_GNUC_UNUSED const gchar *object_path,  
120 - G_GNUC_UNUSED const gchar *interface_name,  
121 - const gchar *property_name,  
122 - GError **error,  
123 - gpointer user_data)  
124 -{  
125 -  
126 - return ipc3270_get_property(G_OBJECT(user_data), property_name, error);  
127 -  
128 -}  
129 -  
130 -static gboolean  
131 - set_property (  
132 - G_GNUC_UNUSED GDBusConnection *connection,  
133 - G_GNUC_UNUSED const gchar *sender,  
134 - G_GNUC_UNUSED const gchar *object_path,  
135 - G_GNUC_UNUSED const gchar *interface_name,  
136 - const gchar *property_name,  
137 - GVariant *value,  
138 - GError **error,  
139 - gpointer user_data)  
140 -{  
141 -  
142 - return ipc3270_set_property(G_OBJECT(user_data), property_name, value, error);  
143 -  
144 -}  
145 -  
146 -  
147 -void ipc3270_set_session(GObject *object, H3270 *hSession, const char *name, GError **error) {  
148 -  
149 - char id;  
150 - int ix;  
151 -  
152 - static const GDBusInterfaceVTable interface_vtable = {  
153 - method_call,  
154 - get_property,  
155 - set_property  
156 - };  
157 -  
158 - ipc3270 * ipc = IPC3270(object);  
159 - ipc->hSession = hSession;  
160 -  
161 - ipc->connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, error);  
162 - if(*error) {  
163 - g_message("Can't get session bus: %s",(*error)->message);  
164 - return;  
165 - }  
166 -  
167 - g_dbus_connection_set_exit_on_close(ipc->connection,FALSE);  
168 -  
169 - for(id='a'; id < 'z' && !ipc->id && !*error; id++) {  
170 -  
171 - gchar *object_name = g_strdup_printf("br.com.bb.%s.%c",name,id);  
172 -  
173 - debug("Requesting \"%s\"",object_name);  
174 -  
175 - // https://dbus.freedesktop.org/doc/dbus-specification.html  
176 - GError *err = NULL;  
177 -  
178 - GVariant * response =  
179 - g_dbus_connection_call_sync (  
180 - ipc->connection,  
181 - DBUS_SERVICE_DBUS,  
182 - DBUS_PATH_DBUS,  
183 - DBUS_INTERFACE_DBUS,  
184 - "RequestName",  
185 - g_variant_new ("(su)", object_name, DBUS_NAME_FLAG_DO_NOT_QUEUE),  
186 - NULL,  
187 - G_DBUS_CALL_FLAGS_NONE,  
188 - -1,  
189 - NULL,  
190 - &err  
191 - );  
192 -  
193 - if(err) {  
194 - g_message("Can't request \"%s\": %s",object_name,err->message);  
195 - g_error_free(err);  
196 - err = NULL;  
197 - }  
198 -  
199 - if(response) {  
200 -  
201 - guint32 reply = 0;  
202 - g_variant_get(response, "(u)", &reply);  
203 - g_variant_unref(response);  
204 -  
205 - if(reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {  
206 -  
207 - g_message("Got %s", object_name);  
208 -  
209 - lib3270_set_session_id(ipc->hSession, id);  
210 -  
211 - // Introspection data for the service we are exporting  
212 - GString * introspection = g_string_new(  
213 - "<node>\n"  
214 - " <interface name='br.com.bb.tn3270'>"  
215 - " <method name='connect'>"  
216 - " <arg type='s' name='url' direction='in'/>"  
217 - " <arg type='i' name='result' direction='out' />" \  
218 - " </method>"  
219 - " <method name='pfkey'>" \  
220 - " <arg type='i' name='keycode' direction='in'/>" \  
221 - " <arg type='i' name='result' direction='out' />" \  
222 - " </method>"  
223 - " <method name='pakey'>" \  
224 - " <arg type='i' name='keycode' direction='in'/>" \  
225 - " <arg type='i' name='result' direction='out' />" \  
226 - " </method>"  
227 - " <method name='getString'>" \  
228 - " <arg type='s' name='text' direction='out' />" \  
229 - " </method>" \  
230 - " <method name='setString'>" \  
231 - " <arg type='s' name='text' direction='in' />" \  
232 - " <arg type='i' name='result' direction='out' />" \  
233 - " </method>" \  
234 - " <method name='setStringAt'>" \  
235 - " <arg type='i' name='row' direction='in' />" \  
236 - " <arg type='i' name='col' direction='in' />" \  
237 - " <arg type='s' name='text' direction='in' />" \  
238 - " <arg type='i' name='result' direction='out' />" \  
239 - " </method>" \  
240 - " <method name= 'getStringAt'>" \  
241 - " <arg type='i' name='row' direction='in' />" \  
242 - " <arg type='i' name='col' direction='in' />" \  
243 - " <arg type='i' name='len' direction='in' />" \  
244 - " <arg type='y' name='lf' direction='in' />" \  
245 - " <arg type='s' name='text' direction='out' />" \  
246 - " </method>" \  
247 - " <method name='setStringAtAddress'>" \  
248 - " <arg type='i' name='addr' direction='in' />" \  
249 - " <arg type='s' name='text' direction='in' />" \  
250 - " <arg type='i' name='result' direction='out' />" \  
251 - " </method>" \  
252 - " <method name= 'getStringAtAddress'>" \  
253 - " <arg type='i' name='addr' direction='in' />" \  
254 - " <arg type='i' name='len' direction='in' />" \  
255 - " <arg type='y' name='lf' direction='in' />" \  
256 - " <arg type='s' name='text' direction='out' />" \  
257 - " </method>"  
258 -  
259 - );  
260 -  
261 - // Constrói métodos usando a tabela de controle  
262 - const LIB3270_ACTION_ENTRY * actions = lib3270_get_action_table();  
263 - for(ix = 0; actions[ix].name; ix++)  
264 - {  
265 - g_string_append_printf(  
266 - introspection, \  
267 - " <method name='%s'>" \  
268 - " </method>", actions[ix].name  
269 - );  
270 - }  
271 -  
272 - // Toggle properties  
273 - for(ix = 0; ix < (int) LIB3270_TOGGLE_COUNT; ix++) {  
274 - g_string_append_printf(introspection, " <property type='i' name='%s' access='readwrite'/>", lib3270_get_toggle_name((LIB3270_TOGGLE) ix));  
275 - }  
276 -  
277 - // Boolean properties  
278 - const LIB3270_INT_PROPERTY * bol_props = lib3270_get_boolean_properties_list();  
279 - for(ix = 0; bol_props[ix].name; ix++) {  
280 - debug("Boolean(%s)",bol_props[ix].name);  
281 - g_string_append_printf(introspection, " <property type='b' name='%s' access='%s'/>",  
282 - bol_props[ix].name,  
283 - ((bol_props[ix].set == NULL) ? "read" : "readwrite")  
284 - );  
285 - }  
286 -  
287 - // Integer properties  
288 - const LIB3270_INT_PROPERTY * int_props = lib3270_get_int_properties_list();  
289 - for(ix = 0; int_props[ix].name; ix++) {  
290 - g_string_append_printf(introspection, " <property type='i' name='%s' access='%s'/>",  
291 - int_props[ix].name,  
292 - ((int_props[ix].set == NULL) ? "read" : "readwrite")  
293 - );  
294 - }  
295 -  
296 - // String properties  
297 - const LIB3270_STRING_PROPERTY * str_props = lib3270_get_string_properties_list();  
298 - for(ix = 0; str_props[ix].name; ix++) {  
299 - g_string_append_printf(introspection, " <property type='s' name='%s' access='%s'/>",  
300 - str_props[ix].name,  
301 - ((str_props[ix].set == NULL) ? "read" : "readwrite")  
302 - );  
303 - }  
304 -  
305 - g_string_append(introspection,  
306 - " </interface>"  
307 - "</node>"  
308 - );  
309 -  
310 - gchar * introspection_xml = g_string_free(introspection,FALSE);  
311 -  
312 - debug("\n%s\n",introspection_xml);  
313 -  
314 - GDBusNodeInfo * introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);  
315 -  
316 - // Register object-id  
317 - ipc->id = g_dbus_connection_register_object (  
318 - ipc->connection,  
319 - "/br/com/bb/tn3270",  
320 - introspection_data->interfaces[0],  
321 - &interface_vtable,  
322 - ipc,  
323 - NULL,  
324 - error  
325 - );  
326 -  
327 - g_dbus_node_info_unref(introspection_data);  
328 - g_free(introspection_xml);  
329 -  
330 - break;  
331 - }  
332 -  
333 - }  
334 -  
335 - g_free(object_name);  
336 -  
337 - }  
338 -  
339 -}  
340 -  
341 -const gchar * ipc3270_get_display_charset(GObject *object) {  
342 - return lib3270_get_display_charset(IPC3270(object)->hSession);  
343 -}  
344 -  
345 -H3270 * ipc3270_get_session(GObject *object) {  
346 - return IPC3270(object)->hSession;  
347 -}  
348 -  
349 -void ipc3270_set_error(GObject *object, int errcode, GError **error) {  
350 - g_set_error(error,IPC3270(object)->error_domain,errcode,"%s",strerror(errcode));  
351 -}  
src/linux/gobject.h
@@ -1,77 +0,0 @@ @@ -1,77 +0,0 @@
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. Registro no INPI sob  
5 - * o nome G3270.  
6 - *  
7 - * Copyright (C) <2008> <Banco do Brasil S.A.>  
8 - *  
9 - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob  
10 - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela  
11 - * Free Software Foundation.  
12 - *  
13 - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER  
14 - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO  
15 - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para  
16 - * obter mais detalhes.  
17 - *  
18 - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este  
19 - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin  
20 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
21 - *  
22 - * Este programa está nomeado como - e possui - linhas de código.  
23 - *  
24 - * Contatos:  
25 - *  
26 - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
27 - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)  
28 - *  
29 - */  
30 -  
31 - /**  
32 - * @brief Private definitions for pw3270 IPC linux module.  
33 - *  
34 - */  
35 -  
36 -#ifndef LINUX_GOBJECT_H_INCLUDED  
37 -  
38 - #define LINUX_GOBJECT_H_INCLUDED  
39 -  
40 - #include <config.h>  
41 -  
42 - #define ENABLE_NLS  
43 - #define GETTEXT_PACKAGE PACKAGE_NAME  
44 -  
45 - #include <libintl.h>  
46 - #include <glib/gi18n.h>  
47 - #include <gio/gio.h>  
48 -  
49 - #include <lib3270.h>  
50 - #include <lib3270/ipc.h>  
51 -  
52 - G_BEGIN_DECLS  
53 -  
54 - typedef struct _ipc3270 ipc3270;  
55 - typedef struct _ipc3270Class ipc3270Class;  
56 -  
57 - struct _ipc3270 {  
58 - GObject parent;  
59 - GDBusConnection * connection;  
60 - guint id;  
61 - H3270 * hSession;  
62 - GQuark error_domain;  
63 - };  
64 -  
65 - struct _ipc3270Class {  
66 - GObjectClass parent;  
67 - };  
68 -  
69 - /*  
70 - G_GNUC_INTERNAL void ipc3270_method_call (GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *method_name, GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data);  
71 - G_GNUC_INTERNAL gboolean ipc3270_set_property(GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *property_name, GVariant *value, GError **error, gpointer user_data);  
72 - G_GNUC_INTERNAL GVariant * ipc3270_get_property (GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *property_name, GError **error, gpointer user_data);  
73 - */  
74 -  
75 - G_END_DECLS  
76 -  
77 -#endif // LINUX_GOBJECT_H_INCLUDED  
src/linux/start.c.1
@@ -1,191 +0,0 @@ @@ -1,191 +0,0 @@
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. Registro no INPI sob  
5 - * o nome G3270.  
6 - *  
7 - * Copyright (C) <2008> <Banco do Brasil S.A.>  
8 - *  
9 - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob  
10 - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela  
11 - * Free Software Foundation.  
12 - *  
13 - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER  
14 - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO  
15 - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para  
16 - * obter mais detalhes.  
17 - *  
18 - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este  
19 - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin  
20 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
21 - *  
22 - * Este programa está nomeado como testprogram.c e possui - linhas de código.  
23 - *  
24 - * Contatos:  
25 - *  
26 - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
27 - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)  
28 - *  
29 - */  
30 -  
31 -  
32 - /**  
33 - * @brief Plugin startup/stop for linux.  
34 - *  
35 - */  
36 -  
37 - #include "private.h"  
38 -  
39 - #include <dbus/dbus-glib.h>  
40 - #include <dbus/dbus-glib-bindings.h>  
41 -  
42 - static void pw3270_dbus_cleanup(struct DBusSession * dBus) {  
43 -  
44 - if(dBus->proxy) {  
45 - g_object_unref(dBus);  
46 - }  
47 -  
48 - }  
49 -  
50 - int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal) {  
51 -  
52 - struct DBusSession * dBus = g_new0(struct DBusSession,1);  
53 - GError * error = NULL;  
54 - int id;  
55 -  
56 - g_object_set_data_full(G_OBJECT(terminal), "dbus-session-info", dBus, (GDestroyNotify) pw3270_dbus_cleanup);  
57 -  
58 - dBus->connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);  
59 -  
60 - if(error) {  
61 - GtkWidget *dialog = gtk_message_dialog_new(  
62 - GTK_WINDOW(window),  
63 - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,  
64 - GTK_MESSAGE_ERROR,  
65 - GTK_BUTTONS_OK,  
66 - _( "Can't get D-Bus connection" ));  
67 -  
68 - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message);  
69 - g_error_free(error);  
70 -  
71 - gtk_dialog_run(GTK_DIALOG(dialog));  
72 - gtk_widget_destroy(dialog);  
73 -  
74 - return -1;  
75 - }  
76 -  
77 - g_dbus_connection_set_exit_on_close(dBus->connection,FALSE);  
78 -  
79 - /*  
80 - dBus->proxy = g_dbus_proxy_new_sync(  
81 - dBus->connection,  
82 - G_DBUS_PROXY_FLAGS_NONE,  
83 - NULL, // GDBusInterfaceInfo  
84 - "br.com.bb." PACKAGE_NAME, // name  
85 - "/br/com/bb/" PACKAGE_NAME "/terminal", // object path  
86 - "br.com.bb." PACKAGE_NAME ".terminal", // interface  
87 - NULL, // GCancellable  
88 - &error );  
89 -  
90 - if(error) {  
91 -  
92 - GtkWidget *dialog = gtk_message_dialog_new(  
93 - GTK_WINDOW(window),  
94 - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,  
95 - GTK_MESSAGE_ERROR,  
96 - GTK_BUTTONS_OK,  
97 - _( "Can't get D-Bus proxy object" ));  
98 -  
99 - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message);  
100 - g_error_free(error);  
101 -  
102 - gtk_dialog_run(GTK_DIALOG(dialog));  
103 - gtk_widget_destroy(dialog);  
104 -  
105 - return -1;  
106 - }  
107 - */  
108 -  
109 - for(id='a'; id < 'z' && !error && !dBus->proxy; id++) {  
110 -  
111 - gchar *name = g_strdup_printf("br.com.bb.%s.%c",gtk_widget_get_name(window),id);  
112 -  
113 - debug("Requesting \"%s\"",name);  
114 -  
115 - // https://dbus.freedesktop.org/doc/dbus-specification.html  
116 - GVariant * response =  
117 - g_dbus_connection_call_sync (  
118 - dBus->connection,  
119 - DBUS_SERVICE_DBUS,  
120 - DBUS_PATH_DBUS,  
121 - DBUS_INTERFACE_DBUS,  
122 - "RequestName",  
123 - g_variant_new ("(su)", name, DBUS_NAME_FLAG_DO_NOT_QUEUE),  
124 - NULL,  
125 - G_DBUS_CALL_FLAGS_NONE,  
126 - -1,  
127 - NULL,  
128 - &error  
129 - );  
130 -  
131 - if(error) {  
132 - g_message("Can't request \"%s\": %s",name,error->message);  
133 - g_error_free(error);  
134 - error = NULL;  
135 - }  
136 -  
137 - if(response) {  
138 -  
139 - guint32 reply = 0;  
140 - g_variant_get(response, "(u)", &reply);  
141 - g_variant_unref(response);  
142 -  
143 - if(reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {  
144 -  
145 - dBus->proxy = g_dbus_proxy_new_sync(  
146 - dBus->connection,  
147 - G_DBUS_PROXY_FLAGS_NONE,  
148 - NULL, // GDBusInterfaceInfo  
149 - name, // name  
150 - "/br/com/bb/" PACKAGE_NAME "/terminal", // object path  
151 - "br.com.bb." PACKAGE_NAME ".terminal", // interface  
152 - NULL, // GCancellable  
153 - &error );  
154 -  
155 - gchar * widget_name = g_strdup_printf("%s:%c",gtk_widget_get_name(window),id);  
156 - v3270_set_session_name(terminal, widget_name);  
157 - g_free(widget_name);  
158 -  
159 - g_message("Got %s - %s", name, v3270_get_session_name(terminal));  
160 -  
161 - }  
162 -  
163 - }  
164 -  
165 - g_free(name);  
166 -  
167 - }  
168 -  
169 - if(!dBus->proxy) {  
170 - GtkWidget *dialog = gtk_message_dialog_new(  
171 - GTK_WINDOW(window),  
172 - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,  
173 - GTK_MESSAGE_ERROR,  
174 - GTK_BUTTONS_OK,  
175 - _( "Can't get DBUS object name" ));  
176 -  
177 - gtk_dialog_run(GTK_DIALOG(dialog));  
178 - gtk_widget_destroy(dialog);  
179 -  
180 - return -1;  
181 - }  
182 -  
183 - // Got D-Bus name, register object.  
184 -  
185 - return 0;  
186 -  
187 - }  
188 -  
189 - #endif // !_WIN32  
190 -  
191 -  
src/methods.c
@@ -1,172 +0,0 @@ @@ -1,172 +0,0 @@
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 main.c e possui - linhas de código.  
22 - *  
23 - * Referências:  
24 - *  
25 - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c  
26 - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c  
27 - *  
28 - * Contatos:  
29 - *  
30 - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
31 - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)  
32 - *  
33 - */  
34 -  
35 -#include <config.h>  
36 -#include <string.h>  
37 -#include <lib3270/ipc.h>  
38 -#include <lib3270.h>  
39 -#include <lib3270/actions.h>  
40 -  
41 -#include <dbus/dbus-glib.h>  
42 -#include <dbus/dbus-glib-bindings.h>  
43 -  
44 -GVariant * ipc3270_method_call(GObject *object, const gchar *method_name, GVariant *parameters, GError **error) {  
45 -  
46 - size_t ix;  
47 -  
48 - debug("%s(%s)",__FUNCTION__,method_name);  
49 -  
50 - if(!g_ascii_strcasecmp(method_name,"getString"))  
51 - {  
52 - return ipc3270_GVariant_from_input_string(object, lib3270_get_string_at_address(ipc3270_get_session(object),0,-1,'\n'), error);  
53 - }  
54 - else if(!g_ascii_strcasecmp(method_name,"setString"))  
55 - {  
56 - gchar *text = NULL;  
57 - g_variant_get(parameters, "(&s)", &text);  
58 -  
59 - g_autofree gchar * converted = ipc3270_convert_output_string(object, text, error);  
60 - if(lib3270_input_string(ipc3270_get_session(object),(const unsigned char *) converted) < 0)  
61 - {  
62 - // Failed!  
63 - ipc3270_set_error(object,errno,error);  
64 - return NULL;  
65 - }  
66 -  
67 - // Suceeded  
68 - return g_variant_new_int16((gint16) 0);  
69 -  
70 - }  
71 - else if(!g_ascii_strcasecmp(method_name,"setStringAt"))  
72 - {  
73 - gint row,col;  
74 - gchar *text = NULL;  
75 - g_variant_get(parameters, "(ii&s)", &row, &col, &text);  
76 -  
77 - g_autofree gchar * converted = ipc3270_convert_output_string(object, text, error);  
78 - if(lib3270_set_string_at(ipc3270_get_session(object),row,col,(const unsigned char *) converted) < 0)  
79 - {  
80 - // Failed!  
81 - ipc3270_set_error(object,errno,error);  
82 - return NULL;  
83 - }  
84 -  
85 - // Suceeded  
86 - return g_variant_new_int16((gint16) 0);  
87 -  
88 - }  
89 - else if(!g_ascii_strcasecmp(method_name,"getStringAt"))  
90 - {  
91 - gint row,col,len;  
92 - guchar lf;  
93 - g_variant_get(parameters, "(iiy)", &row, &col, &len,&lf);  
94 -  
95 - return ipc3270_GVariant_from_input_string(object,lib3270_get_string_at(ipc3270_get_session(object), row, col, len, lf),error);  
96 -  
97 - }  
98 - else if(!g_ascii_strcasecmp(method_name,"setStringAtAddress"))  
99 - {  
100 - gint addr;  
101 - gchar *text = NULL;  
102 - g_variant_get(parameters, "(i&s)", &addr, &text);  
103 -  
104 - g_autofree gchar * converted = ipc3270_convert_output_string(object, text, error);  
105 - if(lib3270_set_string_at_address(ipc3270_get_session(object),addr,(unsigned char *) converted) < 0)  
106 - {  
107 - // Failed!  
108 - ipc3270_set_error(object,errno,error);  
109 - return NULL;  
110 - }  
111 -  
112 - // Suceeded  
113 - return g_variant_new_int16((gint16) 0);  
114 -  
115 - }  
116 - else if(!g_ascii_strcasecmp(method_name,"getStringAtAddress"))  
117 - {  
118 - gint addr,len;  
119 - guchar lf;  
120 - g_variant_get(parameters, "(iiy)", &addr, &len, &lf);  
121 -  
122 - return ipc3270_GVariant_from_input_string(object,lib3270_get_string_at_address(ipc3270_get_session(object), addr, len, lf),error);  
123 -  
124 - }  
125 - // Check action table.  
126 - const LIB3270_ACTION_ENTRY * actions = lib3270_get_action_table();  
127 - for(ix = 0; actions[ix].name; ix++)  
128 - {  
129 - if(!g_ascii_strcasecmp(actions[ix].name,method_name)) {  
130 -  
131 - int rc = actions[ix].call(ipc3270_get_session(object));  
132 - if(rc)  
133 - {  
134 - // Failed  
135 - ipc3270_set_error(object,errno,error);  
136 - return NULL;  
137 - }  
138 -  
139 - // Suceeded  
140 - return g_variant_new_int16((gint16) 0);  
141 -  
142 - }  
143 - }  
144 -  
145 - // Check int methods  
146 - const IPC_METHOD_INT_ARG * int_methods = ipc3270_get_int_arg_methods();  
147 -  
148 - for(ix = 0; int_methods[ix].name; ix++)  
149 - {  
150 - if(!g_ascii_strcasecmp(int_methods[ix].name,method_name)) {  
151 -  
152 - gint value;  
153 - g_variant_get(parameters, "(i)", &value);  
154 -  
155 - int rc = int_methods[ix].call(ipc3270_get_session(object), value);  
156 - if(rc)  
157 - {  
158 - // Failed  
159 - ipc3270_set_error(object,errno,error);  
160 - return NULL;  
161 - }  
162 -  
163 - // Suceeded  
164 - return g_variant_new_int16((gint16) 0);  
165 -  
166 - }  
167 -  
168 - }  
169 -  
170 - return NULL;  
171 -  
172 -}  
src/plugin/windows/resources.rc.in 0 → 100644
@@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
  1 +#include <windows.h>
  2 +
  3 +VS_VERSION_INFO VERSIONINFO
  4 +FILEVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0
  5 +PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0
  6 +
  7 +BEGIN
  8 +
  9 + BLOCK "StringFileInfo"
  10 + BEGIN
  11 + BLOCK "080904E4"
  12 + BEGIN
  13 + VALUE "FileDescription", "@PACKAGE_NAME@ IPC Plugin\0"
  14 + VALUE "CompanyName", "Banco do Brasil S/A.\0"
  15 + VALUE "FileVersion", "@WIN32_VERSION@\0"
  16 + VALUE "LegalCopyright", "(C) 2017 Banco do Brasil S/A. All Rights Reserved\0"
  17 + VALUE "OriginalFilename", "ipc3270@DLLEXT@\0"
  18 + VALUE "ProductName", "@PACKAGE_NAME@\0"
  19 + VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.0\0"
  20 + END
  21 + END
  22 +
  23 + BLOCK "VarFileInfo"
  24 + BEGIN
  25 + VALUE "Translation", 0x809, 0x04E4
  26 + END
  27 +
  28 +END
  29 +
src/setproperties.c
@@ -1,151 +0,0 @@ @@ -1,151 +0,0 @@
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 main.c e possui - linhas de código.  
22 - *  
23 - * Referências:  
24 - *  
25 - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c  
26 - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c  
27 - *  
28 - * Contatos:  
29 - *  
30 - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
31 - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)  
32 - *  
33 - */  
34 -  
35 -#include <config.h>  
36 -#include <lib3270/ipc.h>  
37 -#include <lib3270.h>  
38 -#include <lib3270/properties.h>  
39 -  
40 -#include <dbus/dbus-glib.h>  
41 -#include <dbus/dbus-glib-bindings.h>  
42 -  
43 -gboolean ipc3270_set_property(GObject *object, const gchar *property_name, GVariant *value, GError **error) {  
44 -  
45 - // Check for property  
46 - size_t ix;  
47 -  
48 - // Boolean properties  
49 - const LIB3270_INT_PROPERTY * boolprop = lib3270_get_boolean_properties_list();  
50 - for(ix = 0; boolprop[ix].name; ix++) {  
51 -  
52 - if(boolprop[ix].set && !g_ascii_strcasecmp(boolprop[ix].name, property_name)) {  
53 -  
54 - // Found it!  
55 - if(boolprop[ix].set(ipc3270_get_session(object), (int) (g_variant_get_boolean(value) ? 1 : 0))) {  
56 -  
57 - // Erro!  
58 - g_set_error (error,  
59 - G_IO_ERROR,  
60 - G_IO_ERROR_FAILED,  
61 - g_strerror(errno)  
62 - );  
63 -  
64 - return FALSE;  
65 - }  
66 -  
67 - return TRUE;  
68 -  
69 - }  
70 -  
71 - }  
72 -  
73 - // Integer properties  
74 - const LIB3270_INT_PROPERTY * intprop = lib3270_get_int_properties_list();  
75 - for(ix = 0; intprop[ix].name; ix++) {  
76 -  
77 - if(intprop[ix].set && !g_ascii_strcasecmp(intprop[ix].name, property_name)) {  
78 -  
79 - // Found it!  
80 - if(intprop[ix].set(ipc3270_get_session(object), (int) (g_variant_get_boolean(value) ? 1 : 0))) {  
81 -  
82 - // Erro!  
83 - g_set_error (error,  
84 - G_IO_ERROR,  
85 - G_IO_ERROR_FAILED,  
86 - g_strerror(errno)  
87 - );  
88 -  
89 - return FALSE;  
90 - }  
91 -  
92 - return TRUE;  
93 -  
94 - }  
95 -  
96 - }  
97 -  
98 - // String properties  
99 - const LIB3270_STRING_PROPERTY * strprop = lib3270_get_string_properties_list();  
100 - for(ix = 0; strprop[ix].name; ix++) {  
101 -  
102 - if(strprop[ix].set && !g_ascii_strcasecmp(strprop[ix].name, property_name)) {  
103 -  
104 - // Found it!  
105 - if(strprop[ix].set(ipc3270_get_session(object), g_variant_get_string(value,NULL))) {  
106 -  
107 - // Erro!  
108 - g_set_error (error,  
109 - G_IO_ERROR,  
110 - G_IO_ERROR_FAILED,  
111 - g_strerror(errno)  
112 - );  
113 -  
114 - return FALSE;  
115 - }  
116 -  
117 - return TRUE;  
118 -  
119 - }  
120 -  
121 - }  
122 -  
123 - // Check for toggle  
124 - LIB3270_TOGGLE toggle = lib3270_get_toggle_id(property_name);  
125 - if(toggle != (LIB3270_TOGGLE) -1) {  
126 -  
127 - // Is a Tn3270 toggle, get it!  
128 - if(lib3270_set_toggle(ipc3270_get_session(object),toggle,(int) g_variant_get_int32(value))) {  
129 -  
130 - // Erro!  
131 - g_set_error (error,  
132 - G_IO_ERROR,  
133 - G_IO_ERROR_FAILED,  
134 - g_strerror(errno)  
135 - );  
136 -  
137 - return FALSE;  
138 -  
139 - }  
140 -  
141 - return TRUE;  
142 - }  
143 -  
144 - g_set_error (error,  
145 - G_IO_ERROR,  
146 - G_IO_ERROR_NOT_FOUND,  
147 - "Can't find any property named %s", property_name  
148 - );  
149 -  
150 - return FALSE;  
151 -}  
src/testprogram/testprogram.c
@@ -41,7 +41,7 @@ @@ -41,7 +41,7 @@
41 41
42 /*---[ Implement ]----------------------------------------------------------------------------------*/ 42 /*---[ Implement ]----------------------------------------------------------------------------------*/
43 43
44 -static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { 44 + static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) {
45 45
46 GtkWidget * window = gtk_application_window_new(app); 46 GtkWidget * window = gtk_application_window_new(app);
47 GtkWidget * terminal = v3270_new(); 47 GtkWidget * terminal = v3270_new();
@@ -75,18 +75,40 @@ static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { @@ -75,18 +75,40 @@ static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) {
75 75
76 int main (int argc, char **argv) { 76 int main (int argc, char **argv) {
77 77
78 - GtkApplication *app;  
79 - int status; 78 + /*
  79 + GVariantBuilder builder;
80 80
81 - app = gtk_application_new ("br.com.bb.pw3270",G_APPLICATION_FLAGS_NONE); 81 + g_variant_builder_init(&builder,G_VARIANT_TYPE("(isi)"));
82 82
83 - g_signal_connect (app, "activate", G_CALLBACK(activate), NULL); 83 + g_variant_builder_add(&builder, "i", 10);
  84 + g_variant_builder_add(&builder, "s", "teste");
  85 + g_variant_builder_add(&builder, "i", 20);
84 86
85 - status = g_application_run (G_APPLICATION (app), argc, argv);  
86 - g_object_unref (app); 87 + GVariant *value = g_variant_builder_end(&builder);
87 88
88 - g_message("rc=%d",status);  
89 - return status; 89 + size_t szPacket = 0;
  90 + g_autofree unsigned char * buffer = ipc3270_pack("teste", value, &szPacket);
  91 + g_variant_unref(value);
  92 +
  93 + debug("Package \"%s\" was created with %u bytes", buffer, (unsigned int) szPacket);
  94 +
  95 + value = ipc3270_unpack(buffer);
  96 +
  97 + g_variant_unref(value);
  98 + */
  99 +
  100 + GtkApplication *app;
  101 + int status;
  102 +
  103 + app = gtk_application_new ("br.com.bb.pw3270",G_APPLICATION_FLAGS_NONE);
  104 +
  105 + g_signal_connect (app, "activate", G_CALLBACK(activate), NULL);
  106 +
  107 + status = g_application_run (G_APPLICATION (app), argc, argv);
  108 + g_object_unref (app);
  109 +
  110 + g_message("rc=%d",status);
  111 + return status;
90 112
91 } 113 }
92 114
src/windows/gobject.c
@@ -1,125 +0,0 @@ @@ -1,125 +0,0 @@
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 gobject.c 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 "gobject.h"  
31 -#include <lib3270.h>  
32 -#include <lib3270/actions.h>  
33 -#include <lib3270/properties.h>  
34 -  
35 -G_DEFINE_TYPE(ipc3270, ipc3270, G_TYPE_OBJECT)  
36 -  
37 -static void ipc3270_finalize(GObject *object) {  
38 -  
39 - ipc3270 * ipc = IPC3270(object);  
40 -  
41 -  
42 - G_OBJECT_CLASS(ipc3270_parent_class)->finalize(object);  
43 -}  
44 -  
45 -  
46 -static void ipc3270_class_init(ipc3270Class *klass) {  
47 -  
48 - debug("%s",__FUNCTION__);  
49 -  
50 - GObjectClass *object_class;  
51 - object_class = G_OBJECT_CLASS (klass);  
52 - object_class->finalize = ipc3270_finalize;  
53 -  
54 -}  
55 -  
56 -static void ipc3270_init(ipc3270 *object) {  
57 -  
58 - debug("%s",__FUNCTION__);  
59 - object->error_domain = g_quark_from_static_string(PACKAGE_NAME);  
60 -  
61 -}  
62 -  
63 -GObject * ipc3270_new() {  
64 - return g_object_new(GLIB_TYPE_IPC3270, NULL);  
65 -}  
66 -  
67 -void ipc3270_set_session(GObject *object, H3270 *hSession, const char *name, GError **error) {  
68 -  
69 - char id;  
70 -  
71 - ipc3270 * ipc = IPC3270(object);  
72 - ipc->hSession = hSession;  
73 -  
74 - for(id='A';id < 'Z';id++) {  
75 -  
76 - gchar * pipename = g_strdup_printf("\\\\.\\pipe\\%s\\%c",name,id);  
77 - gchar * ptr;  
78 - HANDLE hPipe;  
79 -  
80 - for(ptr=pipename;*ptr;ptr++)  
81 - *ptr = g_ascii_tolower(*ptr);  
82 -  
83 - hPipe = CreateNamedPipe( TEXT(pipename), // pipe name  
84 - PIPE_ACCESS_DUPLEX | // read/write access  
85 - FILE_FLAG_OVERLAPPED, // overlapped mode  
86 - PIPE_TYPE_MESSAGE | // pipe type  
87 - PIPE_READMODE_MESSAGE | // pipe mode  
88 - PIPE_WAIT, // blocking mode  
89 - 1, // number of instances  
90 - PIPE_BUFFER_LENGTH, // output buffer size  
91 - PIPE_BUFFER_LENGTH, // input buffer size  
92 - NMPWAIT_USE_DEFAULT_WAIT, // client time-out  
93 - NULL); // default security attributes  
94 -  
95 - debug("%s = %p",pipename,hPipe);  
96 - g_free(pipename);  
97 -  
98 - if(hPipe != INVALID_HANDLE_VALUE) {  
99 -  
100 - ipc->source = (IPC3270_PIPE_SOURCE *) g_source_new(&ipc3270_source_funcs,sizeof(IPC3270_PIPE_SOURCE));  
101 -  
102 - lib3270_set_session_id(ipc->hSession, id);  
103 -  
104 - ipc->source->hPipe = hPipe;  
105 - ipc->source->state = PIPE_STATE_WAITING;  
106 - ipc->source->overlap.hEvent = CreateEvent( NULL,TRUE,TRUE,NULL);  
107 -  
108 - g_source_attach((GSource *) ipc->source,NULL);  
109 -  
110 - // IO_accept(source);  
111 - ipc3270_wait_for_client(ipc->source);  
112 -  
113 - break;  
114 - }  
115 -  
116 - }  
117 -  
118 -  
119 -}  
120 -  
121 -const gchar * ipc3270_get_display_charset(GObject *object) {  
122 - return lib3270_get_display_charset(IPC3270(object)->hSession);  
123 -}  
124 -  
125 -  
src/windows/gobject.h
@@ -1,97 +0,0 @@ @@ -1,97 +0,0 @@
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. Registro no INPI sob  
5 - * o nome G3270.  
6 - *  
7 - * Copyright (C) <2008> <Banco do Brasil S.A.>  
8 - *  
9 - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob  
10 - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela  
11 - * Free Software Foundation.  
12 - *  
13 - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER  
14 - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO  
15 - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para  
16 - * obter mais detalhes.  
17 - *  
18 - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este  
19 - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin  
20 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
21 - *  
22 - * Este programa está nomeado como - e possui - linhas de código.  
23 - *  
24 - * Contatos:  
25 - *  
26 - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
27 - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)  
28 - *  
29 - */  
30 -  
31 - /**  
32 - * @brief Private definitions for pw3270 IPC windows module.  
33 - *  
34 - */  
35 -  
36 -#ifndef WINDOWS_GOBJECT_H_INCLUDED  
37 -  
38 - #define WINDOWS_GOBJECT_H_INCLUDED  
39 -  
40 - #include <windows.h>  
41 - #include <config.h>  
42 -  
43 - #define ENABLE_NLS  
44 - #define GETTEXT_PACKAGE PACKAGE_NAME  
45 -  
46 - #include <libintl.h>  
47 - #include <glib/gi18n.h>  
48 - #include <gio/gio.h>  
49 -  
50 - #include <lib3270.h>  
51 - #include <lib3270/ipc.h>  
52 -  
53 - #define PIPE_BUFFER_LENGTH 8192  
54 -  
55 - G_BEGIN_DECLS  
56 -  
57 - typedef struct _ipc3270 ipc3270;  
58 - typedef struct _ipc3270Class ipc3270Class;  
59 - typedef struct _ipc3270Request ipc3270Request;  
60 -  
61 - typedef enum _ipc3270_pipe_state {  
62 - PIPE_STATE_WAITING,  
63 - PIPE_STATE_READ,  
64 - PIPE_STATE_PENDING_READ,  
65 - PIPE_STATE_UNDEFINED  
66 - } IPC3270_PIPE_STATE;  
67 -  
68 - typedef struct _ipc3270_pipe_source {  
69 - GSource gsrc;  
70 - HANDLE hPipe;  
71 -  
72 - IPC3270_PIPE_STATE state;  
73 -  
74 - OVERLAPPED overlap;  
75 - unsigned char buffer[PIPE_BUFFER_LENGTH+1];  
76 -  
77 - } IPC3270_PIPE_SOURCE;  
78 -  
79 - struct _ipc3270 {  
80 - H3270 * hSession;  
81 - IPC3270_PIPE_SOURCE * source;  
82 - GQuark error_domain;  
83 - };  
84 -  
85 - struct _ipc3270Class {  
86 - GObjectClass parent;  
87 - };  
88 -  
89 - G_GNUC_INTERNAL GSourceFuncs ipc3270_source_funcs;  
90 -  
91 - G_GNUC_INTERNAL void ipc3270_wait_for_client(IPC3270_PIPE_SOURCE *source);  
92 - G_GNUC_INTERNAL unsigned char * ipc3270_pack(GVariant *values);  
93 - G_GNUC_INTERNAL GVariant * ipc3270_unpack(const unsigned char *packet);  
94 -  
95 - G_END_DECLS  
96 -  
97 -#endif // WINDOWS_GOBJECT_H_INCLUDED  
src/windows/inout.c
@@ -1,275 +0,0 @@ @@ -1,275 +0,0 @@
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. Registro no INPI sob  
5 - * o nome G3270.  
6 - *  
7 - * Copyright (C) <2008> <Banco do Brasil S.A.>  
8 - *  
9 - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob  
10 - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela  
11 - * Free Software Foundation.  
12 - *  
13 - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER  
14 - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO  
15 - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para  
16 - * obter mais detalhes.  
17 - *  
18 - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este  
19 - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin  
20 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
21 - *  
22 - * Este programa está nomeado como inout.c e possui - linhas de código.  
23 - *  
24 - * Contatos:  
25 - *  
26 - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
27 - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)  
28 - *  
29 - */  
30 -  
31 -  
32 - /**  
33 - * @brief Pack/Unpack IPC data block.  
34 - *  
35 - */  
36 -  
37 - #include <config.h>  
38 - #include <lib3270/ipc.h>  
39 - #include <string.h>  
40 - #include <stdlib.h>  
41 -  
42 -/*---[ Implement ]----------------------------------------------------------------------------------*/  
43 -  
44 -unsigned char * ipc3270_pack(GVariant *values) {  
45 -  
46 - GVariantIter iter;  
47 - gsize count = g_variant_iter_init(&iter, values);  
48 - g_autofree char * types = g_new0(char, count);  
49 - GVariant * child;  
50 - size_t ix = 0;  
51 - size_t szBuffer = sizeof(gint16);  
52 -  
53 - g_print("Packaging %u itens\n", (unsigned int) count);  
54 - while ((child = g_variant_iter_next_value (&iter))) {  
55 -  
56 - // g_print("type='%s' size=%u\n", g_variant_get_type_string(child), (unsigned int) g_variant_get_size(child));  
57 -  
58 - types[ix] = g_variant_get_type_string(child)[0];  
59 -  
60 - szBuffer += (1+g_variant_get_size(child));  
61 - if(types[ix] == 's') {  
62 - szBuffer += sizeof(gint16);  
63 - }  
64 -  
65 - g_variant_unref(child);  
66 - ix++;  
67 - }  
68 -  
69 - unsigned char * outputBuffer = g_malloc0(szBuffer);  
70 - unsigned char * txtptr = outputBuffer + sizeof(guint16) + sizeof(guint16);  
71 -  
72 - *((guint16 *) outputBuffer) = (guint16) szBuffer;  
73 - *((guint16 *) (outputBuffer + sizeof(guint16))) = (guint16) count;  
74 -  
75 - ix = 0;  
76 - g_variant_iter_init(&iter, values);  
77 - while ((child = g_variant_iter_next_value (&iter))) {  
78 -  
79 - debug("type='%s' size=%u index=%u", g_variant_get_type_string(child), (unsigned int) g_variant_get_size(child), (unsigned int) (txtptr - outputBuffer));  
80 -  
81 - *(txtptr++) = types[ix];  
82 -  
83 - switch(types[ix]) {  
84 -  
85 - // https://developer.gnome.org/glib/stable/gvariant-format-strings.html  
86 -  
87 - case 's':  
88 - strcpy((char *) txtptr,g_variant_get_string(child,NULL));  
89 - txtptr += (strlen((char *) txtptr)+1);  
90 - break;  
91 -  
92 - case 'b': // gboolean  
93 - *(txtptr++) = g_variant_get_boolean(child) ? 1 : 0;  
94 - break;  
95 -  
96 - case 'y': // guchar  
97 - *(txtptr++) = g_variant_get_byte(child);  
98 - break;  
99 -  
100 - case 'n': // gint16  
101 - *((gint16 *) txtptr) = g_variant_get_int16(child);  
102 - txtptr += sizeof(gint16);  
103 - break;  
104 -  
105 - case 'q': // guint16  
106 - *((guint16 *) txtptr) = g_variant_get_uint16(child);  
107 - txtptr += sizeof(guint16);  
108 - break;  
109 -  
110 - case 'i': // gint32  
111 - case 'h': // gint32  
112 - *((gint32 *) txtptr) = g_variant_get_int32(child);  
113 - txtptr += sizeof(gint32);  
114 - break;  
115 -  
116 - case 'u': // guint32  
117 - *((guint32 *) txtptr) = g_variant_get_uint32(child);  
118 - txtptr += sizeof(guint32);  
119 - break;  
120 -  
121 - case 'x': // gint64  
122 - *((gint64 *) txtptr) = g_variant_get_int64(child);  
123 - txtptr += sizeof(gint64);  
124 - break;  
125 -  
126 - case 't': // guint64  
127 - *((guint64 *) txtptr) = g_variant_get_uint64(child);  
128 - txtptr += sizeof(guint64);  
129 - break;  
130 -  
131 - default:  
132 - errno = EINVAL;  
133 - g_free(outputBuffer);  
134 - return NULL;  
135 - }  
136 -  
137 - g_variant_unref(child);  
138 - ix++;  
139 - }  
140 -  
141 - return outputBuffer;  
142 -}  
143 -  
144 -GVariant * ipc3270_unpack(const unsigned char *packet) {  
145 -  
146 - size_t szPacket = (size_t) * ((guint16 *) packet);  
147 - size_t count = (size_t) * ((guint16 *) (packet+sizeof(guint16)));  
148 -  
149 - const unsigned char *txtptr = packet + (sizeof(guint16) * 2);  
150 - size_t ix;  
151 -  
152 - g_autofree gchar * descrs = g_malloc0(count+3);  
153 - descrs[0] = '(';  
154 - descrs[count+1] = ')';  
155 -  
156 - debug("Unpacking package with %u bytes and %u itens\n", (unsigned int) szPacket, (unsigned int) count);  
157 -  
158 - for(ix = 0; ix < count; ix++) {  
159 -  
160 - debug("Format(%u): %c at %u",(unsigned int) ix, *txtptr, (unsigned int) (txtptr - packet));  
161 -  
162 - descrs[ix+1] = *(txtptr++);  
163 -  
164 - switch(descrs[ix+1]) {  
165 - case 's':  
166 - txtptr += strlen((char *) txtptr)+1;  
167 - break;  
168 -  
169 - case 'b': // gboolean  
170 - case 'y': // guchar  
171 - txtptr++;  
172 - break;  
173 -  
174 - case 'n': // gint16  
175 - txtptr += sizeof(gint16);  
176 - break;  
177 -  
178 - case 'q': // guint16  
179 - txtptr += sizeof(guint16);  
180 - break;  
181 -  
182 - case 'i': // gint32  
183 - case 'h': // gint32  
184 - txtptr += sizeof(gint32);  
185 - break;  
186 -  
187 - case 'u': // guint32  
188 - txtptr += sizeof(guint32);  
189 - break;  
190 -  
191 - case 'x': // gint64  
192 - txtptr += sizeof(gint64);  
193 - break;  
194 -  
195 - case 't': // guint64  
196 - txtptr += sizeof(guint64);  
197 - break;  
198 -  
199 - default:  
200 - errno = EINVAL;  
201 - return NULL;  
202 - }  
203 - }  
204 -  
205 - debug("Format: \"%s\"\n",descrs);  
206 -  
207 - GVariantBuilder builder;  
208 - g_variant_builder_init(&builder,G_VARIANT_TYPE(descrs));  
209 -  
210 - txtptr = packet + (sizeof(guint16) * 2);  
211 - for(ix = 0; ix < count; ix++) {  
212 -  
213 - debug("Format(%u): %c at %u",(unsigned int) ix, *txtptr, (unsigned int) (txtptr - packet));  
214 - txtptr++;  
215 -  
216 - switch(descrs[ix+1]) {  
217 - case 's':  
218 - g_variant_builder_add(&builder, "s", txtptr);  
219 - txtptr += strlen((char *) txtptr)+1;  
220 - break;  
221 -  
222 - case 'b': // gboolean  
223 - g_variant_builder_add(&builder, "b", *((gboolean *) txtptr));  
224 - txtptr++;  
225 - break;  
226 -  
227 - case 'y': // guchar  
228 - g_variant_builder_add(&builder, "y", *((guchar *) txtptr));  
229 - txtptr++;  
230 - break;  
231 -  
232 - case 'n': // gint16  
233 - g_variant_builder_add(&builder, "n", *((gint16 *) txtptr));  
234 - txtptr += sizeof(gint16);  
235 - break;  
236 -  
237 - case 'q': // guint16  
238 - g_variant_builder_add(&builder, "q", *((guint16 *) txtptr));  
239 - txtptr += sizeof(guint16);  
240 - break;  
241 -  
242 - case 'i': // gint32  
243 - g_variant_builder_add(&builder, "i", *((gint32 *) txtptr));  
244 - txtptr += sizeof(gint32);  
245 - break;  
246 -  
247 - case 'h': // gint32  
248 - g_variant_builder_add(&builder, "h", *((gint32 *) txtptr));  
249 - txtptr += sizeof(gint32);  
250 - break;  
251 -  
252 - case 'u': // guint32  
253 - g_variant_builder_add(&builder, "u", *((guint32 *) txtptr));  
254 - txtptr += sizeof(guint32);  
255 - break;  
256 -  
257 - case 'x': // gint64  
258 - g_variant_builder_add(&builder, "x", *((gint64 *) txtptr));  
259 - txtptr += sizeof(gint64);  
260 - break;  
261 -  
262 - case 't': // guint64  
263 - g_variant_builder_add(&builder, "t", *((guint64 *) txtptr));  
264 - txtptr += sizeof(guint64);  
265 - break;  
266 -  
267 - default:  
268 - errno = EINVAL;  
269 - return NULL;  
270 - }  
271 - }  
272 -  
273 - return g_variant_builder_end(&builder);  
274 -  
275 -}  
src/windows/pipesource.c
@@ -1,214 +0,0 @@ @@ -1,214 +0,0 @@
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 pipesource.c 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 "gobject.h"  
31 -  
32 -void ipc3270_wait_for_client(IPC3270_PIPE_SOURCE *source) {  
33 -  
34 - if(ConnectNamedPipe(source->hPipe,&source->overlap)) {  
35 - g_message("Error %u in ConnectNamedPipe",(unsigned int) GetLastError());  
36 - // popup_lasterror("%s",_( "Error in ConnectNamedPipe" ));  
37 - return;  
38 - }  
39 -  
40 - switch(GetLastError()) {  
41 - case ERROR_IO_PENDING: // The overlapped connection in progress.  
42 - source->state = PIPE_STATE_WAITING;  
43 - break;  
44 -  
45 -  
46 - case ERROR_PIPE_CONNECTED: // Client is already connected, so signal an event.  
47 - if(SetEvent(source->overlap.hEvent))  
48 - break;  
49 -  
50 - default:  
51 - g_message("Error %u in ConnectNamedPipe",(unsigned int) GetLastError());  
52 - // popup_lasterror("%s", _( "ConnectNamedPipe failed" ));  
53 - }  
54 -  
55 -}  
56 -  
57 -static gboolean IO_prepare(GSource *source, gint *timeout) {  
58 - /*  
59 - * Called before all the file descriptors are polled.  
60 - * If the source can determine that it is ready here  
61 - * (without waiting for the results of the poll() call)  
62 - * it should return TRUE.  
63 - *  
64 - * It can also return a timeout_ value which should be the maximum  
65 - * timeout (in milliseconds) which should be passed to the poll() call.  
66 - * The actual timeout used will be -1 if all sources returned -1,  
67 - * or it will be the minimum of all the timeout_ values  
68 - * returned which were >= 0.  
69 - *  
70 - */  
71 - if(WaitForSingleObject(((IPC3270_PIPE_SOURCE *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)  
72 - return TRUE;  
73 -  
74 - *timeout = 10;  
75 -  
76 - return FALSE;  
77 -  
78 -}  
79 -  
80 -static gboolean IO_check(GSource *source) {  
81 - /*  
82 - * Called after all the file descriptors are polled.  
83 - * The source should return TRUE if it is ready to be dispatched.  
84 - * Note that some time may have passed since the previous prepare  
85 - * function was called, so the source should be checked again here.  
86 - *  
87 - */  
88 - if(WaitForSingleObject(((IPC3270_PIPE_SOURCE *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)  
89 - return TRUE;  
90 -  
91 - return FALSE;  
92 -}  
93 -  
94 -static void process_input(IPC3270_PIPE_SOURCE *source, DWORD cbRead) {  
95 -  
96 -}  
97 -  
98 -static void read_input_pipe(IPC3270_PIPE_SOURCE *source) {  
99 -  
100 - DWORD cbRead = 0;  
101 -  
102 - if(ReadFile(source->hPipe,source->buffer,PIPE_BUFFER_LENGTH,&cbRead,&source->overlap) && cbRead > 0)  
103 - process_input(source,cbRead);  
104 -  
105 - // The read operation is still pending.  
106 - switch(GetLastError())  
107 - {  
108 - case 0:  
109 - break;  
110 -  
111 - case ERROR_IO_PENDING:  
112 - source->state = PIPE_STATE_PENDING_READ;  
113 - break;  
114 -  
115 - case ERROR_PIPE_LISTENING:  
116 - source->state = PIPE_STATE_READ;  
117 - break;  
118 -  
119 - case ERROR_BROKEN_PIPE:  
120 -  
121 - if(!DisconnectNamedPipe(source->hPipe)) {  
122 -  
123 - g_message("Error %u on DisconnectNamedPipe", (unsigned int) GetLastError());  
124 -  
125 - } else {  
126 -  
127 - ipc3270_wait_for_client(source);  
128 -  
129 - }  
130 - break;  
131 -  
132 - case ERROR_PIPE_NOT_CONNECTED:  
133 - g_message("Cliente was disconnected");  
134 - break;  
135 -  
136 - default:  
137 - if(source->hPipe != INVALID_HANDLE_VALUE) {  
138 - g_message( "Error %u receiving message from pipe", (unsigned int) GetLastError());  
139 - }  
140 - }  
141 -  
142 -}  
143 -  
144 -  
145 -static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer data) {  
146 - /*  
147 - * Called to dispatch the event source,  
148 - * after it has returned TRUE in either its prepare or its check function.  
149 - * The dispatch function is passed in a callback function and data.  
150 - * The callback function may be NULL if the source was never connected  
151 - * to a callback using g_source_set_callback(). The dispatch function  
152 - * should call the callback function with user_data and whatever additional  
153 - * parameters are needed for this type of event source.  
154 - */  
155 - BOOL fSuccess;  
156 - DWORD cbRead = 0;  
157 -  
158 - fSuccess = GetOverlappedResult(((IPC3270_PIPE_SOURCE *) source)->hPipe,&((IPC3270_PIPE_SOURCE *) source)->overlap,&cbRead,FALSE );  
159 -  
160 - switch(((IPC3270_PIPE_SOURCE *) source)->state) {  
161 - case PIPE_STATE_WAITING:  
162 -  
163 - if(fSuccess) {  
164 -  
165 - g_message("Client is connected");  
166 - ((IPC3270_PIPE_SOURCE *) source)->state = PIPE_STATE_READ;  
167 -  
168 - } else {  
169 -  
170 - // popup_lasterror("%s", _( "Pipe connection failed" ));  
171 -  
172 - }  
173 - break;  
174 -  
175 - case PIPE_STATE_READ:  
176 - // trace("Reading pipe (cbRead=%d)",(int) cbRead);  
177 - read_input_pipe( (IPC3270_PIPE_SOURCE *) source);  
178 - break;  
179 -  
180 - case PIPE_STATE_PENDING_READ:  
181 - if(fSuccess && cbRead > 0)  
182 - process_input((IPC3270_PIPE_SOURCE *) source,cbRead);  
183 - ((IPC3270_PIPE_SOURCE *) source)->state = PIPE_STATE_READ;  
184 - break;  
185 -  
186 - case PIPE_STATE_UNDEFINED:  
187 - break;  
188 -  
189 - }  
190 -  
191 - return TRUE;  
192 -}  
193 -  
194 -static gboolean IO_closure(gpointer data) {  
195 - return 0;  
196 -}  
197 -  
198 -static void IO_finalize(GSource *source) {  
199 -  
200 - if( ((IPC3270_PIPE_SOURCE *) source)->hPipe != INVALID_HANDLE_VALUE) {  
201 - CloseHandle(((IPC3270_PIPE_SOURCE *) source)->hPipe);  
202 - ((IPC3270_PIPE_SOURCE *) source)->hPipe = INVALID_HANDLE_VALUE;  
203 - }  
204 -  
205 -}  
206 -  
207 -GSourceFuncs ipc3270_source_funcs = {  
208 - IO_prepare,  
209 - IO_check,  
210 - IO_dispatch,  
211 - IO_finalize,  
212 - IO_closure,  
213 - NULL  
214 -};  
src/windows/resources.rc.in
@@ -1,29 +0,0 @@ @@ -1,29 +0,0 @@
1 -#include <windows.h>  
2 -  
3 -VS_VERSION_INFO VERSIONINFO  
4 -FILEVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0  
5 -PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0  
6 -  
7 -BEGIN  
8 -  
9 - BLOCK "StringFileInfo"  
10 - BEGIN  
11 - BLOCK "080904E4"  
12 - BEGIN  
13 - VALUE "FileDescription", "@PACKAGE_DESCRIPTION@\0"  
14 - VALUE "CompanyName", "Banco do Brasil S/A.\0"  
15 - VALUE "FileVersion", "@WIN32_VERSION@\0"  
16 - VALUE "LegalCopyright", "(C) 2017 Banco do Brasil S/A. All Rights Reserved\0"  
17 - VALUE "OriginalFilename", "@PACKAGE_TARNAME@@DLLEXT@\0"  
18 - VALUE "ProductName", "@PACKAGE_NAME@\0"  
19 - VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.0\0"  
20 - END  
21 - END  
22 -  
23 - BLOCK "VarFileInfo"  
24 - BEGIN  
25 - VALUE "Translation", 0x809, 0x04E4  
26 - END  
27 -  
28 -END  
29 -