diff --git a/Makefile.in b/Makefile.in
index 6e7d795..eaba94a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -28,10 +28,12 @@
MODULE_NAME=ipc3270
-SOURCES= \
+CORE_SOURCES= \
$(wildcard src/*.c) \
+ $(wildcard src/@OSNAME@/*.c)
+
+PLUGIN_SOURCES= \
$(wildcard src/plugin/*.c) \
- $(wildcard src/@OSNAME@/*.c) \
$(wildcard src/@OSNAME@/*.rc)
TEST_SOURCES= \
@@ -49,6 +51,7 @@ INSTALL_PROGRAM=@INSTALL_PROGRAM@
XGETTEXT=@XGETTEXT@
MSGCAT=@MSGCAT@
WINDRES=@WINDRES@
+AR=@AR@
#---[ Paths ]----------------------------------------------------------------------------
@@ -177,21 +180,40 @@ all: \
Release: \
$(BINRLS)/$(MODULE_NAME)@DLLEXT@
+$(BINRLS)/lib$(MODULE_NAME).a: \
+ $(foreach SRC, $(basename $(CORE_SOURCES)), $(OBJRLS)/$(SRC).o)
+
+ @$(MKDIR) `dirname $@`
+ @echo $< ...
+
+ @$(AR) rcs $@ $^
+
$(BINRLS)/$(MODULE_NAME)@DLLEXT@: \
- $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o)
+ $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) \
+ $(BINRLS)/lib$(MODULE_NAME).a
+
@$(MKDIR) `dirname $@`
@echo $< ...
@$(LD) \
-shared -Wl,-soname,$(@F) \
-o $@ \
- $(LDFLAGS) \
- $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) \
-L$(BINRLS) \
+ $(LDFLAGS) \
+ $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) \
+ -l$(MODULE_NAME) \
$(LIBS)
#---[ Install Targets ]------------------------------------------------------------------
+install-plugin: \
+ $(BINRLS)/$(MODULE_NAME)@DLLEXT@
+
+ @$(MKDIR) $(DESTDIR)$(libdir)/pw3270-plugins
+
+ @$(INSTALL_PROGRAM) \
+ $(BINRLS)/$(MODULE_NAME)@DLLEXT@ \
+ $(DESTDIR)$(libdir)/pw3270-plugins
#---[ Misc Targets ]---------------------------------------------------------------------
@@ -212,6 +234,15 @@ Debug: \
$(BINDBG)/@DLLPREFIX@$(MODULE_NAME)@DLLEXT@ \
$(BINDBG)/$(MODULE_NAME)@EXEEXT@
+$(BINDBG)/lib$(MODULE_NAME).a: \
+ $(foreach SRC, $(basename $(CORE_SOURCES)), $(OBJDBG)/$(SRC).o)
+
+ @$(MKDIR) `dirname $@`
+ @echo $< ...
+
+ @$(AR) rcs $@ $^
+
+
$(BINDBG)/$(MODULE_NAME)@EXEEXT@: \
$(foreach SRC, $(basename $(TEST_SOURCES)), $(OBJDBG)/$(SRC).o) \
$(BINDBG)/@DLLPREFIX@$(MODULE_NAME)@DLLEXT@
@@ -251,7 +282,8 @@ $(BINDBG)/@DLLPREFIX@$(MODULE_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@: \
$@
$(BINDBG)/@DLLPREFIX@$(MODULE_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \
- $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).o)
+ $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) \
+ $(BINDBG)/lib$(MODULE_NAME).a
@$(MKDIR) `dirname $@`
@echo $< ...
@@ -260,8 +292,9 @@ $(BINDBG)/@DLLPREFIX@$(MODULE_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MIN
-o $@ \
-L$(BINDBG) \
$(LDFLAGS) \
- $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).o) \
- $(LIBS)
+ $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) \
+ -l$(MODULE_NAME) \
+ $(LIBS)
#---[ Clean Targets ]--------------------------------------------------------------------
diff --git a/pw3270-plugin-ipc.cbp b/pw3270-plugin-ipc.cbp
index 024eaf9..fa37e42 100644
--- a/pw3270-plugin-ipc.cbp
+++ b/pw3270-plugin-ipc.cbp
@@ -41,6 +41,9 @@
+
+
+
diff --git a/src/convert.c b/src/convert.c
new file mode 100644
index 0000000..0369845
--- /dev/null
+++ b/src/convert.c
@@ -0,0 +1,43 @@
+/*
+ * "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
+#include
+#include
+
+gchar * ipc3270_convert_output_string(GObject *object, const gchar *string)
+{
+ return g_convert_with_fallback(string,-1,ipc3270_get_display_charset(object),"UTF-8","?",NULL,NULL,NULL);
+}
+
diff --git a/src/include/lib3270/ipc.h b/src/include/lib3270/ipc.h
index e1923bc..16509b1 100644
--- a/src/include/lib3270/ipc.h
+++ b/src/include/lib3270/ipc.h
@@ -55,6 +55,8 @@
GObject * ipc3270_new();
GType ipc3270_get_type(void);
void ipc3270_set_session(GObject *object, H3270 *hSession, const char *name, GError **error);
+ gchar * ipc3270_convert_output_string(GObject *object, const gchar *string);
+ const gchar * ipc3270_get_display_charset(GObject *object);
G_END_DECLS
diff --git a/src/linux/getproperties.c b/src/linux/getproperties.c
index 3c6da95..5caf492 100644
--- a/src/linux/getproperties.c
+++ b/src/linux/getproperties.c
@@ -40,13 +40,14 @@
#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)
+ipc3270_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)
{
size_t ix;
diff --git a/src/linux/gobject.c b/src/linux/gobject.c
index 0390378..3da09b8 100644
--- a/src/linux/gobject.c
+++ b/src/linux/gobject.c
@@ -72,7 +72,7 @@ static void ipc3270_init(ipc3270 *object) {
}
-GObject * ipc3270_new(GtkWidget *window, GtkWidget *terminal) {
+GObject * ipc3270_new() {
return g_object_new(GLIB_TYPE_IPC3270, NULL);
}
@@ -270,5 +270,8 @@ void ipc3270_set_session(GObject *object, H3270 *hSession, const char *name, GEr
}
+const gchar * ipc3270_get_display_charset(GObject *object) {
+ return lib3270_get_display_charset(IPC3270(object)->hSession);
+}
diff --git a/src/linux/methods.c b/src/linux/methods.c
index 3f8ef7e..800f85f 100644
--- a/src/linux/methods.c
+++ b/src/linux/methods.c
@@ -40,7 +40,7 @@
#include
/// @brief Converts lib3270 string to UTF-8 sets the method response.
-void g_dbus_method_invocation_return_tn3270_string(ipc3270 *obj, GDBusMethodInvocation *invocation, char *string) {
+static void g_dbus_method_invocation_return_tn3270_string(ipc3270 *obj, GDBusMethodInvocation *invocation, char *string) {
if(!string) {
g_autoptr (GError) error = NULL;
@@ -59,14 +59,15 @@ void g_dbus_method_invocation_return_tn3270_string(ipc3270 *obj, GDBusMethodInvo
}
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)
+ipc3270_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)
{
@@ -85,7 +86,8 @@ ipc3270_method_call (GDBusConnection *connection,
gchar *text = NULL;
g_variant_get(parameters, "(&s)", &text);
- if(lib3270_input_string(IPC3270(user_data)->hSession,(const unsigned char *) text) < 0)
+ g_autofree gchar * converted = ipc3270_convert_output_string(G_OBJECT(user_data), text);
+ if(lib3270_input_string(IPC3270(user_data)->hSession,(const unsigned char *) converted) < 0)
{
// Failed!
g_set_error(&error,IPC3270(user_data)->error_domain,errno,"%s: %s",method_name,strerror(errno));
@@ -105,7 +107,8 @@ ipc3270_method_call (GDBusConnection *connection,
gchar *text = NULL;
g_variant_get(parameters, "(ii&s)", &row, &col, &text);
- if(lib3270_set_string_at(IPC3270(user_data)->hSession,row,col,(const unsigned char *) text) < 0)
+ g_autofree gchar * converted = ipc3270_convert_output_string(G_OBJECT(user_data), text);
+ if(lib3270_set_string_at(IPC3270(user_data)->hSession,row,col,(const unsigned char *) converted) < 0)
{
// Failed!
g_set_error(&error,IPC3270(user_data)->error_domain,errno,"%s: %s",method_name,strerror(errno));
@@ -135,7 +138,8 @@ ipc3270_method_call (GDBusConnection *connection,
gchar *text = NULL;
g_variant_get(parameters, "(i&s)", &addr, &text);
- if(lib3270_set_string_at_address(IPC3270(user_data)->hSession,addr,(unsigned char *) text) < 0)
+ g_autofree gchar * converted = ipc3270_convert_output_string(G_OBJECT(user_data), text);
+ if(lib3270_set_string_at_address(IPC3270(user_data)->hSession,addr,(unsigned char *) converted) < 0)
{
// Failed!
g_set_error(&error,IPC3270(user_data)->error_domain,errno,"%s: %s",method_name,strerror(errno));
diff --git a/src/linux/setproperties.c b/src/linux/setproperties.c
index e0cf770..24cd48e 100644
--- a/src/linux/setproperties.c
+++ b/src/linux/setproperties.c
@@ -40,14 +40,15 @@
#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)
+ipc3270_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)
{
// Check for property
size_t ix;
diff --git a/testscripts/setstring.sh b/testscripts/setstring.sh
new file mode 100755
index 0000000..daa5fc5
--- /dev/null
+++ b/testscripts/setstring.sh
@@ -0,0 +1,13 @@
+#!/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" \
+ "br.com.bb.tn3270.setString"
+ string:${1}
+
--
libgit2 0.21.2