Commit 50cd676a4839b48362b4e8fdb6fb2d940254e3cb
1 parent
ecf3f0c5
Exists in
master
and in
5 other branches
Trabalhando na extensão OpenOffice
Showing
9 changed files
with
136 additions
and
18 deletions
Show diff stats
src/oxt/Makefile.in
@@ -0,0 +1,47 @@ | @@ -0,0 +1,47 @@ | ||
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/get.cxx
@@ -38,4 +38,9 @@ sal_Int16 SAL_CALL pw3270::uno_impl::getRevision() throw (RuntimeException) | @@ -38,4 +38,9 @@ sal_Int16 SAL_CALL pw3270::uno_impl::getRevision() throw (RuntimeException) | ||
38 | return hSession->get_revision(); | 38 | return hSession->get_revision(); |
39 | } | 39 | } |
40 | 40 | ||
41 | +sal_Int16 SAL_CALL pw3270::uno_impl::getConnectionState( ) throw (::com::sun::star::uno::RuntimeException) | ||
42 | +{ | ||
43 | + return hSession->get_state(); | ||
44 | +} | ||
45 | + | ||
41 | 46 |
src/oxt/globals.hpp
@@ -52,14 +52,21 @@ | @@ -52,14 +52,21 @@ | ||
52 | session(); | 52 | session(); |
53 | virtual ~session(); | 53 | virtual ~session(); |
54 | virtual int get_revision(void) = 0; | 54 | virtual int get_revision(void) = 0; |
55 | + virtual int get_state(void) = 0; | ||
56 | + | ||
55 | virtual int connect(const char *uri) = 0; | 57 | virtual int connect(const char *uri) = 0; |
56 | virtual int disconnect(void) = 0; | 58 | virtual int disconnect(void) = 0; |
57 | virtual bool connected(void) = 0; | 59 | virtual bool connected(void) = 0; |
60 | + | ||
58 | virtual int enter(void) = 0; | 61 | virtual int enter(void) = 0; |
59 | virtual int pfkey(int key) = 0; | 62 | virtual int pfkey(int key) = 0; |
60 | virtual int pakey(int key) = 0; | 63 | virtual int pakey(int key) = 0; |
61 | 64 | ||
62 | - rtl_TextEncoding getEncoding(); | 65 | + virtual void mem_free(void *) = 0; |
66 | + | ||
67 | + void sleep(int seconds = 1); | ||
68 | + | ||
69 | + rtl_TextEncoding get_encoding(); | ||
63 | 70 | ||
64 | }; | 71 | }; |
65 | 72 | ||
@@ -70,13 +77,18 @@ | @@ -70,13 +77,18 @@ | ||
70 | virtual ~lib3270_session(); | 77 | virtual ~lib3270_session(); |
71 | 78 | ||
72 | virtual int get_revision(void); | 79 | virtual int get_revision(void); |
80 | + virtual int get_state(void); | ||
81 | + | ||
73 | virtual int connect(const char *uri); | 82 | virtual int connect(const char *uri); |
74 | virtual int disconnect(void); | 83 | virtual int disconnect(void); |
75 | virtual bool connected(void); | 84 | virtual bool connected(void); |
85 | + | ||
76 | virtual int enter(void); | 86 | virtual int enter(void); |
77 | virtual int pfkey(int key); | 87 | virtual int pfkey(int key); |
78 | virtual int pakey(int key); | 88 | virtual int pakey(int key); |
79 | 89 | ||
90 | + virtual void mem_free(void *ptr); | ||
91 | + | ||
80 | private: | 92 | private: |
81 | bool enabled; | 93 | bool enabled; |
82 | oslModule hModule; | 94 | oslModule hModule; |
@@ -89,12 +101,14 @@ | @@ -89,12 +101,14 @@ | ||
89 | 101 | ||
90 | /* lib3270 entry points */ | 102 | /* lib3270 entry points */ |
91 | const char * (* _get_revision)(void); | 103 | const char * (* _get_revision)(void); |
104 | + int (* _get_program_message)(void *); | ||
92 | char * (* _get_text_at)(void *,int,int,int); | 105 | char * (* _get_text_at)(void *,int,int,int); |
93 | int (* _set_text_at)(void *,int,int,const unsigned char *); | 106 | int (* _set_text_at)(void *,int,int,const unsigned char *); |
94 | int (* _cmp_text_at)(void *,int,int,const char *); | 107 | int (* _cmp_text_at)(void *,int,int,const char *); |
95 | int (* _enter)(void *); | 108 | int (* _enter)(void *); |
96 | int (* _pfkey)(void *, int); | 109 | int (* _pfkey)(void *, int); |
97 | int (* _pakey)(void *, int); | 110 | int (* _pakey)(void *, int); |
111 | + void * (* _mem_free)(void *); | ||
98 | 112 | ||
99 | 113 | ||
100 | }; | 114 | }; |
@@ -115,7 +129,11 @@ | @@ -115,7 +129,11 @@ | ||
115 | virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException); | 129 | virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException); |
116 | 130 | ||
117 | // pw3270 implementation - Main | 131 | // pw3270 implementation - Main |
118 | - virtual sal_Int16 SAL_CALL getRevision() throw (RuntimeException); | 132 | + virtual ::sal_Int16 SAL_CALL getRevision() throw (RuntimeException); |
133 | + virtual ::sal_Int16 SAL_CALL Connect( const ::rtl::OUString& hostinfo ) throw (::com::sun::star::uno::RuntimeException); | ||
134 | + virtual ::sal_Int16 SAL_CALL Disconnect( ) throw (::com::sun::star::uno::RuntimeException); | ||
135 | + virtual ::sal_Int16 SAL_CALL getConnectionState( ) throw (::com::sun::star::uno::RuntimeException); | ||
136 | + virtual ::sal_Int16 SAL_CALL sleep( ::sal_Int16 seconds ) throw (::com::sun::star::uno::RuntimeException); | ||
119 | 137 | ||
120 | private: | 138 | private: |
121 | 139 |
src/oxt/local.cxx
@@ -50,13 +50,15 @@ | @@ -50,13 +50,15 @@ | ||
50 | const char * name; | 50 | const char * name; |
51 | } call[] = | 51 | } call[] = |
52 | { | 52 | { |
53 | - { (void **) & _get_revision, "lib3270_get_revision" }, | ||
54 | - { (void **) & _get_text_at, "lib3270_get_text_at" }, | ||
55 | - { (void **) & _set_text_at, "lib3270_set_string_at" }, | ||
56 | - { (void **) & _cmp_text_at, "lib3270_cmp_text_at" }, | ||
57 | - { (void **) & _enter, "lib3270_enter" }, | ||
58 | - { (void **) & _pfkey, "lib3270_pfkey" }, | ||
59 | - { (void **) & _pakey, "lib3270_pakey" } | 53 | + { (void **) & _get_revision, "lib3270_get_revision" }, |
54 | + { (void **) & _get_text_at, "lib3270_get_text_at" }, | ||
55 | + { (void **) & _set_text_at, "lib3270_set_string_at" }, | ||
56 | + { (void **) & _cmp_text_at, "lib3270_cmp_text_at" }, | ||
57 | + { (void **) & _enter, "lib3270_enter" }, | ||
58 | + { (void **) & _pfkey, "lib3270_pfkey" }, | ||
59 | + { (void **) & _pakey, "lib3270_pakey" }, | ||
60 | + { (void **) & _get_program_message, "lib3270_get_program_message" }, | ||
61 | + { (void **) & _mem_free, "lib3270_free" } | ||
60 | 62 | ||
61 | }; | 63 | }; |
62 | 64 | ||
@@ -85,6 +87,10 @@ | @@ -85,6 +87,10 @@ | ||
85 | trace("%s hModule=%p hSession=%p",__FUNCTION__,hModule,hSession); | 87 | trace("%s hModule=%p hSession=%p",__FUNCTION__,hModule,hSession); |
86 | 88 | ||
87 | disconnect(); | 89 | disconnect(); |
90 | + osl_yieldThread(); | ||
91 | + | ||
92 | + if(hThread) | ||
93 | + osl_joinWithThread(hThread); | ||
88 | 94 | ||
89 | if(hModule) | 95 | if(hModule) |
90 | { | 96 | { |
@@ -92,8 +98,10 @@ | @@ -92,8 +98,10 @@ | ||
92 | { | 98 | { |
93 | void (*lib3270_free)(void *) = (void (*)(void *)) osl_getAsciiFunctionSymbol(hModule,"lib3270_session_free"); | 99 | void (*lib3270_free)(void *) = (void (*)(void *)) osl_getAsciiFunctionSymbol(hModule,"lib3270_session_free"); |
94 | lib3270_free(hSession); | 100 | lib3270_free(hSession); |
101 | + hSession = NULL; | ||
95 | } | 102 | } |
96 | osl_unloadModule(hModule); | 103 | osl_unloadModule(hModule); |
104 | + hModule = NULL; | ||
97 | } | 105 | } |
98 | 106 | ||
99 | } | 107 | } |
@@ -201,3 +209,15 @@ | @@ -201,3 +209,15 @@ | ||
201 | return EINVAL; | 209 | return EINVAL; |
202 | return _pakey(hSession,key); | 210 | return _pakey(hSession,key); |
203 | } | 211 | } |
212 | + | ||
213 | + int pw3270::lib3270_session::get_state(void) | ||
214 | + { | ||
215 | + if(!hSession) | ||
216 | + return -1; | ||
217 | + return _get_program_message(hSession); | ||
218 | + } | ||
219 | + | ||
220 | + void pw3270::lib3270_session::mem_free(void *ptr) | ||
221 | + { | ||
222 | + _mem_free(ptr); | ||
223 | + } |
src/oxt/main.cxx
@@ -31,6 +31,7 @@ | @@ -31,6 +31,7 @@ | ||
31 | 31 | ||
32 | #include "globals.hpp" | 32 | #include "globals.hpp" |
33 | 33 | ||
34 | +#include <salhelper/timer.hxx> | ||
34 | #include <com/sun/star/registry/XRegistryKey.hpp> | 35 | #include <com/sun/star/registry/XRegistryKey.hpp> |
35 | #include <com/sun/star/lang/XSingleComponentFactory.hpp> | 36 | #include <com/sun/star/lang/XSingleComponentFactory.hpp> |
36 | 37 | ||
@@ -221,6 +222,14 @@ pw3270::uno_impl::~uno_impl() | @@ -221,6 +222,14 @@ pw3270::uno_impl::~uno_impl() | ||
221 | delete this->hSession; | 222 | delete this->hSession; |
222 | } | 223 | } |
223 | 224 | ||
225 | +::sal_Int16 SAL_CALL pw3270::uno_impl::sleep( ::sal_Int16 seconds ) throw (::com::sun::star::uno::RuntimeException) | ||
226 | +{ | ||
227 | + salhelper::TTimeValue t = salhelper::TTimeValue(seconds,0); | ||
228 | + osl_waitThread(&t); | ||
229 | + return 0; | ||
230 | +} | ||
231 | + | ||
232 | + | ||
224 | pw3270::session::session() | 233 | pw3270::session::session() |
225 | { | 234 | { |
226 | trace("%s",__FUNCTION__); | 235 | trace("%s",__FUNCTION__); |
@@ -231,7 +240,13 @@ pw3270::session::~session() | @@ -231,7 +240,13 @@ pw3270::session::~session() | ||
231 | trace("%s",__FUNCTION__); | 240 | trace("%s",__FUNCTION__); |
232 | } | 241 | } |
233 | 242 | ||
234 | -rtl_TextEncoding pw3270::session::getEncoding() | 243 | +rtl_TextEncoding pw3270::session::get_encoding() |
235 | { | 244 | { |
236 | return RTL_TEXTENCODING_ISO_8859_1; | 245 | return RTL_TEXTENCODING_ISO_8859_1; |
237 | } | 246 | } |
247 | + | ||
248 | +void pw3270::session::sleep(int seconds) | ||
249 | +{ | ||
250 | + salhelper::TTimeValue t = salhelper::TTimeValue(seconds,0); | ||
251 | + osl_waitThread(&t); | ||
252 | +} |
src/oxt/pw3270.idl
@@ -56,7 +56,15 @@ module br | @@ -56,7 +56,15 @@ module br | ||
56 | */ | 56 | */ |
57 | interface pw3270intf : com::sun::star::uno::XInterface | 57 | interface pw3270intf : com::sun::star::uno::XInterface |
58 | { | 58 | { |
59 | + /* Connect/Disconnect */ | ||
60 | + short Connect( [in] string hostinfo ); | ||
61 | + short Disconnect(); | ||
62 | + short getConnectionState(); | ||
63 | + | ||
64 | + /* Misc */ | ||
59 | short getRevision(); | 65 | short getRevision(); |
66 | + short sleep([in] short seconds); | ||
67 | + | ||
60 | }; | 68 | }; |
61 | 69 | ||
62 | service pw3270 | 70 | service pw3270 |
src/oxt/pw3270OXT.cbp
@@ -33,6 +33,7 @@ | @@ -33,6 +33,7 @@ | ||
33 | <Add option="-Wall" /> | 33 | <Add option="-Wall" /> |
34 | </Compiler> | 34 | </Compiler> |
35 | <Unit filename="Makefile.in" /> | 35 | <Unit filename="Makefile.in" /> |
36 | + <Unit filename="connection.cxx" /> | ||
36 | <Unit filename="get.cxx" /> | 37 | <Unit filename="get.cxx" /> |
37 | <Unit filename="globals.hpp" /> | 38 | <Unit filename="globals.hpp" /> |
38 | <Unit filename="local.cxx" /> | 39 | <Unit filename="local.cxx" /> |
src/oxt/testprogram.cxx
@@ -105,17 +105,21 @@ int SAL_CALL main(int argc, char **argv) | @@ -105,17 +105,21 @@ int SAL_CALL main(int argc, char **argv) | ||
105 | { | 105 | { |
106 | // Wait for commands | 106 | // Wait for commands |
107 | // OString str; | 107 | // OString str; |
108 | -// char buffer[80]; | ||
109 | -// printf("getConnectionState: %d\n", srv->getConnectionState()); | ||
110 | - | ||
111 | -// str = OUStringToOString( srv->getVersion(),RTL_TEXTENCODING_UTF8); | ||
112 | -// printf("Version:\t%s\n",str.pData->buffer); | ||
113 | 108 | ||
114 | printf("Revision:\t%d\n",srv->getRevision()); | 109 | printf("Revision:\t%d\n",srv->getRevision()); |
115 | 110 | ||
116 | - // printf("Connect(): %d\n" , srv->Connect(OUString::createFromAscii("L:3270.df.bb:9023"),10)); | 111 | + printf("getConnectionState: %d\n", srv->getConnectionState()); |
112 | + printf("Connect(): %d\n" , srv->Connect(OUString::createFromAscii("L:3270.df.bb:9023"))); | ||
113 | + | ||
114 | + srv->sleep(5); | ||
115 | + printf("getConnectionState: %d\n", srv->getConnectionState()); | ||
116 | + srv->sleep(5); | ||
117 | + | ||
118 | + srv->Disconnect(); | ||
119 | + srv->sleep(5); | ||
120 | + printf("getConnectionState: %d\n", srv->getConnectionState()); | ||
117 | 121 | ||
118 | - // sleep(5); | 122 | + srv->sleep(5); |
119 | 123 | ||
120 | //str = OUStringToOString( srv->getScreenContentAt(20,39,5),RTL_TEXTENCODING_UTF8); | 124 | //str = OUStringToOString( srv->getScreenContentAt(20,39,5),RTL_TEXTENCODING_UTF8); |
121 | //Trace("ContentsAt(20,39): \"%s\"",str.pData->buffer); | 125 | //Trace("ContentsAt(20,39): \"%s\"",str.pData->buffer); |