Commit ae8948cbdac52e41401368020c2f582640dc7bf6

Authored by perry.werneck@gmail.com
1 parent 7a99821c

Reconstruindo módulo libreoffice do zero

src/oxt/Makefile.in
... ... @@ -1,175 +0,0 @@
1   -
2   -PACKAGE=@PACKAGE_NAME@
3   -
4   -SOURCES=main.cxx local.cxx connection.cxx get.cxx set.cxx actions.cxx remote.cxx
5   -
6   -prefix=/usr
7   -exec_prefix=@exec_prefix@
8   -libdir=@libdir@
9   -instdir=$(DESTDIR)/$(libdir)/libreoffice/share/extensions/$(PACKAGE)
10   -
11   -#---[ Paths ]------------------------------------------------------------------------------------------
12   -ROOTDIR ?= .
13   -OBJDIR ?= $(ROOTDIR)/.obj
14   -BINDIR ?= $(ROOTDIR)/.bin
15   -
16   -BINDBG ?= $(BINDIR)/Debug
17   -BINRLS ?= $(BINDIR)/Release
18   -LIBDBG ?= $(BINDIR)/Debug/lib
19   -
20   -OBJDBG = $(OBJDIR)/Debug
21   -OBJRLS = $(OBJDIR)/Release
22   -
23   -#---[ Tools ]------------------------------------------------------------------------------------------
24   -MKDIR=@MKDIR_P@
25   -INSTALL=@INSTALL@
26   -INSTALL_DATA=@INSTALL_DATA@
27   -INSTALL_PROGRAM=@INSTALL_PROGRAM@
28   -CXX=@CXX@
29   -CONVERT=@CONVERT@
30   -ZIP=@ZIP@
31   -
32   -DBG_CFLAGS=-g -DDEBUG=1
33   -RLS_CFLAGS=-DNDEBUG=1
34   -
35   -#---[ LibreOffice SDK ]--------------------------------------------------------------------------------
36   -COMID=gcc3
37   -OO_SDK_NAME=openoffice.org3.5_sdk
38   -OFFICE_HOME=@OFFICE_HOME@
39   -OO_SDK_HOME=@OO_SDK_HOME@
40   -OO_SDK_URE_HOME=@OO_SDK_URE_HOME@
41   -OO_SDK_URE_BIN_DIR=${OO_SDK_URE_HOME}/bin
42   -OO_SDK_URE_LIB_DIR=${OO_SDK_URE_HOME}/lib
43   -
44   -TYPES_RDB=${OO_SDK_URE_HOME}/share/misc/types.rdb
45   -
46   -SALLIB=-luno_sal
47   -CPPULIB=-luno_cppu
48   -CPPUHELPERLIB=-luno_cppuhelper$(COMID)
49   -SALHELPERLIB=-luno_salhelper$(COMID)
50   -REGLIB=-lreg
51   -STORELIB=-lstore
52   -
53   -# Libre office tools
54   -IDLC=@IDLC@
55   -REGMERGE=@REGMERGE@
56   -CPPUMAKER=@CPPUMAKER@
57   -
58   -#---[ Rules ]------------------------------------------------------------------------------------------
59   -
60   -LIB3270_CFLAGS ?= `pkg-config --cflags lib3270`
61   -
62   -DLL_CFLAGS=@DLL_CFLAGS@
63   -DLL_FLAGS=-shared
64   -
65   -CXXFLAGS=-Wno-strict-aliasing -I$(OBJDIR)/uno/include -I$(OO_SDK_HOME)/include \
66   - -I$(OBJDIR)/uno/include/br/com/bb $(LIB3270_CFLAGS) \
67   - @DBUS_CFLAGS@
68   -
69   -LDFLAGS=-L${OO_SDK_HOME}/lib -L${OO_SDK_URE_HOME}/lib \
70   - -Wl,-rpath-link=${OO_SDK_URE_HOME}/lib,-rpath=${OO_SDK_URE_HOME}/lib \
71   - $(CPPULIB) $(CPPUHELPERLIB) $(SALLIB) @DBUS_LIBS@
72   -
73   -# CC_DEFINES=-DUNX -DGCC -DLINUX -DCPPU_ENV=$(CPPU_ENV) -DGXX_INCLUDE_PATH=$(SDK_GXX_INCLUDE_PATH) -DHAVE_GCC_VISIBILITY_FEATURE
74   -
75   -$(OBJDBG)/%.o: %.cxx $(OBJDIR)/uno/include/br/com/bb/$(PACKAGE).hpp Makefile
76   - @echo $< ...
77   - @$(MKDIR) `dirname $@`
78   - @$(CXX) $(DBG_CFLAGS) $(CXXFLAGS) $(LIB3270_CFLAGS) $(DLL_CFLAGS) -o $@ -c $<
79   -
80   -$(OBJRLS)/%.o: %.cxx $(OBJDIR)/uno/include/br/com/bb/$(PACKAGE).hpp Makefile
81   - @echo $< ...
82   - @$(MKDIR) `dirname $@`
83   - @$(CXX) $(CXXFLAGS) $(LIB3270_CFLAGS) $(DLL_CFLAGS) -o $@ -c $<
84   -
85   -%.urd: %.idl
86   - @echo $< ...
87   - @$(MKDIR) `dirname $@`
88   - @$(IDLC) -C -I$(OO_SDK_HOME)/idl -O`dirname $@` $<
89   -
90   -%.uno.rdb: %.urd $(TYPES_RDB)
91   - @echo $< ...
92   - @mkdir -p `dirname $@`
93   - @rm -f $@
94   - $(REGMERGE) -v $@ / $(TYPES_RDB)
95   - $(REGMERGE) -v $@ /UCR $<
96   - $(REGMERGE) -v $@ / $<
97   -
98   -
99   -#---[ Release targets ]--------------------------------------------------------------------------------
100   -
101   -Release: $(BINDIR)/$(PACKAGE).oxt
102   -
103   -install: $(BINRLS)/$(PACKAGE).uno@DLLEXT@ $(PACKAGE).uno.rdb description.xml manifest.xml description.txt $(PACKAGE).png
104   - @$(MKDIR) $(instdir)
105   - @$(MKDIR) $(instdir)/META-INF
106   - @$(INSTALL_DATA) manifest.xml $(instdir)/META-INF
107   -
108   - @$(INSTALL_DATA) description.xml $(instdir)
109   - @$(INSTALL_DATA) description.txt $(instdir)
110   -
111   - @$(INSTALL_DATA) $(PACKAGE).png $(instdir)/$(PACKAGE).png
112   -
113   - @$(INSTALL_PROGRAM) $(BINRLS)/$(PACKAGE).uno@DLLEXT@ $(instdir)
114   - @$(INSTALL_DATA) $(PACKAGE).uno.rdb $(instdir)
115   -
116   -$(BINDIR)/$(PACKAGE).oxt: $(BINRLS)/$(PACKAGE).uno@DLLEXT@ $(PACKAGE).uno.rdb description.xml manifest.xml description.txt
117   - @rm -f $@
118   -
119   - @$(MKDIR) $(BINDIR)/$(PACKAGE).oxt.tmp
120   -
121   - @$(MKDIR) $(BINDIR)/$(PACKAGE).oxt.tmp/META-INF
122   - @cp manifest.xml $(BINDIR)/$(PACKAGE).oxt.tmp/META-INF
123   -
124   - @cp description.xml $(BINDIR)/$(PACKAGE).oxt.tmp
125   - @cp description.txt $(BINDIR)/$(PACKAGE).oxt.tmp
126   -
127   - @$(CONVERT) ../pw3270/pixmaps/pw3270.svg --format=png > $(BINDIR)/$(PACKAGE).oxt.tmp/$(PACKAGE).png
128   -
129   - @cp $(BINRLS)/$(PACKAGE).uno@DLLEXT@ $(BINDIR)/$(PACKAGE).oxt.tmp
130   - @cp $(PACKAGE).uno.rdb $(BINDIR)/$(PACKAGE).oxt.tmp
131   - @rm -f $(BINDIR)/$(PACKAGE).oxt
132   - @cd $(BINDIR)/$(PACKAGE).oxt.tmp ; $(ZIP) -r -m ../$(PACKAGE).oxt .
133   - @echo $@ Ok.
134   -
135   -$(BINRLS)/$(PACKAGE).uno@DLLEXT@: $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o)
136   - @echo $@ ...
137   - @$(MKDIR) `dirname $@`
138   - @$(CXX) $(DLL_FLAGS) $(LDFLAGS) -o $@ $^
139   -
140   -$(PACKAGE).png: ../pw3270/pixmaps/pw3270.svg
141   - @$(CONVERT) $^ --format=png > $@
142   -
143   -#---[ Debug Targets ]----------------------------------------------------------------------------------
144   -
145   -Debug: $(BINDBG)/testprogram
146   -
147   -run: $(BINDBG)/testprogram
148   - @$(BINDBG)/testprogram
149   -
150   -$(BINDBG)/$(PACKAGE).uno@DLLEXT@: $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).o)
151   - @echo $@ ...
152   - @$(MKDIR) `dirname $@`
153   - @$(CXX) $(DLL_FLAGS) $(LDFLAGS) -o $@ $^
154   -
155   -$(BINDBG)/testprogram: $(BINDBG)/$(PACKAGE).uno@DLLEXT@ $(OBJDBG)/testprogram.o
156   - @echo $@ ...
157   - @$(MKDIR) `dirname $@`
158   - @$(CXX) $(LDFLAGS) -o $@ $(OBJDBG)/testprogram.o
159   -
160   -$(OBJDIR)/uno/include/br/com/bb/$(PACKAGE).hpp: $(PACKAGE).uno.rdb
161   - @echo $< ...
162   - @rm -fr $(OBJDIR)/uno/include
163   - @$(MKDIR) $(OBJDIR)/uno/include
164   - @$(CPPUMAKER) -O$(OBJDIR)/uno/include -L -BUCR $<
165   - @touch $@
166   -
167   -cleanDebug: clean
168   -
169   -clean:
170   - @rm -f *.urd
171   - @rm -f *.uno.rdb
172   - @rm -f $(PACKAGE).png
173   - @rm -fr $(OBJDIR)
174   - @rm -fr $(BINDIR)
175   -
src/oxt/actions.cxx
... ... @@ -1,113 +0,0 @@
1   -/*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270.
5   - *
6   - * Copyright (C) <2008> <Banco do Brasil S.A.>
7   - *
8   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
9   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
10   - * Free Software Foundation.
11   - *
12   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
13   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
14   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
15   - * obter mais detalhes.
16   - *
17   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
18   - * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
19   - * Place, Suite 330, Boston, MA, 02111-1307, USA
20   - *
21   - * Este programa está nomeado como actions.cxx e possui - linhas de código.
22   - *
23   - * Contatos:
24   - *
25   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27   - * licinio@bb.com.br (Licínio Luis Branco)
28   - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
29   - *
30   - */
31   -
32   - #include "globals.hpp"
33   - #include <unistd.h>
34   - #include <string.h>
35   -
36   -/*---[ Implement ]-----------------------------------------------------------------------------------------*/
37   -
38   -::sal_Int16 SAL_CALL pw3270::uno_impl::enter( ) throw (::com::sun::star::uno::RuntimeException)
39   -{
40   - return hSession->enter();
41   -}
42   -
43   -::sal_Int16 SAL_CALL pw3270::uno_impl::pfkey( ::sal_Int16 keycode ) throw (::com::sun::star::uno::RuntimeException)
44   -{
45   - return hSession->pfkey((int) keycode);
46   -}
47   -
48   -::sal_Int16 SAL_CALL pw3270::uno_impl::pakey( ::sal_Int16 keycode ) throw (::com::sun::star::uno::RuntimeException)
49   -{
50   - return hSession->pakey((int) keycode);
51   -}
52   -
53   -::sal_Int16 SAL_CALL pw3270::uno_impl::cmpTextAt( ::sal_Int16 row, ::sal_Int16 col, const ::rtl::OUString& text ) throw (::com::sun::star::uno::RuntimeException)
54   -{
55   - return hSession->cmp_text_at((int) row, (int) col, rtl::OUStringToOString(text,hSession->get_encoding()).getStr());
56   -}
57   -
58   -::sal_Bool SAL_CALL pw3270::uno_impl::isReady( ) throw (::com::sun::star::uno::RuntimeException)
59   -{
60   - if(!hSession->in_tn3270e())
61   - return false;
62   -
63   - if(hSession->get_state() == LIB3270_MESSAGE_NONE)
64   - return true;
65   -
66   - return false;
67   -}
68   -
69   -::sal_Bool SAL_CALL pw3270::uno_impl::isConnected( ) throw (::com::sun::star::uno::RuntimeException)
70   -{
71   - return hSession->in_tn3270e() != 0;
72   -}
73   -
74   -::sal_Bool SAL_CALL pw3270::uno_impl::hasTextAt( ::sal_Int16 row, ::sal_Int16 col, const ::rtl::OUString& text ) throw (::com::sun::star::uno::RuntimeException)
75   -{
76   - if(!hSession->in_tn3270e())
77   - return false;
78   -
79   - return cmpTextAt(row,col,text) == 0;
80   -}
81   -
82   -::sal_Int16 SAL_CALL pw3270::uno_impl::waitForReady( ::sal_Int16 seconds ) throw (::com::sun::star::uno::RuntimeException)
83   -{
84   - time_t end = time(0) + seconds;
85   -
86   - while(time(0) < end)
87   - {
88   - osl_yieldThread();
89   -
90   - switch(hSession->get_state())
91   - {
92   - case LIB3270_MESSAGE_NONE:
93   - return 0;
94   -
95   - case LIB3270_MESSAGE_DISCONNECTED:
96   - return ENOTCONN;
97   -
98   - case LIB3270_MESSAGE_MINUS:
99   - case LIB3270_MESSAGE_PROTECTED:
100   - case LIB3270_MESSAGE_NUMERIC:
101   - case LIB3270_MESSAGE_OVERFLOW:
102   - case LIB3270_MESSAGE_INHIBIT:
103   - case LIB3270_MESSAGE_KYBDLOCK:
104   - return EPROTO;
105   -
106   -
107   - }
108   -
109   - sleep(1);
110   - }
111   -
112   - return ETIMEDOUT;
113   -}
src/oxt/connection.cxx
... ... @@ -1,47 +0,0 @@
1   -/*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270.
5   - *
6   - * Copyright (C) <2008> <Banco do Brasil S.A.>
7   - *
8   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
9   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
10   - * Free Software Foundation.
11   - *
12   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
13   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
14   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
15   - * obter mais detalhes.
16   - *
17   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
18   - * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
19   - * Place, Suite 330, Boston, MA, 02111-1307, USA
20   - *
21   - * Este programa está nomeado como connection.cxx e possui - linhas de código.
22   - *
23   - * Contatos:
24   - *
25   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27   - * licinio@bb.com.br (Licínio Luis Branco)
28   - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
29   - *
30   - */
31   -
32   - #include "globals.hpp"
33   -
34   -/*---[ Implement ]-----------------------------------------------------------------------------------------*/
35   -
36   -sal_Int16 SAL_CALL pw3270::uno_impl::Connect( const ::rtl::OUString& hostinfo ) throw (::com::sun::star::uno::RuntimeException)
37   -{
38   - OString str = rtl::OUStringToOString( hostinfo , hSession->get_encoding() );
39   - return hSession->connect(str.getStr());
40   -}
41   -
42   -sal_Int16 SAL_CALL pw3270::uno_impl::Disconnect( ) throw (::com::sun::star::uno::RuntimeException)
43   -{
44   - return hSession->disconnect();
45   -}
46   -
47   -
src/oxt/description.txt
... ... @@ -1,2 +0,0 @@
1   -Uno/OpenOffice library allowing 3270 access from StarBasic
2   -
src/oxt/description.xml.in
... ... @@ -1,30 +0,0 @@
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<description xmlns="http://openoffice.org/extensions/description/2006"
3   -xmlns:d="http://openoffice.org/extensions/description/2006"
4   -xmlns:xlink="http://www.w3.org/1999/xlink">
5   -
6   - <version value="@PACKAGE_VERSION@" />
7   -
8   - <identifier value="@PACKAGE_NAME@" />
9   -
10   - <platform value="linux_@host_cpu@" />
11   -
12   - <dependencies>
13   - <OpenOffice.org-minimal-version value="2.2" d:name="OpenOffice.org 2.2"/>
14   - </dependencies>
15   -
16   - <display-name>
17   - <name lang="en">3270 access extension</name>
18   - </display-name>
19   -
20   - <icon>
21   - <default xlink:href="@PACKAGE_NAME@.png" />
22   - </icon>
23   -
24   - <extension-description>
25   - <src xlink:href="description.txt" lang="en" />
26   - </extension-description>
27   -
28   -
29   -
30   -</description>
src/oxt/get.cxx
... ... @@ -1,68 +0,0 @@
1   -/*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270.
5   - *
6   - * Copyright (C) <2008> <Banco do Brasil S.A.>
7   - *
8   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
9   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
10   - * Free Software Foundation.
11   - *
12   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
13   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
14   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
15   - * obter mais detalhes.
16   - *
17   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
18   - * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
19   - * Place, Suite 330, Boston, MA, 02111-1307, USA
20   - *
21   - * Este programa está nomeado como get.cxx e possui - linhas de código.
22   - *
23   - * Contatos:
24   - *
25   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27   - * licinio@bb.com.br (Licínio Luis Branco)
28   - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
29   - *
30   - */
31   -
32   - #include "globals.hpp"
33   - #include <string.h>
34   -
35   -/*---[ Implement ]-----------------------------------------------------------------------------------------*/
36   -
37   -sal_Int16 SAL_CALL pw3270::uno_impl::getRevision() throw (RuntimeException)
38   -{
39   - return hSession->get_revision();
40   -}
41   -
42   -::rtl::OUString SAL_CALL pw3270::uno_impl::getVersion() throw (RuntimeException)
43   -{
44   - const char *version = PACKAGE_VERSION;
45   - return OUString(version, strlen(version), hSession->get_encoding(), RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE);
46   -}
47   -
48   -sal_Int16 SAL_CALL pw3270::uno_impl::getConnectionState( ) throw (::com::sun::star::uno::RuntimeException)
49   -{
50   - return hSession->get_state();
51   -}
52   -
53   -::rtl::OUString SAL_CALL pw3270::uno_impl::getTextAt( ::sal_Int16 row, ::sal_Int16 col, ::sal_Int16 size ) throw (::com::sun::star::uno::RuntimeException)
54   -{
55   - char * ptr = hSession->get_text_at(row,col,size);
56   - OUString ret;
57   -
58   - if(!ptr)
59   - return OUString( RTL_CONSTASCII_USTRINGPARAM( "" ) );
60   -
61   - ret = OUString(ptr, strlen(ptr), hSession->get_encoding(), RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE);
62   -
63   - hSession->mem_free(ptr);
64   -
65   - return ret;
66   -}
67   -
68   -
src/oxt/globals.hpp
... ... @@ -1,229 +0,0 @@
1   -
2   -
3   -#ifndef GLOBALS_HPP_INCLUDED
4   -
5   - #define GLOBALS_HPP_INCLUDED 1
6   - #define UNX 1
7   - #define GCC 1
8   - #define LINUX 1
9   - #define CPPU_ENV gcc3
10   - #define HAVE_GCC_VISIBILITY_FEATURE 1
11   - #define LANGUAGE_BINDING_NAME "gcc3"
12   -
13   - #include <stdio.h>
14   - #include <lib3270.h>
15   -
16   -#if defined(HAVE_DBUS)
17   - #include <stdio.h>
18   - #include <dbus/dbus.h>
19   -#endif // HAVE_DBUS
20   -
21   - #include <rtl/uuid.h>
22   - #include <osl/thread.hxx>
23   -
24   - #include <cppuhelper/implbase3.hxx> // "3" implementing three interfaces
25   - #include <cppuhelper/factory.hxx>
26   - #include <cppuhelper/implementationentry.hxx>
27   -
28   - #include <com/sun/star/lang/XServiceInfo.hpp>
29   - #include <com/sun/star/lang/XInitialization.hpp>
30   - #include <com/sun/star/lang/IllegalArgumentException.hpp>
31   -
32   - #include <pw3270intf.hpp>
33   -
34   - /*---[ Debug macros ]--------------------------------------------------------------------------------------*/
35   -
36   - #ifdef DEBUG
37   - #define trace(fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr);
38   - #else
39   - #define trace( fmt, ... ) /* fmt __VA_ARGS__ */
40   - #endif
41   -
42   - /*---[ Object implementation ]-----------------------------------------------------------------------------*/
43   -
44   - #define IMPLNAME "br.com.bb.pw3270intf"
45   - #define SERVICENAME "br.com.bb.pw3270"
46   -
47   - using namespace br::com::bb;
48   - using namespace ::rtl; // for OUString
49   - using namespace ::com::sun::star; // for sdk interfaces
50   - using namespace ::com::sun::star::uno; // for basic types
51   -
52   - namespace pw3270
53   - {
54   -
55   - class uno_impl;
56   -
57   - class session
58   - {
59   - public:
60   - session();
61   - virtual ~session();
62   - virtual int get_revision(void) = 0;
63   - virtual LIB3270_MESSAGE get_state(void) = 0;
64   - virtual char * get_text_at(int row, int col, int len) = 0;
65   - virtual int set_text_at(int row, int col, const char *text) = 0;
66   - virtual int cmp_text_at(int row, int col, const char *text) = 0;
67   - virtual void set_toggle(LIB3270_TOGGLE toggle, bool state) = 0;
68   -
69   - virtual int connect(const char *uri) = 0;
70   - virtual int disconnect(void) = 0;
71   - virtual bool connected(void) = 0;
72   -
73   - virtual int enter(void) = 0;
74   - virtual int pfkey(int key) = 0;
75   - virtual int pakey(int key) = 0;
76   - virtual bool in_tn3270e() = 0;
77   - virtual void mem_free(void *) = 0;
78   -
79   - void sleep(int seconds = 1);
80   -
81   - void log(const char *fmt, const char *msg);
82   -
83   - rtl_TextEncoding get_encoding();
84   -
85   - };
86   -
87   - class lib3270_session : public session
88   - {
89   - public:
90   - lib3270_session(uno_impl *obj) throw( RuntimeException );
91   - virtual ~lib3270_session();
92   -
93   - virtual int get_revision(void);
94   - virtual LIB3270_MESSAGE get_state(void);
95   -
96   - virtual int connect(const char *uri);
97   - virtual int disconnect(void);
98   - virtual bool connected(void);
99   - virtual bool in_tn3270e(void);
100   -
101   - virtual int enter(void);
102   - virtual int pfkey(int key);
103   - virtual int pakey(int key);
104   -
105   - virtual char * get_text_at(int row, int col, int len);
106   - virtual int set_text_at(int row, int col, const char *text);
107   - virtual int cmp_text_at(int row, int col, const char *text);
108   -
109   - virtual void mem_free(void *ptr);
110   - virtual void set_toggle(LIB3270_TOGGLE toggle, bool state);
111   -
112   - private:
113   - bool enabled;
114   - oslModule hModule;
115   - oslThread hThread;
116   - H3270 * hSession;
117   -
118   - /* Internal calls */
119   - static void start_connect(lib3270_session *session);
120   - void network_loop(void);
121   -
122   - /* lib3270 entry points */
123   - const char * (* _get_revision)(void);
124   - LIB3270_MESSAGE (* _get_program_message)(H3270 *);
125   - int (* _in_tn3270e)(H3270 *);
126   - char * (* _get_text_at)(H3270 *,int,int,int);
127   - int (* _set_text_at)(H3270 *,int,int,const unsigned char *);
128   - int (* _cmp_text_at)(H3270 *,int,int,const char *);
129   - int (* _enter)(H3270 *);
130   - int (* _pfkey)(H3270 *, int);
131   - int (* _pakey)(H3270 *, int);
132   - void * (* _mem_free)(void *);
133   - void (*_set_toggle)(void *h, LIB3270_TOGGLE ix, int value);
134   -
135   -
136   - };
137   -
138   - class ipc3270_session : public session
139   - {
140   - public:
141   - ipc3270_session(uno_impl *obj, const char *name) throw( RuntimeException );
142   - virtual ~ipc3270_session();
143   - virtual int get_revision(void);
144   - virtual LIB3270_MESSAGE get_state(void);
145   - virtual char * get_text_at(int row, int col, int len);
146   - virtual int set_text_at(int row, int col, const char *text);
147   - virtual int cmp_text_at(int row, int col, const char *text);
148   - virtual void set_toggle(LIB3270_TOGGLE toggle, bool state);
149   -
150   - virtual int connect(const char *uri);
151   - virtual int disconnect(void);
152   - virtual bool connected(void);
153   -
154   - virtual int enter(void);
155   - virtual int pfkey(int key);
156   - virtual int pakey(int key);
157   - virtual bool in_tn3270e();
158   - virtual void mem_free(void *);
159   -
160   - private:
161   -
162   -#if defined(HAVE_DBUS)
163   -
164   - DBusConnection * conn;
165   - char * dest;
166   - char * path;
167   - char * intf;
168   - DBusMessage * create_message(const char *method);
169   - DBusMessage * call(DBusMessage *msg);
170   - char * query_string(const char *method);
171   - int query_intval(const char *method);
172   -
173   -#endif // HAVE_DBUS
174   -
175   - };
176   -
177   -
178   - class uno_impl : public ::cppu::WeakImplHelper3< br::com::bb::pw3270intf, com::sun::star::lang::XServiceInfo, com::sun::star::lang::XInitialization >
179   - {
180   - public:
181   -
182   - uno_impl( const com::sun::star::uno::Reference< XComponentContext > & xContext );
183   - virtual ~uno_impl();
184   -
185   - // XInitialization will be called upon createInstanceWithArguments[AndContext]()
186   - virtual void SAL_CALL initialize( Sequence< Any > const & args ) throw (Exception);
187   -
188   - // XServiceInfo implementation
189   - virtual OUString SAL_CALL getImplementationName( ) throw(RuntimeException);
190   - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
191   - virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException);
192   -
193   - // pw3270 implementation - Main
194   - virtual ::sal_Int16 SAL_CALL getRevision() throw (RuntimeException);
195   - virtual ::rtl::OUString SAL_CALL getVersion( ) throw (::com::sun::star::uno::RuntimeException);
196   - virtual ::sal_Int16 SAL_CALL Connect( const ::rtl::OUString& hostinfo ) throw (::com::sun::star::uno::RuntimeException);
197   - virtual ::sal_Int16 SAL_CALL Disconnect( ) throw (::com::sun::star::uno::RuntimeException);
198   - virtual ::sal_Int16 SAL_CALL getConnectionState( ) throw (::com::sun::star::uno::RuntimeException);
199   - virtual ::sal_Int16 SAL_CALL sleep( ::sal_Int16 seconds ) throw (::com::sun::star::uno::RuntimeException);
200   - virtual ::rtl::OUString SAL_CALL getTextAt( ::sal_Int16 row, ::sal_Int16 col, ::sal_Int16 size ) throw (::com::sun::star::uno::RuntimeException);
201   - virtual ::sal_Int16 SAL_CALL setTextAt( ::sal_Int16 row, ::sal_Int16 col, const ::rtl::OUString& text ) throw (::com::sun::star::uno::RuntimeException);
202   - virtual ::sal_Int16 SAL_CALL log(const ::rtl::OUString& text ) throw (::com::sun::star::uno::RuntimeException);
203   - virtual ::sal_Int16 SAL_CALL enter( ) throw (::com::sun::star::uno::RuntimeException);
204   - virtual ::sal_Int16 SAL_CALL pfkey( ::sal_Int16 keycode ) throw (::com::sun::star::uno::RuntimeException);
205   - virtual ::sal_Int16 SAL_CALL pakey( ::sal_Int16 keycode ) throw (::com::sun::star::uno::RuntimeException);
206   - virtual ::sal_Int16 SAL_CALL cmpTextAt( ::sal_Int16 row, ::sal_Int16 col, const ::rtl::OUString& text ) throw (::com::sun::star::uno::RuntimeException);
207   - virtual ::sal_Bool SAL_CALL isReady( ) throw (::com::sun::star::uno::RuntimeException);
208   - virtual ::sal_Bool SAL_CALL isConnected( ) throw (::com::sun::star::uno::RuntimeException);
209   - virtual ::sal_Bool SAL_CALL hasTextAt( ::sal_Int16 row, ::sal_Int16 col, const ::rtl::OUString& text ) throw (::com::sun::star::uno::RuntimeException);
210   - virtual ::sal_Int16 SAL_CALL waitForReady( ::sal_Int16 seconds ) throw (::com::sun::star::uno::RuntimeException);
211   - virtual ::sal_Int16 SAL_CALL dsTrace( ::sal_Bool state ) throw (::com::sun::star::uno::RuntimeException);
212   - virtual ::sal_Int16 SAL_CALL screenTrace( ::sal_Bool state ) throw (::com::sun::star::uno::RuntimeException);
213   - virtual ::sal_Int16 SAL_CALL setSession( const ::rtl::OUString& name ) throw (::com::sun::star::uno::RuntimeException);
214   -
215   - void failed(const char *fmt, ...) throw( ::com::sun::star::uno::RuntimeException );
216   -
217   - private:
218   -
219   - session *hSession;
220   -
221   - };
222   -
223   - };
224   -
225   -
226   -
227   -
228   -#endif // GLOBALS_HPP_INCLUDED
229   -
src/oxt/local.cxx
... ... @@ -1,343 +0,0 @@
1   -/*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270.
5   - *
6   - * Copyright (C) <2008> <Banco do Brasil S.A.>
7   - *
8   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
9   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
10   - * Free Software Foundation.
11   - *
12   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
13   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
14   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
15   - * obter mais detalhes.
16   - *
17   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
18   - * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
19   - * Place, Suite 330, Boston, MA, 02111-1307, USA
20   - *
21   - * Este programa está nomeado como local.cxx e possui - linhas de código.
22   - *
23   - * Contatos:
24   - *
25   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27   - * licinio@bb.com.br (Licínio Luis Branco)
28   - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
29   - *
30   - */
31   -
32   - #include "globals.hpp"
33   - #include <errno.h>
34   - #include <string.h>
35   -
36   - #ifdef HAVE_SYSLOG
37   - #include <syslog.h>
38   - #include <stdarg.h>
39   - #endif // HAVE_SYSLOG
40   -
41   -/*
42   - * NOTE: Take a better look at osl_createEmptySocketAddr() & osl_connectSocketTo() to see if there's
43   - * a way to use this calls to connect with the host for better performance.
44   - */
45   -
46   -/*---[ Statics ]-------------------------------------------------------------------------------------------*/
47   -
48   -
49   -/*---[ Implement ]-----------------------------------------------------------------------------------------*/
50   -
51   - static void loghandler(H3270 *session, const char *module, int rc, const char *fmt, va_list args)
52   - {
53   -#ifdef HAVE_SYSLOG
54   - openlog(PACKAGE_NAME, LOG_NDELAY, LOG_USER);
55   - vsyslog(LOG_INFO,fmt,args);
56   - closelog();
57   -#endif // HAVE_SYSLOG
58   - }
59   -
60   - static void tracehandler(H3270 *session, const char *fmt, va_list args)
61   - {
62   -#ifdef HAVE_SYSLOG
63   -
64   - #define MAX_LOG_LENGTH 200
65   -
66   - static char line[MAX_LOG_LENGTH+1];
67   - char temp[MAX_LOG_LENGTH];
68   - char * ptr;
69   - size_t len = strlen(line);
70   -
71   - vsnprintf(temp,MAX_LOG_LENGTH-len,fmt,args);
72   -
73   - ptr = strchr(temp,'\n');
74   - if(!ptr)
75   - {
76   - strncat(line,temp,MAX_LOG_LENGTH);
77   - if(strlen(line) >= MAX_LOG_LENGTH)
78   - {
79   - openlog(PACKAGE_NAME, LOG_NDELAY, LOG_USER);
80   - syslog(LOG_INFO,line);
81   - closelog();
82   - *line = 0;
83   - }
84   - return;
85   - }
86   -
87   - *ptr = 0;
88   - strncat(line,temp,MAX_LOG_LENGTH);
89   -
90   - openlog(PACKAGE_NAME, LOG_NDELAY, LOG_USER);
91   - syslog(LOG_DEBUG,line);
92   - closelog();
93   -
94   - strncpy(line,ptr+1,MAX_LOG_LENGTH);
95   -
96   -#endif // HAVE_SYSLOG
97   - }
98   -
99   - pw3270::lib3270_session::lib3270_session(uno_impl *obj) throw( RuntimeException )
100   - {
101   - struct _call
102   - {
103   - void **entry;
104   - const char * name;
105   - } call[] =
106   - {
107   - { (void **) & _get_revision, "lib3270_get_revision" },
108   - { (void **) & _get_text_at, "lib3270_get_text_at" },
109   - { (void **) & _set_text_at, "lib3270_set_string_at" },
110   - { (void **) & _cmp_text_at, "lib3270_cmp_text_at" },
111   - { (void **) & _enter, "lib3270_enter" },
112   - { (void **) & _pfkey, "lib3270_pfkey" },
113   - { (void **) & _pakey, "lib3270_pakey" },
114   - { (void **) & _in_tn3270e, "lib3270_in_tn3270e" },
115   - { (void **) & _get_program_message, "lib3270_get_program_message" },
116   - { (void **) & _mem_free, "lib3270_free" },
117   - { (void **) & _set_toggle, "lib3270_set_toggle" }
118   -
119   - };
120   -
121   - H3270 * (*lib3270_new)(const char *);
122   - void (*set_log_handler)(void (*loghandler)(H3270 *, const char *, int, const char *, va_list));
123   - void (*set_trace_handler)( void (*handler)(H3270 *session, const char *fmt, va_list args) );
124   -
125   - hThread = NULL;
126   - hSession = NULL;
127   -
128   - hModule = osl_loadModuleAscii("lib3270.so." PACKAGE_VERSION,SAL_LOADMODULE_NOW);
129   - trace("%s: hModule(lib3270.so." PACKAGE_VERSION ")=%p",__FUNCTION__,hModule);
130   -
131   - if(!hModule)
132   - {
133   - hModule = osl_loadModuleAscii("lib3270.so." PACKAGE_VERSION,SAL_LOADMODULE_NOW);
134   - trace("%s: hModule(lib3270.so)=%p",__FUNCTION__,hModule);
135   - }
136   -
137   - if(!hModule)
138   - {
139   - obj->failed("%s","Can't load lib3270");
140   - return;
141   - }
142   -
143   - for(int f = 0; f < (sizeof (call) / sizeof ((call)[0]));f++)
144   - {
145   - *call[f].entry = (void *) osl_getAsciiFunctionSymbol(hModule,call[f].name);
146   - if(!*call[f].entry)
147   - obj->failed("Error loading lib3270::%s",call[f].name);
148   - }
149   -
150   - /* Get lib3270 session handle */
151   - set_log_handler = (void (*)(void (*loghandler)(H3270 *, const char *, int, const char *, va_list))) osl_getAsciiFunctionSymbol(hModule,"lib3270_set_log_handler");
152   - set_trace_handler = (void (*)(void (*handler)(H3270 *session, const char *fmt, va_list args) )) osl_getAsciiFunctionSymbol(hModule,"lib3270_set_trace_handler");
153   -
154   - if(set_log_handler)
155   - set_log_handler(loghandler);
156   -
157   - if(set_trace_handler)
158   - set_trace_handler(tracehandler);
159   -
160   - lib3270_new = (H3270 * (*)(const char *)) osl_getAsciiFunctionSymbol(hModule,"lib3270_session_new");
161   - hSession = lib3270_new("");
162   -
163   - log("%s UNO extension loaded",PACKAGE_NAME);
164   - }
165   -
166   - pw3270::lib3270_session::~lib3270_session()
167   - {
168   -
169   - trace("%s hModule=%p hSession=%p",__FUNCTION__,hModule,hSession);
170   -
171   - disconnect();
172   - osl_yieldThread();
173   -
174   - if(hThread)
175   - osl_joinWithThread(hThread);
176   -
177   - if(hModule)
178   - {
179   - if(hSession)
180   - {
181   - void (*lib3270_free)(void *) = (void (*)(void *)) osl_getAsciiFunctionSymbol(hModule,"lib3270_session_free");
182   - lib3270_free(hSession);
183   - hSession = NULL;
184   - }
185   - osl_unloadModule(hModule);
186   - hModule = NULL;
187   - }
188   -
189   - log("%s UNO extension unloaded",PACKAGE_NAME);
190   - }
191   -
192   - int pw3270::lib3270_session::get_revision(void)
193   - {
194   - if(!_get_revision)
195   - return -1;
196   - return atoi(_get_revision());
197   - }
198   -
199   - int pw3270::lib3270_session::connect(const char *uri)
200   - {
201   - const char * (*set_host)(void *h, const char *n);
202   -
203   - if(!(hModule && hSession))
204   - return EINVAL;
205   -
206   - if(hThread)
207   - return EBUSY;
208   -
209   - set_host = (const char * (*)(void *,const char *)) osl_getAsciiFunctionSymbol(hModule,"lib3270_set_host");
210   - if(!set_host)
211   - return EINVAL;
212   -
213   - set_host(hSession,uri);
214   -
215   - enabled = true;
216   - hThread = osl_createThread((oslWorkerFunction) pw3270::lib3270_session::start_connect, this);
217   -
218   - osl_yieldThread();
219   -
220   - if(!hThread)
221   - return -1;
222   -
223   - osl_yieldThread();
224   -
225   - return 0;
226   - }
227   -
228   - int pw3270::lib3270_session::disconnect(void)
229   - {
230   - enabled = false;
231   - return 0;
232   - }
233   -
234   - void pw3270::lib3270_session::start_connect(lib3270_session *session)
235   - {
236   - session->network_loop();
237   - session->hThread = NULL;
238   - session->enabled = false;
239   - }
240   -
241   - void pw3270::lib3270_session::network_loop(void)
242   - {
243   - /* Lib3270 entry points */
244   - void (* _disconnect)(void *h) =
245   - (void (*)(void *)) osl_getAsciiFunctionSymbol(hModule,"lib3270_disconnect");
246   -
247   - int (* _connect)(void *h,const char *n, int wait) =
248   - (int (*)(void *,const char *,int)) osl_getAsciiFunctionSymbol(hModule,"lib3270_connect");
249   -
250   - int (* _status)(void *h) =
251   - (int (*)(void *)) osl_getAsciiFunctionSymbol(hModule,"lib3270_disconnected");
252   -
253   - void (*_iterate)(void *h, int wait) =
254   - (void (*)(void *, int)) osl_getAsciiFunctionSymbol(hModule,"lib3270_main_iterate");
255   -
256   - trace("%s starts",__FUNCTION__);
257   - _connect(hSession,NULL,1);
258   -
259   - trace("%s network loop begin",__FUNCTION__);
260   - while(enabled && !_status(hSession))
261   - {
262   - osl_yieldThread();
263   - _iterate(hSession,1);
264   - }
265   - trace("%s network loop ends",__FUNCTION__);
266   -
267   - osl_yieldThread();
268   -
269   - _disconnect(hSession);
270   -
271   - }
272   -
273   - bool pw3270::lib3270_session::connected(void)
274   - {
275   - return enabled;
276   - }
277   -
278   - int pw3270::lib3270_session::enter(void)
279   - {
280   - if(!hSession)
281   - return EINVAL;
282   - return _enter(hSession);
283   - }
284   -
285   - int pw3270::lib3270_session::pfkey(int key)
286   - {
287   - if(!hSession)
288   - return EINVAL;
289   - return _pfkey(hSession,key);
290   - }
291   -
292   - int pw3270::lib3270_session::pakey(int key)
293   - {
294   - if(!hSession)
295   - return EINVAL;
296   - return _pakey(hSession,key);
297   - }
298   -
299   - LIB3270_MESSAGE pw3270::lib3270_session::get_state(void)
300   - {
301   - if(!hSession)
302   - return LIB3270_MESSAGE_DISCONNECTED;
303   - return _get_program_message(hSession);
304   - }
305   -
306   - void pw3270::lib3270_session::mem_free(void *ptr)
307   - {
308   - _mem_free(ptr);
309   - }
310   -
311   - char * pw3270::lib3270_session::get_text_at(int row, int col, int len)
312   - {
313   - if(!hSession)
314   - return NULL;
315   - return _get_text_at(hSession,row,col,len);
316   - }
317   -
318   - int pw3270::lib3270_session::set_text_at(int row, int col, const char *text)
319   - {
320   - if(!hSession)
321   - return EINVAL;
322   - return _set_text_at(hSession,row,col,(const unsigned char *) text);
323   - }
324   -
325   - int pw3270::lib3270_session::cmp_text_at(int row, int col,const char *text)
326   - {
327   - if(!hSession)
328   - return EINVAL;
329   - return _cmp_text_at(hSession,row,col,text);
330   - }
331   -
332   - bool pw3270::lib3270_session::in_tn3270e(void)
333   - {
334   - if(!hSession)
335   - return false;
336   - return _in_tn3270e(hSession) != 0;
337   - }
338   -
339   - void pw3270::lib3270_session::set_toggle(LIB3270_TOGGLE toggle, bool state)
340   - {
341   - if(hSession)
342   - _set_toggle(hSession,toggle,(int) state);
343   - }
src/oxt/main.cxx
... ... @@ -1,330 +0,0 @@
1   -/*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270.
5   - *
6   - * Copyright (C) <2008> <Banco do Brasil S.A.>
7   - *
8   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
9   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
10   - * Free Software Foundation.
11   - *
12   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
13   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
14   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
15   - * obter mais detalhes.
16   - *
17   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
18   - * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
19   - * Place, Suite 330, Boston, MA, 02111-1307, USA
20   - *
21   - * Este programa está nomeado como main.cxx e possui - linhas de código.
22   - *
23   - * Contatos:
24   - *
25   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27   - * licinio@bb.com.br (Licínio Luis Branco)
28   - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
29   - *
30   - */
31   -
32   -#include "globals.hpp"
33   -#include <string.h>
34   -
35   -#ifdef HAVE_SYSLOG
36   - #include <syslog.h>
37   -#endif // HAVE_SYSLOG
38   -
39   -#include <salhelper/timer.hxx>
40   -#include <com/sun/star/registry/XRegistryKey.hpp>
41   -#include <com/sun/star/lang/XSingleComponentFactory.hpp>
42   -
43   -using namespace com::sun::star::registry; // for XRegistryKey
44   -using namespace com::sun::star::lang; // for XSingleComponentFactory
45   -
46   -/*---[ Statics ]-------------------------------------------------------------------------------------------*/
47   -
48   -
49   -
50   -/*---[ Implement ]-----------------------------------------------------------------------------------------*/
51   -
52   -static Sequence< OUString > getSupportedServiceNames()
53   -{
54   - Sequence<OUString> names(1);
55   -
56   - trace("%s returns: %s",__FUNCTION__, SERVICENAME);
57   - names[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME ) );
58   -
59   - return names;
60   -}
61   -
62   -static Reference< XInterface > SAL_CALL CreateInstance( const Reference< XComponentContext > & xContext )
63   -{
64   - return static_cast< XTypeProvider * >( new pw3270::uno_impl( xContext ) );
65   -}
66   -
67   -/*---[ Implement exported calls ]--------------------------------------------------------------------------*/
68   -
69   -/**************************************************************
70   - * Function to determine the environment of the implementation.
71   - *
72   - * If the environment is NOT session specific
73   - * (needs no additional context), then this function
74   - * should return the environment type name and leave ppEnv (0).
75   - *
76   - * @param ppEnvTypeName environment type name;
77   - * string must be constant
78   - * @param ppEnv function returns its environment
79   - * if the environment is session specific,
80   - * i.e. has special context
81   - */
82   -extern "C" void SAL_CALL component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv)
83   -{
84   -#ifdef LANGUAGE_BINDING_NAME
85   - trace("%s set envtype to %s\n",__FUNCTION__,LANGUAGE_BINDING_NAME);
86   - *ppEnvTypeName = LANGUAGE_BINDING_NAME;
87   -#else
88   - trace("%s set envtype to %s\n",__FUNCTION__,"msci");
89   - *ppEnvTypeName = "msci";
90   -#endif
91   -}
92   -
93   -/************************************************************
94   - * Optional function to retrieve a component description.
95   - *
96   - * @return an XML formatted string containing a short
97   - * component description
98   - */
99   -// typedef const sal_Char * (SAL_CALL * component_getDescriptionFunc)(void);
100   -
101   -/**********************************************************
102   - * Writes component registry info, at least writing the
103   - * supported service names.
104   - *
105   - * @param pServiceManager a service manager
106   - * (the type is XMultiServiceFactory
107   - * to be used by the environment
108   - * returned by
109   - * component_getImplementationEnvironment)
110   - *
111   - * @param pRegistryKey a registry key
112   - * (the type is XRegistryKey to be used
113   - * by the environment returned by
114   - * component_getImplementationEnvironment)
115   - *
116   - * @return true if everything went fine
117   - */
118   -extern "C" sal_Bool SAL_CALL component_writeInfo(void * pServiceManager, void * pRegistryKey)
119   -{
120   - sal_Bool result = sal_False;
121   -
122   - trace("%s",__FUNCTION__);
123   -
124   - if (pRegistryKey)
125   - {
126   - try
127   - {
128   - Reference< XRegistryKey > xNewKey(
129   - reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
130   - OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLNAME "/UNO/SERVICES") ) ) );
131   -
132   - const Sequence< OUString > & rSNL = getSupportedServiceNames();
133   - const OUString * pArray = rSNL.getConstArray();
134   -
135   - for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
136   - xNewKey->createKey( pArray[nPos] );
137   -
138   - return sal_True;
139   - }
140   - catch (InvalidRegistryException &)
141   - {
142   - // we should not ignore exceptions
143   - }
144   - }
145   -
146   - return result;
147   -}
148   -
149   -/*********************************************************
150   - * Retrieves a factory to create component instances.
151   - *
152   - * @param pImplName desired implementation name
153   - *
154   - * @param pServiceManager a service manager
155   - * (the type is XMultiServiceFactory
156   - * to be used by the environment
157   - * returned by
158   - * component_getImplementationEnvironment)
159   - *
160   - * @param pRegistryKey a registry key
161   - * (the type is XRegistryKey to be used
162   - * by the environment returned by
163   - * component_getImplementationEnvironment)
164   - *
165   - * @return acquired component factory
166   - * (the type is XInterface to be used by the
167   - * environment returned by
168   - * component_getImplementationEnvironment)
169   - */
170   -extern "C" void * SAL_CALL component_getFactory(const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey)
171   -{
172   - void * pRet = 0;
173   -
174   - trace("%s",__FUNCTION__);
175   -
176   - if(pServiceManager && rtl_str_compare( pImplName, IMPLNAME ) == 0)
177   - {
178   - Reference< XSingleComponentFactory > xFactory( ::cppu::createSingleComponentFactory(
179   - CreateInstance, OUString::createFromAscii( IMPLNAME ), getSupportedServiceNames() ));
180   -
181   -
182   - if (xFactory.is())
183   - {
184   - xFactory->acquire();
185   - pRet = xFactory.get();
186   - }
187   - }
188   -
189   - return pRet;
190   -}
191   -
192   -/*---[ Implement XInitialization ]-------------------------------------------------------------------------*/
193   -
194   -void SAL_CALL pw3270::uno_impl::initialize( Sequence< Any > const & args ) throw (Exception)
195   -{
196   - trace("%s",__FUNCTION__);
197   -}
198   -
199   -/*---[ Implement XServiceInfo ]----------------------------------------------------------------------------*/
200   -
201   -OUString SAL_CALL pw3270::uno_impl::getImplementationName( ) throw(RuntimeException)
202   -{
203   - trace("%s",__FUNCTION__);
204   - return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) );
205   -}
206   -
207   -sal_Bool SAL_CALL pw3270::uno_impl::supportsService( const OUString& ServiceName ) throw(RuntimeException)
208   -{
209   - trace("%s",__FUNCTION__);
210   - return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IMPLNAME") );
211   -}
212   -
213   -Sequence< OUString > pw3270::uno_impl::getSupportedServiceNames() throw (RuntimeException)
214   -{
215   - return getSupportedServiceNames();
216   -}
217   -
218   -/*---[ Implement pw3270 ]----------------------------------------------------------------------------------*/
219   -
220   -pw3270::uno_impl::uno_impl( const Reference< XComponentContext > & xContext )
221   -{
222   - this->hSession = new lib3270_session(this);
223   -}
224   -
225   -pw3270::uno_impl::~uno_impl()
226   -{
227   - delete this->hSession;
228   -}
229   -
230   -::sal_Int16 SAL_CALL pw3270::uno_impl::sleep( ::sal_Int16 seconds ) throw (::com::sun::star::uno::RuntimeException)
231   -{
232   - salhelper::TTimeValue t = salhelper::TTimeValue(seconds,0);
233   - osl_waitThread(&t);
234   - return 0;
235   -}
236   -
237   -::sal_Int16 SAL_CALL pw3270::uno_impl::log( const ::rtl::OUString& msg ) throw (::com::sun::star::uno::RuntimeException)
238   -{
239   - hSession->log("%s",rtl::OUStringToOString(msg,RTL_TEXTENCODING_UTF8).getStr());
240   - return 0;
241   -}
242   -
243   -::sal_Int16 SAL_CALL pw3270::uno_impl::dsTrace( ::sal_Bool state ) throw (::com::sun::star::uno::RuntimeException)
244   -{
245   - hSession->log("DS trace is %s",state ? "ON" : "OFF");
246   - hSession->set_toggle(LIB3270_TOGGLE_DS_TRACE,state);
247   - return 0;
248   -}
249   -
250   -::sal_Int16 SAL_CALL pw3270::uno_impl::screenTrace( ::sal_Bool state ) throw (::com::sun::star::uno::RuntimeException)
251   -{
252   - hSession->log("Screen trace is %s",state ? "ON" : "OFF");
253   - hSession->set_toggle(LIB3270_TOGGLE_SCREEN_TRACE,state);
254   - return 0;
255   -}
256   -
257   -pw3270::session::session()
258   -{
259   - trace("%s",__FUNCTION__);
260   -}
261   -
262   -pw3270::session::~session()
263   -{
264   - trace("%s",__FUNCTION__);
265   -}
266   -
267   -rtl_TextEncoding pw3270::session::get_encoding()
268   -{
269   - return RTL_TEXTENCODING_ISO_8859_1;
270   -}
271   -
272   -void pw3270::session::sleep(int seconds)
273   -{
274   - salhelper::TTimeValue t = salhelper::TTimeValue(seconds,0);
275   - osl_waitThread(&t);
276   -}
277   -
278   -void pw3270::session::log(const char *fmt, const char *msg)
279   -{
280   -#ifdef HAVE_SYSLOG
281   - openlog(PACKAGE_NAME, LOG_NDELAY, LOG_USER);
282   - syslog(LOG_INFO,fmt,msg);
283   - closelog();
284   -#else
285   - #error This module needs syslog support
286   -#endif // HAVE_SYSLOG
287   -}
288   -
289   -void pw3270::uno_impl::failed(const char *fmt, ...) throw( ::com::sun::star::uno::RuntimeException )
290   -{
291   - va_list arg_ptr;
292   - char * msg = (char *) malloc(1024);
293   -
294   - va_start(arg_ptr, fmt);
295   - vsnprintf(msg, 1023, fmt, arg_ptr);
296   - va_end(arg_ptr);
297   -
298   -#ifdef HAVE_SYSLOG
299   - openlog(PACKAGE_NAME, LOG_NDELAY, LOG_USER);
300   - syslog(LOG_ERR,"%s",msg);
301   - closelog();
302   -#endif // HAVE_SYSLOG
303   -
304   - trace("%s: %s",__FUNCTION__,msg);
305   -
306   - ::rtl::OUString str = OUString(msg, strlen(msg), RTL_TEXTENCODING_UTF8, RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE);
307   -
308   - free(msg);
309   -
310   - throw Exception( str , *this );
311   -
312   -}
313   -
314   -::sal_Int16 SAL_CALL pw3270::uno_impl::setSession( const ::rtl::OUString& name ) throw (::com::sun::star::uno::RuntimeException)
315   -{
316   - const char *ptr;
317   -
318   - OString str = rtl::OUStringToOString( name , hSession->get_encoding() );
319   -
320   - delete this->hSession;
321   -
322   - ptr = str.getStr();
323   -
324   - if(ptr && *ptr)
325   - this->hSession = new ipc3270_session(this,str.getStr());
326   - else
327   - this->hSession = new lib3270_session(this);
328   -
329   - return 0;
330   -}
src/oxt/manifest.xml.in
... ... @@ -1,6 +0,0 @@
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<manifest:manifest>
3   -<manifest:file-entry manifest:media-type= "application/vnd.sun.star.uno-component;type=native;platform=Linux_@host_cpu@" manifest:full-path="@PACKAGE_NAME@.uno.so"/>
4   -<manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-typelibrary;type=RDB" manifest:full-path="@PACKAGE_NAME@.uno.rdb"/>
5   -</manifest:manifest>
6   -
src/oxt/pw3270.idl
... ... @@ -1,101 +0,0 @@
1   -/*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270.
5   - *
6   - * Copyright (C) <2008> <Banco do Brasil S.A.>
7   - *
8   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
9   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
10   - * Free Software Foundation.
11   - *
12   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
13   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
14   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
15   - * obter mais detalhes.
16   - *
17   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
18   - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
19   - * St, Fifth Floor, Boston, MA 02110-1301 USA
20   - *
21   - * Este programa está nomeado como pw3270.idl e possui - linhas de código.
22   - *
23   - * Contatos:
24   - *
25   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27   - * licinio@bb.com.br (Licínio Luis Branco)
28   - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
29   - *
30   - */
31   -
32   -#include <com/sun/star/uno/XInterface.idl>
33   -#include <com/sun/star/lang/XTypeProvider.idl>
34   -
35   -/*
36   -
37   - Referências:
38   -
39   - http://wiki.services.openoffice.org/wiki/IDL_Files_and_Cpp
40   - http://wiki.services.openoffice.org/wiki/IDL_Files_and_Cpp#Specifying_an_interface
41   -
42   - */
43   -
44   -module br
45   -{
46   - module com
47   - {
48   - module bb
49   - {
50   -
51   - /**
52   - * Interface to pw3270.
53   - *
54   - * http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Bridge/Default_Mappings
55   - *
56   - */
57   - interface pw3270intf : com::sun::star::uno::XInterface
58   - {
59   - /* Connect/Disconnect */
60   - short Connect( [in] string hostinfo );
61   - short Disconnect();
62   - short getConnectionState();
63   -
64   - /* Get */
65   - string getTextAt([in] short row, [in] short col, [in] short size);
66   -
67   - /* Set */
68   - short setTextAt([in] short row, [in] short col, [in] string text);
69   -
70   - /* Actions */
71   - short cmpTextAt([in] short row, [in] short col, [in] string text);
72   - short enter();
73   - short pfkey([in] short keycode);
74   - short pakey([in] short keycode);
75   -
76   - /* Misc */
77   - short setSession([in] string name);
78   - short getRevision();
79   - string getVersion();
80   - short log([in] string msg);
81   - short sleep([in] short seconds);
82   - boolean isReady();
83   - boolean hasTextAt([in] short row, [in] short col, [in] string text);
84   - short waitForReady([in] short seconds);
85   -// short waitForTextAt(in] short row, [in] short col, [in] string text, [in] short seconds);
86   - boolean isConnected();
87   - short dsTrace([in] boolean mode);
88   - short screenTrace([in] boolean mode);
89   -
90   - };
91   -
92   - service pw3270
93   - {
94   - // exported interfaces:
95   - interface pw3270intf;
96   - };
97   -
98   - };
99   - };
100   -};
101   -
src/oxt/pw3270OXT.cbp
... ... @@ -1,53 +0,0 @@
1   -<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2   -<CodeBlocks_project_file>
3   - <FileVersion major="1" minor="6" />
4   - <Project>
5   - <Option title="pw3270 OXT" />
6   - <Option makefile_is_custom="1" />
7   - <Option pch_mode="2" />
8   - <Option compiler="gcc" />
9   - <Build>
10   - <Target title="Debug">
11   - <Option output=".bin/Debug/testprogram" prefix_auto="1" extension_auto="1" />
12   - <Option object_output=".obj/Debug/" />
13   - <Option type="1" />
14   - <Option compiler="gcc" />
15   - <Compiler>
16   - <Add option="-g" />
17   - </Compiler>
18   - </Target>
19   - <Target title="Release">
20   - <Option output=".bin/Release/pw3270" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
21   - <Option object_output=".obj/Release/" />
22   - <Option type="3" />
23   - <Option compiler="gcc" />
24   - <Compiler>
25   - <Add option="-O2" />
26   - </Compiler>
27   - <Linker>
28   - <Add option="-s" />
29   - </Linker>
30   - </Target>
31   - </Build>
32   - <Compiler>
33   - <Add option="-Wall" />
34   - </Compiler>
35   - <Unit filename="Makefile.in" />
36   - <Unit filename="actions.cxx" />
37   - <Unit filename="connection.cxx" />
38   - <Unit filename="description.xml.in" />
39   - <Unit filename="get.cxx" />
40   - <Unit filename="globals.hpp" />
41   - <Unit filename="local.cxx" />
42   - <Unit filename="main.cxx" />
43   - <Unit filename="manifest.xml.in" />
44   - <Unit filename="pw3270.idl" />
45   - <Unit filename="remote.cxx" />
46   - <Unit filename="set.cxx" />
47   - <Unit filename="testprogram.cxx" />
48   - <Extensions>
49   - <code_completion />
50   - <debugger />
51   - </Extensions>
52   - </Project>
53   -</CodeBlocks_project_file>
src/oxt/remote.cxx
... ... @@ -1,533 +0,0 @@
1   -/*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270.
5   - *
6   - * Copyright (C) <2008> <Banco do Brasil S.A.>
7   - *
8   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
9   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
10   - * Free Software Foundation.
11   - *
12   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
13   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
14   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
15   - * obter mais detalhes.
16   - *
17   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
18   - * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
19   - * Place, Suite 330, Boston, MA, 02111-1307, USA
20   - *
21   - * Este programa está nomeado como remote.cxx e possui - linhas de código.
22   - *
23   - * Contatos:
24   - *
25   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27   - * licinio@bb.com.br (Licínio Luis Branco)
28   - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
29   - *
30   - */
31   -
32   - #include "globals.hpp"
33   - #include <errno.h>
34   - #include <string.h>
35   -
36   -/*---[ Statics ]-------------------------------------------------------------------------------------------*/
37   -
38   -#if defined(HAVE_DBUS)
39   - static const char * prefix_dest = "br.com.bb.";
40   - static const char * prefix_path = "/br/com/bb/";
41   -#endif // HAVE_DBUS
42   -
43   -/*---[ Implement ]-----------------------------------------------------------------------------------------*/
44   -
45   -#if defined(HAVE_DBUS)
46   -DBusMessage * pw3270::ipc3270_session::create_message(const char *method)
47   -{
48   - DBusMessage * msg = dbus_message_new_method_call( this->dest, // Destination
49   - this->path, // Path
50   - this->intf, // Interface
51   - method); // method
52   -
53   - if (!msg)
54   - log("Error creating message for method %s",method);
55   -
56   - return msg;
57   -}
58   -
59   -DBusMessage * pw3270::ipc3270_session::call(DBusMessage *msg)
60   -{
61   - DBusMessage * reply;
62   - DBusError error;
63   -
64   - dbus_error_init(&error);
65   - reply = dbus_connection_send_with_reply_and_block(conn,msg,10000,&error);
66   - dbus_message_unref(msg);
67   -
68   - if(!reply)
69   - {
70   - log("%s",error.message);
71   - dbus_error_free(&error);
72   - }
73   -
74   - return reply;
75   -
76   -}
77   -
78   -static char * get_string(DBusMessage * msg)
79   -{
80   - char *rc = NULL;
81   - if(msg)
82   - {
83   - DBusMessageIter iter;
84   -
85   - if(dbus_message_iter_init(msg, &iter))
86   - {
87   - if(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING)
88   - {
89   - const char * str;
90   - dbus_message_iter_get_basic(&iter, &str);
91   - trace("Response: [%s]",str);
92   - rc = strdup(str);
93   - }
94   -#ifdef DEBUG
95   - else
96   - {
97   - trace("Return type is %c, expecting %c",dbus_message_iter_get_arg_type(&iter),DBUS_TYPE_STRING);
98   - }
99   -#endif
100   - }
101   -
102   - dbus_message_unref(msg);
103   - }
104   - return rc;
105   -}
106   -
107   -char * pw3270::ipc3270_session::query_string(const char *method)
108   -{
109   - if(conn)
110   - return get_string(call(create_message(method)));
111   - return NULL;
112   -}
113   -
114   -static int get_intval(DBusMessage * msg)
115   -{
116   - int rc = -1;
117   -
118   - if(msg)
119   - {
120   - DBusMessageIter iter;
121   -
122   - if(dbus_message_iter_init(msg, &iter))
123   - {
124   - if(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_INT32)
125   - {
126   - dbus_int32_t iSigned;
127   - dbus_message_iter_get_basic(&iter, &iSigned);
128   - rc = (int) iSigned;
129   - }
130   -#ifdef DEBUG
131   - else
132   - {
133   - trace("Return type is %c, expecting %c",dbus_message_iter_get_arg_type(&iter),DBUS_TYPE_INT32);
134   - }
135   -#endif
136   - }
137   -
138   - dbus_message_unref(msg);
139   - }
140   -
141   - return rc;
142   -}
143   -
144   -int pw3270::ipc3270_session::query_intval(const char *method)
145   -{
146   - if(conn)
147   - return get_intval(call(create_message(method)));
148   - return -1;
149   -}
150   -
151   -#endif // HAVE_DBUS
152   -
153   -
154   -pw3270::ipc3270_session::ipc3270_session(uno_impl *obj, const char *name) throw( RuntimeException ) : pw3270::session()
155   -{
156   -#ifdef HAVE_DBUS
157   -
158   - DBusError err;
159   - int rc;
160   - char * str = strdup(name);
161   - char * ptr;
162   -
163   - for(ptr=str;*ptr;ptr++)
164   - *ptr = tolower(*ptr);
165   -
166   - ptr = strchr(str,':');
167   -
168   - if(ptr)
169   - {
170   - size_t sz;
171   -
172   - *(ptr++) = 0;
173   -
174   - // Build destination
175   - sz = strlen(ptr)+strlen(str)+strlen(prefix_dest)+2;
176   - dest = (char *) malloc(sz+1);
177   - strncpy(dest,prefix_dest,sz);
178   - strncat(dest,str,sz);
179   - strncat(dest,".",sz);
180   - strncat(dest,ptr,sz);
181   -
182   - // Build path
183   - sz = strlen(str)+strlen(prefix_path);
184   - path = (char *) malloc(sz+1);
185   - strncpy(path,prefix_path,sz);
186   - strncat(path,str,sz);
187   -
188   - // Build intf
189   - sz = strlen(str)+strlen(prefix_dest)+1;
190   - intf = (char *) malloc(sz+1);
191   - strncpy(intf,prefix_dest,sz);
192   - strncat(intf,str,sz);
193   -
194   - }
195   - else
196   - {
197   - size_t sz;
198   -
199   - // Build destination
200   - sz = strlen(str)+strlen(prefix_dest)+2;
201   - dest = (char *) malloc(sz+1);
202   - strncpy(dest,prefix_dest,sz);
203   - strncat(dest,str,sz);
204   -
205   - // Build path
206   - sz = strlen(str)+strlen(prefix_path);
207   - path = (char *) malloc(sz+1);
208   - strncpy(path,prefix_path,sz);
209   - strncat(path,str,sz);
210   -
211   - // Build intf
212   - sz = strlen(str)+strlen(prefix_dest)+1;
213   - intf = (char *) malloc(sz+1);
214   - strncpy(intf,prefix_dest,sz);
215   - strncat(intf,str,sz);
216   -
217   - }
218   -
219   - trace("DBUS:\nDestination:\t[%s]\nPath:\t\t[%s]\nInterface:\t[%s]",dest,path,intf);
220   -
221   - free(str);
222   -
223   - dbus_error_init(&err);
224   -
225   - conn = dbus_bus_get(DBUS_BUS_SESSION, &err);
226   -
227   - trace("conn=%p",conn);
228   -
229   - if (dbus_error_is_set(&err))
230   - {
231   - trace("DBUS Connection Error (%s)", err.message);
232   - obj->failed("DBUS Connection Error (%s)", err.message);
233   - dbus_error_free(&err);
234   - return;
235   - }
236   -
237   - if(!conn)
238   - {
239   - obj->failed("%s", "DBUS Connection failed");
240   - return;
241   - }
242   -
243   - rc = dbus_bus_request_name(conn, "br.com.bb." PACKAGE_NAME ".oo", DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
244   -
245   - if (dbus_error_is_set(&err))
246   - {
247   - obj->failed("DBUS Name Error (%s)", err.message);
248   - dbus_error_free(&err);
249   - conn = NULL;
250   - return;
251   - }
252   -
253   - if(rc != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
254   - {
255   - obj->failed("%s", "DBUS request name failed");
256   - conn = NULL;
257   - return;
258   - }
259   - else
260   - {
261   - DBusMessage * reply;
262   - DBusMessage * msg = create_message("getRevision");
263   - DBusError error;
264   -
265   - dbus_error_init(&error);
266   - reply = dbus_connection_send_with_reply_and_block(conn,msg,10000,&error);
267   - dbus_message_unref(msg);
268   -
269   - if(reply)
270   - {
271   - log("%s","PW3270 DBus object found");
272   - dbus_message_unref(reply);
273   - }
274   - else
275   - {
276   - obj->failed("DBUS error: %s",error.message);
277   - dbus_error_free(&error);
278   - }
279   - }
280   -#else
281   -
282   -#endif // HAVE_DBUS
283   -}
284   -
285   -pw3270::ipc3270_session::~ipc3270_session()
286   -{
287   -#ifdef HAVE_DBUS
288   -
289   - free(dest);
290   - free(path);
291   - free(intf);
292   -
293   -#endif // HAVE_DBUS
294   -}
295   -
296   -int pw3270::ipc3270_session::get_revision(void)
297   -{
298   -#ifdef HAVE_DBUS
299   - char *ptr = query_string("getRevision");
300   - if(ptr)
301   - {
302   - int rc = atoi(ptr);
303   - free(ptr);
304   - return rc;
305   - }
306   - return -1;
307   -
308   -#else
309   -
310   - return -1;
311   -
312   -#endif // HAVE_DBUS
313   -}
314   -
315   -LIB3270_MESSAGE pw3270::ipc3270_session::get_state(void)
316   -{
317   -#ifdef HAVE_DBUS
318   -
319   - return (LIB3270_MESSAGE) query_intval("getMessageID");
320   -
321   -#else
322   -
323   - return (LIB3270_MESSAGE) -1;
324   -
325   -#endif // HAVE_DBUS
326   -}
327   -
328   -char * pw3270::ipc3270_session::get_text_at(int row, int col, int len)
329   -{
330   -#ifdef HAVE_DBUS
331   -
332   - dbus_int32_t r = (dbus_int32_t) row;
333   - dbus_int32_t c = (dbus_int32_t) col;
334   - dbus_int32_t l = (dbus_int32_t) len;
335   -
336   - DBusMessage * msg = create_message("getTextAt");
337   - if(!msg)
338   - return NULL;
339   -
340   - trace("%s(%d,%d,%d)",__FUNCTION__,r,c,l);
341   - dbus_message_append_args(msg, DBUS_TYPE_INT32, &r, DBUS_TYPE_INT32, &c, DBUS_TYPE_INT32, &l, DBUS_TYPE_INVALID);
342   -
343   - return get_string(call(msg));
344   -
345   -#else
346   -
347   - return NULL;
348   -
349   -#endif // HAVE_DBUS
350   -}
351   -
352   -int pw3270::ipc3270_session::set_text_at(int row, int col, const char *text)
353   -{
354   -#ifdef HAVE_DBUS
355   -
356   - dbus_int32_t r = (dbus_int32_t) row;
357   - dbus_int32_t c = (dbus_int32_t) col;
358   -
359   - DBusMessage * msg = create_message("setTextAt");
360   - if(msg)
361   - {
362   - dbus_message_append_args(msg, DBUS_TYPE_INT32, &r, DBUS_TYPE_INT32, &c, DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID);
363   - return get_intval(call(msg));
364   - }
365   -
366   -#else
367   -
368   - return -1;
369   -
370   -#endif // HAVE_DBUS
371   -}
372   -
373   -int pw3270::ipc3270_session::cmp_text_at(int row, int col, const char *text)
374   -{
375   -#ifdef HAVE_DBUS
376   -
377   - dbus_int32_t r = (dbus_int32_t) row;
378   - dbus_int32_t c = (dbus_int32_t) col;
379   -
380   - DBusMessage * msg = create_message("cmpTextAt");
381   - if(msg)
382   - {
383   - dbus_message_append_args(msg, DBUS_TYPE_INT32, &r, DBUS_TYPE_INT32, &c, DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID);
384   - return get_intval(call(msg));
385   - }
386   -
387   -#else
388   -
389   - return -1;
390   -
391   -#endif // HAVE_DBUS
392   -}
393   -
394   -void pw3270::ipc3270_session::set_toggle(LIB3270_TOGGLE toggle, bool state)
395   -{
396   -#ifdef HAVE_DBUS
397   -
398   - dbus_int32_t i = (dbus_int32_t) toggle;
399   - dbus_int32_t v = (dbus_int32_t) state;
400   -
401   - DBusMessage * msg = create_message("setToggle");
402   - if(msg)
403   - {
404   - dbus_message_append_args(msg, DBUS_TYPE_INT32, &i, DBUS_TYPE_INT32, &v, DBUS_TYPE_INVALID);
405   - get_intval(call(msg));
406   - }
407   -
408   -#endif // HAVE_DBUS
409   -}
410   -
411   -int pw3270::ipc3270_session::connect(const char *uri)
412   -{
413   -#ifdef HAVE_DBUS
414   -
415   - int rc;
416   - DBusMessage * msg = create_message("connect");
417   - if(!msg)
418   - return -1;
419   -
420   - dbus_message_append_args(msg, DBUS_TYPE_STRING, &uri, DBUS_TYPE_INVALID);
421   -
422   - return get_intval(call(msg));
423   -
424   -#else
425   -
426   - return -1;
427   -
428   -#endif // HAVE_DBUS
429   -}
430   -
431   -int pw3270::ipc3270_session::disconnect(void)
432   -{
433   -#ifdef HAVE_DBUS
434   -
435   - return query_intval("disconnect");
436   -
437   -#else
438   -
439   - return -1;
440   -
441   -#endif // HAVE_DBUS
442   -}
443   -
444   -bool pw3270::ipc3270_session::connected(void)
445   -{
446   -#ifdef HAVE_DBUS
447   -
448   - return query_intval("isConnected") > 0;
449   -
450   -#else
451   -
452   - return false;
453   -
454   -#endif // HAVE_DBUS
455   -}
456   -
457   -int pw3270::ipc3270_session::enter(void)
458   -{
459   -#ifdef HAVE_DBUS
460   -
461   - return query_intval("enter");
462   -
463   -#else
464   -
465   - return -1;
466   -
467   -#endif // HAVE_DBUS
468   -}
469   -
470   -int pw3270::ipc3270_session::pfkey(int key)
471   -{
472   -#ifdef HAVE_DBUS
473   -
474   - dbus_int32_t k = (dbus_int32_t) key;
475   -
476   - DBusMessage * msg = create_message("pfKey");
477   - if(msg)
478   - {
479   - dbus_message_append_args(msg, DBUS_TYPE_INT32, &k, DBUS_TYPE_INVALID);
480   - return get_intval(call(msg));
481   - }
482   -
483   -#endif // HAVE_DBUS
484   -
485   - return -1;
486   -
487   -}
488   -
489   -int pw3270::ipc3270_session::pakey(int key)
490   -{
491   -#ifdef HAVE_DBUS
492   -
493   - dbus_int32_t k = (dbus_int32_t) key;
494   -
495   - DBusMessage * msg = create_message("paKey");
496   - if(msg)
497   - {
498   - dbus_message_append_args(msg, DBUS_TYPE_INT32, &k, DBUS_TYPE_INVALID);
499   - return get_intval(call(msg));
500   - }
501   -
502   -#endif // HAVE_DBUS
503   -
504   - return -1;
505   -
506   -}
507   -
508   -bool pw3270::ipc3270_session::in_tn3270e()
509   -{
510   -#ifdef HAVE_DBUS
511   -
512   - return query_intval("inTN3270E") > 0;
513   -
514   -#else
515   -
516   - return false;
517   -
518   -#endif // HAVE_DBUS
519   -}
520   -
521   -void pw3270::ipc3270_session::mem_free(void *ptr)
522   -{
523   -#ifdef HAVE_DBUS
524   -
525   - free(ptr);
526   -
527   -#else
528   -
529   -
530   -#endif // HAVE_DBUS
531   -}
532   -
533   -
src/oxt/set.cxx
... ... @@ -1,42 +0,0 @@
1   -/*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270.
5   - *
6   - * Copyright (C) <2008> <Banco do Brasil S.A.>
7   - *
8   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
9   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
10   - * Free Software Foundation.
11   - *
12   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
13   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
14   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
15   - * obter mais detalhes.
16   - *
17   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
18   - * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
19   - * Place, Suite 330, Boston, MA, 02111-1307, USA
20   - *
21   - * Este programa está nomeado como set.cxx e possui - linhas de código.
22   - *
23   - * Contatos:
24   - *
25   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27   - * licinio@bb.com.br (Licínio Luis Branco)
28   - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
29   - *
30   - */
31   -
32   - #include "globals.hpp"
33   - #include <string.h>
34   -
35   -/*---[ Implement ]-----------------------------------------------------------------------------------------*/
36   -
37   -::sal_Int16 SAL_CALL pw3270::uno_impl::setTextAt( ::sal_Int16 row, ::sal_Int16 col, const ::rtl::OUString& text ) throw (::com::sun::star::uno::RuntimeException)
38   -{
39   - return hSession->set_text_at((int) row, (int) col, rtl::OUStringToOString(text,hSession->get_encoding()).getStr());
40   -}
41   -
42   -
src/oxt/testprogram.cxx
... ... @@ -1,173 +0,0 @@
1   -/*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270.
5   - *
6   - * Copyright (C) <2008> <Banco do Brasil S.A.>
7   - *
8   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
9   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
10   - * Free Software Foundation.
11   - *
12   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
13   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
14   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
15   - * obter mais detalhes.
16   - *
17   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
18   - * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
19   - * Place, Suite 330, Boston, MA, 02111-1307, USA
20   - *
21   - * Este programa está nomeado como testprogram.cxx e possui - linhas de código.
22   - *
23   - * Contatos:
24   - *
25   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27   - * licinio@bb.com.br (Licínio Luis Branco)
28   - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
29   - *
30   - */
31   -
32   -#include <stdio.h>
33   -#ifdef WIN32
34   - #include <windows.h>
35   - #define sleep(x) Sleep(x)
36   -#endif
37   -
38   -#define trace( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr);
39   -
40   -#include "globals.hpp"
41   -#include <cppuhelper/bootstrap.hxx>
42   -#include <com/sun/star/registry/XSimpleRegistry.hpp>
43   -#include <com/sun/star/registry/XImplementationRegistration.hpp>
44   -#include <com/sun/star/lang/XComponent.hpp>
45   -
46   -using namespace com::sun::star::registry;
47   -using namespace com::sun::star::lang;
48   -using namespace cppu;
49   -
50   -/*---[ Implement ]-----------------------------------------------------------------------------------------*/
51   -
52   -int SAL_CALL main(int argc, char **argv)
53   -{
54   - Reference< XSimpleRegistry > xReg = createSimpleRegistry();
55   -
56   - OSL_ENSURE( xReg.is(), "### cannot get service instance of \"com.sun.star.regiystry.SimpleRegistry\"!" );
57   -
58   - xReg->open(OUString::createFromAscii("pw3270.uno.rdb"), sal_False, sal_False);
59   -
60   - OSL_ENSURE( xReg->isValid(), "### cannot open test registry \"pw3270.uno.rdb\"!" );
61   -
62   - trace("%s","Calling bootstrap_InitialComponentContext");
63   - Reference< XComponentContext > xContext = bootstrap_InitialComponentContext(xReg);
64   - OSL_ENSURE( xContext.is(), "### cannot creage intial component context!" );
65   -
66   - trace("%s","Calling getServiceManager\n");
67   - Reference< XMultiComponentFactory > xMgr = xContext->getServiceManager();
68   - OSL_ENSURE( xMgr.is(), "### cannot get initial service manager!" );
69   -
70   - // register my component
71   - trace("%s","Calling createInstanceWithContext");
72   -
73   - Reference< XImplementationRegistration > xImplReg(
74   - xMgr->createInstanceWithContext(OUString::createFromAscii("com.sun.star.registry.ImplementationRegistration"), xContext), UNO_QUERY);
75   - OSL_ENSURE( xImplReg.is(), "### cannot get service instance of \"com.sun.star.registry.ImplementationRegistration\"!" );
76   -
77   - if (xImplReg.is())
78   - {
79   - const char *libname = ".bin/Debug/pw3270.uno.so";
80   -
81   - trace("Loading %s",libname);
82   -
83   - xImplReg->registerImplementation(
84   - OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), // loader for component
85   - OUString::createFromAscii(libname), // component location
86   - Reference< XSimpleRegistry >() // registry omitted,
87   - // defaulting to service manager registry used
88   - );
89   -
90   - // get an object instance
91   - printf("Calling createInstanceWithContext(%s)\n",IMPLNAME);
92   -
93   - Reference< XInterface > xx ;
94   - xx = xMgr->createInstanceWithContext(OUString::createFromAscii(IMPLNAME), xContext);
95   -
96   - printf("Instance: %p\n",&xx);
97   -
98   - Reference< pw3270intf > srv( xx, UNO_QUERY );
99   -
100   - OSL_ENSURE( srv.is(), "### cannot get service instance!");
101   -
102   - printf("object.is(): %d\n",srv.is());
103   -
104   - if(srv.is())
105   - {
106   - // Wait for commands
107   - char buffer[4096];
108   - OString str;
109   -
110   - try
111   - {
112   -
113   - srv->setSession(OUString::createFromAscii("pw3270:a"));
114   -
115   - }
116   - catch( RuntimeException & e )
117   - {
118   - OString o = OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US );
119   - fprintf( stderr, "%s\n", o.pData->buffer );
120   - exit(-1);
121   - }
122   -
123   - printf("Revision:\t%d\n",srv->getRevision());
124   -
125   - srv->dsTrace(true);
126   - srv->screenTrace(true);
127   -
128   - printf("getConnectionState: %d\n", srv->getConnectionState());
129   - printf("Connect(): %d\n" , srv->Connect(OUString::createFromAscii("L:3270.df.bb:9023")));
130   -
131   - srv->sleep(2);
132   - printf("getConnectionState: %d\n", srv->getConnectionState());
133   - srv->sleep(2);
134   -
135   - str = OUStringToOString( srv->getTextAt(1,1,2000),RTL_TEXTENCODING_UTF8);
136   - printf("ContentsAt(1,1):\n%s\n",str.pData->buffer);
137   -
138   - printf("getConnectionState: %d\n", srv->getConnectionState());
139   -
140   - srv->sleep(1);
141   - srv->enter();
142   - srv->sleep(1);
143   -
144   - str = OUStringToOString( srv->getTextAt(1,1,2000),RTL_TEXTENCODING_UTF8);
145   - printf("ContentsAt(1,1):\n%s\n",str.pData->buffer);
146   -
147   - /*
148   - printf("waitForStringAt(SISBB) returned %d\n",srv->waitForStringAt(20,39,OUString::createFromAscii("SISBB"),20));
149   - printf("sendEnterKey() returned %d\n",srv->sendEnterKey());
150   - printf("waitForStringAt(Senha) returned %d\n",srv->waitForStringAt(14,2,OUString::createFromAscii("Senha"),20));
151   - printf("setStringAt returned %d\n",srv->setStringAt(13,21,OUString::createFromAscii("c1103788")));
152   -
153   - str = OUStringToOString( srv->getScreenContent(),RTL_TEXTENCODING_UTF8);
154   - printf("Entire screen:\n%s\n",str.pData->buffer);
155   -
156   -
157   - */
158   -
159   - printf("Enter to exit...\n");
160   - fgets(buffer,80,stdin);
161   -
162   - printf("Disconnect(): %d\n" , srv->Disconnect());
163   -
164   - srv->sleep(5);
165   -
166   - }
167   - }
168   -
169   -
170   - Reference< XComponent >::query( xContext )->dispose();
171   -
172   - return 0;
173   -}