Commit f7f74109511baa23c811f2ce0211ec324e9c3b41

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

Implementing IPC module.

src/linux/gobject.c 0 → 100644
... ... @@ -0,0 +1,170 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como main.c e possui - linhas de código.
  22 + *
  23 + * Referências:
  24 + *
  25 + * https://github.com/fbuihuu/samples-dbus/blob/master/dbus-server.c
  26 + *
  27 + * Contatos:
  28 + *
  29 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  30 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  31 + *
  32 + */
  33 +
  34 +#include "gobject.h"
  35 +
  36 +#include <dbus/dbus-glib.h>
  37 +#include <dbus/dbus-glib-bindings.h>
  38 +
  39 +G_DEFINE_TYPE(ipc3270, ipc3270, G_TYPE_OBJECT)
  40 +
  41 +static void ipc3270_finalize(GObject *object) {
  42 +
  43 +
  44 +
  45 + G_OBJECT_CLASS(ipc3270_parent_class)->finalize(object);
  46 +}
  47 +
  48 +
  49 +static void ipc3270_class_init(ipc3270Class *klass) {
  50 + GObjectClass *object_class;
  51 + object_class = G_OBJECT_CLASS (klass);
  52 + object_class->finalize = ipc3270_finalize;
  53 +}
  54 +
  55 +static void ipc3270_init(ipc3270 *object) {
  56 +
  57 + debug("%s",__FUNCTION__);
  58 +
  59 +}
  60 +
  61 + GObject * ipc3270_new(GtkWidget *window, GtkWidget *terminal) {
  62 +
  63 + debug("%s",__FUNCTION__);
  64 + ipc3270 * object = IPC3270(g_object_new(GLIB_TYPE_IPC3270, NULL));
  65 +
  66 + GError * error = NULL;
  67 + int id;
  68 +
  69 + object->connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
  70 +
  71 + if(error) {
  72 + GtkWidget *dialog = gtk_message_dialog_new(
  73 + GTK_WINDOW(window),
  74 + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
  75 + GTK_MESSAGE_ERROR,
  76 + GTK_BUTTONS_OK,
  77 + _( "Can't get D-Bus connection" ));
  78 +
  79 + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message);
  80 + g_error_free(error);
  81 +
  82 + gtk_dialog_run(GTK_DIALOG(dialog));
  83 + gtk_widget_destroy(dialog);
  84 +
  85 + return G_OBJECT(object);
  86 +
  87 + }
  88 +
  89 + g_dbus_connection_set_exit_on_close(object->connection,FALSE);
  90 +
  91 + for(id='a'; id < 'z' && !error && !object->proxy; id++) {
  92 +
  93 + gchar *name = g_strdup_printf("br.com.bb.%s.%c",gtk_widget_get_name(window),id);
  94 +
  95 + debug("Requesting \"%s\"",name);
  96 +
  97 + // https://dbus.freedesktop.org/doc/dbus-specification.html
  98 + GVariant * response =
  99 + g_dbus_connection_call_sync (
  100 + object->connection,
  101 + DBUS_SERVICE_DBUS,
  102 + DBUS_PATH_DBUS,
  103 + DBUS_INTERFACE_DBUS,
  104 + "RequestName",
  105 + g_variant_new ("(su)", name, DBUS_NAME_FLAG_DO_NOT_QUEUE),
  106 + NULL,
  107 + G_DBUS_CALL_FLAGS_NONE,
  108 + -1,
  109 + NULL,
  110 + &error
  111 + );
  112 +
  113 + if(error) {
  114 + g_message("Can't request \"%s\": %s",name,error->message);
  115 + g_error_free(error);
  116 + error = NULL;
  117 + }
  118 +
  119 + if(response) {
  120 +
  121 + guint32 reply = 0;
  122 + g_variant_get(response, "(u)", &reply);
  123 + g_variant_unref(response);
  124 +
  125 + if(reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
  126 +
  127 + object->proxy = g_dbus_proxy_new_sync(
  128 + object->connection,
  129 + G_DBUS_PROXY_FLAGS_NONE,
  130 + NULL, // GDBusInterfaceInfo
  131 + name, // name
  132 + "/br/com/bb/" PACKAGE_NAME "/terminal", // object path
  133 + "br.com.bb." PACKAGE_NAME ".terminal", // interface
  134 + NULL, // GCancellable
  135 + &error );
  136 +
  137 + gchar * widget_name = g_strdup_printf("%s:%c",gtk_widget_get_name(window),id);
  138 + v3270_set_session_name(terminal, widget_name);
  139 + g_free(widget_name);
  140 +
  141 + g_message("Got %s - %s", name, v3270_get_session_name(terminal));
  142 +
  143 + }
  144 +
  145 + }
  146 +
  147 + g_free(name);
  148 +
  149 + }
  150 +
  151 + if(!object->proxy) {
  152 +
  153 + GtkWidget *dialog = gtk_message_dialog_new(
  154 + GTK_WINDOW(window),
  155 + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
  156 + GTK_MESSAGE_ERROR,
  157 + GTK_BUTTONS_OK,
  158 + _( "Can't get DBUS object name" ));
  159 +
  160 + gtk_dialog_run(GTK_DIALOG(dialog));
  161 + gtk_widget_destroy(dialog);
  162 +
  163 + return G_OBJECT(object);
  164 + }
  165 +
  166 + // Got D-Bus name, register object.
  167 +
  168 + return G_OBJECT(object);
  169 +
  170 + }
... ...
src/linux/gobject.h 0 → 100644
... ... @@ -0,0 +1,60 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como - e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 + /**
  32 + * @brief Private definitions for pw3270 IPC linux plugin.
  33 + *
  34 + */
  35 +
  36 +#ifndef LINUX_PRIVATE_H_INCLUDED
  37 +
  38 + #define LINUX_PRIVATE_H_INCLUDED
  39 +
  40 + #include "../private.h"
  41 +
  42 + G_BEGIN_DECLS
  43 +
  44 + typedef struct _ipc3270 ipc3270;
  45 + typedef struct _ipc3270Class ipc3270Class;
  46 +
  47 + struct _ipc3270 {
  48 + GObject parent;
  49 + GDBusConnection * connection;
  50 + GDBusProxy * proxy;
  51 + };
  52 +
  53 + struct _ipc3270Class {
  54 + GObjectClass parent;
  55 + };
  56 +
  57 +
  58 + G_END_DECLS
  59 +
  60 +#endif // LINUX_PRIVATE_H_INCLUDED
... ...
src/linux/start.c
... ... @@ -1,178 +0,0 @@
1   -/*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob
5   - * o nome G3270.
6   - *
7   - * Copyright (C) <2008> <Banco do Brasil S.A.>
8   - *
9   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
10   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
11   - * Free Software Foundation.
12   - *
13   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
14   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
15   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
16   - * obter mais detalhes.
17   - *
18   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
19   - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
20   - * St, Fifth Floor, Boston, MA 02110-1301 USA
21   - *
22   - * Este programa está nomeado como testprogram.c e possui - linhas de código.
23   - *
24   - * Contatos:
25   - *
26   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
27   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
28   - *
29   - */
30   -
31   -
32   - /**
33   - * @brief Plugin startup/stop for linux.
34   - *
35   - */
36   -
37   - #include "../private.h"
38   -
39   - #ifndef _WIN32
40   -
41   - #include <dbus/dbus-glib.h>
42   - #include <dbus/dbus-glib-bindings.h>
43   -
44   - static void pw3270_dbus_cleanup(struct DBusSession * dBus) {
45   -
46   - if(dBus->proxy) {
47   - g_object_unref(dBus);
48   - }
49   -
50   - }
51   -
52   - int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal) {
53   -
54   - struct DBusSession * dBus = g_new0(struct DBusSession,1);
55   - GError * error = NULL;
56   - int id;
57   -
58   - g_object_set_data_full(G_OBJECT(terminal), "dbus-session-info", dBus, (GDestroyNotify) pw3270_dbus_cleanup);
59   -
60   - dBus->connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
61   -
62   - if(error) {
63   - GtkWidget *dialog = gtk_message_dialog_new(
64   - GTK_WINDOW(window),
65   - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
66   - GTK_MESSAGE_ERROR,
67   - GTK_BUTTONS_OK,
68   - _( "Can't get D-Bus connection" ));
69   -
70   - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message);
71   - g_error_free(error);
72   -
73   - gtk_dialog_run(GTK_DIALOG(dialog));
74   - gtk_widget_destroy(dialog);
75   -
76   - return -1;
77   - }
78   -
79   - g_dbus_connection_set_exit_on_close(dBus->connection,FALSE);
80   -
81   - /*
82   - dBus->proxy = g_dbus_proxy_new_sync(
83   - dBus->connection,
84   - G_DBUS_PROXY_FLAGS_NONE,
85   - NULL, // GDBusInterfaceInfo
86   - "br.com.bb." PACKAGE_NAME, // name
87   - "/br/com/bb/" PACKAGE_NAME "/terminal", // object path
88   - "br.com.bb." PACKAGE_NAME ".terminal", // interface
89   - NULL, // GCancellable
90   - &error );
91   -
92   - if(error) {
93   -
94   - GtkWidget *dialog = gtk_message_dialog_new(
95   - GTK_WINDOW(window),
96   - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
97   - GTK_MESSAGE_ERROR,
98   - GTK_BUTTONS_OK,
99   - _( "Can't get D-Bus proxy object" ));
100   -
101   - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message);
102   - g_error_free(error);
103   -
104   - gtk_dialog_run(GTK_DIALOG(dialog));
105   - gtk_widget_destroy(dialog);
106   -
107   - return -1;
108   - }
109   - */
110   -
111   - for(id='a'; id < 'z' && !error && !dBus->proxy; id++) {
112   -
113   - gchar *name = g_strdup_printf("br.com.bb.%s.%c",gtk_widget_get_name(window),id);
114   -
115   - debug("Requesting \"%s\"",name);
116   -
117   - // https://dbus.freedesktop.org/doc/dbus-specification.html
118   - GVariant * response =
119   - g_dbus_connection_call_sync (
120   - dBus->connection,
121   - DBUS_SERVICE_DBUS,
122   - DBUS_PATH_DBUS,
123   - DBUS_INTERFACE_DBUS,
124   - "RequestName",
125   - g_variant_new ("(su)", name, DBUS_NAME_FLAG_DO_NOT_QUEUE),
126   - NULL,
127   - G_DBUS_CALL_FLAGS_NONE,
128   - -1,
129   - NULL,
130   - &error
131   - );
132   -
133   - if(error) {
134   - g_message("Can't request \"%s\": %s",name,error->message);
135   - g_error_free(error);
136   - error = NULL;
137   - }
138   -
139   - if(response) {
140   -
141   - guint32 reply = 0;
142   - g_variant_get(response, "(u)", &reply);
143   - g_variant_unref(response);
144   -
145   - if(reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
146   -
147   - dBus->proxy = g_dbus_proxy_new_sync(
148   - dBus->connection,
149   - G_DBUS_PROXY_FLAGS_NONE,
150   - NULL, // GDBusInterfaceInfo
151   - name, // name
152   - "/br/com/bb/" PACKAGE_NAME "/terminal", // object path
153   - "br.com.bb." PACKAGE_NAME ".terminal", // interface
154   - NULL, // GCancellable
155   - &error );
156   -
157   - gchar * widget_name = g_strdup_printf("%s:%c",gtk_widget_get_name(window),id);
158   - v3270_set_session_name(terminal, widget_name);
159   - g_free(widget_name);
160   -
161   - g_message("Got %s - %s", name, v3270_get_session_name(terminal));
162   -
163   - }
164   -
165   - }
166   -
167   - g_free(name);
168   -
169   - }
170   -
171   -
172   - return 0;
173   -
174   - }
175   -
176   - #endif // !_WIN32
177   -
178   -
src/linux/start.c.1 0 → 100644
... ... @@ -0,0 +1,191 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como testprogram.c e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 +
  32 + /**
  33 + * @brief Plugin startup/stop for linux.
  34 + *
  35 + */
  36 +
  37 + #include "private.h"
  38 +
  39 + #include <dbus/dbus-glib.h>
  40 + #include <dbus/dbus-glib-bindings.h>
  41 +
  42 + static void pw3270_dbus_cleanup(struct DBusSession * dBus) {
  43 +
  44 + if(dBus->proxy) {
  45 + g_object_unref(dBus);
  46 + }
  47 +
  48 + }
  49 +
  50 + int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal) {
  51 +
  52 + struct DBusSession * dBus = g_new0(struct DBusSession,1);
  53 + GError * error = NULL;
  54 + int id;
  55 +
  56 + g_object_set_data_full(G_OBJECT(terminal), "dbus-session-info", dBus, (GDestroyNotify) pw3270_dbus_cleanup);
  57 +
  58 + dBus->connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
  59 +
  60 + if(error) {
  61 + GtkWidget *dialog = gtk_message_dialog_new(
  62 + GTK_WINDOW(window),
  63 + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
  64 + GTK_MESSAGE_ERROR,
  65 + GTK_BUTTONS_OK,
  66 + _( "Can't get D-Bus connection" ));
  67 +
  68 + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message);
  69 + g_error_free(error);
  70 +
  71 + gtk_dialog_run(GTK_DIALOG(dialog));
  72 + gtk_widget_destroy(dialog);
  73 +
  74 + return -1;
  75 + }
  76 +
  77 + g_dbus_connection_set_exit_on_close(dBus->connection,FALSE);
  78 +
  79 + /*
  80 + dBus->proxy = g_dbus_proxy_new_sync(
  81 + dBus->connection,
  82 + G_DBUS_PROXY_FLAGS_NONE,
  83 + NULL, // GDBusInterfaceInfo
  84 + "br.com.bb." PACKAGE_NAME, // name
  85 + "/br/com/bb/" PACKAGE_NAME "/terminal", // object path
  86 + "br.com.bb." PACKAGE_NAME ".terminal", // interface
  87 + NULL, // GCancellable
  88 + &error );
  89 +
  90 + if(error) {
  91 +
  92 + GtkWidget *dialog = gtk_message_dialog_new(
  93 + GTK_WINDOW(window),
  94 + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
  95 + GTK_MESSAGE_ERROR,
  96 + GTK_BUTTONS_OK,
  97 + _( "Can't get D-Bus proxy object" ));
  98 +
  99 + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message);
  100 + g_error_free(error);
  101 +
  102 + gtk_dialog_run(GTK_DIALOG(dialog));
  103 + gtk_widget_destroy(dialog);
  104 +
  105 + return -1;
  106 + }
  107 + */
  108 +
  109 + for(id='a'; id < 'z' && !error && !dBus->proxy; id++) {
  110 +
  111 + gchar *name = g_strdup_printf("br.com.bb.%s.%c",gtk_widget_get_name(window),id);
  112 +
  113 + debug("Requesting \"%s\"",name);
  114 +
  115 + // https://dbus.freedesktop.org/doc/dbus-specification.html
  116 + GVariant * response =
  117 + g_dbus_connection_call_sync (
  118 + dBus->connection,
  119 + DBUS_SERVICE_DBUS,
  120 + DBUS_PATH_DBUS,
  121 + DBUS_INTERFACE_DBUS,
  122 + "RequestName",
  123 + g_variant_new ("(su)", name, DBUS_NAME_FLAG_DO_NOT_QUEUE),
  124 + NULL,
  125 + G_DBUS_CALL_FLAGS_NONE,
  126 + -1,
  127 + NULL,
  128 + &error
  129 + );
  130 +
  131 + if(error) {
  132 + g_message("Can't request \"%s\": %s",name,error->message);
  133 + g_error_free(error);
  134 + error = NULL;
  135 + }
  136 +
  137 + if(response) {
  138 +
  139 + guint32 reply = 0;
  140 + g_variant_get(response, "(u)", &reply);
  141 + g_variant_unref(response);
  142 +
  143 + if(reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
  144 +
  145 + dBus->proxy = g_dbus_proxy_new_sync(
  146 + dBus->connection,
  147 + G_DBUS_PROXY_FLAGS_NONE,
  148 + NULL, // GDBusInterfaceInfo
  149 + name, // name
  150 + "/br/com/bb/" PACKAGE_NAME "/terminal", // object path
  151 + "br.com.bb." PACKAGE_NAME ".terminal", // interface
  152 + NULL, // GCancellable
  153 + &error );
  154 +
  155 + gchar * widget_name = g_strdup_printf("%s:%c",gtk_widget_get_name(window),id);
  156 + v3270_set_session_name(terminal, widget_name);
  157 + g_free(widget_name);
  158 +
  159 + g_message("Got %s - %s", name, v3270_get_session_name(terminal));
  160 +
  161 + }
  162 +
  163 + }
  164 +
  165 + g_free(name);
  166 +
  167 + }
  168 +
  169 + if(!dBus->proxy) {
  170 + GtkWidget *dialog = gtk_message_dialog_new(
  171 + GTK_WINDOW(window),
  172 + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
  173 + GTK_MESSAGE_ERROR,
  174 + GTK_BUTTONS_OK,
  175 + _( "Can't get DBUS object name" ));
  176 +
  177 + gtk_dialog_run(GTK_DIALOG(dialog));
  178 + gtk_widget_destroy(dialog);
  179 +
  180 + return -1;
  181 + }
  182 +
  183 + // Got D-Bus name, register object.
  184 +
  185 + return 0;
  186 +
  187 + }
  188 +
  189 + #endif // !_WIN32
  190 +
  191 +
... ...
src/private.h
... ... @@ -29,7 +29,7 @@
29 29 */
30 30  
31 31 /**
32   - * @brief Private definitions for pw3270 IPC plugin.
  32 + * @brief Common definitions for pw3270 IPC plugin.
33 33 *
34 34 */
35 35  
... ... @@ -39,6 +39,9 @@
39 39  
40 40 #define PACKAGE_NAME "pw3270"
41 41  
  42 + #define ENABLE_NLS
  43 + #define GETTEXT_PACKAGE PACKAGE_NAME
  44 +
42 45 #include <libintl.h>
43 46 #include <glib/gi18n.h>
44 47 #include <gtk/gtk.h>
... ... @@ -46,18 +49,22 @@
46 49  
47 50 #include <v3270.h>
48 51  
49   - #ifdef _WIN32
  52 + G_BEGIN_DECLS
50 53  
51   - #include <windows.h>
  54 + #define GLIB_TYPE_IPC3270 (ipc3270_get_type ())
  55 + #define IPC3270(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLIB_TYPE_IPC3270, ipc3270))
  56 + #define IPC3270_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLIB_TYPE_IPC3270, ipc3270Class))
  57 + #define IS_IPC3270(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLIB_TYPE_IPC3270))
  58 + #define IS_IPC3270_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLIB_TYPE_IPC3270))
  59 + #define IPC3270_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLIB_TYPE_IPC3270, ipc3270Class))
52 60  
53   - #else
  61 + typedef struct _ipc3270 ipc3270;
  62 + typedef struct _ipc3270Class ipc3270Class;
54 63  
55   - G_GNUC_INTERNAL struct DBusSession {
56   - GDBusConnection * connection;
57   - GDBusProxy * proxy;
58   - } dBus;
  64 + GObject * ipc3270_new(GtkWidget *window, GtkWidget *terminal);
  65 + GType ipc3270_get_type(void);
59 66  
60   - #endif // _WIN32
  67 + G_END_DECLS
61 68  
62 69 #ifdef DEBUG
63 70 #define debug( fmt, ... ) fprintf(stderr,"%s(%d) " fmt "\n", __FILE__, (int) __LINE__, __VA_ARGS__ ); fflush(stderr);
... ... @@ -65,7 +72,6 @@
65 72 #define debug(...) /* __VA_ARGS */
66 73 #endif
67 74  
68   -
69 75 int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal);
70 76 int pw3270_plugin_stop(GtkWidget *window, GtkWidget *terminal);
71 77  
... ...
src/start.c 0 → 100644
... ... @@ -0,0 +1,47 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como - e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 +
  32 + /**
  33 + * @brief Plugin startup/stop for linux.
  34 + *
  35 + */
  36 +
  37 + #include "private.h"
  38 +
  39 + int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal) {
  40 +
  41 + g_object_set_data_full(G_OBJECT(terminal), "ipc-object-info", ipc3270_new(window,terminal), g_object_unref);
  42 + return 0;
  43 +
  44 + }
  45 +
  46 +
  47 +
... ...