From 2cd54c2062e7ddc40b727731cdf70f64dfedc69c Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Fri, 18 Sep 2020 15:30:40 -0300 Subject: [PATCH] Adding methods to set lib3270's properties. --- client/ipcclient.cbp | 4 +--- client/src/include/lib3270/ipc.h | 18 ++++++++++++++++++ client/src/session/local/private.h | 4 ++++ client/src/session/local/properties.cc | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ client/src/session/remote/private.h | 4 ++++ client/src/session/remote/properties.cc | 16 ++++++++++++++++ client/src/testprogram/testprogram.cc | 1 + 7 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 client/src/session/local/properties.cc diff --git a/client/ipcclient.cbp b/client/ipcclient.cbp index ab5385d..4cb4fd9 100644 --- a/client/ipcclient.cbp +++ b/client/ipcclient.cbp @@ -79,6 +79,7 @@ + @@ -97,9 +98,6 @@ - - - diff --git a/client/src/include/lib3270/ipc.h b/client/src/include/lib3270/ipc.h index a585cb4..5eca6de 100644 --- a/client/src/include/lib3270/ipc.h +++ b/client/src/include/lib3270/ipc.h @@ -660,6 +660,11 @@ int compare(int baddr, const char* s, int len = -1) const; int compare(unsigned short row, unsigned short col, const char* s, int len = -1) const; + virtual void setProperty(const char *name, const int value) = 0; + virtual void setProperty(const char *name, const unsigned int value) = 0; + virtual void setProperty(const char *name, const bool value) = 0; + virtual void setProperty(const char *name, const char *value) = 0; + }; /// @brief TN3270 Host @@ -954,6 +959,19 @@ int compare(int baddr, const char* s, int len = -1) const; int compare(unsigned short row, unsigned short col, const char* s, int len = -1) const; + /* + Host & setProperty(const char *name, const std::string &value) { + session->setProperty(name,value.c_str()); + return *this; + } + + template + Host & setProperty(const char *name, const T value) { + session->setProperty(name,value); + return *this; + } + */ + // Set contents. /// @brief Input string. diff --git a/client/src/session/local/private.h b/client/src/session/local/private.h index c07d6b7..e046690 100644 --- a/client/src/session/local/private.h +++ b/client/src/session/local/private.h @@ -162,6 +162,10 @@ unsigned short setCursor(unsigned short row, unsigned short col) override; unsigned short getCursorAddress() override; Session::Cursor getCursorPosition() override; + void setProperty(const char *name, const int value) override; + void setProperty(const char *name, const unsigned int value) override; + void setProperty(const char *name, const bool value) override; + void setProperty(const char *name, const char *value) override; }; diff --git a/client/src/session/local/properties.cc b/client/src/session/local/properties.cc new file mode 100644 index 0000000..453c24d --- /dev/null +++ b/client/src/session/local/properties.cc @@ -0,0 +1,85 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como - e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + +/** + * @file + * + * @brief + * + * @author perry.werneck@gmail.com + * + */ + + #include "private.h" + #include + #include + +/*---[ Implement ]----------------------------------------------------------------------------------*/ + + namespace TN3270 { + + void Local::Session::setProperty(const char *name, const int value) { + + std::lock_guard lock(const_cast(this)->sync); + int rc = lib3270_set_int_property(hSession,name,value,0); + if(rc) + chkResponse(rc); + + } + + void Local::Session::setProperty(const char *name, const unsigned int value) { + + std::lock_guard lock(const_cast(this)->sync); + int rc = lib3270_set_uint_property(hSession,name,value,0); + if(rc) + chkResponse(rc); + + } + + void Local::Session::setProperty(const char *name, const bool value) { + + std::lock_guard lock(const_cast(this)->sync); + int rc = lib3270_set_boolean_property(hSession,name,(int) value, 0); + if(rc) + chkResponse(rc); + + } + + void Local::Session::setProperty(const char *name, const char *value) { + + std::lock_guard lock(const_cast(this)->sync); + int rc = lib3270_set_string_property(hSession, name, value, 0); + if(rc) + chkResponse(rc); + + } + + } + + diff --git a/client/src/session/remote/private.h b/client/src/session/remote/private.h index 185391a..2a20827 100644 --- a/client/src/session/remote/private.h +++ b/client/src/session/remote/private.h @@ -167,6 +167,10 @@ unsigned short setCursor(unsigned short row, unsigned short col) override; unsigned short getCursorAddress() override; Session::Cursor getCursorPosition() override; + void setProperty(const char *name, const int value) override; + void setProperty(const char *name, const unsigned int value) override; + void setProperty(const char *name, const bool value) override; + void setProperty(const char *name, const char *value) override; }; diff --git a/client/src/session/remote/properties.cc b/client/src/session/remote/properties.cc index e8b7fa7..4bdadd6 100644 --- a/client/src/session/remote/properties.cc +++ b/client/src/session/remote/properties.cc @@ -236,6 +236,22 @@ } + void IPC::Session::setProperty(const char *name, const int value) { + setAttribute(name,value); + } + + void IPC::Session::setProperty(const char *name, const unsigned int value) { + setAttribute(name,value); + } + + void IPC::Session::setProperty(const char *name, const bool value) { + setAttribute(name,value); + } + + void IPC::Session::setProperty(const char *name, const char *value) { + setAttribute(name,value); + } + } diff --git a/client/src/testprogram/testprogram.cc b/client/src/testprogram/testprogram.cc index fca6700..91ce940 100644 --- a/client/src/testprogram/testprogram.cc +++ b/client/src/testprogram/testprogram.cc @@ -104,6 +104,7 @@ TN3270::Host host{session}; host.setTimeout(5); + // host.setProperty("crl_download",false); //name="url"; -- libgit2 0.21.2