Commit 0186bf84a38c03bba9271b0705014da9f2efe867
1 parent
8cb4b528
Exists in
master
and in
5 other branches
Iniciando implementação de plugin DBUS
Showing
12 changed files
with
533 additions
and
3 deletions
Show diff stats
Makefile.in
... | ... | @@ -155,6 +155,8 @@ debian/lib3270-dev.install: Makefile |
155 | 155 | @echo "$(includedir)/lib3270.h" > $@ |
156 | 156 | @echo "$(includedir)/lib3270" >> $@ |
157 | 157 | @echo "$(datarootdir)/@PACKAGE_NAME@/ui/99debug.xml" >> $@ |
158 | + @echo "$(datarootdir)/@PACKAGE_NAME@/sample/*.c" >> $@ | |
159 | + @echo "$(datarootdir)/@PACKAGE_NAME@/sample/Makefile" >> $@ | |
158 | 160 | @echo "$(libdir)/pkgconfig/*.pc" >> $@ |
159 | 161 | @echo "$(includedir)/pw3270.h" >> $@ |
160 | 162 | @echo "$(includedir)/pw3270" >> $@ | ... | ... |
configure.ac
... | ... | @@ -66,6 +66,7 @@ AC_PATH_TOOL([VALGRIND], [valgrind], [no]) |
66 | 66 | |
67 | 67 | AC_PATH_TOOL([MAKENSIS], [makensis], [no]) |
68 | 68 | AC_PATH_TOOL([WINDRES], [windres], [no]) |
69 | +AC_PATH_TOOL([DBUSBINDINGTOOL],[dbus-binding-tool],[no]) | |
69 | 70 | |
70 | 71 | AC_CHECK_PROGS(GZIP,[gzip],no) |
71 | 72 | export GZIP; |
... | ... | @@ -328,10 +329,10 @@ AC_CHECK_HEADER(malloc.h, AC_DEFINE(HAVE_MALLOC_H,,[do we have malloc.h?])) |
328 | 329 | |
329 | 330 | AC_CHECK_FUNCS(getaddrinfo, AC_DEFINE(HAVE_GETADDRINFO) ) |
330 | 331 | |
331 | -#--[ GTK 2/3 check ]------------------------------------------------------------------------------------------------------------------------------------------ | |
332 | - | |
333 | 332 | PKG_CHECK_EXISTS |
334 | 333 | |
334 | +#--[ GTK 2/3 check ]------------------------------------------------------------------------------------------------------------------------------------------ | |
335 | + | |
335 | 336 | PKG_CHECK_MODULES( [GTK], [gtk+-3.0 gmodule-2.0], [ GTK_VERSION="3.0" ], [ PKG_CHECK_MODULES( [GTK], [gtk+-2.0 >= 2.14 gthread-2.0 gmodule-2.0], [ GTK_VERSION="2.0" ] ) ], [ ] ) |
336 | 337 | |
337 | 338 | AC_SUBST(GTK_LIBS) |
... | ... | @@ -339,6 +340,18 @@ AC_SUBST(GTK_CFLAGS) |
339 | 340 | AC_SUBST(GTK_VERSION) |
340 | 341 | AC_SUBST(GTK_MODVERSION,`pkg-config --modversion gtk+-$GTK_VERSION`) |
341 | 342 | |
343 | +#--[ GLIB check ]--------------------------------------------------------------------------------------------------------------------------------------------- | |
344 | + | |
345 | +PKG_CHECK_MODULES( [GLIB], [glib-2.0], AC_DEFINE(HAVE_GLIB) ) | |
346 | +AC_SUBST(GLIB_LIBS) | |
347 | +AC_SUBST(GLIB_CFLAGS) | |
348 | + | |
349 | +#--[ Check DBUS ]--------------------------------------------------------------------------------------------------------------------------------------------- | |
350 | + | |
351 | +PKG_CHECK_MODULES( [DBUS], [dbus-glib-1], AC_DEFINE(HAVE_DBUS) ) | |
352 | +AC_SUBST(DBUS_LIBS) | |
353 | +AC_SUBST(DBUS_CFLAGS) | |
354 | + | |
342 | 355 | #--[ SSL ]---------------------------------------------------------------------------------------------------------------------------------------------------- |
343 | 356 | |
344 | 357 | PKG_CHECK_MODULES( [LIBSSL], [libssl], AC_DEFINE(HAVE_LIBSSL), AC_MSG_NOTICE([libssl not present.]) ) |
... | ... | @@ -416,6 +429,7 @@ AC_CONFIG_FILES([ |
416 | 429 | src/tools/Makefile |
417 | 430 | src/plugins/remotectl/Makefile |
418 | 431 | src/plugins/rx3270/Makefile |
432 | + src/plugins/dbus/Makefile | |
419 | 433 | man/Makefile |
420 | 434 | makegtkruntime.sh |
421 | 435 | src/sample/Makefile | ... | ... |
pw3270.cbp
... | ... | @@ -220,6 +220,19 @@ |
220 | 220 | <Unit filename="src/lib3270/winversc.h" /> |
221 | 221 | <Unit filename="src/lib3270/xioc.h" /> |
222 | 222 | <Unit filename="src/lib3270/xl.h" /> |
223 | + <Unit filename="src/plugins/dbus/Makefile.in" /> | |
224 | + <Unit filename="src/plugins/dbus/daemon.c"> | |
225 | + <Option compilerVar="CC" /> | |
226 | + </Unit> | |
227 | + <Unit filename="src/plugins/dbus/gobject.c"> | |
228 | + <Option compilerVar="CC" /> | |
229 | + </Unit> | |
230 | + <Unit filename="src/plugins/dbus/main.c"> | |
231 | + <Option compilerVar="CC" /> | |
232 | + </Unit> | |
233 | + <Unit filename="src/plugins/dbus/pw3270dbus.xml" /> | |
234 | + <Unit filename="src/plugins/dbus/service.h" /> | |
235 | + <Unit filename="src/plugins/dbus/test.sh" /> | |
223 | 236 | <Unit filename="src/plugins/remotectl/Makefile.in" /> |
224 | 237 | <Unit filename="src/plugins/remotectl/hllapi.c"> |
225 | 238 | <Option compilerVar="CC" /> | ... | ... |
... | ... | @@ -0,0 +1,117 @@ |
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., 59 Temple | |
19 | +# Place, Suite 330, Boston, MA, 02111-1307, USA | |
20 | +# | |
21 | +# Contatos: | |
22 | +# | |
23 | +# perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
24 | +# erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) | |
25 | +# licinio@bb.com.br (Licínio Luis Branco) | |
26 | +# kraucer@bb.com.br (Kraucer Fernandes Mazuco) | |
27 | +# | |
28 | + | |
29 | +#---[ Sources ]---------------------------------------------------------------- | |
30 | + | |
31 | +MODULE_NAME=pw3270dbus | |
32 | +DEPENDS=Makefile dbus-glue.h | |
33 | +PLUGIN_SRC=main.c | |
34 | +DAEMON_SRC=daemon.c gobject.c | |
35 | + | |
36 | +#---[ Paths ]------------------------------------------------------------------ | |
37 | + | |
38 | +ROOTDIR ?= . | |
39 | +OBJDIR ?= $(ROOTDIR)/.obj | |
40 | +BINDIR ?= $(ROOTDIR)/.bin | |
41 | +BINDBG ?= $(BINDIR)/Debug | |
42 | +BINRLS ?= $(BINDIR)/Release | |
43 | + | |
44 | +OBJDBG = $(OBJDIR)/Debug | |
45 | +OBJRLS = $(OBJDIR)/Release | |
46 | +OBJEXT = o | |
47 | + | |
48 | +#---[ Tools ]------------------------------------------------------------------ | |
49 | + | |
50 | +MKDIR=@MKDIR_P@ | |
51 | +CC=@CC@ | |
52 | +LD=@CC@ | |
53 | +DBUSBINDINGTOOL=@DBUSBINDINGTOOL@ | |
54 | + | |
55 | +#---[ Flags ]------------------------------------------------------------------ | |
56 | + | |
57 | +DLL_FLAGS=-shared | |
58 | +DEBUG_CFLAGS=-DDEBUG=1 -g -Wall | |
59 | + | |
60 | +LIB3270_CFLAGS ?= `pkg-config --cflags lib3270` | |
61 | +DBUS_CFLAGS=@DBUS_CFLAGS@ | |
62 | +GLIB_CFLAGS=@GLIB_CFLAGS@ | |
63 | + | |
64 | +LIB3270_LIBS ?= `pkg-config --libs lib3270` | |
65 | +DBUS_LIBS=@DBUS_LIBS@ | |
66 | +GLIB_LIBS=@GLIB_LIBS@ | |
67 | + | |
68 | +#---[ Rules ]------------------------------------------------------------------ | |
69 | + | |
70 | +$(OBJDBG)/%.o: %.c $(DEPENDS) | |
71 | + @echo " CC `basename $@`" | |
72 | + @$(MKDIR) `dirname $@` | |
73 | + @$(CC) $(CFLAGS) $(DBUS_CFLAGS) $(GLIB_CFLAGS) $(DEBUG_CFLAGS) $(LIB3270_CFLAGS) -o $@ -c $< | |
74 | + | |
75 | +$(OBJRLS)/%.o: %.c $(DEPENDS) | |
76 | + @echo " CC `basename $@`" | |
77 | + @$(MKDIR) `dirname $@` | |
78 | + @$(CC) $(CFLAGS) $(DBUS_CFLAGS) $(GLIB_CFLAGS) $(LIB3270_CFLAGS) -o $@ -c $< | |
79 | + | |
80 | + | |
81 | +#---[ Release targets ]-------------------------------------------------------- | |
82 | + | |
83 | +Release: $(BINRLS)/plugins/$(MODULE_NAME).so | |
84 | + | |
85 | +$(BINRLS)/plugins/$(MODULE_NAME).so: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJRLS)/$(SRC).o) | |
86 | + @echo " CCLD `basename $@`" | |
87 | + @$(MKDIR) `dirname $@` | |
88 | + @$(LD) $(DLL_FLAGS) -Wl,-soname,`basename $@` $(LDFLAGS) -o $@ $^ $(LIBS) | |
89 | + | |
90 | +#---[ Debug targets ]---------------------------------------------------------- | |
91 | + | |
92 | +Debug: $(BINDBG)/plugins/$(MODULE_NAME).so $(BINDBG)/libhllapi.so | |
93 | + | |
94 | +$(BINDBG)/plugins/$(MODULE_NAME).so: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJDBG)/$(SRC).o) | |
95 | + @echo " CCLD `basename $@`" | |
96 | + @$(MKDIR) `dirname $@` | |
97 | + @$(LD) $(DLL_FLAGS) -Wl,-soname,`basename $@` $(LDFLAGS) -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(GLIB_LIBS) | |
98 | + | |
99 | +#---[ Misc targets ]----------------------------------------------------------- | |
100 | + | |
101 | +debug-service: $(BINDBG)/@PACKAGE_NAME@d | |
102 | + | |
103 | +dbus-glue.h: pw3270dbus.xml | |
104 | + @$(DBUSBINDINGTOOL) --mode=glib-server --output=$@ --prefix=pw3270_dbus $^ | |
105 | + | |
106 | +$(BINDBG)/@PACKAGE_NAME@d: $(foreach SRC, $(basename $(DAEMON_SRC)), $(OBJDBG)/$(SRC).o) | |
107 | + @echo " CCLD `basename $@`" | |
108 | + @$(MKDIR) `dirname $@` | |
109 | + @$(CC) $(CFLAGS) -o $@ $^ $(DBUS_LIBS) $(GLIB_LIBS) $(LIB3270_LIBS) | |
110 | + | |
111 | +cleandebug-service: clean | |
112 | + | |
113 | +clean: | |
114 | + @rm -fr $(OBJDIR) | |
115 | + @rm -fr $(BINDIR) | |
116 | + @rm -f dbus-glue.h | |
117 | + @find . -name "*~" -exec rm -f {} \; | ... | ... |
... | ... | @@ -0,0 +1,104 @@ |
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 daemon.c e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * licinio@bb.com.br (Licínio Luis Branco) | |
28 | + * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | |
29 | + * | |
30 | + * Referencias: | |
31 | + * | |
32 | + * https://live.gnome.org/DBusGlibBindings | |
33 | + * | |
34 | + */ | |
35 | + | |
36 | +#include <glib.h> | |
37 | +#include <dbus/dbus.h> | |
38 | +#include <dbus/dbus-glib-lowlevel.h> | |
39 | +#include <dbus/dbus-glib.h> | |
40 | + | |
41 | +#include "service.h" | |
42 | +#include "dbus-glue.h" | |
43 | + | |
44 | +/*---[ Globals ]---------------------------------------------------------------------------------*/ | |
45 | + | |
46 | + static DBusGConnection * connection = NULL; | |
47 | + static DBusGProxy * proxy = NULL; | |
48 | + | |
49 | +/*---[ Implement ]-------------------------------------------------------------------------------*/ | |
50 | + | |
51 | +static gpointer dbus_register_object (DBusGConnection *connection,DBusGProxy *proxy,GType object_type,const DBusGObjectInfo *info,const gchar *path) | |
52 | +{ | |
53 | + GObject *object = g_object_new (object_type, NULL); | |
54 | + dbus_g_object_type_install_info (object_type, info); | |
55 | + dbus_g_connection_register_g_object (connection, path, object); | |
56 | + return object; | |
57 | +} | |
58 | + | |
59 | +static int initialize(void) | |
60 | +{ | |
61 | + GError * error = NULL; | |
62 | + guint result; | |
63 | + | |
64 | + connection = dbus_g_bus_get_private(DBUS_BUS_SESSION, g_main_context_default(), &error); | |
65 | + if(error) | |
66 | + { | |
67 | + g_message("Error \"%s\" getting session dbus",error->message); | |
68 | + g_error_free(error); | |
69 | + return -1; | |
70 | + } | |
71 | + | |
72 | + proxy = dbus_g_proxy_new_for_name(connection,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS); | |
73 | + | |
74 | + org_freedesktop_DBus_request_name(proxy, PW3270_DBUS_SERVICE, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error); | |
75 | + | |
76 | + dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,PW3270_DBUS_SERVICE_PATH); | |
77 | + | |
78 | + return 0; | |
79 | +} | |
80 | + | |
81 | +int main(int numpar, char *param[]) | |
82 | +{ | |
83 | + GMainLoop *loop; | |
84 | + | |
85 | + g_type_init (); | |
86 | + | |
87 | + if (!g_thread_supported ()) | |
88 | + g_thread_init (NULL); | |
89 | + | |
90 | + dbus_g_thread_init (); | |
91 | + | |
92 | + loop = g_main_loop_new (NULL, FALSE); | |
93 | + | |
94 | + if(initialize()) | |
95 | + return -1; | |
96 | + | |
97 | + | |
98 | + g_main_loop_run(loop); | |
99 | + | |
100 | + return 0; | |
101 | +} | |
102 | + | |
103 | + | |
104 | + | ... | ... |
... | ... | @@ -0,0 +1,78 @@ |
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 gobject.c e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * licinio@bb.com.br (Licínio Luis Branco) | |
28 | + * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | |
29 | + * | |
30 | + * Referencias: | |
31 | + * | |
32 | + * https://live.gnome.org/DBusGlibBindings | |
33 | + * | |
34 | + */ | |
35 | + | |
36 | +#include <glib.h> | |
37 | +#include <dbus/dbus.h> | |
38 | +#include <dbus/dbus-glib-lowlevel.h> | |
39 | +#include <dbus/dbus-glib.h> | |
40 | + | |
41 | +#include <lib3270/config.h> | |
42 | + | |
43 | +#include "service.h" | |
44 | + | |
45 | +/*---[ Globals ]---------------------------------------------------------------------------------*/ | |
46 | + | |
47 | + | |
48 | +/*---[ Implement ]-------------------------------------------------------------------------------*/ | |
49 | + | |
50 | +G_DEFINE_TYPE(PW3270Dbus, pw3270_dbus, G_TYPE_OBJECT) | |
51 | + | |
52 | +static void pw3270_dbus_finalize(GObject *object) | |
53 | +{ | |
54 | + G_OBJECT_CLASS(pw3270_dbus_parent_class)->finalize (object); | |
55 | +} | |
56 | + | |
57 | + | |
58 | +static void pw3270_dbus_class_init(PW3270DbusClass *klass) | |
59 | +{ | |
60 | + GObjectClass *object_class; | |
61 | + object_class = G_OBJECT_CLASS (klass); | |
62 | + object_class->finalize = pw3270_dbus_finalize; | |
63 | +} | |
64 | + | |
65 | +static void pw3270_dbus_init(PW3270Dbus *object) | |
66 | +{ | |
67 | + | |
68 | +} | |
69 | + | |
70 | +PW3270Dbus * pw3270_dbus_new(void) | |
71 | +{ | |
72 | + return g_object_new(PW3270_TYPE_DBUS, NULL); | |
73 | +} | |
74 | + | |
75 | +void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context) | |
76 | +{ | |
77 | + dbus_g_method_return(context,PACKAGE_REVISION); | |
78 | +} | ... | ... |
... | ... | @@ -0,0 +1,86 @@ |
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 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * licinio@bb.com.br (Licínio Luis Branco) | |
28 | + * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | |
29 | + * | |
30 | + */ | |
31 | + | |
32 | +#include <glib.h> | |
33 | +#include <dbus/dbus.h> | |
34 | +#include <dbus/dbus-glib-lowlevel.h> | |
35 | +#include <dbus/dbus-glib.h> | |
36 | + | |
37 | +#include <pw3270.h> | |
38 | +#include <pw3270/plugin.h> | |
39 | + | |
40 | +#include "service.h" | |
41 | +#include "dbus-glue.h" | |
42 | + | |
43 | +/*---[ Globals ]---------------------------------------------------------------------------------*/ | |
44 | + | |
45 | + static DBusGConnection * connection = NULL; | |
46 | + static DBusGProxy * proxy = NULL; | |
47 | + | |
48 | +/*---[ Implement ]-------------------------------------------------------------------------------*/ | |
49 | + | |
50 | + static gpointer dbus_register_object (DBusGConnection *connection,DBusGProxy *proxy,GType object_type,const DBusGObjectInfo *info,const gchar *path) | |
51 | + { | |
52 | + GObject *object = g_object_new (object_type, NULL); | |
53 | + dbus_g_object_type_install_info (object_type, info); | |
54 | + dbus_g_connection_register_g_object (connection, path, object); | |
55 | + return object; | |
56 | + } | |
57 | + | |
58 | + LIB3270_EXPORT int pw3270_plugin_init(GtkWidget *window) | |
59 | + { | |
60 | + | |
61 | + GError * error = NULL; | |
62 | + guint result; | |
63 | + | |
64 | + connection = dbus_g_bus_get_private(DBUS_BUS_SESSION, g_main_context_default(), &error); | |
65 | + if(error) | |
66 | + { | |
67 | + # Popup Error | |
68 | + g_message("Error \"%s\" getting session dbus",error->message); | |
69 | + g_error_free(error); | |
70 | + return -1; | |
71 | + } | |
72 | + | |
73 | + proxy = dbus_g_proxy_new_for_name(connection,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS); | |
74 | + | |
75 | + org_freedesktop_DBus_request_name(proxy, PW3270_DBUS_SERVICE, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error); | |
76 | + | |
77 | + dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,PW3270_DBUS_SERVICE_PATH); | |
78 | + | |
79 | + return 0; | |
80 | + } | |
81 | + | |
82 | + LIB3270_EXPORT int pw3270_plugin_deinit(GtkWidget *window) | |
83 | + { | |
84 | + | |
85 | + return 0; | |
86 | + } | ... | ... |
... | ... | @@ -0,0 +1,62 @@ |
1 | +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | |
2 | +<CodeBlocks_project_file> | |
3 | + <FileVersion major="1" minor="6" /> | |
4 | + <Project> | |
5 | + <Option title="pw3270dbus" /> | |
6 | + <Option makefile_is_custom="1" /> | |
7 | + <Option pch_mode="2" /> | |
8 | + <Option compiler="gcc" /> | |
9 | + <Build> | |
10 | + <Target title="Debug"> | |
11 | + <Option output=".bin/Debug/pw3270dbus" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" /> | |
12 | + <Option object_output=".obj/Debug/" /> | |
13 | + <Option type="3" /> | |
14 | + <Option compiler="gcc" /> | |
15 | + <Compiler> | |
16 | + <Add option="-g" /> | |
17 | + </Compiler> | |
18 | + </Target> | |
19 | + <Target title="Release"> | |
20 | + <Option output=".bin/Release/pw3270dbus" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" /> | |
21 | + <Option object_output=".obj/Release/" /> | |
22 | + <Option type="3" /> | |
23 | + <Option compiler="gcc" /> | |
24 | + <Compiler> | |
25 | + <Add option="-O2" /> | |
26 | + </Compiler> | |
27 | + <Linker> | |
28 | + <Add option="-s" /> | |
29 | + </Linker> | |
30 | + </Target> | |
31 | + <Target title="debug-service"> | |
32 | + <Option output=".bin/Debug/pw3270d" prefix_auto="1" extension_auto="1" /> | |
33 | + <Option object_output=".obj/Debug/" /> | |
34 | + <Option type="1" /> | |
35 | + <Option compiler="gcc" /> | |
36 | + <Compiler> | |
37 | + <Add option="-g" /> | |
38 | + </Compiler> | |
39 | + </Target> | |
40 | + </Build> | |
41 | + <Compiler> | |
42 | + <Add option="-Wall" /> | |
43 | + </Compiler> | |
44 | + <Unit filename="Makefile.in" /> | |
45 | + <Unit filename="dbus-glue.h" /> | |
46 | + <Unit filename="gobject.c"> | |
47 | + <Option compilerVar="CC" /> | |
48 | + </Unit> | |
49 | + <Unit filename="main.c"> | |
50 | + <Option compilerVar="CC" /> | |
51 | + </Unit> | |
52 | + <Unit filename="pw3270dbus.xml" /> | |
53 | + <Unit filename="service.h" /> | |
54 | + <Unit filename="testprogram.c"> | |
55 | + <Option compilerVar="CC" /> | |
56 | + </Unit> | |
57 | + <Extensions> | |
58 | + <code_completion /> | |
59 | + <debugger /> | |
60 | + </Extensions> | |
61 | + </Project> | |
62 | +</CodeBlocks_project_file> | ... | ... |
... | ... | @@ -0,0 +1,9 @@ |
1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
2 | +<node name="/br/com/bb/pw3270"> | |
3 | + <interface name="br.com.bb.pw3270"> | |
4 | + <method name="getRevision"> | |
5 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
6 | + <arg type="s" name="revision" direction="out" /> | |
7 | + </method> | |
8 | + </interface> | |
9 | +</node> | ... | ... |
... | ... | @@ -0,0 +1,42 @@ |
1 | +#ifndef _PW3270_DBUS_SERVICE_H | |
2 | + | |
3 | + #define _PW3270_DBUS_SERVICE_H | |
4 | + | |
5 | + #include <glib.h> | |
6 | + #include <dbus/dbus-glib.h> | |
7 | + #include <dbus/dbus-glib-bindings.h> | |
8 | + #include <dbus/dbus-glib-lowlevel.h> | |
9 | + | |
10 | + #define PW3270_DBUS_SERVICE_PATH "/br/com/bb/pw3270" | |
11 | + #define PW3270_DBUS_SERVICE "br.com.bb.pw3270" | |
12 | + | |
13 | + #define PW3270_TYPE_DBUS (pw3270_dbus_get_type ()) | |
14 | + #define PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PW3270_TYPE_DBUS, PW3270Dbus)) | |
15 | + #define PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_DBUS, PW3270DbusClass)) | |
16 | + #define IS_PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PW3270_TYPE_DBUS)) | |
17 | + #define IS_PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_DBUS)) | |
18 | + #define PW3270_DBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_DBUS, PW3270DbusClass)) | |
19 | + | |
20 | + G_BEGIN_DECLS | |
21 | + | |
22 | + typedef struct _PW3270Dbus PW3270Dbus; | |
23 | + typedef struct _PW3270DbusClass PW3270DbusClass; | |
24 | + | |
25 | + struct _PW3270Dbus | |
26 | + { | |
27 | + GObject parent; | |
28 | + }; | |
29 | + | |
30 | + struct _PW3270DbusClass | |
31 | + { | |
32 | + GObjectClass parent; | |
33 | + }; | |
34 | + | |
35 | + PW3270Dbus * pw3270_dbus_new (void); | |
36 | + GType pw3270_dbus_get_type (void); | |
37 | + | |
38 | + void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context); | |
39 | + | |
40 | + G_END_DECLS | |
41 | + | |
42 | +#endif // _PW3270_DBUS_SERVICE_H | ... | ... |
src/sample/connect.c
... | ... | @@ -18,7 +18,7 @@ |
18 | 18 | * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin |
19 | 19 | * St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | 20 | * |
21 | - * Este programa está nomeado como main.c e possui - linhas de código. | |
21 | + * Este programa está nomeado como connect.c e possui - linhas de código. | |
22 | 22 | * |
23 | 23 | * Contatos: |
24 | 24 | * | ... | ... |