Commit 24a346b56910a47505676fcd874be3ba7a1426dd

Authored by Perry Werneck
1 parent 45043c1f
Exists in master and in 1 other branch develop

Adding pf/pa key support on host object.

client/src/core/host.cc
@@ -184,6 +184,18 @@ @@ -184,6 +184,18 @@
184 return *this; 184 return *this;
185 } 185 }
186 186
  187 + /// @brief Send PF.
  188 + Host & Host::pfkey(unsigned short value) {
  189 + this->session->pfkey(value);
  190 + return *this;
  191 + }
  192 +
  193 + /// @brief Send PA.
  194 + Host & Host::pakey(unsigned short value) {
  195 + this->session->pakey(value);
  196 + return *this;
  197 + }
  198 +
187 199
188 } 200 }
189 201
client/src/include/ipc-client-internals.h
@@ -195,6 +195,9 @@ @@ -195,6 +195,9 @@
195 TN3270::Session & setCursorPosition(unsigned short addr) override; 195 TN3270::Session & setCursorPosition(unsigned short addr) override;
196 TN3270::Session & setCursorPosition(unsigned short row, unsigned short col) override; 196 TN3270::Session & setCursorPosition(unsigned short row, unsigned short col) override;
197 197
  198 + TN3270::Session & pfkey(unsigned short value);
  199 + TN3270::Session & pakey(unsigned short value);
  200 +
198 /// @brief Set field at current posicion, jumps to next writable field. 201 /// @brief Set field at current posicion, jumps to next writable field.
199 TN3270::Session & push(const char *text) override; 202 TN3270::Session & push(const char *text) override;
200 203
@@ -359,6 +362,9 @@ @@ -359,6 +362,9 @@
359 TN3270::Session & setCursorPosition(unsigned short addr) override; 362 TN3270::Session & setCursorPosition(unsigned short addr) override;
360 TN3270::Session & setCursorPosition(unsigned short row, unsigned short col) override; 363 TN3270::Session & setCursorPosition(unsigned short row, unsigned short col) override;
361 364
  365 + TN3270::Session & pfkey(unsigned short value);
  366 + TN3270::Session & pakey(unsigned short value);
  367 +
362 /// @brief Set field at current posicion, jumps to next writable field. 368 /// @brief Set field at current posicion, jumps to next writable field.
363 TN3270::Session & push(const char *text) override; 369 TN3270::Session & push(const char *text) override;
364 370
client/src/session/local/session.cc
@@ -280,6 +280,31 @@ @@ -280,6 +280,31 @@
280 return *this; 280 return *this;
281 } 281 }
282 282
  283 + TN3270::Session & Local::Session::pfkey(unsigned short value) {
  284 +
  285 + std::lock_guard<std::mutex> lock(sync);
  286 +
  287 + int rc = lib3270_pfkey(hSession,(int) value);
  288 + if(rc) {
  289 + throw std::system_error(errno, std::system_category());
  290 + }
  291 +
  292 + return *this;
  293 + }
  294 +
  295 + TN3270::Session & Local::Session::pakey(unsigned short value) {
  296 +
  297 + std::lock_guard<std::mutex> lock(sync);
  298 +
  299 + int rc = lib3270_pakey(hSession,(int) value);
  300 + if(rc) {
  301 + throw std::system_error(errno, std::system_category());
  302 + }
  303 +
  304 + return *this;
  305 + }
  306 +
  307 +
283 TN3270::Session & Local::Session::pop(int baddr, std::string &text) { 308 TN3270::Session & Local::Session::pop(int baddr, std::string &text) {
284 309
285 std::lock_guard<std::mutex> lock(sync); 310 std::lock_guard<std::mutex> lock(sync);
client/src/session/remote/session.cc
@@ -214,6 +214,39 @@ @@ -214,6 +214,39 @@
214 214
215 } 215 }
216 216
  217 + TN3270::Session & IPC::Session::pfkey(unsigned short value) {
  218 +
  219 + int32_t rc;
  220 +
  221 + Request(*this,"pfkey")
  222 + .push((uint32_t) value)
  223 + .call()
  224 + .pop(rc);
  225 +
  226 + if(rc) {
  227 + throw std::system_error((int) rc, std::system_category());
  228 + }
  229 +
  230 + return *this;
  231 + }
  232 +
  233 + TN3270::Session & IPC::Session::pakey(unsigned short value) {
  234 +
  235 + int32_t rc;
  236 +
  237 + Request(*this,"pakey")
  238 + .push((uint32_t) value)
  239 + .call()
  240 + .pop(rc);
  241 +
  242 + if(rc) {
  243 + throw std::system_error((int) rc, std::system_category());
  244 + }
  245 +
  246 + return *this;
  247 +
  248 + }
  249 +
217 TN3270::Session & IPC::Session::push(const Action action) { 250 TN3270::Session & IPC::Session::push(const Action action) {
218 251
219 const char * actions[] = { 252 const char * actions[] = {
common/src/include/lib3270/ipc.h
@@ -248,6 +248,12 @@ @@ -248,6 +248,12 @@
248 /// @brief Set cursor position. 248 /// @brief Set cursor position.
249 virtual TN3270::Session & setCursorPosition(unsigned short row, unsigned short col) = 0; 249 virtual TN3270::Session & setCursorPosition(unsigned short row, unsigned short col) = 0;
250 250
  251 + /// @brief Send PF.
  252 + virtual Session & pfkey(unsigned short value) = 0;
  253 +
  254 + /// @brief Send PF.
  255 + virtual Session & pakey(unsigned short value) = 0;
  256 +
251 virtual Session & push(int baddr, const std::string &text) = 0; 257 virtual Session & push(int baddr, const std::string &text) = 0;
252 virtual Session & push(int row, int col, const std::string &text) = 0; 258 virtual Session & push(int row, int col, const std::string &text) = 0;
253 virtual Session & push(const PFKey key) = 0; 259 virtual Session & push(const PFKey key) = 0;
@@ -354,6 +360,14 @@ @@ -354,6 +360,14 @@
354 return session->getRevision(); 360 return session->getRevision();
355 } 361 }
356 362
  363 + // Actions
  364 +
  365 + /// @brief Send PF.
  366 + Host & pfkey(unsigned short value);
  367 +
  368 + /// @brief Send PA.
  369 + Host & pakey(unsigned short value);
  370 +
357 // Set contents. 371 // Set contents.
358 372
359 /// @brief Set field at current posicion, jumps to next writable field. 373 /// @brief Set field at current posicion, jumps to next writable field.