diff --git a/src/include/lib3270.h b/src/include/lib3270.h index d5a75bd..560ef05 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -275,21 +275,6 @@ #define LIB3270_SSL_FAILED LIB3270_SSL_UNSECURE - /** - * Notification message types. - * - */ - typedef enum _LIB3270_NOTIFY - { - LIB3270_NOTIFY_INFO, /**< Simple information dialog */ - LIB3270_NOTIFY_WARNING, - LIB3270_NOTIFY_ERROR, - LIB3270_NOTIFY_CRITICAL, /**< Critical error, user can abort application */ - - LIB3270_NOTIFY_USER /**< Reserved, always the last one */ - } LIB3270_NOTIFY; - - #ifdef __cplusplus extern "C" { #endif @@ -1018,17 +1003,6 @@ */ LIB3270_EXPORT const char * lib3270_get_revision(void); - /** - * Pop up an error dialog, based on an error number. - * - * @param hSession Session handle - * @param errn Error number (errno). - * @param fmt Message format - * @param ... Arguments for message - */ - LIB3270_EXPORT void lib3270_popup_an_errno(H3270 *hSession, int errn, const char *fmt, ...); - - LIB3270_EXPORT char * lib3270_vsprintf(const char *fmt, va_list args); LIB3270_EXPORT int lib3270_clear_operator_error(H3270 *hSession); diff --git a/src/include/lib3270/popup.h b/src/include/lib3270/popup.h index eb45efb..644dd3f 100644 --- a/src/include/lib3270/popup.h +++ b/src/include/lib3270/popup.h @@ -37,9 +37,35 @@ extern "C" { #endif + /** + * Notification message types. + * + */ + typedef enum _LIB3270_NOTIFY + { + LIB3270_NOTIFY_INFO, /**< Simple information dialog */ + LIB3270_NOTIFY_WARNING, + LIB3270_NOTIFY_ERROR, + LIB3270_NOTIFY_CRITICAL, /**< Critical error, user can abort application */ + + LIB3270_NOTIFY_USER /**< Reserved, always the last one */ + } LIB3270_NOTIFY; + LIB3270_EXPORT void lib3270_set_popup_handler(int (*popup_handler)(H3270 *, void *, LIB3270_NOTIFY, const char *, const char *, const char *, va_list)); + + /** + * Pop up an error dialog, based on an error number. + * + * @param hSession Session handle + * @param errn Error number (errno). + * @param fmt Message format + * @param ... Arguments for message + */ + LIB3270_EXPORT void lib3270_popup_an_errno(H3270 *hSession, int errn, const char *fmt, ...); + LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...); + LIB3270_EXPORT void lib3270_popup_va(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, va_list); #ifdef __cplusplus } diff --git a/src/include/lib3270/session.h b/src/include/lib3270/session.h index d16fc7e..9f215ab 100644 --- a/src/include/lib3270/session.h +++ b/src/include/lib3270/session.h @@ -33,6 +33,7 @@ #define LIB3270_SESSION_H_INCLUDED 1 #include + #include #define LIB3270_LUNAME_LENGTH 16 #define LIB3270_FULL_MODEL_NAME_LENGTH 13 diff --git a/src/include/pw3270/v3270.h b/src/include/pw3270/v3270.h index 699ac4b..b80e075 100644 --- a/src/include/pw3270/v3270.h +++ b/src/include/pw3270/v3270.h @@ -34,6 +34,7 @@ #include #include #include + #include #define V3270_H_INCLUDED 1 diff --git a/src/lib3270/screen.c b/src/lib3270/screen.c index 8e8bf2f..fe0ec75 100644 --- a/src/lib3270/screen.c +++ b/src/lib3270/screen.c @@ -845,14 +845,19 @@ LIB3270_EXPORT void lib3270_set_popup_handler(int (*handler)(H3270 *, void *, LI LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) { va_list args; + va_start(args, fmt); + lib3270_popup_va(session, id, title, message, fmt, args); + va_end(args); +} + +LIB3270_EXPORT void lib3270_popup_va(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, va_list args) +{ CHECK_SESSION_HANDLE(session); trace("%s: title=%s msg=%s",__FUNCTION__,"3270 Error",message); - va_start(args, fmt); popup_handler(session,session->widget,id,title ? title : _( "3270 Error" ), message,fmt,args); - va_end(args); } LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr) diff --git a/src/plugins/rx3270/local.cc b/src/plugins/rx3270/local.cc index 01d6f02..16b02d0 100644 --- a/src/plugins/rx3270/local.cc +++ b/src/plugins/rx3270/local.cc @@ -88,6 +88,8 @@ int get_field_len(int baddr = -1); int get_next_unprotected(int baddr = -1); + int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...); + private: const char * (*_get_version)(void); @@ -114,6 +116,7 @@ int (*_get_cursor_addr)(H3270 *h); int (*_emulate_input)(H3270 *session, const char *s, int len, int pasting); int (*_get_next_unprotected)(H3270 *hSession, int baddr0); + void (*_popup_va)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, va_list); #ifdef WIN32 HMODULE hModule; @@ -247,7 +250,7 @@ dynamic::dynamic() { (void **) & _get_cursor_addr, "lib3270_get_cursor_address" }, { (void **) & _emulate_input, "lib3270_emulate_input" }, { (void **) & _get_next_unprotected, "lib3270_get_next_unprotected" }, - + { (void **) & _popup_va, "lib3270_popup_va" }, }; // Load lib3270.dll @@ -572,3 +575,16 @@ int dynamic::get_next_unprotected(int baddr) return _get_next_unprotected(hSession,baddr); return -1; } + +int dynamic::popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) +{ + if(hModule) + { + va_list args; + va_start(args, fmt); + _popup_va(hSession, id, title, message, fmt, args); + va_end(args); + return 0; + } + return -1; +} diff --git a/src/plugins/rx3270/pluginmain.cc b/src/plugins/rx3270/pluginmain.cc index 1fc5c38..bede975 100644 --- a/src/plugins/rx3270/pluginmain.cc +++ b/src/plugins/rx3270/pluginmain.cc @@ -107,6 +107,8 @@ char * get_clipboard(void); int set_clipboard(const char *text); + int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...); + protected: private: @@ -313,6 +315,15 @@ return lib3270_get_next_unprotected(hSession,baddr); } +int plugin::popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + lib3270_popup_va(hSession, id, title, message, fmt, args); + va_end(args); + return 0; +} + static int REXXENTRY Rexx_IO_exit(RexxExitContext *context, int exitnumber, int subfunction, PEXIT parmBlock) { trace("%s call with ExitNumber: %d Subfunction: %d",__FUNCTION__,(int) exitnumber, (int) subfunction); diff --git a/src/plugins/rx3270/rexx_methods.cc b/src/plugins/rx3270/rexx_methods.cc index 0e2da28..3db421e 100644 --- a/src/plugins/rx3270/rexx_methods.cc +++ b/src/plugins/rx3270/rexx_methods.cc @@ -35,6 +35,7 @@ #include "rx3270.h" #include #include + #include /*--[ Implement ]------------------------------------------------------------------------------------*/ @@ -491,3 +492,38 @@ RexxMethod2(int, rx3270_method_set_clipboard, CSELF, sessionPtr, CSTRING, text) return -1; } + +RexxMethod5(int, rx3270_method_popup, CSELF, sessionPtr, CSTRING, s_id, CSTRING, title, CSTRING, message, OPTIONAL_CSTRING, det) +{ + LIB3270_NOTIFY id = LIB3270_NOTIFY_INFO; + rx3270 * hSession = (rx3270 *) sessionPtr; + + if(!hSession) + return -1; + + if(*s_id) + { + static const struct _descr + { + char str; + LIB3270_NOTIFY id; + } descr[] = + { + { 'I', LIB3270_NOTIFY_INFO }, + { 'W', LIB3270_NOTIFY_WARNING }, + { 'E', LIB3270_NOTIFY_ERROR }, + { 'C', LIB3270_NOTIFY_CRITICAL }, + }; + + for(int f=0;f<4;f++) + { + if(toupper(*s_id) == descr[f].str) + { + id = descr[f].id; + trace("Using mode %c (%d)",toupper(*s_id),(int) id); + } + } + } + + return hSession->popup_dialog(id, title, message, "%s", det ? det : ""); +} diff --git a/src/plugins/rx3270/rx3270.cc b/src/plugins/rx3270/rx3270.cc index 11a4a0f..add0bf1 100644 --- a/src/plugins/rx3270/rx3270.cc +++ b/src/plugins/rx3270/rx3270.cc @@ -44,7 +44,7 @@ #endif // HAVE_SYSLOG #include - + #include static rx3270 * factory_default(const char *type); @@ -198,4 +198,8 @@ void rx3270::free(void *ptr) free(ptr); } +int rx3270::popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) +{ + return -1; +} diff --git a/src/plugins/rx3270/rx3270.cls b/src/plugins/rx3270/rx3270.cls index 1d06096..0ba87f4 100644 --- a/src/plugins/rx3270/rx3270.cls +++ b/src/plugins/rx3270/rx3270.cls @@ -82,6 +82,8 @@ ::METHOD GETCLIPBOARD EXTERNAL "LIBRARY rx3270 rx3270_method_get_clipboard" ::METHOD SETCLIPBOARD EXTERNAL "LIBRARY rx3270 rx3270_method_set_clipboard" +::METHOD POPUP EXTERNAL "LIBRARY rx3270 rx3270_method_popup" + ::method waitForStringAt use arg row, col, key, timeout if datatype(timeout) <> "NUM" diff --git a/src/plugins/rx3270/rx3270.h b/src/plugins/rx3270/rx3270.h index 1ae606a..51482d8 100644 --- a/src/plugins/rx3270/rx3270.h +++ b/src/plugins/rx3270/rx3270.h @@ -46,6 +46,7 @@ #include #include #include + #include #include #ifndef ETIMEDOUT @@ -114,6 +115,7 @@ REXX_METHOD_PROTOTYPE(rx3270_method_set_selection); REXX_METHOD_PROTOTYPE(rx3270_method_get_clipboard); REXX_METHOD_PROTOTYPE(rx3270_method_set_clipboard); + REXX_METHOD_PROTOTYPE(rx3270_method_popup); REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr); REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr); REXX_METHOD_PROTOTYPE(rx3270_method_input_text); @@ -198,6 +200,8 @@ virtual char * get_clipboard(void); virtual int set_clipboard(const char *text); + virtual int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...); + }; rx3270 * create_lib3270_instance(void); diff --git a/src/plugins/rx3270/rxapimain.cc b/src/plugins/rx3270/rxapimain.cc index 98592ec..6051547 100644 --- a/src/plugins/rx3270/rxapimain.cc +++ b/src/plugins/rx3270/rxapimain.cc @@ -153,6 +153,8 @@ RexxMethodEntry rx3270_methods[] = REXX_METHOD(rx3270_method_get_clipboard, rx3270_method_get_clipboard ), REXX_METHOD(rx3270_method_set_clipboard, rx3270_method_set_clipboard ), + REXX_METHOD(rx3270_method_popup, rx3270_method_popup ), + REXX_METHOD(rx3270_method_get_cursor_addr, rx3270_method_get_cursor_addr ), REXX_METHOD(rx3270_method_set_cursor_addr, rx3270_method_set_cursor_addr ), REXX_METHOD(rx3270_method_input_text, rx3270_method_input_text ), diff --git a/src/plugins/rx3270/sample/clipboard.rex b/src/plugins/rx3270/sample/clipboard.rex index 8e8fc73..da2208a 100644 --- a/src/plugins/rx3270/sample/clipboard.rex +++ b/src/plugins/rx3270/sample/clipboard.rex @@ -9,7 +9,7 @@ if host~connected() = 0 then do - say "Disconnected from host" + host~popup("error","Can't start script","Disconnected from host") return 0 end @@ -22,7 +22,7 @@ if host~WaitForReady(60) <> 0 then do - say "Timeout waiting for host" + host~popup("error","Failed","Timeout waiting for host response") return 0 end -- libgit2 0.21.2