Commit 8d37354a0fb22eb5801f999967d47899a5447bdf
1 parent
31052932
Exists in
master
and in
5 other branches
Incluindo novo tratamento de janelas popup
Showing
12 changed files
with
169 additions
and
261 deletions
Show diff stats
pw3270.cbp
... | ... | @@ -116,6 +116,8 @@ |
116 | 116 | </Unit> |
117 | 117 | <Unit filename="src/include/lib3270.h" /> |
118 | 118 | <Unit filename="src/include/lib3270/config.h.in" /> |
119 | + <Unit filename="src/include/lib3270/log.h" /> | |
120 | + <Unit filename="src/include/lib3270/popup.h" /> | |
119 | 121 | <Unit filename="src/include/lib3270/session.h" /> |
120 | 122 | <Unit filename="src/include/pw3270.h" /> |
121 | 123 | <Unit filename="src/include/rules.mak.in" /> | ... | ... |
src/gtk/main.c
... | ... | @@ -31,22 +31,61 @@ |
31 | 31 | |
32 | 32 | #include "globals.h" |
33 | 33 | #include "v3270/v3270.h" |
34 | +#include <lib3270/popup.h> | |
34 | 35 | #include <stdlib.h> |
35 | 36 | |
37 | +/*--[ Statics ]--------------------------------------------------------------------------------------*/ | |
38 | + | |
39 | + static GtkWidget *toplevel = NULL; | |
40 | + | |
36 | 41 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
37 | 42 | |
38 | -int main (int argc, char *argv[]) | |
43 | +static int popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list args) | |
39 | 44 | { |
40 | - GtkWidget *window; | |
45 | + GtkWidget * dialog; | |
46 | + GtkMessageType msgtype = GTK_MESSAGE_WARNING; | |
47 | + GtkButtonsType buttons = GTK_BUTTONS_OK; | |
48 | + gchar * text = g_strdup_vprintf(fmt,args); | |
49 | + | |
50 | + if(type == LIB3270_NOTIFY_CRITICAL) | |
51 | + { | |
52 | + msgtype = GTK_MESSAGE_ERROR; | |
53 | + buttons = GTK_BUTTONS_CLOSE; | |
54 | + } | |
55 | + | |
56 | + if(msg) | |
57 | + { | |
58 | + dialog = gtk_message_dialog_new_with_markup(GTK_WINDOW(toplevel),GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,msgtype,buttons,"%s",msg); | |
59 | + gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog),"%s",text); | |
60 | + } | |
61 | + else | |
62 | + { | |
63 | + dialog = gtk_message_dialog_new_with_markup(GTK_WINDOW(toplevel),GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,msgtype,buttons,"%s",text); | |
64 | + } | |
41 | 65 | |
66 | + g_free(text); | |
67 | + | |
68 | + gtk_window_set_title(GTK_WINDOW(dialog),title ? title : "Error"); | |
69 | + | |
70 | + gtk_dialog_run(GTK_DIALOG (dialog)); | |
71 | + gtk_widget_destroy(dialog); | |
72 | + | |
73 | + | |
74 | + return 0; | |
75 | +} | |
76 | + | |
77 | +int main (int argc, char *argv[]) | |
78 | +{ | |
42 | 79 | gtk_init(&argc, &argv); |
80 | + | |
43 | 81 | configuration_init(); |
82 | + lib3270_set_popup_handler(popup_handler); | |
44 | 83 | |
45 | - window = create_main_window(); | |
84 | + toplevel = create_main_window(); | |
46 | 85 | |
47 | - if(window) | |
86 | + if(toplevel) | |
48 | 87 | { |
49 | - gtk_widget_show(window); | |
88 | + gtk_widget_show(toplevel); | |
50 | 89 | gtk_main(); |
51 | 90 | } |
52 | 91 | ... | ... |
src/gtk/v3270/widget.c
... | ... | @@ -108,11 +108,18 @@ static void v3270_toggle_changed(v3270 *widget,LIB3270_TOGGLE toggle_id, gboolea |
108 | 108 | |
109 | 109 | } |
110 | 110 | |
111 | +static void loghandler(H3270 *session, const char *module, int rc, const char *fmt, va_list args) | |
112 | +{ | |
113 | + g_logv(module,rc ? G_LOG_LEVEL_WARNING : G_LOG_LEVEL_MESSAGE, fmt, args); | |
114 | +} | |
115 | + | |
111 | 116 | static void v3270_class_init(v3270Class *klass) |
112 | 117 | { |
113 | 118 | GObjectClass * gobject_class = G_OBJECT_CLASS(klass); |
114 | 119 | GtkWidgetClass * widget_class = GTK_WIDGET_CLASS(klass); |
115 | 120 | |
121 | + lib3270_set_log_handler(loghandler); | |
122 | + | |
116 | 123 | widget_class->realize = v3270_realize; |
117 | 124 | widget_class->size_allocate = v3270_size_allocate; |
118 | 125 | widget_class->key_press_event = v3270_key_press_event; |
... | ... | @@ -395,7 +402,7 @@ static void v3270_init(v3270 *widget) |
395 | 402 | |
396 | 403 | if(widget->host->sz != sizeof(H3270)) |
397 | 404 | { |
398 | - g_critical(N_( "Unexpected signature in H3270 object, possible version mismatch in lib3270") ); | |
405 | + g_error(N_( "Unexpected signature in H3270 object, possible version mismatch in lib3270") ); | |
399 | 406 | return; |
400 | 407 | } |
401 | 408 | ... | ... |
... | ... | @@ -0,0 +1,50 @@ |
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 | + * Este programa está nomeado como api.h e possui 444 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 | + * licinio@bb.com.br (Licínio Luis Branco) | |
28 | + * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | |
29 | + * | |
30 | + */ | |
31 | + | |
32 | +#ifndef LIB3270_POPUP_INCLUDED | |
33 | + | |
34 | + #define LIB3270_POPUP_INCLUDED 1 | |
35 | + | |
36 | + typedef enum _LIB3270_NOTIFY | |
37 | + { | |
38 | + LIB3270_NOTIFY_INFO, /**< Simple information dialog */ | |
39 | + LIB3270_NOTIFY_WARNING, | |
40 | + LIB3270_NOTIFY_ERROR, | |
41 | + LIB3270_NOTIFY_CRITICAL, /**< Critical error, user can abort application */ | |
42 | + | |
43 | + LIB3270_NOTIFY_USER /**< Reserver, always the last one */ | |
44 | + } LIB3270_NOTIFY; | |
45 | + | |
46 | + LIB3270_EXPORT void lib3270_set_popup_handler(int (*popup_handler)(H3270 *, LIB3270_NOTIFY, const char *, const char *, const char *, va_list)); | |
47 | + | |
48 | +#endif // LIB3270_POPUP_INCLUDED | |
49 | + | |
50 | + | ... | ... |
src/lib3270/api.h
... | ... | @@ -26,7 +26,6 @@ |
26 | 26 | * erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) |
27 | 27 | * licinio@bb.com.br (Licínio Luis Branco) |
28 | 28 | * kraucer@bb.com.br (Kraucer Fernandes Mazuco) |
29 | - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) | |
30 | 29 | * |
31 | 30 | */ |
32 | 31 | |
... | ... | @@ -179,15 +178,7 @@ |
179 | 178 | |
180 | 179 | |
181 | 180 | /** Type of dialog boxes */ |
182 | - typedef enum _LIB3270_NOTIFY | |
183 | - { | |
184 | - LIB3270_NOTIFY_INFO, /**< Simple information dialog */ | |
185 | - LIB3270_NOTIFY_WARNING, | |
186 | - LIB3270_NOTIFY_ERROR, | |
187 | - LIB3270_NOTIFY_CRITICAL, /**< Critical error, user can abort application */ | |
188 | - | |
189 | - LIB3270_NOTIFY_USER /**< Reserver, always the last one */ | |
190 | - } LIB3270_NOTIFY; | |
181 | + #include <lib3270/popup.h> | |
191 | 182 | |
192 | 183 | #define PW3270_DIALOG_INFO LIB3270_NOTIFY_INFO |
193 | 184 | #define PW3270_DIALOG_CRITICAL LIB3270_NOTIFY_CRITICAL | ... | ... |
src/lib3270/charset.c
... | ... | @@ -410,7 +410,7 @@ resource_charset(char *csname, char *cs, char *ftcs) |
410 | 410 | #endif /*]*/ |
411 | 411 | break; |
412 | 412 | default: |
413 | - popup_an_error("Extra %s value(s), ignoring", | |
413 | + popup_an_error(NULL,"Extra %s value(s), ignoring", | |
414 | 414 | ResDisplayCharset); |
415 | 415 | break; |
416 | 416 | } |
... | ... | @@ -421,7 +421,7 @@ resource_charset(char *csname, char *cs, char *ftcs) |
421 | 421 | #if defined(X3270_DBCS) /*[*/ |
422 | 422 | /* Can't swap DBCS modes while connected. */ |
423 | 423 | if (IN_3270 && (n_rcs == 2) != dbcs) { |
424 | - popup_an_error("Can't change DBCS modes while connected"); | |
424 | + popup_an_error(NULL,"Can't change DBCS modes while connected"); | |
425 | 425 | return CS_ILLEGAL; |
426 | 426 | } |
427 | 427 | #endif /*]*/ |
... | ... | @@ -646,7 +646,7 @@ remap_chars(char *csname, char *spec, remap_scope scope, int *ne) |
646 | 646 | s = CN; |
647 | 647 | } |
648 | 648 | if (ebc != 256) { |
649 | - popup_an_error("Charset has %d entries, need 256", ebc); | |
649 | + popup_an_error(NULL,"Charset has %d entries, need 256", ebc); | |
650 | 650 | rc = CS_BAD; |
651 | 651 | } else { |
652 | 652 | /* |
... | ... | @@ -679,7 +679,7 @@ remap_chars(char *csname, char *spec, remap_scope scope, int *ne) |
679 | 679 | ((ebc = strtoul(ebcs, &ptr, 0)), |
680 | 680 | ptr == ebcs || *ptr != '\0') || |
681 | 681 | (iso = parse_keysym(isos, True)) == NoSymbol) { |
682 | - popup_an_error("Cannot parse %s \"%s\", entry %d", | |
682 | + popup_an_error(NULL,"Cannot parse %s \"%s\", entry %d", | |
683 | 683 | ResCharset, csname, *ne); |
684 | 684 | rc = CS_BAD; |
685 | 685 | break; | ... | ... |
src/lib3270/ctlr.c
... | ... | @@ -225,7 +225,7 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr) |
225 | 225 | if(idx < 0 || idx >= (sizeof(sz)/sizeof(struct _sz))) |
226 | 226 | { |
227 | 227 | idx = 2; |
228 | - popup_an_error("Unknown model: %d - Defaulting to 4 (%dx%d)", mn, sz[idx].cols,sz[idx].rows); | |
228 | + popup_an_error(NULL,"Unknown model: %d - Defaulting to 4 (%dx%d)", mn, sz[idx].cols,sz[idx].rows); | |
229 | 229 | mn = 4; |
230 | 230 | } |
231 | 231 | |
... | ... | @@ -237,13 +237,13 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr) |
237 | 237 | if (ovc != 0 || ovr != 0) |
238 | 238 | { |
239 | 239 | if (ovc <= 0 || ovr <= 0) |
240 | - popup_an_error("Invalid %s %dx%d:\nNegative or zero",ResOversize, ovc, ovr); | |
240 | + popup_an_error(NULL,"Invalid %s %dx%d:\nNegative or zero",ResOversize, ovc, ovr); | |
241 | 241 | else if (ovc * ovr >= 0x4000) |
242 | - popup_an_error("Invalid %s %dx%d:\nToo big",ResOversize, ovc, ovr); | |
242 | + popup_an_error(NULL,"Invalid %s %dx%d:\nToo big",ResOversize, ovc, ovr); | |
243 | 243 | else if (ovc > 0 && ovc < session->maxCOLS) |
244 | - popup_an_error("Invalid %s cols (%d):\nLess than model %d cols (%d)",ResOversize, ovc, session->model_num, session->maxCOLS); | |
244 | + popup_an_error(NULL,"Invalid %s cols (%d):\nLess than model %d cols (%d)",ResOversize, ovc, session->model_num, session->maxCOLS); | |
245 | 245 | else if (ovr > 0 && ovr < session->maxROWS) |
246 | - popup_an_error("Invalid %s rows (%d):\nLess than model %d rows (%d)",ResOversize, ovr, session->model_num, session->maxROWS); | |
246 | + popup_an_error(NULL,"Invalid %s rows (%d):\nLess than model %d rows (%d)",ResOversize, ovr, session->model_num, session->maxROWS); | |
247 | 247 | else |
248 | 248 | update_model_info(session,mn,session->ov_cols = ovc,session->ov_rows = ovr); |
249 | 249 | } |
... | ... | @@ -563,8 +563,7 @@ process_ds(unsigned char *buf, int buflen) |
563 | 563 | break; |
564 | 564 | default: |
565 | 565 | /* unknown 3270 command */ |
566 | - popup_an_error("Unknown 3270 Data Stream command: 0x%X\n", | |
567 | - buf[0]); | |
566 | + popup_an_error(NULL,"Unknown 3270 Data Stream command: 0x%X\n",buf[0]); | |
568 | 567 | return PDS_BAD_CMD; |
569 | 568 | } |
570 | 569 | } | ... | ... |
src/lib3270/glue.c
... | ... | @@ -198,7 +198,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model) |
198 | 198 | model_number = parse_model_number(model); |
199 | 199 | if (model_number < 0) |
200 | 200 | { |
201 | - popup_an_error("Invalid model number: %s", model); | |
201 | + popup_an_error(NULL,"Invalid model number: %s", model); | |
202 | 202 | model_number = 0; |
203 | 203 | } |
204 | 204 | |
... | ... | @@ -268,7 +268,7 @@ H3270 * lib3270_session_new(const char *model) |
268 | 268 | Trace("Charset: %s",appres.charset); |
269 | 269 | if (charset_init(appres.charset) != CS_OKAY) |
270 | 270 | { |
271 | - Warning( _( "Cannot find charset \"%s\", using defaults" ), appres.charset); | |
271 | + Warning(NULL, _( "Cannot find charset \"%s\", using defaults" ), appres.charset); | |
272 | 272 | (void) charset_init(CN); |
273 | 273 | } |
274 | 274 | ... | ... |
src/lib3270/kybd.c
... | ... | @@ -3245,7 +3245,7 @@ static void |
3245 | 3245 | do_pa(unsigned n) |
3246 | 3246 | { |
3247 | 3247 | if (n < 1 || n > PA_SZ) { |
3248 | - popup_an_error( _( "Unknown PA key %d" ), n); | |
3248 | + popup_an_error(NULL, _( "Unknown PA key %d" ), n); | |
3249 | 3249 | return; |
3250 | 3250 | } |
3251 | 3251 | |
... | ... | @@ -3257,7 +3257,7 @@ do_pa(unsigned n) |
3257 | 3257 | static void do_pf(unsigned n) |
3258 | 3258 | { |
3259 | 3259 | if (n < 1 || n > PF_SZ) { |
3260 | - popup_an_error( _( "Unknown PF key %d" ), n); | |
3260 | + popup_an_error(NULL, _( "Unknown PF key %d" ), n); | |
3261 | 3261 | return; |
3262 | 3262 | } |
3263 | 3263 | |
... | ... | @@ -3471,8 +3471,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3471 | 3471 | case BACKSLASH: /* last character was a backslash */ |
3472 | 3472 | switch (c) { |
3473 | 3473 | case 'a': |
3474 | - popup_an_error("%s: Bell not supported", | |
3475 | - action_name(String_action)); | |
3474 | + popup_an_error(NULL,"%s: Bell not supported",action_name(String_action)); | |
3476 | 3475 | // cancel_if_idle_command(); |
3477 | 3476 | state = BASE; |
3478 | 3477 | break; |
... | ... | @@ -3520,7 +3519,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3520 | 3519 | state = BASE; |
3521 | 3520 | break; |
3522 | 3521 | case 'v': |
3523 | - popup_an_error("%s: Vertical tab not supported",action_name(String_action)); | |
3522 | + popup_an_error(NULL,"%s: Vertical tab not supported",action_name(String_action)); | |
3524 | 3523 | // cancel_if_idle_command(); |
3525 | 3524 | state = BASE; |
3526 | 3525 | break; |
... | ... | @@ -3561,8 +3560,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3561 | 3560 | state = BACKPF; |
3562 | 3561 | break; |
3563 | 3562 | default: |
3564 | - popup_an_error("%s: Unknown character " | |
3565 | - "after \\p", | |
3563 | + popup_an_error(NULL,"%s: Unknown character after \\p", | |
3566 | 3564 | action_name(String_action)); |
3567 | 3565 | // cancel_if_idle_command(); |
3568 | 3566 | state = BASE; |
... | ... | @@ -3574,8 +3572,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3574 | 3572 | literal = (literal * 10) + (c - '0'); |
3575 | 3573 | nc++; |
3576 | 3574 | } else if (!nc) { |
3577 | - popup_an_error("%s: Unknown character " | |
3578 | - "after \\pf", | |
3575 | + popup_an_error(NULL,"%s: Unknown character after \\pf", | |
3579 | 3576 | action_name(String_action)); |
3580 | 3577 | // cancel_if_idle_command(); |
3581 | 3578 | state = BASE; |
... | ... | @@ -3593,8 +3590,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3593 | 3590 | literal = (literal * 10) + (c - '0'); |
3594 | 3591 | nc++; |
3595 | 3592 | } else if (!nc) { |
3596 | - popup_an_error("%s: Unknown character " | |
3597 | - "after \\pa", | |
3593 | + popup_an_error(NULL,"%s: Unknown character after \\pa", | |
3598 | 3594 | action_name(String_action)); |
3599 | 3595 | // cancel_if_idle_command(); |
3600 | 3596 | state = BASE; |
... | ... | @@ -3614,7 +3610,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3614 | 3610 | nc = 0; |
3615 | 3611 | continue; |
3616 | 3612 | } else { |
3617 | - popup_an_error("%s: Missing hex digits after \x", | |
3613 | + popup_an_error(NULL,"%s: Missing hex digits after \x", | |
3618 | 3614 | action_name(String_action)); |
3619 | 3615 | // cancel_if_idle_command(); |
3620 | 3616 | state = BASE; |
... | ... | @@ -3691,7 +3687,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3691 | 3687 | } |
3692 | 3688 | break; |
3693 | 3689 | default: |
3694 | - popup_an_error("%s: Missing data after \", | |
3690 | + popup_an_error(NULL,"%s: Missing data after \", | |
3695 | 3691 | action_name(String_action)); |
3696 | 3692 | // cancel_if_idle_command(); |
3697 | 3693 | break; | ... | ... |
src/lib3270/proxy.c
... | ... | @@ -228,7 +228,7 @@ proxy_setup(char **phost, char **pport) |
228 | 228 | *pport = NewString(PORT_SOCKS5D); |
229 | 229 | return PT_SOCKS5D; |
230 | 230 | } |
231 | - popup_an_error("Invalid proxy type '%.*s'", sl, proxy); | |
231 | + popup_an_error(NULL,"Invalid proxy type '%.*s'", sl, proxy); | |
232 | 232 | return -1; |
233 | 233 | } |
234 | 234 | |
... | ... | @@ -695,7 +695,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) |
695 | 695 | if (rv == -2) |
696 | 696 | use_name = 1; |
697 | 697 | else if (rv < 0) { |
698 | - popup_an_error("SOCKS5 proxy: %s/%u: %s", host, port, | |
698 | + popup_an_error(NULL,"SOCKS5 proxy: %s/%u: %s", host, port, | |
699 | 699 | errmsg); |
700 | 700 | return -1; |
701 | 701 | } |
... | ... | @@ -863,7 +863,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) |
863 | 863 | switch (nread++) { |
864 | 864 | case 0: |
865 | 865 | if (r != 0x05) { |
866 | - popup_an_error("SOCKS5 Proxy: incorrect " | |
866 | + popup_an_error(NULL,"SOCKS5 Proxy: incorrect " | |
867 | 867 | "reply version 0x%02x", r); |
868 | 868 | #if defined(X3270_TRACE) /*[*/ |
869 | 869 | if (nread) |
... | ... | @@ -932,7 +932,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) |
932 | 932 | break; |
933 | 933 | #endif /*]*/ |
934 | 934 | default: |
935 | - popup_an_error("SOCKS5 Proxy: unknown server " | |
935 | + popup_an_error(NULL,"SOCKS5 Proxy: unknown server " | |
936 | 936 | "address type 0x%02x", r); |
937 | 937 | #if defined(X3270_TRACE) /*[*/ |
938 | 938 | if (nread) | ... | ... |
src/lib3270/screen.c
... | ... | @@ -26,7 +26,6 @@ |
26 | 26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) |
27 | 27 | * licinio@bb.com.br (Licínio Luis Branco) |
28 | 28 | * kraucer@bb.com.br (Kraucer Fernandes Mazuco) |
29 | - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) | |
30 | 29 | * |
31 | 30 | */ |
32 | 31 | |
... | ... | @@ -75,11 +74,15 @@ |
75 | 74 | #define get_color_pair(fg,bg) (((bg&0x0F) << 4) | (fg&0x0F)) |
76 | 75 | #define DEFCOLOR_MAP(f) ((((f) & FA_PROTECT) >> 4) | (((f) & FA_INT_HIGH_SEL) >> 3)) |
77 | 76 | |
78 | -#if defined(WC3270) /*[*/ | |
79 | -extern char *profile_name; | |
80 | -#endif | |
77 | +// #if defined(WC3270) | |
78 | +// extern char *profile_name; | |
79 | +// #endif | |
80 | + | |
81 | +static int logpopup(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg); | |
82 | + | |
83 | +static int (*popup_handler)(H3270 *, LIB3270_NOTIFY, const char *, const char *, const char *, va_list) = logpopup; | |
81 | 84 | |
82 | -static const struct lib3270_screen_callbacks *callbacks = NULL; | |
85 | +// static const struct lib3270_screen_callbacks *callbacks = NULL; | |
83 | 86 | // static SCRIPT_STATE script_state = SCRIPT_STATE_NONE; |
84 | 87 | |
85 | 88 | |
... | ... | @@ -92,12 +95,10 @@ static void status_connect(H3270 *session, int ignored, void *dunno); |
92 | 95 | static void status_3270_mode(H3270 *session, int ignored, void *dunno); |
93 | 96 | static void status_printer(H3270 *session, int on, void *dunno); |
94 | 97 | static unsigned short color_from_fa(unsigned char fa); |
95 | -static void relabel(H3270 *session, int ignored, void *dunno); | |
98 | +// static void relabel(H3270 *session, int ignored, void *dunno); | |
96 | 99 | |
97 | 100 | void set_display_charset(char *dcs) |
98 | 101 | { |
99 | - if(callbacks && callbacks->charset) | |
100 | - callbacks->charset(dcs); | |
101 | 102 | } |
102 | 103 | |
103 | 104 | static void addch(H3270 *session, int baddr, unsigned char c, unsigned short attr) |
... | ... | @@ -109,9 +110,6 @@ static void addch(H3270 *session, int baddr, unsigned char c, unsigned short att |
109 | 110 | ea_buf[baddr].chr = c; |
110 | 111 | ea_buf[baddr].attr = attr; |
111 | 112 | |
112 | - if(callbacks && callbacks->addch) | |
113 | - callbacks->addch(baddr/session->cols, baddr%session->cols, c, attr); | |
114 | - | |
115 | 113 | if(session->update) |
116 | 114 | session->update(session,baddr,c,attr,baddr == session->cursor_addr); |
117 | 115 | } |
... | ... | @@ -126,76 +124,19 @@ int screen_init(H3270 *session) |
126 | 124 | { |
127 | 125 | CHECK_SESSION_HANDLE(session); |
128 | 126 | |
129 | - /* Initialize the console. */ | |
130 | - if(callbacks) | |
131 | - { | |
132 | - /* Init default callbacks */ | |
133 | - if(callbacks->move_cursor) | |
134 | - session->update_cursor = callbacks->move_cursor; | |
135 | - | |
136 | - if(callbacks->set_oia) | |
137 | - session->update_oia = callbacks->set_oia; | |
138 | - | |
139 | - if(callbacks->set_viewsize) | |
140 | - session->configure = callbacks->set_viewsize; | |
141 | - | |
142 | - if(callbacks->lu) | |
143 | - session->update_luname = callbacks->lu; | |
144 | - | |
145 | - if(callbacks->status) | |
146 | - session->update_status = callbacks->status; | |
147 | - | |
148 | - if(callbacks->erase) | |
149 | - session->erase = callbacks->erase; | |
150 | - | |
151 | - if(callbacks->cursor) | |
152 | - session->cursor = callbacks->cursor; | |
153 | - | |
154 | - if(callbacks->toggle_changed) | |
155 | - session->update_toggle = callbacks->toggle_changed; | |
156 | - | |
157 | - if(callbacks->model_changed) | |
158 | - session->update_model = callbacks->model_changed; | |
159 | - | |
160 | - if(callbacks->init()) | |
161 | - { | |
162 | - popup_an_error(session,"Can't initialize terminal."); | |
163 | - return -1; | |
164 | - } | |
165 | - } | |
166 | - | |
167 | 127 | /* Set up callbacks for state changes. */ |
168 | 128 | lib3270_register_schange(session,ST_CONNECT, status_connect,0); |
169 | 129 | lib3270_register_schange(session,ST_3270_MODE, status_3270_mode,0); |
170 | 130 | lib3270_register_schange(session,ST_PRINTER, status_printer,0); |
171 | 131 | |
172 | - lib3270_register_schange(session,ST_HALF_CONNECT, relabel,0); | |
173 | - lib3270_register_schange(session,ST_CONNECT, relabel,0); | |
174 | - lib3270_register_schange(session,ST_3270_MODE, relabel,0); | |
175 | - | |
176 | - /* See about all-bold behavior. */ | |
177 | -// if (appres.all_bold_on) | |
178 | -// ab_mode = TS_ON; | |
179 | -// else if (!ts_value(appres.all_bold, &ab_mode)) | |
180 | -// (void) fprintf(stderr, "invalid %s value: '%s', assuming 'auto'\n", ResAllBold, appres.all_bold); | |
181 | -// if (ab_mode == TS_AUTO) | |
182 | -// ab_mode = appres.m3279? TS_ON: TS_OFF; | |
132 | +// lib3270_register_schange(session,ST_HALF_CONNECT, relabel,0); | |
133 | +// lib3270_register_schange(session,ST_CONNECT, relabel,0); | |
134 | +// lib3270_register_schange(session,ST_3270_MODE, relabel,0); | |
183 | 135 | |
184 | 136 | /* Set up the controller. */ |
185 | 137 | ctlr_init(session,-1); |
186 | 138 | ctlr_reinit(session,-1); |
187 | 139 | |
188 | - /* Set the window label. */ | |
189 | -#if defined(WC3270) /*[*/ | |
190 | - | |
191 | - if (appres.title != CN) | |
192 | - screen_title(appres.title); | |
193 | - else if (profile_name != CN) | |
194 | - screen_title(profile_name); | |
195 | - else | |
196 | - screen_title(NULL); | |
197 | -#endif | |
198 | - | |
199 | 140 | /* Finish screen initialization. */ |
200 | 141 | screen_suspend(session); |
201 | 142 | |
... | ... | @@ -318,8 +259,6 @@ void update_model_info(H3270 *session, int model, int cols, int rows) |
318 | 259 | |
319 | 260 | if(session->update_model) |
320 | 261 | session->update_model(session, session->model_name,session->model_num,rows,cols); |
321 | - else if(callbacks && callbacks->model_changed) | |
322 | - callbacks->model_changed(session, session->model_name,session->model_num,rows,cols); | |
323 | 262 | } |
324 | 263 | |
325 | 264 | LIB3270_EXPORT int lib3270_get_contents(H3270 *h, int first, int last, unsigned char *chr, unsigned short *attr) |
... | ... | @@ -452,27 +391,16 @@ static void screen_update(H3270 *session, int bstart, int bend) |
452 | 391 | |
453 | 392 | void screen_disp(H3270 *session) |
454 | 393 | { |
455 | -// session->first_changed = -1; | |
456 | -// session->last_changed = -1; | |
457 | - | |
458 | 394 | screen_update(session,0,session->rows*session->cols); |
459 | - | |
460 | - if(callbacks && callbacks->display) | |
461 | - callbacks->display(session); | |
462 | 395 | } |
463 | 396 | |
464 | 397 | void screen_suspend(H3270 *session) |
465 | 398 | { |
466 | - if(callbacks && callbacks->set_suspended) | |
467 | - callbacks->set_suspended(1); | |
468 | 399 | } |
469 | 400 | |
470 | 401 | void screen_resume(H3270 *session) |
471 | 402 | { |
472 | 403 | screen_disp(session); |
473 | - | |
474 | - if(callbacks && callbacks->set_suspended) | |
475 | - callbacks->set_suspended(0); | |
476 | 404 | } |
477 | 405 | |
478 | 406 | LIB3270_EXPORT int lib3270_get_cursor_address(H3270 *h) |
... | ... | @@ -586,12 +514,6 @@ void status_reset(H3270 *session) |
586 | 514 | |
587 | 515 | screen_disp(session); |
588 | 516 | |
589 | - if(callbacks && callbacks->reset) | |
590 | - { | |
591 | - Trace("%s calling reset",__FUNCTION__); | |
592 | - callbacks->reset(kybdlock); | |
593 | - } | |
594 | - | |
595 | 517 | } |
596 | 518 | |
597 | 519 | /** |
... | ... | @@ -700,59 +622,38 @@ static void status_printer(H3270 *session, int on, void *dunno) |
700 | 622 | set_status(session,OIA_FLAG_PRINTER,on); |
701 | 623 | } |
702 | 624 | |
703 | -/* | |
704 | -SCRIPT_STATE status_script(SCRIPT_STATE state) | |
705 | -{ | |
706 | - if(state != script_state && callbacks && callbacks->set_script) | |
707 | - callbacks->set_script(state); | |
708 | - return script_state = state; | |
709 | -} | |
710 | -*/ | |
711 | - | |
712 | 625 | void status_timing(H3270 *session, struct timeval *t0, struct timeval *t1) |
713 | 626 | { |
714 | - CHECK_SESSION_HANDLE(session); | |
715 | - | |
716 | - if(callbacks && callbacks->show_timer) | |
717 | - callbacks->show_timer(t1->tv_sec - t0->tv_sec); | |
718 | 627 | } |
719 | 628 | |
720 | 629 | void status_untiming(H3270 *session) |
721 | 630 | { |
722 | 631 | CHECK_SESSION_HANDLE(session); |
723 | 632 | |
724 | - if(callbacks && callbacks->show_timer) | |
725 | - callbacks->show_timer(-1); | |
726 | - | |
727 | 633 | if(session->set_timer) |
728 | 634 | session->set_timer(session,0); |
729 | 635 | } |
730 | 636 | |
731 | 637 | void ring_bell(void) |
732 | 638 | { |
733 | - if(callbacks && callbacks->ring_bell) | |
734 | - callbacks->ring_bell(); | |
735 | 639 | } |
736 | 640 | |
737 | -/* Set the window title. */ | |
738 | -void | |
739 | -screen_title(char *text) | |
641 | +/* Set the window title. */ /* | |
642 | +void screen_title(char *text) | |
740 | 643 | { |
741 | - if(callbacks && callbacks->title) | |
742 | - callbacks->title(text); | |
743 | 644 | } |
744 | 645 | |
745 | 646 | static void |
746 | 647 | relabel(H3270 *session, int ignored unused, void *dunno) |
747 | 648 | { |
748 | -#if defined(WC3270) /*[*/ | |
649 | +#if defined(WC3270) | |
749 | 650 | if (appres.title != CN) |
750 | 651 | return; |
751 | 652 | #endif |
752 | 653 | |
753 | 654 | if (PCONNECTED) |
754 | 655 | { |
755 | -#if defined(WC3270) /*[*/ | |
656 | +#if defined(WC3270) | |
756 | 657 | if (profile_name != CN) |
757 | 658 | screen_title(profile_name); |
758 | 659 | else |
... | ... | @@ -770,19 +671,7 @@ int query_counter(COUNTER_ID id) |
770 | 671 | { |
771 | 672 | return lib3270_event_counter[id]; |
772 | 673 | } |
773 | - | |
774 | -int Register3270ScreenCallbacks(const struct lib3270_screen_callbacks *cbk) | |
775 | -{ | |
776 | - if(!cbk) | |
777 | - return EINVAL; | |
778 | - | |
779 | - if(cbk->sz != sizeof(struct lib3270_screen_callbacks)) | |
780 | - return -EINVAL; | |
781 | - | |
782 | - callbacks = cbk; | |
783 | - | |
784 | - return 0; | |
785 | -} | |
674 | +*/ | |
786 | 675 | |
787 | 676 | void show_3270_popup_dialog(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, ...) |
788 | 677 | { |
... | ... | @@ -793,16 +682,15 @@ void show_3270_popup_dialog(H3270 *session, LIB3270_NOTIFY type, const char *tit |
793 | 682 | |
794 | 683 | va_list arg_ptr; |
795 | 684 | va_start(arg_ptr, fmt); |
796 | - | |
797 | - if(callbacks && callbacks->notify) | |
798 | - callbacks->notify(session,type,title,msg,fmt,arg_ptr); | |
799 | - else | |
800 | - lib3270_write_va_log(session,"lib3270",fmt,arg_ptr); | |
801 | - | |
685 | + popup_handler(session,type,title,msg,fmt,arg_ptr); | |
802 | 686 | va_end(arg_ptr); |
803 | 687 | |
804 | 688 | } |
805 | 689 | |
690 | +static int logpopup(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg) | |
691 | +{ | |
692 | + lib3270_write_va_log(session,"lib3270",fmt,arg); | |
693 | +} | |
806 | 694 | |
807 | 695 | void Error(H3270 *session, const char *fmt, ...) |
808 | 696 | { |
... | ... | @@ -811,12 +699,7 @@ void Error(H3270 *session, const char *fmt, ...) |
811 | 699 | CHECK_SESSION_HANDLE(session); |
812 | 700 | |
813 | 701 | va_start(arg_ptr, fmt); |
814 | - | |
815 | - if(callbacks && callbacks->notify) | |
816 | - callbacks->notify(session,LIB3270_NOTIFY_ERROR, _( "3270 Error" ),NULL,fmt,arg_ptr); | |
817 | - else | |
818 | - lib3270_write_va_log(&h3270,"lib3270",fmt,arg_ptr); | |
819 | - | |
702 | + popup_handler(session,LIB3270_NOTIFY_ERROR, _( "3270 Error" ),NULL,fmt,arg_ptr); | |
820 | 703 | va_end(arg_ptr); |
821 | 704 | |
822 | 705 | } |
... | ... | @@ -828,12 +711,7 @@ void Warning(H3270 *session, const char *fmt, ...) |
828 | 711 | CHECK_SESSION_HANDLE(session); |
829 | 712 | |
830 | 713 | va_start(arg_ptr, fmt); |
831 | - | |
832 | - if(callbacks && callbacks->notify) | |
833 | - callbacks->notify(session,LIB3270_NOTIFY_WARNING, _( "3270 Warning" ),NULL,fmt,arg_ptr); | |
834 | - else | |
835 | - lib3270_write_va_log(&h3270,"lib3270",fmt,arg_ptr); | |
836 | - | |
714 | + popup_handler(session,LIB3270_NOTIFY_WARNING, _( "3270 Warning" ),NULL,fmt,arg_ptr); | |
837 | 715 | va_end(arg_ptr); |
838 | 716 | |
839 | 717 | } |
... | ... | @@ -846,12 +724,7 @@ extern void popup_an_error(H3270 *session, const char *fmt, ...) |
846 | 724 | CHECK_SESSION_HANDLE(session); |
847 | 725 | |
848 | 726 | va_start(args, fmt); |
849 | - | |
850 | - if(callbacks && callbacks->notify) | |
851 | - callbacks->notify(session,LIB3270_NOTIFY_ERROR,_( "3270 Error" ),NULL,fmt,args); | |
852 | - else | |
853 | - lib3270_write_va_log(&h3270,"lib3270",fmt,args); | |
854 | - | |
727 | + popup_handler(session,LIB3270_NOTIFY_ERROR,_( "3270 Error" ),NULL,fmt,args); | |
855 | 728 | va_end(args); |
856 | 729 | |
857 | 730 | } |
... | ... | @@ -863,19 +736,13 @@ void popup_system_error(H3270 *session, const char *title, const char *message, |
863 | 736 | CHECK_SESSION_HANDLE(session); |
864 | 737 | |
865 | 738 | va_start(args, fmt); |
866 | - | |
867 | - if(callbacks && callbacks->notify) | |
868 | - callbacks->notify(session,LIB3270_NOTIFY_ERROR,title ? title : _( "3270 Error" ), message,fmt,args); | |
869 | - else | |
870 | - lib3270_write_va_log(&h3270,"lib3270",fmt,args); | |
871 | - | |
739 | + popup_handler(session,LIB3270_NOTIFY_ERROR,title ? title : _( "3270 Error" ), message,fmt,args); | |
872 | 740 | va_end(args); |
873 | 741 | } |
874 | 742 | |
875 | - | |
876 | - | |
877 | 743 | LIB3270_EXPORT void update_toggle_actions(void) |
878 | 744 | { |
745 | +/* | |
879 | 746 | int f; |
880 | 747 | |
881 | 748 | if(callbacks && callbacks->toggle_changed) |
... | ... | @@ -883,6 +750,7 @@ LIB3270_EXPORT void update_toggle_actions(void) |
883 | 750 | for(f=0;f< N_TOGGLES;f++) |
884 | 751 | callbacks->toggle_changed(&h3270,f,appres.toggle[f].value,TT_UPDATE,toggle_names[f]); |
885 | 752 | } |
753 | +*/ | |
886 | 754 | } |
887 | 755 | |
888 | 756 | void mcursor_set(H3270 *session,LIB3270_CURSOR m) |
... | ... | @@ -947,7 +815,7 @@ LIB3270_ACTION( testpattern ) |
947 | 815 | }; |
948 | 816 | |
949 | 817 | int row = 0; |
950 | - int max = (h3270.maxROWS * h3270.maxCOLS); | |
818 | + int max = (hSession->maxROWS * hSession->maxCOLS); | |
951 | 819 | int pos = 0; |
952 | 820 | int f; |
953 | 821 | int fg = COLOR_BLUE; |
... | ... | @@ -973,58 +841,14 @@ LIB3270_ACTION( testpattern ) |
973 | 841 | |
974 | 842 | Trace("%s display",__FUNCTION__); |
975 | 843 | |
976 | - screen_disp(&h3270); | |
844 | + screen_disp(hSession); | |
977 | 845 | |
978 | 846 | Trace("%s ends",__FUNCTION__); |
979 | 847 | return 0; |
980 | 848 | } |
981 | 849 | |
982 | -/* | |
983 | -LIB3270_EXPORT struct ea * copy_device_buffer(int *el) | |
984 | -{ | |
985 | - int sz = sizeof(struct ea) * (h3270.maxROWS * h3270.maxCOLS); | |
986 | - struct ea *ret = malloc(sz); | |
987 | - memcpy(ret,ea_buf,sz); | |
988 | - if(el) | |
989 | - *el = (h3270.maxROWS * h3270.maxCOLS); | |
990 | - return ret; | |
991 | -} | |
992 | -*/ | |
993 | - | |
994 | -/* | |
995 | -LIB3270_EXPORT HCONSOLE console_window_new(const char *title, const char *label) | |
996 | -{ | |
997 | - if(callbacks && callbacks->console_new ) | |
998 | - return callbacks->console_new(title,label); | |
999 | - | |
1000 | - return NULL; | |
1001 | -} | |
1002 | - | |
1003 | -LIB3270_EXPORT void console_window_delete(HCONSOLE hwnd) | |
1004 | -{ | |
1005 | - if(callbacks && callbacks->console_delete ) | |
1006 | - callbacks->console_delete(hwnd); | |
1007 | -} | |
1008 | - | |
1009 | -LIB3270_EXPORT int console_window_append(HCONSOLE hwnd, const char *fmt, ...) | |
850 | +LIB3270_EXPORT void lib3270_set_popup_handler(int (*handler)(H3270 *, LIB3270_NOTIFY, const char *, const char *, const char *, va_list)) | |
1010 | 851 | { |
1011 | - va_list args; | |
1012 | - | |
1013 | - if(callbacks && callbacks->console_append) | |
1014 | - { | |
1015 | - va_start(args, fmt); | |
1016 | - callbacks->console_append(hwnd, fmt, args); | |
1017 | - va_end(args); | |
1018 | - } | |
1019 | - | |
1020 | - return 0; | |
852 | + popup_handler = handler ? handler : logpopup; | |
1021 | 853 | } |
1022 | 854 | |
1023 | -LIB3270_EXPORT char * console_window_wait_for_user_entry(HCONSOLE hwnd) | |
1024 | -{ | |
1025 | - if(callbacks && callbacks->console_entry ) | |
1026 | - return callbacks->console_entry(hwnd); | |
1027 | - return NULL; | |
1028 | -} | |
1029 | -*/ | |
1030 | - | ... | ... |
src/lib3270/telnet.c
... | ... | @@ -475,7 +475,7 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving |
475 | 475 | |
476 | 476 | hp = gethostbyname(hn); |
477 | 477 | if (hp == (struct hostent *) 0) { |
478 | - popup_an_error("Unknown passthru host: %s", hn); | |
478 | + popup_an_error(NULL,"Unknown passthru host: %s", hn); | |
479 | 479 | return -1; |
480 | 480 | } |
481 | 481 | (void) memmove(passthru_haddr, hp->h_addr, hp->h_length); |
... | ... | @@ -497,7 +497,7 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving |
497 | 497 | if (ptr == portname || *ptr != '\0' || lport == 0L || |
498 | 498 | lport & ~0xffff) { |
499 | 499 | if (!(sp = getservbyname(portname, "tcp"))) { |
500 | - popup_an_error("Unknown port number " | |
500 | + popup_an_error(NULL,"Unknown port number " | |
501 | 501 | "or service: %s", portname); |
502 | 502 | return -1; |
503 | 503 | } |
... | ... | @@ -657,7 +657,7 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving |
657 | 657 | output_id = AddOutput(h3270.sock, &h3270, output_possible); |
658 | 658 | #endif /*]*/ |
659 | 659 | } else { |
660 | - popup_a_sockerr( N_( "Can't connect to %s:%d" ),h3270.hostname, h3270.current_port); | |
660 | + popup_a_sockerr(NULL, N_( "Can't connect to %s:%d" ),h3270.hostname, h3270.current_port); | |
661 | 661 | close_fail; |
662 | 662 | } |
663 | 663 | } else { |
... | ... | @@ -1029,7 +1029,7 @@ void net_input(H3270 *session) |
1029 | 1029 | */ |
1030 | 1030 | trace_dsn("RCVD socket error %d\n", errno); |
1031 | 1031 | if (HALF_CONNECTED) { |
1032 | - popup_a_sockerr( N_( "%s:%d" ),h3270.hostname, h3270.current_port); | |
1032 | + popup_a_sockerr(NULL, N_( "%s:%d" ),h3270.hostname, h3270.current_port); | |
1033 | 1033 | } else if (socket_errno() != SE_ECONNRESET) { |
1034 | 1034 | popup_a_sockerr(NULL, N_( "Socket read error" ) ); |
1035 | 1035 | } |
... | ... | @@ -3179,14 +3179,14 @@ non_blocking(Boolean on) |
3179 | 3179 | int i = on ? 1 : 0; |
3180 | 3180 | |
3181 | 3181 | if (SOCK_IOCTL(h3270.sock, FIONBIO, (int *) &i) < 0) { |
3182 | - popup_a_sockerr( N_( "ioctl(%s)" ), "FIONBIO"); | |
3182 | + popup_a_sockerr(NULL, N_( "ioctl(%s)" ), "FIONBIO"); | |
3183 | 3183 | return -1; |
3184 | 3184 | } |
3185 | 3185 | # else /*][*/ |
3186 | 3186 | int f; |
3187 | 3187 | |
3188 | 3188 | if ((f = fcntl(sock, F_GETFL, 0)) == -1) { |
3189 | - popup_an_errno(errno, N_( "fcntl(%s)" ), "F_GETFL" ); | |
3189 | + popup_an_errno(NULL,errno, N_( "fcntl(%s)" ), "F_GETFL" ); | |
3190 | 3190 | return -1; |
3191 | 3191 | } |
3192 | 3192 | if (on) |
... | ... | @@ -3194,7 +3194,7 @@ non_blocking(Boolean on) |
3194 | 3194 | else |
3195 | 3195 | f &= ~O_NDELAY; |
3196 | 3196 | if (fcntl(sock, F_SETFL, f) < 0) { |
3197 | - popup_an_errno(errno, N_( "fcntl(%s)" ), "F_GETFL"); | |
3197 | + popup_an_errno(NULL,errno, N_( "fcntl(%s)" ), "F_GETFL"); | |
3198 | 3198 | return -1; |
3199 | 3199 | } |
3200 | 3200 | # endif /*]*/ | ... | ... |