Commit 6cb68c518d598f2f5dbd489795ee4238d446e328
1 parent
58b16dca
Exists in
master
and in
5 other branches
Main application now uses v3270 simple trace window for tracing.
Showing
9 changed files
with
144 additions
and
786 deletions
Show diff stats
modules/lib3270
modules/libv3270
pw3270.cbp
| ... | ... | @@ -68,7 +68,6 @@ |
| 68 | 68 | <Unit filename="src/classlib/class.mak.in" /> |
| 69 | 69 | <Unit filename="src/classlib/private.h" /> |
| 70 | 70 | <Unit filename="src/include/config.h.in" /> |
| 71 | - <Unit filename="src/include/lib3270.h" /> | |
| 72 | 71 | <Unit filename="src/include/lib3270/X11keysym.h" /> |
| 73 | 72 | <Unit filename="src/include/lib3270/action_table.h" /> |
| 74 | 73 | <Unit filename="src/include/lib3270/actions.h" /> |
| ... | ... | @@ -88,10 +87,6 @@ |
| 88 | 87 | <Unit filename="src/include/pw3270/ipcpackets.h" /> |
| 89 | 88 | <Unit filename="src/include/pw3270/plugin.h" /> |
| 90 | 89 | <Unit filename="src/include/pw3270/trace.h" /> |
| 91 | - <Unit filename="src/include/pw3270/v3270.h"> | |
| 92 | - <Option target="Debug" /> | |
| 93 | - <Option target="Release" /> | |
| 94 | - </Unit> | |
| 95 | 90 | <Unit filename="src/include/pw3270cpp.h" /> |
| 96 | 91 | <Unit filename="src/include/rules.mak.in" /> |
| 97 | 92 | <Unit filename="src/java/Makefile.in"> |
| ... | ... | @@ -128,149 +123,38 @@ |
| 128 | 123 | </Unit> |
| 129 | 124 | <Unit filename="src/lib3270/3270ds.h" /> |
| 130 | 125 | <Unit filename="src/lib3270/Makefile.in" /> |
| 131 | - <Unit filename="src/lib3270/actions.c"> | |
| 132 | - <Option compilerVar="CC" /> | |
| 133 | - </Unit> | |
| 134 | - <Unit filename="src/lib3270/ansi.c"> | |
| 135 | - <Option compilerVar="CC" /> | |
| 136 | - </Unit> | |
| 137 | 126 | <Unit filename="src/lib3270/ansic.h" /> |
| 138 | 127 | <Unit filename="src/lib3270/api.h" /> |
| 139 | 128 | <Unit filename="src/lib3270/arpa_telnet.h" /> |
| 140 | - <Unit filename="src/lib3270/bounds.c"> | |
| 141 | - <Option compilerVar="CC" /> | |
| 142 | - </Unit> | |
| 143 | 129 | <Unit filename="src/lib3270/cg.h" /> |
| 144 | - <Unit filename="src/lib3270/charset.c"> | |
| 145 | - <Option compilerVar="CC" /> | |
| 146 | - </Unit> | |
| 147 | - <Unit filename="src/lib3270/connect.c"> | |
| 148 | - <Option compilerVar="CC" /> | |
| 149 | - </Unit> | |
| 150 | - <Unit filename="src/lib3270/ctlr.c"> | |
| 151 | - <Option compilerVar="CC" /> | |
| 152 | - </Unit> | |
| 153 | 130 | <Unit filename="src/lib3270/ctlrc.h" /> |
| 154 | - <Unit filename="src/lib3270/ft.c"> | |
| 155 | - <Option compilerVar="CC" /> | |
| 156 | - </Unit> | |
| 157 | - <Unit filename="src/lib3270/ft_cut.c"> | |
| 158 | - <Option compilerVar="CC" /> | |
| 159 | - </Unit> | |
| 160 | 131 | <Unit filename="src/lib3270/ft_cut_ds.h" /> |
| 161 | 132 | <Unit filename="src/lib3270/ft_cutc.h" /> |
| 162 | - <Unit filename="src/lib3270/ft_dft.c"> | |
| 163 | - <Option compilerVar="CC" /> | |
| 164 | - </Unit> | |
| 165 | 133 | <Unit filename="src/lib3270/ft_dft_ds.h" /> |
| 166 | 134 | <Unit filename="src/lib3270/ft_dftc.h" /> |
| 167 | 135 | <Unit filename="src/lib3270/ftc.h" /> |
| 168 | - <Unit filename="src/lib3270/glue.c"> | |
| 169 | - <Option compilerVar="CC" /> | |
| 170 | - </Unit> | |
| 171 | 136 | <Unit filename="src/lib3270/gluec.h" /> |
| 172 | - <Unit filename="src/lib3270/host.c"> | |
| 173 | - <Option compilerVar="CC" /> | |
| 174 | - </Unit> | |
| 175 | 137 | <Unit filename="src/lib3270/hostc.h" /> |
| 176 | - <Unit filename="src/lib3270/html.c"> | |
| 177 | - <Option compilerVar="CC" /> | |
| 178 | - </Unit> | |
| 179 | - <Unit filename="src/lib3270/iocalls.c"> | |
| 180 | - <Option compilerVar="CC" /> | |
| 181 | - </Unit> | |
| 182 | - <Unit filename="src/lib3270/kybd.c"> | |
| 183 | - <Option compilerVar="CC" /> | |
| 184 | - </Unit> | |
| 185 | 138 | <Unit filename="src/lib3270/kybdc.h" /> |
| 186 | 139 | <Unit filename="src/lib3270/localdefs.h" /> |
| 187 | - <Unit filename="src/lib3270/log.c"> | |
| 188 | - <Option compilerVar="CC" /> | |
| 189 | - </Unit> | |
| 190 | - <Unit filename="src/lib3270/macros.c"> | |
| 191 | - <Option compilerVar="CC" /> | |
| 192 | - </Unit> | |
| 193 | - <Unit filename="src/lib3270/mkfb.c"> | |
| 194 | - <Option compilerVar="CC" /> | |
| 195 | - </Unit> | |
| 196 | - <Unit filename="src/lib3270/options.c"> | |
| 197 | - <Option compilerVar="CC" /> | |
| 198 | - </Unit> | |
| 199 | - <Unit filename="src/lib3270/paste.c"> | |
| 200 | - <Option compilerVar="CC" /> | |
| 201 | - </Unit> | |
| 202 | 140 | <Unit filename="src/lib3270/popupsc.h" /> |
| 203 | 141 | <Unit filename="src/lib3270/private.h" /> |
| 204 | - <Unit filename="src/lib3270/proxy.c"> | |
| 205 | - <Option compilerVar="CC" /> | |
| 206 | - </Unit> | |
| 207 | 142 | <Unit filename="src/lib3270/proxyc.h" /> |
| 208 | - <Unit filename="src/lib3270/resolver.c"> | |
| 209 | - <Option compilerVar="CC" /> | |
| 210 | - </Unit> | |
| 211 | 143 | <Unit filename="src/lib3270/resolverc.h" /> |
| 212 | - <Unit filename="src/lib3270/resources.c"> | |
| 213 | - <Option compilerVar="CC" /> | |
| 214 | - </Unit> | |
| 215 | 144 | <Unit filename="src/lib3270/resources.h" /> |
| 216 | - <Unit filename="src/lib3270/rpq.c"> | |
| 217 | - <Option compilerVar="CC" /> | |
| 218 | - </Unit> | |
| 219 | - <Unit filename="src/lib3270/screen.c"> | |
| 220 | - <Option compilerVar="CC" /> | |
| 221 | - </Unit> | |
| 222 | 145 | <Unit filename="src/lib3270/screen.h" /> |
| 223 | 146 | <Unit filename="src/lib3270/screenc.h" /> |
| 224 | - <Unit filename="src/lib3270/see.c"> | |
| 225 | - <Option compilerVar="CC" /> | |
| 226 | - </Unit> | |
| 227 | 147 | <Unit filename="src/lib3270/seec.h" /> |
| 228 | - <Unit filename="src/lib3270/selection.c"> | |
| 229 | - <Option compilerVar="CC" /> | |
| 230 | - </Unit> | |
| 231 | - <Unit filename="src/lib3270/session.c"> | |
| 232 | - <Option compilerVar="CC" /> | |
| 233 | - </Unit> | |
| 234 | - <Unit filename="src/lib3270/sf.c"> | |
| 235 | - <Option compilerVar="CC" /> | |
| 236 | - </Unit> | |
| 237 | 148 | <Unit filename="src/lib3270/sf.h" /> |
| 238 | 149 | <Unit filename="src/lib3270/shlobj_missing.h" /> |
| 239 | 150 | <Unit filename="src/lib3270/sources.mak" /> |
| 240 | - <Unit filename="src/lib3270/ssl.c"> | |
| 241 | - <Option compilerVar="CC" /> | |
| 242 | - </Unit> | |
| 243 | - <Unit filename="src/lib3270/state.c"> | |
| 244 | - <Option compilerVar="CC" /> | |
| 245 | - </Unit> | |
| 246 | 151 | <Unit filename="src/lib3270/statusc.h" /> |
| 247 | - <Unit filename="src/lib3270/tables.c"> | |
| 248 | - <Option compilerVar="CC" /> | |
| 249 | - </Unit> | |
| 250 | - <Unit filename="src/lib3270/telnet.c"> | |
| 251 | - <Option compilerVar="CC" /> | |
| 252 | - </Unit> | |
| 253 | 152 | <Unit filename="src/lib3270/telnetc.h" /> |
| 254 | - <Unit filename="src/lib3270/testprogram.c"> | |
| 255 | - <Option compilerVar="CC" /> | |
| 256 | - </Unit> | |
| 257 | 153 | <Unit filename="src/lib3270/tn3270e.h" /> |
| 258 | 154 | <Unit filename="src/lib3270/toggle.h" /> |
| 259 | - <Unit filename="src/lib3270/toggles.c"> | |
| 260 | - <Option compilerVar="CC" /> | |
| 261 | - </Unit> | |
| 262 | 155 | <Unit filename="src/lib3270/togglesc.h" /> |
| 263 | - <Unit filename="src/lib3270/trace_ds.c"> | |
| 264 | - <Option compilerVar="CC" /> | |
| 265 | - </Unit> | |
| 266 | 156 | <Unit filename="src/lib3270/trace_dsc.h" /> |
| 267 | - <Unit filename="src/lib3270/utf8.c"> | |
| 268 | - <Option compilerVar="CC" /> | |
| 269 | - </Unit> | |
| 270 | 157 | <Unit filename="src/lib3270/utf8c.h" /> |
| 271 | - <Unit filename="src/lib3270/util.c"> | |
| 272 | - <Option compilerVar="CC" /> | |
| 273 | - </Unit> | |
| 274 | 158 | <Unit filename="src/lib3270/utilc.h" /> |
| 275 | 159 | <Unit filename="src/lib3270/w3miscc.h" /> |
| 276 | 160 | <Unit filename="src/lib3270/widec.h" /> |
| ... | ... | @@ -455,52 +339,11 @@ |
| 455 | 339 | <Unit filename="src/pw3270/uiparser/toolitem.c"> |
| 456 | 340 | <Option compilerVar="CC" /> |
| 457 | 341 | </Unit> |
| 458 | - <Unit filename="src/pw3270/v3270/accessible.c"> | |
| 459 | - <Option compilerVar="CC" /> | |
| 460 | - </Unit> | |
| 461 | 342 | <Unit filename="src/pw3270/v3270/accessible.h" /> |
| 462 | - <Unit filename="src/pw3270/v3270/charset.c"> | |
| 463 | - <Option compilerVar="CC" /> | |
| 464 | - <Option target="Debug" /> | |
| 465 | - <Option target="Release" /> | |
| 466 | - </Unit> | |
| 467 | - <Unit filename="src/pw3270/v3270/draw.c"> | |
| 468 | - <Option compilerVar="CC" /> | |
| 469 | - </Unit> | |
| 470 | 343 | <Unit filename="src/pw3270/v3270/genmarshal" /> |
| 471 | - <Unit filename="src/pw3270/v3270/hostselect.c"> | |
| 472 | - <Option compilerVar="CC" /> | |
| 473 | - </Unit> | |
| 474 | 344 | <Unit filename="src/pw3270/v3270/hostselect.h" /> |
| 475 | - <Unit filename="src/pw3270/v3270/iocallback.c"> | |
| 476 | - <Option compilerVar="CC" /> | |
| 477 | - </Unit> | |
| 478 | - <Unit filename="src/pw3270/v3270/keyboard.c"> | |
| 479 | - <Option compilerVar="CC" /> | |
| 480 | - </Unit> | |
| 481 | - <Unit filename="src/pw3270/v3270/macros.c"> | |
| 482 | - <Option compilerVar="CC" /> | |
| 483 | - </Unit> | |
| 484 | - <Unit filename="src/pw3270/v3270/mouse.c"> | |
| 485 | - <Option compilerVar="CC" /> | |
| 486 | - </Unit> | |
| 487 | - <Unit filename="src/pw3270/v3270/oia.c"> | |
| 488 | - <Option compilerVar="CC" /> | |
| 489 | - </Unit> | |
| 490 | 345 | <Unit filename="src/pw3270/v3270/private.h" /> |
| 491 | - <Unit filename="src/pw3270/v3270/properties.c"> | |
| 492 | - <Option compilerVar="CC" /> | |
| 493 | - </Unit> | |
| 494 | - <Unit filename="src/pw3270/v3270/security.c"> | |
| 495 | - <Option compilerVar="CC" /> | |
| 496 | - </Unit> | |
| 497 | - <Unit filename="src/pw3270/v3270/selection.c"> | |
| 498 | - <Option compilerVar="CC" /> | |
| 499 | - </Unit> | |
| 500 | 346 | <Unit filename="src/pw3270/v3270/sources.mak" /> |
| 501 | - <Unit filename="src/pw3270/v3270/widget.c"> | |
| 502 | - <Option compilerVar="CC" /> | |
| 503 | - </Unit> | |
| 504 | 347 | <Unit filename="src/pw3270/v3270ft/Makefile.in" /> |
| 505 | 348 | <Unit filename="src/pw3270/v3270ft/filelist.c"> |
| 506 | 349 | <Option compilerVar="CC" /> | ... | ... |
src/include/pw3270/trace.h
| ... | ... | @@ -1,60 +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 trace.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_TRACE_H_INCLUDED | |
| 33 | - | |
| 34 | - #include <gtk/gtk.h> | |
| 35 | - #include <lib3270.h> | |
| 36 | - | |
| 37 | - #define PW3270_TRACE_H_INCLUDED 1 | |
| 38 | - | |
| 39 | - G_BEGIN_DECLS | |
| 40 | - | |
| 41 | - #define PW3270_TYPE_TRACE (pw3270_trace_get_type ()) | |
| 42 | - #define PW3270_TRACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PW3270_TYPE_TRACE, pw3270_trace)) | |
| 43 | - #define PW3270_TRACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_TRACE, pw3270_traceClass)) | |
| 44 | - #define IS_PW3270_TRACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PW3270_TYPE_TRACE)) | |
| 45 | - #define IS_PW3270_TRACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_TRACE)) | |
| 46 | - #define PW3270_TRACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_TRACE, pw3270_traceClass)) | |
| 47 | - | |
| 48 | - typedef struct _pw3270_trace pw3270_trace; | |
| 49 | - typedef struct _pw3270_traceClass pw3270_traceClass; | |
| 50 | - | |
| 51 | - LIB3270_EXPORT GtkWidget * pw3270_trace_new(void); | |
| 52 | - LIB3270_EXPORT GType pw3270_trace_get_type(void); | |
| 53 | - LIB3270_EXPORT void pw3270_trace_vprintf(GtkWidget *widget, const char *fmt, va_list args); | |
| 54 | - LIB3270_EXPORT void pw3270_trace_printf(GtkWidget *widget, const char *fmt, ... ); | |
| 55 | - LIB3270_EXPORT gchar * pw3270_trace_get_command(GtkWidget *widget); | |
| 56 | - LIB3270_EXPORT void pw3270_trace_set_destroy_on_close(GtkWidget *widget,gboolean on); | |
| 57 | - | |
| 58 | - G_END_DECLS | |
| 59 | - | |
| 60 | -#endif // V3270_H_INCLUDED |
src/pw3270/Makefile.in
| ... | ... | @@ -26,12 +26,24 @@ |
| 26 | 26 | |
| 27 | 27 | LIBNAME=@DLLPREFIX@@PACKAGE_TARNAME@@DLLEXT@ |
| 28 | 28 | |
| 29 | -LIB_SOURCES=window.c actions.c fonts.c dialog.c hostdialog.c print.c colors.c \ | |
| 30 | - tools.c plugin.c trace.c | |
| 31 | - | |
| 32 | -APP_SOURCES=main.c @APP_RESOURCES@ | |
| 33 | - | |
| 34 | -MODULES=uiparser common | |
| 29 | +LIB_SOURCES=\ | |
| 30 | + window.c \ | |
| 31 | + actions.c \ | |
| 32 | + fonts.c \ | |
| 33 | + dialog.c \ | |
| 34 | + hostdialog.c \ | |
| 35 | + print.c \ | |
| 36 | + colors.c \ | |
| 37 | + tools.c \ | |
| 38 | + plugin.c | |
| 39 | + | |
| 40 | +APP_SOURCES=\ | |
| 41 | + main.c \ | |
| 42 | + @APP_RESOURCES@ | |
| 43 | + | |
| 44 | +MODULES=\ | |
| 45 | + uiparser \ | |
| 46 | + common | |
| 35 | 47 | |
| 36 | 48 | #---[ Configuration values ]------------------------------------------------------------- |
| 37 | 49 | ... | ... |
src/pw3270/globals.h
| ... | ... | @@ -52,6 +52,7 @@ |
| 52 | 52 | |
| 53 | 53 | /*--[ Statics ]--------------------------------------------------------------------------------------*/ |
| 54 | 54 | |
| 55 | + G_GNUC_INTERNAL const gchar * tracefile; | |
| 55 | 56 | |
| 56 | 57 | /*--[ Global prototipes ]----------------------------------------------------------------------------*/ |
| 57 | 58 | ... | ... |
src/pw3270/main.c
| ... | ... | @@ -42,8 +42,6 @@ |
| 42 | 42 | #include <v3270.h> |
| 43 | 43 | #include <pw3270/plugin.h> |
| 44 | 44 | #include "v3270/accessible.h" |
| 45 | -#include <lib3270/trace.h> | |
| 46 | -#include <pw3270/trace.h> | |
| 47 | 45 | #include <stdlib.h> |
| 48 | 46 | |
| 49 | 47 | #if defined( HAVE_SYSLOG ) |
| ... | ... | @@ -55,19 +53,19 @@ |
| 55 | 53 | /*--[ Statics ]--------------------------------------------------------------------------------------*/ |
| 56 | 54 | |
| 57 | 55 | static GtkWidget * toplevel = NULL; |
| 58 | - static GtkWidget * trace_window = NULL; | |
| 59 | 56 | static unsigned int syscolors = 16; |
| 60 | 57 | static unsigned int timer = 0; |
| 61 | 58 | static const gchar * systype = NULL; |
| 62 | 59 | static const gchar * toggleset = NULL; |
| 63 | 60 | static const gchar * togglereset = NULL; |
| 64 | 61 | static const gchar * logfile = NULL; |
| 65 | - static const gchar * tracefile = NULL; | |
| 66 | 62 | static const gchar * charset = NULL; |
| 67 | 63 | static const gchar * remap = NULL; |
| 68 | 64 | static const gchar * model = NULL; |
| 69 | 65 | static const gchar * pluginpath = NULL; |
| 70 | 66 | |
| 67 | + const gchar * tracefile = NULL; | |
| 68 | + | |
| 71 | 69 | #ifdef HAVE_GTKMAC |
| 72 | 70 | GtkOSXApplication * osxapp = NULL; |
| 73 | 71 | #endif // HAVE_GTKMAC |
| ... | ... | @@ -266,79 +264,6 @@ static void g_logfile(const gchar *log_domain,GLogLevelFlags log_level,const gch |
| 266 | 264 | } |
| 267 | 265 | } |
| 268 | 266 | |
| 269 | -static void trace_window_destroy(GtkWidget *widget, H3270 *hSession) | |
| 270 | -{ | |
| 271 | - trace("%s",__FUNCTION__); | |
| 272 | - lib3270_set_toggle(hSession,LIB3270_TOGGLE_DS_TRACE,0); | |
| 273 | - lib3270_set_toggle(hSession,LIB3270_TOGGLE_SCREEN_TRACE,0); | |
| 274 | - lib3270_set_toggle(hSession,LIB3270_TOGGLE_EVENT_TRACE,0); | |
| 275 | - lib3270_set_toggle(hSession,LIB3270_TOGGLE_NETWORK_TRACE,0); | |
| 276 | - trace_window = NULL; | |
| 277 | -} | |
| 278 | - | |
| 279 | -/* | |
| 280 | -static void g_trace(H3270 *hSession, const char *fmt, va_list args) | |
| 281 | -{ | |
| 282 | - gchar *ptr = g_strdup_vprintf(fmt,args); | |
| 283 | - | |
| 284 | - if(tracefile) | |
| 285 | - { | |
| 286 | - // Has trace file, use it | |
| 287 | - int err; | |
| 288 | - | |
| 289 | - FILE *out = fopen(tracefile,"a"); | |
| 290 | - err = errno; | |
| 291 | - | |
| 292 | - if(!out) | |
| 293 | - { | |
| 294 | - // Error opening trace file, notify user and disable it | |
| 295 | - GtkWidget *popup = gtk_message_dialog_new_with_markup( | |
| 296 | - GTK_WINDOW(pw3270_get_toplevel()), | |
| 297 | - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 298 | - GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE, | |
| 299 | - _( "Can't save trace data to file %s" ),tracefile); | |
| 300 | - | |
| 301 | - gtk_window_set_title(GTK_WINDOW(popup),_("Can't open file")); | |
| 302 | - | |
| 303 | - gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(popup),"%s",strerror(err)); | |
| 304 | - | |
| 305 | - gtk_dialog_run(GTK_DIALOG(popup)); | |
| 306 | - gtk_widget_destroy(popup); | |
| 307 | - | |
| 308 | - tracefile = NULL; | |
| 309 | - } | |
| 310 | - else | |
| 311 | - { | |
| 312 | - fprintf(out,"%s",ptr); | |
| 313 | - fclose(out); | |
| 314 | - } | |
| 315 | - } | |
| 316 | - else | |
| 317 | - { | |
| 318 | - // No trace file, open standard window | |
| 319 | - gchar * utftext = g_convert_with_fallback(ptr,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL); | |
| 320 | - | |
| 321 | - if(!trace_window) | |
| 322 | - { | |
| 323 | - trace_window = pw3270_trace_new(); | |
| 324 | - pw3270_trace_set_destroy_on_close(trace_window,TRUE); | |
| 325 | - g_signal_connect(trace_window, "destroy", G_CALLBACK(trace_window_destroy), hSession); | |
| 326 | - gtk_window_set_default_size(GTK_WINDOW(trace_window),590,430); | |
| 327 | - | |
| 328 | -#if GTK_CHECK_VERSION(3,4,0) | |
| 329 | - gtk_window_set_attached_to(GTK_WINDOW(trace_window),toplevel); | |
| 330 | -#endif // GTK_CHECK_VERSION(3,4,0) | |
| 331 | - | |
| 332 | - gtk_widget_show(trace_window); | |
| 333 | - } | |
| 334 | - pw3270_trace_printf(trace_window,"%s",utftext); | |
| 335 | - g_free(utftext); | |
| 336 | - } | |
| 337 | - | |
| 338 | - g_free(ptr); | |
| 339 | -} | |
| 340 | -*/ | |
| 341 | - | |
| 342 | 267 | static gboolean startup(GtkWidget *toplevel) |
| 343 | 268 | { |
| 344 | 269 | gtk_window_present(GTK_WINDOW(toplevel)); |
| ... | ... | @@ -495,8 +420,6 @@ int main(int argc, char *argv[]) |
| 495 | 420 | g_log_set_default_handler(g_logfile,NULL); |
| 496 | 421 | } |
| 497 | 422 | |
| 498 | -// lib3270_set_trace_handler(g_trace); | |
| 499 | - | |
| 500 | 423 | // Check GTK Version |
| 501 | 424 | { |
| 502 | 425 | const gchar *msg = gtk_check_version(GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION); |
| ... | ... | @@ -609,9 +532,6 @@ int main(int argc, char *argv[]) |
| 609 | 532 | |
| 610 | 533 | gtk_main(); |
| 611 | 534 | |
| 612 | - if(trace_window) | |
| 613 | - gtk_widget_destroy(trace_window); | |
| 614 | - | |
| 615 | 535 | pw3270_stop_plugins(toplevel); |
| 616 | 536 | pw3270_unload_plugins(); |
| 617 | 537 | ... | ... |
src/pw3270/trace.c
| ... | ... | @@ -1,478 +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 trace.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 | - * | |
| 28 | - */ | |
| 29 | - | |
| 30 | - #include <gtk/gtk.h> | |
| 31 | - | |
| 32 | - #define ENABLE_NLS | |
| 33 | - #define GETTEXT_PACKAGE PACKAGE_NAME | |
| 34 | - | |
| 35 | - #include <libintl.h> | |
| 36 | - #include <glib/gi18n.h> | |
| 37 | - | |
| 38 | - #include <pw3270/trace.h> | |
| 39 | - #include "common/common.h" | |
| 40 | - | |
| 41 | -#if defined( HAVE_SYSLOG ) | |
| 42 | - #include <syslog.h> | |
| 43 | -#endif // HAVE_SYSLOG | |
| 44 | - | |
| 45 | -/*--[ Widget definition ]----------------------------------------------------------------------------*/ | |
| 46 | - | |
| 47 | - G_BEGIN_DECLS | |
| 48 | - | |
| 49 | - struct _pw3270_traceClass | |
| 50 | - { | |
| 51 | - GtkWindowClass parent_class; | |
| 52 | - }; | |
| 53 | - | |
| 54 | - struct _pw3270_trace | |
| 55 | - { | |
| 56 | - GtkWindow parent; | |
| 57 | - GtkAdjustment * scroll; | |
| 58 | - GtkTextBuffer * text; | |
| 59 | - GtkWidget * entry; | |
| 60 | - GtkWidget * button; | |
| 61 | - gchar **line; | |
| 62 | - guint log_handler; | |
| 63 | - gboolean * enabled; | |
| 64 | - gboolean destroy_on_close; | |
| 65 | - }; | |
| 66 | - | |
| 67 | - const GtkWindowClass * pw3270_trace_get_parent_class(void); | |
| 68 | - | |
| 69 | - G_END_DECLS | |
| 70 | - | |
| 71 | - G_DEFINE_TYPE(pw3270_trace, pw3270_trace, GTK_TYPE_WINDOW); | |
| 72 | - | |
| 73 | -/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 74 | - | |
| 75 | - const GtkWindowClass * pw3270_trace_get_parent_class(void) | |
| 76 | - { | |
| 77 | - trace("%s",__FUNCTION__); | |
| 78 | - return GTK_WINDOW_CLASS(pw3270_trace_parent_class); | |
| 79 | - } | |
| 80 | - | |
| 81 | - static void activate_default(GtkWindow *window) | |
| 82 | - { | |
| 83 | - pw3270_trace * hwnd = PW3270_TRACE(window); | |
| 84 | - | |
| 85 | - trace("%s",__FUNCTION__); | |
| 86 | - | |
| 87 | - if(hwnd->enabled) | |
| 88 | - { | |
| 89 | - if(*hwnd->line) | |
| 90 | - g_free(*hwnd->line); | |
| 91 | - | |
| 92 | - *hwnd->line = g_strdup(gtk_entry_get_text(GTK_ENTRY(hwnd->entry))); | |
| 93 | - | |
| 94 | - gtk_widget_set_sensitive(hwnd->entry,FALSE); | |
| 95 | - gtk_widget_set_sensitive(hwnd->button,FALSE); | |
| 96 | - | |
| 97 | - *hwnd->enabled = FALSE; | |
| 98 | - } | |
| 99 | - | |
| 100 | - } | |
| 101 | - | |
| 102 | -#if GTK_CHECK_VERSION(3,0,0) | |
| 103 | -static void destroy(GtkWidget *widget) | |
| 104 | -#else | |
| 105 | -static void destroy(GtkObject *widget) | |
| 106 | -#endif | |
| 107 | - { | |
| 108 | - pw3270_trace * hwnd = PW3270_TRACE(widget); | |
| 109 | - | |
| 110 | - if(hwnd->log_handler) | |
| 111 | - { | |
| 112 | - g_log_remove_handler(NULL,hwnd->log_handler); | |
| 113 | - hwnd->log_handler = 0; | |
| 114 | - } | |
| 115 | - | |
| 116 | - if(hwnd->line) | |
| 117 | - *hwnd->line = NULL; | |
| 118 | - | |
| 119 | - if(hwnd->enabled) | |
| 120 | - *hwnd->enabled = FALSE; | |
| 121 | - | |
| 122 | - } | |
| 123 | - | |
| 124 | - static gboolean delete_event(GtkWidget *widget, GdkEventAny *event) | |
| 125 | - { | |
| 126 | - pw3270_trace * hwnd = PW3270_TRACE(widget); | |
| 127 | - | |
| 128 | - trace("%s destroy=%s",__FUNCTION__,hwnd->destroy_on_close ? "Yes" : "No"); | |
| 129 | - | |
| 130 | - if(hwnd->line) | |
| 131 | - *hwnd->line = NULL; | |
| 132 | - | |
| 133 | - if(hwnd->enabled) | |
| 134 | - *hwnd->enabled = FALSE; | |
| 135 | - | |
| 136 | - if(hwnd->destroy_on_close) | |
| 137 | - return FALSE; | |
| 138 | - | |
| 139 | - gtk_widget_hide(widget); | |
| 140 | - return TRUE; | |
| 141 | - } | |
| 142 | - | |
| 143 | - static void pw3270_trace_class_init(pw3270_traceClass *klass) | |
| 144 | - { | |
| 145 | - GtkWindowClass * window_class = GTK_WINDOW_CLASS(klass); | |
| 146 | - GtkWidgetClass * widget_class = GTK_WIDGET_CLASS(klass); | |
| 147 | - | |
| 148 | - trace("%s",__FUNCTION__); | |
| 149 | - | |
| 150 | - window_class->activate_default = activate_default; | |
| 151 | - widget_class->delete_event = delete_event; | |
| 152 | - | |
| 153 | -#if GTK_CHECK_VERSION(3,0,0) | |
| 154 | - { | |
| 155 | - widget_class->destroy = destroy; | |
| 156 | - } | |
| 157 | -#else | |
| 158 | - { | |
| 159 | - GtkObjectClass *object_class = (GtkObjectClass*) klass; | |
| 160 | - object_class->destroy = destroy; | |
| 161 | - } | |
| 162 | -#endif // GTK3 | |
| 163 | - | |
| 164 | - } | |
| 165 | - | |
| 166 | - static void activate(GtkButton *button, GtkWindow *window) | |
| 167 | - { | |
| 168 | - trace("%s",__FUNCTION__); | |
| 169 | - activate_default(window); | |
| 170 | - } | |
| 171 | - | |
| 172 | - static void menu_save(GtkWidget *button, pw3270_trace *window) | |
| 173 | - { | |
| 174 | - GtkWindow * toplevel = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(window))); | |
| 175 | - GtkWidget * dialog; | |
| 176 | - | |
| 177 | - dialog = gtk_file_chooser_dialog_new( _( "Save trace file" ), | |
| 178 | - toplevel, | |
| 179 | - GTK_FILE_CHOOSER_ACTION_SAVE, | |
| 180 | - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
| 181 | - GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, | |
| 182 | - NULL ); | |
| 183 | - | |
| 184 | - gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE); | |
| 185 | - | |
| 186 | - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),g_get_user_special_dir(G_USER_DIRECTORY_DOCUMENTS)); | |
| 187 | - | |
| 188 | - if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) | |
| 189 | - { | |
| 190 | - gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | |
| 191 | - if(filename) | |
| 192 | - { | |
| 193 | - GError * error = NULL; | |
| 194 | - gchar * text; | |
| 195 | - GtkTextIter start; | |
| 196 | - GtkTextIter end; | |
| 197 | - | |
| 198 | - gtk_text_buffer_get_start_iter(window->text,&start); | |
| 199 | - gtk_text_buffer_get_end_iter(window->text,&end); | |
| 200 | - text = gtk_text_buffer_get_text(window->text,&start,&end,FALSE); | |
| 201 | - | |
| 202 | - g_file_set_contents(filename,text,-1,&error); | |
| 203 | - | |
| 204 | - g_free(text); | |
| 205 | - | |
| 206 | - if(error) | |
| 207 | - { | |
| 208 | - GtkWidget *popup = gtk_message_dialog_new_with_markup(GTK_WINDOW(dialog),GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE,_( "Can't save %s" ),filename); | |
| 209 | - | |
| 210 | - gtk_window_set_title(GTK_WINDOW(popup),_("Can't save file")); | |
| 211 | - | |
| 212 | - gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(popup),"%s",error->message); | |
| 213 | - g_error_free(error); | |
| 214 | - | |
| 215 | - gtk_dialog_run(GTK_DIALOG(popup)); | |
| 216 | - gtk_widget_destroy(popup); | |
| 217 | - | |
| 218 | - } | |
| 219 | - | |
| 220 | - g_free(filename); | |
| 221 | - } | |
| 222 | - } | |
| 223 | - | |
| 224 | - gtk_widget_destroy(dialog); | |
| 225 | - | |
| 226 | - } | |
| 227 | - | |
| 228 | - static void menu_close(GtkWidget *button, GtkWidget *window) | |
| 229 | - { | |
| 230 | - gtk_widget_destroy(window); | |
| 231 | - } | |
| 232 | - | |
| 233 | - struct submenu | |
| 234 | - { | |
| 235 | - const gchar * stock_id; | |
| 236 | - GCallback action; | |
| 237 | - }; | |
| 238 | - | |
| 239 | - static void build_menu(GtkWidget *menubar, pw3270_trace *window, const gchar *name, const struct submenu *item, size_t sz) | |
| 240 | - { | |
| 241 | - int f; | |
| 242 | - GtkWidget * menu = gtk_menu_new(); | |
| 243 | - GtkWidget * topitem = gtk_image_menu_item_new_from_stock( name, NULL ); | |
| 244 | - | |
| 245 | - gtk_menu_item_set_submenu(GTK_MENU_ITEM(topitem), menu); | |
| 246 | - | |
| 247 | - for(f=0;f<sz;f++) | |
| 248 | - { | |
| 249 | - GtkWidget *widget = gtk_image_menu_item_new_from_stock( item[f].stock_id, NULL ); | |
| 250 | - gtk_menu_shell_append(GTK_MENU_SHELL(menu),widget); | |
| 251 | - g_signal_connect(G_OBJECT(widget), "activate",item[f].action,window); | |
| 252 | - } | |
| 253 | - | |
| 254 | - gtk_menu_shell_append(GTK_MENU_SHELL(menubar), topitem); | |
| 255 | - } | |
| 256 | - | |
| 257 | - static void glog(const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,GtkWidget *window) | |
| 258 | - { | |
| 259 | - #ifndef LOG_INFO | |
| 260 | - #define LOG_INFO 0 | |
| 261 | - #endif // LOG_INFO | |
| 262 | - | |
| 263 | - #ifndef LOG_ERR | |
| 264 | - #define LOG_ERR 0 | |
| 265 | - #endif // LOG_ERR | |
| 266 | - | |
| 267 | - #ifndef LOG_DEBUG | |
| 268 | - #define LOG_DEBUG 0 | |
| 269 | - #endif // LOG_DEBUG | |
| 270 | - | |
| 271 | - static const struct _logtype | |
| 272 | - { | |
| 273 | - GLogLevelFlags log_level; | |
| 274 | - int priority; | |
| 275 | - const gchar * msg; | |
| 276 | - } logtype[] = | |
| 277 | - { | |
| 278 | - { G_LOG_FLAG_RECURSION, LOG_INFO, "recursion" }, | |
| 279 | - { G_LOG_FLAG_FATAL, LOG_ERR, "fatal error" }, | |
| 280 | - | |
| 281 | - /* GLib log levels */ | |
| 282 | - { G_LOG_LEVEL_ERROR, LOG_ERR, "error" }, | |
| 283 | - { G_LOG_LEVEL_CRITICAL, LOG_ERR, "critical error" }, | |
| 284 | - { G_LOG_LEVEL_WARNING, LOG_ERR, "warning" }, | |
| 285 | - { G_LOG_LEVEL_MESSAGE, LOG_ERR, "message" }, | |
| 286 | - { G_LOG_LEVEL_INFO, LOG_INFO, "info" }, | |
| 287 | - { G_LOG_LEVEL_DEBUG, LOG_DEBUG, "debug" }, | |
| 288 | - }; | |
| 289 | - | |
| 290 | - int f; | |
| 291 | - | |
| 292 | - for(f=0;f<G_N_ELEMENTS(logtype);f++) | |
| 293 | - { | |
| 294 | - if(logtype[f].log_level == log_level) | |
| 295 | - { | |
| 296 | - gchar *ptr; | |
| 297 | - gchar *text = g_strdup_printf("%s: %s %s",logtype[f].msg,log_domain ? log_domain : "",message); | |
| 298 | - for(ptr = text;*ptr;ptr++) | |
| 299 | - { | |
| 300 | - if(*ptr < ' ') | |
| 301 | - *ptr = ' '; | |
| 302 | - } | |
| 303 | - | |
| 304 | - pw3270_trace_printf(window,"%s\n",text); | |
| 305 | - | |
| 306 | -#ifdef HAVE_SYSLOG | |
| 307 | - syslog(logtype[f].priority,"%s",text); | |
| 308 | -#endif // HAVE_SYSLOG | |
| 309 | - g_free(text); | |
| 310 | - return; | |
| 311 | - } | |
| 312 | - } | |
| 313 | - | |
| 314 | - pw3270_trace_printf(window,"%s %s\n",log_domain ? log_domain : "", message); | |
| 315 | - | |
| 316 | -#ifdef HAVE_SYSLOG | |
| 317 | - syslog(LOG_INFO,"%s %s",log_domain ? log_domain : "", message); | |
| 318 | -#endif // HAVE_SYSLOG | |
| 319 | - | |
| 320 | - } | |
| 321 | - | |
| 322 | - static void pw3270_trace_init(pw3270_trace *window) | |
| 323 | - { | |
| 324 | - GtkWidget * widget; | |
| 325 | - GtkWidget * view; | |
| 326 | -#if GTK_CHECK_VERSION(3,0,0) | |
| 327 | - GtkWidget * vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL,0); | |
| 328 | -#else | |
| 329 | - GtkWidget * vbox = gtk_vbox_new(FALSE,0); | |
| 330 | -#endif // GTK_CHECK_VERSION | |
| 331 | - gchar * fontname = get_string_from_config("trace", "fontname", "Monospace 8"); | |
| 332 | - PangoFontDescription * fontdesc = pango_font_description_from_string("Monospace 8"); | |
| 333 | - | |
| 334 | - g_free(fontname); | |
| 335 | - | |
| 336 | - // Top menu | |
| 337 | - { | |
| 338 | - | |
| 339 | - static const struct submenu filemenu[] = | |
| 340 | - { | |
| 341 | - { GTK_STOCK_SAVE_AS, G_CALLBACK(menu_save) }, | |
| 342 | - { GTK_STOCK_QUIT, G_CALLBACK(menu_close) }, | |
| 343 | - | |
| 344 | - }; | |
| 345 | - | |
| 346 | - widget = gtk_menu_bar_new(); | |
| 347 | - | |
| 348 | - build_menu(widget, window, GTK_STOCK_FILE, filemenu, G_N_ELEMENTS(filemenu)); | |
| 349 | - | |
| 350 | - gtk_box_pack_start(GTK_BOX(vbox),widget,FALSE,TRUE,0); | |
| 351 | - } | |
| 352 | - | |
| 353 | - // Trace container | |
| 354 | - widget = gtk_scrolled_window_new(NULL,NULL); | |
| 355 | - window->scroll = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(widget)); | |
| 356 | - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(widget),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); | |
| 357 | - view = gtk_text_view_new(); | |
| 358 | - | |
| 359 | -#if GTK_CHECK_VERSION(3,0,0) | |
| 360 | - gtk_widget_override_font(GTK_WIDGET(view), fontdesc); | |
| 361 | -#else | |
| 362 | - gtk_widget_modify_font(GTK_WIDGET(view), fontdesc); | |
| 363 | -#endif // GTK_CHECK_VERSION | |
| 364 | - | |
| 365 | - window->text = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view)); | |
| 366 | - gtk_text_view_set_editable(GTK_TEXT_VIEW(view), TRUE); | |
| 367 | - | |
| 368 | -#if GTK_CHECK_VERSION(3,8,0) | |
| 369 | - gtk_container_add(GTK_CONTAINER(widget),view); | |
| 370 | -#else | |
| 371 | - gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(widget),view); | |
| 372 | -#endif // GTK_CHECK_VERSION | |
| 373 | - gtk_box_pack_start(GTK_BOX(vbox),widget,TRUE,TRUE,0); | |
| 374 | - | |
| 375 | - // Edit box | |
| 376 | -#if GTK_CHECK_VERSION(3,0,0) | |
| 377 | - widget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); | |
| 378 | -#else | |
| 379 | - widget = gtk_hbox_new(FALSE,0); | |
| 380 | -#endif // GTK_CHECK_VERSION | |
| 381 | - gtk_box_pack_start(GTK_BOX(widget),gtk_label_new( _( "Command:" )),FALSE,TRUE,4); | |
| 382 | - window->entry = gtk_entry_new(); | |
| 383 | - gtk_box_pack_start(GTK_BOX(widget),window->entry,TRUE,TRUE,4); | |
| 384 | - gtk_widget_set_sensitive(window->entry,FALSE); | |
| 385 | - g_signal_connect(G_OBJECT(window->entry),"activate",G_CALLBACK(activate),window); | |
| 386 | - | |
| 387 | - window->button = gtk_button_new_from_stock(GTK_STOCK_OK); | |
| 388 | - gtk_box_pack_end(GTK_BOX(widget),window->button,FALSE,FALSE,4); | |
| 389 | - gtk_widget_set_sensitive(window->button,FALSE); | |
| 390 | - gtk_button_set_focus_on_click(GTK_BUTTON(window->button),FALSE); | |
| 391 | - | |
| 392 | - g_signal_connect(G_OBJECT(window->button),"clicked",G_CALLBACK(activate),window); | |
| 393 | - | |
| 394 | - gtk_box_pack_start(GTK_BOX(vbox),widget,FALSE,TRUE,0); | |
| 395 | - | |
| 396 | - gtk_widget_show_all(vbox); | |
| 397 | - | |
| 398 | - gtk_container_add(GTK_CONTAINER(window),vbox); | |
| 399 | - | |
| 400 | - pango_font_description_free(fontdesc); | |
| 401 | - | |
| 402 | - window->log_handler = g_log_set_handler(NULL,G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,(GLogFunc) glog,window); | |
| 403 | - trace("Log handler set to %d",window->log_handler); | |
| 404 | - | |
| 405 | - } | |
| 406 | - | |
| 407 | - GtkWidget * pw3270_trace_new(void) | |
| 408 | - { | |
| 409 | - return g_object_new(PW3270_TYPE_TRACE, NULL); | |
| 410 | - } | |
| 411 | - | |
| 412 | - void pw3270_trace_vprintf(GtkWidget *widget, const char *fmt, va_list args) | |
| 413 | - { | |
| 414 | - GtkTextIter itr; | |
| 415 | - gchar * msg; | |
| 416 | - pw3270_trace * hwnd = PW3270_TRACE(widget); | |
| 417 | - | |
| 418 | - gtk_text_buffer_get_end_iter(hwnd->text,&itr); | |
| 419 | - | |
| 420 | - msg = g_strdup_vprintf(fmt,args); | |
| 421 | - | |
| 422 | - if(g_utf8_validate(msg,strlen(msg),NULL)) | |
| 423 | - { | |
| 424 | - gtk_text_buffer_insert(hwnd->text,&itr,msg,strlen(msg)); | |
| 425 | - } | |
| 426 | - else | |
| 427 | - { | |
| 428 | - gtk_text_buffer_insert(hwnd->text,&itr,"** Invalid UTF8 String **",-1); | |
| 429 | - } | |
| 430 | - g_free(msg); | |
| 431 | - | |
| 432 | - gtk_text_buffer_get_end_iter(hwnd->text,&itr); | |
| 433 | - | |
| 434 | -#if GTK_CHECK_VERSION(2,14,0) | |
| 435 | - gtk_adjustment_set_value(hwnd->scroll,gtk_adjustment_get_upper(hwnd->scroll)); | |
| 436 | -#else | |
| 437 | - gtk_adjustment_set_value(hwnd->scroll,(GTK_ADJUSTMENT(hwnd->scroll))->upper); | |
| 438 | -#endif // | |
| 439 | - | |
| 440 | - } | |
| 441 | - | |
| 442 | - void pw3270_trace_printf(GtkWidget *widget, const char *fmt, ... ) | |
| 443 | - { | |
| 444 | - va_list arg_ptr; | |
| 445 | - va_start(arg_ptr, fmt); | |
| 446 | - pw3270_trace_vprintf(widget,fmt,arg_ptr); | |
| 447 | - va_end(arg_ptr); | |
| 448 | - } | |
| 449 | - | |
| 450 | - LIB3270_EXPORT gchar * pw3270_trace_get_command(GtkWidget *widget) | |
| 451 | - { | |
| 452 | - pw3270_trace * hwnd = PW3270_TRACE(widget); | |
| 453 | - gchar * line = NULL; | |
| 454 | - gboolean enabled = TRUE; | |
| 455 | - | |
| 456 | - hwnd->line = &line; | |
| 457 | - hwnd->enabled = &enabled; | |
| 458 | - | |
| 459 | - gtk_window_present(GTK_WINDOW(widget)); | |
| 460 | - gtk_widget_set_sensitive(hwnd->entry,TRUE); | |
| 461 | - gtk_widget_set_sensitive(hwnd->button,TRUE); | |
| 462 | - gtk_widget_grab_focus(hwnd->entry); | |
| 463 | - | |
| 464 | - while(enabled) | |
| 465 | - { | |
| 466 | - gtk_main_iteration(); | |
| 467 | - } | |
| 468 | - | |
| 469 | - hwnd->line = NULL; | |
| 470 | - hwnd->enabled = NULL; | |
| 471 | - | |
| 472 | - return line; | |
| 473 | - } | |
| 474 | - | |
| 475 | - LIB3270_EXPORT void pw3270_trace_set_destroy_on_close(GtkWidget *widget,gboolean on) | |
| 476 | - { | |
| 477 | - PW3270_TRACE(widget)->destroy_on_close = on; | |
| 478 | - } |
src/pw3270/window.c
| ... | ... | @@ -33,6 +33,8 @@ |
| 33 | 33 | #include "uiparser/parser.h" |
| 34 | 34 | #include <lib3270/popup.h> |
| 35 | 35 | #include <lib3270/actions.h> |
| 36 | +#include <lib3270/trace.h> | |
| 37 | +#include <v3270/trace.h> | |
| 36 | 38 | |
| 37 | 39 | /*--[ Widget definition ]----------------------------------------------------------------------------*/ |
| 38 | 40 | |
| ... | ... | @@ -155,11 +157,129 @@ |
| 155 | 157 | |
| 156 | 158 | } |
| 157 | 159 | |
| 160 | + /* | |
| 161 | + static void g_trace(H3270 *hSession, const char *fmt, va_list args) | |
| 162 | + { | |
| 163 | + gchar *ptr = g_strdup_vprintf(fmt,args); | |
| 164 | + | |
| 165 | + if(tracefile) | |
| 166 | + { | |
| 167 | + // Has trace file, use it | |
| 168 | + int err; | |
| 169 | + | |
| 170 | + FILE *out = fopen(tracefile,"a"); | |
| 171 | + err = errno; | |
| 172 | + | |
| 173 | + if(!out) | |
| 174 | + { | |
| 175 | + // Error opening trace file, notify user and disable it | |
| 176 | + GtkWidget *popup = gtk_message_dialog_new_with_markup( | |
| 177 | + GTK_WINDOW(pw3270_get_toplevel()), | |
| 178 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 179 | + GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE, | |
| 180 | + _( "Can't save trace data to file %s" ),tracefile); | |
| 181 | + | |
| 182 | + gtk_window_set_title(GTK_WINDOW(popup),_("Can't open file")); | |
| 183 | + | |
| 184 | + gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(popup),"%s",strerror(err)); | |
| 185 | + | |
| 186 | + gtk_dialog_run(GTK_DIALOG(popup)); | |
| 187 | + gtk_widget_destroy(popup); | |
| 188 | + | |
| 189 | + tracefile = NULL; | |
| 190 | + } | |
| 191 | + else | |
| 192 | + { | |
| 193 | + fprintf(out,"%s",ptr); | |
| 194 | + fclose(out); | |
| 195 | + } | |
| 196 | + } | |
| 197 | + else | |
| 198 | + { | |
| 199 | + // No trace file, open standard window | |
| 200 | + gchar * utftext = g_convert_with_fallback(ptr,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL); | |
| 201 | + | |
| 202 | + if(!trace_window) | |
| 203 | + { | |
| 204 | + trace_window = v3270_trace_new_from_session(hSession); | |
| 205 | + v3270_trace_set_destroy_on_close(trace_window,TRUE); | |
| 206 | + g_signal_connect(trace_window, "destroy", G_CALLBACK(trace_window_destroy), hSession); | |
| 207 | + gtk_window_set_default_size(GTK_WINDOW(trace_window),590,430); | |
| 208 | + gtk_widget_show(trace_window); | |
| 209 | + } | |
| 210 | + v3270_trace_printf(trace_window,"%s",utftext); | |
| 211 | + g_free(utftext); | |
| 212 | + } | |
| 213 | + | |
| 214 | + g_free(ptr); | |
| 215 | + } | |
| 216 | + */ | |
| 217 | + | |
| 218 | + static void trace_file(G_GNUC_UNUSED H3270 *hSession, void * userdata, const char *fmt, va_list args) | |
| 219 | + { | |
| 220 | + int err; | |
| 221 | + | |
| 222 | + FILE *out = fopen(tracefile,"a"); | |
| 223 | + err = errno; | |
| 224 | + | |
| 225 | + if(!out) | |
| 226 | + { | |
| 227 | + // Error opening trace file, notify user and disable it | |
| 228 | + GtkWidget *popup = gtk_message_dialog_new_with_markup( | |
| 229 | + GTK_WINDOW(userdata), | |
| 230 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 231 | + GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE, | |
| 232 | + _( "Can't save trace data to file %s" ),tracefile); | |
| 233 | + | |
| 234 | + gtk_window_set_title(GTK_WINDOW(popup),_("Can't open file")); | |
| 235 | + | |
| 236 | + gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(popup),"%s",strerror(err)); | |
| 237 | + | |
| 238 | + gtk_dialog_run(GTK_DIALOG(popup)); | |
| 239 | + gtk_widget_destroy(popup); | |
| 240 | + | |
| 241 | + tracefile = NULL; | |
| 242 | + } | |
| 243 | + else | |
| 244 | + { | |
| 245 | + vfprintf(out,fmt,args); | |
| 246 | + fclose(out); | |
| 247 | + } | |
| 248 | + | |
| 249 | + } | |
| 250 | + | |
| 251 | + static void trace_window_destroy(GtkWidget *widget, H3270 *hSession) | |
| 252 | + { | |
| 253 | + trace("%s",__FUNCTION__); | |
| 254 | + lib3270_set_toggle(hSession,LIB3270_TOGGLE_DS_TRACE,0); | |
| 255 | + lib3270_set_toggle(hSession,LIB3270_TOGGLE_SCREEN_TRACE,0); | |
| 256 | + lib3270_set_toggle(hSession,LIB3270_TOGGLE_EVENT_TRACE,0); | |
| 257 | + lib3270_set_toggle(hSession,LIB3270_TOGGLE_NETWORK_TRACE,0); | |
| 258 | + } | |
| 259 | + | |
| 260 | + | |
| 261 | + static void trace_window(G_GNUC_UNUSED H3270 *hSession, G_GNUC_UNUSED void * userdata, const char *fmt, va_list args) | |
| 262 | + { | |
| 263 | + GtkWidget * widget = v3270_trace_new_from_session(hSession); | |
| 264 | + v3270_trace_set_destroy_on_close(widget,TRUE); | |
| 265 | + g_signal_connect(widget, "destroy", G_CALLBACK(trace_window_destroy), hSession); | |
| 266 | + gtk_widget_show(widget); | |
| 267 | + } | |
| 268 | + | |
| 158 | 269 | GtkWidget * pw3270_new(const gchar *host, const gchar *systype, unsigned short colors) |
| 159 | 270 | { |
| 160 | 271 | GtkWidget * widget = g_object_new(GTK_TYPE_PW3270, NULL); |
| 161 | 272 | gboolean connct = FALSE; |
| 162 | 273 | |
| 274 | + if(tracefile) | |
| 275 | + { | |
| 276 | + lib3270_set_trace_handler(pw3270_get_session(widget),trace_file,(void *) widget); | |
| 277 | + } | |
| 278 | + else | |
| 279 | + { | |
| 280 | + lib3270_set_trace_handler(pw3270_get_session(widget),trace_window,(void *) widget); | |
| 281 | + } | |
| 282 | + | |
| 163 | 283 | if(host) |
| 164 | 284 | { |
| 165 | 285 | set_string_to_config("host","uri","%s",host); |
| ... | ... | @@ -212,7 +332,7 @@ |
| 212 | 332 | |
| 213 | 333 | void pw3270_set_url(GtkWidget *widget, const gchar *uri) |
| 214 | 334 | { |
| 215 | - g_return_val_if_fail(GTK_IS_PW3270(widget),""); | |
| 335 | + g_return_if_fail(GTK_IS_PW3270(widget)); | |
| 216 | 336 | v3270_set_url(GTK_PW3270(widget)->terminal,uri); |
| 217 | 337 | } |
| 218 | 338 | ... | ... |