diff --git a/src/core/linux/gobject.c b/src/core/linux/gobject.c
index 28b949f..64408c0 100644
--- a/src/core/linux/gobject.c
+++ b/src/core/linux/gobject.c
@@ -143,6 +143,101 @@ static gboolean
}
+void ipc3270_add_terminal_introspection(GString *introspection) {
+
+ size_t ix;
+
+ g_string_append(introspection,
+ " "
+ " "
+ " " \
+ " "
+ " " \
+ " " \
+ " " \
+ " "
+ " " \
+ " " \
+ " " \
+ " "
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " "
+ );
+
+ // Constrói métodos usando a tabela de controle
+ const LIB3270_ACTION_ENTRY * actions = lib3270_get_action_table();
+ for(ix = 0; actions[ix].name; ix++)
+ {
+ g_string_append_printf(
+ introspection, \
+ " " \
+ " ", actions[ix].name
+ );
+ }
+
+ // Toggle properties
+ for(ix = 0; ix < (int) LIB3270_TOGGLE_COUNT; ix++) {
+ g_string_append_printf(introspection, " ", lib3270_get_toggle_name((LIB3270_TOGGLE) ix));
+ }
+
+ // Boolean properties
+ const LIB3270_INT_PROPERTY * bol_props = lib3270_get_boolean_properties_list();
+ for(ix = 0; bol_props[ix].name; ix++) {
+ debug("Boolean(%s)",bol_props[ix].name);
+ g_string_append_printf(introspection, " ",
+ bol_props[ix].name,
+ ((bol_props[ix].set == NULL) ? "read" : "readwrite")
+ );
+ }
+
+ // Integer properties
+ const LIB3270_INT_PROPERTY * int_props = lib3270_get_int_properties_list();
+ for(ix = 0; int_props[ix].name; ix++) {
+ g_string_append_printf(introspection, " ",
+ int_props[ix].name,
+ ((int_props[ix].set == NULL) ? "read" : "readwrite")
+ );
+ }
+
+ // String properties
+ const LIB3270_STRING_PROPERTY * str_props = lib3270_get_string_properties_list();
+ for(ix = 0; str_props[ix].name; ix++) {
+ g_string_append_printf(introspection, " ",
+ str_props[ix].name,
+ ((str_props[ix].set == NULL) ? "read" : "readwrite")
+ );
+ }
+
+}
void ipc3270_set_session(GObject *object, H3270 *hSession, const char *name, GError **error) {
@@ -209,103 +304,9 @@ void ipc3270_set_session(GObject *object, H3270 *hSession, const char *name, GEr
lib3270_set_session_id(ipc->hSession, id);
// Introspection data for the service we are exporting
- GString * introspection = g_string_new(
- "\n"
- " "
- " "
- " "
- " " \
- " "
- " " \
- " " \
- " " \
- " "
- " " \
- " " \
- " " \
- " "
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " " \
- " "
-
- );
-
- // Constrói métodos usando a tabela de controle
- const LIB3270_ACTION_ENTRY * actions = lib3270_get_action_table();
- for(ix = 0; actions[ix].name; ix++)
- {
- g_string_append_printf(
- introspection, \
- " " \
- " ", actions[ix].name
- );
- }
-
- // Toggle properties
- for(ix = 0; ix < (int) LIB3270_TOGGLE_COUNT; ix++) {
- g_string_append_printf(introspection, " ", lib3270_get_toggle_name((LIB3270_TOGGLE) ix));
- }
-
- // Boolean properties
- const LIB3270_INT_PROPERTY * bol_props = lib3270_get_boolean_properties_list();
- for(ix = 0; bol_props[ix].name; ix++) {
- debug("Boolean(%s)",bol_props[ix].name);
- g_string_append_printf(introspection, " ",
- bol_props[ix].name,
- ((bol_props[ix].set == NULL) ? "read" : "readwrite")
- );
- }
-
- // Integer properties
- const LIB3270_INT_PROPERTY * int_props = lib3270_get_int_properties_list();
- for(ix = 0; int_props[ix].name; ix++) {
- g_string_append_printf(introspection, " ",
- int_props[ix].name,
- ((int_props[ix].set == NULL) ? "read" : "readwrite")
- );
- }
-
- // String properties
- const LIB3270_STRING_PROPERTY * str_props = lib3270_get_string_properties_list();
- for(ix = 0; str_props[ix].name; ix++) {
- g_string_append_printf(introspection, " ",
- str_props[ix].name,
- ((str_props[ix].set == NULL) ? "read" : "readwrite")
- );
- }
-
- g_string_append(introspection,
- " "
- ""
- );
+ GString * introspection = g_string_new("");
+ ipc3270_add_terminal_introspection(introspection);
+ g_string_append(introspection,"");
gchar * introspection_xml = g_string_free(introspection,FALSE);
diff --git a/src/include/lib3270/ipc.h b/src/include/lib3270/ipc.h
index 21e829e..40f0c5f 100644
--- a/src/include/lib3270/ipc.h
+++ b/src/include/lib3270/ipc.h
@@ -60,6 +60,8 @@
gchar * ipc3270_convert_input_string(GObject *object, const gchar *string, GError **error);
GVariant * ipc3270_GVariant_from_input_string(GObject *object, char *string, GError **error);
+ void ipc3270_add_terminal_introspection(GString *string);
+
const gchar * ipc3270_get_display_charset(GObject *object);
H3270 * ipc3270_get_session(GObject *object);
diff --git a/src/service/getproperties.c b/src/service/getproperties.c
index d115dc6..d50f6a5 100644
--- a/src/service/getproperties.c
+++ b/src/service/getproperties.c
@@ -33,13 +33,21 @@
*/
#include
+#include "private.h"
#include
#include
#include
-GVariant * service_get_property(GObject *object, const gchar *property_name, GError **error) {
+GVariant * service_get_property(const gchar *property_name, GError **error) {
+
+ debug("%s(%s)",__FUNCTION__,property_name);
+
+ if(!g_ascii_strcasecmp(property_name,"version")) {
+ return g_variant_new_string(PACKAGE_VERSION);
+ } else if(!g_ascii_strcasecmp(property_name,"release")) {
+ return g_variant_new_string(G_STRINGIFY(PACKAGE_RELEASE));
+ }
- debug("%s",__FUNCTION__);
g_set_error (error,
G_IO_ERROR,
diff --git a/src/service/linux/start.c b/src/service/linux/start.c
index 965fbcd..46456a4 100644
--- a/src/service/linux/start.c
+++ b/src/service/linux/start.c
@@ -31,32 +31,101 @@
*
*/
+#include
+#include
#include "../private.h"
#define PW3270_SERVICE_DBUS_SERVICE_PATH "/br/com/bb/tn3270/service"
#define PW3270_SERVICE_DBUS_SERVICE "br.com.bb.tn3270.service"
#define PW3270_SERVICE_DBUS_SERVICE_INTERFACE "br.com.bb.tn3270.service"
-static const gchar introspection_xml[] =
- ""
- " "
- " "
- " "
- "";
-
static GDBusNodeInfo *introspection_data = NULL;
static guint owner_id = 0;
+static gchar * introspection_xml = NULL;
+
+static void
+ method_call (
+ G_GNUC_UNUSED GDBusConnection *connection,
+ G_GNUC_UNUSED const gchar *sender,
+ G_GNUC_UNUSED const gchar *object_path,
+ G_GNUC_UNUSED const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data) {
+
+ g_autoptr (GError) error = NULL;
+
+ debug("%s(%s)",__FUNCTION__,object_path);
+
+ GVariant * rc = service_method_call(method_name, parameters, &error);
+
+ if(error) {
+
+ if(rc) {
+ g_variant_unref(rc);
+ }
+
+ g_dbus_method_invocation_return_gerror(invocation, error);
+
+ } else if(rc) {
+
+ g_dbus_method_invocation_return_value(invocation, rc);
+
+ } else {
+
+ g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Invalid or unexpected method call");
+
+ }
+
+
+}
+
+static GVariant *
+ get_property (
+ G_GNUC_UNUSED GDBusConnection *connection,
+ G_GNUC_UNUSED const gchar *sender,
+ G_GNUC_UNUSED const gchar *object_path,
+ G_GNUC_UNUSED const gchar *interface_name,
+ const gchar *property_name,
+ GError **error,
+ gpointer user_data)
+{
+
+ debug("%s(%s)",__FUNCTION__,object_path);
+ return service_get_property(property_name, error);
+
+}
+
+static gboolean
+ set_property (
+ G_GNUC_UNUSED GDBusConnection *connection,
+ G_GNUC_UNUSED const gchar *sender,
+ G_GNUC_UNUSED const gchar *object_path,
+ G_GNUC_UNUSED const gchar *interface_name,
+ const gchar *property_name,
+ GVariant *value,
+ GError **error,
+ gpointer user_data)
+{
+
+ debug("%s(%s)",__FUNCTION__,object_path);
+ return service_set_property(property_name, value, error);
+
+}
+
static void on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) {
static const GDBusInterfaceVTable interface_vtable = {
- service_method_call,
- service_get_property,
- service_set_property
+ method_call,
+ get_property,
+ set_property
};
guint registration_id;
+ g_message("Registering object %s",PW3270_SERVICE_DBUS_SERVICE_PATH);
registration_id = g_dbus_connection_register_object (connection,
PW3270_SERVICE_DBUS_SERVICE_PATH,
@@ -82,6 +151,29 @@ static void on_name_lost (GDBusConnection *connection, const gchar *name, gpoint
void service_start(void) {
+ GString * introspection = g_string_new("\n");
+
+ g_string_append(introspection,
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ );
+
+ ipc3270_add_terminal_introspection(introspection);
+
+ g_string_append(introspection,"\n");
+
+ introspection_xml = g_string_free(introspection,FALSE);
+
+ debug("\n\n%s\n\n",introspection_xml);
+
introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
diff --git a/src/service/methods.c b/src/service/methods.c
index f0d8869..d3f4a18 100644
--- a/src/service/methods.c
+++ b/src/service/methods.c
@@ -33,12 +33,15 @@
*/
#include
+#include "private.h"
#include
#include
#include
#include
-GVariant * service_method_call(GObject *object, const gchar *method_name, GVariant *parameters, GError **error) {
+GVariant * service_method_call(const gchar *method_name, GVariant *parameters, GError **error) {
+
+ debug("%s(%s)",__FUNCTION__,method_name);
g_set_error (error,
G_IO_ERROR,
diff --git a/src/service/private.h b/src/service/private.h
index d55223b..0a6338f 100644
--- a/src/service/private.h
+++ b/src/service/private.h
@@ -50,34 +50,10 @@
typedef struct _sessionClass sessionClass;
G_GNUC_INTERNAL void service_start(void);
- G_GNUC_INTERNAL GVariant * service_method_call(GObject *object, const gchar *method_name, GVariant *parameters, GError **error);
- G_GNUC_INTERNAL GVariant * service_get_property(GObject *object, const gchar *property_name, GError **error);
- G_GNUC_INTERNAL gboolean service_set_property(GObject *object, const gchar *property_name, GVariant *value, GError **error);
+ G_GNUC_INTERNAL GVariant * service_method_call(const gchar *method_name, GVariant *parameters, GError **error);
+ G_GNUC_INTERNAL GVariant * service_get_property(const gchar *property_name, GError **error);
+ G_GNUC_INTERNAL gboolean service_set_property(const gchar *property_name, GVariant *value, GError **error);
G_END_DECLS
-
- /*
- struct session {
- unsigned int id; ///< @brief Identificador da sessão.
- time_t activity; ///< @brief Timestamp da última atividade dessa sessão.
- time_t timeout; ///< @brief Após quantos segundos eu encerro a sessao?
- time_t maxidle; ///< @brief Tempo máximo que a sessão pode ficar IDLE
- time_t autoclose; ///< @brief Destroi a sessão quantos segundos após a desconexão?
- H3270 * host; ///< @brief Sessão TN3270.
- };
- */
-
- G_GNUC_INTERNAL GMainLoop * main_loop;
-
- /*
- G_GNUC_INTERNAL void init_3270(void);
- G_GNUC_INTERNAL void register_3270_io_handlers(void);
-
- G_GNUC_INTERNAL struct session * session_new();
- G_GNUC_INTERNAL struct session * session_find(const gchar *key);
- G_GNUC_INTERNAL void session_destroy(struct session *ses);
- G_GNUC_INTERNAL void session_check_for_timeout(void);
- */
-
#endif // PRIVATE_H_INCLUDED
diff --git a/src/service/setproperties.c b/src/service/setproperties.c
index ca208e7..cf8eb55 100644
--- a/src/service/setproperties.c
+++ b/src/service/setproperties.c
@@ -33,21 +33,20 @@
*/
#include
+#include "private.h"
#include
#include
#include
-gboolean service_set_property(GObject *object, const gchar *property_name, GVariant *value, GError **error) {
+gboolean service_set_property(const gchar *property_name, GVariant *value, GError **error) {
- debug("%s",__FUNCTION__);
+ debug("%s(%s)",__FUNCTION__,property_name);
- /*
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_NOT_FOUND,
"Can't find any property named %s", property_name
);
- */
return FALSE;
}
--
libgit2 0.21.2