Commit 250f57e2abf617bc3145e6aab589ddb12179e30e
1 parent
190f2b2d
Exists in
master
and in
5 other branches
Interface DBUS já consegue obter o conteúdo do terminal
Showing
12 changed files
with
257 additions
and
55 deletions
Show diff stats
configure.ac
@@ -429,7 +429,7 @@ AC_CONFIG_FILES([ | @@ -429,7 +429,7 @@ AC_CONFIG_FILES([ | ||
429 | src/tools/Makefile | 429 | src/tools/Makefile |
430 | src/plugins/remotectl/Makefile | 430 | src/plugins/remotectl/Makefile |
431 | src/plugins/rx3270/Makefile | 431 | src/plugins/rx3270/Makefile |
432 | - src/plugins/dbus/Makefile | 432 | + src/plugins/3270dbus/Makefile |
433 | man/Makefile | 433 | man/Makefile |
434 | makegtkruntime.sh | 434 | makegtkruntime.sh |
435 | src/sample/Makefile | 435 | src/sample/Makefile |
src/include/lib3270.h
@@ -178,22 +178,22 @@ | @@ -178,22 +178,22 @@ | ||
178 | */ | 178 | */ |
179 | typedef enum _LIB3270_MESSAGE | 179 | typedef enum _LIB3270_MESSAGE |
180 | { | 180 | { |
181 | - LIB3270_MESSAGE_NONE, /**< No message */ | ||
182 | - LIB3270_MESSAGE_SYSWAIT, | ||
183 | - LIB3270_MESSAGE_TWAIT, | ||
184 | - LIB3270_MESSAGE_CONNECTED, /**< Connected */ | ||
185 | - LIB3270_MESSAGE_DISCONNECTED, /**< Disconnected from host */ | ||
186 | - LIB3270_MESSAGE_AWAITING_FIRST, | ||
187 | - LIB3270_MESSAGE_MINUS, | ||
188 | - LIB3270_MESSAGE_PROTECTED, | ||
189 | - LIB3270_MESSAGE_NUMERIC, | ||
190 | - LIB3270_MESSAGE_OVERFLOW, | ||
191 | - LIB3270_MESSAGE_INHIBIT, | ||
192 | - LIB3270_MESSAGE_KYBDLOCK, | ||
193 | - | ||
194 | - LIB3270_MESSAGE_X, | ||
195 | - LIB3270_MESSAGE_RESOLVING, /**< Resolving hostname (running DNS query) */ | ||
196 | - LIB3270_MESSAGE_CONNECTING, /**< Connecting to host */ | 181 | + LIB3270_MESSAGE_NONE, /**< 0 - No message */ |
182 | + LIB3270_MESSAGE_SYSWAIT, /**< 1 - */ | ||
183 | + LIB3270_MESSAGE_TWAIT, /**< 2 - */ | ||
184 | + LIB3270_MESSAGE_CONNECTED, /**< 3 - Connected */ | ||
185 | + LIB3270_MESSAGE_DISCONNECTED, /**< 4 - Disconnected from host */ | ||
186 | + LIB3270_MESSAGE_AWAITING_FIRST, /**< 5 - */ | ||
187 | + LIB3270_MESSAGE_MINUS, /**< 6 - */ | ||
188 | + LIB3270_MESSAGE_PROTECTED, /**< 7 - */ | ||
189 | + LIB3270_MESSAGE_NUMERIC, /**< 8 - */ | ||
190 | + LIB3270_MESSAGE_OVERFLOW, /**< 9 - */ | ||
191 | + LIB3270_MESSAGE_INHIBIT, /**< 10 - */ | ||
192 | + LIB3270_MESSAGE_KYBDLOCK, /**< 11 - */ | ||
193 | + | ||
194 | + LIB3270_MESSAGE_X, /**< 12 - */ | ||
195 | + LIB3270_MESSAGE_RESOLVING, /**< 13 - Resolving hostname (running DNS query) */ | ||
196 | + LIB3270_MESSAGE_CONNECTING, /**< 14 - Connecting to host */ | ||
197 | 197 | ||
198 | LIB3270_MESSAGE_USER | 198 | LIB3270_MESSAGE_USER |
199 | 199 |
src/plugins/3270dbus/Makefile.in
@@ -28,10 +28,10 @@ | @@ -28,10 +28,10 @@ | ||
28 | 28 | ||
29 | #---[ Sources ]---------------------------------------------------------------- | 29 | #---[ Sources ]---------------------------------------------------------------- |
30 | 30 | ||
31 | -MODULE_NAME=pw3270dbus | 31 | +MODULE_NAME=3270dbus |
32 | DEPENDS=Makefile dbus-glue.h | 32 | DEPENDS=Makefile dbus-glue.h |
33 | -PLUGIN_SRC=main.c gobject.c | ||
34 | -DAEMON_SRC=daemon.c gobject.c iocallback.c | 33 | +PLUGIN_SRC=main.c gobject.c misc.c |
34 | +DAEMON_SRC=daemon.c gobject.c iocallback.c misc.c | ||
35 | 35 | ||
36 | #---[ Paths ]------------------------------------------------------------------ | 36 | #---[ Paths ]------------------------------------------------------------------ |
37 | 37 | ||
@@ -55,6 +55,7 @@ DBUSBINDINGTOOL=@DBUSBINDINGTOOL@ | @@ -55,6 +55,7 @@ DBUSBINDINGTOOL=@DBUSBINDINGTOOL@ | ||
55 | #---[ Flags ]------------------------------------------------------------------ | 55 | #---[ Flags ]------------------------------------------------------------------ |
56 | 56 | ||
57 | DLL_FLAGS=-shared | 57 | DLL_FLAGS=-shared |
58 | +DLL_CFLAGS=@DLL_CFLAGS@ | ||
58 | DEBUG_CFLAGS=-DDEBUG=1 -g -Wall | 59 | DEBUG_CFLAGS=-DDEBUG=1 -g -Wall |
59 | 60 | ||
60 | LIB3270_CFLAGS ?= `pkg-config --cflags lib3270` | 61 | LIB3270_CFLAGS ?= `pkg-config --cflags lib3270` |
@@ -72,12 +73,12 @@ GTK_LIBS=@GTK_LIBS@ | @@ -72,12 +73,12 @@ GTK_LIBS=@GTK_LIBS@ | ||
72 | $(OBJDBG)/%.o: %.c $(DEPENDS) | 73 | $(OBJDBG)/%.o: %.c $(DEPENDS) |
73 | @echo " CC `basename $@`" | 74 | @echo " CC `basename $@`" |
74 | @$(MKDIR) `dirname $@` | 75 | @$(MKDIR) `dirname $@` |
75 | - @$(CC) $(CFLAGS) $(DBUS_CFLAGS) $(GLIB_CFLAGS) $(GTK_CFLAGS) $(DEBUG_CFLAGS) $(LIB3270_CFLAGS) -o $@ -c $< | 76 | + @$(CC) $(CFLAGS) $(DLL_CFLAGS) $(DBUS_CFLAGS) $(GLIB_CFLAGS) $(GTK_CFLAGS) $(DEBUG_CFLAGS) $(LIB3270_CFLAGS) -o $@ -c $< |
76 | 77 | ||
77 | $(OBJRLS)/%.o: %.c $(DEPENDS) | 78 | $(OBJRLS)/%.o: %.c $(DEPENDS) |
78 | @echo " CC `basename $@`" | 79 | @echo " CC `basename $@`" |
79 | @$(MKDIR) `dirname $@` | 80 | @$(MKDIR) `dirname $@` |
80 | - @$(CC) $(CFLAGS) $(DBUS_CFLAGS) $(GLIB_CFLAGS) $(GTK_CFLAGS) $(LIB3270_CFLAGS) -o $@ -c $< | 81 | + @$(CC) $(CFLAGS) $(DLL_CFLAGS) $(DBUS_CFLAGS) $(GLIB_CFLAGS) $(GTK_CFLAGS) $(LIB3270_CFLAGS) -o $@ -c $< |
81 | 82 | ||
82 | 83 | ||
83 | #---[ Release targets ]-------------------------------------------------------- | 84 | #---[ Release targets ]-------------------------------------------------------- |
@@ -91,7 +92,7 @@ $(BINRLS)/plugins/$(MODULE_NAME).so: $(foreach SRC, $(basename $(PLUGIN_SRC)), $ | @@ -91,7 +92,7 @@ $(BINRLS)/plugins/$(MODULE_NAME).so: $(foreach SRC, $(basename $(PLUGIN_SRC)), $ | ||
91 | 92 | ||
92 | #---[ Debug targets ]---------------------------------------------------------- | 93 | #---[ Debug targets ]---------------------------------------------------------- |
93 | 94 | ||
94 | -Debug: $(BINDBG)/plugins/$(MODULE_NAME).so $(BINDBG)/libhllapi.so | 95 | +Debug: $(BINDBG)/plugins/$(MODULE_NAME).so |
95 | 96 | ||
96 | $(BINDBG)/plugins/$(MODULE_NAME).so: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJDBG)/$(SRC).o) | 97 | $(BINDBG)/plugins/$(MODULE_NAME).so: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJDBG)/$(SRC).o) |
97 | @echo " CCLD `basename $@`" | 98 | @echo " CCLD `basename $@`" |
src/plugins/3270dbus/daemon.c
@@ -52,14 +52,6 @@ | @@ -52,14 +52,6 @@ | ||
52 | 52 | ||
53 | /*---[ Implement ]-------------------------------------------------------------------------------*/ | 53 | /*---[ Implement ]-------------------------------------------------------------------------------*/ |
54 | 54 | ||
55 | -static gpointer dbus_register_object (DBusGConnection *connection,DBusGProxy *proxy,GType object_type,const DBusGObjectInfo *info,const gchar *path) | ||
56 | -{ | ||
57 | - GObject *object = g_object_new (object_type, NULL); | ||
58 | - dbus_g_object_type_install_info (object_type, info); | ||
59 | - dbus_g_connection_register_g_object (connection, path, object); | ||
60 | - return object; | ||
61 | -} | ||
62 | - | ||
63 | static int initialize(void) | 55 | static int initialize(void) |
64 | { | 56 | { |
65 | GError * error = NULL; | 57 | GError * error = NULL; |
@@ -77,7 +69,7 @@ static int initialize(void) | @@ -77,7 +69,7 @@ static int initialize(void) | ||
77 | 69 | ||
78 | org_freedesktop_DBus_request_name(proxy, PW3270_DBUS_SERVICE, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error); | 70 | org_freedesktop_DBus_request_name(proxy, PW3270_DBUS_SERVICE, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error); |
79 | 71 | ||
80 | - dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,PW3270_DBUS_SERVICE_PATH); | 72 | + pw3270_dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,PW3270_DBUS_SERVICE_PATH); |
81 | 73 | ||
82 | return 0; | 74 | return 0; |
83 | } | 75 | } |
@@ -100,7 +92,6 @@ int main(int numpar, char *param[]) | @@ -100,7 +92,6 @@ int main(int numpar, char *param[]) | ||
100 | if(initialize()) | 92 | if(initialize()) |
101 | return -1; | 93 | return -1; |
102 | 94 | ||
103 | - | ||
104 | g_main_loop_run(main_loop); | 95 | g_main_loop_run(main_loop); |
105 | 96 | ||
106 | lib3270_session_free(hSession); | 97 | lib3270_session_free(hSession); |
src/plugins/3270dbus/gobject.c
@@ -86,7 +86,96 @@ void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvoca | @@ -86,7 +86,96 @@ void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvoca | ||
86 | void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context) | 86 | void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context) |
87 | { | 87 | { |
88 | g_message("Disconnecting by remote request"); | 88 | g_message("Disconnecting by remote request"); |
89 | - lib3270_disconnect(pw3270_dbus_get_session_handle(PW3270_DBUS(object))); | 89 | + lib3270_disconnect(pw3270_dbus_get_session_handle(object)); |
90 | dbus_g_method_return(context,0); | 90 | dbus_g_method_return(context,0); |
91 | } | 91 | } |
92 | 92 | ||
93 | +void pw3270_dbus_get_program_message(PW3270Dbus *object, DBusGMethodInvocation *context) | ||
94 | +{ | ||
95 | + dbus_g_method_return(context,lib3270_get_program_message(pw3270_dbus_get_session_handle(object))); | ||
96 | +} | ||
97 | + | ||
98 | +GError * pw3270_dbus_get_error_from_errno(int code) | ||
99 | +{ | ||
100 | + return g_error_new(ERROR_DOMAIN,code,"%s",g_strerror(code)); | ||
101 | +} | ||
102 | + | ||
103 | +int pw3270_dbus_check_valid_state(PW3270Dbus *object, DBusGMethodInvocation *context) | ||
104 | +{ | ||
105 | + H3270 * hSession = pw3270_dbus_get_session_handle(object); | ||
106 | + GError * error = NULL; | ||
107 | + | ||
108 | + if(!lib3270_is_connected(hSession)) | ||
109 | + { | ||
110 | + error = pw3270_dbus_get_error_from_errno(ENOTCONN); | ||
111 | + } | ||
112 | + else | ||
113 | + { | ||
114 | + LIB3270_MESSAGE state = lib3270_get_program_message(hSession); | ||
115 | + | ||
116 | + switch(state) | ||
117 | + { | ||
118 | + case LIB3270_MESSAGE_NONE: | ||
119 | + return 0; | ||
120 | + | ||
121 | + case LIB3270_MESSAGE_DISCONNECTED: | ||
122 | + error = pw3270_dbus_get_error_from_errno(ENOTCONN); | ||
123 | + break; | ||
124 | + | ||
125 | + case LIB3270_MESSAGE_MINUS: | ||
126 | + case LIB3270_MESSAGE_PROTECTED: | ||
127 | + case LIB3270_MESSAGE_NUMERIC: | ||
128 | + case LIB3270_MESSAGE_OVERFLOW: | ||
129 | + case LIB3270_MESSAGE_INHIBIT: | ||
130 | + case LIB3270_MESSAGE_KYBDLOCK: | ||
131 | + case LIB3270_MESSAGE_X: | ||
132 | + error = g_error_new(ERROR_DOMAIN,-1,_( "State %04d can't accept requests" ),state); | ||
133 | + break; | ||
134 | + | ||
135 | + case LIB3270_MESSAGE_SYSWAIT: | ||
136 | + case LIB3270_MESSAGE_TWAIT: | ||
137 | + case LIB3270_MESSAGE_CONNECTED: | ||
138 | + case LIB3270_MESSAGE_AWAITING_FIRST: | ||
139 | + error = pw3270_dbus_get_error_from_errno(EBUSY); | ||
140 | + break; | ||
141 | + | ||
142 | + case LIB3270_MESSAGE_RESOLVING: | ||
143 | + case LIB3270_MESSAGE_CONNECTING: | ||
144 | + error = g_error_new(ERROR_DOMAIN,EINPROGRESS,_( "Connecting to host" )); | ||
145 | + | ||
146 | + case LIB3270_MESSAGE_USER: | ||
147 | + error = g_error_new(ERROR_DOMAIN,-1,_( "Unexpected state %04d" ),state); | ||
148 | + } | ||
149 | + } | ||
150 | + | ||
151 | + if(error) | ||
152 | + { | ||
153 | + dbus_g_method_return_error(context,error); | ||
154 | + g_error_free(error); | ||
155 | + return -1; | ||
156 | + } | ||
157 | + | ||
158 | + return 0; | ||
159 | +} | ||
160 | + | ||
161 | +void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *context) | ||
162 | +{ | ||
163 | + char * text; | ||
164 | + gchar * utftext; | ||
165 | + H3270 * hSession = pw3270_dbus_get_session_handle(object); | ||
166 | + | ||
167 | + if(pw3270_dbus_check_valid_state(object,context)) | ||
168 | + return; | ||
169 | + | ||
170 | + text = lib3270_get_text(hSession,0,-1); | ||
171 | + | ||
172 | + utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_charset(hSession),"?",NULL,NULL,NULL); | ||
173 | + | ||
174 | + lib3270_free(text); | ||
175 | + | ||
176 | + dbus_g_method_return(context,utftext); | ||
177 | + | ||
178 | + g_free(utftext); | ||
179 | + | ||
180 | +} | ||
181 | + |
src/plugins/3270dbus/iocallback.c
@@ -247,6 +247,7 @@ static gboolean IO_closure(gpointer data) | @@ -247,6 +247,7 @@ static gboolean IO_closure(gpointer data) | ||
247 | struct bgParameter | 247 | struct bgParameter |
248 | { | 248 | { |
249 | gboolean running; | 249 | gboolean running; |
250 | + gboolean timer; | ||
250 | H3270 *session; | 251 | H3270 *session; |
251 | int rc; | 252 | int rc; |
252 | int(*callback)(H3270 *session, void *); | 253 | int(*callback)(H3270 *session, void *); |
@@ -263,14 +264,26 @@ gpointer BgCall(struct bgParameter *p) | @@ -263,14 +264,26 @@ gpointer BgCall(struct bgParameter *p) | ||
263 | return 0; | 264 | return 0; |
264 | } | 265 | } |
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 | + | ||
266 | static int static_CallAndWait(int(*callback)(H3270 *session, void *), H3270 *session, void *parm) | 277 | static int static_CallAndWait(int(*callback)(H3270 *session, void *), H3270 *session, void *parm) |
267 | { | 278 | { |
268 | - struct bgParameter p = { TRUE, session, -1, callback, parm }; | ||
269 | - GThread *thread; | 279 | + struct bgParameter p = { TRUE, TRUE, session, -1, callback, parm }; |
280 | + GThread * thread; | ||
270 | 281 | ||
271 | // trace("Starting auxiliary thread for callback %p",callback); | 282 | // trace("Starting auxiliary thread for callback %p",callback); |
272 | 283 | ||
273 | - p.running = TRUE; | 284 | + p.running = TRUE; |
285 | + p.timer = TRUE; | ||
286 | + | ||
274 | thread = g_thread_create( (GThreadFunc) BgCall, &p, 0, NULL); | 287 | thread = g_thread_create( (GThreadFunc) BgCall, &p, 0, NULL); |
275 | 288 | ||
276 | if(!thread) | 289 | if(!thread) |
@@ -279,7 +292,9 @@ static int static_CallAndWait(int(*callback)(H3270 *session, void *), H3270 *ses | @@ -279,7 +292,9 @@ static int static_CallAndWait(int(*callback)(H3270 *session, void *), H3270 *ses | ||
279 | return -1; | 292 | return -1; |
280 | } | 293 | } |
281 | 294 | ||
282 | - while(p.running) | 295 | + g_timeout_add(50,(GSourceFunc) wait_for_thread,(gpointer) &p); |
296 | + | ||
297 | + while(p.timer) | ||
283 | g_main_context_iteration(g_main_loop_get_context(main_loop),TRUE); | 298 | g_main_context_iteration(g_main_loop_get_context(main_loop),TRUE); |
284 | 299 | ||
285 | return p.rc; | 300 | return p.rc; |
src/plugins/3270dbus/main.c
@@ -49,14 +49,6 @@ | @@ -49,14 +49,6 @@ | ||
49 | 49 | ||
50 | /*---[ Implement ]-------------------------------------------------------------------------------*/ | 50 | /*---[ Implement ]-------------------------------------------------------------------------------*/ |
51 | 51 | ||
52 | - static gpointer dbus_register_object (DBusGConnection *connection,DBusGProxy *proxy,GType object_type,const DBusGObjectInfo *info,const gchar *path) | ||
53 | - { | ||
54 | - GObject *object = g_object_new (object_type, NULL); | ||
55 | - dbus_g_object_type_install_info (object_type, info); | ||
56 | - dbus_g_connection_register_g_object (connection, path, object); | ||
57 | - return object; | ||
58 | - } | ||
59 | - | ||
60 | LIB3270_EXPORT int pw3270_plugin_init(GtkWidget *window) | 52 | LIB3270_EXPORT int pw3270_plugin_init(GtkWidget *window) |
61 | { | 53 | { |
62 | 54 | ||
@@ -89,8 +81,28 @@ | @@ -89,8 +81,28 @@ | ||
89 | proxy = dbus_g_proxy_new_for_name(connection,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS); | 81 | proxy = dbus_g_proxy_new_for_name(connection,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS); |
90 | 82 | ||
91 | org_freedesktop_DBus_request_name(proxy, PW3270_DBUS_SERVICE, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error); | 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 | + } | ||
92 | 104 | ||
93 | - dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,PW3270_DBUS_SERVICE_PATH); | 105 | + pw3270_dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,PW3270_DBUS_SERVICE_PATH); |
94 | 106 | ||
95 | return 0; | 107 | return 0; |
96 | } | 108 | } |
@@ -0,0 +1,47 @@ | @@ -0,0 +1,47 @@ | ||
1 | +/* | ||
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
5 | + * | ||
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
7 | + * | ||
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
10 | + * Free Software Foundation. | ||
11 | + * | ||
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
15 | + * obter mais detalhes. | ||
16 | + * | ||
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | + * | ||
21 | + * Este programa está nomeado como misc.c e possui - linhas de código. | ||
22 | + * | ||
23 | + * Contatos: | ||
24 | + * | ||
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
27 | + * licinio@bb.com.br (Licínio Luis Branco) | ||
28 | + * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | ||
29 | + * | ||
30 | + * Referencias: | ||
31 | + * | ||
32 | + * https://live.gnome.org/DBusGlibBindings | ||
33 | + * | ||
34 | + */ | ||
35 | + | ||
36 | +#include "globals.h" | ||
37 | + | ||
38 | +/*---[ Implement ]-------------------------------------------------------------------------------*/ | ||
39 | + | ||
40 | +gpointer pw3270_dbus_register_object(DBusGConnection *connection,DBusGProxy *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
@@ -47,6 +47,7 @@ | @@ -47,6 +47,7 @@ | ||
47 | </Unit> | 47 | </Unit> |
48 | <Unit filename="daemon.h" /> | 48 | <Unit filename="daemon.h" /> |
49 | <Unit filename="dbus-glue.h" /> | 49 | <Unit filename="dbus-glue.h" /> |
50 | + <Unit filename="globals.h" /> | ||
50 | <Unit filename="gobject.c"> | 51 | <Unit filename="gobject.c"> |
51 | <Option compilerVar="CC" /> | 52 | <Option compilerVar="CC" /> |
52 | </Unit> | 53 | </Unit> |
@@ -56,6 +57,9 @@ | @@ -56,6 +57,9 @@ | ||
56 | <Unit filename="main.c"> | 57 | <Unit filename="main.c"> |
57 | <Option compilerVar="CC" /> | 58 | <Option compilerVar="CC" /> |
58 | </Unit> | 59 | </Unit> |
60 | + <Unit filename="misc.c"> | ||
61 | + <Option compilerVar="CC" /> | ||
62 | + </Unit> | ||
59 | <Unit filename="pw3270dbus.xml" /> | 63 | <Unit filename="pw3270dbus.xml" /> |
60 | <Unit filename="service.h" /> | 64 | <Unit filename="service.h" /> |
61 | <Unit filename="test.sh" /> | 65 | <Unit filename="test.sh" /> |
src/plugins/3270dbus/pw3270dbus.xml
@@ -18,5 +18,13 @@ | @@ -18,5 +18,13 @@ | ||
18 | <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | 18 | <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> |
19 | <arg type="i" name="result" direction="out" /> | 19 | <arg type="i" name="result" direction="out" /> |
20 | </method> | 20 | </method> |
21 | + <method name="getProgramMessage"> | ||
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> | ||
21 | </interface> | 29 | </interface> |
22 | </node> | 30 | </node> |
src/plugins/3270dbus/service.h
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 | + | ||
1 | #ifndef _PW3270_DBUS_SERVICE_H | 32 | #ifndef _PW3270_DBUS_SERVICE_H |
2 | 33 | ||
3 | #define _PW3270_DBUS_SERVICE_H 1 | 34 | #define _PW3270_DBUS_SERVICE_H 1 |
@@ -5,14 +36,7 @@ | @@ -5,14 +36,7 @@ | ||
5 | #define ENABLE_NLS | 36 | #define ENABLE_NLS |
6 | #define GETTEXT_PACKAGE PACKAGE_NAME | 37 | #define GETTEXT_PACKAGE PACKAGE_NAME |
7 | 38 | ||
8 | - #include <libintl.h> | ||
9 | - #include <glib/gi18n.h> | ||
10 | - | ||
11 | - #include <lib3270.h> | ||
12 | - #include <glib.h> | ||
13 | - #include <dbus/dbus-glib.h> | ||
14 | - #include <dbus/dbus-glib-bindings.h> | ||
15 | - #include <dbus/dbus-glib-lowlevel.h> | 39 | + #include "globals.h" |
16 | 40 | ||
17 | #define PW3270_DBUS_SERVICE_PATH "/br/com/bb/pw3270" | 41 | #define PW3270_DBUS_SERVICE_PATH "/br/com/bb/pw3270" |
18 | #define PW3270_DBUS_SERVICE "br.com.bb.pw3270" | 42 | #define PW3270_DBUS_SERVICE "br.com.bb.pw3270" |
@@ -46,7 +70,10 @@ | @@ -46,7 +70,10 @@ | ||
46 | void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context); | 70 | void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context); |
47 | void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context); | 71 | void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context); |
48 | void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context); | 72 | void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context); |
73 | + void pw3270_dbus_get_program_message(PW3270Dbus *object, DBusGMethodInvocation *context); | ||
74 | + void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *context); | ||
49 | H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object); | 75 | H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object); |
76 | + GError * pw3270_dbus_get_error_from_errno(int code); | ||
50 | 77 | ||
51 | G_END_DECLS | 78 | G_END_DECLS |
52 | 79 |
src/plugins/3270dbus/test.sh
@@ -6,6 +6,10 @@ case $1 in | @@ -6,6 +6,10 @@ case $1 in | ||
6 | dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.getRevision | 6 | dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.getRevision |
7 | ;; | 7 | ;; |
8 | 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 | + | ||
9 | connect) | 13 | connect) |
10 | dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.connect string:$2 | 14 | dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.connect string:$2 |
11 | ;; | 15 | ;; |
@@ -18,6 +22,10 @@ case $1 in | @@ -18,6 +22,10 @@ case $1 in | ||
18 | dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.quit | 22 | dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.quit |
19 | ;; | 23 | ;; |
20 | 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 | + | ||
21 | *) | 29 | *) |
22 | dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.getRevision | 30 | dbus-send --session --print-reply --dest=br.com.bb.pw3270 /br/com/bb/pw3270 br.com.bb.pw3270.getRevision |
23 | ;; | 31 | ;; |