Commit 4a57beb0bec0f787e21e3fa3d44881626a4023a2
1 parent
248cab7f
Exists in
master
and in
1 other branch
Improving "wait" calls
Adding methods required by the .NET module.
Showing
12 changed files
with
439 additions
and
135 deletions
Show diff stats
client/ipcclient.cbp
| ... | ... | @@ -71,6 +71,7 @@ |
| 71 | 71 | <Unit filename="src/session/local/private.h" /> |
| 72 | 72 | <Unit filename="src/session/local/properties.cc" /> |
| 73 | 73 | <Unit filename="src/session/local/set.cc" /> |
| 74 | + <Unit filename="src/session/local/wait.cc" /> | |
| 74 | 75 | <Unit filename="src/session/remote/actions.cc" /> |
| 75 | 76 | <Unit filename="src/session/remote/get.cc" /> |
| 76 | 77 | <Unit filename="src/session/remote/linux/request.cc" /> |
| ... | ... | @@ -79,6 +80,7 @@ |
| 79 | 80 | <Unit filename="src/session/remote/properties.cc" /> |
| 80 | 81 | <Unit filename="src/session/remote/set.cc" /> |
| 81 | 82 | <Unit filename="src/session/remote/tools.cc" /> |
| 83 | + <Unit filename="src/session/remote/wait.cc" /> | |
| 82 | 84 | <Unit filename="src/session/remote/windows/request.cc" /> |
| 83 | 85 | <Unit filename="src/session/remote/windows/session.cc" /> |
| 84 | 86 | <Unit filename="src/session/set.cc" /> | ... | ... |
client/src/include/lib3270/ipc.h
| ... | ... | @@ -413,6 +413,15 @@ |
| 413 | 413 | /// @brief Wait for screen changes. |
| 414 | 414 | virtual LIB3270_KEYBOARD_LOCK_STATE waitForKeyboardUnlock(time_t seconds = DEFAULT_TIMEOUT) const = 0; |
| 415 | 415 | |
| 416 | + /// @brief Wait for string. | |
| 417 | + virtual void wait(const char *text, int seconds = DEFAULT_TIMEOUT) = 0; | |
| 418 | + | |
| 419 | + /// @brief Wait for string. | |
| 420 | + virtual void wait(unsigned int row, unsigned int col, const char *text, int seconds = DEFAULT_TIMEOUT) = 0; | |
| 421 | + | |
| 422 | + /// @brief Wait for string. | |
| 423 | + virtual void wait(int addr, const char *text, int seconds = DEFAULT_TIMEOUT) = 0; | |
| 424 | + | |
| 416 | 425 | /// @brief Send PF. |
| 417 | 426 | virtual void pfkey(unsigned short value) = 0; |
| 418 | 427 | ... | ... |
client/src/session/local/actions.cc
| ... | ... | @@ -60,32 +60,6 @@ |
| 60 | 60 | chkResponse(lib3270_disconnect(hSession)); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - void Local::Session::wait(time_t seconds) const { | |
| 64 | - | |
| 65 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 66 | - chkResponse(lib3270_wait(this->hSession, seconds)); | |
| 67 | - | |
| 68 | - } | |
| 69 | - | |
| 70 | - void Local::Session::waitForReady(time_t timeout) const { | |
| 71 | - | |
| 72 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 73 | - chkResponse(lib3270_wait_for_ready(this->hSession, timeout)); | |
| 74 | - } | |
| 75 | - | |
| 76 | - LIB3270_KEYBOARD_LOCK_STATE Local::Session::waitForKeyboardUnlock(time_t timeout) const { | |
| 77 | - | |
| 78 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 79 | - return lib3270_wait_for_keyboard_unlock(this->hSession, timeout); | |
| 80 | - } | |
| 81 | - | |
| 82 | - void Local::Session::waitForChange(time_t seconds) const { | |
| 83 | - | |
| 84 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 85 | - chkResponse(lib3270_wait_for_update(this->hSession, seconds)); | |
| 86 | - | |
| 87 | - } | |
| 88 | - | |
| 89 | 63 | void Local::Session::pfkey(unsigned short value) { |
| 90 | 64 | |
| 91 | 65 | std::lock_guard<std::mutex> lock(sync); | ... | ... |
client/src/session/local/private.h
| ... | ... | @@ -100,8 +100,13 @@ |
| 100 | 100 | void wait(time_t seconds) const override; |
| 101 | 101 | void waitForReady(time_t timeout) const override; |
| 102 | 102 | void waitForChange(time_t timeout) const override; |
| 103 | + | |
| 103 | 104 | LIB3270_KEYBOARD_LOCK_STATE waitForKeyboardUnlock(time_t seconds) const override; |
| 104 | 105 | |
| 106 | + void wait(const char *text, int seconds) override; | |
| 107 | + void wait(int addr, const char *text, int seconds) override; | |
| 108 | + void wait(unsigned int row, unsigned int col, const char *text, int seconds) override; | |
| 109 | + | |
| 105 | 110 | // States |
| 106 | 111 | ProgramMessage getProgramMessage() const override; |
| 107 | 112 | ConnectionState getConnectionState() const override; | ... | ... |
| ... | ... | @@ -0,0 +1,95 @@ |
| 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 | + #include <lib3270/actions.h> | |
| 41 | + | |
| 42 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 43 | + | |
| 44 | + namespace TN3270 { | |
| 45 | + | |
| 46 | + void Local::Session::wait(time_t seconds) const { | |
| 47 | + | |
| 48 | + std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 49 | + chkResponse(lib3270_wait(this->hSession, seconds)); | |
| 50 | + | |
| 51 | + } | |
| 52 | + | |
| 53 | + void Local::Session::waitForReady(time_t timeout) const { | |
| 54 | + | |
| 55 | + std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 56 | + chkResponse(lib3270_wait_for_ready(this->hSession, timeout)); | |
| 57 | + } | |
| 58 | + | |
| 59 | + LIB3270_KEYBOARD_LOCK_STATE Local::Session::waitForKeyboardUnlock(time_t timeout) const { | |
| 60 | + | |
| 61 | + std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 62 | + return lib3270_wait_for_keyboard_unlock(this->hSession, timeout); | |
| 63 | + } | |
| 64 | + | |
| 65 | + void Local::Session::waitForChange(time_t seconds) const { | |
| 66 | + | |
| 67 | + std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 68 | + chkResponse(lib3270_wait_for_update(this->hSession, seconds)); | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + void Local::Session::wait(const char *text, int seconds) { | |
| 73 | + | |
| 74 | + std::lock_guard<std::mutex> lock(sync); | |
| 75 | + chkResponse(lib3270_wait_for_string(hSession,convertToHost(text,-1).c_str(),seconds)); | |
| 76 | + | |
| 77 | + } | |
| 78 | + | |
| 79 | + void Local::Session::wait(unsigned int row, unsigned int col, const char *text, int seconds) { | |
| 80 | + | |
| 81 | + std::lock_guard<std::mutex> lock(sync); | |
| 82 | + chkResponse(lib3270_wait_for_string_at(hSession,row,col,convertToHost(text,-1).c_str(),seconds)); | |
| 83 | + | |
| 84 | + } | |
| 85 | + | |
| 86 | + void Local::Session::wait(int addr, const char *text, int seconds) { | |
| 87 | + | |
| 88 | + std::lock_guard<std::mutex> lock(sync); | |
| 89 | + chkResponse(lib3270_wait_for_string_at_address(hSession,addr,convertToHost(text,-1).c_str(),seconds)); | |
| 90 | + | |
| 91 | + } | |
| 92 | + | |
| 93 | + } | |
| 94 | + | |
| 95 | + | ... | ... |
client/src/session/remote/actions.cc
| ... | ... | @@ -83,103 +83,6 @@ |
| 83 | 83 | |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - void IPC::Session::wait(time_t seconds) const { | |
| 87 | - | |
| 88 | - time_t end = time(nullptr) + seconds; | |
| 89 | - | |
| 90 | - while(time(nullptr) < end) { | |
| 91 | - | |
| 92 | -#ifdef _WIN32 | |
| 93 | - Sleep(1000); | |
| 94 | -#else | |
| 95 | - sleep(1); | |
| 96 | -#endif // _WIN32 | |
| 97 | - | |
| 98 | - if(getConnectionState() == TN3270::DISCONNECTED) | |
| 99 | - chkResponse(ENOTCONN); | |
| 100 | - | |
| 101 | - } | |
| 102 | - | |
| 103 | - } | |
| 104 | - | |
| 105 | - void IPC::Session::waitForReady(time_t timeout) const { | |
| 106 | - | |
| 107 | - int rc; | |
| 108 | - | |
| 109 | - time_t end = time(nullptr) + timeout; | |
| 110 | - | |
| 111 | - while(time(nullptr) < end) { | |
| 112 | - | |
| 113 | - debug("Running waitForReady request..."); | |
| 114 | - | |
| 115 | - Request(*this,"waitForReady") | |
| 116 | - .push((uint32_t) 1) | |
| 117 | - .call() | |
| 118 | - .pop(rc); | |
| 119 | - | |
| 120 | - debug("Wait for ready returned ",rc); | |
| 121 | - | |
| 122 | - if(rc == 0) | |
| 123 | - return; | |
| 124 | - | |
| 125 | - } | |
| 126 | - | |
| 127 | - throw std::system_error(ETIMEDOUT, std::system_category()); | |
| 128 | - | |
| 129 | - } | |
| 130 | - | |
| 131 | - LIB3270_KEYBOARD_LOCK_STATE IPC::Session::waitForKeyboardUnlock(time_t timeout) const { | |
| 132 | - | |
| 133 | - int rc; | |
| 134 | - | |
| 135 | - time_t end = time(nullptr) + timeout; | |
| 136 | - | |
| 137 | - while(time(nullptr) < end) { | |
| 138 | - | |
| 139 | - debug("Running waitForKeyboardUnlock request..."); | |
| 140 | - | |
| 141 | - Request(*this,"waitForKeyboardUnlock") | |
| 142 | - .push((uint32_t) 1) | |
| 143 | - .call() | |
| 144 | - .pop(rc); | |
| 145 | - | |
| 146 | - debug("Wait for unlock returned ",rc); | |
| 147 | - | |
| 148 | - if(rc == 0) | |
| 149 | - return (LIB3270_KEYBOARD_LOCK_STATE) 0; | |
| 150 | - | |
| 151 | - } | |
| 152 | - | |
| 153 | - return (LIB3270_KEYBOARD_LOCK_STATE) rc; | |
| 154 | - | |
| 155 | - } | |
| 156 | - | |
| 157 | - void IPC::Session::waitForChange(time_t seconds) const { | |
| 158 | - | |
| 159 | - int rc; | |
| 160 | - | |
| 161 | - time_t end = time(nullptr) + seconds; | |
| 162 | - | |
| 163 | - while(time(nullptr) < end) { | |
| 164 | - | |
| 165 | - debug("Running waitForUpdate request..."); | |
| 166 | - | |
| 167 | - Request(*this,"waitForUpdate") | |
| 168 | - .push((uint32_t) 1) | |
| 169 | - .call() | |
| 170 | - .pop(rc); | |
| 171 | - | |
| 172 | - debug("Wait for update returned ",rc); | |
| 173 | - | |
| 174 | - if(rc == 0) | |
| 175 | - return; | |
| 176 | - | |
| 177 | - } | |
| 178 | - | |
| 179 | - throw std::system_error(ETIMEDOUT, std::system_category()); | |
| 180 | - | |
| 181 | - } | |
| 182 | - | |
| 183 | 86 | void IPC::Session::pfkey(unsigned short value) { |
| 184 | 87 | |
| 185 | 88 | int32_t rc; | ... | ... |
client/src/session/remote/private.h
| ... | ... | @@ -70,6 +70,8 @@ |
| 70 | 70 | |
| 71 | 71 | #endif // _WIN32 |
| 72 | 72 | |
| 73 | + void wait(int seconds, std::function<int()> worker) const; | |
| 74 | + | |
| 73 | 75 | protected: |
| 74 | 76 | |
| 75 | 77 | // Get strings from lib3270 without charset conversion. |
| ... | ... | @@ -99,8 +101,13 @@ |
| 99 | 101 | void wait(time_t seconds) const override; |
| 100 | 102 | void waitForReady(time_t timeout) const override; |
| 101 | 103 | void waitForChange(time_t timeout) const override; |
| 104 | + | |
| 102 | 105 | LIB3270_KEYBOARD_LOCK_STATE waitForKeyboardUnlock(time_t seconds) const override; |
| 103 | 106 | |
| 107 | + void wait(const char *text, int seconds) override; | |
| 108 | + void wait(int addr, const char *text, int seconds) override; | |
| 109 | + void wait(unsigned int row, unsigned int col, const char *text, int seconds) override; | |
| 110 | + | |
| 104 | 111 | // States |
| 105 | 112 | ProgramMessage getProgramMessage() const override; |
| 106 | 113 | ConnectionState getConnectionState() const override; | ... | ... |
| ... | ... | @@ -0,0 +1,222 @@ |
| 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 | + #include <lib3270/actions.h> | |
| 41 | + | |
| 42 | +#ifndef _WIN32 | |
| 43 | + #include <unistd.h> | |
| 44 | +#endif // _WIN32 | |
| 45 | + | |
| 46 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 47 | + | |
| 48 | + namespace TN3270 { | |
| 49 | + | |
| 50 | + void IPC::Session::wait(int seconds, std::function<int()> worker) const { | |
| 51 | + | |
| 52 | + int rc; | |
| 53 | + | |
| 54 | + time_t end = time(nullptr) + seconds; | |
| 55 | + | |
| 56 | + while(time(nullptr) < end) { | |
| 57 | + | |
| 58 | + rc = worker(); | |
| 59 | + | |
| 60 | + if(rc == 0) | |
| 61 | + return; | |
| 62 | + else if(rc != ETIMEDOUT) | |
| 63 | + chkResponse(rc); | |
| 64 | + | |
| 65 | + } | |
| 66 | + | |
| 67 | + chkResponse(ETIMEDOUT); | |
| 68 | + | |
| 69 | + } | |
| 70 | + | |
| 71 | + void IPC::Session::wait(time_t seconds) const { | |
| 72 | + | |
| 73 | + time_t end = time(nullptr) + seconds; | |
| 74 | + | |
| 75 | + while(time(nullptr) < end) { | |
| 76 | + | |
| 77 | +#ifdef _WIN32 | |
| 78 | + Sleep(1000); | |
| 79 | +#else | |
| 80 | + sleep(1); | |
| 81 | +#endif // _WIN32 | |
| 82 | + | |
| 83 | + if(getConnectionState() == TN3270::DISCONNECTED) | |
| 84 | + chkResponse(ENOTCONN); | |
| 85 | + | |
| 86 | + } | |
| 87 | + | |
| 88 | + } | |
| 89 | + | |
| 90 | + void IPC::Session::waitForReady(time_t timeout) const { | |
| 91 | + | |
| 92 | + wait(timeout, [this]() { | |
| 93 | + | |
| 94 | + int rc; | |
| 95 | + | |
| 96 | + debug("Running waitForReady request..."); | |
| 97 | + | |
| 98 | + Request(*this,"waitForReady") | |
| 99 | + .push((uint32_t) 1) | |
| 100 | + .call() | |
| 101 | + .pop(rc); | |
| 102 | + | |
| 103 | + debug("Wait for ready returned ",rc); | |
| 104 | + | |
| 105 | + return rc; | |
| 106 | + | |
| 107 | + }); | |
| 108 | + | |
| 109 | + } | |
| 110 | + | |
| 111 | + LIB3270_KEYBOARD_LOCK_STATE IPC::Session::waitForKeyboardUnlock(time_t timeout) const { | |
| 112 | + | |
| 113 | + int rc; | |
| 114 | + | |
| 115 | + time_t end = time(nullptr) + timeout; | |
| 116 | + | |
| 117 | + while(time(nullptr) < end) { | |
| 118 | + | |
| 119 | + debug("Running waitForKeyboardUnlock request..."); | |
| 120 | + | |
| 121 | + Request(*this,"waitForKeyboardUnlock") | |
| 122 | + .push((uint32_t) 1) | |
| 123 | + .call() | |
| 124 | + .pop(rc); | |
| 125 | + | |
| 126 | + debug("Wait for unlock returned ",rc); | |
| 127 | + | |
| 128 | + if(rc == 0) | |
| 129 | + return (LIB3270_KEYBOARD_LOCK_STATE) 0; | |
| 130 | + | |
| 131 | + } | |
| 132 | + | |
| 133 | + return (LIB3270_KEYBOARD_LOCK_STATE) rc; | |
| 134 | + | |
| 135 | + } | |
| 136 | + | |
| 137 | + void IPC::Session::waitForChange(time_t seconds) const { | |
| 138 | + | |
| 139 | + wait(seconds, [this]() { | |
| 140 | + | |
| 141 | + int rc; | |
| 142 | + debug("Running waitForUpdate request..."); | |
| 143 | + | |
| 144 | + Request(*this,"waitForUpdate") | |
| 145 | + .push((uint32_t) 1) | |
| 146 | + .call() | |
| 147 | + .pop(rc); | |
| 148 | + | |
| 149 | + debug("Wait for update returned ",rc); | |
| 150 | + | |
| 151 | + return rc; | |
| 152 | + | |
| 153 | + }); | |
| 154 | + | |
| 155 | + } | |
| 156 | + | |
| 157 | + void IPC::Session::wait(const char *text, int seconds) { | |
| 158 | + | |
| 159 | + string key = convertToHost(text,-1); | |
| 160 | + | |
| 161 | + wait(seconds, [this, key]() { | |
| 162 | + | |
| 163 | + int rc; | |
| 164 | + | |
| 165 | + Request(*this,"waitForString") | |
| 166 | + .push(key.c_str()) | |
| 167 | + .push((uint32_t) 1) | |
| 168 | + .call() | |
| 169 | + .pop(rc); | |
| 170 | + | |
| 171 | + return rc; | |
| 172 | + | |
| 173 | + }); | |
| 174 | + | |
| 175 | + } | |
| 176 | + | |
| 177 | + void IPC::Session::wait(unsigned int row, unsigned int col, const char *text, int seconds) { | |
| 178 | + | |
| 179 | + string key = convertToHost(text,-1); | |
| 180 | + | |
| 181 | + wait(seconds, [this, key, row, col]() { | |
| 182 | + | |
| 183 | + int rc; | |
| 184 | + | |
| 185 | + Request(*this,"waitForStringAt") | |
| 186 | + .push((uint32_t) row) | |
| 187 | + .push((uint32_t) col) | |
| 188 | + .push(key.c_str()) | |
| 189 | + .push((uint32_t) 1) | |
| 190 | + .call() | |
| 191 | + .pop(rc); | |
| 192 | + | |
| 193 | + return rc; | |
| 194 | + | |
| 195 | + }); | |
| 196 | + | |
| 197 | + } | |
| 198 | + | |
| 199 | + void IPC::Session::wait(int addr, const char *text, int seconds) { | |
| 200 | + | |
| 201 | + string key = convertToHost(text,-1); | |
| 202 | + | |
| 203 | + wait(seconds, [this, key, addr]() { | |
| 204 | + | |
| 205 | + int rc; | |
| 206 | + | |
| 207 | + Request(*this,"waitForStringAtAddress") | |
| 208 | + .push((int32_t) addr) | |
| 209 | + .push(key.c_str()) | |
| 210 | + .push((uint32_t) 1) | |
| 211 | + .call() | |
| 212 | + .pop(rc); | |
| 213 | + | |
| 214 | + return rc; | |
| 215 | + | |
| 216 | + }); | |
| 217 | + | |
| 218 | + } | |
| 219 | + | |
| 220 | + } | |
| 221 | + | |
| 222 | + | ... | ... |
server/src/core/linux/gobject.c
| ... | ... | @@ -151,6 +151,10 @@ void ipc3270_add_terminal_introspection(GString *introspection) { |
| 151 | 151 | " <arg type='y' name='lf' direction='in' />" \ |
| 152 | 152 | " <arg type='s' name='text' direction='out' />" \ |
| 153 | 153 | " </method>" \ |
| 154 | + " <method name= 'wait'>" \ | |
| 155 | + " <arg type='u' name='seconds' direction='in' />" \ | |
| 156 | + " <arg type='i' name='result' direction='out' />" \ | |
| 157 | + " </method>" \ | |
| 154 | 158 | " <method name= 'waitForReady'>" \ |
| 155 | 159 | " <arg type='u' name='seconds' direction='in' />" \ |
| 156 | 160 | " <arg type='i' name='result' direction='out' />" \ |
| ... | ... | @@ -184,6 +188,21 @@ void ipc3270_add_terminal_introspection(GString *introspection) { |
| 184 | 188 | " <arg type='i' name='addr' direction='in' />" \ |
| 185 | 189 | " <arg type='u' name='attribute' direction='out' />" \ |
| 186 | 190 | " </method>" \ |
| 191 | + | |
| 192 | + " <method name= 'waitForStringAt'>" \ | |
| 193 | + " <arg type='i' name='row' direction='in' />" \ | |
| 194 | + " <arg type='i' name='col' direction='in' />" \ | |
| 195 | + " <arg type='s' name='text' direction='in' />" \ | |
| 196 | + " <arg type='u' name='seconds' direction='in' />" \ | |
| 197 | + " <arg type='u' name='attribute' direction='out' />" \ | |
| 198 | + " </method>" \ | |
| 199 | + " <method name= 'waitForStringAtAddress'>" \ | |
| 200 | + " <arg type='i' name='addr' direction='in' />" \ | |
| 201 | + " <arg type='s' name='text' direction='in' />" \ | |
| 202 | + " <arg type='u' name='seconds' direction='in' />" \ | |
| 203 | + " <arg type='u' name='attribute' direction='out' />" \ | |
| 204 | + " </method>" \ | |
| 205 | + | |
| 187 | 206 | " <property type='s' name='version' access='read'/>" \ |
| 188 | 207 | " <property type='s' name='revision' access='read'/>" |
| 189 | 208 | ); | ... | ... |
server/src/core/methods/methods.c
| ... | ... | @@ -59,6 +59,10 @@ int ipc3270_method_call(GObject *object, const gchar *method_name, GVariant *req |
| 59 | 59 | { "setStringAt", ipc3270_method_set_string }, |
| 60 | 60 | { "setStringAtAddress", ipc3270_method_set_string }, |
| 61 | 61 | |
| 62 | + { "waitForString", ipc3270_method_wait_for_string }, | |
| 63 | + { "waitForStringAt", ipc3270_method_wait_for_string }, | |
| 64 | + { "waitForStringAtAddress", ipc3270_method_wait_for_string }, | |
| 65 | + | |
| 62 | 66 | { "getFieldAttribute", ipc3270_method_get_field_attribute }, |
| 63 | 67 | { "getFieldAttributeAt", ipc3270_method_get_field_attribute }, |
| 64 | 68 | { "getFieldAttributeAtAddress", ipc3270_method_get_field_attribute }, | ... | ... |
server/src/core/methods/private.h
| ... | ... | @@ -47,6 +47,8 @@ |
| 47 | 47 | |
| 48 | 48 | G_GNUC_INTERNAL int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *response, GError **error); |
| 49 | 49 | |
| 50 | + G_GNUC_INTERNAL int ipc3270_method_wait_for_string(GObject *session, GVariant *request, GObject *response, GError **error); | |
| 51 | + | |
| 50 | 52 | G_GNUC_INTERNAL int ipc3270_method_wait(GObject *session, GVariant *request, GObject *response, GError **error); |
| 51 | 53 | G_GNUC_INTERNAL int ipc3270_method_wait_for_ready(GObject *session, GVariant *request, GObject *response, GError **error); |
| 52 | 54 | G_GNUC_INTERNAL int ipc3270_method_wait_for_update(GObject *session, GVariant *request, GObject *response, GError **error); | ... | ... |
server/src/core/methods/wait.c
| ... | ... | @@ -28,40 +28,102 @@ |
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | 30 | #include "private.h" |
| 31 | +#include <errno.h> | |
| 32 | +#include <string.h> | |
| 31 | 33 | #include <lib3270/keyboard.h> |
| 32 | 34 | |
| 33 | -int ipc3270_method_wait(GObject *session, GVariant *request, GObject *response, GError G_GNUC_UNUSED(**error)) { | |
| 35 | +int ipc3270_method_wait_for_string(GObject *session, GVariant *request, GObject *response, GError **error) { | |
| 34 | 36 | |
| 37 | + H3270 *hSession = ipc3270_get_session(session); | |
| 38 | + int rc = 0; | |
| 35 | 39 | guint seconds = 1; |
| 36 | - g_variant_get(request, "(u)", &seconds); | |
| 37 | - ipc3270_response_append_int32(response, lib3270_wait(ipc3270_get_session(session),seconds)); | |
| 40 | + gchar *text = NULL; | |
| 41 | + | |
| 42 | + if(*error) | |
| 43 | + return 0; | |
| 44 | + | |
| 45 | + switch(g_variant_n_children(request)) { | |
| 46 | + case 1: // Just text | |
| 47 | + { | |
| 48 | + gchar *text = NULL; | |
| 49 | + g_variant_get(request, "(&su)", &text, seconds); | |
| 50 | + | |
| 51 | + if(text) { | |
| 52 | + | |
| 53 | + g_autofree gchar * converted = g_convert_with_fallback(text,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,error); | |
| 54 | + rc = lib3270_wait_for_string(hSession,(const char *) converted, seconds); | |
| 55 | + | |
| 56 | + } | |
| 57 | + | |
| 58 | + } | |
| 59 | + | |
| 60 | + break; | |
| 61 | + | |
| 62 | + case 2: // Address and text | |
| 63 | + { | |
| 64 | + gint addr; | |
| 65 | + g_variant_get(request, "(i&su)", &addr, &text, &seconds); | |
| 66 | + | |
| 67 | + if(text) { | |
| 68 | + | |
| 69 | + g_autofree gchar * converted = g_convert_with_fallback(text,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,error); | |
| 70 | + rc = lib3270_wait_for_string_at_address(hSession,addr,(const char *) converted, seconds); | |
| 71 | + | |
| 72 | + } | |
| 73 | + | |
| 74 | + } | |
| 75 | + break; | |
| 76 | + | |
| 77 | + case 3: // Row, col & text | |
| 78 | + { | |
| 79 | + guint row, col; | |
| 80 | + g_variant_get(request, "(uu&su)", &row, &col, &text, &seconds); | |
| 81 | + | |
| 82 | + if(text) { | |
| 83 | + | |
| 84 | + g_autofree gchar * converted = g_convert_with_fallback(text,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,error); | |
| 85 | + rc = lib3270_wait_for_string_at(hSession,row,col,converted,seconds); | |
| 86 | + | |
| 87 | + } | |
| 88 | + | |
| 89 | + } | |
| 90 | + break; | |
| 91 | + | |
| 92 | + default: | |
| 93 | + g_message("waitforstring was called with %u arguments.",(unsigned int) g_variant_n_children(request)); | |
| 94 | + return EINVAL; | |
| 95 | + } | |
| 96 | + | |
| 97 | + ipc3270_response_append_int32(response, rc); | |
| 98 | + | |
| 38 | 99 | return 0; |
| 100 | +} | |
| 39 | 101 | |
| 102 | +int ipc3270_method_wait(GObject *session, GVariant *request, GObject *response, GError G_GNUC_UNUSED(**error)) { | |
| 103 | + guint seconds = 1; | |
| 104 | + g_variant_get(request, "(u)", &seconds); | |
| 105 | + ipc3270_response_append_int32(response,lib3270_wait(ipc3270_get_session(session),seconds)); | |
| 106 | + return 0; | |
| 40 | 107 | } |
| 41 | 108 | |
| 42 | 109 | int ipc3270_method_wait_for_ready(GObject *session, GVariant *request, GObject *response, GError G_GNUC_UNUSED(**error)) { |
| 43 | - | |
| 44 | 110 | guint seconds = 1; |
| 45 | 111 | g_variant_get(request, "(u)", &seconds); |
| 46 | - ipc3270_response_append_int32(response, lib3270_wait_for_ready(ipc3270_get_session(session),seconds)); | |
| 112 | + ipc3270_response_append_int32(response,lib3270_wait_for_ready(ipc3270_get_session(session),seconds)); | |
| 47 | 113 | return 0; |
| 48 | - | |
| 49 | 114 | } |
| 50 | 115 | |
| 51 | 116 | int ipc3270_method_wait_for_update(GObject *session, GVariant *request, GObject *response, GError G_GNUC_UNUSED(**error)) { |
| 52 | - | |
| 53 | 117 | guint seconds = 1; |
| 54 | 118 | g_variant_get(request, "(u)", &seconds); |
| 55 | - ipc3270_response_append_int32(response, lib3270_wait_for_update(ipc3270_get_session(session),seconds)); | |
| 119 | + ipc3270_response_append_int32(response,lib3270_wait_for_update(ipc3270_get_session(session),seconds)); | |
| 56 | 120 | return 0; |
| 57 | - | |
| 58 | 121 | } |
| 59 | 122 | |
| 60 | 123 | int ipc3270_method_wait_for_keyboard_unlock(GObject *session, GVariant *request, GObject *response, GError G_GNUC_UNUSED(**error)) { |
| 61 | - | |
| 62 | 124 | guint seconds = 1; |
| 63 | 125 | g_variant_get(request, "(u)", &seconds); |
| 64 | - ipc3270_response_append_int32(response, (gint32) lib3270_wait_for_keyboard_unlock(ipc3270_get_session(session),seconds)); | |
| 126 | + ipc3270_response_append_int32(response,lib3270_wait_for_keyboard_unlock(ipc3270_get_session(session),seconds)); | |
| 65 | 127 | return 0; |
| 66 | - | |
| 67 | 128 | } |
| 129 | + | ... | ... |