Commit dddb96d184291324ca8076e3c9f5f1ed308bd24a
1 parent
68743f00
Exists in
master
and in
3 other branches
Planejando novo componente C++.
Showing
7 changed files
with
565 additions
and
10 deletions
Show diff stats
src/include/lib3270++.h
@@ -81,7 +81,7 @@ | @@ -81,7 +81,7 @@ | ||
81 | 81 | ||
82 | MESSAGE_X = LIB3270_MESSAGE_X, ///< @brief -- | 82 | MESSAGE_X = LIB3270_MESSAGE_X, ///< @brief -- |
83 | MESSAGE_RESOLVING = LIB3270_MESSAGE_RESOLVING, ///< @brief Resolving hostname (running DNS query) | 83 | MESSAGE_RESOLVING = LIB3270_MESSAGE_RESOLVING, ///< @brief Resolving hostname (running DNS query) |
84 | - MESSAGE_CONNECTING, = LIB3270_MESSAGE_CONNECTING ///< @brief Connecting to host | 84 | +// MESSAGE_CONNECTING, = LIB3270_MESSAGE_CONNECTING ///< @brief Connecting to host |
85 | 85 | ||
86 | }; | 86 | }; |
87 | 87 | ||
@@ -124,7 +124,11 @@ | @@ -124,7 +124,11 @@ | ||
124 | 124 | ||
125 | /// @brief Actions keys | 125 | /// @brief Actions keys |
126 | enum Action : uint8_t { | 126 | enum Action : uint8_t { |
127 | - ENTER ///< Enter key | 127 | + ENTER, ///< Enter key |
128 | + ERASE, | ||
129 | + ERASE_EOF, | ||
130 | + ERASE_EOL, | ||
131 | + ERASE_INPUT | ||
128 | }; | 132 | }; |
129 | 133 | ||
130 | /// @brief TN3270 Session. | 134 | /// @brief TN3270 Session. |
@@ -143,13 +147,14 @@ | @@ -143,13 +147,14 @@ | ||
143 | virtual void connect(const char *url) = 0; | 147 | virtual void connect(const char *url) = 0; |
144 | virtual void disconnect(); | 148 | virtual void disconnect(); |
145 | 149 | ||
150 | + // Wait for session state. | ||
151 | + virtual void waitForReady(time_t timeout = 5) throw() = 0; | ||
152 | + | ||
146 | // Gets | 153 | // Gets |
154 | + virtual std::string toString() const = 0; | ||
147 | virtual std::string toString(int baddr = 0, size_t len = -1, bool lf = false) = 0; | 155 | virtual std::string toString(int baddr = 0, size_t len = -1, bool lf = false) = 0; |
148 | virtual std::string toString(int row, int col, size_t sz, bool lf = false) = 0; | 156 | virtual std::string toString(int row, int col, size_t sz, bool lf = false) = 0; |
149 | 157 | ||
150 | - /// @brief Get field at current position, update to next one. | ||
151 | - virtual Session & pop(std::string &value) = 0; | ||
152 | - | ||
153 | inline operator std::string() const { | 158 | inline operator std::string() const { |
154 | return toString(); | 159 | return toString(); |
155 | } | 160 | } |
@@ -164,7 +169,7 @@ | @@ -164,7 +169,7 @@ | ||
164 | return getConnectionState(); | 169 | return getConnectionState(); |
165 | } | 170 | } |
166 | 171 | ||
167 | - // Sets | 172 | + // Set contents. |
168 | 173 | ||
169 | /// @brief Set field at current posicion, jumps to next writable field. | 174 | /// @brief Set field at current posicion, jumps to next writable field. |
170 | virtual Session & push(const char *text) = 0; | 175 | virtual Session & push(const char *text) = 0; |
@@ -178,6 +183,11 @@ | @@ -178,6 +183,11 @@ | ||
178 | virtual Session & push(const PAKey key) = 0; | 183 | virtual Session & push(const PAKey key) = 0; |
179 | virtual Session & push(const Action action) = 0; | 184 | virtual Session & push(const Action action) = 0; |
180 | 185 | ||
186 | + // Get contents. | ||
187 | + virtual Session & pop(int baddr, std::string &text) = 0; | ||
188 | + virtual Session & pop(int row, int col, std::string &text) = 0; | ||
189 | + virtual Session & pop(std::string &text) = 0; | ||
190 | + | ||
181 | }; | 191 | }; |
182 | 192 | ||
183 | /// @brief TN3270 Host | 193 | /// @brief TN3270 Host |
@@ -199,6 +209,10 @@ | @@ -199,6 +209,10 @@ | ||
199 | Host(const char *id = nullptr, const char *url = nullptr); | 209 | Host(const char *id = nullptr, const char *url = nullptr); |
200 | ~Host(); | 210 | ~Host(); |
201 | 211 | ||
212 | + inline void connect(const char *url) { | ||
213 | + this->session->connect(url); | ||
214 | + } | ||
215 | + | ||
202 | inline ProgramMessage getProgramMessage() const { | 216 | inline ProgramMessage getProgramMessage() const { |
203 | return session->getProgramMessage(); | 217 | return session->getProgramMessage(); |
204 | } | 218 | } |
@@ -215,8 +229,7 @@ | @@ -215,8 +229,7 @@ | ||
215 | return getConnectionState(); | 229 | return getConnectionState(); |
216 | } | 230 | } |
217 | 231 | ||
218 | - | ||
219 | - // Sets | 232 | + // Set contents. |
220 | 233 | ||
221 | /// @brief Set field at current posicion, jumps to next writable field. | 234 | /// @brief Set field at current posicion, jumps to next writable field. |
222 | inline Host & push(const char *text) { | 235 | inline Host & push(const char *text) { |
@@ -225,7 +238,7 @@ | @@ -225,7 +238,7 @@ | ||
225 | }; | 238 | }; |
226 | 239 | ||
227 | inline Host & push(const std::string &text) { | 240 | inline Host & push(const std::string &text) { |
228 | - session->push(text)); | 241 | + session->push(text); |
229 | return *this; | 242 | return *this; |
230 | 243 | ||
231 | } | 244 | } |
@@ -255,6 +268,23 @@ | @@ -255,6 +268,23 @@ | ||
255 | return *this; | 268 | return *this; |
256 | } | 269 | } |
257 | 270 | ||
271 | + // Get contents. | ||
272 | + | ||
273 | + inline Host & pop(int baddr, std::string &text) { | ||
274 | + session->pop(baddr, text); | ||
275 | + return *this; | ||
276 | + } | ||
277 | + | ||
278 | + inline Host & pop(int row, int col, std::string &text) { | ||
279 | + session->pop(row,col,text); | ||
280 | + return *this; | ||
281 | + } | ||
282 | + | ||
283 | + inline Host & pop(std::string &text) { | ||
284 | + session->pop(text); | ||
285 | + return *this; | ||
286 | + } | ||
287 | + | ||
258 | }; | 288 | }; |
259 | 289 | ||
260 | } | 290 | } |
@@ -279,7 +309,7 @@ | @@ -279,7 +309,7 @@ | ||
279 | 309 | ||
280 | template <typename T> | 310 | template <typename T> |
281 | inline TN3270_PUBLIC TN3270::Host & operator>>(TN3270::Host& host, const T value) { | 311 | inline TN3270_PUBLIC TN3270::Host & operator>>(TN3270::Host& host, const T value) { |
282 | - return Host.pop(value); | 312 | + return host.pop(value); |
283 | } | 313 | } |
284 | 314 | ||
285 | #endif | 315 | #endif |
@@ -0,0 +1,75 @@ | @@ -0,0 +1,75 @@ | ||
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 lib3270++.h 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 | + * | ||
28 | + */ | ||
29 | + | ||
30 | +/** | ||
31 | + * @file src/lib3270++/abstract.cc | ||
32 | + * | ||
33 | + * @brief | ||
34 | + * | ||
35 | + * @author perry.werneck@gmail.com | ||
36 | + * | ||
37 | + */ | ||
38 | + | ||
39 | + #include "private.h" | ||
40 | + | ||
41 | + | ||
42 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | ||
43 | + | ||
44 | + namespace TN3270 { | ||
45 | + | ||
46 | + Abstract::Session::Session() { | ||
47 | + | ||
48 | +#ifdef HAVE_ICONV | ||
49 | + this->iconv.local = (iconv_t) (-1); | ||
50 | + this->iconv.host = (iconv_t) (-1); | ||
51 | +#endif | ||
52 | + | ||
53 | + this->baddr = 0; | ||
54 | + | ||
55 | + } | ||
56 | + | ||
57 | + Abstract::Session::~Session() { | ||
58 | + | ||
59 | +#ifdef HAVE_ICONV | ||
60 | + | ||
61 | + if(this->iconv.local != (iconv_t) (-1)) | ||
62 | + iconv_close(this->iconv.local); | ||
63 | + | ||
64 | + if(this->iconv.host != (iconv_t) (-1)) | ||
65 | + iconv_close(this->iconv.host); | ||
66 | + | ||
67 | +#endif | ||
68 | + | ||
69 | + } | ||
70 | + | ||
71 | + } | ||
72 | + | ||
73 | + | ||
74 | + | ||
75 | + |
@@ -0,0 +1,78 @@ | @@ -0,0 +1,78 @@ | ||
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 lib3270++.h 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 | + * | ||
28 | + */ | ||
29 | + | ||
30 | +/** | ||
31 | + * @file src/lib3270++/host.cc | ||
32 | + * | ||
33 | + * @brief | ||
34 | + * | ||
35 | + * @author perry.werneck@gmail.com | ||
36 | + * | ||
37 | + */ | ||
38 | + | ||
39 | + #include "private.h" | ||
40 | + | ||
41 | + | ||
42 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | ||
43 | + | ||
44 | + namespace TN3270 { | ||
45 | + | ||
46 | + Host::Host(const char *id, const char *url) { | ||
47 | + this->session = Session::create(id); | ||
48 | + if(url) { | ||
49 | + this->connect(url); | ||
50 | + } | ||
51 | + } | ||
52 | + | ||
53 | + Host::~Host() { | ||
54 | + delete this->session; | ||
55 | + this->session = nullptr; | ||
56 | + } | ||
57 | + | ||
58 | + /// @brief Writes characters to the associated file from the put area | ||
59 | + int Host::sync() { | ||
60 | + return 0; | ||
61 | + } | ||
62 | + | ||
63 | + /// @brief Writes characters to the associated output sequence from the put area. | ||
64 | + int Host::overflow(int c) { | ||
65 | + | ||
66 | + if (c != EOF) { | ||
67 | + char str[] = { static_cast<char>(c), 0 }; | ||
68 | + this->session->push((const char *) str); | ||
69 | + } else { | ||
70 | + sync(); | ||
71 | + } | ||
72 | + | ||
73 | + return c; | ||
74 | + | ||
75 | + } | ||
76 | + | ||
77 | + } | ||
78 | + |
@@ -0,0 +1,56 @@ | @@ -0,0 +1,56 @@ | ||
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="C++ Bindings for lib3270" /> | ||
6 | + <Option pch_mode="2" /> | ||
7 | + <Option compiler="gcc" /> | ||
8 | + <Build> | ||
9 | + <Target title="Debug"> | ||
10 | + <Option output=".bin/Debug/C++ Bindings for lib3270" prefix_auto="1" extension_auto="1" /> | ||
11 | + <Option object_output=".obj/Debug/" /> | ||
12 | + <Option type="1" /> | ||
13 | + <Option compiler="gcc" /> | ||
14 | + <Compiler> | ||
15 | + <Add option="-g" /> | ||
16 | + <Add option="-DDEBUG=1" /> | ||
17 | + </Compiler> | ||
18 | + </Target> | ||
19 | + <Target title="Release"> | ||
20 | + <Option output=".bin/Release/C++ Bindings for lib3270" prefix_auto="1" extension_auto="1" /> | ||
21 | + <Option object_output=".obj/Release/" /> | ||
22 | + <Option type="1" /> | ||
23 | + <Option compiler="gcc" /> | ||
24 | + <Compiler> | ||
25 | + <Add option="-O2" /> | ||
26 | + <Add option="-std=c++11" /> | ||
27 | + <Add option="-DNDEBUG=1" /> | ||
28 | + </Compiler> | ||
29 | + <Linker> | ||
30 | + <Add option="-s" /> | ||
31 | + </Linker> | ||
32 | + </Target> | ||
33 | + </Build> | ||
34 | + <Compiler> | ||
35 | + <Add option="-Wall" /> | ||
36 | + <Add option="`pkg-config --clags lib3270`" /> | ||
37 | + <Add directory="../include" /> | ||
38 | + </Compiler> | ||
39 | + <Linker> | ||
40 | + <Add option="`pkg-config --libs lib3270`" /> | ||
41 | + </Linker> | ||
42 | + <Unit filename="../include/lib3270++.h" /> | ||
43 | + <Unit filename="../include/lib3270.h" /> | ||
44 | + <Unit filename="abstract.cc" /> | ||
45 | + <Unit filename="host.cc" /> | ||
46 | + <Unit filename="local.cc" /> | ||
47 | + <Unit filename="private.h" /> | ||
48 | + <Unit filename="session.cc" /> | ||
49 | + <Extensions> | ||
50 | + <code_completion /> | ||
51 | + <envvars /> | ||
52 | + <debugger /> | ||
53 | + <lib_finder disable_auto="1" /> | ||
54 | + </Extensions> | ||
55 | + </Project> | ||
56 | +</CodeBlocks_project_file> |
@@ -0,0 +1,132 @@ | @@ -0,0 +1,132 @@ | ||
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 lib3270++.h 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 | + * | ||
28 | + */ | ||
29 | + | ||
30 | +/** | ||
31 | + * @file src/lib3270++/local.cc | ||
32 | + * | ||
33 | + * @brief | ||
34 | + * | ||
35 | + * @author perry.werneck@gmail.com | ||
36 | + * | ||
37 | + */ | ||
38 | + | ||
39 | + #include "private.h" | ||
40 | + | ||
41 | + | ||
42 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | ||
43 | + | ||
44 | + namespace TN3270 { | ||
45 | + | ||
46 | + LocalSession::LocalSession() : Abstract::Session() { | ||
47 | + this->hSession = lib3270_session_new(""); | ||
48 | + lib3270_set_user_data(this->hSession,(void *) this); | ||
49 | + } | ||
50 | + | ||
51 | + LocalSession::~LocalSession() { | ||
52 | + lib3270_session_free(this->hSession); | ||
53 | + this->hSession = nullptr; | ||
54 | + } | ||
55 | + | ||
56 | + void LocalSession::connect(const char *url) { | ||
57 | + lib3270_connect_url(hSession,url,0); | ||
58 | + } | ||
59 | + | ||
60 | + void LocalSession::disconnect() { | ||
61 | + lib3270_disconnect(hSession); | ||
62 | + } | ||
63 | + | ||
64 | + // Wait for session state. | ||
65 | + void LocalSession::waitForReady(time_t timeout) throw() { | ||
66 | + | ||
67 | + int rc = lib3270_wait_for_ready(this->hSession, timeout); | ||
68 | + | ||
69 | + if(rc) { | ||
70 | + throw std::system_error(rc, std::system_category()); | ||
71 | + } | ||
72 | + | ||
73 | + } | ||
74 | + | ||
75 | + // Gets | ||
76 | + std::string LocalSession::toString() const { | ||
77 | + } | ||
78 | + | ||
79 | + std::string LocalSession::toString(int baddr, size_t len, bool lf) { | ||
80 | + } | ||
81 | + | ||
82 | + std::string LocalSession::toString(int row, int col, size_t sz, bool lf) { | ||
83 | + } | ||
84 | + | ||
85 | + ProgramMessage LocalSession::getProgramMessage() const { | ||
86 | + return (ProgramMessage) lib3270_get_program_message(this->hSession); | ||
87 | + } | ||
88 | + | ||
89 | + ConnectionState LocalSession::getConnectionState() const { | ||
90 | + return (ConnectionState) lib3270_get_connection_state(this->hSession); | ||
91 | + } | ||
92 | + | ||
93 | + /// @brief Set field at current posicion, jumps to next writable field. | ||
94 | + TN3270::Session & LocalSession::push(const char *text) { | ||
95 | + return *this; | ||
96 | + } | ||
97 | + | ||
98 | + TN3270::Session & LocalSession::push(int baddr, const std::string &text) { | ||
99 | + return *this; | ||
100 | + } | ||
101 | + | ||
102 | + TN3270::Session & LocalSession::push(int row, int col, const std::string &text) { | ||
103 | + return *this; | ||
104 | + } | ||
105 | + | ||
106 | + TN3270::Session & LocalSession::push(const PFKey key) { | ||
107 | + return *this; | ||
108 | + } | ||
109 | + | ||
110 | + TN3270::Session & LocalSession::push(const PAKey key) { | ||
111 | + return *this; | ||
112 | + } | ||
113 | + | ||
114 | + TN3270::Session & LocalSession::push(const Action action) { | ||
115 | + return *this; | ||
116 | + } | ||
117 | + | ||
118 | + TN3270::Session & LocalSession::pop(int baddr, std::string &text) { | ||
119 | + return *this; | ||
120 | + } | ||
121 | + | ||
122 | + TN3270::Session & LocalSession::pop(int row, int col, std::string &text) { | ||
123 | + return *this; | ||
124 | + } | ||
125 | + | ||
126 | + TN3270::Session & LocalSession::pop(std::string &text) { | ||
127 | + return *this; | ||
128 | + } | ||
129 | + | ||
130 | + } | ||
131 | + | ||
132 | + |
@@ -0,0 +1,127 @@ | @@ -0,0 +1,127 @@ | ||
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 lib3270++.h 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 | + * | ||
28 | + */ | ||
29 | + | ||
30 | +/** | ||
31 | + * @file src/lib3270++/private.h | ||
32 | + * | ||
33 | + * @brief | ||
34 | + * | ||
35 | + * @author perry.werneck@gmail.com | ||
36 | + * | ||
37 | + */ | ||
38 | + | ||
39 | +#ifndef PRIVATE_H_INCLUDED | ||
40 | + | ||
41 | + #define PRIVATE_H_INCLUDED | ||
42 | + | ||
43 | + #include <config.h> | ||
44 | + #include <lib3270++.h> | ||
45 | + #include <system_error> | ||
46 | + | ||
47 | + | ||
48 | +#ifdef HAVE_ICONV | ||
49 | + #include <iconv.h> | ||
50 | +#endif // HAVE_ICONV | ||
51 | + | ||
52 | + namespace TN3270 { | ||
53 | + | ||
54 | + namespace Abstract { | ||
55 | + | ||
56 | + class TN3270_PRIVATE Session : public TN3270::Session { | ||
57 | + private: | ||
58 | + | ||
59 | +#ifdef HAVE_ICONV | ||
60 | + struct { | ||
61 | + | ||
62 | + /// @brief Convert strings from host codepage to local codepage. | ||
63 | + iconv_t local; | ||
64 | + | ||
65 | + /// @brief Convert string from local codepage to host codepage. | ||
66 | + iconv_t host; | ||
67 | + | ||
68 | + } iconv; | ||
69 | +#endif | ||
70 | + | ||
71 | + protected: | ||
72 | + | ||
73 | + /// @brief Current in/out position. | ||
74 | + int baddr; | ||
75 | + | ||
76 | + Session(); | ||
77 | + virtual ~Session(); | ||
78 | + | ||
79 | + }; | ||
80 | + | ||
81 | + } | ||
82 | + | ||
83 | + class TN3270_PRIVATE LocalSession : public Abstract::Session { | ||
84 | + private: | ||
85 | + | ||
86 | + /// @brief Handle of the related instance of lib3270 | ||
87 | + H3270 * hSession; | ||
88 | + | ||
89 | + public: | ||
90 | + LocalSession(); | ||
91 | + virtual ~LocalSession(); | ||
92 | + | ||
93 | + // Connect/disconnect | ||
94 | + void connect(const char *url) override; | ||
95 | + void disconnect() override; | ||
96 | + | ||
97 | + // Wait for session state. | ||
98 | + void waitForReady(time_t timeout = 5) throw() override; | ||
99 | + | ||
100 | + // Gets | ||
101 | + std::string toString() const override; | ||
102 | + std::string toString(int baddr = 0, size_t len = -1, bool lf = false) override; | ||
103 | + std::string toString(int row, int col, size_t sz, bool lf = false) override; | ||
104 | + | ||
105 | + ProgramMessage getProgramMessage() const override; | ||
106 | + | ||
107 | + ConnectionState getConnectionState() const override; | ||
108 | + | ||
109 | + /// @brief Set field at current posicion, jumps to next writable field. | ||
110 | + TN3270::Session & push(const char *text) override; | ||
111 | + | ||
112 | + TN3270::Session & push(int baddr, const std::string &text) override; | ||
113 | + TN3270::Session & push(int row, int col, const std::string &text) override; | ||
114 | + TN3270::Session & push(const PFKey key) override; | ||
115 | + TN3270::Session & push(const PAKey key) override; | ||
116 | + TN3270::Session & push(const Action action) override; | ||
117 | + | ||
118 | + // Get contents. | ||
119 | + TN3270::Session & pop(int baddr, std::string &text) override; | ||
120 | + TN3270::Session & pop(int row, int col, std::string &text) override; | ||
121 | + TN3270::Session & pop(std::string &text) override; | ||
122 | + | ||
123 | + }; | ||
124 | + | ||
125 | + } | ||
126 | + | ||
127 | +#endif // PRIVATE_H_INCLUDED |
@@ -0,0 +1,57 @@ | @@ -0,0 +1,57 @@ | ||
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 lib3270++.h 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 | + * | ||
28 | + */ | ||
29 | + | ||
30 | +/** | ||
31 | + * @file src/lib3270++/session.cc | ||
32 | + * | ||
33 | + * @brief | ||
34 | + * | ||
35 | + * @author perry.werneck@gmail.com | ||
36 | + * | ||
37 | + */ | ||
38 | + | ||
39 | + #include "private.h" | ||
40 | + | ||
41 | + | ||
42 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | ||
43 | + | ||
44 | + namespace TN3270 { | ||
45 | + | ||
46 | + Session::Session() { | ||
47 | + | ||
48 | + } | ||
49 | + | ||
50 | + Session::~Session() { | ||
51 | + | ||
52 | + } | ||
53 | + | ||
54 | + } | ||
55 | + | ||
56 | + | ||
57 | + |