Commit af9aeaa3c6a42d8af27dd4539923321302f3d814
1 parent
12679f38
Exists in
master
and in
1 other branch
Updating plugin engine.
Showing
10 changed files
with
125 additions
and
50 deletions
Show diff stats
server/pw3270-plugin-ipc.cbp
@@ -131,6 +131,7 @@ | @@ -131,6 +131,7 @@ | ||
131 | <Option compilerVar="CC" /> | 131 | <Option compilerVar="CC" /> |
132 | </Unit> | 132 | </Unit> |
133 | <Unit filename="src/include/config.h.in" /> | 133 | <Unit filename="src/include/config.h.in" /> |
134 | + <Unit filename="src/include/internals.h" /> | ||
134 | <Unit filename="src/include/ipc-glib.h" /> | 135 | <Unit filename="src/include/ipc-glib.h" /> |
135 | <Unit filename="src/plugin/plugin.c"> | 136 | <Unit filename="src/plugin/plugin.c"> |
136 | <Option compilerVar="CC" /> | 137 | <Option compilerVar="CC" /> |
server/src/core/getproperties.c
server/src/core/linux/gobject.c
server/src/core/linux/gobject.h
@@ -37,13 +37,9 @@ | @@ -37,13 +37,9 @@ | ||
37 | 37 | ||
38 | #define LINUX_GOBJECT_H_INCLUDED | 38 | #define LINUX_GOBJECT_H_INCLUDED |
39 | 39 | ||
40 | - #include <config.h> | 40 | + #include <internals.h> |
41 | 41 | ||
42 | - #define ENABLE_NLS | ||
43 | - #define GETTEXT_PACKAGE PACKAGE_NAME | ||
44 | - | ||
45 | - #include <libintl.h> | ||
46 | - #include <glib/gi18n.h> | 42 | + #include <glib.h> |
47 | #include <gio/gio.h> | 43 | #include <gio/gio.h> |
48 | 44 | ||
49 | #include <lib3270.h> | 45 | #include <lib3270.h> |
server/src/core/linux/start.c
@@ -226,31 +226,24 @@ void ipc3270_export_object(GObject *object, const char *name, GError **error) { | @@ -226,31 +226,24 @@ void ipc3270_export_object(GObject *object, const char *name, GError **error) { | ||
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | 228 | ||
229 | - g_autofree gchar *basename = g_strdup(name); | ||
230 | - { | ||
231 | - gchar *ptr = strrchr(basename,':'); | ||
232 | - if(ptr) | ||
233 | - *ptr = 0; | ||
234 | - } | ||
235 | - | ||
236 | g_dbus_connection_set_exit_on_close(ipc->dbus.connection,FALSE); | 229 | g_dbus_connection_set_exit_on_close(ipc->dbus.connection,FALSE); |
237 | 230 | ||
238 | char id = lib3270_get_session_id(ipc->hSession); | 231 | char id = lib3270_get_session_id(ipc->hSession); |
239 | 232 | ||
240 | if(id) { | 233 | if(id) { |
241 | 234 | ||
242 | - if(register_object(ipc,basename,id)) | 235 | + if(register_object(ipc,name,id)) |
243 | return; | 236 | return; |
244 | 237 | ||
245 | } | 238 | } |
246 | 239 | ||
247 | for(id='a'; id < 'z' && !ipc->dbus.id && !*error; id++) { | 240 | for(id='a'; id < 'z' && !ipc->dbus.id && !*error; id++) { |
248 | 241 | ||
249 | - if(register_object(ipc,basename,id)) | 242 | + if(register_object(ipc,name,id)) |
250 | return; | 243 | return; |
251 | 244 | ||
252 | } | 245 | } |
253 | 246 | ||
254 | - g_message("Can't register IPC object for session \"%s\"",basename); | 247 | + g_message("Can't register IPC object for session \"%s\"",name); |
255 | 248 | ||
256 | } | 249 | } |
server/src/core/methods/private.h
@@ -0,0 +1,59 @@ | @@ -0,0 +1,59 @@ | ||
1 | +/* | ||
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob | ||
5 | + * o nome G3270. | ||
6 | + * | ||
7 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
8 | + * | ||
9 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
10 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
11 | + * Free Software Foundation. | ||
12 | + * | ||
13 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
14 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
15 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
16 | + * obter mais detalhes. | ||
17 | + * | ||
18 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
19 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
20 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | + * | ||
22 | + * Este programa está nomeado como - e possui - linhas de código. | ||
23 | + * | ||
24 | + * Contatos: | ||
25 | + * | ||
26 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
27 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
28 | + * | ||
29 | + */ | ||
30 | + | ||
31 | + /** | ||
32 | + * @brief Internal definitions for pw3270 IPC plugin. | ||
33 | + * | ||
34 | + * @author Perry Werneck <perry.werneck@gmail.com> | ||
35 | + * | ||
36 | + */ | ||
37 | + | ||
38 | +#ifndef INTERNALS_H_INCLUDED | ||
39 | + | ||
40 | + #define INTERNALS_H_INCLUDED | ||
41 | + | ||
42 | + #include <config.h> | ||
43 | + | ||
44 | + #define ENABLE_NLS | ||
45 | + #define GETTEXT_PACKAGE PACKAGE_NAME | ||
46 | + | ||
47 | + #include <glib.h> | ||
48 | + #include <glib/gi18n-lib.h> | ||
49 | + | ||
50 | + #include <lib3270.h> | ||
51 | + #include <lib3270/log.h> | ||
52 | + #include <v3270.h> | ||
53 | + | ||
54 | + G_BEGIN_DECLS | ||
55 | + | ||
56 | + | ||
57 | + G_END_DECLS | ||
58 | + | ||
59 | +#endif // PW3270_IPC_H_INCLUDED |
server/src/include/ipc-glib.h
@@ -157,12 +157,6 @@ | @@ -157,12 +157,6 @@ | ||
157 | #define g_autofree __attribute__((cleanup(ipc3270_autoptr_cleanup_generic_gfree))) | 157 | #define g_autofree __attribute__((cleanup(ipc3270_autoptr_cleanup_generic_gfree))) |
158 | #endif // ! GLIB(2,44,0) | 158 | #endif // ! GLIB(2,44,0) |
159 | 159 | ||
160 | - #ifdef DEBUG | ||
161 | - #define debug( fmt, ... ) fprintf(stderr,"%s(%d) " fmt "\n", __FILE__, (int) __LINE__, __VA_ARGS__ ); fflush(stderr); | ||
162 | - #else | ||
163 | - #define debug(...) /* __VA_ARGS */ | ||
164 | - #endif | ||
165 | - | ||
166 | typedef struct _ipc_method_int_arg { | 160 | typedef struct _ipc_method_int_arg { |
167 | const gchar *name; | 161 | const gchar *name; |
168 | int (*call)(H3270 *hSession, int keycode); | 162 | int (*call)(H3270 *hSession, int keycode); |
server/src/plugin/plugin.c
@@ -34,41 +34,51 @@ | @@ -34,41 +34,51 @@ | ||
34 | * | 34 | * |
35 | */ | 35 | */ |
36 | 36 | ||
37 | - #define ENABLE_NLS | ||
38 | - #define GETTEXT_PACKAGE PACKAGE_NAME | ||
39 | - | ||
40 | - #include <libintl.h> | ||
41 | - #include <glib/gi18n.h> | ||
42 | - #include <gio/gio.h> | ||
43 | - | ||
44 | #include "private.h" | 37 | #include "private.h" |
45 | #include <v3270.h> | 38 | #include <v3270.h> |
46 | #include <ipc-glib.h> | 39 | #include <ipc-glib.h> |
47 | 40 | ||
48 | - int pw3270_plugin_stop(GtkWidget G_GNUC_UNUSED(*window), GtkWidget *terminal) { | ||
49 | - debug("%s(%p)",__FUNCTION__,g_object_get_data(G_OBJECT(terminal),"ipc-object-info")); | ||
50 | - g_object_set_data(G_OBJECT(terminal), "ipc-object-info", NULL); | ||
51 | - return 0; | ||
52 | - } | 41 | + int pw3270_plugin_page_added(GtkWidget *terminal) { |
42 | + | ||
43 | + // Creates IPC, associate it with the terminal window. | ||
44 | + | ||
45 | + g_return_val_if_fail(GTK_IS_V3270(terminal),EINVAL); | ||
53 | 46 | ||
54 | - int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal) { | 47 | + // Build session name. |
48 | + g_autofree gchar * session_name = g_strdup(v3270_get_session_name(terminal)); | ||
49 | + { | ||
50 | + gchar *ptr = strchr(session_name,':'); | ||
51 | + if(ptr) | ||
52 | + *ptr = 0; | ||
55 | 53 | ||
56 | - // Creates IPC, associate it with the terminal window | 54 | + for(ptr=session_name;*ptr;ptr++) { |
55 | + | ||
56 | + if(!g_ascii_isalnum(*ptr)) { | ||
57 | + *ptr = '_'; | ||
58 | + } else { | ||
59 | + *ptr = g_ascii_tolower(*ptr); | ||
60 | + } | ||
61 | + | ||
62 | + } | ||
63 | + | ||
64 | + } | ||
65 | + | ||
66 | + debug("Session name for widget %p is \"%s\"",terminal,session_name); | ||
67 | + | ||
68 | + // Create IPC object | ||
57 | GObject * ipc = ipc3270_new(); | 69 | GObject * ipc = ipc3270_new(); |
58 | g_object_set_data_full(G_OBJECT(terminal), "ipc-object-info", ipc, g_object_unref); | 70 | g_object_set_data_full(G_OBJECT(terminal), "ipc-object-info", ipc, g_object_unref); |
59 | 71 | ||
60 | - debug("Name: \"%s\"",v3270_get_session_name(terminal)); | ||
61 | - | ||
62 | // Set session handle, this starts the IPC communication. | 72 | // Set session handle, this starts the IPC communication. |
63 | GError * error = NULL; | 73 | GError * error = NULL; |
64 | 74 | ||
65 | ipc3270_set_terminal_widget(ipc,terminal); | 75 | ipc3270_set_terminal_widget(ipc,terminal); |
66 | - ipc3270_export_object(ipc,v3270_get_session_name(terminal),&error); | 76 | + ipc3270_export_object(ipc,session_name,&error); |
67 | 77 | ||
68 | if(error) { | 78 | if(error) { |
69 | 79 | ||
70 | GtkWidget *dialog = gtk_message_dialog_new( | 80 | GtkWidget *dialog = gtk_message_dialog_new( |
71 | - GTK_WINDOW(window), | 81 | + GTK_WINDOW(gtk_widget_get_toplevel(terminal)), |
72 | GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | 82 | GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, |
73 | GTK_MESSAGE_ERROR, | 83 | GTK_MESSAGE_ERROR, |
74 | GTK_BUTTONS_OK, | 84 | GTK_BUTTONS_OK, |
@@ -82,7 +92,7 @@ | @@ -82,7 +92,7 @@ | ||
82 | 92 | ||
83 | gtk_widget_show_all(dialog); | 93 | gtk_widget_show_all(dialog); |
84 | 94 | ||
85 | - return 0; | 95 | + return -1; |
86 | 96 | ||
87 | } | 97 | } |
88 | 98 | ||
@@ -92,7 +102,27 @@ | @@ -92,7 +102,27 @@ | ||
92 | v3270_set_session_name(terminal, widget_name); | 102 | v3270_set_session_name(terminal, widget_name); |
93 | } | 103 | } |
94 | 104 | ||
95 | - return 0; | 105 | + return 0; |
106 | + | ||
107 | + } | ||
108 | + | ||
109 | + int pw3270_plugin_page_removed(GtkWidget *terminal) { | ||
110 | + | ||
111 | + if(GTK_IS_V3270(terminal)) { | ||
112 | + debug("%s(%p)",__FUNCTION__,g_object_get_data(G_OBJECT(terminal),"ipc-object-info")); | ||
113 | + g_object_set_data(G_OBJECT(terminal), "ipc-object-info", NULL); | ||
114 | + return 0; | ||
115 | + } | ||
116 | + | ||
117 | + return -1; | ||
118 | + } | ||
119 | + | ||
120 | + int pw3270_plugin_start(GtkWidget G_GNUC_UNUSED(*window), GtkWidget *terminal) { | ||
121 | + return pw3270_plugin_page_added(terminal); | ||
122 | + } | ||
123 | + | ||
124 | + int pw3270_plugin_stop(GtkWidget G_GNUC_UNUSED(*window), GtkWidget *terminal) { | ||
125 | + return pw3270_plugin_page_removed(terminal); | ||
96 | } | 126 | } |
97 | 127 | ||
98 | 128 |
server/src/plugin/private.h
@@ -37,16 +37,17 @@ | @@ -37,16 +37,17 @@ | ||
37 | 37 | ||
38 | #define PRIVATE_H_INCLUDED | 38 | #define PRIVATE_H_INCLUDED |
39 | 39 | ||
40 | - #include <config.h> | 40 | + #include <internals.h> |
41 | #include <ipc-glib.h> | 41 | #include <ipc-glib.h> |
42 | 42 | ||
43 | + G_BEGIN_DECLS | ||
44 | + | ||
43 | int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal); | 45 | int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal); |
44 | int pw3270_plugin_stop(GtkWidget *window, GtkWidget *terminal); | 46 | int pw3270_plugin_stop(GtkWidget *window, GtkWidget *terminal); |
45 | 47 | ||
46 | - #ifdef DEBUG | ||
47 | - #define debug( fmt, ... ) fprintf(stderr,"%s(%d) " fmt "\n", __FILE__, (int) __LINE__, __VA_ARGS__ ); fflush(stderr); | ||
48 | - #else | ||
49 | - #define debug(...) /* __VA_ARGS */ | ||
50 | - #endif | 48 | + int pw3270_plugin_page_added(GtkWidget *terminal); |
49 | + int pw3270_plugin_page_removed(GtkWidget *terminal); | ||
50 | + | ||
51 | + G_END_DECLS | ||
51 | 52 | ||
52 | #endif // PRIVATE_H_INCLUDED | 53 | #endif // PRIVATE_H_INCLUDED |