From 9167ba7281d1267147ffdb7ebbf4978c6e76c551 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Wed, 16 Sep 2020 10:03:50 -0300 Subject: [PATCH] Adding get cursor position method. --- client/src/include/lib3270/ipc.h | 30 +++++++++++++++++++++++------- client/src/session/local/attribute.cc | 12 ++++++++++++ client/src/session/local/private.h | 2 +- client/src/session/remote/private.h | 1 + client/src/testprogram/testprogram.cc | 2 +- server/pw3270-plugin-ipc.cbp | 9 +++------ server/src/core/linux/gobject.c | 4 ++++ server/src/core/linux/response.c | 149 ----------------------------------------------------------------------------------------------------------------------------------------------------- server/src/core/linux/start.c | 12 ++++++++++-- server/src/core/methods/cursor.c | 19 +++++++++++++++++++ server/src/core/methods/methods.c | 1 + server/src/core/methods/private.h | 1 + server/src/core/response.c | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ server/src/core/windows/response.c | 150 ------------------------------------------------------------------------------------------------------------------------------------------------------ server/src/include/ipc-glib.h | 2 ++ server/src/testprogram/testprogram.c | 4 ++++ server/testscripts/dbus.conf | 6 ++++++ server/testscripts/getcursorposition.sh | 14 ++++++++++++++ server/testscripts/introspect.sh | 6 +++--- 19 files changed, 244 insertions(+), 319 deletions(-) delete mode 100644 server/src/core/linux/response.c create mode 100644 server/src/core/response.c delete mode 100644 server/src/core/windows/response.c create mode 100644 server/testscripts/dbus.conf create mode 100755 server/testscripts/getcursorposition.sh diff --git a/client/src/include/lib3270/ipc.h b/client/src/include/lib3270/ipc.h index 27ae009..13c6c5f 100644 --- a/client/src/include/lib3270/ipc.h +++ b/client/src/include/lib3270/ipc.h @@ -116,27 +116,26 @@ template class lib3270_ptr { private: - T *data; + T *ptr; public: - lib3270_ptr(T *data) { - this->data = data; + lib3270_ptr(T *d) : ptr(d) { } ~lib3270_ptr() { - lib3270_free((void *) this->data); + lib3270_free((void *) this->ptr); } operator bool() const noexcept { - return this->data != NULL; + return this->ptr != NULL; } T * operator->() { - return this->data; + return this->ptr; } operator T *() const noexcept { - return this->data; + return this->ptr; } }; @@ -230,6 +229,7 @@ SSL_SECURE = LIB3270_SSL_SECURE, ///< @brief Connection secure with CA check SSL_NEGOTIATED = LIB3270_SSL_NEGOTIATED, ///< @brief Connection secure, no CA, self-signed or expired CRL SSL_NEGOTIATING = LIB3270_SSL_NEGOTIATING, ///< @brief Negotiating SSL + SSL_VERIFYING = LIB3270_SSL_VERIFYING, ///< @brief Verifying SSL (Getting CRL) SSL_UNDEFINED = LIB3270_SSL_UNDEFINED ///< @brief Undefined }; @@ -451,6 +451,15 @@ public: + struct Cursor { + unsigned short row; + unsigned short col; + + Cursor(unsigned short r, unsigned short c) : row(r), col(c) { + } + + }; + /// @brief Get an instance of the TN3270 session based on the supplied ID. static Session * getInstance(const char *id = nullptr, const char *charset = nullptr); virtual ~Session(); @@ -586,6 +595,9 @@ /// @brief Get cursor address virtual unsigned short getCursorAddress() = 0; + /// @brief Get cursor position. + virtual struct Cursor getCursorPosition() = 0; + /// @brief Set local charset. virtual void setCharSet(const char *charset = NULL) = 0; @@ -783,6 +795,10 @@ return session->getCursorAddress(); } + inline Session::Cursor getCursorPosition() { + return session->getCursorPosition(); + } + inline void setHostURL(const char *url) { session->setHostURL(url); } diff --git a/client/src/session/local/attribute.cc b/client/src/session/local/attribute.cc index 69bf38f..4ce77ac 100644 --- a/client/src/session/local/attribute.cc +++ b/client/src/session/local/attribute.cc @@ -527,6 +527,18 @@ return rc; } + struct Session::Cursor Local::Session::getCursorPosition() { + + std::lock_guard lock(sync); + + unsigned short row = 0, col = 0; + + + return Session::Cursor(row,col); + + }; + + std::string Local::Session::getVersion() const { std::lock_guard lock(const_cast(this)->sync); diff --git a/client/src/session/local/private.h b/client/src/session/local/private.h index bc2c406..c07d6b7 100644 --- a/client/src/session/local/private.h +++ b/client/src/session/local/private.h @@ -161,7 +161,7 @@ unsigned short setCursor(int addr) override; unsigned short setCursor(unsigned short row, unsigned short col) override; unsigned short getCursorAddress() override; - + Session::Cursor getCursorPosition() override; }; diff --git a/client/src/session/remote/private.h b/client/src/session/remote/private.h index 746991e..185391a 100644 --- a/client/src/session/remote/private.h +++ b/client/src/session/remote/private.h @@ -166,6 +166,7 @@ unsigned short setCursor(int addr) override; unsigned short setCursor(unsigned short row, unsigned short col) override; unsigned short getCursorAddress() override; + Session::Cursor getCursorPosition() override; }; diff --git a/client/src/testprogram/testprogram.cc b/client/src/testprogram/testprogram.cc index 342adae..1ea8fbb 100644 --- a/client/src/testprogram/testprogram.cc +++ b/client/src/testprogram/testprogram.cc @@ -103,7 +103,7 @@ TN3270::Host host{session}; - name="url"; + // name="url"; cout << endl << endl; for(auto attribute : host.getAttributes()) { diff --git a/server/pw3270-plugin-ipc.cbp b/server/pw3270-plugin-ipc.cbp index 5f4e4e7..ce6b1c0 100644 --- a/server/pw3270-plugin-ipc.cbp +++ b/server/pw3270-plugin-ipc.cbp @@ -68,9 +68,6 @@