Commit 5a66c3882044ef002d241b0bdc6084e07128056e
1 parent
2705a1d4
Exists in
master
and in
5 other branches
Isolando estrutura de sessão para evitar que alterações na biblioteca causem que…
…bra de compatibilidade binária com o aplicativo principal ou plugins.
Showing
7 changed files
with
418 additions
and
466 deletions
Show diff stats
src/include/lib3270.h
... | ... | @@ -745,12 +745,10 @@ |
745 | 745 | */ |
746 | 746 | LIB3270_EXPORT const char * lib3270_get_luname(H3270 *h); |
747 | 747 | |
748 | -// #define lib3270_has_printer_session(h) (h->oia_flag[LIB3270_FLAG_PRINTER] != 0) | |
749 | - #define lib3270_has_active_script(h) (h->oia_flag[LIB3270_FLAG_SCRIPT] != 0) | |
750 | - #define lib3270_get_typeahead(h) (h->oia_flag[LIB3270_FLAG_TYPEAHEAD] != 0) | |
751 | - #define lib3270_get_undera(h) (h->oia_flag[LIB3270_FLAG_UNDERA] != 0) | |
752 | - #define lib3270_get_oia_box_solid(h) (h->oia_flag[LIB3270_FLAG_BOXSOLID] != 0) | |
753 | - | |
748 | + LIB3270_EXPORT int lib3270_has_active_script(H3270 *h); | |
749 | + LIB3270_EXPORT int lib3270_get_typeahead(H3270 *h); | |
750 | + LIB3270_EXPORT int lib3270_get_undera(H3270 *h); | |
751 | + LIB3270_EXPORT int lib3270_get_oia_box_solid(H3270 *h); | |
754 | 752 | LIB3270_EXPORT int lib3270_pconnected(H3270 *h); |
755 | 753 | LIB3270_EXPORT int lib3270_half_connected(H3270 *h); |
756 | 754 | LIB3270_EXPORT int lib3270_connected(H3270 *h); | ... | ... |
src/include/lib3270/session.h
... | ... | @@ -24,62 +24,16 @@ |
24 | 24 | * |
25 | 25 | * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) |
26 | 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 | 27 | * |
30 | 28 | */ |
31 | 29 | |
32 | 30 | #ifndef LIB3270_SESSION_H_INCLUDED |
33 | 31 | |
34 | 32 | #define LIB3270_SESSION_H_INCLUDED 1 |
35 | - #include <sys/time.h> | |
36 | 33 | |
34 | +// #include <sys/time.h> | |
37 | 35 | #include <lib3270/popup.h> |
38 | - #include <lib3270/charset.h> | |
39 | - | |
40 | - #define LIB3270_LUNAME_LENGTH 16 | |
41 | - #define LIB3270_FULL_MODEL_NAME_LENGTH 13 | |
42 | - #define LIB3270_LU_MAX 32 | |
43 | - | |
44 | - #define LIB3270_TELNET_N_OPTS 256 | |
45 | - | |
46 | - /** extended attributes */ | |
47 | - struct lib3270_ea; | |
48 | - struct lib3270_text; | |
49 | - | |
50 | - /* | |
51 | - struct lib3270_ea | |
52 | - { | |
53 | - unsigned char cc; ///< @brief EBCDIC or ASCII character code | |
54 | - unsigned char fa; ///< @brief field attribute, it nonzero | |
55 | - unsigned char fg; ///< @brief foreground color (0x00 or 0xf<n>) | |
56 | - unsigned char bg; ///< @brief background color (0x00 or 0xf<n>) | |
57 | - unsigned char gr; ///< @brief ANSI graphics rendition bits | |
58 | - unsigned char cs; ///< @brief character set (GE flag, or 0..2) | |
59 | - unsigned char ic; ///< @brief input control (DBCS) | |
60 | - unsigned char db; ///< @brief DBCS state | |
61 | - }; | |
62 | - */ | |
63 | - | |
64 | - /* | |
65 | - struct lib3270_text | |
66 | - { | |
67 | - unsigned char chr; ///< ASCII character code | |
68 | - unsigned short attr; ///< Converted character attribute (color & etc) | |
69 | - }; | |
70 | - */ | |
71 | - | |
72 | - #ifndef HEADER_SSL_H | |
73 | - #define SSL void | |
74 | - #endif // !HEADER_SSL_H | |
75 | - | |
76 | - #ifndef LIB3270_TA | |
77 | - #define LIB3270_TA void | |
78 | - #endif // !LIB3270_TA | |
79 | - | |
80 | - #define LIB3270_MB_MAX 16 | |
81 | - #define LIB3270_DEFAULT_CGEN 0x02b90000 | |
82 | - #define LIB3270_DEFAULT_CSET 0x00000025 | |
36 | +// #include <lib3270/charset.h> | |
83 | 37 | |
84 | 38 | struct lib3270_session_callbacks |
85 | 39 | { |
... | ... | @@ -116,357 +70,8 @@ |
116 | 70 | |
117 | 71 | }; |
118 | 72 | |
119 | - | |
120 | 73 | LIB3270_EXPORT struct lib3270_session_callbacks * lib3270_get_session_callbacks(H3270 *session, unsigned short sz); |
121 | 74 | |
122 | - struct _h3270 | |
123 | - { | |
124 | - unsigned short sz; /**< Struct size */ | |
125 | - | |
126 | - // Connection info | |
127 | - int sock; /**< Network socket */ | |
128 | - LIB3270_CSTATE cstate; /**< Connection state */ | |
129 | - | |
130 | - // flags | |
131 | - LIB3270_OPTION options; /**< Session options */ | |
132 | - | |
133 | - int bgthread : 1; /**< Running on a background thread ? */ | |
134 | - int selected : 1; /**< Has selected region? */ | |
135 | - int rectsel : 1; /**< Selected region is a rectangle ? */ | |
136 | - int vcontrol : 1; /**< Visible control ? */ | |
137 | - int modified_sel : 1; | |
138 | - int mono : 1; /**< Forces monochrome display */ | |
139 | - int m3279 : 1; | |
140 | - int extended : 1; | |
141 | - int typeahead : 1; | |
142 | - int numeric_lock : 1; | |
143 | - int oerr_lock : 1; | |
144 | - int unlock_delay : 1; | |
145 | - int auto_reconnect_inprogress : 1; | |
146 | - unsigned int colors : 5; | |
147 | - int apl_mode : 1; | |
148 | - int icrnl : 1; | |
149 | - int inlcr : 1; | |
150 | - int onlcr : 1; | |
151 | - int bsd_tm : 1; | |
152 | - int syncing : 1; | |
153 | - int reverse : 1; /**< reverse-input mode */ | |
154 | - int dbcs : 1; | |
155 | - int linemode : 1; | |
156 | - int trace_skipping : 1; | |
157 | - int need_tls_follows : 1; | |
158 | - int cut_xfer_in_progress : 1; | |
159 | -// int auto_keymap : 1; | |
160 | - int formatted : 1; /**< Formatted screen flag */ | |
161 | - int starting : 1; /**< Is starting (no first screen)? */ | |
162 | - | |
163 | - char * oversize; | |
164 | - | |
165 | - LIB3270_SSL_STATE secure; | |
166 | - | |
167 | - struct lib3270_toggle | |
168 | - { | |
169 | - char value; /**< toggle value */ | |
170 | - void (*upcall)(H3270 *, struct lib3270_toggle *, LIB3270_TOGGLE_TYPE); /**< change value */ | |
171 | - } toggle[LIB3270_TOGGLE_COUNT]; | |
172 | - | |
173 | - // Network & Termtype | |
174 | - char * connected_type; | |
175 | - char * connected_lu; | |
176 | - char luname[LIB3270_LUNAME_LENGTH+1]; | |
177 | - | |
178 | - char full_model_name[LIB3270_FULL_MODEL_NAME_LENGTH+1]; | |
179 | - char * model_name; | |
180 | - int model_num; | |
181 | - char * termtype; | |
182 | - | |
183 | - struct | |
184 | - { | |
185 | - char * current; /**< The hostname part, stripped of qualifiers, luname and port number */ | |
186 | - char * full; /**< The entire string, for use in reconnecting */ | |
187 | - char * srvc; /**< The service name */ | |
188 | - char * qualified; | |
189 | - } host; | |
190 | - | |
191 | - char * proxy; /**< Proxy server (type:host[:port]) */ | |
192 | - char * termname; | |
193 | - | |
194 | - struct lib3270_charset charset; | |
195 | - | |
196 | - LIB3270_MESSAGE oia_status; | |
197 | - | |
198 | - unsigned char oia_flag[LIB3270_FLAG_COUNT]; | |
199 | - | |
200 | - unsigned short current_port; | |
201 | - | |
202 | - // Misc | |
203 | - void * ft; /**< Active file transfer data */ | |
204 | - | |
205 | - // screen info | |
206 | - int ov_rows; | |
207 | - int ov_cols; | |
208 | - int maxROWS; | |
209 | - int maxCOLS; | |
210 | - unsigned short rows; | |
211 | - unsigned short cols; | |
212 | - int cursor_addr; | |
213 | - int buffer_addr; | |
214 | - char flipped; | |
215 | - int screen_alt; /**< alternate screen? */ | |
216 | - int is_altbuffer; | |
217 | - | |
218 | - // Screen contents | |
219 | - void * buffer[2]; /**< Internal buffers */ | |
220 | - struct lib3270_ea * ea_buf; /**< 3270 device buffer. ea_buf[-1] is the dummy default field attribute */ | |
221 | - struct lib3270_ea * aea_buf; /**< alternate 3270 extended attribute buffer */ | |
222 | - struct lib3270_text * text; /**< Converted 3270 chars */ | |
223 | - | |
224 | - // host.c | |
225 | - char std_ds_host; | |
226 | - char no_login_host; | |
227 | - char non_tn3270e_host; | |
228 | - char passthru_host; | |
229 | - char ssl_host; | |
230 | - char ever_3270; | |
231 | - | |
232 | - // ctlr.c | |
233 | - int sscp_start; | |
234 | - unsigned char default_fg; | |
235 | - unsigned char default_bg; | |
236 | - unsigned char default_gr; | |
237 | - unsigned char default_cs; | |
238 | - unsigned char default_ic; | |
239 | - char reply_mode; | |
240 | - int trace_primed : 1; | |
241 | - int ticking : 1; | |
242 | - int mticking : 1; | |
243 | - int crm_nattr; | |
244 | - unsigned char crm_attr[16]; | |
245 | - unsigned char * zero_buf; /**< empty buffer, for area clears */ | |
246 | - | |
247 | - struct timeval t_start; | |
248 | - void * tick_id; | |
249 | - struct timeval t_want; | |
250 | - | |
251 | - // Telnet.c | |
252 | - unsigned char * ibuf; | |
253 | - int ibuf_size; /**< size of ibuf */ | |
254 | - unsigned char * obuf; /**< 3270 output buffer */ | |
255 | - unsigned char * obptr; | |
256 | - time_t ns_time; | |
257 | - int ns_brcvd; | |
258 | - int ns_rrcvd; | |
259 | - int ns_bsent; | |
260 | - int ns_rsent; | |
261 | - struct timeval ds_ts; | |
262 | - unsigned long e_funcs; /**< negotiated TN3270E functions */ | |
263 | - unsigned short e_xmit_seq; /**< transmit sequence number */ | |
264 | - int response_required; | |
265 | - int tn3270e_bound; | |
266 | - int tn3270e_negotiated; | |
267 | - int ansi_data; | |
268 | - int lnext; | |
269 | - int backslashed; | |
270 | - char plu_name[LIB3270_BIND_PLU_NAME_MAX+1]; | |
271 | - char **lus; | |
272 | - char **curr_lu; | |
273 | - char * try_lu; | |
274 | - int proxy_type; | |
275 | - char * proxy_host; | |
276 | - char * proxy_portname; | |
277 | - unsigned short proxy_port; | |
278 | - char reported_lu[LIB3270_LU_MAX+1]; | |
279 | - char reported_type[LIB3270_LU_MAX+1]; | |
280 | - | |
281 | - enum | |
282 | - { | |
283 | - E_NONE, | |
284 | - E_3270, | |
285 | - E_NVT, | |
286 | - E_SSCP | |
287 | - } tn3270e_submode; | |
288 | - | |
289 | - unsigned char * lbuf; /**< line-mode input buffer */ | |
290 | - unsigned char * lbptr; | |
291 | - | |
292 | - | |
293 | - // 3270 input buffer | |
294 | - unsigned char * ibptr; | |
295 | - unsigned char * obuf_base; | |
296 | - int obuf_size; | |
297 | -// unsigned char * netrbuf; | |
298 | - | |
299 | - // network input buffer | |
300 | - unsigned char * sbbuf; | |
301 | - | |
302 | - // telnet sub-option buffer | |
303 | - unsigned char * sbptr; | |
304 | - unsigned char telnet_state; | |
305 | -// char ttype_tmpval[13]; | |
306 | - | |
307 | - unsigned char myopts[LIB3270_TELNET_N_OPTS]; | |
308 | - unsigned char hisopts[LIB3270_TELNET_N_OPTS]; | |
309 | - | |
310 | - // kybd.c | |
311 | - unsigned int kybdlock; ///< @brief keyboard lock state | |
312 | - unsigned char aid; ///< @brief current attention ID | |
313 | - void * unlock_id; | |
314 | - time_t unlock_delay_time; | |
315 | - unsigned long unlock_delay_ms; ///< @brief Delay before actually unlocking the keyboard after the host permits it. | |
316 | - LIB3270_TA * ta_head; | |
317 | - LIB3270_TA * ta_tail; | |
318 | - | |
319 | - // ft_dft.c | |
320 | - int dft_buffersize; ///< @brief Buffer size (LIMIN, LIMOUT) | |
321 | - | |
322 | - // rpq.c | |
323 | - int rpq_complained : 1; | |
324 | -#if !defined(_WIN32) | |
325 | - int omit_due_space_limit : 1; | |
326 | -#endif | |
327 | - | |
328 | - char * rpq_warnbuf; | |
329 | - int rpq_wbcnt; | |
330 | - | |
331 | - // User data (Usually points to session's widget) | |
332 | - void * user_data; | |
333 | - | |
334 | - // selection | |
335 | - char * paste_buffer; | |
336 | - struct | |
337 | - { | |
338 | - int start; | |
339 | - int end; | |
340 | - } select; | |
341 | - | |
342 | - // ansi.c | |
343 | - int scroll_top; | |
344 | - int scroll_bottom; | |
345 | - int once_cset; | |
346 | - int saved_cursor; | |
347 | - | |
348 | - int held_wrap : 1; | |
349 | - | |
350 | - int insert_mode : 1; | |
351 | - int auto_newline_mode : 1; | |
352 | - | |
353 | - int appl_cursor : 1; | |
354 | - int saved_appl_cursor : 1; | |
355 | - | |
356 | - int wraparound_mode : 1; | |
357 | - int saved_wraparound_mode : 1; | |
358 | - | |
359 | - int rev_wraparound_mode : 1; | |
360 | - int saved_rev_wraparound_mode : 1; | |
361 | - | |
362 | - int allow_wide_mode : 1; | |
363 | - int saved_allow_wide_mode : 1; | |
364 | - | |
365 | - int wide_mode : 1; | |
366 | - int saved_wide_mode : 1; | |
367 | - | |
368 | - int saved_altbuffer : 1; | |
369 | - int ansi_reset : 1; /**< Non zero if the ansi_reset() was called in this session */ | |
370 | - | |
371 | - int ansi_ch; | |
372 | - int cs_to_change; | |
373 | - | |
374 | - /** ANSI Character sets. */ | |
375 | - enum lib3270_ansi_cs | |
376 | - { | |
377 | - LIB3270_ANSI_CS_G0 = 0, | |
378 | - LIB3270_ANSI_CS_G1 = 1, | |
379 | - LIB3270_ANSI_CS_G2 = 2, | |
380 | - LIB3270_ANSI_CS_G3 = 3 | |
381 | - } cset; | |
382 | - enum lib3270_ansi_cs saved_cset; | |
383 | - | |
384 | - /** Character set designations. */ | |
385 | - enum lib3270_ansi_csd | |
386 | - { | |
387 | - LIB3270_ANSI_CSD_LD = 0, | |
388 | - LIB3270_ANSI_CSD_UK = 1, | |
389 | - LIB3270_ANSI_CSD_US = 2 | |
390 | - } csd[4]; | |
391 | - enum lib3270_ansi_csd saved_csd[4]; | |
392 | - | |
393 | - enum lib3270_ansi_state | |
394 | - { | |
395 | - LIB3270_ANSI_STATE_DATA = 0, | |
396 | - LIB3270_ANSI_STATE_ESC = 1, | |
397 | - LIB3270_ANSI_STATE_CSDES = 2, | |
398 | - LIB3270_ANSI_STATE_N1 = 3, | |
399 | - LIB3270_ANSI_STATE_DECP = 4, | |
400 | - LIB3270_ANSI_STATE_TEXT = 5, | |
401 | - LIB3270_ANSI_STATE_TEXT2 = 6, | |
402 | - LIB3270_ANSI_STATE_MBPEND = 7 | |
403 | - } state; | |
404 | - | |
405 | - unsigned char * tabs; | |
406 | - | |
407 | - int pmi; | |
408 | - char pending_mbs[LIB3270_MB_MAX]; | |
409 | - | |
410 | - unsigned char gr; | |
411 | - unsigned char saved_gr; | |
412 | - | |
413 | - unsigned char fg; | |
414 | - unsigned char saved_fg; | |
415 | - | |
416 | - unsigned char bg; | |
417 | - unsigned char saved_bg; | |
418 | - | |
419 | - // xio | |
420 | - void * ns_read_id; | |
421 | - void * ns_write_id; | |
422 | - void * ns_exception_id; | |
423 | - | |
424 | - // SSL Data (Always defined to mantain the same structure size) | |
425 | - unsigned long ssl_error; | |
426 | - SSL * ssl_con; | |
427 | - | |
428 | - // Callbacks. | |
429 | - struct lib3270_state_callback * st_callbacks[LIB3270_STATE_USER]; | |
430 | - struct lib3270_state_callback * st_last[LIB3270_STATE_USER]; | |
431 | - struct lib3270_session_callbacks cbk; | |
432 | - | |
433 | - // Session based callbacks | |
434 | - /* | |
435 | - int (*write)(H3270 *hSession, unsigned const char *buf, int len); | |
436 | - void (*disconnect)(H3270 *hSession); | |
437 | - | |
438 | - void (*configure)(H3270 *session, unsigned short rows, unsigned short cols); | |
439 | - void (*update)(H3270 *session, int baddr, unsigned char c, unsigned short attr, unsigned char cursor); | |
440 | - void (*changed)(H3270 *session, int offset, int len); | |
441 | - void (*display)(H3270 *session); | |
442 | - void (*set_width)(H3270 *session, int width); | |
443 | - | |
444 | - void (*update_cursor)(H3270 *session, unsigned short row, unsigned short col, unsigned char c, unsigned short attr); | |
445 | - void (*update_oia)(H3270 *session, LIB3270_FLAG id, unsigned char on); | |
446 | - void (*update_toggle)(H3270 *session, LIB3270_TOGGLE ix, unsigned char value, LIB3270_TOGGLE_TYPE reason, const char *name); | |
447 | - void (*update_luname)(H3270 *session, const char *name); | |
448 | - void (*update_status)(H3270 *session, LIB3270_MESSAGE id); | |
449 | - void (*update_connect)(H3270 *session, unsigned char connected); | |
450 | - void (*update_model)(H3270 *session, const char *name, int model, int rows, int cols); | |
451 | - void (*update_selection)(H3270 *session, int start, int end); | |
452 | - void (*update_ssl)(H3270 *session, LIB3270_SSL_STATE state); | |
453 | - | |
454 | - void (*set_timer)(H3270 *session, unsigned char on); | |
455 | - void (*erase)(H3270 *session); | |
456 | - void (*suspend)(H3270 *session); | |
457 | - void (*resume)(H3270 *session); | |
458 | - void (*cursor)(H3270 *session, LIB3270_CURSOR id); | |
459 | - void (*set_selection)(H3270 *session, unsigned char on); | |
460 | - void (*ctlr_done)(H3270 *session); | |
461 | - void (*autostart)(H3270 *session); | |
462 | - int (*print)(H3270 *session); | |
463 | - | |
464 | - void (*message)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text); | |
465 | - */ | |
466 | - | |
467 | - }; | |
468 | - | |
469 | - | |
470 | 75 | #endif // LIB3270_SESSION_H_INCLUDED |
471 | 76 | |
472 | 77 | ... | ... |
src/lib3270/host.c
... | ... | @@ -375,3 +375,26 @@ LIB3270_EXPORT const char * lib3270_get_luname(H3270 *h) |
375 | 375 | return h->connected_lu; |
376 | 376 | } |
377 | 377 | |
378 | +LIB3270_EXPORT int lib3270_has_active_script(H3270 *h) | |
379 | +{ | |
380 | + CHECK_SESSION_HANDLE(h); | |
381 | + return (h->oia_flag[LIB3270_FLAG_SCRIPT] != 0); | |
382 | +} | |
383 | + | |
384 | +LIB3270_EXPORT int lib3270_get_typeahead(H3270 *h) | |
385 | +{ | |
386 | + CHECK_SESSION_HANDLE(h); | |
387 | + return (h->oia_flag[LIB3270_FLAG_TYPEAHEAD] != 0); | |
388 | +} | |
389 | + | |
390 | +LIB3270_EXPORT int lib3270_get_undera(H3270 *h) | |
391 | +{ | |
392 | + CHECK_SESSION_HANDLE(h); | |
393 | + return (h->oia_flag[LIB3270_FLAG_UNDERA] != 0); | |
394 | +} | |
395 | + | |
396 | +LIB3270_EXPORT int lib3270_get_oia_box_solid(H3270 *h) | |
397 | +{ | |
398 | + CHECK_SESSION_HANDLE(h); | |
399 | + return (h->oia_flag[LIB3270_FLAG_BOXSOLID] != 0); | |
400 | +} | ... | ... |
src/lib3270/private.h
... | ... | @@ -24,15 +24,13 @@ |
24 | 24 | * |
25 | 25 | * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) |
26 | 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 | - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) | |
30 | 27 | * |
31 | 28 | */ |
32 | 29 | |
33 | 30 | /* Autoconf settings. */ |
34 | 31 | #include <lib3270/config.h> /* autoconf settings */ |
35 | 32 | #include <lib3270.h> /* lib3270 API calls and defs */ |
33 | +#include <lib3270/charset.h> | |
36 | 34 | #include "api.h" |
37 | 35 | |
38 | 36 | #if defined(X3270_TN3270E) && !defined(X3270_ANSI) /*[*/ |
... | ... | @@ -148,20 +146,19 @@ struct toggle_name { |
148 | 146 | /* Naming convention for private actions. */ |
149 | 147 | #define PA_PFX "PA-" |
150 | 148 | |
151 | -/* Shorthand macros */ | |
152 | - | |
149 | +/// @brief Shorthand macros | |
153 | 150 | #define CN ((char *) NULL) |
154 | 151 | #define PN ((XtPointer) NULL) |
155 | 152 | #define Replace(var, value) { lib3270_free(var); var = (value); }; |
156 | 153 | |
157 | -/* Configuration change masks. */ | |
158 | -#define NO_CHANGE 0x0000 /* no change */ | |
159 | -#define MODEL_CHANGE 0x0001 /* screen dimensions changed */ | |
160 | -#define FONT_CHANGE 0x0002 /* emulator font changed */ | |
161 | -#define COLOR_CHANGE 0x0004 /* color scheme or 3278/9 mode changed */ | |
162 | -#define SCROLL_CHANGE 0x0008 /* scrollbar snapped on or off */ | |
163 | -#define CHARSET_CHANGE 0x0010 /* character set changed */ | |
164 | -#define ALL_CHANGE 0xffff /* everything changed */ | |
154 | +/// @brief Configuration change masks. | |
155 | +#define NO_CHANGE 0x0000 /// @brief no change | |
156 | +#define MODEL_CHANGE 0x0001 /// @brief screen dimensions changed | |
157 | +#define FONT_CHANGE 0x0002 /// @brief emulator font changed | |
158 | +#define COLOR_CHANGE 0x0004 /// @brief color scheme or 3278/9 mode changed | |
159 | +#define SCROLL_CHANGE 0x0008 /// @brief scrollbar snapped on or off | |
160 | +#define CHARSET_CHANGE 0x0010 /// @brief character set changed | |
161 | +#define ALL_CHANGE 0xffff /// @brief everything changed | |
165 | 162 | |
166 | 163 | /* Portability macros */ |
167 | 164 | |
... | ... | @@ -186,7 +183,7 @@ struct toggle_name { |
186 | 183 | |
187 | 184 | /* DBCS Preedit Types */ |
188 | 185 | #if defined(X3270_DBCS) /*[*/ |
189 | - #define PT_ROOT "Root" | |
186 | + #define PT_ROOT "Root" | |
190 | 187 | #define PT_OVER_THE_SPOT "OverTheSpot" |
191 | 188 | #define PT_OFF_THE_SPOT "OffTheSpot" |
192 | 189 | #define PT_ON_THE_SPOT "OnTheSpot" |
... | ... | @@ -211,7 +208,7 @@ LIB3270_INTERNAL struct _ansictl |
211 | 208 | char vlnext; |
212 | 209 | } ansictl; |
213 | 210 | |
214 | -/** extended attributes */ | |
211 | +/** @brief Extended attributes */ | |
215 | 212 | struct lib3270_ea |
216 | 213 | { |
217 | 214 | unsigned char cc; ///< @brief EBCDIC or ASCII character code |
... | ... | @@ -230,21 +227,346 @@ struct lib3270_text |
230 | 227 | unsigned short attr; ///< @brief Converted character attribute (color & etc) |
231 | 228 | }; |
232 | 229 | |
230 | +#ifndef HEADER_SSL_H | |
231 | + #define SSL void | |
232 | +#endif // !HEADER_SSL_H | |
233 | + | |
234 | +#ifndef LIB3270_TA | |
235 | + #define LIB3270_TA void | |
236 | +#endif // !LIB3270_TA | |
237 | + | |
238 | +#define LIB3270_MB_MAX 16 | |
239 | +#define LIB3270_DEFAULT_CGEN 0x02b90000 | |
240 | +#define LIB3270_DEFAULT_CSET 0x00000025 | |
241 | + | |
242 | +#define LIB3270_LUNAME_LENGTH 16 | |
243 | +#define LIB3270_FULL_MODEL_NAME_LENGTH 13 | |
244 | +#define LIB3270_LU_MAX 32 | |
233 | 245 | |
246 | +#define LIB3270_TELNET_N_OPTS 256 | |
234 | 247 | |
235 | 248 | |
236 | -/* default charset translation tables */ | |
237 | -// LIB3270_INTERNAL const unsigned short ebc2asc0[256]; | |
238 | -// LIB3270_INTERNAL const unsigned short asc2ft0[256]; | |
249 | +/** @brief lib3270 session data */ | |
250 | +struct _h3270 | |
251 | +{ | |
252 | + unsigned short sz; /**< Struct size */ | |
253 | + | |
254 | + // Connection info | |
255 | + int sock; /**< Network socket */ | |
256 | + LIB3270_CSTATE cstate; /**< Connection state */ | |
257 | + | |
258 | + // flags | |
259 | + LIB3270_OPTION options; /**< Session options */ | |
260 | + | |
261 | + int bgthread : 1; /**< Running on a background thread ? */ | |
262 | + int selected : 1; /**< Has selected region? */ | |
263 | + int rectsel : 1; /**< Selected region is a rectangle ? */ | |
264 | + int vcontrol : 1; /**< Visible control ? */ | |
265 | + int modified_sel : 1; | |
266 | + int mono : 1; /**< Forces monochrome display */ | |
267 | + int m3279 : 1; | |
268 | + int extended : 1; | |
269 | + int typeahead : 1; | |
270 | + int numeric_lock : 1; | |
271 | + int oerr_lock : 1; | |
272 | + int unlock_delay : 1; | |
273 | + int auto_reconnect_inprogress : 1; | |
274 | + unsigned int colors : 5; | |
275 | + int apl_mode : 1; | |
276 | + int icrnl : 1; | |
277 | + int inlcr : 1; | |
278 | + int onlcr : 1; | |
279 | + int bsd_tm : 1; | |
280 | + int syncing : 1; | |
281 | + int reverse : 1; /**< reverse-input mode */ | |
282 | + int dbcs : 1; | |
283 | + int linemode : 1; | |
284 | + int trace_skipping : 1; | |
285 | + int need_tls_follows : 1; | |
286 | + int cut_xfer_in_progress : 1; | |
287 | +// int auto_keymap : 1; | |
288 | + int formatted : 1; /**< Formatted screen flag */ | |
289 | + int starting : 1; /**< Is starting (no first screen)? */ | |
290 | + | |
291 | + char * oversize; | |
292 | + | |
293 | + LIB3270_SSL_STATE secure; | |
294 | + | |
295 | + struct lib3270_toggle | |
296 | + { | |
297 | + char value; /**< toggle value */ | |
298 | + void (*upcall)(H3270 *, struct lib3270_toggle *, LIB3270_TOGGLE_TYPE); /**< change value */ | |
299 | + } toggle[LIB3270_TOGGLE_COUNT]; | |
300 | + | |
301 | + // Network & Termtype | |
302 | + char * connected_type; | |
303 | + char * connected_lu; | |
304 | + char luname[LIB3270_LUNAME_LENGTH+1]; | |
305 | + | |
306 | + char full_model_name[LIB3270_FULL_MODEL_NAME_LENGTH+1]; | |
307 | + char * model_name; | |
308 | + int model_num; | |
309 | + char * termtype; | |
310 | + | |
311 | + struct | |
312 | + { | |
313 | + char * current; /**< The hostname part, stripped of qualifiers, luname and port number */ | |
314 | + char * full; /**< The entire string, for use in reconnecting */ | |
315 | + char * srvc; /**< The service name */ | |
316 | + char * qualified; | |
317 | + } host; | |
318 | + | |
319 | + char * proxy; /**< Proxy server (type:host[:port]) */ | |
320 | + char * termname; | |
321 | + | |
322 | + struct lib3270_charset charset; | |
323 | + | |
324 | + LIB3270_MESSAGE oia_status; | |
325 | + | |
326 | + unsigned char oia_flag[LIB3270_FLAG_COUNT]; | |
327 | + | |
328 | + unsigned short current_port; | |
329 | + | |
330 | + // Misc | |
331 | + void * ft; /**< Active file transfer data */ | |
332 | + | |
333 | + // screen info | |
334 | + int ov_rows; | |
335 | + int ov_cols; | |
336 | + int maxROWS; | |
337 | + int maxCOLS; | |
338 | + unsigned short rows; | |
339 | + unsigned short cols; | |
340 | + int cursor_addr; | |
341 | + int buffer_addr; | |
342 | + char flipped; | |
343 | + int screen_alt; /**< alternate screen? */ | |
344 | + int is_altbuffer; | |
345 | + | |
346 | + // Screen contents | |
347 | + void * buffer[2]; /**< Internal buffers */ | |
348 | + struct lib3270_ea * ea_buf; /**< 3270 device buffer. ea_buf[-1] is the dummy default field attribute */ | |
349 | + struct lib3270_ea * aea_buf; /**< alternate 3270 extended attribute buffer */ | |
350 | + struct lib3270_text * text; /**< Converted 3270 chars */ | |
351 | + | |
352 | + // host.c | |
353 | + char std_ds_host; | |
354 | + char no_login_host; | |
355 | + char non_tn3270e_host; | |
356 | + char passthru_host; | |
357 | + char ssl_host; | |
358 | + char ever_3270; | |
359 | + | |
360 | + // ctlr.c | |
361 | + int sscp_start; | |
362 | + unsigned char default_fg; | |
363 | + unsigned char default_bg; | |
364 | + unsigned char default_gr; | |
365 | + unsigned char default_cs; | |
366 | + unsigned char default_ic; | |
367 | + char reply_mode; | |
368 | + int trace_primed : 1; | |
369 | + int ticking : 1; | |
370 | + int mticking : 1; | |
371 | + int crm_nattr; | |
372 | + unsigned char crm_attr[16]; | |
373 | + unsigned char * zero_buf; /**< empty buffer, for area clears */ | |
374 | + | |
375 | + struct timeval t_start; | |
376 | + void * tick_id; | |
377 | + struct timeval t_want; | |
378 | + | |
379 | + // Telnet.c | |
380 | + unsigned char * ibuf; | |
381 | + int ibuf_size; /**< size of ibuf */ | |
382 | + unsigned char * obuf; /**< 3270 output buffer */ | |
383 | + unsigned char * obptr; | |
384 | + time_t ns_time; | |
385 | + int ns_brcvd; | |
386 | + int ns_rrcvd; | |
387 | + int ns_bsent; | |
388 | + int ns_rsent; | |
389 | + struct timeval ds_ts; | |
390 | + unsigned long e_funcs; /**< negotiated TN3270E functions */ | |
391 | + unsigned short e_xmit_seq; /**< transmit sequence number */ | |
392 | + int response_required; | |
393 | + int tn3270e_bound; | |
394 | + int tn3270e_negotiated; | |
395 | + int ansi_data; | |
396 | + int lnext; | |
397 | + int backslashed; | |
398 | + char plu_name[LIB3270_BIND_PLU_NAME_MAX+1]; | |
399 | + char **lus; | |
400 | + char **curr_lu; | |
401 | + char * try_lu; | |
402 | + int proxy_type; | |
403 | + char * proxy_host; | |
404 | + char * proxy_portname; | |
405 | + unsigned short proxy_port; | |
406 | + char reported_lu[LIB3270_LU_MAX+1]; | |
407 | + char reported_type[LIB3270_LU_MAX+1]; | |
408 | + | |
409 | + enum | |
410 | + { | |
411 | + E_NONE, | |
412 | + E_3270, | |
413 | + E_NVT, | |
414 | + E_SSCP | |
415 | + } tn3270e_submode; | |
416 | + | |
417 | + unsigned char * lbuf; /**< line-mode input buffer */ | |
418 | + unsigned char * lbptr; | |
419 | + | |
420 | + | |
421 | + // 3270 input buffer | |
422 | + unsigned char * ibptr; | |
423 | + unsigned char * obuf_base; | |
424 | + int obuf_size; | |
425 | +// unsigned char * netrbuf; | |
426 | + | |
427 | + // network input buffer | |
428 | + unsigned char * sbbuf; | |
429 | + | |
430 | + // telnet sub-option buffer | |
431 | + unsigned char * sbptr; | |
432 | + unsigned char telnet_state; | |
433 | +// char ttype_tmpval[13]; | |
434 | + | |
435 | + unsigned char myopts[LIB3270_TELNET_N_OPTS]; | |
436 | + unsigned char hisopts[LIB3270_TELNET_N_OPTS]; | |
437 | + | |
438 | + // kybd.c | |
439 | + unsigned int kybdlock; ///< @brief keyboard lock state | |
440 | + unsigned char aid; ///< @brief current attention ID | |
441 | + void * unlock_id; | |
442 | + time_t unlock_delay_time; | |
443 | + unsigned long unlock_delay_ms; ///< @brief Delay before actually unlocking the keyboard after the host permits it. | |
444 | + LIB3270_TA * ta_head; | |
445 | + LIB3270_TA * ta_tail; | |
446 | + | |
447 | + // ft_dft.c | |
448 | + int dft_buffersize; ///< @brief Buffer size (LIMIN, LIMOUT) | |
449 | + | |
450 | + // rpq.c | |
451 | + int rpq_complained : 1; | |
452 | +#if !defined(_WIN32) | |
453 | + int omit_due_space_limit : 1; | |
454 | +#endif | |
239 | 455 | |
456 | + char * rpq_warnbuf; | |
457 | + int rpq_wbcnt; | |
458 | + | |
459 | + // User data (Usually points to session's widget) | |
460 | + void * user_data; | |
461 | + | |
462 | + // selection | |
463 | + char * paste_buffer; | |
464 | + struct | |
465 | + { | |
466 | + int start; | |
467 | + int end; | |
468 | + } select; | |
469 | + | |
470 | + // ansi.c | |
471 | + int scroll_top; | |
472 | + int scroll_bottom; | |
473 | + int once_cset; | |
474 | + int saved_cursor; | |
475 | + | |
476 | + int held_wrap : 1; | |
477 | + | |
478 | + int insert_mode : 1; | |
479 | + int auto_newline_mode : 1; | |
480 | + | |
481 | + int appl_cursor : 1; | |
482 | + int saved_appl_cursor : 1; | |
483 | + | |
484 | + int wraparound_mode : 1; | |
485 | + int saved_wraparound_mode : 1; | |
486 | + | |
487 | + int rev_wraparound_mode : 1; | |
488 | + int saved_rev_wraparound_mode : 1; | |
489 | + | |
490 | + int allow_wide_mode : 1; | |
491 | + int saved_allow_wide_mode : 1; | |
492 | + | |
493 | + int wide_mode : 1; | |
494 | + int saved_wide_mode : 1; | |
495 | + | |
496 | + int saved_altbuffer : 1; | |
497 | + int ansi_reset : 1; /**< Non zero if the ansi_reset() was called in this session */ | |
498 | + | |
499 | + int ansi_ch; | |
500 | + int cs_to_change; | |
501 | + | |
502 | + /** ANSI Character sets. */ | |
503 | + enum lib3270_ansi_cs | |
504 | + { | |
505 | + LIB3270_ANSI_CS_G0 = 0, | |
506 | + LIB3270_ANSI_CS_G1 = 1, | |
507 | + LIB3270_ANSI_CS_G2 = 2, | |
508 | + LIB3270_ANSI_CS_G3 = 3 | |
509 | + } cset; | |
510 | + enum lib3270_ansi_cs saved_cset; | |
511 | + | |
512 | + /** Character set designations. */ | |
513 | + enum lib3270_ansi_csd | |
514 | + { | |
515 | + LIB3270_ANSI_CSD_LD = 0, | |
516 | + LIB3270_ANSI_CSD_UK = 1, | |
517 | + LIB3270_ANSI_CSD_US = 2 | |
518 | + } csd[4]; | |
519 | + enum lib3270_ansi_csd saved_csd[4]; | |
520 | + | |
521 | + enum lib3270_ansi_state | |
522 | + { | |
523 | + LIB3270_ANSI_STATE_DATA = 0, | |
524 | + LIB3270_ANSI_STATE_ESC = 1, | |
525 | + LIB3270_ANSI_STATE_CSDES = 2, | |
526 | + LIB3270_ANSI_STATE_N1 = 3, | |
527 | + LIB3270_ANSI_STATE_DECP = 4, | |
528 | + LIB3270_ANSI_STATE_TEXT = 5, | |
529 | + LIB3270_ANSI_STATE_TEXT2 = 6, | |
530 | + LIB3270_ANSI_STATE_MBPEND = 7 | |
531 | + } state; | |
532 | + | |
533 | + unsigned char * tabs; | |
534 | + | |
535 | + int pmi; | |
536 | + char pending_mbs[LIB3270_MB_MAX]; | |
537 | + | |
538 | + unsigned char gr; | |
539 | + unsigned char saved_gr; | |
540 | + | |
541 | + unsigned char fg; | |
542 | + unsigned char saved_fg; | |
543 | + | |
544 | + unsigned char bg; | |
545 | + unsigned char saved_bg; | |
546 | + | |
547 | + // xio | |
548 | + void * ns_read_id; | |
549 | + void * ns_write_id; | |
550 | + void * ns_exception_id; | |
551 | + | |
552 | + // SSL Data (Always defined to mantain the same structure size) | |
553 | + unsigned long ssl_error; | |
554 | + SSL * ssl_con; | |
555 | + | |
556 | + // Callbacks. | |
557 | + struct lib3270_state_callback * st_callbacks[LIB3270_STATE_USER]; | |
558 | + struct lib3270_state_callback * st_last[LIB3270_STATE_USER]; | |
559 | + struct lib3270_session_callbacks cbk; | |
560 | + | |
561 | +}; | |
240 | 562 | |
241 | 563 | /* Library internal calls */ |
242 | -LIB3270_INTERNAL void key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped); | |
243 | -LIB3270_INTERNAL void lib3270_initialize(void); | |
244 | -LIB3270_INTERNAL int cursor_move(H3270 *session, int baddr); | |
564 | +LIB3270_INTERNAL void key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped); | |
565 | +LIB3270_INTERNAL void lib3270_initialize(void); | |
566 | +LIB3270_INTERNAL int cursor_move(H3270 *session, int baddr); | |
245 | 567 | |
246 | -LIB3270_INTERNAL void toggle_rectselect(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_TYPE tt); | |
247 | -LIB3270_INTERNAL void remove_input_calls(H3270 *session); | |
568 | +LIB3270_INTERNAL void toggle_rectselect(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_TYPE tt); | |
569 | +LIB3270_INTERNAL void remove_input_calls(H3270 *session); | |
248 | 570 | |
249 | 571 | LIB3270_INTERNAL int lib3270_sock_send(H3270 *hSession, unsigned const char *buf, int len); |
250 | 572 | LIB3270_INTERNAL void lib3270_sock_disconnect(H3270 *hSession); |
... | ... | @@ -259,7 +581,7 @@ LIB3270_INTERNAL int lib3270_default_event_dispatcher(H3270 *hSession, int block |
259 | 581 | LIB3270_INTERNAL void check_session_handle(H3270 **hSession); |
260 | 582 | #endif // DEBUG |
261 | 583 | |
262 | -LIB3270_INTERNAL int non_blocking(H3270 *session, Boolean on); | |
584 | +LIB3270_INTERNAL int non_blocking(H3270 *session, Boolean on); | |
263 | 585 | |
264 | 586 | #if defined(HAVE_LIBSSL) /*[*/ |
265 | 587 | ... | ... |
src/pw3270/v3270/draw.c
... | ... | @@ -400,7 +400,7 @@ void v3270_reload(GtkWidget *widget) |
400 | 400 | |
401 | 401 | void v3270_update_char(H3270 *session, int addr, unsigned char chr, unsigned short attr, unsigned char cursor) |
402 | 402 | { |
403 | - v3270 * terminal = GTK_V3270(session->user_data); | |
403 | + v3270 * terminal = GTK_V3270(lib3270_get_user_data(session)); | |
404 | 404 | cairo_t * cr; |
405 | 405 | GdkRectangle rect; |
406 | 406 | int rows,cols; | ... | ... |
src/pw3270/v3270/oia.c
... | ... | @@ -765,7 +765,7 @@ static void draw_cursor_position(cairo_t *cr, GdkRectangle *rect, v3270FontInfo |
765 | 765 | |
766 | 766 | void v3270_update_cursor(H3270 *session, unsigned short row, unsigned short col, unsigned char c, unsigned short attr) |
767 | 767 | { |
768 | - v3270 * terminal = GTK_V3270(session->user_data); | |
768 | + v3270 * terminal = GTK_V3270(lib3270_get_user_data(session)); | |
769 | 769 | GdkRectangle saved; |
770 | 770 | |
771 | 771 | if(!terminal->surface) |
... | ... | @@ -1081,9 +1081,7 @@ void v3270_stop_timer(GtkWidget *widget) |
1081 | 1081 | |
1082 | 1082 | void v3270_update_ssl(H3270 *session, LIB3270_SSL_STATE state) |
1083 | 1083 | { |
1084 | - debug("%s **************************************** %d",__FUNCTION__,(int) state); | |
1085 | - | |
1086 | - v3270 * terminal = GTK_V3270(session->user_data); | |
1084 | + v3270 * terminal = GTK_V3270(lib3270_get_user_data(session)); | |
1087 | 1085 | cairo_t * cr; |
1088 | 1086 | GdkRectangle * r; |
1089 | 1087 | |
... | ... | @@ -1102,7 +1100,7 @@ void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) |
1102 | 1100 | cairo_t *cr; |
1103 | 1101 | GdkRectangle *r; |
1104 | 1102 | |
1105 | - v3270 *terminal = GTK_V3270(session->user_data); | |
1103 | + v3270 *terminal = GTK_V3270(lib3270_get_user_data(session)); | |
1106 | 1104 | |
1107 | 1105 | if(!(terminal->surface && terminal->drawing)) |
1108 | 1106 | return; | ... | ... |
src/pw3270/v3270/widget.c
... | ... | @@ -639,7 +639,7 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int heig |
639 | 639 | |
640 | 640 | static void set_timer(H3270 *session, unsigned char on) |
641 | 641 | { |
642 | - GtkWidget *widget = GTK_WIDGET(session->user_data); | |
642 | + GtkWidget *widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
643 | 643 | |
644 | 644 | if(on) |
645 | 645 | v3270_start_timer(widget); |
... | ... | @@ -650,6 +650,8 @@ static void set_timer(H3270 *session, unsigned char on) |
650 | 650 | |
651 | 651 | static void update_toggle(H3270 *session, LIB3270_TOGGLE ix, unsigned char value, LIB3270_TOGGLE_TYPE reason, const char *name) |
652 | 652 | { |
653 | + GtkWidget *widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
654 | + | |
653 | 655 | trace("Toggle %s is %s",name,value ? "ON" : "OFF"); |
654 | 656 | |
655 | 657 | switch(ix) |
... | ... | @@ -665,29 +667,29 @@ static void update_toggle(H3270 *session, LIB3270_TOGGLE ix, unsigned char value |
665 | 667 | case LIB3270_TOGGLE_UNDERLINE: |
666 | 668 | case LIB3270_TOGGLE_VIEW_FIELD: |
667 | 669 | case LIB3270_TOGGLE_ALTSCREEN: |
668 | - v3270_reload(GTK_WIDGET(session->user_data)); | |
669 | - gtk_widget_queue_draw(GTK_WIDGET(session->user_data)); | |
670 | + v3270_reload(widget); | |
671 | + gtk_widget_queue_draw(widget); | |
670 | 672 | break; |
671 | 673 | |
672 | 674 | case LIB3270_TOGGLE_CURSOR_BLINK: |
673 | - GTK_V3270(session->user_data)->cursor.show |= 1; | |
675 | + GTK_V3270(widget)->cursor.show |= 1; | |
674 | 676 | break; |
675 | 677 | |
676 | 678 | case LIB3270_TOGGLE_INSERT: |
677 | - v3270_draw_ins_status(GTK_V3270(session->user_data)); | |
678 | - v3270_cursor_draw(GTK_V3270(session->user_data)); | |
679 | + v3270_draw_ins_status(GTK_V3270(widget)); | |
680 | + v3270_cursor_draw(GTK_V3270(widget)); | |
679 | 681 | break; |
680 | 682 | |
681 | 683 | case LIB3270_TOGGLE_BOLD: |
682 | - v3270_reload(GTK_WIDGET(session->user_data)); | |
683 | - gtk_widget_queue_draw(GTK_WIDGET(session->user_data)); | |
684 | + v3270_reload(widget); | |
685 | + gtk_widget_queue_draw(widget); | |
684 | 686 | break; |
685 | 687 | |
686 | 688 | case LIB3270_TOGGLE_FULL_SCREEN: |
687 | 689 | if(value) |
688 | - gtk_window_fullscreen(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(session->user_data)))); | |
690 | + gtk_window_fullscreen(GTK_WINDOW(gtk_widget_get_toplevel(widget))); | |
689 | 691 | else |
690 | - gtk_window_unfullscreen(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(session->user_data)))); | |
692 | + gtk_window_unfullscreen(GTK_WINDOW(gtk_widget_get_toplevel(widget))); | |
691 | 693 | |
692 | 694 | break; |
693 | 695 | |
... | ... | @@ -709,27 +711,27 @@ static void update_toggle(H3270 *session, LIB3270_TOGGLE ix, unsigned char value |
709 | 711 | |
710 | 712 | } |
711 | 713 | #if GTK_CHECK_VERSION(2,26,0) |
712 | - g_object_notify_by_pspec(G_OBJECT(session->user_data), v3270_properties[PROP_TOGGLE+ix]); | |
714 | + g_object_notify_by_pspec(G_OBJECT(widget), v3270_properties[PROP_TOGGLE+ix]); | |
713 | 715 | #else |
714 | - g_object_notify(G_OBJECT(session->user_data),name); | |
716 | + g_object_notify(G_OBJECT(widget),name); | |
715 | 717 | #endif // GTK_CHECK_VERSION |
716 | 718 | |
717 | - g_signal_emit(GTK_WIDGET(session->user_data), v3270_widget_signal[SIGNAL_TOGGLE_CHANGED], 0, (guint) ix, (gboolean) (value != 0), (gchar *) name); | |
719 | + g_signal_emit(widget, v3270_widget_signal[SIGNAL_TOGGLE_CHANGED], 0, (guint) ix, (gboolean) (value != 0), (gchar *) name); | |
718 | 720 | } |
719 | 721 | |
720 | 722 | static void update_message(H3270 *session, LIB3270_MESSAGE id) |
721 | 723 | { |
722 | - g_signal_emit(GTK_WIDGET(session->user_data), v3270_widget_signal[SIGNAL_MESSAGE_CHANGED], 0, (gint) id); | |
724 | + g_signal_emit(GTK_WIDGET(lib3270_get_user_data(session)), v3270_widget_signal[SIGNAL_MESSAGE_CHANGED], 0, (gint) id); | |
723 | 725 | } |
724 | 726 | |
725 | 727 | static void update_luname(H3270 *session, const char *name) |
726 | 728 | { |
727 | - v3270_update_luname(GTK_WIDGET(session->user_data),name); | |
729 | + v3270_update_luname(GTK_WIDGET(lib3270_get_user_data(session)),name); | |
728 | 730 | } |
729 | 731 | |
730 | 732 | static void select_cursor(H3270 *session, LIB3270_CURSOR id) |
731 | 733 | { |
732 | - GtkWidget *widget = GTK_WIDGET(session->user_data); | |
734 | + GtkWidget *widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
733 | 735 | |
734 | 736 | #if GTK_CHECK_VERSION(2,20,0) |
735 | 737 | if(gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget)) |
... | ... | @@ -744,7 +746,7 @@ static void select_cursor(H3270 *session, LIB3270_CURSOR id) |
744 | 746 | |
745 | 747 | static void ctlr_done(H3270 *session) |
746 | 748 | { |
747 | - GtkWidget *widget = GTK_WIDGET(session->user_data); | |
749 | + GtkWidget *widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
748 | 750 | |
749 | 751 | #if GTK_CHECK_VERSION(2,20,0) |
750 | 752 | if(gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget)) |
... | ... | @@ -759,14 +761,14 @@ static void ctlr_done(H3270 *session) |
759 | 761 | |
760 | 762 | static void update_connect(H3270 *session, unsigned char connected) |
761 | 763 | { |
762 | - v3270 *widget = GTK_V3270(session->user_data); | |
764 | + v3270 *widget = GTK_V3270(lib3270_get_user_data(session)); | |
763 | 765 | |
764 | 766 | trace("%s - %s",__FUNCTION__,connected ? "Connected" : "Disconnected"); |
765 | 767 | |
766 | 768 | if(connected) |
767 | 769 | { |
768 | 770 | widget->cursor.show |= 2; |
769 | - g_signal_emit(GTK_WIDGET(widget), v3270_widget_signal[SIGNAL_CONNECTED], 0, session->host.full); | |
771 | + g_signal_emit(GTK_WIDGET(widget), v3270_widget_signal[SIGNAL_CONNECTED], 0, lib3270_get_host(session)); | |
770 | 772 | } |
771 | 773 | else |
772 | 774 | { |
... | ... | @@ -788,23 +790,23 @@ static void update_connect(H3270 *session, unsigned char connected) |
788 | 790 | static void update_screen_size(H3270 *session,unsigned short rows, unsigned short cols) |
789 | 791 | { |
790 | 792 | // trace("Widget %p changes to %dx%d",session->widget,cols,rows); |
791 | - v3270_reload(GTK_WIDGET(session->user_data)); | |
792 | - gtk_widget_queue_draw(GTK_WIDGET(session->user_data)); | |
793 | + v3270_reload(GTK_WIDGET(lib3270_get_user_data(session))); | |
794 | + gtk_widget_queue_draw(GTK_WIDGET(lib3270_get_user_data(session))); | |
793 | 795 | } |
794 | 796 | |
795 | 797 | static void update_model(H3270 *session, const char *name, int model, int rows, int cols) |
796 | 798 | { |
797 | 799 | #if GTK_CHECK_VERSION(2,26,0) |
798 | - g_object_notify_by_pspec(G_OBJECT(session->user_data), v3270_properties[PROP_MODEL]); | |
800 | + g_object_notify_by_pspec(G_OBJECT(lib3270_get_user_data(session)), v3270_properties[PROP_MODEL]); | |
799 | 801 | #else |
800 | - g_object_notify(G_OBJECT(session->user_data),"model"); | |
802 | + g_object_notify(G_OBJECT(lib3270_get_user_data(session)),"model"); | |
801 | 803 | #endif // GTK_CHECK_VERSION |
802 | - g_signal_emit(GTK_WIDGET(session->user_data),v3270_widget_signal[SIGNAL_MODEL_CHANGED], 0, (guint) model, name); | |
804 | + g_signal_emit(GTK_WIDGET(lib3270_get_user_data(session)),v3270_widget_signal[SIGNAL_MODEL_CHANGED], 0, (guint) model, name); | |
803 | 805 | } |
804 | 806 | |
805 | 807 | static void changed(H3270 *session, int offset, int len) |
806 | 808 | { |
807 | - GtkWidget * widget = session->user_data; | |
809 | + GtkWidget * widget = lib3270_get_user_data(session); | |
808 | 810 | GtkAccessible * obj = GTK_V3270(widget)->accessible; |
809 | 811 | |
810 | 812 | #ifdef WIN32 |
... | ... | @@ -863,7 +865,7 @@ static void changed(H3270 *session, int offset, int len) |
863 | 865 | |
864 | 866 | static void set_selection(H3270 *session, unsigned char status) |
865 | 867 | { |
866 | - GtkWidget * widget = GTK_WIDGET(session->user_data); | |
868 | + GtkWidget * widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
867 | 869 | |
868 | 870 | #if GTK_CHECK_VERSION(2,26,0) |
869 | 871 | g_object_notify_by_pspec(G_OBJECT(widget), v3270_properties[PROP_SELECTION]); |
... | ... | @@ -877,7 +879,7 @@ static void set_selection(H3270 *session, unsigned char status) |
877 | 879 | static void update_selection(H3270 *session, int start, int end) |
878 | 880 | { |
879 | 881 | // Selected region changed |
880 | - GtkWidget * widget = GTK_WIDGET(session->user_data); | |
882 | + GtkWidget * widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
881 | 883 | GtkAccessible * atk_obj = GTK_V3270(widget)->accessible; |
882 | 884 | |
883 | 885 | if(atk_obj) |
... | ... | @@ -887,7 +889,7 @@ static void update_selection(H3270 *session, int start, int end) |
887 | 889 | |
888 | 890 | static void message(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text) |
889 | 891 | { |
890 | - g_signal_emit( GTK_WIDGET(session->user_data), v3270_widget_signal[SIGNAL_MESSAGE], 0, | |
892 | + g_signal_emit( GTK_WIDGET(lib3270_get_user_data(session)), v3270_widget_signal[SIGNAL_MESSAGE], 0, | |
891 | 893 | (int) id, |
892 | 894 | (gchar *) title, |
893 | 895 | (gchar *) message, |
... | ... | @@ -897,7 +899,7 @@ static void message(H3270 *session, LIB3270_NOTIFY id , const char *title, const |
897 | 899 | |
898 | 900 | static int emit_print_signal(H3270 *session) |
899 | 901 | { |
900 | - g_signal_emit(GTK_WIDGET(session->user_data), v3270_widget_signal[SIGNAL_PRINT], 0); | |
902 | + g_signal_emit(GTK_WIDGET(lib3270_get_user_data(session)), v3270_widget_signal[SIGNAL_PRINT], 0); | |
901 | 903 | return 0; |
902 | 904 | } |
903 | 905 | |
... | ... | @@ -920,10 +922,11 @@ static void v3270_init(v3270 *widget) |
920 | 922 | { |
921 | 923 | struct lib3270_session_callbacks *cbk; |
922 | 924 | |
923 | - widget->host = lib3270_session_new(""); | |
924 | - widget->host->user_data = widget; | |
925 | + widget->host = lib3270_session_new(""); | |
925 | 926 | |
927 | + lib3270_set_user_data(widget->host,widget); | |
926 | 928 | |
929 | + /* | |
927 | 930 | trace("%s host->sz=%d expected=%d revision=%s expected=%s",__FUNCTION__,widget->host->sz,(int) sizeof(H3270),lib3270_get_revision(),PACKAGE_REVISION); |
928 | 931 | |
929 | 932 | if(widget->host->sz != sizeof(H3270)) |
... | ... | @@ -931,6 +934,7 @@ static void v3270_init(v3270 *widget) |
931 | 934 | g_error( _( "Unexpected signature in H3270 object, possible version mismatch in lib3270") ); |
932 | 935 | return; |
933 | 936 | } |
937 | + */ | |
934 | 938 | |
935 | 939 | cbk = lib3270_get_session_callbacks(widget->host,sizeof(struct lib3270_session_callbacks)); |
936 | 940 | if(!cbk) |
... | ... | @@ -1689,13 +1693,15 @@ GtkWidget * v3270_get_default_widget(void) |
1689 | 1693 | return NULL; |
1690 | 1694 | } |
1691 | 1695 | |
1692 | - if(!(hSession->user_data && GTK_IS_V3270(hSession->user_data))) | |
1696 | + GtkWidget *widget = lib3270_get_user_data(hSession); | |
1697 | + | |
1698 | + if(!(widget && GTK_IS_V3270(widget))) | |
1693 | 1699 | { |
1694 | 1700 | g_warning("No widget on default session on %s",__FUNCTION__); |
1695 | 1701 | return NULL; |
1696 | 1702 | } |
1697 | 1703 | |
1698 | - return GTK_WIDGET(hSession->user_data); | |
1704 | + return GTK_WIDGET(widget); | |
1699 | 1705 | } |
1700 | 1706 | |
1701 | 1707 | void v3270_disable_updates(GtkWidget *widget) | ... | ... |