Commit 9cc790e6d324ffc27a20af5fa7e48ed8e817061e
1 parent
000f528f
Exists in
master
and in
5 other branches
Implementando plugin java
Showing
11 changed files
with
377 additions
and
7 deletions
Show diff stats
src/java/Makefile.in
... | ... | @@ -26,6 +26,7 @@ |
26 | 26 | |
27 | 27 | PACKAGE_NAME=@PACKAGE_NAME@ |
28 | 28 | SOURCES=main.cc info.cc connect.cc getset.cc cursor.cc keyboard.cc actions.cc |
29 | +PLUGIN_SRC=plugin.cc | |
29 | 30 | |
30 | 31 | #---[ Paths ]------------------------------------------------------------------ |
31 | 32 | |
... | ... | @@ -77,6 +78,8 @@ include $(CLASSLIBDIR)/class.mak |
77 | 78 | #---[ Build options ]---------------------------------------------------------- |
78 | 79 | |
79 | 80 | CXXFLAGS=@CXXFLAGS@ @DLL_CFLAGS@ @JNI_CPPFLAGS@ -I../include |
81 | +PLUGIN_CFLAGS=@CXXFLAGS@ @DLL_CFLAGS@ @JNI_CPPFLAGS@ @GTK_CFLAGS@ @GTKMAC_CFLAGS@ -I../include | |
82 | +PLUGINS_LIBS=@GTK_LIBS@ @GTKMAC_LIBS@ | |
80 | 83 | |
81 | 84 | #---[ Rules ]------------------------------------------------------------------ |
82 | 85 | |
... | ... | @@ -85,11 +88,21 @@ $(OBJDBG)/%.o: %.cc Makefile private.h jni3270.h |
85 | 88 | @mkdir -p `dirname $@` |
86 | 89 | @$(CXX) -DDEBUG=1 $(CXXFLAGS) -o $@ -c $< |
87 | 90 | |
91 | +$(OBJDBG)/j3270/%.o: %.cc Makefile private.h | |
92 | + @echo " CC `basename $@`" | |
93 | + @mkdir -p `dirname $@` | |
94 | + @$(CXX) -DDEBUG=1 $(PLUGIN_CFLAGS) -o $@ -c $< | |
95 | + | |
88 | 96 | $(OBJRLS)/%.o: %.cc Makefile private.h jni3270.h |
89 | 97 | @echo " CC `basename $@`" |
90 | 98 | @mkdir -p `dirname $@` |
91 | 99 | @$(CXX) -DNDEBUG=1 $(CXXFLAGS) -o $@ -c $< |
92 | 100 | |
101 | +$(OBJRLS)/j3270/%.o: %.cc Makefile private.h | |
102 | + @echo " CC `basename $@`" | |
103 | + @mkdir -p `dirname $@` | |
104 | + @$(CXX) -DNDEBUG=1 $(PLUGIN_CFLAGS) -o $@ -c $< | |
105 | + | |
93 | 106 | $(BINDIR)/java/%.class: %.java $(BINDIR)/java/$(PACKAGE_NAME)/terminal.class |
94 | 107 | @echo $< ... |
95 | 108 | @mkdir -p `dirname $@` |
... | ... | @@ -116,7 +129,7 @@ all: $(BINRLS)@DLLDIR@/@DLLPREFIX@jni3270@DLLEXT@ |
116 | 129 | |
117 | 130 | Release: $(BINRLS)@DLLDIR@/@DLLPREFIX@jni3270@DLLEXT@ |
118 | 131 | |
119 | -zip: jni3270.zip | |
132 | +zip: jni3270.zip | |
120 | 133 | |
121 | 134 | jni3270.zip: $(BINRLS)@DLLDIR@/@DLLPREFIX@jni3270@DLLEXT@ $(BINRLS)/$(PACKAGE_NAME).jar testprogram.java doc |
122 | 135 | @rm -fr .tmp.zip |
... | ... | @@ -133,19 +146,36 @@ $(BINRLS)@DLLDIR@/@DLLPREFIX@jni3270@DLLEXT@: \ |
133 | 146 | |
134 | 147 | @echo " LD `basename $@`" |
135 | 148 | @$(MKDIR) `dirname $@` |
136 | - @$(CXX) @SYSDLL_FLAGS@ $(LDFLAGS) $(OO_LDFLAGS) -o $@ $^ $(CLASS_LIBS) | |
149 | + @$(CXX) @SYSDLL_FLAGS@ $(LDFLAGS) -o $@ $^ $(CLASS_LIBS) | |
137 | 150 | |
151 | +$(BINRLS)/plugins/j3270@DLLEXT@: \ | |
152 | + $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJRLS)/j3270/$(SRC)@OBJEXT@) | |
153 | + | |
154 | + @echo " LD `basename $@`" | |
155 | + @$(MKDIR) `dirname $@` | |
156 | + @$(CXX) @SYSDLL_FLAGS@ $(LDFLAGS) -o $@ $^ $(CLASS_LIBS) $(PLUGIN_LIBS) -ljni3270 | |
138 | 157 | |
139 | 158 | #---[ Debug targets ]---------------------------------------------------------- |
140 | 159 | |
141 | -Debug: $(BINDBG)@DLLDIR@/@DLLPREFIX@jni3270@DLLEXT@ $(BINDIR)/java/testprogram.class | |
160 | +Debug: $(BINDBG)@DLLDIR@/@DLLPREFIX@jni3270@DLLEXT@ \ | |
161 | + $(BINDIR)/java/testprogram.class \ | |
162 | + $(BINDBG)/plugins/j3270@DLLEXT@ | |
163 | + | |
164 | +$(BINDBG)@DLLDIR@/@DLLPREFIX@jni3270@DLLEXT@: \ | |
165 | + $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@) \ | |
166 | + $(CLASS_DEBUG_OBJECTS) | |
142 | 167 | |
143 | -$(BINDBG)@DLLDIR@/@DLLPREFIX@jni3270@DLLEXT@: $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@) \ | |
144 | - $(CLASS_DEBUG_OBJECTS) | |
145 | 168 | @echo " LD `basename $@`" |
146 | 169 | @$(MKDIR) `dirname $@` |
147 | - @$(CXX) @SYSDLL_FLAGS@ $(LDFLAGS) $(OO_LDFLAGS) -o $@ $^ $(CLASS_LIBS) | |
170 | + @$(CXX) @SYSDLL_FLAGS@ $(LDFLAGS) -o $@ $^ $(CLASS_LIBS) | |
148 | 171 | |
172 | +$(BINDBG)/plugins/j3270@DLLEXT@: \ | |
173 | + $(BINDBG)@DLLDIR@/@DLLPREFIX@jni3270@DLLEXT@ \ | |
174 | + $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJDBG)/j3270/$(SRC)@OBJEXT@) | |
175 | + | |
176 | + @echo " LD `basename $@`" | |
177 | + @$(MKDIR) `dirname $@` | |
178 | + @$(CXX) @SYSDLL_FLAGS@ @DBGRPATH@ $(LDFLAGS) -o $@ $^ $(CLASS_LIBS) $(PLUGIN_LIBS) -L$(BINDBG)@DLLDIR@ -ljni3270 | |
149 | 179 | |
150 | 180 | run: $(BINDBG)@DLLDIR@/@DLLPREFIX@jni3270@DLLEXT@ $(BINDIR)/java/testprogram.class |
151 | 181 | @LD_LIBRARY_PATH=../../.bin/Debug/lib/ java -Djava.library.path=$(BINDBG)@DLLDIR@ -cp .bin/java/ testprogram | ... | ... |
src/java/actions.cc
src/java/connect.cc
src/java/cursor.cc
src/java/getset.cc
src/java/info.cc
src/java/jni3270.cbp
src/java/keyboard.cc
src/java/main.cc
... | ... | @@ -0,0 +1,332 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple | |
19 | + * Place, Suite 330, Boston, MA, 02111-1307, USA | |
20 | + * | |
21 | + * Este programa está nomeado como plugin.cc 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 | + | |
32 | + #include <libintl.h> | |
33 | + #include <glib/gi18n.h> | |
34 | + #include <gtk/gtk.h> | |
35 | + | |
36 | + #include <pw3270.h> | |
37 | + #include <pw3270/plugin.h> | |
38 | + #include <pw3270/v3270.h> | |
39 | + #include <lib3270/actions.h> | |
40 | + #include <lib3270/log.h> | |
41 | + #include <lib3270/trace.h> | |
42 | + #include <lib3270/charset.h> | |
43 | + #include <pw3270/class.h> | |
44 | + | |
45 | + | |
46 | +/*--[ Globals ]--------------------------------------------------------------------------------------*/ | |
47 | + | |
48 | +#if GTK_CHECK_VERSION(2,32,0) | |
49 | + static GMutex mutex; | |
50 | +#else | |
51 | + static GStaticMutex mutex = G_STATIC_MUTEX_INIT; | |
52 | +#endif // GTK_CHECK_VERSION | |
53 | + | |
54 | +/*--[ Plugin session object ]--------------------------------------------------------------------------------*/ | |
55 | + | |
56 | + class plugin : public PW3270_NAMESPACE::session | |
57 | + { | |
58 | + private: | |
59 | + H3270 * hSession; | |
60 | + | |
61 | + public: | |
62 | + plugin(H3270 *hSession) : PW3270_NAMESPACE::session() { | |
63 | + this->hSession = hSession; | |
64 | + } | |
65 | + | |
66 | + virtual ~plugin() { | |
67 | + trace("%s",__FUNCTION__); | |
68 | + } | |
69 | + | |
70 | + const string get_version(void) { | |
71 | + return string(lib3270_get_version()); | |
72 | + } | |
73 | + | |
74 | + LIB3270_CSTATE get_cstate(void) { | |
75 | + return lib3270_get_connection_state(hSession); | |
76 | + } | |
77 | + | |
78 | + int disconnect(void) { | |
79 | + lib3270_disconnect(hSession); | |
80 | + return 0; | |
81 | + } | |
82 | + | |
83 | + int connect(void) { | |
84 | + return lib3270_connect(hSession,0); | |
85 | + } | |
86 | + | |
87 | + bool is_connected(void) { | |
88 | + return lib3270_is_connected(hSession); | |
89 | + } | |
90 | + | |
91 | + int iterate(bool wait) { | |
92 | + if(!lib3270_is_connected(hSession)) | |
93 | + return ENOTCONN; | |
94 | + | |
95 | + lib3270_main_iterate(hSession,wait); | |
96 | + | |
97 | + return 0; | |
98 | + | |
99 | + } | |
100 | + | |
101 | + int wait(int seconds) { | |
102 | + return lib3270_wait(hSession,seconds); | |
103 | + } | |
104 | + | |
105 | + int wait_for_ready(int seconds) { | |
106 | + return lib3270_wait_for_ready(hSession,seconds); | |
107 | + } | |
108 | + | |
109 | + bool is_ready(void) { | |
110 | + return lib3270_is_ready(hSession) != 0; | |
111 | + } | |
112 | + | |
113 | + void logva(const char *fmt, va_list args) { | |
114 | + lib3270_write_va_log(hSession,"JAVA",fmt,args); | |
115 | + } | |
116 | + | |
117 | + string get_text(int baddr, size_t len) { | |
118 | + | |
119 | + string rc; | |
120 | + char * ptr = lib3270_get_text(hSession,baddr,len); | |
121 | + | |
122 | + if(ptr) | |
123 | + { | |
124 | + rc.assign(ptr); | |
125 | + lib3270_free(ptr); | |
126 | + } | |
127 | + | |
128 | + return rc; | |
129 | + } | |
130 | + | |
131 | + string get_text_at(int row, int col, size_t sz) { | |
132 | + | |
133 | + string rc; | |
134 | + char * ptr = lib3270_get_text_at(hSession,row,col,(int) sz); | |
135 | + | |
136 | + if(ptr) | |
137 | + { | |
138 | + rc.assign(ptr); | |
139 | + lib3270_free(ptr); | |
140 | + } | |
141 | + | |
142 | + return rc; | |
143 | + | |
144 | + } | |
145 | + | |
146 | + int cmp_text_at(int row, int col, const char *text) { | |
147 | + return lib3270_cmp_text_at(hSession,row,col,text); | |
148 | + } | |
149 | + | |
150 | + int set_text_at(int row, int col, const char *str) { | |
151 | + return lib3270_set_text_at(hSession,row,col,(const unsigned char *) str); | |
152 | + } | |
153 | + | |
154 | + int set_cursor_position(int row, int col) { | |
155 | + return lib3270_set_cursor_position(hSession,row,col); | |
156 | + } | |
157 | + | |
158 | + int set_cursor_addr(int addr) { | |
159 | + return lib3270_set_cursor_address(hSession,addr); | |
160 | + } | |
161 | + | |
162 | + int get_cursor_addr(void) { | |
163 | + return lib3270_get_cursor_address(hSession); | |
164 | + } | |
165 | + | |
166 | + int emulate_input(const char *str) { | |
167 | + return lib3270_emulate_input(hSession, str, -1, 1); | |
168 | + } | |
169 | + | |
170 | + int set_toggle(LIB3270_TOGGLE ix, bool value) { | |
171 | + return lib3270_set_toggle(hSession,ix,(int) value); | |
172 | + } | |
173 | + | |
174 | + int enter(void) { | |
175 | + return lib3270_enter(hSession); | |
176 | + } | |
177 | + | |
178 | + int pfkey(int key) { | |
179 | + return lib3270_pfkey(hSession,key); | |
180 | + } | |
181 | + | |
182 | + int pakey(int key) { | |
183 | + return lib3270_pakey(hSession,key); | |
184 | + } | |
185 | + | |
186 | + int erase_eof(void) { | |
187 | + return lib3270_eraseeof(hSession); | |
188 | + } | |
189 | + | |
190 | + int print(void) { | |
191 | + return lib3270_print(hSession); | |
192 | + } | |
193 | + | |
194 | + int get_field_start(int baddr = -1) { | |
195 | + return lib3270_get_field_start(hSession,baddr); | |
196 | + } | |
197 | + | |
198 | + int get_field_len(int baddr = -1) { | |
199 | + return lib3270_get_field_len(hSession,baddr); | |
200 | + } | |
201 | + | |
202 | + int get_next_unprotected(int baddr = -1) { | |
203 | + return lib3270_get_next_unprotected(hSession,baddr); | |
204 | + } | |
205 | + | |
206 | + int set_copy(const char *text) { | |
207 | + v3270_set_copy(GTK_WIDGET(lib3270_get_user_data(hSession)),text); | |
208 | + return 0; | |
209 | + } | |
210 | + | |
211 | + string get_copy(void) { | |
212 | + | |
213 | + string rc; | |
214 | + gchar * ptr = v3270_get_copy(GTK_WIDGET(lib3270_get_user_data(hSession))); | |
215 | + | |
216 | + if(ptr) | |
217 | + { | |
218 | + rc.assign(ptr); | |
219 | + g_free(ptr); | |
220 | + } | |
221 | + | |
222 | + return rc; | |
223 | + | |
224 | + } | |
225 | + | |
226 | + string get_clipboard(void) { | |
227 | + | |
228 | + string rc; | |
229 | + gchar * ptr = gtk_clipboard_wait_for_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD)); | |
230 | + | |
231 | + if(ptr) | |
232 | + { | |
233 | + rc.assign(ptr); | |
234 | + g_free(ptr); | |
235 | + } | |
236 | + | |
237 | + return rc; | |
238 | + | |
239 | + } | |
240 | + | |
241 | + int set_clipboard(const char *text) { | |
242 | + gtk_clipboard_set_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD),(gchar *) text, -1); | |
243 | + return 0; | |
244 | + } | |
245 | + | |
246 | + void free(void *ptr) { | |
247 | + g_free(ptr); | |
248 | + } | |
249 | + | |
250 | + int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) { | |
251 | + va_list args; | |
252 | + va_start(args, fmt); | |
253 | + lib3270_popup_va(hSession, id, title, message, fmt, args); | |
254 | + va_end(args); | |
255 | + return 0; | |
256 | + } | |
257 | + | |
258 | + string file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename) { | |
259 | + string rc; | |
260 | + gchar * ptr = pw3270_file_chooser(action, "java", title, filename, extension); | |
261 | + | |
262 | + if(ptr) | |
263 | + { | |
264 | + rc.assign((char *) ptr); | |
265 | + g_free(ptr); | |
266 | + } | |
267 | + | |
268 | + return rc; | |
269 | + } | |
270 | + | |
271 | + int set_host_charset(const char *charset) { | |
272 | + return lib3270_set_host_charset(hSession,charset); | |
273 | + } | |
274 | + | |
275 | + string get_host_charset(void) { | |
276 | + return string(lib3270_get_host_charset(hSession)); | |
277 | + } | |
278 | + | |
279 | + string get_display_charset(void) { | |
280 | + return string(lib3270_get_display_charset(hSession)); | |
281 | + } | |
282 | + | |
283 | + const char * asc2ebc(unsigned char *str, int sz = -1) { | |
284 | + return lib3270_asc2ebc(hSession,str,sz); | |
285 | + } | |
286 | + | |
287 | + const char * ebc2asc(unsigned char *str, int sz = -1) { | |
288 | + return lib3270_ebc2asc(hSession,str,sz); | |
289 | + } | |
290 | + | |
291 | + int set_url(const char *uri) { | |
292 | + return lib3270_set_url(hSession,uri) != NULL ? 1 : 0; | |
293 | + } | |
294 | + | |
295 | + int file_transfer(LIB3270_FT_OPTION options, const gchar *local, const gchar *remote, int lrecl = 0, int blksize = 0, int primspace = 0, int secspace = 0, int dft = 4096) { | |
296 | + return v3270_transfer_file(v3270_get_default_widget(),options,local,remote,lrecl,blksize,primspace,secspace,dft); | |
297 | + } | |
298 | + | |
299 | + int quit(void) { | |
300 | + gtk_main_quit(); | |
301 | + return 0; | |
302 | + } | |
303 | + | |
304 | + }; | |
305 | + | |
306 | + | |
307 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
308 | + | |
309 | + static session * factory(const char *name) | |
310 | + { | |
311 | + return new plugin(lib3270_get_default_session_handle()); | |
312 | + } | |
313 | + | |
314 | + LIB3270_EXPORT int pw3270_plugin_start(GtkWidget *window) | |
315 | + { | |
316 | + trace("%s",__FUNCTION__); | |
317 | +#if GTK_CHECK_VERSION(2,32,0) | |
318 | + g_mutex_init(&mutex); | |
319 | +#endif // GTK_CHECK_VERSION | |
320 | + set_java_session_factory(factory); | |
321 | + return 0; | |
322 | + } | |
323 | + | |
324 | + LIB3270_EXPORT int pw3270_plugin_stop(GtkWidget *window) | |
325 | + { | |
326 | +#if GTK_CHECK_VERSION(2,32,0) | |
327 | + g_mutex_clear(&mutex); | |
328 | +#endif // GTK_CHECK_VERSION | |
329 | + trace("%s",__FUNCTION__); | |
330 | + return 0; | |
331 | + } | |
332 | + | ... | ... |