Commit 56b8c5497034ff29b5d39206e1b526dbb70e04b9

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

Refactoring build process.

@@ -24,18 +24,19 @@ @@ -24,18 +24,19 @@
24 # erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) 24 # erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça)
25 # 25 #
26 26
27 -#---[ Library configuration ]------------------------------------------------------------  
28 -  
29 -MODULE_NAME=ipc3270c  
30 PACKAGE_NAME=@PACKAGE_NAME@ 27 PACKAGE_NAME=@PACKAGE_NAME@
31 28
  29 +#---[ PLugin configuration ]-------------------------------------------------------------
  30 +
  31 +PLUGIN_NAME=ipc3270c
  32 +
32 PLUGIN_SOURCES= \ 33 PLUGIN_SOURCES= \
33 - $(wildcard src/plugin/*.c) \  
34 - $(wildcard src/plugin/@OSNAME@/*.c) \  
35 - $(wildcard src/plugin/@OSNAME@/*.rc) 34 + $(wildcard src/$(PLUGIN_NAME)/*.c) \
  35 + $(wildcard src/$(PLUGIN_NAME)/@OSNAME@/*.c) \
  36 + $(wildcard src/$(PLUGIN_NAME)/@OSNAME@/*.rc)
36 37
37 -TEST_SOURCES= \  
38 - $(wildcard src/testprogram/*.c) 38 +PLUGIN_TEST_SOURCES= \
  39 + src/testprograms/plugin.c
39 40
40 #---[ Tools ]---------------------------------------------------------------------------- 41 #---[ Tools ]----------------------------------------------------------------------------
41 42
@@ -69,7 +70,7 @@ BASEDIR=@BASEDIR@ @@ -69,7 +70,7 @@ BASEDIR=@BASEDIR@
69 70
70 POTDIR=$(BASEDIR)/.pot 71 POTDIR=$(BASEDIR)/.pot
71 72
72 -OBJDIR=$(BASEDIR)/.obj/$(MODULE_NAME) 73 +OBJDIR=$(BASEDIR)/.obj
73 OBJDBG=$(OBJDIR)/Debug 74 OBJDBG=$(OBJDIR)/Debug
74 OBJRLS=$(OBJDIR)/Release 75 OBJRLS=$(OBJDIR)/Release
75 76
@@ -160,7 +161,7 @@ $(OBJRLS)/%.o: \ @@ -160,7 +161,7 @@ $(OBJRLS)/%.o: \
160 161
161 #---[ Misc Rules ]----------------------------------------------------------------------- 162 #---[ Misc Rules ]-----------------------------------------------------------------------
162 163
163 -$(POTDIR)/$(MODULE_NAME)/%.pot: \ 164 +$(POTDIR)/$(PLUGIN_NAME)/%.pot: \
164 %.c 165 %.c
165 166
166 @echo $(notdir $@) ... 167 @echo $(notdir $@) ...
@@ -174,7 +175,7 @@ $(POTDIR)/$(MODULE_NAME)/%.pot: \ @@ -174,7 +175,7 @@ $(POTDIR)/$(MODULE_NAME)/%.pot: \
174 $< 175 $<
175 @touch $@ 176 @touch $@
176 177
177 -$(POTDIR)/$(MODULE_NAME)/%.pot: \ 178 +$(POTDIR)/$(PLUGIN_NAME)/%.pot: \
178 %.rc 179 %.rc
179 180
180 @echo $< ... 181 @echo $< ...
@@ -185,13 +186,13 @@ $(POTDIR)/$(MODULE_NAME)/%.pot: \ @@ -185,13 +186,13 @@ $(POTDIR)/$(MODULE_NAME)/%.pot: \
185 #---[ Release Targets ]------------------------------------------------------------------ 186 #---[ Release Targets ]------------------------------------------------------------------
186 187
187 all: \ 188 all: \
188 - $(BINRLS)/$(MODULE_NAME)@DLLEXT@ \  
189 - $(POTDIR)/$(MODULE_NAME).pot 189 + $(BINRLS)/$(PLUGIN_NAME)@DLLEXT@ \
  190 + $(POTDIR)/$(PLUGIN_NAME).pot
190 191
191 Release: \ 192 Release: \
192 - $(BINRLS)/$(MODULE_NAME)@DLLEXT@ 193 + $(BINRLS)/$(PLUGIN_NAME)@DLLEXT@
193 194
194 -$(BINRLS)/$(MODULE_NAME)@DLLEXT@: \ 195 +$(BINRLS)/$(PLUGIN_NAME)@DLLEXT@: \
195 $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) 196 $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o)
196 197
197 @$(MKDIR) $(@D) 198 @$(MKDIR) $(@D)
@@ -213,39 +214,39 @@ install: \ @@ -213,39 +214,39 @@ install: \
213 install-plugin 214 install-plugin
214 215
215 install-plugin: \ 216 install-plugin: \
216 - $(BINRLS)/$(MODULE_NAME)@DLLEXT@ 217 + $(BINRLS)/$(PLUGIN_NAME)@DLLEXT@
217 218
218 @$(MKDIR) $(DESTDIR)$(libdir)/pw3270-plugins 219 @$(MKDIR) $(DESTDIR)$(libdir)/pw3270-plugins
219 220
220 @$(INSTALL_PROGRAM) \ 221 @$(INSTALL_PROGRAM) \
221 - $(BINRLS)/$(MODULE_NAME)@DLLEXT@ \ 222 + $(BINRLS)/$(PLUGIN_NAME)@DLLEXT@ \
222 $(DESTDIR)$(libdir)/pw3270-plugins 223 $(DESTDIR)$(libdir)/pw3270-plugins
223 224
224 #---[ Misc Targets ]--------------------------------------------------------------------- 225 #---[ Misc Targets ]---------------------------------------------------------------------
225 226
226 -$(POTDIR)/$(MODULE_NAME).pot: \  
227 - $(foreach SRC, $(basename $(SOURCES)), $(POTDIR)/$(MODULE_NAME)/$(SRC).pot) 227 +$(POTDIR)/$(PLUGIN_NAME).pot: \
  228 + $(foreach SRC, $(basename $(SOURCES)), $(POTDIR)/$(PLUGIN_NAME)/$(SRC).pot)
228 229
229 @rm -f $@ 230 @rm -f $@
230 @mkdir -p `dirname $@` 231 @mkdir -p `dirname $@`
231 @$(MSGCAT) --sort-output $^ > $@ 232 @$(MSGCAT) --sort-output $^ > $@
232 233
233 locale: \ 234 locale: \
234 - $(POTDIR)/$(MODULE_NAME).pot 235 + $(POTDIR)/$(PLUGIN_NAME).pot
235 236
236 -run: \  
237 - $(BINDBG)/$(MODULE_NAME)@DLLEXT@ \  
238 - $(BINDBG)/$(MODULE_NAME)@EXEEXT@ 237 +run-plugin: \
  238 + $(BINDBG)/$(PLUGIN_NAME)@DLLEXT@ \
  239 + $(BINDBG)/$(PLUGIN_NAME)@EXEEXT@
239 240
240 - $(BINDBG)/$(MODULE_NAME)@EXEEXT@ 241 + $(BINDBG)/$(PLUGIN_NAME)@EXEEXT@
241 242
242 #---[ Debug Targets ]-------------------------------------------------------------------- 243 #---[ Debug Targets ]--------------------------------------------------------------------
243 244
244 Debug: \ 245 Debug: \
245 - $(BINDBG)/$(MODULE_NAME)@DLLEXT@ \  
246 - $(BINDBG)/$(MODULE_NAME)@EXEEXT@ 246 + $(BINDBG)/$(PLUGIN_NAME)@DLLEXT@ \
  247 + $(BINDBG)/$(PLUGIN_NAME)@EXEEXT@
247 248
248 -$(BINDBG)/lib$(MODULE_NAME).a: \ 249 +$(BINDBG)/lib$(PLUGIN_NAME).a: \
249 $(foreach SRC, $(basename $(CORE_SOURCES)), $(OBJDBG)/$(SRC).o) 250 $(foreach SRC, $(basename $(CORE_SOURCES)), $(OBJDBG)/$(SRC).o)
250 251
251 @$(MKDIR) $(@D) 252 @$(MKDIR) $(@D)
@@ -254,8 +255,8 @@ $(BINDBG)/lib$(MODULE_NAME).a: \ @@ -254,8 +255,8 @@ $(BINDBG)/lib$(MODULE_NAME).a: \
254 @$(AR) rcs $@ $^ 255 @$(AR) rcs $@ $^
255 256
256 257
257 -$(BINDBG)/$(MODULE_NAME)@EXEEXT@: \  
258 - $(foreach SRC, $(basename $(TEST_SOURCES)), $(OBJDBG)/$(SRC).o) 258 +$(BINDBG)/$(PLUGIN_NAME)@EXEEXT@: \
  259 + $(foreach SRC, $(basename $(PLUGIN_TEST_SOURCES)), $(OBJDBG)/$(SRC).o)
259 260
260 @$(MKDIR) $(@D) 261 @$(MKDIR) $(@D)
261 @echo $< ... 262 @echo $< ...
@@ -270,7 +271,7 @@ $(BINDBG)/$(MODULE_NAME)@EXEEXT@: \ @@ -270,7 +271,7 @@ $(BINDBG)/$(MODULE_NAME)@EXEEXT@: \
270 $(GTK_LIBS) \ 271 $(GTK_LIBS) \
271 $(GLIB_LIBS) 272 $(GLIB_LIBS)
272 273
273 -$(BINDBG)/$(MODULE_NAME)@DLLEXT@: \ 274 +$(BINDBG)/$(PLUGIN_NAME)@DLLEXT@: \
274 $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) 275 $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o)
275 276
276 @$(MKDIR) $(@D) 277 @$(MKDIR) $(@D)
@@ -293,8 +294,8 @@ clean: \ @@ -293,8 +294,8 @@ clean: \
293 cleanDebug \ 294 cleanDebug \
294 cleanRelease 295 cleanRelease
295 296
296 - @rm -fr $(BASEDIR)/.tmp/$(MODULE_NAME)  
297 - @rm -fr $(POTDIR)/$(MODULE_NAME) 297 + @rm -fr $(BASEDIR)/.tmp/$(PLUGIN_NAME)
  298 + @rm -fr $(POTDIR)/$(PLUGIN_NAME)
298 299
299 cleanDebug: 300 cleanDebug:
300 301
@@ -31,7 +31,7 @@ AC_PREREQ(2.61) @@ -31,7 +31,7 @@ AC_PREREQ(2.61)
31 31
32 dnl Initialise automake with the package name, version and 32 dnl Initialise automake with the package name, version and
33 dnl bug-reporting address. 33 dnl bug-reporting address.
34 -AC_INIT([pw3270], [5.2], [perry.werneck@gmail.com]) 34 +AC_INIT([ipc3270], [5.2], [perry.werneck@gmail.com])
35 35
36 dnl Place auxilliary scripts here. 36 dnl Place auxilliary scripts here.
37 AC_CONFIG_AUX_DIR([scripts]) 37 AC_CONFIG_AUX_DIR([scripts])
src/ipc3270c/linux/daemon.h 0 → 100644
@@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
  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 daemon.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 + * licinio@bb.com.br (Licínio Luis Branco)
  28 + * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
  29 + *
  30 + * Referencias:
  31 + *
  32 + * https://live.gnome.org/DBusGlibBindings
  33 + *
  34 + */
  35 +
  36 + #include "service.h"
  37 +
  38 +/*---[ Globals ]---------------------------------------------------------------------------------*/
  39 +
  40 + G_GNUC_INTERNAL GMainLoop * main_loop;
  41 +
  42 +
  43 +/*---[ Prototipes ]------------------------------------------------------------------------------*/
  44 +
  45 + G_GNUC_INTERNAL void pw3270_dbus_register_io_handlers(void);
  46 +
src/ipc3270c/linux/globals.h 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 globals.h 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 + * licinio@bb.com.br (Licínio Luis Branco)
  28 + * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
  29 + *
  30 + */
  31 +
  32 +#ifndef PW3270_DBUS_GLOBALS_H_INCLUDED
  33 +
  34 + #define PW3270_DBUS_GLOBALS_H_INCLUDED 1
  35 +
  36 + #include <libintl.h>
  37 + #include <glib/gi18n.h>
  38 +
  39 + #include <errno.h>
  40 + #include <lib3270.h>
  41 + #include <lib3270/log.h>
  42 + #include <glib.h>
  43 +
  44 + //
  45 + // Disabling warning on unused-function defined in dbus-glib-bindings.h
  46 + // warning: 'org_freedesktop_DBus_reload_config' defined but not used [-Wunused-function] ...
  47 + //
  48 + #pragma GCC diagnostic ignored "-Wunused-function"
  49 +
  50 + #include <dbus/dbus-glib.h>
  51 + #include <dbus/dbus-glib-bindings.h>
  52 + #include <dbus/dbus-glib-lowlevel.h>
  53 +
  54 + #define ERROR_DOMAIN g_quark_from_static_string("pw3270DBUS")
  55 +
  56 + G_GNUC_INTERNAL gpointer pw3270_dbus_register_object (DBusGConnection *connection,DBusGProxy *proxy,GType object_type,const DBusGObjectInfo *info,const gchar *path);
  57 +
  58 +
  59 +#endif // PW3270_DBUS_GLOBALS_H_INCLUDED
src/ipc3270c/linux/gobject.c 0 → 100644
@@ -0,0 +1,620 @@ @@ -0,0 +1,620 @@
  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 + * licinio@bb.com.br (Licínio Luis Branco)
  28 + * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
  29 + *
  30 + * Referencias:
  31 + *
  32 + * https://live.gnome.org/DBusGlibBindings
  33 + *
  34 + */
  35 +
  36 +#include <glib.h>
  37 +#include <gtk/gtk.h>
  38 +#include <dbus/dbus.h>
  39 +#include <dbus/dbus-glib-lowlevel.h>
  40 +#include <dbus/dbus-glib.h>
  41 +
  42 +#include <config.h>
  43 +#include <lib3270.h>
  44 +#include <pw3270.h>
  45 +#include <v3270.h>
  46 +#include <lib3270/actions.h>
  47 +#include <lib3270/charset.h>
  48 +
  49 +#include "service.h"
  50 +
  51 +/*---[ Globals ]---------------------------------------------------------------------------------*/
  52 +
  53 +
  54 +/*---[ Implement ]-------------------------------------------------------------------------------*/
  55 +
  56 +G_DEFINE_TYPE(PW3270Dbus, pw3270_dbus, G_TYPE_OBJECT)
  57 +
  58 +static void pw3270_dbus_finalize(GObject *object)
  59 +{
  60 + G_OBJECT_CLASS(pw3270_dbus_parent_class)->finalize (object);
  61 +}
  62 +
  63 +
  64 +static void pw3270_dbus_class_init(PW3270DbusClass *klass)
  65 +{
  66 + GObjectClass *object_class;
  67 + object_class = G_OBJECT_CLASS (klass);
  68 + object_class->finalize = pw3270_dbus_finalize;
  69 + debug("%s",__FUNCTION__);
  70 +}
  71 +
  72 +static void pw3270_dbus_init(PW3270Dbus *object)
  73 +{
  74 + debug("%s(%p)",__FUNCTION__,object);
  75 +}
  76 +
  77 +PW3270Dbus * pw3270_dbus_new(void)
  78 +{
  79 + return (PW3270Dbus *) g_object_new(PW3270_TYPE_DBUS, NULL);
  80 +}
  81 +
  82 +void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context)
  83 +{
  84 + debug("%s object=%p context=%p",__FUNCTION__,object,context);
  85 + dbus_g_method_return(context,lib3270_get_revision());
  86 +}
  87 +
  88 +void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context)
  89 +{
  90 + H3270 *hSession = pw3270_dbus_get_session_handle(PW3270_DBUS(object));
  91 +
  92 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  93 +
  94 + if(uri && *uri)
  95 + {
  96 + lib3270_set_url(hSession,uri);
  97 + g_message("Connecting to \"%s\" by remote request",lib3270_get_url(hSession));
  98 + }
  99 + else
  100 + {
  101 + g_message("%s","Connecting by remote request");
  102 + }
  103 +
  104 + dbus_g_method_return(context,lib3270_reconnect(hSession,0));
  105 +}
  106 +
  107 +void pw3270_dbus_set_ur_l(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context)
  108 +{
  109 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  110 +
  111 + g_message("Changing host to \"%s\" by remote request",uri);
  112 +
  113 + dbus_g_method_return(context,lib3270_set_url(pw3270_dbus_get_session_handle(PW3270_DBUS(object)),uri) != 0);
  114 +}
  115 +
  116 +void pw3270_dbus_get_ur_l(PW3270Dbus *object, DBusGMethodInvocation *context)
  117 +{
  118 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  119 + dbus_g_method_return(context,lib3270_get_url(pw3270_dbus_get_session_handle(PW3270_DBUS(object))));
  120 +}
  121 +
  122 +
  123 +void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context)
  124 +{
  125 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  126 +
  127 + g_message("Disconnecting by remote request");
  128 + lib3270_disconnect(pw3270_dbus_get_session_handle(object));
  129 + dbus_g_method_return(context,0);
  130 +}
  131 +
  132 +void pw3270_dbus_get_message_id(PW3270Dbus *object, DBusGMethodInvocation *context)
  133 +{
  134 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  135 + dbus_g_method_return(context,lib3270_get_program_message(pw3270_dbus_get_session_handle(object)));
  136 +}
  137 +
  138 +void pw3270_dbus_get_connection_state(PW3270Dbus *object, DBusGMethodInvocation *context)
  139 +{
  140 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  141 + dbus_g_method_return(context,lib3270_get_connection_state(pw3270_dbus_get_session_handle(object)));
  142 +}
  143 +
  144 +void pw3270_dbus_get_secure_state(PW3270Dbus *object, DBusGMethodInvocation *context)
  145 +{
  146 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  147 + dbus_g_method_return(context,lib3270_get_secure(pw3270_dbus_get_session_handle(object)));
  148 +}
  149 +
  150 +GError * pw3270_dbus_get_error_from_errno(int code)
  151 +{
  152 + return g_error_new(ERROR_DOMAIN,code,"%s",g_strerror(code));
  153 +}
  154 +
  155 +int pw3270_dbus_check_valid_state(PW3270Dbus *object, DBusGMethodInvocation *context)
  156 +{
  157 + H3270 * hSession = pw3270_dbus_get_session_handle(object);
  158 + GError * error = NULL;
  159 +
  160 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  161 +
  162 + if(!lib3270_is_connected(hSession))
  163 + {
  164 + error = pw3270_dbus_get_error_from_errno(ENOTCONN);
  165 + }
  166 + else
  167 + {
  168 + LIB3270_MESSAGE state = lib3270_get_program_message(hSession);
  169 +
  170 + switch(state)
  171 + {
  172 + case LIB3270_MESSAGE_NONE:
  173 + return 0;
  174 +
  175 + case LIB3270_MESSAGE_DISCONNECTED:
  176 + error = pw3270_dbus_get_error_from_errno(ENOTCONN);
  177 + break;
  178 +
  179 + case LIB3270_MESSAGE_MINUS:
  180 + case LIB3270_MESSAGE_PROTECTED:
  181 + case LIB3270_MESSAGE_NUMERIC:
  182 + case LIB3270_MESSAGE_OVERFLOW:
  183 + case LIB3270_MESSAGE_INHIBIT:
  184 + case LIB3270_MESSAGE_KYBDLOCK:
  185 + case LIB3270_MESSAGE_X:
  186 + error = g_error_new(ERROR_DOMAIN,-1,_( "State %04d can't accept requests" ),state);
  187 + break;
  188 +
  189 + case LIB3270_MESSAGE_SYSWAIT:
  190 + case LIB3270_MESSAGE_TWAIT:
  191 + case LIB3270_MESSAGE_CONNECTED:
  192 + case LIB3270_MESSAGE_AWAITING_FIRST:
  193 + error = pw3270_dbus_get_error_from_errno(EBUSY);
  194 + break;
  195 +
  196 + case LIB3270_MESSAGE_RESOLVING:
  197 + case LIB3270_MESSAGE_CONNECTING:
  198 + error = g_error_new(ERROR_DOMAIN,EINPROGRESS,_( "Connecting to host" ));
  199 + break;
  200 +
  201 + case LIB3270_MESSAGE_USER:
  202 + error = g_error_new(ERROR_DOMAIN,-1,_( "Unexpected state %04d" ),state);
  203 + }
  204 + }
  205 +
  206 + if(error)
  207 + {
  208 + dbus_g_method_return_error(context,error);
  209 + g_error_free(error);
  210 + return -1;
  211 + }
  212 +
  213 + return 0;
  214 +}
  215 +
  216 +void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *context)
  217 +{
  218 + char * text;
  219 + gchar * utftext;
  220 + H3270 * hSession = pw3270_dbus_get_session_handle(object);
  221 +
  222 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  223 +
  224 + if(pw3270_dbus_check_valid_state(object,context))
  225 + return;
  226 +
  227 + text = lib3270_get_string_at_address(hSession,0,-1,'\n');
  228 +
  229 + utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL);
  230 +
  231 + lib3270_free(text);
  232 +
  233 + dbus_g_method_return(context,utftext);
  234 +
  235 + g_free(utftext);
  236 +
  237 +}
  238 +
  239 +void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context)
  240 +{
  241 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  242 + if(pw3270_dbus_check_valid_state(object,context))
  243 + return;
  244 + dbus_g_method_return(context,lib3270_enter(pw3270_dbus_get_session_handle(object)));
  245 +}
  246 +
  247 +void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *utftext, DBusGMethodInvocation *context)
  248 +{
  249 + gchar * text;
  250 + H3270 * hSession = pw3270_dbus_get_session_handle(object);
  251 +
  252 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  253 + if(pw3270_dbus_check_valid_state(object,context))
  254 + return;
  255 +
  256 + text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL);
  257 +
  258 + int sz = lib3270_set_string_at(hSession,row,col,(const unsigned char *) text);
  259 +
  260 + trace("%s returns %d",__FUNCTION__,sz);
  261 + dbus_g_method_return(context,sz);
  262 +
  263 + g_free(text);
  264 +}
  265 +
  266 +void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context)
  267 +{
  268 + gchar * text;
  269 + H3270 * hSession = pw3270_dbus_get_session_handle(object);
  270 +
  271 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  272 + if(pw3270_dbus_check_valid_state(object,context))
  273 + return;
  274 +
  275 + text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL);
  276 +
  277 + dbus_g_method_return(context,lib3270_emulate_input(hSession,(const char *) text,-1,1));
  278 +
  279 + g_free(text);
  280 +}
  281 +
  282 +
  283 +void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, char lf, DBusGMethodInvocation *context)
  284 +{
  285 + gchar * text;
  286 + H3270 * hSession = pw3270_dbus_get_session_handle(object);
  287 +
  288 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  289 + if(pw3270_dbus_check_valid_state(object,context))
  290 + return;
  291 +
  292 + text = lib3270_get_string_at(hSession, row, col, len, lf);
  293 + if(!text)
  294 + {
  295 + GError *error = pw3270_dbus_get_error_from_errno(errno);
  296 + dbus_g_method_return_error(context,error);
  297 + g_error_free(error);
  298 + }
  299 + else
  300 + {
  301 + gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL);
  302 +
  303 + lib3270_free(text);
  304 +
  305 + dbus_g_method_return(context,utftext);
  306 +
  307 + g_free(utftext);
  308 + }
  309 + }
  310 +
  311 + void pw3270_dbus_get_text(PW3270Dbus *object, int offset, int len, char lf, DBusGMethodInvocation *context)
  312 + {
  313 + gchar * text;
  314 + H3270 * hSession = pw3270_dbus_get_session_handle(object);
  315 +
  316 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  317 + if(pw3270_dbus_check_valid_state(object,context))
  318 + return;
  319 +
  320 + if(len < 0) {
  321 + len = lib3270_get_length(hSession);
  322 + }
  323 +
  324 + text = lib3270_get_string_at_address(hSession,offset,len,lf);
  325 + if(!text)
  326 + {
  327 + GError *error = pw3270_dbus_get_error_from_errno(errno);
  328 + dbus_g_method_return_error(context,error);
  329 + g_error_free(error);
  330 + }
  331 + else
  332 + {
  333 + gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL);
  334 +
  335 + lib3270_free(text);
  336 +
  337 + debug("\n%s\n",utftext);
  338 +
  339 + dbus_g_method_return(context,utftext);
  340 +
  341 + g_free(utftext);
  342 + }
  343 +
  344 + }
  345 +
  346 + void pw3270_dbus_is_connected(PW3270Dbus *object, DBusGMethodInvocation *context)
  347 + {
  348 + trace("%s object=%p context=%p connected=%s",__FUNCTION__,object,context, lib3270_is_connected(pw3270_dbus_get_session_handle(object)) ? "Yes" : "No");
  349 + dbus_g_method_return(context,lib3270_is_connected(pw3270_dbus_get_session_handle(object)));
  350 + }
  351 +
  352 + void pw3270_dbus_is_ready(PW3270Dbus *object, DBusGMethodInvocation *context)
  353 + {
  354 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  355 + dbus_g_method_return(context,lib3270_is_ready(pw3270_dbus_get_session_handle(object)));
  356 + }
  357 +
  358 + void pw3270_dbus_in_tn3270_e(PW3270Dbus *object, DBusGMethodInvocation *context)
  359 + {
  360 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  361 + dbus_g_method_return(context,lib3270_in_tn3270e(pw3270_dbus_get_session_handle(object)));
  362 + }
  363 +
  364 + void pw3270_dbus_wait_for_ready(PW3270Dbus *object, int timeout, DBusGMethodInvocation *context)
  365 + {
  366 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  367 + dbus_g_method_return(context,lib3270_wait_for_ready(pw3270_dbus_get_session_handle(object),timeout));
  368 + }
  369 +
  370 + void pw3270_dbus_set_cursor_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context)
  371 + {
  372 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  373 + dbus_g_method_return(context,lib3270_set_cursor_position(pw3270_dbus_get_session_handle(object),row,col));
  374 + }
  375 +
  376 + void pw3270_dbus_set_cursor_address(PW3270Dbus *object, int addr, DBusGMethodInvocation *context)
  377 + {
  378 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  379 + dbus_g_method_return(context,lib3270_set_cursor_address(pw3270_dbus_get_session_handle(object),addr));
  380 + }
  381 +
  382 + void pw3270_dbus_get_cursor_address(PW3270Dbus *object, DBusGMethodInvocation *context)
  383 + {
  384 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  385 + dbus_g_method_return(context,lib3270_get_cursor_address(pw3270_dbus_get_session_handle(object)));
  386 + }
  387 +
  388 + void pw3270_dbus_get_screen_width(PW3270Dbus *object, DBusGMethodInvocation *context)
  389 + {
  390 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  391 + dbus_g_method_return(context,lib3270_get_width(pw3270_dbus_get_session_handle(object)));
  392 + }
  393 +
  394 + void pw3270_dbus_get_screen_height(PW3270Dbus *object, DBusGMethodInvocation *context)
  395 + {
  396 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  397 + dbus_g_method_return(context,lib3270_get_height(pw3270_dbus_get_session_handle(object)));
  398 + }
  399 +
  400 + void pw3270_dbus_get_screen_length(PW3270Dbus *object, DBusGMethodInvocation *context)
  401 + {
  402 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  403 + dbus_g_method_return(context,lib3270_get_width(pw3270_dbus_get_session_handle(object)));
  404 + }
  405 +
  406 + void pw3270_dbus_set_toggle(PW3270Dbus *object, int id, int value, DBusGMethodInvocation *context)
  407 + {
  408 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  409 + dbus_g_method_return(context,lib3270_set_toggle(pw3270_dbus_get_session_handle(object),(LIB3270_TOGGLE) id,value));
  410 + }
  411 +
  412 +void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *utftext, char lf, DBusGMethodInvocation *context)
  413 +{
  414 + gchar * text;
  415 + H3270 * hSession = pw3270_dbus_get_session_handle(object);
  416 +
  417 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  418 + if(pw3270_dbus_check_valid_state(object,context))
  419 + return;
  420 +
  421 + text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL);
  422 +
  423 + dbus_g_method_return(context,lib3270_cmp_text_at(hSession,row,col,text,lf));
  424 +
  425 + g_free(text);
  426 +}
  427 +
  428 +void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context)
  429 +{
  430 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  431 + if(pw3270_dbus_check_valid_state(object,context))
  432 + return;
  433 + dbus_g_method_return(context,lib3270_pfkey(pw3270_dbus_get_session_handle(object),key));
  434 +}
  435 +
  436 +void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context)
  437 +{
  438 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  439 + if(pw3270_dbus_check_valid_state(object,context))
  440 + return;
  441 + dbus_g_method_return(context,lib3270_pakey(pw3270_dbus_get_session_handle(object),key));
  442 +}
  443 +
  444 + void pw3270_dbus_get_field_start(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context)
  445 + {
  446 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  447 + dbus_g_method_return(context,lib3270_get_field_start(pw3270_dbus_get_session_handle(object),baddr));
  448 + }
  449 +
  450 + void pw3270_dbus_get_field_length(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context)
  451 + {
  452 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  453 + dbus_g_method_return(context,lib3270_get_field_len(pw3270_dbus_get_session_handle(object),baddr));
  454 + }
  455 +
  456 + void pw3270_dbus_get_next_unprotected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context)
  457 + {
  458 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  459 + dbus_g_method_return(context,lib3270_get_next_unprotected(pw3270_dbus_get_session_handle(object),baddr));
  460 + }
  461 +
  462 + void pw3270_dbus_get_is_protected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context)
  463 + {
  464 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  465 + dbus_g_method_return(context,lib3270_get_is_protected(pw3270_dbus_get_session_handle(object),baddr));
  466 + }
  467 +
  468 + void pw3270_dbus_get_is_protected_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context)
  469 + {
  470 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  471 + dbus_g_method_return(context,lib3270_get_is_protected_at(pw3270_dbus_get_session_handle(object),row,col));
  472 + }
  473 +
  474 + void pw3270_dbus_action(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context)
  475 + {
  476 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  477 + dbus_g_method_return(context,lib3270_action(pw3270_dbus_get_session_handle(object),text));
  478 + }
  479 +
  480 + void pw3270_dbus_get_clipboard(PW3270Dbus *object, DBusGMethodInvocation *context)
  481 + {
  482 + gchar *text;
  483 +
  484 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  485 +
  486 + if(pw3270_dbus_check_valid_state(object,context))
  487 + return;
  488 +
  489 + text = gtk_clipboard_wait_for_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD));
  490 +
  491 + trace("Clipboard:\n%s\n",text);
  492 +
  493 + if(!text)
  494 + {
  495 + GError *error = pw3270_dbus_get_error_from_errno(ENOENT);
  496 + dbus_g_method_return_error(context,error);
  497 + g_error_free(error);
  498 + }
  499 + else
  500 + {
  501 + dbus_g_method_return(context,text);
  502 + g_free(text);
  503 + }
  504 +}
  505 +
  506 +void pw3270_dbus_set_clipboard(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context)
  507 +{
  508 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  509 + gtk_clipboard_set_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD),(gchar *) text, -1);
  510 + dbus_g_method_return(context,0);
  511 +}
  512 +
  513 +void pw3270_dbus_set_script(PW3270Dbus *object, const gchar G_GNUC_UNUSED(*text), int mode, DBusGMethodInvocation *context)
  514 +{
  515 + GtkWidget *widget = pw3270_get_terminal_widget(NULL);
  516 +
  517 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  518 +
  519 + if(!widget)
  520 + {
  521 + GError *error = pw3270_dbus_get_error_from_errno(EINVAL);
  522 + dbus_g_method_return_error(context,error);
  523 + g_error_free(error);
  524 + return;
  525 + }
  526 +
  527 + dbus_g_method_return(context,v3270_set_script(widget,mode == 0 ? 0 : 'S'));
  528 +}
  529 +
  530 +void pw3270_dbus_show_popup(PW3270Dbus *object, int id, const gchar *title, const gchar *msg, const gchar *text, DBusGMethodInvocation *context)
  531 +{
  532 + lib3270_popup_dialog(pw3270_dbus_get_session_handle(object), (LIB3270_NOTIFY) id , title, msg, "%s", text);
  533 + dbus_g_method_return(context,0);
  534 +}
  535 +
  536 +void pw3270_dbus_get_host_charset(PW3270Dbus *object, DBusGMethodInvocation *context)
  537 +{
  538 + dbus_g_method_return(context,lib3270_get_host_charset(pw3270_dbus_get_session_handle(object)));
  539 +}
  540 +
  541 +void pw3270_dbus_get_display_charset(PW3270Dbus G_GNUC_UNUSED(*object), DBusGMethodInvocation *context)
  542 +{
  543 + // Allways return UTF-8 to avoid double conversion
  544 + dbus_g_method_return(context,"UTF-8");
  545 +}
  546 +
  547 +void pw3270_dbus_set_host_charset(PW3270Dbus *object, const gchar *charset, DBusGMethodInvocation *context)
  548 +{
  549 + dbus_g_method_return(context,lib3270_set_host_charset(pw3270_dbus_get_session_handle(object),charset));
  550 +}
  551 +
  552 +void pw3270_dbus_erase_eof(PW3270Dbus *object, DBusGMethodInvocation *context)
  553 +{
  554 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  555 + dbus_g_method_return(context,lib3270_eraseeof(pw3270_dbus_get_session_handle(object)));
  556 +}
  557 +
  558 +void pw3270_dbus_print(PW3270Dbus *object, DBusGMethodInvocation *context)
  559 +{
  560 + dbus_g_method_return(context,lib3270_print_all(pw3270_dbus_get_session_handle(object)));
  561 +}
  562 +
  563 +void pw3270_dbus_set_unlock_delay(PW3270Dbus *object, int value, DBusGMethodInvocation *context)
  564 +{
  565 + lib3270_set_unlock_delay(pw3270_dbus_get_session_handle(object),(unsigned short) value);
  566 + dbus_g_method_return(context,0);
  567 +}
  568 +
  569 +
  570 +void pw3270_dbus_ebc2asc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context)
  571 +{
  572 + int sz = strlen(from);
  573 +
  574 + if(sz > 0)
  575 + {
  576 + unsigned char buffer[sz+1];
  577 + memcpy(buffer,from,sz);
  578 + dbus_g_method_return(context,lib3270_ebc2asc(pw3270_dbus_get_session_handle(object),buffer,sz));
  579 + return;
  580 + }
  581 +
  582 + dbus_g_method_return(context,"");
  583 +
  584 +}
  585 +
  586 +void pw3270_dbus_asc2ebc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context)
  587 +{
  588 + int sz = strlen(from);
  589 +
  590 + if(sz > 0)
  591 + {
  592 + unsigned char buffer[sz+1];
  593 + memcpy(buffer,from,sz);
  594 + dbus_g_method_return(context,lib3270_asc2ebc(pw3270_dbus_get_session_handle(object),buffer,sz));
  595 + return;
  596 + }
  597 +
  598 + dbus_g_method_return(context,"");
  599 +
  600 +}
  601 +
  602 +void pw3270_dbus_filetransfer(PW3270Dbus *object, const gchar *local, const gchar *remote, int flags, int lrecl, int blksize, int primspace, int secspace, int dft, DBusGMethodInvocation *context)
  603 +{
  604 + /*
  605 + dbus_g_method_return(context,
  606 + v3270_transfer_file(
  607 + v3270_get_default_widget(),
  608 + (LIB3270_FT_OPTION) flags,
  609 + local,
  610 + remote,
  611 + lrecl,
  612 + blksize,
  613 + primspace,
  614 + secspace,
  615 + dft
  616 + ));
  617 + */
  618 + return;
  619 +}
  620 +
src/ipc3270c/linux/main.c 0 → 100644
@@ -0,0 +1,179 @@ @@ -0,0 +1,179 @@
  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/fbuihuu/samples-dbus/blob/master/dbus-server.c
  26 + *
  27 + * Contatos:
  28 + *
  29 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  30 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  31 + *
  32 + */
  33 +
  34 +#include <glib.h>
  35 +#include <dbus/dbus.h>
  36 +#include <dbus/dbus-glib-lowlevel.h>
  37 +#include <dbus/dbus-glib.h>
  38 +
  39 +#include <v3270.h>
  40 +#include <pw3270.h>
  41 +#include <pw3270/plugin.h>
  42 +
  43 +#include "service.h"
  44 +#include "dbus-glue.h"
  45 +
  46 +#include <gtk/gtk.h>
  47 +
  48 +/*---[ Globals ]---------------------------------------------------------------------------------*/
  49 +
  50 + static DBusGConnection * connection = NULL;
  51 + static DBusGProxy * proxy = NULL;
  52 + static gchar * service_name = NULL;
  53 +
  54 +
  55 +/*---[ Implement ]-------------------------------------------------------------------------------*/
  56 +
  57 + LIB3270_EXPORT int pw3270_plugin_start(GtkWidget G_GNUC_UNUSED(*window), GtkWidget *terminal)
  58 + {
  59 + GError * error = NULL;
  60 + guint result;
  61 + char session_id = 0;
  62 + char id = 'a';
  63 + const gchar * name = "pw3270";
  64 +
  65 + connection = dbus_g_bus_get_private(DBUS_BUS_SESSION, g_main_context_default(), &error);
  66 + if(error)
  67 + {
  68 + GtkWidget *dialog = gtk_message_dialog_new(
  69 + GTK_WINDOW(window),
  70 + (GtkDialogFlags) (GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT),
  71 + GTK_MESSAGE_ERROR,
  72 + GTK_BUTTONS_OK,
  73 + _( "Can't connect to DBUS server" ));
  74 +
  75 + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message);
  76 +
  77 + g_message("Error \"%s\" getting session dbus",error->message);
  78 +
  79 + g_error_free(error);
  80 +
  81 + gtk_dialog_run(GTK_DIALOG(dialog));
  82 + gtk_widget_destroy(dialog);
  83 +
  84 + return -1;
  85 + }
  86 +
  87 + proxy = dbus_g_proxy_new_for_name(connection,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS);
  88 +
  89 + for(id='a'; id < 'z' && !error && !service_name; id++)
  90 + {
  91 + gboolean has_owner = FALSE;
  92 +
  93 + service_name = g_strdup_printf("br.com.bb.%s.%c",name,(int) id);
  94 +
  95 + org_freedesktop_DBus_name_has_owner(proxy, service_name, &has_owner, NULL);
  96 +
  97 + if(has_owner)
  98 + {
  99 + trace("Service \"%s\" has owner",service_name)
  100 + g_free(service_name);
  101 + service_name = NULL;
  102 + }
  103 + else
  104 + {
  105 + session_id = id;
  106 + g_message("DBUS service name is %s",service_name);
  107 + org_freedesktop_DBus_request_name(proxy, service_name, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error);
  108 + }
  109 + }
  110 +
  111 + if(error)
  112 + {
  113 + GtkWidget *dialog = gtk_message_dialog_new(
  114 + GTK_WINDOW(window),
  115 + (GtkDialogFlags) (GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT),
  116 + GTK_MESSAGE_ERROR,
  117 + GTK_BUTTONS_OK,
  118 + _( "Can't get DBUS object name" ));
  119 +
  120 + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message);
  121 +
  122 + g_message("Error \"%s\" requesting DBUS name",error->message);
  123 +
  124 + g_error_free(error);
  125 +
  126 + gtk_dialog_run(GTK_DIALOG(dialog));
  127 + gtk_widget_destroy(dialog);
  128 +
  129 + return -1;
  130 + }
  131 +
  132 + if(session_id)
  133 + {
  134 + g_autofree gchar * path = g_strdup_printf("/br/com/bb/%s",name);
  135 + g_autofree gchar * session = g_strdup_printf("%s:%c",name,g_ascii_toupper(session_id));
  136 +
  137 + // pw3270_set_session_name(window,session);
  138 + v3270_set_session_name(terminal,session);
  139 +
  140 + g_message("DBUS service path is %s, session name is %s",path,session);
  141 +
  142 + pw3270_dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,path);
  143 +
  144 + }
  145 +
  146 + return 0;
  147 + }
  148 +
  149 + LIB3270_EXPORT int pw3270_plugin_stop(GtkWidget G_GNUC_UNUSED(*window), GtkWidget G_GNUC_UNUSED(*terminal))
  150 + {
  151 + if(proxy)
  152 + {
  153 + debug("%s: Releasing proxy",__FUNCTION__);
  154 + g_object_unref(proxy);
  155 + proxy = NULL;
  156 + }
  157 +
  158 + if(service_name)
  159 + {
  160 + g_free(service_name);
  161 + service_name = NULL;
  162 + }
  163 + return 0;
  164 + }
  165 +
  166 + void pw3270_dbus_quit(PW3270Dbus G_GNUC_UNUSED(*object), DBusGMethodInvocation *context)
  167 + {
  168 + gtk_main_quit();
  169 + dbus_g_method_return(context,0);
  170 + }
  171 +
  172 + H3270 * pw3270_dbus_get_session_handle(PW3270Dbus G_GNUC_UNUSED(*object))
  173 + {
  174 + debug("%s=%p",__FUNCTION__,lib3270_get_default_session_handle());
  175 + return lib3270_get_default_session_handle();
  176 + }
  177 +
  178 +
  179 +
src/ipc3270c/linux/misc.c 0 → 100644
@@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
  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 misc.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 + * licinio@bb.com.br (Licínio Luis Branco)
  28 + * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
  29 + *
  30 + * Referencias:
  31 + *
  32 + * https://live.gnome.org/DBusGlibBindings
  33 + *
  34 + */
  35 +
  36 +#include "globals.h"
  37 +
  38 +/*---[ Implement ]-------------------------------------------------------------------------------*/
  39 +
  40 +gpointer pw3270_dbus_register_object(DBusGConnection *connection,DBusGProxy G_GNUC_UNUSED(*proxy),GType object_type,const DBusGObjectInfo *info,const gchar *path)
  41 +{
  42 + GObject *object = G_OBJECT(g_object_new(object_type, NULL));
  43 + dbus_g_object_type_install_info (object_type, info);
  44 + dbus_g_connection_register_g_object (connection, path, object);
  45 + return object;
  46 +}
  47 +
src/ipc3270c/linux/service.h 0 → 100644
@@ -0,0 +1,138 @@ @@ -0,0 +1,138 @@
  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 service.h 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 + * licinio@bb.com.br (Licínio Luis Branco)
  28 + * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
  29 + *
  30 + */
  31 +
  32 +#ifndef _PW3270_DBUS_SERVICE_H
  33 +
  34 + #define _PW3270_DBUS_SERVICE_H 1
  35 +
  36 + #define ENABLE_NLS
  37 + #define GETTEXT_PACKAGE PACKAGE_NAME
  38 +
  39 + #include "globals.h"
  40 +
  41 + #define PW3270_TYPE_DBUS (pw3270_dbus_get_type ())
  42 + #define PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PW3270_TYPE_DBUS, PW3270Dbus))
  43 + #define PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_DBUS, PW3270DbusClass))
  44 + #define IS_PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PW3270_TYPE_DBUS))
  45 + #define IS_PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_DBUS))
  46 + #define PW3270_DBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_DBUS, PW3270DbusClass))
  47 +
  48 + G_BEGIN_DECLS
  49 +
  50 + typedef struct _PW3270Dbus PW3270Dbus;
  51 + typedef struct _PW3270DbusClass PW3270DbusClass;
  52 +
  53 + struct _PW3270Dbus
  54 + {
  55 + GObject parent;
  56 + };
  57 +
  58 + struct _PW3270DbusClass
  59 + {
  60 + GObjectClass parent;
  61 + };
  62 +
  63 + PW3270Dbus * pw3270_dbus_new (void);
  64 + GType pw3270_dbus_get_type (void);
  65 +
  66 + void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context);
  67 + void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context);
  68 + void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context);
  69 + void pw3270_dbus_get_ur_l(PW3270Dbus *object, DBusGMethodInvocation *context);
  70 + void pw3270_dbus_set_ur_l(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context);
  71 + void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context);
  72 +
  73 + void pw3270_dbus_get_message_id(PW3270Dbus *object, DBusGMethodInvocation *context);
  74 + void pw3270_dbus_get_connection_state(PW3270Dbus *object, DBusGMethodInvocation *context);
  75 + void pw3270_dbus_get_secure_state(PW3270Dbus *object, DBusGMethodInvocation *context);
  76 +
  77 + void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *context);
  78 + H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object);
  79 + GError * pw3270_dbus_get_error_from_errno(int code);
  80 +
  81 + void pw3270_dbus_is_connected(PW3270Dbus *object, DBusGMethodInvocation *context);
  82 + void pw3270_dbus_is_ready(PW3270Dbus *object, DBusGMethodInvocation *context);
  83 + void pw3270_dbus_in_tn3270_e(PW3270Dbus *object, DBusGMethodInvocation *context);
  84 +
  85 + void pw3270_dbus_set_cursor_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context);
  86 + void pw3270_dbus_set_cursor_address(PW3270Dbus *object, int addr, DBusGMethodInvocation *context);
  87 + void pw3270_dbus_get_cursor_address(PW3270Dbus *object, DBusGMethodInvocation *context);
  88 +
  89 + void pw3270_dbus_get_screen_width(PW3270Dbus *object, DBusGMethodInvocation *context);
  90 + void pw3270_dbus_get_screen_height(PW3270Dbus *object, DBusGMethodInvocation *context);
  91 + void pw3270_dbus_get_screen_length(PW3270Dbus *object, DBusGMethodInvocation *context);
  92 +
  93 + void pw3270_dbus_set_toggle(PW3270Dbus *object, int id, int value, DBusGMethodInvocation *context);
  94 +
  95 + void pw3270_dbus_wait_for_ready(PW3270Dbus *object, int timeout, DBusGMethodInvocation *context);
  96 +
  97 + void pw3270_dbus_get_field_start(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context);
  98 + void pw3270_dbus_get_field_length(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context);
  99 + void pw3270_dbus_get_next_unprotected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context);
  100 +
  101 + void pw3270_dbus_get_is_protected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context);
  102 + void pw3270_dbus_get_is_protected_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context);
  103 +
  104 + void pw3270_dbus_set_script(PW3270Dbus *object, const gchar *text, int mode, DBusGMethodInvocation *context);
  105 +
  106 + void pw3270_dbus_show_popup(PW3270Dbus *object, int id, const gchar *title, const gchar *msg, const gchar *text, DBusGMethodInvocation *context);
  107 +
  108 + void pw3270_dbus_action(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context);
  109 +
  110 + // Actions
  111 + void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context);
  112 + void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context);
  113 + void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context);
  114 + void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context);
  115 + void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, char lf, DBusGMethodInvocation *context);
  116 + void pw3270_dbus_get_text(PW3270Dbus *object, int offset, int len, char lf, DBusGMethodInvocation *context);
  117 + void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *text, char lf, DBusGMethodInvocation *context);
  118 + void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context);
  119 +
  120 + void pw3270_dbus_set_clipboard(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context);
  121 + void pw3270_dbus_get_clipboard(PW3270Dbus *object, DBusGMethodInvocation *context);
  122 +
  123 + void pw3270_dbus_get_display_charset(PW3270Dbus *object, DBusGMethodInvocation *context);
  124 + void pw3270_dbus_get_host_charset(PW3270Dbus *object, DBusGMethodInvocation *context);
  125 + void pw3270_dbus_set_host_charset(PW3270Dbus *object, const gchar *charset, DBusGMethodInvocation *context);
  126 + void pw3270_dbus_erase_eof(PW3270Dbus *object, DBusGMethodInvocation *context);
  127 + void pw3270_dbus_print(PW3270Dbus *object, DBusGMethodInvocation *context);
  128 +
  129 + void pw3270_dbus_asc2ebc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context);
  130 + void pw3270_dbus_ebc2asc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context);
  131 +
  132 + void pw3270_dbus_filetransfer(PW3270Dbus *object, const gchar *local, const gchar *remote, int flags, int lrecl, int blksize, int primspace, int secspace, int dft, DBusGMethodInvocation *context);
  133 +
  134 + void pw3270_dbus_set_unlock_delay(PW3270Dbus *object, int value, DBusGMethodInvocation *context);
  135 +
  136 + G_END_DECLS
  137 +
  138 +#endif // _PW3270_DBUS_SERVICE_H
src/ipc3270c/windows/main.c 0 → 100644
@@ -0,0 +1,675 @@ @@ -0,0 +1,675 @@
  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 o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como - e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + * Agradecimento:
  29 + *
  30 + * Hélio Passos
  31 + *
  32 + */
  33 +
  34 + #include "private.h"
  35 +
  36 +#ifdef _WIN32
  37 + #include <windows.h>
  38 +#else
  39 + #error HLLAPI is designed for windows.
  40 +#endif // _WIN32
  41 +
  42 + #include <pw3270/plugin.h>
  43 + #include <v3270.h>
  44 + #include <pw3270/ipcpackets.h>
  45 + #include <lib3270/actions.h>
  46 + #include <lib3270/charset.h>
  47 +
  48 +/*--[ Defines ]--------------------------------------------------------------------------------------*/
  49 +
  50 + #pragma pack(1)
  51 +
  52 + enum PIPE_STATE
  53 + {
  54 + PIPE_STATE_WAITING,
  55 + PIPE_STATE_READ,
  56 + PIPE_STATE_PENDING_READ,
  57 + PIPE_STATE_UNDEFINED
  58 + };
  59 +
  60 + typedef struct _pipe_source
  61 + {
  62 + GSource gsrc;
  63 + HANDLE hPipe;
  64 +
  65 + enum PIPE_STATE state;
  66 +
  67 + OVERLAPPED overlap;
  68 + unsigned char buffer[PIPE_BUFFER_LENGTH+1];
  69 + } pipe_source;
  70 +
  71 + #pragma pack()
  72 +
  73 +
  74 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  75 +
  76 +// static const gchar control_char = '@';
  77 +
  78 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  79 +
  80 + static void IO_accept(pipe_source *source)
  81 + {
  82 + set_active(FALSE);
  83 +
  84 + if(ConnectNamedPipe(source->hPipe,&source->overlap))
  85 + {
  86 + popup_lasterror("%s",_( "Error in ConnectNamedPipe" ));
  87 + return;
  88 + }
  89 +
  90 + switch(GetLastError())
  91 + {
  92 + // The overlapped connection in progress.
  93 + case ERROR_IO_PENDING:
  94 + // trace("%s: ERROR_IO_PENDING",__FUNCTION__);
  95 + source->state = PIPE_STATE_WAITING;
  96 + break;
  97 +
  98 + // Client is already connected, so signal an event.
  99 + case ERROR_PIPE_CONNECTED:
  100 + trace("%s: ERROR_PIPE_CONNECTED",__FUNCTION__);
  101 + set_active(TRUE);
  102 + SetEvent(source->overlap.hEvent);
  103 + break;
  104 +
  105 + // If an error occurs during the connect operation...
  106 + default:
  107 + popup_lasterror("%s", _( "ConnectNamedPipe failed" ));
  108 + }
  109 +
  110 + }
  111 +
  112 + static gboolean IO_prepare(GSource *source, gint *timeout)
  113 + {
  114 + /*
  115 + * Called before all the file descriptors are polled.
  116 + * If the source can determine that it is ready here
  117 + * (without waiting for the results of the poll() call)
  118 + * it should return TRUE.
  119 + *
  120 + * It can also return a timeout_ value which should be the maximum
  121 + * timeout (in milliseconds) which should be passed to the poll() call.
  122 + * The actual timeout used will be -1 if all sources returned -1,
  123 + * or it will be the minimum of all the timeout_ values
  124 + * returned which were >= 0.
  125 + *
  126 + */
  127 + if(WaitForSingleObject(((pipe_source *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)
  128 + return TRUE;
  129 +
  130 + *timeout = 10;
  131 + return FALSE;
  132 + }
  133 +
  134 + static gboolean IO_check(GSource *source)
  135 + {
  136 + /*
  137 + * Called after all the file descriptors are polled.
  138 + * The source should return TRUE if it is ready to be dispatched.
  139 + * Note that some time may have passed since the previous prepare
  140 + * function was called, so the source should be checked again here.
  141 + *
  142 + */
  143 + if(WaitForSingleObject(((pipe_source *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)
  144 + return TRUE;
  145 +
  146 + return FALSE;
  147 + }
  148 +
  149 + static void send_text(pipe_source *source, char *text)
  150 + {
  151 + struct hllapi_packet_text *pkt;
  152 + DWORD szBlock;
  153 + int f;
  154 +
  155 + if(text)
  156 + {
  157 + szBlock = sizeof(struct hllapi_packet_text)+strlen(text);
  158 + pkt = (struct hllapi_packet_text *) g_malloc0(szBlock);
  159 + pkt->packet_id = 0;
  160 + strcpy(pkt->text,text);
  161 + lib3270_free(text);
  162 + }
  163 + else
  164 + {
  165 + szBlock = sizeof(struct hllapi_packet_text);
  166 + pkt = (struct hllapi_packet_text *) g_malloc0(szBlock);
  167 + pkt->packet_id = errno ? errno : -1;
  168 + }
  169 +
  170 + trace("szBlock=%d text=\"%s\"",szBlock, ( (struct hllapi_packet_text *) pkt)->text);
  171 + for(f=0;f< (int) szBlock;f++)
  172 + {
  173 + trace("rsp(%d)= %d \"%s\"",f,* (((char *) pkt)+f),((char *) pkt)+f);
  174 + }
  175 +
  176 + WriteFile(source->hPipe,pkt,szBlock,&szBlock,NULL);
  177 +
  178 + g_free(pkt);
  179 + }
  180 +
  181 + static void send_result(pipe_source *source, int rc)
  182 + {
  183 + struct hllapi_packet_result pkt = { rc };
  184 + DWORD wrote = sizeof(pkt);
  185 + WriteFile(source->hPipe,&pkt,wrote,&wrote,NULL);
  186 + }
  187 +
  188 + static int do_file_transfer(struct hllapi_packet_file_transfer * source)
  189 + {
  190 + /*
  191 + const gchar * local = (const char *) source->text;
  192 + const gchar * remote = (const char *) (local+strlen(local)+1);
  193 +
  194 + return v3270_transfer_file( v3270_get_default_widget(),
  195 + (LIB3270_FT_OPTION) source->options,
  196 + local,
  197 + remote,
  198 + source->lrecl,
  199 + source->blksize,
  200 + source->primspace,
  201 + source->secspace,
  202 + source->dft );
  203 + */
  204 + return EINVAL;
  205 + }
  206 +
  207 + static void get_host(pipe_source *source) {
  208 + send_text(source,strdup(lib3270_get_url(lib3270_get_default_session_handle())));
  209 + }
  210 +
  211 + static void process_input(pipe_source *source, DWORD G_GNUC_UNUSED(cbRead))
  212 + {
  213 + const struct hllapi_packet_query * query = ((struct hllapi_packet_query *) source->buffer);
  214 +
  215 + trace("%s id=%d",__FUNCTION__,query->packet_id);
  216 +
  217 + switch(query->packet_id)
  218 + {
  219 + case HLLAPI_PACKET_CONNECT:
  220 + send_result(source,lib3270_reconnect( lib3270_get_default_session_handle(),
  221 + ((struct hllapi_packet_connect *) source->buffer)->wait));
  222 + break;
  223 +
  224 + case HLLAPI_PACKET_CONNECT_URL:
  225 + send_result(source,lib3270_connect_url(lib3270_get_default_session_handle(),(const char *) (query+1),0));
  226 + break;
  227 +
  228 + case HLLAPI_PACKET_SET_HOST:
  229 + send_result(source,lib3270_set_url(lib3270_get_default_session_handle(),
  230 + ((struct hllapi_packet_text *) source->buffer)->text));
  231 + break;
  232 +
  233 + case HLLAPI_PACKET_GET_HOST:
  234 + get_host(source);
  235 + break;
  236 +
  237 + case HLLAPI_PACKET_DISCONNECT:
  238 + send_result(source,lib3270_disconnect(lib3270_get_default_session_handle()));
  239 + break;
  240 +
  241 + case HLLAPI_PACKET_IS_CONNECTED:
  242 + send_result(source,lib3270_in_tn3270e(lib3270_get_default_session_handle()));
  243 + break;
  244 +
  245 + case HLLAPI_PACKET_IS_READY:
  246 + send_result(source,lib3270_is_ready(lib3270_get_default_session_handle()));
  247 + break;
  248 +
  249 + case HLLAPI_PACKET_ENTER:
  250 + send_result(source,lib3270_enter(lib3270_get_default_session_handle()));
  251 + break;
  252 +
  253 + case HLLAPI_PACKET_PRINT:
  254 + send_result(source,lib3270_print_all(lib3270_get_default_session_handle()));
  255 + break;
  256 +
  257 + case HLLAPI_PACKET_ERASE:
  258 + send_result(source,lib3270_erase(lib3270_get_default_session_handle()));
  259 + break;
  260 +
  261 + case HLLAPI_PACKET_ERASE_EOF:
  262 + send_result(source,lib3270_eraseeof(lib3270_get_default_session_handle()));
  263 + break;
  264 +
  265 + case HLLAPI_PACKET_ERASE_EOL:
  266 + send_result(source,lib3270_eraseeol(lib3270_get_default_session_handle()));
  267 + break;
  268 +
  269 + case HLLAPI_PACKET_ERASE_INPUT:
  270 + send_result(source,lib3270_eraseinput(lib3270_get_default_session_handle()));
  271 + break;
  272 +
  273 + case HLLAPI_PACKET_PFKEY:
  274 + send_result(source,lib3270_pfkey( lib3270_get_default_session_handle(),
  275 + ((struct hllapi_packet_keycode *) source->buffer)->keycode));
  276 + break;
  277 +
  278 + case HLLAPI_PACKET_PAKEY:
  279 + send_result(source,lib3270_pakey( lib3270_get_default_session_handle(),
  280 + ((struct hllapi_packet_keycode *) source->buffer)->keycode));
  281 + break;
  282 +
  283 + case HLLAPI_PACKET_SET_CURSOR_POSITION:
  284 + send_result(source,lib3270_set_cursor_position( lib3270_get_default_session_handle(),
  285 + ((struct hllapi_packet_cursor *) source->buffer)->row,
  286 + ((struct hllapi_packet_cursor *) source->buffer)->col));
  287 + break;
  288 +
  289 + case HLLAPI_PACKET_SET_TEXT_AT:
  290 + send_result(source,lib3270_set_text_at( lib3270_get_default_session_handle(),
  291 + ((struct hllapi_packet_text_at *) source->buffer)->row,
  292 + ((struct hllapi_packet_text_at *) source->buffer)->col,
  293 + (unsigned char *) ((struct hllapi_packet_text_at *) source->buffer)->text));
  294 + break;
  295 +
  296 + case HLLAPI_PACKET_GET_TEXT_AT:
  297 + send_text(source,lib3270_get_string_at( lib3270_get_default_session_handle(),
  298 + ((struct hllapi_packet_at *) source->buffer)->row,
  299 + ((struct hllapi_packet_at *) source->buffer)->col,
  300 + ((struct hllapi_packet_at *) source->buffer)->len,
  301 + ((struct hllapi_packet_at *) source->buffer)->lf));
  302 + break;
  303 +
  304 + case HLLAPI_PACKET_GET_TEXT_AT_OFFSET:
  305 + send_text(source,lib3270_get_string_at_address( lib3270_get_default_session_handle(),
  306 + ((struct hllapi_packet_query_offset *) source->buffer)->addr,
  307 + ((struct hllapi_packet_query_offset *) source->buffer)->len,
  308 + ((struct hllapi_packet_query_offset *) source->buffer)->lf));
  309 + break;
  310 +
  311 + case HLLAPI_PACKET_CMP_TEXT_AT:
  312 + send_result(source,lib3270_cmp_text_at( lib3270_get_default_session_handle(),
  313 + ((struct hllapi_packet_text_at *) source->buffer)->row,
  314 + ((struct hllapi_packet_text_at *) source->buffer)->col,
  315 + ((struct hllapi_packet_text_at *) source->buffer)->text,
  316 + ((struct hllapi_packet_text_at *) source->buffer)->lf));
  317 + break;
  318 +
  319 + case HLLAPI_PACKET_INPUT_STRING:
  320 + send_result(source,lib3270_input_string(lib3270_get_default_session_handle(),
  321 + (unsigned char *) ((struct hllapi_packet_text *) source->buffer)->text));
  322 + break;
  323 +
  324 + case HLLAPI_PACKET_EMULATE_INPUT:
  325 + send_result(source,lib3270_emulate_input(lib3270_get_default_session_handle(),
  326 + (const char *) ((struct hllapi_packet_emulate_input *) source->buffer)->text,
  327 + (int) ((struct hllapi_packet_emulate_input *) source->buffer)->len,
  328 + (int) ((struct hllapi_packet_emulate_input *) source->buffer)->pasting));
  329 + break;
  330 +
  331 + case HLLAPI_PACKET_SET_CURSOR:
  332 + send_result(source,lib3270_set_cursor_address(lib3270_get_default_session_handle(),
  333 + ((struct hllapi_packet_addr *) source->buffer)->addr));
  334 + break;
  335 +
  336 + case HLLAPI_PACKET_GET_CURSOR:
  337 + send_result(source,lib3270_get_cursor_address(lib3270_get_default_session_handle()));
  338 + break;
  339 +
  340 + case HLLAPI_PACKET_GET_WIDTH:
  341 + send_result(source,lib3270_get_width(lib3270_get_default_session_handle()));
  342 + break;
  343 +
  344 + case HLLAPI_PACKET_GET_HEIGHT:
  345 + send_result(source,lib3270_get_height(lib3270_get_default_session_handle()));
  346 + break;
  347 +
  348 + case HLLAPI_PACKET_GET_LENGTH:
  349 + send_result(source,lib3270_get_length(lib3270_get_default_session_handle()));
  350 + break;
  351 +
  352 + case HLLAPI_PACKET_GET_PROGRAM_MESSAGE:
  353 + send_result(source,lib3270_get_program_message(lib3270_get_default_session_handle()));
  354 + break;
  355 +
  356 + case HLLAPI_PACKET_GET_SSL_STATE:
  357 + send_result(source,lib3270_get_secure(lib3270_get_default_session_handle()));
  358 + break;
  359 +
  360 + case HLLAPI_PACKET_SET_UNLOCK_DELAY:
  361 + lib3270_set_unlock_delay(lib3270_get_default_session_handle(),(unsigned short) ((struct hllapi_packet_set_int *) source->buffer)->value);
  362 + send_result(source,0);
  363 + break;
  364 +
  365 + case HLLAPI_PACKET_SET_TOGGLE:
  366 + send_result(source,lib3270_set_toggle(lib3270_get_default_session_handle(),
  367 + (LIB3270_TOGGLE) ((struct hllapi_packet_set *) source->buffer)->id,
  368 + ((struct hllapi_packet_set *) source->buffer)->value));
  369 + break;
  370 +
  371 + case HLLAPI_PACKET_FIELD_START:
  372 + send_result(source,lib3270_get_field_start(lib3270_get_default_session_handle(),
  373 + ((struct hllapi_packet_addr *) source->buffer)->addr));
  374 + break;
  375 +
  376 +
  377 + case HLLAPI_PACKET_FIELD_LEN:
  378 + send_result(source,lib3270_get_field_len(lib3270_get_default_session_handle(),
  379 + ((struct hllapi_packet_addr *) source->buffer)->addr));
  380 + break;
  381 +
  382 + case HLLAPI_PACKET_NEXT_UNPROTECTED:
  383 + send_result(source,lib3270_get_next_unprotected(lib3270_get_default_session_handle(),
  384 + ((struct hllapi_packet_addr *) source->buffer)->addr));
  385 + break;
  386 +
  387 + case HLLAPI_PACKET_IS_PROTECTED:
  388 + send_result(source,lib3270_get_is_protected(lib3270_get_default_session_handle(),
  389 + ((struct hllapi_packet_addr *) source->buffer)->addr));
  390 + break;
  391 +
  392 + case HLLAPI_PACKET_IS_PROTECTED_AT:
  393 + send_result(source,lib3270_get_is_protected_at( lib3270_get_default_session_handle(),
  394 + ((struct hllapi_packet_query_at *) source->buffer)->row,
  395 + ((struct hllapi_packet_query_at *) source->buffer)->col));
  396 + break;
  397 +
  398 + case HLLAPI_PACKET_QUIT:
  399 + gtk_main_quit();
  400 + send_result(source,0);
  401 + break;
  402 +
  403 + case HLLAPI_PACKET_SET_HOST_CHARSET:
  404 + send_result(source,lib3270_set_host_charset( lib3270_get_default_session_handle(),
  405 + (const char *) ((struct hllapi_packet_set_text *) source->buffer)->text));
  406 + break;
  407 +
  408 + case HLLAPI_PACKET_ASC2EBC:
  409 + send_text(source,(char *) lib3270_asc2ebc(
  410 + lib3270_get_default_session_handle(),
  411 + (unsigned char *) ((struct hllapi_packet_set_text *) source->buffer)->text,-1
  412 + ));
  413 + break;
  414 +
  415 + case HLLAPI_PACKET_EBC2ASC:
  416 + send_text(source,(char *) lib3270_ebc2asc(
  417 + lib3270_get_default_session_handle(),
  418 + (unsigned char *) ((struct hllapi_packet_set_text *) source->buffer)->text,-1
  419 + ));
  420 + break;
  421 +
  422 + case HLLAPI_PACKET_FILE_TRANSFER:
  423 + send_result(source,do_file_transfer((struct hllapi_packet_file_transfer *) source));
  424 + break;
  425 +
  426 + case HLLAPI_PACKET_GET_HOST_CHARSET:
  427 + trace("%s","HLLAPI_PACKET_GET_HOST_CHARSET");
  428 + send_text(source,(char *) lib3270_get_host_charset(lib3270_get_default_session_handle()));
  429 + break;
  430 +
  431 + case HLLAPI_PACKET_ACTION:
  432 + send_result(source,lib3270_action(lib3270_get_default_session_handle(),
  433 + (const char *) ((struct hllapi_packet_text *) source->buffer)->text));
  434 + break;
  435 +
  436 +
  437 + default:
  438 + send_result(source, EINVAL);
  439 + g_message("Invalid remote request (id=%d)",source->buffer[0]);
  440 + }
  441 +
  442 + }
  443 +
  444 + static void read_input_pipe(pipe_source *source)
  445 + {
  446 + DWORD cbRead = 0;
  447 +
  448 + if(ReadFile(source->hPipe,source->buffer,PIPE_BUFFER_LENGTH,&cbRead,&source->overlap) && cbRead > 0)
  449 + process_input(source,cbRead);
  450 +
  451 + // The read operation is still pending.
  452 + switch(GetLastError())
  453 + {
  454 + case 0:
  455 + break;
  456 +
  457 + case ERROR_IO_PENDING:
  458 + // trace("%s: PIPE_STATE_PENDING_READ",__FUNCTION__);
  459 + source->state = PIPE_STATE_PENDING_READ;
  460 + break;
  461 +
  462 + case ERROR_PIPE_LISTENING:
  463 + // trace("%s: ERROR_PIPE_LISTENING",__FUNCTION__);
  464 + source->state = PIPE_STATE_READ;
  465 + break;
  466 +
  467 + case ERROR_BROKEN_PIPE:
  468 + trace("%s: ERROR_BROKEN_PIPE",__FUNCTION__);
  469 +
  470 + if(!DisconnectNamedPipe(source->hPipe))
  471 + {
  472 + set_active(FALSE);
  473 + popup_lasterror("%s",_( "Error in DisconnectNamedPipe" ));
  474 + }
  475 + else
  476 + {
  477 + IO_accept(source);
  478 + }
  479 + break;
  480 +
  481 + case ERROR_PIPE_NOT_CONNECTED:
  482 + trace("%s: ERROR_PIPE_NOT_CONNECTED",__FUNCTION__);
  483 + set_active(FALSE);
  484 + break;
  485 +
  486 + default:
  487 + if(source->hPipe != INVALID_HANDLE_VALUE)
  488 + popup_lasterror("%s",_( "Error receiving message from pipe" ) );
  489 + }
  490 +
  491 + }
  492 +
  493 + static gboolean IO_dispatch(GSource *source, GSourceFunc G_GNUC_UNUSED(callback), gpointer G_GNUC_UNUSED(data))
  494 + {
  495 + /*
  496 + * Called to dispatch the event source,
  497 + * after it has returned TRUE in either its prepare or its check function.
  498 + * The dispatch function is passed in a callback function and data.
  499 + * The callback function may be NULL if the source was never connected
  500 + * to a callback using g_source_set_callback(). The dispatch function
  501 + * should call the callback function with user_data and whatever additional
  502 + * parameters are needed for this type of event source.
  503 + */
  504 + BOOL fSuccess;
  505 + DWORD cbRead = 0;
  506 +// DWORD dwErr = 0;
  507 +
  508 + fSuccess = GetOverlappedResult(((pipe_source *) source)->hPipe,&((pipe_source *) source)->overlap,&cbRead,FALSE );
  509 +
  510 + // trace("%s: source=%p data=%p Result=%s cbRead=%d",__FUNCTION__,source,data,fSuccess ? "Success" : "Unsuccess",(int) cbRead);
  511 +
  512 + switch(((pipe_source *) source)->state)
  513 + {
  514 + case PIPE_STATE_WAITING:
  515 + if(fSuccess)
  516 + {
  517 + trace("Pipe connected (cbRet=%d)",(int) cbRead);
  518 + set_active(TRUE);
  519 + ((pipe_source *) source)->state = PIPE_STATE_READ;
  520 + }
  521 + else
  522 + {
  523 + popup_lasterror("%s", _( "Pipe connection failed" ));
  524 + }
  525 + break;
  526 +
  527 + case PIPE_STATE_READ:
  528 + // trace("Reading pipe (cbRead=%d)",(int) cbRead);
  529 + read_input_pipe( (pipe_source *) source);
  530 + break;
  531 +
  532 + case PIPE_STATE_PENDING_READ:
  533 + if(fSuccess && cbRead > 0)
  534 + process_input((pipe_source *) source,cbRead);
  535 + ((pipe_source *) source)->state = PIPE_STATE_READ;
  536 + break;
  537 +
  538 + case PIPE_STATE_UNDEFINED:
  539 + break;
  540 +
  541 +//#ifdef DEBUG
  542 +// default:
  543 +// trace("%s: source=%p data=%p Unexpected mode %d",__FUNCTION__,source,data,((pipe_source *) source)->state);
  544 +//#endif
  545 + }
  546 +
  547 + return TRUE;
  548 + }
  549 +
  550 + static void IO_finalize(GSource *source)
  551 + {
  552 +// trace("%s: source=%p",__FUNCTION__,source);
  553 +
  554 + if( ((pipe_source *) source)->hPipe != INVALID_HANDLE_VALUE)
  555 + {
  556 + CloseHandle(((pipe_source *) source)->hPipe);
  557 + ((pipe_source *) source)->hPipe = INVALID_HANDLE_VALUE;
  558 + }
  559 +
  560 + }
  561 +
  562 + static gboolean IO_closure(gpointer G_GNUC_UNUSED(data))
  563 + {
  564 + return 0;
  565 + }
  566 +
  567 + void popup_lasterror(const gchar *fmt, ...)
  568 + {
  569 + char buffer[4096];
  570 + va_list arg_ptr;
  571 + int sz;
  572 + DWORD errcode = GetLastError();
  573 + char *ptr;
  574 + LPVOID lpMsgBuf = 0;
  575 +
  576 + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errcode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL);
  577 +
  578 + for(ptr= (char *) lpMsgBuf;*ptr && *ptr != '\n';ptr++);
  579 + *ptr = 0;
  580 +
  581 + va_start(arg_ptr, fmt);
  582 + vsnprintf(buffer,4095,fmt,arg_ptr);
  583 + va_end(arg_ptr);
  584 +
  585 + sz = strlen(buffer);
  586 + snprintf(buffer+sz,4096-sz,": %s\n(rc=%d)",lpMsgBuf,(int) errcode);
  587 +
  588 + printf("%s\n",buffer);
  589 +
  590 +#ifdef DEBUG
  591 + fprintf(stderr,"%s\n",buffer);
  592 + fflush(stderr);
  593 +#endif
  594 +
  595 + LocalFree(lpMsgBuf);
  596 + }
  597 +
  598 + LIB3270_EXPORT int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal)
  599 + {
  600 + char id;
  601 + const gchar * name = "pw3270";
  602 +
  603 + for(id='A';id < 'Z';id++)
  604 + {
  605 + gchar * pipename = g_strdup_printf("\\\\.\\pipe\\%s_%c",name,id);
  606 + gchar * ptr;
  607 + HANDLE hPipe;
  608 +
  609 + for(ptr=pipename;*ptr;ptr++)
  610 + *ptr = g_ascii_tolower(*ptr);
  611 +
  612 + hPipe = CreateNamedPipe( TEXT(pipename), // pipe name
  613 + PIPE_ACCESS_DUPLEX | // read/write access
  614 + FILE_FLAG_OVERLAPPED, // overlapped mode
  615 + PIPE_TYPE_MESSAGE | // pipe type
  616 + PIPE_READMODE_MESSAGE | // pipe mode
  617 + PIPE_WAIT, // blocking mode
  618 + 1, // number of instances
  619 + PIPE_BUFFER_LENGTH, // output buffer size
  620 + PIPE_BUFFER_LENGTH, // input buffer size
  621 + NMPWAIT_USE_DEFAULT_WAIT, // client time-out
  622 + NULL); // default security attributes
  623 +
  624 + trace("%s = %p",pipename,hPipe);
  625 + g_free(pipename);
  626 +
  627 + if(hPipe != INVALID_HANDLE_VALUE)
  628 + {
  629 + static GSourceFuncs pipe_source_funcs =
  630 + {
  631 + IO_prepare,
  632 + IO_check,
  633 + IO_dispatch,
  634 + IO_finalize,
  635 + IO_closure,
  636 + NULL
  637 + };
  638 + pipe_source * source;
  639 + gchar * session = g_strdup_printf("%s:%c",name,id);
  640 +
  641 + // pw3270_set_session_name(window,session);
  642 + v3270_set_session_name(terminal,session);
  643 +
  644 + g_free(session);
  645 +
  646 + source = (pipe_source *) g_source_new(&pipe_source_funcs,sizeof(pipe_source));
  647 +
  648 + source->hPipe = hPipe;
  649 + source->state = PIPE_STATE_WAITING;
  650 + source->overlap.hEvent = CreateEvent( NULL,TRUE,TRUE,NULL);
  651 +
  652 + g_source_attach((GSource *) source,NULL);
  653 + IO_accept(source);
  654 +
  655 + return 0;
  656 + }
  657 +
  658 + }
  659 +
  660 + popup_lasterror( "%s", _( "Can´t create remote control pipe" ));
  661 +
  662 + return -1;
  663 + }
  664 +
  665 + LIB3270_EXPORT int pw3270_plugin_stop(GtkWidget *window, GtkWidget *terminal)
  666 + {
  667 +
  668 + return 0;
  669 + }
  670 +
  671 + G_GNUC_INTERNAL void set_active(gboolean on)
  672 + {
  673 + trace("%s(%s)",__FUNCTION__,on ? "Active" : "Inactive");
  674 + // v3270_set_script(v3270_get_default_widget(),'H');
  675 + }
src/ipc3270c/windows/private.h 0 → 100644
@@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
  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., 59 Temple
  19 + * Place, Suite 330, Boston, MA, 02111-1307, USA
  20 + *
  21 + * Este programa está nomeado como -e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 + #include <config.h>
  31 + #define ENABLE_NLS
  32 + #define GETTEXT_PACKAGE PACKAGE_NAME
  33 +
  34 + #include <libintl.h>
  35 + #include <glib/gi18n.h>
  36 + #include <gtk/gtk.h>
  37 +
  38 + #include <lib3270.h>
  39 + #include <lib3270/log.h>
  40 + #include <pw3270.h>
  41 + #include <pw3270/hllapi.h>
  42 +
  43 + #include <windows.h>
  44 +
  45 + #define PIPE_BUFFER_LENGTH HLLAPI_MAXLENGTH+30
  46 +
  47 + G_GNUC_INTERNAL void popup_lasterror(const gchar *fmt, ...);
  48 + G_GNUC_INTERNAL void set_active(gboolean on);
  49 +
  50 +
src/ipc3270c/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/plugin/linux/daemon.h
@@ -1,46 +0,0 @@ @@ -1,46 +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 daemon.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 - * licinio@bb.com.br (Licínio Luis Branco)  
28 - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)  
29 - *  
30 - * Referencias:  
31 - *  
32 - * https://live.gnome.org/DBusGlibBindings  
33 - *  
34 - */  
35 -  
36 - #include "service.h"  
37 -  
38 -/*---[ Globals ]---------------------------------------------------------------------------------*/  
39 -  
40 - G_GNUC_INTERNAL GMainLoop * main_loop;  
41 -  
42 -  
43 -/*---[ Prototipes ]------------------------------------------------------------------------------*/  
44 -  
45 - G_GNUC_INTERNAL void pw3270_dbus_register_io_handlers(void);  
46 -  
src/plugin/linux/globals.h
@@ -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 globals.h 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 - * licinio@bb.com.br (Licínio Luis Branco)  
28 - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)  
29 - *  
30 - */  
31 -  
32 -#ifndef PW3270_DBUS_GLOBALS_H_INCLUDED  
33 -  
34 - #define PW3270_DBUS_GLOBALS_H_INCLUDED 1  
35 -  
36 - #include <libintl.h>  
37 - #include <glib/gi18n.h>  
38 -  
39 - #include <errno.h>  
40 - #include <lib3270.h>  
41 - #include <lib3270/log.h>  
42 - #include <glib.h>  
43 -  
44 - //  
45 - // Disabling warning on unused-function defined in dbus-glib-bindings.h  
46 - // warning: 'org_freedesktop_DBus_reload_config' defined but not used [-Wunused-function] ...  
47 - //  
48 - #pragma GCC diagnostic ignored "-Wunused-function"  
49 -  
50 - #include <dbus/dbus-glib.h>  
51 - #include <dbus/dbus-glib-bindings.h>  
52 - #include <dbus/dbus-glib-lowlevel.h>  
53 -  
54 - #define ERROR_DOMAIN g_quark_from_static_string("pw3270DBUS")  
55 -  
56 - G_GNUC_INTERNAL gpointer pw3270_dbus_register_object (DBusGConnection *connection,DBusGProxy *proxy,GType object_type,const DBusGObjectInfo *info,const gchar *path);  
57 -  
58 -  
59 -#endif // PW3270_DBUS_GLOBALS_H_INCLUDED  
src/plugin/linux/gobject.c
@@ -1,620 +0,0 @@ @@ -1,620 +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 - * licinio@bb.com.br (Licínio Luis Branco)  
28 - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)  
29 - *  
30 - * Referencias:  
31 - *  
32 - * https://live.gnome.org/DBusGlibBindings  
33 - *  
34 - */  
35 -  
36 -#include <glib.h>  
37 -#include <gtk/gtk.h>  
38 -#include <dbus/dbus.h>  
39 -#include <dbus/dbus-glib-lowlevel.h>  
40 -#include <dbus/dbus-glib.h>  
41 -  
42 -#include <config.h>  
43 -#include <lib3270.h>  
44 -#include <pw3270.h>  
45 -#include <v3270.h>  
46 -#include <lib3270/actions.h>  
47 -#include <lib3270/charset.h>  
48 -  
49 -#include "service.h"  
50 -  
51 -/*---[ Globals ]---------------------------------------------------------------------------------*/  
52 -  
53 -  
54 -/*---[ Implement ]-------------------------------------------------------------------------------*/  
55 -  
56 -G_DEFINE_TYPE(PW3270Dbus, pw3270_dbus, G_TYPE_OBJECT)  
57 -  
58 -static void pw3270_dbus_finalize(GObject *object)  
59 -{  
60 - G_OBJECT_CLASS(pw3270_dbus_parent_class)->finalize (object);  
61 -}  
62 -  
63 -  
64 -static void pw3270_dbus_class_init(PW3270DbusClass *klass)  
65 -{  
66 - GObjectClass *object_class;  
67 - object_class = G_OBJECT_CLASS (klass);  
68 - object_class->finalize = pw3270_dbus_finalize;  
69 - debug("%s",__FUNCTION__);  
70 -}  
71 -  
72 -static void pw3270_dbus_init(PW3270Dbus *object)  
73 -{  
74 - debug("%s(%p)",__FUNCTION__,object);  
75 -}  
76 -  
77 -PW3270Dbus * pw3270_dbus_new(void)  
78 -{  
79 - return (PW3270Dbus *) g_object_new(PW3270_TYPE_DBUS, NULL);  
80 -}  
81 -  
82 -void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context)  
83 -{  
84 - debug("%s object=%p context=%p",__FUNCTION__,object,context);  
85 - dbus_g_method_return(context,lib3270_get_revision());  
86 -}  
87 -  
88 -void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context)  
89 -{  
90 - H3270 *hSession = pw3270_dbus_get_session_handle(PW3270_DBUS(object));  
91 -  
92 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
93 -  
94 - if(uri && *uri)  
95 - {  
96 - lib3270_set_url(hSession,uri);  
97 - g_message("Connecting to \"%s\" by remote request",lib3270_get_url(hSession));  
98 - }  
99 - else  
100 - {  
101 - g_message("%s","Connecting by remote request");  
102 - }  
103 -  
104 - dbus_g_method_return(context,lib3270_reconnect(hSession,0));  
105 -}  
106 -  
107 -void pw3270_dbus_set_ur_l(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context)  
108 -{  
109 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
110 -  
111 - g_message("Changing host to \"%s\" by remote request",uri);  
112 -  
113 - dbus_g_method_return(context,lib3270_set_url(pw3270_dbus_get_session_handle(PW3270_DBUS(object)),uri) != 0);  
114 -}  
115 -  
116 -void pw3270_dbus_get_ur_l(PW3270Dbus *object, DBusGMethodInvocation *context)  
117 -{  
118 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
119 - dbus_g_method_return(context,lib3270_get_url(pw3270_dbus_get_session_handle(PW3270_DBUS(object))));  
120 -}  
121 -  
122 -  
123 -void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context)  
124 -{  
125 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
126 -  
127 - g_message("Disconnecting by remote request");  
128 - lib3270_disconnect(pw3270_dbus_get_session_handle(object));  
129 - dbus_g_method_return(context,0);  
130 -}  
131 -  
132 -void pw3270_dbus_get_message_id(PW3270Dbus *object, DBusGMethodInvocation *context)  
133 -{  
134 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
135 - dbus_g_method_return(context,lib3270_get_program_message(pw3270_dbus_get_session_handle(object)));  
136 -}  
137 -  
138 -void pw3270_dbus_get_connection_state(PW3270Dbus *object, DBusGMethodInvocation *context)  
139 -{  
140 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
141 - dbus_g_method_return(context,lib3270_get_connection_state(pw3270_dbus_get_session_handle(object)));  
142 -}  
143 -  
144 -void pw3270_dbus_get_secure_state(PW3270Dbus *object, DBusGMethodInvocation *context)  
145 -{  
146 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
147 - dbus_g_method_return(context,lib3270_get_secure(pw3270_dbus_get_session_handle(object)));  
148 -}  
149 -  
150 -GError * pw3270_dbus_get_error_from_errno(int code)  
151 -{  
152 - return g_error_new(ERROR_DOMAIN,code,"%s",g_strerror(code));  
153 -}  
154 -  
155 -int pw3270_dbus_check_valid_state(PW3270Dbus *object, DBusGMethodInvocation *context)  
156 -{  
157 - H3270 * hSession = pw3270_dbus_get_session_handle(object);  
158 - GError * error = NULL;  
159 -  
160 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
161 -  
162 - if(!lib3270_is_connected(hSession))  
163 - {  
164 - error = pw3270_dbus_get_error_from_errno(ENOTCONN);  
165 - }  
166 - else  
167 - {  
168 - LIB3270_MESSAGE state = lib3270_get_program_message(hSession);  
169 -  
170 - switch(state)  
171 - {  
172 - case LIB3270_MESSAGE_NONE:  
173 - return 0;  
174 -  
175 - case LIB3270_MESSAGE_DISCONNECTED:  
176 - error = pw3270_dbus_get_error_from_errno(ENOTCONN);  
177 - break;  
178 -  
179 - case LIB3270_MESSAGE_MINUS:  
180 - case LIB3270_MESSAGE_PROTECTED:  
181 - case LIB3270_MESSAGE_NUMERIC:  
182 - case LIB3270_MESSAGE_OVERFLOW:  
183 - case LIB3270_MESSAGE_INHIBIT:  
184 - case LIB3270_MESSAGE_KYBDLOCK:  
185 - case LIB3270_MESSAGE_X:  
186 - error = g_error_new(ERROR_DOMAIN,-1,_( "State %04d can't accept requests" ),state);  
187 - break;  
188 -  
189 - case LIB3270_MESSAGE_SYSWAIT:  
190 - case LIB3270_MESSAGE_TWAIT:  
191 - case LIB3270_MESSAGE_CONNECTED:  
192 - case LIB3270_MESSAGE_AWAITING_FIRST:  
193 - error = pw3270_dbus_get_error_from_errno(EBUSY);  
194 - break;  
195 -  
196 - case LIB3270_MESSAGE_RESOLVING:  
197 - case LIB3270_MESSAGE_CONNECTING:  
198 - error = g_error_new(ERROR_DOMAIN,EINPROGRESS,_( "Connecting to host" ));  
199 - break;  
200 -  
201 - case LIB3270_MESSAGE_USER:  
202 - error = g_error_new(ERROR_DOMAIN,-1,_( "Unexpected state %04d" ),state);  
203 - }  
204 - }  
205 -  
206 - if(error)  
207 - {  
208 - dbus_g_method_return_error(context,error);  
209 - g_error_free(error);  
210 - return -1;  
211 - }  
212 -  
213 - return 0;  
214 -}  
215 -  
216 -void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *context)  
217 -{  
218 - char * text;  
219 - gchar * utftext;  
220 - H3270 * hSession = pw3270_dbus_get_session_handle(object);  
221 -  
222 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
223 -  
224 - if(pw3270_dbus_check_valid_state(object,context))  
225 - return;  
226 -  
227 - text = lib3270_get_string_at_address(hSession,0,-1,'\n');  
228 -  
229 - utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL);  
230 -  
231 - lib3270_free(text);  
232 -  
233 - dbus_g_method_return(context,utftext);  
234 -  
235 - g_free(utftext);  
236 -  
237 -}  
238 -  
239 -void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context)  
240 -{  
241 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
242 - if(pw3270_dbus_check_valid_state(object,context))  
243 - return;  
244 - dbus_g_method_return(context,lib3270_enter(pw3270_dbus_get_session_handle(object)));  
245 -}  
246 -  
247 -void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *utftext, DBusGMethodInvocation *context)  
248 -{  
249 - gchar * text;  
250 - H3270 * hSession = pw3270_dbus_get_session_handle(object);  
251 -  
252 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
253 - if(pw3270_dbus_check_valid_state(object,context))  
254 - return;  
255 -  
256 - text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL);  
257 -  
258 - int sz = lib3270_set_string_at(hSession,row,col,(const unsigned char *) text);  
259 -  
260 - trace("%s returns %d",__FUNCTION__,sz);  
261 - dbus_g_method_return(context,sz);  
262 -  
263 - g_free(text);  
264 -}  
265 -  
266 -void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context)  
267 -{  
268 - gchar * text;  
269 - H3270 * hSession = pw3270_dbus_get_session_handle(object);  
270 -  
271 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
272 - if(pw3270_dbus_check_valid_state(object,context))  
273 - return;  
274 -  
275 - text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL);  
276 -  
277 - dbus_g_method_return(context,lib3270_emulate_input(hSession,(const char *) text,-1,1));  
278 -  
279 - g_free(text);  
280 -}  
281 -  
282 -  
283 -void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, char lf, DBusGMethodInvocation *context)  
284 -{  
285 - gchar * text;  
286 - H3270 * hSession = pw3270_dbus_get_session_handle(object);  
287 -  
288 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
289 - if(pw3270_dbus_check_valid_state(object,context))  
290 - return;  
291 -  
292 - text = lib3270_get_string_at(hSession, row, col, len, lf);  
293 - if(!text)  
294 - {  
295 - GError *error = pw3270_dbus_get_error_from_errno(errno);  
296 - dbus_g_method_return_error(context,error);  
297 - g_error_free(error);  
298 - }  
299 - else  
300 - {  
301 - gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL);  
302 -  
303 - lib3270_free(text);  
304 -  
305 - dbus_g_method_return(context,utftext);  
306 -  
307 - g_free(utftext);  
308 - }  
309 - }  
310 -  
311 - void pw3270_dbus_get_text(PW3270Dbus *object, int offset, int len, char lf, DBusGMethodInvocation *context)  
312 - {  
313 - gchar * text;  
314 - H3270 * hSession = pw3270_dbus_get_session_handle(object);  
315 -  
316 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
317 - if(pw3270_dbus_check_valid_state(object,context))  
318 - return;  
319 -  
320 - if(len < 0) {  
321 - len = lib3270_get_length(hSession);  
322 - }  
323 -  
324 - text = lib3270_get_string_at_address(hSession,offset,len,lf);  
325 - if(!text)  
326 - {  
327 - GError *error = pw3270_dbus_get_error_from_errno(errno);  
328 - dbus_g_method_return_error(context,error);  
329 - g_error_free(error);  
330 - }  
331 - else  
332 - {  
333 - gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL);  
334 -  
335 - lib3270_free(text);  
336 -  
337 - debug("\n%s\n",utftext);  
338 -  
339 - dbus_g_method_return(context,utftext);  
340 -  
341 - g_free(utftext);  
342 - }  
343 -  
344 - }  
345 -  
346 - void pw3270_dbus_is_connected(PW3270Dbus *object, DBusGMethodInvocation *context)  
347 - {  
348 - trace("%s object=%p context=%p connected=%s",__FUNCTION__,object,context, lib3270_is_connected(pw3270_dbus_get_session_handle(object)) ? "Yes" : "No");  
349 - dbus_g_method_return(context,lib3270_is_connected(pw3270_dbus_get_session_handle(object)));  
350 - }  
351 -  
352 - void pw3270_dbus_is_ready(PW3270Dbus *object, DBusGMethodInvocation *context)  
353 - {  
354 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
355 - dbus_g_method_return(context,lib3270_is_ready(pw3270_dbus_get_session_handle(object)));  
356 - }  
357 -  
358 - void pw3270_dbus_in_tn3270_e(PW3270Dbus *object, DBusGMethodInvocation *context)  
359 - {  
360 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
361 - dbus_g_method_return(context,lib3270_in_tn3270e(pw3270_dbus_get_session_handle(object)));  
362 - }  
363 -  
364 - void pw3270_dbus_wait_for_ready(PW3270Dbus *object, int timeout, DBusGMethodInvocation *context)  
365 - {  
366 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
367 - dbus_g_method_return(context,lib3270_wait_for_ready(pw3270_dbus_get_session_handle(object),timeout));  
368 - }  
369 -  
370 - void pw3270_dbus_set_cursor_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context)  
371 - {  
372 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
373 - dbus_g_method_return(context,lib3270_set_cursor_position(pw3270_dbus_get_session_handle(object),row,col));  
374 - }  
375 -  
376 - void pw3270_dbus_set_cursor_address(PW3270Dbus *object, int addr, DBusGMethodInvocation *context)  
377 - {  
378 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
379 - dbus_g_method_return(context,lib3270_set_cursor_address(pw3270_dbus_get_session_handle(object),addr));  
380 - }  
381 -  
382 - void pw3270_dbus_get_cursor_address(PW3270Dbus *object, DBusGMethodInvocation *context)  
383 - {  
384 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
385 - dbus_g_method_return(context,lib3270_get_cursor_address(pw3270_dbus_get_session_handle(object)));  
386 - }  
387 -  
388 - void pw3270_dbus_get_screen_width(PW3270Dbus *object, DBusGMethodInvocation *context)  
389 - {  
390 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
391 - dbus_g_method_return(context,lib3270_get_width(pw3270_dbus_get_session_handle(object)));  
392 - }  
393 -  
394 - void pw3270_dbus_get_screen_height(PW3270Dbus *object, DBusGMethodInvocation *context)  
395 - {  
396 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
397 - dbus_g_method_return(context,lib3270_get_height(pw3270_dbus_get_session_handle(object)));  
398 - }  
399 -  
400 - void pw3270_dbus_get_screen_length(PW3270Dbus *object, DBusGMethodInvocation *context)  
401 - {  
402 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
403 - dbus_g_method_return(context,lib3270_get_width(pw3270_dbus_get_session_handle(object)));  
404 - }  
405 -  
406 - void pw3270_dbus_set_toggle(PW3270Dbus *object, int id, int value, DBusGMethodInvocation *context)  
407 - {  
408 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
409 - dbus_g_method_return(context,lib3270_set_toggle(pw3270_dbus_get_session_handle(object),(LIB3270_TOGGLE) id,value));  
410 - }  
411 -  
412 -void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *utftext, char lf, DBusGMethodInvocation *context)  
413 -{  
414 - gchar * text;  
415 - H3270 * hSession = pw3270_dbus_get_session_handle(object);  
416 -  
417 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
418 - if(pw3270_dbus_check_valid_state(object,context))  
419 - return;  
420 -  
421 - text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL);  
422 -  
423 - dbus_g_method_return(context,lib3270_cmp_text_at(hSession,row,col,text,lf));  
424 -  
425 - g_free(text);  
426 -}  
427 -  
428 -void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context)  
429 -{  
430 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
431 - if(pw3270_dbus_check_valid_state(object,context))  
432 - return;  
433 - dbus_g_method_return(context,lib3270_pfkey(pw3270_dbus_get_session_handle(object),key));  
434 -}  
435 -  
436 -void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context)  
437 -{  
438 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
439 - if(pw3270_dbus_check_valid_state(object,context))  
440 - return;  
441 - dbus_g_method_return(context,lib3270_pakey(pw3270_dbus_get_session_handle(object),key));  
442 -}  
443 -  
444 - void pw3270_dbus_get_field_start(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context)  
445 - {  
446 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
447 - dbus_g_method_return(context,lib3270_get_field_start(pw3270_dbus_get_session_handle(object),baddr));  
448 - }  
449 -  
450 - void pw3270_dbus_get_field_length(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context)  
451 - {  
452 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
453 - dbus_g_method_return(context,lib3270_get_field_len(pw3270_dbus_get_session_handle(object),baddr));  
454 - }  
455 -  
456 - void pw3270_dbus_get_next_unprotected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context)  
457 - {  
458 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
459 - dbus_g_method_return(context,lib3270_get_next_unprotected(pw3270_dbus_get_session_handle(object),baddr));  
460 - }  
461 -  
462 - void pw3270_dbus_get_is_protected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context)  
463 - {  
464 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
465 - dbus_g_method_return(context,lib3270_get_is_protected(pw3270_dbus_get_session_handle(object),baddr));  
466 - }  
467 -  
468 - void pw3270_dbus_get_is_protected_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context)  
469 - {  
470 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
471 - dbus_g_method_return(context,lib3270_get_is_protected_at(pw3270_dbus_get_session_handle(object),row,col));  
472 - }  
473 -  
474 - void pw3270_dbus_action(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context)  
475 - {  
476 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
477 - dbus_g_method_return(context,lib3270_action(pw3270_dbus_get_session_handle(object),text));  
478 - }  
479 -  
480 - void pw3270_dbus_get_clipboard(PW3270Dbus *object, DBusGMethodInvocation *context)  
481 - {  
482 - gchar *text;  
483 -  
484 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
485 -  
486 - if(pw3270_dbus_check_valid_state(object,context))  
487 - return;  
488 -  
489 - text = gtk_clipboard_wait_for_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD));  
490 -  
491 - trace("Clipboard:\n%s\n",text);  
492 -  
493 - if(!text)  
494 - {  
495 - GError *error = pw3270_dbus_get_error_from_errno(ENOENT);  
496 - dbus_g_method_return_error(context,error);  
497 - g_error_free(error);  
498 - }  
499 - else  
500 - {  
501 - dbus_g_method_return(context,text);  
502 - g_free(text);  
503 - }  
504 -}  
505 -  
506 -void pw3270_dbus_set_clipboard(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context)  
507 -{  
508 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
509 - gtk_clipboard_set_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD),(gchar *) text, -1);  
510 - dbus_g_method_return(context,0);  
511 -}  
512 -  
513 -void pw3270_dbus_set_script(PW3270Dbus *object, const gchar G_GNUC_UNUSED(*text), int mode, DBusGMethodInvocation *context)  
514 -{  
515 - GtkWidget *widget = pw3270_get_terminal_widget(NULL);  
516 -  
517 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
518 -  
519 - if(!widget)  
520 - {  
521 - GError *error = pw3270_dbus_get_error_from_errno(EINVAL);  
522 - dbus_g_method_return_error(context,error);  
523 - g_error_free(error);  
524 - return;  
525 - }  
526 -  
527 - dbus_g_method_return(context,v3270_set_script(widget,mode == 0 ? 0 : 'S'));  
528 -}  
529 -  
530 -void pw3270_dbus_show_popup(PW3270Dbus *object, int id, const gchar *title, const gchar *msg, const gchar *text, DBusGMethodInvocation *context)  
531 -{  
532 - lib3270_popup_dialog(pw3270_dbus_get_session_handle(object), (LIB3270_NOTIFY) id , title, msg, "%s", text);  
533 - dbus_g_method_return(context,0);  
534 -}  
535 -  
536 -void pw3270_dbus_get_host_charset(PW3270Dbus *object, DBusGMethodInvocation *context)  
537 -{  
538 - dbus_g_method_return(context,lib3270_get_host_charset(pw3270_dbus_get_session_handle(object)));  
539 -}  
540 -  
541 -void pw3270_dbus_get_display_charset(PW3270Dbus G_GNUC_UNUSED(*object), DBusGMethodInvocation *context)  
542 -{  
543 - // Allways return UTF-8 to avoid double conversion  
544 - dbus_g_method_return(context,"UTF-8");  
545 -}  
546 -  
547 -void pw3270_dbus_set_host_charset(PW3270Dbus *object, const gchar *charset, DBusGMethodInvocation *context)  
548 -{  
549 - dbus_g_method_return(context,lib3270_set_host_charset(pw3270_dbus_get_session_handle(object),charset));  
550 -}  
551 -  
552 -void pw3270_dbus_erase_eof(PW3270Dbus *object, DBusGMethodInvocation *context)  
553 -{  
554 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
555 - dbus_g_method_return(context,lib3270_eraseeof(pw3270_dbus_get_session_handle(object)));  
556 -}  
557 -  
558 -void pw3270_dbus_print(PW3270Dbus *object, DBusGMethodInvocation *context)  
559 -{  
560 - dbus_g_method_return(context,lib3270_print_all(pw3270_dbus_get_session_handle(object)));  
561 -}  
562 -  
563 -void pw3270_dbus_set_unlock_delay(PW3270Dbus *object, int value, DBusGMethodInvocation *context)  
564 -{  
565 - lib3270_set_unlock_delay(pw3270_dbus_get_session_handle(object),(unsigned short) value);  
566 - dbus_g_method_return(context,0);  
567 -}  
568 -  
569 -  
570 -void pw3270_dbus_ebc2asc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context)  
571 -{  
572 - int sz = strlen(from);  
573 -  
574 - if(sz > 0)  
575 - {  
576 - unsigned char buffer[sz+1];  
577 - memcpy(buffer,from,sz);  
578 - dbus_g_method_return(context,lib3270_ebc2asc(pw3270_dbus_get_session_handle(object),buffer,sz));  
579 - return;  
580 - }  
581 -  
582 - dbus_g_method_return(context,"");  
583 -  
584 -}  
585 -  
586 -void pw3270_dbus_asc2ebc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context)  
587 -{  
588 - int sz = strlen(from);  
589 -  
590 - if(sz > 0)  
591 - {  
592 - unsigned char buffer[sz+1];  
593 - memcpy(buffer,from,sz);  
594 - dbus_g_method_return(context,lib3270_asc2ebc(pw3270_dbus_get_session_handle(object),buffer,sz));  
595 - return;  
596 - }  
597 -  
598 - dbus_g_method_return(context,"");  
599 -  
600 -}  
601 -  
602 -void pw3270_dbus_filetransfer(PW3270Dbus *object, const gchar *local, const gchar *remote, int flags, int lrecl, int blksize, int primspace, int secspace, int dft, DBusGMethodInvocation *context)  
603 -{  
604 - /*  
605 - dbus_g_method_return(context,  
606 - v3270_transfer_file(  
607 - v3270_get_default_widget(),  
608 - (LIB3270_FT_OPTION) flags,  
609 - local,  
610 - remote,  
611 - lrecl,  
612 - blksize,  
613 - primspace,  
614 - secspace,  
615 - dft  
616 - ));  
617 - */  
618 - return;  
619 -}  
620 -  
src/plugin/linux/main.c
@@ -1,179 +0,0 @@ @@ -1,179 +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/fbuihuu/samples-dbus/blob/master/dbus-server.c  
26 - *  
27 - * Contatos:  
28 - *  
29 - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
30 - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)  
31 - *  
32 - */  
33 -  
34 -#include <glib.h>  
35 -#include <dbus/dbus.h>  
36 -#include <dbus/dbus-glib-lowlevel.h>  
37 -#include <dbus/dbus-glib.h>  
38 -  
39 -#include <v3270.h>  
40 -#include <pw3270.h>  
41 -#include <pw3270/plugin.h>  
42 -  
43 -#include "service.h"  
44 -#include "dbus-glue.h"  
45 -  
46 -#include <gtk/gtk.h>  
47 -  
48 -/*---[ Globals ]---------------------------------------------------------------------------------*/  
49 -  
50 - static DBusGConnection * connection = NULL;  
51 - static DBusGProxy * proxy = NULL;  
52 - static gchar * service_name = NULL;  
53 -  
54 -  
55 -/*---[ Implement ]-------------------------------------------------------------------------------*/  
56 -  
57 - LIB3270_EXPORT int pw3270_plugin_start(GtkWidget G_GNUC_UNUSED(*window), GtkWidget *terminal)  
58 - {  
59 - GError * error = NULL;  
60 - guint result;  
61 - char session_id = 0;  
62 - char id = 'a';  
63 - const gchar * name = "pw3270";  
64 -  
65 - connection = dbus_g_bus_get_private(DBUS_BUS_SESSION, g_main_context_default(), &error);  
66 - if(error)  
67 - {  
68 - GtkWidget *dialog = gtk_message_dialog_new(  
69 - GTK_WINDOW(window),  
70 - (GtkDialogFlags) (GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT),  
71 - GTK_MESSAGE_ERROR,  
72 - GTK_BUTTONS_OK,  
73 - _( "Can't connect to DBUS server" ));  
74 -  
75 - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message);  
76 -  
77 - g_message("Error \"%s\" getting session dbus",error->message);  
78 -  
79 - g_error_free(error);  
80 -  
81 - gtk_dialog_run(GTK_DIALOG(dialog));  
82 - gtk_widget_destroy(dialog);  
83 -  
84 - return -1;  
85 - }  
86 -  
87 - proxy = dbus_g_proxy_new_for_name(connection,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS);  
88 -  
89 - for(id='a'; id < 'z' && !error && !service_name; id++)  
90 - {  
91 - gboolean has_owner = FALSE;  
92 -  
93 - service_name = g_strdup_printf("br.com.bb.%s.%c",name,(int) id);  
94 -  
95 - org_freedesktop_DBus_name_has_owner(proxy, service_name, &has_owner, NULL);  
96 -  
97 - if(has_owner)  
98 - {  
99 - trace("Service \"%s\" has owner",service_name)  
100 - g_free(service_name);  
101 - service_name = NULL;  
102 - }  
103 - else  
104 - {  
105 - session_id = id;  
106 - g_message("DBUS service name is %s",service_name);  
107 - org_freedesktop_DBus_request_name(proxy, service_name, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error);  
108 - }  
109 - }  
110 -  
111 - if(error)  
112 - {  
113 - GtkWidget *dialog = gtk_message_dialog_new(  
114 - GTK_WINDOW(window),  
115 - (GtkDialogFlags) (GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT),  
116 - GTK_MESSAGE_ERROR,  
117 - GTK_BUTTONS_OK,  
118 - _( "Can't get DBUS object name" ));  
119 -  
120 - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message);  
121 -  
122 - g_message("Error \"%s\" requesting DBUS name",error->message);  
123 -  
124 - g_error_free(error);  
125 -  
126 - gtk_dialog_run(GTK_DIALOG(dialog));  
127 - gtk_widget_destroy(dialog);  
128 -  
129 - return -1;  
130 - }  
131 -  
132 - if(session_id)  
133 - {  
134 - g_autofree gchar * path = g_strdup_printf("/br/com/bb/%s",name);  
135 - g_autofree gchar * session = g_strdup_printf("%s:%c",name,g_ascii_toupper(session_id));  
136 -  
137 - // pw3270_set_session_name(window,session);  
138 - v3270_set_session_name(terminal,session);  
139 -  
140 - g_message("DBUS service path is %s, session name is %s",path,session);  
141 -  
142 - pw3270_dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,path);  
143 -  
144 - }  
145 -  
146 - return 0;  
147 - }  
148 -  
149 - LIB3270_EXPORT int pw3270_plugin_stop(GtkWidget G_GNUC_UNUSED(*window), GtkWidget G_GNUC_UNUSED(*terminal))  
150 - {  
151 - if(proxy)  
152 - {  
153 - debug("%s: Releasing proxy",__FUNCTION__);  
154 - g_object_unref(proxy);  
155 - proxy = NULL;  
156 - }  
157 -  
158 - if(service_name)  
159 - {  
160 - g_free(service_name);  
161 - service_name = NULL;  
162 - }  
163 - return 0;  
164 - }  
165 -  
166 - void pw3270_dbus_quit(PW3270Dbus G_GNUC_UNUSED(*object), DBusGMethodInvocation *context)  
167 - {  
168 - gtk_main_quit();  
169 - dbus_g_method_return(context,0);  
170 - }  
171 -  
172 - H3270 * pw3270_dbus_get_session_handle(PW3270Dbus G_GNUC_UNUSED(*object))  
173 - {  
174 - debug("%s=%p",__FUNCTION__,lib3270_get_default_session_handle());  
175 - return lib3270_get_default_session_handle();  
176 - }  
177 -  
178 -  
179 -  
src/plugin/linux/misc.c
@@ -1,47 +0,0 @@ @@ -1,47 +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 misc.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 - * licinio@bb.com.br (Licínio Luis Branco)  
28 - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)  
29 - *  
30 - * Referencias:  
31 - *  
32 - * https://live.gnome.org/DBusGlibBindings  
33 - *  
34 - */  
35 -  
36 -#include "globals.h"  
37 -  
38 -/*---[ Implement ]-------------------------------------------------------------------------------*/  
39 -  
40 -gpointer pw3270_dbus_register_object(DBusGConnection *connection,DBusGProxy G_GNUC_UNUSED(*proxy),GType object_type,const DBusGObjectInfo *info,const gchar *path)  
41 -{  
42 - GObject *object = G_OBJECT(g_object_new(object_type, NULL));  
43 - dbus_g_object_type_install_info (object_type, info);  
44 - dbus_g_connection_register_g_object (connection, path, object);  
45 - return object;  
46 -}  
47 -  
src/plugin/linux/service.h
@@ -1,138 +0,0 @@ @@ -1,138 +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 service.h 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 - * licinio@bb.com.br (Licínio Luis Branco)  
28 - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)  
29 - *  
30 - */  
31 -  
32 -#ifndef _PW3270_DBUS_SERVICE_H  
33 -  
34 - #define _PW3270_DBUS_SERVICE_H 1  
35 -  
36 - #define ENABLE_NLS  
37 - #define GETTEXT_PACKAGE PACKAGE_NAME  
38 -  
39 - #include "globals.h"  
40 -  
41 - #define PW3270_TYPE_DBUS (pw3270_dbus_get_type ())  
42 - #define PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PW3270_TYPE_DBUS, PW3270Dbus))  
43 - #define PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_DBUS, PW3270DbusClass))  
44 - #define IS_PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PW3270_TYPE_DBUS))  
45 - #define IS_PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_DBUS))  
46 - #define PW3270_DBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_DBUS, PW3270DbusClass))  
47 -  
48 - G_BEGIN_DECLS  
49 -  
50 - typedef struct _PW3270Dbus PW3270Dbus;  
51 - typedef struct _PW3270DbusClass PW3270DbusClass;  
52 -  
53 - struct _PW3270Dbus  
54 - {  
55 - GObject parent;  
56 - };  
57 -  
58 - struct _PW3270DbusClass  
59 - {  
60 - GObjectClass parent;  
61 - };  
62 -  
63 - PW3270Dbus * pw3270_dbus_new (void);  
64 - GType pw3270_dbus_get_type (void);  
65 -  
66 - void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context);  
67 - void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context);  
68 - void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context);  
69 - void pw3270_dbus_get_ur_l(PW3270Dbus *object, DBusGMethodInvocation *context);  
70 - void pw3270_dbus_set_ur_l(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context);  
71 - void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context);  
72 -  
73 - void pw3270_dbus_get_message_id(PW3270Dbus *object, DBusGMethodInvocation *context);  
74 - void pw3270_dbus_get_connection_state(PW3270Dbus *object, DBusGMethodInvocation *context);  
75 - void pw3270_dbus_get_secure_state(PW3270Dbus *object, DBusGMethodInvocation *context);  
76 -  
77 - void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *context);  
78 - H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object);  
79 - GError * pw3270_dbus_get_error_from_errno(int code);  
80 -  
81 - void pw3270_dbus_is_connected(PW3270Dbus *object, DBusGMethodInvocation *context);  
82 - void pw3270_dbus_is_ready(PW3270Dbus *object, DBusGMethodInvocation *context);  
83 - void pw3270_dbus_in_tn3270_e(PW3270Dbus *object, DBusGMethodInvocation *context);  
84 -  
85 - void pw3270_dbus_set_cursor_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context);  
86 - void pw3270_dbus_set_cursor_address(PW3270Dbus *object, int addr, DBusGMethodInvocation *context);  
87 - void pw3270_dbus_get_cursor_address(PW3270Dbus *object, DBusGMethodInvocation *context);  
88 -  
89 - void pw3270_dbus_get_screen_width(PW3270Dbus *object, DBusGMethodInvocation *context);  
90 - void pw3270_dbus_get_screen_height(PW3270Dbus *object, DBusGMethodInvocation *context);  
91 - void pw3270_dbus_get_screen_length(PW3270Dbus *object, DBusGMethodInvocation *context);  
92 -  
93 - void pw3270_dbus_set_toggle(PW3270Dbus *object, int id, int value, DBusGMethodInvocation *context);  
94 -  
95 - void pw3270_dbus_wait_for_ready(PW3270Dbus *object, int timeout, DBusGMethodInvocation *context);  
96 -  
97 - void pw3270_dbus_get_field_start(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context);  
98 - void pw3270_dbus_get_field_length(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context);  
99 - void pw3270_dbus_get_next_unprotected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context);  
100 -  
101 - void pw3270_dbus_get_is_protected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context);  
102 - void pw3270_dbus_get_is_protected_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context);  
103 -  
104 - void pw3270_dbus_set_script(PW3270Dbus *object, const gchar *text, int mode, DBusGMethodInvocation *context);  
105 -  
106 - void pw3270_dbus_show_popup(PW3270Dbus *object, int id, const gchar *title, const gchar *msg, const gchar *text, DBusGMethodInvocation *context);  
107 -  
108 - void pw3270_dbus_action(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context);  
109 -  
110 - // Actions  
111 - void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context);  
112 - void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context);  
113 - void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context);  
114 - void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context);  
115 - void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, char lf, DBusGMethodInvocation *context);  
116 - void pw3270_dbus_get_text(PW3270Dbus *object, int offset, int len, char lf, DBusGMethodInvocation *context);  
117 - void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *text, char lf, DBusGMethodInvocation *context);  
118 - void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context);  
119 -  
120 - void pw3270_dbus_set_clipboard(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context);  
121 - void pw3270_dbus_get_clipboard(PW3270Dbus *object, DBusGMethodInvocation *context);  
122 -  
123 - void pw3270_dbus_get_display_charset(PW3270Dbus *object, DBusGMethodInvocation *context);  
124 - void pw3270_dbus_get_host_charset(PW3270Dbus *object, DBusGMethodInvocation *context);  
125 - void pw3270_dbus_set_host_charset(PW3270Dbus *object, const gchar *charset, DBusGMethodInvocation *context);  
126 - void pw3270_dbus_erase_eof(PW3270Dbus *object, DBusGMethodInvocation *context);  
127 - void pw3270_dbus_print(PW3270Dbus *object, DBusGMethodInvocation *context);  
128 -  
129 - void pw3270_dbus_asc2ebc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context);  
130 - void pw3270_dbus_ebc2asc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context);  
131 -  
132 - void pw3270_dbus_filetransfer(PW3270Dbus *object, const gchar *local, const gchar *remote, int flags, int lrecl, int blksize, int primspace, int secspace, int dft, DBusGMethodInvocation *context);  
133 -  
134 - void pw3270_dbus_set_unlock_delay(PW3270Dbus *object, int value, DBusGMethodInvocation *context);  
135 -  
136 - G_END_DECLS  
137 -  
138 -#endif // _PW3270_DBUS_SERVICE_H  
src/plugin/windows/main.c
@@ -1,675 +0,0 @@ @@ -1,675 +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 o nome G3270.  
5 - *  
6 - * Copyright (C) <2008> <Banco do Brasil S.A.>  
7 - *  
8 - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob  
9 - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela  
10 - * Free Software Foundation.  
11 - *  
12 - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER  
13 - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO  
14 - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para  
15 - * obter mais detalhes.  
16 - *  
17 - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este  
18 - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin  
19 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
20 - *  
21 - * Este programa está nomeado como - e possui - linhas de código.  
22 - *  
23 - * Contatos:  
24 - *  
25 - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
26 - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)  
27 - *  
28 - * Agradecimento:  
29 - *  
30 - * Hélio Passos  
31 - *  
32 - */  
33 -  
34 - #include "private.h"  
35 -  
36 -#ifdef _WIN32  
37 - #include <windows.h>  
38 -#else  
39 - #error HLLAPI is designed for windows.  
40 -#endif // _WIN32  
41 -  
42 - #include <pw3270/plugin.h>  
43 - #include <v3270.h>  
44 - #include <pw3270/ipcpackets.h>  
45 - #include <lib3270/actions.h>  
46 - #include <lib3270/charset.h>  
47 -  
48 -/*--[ Defines ]--------------------------------------------------------------------------------------*/  
49 -  
50 - #pragma pack(1)  
51 -  
52 - enum PIPE_STATE  
53 - {  
54 - PIPE_STATE_WAITING,  
55 - PIPE_STATE_READ,  
56 - PIPE_STATE_PENDING_READ,  
57 - PIPE_STATE_UNDEFINED  
58 - };  
59 -  
60 - typedef struct _pipe_source  
61 - {  
62 - GSource gsrc;  
63 - HANDLE hPipe;  
64 -  
65 - enum PIPE_STATE state;  
66 -  
67 - OVERLAPPED overlap;  
68 - unsigned char buffer[PIPE_BUFFER_LENGTH+1];  
69 - } pipe_source;  
70 -  
71 - #pragma pack()  
72 -  
73 -  
74 -/*--[ Globals ]--------------------------------------------------------------------------------------*/  
75 -  
76 -// static const gchar control_char = '@';  
77 -  
78 -/*--[ Implement ]------------------------------------------------------------------------------------*/  
79 -  
80 - static void IO_accept(pipe_source *source)  
81 - {  
82 - set_active(FALSE);  
83 -  
84 - if(ConnectNamedPipe(source->hPipe,&source->overlap))  
85 - {  
86 - popup_lasterror("%s",_( "Error in ConnectNamedPipe" ));  
87 - return;  
88 - }  
89 -  
90 - switch(GetLastError())  
91 - {  
92 - // The overlapped connection in progress.  
93 - case ERROR_IO_PENDING:  
94 - // trace("%s: ERROR_IO_PENDING",__FUNCTION__);  
95 - source->state = PIPE_STATE_WAITING;  
96 - break;  
97 -  
98 - // Client is already connected, so signal an event.  
99 - case ERROR_PIPE_CONNECTED:  
100 - trace("%s: ERROR_PIPE_CONNECTED",__FUNCTION__);  
101 - set_active(TRUE);  
102 - SetEvent(source->overlap.hEvent);  
103 - break;  
104 -  
105 - // If an error occurs during the connect operation...  
106 - default:  
107 - popup_lasterror("%s", _( "ConnectNamedPipe failed" ));  
108 - }  
109 -  
110 - }  
111 -  
112 - static gboolean IO_prepare(GSource *source, gint *timeout)  
113 - {  
114 - /*  
115 - * Called before all the file descriptors are polled.  
116 - * If the source can determine that it is ready here  
117 - * (without waiting for the results of the poll() call)  
118 - * it should return TRUE.  
119 - *  
120 - * It can also return a timeout_ value which should be the maximum  
121 - * timeout (in milliseconds) which should be passed to the poll() call.  
122 - * The actual timeout used will be -1 if all sources returned -1,  
123 - * or it will be the minimum of all the timeout_ values  
124 - * returned which were >= 0.  
125 - *  
126 - */  
127 - if(WaitForSingleObject(((pipe_source *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)  
128 - return TRUE;  
129 -  
130 - *timeout = 10;  
131 - return FALSE;  
132 - }  
133 -  
134 - static gboolean IO_check(GSource *source)  
135 - {  
136 - /*  
137 - * Called after all the file descriptors are polled.  
138 - * The source should return TRUE if it is ready to be dispatched.  
139 - * Note that some time may have passed since the previous prepare  
140 - * function was called, so the source should be checked again here.  
141 - *  
142 - */  
143 - if(WaitForSingleObject(((pipe_source *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)  
144 - return TRUE;  
145 -  
146 - return FALSE;  
147 - }  
148 -  
149 - static void send_text(pipe_source *source, char *text)  
150 - {  
151 - struct hllapi_packet_text *pkt;  
152 - DWORD szBlock;  
153 - int f;  
154 -  
155 - if(text)  
156 - {  
157 - szBlock = sizeof(struct hllapi_packet_text)+strlen(text);  
158 - pkt = (struct hllapi_packet_text *) g_malloc0(szBlock);  
159 - pkt->packet_id = 0;  
160 - strcpy(pkt->text,text);  
161 - lib3270_free(text);  
162 - }  
163 - else  
164 - {  
165 - szBlock = sizeof(struct hllapi_packet_text);  
166 - pkt = (struct hllapi_packet_text *) g_malloc0(szBlock);  
167 - pkt->packet_id = errno ? errno : -1;  
168 - }  
169 -  
170 - trace("szBlock=%d text=\"%s\"",szBlock, ( (struct hllapi_packet_text *) pkt)->text);  
171 - for(f=0;f< (int) szBlock;f++)  
172 - {  
173 - trace("rsp(%d)= %d \"%s\"",f,* (((char *) pkt)+f),((char *) pkt)+f);  
174 - }  
175 -  
176 - WriteFile(source->hPipe,pkt,szBlock,&szBlock,NULL);  
177 -  
178 - g_free(pkt);  
179 - }  
180 -  
181 - static void send_result(pipe_source *source, int rc)  
182 - {  
183 - struct hllapi_packet_result pkt = { rc };  
184 - DWORD wrote = sizeof(pkt);  
185 - WriteFile(source->hPipe,&pkt,wrote,&wrote,NULL);  
186 - }  
187 -  
188 - static int do_file_transfer(struct hllapi_packet_file_transfer * source)  
189 - {  
190 - /*  
191 - const gchar * local = (const char *) source->text;  
192 - const gchar * remote = (const char *) (local+strlen(local)+1);  
193 -  
194 - return v3270_transfer_file( v3270_get_default_widget(),  
195 - (LIB3270_FT_OPTION) source->options,  
196 - local,  
197 - remote,  
198 - source->lrecl,  
199 - source->blksize,  
200 - source->primspace,  
201 - source->secspace,  
202 - source->dft );  
203 - */  
204 - return EINVAL;  
205 - }  
206 -  
207 - static void get_host(pipe_source *source) {  
208 - send_text(source,strdup(lib3270_get_url(lib3270_get_default_session_handle())));  
209 - }  
210 -  
211 - static void process_input(pipe_source *source, DWORD G_GNUC_UNUSED(cbRead))  
212 - {  
213 - const struct hllapi_packet_query * query = ((struct hllapi_packet_query *) source->buffer);  
214 -  
215 - trace("%s id=%d",__FUNCTION__,query->packet_id);  
216 -  
217 - switch(query->packet_id)  
218 - {  
219 - case HLLAPI_PACKET_CONNECT:  
220 - send_result(source,lib3270_reconnect( lib3270_get_default_session_handle(),  
221 - ((struct hllapi_packet_connect *) source->buffer)->wait));  
222 - break;  
223 -  
224 - case HLLAPI_PACKET_CONNECT_URL:  
225 - send_result(source,lib3270_connect_url(lib3270_get_default_session_handle(),(const char *) (query+1),0));  
226 - break;  
227 -  
228 - case HLLAPI_PACKET_SET_HOST:  
229 - send_result(source,lib3270_set_url(lib3270_get_default_session_handle(),  
230 - ((struct hllapi_packet_text *) source->buffer)->text));  
231 - break;  
232 -  
233 - case HLLAPI_PACKET_GET_HOST:  
234 - get_host(source);  
235 - break;  
236 -  
237 - case HLLAPI_PACKET_DISCONNECT:  
238 - send_result(source,lib3270_disconnect(lib3270_get_default_session_handle()));  
239 - break;  
240 -  
241 - case HLLAPI_PACKET_IS_CONNECTED:  
242 - send_result(source,lib3270_in_tn3270e(lib3270_get_default_session_handle()));  
243 - break;  
244 -  
245 - case HLLAPI_PACKET_IS_READY:  
246 - send_result(source,lib3270_is_ready(lib3270_get_default_session_handle()));  
247 - break;  
248 -  
249 - case HLLAPI_PACKET_ENTER:  
250 - send_result(source,lib3270_enter(lib3270_get_default_session_handle()));  
251 - break;  
252 -  
253 - case HLLAPI_PACKET_PRINT:  
254 - send_result(source,lib3270_print_all(lib3270_get_default_session_handle()));  
255 - break;  
256 -  
257 - case HLLAPI_PACKET_ERASE:  
258 - send_result(source,lib3270_erase(lib3270_get_default_session_handle()));  
259 - break;  
260 -  
261 - case HLLAPI_PACKET_ERASE_EOF:  
262 - send_result(source,lib3270_eraseeof(lib3270_get_default_session_handle()));  
263 - break;  
264 -  
265 - case HLLAPI_PACKET_ERASE_EOL:  
266 - send_result(source,lib3270_eraseeol(lib3270_get_default_session_handle()));  
267 - break;  
268 -  
269 - case HLLAPI_PACKET_ERASE_INPUT:  
270 - send_result(source,lib3270_eraseinput(lib3270_get_default_session_handle()));  
271 - break;  
272 -  
273 - case HLLAPI_PACKET_PFKEY:  
274 - send_result(source,lib3270_pfkey( lib3270_get_default_session_handle(),  
275 - ((struct hllapi_packet_keycode *) source->buffer)->keycode));  
276 - break;  
277 -  
278 - case HLLAPI_PACKET_PAKEY:  
279 - send_result(source,lib3270_pakey( lib3270_get_default_session_handle(),  
280 - ((struct hllapi_packet_keycode *) source->buffer)->keycode));  
281 - break;  
282 -  
283 - case HLLAPI_PACKET_SET_CURSOR_POSITION:  
284 - send_result(source,lib3270_set_cursor_position( lib3270_get_default_session_handle(),  
285 - ((struct hllapi_packet_cursor *) source->buffer)->row,  
286 - ((struct hllapi_packet_cursor *) source->buffer)->col));  
287 - break;  
288 -  
289 - case HLLAPI_PACKET_SET_TEXT_AT:  
290 - send_result(source,lib3270_set_text_at( lib3270_get_default_session_handle(),  
291 - ((struct hllapi_packet_text_at *) source->buffer)->row,  
292 - ((struct hllapi_packet_text_at *) source->buffer)->col,  
293 - (unsigned char *) ((struct hllapi_packet_text_at *) source->buffer)->text));  
294 - break;  
295 -  
296 - case HLLAPI_PACKET_GET_TEXT_AT:  
297 - send_text(source,lib3270_get_string_at( lib3270_get_default_session_handle(),  
298 - ((struct hllapi_packet_at *) source->buffer)->row,  
299 - ((struct hllapi_packet_at *) source->buffer)->col,  
300 - ((struct hllapi_packet_at *) source->buffer)->len,  
301 - ((struct hllapi_packet_at *) source->buffer)->lf));  
302 - break;  
303 -  
304 - case HLLAPI_PACKET_GET_TEXT_AT_OFFSET:  
305 - send_text(source,lib3270_get_string_at_address( lib3270_get_default_session_handle(),  
306 - ((struct hllapi_packet_query_offset *) source->buffer)->addr,  
307 - ((struct hllapi_packet_query_offset *) source->buffer)->len,  
308 - ((struct hllapi_packet_query_offset *) source->buffer)->lf));  
309 - break;  
310 -  
311 - case HLLAPI_PACKET_CMP_TEXT_AT:  
312 - send_result(source,lib3270_cmp_text_at( lib3270_get_default_session_handle(),  
313 - ((struct hllapi_packet_text_at *) source->buffer)->row,  
314 - ((struct hllapi_packet_text_at *) source->buffer)->col,  
315 - ((struct hllapi_packet_text_at *) source->buffer)->text,  
316 - ((struct hllapi_packet_text_at *) source->buffer)->lf));  
317 - break;  
318 -  
319 - case HLLAPI_PACKET_INPUT_STRING:  
320 - send_result(source,lib3270_input_string(lib3270_get_default_session_handle(),  
321 - (unsigned char *) ((struct hllapi_packet_text *) source->buffer)->text));  
322 - break;  
323 -  
324 - case HLLAPI_PACKET_EMULATE_INPUT:  
325 - send_result(source,lib3270_emulate_input(lib3270_get_default_session_handle(),  
326 - (const char *) ((struct hllapi_packet_emulate_input *) source->buffer)->text,  
327 - (int) ((struct hllapi_packet_emulate_input *) source->buffer)->len,  
328 - (int) ((struct hllapi_packet_emulate_input *) source->buffer)->pasting));  
329 - break;  
330 -  
331 - case HLLAPI_PACKET_SET_CURSOR:  
332 - send_result(source,lib3270_set_cursor_address(lib3270_get_default_session_handle(),  
333 - ((struct hllapi_packet_addr *) source->buffer)->addr));  
334 - break;  
335 -  
336 - case HLLAPI_PACKET_GET_CURSOR:  
337 - send_result(source,lib3270_get_cursor_address(lib3270_get_default_session_handle()));  
338 - break;  
339 -  
340 - case HLLAPI_PACKET_GET_WIDTH:  
341 - send_result(source,lib3270_get_width(lib3270_get_default_session_handle()));  
342 - break;  
343 -  
344 - case HLLAPI_PACKET_GET_HEIGHT:  
345 - send_result(source,lib3270_get_height(lib3270_get_default_session_handle()));  
346 - break;  
347 -  
348 - case HLLAPI_PACKET_GET_LENGTH:  
349 - send_result(source,lib3270_get_length(lib3270_get_default_session_handle()));  
350 - break;  
351 -  
352 - case HLLAPI_PACKET_GET_PROGRAM_MESSAGE:  
353 - send_result(source,lib3270_get_program_message(lib3270_get_default_session_handle()));  
354 - break;  
355 -  
356 - case HLLAPI_PACKET_GET_SSL_STATE:  
357 - send_result(source,lib3270_get_secure(lib3270_get_default_session_handle()));  
358 - break;  
359 -  
360 - case HLLAPI_PACKET_SET_UNLOCK_DELAY:  
361 - lib3270_set_unlock_delay(lib3270_get_default_session_handle(),(unsigned short) ((struct hllapi_packet_set_int *) source->buffer)->value);  
362 - send_result(source,0);  
363 - break;  
364 -  
365 - case HLLAPI_PACKET_SET_TOGGLE:  
366 - send_result(source,lib3270_set_toggle(lib3270_get_default_session_handle(),  
367 - (LIB3270_TOGGLE) ((struct hllapi_packet_set *) source->buffer)->id,  
368 - ((struct hllapi_packet_set *) source->buffer)->value));  
369 - break;  
370 -  
371 - case HLLAPI_PACKET_FIELD_START:  
372 - send_result(source,lib3270_get_field_start(lib3270_get_default_session_handle(),  
373 - ((struct hllapi_packet_addr *) source->buffer)->addr));  
374 - break;  
375 -  
376 -  
377 - case HLLAPI_PACKET_FIELD_LEN:  
378 - send_result(source,lib3270_get_field_len(lib3270_get_default_session_handle(),  
379 - ((struct hllapi_packet_addr *) source->buffer)->addr));  
380 - break;  
381 -  
382 - case HLLAPI_PACKET_NEXT_UNPROTECTED:  
383 - send_result(source,lib3270_get_next_unprotected(lib3270_get_default_session_handle(),  
384 - ((struct hllapi_packet_addr *) source->buffer)->addr));  
385 - break;  
386 -  
387 - case HLLAPI_PACKET_IS_PROTECTED:  
388 - send_result(source,lib3270_get_is_protected(lib3270_get_default_session_handle(),  
389 - ((struct hllapi_packet_addr *) source->buffer)->addr));  
390 - break;  
391 -  
392 - case HLLAPI_PACKET_IS_PROTECTED_AT:  
393 - send_result(source,lib3270_get_is_protected_at( lib3270_get_default_session_handle(),  
394 - ((struct hllapi_packet_query_at *) source->buffer)->row,  
395 - ((struct hllapi_packet_query_at *) source->buffer)->col));  
396 - break;  
397 -  
398 - case HLLAPI_PACKET_QUIT:  
399 - gtk_main_quit();  
400 - send_result(source,0);  
401 - break;  
402 -  
403 - case HLLAPI_PACKET_SET_HOST_CHARSET:  
404 - send_result(source,lib3270_set_host_charset( lib3270_get_default_session_handle(),  
405 - (const char *) ((struct hllapi_packet_set_text *) source->buffer)->text));  
406 - break;  
407 -  
408 - case HLLAPI_PACKET_ASC2EBC:  
409 - send_text(source,(char *) lib3270_asc2ebc(  
410 - lib3270_get_default_session_handle(),  
411 - (unsigned char *) ((struct hllapi_packet_set_text *) source->buffer)->text,-1  
412 - ));  
413 - break;  
414 -  
415 - case HLLAPI_PACKET_EBC2ASC:  
416 - send_text(source,(char *) lib3270_ebc2asc(  
417 - lib3270_get_default_session_handle(),  
418 - (unsigned char *) ((struct hllapi_packet_set_text *) source->buffer)->text,-1  
419 - ));  
420 - break;  
421 -  
422 - case HLLAPI_PACKET_FILE_TRANSFER:  
423 - send_result(source,do_file_transfer((struct hllapi_packet_file_transfer *) source));  
424 - break;  
425 -  
426 - case HLLAPI_PACKET_GET_HOST_CHARSET:  
427 - trace("%s","HLLAPI_PACKET_GET_HOST_CHARSET");  
428 - send_text(source,(char *) lib3270_get_host_charset(lib3270_get_default_session_handle()));  
429 - break;  
430 -  
431 - case HLLAPI_PACKET_ACTION:  
432 - send_result(source,lib3270_action(lib3270_get_default_session_handle(),  
433 - (const char *) ((struct hllapi_packet_text *) source->buffer)->text));  
434 - break;  
435 -  
436 -  
437 - default:  
438 - send_result(source, EINVAL);  
439 - g_message("Invalid remote request (id=%d)",source->buffer[0]);  
440 - }  
441 -  
442 - }  
443 -  
444 - static void read_input_pipe(pipe_source *source)  
445 - {  
446 - DWORD cbRead = 0;  
447 -  
448 - if(ReadFile(source->hPipe,source->buffer,PIPE_BUFFER_LENGTH,&cbRead,&source->overlap) && cbRead > 0)  
449 - process_input(source,cbRead);  
450 -  
451 - // The read operation is still pending.  
452 - switch(GetLastError())  
453 - {  
454 - case 0:  
455 - break;  
456 -  
457 - case ERROR_IO_PENDING:  
458 - // trace("%s: PIPE_STATE_PENDING_READ",__FUNCTION__);  
459 - source->state = PIPE_STATE_PENDING_READ;  
460 - break;  
461 -  
462 - case ERROR_PIPE_LISTENING:  
463 - // trace("%s: ERROR_PIPE_LISTENING",__FUNCTION__);  
464 - source->state = PIPE_STATE_READ;  
465 - break;  
466 -  
467 - case ERROR_BROKEN_PIPE:  
468 - trace("%s: ERROR_BROKEN_PIPE",__FUNCTION__);  
469 -  
470 - if(!DisconnectNamedPipe(source->hPipe))  
471 - {  
472 - set_active(FALSE);  
473 - popup_lasterror("%s",_( "Error in DisconnectNamedPipe" ));  
474 - }  
475 - else  
476 - {  
477 - IO_accept(source);  
478 - }  
479 - break;  
480 -  
481 - case ERROR_PIPE_NOT_CONNECTED:  
482 - trace("%s: ERROR_PIPE_NOT_CONNECTED",__FUNCTION__);  
483 - set_active(FALSE);  
484 - break;  
485 -  
486 - default:  
487 - if(source->hPipe != INVALID_HANDLE_VALUE)  
488 - popup_lasterror("%s",_( "Error receiving message from pipe" ) );  
489 - }  
490 -  
491 - }  
492 -  
493 - static gboolean IO_dispatch(GSource *source, GSourceFunc G_GNUC_UNUSED(callback), gpointer G_GNUC_UNUSED(data))  
494 - {  
495 - /*  
496 - * Called to dispatch the event source,  
497 - * after it has returned TRUE in either its prepare or its check function.  
498 - * The dispatch function is passed in a callback function and data.  
499 - * The callback function may be NULL if the source was never connected  
500 - * to a callback using g_source_set_callback(). The dispatch function  
501 - * should call the callback function with user_data and whatever additional  
502 - * parameters are needed for this type of event source.  
503 - */  
504 - BOOL fSuccess;  
505 - DWORD cbRead = 0;  
506 -// DWORD dwErr = 0;  
507 -  
508 - fSuccess = GetOverlappedResult(((pipe_source *) source)->hPipe,&((pipe_source *) source)->overlap,&cbRead,FALSE );  
509 -  
510 - // trace("%s: source=%p data=%p Result=%s cbRead=%d",__FUNCTION__,source,data,fSuccess ? "Success" : "Unsuccess",(int) cbRead);  
511 -  
512 - switch(((pipe_source *) source)->state)  
513 - {  
514 - case PIPE_STATE_WAITING:  
515 - if(fSuccess)  
516 - {  
517 - trace("Pipe connected (cbRet=%d)",(int) cbRead);  
518 - set_active(TRUE);  
519 - ((pipe_source *) source)->state = PIPE_STATE_READ;  
520 - }  
521 - else  
522 - {  
523 - popup_lasterror("%s", _( "Pipe connection failed" ));  
524 - }  
525 - break;  
526 -  
527 - case PIPE_STATE_READ:  
528 - // trace("Reading pipe (cbRead=%d)",(int) cbRead);  
529 - read_input_pipe( (pipe_source *) source);  
530 - break;  
531 -  
532 - case PIPE_STATE_PENDING_READ:  
533 - if(fSuccess && cbRead > 0)  
534 - process_input((pipe_source *) source,cbRead);  
535 - ((pipe_source *) source)->state = PIPE_STATE_READ;  
536 - break;  
537 -  
538 - case PIPE_STATE_UNDEFINED:  
539 - break;  
540 -  
541 -//#ifdef DEBUG  
542 -// default:  
543 -// trace("%s: source=%p data=%p Unexpected mode %d",__FUNCTION__,source,data,((pipe_source *) source)->state);  
544 -//#endif  
545 - }  
546 -  
547 - return TRUE;  
548 - }  
549 -  
550 - static void IO_finalize(GSource *source)  
551 - {  
552 -// trace("%s: source=%p",__FUNCTION__,source);  
553 -  
554 - if( ((pipe_source *) source)->hPipe != INVALID_HANDLE_VALUE)  
555 - {  
556 - CloseHandle(((pipe_source *) source)->hPipe);  
557 - ((pipe_source *) source)->hPipe = INVALID_HANDLE_VALUE;  
558 - }  
559 -  
560 - }  
561 -  
562 - static gboolean IO_closure(gpointer G_GNUC_UNUSED(data))  
563 - {  
564 - return 0;  
565 - }  
566 -  
567 - void popup_lasterror(const gchar *fmt, ...)  
568 - {  
569 - char buffer[4096];  
570 - va_list arg_ptr;  
571 - int sz;  
572 - DWORD errcode = GetLastError();  
573 - char *ptr;  
574 - LPVOID lpMsgBuf = 0;  
575 -  
576 - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errcode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL);  
577 -  
578 - for(ptr= (char *) lpMsgBuf;*ptr && *ptr != '\n';ptr++);  
579 - *ptr = 0;  
580 -  
581 - va_start(arg_ptr, fmt);  
582 - vsnprintf(buffer,4095,fmt,arg_ptr);  
583 - va_end(arg_ptr);  
584 -  
585 - sz = strlen(buffer);  
586 - snprintf(buffer+sz,4096-sz,": %s\n(rc=%d)",lpMsgBuf,(int) errcode);  
587 -  
588 - printf("%s\n",buffer);  
589 -  
590 -#ifdef DEBUG  
591 - fprintf(stderr,"%s\n",buffer);  
592 - fflush(stderr);  
593 -#endif  
594 -  
595 - LocalFree(lpMsgBuf);  
596 - }  
597 -  
598 - LIB3270_EXPORT int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal)  
599 - {  
600 - char id;  
601 - const gchar * name = "pw3270";  
602 -  
603 - for(id='A';id < 'Z';id++)  
604 - {  
605 - gchar * pipename = g_strdup_printf("\\\\.\\pipe\\%s_%c",name,id);  
606 - gchar * ptr;  
607 - HANDLE hPipe;  
608 -  
609 - for(ptr=pipename;*ptr;ptr++)  
610 - *ptr = g_ascii_tolower(*ptr);  
611 -  
612 - hPipe = CreateNamedPipe( TEXT(pipename), // pipe name  
613 - PIPE_ACCESS_DUPLEX | // read/write access  
614 - FILE_FLAG_OVERLAPPED, // overlapped mode  
615 - PIPE_TYPE_MESSAGE | // pipe type  
616 - PIPE_READMODE_MESSAGE | // pipe mode  
617 - PIPE_WAIT, // blocking mode  
618 - 1, // number of instances  
619 - PIPE_BUFFER_LENGTH, // output buffer size  
620 - PIPE_BUFFER_LENGTH, // input buffer size  
621 - NMPWAIT_USE_DEFAULT_WAIT, // client time-out  
622 - NULL); // default security attributes  
623 -  
624 - trace("%s = %p",pipename,hPipe);  
625 - g_free(pipename);  
626 -  
627 - if(hPipe != INVALID_HANDLE_VALUE)  
628 - {  
629 - static GSourceFuncs pipe_source_funcs =  
630 - {  
631 - IO_prepare,  
632 - IO_check,  
633 - IO_dispatch,  
634 - IO_finalize,  
635 - IO_closure,  
636 - NULL  
637 - };  
638 - pipe_source * source;  
639 - gchar * session = g_strdup_printf("%s:%c",name,id);  
640 -  
641 - // pw3270_set_session_name(window,session);  
642 - v3270_set_session_name(terminal,session);  
643 -  
644 - g_free(session);  
645 -  
646 - source = (pipe_source *) g_source_new(&pipe_source_funcs,sizeof(pipe_source));  
647 -  
648 - source->hPipe = hPipe;  
649 - source->state = PIPE_STATE_WAITING;  
650 - source->overlap.hEvent = CreateEvent( NULL,TRUE,TRUE,NULL);  
651 -  
652 - g_source_attach((GSource *) source,NULL);  
653 - IO_accept(source);  
654 -  
655 - return 0;  
656 - }  
657 -  
658 - }  
659 -  
660 - popup_lasterror( "%s", _( "Can´t create remote control pipe" ));  
661 -  
662 - return -1;  
663 - }  
664 -  
665 - LIB3270_EXPORT int pw3270_plugin_stop(GtkWidget *window, GtkWidget *terminal)  
666 - {  
667 -  
668 - return 0;  
669 - }  
670 -  
671 - G_GNUC_INTERNAL void set_active(gboolean on)  
672 - {  
673 - trace("%s(%s)",__FUNCTION__,on ? "Active" : "Inactive");  
674 - // v3270_set_script(v3270_get_default_widget(),'H');  
675 - }  
src/plugin/windows/private.h
@@ -1,50 +0,0 @@ @@ -1,50 +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., 59 Temple  
19 - * Place, Suite 330, Boston, MA, 02111-1307, USA  
20 - *  
21 - * Este programa está nomeado como -e possui - linhas de código.  
22 - *  
23 - * Contatos:  
24 - *  
25 - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
26 - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)  
27 - *  
28 - */  
29 -  
30 - #include <config.h>  
31 - #define ENABLE_NLS  
32 - #define GETTEXT_PACKAGE PACKAGE_NAME  
33 -  
34 - #include <libintl.h>  
35 - #include <glib/gi18n.h>  
36 - #include <gtk/gtk.h>  
37 -  
38 - #include <lib3270.h>  
39 - #include <lib3270/log.h>  
40 - #include <pw3270.h>  
41 - #include <pw3270/hllapi.h>  
42 -  
43 - #include <windows.h>  
44 -  
45 - #define PIPE_BUFFER_LENGTH HLLAPI_MAXLENGTH+30  
46 -  
47 - G_GNUC_INTERNAL void popup_lasterror(const gchar *fmt, ...);  
48 - G_GNUC_INTERNAL void set_active(gboolean on);  
49 -  
50 -  
src/plugin/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_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/testprogram/linux/test.sh
@@ -1,126 +0,0 @@ @@ -1,126 +0,0 @@
1 -#!/bin/bash  
2 -  
3 -SESSION=a  
4 -DEST=br.com.bb.pw3270  
5 -BPATH=/br/com/bb/pw3270  
6 -  
7 -run_command()  
8 -{  
9 -  
10 - case $1 in  
11 -  
12 - revision)  
13 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getRevision  
14 - ;;  
15 -  
16 - message)  
17 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getMessageID  
18 - ;;  
19 -  
20 - ssl)  
21 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getSecureState  
22 - ;;  
23 -  
24 - connect)  
25 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.connect string:$2 int32:10  
26 - ;;  
27 -  
28 - disconnect)  
29 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.disconnect  
30 - ;;  
31 -  
32 - url)  
33 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getURL  
34 - ;;  
35 -  
36 - quit)  
37 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.quit  
38 - ;;  
39 -  
40 - get)  
41 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getScreenContents  
42 - ;;  
43 -  
44 - gettext)  
45 -# addr,len,lf  
46 -# dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getText int32:1 int32:-1 byte:0  
47 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getText int32:1 int32:-1 byte:10  
48 - ;;  
49 -  
50 - protect)  
51 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getIsProtectedAt int32:$2 int32:$3  
52 - ;;  
53 -  
54 - set)  
55 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.setTextAt int32:$2 int32:$3 string:$4  
56 - ;;  
57 -  
58 - action)  
59 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.action string:$2  
60 - ;;  
61 -  
62 - enter)  
63 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.enter  
64 - ;;  
65 -  
66 - isconnected)  
67 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.isConnected  
68 - ;;  
69 -  
70 - hostcharset)  
71 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getHostCharset  
72 - ;;  
73 -  
74 - displaycharset)  
75 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getDisplayCharset  
76 - ;;  
77 -  
78 - unlockdelay)  
79 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.setUnlockDelay int32:$2  
80 - ;;  
81 -  
82 - *)  
83 - echo "Comando $1 desconhecido"  
84 - ;;  
85 -  
86 - esac  
87 -}  
88 -  
89 -  
90 -  
91 -until [ -z "$1" ]  
92 -do  
93 - if [ ${1:0:2} = '--' ]; then  
94 - tmp=${1:2}  
95 - parameter=${tmp%%=*}  
96 - parameter=$(echo $parameter | tr "[:lower:]" "[:upper:]")  
97 - value=${tmp##*=}  
98 -  
99 - case "$parameter" in  
100 - SESSION)  
101 - SESSION=$value  
102 - ;;  
103 - HELP)  
104 - echo "$0 options"  
105 - echo ""  
106 - echo "Options:"  
107 - echo ""  
108 - echo " --session pw3270's session manager"  
109 - echo ""  
110 - exit 0  
111 - ;;  
112 -  
113 - *)  
114 - eval $parameter=$value  
115 - ;;  
116 -  
117 - esac  
118 -  
119 - else  
120 - run_command $@  
121 - exit 0  
122 - fi  
123 -  
124 - shift  
125 -done  
126 -  
src/testprogram/testprogram.c
@@ -1,248 +0,0 @@ @@ -1,248 +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 Test program for pw3270 HLLAPI compatibility plugin.  
34 - *  
35 - */  
36 -  
37 - #include <config.h>  
38 - #include <v3270.h>  
39 - #include <v3270/trace.h>  
40 - #include <pw3270/plugin.h>  
41 - #include <string.h>  
42 - #include <stdlib.h>  
43 - #include <pw3270.h>  
44 -  
45 - /*---[ Globals ]------------------------------------------------------------------------------------*/  
46 -  
47 - const gchar * plugin_path = ".bin/Debug";  
48 - const gchar * session_name = "pw3270";  
49 - const gchar * plugin_name = "ipc3270c." G_MODULE_SUFFIX;  
50 -  
51 - /*---[ Implement ]----------------------------------------------------------------------------------*/  
52 -  
53 - static void close_module(GtkWidget *widget, GModule *module)  
54 - {  
55 - g_message("Closing module %p",module);  
56 -  
57 - static void (*stop)(GtkWidget *window, GtkWidget *terminal) = NULL;  
58 - if(!g_module_symbol(module,"pw3270_plugin_stop",(void **) &stop))  
59 - {  
60 - g_message("Can't get stop method from plugin: %s",g_module_error());  
61 - }  
62 - else  
63 - {  
64 - stop(gtk_widget_get_toplevel(widget),widget);  
65 - }  
66 -  
67 - g_module_close(module);  
68 - g_message("Module %p was closed",module);  
69 - }  
70 -  
71 - static void toggle_ds_trace(GtkToggleToolButton *button, GtkWidget *terminal)  
72 - {  
73 - v3270_set_toggle(terminal,LIB3270_TOGGLE_DS_TRACE,gtk_toggle_tool_button_get_active(button));  
74 - }  
75 -  
76 - static void toggle_event_trace(GtkToggleToolButton *button, GtkWidget *terminal)  
77 - {  
78 - v3270_set_toggle(terminal,LIB3270_TOGGLE_EVENT_TRACE,gtk_toggle_tool_button_get_active(button));  
79 - }  
80 -  
81 - static void toggle_ssl_trace(GtkToggleToolButton *button, GtkWidget *terminal)  
82 - {  
83 - v3270_set_toggle(terminal,LIB3270_TOGGLE_SSL_TRACE,gtk_toggle_tool_button_get_active(button));  
84 - }  
85 -  
86 - static void toggle_screen_trace(GtkToggleToolButton *button, GtkWidget *terminal)  
87 - {  
88 - v3270_set_toggle(terminal,LIB3270_TOGGLE_SCREEN_TRACE,gtk_toggle_tool_button_get_active(button));  
89 - }  
90 -  
91 - static void toggle_started_trace(GtkToggleToolButton *button, GModule *module)  
92 - {  
93 - if(!module)  
94 - return;  
95 -  
96 - GtkWidget * terminal = GTK_WIDGET(g_object_get_data(G_OBJECT(button),"terminal"));  
97 -  
98 - const gchar * method_name = (gtk_toggle_tool_button_get_active(button) ? "pw3270_plugin_start" : "pw3270_plugin_stop");  
99 -  
100 - static void (*call)(GtkWidget *window, GtkWidget *terminal) = NULL;  
101 - if(!g_module_symbol(module,method_name,(void **) &call))  
102 - {  
103 - g_message("Can't get method \"%s\": %s",method_name,g_module_error());  
104 - return;  
105 - }  
106 -  
107 - g_message("Calling %s",method_name);  
108 - call(gtk_widget_get_toplevel(terminal), GTK_WIDGET(terminal));  
109 -  
110 - }  
111 -  
112 - static GtkToolItem * create_tool_item(GtkWidget *terminal, const gchar *label, const gchar *tooltip, GCallback callback)  
113 - {  
114 - GtkToolItem * item = gtk_toggle_tool_button_new();  
115 - gtk_tool_button_set_label(GTK_TOOL_BUTTON(item),label);  
116 -  
117 - g_signal_connect(GTK_WIDGET(item), "toggled", G_CALLBACK(callback), terminal);  
118 -  
119 - if(tooltip)  
120 - gtk_widget_set_tooltip_text(GTK_WIDGET(item),tooltip);  
121 -  
122 - return item;  
123 - }  
124 -  
125 - static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) {  
126 -  
127 - GtkWidget * window = gtk_application_window_new(app);  
128 - GtkWidget * terminal = v3270_new();  
129 - GtkWidget * notebook = gtk_notebook_new();  
130 - GModule * module = NULL;  
131 -  
132 - gtk_widget_set_name(window,session_name);  
133 -  
134 - // Setup tabs  
135 - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),terminal,gtk_label_new(v3270_get_session_name(terminal)));  
136 -  
137 - // Load plugin  
138 - {  
139 - g_autofree gchar * plugin = g_build_filename(plugin_path,plugin_name,NULL);  
140 -  
141 - g_message("Loading %s",plugin);  
142 -  
143 - module = g_module_open(plugin,G_MODULE_BIND_LOCAL);  
144 -  
145 - if(module)  
146 - {  
147 - g_signal_connect (terminal, "destroy", G_CALLBACK(close_module), module);  
148 - }  
149 - else  
150 - {  
151 - g_message("Can't open \"%s\": %s",plugin,g_module_error());  
152 - gtk_main_quit();  
153 - }  
154 -  
155 - }  
156 - // Create trace window  
157 - {  
158 - GtkWidget * box = gtk_box_new(GTK_ORIENTATION_VERTICAL,0);  
159 - GtkWidget * trace = v3270_trace_new(terminal);  
160 - GtkWidget * toolbar = gtk_toolbar_new();  
161 - GtkToolItem * start = gtk_toggle_tool_button_new();  
162 -  
163 - gtk_widget_set_sensitive(GTK_WIDGET(start),module != NULL);  
164 -  
165 - g_object_set_data(G_OBJECT(start),"terminal",terminal);  
166 -  
167 - gtk_tool_button_set_label(GTK_TOOL_BUTTON(start),"Enable");  
168 - g_signal_connect(GTK_WIDGET(start), "toggled", G_CALLBACK(toggle_started_trace), module);  
169 - gtk_widget_set_tooltip_text(GTK_WIDGET(start),"Start/Stop plugin module");  
170 -  
171 - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), start, -1);  
172 -  
173 - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),gtk_separator_tool_item_new(),-1);  
174 -  
175 - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "DS Trace","Toggle DS Trace",G_CALLBACK(toggle_ds_trace)),-1);  
176 - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "Event Trace","Toggle Event Trace",G_CALLBACK(toggle_event_trace)),-1);  
177 - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "Screen Trace","Toggle Screen Trace",G_CALLBACK(toggle_screen_trace)),-1);  
178 - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "SSL Trace","Toggle SSL Trace",G_CALLBACK(toggle_ssl_trace)),-1);  
179 -  
180 - gtk_box_pack_start(GTK_BOX(box),toolbar,FALSE,FALSE,0);  
181 - gtk_box_pack_start(GTK_BOX(box),trace,TRUE,TRUE,0);  
182 - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),box,gtk_label_new("Trace"));  
183 - }  
184 -  
185 - // Setup and show main window  
186 - gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);  
187 - gtk_window_set_default_size (GTK_WINDOW (window), 800, 500);  
188 - gtk_container_add(GTK_CONTAINER(window),notebook);  
189 - gtk_widget_show_all (window);  
190 -  
191 - // Setup title.  
192 - const gchar *url = lib3270_get_url(v3270_get_session(terminal));  
193 - if(url) {  
194 -  
195 - v3270_set_url(terminal,url);  
196 - v3270_reconnect(terminal);  
197 -  
198 - gchar * title = g_strdup_printf("%s - %s", v3270_get_session_name(terminal), url);  
199 - gtk_window_set_title(GTK_WINDOW(window), title);  
200 - g_free(title);  
201 -  
202 - } else {  
203 -  
204 - gtk_window_set_title(GTK_WINDOW(window), v3270_get_session_name(terminal));  
205 -  
206 - }  
207 -  
208 -}  
209 -  
210 -int main (int argc, char **argv) {  
211 -  
212 - /*  
213 - GVariantBuilder builder;  
214 -  
215 - g_variant_builder_init(&builder,G_VARIANT_TYPE("(isi)"));  
216 -  
217 - g_variant_builder_add(&builder, "i", 10);  
218 - g_variant_builder_add(&builder, "s", "teste");  
219 - g_variant_builder_add(&builder, "i", 20);  
220 -  
221 - GVariant *value = g_variant_builder_end(&builder);  
222 -  
223 - size_t szPacket = 0;  
224 - g_autofree unsigned char * buffer = ipc3270_pack("teste", value, &szPacket);  
225 - g_variant_unref(value);  
226 -  
227 - debug("Package \"%s\" was created with %u bytes", buffer, (unsigned int) szPacket);  
228 -  
229 - value = ipc3270_unpack(buffer);  
230 -  
231 - g_variant_unref(value);  
232 - */  
233 -  
234 - GtkApplication *app;  
235 - int status;  
236 -  
237 - app = gtk_application_new ("br.com.bb.pw3270",G_APPLICATION_FLAGS_NONE);  
238 -  
239 - g_signal_connect (app, "activate", G_CALLBACK(activate), NULL);  
240 -  
241 - status = g_application_run (G_APPLICATION (app), argc, argv);  
242 - g_object_unref (app);  
243 -  
244 - g_message("rc=%d",status);  
245 - return status;  
246 -  
247 -}  
248 -  
src/testprograms/linux/test.sh 0 → 100755
@@ -0,0 +1,126 @@ @@ -0,0 +1,126 @@
  1 +#!/bin/bash
  2 +
  3 +SESSION=a
  4 +DEST=br.com.bb.pw3270
  5 +BPATH=/br/com/bb/pw3270
  6 +
  7 +run_command()
  8 +{
  9 +
  10 + case $1 in
  11 +
  12 + revision)
  13 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getRevision
  14 + ;;
  15 +
  16 + message)
  17 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getMessageID
  18 + ;;
  19 +
  20 + ssl)
  21 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getSecureState
  22 + ;;
  23 +
  24 + connect)
  25 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.connect string:$2 int32:10
  26 + ;;
  27 +
  28 + disconnect)
  29 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.disconnect
  30 + ;;
  31 +
  32 + url)
  33 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getURL
  34 + ;;
  35 +
  36 + quit)
  37 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.quit
  38 + ;;
  39 +
  40 + get)
  41 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getScreenContents
  42 + ;;
  43 +
  44 + gettext)
  45 +# addr,len,lf
  46 +# dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getText int32:1 int32:-1 byte:0
  47 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getText int32:1 int32:-1 byte:10
  48 + ;;
  49 +
  50 + protect)
  51 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getIsProtectedAt int32:$2 int32:$3
  52 + ;;
  53 +
  54 + set)
  55 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.setTextAt int32:$2 int32:$3 string:$4
  56 + ;;
  57 +
  58 + action)
  59 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.action string:$2
  60 + ;;
  61 +
  62 + enter)
  63 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.enter
  64 + ;;
  65 +
  66 + isconnected)
  67 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.isConnected
  68 + ;;
  69 +
  70 + hostcharset)
  71 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getHostCharset
  72 + ;;
  73 +
  74 + displaycharset)
  75 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getDisplayCharset
  76 + ;;
  77 +
  78 + unlockdelay)
  79 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.setUnlockDelay int32:$2
  80 + ;;
  81 +
  82 + *)
  83 + echo "Comando $1 desconhecido"
  84 + ;;
  85 +
  86 + esac
  87 +}
  88 +
  89 +
  90 +
  91 +until [ -z "$1" ]
  92 +do
  93 + if [ ${1:0:2} = '--' ]; then
  94 + tmp=${1:2}
  95 + parameter=${tmp%%=*}
  96 + parameter=$(echo $parameter | tr "[:lower:]" "[:upper:]")
  97 + value=${tmp##*=}
  98 +
  99 + case "$parameter" in
  100 + SESSION)
  101 + SESSION=$value
  102 + ;;
  103 + HELP)
  104 + echo "$0 options"
  105 + echo ""
  106 + echo "Options:"
  107 + echo ""
  108 + echo " --session pw3270's session manager"
  109 + echo ""
  110 + exit 0
  111 + ;;
  112 +
  113 + *)
  114 + eval $parameter=$value
  115 + ;;
  116 +
  117 + esac
  118 +
  119 + else
  120 + run_command $@
  121 + exit 0
  122 + fi
  123 +
  124 + shift
  125 +done
  126 +
src/testprograms/plugin.c 0 → 100644
@@ -0,0 +1,248 @@ @@ -0,0 +1,248 @@
  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 Test program for pw3270 HLLAPI compatibility plugin.
  34 + *
  35 + */
  36 +
  37 + #include <config.h>
  38 + #include <v3270.h>
  39 + #include <v3270/trace.h>
  40 + #include <pw3270/plugin.h>
  41 + #include <string.h>
  42 + #include <stdlib.h>
  43 + #include <pw3270.h>
  44 +
  45 + /*---[ Globals ]------------------------------------------------------------------------------------*/
  46 +
  47 + const gchar * plugin_path = ".bin/Debug";
  48 + const gchar * session_name = "pw3270";
  49 + const gchar * plugin_name = "ipc3270c." G_MODULE_SUFFIX;
  50 +
  51 + /*---[ Implement ]----------------------------------------------------------------------------------*/
  52 +
  53 + static void close_module(GtkWidget *widget, GModule *module)
  54 + {
  55 + g_message("Closing module %p",module);
  56 +
  57 + static void (*stop)(GtkWidget *window, GtkWidget *terminal) = NULL;
  58 + if(!g_module_symbol(module,"pw3270_plugin_stop",(void **) &stop))
  59 + {
  60 + g_message("Can't get stop method from plugin: %s",g_module_error());
  61 + }
  62 + else
  63 + {
  64 + stop(gtk_widget_get_toplevel(widget),widget);
  65 + }
  66 +
  67 + g_module_close(module);
  68 + g_message("Module %p was closed",module);
  69 + }
  70 +
  71 + static void toggle_ds_trace(GtkToggleToolButton *button, GtkWidget *terminal)
  72 + {
  73 + v3270_set_toggle(terminal,LIB3270_TOGGLE_DS_TRACE,gtk_toggle_tool_button_get_active(button));
  74 + }
  75 +
  76 + static void toggle_event_trace(GtkToggleToolButton *button, GtkWidget *terminal)
  77 + {
  78 + v3270_set_toggle(terminal,LIB3270_TOGGLE_EVENT_TRACE,gtk_toggle_tool_button_get_active(button));
  79 + }
  80 +
  81 + static void toggle_ssl_trace(GtkToggleToolButton *button, GtkWidget *terminal)
  82 + {
  83 + v3270_set_toggle(terminal,LIB3270_TOGGLE_SSL_TRACE,gtk_toggle_tool_button_get_active(button));
  84 + }
  85 +
  86 + static void toggle_screen_trace(GtkToggleToolButton *button, GtkWidget *terminal)
  87 + {
  88 + v3270_set_toggle(terminal,LIB3270_TOGGLE_SCREEN_TRACE,gtk_toggle_tool_button_get_active(button));
  89 + }
  90 +
  91 + static void toggle_started_trace(GtkToggleToolButton *button, GModule *module)
  92 + {
  93 + if(!module)
  94 + return;
  95 +
  96 + GtkWidget * terminal = GTK_WIDGET(g_object_get_data(G_OBJECT(button),"terminal"));
  97 +
  98 + const gchar * method_name = (gtk_toggle_tool_button_get_active(button) ? "pw3270_plugin_start" : "pw3270_plugin_stop");
  99 +
  100 + static void (*call)(GtkWidget *window, GtkWidget *terminal) = NULL;
  101 + if(!g_module_symbol(module,method_name,(void **) &call))
  102 + {
  103 + g_message("Can't get method \"%s\": %s",method_name,g_module_error());
  104 + return;
  105 + }
  106 +
  107 + g_message("Calling %s",method_name);
  108 + call(gtk_widget_get_toplevel(terminal), GTK_WIDGET(terminal));
  109 +
  110 + }
  111 +
  112 + static GtkToolItem * create_tool_item(GtkWidget *terminal, const gchar *label, const gchar *tooltip, GCallback callback)
  113 + {
  114 + GtkToolItem * item = gtk_toggle_tool_button_new();
  115 + gtk_tool_button_set_label(GTK_TOOL_BUTTON(item),label);
  116 +
  117 + g_signal_connect(GTK_WIDGET(item), "toggled", G_CALLBACK(callback), terminal);
  118 +
  119 + if(tooltip)
  120 + gtk_widget_set_tooltip_text(GTK_WIDGET(item),tooltip);
  121 +
  122 + return item;
  123 + }
  124 +
  125 + static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) {
  126 +
  127 + GtkWidget * window = gtk_application_window_new(app);
  128 + GtkWidget * terminal = v3270_new();
  129 + GtkWidget * notebook = gtk_notebook_new();
  130 + GModule * module = NULL;
  131 +
  132 + gtk_widget_set_name(window,session_name);
  133 +
  134 + // Setup tabs
  135 + gtk_notebook_append_page(GTK_NOTEBOOK(notebook),terminal,gtk_label_new(v3270_get_session_name(terminal)));
  136 +
  137 + // Load plugin
  138 + {
  139 + g_autofree gchar * plugin = g_build_filename(plugin_path,plugin_name,NULL);
  140 +
  141 + g_message("Loading %s",plugin);
  142 +
  143 + module = g_module_open(plugin,G_MODULE_BIND_LOCAL);
  144 +
  145 + if(module)
  146 + {
  147 + g_signal_connect (terminal, "destroy", G_CALLBACK(close_module), module);
  148 + }
  149 + else
  150 + {
  151 + g_message("Can't open \"%s\": %s",plugin,g_module_error());
  152 + gtk_main_quit();
  153 + }
  154 +
  155 + }
  156 + // Create trace window
  157 + {
  158 + GtkWidget * box = gtk_box_new(GTK_ORIENTATION_VERTICAL,0);
  159 + GtkWidget * trace = v3270_trace_new(terminal);
  160 + GtkWidget * toolbar = gtk_toolbar_new();
  161 + GtkToolItem * start = gtk_toggle_tool_button_new();
  162 +
  163 + gtk_widget_set_sensitive(GTK_WIDGET(start),module != NULL);
  164 +
  165 + g_object_set_data(G_OBJECT(start),"terminal",terminal);
  166 +
  167 + gtk_tool_button_set_label(GTK_TOOL_BUTTON(start),"Enable");
  168 + g_signal_connect(GTK_WIDGET(start), "toggled", G_CALLBACK(toggle_started_trace), module);
  169 + gtk_widget_set_tooltip_text(GTK_WIDGET(start),"Start/Stop plugin module");
  170 +
  171 + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), start, -1);
  172 +
  173 + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),gtk_separator_tool_item_new(),-1);
  174 +
  175 + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "DS Trace","Toggle DS Trace",G_CALLBACK(toggle_ds_trace)),-1);
  176 + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "Event Trace","Toggle Event Trace",G_CALLBACK(toggle_event_trace)),-1);
  177 + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "Screen Trace","Toggle Screen Trace",G_CALLBACK(toggle_screen_trace)),-1);
  178 + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "SSL Trace","Toggle SSL Trace",G_CALLBACK(toggle_ssl_trace)),-1);
  179 +
  180 + gtk_box_pack_start(GTK_BOX(box),toolbar,FALSE,FALSE,0);
  181 + gtk_box_pack_start(GTK_BOX(box),trace,TRUE,TRUE,0);
  182 + gtk_notebook_append_page(GTK_NOTEBOOK(notebook),box,gtk_label_new("Trace"));
  183 + }
  184 +
  185 + // Setup and show main window
  186 + gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
  187 + gtk_window_set_default_size (GTK_WINDOW (window), 800, 500);
  188 + gtk_container_add(GTK_CONTAINER(window),notebook);
  189 + gtk_widget_show_all (window);
  190 +
  191 + // Setup title.
  192 + const gchar *url = lib3270_get_url(v3270_get_session(terminal));
  193 + if(url) {
  194 +
  195 + v3270_set_url(terminal,url);
  196 + v3270_reconnect(terminal);
  197 +
  198 + gchar * title = g_strdup_printf("%s - %s", v3270_get_session_name(terminal), url);
  199 + gtk_window_set_title(GTK_WINDOW(window), title);
  200 + g_free(title);
  201 +
  202 + } else {
  203 +
  204 + gtk_window_set_title(GTK_WINDOW(window), v3270_get_session_name(terminal));
  205 +
  206 + }
  207 +
  208 +}
  209 +
  210 +int main (int argc, char **argv) {
  211 +
  212 + /*
  213 + GVariantBuilder builder;
  214 +
  215 + g_variant_builder_init(&builder,G_VARIANT_TYPE("(isi)"));
  216 +
  217 + g_variant_builder_add(&builder, "i", 10);
  218 + g_variant_builder_add(&builder, "s", "teste");
  219 + g_variant_builder_add(&builder, "i", 20);
  220 +
  221 + GVariant *value = g_variant_builder_end(&builder);
  222 +
  223 + size_t szPacket = 0;
  224 + g_autofree unsigned char * buffer = ipc3270_pack("teste", value, &szPacket);
  225 + g_variant_unref(value);
  226 +
  227 + debug("Package \"%s\" was created with %u bytes", buffer, (unsigned int) szPacket);
  228 +
  229 + value = ipc3270_unpack(buffer);
  230 +
  231 + g_variant_unref(value);
  232 + */
  233 +
  234 + GtkApplication *app;
  235 + int status;
  236 +
  237 + app = gtk_application_new ("br.com.bb.pw3270",G_APPLICATION_FLAGS_NONE);
  238 +
  239 + g_signal_connect (app, "activate", G_CALLBACK(activate), NULL);
  240 +
  241 + status = g_application_run (G_APPLICATION (app), argc, argv);
  242 + g_object_unref (app);
  243 +
  244 + g_message("rc=%d",status);
  245 + return status;
  246 +
  247 +}
  248 +