Commit 2cd54c2062e7ddc40b727731cdf70f64dfedc69c

Authored by Perry Werneck
1 parent 82fa758b
Exists in master and in 1 other branch develop

Adding methods to set lib3270's properties.

client/ipcclient.cbp
... ... @@ -79,6 +79,7 @@
79 79 <Unit filename="src/session/local/get.cc" />
80 80 <Unit filename="src/session/local/init.cc" />
81 81 <Unit filename="src/session/local/private.h" />
  82 + <Unit filename="src/session/local/properties.cc" />
82 83 <Unit filename="src/session/local/set.cc" />
83 84 <Unit filename="src/session/local/wait.cc" />
84 85 <Unit filename="src/session/remote/actions.cc" />
... ... @@ -97,9 +98,6 @@
97 98 <Unit filename="src/session/tools.cc" />
98 99 <Unit filename="src/testprogram/testprogram.cc" />
99 100 <Extensions>
100   - <code_completion />
101   - <envvars />
102   - <debugger />
103 101 <lib_finder disable_auto="1" />
104 102 </Extensions>
105 103 </Project>
... ...
client/src/include/lib3270/ipc.h
... ... @@ -660,6 +660,11 @@
660 660 int compare(int baddr, const char* s, int len = -1) const;
661 661 int compare(unsigned short row, unsigned short col, const char* s, int len = -1) const;
662 662  
  663 + virtual void setProperty(const char *name, const int value) = 0;
  664 + virtual void setProperty(const char *name, const unsigned int value) = 0;
  665 + virtual void setProperty(const char *name, const bool value) = 0;
  666 + virtual void setProperty(const char *name, const char *value) = 0;
  667 +
663 668 };
664 669  
665 670 /// @brief TN3270 Host
... ... @@ -954,6 +959,19 @@
954 959 int compare(int baddr, const char* s, int len = -1) const;
955 960 int compare(unsigned short row, unsigned short col, const char* s, int len = -1) const;
956 961  
  962 + /*
  963 + Host & setProperty(const char *name, const std::string &value) {
  964 + session->setProperty(name,value.c_str());
  965 + return *this;
  966 + }
  967 +
  968 + template <typename T>
  969 + Host & setProperty(const char *name, const T value) {
  970 + session->setProperty(name,value);
  971 + return *this;
  972 + }
  973 + */
  974 +
957 975 // Set contents.
958 976  
959 977 /// @brief Input string.
... ...
client/src/session/local/private.h
... ... @@ -162,6 +162,10 @@
162 162 unsigned short setCursor(unsigned short row, unsigned short col) override;
163 163 unsigned short getCursorAddress() override;
164 164 Session::Cursor getCursorPosition() override;
  165 + void setProperty(const char *name, const int value) override;
  166 + void setProperty(const char *name, const unsigned int value) override;
  167 + void setProperty(const char *name, const bool value) override;
  168 + void setProperty(const char *name, const char *value) override;
165 169  
166 170 };
167 171  
... ...
client/src/session/local/properties.cc 0 → 100644
... ... @@ -0,0 +1,85 @@
  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/ipc.h>
  41 + #include <lib3270/properties.h>
  42 +
  43 +/*---[ Implement ]----------------------------------------------------------------------------------*/
  44 +
  45 + namespace TN3270 {
  46 +
  47 + void Local::Session::setProperty(const char *name, const int value) {
  48 +
  49 + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync);
  50 + int rc = lib3270_set_int_property(hSession,name,value,0);
  51 + if(rc)
  52 + chkResponse(rc);
  53 +
  54 + }
  55 +
  56 + void Local::Session::setProperty(const char *name, const unsigned int value) {
  57 +
  58 + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync);
  59 + int rc = lib3270_set_uint_property(hSession,name,value,0);
  60 + if(rc)
  61 + chkResponse(rc);
  62 +
  63 + }
  64 +
  65 + void Local::Session::setProperty(const char *name, const bool value) {
  66 +
  67 + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync);
  68 + int rc = lib3270_set_boolean_property(hSession,name,(int) value, 0);
  69 + if(rc)
  70 + chkResponse(rc);
  71 +
  72 + }
  73 +
  74 + void Local::Session::setProperty(const char *name, const char *value) {
  75 +
  76 + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync);
  77 + int rc = lib3270_set_string_property(hSession, name, value, 0);
  78 + if(rc)
  79 + chkResponse(rc);
  80 +
  81 + }
  82 +
  83 + }
  84 +
  85 +
... ...
client/src/session/remote/private.h
... ... @@ -167,6 +167,10 @@
167 167 unsigned short setCursor(unsigned short row, unsigned short col) override;
168 168 unsigned short getCursorAddress() override;
169 169 Session::Cursor getCursorPosition() override;
  170 + void setProperty(const char *name, const int value) override;
  171 + void setProperty(const char *name, const unsigned int value) override;
  172 + void setProperty(const char *name, const bool value) override;
  173 + void setProperty(const char *name, const char *value) override;
170 174  
171 175 };
172 176  
... ...
client/src/session/remote/properties.cc
... ... @@ -236,6 +236,22 @@
236 236  
237 237 }
238 238  
  239 + void IPC::Session::setProperty(const char *name, const int value) {
  240 + setAttribute(name,value);
  241 + }
  242 +
  243 + void IPC::Session::setProperty(const char *name, const unsigned int value) {
  244 + setAttribute(name,value);
  245 + }
  246 +
  247 + void IPC::Session::setProperty(const char *name, const bool value) {
  248 + setAttribute(name,value);
  249 + }
  250 +
  251 + void IPC::Session::setProperty(const char *name, const char *value) {
  252 + setAttribute(name,value);
  253 + }
  254 +
239 255 }
240 256  
241 257  
... ...
client/src/testprogram/testprogram.cc
... ... @@ -104,6 +104,7 @@
104 104 TN3270::Host host{session};
105 105  
106 106 host.setTimeout(5);
  107 + // host.setProperty("crl_download",false);
107 108  
108 109 //name="url";
109 110  
... ...