Commit 9b21070e5ddaa18a95cce58795f02ff9b642506d
1 parent
44b17966
Exists in
master
and in
1 other branch
Refactoring host object.
Showing
5 changed files
with
119 additions
and
120 deletions
Show diff stats
client/lib3270++.cbp
| ... | ... | @@ -55,6 +55,7 @@ |
| 55 | 55 | <Unit filename="src/host/init.cc" /> |
| 56 | 56 | <Unit filename="src/host/pop.cc" /> |
| 57 | 57 | <Unit filename="src/host/private.h" /> |
| 58 | + <Unit filename="src/host/push.cc" /> | |
| 58 | 59 | <Unit filename="src/host/states.cc" /> |
| 59 | 60 | <Unit filename="src/host/stream.cc" /> |
| 60 | 61 | <Unit filename="src/host/string.cc" /> | ... | ... |
client/src/core/session.cc
| ... | ... | @@ -71,26 +71,10 @@ |
| 71 | 71 | pakey( ((unsigned short) key) + 1); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - /* | |
| 75 | - void Session::insert(Event::Type type, std::function <void(const Event &event)> listener) { | |
| 76 | - } | |
| 77 | - | |
| 78 | - | |
| 79 | - Session & Session::push(int row, int col, const std::string &text) { | |
| 80 | - return push(row,col,text.c_str(),text.size()); | |
| 81 | - } | |
| 82 | - | |
| 83 | - Session & Session::push(int baddr, const std::string &text) { | |
| 84 | - return push(baddr,text.c_str(),text.size()); | |
| 85 | - } | |
| 86 | - | |
| 87 | - void Session::setCharSet(const char *charset) { | |
| 88 | - } | |
| 89 | - | |
| 90 | - */ | |
| 91 | - | |
| 92 | 74 | void Session::input(const char *text, const char control_char) { |
| 93 | 75 | |
| 76 | + waitForReady(); | |
| 77 | + | |
| 94 | 78 | for(const char * ptr = strchr(text,control_char); ptr; ptr = strchr(text,control_char)) { |
| 95 | 79 | |
| 96 | 80 | push(text,(size_t) (ptr-text)); |
| ... | ... | @@ -102,6 +86,7 @@ |
| 102 | 86 | |
| 103 | 87 | case 'E': // Enter |
| 104 | 88 | push(ENTER); |
| 89 | + waitForReady(); | |
| 105 | 90 | break; |
| 106 | 91 | |
| 107 | 92 | case 'F': // Erase EOF |
| ... | ... | @@ -110,98 +95,122 @@ |
| 110 | 95 | |
| 111 | 96 | case '1': // PF1 |
| 112 | 97 | push(PF_1); |
| 98 | + waitForReady(); | |
| 113 | 99 | break; |
| 114 | 100 | |
| 115 | 101 | case '2': // PF2 |
| 116 | 102 | push(PF_2); |
| 103 | + waitForReady(); | |
| 117 | 104 | break; |
| 118 | 105 | |
| 119 | 106 | case '3': // PF3 |
| 120 | 107 | push(PF_3); |
| 108 | + waitForReady(); | |
| 121 | 109 | break; |
| 122 | 110 | |
| 123 | 111 | case '4': // PF4 |
| 124 | 112 | push(PF_4); |
| 113 | + waitForReady(); | |
| 125 | 114 | break; |
| 126 | 115 | |
| 127 | 116 | case '5': // PF5 |
| 128 | 117 | push(PF_5); |
| 118 | + waitForReady(); | |
| 129 | 119 | break; |
| 130 | 120 | |
| 131 | 121 | case '6': // PF6 |
| 132 | 122 | push(PF_6); |
| 123 | + waitForReady(); | |
| 133 | 124 | break; |
| 134 | 125 | |
| 135 | 126 | case '7': // PF7 |
| 136 | 127 | push(PF_7); |
| 128 | + waitForReady(); | |
| 137 | 129 | break; |
| 138 | 130 | |
| 139 | 131 | case '8': // PF8 |
| 140 | 132 | push(PF_8); |
| 133 | + waitForReady(); | |
| 141 | 134 | break; |
| 142 | 135 | |
| 143 | 136 | case '9': // PF9 |
| 144 | 137 | push(PF_9); |
| 138 | + waitForReady(); | |
| 145 | 139 | break; |
| 146 | 140 | |
| 147 | 141 | case 'a': // PF10 |
| 148 | 142 | push(PF_10); |
| 143 | + waitForReady(); | |
| 149 | 144 | break; |
| 150 | 145 | |
| 151 | 146 | case 'b': // PF11 |
| 152 | 147 | push(PF_11); |
| 148 | + waitForReady(); | |
| 153 | 149 | break; |
| 154 | 150 | |
| 155 | 151 | case 'c': // PF12 |
| 156 | 152 | push(PF_12); |
| 153 | + waitForReady(); | |
| 157 | 154 | break; |
| 158 | 155 | |
| 159 | 156 | case 'd': // PF13 |
| 160 | 157 | push(PF_13); |
| 158 | + waitForReady(); | |
| 161 | 159 | break; |
| 162 | 160 | |
| 163 | 161 | case 'e': // PF14 |
| 164 | 162 | push(PF_14); |
| 163 | + waitForReady(); | |
| 165 | 164 | break; |
| 166 | 165 | |
| 167 | 166 | case 'f': // PF15 |
| 168 | 167 | push(PF_15); |
| 168 | + waitForReady(); | |
| 169 | 169 | break; |
| 170 | 170 | |
| 171 | 171 | case 'g': // PF16 |
| 172 | 172 | push(PF_16); |
| 173 | + waitForReady(); | |
| 173 | 174 | break; |
| 174 | 175 | |
| 175 | 176 | case 'h': // PF17 |
| 176 | 177 | push(PF_17); |
| 178 | + waitForReady(); | |
| 177 | 179 | break; |
| 178 | 180 | |
| 179 | 181 | case 'i': // PF18 |
| 180 | 182 | push(PF_18); |
| 183 | + waitForReady(); | |
| 181 | 184 | break; |
| 182 | 185 | |
| 183 | 186 | case 'j': // PF19 |
| 184 | 187 | push(PF_19); |
| 188 | + waitForReady(); | |
| 185 | 189 | break; |
| 186 | 190 | |
| 187 | 191 | case 'k': // PF20 |
| 188 | 192 | push(PF_20); |
| 193 | + waitForReady(); | |
| 189 | 194 | break; |
| 190 | 195 | |
| 191 | 196 | case 'l': // PF21 |
| 192 | 197 | push(PF_21); |
| 198 | + waitForReady(); | |
| 193 | 199 | break; |
| 194 | 200 | |
| 195 | 201 | case 'm': // PF22 |
| 196 | 202 | push(PF_22); |
| 203 | + waitForReady(); | |
| 197 | 204 | break; |
| 198 | 205 | |
| 199 | 206 | case 'n': // PF23 |
| 200 | 207 | push(PF_23); |
| 208 | + waitForReady(); | |
| 201 | 209 | break; |
| 202 | 210 | |
| 203 | 211 | case 'o': // PF24 |
| 204 | 212 | push(PF_24); |
| 213 | + waitForReady(); | |
| 205 | 214 | break; |
| 206 | 215 | |
| 207 | 216 | case '@': // Send '@' character |
| ... | ... | @@ -210,14 +219,17 @@ |
| 210 | 219 | |
| 211 | 220 | case 'x': // PA1 |
| 212 | 221 | push(PA_1); |
| 222 | + waitForReady(); | |
| 213 | 223 | break; |
| 214 | 224 | |
| 215 | 225 | case 'y': // PA2 |
| 216 | 226 | push(PA_2); |
| 227 | + waitForReady(); | |
| 217 | 228 | break; |
| 218 | 229 | |
| 219 | 230 | case 'z': // PA3 |
| 220 | 231 | push(PA_3); |
| 232 | + waitForReady(); | |
| 221 | 233 | break; |
| 222 | 234 | |
| 223 | 235 | case 'B': // PC_LEFTTAB = "@B" | ... | ... |
| ... | ... | @@ -0,0 +1,77 @@ |
| 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 - 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 | |
| 32 | + * | |
| 33 | + * @brief | |
| 34 | + * | |
| 35 | + * @author perry.werneck@gmail.com | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + | |
| 39 | + #include "private.h" | |
| 40 | + | |
| 41 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 42 | + | |
| 43 | +TN3270::Host & TN3270::Host::push(int baddr, const char *str, int len) { | |
| 44 | + session->push(baddr,str,len); | |
| 45 | + return *this; | |
| 46 | +} | |
| 47 | + | |
| 48 | +TN3270::Host & TN3270::Host::push(int row, int col, const char *str, int len) { | |
| 49 | + session->push(row,col,str,len); | |
| 50 | + return *this; | |
| 51 | +} | |
| 52 | + | |
| 53 | +TN3270::Host & TN3270::Host::push(const char *str, int len) { | |
| 54 | + session->push(str,len); | |
| 55 | + return *this; | |
| 56 | +} | |
| 57 | + | |
| 58 | +TN3270::Host & TN3270::Host::push(int baddr, const std::string &text) { | |
| 59 | + session->push(baddr,text); | |
| 60 | + return *this; | |
| 61 | +} | |
| 62 | + | |
| 63 | +TN3270::Host & TN3270::Host::push(int row, int col, const std::string &text) { | |
| 64 | + session->push(row,col,text); | |
| 65 | + return *this; | |
| 66 | +} | |
| 67 | + | |
| 68 | +TN3270::Host & TN3270::Host::push(const std::string &text) { | |
| 69 | + session->push(text); | |
| 70 | + return *this; | |
| 71 | +} | |
| 72 | + | |
| 73 | +TN3270::Host & TN3270::Host::input(const char *text, const char control_char) { | |
| 74 | + session->input(text,control_char); | |
| 75 | + return *this; | |
| 76 | +} | |
| 77 | + | ... | ... |
client/src/include/ipc-client-internals.h
| ... | ... | @@ -261,104 +261,6 @@ |
| 261 | 261 | |
| 262 | 262 | }; |
| 263 | 263 | |
| 264 | - /* | |
| 265 | - | |
| 266 | - | |
| 267 | - class TN3270_PRIVATE Session : public TN3270::Abstract::Session { | |
| 268 | - private: | |
| 269 | - | |
| 270 | - friend class Request; | |
| 271 | - | |
| 272 | -#ifdef _WIN32 | |
| 273 | - /// @brief Pipe Handle. | |
| 274 | - HANDLE hPipe; | |
| 275 | -#else | |
| 276 | - | |
| 277 | - DBusConnection * conn; | |
| 278 | - std::string name; ///< @brief D-Bus Object name. | |
| 279 | - std::string path; ///< @brief D-Bus Object path. | |
| 280 | - std::string interface; ///< @brief D-Bus interface. | |
| 281 | - | |
| 282 | -#endif // _WIN32 | |
| 283 | - | |
| 284 | - void call(Request &request); | |
| 285 | - | |
| 286 | - public: | |
| 287 | - | |
| 288 | - Session(const char *id); | |
| 289 | - virtual ~Session(); | |
| 290 | - | |
| 291 | - // Connect/disconnect | |
| 292 | - void connect(const char *url) override; | |
| 293 | - void disconnect() override; | |
| 294 | - | |
| 295 | - // Wait for session state. | |
| 296 | - void waitForReady(time_t timeout = 5) override; | |
| 297 | - | |
| 298 | - // Get properties. | |
| 299 | - void getProperty(const char *name, int &value) const override; | |
| 300 | - void getProperty(const char *name, std::string &value) const override; | |
| 301 | - void getProperty(const char *name, bool &value) const override; | |
| 302 | - | |
| 303 | - std::string getVersion() const override; | |
| 304 | - std::string getRevision() const override; | |
| 305 | - std::string getLUName() const override; | |
| 306 | - std::string getHostURL() const override; | |
| 307 | - SSLState getSSLState() const override; | |
| 308 | - | |
| 309 | - unsigned short getScreenWidth() const override; | |
| 310 | - unsigned short getScreenHeight() const override; | |
| 311 | - unsigned short getScreenLength() const override; | |
| 312 | - | |
| 313 | - // Set properties. | |
| 314 | - void setProperty(const char *name, const int value) const; | |
| 315 | - void setProperty(const char *name, const char * value) const; | |
| 316 | - void setUnlockDelay(unsigned short delay = 350) override; | |
| 317 | - void setHostURL(const char *url) override; | |
| 318 | - | |
| 319 | - | |
| 320 | - // Gets | |
| 321 | - std::string toString(int baddr, size_t len, char lf) const override; | |
| 322 | - std::string toString(int row, int col, size_t sz, char lf) const override; | |
| 323 | - | |
| 324 | - ProgramMessage getProgramMessage() const override; | |
| 325 | - | |
| 326 | - ConnectionState getConnectionState() const override; | |
| 327 | - | |
| 328 | - TN3270::Session & setCursor(unsigned short addr) override; | |
| 329 | - TN3270::Session & setCursor(unsigned short row, unsigned short col) override; | |
| 330 | - unsigned short getCursorAddress() override; | |
| 331 | - | |
| 332 | - TN3270::Session & pfkey(unsigned short value); | |
| 333 | - TN3270::Session & pakey(unsigned short value); | |
| 334 | - | |
| 335 | - TN3270::Session & input(const char *text, size_t length) override; | |
| 336 | - | |
| 337 | - /// @brief Set field at current posicion, jumps to next writable field. | |
| 338 | - TN3270::Session & push(const char *text) override; | |
| 339 | - | |
| 340 | - TN3270::Session & push(int baddr, const char *text, int length = -1) override; | |
| 341 | - TN3270::Session & push(int row, int col, const char *text, int length = -1) override; | |
| 342 | - | |
| 343 | - TN3270::Session & push(const Action action) override; | |
| 344 | - | |
| 345 | - // Get contents. | |
| 346 | - TN3270::Session & pop(int baddr, std::string &text) override; | |
| 347 | - TN3270::Session & pop(int row, int col, std::string &text) override; | |
| 348 | - TN3270::Session & pop(std::string &text) override; | |
| 349 | - | |
| 350 | - /// @brief Execute action by name. | |
| 351 | - TN3270::Session & action(const char *action_name) override; | |
| 352 | - | |
| 353 | - /// @brief Wait. | |
| 354 | - TN3270::Session & wait(unsigned short seconds) override; | |
| 355 | - | |
| 356 | - /// @brief Wait for update. | |
| 357 | - TN3270::Session & waitForChange(unsigned short seconds) override; | |
| 358 | - | |
| 359 | - }; | |
| 360 | - | |
| 361 | - */ | |
| 362 | 264 | } |
| 363 | 265 | |
| 364 | 266 | } | ... | ... |
common/src/include/lib3270/ipc.h
| ... | ... | @@ -282,7 +282,6 @@ |
| 282 | 282 | |
| 283 | 283 | /** |
| 284 | 284 | * @brief Input string parsing control char. |
| 285 | - * | |
| 286 | 285 | */ |
| 287 | 286 | void input(const char *text, const char control_char); |
| 288 | 287 | |
| ... | ... | @@ -377,6 +376,7 @@ |
| 377 | 376 | /// @brief Writes characters to the associated output sequence from the put area. |
| 378 | 377 | int overflow(int c) override; |
| 379 | 378 | |
| 379 | + /* | |
| 380 | 380 | /// @brief Write information to log file. |
| 381 | 381 | void info(const char *fmt, ...) const; |
| 382 | 382 | |
| ... | ... | @@ -385,6 +385,7 @@ |
| 385 | 385 | |
| 386 | 386 | /// @brief Write error to log file. |
| 387 | 387 | void error(const char *fmt, ...) const; |
| 388 | + */ | |
| 388 | 389 | |
| 389 | 390 | public: |
| 390 | 391 | Host(const char *id = nullptr, const char *url = nullptr, time_t timeout = DEFAULT_TIMEOUT); |
| ... | ... | @@ -395,9 +396,15 @@ |
| 395 | 396 | } |
| 396 | 397 | |
| 397 | 398 | // Contents |
| 398 | - Host & push(int baddr, std::string &text); | |
| 399 | - Host & push(int row, int col, std::string &text); | |
| 400 | - Host & push(std::string &text); | |
| 399 | + | |
| 400 | + /** | |
| 401 | + * @brief Input string parsing control char. | |
| 402 | + */ | |
| 403 | + Host & input(const char *text, const char control_char); | |
| 404 | + | |
| 405 | + Host & push(int baddr, const std::string &text); | |
| 406 | + Host & push(int row, int col, const std::string &text); | |
| 407 | + Host & push(const std::string &text); | |
| 401 | 408 | |
| 402 | 409 | Host & push(int baddr, const char *str, int len = -1); |
| 403 | 410 | Host & push(int row, int col, const char *str, int len = -1); | ... | ... |