Commit 87b4a51aa24ecae42f3608730b8f850c2c614a3d

Authored by Perry Werneck
1 parent ebebd49f
Exists in master and in 1 other branch develop

Refactoring D-Bus IPC module.

src/plugin/linux/main.c
... ... @@ -36,6 +36,7 @@
36 36 #include <dbus/dbus-glib-lowlevel.h>
37 37 #include <dbus/dbus-glib.h>
38 38  
  39 +#include <v3270.h>
39 40 #include <pw3270.h>
40 41 #include <pw3270/plugin.h>
41 42  
... ... @@ -53,12 +54,13 @@
53 54  
54 55 /*---[ Implement ]-------------------------------------------------------------------------------*/
55 56  
56   - LIB3270_EXPORT int pw3270_plugin_start(GtkWidget *window, GtkWidget G_GNUC_UNUSED(*terminal))
  57 + LIB3270_EXPORT int pw3270_plugin_start(GtkWidget G_GNUC_UNUSED(*window), GtkWidget *terminal)
57 58 {
58   - GError * error = NULL;
59   - guint result;
60   - char session_id = 0;
61   - char id = 'a';
  59 + GError * error = NULL;
  60 + guint result;
  61 + char session_id = 0;
  62 + char id = 'a';
  63 + const gchar * name = "pw3270";
62 64  
63 65 connection = dbus_g_bus_get_private(DBUS_BUS_SESSION, g_main_context_default(), &error);
64 66 if(error)
... ... @@ -88,7 +90,7 @@
88 90 {
89 91 gboolean has_owner = FALSE;
90 92  
91   - service_name = g_strdup_printf("br.com.bb.%s.%c",pw3270_get_session_name(window),(int) id);
  93 + service_name = g_strdup_printf("br.com.bb.%s.%c",name,(int) id);
92 94  
93 95 org_freedesktop_DBus_name_has_owner(proxy, service_name, &has_owner, NULL);
94 96  
... ... @@ -129,16 +131,16 @@
129 131  
130 132 if(session_id)
131 133 {
132   - gchar * path = g_strdup_printf("/br/com/bb/%s",pw3270_get_session_name(window));
133   - gchar * session = g_strdup_printf("%s:%c",pw3270_get_session_name(window),g_ascii_toupper(session_id));
134   - pw3270_set_session_name(window,session);
135   - g_free(session);
  134 + g_autofree gchar * path = g_strdup_printf("/br/com/bb/%s",name);
  135 + g_autofree gchar * session = g_strdup_printf("%s:%c",name,g_ascii_toupper(session_id));
136 136  
137   - g_message("DBUS service path is %s",path);
  137 + // pw3270_set_session_name(window,session);
  138 + v3270_set_session_name(terminal,session);
  139 +
  140 + g_message("DBUS service path is %s, session name is %s",path,session);
138 141  
139 142 pw3270_dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,path);
140 143  
141   - g_free(path);
142 144 }
143 145  
144 146 return 0;
... ... @@ -146,10 +148,15 @@
146 148  
147 149 LIB3270_EXPORT int pw3270_plugin_stop(GtkWidget G_GNUC_UNUSED(*window), GtkWidget G_GNUC_UNUSED(*terminal))
148 150 {
149   - if(service_name)
  151 + if(proxy)
150 152 {
151   - // org_freedesktop_DBus_release_name
  153 + debug("%s: Releasing proxy",__FUNCTION__);
  154 + g_object_unref(proxy);
  155 + proxy = NULL;
  156 + }
152 157  
  158 + if(service_name)
  159 + {
153 160 g_free(service_name);
154 161 service_name = NULL;
155 162 }
... ...
src/testprogram/testprogram.c
... ... @@ -40,6 +40,7 @@
40 40 #include <pw3270/plugin.h>
41 41 #include <string.h>
42 42 #include <stdlib.h>
  43 + #include <pw3270.h>
43 44  
44 45 /*---[ Globals ]------------------------------------------------------------------------------------*/
45 46  
... ...