diff --git a/pw3270-plugin-ipc.cbp b/pw3270-plugin-ipc.cbp
index 9cc1228..deabc18 100644
--- a/pw3270-plugin-ipc.cbp
+++ b/pw3270-plugin-ipc.cbp
@@ -8,7 +8,7 @@
-
+
@@ -40,10 +40,19 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/linux/getproperties.c b/src/linux/getproperties.c
new file mode 100644
index 0000000..943c27c
--- /dev/null
+++ b/src/linux/getproperties.c
@@ -0,0 +1,69 @@
+/*
+ * "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 main.c e possui - linhas de código.
+ *
+ * Referências:
+ *
+ * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c
+ * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
+ *
+ */
+
+#include "gobject.h"
+#include
+
+#include
+#include
+
+GVariant *
+ipc3270_get_property (GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *property_name,
+ GError **error,
+ gpointer user_data)
+{
+ LIB3270_TOGGLE toggle = lib3270_get_toggle_id(property_name);
+
+ debug("%s: toggle(%s)=%d", __FUNCTION__, property_name,(int) toggle);
+ if(toggle != (LIB3270_TOGGLE) -1) {
+
+ // Is a Tn3270 toggle, get it!
+ return g_variant_new_int16((gint16) lib3270_get_toggle(IPC3270(user_data)->hSession,toggle));
+
+ }
+
+
+ g_set_error (error,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_FOUND,
+ "Can't find any property named %s", property_name
+ );
+
+ return NULL;
+}
+
diff --git a/src/linux/gobject.c b/src/linux/gobject.c
index cd80f08..1701de1 100644
--- a/src/linux/gobject.c
+++ b/src/linux/gobject.c
@@ -38,16 +38,6 @@
#include
#include
-/* Introspection data for the service we are exporting */
-static const gchar introspection_xml[] =
- ""
- " "
- " "
- " "
- " "
- " "
- "";
-
G_DEFINE_TYPE(ipc3270, ipc3270, G_TYPE_OBJECT)
static void ipc3270_finalize(GObject *object) {
@@ -79,67 +69,6 @@ static void ipc3270_init(ipc3270 *object) {
}
-void
-ipc3270_method_call (GDBusConnection *connection,
- const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
-
-
- g_dbus_method_invocation_return_error (
- invocation,
- G_DBUS_ERROR,
- G_DBUS_ERROR_UNKNOWN_METHOD,
- "Invalid or unexpected method call");
-
-}
-
-GVariant *
-ipc3270_get_property (GDBusConnection *connection,
- const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *property_name,
- GError **error,
- gpointer user_data)
-{
- GVariant *ret = NULL;
-
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_NOT_FOUND,
- "There's no %s propriety", property_name
- );
-
- return ret;
-}
-
-gboolean
-ipc3270_set_property (GDBusConnection *connection,
- const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *property_name,
- GVariant *value,
- GError **error,
- gpointer user_data)
-{
-
-
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_NOT_FOUND,
- "There's no %s propriety", property_name
- );
-
- return *error == NULL;
-}
-
GObject * ipc3270_new(GtkWidget *window, GtkWidget *terminal) {
static const GDBusInterfaceVTable interface_vtable = {
@@ -151,9 +80,10 @@ GObject * ipc3270_new(GtkWidget *window, GtkWidget *terminal) {
ipc3270 * object = IPC3270(g_object_new(GLIB_TYPE_IPC3270, NULL));
GError * error = NULL;
- int id;
+ int id, ix;
- object->connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
+ object->hSession = v3270_get_session(terminal);
+ object->connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
if(error) {
GtkWidget *dialog = gtk_message_dialog_new(
@@ -217,6 +147,27 @@ GObject * ipc3270_new(GtkWidget *window, GtkWidget *terminal) {
g_message("Got %s - %s", name, v3270_get_session_name(terminal));
+ // Introspection data for the service we are exporting
+ GString * introspection = g_string_new(
+ "\n"
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ );
+
+ for(ix = 0; ix < (int) LIB3270_TOGGLE_COUNT; ix++) {
+ g_string_append_printf(introspection, " ", lib3270_get_toggle_name((LIB3270_TOGGLE) ix));
+ }
+
+ g_string_append(introspection,
+ " "
+ ""
+ );
+
+ gchar * introspection_xml = g_string_free(introspection,FALSE);
GDBusNodeInfo * introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
// Register object-id
@@ -231,6 +182,7 @@ GObject * ipc3270_new(GtkWidget *window, GtkWidget *terminal) {
);
g_dbus_node_info_unref(introspection_data);
+ g_free(introspection_xml);
break;
}
diff --git a/src/linux/gobject.h b/src/linux/gobject.h
index df82fdb..786403d 100644
--- a/src/linux/gobject.h
+++ b/src/linux/gobject.h
@@ -46,6 +46,7 @@
#include
#include
+ #include
#include
G_BEGIN_DECLS
@@ -57,6 +58,7 @@
GObject parent;
GDBusConnection * connection;
guint id;
+ GtkWidget * hSession;
};
struct _ipc3270Class {
diff --git a/src/linux/methods.c b/src/linux/methods.c
new file mode 100644
index 0000000..0198d6a
--- /dev/null
+++ b/src/linux/methods.c
@@ -0,0 +1,59 @@
+/*
+ * "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 main.c e possui - linhas de código.
+ *
+ * Referências:
+ *
+ * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c
+ * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
+ *
+ */
+
+#include "gobject.h"
+#include
+
+#include
+#include
+
+void
+ipc3270_method_call (GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+
+
+ g_dbus_method_invocation_return_error (
+ invocation,
+ G_DBUS_ERROR,
+ G_DBUS_ERROR_UNKNOWN_METHOD,
+ "Invalid or unexpected method call");
+
+}
diff --git a/src/linux/setproperties.c b/src/linux/setproperties.c
new file mode 100644
index 0000000..e69bb50
--- /dev/null
+++ b/src/linux/setproperties.c
@@ -0,0 +1,59 @@
+/*
+ * "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 main.c e possui - linhas de código.
+ *
+ * Referências:
+ *
+ * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c
+ * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
+ *
+ */
+
+#include "gobject.h"
+#include
+
+#include
+#include
+
+gboolean
+ipc3270_set_property (GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *property_name,
+ GVariant *value,
+ GError **error,
+ gpointer user_data)
+{
+
+ g_set_error (error,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_FOUND,
+ "Can't find any property named %s", property_name
+ );
+
+ return *error == NULL;
+}
diff --git a/testscripts/getproperty.sh b/testscripts/getproperty.sh
new file mode 100755
index 0000000..43f2c3b
--- /dev/null
+++ b/testscripts/getproperty.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+#
+# https://stackoverflow.com/questions/48648952/set-get-property-using-dbus-send
+#
+
+dbus-send \
+ --session \
+ --dest=br.com.bb.pw3270.a\
+ --print-reply \
+ "/br/com/bb/tn3270" \
+ "org.freedesktop.DBus.Properties.Get" \
+ string:br.com.bb.tn3270 \
+ string:${1}
+
--
libgit2 0.21.2