From ae8948cbdac52e41401368020c2f582640dc7bf6 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Fri, 28 Mar 2014 11:40:41 +0000 Subject: [PATCH] Reconstruindo módulo libreoffice do zero --- src/oxt/Makefile.in | 175 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/oxt/actions.cxx | 113 ----------------------------------------------------------------------------------------------------------------- src/oxt/connection.cxx | 47 ----------------------------------------------- src/oxt/description.txt | 2 -- src/oxt/description.xml.in | 30 ------------------------------ src/oxt/get.cxx | 68 -------------------------------------------------------------------- src/oxt/globals.hpp | 229 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/oxt/local.cxx | 343 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/oxt/main.cxx | 330 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ src/oxt/manifest.xml.in | 6 ------ src/oxt/pw3270.idl | 101 ----------------------------------------------------------------------------------------------------- src/oxt/pw3270OXT.cbp | 53 ----------------------------------------------------- src/oxt/remote.cxx | 533 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/oxt/set.cxx | 42 ------------------------------------------ src/oxt/testprogram.cxx | 173 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 15 files changed, 0 insertions(+), 2245 deletions(-) delete mode 100644 src/oxt/Makefile.in delete mode 100644 src/oxt/actions.cxx delete mode 100644 src/oxt/connection.cxx delete mode 100644 src/oxt/description.txt delete mode 100644 src/oxt/description.xml.in delete mode 100644 src/oxt/get.cxx delete mode 100644 src/oxt/globals.hpp delete mode 100644 src/oxt/local.cxx delete mode 100644 src/oxt/main.cxx delete mode 100644 src/oxt/manifest.xml.in delete mode 100644 src/oxt/pw3270.idl delete mode 100644 src/oxt/pw3270OXT.cbp delete mode 100644 src/oxt/remote.cxx delete mode 100644 src/oxt/set.cxx delete mode 100644 src/oxt/testprogram.cxx diff --git a/src/oxt/Makefile.in b/src/oxt/Makefile.in deleted file mode 100644 index 108f899..0000000 --- a/src/oxt/Makefile.in +++ /dev/null @@ -1,175 +0,0 @@ - -PACKAGE=@PACKAGE_NAME@ - -SOURCES=main.cxx local.cxx connection.cxx get.cxx set.cxx actions.cxx remote.cxx - -prefix=/usr -exec_prefix=@exec_prefix@ -libdir=@libdir@ -instdir=$(DESTDIR)/$(libdir)/libreoffice/share/extensions/$(PACKAGE) - -#---[ Paths ]------------------------------------------------------------------------------------------ -ROOTDIR ?= . -OBJDIR ?= $(ROOTDIR)/.obj -BINDIR ?= $(ROOTDIR)/.bin - -BINDBG ?= $(BINDIR)/Debug -BINRLS ?= $(BINDIR)/Release -LIBDBG ?= $(BINDIR)/Debug/lib - -OBJDBG = $(OBJDIR)/Debug -OBJRLS = $(OBJDIR)/Release - -#---[ Tools ]------------------------------------------------------------------------------------------ -MKDIR=@MKDIR_P@ -INSTALL=@INSTALL@ -INSTALL_DATA=@INSTALL_DATA@ -INSTALL_PROGRAM=@INSTALL_PROGRAM@ -CXX=@CXX@ -CONVERT=@CONVERT@ -ZIP=@ZIP@ - -DBG_CFLAGS=-g -DDEBUG=1 -RLS_CFLAGS=-DNDEBUG=1 - -#---[ LibreOffice SDK ]-------------------------------------------------------------------------------- -COMID=gcc3 -OO_SDK_NAME=openoffice.org3.5_sdk -OFFICE_HOME=@OFFICE_HOME@ -OO_SDK_HOME=@OO_SDK_HOME@ -OO_SDK_URE_HOME=@OO_SDK_URE_HOME@ -OO_SDK_URE_BIN_DIR=${OO_SDK_URE_HOME}/bin -OO_SDK_URE_LIB_DIR=${OO_SDK_URE_HOME}/lib - -TYPES_RDB=${OO_SDK_URE_HOME}/share/misc/types.rdb - -SALLIB=-luno_sal -CPPULIB=-luno_cppu -CPPUHELPERLIB=-luno_cppuhelper$(COMID) -SALHELPERLIB=-luno_salhelper$(COMID) -REGLIB=-lreg -STORELIB=-lstore - -# Libre office tools -IDLC=@IDLC@ -REGMERGE=@REGMERGE@ -CPPUMAKER=@CPPUMAKER@ - -#---[ Rules ]------------------------------------------------------------------------------------------ - -LIB3270_CFLAGS ?= `pkg-config --cflags lib3270` - -DLL_CFLAGS=@DLL_CFLAGS@ -DLL_FLAGS=-shared - -CXXFLAGS=-Wno-strict-aliasing -I$(OBJDIR)/uno/include -I$(OO_SDK_HOME)/include \ - -I$(OBJDIR)/uno/include/br/com/bb $(LIB3270_CFLAGS) \ - @DBUS_CFLAGS@ - -LDFLAGS=-L${OO_SDK_HOME}/lib -L${OO_SDK_URE_HOME}/lib \ - -Wl,-rpath-link=${OO_SDK_URE_HOME}/lib,-rpath=${OO_SDK_URE_HOME}/lib \ - $(CPPULIB) $(CPPUHELPERLIB) $(SALLIB) @DBUS_LIBS@ - -# CC_DEFINES=-DUNX -DGCC -DLINUX -DCPPU_ENV=$(CPPU_ENV) -DGXX_INCLUDE_PATH=$(SDK_GXX_INCLUDE_PATH) -DHAVE_GCC_VISIBILITY_FEATURE - -$(OBJDBG)/%.o: %.cxx $(OBJDIR)/uno/include/br/com/bb/$(PACKAGE).hpp Makefile - @echo $< ... - @$(MKDIR) `dirname $@` - @$(CXX) $(DBG_CFLAGS) $(CXXFLAGS) $(LIB3270_CFLAGS) $(DLL_CFLAGS) -o $@ -c $< - -$(OBJRLS)/%.o: %.cxx $(OBJDIR)/uno/include/br/com/bb/$(PACKAGE).hpp Makefile - @echo $< ... - @$(MKDIR) `dirname $@` - @$(CXX) $(CXXFLAGS) $(LIB3270_CFLAGS) $(DLL_CFLAGS) -o $@ -c $< - -%.urd: %.idl - @echo $< ... - @$(MKDIR) `dirname $@` - @$(IDLC) -C -I$(OO_SDK_HOME)/idl -O`dirname $@` $< - -%.uno.rdb: %.urd $(TYPES_RDB) - @echo $< ... - @mkdir -p `dirname $@` - @rm -f $@ - $(REGMERGE) -v $@ / $(TYPES_RDB) - $(REGMERGE) -v $@ /UCR $< - $(REGMERGE) -v $@ / $< - - -#---[ Release targets ]-------------------------------------------------------------------------------- - -Release: $(BINDIR)/$(PACKAGE).oxt - -install: $(BINRLS)/$(PACKAGE).uno@DLLEXT@ $(PACKAGE).uno.rdb description.xml manifest.xml description.txt $(PACKAGE).png - @$(MKDIR) $(instdir) - @$(MKDIR) $(instdir)/META-INF - @$(INSTALL_DATA) manifest.xml $(instdir)/META-INF - - @$(INSTALL_DATA) description.xml $(instdir) - @$(INSTALL_DATA) description.txt $(instdir) - - @$(INSTALL_DATA) $(PACKAGE).png $(instdir)/$(PACKAGE).png - - @$(INSTALL_PROGRAM) $(BINRLS)/$(PACKAGE).uno@DLLEXT@ $(instdir) - @$(INSTALL_DATA) $(PACKAGE).uno.rdb $(instdir) - -$(BINDIR)/$(PACKAGE).oxt: $(BINRLS)/$(PACKAGE).uno@DLLEXT@ $(PACKAGE).uno.rdb description.xml manifest.xml description.txt - @rm -f $@ - - @$(MKDIR) $(BINDIR)/$(PACKAGE).oxt.tmp - - @$(MKDIR) $(BINDIR)/$(PACKAGE).oxt.tmp/META-INF - @cp manifest.xml $(BINDIR)/$(PACKAGE).oxt.tmp/META-INF - - @cp description.xml $(BINDIR)/$(PACKAGE).oxt.tmp - @cp description.txt $(BINDIR)/$(PACKAGE).oxt.tmp - - @$(CONVERT) ../pw3270/pixmaps/pw3270.svg --format=png > $(BINDIR)/$(PACKAGE).oxt.tmp/$(PACKAGE).png - - @cp $(BINRLS)/$(PACKAGE).uno@DLLEXT@ $(BINDIR)/$(PACKAGE).oxt.tmp - @cp $(PACKAGE).uno.rdb $(BINDIR)/$(PACKAGE).oxt.tmp - @rm -f $(BINDIR)/$(PACKAGE).oxt - @cd $(BINDIR)/$(PACKAGE).oxt.tmp ; $(ZIP) -r -m ../$(PACKAGE).oxt . - @echo $@ Ok. - -$(BINRLS)/$(PACKAGE).uno@DLLEXT@: $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) - @echo $@ ... - @$(MKDIR) `dirname $@` - @$(CXX) $(DLL_FLAGS) $(LDFLAGS) -o $@ $^ - -$(PACKAGE).png: ../pw3270/pixmaps/pw3270.svg - @$(CONVERT) $^ --format=png > $@ - -#---[ Debug Targets ]---------------------------------------------------------------------------------- - -Debug: $(BINDBG)/testprogram - -run: $(BINDBG)/testprogram - @$(BINDBG)/testprogram - -$(BINDBG)/$(PACKAGE).uno@DLLEXT@: $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).o) - @echo $@ ... - @$(MKDIR) `dirname $@` - @$(CXX) $(DLL_FLAGS) $(LDFLAGS) -o $@ $^ - -$(BINDBG)/testprogram: $(BINDBG)/$(PACKAGE).uno@DLLEXT@ $(OBJDBG)/testprogram.o - @echo $@ ... - @$(MKDIR) `dirname $@` - @$(CXX) $(LDFLAGS) -o $@ $(OBJDBG)/testprogram.o - -$(OBJDIR)/uno/include/br/com/bb/$(PACKAGE).hpp: $(PACKAGE).uno.rdb - @echo $< ... - @rm -fr $(OBJDIR)/uno/include - @$(MKDIR) $(OBJDIR)/uno/include - @$(CPPUMAKER) -O$(OBJDIR)/uno/include -L -BUCR $< - @touch $@ - -cleanDebug: clean - -clean: - @rm -f *.urd - @rm -f *.uno.rdb - @rm -f $(PACKAGE).png - @rm -fr $(OBJDIR) - @rm -fr $(BINDIR) - diff --git a/src/oxt/actions.cxx b/src/oxt/actions.cxx deleted file mode 100644 index bd6b9c4..0000000 --- a/src/oxt/actions.cxx +++ /dev/null @@ -1,113 +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 actions.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" - #include - #include - -/*---[ Implement ]-----------------------------------------------------------------------------------------*/ - -::sal_Int16 SAL_CALL pw3270::uno_impl::enter( ) throw (::com::sun::star::uno::RuntimeException) -{ - return hSession->enter(); -} - -::sal_Int16 SAL_CALL pw3270::uno_impl::pfkey( ::sal_Int16 keycode ) throw (::com::sun::star::uno::RuntimeException) -{ - return hSession->pfkey((int) keycode); -} - -::sal_Int16 SAL_CALL pw3270::uno_impl::pakey( ::sal_Int16 keycode ) throw (::com::sun::star::uno::RuntimeException) -{ - return hSession->pakey((int) keycode); -} - -::sal_Int16 SAL_CALL pw3270::uno_impl::cmpTextAt( ::sal_Int16 row, ::sal_Int16 col, const ::rtl::OUString& text ) throw (::com::sun::star::uno::RuntimeException) -{ - return hSession->cmp_text_at((int) row, (int) col, rtl::OUStringToOString(text,hSession->get_encoding()).getStr()); -} - -::sal_Bool SAL_CALL pw3270::uno_impl::isReady( ) throw (::com::sun::star::uno::RuntimeException) -{ - if(!hSession->in_tn3270e()) - return false; - - if(hSession->get_state() == LIB3270_MESSAGE_NONE) - return true; - - return false; -} - -::sal_Bool SAL_CALL pw3270::uno_impl::isConnected( ) throw (::com::sun::star::uno::RuntimeException) -{ - return hSession->in_tn3270e() != 0; -} - -::sal_Bool SAL_CALL pw3270::uno_impl::hasTextAt( ::sal_Int16 row, ::sal_Int16 col, const ::rtl::OUString& text ) throw (::com::sun::star::uno::RuntimeException) -{ - if(!hSession->in_tn3270e()) - return false; - - return cmpTextAt(row,col,text) == 0; -} - -::sal_Int16 SAL_CALL pw3270::uno_impl::waitForReady( ::sal_Int16 seconds ) throw (::com::sun::star::uno::RuntimeException) -{ - time_t end = time(0) + seconds; - - while(time(0) < end) - { - osl_yieldThread(); - - switch(hSession->get_state()) - { - case LIB3270_MESSAGE_NONE: - return 0; - - case LIB3270_MESSAGE_DISCONNECTED: - return ENOTCONN; - - case LIB3270_MESSAGE_MINUS: - case LIB3270_MESSAGE_PROTECTED: - case LIB3270_MESSAGE_NUMERIC: - case LIB3270_MESSAGE_OVERFLOW: - case LIB3270_MESSAGE_INHIBIT: - case LIB3270_MESSAGE_KYBDLOCK: - return EPROTO; - - - } - - sleep(1); - } - - return ETIMEDOUT; -} diff --git a/src/oxt/connection.cxx b/src/oxt/connection.cxx deleted file mode 100644 index 3d54578..0000000 --- a/src/oxt/connection.cxx +++ /dev/null @@ -1,47 +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 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/description.txt b/src/oxt/description.txt deleted file mode 100644 index a163cab..0000000 --- a/src/oxt/description.txt +++ /dev/null @@ -1,2 +0,0 @@ -Uno/OpenOffice library allowing 3270 access from StarBasic - diff --git a/src/oxt/description.xml.in b/src/oxt/description.xml.in deleted file mode 100644 index 327d444..0000000 --- a/src/oxt/description.xml.in +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - 3270 access extension - - - - - - - - - - - - - diff --git a/src/oxt/get.cxx b/src/oxt/get.cxx deleted file mode 100644 index 875323e..0000000 --- a/src/oxt/get.cxx +++ /dev/null @@ -1,68 +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 get.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" - #include - -/*---[ Implement ]-----------------------------------------------------------------------------------------*/ - -sal_Int16 SAL_CALL pw3270::uno_impl::getRevision() throw (RuntimeException) -{ - return hSession->get_revision(); -} - -::rtl::OUString SAL_CALL pw3270::uno_impl::getVersion() throw (RuntimeException) -{ - const char *version = PACKAGE_VERSION; - return OUString(version, strlen(version), hSession->get_encoding(), RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); -} - -sal_Int16 SAL_CALL pw3270::uno_impl::getConnectionState( ) throw (::com::sun::star::uno::RuntimeException) -{ - return hSession->get_state(); -} - -::rtl::OUString SAL_CALL pw3270::uno_impl::getTextAt( ::sal_Int16 row, ::sal_Int16 col, ::sal_Int16 size ) throw (::com::sun::star::uno::RuntimeException) -{ - char * ptr = hSession->get_text_at(row,col,size); - OUString ret; - - if(!ptr) - return OUString( RTL_CONSTASCII_USTRINGPARAM( "" ) ); - - ret = OUString(ptr, strlen(ptr), hSession->get_encoding(), RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); - - hSession->mem_free(ptr); - - return ret; -} - - diff --git a/src/oxt/globals.hpp b/src/oxt/globals.hpp deleted file mode 100644 index e39c280..0000000 --- a/src/oxt/globals.hpp +++ /dev/null @@ -1,229 +0,0 @@ - - -#ifndef GLOBALS_HPP_INCLUDED - - #define GLOBALS_HPP_INCLUDED 1 - #define UNX 1 - #define GCC 1 - #define LINUX 1 - #define CPPU_ENV gcc3 - #define HAVE_GCC_VISIBILITY_FEATURE 1 - #define LANGUAGE_BINDING_NAME "gcc3" - - #include - #include - -#if defined(HAVE_DBUS) - #include - #include -#endif // HAVE_DBUS - - #include - #include - - #include // "3" implementing three interfaces - #include - #include - - #include - #include - #include - - #include - - /*---[ Debug macros ]--------------------------------------------------------------------------------------*/ - - #ifdef DEBUG - #define trace(fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr); - #else - #define trace( fmt, ... ) /* fmt __VA_ARGS__ */ - #endif - - /*---[ Object implementation ]-----------------------------------------------------------------------------*/ - - #define IMPLNAME "br.com.bb.pw3270intf" - #define SERVICENAME "br.com.bb.pw3270" - - using namespace br::com::bb; - using namespace ::rtl; // for OUString - using namespace ::com::sun::star; // for sdk interfaces - using namespace ::com::sun::star::uno; // for basic types - - namespace pw3270 - { - - class uno_impl; - - class session - { - public: - session(); - virtual ~session(); - virtual int get_revision(void) = 0; - virtual LIB3270_MESSAGE get_state(void) = 0; - virtual char * get_text_at(int row, int col, int len) = 0; - virtual int set_text_at(int row, int col, const char *text) = 0; - virtual int cmp_text_at(int row, int col, const char *text) = 0; - virtual void set_toggle(LIB3270_TOGGLE toggle, bool state) = 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; - virtual bool in_tn3270e() = 0; - virtual void mem_free(void *) = 0; - - void sleep(int seconds = 1); - - void log(const char *fmt, const char *msg); - - rtl_TextEncoding get_encoding(); - - }; - - class lib3270_session : public session - { - public: - lib3270_session(uno_impl *obj) throw( RuntimeException ); - virtual ~lib3270_session(); - - virtual int get_revision(void); - virtual LIB3270_MESSAGE get_state(void); - - virtual int connect(const char *uri); - virtual int disconnect(void); - virtual bool connected(void); - virtual bool in_tn3270e(void); - - virtual int enter(void); - virtual int pfkey(int key); - virtual int pakey(int key); - - virtual char * get_text_at(int row, int col, int len); - virtual int set_text_at(int row, int col, const char *text); - virtual int cmp_text_at(int row, int col, const char *text); - - virtual void mem_free(void *ptr); - virtual void set_toggle(LIB3270_TOGGLE toggle, bool state); - - private: - bool enabled; - oslModule hModule; - oslThread hThread; - H3270 * hSession; - - /* Internal calls */ - static void start_connect(lib3270_session *session); - void network_loop(void); - - /* lib3270 entry points */ - const char * (* _get_revision)(void); - LIB3270_MESSAGE (* _get_program_message)(H3270 *); - int (* _in_tn3270e)(H3270 *); - char * (* _get_text_at)(H3270 *,int,int,int); - int (* _set_text_at)(H3270 *,int,int,const unsigned char *); - int (* _cmp_text_at)(H3270 *,int,int,const char *); - int (* _enter)(H3270 *); - int (* _pfkey)(H3270 *, int); - int (* _pakey)(H3270 *, int); - void * (* _mem_free)(void *); - void (*_set_toggle)(void *h, LIB3270_TOGGLE ix, int value); - - - }; - - class ipc3270_session : public session - { - public: - ipc3270_session(uno_impl *obj, const char *name) throw( RuntimeException ); - virtual ~ipc3270_session(); - virtual int get_revision(void); - virtual LIB3270_MESSAGE get_state(void); - virtual char * get_text_at(int row, int col, int len); - virtual int set_text_at(int row, int col, const char *text); - virtual int cmp_text_at(int row, int col, const char *text); - virtual void set_toggle(LIB3270_TOGGLE toggle, bool state); - - 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 bool in_tn3270e(); - virtual void mem_free(void *); - - private: - -#if 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); - -#endif // HAVE_DBUS - - }; - - - class uno_impl : public ::cppu::WeakImplHelper3< br::com::bb::pw3270intf, com::sun::star::lang::XServiceInfo, com::sun::star::lang::XInitialization > - { - public: - - uno_impl( const com::sun::star::uno::Reference< XComponentContext > & xContext ); - virtual ~uno_impl(); - - // XInitialization will be called upon createInstanceWithArguments[AndContext]() - virtual void SAL_CALL initialize( Sequence< Any > const & args ) throw (Exception); - - // XServiceInfo implementation - virtual OUString SAL_CALL getImplementationName( ) throw(RuntimeException); - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException); - virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException); - - // pw3270 implementation - Main - virtual ::sal_Int16 SAL_CALL getRevision() throw (RuntimeException); - virtual ::rtl::OUString SAL_CALL getVersion( ) throw (::com::sun::star::uno::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); - virtual ::rtl::OUString SAL_CALL getTextAt( ::sal_Int16 row, ::sal_Int16 col, ::sal_Int16 size ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int16 SAL_CALL setTextAt( ::sal_Int16 row, ::sal_Int16 col, const ::rtl::OUString& text ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int16 SAL_CALL log(const ::rtl::OUString& text ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int16 SAL_CALL enter( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int16 SAL_CALL pfkey( ::sal_Int16 keycode ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int16 SAL_CALL pakey( ::sal_Int16 keycode ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int16 SAL_CALL cmpTextAt( ::sal_Int16 row, ::sal_Int16 col, const ::rtl::OUString& text ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL isReady( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL isConnected( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL hasTextAt( ::sal_Int16 row, ::sal_Int16 col, const ::rtl::OUString& text ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int16 SAL_CALL waitForReady( ::sal_Int16 seconds ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int16 SAL_CALL dsTrace( ::sal_Bool state ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int16 SAL_CALL screenTrace( ::sal_Bool state ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int16 SAL_CALL setSession( const ::rtl::OUString& name ) throw (::com::sun::star::uno::RuntimeException); - - void failed(const char *fmt, ...) throw( ::com::sun::star::uno::RuntimeException ); - - private: - - session *hSession; - - }; - - }; - - - - -#endif // GLOBALS_HPP_INCLUDED - diff --git a/src/oxt/local.cxx b/src/oxt/local.cxx deleted file mode 100644 index 6847e5e..0000000 --- a/src/oxt/local.cxx +++ /dev/null @@ -1,343 +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.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" - #include - #include - - #ifdef HAVE_SYSLOG - #include - #include - #endif // HAVE_SYSLOG - -/* - * NOTE: Take a better look at osl_createEmptySocketAddr() & osl_connectSocketTo() to see if there's - * a way to use this calls to connect with the host for better performance. - */ - -/*---[ Statics ]-------------------------------------------------------------------------------------------*/ - - -/*---[ Implement ]-----------------------------------------------------------------------------------------*/ - - 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 - } - - pw3270::lib3270_session::lib3270_session(uno_impl *obj) throw( RuntimeException ) - { - struct _call - { - void **entry; - 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 **) & _in_tn3270e, "lib3270_in_tn3270e" }, - { (void **) & _get_program_message, "lib3270_get_program_message" }, - { (void **) & _mem_free, "lib3270_free" }, - { (void **) & _set_toggle, "lib3270_set_toggle" } - - }; - - 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) ); - - hThread = NULL; - hSession = NULL; - - hModule = osl_loadModuleAscii("lib3270.so." PACKAGE_VERSION,SAL_LOADMODULE_NOW); - trace("%s: hModule(lib3270.so." PACKAGE_VERSION ")=%p",__FUNCTION__,hModule); - - if(!hModule) - { - hModule = osl_loadModuleAscii("lib3270.so." PACKAGE_VERSION,SAL_LOADMODULE_NOW); - trace("%s: hModule(lib3270.so)=%p",__FUNCTION__,hModule); - } - - if(!hModule) - { - obj->failed("%s","Can't load lib3270"); - return; - } - - for(int f = 0; f < (sizeof (call) / sizeof ((call)[0]));f++) - { - *call[f].entry = (void *) osl_getAsciiFunctionSymbol(hModule,call[f].name); - if(!*call[f].entry) - obj->failed("Error loading lib3270::%s",call[f].name); - } - - /* Get lib3270 session handle */ - set_log_handler = (void (*)(void (*loghandler)(H3270 *, const char *, int, const char *, va_list))) osl_getAsciiFunctionSymbol(hModule,"lib3270_set_log_handler"); - set_trace_handler = (void (*)(void (*handler)(H3270 *session, const char *fmt, va_list args) )) osl_getAsciiFunctionSymbol(hModule,"lib3270_set_trace_handler"); - - if(set_log_handler) - set_log_handler(loghandler); - - if(set_trace_handler) - set_trace_handler(tracehandler); - - lib3270_new = (H3270 * (*)(const char *)) osl_getAsciiFunctionSymbol(hModule,"lib3270_session_new"); - hSession = lib3270_new(""); - - log("%s UNO extension loaded",PACKAGE_NAME); - } - - pw3270::lib3270_session::~lib3270_session() - { - - trace("%s hModule=%p hSession=%p",__FUNCTION__,hModule,hSession); - - disconnect(); - osl_yieldThread(); - - if(hThread) - osl_joinWithThread(hThread); - - if(hModule) - { - if(hSession) - { - void (*lib3270_free)(void *) = (void (*)(void *)) osl_getAsciiFunctionSymbol(hModule,"lib3270_session_free"); - lib3270_free(hSession); - hSession = NULL; - } - osl_unloadModule(hModule); - hModule = NULL; - } - - log("%s UNO extension unloaded",PACKAGE_NAME); - } - - int pw3270::lib3270_session::get_revision(void) - { - if(!_get_revision) - return -1; - return atoi(_get_revision()); - } - - int pw3270::lib3270_session::connect(const char *uri) - { - const char * (*set_host)(void *h, const char *n); - - if(!(hModule && hSession)) - return EINVAL; - - if(hThread) - return EBUSY; - - set_host = (const char * (*)(void *,const char *)) osl_getAsciiFunctionSymbol(hModule,"lib3270_set_host"); - if(!set_host) - return EINVAL; - - set_host(hSession,uri); - - enabled = true; - hThread = osl_createThread((oslWorkerFunction) pw3270::lib3270_session::start_connect, this); - - osl_yieldThread(); - - if(!hThread) - return -1; - - osl_yieldThread(); - - return 0; - } - - int pw3270::lib3270_session::disconnect(void) - { - enabled = false; - return 0; - } - - void pw3270::lib3270_session::start_connect(lib3270_session *session) - { - session->network_loop(); - session->hThread = NULL; - session->enabled = false; - } - - void pw3270::lib3270_session::network_loop(void) - { - /* Lib3270 entry points */ - void (* _disconnect)(void *h) = - (void (*)(void *)) osl_getAsciiFunctionSymbol(hModule,"lib3270_disconnect"); - - int (* _connect)(void *h,const char *n, int wait) = - (int (*)(void *,const char *,int)) osl_getAsciiFunctionSymbol(hModule,"lib3270_connect"); - - int (* _status)(void *h) = - (int (*)(void *)) osl_getAsciiFunctionSymbol(hModule,"lib3270_disconnected"); - - void (*_iterate)(void *h, int wait) = - (void (*)(void *, int)) osl_getAsciiFunctionSymbol(hModule,"lib3270_main_iterate"); - - trace("%s starts",__FUNCTION__); - _connect(hSession,NULL,1); - - trace("%s network loop begin",__FUNCTION__); - while(enabled && !_status(hSession)) - { - osl_yieldThread(); - _iterate(hSession,1); - } - trace("%s network loop ends",__FUNCTION__); - - osl_yieldThread(); - - _disconnect(hSession); - - } - - bool pw3270::lib3270_session::connected(void) - { - return enabled; - } - - int pw3270::lib3270_session::enter(void) - { - if(!hSession) - return EINVAL; - return _enter(hSession); - } - - int pw3270::lib3270_session::pfkey(int key) - { - if(!hSession) - return EINVAL; - return _pfkey(hSession,key); - } - - int pw3270::lib3270_session::pakey(int key) - { - if(!hSession) - return EINVAL; - return _pakey(hSession,key); - } - - LIB3270_MESSAGE pw3270::lib3270_session::get_state(void) - { - if(!hSession) - return LIB3270_MESSAGE_DISCONNECTED; - return _get_program_message(hSession); - } - - void pw3270::lib3270_session::mem_free(void *ptr) - { - _mem_free(ptr); - } - - char * pw3270::lib3270_session::get_text_at(int row, int col, int len) - { - if(!hSession) - return NULL; - return _get_text_at(hSession,row,col,len); - } - - int pw3270::lib3270_session::set_text_at(int row, int col, const char *text) - { - if(!hSession) - return EINVAL; - return _set_text_at(hSession,row,col,(const unsigned char *) text); - } - - int pw3270::lib3270_session::cmp_text_at(int row, int col,const char *text) - { - if(!hSession) - return EINVAL; - return _cmp_text_at(hSession,row,col,text); - } - - bool pw3270::lib3270_session::in_tn3270e(void) - { - if(!hSession) - return false; - return _in_tn3270e(hSession) != 0; - } - - void pw3270::lib3270_session::set_toggle(LIB3270_TOGGLE toggle, bool state) - { - if(hSession) - _set_toggle(hSession,toggle,(int) state); - } diff --git a/src/oxt/main.cxx b/src/oxt/main.cxx deleted file mode 100644 index 4f31bb0..0000000 --- a/src/oxt/main.cxx +++ /dev/null @@ -1,330 +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 main.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" -#include - -#ifdef HAVE_SYSLOG - #include -#endif // HAVE_SYSLOG - -#include -#include -#include - -using namespace com::sun::star::registry; // for XRegistryKey -using namespace com::sun::star::lang; // for XSingleComponentFactory - -/*---[ Statics ]-------------------------------------------------------------------------------------------*/ - - - -/*---[ Implement ]-----------------------------------------------------------------------------------------*/ - -static Sequence< OUString > getSupportedServiceNames() -{ - Sequence names(1); - - trace("%s returns: %s",__FUNCTION__, SERVICENAME); - names[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME ) ); - - return names; -} - -static Reference< XInterface > SAL_CALL CreateInstance( const Reference< XComponentContext > & xContext ) -{ - return static_cast< XTypeProvider * >( new pw3270::uno_impl( xContext ) ); -} - -/*---[ Implement exported calls ]--------------------------------------------------------------------------*/ - -/************************************************************** - * Function to determine the environment of the implementation. - * - * If the environment is NOT session specific - * (needs no additional context), then this function - * should return the environment type name and leave ppEnv (0). - * - * @param ppEnvTypeName environment type name; - * string must be constant - * @param ppEnv function returns its environment - * if the environment is session specific, - * i.e. has special context - */ -extern "C" void SAL_CALL component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv) -{ -#ifdef LANGUAGE_BINDING_NAME - trace("%s set envtype to %s\n",__FUNCTION__,LANGUAGE_BINDING_NAME); - *ppEnvTypeName = LANGUAGE_BINDING_NAME; -#else - trace("%s set envtype to %s\n",__FUNCTION__,"msci"); - *ppEnvTypeName = "msci"; -#endif -} - -/************************************************************ - * Optional function to retrieve a component description. - * - * @return an XML formatted string containing a short - * component description - */ -// typedef const sal_Char * (SAL_CALL * component_getDescriptionFunc)(void); - -/********************************************************** - * Writes component registry info, at least writing the - * supported service names. - * - * @param pServiceManager a service manager - * (the type is XMultiServiceFactory - * to be used by the environment - * returned by - * component_getImplementationEnvironment) - * - * @param pRegistryKey a registry key - * (the type is XRegistryKey to be used - * by the environment returned by - * component_getImplementationEnvironment) - * - * @return true if everything went fine - */ -extern "C" sal_Bool SAL_CALL component_writeInfo(void * pServiceManager, void * pRegistryKey) -{ - sal_Bool result = sal_False; - - trace("%s",__FUNCTION__); - - if (pRegistryKey) - { - try - { - Reference< XRegistryKey > xNewKey( - reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( - OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLNAME "/UNO/SERVICES") ) ) ); - - const Sequence< OUString > & rSNL = getSupportedServiceNames(); - const OUString * pArray = rSNL.getConstArray(); - - for ( sal_Int32 nPos = rSNL.getLength(); nPos--; ) - xNewKey->createKey( pArray[nPos] ); - - return sal_True; - } - catch (InvalidRegistryException &) - { - // we should not ignore exceptions - } - } - - return result; -} - -/********************************************************* - * Retrieves a factory to create component instances. - * - * @param pImplName desired implementation name - * - * @param pServiceManager a service manager - * (the type is XMultiServiceFactory - * to be used by the environment - * returned by - * component_getImplementationEnvironment) - * - * @param pRegistryKey a registry key - * (the type is XRegistryKey to be used - * by the environment returned by - * component_getImplementationEnvironment) - * - * @return acquired component factory - * (the type is XInterface to be used by the - * environment returned by - * component_getImplementationEnvironment) - */ -extern "C" void * SAL_CALL component_getFactory(const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey) -{ - void * pRet = 0; - - trace("%s",__FUNCTION__); - - if(pServiceManager && rtl_str_compare( pImplName, IMPLNAME ) == 0) - { - Reference< XSingleComponentFactory > xFactory( ::cppu::createSingleComponentFactory( - CreateInstance, OUString::createFromAscii( IMPLNAME ), getSupportedServiceNames() )); - - - if (xFactory.is()) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - - return pRet; -} - -/*---[ Implement XInitialization ]-------------------------------------------------------------------------*/ - -void SAL_CALL pw3270::uno_impl::initialize( Sequence< Any > const & args ) throw (Exception) -{ - trace("%s",__FUNCTION__); -} - -/*---[ Implement XServiceInfo ]----------------------------------------------------------------------------*/ - -OUString SAL_CALL pw3270::uno_impl::getImplementationName( ) throw(RuntimeException) -{ - trace("%s",__FUNCTION__); - return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) ); -} - -sal_Bool SAL_CALL pw3270::uno_impl::supportsService( const OUString& ServiceName ) throw(RuntimeException) -{ - trace("%s",__FUNCTION__); - return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IMPLNAME") ); -} - -Sequence< OUString > pw3270::uno_impl::getSupportedServiceNames() throw (RuntimeException) -{ - return getSupportedServiceNames(); -} - -/*---[ Implement pw3270 ]----------------------------------------------------------------------------------*/ - -pw3270::uno_impl::uno_impl( const Reference< XComponentContext > & xContext ) -{ - this->hSession = new lib3270_session(this); -} - -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; -} - -::sal_Int16 SAL_CALL pw3270::uno_impl::log( const ::rtl::OUString& msg ) throw (::com::sun::star::uno::RuntimeException) -{ - hSession->log("%s",rtl::OUStringToOString(msg,RTL_TEXTENCODING_UTF8).getStr()); - return 0; -} - -::sal_Int16 SAL_CALL pw3270::uno_impl::dsTrace( ::sal_Bool state ) throw (::com::sun::star::uno::RuntimeException) -{ - hSession->log("DS trace is %s",state ? "ON" : "OFF"); - hSession->set_toggle(LIB3270_TOGGLE_DS_TRACE,state); - return 0; -} - -::sal_Int16 SAL_CALL pw3270::uno_impl::screenTrace( ::sal_Bool state ) throw (::com::sun::star::uno::RuntimeException) -{ - hSession->log("Screen trace is %s",state ? "ON" : "OFF"); - hSession->set_toggle(LIB3270_TOGGLE_SCREEN_TRACE,state); - return 0; -} - -pw3270::session::session() -{ - trace("%s",__FUNCTION__); -} - -pw3270::session::~session() -{ - trace("%s",__FUNCTION__); -} - -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); -} - -void pw3270::session::log(const char *fmt, const char *msg) -{ -#ifdef HAVE_SYSLOG - openlog(PACKAGE_NAME, LOG_NDELAY, LOG_USER); - syslog(LOG_INFO,fmt,msg); - closelog(); -#else - #error This module needs syslog support -#endif // HAVE_SYSLOG -} - -void pw3270::uno_impl::failed(const char *fmt, ...) throw( ::com::sun::star::uno::RuntimeException ) -{ - va_list arg_ptr; - char * msg = (char *) malloc(1024); - - va_start(arg_ptr, fmt); - vsnprintf(msg, 1023, fmt, arg_ptr); - va_end(arg_ptr); - -#ifdef HAVE_SYSLOG - openlog(PACKAGE_NAME, LOG_NDELAY, LOG_USER); - syslog(LOG_ERR,"%s",msg); - closelog(); -#endif // HAVE_SYSLOG - - trace("%s: %s",__FUNCTION__,msg); - - ::rtl::OUString str = OUString(msg, strlen(msg), RTL_TEXTENCODING_UTF8, RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); - - free(msg); - - throw Exception( str , *this ); - -} - -::sal_Int16 SAL_CALL pw3270::uno_impl::setSession( const ::rtl::OUString& name ) throw (::com::sun::star::uno::RuntimeException) -{ - const char *ptr; - - OString str = rtl::OUStringToOString( name , hSession->get_encoding() ); - - delete this->hSession; - - ptr = str.getStr(); - - if(ptr && *ptr) - this->hSession = new ipc3270_session(this,str.getStr()); - else - this->hSession = new lib3270_session(this); - - return 0; -} diff --git a/src/oxt/manifest.xml.in b/src/oxt/manifest.xml.in deleted file mode 100644 index 826cc22..0000000 --- a/src/oxt/manifest.xml.in +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/src/oxt/pw3270.idl b/src/oxt/pw3270.idl deleted file mode 100644 index ada7293..0000000 --- a/src/oxt/pw3270.idl +++ /dev/null @@ -1,101 +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., 51 Franklin - * St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Este programa está nomeado como pw3270.idl 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 -#include - -/* - - Referências: - - http://wiki.services.openoffice.org/wiki/IDL_Files_and_Cpp - http://wiki.services.openoffice.org/wiki/IDL_Files_and_Cpp#Specifying_an_interface - - */ - -module br -{ - module com - { - module bb - { - - /** - * Interface to pw3270. - * - * http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Bridge/Default_Mappings - * - */ - interface pw3270intf : com::sun::star::uno::XInterface - { - /* Connect/Disconnect */ - short Connect( [in] string hostinfo ); - short Disconnect(); - short getConnectionState(); - - /* Get */ - string getTextAt([in] short row, [in] short col, [in] short size); - - /* Set */ - short setTextAt([in] short row, [in] short col, [in] string text); - - /* Actions */ - short cmpTextAt([in] short row, [in] short col, [in] string text); - short enter(); - short pfkey([in] short keycode); - short pakey([in] short keycode); - - /* Misc */ - short setSession([in] string name); - short getRevision(); - string getVersion(); - short log([in] string msg); - short sleep([in] short seconds); - boolean isReady(); - boolean hasTextAt([in] short row, [in] short col, [in] string text); - short waitForReady([in] short seconds); -// short waitForTextAt(in] short row, [in] short col, [in] string text, [in] short seconds); - boolean isConnected(); - short dsTrace([in] boolean mode); - short screenTrace([in] boolean mode); - - }; - - service pw3270 - { - // exported interfaces: - interface pw3270intf; - }; - - }; - }; -}; - diff --git a/src/oxt/pw3270OXT.cbp b/src/oxt/pw3270OXT.cbp deleted file mode 100644 index 699cf5b..0000000 --- a/src/oxt/pw3270OXT.cbp +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - diff --git a/src/oxt/remote.cxx b/src/oxt/remote.cxx deleted file mode 100644 index bc87757..0000000 --- a/src/oxt/remote.cxx +++ /dev/null @@ -1,533 +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.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" - #include - #include - -/*---[ Statics ]-------------------------------------------------------------------------------------------*/ - -#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 * pw3270::ipc3270_session::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) - log("Error creating message for method %s",method); - - return msg; -} - -DBusMessage * pw3270::ipc3270_session::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) - { - log("%s",error.message); - dbus_error_free(&error); - } - - return reply; - -} - -static char * 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); - } -#ifdef DEBUG - else - { - trace("Return type is %c, expecting %c",dbus_message_iter_get_arg_type(&iter),DBUS_TYPE_STRING); - } -#endif - } - - dbus_message_unref(msg); - } - return rc; -} - -char * pw3270::ipc3270_session::query_string(const char *method) -{ - if(conn) - return get_string(call(create_message(method))); - return NULL; -} - -static int 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; - } -#ifdef DEBUG - else - { - trace("Return type is %c, expecting %c",dbus_message_iter_get_arg_type(&iter),DBUS_TYPE_INT32); - } -#endif - } - - dbus_message_unref(msg); - } - - return rc; -} - -int pw3270::ipc3270_session::query_intval(const char *method) -{ - if(conn) - return get_intval(call(create_message(method))); - return -1; -} - -#endif // HAVE_DBUS - - -pw3270::ipc3270_session::ipc3270_session(uno_impl *obj, const char *name) throw( RuntimeException ) : pw3270::session() -{ -#ifdef HAVE_DBUS - - DBusError err; - int rc; - char * str = strdup(name); - char * ptr; - - 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("conn=%p",conn); - - if (dbus_error_is_set(&err)) - { - trace("DBUS Connection Error (%s)", err.message); - obj->failed("DBUS Connection Error (%s)", err.message); - dbus_error_free(&err); - return; - } - - if(!conn) - { - obj->failed("%s", "DBUS Connection failed"); - return; - } - - rc = dbus_bus_request_name(conn, "br.com.bb." PACKAGE_NAME ".oo", DBUS_NAME_FLAG_REPLACE_EXISTING , &err); - - if (dbus_error_is_set(&err)) - { - obj->failed("DBUS Name Error (%s)", err.message); - dbus_error_free(&err); - conn = NULL; - return; - } - - if(rc != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) - { - obj->failed("%s", "DBUS request name failed"); - conn = NULL; - return; - } - else - { - DBusMessage * reply; - DBusMessage * msg = create_message("getRevision"); - DBusError error; - - dbus_error_init(&error); - reply = dbus_connection_send_with_reply_and_block(conn,msg,10000,&error); - dbus_message_unref(msg); - - if(reply) - { - log("%s","PW3270 DBus object found"); - dbus_message_unref(reply); - } - else - { - obj->failed("DBUS error: %s",error.message); - dbus_error_free(&error); - } - } -#else - -#endif // HAVE_DBUS -} - -pw3270::ipc3270_session::~ipc3270_session() -{ -#ifdef HAVE_DBUS - - free(dest); - free(path); - free(intf); - -#endif // HAVE_DBUS -} - -int pw3270::ipc3270_session::get_revision(void) -{ -#ifdef HAVE_DBUS - char *ptr = query_string("getRevision"); - if(ptr) - { - int rc = atoi(ptr); - free(ptr); - return rc; - } - return -1; - -#else - - return -1; - -#endif // HAVE_DBUS -} - -LIB3270_MESSAGE pw3270::ipc3270_session::get_state(void) -{ -#ifdef HAVE_DBUS - - return (LIB3270_MESSAGE) query_intval("getMessageID"); - -#else - - return (LIB3270_MESSAGE) -1; - -#endif // HAVE_DBUS -} - -char * pw3270::ipc3270_session::get_text_at(int row, int col, int len) -{ -#ifdef 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) len; - - 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)); - -#else - - return NULL; - -#endif // HAVE_DBUS -} - -int pw3270::ipc3270_session::set_text_at(int row, int col, const char *text) -{ -#ifdef 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, &text, DBUS_TYPE_INVALID); - return get_intval(call(msg)); - } - -#else - - return -1; - -#endif // HAVE_DBUS -} - -int pw3270::ipc3270_session::cmp_text_at(int row, int col, const char *text) -{ -#ifdef 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)); - } - -#else - - return -1; - -#endif // HAVE_DBUS -} - -void pw3270::ipc3270_session::set_toggle(LIB3270_TOGGLE toggle, bool state) -{ -#ifdef HAVE_DBUS - - dbus_int32_t i = (dbus_int32_t) toggle; - dbus_int32_t v = (dbus_int32_t) state; - - DBusMessage * msg = create_message("setToggle"); - if(msg) - { - dbus_message_append_args(msg, DBUS_TYPE_INT32, &i, DBUS_TYPE_INT32, &v, DBUS_TYPE_INVALID); - get_intval(call(msg)); - } - -#endif // HAVE_DBUS -} - -int pw3270::ipc3270_session::connect(const char *uri) -{ -#ifdef 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); - - return get_intval(call(msg)); - -#else - - return -1; - -#endif // HAVE_DBUS -} - -int pw3270::ipc3270_session::disconnect(void) -{ -#ifdef HAVE_DBUS - - return query_intval("disconnect"); - -#else - - return -1; - -#endif // HAVE_DBUS -} - -bool pw3270::ipc3270_session::connected(void) -{ -#ifdef HAVE_DBUS - - return query_intval("isConnected") > 0; - -#else - - return false; - -#endif // HAVE_DBUS -} - -int pw3270::ipc3270_session::enter(void) -{ -#ifdef HAVE_DBUS - - return query_intval("enter"); - -#else - - return -1; - -#endif // HAVE_DBUS -} - -int pw3270::ipc3270_session::pfkey(int key) -{ -#ifdef 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 // HAVE_DBUS - - return -1; - -} - -int pw3270::ipc3270_session::pakey(int key) -{ -#ifdef 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 // HAVE_DBUS - - return -1; - -} - -bool pw3270::ipc3270_session::in_tn3270e() -{ -#ifdef HAVE_DBUS - - return query_intval("inTN3270E") > 0; - -#else - - return false; - -#endif // HAVE_DBUS -} - -void pw3270::ipc3270_session::mem_free(void *ptr) -{ -#ifdef HAVE_DBUS - - free(ptr); - -#else - - -#endif // HAVE_DBUS -} - - diff --git a/src/oxt/set.cxx b/src/oxt/set.cxx deleted file mode 100644 index 9a55799..0000000 --- a/src/oxt/set.cxx +++ /dev/null @@ -1,42 +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 set.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" - #include - -/*---[ Implement ]-----------------------------------------------------------------------------------------*/ - -::sal_Int16 SAL_CALL pw3270::uno_impl::setTextAt( ::sal_Int16 row, ::sal_Int16 col, const ::rtl::OUString& text ) throw (::com::sun::star::uno::RuntimeException) -{ - return hSession->set_text_at((int) row, (int) col, rtl::OUStringToOString(text,hSession->get_encoding()).getStr()); -} - - diff --git a/src/oxt/testprogram.cxx b/src/oxt/testprogram.cxx deleted file mode 100644 index 4bf09ad..0000000 --- a/src/oxt/testprogram.cxx +++ /dev/null @@ -1,173 +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 testprogram.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 -#ifdef WIN32 - #include - #define sleep(x) Sleep(x) -#endif - -#define trace( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr); - -#include "globals.hpp" -#include -#include -#include -#include - -using namespace com::sun::star::registry; -using namespace com::sun::star::lang; -using namespace cppu; - -/*---[ Implement ]-----------------------------------------------------------------------------------------*/ - -int SAL_CALL main(int argc, char **argv) -{ - Reference< XSimpleRegistry > xReg = createSimpleRegistry(); - - OSL_ENSURE( xReg.is(), "### cannot get service instance of \"com.sun.star.regiystry.SimpleRegistry\"!" ); - - xReg->open(OUString::createFromAscii("pw3270.uno.rdb"), sal_False, sal_False); - - OSL_ENSURE( xReg->isValid(), "### cannot open test registry \"pw3270.uno.rdb\"!" ); - - trace("%s","Calling bootstrap_InitialComponentContext"); - Reference< XComponentContext > xContext = bootstrap_InitialComponentContext(xReg); - OSL_ENSURE( xContext.is(), "### cannot creage intial component context!" ); - - trace("%s","Calling getServiceManager\n"); - Reference< XMultiComponentFactory > xMgr = xContext->getServiceManager(); - OSL_ENSURE( xMgr.is(), "### cannot get initial service manager!" ); - - // register my component - trace("%s","Calling createInstanceWithContext"); - - Reference< XImplementationRegistration > xImplReg( - xMgr->createInstanceWithContext(OUString::createFromAscii("com.sun.star.registry.ImplementationRegistration"), xContext), UNO_QUERY); - OSL_ENSURE( xImplReg.is(), "### cannot get service instance of \"com.sun.star.registry.ImplementationRegistration\"!" ); - - if (xImplReg.is()) - { - const char *libname = ".bin/Debug/pw3270.uno.so"; - - trace("Loading %s",libname); - - xImplReg->registerImplementation( - OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), // loader for component - OUString::createFromAscii(libname), // component location - Reference< XSimpleRegistry >() // registry omitted, - // defaulting to service manager registry used - ); - - // get an object instance - printf("Calling createInstanceWithContext(%s)\n",IMPLNAME); - - Reference< XInterface > xx ; - xx = xMgr->createInstanceWithContext(OUString::createFromAscii(IMPLNAME), xContext); - - printf("Instance: %p\n",&xx); - - Reference< pw3270intf > srv( xx, UNO_QUERY ); - - OSL_ENSURE( srv.is(), "### cannot get service instance!"); - - printf("object.is(): %d\n",srv.is()); - - if(srv.is()) - { - // Wait for commands - char buffer[4096]; - OString str; - - try - { - - srv->setSession(OUString::createFromAscii("pw3270:a")); - - } - catch( RuntimeException & e ) - { - OString o = OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ); - fprintf( stderr, "%s\n", o.pData->buffer ); - exit(-1); - } - - printf("Revision:\t%d\n",srv->getRevision()); - - srv->dsTrace(true); - srv->screenTrace(true); - - printf("getConnectionState: %d\n", srv->getConnectionState()); - printf("Connect(): %d\n" , srv->Connect(OUString::createFromAscii("L:3270.df.bb:9023"))); - - srv->sleep(2); - printf("getConnectionState: %d\n", srv->getConnectionState()); - srv->sleep(2); - - str = OUStringToOString( srv->getTextAt(1,1,2000),RTL_TEXTENCODING_UTF8); - printf("ContentsAt(1,1):\n%s\n",str.pData->buffer); - - printf("getConnectionState: %d\n", srv->getConnectionState()); - - srv->sleep(1); - srv->enter(); - srv->sleep(1); - - str = OUStringToOString( srv->getTextAt(1,1,2000),RTL_TEXTENCODING_UTF8); - printf("ContentsAt(1,1):\n%s\n",str.pData->buffer); - - /* - printf("waitForStringAt(SISBB) returned %d\n",srv->waitForStringAt(20,39,OUString::createFromAscii("SISBB"),20)); - printf("sendEnterKey() returned %d\n",srv->sendEnterKey()); - printf("waitForStringAt(Senha) returned %d\n",srv->waitForStringAt(14,2,OUString::createFromAscii("Senha"),20)); - printf("setStringAt returned %d\n",srv->setStringAt(13,21,OUString::createFromAscii("c1103788"))); - - str = OUStringToOString( srv->getScreenContent(),RTL_TEXTENCODING_UTF8); - printf("Entire screen:\n%s\n",str.pData->buffer); - - - */ - - printf("Enter to exit...\n"); - fgets(buffer,80,stdin); - - printf("Disconnect(): %d\n" , srv->Disconnect()); - - srv->sleep(5); - - } - } - - - Reference< XComponent >::query( xContext )->dispose(); - - return 0; -} -- libgit2 0.21.2