Commit 488118752d64776145d1dc0150147a4a8b34edce
1 parent
0f190dc5
Exists in
master
and in
1 other branch
Reorganizing linux sources.
Showing
22 changed files
with
2241 additions
and
1567 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,315 @@ |
| 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 | +# | |
| 26 | + | |
| 27 | +#---[ Library configuration ]------------------------------------------------------------ | |
| 28 | + | |
| 29 | +MODULE_NAME=ipc3270c | |
| 30 | +PACKAGE_NAME=@PACKAGE_NAME@ | |
| 31 | + | |
| 32 | +PLUGIN_SOURCES= \ | |
| 33 | + $(wildcard src/plugin/*.c) \ | |
| 34 | + $(wildcard src/plugin/@OSNAME@/*.rc) | |
| 35 | + | |
| 36 | +TEST_SOURCES= \ | |
| 37 | + $(wildcard src/testprogram/*.c) | |
| 38 | + | |
| 39 | +#---[ Tools ]---------------------------------------------------------------------------- | |
| 40 | + | |
| 41 | +CC=@CC@ | |
| 42 | +LD=@CC@ | |
| 43 | +LN_S=@LN_S@ | |
| 44 | +MKDIR=@MKDIR_P@ | |
| 45 | +INSTALL=@INSTALL@ | |
| 46 | +INSTALL_DATA=@INSTALL_DATA@ | |
| 47 | +INSTALL_PROGRAM=@INSTALL_PROGRAM@ | |
| 48 | +XGETTEXT=@XGETTEXT@ | |
| 49 | +MSGCAT=@MSGCAT@ | |
| 50 | +WINDRES=@WINDRES@ | |
| 51 | +AR=@AR@ | |
| 52 | + | |
| 53 | +#---[ Paths ]---------------------------------------------------------------------------- | |
| 54 | + | |
| 55 | +prefix=@prefix@ | |
| 56 | +exec_prefix=@exec_prefix@ | |
| 57 | +bindir=@bindir@ | |
| 58 | +sbindir=@sbindir@ | |
| 59 | +libdir=@libdir@ | |
| 60 | +includedir=@includedir@ | |
| 61 | +datarootdir=@datarootdir@ | |
| 62 | +localedir=@localedir@ | |
| 63 | +docdir=@docdir@ | |
| 64 | +sysconfdir=@sysconfdir@ | |
| 65 | + | |
| 66 | +BASEDIR=@BASEDIR@ | |
| 67 | + | |
| 68 | +POTDIR=$(BASEDIR)/.pot | |
| 69 | + | |
| 70 | +OBJDIR=$(BASEDIR)/.obj/$(MODULE_NAME) | |
| 71 | +OBJDBG=$(OBJDIR)/Debug | |
| 72 | +OBJRLS=$(OBJDIR)/Release | |
| 73 | + | |
| 74 | +BINDIR=$(BASEDIR)/.bin | |
| 75 | +BINDBG=$(BINDIR)/Debug | |
| 76 | +BINRLS=$(BINDIR)/Release | |
| 77 | + | |
| 78 | +#---[ Rules ]---------------------------------------------------------------------------- | |
| 79 | + | |
| 80 | +DEPENDS= \ | |
| 81 | + Makefile \ | |
| 82 | + src/include/*.h \ | |
| 83 | + src/include/lib3270/*.h | |
| 84 | + | |
| 85 | +CFLAGS= \ | |
| 86 | + @CFLAGS@ \ | |
| 87 | + -g \ | |
| 88 | + -Isrc/include \ | |
| 89 | + -DBUILD_DATE=`date +%Y%m%d` \ | |
| 90 | + @LIB3270_CFLAGS@ \ | |
| 91 | + @V3270_CFLAGS@ \ | |
| 92 | + @GTK_CFLAGS@ \ | |
| 93 | + @GLIB_CFLAGS@ | |
| 94 | + | |
| 95 | +GTK_LIBS=@GTK_LIBS@ | |
| 96 | +V3270_LIBS=@V3270_LIBS@ | |
| 97 | +GLIB_LIBS=@GLIB_LIBS@ | |
| 98 | + | |
| 99 | +LIBS= \ | |
| 100 | + @LIBS@ \ | |
| 101 | + @LIBICONV@ \ | |
| 102 | + @INTL_LIBS@ \ | |
| 103 | + @LIB3270_LIBS@ | |
| 104 | + | |
| 105 | +#---[ Debug Rules ]---------------------------------------------------------------------- | |
| 106 | + | |
| 107 | +$(OBJDBG)/%.o: \ | |
| 108 | + %.c \ | |
| 109 | + $(DEPENDS) | |
| 110 | + | |
| 111 | + @echo $< ... | |
| 112 | + @$(MKDIR) $(@D) | |
| 113 | + | |
| 114 | + @$(CC) \ | |
| 115 | + $(CFLAGS) \ | |
| 116 | + -Wall -Wextra -fstack-check \ | |
| 117 | + -DDEBUG=1 \ | |
| 118 | + -o $@ -c $< | |
| 119 | + | |
| 120 | +$(OBJDBG)/%.o: \ | |
| 121 | + %.rc | |
| 122 | + | |
| 123 | + @echo $< ... | |
| 124 | + @$(MKDIR) $(@D) | |
| 125 | + @$(WINDRES) $< -O coff -o $@ | |
| 126 | + | |
| 127 | +#---[ Release Rules ]-------------------------------------------------------------------- | |
| 128 | + | |
| 129 | +$(OBJRLS)/%.o: \ | |
| 130 | + %.c \ | |
| 131 | + $(DEPENDS) | |
| 132 | + | |
| 133 | + @echo $< ... | |
| 134 | + @$(MKDIR) $(@D) | |
| 135 | + @$(CC) \ | |
| 136 | + $(CFLAGS) \ | |
| 137 | + -DNDEBUG=1 \ | |
| 138 | + -o $@ -c $< | |
| 139 | + | |
| 140 | +$(OBJRLS)/%.o: \ | |
| 141 | + %.rc | |
| 142 | + | |
| 143 | + @echo $< ... | |
| 144 | + @$(MKDIR) $(@D) | |
| 145 | + @$(WINDRES) $< -O coff -o $@ | |
| 146 | + | |
| 147 | +#---[ Misc Rules ]----------------------------------------------------------------------- | |
| 148 | + | |
| 149 | +$(POTDIR)/$(MODULE_NAME)/%.pot: \ | |
| 150 | + %.c | |
| 151 | + | |
| 152 | + @echo $(notdir $@) ... | |
| 153 | + @$(MKDIR) $(@D) | |
| 154 | + @$(XGETTEXT) \ | |
| 155 | + --language=C \ | |
| 156 | + --keyword=_ \ | |
| 157 | + --keyword=N_ \ | |
| 158 | + --keyword=MSG_:2 \ | |
| 159 | + --output=$@ \ | |
| 160 | + $< | |
| 161 | + @touch $@ | |
| 162 | + | |
| 163 | +$(POTDIR)/$(MODULE_NAME)/%.pot: \ | |
| 164 | + %.rc | |
| 165 | + | |
| 166 | + @echo $< ... | |
| 167 | + @$(MKDIR) $(@D) | |
| 168 | + @touch $@ | |
| 169 | + | |
| 170 | + | |
| 171 | +#---[ Release Targets ]------------------------------------------------------------------ | |
| 172 | + | |
| 173 | +all: \ | |
| 174 | + $(BINRLS)/$(MODULE_NAME)@DLLEXT@ \ | |
| 175 | + $(POTDIR)/$(MODULE_NAME).pot | |
| 176 | + | |
| 177 | +Release: \ | |
| 178 | + $(BINRLS)/$(MODULE_NAME)@DLLEXT@ \ | |
| 179 | + $(BINRLS)/$(PACKAGE_NAME)d@EXEEXT@ | |
| 180 | + | |
| 181 | +$(BINRLS)/$(MODULE_NAME)@DLLEXT@: \ | |
| 182 | + $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) \ | |
| 183 | + $(BINRLS)/lib$(MODULE_NAME).a | |
| 184 | + | |
| 185 | + @$(MKDIR) $(@D) | |
| 186 | + @echo $< ... | |
| 187 | + @$(LD) \ | |
| 188 | + -shared -Wl,-soname,$(@F) \ | |
| 189 | + -o $@ \ | |
| 190 | + $(LDFLAGS) \ | |
| 191 | + $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) \ | |
| 192 | + -L$(BINRLS) -l$(MODULE_NAME) \ | |
| 193 | + $(V3270_LIBS) \ | |
| 194 | + $(LIBS) \ | |
| 195 | + $(GTK_LIBS) | |
| 196 | + | |
| 197 | +$(BINRLS)/lib$(MODULE_NAME).a: \ | |
| 198 | + $(foreach SRC, $(basename $(CORE_SOURCES)), $(OBJRLS)/$(SRC).o) | |
| 199 | + | |
| 200 | + @$(MKDIR) $(@D) | |
| 201 | + @echo $< ... | |
| 202 | + | |
| 203 | + @$(AR) rcs $@ $^ | |
| 204 | + | |
| 205 | + | |
| 206 | +#---[ Install Targets ]------------------------------------------------------------------ | |
| 207 | + | |
| 208 | +install: \ | |
| 209 | + install-plugin | |
| 210 | + | |
| 211 | +install-plugin: \ | |
| 212 | + $(BINRLS)/$(MODULE_NAME)@DLLEXT@ | |
| 213 | + | |
| 214 | + @$(MKDIR) $(DESTDIR)$(libdir)/pw3270-plugins | |
| 215 | + | |
| 216 | + @$(INSTALL_PROGRAM) \ | |
| 217 | + $(BINRLS)/$(MODULE_NAME)@DLLEXT@ \ | |
| 218 | + $(DESTDIR)$(libdir)/pw3270-plugins | |
| 219 | + | |
| 220 | +#---[ Misc Targets ]--------------------------------------------------------------------- | |
| 221 | + | |
| 222 | +$(POTDIR)/$(MODULE_NAME).pot: \ | |
| 223 | + $(foreach SRC, $(basename $(SOURCES)), $(POTDIR)/$(MODULE_NAME)/$(SRC).pot) | |
| 224 | + | |
| 225 | + @rm -f $@ | |
| 226 | + @mkdir -p `dirname $@` | |
| 227 | + @$(MSGCAT) --sort-output $^ > $@ | |
| 228 | + | |
| 229 | +locale: \ | |
| 230 | + $(POTDIR)/$(MODULE_NAME).pot | |
| 231 | + | |
| 232 | + | |
| 233 | +#---[ Debug Targets ]-------------------------------------------------------------------- | |
| 234 | + | |
| 235 | +Debug: \ | |
| 236 | + $(BINDBG)/$(MODULE_NAME)@DLLEXT@ | |
| 237 | + | |
| 238 | +$(BINDBG)/lib$(MODULE_NAME).a: \ | |
| 239 | + $(foreach SRC, $(basename $(CORE_SOURCES)), $(OBJDBG)/$(SRC).o) | |
| 240 | + | |
| 241 | + @$(MKDIR) $(@D) | |
| 242 | + @echo $< ... | |
| 243 | + | |
| 244 | + @$(AR) rcs $@ $^ | |
| 245 | + | |
| 246 | + | |
| 247 | +$(BINDBG)/$(MODULE_NAME)@EXEEXT@: \ | |
| 248 | + $(foreach SRC, $(basename $(TEST_SOURCES)), $(OBJDBG)/$(SRC).o) | |
| 249 | + | |
| 250 | + @$(MKDIR) $(@D) | |
| 251 | + @echo $< ... | |
| 252 | + @$(LD) \ | |
| 253 | + -o $@ \ | |
| 254 | + $^ \ | |
| 255 | + -L$(BINDBG) \ | |
| 256 | + -Wl,-rpath,$(BINDBG) \ | |
| 257 | + $(LDFLAGS) \ | |
| 258 | + $(LIBS) \ | |
| 259 | + $(V3270_LIBS) \ | |
| 260 | + $(GTK_LIBS) \ | |
| 261 | + $(GLIB_LIBS) | |
| 262 | + | |
| 263 | +$(BINDBG)/$(PACKAGE_NAME)d@EXEEXT@: \ | |
| 264 | + $(foreach SRC, $(basename $(SERVICE_SOURCES)), $(OBJDBG)/$(SRC).o) \ | |
| 265 | + $(BINDBG)/lib$(MODULE_NAME).a | |
| 266 | + | |
| 267 | + @$(MKDIR) $(@D) | |
| 268 | + @echo $< ... | |
| 269 | + @$(LD) \ | |
| 270 | + -o $@ \ | |
| 271 | + $(foreach SRC, $(basename $(SERVICE_SOURCES)), $(OBJDBG)/$(SRC).o) \ | |
| 272 | + -L$(BINDBG) \ | |
| 273 | + -Wl,-rpath,$(BINDBG) \ | |
| 274 | + $(LDFLAGS) \ | |
| 275 | + $(LIBS) \ | |
| 276 | + -l$(MODULE_NAME) \ | |
| 277 | + $(GLIB_LIBS) | |
| 278 | + | |
| 279 | +$(BINDBG)/$(MODULE_NAME)@DLLEXT@: \ | |
| 280 | + $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) \ | |
| 281 | + $(BINDBG)/lib$(MODULE_NAME).a | |
| 282 | + | |
| 283 | + @$(MKDIR) $(@D) | |
| 284 | + @echo $< ... | |
| 285 | + @$(LD) \ | |
| 286 | + -shared -Wl,-soname,$(@F) \ | |
| 287 | + -o $@ \ | |
| 288 | + $(LDFLAGS) \ | |
| 289 | + $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) \ | |
| 290 | + -L$(BINDBG) -l$(MODULE_NAME) \ | |
| 291 | + $(V3270_LIBS) \ | |
| 292 | + $(LIBS) \ | |
| 293 | + $(GTK_LIBS) | |
| 294 | + | |
| 295 | + | |
| 296 | +#---[ Clean Targets ]-------------------------------------------------------------------- | |
| 297 | + | |
| 298 | +clean: \ | |
| 299 | + cleanDebug \ | |
| 300 | + cleanRelease | |
| 301 | + | |
| 302 | + @rm -fr $(BASEDIR)/.tmp/$(MODULE_NAME) | |
| 303 | + @rm -fr $(POTDIR)/$(MODULE_NAME) | |
| 304 | + | |
| 305 | +cleanDebug: | |
| 306 | + | |
| 307 | + @rm -fr $(OBJDBG) | |
| 308 | + @rm -fr $(BINDBG) | |
| 309 | + @rm -fr $(OBJDIR)/marshal | |
| 310 | + | |
| 311 | +clean: \ | |
| 312 | + cleanDebug \ | |
| 313 | + cleanRelease | |
| 314 | + | |
| 315 | + | ... | ... |
| ... | ... | @@ -0,0 +1,29 @@ |
| 1 | +#!/bin/bash | |
| 2 | + | |
| 3 | +test -n "$srcdir" || srcdir=`dirname "$0"` | |
| 4 | +test -n "$srcdir" || srcdir=. | |
| 5 | + | |
| 6 | +olddir=`pwd` | |
| 7 | +cd "$srcdir" | |
| 8 | + | |
| 9 | +aclocal | |
| 10 | +if test $? != 0 ; then | |
| 11 | + echo "aclocal failed." | |
| 12 | + exit -1 | |
| 13 | +fi | |
| 14 | + | |
| 15 | +autoconf | |
| 16 | +if test $? != 0 ; then | |
| 17 | + echo "autoconf failed." | |
| 18 | + exit -1 | |
| 19 | +fi | |
| 20 | + | |
| 21 | +mkdir -p scripts | |
| 22 | +automake --add-missing 2> /dev/null | true | |
| 23 | + | |
| 24 | +cd "$olddir" | |
| 25 | +test -n "$NOCONFIGURE" || "$srcdir/configure" "$@" | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | ... | ... |
| ... | ... | @@ -0,0 +1,250 @@ |
| 1 | +dnl | |
| 2 | +dnl Software pw3270, desenvolvido com base nos códigos fontes do C3270 e X3270 | |
| 3 | +dnl (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
| 4 | +dnl aplicativos mainframe. Registro no INPI sob o nome G3270. | |
| 5 | +dnl | |
| 6 | +dnl Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 7 | +dnl | |
| 8 | +dnl Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 9 | +dnl os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 10 | +dnl Free Software Foundation. | |
| 11 | +dnl | |
| 12 | +dnl Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 13 | +dnl GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 14 | +dnl A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 15 | +dnl obter mais detalhes. | |
| 16 | +dnl | |
| 17 | +dnl Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 18 | +dnl programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple | |
| 19 | +dnl Place, Suite 330, Boston, MA, 02111-1307, USA | |
| 20 | +dnl | |
| 21 | +dnl Contatos: | |
| 22 | +dnl | |
| 23 | +dnl perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 24 | +dnl erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) | |
| 25 | +dnl | |
| 26 | + | |
| 27 | +dnl Process this file with autoconf to produce a configure script. | |
| 28 | + | |
| 29 | +dnl The minimum version of autoconf required. | |
| 30 | +AC_PREREQ(2.61) | |
| 31 | + | |
| 32 | +dnl Initialise automake with the package name, version and | |
| 33 | +dnl bug-reporting address. | |
| 34 | +AC_INIT([pw3270], [5.2], [perry.werneck@gmail.com]) | |
| 35 | + | |
| 36 | +dnl Place auxilliary scripts here. | |
| 37 | +AC_CONFIG_AUX_DIR([scripts]) | |
| 38 | + | |
| 39 | +dnl Compute the canonical host-system type | |
| 40 | +AC_CANONICAL_HOST | |
| 41 | + | |
| 42 | +dnl Put macro definitions here (though they aren't used). | |
| 43 | +AC_CONFIG_HEADER([src/include/config.h]) | |
| 44 | + | |
| 45 | +dnl Initialise automake stuff. | |
| 46 | +AM_INIT_AUTOMAKE | |
| 47 | + | |
| 48 | +dnl Check for iconv | |
| 49 | +AM_ICONV | |
| 50 | + | |
| 51 | +dnl Checks for programs. | |
| 52 | +AC_PROG_CC | |
| 53 | +AC_PROG_SED | |
| 54 | +AC_PROG_LN_S | |
| 55 | + | |
| 56 | +AC_LANG([C]) | |
| 57 | + | |
| 58 | +dnl --------------------------------------------------------------------------- | |
| 59 | +dnl Initialize defaults | |
| 60 | +dnl --------------------------------------------------------------------------- | |
| 61 | + | |
| 62 | +DBG_CFLAGS="-g -fstack-check -DDEBUG=1" | |
| 63 | +RLS_CFLAGS="-DNDEBUG=1" | |
| 64 | +PLUGINS="" | |
| 65 | +APP_RESOURCES="" | |
| 66 | +APP_LDFLAGS="" | |
| 67 | +DLL_LDFLAGS="-shared" | |
| 68 | +STATIC_LDFLAGS="" | |
| 69 | + | |
| 70 | +dnl --------------------------------------------------------------------------- | |
| 71 | +dnl Check for OS specifics | |
| 72 | +dnl --------------------------------------------------------------------------- | |
| 73 | + | |
| 74 | +DLLPREFIX="lib" | |
| 75 | + | |
| 76 | +case "$host" in | |
| 77 | + *-mingw32|*-pc-msys) | |
| 78 | + app_cv_osname="windows" | |
| 79 | + CFLAGS="$CFLAGS -pthread -D_WIN32_WINNT=0x0600" | |
| 80 | + LIBS="$LIBS -lws2_32 -lwtsapi32 -lcomdlg32" | |
| 81 | + LDFLAGS="$LDFLAGS -pthread" | |
| 82 | + DLLEXT=".dll" | |
| 83 | + DLLPREFIX="" | |
| 84 | + | |
| 85 | + app_win32_revision=$(date +%y.%m.%d.%H) | |
| 86 | + AC_SUBST(WIN32_VERSION,$app_win32_revision) | |
| 87 | + AC_CONFIG_FILES(src/plugin/windows/resources.rc) | |
| 88 | + ;; | |
| 89 | + | |
| 90 | + *) | |
| 91 | + CFLAGS="$CFLAGS -pthread" | |
| 92 | + LDFLAGS="$LDFLAGS -pthread" | |
| 93 | + app_cv_datadir="/usr/share" | |
| 94 | + app_cv_confdir="/etc" | |
| 95 | + app_cv_osname="linux" | |
| 96 | + LOGDIR="/var/log" | |
| 97 | + DLLEXT=".so" | |
| 98 | + | |
| 99 | +esac | |
| 100 | + | |
| 101 | +AC_SUBST(DATADIR,$app_cv_datadir) | |
| 102 | +AC_SUBST(CONFDIR,$app_cv_confdir) | |
| 103 | +AC_SUBST(OSNAME,$app_cv_osname) | |
| 104 | +AC_SUBST(LIBS) | |
| 105 | +AC_SUBST(LOGDIR) | |
| 106 | +AC_SUBST(DLLEXT) | |
| 107 | +AC_SUBST(DLLPREFIX) | |
| 108 | + | |
| 109 | +dnl --------------------------------------------------------------------------- | |
| 110 | +dnl Check for other programs | |
| 111 | +dnl --------------------------------------------------------------------------- | |
| 112 | + | |
| 113 | +AC_PATH_TOOL([AR], [ar], [ar]) | |
| 114 | +AC_PATH_TOOL([WINDRES], [windres], [no]) | |
| 115 | + | |
| 116 | +PKG_CHECK_EXISTS | |
| 117 | + | |
| 118 | +dnl --------------------------------------------------------------------------- | |
| 119 | +dnl Version info | |
| 120 | +dnl --------------------------------------------------------------------------- | |
| 121 | + | |
| 122 | +AC_SUBST(PACKAGE_DESCRIPTION,"PW3270 IPC Compatible Module") | |
| 123 | + | |
| 124 | +app_vrs_major=$(echo $VERSION | cut -d. -f1) | |
| 125 | +app_vrs_minor=$(echo $VERSION | cut -d. -f2) | |
| 126 | + | |
| 127 | +AC_DEFINE_UNQUOTED(PACKAGE_MAJOR_VERSION, $app_vrs_major) | |
| 128 | +AC_DEFINE_UNQUOTED(PACKAGE_MINOR_VERSION, $app_vrs_minor) | |
| 129 | + | |
| 130 | +AC_SUBST(PACKAGE_MAJOR_VERSION,$app_vrs_major) | |
| 131 | +AC_SUBST(PACKAGE_MINOR_VERSION,$app_vrs_minor) | |
| 132 | + | |
| 133 | +AC_ARG_WITH([release], [AS_HELP_STRING([--with-release], [Set release])], [ app_cv_release="$withval" ],[ app_cv_release="`date +%y`.`date +%m`.`date +%d`" ]) | |
| 134 | + | |
| 135 | +app_rls_major=$(echo $app_cv_release.0.0 | cut -d. -f1) | |
| 136 | +app_rls_minor=$(echo $app_cv_release.0.0 | cut -d. -f2) | |
| 137 | + | |
| 138 | +AC_DEFINE_UNQUOTED(PACKAGE_RELEASE, $app_cv_release) | |
| 139 | +AC_DEFINE_UNQUOTED(PACKAGE_MAJOR_RELEASE, $app_rls_major) | |
| 140 | +AC_DEFINE_UNQUOTED(PACKAGE_MINOR_RELEASE, $app_rls_minor) | |
| 141 | + | |
| 142 | +AC_SUBST(PACKAGE_RELEASE,$app_cv_release) | |
| 143 | +AC_SUBST(PACKAGE_MAJOR_RELEASE,$app_rls_major) | |
| 144 | +AC_SUBST(PACKAGE_MINOR_RELEASE,$app_rls_minor) | |
| 145 | + | |
| 146 | +dnl --------------------------------------------------------------------------- | |
| 147 | +dnl Check for libintl | |
| 148 | +dnl --------------------------------------------------------------------------- | |
| 149 | + | |
| 150 | +INTL_LIBS="" | |
| 151 | + | |
| 152 | +AC_PATH_TOOL([XGETTEXT], [xgettext], [no]) | |
| 153 | +AC_PATH_TOOL([MSGCAT], [msgcat], [no]) | |
| 154 | +AC_PATH_TOOL([MSGINIT], [msginit], [no]) | |
| 155 | +AC_PATH_TOOL([MSGMERGE], [msgmerge], [no]) | |
| 156 | +AC_PATH_TOOL([MSGFMT], [msgfmt], [no]) | |
| 157 | + | |
| 158 | +AC_SUBST(INTL_LIBS) | |
| 159 | + | |
| 160 | +dnl --------------------------------------------------------------------------- | |
| 161 | +dnl Check for LIB3270 | |
| 162 | +dnl --------------------------------------------------------------------------- | |
| 163 | + | |
| 164 | +PKG_CHECK_MODULES( [LIB3270], [lib3270], AC_DEFINE(HAVE_LIB3270), AC_MSG_ERROR([LIB3270 not present.])) | |
| 165 | + | |
| 166 | +AC_SUBST(LIB3270_LIBS) | |
| 167 | +AC_SUBST(LIB3270_CFLAGS) | |
| 168 | + | |
| 169 | +dnl --------------------------------------------------------------------------- | |
| 170 | +dnl Check for LIBV3270 | |
| 171 | +dnl --------------------------------------------------------------------------- | |
| 172 | + | |
| 173 | +PKG_CHECK_MODULES( [V3270], [libv3270], AC_DEFINE(HAVE_V3270), AC_MSG_ERROR([V3270 not present.])) | |
| 174 | + | |
| 175 | +AC_SUBST(V3270_LIBS) | |
| 176 | +AC_SUBST(V3270_CFLAGS) | |
| 177 | + | |
| 178 | +dnl --------------------------------------------------------------------------- | |
| 179 | +dnl Check for GTK | |
| 180 | +dnl --------------------------------------------------------------------------- | |
| 181 | + | |
| 182 | +PKG_CHECK_MODULES( [GTK], [gtk+-3.0], AC_DEFINE(HAVE_GTK), AC_MSG_ERROR([GTK not present.])) | |
| 183 | + | |
| 184 | +AC_SUBST(GTK_LIBS) | |
| 185 | +AC_SUBST(GTK_CFLAGS) | |
| 186 | + | |
| 187 | +dnl --------------------------------------------------------------------------- | |
| 188 | +dnl Check for GLIB | |
| 189 | +dnl --------------------------------------------------------------------------- | |
| 190 | + | |
| 191 | +PKG_CHECK_MODULES( [GLIB], [glib-2.0 gobject-2.0 gmodule-2.0 gio-2.0], AC_DEFINE(HAVE_GLIB), AC_MSG_ERROR([GLIB not present.] )) | |
| 192 | +AC_SUBST(GLIB_LIBS) | |
| 193 | +AC_SUBST(GLIB_CFLAGS) | |
| 194 | + | |
| 195 | +dnl --------------------------------------------------------------------------- | |
| 196 | +dnl Check for D-Bus | |
| 197 | +dnl --------------------------------------------------------------------------- | |
| 198 | + | |
| 199 | +PKG_CHECK_MODULES( [DBUS], [dbus-1], app_cv_libdbus=yes, AC_MSG_NOTICE([ No DBUS support.]) ) | |
| 200 | +AC_SUBST(DBUS_LIBS) | |
| 201 | +AC_SUBST(DBUS_CFLAGS) | |
| 202 | + | |
| 203 | +PKG_CHECK_MODULES( [GDBUS], [dbus-glib-1], app_cv_dbus=yes, AC_MSG_NOTICE([No GDBUS support.]) ) | |
| 204 | +AC_SUBST(GDBUS_LIBS) | |
| 205 | +AC_SUBST(GDBUS_CFLAGS) | |
| 206 | + | |
| 207 | +dnl --------------------------------------------------------------------------- | |
| 208 | +dnl Check for pic | |
| 209 | +dnl --------------------------------------------------------------------------- | |
| 210 | + | |
| 211 | +AC_ARG_ENABLE([pic], | |
| 212 | + [AS_HELP_STRING([--disable-pic], [disable support for PIC libraries (required to compile on 64bits)])], | |
| 213 | +[ | |
| 214 | + app_cv_pic="$enableval" | |
| 215 | +],[ | |
| 216 | + | |
| 217 | + case "$host_cpu" in | |
| 218 | + x86_64) | |
| 219 | + app_cv_pic="yes" | |
| 220 | + ;; | |
| 221 | + | |
| 222 | + aarch64) | |
| 223 | + app_cv_pic="yes" | |
| 224 | + ;; | |
| 225 | + | |
| 226 | + *) | |
| 227 | + app_cv_pic="no" | |
| 228 | + esac | |
| 229 | + | |
| 230 | +]) | |
| 231 | + | |
| 232 | +if test "$app_cv_pic" == "yes"; then | |
| 233 | + CFLAGS="$CFLAGS -fPIC" | |
| 234 | + CXXFLAGS="$CXXFLAGS -fPIC" | |
| 235 | +fi | |
| 236 | + | |
| 237 | +dnl --------------------------------------------------------------------------- | |
| 238 | +dnl Configure which files to generate. | |
| 239 | +dnl --------------------------------------------------------------------------- | |
| 240 | + | |
| 241 | +AC_CONFIG_FILES(Makefile) | |
| 242 | + | |
| 243 | +dnl --------------------------------------------------------------------------- | |
| 244 | +dnl Output the generated config.status script. | |
| 245 | +dnl --------------------------------------------------------------------------- | |
| 246 | +AC_SUBST(BASEDIR,$ac_pwd) | |
| 247 | + | |
| 248 | +AC_OUTPUT | |
| 249 | + | |
| 250 | + | ... | ... |
src/dbus3270/daemon.c
| ... | ... | @@ -1,122 +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. | |
| 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 "daemon.h" | |
| 42 | -#include "dbus-glue.h" | |
| 43 | - | |
| 44 | -#define PW3270_DBUS_SERVICE_PATH "/br/com/bb/pw3270" | |
| 45 | -#define PW3270_DBUS_SERVICE "br.com.bb.pw3270" | |
| 46 | - | |
| 47 | - | |
| 48 | -/*---[ Globals ]---------------------------------------------------------------------------------*/ | |
| 49 | - | |
| 50 | - static DBusGConnection * connection = NULL; | |
| 51 | - static DBusGProxy * proxy = NULL; | |
| 52 | - static H3270 * hSession = NULL; | |
| 53 | - | |
| 54 | - GMainLoop * main_loop = NULL; | |
| 55 | - | |
| 56 | - | |
| 57 | -/*---[ Implement ]-------------------------------------------------------------------------------*/ | |
| 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 | - pw3270_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 | -static void loghandler(H3270 *session, const char *module, int rc, const char *fmt, va_list args) | |
| 82 | -{ | |
| 83 | - g_logv(module,rc ? G_LOG_LEVEL_WARNING : G_LOG_LEVEL_MESSAGE, fmt, args); | |
| 84 | -} | |
| 85 | - | |
| 86 | -int main(int numpar, char *param[]) | |
| 87 | -{ | |
| 88 | - g_type_init (); | |
| 89 | - | |
| 90 | - if (!g_thread_supported ()) | |
| 91 | - g_thread_init (NULL); | |
| 92 | - | |
| 93 | - dbus_g_thread_init (); | |
| 94 | - | |
| 95 | - lib3270_set_log_handler(loghandler); | |
| 96 | - pw3270_dbus_register_io_handlers(); | |
| 97 | - | |
| 98 | - hSession = lib3270_session_new(""); | |
| 99 | - | |
| 100 | - main_loop = g_main_loop_new (NULL, FALSE); | |
| 101 | - | |
| 102 | - if(initialize()) | |
| 103 | - return -1; | |
| 104 | - | |
| 105 | - g_main_loop_run(main_loop); | |
| 106 | - | |
| 107 | - lib3270_session_free(hSession); | |
| 108 | - | |
| 109 | - return 0; | |
| 110 | -} | |
| 111 | - | |
| 112 | -void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 113 | -{ | |
| 114 | - g_main_loop_quit(main_loop); | |
| 115 | - dbus_g_method_return(context,0); | |
| 116 | -} | |
| 117 | - | |
| 118 | -H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object) | |
| 119 | -{ | |
| 120 | - return hSession; | |
| 121 | -} | |
| 122 | - |
src/dbus3270/daemon.h
| ... | ... | @@ -1,46 +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. | |
| 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 "service.h" | |
| 37 | - | |
| 38 | -/*---[ Globals ]---------------------------------------------------------------------------------*/ | |
| 39 | - | |
| 40 | - G_GNUC_INTERNAL GMainLoop * main_loop; | |
| 41 | - | |
| 42 | - | |
| 43 | -/*---[ Prototipes ]------------------------------------------------------------------------------*/ | |
| 44 | - | |
| 45 | - G_GNUC_INTERNAL void pw3270_dbus_register_io_handlers(void); | |
| 46 | - |
src/dbus3270/globals.h
| ... | ... | @@ -1,59 +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. | |
| 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 globals.h 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 | -#ifndef PW3270_DBUS_GLOBALS_H_INCLUDED | |
| 33 | - | |
| 34 | - #define PW3270_DBUS_GLOBALS_H_INCLUDED 1 | |
| 35 | - | |
| 36 | - #include <libintl.h> | |
| 37 | - #include <glib/gi18n.h> | |
| 38 | - | |
| 39 | - #include <errno.h> | |
| 40 | - #include <lib3270.h> | |
| 41 | - #include <lib3270/log.h> | |
| 42 | - #include <glib.h> | |
| 43 | - | |
| 44 | - // | |
| 45 | - // Disabling warning on unused-function defined in dbus-glib-bindings.h | |
| 46 | - // warning: 'org_freedesktop_DBus_reload_config' defined but not used [-Wunused-function] ... | |
| 47 | - // | |
| 48 | - #pragma GCC diagnostic ignored "-Wunused-function" | |
| 49 | - | |
| 50 | - #include <dbus/dbus-glib.h> | |
| 51 | - #include <dbus/dbus-glib-bindings.h> | |
| 52 | - #include <dbus/dbus-glib-lowlevel.h> | |
| 53 | - | |
| 54 | - #define ERROR_DOMAIN g_quark_from_static_string("pw3270DBUS") | |
| 55 | - | |
| 56 | - G_GNUC_INTERNAL gpointer pw3270_dbus_register_object (DBusGConnection *connection,DBusGProxy *proxy,GType object_type,const DBusGObjectInfo *info,const gchar *path); | |
| 57 | - | |
| 58 | - | |
| 59 | -#endif // PW3270_DBUS_GLOBALS_H_INCLUDED |
src/dbus3270/gobject.c
| ... | ... | @@ -1,622 +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. | |
| 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 <gtk/gtk.h> | |
| 38 | -#include <dbus/dbus.h> | |
| 39 | -#include <dbus/dbus-glib-lowlevel.h> | |
| 40 | -#include <dbus/dbus-glib.h> | |
| 41 | - | |
| 42 | -#include <config.h> | |
| 43 | -#include <lib3270.h> | |
| 44 | -#include <pw3270.h> | |
| 45 | -#include <v3270.h> | |
| 46 | -#include <lib3270/actions.h> | |
| 47 | -#include <lib3270/charset.h> | |
| 48 | - | |
| 49 | -#include "service.h" | |
| 50 | - | |
| 51 | -/*---[ Globals ]---------------------------------------------------------------------------------*/ | |
| 52 | - | |
| 53 | - | |
| 54 | -/*---[ Implement ]-------------------------------------------------------------------------------*/ | |
| 55 | - | |
| 56 | -G_DEFINE_TYPE(PW3270Dbus, pw3270_dbus, G_TYPE_OBJECT) | |
| 57 | - | |
| 58 | -static void pw3270_dbus_finalize(GObject *object) | |
| 59 | -{ | |
| 60 | - G_OBJECT_CLASS(pw3270_dbus_parent_class)->finalize (object); | |
| 61 | -} | |
| 62 | - | |
| 63 | - | |
| 64 | -static void pw3270_dbus_class_init(PW3270DbusClass *klass) | |
| 65 | -{ | |
| 66 | - GObjectClass *object_class; | |
| 67 | - object_class = G_OBJECT_CLASS (klass); | |
| 68 | - object_class->finalize = pw3270_dbus_finalize; | |
| 69 | -} | |
| 70 | - | |
| 71 | -static void pw3270_dbus_init(PW3270Dbus *object) | |
| 72 | -{ | |
| 73 | - | |
| 74 | -} | |
| 75 | - | |
| 76 | -PW3270Dbus * pw3270_dbus_new(void) | |
| 77 | -{ | |
| 78 | - return g_object_new(PW3270_TYPE_DBUS, NULL); | |
| 79 | -} | |
| 80 | - | |
| 81 | -void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 82 | -{ | |
| 83 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 84 | -#ifdef PACKAGE_REVISION | |
| 85 | - dbus_g_method_return(context,PACKAGE_REVISION); | |
| 86 | -#else | |
| 87 | - dbus_g_method_return(context,BUILD_DATE); | |
| 88 | -#endif | |
| 89 | -} | |
| 90 | - | |
| 91 | -void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context) | |
| 92 | -{ | |
| 93 | - H3270 *hSession = pw3270_dbus_get_session_handle(PW3270_DBUS(object)); | |
| 94 | - | |
| 95 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 96 | - | |
| 97 | - if(uri && *uri) | |
| 98 | - { | |
| 99 | - lib3270_set_url(hSession,uri); | |
| 100 | - g_message("Connecting to \"%s\" by remote request",lib3270_get_url(hSession)); | |
| 101 | - } | |
| 102 | - else | |
| 103 | - { | |
| 104 | - g_message("%s","Connecting by remote request"); | |
| 105 | - } | |
| 106 | - | |
| 107 | - dbus_g_method_return(context,lib3270_reconnect(hSession,0)); | |
| 108 | -} | |
| 109 | - | |
| 110 | -void pw3270_dbus_set_ur_l(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context) | |
| 111 | -{ | |
| 112 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 113 | - | |
| 114 | - g_message("Changing host to \"%s\" by remote request",uri); | |
| 115 | - | |
| 116 | - dbus_g_method_return(context,lib3270_set_url(pw3270_dbus_get_session_handle(PW3270_DBUS(object)),uri) != 0); | |
| 117 | -} | |
| 118 | - | |
| 119 | -void pw3270_dbus_get_ur_l(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 120 | -{ | |
| 121 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 122 | - dbus_g_method_return(context,lib3270_get_url(pw3270_dbus_get_session_handle(PW3270_DBUS(object)))); | |
| 123 | -} | |
| 124 | - | |
| 125 | - | |
| 126 | -void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 127 | -{ | |
| 128 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 129 | - | |
| 130 | - g_message("Disconnecting by remote request"); | |
| 131 | - lib3270_disconnect(pw3270_dbus_get_session_handle(object)); | |
| 132 | - dbus_g_method_return(context,0); | |
| 133 | -} | |
| 134 | - | |
| 135 | -void pw3270_dbus_get_message_id(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 136 | -{ | |
| 137 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 138 | - dbus_g_method_return(context,lib3270_get_program_message(pw3270_dbus_get_session_handle(object))); | |
| 139 | -} | |
| 140 | - | |
| 141 | -void pw3270_dbus_get_connection_state(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 142 | -{ | |
| 143 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 144 | - dbus_g_method_return(context,lib3270_get_connection_state(pw3270_dbus_get_session_handle(object))); | |
| 145 | -} | |
| 146 | - | |
| 147 | -void pw3270_dbus_get_secure_state(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 148 | -{ | |
| 149 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 150 | - dbus_g_method_return(context,lib3270_get_secure(pw3270_dbus_get_session_handle(object))); | |
| 151 | -} | |
| 152 | - | |
| 153 | -GError * pw3270_dbus_get_error_from_errno(int code) | |
| 154 | -{ | |
| 155 | - return g_error_new(ERROR_DOMAIN,code,"%s",g_strerror(code)); | |
| 156 | -} | |
| 157 | - | |
| 158 | -int pw3270_dbus_check_valid_state(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 159 | -{ | |
| 160 | - H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
| 161 | - GError * error = NULL; | |
| 162 | - | |
| 163 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 164 | - | |
| 165 | - if(!lib3270_is_connected(hSession)) | |
| 166 | - { | |
| 167 | - error = pw3270_dbus_get_error_from_errno(ENOTCONN); | |
| 168 | - } | |
| 169 | - else | |
| 170 | - { | |
| 171 | - LIB3270_MESSAGE state = lib3270_get_program_message(hSession); | |
| 172 | - | |
| 173 | - switch(state) | |
| 174 | - { | |
| 175 | - case LIB3270_MESSAGE_NONE: | |
| 176 | - return 0; | |
| 177 | - | |
| 178 | - case LIB3270_MESSAGE_DISCONNECTED: | |
| 179 | - error = pw3270_dbus_get_error_from_errno(ENOTCONN); | |
| 180 | - break; | |
| 181 | - | |
| 182 | - case LIB3270_MESSAGE_MINUS: | |
| 183 | - case LIB3270_MESSAGE_PROTECTED: | |
| 184 | - case LIB3270_MESSAGE_NUMERIC: | |
| 185 | - case LIB3270_MESSAGE_OVERFLOW: | |
| 186 | - case LIB3270_MESSAGE_INHIBIT: | |
| 187 | - case LIB3270_MESSAGE_KYBDLOCK: | |
| 188 | - case LIB3270_MESSAGE_X: | |
| 189 | - error = g_error_new(ERROR_DOMAIN,-1,_( "State %04d can't accept requests" ),state); | |
| 190 | - break; | |
| 191 | - | |
| 192 | - case LIB3270_MESSAGE_SYSWAIT: | |
| 193 | - case LIB3270_MESSAGE_TWAIT: | |
| 194 | - case LIB3270_MESSAGE_CONNECTED: | |
| 195 | - case LIB3270_MESSAGE_AWAITING_FIRST: | |
| 196 | - error = pw3270_dbus_get_error_from_errno(EBUSY); | |
| 197 | - break; | |
| 198 | - | |
| 199 | - case LIB3270_MESSAGE_RESOLVING: | |
| 200 | - case LIB3270_MESSAGE_CONNECTING: | |
| 201 | - error = g_error_new(ERROR_DOMAIN,EINPROGRESS,_( "Connecting to host" )); | |
| 202 | - | |
| 203 | - case LIB3270_MESSAGE_USER: | |
| 204 | - error = g_error_new(ERROR_DOMAIN,-1,_( "Unexpected state %04d" ),state); | |
| 205 | - } | |
| 206 | - } | |
| 207 | - | |
| 208 | - if(error) | |
| 209 | - { | |
| 210 | - dbus_g_method_return_error(context,error); | |
| 211 | - g_error_free(error); | |
| 212 | - return -1; | |
| 213 | - } | |
| 214 | - | |
| 215 | - return 0; | |
| 216 | -} | |
| 217 | - | |
| 218 | -void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 219 | -{ | |
| 220 | - char * text; | |
| 221 | - gchar * utftext; | |
| 222 | - H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
| 223 | - | |
| 224 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 225 | - | |
| 226 | - if(pw3270_dbus_check_valid_state(object,context)) | |
| 227 | - return; | |
| 228 | - | |
| 229 | - text = lib3270_get_string_at_address(hSession,0,-1,'\n'); | |
| 230 | - | |
| 231 | - utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL); | |
| 232 | - | |
| 233 | - lib3270_free(text); | |
| 234 | - | |
| 235 | - dbus_g_method_return(context,utftext); | |
| 236 | - | |
| 237 | - g_free(utftext); | |
| 238 | - | |
| 239 | -} | |
| 240 | - | |
| 241 | -void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 242 | -{ | |
| 243 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 244 | - if(pw3270_dbus_check_valid_state(object,context)) | |
| 245 | - return; | |
| 246 | - dbus_g_method_return(context,lib3270_enter(pw3270_dbus_get_session_handle(object))); | |
| 247 | -} | |
| 248 | - | |
| 249 | -void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *utftext, DBusGMethodInvocation *context) | |
| 250 | -{ | |
| 251 | - gchar * text; | |
| 252 | - H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
| 253 | - | |
| 254 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 255 | - if(pw3270_dbus_check_valid_state(object,context)) | |
| 256 | - return; | |
| 257 | - | |
| 258 | - text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL); | |
| 259 | - | |
| 260 | - int sz = lib3270_set_string_at(hSession,row,col,(const unsigned char *) text); | |
| 261 | - | |
| 262 | - trace("%s returns %d",__FUNCTION__,sz); | |
| 263 | - dbus_g_method_return(context,sz); | |
| 264 | - | |
| 265 | - g_free(text); | |
| 266 | -} | |
| 267 | - | |
| 268 | -void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context) | |
| 269 | -{ | |
| 270 | - gchar * text; | |
| 271 | - H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
| 272 | - | |
| 273 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 274 | - if(pw3270_dbus_check_valid_state(object,context)) | |
| 275 | - return; | |
| 276 | - | |
| 277 | - text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL); | |
| 278 | - | |
| 279 | - dbus_g_method_return(context,lib3270_emulate_input(hSession,(const char *) text,-1,1)); | |
| 280 | - | |
| 281 | - g_free(text); | |
| 282 | -} | |
| 283 | - | |
| 284 | - | |
| 285 | -void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, char lf, DBusGMethodInvocation *context) | |
| 286 | -{ | |
| 287 | - gchar * text; | |
| 288 | - H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
| 289 | - | |
| 290 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 291 | - if(pw3270_dbus_check_valid_state(object,context)) | |
| 292 | - return; | |
| 293 | - | |
| 294 | - text = lib3270_get_string_at(hSession, row, col, len, lf); | |
| 295 | - if(!text) | |
| 296 | - { | |
| 297 | - GError *error = pw3270_dbus_get_error_from_errno(errno); | |
| 298 | - dbus_g_method_return_error(context,error); | |
| 299 | - g_error_free(error); | |
| 300 | - } | |
| 301 | - else | |
| 302 | - { | |
| 303 | - gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL); | |
| 304 | - | |
| 305 | - lib3270_free(text); | |
| 306 | - | |
| 307 | - dbus_g_method_return(context,utftext); | |
| 308 | - | |
| 309 | - g_free(utftext); | |
| 310 | - } | |
| 311 | - } | |
| 312 | - | |
| 313 | - void pw3270_dbus_get_text(PW3270Dbus *object, int offset, int len, char lf, DBusGMethodInvocation *context) | |
| 314 | - { | |
| 315 | - gchar * text; | |
| 316 | - H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
| 317 | - | |
| 318 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 319 | - if(pw3270_dbus_check_valid_state(object,context)) | |
| 320 | - return; | |
| 321 | - | |
| 322 | - if(len < 0) { | |
| 323 | - len = lib3270_get_length(hSession); | |
| 324 | - } | |
| 325 | - | |
| 326 | - text = lib3270_get_string_at_address(hSession,offset,len,lf); | |
| 327 | - if(!text) | |
| 328 | - { | |
| 329 | - GError *error = pw3270_dbus_get_error_from_errno(errno); | |
| 330 | - dbus_g_method_return_error(context,error); | |
| 331 | - g_error_free(error); | |
| 332 | - } | |
| 333 | - else | |
| 334 | - { | |
| 335 | - gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL); | |
| 336 | - | |
| 337 | - lib3270_free(text); | |
| 338 | - | |
| 339 | - debug("\n%s\n",utftext); | |
| 340 | - | |
| 341 | - dbus_g_method_return(context,utftext); | |
| 342 | - | |
| 343 | - g_free(utftext); | |
| 344 | - } | |
| 345 | - | |
| 346 | - } | |
| 347 | - | |
| 348 | - void pw3270_dbus_is_connected(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 349 | - { | |
| 350 | - trace("%s object=%p context=%p connected=%s",__FUNCTION__,object,context, lib3270_is_connected(pw3270_dbus_get_session_handle(object)) ? "Yes" : "No"); | |
| 351 | - dbus_g_method_return(context,lib3270_is_connected(pw3270_dbus_get_session_handle(object))); | |
| 352 | - } | |
| 353 | - | |
| 354 | - void pw3270_dbus_is_ready(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 355 | - { | |
| 356 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 357 | - dbus_g_method_return(context,lib3270_is_ready(pw3270_dbus_get_session_handle(object))); | |
| 358 | - } | |
| 359 | - | |
| 360 | - void pw3270_dbus_in_tn3270_e(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 361 | - { | |
| 362 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 363 | - dbus_g_method_return(context,lib3270_in_tn3270e(pw3270_dbus_get_session_handle(object))); | |
| 364 | - } | |
| 365 | - | |
| 366 | - void pw3270_dbus_wait_for_ready(PW3270Dbus *object, int timeout, DBusGMethodInvocation *context) | |
| 367 | - { | |
| 368 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 369 | - dbus_g_method_return(context,lib3270_wait_for_ready(pw3270_dbus_get_session_handle(object),timeout)); | |
| 370 | - } | |
| 371 | - | |
| 372 | - void pw3270_dbus_set_cursor_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context) | |
| 373 | - { | |
| 374 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 375 | - dbus_g_method_return(context,lib3270_set_cursor_position(pw3270_dbus_get_session_handle(object),row,col)); | |
| 376 | - } | |
| 377 | - | |
| 378 | - void pw3270_dbus_set_cursor_address(PW3270Dbus *object, int addr, DBusGMethodInvocation *context) | |
| 379 | - { | |
| 380 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 381 | - dbus_g_method_return(context,lib3270_set_cursor_address(pw3270_dbus_get_session_handle(object),addr)); | |
| 382 | - } | |
| 383 | - | |
| 384 | - void pw3270_dbus_get_cursor_address(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 385 | - { | |
| 386 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 387 | - dbus_g_method_return(context,lib3270_get_cursor_address(pw3270_dbus_get_session_handle(object))); | |
| 388 | - } | |
| 389 | - | |
| 390 | - void pw3270_dbus_get_screen_width(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 391 | - { | |
| 392 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 393 | - dbus_g_method_return(context,lib3270_get_width(pw3270_dbus_get_session_handle(object))); | |
| 394 | - } | |
| 395 | - | |
| 396 | - void pw3270_dbus_get_screen_height(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 397 | - { | |
| 398 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 399 | - dbus_g_method_return(context,lib3270_get_height(pw3270_dbus_get_session_handle(object))); | |
| 400 | - } | |
| 401 | - | |
| 402 | - void pw3270_dbus_get_screen_length(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 403 | - { | |
| 404 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 405 | - dbus_g_method_return(context,lib3270_get_width(pw3270_dbus_get_session_handle(object))); | |
| 406 | - } | |
| 407 | - | |
| 408 | - void pw3270_dbus_set_toggle(PW3270Dbus *object, int id, int value, DBusGMethodInvocation *context) | |
| 409 | - { | |
| 410 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 411 | - dbus_g_method_return(context,lib3270_set_toggle(pw3270_dbus_get_session_handle(object),id,value)); | |
| 412 | - } | |
| 413 | - | |
| 414 | -void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *utftext, char lf, DBusGMethodInvocation *context) | |
| 415 | -{ | |
| 416 | - gchar * text; | |
| 417 | - H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
| 418 | - | |
| 419 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 420 | - if(pw3270_dbus_check_valid_state(object,context)) | |
| 421 | - return; | |
| 422 | - | |
| 423 | - text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL); | |
| 424 | - | |
| 425 | - dbus_g_method_return(context,lib3270_cmp_text_at(hSession,row,col,text,lf)); | |
| 426 | - | |
| 427 | - g_free(text); | |
| 428 | -} | |
| 429 | - | |
| 430 | -void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context) | |
| 431 | -{ | |
| 432 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 433 | - if(pw3270_dbus_check_valid_state(object,context)) | |
| 434 | - return; | |
| 435 | - dbus_g_method_return(context,lib3270_pfkey(pw3270_dbus_get_session_handle(object),key)); | |
| 436 | -} | |
| 437 | - | |
| 438 | -void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context) | |
| 439 | -{ | |
| 440 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 441 | - if(pw3270_dbus_check_valid_state(object,context)) | |
| 442 | - return; | |
| 443 | - dbus_g_method_return(context,lib3270_pakey(pw3270_dbus_get_session_handle(object),key)); | |
| 444 | -} | |
| 445 | - | |
| 446 | - void pw3270_dbus_get_field_start(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context) | |
| 447 | - { | |
| 448 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 449 | - dbus_g_method_return(context,lib3270_get_field_start(pw3270_dbus_get_session_handle(object),baddr)); | |
| 450 | - } | |
| 451 | - | |
| 452 | - void pw3270_dbus_get_field_length(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context) | |
| 453 | - { | |
| 454 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 455 | - dbus_g_method_return(context,lib3270_get_field_len(pw3270_dbus_get_session_handle(object),baddr)); | |
| 456 | - } | |
| 457 | - | |
| 458 | - void pw3270_dbus_get_next_unprotected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context) | |
| 459 | - { | |
| 460 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 461 | - dbus_g_method_return(context,lib3270_get_next_unprotected(pw3270_dbus_get_session_handle(object),baddr)); | |
| 462 | - } | |
| 463 | - | |
| 464 | - void pw3270_dbus_get_is_protected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context) | |
| 465 | - { | |
| 466 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 467 | - dbus_g_method_return(context,lib3270_get_is_protected(pw3270_dbus_get_session_handle(object),baddr)); | |
| 468 | - } | |
| 469 | - | |
| 470 | - void pw3270_dbus_get_is_protected_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context) | |
| 471 | - { | |
| 472 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 473 | - dbus_g_method_return(context,lib3270_get_is_protected_at(pw3270_dbus_get_session_handle(object),row,col)); | |
| 474 | - } | |
| 475 | - | |
| 476 | - void pw3270_dbus_action(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context) | |
| 477 | - { | |
| 478 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 479 | - dbus_g_method_return(context,lib3270_action(pw3270_dbus_get_session_handle(object),text)); | |
| 480 | - } | |
| 481 | - | |
| 482 | - void pw3270_dbus_get_clipboard(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 483 | - { | |
| 484 | - gchar *text; | |
| 485 | - | |
| 486 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 487 | - | |
| 488 | - if(pw3270_dbus_check_valid_state(object,context)) | |
| 489 | - return; | |
| 490 | - | |
| 491 | - text = gtk_clipboard_wait_for_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD)); | |
| 492 | - | |
| 493 | - trace("Clipboard:\n%s\n",text); | |
| 494 | - | |
| 495 | - if(!text) | |
| 496 | - { | |
| 497 | - GError *error = pw3270_dbus_get_error_from_errno(ENOENT); | |
| 498 | - dbus_g_method_return_error(context,error); | |
| 499 | - g_error_free(error); | |
| 500 | - } | |
| 501 | - else | |
| 502 | - { | |
| 503 | - dbus_g_method_return(context,text); | |
| 504 | - g_free(text); | |
| 505 | - } | |
| 506 | -} | |
| 507 | - | |
| 508 | -void pw3270_dbus_set_clipboard(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context) | |
| 509 | -{ | |
| 510 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 511 | - gtk_clipboard_set_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD),(gchar *) text, -1); | |
| 512 | - dbus_g_method_return(context,0); | |
| 513 | -} | |
| 514 | - | |
| 515 | -void pw3270_dbus_set_script(PW3270Dbus *object, const gchar *text, int mode, DBusGMethodInvocation *context) | |
| 516 | -{ | |
| 517 | - GtkWidget *widget = pw3270_get_terminal_widget(NULL); | |
| 518 | - | |
| 519 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 520 | - | |
| 521 | - if(!widget) | |
| 522 | - { | |
| 523 | - GError *error = pw3270_dbus_get_error_from_errno(EINVAL); | |
| 524 | - dbus_g_method_return_error(context,error); | |
| 525 | - g_error_free(error); | |
| 526 | - return; | |
| 527 | - } | |
| 528 | - | |
| 529 | - dbus_g_method_return(context,v3270_set_script(widget,mode == 0 ? 0 : 'S')); | |
| 530 | -} | |
| 531 | - | |
| 532 | -void pw3270_dbus_show_popup(PW3270Dbus *object, int id, const gchar *title, const gchar *msg, const gchar *text, DBusGMethodInvocation *context) | |
| 533 | -{ | |
| 534 | - lib3270_popup_dialog(pw3270_dbus_get_session_handle(object), (LIB3270_NOTIFY) id , title, msg, "%s", text); | |
| 535 | - dbus_g_method_return(context,0); | |
| 536 | -} | |
| 537 | - | |
| 538 | -void pw3270_dbus_get_host_charset(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 539 | -{ | |
| 540 | - dbus_g_method_return(context,lib3270_get_host_charset(pw3270_dbus_get_session_handle(object))); | |
| 541 | -} | |
| 542 | - | |
| 543 | -void pw3270_dbus_get_display_charset(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 544 | -{ | |
| 545 | - // Allways return UTF-8 to avoid double conversion | |
| 546 | - dbus_g_method_return(context,"UTF-8"); | |
| 547 | -} | |
| 548 | - | |
| 549 | -void pw3270_dbus_set_host_charset(PW3270Dbus *object, const gchar *charset, DBusGMethodInvocation *context) | |
| 550 | -{ | |
| 551 | - dbus_g_method_return(context,lib3270_set_host_charset(pw3270_dbus_get_session_handle(object),charset)); | |
| 552 | -} | |
| 553 | - | |
| 554 | -void pw3270_dbus_erase_eof(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 555 | -{ | |
| 556 | - trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 557 | - dbus_g_method_return(context,lib3270_eraseeof(pw3270_dbus_get_session_handle(object))); | |
| 558 | -} | |
| 559 | - | |
| 560 | -void pw3270_dbus_print(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 561 | -{ | |
| 562 | - dbus_g_method_return(context,lib3270_print_all(pw3270_dbus_get_session_handle(object))); | |
| 563 | -} | |
| 564 | - | |
| 565 | -void pw3270_dbus_set_unlock_delay(PW3270Dbus *object, int value, DBusGMethodInvocation *context) | |
| 566 | -{ | |
| 567 | - lib3270_set_unlock_delay(pw3270_dbus_get_session_handle(object),(unsigned short) value); | |
| 568 | - dbus_g_method_return(context,0); | |
| 569 | -} | |
| 570 | - | |
| 571 | - | |
| 572 | -void pw3270_dbus_ebc2asc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context) | |
| 573 | -{ | |
| 574 | - int sz = strlen(from); | |
| 575 | - | |
| 576 | - if(sz > 0) | |
| 577 | - { | |
| 578 | - unsigned char buffer[sz+1]; | |
| 579 | - memcpy(buffer,from,sz); | |
| 580 | - dbus_g_method_return(context,lib3270_ebc2asc(pw3270_dbus_get_session_handle(object),buffer,sz)); | |
| 581 | - return; | |
| 582 | - } | |
| 583 | - | |
| 584 | - dbus_g_method_return(context,""); | |
| 585 | - | |
| 586 | -} | |
| 587 | - | |
| 588 | -void pw3270_dbus_asc2ebc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context) | |
| 589 | -{ | |
| 590 | - int sz = strlen(from); | |
| 591 | - | |
| 592 | - if(sz > 0) | |
| 593 | - { | |
| 594 | - unsigned char buffer[sz+1]; | |
| 595 | - memcpy(buffer,from,sz); | |
| 596 | - dbus_g_method_return(context,lib3270_asc2ebc(pw3270_dbus_get_session_handle(object),buffer,sz)); | |
| 597 | - return; | |
| 598 | - } | |
| 599 | - | |
| 600 | - dbus_g_method_return(context,""); | |
| 601 | - | |
| 602 | -} | |
| 603 | - | |
| 604 | -void pw3270_dbus_filetransfer(PW3270Dbus *object, const gchar *local, const gchar *remote, int flags, int lrecl, int blksize, int primspace, int secspace, int dft, DBusGMethodInvocation *context) | |
| 605 | -{ | |
| 606 | - /* | |
| 607 | - dbus_g_method_return(context, | |
| 608 | - v3270_transfer_file( | |
| 609 | - v3270_get_default_widget(), | |
| 610 | - (LIB3270_FT_OPTION) flags, | |
| 611 | - local, | |
| 612 | - remote, | |
| 613 | - lrecl, | |
| 614 | - blksize, | |
| 615 | - primspace, | |
| 616 | - secspace, | |
| 617 | - dft | |
| 618 | - )); | |
| 619 | - */ | |
| 620 | - return; | |
| 621 | -} | |
| 622 | - |
src/dbus3270/iocallback.c
| ... | ... | @@ -1,361 +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. | |
| 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 iocallback.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 | -#if defined(_WIN32) /*[*/ | |
| 33 | - #include <windows.h> | |
| 34 | -#elif defined(__APPLE__) | |
| 35 | - #include <poll.h> | |
| 36 | - #include <string.h> | |
| 37 | -#else | |
| 38 | - #include <poll.h> | |
| 39 | - #include <string.h> | |
| 40 | -#endif /*]*/ | |
| 41 | - | |
| 42 | -#include <stdio.h> | |
| 43 | -#include <glib.h> | |
| 44 | -#include "daemon.h" | |
| 45 | - | |
| 46 | -static int static_CallAndWait(int(*callback)(H3270 *session, void *), H3270 *session, void *parm); | |
| 47 | -static void static_RemoveSource(void *id); | |
| 48 | - | |
| 49 | -static void * static_AddInput(int source, H3270 *session, void (*fn)(H3270 *session)); | |
| 50 | -static void * static_AddExcept(int source, H3270 *session, void (*fn)(H3270 *session)); | |
| 51 | - | |
| 52 | -static void * static_AddTimeOut(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session)); | |
| 53 | -static void static_RemoveTimeOut(void * timer); | |
| 54 | -static int static_Sleep(H3270 *hSession, int seconds); | |
| 55 | -static int static_RunPendingEvents(H3270 *hSession, int wait); | |
| 56 | - | |
| 57 | -static gboolean IO_prepare(GSource *source, gint *timeout); | |
| 58 | -static gboolean IO_check(GSource *source); | |
| 59 | -static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer user_data); | |
| 60 | -static void IO_finalize(GSource *source); /* Can be NULL */ | |
| 61 | -static gboolean IO_closure(gpointer data); | |
| 62 | - | |
| 63 | -/*---[ Structs ]-------------------------------------------------------------------------------------------*/ | |
| 64 | - | |
| 65 | - typedef struct _IO_Source | |
| 66 | - { | |
| 67 | - GSource gsrc; | |
| 68 | - GPollFD poll; | |
| 69 | -#if defined(_WIN32) | |
| 70 | - HANDLE source; | |
| 71 | -#else | |
| 72 | - int source; | |
| 73 | -#endif // _WIN32 | |
| 74 | - void (*fn)(H3270 *session); | |
| 75 | - H3270 *session; | |
| 76 | - } IO_Source; | |
| 77 | - | |
| 78 | - typedef struct _timer | |
| 79 | - { | |
| 80 | - unsigned char remove; | |
| 81 | - void (*fn)(H3270 *session); | |
| 82 | - H3270 *session; | |
| 83 | - } TIMER; | |
| 84 | - | |
| 85 | - static GSourceFuncs IOSources = | |
| 86 | - { | |
| 87 | - IO_prepare, | |
| 88 | - IO_check, | |
| 89 | - IO_dispatch, | |
| 90 | - IO_finalize, | |
| 91 | - IO_closure, | |
| 92 | - NULL | |
| 93 | - }; | |
| 94 | - | |
| 95 | -/*---[ Implement ]-----------------------------------------------------------------------------------------*/ | |
| 96 | - | |
| 97 | -#ifdef _WIN32 | |
| 98 | -static void * AddSource(HANDLE source, H3270 *session, gushort events, void (*fn)(H3270 *session)) | |
| 99 | -#else | |
| 100 | -static void * AddSource(int source, H3270 *session, gushort events, void (*fn)(H3270 *session)) | |
| 101 | -#endif // _WIN32 | |
| 102 | -{ | |
| 103 | - IO_Source *src = (IO_Source *) g_source_new(&IOSources,sizeof(IO_Source)); | |
| 104 | - | |
| 105 | - src->source = source; | |
| 106 | - src->fn = fn; | |
| 107 | - src->poll.fd = (int) source; | |
| 108 | - src->poll.events = events; | |
| 109 | - src->session = session; | |
| 110 | - | |
| 111 | - g_source_attach((GSource *) src,NULL); | |
| 112 | - g_source_add_poll((GSource *) src,&src->poll); | |
| 113 | - | |
| 114 | - return src; | |
| 115 | -} | |
| 116 | - | |
| 117 | -#ifdef _WIN32 | |
| 118 | -static void * static_AddInput(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | |
| 119 | -#else | |
| 120 | -static void * static_AddInput(int source, H3270 *session, void (*fn)(H3270 *session)) | |
| 121 | -#endif // _WIN32 | |
| 122 | -{ | |
| 123 | - return AddSource(source,session,G_IO_IN|G_IO_HUP|G_IO_ERR,fn); | |
| 124 | -} | |
| 125 | - | |
| 126 | -static void static_RemoveSource(void *id) | |
| 127 | -{ | |
| 128 | - if(id) | |
| 129 | - g_source_destroy((GSource *) id); | |
| 130 | -} | |
| 131 | - | |
| 132 | -#if defined(_WIN32) | |
| 133 | -static void * static_AddExcept(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | |
| 134 | -{ | |
| 135 | - return 0; | |
| 136 | -} | |
| 137 | -#else | |
| 138 | -static void * static_AddExcept(int source, H3270 *session, void (*fn)(H3270 *session)) | |
| 139 | -{ | |
| 140 | - return AddSource(source,session,G_IO_HUP|G_IO_ERR,fn); | |
| 141 | -} | |
| 142 | -#endif // _WIN32 | |
| 143 | - | |
| 144 | -static gboolean do_timer(TIMER *t) | |
| 145 | -{ | |
| 146 | - if(!t->remove) | |
| 147 | - t->fn(t->session); | |
| 148 | - return FALSE; | |
| 149 | -} | |
| 150 | - | |
| 151 | -static void * static_AddTimeOut(unsigned long interval, H3270 *session, void (*proc)(H3270 *session)) | |
| 152 | -{ | |
| 153 | - TIMER *t = g_malloc0(sizeof(TIMER)); | |
| 154 | - | |
| 155 | - t->fn = proc; | |
| 156 | - t->session = session; | |
| 157 | - | |
| 158 | - g_timeout_add_full(G_PRIORITY_DEFAULT, (guint) interval, (GSourceFunc) do_timer, t, g_free); | |
| 159 | - | |
| 160 | - return t; | |
| 161 | -} | |
| 162 | - | |
| 163 | -static void static_RemoveTimeOut(void * timer) | |
| 164 | -{ | |
| 165 | - ((TIMER *) timer)->remove++; | |
| 166 | -} | |
| 167 | - | |
| 168 | -static gboolean IO_prepare(GSource *source, gint *timeout) | |
| 169 | -{ | |
| 170 | - /* | |
| 171 | - * Called before all the file descriptors are polled. | |
| 172 | - * If the source can determine that it is ready here | |
| 173 | - * (without waiting for the results of the poll() call) | |
| 174 | - * it should return TRUE. | |
| 175 | - * | |
| 176 | - * It can also return a timeout_ value which should be the maximum | |
| 177 | - * timeout (in milliseconds) which should be passed to the poll() call. | |
| 178 | - * The actual timeout used will be -1 if all sources returned -1, | |
| 179 | - * or it will be the minimum of all the timeout_ values | |
| 180 | - * returned which were >= 0. | |
| 181 | - * | |
| 182 | - */ | |
| 183 | - return 0; | |
| 184 | -} | |
| 185 | - | |
| 186 | -static gboolean IO_check(GSource *source) | |
| 187 | -{ | |
| 188 | - /* | |
| 189 | - * Called after all the file descriptors are polled. | |
| 190 | - * The source should return TRUE if it is ready to be dispatched. | |
| 191 | - * Note that some time may have passed since the previous prepare | |
| 192 | - * function was called, so the source should be checked again here. | |
| 193 | - * | |
| 194 | - */ | |
| 195 | -#if defined(_WIN32) /*[*/ | |
| 196 | - | |
| 197 | - if(WaitForSingleObject(((IO_Source *) source)->source,0) == WAIT_OBJECT_0) | |
| 198 | - return TRUE; | |
| 199 | - | |
| 200 | -#else /*][*/ | |
| 201 | - | |
| 202 | - struct pollfd fds; | |
| 203 | - | |
| 204 | - memset(&fds,0,sizeof(fds)); | |
| 205 | - | |
| 206 | - fds.fd = ((IO_Source *) source)->poll.fd; | |
| 207 | - fds.events = ((IO_Source *) source)->poll.events; | |
| 208 | - | |
| 209 | - if(poll(&fds,1,0) > 0) | |
| 210 | - return TRUE; | |
| 211 | - | |
| 212 | -#endif /*]*/ | |
| 213 | - | |
| 214 | - return FALSE; | |
| 215 | -} | |
| 216 | - | |
| 217 | -static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) | |
| 218 | -{ | |
| 219 | - /* | |
| 220 | - * Called to dispatch the event source, | |
| 221 | - * after it has returned TRUE in either its prepare or its check function. | |
| 222 | - * The dispatch function is passed in a callback function and data. | |
| 223 | - * The callback function may be NULL if the source was never connected | |
| 224 | - * to a callback using g_source_set_callback(). The dispatch function | |
| 225 | - * should call the callback function with user_data and whatever additional | |
| 226 | - * parameters are needed for this type of event source. | |
| 227 | - */ | |
| 228 | - ((IO_Source *) source)->fn(((IO_Source *) source)->session); | |
| 229 | - return TRUE; | |
| 230 | -} | |
| 231 | - | |
| 232 | -static void IO_finalize(GSource *source) | |
| 233 | -{ | |
| 234 | - | |
| 235 | -} | |
| 236 | - | |
| 237 | -static gboolean IO_closure(gpointer data) | |
| 238 | -{ | |
| 239 | - return 0; | |
| 240 | -} | |
| 241 | - | |
| 242 | -struct bgParameter | |
| 243 | -{ | |
| 244 | - gboolean running; | |
| 245 | - gboolean timer; | |
| 246 | - H3270 *session; | |
| 247 | - int rc; | |
| 248 | - int(*callback)(H3270 *session, void *); | |
| 249 | - void *parm; | |
| 250 | - | |
| 251 | -}; | |
| 252 | - | |
| 253 | -gpointer BgCall(struct bgParameter *p) | |
| 254 | -{ | |
| 255 | -// trace("%s starts",__FUNCTION__); | |
| 256 | - p->rc = p->callback(p->session, p->parm); | |
| 257 | - p->running = FALSE; | |
| 258 | -// trace("%s ends",__FUNCTION__); | |
| 259 | - return 0; | |
| 260 | -} | |
| 261 | - | |
| 262 | -static gboolean wait_for_thread(struct bgParameter *p) | |
| 263 | -{ | |
| 264 | - if(!p->running) | |
| 265 | - { | |
| 266 | - p->timer = 0; | |
| 267 | - return FALSE; | |
| 268 | - } | |
| 269 | - return TRUE; | |
| 270 | -} | |
| 271 | - | |
| 272 | -static int static_CallAndWait(int(*callback)(H3270 *session, void *), H3270 *session, void *parm) | |
| 273 | -{ | |
| 274 | - struct bgParameter p = { TRUE, TRUE, session, -1, callback, parm }; | |
| 275 | - GThread * thread; | |
| 276 | - | |
| 277 | -// trace("Starting auxiliary thread for callback %p",callback); | |
| 278 | - | |
| 279 | - p.running = TRUE; | |
| 280 | - p.timer = TRUE; | |
| 281 | - | |
| 282 | - thread = g_thread_create( (GThreadFunc) BgCall, &p, 0, NULL); | |
| 283 | - | |
| 284 | - if(!thread) | |
| 285 | - { | |
| 286 | - g_error("Can't start background thread"); | |
| 287 | - return -1; | |
| 288 | - } | |
| 289 | - | |
| 290 | - g_timeout_add(50,(GSourceFunc) wait_for_thread,(gpointer) &p); | |
| 291 | - | |
| 292 | - while(p.timer) | |
| 293 | - g_main_context_iteration(g_main_loop_get_context(main_loop),TRUE); | |
| 294 | - | |
| 295 | - return p.rc; | |
| 296 | -} | |
| 297 | - | |
| 298 | -static int static_Sleep(H3270 *hSession, int seconds) | |
| 299 | -{ | |
| 300 | - time_t end = time(0) + seconds; | |
| 301 | - | |
| 302 | - while(time(0) < end) | |
| 303 | - g_main_iteration(TRUE); | |
| 304 | - | |
| 305 | - return 0; | |
| 306 | -} | |
| 307 | - | |
| 308 | -static int static_RunPendingEvents(H3270 *hSession, int wait) | |
| 309 | -{ | |
| 310 | - GMainContext *context = g_main_loop_get_context(main_loop); | |
| 311 | - int rc = 0; | |
| 312 | - while(g_main_context_pending(context)) | |
| 313 | - { | |
| 314 | - rc = 1; | |
| 315 | - g_main_context_iteration(context,FALSE); | |
| 316 | - } | |
| 317 | - | |
| 318 | - if(wait) | |
| 319 | - g_main_context_iteration(context,TRUE); | |
| 320 | - | |
| 321 | - return rc; | |
| 322 | -} | |
| 323 | - | |
| 324 | -static void beep(H3270 *session) | |
| 325 | -{ | |
| 326 | -} | |
| 327 | - | |
| 328 | -void pw3270_dbus_register_io_handlers(void) | |
| 329 | -{ | |
| 330 | - static const struct lib3270_callbacks hdl = | |
| 331 | - { | |
| 332 | - sizeof(struct lib3270_callbacks), | |
| 333 | - | |
| 334 | - static_AddTimeOut, | |
| 335 | - static_RemoveTimeOut, | |
| 336 | - | |
| 337 | - static_AddInput, | |
| 338 | - static_RemoveSource, | |
| 339 | - | |
| 340 | - static_AddExcept, | |
| 341 | - | |
| 342 | -#ifdef G_THREADS_ENABLED | |
| 343 | - static_CallAndWait, | |
| 344 | -#else | |
| 345 | - NULL, | |
| 346 | -#endif | |
| 347 | - | |
| 348 | - static_Sleep, | |
| 349 | - static_RunPendingEvents, | |
| 350 | - beep | |
| 351 | - | |
| 352 | - }; | |
| 353 | - | |
| 354 | - #error Need rewrite | |
| 355 | - | |
| 356 | - if(lib3270_register_handlers(&hdl)) | |
| 357 | - { | |
| 358 | - g_error("%s","Can't set lib3270 I/O handlers"); | |
| 359 | - } | |
| 360 | - | |
| 361 | -} |
src/dbus3270/main.c
| ... | ... | @@ -1,172 +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. | |
| 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 <glib.h> | |
| 35 | -#include <dbus/dbus.h> | |
| 36 | -#include <dbus/dbus-glib-lowlevel.h> | |
| 37 | -#include <dbus/dbus-glib.h> | |
| 38 | - | |
| 39 | -#include <pw3270.h> | |
| 40 | -#include <pw3270/plugin.h> | |
| 41 | - | |
| 42 | -#include "service.h" | |
| 43 | -#include "dbus-glue.h" | |
| 44 | - | |
| 45 | -#include <gtk/gtk.h> | |
| 46 | - | |
| 47 | -/*---[ Globals ]---------------------------------------------------------------------------------*/ | |
| 48 | - | |
| 49 | - static DBusGConnection * connection = NULL; | |
| 50 | - static DBusGProxy * proxy = NULL; | |
| 51 | - static gchar * service_name = NULL; | |
| 52 | - | |
| 53 | - | |
| 54 | -/*---[ Implement ]-------------------------------------------------------------------------------*/ | |
| 55 | - | |
| 56 | - LIB3270_EXPORT int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal) | |
| 57 | - { | |
| 58 | - | |
| 59 | - GError * error = NULL; | |
| 60 | - guint result; | |
| 61 | - char session_id = 0; | |
| 62 | - char id = 'a'; | |
| 63 | - | |
| 64 | - connection = dbus_g_bus_get_private(DBUS_BUS_SESSION, g_main_context_default(), &error); | |
| 65 | - if(error) | |
| 66 | - { | |
| 67 | - GtkWidget *dialog = gtk_message_dialog_new( | |
| 68 | - GTK_WINDOW(window), | |
| 69 | - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 70 | - GTK_MESSAGE_ERROR, | |
| 71 | - GTK_BUTTONS_OK, | |
| 72 | - _( "Can't connect to DBUS server" )); | |
| 73 | - | |
| 74 | - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); | |
| 75 | - | |
| 76 | - g_message("Error \"%s\" getting session dbus",error->message); | |
| 77 | - | |
| 78 | - g_error_free(error); | |
| 79 | - | |
| 80 | - gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 81 | - gtk_widget_destroy(dialog); | |
| 82 | - | |
| 83 | - return -1; | |
| 84 | - } | |
| 85 | - | |
| 86 | - proxy = dbus_g_proxy_new_for_name(connection,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS); | |
| 87 | - | |
| 88 | - for(id='a'; id < 'z' && !error && !service_name; id++) | |
| 89 | - { | |
| 90 | - gboolean has_owner = FALSE; | |
| 91 | - | |
| 92 | - service_name = g_strdup_printf("br.com.bb.%s.%c",pw3270_get_session_name(window),(int) id); | |
| 93 | - | |
| 94 | - org_freedesktop_DBus_name_has_owner(proxy, service_name, &has_owner, NULL); | |
| 95 | - | |
| 96 | - if(has_owner) | |
| 97 | - { | |
| 98 | - trace("Service \"%s\" has owner",service_name) | |
| 99 | - g_free(service_name); | |
| 100 | - service_name = NULL; | |
| 101 | - } | |
| 102 | - else | |
| 103 | - { | |
| 104 | - session_id = id; | |
| 105 | - g_message("DBUS service name is %s",service_name); | |
| 106 | - org_freedesktop_DBus_request_name(proxy, service_name, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error); | |
| 107 | - } | |
| 108 | - } | |
| 109 | - | |
| 110 | - if(error) | |
| 111 | - { | |
| 112 | - GtkWidget *dialog = gtk_message_dialog_new( | |
| 113 | - GTK_WINDOW(window), | |
| 114 | - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 115 | - GTK_MESSAGE_ERROR, | |
| 116 | - GTK_BUTTONS_OK, | |
| 117 | - _( "Can't get DBUS object name" )); | |
| 118 | - | |
| 119 | - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); | |
| 120 | - | |
| 121 | - g_message("Error \"%s\" requesting DBUS name",error->message); | |
| 122 | - | |
| 123 | - g_error_free(error); | |
| 124 | - | |
| 125 | - gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 126 | - gtk_widget_destroy(dialog); | |
| 127 | - | |
| 128 | - return -1; | |
| 129 | - } | |
| 130 | - | |
| 131 | - if(session_id) | |
| 132 | - { | |
| 133 | - gchar * path = g_strdup_printf("/br/com/bb/%s",pw3270_get_session_name(window)); | |
| 134 | - gchar * session = g_strdup_printf("%s:%c",pw3270_get_session_name(window),g_ascii_toupper(session_id)); | |
| 135 | - pw3270_set_session_name(window,session); | |
| 136 | - g_free(session); | |
| 137 | - | |
| 138 | - g_message("DBUS service path is %s",path); | |
| 139 | - | |
| 140 | - pw3270_dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,path); | |
| 141 | - | |
| 142 | - g_free(path); | |
| 143 | - } | |
| 144 | - | |
| 145 | - return 0; | |
| 146 | - } | |
| 147 | - | |
| 148 | - LIB3270_EXPORT int pw3270_plugin_stop(GtkWidget *window, GtkWidget *terminal) | |
| 149 | - { | |
| 150 | - if(service_name) | |
| 151 | - { | |
| 152 | - // org_freedesktop_DBus_release_name | |
| 153 | - | |
| 154 | - g_free(service_name); | |
| 155 | - service_name = NULL; | |
| 156 | - } | |
| 157 | - return 0; | |
| 158 | - } | |
| 159 | - | |
| 160 | - void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 161 | - { | |
| 162 | - gtk_main_quit(); | |
| 163 | - dbus_g_method_return(context,0); | |
| 164 | - } | |
| 165 | - | |
| 166 | - H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object) | |
| 167 | - { | |
| 168 | - return lib3270_get_default_session_handle(); | |
| 169 | - } | |
| 170 | - | |
| 171 | - | |
| 172 | - |
src/dbus3270/misc.c
| ... | ... | @@ -1,47 +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. | |
| 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 misc.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 "globals.h" | |
| 37 | - | |
| 38 | -/*---[ Implement ]-------------------------------------------------------------------------------*/ | |
| 39 | - | |
| 40 | -gpointer pw3270_dbus_register_object(DBusGConnection *connection,DBusGProxy *proxy,GType object_type,const DBusGObjectInfo *info,const gchar *path) | |
| 41 | -{ | |
| 42 | - GObject *object = g_object_new (object_type, NULL); | |
| 43 | - dbus_g_object_type_install_info (object_type, info); | |
| 44 | - dbus_g_connection_register_g_object (connection, path, object); | |
| 45 | - return object; | |
| 46 | -} | |
| 47 | - |
src/dbus3270/service.h
| ... | ... | @@ -1,138 +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. | |
| 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 service.h 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 | -#ifndef _PW3270_DBUS_SERVICE_H | |
| 33 | - | |
| 34 | - #define _PW3270_DBUS_SERVICE_H 1 | |
| 35 | - | |
| 36 | - #define ENABLE_NLS | |
| 37 | - #define GETTEXT_PACKAGE PACKAGE_NAME | |
| 38 | - | |
| 39 | - #include "globals.h" | |
| 40 | - | |
| 41 | - #define PW3270_TYPE_DBUS (pw3270_dbus_get_type ()) | |
| 42 | - #define PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PW3270_TYPE_DBUS, PW3270Dbus)) | |
| 43 | - #define PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_DBUS, PW3270DbusClass)) | |
| 44 | - #define IS_PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PW3270_TYPE_DBUS)) | |
| 45 | - #define IS_PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_DBUS)) | |
| 46 | - #define PW3270_DBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_DBUS, PW3270DbusClass)) | |
| 47 | - | |
| 48 | - G_BEGIN_DECLS | |
| 49 | - | |
| 50 | - typedef struct _PW3270Dbus PW3270Dbus; | |
| 51 | - typedef struct _PW3270DbusClass PW3270DbusClass; | |
| 52 | - | |
| 53 | - struct _PW3270Dbus | |
| 54 | - { | |
| 55 | - GObject parent; | |
| 56 | - }; | |
| 57 | - | |
| 58 | - struct _PW3270DbusClass | |
| 59 | - { | |
| 60 | - GObjectClass parent; | |
| 61 | - }; | |
| 62 | - | |
| 63 | - PW3270Dbus * pw3270_dbus_new (void); | |
| 64 | - GType pw3270_dbus_get_type (void); | |
| 65 | - | |
| 66 | - void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 67 | - void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 68 | - void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context); | |
| 69 | - void pw3270_dbus_get_ur_l(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 70 | - void pw3270_dbus_set_ur_l(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context); | |
| 71 | - void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 72 | - | |
| 73 | - void pw3270_dbus_get_message_id(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 74 | - void pw3270_dbus_get_connection_state(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 75 | - void pw3270_dbus_get_secure_state(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 76 | - | |
| 77 | - void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 78 | - H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object); | |
| 79 | - GError * pw3270_dbus_get_error_from_errno(int code); | |
| 80 | - | |
| 81 | - void pw3270_dbus_is_connected(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 82 | - void pw3270_dbus_is_ready(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 83 | - void pw3270_dbus_in_tn3270_e(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 84 | - | |
| 85 | - void pw3270_dbus_set_cursor_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context); | |
| 86 | - void pw3270_dbus_set_cursor_address(PW3270Dbus *object, int addr, DBusGMethodInvocation *context); | |
| 87 | - void pw3270_dbus_get_cursor_address(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 88 | - | |
| 89 | - void pw3270_dbus_get_screen_width(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 90 | - void pw3270_dbus_get_screen_height(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 91 | - void pw3270_dbus_get_screen_length(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 92 | - | |
| 93 | - void pw3270_dbus_set_toggle(PW3270Dbus *object, int id, int value, DBusGMethodInvocation *context); | |
| 94 | - | |
| 95 | - void pw3270_dbus_wait_for_ready(PW3270Dbus *object, int timeout, DBusGMethodInvocation *context); | |
| 96 | - | |
| 97 | - void pw3270_dbus_get_field_start(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); | |
| 98 | - void pw3270_dbus_get_field_length(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); | |
| 99 | - void pw3270_dbus_get_next_unprotected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); | |
| 100 | - | |
| 101 | - void pw3270_dbus_get_is_protected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); | |
| 102 | - void pw3270_dbus_get_is_protected_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context); | |
| 103 | - | |
| 104 | - void pw3270_dbus_set_script(PW3270Dbus *object, const gchar *text, int mode, DBusGMethodInvocation *context); | |
| 105 | - | |
| 106 | - void pw3270_dbus_show_popup(PW3270Dbus *object, int id, const gchar *title, const gchar *msg, const gchar *text, DBusGMethodInvocation *context); | |
| 107 | - | |
| 108 | - void pw3270_dbus_action(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context); | |
| 109 | - | |
| 110 | - // Actions | |
| 111 | - void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 112 | - void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context); | |
| 113 | - void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context); | |
| 114 | - void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context); | |
| 115 | - void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, char lf, DBusGMethodInvocation *context); | |
| 116 | - void pw3270_dbus_get_text(PW3270Dbus *object, int offset, int len, char lf, DBusGMethodInvocation *context); | |
| 117 | - void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *text, char lf, DBusGMethodInvocation *context); | |
| 118 | - void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context); | |
| 119 | - | |
| 120 | - void pw3270_dbus_set_clipboard(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context); | |
| 121 | - void pw3270_dbus_get_clipboard(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 122 | - | |
| 123 | - void pw3270_dbus_get_display_charset(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 124 | - void pw3270_dbus_get_host_charset(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 125 | - void pw3270_dbus_set_host_charset(PW3270Dbus *object, const gchar *charset, DBusGMethodInvocation *context); | |
| 126 | - void pw3270_dbus_erase_eof(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 127 | - void pw3270_dbus_print(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 128 | - | |
| 129 | - void pw3270_dbus_asc2ebc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context); | |
| 130 | - void pw3270_dbus_ebc2asc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context); | |
| 131 | - | |
| 132 | - void pw3270_dbus_filetransfer(PW3270Dbus *object, const gchar *local, const gchar *remote, int flags, int lrecl, int blksize, int primspace, int secspace, int dft, DBusGMethodInvocation *context); | |
| 133 | - | |
| 134 | - void pw3270_dbus_set_unlock_delay(PW3270Dbus *object, int value, DBusGMethodInvocation *context); | |
| 135 | - | |
| 136 | - G_END_DECLS | |
| 137 | - | |
| 138 | -#endif // _PW3270_DBUS_SERVICE_H |
| ... | ... | @@ -0,0 +1,41 @@ |
| 1 | +/* | |
| 2 | + * "Software G3270, 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 config.h 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 de Mendonça) | |
| 27 | + * | |
| 28 | + */ | |
| 29 | + | |
| 30 | +#ifndef LIBV3270_CONFIG_INCLUDED | |
| 31 | + | |
| 32 | + #define LIBV3270_CONFIG_INCLUDED 1 | |
| 33 | + | |
| 34 | + #undef PACKAGE_NAME | |
| 35 | + #undef PACKAGE_VERSION | |
| 36 | + #undef PACKAGE_RELEASE | |
| 37 | + | |
| 38 | + #undef HAVE_GNOME | |
| 39 | + #undef HAVE_GTKMAC | |
| 40 | + | |
| 41 | +#endif /* LIBV3270_CONFIG_INCLUDED */ | ... | ... |
| ... | ... | @@ -0,0 +1,122 @@ |
| 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 "daemon.h" | |
| 42 | +#include "dbus-glue.h" | |
| 43 | + | |
| 44 | +#define PW3270_DBUS_SERVICE_PATH "/br/com/bb/pw3270" | |
| 45 | +#define PW3270_DBUS_SERVICE "br.com.bb.pw3270" | |
| 46 | + | |
| 47 | + | |
| 48 | +/*---[ Globals ]---------------------------------------------------------------------------------*/ | |
| 49 | + | |
| 50 | + static DBusGConnection * connection = NULL; | |
| 51 | + static DBusGProxy * proxy = NULL; | |
| 52 | + static H3270 * hSession = NULL; | |
| 53 | + | |
| 54 | + GMainLoop * main_loop = NULL; | |
| 55 | + | |
| 56 | + | |
| 57 | +/*---[ Implement ]-------------------------------------------------------------------------------*/ | |
| 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 | + pw3270_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 | +static void loghandler(H3270 *session, const char *module, int rc, const char *fmt, va_list args) | |
| 82 | +{ | |
| 83 | + g_logv(module,rc ? G_LOG_LEVEL_WARNING : G_LOG_LEVEL_MESSAGE, fmt, args); | |
| 84 | +} | |
| 85 | + | |
| 86 | +int main(int numpar, char *param[]) | |
| 87 | +{ | |
| 88 | + g_type_init (); | |
| 89 | + | |
| 90 | + if (!g_thread_supported ()) | |
| 91 | + g_thread_init (NULL); | |
| 92 | + | |
| 93 | + dbus_g_thread_init (); | |
| 94 | + | |
| 95 | + lib3270_set_log_handler(loghandler); | |
| 96 | + pw3270_dbus_register_io_handlers(); | |
| 97 | + | |
| 98 | + hSession = lib3270_session_new(""); | |
| 99 | + | |
| 100 | + main_loop = g_main_loop_new (NULL, FALSE); | |
| 101 | + | |
| 102 | + if(initialize()) | |
| 103 | + return -1; | |
| 104 | + | |
| 105 | + g_main_loop_run(main_loop); | |
| 106 | + | |
| 107 | + lib3270_session_free(hSession); | |
| 108 | + | |
| 109 | + return 0; | |
| 110 | +} | |
| 111 | + | |
| 112 | +void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 113 | +{ | |
| 114 | + g_main_loop_quit(main_loop); | |
| 115 | + dbus_g_method_return(context,0); | |
| 116 | +} | |
| 117 | + | |
| 118 | +H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object) | |
| 119 | +{ | |
| 120 | + return hSession; | |
| 121 | +} | |
| 122 | + | ... | ... |
| ... | ... | @@ -0,0 +1,46 @@ |
| 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 "service.h" | |
| 37 | + | |
| 38 | +/*---[ Globals ]---------------------------------------------------------------------------------*/ | |
| 39 | + | |
| 40 | + G_GNUC_INTERNAL GMainLoop * main_loop; | |
| 41 | + | |
| 42 | + | |
| 43 | +/*---[ Prototipes ]------------------------------------------------------------------------------*/ | |
| 44 | + | |
| 45 | + G_GNUC_INTERNAL void pw3270_dbus_register_io_handlers(void); | |
| 46 | + | ... | ... |
| ... | ... | @@ -0,0 +1,59 @@ |
| 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 globals.h 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 | +#ifndef PW3270_DBUS_GLOBALS_H_INCLUDED | |
| 33 | + | |
| 34 | + #define PW3270_DBUS_GLOBALS_H_INCLUDED 1 | |
| 35 | + | |
| 36 | + #include <libintl.h> | |
| 37 | + #include <glib/gi18n.h> | |
| 38 | + | |
| 39 | + #include <errno.h> | |
| 40 | + #include <lib3270.h> | |
| 41 | + #include <lib3270/log.h> | |
| 42 | + #include <glib.h> | |
| 43 | + | |
| 44 | + // | |
| 45 | + // Disabling warning on unused-function defined in dbus-glib-bindings.h | |
| 46 | + // warning: 'org_freedesktop_DBus_reload_config' defined but not used [-Wunused-function] ... | |
| 47 | + // | |
| 48 | + #pragma GCC diagnostic ignored "-Wunused-function" | |
| 49 | + | |
| 50 | + #include <dbus/dbus-glib.h> | |
| 51 | + #include <dbus/dbus-glib-bindings.h> | |
| 52 | + #include <dbus/dbus-glib-lowlevel.h> | |
| 53 | + | |
| 54 | + #define ERROR_DOMAIN g_quark_from_static_string("pw3270DBUS") | |
| 55 | + | |
| 56 | + G_GNUC_INTERNAL gpointer pw3270_dbus_register_object (DBusGConnection *connection,DBusGProxy *proxy,GType object_type,const DBusGObjectInfo *info,const gchar *path); | |
| 57 | + | |
| 58 | + | |
| 59 | +#endif // PW3270_DBUS_GLOBALS_H_INCLUDED | ... | ... |
| ... | ... | @@ -0,0 +1,622 @@ |
| 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 <gtk/gtk.h> | |
| 38 | +#include <dbus/dbus.h> | |
| 39 | +#include <dbus/dbus-glib-lowlevel.h> | |
| 40 | +#include <dbus/dbus-glib.h> | |
| 41 | + | |
| 42 | +#include <config.h> | |
| 43 | +#include <lib3270.h> | |
| 44 | +#include <pw3270.h> | |
| 45 | +#include <v3270.h> | |
| 46 | +#include <lib3270/actions.h> | |
| 47 | +#include <lib3270/charset.h> | |
| 48 | + | |
| 49 | +#include "service.h" | |
| 50 | + | |
| 51 | +/*---[ Globals ]---------------------------------------------------------------------------------*/ | |
| 52 | + | |
| 53 | + | |
| 54 | +/*---[ Implement ]-------------------------------------------------------------------------------*/ | |
| 55 | + | |
| 56 | +G_DEFINE_TYPE(PW3270Dbus, pw3270_dbus, G_TYPE_OBJECT) | |
| 57 | + | |
| 58 | +static void pw3270_dbus_finalize(GObject *object) | |
| 59 | +{ | |
| 60 | + G_OBJECT_CLASS(pw3270_dbus_parent_class)->finalize (object); | |
| 61 | +} | |
| 62 | + | |
| 63 | + | |
| 64 | +static void pw3270_dbus_class_init(PW3270DbusClass *klass) | |
| 65 | +{ | |
| 66 | + GObjectClass *object_class; | |
| 67 | + object_class = G_OBJECT_CLASS (klass); | |
| 68 | + object_class->finalize = pw3270_dbus_finalize; | |
| 69 | +} | |
| 70 | + | |
| 71 | +static void pw3270_dbus_init(PW3270Dbus *object) | |
| 72 | +{ | |
| 73 | + | |
| 74 | +} | |
| 75 | + | |
| 76 | +PW3270Dbus * pw3270_dbus_new(void) | |
| 77 | +{ | |
| 78 | + return g_object_new(PW3270_TYPE_DBUS, NULL); | |
| 79 | +} | |
| 80 | + | |
| 81 | +void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 82 | +{ | |
| 83 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 84 | +#ifdef PACKAGE_REVISION | |
| 85 | + dbus_g_method_return(context,PACKAGE_REVISION); | |
| 86 | +#else | |
| 87 | + dbus_g_method_return(context,BUILD_DATE); | |
| 88 | +#endif | |
| 89 | +} | |
| 90 | + | |
| 91 | +void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context) | |
| 92 | +{ | |
| 93 | + H3270 *hSession = pw3270_dbus_get_session_handle(PW3270_DBUS(object)); | |
| 94 | + | |
| 95 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 96 | + | |
| 97 | + if(uri && *uri) | |
| 98 | + { | |
| 99 | + lib3270_set_url(hSession,uri); | |
| 100 | + g_message("Connecting to \"%s\" by remote request",lib3270_get_url(hSession)); | |
| 101 | + } | |
| 102 | + else | |
| 103 | + { | |
| 104 | + g_message("%s","Connecting by remote request"); | |
| 105 | + } | |
| 106 | + | |
| 107 | + dbus_g_method_return(context,lib3270_reconnect(hSession,0)); | |
| 108 | +} | |
| 109 | + | |
| 110 | +void pw3270_dbus_set_ur_l(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context) | |
| 111 | +{ | |
| 112 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 113 | + | |
| 114 | + g_message("Changing host to \"%s\" by remote request",uri); | |
| 115 | + | |
| 116 | + dbus_g_method_return(context,lib3270_set_url(pw3270_dbus_get_session_handle(PW3270_DBUS(object)),uri) != 0); | |
| 117 | +} | |
| 118 | + | |
| 119 | +void pw3270_dbus_get_ur_l(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 120 | +{ | |
| 121 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 122 | + dbus_g_method_return(context,lib3270_get_url(pw3270_dbus_get_session_handle(PW3270_DBUS(object)))); | |
| 123 | +} | |
| 124 | + | |
| 125 | + | |
| 126 | +void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 127 | +{ | |
| 128 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 129 | + | |
| 130 | + g_message("Disconnecting by remote request"); | |
| 131 | + lib3270_disconnect(pw3270_dbus_get_session_handle(object)); | |
| 132 | + dbus_g_method_return(context,0); | |
| 133 | +} | |
| 134 | + | |
| 135 | +void pw3270_dbus_get_message_id(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 136 | +{ | |
| 137 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 138 | + dbus_g_method_return(context,lib3270_get_program_message(pw3270_dbus_get_session_handle(object))); | |
| 139 | +} | |
| 140 | + | |
| 141 | +void pw3270_dbus_get_connection_state(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 142 | +{ | |
| 143 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 144 | + dbus_g_method_return(context,lib3270_get_connection_state(pw3270_dbus_get_session_handle(object))); | |
| 145 | +} | |
| 146 | + | |
| 147 | +void pw3270_dbus_get_secure_state(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 148 | +{ | |
| 149 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 150 | + dbus_g_method_return(context,lib3270_get_secure(pw3270_dbus_get_session_handle(object))); | |
| 151 | +} | |
| 152 | + | |
| 153 | +GError * pw3270_dbus_get_error_from_errno(int code) | |
| 154 | +{ | |
| 155 | + return g_error_new(ERROR_DOMAIN,code,"%s",g_strerror(code)); | |
| 156 | +} | |
| 157 | + | |
| 158 | +int pw3270_dbus_check_valid_state(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 159 | +{ | |
| 160 | + H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
| 161 | + GError * error = NULL; | |
| 162 | + | |
| 163 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 164 | + | |
| 165 | + if(!lib3270_is_connected(hSession)) | |
| 166 | + { | |
| 167 | + error = pw3270_dbus_get_error_from_errno(ENOTCONN); | |
| 168 | + } | |
| 169 | + else | |
| 170 | + { | |
| 171 | + LIB3270_MESSAGE state = lib3270_get_program_message(hSession); | |
| 172 | + | |
| 173 | + switch(state) | |
| 174 | + { | |
| 175 | + case LIB3270_MESSAGE_NONE: | |
| 176 | + return 0; | |
| 177 | + | |
| 178 | + case LIB3270_MESSAGE_DISCONNECTED: | |
| 179 | + error = pw3270_dbus_get_error_from_errno(ENOTCONN); | |
| 180 | + break; | |
| 181 | + | |
| 182 | + case LIB3270_MESSAGE_MINUS: | |
| 183 | + case LIB3270_MESSAGE_PROTECTED: | |
| 184 | + case LIB3270_MESSAGE_NUMERIC: | |
| 185 | + case LIB3270_MESSAGE_OVERFLOW: | |
| 186 | + case LIB3270_MESSAGE_INHIBIT: | |
| 187 | + case LIB3270_MESSAGE_KYBDLOCK: | |
| 188 | + case LIB3270_MESSAGE_X: | |
| 189 | + error = g_error_new(ERROR_DOMAIN,-1,_( "State %04d can't accept requests" ),state); | |
| 190 | + break; | |
| 191 | + | |
| 192 | + case LIB3270_MESSAGE_SYSWAIT: | |
| 193 | + case LIB3270_MESSAGE_TWAIT: | |
| 194 | + case LIB3270_MESSAGE_CONNECTED: | |
| 195 | + case LIB3270_MESSAGE_AWAITING_FIRST: | |
| 196 | + error = pw3270_dbus_get_error_from_errno(EBUSY); | |
| 197 | + break; | |
| 198 | + | |
| 199 | + case LIB3270_MESSAGE_RESOLVING: | |
| 200 | + case LIB3270_MESSAGE_CONNECTING: | |
| 201 | + error = g_error_new(ERROR_DOMAIN,EINPROGRESS,_( "Connecting to host" )); | |
| 202 | + | |
| 203 | + case LIB3270_MESSAGE_USER: | |
| 204 | + error = g_error_new(ERROR_DOMAIN,-1,_( "Unexpected state %04d" ),state); | |
| 205 | + } | |
| 206 | + } | |
| 207 | + | |
| 208 | + if(error) | |
| 209 | + { | |
| 210 | + dbus_g_method_return_error(context,error); | |
| 211 | + g_error_free(error); | |
| 212 | + return -1; | |
| 213 | + } | |
| 214 | + | |
| 215 | + return 0; | |
| 216 | +} | |
| 217 | + | |
| 218 | +void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 219 | +{ | |
| 220 | + char * text; | |
| 221 | + gchar * utftext; | |
| 222 | + H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
| 223 | + | |
| 224 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 225 | + | |
| 226 | + if(pw3270_dbus_check_valid_state(object,context)) | |
| 227 | + return; | |
| 228 | + | |
| 229 | + text = lib3270_get_string_at_address(hSession,0,-1,'\n'); | |
| 230 | + | |
| 231 | + utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL); | |
| 232 | + | |
| 233 | + lib3270_free(text); | |
| 234 | + | |
| 235 | + dbus_g_method_return(context,utftext); | |
| 236 | + | |
| 237 | + g_free(utftext); | |
| 238 | + | |
| 239 | +} | |
| 240 | + | |
| 241 | +void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 242 | +{ | |
| 243 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 244 | + if(pw3270_dbus_check_valid_state(object,context)) | |
| 245 | + return; | |
| 246 | + dbus_g_method_return(context,lib3270_enter(pw3270_dbus_get_session_handle(object))); | |
| 247 | +} | |
| 248 | + | |
| 249 | +void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *utftext, DBusGMethodInvocation *context) | |
| 250 | +{ | |
| 251 | + gchar * text; | |
| 252 | + H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
| 253 | + | |
| 254 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 255 | + if(pw3270_dbus_check_valid_state(object,context)) | |
| 256 | + return; | |
| 257 | + | |
| 258 | + text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL); | |
| 259 | + | |
| 260 | + int sz = lib3270_set_string_at(hSession,row,col,(const unsigned char *) text); | |
| 261 | + | |
| 262 | + trace("%s returns %d",__FUNCTION__,sz); | |
| 263 | + dbus_g_method_return(context,sz); | |
| 264 | + | |
| 265 | + g_free(text); | |
| 266 | +} | |
| 267 | + | |
| 268 | +void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context) | |
| 269 | +{ | |
| 270 | + gchar * text; | |
| 271 | + H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
| 272 | + | |
| 273 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 274 | + if(pw3270_dbus_check_valid_state(object,context)) | |
| 275 | + return; | |
| 276 | + | |
| 277 | + text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL); | |
| 278 | + | |
| 279 | + dbus_g_method_return(context,lib3270_emulate_input(hSession,(const char *) text,-1,1)); | |
| 280 | + | |
| 281 | + g_free(text); | |
| 282 | +} | |
| 283 | + | |
| 284 | + | |
| 285 | +void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, char lf, DBusGMethodInvocation *context) | |
| 286 | +{ | |
| 287 | + gchar * text; | |
| 288 | + H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
| 289 | + | |
| 290 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 291 | + if(pw3270_dbus_check_valid_state(object,context)) | |
| 292 | + return; | |
| 293 | + | |
| 294 | + text = lib3270_get_string_at(hSession, row, col, len, lf); | |
| 295 | + if(!text) | |
| 296 | + { | |
| 297 | + GError *error = pw3270_dbus_get_error_from_errno(errno); | |
| 298 | + dbus_g_method_return_error(context,error); | |
| 299 | + g_error_free(error); | |
| 300 | + } | |
| 301 | + else | |
| 302 | + { | |
| 303 | + gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL); | |
| 304 | + | |
| 305 | + lib3270_free(text); | |
| 306 | + | |
| 307 | + dbus_g_method_return(context,utftext); | |
| 308 | + | |
| 309 | + g_free(utftext); | |
| 310 | + } | |
| 311 | + } | |
| 312 | + | |
| 313 | + void pw3270_dbus_get_text(PW3270Dbus *object, int offset, int len, char lf, DBusGMethodInvocation *context) | |
| 314 | + { | |
| 315 | + gchar * text; | |
| 316 | + H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
| 317 | + | |
| 318 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 319 | + if(pw3270_dbus_check_valid_state(object,context)) | |
| 320 | + return; | |
| 321 | + | |
| 322 | + if(len < 0) { | |
| 323 | + len = lib3270_get_length(hSession); | |
| 324 | + } | |
| 325 | + | |
| 326 | + text = lib3270_get_string_at_address(hSession,offset,len,lf); | |
| 327 | + if(!text) | |
| 328 | + { | |
| 329 | + GError *error = pw3270_dbus_get_error_from_errno(errno); | |
| 330 | + dbus_g_method_return_error(context,error); | |
| 331 | + g_error_free(error); | |
| 332 | + } | |
| 333 | + else | |
| 334 | + { | |
| 335 | + gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL); | |
| 336 | + | |
| 337 | + lib3270_free(text); | |
| 338 | + | |
| 339 | + debug("\n%s\n",utftext); | |
| 340 | + | |
| 341 | + dbus_g_method_return(context,utftext); | |
| 342 | + | |
| 343 | + g_free(utftext); | |
| 344 | + } | |
| 345 | + | |
| 346 | + } | |
| 347 | + | |
| 348 | + void pw3270_dbus_is_connected(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 349 | + { | |
| 350 | + trace("%s object=%p context=%p connected=%s",__FUNCTION__,object,context, lib3270_is_connected(pw3270_dbus_get_session_handle(object)) ? "Yes" : "No"); | |
| 351 | + dbus_g_method_return(context,lib3270_is_connected(pw3270_dbus_get_session_handle(object))); | |
| 352 | + } | |
| 353 | + | |
| 354 | + void pw3270_dbus_is_ready(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 355 | + { | |
| 356 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 357 | + dbus_g_method_return(context,lib3270_is_ready(pw3270_dbus_get_session_handle(object))); | |
| 358 | + } | |
| 359 | + | |
| 360 | + void pw3270_dbus_in_tn3270_e(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 361 | + { | |
| 362 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 363 | + dbus_g_method_return(context,lib3270_in_tn3270e(pw3270_dbus_get_session_handle(object))); | |
| 364 | + } | |
| 365 | + | |
| 366 | + void pw3270_dbus_wait_for_ready(PW3270Dbus *object, int timeout, DBusGMethodInvocation *context) | |
| 367 | + { | |
| 368 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 369 | + dbus_g_method_return(context,lib3270_wait_for_ready(pw3270_dbus_get_session_handle(object),timeout)); | |
| 370 | + } | |
| 371 | + | |
| 372 | + void pw3270_dbus_set_cursor_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context) | |
| 373 | + { | |
| 374 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 375 | + dbus_g_method_return(context,lib3270_set_cursor_position(pw3270_dbus_get_session_handle(object),row,col)); | |
| 376 | + } | |
| 377 | + | |
| 378 | + void pw3270_dbus_set_cursor_address(PW3270Dbus *object, int addr, DBusGMethodInvocation *context) | |
| 379 | + { | |
| 380 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 381 | + dbus_g_method_return(context,lib3270_set_cursor_address(pw3270_dbus_get_session_handle(object),addr)); | |
| 382 | + } | |
| 383 | + | |
| 384 | + void pw3270_dbus_get_cursor_address(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 385 | + { | |
| 386 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 387 | + dbus_g_method_return(context,lib3270_get_cursor_address(pw3270_dbus_get_session_handle(object))); | |
| 388 | + } | |
| 389 | + | |
| 390 | + void pw3270_dbus_get_screen_width(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 391 | + { | |
| 392 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 393 | + dbus_g_method_return(context,lib3270_get_width(pw3270_dbus_get_session_handle(object))); | |
| 394 | + } | |
| 395 | + | |
| 396 | + void pw3270_dbus_get_screen_height(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 397 | + { | |
| 398 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 399 | + dbus_g_method_return(context,lib3270_get_height(pw3270_dbus_get_session_handle(object))); | |
| 400 | + } | |
| 401 | + | |
| 402 | + void pw3270_dbus_get_screen_length(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 403 | + { | |
| 404 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 405 | + dbus_g_method_return(context,lib3270_get_width(pw3270_dbus_get_session_handle(object))); | |
| 406 | + } | |
| 407 | + | |
| 408 | + void pw3270_dbus_set_toggle(PW3270Dbus *object, int id, int value, DBusGMethodInvocation *context) | |
| 409 | + { | |
| 410 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 411 | + dbus_g_method_return(context,lib3270_set_toggle(pw3270_dbus_get_session_handle(object),id,value)); | |
| 412 | + } | |
| 413 | + | |
| 414 | +void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *utftext, char lf, DBusGMethodInvocation *context) | |
| 415 | +{ | |
| 416 | + gchar * text; | |
| 417 | + H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
| 418 | + | |
| 419 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 420 | + if(pw3270_dbus_check_valid_state(object,context)) | |
| 421 | + return; | |
| 422 | + | |
| 423 | + text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL); | |
| 424 | + | |
| 425 | + dbus_g_method_return(context,lib3270_cmp_text_at(hSession,row,col,text,lf)); | |
| 426 | + | |
| 427 | + g_free(text); | |
| 428 | +} | |
| 429 | + | |
| 430 | +void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context) | |
| 431 | +{ | |
| 432 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 433 | + if(pw3270_dbus_check_valid_state(object,context)) | |
| 434 | + return; | |
| 435 | + dbus_g_method_return(context,lib3270_pfkey(pw3270_dbus_get_session_handle(object),key)); | |
| 436 | +} | |
| 437 | + | |
| 438 | +void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context) | |
| 439 | +{ | |
| 440 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 441 | + if(pw3270_dbus_check_valid_state(object,context)) | |
| 442 | + return; | |
| 443 | + dbus_g_method_return(context,lib3270_pakey(pw3270_dbus_get_session_handle(object),key)); | |
| 444 | +} | |
| 445 | + | |
| 446 | + void pw3270_dbus_get_field_start(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context) | |
| 447 | + { | |
| 448 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 449 | + dbus_g_method_return(context,lib3270_get_field_start(pw3270_dbus_get_session_handle(object),baddr)); | |
| 450 | + } | |
| 451 | + | |
| 452 | + void pw3270_dbus_get_field_length(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context) | |
| 453 | + { | |
| 454 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 455 | + dbus_g_method_return(context,lib3270_get_field_len(pw3270_dbus_get_session_handle(object),baddr)); | |
| 456 | + } | |
| 457 | + | |
| 458 | + void pw3270_dbus_get_next_unprotected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context) | |
| 459 | + { | |
| 460 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 461 | + dbus_g_method_return(context,lib3270_get_next_unprotected(pw3270_dbus_get_session_handle(object),baddr)); | |
| 462 | + } | |
| 463 | + | |
| 464 | + void pw3270_dbus_get_is_protected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context) | |
| 465 | + { | |
| 466 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 467 | + dbus_g_method_return(context,lib3270_get_is_protected(pw3270_dbus_get_session_handle(object),baddr)); | |
| 468 | + } | |
| 469 | + | |
| 470 | + void pw3270_dbus_get_is_protected_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context) | |
| 471 | + { | |
| 472 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 473 | + dbus_g_method_return(context,lib3270_get_is_protected_at(pw3270_dbus_get_session_handle(object),row,col)); | |
| 474 | + } | |
| 475 | + | |
| 476 | + void pw3270_dbus_action(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context) | |
| 477 | + { | |
| 478 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 479 | + dbus_g_method_return(context,lib3270_action(pw3270_dbus_get_session_handle(object),text)); | |
| 480 | + } | |
| 481 | + | |
| 482 | + void pw3270_dbus_get_clipboard(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 483 | + { | |
| 484 | + gchar *text; | |
| 485 | + | |
| 486 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 487 | + | |
| 488 | + if(pw3270_dbus_check_valid_state(object,context)) | |
| 489 | + return; | |
| 490 | + | |
| 491 | + text = gtk_clipboard_wait_for_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD)); | |
| 492 | + | |
| 493 | + trace("Clipboard:\n%s\n",text); | |
| 494 | + | |
| 495 | + if(!text) | |
| 496 | + { | |
| 497 | + GError *error = pw3270_dbus_get_error_from_errno(ENOENT); | |
| 498 | + dbus_g_method_return_error(context,error); | |
| 499 | + g_error_free(error); | |
| 500 | + } | |
| 501 | + else | |
| 502 | + { | |
| 503 | + dbus_g_method_return(context,text); | |
| 504 | + g_free(text); | |
| 505 | + } | |
| 506 | +} | |
| 507 | + | |
| 508 | +void pw3270_dbus_set_clipboard(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context) | |
| 509 | +{ | |
| 510 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 511 | + gtk_clipboard_set_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD),(gchar *) text, -1); | |
| 512 | + dbus_g_method_return(context,0); | |
| 513 | +} | |
| 514 | + | |
| 515 | +void pw3270_dbus_set_script(PW3270Dbus *object, const gchar *text, int mode, DBusGMethodInvocation *context) | |
| 516 | +{ | |
| 517 | + GtkWidget *widget = pw3270_get_terminal_widget(NULL); | |
| 518 | + | |
| 519 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 520 | + | |
| 521 | + if(!widget) | |
| 522 | + { | |
| 523 | + GError *error = pw3270_dbus_get_error_from_errno(EINVAL); | |
| 524 | + dbus_g_method_return_error(context,error); | |
| 525 | + g_error_free(error); | |
| 526 | + return; | |
| 527 | + } | |
| 528 | + | |
| 529 | + dbus_g_method_return(context,v3270_set_script(widget,mode == 0 ? 0 : 'S')); | |
| 530 | +} | |
| 531 | + | |
| 532 | +void pw3270_dbus_show_popup(PW3270Dbus *object, int id, const gchar *title, const gchar *msg, const gchar *text, DBusGMethodInvocation *context) | |
| 533 | +{ | |
| 534 | + lib3270_popup_dialog(pw3270_dbus_get_session_handle(object), (LIB3270_NOTIFY) id , title, msg, "%s", text); | |
| 535 | + dbus_g_method_return(context,0); | |
| 536 | +} | |
| 537 | + | |
| 538 | +void pw3270_dbus_get_host_charset(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 539 | +{ | |
| 540 | + dbus_g_method_return(context,lib3270_get_host_charset(pw3270_dbus_get_session_handle(object))); | |
| 541 | +} | |
| 542 | + | |
| 543 | +void pw3270_dbus_get_display_charset(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 544 | +{ | |
| 545 | + // Allways return UTF-8 to avoid double conversion | |
| 546 | + dbus_g_method_return(context,"UTF-8"); | |
| 547 | +} | |
| 548 | + | |
| 549 | +void pw3270_dbus_set_host_charset(PW3270Dbus *object, const gchar *charset, DBusGMethodInvocation *context) | |
| 550 | +{ | |
| 551 | + dbus_g_method_return(context,lib3270_set_host_charset(pw3270_dbus_get_session_handle(object),charset)); | |
| 552 | +} | |
| 553 | + | |
| 554 | +void pw3270_dbus_erase_eof(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 555 | +{ | |
| 556 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 557 | + dbus_g_method_return(context,lib3270_eraseeof(pw3270_dbus_get_session_handle(object))); | |
| 558 | +} | |
| 559 | + | |
| 560 | +void pw3270_dbus_print(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 561 | +{ | |
| 562 | + dbus_g_method_return(context,lib3270_print_all(pw3270_dbus_get_session_handle(object))); | |
| 563 | +} | |
| 564 | + | |
| 565 | +void pw3270_dbus_set_unlock_delay(PW3270Dbus *object, int value, DBusGMethodInvocation *context) | |
| 566 | +{ | |
| 567 | + lib3270_set_unlock_delay(pw3270_dbus_get_session_handle(object),(unsigned short) value); | |
| 568 | + dbus_g_method_return(context,0); | |
| 569 | +} | |
| 570 | + | |
| 571 | + | |
| 572 | +void pw3270_dbus_ebc2asc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context) | |
| 573 | +{ | |
| 574 | + int sz = strlen(from); | |
| 575 | + | |
| 576 | + if(sz > 0) | |
| 577 | + { | |
| 578 | + unsigned char buffer[sz+1]; | |
| 579 | + memcpy(buffer,from,sz); | |
| 580 | + dbus_g_method_return(context,lib3270_ebc2asc(pw3270_dbus_get_session_handle(object),buffer,sz)); | |
| 581 | + return; | |
| 582 | + } | |
| 583 | + | |
| 584 | + dbus_g_method_return(context,""); | |
| 585 | + | |
| 586 | +} | |
| 587 | + | |
| 588 | +void pw3270_dbus_asc2ebc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context) | |
| 589 | +{ | |
| 590 | + int sz = strlen(from); | |
| 591 | + | |
| 592 | + if(sz > 0) | |
| 593 | + { | |
| 594 | + unsigned char buffer[sz+1]; | |
| 595 | + memcpy(buffer,from,sz); | |
| 596 | + dbus_g_method_return(context,lib3270_asc2ebc(pw3270_dbus_get_session_handle(object),buffer,sz)); | |
| 597 | + return; | |
| 598 | + } | |
| 599 | + | |
| 600 | + dbus_g_method_return(context,""); | |
| 601 | + | |
| 602 | +} | |
| 603 | + | |
| 604 | +void pw3270_dbus_filetransfer(PW3270Dbus *object, const gchar *local, const gchar *remote, int flags, int lrecl, int blksize, int primspace, int secspace, int dft, DBusGMethodInvocation *context) | |
| 605 | +{ | |
| 606 | + /* | |
| 607 | + dbus_g_method_return(context, | |
| 608 | + v3270_transfer_file( | |
| 609 | + v3270_get_default_widget(), | |
| 610 | + (LIB3270_FT_OPTION) flags, | |
| 611 | + local, | |
| 612 | + remote, | |
| 613 | + lrecl, | |
| 614 | + blksize, | |
| 615 | + primspace, | |
| 616 | + secspace, | |
| 617 | + dft | |
| 618 | + )); | |
| 619 | + */ | |
| 620 | + return; | |
| 621 | +} | |
| 622 | + | ... | ... |
| ... | ... | @@ -0,0 +1,361 @@ |
| 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 iocallback.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 | +#if defined(_WIN32) /*[*/ | |
| 33 | + #include <windows.h> | |
| 34 | +#elif defined(__APPLE__) | |
| 35 | + #include <poll.h> | |
| 36 | + #include <string.h> | |
| 37 | +#else | |
| 38 | + #include <poll.h> | |
| 39 | + #include <string.h> | |
| 40 | +#endif /*]*/ | |
| 41 | + | |
| 42 | +#include <stdio.h> | |
| 43 | +#include <glib.h> | |
| 44 | +#include "daemon.h" | |
| 45 | + | |
| 46 | +static int static_CallAndWait(int(*callback)(H3270 *session, void *), H3270 *session, void *parm); | |
| 47 | +static void static_RemoveSource(void *id); | |
| 48 | + | |
| 49 | +static void * static_AddInput(int source, H3270 *session, void (*fn)(H3270 *session)); | |
| 50 | +static void * static_AddExcept(int source, H3270 *session, void (*fn)(H3270 *session)); | |
| 51 | + | |
| 52 | +static void * static_AddTimeOut(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session)); | |
| 53 | +static void static_RemoveTimeOut(void * timer); | |
| 54 | +static int static_Sleep(H3270 *hSession, int seconds); | |
| 55 | +static int static_RunPendingEvents(H3270 *hSession, int wait); | |
| 56 | + | |
| 57 | +static gboolean IO_prepare(GSource *source, gint *timeout); | |
| 58 | +static gboolean IO_check(GSource *source); | |
| 59 | +static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer user_data); | |
| 60 | +static void IO_finalize(GSource *source); /* Can be NULL */ | |
| 61 | +static gboolean IO_closure(gpointer data); | |
| 62 | + | |
| 63 | +/*---[ Structs ]-------------------------------------------------------------------------------------------*/ | |
| 64 | + | |
| 65 | + typedef struct _IO_Source | |
| 66 | + { | |
| 67 | + GSource gsrc; | |
| 68 | + GPollFD poll; | |
| 69 | +#if defined(_WIN32) | |
| 70 | + HANDLE source; | |
| 71 | +#else | |
| 72 | + int source; | |
| 73 | +#endif // _WIN32 | |
| 74 | + void (*fn)(H3270 *session); | |
| 75 | + H3270 *session; | |
| 76 | + } IO_Source; | |
| 77 | + | |
| 78 | + typedef struct _timer | |
| 79 | + { | |
| 80 | + unsigned char remove; | |
| 81 | + void (*fn)(H3270 *session); | |
| 82 | + H3270 *session; | |
| 83 | + } TIMER; | |
| 84 | + | |
| 85 | + static GSourceFuncs IOSources = | |
| 86 | + { | |
| 87 | + IO_prepare, | |
| 88 | + IO_check, | |
| 89 | + IO_dispatch, | |
| 90 | + IO_finalize, | |
| 91 | + IO_closure, | |
| 92 | + NULL | |
| 93 | + }; | |
| 94 | + | |
| 95 | +/*---[ Implement ]-----------------------------------------------------------------------------------------*/ | |
| 96 | + | |
| 97 | +#ifdef _WIN32 | |
| 98 | +static void * AddSource(HANDLE source, H3270 *session, gushort events, void (*fn)(H3270 *session)) | |
| 99 | +#else | |
| 100 | +static void * AddSource(int source, H3270 *session, gushort events, void (*fn)(H3270 *session)) | |
| 101 | +#endif // _WIN32 | |
| 102 | +{ | |
| 103 | + IO_Source *src = (IO_Source *) g_source_new(&IOSources,sizeof(IO_Source)); | |
| 104 | + | |
| 105 | + src->source = source; | |
| 106 | + src->fn = fn; | |
| 107 | + src->poll.fd = (int) source; | |
| 108 | + src->poll.events = events; | |
| 109 | + src->session = session; | |
| 110 | + | |
| 111 | + g_source_attach((GSource *) src,NULL); | |
| 112 | + g_source_add_poll((GSource *) src,&src->poll); | |
| 113 | + | |
| 114 | + return src; | |
| 115 | +} | |
| 116 | + | |
| 117 | +#ifdef _WIN32 | |
| 118 | +static void * static_AddInput(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | |
| 119 | +#else | |
| 120 | +static void * static_AddInput(int source, H3270 *session, void (*fn)(H3270 *session)) | |
| 121 | +#endif // _WIN32 | |
| 122 | +{ | |
| 123 | + return AddSource(source,session,G_IO_IN|G_IO_HUP|G_IO_ERR,fn); | |
| 124 | +} | |
| 125 | + | |
| 126 | +static void static_RemoveSource(void *id) | |
| 127 | +{ | |
| 128 | + if(id) | |
| 129 | + g_source_destroy((GSource *) id); | |
| 130 | +} | |
| 131 | + | |
| 132 | +#if defined(_WIN32) | |
| 133 | +static void * static_AddExcept(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | |
| 134 | +{ | |
| 135 | + return 0; | |
| 136 | +} | |
| 137 | +#else | |
| 138 | +static void * static_AddExcept(int source, H3270 *session, void (*fn)(H3270 *session)) | |
| 139 | +{ | |
| 140 | + return AddSource(source,session,G_IO_HUP|G_IO_ERR,fn); | |
| 141 | +} | |
| 142 | +#endif // _WIN32 | |
| 143 | + | |
| 144 | +static gboolean do_timer(TIMER *t) | |
| 145 | +{ | |
| 146 | + if(!t->remove) | |
| 147 | + t->fn(t->session); | |
| 148 | + return FALSE; | |
| 149 | +} | |
| 150 | + | |
| 151 | +static void * static_AddTimeOut(unsigned long interval, H3270 *session, void (*proc)(H3270 *session)) | |
| 152 | +{ | |
| 153 | + TIMER *t = g_malloc0(sizeof(TIMER)); | |
| 154 | + | |
| 155 | + t->fn = proc; | |
| 156 | + t->session = session; | |
| 157 | + | |
| 158 | + g_timeout_add_full(G_PRIORITY_DEFAULT, (guint) interval, (GSourceFunc) do_timer, t, g_free); | |
| 159 | + | |
| 160 | + return t; | |
| 161 | +} | |
| 162 | + | |
| 163 | +static void static_RemoveTimeOut(void * timer) | |
| 164 | +{ | |
| 165 | + ((TIMER *) timer)->remove++; | |
| 166 | +} | |
| 167 | + | |
| 168 | +static gboolean IO_prepare(GSource *source, gint *timeout) | |
| 169 | +{ | |
| 170 | + /* | |
| 171 | + * Called before all the file descriptors are polled. | |
| 172 | + * If the source can determine that it is ready here | |
| 173 | + * (without waiting for the results of the poll() call) | |
| 174 | + * it should return TRUE. | |
| 175 | + * | |
| 176 | + * It can also return a timeout_ value which should be the maximum | |
| 177 | + * timeout (in milliseconds) which should be passed to the poll() call. | |
| 178 | + * The actual timeout used will be -1 if all sources returned -1, | |
| 179 | + * or it will be the minimum of all the timeout_ values | |
| 180 | + * returned which were >= 0. | |
| 181 | + * | |
| 182 | + */ | |
| 183 | + return 0; | |
| 184 | +} | |
| 185 | + | |
| 186 | +static gboolean IO_check(GSource *source) | |
| 187 | +{ | |
| 188 | + /* | |
| 189 | + * Called after all the file descriptors are polled. | |
| 190 | + * The source should return TRUE if it is ready to be dispatched. | |
| 191 | + * Note that some time may have passed since the previous prepare | |
| 192 | + * function was called, so the source should be checked again here. | |
| 193 | + * | |
| 194 | + */ | |
| 195 | +#if defined(_WIN32) /*[*/ | |
| 196 | + | |
| 197 | + if(WaitForSingleObject(((IO_Source *) source)->source,0) == WAIT_OBJECT_0) | |
| 198 | + return TRUE; | |
| 199 | + | |
| 200 | +#else /*][*/ | |
| 201 | + | |
| 202 | + struct pollfd fds; | |
| 203 | + | |
| 204 | + memset(&fds,0,sizeof(fds)); | |
| 205 | + | |
| 206 | + fds.fd = ((IO_Source *) source)->poll.fd; | |
| 207 | + fds.events = ((IO_Source *) source)->poll.events; | |
| 208 | + | |
| 209 | + if(poll(&fds,1,0) > 0) | |
| 210 | + return TRUE; | |
| 211 | + | |
| 212 | +#endif /*]*/ | |
| 213 | + | |
| 214 | + return FALSE; | |
| 215 | +} | |
| 216 | + | |
| 217 | +static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) | |
| 218 | +{ | |
| 219 | + /* | |
| 220 | + * Called to dispatch the event source, | |
| 221 | + * after it has returned TRUE in either its prepare or its check function. | |
| 222 | + * The dispatch function is passed in a callback function and data. | |
| 223 | + * The callback function may be NULL if the source was never connected | |
| 224 | + * to a callback using g_source_set_callback(). The dispatch function | |
| 225 | + * should call the callback function with user_data and whatever additional | |
| 226 | + * parameters are needed for this type of event source. | |
| 227 | + */ | |
| 228 | + ((IO_Source *) source)->fn(((IO_Source *) source)->session); | |
| 229 | + return TRUE; | |
| 230 | +} | |
| 231 | + | |
| 232 | +static void IO_finalize(GSource *source) | |
| 233 | +{ | |
| 234 | + | |
| 235 | +} | |
| 236 | + | |
| 237 | +static gboolean IO_closure(gpointer data) | |
| 238 | +{ | |
| 239 | + return 0; | |
| 240 | +} | |
| 241 | + | |
| 242 | +struct bgParameter | |
| 243 | +{ | |
| 244 | + gboolean running; | |
| 245 | + gboolean timer; | |
| 246 | + H3270 *session; | |
| 247 | + int rc; | |
| 248 | + int(*callback)(H3270 *session, void *); | |
| 249 | + void *parm; | |
| 250 | + | |
| 251 | +}; | |
| 252 | + | |
| 253 | +gpointer BgCall(struct bgParameter *p) | |
| 254 | +{ | |
| 255 | +// trace("%s starts",__FUNCTION__); | |
| 256 | + p->rc = p->callback(p->session, p->parm); | |
| 257 | + p->running = FALSE; | |
| 258 | +// trace("%s ends",__FUNCTION__); | |
| 259 | + return 0; | |
| 260 | +} | |
| 261 | + | |
| 262 | +static gboolean wait_for_thread(struct bgParameter *p) | |
| 263 | +{ | |
| 264 | + if(!p->running) | |
| 265 | + { | |
| 266 | + p->timer = 0; | |
| 267 | + return FALSE; | |
| 268 | + } | |
| 269 | + return TRUE; | |
| 270 | +} | |
| 271 | + | |
| 272 | +static int static_CallAndWait(int(*callback)(H3270 *session, void *), H3270 *session, void *parm) | |
| 273 | +{ | |
| 274 | + struct bgParameter p = { TRUE, TRUE, session, -1, callback, parm }; | |
| 275 | + GThread * thread; | |
| 276 | + | |
| 277 | +// trace("Starting auxiliary thread for callback %p",callback); | |
| 278 | + | |
| 279 | + p.running = TRUE; | |
| 280 | + p.timer = TRUE; | |
| 281 | + | |
| 282 | + thread = g_thread_create( (GThreadFunc) BgCall, &p, 0, NULL); | |
| 283 | + | |
| 284 | + if(!thread) | |
| 285 | + { | |
| 286 | + g_error("Can't start background thread"); | |
| 287 | + return -1; | |
| 288 | + } | |
| 289 | + | |
| 290 | + g_timeout_add(50,(GSourceFunc) wait_for_thread,(gpointer) &p); | |
| 291 | + | |
| 292 | + while(p.timer) | |
| 293 | + g_main_context_iteration(g_main_loop_get_context(main_loop),TRUE); | |
| 294 | + | |
| 295 | + return p.rc; | |
| 296 | +} | |
| 297 | + | |
| 298 | +static int static_Sleep(H3270 *hSession, int seconds) | |
| 299 | +{ | |
| 300 | + time_t end = time(0) + seconds; | |
| 301 | + | |
| 302 | + while(time(0) < end) | |
| 303 | + g_main_iteration(TRUE); | |
| 304 | + | |
| 305 | + return 0; | |
| 306 | +} | |
| 307 | + | |
| 308 | +static int static_RunPendingEvents(H3270 *hSession, int wait) | |
| 309 | +{ | |
| 310 | + GMainContext *context = g_main_loop_get_context(main_loop); | |
| 311 | + int rc = 0; | |
| 312 | + while(g_main_context_pending(context)) | |
| 313 | + { | |
| 314 | + rc = 1; | |
| 315 | + g_main_context_iteration(context,FALSE); | |
| 316 | + } | |
| 317 | + | |
| 318 | + if(wait) | |
| 319 | + g_main_context_iteration(context,TRUE); | |
| 320 | + | |
| 321 | + return rc; | |
| 322 | +} | |
| 323 | + | |
| 324 | +static void beep(H3270 *session) | |
| 325 | +{ | |
| 326 | +} | |
| 327 | + | |
| 328 | +void pw3270_dbus_register_io_handlers(void) | |
| 329 | +{ | |
| 330 | + static const struct lib3270_callbacks hdl = | |
| 331 | + { | |
| 332 | + sizeof(struct lib3270_callbacks), | |
| 333 | + | |
| 334 | + static_AddTimeOut, | |
| 335 | + static_RemoveTimeOut, | |
| 336 | + | |
| 337 | + static_AddInput, | |
| 338 | + static_RemoveSource, | |
| 339 | + | |
| 340 | + static_AddExcept, | |
| 341 | + | |
| 342 | +#ifdef G_THREADS_ENABLED | |
| 343 | + static_CallAndWait, | |
| 344 | +#else | |
| 345 | + NULL, | |
| 346 | +#endif | |
| 347 | + | |
| 348 | + static_Sleep, | |
| 349 | + static_RunPendingEvents, | |
| 350 | + beep | |
| 351 | + | |
| 352 | + }; | |
| 353 | + | |
| 354 | + #error Need rewrite | |
| 355 | + | |
| 356 | + if(lib3270_register_handlers(&hdl)) | |
| 357 | + { | |
| 358 | + g_error("%s","Can't set lib3270 I/O handlers"); | |
| 359 | + } | |
| 360 | + | |
| 361 | +} | ... | ... |
| ... | ... | @@ -0,0 +1,172 @@ |
| 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 <glib.h> | |
| 35 | +#include <dbus/dbus.h> | |
| 36 | +#include <dbus/dbus-glib-lowlevel.h> | |
| 37 | +#include <dbus/dbus-glib.h> | |
| 38 | + | |
| 39 | +#include <pw3270.h> | |
| 40 | +#include <pw3270/plugin.h> | |
| 41 | + | |
| 42 | +#include "service.h" | |
| 43 | +#include "dbus-glue.h" | |
| 44 | + | |
| 45 | +#include <gtk/gtk.h> | |
| 46 | + | |
| 47 | +/*---[ Globals ]---------------------------------------------------------------------------------*/ | |
| 48 | + | |
| 49 | + static DBusGConnection * connection = NULL; | |
| 50 | + static DBusGProxy * proxy = NULL; | |
| 51 | + static gchar * service_name = NULL; | |
| 52 | + | |
| 53 | + | |
| 54 | +/*---[ Implement ]-------------------------------------------------------------------------------*/ | |
| 55 | + | |
| 56 | + LIB3270_EXPORT int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal) | |
| 57 | + { | |
| 58 | + | |
| 59 | + GError * error = NULL; | |
| 60 | + guint result; | |
| 61 | + char session_id = 0; | |
| 62 | + char id = 'a'; | |
| 63 | + | |
| 64 | + connection = dbus_g_bus_get_private(DBUS_BUS_SESSION, g_main_context_default(), &error); | |
| 65 | + if(error) | |
| 66 | + { | |
| 67 | + GtkWidget *dialog = gtk_message_dialog_new( | |
| 68 | + GTK_WINDOW(window), | |
| 69 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 70 | + GTK_MESSAGE_ERROR, | |
| 71 | + GTK_BUTTONS_OK, | |
| 72 | + _( "Can't connect to DBUS server" )); | |
| 73 | + | |
| 74 | + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); | |
| 75 | + | |
| 76 | + g_message("Error \"%s\" getting session dbus",error->message); | |
| 77 | + | |
| 78 | + g_error_free(error); | |
| 79 | + | |
| 80 | + gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 81 | + gtk_widget_destroy(dialog); | |
| 82 | + | |
| 83 | + return -1; | |
| 84 | + } | |
| 85 | + | |
| 86 | + proxy = dbus_g_proxy_new_for_name(connection,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS); | |
| 87 | + | |
| 88 | + for(id='a'; id < 'z' && !error && !service_name; id++) | |
| 89 | + { | |
| 90 | + gboolean has_owner = FALSE; | |
| 91 | + | |
| 92 | + service_name = g_strdup_printf("br.com.bb.%s.%c",pw3270_get_session_name(window),(int) id); | |
| 93 | + | |
| 94 | + org_freedesktop_DBus_name_has_owner(proxy, service_name, &has_owner, NULL); | |
| 95 | + | |
| 96 | + if(has_owner) | |
| 97 | + { | |
| 98 | + trace("Service \"%s\" has owner",service_name) | |
| 99 | + g_free(service_name); | |
| 100 | + service_name = NULL; | |
| 101 | + } | |
| 102 | + else | |
| 103 | + { | |
| 104 | + session_id = id; | |
| 105 | + g_message("DBUS service name is %s",service_name); | |
| 106 | + org_freedesktop_DBus_request_name(proxy, service_name, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error); | |
| 107 | + } | |
| 108 | + } | |
| 109 | + | |
| 110 | + if(error) | |
| 111 | + { | |
| 112 | + GtkWidget *dialog = gtk_message_dialog_new( | |
| 113 | + GTK_WINDOW(window), | |
| 114 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 115 | + GTK_MESSAGE_ERROR, | |
| 116 | + GTK_BUTTONS_OK, | |
| 117 | + _( "Can't get DBUS object name" )); | |
| 118 | + | |
| 119 | + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); | |
| 120 | + | |
| 121 | + g_message("Error \"%s\" requesting DBUS name",error->message); | |
| 122 | + | |
| 123 | + g_error_free(error); | |
| 124 | + | |
| 125 | + gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 126 | + gtk_widget_destroy(dialog); | |
| 127 | + | |
| 128 | + return -1; | |
| 129 | + } | |
| 130 | + | |
| 131 | + if(session_id) | |
| 132 | + { | |
| 133 | + gchar * path = g_strdup_printf("/br/com/bb/%s",pw3270_get_session_name(window)); | |
| 134 | + gchar * session = g_strdup_printf("%s:%c",pw3270_get_session_name(window),g_ascii_toupper(session_id)); | |
| 135 | + pw3270_set_session_name(window,session); | |
| 136 | + g_free(session); | |
| 137 | + | |
| 138 | + g_message("DBUS service path is %s",path); | |
| 139 | + | |
| 140 | + pw3270_dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,path); | |
| 141 | + | |
| 142 | + g_free(path); | |
| 143 | + } | |
| 144 | + | |
| 145 | + return 0; | |
| 146 | + } | |
| 147 | + | |
| 148 | + LIB3270_EXPORT int pw3270_plugin_stop(GtkWidget *window, GtkWidget *terminal) | |
| 149 | + { | |
| 150 | + if(service_name) | |
| 151 | + { | |
| 152 | + // org_freedesktop_DBus_release_name | |
| 153 | + | |
| 154 | + g_free(service_name); | |
| 155 | + service_name = NULL; | |
| 156 | + } | |
| 157 | + return 0; | |
| 158 | + } | |
| 159 | + | |
| 160 | + void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context) | |
| 161 | + { | |
| 162 | + gtk_main_quit(); | |
| 163 | + dbus_g_method_return(context,0); | |
| 164 | + } | |
| 165 | + | |
| 166 | + H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object) | |
| 167 | + { | |
| 168 | + return lib3270_get_default_session_handle(); | |
| 169 | + } | |
| 170 | + | |
| 171 | + | |
| 172 | + | ... | ... |
| ... | ... | @@ -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. | |
| 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 misc.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 "globals.h" | |
| 37 | + | |
| 38 | +/*---[ Implement ]-------------------------------------------------------------------------------*/ | |
| 39 | + | |
| 40 | +gpointer pw3270_dbus_register_object(DBusGConnection *connection,DBusGProxy *proxy,GType object_type,const DBusGObjectInfo *info,const gchar *path) | |
| 41 | +{ | |
| 42 | + GObject *object = g_object_new (object_type, NULL); | |
| 43 | + dbus_g_object_type_install_info (object_type, info); | |
| 44 | + dbus_g_connection_register_g_object (connection, path, object); | |
| 45 | + return object; | |
| 46 | +} | |
| 47 | + | ... | ... |
| ... | ... | @@ -0,0 +1,138 @@ |
| 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 service.h 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 | +#ifndef _PW3270_DBUS_SERVICE_H | |
| 33 | + | |
| 34 | + #define _PW3270_DBUS_SERVICE_H 1 | |
| 35 | + | |
| 36 | + #define ENABLE_NLS | |
| 37 | + #define GETTEXT_PACKAGE PACKAGE_NAME | |
| 38 | + | |
| 39 | + #include "globals.h" | |
| 40 | + | |
| 41 | + #define PW3270_TYPE_DBUS (pw3270_dbus_get_type ()) | |
| 42 | + #define PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PW3270_TYPE_DBUS, PW3270Dbus)) | |
| 43 | + #define PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_DBUS, PW3270DbusClass)) | |
| 44 | + #define IS_PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PW3270_TYPE_DBUS)) | |
| 45 | + #define IS_PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_DBUS)) | |
| 46 | + #define PW3270_DBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_DBUS, PW3270DbusClass)) | |
| 47 | + | |
| 48 | + G_BEGIN_DECLS | |
| 49 | + | |
| 50 | + typedef struct _PW3270Dbus PW3270Dbus; | |
| 51 | + typedef struct _PW3270DbusClass PW3270DbusClass; | |
| 52 | + | |
| 53 | + struct _PW3270Dbus | |
| 54 | + { | |
| 55 | + GObject parent; | |
| 56 | + }; | |
| 57 | + | |
| 58 | + struct _PW3270DbusClass | |
| 59 | + { | |
| 60 | + GObjectClass parent; | |
| 61 | + }; | |
| 62 | + | |
| 63 | + PW3270Dbus * pw3270_dbus_new (void); | |
| 64 | + GType pw3270_dbus_get_type (void); | |
| 65 | + | |
| 66 | + void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 67 | + void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 68 | + void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context); | |
| 69 | + void pw3270_dbus_get_ur_l(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 70 | + void pw3270_dbus_set_ur_l(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context); | |
| 71 | + void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 72 | + | |
| 73 | + void pw3270_dbus_get_message_id(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 74 | + void pw3270_dbus_get_connection_state(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 75 | + void pw3270_dbus_get_secure_state(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 76 | + | |
| 77 | + void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 78 | + H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object); | |
| 79 | + GError * pw3270_dbus_get_error_from_errno(int code); | |
| 80 | + | |
| 81 | + void pw3270_dbus_is_connected(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 82 | + void pw3270_dbus_is_ready(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 83 | + void pw3270_dbus_in_tn3270_e(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 84 | + | |
| 85 | + void pw3270_dbus_set_cursor_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context); | |
| 86 | + void pw3270_dbus_set_cursor_address(PW3270Dbus *object, int addr, DBusGMethodInvocation *context); | |
| 87 | + void pw3270_dbus_get_cursor_address(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 88 | + | |
| 89 | + void pw3270_dbus_get_screen_width(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 90 | + void pw3270_dbus_get_screen_height(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 91 | + void pw3270_dbus_get_screen_length(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 92 | + | |
| 93 | + void pw3270_dbus_set_toggle(PW3270Dbus *object, int id, int value, DBusGMethodInvocation *context); | |
| 94 | + | |
| 95 | + void pw3270_dbus_wait_for_ready(PW3270Dbus *object, int timeout, DBusGMethodInvocation *context); | |
| 96 | + | |
| 97 | + void pw3270_dbus_get_field_start(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); | |
| 98 | + void pw3270_dbus_get_field_length(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); | |
| 99 | + void pw3270_dbus_get_next_unprotected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); | |
| 100 | + | |
| 101 | + void pw3270_dbus_get_is_protected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); | |
| 102 | + void pw3270_dbus_get_is_protected_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context); | |
| 103 | + | |
| 104 | + void pw3270_dbus_set_script(PW3270Dbus *object, const gchar *text, int mode, DBusGMethodInvocation *context); | |
| 105 | + | |
| 106 | + void pw3270_dbus_show_popup(PW3270Dbus *object, int id, const gchar *title, const gchar *msg, const gchar *text, DBusGMethodInvocation *context); | |
| 107 | + | |
| 108 | + void pw3270_dbus_action(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context); | |
| 109 | + | |
| 110 | + // Actions | |
| 111 | + void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 112 | + void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context); | |
| 113 | + void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context); | |
| 114 | + void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context); | |
| 115 | + void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, char lf, DBusGMethodInvocation *context); | |
| 116 | + void pw3270_dbus_get_text(PW3270Dbus *object, int offset, int len, char lf, DBusGMethodInvocation *context); | |
| 117 | + void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *text, char lf, DBusGMethodInvocation *context); | |
| 118 | + void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context); | |
| 119 | + | |
| 120 | + void pw3270_dbus_set_clipboard(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context); | |
| 121 | + void pw3270_dbus_get_clipboard(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 122 | + | |
| 123 | + void pw3270_dbus_get_display_charset(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 124 | + void pw3270_dbus_get_host_charset(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 125 | + void pw3270_dbus_set_host_charset(PW3270Dbus *object, const gchar *charset, DBusGMethodInvocation *context); | |
| 126 | + void pw3270_dbus_erase_eof(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 127 | + void pw3270_dbus_print(PW3270Dbus *object, DBusGMethodInvocation *context); | |
| 128 | + | |
| 129 | + void pw3270_dbus_asc2ebc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context); | |
| 130 | + void pw3270_dbus_ebc2asc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context); | |
| 131 | + | |
| 132 | + void pw3270_dbus_filetransfer(PW3270Dbus *object, const gchar *local, const gchar *remote, int flags, int lrecl, int blksize, int primspace, int secspace, int dft, DBusGMethodInvocation *context); | |
| 133 | + | |
| 134 | + void pw3270_dbus_set_unlock_delay(PW3270Dbus *object, int value, DBusGMethodInvocation *context); | |
| 135 | + | |
| 136 | + G_END_DECLS | |
| 137 | + | |
| 138 | +#endif // _PW3270_DBUS_SERVICE_H | ... | ... |
| ... | ... | @@ -0,0 +1,29 @@ |
| 1 | +#include <windows.h> | |
| 2 | + | |
| 3 | +VS_VERSION_INFO VERSIONINFO | |
| 4 | +FILEVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0 | |
| 5 | +PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0 | |
| 6 | + | |
| 7 | +BEGIN | |
| 8 | + | |
| 9 | + BLOCK "StringFileInfo" | |
| 10 | + BEGIN | |
| 11 | + BLOCK "080904E4" | |
| 12 | + BEGIN | |
| 13 | + VALUE "FileDescription", "@PACKAGE_NAME@ IPC Plugin\0" | |
| 14 | + VALUE "CompanyName", "Banco do Brasil S/A.\0" | |
| 15 | + VALUE "FileVersion", "@WIN32_VERSION@\0" | |
| 16 | + VALUE "LegalCopyright", "(C) 2017 Banco do Brasil S/A. All Rights Reserved\0" | |
| 17 | + VALUE "OriginalFilename", "ipc3270@DLLEXT@\0" | |
| 18 | + VALUE "ProductName", "@PACKAGE_NAME@\0" | |
| 19 | + VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.0\0" | |
| 20 | + END | |
| 21 | + END | |
| 22 | + | |
| 23 | + BLOCK "VarFileInfo" | |
| 24 | + BEGIN | |
| 25 | + VALUE "Translation", 0x809, 0x04E4 | |
| 26 | + END | |
| 27 | + | |
| 28 | +END | |
| 29 | + | ... | ... |