diff --git a/client/ipcclient.cbp b/client/ipcclient.cbp
index cf95ed1..919b525 100644
--- a/client/ipcclient.cbp
+++ b/client/ipcclient.cbp
@@ -68,6 +68,7 @@
+
diff --git a/client/src/core/constants.cc b/client/src/core/constants.cc
index b3ef2c4..7ba30f9 100644
--- a/client/src/core/constants.cc
+++ b/client/src/core/constants.cc
@@ -50,7 +50,7 @@ TN3270_PUBLIC const char * getRevision() {
return LIB3270_STRINGIZE_VALUE_OF(PACKAGE_RELEASE);
}
-TN3270_PUBLIC const char * toCharString(const TN3270::Action action) {
+TN3270_PUBLIC const char * toCharString(const TN3270::KeyboardAction action) {
static const char * actions[] = {
"enter",
diff --git a/client/src/core/session.cc b/client/src/core/session.cc
index d07d16e..0e9732c 100644
--- a/client/src/core/session.cc
+++ b/client/src/core/session.cc
@@ -439,6 +439,11 @@
value = getAttribute(name).getBoolean();
}
+ /// @brief Create an action object
+ Action * Session::getAction(const LIB3270_ACTION *descriptor) {
+ throw std::system_error(ENOTSUP, std::system_category());
+ }
+
}
diff --git a/client/src/include/lib3270/ipc.h b/client/src/include/lib3270/ipc.h
index 3f63202..1aed4ab 100644
--- a/client/src/include/lib3270/ipc.h
+++ b/client/src/include/lib3270/ipc.h
@@ -68,6 +68,7 @@
class Host;
class Controller;
+ class Action;
#define DEFAULT_TIMEOUT 5
@@ -222,8 +223,8 @@
PA_3
};
- /// @brief LIB3270 Action.
- enum Action : uint8_t {
+ /// @brief Keyboard Actions.
+ enum KeyboardAction : uint8_t {
ENTER, ///< @brief Enter key
ERASE,
ERASE_EOF,
@@ -436,7 +437,7 @@
void push(const PFKey key);
void push(const PAKey key);
- virtual void push(const Action action) = 0;
+ virtual void push(const KeyboardAction action) = 0;
/// @brief Get contents of field ad address.
virtual void pop(int baddr, std::string &text) = 0;
@@ -541,8 +542,6 @@
/// @brief Set local charset.
virtual void setCharSet(const char *charset = NULL) = 0;
- // Actions
-
/// @brief Execute action by name.
virtual void action(const char *action_name) = 0;
@@ -583,7 +582,8 @@
/// @brief Insert event listener.
// void insert(Event::Type type, std::function listener);
- // Misc
+ /// @brief Create an action object
+ virtual Action * getAction(const LIB3270_ACTION *descriptor);
/// @brief Search
size_t find(const char * str, size_t pos = 0) const;
@@ -899,7 +899,7 @@
/// @param The action code.
///
/// @return The action description.
- TN3270_PUBLIC const char * toCharString(const TN3270::Action action);
+ TN3270_PUBLIC const char * toCharString(const TN3270::KeyboardAction action);
template
inline TN3270_PUBLIC TN3270::Session & operator<<(TN3270::Session& session, const T value) {
diff --git a/client/src/include/lib3270/ipc/action.h b/client/src/include/lib3270/ipc/action.h
new file mode 100644
index 0000000..f26362e
--- /dev/null
+++ b/client/src/include/lib3270/ipc/action.h
@@ -0,0 +1,61 @@
+/*
+ * "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 lib3270/ipc/action.h
+ *
+ * @brief Declares the TN3270 IPC Action object.
+ *
+ * @author perry.werneck@gmail.com
+ *
+ */
+
+#ifndef IPC3270_ACTION_H_INCLUDED
+
+ #define IPC3270_ACTION_H_INCLUDED
+
+ #include
+
+ namespace TN3270 {
+
+ /// @brief TN3270 Action
+ class TN3270_PUBLIC Action {
+ public:
+ virtual bool activatable() const noexcept = 0;
+ virtual void activate() = 0;
+
+ inline operator bool() const noexcept {
+ return activatable();
+ }
+
+ };
+
+ }
+
+#endif // IPC3270_ACTION_H_INCLUDED
diff --git a/client/src/include/lib3270/ipc/request.h b/client/src/include/lib3270/ipc/request.h
index 6de8563..62d1dc6 100644
--- a/client/src/include/lib3270/ipc/request.h
+++ b/client/src/include/lib3270/ipc/request.h
@@ -40,7 +40,7 @@
#define IPC3270_REQUEST_H_INCLUDED
- #include
+ #include
#ifdef _WIN32
#include
diff --git a/client/src/session/local/actions.cc b/client/src/session/local/actions.cc
index 4c45fa3..e8cf9bd 100644
--- a/client/src/session/local/actions.cc
+++ b/client/src/session/local/actions.cc
@@ -38,11 +38,32 @@
#include "private.h"
#include
+ #include
/*---[ Implement ]----------------------------------------------------------------------------------*/
namespace TN3270 {
+ Local::Action::Action(Session *session, const LIB3270_ACTION *descriptor) {
+ this->session = session;
+ this->descriptor = descriptor;
+ }
+
+ bool Local::Action::activatable() const noexcept {
+ std::lock_guard lock(this->session->sync);
+ return lib3270_action_is_activatable(this->descriptor,this->session->hSession);
+ }
+
+ void Local::Action::activate() {
+ std::lock_guard lock(this->session->sync);
+ chkResponse(lib3270_action_activate(this->descriptor,this->session->hSession));
+ }
+
+ TN3270::Action * Local::Session::getAction(const LIB3270_ACTION *descriptor) {
+ std::lock_guard lock(sync);
+ return new Local::Action(this, descriptor);
+ }
+
void Local::Session::action(const char *action_name) {
std::lock_guard lock(sync);
chkResponse(lib3270_action_activate_by_name(action_name,hSession));
@@ -74,7 +95,7 @@
}
- void Local::Session::push(const Action action) {
+ void Local::Session::push(const KeyboardAction action) {
typedef int (*ActionCallback)(H3270 *);
diff --git a/client/src/session/local/private.h b/client/src/session/local/private.h
index 26c3b3f..47ef7c6 100644
--- a/client/src/session/local/private.h
+++ b/client/src/session/local/private.h
@@ -42,6 +42,7 @@
#include
#include
+ #include
#include
#include
#include
@@ -53,9 +54,25 @@
namespace Local {
+ class Session;
+
+ class Action : public TN3270::Action {
+ private:
+ Session *session;
+ const LIB3270_ACTION *descriptor;
+
+ public:
+ Action(Session *hSession, const LIB3270_ACTION *descriptor);
+ bool activatable() const noexcept override;
+ void activate() override;
+
+ };
+
class TN3270_PRIVATE Session : public TN3270::Abstract::Session {
private:
+ friend class Action;
+
/// @brief Handle of the related instance of lib3270
H3270 * hSession;
@@ -89,12 +106,14 @@
virtual ~Session();
// Actions
+ TN3270::Action * getAction(const LIB3270_ACTION *descriptor) override;
+
void action(const char *action_name) override;
void connect(const char *url, int seconds) override;
void disconnect() override;
void pfkey(unsigned short value) override;
void pakey(unsigned short value) override;
- void push(const Action action) override;
+ void push(const KeyboardAction action) override;
void print(LIB3270_CONTENT_OPTION option = LIB3270_CONTENT_ALL) override;
void wait(time_t seconds) const override;
diff --git a/client/src/session/remote/actions.cc b/client/src/session/remote/actions.cc
index e7d097a..bab92bd 100644
--- a/client/src/session/remote/actions.cc
+++ b/client/src/session/remote/actions.cc
@@ -113,7 +113,7 @@
}
- void IPC::Session::push(const Action action) {
+ void IPC::Session::push(const KeyboardAction action) {
this->action(toCharString(action));
}
diff --git a/client/src/session/remote/private.h b/client/src/session/remote/private.h
index 03ddf15..813fbcb 100644
--- a/client/src/session/remote/private.h
+++ b/client/src/session/remote/private.h
@@ -95,7 +95,7 @@
void disconnect() override;
void pfkey(unsigned short value) override;
void pakey(unsigned short value) override;
- void push(const Action action) override;
+ void push(const KeyboardAction action) override;
void print(LIB3270_CONTENT_OPTION option = LIB3270_CONTENT_ALL) override;
void wait(time_t seconds) const override;
--
libgit2 0.21.2