diff --git a/src/oxt/Makefile.in b/src/oxt/Makefile.in index 0b0757b..2e17f07 100644 --- a/src/oxt/Makefile.in +++ b/src/oxt/Makefile.in @@ -1,7 +1,7 @@ PACKAGE=@PACKAGE_NAME@ -SOURCES=main.cxx local.cxx get.cxx +SOURCES=main.cxx local.cxx connection.cxx get.cxx prefix=/usr exec_prefix=@exec_prefix@ diff --git a/src/oxt/connection.cxx b/src/oxt/connection.cxx new file mode 100644 index 0000000..3d54578 --- /dev/null +++ b/src/oxt/connection.cxx @@ -0,0 +1,47 @@ +/* + * "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 connection.cxx e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * licinio@bb.com.br (Licínio Luis Branco) + * kraucer@bb.com.br (Kraucer Fernandes Mazuco) + * + */ + + #include "globals.hpp" + +/*---[ Implement ]-----------------------------------------------------------------------------------------*/ + +sal_Int16 SAL_CALL pw3270::uno_impl::Connect( const ::rtl::OUString& hostinfo ) throw (::com::sun::star::uno::RuntimeException) +{ + OString str = rtl::OUStringToOString( hostinfo , hSession->get_encoding() ); + return hSession->connect(str.getStr()); +} + +sal_Int16 SAL_CALL pw3270::uno_impl::Disconnect( ) throw (::com::sun::star::uno::RuntimeException) +{ + return hSession->disconnect(); +} + + diff --git a/src/oxt/get.cxx b/src/oxt/get.cxx index 2d7bb2d..2bcfc1f 100644 --- a/src/oxt/get.cxx +++ b/src/oxt/get.cxx @@ -38,4 +38,9 @@ sal_Int16 SAL_CALL pw3270::uno_impl::getRevision() throw (RuntimeException) return hSession->get_revision(); } +sal_Int16 SAL_CALL pw3270::uno_impl::getConnectionState( ) throw (::com::sun::star::uno::RuntimeException) +{ + return hSession->get_state(); +} + diff --git a/src/oxt/globals.hpp b/src/oxt/globals.hpp index 51048e9..876dd23 100644 --- a/src/oxt/globals.hpp +++ b/src/oxt/globals.hpp @@ -52,14 +52,21 @@ session(); virtual ~session(); virtual int get_revision(void) = 0; + virtual int get_state(void) = 0; + virtual int connect(const char *uri) = 0; virtual int disconnect(void) = 0; virtual bool connected(void) = 0; + virtual int enter(void) = 0; virtual int pfkey(int key) = 0; virtual int pakey(int key) = 0; - rtl_TextEncoding getEncoding(); + virtual void mem_free(void *) = 0; + + void sleep(int seconds = 1); + + rtl_TextEncoding get_encoding(); }; @@ -70,13 +77,18 @@ virtual ~lib3270_session(); virtual int get_revision(void); + virtual int get_state(void); + virtual int connect(const char *uri); virtual int disconnect(void); virtual bool connected(void); + virtual int enter(void); virtual int pfkey(int key); virtual int pakey(int key); + virtual void mem_free(void *ptr); + private: bool enabled; oslModule hModule; @@ -89,12 +101,14 @@ /* lib3270 entry points */ const char * (* _get_revision)(void); + int (* _get_program_message)(void *); char * (* _get_text_at)(void *,int,int,int); int (* _set_text_at)(void *,int,int,const unsigned char *); int (* _cmp_text_at)(void *,int,int,const char *); int (* _enter)(void *); int (* _pfkey)(void *, int); int (* _pakey)(void *, int); + void * (* _mem_free)(void *); }; @@ -115,7 +129,11 @@ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException); // pw3270 implementation - Main - virtual sal_Int16 SAL_CALL getRevision() throw (RuntimeException); + virtual ::sal_Int16 SAL_CALL getRevision() throw (RuntimeException); + virtual ::sal_Int16 SAL_CALL Connect( const ::rtl::OUString& hostinfo ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL Disconnect( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getConnectionState( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL sleep( ::sal_Int16 seconds ) throw (::com::sun::star::uno::RuntimeException); private: diff --git a/src/oxt/local.cxx b/src/oxt/local.cxx index 30b2b9a..c92951c 100644 --- a/src/oxt/local.cxx +++ b/src/oxt/local.cxx @@ -50,13 +50,15 @@ const char * name; } call[] = { - { (void **) & _get_revision, "lib3270_get_revision" }, - { (void **) & _get_text_at, "lib3270_get_text_at" }, - { (void **) & _set_text_at, "lib3270_set_string_at" }, - { (void **) & _cmp_text_at, "lib3270_cmp_text_at" }, - { (void **) & _enter, "lib3270_enter" }, - { (void **) & _pfkey, "lib3270_pfkey" }, - { (void **) & _pakey, "lib3270_pakey" } + { (void **) & _get_revision, "lib3270_get_revision" }, + { (void **) & _get_text_at, "lib3270_get_text_at" }, + { (void **) & _set_text_at, "lib3270_set_string_at" }, + { (void **) & _cmp_text_at, "lib3270_cmp_text_at" }, + { (void **) & _enter, "lib3270_enter" }, + { (void **) & _pfkey, "lib3270_pfkey" }, + { (void **) & _pakey, "lib3270_pakey" }, + { (void **) & _get_program_message, "lib3270_get_program_message" }, + { (void **) & _mem_free, "lib3270_free" } }; @@ -85,6 +87,10 @@ trace("%s hModule=%p hSession=%p",__FUNCTION__,hModule,hSession); disconnect(); + osl_yieldThread(); + + if(hThread) + osl_joinWithThread(hThread); if(hModule) { @@ -92,8 +98,10 @@ { void (*lib3270_free)(void *) = (void (*)(void *)) osl_getAsciiFunctionSymbol(hModule,"lib3270_session_free"); lib3270_free(hSession); + hSession = NULL; } osl_unloadModule(hModule); + hModule = NULL; } } @@ -201,3 +209,15 @@ return EINVAL; return _pakey(hSession,key); } + + int pw3270::lib3270_session::get_state(void) + { + if(!hSession) + return -1; + return _get_program_message(hSession); + } + + void pw3270::lib3270_session::mem_free(void *ptr) + { + _mem_free(ptr); + } diff --git a/src/oxt/main.cxx b/src/oxt/main.cxx index 08173dc..14fcb31 100644 --- a/src/oxt/main.cxx +++ b/src/oxt/main.cxx @@ -31,6 +31,7 @@ #include "globals.hpp" +#include #include #include @@ -221,6 +222,14 @@ pw3270::uno_impl::~uno_impl() delete this->hSession; } +::sal_Int16 SAL_CALL pw3270::uno_impl::sleep( ::sal_Int16 seconds ) throw (::com::sun::star::uno::RuntimeException) +{ + salhelper::TTimeValue t = salhelper::TTimeValue(seconds,0); + osl_waitThread(&t); + return 0; +} + + pw3270::session::session() { trace("%s",__FUNCTION__); @@ -231,7 +240,13 @@ pw3270::session::~session() trace("%s",__FUNCTION__); } -rtl_TextEncoding pw3270::session::getEncoding() +rtl_TextEncoding pw3270::session::get_encoding() { return RTL_TEXTENCODING_ISO_8859_1; } + +void pw3270::session::sleep(int seconds) +{ + salhelper::TTimeValue t = salhelper::TTimeValue(seconds,0); + osl_waitThread(&t); +} diff --git a/src/oxt/pw3270.idl b/src/oxt/pw3270.idl index 8f16610..ded1e33 100644 --- a/src/oxt/pw3270.idl +++ b/src/oxt/pw3270.idl @@ -56,7 +56,15 @@ module br */ interface pw3270intf : com::sun::star::uno::XInterface { + /* Connect/Disconnect */ + short Connect( [in] string hostinfo ); + short Disconnect(); + short getConnectionState(); + + /* Misc */ short getRevision(); + short sleep([in] short seconds); + }; service pw3270 diff --git a/src/oxt/pw3270OXT.cbp b/src/oxt/pw3270OXT.cbp index 65d0683..fb6f37a 100644 --- a/src/oxt/pw3270OXT.cbp +++ b/src/oxt/pw3270OXT.cbp @@ -33,6 +33,7 @@ + diff --git a/src/oxt/testprogram.cxx b/src/oxt/testprogram.cxx index 061ac75..4e21f82 100644 --- a/src/oxt/testprogram.cxx +++ b/src/oxt/testprogram.cxx @@ -105,17 +105,21 @@ int SAL_CALL main(int argc, char **argv) { // Wait for commands // OString str; -// char buffer[80]; -// printf("getConnectionState: %d\n", srv->getConnectionState()); - -// str = OUStringToOString( srv->getVersion(),RTL_TEXTENCODING_UTF8); -// printf("Version:\t%s\n",str.pData->buffer); printf("Revision:\t%d\n",srv->getRevision()); - // printf("Connect(): %d\n" , srv->Connect(OUString::createFromAscii("L:3270.df.bb:9023"),10)); + printf("getConnectionState: %d\n", srv->getConnectionState()); + printf("Connect(): %d\n" , srv->Connect(OUString::createFromAscii("L:3270.df.bb:9023"))); + + srv->sleep(5); + printf("getConnectionState: %d\n", srv->getConnectionState()); + srv->sleep(5); + + srv->Disconnect(); + srv->sleep(5); + printf("getConnectionState: %d\n", srv->getConnectionState()); - // sleep(5); + srv->sleep(5); //str = OUStringToOString( srv->getScreenContentAt(20,39,5),RTL_TEXTENCODING_UTF8); //Trace("ContentsAt(20,39): \"%s\"",str.pData->buffer); -- libgit2 0.21.2