Commit 87b4a51aa24ecae42f3608730b8f850c2c614a3d
1 parent
ebebd49f
Exists in
master
and in
1 other branch
Refactoring D-Bus IPC module.
Showing
2 changed files
with
22 additions
and
14 deletions
Show diff stats
src/plugin/linux/main.c
| @@ -36,6 +36,7 @@ | @@ -36,6 +36,7 @@ | ||
| 36 | #include <dbus/dbus-glib-lowlevel.h> | 36 | #include <dbus/dbus-glib-lowlevel.h> |
| 37 | #include <dbus/dbus-glib.h> | 37 | #include <dbus/dbus-glib.h> |
| 38 | 38 | ||
| 39 | +#include <v3270.h> | ||
| 39 | #include <pw3270.h> | 40 | #include <pw3270.h> |
| 40 | #include <pw3270/plugin.h> | 41 | #include <pw3270/plugin.h> |
| 41 | 42 | ||
| @@ -53,12 +54,13 @@ | @@ -53,12 +54,13 @@ | ||
| 53 | 54 | ||
| 54 | /*---[ Implement ]-------------------------------------------------------------------------------*/ | 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 | connection = dbus_g_bus_get_private(DBUS_BUS_SESSION, g_main_context_default(), &error); | 65 | connection = dbus_g_bus_get_private(DBUS_BUS_SESSION, g_main_context_default(), &error); |
| 64 | if(error) | 66 | if(error) |
| @@ -88,7 +90,7 @@ | @@ -88,7 +90,7 @@ | ||
| 88 | { | 90 | { |
| 89 | gboolean has_owner = FALSE; | 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 | org_freedesktop_DBus_name_has_owner(proxy, service_name, &has_owner, NULL); | 95 | org_freedesktop_DBus_name_has_owner(proxy, service_name, &has_owner, NULL); |
| 94 | 96 | ||
| @@ -129,16 +131,16 @@ | @@ -129,16 +131,16 @@ | ||
| 129 | 131 | ||
| 130 | if(session_id) | 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 | pw3270_dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,path); | 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 | return 0; | 146 | return 0; |
| @@ -146,10 +148,15 @@ | @@ -146,10 +148,15 @@ | ||
| 146 | 148 | ||
| 147 | LIB3270_EXPORT int pw3270_plugin_stop(GtkWidget G_GNUC_UNUSED(*window), GtkWidget G_GNUC_UNUSED(*terminal)) | 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 | g_free(service_name); | 160 | g_free(service_name); |
| 154 | service_name = NULL; | 161 | service_name = NULL; |
| 155 | } | 162 | } |
src/testprogram/testprogram.c
| @@ -40,6 +40,7 @@ | @@ -40,6 +40,7 @@ | ||
| 40 | #include <pw3270/plugin.h> | 40 | #include <pw3270/plugin.h> |
| 41 | #include <string.h> | 41 | #include <string.h> |
| 42 | #include <stdlib.h> | 42 | #include <stdlib.h> |
| 43 | + #include <pw3270.h> | ||
| 43 | 44 | ||
| 44 | /*---[ Globals ]------------------------------------------------------------------------------------*/ | 45 | /*---[ Globals ]------------------------------------------------------------------------------------*/ |
| 45 | 46 |