Commit 6c6092190e1933d2982105f6de61c511738731b9

Authored by perry.werneck@gmail.com
1 parent 0a3c9668

Incluindo suporte para janelas popup no plugin rexx

src/include/lib3270.h
... ... @@ -275,21 +275,6 @@
275 275  
276 276 #define LIB3270_SSL_FAILED LIB3270_SSL_UNSECURE
277 277  
278   - /**
279   - * Notification message types.
280   - *
281   - */
282   - typedef enum _LIB3270_NOTIFY
283   - {
284   - LIB3270_NOTIFY_INFO, /**< Simple information dialog */
285   - LIB3270_NOTIFY_WARNING,
286   - LIB3270_NOTIFY_ERROR,
287   - LIB3270_NOTIFY_CRITICAL, /**< Critical error, user can abort application */
288   -
289   - LIB3270_NOTIFY_USER /**< Reserved, always the last one */
290   - } LIB3270_NOTIFY;
291   -
292   -
293 278 #ifdef __cplusplus
294 279 extern "C" {
295 280 #endif
... ... @@ -1018,17 +1003,6 @@
1018 1003 */
1019 1004 LIB3270_EXPORT const char * lib3270_get_revision(void);
1020 1005  
1021   - /**
1022   - * Pop up an error dialog, based on an error number.
1023   - *
1024   - * @param hSession Session handle
1025   - * @param errn Error number (errno).
1026   - * @param fmt Message format
1027   - * @param ... Arguments for message
1028   - */
1029   - LIB3270_EXPORT void lib3270_popup_an_errno(H3270 *hSession, int errn, const char *fmt, ...);
1030   -
1031   -
1032 1006 LIB3270_EXPORT char * lib3270_vsprintf(const char *fmt, va_list args);
1033 1007  
1034 1008 LIB3270_EXPORT int lib3270_clear_operator_error(H3270 *hSession);
... ...
src/include/lib3270/popup.h
... ... @@ -37,9 +37,35 @@
37 37 extern "C" {
38 38 #endif
39 39  
  40 + /**
  41 + * Notification message types.
  42 + *
  43 + */
  44 + typedef enum _LIB3270_NOTIFY
  45 + {
  46 + LIB3270_NOTIFY_INFO, /**< Simple information dialog */
  47 + LIB3270_NOTIFY_WARNING,
  48 + LIB3270_NOTIFY_ERROR,
  49 + LIB3270_NOTIFY_CRITICAL, /**< Critical error, user can abort application */
  50 +
  51 + LIB3270_NOTIFY_USER /**< Reserved, always the last one */
  52 + } LIB3270_NOTIFY;
  53 +
40 54 LIB3270_EXPORT void lib3270_set_popup_handler(int (*popup_handler)(H3270 *, void *, LIB3270_NOTIFY, const char *, const char *, const char *, va_list));
  55 +
  56 + /**
  57 + * Pop up an error dialog, based on an error number.
  58 + *
  59 + * @param hSession Session handle
  60 + * @param errn Error number (errno).
  61 + * @param fmt Message format
  62 + * @param ... Arguments for message
  63 + */
  64 + LIB3270_EXPORT void lib3270_popup_an_errno(H3270 *hSession, int errn, const char *fmt, ...);
  65 +
41 66 LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...);
42 67  
  68 + LIB3270_EXPORT void lib3270_popup_va(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, va_list);
43 69  
44 70 #ifdef __cplusplus
45 71 }
... ...
src/include/lib3270/session.h
... ... @@ -33,6 +33,7 @@
33 33  
34 34 #define LIB3270_SESSION_H_INCLUDED 1
35 35 #include <sys/time.h>
  36 + #include <lib3270/popup.h>
36 37  
37 38 #define LIB3270_LUNAME_LENGTH 16
38 39 #define LIB3270_FULL_MODEL_NAME_LENGTH 13
... ...
src/include/pw3270/v3270.h
... ... @@ -34,6 +34,7 @@
34 34 #include <gtk/gtk.h>
35 35 #include <lib3270/config.h>
36 36 #include <lib3270.h>
  37 + #include <lib3270/popup.h>
37 38  
38 39 #define V3270_H_INCLUDED 1
39 40  
... ...
src/lib3270/screen.c
... ... @@ -845,14 +845,19 @@ LIB3270_EXPORT void lib3270_set_popup_handler(int (*handler)(H3270 *, void *, LI
845 845 LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...)
846 846 {
847 847 va_list args;
  848 + va_start(args, fmt);
  849 + lib3270_popup_va(session, id, title, message, fmt, args);
  850 + va_end(args);
  851 +}
  852 +
  853 +LIB3270_EXPORT void lib3270_popup_va(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, va_list args)
  854 +{
848 855  
849 856 CHECK_SESSION_HANDLE(session);
850 857  
851 858 trace("%s: title=%s msg=%s",__FUNCTION__,"3270 Error",message);
852 859  
853   - va_start(args, fmt);
854 860 popup_handler(session,session->widget,id,title ? title : _( "3270 Error" ), message,fmt,args);
855   - va_end(args);
856 861 }
857 862  
858 863 LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr)
... ...
src/plugins/rx3270/local.cc
... ... @@ -88,6 +88,8 @@
88 88 int get_field_len(int baddr = -1);
89 89 int get_next_unprotected(int baddr = -1);
90 90  
  91 + int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...);
  92 +
91 93 private:
92 94  
93 95 const char * (*_get_version)(void);
... ... @@ -114,6 +116,7 @@
114 116 int (*_get_cursor_addr)(H3270 *h);
115 117 int (*_emulate_input)(H3270 *session, const char *s, int len, int pasting);
116 118 int (*_get_next_unprotected)(H3270 *hSession, int baddr0);
  119 + void (*_popup_va)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, va_list);
117 120  
118 121 #ifdef WIN32
119 122 HMODULE hModule;
... ... @@ -247,7 +250,7 @@ dynamic::dynamic()
247 250 { (void **) & _get_cursor_addr, "lib3270_get_cursor_address" },
248 251 { (void **) & _emulate_input, "lib3270_emulate_input" },
249 252 { (void **) & _get_next_unprotected, "lib3270_get_next_unprotected" },
250   -
  253 + { (void **) & _popup_va, "lib3270_popup_va" },
251 254 };
252 255  
253 256 // Load lib3270.dll
... ... @@ -572,3 +575,16 @@ int dynamic::get_next_unprotected(int baddr)
572 575 return _get_next_unprotected(hSession,baddr);
573 576 return -1;
574 577 }
  578 +
  579 +int dynamic::popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...)
  580 +{
  581 + if(hModule)
  582 + {
  583 + va_list args;
  584 + va_start(args, fmt);
  585 + _popup_va(hSession, id, title, message, fmt, args);
  586 + va_end(args);
  587 + return 0;
  588 + }
  589 + return -1;
  590 +}
... ...
src/plugins/rx3270/pluginmain.cc
... ... @@ -107,6 +107,8 @@
107 107 char * get_clipboard(void);
108 108 int set_clipboard(const char *text);
109 109  
  110 + int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...);
  111 +
110 112 protected:
111 113  
112 114 private:
... ... @@ -313,6 +315,15 @@
313 315 return lib3270_get_next_unprotected(hSession,baddr);
314 316 }
315 317  
  318 +int plugin::popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...)
  319 +{
  320 + va_list args;
  321 + va_start(args, fmt);
  322 + lib3270_popup_va(hSession, id, title, message, fmt, args);
  323 + va_end(args);
  324 + return 0;
  325 +}
  326 +
316 327 static int REXXENTRY Rexx_IO_exit(RexxExitContext *context, int exitnumber, int subfunction, PEXIT parmBlock)
317 328 {
318 329 trace("%s call with ExitNumber: %d Subfunction: %d",__FUNCTION__,(int) exitnumber, (int) subfunction);
... ...
src/plugins/rx3270/rexx_methods.cc
... ... @@ -35,6 +35,7 @@
35 35 #include "rx3270.h"
36 36 #include <time.h>
37 37 #include <string.h>
  38 + #include <ctype.h>
38 39  
39 40 /*--[ Implement ]------------------------------------------------------------------------------------*/
40 41  
... ... @@ -491,3 +492,38 @@ RexxMethod2(int, rx3270_method_set_clipboard, CSELF, sessionPtr, CSTRING, text)
491 492 return -1;
492 493 }
493 494  
  495 +
  496 +RexxMethod5(int, rx3270_method_popup, CSELF, sessionPtr, CSTRING, s_id, CSTRING, title, CSTRING, message, OPTIONAL_CSTRING, det)
  497 +{
  498 + LIB3270_NOTIFY id = LIB3270_NOTIFY_INFO;
  499 + rx3270 * hSession = (rx3270 *) sessionPtr;
  500 +
  501 + if(!hSession)
  502 + return -1;
  503 +
  504 + if(*s_id)
  505 + {
  506 + static const struct _descr
  507 + {
  508 + char str;
  509 + LIB3270_NOTIFY id;
  510 + } descr[] =
  511 + {
  512 + { 'I', LIB3270_NOTIFY_INFO },
  513 + { 'W', LIB3270_NOTIFY_WARNING },
  514 + { 'E', LIB3270_NOTIFY_ERROR },
  515 + { 'C', LIB3270_NOTIFY_CRITICAL },
  516 + };
  517 +
  518 + for(int f=0;f<4;f++)
  519 + {
  520 + if(toupper(*s_id) == descr[f].str)
  521 + {
  522 + id = descr[f].id;
  523 + trace("Using mode %c (%d)",toupper(*s_id),(int) id);
  524 + }
  525 + }
  526 + }
  527 +
  528 + return hSession->popup_dialog(id, title, message, "%s", det ? det : "");
  529 +}
... ...
src/plugins/rx3270/rx3270.cc
... ... @@ -44,7 +44,7 @@
44 44 #endif // HAVE_SYSLOG
45 45  
46 46 #include <string.h>
47   -
  47 + #include <stdarg.h>
48 48  
49 49 static rx3270 * factory_default(const char *type);
50 50  
... ... @@ -198,4 +198,8 @@ void rx3270::free(void *ptr)
198 198 free(ptr);
199 199 }
200 200  
  201 +int rx3270::popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...)
  202 +{
  203 + return -1;
  204 +}
201 205  
... ...
src/plugins/rx3270/rx3270.cls
... ... @@ -82,6 +82,8 @@
82 82 ::METHOD GETCLIPBOARD EXTERNAL "LIBRARY rx3270 rx3270_method_get_clipboard"
83 83 ::METHOD SETCLIPBOARD EXTERNAL "LIBRARY rx3270 rx3270_method_set_clipboard"
84 84  
  85 +::METHOD POPUP EXTERNAL "LIBRARY rx3270 rx3270_method_popup"
  86 +
85 87 ::method waitForStringAt
86 88 use arg row, col, key, timeout
87 89 if datatype(timeout) <> "NUM"
... ...
src/plugins/rx3270/rx3270.h
... ... @@ -46,6 +46,7 @@
46 46 #include <stdio.h>
47 47 #include <lib3270.h>
48 48 #include <lib3270/log.h>
  49 + #include <lib3270/popup.h>
49 50 #include <stdarg.h>
50 51  
51 52 #ifndef ETIMEDOUT
... ... @@ -114,6 +115,7 @@
114 115 REXX_METHOD_PROTOTYPE(rx3270_method_set_selection);
115 116 REXX_METHOD_PROTOTYPE(rx3270_method_get_clipboard);
116 117 REXX_METHOD_PROTOTYPE(rx3270_method_set_clipboard);
  118 + REXX_METHOD_PROTOTYPE(rx3270_method_popup);
117 119 REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr);
118 120 REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr);
119 121 REXX_METHOD_PROTOTYPE(rx3270_method_input_text);
... ... @@ -198,6 +200,8 @@
198 200 virtual char * get_clipboard(void);
199 201 virtual int set_clipboard(const char *text);
200 202  
  203 + virtual int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...);
  204 +
201 205 };
202 206  
203 207 rx3270 * create_lib3270_instance(void);
... ...
src/plugins/rx3270/rxapimain.cc
... ... @@ -153,6 +153,8 @@ RexxMethodEntry rx3270_methods[] =
153 153 REXX_METHOD(rx3270_method_get_clipboard, rx3270_method_get_clipboard ),
154 154 REXX_METHOD(rx3270_method_set_clipboard, rx3270_method_set_clipboard ),
155 155  
  156 + REXX_METHOD(rx3270_method_popup, rx3270_method_popup ),
  157 +
156 158 REXX_METHOD(rx3270_method_get_cursor_addr, rx3270_method_get_cursor_addr ),
157 159 REXX_METHOD(rx3270_method_set_cursor_addr, rx3270_method_set_cursor_addr ),
158 160 REXX_METHOD(rx3270_method_input_text, rx3270_method_input_text ),
... ...
src/plugins/rx3270/sample/clipboard.rex
... ... @@ -9,7 +9,7 @@
9 9  
10 10 if host~connected() = 0 then
11 11 do
12   - say "Disconnected from host"
  12 + host~popup("error","Can't start script","Disconnected from host")
13 13 return 0
14 14 end
15 15  
... ... @@ -22,7 +22,7 @@
22 22  
23 23 if host~WaitForReady(60) <> 0 then
24 24 do
25   - say "Timeout waiting for host"
  25 + host~popup("error","Failed","Timeout waiting for host response")
26 26 return 0
27 27 end
28 28  
... ...