Commit 8af651518c67b6f1b9c2d0965d65805e82b4e441
1 parent
b6677ed4
Exists in
master
and in
1 other branch
Fixing bugs.
Showing
4 changed files
with
57 additions
and
15 deletions
Show diff stats
client/src/include/ipc-client-internals.h
... | ... | @@ -235,7 +235,7 @@ |
235 | 235 | TN3270::Session & wait(unsigned short seconds) override; |
236 | 236 | |
237 | 237 | /// @brief Wait for update. |
238 | - TN3270::Session & wait_for_update(unsigned short seconds) override; | |
238 | + TN3270::Session & waitForChange(unsigned short seconds) override; | |
239 | 239 | |
240 | 240 | }; |
241 | 241 | |
... | ... | @@ -424,7 +424,7 @@ |
424 | 424 | TN3270::Session & wait(unsigned short seconds) override; |
425 | 425 | |
426 | 426 | /// @brief Wait for update. |
427 | - TN3270::Session & wait_for_update(unsigned short seconds) override; | |
427 | + TN3270::Session & waitForChange(unsigned short seconds) override; | |
428 | 428 | |
429 | 429 | }; |
430 | 430 | ... | ... |
client/src/session/local/session.cc
... | ... | @@ -464,7 +464,7 @@ |
464 | 464 | |
465 | 465 | string converted = convertToHost(text,length); |
466 | 466 | |
467 | - if(lib3270_set_string_at(this->hSession,row,col,(unsigned char *) converted.c_str())) { | |
467 | + if(lib3270_set_string_at(this->hSession,row,col,(unsigned char *) converted.c_str(),-1)) { | |
468 | 468 | throw std::system_error(errno, std::system_category()); |
469 | 469 | } |
470 | 470 | |
... | ... | @@ -666,8 +666,8 @@ |
666 | 666 | } |
667 | 667 | |
668 | 668 | /// @brief Wait for update. |
669 | - TN3270::Session & Local::Session::wait_for_update(unsigned short seconds) { | |
670 | - throw std::system_error(ENOTSUP, std::system_category()); | |
669 | + TN3270::Session & Local::Session::waitForChange(unsigned short seconds) { | |
670 | + chkResponse(lib3270_wait_for_update(hSession,seconds)); | |
671 | 671 | return *this; |
672 | 672 | } |
673 | 673 | |
... | ... | @@ -695,8 +695,8 @@ |
695 | 695 | return (unsigned short) lib3270_get_length(hSession); |
696 | 696 | } |
697 | 697 | |
698 | - TN3270::SSLState Local::Session::getSSLState() const override { | |
699 | - return lib3270_get_secure(hSession); | |
698 | + TN3270::SSLState Local::Session::getSSLState() const { | |
699 | + return (TN3270::SSLState) lib3270_get_ssl_state(hSession); | |
700 | 700 | } |
701 | 701 | |
702 | 702 | } | ... | ... |
client/src/session/remote/session.cc
... | ... | @@ -39,6 +39,10 @@ |
39 | 39 | #include <ipc-client-internals.h> |
40 | 40 | #include <cstring> |
41 | 41 | |
42 | +#ifndef _WIN32 | |
43 | + #include <unistd.h> // sleep | |
44 | +#endif // _WIN32 | |
45 | + | |
42 | 46 | using std::string; |
43 | 47 | |
44 | 48 | /*---[ Implement ]----------------------------------------------------------------------------------*/ |
... | ... | @@ -78,6 +82,7 @@ |
78 | 82 | } |
79 | 83 | |
80 | 84 | throw std::system_error(ETIMEDOUT, std::system_category()); |
85 | + | |
81 | 86 | } |
82 | 87 | |
83 | 88 | std::string IPC::Session::toString(int baddr, size_t len, char lf) const { |
... | ... | @@ -399,13 +404,44 @@ |
399 | 404 | /// @brief Wait. |
400 | 405 | TN3270::Session & IPC::Session::wait(unsigned short seconds) { |
401 | 406 | |
407 | + time_t end = time(nullptr) + seconds; | |
408 | + | |
409 | + while(time(nullptr) < end) { | |
410 | + | |
411 | + sleep(1); | |
412 | + if(getConnectionState() == TN3270::DISCONNECTED) | |
413 | + throw std::runtime_error("Disconnected"); | |
414 | + | |
415 | + } | |
416 | + | |
402 | 417 | return *this; |
403 | 418 | } |
404 | 419 | |
405 | 420 | /// @brief Wait for update. |
406 | - TN3270::Session & IPC::Session::wait_for_update(unsigned short seconds) { | |
421 | + TN3270::Session & IPC::Session::waitForChange(unsigned short seconds) { | |
422 | + | |
423 | + int rc; | |
424 | + | |
425 | + time_t end = time(nullptr) + seconds; | |
426 | + | |
427 | + while(time(nullptr) < end) { | |
428 | + | |
429 | + debug("Running waitForUpdate request..."); | |
430 | + | |
431 | + Request(*this,"waitForUpdate") | |
432 | + .push((uint32_t) 1) | |
433 | + .call() | |
434 | + .pop(rc); | |
435 | + | |
436 | + debug("Wait for update returned ",rc); | |
437 | + | |
438 | + if(rc == 0) | |
439 | + return *this; | |
440 | + | |
441 | + } | |
442 | + | |
443 | + throw std::system_error(ETIMEDOUT, std::system_category()); | |
407 | 444 | |
408 | - return *this; | |
409 | 445 | } |
410 | 446 | |
411 | 447 | void IPC::Session::setUnlockDelay(unsigned short delay) { |
... | ... | @@ -450,7 +486,7 @@ |
450 | 486 | |
451 | 487 | } |
452 | 488 | |
453 | - TN3270::SSLState Local::Session::getSSLState() const override { | |
489 | + TN3270::SSLState IPC::Session::getSSLState() const { | |
454 | 490 | |
455 | 491 | int value; |
456 | 492 | getProperty("sslstate",value); | ... | ... |
common/src/include/lib3270/ipc.h
... | ... | @@ -243,9 +243,6 @@ |
243 | 243 | virtual void connect(const char *url) = 0; |
244 | 244 | virtual void disconnect() = 0; |
245 | 245 | |
246 | - // Wait for session state. | |
247 | - virtual void waitForReady(time_t timeout = DEFAULT_TIMEOUT) = 0; | |
248 | - | |
249 | 246 | // Gets |
250 | 247 | virtual std::string toString(int baddr = 0, size_t len = -1, char lf = '\n') const = 0; |
251 | 248 | virtual std::string toString(int row, int col, size_t sz, char lf = '\n') const = 0; |
... | ... | @@ -350,8 +347,11 @@ |
350 | 347 | /// @brief Wait. |
351 | 348 | virtual Session & wait(unsigned short seconds) = 0; |
352 | 349 | |
353 | - /// @brief Wait for update. | |
354 | - virtual Session & wait_for_update(unsigned short seconds) = 0; | |
350 | + /// @brief Wait until session state changes to "ready". | |
351 | + virtual void waitForReady(time_t timeout = DEFAULT_TIMEOUT) = 0; | |
352 | + | |
353 | + /// @brief Wait for screen changes. | |
354 | + virtual Session & waitForChange(unsigned short seconds) = 0; | |
355 | 355 | |
356 | 356 | /// @brief Wait for string. |
357 | 357 | /// |
... | ... | @@ -498,6 +498,12 @@ |
498 | 498 | return *this; |
499 | 499 | } |
500 | 500 | |
501 | + /// @brief Wait for update. | |
502 | + inline Host & waitForChange(unsigned short seconds) { | |
503 | + session->waitForChange(seconds); | |
504 | + return *this; | |
505 | + } | |
506 | + | |
501 | 507 | // Set contents. |
502 | 508 | |
503 | 509 | /// @brief Input string. | ... | ... |