Commit ef0169df62e90a0b19db9010b10d422a4d0a0b17
1 parent
8ba27d01
Exists in
master
and in
1 other branch
Reorganizin sources for IPC Server Module.
Showing
69 changed files
with
4259 additions
and
4260 deletions
Show diff stats
Makefile.in
... | ... | @@ -1,366 +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 | -# | |
26 | - | |
27 | -#---[ Library configuration ]------------------------------------------------------------ | |
28 | - | |
29 | -MODULE_NAME=ipc3270 | |
30 | -PACKAGE_NAME=@PACKAGE_NAME@ | |
31 | - | |
32 | -CORE_SOURCES= \ | |
33 | - $(wildcard src/core/*.c) \ | |
34 | - $(wildcard src/core/@OSNAME@/*.c) | |
35 | - | |
36 | -PLUGIN_SOURCES= \ | |
37 | - $(wildcard src/plugin/*.c) \ | |
38 | - $(wildcard src/plugin/@OSNAME@/*.rc) | |
39 | - | |
40 | -SERVICE_SOURCES= \ | |
41 | - $(wildcard src/service/*.c) \ | |
42 | - $(wildcard src/service/@OSNAME@/*.c) \ | |
43 | - $(wildcard src/service/@OSNAME@/*.rc) | |
44 | - | |
45 | -TEST_SOURCES= \ | |
46 | - $(wildcard src/testprogram/*.c) | |
47 | - | |
48 | -#---[ Tools ]---------------------------------------------------------------------------- | |
49 | - | |
50 | -CC=@CC@ | |
51 | -LD=@CC@ | |
52 | -LN_S=@LN_S@ | |
53 | -MKDIR=@MKDIR_P@ | |
54 | -INSTALL=@INSTALL@ | |
55 | -INSTALL_DATA=@INSTALL_DATA@ | |
56 | -INSTALL_PROGRAM=@INSTALL_PROGRAM@ | |
57 | -XGETTEXT=@XGETTEXT@ | |
58 | -MSGCAT=@MSGCAT@ | |
59 | -WINDRES=@WINDRES@ | |
60 | -AR=@AR@ | |
61 | - | |
62 | -#---[ Paths ]---------------------------------------------------------------------------- | |
63 | - | |
64 | -prefix=@prefix@ | |
65 | -exec_prefix=@exec_prefix@ | |
66 | -bindir=@bindir@ | |
67 | -sbindir=@sbindir@ | |
68 | -libdir=@libdir@ | |
69 | -includedir=@includedir@ | |
70 | -datarootdir=@datarootdir@ | |
71 | -localedir=@localedir@ | |
72 | -docdir=@docdir@ | |
73 | -sysconfdir=@sysconfdir@ | |
74 | - | |
75 | -BASEDIR=@BASEDIR@ | |
76 | - | |
77 | -POTDIR=$(BASEDIR)/.pot | |
78 | - | |
79 | -OBJDIR=$(BASEDIR)/.obj/$(MODULE_NAME) | |
80 | -OBJDBG=$(OBJDIR)/Debug | |
81 | -OBJRLS=$(OBJDIR)/Release | |
82 | - | |
83 | -BINDIR=$(BASEDIR)/.bin | |
84 | -BINDBG=$(BINDIR)/Debug | |
85 | -BINRLS=$(BINDIR)/Release | |
86 | - | |
87 | -#---[ Rules ]---------------------------------------------------------------------------- | |
88 | - | |
89 | -DEPENDS= \ | |
90 | - Makefile \ | |
91 | - src/include/*.h \ | |
92 | - src/include/lib3270/*.h | |
93 | - | |
94 | -CFLAGS= \ | |
95 | - @CFLAGS@ \ | |
96 | - -g \ | |
97 | - -Isrc/include \ | |
98 | - -DBUILD_DATE=`date +%Y%m%d` \ | |
99 | - @LIB3270_CFLAGS@ \ | |
100 | - @V3270_CFLAGS@ \ | |
101 | - @GTK_CFLAGS@ \ | |
102 | - @GLIB_CFLAGS@ | |
103 | - | |
104 | -GTK_LIBS=@GTK_LIBS@ | |
105 | -V3270_LIBS=@V3270_LIBS@ | |
106 | -GLIB_LIBS=@GLIB_LIBS@ | |
107 | - | |
108 | -LIBS= \ | |
109 | - @LIBS@ \ | |
110 | - @LIBICONV@ \ | |
111 | - @INTL_LIBS@ \ | |
112 | - @LIB3270_LIBS@ | |
113 | - | |
114 | -#---[ Debug Rules ]---------------------------------------------------------------------- | |
115 | - | |
116 | -$(OBJDBG)/%.o: \ | |
117 | - %.c \ | |
118 | - $(DEPENDS) | |
119 | - | |
120 | - @echo $< ... | |
121 | - @$(MKDIR) $(@D) | |
122 | - | |
123 | - @$(CC) \ | |
124 | - $(CFLAGS) \ | |
125 | - -Wall -Wextra -fstack-check \ | |
126 | - -DDEBUG=1 \ | |
127 | - -o $@ -c $< | |
128 | - | |
129 | -$(OBJDBG)/%.o: \ | |
130 | - %.rc | |
131 | - | |
132 | - @echo $< ... | |
133 | - @$(MKDIR) $(@D) | |
134 | - @$(WINDRES) $< -O coff -o $@ | |
135 | - | |
136 | -#---[ Release Rules ]-------------------------------------------------------------------- | |
137 | - | |
138 | -$(OBJRLS)/%.o: \ | |
139 | - %.c \ | |
140 | - $(DEPENDS) | |
141 | - | |
142 | - @echo $< ... | |
143 | - @$(MKDIR) $(@D) | |
144 | - @$(CC) \ | |
145 | - $(CFLAGS) \ | |
146 | - -DNDEBUG=1 \ | |
147 | - -o $@ -c $< | |
148 | - | |
149 | -$(OBJRLS)/%.o: \ | |
150 | - %.rc | |
151 | - | |
152 | - @echo $< ... | |
153 | - @$(MKDIR) $(@D) | |
154 | - @$(WINDRES) $< -O coff -o $@ | |
155 | - | |
156 | -#---[ Misc Rules ]----------------------------------------------------------------------- | |
157 | - | |
158 | -$(POTDIR)/$(MODULE_NAME)/%.pot: \ | |
159 | - %.c | |
160 | - | |
161 | - @echo $(notdir $@) ... | |
162 | - @$(MKDIR) $(@D) | |
163 | - @$(XGETTEXT) \ | |
164 | - --language=C \ | |
165 | - --keyword=_ \ | |
166 | - --keyword=N_ \ | |
167 | - --keyword=MSG_:2 \ | |
168 | - --output=$@ \ | |
169 | - $< | |
170 | - @touch $@ | |
171 | - | |
172 | -$(POTDIR)/$(MODULE_NAME)/%.pot: \ | |
173 | - %.rc | |
174 | - | |
175 | - @echo $< ... | |
176 | - @$(MKDIR) $(@D) | |
177 | - @touch $@ | |
178 | - | |
179 | - | |
180 | -#---[ Release Targets ]------------------------------------------------------------------ | |
181 | - | |
182 | -all: \ | |
183 | - $(BINRLS)/$(MODULE_NAME)@DLLEXT@ \ | |
184 | - $(POTDIR)/$(MODULE_NAME).pot | |
185 | - | |
186 | -Release: \ | |
187 | - $(BINRLS)/$(MODULE_NAME)@DLLEXT@ \ | |
188 | - $(BINRLS)/$(PACKAGE_NAME)d@EXEEXT@ | |
189 | - | |
190 | -$(BINRLS)/$(MODULE_NAME)@DLLEXT@: \ | |
191 | - $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) \ | |
192 | - $(BINRLS)/lib$(MODULE_NAME).a | |
193 | - | |
194 | - @$(MKDIR) $(@D) | |
195 | - @echo $< ... | |
196 | - @$(LD) \ | |
197 | - -shared -Wl,-soname,$(@F) \ | |
198 | - -o $@ \ | |
199 | - $(LDFLAGS) \ | |
200 | - $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) \ | |
201 | - -L$(BINRLS) -l$(MODULE_NAME) \ | |
202 | - $(V3270_LIBS) \ | |
203 | - $(LIBS) \ | |
204 | - $(GTK_LIBS) | |
205 | - | |
206 | -$(BINRLS)/lib$(MODULE_NAME).a: \ | |
207 | - $(foreach SRC, $(basename $(CORE_SOURCES)), $(OBJRLS)/$(SRC).o) | |
208 | - | |
209 | - @$(MKDIR) $(@D) | |
210 | - @echo $< ... | |
211 | - | |
212 | - @$(AR) rcs $@ $^ | |
213 | - | |
214 | - | |
215 | -#---[ Install Targets ]------------------------------------------------------------------ | |
216 | - | |
217 | -install: \ | |
218 | - install-plugin | |
219 | - | |
220 | -install-plugin: \ | |
221 | - $(BINRLS)/$(MODULE_NAME)@DLLEXT@ | |
222 | - | |
223 | - @$(MKDIR) $(DESTDIR)$(libdir)/pw3270-plugins | |
224 | - | |
225 | - @$(INSTALL_PROGRAM) \ | |
226 | - $(BINRLS)/$(MODULE_NAME)@DLLEXT@ \ | |
227 | - $(DESTDIR)$(libdir)/pw3270-plugins | |
228 | - | |
229 | -#---[ Misc Targets ]--------------------------------------------------------------------- | |
230 | - | |
231 | -$(POTDIR)/$(MODULE_NAME).pot: \ | |
232 | - $(foreach SRC, $(basename $(SOURCES)), $(POTDIR)/$(MODULE_NAME)/$(SRC).pot) | |
233 | - | |
234 | - @rm -f $@ | |
235 | - @mkdir -p `dirname $@` | |
236 | - @$(MSGCAT) --sort-output $^ > $@ | |
237 | - | |
238 | -locale: \ | |
239 | - $(POTDIR)/$(MODULE_NAME).pot | |
240 | - | |
241 | - | |
242 | -#---[ Debug Targets ]-------------------------------------------------------------------- | |
243 | - | |
244 | -Debug: \ | |
245 | - $(BINDBG)/$(MODULE_NAME)@DLLEXT@ \ | |
246 | - $(BINDBG)/$(MODULE_NAME)@EXEEXT@ | |
247 | - | |
248 | -$(BINDBG)/lib$(MODULE_NAME).a: \ | |
249 | - $(foreach SRC, $(basename $(CORE_SOURCES)), $(OBJDBG)/$(SRC).o) | |
250 | - | |
251 | - @$(MKDIR) $(@D) | |
252 | - @echo $< ... | |
253 | - | |
254 | - @$(AR) rcs $@ $^ | |
255 | - | |
256 | - | |
257 | -$(BINDBG)/$(MODULE_NAME)@EXEEXT@: \ | |
258 | - $(foreach SRC, $(basename $(TEST_SOURCES)), $(OBJDBG)/$(SRC).o) | |
259 | - | |
260 | - @$(MKDIR) $(@D) | |
261 | - @echo $< ... | |
262 | - @$(LD) \ | |
263 | - -o $@ \ | |
264 | - $^ \ | |
265 | - -L$(BINDBG) \ | |
266 | - -Wl,-rpath,$(BINDBG) \ | |
267 | - $(LDFLAGS) \ | |
268 | - $(LIBS) \ | |
269 | - $(V3270_LIBS) \ | |
270 | - $(GTK_LIBS) \ | |
271 | - $(GLIB_LIBS) | |
272 | - | |
273 | -$(BINDBG)/$(PACKAGE_NAME)d@EXEEXT@: \ | |
274 | - $(foreach SRC, $(basename $(SERVICE_SOURCES)), $(OBJDBG)/$(SRC).o) \ | |
275 | - $(BINDBG)/lib$(MODULE_NAME).a | |
276 | - | |
277 | - @$(MKDIR) $(@D) | |
278 | - @echo $< ... | |
279 | - @$(LD) \ | |
280 | - -o $@ \ | |
281 | - $(foreach SRC, $(basename $(SERVICE_SOURCES)), $(OBJDBG)/$(SRC).o) \ | |
282 | - -L$(BINDBG) \ | |
283 | - -Wl,-rpath,$(BINDBG) \ | |
284 | - $(LDFLAGS) \ | |
285 | - $(LIBS) \ | |
286 | - -l$(MODULE_NAME) \ | |
287 | - $(GLIB_LIBS) | |
288 | - | |
289 | -$(BINDBG)/$(MODULE_NAME)@DLLEXT@: \ | |
290 | - $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) \ | |
291 | - $(BINDBG)/lib$(MODULE_NAME).a | |
292 | - | |
293 | - @$(MKDIR) $(@D) | |
294 | - @echo $< ... | |
295 | - @$(LD) \ | |
296 | - -shared -Wl,-soname,$(@F) \ | |
297 | - -o $@ \ | |
298 | - $(LDFLAGS) \ | |
299 | - $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) \ | |
300 | - -L$(BINDBG) -l$(MODULE_NAME) \ | |
301 | - $(V3270_LIBS) \ | |
302 | - $(LIBS) \ | |
303 | - $(GTK_LIBS) | |
304 | - | |
305 | - | |
306 | -run: \ | |
307 | - run-plugin | |
308 | - | |
309 | -run-plugin: \ | |
310 | - $(BINDBG)/$(MODULE_NAME)@DLLEXT@ \ | |
311 | - $(BINDBG)/$(MODULE_NAME)@EXEEXT@ | |
312 | - | |
313 | - @LD_LIBRARY_PATH=$(BINDBG) \ | |
314 | - $(BINDBG)/$(MODULE_NAME)@EXEEXT@ | |
315 | - | |
316 | -run-service: \ | |
317 | - $(BINDBG)/$(PACKAGE_NAME)d@EXEEXT@ | |
318 | - | |
319 | - @LD_LIBRARY_PATH=$(BINDBG) \ | |
320 | - $(BINDBG)/$(PACKAGE_NAME)d@EXEEXT@ | |
321 | - | |
322 | - | |
323 | -#---[ Clean Targets ]-------------------------------------------------------------------- | |
324 | - | |
325 | -clean: \ | |
326 | - cleanDebug \ | |
327 | - cleanRelease | |
328 | - | |
329 | - @rm -fr $(BASEDIR)/.tmp/$(MODULE_NAME) | |
330 | - @rm -fr $(POTDIR)/$(MODULE_NAME) | |
331 | - @rm -fr src/include/marshal | |
332 | - | |
333 | -cleanDebug: | |
334 | - | |
335 | - @rm -fr $(OBJDBG) | |
336 | - @rm -fr $(BINDBG) | |
337 | - @rm -fr $(OBJDIR)/marshal | |
338 | - @rm -f src/v3270/marshal.h | |
339 | - @rm -f src/v3270ft/marshal.h | |
340 | - | |
341 | -cleanDebug-plugin: | |
342 | - @rm -fr $(OBJDBG) | |
343 | - @rm -fr $(BINDBG) | |
344 | - @rm -fr $(OBJDIR)/marshal | |
345 | - @rm -f src/v3270/marshal.h | |
346 | - @rm -f src/v3270ft/marshal.h | |
347 | - | |
348 | -cleanDebug-service: | |
349 | - @rm -fr $(OBJDBG) | |
350 | - @rm -fr $(BINDBG) | |
351 | - @rm -fr $(OBJDIR)/marshal | |
352 | - @rm -f src/v3270/marshal.h | |
353 | - @rm -f src/v3270ft/marshal.h | |
354 | - | |
355 | -cleanRelease: | |
356 | - | |
357 | - @rm -fr $(OBJRLS) | |
358 | - @rm -fr $(BINRLS) | |
359 | - @rm -fr $(POTDIR) | |
360 | - @rm -f $(MODULE_NAME).pot | |
361 | - | |
362 | -clean: \ | |
363 | - cleanDebug \ | |
364 | - cleanRelease | |
365 | - | |
366 | - |
... | ... | @@ -0,0 +1,41 @@ |
1 | +/* | |
2 | + * "Software G3270, 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 config.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 de Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | +#ifndef LIBV3270_CONFIG_INCLUDED | |
31 | + | |
32 | + #define LIBV3270_CONFIG_INCLUDED 1 | |
33 | + | |
34 | + #undef PACKAGE_NAME | |
35 | + #undef PACKAGE_VERSION | |
36 | + #undef PACKAGE_RELEASE | |
37 | + | |
38 | + #undef HAVE_GNOME | |
39 | + #undef HAVE_GTKMAC | |
40 | + | |
41 | +#endif /* LIBV3270_CONFIG_INCLUDED */ | ... | ... |
... | ... | @@ -0,0 +1,121 @@ |
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 Common definitions for pw3270 IPC plugin. | |
33 | + * | |
34 | + * @author Perry Werneck <perry.werneck@gmail.com> | |
35 | + * | |
36 | + */ | |
37 | + | |
38 | +#ifndef PW3270_IPC_H_INCLUDED | |
39 | + | |
40 | + #define PW3270_IPC_H_INCLUDED | |
41 | + | |
42 | + #ifdef _WIN32 | |
43 | + | |
44 | + #define PW3270_IPC_SESSION_BUS_NAME "\\\\.\\pipe\\%s\\%c" | |
45 | + | |
46 | + #else | |
47 | + | |
48 | + #define PW3270_IPC_SESSION_BUS_NAME "br.com.bb.%s.%c" | |
49 | + #define PW3270_IPC_SESSION_INTERFACE_NAME "br.com.bb.tn3270.session" | |
50 | + #define PW3270_IPC_SESSION_OBJECT_PATH "/br/com/bb/tn3270/session" | |
51 | + | |
52 | + #define PW3270_IPC_SERVICE_BUS_NAME "br.com.bb.tn3270.service" | |
53 | + #define PW3270_IPC_SERVICE_INTERFACE_NAME "br.com.bb.tn3270.service" | |
54 | + #define PW3270_IPC_SERVICE_OBJECT_PATH "/br/com/bb/tn3270/service" | |
55 | + | |
56 | + #endif // _WIN32 | |
57 | + | |
58 | + #include <glib.h> | |
59 | + #include <gtk/gtk.h> | |
60 | + #include <lib3270.h> | |
61 | + | |
62 | + G_BEGIN_DECLS | |
63 | + | |
64 | + #define GLIB_TYPE_IPC3270 (ipc3270_get_type ()) | |
65 | + #define IPC3270(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLIB_TYPE_IPC3270, ipc3270)) | |
66 | + #define IPC3270_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLIB_TYPE_IPC3270, ipc3270Class)) | |
67 | + #define IS_IPC3270(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLIB_TYPE_IPC3270)) | |
68 | + #define IS_IPC3270_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLIB_TYPE_IPC3270)) | |
69 | + #define IPC3270_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLIB_TYPE_IPC3270, ipc3270Class)) | |
70 | + | |
71 | + typedef struct _ipc3270 ipc3270; | |
72 | + typedef struct _ipc3270Class ipc3270Class; | |
73 | + | |
74 | + GObject * ipc3270_new(); | |
75 | + GType ipc3270_get_type(void); | |
76 | + void ipc3270_set_session(GObject *object, H3270 *hSession); | |
77 | + void ipc3270_export_object(GObject *object, const char *name, GError **error); | |
78 | + | |
79 | + gchar * ipc3270_convert_output_string(GObject *object, const gchar *string, GError **error); | |
80 | + gchar * ipc3270_convert_input_string(GObject *object, const gchar *string, GError **error); | |
81 | + GVariant * ipc3270_GVariant_from_input_string(GObject *object, char *string, GError **error); | |
82 | + | |
83 | + void ipc3270_add_terminal_introspection(GString *string); | |
84 | + | |
85 | + const gchar * ipc3270_get_display_charset(GObject *object); | |
86 | + H3270 * ipc3270_get_session(GObject *object); | |
87 | + | |
88 | + void ipc3270_set_error(GObject *object, int errcode, GError **error); | |
89 | + | |
90 | + GVariant * ipc3270_method_call(GObject *object, const gchar *method_name, GVariant *parameters, GError **error); | |
91 | + gboolean ipc3270_set_property(GObject *object, const gchar *property_name, GVariant *value, GError **error); | |
92 | + GVariant * ipc3270_get_property(GObject *object, const gchar *property_name, GError **error); | |
93 | + | |
94 | + #ifdef _WIN32 | |
95 | + unsigned char * ipc3270_pack(const gchar *name, int id, GVariant *values, size_t * szPacket); | |
96 | + unsigned char * ipc3270_pack_value(const gchar *name, int id, GVariant *value, size_t * szPacket); | |
97 | + unsigned char * ipc3270_pack_error(const GError *error, size_t * szPacket); | |
98 | + GVariant * ipc3270_unpack(const unsigned char *packet, int *id); | |
99 | + #endif // _WIN32 | |
100 | + | |
101 | + G_END_DECLS | |
102 | + | |
103 | + #if ! GLIB_CHECK_VERSION(2,44,0) | |
104 | + G_GNUC_INTERNAL void ipc3270_autoptr_cleanup_generic_gfree(void *p); | |
105 | + #define g_autofree __attribute__((cleanup(ipc3270_autoptr_cleanup_generic_gfree))) | |
106 | + #endif // ! GLIB(2,44,0) | |
107 | + | |
108 | + #ifdef DEBUG | |
109 | + #define debug( fmt, ... ) fprintf(stderr,"%s(%d) " fmt "\n", __FILE__, (int) __LINE__, __VA_ARGS__ ); fflush(stderr); | |
110 | + #else | |
111 | + #define debug(...) /* __VA_ARGS */ | |
112 | + #endif | |
113 | + | |
114 | + typedef struct _ipc_method_int_arg { | |
115 | + const gchar *name; | |
116 | + int (*call)(H3270 *hSession, int keycode); | |
117 | + } IPC_METHOD_INT_ARG; | |
118 | + | |
119 | + const IPC_METHOD_INT_ARG * ipc3270_get_int_arg_methods(); | |
120 | + | |
121 | +#endif // PW3270_IPC_H_INCLUDED | ... | ... |
configure.ac
... | ... | @@ -31,7 +31,7 @@ AC_PREREQ(2.61) |
31 | 31 | |
32 | 32 | dnl Initialise automake with the package name, version and |
33 | 33 | dnl bug-reporting address. |
34 | -AC_INIT([pw3270], [5.2], [perry.werneck@gmail.com]) | |
34 | +AC_INIT([ipc3270], [5.2], [perry.werneck@gmail.com]) | |
35 | 35 | |
36 | 36 | dnl Place auxilliary scripts here. |
37 | 37 | AC_CONFIG_AUX_DIR([scripts]) |
... | ... | @@ -40,7 +40,7 @@ dnl Compute the canonical host-system type |
40 | 40 | AC_CANONICAL_HOST |
41 | 41 | |
42 | 42 | dnl Put macro definitions here (though they aren't used). |
43 | -AC_CONFIG_HEADER([src/include/config.h]) | |
43 | +AC_CONFIG_HEADER([common/src/include/config.h]) | |
44 | 44 | |
45 | 45 | dnl Initialise automake stuff. |
46 | 46 | AM_INIT_AUTOMAKE |
... | ... | @@ -284,7 +284,7 @@ dnl --------------------------------------------------------------------------- |
284 | 284 | dnl Configure which files to generate. |
285 | 285 | dnl --------------------------------------------------------------------------- |
286 | 286 | |
287 | -AC_CONFIG_FILES(Makefile) | |
287 | +AC_CONFIG_FILES(server/Makefile) | |
288 | 288 | |
289 | 289 | dnl --------------------------------------------------------------------------- |
290 | 290 | dnl Output the generated config.status script. | ... | ... |
pw3270-plugin-ipc.cbp
... | ... | @@ -1,145 +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="IPC plugin for pw3270" /> | |
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/ipc3270" prefix_auto="1" extension_auto="1" /> | |
12 | - <Option object_output=".obj/Debug/" /> | |
13 | - <Option type="1" /> | |
14 | - <Option compiler="gcc" /> | |
15 | - <Compiler> | |
16 | - <Add option="-g" /> | |
17 | - <Add option="-DDEBUG=1" /> | |
18 | - </Compiler> | |
19 | - </Target> | |
20 | - <Target title="Release"> | |
21 | - <Option output=".bin/Release/pw3270ipc" prefix_auto="1" extension_auto="1" /> | |
22 | - <Option object_output=".obj/Release/" /> | |
23 | - <Option type="1" /> | |
24 | - <Option compiler="gcc" /> | |
25 | - <Compiler> | |
26 | - <Add option="-O2" /> | |
27 | - <Add option="-DNDEBUG=1" /> | |
28 | - </Compiler> | |
29 | - <Linker> | |
30 | - <Add option="-s" /> | |
31 | - </Linker> | |
32 | - </Target> | |
33 | - <Target title="Debug-plugin"> | |
34 | - <Option output=".bin/Debug/ipc3270" prefix_auto="1" extension_auto="1" /> | |
35 | - <Option object_output=".obj/Debug/" /> | |
36 | - <Option type="1" /> | |
37 | - <Option compiler="gcc" /> | |
38 | - <Compiler> | |
39 | - <Add option="-g" /> | |
40 | - <Add option="-DDEBUG=1" /> | |
41 | - </Compiler> | |
42 | - </Target> | |
43 | - <Target title="Debug-service"> | |
44 | - <Option output=".bin/Debug/pw3270d" prefix_auto="1" extension_auto="1" /> | |
45 | - <Option object_output=".obj/Debug/" /> | |
46 | - <Option type="1" /> | |
47 | - <Option compiler="gcc" /> | |
48 | - <Compiler> | |
49 | - <Add option="-g" /> | |
50 | - <Add option="-DDEBUG=1" /> | |
51 | - </Compiler> | |
52 | - </Target> | |
53 | - </Build> | |
54 | - <Compiler> | |
55 | - <Add option="-Wall" /> | |
56 | - <Add option="`pkg-config --cflags gtk+-3.0 lib3270 v3270 gio-2.0`" /> | |
57 | - </Compiler> | |
58 | - <Linker> | |
59 | - <Add option="`pkg-config --libs gtk+-3.0 lib3270 v3270 gio-2.0 dbus-1 dbus-glib-1`" /> | |
60 | - </Linker> | |
61 | - <Unit filename="src/core/constants.c"> | |
62 | - <Option compilerVar="CC" /> | |
63 | - </Unit> | |
64 | - <Unit filename="src/core/convert.c"> | |
65 | - <Option compilerVar="CC" /> | |
66 | - </Unit> | |
67 | - <Unit filename="src/core/getproperties.c"> | |
68 | - <Option compilerVar="CC" /> | |
69 | - </Unit> | |
70 | - <Unit filename="src/core/linux/gobject.c"> | |
71 | - <Option compilerVar="CC" /> | |
72 | - </Unit> | |
73 | - <Unit filename="src/core/linux/gobject.h" /> | |
74 | - <Unit filename="src/core/linux/start.c"> | |
75 | - <Option compilerVar="CC" /> | |
76 | - </Unit> | |
77 | - <Unit filename="src/core/linux/stop.c"> | |
78 | - <Option compilerVar="CC" /> | |
79 | - </Unit> | |
80 | - <Unit filename="src/core/methods.c"> | |
81 | - <Option compilerVar="CC" /> | |
82 | - </Unit> | |
83 | - <Unit filename="src/core/setproperties.c"> | |
84 | - <Option compilerVar="CC" /> | |
85 | - </Unit> | |
86 | - <Unit filename="src/core/tools.c"> | |
87 | - <Option compilerVar="CC" /> | |
88 | - </Unit> | |
89 | - <Unit filename="src/core/windows/gobject.c"> | |
90 | - <Option compilerVar="CC" /> | |
91 | - </Unit> | |
92 | - <Unit filename="src/core/windows/gobject.h" /> | |
93 | - <Unit filename="src/core/windows/inout.c"> | |
94 | - <Option compilerVar="CC" /> | |
95 | - </Unit> | |
96 | - <Unit filename="src/core/windows/pipesource.c"> | |
97 | - <Option compilerVar="CC" /> | |
98 | - </Unit> | |
99 | - <Unit filename="src/core/windows/resources.rc"> | |
100 | - <Option compilerVar="WINDRES" /> | |
101 | - </Unit> | |
102 | - <Unit filename="src/core/windows/start.c"> | |
103 | - <Option compilerVar="CC" /> | |
104 | - </Unit> | |
105 | - <Unit filename="src/core/windows/stop.c"> | |
106 | - <Option compilerVar="CC" /> | |
107 | - </Unit> | |
108 | - <Unit filename="src/include/config.h" /> | |
109 | - <Unit filename="src/include/config.h.in" /> | |
110 | - <Unit filename="src/include/lib3270/ipc-glib.h" /> | |
111 | - <Unit filename="src/plugin/plugin.c"> | |
112 | - <Option compilerVar="CC" /> | |
113 | - </Unit> | |
114 | - <Unit filename="src/plugin/private.h" /> | |
115 | - <Unit filename="src/service/getproperties.c"> | |
116 | - <Option compilerVar="CC" /> | |
117 | - </Unit> | |
118 | - <Unit filename="src/service/linux/start.c"> | |
119 | - <Option compilerVar="CC" /> | |
120 | - </Unit> | |
121 | - <Unit filename="src/service/methods.c"> | |
122 | - <Option compilerVar="CC" /> | |
123 | - </Unit> | |
124 | - <Unit filename="src/service/private.h" /> | |
125 | - <Unit filename="src/service/service.c"> | |
126 | - <Option compilerVar="CC" /> | |
127 | - </Unit> | |
128 | - <Unit filename="src/service/session.c"> | |
129 | - <Option compilerVar="CC" /> | |
130 | - </Unit> | |
131 | - <Unit filename="src/service/setproperties.c"> | |
132 | - <Option compilerVar="CC" /> | |
133 | - </Unit> | |
134 | - <Unit filename="src/service/windows/resources.rc.in" /> | |
135 | - <Unit filename="src/testprogram/testprogram.c"> | |
136 | - <Option compilerVar="CC" /> | |
137 | - </Unit> | |
138 | - <Extensions> | |
139 | - <code_completion /> | |
140 | - <envvars /> | |
141 | - <debugger /> | |
142 | - <lib_finder disable_auto="1" /> | |
143 | - </Extensions> | |
144 | - </Project> | |
145 | -</CodeBlocks_project_file> |
... | ... | @@ -0,0 +1,365 @@ |
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 | +# | |
26 | + | |
27 | +#---[ Library configuration ]------------------------------------------------------------ | |
28 | + | |
29 | +MODULE_NAME=ipc3270 | |
30 | +PACKAGE_NAME=@PACKAGE_NAME@ | |
31 | + | |
32 | +CORE_SOURCES= \ | |
33 | + $(wildcard src/core/*.c) \ | |
34 | + $(wildcard src/core/@OSNAME@/*.c) | |
35 | + | |
36 | +PLUGIN_SOURCES= \ | |
37 | + $(wildcard src/plugin/*.c) \ | |
38 | + $(wildcard src/plugin/@OSNAME@/*.rc) | |
39 | + | |
40 | +SERVICE_SOURCES= \ | |
41 | + $(wildcard src/service/*.c) \ | |
42 | + $(wildcard src/service/@OSNAME@/*.c) \ | |
43 | + $(wildcard src/service/@OSNAME@/*.rc) | |
44 | + | |
45 | +TEST_SOURCES= \ | |
46 | + $(wildcard src/testprogram/*.c) | |
47 | + | |
48 | +#---[ Tools ]---------------------------------------------------------------------------- | |
49 | + | |
50 | +CC=@CC@ | |
51 | +LD=@CC@ | |
52 | +LN_S=@LN_S@ | |
53 | +MKDIR=@MKDIR_P@ | |
54 | +INSTALL=@INSTALL@ | |
55 | +INSTALL_DATA=@INSTALL_DATA@ | |
56 | +INSTALL_PROGRAM=@INSTALL_PROGRAM@ | |
57 | +XGETTEXT=@XGETTEXT@ | |
58 | +MSGCAT=@MSGCAT@ | |
59 | +WINDRES=@WINDRES@ | |
60 | +AR=@AR@ | |
61 | + | |
62 | +#---[ Paths ]---------------------------------------------------------------------------- | |
63 | + | |
64 | +prefix=@prefix@ | |
65 | +exec_prefix=@exec_prefix@ | |
66 | +bindir=@bindir@ | |
67 | +sbindir=@sbindir@ | |
68 | +libdir=@libdir@ | |
69 | +includedir=@includedir@ | |
70 | +datarootdir=@datarootdir@ | |
71 | +localedir=@localedir@ | |
72 | +docdir=@docdir@ | |
73 | +sysconfdir=@sysconfdir@ | |
74 | + | |
75 | +BASEDIR=@BASEDIR@ | |
76 | + | |
77 | +POTDIR=$(BASEDIR)/.pot | |
78 | + | |
79 | +OBJDIR=.obj/$(MODULE_NAME) | |
80 | +OBJDBG=$(OBJDIR)/Debug | |
81 | +OBJRLS=$(OBJDIR)/Release | |
82 | + | |
83 | +BINDIR=.bin | |
84 | +BINDBG=$(BINDIR)/Debug | |
85 | +BINRLS=$(BINDIR)/Release | |
86 | + | |
87 | +#---[ Rules ]---------------------------------------------------------------------------- | |
88 | + | |
89 | +DEPENDS= \ | |
90 | + Makefile \ | |
91 | + $(BASEDIR)/common/src/include/*.h \ | |
92 | + $(BASEDIR)/common/src/include/lib3270/*.h | |
93 | + | |
94 | +CFLAGS= \ | |
95 | + @CFLAGS@ \ | |
96 | + -I$(BASEDIR)/common/src/include \ | |
97 | + -DBUILD_DATE=`date +%Y%m%d` \ | |
98 | + @LIB3270_CFLAGS@ \ | |
99 | + @V3270_CFLAGS@ \ | |
100 | + @GTK_CFLAGS@ \ | |
101 | + @GLIB_CFLAGS@ | |
102 | + | |
103 | +GTK_LIBS=@GTK_LIBS@ | |
104 | +V3270_LIBS=@V3270_LIBS@ | |
105 | +GLIB_LIBS=@GLIB_LIBS@ | |
106 | + | |
107 | +LIBS= \ | |
108 | + @LIBS@ \ | |
109 | + @LIBICONV@ \ | |
110 | + @INTL_LIBS@ \ | |
111 | + @LIB3270_LIBS@ | |
112 | + | |
113 | +#---[ Debug Rules ]---------------------------------------------------------------------- | |
114 | + | |
115 | +$(OBJDBG)/%.o: \ | |
116 | + %.c \ | |
117 | + $(DEPENDS) | |
118 | + | |
119 | + @echo $< ... | |
120 | + @$(MKDIR) $(@D) | |
121 | + | |
122 | + @$(CC) \ | |
123 | + $(CFLAGS) \ | |
124 | + -Wall -Wextra -fstack-check \ | |
125 | + -DDEBUG=1 \ | |
126 | + -o $@ -c $< | |
127 | + | |
128 | +$(OBJDBG)/%.o: \ | |
129 | + %.rc | |
130 | + | |
131 | + @echo $< ... | |
132 | + @$(MKDIR) $(@D) | |
133 | + @$(WINDRES) $< -O coff -o $@ | |
134 | + | |
135 | +#---[ Release Rules ]-------------------------------------------------------------------- | |
136 | + | |
137 | +$(OBJRLS)/%.o: \ | |
138 | + %.c \ | |
139 | + $(DEPENDS) | |
140 | + | |
141 | + @echo $< ... | |
142 | + @$(MKDIR) $(@D) | |
143 | + @$(CC) \ | |
144 | + $(CFLAGS) \ | |
145 | + -DNDEBUG=1 \ | |
146 | + -o $@ -c $< | |
147 | + | |
148 | +$(OBJRLS)/%.o: \ | |
149 | + %.rc | |
150 | + | |
151 | + @echo $< ... | |
152 | + @$(MKDIR) $(@D) | |
153 | + @$(WINDRES) $< -O coff -o $@ | |
154 | + | |
155 | +#---[ Misc Rules ]----------------------------------------------------------------------- | |
156 | + | |
157 | +$(POTDIR)/$(MODULE_NAME)/%.pot: \ | |
158 | + %.c | |
159 | + | |
160 | + @echo $(notdir $@) ... | |
161 | + @$(MKDIR) $(@D) | |
162 | + @$(XGETTEXT) \ | |
163 | + --language=C \ | |
164 | + --keyword=_ \ | |
165 | + --keyword=N_ \ | |
166 | + --keyword=MSG_:2 \ | |
167 | + --output=$@ \ | |
168 | + $< | |
169 | + @touch $@ | |
170 | + | |
171 | +$(POTDIR)/$(MODULE_NAME)/%.pot: \ | |
172 | + %.rc | |
173 | + | |
174 | + @echo $< ... | |
175 | + @$(MKDIR) $(@D) | |
176 | + @touch $@ | |
177 | + | |
178 | + | |
179 | +#---[ Release Targets ]------------------------------------------------------------------ | |
180 | + | |
181 | +all: \ | |
182 | + $(BINRLS)/$(MODULE_NAME)@DLLEXT@ \ | |
183 | + $(POTDIR)/$(MODULE_NAME).pot | |
184 | + | |
185 | +Release: \ | |
186 | + $(BINRLS)/$(MODULE_NAME)@DLLEXT@ \ | |
187 | + $(BINRLS)/$(PACKAGE_NAME)d@EXEEXT@ | |
188 | + | |
189 | +$(BINRLS)/$(MODULE_NAME)@DLLEXT@: \ | |
190 | + $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) \ | |
191 | + $(BINRLS)/lib$(MODULE_NAME).a | |
192 | + | |
193 | + @$(MKDIR) $(@D) | |
194 | + @echo $< ... | |
195 | + @$(LD) \ | |
196 | + -shared -Wl,-soname,$(@F) \ | |
197 | + -o $@ \ | |
198 | + $(LDFLAGS) \ | |
199 | + $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) \ | |
200 | + -L$(BINRLS) -l$(MODULE_NAME) \ | |
201 | + $(V3270_LIBS) \ | |
202 | + $(LIBS) \ | |
203 | + $(GTK_LIBS) | |
204 | + | |
205 | +$(BINRLS)/lib$(MODULE_NAME).a: \ | |
206 | + $(foreach SRC, $(basename $(CORE_SOURCES)), $(OBJRLS)/$(SRC).o) | |
207 | + | |
208 | + @$(MKDIR) $(@D) | |
209 | + @echo $< ... | |
210 | + | |
211 | + @$(AR) rcs $@ $^ | |
212 | + | |
213 | + | |
214 | +#---[ Install Targets ]------------------------------------------------------------------ | |
215 | + | |
216 | +install: \ | |
217 | + install-plugin | |
218 | + | |
219 | +install-plugin: \ | |
220 | + $(BINRLS)/$(MODULE_NAME)@DLLEXT@ | |
221 | + | |
222 | + @$(MKDIR) $(DESTDIR)$(libdir)/pw3270-plugins | |
223 | + | |
224 | + @$(INSTALL_PROGRAM) \ | |
225 | + $(BINRLS)/$(MODULE_NAME)@DLLEXT@ \ | |
226 | + $(DESTDIR)$(libdir)/pw3270-plugins | |
227 | + | |
228 | +#---[ Misc Targets ]--------------------------------------------------------------------- | |
229 | + | |
230 | +$(POTDIR)/$(MODULE_NAME).pot: \ | |
231 | + $(foreach SRC, $(basename $(SOURCES)), $(POTDIR)/$(MODULE_NAME)/$(SRC).pot) | |
232 | + | |
233 | + @rm -f $@ | |
234 | + @mkdir -p `dirname $@` | |
235 | + @$(MSGCAT) --sort-output $^ > $@ | |
236 | + | |
237 | +locale: \ | |
238 | + $(POTDIR)/$(MODULE_NAME).pot | |
239 | + | |
240 | + | |
241 | +#---[ Debug Targets ]-------------------------------------------------------------------- | |
242 | + | |
243 | +Debug: \ | |
244 | + $(BINDBG)/$(MODULE_NAME)@DLLEXT@ \ | |
245 | + $(BINDBG)/$(MODULE_NAME)@EXEEXT@ | |
246 | + | |
247 | +$(BINDBG)/lib$(MODULE_NAME).a: \ | |
248 | + $(foreach SRC, $(basename $(CORE_SOURCES)), $(OBJDBG)/$(SRC).o) | |
249 | + | |
250 | + @$(MKDIR) $(@D) | |
251 | + @echo $< ... | |
252 | + | |
253 | + @$(AR) rcs $@ $^ | |
254 | + | |
255 | + | |
256 | +$(BINDBG)/$(MODULE_NAME)@EXEEXT@: \ | |
257 | + $(foreach SRC, $(basename $(TEST_SOURCES)), $(OBJDBG)/$(SRC).o) | |
258 | + | |
259 | + @$(MKDIR) $(@D) | |
260 | + @echo $< ... | |
261 | + @$(LD) \ | |
262 | + -o $@ \ | |
263 | + $^ \ | |
264 | + -L$(BINDBG) \ | |
265 | + -Wl,-rpath,$(BINDBG) \ | |
266 | + $(LDFLAGS) \ | |
267 | + $(LIBS) \ | |
268 | + $(V3270_LIBS) \ | |
269 | + $(GTK_LIBS) \ | |
270 | + $(GLIB_LIBS) | |
271 | + | |
272 | +$(BINDBG)/$(PACKAGE_NAME)d@EXEEXT@: \ | |
273 | + $(foreach SRC, $(basename $(SERVICE_SOURCES)), $(OBJDBG)/$(SRC).o) \ | |
274 | + $(BINDBG)/lib$(MODULE_NAME).a | |
275 | + | |
276 | + @$(MKDIR) $(@D) | |
277 | + @echo $< ... | |
278 | + @$(LD) \ | |
279 | + -o $@ \ | |
280 | + $(foreach SRC, $(basename $(SERVICE_SOURCES)), $(OBJDBG)/$(SRC).o) \ | |
281 | + -L$(BINDBG) \ | |
282 | + -Wl,-rpath,$(BINDBG) \ | |
283 | + $(LDFLAGS) \ | |
284 | + $(LIBS) \ | |
285 | + -l$(MODULE_NAME) \ | |
286 | + $(GLIB_LIBS) | |
287 | + | |
288 | +$(BINDBG)/$(MODULE_NAME)@DLLEXT@: \ | |
289 | + $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) \ | |
290 | + $(BINDBG)/lib$(MODULE_NAME).a | |
291 | + | |
292 | + @$(MKDIR) $(@D) | |
293 | + @echo $< ... | |
294 | + @$(LD) \ | |
295 | + -shared -Wl,-soname,$(@F) \ | |
296 | + -o $@ \ | |
297 | + $(LDFLAGS) \ | |
298 | + $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) \ | |
299 | + -L$(BINDBG) -l$(MODULE_NAME) \ | |
300 | + $(V3270_LIBS) \ | |
301 | + $(LIBS) \ | |
302 | + $(GTK_LIBS) | |
303 | + | |
304 | + | |
305 | +run: \ | |
306 | + run-plugin | |
307 | + | |
308 | +run-plugin: \ | |
309 | + $(BINDBG)/$(MODULE_NAME)@DLLEXT@ \ | |
310 | + $(BINDBG)/$(MODULE_NAME)@EXEEXT@ | |
311 | + | |
312 | + @LD_LIBRARY_PATH=$(BINDBG) \ | |
313 | + $(BINDBG)/$(MODULE_NAME)@EXEEXT@ | |
314 | + | |
315 | +run-service: \ | |
316 | + $(BINDBG)/$(PACKAGE_NAME)d@EXEEXT@ | |
317 | + | |
318 | + @LD_LIBRARY_PATH=$(BINDBG) \ | |
319 | + $(BINDBG)/$(PACKAGE_NAME)d@EXEEXT@ | |
320 | + | |
321 | + | |
322 | +#---[ Clean Targets ]-------------------------------------------------------------------- | |
323 | + | |
324 | +clean: \ | |
325 | + cleanDebug \ | |
326 | + cleanRelease | |
327 | + | |
328 | + @rm -fr $(BASEDIR)/.tmp/$(MODULE_NAME) | |
329 | + @rm -fr $(POTDIR)/$(MODULE_NAME) | |
330 | + @rm -fr src/include/marshal | |
331 | + | |
332 | +cleanDebug: | |
333 | + | |
334 | + @rm -fr $(OBJDBG) | |
335 | + @rm -fr $(BINDBG) | |
336 | + @rm -fr $(OBJDIR)/marshal | |
337 | + @rm -f src/v3270/marshal.h | |
338 | + @rm -f src/v3270ft/marshal.h | |
339 | + | |
340 | +cleanDebug-plugin: | |
341 | + @rm -fr $(OBJDBG) | |
342 | + @rm -fr $(BINDBG) | |
343 | + @rm -fr $(OBJDIR)/marshal | |
344 | + @rm -f src/v3270/marshal.h | |
345 | + @rm -f src/v3270ft/marshal.h | |
346 | + | |
347 | +cleanDebug-service: | |
348 | + @rm -fr $(OBJDBG) | |
349 | + @rm -fr $(BINDBG) | |
350 | + @rm -fr $(OBJDIR)/marshal | |
351 | + @rm -f src/v3270/marshal.h | |
352 | + @rm -f src/v3270ft/marshal.h | |
353 | + | |
354 | +cleanRelease: | |
355 | + | |
356 | + @rm -fr $(OBJRLS) | |
357 | + @rm -fr $(BINRLS) | |
358 | + @rm -fr $(POTDIR) | |
359 | + @rm -f $(MODULE_NAME).pot | |
360 | + | |
361 | +clean: \ | |
362 | + cleanDebug \ | |
363 | + cleanRelease | |
364 | + | |
365 | + | ... | ... |
... | ... | @@ -0,0 +1,145 @@ |
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="IPC plugin for pw3270" /> | |
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/ipc3270" prefix_auto="1" extension_auto="1" /> | |
12 | + <Option object_output=".obj/Debug/" /> | |
13 | + <Option type="1" /> | |
14 | + <Option compiler="gcc" /> | |
15 | + <Compiler> | |
16 | + <Add option="-g" /> | |
17 | + <Add option="-DDEBUG=1" /> | |
18 | + </Compiler> | |
19 | + </Target> | |
20 | + <Target title="Release"> | |
21 | + <Option output=".bin/Release/pw3270ipc" prefix_auto="1" extension_auto="1" /> | |
22 | + <Option object_output=".obj/Release/" /> | |
23 | + <Option type="1" /> | |
24 | + <Option compiler="gcc" /> | |
25 | + <Compiler> | |
26 | + <Add option="-O2" /> | |
27 | + <Add option="-DNDEBUG=1" /> | |
28 | + </Compiler> | |
29 | + <Linker> | |
30 | + <Add option="-s" /> | |
31 | + </Linker> | |
32 | + </Target> | |
33 | + <Target title="Debug-plugin"> | |
34 | + <Option output=".bin/Debug/ipc3270" prefix_auto="1" extension_auto="1" /> | |
35 | + <Option object_output=".obj/Debug/" /> | |
36 | + <Option type="1" /> | |
37 | + <Option compiler="gcc" /> | |
38 | + <Compiler> | |
39 | + <Add option="-g" /> | |
40 | + <Add option="-DDEBUG=1" /> | |
41 | + </Compiler> | |
42 | + </Target> | |
43 | + <Target title="Debug-service"> | |
44 | + <Option output=".bin/Debug/pw3270d" prefix_auto="1" extension_auto="1" /> | |
45 | + <Option object_output=".obj/Debug/" /> | |
46 | + <Option type="1" /> | |
47 | + <Option compiler="gcc" /> | |
48 | + <Compiler> | |
49 | + <Add option="-g" /> | |
50 | + <Add option="-DDEBUG=1" /> | |
51 | + </Compiler> | |
52 | + </Target> | |
53 | + </Build> | |
54 | + <Compiler> | |
55 | + <Add option="-Wall" /> | |
56 | + <Add option="`pkg-config --cflags gtk+-3.0 lib3270 v3270 gio-2.0`" /> | |
57 | + </Compiler> | |
58 | + <Linker> | |
59 | + <Add option="`pkg-config --libs gtk+-3.0 lib3270 v3270 gio-2.0 dbus-1 dbus-glib-1`" /> | |
60 | + </Linker> | |
61 | + <Unit filename="src/core/constants.c"> | |
62 | + <Option compilerVar="CC" /> | |
63 | + </Unit> | |
64 | + <Unit filename="src/core/convert.c"> | |
65 | + <Option compilerVar="CC" /> | |
66 | + </Unit> | |
67 | + <Unit filename="src/core/getproperties.c"> | |
68 | + <Option compilerVar="CC" /> | |
69 | + </Unit> | |
70 | + <Unit filename="src/core/linux/gobject.c"> | |
71 | + <Option compilerVar="CC" /> | |
72 | + </Unit> | |
73 | + <Unit filename="src/core/linux/gobject.h" /> | |
74 | + <Unit filename="src/core/linux/start.c"> | |
75 | + <Option compilerVar="CC" /> | |
76 | + </Unit> | |
77 | + <Unit filename="src/core/linux/stop.c"> | |
78 | + <Option compilerVar="CC" /> | |
79 | + </Unit> | |
80 | + <Unit filename="src/core/methods.c"> | |
81 | + <Option compilerVar="CC" /> | |
82 | + </Unit> | |
83 | + <Unit filename="src/core/setproperties.c"> | |
84 | + <Option compilerVar="CC" /> | |
85 | + </Unit> | |
86 | + <Unit filename="src/core/tools.c"> | |
87 | + <Option compilerVar="CC" /> | |
88 | + </Unit> | |
89 | + <Unit filename="src/core/windows/gobject.c"> | |
90 | + <Option compilerVar="CC" /> | |
91 | + </Unit> | |
92 | + <Unit filename="src/core/windows/gobject.h" /> | |
93 | + <Unit filename="src/core/windows/inout.c"> | |
94 | + <Option compilerVar="CC" /> | |
95 | + </Unit> | |
96 | + <Unit filename="src/core/windows/pipesource.c"> | |
97 | + <Option compilerVar="CC" /> | |
98 | + </Unit> | |
99 | + <Unit filename="src/core/windows/resources.rc"> | |
100 | + <Option compilerVar="WINDRES" /> | |
101 | + </Unit> | |
102 | + <Unit filename="src/core/windows/start.c"> | |
103 | + <Option compilerVar="CC" /> | |
104 | + </Unit> | |
105 | + <Unit filename="src/core/windows/stop.c"> | |
106 | + <Option compilerVar="CC" /> | |
107 | + </Unit> | |
108 | + <Unit filename="src/include/config.h" /> | |
109 | + <Unit filename="src/include/config.h.in" /> | |
110 | + <Unit filename="src/include/lib3270/ipc-glib.h" /> | |
111 | + <Unit filename="src/plugin/plugin.c"> | |
112 | + <Option compilerVar="CC" /> | |
113 | + </Unit> | |
114 | + <Unit filename="src/plugin/private.h" /> | |
115 | + <Unit filename="src/service/getproperties.c"> | |
116 | + <Option compilerVar="CC" /> | |
117 | + </Unit> | |
118 | + <Unit filename="src/service/linux/start.c"> | |
119 | + <Option compilerVar="CC" /> | |
120 | + </Unit> | |
121 | + <Unit filename="src/service/methods.c"> | |
122 | + <Option compilerVar="CC" /> | |
123 | + </Unit> | |
124 | + <Unit filename="src/service/private.h" /> | |
125 | + <Unit filename="src/service/service.c"> | |
126 | + <Option compilerVar="CC" /> | |
127 | + </Unit> | |
128 | + <Unit filename="src/service/session.c"> | |
129 | + <Option compilerVar="CC" /> | |
130 | + </Unit> | |
131 | + <Unit filename="src/service/setproperties.c"> | |
132 | + <Option compilerVar="CC" /> | |
133 | + </Unit> | |
134 | + <Unit filename="src/service/windows/resources.rc.in" /> | |
135 | + <Unit filename="src/testprogram/testprogram.c"> | |
136 | + <Option compilerVar="CC" /> | |
137 | + </Unit> | |
138 | + <Extensions> | |
139 | + <code_completion /> | |
140 | + <envvars /> | |
141 | + <debugger /> | |
142 | + <lib_finder disable_auto="1" /> | |
143 | + </Extensions> | |
144 | + </Project> | |
145 | +</CodeBlocks_project_file> | ... | ... |
... | ... | @@ -0,0 +1,51 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como - e possui - linhas de código. | |
22 | + * | |
23 | + * Referências: | |
24 | + * | |
25 | + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | + * | |
28 | + * Contatos: | |
29 | + * | |
30 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | + * | |
33 | + */ | |
34 | + | |
35 | +#include <lib3270.h> | |
36 | +#include <lib3270/actions.h> | |
37 | +#include <lib3270/ipc-glib.h> | |
38 | + | |
39 | +const IPC_METHOD_INT_ARG * ipc3270_get_int_arg_methods() { | |
40 | + | |
41 | + static const IPC_METHOD_INT_ARG int_arg_methods[] = { | |
42 | + { "pfkey", lib3270_pfkey }, | |
43 | + { "pakey", lib3270_pakey }, | |
44 | + { NULL, NULL } | |
45 | + }; | |
46 | + | |
47 | + return int_arg_methods; | |
48 | + | |
49 | +} | |
50 | + | |
51 | + | ... | ... |
... | ... | @@ -0,0 +1,59 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como - e possui - linhas de código. | |
22 | + * | |
23 | + * Referências: | |
24 | + * | |
25 | + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | + * | |
28 | + * Contatos: | |
29 | + * | |
30 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | + * | |
33 | + */ | |
34 | + | |
35 | +#include <lib3270.h> | |
36 | +#include <lib3270/actions.h> | |
37 | +#include <lib3270/ipc-glib.h> | |
38 | + | |
39 | +gchar * ipc3270_convert_output_string(GObject *object, const gchar *string, GError **error) { | |
40 | + return g_convert_with_fallback(string,-1,ipc3270_get_display_charset(object),"UTF-8","?",NULL,NULL,error); | |
41 | +} | |
42 | + | |
43 | +gchar * ipc3270_convert_input_string(GObject *object, const gchar *string, GError **error) { | |
44 | + return g_convert_with_fallback(string,-1,"UTF-8",ipc3270_get_display_charset(object),"?",NULL,NULL,error); | |
45 | +} | |
46 | + | |
47 | +GVariant * ipc3270_GVariant_from_input_string(GObject *object, char *string, GError **error) { | |
48 | + | |
49 | + if(string) { | |
50 | + g_autofree gchar * utfstring = ipc3270_convert_input_string(object,string,error); | |
51 | + lib3270_free(string); | |
52 | + return g_variant_new("(s)", utfstring); | |
53 | + } | |
54 | + | |
55 | + ipc3270_set_error(object,errno,error); | |
56 | + return g_variant_new("(s)", ""); | |
57 | +} | |
58 | + | |
59 | + | ... | ... |
... | ... | @@ -0,0 +1,130 @@ |
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 - e possui - linhas de código. | |
22 | + * | |
23 | + * Referências: | |
24 | + * | |
25 | + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | + * | |
28 | + * Contatos: | |
29 | + * | |
30 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | + * | |
33 | + */ | |
34 | + | |
35 | +#include <config.h> | |
36 | +#include <lib3270/ipc-glib.h> | |
37 | +#include <lib3270.h> | |
38 | +#include <lib3270/properties.h> | |
39 | +#include <lib3270/trace.h> | |
40 | + | |
41 | +GVariant * ipc3270_get_property(GObject *object, const gchar *property_name, GError **error) { | |
42 | + | |
43 | + size_t ix; | |
44 | + H3270 * hSession = ipc3270_get_session(object); | |
45 | + | |
46 | + errno = 0; // Just in case. | |
47 | + | |
48 | + lib3270_trace_event(hSession,"GetProperty(%s) called on session %c\n",property_name,lib3270_get_session_id(hSession)); | |
49 | + | |
50 | + // Boolean properties | |
51 | + const LIB3270_INT_PROPERTY * boolprop = lib3270_get_boolean_properties_list(); | |
52 | + for(ix = 0; boolprop[ix].name; ix++) { | |
53 | + | |
54 | + if(boolprop[ix].get && !g_ascii_strcasecmp(boolprop[ix].name, property_name)) { | |
55 | + | |
56 | + // Found it! | |
57 | + int value = boolprop[ix].get(hSession); | |
58 | + | |
59 | + debug("%s=%d",property_name,value); | |
60 | + | |
61 | + if(value > 0 || errno == 0) { | |
62 | + return g_variant_new_boolean(value != 0); | |
63 | + } | |
64 | + | |
65 | + // Erro! | |
66 | + ipc3270_set_error(object,ENOENT,error); | |
67 | + return NULL; | |
68 | + | |
69 | + } | |
70 | + | |
71 | + } | |
72 | + | |
73 | + // int properties | |
74 | + const LIB3270_INT_PROPERTY * intprop = lib3270_get_int_properties_list(); | |
75 | + for(ix = 0; intprop[ix].name; ix++) { | |
76 | + | |
77 | + if(intprop[ix].get && !g_ascii_strcasecmp(intprop[ix].name, property_name)) { | |
78 | + | |
79 | + // Found it! | |
80 | + int value = intprop[ix].get(hSession); | |
81 | + | |
82 | + debug("%s=%d",property_name,value); | |
83 | + | |
84 | + if(value > 0 || errno == 0) { | |
85 | + return g_variant_new_int16((gint16) value); | |
86 | + } | |
87 | + | |
88 | + // Erro! | |
89 | + ipc3270_set_error(object,errno,error); | |
90 | + return NULL; | |
91 | + | |
92 | + } | |
93 | + | |
94 | + } | |
95 | + | |
96 | + // String properties | |
97 | + const LIB3270_STRING_PROPERTY * strprop = lib3270_get_string_properties_list(); | |
98 | + for(ix = 0; strprop[ix].name; ix++) { | |
99 | + | |
100 | + if(strprop[ix].get && !g_ascii_strcasecmp(strprop[ix].name, property_name)) { | |
101 | + | |
102 | + // Found it! | |
103 | + const char * value = strprop[ix].get(hSession); | |
104 | + | |
105 | + if(value) { | |
106 | + debug("%s=%s",property_name,value); | |
107 | + return g_variant_new_string(value); | |
108 | + } | |
109 | + | |
110 | + // Erro! | |
111 | + ipc3270_set_error(object,errno,error); | |
112 | + return NULL; | |
113 | + | |
114 | + } | |
115 | + | |
116 | + } | |
117 | + | |
118 | + // Check for toggle | |
119 | + LIB3270_TOGGLE toggle = lib3270_get_toggle_id(property_name); | |
120 | + if(toggle != (LIB3270_TOGGLE) -1) { | |
121 | + | |
122 | + // Is a Tn3270 toggle, get it! | |
123 | + return g_variant_new_boolean(lib3270_get_toggle( (hSession), toggle) != 0); | |
124 | + | |
125 | + } | |
126 | + | |
127 | + return NULL; | |
128 | + | |
129 | +} | |
130 | + | ... | ... |
... | ... | @@ -0,0 +1,9 @@ |
1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
2 | +<node name="/br/com/bb/pw3270"> | |
3 | + <interface name="br.com.bb.pw3270"> | |
4 | + <method name="getRevision"> | |
5 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
6 | + <arg type="s" name="revision" direction="out" /> | |
7 | + </method> | |
8 | + </interface> | |
9 | +</node> | ... | ... |
... | ... | @@ -0,0 +1,227 @@ |
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 - e possui - linhas de código. | |
22 | + * | |
23 | + * Referências: | |
24 | + * | |
25 | + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | + * | |
28 | + * Contatos: | |
29 | + * | |
30 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | + * | |
33 | + */ | |
34 | + | |
35 | +#include "gobject.h" | |
36 | +#include <lib3270.h> | |
37 | +#include <lib3270/actions.h> | |
38 | +#include <lib3270/properties.h> | |
39 | + | |
40 | +#include <dbus/dbus-glib.h> | |
41 | +#include <dbus/dbus-glib-bindings.h> | |
42 | + | |
43 | +/*--[ Widget definition ]----------------------------------------------------------------------------*/ | |
44 | + | |
45 | +G_DEFINE_TYPE(ipc3270, ipc3270, G_TYPE_OBJECT) | |
46 | + | |
47 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
48 | + | |
49 | +static void ipc3270_finalize(GObject *object) { | |
50 | + | |
51 | + debug("ipc3270::%s(%p)",__FUNCTION__,object); | |
52 | + | |
53 | + ipc3270_release_object(IPC3270(object)); | |
54 | + | |
55 | + G_OBJECT_CLASS(ipc3270_parent_class)->finalize(object); | |
56 | +} | |
57 | + | |
58 | + | |
59 | +static void ipc3270_class_init(ipc3270Class *klass) { | |
60 | + | |
61 | + debug("%s",__FUNCTION__); | |
62 | + | |
63 | + GObjectClass *object_class; | |
64 | + object_class = G_OBJECT_CLASS (klass); | |
65 | + object_class->finalize = ipc3270_finalize; | |
66 | + | |
67 | +} | |
68 | + | |
69 | +static void ipc3270_init(ipc3270 *object) { | |
70 | + | |
71 | + debug("%s",__FUNCTION__); | |
72 | + object->error_domain = g_quark_from_static_string(PACKAGE_NAME); | |
73 | + | |
74 | +} | |
75 | + | |
76 | +GObject * ipc3270_new() { | |
77 | + return g_object_new(GLIB_TYPE_IPC3270, NULL); | |
78 | +} | |
79 | + | |
80 | +void ipc3270_add_terminal_introspection(GString *introspection) { | |
81 | + | |
82 | + size_t ix; | |
83 | + | |
84 | + g_string_append(introspection, | |
85 | + " <method name='connect'>" | |
86 | + " <arg type='s' name='url' direction='in'/>" | |
87 | + " <arg type='i' name='result' direction='out' />" \ | |
88 | + " </method>" | |
89 | + " <method name='disconnect'>" | |
90 | + " <arg type='i' name='result' direction='out' />" \ | |
91 | + " </method>" | |
92 | + " <method name='action'>" | |
93 | + " <arg type='s' name='name' direction='in' />" \ | |
94 | + " <arg type='i' name='result' direction='out' />" \ | |
95 | + " </method>" | |
96 | + " <method name='pfkey'>" \ | |
97 | + " <arg type='u' name='keycode' direction='in'/>" \ | |
98 | + " <arg type='i' name='result' direction='out' />" \ | |
99 | + " </method>" | |
100 | + " <method name='pakey'>" \ | |
101 | + " <arg type='u' name='keycode' direction='in'/>" \ | |
102 | + " <arg type='i' name='result' direction='out' />" \ | |
103 | + " </method>" | |
104 | + " <method name='getString'>" \ | |
105 | + " <arg type='s' name='text' direction='out' />" \ | |
106 | + " </method>" \ | |
107 | + " <method name='setString'>" \ | |
108 | + " <arg type='s' name='text' direction='in' />" \ | |
109 | + " <arg type='i' name='result' direction='out' />" \ | |
110 | + " </method>" \ | |
111 | + " <method name='setStringAt'>" \ | |
112 | + " <arg type='u' name='row' direction='in' />" \ | |
113 | + " <arg type='u' name='col' direction='in' />" \ | |
114 | + " <arg type='s' name='text' direction='in' />" \ | |
115 | + " <arg type='i' name='result' direction='out' />" \ | |
116 | + " </method>" \ | |
117 | + " <method name= 'getStringAt'>" \ | |
118 | + " <arg type='u' name='row' direction='in' />" \ | |
119 | + " <arg type='u' name='col' direction='in' />" \ | |
120 | + " <arg type='u' name='len' direction='in' />" \ | |
121 | + " <arg type='y' name='lf' direction='in' />" \ | |
122 | + " <arg type='s' name='text' direction='out' />" \ | |
123 | + " </method>" \ | |
124 | + " <method name='setStringAtAddress'>" \ | |
125 | + " <arg type='u' name='addr' direction='in' />" \ | |
126 | + " <arg type='s' name='text' direction='in' />" \ | |
127 | + " <arg type='i' name='result' direction='out' />" \ | |
128 | + " </method>" \ | |
129 | + " <method name= 'getStringAtAddress'>" \ | |
130 | + " <arg type='u' name='addr' direction='in' />" \ | |
131 | + " <arg type='u' name='len' direction='in' />" \ | |
132 | + " <arg type='y' name='lf' direction='in' />" \ | |
133 | + " <arg type='s' name='text' direction='out' />" \ | |
134 | + " </method>" \ | |
135 | + " <method name= 'getFieldAt'>" \ | |
136 | + " <arg type='u' name='row' direction='in' />" \ | |
137 | + " <arg type='u' name='col' direction='in' />" \ | |
138 | + " <arg type='s' name='text' direction='out' />" \ | |
139 | + " </method>" \ | |
140 | + " <method name= 'getFieldAtAddress'>" \ | |
141 | + " <arg type='u' name='addr' direction='in' />" \ | |
142 | + " <arg type='s' name='text' direction='out' />" \ | |
143 | + " </method>" \ | |
144 | + " <method name= 'getFieldAtCursor'>" \ | |
145 | + " <arg type='s' name='text' direction='out' />" \ | |
146 | + " </method>" \ | |
147 | + " <method name= 'waitForReady'>" \ | |
148 | + " <arg type='u' name='seconds' direction='in' />" \ | |
149 | + " <arg type='i' name='result' direction='out' />" \ | |
150 | + " </method>" \ | |
151 | + " <method name= 'setCursorAddress'>" \ | |
152 | + " <arg type='u' name='addr' direction='in' />" \ | |
153 | + " <arg type='s' name='text' direction='out' />" \ | |
154 | + " </method>" \ | |
155 | + " <method name= 'setCursorPosition'>" \ | |
156 | + " <arg type='u' name='row' direction='in' />" \ | |
157 | + " <arg type='u' name='col' direction='in' />" \ | |
158 | + " <arg type='s' name='text' direction='out' />" \ | |
159 | + " </method>" \ | |
160 | + " <property type='s' name='version' access='read'/>" \ | |
161 | + " <property type='s' name='revision' access='read'/>" | |
162 | + ); | |
163 | + | |
164 | + // Constrói métodos usando a tabela de controle | |
165 | + const LIB3270_ACTION_ENTRY * actions = lib3270_get_action_table(); | |
166 | + for(ix = 0; actions[ix].name; ix++) | |
167 | + { | |
168 | + g_string_append_printf( | |
169 | + introspection, \ | |
170 | + " <method name='%s'>" \ | |
171 | + " </method>", actions[ix].name | |
172 | + ); | |
173 | + } | |
174 | + | |
175 | + // Toggle properties | |
176 | + for(ix = 0; ix < (int) LIB3270_TOGGLE_COUNT; ix++) { | |
177 | + g_string_append_printf(introspection, " <property type='i' name='%s' access='readwrite'/>", lib3270_get_toggle_name((LIB3270_TOGGLE) ix)); | |
178 | + } | |
179 | + | |
180 | + // Boolean properties | |
181 | + const LIB3270_INT_PROPERTY * bol_props = lib3270_get_boolean_properties_list(); | |
182 | + for(ix = 0; bol_props[ix].name; ix++) { | |
183 | +// debug("Boolean(%s)",bol_props[ix].name); | |
184 | + g_string_append_printf(introspection, " <property type='b' name='%s' access='%s'/>", | |
185 | + bol_props[ix].name, | |
186 | + ((bol_props[ix].set == NULL) ? "read" : "readwrite") | |
187 | + ); | |
188 | + } | |
189 | + | |
190 | + // Integer properties | |
191 | + const LIB3270_INT_PROPERTY * int_props = lib3270_get_int_properties_list(); | |
192 | + for(ix = 0; int_props[ix].name; ix++) { | |
193 | + g_string_append_printf(introspection, " <property type='i' name='%s' access='%s'/>", | |
194 | + int_props[ix].name, | |
195 | + ((int_props[ix].set == NULL) ? "read" : "readwrite") | |
196 | + ); | |
197 | + } | |
198 | + | |
199 | + // String properties | |
200 | + const LIB3270_STRING_PROPERTY * str_props = lib3270_get_string_properties_list(); | |
201 | + for(ix = 0; str_props[ix].name; ix++) { | |
202 | + g_string_append_printf(introspection, " <property type='s' name='%s' access='%s'/>", | |
203 | + str_props[ix].name, | |
204 | + ((str_props[ix].set == NULL) ? "read" : "readwrite") | |
205 | + ); | |
206 | + } | |
207 | + | |
208 | +} | |
209 | + | |
210 | +void ipc3270_set_session(GObject *object, H3270 *hSession) { | |
211 | + | |
212 | + ipc3270 * ipc = IPC3270(object); | |
213 | + ipc->hSession = hSession; | |
214 | + | |
215 | +} | |
216 | + | |
217 | +const gchar * ipc3270_get_display_charset(GObject *object) { | |
218 | + return lib3270_get_display_charset(IPC3270(object)->hSession); | |
219 | +} | |
220 | + | |
221 | +H3270 * ipc3270_get_session(GObject *object) { | |
222 | + return IPC3270(object)->hSession; | |
223 | +} | |
224 | + | |
225 | +void ipc3270_set_error(GObject *object, int errcode, GError **error) { | |
226 | + g_set_error(error,IPC3270(object)->error_domain,errcode,"%s",strerror(errcode)); | |
227 | +} | ... | ... |
... | ... | @@ -0,0 +1,78 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob | |
5 | + * o nome G3270. | |
6 | + * | |
7 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
8 | + * | |
9 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
10 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
11 | + * Free Software Foundation. | |
12 | + * | |
13 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
14 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
15 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
16 | + * obter mais detalhes. | |
17 | + * | |
18 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
19 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
20 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | + * | |
22 | + * Este programa está nomeado como - e possui - linhas de código. | |
23 | + * | |
24 | + * Contatos: | |
25 | + * | |
26 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
27 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
28 | + * | |
29 | + */ | |
30 | + | |
31 | + /** | |
32 | + * @brief Private definitions for pw3270 IPC linux module. | |
33 | + * | |
34 | + */ | |
35 | + | |
36 | +#ifndef LINUX_GOBJECT_H_INCLUDED | |
37 | + | |
38 | + #define LINUX_GOBJECT_H_INCLUDED | |
39 | + | |
40 | + #include <config.h> | |
41 | + | |
42 | + #define ENABLE_NLS | |
43 | + #define GETTEXT_PACKAGE PACKAGE_NAME | |
44 | + | |
45 | + #include <libintl.h> | |
46 | + #include <glib/gi18n.h> | |
47 | + #include <gio/gio.h> | |
48 | + | |
49 | + #include <lib3270.h> | |
50 | + #include <lib3270/ipc-glib.h> | |
51 | + | |
52 | + G_BEGIN_DECLS | |
53 | + | |
54 | + typedef struct _ipc3270 ipc3270; | |
55 | + typedef struct _ipc3270Class ipc3270Class; | |
56 | + | |
57 | + struct _ipc3270 { | |
58 | + GObject parent; | |
59 | + | |
60 | + struct { | |
61 | + gchar * name; | |
62 | + GDBusConnection * connection; | |
63 | + guint id; | |
64 | + } dbus; | |
65 | + | |
66 | + H3270 * hSession; | |
67 | + GQuark error_domain; | |
68 | + }; | |
69 | + | |
70 | + struct _ipc3270Class { | |
71 | + GObjectClass parent; | |
72 | + }; | |
73 | + | |
74 | + G_GNUC_INTERNAL void ipc3270_release_object(ipc3270 *object); | |
75 | + | |
76 | + G_END_DECLS | |
77 | + | |
78 | +#endif // LINUX_GOBJECT_H_INCLUDED | ... | ... |
... | ... | @@ -0,0 +1,207 @@ |
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 - e possui - linhas de código. | |
22 | + * | |
23 | + * Referências: | |
24 | + * | |
25 | + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | + * | |
28 | + * Contatos: | |
29 | + * | |
30 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | + * | |
33 | + */ | |
34 | + | |
35 | +#include "gobject.h" | |
36 | +#include <lib3270.h> | |
37 | +#include <lib3270/ipc-glib.h> | |
38 | + | |
39 | +#include <dbus/dbus-glib.h> | |
40 | +#include <dbus/dbus-glib-bindings.h> | |
41 | + | |
42 | +static void | |
43 | + method_call ( | |
44 | + G_GNUC_UNUSED GDBusConnection *connection, | |
45 | + G_GNUC_UNUSED const gchar *sender, | |
46 | + G_GNUC_UNUSED const gchar *object_path, | |
47 | + G_GNUC_UNUSED const gchar *interface_name, | |
48 | + const gchar *method_name, | |
49 | + GVariant *parameters, | |
50 | + GDBusMethodInvocation *invocation, | |
51 | + gpointer user_data) { | |
52 | + | |
53 | + g_autoptr (GError) error = NULL; | |
54 | + | |
55 | + GVariant * rc = ipc3270_method_call(G_OBJECT(user_data), method_name, parameters, &error); | |
56 | + | |
57 | + if(error) { | |
58 | + | |
59 | + if(rc) { | |
60 | + g_variant_unref(rc); | |
61 | + } | |
62 | + | |
63 | + g_dbus_method_invocation_return_gerror(invocation, error); | |
64 | + | |
65 | + } else if(rc) { | |
66 | + | |
67 | + g_dbus_method_invocation_return_value(invocation, rc); | |
68 | + | |
69 | + } else { | |
70 | + | |
71 | + g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Invalid or unexpected method call"); | |
72 | + | |
73 | + } | |
74 | + | |
75 | + | |
76 | +} | |
77 | + | |
78 | +static GVariant * | |
79 | + get_property ( | |
80 | + G_GNUC_UNUSED GDBusConnection *connection, | |
81 | + G_GNUC_UNUSED const gchar *sender, | |
82 | + G_GNUC_UNUSED const gchar *object_path, | |
83 | + G_GNUC_UNUSED const gchar *interface_name, | |
84 | + const gchar *property_name, | |
85 | + GError **error, | |
86 | + gpointer user_data) | |
87 | +{ | |
88 | + | |
89 | + return ipc3270_get_property(G_OBJECT(user_data), property_name, error); | |
90 | + | |
91 | +} | |
92 | + | |
93 | +static gboolean | |
94 | + set_property ( | |
95 | + G_GNUC_UNUSED GDBusConnection *connection, | |
96 | + G_GNUC_UNUSED const gchar *sender, | |
97 | + G_GNUC_UNUSED const gchar *object_path, | |
98 | + G_GNUC_UNUSED const gchar *interface_name, | |
99 | + const gchar *property_name, | |
100 | + GVariant *value, | |
101 | + GError **error, | |
102 | + gpointer user_data) | |
103 | +{ | |
104 | + | |
105 | + return ipc3270_set_property(G_OBJECT(user_data), property_name, value, error); | |
106 | + | |
107 | +} | |
108 | + | |
109 | +void ipc3270_export_object(GObject *object, const char *name, GError **error) { | |
110 | + | |
111 | + char id; | |
112 | + | |
113 | + #pragma GCC diagnostic push | |
114 | + #pragma GCC diagnostic ignored "-Wmissing-field-initializers" | |
115 | + static const GDBusInterfaceVTable interface_vtable = { | |
116 | + method_call, | |
117 | + get_property, | |
118 | + set_property | |
119 | + }; | |
120 | + #pragma GCC diagnostic pop | |
121 | + | |
122 | + ipc3270 * ipc = IPC3270(object); | |
123 | + | |
124 | + ipc->dbus.connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, error); | |
125 | + if(*error) { | |
126 | + g_message("Can't get session bus: %s",(*error)->message); | |
127 | + return; | |
128 | + } | |
129 | + | |
130 | + g_dbus_connection_set_exit_on_close(ipc->dbus.connection,FALSE); | |
131 | + | |
132 | + for(id='a'; id < 'z' && !ipc->dbus.id && !*error; id++) { | |
133 | + | |
134 | + g_autofree gchar *object_name = g_strdup_printf(PW3270_IPC_SESSION_BUS_NAME,name,id); | |
135 | + | |
136 | + debug("Requesting \"%s\"",object_name); | |
137 | + | |
138 | + // https://dbus.freedesktop.org/doc/dbus-specification.html | |
139 | + GError *err = NULL; | |
140 | + | |
141 | + GVariant * response = | |
142 | + g_dbus_connection_call_sync ( | |
143 | + ipc->dbus.connection, | |
144 | + DBUS_SERVICE_DBUS, | |
145 | + DBUS_PATH_DBUS, | |
146 | + DBUS_INTERFACE_DBUS, | |
147 | + "RequestName", | |
148 | + g_variant_new ("(su)", object_name, DBUS_NAME_FLAG_DO_NOT_QUEUE), | |
149 | + NULL, | |
150 | + G_DBUS_CALL_FLAGS_NONE, | |
151 | + -1, | |
152 | + NULL, | |
153 | + &err | |
154 | + ); | |
155 | + | |
156 | + if(err) { | |
157 | + | |
158 | + g_message("Can't request \"%s\": %s",object_name,err->message); | |
159 | + g_error_free(err); | |
160 | + err = NULL; | |
161 | + | |
162 | + } else if(response) { | |
163 | + | |
164 | + guint32 reply = 0; | |
165 | + g_variant_get(response, "(u)", &reply); | |
166 | + g_variant_unref(response); | |
167 | + | |
168 | + if(reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { | |
169 | + | |
170 | + ipc->dbus.name = g_strdup(object_name); | |
171 | + g_message("Got %s", ipc->dbus.name); | |
172 | + | |
173 | + lib3270_set_session_id(ipc->hSession, id); | |
174 | + | |
175 | + // Introspection data for the service we are exporting | |
176 | + GString * introspection = g_string_new("<node><interface name='" PW3270_IPC_SESSION_INTERFACE_NAME "'>"); | |
177 | + ipc3270_add_terminal_introspection(introspection); | |
178 | + g_string_append(introspection,"</interface></node>"); | |
179 | + | |
180 | + gchar * introspection_xml = g_string_free(introspection,FALSE); | |
181 | + | |
182 | + // debug("\n%s\n",introspection_xml); | |
183 | + | |
184 | + GDBusNodeInfo * introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL); | |
185 | + | |
186 | + // Register object-id | |
187 | + ipc->dbus.id = g_dbus_connection_register_object ( | |
188 | + ipc->dbus.connection, | |
189 | + PW3270_IPC_SESSION_OBJECT_PATH, | |
190 | + introspection_data->interfaces[0], | |
191 | + &interface_vtable, | |
192 | + ipc, | |
193 | + NULL, | |
194 | + error | |
195 | + ); | |
196 | + | |
197 | + g_dbus_node_info_unref(introspection_data); | |
198 | + g_free(introspection_xml); | |
199 | + | |
200 | + return; | |
201 | + } | |
202 | + | |
203 | + } | |
204 | + | |
205 | + } | |
206 | + | |
207 | +} | ... | ... |
... | ... | @@ -0,0 +1,191 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob | |
5 | + * o nome G3270. | |
6 | + * | |
7 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
8 | + * | |
9 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
10 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
11 | + * Free Software Foundation. | |
12 | + * | |
13 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
14 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
15 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
16 | + * obter mais detalhes. | |
17 | + * | |
18 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
19 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
20 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | + * | |
22 | + * Este programa está nomeado como testprogram.c e possui - linhas de código. | |
23 | + * | |
24 | + * Contatos: | |
25 | + * | |
26 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
27 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
28 | + * | |
29 | + */ | |
30 | + | |
31 | + | |
32 | + /** | |
33 | + * @brief Plugin startup/stop for linux. | |
34 | + * | |
35 | + */ | |
36 | + | |
37 | + #include "private.h" | |
38 | + | |
39 | + #include <dbus/dbus-glib.h> | |
40 | + #include <dbus/dbus-glib-bindings.h> | |
41 | + | |
42 | + static void pw3270_dbus_cleanup(struct DBusSession * dBus) { | |
43 | + | |
44 | + if(dBus->proxy) { | |
45 | + g_object_unref(dBus); | |
46 | + } | |
47 | + | |
48 | + } | |
49 | + | |
50 | + int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal) { | |
51 | + | |
52 | + struct DBusSession * dBus = g_new0(struct DBusSession,1); | |
53 | + GError * error = NULL; | |
54 | + int id; | |
55 | + | |
56 | + g_object_set_data_full(G_OBJECT(terminal), "dbus-session-info", dBus, (GDestroyNotify) pw3270_dbus_cleanup); | |
57 | + | |
58 | + dBus->connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error); | |
59 | + | |
60 | + if(error) { | |
61 | + GtkWidget *dialog = gtk_message_dialog_new( | |
62 | + GTK_WINDOW(window), | |
63 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
64 | + GTK_MESSAGE_ERROR, | |
65 | + GTK_BUTTONS_OK, | |
66 | + _( "Can't get D-Bus connection" )); | |
67 | + | |
68 | + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); | |
69 | + g_error_free(error); | |
70 | + | |
71 | + gtk_dialog_run(GTK_DIALOG(dialog)); | |
72 | + gtk_widget_destroy(dialog); | |
73 | + | |
74 | + return -1; | |
75 | + } | |
76 | + | |
77 | + g_dbus_connection_set_exit_on_close(dBus->connection,FALSE); | |
78 | + | |
79 | + /* | |
80 | + dBus->proxy = g_dbus_proxy_new_sync( | |
81 | + dBus->connection, | |
82 | + G_DBUS_PROXY_FLAGS_NONE, | |
83 | + NULL, // GDBusInterfaceInfo | |
84 | + "br.com.bb." PACKAGE_NAME, // name | |
85 | + "/br/com/bb/" PACKAGE_NAME "/terminal", // object path | |
86 | + "br.com.bb." PACKAGE_NAME ".terminal", // interface | |
87 | + NULL, // GCancellable | |
88 | + &error ); | |
89 | + | |
90 | + if(error) { | |
91 | + | |
92 | + GtkWidget *dialog = gtk_message_dialog_new( | |
93 | + GTK_WINDOW(window), | |
94 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
95 | + GTK_MESSAGE_ERROR, | |
96 | + GTK_BUTTONS_OK, | |
97 | + _( "Can't get D-Bus proxy object" )); | |
98 | + | |
99 | + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); | |
100 | + g_error_free(error); | |
101 | + | |
102 | + gtk_dialog_run(GTK_DIALOG(dialog)); | |
103 | + gtk_widget_destroy(dialog); | |
104 | + | |
105 | + return -1; | |
106 | + } | |
107 | + */ | |
108 | + | |
109 | + for(id='a'; id < 'z' && !error && !dBus->proxy; id++) { | |
110 | + | |
111 | + gchar *name = g_strdup_printf("br.com.bb.%s.%c",gtk_widget_get_name(window),id); | |
112 | + | |
113 | + debug("Requesting \"%s\"",name); | |
114 | + | |
115 | + // https://dbus.freedesktop.org/doc/dbus-specification.html | |
116 | + GVariant * response = | |
117 | + g_dbus_connection_call_sync ( | |
118 | + dBus->connection, | |
119 | + DBUS_SERVICE_DBUS, | |
120 | + DBUS_PATH_DBUS, | |
121 | + DBUS_INTERFACE_DBUS, | |
122 | + "RequestName", | |
123 | + g_variant_new ("(su)", name, DBUS_NAME_FLAG_DO_NOT_QUEUE), | |
124 | + NULL, | |
125 | + G_DBUS_CALL_FLAGS_NONE, | |
126 | + -1, | |
127 | + NULL, | |
128 | + &error | |
129 | + ); | |
130 | + | |
131 | + if(error) { | |
132 | + g_message("Can't request \"%s\": %s",name,error->message); | |
133 | + g_error_free(error); | |
134 | + error = NULL; | |
135 | + } | |
136 | + | |
137 | + if(response) { | |
138 | + | |
139 | + guint32 reply = 0; | |
140 | + g_variant_get(response, "(u)", &reply); | |
141 | + g_variant_unref(response); | |
142 | + | |
143 | + if(reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { | |
144 | + | |
145 | + dBus->proxy = g_dbus_proxy_new_sync( | |
146 | + dBus->connection, | |
147 | + G_DBUS_PROXY_FLAGS_NONE, | |
148 | + NULL, // GDBusInterfaceInfo | |
149 | + name, // name | |
150 | + "/br/com/bb/" PACKAGE_NAME "/terminal", // object path | |
151 | + "br.com.bb." PACKAGE_NAME ".terminal", // interface | |
152 | + NULL, // GCancellable | |
153 | + &error ); | |
154 | + | |
155 | + gchar * widget_name = g_strdup_printf("%s:%c",gtk_widget_get_name(window),id); | |
156 | + v3270_set_session_name(terminal, widget_name); | |
157 | + g_free(widget_name); | |
158 | + | |
159 | + g_message("Got %s - %s", name, v3270_get_session_name(terminal)); | |
160 | + | |
161 | + } | |
162 | + | |
163 | + } | |
164 | + | |
165 | + g_free(name); | |
166 | + | |
167 | + } | |
168 | + | |
169 | + if(!dBus->proxy) { | |
170 | + GtkWidget *dialog = gtk_message_dialog_new( | |
171 | + GTK_WINDOW(window), | |
172 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
173 | + GTK_MESSAGE_ERROR, | |
174 | + GTK_BUTTONS_OK, | |
175 | + _( "Can't get DBUS object name" )); | |
176 | + | |
177 | + gtk_dialog_run(GTK_DIALOG(dialog)); | |
178 | + gtk_widget_destroy(dialog); | |
179 | + | |
180 | + return -1; | |
181 | + } | |
182 | + | |
183 | + // Got D-Bus name, register object. | |
184 | + | |
185 | + return 0; | |
186 | + | |
187 | + } | |
188 | + | |
189 | + #endif // !_WIN32 | |
190 | + | |
191 | + | ... | ... |
... | ... | @@ -0,0 +1,111 @@ |
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 - e possui - linhas de código. | |
22 | + * | |
23 | + * Referências: | |
24 | + * | |
25 | + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | + * | |
28 | + * Contatos: | |
29 | + * | |
30 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | + * | |
33 | + */ | |
34 | + | |
35 | +#include "gobject.h" | |
36 | +#include <lib3270.h> | |
37 | +#include <lib3270/ipc-glib.h> | |
38 | + | |
39 | +#include <dbus/dbus-glib.h> | |
40 | +#include <dbus/dbus-glib-bindings.h> | |
41 | + | |
42 | +void ipc3270_release_object(ipc3270 *object) { | |
43 | + | |
44 | + if(object->dbus.id) { | |
45 | + g_dbus_connection_unregister_object(object->dbus.connection,object->dbus.id); | |
46 | + } | |
47 | + | |
48 | + if(object->dbus.name) { | |
49 | + | |
50 | + debug("Releasing %s",object->dbus.name); | |
51 | + | |
52 | + // https://dbus.freedesktop.org/doc/dbus-specification.html | |
53 | + GError *err = NULL; | |
54 | + | |
55 | + GVariant * response = | |
56 | + g_dbus_connection_call_sync ( | |
57 | + object->dbus.connection, | |
58 | + DBUS_SERVICE_DBUS, | |
59 | + DBUS_PATH_DBUS, | |
60 | + DBUS_INTERFACE_DBUS, | |
61 | + "ReleaseName", | |
62 | + g_variant_new ("(s)", object->dbus.name), | |
63 | + NULL, | |
64 | + G_DBUS_CALL_FLAGS_NONE, | |
65 | + -1, | |
66 | + NULL, | |
67 | + &err | |
68 | + ); | |
69 | + | |
70 | + if(err) { | |
71 | + | |
72 | + g_message("Can't release \"%s\": %s",object->dbus.name,err->message); | |
73 | + g_error_free(err); | |
74 | + err = NULL; | |
75 | + | |
76 | + } else if(response) { | |
77 | + | |
78 | + guint32 reply = 0; | |
79 | + g_variant_get(response, "(u)", &reply); | |
80 | + g_variant_unref(response); | |
81 | + | |
82 | + switch(reply) | |
83 | + { | |
84 | + case DBUS_RELEASE_NAME_REPLY_RELEASED: | |
85 | + // The caller has released his claim on the given name. | |
86 | + // Either the caller was the primary owner of the name, and the name is | |
87 | + // now unused or taken by somebody waiting in the queue for the name, | |
88 | + // or the caller was waiting in the queue for the name and has now been removed from the queue. | |
89 | + g_message("%s released",object->dbus.name); | |
90 | + break; | |
91 | + | |
92 | + case DBUS_RELEASE_NAME_REPLY_NON_EXISTENT: | |
93 | + // The given name does not exist on this bus. | |
94 | + g_message("%s does not exist on this bus",object->dbus.name); | |
95 | + break; | |
96 | + | |
97 | + case DBUS_RELEASE_NAME_REPLY_NOT_OWNER: | |
98 | + // The caller was not the primary owner of this name, and was also not waiting in the queue to own this name. | |
99 | + g_message("%s does not exist on this bus", object->dbus.name); | |
100 | + break; | |
101 | + | |
102 | + default: | |
103 | + g_message("Unexpected response %u when removing %s",(unsigned int) reply, object->dbus.name); | |
104 | + } | |
105 | + } | |
106 | + | |
107 | + g_free(object->dbus.name); | |
108 | + object->dbus.name = NULL; | |
109 | + } | |
110 | + | |
111 | +} | ... | ... |
... | ... | @@ -0,0 +1,190 @@ |
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 - e possui - linhas de código. | |
22 | + * | |
23 | + * Referências: | |
24 | + * | |
25 | + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | + * | |
28 | + * Contatos: | |
29 | + * | |
30 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | + * | |
33 | + */ | |
34 | + | |
35 | +#include <config.h> | |
36 | +#include <string.h> | |
37 | +#include <lib3270/ipc-glib.h> | |
38 | +#include <lib3270.h> | |
39 | +#include <lib3270/actions.h> | |
40 | +#include <lib3270/trace.h> | |
41 | + | |
42 | +// #include <dbus/dbus-glib.h> | |
43 | +// #include <dbus/dbus-glib-bindings.h> | |
44 | + | |
45 | +GVariant * ipc3270_method_call(GObject *object, const gchar *method_name, GVariant *parameters, GError **error) | |
46 | +{ | |
47 | + | |
48 | + size_t ix; | |
49 | + H3270 * hSession = ipc3270_get_session(object); | |
50 | + | |
51 | + lib3270_trace_event(hSession,"Method %s called on session %c\n",method_name,lib3270_get_session_id(hSession)); | |
52 | + | |
53 | + debug("%s(%s)",__FUNCTION__,method_name); | |
54 | + | |
55 | + if(!g_ascii_strcasecmp(method_name,"getString")) | |
56 | + { | |
57 | + return ipc3270_GVariant_from_input_string(object, lib3270_get_string_at_address(hSession,0,-1,'\n'), error); | |
58 | + } | |
59 | + else if(!g_ascii_strcasecmp(method_name,"setString")) | |
60 | + { | |
61 | + gchar *text = NULL; | |
62 | + g_variant_get(parameters, "(&s)", &text); | |
63 | + | |
64 | + g_autofree gchar * converted = ipc3270_convert_output_string(object, text, error); | |
65 | + if(lib3270_input_string(hSession,(const unsigned char *) converted) < 0) | |
66 | + { | |
67 | + // Failed! | |
68 | + debug("%s failed: %s",method_name,strerror(errno)); | |
69 | + ipc3270_set_error(object,errno,error); | |
70 | + return NULL; | |
71 | + } | |
72 | + | |
73 | + // Suceeded | |
74 | + debug("%s Suceeds",method_name); | |
75 | + return g_variant_new("(i)", (gint) 0); | |
76 | + | |
77 | + } | |
78 | + else if(!g_ascii_strcasecmp(method_name,"setStringAt")) | |
79 | + { | |
80 | + guint row,col; | |
81 | + gchar *text = NULL; | |
82 | + g_variant_get(parameters, "(ii&s)", &row, &col, &text); | |
83 | + | |
84 | + g_autofree gchar * converted = ipc3270_convert_output_string(object, text, error); | |
85 | + if(lib3270_set_string_at(hSession,row,col,(const unsigned char *) converted) < 0) | |
86 | + { | |
87 | + // Failed! | |
88 | + ipc3270_set_error(object,errno,error); | |
89 | + return NULL; | |
90 | + } | |
91 | + | |
92 | + // Suceeded | |
93 | + return g_variant_new("(i)", (gint) 0); | |
94 | + | |
95 | + } | |
96 | + else if(!g_ascii_strcasecmp(method_name,"getStringAt")) | |
97 | + { | |
98 | + guint row,col,len; | |
99 | + guchar lf; | |
100 | + g_variant_get(parameters, "(uuuy)", &row, &col, &len,&lf); | |
101 | + | |
102 | + return ipc3270_GVariant_from_input_string(object,lib3270_get_string_at(hSession, row, col, len, lf),error); | |
103 | + | |
104 | + } | |
105 | + else if(!g_ascii_strcasecmp(method_name,"setStringAtAddress")) | |
106 | + { | |
107 | + guint addr; | |
108 | + gchar *text = NULL; | |
109 | + g_variant_get(parameters, "(i&s)", &addr, &text); | |
110 | + | |
111 | + g_autofree gchar * converted = ipc3270_convert_output_string(object, text, error); | |
112 | + if(lib3270_set_string_at_address(hSession,addr,(unsigned char *) converted) < 0) | |
113 | + { | |
114 | + // Failed! | |
115 | + ipc3270_set_error(object,errno,error); | |
116 | + return NULL; | |
117 | + } | |
118 | + | |
119 | + // Suceeded | |
120 | + return g_variant_new("(i)", (gint) 0); | |
121 | + | |
122 | + } | |
123 | + else if(!g_ascii_strcasecmp(method_name,"getStringAtAddress")) | |
124 | + { | |
125 | + guint addr,len; | |
126 | + guchar lf; | |
127 | + g_variant_get(parameters, "(uuy)", &addr, &len, &lf); | |
128 | + | |
129 | + debug("lf=%02x",(int) lf); | |
130 | + | |
131 | + return ipc3270_GVariant_from_input_string(object,lib3270_get_string_at_address(hSession, addr, len, lf),error); | |
132 | + | |
133 | + } | |
134 | + else if(!g_ascii_strcasecmp(method_name,"waitforready")) | |
135 | + { | |
136 | + guint timeout = 1; | |
137 | + g_variant_get(parameters, "(u)", &timeout); | |
138 | + return g_variant_new("(i)", (gint) lib3270_wait_for_ready(hSession,timeout)); | |
139 | + } | |
140 | + | |
141 | + // Check action table. | |
142 | + const LIB3270_ACTION_ENTRY * actions = lib3270_get_action_table(); | |
143 | + for(ix = 0; actions[ix].name; ix++) | |
144 | + { | |
145 | + if(!g_ascii_strcasecmp(actions[ix].name,method_name)) { | |
146 | + | |
147 | + int rc = actions[ix].call(hSession); | |
148 | + if(rc) | |
149 | + { | |
150 | + // Failed | |
151 | + ipc3270_set_error(object,errno,error); | |
152 | + return NULL; | |
153 | + } | |
154 | + | |
155 | + // Suceeded | |
156 | + return g_variant_new("(i)", (gint) 0); | |
157 | + | |
158 | + } | |
159 | + } | |
160 | + | |
161 | + // Check int methods | |
162 | + const IPC_METHOD_INT_ARG * int_methods = ipc3270_get_int_arg_methods(); | |
163 | + | |
164 | + for(ix = 0; int_methods[ix].name; ix++) | |
165 | + { | |
166 | + if(!g_ascii_strcasecmp(int_methods[ix].name,method_name)) { | |
167 | + | |
168 | + gint value; | |
169 | + g_variant_get(parameters, "(i)", &value); | |
170 | + | |
171 | + int rc = int_methods[ix].call(hSession, value); | |
172 | + if(rc) | |
173 | + { | |
174 | + // Failed | |
175 | + ipc3270_set_error(object,errno,error); | |
176 | + return NULL; | |
177 | + } | |
178 | + | |
179 | + // Suceeded | |
180 | + return g_variant_new("(i)", (gint) 0); | |
181 | + | |
182 | + } | |
183 | + | |
184 | + } | |
185 | + | |
186 | + g_message("Unknown method \"%s\"",method_name); | |
187 | + | |
188 | + return NULL; | |
189 | + | |
190 | +} | ... | ... |
... | ... | @@ -0,0 +1,153 @@ |
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 - e possui - linhas de código. | |
22 | + * | |
23 | + * Referências: | |
24 | + * | |
25 | + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | + * | |
28 | + * Contatos: | |
29 | + * | |
30 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | + * | |
33 | + */ | |
34 | + | |
35 | +#include <config.h> | |
36 | +#include <lib3270/ipc-glib.h> | |
37 | +#include <lib3270.h> | |
38 | +#include <lib3270/properties.h> | |
39 | +#include <lib3270/trace.h> | |
40 | + | |
41 | +gboolean ipc3270_set_property(GObject *object, const gchar *property_name, GVariant *value, GError **error) { | |
42 | + | |
43 | + // Check for property | |
44 | + size_t ix; | |
45 | + H3270 * hSession = ipc3270_get_session(object); | |
46 | + | |
47 | + lib3270_trace_event(hSession,"SetProperty(%s) called on session %c\n",property_name,lib3270_get_session_id(hSession)); | |
48 | + | |
49 | + // Boolean properties | |
50 | + const LIB3270_INT_PROPERTY * boolprop = lib3270_get_boolean_properties_list(); | |
51 | + for(ix = 0; boolprop[ix].name; ix++) { | |
52 | + | |
53 | + if(boolprop[ix].set && !g_ascii_strcasecmp(boolprop[ix].name, property_name)) { | |
54 | + | |
55 | + // Found it! | |
56 | + if(boolprop[ix].set(hSession, (int) (g_variant_get_boolean(value) ? 1 : 0))) { | |
57 | + | |
58 | + // Erro! | |
59 | + g_set_error_literal(error, | |
60 | + G_IO_ERROR, | |
61 | + G_IO_ERROR_FAILED, | |
62 | + g_strerror(errno) | |
63 | + ); | |
64 | + | |
65 | + return FALSE; | |
66 | + } | |
67 | + | |
68 | + return TRUE; | |
69 | + | |
70 | + } | |
71 | + | |
72 | + } | |
73 | + | |
74 | + // Integer properties | |
75 | + const LIB3270_INT_PROPERTY * intprop = lib3270_get_int_properties_list(); | |
76 | + for(ix = 0; intprop[ix].name; ix++) { | |
77 | + | |
78 | + if(intprop[ix].set && !g_ascii_strcasecmp(intprop[ix].name, property_name)) { | |
79 | + | |
80 | + // Found it! | |
81 | + if(intprop[ix].set(hSession, (int) (g_variant_get_boolean(value) ? 1 : 0))) { | |
82 | + | |
83 | + // Erro! | |
84 | + g_set_error_literal( | |
85 | + error, | |
86 | + G_IO_ERROR, | |
87 | + G_IO_ERROR_FAILED, | |
88 | + g_strerror(errno) | |
89 | + ); | |
90 | + | |
91 | + return FALSE; | |
92 | + } | |
93 | + | |
94 | + return TRUE; | |
95 | + | |
96 | + } | |
97 | + | |
98 | + } | |
99 | + | |
100 | + // String properties | |
101 | + const LIB3270_STRING_PROPERTY * strprop = lib3270_get_string_properties_list(); | |
102 | + for(ix = 0; strprop[ix].name; ix++) { | |
103 | + | |
104 | + if(strprop[ix].set && !g_ascii_strcasecmp(strprop[ix].name, property_name)) { | |
105 | + | |
106 | + // Found it! | |
107 | + if(strprop[ix].set(hSession, g_variant_get_string(value,NULL))) { | |
108 | + | |
109 | + // Erro! | |
110 | + g_set_error_literal(error, | |
111 | + G_IO_ERROR, | |
112 | + G_IO_ERROR_FAILED, | |
113 | + g_strerror(errno) | |
114 | + ); | |
115 | + | |
116 | + return FALSE; | |
117 | + } | |
118 | + | |
119 | + return TRUE; | |
120 | + | |
121 | + } | |
122 | + | |
123 | + } | |
124 | + | |
125 | + // Check for toggle | |
126 | + LIB3270_TOGGLE toggle = lib3270_get_toggle_id(property_name); | |
127 | + if(toggle != (LIB3270_TOGGLE) -1) { | |
128 | + | |
129 | + // Is a Tn3270 toggle, get it! | |
130 | + if(lib3270_set_toggle(hSession,toggle,(int) g_variant_get_int32(value))) { | |
131 | + | |
132 | + // Erro! | |
133 | + g_set_error_literal(error, | |
134 | + G_IO_ERROR, | |
135 | + G_IO_ERROR_FAILED, | |
136 | + g_strerror(errno) | |
137 | + ); | |
138 | + | |
139 | + return FALSE; | |
140 | + | |
141 | + } | |
142 | + | |
143 | + return TRUE; | |
144 | + } | |
145 | + | |
146 | + g_set_error (error, | |
147 | + G_IO_ERROR, | |
148 | + G_IO_ERROR_NOT_FOUND, | |
149 | + "Can't find any property named %s", property_name | |
150 | + ); | |
151 | + | |
152 | + return FALSE; | |
153 | +} | ... | ... |
... | ... | @@ -0,0 +1,45 @@ |
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 - e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | +#include <lib3270.h> | |
31 | +#include <lib3270/ipc-glib.h> | |
32 | + | |
33 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
34 | + | |
35 | + #if ! GLIB_CHECK_VERSION(2,44,0) | |
36 | + | |
37 | + // Reference: https://github.com/ImageMagick/glib/blob/master/glib/glib-autocleanups.h | |
38 | + void ipc3270_autoptr_cleanup_generic_gfree(void *p) | |
39 | + { | |
40 | + void **pp = (void**)p; | |
41 | + g_free (*pp); | |
42 | + } | |
43 | + | |
44 | + #endif // ! GLIB(2,44,0) | |
45 | + | ... | ... |
... | ... | @@ -0,0 +1,92 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como gobject.c e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | +#include "gobject.h" | |
31 | +#include <lib3270.h> | |
32 | +#include <lib3270/actions.h> | |
33 | +#include <lib3270/properties.h> | |
34 | +#include <lib3270/ipc-glib.h> | |
35 | + | |
36 | +/*--[ Widget definition ]----------------------------------------------------------------------------*/ | |
37 | + | |
38 | +G_DEFINE_TYPE(ipc3270, ipc3270, G_TYPE_OBJECT) | |
39 | + | |
40 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
41 | + | |
42 | +static void ipc3270_finalize(GObject *object) { | |
43 | + | |
44 | + debug("ipc3270::%s(%p)",__FUNCTION__,object); | |
45 | + | |
46 | + ipc3270_release_object(IPC3270(object)); | |
47 | + | |
48 | + G_OBJECT_CLASS(ipc3270_parent_class)->finalize(object); | |
49 | + | |
50 | +} | |
51 | + | |
52 | + | |
53 | +static void ipc3270_class_init(ipc3270Class *klass) { | |
54 | + | |
55 | + debug("%s",__FUNCTION__); | |
56 | + | |
57 | + GObjectClass *object_class; | |
58 | + object_class = G_OBJECT_CLASS (klass); | |
59 | + object_class->finalize = ipc3270_finalize; | |
60 | + | |
61 | +} | |
62 | + | |
63 | +static void ipc3270_init(ipc3270 *object) { | |
64 | + | |
65 | + debug("%s(%p)",__FUNCTION__,object); | |
66 | + object->error_domain = g_quark_from_static_string(PACKAGE_NAME); | |
67 | + | |
68 | +} | |
69 | + | |
70 | +GObject * ipc3270_new() { | |
71 | + return g_object_new(GLIB_TYPE_IPC3270, NULL); | |
72 | +} | |
73 | + | |
74 | +void ipc3270_set_session(GObject *object, H3270 *hSession) { | |
75 | + | |
76 | + ipc3270 * ipc = IPC3270(object); | |
77 | + ipc->hSession = hSession; | |
78 | + | |
79 | +} | |
80 | + | |
81 | +const gchar * ipc3270_get_display_charset(GObject *object) { | |
82 | + return lib3270_get_display_charset(IPC3270(object)->hSession); | |
83 | +} | |
84 | + | |
85 | +H3270 * ipc3270_get_session(GObject *object) { | |
86 | + return IPC3270(object)->hSession; | |
87 | +} | |
88 | + | |
89 | +void ipc3270_set_error(GObject *object, int errcode, GError **error) { | |
90 | + g_set_error(error,IPC3270(object)->error_domain,errcode,"%s",strerror(errcode)); | |
91 | +} | |
92 | + | ... | ... |
... | ... | @@ -0,0 +1,98 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob | |
5 | + * o nome G3270. | |
6 | + * | |
7 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
8 | + * | |
9 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
10 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
11 | + * Free Software Foundation. | |
12 | + * | |
13 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
14 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
15 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
16 | + * obter mais detalhes. | |
17 | + * | |
18 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
19 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
20 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | + * | |
22 | + * Este programa está nomeado como - e possui - linhas de código. | |
23 | + * | |
24 | + * Contatos: | |
25 | + * | |
26 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
27 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
28 | + * | |
29 | + */ | |
30 | + | |
31 | + /** | |
32 | + * @brief Private definitions for pw3270 IPC windows module. | |
33 | + * | |
34 | + */ | |
35 | + | |
36 | +#ifndef WINDOWS_GOBJECT_H_INCLUDED | |
37 | + | |
38 | + #define WINDOWS_GOBJECT_H_INCLUDED | |
39 | + | |
40 | + #include <windows.h> | |
41 | + #include <config.h> | |
42 | + | |
43 | + #define ENABLE_NLS | |
44 | + #define GETTEXT_PACKAGE PACKAGE_NAME | |
45 | + | |
46 | + #include <libintl.h> | |
47 | + #include <glib/gi18n.h> | |
48 | + #include <gio/gio.h> | |
49 | + | |
50 | + #include <lib3270.h> | |
51 | + #include <lib3270/ipc-glib.h> | |
52 | + | |
53 | + #define PIPE_BUFFER_LENGTH 8192 | |
54 | + | |
55 | + G_BEGIN_DECLS | |
56 | + | |
57 | + typedef struct _ipc3270 ipc3270; | |
58 | + typedef struct _ipc3270Class ipc3270Class; | |
59 | + typedef struct _ipc3270Request ipc3270Request; | |
60 | + | |
61 | + typedef enum _ipc3270_pipe_state { | |
62 | + PIPE_STATE_WAITING, | |
63 | + PIPE_STATE_READ, | |
64 | + PIPE_STATE_PENDING_READ, | |
65 | + PIPE_STATE_UNDEFINED | |
66 | + } IPC3270_PIPE_STATE; | |
67 | + | |
68 | + typedef struct _ipc3270_pipe_source { | |
69 | + GSource gsrc; | |
70 | + GObject * object; | |
71 | + HANDLE hPipe; | |
72 | + | |
73 | + IPC3270_PIPE_STATE state; | |
74 | + | |
75 | + OVERLAPPED overlap; | |
76 | + unsigned char buffer[PIPE_BUFFER_LENGTH+1]; | |
77 | + | |
78 | + } IPC3270_PIPE_SOURCE; | |
79 | + | |
80 | + struct _ipc3270 { | |
81 | + GObject parent; | |
82 | + H3270 * hSession; | |
83 | + IPC3270_PIPE_SOURCE * source; | |
84 | + GQuark error_domain; | |
85 | + }; | |
86 | + | |
87 | + struct _ipc3270Class { | |
88 | + GObjectClass parent; | |
89 | + }; | |
90 | + | |
91 | + G_GNUC_INTERNAL GSourceFuncs ipc3270_source_funcs; | |
92 | + | |
93 | + G_GNUC_INTERNAL void ipc3270_release_object(ipc3270 *object); | |
94 | + G_GNUC_INTERNAL void ipc3270_wait_for_client(IPC3270_PIPE_SOURCE *source); | |
95 | + | |
96 | + G_END_DECLS | |
97 | + | |
98 | +#endif // WINDOWS_GOBJECT_H_INCLUDED | ... | ... |
... | ... | @@ -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. Registro no INPI sob | |
5 | + * o nome G3270. | |
6 | + * | |
7 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
8 | + * | |
9 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
10 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
11 | + * Free Software Foundation. | |
12 | + * | |
13 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
14 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
15 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
16 | + * obter mais detalhes. | |
17 | + * | |
18 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
19 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
20 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | + * | |
22 | + * Este programa está nomeado como inout.c e possui - linhas de código. | |
23 | + * | |
24 | + * Contatos: | |
25 | + * | |
26 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
27 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
28 | + * | |
29 | + */ | |
30 | + | |
31 | + | |
32 | + /** | |
33 | + * @brief Pack/Unpack IPC data block. | |
34 | + * | |
35 | + */ | |
36 | + | |
37 | + #include <config.h> | |
38 | + #include <lib3270/ipc-glib.h> | |
39 | + #include <string.h> | |
40 | + #include <stdlib.h> | |
41 | + | |
42 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
43 | + | |
44 | +unsigned char * ipc3270_pack_error(const GError *error, size_t * szPacket) { | |
45 | + | |
46 | + static const char * error_response = "error"; | |
47 | + | |
48 | + *szPacket = strlen(error_response) + 1 + (sizeof(guint16) * 2) + strlen(error->message); | |
49 | + | |
50 | + // Allocate buffer | |
51 | + unsigned char * outputBuffer = g_malloc0(*szPacket); | |
52 | + unsigned char * txtptr = outputBuffer; | |
53 | + | |
54 | + // Add name | |
55 | + strcpy((char *) txtptr,error_response); | |
56 | + txtptr += strlen((char *) txtptr) + 1; | |
57 | + | |
58 | + // Add RC | |
59 | + *((guint16 *) txtptr) = (guint16) error->code; | |
60 | + txtptr += sizeof(guint16); | |
61 | + | |
62 | + // Add message | |
63 | + strcpy((char *) txtptr,error->message); | |
64 | + txtptr += (strlen((char *) txtptr)+1); | |
65 | + | |
66 | + return outputBuffer; | |
67 | +} | |
68 | + | |
69 | +static unsigned char * setup_header(unsigned char *txtptr, const gchar *name, int id, size_t count) { | |
70 | + | |
71 | + // Add name | |
72 | + strcpy((char *) txtptr,name); | |
73 | + txtptr += strlen((char *) txtptr) + 1; | |
74 | + | |
75 | + // Add ID | |
76 | + *((guint16 *) txtptr) = (guint16) id; | |
77 | + txtptr += sizeof(guint16); | |
78 | + | |
79 | + // Update ptr; | |
80 | + *((guint16 *) txtptr) = (guint16) count; | |
81 | + txtptr += sizeof(guint16); | |
82 | + | |
83 | + return txtptr; | |
84 | +} | |
85 | + | |
86 | +unsigned char * pack_value(unsigned char *txtptr, GVariant *value) { | |
87 | + | |
88 | + unsigned char type = (unsigned char) g_variant_get_type_string(value)[0]; | |
89 | + | |
90 | + debug("%s type=%c",__FUNCTION__,type); | |
91 | + | |
92 | + *(txtptr++) = type; | |
93 | + | |
94 | + switch(type) { | |
95 | + // https://developer.gnome.org/glib/stable/gvariant-format-strings.html | |
96 | + case 's': | |
97 | + strcpy((char *) txtptr,g_variant_get_string(value,NULL)); | |
98 | + txtptr += (strlen((char *) txtptr)+1); | |
99 | + break; | |
100 | + | |
101 | + case 'b': // gboolean | |
102 | + *(txtptr++) = g_variant_get_boolean(value) ? 1 : 0; | |
103 | + break; | |
104 | + | |
105 | + case 'y': // guchar | |
106 | + *(txtptr++) = g_variant_get_byte(value); | |
107 | + break; | |
108 | + | |
109 | + case 'n': // gint16 | |
110 | + *((gint16 *) txtptr) = g_variant_get_int16(value); | |
111 | + txtptr += sizeof(gint16); | |
112 | + break; | |
113 | + | |
114 | + case 'q': // guint16 | |
115 | + *((guint16 *) txtptr) = g_variant_get_uint16(value); | |
116 | + txtptr += sizeof(guint16); | |
117 | + break; | |
118 | + | |
119 | + case 'i': // gint32 | |
120 | + case 'h': // gint32 | |
121 | + *((gint32 *) txtptr) = g_variant_get_int32(value); | |
122 | + txtptr += sizeof(gint32); | |
123 | + break; | |
124 | + | |
125 | + case 'u': // guint32 | |
126 | + *((guint32 *) txtptr) = g_variant_get_uint32(value); | |
127 | + txtptr += sizeof(guint32); | |
128 | + break; | |
129 | + | |
130 | + case 'x': // gint64 | |
131 | + *((gint64 *) txtptr) = g_variant_get_int64(value); | |
132 | + txtptr += sizeof(gint64); | |
133 | + break; | |
134 | + | |
135 | + case 't': // guint64 | |
136 | + *((guint64 *) txtptr) = g_variant_get_uint64(value); | |
137 | + txtptr += sizeof(guint64); | |
138 | + break; | |
139 | + | |
140 | + default: | |
141 | + errno = EINVAL; | |
142 | + return NULL; | |
143 | + | |
144 | + } | |
145 | + | |
146 | + return txtptr; | |
147 | +} | |
148 | + | |
149 | +unsigned char * ipc3270_pack_value(const gchar *name, int id, GVariant *value, size_t * szPacket) { | |
150 | + | |
151 | + debug("%s(%s)",__FUNCTION__,name); | |
152 | + | |
153 | + // Set packet size; | |
154 | + *szPacket = | |
155 | + strlen(name) + 1 | |
156 | + + (sizeof(guint16) * 2) | |
157 | + + g_variant_get_size(value) +1; | |
158 | + | |
159 | + unsigned char * outputBuffer = g_malloc0(*szPacket); | |
160 | + unsigned char * txtptr = setup_header(outputBuffer,name,id,1); | |
161 | + | |
162 | + txtptr = pack_value(txtptr, value); | |
163 | + if(!txtptr) { | |
164 | + g_free(outputBuffer); | |
165 | + return NULL; | |
166 | + } | |
167 | + | |
168 | + debug("used=%u allocated=%u",(unsigned int) (txtptr-outputBuffer), (unsigned int) *szPacket); | |
169 | + | |
170 | + return outputBuffer; | |
171 | + | |
172 | +} | |
173 | + | |
174 | + | |
175 | +unsigned char * ipc3270_pack(const gchar * name, int id, GVariant *values, size_t * szPacket) { | |
176 | + | |
177 | + GVariantIter iter; | |
178 | + gsize count = g_variant_iter_init(&iter, values); | |
179 | + GVariant * child; | |
180 | + size_t ix = 0; | |
181 | + | |
182 | + debug("%s(%s)",__FUNCTION__,name); | |
183 | + | |
184 | + // Init packet size; | |
185 | + *szPacket = strlen(name) + 1 + (sizeof(guint16) * 2); | |
186 | + | |
187 | + debug("Packaging %u itens for \"%s\"", (unsigned int) count, name); | |
188 | + while ((child = g_variant_iter_next_value (&iter))) { | |
189 | + | |
190 | + // debug("type='%s' size=%u", g_variant_get_type_string(child), (unsigned int) g_variant_get_size(child)); | |
191 | + | |
192 | + *szPacket += (1+g_variant_get_size(child)); | |
193 | + | |
194 | + g_variant_unref(child); | |
195 | + ix++; | |
196 | + } | |
197 | + | |
198 | + // Allocate buffer | |
199 | + unsigned char * outputBuffer = g_malloc0(*szPacket); | |
200 | + unsigned char * txtptr = setup_header(outputBuffer,name,id,count); | |
201 | + | |
202 | + ix = 0; | |
203 | + g_variant_iter_init(&iter, values); | |
204 | + while ((child = g_variant_iter_next_value (&iter))) { | |
205 | + | |
206 | + debug("type='%s' size=%u index=%u", g_variant_get_type_string(child), (unsigned int) g_variant_get_size(child), (unsigned int) (txtptr - outputBuffer)); | |
207 | + | |
208 | + txtptr = pack_value(txtptr, child); | |
209 | + if(!txtptr) { | |
210 | + g_free(outputBuffer); | |
211 | + return NULL; | |
212 | + } | |
213 | + | |
214 | + g_variant_unref(child); | |
215 | + ix++; | |
216 | + } | |
217 | + | |
218 | + return outputBuffer; | |
219 | +} | |
220 | + | |
221 | +GVariant * ipc3270_unpack(const unsigned char *packet, int *id) { | |
222 | + | |
223 | + const unsigned char *txtptr; | |
224 | + size_t ix; | |
225 | + | |
226 | + // Skip packet name. | |
227 | + packet += strlen((const char *) packet)+1; | |
228 | + | |
229 | + // Get Packet ID or error code. | |
230 | + if(id) { | |
231 | + *id = (int) *((guint16 *) packet); | |
232 | + } | |
233 | + packet += sizeof(guint16); | |
234 | + | |
235 | + // Get argument count. | |
236 | + size_t arguments = (size_t) * ((guint16 *) packet); | |
237 | + packet += sizeof(guint16); | |
238 | + | |
239 | + debug("Unpacking package with %u itens", (unsigned int) arguments); | |
240 | + | |
241 | + // Scan for argument types. | |
242 | + g_autofree gchar * descrs = g_malloc0(arguments+3); | |
243 | + descrs[0] = '('; | |
244 | + descrs[arguments+1] = ')'; | |
245 | + | |
246 | + txtptr = packet; | |
247 | + for(ix = 0; ix < arguments; ix++) { | |
248 | + | |
249 | + debug("Format(%u): %c",(unsigned int) ix, *txtptr); | |
250 | + | |
251 | + descrs[ix+1] = *(txtptr++); | |
252 | + | |
253 | + switch(descrs[ix+1]) { | |
254 | + case 's': | |
255 | + txtptr += strlen((char *) txtptr)+1; | |
256 | + break; | |
257 | + | |
258 | + case 'b': // gboolean | |
259 | + case 'y': // guchar | |
260 | + txtptr++; | |
261 | + break; | |
262 | + | |
263 | + case 'n': // gint16 | |
264 | + txtptr += sizeof(gint16); | |
265 | + break; | |
266 | + | |
267 | + case 'q': // guint16 | |
268 | + txtptr += sizeof(guint16); | |
269 | + break; | |
270 | + | |
271 | + case 'i': // gint32 | |
272 | + case 'h': // gint32 | |
273 | + txtptr += sizeof(gint32); | |
274 | + break; | |
275 | + | |
276 | + case 'u': // guint32 | |
277 | + txtptr += sizeof(guint32); | |
278 | + break; | |
279 | + | |
280 | + case 'x': // gint64 | |
281 | + txtptr += sizeof(gint64); | |
282 | + break; | |
283 | + | |
284 | + case 't': // guint64 | |
285 | + txtptr += sizeof(guint64); | |
286 | + break; | |
287 | + | |
288 | + default: | |
289 | + errno = EINVAL; | |
290 | + return NULL; | |
291 | + } | |
292 | + } | |
293 | + | |
294 | + debug("Format: \"%s\"\n",descrs); | |
295 | + | |
296 | + GVariantBuilder builder; | |
297 | + g_variant_builder_init(&builder,G_VARIANT_TYPE(descrs)); | |
298 | + | |
299 | + txtptr = packet; | |
300 | + for(ix = 0; ix < arguments; ix++) { | |
301 | + | |
302 | + debug("Format(%u): %c",(unsigned int) ix, *txtptr); | |
303 | + txtptr++; | |
304 | + | |
305 | + switch(descrs[ix+1]) { | |
306 | + case 's': | |
307 | + g_variant_builder_add(&builder, "s", txtptr); | |
308 | + txtptr += strlen((char *) txtptr)+1; | |
309 | + break; | |
310 | + | |
311 | + case 'b': // gboolean | |
312 | + g_variant_builder_add(&builder, "b", *((gboolean *) txtptr)); | |
313 | + txtptr++; | |
314 | + break; | |
315 | + | |
316 | + case 'y': // guchar | |
317 | + g_variant_builder_add(&builder, "y", *((guchar *) txtptr)); | |
318 | + txtptr++; | |
319 | + break; | |
320 | + | |
321 | + case 'n': // gint16 | |
322 | + g_variant_builder_add(&builder, "n", *((gint16 *) txtptr)); | |
323 | + txtptr += sizeof(gint16); | |
324 | + break; | |
325 | + | |
326 | + case 'q': // guint16 | |
327 | + g_variant_builder_add(&builder, "q", *((guint16 *) txtptr)); | |
328 | + txtptr += sizeof(guint16); | |
329 | + break; | |
330 | + | |
331 | + case 'i': // gint32 | |
332 | + g_variant_builder_add(&builder, "i", *((gint32 *) txtptr)); | |
333 | + txtptr += sizeof(gint32); | |
334 | + break; | |
335 | + | |
336 | + case 'h': // gint32 | |
337 | + g_variant_builder_add(&builder, "h", *((gint32 *) txtptr)); | |
338 | + txtptr += sizeof(gint32); | |
339 | + break; | |
340 | + | |
341 | + case 'u': // guint32 | |
342 | + g_variant_builder_add(&builder, "u", *((guint32 *) txtptr)); | |
343 | + txtptr += sizeof(guint32); | |
344 | + break; | |
345 | + | |
346 | + case 'x': // gint64 | |
347 | + g_variant_builder_add(&builder, "x", *((gint64 *) txtptr)); | |
348 | + txtptr += sizeof(gint64); | |
349 | + break; | |
350 | + | |
351 | + case 't': // guint64 | |
352 | + g_variant_builder_add(&builder, "t", *((guint64 *) txtptr)); | |
353 | + txtptr += sizeof(guint64); | |
354 | + break; | |
355 | + | |
356 | + default: | |
357 | + errno = EINVAL; | |
358 | + return NULL; | |
359 | + } | |
360 | + } | |
361 | + | |
362 | + return g_variant_builder_end(&builder); | |
363 | + | |
364 | +} | ... | ... |
... | ... | @@ -0,0 +1,279 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como pipesource.c e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | +#include "gobject.h" | |
31 | +#include <lib3270/ipc-glib.h> | |
32 | +#include <lib3270/trace.h> | |
33 | + | |
34 | +void ipc3270_wait_for_client(IPC3270_PIPE_SOURCE *source) { | |
35 | + | |
36 | + if(ConnectNamedPipe(source->hPipe,&source->overlap)) { | |
37 | + g_message("Error %u in ConnectNamedPipe",(unsigned int) GetLastError()); | |
38 | + // popup_lasterror("%s",_( "Error in ConnectNamedPipe" )); | |
39 | + return; | |
40 | + } | |
41 | + | |
42 | + switch(GetLastError()) { | |
43 | + case ERROR_IO_PENDING: // The overlapped connection in progress. | |
44 | + source->state = PIPE_STATE_WAITING; | |
45 | + break; | |
46 | + | |
47 | + case ERROR_PIPE_CONNECTED: // Client is already connected, so signal an event. | |
48 | + source->state = PIPE_STATE_WAITING; | |
49 | + SetEvent(source->overlap.hEvent); | |
50 | + break; | |
51 | + | |
52 | + default: | |
53 | + g_message("Error %u in ConnectNamedPipe",(unsigned int) GetLastError()); | |
54 | + // popup_lasterror("%s", _( "ConnectNamedPipe failed" )); | |
55 | + } | |
56 | + | |
57 | +} | |
58 | + | |
59 | +static gboolean IO_prepare(GSource *source, gint *timeout) { | |
60 | + /* | |
61 | + * Called before all the file descriptors are polled. | |
62 | + * If the source can determine that it is ready here | |
63 | + * (without waiting for the results of the poll() call) | |
64 | + * it should return TRUE. | |
65 | + * | |
66 | + * It can also return a timeout_ value which should be the maximum | |
67 | + * timeout (in milliseconds) which should be passed to the poll() call. | |
68 | + * The actual timeout used will be -1 if all sources returned -1, | |
69 | + * or it will be the minimum of all the timeout_ values | |
70 | + * returned which were >= 0. | |
71 | + * | |
72 | + */ | |
73 | + if(WaitForSingleObject(((IPC3270_PIPE_SOURCE *) source)->overlap.hEvent,0) == WAIT_OBJECT_0) | |
74 | + return TRUE; | |
75 | + | |
76 | + *timeout = 10; | |
77 | + | |
78 | + return FALSE; | |
79 | + | |
80 | +} | |
81 | + | |
82 | +static gboolean IO_check(GSource *source) { | |
83 | + /* | |
84 | + * Called after all the file descriptors are polled. | |
85 | + * The source should return TRUE if it is ready to be dispatched. | |
86 | + * Note that some time may have passed since the previous prepare | |
87 | + * function was called, so the source should be checked again here. | |
88 | + * | |
89 | + */ | |
90 | + if(WaitForSingleObject(((IPC3270_PIPE_SOURCE *) source)->overlap.hEvent,0) == WAIT_OBJECT_0) | |
91 | + return TRUE; | |
92 | + | |
93 | + return FALSE; | |
94 | +} | |
95 | + | |
96 | +static void process_input(IPC3270_PIPE_SOURCE *source, DWORD cbRead) { | |
97 | + | |
98 | + const gchar * request_name = (const gchar *) (source->buffer); | |
99 | + H3270 * hSession = ipc3270_get_session(source->object); | |
100 | + int request_type = 0; | |
101 | + | |
102 | + if(lib3270_get_toggle(hSession,LIB3270_TOGGLE_EVENT_TRACE)) | |
103 | + lib3270_trace_data(hSession, "IPC Data block received on pipe", (const char *) source->buffer, (size_t) cbRead); | |
104 | + | |
105 | + debug("Received packet \"%s\" with %u bytes", request_name, (unsigned int) cbRead); | |
106 | + | |
107 | + g_autoptr (GError) error = NULL; | |
108 | + g_autoptr (GVariant) parameters = ipc3270_unpack(source->buffer, &request_type); | |
109 | + g_autoptr (GVariant) response = NULL; | |
110 | + | |
111 | + if(!parameters) { | |
112 | + g_message("Rejecting invalid request \"%s\"", request_name); | |
113 | + } | |
114 | + | |
115 | + // Process query | |
116 | + switch(request_type) { | |
117 | + case 1: // getProperty | |
118 | + response = ipc3270_get_property(source->object, request_name, &error); | |
119 | + break; | |
120 | + | |
121 | + case 2: // setProperty | |
122 | + ipc3270_set_property(source->object, request_name, parameters, &error); | |
123 | + break; | |
124 | + | |
125 | + case 3: // method | |
126 | + response = ipc3270_method_call(source->object, request_name, parameters, &error); | |
127 | + break; | |
128 | + | |
129 | + default: | |
130 | + g_message("Rejecting request \"%s\": Invalid type %d",request_name, request_type); | |
131 | + g_set_error(&error,IPC3270(source->object)->error_domain,EINVAL,"Invalid or unexpected type %d",request_type); | |
132 | + | |
133 | + } | |
134 | + | |
135 | + debug("response=%p",response); | |
136 | + | |
137 | + // Pack response | |
138 | + size_t szPacket = 0; | |
139 | + g_autofree unsigned char * buffer = NULL; | |
140 | + | |
141 | + if(error) { | |
142 | + | |
143 | + buffer = ipc3270_pack_error(error, &szPacket); | |
144 | + | |
145 | + } else { | |
146 | + | |
147 | + buffer = ipc3270_pack_value(request_name, 0, response, &szPacket); | |
148 | + | |
149 | + } | |
150 | + | |
151 | + // Send response | |
152 | + DWORD wrote = (DWORD) szPacket; | |
153 | + | |
154 | + if(lib3270_get_toggle(hSession,LIB3270_TOGGLE_EVENT_TRACE)) | |
155 | + lib3270_trace_data(hSession, "IPC Data block sent to pipe", (const char *) buffer, szPacket); | |
156 | + | |
157 | + WriteFile(source->hPipe,buffer,wrote,&wrote,NULL); | |
158 | + | |
159 | +} | |
160 | + | |
161 | +static void read_input_pipe(IPC3270_PIPE_SOURCE *source) { | |
162 | + | |
163 | + DWORD cbRead = 0; | |
164 | + | |
165 | + if(ReadFile(source->hPipe,source->buffer,PIPE_BUFFER_LENGTH,&cbRead,&source->overlap) && cbRead > 0) | |
166 | + process_input(source,cbRead); | |
167 | + | |
168 | + // The read operation is still pending. | |
169 | + switch(GetLastError()) | |
170 | + { | |
171 | + case 0: | |
172 | + break; | |
173 | + | |
174 | + case ERROR_IO_PENDING: | |
175 | + source->state = PIPE_STATE_PENDING_READ; | |
176 | + break; | |
177 | + | |
178 | + case ERROR_PIPE_LISTENING: | |
179 | + source->state = PIPE_STATE_READ; | |
180 | + break; | |
181 | + | |
182 | + case ERROR_BROKEN_PIPE: | |
183 | + | |
184 | + if(!DisconnectNamedPipe(source->hPipe)) { | |
185 | + | |
186 | + g_message("Error %u on DisconnectNamedPipe", (unsigned int) GetLastError()); | |
187 | + | |
188 | + } else { | |
189 | + | |
190 | + ipc3270_wait_for_client(source); | |
191 | + | |
192 | + } | |
193 | + break; | |
194 | + | |
195 | + case ERROR_PIPE_NOT_CONNECTED: | |
196 | + g_message("Cliente was disconnected"); | |
197 | + break; | |
198 | + | |
199 | + default: | |
200 | + if(source->hPipe != INVALID_HANDLE_VALUE) { | |
201 | + g_message( "Error %u receiving message from pipe", (unsigned int) GetLastError()); | |
202 | + } | |
203 | + } | |
204 | + | |
205 | +} | |
206 | + | |
207 | + | |
208 | +static gboolean IO_dispatch(GSource *source, GSourceFunc G_GNUC_UNUSED(callback), gpointer G_GNUC_UNUSED(data)) { | |
209 | + /* | |
210 | + * Called to dispatch the event source, | |
211 | + * after it has returned TRUE in either its prepare or its check function. | |
212 | + * The dispatch function is passed in a callback function and data. | |
213 | + * The callback function may be NULL if the source was never connected | |
214 | + * to a callback using g_source_set_callback(). The dispatch function | |
215 | + * should call the callback function with user_data and whatever additional | |
216 | + * parameters are needed for this type of event source. | |
217 | + */ | |
218 | + BOOL fSuccess; | |
219 | + DWORD cbRead = 0; | |
220 | + | |
221 | + fSuccess = GetOverlappedResult(((IPC3270_PIPE_SOURCE *) source)->hPipe,&((IPC3270_PIPE_SOURCE *) source)->overlap,&cbRead,FALSE ); | |
222 | + | |
223 | + switch(((IPC3270_PIPE_SOURCE *) source)->state) { | |
224 | + case PIPE_STATE_WAITING: | |
225 | + | |
226 | + if(fSuccess) { | |
227 | + | |
228 | + g_message("Client is connected"); | |
229 | + ((IPC3270_PIPE_SOURCE *) source)->state = PIPE_STATE_READ; | |
230 | + | |
231 | + } else { | |
232 | + | |
233 | + g_message("Pipe connection failed with rc=%u",(unsigned int) GetLastError()); | |
234 | + | |
235 | + } | |
236 | + break; | |
237 | + | |
238 | + case PIPE_STATE_READ: | |
239 | + // trace("Reading pipe (cbRead=%d)",(int) cbRead); | |
240 | + read_input_pipe( (IPC3270_PIPE_SOURCE *) source); | |
241 | + break; | |
242 | + | |
243 | + case PIPE_STATE_PENDING_READ: | |
244 | + if(fSuccess && cbRead > 0) | |
245 | + process_input((IPC3270_PIPE_SOURCE *) source,cbRead); | |
246 | + ((IPC3270_PIPE_SOURCE *) source)->state = PIPE_STATE_READ; | |
247 | + break; | |
248 | + | |
249 | + case PIPE_STATE_UNDEFINED: | |
250 | + break; | |
251 | + | |
252 | + } | |
253 | + | |
254 | + return TRUE; | |
255 | +} | |
256 | + | |
257 | +static gboolean IO_closure(gpointer G_GNUC_UNUSED(data)) { | |
258 | + return 0; | |
259 | +} | |
260 | + | |
261 | +static void IO_finalize(GSource *source) { | |
262 | + | |
263 | + debug("%s(%p)",__FUNCTION__,source); | |
264 | + | |
265 | + if( ((IPC3270_PIPE_SOURCE *) source)->hPipe != INVALID_HANDLE_VALUE) { | |
266 | + CloseHandle(((IPC3270_PIPE_SOURCE *) source)->hPipe); | |
267 | + ((IPC3270_PIPE_SOURCE *) source)->hPipe = INVALID_HANDLE_VALUE; | |
268 | + } | |
269 | + | |
270 | +} | |
271 | + | |
272 | +GSourceFuncs ipc3270_source_funcs = { | |
273 | + IO_prepare, | |
274 | + IO_check, | |
275 | + IO_dispatch, | |
276 | + IO_finalize, | |
277 | + IO_closure, | |
278 | + NULL | |
279 | +}; | ... | ... |
... | ... | @@ -0,0 +1,91 @@ |
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 - e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | +#include "gobject.h" | |
31 | +#include <lib3270.h> | |
32 | +#include <lib3270/actions.h> | |
33 | +#include <lib3270/properties.h> | |
34 | +#include <lib3270/ipc-glib.h> | |
35 | + | |
36 | +void ipc3270_export_object(GObject *object, const char *name, GError G_GNUC_UNUSED(**error)) { | |
37 | + | |
38 | + char id; | |
39 | + | |
40 | + debug("%s object=%p name=%s type=%p",__FUNCTION__,object,name,ipc3270_get_type()); | |
41 | + | |
42 | + ipc3270 * ipc = IPC3270(object); | |
43 | + | |
44 | + for(id='A';id < 'Z';id++) { | |
45 | + | |
46 | + gchar * pipename = g_strdup_printf(PW3270_IPC_SESSION_BUS_NAME,name,id); | |
47 | + gchar * ptr; | |
48 | + HANDLE hPipe; | |
49 | + | |
50 | + for(ptr=pipename;*ptr;ptr++) | |
51 | + *ptr = g_ascii_tolower(*ptr); | |
52 | + | |
53 | + hPipe = CreateNamedPipe( TEXT(pipename), // pipe name | |
54 | + PIPE_ACCESS_DUPLEX | // read/write access | |
55 | + FILE_FLAG_OVERLAPPED, // overlapped mode | |
56 | + PIPE_TYPE_MESSAGE | // pipe type | |
57 | + PIPE_READMODE_MESSAGE | // pipe mode | |
58 | + PIPE_WAIT, // blocking mode | |
59 | + 1, // number of instances | |
60 | + PIPE_BUFFER_LENGTH, // output buffer size | |
61 | + PIPE_BUFFER_LENGTH, // input buffer size | |
62 | + NMPWAIT_USE_DEFAULT_WAIT, // client time-out | |
63 | + NULL); // default security attributes | |
64 | + | |
65 | + debug("%s = %p",pipename,hPipe); | |
66 | + g_free(pipename); | |
67 | + | |
68 | + if(hPipe != INVALID_HANDLE_VALUE) { | |
69 | + | |
70 | + ipc->source = (IPC3270_PIPE_SOURCE *) g_source_new(&ipc3270_source_funcs,sizeof(IPC3270_PIPE_SOURCE)); | |
71 | + | |
72 | + g_message("Got session \"%c\"",id); | |
73 | + | |
74 | + lib3270_set_session_id(ipc->hSession, id); | |
75 | + | |
76 | + ipc->source->hPipe = hPipe; | |
77 | + ipc->source->object = object; | |
78 | + ipc->source->state = PIPE_STATE_WAITING; | |
79 | + ipc->source->overlap.hEvent = CreateEvent( NULL,TRUE,TRUE,NULL); | |
80 | + | |
81 | + g_source_attach((GSource *) ipc->source,NULL); | |
82 | + | |
83 | + // IO_accept(source); | |
84 | + ipc3270_wait_for_client(ipc->source); | |
85 | + | |
86 | + break; | |
87 | + } | |
88 | + | |
89 | + } | |
90 | + | |
91 | +} | ... | ... |
... | ... | @@ -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 - e possui - linhas de código. | |
22 | + * | |
23 | + * Referências: | |
24 | + * | |
25 | + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | + * | |
28 | + * Contatos: | |
29 | + * | |
30 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | + * | |
33 | + */ | |
34 | + | |
35 | +#include "gobject.h" | |
36 | +#include <lib3270.h> | |
37 | +#include <lib3270/ipc-glib.h> | |
38 | + | |
39 | +void ipc3270_release_object(ipc3270 *object) { | |
40 | + | |
41 | + if(object->source) | |
42 | + { | |
43 | + g_source_destroy((GSource *) object->source); | |
44 | + object->source = NULL; | |
45 | + } | |
46 | + | |
47 | +} | ... | ... |
... | ... | @@ -0,0 +1,97 @@ |
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 | + /** | |
33 | + * @brief IPC Plugin startup/stop. | |
34 | + * | |
35 | + */ | |
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" | |
45 | + #include <v3270.h> | |
46 | + #include <lib3270/ipc-glib.h> | |
47 | + | |
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 | + } | |
53 | + | |
54 | + int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal) { | |
55 | + | |
56 | + // Creates IPC, associate it with the terminal window | |
57 | + GObject * ipc = ipc3270_new(); | |
58 | + g_object_set_data_full(G_OBJECT(terminal), "ipc-object-info", ipc, g_object_unref); | |
59 | + | |
60 | + debug("Name: \"%s\"",gtk_widget_get_name(window)); | |
61 | + | |
62 | + // Set session handle, this starts the IPC communication. | |
63 | + GError * error = NULL; | |
64 | + | |
65 | + ipc3270_set_session(ipc,v3270_get_session(terminal)); | |
66 | + ipc3270_export_object(ipc,gtk_widget_get_name(window),&error); | |
67 | + | |
68 | + if(error) { | |
69 | + | |
70 | + GtkWidget *dialog = gtk_message_dialog_new( | |
71 | + GTK_WINDOW(window), | |
72 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
73 | + GTK_MESSAGE_ERROR, | |
74 | + GTK_BUTTONS_OK, | |
75 | + _( "Can't start IPC Module" )); | |
76 | + | |
77 | + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); | |
78 | + g_error_free(error); | |
79 | + | |
80 | + gtk_dialog_run(GTK_DIALOG(dialog)); | |
81 | + gtk_widget_destroy(dialog); | |
82 | + return 0; | |
83 | + | |
84 | + } | |
85 | + | |
86 | + char id = lib3270_get_session_id(v3270_get_session(terminal)); | |
87 | + if(id) { | |
88 | + gchar * widget_name = g_strdup_printf("%s:%c",gtk_widget_get_name(window),id); | |
89 | + v3270_set_session_name(terminal, widget_name); | |
90 | + g_free(widget_name); | |
91 | + } | |
92 | + | |
93 | + return 0; | |
94 | + } | |
95 | + | |
96 | + | |
97 | + | ... | ... |
... | ... | @@ -0,0 +1,52 @@ |
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 Common definitions for pw3270 IPC plugin. | |
33 | + * | |
34 | + */ | |
35 | + | |
36 | +#ifndef PRIVATE_H_INCLUDED | |
37 | + | |
38 | + #define PRIVATE_H_INCLUDED | |
39 | + | |
40 | + #include <config.h> | |
41 | + #include <lib3270/ipc-glib.h> | |
42 | + | |
43 | + int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal); | |
44 | + int pw3270_plugin_stop(GtkWidget *window, GtkWidget *terminal); | |
45 | + | |
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 | |
51 | + | |
52 | +#endif // PRIVATE_H_INCLUDED | ... | ... |
... | ... | @@ -0,0 +1,29 @@ |
1 | +#include <windows.h> | |
2 | + | |
3 | +VS_VERSION_INFO VERSIONINFO | |
4 | +FILEVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0 | |
5 | +PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0 | |
6 | + | |
7 | +BEGIN | |
8 | + | |
9 | + BLOCK "StringFileInfo" | |
10 | + BEGIN | |
11 | + BLOCK "080904E4" | |
12 | + BEGIN | |
13 | + VALUE "FileDescription", "@PACKAGE_NAME@ IPC Plugin\0" | |
14 | + VALUE "CompanyName", "Banco do Brasil S/A.\0" | |
15 | + VALUE "FileVersion", "@WIN32_VERSION@\0" | |
16 | + VALUE "LegalCopyright", "(C) 2017 Banco do Brasil S/A. All Rights Reserved\0" | |
17 | + VALUE "OriginalFilename", "ipc3270@DLLEXT@\0" | |
18 | + VALUE "ProductName", "@PACKAGE_NAME@\0" | |
19 | + VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.0\0" | |
20 | + END | |
21 | + END | |
22 | + | |
23 | + BLOCK "VarFileInfo" | |
24 | + BEGIN | |
25 | + VALUE "Translation", 0x809, 0x04E4 | |
26 | + END | |
27 | + | |
28 | +END | |
29 | + | ... | ... |
... | ... | @@ -0,0 +1,61 @@ |
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 getproperties.c e possui - linhas de código. | |
22 | + * | |
23 | + * Referências: | |
24 | + * | |
25 | + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | + * | |
28 | + * Contatos: | |
29 | + * | |
30 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | + * | |
33 | + */ | |
34 | + | |
35 | +#include <config.h> | |
36 | +#include "private.h" | |
37 | +#include <lib3270/ipc-glib.h> | |
38 | +#include <lib3270.h> | |
39 | +#include <lib3270/properties.h> | |
40 | + | |
41 | +GVariant * service_get_property(const gchar *property_name, GError **error) { | |
42 | + | |
43 | + debug("%s(%s)",__FUNCTION__,property_name); | |
44 | + | |
45 | + if(!g_ascii_strcasecmp(property_name,"version")) { | |
46 | + return g_variant_new_string(PACKAGE_VERSION); | |
47 | + } else if(!g_ascii_strcasecmp(property_name,"release")) { | |
48 | + return g_variant_new_string(G_STRINGIFY(PACKAGE_RELEASE)); | |
49 | + } | |
50 | + | |
51 | + | |
52 | + g_set_error (error, | |
53 | + G_IO_ERROR, | |
54 | + G_IO_ERROR_NOT_FOUND, | |
55 | + "Can't find any property named %s", property_name | |
56 | + ); | |
57 | + | |
58 | + return NULL; | |
59 | + | |
60 | +} | |
61 | + | ... | ... |
... | ... | @@ -0,0 +1,186 @@ |
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 start.c e possui - linhas de código. | |
22 | + * | |
23 | + * Referências: | |
24 | + * | |
25 | + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | + * | |
28 | + * Contatos: | |
29 | + * | |
30 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | + * | |
32 | + */ | |
33 | + | |
34 | +#include <config.h> | |
35 | +#include <lib3270/ipc-glib.h> | |
36 | +#include "../private.h" | |
37 | + | |
38 | +static GDBusNodeInfo *introspection_data = NULL; | |
39 | +static guint owner_id = 0; | |
40 | +static gchar * introspection_xml = NULL; | |
41 | + | |
42 | +static void | |
43 | + method_call ( | |
44 | + G_GNUC_UNUSED GDBusConnection *connection, | |
45 | + G_GNUC_UNUSED const gchar *sender, | |
46 | + G_GNUC_UNUSED const gchar *object_path, | |
47 | + G_GNUC_UNUSED const gchar *interface_name, | |
48 | + const gchar *method_name, | |
49 | + GVariant *parameters, | |
50 | + GDBusMethodInvocation *invocation, | |
51 | + gpointer user_data) { | |
52 | + | |
53 | + g_autoptr (GError) error = NULL; | |
54 | + | |
55 | + debug("%s(%s)",__FUNCTION__,object_path); | |
56 | + | |
57 | + GVariant * rc = service_method_call(method_name, parameters, &error); | |
58 | + | |
59 | + if(error) { | |
60 | + | |
61 | + if(rc) { | |
62 | + g_variant_unref(rc); | |
63 | + } | |
64 | + | |
65 | + g_dbus_method_invocation_return_gerror(invocation, error); | |
66 | + | |
67 | + } else if(rc) { | |
68 | + | |
69 | + g_dbus_method_invocation_return_value(invocation, rc); | |
70 | + | |
71 | + } else { | |
72 | + | |
73 | + g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Invalid or unexpected method call"); | |
74 | + | |
75 | + } | |
76 | + | |
77 | + | |
78 | +} | |
79 | + | |
80 | +static GVariant * | |
81 | + get_property ( | |
82 | + G_GNUC_UNUSED GDBusConnection *connection, | |
83 | + G_GNUC_UNUSED const gchar *sender, | |
84 | + G_GNUC_UNUSED const gchar *object_path, | |
85 | + G_GNUC_UNUSED const gchar *interface_name, | |
86 | + const gchar *property_name, | |
87 | + GError **error, | |
88 | + gpointer user_data) | |
89 | +{ | |
90 | + | |
91 | + debug("%s(%s)",__FUNCTION__,object_path); | |
92 | + return service_get_property(property_name, error); | |
93 | + | |
94 | +} | |
95 | + | |
96 | +static gboolean | |
97 | + set_property ( | |
98 | + G_GNUC_UNUSED GDBusConnection *connection, | |
99 | + G_GNUC_UNUSED const gchar *sender, | |
100 | + G_GNUC_UNUSED const gchar *object_path, | |
101 | + G_GNUC_UNUSED const gchar *interface_name, | |
102 | + const gchar *property_name, | |
103 | + GVariant *value, | |
104 | + GError **error, | |
105 | + gpointer user_data) | |
106 | +{ | |
107 | + | |
108 | + debug("%s(%s)",__FUNCTION__,object_path); | |
109 | + return service_set_property(property_name, value, error); | |
110 | + | |
111 | +} | |
112 | + | |
113 | + | |
114 | +static void on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) { | |
115 | + | |
116 | + static const GDBusInterfaceVTable interface_vtable = { | |
117 | + method_call, | |
118 | + get_property, | |
119 | + set_property | |
120 | + }; | |
121 | + | |
122 | + guint registration_id; | |
123 | + | |
124 | + g_message("Registering object %s",PW3270_IPC_SERVICE_OBJECT_PATH); | |
125 | + | |
126 | + registration_id = g_dbus_connection_register_object (connection, | |
127 | + PW3270_IPC_SERVICE_OBJECT_PATH, | |
128 | + introspection_data->interfaces[0], | |
129 | + &interface_vtable, | |
130 | + NULL, /* user_data */ | |
131 | + NULL, /* user_data_free_func */ | |
132 | + NULL); /* GError** */ | |
133 | + g_assert (registration_id > 0); | |
134 | + | |
135 | +} | |
136 | + | |
137 | +static void on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) { | |
138 | + | |
139 | + g_message("Acquired %s",name); | |
140 | + | |
141 | +} | |
142 | + | |
143 | +static void on_name_lost (GDBusConnection *connection, const gchar *name, gpointer user_data) { | |
144 | + g_message("Lost %s",name); | |
145 | + g_main_loop_quit(NULL); | |
146 | +} | |
147 | + | |
148 | +void service_start(void) { | |
149 | + | |
150 | + GString * introspection = g_string_new("<node>\n"); | |
151 | + | |
152 | + g_string_append(introspection, | |
153 | + " <interface name='" PW3270_IPC_SERVICE_INTERFACE_NAME "'>" | |
154 | + " <method name='createSession'>" | |
155 | + " <arg type='s' name='id' direction='out' />" | |
156 | + " </method>" | |
157 | + " <method name='destroySession'>" | |
158 | + " <arg type='s' name='id' direction='in' />" | |
159 | + " <arg type='i' name='rc' direction='out' />" | |
160 | + " </method>" | |
161 | + " <property type='s' name='version' access='read'/>" | |
162 | + " <property type='s' name='release' access='read'/>" | |
163 | + ); | |
164 | + | |
165 | + ipc3270_add_terminal_introspection(introspection); | |
166 | + | |
167 | + g_string_append(introspection,"</interface></node>\n"); | |
168 | + | |
169 | + introspection_xml = g_string_free(introspection,FALSE); | |
170 | + | |
171 | + debug("\n\n%s\n\n",introspection_xml); | |
172 | + | |
173 | + introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL); | |
174 | + | |
175 | + owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, | |
176 | + PW3270_IPC_SERVICE_BUS_NAME, | |
177 | + G_BUS_NAME_OWNER_FLAGS_NONE, | |
178 | + on_bus_acquired, | |
179 | + on_name_acquired, | |
180 | + on_name_lost, | |
181 | + NULL, | |
182 | + NULL); | |
183 | + | |
184 | + | |
185 | +} | |
186 | + | ... | ... |
... | ... | @@ -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 methods.c e possui - linhas de código. | |
22 | + * | |
23 | + * Referências: | |
24 | + * | |
25 | + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | + * | |
28 | + * Contatos: | |
29 | + * | |
30 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | + * | |
33 | + */ | |
34 | + | |
35 | +#include <config.h> | |
36 | +#include "private.h" | |
37 | +#include <string.h> | |
38 | +#include <lib3270/ipc-glib.h> | |
39 | +#include <lib3270.h> | |
40 | +#include <lib3270/actions.h> | |
41 | + | |
42 | +GVariant * service_method_call(const gchar *method_name, GVariant *parameters, GError **error) { | |
43 | + | |
44 | + debug("%s(%s)",__FUNCTION__,method_name); | |
45 | + | |
46 | + g_set_error (error, | |
47 | + G_IO_ERROR, | |
48 | + G_IO_ERROR_NOT_FOUND, | |
49 | + "Can't find any method named %s", method_name | |
50 | + ); | |
51 | + | |
52 | + return NULL; | |
53 | +} | ... | ... |
... | ... | @@ -0,0 +1,59 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como private.h e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * | |
27 | + */ | |
28 | + | |
29 | +#ifndef PRIVATE_H_INCLUDED | |
30 | + | |
31 | + #define PRIVATE_H_INCLUDED | |
32 | + #include <config.h> | |
33 | + | |
34 | + #define ERROR_DOMAIN g_quark_from_static_string(PACKAGE_NAME) | |
35 | + | |
36 | + #include <glib.h> | |
37 | + #include <gio/gio.h> | |
38 | + #include <lib3270.h> | |
39 | + | |
40 | + G_BEGIN_DECLS | |
41 | + | |
42 | + #define GLIB_TYPE_SESSION (session_get_type ()) | |
43 | + #define SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLIB_TYPE_SESSION, session)) | |
44 | + #define SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLIB_TYPE_SESSION, sessionClass)) | |
45 | + #define IS_SESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLIB_TYPE_SESSION)) | |
46 | + #define IS_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLIB_TYPE_SESSION)) | |
47 | + #define SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLIB_TYPE_SESSION, sessionClass)) | |
48 | + | |
49 | + typedef struct _session session; | |
50 | + typedef struct _sessionClass sessionClass; | |
51 | + | |
52 | + G_GNUC_INTERNAL void service_start(void); | |
53 | + G_GNUC_INTERNAL GVariant * service_method_call(const gchar *method_name, GVariant *parameters, GError **error); | |
54 | + G_GNUC_INTERNAL GVariant * service_get_property(const gchar *property_name, GError **error); | |
55 | + G_GNUC_INTERNAL gboolean service_set_property(const gchar *property_name, GVariant *value, GError **error); | |
56 | + | |
57 | + G_END_DECLS | |
58 | + | |
59 | +#endif // PRIVATE_H_INCLUDED | ... | ... |
... | ... | @@ -0,0 +1,186 @@ |
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.c e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * | |
27 | + */ | |
28 | + | |
29 | +#include "private.h" | |
30 | +#include <errno.h> | |
31 | +#include <string.h> | |
32 | +#include <stdlib.h> | |
33 | +#include <lib3270/ipc-glib.h> | |
34 | + | |
35 | +#ifndef _WIN32 | |
36 | + #include <signal.h> | |
37 | +#endif // !_WIN32 | |
38 | + | |
39 | +GMainLoop * main_loop = NULL; | |
40 | + | |
41 | +#ifdef DEBUG | |
42 | + static gchar * pidfile = PACKAGE_NAME ".pid"; | |
43 | +#else | |
44 | + static gchar * pidfile = "/var/run/" PACKAGE_NAME ".pid"; | |
45 | +#endif // DEBUG | |
46 | + | |
47 | +#ifndef _WIN32 | |
48 | +static void on_sigterm(int signal) { | |
49 | + g_message("Stopping by termination request\n"); | |
50 | + g_main_loop_quit(main_loop); | |
51 | +} | |
52 | +#endif // !_WIN32 | |
53 | + | |
54 | +#if defined( HAVE_SYSLOG ) | |
55 | +static void g_syslog(const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,gpointer user_data) | |
56 | +{ | |
57 | + static const struct _logtype | |
58 | + { | |
59 | + GLogLevelFlags log_level; | |
60 | + int priority; | |
61 | + const gchar * msg; | |
62 | + } logtype[] = | |
63 | + { | |
64 | + { G_LOG_FLAG_RECURSION, LOG_INFO, "recursion" }, | |
65 | + { G_LOG_FLAG_FATAL, LOG_ERR, "fatal error" }, | |
66 | + | |
67 | + /* GLib log levels */ | |
68 | + { G_LOG_LEVEL_ERROR, LOG_ERR, "error" }, | |
69 | + { G_LOG_LEVEL_CRITICAL, LOG_ERR, "critical error" }, | |
70 | + { G_LOG_LEVEL_WARNING, LOG_ERR, "warning" }, | |
71 | + { G_LOG_LEVEL_MESSAGE, LOG_ERR, "message" }, | |
72 | + { G_LOG_LEVEL_INFO, LOG_INFO, "info" }, | |
73 | + { G_LOG_LEVEL_DEBUG, LOG_DEBUG, "debug" }, | |
74 | + }; | |
75 | + | |
76 | + int f; | |
77 | + | |
78 | + for(f=0;f<G_N_ELEMENTS(logtype);f++) | |
79 | + { | |
80 | + if(logtype[f].log_level == log_level) | |
81 | + { | |
82 | + gchar *ptr; | |
83 | + gchar *text = g_strdup_printf("%s: %s %s",logtype[f].msg,log_domain ? log_domain : "",message); | |
84 | + for(ptr = text;*ptr;ptr++) | |
85 | + { | |
86 | + if(*ptr < ' ') | |
87 | + *ptr = ' '; | |
88 | + } | |
89 | + | |
90 | +#ifdef DEBUG | |
91 | + printf("%s\n",text); | |
92 | + fflush(stdout); | |
93 | +#endif // DEBUG | |
94 | + | |
95 | + syslog(logtype[f].priority,"%s",text); | |
96 | + g_free(text); | |
97 | + return; | |
98 | + } | |
99 | + } | |
100 | + | |
101 | + #ifdef DEBUG | |
102 | + printf("%s\n",message); | |
103 | + fflush(stdout); | |
104 | + #endif // DEBUG | |
105 | + | |
106 | + syslog(LOG_INFO,"%s %s",log_domain ? log_domain : "", message); | |
107 | +} | |
108 | +#endif // HAVE_SYSLOG | |
109 | + | |
110 | +static gboolean do_idle_check(G_GNUC_UNUSED gpointer dunno) { | |
111 | + | |
112 | + return TRUE; | |
113 | +} | |
114 | + | |
115 | +static void cleanup() { | |
116 | + | |
117 | + if(pidfile) { | |
118 | + remove(pidfile); | |
119 | + } | |
120 | + | |
121 | +} | |
122 | + | |
123 | +int main(int argc, char *argv[]) { | |
124 | + | |
125 | + static gboolean asDaemon = FALSE; | |
126 | + | |
127 | +#if defined( HAVE_SYSLOG ) | |
128 | + openlog(g_get_prgname(), LOG_NDELAY, LOG_USER); | |
129 | + g_log_set_default_handler(g_syslog,NULL); | |
130 | +#endif // HAVE_SYSLOG | |
131 | + | |
132 | + // Verifica argumentos | |
133 | + static const GOptionEntry app_options[] = { | |
134 | + { "pidfile", 'p', 0, G_OPTION_ARG_STRING, &pidfile, "Path to pidfile" , NULL }, | |
135 | +#ifndef _WIN32 | |
136 | + { "daemon", 'd', 0, G_OPTION_ARG_NONE, &asDaemon, "Run as daemon", NULL }, | |
137 | +#endif // !_WIN32 | |
138 | + { NULL } | |
139 | + }; | |
140 | + | |
141 | + GOptionContext * context = g_option_context_new (PACKAGE_NAME " IPC service daemon"); | |
142 | + GError * error = NULL; | |
143 | + GOptionGroup * group = g_option_group_new( PACKAGE_NAME, NULL, NULL, NULL, NULL); | |
144 | + | |
145 | + g_option_context_set_main_group(context, group); | |
146 | + g_option_context_add_main_entries(context, app_options, NULL); | |
147 | + if(!g_option_context_parse( context, &argc, &argv, &error )) { | |
148 | + fprintf(stderr,"%s\n",error->message); | |
149 | + return -1; | |
150 | + } | |
151 | + | |
152 | + atexit(cleanup); | |
153 | + | |
154 | + if(pidfile) { | |
155 | + FILE * hpid = fopen(pidfile,"w"); | |
156 | + if(hpid) { | |
157 | + fprintf(hpid,"%u",(unsigned int) getpid()); | |
158 | + fclose(hpid); | |
159 | + } | |
160 | + } | |
161 | + | |
162 | + service_start(); | |
163 | + | |
164 | + g_print("%s starts\n",argv[0]); | |
165 | + | |
166 | + main_loop = g_main_loop_new(NULL, FALSE); | |
167 | + | |
168 | +#ifndef _WIN32 | |
169 | + | |
170 | + if(asDaemon && daemon(0,0)) { | |
171 | + g_print("%s can't start: %s\n",argv[0],strerror(errno)); | |
172 | + return -1; | |
173 | + } | |
174 | + | |
175 | + signal(SIGTERM,on_sigterm); | |
176 | + signal(SIGINT,on_sigterm); | |
177 | + | |
178 | +#endif // !_WIN32 | |
179 | + | |
180 | + g_main_loop_run(main_loop); | |
181 | + | |
182 | + g_print("%s ends\n",argv[0]); | |
183 | + | |
184 | + return 0; | |
185 | +} | |
186 | + | ... | ... |
... | ... | @@ -0,0 +1,85 @@ |
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 - e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | +#include "private.h" | |
31 | +#include <lib3270/ipc-glib.h> | |
32 | + | |
33 | +struct _session { | |
34 | + GObject parent; | |
35 | + time_t activity; ///< @brief Timestamp da última atividade dessa sessão. | |
36 | + time_t timeout; ///< @brief Após quantos segundos eu encerro a sessao? | |
37 | + time_t maxidle; ///< @brief Tempo máximo que a sessão pode ficar IDLE | |
38 | + time_t autoclose; ///< @brief Destroi a sessão quantos segundos após a desconexão? | |
39 | +}; | |
40 | + | |
41 | +struct _sessionClass { | |
42 | + GObjectClass parent; | |
43 | +}; | |
44 | + | |
45 | +static GList * session_list = NULL; | |
46 | + | |
47 | +G_DEFINE_TYPE(session, session, GLIB_TYPE_IPC3270) | |
48 | + | |
49 | +static void session_finalize(GObject *object) { | |
50 | + | |
51 | + session_list = g_list_remove(session_list, object); | |
52 | + | |
53 | + lib3270_session_free(ipc3270_get_session(object)); | |
54 | + G_OBJECT_CLASS(session_parent_class)->finalize(object); | |
55 | + | |
56 | + debug("%s(%p)",__FUNCTION__,(void *) object); | |
57 | + | |
58 | +} | |
59 | + | |
60 | +static void session_class_init(sessionClass *klass) { | |
61 | + | |
62 | + debug("%s",__FUNCTION__); | |
63 | + | |
64 | + GObjectClass *object_class; | |
65 | + object_class = G_OBJECT_CLASS (klass); | |
66 | + object_class->finalize = session_finalize; | |
67 | + | |
68 | +} | |
69 | + | |
70 | +static void session_init(session *object) { | |
71 | + | |
72 | + debug("%s(%p)",__FUNCTION__,(void *) object); | |
73 | + | |
74 | + H3270 * hSession = lib3270_session_new(""); | |
75 | + lib3270_set_user_data(hSession,object); | |
76 | + ipc3270_set_session(&object->parent,hSession); | |
77 | + | |
78 | + session_list = g_list_prepend(session_list, object); | |
79 | + | |
80 | +} | |
81 | + | |
82 | +GObject * session_new() { | |
83 | + return g_object_new(GLIB_TYPE_SESSION, NULL); | |
84 | +} | |
85 | + | ... | ... |
... | ... | @@ -0,0 +1,52 @@ |
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 - e possui - linhas de código. | |
22 | + * | |
23 | + * Referências: | |
24 | + * | |
25 | + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | + * | |
28 | + * Contatos: | |
29 | + * | |
30 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | + * | |
33 | + */ | |
34 | + | |
35 | +#include <config.h> | |
36 | +#include "private.h" | |
37 | +#include <lib3270/ipc-glib.h> | |
38 | +#include <lib3270.h> | |
39 | +#include <lib3270/properties.h> | |
40 | + | |
41 | +gboolean service_set_property(const gchar *property_name, GVariant *value, GError **error) { | |
42 | + | |
43 | + debug("%s(%s)",__FUNCTION__,property_name); | |
44 | + | |
45 | + g_set_error (error, | |
46 | + G_IO_ERROR, | |
47 | + G_IO_ERROR_NOT_FOUND, | |
48 | + "Can't find any property named %s", property_name | |
49 | + ); | |
50 | + | |
51 | + return FALSE; | |
52 | +} | ... | ... |
... | ... | @@ -0,0 +1,29 @@ |
1 | +#include <windows.h> | |
2 | + | |
3 | +VS_VERSION_INFO VERSIONINFO | |
4 | +FILEVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0 | |
5 | +PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0 | |
6 | + | |
7 | +BEGIN | |
8 | + | |
9 | + BLOCK "StringFileInfo" | |
10 | + BEGIN | |
11 | + BLOCK "080904E4" | |
12 | + BEGIN | |
13 | + VALUE "FileDescription", "@PACKAGE_NAME@ IPC Service\0" | |
14 | + VALUE "CompanyName", "Banco do Brasil S/A.\0" | |
15 | + VALUE "FileVersion", "@WIN32_VERSION@\0" | |
16 | + VALUE "LegalCopyright", "(C) 2017 Banco do Brasil S/A. All Rights Reserved\0" | |
17 | + VALUE "OriginalFilename", "ipc3270@DLLEXT@\0" | |
18 | + VALUE "ProductName", "@PACKAGE_NAME@\0" | |
19 | + VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.0\0" | |
20 | + END | |
21 | + END | |
22 | + | |
23 | + BLOCK "VarFileInfo" | |
24 | + BEGIN | |
25 | + VALUE "Translation", 0x809, 0x04E4 | |
26 | + END | |
27 | + | |
28 | +END | |
29 | + | ... | ... |
... | ... | @@ -0,0 +1,273 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob | |
5 | + * o nome G3270. | |
6 | + * | |
7 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
8 | + * | |
9 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
10 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
11 | + * Free Software Foundation. | |
12 | + * | |
13 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
14 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
15 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
16 | + * obter mais detalhes. | |
17 | + * | |
18 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
19 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
20 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | + * | |
22 | + * Este programa está nomeado como testprogram.c e possui - linhas de código. | |
23 | + * | |
24 | + * Contatos: | |
25 | + * | |
26 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
27 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
28 | + * | |
29 | + */ | |
30 | + | |
31 | + | |
32 | + /** | |
33 | + * @brief Test program for pw3270 IPC plugin. | |
34 | + * | |
35 | + */ | |
36 | + | |
37 | + #include <config.h> | |
38 | + #include <v3270.h> | |
39 | + #include <v3270/trace.h> | |
40 | + #include <lib3270/ipc-glib.h> | |
41 | + #include <string.h> | |
42 | + #include <stdlib.h> | |
43 | + | |
44 | + /*---[ Globals ]------------------------------------------------------------------------------------*/ | |
45 | + | |
46 | + const gchar * plugin_path = ".bin/Debug"; | |
47 | + const gchar * session_name = "pw3270"; | |
48 | + const gchar * plugin_name = "ipc3270." G_MODULE_SUFFIX; | |
49 | + | |
50 | + /*---[ Implement ]----------------------------------------------------------------------------------*/ | |
51 | + | |
52 | + static void close_module(GtkWidget *widget, GModule *module) | |
53 | + { | |
54 | + g_message("Closing module %p",module); | |
55 | + | |
56 | + static void (*stop)(GtkWidget *window, GtkWidget *terminal) = NULL; | |
57 | + if(!g_module_symbol(module,"pw3270_plugin_stop",(gpointer) &stop)) | |
58 | + { | |
59 | + g_message("Can't get stop method from plugin: %s",g_module_error()); | |
60 | + } | |
61 | + else | |
62 | + { | |
63 | + stop(gtk_widget_get_toplevel(widget),widget); | |
64 | + } | |
65 | + | |
66 | + g_module_close(module); | |
67 | + g_message("Module %p was closed",module); | |
68 | + } | |
69 | + | |
70 | + static void toggle_ds_trace(GtkToggleToolButton *button, GtkWidget *terminal) | |
71 | + { | |
72 | + v3270_set_toggle(terminal,LIB3270_TOGGLE_DS_TRACE,gtk_toggle_tool_button_get_active(button)); | |
73 | + } | |
74 | + | |
75 | + static void toggle_event_trace(GtkToggleToolButton *button, GtkWidget *terminal) | |
76 | + { | |
77 | + v3270_set_toggle(terminal,LIB3270_TOGGLE_EVENT_TRACE,gtk_toggle_tool_button_get_active(button)); | |
78 | + } | |
79 | + | |
80 | + static void toggle_ssl_trace(GtkToggleToolButton *button, GtkWidget *terminal) | |
81 | + { | |
82 | + v3270_set_toggle(terminal,LIB3270_TOGGLE_SSL_TRACE,gtk_toggle_tool_button_get_active(button)); | |
83 | + } | |
84 | + | |
85 | + static void toggle_screen_trace(GtkToggleToolButton *button, GtkWidget *terminal) | |
86 | + { | |
87 | + v3270_set_toggle(terminal,LIB3270_TOGGLE_SCREEN_TRACE,gtk_toggle_tool_button_get_active(button)); | |
88 | + } | |
89 | + | |
90 | + static void toggle_started_trace(GtkToggleToolButton *button, GModule *module) | |
91 | + { | |
92 | + if(!module) | |
93 | + return; | |
94 | + | |
95 | + GtkWidget * terminal = g_object_get_data(G_OBJECT(button),"terminal"); | |
96 | + | |
97 | + const gchar * method_name = (gtk_toggle_tool_button_get_active(button) ? "pw3270_plugin_start" : "pw3270_plugin_stop"); | |
98 | + | |
99 | + static void (*call)(GtkWidget *window, GtkWidget *terminal) = NULL; | |
100 | + if(!g_module_symbol(module,method_name,(gpointer) &call)) | |
101 | + { | |
102 | + g_message("Can't get method \"%s\": %s",method_name,g_module_error()); | |
103 | + return; | |
104 | + } | |
105 | + | |
106 | + g_message("Calling %s",method_name); | |
107 | + call(gtk_widget_get_toplevel(terminal), GTK_WIDGET(terminal)); | |
108 | + | |
109 | + } | |
110 | + | |
111 | + static GtkToolItem * create_tool_item(GtkWidget *terminal, const gchar *label, const gchar *tooltip, GCallback callback) | |
112 | + { | |
113 | + GtkToolItem * item = gtk_toggle_tool_button_new(); | |
114 | + gtk_tool_button_set_label(GTK_TOOL_BUTTON(item),label); | |
115 | + | |
116 | + g_signal_connect(GTK_WIDGET(item), "toggled", G_CALLBACK(callback), terminal); | |
117 | + | |
118 | + if(tooltip) | |
119 | + gtk_widget_set_tooltip_text(GTK_WIDGET(item),tooltip); | |
120 | + | |
121 | + return item; | |
122 | + } | |
123 | + | |
124 | + static void session_changed(GtkWidget *widget, GtkWidget *window) { | |
125 | + | |
126 | + g_autofree gchar * title = NULL; | |
127 | + | |
128 | + g_message("Session name was changed"); | |
129 | + | |
130 | + if(v3270_is_connected(widget)) { | |
131 | + const gchar *host = v3270_get_hostname(widget); | |
132 | + | |
133 | + if(host && *host) | |
134 | + title = g_strdup_printf("%s - %s",v3270_get_session_name(widget),host); | |
135 | + else | |
136 | + title = g_strdup_printf("%s",v3270_get_session_name(widget)); | |
137 | + | |
138 | + } else { | |
139 | + | |
140 | + title = g_strdup_printf("%s - Disconnected",v3270_get_session_name(widget)); | |
141 | + } | |
142 | + | |
143 | + gtk_window_set_title(GTK_WINDOW(window),title); | |
144 | + | |
145 | + | |
146 | + } | |
147 | + | |
148 | + static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { | |
149 | + | |
150 | + GtkWidget * window = gtk_application_window_new(app); | |
151 | + GtkWidget * terminal = v3270_new(); | |
152 | + GtkWidget * notebook = gtk_notebook_new(); | |
153 | + GModule * module = NULL; | |
154 | + | |
155 | + gtk_widget_set_name(window,session_name); | |
156 | + | |
157 | + // Setup tabs | |
158 | + gtk_notebook_append_page(GTK_NOTEBOOK(notebook),terminal,gtk_label_new(v3270_get_session_name(terminal))); | |
159 | + | |
160 | + // Load plugin | |
161 | + { | |
162 | + g_autofree gchar * plugin = g_build_filename(plugin_path,plugin_name,NULL); | |
163 | + | |
164 | + g_message("Loading %s",plugin); | |
165 | + | |
166 | + module = g_module_open(plugin,G_MODULE_BIND_LOCAL); | |
167 | + | |
168 | + if(module) | |
169 | + { | |
170 | + g_signal_connect (terminal, "destroy", G_CALLBACK(close_module), module); | |
171 | + } | |
172 | + else | |
173 | + { | |
174 | + g_message("Can't open \"%s\": %s",plugin,g_module_error()); | |
175 | + gtk_main_quit(); | |
176 | + } | |
177 | + | |
178 | + } | |
179 | + // Create trace window | |
180 | + { | |
181 | + GtkWidget * box = gtk_box_new(GTK_ORIENTATION_VERTICAL,0); | |
182 | + GtkWidget * trace = v3270_trace_new(terminal); | |
183 | + GtkWidget * toolbar = gtk_toolbar_new(); | |
184 | + GtkToolItem * start = gtk_toggle_tool_button_new(); | |
185 | + | |
186 | + gtk_widget_set_sensitive(GTK_WIDGET(start),module != NULL); | |
187 | + | |
188 | + g_object_set_data(G_OBJECT(start),"terminal",terminal); | |
189 | + | |
190 | + gtk_tool_button_set_label(GTK_TOOL_BUTTON(start),"Enable"); | |
191 | + g_signal_connect(GTK_WIDGET(start), "toggled", G_CALLBACK(toggle_started_trace), module); | |
192 | + gtk_widget_set_tooltip_text(GTK_WIDGET(start),"Start/Stop plugin module"); | |
193 | + | |
194 | + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), start, -1); | |
195 | + | |
196 | + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),gtk_separator_tool_item_new(),-1); | |
197 | + | |
198 | + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "DS Trace","Toggle DS Trace",G_CALLBACK(toggle_ds_trace)),-1); | |
199 | + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "Event Trace","Toggle Event Trace",G_CALLBACK(toggle_event_trace)),-1); | |
200 | + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "Screen Trace","Toggle Screen Trace",G_CALLBACK(toggle_screen_trace)),-1); | |
201 | + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "SSL Trace","Toggle SSL Trace",G_CALLBACK(toggle_ssl_trace)),-1); | |
202 | + | |
203 | + gtk_box_pack_start(GTK_BOX(box),toolbar,FALSE,FALSE,0); | |
204 | + gtk_box_pack_start(GTK_BOX(box),trace,TRUE,TRUE,0); | |
205 | + gtk_notebook_append_page(GTK_NOTEBOOK(notebook),box,gtk_label_new("Trace")); | |
206 | + } | |
207 | + | |
208 | + // Setup and show main window | |
209 | + gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); | |
210 | + gtk_window_set_default_size (GTK_WINDOW (window), 800, 500); | |
211 | + gtk_container_add(GTK_CONTAINER(window),notebook); | |
212 | + gtk_widget_show_all (window); | |
213 | + | |
214 | + // Setup title. | |
215 | + const gchar *url = lib3270_get_url(v3270_get_session(terminal)); | |
216 | + if(url) { | |
217 | + | |
218 | + v3270_set_url(terminal,url); | |
219 | + v3270_reconnect(terminal); | |
220 | + | |
221 | + gchar * title = g_strdup_printf("%s - %s", v3270_get_session_name(terminal), url); | |
222 | + gtk_window_set_title(GTK_WINDOW(window), title); | |
223 | + g_free(title); | |
224 | + | |
225 | + } else { | |
226 | + | |
227 | + gtk_window_set_title(GTK_WINDOW(window), v3270_get_session_name(terminal)); | |
228 | + | |
229 | + } | |
230 | + | |
231 | + g_signal_connect(terminal,"session_changed",G_CALLBACK(session_changed),window); | |
232 | + | |
233 | +} | |
234 | + | |
235 | +int main (int argc, char **argv) { | |
236 | + | |
237 | + /* | |
238 | + GVariantBuilder builder; | |
239 | + | |
240 | + g_variant_builder_init(&builder,G_VARIANT_TYPE("(isi)")); | |
241 | + | |
242 | + g_variant_builder_add(&builder, "i", 10); | |
243 | + g_variant_builder_add(&builder, "s", "teste"); | |
244 | + g_variant_builder_add(&builder, "i", 20); | |
245 | + | |
246 | + GVariant *value = g_variant_builder_end(&builder); | |
247 | + | |
248 | + size_t szPacket = 0; | |
249 | + g_autofree unsigned char * buffer = ipc3270_pack("teste", value, &szPacket); | |
250 | + g_variant_unref(value); | |
251 | + | |
252 | + debug("Package \"%s\" was created with %u bytes", buffer, (unsigned int) szPacket); | |
253 | + | |
254 | + value = ipc3270_unpack(buffer); | |
255 | + | |
256 | + g_variant_unref(value); | |
257 | + */ | |
258 | + | |
259 | + GtkApplication *app; | |
260 | + int status; | |
261 | + | |
262 | + app = gtk_application_new ("br.com.bb.pw3270",G_APPLICATION_FLAGS_NONE); | |
263 | + | |
264 | + g_signal_connect (app, "activate", G_CALLBACK(activate), NULL); | |
265 | + | |
266 | + status = g_application_run (G_APPLICATION (app), argc, argv); | |
267 | + g_object_unref (app); | |
268 | + | |
269 | + g_message("rc=%d",status); | |
270 | + return status; | |
271 | + | |
272 | +} | |
273 | + | ... | ... |
src/core/constants.c
... | ... | @@ -1,51 +0,0 @@ |
1 | -/* | |
2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | - * | |
6 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | - * | |
8 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | - * Free Software Foundation. | |
11 | - * | |
12 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | - * obter mais detalhes. | |
16 | - * | |
17 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | - * | |
21 | - * Este programa está nomeado como - e possui - linhas de código. | |
22 | - * | |
23 | - * Referências: | |
24 | - * | |
25 | - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | - * | |
28 | - * Contatos: | |
29 | - * | |
30 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | - * | |
33 | - */ | |
34 | - | |
35 | -#include <lib3270.h> | |
36 | -#include <lib3270/actions.h> | |
37 | -#include <lib3270/ipc-glib.h> | |
38 | - | |
39 | -const IPC_METHOD_INT_ARG * ipc3270_get_int_arg_methods() { | |
40 | - | |
41 | - static const IPC_METHOD_INT_ARG int_arg_methods[] = { | |
42 | - { "pfkey", lib3270_pfkey }, | |
43 | - { "pakey", lib3270_pakey }, | |
44 | - { NULL, NULL } | |
45 | - }; | |
46 | - | |
47 | - return int_arg_methods; | |
48 | - | |
49 | -} | |
50 | - | |
51 | - |
src/core/convert.c
... | ... | @@ -1,59 +0,0 @@ |
1 | -/* | |
2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | - * | |
6 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | - * | |
8 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | - * Free Software Foundation. | |
11 | - * | |
12 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | - * obter mais detalhes. | |
16 | - * | |
17 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | - * | |
21 | - * Este programa está nomeado como - e possui - linhas de código. | |
22 | - * | |
23 | - * Referências: | |
24 | - * | |
25 | - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | - * | |
28 | - * Contatos: | |
29 | - * | |
30 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | - * | |
33 | - */ | |
34 | - | |
35 | -#include <lib3270.h> | |
36 | -#include <lib3270/actions.h> | |
37 | -#include <lib3270/ipc-glib.h> | |
38 | - | |
39 | -gchar * ipc3270_convert_output_string(GObject *object, const gchar *string, GError **error) { | |
40 | - return g_convert_with_fallback(string,-1,ipc3270_get_display_charset(object),"UTF-8","?",NULL,NULL,error); | |
41 | -} | |
42 | - | |
43 | -gchar * ipc3270_convert_input_string(GObject *object, const gchar *string, GError **error) { | |
44 | - return g_convert_with_fallback(string,-1,"UTF-8",ipc3270_get_display_charset(object),"?",NULL,NULL,error); | |
45 | -} | |
46 | - | |
47 | -GVariant * ipc3270_GVariant_from_input_string(GObject *object, char *string, GError **error) { | |
48 | - | |
49 | - if(string) { | |
50 | - g_autofree gchar * utfstring = ipc3270_convert_input_string(object,string,error); | |
51 | - lib3270_free(string); | |
52 | - return g_variant_new("(s)", utfstring); | |
53 | - } | |
54 | - | |
55 | - ipc3270_set_error(object,errno,error); | |
56 | - return g_variant_new("(s)", ""); | |
57 | -} | |
58 | - | |
59 | - |
src/core/getproperties.c
... | ... | @@ -1,130 +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 - e possui - linhas de código. | |
22 | - * | |
23 | - * Referências: | |
24 | - * | |
25 | - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | - * | |
28 | - * Contatos: | |
29 | - * | |
30 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | - * | |
33 | - */ | |
34 | - | |
35 | -#include <config.h> | |
36 | -#include <lib3270/ipc-glib.h> | |
37 | -#include <lib3270.h> | |
38 | -#include <lib3270/properties.h> | |
39 | -#include <lib3270/trace.h> | |
40 | - | |
41 | -GVariant * ipc3270_get_property(GObject *object, const gchar *property_name, GError **error) { | |
42 | - | |
43 | - size_t ix; | |
44 | - H3270 * hSession = ipc3270_get_session(object); | |
45 | - | |
46 | - errno = 0; // Just in case. | |
47 | - | |
48 | - lib3270_trace_event(hSession,"GetProperty(%s) called on session %c\n",property_name,lib3270_get_session_id(hSession)); | |
49 | - | |
50 | - // Boolean properties | |
51 | - const LIB3270_INT_PROPERTY * boolprop = lib3270_get_boolean_properties_list(); | |
52 | - for(ix = 0; boolprop[ix].name; ix++) { | |
53 | - | |
54 | - if(boolprop[ix].get && !g_ascii_strcasecmp(boolprop[ix].name, property_name)) { | |
55 | - | |
56 | - // Found it! | |
57 | - int value = boolprop[ix].get(hSession); | |
58 | - | |
59 | - debug("%s=%d",property_name,value); | |
60 | - | |
61 | - if(value > 0 || errno == 0) { | |
62 | - return g_variant_new_boolean(value != 0); | |
63 | - } | |
64 | - | |
65 | - // Erro! | |
66 | - ipc3270_set_error(object,ENOENT,error); | |
67 | - return NULL; | |
68 | - | |
69 | - } | |
70 | - | |
71 | - } | |
72 | - | |
73 | - // int properties | |
74 | - const LIB3270_INT_PROPERTY * intprop = lib3270_get_int_properties_list(); | |
75 | - for(ix = 0; intprop[ix].name; ix++) { | |
76 | - | |
77 | - if(intprop[ix].get && !g_ascii_strcasecmp(intprop[ix].name, property_name)) { | |
78 | - | |
79 | - // Found it! | |
80 | - int value = intprop[ix].get(hSession); | |
81 | - | |
82 | - debug("%s=%d",property_name,value); | |
83 | - | |
84 | - if(value > 0 || errno == 0) { | |
85 | - return g_variant_new_int16((gint16) value); | |
86 | - } | |
87 | - | |
88 | - // Erro! | |
89 | - ipc3270_set_error(object,errno,error); | |
90 | - return NULL; | |
91 | - | |
92 | - } | |
93 | - | |
94 | - } | |
95 | - | |
96 | - // String properties | |
97 | - const LIB3270_STRING_PROPERTY * strprop = lib3270_get_string_properties_list(); | |
98 | - for(ix = 0; strprop[ix].name; ix++) { | |
99 | - | |
100 | - if(strprop[ix].get && !g_ascii_strcasecmp(strprop[ix].name, property_name)) { | |
101 | - | |
102 | - // Found it! | |
103 | - const char * value = strprop[ix].get(hSession); | |
104 | - | |
105 | - if(value) { | |
106 | - debug("%s=%s",property_name,value); | |
107 | - return g_variant_new_string(value); | |
108 | - } | |
109 | - | |
110 | - // Erro! | |
111 | - ipc3270_set_error(object,errno,error); | |
112 | - return NULL; | |
113 | - | |
114 | - } | |
115 | - | |
116 | - } | |
117 | - | |
118 | - // Check for toggle | |
119 | - LIB3270_TOGGLE toggle = lib3270_get_toggle_id(property_name); | |
120 | - if(toggle != (LIB3270_TOGGLE) -1) { | |
121 | - | |
122 | - // Is a Tn3270 toggle, get it! | |
123 | - return g_variant_new_boolean(lib3270_get_toggle( (hSession), toggle) != 0); | |
124 | - | |
125 | - } | |
126 | - | |
127 | - return NULL; | |
128 | - | |
129 | -} | |
130 | - |
src/core/linux/dbus-definition.xml
... | ... | @@ -1,9 +0,0 @@ |
1 | -<?xml version="1.0" encoding="UTF-8" ?> | |
2 | -<node name="/br/com/bb/pw3270"> | |
3 | - <interface name="br.com.bb.pw3270"> | |
4 | - <method name="getRevision"> | |
5 | - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
6 | - <arg type="s" name="revision" direction="out" /> | |
7 | - </method> | |
8 | - </interface> | |
9 | -</node> |
src/core/linux/gobject.c
... | ... | @@ -1,227 +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 - e possui - linhas de código. | |
22 | - * | |
23 | - * Referências: | |
24 | - * | |
25 | - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | - * | |
28 | - * Contatos: | |
29 | - * | |
30 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | - * | |
33 | - */ | |
34 | - | |
35 | -#include "gobject.h" | |
36 | -#include <lib3270.h> | |
37 | -#include <lib3270/actions.h> | |
38 | -#include <lib3270/properties.h> | |
39 | - | |
40 | -#include <dbus/dbus-glib.h> | |
41 | -#include <dbus/dbus-glib-bindings.h> | |
42 | - | |
43 | -/*--[ Widget definition ]----------------------------------------------------------------------------*/ | |
44 | - | |
45 | -G_DEFINE_TYPE(ipc3270, ipc3270, G_TYPE_OBJECT) | |
46 | - | |
47 | -/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
48 | - | |
49 | -static void ipc3270_finalize(GObject *object) { | |
50 | - | |
51 | - debug("ipc3270::%s(%p)",__FUNCTION__,object); | |
52 | - | |
53 | - ipc3270_release_object(IPC3270(object)); | |
54 | - | |
55 | - G_OBJECT_CLASS(ipc3270_parent_class)->finalize(object); | |
56 | -} | |
57 | - | |
58 | - | |
59 | -static void ipc3270_class_init(ipc3270Class *klass) { | |
60 | - | |
61 | - debug("%s",__FUNCTION__); | |
62 | - | |
63 | - GObjectClass *object_class; | |
64 | - object_class = G_OBJECT_CLASS (klass); | |
65 | - object_class->finalize = ipc3270_finalize; | |
66 | - | |
67 | -} | |
68 | - | |
69 | -static void ipc3270_init(ipc3270 *object) { | |
70 | - | |
71 | - debug("%s",__FUNCTION__); | |
72 | - object->error_domain = g_quark_from_static_string(PACKAGE_NAME); | |
73 | - | |
74 | -} | |
75 | - | |
76 | -GObject * ipc3270_new() { | |
77 | - return g_object_new(GLIB_TYPE_IPC3270, NULL); | |
78 | -} | |
79 | - | |
80 | -void ipc3270_add_terminal_introspection(GString *introspection) { | |
81 | - | |
82 | - size_t ix; | |
83 | - | |
84 | - g_string_append(introspection, | |
85 | - " <method name='connect'>" | |
86 | - " <arg type='s' name='url' direction='in'/>" | |
87 | - " <arg type='i' name='result' direction='out' />" \ | |
88 | - " </method>" | |
89 | - " <method name='disconnect'>" | |
90 | - " <arg type='i' name='result' direction='out' />" \ | |
91 | - " </method>" | |
92 | - " <method name='action'>" | |
93 | - " <arg type='s' name='name' direction='in' />" \ | |
94 | - " <arg type='i' name='result' direction='out' />" \ | |
95 | - " </method>" | |
96 | - " <method name='pfkey'>" \ | |
97 | - " <arg type='u' name='keycode' direction='in'/>" \ | |
98 | - " <arg type='i' name='result' direction='out' />" \ | |
99 | - " </method>" | |
100 | - " <method name='pakey'>" \ | |
101 | - " <arg type='u' name='keycode' direction='in'/>" \ | |
102 | - " <arg type='i' name='result' direction='out' />" \ | |
103 | - " </method>" | |
104 | - " <method name='getString'>" \ | |
105 | - " <arg type='s' name='text' direction='out' />" \ | |
106 | - " </method>" \ | |
107 | - " <method name='setString'>" \ | |
108 | - " <arg type='s' name='text' direction='in' />" \ | |
109 | - " <arg type='i' name='result' direction='out' />" \ | |
110 | - " </method>" \ | |
111 | - " <method name='setStringAt'>" \ | |
112 | - " <arg type='u' name='row' direction='in' />" \ | |
113 | - " <arg type='u' name='col' direction='in' />" \ | |
114 | - " <arg type='s' name='text' direction='in' />" \ | |
115 | - " <arg type='i' name='result' direction='out' />" \ | |
116 | - " </method>" \ | |
117 | - " <method name= 'getStringAt'>" \ | |
118 | - " <arg type='u' name='row' direction='in' />" \ | |
119 | - " <arg type='u' name='col' direction='in' />" \ | |
120 | - " <arg type='u' name='len' direction='in' />" \ | |
121 | - " <arg type='y' name='lf' direction='in' />" \ | |
122 | - " <arg type='s' name='text' direction='out' />" \ | |
123 | - " </method>" \ | |
124 | - " <method name='setStringAtAddress'>" \ | |
125 | - " <arg type='u' name='addr' direction='in' />" \ | |
126 | - " <arg type='s' name='text' direction='in' />" \ | |
127 | - " <arg type='i' name='result' direction='out' />" \ | |
128 | - " </method>" \ | |
129 | - " <method name= 'getStringAtAddress'>" \ | |
130 | - " <arg type='u' name='addr' direction='in' />" \ | |
131 | - " <arg type='u' name='len' direction='in' />" \ | |
132 | - " <arg type='y' name='lf' direction='in' />" \ | |
133 | - " <arg type='s' name='text' direction='out' />" \ | |
134 | - " </method>" \ | |
135 | - " <method name= 'getFieldAt'>" \ | |
136 | - " <arg type='u' name='row' direction='in' />" \ | |
137 | - " <arg type='u' name='col' direction='in' />" \ | |
138 | - " <arg type='s' name='text' direction='out' />" \ | |
139 | - " </method>" \ | |
140 | - " <method name= 'getFieldAtAddress'>" \ | |
141 | - " <arg type='u' name='addr' direction='in' />" \ | |
142 | - " <arg type='s' name='text' direction='out' />" \ | |
143 | - " </method>" \ | |
144 | - " <method name= 'getFieldAtCursor'>" \ | |
145 | - " <arg type='s' name='text' direction='out' />" \ | |
146 | - " </method>" \ | |
147 | - " <method name= 'waitForReady'>" \ | |
148 | - " <arg type='u' name='seconds' direction='in' />" \ | |
149 | - " <arg type='i' name='result' direction='out' />" \ | |
150 | - " </method>" \ | |
151 | - " <method name= 'setCursorAddress'>" \ | |
152 | - " <arg type='u' name='addr' direction='in' />" \ | |
153 | - " <arg type='s' name='text' direction='out' />" \ | |
154 | - " </method>" \ | |
155 | - " <method name= 'setCursorPosition'>" \ | |
156 | - " <arg type='u' name='row' direction='in' />" \ | |
157 | - " <arg type='u' name='col' direction='in' />" \ | |
158 | - " <arg type='s' name='text' direction='out' />" \ | |
159 | - " </method>" \ | |
160 | - " <property type='s' name='version' access='read'/>" \ | |
161 | - " <property type='s' name='revision' access='read'/>" | |
162 | - ); | |
163 | - | |
164 | - // Constrói métodos usando a tabela de controle | |
165 | - const LIB3270_ACTION_ENTRY * actions = lib3270_get_action_table(); | |
166 | - for(ix = 0; actions[ix].name; ix++) | |
167 | - { | |
168 | - g_string_append_printf( | |
169 | - introspection, \ | |
170 | - " <method name='%s'>" \ | |
171 | - " </method>", actions[ix].name | |
172 | - ); | |
173 | - } | |
174 | - | |
175 | - // Toggle properties | |
176 | - for(ix = 0; ix < (int) LIB3270_TOGGLE_COUNT; ix++) { | |
177 | - g_string_append_printf(introspection, " <property type='i' name='%s' access='readwrite'/>", lib3270_get_toggle_name((LIB3270_TOGGLE) ix)); | |
178 | - } | |
179 | - | |
180 | - // Boolean properties | |
181 | - const LIB3270_INT_PROPERTY * bol_props = lib3270_get_boolean_properties_list(); | |
182 | - for(ix = 0; bol_props[ix].name; ix++) { | |
183 | -// debug("Boolean(%s)",bol_props[ix].name); | |
184 | - g_string_append_printf(introspection, " <property type='b' name='%s' access='%s'/>", | |
185 | - bol_props[ix].name, | |
186 | - ((bol_props[ix].set == NULL) ? "read" : "readwrite") | |
187 | - ); | |
188 | - } | |
189 | - | |
190 | - // Integer properties | |
191 | - const LIB3270_INT_PROPERTY * int_props = lib3270_get_int_properties_list(); | |
192 | - for(ix = 0; int_props[ix].name; ix++) { | |
193 | - g_string_append_printf(introspection, " <property type='i' name='%s' access='%s'/>", | |
194 | - int_props[ix].name, | |
195 | - ((int_props[ix].set == NULL) ? "read" : "readwrite") | |
196 | - ); | |
197 | - } | |
198 | - | |
199 | - // String properties | |
200 | - const LIB3270_STRING_PROPERTY * str_props = lib3270_get_string_properties_list(); | |
201 | - for(ix = 0; str_props[ix].name; ix++) { | |
202 | - g_string_append_printf(introspection, " <property type='s' name='%s' access='%s'/>", | |
203 | - str_props[ix].name, | |
204 | - ((str_props[ix].set == NULL) ? "read" : "readwrite") | |
205 | - ); | |
206 | - } | |
207 | - | |
208 | -} | |
209 | - | |
210 | -void ipc3270_set_session(GObject *object, H3270 *hSession) { | |
211 | - | |
212 | - ipc3270 * ipc = IPC3270(object); | |
213 | - ipc->hSession = hSession; | |
214 | - | |
215 | -} | |
216 | - | |
217 | -const gchar * ipc3270_get_display_charset(GObject *object) { | |
218 | - return lib3270_get_display_charset(IPC3270(object)->hSession); | |
219 | -} | |
220 | - | |
221 | -H3270 * ipc3270_get_session(GObject *object) { | |
222 | - return IPC3270(object)->hSession; | |
223 | -} | |
224 | - | |
225 | -void ipc3270_set_error(GObject *object, int errcode, GError **error) { | |
226 | - g_set_error(error,IPC3270(object)->error_domain,errcode,"%s",strerror(errcode)); | |
227 | -} |
src/core/linux/gobject.h
... | ... | @@ -1,78 +0,0 @@ |
1 | -/* | |
2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob | |
5 | - * o nome G3270. | |
6 | - * | |
7 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
8 | - * | |
9 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
10 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
11 | - * Free Software Foundation. | |
12 | - * | |
13 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
14 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
15 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
16 | - * obter mais detalhes. | |
17 | - * | |
18 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
19 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
20 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | - * | |
22 | - * Este programa está nomeado como - e possui - linhas de código. | |
23 | - * | |
24 | - * Contatos: | |
25 | - * | |
26 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
27 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
28 | - * | |
29 | - */ | |
30 | - | |
31 | - /** | |
32 | - * @brief Private definitions for pw3270 IPC linux module. | |
33 | - * | |
34 | - */ | |
35 | - | |
36 | -#ifndef LINUX_GOBJECT_H_INCLUDED | |
37 | - | |
38 | - #define LINUX_GOBJECT_H_INCLUDED | |
39 | - | |
40 | - #include <config.h> | |
41 | - | |
42 | - #define ENABLE_NLS | |
43 | - #define GETTEXT_PACKAGE PACKAGE_NAME | |
44 | - | |
45 | - #include <libintl.h> | |
46 | - #include <glib/gi18n.h> | |
47 | - #include <gio/gio.h> | |
48 | - | |
49 | - #include <lib3270.h> | |
50 | - #include <lib3270/ipc-glib.h> | |
51 | - | |
52 | - G_BEGIN_DECLS | |
53 | - | |
54 | - typedef struct _ipc3270 ipc3270; | |
55 | - typedef struct _ipc3270Class ipc3270Class; | |
56 | - | |
57 | - struct _ipc3270 { | |
58 | - GObject parent; | |
59 | - | |
60 | - struct { | |
61 | - gchar * name; | |
62 | - GDBusConnection * connection; | |
63 | - guint id; | |
64 | - } dbus; | |
65 | - | |
66 | - H3270 * hSession; | |
67 | - GQuark error_domain; | |
68 | - }; | |
69 | - | |
70 | - struct _ipc3270Class { | |
71 | - GObjectClass parent; | |
72 | - }; | |
73 | - | |
74 | - G_GNUC_INTERNAL void ipc3270_release_object(ipc3270 *object); | |
75 | - | |
76 | - G_END_DECLS | |
77 | - | |
78 | -#endif // LINUX_GOBJECT_H_INCLUDED |
src/core/linux/start.c
... | ... | @@ -1,207 +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 - e possui - linhas de código. | |
22 | - * | |
23 | - * Referências: | |
24 | - * | |
25 | - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | - * | |
28 | - * Contatos: | |
29 | - * | |
30 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | - * | |
33 | - */ | |
34 | - | |
35 | -#include "gobject.h" | |
36 | -#include <lib3270.h> | |
37 | -#include <lib3270/ipc-glib.h> | |
38 | - | |
39 | -#include <dbus/dbus-glib.h> | |
40 | -#include <dbus/dbus-glib-bindings.h> | |
41 | - | |
42 | -static void | |
43 | - method_call ( | |
44 | - G_GNUC_UNUSED GDBusConnection *connection, | |
45 | - G_GNUC_UNUSED const gchar *sender, | |
46 | - G_GNUC_UNUSED const gchar *object_path, | |
47 | - G_GNUC_UNUSED const gchar *interface_name, | |
48 | - const gchar *method_name, | |
49 | - GVariant *parameters, | |
50 | - GDBusMethodInvocation *invocation, | |
51 | - gpointer user_data) { | |
52 | - | |
53 | - g_autoptr (GError) error = NULL; | |
54 | - | |
55 | - GVariant * rc = ipc3270_method_call(G_OBJECT(user_data), method_name, parameters, &error); | |
56 | - | |
57 | - if(error) { | |
58 | - | |
59 | - if(rc) { | |
60 | - g_variant_unref(rc); | |
61 | - } | |
62 | - | |
63 | - g_dbus_method_invocation_return_gerror(invocation, error); | |
64 | - | |
65 | - } else if(rc) { | |
66 | - | |
67 | - g_dbus_method_invocation_return_value(invocation, rc); | |
68 | - | |
69 | - } else { | |
70 | - | |
71 | - g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Invalid or unexpected method call"); | |
72 | - | |
73 | - } | |
74 | - | |
75 | - | |
76 | -} | |
77 | - | |
78 | -static GVariant * | |
79 | - get_property ( | |
80 | - G_GNUC_UNUSED GDBusConnection *connection, | |
81 | - G_GNUC_UNUSED const gchar *sender, | |
82 | - G_GNUC_UNUSED const gchar *object_path, | |
83 | - G_GNUC_UNUSED const gchar *interface_name, | |
84 | - const gchar *property_name, | |
85 | - GError **error, | |
86 | - gpointer user_data) | |
87 | -{ | |
88 | - | |
89 | - return ipc3270_get_property(G_OBJECT(user_data), property_name, error); | |
90 | - | |
91 | -} | |
92 | - | |
93 | -static gboolean | |
94 | - set_property ( | |
95 | - G_GNUC_UNUSED GDBusConnection *connection, | |
96 | - G_GNUC_UNUSED const gchar *sender, | |
97 | - G_GNUC_UNUSED const gchar *object_path, | |
98 | - G_GNUC_UNUSED const gchar *interface_name, | |
99 | - const gchar *property_name, | |
100 | - GVariant *value, | |
101 | - GError **error, | |
102 | - gpointer user_data) | |
103 | -{ | |
104 | - | |
105 | - return ipc3270_set_property(G_OBJECT(user_data), property_name, value, error); | |
106 | - | |
107 | -} | |
108 | - | |
109 | -void ipc3270_export_object(GObject *object, const char *name, GError **error) { | |
110 | - | |
111 | - char id; | |
112 | - | |
113 | - #pragma GCC diagnostic push | |
114 | - #pragma GCC diagnostic ignored "-Wmissing-field-initializers" | |
115 | - static const GDBusInterfaceVTable interface_vtable = { | |
116 | - method_call, | |
117 | - get_property, | |
118 | - set_property | |
119 | - }; | |
120 | - #pragma GCC diagnostic pop | |
121 | - | |
122 | - ipc3270 * ipc = IPC3270(object); | |
123 | - | |
124 | - ipc->dbus.connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, error); | |
125 | - if(*error) { | |
126 | - g_message("Can't get session bus: %s",(*error)->message); | |
127 | - return; | |
128 | - } | |
129 | - | |
130 | - g_dbus_connection_set_exit_on_close(ipc->dbus.connection,FALSE); | |
131 | - | |
132 | - for(id='a'; id < 'z' && !ipc->dbus.id && !*error; id++) { | |
133 | - | |
134 | - g_autofree gchar *object_name = g_strdup_printf(PW3270_IPC_SESSION_BUS_NAME,name,id); | |
135 | - | |
136 | - debug("Requesting \"%s\"",object_name); | |
137 | - | |
138 | - // https://dbus.freedesktop.org/doc/dbus-specification.html | |
139 | - GError *err = NULL; | |
140 | - | |
141 | - GVariant * response = | |
142 | - g_dbus_connection_call_sync ( | |
143 | - ipc->dbus.connection, | |
144 | - DBUS_SERVICE_DBUS, | |
145 | - DBUS_PATH_DBUS, | |
146 | - DBUS_INTERFACE_DBUS, | |
147 | - "RequestName", | |
148 | - g_variant_new ("(su)", object_name, DBUS_NAME_FLAG_DO_NOT_QUEUE), | |
149 | - NULL, | |
150 | - G_DBUS_CALL_FLAGS_NONE, | |
151 | - -1, | |
152 | - NULL, | |
153 | - &err | |
154 | - ); | |
155 | - | |
156 | - if(err) { | |
157 | - | |
158 | - g_message("Can't request \"%s\": %s",object_name,err->message); | |
159 | - g_error_free(err); | |
160 | - err = NULL; | |
161 | - | |
162 | - } else if(response) { | |
163 | - | |
164 | - guint32 reply = 0; | |
165 | - g_variant_get(response, "(u)", &reply); | |
166 | - g_variant_unref(response); | |
167 | - | |
168 | - if(reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { | |
169 | - | |
170 | - ipc->dbus.name = g_strdup(object_name); | |
171 | - g_message("Got %s", ipc->dbus.name); | |
172 | - | |
173 | - lib3270_set_session_id(ipc->hSession, id); | |
174 | - | |
175 | - // Introspection data for the service we are exporting | |
176 | - GString * introspection = g_string_new("<node><interface name='" PW3270_IPC_SESSION_INTERFACE_NAME "'>"); | |
177 | - ipc3270_add_terminal_introspection(introspection); | |
178 | - g_string_append(introspection,"</interface></node>"); | |
179 | - | |
180 | - gchar * introspection_xml = g_string_free(introspection,FALSE); | |
181 | - | |
182 | - // debug("\n%s\n",introspection_xml); | |
183 | - | |
184 | - GDBusNodeInfo * introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL); | |
185 | - | |
186 | - // Register object-id | |
187 | - ipc->dbus.id = g_dbus_connection_register_object ( | |
188 | - ipc->dbus.connection, | |
189 | - PW3270_IPC_SESSION_OBJECT_PATH, | |
190 | - introspection_data->interfaces[0], | |
191 | - &interface_vtable, | |
192 | - ipc, | |
193 | - NULL, | |
194 | - error | |
195 | - ); | |
196 | - | |
197 | - g_dbus_node_info_unref(introspection_data); | |
198 | - g_free(introspection_xml); | |
199 | - | |
200 | - return; | |
201 | - } | |
202 | - | |
203 | - } | |
204 | - | |
205 | - } | |
206 | - | |
207 | -} |
src/core/linux/start.c.1
... | ... | @@ -1,191 +0,0 @@ |
1 | -/* | |
2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob | |
5 | - * o nome G3270. | |
6 | - * | |
7 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
8 | - * | |
9 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
10 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
11 | - * Free Software Foundation. | |
12 | - * | |
13 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
14 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
15 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
16 | - * obter mais detalhes. | |
17 | - * | |
18 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
19 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
20 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | - * | |
22 | - * Este programa está nomeado como testprogram.c e possui - linhas de código. | |
23 | - * | |
24 | - * Contatos: | |
25 | - * | |
26 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
27 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
28 | - * | |
29 | - */ | |
30 | - | |
31 | - | |
32 | - /** | |
33 | - * @brief Plugin startup/stop for linux. | |
34 | - * | |
35 | - */ | |
36 | - | |
37 | - #include "private.h" | |
38 | - | |
39 | - #include <dbus/dbus-glib.h> | |
40 | - #include <dbus/dbus-glib-bindings.h> | |
41 | - | |
42 | - static void pw3270_dbus_cleanup(struct DBusSession * dBus) { | |
43 | - | |
44 | - if(dBus->proxy) { | |
45 | - g_object_unref(dBus); | |
46 | - } | |
47 | - | |
48 | - } | |
49 | - | |
50 | - int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal) { | |
51 | - | |
52 | - struct DBusSession * dBus = g_new0(struct DBusSession,1); | |
53 | - GError * error = NULL; | |
54 | - int id; | |
55 | - | |
56 | - g_object_set_data_full(G_OBJECT(terminal), "dbus-session-info", dBus, (GDestroyNotify) pw3270_dbus_cleanup); | |
57 | - | |
58 | - dBus->connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error); | |
59 | - | |
60 | - if(error) { | |
61 | - GtkWidget *dialog = gtk_message_dialog_new( | |
62 | - GTK_WINDOW(window), | |
63 | - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
64 | - GTK_MESSAGE_ERROR, | |
65 | - GTK_BUTTONS_OK, | |
66 | - _( "Can't get D-Bus connection" )); | |
67 | - | |
68 | - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); | |
69 | - g_error_free(error); | |
70 | - | |
71 | - gtk_dialog_run(GTK_DIALOG(dialog)); | |
72 | - gtk_widget_destroy(dialog); | |
73 | - | |
74 | - return -1; | |
75 | - } | |
76 | - | |
77 | - g_dbus_connection_set_exit_on_close(dBus->connection,FALSE); | |
78 | - | |
79 | - /* | |
80 | - dBus->proxy = g_dbus_proxy_new_sync( | |
81 | - dBus->connection, | |
82 | - G_DBUS_PROXY_FLAGS_NONE, | |
83 | - NULL, // GDBusInterfaceInfo | |
84 | - "br.com.bb." PACKAGE_NAME, // name | |
85 | - "/br/com/bb/" PACKAGE_NAME "/terminal", // object path | |
86 | - "br.com.bb." PACKAGE_NAME ".terminal", // interface | |
87 | - NULL, // GCancellable | |
88 | - &error ); | |
89 | - | |
90 | - if(error) { | |
91 | - | |
92 | - GtkWidget *dialog = gtk_message_dialog_new( | |
93 | - GTK_WINDOW(window), | |
94 | - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
95 | - GTK_MESSAGE_ERROR, | |
96 | - GTK_BUTTONS_OK, | |
97 | - _( "Can't get D-Bus proxy object" )); | |
98 | - | |
99 | - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); | |
100 | - g_error_free(error); | |
101 | - | |
102 | - gtk_dialog_run(GTK_DIALOG(dialog)); | |
103 | - gtk_widget_destroy(dialog); | |
104 | - | |
105 | - return -1; | |
106 | - } | |
107 | - */ | |
108 | - | |
109 | - for(id='a'; id < 'z' && !error && !dBus->proxy; id++) { | |
110 | - | |
111 | - gchar *name = g_strdup_printf("br.com.bb.%s.%c",gtk_widget_get_name(window),id); | |
112 | - | |
113 | - debug("Requesting \"%s\"",name); | |
114 | - | |
115 | - // https://dbus.freedesktop.org/doc/dbus-specification.html | |
116 | - GVariant * response = | |
117 | - g_dbus_connection_call_sync ( | |
118 | - dBus->connection, | |
119 | - DBUS_SERVICE_DBUS, | |
120 | - DBUS_PATH_DBUS, | |
121 | - DBUS_INTERFACE_DBUS, | |
122 | - "RequestName", | |
123 | - g_variant_new ("(su)", name, DBUS_NAME_FLAG_DO_NOT_QUEUE), | |
124 | - NULL, | |
125 | - G_DBUS_CALL_FLAGS_NONE, | |
126 | - -1, | |
127 | - NULL, | |
128 | - &error | |
129 | - ); | |
130 | - | |
131 | - if(error) { | |
132 | - g_message("Can't request \"%s\": %s",name,error->message); | |
133 | - g_error_free(error); | |
134 | - error = NULL; | |
135 | - } | |
136 | - | |
137 | - if(response) { | |
138 | - | |
139 | - guint32 reply = 0; | |
140 | - g_variant_get(response, "(u)", &reply); | |
141 | - g_variant_unref(response); | |
142 | - | |
143 | - if(reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { | |
144 | - | |
145 | - dBus->proxy = g_dbus_proxy_new_sync( | |
146 | - dBus->connection, | |
147 | - G_DBUS_PROXY_FLAGS_NONE, | |
148 | - NULL, // GDBusInterfaceInfo | |
149 | - name, // name | |
150 | - "/br/com/bb/" PACKAGE_NAME "/terminal", // object path | |
151 | - "br.com.bb." PACKAGE_NAME ".terminal", // interface | |
152 | - NULL, // GCancellable | |
153 | - &error ); | |
154 | - | |
155 | - gchar * widget_name = g_strdup_printf("%s:%c",gtk_widget_get_name(window),id); | |
156 | - v3270_set_session_name(terminal, widget_name); | |
157 | - g_free(widget_name); | |
158 | - | |
159 | - g_message("Got %s - %s", name, v3270_get_session_name(terminal)); | |
160 | - | |
161 | - } | |
162 | - | |
163 | - } | |
164 | - | |
165 | - g_free(name); | |
166 | - | |
167 | - } | |
168 | - | |
169 | - if(!dBus->proxy) { | |
170 | - GtkWidget *dialog = gtk_message_dialog_new( | |
171 | - GTK_WINDOW(window), | |
172 | - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
173 | - GTK_MESSAGE_ERROR, | |
174 | - GTK_BUTTONS_OK, | |
175 | - _( "Can't get DBUS object name" )); | |
176 | - | |
177 | - gtk_dialog_run(GTK_DIALOG(dialog)); | |
178 | - gtk_widget_destroy(dialog); | |
179 | - | |
180 | - return -1; | |
181 | - } | |
182 | - | |
183 | - // Got D-Bus name, register object. | |
184 | - | |
185 | - return 0; | |
186 | - | |
187 | - } | |
188 | - | |
189 | - #endif // !_WIN32 | |
190 | - | |
191 | - |
src/core/linux/stop.c
... | ... | @@ -1,111 +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 - e possui - linhas de código. | |
22 | - * | |
23 | - * Referências: | |
24 | - * | |
25 | - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | - * | |
28 | - * Contatos: | |
29 | - * | |
30 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | - * | |
33 | - */ | |
34 | - | |
35 | -#include "gobject.h" | |
36 | -#include <lib3270.h> | |
37 | -#include <lib3270/ipc-glib.h> | |
38 | - | |
39 | -#include <dbus/dbus-glib.h> | |
40 | -#include <dbus/dbus-glib-bindings.h> | |
41 | - | |
42 | -void ipc3270_release_object(ipc3270 *object) { | |
43 | - | |
44 | - if(object->dbus.id) { | |
45 | - g_dbus_connection_unregister_object(object->dbus.connection,object->dbus.id); | |
46 | - } | |
47 | - | |
48 | - if(object->dbus.name) { | |
49 | - | |
50 | - debug("Releasing %s",object->dbus.name); | |
51 | - | |
52 | - // https://dbus.freedesktop.org/doc/dbus-specification.html | |
53 | - GError *err = NULL; | |
54 | - | |
55 | - GVariant * response = | |
56 | - g_dbus_connection_call_sync ( | |
57 | - object->dbus.connection, | |
58 | - DBUS_SERVICE_DBUS, | |
59 | - DBUS_PATH_DBUS, | |
60 | - DBUS_INTERFACE_DBUS, | |
61 | - "ReleaseName", | |
62 | - g_variant_new ("(s)", object->dbus.name), | |
63 | - NULL, | |
64 | - G_DBUS_CALL_FLAGS_NONE, | |
65 | - -1, | |
66 | - NULL, | |
67 | - &err | |
68 | - ); | |
69 | - | |
70 | - if(err) { | |
71 | - | |
72 | - g_message("Can't release \"%s\": %s",object->dbus.name,err->message); | |
73 | - g_error_free(err); | |
74 | - err = NULL; | |
75 | - | |
76 | - } else if(response) { | |
77 | - | |
78 | - guint32 reply = 0; | |
79 | - g_variant_get(response, "(u)", &reply); | |
80 | - g_variant_unref(response); | |
81 | - | |
82 | - switch(reply) | |
83 | - { | |
84 | - case DBUS_RELEASE_NAME_REPLY_RELEASED: | |
85 | - // The caller has released his claim on the given name. | |
86 | - // Either the caller was the primary owner of the name, and the name is | |
87 | - // now unused or taken by somebody waiting in the queue for the name, | |
88 | - // or the caller was waiting in the queue for the name and has now been removed from the queue. | |
89 | - g_message("%s released",object->dbus.name); | |
90 | - break; | |
91 | - | |
92 | - case DBUS_RELEASE_NAME_REPLY_NON_EXISTENT: | |
93 | - // The given name does not exist on this bus. | |
94 | - g_message("%s does not exist on this bus",object->dbus.name); | |
95 | - break; | |
96 | - | |
97 | - case DBUS_RELEASE_NAME_REPLY_NOT_OWNER: | |
98 | - // The caller was not the primary owner of this name, and was also not waiting in the queue to own this name. | |
99 | - g_message("%s does not exist on this bus", object->dbus.name); | |
100 | - break; | |
101 | - | |
102 | - default: | |
103 | - g_message("Unexpected response %u when removing %s",(unsigned int) reply, object->dbus.name); | |
104 | - } | |
105 | - } | |
106 | - | |
107 | - g_free(object->dbus.name); | |
108 | - object->dbus.name = NULL; | |
109 | - } | |
110 | - | |
111 | -} |
src/core/methods.c
... | ... | @@ -1,190 +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 - e possui - linhas de código. | |
22 | - * | |
23 | - * Referências: | |
24 | - * | |
25 | - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | - * | |
28 | - * Contatos: | |
29 | - * | |
30 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | - * | |
33 | - */ | |
34 | - | |
35 | -#include <config.h> | |
36 | -#include <string.h> | |
37 | -#include <lib3270/ipc-glib.h> | |
38 | -#include <lib3270.h> | |
39 | -#include <lib3270/actions.h> | |
40 | -#include <lib3270/trace.h> | |
41 | - | |
42 | -// #include <dbus/dbus-glib.h> | |
43 | -// #include <dbus/dbus-glib-bindings.h> | |
44 | - | |
45 | -GVariant * ipc3270_method_call(GObject *object, const gchar *method_name, GVariant *parameters, GError **error) | |
46 | -{ | |
47 | - | |
48 | - size_t ix; | |
49 | - H3270 * hSession = ipc3270_get_session(object); | |
50 | - | |
51 | - lib3270_trace_event(hSession,"Method %s called on session %c\n",method_name,lib3270_get_session_id(hSession)); | |
52 | - | |
53 | - debug("%s(%s)",__FUNCTION__,method_name); | |
54 | - | |
55 | - if(!g_ascii_strcasecmp(method_name,"getString")) | |
56 | - { | |
57 | - return ipc3270_GVariant_from_input_string(object, lib3270_get_string_at_address(hSession,0,-1,'\n'), error); | |
58 | - } | |
59 | - else if(!g_ascii_strcasecmp(method_name,"setString")) | |
60 | - { | |
61 | - gchar *text = NULL; | |
62 | - g_variant_get(parameters, "(&s)", &text); | |
63 | - | |
64 | - g_autofree gchar * converted = ipc3270_convert_output_string(object, text, error); | |
65 | - if(lib3270_input_string(hSession,(const unsigned char *) converted) < 0) | |
66 | - { | |
67 | - // Failed! | |
68 | - debug("%s failed: %s",method_name,strerror(errno)); | |
69 | - ipc3270_set_error(object,errno,error); | |
70 | - return NULL; | |
71 | - } | |
72 | - | |
73 | - // Suceeded | |
74 | - debug("%s Suceeds",method_name); | |
75 | - return g_variant_new("(i)", (gint) 0); | |
76 | - | |
77 | - } | |
78 | - else if(!g_ascii_strcasecmp(method_name,"setStringAt")) | |
79 | - { | |
80 | - guint row,col; | |
81 | - gchar *text = NULL; | |
82 | - g_variant_get(parameters, "(ii&s)", &row, &col, &text); | |
83 | - | |
84 | - g_autofree gchar * converted = ipc3270_convert_output_string(object, text, error); | |
85 | - if(lib3270_set_string_at(hSession,row,col,(const unsigned char *) converted) < 0) | |
86 | - { | |
87 | - // Failed! | |
88 | - ipc3270_set_error(object,errno,error); | |
89 | - return NULL; | |
90 | - } | |
91 | - | |
92 | - // Suceeded | |
93 | - return g_variant_new("(i)", (gint) 0); | |
94 | - | |
95 | - } | |
96 | - else if(!g_ascii_strcasecmp(method_name,"getStringAt")) | |
97 | - { | |
98 | - guint row,col,len; | |
99 | - guchar lf; | |
100 | - g_variant_get(parameters, "(uuuy)", &row, &col, &len,&lf); | |
101 | - | |
102 | - return ipc3270_GVariant_from_input_string(object,lib3270_get_string_at(hSession, row, col, len, lf),error); | |
103 | - | |
104 | - } | |
105 | - else if(!g_ascii_strcasecmp(method_name,"setStringAtAddress")) | |
106 | - { | |
107 | - guint addr; | |
108 | - gchar *text = NULL; | |
109 | - g_variant_get(parameters, "(i&s)", &addr, &text); | |
110 | - | |
111 | - g_autofree gchar * converted = ipc3270_convert_output_string(object, text, error); | |
112 | - if(lib3270_set_string_at_address(hSession,addr,(unsigned char *) converted) < 0) | |
113 | - { | |
114 | - // Failed! | |
115 | - ipc3270_set_error(object,errno,error); | |
116 | - return NULL; | |
117 | - } | |
118 | - | |
119 | - // Suceeded | |
120 | - return g_variant_new("(i)", (gint) 0); | |
121 | - | |
122 | - } | |
123 | - else if(!g_ascii_strcasecmp(method_name,"getStringAtAddress")) | |
124 | - { | |
125 | - guint addr,len; | |
126 | - guchar lf; | |
127 | - g_variant_get(parameters, "(uuy)", &addr, &len, &lf); | |
128 | - | |
129 | - debug("lf=%02x",(int) lf); | |
130 | - | |
131 | - return ipc3270_GVariant_from_input_string(object,lib3270_get_string_at_address(hSession, addr, len, lf),error); | |
132 | - | |
133 | - } | |
134 | - else if(!g_ascii_strcasecmp(method_name,"waitforready")) | |
135 | - { | |
136 | - guint timeout = 1; | |
137 | - g_variant_get(parameters, "(u)", &timeout); | |
138 | - return g_variant_new("(i)", (gint) lib3270_wait_for_ready(hSession,timeout)); | |
139 | - } | |
140 | - | |
141 | - // Check action table. | |
142 | - const LIB3270_ACTION_ENTRY * actions = lib3270_get_action_table(); | |
143 | - for(ix = 0; actions[ix].name; ix++) | |
144 | - { | |
145 | - if(!g_ascii_strcasecmp(actions[ix].name,method_name)) { | |
146 | - | |
147 | - int rc = actions[ix].call(hSession); | |
148 | - if(rc) | |
149 | - { | |
150 | - // Failed | |
151 | - ipc3270_set_error(object,errno,error); | |
152 | - return NULL; | |
153 | - } | |
154 | - | |
155 | - // Suceeded | |
156 | - return g_variant_new("(i)", (gint) 0); | |
157 | - | |
158 | - } | |
159 | - } | |
160 | - | |
161 | - // Check int methods | |
162 | - const IPC_METHOD_INT_ARG * int_methods = ipc3270_get_int_arg_methods(); | |
163 | - | |
164 | - for(ix = 0; int_methods[ix].name; ix++) | |
165 | - { | |
166 | - if(!g_ascii_strcasecmp(int_methods[ix].name,method_name)) { | |
167 | - | |
168 | - gint value; | |
169 | - g_variant_get(parameters, "(i)", &value); | |
170 | - | |
171 | - int rc = int_methods[ix].call(hSession, value); | |
172 | - if(rc) | |
173 | - { | |
174 | - // Failed | |
175 | - ipc3270_set_error(object,errno,error); | |
176 | - return NULL; | |
177 | - } | |
178 | - | |
179 | - // Suceeded | |
180 | - return g_variant_new("(i)", (gint) 0); | |
181 | - | |
182 | - } | |
183 | - | |
184 | - } | |
185 | - | |
186 | - g_message("Unknown method \"%s\"",method_name); | |
187 | - | |
188 | - return NULL; | |
189 | - | |
190 | -} |
src/core/setproperties.c
... | ... | @@ -1,153 +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 - e possui - linhas de código. | |
22 | - * | |
23 | - * Referências: | |
24 | - * | |
25 | - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | - * | |
28 | - * Contatos: | |
29 | - * | |
30 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | - * | |
33 | - */ | |
34 | - | |
35 | -#include <config.h> | |
36 | -#include <lib3270/ipc-glib.h> | |
37 | -#include <lib3270.h> | |
38 | -#include <lib3270/properties.h> | |
39 | -#include <lib3270/trace.h> | |
40 | - | |
41 | -gboolean ipc3270_set_property(GObject *object, const gchar *property_name, GVariant *value, GError **error) { | |
42 | - | |
43 | - // Check for property | |
44 | - size_t ix; | |
45 | - H3270 * hSession = ipc3270_get_session(object); | |
46 | - | |
47 | - lib3270_trace_event(hSession,"SetProperty(%s) called on session %c\n",property_name,lib3270_get_session_id(hSession)); | |
48 | - | |
49 | - // Boolean properties | |
50 | - const LIB3270_INT_PROPERTY * boolprop = lib3270_get_boolean_properties_list(); | |
51 | - for(ix = 0; boolprop[ix].name; ix++) { | |
52 | - | |
53 | - if(boolprop[ix].set && !g_ascii_strcasecmp(boolprop[ix].name, property_name)) { | |
54 | - | |
55 | - // Found it! | |
56 | - if(boolprop[ix].set(hSession, (int) (g_variant_get_boolean(value) ? 1 : 0))) { | |
57 | - | |
58 | - // Erro! | |
59 | - g_set_error_literal(error, | |
60 | - G_IO_ERROR, | |
61 | - G_IO_ERROR_FAILED, | |
62 | - g_strerror(errno) | |
63 | - ); | |
64 | - | |
65 | - return FALSE; | |
66 | - } | |
67 | - | |
68 | - return TRUE; | |
69 | - | |
70 | - } | |
71 | - | |
72 | - } | |
73 | - | |
74 | - // Integer properties | |
75 | - const LIB3270_INT_PROPERTY * intprop = lib3270_get_int_properties_list(); | |
76 | - for(ix = 0; intprop[ix].name; ix++) { | |
77 | - | |
78 | - if(intprop[ix].set && !g_ascii_strcasecmp(intprop[ix].name, property_name)) { | |
79 | - | |
80 | - // Found it! | |
81 | - if(intprop[ix].set(hSession, (int) (g_variant_get_boolean(value) ? 1 : 0))) { | |
82 | - | |
83 | - // Erro! | |
84 | - g_set_error_literal( | |
85 | - error, | |
86 | - G_IO_ERROR, | |
87 | - G_IO_ERROR_FAILED, | |
88 | - g_strerror(errno) | |
89 | - ); | |
90 | - | |
91 | - return FALSE; | |
92 | - } | |
93 | - | |
94 | - return TRUE; | |
95 | - | |
96 | - } | |
97 | - | |
98 | - } | |
99 | - | |
100 | - // String properties | |
101 | - const LIB3270_STRING_PROPERTY * strprop = lib3270_get_string_properties_list(); | |
102 | - for(ix = 0; strprop[ix].name; ix++) { | |
103 | - | |
104 | - if(strprop[ix].set && !g_ascii_strcasecmp(strprop[ix].name, property_name)) { | |
105 | - | |
106 | - // Found it! | |
107 | - if(strprop[ix].set(hSession, g_variant_get_string(value,NULL))) { | |
108 | - | |
109 | - // Erro! | |
110 | - g_set_error_literal(error, | |
111 | - G_IO_ERROR, | |
112 | - G_IO_ERROR_FAILED, | |
113 | - g_strerror(errno) | |
114 | - ); | |
115 | - | |
116 | - return FALSE; | |
117 | - } | |
118 | - | |
119 | - return TRUE; | |
120 | - | |
121 | - } | |
122 | - | |
123 | - } | |
124 | - | |
125 | - // Check for toggle | |
126 | - LIB3270_TOGGLE toggle = lib3270_get_toggle_id(property_name); | |
127 | - if(toggle != (LIB3270_TOGGLE) -1) { | |
128 | - | |
129 | - // Is a Tn3270 toggle, get it! | |
130 | - if(lib3270_set_toggle(hSession,toggle,(int) g_variant_get_int32(value))) { | |
131 | - | |
132 | - // Erro! | |
133 | - g_set_error_literal(error, | |
134 | - G_IO_ERROR, | |
135 | - G_IO_ERROR_FAILED, | |
136 | - g_strerror(errno) | |
137 | - ); | |
138 | - | |
139 | - return FALSE; | |
140 | - | |
141 | - } | |
142 | - | |
143 | - return TRUE; | |
144 | - } | |
145 | - | |
146 | - g_set_error (error, | |
147 | - G_IO_ERROR, | |
148 | - G_IO_ERROR_NOT_FOUND, | |
149 | - "Can't find any property named %s", property_name | |
150 | - ); | |
151 | - | |
152 | - return FALSE; | |
153 | -} |
src/core/tools.c
... | ... | @@ -1,45 +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 - e possui - linhas de código. | |
22 | - * | |
23 | - * Contatos: | |
24 | - * | |
25 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | - * | |
28 | - */ | |
29 | - | |
30 | -#include <lib3270.h> | |
31 | -#include <lib3270/ipc-glib.h> | |
32 | - | |
33 | -/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
34 | - | |
35 | - #if ! GLIB_CHECK_VERSION(2,44,0) | |
36 | - | |
37 | - // Reference: https://github.com/ImageMagick/glib/blob/master/glib/glib-autocleanups.h | |
38 | - void ipc3270_autoptr_cleanup_generic_gfree(void *p) | |
39 | - { | |
40 | - void **pp = (void**)p; | |
41 | - g_free (*pp); | |
42 | - } | |
43 | - | |
44 | - #endif // ! GLIB(2,44,0) | |
45 | - |
src/core/windows/gobject.c
... | ... | @@ -1,92 +0,0 @@ |
1 | -/* | |
2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | - * | |
6 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | - * | |
8 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | - * Free Software Foundation. | |
11 | - * | |
12 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | - * obter mais detalhes. | |
16 | - * | |
17 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | - * | |
21 | - * Este programa está nomeado como gobject.c e possui - linhas de código. | |
22 | - * | |
23 | - * Contatos: | |
24 | - * | |
25 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | - * | |
28 | - */ | |
29 | - | |
30 | -#include "gobject.h" | |
31 | -#include <lib3270.h> | |
32 | -#include <lib3270/actions.h> | |
33 | -#include <lib3270/properties.h> | |
34 | -#include <lib3270/ipc-glib.h> | |
35 | - | |
36 | -/*--[ Widget definition ]----------------------------------------------------------------------------*/ | |
37 | - | |
38 | -G_DEFINE_TYPE(ipc3270, ipc3270, G_TYPE_OBJECT) | |
39 | - | |
40 | -/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
41 | - | |
42 | -static void ipc3270_finalize(GObject *object) { | |
43 | - | |
44 | - debug("ipc3270::%s(%p)",__FUNCTION__,object); | |
45 | - | |
46 | - ipc3270_release_object(IPC3270(object)); | |
47 | - | |
48 | - G_OBJECT_CLASS(ipc3270_parent_class)->finalize(object); | |
49 | - | |
50 | -} | |
51 | - | |
52 | - | |
53 | -static void ipc3270_class_init(ipc3270Class *klass) { | |
54 | - | |
55 | - debug("%s",__FUNCTION__); | |
56 | - | |
57 | - GObjectClass *object_class; | |
58 | - object_class = G_OBJECT_CLASS (klass); | |
59 | - object_class->finalize = ipc3270_finalize; | |
60 | - | |
61 | -} | |
62 | - | |
63 | -static void ipc3270_init(ipc3270 *object) { | |
64 | - | |
65 | - debug("%s(%p)",__FUNCTION__,object); | |
66 | - object->error_domain = g_quark_from_static_string(PACKAGE_NAME); | |
67 | - | |
68 | -} | |
69 | - | |
70 | -GObject * ipc3270_new() { | |
71 | - return g_object_new(GLIB_TYPE_IPC3270, NULL); | |
72 | -} | |
73 | - | |
74 | -void ipc3270_set_session(GObject *object, H3270 *hSession) { | |
75 | - | |
76 | - ipc3270 * ipc = IPC3270(object); | |
77 | - ipc->hSession = hSession; | |
78 | - | |
79 | -} | |
80 | - | |
81 | -const gchar * ipc3270_get_display_charset(GObject *object) { | |
82 | - return lib3270_get_display_charset(IPC3270(object)->hSession); | |
83 | -} | |
84 | - | |
85 | -H3270 * ipc3270_get_session(GObject *object) { | |
86 | - return IPC3270(object)->hSession; | |
87 | -} | |
88 | - | |
89 | -void ipc3270_set_error(GObject *object, int errcode, GError **error) { | |
90 | - g_set_error(error,IPC3270(object)->error_domain,errcode,"%s",strerror(errcode)); | |
91 | -} | |
92 | - |
src/core/windows/gobject.h
... | ... | @@ -1,98 +0,0 @@ |
1 | -/* | |
2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob | |
5 | - * o nome G3270. | |
6 | - * | |
7 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
8 | - * | |
9 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
10 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
11 | - * Free Software Foundation. | |
12 | - * | |
13 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
14 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
15 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
16 | - * obter mais detalhes. | |
17 | - * | |
18 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
19 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
20 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | - * | |
22 | - * Este programa está nomeado como - e possui - linhas de código. | |
23 | - * | |
24 | - * Contatos: | |
25 | - * | |
26 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
27 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
28 | - * | |
29 | - */ | |
30 | - | |
31 | - /** | |
32 | - * @brief Private definitions for pw3270 IPC windows module. | |
33 | - * | |
34 | - */ | |
35 | - | |
36 | -#ifndef WINDOWS_GOBJECT_H_INCLUDED | |
37 | - | |
38 | - #define WINDOWS_GOBJECT_H_INCLUDED | |
39 | - | |
40 | - #include <windows.h> | |
41 | - #include <config.h> | |
42 | - | |
43 | - #define ENABLE_NLS | |
44 | - #define GETTEXT_PACKAGE PACKAGE_NAME | |
45 | - | |
46 | - #include <libintl.h> | |
47 | - #include <glib/gi18n.h> | |
48 | - #include <gio/gio.h> | |
49 | - | |
50 | - #include <lib3270.h> | |
51 | - #include <lib3270/ipc-glib.h> | |
52 | - | |
53 | - #define PIPE_BUFFER_LENGTH 8192 | |
54 | - | |
55 | - G_BEGIN_DECLS | |
56 | - | |
57 | - typedef struct _ipc3270 ipc3270; | |
58 | - typedef struct _ipc3270Class ipc3270Class; | |
59 | - typedef struct _ipc3270Request ipc3270Request; | |
60 | - | |
61 | - typedef enum _ipc3270_pipe_state { | |
62 | - PIPE_STATE_WAITING, | |
63 | - PIPE_STATE_READ, | |
64 | - PIPE_STATE_PENDING_READ, | |
65 | - PIPE_STATE_UNDEFINED | |
66 | - } IPC3270_PIPE_STATE; | |
67 | - | |
68 | - typedef struct _ipc3270_pipe_source { | |
69 | - GSource gsrc; | |
70 | - GObject * object; | |
71 | - HANDLE hPipe; | |
72 | - | |
73 | - IPC3270_PIPE_STATE state; | |
74 | - | |
75 | - OVERLAPPED overlap; | |
76 | - unsigned char buffer[PIPE_BUFFER_LENGTH+1]; | |
77 | - | |
78 | - } IPC3270_PIPE_SOURCE; | |
79 | - | |
80 | - struct _ipc3270 { | |
81 | - GObject parent; | |
82 | - H3270 * hSession; | |
83 | - IPC3270_PIPE_SOURCE * source; | |
84 | - GQuark error_domain; | |
85 | - }; | |
86 | - | |
87 | - struct _ipc3270Class { | |
88 | - GObjectClass parent; | |
89 | - }; | |
90 | - | |
91 | - G_GNUC_INTERNAL GSourceFuncs ipc3270_source_funcs; | |
92 | - | |
93 | - G_GNUC_INTERNAL void ipc3270_release_object(ipc3270 *object); | |
94 | - G_GNUC_INTERNAL void ipc3270_wait_for_client(IPC3270_PIPE_SOURCE *source); | |
95 | - | |
96 | - G_END_DECLS | |
97 | - | |
98 | -#endif // WINDOWS_GOBJECT_H_INCLUDED |
src/core/windows/inout.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. Registro no INPI sob | |
5 | - * o nome G3270. | |
6 | - * | |
7 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
8 | - * | |
9 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
10 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
11 | - * Free Software Foundation. | |
12 | - * | |
13 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
14 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
15 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
16 | - * obter mais detalhes. | |
17 | - * | |
18 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
19 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
20 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | - * | |
22 | - * Este programa está nomeado como inout.c e possui - linhas de código. | |
23 | - * | |
24 | - * Contatos: | |
25 | - * | |
26 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
27 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
28 | - * | |
29 | - */ | |
30 | - | |
31 | - | |
32 | - /** | |
33 | - * @brief Pack/Unpack IPC data block. | |
34 | - * | |
35 | - */ | |
36 | - | |
37 | - #include <config.h> | |
38 | - #include <lib3270/ipc-glib.h> | |
39 | - #include <string.h> | |
40 | - #include <stdlib.h> | |
41 | - | |
42 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
43 | - | |
44 | -unsigned char * ipc3270_pack_error(const GError *error, size_t * szPacket) { | |
45 | - | |
46 | - static const char * error_response = "error"; | |
47 | - | |
48 | - *szPacket = strlen(error_response) + 1 + (sizeof(guint16) * 2) + strlen(error->message); | |
49 | - | |
50 | - // Allocate buffer | |
51 | - unsigned char * outputBuffer = g_malloc0(*szPacket); | |
52 | - unsigned char * txtptr = outputBuffer; | |
53 | - | |
54 | - // Add name | |
55 | - strcpy((char *) txtptr,error_response); | |
56 | - txtptr += strlen((char *) txtptr) + 1; | |
57 | - | |
58 | - // Add RC | |
59 | - *((guint16 *) txtptr) = (guint16) error->code; | |
60 | - txtptr += sizeof(guint16); | |
61 | - | |
62 | - // Add message | |
63 | - strcpy((char *) txtptr,error->message); | |
64 | - txtptr += (strlen((char *) txtptr)+1); | |
65 | - | |
66 | - return outputBuffer; | |
67 | -} | |
68 | - | |
69 | -static unsigned char * setup_header(unsigned char *txtptr, const gchar *name, int id, size_t count) { | |
70 | - | |
71 | - // Add name | |
72 | - strcpy((char *) txtptr,name); | |
73 | - txtptr += strlen((char *) txtptr) + 1; | |
74 | - | |
75 | - // Add ID | |
76 | - *((guint16 *) txtptr) = (guint16) id; | |
77 | - txtptr += sizeof(guint16); | |
78 | - | |
79 | - // Update ptr; | |
80 | - *((guint16 *) txtptr) = (guint16) count; | |
81 | - txtptr += sizeof(guint16); | |
82 | - | |
83 | - return txtptr; | |
84 | -} | |
85 | - | |
86 | -unsigned char * pack_value(unsigned char *txtptr, GVariant *value) { | |
87 | - | |
88 | - unsigned char type = (unsigned char) g_variant_get_type_string(value)[0]; | |
89 | - | |
90 | - debug("%s type=%c",__FUNCTION__,type); | |
91 | - | |
92 | - *(txtptr++) = type; | |
93 | - | |
94 | - switch(type) { | |
95 | - // https://developer.gnome.org/glib/stable/gvariant-format-strings.html | |
96 | - case 's': | |
97 | - strcpy((char *) txtptr,g_variant_get_string(value,NULL)); | |
98 | - txtptr += (strlen((char *) txtptr)+1); | |
99 | - break; | |
100 | - | |
101 | - case 'b': // gboolean | |
102 | - *(txtptr++) = g_variant_get_boolean(value) ? 1 : 0; | |
103 | - break; | |
104 | - | |
105 | - case 'y': // guchar | |
106 | - *(txtptr++) = g_variant_get_byte(value); | |
107 | - break; | |
108 | - | |
109 | - case 'n': // gint16 | |
110 | - *((gint16 *) txtptr) = g_variant_get_int16(value); | |
111 | - txtptr += sizeof(gint16); | |
112 | - break; | |
113 | - | |
114 | - case 'q': // guint16 | |
115 | - *((guint16 *) txtptr) = g_variant_get_uint16(value); | |
116 | - txtptr += sizeof(guint16); | |
117 | - break; | |
118 | - | |
119 | - case 'i': // gint32 | |
120 | - case 'h': // gint32 | |
121 | - *((gint32 *) txtptr) = g_variant_get_int32(value); | |
122 | - txtptr += sizeof(gint32); | |
123 | - break; | |
124 | - | |
125 | - case 'u': // guint32 | |
126 | - *((guint32 *) txtptr) = g_variant_get_uint32(value); | |
127 | - txtptr += sizeof(guint32); | |
128 | - break; | |
129 | - | |
130 | - case 'x': // gint64 | |
131 | - *((gint64 *) txtptr) = g_variant_get_int64(value); | |
132 | - txtptr += sizeof(gint64); | |
133 | - break; | |
134 | - | |
135 | - case 't': // guint64 | |
136 | - *((guint64 *) txtptr) = g_variant_get_uint64(value); | |
137 | - txtptr += sizeof(guint64); | |
138 | - break; | |
139 | - | |
140 | - default: | |
141 | - errno = EINVAL; | |
142 | - return NULL; | |
143 | - | |
144 | - } | |
145 | - | |
146 | - return txtptr; | |
147 | -} | |
148 | - | |
149 | -unsigned char * ipc3270_pack_value(const gchar *name, int id, GVariant *value, size_t * szPacket) { | |
150 | - | |
151 | - debug("%s(%s)",__FUNCTION__,name); | |
152 | - | |
153 | - // Set packet size; | |
154 | - *szPacket = | |
155 | - strlen(name) + 1 | |
156 | - + (sizeof(guint16) * 2) | |
157 | - + g_variant_get_size(value) +1; | |
158 | - | |
159 | - unsigned char * outputBuffer = g_malloc0(*szPacket); | |
160 | - unsigned char * txtptr = setup_header(outputBuffer,name,id,1); | |
161 | - | |
162 | - txtptr = pack_value(txtptr, value); | |
163 | - if(!txtptr) { | |
164 | - g_free(outputBuffer); | |
165 | - return NULL; | |
166 | - } | |
167 | - | |
168 | - debug("used=%u allocated=%u",(unsigned int) (txtptr-outputBuffer), (unsigned int) *szPacket); | |
169 | - | |
170 | - return outputBuffer; | |
171 | - | |
172 | -} | |
173 | - | |
174 | - | |
175 | -unsigned char * ipc3270_pack(const gchar * name, int id, GVariant *values, size_t * szPacket) { | |
176 | - | |
177 | - GVariantIter iter; | |
178 | - gsize count = g_variant_iter_init(&iter, values); | |
179 | - GVariant * child; | |
180 | - size_t ix = 0; | |
181 | - | |
182 | - debug("%s(%s)",__FUNCTION__,name); | |
183 | - | |
184 | - // Init packet size; | |
185 | - *szPacket = strlen(name) + 1 + (sizeof(guint16) * 2); | |
186 | - | |
187 | - debug("Packaging %u itens for \"%s\"", (unsigned int) count, name); | |
188 | - while ((child = g_variant_iter_next_value (&iter))) { | |
189 | - | |
190 | - // debug("type='%s' size=%u", g_variant_get_type_string(child), (unsigned int) g_variant_get_size(child)); | |
191 | - | |
192 | - *szPacket += (1+g_variant_get_size(child)); | |
193 | - | |
194 | - g_variant_unref(child); | |
195 | - ix++; | |
196 | - } | |
197 | - | |
198 | - // Allocate buffer | |
199 | - unsigned char * outputBuffer = g_malloc0(*szPacket); | |
200 | - unsigned char * txtptr = setup_header(outputBuffer,name,id,count); | |
201 | - | |
202 | - ix = 0; | |
203 | - g_variant_iter_init(&iter, values); | |
204 | - while ((child = g_variant_iter_next_value (&iter))) { | |
205 | - | |
206 | - debug("type='%s' size=%u index=%u", g_variant_get_type_string(child), (unsigned int) g_variant_get_size(child), (unsigned int) (txtptr - outputBuffer)); | |
207 | - | |
208 | - txtptr = pack_value(txtptr, child); | |
209 | - if(!txtptr) { | |
210 | - g_free(outputBuffer); | |
211 | - return NULL; | |
212 | - } | |
213 | - | |
214 | - g_variant_unref(child); | |
215 | - ix++; | |
216 | - } | |
217 | - | |
218 | - return outputBuffer; | |
219 | -} | |
220 | - | |
221 | -GVariant * ipc3270_unpack(const unsigned char *packet, int *id) { | |
222 | - | |
223 | - const unsigned char *txtptr; | |
224 | - size_t ix; | |
225 | - | |
226 | - // Skip packet name. | |
227 | - packet += strlen((const char *) packet)+1; | |
228 | - | |
229 | - // Get Packet ID or error code. | |
230 | - if(id) { | |
231 | - *id = (int) *((guint16 *) packet); | |
232 | - } | |
233 | - packet += sizeof(guint16); | |
234 | - | |
235 | - // Get argument count. | |
236 | - size_t arguments = (size_t) * ((guint16 *) packet); | |
237 | - packet += sizeof(guint16); | |
238 | - | |
239 | - debug("Unpacking package with %u itens", (unsigned int) arguments); | |
240 | - | |
241 | - // Scan for argument types. | |
242 | - g_autofree gchar * descrs = g_malloc0(arguments+3); | |
243 | - descrs[0] = '('; | |
244 | - descrs[arguments+1] = ')'; | |
245 | - | |
246 | - txtptr = packet; | |
247 | - for(ix = 0; ix < arguments; ix++) { | |
248 | - | |
249 | - debug("Format(%u): %c",(unsigned int) ix, *txtptr); | |
250 | - | |
251 | - descrs[ix+1] = *(txtptr++); | |
252 | - | |
253 | - switch(descrs[ix+1]) { | |
254 | - case 's': | |
255 | - txtptr += strlen((char *) txtptr)+1; | |
256 | - break; | |
257 | - | |
258 | - case 'b': // gboolean | |
259 | - case 'y': // guchar | |
260 | - txtptr++; | |
261 | - break; | |
262 | - | |
263 | - case 'n': // gint16 | |
264 | - txtptr += sizeof(gint16); | |
265 | - break; | |
266 | - | |
267 | - case 'q': // guint16 | |
268 | - txtptr += sizeof(guint16); | |
269 | - break; | |
270 | - | |
271 | - case 'i': // gint32 | |
272 | - case 'h': // gint32 | |
273 | - txtptr += sizeof(gint32); | |
274 | - break; | |
275 | - | |
276 | - case 'u': // guint32 | |
277 | - txtptr += sizeof(guint32); | |
278 | - break; | |
279 | - | |
280 | - case 'x': // gint64 | |
281 | - txtptr += sizeof(gint64); | |
282 | - break; | |
283 | - | |
284 | - case 't': // guint64 | |
285 | - txtptr += sizeof(guint64); | |
286 | - break; | |
287 | - | |
288 | - default: | |
289 | - errno = EINVAL; | |
290 | - return NULL; | |
291 | - } | |
292 | - } | |
293 | - | |
294 | - debug("Format: \"%s\"\n",descrs); | |
295 | - | |
296 | - GVariantBuilder builder; | |
297 | - g_variant_builder_init(&builder,G_VARIANT_TYPE(descrs)); | |
298 | - | |
299 | - txtptr = packet; | |
300 | - for(ix = 0; ix < arguments; ix++) { | |
301 | - | |
302 | - debug("Format(%u): %c",(unsigned int) ix, *txtptr); | |
303 | - txtptr++; | |
304 | - | |
305 | - switch(descrs[ix+1]) { | |
306 | - case 's': | |
307 | - g_variant_builder_add(&builder, "s", txtptr); | |
308 | - txtptr += strlen((char *) txtptr)+1; | |
309 | - break; | |
310 | - | |
311 | - case 'b': // gboolean | |
312 | - g_variant_builder_add(&builder, "b", *((gboolean *) txtptr)); | |
313 | - txtptr++; | |
314 | - break; | |
315 | - | |
316 | - case 'y': // guchar | |
317 | - g_variant_builder_add(&builder, "y", *((guchar *) txtptr)); | |
318 | - txtptr++; | |
319 | - break; | |
320 | - | |
321 | - case 'n': // gint16 | |
322 | - g_variant_builder_add(&builder, "n", *((gint16 *) txtptr)); | |
323 | - txtptr += sizeof(gint16); | |
324 | - break; | |
325 | - | |
326 | - case 'q': // guint16 | |
327 | - g_variant_builder_add(&builder, "q", *((guint16 *) txtptr)); | |
328 | - txtptr += sizeof(guint16); | |
329 | - break; | |
330 | - | |
331 | - case 'i': // gint32 | |
332 | - g_variant_builder_add(&builder, "i", *((gint32 *) txtptr)); | |
333 | - txtptr += sizeof(gint32); | |
334 | - break; | |
335 | - | |
336 | - case 'h': // gint32 | |
337 | - g_variant_builder_add(&builder, "h", *((gint32 *) txtptr)); | |
338 | - txtptr += sizeof(gint32); | |
339 | - break; | |
340 | - | |
341 | - case 'u': // guint32 | |
342 | - g_variant_builder_add(&builder, "u", *((guint32 *) txtptr)); | |
343 | - txtptr += sizeof(guint32); | |
344 | - break; | |
345 | - | |
346 | - case 'x': // gint64 | |
347 | - g_variant_builder_add(&builder, "x", *((gint64 *) txtptr)); | |
348 | - txtptr += sizeof(gint64); | |
349 | - break; | |
350 | - | |
351 | - case 't': // guint64 | |
352 | - g_variant_builder_add(&builder, "t", *((guint64 *) txtptr)); | |
353 | - txtptr += sizeof(guint64); | |
354 | - break; | |
355 | - | |
356 | - default: | |
357 | - errno = EINVAL; | |
358 | - return NULL; | |
359 | - } | |
360 | - } | |
361 | - | |
362 | - return g_variant_builder_end(&builder); | |
363 | - | |
364 | -} |
src/core/windows/pipesource.c
... | ... | @@ -1,279 +0,0 @@ |
1 | -/* | |
2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | - * | |
6 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | - * | |
8 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | - * Free Software Foundation. | |
11 | - * | |
12 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | - * obter mais detalhes. | |
16 | - * | |
17 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | - * | |
21 | - * Este programa está nomeado como pipesource.c e possui - linhas de código. | |
22 | - * | |
23 | - * Contatos: | |
24 | - * | |
25 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | - * | |
28 | - */ | |
29 | - | |
30 | -#include "gobject.h" | |
31 | -#include <lib3270/ipc-glib.h> | |
32 | -#include <lib3270/trace.h> | |
33 | - | |
34 | -void ipc3270_wait_for_client(IPC3270_PIPE_SOURCE *source) { | |
35 | - | |
36 | - if(ConnectNamedPipe(source->hPipe,&source->overlap)) { | |
37 | - g_message("Error %u in ConnectNamedPipe",(unsigned int) GetLastError()); | |
38 | - // popup_lasterror("%s",_( "Error in ConnectNamedPipe" )); | |
39 | - return; | |
40 | - } | |
41 | - | |
42 | - switch(GetLastError()) { | |
43 | - case ERROR_IO_PENDING: // The overlapped connection in progress. | |
44 | - source->state = PIPE_STATE_WAITING; | |
45 | - break; | |
46 | - | |
47 | - case ERROR_PIPE_CONNECTED: // Client is already connected, so signal an event. | |
48 | - source->state = PIPE_STATE_WAITING; | |
49 | - SetEvent(source->overlap.hEvent); | |
50 | - break; | |
51 | - | |
52 | - default: | |
53 | - g_message("Error %u in ConnectNamedPipe",(unsigned int) GetLastError()); | |
54 | - // popup_lasterror("%s", _( "ConnectNamedPipe failed" )); | |
55 | - } | |
56 | - | |
57 | -} | |
58 | - | |
59 | -static gboolean IO_prepare(GSource *source, gint *timeout) { | |
60 | - /* | |
61 | - * Called before all the file descriptors are polled. | |
62 | - * If the source can determine that it is ready here | |
63 | - * (without waiting for the results of the poll() call) | |
64 | - * it should return TRUE. | |
65 | - * | |
66 | - * It can also return a timeout_ value which should be the maximum | |
67 | - * timeout (in milliseconds) which should be passed to the poll() call. | |
68 | - * The actual timeout used will be -1 if all sources returned -1, | |
69 | - * or it will be the minimum of all the timeout_ values | |
70 | - * returned which were >= 0. | |
71 | - * | |
72 | - */ | |
73 | - if(WaitForSingleObject(((IPC3270_PIPE_SOURCE *) source)->overlap.hEvent,0) == WAIT_OBJECT_0) | |
74 | - return TRUE; | |
75 | - | |
76 | - *timeout = 10; | |
77 | - | |
78 | - return FALSE; | |
79 | - | |
80 | -} | |
81 | - | |
82 | -static gboolean IO_check(GSource *source) { | |
83 | - /* | |
84 | - * Called after all the file descriptors are polled. | |
85 | - * The source should return TRUE if it is ready to be dispatched. | |
86 | - * Note that some time may have passed since the previous prepare | |
87 | - * function was called, so the source should be checked again here. | |
88 | - * | |
89 | - */ | |
90 | - if(WaitForSingleObject(((IPC3270_PIPE_SOURCE *) source)->overlap.hEvent,0) == WAIT_OBJECT_0) | |
91 | - return TRUE; | |
92 | - | |
93 | - return FALSE; | |
94 | -} | |
95 | - | |
96 | -static void process_input(IPC3270_PIPE_SOURCE *source, DWORD cbRead) { | |
97 | - | |
98 | - const gchar * request_name = (const gchar *) (source->buffer); | |
99 | - H3270 * hSession = ipc3270_get_session(source->object); | |
100 | - int request_type = 0; | |
101 | - | |
102 | - if(lib3270_get_toggle(hSession,LIB3270_TOGGLE_EVENT_TRACE)) | |
103 | - lib3270_trace_data(hSession, "IPC Data block received on pipe", (const char *) source->buffer, (size_t) cbRead); | |
104 | - | |
105 | - debug("Received packet \"%s\" with %u bytes", request_name, (unsigned int) cbRead); | |
106 | - | |
107 | - g_autoptr (GError) error = NULL; | |
108 | - g_autoptr (GVariant) parameters = ipc3270_unpack(source->buffer, &request_type); | |
109 | - g_autoptr (GVariant) response = NULL; | |
110 | - | |
111 | - if(!parameters) { | |
112 | - g_message("Rejecting invalid request \"%s\"", request_name); | |
113 | - } | |
114 | - | |
115 | - // Process query | |
116 | - switch(request_type) { | |
117 | - case 1: // getProperty | |
118 | - response = ipc3270_get_property(source->object, request_name, &error); | |
119 | - break; | |
120 | - | |
121 | - case 2: // setProperty | |
122 | - ipc3270_set_property(source->object, request_name, parameters, &error); | |
123 | - break; | |
124 | - | |
125 | - case 3: // method | |
126 | - response = ipc3270_method_call(source->object, request_name, parameters, &error); | |
127 | - break; | |
128 | - | |
129 | - default: | |
130 | - g_message("Rejecting request \"%s\": Invalid type %d",request_name, request_type); | |
131 | - g_set_error(&error,IPC3270(source->object)->error_domain,EINVAL,"Invalid or unexpected type %d",request_type); | |
132 | - | |
133 | - } | |
134 | - | |
135 | - debug("response=%p",response); | |
136 | - | |
137 | - // Pack response | |
138 | - size_t szPacket = 0; | |
139 | - g_autofree unsigned char * buffer = NULL; | |
140 | - | |
141 | - if(error) { | |
142 | - | |
143 | - buffer = ipc3270_pack_error(error, &szPacket); | |
144 | - | |
145 | - } else { | |
146 | - | |
147 | - buffer = ipc3270_pack_value(request_name, 0, response, &szPacket); | |
148 | - | |
149 | - } | |
150 | - | |
151 | - // Send response | |
152 | - DWORD wrote = (DWORD) szPacket; | |
153 | - | |
154 | - if(lib3270_get_toggle(hSession,LIB3270_TOGGLE_EVENT_TRACE)) | |
155 | - lib3270_trace_data(hSession, "IPC Data block sent to pipe", (const char *) buffer, szPacket); | |
156 | - | |
157 | - WriteFile(source->hPipe,buffer,wrote,&wrote,NULL); | |
158 | - | |
159 | -} | |
160 | - | |
161 | -static void read_input_pipe(IPC3270_PIPE_SOURCE *source) { | |
162 | - | |
163 | - DWORD cbRead = 0; | |
164 | - | |
165 | - if(ReadFile(source->hPipe,source->buffer,PIPE_BUFFER_LENGTH,&cbRead,&source->overlap) && cbRead > 0) | |
166 | - process_input(source,cbRead); | |
167 | - | |
168 | - // The read operation is still pending. | |
169 | - switch(GetLastError()) | |
170 | - { | |
171 | - case 0: | |
172 | - break; | |
173 | - | |
174 | - case ERROR_IO_PENDING: | |
175 | - source->state = PIPE_STATE_PENDING_READ; | |
176 | - break; | |
177 | - | |
178 | - case ERROR_PIPE_LISTENING: | |
179 | - source->state = PIPE_STATE_READ; | |
180 | - break; | |
181 | - | |
182 | - case ERROR_BROKEN_PIPE: | |
183 | - | |
184 | - if(!DisconnectNamedPipe(source->hPipe)) { | |
185 | - | |
186 | - g_message("Error %u on DisconnectNamedPipe", (unsigned int) GetLastError()); | |
187 | - | |
188 | - } else { | |
189 | - | |
190 | - ipc3270_wait_for_client(source); | |
191 | - | |
192 | - } | |
193 | - break; | |
194 | - | |
195 | - case ERROR_PIPE_NOT_CONNECTED: | |
196 | - g_message("Cliente was disconnected"); | |
197 | - break; | |
198 | - | |
199 | - default: | |
200 | - if(source->hPipe != INVALID_HANDLE_VALUE) { | |
201 | - g_message( "Error %u receiving message from pipe", (unsigned int) GetLastError()); | |
202 | - } | |
203 | - } | |
204 | - | |
205 | -} | |
206 | - | |
207 | - | |
208 | -static gboolean IO_dispatch(GSource *source, GSourceFunc G_GNUC_UNUSED(callback), gpointer G_GNUC_UNUSED(data)) { | |
209 | - /* | |
210 | - * Called to dispatch the event source, | |
211 | - * after it has returned TRUE in either its prepare or its check function. | |
212 | - * The dispatch function is passed in a callback function and data. | |
213 | - * The callback function may be NULL if the source was never connected | |
214 | - * to a callback using g_source_set_callback(). The dispatch function | |
215 | - * should call the callback function with user_data and whatever additional | |
216 | - * parameters are needed for this type of event source. | |
217 | - */ | |
218 | - BOOL fSuccess; | |
219 | - DWORD cbRead = 0; | |
220 | - | |
221 | - fSuccess = GetOverlappedResult(((IPC3270_PIPE_SOURCE *) source)->hPipe,&((IPC3270_PIPE_SOURCE *) source)->overlap,&cbRead,FALSE ); | |
222 | - | |
223 | - switch(((IPC3270_PIPE_SOURCE *) source)->state) { | |
224 | - case PIPE_STATE_WAITING: | |
225 | - | |
226 | - if(fSuccess) { | |
227 | - | |
228 | - g_message("Client is connected"); | |
229 | - ((IPC3270_PIPE_SOURCE *) source)->state = PIPE_STATE_READ; | |
230 | - | |
231 | - } else { | |
232 | - | |
233 | - g_message("Pipe connection failed with rc=%u",(unsigned int) GetLastError()); | |
234 | - | |
235 | - } | |
236 | - break; | |
237 | - | |
238 | - case PIPE_STATE_READ: | |
239 | - // trace("Reading pipe (cbRead=%d)",(int) cbRead); | |
240 | - read_input_pipe( (IPC3270_PIPE_SOURCE *) source); | |
241 | - break; | |
242 | - | |
243 | - case PIPE_STATE_PENDING_READ: | |
244 | - if(fSuccess && cbRead > 0) | |
245 | - process_input((IPC3270_PIPE_SOURCE *) source,cbRead); | |
246 | - ((IPC3270_PIPE_SOURCE *) source)->state = PIPE_STATE_READ; | |
247 | - break; | |
248 | - | |
249 | - case PIPE_STATE_UNDEFINED: | |
250 | - break; | |
251 | - | |
252 | - } | |
253 | - | |
254 | - return TRUE; | |
255 | -} | |
256 | - | |
257 | -static gboolean IO_closure(gpointer G_GNUC_UNUSED(data)) { | |
258 | - return 0; | |
259 | -} | |
260 | - | |
261 | -static void IO_finalize(GSource *source) { | |
262 | - | |
263 | - debug("%s(%p)",__FUNCTION__,source); | |
264 | - | |
265 | - if( ((IPC3270_PIPE_SOURCE *) source)->hPipe != INVALID_HANDLE_VALUE) { | |
266 | - CloseHandle(((IPC3270_PIPE_SOURCE *) source)->hPipe); | |
267 | - ((IPC3270_PIPE_SOURCE *) source)->hPipe = INVALID_HANDLE_VALUE; | |
268 | - } | |
269 | - | |
270 | -} | |
271 | - | |
272 | -GSourceFuncs ipc3270_source_funcs = { | |
273 | - IO_prepare, | |
274 | - IO_check, | |
275 | - IO_dispatch, | |
276 | - IO_finalize, | |
277 | - IO_closure, | |
278 | - NULL | |
279 | -}; |
src/core/windows/start.c
... | ... | @@ -1,91 +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 - e possui - linhas de código. | |
22 | - * | |
23 | - * Contatos: | |
24 | - * | |
25 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | - * | |
28 | - */ | |
29 | - | |
30 | -#include "gobject.h" | |
31 | -#include <lib3270.h> | |
32 | -#include <lib3270/actions.h> | |
33 | -#include <lib3270/properties.h> | |
34 | -#include <lib3270/ipc-glib.h> | |
35 | - | |
36 | -void ipc3270_export_object(GObject *object, const char *name, GError G_GNUC_UNUSED(**error)) { | |
37 | - | |
38 | - char id; | |
39 | - | |
40 | - debug("%s object=%p name=%s type=%p",__FUNCTION__,object,name,ipc3270_get_type()); | |
41 | - | |
42 | - ipc3270 * ipc = IPC3270(object); | |
43 | - | |
44 | - for(id='A';id < 'Z';id++) { | |
45 | - | |
46 | - gchar * pipename = g_strdup_printf(PW3270_IPC_SESSION_BUS_NAME,name,id); | |
47 | - gchar * ptr; | |
48 | - HANDLE hPipe; | |
49 | - | |
50 | - for(ptr=pipename;*ptr;ptr++) | |
51 | - *ptr = g_ascii_tolower(*ptr); | |
52 | - | |
53 | - hPipe = CreateNamedPipe( TEXT(pipename), // pipe name | |
54 | - PIPE_ACCESS_DUPLEX | // read/write access | |
55 | - FILE_FLAG_OVERLAPPED, // overlapped mode | |
56 | - PIPE_TYPE_MESSAGE | // pipe type | |
57 | - PIPE_READMODE_MESSAGE | // pipe mode | |
58 | - PIPE_WAIT, // blocking mode | |
59 | - 1, // number of instances | |
60 | - PIPE_BUFFER_LENGTH, // output buffer size | |
61 | - PIPE_BUFFER_LENGTH, // input buffer size | |
62 | - NMPWAIT_USE_DEFAULT_WAIT, // client time-out | |
63 | - NULL); // default security attributes | |
64 | - | |
65 | - debug("%s = %p",pipename,hPipe); | |
66 | - g_free(pipename); | |
67 | - | |
68 | - if(hPipe != INVALID_HANDLE_VALUE) { | |
69 | - | |
70 | - ipc->source = (IPC3270_PIPE_SOURCE *) g_source_new(&ipc3270_source_funcs,sizeof(IPC3270_PIPE_SOURCE)); | |
71 | - | |
72 | - g_message("Got session \"%c\"",id); | |
73 | - | |
74 | - lib3270_set_session_id(ipc->hSession, id); | |
75 | - | |
76 | - ipc->source->hPipe = hPipe; | |
77 | - ipc->source->object = object; | |
78 | - ipc->source->state = PIPE_STATE_WAITING; | |
79 | - ipc->source->overlap.hEvent = CreateEvent( NULL,TRUE,TRUE,NULL); | |
80 | - | |
81 | - g_source_attach((GSource *) ipc->source,NULL); | |
82 | - | |
83 | - // IO_accept(source); | |
84 | - ipc3270_wait_for_client(ipc->source); | |
85 | - | |
86 | - break; | |
87 | - } | |
88 | - | |
89 | - } | |
90 | - | |
91 | -} |
src/core/windows/stop.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 - e possui - linhas de código. | |
22 | - * | |
23 | - * Referências: | |
24 | - * | |
25 | - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | - * | |
28 | - * Contatos: | |
29 | - * | |
30 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | - * | |
33 | - */ | |
34 | - | |
35 | -#include "gobject.h" | |
36 | -#include <lib3270.h> | |
37 | -#include <lib3270/ipc-glib.h> | |
38 | - | |
39 | -void ipc3270_release_object(ipc3270 *object) { | |
40 | - | |
41 | - if(object->source) | |
42 | - { | |
43 | - g_source_destroy((GSource *) object->source); | |
44 | - object->source = NULL; | |
45 | - } | |
46 | - | |
47 | -} |
src/include/config.h.in
... | ... | @@ -1,41 +0,0 @@ |
1 | -/* | |
2 | - * "Software G3270, 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 config.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 de Mendonça) | |
27 | - * | |
28 | - */ | |
29 | - | |
30 | -#ifndef LIBV3270_CONFIG_INCLUDED | |
31 | - | |
32 | - #define LIBV3270_CONFIG_INCLUDED 1 | |
33 | - | |
34 | - #undef PACKAGE_NAME | |
35 | - #undef PACKAGE_VERSION | |
36 | - #undef PACKAGE_RELEASE | |
37 | - | |
38 | - #undef HAVE_GNOME | |
39 | - #undef HAVE_GTKMAC | |
40 | - | |
41 | -#endif /* LIBV3270_CONFIG_INCLUDED */ |
src/include/lib3270/ipc-glib.h
... | ... | @@ -1,121 +0,0 @@ |
1 | -/* | |
2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob | |
5 | - * o nome G3270. | |
6 | - * | |
7 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
8 | - * | |
9 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
10 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
11 | - * Free Software Foundation. | |
12 | - * | |
13 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
14 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
15 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
16 | - * obter mais detalhes. | |
17 | - * | |
18 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
19 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
20 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | - * | |
22 | - * Este programa está nomeado como - e possui - linhas de código. | |
23 | - * | |
24 | - * Contatos: | |
25 | - * | |
26 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
27 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
28 | - * | |
29 | - */ | |
30 | - | |
31 | - /** | |
32 | - * @brief Common definitions for pw3270 IPC plugin. | |
33 | - * | |
34 | - * @author Perry Werneck <perry.werneck@gmail.com> | |
35 | - * | |
36 | - */ | |
37 | - | |
38 | -#ifndef PW3270_IPC_H_INCLUDED | |
39 | - | |
40 | - #define PW3270_IPC_H_INCLUDED | |
41 | - | |
42 | - #ifdef _WIN32 | |
43 | - | |
44 | - #define PW3270_IPC_SESSION_BUS_NAME "\\\\.\\pipe\\%s\\%c" | |
45 | - | |
46 | - #else | |
47 | - | |
48 | - #define PW3270_IPC_SESSION_BUS_NAME "br.com.bb.%s.%c" | |
49 | - #define PW3270_IPC_SESSION_INTERFACE_NAME "br.com.bb.tn3270.session" | |
50 | - #define PW3270_IPC_SESSION_OBJECT_PATH "/br/com/bb/tn3270/session" | |
51 | - | |
52 | - #define PW3270_IPC_SERVICE_BUS_NAME "br.com.bb.tn3270.service" | |
53 | - #define PW3270_IPC_SERVICE_INTERFACE_NAME "br.com.bb.tn3270.service" | |
54 | - #define PW3270_IPC_SERVICE_OBJECT_PATH "/br/com/bb/tn3270/service" | |
55 | - | |
56 | - #endif // _WIN32 | |
57 | - | |
58 | - #include <glib.h> | |
59 | - #include <gtk/gtk.h> | |
60 | - #include <lib3270.h> | |
61 | - | |
62 | - G_BEGIN_DECLS | |
63 | - | |
64 | - #define GLIB_TYPE_IPC3270 (ipc3270_get_type ()) | |
65 | - #define IPC3270(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLIB_TYPE_IPC3270, ipc3270)) | |
66 | - #define IPC3270_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLIB_TYPE_IPC3270, ipc3270Class)) | |
67 | - #define IS_IPC3270(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLIB_TYPE_IPC3270)) | |
68 | - #define IS_IPC3270_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLIB_TYPE_IPC3270)) | |
69 | - #define IPC3270_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLIB_TYPE_IPC3270, ipc3270Class)) | |
70 | - | |
71 | - typedef struct _ipc3270 ipc3270; | |
72 | - typedef struct _ipc3270Class ipc3270Class; | |
73 | - | |
74 | - GObject * ipc3270_new(); | |
75 | - GType ipc3270_get_type(void); | |
76 | - void ipc3270_set_session(GObject *object, H3270 *hSession); | |
77 | - void ipc3270_export_object(GObject *object, const char *name, GError **error); | |
78 | - | |
79 | - gchar * ipc3270_convert_output_string(GObject *object, const gchar *string, GError **error); | |
80 | - gchar * ipc3270_convert_input_string(GObject *object, const gchar *string, GError **error); | |
81 | - GVariant * ipc3270_GVariant_from_input_string(GObject *object, char *string, GError **error); | |
82 | - | |
83 | - void ipc3270_add_terminal_introspection(GString *string); | |
84 | - | |
85 | - const gchar * ipc3270_get_display_charset(GObject *object); | |
86 | - H3270 * ipc3270_get_session(GObject *object); | |
87 | - | |
88 | - void ipc3270_set_error(GObject *object, int errcode, GError **error); | |
89 | - | |
90 | - GVariant * ipc3270_method_call(GObject *object, const gchar *method_name, GVariant *parameters, GError **error); | |
91 | - gboolean ipc3270_set_property(GObject *object, const gchar *property_name, GVariant *value, GError **error); | |
92 | - GVariant * ipc3270_get_property(GObject *object, const gchar *property_name, GError **error); | |
93 | - | |
94 | - #ifdef _WIN32 | |
95 | - unsigned char * ipc3270_pack(const gchar *name, int id, GVariant *values, size_t * szPacket); | |
96 | - unsigned char * ipc3270_pack_value(const gchar *name, int id, GVariant *value, size_t * szPacket); | |
97 | - unsigned char * ipc3270_pack_error(const GError *error, size_t * szPacket); | |
98 | - GVariant * ipc3270_unpack(const unsigned char *packet, int *id); | |
99 | - #endif // _WIN32 | |
100 | - | |
101 | - G_END_DECLS | |
102 | - | |
103 | - #if ! GLIB_CHECK_VERSION(2,44,0) | |
104 | - G_GNUC_INTERNAL void ipc3270_autoptr_cleanup_generic_gfree(void *p); | |
105 | - #define g_autofree __attribute__((cleanup(ipc3270_autoptr_cleanup_generic_gfree))) | |
106 | - #endif // ! GLIB(2,44,0) | |
107 | - | |
108 | - #ifdef DEBUG | |
109 | - #define debug( fmt, ... ) fprintf(stderr,"%s(%d) " fmt "\n", __FILE__, (int) __LINE__, __VA_ARGS__ ); fflush(stderr); | |
110 | - #else | |
111 | - #define debug(...) /* __VA_ARGS */ | |
112 | - #endif | |
113 | - | |
114 | - typedef struct _ipc_method_int_arg { | |
115 | - const gchar *name; | |
116 | - int (*call)(H3270 *hSession, int keycode); | |
117 | - } IPC_METHOD_INT_ARG; | |
118 | - | |
119 | - const IPC_METHOD_INT_ARG * ipc3270_get_int_arg_methods(); | |
120 | - | |
121 | -#endif // PW3270_IPC_H_INCLUDED |
src/plugin/plugin.c
... | ... | @@ -1,97 +0,0 @@ |
1 | -/* | |
2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob | |
5 | - * o nome G3270. | |
6 | - * | |
7 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
8 | - * | |
9 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
10 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
11 | - * Free Software Foundation. | |
12 | - * | |
13 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
14 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
15 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
16 | - * obter mais detalhes. | |
17 | - * | |
18 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
19 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
20 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | - * | |
22 | - * Este programa está nomeado como - e possui - linhas de código. | |
23 | - * | |
24 | - * Contatos: | |
25 | - * | |
26 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
27 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
28 | - * | |
29 | - */ | |
30 | - | |
31 | - | |
32 | - /** | |
33 | - * @brief IPC Plugin startup/stop. | |
34 | - * | |
35 | - */ | |
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" | |
45 | - #include <v3270.h> | |
46 | - #include <lib3270/ipc-glib.h> | |
47 | - | |
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 | - } | |
53 | - | |
54 | - int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal) { | |
55 | - | |
56 | - // Creates IPC, associate it with the terminal window | |
57 | - GObject * ipc = ipc3270_new(); | |
58 | - g_object_set_data_full(G_OBJECT(terminal), "ipc-object-info", ipc, g_object_unref); | |
59 | - | |
60 | - debug("Name: \"%s\"",gtk_widget_get_name(window)); | |
61 | - | |
62 | - // Set session handle, this starts the IPC communication. | |
63 | - GError * error = NULL; | |
64 | - | |
65 | - ipc3270_set_session(ipc,v3270_get_session(terminal)); | |
66 | - ipc3270_export_object(ipc,gtk_widget_get_name(window),&error); | |
67 | - | |
68 | - if(error) { | |
69 | - | |
70 | - GtkWidget *dialog = gtk_message_dialog_new( | |
71 | - GTK_WINDOW(window), | |
72 | - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
73 | - GTK_MESSAGE_ERROR, | |
74 | - GTK_BUTTONS_OK, | |
75 | - _( "Can't start IPC Module" )); | |
76 | - | |
77 | - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); | |
78 | - g_error_free(error); | |
79 | - | |
80 | - gtk_dialog_run(GTK_DIALOG(dialog)); | |
81 | - gtk_widget_destroy(dialog); | |
82 | - return 0; | |
83 | - | |
84 | - } | |
85 | - | |
86 | - char id = lib3270_get_session_id(v3270_get_session(terminal)); | |
87 | - if(id) { | |
88 | - gchar * widget_name = g_strdup_printf("%s:%c",gtk_widget_get_name(window),id); | |
89 | - v3270_set_session_name(terminal, widget_name); | |
90 | - g_free(widget_name); | |
91 | - } | |
92 | - | |
93 | - return 0; | |
94 | - } | |
95 | - | |
96 | - | |
97 | - |
src/plugin/private.h
... | ... | @@ -1,52 +0,0 @@ |
1 | -/* | |
2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob | |
5 | - * o nome G3270. | |
6 | - * | |
7 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
8 | - * | |
9 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
10 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
11 | - * Free Software Foundation. | |
12 | - * | |
13 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
14 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
15 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
16 | - * obter mais detalhes. | |
17 | - * | |
18 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
19 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
20 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | - * | |
22 | - * Este programa está nomeado como - e possui - linhas de código. | |
23 | - * | |
24 | - * Contatos: | |
25 | - * | |
26 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
27 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
28 | - * | |
29 | - */ | |
30 | - | |
31 | - /** | |
32 | - * @brief Common definitions for pw3270 IPC plugin. | |
33 | - * | |
34 | - */ | |
35 | - | |
36 | -#ifndef PRIVATE_H_INCLUDED | |
37 | - | |
38 | - #define PRIVATE_H_INCLUDED | |
39 | - | |
40 | - #include <config.h> | |
41 | - #include <lib3270/ipc-glib.h> | |
42 | - | |
43 | - int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal); | |
44 | - int pw3270_plugin_stop(GtkWidget *window, GtkWidget *terminal); | |
45 | - | |
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 | |
51 | - | |
52 | -#endif // PRIVATE_H_INCLUDED |
src/plugin/windows/resources.rc.in
... | ... | @@ -1,29 +0,0 @@ |
1 | -#include <windows.h> | |
2 | - | |
3 | -VS_VERSION_INFO VERSIONINFO | |
4 | -FILEVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0 | |
5 | -PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0 | |
6 | - | |
7 | -BEGIN | |
8 | - | |
9 | - BLOCK "StringFileInfo" | |
10 | - BEGIN | |
11 | - BLOCK "080904E4" | |
12 | - BEGIN | |
13 | - VALUE "FileDescription", "@PACKAGE_NAME@ IPC Plugin\0" | |
14 | - VALUE "CompanyName", "Banco do Brasil S/A.\0" | |
15 | - VALUE "FileVersion", "@WIN32_VERSION@\0" | |
16 | - VALUE "LegalCopyright", "(C) 2017 Banco do Brasil S/A. All Rights Reserved\0" | |
17 | - VALUE "OriginalFilename", "ipc3270@DLLEXT@\0" | |
18 | - VALUE "ProductName", "@PACKAGE_NAME@\0" | |
19 | - VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.0\0" | |
20 | - END | |
21 | - END | |
22 | - | |
23 | - BLOCK "VarFileInfo" | |
24 | - BEGIN | |
25 | - VALUE "Translation", 0x809, 0x04E4 | |
26 | - END | |
27 | - | |
28 | -END | |
29 | - |
src/service/getproperties.c
... | ... | @@ -1,61 +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 getproperties.c e possui - linhas de código. | |
22 | - * | |
23 | - * Referências: | |
24 | - * | |
25 | - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | - * | |
28 | - * Contatos: | |
29 | - * | |
30 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | - * | |
33 | - */ | |
34 | - | |
35 | -#include <config.h> | |
36 | -#include "private.h" | |
37 | -#include <lib3270/ipc-glib.h> | |
38 | -#include <lib3270.h> | |
39 | -#include <lib3270/properties.h> | |
40 | - | |
41 | -GVariant * service_get_property(const gchar *property_name, GError **error) { | |
42 | - | |
43 | - debug("%s(%s)",__FUNCTION__,property_name); | |
44 | - | |
45 | - if(!g_ascii_strcasecmp(property_name,"version")) { | |
46 | - return g_variant_new_string(PACKAGE_VERSION); | |
47 | - } else if(!g_ascii_strcasecmp(property_name,"release")) { | |
48 | - return g_variant_new_string(G_STRINGIFY(PACKAGE_RELEASE)); | |
49 | - } | |
50 | - | |
51 | - | |
52 | - g_set_error (error, | |
53 | - G_IO_ERROR, | |
54 | - G_IO_ERROR_NOT_FOUND, | |
55 | - "Can't find any property named %s", property_name | |
56 | - ); | |
57 | - | |
58 | - return NULL; | |
59 | - | |
60 | -} | |
61 | - |
src/service/linux/start.c
... | ... | @@ -1,186 +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 start.c e possui - linhas de código. | |
22 | - * | |
23 | - * Referências: | |
24 | - * | |
25 | - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | - * | |
28 | - * Contatos: | |
29 | - * | |
30 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | - * | |
32 | - */ | |
33 | - | |
34 | -#include <config.h> | |
35 | -#include <lib3270/ipc-glib.h> | |
36 | -#include "../private.h" | |
37 | - | |
38 | -static GDBusNodeInfo *introspection_data = NULL; | |
39 | -static guint owner_id = 0; | |
40 | -static gchar * introspection_xml = NULL; | |
41 | - | |
42 | -static void | |
43 | - method_call ( | |
44 | - G_GNUC_UNUSED GDBusConnection *connection, | |
45 | - G_GNUC_UNUSED const gchar *sender, | |
46 | - G_GNUC_UNUSED const gchar *object_path, | |
47 | - G_GNUC_UNUSED const gchar *interface_name, | |
48 | - const gchar *method_name, | |
49 | - GVariant *parameters, | |
50 | - GDBusMethodInvocation *invocation, | |
51 | - gpointer user_data) { | |
52 | - | |
53 | - g_autoptr (GError) error = NULL; | |
54 | - | |
55 | - debug("%s(%s)",__FUNCTION__,object_path); | |
56 | - | |
57 | - GVariant * rc = service_method_call(method_name, parameters, &error); | |
58 | - | |
59 | - if(error) { | |
60 | - | |
61 | - if(rc) { | |
62 | - g_variant_unref(rc); | |
63 | - } | |
64 | - | |
65 | - g_dbus_method_invocation_return_gerror(invocation, error); | |
66 | - | |
67 | - } else if(rc) { | |
68 | - | |
69 | - g_dbus_method_invocation_return_value(invocation, rc); | |
70 | - | |
71 | - } else { | |
72 | - | |
73 | - g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Invalid or unexpected method call"); | |
74 | - | |
75 | - } | |
76 | - | |
77 | - | |
78 | -} | |
79 | - | |
80 | -static GVariant * | |
81 | - get_property ( | |
82 | - G_GNUC_UNUSED GDBusConnection *connection, | |
83 | - G_GNUC_UNUSED const gchar *sender, | |
84 | - G_GNUC_UNUSED const gchar *object_path, | |
85 | - G_GNUC_UNUSED const gchar *interface_name, | |
86 | - const gchar *property_name, | |
87 | - GError **error, | |
88 | - gpointer user_data) | |
89 | -{ | |
90 | - | |
91 | - debug("%s(%s)",__FUNCTION__,object_path); | |
92 | - return service_get_property(property_name, error); | |
93 | - | |
94 | -} | |
95 | - | |
96 | -static gboolean | |
97 | - set_property ( | |
98 | - G_GNUC_UNUSED GDBusConnection *connection, | |
99 | - G_GNUC_UNUSED const gchar *sender, | |
100 | - G_GNUC_UNUSED const gchar *object_path, | |
101 | - G_GNUC_UNUSED const gchar *interface_name, | |
102 | - const gchar *property_name, | |
103 | - GVariant *value, | |
104 | - GError **error, | |
105 | - gpointer user_data) | |
106 | -{ | |
107 | - | |
108 | - debug("%s(%s)",__FUNCTION__,object_path); | |
109 | - return service_set_property(property_name, value, error); | |
110 | - | |
111 | -} | |
112 | - | |
113 | - | |
114 | -static void on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) { | |
115 | - | |
116 | - static const GDBusInterfaceVTable interface_vtable = { | |
117 | - method_call, | |
118 | - get_property, | |
119 | - set_property | |
120 | - }; | |
121 | - | |
122 | - guint registration_id; | |
123 | - | |
124 | - g_message("Registering object %s",PW3270_IPC_SERVICE_OBJECT_PATH); | |
125 | - | |
126 | - registration_id = g_dbus_connection_register_object (connection, | |
127 | - PW3270_IPC_SERVICE_OBJECT_PATH, | |
128 | - introspection_data->interfaces[0], | |
129 | - &interface_vtable, | |
130 | - NULL, /* user_data */ | |
131 | - NULL, /* user_data_free_func */ | |
132 | - NULL); /* GError** */ | |
133 | - g_assert (registration_id > 0); | |
134 | - | |
135 | -} | |
136 | - | |
137 | -static void on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) { | |
138 | - | |
139 | - g_message("Acquired %s",name); | |
140 | - | |
141 | -} | |
142 | - | |
143 | -static void on_name_lost (GDBusConnection *connection, const gchar *name, gpointer user_data) { | |
144 | - g_message("Lost %s",name); | |
145 | - g_main_loop_quit(NULL); | |
146 | -} | |
147 | - | |
148 | -void service_start(void) { | |
149 | - | |
150 | - GString * introspection = g_string_new("<node>\n"); | |
151 | - | |
152 | - g_string_append(introspection, | |
153 | - " <interface name='" PW3270_IPC_SERVICE_INTERFACE_NAME "'>" | |
154 | - " <method name='createSession'>" | |
155 | - " <arg type='s' name='id' direction='out' />" | |
156 | - " </method>" | |
157 | - " <method name='destroySession'>" | |
158 | - " <arg type='s' name='id' direction='in' />" | |
159 | - " <arg type='i' name='rc' direction='out' />" | |
160 | - " </method>" | |
161 | - " <property type='s' name='version' access='read'/>" | |
162 | - " <property type='s' name='release' access='read'/>" | |
163 | - ); | |
164 | - | |
165 | - ipc3270_add_terminal_introspection(introspection); | |
166 | - | |
167 | - g_string_append(introspection,"</interface></node>\n"); | |
168 | - | |
169 | - introspection_xml = g_string_free(introspection,FALSE); | |
170 | - | |
171 | - debug("\n\n%s\n\n",introspection_xml); | |
172 | - | |
173 | - introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL); | |
174 | - | |
175 | - owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, | |
176 | - PW3270_IPC_SERVICE_BUS_NAME, | |
177 | - G_BUS_NAME_OWNER_FLAGS_NONE, | |
178 | - on_bus_acquired, | |
179 | - on_name_acquired, | |
180 | - on_name_lost, | |
181 | - NULL, | |
182 | - NULL); | |
183 | - | |
184 | - | |
185 | -} | |
186 | - |
src/service/methods.c
... | ... | @@ -1,53 +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 methods.c e possui - linhas de código. | |
22 | - * | |
23 | - * Referências: | |
24 | - * | |
25 | - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | - * | |
28 | - * Contatos: | |
29 | - * | |
30 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | - * | |
33 | - */ | |
34 | - | |
35 | -#include <config.h> | |
36 | -#include "private.h" | |
37 | -#include <string.h> | |
38 | -#include <lib3270/ipc-glib.h> | |
39 | -#include <lib3270.h> | |
40 | -#include <lib3270/actions.h> | |
41 | - | |
42 | -GVariant * service_method_call(const gchar *method_name, GVariant *parameters, GError **error) { | |
43 | - | |
44 | - debug("%s(%s)",__FUNCTION__,method_name); | |
45 | - | |
46 | - g_set_error (error, | |
47 | - G_IO_ERROR, | |
48 | - G_IO_ERROR_NOT_FOUND, | |
49 | - "Can't find any method named %s", method_name | |
50 | - ); | |
51 | - | |
52 | - return NULL; | |
53 | -} |
src/service/private.h
... | ... | @@ -1,59 +0,0 @@ |
1 | -/* | |
2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | - * | |
6 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | - * | |
8 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | - * Free Software Foundation. | |
11 | - * | |
12 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | - * obter mais detalhes. | |
16 | - * | |
17 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | - * | |
21 | - * Este programa está nomeado como private.h e possui - linhas de código. | |
22 | - * | |
23 | - * Contatos: | |
24 | - * | |
25 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | - * | |
27 | - */ | |
28 | - | |
29 | -#ifndef PRIVATE_H_INCLUDED | |
30 | - | |
31 | - #define PRIVATE_H_INCLUDED | |
32 | - #include <config.h> | |
33 | - | |
34 | - #define ERROR_DOMAIN g_quark_from_static_string(PACKAGE_NAME) | |
35 | - | |
36 | - #include <glib.h> | |
37 | - #include <gio/gio.h> | |
38 | - #include <lib3270.h> | |
39 | - | |
40 | - G_BEGIN_DECLS | |
41 | - | |
42 | - #define GLIB_TYPE_SESSION (session_get_type ()) | |
43 | - #define SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLIB_TYPE_SESSION, session)) | |
44 | - #define SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLIB_TYPE_SESSION, sessionClass)) | |
45 | - #define IS_SESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLIB_TYPE_SESSION)) | |
46 | - #define IS_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLIB_TYPE_SESSION)) | |
47 | - #define SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLIB_TYPE_SESSION, sessionClass)) | |
48 | - | |
49 | - typedef struct _session session; | |
50 | - typedef struct _sessionClass sessionClass; | |
51 | - | |
52 | - G_GNUC_INTERNAL void service_start(void); | |
53 | - G_GNUC_INTERNAL GVariant * service_method_call(const gchar *method_name, GVariant *parameters, GError **error); | |
54 | - G_GNUC_INTERNAL GVariant * service_get_property(const gchar *property_name, GError **error); | |
55 | - G_GNUC_INTERNAL gboolean service_set_property(const gchar *property_name, GVariant *value, GError **error); | |
56 | - | |
57 | - G_END_DECLS | |
58 | - | |
59 | -#endif // PRIVATE_H_INCLUDED |
src/service/service.c
... | ... | @@ -1,186 +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.c e possui - linhas de código. | |
22 | - * | |
23 | - * Contatos: | |
24 | - * | |
25 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | - * | |
27 | - */ | |
28 | - | |
29 | -#include "private.h" | |
30 | -#include <errno.h> | |
31 | -#include <string.h> | |
32 | -#include <stdlib.h> | |
33 | -#include <lib3270/ipc-glib.h> | |
34 | - | |
35 | -#ifndef _WIN32 | |
36 | - #include <signal.h> | |
37 | -#endif // !_WIN32 | |
38 | - | |
39 | -GMainLoop * main_loop = NULL; | |
40 | - | |
41 | -#ifdef DEBUG | |
42 | - static gchar * pidfile = PACKAGE_NAME ".pid"; | |
43 | -#else | |
44 | - static gchar * pidfile = "/var/run/" PACKAGE_NAME ".pid"; | |
45 | -#endif // DEBUG | |
46 | - | |
47 | -#ifndef _WIN32 | |
48 | -static void on_sigterm(int signal) { | |
49 | - g_message("Stopping by termination request\n"); | |
50 | - g_main_loop_quit(main_loop); | |
51 | -} | |
52 | -#endif // !_WIN32 | |
53 | - | |
54 | -#if defined( HAVE_SYSLOG ) | |
55 | -static void g_syslog(const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,gpointer user_data) | |
56 | -{ | |
57 | - static const struct _logtype | |
58 | - { | |
59 | - GLogLevelFlags log_level; | |
60 | - int priority; | |
61 | - const gchar * msg; | |
62 | - } logtype[] = | |
63 | - { | |
64 | - { G_LOG_FLAG_RECURSION, LOG_INFO, "recursion" }, | |
65 | - { G_LOG_FLAG_FATAL, LOG_ERR, "fatal error" }, | |
66 | - | |
67 | - /* GLib log levels */ | |
68 | - { G_LOG_LEVEL_ERROR, LOG_ERR, "error" }, | |
69 | - { G_LOG_LEVEL_CRITICAL, LOG_ERR, "critical error" }, | |
70 | - { G_LOG_LEVEL_WARNING, LOG_ERR, "warning" }, | |
71 | - { G_LOG_LEVEL_MESSAGE, LOG_ERR, "message" }, | |
72 | - { G_LOG_LEVEL_INFO, LOG_INFO, "info" }, | |
73 | - { G_LOG_LEVEL_DEBUG, LOG_DEBUG, "debug" }, | |
74 | - }; | |
75 | - | |
76 | - int f; | |
77 | - | |
78 | - for(f=0;f<G_N_ELEMENTS(logtype);f++) | |
79 | - { | |
80 | - if(logtype[f].log_level == log_level) | |
81 | - { | |
82 | - gchar *ptr; | |
83 | - gchar *text = g_strdup_printf("%s: %s %s",logtype[f].msg,log_domain ? log_domain : "",message); | |
84 | - for(ptr = text;*ptr;ptr++) | |
85 | - { | |
86 | - if(*ptr < ' ') | |
87 | - *ptr = ' '; | |
88 | - } | |
89 | - | |
90 | -#ifdef DEBUG | |
91 | - printf("%s\n",text); | |
92 | - fflush(stdout); | |
93 | -#endif // DEBUG | |
94 | - | |
95 | - syslog(logtype[f].priority,"%s",text); | |
96 | - g_free(text); | |
97 | - return; | |
98 | - } | |
99 | - } | |
100 | - | |
101 | - #ifdef DEBUG | |
102 | - printf("%s\n",message); | |
103 | - fflush(stdout); | |
104 | - #endif // DEBUG | |
105 | - | |
106 | - syslog(LOG_INFO,"%s %s",log_domain ? log_domain : "", message); | |
107 | -} | |
108 | -#endif // HAVE_SYSLOG | |
109 | - | |
110 | -static gboolean do_idle_check(G_GNUC_UNUSED gpointer dunno) { | |
111 | - | |
112 | - return TRUE; | |
113 | -} | |
114 | - | |
115 | -static void cleanup() { | |
116 | - | |
117 | - if(pidfile) { | |
118 | - remove(pidfile); | |
119 | - } | |
120 | - | |
121 | -} | |
122 | - | |
123 | -int main(int argc, char *argv[]) { | |
124 | - | |
125 | - static gboolean asDaemon = FALSE; | |
126 | - | |
127 | -#if defined( HAVE_SYSLOG ) | |
128 | - openlog(g_get_prgname(), LOG_NDELAY, LOG_USER); | |
129 | - g_log_set_default_handler(g_syslog,NULL); | |
130 | -#endif // HAVE_SYSLOG | |
131 | - | |
132 | - // Verifica argumentos | |
133 | - static const GOptionEntry app_options[] = { | |
134 | - { "pidfile", 'p', 0, G_OPTION_ARG_STRING, &pidfile, "Path to pidfile" , NULL }, | |
135 | -#ifndef _WIN32 | |
136 | - { "daemon", 'd', 0, G_OPTION_ARG_NONE, &asDaemon, "Run as daemon", NULL }, | |
137 | -#endif // !_WIN32 | |
138 | - { NULL } | |
139 | - }; | |
140 | - | |
141 | - GOptionContext * context = g_option_context_new (PACKAGE_NAME " IPC service daemon"); | |
142 | - GError * error = NULL; | |
143 | - GOptionGroup * group = g_option_group_new( PACKAGE_NAME, NULL, NULL, NULL, NULL); | |
144 | - | |
145 | - g_option_context_set_main_group(context, group); | |
146 | - g_option_context_add_main_entries(context, app_options, NULL); | |
147 | - if(!g_option_context_parse( context, &argc, &argv, &error )) { | |
148 | - fprintf(stderr,"%s\n",error->message); | |
149 | - return -1; | |
150 | - } | |
151 | - | |
152 | - atexit(cleanup); | |
153 | - | |
154 | - if(pidfile) { | |
155 | - FILE * hpid = fopen(pidfile,"w"); | |
156 | - if(hpid) { | |
157 | - fprintf(hpid,"%u",(unsigned int) getpid()); | |
158 | - fclose(hpid); | |
159 | - } | |
160 | - } | |
161 | - | |
162 | - service_start(); | |
163 | - | |
164 | - g_print("%s starts\n",argv[0]); | |
165 | - | |
166 | - main_loop = g_main_loop_new(NULL, FALSE); | |
167 | - | |
168 | -#ifndef _WIN32 | |
169 | - | |
170 | - if(asDaemon && daemon(0,0)) { | |
171 | - g_print("%s can't start: %s\n",argv[0],strerror(errno)); | |
172 | - return -1; | |
173 | - } | |
174 | - | |
175 | - signal(SIGTERM,on_sigterm); | |
176 | - signal(SIGINT,on_sigterm); | |
177 | - | |
178 | -#endif // !_WIN32 | |
179 | - | |
180 | - g_main_loop_run(main_loop); | |
181 | - | |
182 | - g_print("%s ends\n",argv[0]); | |
183 | - | |
184 | - return 0; | |
185 | -} | |
186 | - |
src/service/session.c
... | ... | @@ -1,85 +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 - e possui - linhas de código. | |
22 | - * | |
23 | - * Contatos: | |
24 | - * | |
25 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | - * | |
28 | - */ | |
29 | - | |
30 | -#include "private.h" | |
31 | -#include <lib3270/ipc-glib.h> | |
32 | - | |
33 | -struct _session { | |
34 | - GObject parent; | |
35 | - time_t activity; ///< @brief Timestamp da última atividade dessa sessão. | |
36 | - time_t timeout; ///< @brief Após quantos segundos eu encerro a sessao? | |
37 | - time_t maxidle; ///< @brief Tempo máximo que a sessão pode ficar IDLE | |
38 | - time_t autoclose; ///< @brief Destroi a sessão quantos segundos após a desconexão? | |
39 | -}; | |
40 | - | |
41 | -struct _sessionClass { | |
42 | - GObjectClass parent; | |
43 | -}; | |
44 | - | |
45 | -static GList * session_list = NULL; | |
46 | - | |
47 | -G_DEFINE_TYPE(session, session, GLIB_TYPE_IPC3270) | |
48 | - | |
49 | -static void session_finalize(GObject *object) { | |
50 | - | |
51 | - session_list = g_list_remove(session_list, object); | |
52 | - | |
53 | - lib3270_session_free(ipc3270_get_session(object)); | |
54 | - G_OBJECT_CLASS(session_parent_class)->finalize(object); | |
55 | - | |
56 | - debug("%s(%p)",__FUNCTION__,(void *) object); | |
57 | - | |
58 | -} | |
59 | - | |
60 | -static void session_class_init(sessionClass *klass) { | |
61 | - | |
62 | - debug("%s",__FUNCTION__); | |
63 | - | |
64 | - GObjectClass *object_class; | |
65 | - object_class = G_OBJECT_CLASS (klass); | |
66 | - object_class->finalize = session_finalize; | |
67 | - | |
68 | -} | |
69 | - | |
70 | -static void session_init(session *object) { | |
71 | - | |
72 | - debug("%s(%p)",__FUNCTION__,(void *) object); | |
73 | - | |
74 | - H3270 * hSession = lib3270_session_new(""); | |
75 | - lib3270_set_user_data(hSession,object); | |
76 | - ipc3270_set_session(&object->parent,hSession); | |
77 | - | |
78 | - session_list = g_list_prepend(session_list, object); | |
79 | - | |
80 | -} | |
81 | - | |
82 | -GObject * session_new() { | |
83 | - return g_object_new(GLIB_TYPE_SESSION, NULL); | |
84 | -} | |
85 | - |
src/service/setproperties.c
... | ... | @@ -1,52 +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 - e possui - linhas de código. | |
22 | - * | |
23 | - * Referências: | |
24 | - * | |
25 | - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
26 | - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
27 | - * | |
28 | - * Contatos: | |
29 | - * | |
30 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
31 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
32 | - * | |
33 | - */ | |
34 | - | |
35 | -#include <config.h> | |
36 | -#include "private.h" | |
37 | -#include <lib3270/ipc-glib.h> | |
38 | -#include <lib3270.h> | |
39 | -#include <lib3270/properties.h> | |
40 | - | |
41 | -gboolean service_set_property(const gchar *property_name, GVariant *value, GError **error) { | |
42 | - | |
43 | - debug("%s(%s)",__FUNCTION__,property_name); | |
44 | - | |
45 | - g_set_error (error, | |
46 | - G_IO_ERROR, | |
47 | - G_IO_ERROR_NOT_FOUND, | |
48 | - "Can't find any property named %s", property_name | |
49 | - ); | |
50 | - | |
51 | - return FALSE; | |
52 | -} |
src/service/windows/resources.rc.in
... | ... | @@ -1,29 +0,0 @@ |
1 | -#include <windows.h> | |
2 | - | |
3 | -VS_VERSION_INFO VERSIONINFO | |
4 | -FILEVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0 | |
5 | -PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0 | |
6 | - | |
7 | -BEGIN | |
8 | - | |
9 | - BLOCK "StringFileInfo" | |
10 | - BEGIN | |
11 | - BLOCK "080904E4" | |
12 | - BEGIN | |
13 | - VALUE "FileDescription", "@PACKAGE_NAME@ IPC Service\0" | |
14 | - VALUE "CompanyName", "Banco do Brasil S/A.\0" | |
15 | - VALUE "FileVersion", "@WIN32_VERSION@\0" | |
16 | - VALUE "LegalCopyright", "(C) 2017 Banco do Brasil S/A. All Rights Reserved\0" | |
17 | - VALUE "OriginalFilename", "ipc3270@DLLEXT@\0" | |
18 | - VALUE "ProductName", "@PACKAGE_NAME@\0" | |
19 | - VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.0\0" | |
20 | - END | |
21 | - END | |
22 | - | |
23 | - BLOCK "VarFileInfo" | |
24 | - BEGIN | |
25 | - VALUE "Translation", 0x809, 0x04E4 | |
26 | - END | |
27 | - | |
28 | -END | |
29 | - |
src/testprogram/testprogram.c
... | ... | @@ -1,273 +0,0 @@ |
1 | -/* | |
2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob | |
5 | - * o nome G3270. | |
6 | - * | |
7 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
8 | - * | |
9 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
10 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
11 | - * Free Software Foundation. | |
12 | - * | |
13 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
14 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
15 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
16 | - * obter mais detalhes. | |
17 | - * | |
18 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
19 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
20 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | - * | |
22 | - * Este programa está nomeado como testprogram.c e possui - linhas de código. | |
23 | - * | |
24 | - * Contatos: | |
25 | - * | |
26 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
27 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
28 | - * | |
29 | - */ | |
30 | - | |
31 | - | |
32 | - /** | |
33 | - * @brief Test program for pw3270 IPC plugin. | |
34 | - * | |
35 | - */ | |
36 | - | |
37 | - #include <config.h> | |
38 | - #include <v3270.h> | |
39 | - #include <v3270/trace.h> | |
40 | - #include <lib3270/ipc-glib.h> | |
41 | - #include <string.h> | |
42 | - #include <stdlib.h> | |
43 | - | |
44 | - /*---[ Globals ]------------------------------------------------------------------------------------*/ | |
45 | - | |
46 | - const gchar * plugin_path = ".bin/Debug"; | |
47 | - const gchar * session_name = "pw3270"; | |
48 | - const gchar * plugin_name = "ipc3270." G_MODULE_SUFFIX; | |
49 | - | |
50 | - /*---[ Implement ]----------------------------------------------------------------------------------*/ | |
51 | - | |
52 | - static void close_module(GtkWidget *widget, GModule *module) | |
53 | - { | |
54 | - g_message("Closing module %p",module); | |
55 | - | |
56 | - static void (*stop)(GtkWidget *window, GtkWidget *terminal) = NULL; | |
57 | - if(!g_module_symbol(module,"pw3270_plugin_stop",(gpointer) &stop)) | |
58 | - { | |
59 | - g_message("Can't get stop method from plugin: %s",g_module_error()); | |
60 | - } | |
61 | - else | |
62 | - { | |
63 | - stop(gtk_widget_get_toplevel(widget),widget); | |
64 | - } | |
65 | - | |
66 | - g_module_close(module); | |
67 | - g_message("Module %p was closed",module); | |
68 | - } | |
69 | - | |
70 | - static void toggle_ds_trace(GtkToggleToolButton *button, GtkWidget *terminal) | |
71 | - { | |
72 | - v3270_set_toggle(terminal,LIB3270_TOGGLE_DS_TRACE,gtk_toggle_tool_button_get_active(button)); | |
73 | - } | |
74 | - | |
75 | - static void toggle_event_trace(GtkToggleToolButton *button, GtkWidget *terminal) | |
76 | - { | |
77 | - v3270_set_toggle(terminal,LIB3270_TOGGLE_EVENT_TRACE,gtk_toggle_tool_button_get_active(button)); | |
78 | - } | |
79 | - | |
80 | - static void toggle_ssl_trace(GtkToggleToolButton *button, GtkWidget *terminal) | |
81 | - { | |
82 | - v3270_set_toggle(terminal,LIB3270_TOGGLE_SSL_TRACE,gtk_toggle_tool_button_get_active(button)); | |
83 | - } | |
84 | - | |
85 | - static void toggle_screen_trace(GtkToggleToolButton *button, GtkWidget *terminal) | |
86 | - { | |
87 | - v3270_set_toggle(terminal,LIB3270_TOGGLE_SCREEN_TRACE,gtk_toggle_tool_button_get_active(button)); | |
88 | - } | |
89 | - | |
90 | - static void toggle_started_trace(GtkToggleToolButton *button, GModule *module) | |
91 | - { | |
92 | - if(!module) | |
93 | - return; | |
94 | - | |
95 | - GtkWidget * terminal = g_object_get_data(G_OBJECT(button),"terminal"); | |
96 | - | |
97 | - const gchar * method_name = (gtk_toggle_tool_button_get_active(button) ? "pw3270_plugin_start" : "pw3270_plugin_stop"); | |
98 | - | |
99 | - static void (*call)(GtkWidget *window, GtkWidget *terminal) = NULL; | |
100 | - if(!g_module_symbol(module,method_name,(gpointer) &call)) | |
101 | - { | |
102 | - g_message("Can't get method \"%s\": %s",method_name,g_module_error()); | |
103 | - return; | |
104 | - } | |
105 | - | |
106 | - g_message("Calling %s",method_name); | |
107 | - call(gtk_widget_get_toplevel(terminal), GTK_WIDGET(terminal)); | |
108 | - | |
109 | - } | |
110 | - | |
111 | - static GtkToolItem * create_tool_item(GtkWidget *terminal, const gchar *label, const gchar *tooltip, GCallback callback) | |
112 | - { | |
113 | - GtkToolItem * item = gtk_toggle_tool_button_new(); | |
114 | - gtk_tool_button_set_label(GTK_TOOL_BUTTON(item),label); | |
115 | - | |
116 | - g_signal_connect(GTK_WIDGET(item), "toggled", G_CALLBACK(callback), terminal); | |
117 | - | |
118 | - if(tooltip) | |
119 | - gtk_widget_set_tooltip_text(GTK_WIDGET(item),tooltip); | |
120 | - | |
121 | - return item; | |
122 | - } | |
123 | - | |
124 | - static void session_changed(GtkWidget *widget, GtkWidget *window) { | |
125 | - | |
126 | - g_autofree gchar * title = NULL; | |
127 | - | |
128 | - g_message("Session name was changed"); | |
129 | - | |
130 | - if(v3270_is_connected(widget)) { | |
131 | - const gchar *host = v3270_get_hostname(widget); | |
132 | - | |
133 | - if(host && *host) | |
134 | - title = g_strdup_printf("%s - %s",v3270_get_session_name(widget),host); | |
135 | - else | |
136 | - title = g_strdup_printf("%s",v3270_get_session_name(widget)); | |
137 | - | |
138 | - } else { | |
139 | - | |
140 | - title = g_strdup_printf("%s - Disconnected",v3270_get_session_name(widget)); | |
141 | - } | |
142 | - | |
143 | - gtk_window_set_title(GTK_WINDOW(window),title); | |
144 | - | |
145 | - | |
146 | - } | |
147 | - | |
148 | - static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { | |
149 | - | |
150 | - GtkWidget * window = gtk_application_window_new(app); | |
151 | - GtkWidget * terminal = v3270_new(); | |
152 | - GtkWidget * notebook = gtk_notebook_new(); | |
153 | - GModule * module = NULL; | |
154 | - | |
155 | - gtk_widget_set_name(window,session_name); | |
156 | - | |
157 | - // Setup tabs | |
158 | - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),terminal,gtk_label_new(v3270_get_session_name(terminal))); | |
159 | - | |
160 | - // Load plugin | |
161 | - { | |
162 | - g_autofree gchar * plugin = g_build_filename(plugin_path,plugin_name,NULL); | |
163 | - | |
164 | - g_message("Loading %s",plugin); | |
165 | - | |
166 | - module = g_module_open(plugin,G_MODULE_BIND_LOCAL); | |
167 | - | |
168 | - if(module) | |
169 | - { | |
170 | - g_signal_connect (terminal, "destroy", G_CALLBACK(close_module), module); | |
171 | - } | |
172 | - else | |
173 | - { | |
174 | - g_message("Can't open \"%s\": %s",plugin,g_module_error()); | |
175 | - gtk_main_quit(); | |
176 | - } | |
177 | - | |
178 | - } | |
179 | - // Create trace window | |
180 | - { | |
181 | - GtkWidget * box = gtk_box_new(GTK_ORIENTATION_VERTICAL,0); | |
182 | - GtkWidget * trace = v3270_trace_new(terminal); | |
183 | - GtkWidget * toolbar = gtk_toolbar_new(); | |
184 | - GtkToolItem * start = gtk_toggle_tool_button_new(); | |
185 | - | |
186 | - gtk_widget_set_sensitive(GTK_WIDGET(start),module != NULL); | |
187 | - | |
188 | - g_object_set_data(G_OBJECT(start),"terminal",terminal); | |
189 | - | |
190 | - gtk_tool_button_set_label(GTK_TOOL_BUTTON(start),"Enable"); | |
191 | - g_signal_connect(GTK_WIDGET(start), "toggled", G_CALLBACK(toggle_started_trace), module); | |
192 | - gtk_widget_set_tooltip_text(GTK_WIDGET(start),"Start/Stop plugin module"); | |
193 | - | |
194 | - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), start, -1); | |
195 | - | |
196 | - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),gtk_separator_tool_item_new(),-1); | |
197 | - | |
198 | - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "DS Trace","Toggle DS Trace",G_CALLBACK(toggle_ds_trace)),-1); | |
199 | - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "Event Trace","Toggle Event Trace",G_CALLBACK(toggle_event_trace)),-1); | |
200 | - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "Screen Trace","Toggle Screen Trace",G_CALLBACK(toggle_screen_trace)),-1); | |
201 | - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "SSL Trace","Toggle SSL Trace",G_CALLBACK(toggle_ssl_trace)),-1); | |
202 | - | |
203 | - gtk_box_pack_start(GTK_BOX(box),toolbar,FALSE,FALSE,0); | |
204 | - gtk_box_pack_start(GTK_BOX(box),trace,TRUE,TRUE,0); | |
205 | - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),box,gtk_label_new("Trace")); | |
206 | - } | |
207 | - | |
208 | - // Setup and show main window | |
209 | - gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); | |
210 | - gtk_window_set_default_size (GTK_WINDOW (window), 800, 500); | |
211 | - gtk_container_add(GTK_CONTAINER(window),notebook); | |
212 | - gtk_widget_show_all (window); | |
213 | - | |
214 | - // Setup title. | |
215 | - const gchar *url = lib3270_get_url(v3270_get_session(terminal)); | |
216 | - if(url) { | |
217 | - | |
218 | - v3270_set_url(terminal,url); | |
219 | - v3270_reconnect(terminal); | |
220 | - | |
221 | - gchar * title = g_strdup_printf("%s - %s", v3270_get_session_name(terminal), url); | |
222 | - gtk_window_set_title(GTK_WINDOW(window), title); | |
223 | - g_free(title); | |
224 | - | |
225 | - } else { | |
226 | - | |
227 | - gtk_window_set_title(GTK_WINDOW(window), v3270_get_session_name(terminal)); | |
228 | - | |
229 | - } | |
230 | - | |
231 | - g_signal_connect(terminal,"session_changed",G_CALLBACK(session_changed),window); | |
232 | - | |
233 | -} | |
234 | - | |
235 | -int main (int argc, char **argv) { | |
236 | - | |
237 | - /* | |
238 | - GVariantBuilder builder; | |
239 | - | |
240 | - g_variant_builder_init(&builder,G_VARIANT_TYPE("(isi)")); | |
241 | - | |
242 | - g_variant_builder_add(&builder, "i", 10); | |
243 | - g_variant_builder_add(&builder, "s", "teste"); | |
244 | - g_variant_builder_add(&builder, "i", 20); | |
245 | - | |
246 | - GVariant *value = g_variant_builder_end(&builder); | |
247 | - | |
248 | - size_t szPacket = 0; | |
249 | - g_autofree unsigned char * buffer = ipc3270_pack("teste", value, &szPacket); | |
250 | - g_variant_unref(value); | |
251 | - | |
252 | - debug("Package \"%s\" was created with %u bytes", buffer, (unsigned int) szPacket); | |
253 | - | |
254 | - value = ipc3270_unpack(buffer); | |
255 | - | |
256 | - g_variant_unref(value); | |
257 | - */ | |
258 | - | |
259 | - GtkApplication *app; | |
260 | - int status; | |
261 | - | |
262 | - app = gtk_application_new ("br.com.bb.pw3270",G_APPLICATION_FLAGS_NONE); | |
263 | - | |
264 | - g_signal_connect (app, "activate", G_CALLBACK(activate), NULL); | |
265 | - | |
266 | - status = g_application_run (G_APPLICATION (app), argc, argv); | |
267 | - g_object_unref (app); | |
268 | - | |
269 | - g_message("rc=%d",status); | |
270 | - return status; | |
271 | - | |
272 | -} | |
273 | - |