Commit 96ed31d591fdd16d48400a771d1996721b4e56d4
1 parent
3c277bef
Exists in
master
and in
5 other branches
Padronizando nome do plugin dbus, incluindo mais métodos dbus para interação com o terminal
Showing
24 changed files
with
1290 additions
and
1210 deletions
Show diff stats
configure.ac
| ... | ... | @@ -429,7 +429,7 @@ AC_CONFIG_FILES([ |
| 429 | 429 | src/tools/Makefile |
| 430 | 430 | src/plugins/remotectl/Makefile |
| 431 | 431 | src/plugins/rx3270/Makefile |
| 432 | - src/plugins/3270dbus/Makefile | |
| 432 | + src/plugins/dbus3270/Makefile | |
| 433 | 433 | man/Makefile |
| 434 | 434 | makegtkruntime.sh |
| 435 | 435 | src/sample/Makefile | ... | ... |
src/plugins/3270dbus/Makefile.in
| ... | ... | @@ -1,120 +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 | -# Contatos: | |
| 22 | -# | |
| 23 | -# perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 24 | -# erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) | |
| 25 | -# licinio@bb.com.br (Licínio Luis Branco) | |
| 26 | -# kraucer@bb.com.br (Kraucer Fernandes Mazuco) | |
| 27 | -# | |
| 28 | - | |
| 29 | -#---[ Sources ]---------------------------------------------------------------- | |
| 30 | - | |
| 31 | -MODULE_NAME=3270dbus | |
| 32 | -DEPENDS=Makefile dbus-glue.h | |
| 33 | -PLUGIN_SRC=main.c gobject.c misc.c | |
| 34 | -DAEMON_SRC=daemon.c gobject.c iocallback.c misc.c | |
| 35 | - | |
| 36 | -#---[ Paths ]------------------------------------------------------------------ | |
| 37 | - | |
| 38 | -ROOTDIR ?= . | |
| 39 | -OBJDIR ?= $(ROOTDIR)/.obj | |
| 40 | -BINDIR ?= $(ROOTDIR)/.bin | |
| 41 | -BINDBG ?= $(BINDIR)/Debug | |
| 42 | -BINRLS ?= $(BINDIR)/Release | |
| 43 | - | |
| 44 | -OBJDBG = $(OBJDIR)/Debug | |
| 45 | -OBJRLS = $(OBJDIR)/Release | |
| 46 | -OBJEXT = o | |
| 47 | - | |
| 48 | -#---[ Tools ]------------------------------------------------------------------ | |
| 49 | - | |
| 50 | -MKDIR=@MKDIR_P@ | |
| 51 | -CC=@CC@ | |
| 52 | -LD=@CC@ | |
| 53 | -DBUSBINDINGTOOL=@DBUSBINDINGTOOL@ | |
| 54 | - | |
| 55 | -#---[ Flags ]------------------------------------------------------------------ | |
| 56 | - | |
| 57 | -DLL_FLAGS=-shared | |
| 58 | -DLL_CFLAGS=@DLL_CFLAGS@ | |
| 59 | -DEBUG_CFLAGS=-DDEBUG=1 -g -Wall | |
| 60 | - | |
| 61 | -LIB3270_CFLAGS ?= `pkg-config --cflags lib3270` | |
| 62 | -DBUS_CFLAGS=@DBUS_CFLAGS@ | |
| 63 | -GLIB_CFLAGS=@GLIB_CFLAGS@ | |
| 64 | -GTK_CFLAGS=@GTK_CFLAGS@ | |
| 65 | - | |
| 66 | -LIB3270_LIBS ?= `pkg-config --libs lib3270` | |
| 67 | -DBUS_LIBS=@DBUS_LIBS@ | |
| 68 | -GLIB_LIBS=@GLIB_LIBS@ | |
| 69 | -GTK_LIBS=@GTK_LIBS@ | |
| 70 | - | |
| 71 | -#---[ Rules ]------------------------------------------------------------------ | |
| 72 | - | |
| 73 | -$(OBJDBG)/%.o: %.c $(DEPENDS) | |
| 74 | - @echo " CC `basename $@`" | |
| 75 | - @$(MKDIR) `dirname $@` | |
| 76 | - @$(CC) $(CFLAGS) $(DLL_CFLAGS) $(DBUS_CFLAGS) $(GLIB_CFLAGS) $(GTK_CFLAGS) $(DEBUG_CFLAGS) $(LIB3270_CFLAGS) -o $@ -c $< | |
| 77 | - | |
| 78 | -$(OBJRLS)/%.o: %.c $(DEPENDS) | |
| 79 | - @echo " CC `basename $@`" | |
| 80 | - @$(MKDIR) `dirname $@` | |
| 81 | - @$(CC) $(CFLAGS) $(DLL_CFLAGS) $(DBUS_CFLAGS) $(GLIB_CFLAGS) $(GTK_CFLAGS) $(LIB3270_CFLAGS) -o $@ -c $< | |
| 82 | - | |
| 83 | - | |
| 84 | -#---[ Release targets ]-------------------------------------------------------- | |
| 85 | - | |
| 86 | -Release: $(BINRLS)/plugins/$(MODULE_NAME).so | |
| 87 | - | |
| 88 | -$(BINRLS)/plugins/$(MODULE_NAME).so: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJRLS)/$(SRC).o) | |
| 89 | - @echo " CCLD `basename $@`" | |
| 90 | - @$(MKDIR) `dirname $@` | |
| 91 | - @$(LD) $(DLL_FLAGS) -Wl,-soname,`basename $@` $(LDFLAGS) -o $@ $^ $(LIBS) | |
| 92 | - | |
| 93 | -#---[ Debug targets ]---------------------------------------------------------- | |
| 94 | - | |
| 95 | -Debug: $(BINDBG)/plugins/$(MODULE_NAME).so | |
| 96 | - | |
| 97 | -$(BINDBG)/plugins/$(MODULE_NAME).so: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJDBG)/$(SRC).o) | |
| 98 | - @echo " CCLD `basename $@`" | |
| 99 | - @$(MKDIR) `dirname $@` | |
| 100 | - @$(LD) $(DLL_FLAGS) -Wl,-soname,`basename $@` $(LDFLAGS) -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(GLIB_LIBS) $(GTK_LIBS) | |
| 101 | - | |
| 102 | -#---[ Misc targets ]----------------------------------------------------------- | |
| 103 | - | |
| 104 | -debug-service: $(BINDBG)/@PACKAGE_NAME@d | |
| 105 | - | |
| 106 | -dbus-glue.h: pw3270dbus.xml | |
| 107 | - @$(DBUSBINDINGTOOL) --mode=glib-server --output=$@ --prefix=pw3270_dbus $^ | |
| 108 | - | |
| 109 | -$(BINDBG)/@PACKAGE_NAME@d: $(foreach SRC, $(basename $(DAEMON_SRC)), $(OBJDBG)/$(SRC).o) | |
| 110 | - @echo " CCLD `basename $@`" | |
| 111 | - @$(MKDIR) `dirname $@` | |
| 112 | - @$(CC) $(CFLAGS) -o $@ $^ $(DBUS_LIBS) $(GLIB_LIBS) $(LIB3270_LIBS) | |
| 113 | - | |
| 114 | -cleandebug-service: clean | |
| 115 | - | |
| 116 | -clean: | |
| 117 | - @rm -fr $(OBJDIR) | |
| 118 | - @rm -fr $(BINDIR) | |
| 119 | - @rm -f dbus-glue.h | |
| 120 | - @find . -name "*~" -exec rm -f {} \; |
src/plugins/3270dbus/daemon.c
| ... | ... | @@ -1,112 +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 <glib.h> | |
| 37 | -#include <dbus/dbus.h> | |
| 38 | -#include <dbus/dbus-glib-lowlevel.h> | |
| 39 | -#include <dbus/dbus-glib.h> | |
| 40 | - | |
| 41 | -#include "daemon.h" | |
| 42 | -#include "dbus-glue.h" | |
| 43 | - | |
| 44 | -/*---[ Globals ]---------------------------------------------------------------------------------*/ | |
| 45 | - | |
| 46 | - static DBusGConnection * connection = NULL; | |
| 47 | - static DBusGProxy * proxy = NULL; | |
| 48 | - static H3270 * hSession = NULL; | |
| 49 | - | |
| 50 | - GMainLoop * main_loop = NULL; | |
| 51 | - | |
| 52 | - | |
| 53 | -/*---[ Implement ]-------------------------------------------------------------------------------*/ | |
| 54 | - | |
| 55 | -static int initialize(void) | |
| 56 | -{ | |
| 57 | - GError * error = NULL; | |
| 58 | - guint result; | |
| 59 | - | |
| 60 | - connection = dbus_g_bus_get_private(DBUS_BUS_SESSION, g_main_context_default(), &error); | |
| 61 | - if(error) | |
| 62 | - { | |
| 63 | - g_message("Error \"%s\" getting session dbus",error->message); | |
| 64 | - g_error_free(error); | |
| 65 | - return -1; | |
| 66 | - } | |
| 67 | - | |
| 68 | - proxy = dbus_g_proxy_new_for_name(connection,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS); | |
| 69 | - | |
| 70 | - org_freedesktop_DBus_request_name(proxy, PW3270_DBUS_SERVICE, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error); | |
| 71 | - | |
| 72 | - pw3270_dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,PW3270_DBUS_SERVICE_PATH); | |
| 73 | - | |
| 74 | - return 0; | |
| 75 | -} | |
| 76 | - | |
| 77 | -int main(int numpar, char *param[]) | |
| 78 | -{ | |
| 79 | - g_type_init (); | |
| 80 | - | |
| 81 | - if (!g_thread_supported ()) | |
| 82 | - g_thread_init (NULL); | |
| 83 | - | |
| 84 | - dbus_g_thread_init (); | |
| 85 | - | |
| 86 | - pw3270_dbus_register_io_handlers(); | |
| 87 | - | |
| 88 | - hSession = lib3270_session_new(""); | |
| 89 | - | |
| 90 | - main_loop = g_main_loop_new (NULL, FALSE); | |
| 91 | - | |
| 92 | - if(initialize()) | |
| 93 | - return -1; | |
| 94 | - | |
| 95 | - g_main_loop_run(main_loop); | |
| 96 | - | |
| 97 | - lib3270_session_free(hSession); | |
| 98 | - | |
| 99 | - return 0; | |
| 100 | -} | |
| 101 | - | |
| 102 | -void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 103 | -{ | |
| 104 | - g_main_loop_quit(main_loop); | |
| 105 | - dbus_g_method_return(context,0); | |
| 106 | -} | |
| 107 | - | |
| 108 | -H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object) | |
| 109 | -{ | |
| 110 | - return hSession; | |
| 111 | -} | |
| 112 | - |
src/plugins/3270dbus/daemon.h
| ... | ... | @@ -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/plugins/3270dbus/gobject.c
| ... | ... | @@ -1,191 +0,0 @@ |
| 1 | -/* | |
| 2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
| 3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
| 4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
| 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 <dbus/dbus.h> | |
| 38 | -#include <dbus/dbus-glib-lowlevel.h> | |
| 39 | -#include <dbus/dbus-glib.h> | |
| 40 | - | |
| 41 | -#include <lib3270/config.h> | |
| 42 | - | |
| 43 | -#include "service.h" | |
| 44 | - | |
| 45 | -/*---[ Globals ]---------------------------------------------------------------------------------*/ | |
| 46 | - | |
| 47 | - | |
| 48 | -/*---[ Implement ]-------------------------------------------------------------------------------*/ | |
| 49 | - | |
| 50 | -G_DEFINE_TYPE(PW3270Dbus, pw3270_dbus, G_TYPE_OBJECT) | |
| 51 | - | |
| 52 | -static void pw3270_dbus_finalize(GObject *object) | |
| 53 | -{ | |
| 54 | - G_OBJECT_CLASS(pw3270_dbus_parent_class)->finalize (object); | |
| 55 | -} | |
| 56 | - | |
| 57 | - | |
| 58 | -static void pw3270_dbus_class_init(PW3270DbusClass *klass) | |
| 59 | -{ | |
| 60 | - GObjectClass *object_class; | |
| 61 | - object_class = G_OBJECT_CLASS (klass); | |
| 62 | - object_class->finalize = pw3270_dbus_finalize; | |
| 63 | -} | |
| 64 | - | |
| 65 | -static void pw3270_dbus_init(PW3270Dbus *object) | |
| 66 | -{ | |
| 67 | - | |
| 68 | -} | |
| 69 | - | |
| 70 | -PW3270Dbus * pw3270_dbus_new(void) | |
| 71 | -{ | |
| 72 | - return g_object_new(PW3270_TYPE_DBUS, NULL); | |
| 73 | -} | |
| 74 | - | |
| 75 | -void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 76 | -{ | |
| 77 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 78 | - dbus_g_method_return(context,PACKAGE_REVISION); | |
| 79 | -} | |
| 80 | - | |
| 81 | -void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context) | |
| 82 | -{ | |
| 83 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 84 | - | |
| 85 | - g_message("Connecting to \"%s\" by remote request",uri); | |
| 86 | - dbus_g_method_return(context,lib3270_connect(pw3270_dbus_get_session_handle(PW3270_DBUS(object)),uri,0)); | |
| 87 | -} | |
| 88 | - | |
| 89 | -void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 90 | -{ | |
| 91 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 92 | - | |
| 93 | - g_message("Disconnecting by remote request"); | |
| 94 | - lib3270_disconnect(pw3270_dbus_get_session_handle(object)); | |
| 95 | - dbus_g_method_return(context,0); | |
| 96 | -} | |
| 97 | - | |
| 98 | -void pw3270_dbus_get_message_id(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 99 | -{ | |
| 100 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 101 | - dbus_g_method_return(context,lib3270_get_program_message(pw3270_dbus_get_session_handle(object))); | |
| 102 | -} | |
| 103 | - | |
| 104 | -GError * pw3270_dbus_get_error_from_errno(int code) | |
| 105 | -{ | |
| 106 | - return g_error_new(ERROR_DOMAIN,code,"%s",g_strerror(code)); | |
| 107 | -} | |
| 108 | - | |
| 109 | -int pw3270_dbus_check_valid_state(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 110 | -{ | |
| 111 | - H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
| 112 | - GError * error = NULL; | |
| 113 | - | |
| 114 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 115 | - | |
| 116 | - if(!lib3270_is_connected(hSession)) | |
| 117 | - { | |
| 118 | - error = pw3270_dbus_get_error_from_errno(ENOTCONN); | |
| 119 | - } | |
| 120 | - else | |
| 121 | - { | |
| 122 | - LIB3270_MESSAGE state = lib3270_get_program_message(hSession); | |
| 123 | - | |
| 124 | - switch(state) | |
| 125 | - { | |
| 126 | - case LIB3270_MESSAGE_NONE: | |
| 127 | - return 0; | |
| 128 | - | |
| 129 | - case LIB3270_MESSAGE_DISCONNECTED: | |
| 130 | - error = pw3270_dbus_get_error_from_errno(ENOTCONN); | |
| 131 | - break; | |
| 132 | - | |
| 133 | - case LIB3270_MESSAGE_MINUS: | |
| 134 | - case LIB3270_MESSAGE_PROTECTED: | |
| 135 | - case LIB3270_MESSAGE_NUMERIC: | |
| 136 | - case LIB3270_MESSAGE_OVERFLOW: | |
| 137 | - case LIB3270_MESSAGE_INHIBIT: | |
| 138 | - case LIB3270_MESSAGE_KYBDLOCK: | |
| 139 | - case LIB3270_MESSAGE_X: | |
| 140 | - error = g_error_new(ERROR_DOMAIN,-1,_( "State %04d can't accept requests" ),state); | |
| 141 | - break; | |
| 142 | - | |
| 143 | - case LIB3270_MESSAGE_SYSWAIT: | |
| 144 | - case LIB3270_MESSAGE_TWAIT: | |
| 145 | - case LIB3270_MESSAGE_CONNECTED: | |
| 146 | - case LIB3270_MESSAGE_AWAITING_FIRST: | |
| 147 | - error = pw3270_dbus_get_error_from_errno(EBUSY); | |
| 148 | - break; | |
| 149 | - | |
| 150 | - case LIB3270_MESSAGE_RESOLVING: | |
| 151 | - case LIB3270_MESSAGE_CONNECTING: | |
| 152 | - error = g_error_new(ERROR_DOMAIN,EINPROGRESS,_( "Connecting to host" )); | |
| 153 | - | |
| 154 | - case LIB3270_MESSAGE_USER: | |
| 155 | - error = g_error_new(ERROR_DOMAIN,-1,_( "Unexpected state %04d" ),state); | |
| 156 | - } | |
| 157 | - } | |
| 158 | - | |
| 159 | - if(error) | |
| 160 | - { | |
| 161 | - dbus_g_method_return_error(context,error); | |
| 162 | - g_error_free(error); | |
| 163 | - return -1; | |
| 164 | - } | |
| 165 | - | |
| 166 | - return 0; | |
| 167 | -} | |
| 168 | - | |
| 169 | -void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 170 | -{ | |
| 171 | - char * text; | |
| 172 | - gchar * utftext; | |
| 173 | - H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
| 174 | - | |
| 175 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 176 | - | |
| 177 | - if(pw3270_dbus_check_valid_state(object,context)) | |
| 178 | - return; | |
| 179 | - | |
| 180 | - text = lib3270_get_text(hSession,0,-1); | |
| 181 | - | |
| 182 | - utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_charset(hSession),"?",NULL,NULL,NULL); | |
| 183 | - | |
| 184 | - lib3270_free(text); | |
| 185 | - | |
| 186 | - dbus_g_method_return(context,utftext); | |
| 187 | - | |
| 188 | - g_free(utftext); | |
| 189 | - | |
| 190 | -} | |
| 191 | - |
src/plugins/3270dbus/iocallback.c
| ... | ... | @@ -1,364 +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 iocallback.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 | - */ | |
| 31 | - | |
| 32 | -#if defined(_WIN32) /*[*/ | |
| 33 | - #include <windows.h> | |
| 34 | -#elif defined(__APPLE__) | |
| 35 | - #include <poll.h> | |
| 36 | - #include <string.h> | |
| 37 | -#else | |
| 38 | - #include <poll.h> | |
| 39 | - #include <string.h> | |
| 40 | -#endif /*]*/ | |
| 41 | - | |
| 42 | -#include <stdio.h> | |
| 43 | -#include <glib.h> | |
| 44 | -#include "daemon.h" | |
| 45 | - | |
| 46 | -static int static_CallAndWait(int(*callback)(H3270 *session, void *), H3270 *session, void *parm); | |
| 47 | -static void static_RemoveSource(void *id); | |
| 48 | - | |
| 49 | -#ifdef WIN32 | |
| 50 | -static void * static_AddInput(HANDLE source, H3270 *session, void (*fn)(H3270 *session)); | |
| 51 | -static void * static_AddExcept(HANDLE source, H3270 *session, void (*fn)(H3270 *session)); | |
| 52 | -#else | |
| 53 | -static void * static_AddInput(int source, H3270 *session, void (*fn)(H3270 *session)); | |
| 54 | -static void * static_AddExcept(int source, H3270 *session, void (*fn)(H3270 *session)); | |
| 55 | -#endif // WIN32 | |
| 56 | - | |
| 57 | -static void * static_AddTimeOut(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session)); | |
| 58 | -static void static_RemoveTimeOut(void * timer); | |
| 59 | -static int static_Sleep(H3270 *hSession, int seconds); | |
| 60 | -static int static_RunPendingEvents(H3270 *hSession, int wait); | |
| 61 | - | |
| 62 | -static gboolean IO_prepare(GSource *source, gint *timeout); | |
| 63 | -static gboolean IO_check(GSource *source); | |
| 64 | -static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer user_data); | |
| 65 | -static void IO_finalize(GSource *source); /* Can be NULL */ | |
| 66 | -static gboolean IO_closure(gpointer data); | |
| 67 | - | |
| 68 | -/*---[ Structs ]-------------------------------------------------------------------------------------------*/ | |
| 69 | - | |
| 70 | - typedef struct _IO_Source | |
| 71 | - { | |
| 72 | - GSource gsrc; | |
| 73 | - GPollFD poll; | |
| 74 | -#if defined(_WIN32) | |
| 75 | - HANDLE source; | |
| 76 | -#else | |
| 77 | - int source; | |
| 78 | -#endif // WIN32 | |
| 79 | - void (*fn)(H3270 *session); | |
| 80 | - H3270 *session; | |
| 81 | - } IO_Source; | |
| 82 | - | |
| 83 | - typedef struct _timer | |
| 84 | - { | |
| 85 | - unsigned char remove; | |
| 86 | - void (*fn)(H3270 *session); | |
| 87 | - H3270 *session; | |
| 88 | - } TIMER; | |
| 89 | - | |
| 90 | - static GSourceFuncs IOSources = | |
| 91 | - { | |
| 92 | - IO_prepare, | |
| 93 | - IO_check, | |
| 94 | - IO_dispatch, | |
| 95 | - IO_finalize, | |
| 96 | - IO_closure, | |
| 97 | - NULL | |
| 98 | - }; | |
| 99 | - | |
| 100 | -/*---[ Implement ]-----------------------------------------------------------------------------------------*/ | |
| 101 | - | |
| 102 | -#ifdef WIN32 | |
| 103 | -static void * AddSource(HANDLE source, H3270 *session, gushort events, void (*fn)(H3270 *session)) | |
| 104 | -#else | |
| 105 | -static void * AddSource(int source, H3270 *session, gushort events, void (*fn)(H3270 *session)) | |
| 106 | -#endif // WIN32 | |
| 107 | -{ | |
| 108 | - IO_Source *src = (IO_Source *) g_source_new(&IOSources,sizeof(IO_Source)); | |
| 109 | - | |
| 110 | - src->source = source; | |
| 111 | - src->fn = fn; | |
| 112 | - src->poll.fd = (int) source; | |
| 113 | - src->poll.events = events; | |
| 114 | - src->session = session; | |
| 115 | - | |
| 116 | - g_source_attach((GSource *) src,NULL); | |
| 117 | - g_source_add_poll((GSource *) src,&src->poll); | |
| 118 | - | |
| 119 | - return src; | |
| 120 | -} | |
| 121 | - | |
| 122 | -#ifdef WIN32 | |
| 123 | -static void * static_AddInput(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | |
| 124 | -#else | |
| 125 | -static void * static_AddInput(int source, H3270 *session, void (*fn)(H3270 *session)) | |
| 126 | -#endif // WIN32 | |
| 127 | -{ | |
| 128 | - return AddSource(source,session,G_IO_IN|G_IO_HUP|G_IO_ERR,fn); | |
| 129 | -} | |
| 130 | - | |
| 131 | -static void static_RemoveSource(void *id) | |
| 132 | -{ | |
| 133 | - if(id) | |
| 134 | - g_source_destroy((GSource *) id); | |
| 135 | -} | |
| 136 | - | |
| 137 | -#if defined(WIN32) | |
| 138 | -static void * static_AddExcept(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | |
| 139 | -{ | |
| 140 | - return 0; | |
| 141 | -} | |
| 142 | -#else | |
| 143 | -static void * static_AddExcept(int source, H3270 *session, void (*fn)(H3270 *session)) | |
| 144 | -{ | |
| 145 | - return AddSource(source,session,G_IO_HUP|G_IO_ERR,fn); | |
| 146 | -} | |
| 147 | -#endif // WIN32 | |
| 148 | - | |
| 149 | -static gboolean do_timer(TIMER *t) | |
| 150 | -{ | |
| 151 | - if(!t->remove) | |
| 152 | - t->fn(t->session); | |
| 153 | - return FALSE; | |
| 154 | -} | |
| 155 | - | |
| 156 | -static void * static_AddTimeOut(unsigned long interval, H3270 *session, void (*proc)(H3270 *session)) | |
| 157 | -{ | |
| 158 | - TIMER *t = g_malloc0(sizeof(TIMER)); | |
| 159 | - | |
| 160 | - t->fn = proc; | |
| 161 | - t->session = session; | |
| 162 | - | |
| 163 | - g_timeout_add_full(G_PRIORITY_DEFAULT, (guint) interval, (GSourceFunc) do_timer, t, g_free); | |
| 164 | - | |
| 165 | - return t; | |
| 166 | -} | |
| 167 | - | |
| 168 | -static void static_RemoveTimeOut(void * timer) | |
| 169 | -{ | |
| 170 | - ((TIMER *) timer)->remove++; | |
| 171 | -} | |
| 172 | - | |
| 173 | -static gboolean IO_prepare(GSource *source, gint *timeout) | |
| 174 | -{ | |
| 175 | - /* | |
| 176 | - * Called before all the file descriptors are polled. | |
| 177 | - * If the source can determine that it is ready here | |
| 178 | - * (without waiting for the results of the poll() call) | |
| 179 | - * it should return TRUE. | |
| 180 | - * | |
| 181 | - * It can also return a timeout_ value which should be the maximum | |
| 182 | - * timeout (in milliseconds) which should be passed to the poll() call. | |
| 183 | - * The actual timeout used will be -1 if all sources returned -1, | |
| 184 | - * or it will be the minimum of all the timeout_ values | |
| 185 | - * returned which were >= 0. | |
| 186 | - * | |
| 187 | - */ | |
| 188 | - return 0; | |
| 189 | -} | |
| 190 | - | |
| 191 | -static gboolean IO_check(GSource *source) | |
| 192 | -{ | |
| 193 | - /* | |
| 194 | - * Called after all the file descriptors are polled. | |
| 195 | - * The source should return TRUE if it is ready to be dispatched. | |
| 196 | - * Note that some time may have passed since the previous prepare | |
| 197 | - * function was called, so the source should be checked again here. | |
| 198 | - * | |
| 199 | - */ | |
| 200 | -#if defined(_WIN32) /*[*/ | |
| 201 | - | |
| 202 | - if(WaitForSingleObject(((IO_Source *) source)->source,0) == WAIT_OBJECT_0) | |
| 203 | - return TRUE; | |
| 204 | - | |
| 205 | -#else /*][*/ | |
| 206 | - | |
| 207 | - struct pollfd fds; | |
| 208 | - | |
| 209 | - memset(&fds,0,sizeof(fds)); | |
| 210 | - | |
| 211 | - fds.fd = ((IO_Source *) source)->poll.fd; | |
| 212 | - fds.events = ((IO_Source *) source)->poll.events; | |
| 213 | - | |
| 214 | - if(poll(&fds,1,0) > 0) | |
| 215 | - return TRUE; | |
| 216 | - | |
| 217 | -#endif /*]*/ | |
| 218 | - | |
| 219 | - return FALSE; | |
| 220 | -} | |
| 221 | - | |
| 222 | -static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) | |
| 223 | -{ | |
| 224 | - /* | |
| 225 | - * Called to dispatch the event source, | |
| 226 | - * after it has returned TRUE in either its prepare or its check function. | |
| 227 | - * The dispatch function is passed in a callback function and data. | |
| 228 | - * The callback function may be NULL if the source was never connected | |
| 229 | - * to a callback using g_source_set_callback(). The dispatch function | |
| 230 | - * should call the callback function with user_data and whatever additional | |
| 231 | - * parameters are needed for this type of event source. | |
| 232 | - */ | |
| 233 | - ((IO_Source *) source)->fn(((IO_Source *) source)->session); | |
| 234 | - return TRUE; | |
| 235 | -} | |
| 236 | - | |
| 237 | -static void IO_finalize(GSource *source) | |
| 238 | -{ | |
| 239 | - | |
| 240 | -} | |
| 241 | - | |
| 242 | -static gboolean IO_closure(gpointer data) | |
| 243 | -{ | |
| 244 | - return 0; | |
| 245 | -} | |
| 246 | - | |
| 247 | -struct bgParameter | |
| 248 | -{ | |
| 249 | - gboolean running; | |
| 250 | - gboolean timer; | |
| 251 | - H3270 *session; | |
| 252 | - int rc; | |
| 253 | - int(*callback)(H3270 *session, void *); | |
| 254 | - void *parm; | |
| 255 | - | |
| 256 | -}; | |
| 257 | - | |
| 258 | -gpointer BgCall(struct bgParameter *p) | |
| 259 | -{ | |
| 260 | -// trace("%s starts",__FUNCTION__); | |
| 261 | - p->rc = p->callback(p->session, p->parm); | |
| 262 | - p->running = FALSE; | |
| 263 | -// trace("%s ends",__FUNCTION__); | |
| 264 | - return 0; | |
| 265 | -} | |
| 266 | - | |
| 267 | -static gboolean wait_for_thread(struct bgParameter *p) | |
| 268 | -{ | |
| 269 | - if(!p->running) | |
| 270 | - { | |
| 271 | - p->timer = 0; | |
| 272 | - return FALSE; | |
| 273 | - } | |
| 274 | - return TRUE; | |
| 275 | -} | |
| 276 | - | |
| 277 | -static int static_CallAndWait(int(*callback)(H3270 *session, void *), H3270 *session, void *parm) | |
| 278 | -{ | |
| 279 | - struct bgParameter p = { TRUE, TRUE, session, -1, callback, parm }; | |
| 280 | - GThread * thread; | |
| 281 | - | |
| 282 | -// trace("Starting auxiliary thread for callback %p",callback); | |
| 283 | - | |
| 284 | - p.running = TRUE; | |
| 285 | - p.timer = TRUE; | |
| 286 | - | |
| 287 | - thread = g_thread_create( (GThreadFunc) BgCall, &p, 0, NULL); | |
| 288 | - | |
| 289 | - if(!thread) | |
| 290 | - { | |
| 291 | - g_error("Can't start background thread"); | |
| 292 | - return -1; | |
| 293 | - } | |
| 294 | - | |
| 295 | - g_timeout_add(50,(GSourceFunc) wait_for_thread,(gpointer) &p); | |
| 296 | - | |
| 297 | - while(p.timer) | |
| 298 | - g_main_context_iteration(g_main_loop_get_context(main_loop),TRUE); | |
| 299 | - | |
| 300 | - return p.rc; | |
| 301 | -} | |
| 302 | - | |
| 303 | -static int static_Sleep(H3270 *hSession, int seconds) | |
| 304 | -{ | |
| 305 | - time_t end = time(0) + seconds; | |
| 306 | - | |
| 307 | - while(time(0) < end) | |
| 308 | - g_main_iteration(TRUE); | |
| 309 | - | |
| 310 | - return 0; | |
| 311 | -} | |
| 312 | - | |
| 313 | -static int static_RunPendingEvents(H3270 *hSession, int wait) | |
| 314 | -{ | |
| 315 | - GMainContext *context = g_main_loop_get_context(main_loop); | |
| 316 | - int rc = 0; | |
| 317 | - while(g_main_context_pending(context)) | |
| 318 | - { | |
| 319 | - rc = 1; | |
| 320 | - g_main_context_iteration(context,FALSE); | |
| 321 | - } | |
| 322 | - | |
| 323 | - if(wait) | |
| 324 | - g_main_context_iteration(context,TRUE); | |
| 325 | - | |
| 326 | - return rc; | |
| 327 | -} | |
| 328 | - | |
| 329 | -static void beep(H3270 *session) | |
| 330 | -{ | |
| 331 | -} | |
| 332 | - | |
| 333 | -void pw3270_dbus_register_io_handlers(void) | |
| 334 | -{ | |
| 335 | - static const struct lib3270_callbacks hdl = | |
| 336 | - { | |
| 337 | - sizeof(struct lib3270_callbacks), | |
| 338 | - | |
| 339 | - static_AddTimeOut, | |
| 340 | - static_RemoveTimeOut, | |
| 341 | - | |
| 342 | - static_AddInput, | |
| 343 | - static_RemoveSource, | |
| 344 | - | |
| 345 | - static_AddExcept, | |
| 346 | - | |
| 347 | -#ifdef G_THREADS_ENABLED | |
| 348 | - static_CallAndWait, | |
| 349 | -#else | |
| 350 | - NULL, | |
| 351 | -#endif | |
| 352 | - | |
| 353 | - static_Sleep, | |
| 354 | - static_RunPendingEvents, | |
| 355 | - beep | |
| 356 | - | |
| 357 | - }; | |
| 358 | - | |
| 359 | - if(lib3270_register_handlers(&hdl)) | |
| 360 | - { | |
| 361 | - g_error("%s","Can't set lib3270 I/O handlers"); | |
| 362 | - } | |
| 363 | - | |
| 364 | -} |
src/plugins/3270dbus/main.c
| ... | ... | @@ -1,114 +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 | - * 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 | -#include <glib.h> | |
| 33 | -#include <dbus/dbus.h> | |
| 34 | -#include <dbus/dbus-glib-lowlevel.h> | |
| 35 | -#include <dbus/dbus-glib.h> | |
| 36 | - | |
| 37 | -#include <pw3270.h> | |
| 38 | -#include <pw3270/plugin.h> | |
| 39 | - | |
| 40 | -#include "service.h" | |
| 41 | -#include "dbus-glue.h" | |
| 42 | - | |
| 43 | -#include <gtk/gtk.h> | |
| 44 | - | |
| 45 | -/*---[ Globals ]---------------------------------------------------------------------------------*/ | |
| 46 | - | |
| 47 | - static DBusGConnection * connection = NULL; | |
| 48 | - static DBusGProxy * proxy = NULL; | |
| 49 | - | |
| 50 | -/*---[ Implement ]-------------------------------------------------------------------------------*/ | |
| 51 | - | |
| 52 | - LIB3270_EXPORT int pw3270_plugin_init(GtkWidget *window) | |
| 53 | - { | |
| 54 | - | |
| 55 | - GError * error = NULL; | |
| 56 | - guint result; | |
| 57 | - | |
| 58 | - connection = dbus_g_bus_get_private(DBUS_BUS_SESSION, g_main_context_default(), &error); | |
| 59 | - if(error) | |
| 60 | - { | |
| 61 | - GtkWidget *dialog = gtk_message_dialog_new( | |
| 62 | - GTK_WINDOW(window), | |
| 63 | - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 64 | - GTK_MESSAGE_ERROR, | |
| 65 | - GTK_BUTTONS_OK, | |
| 66 | - _( "Can't connect to DBUS server" )); | |
| 67 | - | |
| 68 | - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); | |
| 69 | - | |
| 70 | - g_message("Error \"%s\" getting session dbus",error->message); | |
| 71 | - | |
| 72 | - g_error_free(error); | |
| 73 | - | |
| 74 | - gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 75 | - gtk_widget_destroy(dialog); | |
| 76 | - | |
| 77 | - return -1; | |
| 78 | - } | |
| 79 | - | |
| 80 | - | |
| 81 | - proxy = dbus_g_proxy_new_for_name(connection,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS); | |
| 82 | - | |
| 83 | - org_freedesktop_DBus_request_name(proxy, PW3270_DBUS_SERVICE, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error); | |
| 84 | - if(error) | |
| 85 | - { | |
| 86 | - GtkWidget *dialog = gtk_message_dialog_new( | |
| 87 | - GTK_WINDOW(window), | |
| 88 | - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 89 | - GTK_MESSAGE_ERROR, | |
| 90 | - GTK_BUTTONS_OK, | |
| 91 | - _( "Can't get DBUS object name" )); | |
| 92 | - | |
| 93 | - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); | |
| 94 | - | |
| 95 | - g_message("Error \"%s\" requesting DBUS name",error->message); | |
| 96 | - | |
| 97 | - g_error_free(error); | |
| 98 | - | |
| 99 | - gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 100 | - gtk_widget_destroy(dialog); | |
| 101 | - | |
| 102 | - return -1; | |
| 103 | - } | |
| 104 | - | |
| 105 | - pw3270_dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,PW3270_DBUS_SERVICE_PATH); | |
| 106 | - | |
| 107 | - return 0; | |
| 108 | - } | |
| 109 | - | |
| 110 | - LIB3270_EXPORT int pw3270_plugin_deinit(GtkWidget *window) | |
| 111 | - { | |
| 112 | - | |
| 113 | - return 0; | |
| 114 | - } |
src/plugins/3270dbus/misc.c
| ... | ... | @@ -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 *proxy,GType object_type,const DBusGObjectInfo *info,const gchar *path) | |
| 41 | -{ | |
| 42 | - GObject *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/plugins/3270dbus/pw3270dbus.cbp
| ... | ... | @@ -1,71 +0,0 @@ |
| 1 | -<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | |
| 2 | -<CodeBlocks_project_file> | |
| 3 | - <FileVersion major="1" minor="6" /> | |
| 4 | - <Project> | |
| 5 | - <Option title="pw3270dbus" /> | |
| 6 | - <Option makefile_is_custom="1" /> | |
| 7 | - <Option pch_mode="2" /> | |
| 8 | - <Option compiler="gcc" /> | |
| 9 | - <Build> | |
| 10 | - <Target title="Debug"> | |
| 11 | - <Option output=".bin/Debug/pw3270dbus" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" /> | |
| 12 | - <Option object_output=".obj/Debug/" /> | |
| 13 | - <Option type="3" /> | |
| 14 | - <Option compiler="gcc" /> | |
| 15 | - <Compiler> | |
| 16 | - <Add option="-g" /> | |
| 17 | - </Compiler> | |
| 18 | - </Target> | |
| 19 | - <Target title="Release"> | |
| 20 | - <Option output=".bin/Release/pw3270dbus" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" /> | |
| 21 | - <Option object_output=".obj/Release/" /> | |
| 22 | - <Option type="3" /> | |
| 23 | - <Option compiler="gcc" /> | |
| 24 | - <Compiler> | |
| 25 | - <Add option="-O2" /> | |
| 26 | - </Compiler> | |
| 27 | - <Linker> | |
| 28 | - <Add option="-s" /> | |
| 29 | - </Linker> | |
| 30 | - </Target> | |
| 31 | - <Target title="debug-service"> | |
| 32 | - <Option output=".bin/Debug/pw3270d" prefix_auto="1" extension_auto="1" /> | |
| 33 | - <Option object_output=".obj/Debug/" /> | |
| 34 | - <Option type="1" /> | |
| 35 | - <Option compiler="gcc" /> | |
| 36 | - <Compiler> | |
| 37 | - <Add option="-g" /> | |
| 38 | - </Compiler> | |
| 39 | - </Target> | |
| 40 | - </Build> | |
| 41 | - <Compiler> | |
| 42 | - <Add option="-Wall" /> | |
| 43 | - </Compiler> | |
| 44 | - <Unit filename="Makefile.in" /> | |
| 45 | - <Unit filename="daemon.c"> | |
| 46 | - <Option compilerVar="CC" /> | |
| 47 | - </Unit> | |
| 48 | - <Unit filename="daemon.h" /> | |
| 49 | - <Unit filename="dbus-glue.h" /> | |
| 50 | - <Unit filename="globals.h" /> | |
| 51 | - <Unit filename="gobject.c"> | |
| 52 | - <Option compilerVar="CC" /> | |
| 53 | - </Unit> | |
| 54 | - <Unit filename="iocallback.c"> | |
| 55 | - <Option compilerVar="CC" /> | |
| 56 | - </Unit> | |
| 57 | - <Unit filename="main.c"> | |
| 58 | - <Option compilerVar="CC" /> | |
| 59 | - </Unit> | |
| 60 | - <Unit filename="misc.c"> | |
| 61 | - <Option compilerVar="CC" /> | |
| 62 | - </Unit> | |
| 63 | - <Unit filename="pw3270dbus.xml" /> | |
| 64 | - <Unit filename="service.h" /> | |
| 65 | - <Unit filename="test.sh" /> | |
| 66 | - <Extensions> | |
| 67 | - <code_completion /> | |
| 68 | - <debugger /> | |
| 69 | - </Extensions> | |
| 70 | - </Project> | |
| 71 | -</CodeBlocks_project_file> |
src/plugins/3270dbus/pw3270dbus.xml
| ... | ... | @@ -1,30 +0,0 @@ |
| 1 | -<?xml version="1.0" encoding="UTF-8" ?> | |
| 2 | -<node name="/br/com/bb/pw3270"> | |
| 3 | - <interface name="br.com.bb.pw3270"> | |
| 4 | - <method name="getRevision"> | |
| 5 | - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
| 6 | - <arg type="s" name="revision" direction="out" /> | |
| 7 | - </method> | |
| 8 | - <method name="quit"> | |
| 9 | - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
| 10 | - <arg type="i" name="result" direction="out" /> | |
| 11 | - </method> | |
| 12 | - <method name="connect"> | |
| 13 | - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
| 14 | - <arg type="s" name="uri" direction="in" /> | |
| 15 | - <arg type="i" name="result" direction="out" /> | |
| 16 | - </method> | |
| 17 | - <method name="disconnect"> | |
| 18 | - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
| 19 | - <arg type="i" name="result" direction="out" /> | |
| 20 | - </method> | |
| 21 | - <method name="getMessageID"> | |
| 22 | - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
| 23 | - <arg type="i" name="status" direction="out" /> | |
| 24 | - </method> | |
| 25 | - <method name="getScreenContents"> | |
| 26 | - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
| 27 | - <arg type="s" name="contents" direction="out" /> | |
| 28 | - </method> | |
| 29 | - </interface> | |
| 30 | -</node> |
src/plugins/3270dbus/service.h
| ... | ... | @@ -1,80 +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_DBUS_SERVICE_PATH "/br/com/bb/pw3270" | |
| 42 | - #define PW3270_DBUS_SERVICE "br.com.bb.pw3270" | |
| 43 | - | |
| 44 | - #define PW3270_TYPE_DBUS (pw3270_dbus_get_type ()) | |
| 45 | - #define PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PW3270_TYPE_DBUS, PW3270Dbus)) | |
| 46 | - #define PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_DBUS, PW3270DbusClass)) | |
| 47 | - #define IS_PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PW3270_TYPE_DBUS)) | |
| 48 | - #define IS_PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_DBUS)) | |
| 49 | - #define PW3270_DBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_DBUS, PW3270DbusClass)) | |
| 50 | - | |
| 51 | - G_BEGIN_DECLS | |
| 52 | - | |
| 53 | - typedef struct _PW3270Dbus PW3270Dbus; | |
| 54 | - typedef struct _PW3270DbusClass PW3270DbusClass; | |
| 55 | - | |
| 56 | - struct _PW3270Dbus | |
| 57 | - { | |
| 58 | - GObject parent; | |
| 59 | - }; | |
| 60 | - | |
| 61 | - struct _PW3270DbusClass | |
| 62 | - { | |
| 63 | - GObjectClass parent; | |
| 64 | - }; | |
| 65 | - | |
| 66 | - PW3270Dbus * pw3270_dbus_new (void); | |
| 67 | - GType pw3270_dbus_get_type (void); | |
| 68 | - | |
| 69 | - void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 70 | - void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 71 | - void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context); | |
| 72 | - void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 73 | - void pw3270_dbus_get_message_id(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 74 | - void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 75 | - H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object); | |
| 76 | - GError * pw3270_dbus_get_error_from_errno(int code); | |
| 77 | - | |
| 78 | - G_END_DECLS | |
| 79 | - | |
| 80 | -#endif // _PW3270_DBUS_SERVICE_H |
src/plugins/3270dbus/test.sh
| ... | ... | @@ -1,34 +0,0 @@ |
| 1 | -#!/bin/bash | |
| 2 | - | |
| 3 | -case $1 in | |
| 4 | - | |
| 5 | - revision) | |
| 6 | - dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.getRevision | |
| 7 | - ;; | |
| 8 | - | |
| 9 | - message) | |
| 10 | - dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.getProgramMessage | |
| 11 | - ;; | |
| 12 | - | |
| 13 | - connect) | |
| 14 | - dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.connect string:$2 | |
| 15 | - ;; | |
| 16 | - | |
| 17 | - disconnect) | |
| 18 | - dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.disconnect | |
| 19 | - ;; | |
| 20 | - | |
| 21 | - quit) | |
| 22 | - dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.quit | |
| 23 | - ;; | |
| 24 | - | |
| 25 | - get) | |
| 26 | - dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.getScreenContents | |
| 27 | - ;; | |
| 28 | - | |
| 29 | - *) | |
| 30 | - dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.getRevision | |
| 31 | - ;; | |
| 32 | - | |
| 33 | -esac | |
| 34 | - |
| ... | ... | @@ -0,0 +1,120 @@ |
| 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 | +# Contatos: | |
| 22 | +# | |
| 23 | +# perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 24 | +# erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) | |
| 25 | +# licinio@bb.com.br (Licínio Luis Branco) | |
| 26 | +# kraucer@bb.com.br (Kraucer Fernandes Mazuco) | |
| 27 | +# | |
| 28 | + | |
| 29 | +#---[ Sources ]---------------------------------------------------------------- | |
| 30 | + | |
| 31 | +MODULE_NAME=dbus3270 | |
| 32 | +DEPENDS=Makefile dbus-glue.h | |
| 33 | +PLUGIN_SRC=main.c gobject.c misc.c | |
| 34 | +DAEMON_SRC=daemon.c gobject.c iocallback.c misc.c | |
| 35 | + | |
| 36 | +#---[ Paths ]------------------------------------------------------------------ | |
| 37 | + | |
| 38 | +ROOTDIR ?= . | |
| 39 | +OBJDIR ?= $(ROOTDIR)/.obj | |
| 40 | +BINDIR ?= $(ROOTDIR)/.bin | |
| 41 | +BINDBG ?= $(BINDIR)/Debug | |
| 42 | +BINRLS ?= $(BINDIR)/Release | |
| 43 | + | |
| 44 | +OBJDBG = $(OBJDIR)/Debug | |
| 45 | +OBJRLS = $(OBJDIR)/Release | |
| 46 | +OBJEXT = o | |
| 47 | + | |
| 48 | +#---[ Tools ]------------------------------------------------------------------ | |
| 49 | + | |
| 50 | +MKDIR=@MKDIR_P@ | |
| 51 | +CC=@CC@ | |
| 52 | +LD=@CC@ | |
| 53 | +DBUSBINDINGTOOL=@DBUSBINDINGTOOL@ | |
| 54 | + | |
| 55 | +#---[ Flags ]------------------------------------------------------------------ | |
| 56 | + | |
| 57 | +DLL_FLAGS=-shared | |
| 58 | +DLL_CFLAGS=@DLL_CFLAGS@ | |
| 59 | +DEBUG_CFLAGS=-DDEBUG=1 -g -Wall | |
| 60 | + | |
| 61 | +LIB3270_CFLAGS ?= `pkg-config --cflags lib3270` | |
| 62 | +DBUS_CFLAGS=@DBUS_CFLAGS@ | |
| 63 | +GLIB_CFLAGS=@GLIB_CFLAGS@ | |
| 64 | +GTK_CFLAGS=@GTK_CFLAGS@ | |
| 65 | + | |
| 66 | +LIB3270_LIBS ?= `pkg-config --libs lib3270` | |
| 67 | +DBUS_LIBS=@DBUS_LIBS@ | |
| 68 | +GLIB_LIBS=@GLIB_LIBS@ | |
| 69 | +GTK_LIBS=@GTK_LIBS@ | |
| 70 | + | |
| 71 | +#---[ Rules ]------------------------------------------------------------------ | |
| 72 | + | |
| 73 | +$(OBJDBG)/%.o: %.c $(DEPENDS) | |
| 74 | + @echo " CC `basename $@`" | |
| 75 | + @$(MKDIR) `dirname $@` | |
| 76 | + @$(CC) $(CFLAGS) $(DLL_CFLAGS) $(DBUS_CFLAGS) $(GLIB_CFLAGS) $(GTK_CFLAGS) $(DEBUG_CFLAGS) $(LIB3270_CFLAGS) -o $@ -c $< | |
| 77 | + | |
| 78 | +$(OBJRLS)/%.o: %.c $(DEPENDS) | |
| 79 | + @echo " CC `basename $@`" | |
| 80 | + @$(MKDIR) `dirname $@` | |
| 81 | + @$(CC) $(CFLAGS) $(DLL_CFLAGS) $(DBUS_CFLAGS) $(GLIB_CFLAGS) $(GTK_CFLAGS) $(LIB3270_CFLAGS) -o $@ -c $< | |
| 82 | + | |
| 83 | + | |
| 84 | +#---[ Release targets ]-------------------------------------------------------- | |
| 85 | + | |
| 86 | +Release: $(BINRLS)/plugins/$(MODULE_NAME).so | |
| 87 | + | |
| 88 | +$(BINRLS)/plugins/$(MODULE_NAME).so: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJRLS)/$(SRC).o) | |
| 89 | + @echo " CCLD `basename $@`" | |
| 90 | + @$(MKDIR) `dirname $@` | |
| 91 | + @$(LD) $(DLL_FLAGS) -Wl,-soname,`basename $@` $(LDFLAGS) -o $@ $^ $(LIBS) | |
| 92 | + | |
| 93 | +#---[ Debug targets ]---------------------------------------------------------- | |
| 94 | + | |
| 95 | +Debug: $(BINDBG)/plugins/$(MODULE_NAME).so | |
| 96 | + | |
| 97 | +$(BINDBG)/plugins/$(MODULE_NAME).so: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJDBG)/$(SRC).o) | |
| 98 | + @echo " CCLD `basename $@`" | |
| 99 | + @$(MKDIR) `dirname $@` | |
| 100 | + @$(LD) $(DLL_FLAGS) -Wl,-soname,`basename $@` $(LDFLAGS) -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(GLIB_LIBS) $(GTK_LIBS) | |
| 101 | + | |
| 102 | +#---[ Misc targets ]----------------------------------------------------------- | |
| 103 | + | |
| 104 | +debug-service: $(BINDBG)/@PACKAGE_NAME@d | |
| 105 | + | |
| 106 | +dbus-glue.h: pw3270dbus.xml | |
| 107 | + @$(DBUSBINDINGTOOL) --mode=glib-server --output=$@ --prefix=pw3270_dbus $^ | |
| 108 | + | |
| 109 | +$(BINDBG)/@PACKAGE_NAME@d: $(foreach SRC, $(basename $(DAEMON_SRC)), $(OBJDBG)/$(SRC).o) | |
| 110 | + @echo " CCLD `basename $@`" | |
| 111 | + @$(MKDIR) `dirname $@` | |
| 112 | + @$(CC) $(CFLAGS) -o $@ $^ $(DBUS_LIBS) $(GLIB_LIBS) $(LIB3270_LIBS) | |
| 113 | + | |
| 114 | +cleandebug-service: clean | |
| 115 | + | |
| 116 | +clean: | |
| 117 | + @rm -fr $(OBJDIR) | |
| 118 | + @rm -fr $(BINDIR) | |
| 119 | + @rm -f dbus-glue.h | |
| 120 | + @find . -name "*~" -exec rm -f {} \; | ... | ... |
| ... | ... | @@ -0,0 +1,118 @@ |
| 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 <glib.h> | |
| 37 | +#include <dbus/dbus.h> | |
| 38 | +#include <dbus/dbus-glib-lowlevel.h> | |
| 39 | +#include <dbus/dbus-glib.h> | |
| 40 | + | |
| 41 | +#include "daemon.h" | |
| 42 | +#include "dbus-glue.h" | |
| 43 | + | |
| 44 | +/*---[ Globals ]---------------------------------------------------------------------------------*/ | |
| 45 | + | |
| 46 | + static DBusGConnection * connection = NULL; | |
| 47 | + static DBusGProxy * proxy = NULL; | |
| 48 | + static H3270 * hSession = NULL; | |
| 49 | + | |
| 50 | + GMainLoop * main_loop = NULL; | |
| 51 | + | |
| 52 | + | |
| 53 | +/*---[ Implement ]-------------------------------------------------------------------------------*/ | |
| 54 | + | |
| 55 | +static int initialize(void) | |
| 56 | +{ | |
| 57 | + GError * error = NULL; | |
| 58 | + guint result; | |
| 59 | + | |
| 60 | + connection = dbus_g_bus_get_private(DBUS_BUS_SESSION, g_main_context_default(), &error); | |
| 61 | + if(error) | |
| 62 | + { | |
| 63 | + g_message("Error \"%s\" getting session dbus",error->message); | |
| 64 | + g_error_free(error); | |
| 65 | + return -1; | |
| 66 | + } | |
| 67 | + | |
| 68 | + proxy = dbus_g_proxy_new_for_name(connection,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS); | |
| 69 | + | |
| 70 | + org_freedesktop_DBus_request_name(proxy, PW3270_DBUS_SERVICE, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error); | |
| 71 | + | |
| 72 | + pw3270_dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,PW3270_DBUS_SERVICE_PATH); | |
| 73 | + | |
| 74 | + return 0; | |
| 75 | +} | |
| 76 | + | |
| 77 | +static void loghandler(H3270 *session, const char *module, int rc, const char *fmt, va_list args) | |
| 78 | +{ | |
| 79 | + g_logv(module,rc ? G_LOG_LEVEL_WARNING : G_LOG_LEVEL_MESSAGE, fmt, args); | |
| 80 | +} | |
| 81 | + | |
| 82 | +int main(int numpar, char *param[]) | |
| 83 | +{ | |
| 84 | + g_type_init (); | |
| 85 | + | |
| 86 | + if (!g_thread_supported ()) | |
| 87 | + g_thread_init (NULL); | |
| 88 | + | |
| 89 | + dbus_g_thread_init (); | |
| 90 | + | |
| 91 | + lib3270_set_log_handler(loghandler); | |
| 92 | + pw3270_dbus_register_io_handlers(); | |
| 93 | + | |
| 94 | + hSession = lib3270_session_new(""); | |
| 95 | + | |
| 96 | + main_loop = g_main_loop_new (NULL, FALSE); | |
| 97 | + | |
| 98 | + if(initialize()) | |
| 99 | + return -1; | |
| 100 | + | |
| 101 | + g_main_loop_run(main_loop); | |
| 102 | + | |
| 103 | + lib3270_session_free(hSession); | |
| 104 | + | |
| 105 | + return 0; | |
| 106 | +} | |
| 107 | + | |
| 108 | +void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 109 | +{ | |
| 110 | + g_main_loop_quit(main_loop); | |
| 111 | + dbus_g_method_return(context,0); | |
| 112 | +} | |
| 113 | + | |
| 114 | +H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object) | |
| 115 | +{ | |
| 116 | + return hSession; | |
| 117 | +} | |
| 118 | + | ... | ... |
| ... | ... | @@ -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 | + | ... | ... |
| ... | ... | @@ -0,0 +1,53 @@ |
| 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 | + #include <dbus/dbus-glib.h> | |
| 45 | + #include <dbus/dbus-glib-bindings.h> | |
| 46 | + #include <dbus/dbus-glib-lowlevel.h> | |
| 47 | + | |
| 48 | + #define ERROR_DOMAIN g_quark_from_static_string("pw3270DBUS") | |
| 49 | + | |
| 50 | + G_GNUC_INTERNAL gpointer pw3270_dbus_register_object (DBusGConnection *connection,DBusGProxy *proxy,GType object_type,const DBusGObjectInfo *info,const gchar *path); | |
| 51 | + | |
| 52 | + | |
| 53 | +#endif // PW3270_DBUS_GLOBALS_H_INCLUDED | ... | ... |
| ... | ... | @@ -0,0 +1,200 @@ |
| 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 <dbus/dbus.h> | |
| 38 | +#include <dbus/dbus-glib-lowlevel.h> | |
| 39 | +#include <dbus/dbus-glib.h> | |
| 40 | + | |
| 41 | +#include <lib3270/config.h> | |
| 42 | +#include <lib3270.h> | |
| 43 | +#include <lib3270/actions.h> | |
| 44 | + | |
| 45 | +#include "service.h" | |
| 46 | + | |
| 47 | +/*---[ Globals ]---------------------------------------------------------------------------------*/ | |
| 48 | + | |
| 49 | + | |
| 50 | +/*---[ Implement ]-------------------------------------------------------------------------------*/ | |
| 51 | + | |
| 52 | +G_DEFINE_TYPE(PW3270Dbus, pw3270_dbus, G_TYPE_OBJECT) | |
| 53 | + | |
| 54 | +static void pw3270_dbus_finalize(GObject *object) | |
| 55 | +{ | |
| 56 | + G_OBJECT_CLASS(pw3270_dbus_parent_class)->finalize (object); | |
| 57 | +} | |
| 58 | + | |
| 59 | + | |
| 60 | +static void pw3270_dbus_class_init(PW3270DbusClass *klass) | |
| 61 | +{ | |
| 62 | + GObjectClass *object_class; | |
| 63 | + object_class = G_OBJECT_CLASS (klass); | |
| 64 | + object_class->finalize = pw3270_dbus_finalize; | |
| 65 | +} | |
| 66 | + | |
| 67 | +static void pw3270_dbus_init(PW3270Dbus *object) | |
| 68 | +{ | |
| 69 | + | |
| 70 | +} | |
| 71 | + | |
| 72 | +PW3270Dbus * pw3270_dbus_new(void) | |
| 73 | +{ | |
| 74 | + return g_object_new(PW3270_TYPE_DBUS, NULL); | |
| 75 | +} | |
| 76 | + | |
| 77 | +void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 78 | +{ | |
| 79 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 80 | + dbus_g_method_return(context,PACKAGE_REVISION); | |
| 81 | +} | |
| 82 | + | |
| 83 | +void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context) | |
| 84 | +{ | |
| 85 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 86 | + | |
| 87 | + g_message("Connecting to \"%s\" by remote request",uri); | |
| 88 | + dbus_g_method_return(context,lib3270_connect(pw3270_dbus_get_session_handle(PW3270_DBUS(object)),uri,0)); | |
| 89 | +} | |
| 90 | + | |
| 91 | +void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 92 | +{ | |
| 93 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 94 | + | |
| 95 | + g_message("Disconnecting by remote request"); | |
| 96 | + lib3270_disconnect(pw3270_dbus_get_session_handle(object)); | |
| 97 | + dbus_g_method_return(context,0); | |
| 98 | +} | |
| 99 | + | |
| 100 | +void pw3270_dbus_get_message_id(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 101 | +{ | |
| 102 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 103 | + dbus_g_method_return(context,lib3270_get_program_message(pw3270_dbus_get_session_handle(object))); | |
| 104 | +} | |
| 105 | + | |
| 106 | +GError * pw3270_dbus_get_error_from_errno(int code) | |
| 107 | +{ | |
| 108 | + return g_error_new(ERROR_DOMAIN,code,"%s",g_strerror(code)); | |
| 109 | +} | |
| 110 | + | |
| 111 | +int pw3270_dbus_check_valid_state(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 112 | +{ | |
| 113 | + H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
| 114 | + GError * error = NULL; | |
| 115 | + | |
| 116 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 117 | + | |
| 118 | + if(!lib3270_is_connected(hSession)) | |
| 119 | + { | |
| 120 | + error = pw3270_dbus_get_error_from_errno(ENOTCONN); | |
| 121 | + } | |
| 122 | + else | |
| 123 | + { | |
| 124 | + LIB3270_MESSAGE state = lib3270_get_program_message(hSession); | |
| 125 | + | |
| 126 | + switch(state) | |
| 127 | + { | |
| 128 | + case LIB3270_MESSAGE_NONE: | |
| 129 | + return 0; | |
| 130 | + | |
| 131 | + case LIB3270_MESSAGE_DISCONNECTED: | |
| 132 | + error = pw3270_dbus_get_error_from_errno(ENOTCONN); | |
| 133 | + break; | |
| 134 | + | |
| 135 | + case LIB3270_MESSAGE_MINUS: | |
| 136 | + case LIB3270_MESSAGE_PROTECTED: | |
| 137 | + case LIB3270_MESSAGE_NUMERIC: | |
| 138 | + case LIB3270_MESSAGE_OVERFLOW: | |
| 139 | + case LIB3270_MESSAGE_INHIBIT: | |
| 140 | + case LIB3270_MESSAGE_KYBDLOCK: | |
| 141 | + case LIB3270_MESSAGE_X: | |
| 142 | + error = g_error_new(ERROR_DOMAIN,-1,_( "State %04d can't accept requests" ),state); | |
| 143 | + break; | |
| 144 | + | |
| 145 | + case LIB3270_MESSAGE_SYSWAIT: | |
| 146 | + case LIB3270_MESSAGE_TWAIT: | |
| 147 | + case LIB3270_MESSAGE_CONNECTED: | |
| 148 | + case LIB3270_MESSAGE_AWAITING_FIRST: | |
| 149 | + error = pw3270_dbus_get_error_from_errno(EBUSY); | |
| 150 | + break; | |
| 151 | + | |
| 152 | + case LIB3270_MESSAGE_RESOLVING: | |
| 153 | + case LIB3270_MESSAGE_CONNECTING: | |
| 154 | + error = g_error_new(ERROR_DOMAIN,EINPROGRESS,_( "Connecting to host" )); | |
| 155 | + | |
| 156 | + case LIB3270_MESSAGE_USER: | |
| 157 | + error = g_error_new(ERROR_DOMAIN,-1,_( "Unexpected state %04d" ),state); | |
| 158 | + } | |
| 159 | + } | |
| 160 | + | |
| 161 | + if(error) | |
| 162 | + { | |
| 163 | + dbus_g_method_return_error(context,error); | |
| 164 | + g_error_free(error); | |
| 165 | + return -1; | |
| 166 | + } | |
| 167 | + | |
| 168 | + return 0; | |
| 169 | +} | |
| 170 | + | |
| 171 | +void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 172 | +{ | |
| 173 | + char * text; | |
| 174 | + gchar * utftext; | |
| 175 | + H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
| 176 | + | |
| 177 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 178 | + | |
| 179 | + if(pw3270_dbus_check_valid_state(object,context)) | |
| 180 | + return; | |
| 181 | + | |
| 182 | + text = lib3270_get_text(hSession,0,-1); | |
| 183 | + | |
| 184 | + utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_charset(hSession),"?",NULL,NULL,NULL); | |
| 185 | + | |
| 186 | + lib3270_free(text); | |
| 187 | + | |
| 188 | + dbus_g_method_return(context,utftext); | |
| 189 | + | |
| 190 | + g_free(utftext); | |
| 191 | + | |
| 192 | +} | |
| 193 | + | |
| 194 | +void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 195 | +{ | |
| 196 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 197 | + if(pw3270_dbus_check_valid_state(object,context)) | |
| 198 | + return; | |
| 199 | + dbus_g_method_return(context,lib3270_enter(pw3270_dbus_get_session_handle(object))); | |
| 200 | +} | ... | ... |
| ... | ... | @@ -0,0 +1,364 @@ |
| 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 iocallback.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 | + */ | |
| 31 | + | |
| 32 | +#if defined(_WIN32) /*[*/ | |
| 33 | + #include <windows.h> | |
| 34 | +#elif defined(__APPLE__) | |
| 35 | + #include <poll.h> | |
| 36 | + #include <string.h> | |
| 37 | +#else | |
| 38 | + #include <poll.h> | |
| 39 | + #include <string.h> | |
| 40 | +#endif /*]*/ | |
| 41 | + | |
| 42 | +#include <stdio.h> | |
| 43 | +#include <glib.h> | |
| 44 | +#include "daemon.h" | |
| 45 | + | |
| 46 | +static int static_CallAndWait(int(*callback)(H3270 *session, void *), H3270 *session, void *parm); | |
| 47 | +static void static_RemoveSource(void *id); | |
| 48 | + | |
| 49 | +#ifdef WIN32 | |
| 50 | +static void * static_AddInput(HANDLE source, H3270 *session, void (*fn)(H3270 *session)); | |
| 51 | +static void * static_AddExcept(HANDLE source, H3270 *session, void (*fn)(H3270 *session)); | |
| 52 | +#else | |
| 53 | +static void * static_AddInput(int source, H3270 *session, void (*fn)(H3270 *session)); | |
| 54 | +static void * static_AddExcept(int source, H3270 *session, void (*fn)(H3270 *session)); | |
| 55 | +#endif // WIN32 | |
| 56 | + | |
| 57 | +static void * static_AddTimeOut(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session)); | |
| 58 | +static void static_RemoveTimeOut(void * timer); | |
| 59 | +static int static_Sleep(H3270 *hSession, int seconds); | |
| 60 | +static int static_RunPendingEvents(H3270 *hSession, int wait); | |
| 61 | + | |
| 62 | +static gboolean IO_prepare(GSource *source, gint *timeout); | |
| 63 | +static gboolean IO_check(GSource *source); | |
| 64 | +static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer user_data); | |
| 65 | +static void IO_finalize(GSource *source); /* Can be NULL */ | |
| 66 | +static gboolean IO_closure(gpointer data); | |
| 67 | + | |
| 68 | +/*---[ Structs ]-------------------------------------------------------------------------------------------*/ | |
| 69 | + | |
| 70 | + typedef struct _IO_Source | |
| 71 | + { | |
| 72 | + GSource gsrc; | |
| 73 | + GPollFD poll; | |
| 74 | +#if defined(_WIN32) | |
| 75 | + HANDLE source; | |
| 76 | +#else | |
| 77 | + int source; | |
| 78 | +#endif // WIN32 | |
| 79 | + void (*fn)(H3270 *session); | |
| 80 | + H3270 *session; | |
| 81 | + } IO_Source; | |
| 82 | + | |
| 83 | + typedef struct _timer | |
| 84 | + { | |
| 85 | + unsigned char remove; | |
| 86 | + void (*fn)(H3270 *session); | |
| 87 | + H3270 *session; | |
| 88 | + } TIMER; | |
| 89 | + | |
| 90 | + static GSourceFuncs IOSources = | |
| 91 | + { | |
| 92 | + IO_prepare, | |
| 93 | + IO_check, | |
| 94 | + IO_dispatch, | |
| 95 | + IO_finalize, | |
| 96 | + IO_closure, | |
| 97 | + NULL | |
| 98 | + }; | |
| 99 | + | |
| 100 | +/*---[ Implement ]-----------------------------------------------------------------------------------------*/ | |
| 101 | + | |
| 102 | +#ifdef WIN32 | |
| 103 | +static void * AddSource(HANDLE source, H3270 *session, gushort events, void (*fn)(H3270 *session)) | |
| 104 | +#else | |
| 105 | +static void * AddSource(int source, H3270 *session, gushort events, void (*fn)(H3270 *session)) | |
| 106 | +#endif // WIN32 | |
| 107 | +{ | |
| 108 | + IO_Source *src = (IO_Source *) g_source_new(&IOSources,sizeof(IO_Source)); | |
| 109 | + | |
| 110 | + src->source = source; | |
| 111 | + src->fn = fn; | |
| 112 | + src->poll.fd = (int) source; | |
| 113 | + src->poll.events = events; | |
| 114 | + src->session = session; | |
| 115 | + | |
| 116 | + g_source_attach((GSource *) src,NULL); | |
| 117 | + g_source_add_poll((GSource *) src,&src->poll); | |
| 118 | + | |
| 119 | + return src; | |
| 120 | +} | |
| 121 | + | |
| 122 | +#ifdef WIN32 | |
| 123 | +static void * static_AddInput(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | |
| 124 | +#else | |
| 125 | +static void * static_AddInput(int source, H3270 *session, void (*fn)(H3270 *session)) | |
| 126 | +#endif // WIN32 | |
| 127 | +{ | |
| 128 | + return AddSource(source,session,G_IO_IN|G_IO_HUP|G_IO_ERR,fn); | |
| 129 | +} | |
| 130 | + | |
| 131 | +static void static_RemoveSource(void *id) | |
| 132 | +{ | |
| 133 | + if(id) | |
| 134 | + g_source_destroy((GSource *) id); | |
| 135 | +} | |
| 136 | + | |
| 137 | +#if defined(WIN32) | |
| 138 | +static void * static_AddExcept(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | |
| 139 | +{ | |
| 140 | + return 0; | |
| 141 | +} | |
| 142 | +#else | |
| 143 | +static void * static_AddExcept(int source, H3270 *session, void (*fn)(H3270 *session)) | |
| 144 | +{ | |
| 145 | + return AddSource(source,session,G_IO_HUP|G_IO_ERR,fn); | |
| 146 | +} | |
| 147 | +#endif // WIN32 | |
| 148 | + | |
| 149 | +static gboolean do_timer(TIMER *t) | |
| 150 | +{ | |
| 151 | + if(!t->remove) | |
| 152 | + t->fn(t->session); | |
| 153 | + return FALSE; | |
| 154 | +} | |
| 155 | + | |
| 156 | +static void * static_AddTimeOut(unsigned long interval, H3270 *session, void (*proc)(H3270 *session)) | |
| 157 | +{ | |
| 158 | + TIMER *t = g_malloc0(sizeof(TIMER)); | |
| 159 | + | |
| 160 | + t->fn = proc; | |
| 161 | + t->session = session; | |
| 162 | + | |
| 163 | + g_timeout_add_full(G_PRIORITY_DEFAULT, (guint) interval, (GSourceFunc) do_timer, t, g_free); | |
| 164 | + | |
| 165 | + return t; | |
| 166 | +} | |
| 167 | + | |
| 168 | +static void static_RemoveTimeOut(void * timer) | |
| 169 | +{ | |
| 170 | + ((TIMER *) timer)->remove++; | |
| 171 | +} | |
| 172 | + | |
| 173 | +static gboolean IO_prepare(GSource *source, gint *timeout) | |
| 174 | +{ | |
| 175 | + /* | |
| 176 | + * Called before all the file descriptors are polled. | |
| 177 | + * If the source can determine that it is ready here | |
| 178 | + * (without waiting for the results of the poll() call) | |
| 179 | + * it should return TRUE. | |
| 180 | + * | |
| 181 | + * It can also return a timeout_ value which should be the maximum | |
| 182 | + * timeout (in milliseconds) which should be passed to the poll() call. | |
| 183 | + * The actual timeout used will be -1 if all sources returned -1, | |
| 184 | + * or it will be the minimum of all the timeout_ values | |
| 185 | + * returned which were >= 0. | |
| 186 | + * | |
| 187 | + */ | |
| 188 | + return 0; | |
| 189 | +} | |
| 190 | + | |
| 191 | +static gboolean IO_check(GSource *source) | |
| 192 | +{ | |
| 193 | + /* | |
| 194 | + * Called after all the file descriptors are polled. | |
| 195 | + * The source should return TRUE if it is ready to be dispatched. | |
| 196 | + * Note that some time may have passed since the previous prepare | |
| 197 | + * function was called, so the source should be checked again here. | |
| 198 | + * | |
| 199 | + */ | |
| 200 | +#if defined(_WIN32) /*[*/ | |
| 201 | + | |
| 202 | + if(WaitForSingleObject(((IO_Source *) source)->source,0) == WAIT_OBJECT_0) | |
| 203 | + return TRUE; | |
| 204 | + | |
| 205 | +#else /*][*/ | |
| 206 | + | |
| 207 | + struct pollfd fds; | |
| 208 | + | |
| 209 | + memset(&fds,0,sizeof(fds)); | |
| 210 | + | |
| 211 | + fds.fd = ((IO_Source *) source)->poll.fd; | |
| 212 | + fds.events = ((IO_Source *) source)->poll.events; | |
| 213 | + | |
| 214 | + if(poll(&fds,1,0) > 0) | |
| 215 | + return TRUE; | |
| 216 | + | |
| 217 | +#endif /*]*/ | |
| 218 | + | |
| 219 | + return FALSE; | |
| 220 | +} | |
| 221 | + | |
| 222 | +static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) | |
| 223 | +{ | |
| 224 | + /* | |
| 225 | + * Called to dispatch the event source, | |
| 226 | + * after it has returned TRUE in either its prepare or its check function. | |
| 227 | + * The dispatch function is passed in a callback function and data. | |
| 228 | + * The callback function may be NULL if the source was never connected | |
| 229 | + * to a callback using g_source_set_callback(). The dispatch function | |
| 230 | + * should call the callback function with user_data and whatever additional | |
| 231 | + * parameters are needed for this type of event source. | |
| 232 | + */ | |
| 233 | + ((IO_Source *) source)->fn(((IO_Source *) source)->session); | |
| 234 | + return TRUE; | |
| 235 | +} | |
| 236 | + | |
| 237 | +static void IO_finalize(GSource *source) | |
| 238 | +{ | |
| 239 | + | |
| 240 | +} | |
| 241 | + | |
| 242 | +static gboolean IO_closure(gpointer data) | |
| 243 | +{ | |
| 244 | + return 0; | |
| 245 | +} | |
| 246 | + | |
| 247 | +struct bgParameter | |
| 248 | +{ | |
| 249 | + gboolean running; | |
| 250 | + gboolean timer; | |
| 251 | + H3270 *session; | |
| 252 | + int rc; | |
| 253 | + int(*callback)(H3270 *session, void *); | |
| 254 | + void *parm; | |
| 255 | + | |
| 256 | +}; | |
| 257 | + | |
| 258 | +gpointer BgCall(struct bgParameter *p) | |
| 259 | +{ | |
| 260 | +// trace("%s starts",__FUNCTION__); | |
| 261 | + p->rc = p->callback(p->session, p->parm); | |
| 262 | + p->running = FALSE; | |
| 263 | +// trace("%s ends",__FUNCTION__); | |
| 264 | + return 0; | |
| 265 | +} | |
| 266 | + | |
| 267 | +static gboolean wait_for_thread(struct bgParameter *p) | |
| 268 | +{ | |
| 269 | + if(!p->running) | |
| 270 | + { | |
| 271 | + p->timer = 0; | |
| 272 | + return FALSE; | |
| 273 | + } | |
| 274 | + return TRUE; | |
| 275 | +} | |
| 276 | + | |
| 277 | +static int static_CallAndWait(int(*callback)(H3270 *session, void *), H3270 *session, void *parm) | |
| 278 | +{ | |
| 279 | + struct bgParameter p = { TRUE, TRUE, session, -1, callback, parm }; | |
| 280 | + GThread * thread; | |
| 281 | + | |
| 282 | +// trace("Starting auxiliary thread for callback %p",callback); | |
| 283 | + | |
| 284 | + p.running = TRUE; | |
| 285 | + p.timer = TRUE; | |
| 286 | + | |
| 287 | + thread = g_thread_create( (GThreadFunc) BgCall, &p, 0, NULL); | |
| 288 | + | |
| 289 | + if(!thread) | |
| 290 | + { | |
| 291 | + g_error("Can't start background thread"); | |
| 292 | + return -1; | |
| 293 | + } | |
| 294 | + | |
| 295 | + g_timeout_add(50,(GSourceFunc) wait_for_thread,(gpointer) &p); | |
| 296 | + | |
| 297 | + while(p.timer) | |
| 298 | + g_main_context_iteration(g_main_loop_get_context(main_loop),TRUE); | |
| 299 | + | |
| 300 | + return p.rc; | |
| 301 | +} | |
| 302 | + | |
| 303 | +static int static_Sleep(H3270 *hSession, int seconds) | |
| 304 | +{ | |
| 305 | + time_t end = time(0) + seconds; | |
| 306 | + | |
| 307 | + while(time(0) < end) | |
| 308 | + g_main_iteration(TRUE); | |
| 309 | + | |
| 310 | + return 0; | |
| 311 | +} | |
| 312 | + | |
| 313 | +static int static_RunPendingEvents(H3270 *hSession, int wait) | |
| 314 | +{ | |
| 315 | + GMainContext *context = g_main_loop_get_context(main_loop); | |
| 316 | + int rc = 0; | |
| 317 | + while(g_main_context_pending(context)) | |
| 318 | + { | |
| 319 | + rc = 1; | |
| 320 | + g_main_context_iteration(context,FALSE); | |
| 321 | + } | |
| 322 | + | |
| 323 | + if(wait) | |
| 324 | + g_main_context_iteration(context,TRUE); | |
| 325 | + | |
| 326 | + return rc; | |
| 327 | +} | |
| 328 | + | |
| 329 | +static void beep(H3270 *session) | |
| 330 | +{ | |
| 331 | +} | |
| 332 | + | |
| 333 | +void pw3270_dbus_register_io_handlers(void) | |
| 334 | +{ | |
| 335 | + static const struct lib3270_callbacks hdl = | |
| 336 | + { | |
| 337 | + sizeof(struct lib3270_callbacks), | |
| 338 | + | |
| 339 | + static_AddTimeOut, | |
| 340 | + static_RemoveTimeOut, | |
| 341 | + | |
| 342 | + static_AddInput, | |
| 343 | + static_RemoveSource, | |
| 344 | + | |
| 345 | + static_AddExcept, | |
| 346 | + | |
| 347 | +#ifdef G_THREADS_ENABLED | |
| 348 | + static_CallAndWait, | |
| 349 | +#else | |
| 350 | + NULL, | |
| 351 | +#endif | |
| 352 | + | |
| 353 | + static_Sleep, | |
| 354 | + static_RunPendingEvents, | |
| 355 | + beep | |
| 356 | + | |
| 357 | + }; | |
| 358 | + | |
| 359 | + if(lib3270_register_handlers(&hdl)) | |
| 360 | + { | |
| 361 | + g_error("%s","Can't set lib3270 I/O handlers"); | |
| 362 | + } | |
| 363 | + | |
| 364 | +} | ... | ... |
| ... | ... | @@ -0,0 +1,114 @@ |
| 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 | + * 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 | +#include <glib.h> | |
| 33 | +#include <dbus/dbus.h> | |
| 34 | +#include <dbus/dbus-glib-lowlevel.h> | |
| 35 | +#include <dbus/dbus-glib.h> | |
| 36 | + | |
| 37 | +#include <pw3270.h> | |
| 38 | +#include <pw3270/plugin.h> | |
| 39 | + | |
| 40 | +#include "service.h" | |
| 41 | +#include "dbus-glue.h" | |
| 42 | + | |
| 43 | +#include <gtk/gtk.h> | |
| 44 | + | |
| 45 | +/*---[ Globals ]---------------------------------------------------------------------------------*/ | |
| 46 | + | |
| 47 | + static DBusGConnection * connection = NULL; | |
| 48 | + static DBusGProxy * proxy = NULL; | |
| 49 | + | |
| 50 | +/*---[ Implement ]-------------------------------------------------------------------------------*/ | |
| 51 | + | |
| 52 | + LIB3270_EXPORT int pw3270_plugin_init(GtkWidget *window) | |
| 53 | + { | |
| 54 | + | |
| 55 | + GError * error = NULL; | |
| 56 | + guint result; | |
| 57 | + | |
| 58 | + connection = dbus_g_bus_get_private(DBUS_BUS_SESSION, g_main_context_default(), &error); | |
| 59 | + if(error) | |
| 60 | + { | |
| 61 | + GtkWidget *dialog = gtk_message_dialog_new( | |
| 62 | + GTK_WINDOW(window), | |
| 63 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 64 | + GTK_MESSAGE_ERROR, | |
| 65 | + GTK_BUTTONS_OK, | |
| 66 | + _( "Can't connect to DBUS server" )); | |
| 67 | + | |
| 68 | + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); | |
| 69 | + | |
| 70 | + g_message("Error \"%s\" getting session dbus",error->message); | |
| 71 | + | |
| 72 | + g_error_free(error); | |
| 73 | + | |
| 74 | + gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 75 | + gtk_widget_destroy(dialog); | |
| 76 | + | |
| 77 | + return -1; | |
| 78 | + } | |
| 79 | + | |
| 80 | + | |
| 81 | + proxy = dbus_g_proxy_new_for_name(connection,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS); | |
| 82 | + | |
| 83 | + org_freedesktop_DBus_request_name(proxy, PW3270_DBUS_SERVICE, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error); | |
| 84 | + if(error) | |
| 85 | + { | |
| 86 | + GtkWidget *dialog = gtk_message_dialog_new( | |
| 87 | + GTK_WINDOW(window), | |
| 88 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 89 | + GTK_MESSAGE_ERROR, | |
| 90 | + GTK_BUTTONS_OK, | |
| 91 | + _( "Can't get DBUS object name" )); | |
| 92 | + | |
| 93 | + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); | |
| 94 | + | |
| 95 | + g_message("Error \"%s\" requesting DBUS name",error->message); | |
| 96 | + | |
| 97 | + g_error_free(error); | |
| 98 | + | |
| 99 | + gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 100 | + gtk_widget_destroy(dialog); | |
| 101 | + | |
| 102 | + return -1; | |
| 103 | + } | |
| 104 | + | |
| 105 | + pw3270_dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,PW3270_DBUS_SERVICE_PATH); | |
| 106 | + | |
| 107 | + return 0; | |
| 108 | + } | |
| 109 | + | |
| 110 | + LIB3270_EXPORT int pw3270_plugin_deinit(GtkWidget *window) | |
| 111 | + { | |
| 112 | + | |
| 113 | + return 0; | |
| 114 | + } | ... | ... |
| ... | ... | @@ -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 *proxy,GType object_type,const DBusGObjectInfo *info,const gchar *path) | |
| 41 | +{ | |
| 42 | + GObject *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 | + | ... | ... |
| ... | ... | @@ -0,0 +1,71 @@ |
| 1 | +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | |
| 2 | +<CodeBlocks_project_file> | |
| 3 | + <FileVersion major="1" minor="6" /> | |
| 4 | + <Project> | |
| 5 | + <Option title="pw3270dbus" /> | |
| 6 | + <Option makefile_is_custom="1" /> | |
| 7 | + <Option pch_mode="2" /> | |
| 8 | + <Option compiler="gcc" /> | |
| 9 | + <Build> | |
| 10 | + <Target title="Debug"> | |
| 11 | + <Option output=".bin/Debug/pw3270dbus" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" /> | |
| 12 | + <Option object_output=".obj/Debug/" /> | |
| 13 | + <Option type="3" /> | |
| 14 | + <Option compiler="gcc" /> | |
| 15 | + <Compiler> | |
| 16 | + <Add option="-g" /> | |
| 17 | + </Compiler> | |
| 18 | + </Target> | |
| 19 | + <Target title="Release"> | |
| 20 | + <Option output=".bin/Release/pw3270dbus" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" /> | |
| 21 | + <Option object_output=".obj/Release/" /> | |
| 22 | + <Option type="3" /> | |
| 23 | + <Option compiler="gcc" /> | |
| 24 | + <Compiler> | |
| 25 | + <Add option="-O2" /> | |
| 26 | + </Compiler> | |
| 27 | + <Linker> | |
| 28 | + <Add option="-s" /> | |
| 29 | + </Linker> | |
| 30 | + </Target> | |
| 31 | + <Target title="debug-service"> | |
| 32 | + <Option output=".bin/Debug/pw3270d" prefix_auto="1" extension_auto="1" /> | |
| 33 | + <Option object_output=".obj/Debug/" /> | |
| 34 | + <Option type="1" /> | |
| 35 | + <Option compiler="gcc" /> | |
| 36 | + <Compiler> | |
| 37 | + <Add option="-g" /> | |
| 38 | + </Compiler> | |
| 39 | + </Target> | |
| 40 | + </Build> | |
| 41 | + <Compiler> | |
| 42 | + <Add option="-Wall" /> | |
| 43 | + </Compiler> | |
| 44 | + <Unit filename="Makefile.in" /> | |
| 45 | + <Unit filename="daemon.c"> | |
| 46 | + <Option compilerVar="CC" /> | |
| 47 | + </Unit> | |
| 48 | + <Unit filename="daemon.h" /> | |
| 49 | + <Unit filename="dbus-glue.h" /> | |
| 50 | + <Unit filename="globals.h" /> | |
| 51 | + <Unit filename="gobject.c"> | |
| 52 | + <Option compilerVar="CC" /> | |
| 53 | + </Unit> | |
| 54 | + <Unit filename="iocallback.c"> | |
| 55 | + <Option compilerVar="CC" /> | |
| 56 | + </Unit> | |
| 57 | + <Unit filename="main.c"> | |
| 58 | + <Option compilerVar="CC" /> | |
| 59 | + </Unit> | |
| 60 | + <Unit filename="misc.c"> | |
| 61 | + <Option compilerVar="CC" /> | |
| 62 | + </Unit> | |
| 63 | + <Unit filename="pw3270dbus.xml" /> | |
| 64 | + <Unit filename="service.h" /> | |
| 65 | + <Unit filename="test.sh" /> | |
| 66 | + <Extensions> | |
| 67 | + <code_completion /> | |
| 68 | + <debugger /> | |
| 69 | + </Extensions> | |
| 70 | + </Project> | |
| 71 | +</CodeBlocks_project_file> | ... | ... |
| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
| 2 | +<node name="/br/com/bb/pw3270"> | |
| 3 | + <interface name="br.com.bb.pw3270"> | |
| 4 | + <method name="getRevision"> | |
| 5 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
| 6 | + <arg type="s" name="revision" direction="out" /> | |
| 7 | + </method> | |
| 8 | + <method name="quit"> | |
| 9 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
| 10 | + <arg type="i" name="result" direction="out" /> | |
| 11 | + </method> | |
| 12 | + <method name="connect"> | |
| 13 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
| 14 | + <arg type="s" name="uri" direction="in" /> | |
| 15 | + <arg type="i" name="result" direction="out" /> | |
| 16 | + </method> | |
| 17 | + <method name="disconnect"> | |
| 18 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
| 19 | + <arg type="i" name="result" direction="out" /> | |
| 20 | + </method> | |
| 21 | + <method name="getMessageID"> | |
| 22 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
| 23 | + <arg type="i" name="status" direction="out" /> | |
| 24 | + </method> | |
| 25 | + <method name="getScreenContents"> | |
| 26 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
| 27 | + <arg type="s" name="contents" direction="out" /> | |
| 28 | + </method> | |
| 29 | + <method name="enter"> | |
| 30 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
| 31 | + <arg type="i" name="result" direction="out" /> | |
| 32 | + </method> | |
| 33 | + </interface> | |
| 34 | +</node> | ... | ... |
| ... | ... | @@ -0,0 +1,84 @@ |
| 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_DBUS_SERVICE_PATH "/br/com/bb/pw3270" | |
| 42 | + #define PW3270_DBUS_SERVICE "br.com.bb.pw3270" | |
| 43 | + | |
| 44 | + #define PW3270_TYPE_DBUS (pw3270_dbus_get_type ()) | |
| 45 | + #define PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PW3270_TYPE_DBUS, PW3270Dbus)) | |
| 46 | + #define PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_DBUS, PW3270DbusClass)) | |
| 47 | + #define IS_PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PW3270_TYPE_DBUS)) | |
| 48 | + #define IS_PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_DBUS)) | |
| 49 | + #define PW3270_DBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_DBUS, PW3270DbusClass)) | |
| 50 | + | |
| 51 | + G_BEGIN_DECLS | |
| 52 | + | |
| 53 | + typedef struct _PW3270Dbus PW3270Dbus; | |
| 54 | + typedef struct _PW3270DbusClass PW3270DbusClass; | |
| 55 | + | |
| 56 | + struct _PW3270Dbus | |
| 57 | + { | |
| 58 | + GObject parent; | |
| 59 | + }; | |
| 60 | + | |
| 61 | + struct _PW3270DbusClass | |
| 62 | + { | |
| 63 | + GObjectClass parent; | |
| 64 | + }; | |
| 65 | + | |
| 66 | + PW3270Dbus * pw3270_dbus_new (void); | |
| 67 | + GType pw3270_dbus_get_type (void); | |
| 68 | + | |
| 69 | + void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 70 | + void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 71 | + void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context); | |
| 72 | + void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 73 | + void pw3270_dbus_get_message_id(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 74 | + void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 75 | + H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object); | |
| 76 | + GError * pw3270_dbus_get_error_from_errno(int code); | |
| 77 | + | |
| 78 | + // Actions | |
| 79 | + void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 80 | + | |
| 81 | + | |
| 82 | + G_END_DECLS | |
| 83 | + | |
| 84 | +#endif // _PW3270_DBUS_SERVICE_H | ... | ... |
| ... | ... | @@ -0,0 +1,38 @@ |
| 1 | +#!/bin/bash | |
| 2 | + | |
| 3 | +case $1 in | |
| 4 | + | |
| 5 | + revision) | |
| 6 | + dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.getRevision | |
| 7 | + ;; | |
| 8 | + | |
| 9 | + message) | |
| 10 | + dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.getMessageID | |
| 11 | + ;; | |
| 12 | + | |
| 13 | + connect) | |
| 14 | + dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.connect string:$2 | |
| 15 | + ;; | |
| 16 | + | |
| 17 | + disconnect) | |
| 18 | + dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.disconnect | |
| 19 | + ;; | |
| 20 | + | |
| 21 | + quit) | |
| 22 | + dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.quit | |
| 23 | + ;; | |
| 24 | + | |
| 25 | + get) | |
| 26 | + dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.getScreenContents | |
| 27 | + ;; | |
| 28 | + | |
| 29 | + enter) | |
| 30 | + dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.enter | |
| 31 | + ;; | |
| 32 | + | |
| 33 | + *) | |
| 34 | + echo "Comando $1 desconhecido" | |
| 35 | + ;; | |
| 36 | + | |
| 37 | +esac | |
| 38 | + | ... | ... |