diff --git a/pw3270.cbp b/pw3270.cbp
index 54b62c2..45d0e15 100644
--- a/pw3270.cbp
+++ b/pw3270.cbp
@@ -61,6 +61,13 @@
+
+
+
+
+
+
+
@@ -76,6 +83,7 @@
+
diff --git a/src/classlib/classlib.cbp b/src/classlib/classlib.cbp
index bcc774d..342adfb 100644
--- a/src/classlib/classlib.cbp
+++ b/src/classlib/classlib.cbp
@@ -36,7 +36,6 @@
-
diff --git a/src/classlib/exception.cc b/src/classlib/exception.cc
index bb7b611..c0985c2 100644
--- a/src/classlib/exception.cc
+++ b/src/classlib/exception.cc
@@ -34,7 +34,7 @@
/*--[ Implement ]--------------------------------------------------------------------------------------------------*/
- namespace pw3270
+ namespace PW3270_NAMESPACE
{
exception::exception(int code, const char *fmt, ...)
diff --git a/src/classlib/local.cc b/src/classlib/local.cc
index 4cc36e0..05fbb28 100644
--- a/src/classlib/local.cc
+++ b/src/classlib/local.cc
@@ -111,7 +111,7 @@
}
- namespace pw3270
+ namespace PW3270_NAMESPACE
{
class local : public session
diff --git a/src/classlib/remote.cc b/src/classlib/remote.cc
index 646f0e9..8c12de7 100644
--- a/src/classlib/remote.cc
+++ b/src/classlib/remote.cc
@@ -53,7 +53,7 @@
/*--[ Implement ]--------------------------------------------------------------------------------------------------*/
- namespace pw3270
+ namespace PW3270_NAMESPACE
{
class remote : public session
diff --git a/src/classlib/session.cc b/src/classlib/session.cc
index 5efb804..6b2bf8f 100644
--- a/src/classlib/session.cc
+++ b/src/classlib/session.cc
@@ -40,7 +40,7 @@
/*--[ Implement ]--------------------------------------------------------------------------------------------------*/
- namespace pw3270
+ namespace PW3270_NAMESPACE
{
session * session::first = 0;
session * session::last = 0;
diff --git a/src/classlib/testprogram.cc b/src/classlib/testprogram.cc
index d2e7708..db3a4ef 100644
--- a/src/classlib/testprogram.cc
+++ b/src/classlib/testprogram.cc
@@ -31,7 +31,7 @@
#include
using namespace std;
- using namespace pw3270;
+ using namespace PW3270_NAMESPACE;
/*--[ Implement ]------------------------------------------------------------------------------------*/
diff --git a/src/include/pw3270/class.h b/src/include/pw3270/class.h
index 578737e..1042f8e 100644
--- a/src/include/pw3270/class.h
+++ b/src/include/pw3270/class.h
@@ -51,7 +51,9 @@
#include
#include
- namespace pw3270
+ #define PW3270_NAMESPACE h3270
+
+ namespace PW3270_NAMESPACE
{
using namespace std;
diff --git a/src/plugins/rx3270/Makefile.in b/src/plugins/rx3270/Makefile.in
index 7ee8149..6203532 100644
--- a/src/plugins/rx3270/Makefile.in
+++ b/src/plugins/rx3270/Makefile.in
@@ -29,7 +29,8 @@
MODULE_NAME=rx3270
DEPENDS=*.h ../../include/*.h ../../include/lib3270/*.h Makefile
PLUGIN_SRC=pluginmain.cc
-EXTAPI_SRC=rxapimain.cc text.cc typed_routines.cc local.cc remote.cc rexx_methods.cc rx3270.cc exception.cc
+# EXTAPI_SRC=rxapimain.cc text.cc typed_routines.cc local.cc remote.cc rexx_methods.cc rx3270.cc exception.cc
+EXTAPI_SRC=rxapimain.cc typed_routines.cc rexx_methods.cc
#---[ Tools ]------------------------------------------------------------------
@@ -43,7 +44,10 @@ CFLAGS=@REXX_CFLAGS@ @DBUS_CFLAGS@
REXX_HOME=@REXX_HOME@
REXXLIBDIR=$(libdir)/ooRexx
+CLASSLIBDIR=../../classlib
+
include ../../include/plugin.mak
+include $(CLASSLIBDIR)/class.mak
#---[ Debug Targets ]----------------------------------------------------------
@@ -52,7 +56,7 @@ $(BINDBG)/$(PLUGIN_NAME): $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJDBG)/$(
@$(MKDIR) `dirname $@`
@$(CXX) $(DLL_FLAGS) @LDSOFLAGS@ @DBGRPATH@ $(LDFLAGS) -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(GTK_LIBS) $(GLIB_LIBS) $(PW3270_LIBS)
-$(BINDBG)$(DLL_NAME).$(VERSION): $(foreach SRC, $(basename $(EXTAPI_SRC)), $(OBJDBG)/$(SRC)@OBJEXT@)
+$(BINDBG)$(DLL_NAME).$(VERSION): $(foreach SRC, $(basename $(EXTAPI_SRC) $(CLASS_SRC)), $(OBJDBG)/$(SRC)@OBJEXT@)
@echo " CCLD `basename $@`"
@$(MKDIR) `dirname $@`
@$(CXX) $(DLL_FLAGS) $(LDFLAGS) @LDSOFLAGS@ @DBGRPATH@ -o $@ $^ $(LIBS) $(LIB3270_LIBS)
diff --git a/src/plugins/rx3270/exception.cc b/src/plugins/rx3270/exception.cc
deleted file mode 100644
index 25b35b8..0000000
--- a/src/plugins/rx3270/exception.cc
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA, 02111-1307, USA
- *
- * Este programa está nomeado como exception.cc e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- */
-
- #include "rx3270.h"
-
-#ifdef HAVE_SYSLOG
- #include
-#endif // HAVE_SYSLOG
-
- #include
- #include
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-rx3270::exception::exception(const char *fmt, ...)
-{
- va_list arg_ptr;
-
- va_start(arg_ptr, fmt);
- vsnprintf(this->msg,4095,fmt,arg_ptr);
- va_end(arg_ptr);
-
- this->code = Rexx_Error_Application_error;
-}
-
-rx3270::exception::exception(int code, const char *fmt, ...)
-{
- va_list arg_ptr;
-
- va_start(arg_ptr, fmt);
- vsnprintf(this->msg,4095,fmt,arg_ptr);
- va_end(arg_ptr);
-
- this->code = code;
-
-}
-
-
-const char * rx3270::exception::getMessage(void)
-{
- return this->msg;
-}
-
-void rx3270::exception::logMessage(void)
-{
-#ifdef HAVE_SYSLOG
- openlog(PACKAGE_NAME, LOG_NDELAY, LOG_USER);
- syslog(LOG_INFO,"%s",this->getMessage());
- closelog();
-#else
- fprintf(stderr,"%s",this->getMessage());
-#endif
-}
-
-void rx3270::exception::RaiseException(RexxMethodContext *context)
-{
- trace("%s: %s",__FUNCTION__,this->getMessage());
- logMessage();
-
- context->RaiseException1( this->code,
- context->NewStringFromAsciiz(this->msg)
- );
-}
-
-void rx3270::exception::RaiseException(RexxCallContext *context)
-{
- trace("%s: %s",__FUNCTION__,this->getMessage());
- logMessage();
-
- context->RaiseException1( this->code,
- context->NewStringFromAsciiz(this->msg)
- );
-}
-
-const char * rx3270::exception::what() const throw()
-{
- return this->msg;
-}
diff --git a/src/plugins/rx3270/local.cc b/src/plugins/rx3270/local.cc
deleted file mode 100644
index 3086d21..0000000
--- a/src/plugins/rx3270/local.cc
+++ /dev/null
@@ -1,596 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA, 02111-1307, USA
- *
- * Este programa está nomeado como local.cc e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- */
-
- #include "rx3270.h"
- #include
-
-#if !defined WIN32
- #include
- #include
-#endif
-
-#ifdef HAVE_SYSLOG
- #include
- #include
-#endif // HAVE_SYSLOG
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/ms684179(v=vs.85).aspx
-#ifndef LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
- #define LOAD_LIBRARY_SEARCH_DEFAULT_DIRS 0x00001000
-#endif // LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
-
-#ifndef LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
- #define LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR 0x00000100
-#endif // LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
-
-/*--[ Class definition ]-----------------------------------------------------------------------------*/
-
- class dynamic : public rx3270
- {
- public:
- dynamic();
- ~dynamic();
-
- char * get_version(void);
- LIB3270_CSTATE get_cstate(void);
- int disconnect(void);
- int connect(const char *uri, bool wait = true);
- bool is_connected(void);
- bool is_ready(void);
-
- int iterate(bool wait);
- int wait(int seconds);
- int wait_for_ready(int seconds);
-
- char * get_text(int baddr, size_t len);
- char * get_text_at(int row, int col, size_t sz);
- int cmp_text_at(int row, int col, const char *text);
- int set_text_at(int row, int col, const char *str);
- int emulate_input(const char *str);
-
- int set_cursor_position(int row, int col);
- int set_cursor_addr(int addr);
- int get_cursor_addr(void);
-
- int set_toggle(LIB3270_TOGGLE ix, bool value);
-
- int enter(void);
- int pfkey(int key);
- int pakey(int key);
-
- int get_field_start(int baddr = -1);
- 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, ...);
-
- int quit(void);
-
- private:
-
- const char * (*_get_version)(void);
- LIB3270_CSTATE (*_get_connection_state)(H3270 *h);
- int (*_disconnect)(H3270 *h);
- int (*_connect)(H3270 *h,const char *n, int wait);
- int (*_is_connected)(H3270 *h);
- void (*_main_iterate)(H3270 *h, int wait);
- int (*_wait)(H3270 *hSession, int seconds);
- int (*_enter)(H3270 *hSession);
- int (*_pfkey)(H3270 *hSession, int key);
- int (*_pakey)(H3270 *hSession, int key);
- int (*_wait_for_ready)(H3270 *hSession, int seconds);
- char * (*_get_text)(H3270 *h, int offset, int len);
- char * (*_get_text_at)(H3270 *h, int row, int col, int len);
- int (*_cmp_text_at)(H3270 *h, int row, int col, const char *text);
- int (*_set_text_at)(H3270 *h, int row, int col, const unsigned char *str);
- int (*_is_ready)(H3270 *h);
- int (*_set_cursor_position)(H3270 *h, int row, int col);
- int (*_set_toggle)(H3270 *h, LIB3270_TOGGLE ix, int value);
- int (*_get_field_start)(H3270 *h, int baddr);
- int (*_get_field_len)(H3270 *h, int baddr);
- int (*_set_cursor_addr)(H3270 *h, int addr);
- 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;
-#else
- void * hModule;
-#endif // WIN32
-
- H3270 * hSession;
-
- };
-
-/*--[ Globals ]--------------------------------------------------------------------------------------*/
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-rx3270 * rx3270::create_local(void)
-{
- trace("%s",__FUNCTION__);
- return new dynamic();
-}
-
-#ifdef WIN32
-static int get_datadir(LPSTR datadir)
-{
- HKEY hKey = 0;
- unsigned long datalen = strlen(datadir);
-
- *datadir = 0;
-
- if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\pw3270",0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS)
- {
- unsigned long datatype; // #defined in winnt.h (predefined types 0-11)
- if(RegQueryValueExA(hKey,"datadir",NULL,&datatype,(LPBYTE) datadir,&datalen) != ERROR_SUCCESS)
- *datadir = 0;
- RegCloseKey(hKey);
- }
-
- return *datadir;
-}
-#endif // WIN32
-
-extern "C"
-{
-
-static void loghandler(H3270 *session, const char *module, int rc, const char *fmt, va_list args)
-{
-#ifdef HAVE_SYSLOG
- openlog(PACKAGE_NAME, LOG_NDELAY, LOG_USER);
- vsyslog(LOG_INFO,fmt,args);
- closelog();
-#endif // HAVE_SYSLOG
-}
-
-static void tracehandler(H3270 *session, const char *fmt, va_list args)
-{
-#ifdef HAVE_SYSLOG
-
- #define MAX_LOG_LENGTH 200
-
- static char line[MAX_LOG_LENGTH+1];
- char temp[MAX_LOG_LENGTH];
- char * ptr;
- size_t len = strlen(line);
-
- vsnprintf(temp,MAX_LOG_LENGTH-len,fmt,args);
-
- ptr = strchr(temp,'\n');
- if(!ptr)
- {
- strncat(line,temp,MAX_LOG_LENGTH);
- if(strlen(line) >= MAX_LOG_LENGTH)
- {
- openlog(PACKAGE_NAME, LOG_NDELAY, LOG_USER);
- syslog(LOG_INFO,line);
- closelog();
- *line = 0;
- }
- return;
- }
-
- *ptr = 0;
- strncat(line,temp,MAX_LOG_LENGTH);
-
- openlog(PACKAGE_NAME, LOG_NDELAY, LOG_USER);
- syslog(LOG_DEBUG,line);
- closelog();
-
- strncpy(line,ptr+1,MAX_LOG_LENGTH);
-
-#endif // HAVE_SYSLOG
-}
-
-}
-
-dynamic::dynamic()
-{
- H3270 * (*lib3270_new)(const char *);
- void (*set_log_handler)(void (*loghandler)(H3270 *, const char *, int, const char *, va_list));
- void (*set_trace_handler)( void (*handler)(H3270 *session, const char *fmt, va_list args) );
-
- struct _call
- {
- void **entry;
- const char * name;
- } call[] =
- {
- { (void **) & lib3270_new, "lib3270_session_new" },
- { (void **) & set_log_handler, "lib3270_set_log_handler" },
- { (void **) & set_trace_handler, "lib3270_set_trace_handler" },
- { (void **) & _get_version, "lib3270_get_version" },
- { (void **) & _get_connection_state, "lib3270_get_connection_state" },
- { (void **) & _disconnect, "lib3270_disconnect" },
- { (void **) & _connect, "lib3270_connect" },
- { (void **) & _is_connected, "lib3270_in_tn3270e" },
- { (void **) & _main_iterate, "lib3270_main_iterate" },
- { (void **) & _wait, "lib3270_wait" },
- { (void **) & _enter, "lib3270_enter" },
- { (void **) & _pfkey, "lib3270_pfkey" },
- { (void **) & _pakey, "lib3270_pakey" },
- { (void **) & _wait_for_ready, "lib3270_wait_for_ready" },
- { (void **) & _get_text, "lib3270_get_text" },
- { (void **) & _get_text_at, "lib3270_get_text_at" },
- { (void **) & _cmp_text_at, "lib3270_cmp_text_at" },
- { (void **) & _set_text_at, "lib3270_set_string_at" },
- { (void **) & _is_ready, "lib3270_is_ready" },
- { (void **) & _set_cursor_position, "lib3270_set_cursor_position" },
- { (void **) & _set_toggle, "lib3270_set_toggle" },
- { (void **) & _get_field_start, "lib3270_get_field_start" },
- { (void **) & _get_field_len, "lib3270_get_field_len" },
- { (void **) & _set_cursor_addr, "lib3270_set_cursor_address" },
- { (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
-#ifdef WIN32
- static const char *dllname = "lib3270.dll." PACKAGE_VERSION;
-
- HMODULE kernel;
- HANDLE cookie = NULL;
- DWORD rc;
- HANDLE WINAPI (*AddDllDirectory)(PCWSTR NewDirectory);
- BOOL WINAPI (*RemoveDllDirectory)(HANDLE Cookie);
- UINT errorMode;
- char datadir[4096];
- char buffer[4096];
-
- kernel = LoadLibrary("kernel32.dll");
- AddDllDirectory = (HANDLE WINAPI (*)(PCWSTR)) GetProcAddress(kernel,"AddDllDirectory");
- RemoveDllDirectory = (BOOL WINAPI (*)(HANDLE)) GetProcAddress(kernel,"RemoveDllDirectory");
-
- // Notify user in case of error loading protocol DLL
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms680621(v=vs.85).aspx
- errorMode = SetErrorMode(1);
-
- memset(datadir,' ',4095);
- datadir[4095] = 0;
-
- if(get_datadir(datadir))
- {
- trace("Datadir=[%s] AddDllDirectory=%p RemoveDllDirectory=%p\n",datadir,AddDllDirectory,RemoveDllDirectory);
-
- if(AddDllDirectory)
- {
- wchar_t *path = (wchar_t *) malloc(4096*sizeof(wchar_t));
- mbstowcs(path, datadir, 4095);
- cookie = AddDllDirectory(path);
- free(path);
- }
-
-#ifdef DEBUG
- snprintf(buffer,4096,"%s\\.bin\\Debug\\%s",datadir,dllname);
-#else
- snprintf(buffer,4096,"%s\\%s",datadir,dllname);
-#endif // DEBUG
-
- trace("Loading [%s] [%s]",buffer,datadir);
- hModule = LoadLibrary(buffer);
-
- trace("Module=%p rc=%d",hModule,(int) GetLastError());
-
- if(hModule == NULL)
- {
- // Enable DLL error popup and try again with full path
- SetErrorMode(0);
- hModule = LoadLibraryEx(buffer,NULL,LOAD_LIBRARY_SEARCH_DEFAULT_DIRS|LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
- }
-
- rc = GetLastError();
-
- trace("%s hModule=%p rc=%d",buffer,hModule,(int) rc);
- }
- else
- {
- hModule = LoadLibrary(dllname);
- rc = GetLastError();
- }
-
- SetErrorMode(errorMode);
-
- trace("%s hModule=%p rc=%d",dllname,hModule,(int) rc);
-
- if(cookie && RemoveDllDirectory)
- RemoveDllDirectory(cookie);
-
- if(kernel)
- FreeLibrary(kernel);
-
- if(!hModule)
- throw exception("Can't load %s",dllname);
-
-
-#else
- dlerror();
-
- hModule = dlopen("lib3270.so." PACKAGE_VERSION, RTLD_NOW);
- if(!hModule)
- {
- throw exception("Can't load lib3270: %s",dlerror());
- return;
- }
-
-#endif // WIN32
-
- // Load entry points
- for(unsigned int f = 0; f < (sizeof (call) / sizeof ((call)[0]));f++)
- {
-#ifdef WIN32
- *call[f].entry = (void *) GetProcAddress(hModule,call[f].name);
-#else
- *call[f].entry = dlsym(hModule,call[f].name);
-#endif // WIN32
-
- if(!*call[f].entry)
- {
-#ifndef WIN32
- throw exception("Error \"%s\" loading lib3270::%s",dlerror(),call[f].name);
- dlclose(hModule);
-#else
- throw exception("Error loading lib3270::%s",call[f].name);
- FreeLibrary(hModule);
-#endif // !WIN32
- hModule = NULL;
- return;
- }
- }
-
- // Get Session handle, setup base callbacks
- set_log_handler(loghandler);
- set_trace_handler(tracehandler);
- this->hSession = lib3270_new("");
-
-}
-
-dynamic::~dynamic()
-{
- static void (*session_free)(void *h);
-
- trace("%s",__FUNCTION__);
-
- if(!hModule)
- return;
-
-#ifdef WIN32
-
- session_free = (void (*)(void *h)) GetProcAddress(hModule,"lib3270_session_free");
-
- if(session_free)
- session_free(hSession);
-
- FreeLibrary(hModule);
-
-#else
-
- session_free = (void (*)(void *h)) dlsym(hModule,"lib3270_session_free");
-
- if(session_free)
- session_free(hSession);
-
- dlclose(hModule);
-
-#endif // WIN32
-
-}
-
-char * dynamic::get_version(void)
-{
- if(!hModule)
- return NULL;
- return strdup(_get_version());
-}
-
-LIB3270_CSTATE dynamic::get_cstate(void)
-{
- if(!hModule)
- return (LIB3270_CSTATE) -1;
- return _get_connection_state(hSession);
-}
-
-int dynamic::disconnect(void)
-{
- if(!hModule)
- return -1;
- return _disconnect(hSession);
-}
-
-int dynamic::connect(const char *uri, bool wait)
-{
- if(!hModule)
- return -1;
- return _connect(hSession,uri,(int) wait);
-}
-
-bool dynamic::is_connected(void)
-{
- if(!hModule)
- return -1;
- return _is_connected(hSession) != 0;
-}
-
-bool dynamic::is_ready(void)
-{
- if(!hModule)
- return -1;
- return _is_ready(hSession) != 0;
-}
-
-int dynamic::iterate(bool wait)
-{
- if(!hModule)
- return -1;
-
- _main_iterate(hSession,wait);
-
- return 0;
-}
-
-int dynamic::wait(int seconds)
-{
- if(!hModule)
- return -1;
- return _wait(hSession,seconds);
-}
-
-int dynamic::wait_for_ready(int seconds)
-{
- if(!hModule)
- return -1;
- return _wait_for_ready(hSession,seconds);
-}
-
-char * dynamic::get_text(int offset, size_t len)
-{
- if(!hModule)
- return NULL;
- return _get_text(hSession,offset,len);
-}
-
-char * dynamic::get_text_at(int row, int col, size_t sz)
-{
- if(!hModule)
- return NULL;
- return _get_text_at(hSession,row,col,sz);
-}
-
-int dynamic::cmp_text_at(int row, int col, const char *text)
-{
- if(!hModule)
- return 0;
- return _cmp_text_at(hSession,row,col,text);
-}
-
-int dynamic::set_text_at(int row, int col, const char *str)
-{
- if(!hModule)
- return -1;
- return _set_text_at(hSession,row,col,(const unsigned char *) str);
-}
-
-int dynamic::set_cursor_position(int row, int col)
-{
- if(!hModule)
- return -1;
- return _set_cursor_position(hSession,row,col);
-}
-
-int dynamic::enter(void)
-{
- if(!hModule)
- return -1;
- return _enter(hSession);
-}
-
-int dynamic::pfkey(int key)
-{
- if(!hModule)
- return -1;
- return _pfkey(hSession,key);
-}
-
-int dynamic::pakey(int key)
-{
- if(!hModule)
- return -1;
- return _pakey(hSession,key);
-}
-
-int dynamic::set_toggle(LIB3270_TOGGLE ix, bool value)
-{
- if(hModule)
- return _set_toggle(hSession,ix,(int) value);
- return -1;
-}
-
-int dynamic::get_field_start(int baddr)
-{
- if(hModule)
- return _get_field_start(hSession,baddr);
- return -1;
-}
-
-int dynamic::get_field_len(int baddr)
-{
- if(hModule)
- return _get_field_len(hSession,baddr);
- return -1;
-}
-
-int dynamic::set_cursor_addr(int addr)
-{
- if(hModule)
- return _set_cursor_addr(hSession,addr);
- return -1;
-}
-
-int dynamic::get_cursor_addr(void)
-{
- if(hModule)
- return _get_cursor_addr(hSession);
- return -1;
-}
-
-int dynamic::emulate_input(const char *str)
-{
- if(hModule)
- return _emulate_input(hSession,str,-1,1);
- return -1;
-}
-
-int dynamic::get_next_unprotected(int baddr)
-{
- if(hModule)
- 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;
-}
-
-int dynamic::quit(void)
-{
- return EINVAL;
-}
diff --git a/src/plugins/rx3270/pluginmain.cc b/src/plugins/rx3270/pluginmain.cc
index 33a2dbc..ef4bfbd 100644
--- a/src/plugins/rx3270/pluginmain.cc
+++ b/src/plugins/rx3270/pluginmain.cc
@@ -47,6 +47,7 @@
#include
#include
#include
+ #include
/*--[ Globals ]--------------------------------------------------------------------------------------*/
@@ -69,7 +70,10 @@
/*--[ Plugin session object ]--------------------------------------------------------------------------------*/
- class plugin : public rx3270
+ using namespace std;
+ using namespace PW3270_NAMESPACE;
+
+ class plugin : public session
{
public:
plugin(H3270 *hSession);
@@ -77,7 +81,7 @@
void free(void *ptr);
- char * get_version(void);
+ string get_version(void);
LIB3270_CSTATE get_cstate(void);
int disconnect(void);
int connect(const char *uri, bool wait = true);
@@ -90,8 +94,8 @@
int wait(int seconds);
int wait_for_ready(int seconds);
- char * get_text(int baddr, size_t len);
- char * get_text_at(int row, int col, size_t sz);
+ string * get_text(int baddr, size_t len);
+ string * get_text_at(int row, int col, size_t sz);
int cmp_text_at(int row, int col, const char *text);
int set_text_at(int row, int col, const char *str);
@@ -111,13 +115,13 @@
int get_next_unprotected(int baddr = -1);
int set_copy(const char *text);
- char * get_copy(void);
+ string * get_copy(void);
- char * get_clipboard(void);
+ string * get_clipboard(void);
int set_clipboard(const char *text);
int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...);
- char * file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename);
+ string * file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename);
int quit(void);
@@ -365,7 +369,7 @@ extern "C"
/*--[ Implement ]------------------------------------------------------------------------------------*/
- static rx3270 * factory(const char *name)
+ static session * factory(const char *name)
{
return new plugin(lib3270_get_default_session_handle());
}
@@ -376,7 +380,7 @@ extern "C"
#if GTK_CHECK_VERSION(2,32,0)
g_mutex_init(&mutex);
#endif // GTK_CHECK_VERSION
- rx3270::set_plugin(factory);
+ session::set_plugin(factory);
return 0;
}
@@ -389,7 +393,7 @@ extern "C"
return 0;
}
- plugin::plugin(H3270 *hSession) : rx3270()
+ plugin::plugin(H3270 *hSession) : session()
{
this->hSession = hSession;
}
@@ -400,9 +404,9 @@ extern "C"
}
- char * plugin::get_version(void)
+ string plugin::get_version(void)
{
- return strdup(lib3270_get_version());
+ return string(lib3270_get_version());
}
LIB3270_CSTATE plugin::get_cstate(void)
@@ -461,9 +465,18 @@ extern "C"
return lib3270_wait_for_ready(hSession,seconds);
}
- char * plugin::get_text_at(int row, int col, size_t sz)
+ string * plugin::get_text_at(int row, int col, size_t sz)
{
- return lib3270_get_text_at(hSession,row,col,(int) sz);
+ char * ptr = lib3270_get_text_at(hSession,row,col,(int) sz);
+
+ if(ptr)
+ {
+ string *s = new string(ptr);
+ lib3270_free(ptr);
+ return s;
+ }
+
+ return new string("");
}
int plugin::cmp_text_at(int row, int col, const char *text)
@@ -496,9 +509,17 @@ extern "C"
lib3270_write_va_log(hSession,"REXX",fmt,args);
}
- char * plugin::get_text(int baddr, size_t len)
+ string * plugin::get_text(int baddr, size_t len)
{
- return lib3270_get_text(hSession,baddr,len);
+ char *ptr = lib3270_get_text(hSession,baddr,len);
+ if(ptr)
+ {
+ string *s = new string(ptr);
+ lib3270_free(ptr);
+ return s;
+ }
+
+ return new string("");
}
int plugin::get_field_start(int baddr)
@@ -517,15 +538,32 @@ extern "C"
return 0;
}
- char * plugin::get_copy(void)
+ string * plugin::get_copy(void)
{
- return v3270_get_copy(GTK_WIDGET(lib3270_get_widget(hSession)));
+ gchar *ptr = v3270_get_copy(GTK_WIDGET(lib3270_get_widget(hSession)));
+
+ if(ptr)
+ {
+ string *ret = new string((char *) ptr);
+ g_free(ptr);
+ return ret;
+ }
+
+ return NULL;
}
- char * plugin::get_clipboard(void)
+ string * plugin::get_clipboard(void)
{
- trace("%s toplevel=%p",__FUNCTION__,pw3270_get_toplevel());
- return gtk_clipboard_wait_for_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD));
+ gchar *ptr = gtk_clipboard_wait_for_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD));
+
+ if(ptr)
+ {
+ string *ret = new string((char *) ptr);
+ g_free(ptr);
+ return ret;
+ }
+
+ return NULL;
}
int plugin::set_clipboard(const char *text)
@@ -568,9 +606,18 @@ int plugin::popup_dialog(LIB3270_NOTIFY id , const char *title, const char *mess
return 0;
}
-char * plugin::file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename)
+string * plugin::file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename)
{
- return pw3270_file_chooser(action, script_name ? script_name : "rexx", title, filename, extension);
+ gchar *ptr = pw3270_file_chooser(action, script_name ? script_name : "rexx", title, filename, extension);
+
+ if(ptr)
+ {
+ string *s = new string((char *) ptr);
+ g_free(ptr);
+ return s;
+ }
+
+ return NULL;
}
int plugin::quit(void)
diff --git a/src/plugins/rx3270/remote.cc b/src/plugins/rx3270/remote.cc
deleted file mode 100644
index db902e2..0000000
--- a/src/plugins/rx3270/remote.cc
+++ /dev/null
@@ -1,1270 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA, 02111-1307, USA
- *
- * Este programa está nomeado como remote.cc e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- */
-
- #include "rx3270.h"
-
-#if defined(HAVE_DBUS)
- #include
- #include
-#endif // HAVE_DBUS
-
-#if defined(WIN32)
- #include
-#endif // WIN32
-
- #include
- #include
- #include
-
-/*--[ Class definition ]-----------------------------------------------------------------------------*/
-
- class remote : public rx3270
- {
- public:
- remote(const char *session);
- ~remote();
-
- char * get_revision(void);
- LIB3270_CSTATE get_cstate(void);
- int disconnect(void);
- int connect(const char *uri, bool wait = true);
- bool is_connected(void);
- bool is_ready(void);
-
- int iterate(bool wait);
- int wait(int seconds);
- int wait_for_ready(int seconds);
-
- char * get_text(int baddr, size_t len);
- char * get_text_at(int row, int col, size_t sz);
- int cmp_text_at(int row, int col, const char *text);
- int set_text_at(int row, int col, const char *str);
- int emulate_input(const char *str);
-
- int wait_for_text_at(int row, int col, const char *key, int timeout);
-
- int set_cursor_position(int row, int col);
- int set_cursor_addr(int addr);
- int get_cursor_addr(void);
-
- int set_toggle(LIB3270_TOGGLE ix, bool value);
-
- int enter(void);
- int pfkey(int key);
- int pakey(int key);
-
- int get_field_start(int baddr = -1);
- int get_field_len(int baddr = -1);
- int get_next_unprotected(int baddr = -1);
-
- char * get_clipboard(void);
- int set_clipboard(const char *text);
-
- int quit(void);
-
- private:
-#if defined(WIN32)
-
- HANDLE hPipe;
-
-#elif defined(HAVE_DBUS)
-
- DBusConnection * conn;
- char * dest;
- char * path;
- char * intf;
- DBusMessage * create_message(const char *method);
- DBusMessage * call(DBusMessage *msg);
- char * query_string(const char *method);
- int query_intval(const char *method);
-
- char * get_string(DBusMessage * msg);
- int get_intval(DBusMessage * msg);
-
-#endif
-
-
- };
-
-/*--[ Globals ]--------------------------------------------------------------------------------------*/
-
-#if defined(HAVE_DBUS)
- static const char * prefix_dest = "br.com.bb.";
- static const char * prefix_path = "/br/com/bb/";
-#endif // HAVE_DBUS
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-#if defined(HAVE_DBUS)
-DBusMessage * remote::create_message(const char *method)
-{
- DBusMessage * msg = dbus_message_new_method_call( this->dest, // Destination
- this->path, // Path
- this->intf, // Interface
- method); // method
-
- if (!msg)
- throw exception("Error creating message for method %s",method);
-
- return msg;
-}
-#endif // HAVE_DBUS
-
-rx3270 * rx3270::create_remote(const char *name)
-{
- return new remote(name);
-}
-
-
-#if defined(HAVE_DBUS)
-remote::remote(const char *name) : rx3270(REXX_DEFAULT_CHARSET,"UTF-8")
-#else
-remote::remote(const char *name)
-#endif // HAVE_DBUS
-{
-#if defined(WIN32)
- static DWORD dwMode = PIPE_READMODE_MESSAGE;
- char buffer[4096];
- char * str = strdup(name);
- char * ptr;
-
- hPipe = INVALID_HANDLE_VALUE;
-
- for(ptr=str;*ptr;ptr++)
- {
- if(*ptr == ':')
- *ptr = '_';
- else
- *ptr = tolower(*ptr);
- }
-
- snprintf(buffer,4095,"\\\\.\\pipe\\%s",str);
-
- free(str);
-
- if(!WaitNamedPipe(buffer,NMPWAIT_USE_DEFAULT_WAIT))
- {
- throw exception("Invalid service instance: %s",name);
- return;
- }
-
- hPipe = CreateFile(buffer,GENERIC_WRITE|GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
-
- if(hPipe == INVALID_HANDLE_VALUE)
- {
- throw exception("Can´t create service pipe %s",buffer);
- return;
- }
-
- if(!SetNamedPipeHandleState(hPipe,&dwMode,NULL,NULL))
- {
- throw exception("%s","Can´t set pipe state");
- CloseHandle(hPipe);
- hPipe = INVALID_HANDLE_VALUE;
- return;
- }
-
- // Connected
-
-#elif defined(HAVE_DBUS)
- DBusError err;
- int rc;
- char * str = strdup(name);
- char * ptr;
- char busname[4096];
- char pidname[10];
- int pid = (int) getpid();
-
- trace("%s str=%p",__FUNCTION__,str);
-
- for(ptr=str;*ptr;ptr++)
- *ptr = tolower(*ptr);
-
- ptr = strchr(str,':');
-
- if(ptr)
- {
- size_t sz;
-
- *(ptr++) = 0;
-
- // Build destination
- sz = strlen(ptr)+strlen(str)+strlen(prefix_dest)+2;
- dest = (char *) malloc(sz+1);
- strncpy(dest,prefix_dest,sz);
- strncat(dest,str,sz);
- strncat(dest,".",sz);
- strncat(dest,ptr,sz);
-
- // Build path
- sz = strlen(str)+strlen(prefix_path);
- path = (char *) malloc(sz+1);
- strncpy(path,prefix_path,sz);
- strncat(path,str,sz);
-
- // Build intf
- sz = strlen(str)+strlen(prefix_dest)+1;
- intf = (char *) malloc(sz+1);
- strncpy(intf,prefix_dest,sz);
- strncat(intf,str,sz);
-
- }
- else
- {
- size_t sz;
-
- // Build destination
- sz = strlen(str)+strlen(prefix_dest)+2;
- dest = (char *) malloc(sz+1);
- strncpy(dest,prefix_dest,sz);
- strncat(dest,str,sz);
-
- // Build path
- sz = strlen(str)+strlen(prefix_path);
- path = (char *) malloc(sz+1);
- strncpy(path,prefix_path,sz);
- strncat(path,str,sz);
-
- // Build intf
- sz = strlen(str)+strlen(prefix_dest)+1;
- intf = (char *) malloc(sz+1);
- strncpy(intf,prefix_dest,sz);
- strncat(intf,str,sz);
-
- }
-
- trace("DBUS:\nDestination:\t[%s]\nPath:\t\t[%s]\nInterface:\t[%s]",dest,path,intf);
-
- free(str);
-
- dbus_error_init(&err);
-
- conn = dbus_bus_get(DBUS_BUS_SESSION, &err);
- trace("dbus_bus_get conn=%p",conn);
-
- if (dbus_error_is_set(&err))
- {
- throw exception("DBUS Connection Error (%s)", err.message);
- dbus_error_free(&err);
- }
-
- if(!conn)
- {
- throw exception("%s", "DBUS Connection failed");
- return;
- }
-
- memset(pidname,0,10);
- for(int f = 0; f < 9 && pid > 0;f++)
- {
- pidname[f] = 'a'+(pid % 25);
- pid /= 25;
- }
-
- snprintf(busname, 4095, "%s.rx3270.br.com.bb",pidname);
-
- trace("Busname: [%s]",busname);
-
- rc = dbus_bus_request_name(conn, busname, DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
- trace("dbus_bus_request_name rc=%d",rc);
-
- if (dbus_error_is_set(&err))
- {
- throw exception("Name Error (%s)", err.message);
- dbus_error_free(&err);
- conn = NULL;
- return;
- }
-
- if(rc != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
- {
- trace("%s: DBUS request for name %s failed",__FUNCTION__, busname);
- throw exception("DBUS request for \"%s\" failed",name);
- conn = NULL;
- return;
- }
-
- trace("%s: Using DBUS name %s",__FUNCTION__,busname);
-
- DBusMessage * msg = create_message("setScript");
-
- if(msg)
- {
- const char * id = "r";
- static const dbus_int32_t flag = 1;
- dbus_message_append_args(msg, DBUS_TYPE_STRING, &id, DBUS_TYPE_INT32, &flag, DBUS_TYPE_INVALID);
- get_intval(call(msg));
- }
-
-#else
-
-#endif
-}
-
-remote::~remote()
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- CloseHandle(hPipe);
-
-#elif defined(HAVE_DBUS)
-
- try
- {
- DBusMessage * msg = create_message("setScript");
- if(msg)
- {
- const char * id = "r";
- static const dbus_int32_t flag = 0;
- dbus_message_append_args(msg, DBUS_TYPE_STRING, &id, DBUS_TYPE_INT32, &flag, DBUS_TYPE_INVALID);
- get_intval(call(msg));
- }
- }
- catch(rx3270::exception e)
- {
- }
-
- free(dest);
- free(path);
- free(intf);
-
-#else
-
-#endif
-}
-
-#if defined(HAVE_DBUS)
-DBusMessage * remote::call(DBusMessage *msg)
-{
- DBusMessage * reply;
- DBusError error;
-
- dbus_error_init(&error);
- reply = dbus_connection_send_with_reply_and_block(conn,msg,10000,&error);
- dbus_message_unref(msg);
-
- if(!reply)
- {
- throw exception("%s",error.message);
- dbus_error_free(&error);
- }
-
- return reply;
-
-}
-
-char * remote::get_string(DBusMessage * msg)
-{
- char *rc = NULL;
- if(msg)
- {
- DBusMessageIter iter;
-
- if(dbus_message_iter_init(msg, &iter))
- {
- if(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING)
- {
- const char * str;
- dbus_message_iter_get_basic(&iter, &str);
- trace("Response: [%s]",str);
- rc = strdup(str);
- }
- else
- {
- dbus_message_unref(msg);
- throw exception("DBUS Return type was %c, expecting %c",dbus_message_iter_get_arg_type(&iter),DBUS_TYPE_INT32);
- return NULL;
- }
- }
-
- dbus_message_unref(msg);
- }
- return rc;
-}
-
-char * remote::query_string(const char *method)
-{
- if(conn)
- return get_string(call(create_message(method)));
- return NULL;
-}
-
-int remote::get_intval(DBusMessage * msg)
-{
- int rc = -1;
-
- if(msg)
- {
- DBusMessageIter iter;
-
- if(dbus_message_iter_init(msg, &iter))
- {
- if(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_INT32)
- {
- dbus_int32_t iSigned;
- dbus_message_iter_get_basic(&iter, &iSigned);
- rc = (int) iSigned;
- }
- else
- {
- dbus_message_unref(msg);
- throw exception("DBUS Return type was %c, expecting %c",dbus_message_iter_get_arg_type(&iter),DBUS_TYPE_INT32);
- return -1;
- }
- }
-
- dbus_message_unref(msg);
- }
-
- return rc;
-}
-
-int remote::query_intval(const char *method)
-{
- if(conn)
- return get_intval(call(create_message(method)));
- return -1;
-}
-
-
-#endif // HAVE_DBUS
-
-char * remote::get_revision(void)
-{
-#if defined(WIN32)
-
- return strdup(PACKAGE_REVISION);
-
-#elif defined(HAVE_DBUS)
-
- return query_string("getRevision");
-
-#else
-
- return NULL;
-
-#endif
-
-}
-
-LIB3270_CSTATE remote::get_cstate(void)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- static const struct hllapi_packet_query query = { HLLAPI_PACKET_GET_CSTATE };
- struct hllapi_packet_result response;
- DWORD cbSize = sizeof(query);
- TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
- return (LIB3270_CSTATE) response.rc;
- }
-
- return (LIB3270_CSTATE) -1;
-
-#elif defined(HAVE_DBUS)
-
- return (LIB3270_CSTATE) query_intval("getConnectionState");
-
-#else
-
- return (LIB3270_CSTATE) -1;
-
-#endif
-
-}
-
-int remote::disconnect(void)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- static const struct hllapi_packet_query query = { HLLAPI_PACKET_DISCONNECT };
- struct hllapi_packet_result response;
- DWORD cbSize = sizeof(query);
- TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
- return 0;
- }
- return -1;
-
-#elif defined(HAVE_DBUS)
-
- return query_intval("disconnect");
-
-#else
-
- return -1;
-
-#endif
-
-}
-
-int remote::connect(const char *uri, bool wait)
-{
-#if defined(WIN32)
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- struct hllapi_packet_connect * pkt;
- struct hllapi_packet_result response;
- DWORD cbSize;
-
- cbSize = sizeof(struct hllapi_packet_connect)+strlen(uri);
- pkt = (struct hllapi_packet_connect *) malloc(cbSize);
-
- pkt->packet_id = HLLAPI_PACKET_CONNECT;
- pkt->wait = (unsigned char) wait;
- strcpy(pkt->hostname,uri);
-
- trace("Sending %s",pkt->hostname);
-
- if(!TransactNamedPipe(hPipe,(LPVOID) pkt, cbSize, &response, sizeof(response), &cbSize,NULL))
- {
- errno = GetLastError();
- response.rc = -1;
- }
-
- free(pkt);
-
- return response.rc;
-
- }
-
-#elif defined(HAVE_DBUS)
-
- int rc;
- DBusMessage * msg = create_message("connect");
- if(!msg)
- return -1;
-
- dbus_message_append_args(msg, DBUS_TYPE_STRING, &uri, DBUS_TYPE_INVALID);
-
- rc = get_intval(call(msg));
-
- if(!rc && wait)
- return wait_for_ready(120);
-
- return rc;
-
-#endif
-
- return -1;
-}
-
-bool remote::is_connected(void)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- static const struct hllapi_packet_query query = { HLLAPI_PACKET_IS_CONNECTED };
- struct hllapi_packet_result response;
- DWORD cbSize = sizeof(query);
- TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
- return response.rc != 0;
- }
-
-#elif defined(HAVE_DBUS)
-
- return query_intval("isConnected") != 0;
-
-#endif
-
- return false;
-}
-
-bool remote::is_ready(void)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- static const struct hllapi_packet_query query = { HLLAPI_PACKET_IS_READY };
- struct hllapi_packet_result response;
- DWORD cbSize = sizeof(query);
- TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
- return response.rc != 0;
- }
-
-#elif defined(HAVE_DBUS)
-
- return query_intval("isReady") != 0;
-
-#endif
-
- return false;
-}
-
-int remote::iterate(bool wait)
-{
-#if defined(WIN32)
-
- return 0;
-
-#elif defined(HAVE_DBUS)
-
- return 0;
-
-#endif
-
- return -1;
-}
-
-int remote::wait(int seconds)
-{
-#if defined(WIN32)
-
- time_t end = time(0)+seconds;
-
- while(time(0) < end)
- {
- if(!is_connected())
- return ENOTCONN;
- Sleep(500);
- }
-
- return 0;
-
-#elif defined(HAVE_DBUS)
-
- time_t end = time(0)+seconds;
-
- while(time(0) < end)
- {
- if(!is_connected())
- return ENOTCONN;
- usleep(500);
- }
-
- return 0;
-
-#endif
-
- return -1;
-}
-
-int remote::wait_for_ready(int seconds)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- time_t end = time(0)+seconds;
-
- while(time(0) < end)
- {
- if(!is_connected())
- return ENOTCONN;
-
- if(is_ready())
- return 0;
-
- Sleep(250);
- }
-
- return ETIMEDOUT;
-
- }
-
- return -1;
-
-#elif defined(HAVE_DBUS)
-
- time_t end = time(0)+seconds;
-
- while(time(0) < end)
- {
- static const dbus_int32_t delay = 2;
-
- DBusMessage * msg = create_message("waitForReady");
- int rc;
-
- if(!msg)
- return -1;
-
- dbus_message_append_args(msg, DBUS_TYPE_INT32, &delay, DBUS_TYPE_INVALID);
-
- rc = get_intval(call(msg));
- trace("waitForReady exits with rc=%d",rc);
- if(rc != ETIMEDOUT)
- return rc;
- }
-
- return ETIMEDOUT;
-
-#else
-
- return -1;
-
-#endif
-
-}
-
-char * remote::get_text_at(int row, int col, size_t sz)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- struct hllapi_packet_query_at query = { HLLAPI_PACKET_GET_TEXT_AT, (unsigned short) row, (unsigned short) col, (unsigned short) sz };
- struct hllapi_packet_text * response;
- DWORD cbSize = sizeof(struct hllapi_packet_text)+sz;
- char * text = NULL;
-
- response = (struct hllapi_packet_text *) malloc(cbSize+2);
- memset(response,0,cbSize+2);
-
- if(!TransactNamedPipe(hPipe,(LPVOID) &query, sizeof(struct hllapi_packet_query_at), &response, cbSize, &cbSize,NULL))
- return NULL;
-
- if(response->packet_id)
- errno = response->packet_id;
- else
- text = strdup(response->text);
-
- free(response);
- return text;
-
- }
-
-#elif defined(HAVE_DBUS)
-
- dbus_int32_t r = (dbus_int32_t) row;
- dbus_int32_t c = (dbus_int32_t) col;
- dbus_int32_t l = (dbus_int32_t) sz;
-
- DBusMessage * msg = create_message("getTextAt");
- if(!msg)
- return NULL;
-
- trace("%s(%d,%d,%d)",__FUNCTION__,r,c,l);
- dbus_message_append_args(msg, DBUS_TYPE_INT32, &r, DBUS_TYPE_INT32, &c, DBUS_TYPE_INT32, &l, DBUS_TYPE_INVALID);
-
- return get_string(call(msg));
-
-#endif
-
- return NULL;
-}
-
-int remote::cmp_text_at(int row, int col, const char *text)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- struct hllapi_packet_text_at * query;
- struct hllapi_packet_result response;
- DWORD cbSize = sizeof(struct hllapi_packet_text_at)+strlen(text);
-
- query = (struct hllapi_packet_text_at *) malloc(cbSize);
- query->packet_id = HLLAPI_PACKET_CMP_TEXT_AT;
- query->row = row;
- query->col = col;
- strcpy(query->text,text);
-
- TransactNamedPipe(hPipe,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL);
-
- free(query);
-
- return response.rc;
- }
-
-
-#elif defined(HAVE_DBUS)
-
- dbus_int32_t r = (dbus_int32_t) row;
- dbus_int32_t c = (dbus_int32_t) col;
-
- DBusMessage * msg = create_message("cmpTextAt");
- if(msg)
- {
- dbus_message_append_args(msg, DBUS_TYPE_INT32, &r, DBUS_TYPE_INT32, &c, DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID);
- return get_intval(call(msg));
- }
-
-#endif
-
- return 0;
-}
-
-int remote::set_text_at(int row, int col, const char *str)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- struct hllapi_packet_text_at * query;
- struct hllapi_packet_result response;
- DWORD cbSize = sizeof(struct hllapi_packet_text_at)+strlen((const char *) str);
-
- query = (struct hllapi_packet_text_at *) malloc(cbSize);
- query->packet_id = HLLAPI_PACKET_SET_TEXT_AT;
- query->row = row;
- query->col = col;
- strcpy(query->text,(const char *) str);
-
- TransactNamedPipe(hPipe,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL);
-
- free(query);
-
- return response.rc;
- }
-
-#elif defined(HAVE_DBUS)
-
- dbus_int32_t r = (dbus_int32_t) row;
- dbus_int32_t c = (dbus_int32_t) col;
-
- DBusMessage * msg = create_message("setTextAt");
- if(msg)
- {
- dbus_message_append_args(msg, DBUS_TYPE_INT32, &r, DBUS_TYPE_INT32, &c, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID);
- return get_intval(call(msg));
- }
-
-#endif
-
- return -1;
-}
-
-int remote::emulate_input(const char *str)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- size_t len = strlen(str);
- struct hllapi_packet_emulate_input * query;
- struct hllapi_packet_result response;
- DWORD cbSize = sizeof(struct hllapi_packet_emulate_input)+len;
-
- query = (struct hllapi_packet_emulate_input *) malloc(cbSize);
- query->packet_id = HLLAPI_PACKET_EMULATE_INPUT;
- query->len = len;
- query->pasting = 1;
- strcpy(query->text,str);
-
- TransactNamedPipe(hPipe,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL);
-
- free(query);
-
- return response.rc;
- }
-
-#elif defined(HAVE_DBUS)
-
- DBusMessage * msg = create_message("input");
- if(msg)
- {
- dbus_message_append_args(msg, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID);
- return get_intval(call(msg));
- }
-
-#endif
-
- return -1;
-}
-
-int remote::set_cursor_position(int row, int col)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- struct hllapi_packet_cursor query = { HLLAPI_PACKET_SET_CURSOR_POSITION, (unsigned short) row, (unsigned short) col };
- struct hllapi_packet_result response;
- DWORD cbSize = sizeof(query);
- TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
- return response.rc != 0;
- }
-
-#elif defined(HAVE_DBUS)
-
- dbus_int32_t r = (dbus_int32_t) row;
- dbus_int32_t c = (dbus_int32_t) col;
-
- DBusMessage * msg = create_message("setCursorAt");
- if(msg)
- {
- dbus_message_append_args(msg, DBUS_TYPE_INT32, &r, DBUS_TYPE_INT32, &c, DBUS_TYPE_INVALID);
- return get_intval(call(msg));
- }
-
-#endif
-
- return -1;
-}
-
-int remote::enter(void)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- static const struct hllapi_packet_query query = { HLLAPI_PACKET_ENTER };
- struct hllapi_packet_result response;
- DWORD cbSize = sizeof(query);
- TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
- return response.rc;
- }
-
- return -1;
-
-#elif defined(HAVE_DBUS)
-
- return query_intval("enter");
-
-#else
-
- return -1;
-
-#endif
-
-}
-
-int remote::pfkey(int key)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- struct hllapi_packet_keycode query = { HLLAPI_PACKET_PFKEY, (unsigned short) key };
- struct hllapi_packet_result response;
- DWORD cbSize = sizeof(query);
- TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
- return response.rc;
- }
-
-#elif defined(HAVE_DBUS)
-
- dbus_int32_t k = (dbus_int32_t) key;
-
- DBusMessage * msg = create_message("pfKey");
- if(msg)
- {
- dbus_message_append_args(msg, DBUS_TYPE_INT32, &k, DBUS_TYPE_INVALID);
- return get_intval(call(msg));
- }
-
-#endif
-
- return -1;
-}
-
-int remote::pakey(int key)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- struct hllapi_packet_keycode query = { HLLAPI_PACKET_PAKEY, (unsigned short) key };
- struct hllapi_packet_result response;
- DWORD cbSize = sizeof(query);
- TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
- return response.rc;
- }
-
-#elif defined(HAVE_DBUS)
-
- dbus_int32_t k = (dbus_int32_t) key;
-
- DBusMessage * msg = create_message("paKey");
- if(msg)
- {
- dbus_message_append_args(msg, DBUS_TYPE_INT32, &k, DBUS_TYPE_INVALID);
- return get_intval(call(msg));
- }
-
-#endif
-
- return -1;
-}
-
-int remote::get_field_start(int baddr)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- struct hllapi_packet_addr query = { HLLAPI_PACKET_FIELD_START, (unsigned short) baddr };
- struct hllapi_packet_result response;
- DWORD cbSize = sizeof(query);
- TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
- return response.rc;
- }
-
-#elif defined(HAVE_DBUS)
-
- dbus_int32_t k = (dbus_int32_t) baddr;
-
- DBusMessage * msg = create_message("getFieldStart");
- if(msg)
- {
- dbus_message_append_args(msg, DBUS_TYPE_INT32, &k, DBUS_TYPE_INVALID);
- return get_intval(call(msg));
- }
-
-#endif
-
- return -1;
-}
-
-int remote::get_field_len(int baddr)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- struct hllapi_packet_addr query = { HLLAPI_PACKET_FIELD_LEN, (unsigned short) baddr };
- struct hllapi_packet_result response;
- DWORD cbSize = sizeof(query);
- TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
- return response.rc;
- }
-
-#elif defined(HAVE_DBUS)
-
- dbus_int32_t k = (dbus_int32_t) baddr;
-
- DBusMessage * msg = create_message("getFieldLength");
- if(msg)
- {
- dbus_message_append_args(msg, DBUS_TYPE_INT32, &k, DBUS_TYPE_INVALID);
- return get_intval(call(msg));
- }
-
-#endif
-
- return -1;
-}
-
-
-
-int remote::set_toggle(LIB3270_TOGGLE ix, bool value)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- struct hllapi_packet_set query = { HLLAPI_PACKET_SET_TOGGLE, (unsigned short) ix, (unsigned short) value };
- struct hllapi_packet_result response;
- DWORD cbSize = sizeof(query);
- TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
- return response.rc;
- }
-
-#elif defined(HAVE_DBUS)
-
- dbus_int32_t i = (dbus_int32_t) ix;
- dbus_int32_t v = (dbus_int32_t) value;
-
- DBusMessage * msg = create_message("setToggle");
- if(msg)
- {
- dbus_message_append_args(msg, DBUS_TYPE_INT32, &i, DBUS_TYPE_INT32, &v, DBUS_TYPE_INVALID);
- return get_intval(call(msg));
- }
-
-#endif
-
- return -1;
-}
-
-int remote::wait_for_text_at(int row, int col, const char *key, int timeout)
-{
- time_t end = time(0)+timeout;
-
- while(time(0) < end)
- {
- if(!is_connected())
- return ENOTCONN;
-
- if(!cmp_text_at(row,col,key))
- return 0;
-
-#ifdef WIN32
- Sleep(500);
-#else
- usleep(500);
-#endif
- }
-
- return ETIMEDOUT;
-}
-
-char * remote::get_text(int baddr, size_t len)
-{
- #warning IMPLEMENTAR
- return NULL;
-}
-
-int remote::set_cursor_addr(int addr)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- struct hllapi_packet_addr query = { HLLAPI_PACKET_SET_CURSOR, (unsigned short) addr };
- struct hllapi_packet_result response;
- DWORD cbSize = sizeof(query);
- TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
- return response.rc;
- }
-
-#elif defined(HAVE_DBUS)
-
- dbus_int32_t k = (dbus_int32_t) addr;
-
- DBusMessage * msg = create_message("setCursorAddress");
- if(msg)
- {
- dbus_message_append_args(msg, DBUS_TYPE_INT32, &k, DBUS_TYPE_INVALID);
- return get_intval(call(msg));
- }
-
-#endif
-
- return -1;
-}
-
-int remote::get_cursor_addr(void)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- struct hllapi_packet_query query = { HLLAPI_PACKET_GET_CURSOR };
- struct hllapi_packet_result response;
- DWORD cbSize = sizeof(query);
- TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
- return response.rc;
- }
-
-#elif defined(HAVE_DBUS)
-
- return query_intval("getCursorAddress");
-
-#else
-
- return -1;
-
-#endif
-}
-
-int remote::get_next_unprotected(int baddr)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- struct hllapi_packet_addr query = { HLLAPI_PACKET_NEXT_UNPROTECTED, (unsigned short) baddr };
- struct hllapi_packet_result response;
- DWORD cbSize = sizeof(query);
- TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
- return response.rc;
- }
-
-#elif defined(HAVE_DBUS)
-
- dbus_int32_t k = (dbus_int32_t) baddr;
-
- DBusMessage * msg = create_message("getNextUnprotected");
- if(msg)
- {
- dbus_message_append_args(msg, DBUS_TYPE_INT32, &k, DBUS_TYPE_INVALID);
- return get_intval(call(msg));
- }
-
-#endif
-
- return -1;
-}
-
-int remote::set_clipboard(const char *text)
-{
-#if defined(WIN32)
-
- return -1;
-
-#elif defined(HAVE_DBUS)
-
- DBusMessage * msg = create_message("setClipboard");
- if(msg)
- {
- dbus_message_append_args(msg, DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID);
- return get_intval(call(msg));
- }
-
-#endif
-
- return -1;
-}
-
-char * remote::get_clipboard(void)
-{
-#if defined(WIN32)
-
- return NULL;
-
-#elif defined(HAVE_DBUS)
-
- trace("%s",__FUNCTION__);
- return query_string("getClipboard");
-
-#endif
-
- return NULL;
-}
-
-int remote::quit(void)
-{
-#if defined(WIN32)
-
- if(hPipe != INVALID_HANDLE_VALUE)
- {
- static const struct hllapi_packet_query query = { HLLAPI_PACKET_QUIT };
- struct hllapi_packet_result response;
- DWORD cbSize = sizeof(query);
- TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
- return (int) response.rc;
- }
-
- return (int) -1;
-
-#elif defined(HAVE_DBUS)
-
- return query_intval("quit");
-
-#endif
-
- return -1;
-
-}
diff --git a/src/plugins/rx3270/rexx_methods.cc b/src/plugins/rx3270/rexx_methods.cc
index 9404ae9..61d198f 100644
--- a/src/plugins/rx3270/rexx_methods.cc
+++ b/src/plugins/rx3270/rexx_methods.cc
@@ -37,6 +37,10 @@
#include
#include
#include
+ #include
+
+ using namespace std;
+ using namespace PW3270_NAMESPACE;
/*--[ Implement ]------------------------------------------------------------------------------------*/
@@ -45,12 +49,12 @@ RexxMethod1(int, rx3270_method_init, CSTRING, type)
// Set session class in rexx object
try
{
- RexxPointerObject sessionPtr = context->NewPointer(rx3270::create(type));
+ RexxPointerObject sessionPtr = context->NewPointer(session::create(type));
context->SetObjectVariable("CSELF", sessionPtr);
}
- catch(rx3270::exception e)
+ catch(std::exception &e)
{
- e.RaiseException(context);
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
}
return 0;
@@ -58,7 +62,7 @@ RexxMethod1(int, rx3270_method_init, CSTRING, type)
RexxMethod1(int, rx3270_method_uninit, CSELF, sessionPtr)
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
trace("rx3270_method_uninit hSession=%p",hSession);
@@ -71,37 +75,27 @@ RexxMethod1(int, rx3270_method_uninit, CSELF, sessionPtr)
RexxMethod1(RexxStringObject, rx3270_method_version, CSELF, sessionPtr)
{
- rx3270 * session = (rx3270 *) sessionPtr;
+ session * hSession = (session *) sessionPtr;
- if(session)
- {
- char * version = session->get_version();
- RexxStringObject ret = context->String((CSTRING) (version ? version : "ERROR:"));
- free(version);
- return ret;
- }
+ if(hSession)
+ return context->String((CSTRING) hSession->get_version().c_str());
return context->String((CSTRING) PACKAGE_VERSION);
}
RexxMethod1(RexxStringObject, rx3270_method_revision, CSELF, sessionPtr)
{
- rx3270 * session = (rx3270 *) sessionPtr;
+ session * hSession = (session *) sessionPtr;
- if(session)
- {
- char * version = session->get_revision();
- RexxStringObject ret = context->String((CSTRING) (version ? version : PACKAGE_REVISION));
- free(version);
- return ret;
- }
+ if(hSession)
+ return context->String((CSTRING) hSession->get_revision().c_str());
return context->String((CSTRING) PACKAGE_REVISION);
}
RexxMethod3(int, rx3270_method_connect, CSELF, sessionPtr, CSTRING, uri, OPTIONAL_int, wait)
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(!hSession)
return -1;
return hSession->connect(uri,wait != 0);
@@ -109,7 +103,7 @@ RexxMethod3(int, rx3270_method_connect, CSELF, sessionPtr, CSTRING, uri, OPTIONA
RexxMethod1(int, rx3270_method_disconnect, CSELF, sessionPtr)
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(!hSession)
return -1;
return hSession->disconnect();
@@ -117,7 +111,7 @@ RexxMethod1(int, rx3270_method_disconnect, CSELF, sessionPtr)
RexxMethod2(int, rx3270_method_sleep, CSELF, sessionPtr, int, seconds)
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(!hSession)
return -1;
return hSession->wait(seconds);
@@ -127,14 +121,14 @@ RexxMethod1(logical_t, rx3270_method_is_connected, CSELF, sessionPtr)
{
try
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(!hSession)
return false;
return hSession->is_connected();
}
- catch(rx3270::exception e)
+ catch(std::exception e)
{
- e.RaiseException(context);
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
}
return 0;
@@ -142,7 +136,7 @@ RexxMethod1(logical_t, rx3270_method_is_connected, CSELF, sessionPtr)
RexxMethod1(logical_t, rx3270_method_is_ready, CSELF, sessionPtr)
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(!hSession)
return false;
return hSession->is_ready();
@@ -150,7 +144,7 @@ RexxMethod1(logical_t, rx3270_method_is_ready, CSELF, sessionPtr)
RexxMethod2(int, rx3270_method_wait_for_ready, CSELF, sessionPtr, OPTIONAL_int, seconds)
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(!hSession)
return -1;
return hSession->wait_for_ready(seconds > 0 ? seconds : 60);
@@ -158,7 +152,7 @@ RexxMethod2(int, rx3270_method_wait_for_ready, CSELF, sessionPtr, OPTIONAL_int,
RexxMethod3(int, rx3270_method_set_cursor, CSELF, sessionPtr, int, row, int, col)
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(!hSession)
return -1;
return hSession->set_cursor_position(row,col);
@@ -166,7 +160,7 @@ RexxMethod3(int, rx3270_method_set_cursor, CSELF, sessionPtr, int, row, int, col
RexxMethod1(int, rx3270_method_get_cursor_addr, CSELF, sessionPtr)
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(!hSession)
return -1;
return hSession->get_cursor_addr();
@@ -174,7 +168,7 @@ RexxMethod1(int, rx3270_method_get_cursor_addr, CSELF, sessionPtr)
RexxMethod2(int, rx3270_method_set_cursor_addr, CSELF, sessionPtr, int, addr)
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(!hSession)
return -1;
return hSession->set_cursor_addr(addr);
@@ -182,7 +176,7 @@ RexxMethod2(int, rx3270_method_set_cursor_addr, CSELF, sessionPtr, int, addr)
RexxMethod1(int, rx3270_method_enter, CSELF, sessionPtr)
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(!hSession)
return -1;
return hSession->enter();
@@ -190,7 +184,7 @@ RexxMethod1(int, rx3270_method_enter, CSELF, sessionPtr)
RexxMethod2(int, rx3270_method_pfkey, CSELF, sessionPtr, int, key)
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(!hSession)
return -1;
return hSession->pfkey(key);
@@ -198,7 +192,7 @@ RexxMethod2(int, rx3270_method_pfkey, CSELF, sessionPtr, int, key)
RexxMethod2(int, rx3270_method_pakey, CSELF, sessionPtr, int, key)
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(!hSession)
return -1;
return hSession->pakey(key);
@@ -206,9 +200,11 @@ RexxMethod2(int, rx3270_method_pakey, CSELF, sessionPtr, int, key)
RexxMethod4(RexxStringObject, rx3270_method_get_text_at, CSELF, sessionPtr, int, row, int, col, int, sz)
{
- rx3270 * session = (rx3270 *) sessionPtr;
+ #warning Reimplementar
+/*
+ session * hSession = (session *) sessionPtr;
- if(session)
+ if(hSession)
{
char * str = session->get_text_at(row,col,sz);
@@ -221,13 +217,15 @@ RexxMethod4(RexxStringObject, rx3270_method_get_text_at, CSELF, sessionPtr, int,
return ret;
}
}
-
+*/
return context->String("");
}
RexxMethod4(int, rx3270_method_set_text_at, CSELF, sessionPtr, int, row, int, col, CSTRING, text)
{
+ #warning Reimplementar
+/*
rx3270 * session = (rx3270 *) sessionPtr;
if(session)
@@ -238,11 +236,14 @@ RexxMethod4(int, rx3270_method_set_text_at, CSELF, sessionPtr, int, row, int, co
free(str);
return rc;
}
+*/
return -1;
}
RexxMethod2(int, rx3270_method_input_text, CSELF, sessionPtr, CSTRING, text)
{
+#warning Reimplementar
+/*
rx3270 * session = (rx3270 *) sessionPtr;
if(session)
@@ -252,12 +253,14 @@ RexxMethod2(int, rx3270_method_input_text, CSELF, sessionPtr, CSTRING, text)
free(str);
return rc;
}
-
+*/
return -1;
}
RexxMethod4(int, rx3270_method_cmp_text_at, CSELF, sessionPtr, int, row, int, col, CSTRING, key)
{
+ #warning Reimplementar
+/*
int rc = 0;
rx3270 * session = (rx3270 *) sessionPtr;
@@ -272,13 +275,15 @@ RexxMethod4(int, rx3270_method_cmp_text_at, CSELF, sessionPtr, int, row, int, co
}
free(str);
}
-
return rc;
+*/
+
+ return -1;
}
RexxMethod2(int, rx3270_method_event_trace, CSELF, sessionPtr, int, flag)
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(!hSession)
return -1;
hSession->set_toggle(LIB3270_TOGGLE_EVENT_TRACE,flag);
@@ -287,7 +292,7 @@ RexxMethod2(int, rx3270_method_event_trace, CSELF, sessionPtr, int, flag)
RexxMethod2(int, rx3270_method_screen_trace, CSELF, sessionPtr, int, flag)
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(!hSession)
return -1;
hSession->set_toggle(LIB3270_TOGGLE_SCREEN_TRACE,flag);
@@ -297,7 +302,7 @@ RexxMethod2(int, rx3270_method_screen_trace, CSELF, sessionPtr, int, flag)
RexxMethod2(int, rx3270_method_ds_trace, CSELF, sessionPtr, int, flag)
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(!hSession)
return -1;
hSession->set_toggle(LIB3270_TOGGLE_DS_TRACE,flag);
@@ -339,7 +344,7 @@ RexxMethod3(int, rx3270_method_set_option, CSELF, sessionPtr, CSTRING, name, int
{ "altscreen", LIB3270_TOGGLE_ALTSCREEN }
};
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(hSession)
{
for(int f = 0; f < LIB3270_TOGGLE_COUNT; f++)
@@ -358,7 +363,9 @@ RexxMethod3(int, rx3270_method_set_option, CSELF, sessionPtr, CSTRING, name, int
RexxMethod4(logical_t, rx3270_method_test, CSELF, sessionPtr, CSTRING, key, int, row, int, col)
{
- rx3270 * hSession = (rx3270 *) sessionPtr;
+ #warning Reimplementar
+/*
+ session * hSession = (session *) sessionPtr;
if(!hSession)
return false;
@@ -379,22 +386,26 @@ RexxMethod4(logical_t, rx3270_method_test, CSELF, sessionPtr, CSTRING, key, int,
free(str);
return rc;
}
-
+*/
return false;
}
RexxMethod5(int, rx3270_method_wait_for_text_at, CSELF, sessionPtr, int, row, int, col, CSTRING, key, int, timeout)
{
+ #warning Reimplementar
+/*
rx3270 * hSession = (rx3270 *) sessionPtr;
if(hSession)
return hSession->wait_for_text_at(row,col,key,timeout);
-
+*/
return -1;
}
RexxMethod3(RexxStringObject, rx3270_method_get_text, CSELF, sessionPtr, OPTIONAL_int, baddr, OPTIONAL_int, sz)
{
+ #warning Reimplementar
+/*
rx3270 * hSession = (rx3270 *) sessionPtr;
if(hSession)
@@ -409,14 +420,14 @@ RexxMethod3(RexxStringObject, rx3270_method_get_text, CSELF, sessionPtr, OPTIONA
return ret;
}
}
-
+*/
return context->String("");
}
RexxMethod2(int, rx3270_method_get_field_len, CSELF, sessionPtr, OPTIONAL_int, baddr)
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(!hSession)
return -1;
return hSession->get_field_len(baddr);
@@ -424,7 +435,7 @@ RexxMethod2(int, rx3270_method_get_field_len, CSELF, sessionPtr, OPTIONAL_int, b
RexxMethod2(int, rx3270_method_get_field_start, CSELF, sessionPtr, OPTIONAL_int, baddr)
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(!hSession)
return -1;
return hSession->get_field_start(baddr)+1;
@@ -432,7 +443,7 @@ RexxMethod2(int, rx3270_method_get_field_start, CSELF, sessionPtr, OPTIONAL_int,
RexxMethod2(int, rx3270_method_get_next_unprotected, CSELF, sessionPtr, OPTIONAL_int, baddr)
{
- rx3270 *hSession = (rx3270 *) sessionPtr;
+ session *hSession = (session *) sessionPtr;
if(!hSession)
return -1;
@@ -445,7 +456,9 @@ RexxMethod2(int, rx3270_method_get_next_unprotected, CSELF, sessionPtr, OPTIONAL
RexxMethod1(RexxStringObject, rx3270_method_get_selection, CSELF, sessionPtr)
{
- rx3270 * hSession = (rx3270 *) sessionPtr;
+ #warning Reimplementar
+/*
+ session * hSession = (session *) sessionPtr;
if(hSession)
{
@@ -459,12 +472,14 @@ RexxMethod1(RexxStringObject, rx3270_method_get_selection, CSELF, sessionPtr)
return ret;
}
}
-
+*/
return context->String("");
}
RexxMethod2(int, rx3270_method_set_selection, CSELF, sessionPtr, CSTRING, text)
{
+ #warning Reimplementar
+/*
rx3270 * session = (rx3270 *) sessionPtr;
if(session)
@@ -475,23 +490,22 @@ RexxMethod2(int, rx3270_method_set_selection, CSELF, sessionPtr, CSTRING, text)
free(str);
return rc;
}
+*/
return -1;
}
RexxMethod1(RexxStringObject, rx3270_method_get_clipboard, CSELF, sessionPtr)
{
- rx3270 * hSession = (rx3270 *) sessionPtr;
+ session * hSession = (session *) sessionPtr;
if(hSession)
{
- char *str = hSession->get_clipboard();
-
- trace("str=%p (%s)",str,str);
+ string *str = hSession->get_clipboard();
if(str)
{
- RexxStringObject ret = context->String((CSTRING) str);
- hSession->free(str);
+ RexxStringObject ret = context->String((CSTRING) str->c_str());
+ delete str;
return ret;
}
}
@@ -502,7 +516,7 @@ RexxMethod1(RexxStringObject, rx3270_method_get_clipboard, CSELF, sessionPtr)
RexxMethod2(int, rx3270_method_set_clipboard, CSELF, sessionPtr, CSTRING, text)
{
- rx3270 * hSession = (rx3270 *) sessionPtr;
+ session * hSession = (session *) sessionPtr;
if(hSession)
return hSession->set_clipboard(text);
@@ -513,8 +527,8 @@ RexxMethod2(int, rx3270_method_set_clipboard, CSELF, sessionPtr, CSTRING, text)
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;
+ LIB3270_NOTIFY id = LIB3270_NOTIFY_INFO;
+ session * hSession = (session *) sessionPtr;
if(!hSession)
return -1;
@@ -562,7 +576,7 @@ RexxMethod5(RexxStringObject, rx3270_method_get_filename, CSELF, sessionPtr, CST
};
GtkFileChooserAction id = GTK_FILE_CHOOSER_ACTION_OPEN;
- char * ret;
+ string * ret;
for(int f=0;f<5;f++)
{
@@ -573,11 +587,11 @@ RexxMethod5(RexxStringObject, rx3270_method_get_filename, CSELF, sessionPtr, CST
}
}
- ret = ((rx3270 *) sessionPtr)->file_chooser_dialog(id, title, extension,filename);
+ ret = ((session *) sessionPtr)->file_chooser_dialog(id, title, extension,filename);
if(ret)
{
- RexxStringObject obj = context->String(ret);
- ((rx3270 *) sessionPtr)->free(ret);
+ RexxStringObject obj = context->String(ret->c_str());
+ delete ret;
return obj;
}
diff --git a/src/plugins/rx3270/rx3270.h b/src/plugins/rx3270/rx3270.h
index 9e70433..015af55 100644
--- a/src/plugins/rx3270/rx3270.h
+++ b/src/plugins/rx3270/rx3270.h
@@ -64,7 +64,7 @@
#define REXX_DEFAULT_CHARSET "UTF-8"
#endif // WIN32
-#include
+// #include
/*---[ Rexx entry points ]-----------------------------------------------------------------------------------*/
@@ -128,6 +128,7 @@
/*--[ 3270 Session ]-----------------------------------------------------------------------------------------*/
+/*
#if defined (HAVE_GNUC_VISIBILITY)
class __attribute__((visibility("default"))) rx3270
#elif defined(WIN32)
@@ -232,6 +233,7 @@
};
rx3270 * create_lib3270_instance(void);
+*/
#ifdef __cplusplus
extern "C" {
diff --git a/src/plugins/rx3270/session.cc b/src/plugins/rx3270/session.cc
deleted file mode 100644
index 5bf74b6..0000000
--- a/src/plugins/rx3270/session.cc
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA, 02111-1307, USA
- *
- * Este programa está nomeado como session.cc e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- */
-
- #include
- #include
-
- #include "rx3270.h"
- #include
-
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-session::session()
-{
- this->hSession = lib3270_get_default_session_handle();
-}
-
-session::~session()
-{
-
-}
-
-const char * session::getVersion(void)
-{
- return lib3270_get_version();
-}
diff --git a/src/plugins/rx3270/typed_routines.cc b/src/plugins/rx3270/typed_routines.cc
index 5a45abc..50fa7cb 100644
--- a/src/plugins/rx3270/typed_routines.cc
+++ b/src/plugins/rx3270/typed_routines.cc
@@ -30,6 +30,11 @@
#include "rx3270.h"
#include
#include
+ #include
+ #include
+
+ using namespace std;
+ using namespace PW3270_NAMESPACE;
/*--[ Implement ]------------------------------------------------------------------------------------*/
@@ -37,11 +42,11 @@ RexxRoutine0(CSTRING, rx3270version)
{
try
{
- return rx3270::get_default()->get_version();
+ return session::get_default()->get_version().c_str();
}
- catch(rx3270::exception e)
+ catch(std::exception& e)
{
- e.RaiseException(context);
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
}
return NULL;
@@ -70,7 +75,7 @@ RexxRoutine0(CSTRING, rx3270QueryCState)
};
size_t f;
- LIB3270_CSTATE state = rx3270::get_default()->get_cstate();
+ LIB3270_CSTATE state = session::get_default()->get_cstate();
for(f=0;f < (sizeof(xlat_state)/sizeof(struct _xlat_state)); f++)
{
@@ -83,52 +88,54 @@ RexxRoutine0(CSTRING, rx3270QueryCState)
RexxRoutine0(int, rx3270Disconnect)
{
- return rx3270::get_default()->disconnect();
+ return session::get_default()->disconnect();
}
RexxRoutine2(int, rx3270Connect, CSTRING, hostname, int, wait)
{
- return rx3270::get_default()->connect(hostname,wait);
+ return session::get_default()->connect(hostname,wait);
}
RexxRoutine0(int, rx3270isConnected)
{
- return rx3270::get_default()->is_connected();
+ return session::get_default()->is_connected();
}
RexxRoutine0(int, rx3270WaitForEvents)
{
- return rx3270::get_default()->iterate();
+ return session::get_default()->iterate();
}
RexxRoutine1(int, rx3270Sleep, int, seconds)
{
- return rx3270::get_default()->wait(seconds);
+ return session::get_default()->wait(seconds);
}
RexxRoutine0(int, rx3270SendENTERKey)
{
- return rx3270::get_default()->enter();
+ return session::get_default()->enter();
}
RexxRoutine1(int, rx3270SendPFKey, int, key)
{
- return rx3270::get_default()->pfkey(key);
+ return session::get_default()->pfkey(key);
}
RexxRoutine1(int, rx3270SendPAKey, int, key)
{
- return rx3270::get_default()->pakey(key);
+ return session::get_default()->pakey(key);
}
RexxRoutine1(int, rx3270WaitForTerminalReady, int, seconds)
{
- return rx3270::get_default()->wait_for_ready(seconds);
+ return session::get_default()->wait_for_ready(seconds);
}
RexxRoutine4(int, rx3270WaitForStringAt, int, row, int, col, CSTRING, key, int, timeout)
{
- rx3270 * session = rx3270::get_default();
+ #warning REIMPLEMENTAR
+/*
+ session * session = session::get_default();
time_t end = time(0) + timeout;
char * text = session->get_3270_string(key);
@@ -146,13 +153,15 @@ RexxRoutine4(int, rx3270WaitForStringAt, int, row, int, col, CSTRING, key, int,
}
free(text);
-
+*/
return ETIMEDOUT;
}
RexxRoutine3(RexxStringObject, rx3270GetStringAt, int, row, int, col, int, sz)
{
+ #warning REIMPLEMENTAR
+/*
rx3270 * session = rx3270::get_default();
char * str = session->get_text_at(row,col,sz);
@@ -164,17 +173,19 @@ RexxRoutine3(RexxStringObject, rx3270GetStringAt, int, row, int, col, int, sz)
free(text);
return ret;
}
-
+*/
return context->String("");
}
RexxRoutine0(int, rx3270IsTerminalReady)
{
- return rx3270::get_default()->is_ready();
+ return session::get_default()->is_ready();
}
RexxRoutine3(int, rx3270queryStringAt, int, row, int, col, CSTRING, key)
{
+ #warning Reimplementar
+/*
int rc = 0;
rx3270 * session = rx3270::get_default();
char * str = session->get_text_at(row,col,strlen(key));
@@ -189,17 +200,19 @@ RexxRoutine3(int, rx3270queryStringAt, int, row, int, col, CSTRING, key)
free(str);
return rc;
+*/
+ return -1;
}
RexxRoutine2(int, rx3270SetCursorPosition, int, row, int, col)
{
try
{
- return rx3270::get_default()->set_cursor_position(row,col);
+ return session::get_default()->set_cursor_position(row,col);
}
- catch(rx3270::exception e)
+ catch(std::exception &e)
{
- e.RaiseException(context);
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
}
return -1;
@@ -207,6 +220,8 @@ RexxRoutine2(int, rx3270SetCursorPosition, int, row, int, col)
RexxRoutine3(int, rx3270SetStringAt, int, row, int, col, CSTRING, text)
{
+ #warning Reimplementar
+/*
rx3270 * session = rx3270::get_default();
char * str = session->get_3270_string(text);
int rc;
@@ -216,10 +231,12 @@ RexxRoutine3(int, rx3270SetStringAt, int, row, int, col, CSTRING, text)
free(str);
return rc;
+*/
+ return -1;
}
RexxRoutine0(int, rx3270CloseApplication)
{
- rx3270 * session = rx3270::get_default();
+ session * session = session::get_default();
return session->quit();
}
--
libgit2 0.21.2