Commit ee9b978d2b9552de494a2f5f1022df583561e060
1 parent
cbf1f7c1
Exists in
master
and in
5 other branches
Implementando novo mecanismo no plugin java.
Showing
1 changed file
with
1 additions
and
293 deletions
Show diff stats
src/java/plugin.cc
@@ -68,300 +68,8 @@ | @@ -68,300 +68,8 @@ | ||
68 | static GStaticMutex mutex = G_STATIC_MUTEX_INIT; | 68 | static GStaticMutex mutex = G_STATIC_MUTEX_INIT; |
69 | #endif // GTK_CHECK_VERSION | 69 | #endif // GTK_CHECK_VERSION |
70 | 70 | ||
71 | -/*--[ Plugin session object ]--------------------------------------------------------------------------------*/ | ||
72 | - | ||
73 | using namespace std; | 71 | using namespace std; |
74 | 72 | ||
75 | - class plugin : public PW3270_NAMESPACE::session | ||
76 | - { | ||
77 | - private: | ||
78 | - H3270 * hSession; | ||
79 | - | ||
80 | - public: | ||
81 | - plugin(H3270 *hSession) : PW3270_NAMESPACE::session() { | ||
82 | - this->hSession = hSession; | ||
83 | - } | ||
84 | - | ||
85 | - virtual ~plugin() { | ||
86 | - trace("%s",__FUNCTION__); | ||
87 | - } | ||
88 | - | ||
89 | - const string get_version(void) { | ||
90 | - return string(lib3270_get_version()); | ||
91 | - } | ||
92 | - | ||
93 | - LIB3270_CSTATE get_cstate(void) { | ||
94 | - return lib3270_get_connection_state(hSession); | ||
95 | - } | ||
96 | - | ||
97 | - LIB3270_MESSAGE get_program_message(void) { | ||
98 | - return lib3270_get_program_message(hSession); | ||
99 | - } | ||
100 | - | ||
101 | - LIB3270_SSL_STATE get_secure(void) { | ||
102 | - return lib3270_get_secure(hSession); | ||
103 | - } | ||
104 | - | ||
105 | - int disconnect(void) { | ||
106 | - lib3270_disconnect(hSession); | ||
107 | - return 0; | ||
108 | - } | ||
109 | - | ||
110 | - int connect(void) { | ||
111 | - return lib3270_connect(hSession,0); | ||
112 | - } | ||
113 | - | ||
114 | - bool is_connected(void) { | ||
115 | - return lib3270_is_connected(hSession); | ||
116 | - } | ||
117 | - | ||
118 | - int iterate(bool wait) { | ||
119 | - if(!lib3270_is_connected(hSession)) | ||
120 | - return ENOTCONN; | ||
121 | - | ||
122 | - lib3270_main_iterate(hSession,wait); | ||
123 | - | ||
124 | - return 0; | ||
125 | - | ||
126 | - } | ||
127 | - | ||
128 | - int wait(int seconds) { | ||
129 | - return lib3270_wait(hSession,seconds); | ||
130 | - } | ||
131 | - | ||
132 | - int wait_for_ready(int seconds) { | ||
133 | - return lib3270_wait_for_ready(hSession,seconds); | ||
134 | - } | ||
135 | - | ||
136 | - bool is_ready(void) { | ||
137 | - return lib3270_is_ready(hSession) != 0; | ||
138 | - } | ||
139 | - | ||
140 | - void logva(const char *fmt, va_list args) { | ||
141 | - lib3270_write_va_log(hSession,"JAVA",fmt,args); | ||
142 | - } | ||
143 | - | ||
144 | - string get_text(int baddr, size_t len) { | ||
145 | - | ||
146 | - string rc; | ||
147 | - char * ptr = lib3270_get_text(hSession,baddr,len); | ||
148 | - | ||
149 | - if(ptr) | ||
150 | - { | ||
151 | - rc.assign(ptr); | ||
152 | - lib3270_free(ptr); | ||
153 | - } | ||
154 | - | ||
155 | - return rc; | ||
156 | - } | ||
157 | - | ||
158 | - string get_text_at(int row, int col, size_t sz) { | ||
159 | - | ||
160 | - string rc; | ||
161 | - char * ptr = lib3270_get_text_at(hSession,row,col,(int) sz); | ||
162 | - | ||
163 | - if(ptr) | ||
164 | - { | ||
165 | - rc.assign(ptr); | ||
166 | - lib3270_free(ptr); | ||
167 | - } | ||
168 | - | ||
169 | - return rc; | ||
170 | - | ||
171 | - } | ||
172 | - | ||
173 | - int cmp_text_at(int row, int col, const char *text) { | ||
174 | - return lib3270_cmp_text_at(hSession,row,col,text); | ||
175 | - } | ||
176 | - | ||
177 | - int set_text_at(int row, int col, const char *str) { | ||
178 | - return lib3270_set_text_at(hSession,row,col,(const unsigned char *) str); | ||
179 | - } | ||
180 | - | ||
181 | - int set_cursor_position(int row, int col) { | ||
182 | - return lib3270_set_cursor_position(hSession,row,col); | ||
183 | - } | ||
184 | - | ||
185 | - int set_cursor_addr(int addr) { | ||
186 | - return lib3270_set_cursor_address(hSession,addr); | ||
187 | - } | ||
188 | - | ||
189 | - int get_cursor_addr(void) { | ||
190 | - return lib3270_get_cursor_address(hSession); | ||
191 | - } | ||
192 | - | ||
193 | - int emulate_input(const char *str) { | ||
194 | - return lib3270_emulate_input(hSession, str, -1, 1); | ||
195 | - } | ||
196 | - | ||
197 | - int set_toggle(LIB3270_TOGGLE ix, bool value) { | ||
198 | - return lib3270_set_toggle(hSession,ix,(int) value); | ||
199 | - } | ||
200 | - | ||
201 | - int enter(void) { | ||
202 | - return lib3270_enter(hSession); | ||
203 | - } | ||
204 | - | ||
205 | - int pfkey(int key) { | ||
206 | - return lib3270_pfkey(hSession,key); | ||
207 | - } | ||
208 | - | ||
209 | - int pakey(int key) { | ||
210 | - return lib3270_pakey(hSession,key); | ||
211 | - } | ||
212 | - | ||
213 | - int erase(void) { | ||
214 | - return lib3270_erase(hSession); | ||
215 | - } | ||
216 | - | ||
217 | - int erase_eof(void) { | ||
218 | - return lib3270_eraseeof(hSession); | ||
219 | - } | ||
220 | - | ||
221 | - int erase_eol(void) { | ||
222 | - return lib3270_eraseeol(hSession); | ||
223 | - } | ||
224 | - | ||
225 | - int erase_input(void) { | ||
226 | - return lib3270_eraseinput(hSession); | ||
227 | - } | ||
228 | - | ||
229 | - int print(void) { | ||
230 | - return lib3270_print(hSession); | ||
231 | - } | ||
232 | - | ||
233 | - int get_field_start(int baddr = -1) { | ||
234 | - return lib3270_get_field_start(hSession,baddr); | ||
235 | - } | ||
236 | - | ||
237 | - int get_field_len(int baddr = -1) { | ||
238 | - return lib3270_get_field_len(hSession,baddr); | ||
239 | - } | ||
240 | - | ||
241 | - int get_next_unprotected(int baddr = -1) { | ||
242 | - return lib3270_get_next_unprotected(hSession,baddr); | ||
243 | - } | ||
244 | - | ||
245 | - int get_is_protected(int baddr = -1) { | ||
246 | - return lib3270_get_is_protected(hSession,baddr); | ||
247 | - } | ||
248 | - | ||
249 | - int get_is_protected_at(int row, int col) { | ||
250 | - return lib3270_get_is_protected_at(hSession,row,col); | ||
251 | - } | ||
252 | - | ||
253 | - int set_copy(const char *text) { | ||
254 | - v3270_set_copy(GTK_WIDGET(lib3270_get_user_data(hSession)),text); | ||
255 | - return 0; | ||
256 | - } | ||
257 | - | ||
258 | - string get_copy(void) { | ||
259 | - | ||
260 | - string rc; | ||
261 | - gchar * ptr = v3270_get_copy(GTK_WIDGET(lib3270_get_user_data(hSession))); | ||
262 | - | ||
263 | - if(ptr) | ||
264 | - { | ||
265 | - rc.assign(ptr); | ||
266 | - g_free(ptr); | ||
267 | - } | ||
268 | - | ||
269 | - return rc; | ||
270 | - | ||
271 | - } | ||
272 | - | ||
273 | - string get_clipboard(void) { | ||
274 | - | ||
275 | - string rc; | ||
276 | - gchar * ptr = gtk_clipboard_wait_for_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD)); | ||
277 | - | ||
278 | - if(ptr) | ||
279 | - { | ||
280 | - rc.assign(ptr); | ||
281 | - g_free(ptr); | ||
282 | - } | ||
283 | - | ||
284 | - return rc; | ||
285 | - | ||
286 | - } | ||
287 | - | ||
288 | - int set_clipboard(const char *text) { | ||
289 | - gtk_clipboard_set_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD),(gchar *) text, -1); | ||
290 | - return 0; | ||
291 | - } | ||
292 | - | ||
293 | - void free(void *ptr) { | ||
294 | - g_free(ptr); | ||
295 | - } | ||
296 | - | ||
297 | - int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) { | ||
298 | - va_list args; | ||
299 | - va_start(args, fmt); | ||
300 | - lib3270_popup_va(hSession, id, title, message, fmt, args); | ||
301 | - va_end(args); | ||
302 | - return 0; | ||
303 | - } | ||
304 | - | ||
305 | - string file_chooser_dialog(int action, const char *title, const char *extension, const char *filename) { | ||
306 | - string rc; | ||
307 | - gchar * ptr = pw3270_file_chooser((GtkFileChooserAction) action, "java", title, filename, extension); | ||
308 | - | ||
309 | - if(ptr) | ||
310 | - { | ||
311 | - rc.assign((char *) ptr); | ||
312 | - g_free(ptr); | ||
313 | - } | ||
314 | - | ||
315 | - return rc; | ||
316 | - } | ||
317 | - | ||
318 | - int set_host_charset(const char *charset) { | ||
319 | - return lib3270_set_host_charset(hSession,charset); | ||
320 | - } | ||
321 | - | ||
322 | - string get_host_charset(void) { | ||
323 | - return string(lib3270_get_host_charset(hSession)); | ||
324 | - } | ||
325 | - | ||
326 | - string get_display_charset(void) { | ||
327 | - return string(lib3270_get_display_charset(hSession)); | ||
328 | - } | ||
329 | - | ||
330 | - const char * asc2ebc(unsigned char *str, int sz = -1) { | ||
331 | - return lib3270_asc2ebc(hSession,str,sz); | ||
332 | - } | ||
333 | - | ||
334 | - const char * ebc2asc(unsigned char *str, int sz = -1) { | ||
335 | - return lib3270_ebc2asc(hSession,str,sz); | ||
336 | - } | ||
337 | - | ||
338 | - int set_url(const char *uri) { | ||
339 | - return lib3270_set_url(hSession,uri) != NULL ? 1 : 0; | ||
340 | - } | ||
341 | - | ||
342 | - 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) { | ||
343 | - /* | ||
344 | - return v3270_transfer_file(v3270_get_default_widget(),options,local,remote,lrecl,blksize,primspace,secspace,dft); | ||
345 | - */ | ||
346 | - return EINVAL; | ||
347 | - } | ||
348 | - | ||
349 | - void set_unlock_delay(unsigned short ms) | ||
350 | - { | ||
351 | - lib3270_set_unlock_delay(hSession, ms); | ||
352 | - } | ||
353 | - | ||
354 | - int quit(void) { | ||
355 | - gtk_main_quit(); | ||
356 | - return 0; | ||
357 | - } | ||
358 | - | ||
359 | - int action(const char *name) { | ||
360 | - return lib3270_action(hSession,name); | ||
361 | - } | ||
362 | - | ||
363 | - }; | ||
364 | - | ||
365 | 73 | ||
366 | /*---[ Implement ]----------------------------------------------------------------------------------*/ | 74 | /*---[ Implement ]----------------------------------------------------------------------------------*/ |
367 | 75 | ||
@@ -398,7 +106,7 @@ using namespace PW3270_NAMESPACE; | @@ -398,7 +106,7 @@ using namespace PW3270_NAMESPACE; | ||
398 | extern "C" { | 106 | extern "C" { |
399 | 107 | ||
400 | static PW3270_NAMESPACE::session * factory(const char *name) { | 108 | static PW3270_NAMESPACE::session * factory(const char *name) { |
401 | - return new plugin(lib3270_get_default_session_handle()); | 109 | + return session::create_local(lib3270_get_default_session_handle()); |
402 | } | 110 | } |
403 | 111 | ||
404 | LIB3270_EXPORT int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal) { | 112 | LIB3270_EXPORT int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal) { |