Commit 9167ba7281d1267147ffdb7ebbf4978c6e76c551
1 parent
dcf0fc2c
Exists in
master
and in
1 other branch
Adding get cursor position method.
Showing
19 changed files
with
244 additions
and
319 deletions
Show diff stats
client/src/include/lib3270/ipc.h
| ... | ... | @@ -116,27 +116,26 @@ |
| 116 | 116 | template<typename T> |
| 117 | 117 | class lib3270_ptr { |
| 118 | 118 | private: |
| 119 | - T *data; | |
| 119 | + T *ptr; | |
| 120 | 120 | |
| 121 | 121 | public: |
| 122 | - lib3270_ptr(T *data) { | |
| 123 | - this->data = data; | |
| 122 | + lib3270_ptr(T *d) : ptr(d) { | |
| 124 | 123 | } |
| 125 | 124 | |
| 126 | 125 | ~lib3270_ptr() { |
| 127 | - lib3270_free((void *) this->data); | |
| 126 | + lib3270_free((void *) this->ptr); | |
| 128 | 127 | } |
| 129 | 128 | |
| 130 | 129 | operator bool() const noexcept { |
| 131 | - return this->data != NULL; | |
| 130 | + return this->ptr != NULL; | |
| 132 | 131 | } |
| 133 | 132 | |
| 134 | 133 | T * operator->() { |
| 135 | - return this->data; | |
| 134 | + return this->ptr; | |
| 136 | 135 | } |
| 137 | 136 | |
| 138 | 137 | operator T *() const noexcept { |
| 139 | - return this->data; | |
| 138 | + return this->ptr; | |
| 140 | 139 | } |
| 141 | 140 | |
| 142 | 141 | }; |
| ... | ... | @@ -230,6 +229,7 @@ |
| 230 | 229 | SSL_SECURE = LIB3270_SSL_SECURE, ///< @brief Connection secure with CA check |
| 231 | 230 | SSL_NEGOTIATED = LIB3270_SSL_NEGOTIATED, ///< @brief Connection secure, no CA, self-signed or expired CRL |
| 232 | 231 | SSL_NEGOTIATING = LIB3270_SSL_NEGOTIATING, ///< @brief Negotiating SSL |
| 232 | + SSL_VERIFYING = LIB3270_SSL_VERIFYING, ///< @brief Verifying SSL (Getting CRL) | |
| 233 | 233 | SSL_UNDEFINED = LIB3270_SSL_UNDEFINED ///< @brief Undefined |
| 234 | 234 | }; |
| 235 | 235 | |
| ... | ... | @@ -451,6 +451,15 @@ |
| 451 | 451 | |
| 452 | 452 | public: |
| 453 | 453 | |
| 454 | + struct Cursor { | |
| 455 | + unsigned short row; | |
| 456 | + unsigned short col; | |
| 457 | + | |
| 458 | + Cursor(unsigned short r, unsigned short c) : row(r), col(c) { | |
| 459 | + } | |
| 460 | + | |
| 461 | + }; | |
| 462 | + | |
| 454 | 463 | /// @brief Get an instance of the TN3270 session based on the supplied ID. |
| 455 | 464 | static Session * getInstance(const char *id = nullptr, const char *charset = nullptr); |
| 456 | 465 | virtual ~Session(); |
| ... | ... | @@ -586,6 +595,9 @@ |
| 586 | 595 | /// @brief Get cursor address |
| 587 | 596 | virtual unsigned short getCursorAddress() = 0; |
| 588 | 597 | |
| 598 | + /// @brief Get cursor position. | |
| 599 | + virtual struct Cursor getCursorPosition() = 0; | |
| 600 | + | |
| 589 | 601 | /// @brief Set local charset. |
| 590 | 602 | virtual void setCharSet(const char *charset = NULL) = 0; |
| 591 | 603 | |
| ... | ... | @@ -783,6 +795,10 @@ |
| 783 | 795 | return session->getCursorAddress(); |
| 784 | 796 | } |
| 785 | 797 | |
| 798 | + inline Session::Cursor getCursorPosition() { | |
| 799 | + return session->getCursorPosition(); | |
| 800 | + } | |
| 801 | + | |
| 786 | 802 | inline void setHostURL(const char *url) { |
| 787 | 803 | session->setHostURL(url); |
| 788 | 804 | } | ... | ... |
client/src/session/local/attribute.cc
| ... | ... | @@ -527,6 +527,18 @@ |
| 527 | 527 | return rc; |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | + struct Session::Cursor Local::Session::getCursorPosition() { | |
| 531 | + | |
| 532 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
| 533 | + | |
| 534 | + unsigned short row = 0, col = 0; | |
| 535 | + | |
| 536 | + | |
| 537 | + return Session::Cursor(row,col); | |
| 538 | + | |
| 539 | + }; | |
| 540 | + | |
| 541 | + | |
| 530 | 542 | std::string Local::Session::getVersion() const { |
| 531 | 543 | |
| 532 | 544 | std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | ... | ... |
client/src/session/local/private.h
| ... | ... | @@ -161,7 +161,7 @@ |
| 161 | 161 | unsigned short setCursor(int addr) override; |
| 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 | 165 | |
| 166 | 166 | }; |
| 167 | 167 | ... | ... |
client/src/session/remote/private.h
| ... | ... | @@ -166,6 +166,7 @@ |
| 166 | 166 | unsigned short setCursor(int addr) override; |
| 167 | 167 | unsigned short setCursor(unsigned short row, unsigned short col) override; |
| 168 | 168 | unsigned short getCursorAddress() override; |
| 169 | + Session::Cursor getCursorPosition() override; | |
| 169 | 170 | |
| 170 | 171 | }; |
| 171 | 172 | ... | ... |
client/src/testprogram/testprogram.cc
server/pw3270-plugin-ipc.cbp
| ... | ... | @@ -68,9 +68,6 @@ |
| 68 | 68 | <Option compilerVar="CC" /> |
| 69 | 69 | </Unit> |
| 70 | 70 | <Unit filename="src/core/linux/gobject.h" /> |
| 71 | - <Unit filename="src/core/linux/response.c"> | |
| 72 | - <Option compilerVar="CC" /> | |
| 73 | - </Unit> | |
| 74 | 71 | <Unit filename="src/core/linux/start.c"> |
| 75 | 72 | <Option compilerVar="CC" /> |
| 76 | 73 | </Unit> |
| ... | ... | @@ -102,6 +99,9 @@ |
| 102 | 99 | <Unit filename="src/core/methods/wait.c"> |
| 103 | 100 | <Option compilerVar="CC" /> |
| 104 | 101 | </Unit> |
| 102 | + <Unit filename="src/core/response.c"> | |
| 103 | + <Option compilerVar="CC" /> | |
| 104 | + </Unit> | |
| 105 | 105 | <Unit filename="src/core/setproperties.c"> |
| 106 | 106 | <Option compilerVar="CC" /> |
| 107 | 107 | </Unit> |
| ... | ... | @@ -161,9 +161,6 @@ |
| 161 | 161 | <Option compilerVar="CC" /> |
| 162 | 162 | </Unit> |
| 163 | 163 | <Extensions> |
| 164 | - <code_completion /> | |
| 165 | - <envvars /> | |
| 166 | - <debugger /> | |
| 167 | 164 | <lib_finder disable_auto="1" /> |
| 168 | 165 | </Extensions> |
| 169 | 166 | </Project> | ... | ... |
server/src/core/linux/gobject.c
| ... | ... | @@ -197,6 +197,10 @@ void ipc3270_add_terminal_introspection(GString *introspection) { |
| 197 | 197 | " <arg type='i' name='addr' direction='in' />" \ |
| 198 | 198 | " <arg type='i' name='old' direction='out' />" \ |
| 199 | 199 | " </method>" \ |
| 200 | + " <method name= 'getCursorPosition'>" \ | |
| 201 | + " <arg type='u' name='row' direction='out' />" \ | |
| 202 | + " <arg type='u' name='col' direction='out' />" \ | |
| 203 | + " </method>" \ | |
| 200 | 204 | " <method name= 'getFieldAttribute'>" \ |
| 201 | 205 | " <arg type='u' name='attribute' direction='out' />" \ |
| 202 | 206 | " </method>" \ | ... | ... |
server/src/core/linux/response.c
| ... | ... | @@ -1,149 +0,0 @@ |
| 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 | - * Referências: | |
| 24 | - * | |
| 25 | - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
| 26 | - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
| 27 | - * | |
| 28 | - * Contatos: | |
| 29 | - * | |
| 30 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 31 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 32 | - * | |
| 33 | - */ | |
| 34 | - | |
| 35 | -#include "gobject.h" | |
| 36 | -#include <lib3270.h> | |
| 37 | -#include <lib3270/actions.h> | |
| 38 | -#include <lib3270/properties.h> | |
| 39 | -#include <lib3270/toggle.h> | |
| 40 | -#include <v3270.h> | |
| 41 | - | |
| 42 | -#include <dbus/dbus-glib.h> | |
| 43 | -#include <dbus/dbus-glib-bindings.h> | |
| 44 | - | |
| 45 | -/*--[ Widget definition ]----------------------------------------------------------------------------*/ | |
| 46 | - | |
| 47 | -struct _ipc3270Response { | |
| 48 | - GObject parent; | |
| 49 | - GVariant * value; | |
| 50 | -}; | |
| 51 | - | |
| 52 | -struct _ipc3270ResponseClass { | |
| 53 | - | |
| 54 | - GObjectClass parent; | |
| 55 | - int dummy; | |
| 56 | - | |
| 57 | -}; | |
| 58 | - | |
| 59 | - | |
| 60 | -G_DEFINE_TYPE(ipc3270Response, ipc3270Response, G_TYPE_OBJECT) | |
| 61 | - | |
| 62 | -/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 63 | - | |
| 64 | -static void ipc3270Response_finalize(GObject *object) { | |
| 65 | - | |
| 66 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 67 | - | |
| 68 | - debug("%s value=%p",__FUNCTION__,response->value); | |
| 69 | - | |
| 70 | - if(response->value) | |
| 71 | - g_variant_unref(response->value); | |
| 72 | - | |
| 73 | -} | |
| 74 | - | |
| 75 | - | |
| 76 | -static void ipc3270Response_class_init(ipc3270ResponseClass *klass) { | |
| 77 | - | |
| 78 | - debug("%s",__FUNCTION__); | |
| 79 | - | |
| 80 | - GObjectClass *object_class; | |
| 81 | - object_class = G_OBJECT_CLASS (klass); | |
| 82 | - object_class->finalize = ipc3270Response_finalize; | |
| 83 | - | |
| 84 | -} | |
| 85 | - | |
| 86 | -static void ipc3270Response_init(ipc3270Response *object) { | |
| 87 | - | |
| 88 | - object->value = NULL; | |
| 89 | - | |
| 90 | -} | |
| 91 | - | |
| 92 | -GObject * ipc3270_response_new() { | |
| 93 | - return g_object_new(GLIB_TYPE_IPC3270_RESPONSE, NULL); | |
| 94 | -} | |
| 95 | - | |
| 96 | -void ipc3270_response_append_int32(GObject *object, gint32 value) { | |
| 97 | - | |
| 98 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 99 | - | |
| 100 | - if(response->value) | |
| 101 | - g_variant_unref(response->value); | |
| 102 | - | |
| 103 | - response->value = g_variant_new_int32(value); | |
| 104 | -} | |
| 105 | - | |
| 106 | -void ipc3270_response_append_uint32(GObject *object, guint32 value) { | |
| 107 | - | |
| 108 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 109 | - | |
| 110 | - if(response->value) | |
| 111 | - g_variant_unref(response->value); | |
| 112 | - | |
| 113 | - response->value = g_variant_new_uint32(value); | |
| 114 | -} | |
| 115 | - | |
| 116 | -void ipc3270_response_append_string(GObject *object, const gchar *text) { | |
| 117 | - | |
| 118 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 119 | - | |
| 120 | - if(response->value) | |
| 121 | - g_variant_unref(response->value); | |
| 122 | - | |
| 123 | - response->value = g_variant_new_string(text); | |
| 124 | - | |
| 125 | -} | |
| 126 | - | |
| 127 | -void ipc3270_response_append_boolean(GObject *object, gboolean value) { | |
| 128 | - | |
| 129 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 130 | - | |
| 131 | - if(response->value) | |
| 132 | - g_variant_unref(response->value); | |
| 133 | - | |
| 134 | - response->value = g_variant_new_boolean(value); | |
| 135 | -} | |
| 136 | - | |
| 137 | -GVariant * ipc3270_response_steal_value(GObject *object) { | |
| 138 | - | |
| 139 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 140 | - | |
| 141 | - GVariant * value = response->value; | |
| 142 | - response->value = NULL; | |
| 143 | - | |
| 144 | - return value; | |
| 145 | -} | |
| 146 | - | |
| 147 | -gboolean ipc3270_response_has_values(GObject *object) { | |
| 148 | - return IPC3270_RESPONSE(object)->value != NULL; | |
| 149 | -} |
server/src/core/linux/start.c
| ... | ... | @@ -67,8 +67,16 @@ static void |
| 67 | 67 | // It is an error if parameters is not of the right format: it must be a tuple containing the out-parameters of the D-Bus method. |
| 68 | 68 | // Even if the method has a single out-parameter, it must be contained in a tuple. |
| 69 | 69 | |
| 70 | - GVariant *values[] = { ipc3270_response_steal_value(response) }; | |
| 71 | - g_dbus_method_invocation_return_value(invocation, g_variant_new_tuple(values,1)); | |
| 70 | + guint ix; | |
| 71 | + guint length = ipc3270_response_length(response); | |
| 72 | + | |
| 73 | + g_autofree GVariant ** values = g_new0(GVariant *, length); | |
| 74 | + | |
| 75 | + for(ix = 0; ix < length; ix++) { | |
| 76 | + values[ix] = ipc3270_response_steal_value(response); | |
| 77 | + } | |
| 78 | + | |
| 79 | + g_dbus_method_invocation_return_value(invocation, g_variant_new_tuple(values,length)); | |
| 72 | 80 | |
| 73 | 81 | } else { |
| 74 | 82 | ... | ... |
server/src/core/methods/cursor.c
| ... | ... | @@ -66,3 +66,22 @@ int ipc3270_method_set_cursor(GObject *session, GVariant *request, GObject *resp |
| 66 | 66 | return 0; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | +int ipc3270_method_get_cursor_position(GObject *session, GVariant G_GNUC_UNUSED(*request), GObject *response, GError **error) { | |
| 70 | + | |
| 71 | + H3270 *hSession = ipc3270_get_session(session); | |
| 72 | + | |
| 73 | + if(*error) | |
| 74 | + return 0; | |
| 75 | + | |
| 76 | + unsigned short row, col; | |
| 77 | + | |
| 78 | + int rc = lib3270_get_cursor_position(hSession,&row,&col); | |
| 79 | + if(rc) | |
| 80 | + return rc; | |
| 81 | + | |
| 82 | + ipc3270_response_append_uint32(response, (guint32) row); | |
| 83 | + ipc3270_response_append_uint32(response, (guint32) col); | |
| 84 | + | |
| 85 | + return 0; | |
| 86 | +} | |
| 87 | + | ... | ... |
server/src/core/methods/methods.c
| ... | ... | @@ -71,6 +71,7 @@ int ipc3270_method_call(GObject *object, const gchar *method_name, GVariant *req |
| 71 | 71 | |
| 72 | 72 | { "setCursorAddress", ipc3270_method_set_cursor }, |
| 73 | 73 | { "setCursorPosition", ipc3270_method_set_cursor }, |
| 74 | + { "getCursorPosition", ipc3270_method_get_cursor_position }, | |
| 74 | 75 | |
| 75 | 76 | { "action", ipc3270_method_action }, |
| 76 | 77 | { "activatable", ipc3270_method_activatable }, | ... | ... |
server/src/core/methods/private.h
| ... | ... | @@ -57,6 +57,7 @@ |
| 57 | 57 | G_GNUC_INTERNAL int ipc3270_method_wait_for_keyboard_unlock(GObject *session, GVariant *request, GObject *response, GError **error); |
| 58 | 58 | |
| 59 | 59 | G_GNUC_INTERNAL int ipc3270_method_set_cursor(GObject *session, GVariant *request, GObject *response, GError **error); |
| 60 | + G_GNUC_INTERNAL int ipc3270_method_get_cursor_position(GObject *session, GVariant *request, GObject *response, GError **error); | |
| 60 | 61 | |
| 61 | 62 | G_GNUC_INTERNAL int ipc3270_method_action(GObject *session, GVariant *request, GObject *response, GError **error); |
| 62 | 63 | G_GNUC_INTERNAL int ipc3270_method_activatable(GObject *session, GVariant *request, GObject *response, GError **error); | ... | ... |
| ... | ... | @@ -0,0 +1,139 @@ |
| 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 | + * Referências: | |
| 24 | + * | |
| 25 | + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
| 26 | + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
| 27 | + * | |
| 28 | + * Contatos: | |
| 29 | + * | |
| 30 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 31 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 32 | + * | |
| 33 | + */ | |
| 34 | + | |
| 35 | +#include <internals.h> | |
| 36 | + | |
| 37 | +#include <glib.h> | |
| 38 | +#include <gio/gio.h> | |
| 39 | + | |
| 40 | +#include <ipc-glib.h> | |
| 41 | +#include <lib3270.h> | |
| 42 | + | |
| 43 | +#include <lib3270/actions.h> | |
| 44 | +#include <lib3270/properties.h> | |
| 45 | +#include <lib3270/toggle.h> | |
| 46 | +#include <v3270.h> | |
| 47 | + | |
| 48 | +#include <dbus/dbus-glib.h> | |
| 49 | +#include <dbus/dbus-glib-bindings.h> | |
| 50 | + | |
| 51 | +/*--[ Widget definition ]----------------------------------------------------------------------------*/ | |
| 52 | + | |
| 53 | +struct _ipc3270Response { | |
| 54 | + GObject parent; | |
| 55 | + GList * values; | |
| 56 | +}; | |
| 57 | + | |
| 58 | +struct _ipc3270ResponseClass { | |
| 59 | + | |
| 60 | + GObjectClass parent; | |
| 61 | + int dummy; | |
| 62 | + | |
| 63 | +}; | |
| 64 | + | |
| 65 | + | |
| 66 | +G_DEFINE_TYPE(ipc3270Response, ipc3270Response, G_TYPE_OBJECT) | |
| 67 | + | |
| 68 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 69 | + | |
| 70 | +static void ipc3270Response_finalize(GObject *object) { | |
| 71 | + | |
| 72 | + ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 73 | + | |
| 74 | + if(response->values) | |
| 75 | + g_list_free_full(response->values,(GDestroyNotify) g_variant_unref); | |
| 76 | + | |
| 77 | +} | |
| 78 | + | |
| 79 | + | |
| 80 | +static void ipc3270Response_class_init(ipc3270ResponseClass *klass) { | |
| 81 | + | |
| 82 | + debug("%s",__FUNCTION__); | |
| 83 | + | |
| 84 | + GObjectClass *object_class; | |
| 85 | + object_class = G_OBJECT_CLASS (klass); | |
| 86 | + object_class->finalize = ipc3270Response_finalize; | |
| 87 | + | |
| 88 | +} | |
| 89 | + | |
| 90 | +static void ipc3270Response_init(ipc3270Response *object) { | |
| 91 | + | |
| 92 | + object->values = NULL; | |
| 93 | + | |
| 94 | +} | |
| 95 | + | |
| 96 | +GObject * ipc3270_response_new() { | |
| 97 | + return g_object_new(GLIB_TYPE_IPC3270_RESPONSE, NULL); | |
| 98 | +} | |
| 99 | + | |
| 100 | +void ipc3270_response_append(GObject *object, GVariant *value) { | |
| 101 | + ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 102 | + response->values = g_list_append(response->values,value); | |
| 103 | +} | |
| 104 | + | |
| 105 | +void ipc3270_response_append_int32(GObject *object, gint32 value) { | |
| 106 | + ipc3270_response_append(object,g_variant_new_int32(value)); | |
| 107 | +} | |
| 108 | + | |
| 109 | +void ipc3270_response_append_uint32(GObject *object, guint32 value) { | |
| 110 | + ipc3270_response_append(object,g_variant_new_uint32(value)); | |
| 111 | +} | |
| 112 | + | |
| 113 | +void ipc3270_response_append_string(GObject *object, const gchar *text) { | |
| 114 | + ipc3270_response_append(object,g_variant_new_string(text)); | |
| 115 | +} | |
| 116 | + | |
| 117 | +void ipc3270_response_append_boolean(GObject *object, gboolean value) { | |
| 118 | + ipc3270_response_append(object,g_variant_new_boolean(value)); | |
| 119 | +} | |
| 120 | + | |
| 121 | +GVariant * ipc3270_response_steal_value(GObject *object) { | |
| 122 | + | |
| 123 | + ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 124 | + | |
| 125 | + GList *first = g_list_first(response->values); | |
| 126 | + GVariant * value = first->data; | |
| 127 | + | |
| 128 | + response->values = g_list_remove(response->values,value); | |
| 129 | + | |
| 130 | + return value; | |
| 131 | +} | |
| 132 | + | |
| 133 | +guint ipc3270_response_length(GObject *object) { | |
| 134 | + return g_list_length(IPC3270_RESPONSE(object)->values); | |
| 135 | +} | |
| 136 | + | |
| 137 | +gboolean ipc3270_response_has_values(GObject *object) { | |
| 138 | + return IPC3270_RESPONSE(object)->values != NULL; | |
| 139 | +} | ... | ... |
server/src/core/windows/response.c
| ... | ... | @@ -1,150 +0,0 @@ |
| 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 | - * Referências: | |
| 24 | - * | |
| 25 | - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
| 26 | - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
| 27 | - * | |
| 28 | - * Contatos: | |
| 29 | - * | |
| 30 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 31 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 32 | - * | |
| 33 | - */ | |
| 34 | - | |
| 35 | -#include "gobject.h" | |
| 36 | -#include <lib3270.h> | |
| 37 | -#include <lib3270/actions.h> | |
| 38 | -#include <lib3270/properties.h> | |
| 39 | -#include <lib3270/toggle.h> | |
| 40 | -#include <lib3270/log.h> | |
| 41 | -#include <v3270.h> | |
| 42 | - | |
| 43 | -/*--[ Widget definition ]----------------------------------------------------------------------------*/ | |
| 44 | - | |
| 45 | -struct _ipc3270Response { | |
| 46 | - GObject parent; | |
| 47 | - GVariant * value; | |
| 48 | -}; | |
| 49 | - | |
| 50 | -struct _ipc3270ResponseClass { | |
| 51 | - | |
| 52 | - GObjectClass parent; | |
| 53 | - int dummy; | |
| 54 | - | |
| 55 | -}; | |
| 56 | - | |
| 57 | - | |
| 58 | -G_DEFINE_TYPE(ipc3270Response, ipc3270Response, G_TYPE_OBJECT) | |
| 59 | - | |
| 60 | -/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 61 | - | |
| 62 | -static void ipc3270Response_finalize(GObject *object) { | |
| 63 | - | |
| 64 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 65 | - | |
| 66 | - debug("%s value=%p",__FUNCTION__,response->value); | |
| 67 | - | |
| 68 | - if(response->value) | |
| 69 | - g_variant_unref(response->value); | |
| 70 | - | |
| 71 | -} | |
| 72 | - | |
| 73 | - | |
| 74 | -static void ipc3270Response_class_init(ipc3270ResponseClass *klass) { | |
| 75 | - | |
| 76 | - debug("%s",__FUNCTION__); | |
| 77 | - | |
| 78 | - GObjectClass *object_class; | |
| 79 | - object_class = G_OBJECT_CLASS (klass); | |
| 80 | - object_class->finalize = ipc3270Response_finalize; | |
| 81 | - | |
| 82 | -} | |
| 83 | - | |
| 84 | -static void ipc3270Response_init(ipc3270Response *object) { | |
| 85 | - | |
| 86 | - object->value = NULL; | |
| 87 | - | |
| 88 | -} | |
| 89 | - | |
| 90 | -GObject * ipc3270_response_new() { | |
| 91 | - return g_object_new(GLIB_TYPE_IPC3270_RESPONSE, NULL); | |
| 92 | -} | |
| 93 | - | |
| 94 | -void ipc3270_response_append_int32(GObject *object, gint32 value) { | |
| 95 | - | |
| 96 | - debug("%s(%d)",__FUNCTION__,value); | |
| 97 | - | |
| 98 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 99 | - | |
| 100 | - if(response->value) | |
| 101 | - g_variant_unref(response->value); | |
| 102 | - | |
| 103 | - response->value = g_variant_new_int32(value); | |
| 104 | -} | |
| 105 | - | |
| 106 | -void ipc3270_response_append_uint32(GObject *object, guint32 value) { | |
| 107 | - | |
| 108 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 109 | - | |
| 110 | - if(response->value) | |
| 111 | - g_variant_unref(response->value); | |
| 112 | - | |
| 113 | - response->value = g_variant_new_uint32(value); | |
| 114 | -} | |
| 115 | - | |
| 116 | -void ipc3270_response_append_string(GObject *object, const gchar *text) { | |
| 117 | - | |
| 118 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 119 | - | |
| 120 | - if(response->value) | |
| 121 | - g_variant_unref(response->value); | |
| 122 | - | |
| 123 | - response->value = g_variant_new_string(text); | |
| 124 | - | |
| 125 | -} | |
| 126 | - | |
| 127 | -void ipc3270_response_append_boolean(GObject *object, gboolean value) { | |
| 128 | - | |
| 129 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 130 | - | |
| 131 | - if(response->value) | |
| 132 | - g_variant_unref(response->value); | |
| 133 | - | |
| 134 | - response->value = g_variant_new_boolean(value); | |
| 135 | -} | |
| 136 | - | |
| 137 | - | |
| 138 | -GVariant * ipc3270_response_steal_value(GObject *object) { | |
| 139 | - | |
| 140 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 141 | - | |
| 142 | - GVariant * value = response->value; | |
| 143 | - response->value = NULL; | |
| 144 | - | |
| 145 | - return value; | |
| 146 | -} | |
| 147 | - | |
| 148 | -gboolean ipc3270_response_has_values(GObject *object) { | |
| 149 | - return IPC3270_RESPONSE(object)->value != NULL; | |
| 150 | -} |
server/src/include/ipc-glib.h
| ... | ... | @@ -113,6 +113,8 @@ |
| 113 | 113 | void ipc3270_response_append_boolean(GObject *object, gboolean value); |
| 114 | 114 | |
| 115 | 115 | gboolean ipc3270_response_has_values(GObject *object); |
| 116 | + guint ipc3270_response_length(GObject *object); | |
| 117 | + | |
| 116 | 118 | GVariant * ipc3270_response_steal_value(GObject *object); |
| 117 | 119 | |
| 118 | 120 | ... | ... |
server/src/testprogram/testprogram.c
| ... | ... | @@ -43,6 +43,7 @@ |
| 43 | 43 | #include <glib.h> |
| 44 | 44 | #include <glib/gstdio.h> |
| 45 | 45 | #include <lib3270/toggle.h> |
| 46 | + #include <lib3270/ssl.h> | |
| 46 | 47 | |
| 47 | 48 | /*---[ Globals ]------------------------------------------------------------------------------------*/ |
| 48 | 49 | |
| ... | ... | @@ -106,6 +107,9 @@ |
| 106 | 107 | GtkWidget * notebook = gtk_notebook_new(); |
| 107 | 108 | GModule * module = NULL; |
| 108 | 109 | |
| 110 | + // Hack to speed up the tests. | |
| 111 | + lib3270_ssl_set_crl_download(v3270_get_session(terminal),0); | |
| 112 | + | |
| 109 | 113 | gtk_widget_set_name(window,session_name); |
| 110 | 114 | v3270_set_session_name(terminal,session_name); |
| 111 | 115 | ... | ... |
| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | +#!/bin/bash | |
| 2 | +# | |
| 3 | +# https://stackoverflow.com/questions/48648952/set-get-property-using-dbus-send | |
| 4 | +# | |
| 5 | + | |
| 6 | +. ./dbus.conf | |
| 7 | + | |
| 8 | +dbus-send \ | |
| 9 | + --session \ | |
| 10 | + --dest=${DBUS_DEST} \ | |
| 11 | + --print-reply \ | |
| 12 | + "${DBUS_PATH}" \ | |
| 13 | + "${DBUS_INTERFACE}.getCursorPosition" | |
| 14 | + | ... | ... |
server/testscripts/introspect.sh
| 1 | 1 | #!/bin/bash |
| 2 | 2 | |
| 3 | -PRODUCT_NAME=$(pkg-config --variable=product_name lib3270) | |
| 3 | +. ./dbus.conf | |
| 4 | 4 | |
| 5 | 5 | gdbus \ |
| 6 | 6 | introspect \ |
| 7 | 7 | --session \ |
| 8 | - --dest=br.com.bb.${PRODUCT_NAME}.a \ | |
| 9 | - --object-path=/br/com/bb/${PRODUCT_NAME}/a | |
| 8 | + --dest=${DBUS_DEST} \ | |
| 9 | + --object-path="${DBUS_PATH}" | |
| 10 | 10 | ... | ... |