Commit 76542fbe8880f66d78e9e1cfe6cd7bb3bdb6e686

Authored by Perry Werneck
1 parent eb3b45fc

Anexando novo diálogo de transferência de arquivos no projeto principal.

configure.ac
... ... @@ -897,7 +897,7 @@ AC_CONFIG_FILES(src/lib3270/mkversion.sh)
897 897 AC_CONFIG_FILES(src/lib3270/Makefile)
898 898 AC_CONFIG_FILES(src/pw3270/Makefile)
899 899 AC_CONFIG_FILES(src/pw3270/uiparser/Makefile)
900   -AC_CONFIG_FILES(src/pw3270/ft/Makefile)
  900 +AC_CONFIG_FILES(src/pw3270/v3270ft/Makefile)
901 901 AC_CONFIG_FILES(src/tools/Makefile)
902 902  
903 903 AC_CONFIG_FILES(src/classlib/Makefile)
... ...
pw3270.cbp
... ... @@ -433,24 +433,15 @@
433 433 <Unit filename="src/pw3270/dialog.c">
434 434 <Option compilerVar="CC" />
435 435 </Unit>
436   - <Unit filename="src/pw3270/filetransfer.c">
437   - <Option compilerVar="CC" />
438   - </Unit>
439 436 <Unit filename="src/pw3270/filetransfer.h" />
440 437 <Unit filename="src/pw3270/fonts.c">
441 438 <Option compilerVar="CC" />
442 439 </Unit>
443   - <Unit filename="src/pw3270/ft/ftdialog.c">
444   - <Option compilerVar="CC" />
445   - </Unit>
446   - <Unit filename="src/pw3270/ft/ftprogress.c">
447   - <Option compilerVar="CC" />
448   - </Unit>
449   - <Unit filename="src/pw3270/ft/v3270ft.h" />
450 440 <Unit filename="src/pw3270/globals.h" />
451 441 <Unit filename="src/pw3270/hostdialog.c">
452 442 <Option compilerVar="CC" />
453 443 </Unit>
  444 + <Unit filename="src/pw3270/include/v3270ft.h" />
454 445 <Unit filename="src/pw3270/main.c">
455 446 <Option compilerVar="CC" />
456 447 </Unit>
... ... @@ -559,6 +550,42 @@
559 550 <Unit filename="src/pw3270/v3270/widget.c">
560 551 <Option compilerVar="CC" />
561 552 </Unit>
  553 + <Unit filename="src/pw3270/v3270ft/Makefile.in" />
  554 + <Unit filename="src/pw3270/v3270ft/filelist.c">
  555 + <Option compilerVar="CC" />
  556 + </Unit>
  557 + <Unit filename="src/pw3270/v3270ft/genmarshal" />
  558 + <Unit filename="src/pw3270/v3270ft/get.c">
  559 + <Option compilerVar="CC" />
  560 + </Unit>
  561 + <Unit filename="src/pw3270/v3270ft/load.c">
  562 + <Option compilerVar="CC" />
  563 + </Unit>
  564 + <Unit filename="src/pw3270/v3270ft/misc.c">
  565 + <Option compilerVar="CC" />
  566 + </Unit>
  567 + <Unit filename="src/pw3270/v3270ft/private.h" />
  568 + <Unit filename="src/pw3270/v3270ft/save.c">
  569 + <Option compilerVar="CC" />
  570 + </Unit>
  571 + <Unit filename="src/pw3270/v3270ft/select.c">
  572 + <Option compilerVar="CC" />
  573 + </Unit>
  574 + <Unit filename="src/pw3270/v3270ft/set.c">
  575 + <Option compilerVar="CC" />
  576 + </Unit>
  577 + <Unit filename="src/pw3270/v3270ft/tables.c">
  578 + <Option compilerVar="CC" />
  579 + </Unit>
  580 + <Unit filename="src/pw3270/v3270ft/transfer.c">
  581 + <Option compilerVar="CC" />
  582 + </Unit>
  583 + <Unit filename="src/pw3270/v3270ft/v3270ft.c">
  584 + <Option compilerVar="CC" />
  585 + </Unit>
  586 + <Unit filename="src/pw3270/v3270ft/v3270ftprogress.c">
  587 + <Option compilerVar="CC" />
  588 + </Unit>
562 589 <Unit filename="src/pw3270/window.c">
563 590 <Option compilerVar="CC" />
564 591 </Unit>
... ...
src/include/pw3270/v3270.h
... ... @@ -1,268 +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 v3270.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 V3270_H_INCLUDED
33   -
34   - #include <gtk/gtk.h>
35   - #include <lib3270/config.h>
36   - #include <lib3270.h>
37   - #include <lib3270/popup.h>
38   - #include <lib3270/filetransfer.h>
39   -
40   - #define V3270_H_INCLUDED 1
41   -
42   - G_BEGIN_DECLS
43   -
44   - #define GTK_TYPE_V3270 (v3270_get_type ())
45   - #define GTK_V3270(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270, v3270))
46   - #define GTK_V3270_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_V3270, v3270Class))
47   - #define GTK_IS_V3270(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_V3270))
48   - #define GTK_IS_V3270_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_V3270))
49   - #define GTK_V3270_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_V3270, v3270Class))
50   -
51   -#if ! GTK_CHECK_VERSION(3,0,0)
52   - #define GdkRGBA GdkColor
53   - #define gdk_cairo_set_source_rgba(cr,cl) gdk_cairo_set_source_color(cr,cl)
54   - #define gdk_rgba_parse(a,b) gdk_color_parse(b,a)
55   - #define gdk_rgba_to_string(c) gdk_color_to_string(c)
56   - #define gdk_rgba_equal(a,b) gdk_color_equal(a,b)
57   - #define gdk_rgba_to_string(c) gdk_color_to_string(c)
58   - #define gtk_color_selection_set_current_rgba(w,c) gtk_color_selection_set_current_color(w,c)
59   - #define gtk_color_selection_get_current_rgba(w,c) gtk_color_selection_get_current_color(w,c)
60   - #define gtk_color_selection_set_previous_rgba(w,c) gtk_color_selection_set_previous_color(w,c)
61   - #define gtk_color_selection_set_current_rgba(w,c) gtk_color_selection_set_current_color(w,c)
62   -#endif // !GTK(3,0,0)
63   -
64   -
65   - typedef struct _v3270 v3270;
66   - typedef struct _v3270Class v3270Class;
67   -
68   - /**
69   - * @brief Informações para desenho de fontes com o cairo.
70   - *
71   - */
72   - typedef struct _v3270FontInfo {
73   -
74   - guint width;
75   - guint height;
76   - guint ascent;
77   - guint descent;
78   -
79   - guint spacing;
80   -
81   - guint left;
82   - guint top;
83   -
84   - gchar * family;
85   - cairo_font_weight_t weight;
86   - cairo_scaled_font_t * scaled;
87   -
88   - } v3270FontInfo;
89   -
90   - enum V3270_COLOR
91   - {
92   - V3270_COLOR_BACKGROUND,
93   - V3270_COLOR_BLUE,
94   - V3270_COLOR_RED,
95   - V3270_COLOR_PINK,
96   - V3270_COLOR_GREEN,
97   - V3270_COLOR_TURQUOISE,
98   - V3270_COLOR_YELLOW,
99   - V3270_COLOR_WHITE,
100   - V3270_COLOR_BLACK,
101   - V3270_COLOR_DARK_BLUE,
102   - V3270_COLOR_ORANGE,
103   - V3270_COLOR_PURPLE,
104   - V3270_COLOR_DARK_GREEN,
105   - V3270_COLOR_DARK_TURQUOISE,
106   - V3270_COLOR_MUSTARD,
107   - V3270_COLOR_GRAY,
108   -
109   - V3270_COLOR_FIELD,
110   - V3270_COLOR_FIELD_INTENSIFIED,
111   - V3270_COLOR_FIELD_PROTECTED,
112   - V3270_COLOR_FIELD_PROTECTED_INTENSIFIED,
113   -
114   - V3270_COLOR_SELECTED_BG,
115   - V3270_COLOR_SELECTED_FG,
116   -
117   - V3270_COLOR_CROSS_HAIR,
118   -
119   - // Oia Colors (Must be the last block)
120   - V3270_COLOR_OIA_BACKGROUND,
121   - V3270_COLOR_OIA_FOREGROUND,
122   - V3270_COLOR_OIA_SEPARATOR,
123   - V3270_COLOR_OIA_STATUS_OK,
124   - V3270_COLOR_OIA_STATUS_WARNING,
125   - V3270_COLOR_OIA_STATUS_INVALID,
126   -
127   - V3270_COLOR_COUNT
128   - };
129   -
130   -// #define V3270_COLOR_OIA_STATUS_WARNING V3270_COLOR_OIA_STATUS_OK
131   -
132   - typedef enum _v3270_oia_field
133   - {
134   - V3270_OIA_UNDERA, /**< "A" underlined */
135   - V3270_OIA_CONNECTION, /**< solid box if connected, "?" in a box if not */
136   - V3270_OIA_MESSAGE, /**< message area */
137   - V3270_OIA_SSL, /**< SSL Status */
138   - /**< Meta indication ("M" or blank) */
139   - V3270_OIA_ALT, /**< Alt indication ("A" or blank) */
140   - /**< Compose indication ("C" or blank) */
141   - /**< Compose first character */
142   - V3270_OIA_SHIFT, /**< Shift Status */
143   - V3270_OIA_TYPEAHEAD, /**< Typeahead indication ("T" or blank) */
144   - V3270_OIA_INSERT, /**< Insert mode indication (Special symbol/"I" or blank) */
145   - V3270_OIA_SCRIPT, /**< Script indication ("S" or blank) */
146   - V3270_OIA_LUNAME, /**< LU Name */
147   - V3270_OIA_SPINNER, /**< command timing spinner */
148   - V3270_OIA_TIMER, /**< command timing (mmm:ss, or blank) */
149   - V3270_OIA_CURSOR_POSITION, /**< cursor position (rrr/ccc or blank) */
150   -
151   -// V3270_OIA_CAPS, /**< Caps indication ("A" or blank) */
152   -
153   -#ifdef HAVE_PRINTER
154   - V3270_OIA_PRINTER, /**< Printer indication ("P" or blank) */
155   -#endif // HAVE_PRINTER
156   -
157   - V3270_OIA_FIELD_COUNT
158   -
159   - } V3270_OIA_FIELD;
160   -
161   - #define V3270_OIA_FIELD_INVALID ((V3270_OIA_FIELD) -1)
162   -
163   -
164   - #define V3270_COLOR_OIA_SPINNER V3270_COLOR_OIA_FOREGROUND
165   - #define V3270_COLOR_OIA_LUNAME V3270_COLOR_OIA_FOREGROUND
166   - #define V3270_COLOR_OIA_INSERT V3270_COLOR_OIA_FOREGROUND
167   -
168   - #ifndef v3270char
169   - #define v3270char void
170   - #endif // v3270_char
171   -
172   - LIB3270_EXPORT GtkWidget * v3270_new(void);
173   - LIB3270_EXPORT GType v3270_get_type(void);
174   -
175   - LIB3270_EXPORT void v3270_reload(GtkWidget * widget);
176   -
177   - LIB3270_EXPORT void v3270_set_font_family(GtkWidget *widget, const gchar *name);
178   - LIB3270_EXPORT const gchar * v3270_get_font_family(GtkWidget *widget);
179   -
180   - LIB3270_EXPORT H3270 * v3270_get_session(GtkWidget *widget);
181   - LIB3270_EXPORT gboolean v3270_is_connected(GtkWidget *widget);
182   -
183   - LIB3270_EXPORT int v3270_connect(GtkWidget *widget);
184   - LIB3270_EXPORT void v3270_disconnect(GtkWidget *widget);
185   -
186   - LIB3270_EXPORT int v3270_set_host_charset(GtkWidget *widget, const gchar *name);
187   -
188   - LIB3270_EXPORT void v3270_set_auto_disconnect(GtkWidget *widget, guint minutes);
189   - LIB3270_EXPORT guint v3270_get_auto_disconnect(GtkWidget *widget);
190   -
191   -
192   - // Clipboard
193   - typedef enum _v3270_select_format
194   - {
195   - V3270_SELECT_TEXT,
196   - V3270_SELECT_TABLE,
197   -
198   - V3270_SELECT_MAX
199   - } V3270_SELECT_FORMAT;
200   -
201   - LIB3270_EXPORT void v3270_copy(GtkWidget *widget, V3270_SELECT_FORMAT mode, gboolean cut);
202   - LIB3270_EXPORT void v3270_copy_append(GtkWidget *widget);
203   - LIB3270_EXPORT gchar * v3270_get_selected(GtkWidget *widget, gboolean cut);
204   - LIB3270_EXPORT gchar * v3270_get_copy(GtkWidget *widget);
205   - LIB3270_EXPORT void v3270_set_copy(GtkWidget *widget, const gchar *text);
206   -
207   - LIB3270_EXPORT int v3270_run_script(GtkWidget *widget, const gchar *script);
208   -
209   - LIB3270_EXPORT gchar * v3270_get_text(GtkWidget *widget,int offset, int len);
210   - LIB3270_EXPORT gchar * v3270_get_region(GtkWidget *widget, gint start_pos, gint end_pos, gboolean all);
211   -
212   - LIB3270_EXPORT void v3270_set_string(GtkWidget *widget, const gchar *str);
213   - LIB3270_EXPORT void v3270_tab(GtkWidget *widget);
214   - LIB3270_EXPORT void v3270_backtab(GtkWidget *widget);
215   -
216   - // Cut & Paste
217   - LIB3270_EXPORT gboolean v3270_get_selection_bounds(GtkWidget *widget, gint *start, gint *end);
218   - LIB3270_EXPORT void v3270_unselect(GtkWidget *widget);
219   - LIB3270_EXPORT void v3270_select_all(GtkWidget *widget);
220   - LIB3270_EXPORT void v3270_paste(GtkWidget *widget);
221   - LIB3270_EXPORT void v3270_paste_string(GtkWidget *widget, const gchar *text, const gchar *encoding);
222   - LIB3270_EXPORT void v3270_select_region(GtkWidget *widget, gint start, gint end);
223   -
224   - // Colors
225   - LIB3270_EXPORT void v3270_set_colors(GtkWidget *widget, const gchar *);
226   - LIB3270_EXPORT void v3270_set_color_table(GdkRGBA *table, const gchar *colors);
227   - LIB3270_EXPORT const GdkRGBA * v3270_get_color_table(GtkWidget *widget);
228   - LIB3270_EXPORT void v3270_set_mono_color_table(GdkRGBA *table, const gchar *fg, const gchar *bg);
229   - LIB3270_EXPORT void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, v3270FontInfo *font, GdkRectangle *rect, GdkRGBA *color);
230   - LIB3270_EXPORT void v3270_set_color(GtkWidget *widget, enum V3270_COLOR id, GdkRGBA *color);
231   - LIB3270_EXPORT GdkRGBA * v3270_get_color(GtkWidget *widget, enum V3270_COLOR id);
232   -
233   - // Misc
234   - LIB3270_EXPORT GtkIMContext * v3270_get_im_context(GtkWidget *widget);
235   - LIB3270_EXPORT gboolean v3270_get_toggle(GtkWidget *widget, LIB3270_TOGGLE ix);
236   - LIB3270_EXPORT void v3270_popup_message(GtkWidget *widget, LIB3270_NOTIFY type, const gchar *title, const gchar *message, const gchar *text);
237   - LIB3270_EXPORT const gchar * v3270_get_session_name(GtkWidget *widget);
238   - LIB3270_EXPORT void v3270_set_session_name(GtkWidget *widget, const gchar *name);
239   - LIB3270_EXPORT int v3270_set_script(GtkWidget *widget, const gchar id, gboolean on);
240   - LIB3270_EXPORT void v3270_set_scaled_fonts(GtkWidget *widget, gboolean on);
241   - LIB3270_EXPORT void v3270_set_session_options(GtkWidget *widget, LIB3270_OPTION options);
242   - LIB3270_EXPORT int v3270_set_session_color_type(GtkWidget *widget, unsigned short colortype);
243   - LIB3270_EXPORT int v3270_set_host_type(GtkWidget *widget, const char *name);
244   - LIB3270_EXPORT const gchar * v3270_set_url(GtkWidget *widget, const gchar *uri);
245   - LIB3270_EXPORT const gchar * v3270_get_hostname(GtkWidget *widget);
246   - LIB3270_EXPORT GtkWidget * v3270_get_default_widget(void);
247   -
248   - // Keyboard & Mouse special actions
249   - LIB3270_EXPORT gboolean v3270_set_keyboard_action(GtkWidget *widget, const gchar *key_name, GtkAction *action);
250   - LIB3270_EXPORT void v3270_set_scroll_action(GtkWidget *widget, GdkScrollDirection direction, GtkAction *action);
251   -
252   - // SSL & Security
253   - LIB3270_EXPORT const gchar * v3270_get_ssl_status_icon(GtkWidget *widget);
254   - LIB3270_EXPORT const gchar * v3270_get_ssl_status_text(GtkWidget *widget);
255   - LIB3270_EXPORT const gchar * v3270_get_ssl_status_message(GtkWidget *widget);
256   - LIB3270_EXPORT void v3270_popup_security_dialog(GtkWidget *widget);
257   -
258   - // File transfer
259   - LIB3270_EXPORT gint v3270_transfer_file(GtkWidget *widget, LIB3270_FT_OPTION options, const gchar *local, const gchar *remote, int lrecl, int blksize, int primspace, int secspace, int dft);
260   -
261   - // Auxiliary widgets
262   - LIB3270_EXPORT GtkWidget * v3270_host_select_new(GtkWidget *widget);
263   - LIB3270_EXPORT void v3270_select_host(GtkWidget *widget);
264   -
265   -
266   - G_END_DECLS
267   -
268   -#endif // V3270_H_INCLUDED
src/pw3270/Makefile.in
... ... @@ -65,15 +65,18 @@ LIB_SOURCES= window.c actions.c fonts.c dialog.c hostdialog.c print.c colors.c \
65 65 tools.c plugin.c trace.c \
66 66 $(foreach SRC, $(UI_PARSER_SRC), uiparser/$(SRC)) \
67 67 $(foreach SRC, $(V3270_SRC), v3270/$(SRC)) \
68   - $(foreach SRC, $(COMMON_SRC), common/$(SRC)) \
69   - filetransfer.c ft/ftdialog.c ft/ftprogress.c \
70   - ft/browse.c
  68 + $(foreach SRC, $(COMMON_SRC), common/$(SRC))
  69 +
  70 +# ft/filetransfer.c
  71 +# ft/ftdialog.c ft/ftprogress.c ft/browse.c
71 72  
72 73 DEPENDS=*.h common/*.h uiparser/*.h v3270/*.h $(GLOBAL_DEPS)
73 74  
74 75 VALGRIND=@VALGRIND@
75 76  
76   -CFLAGS=@CFLAGS@ @DLL_CFLAGS@ @GTK_CFLAGS@ @GTKMAC_CFLAGS@ -DLIBDIR=\"$(libdir)\" -DDATAROOTDIR=\"$(datarootdir)\" -I../../src/include
  77 +CFLAGS=@CFLAGS@ @DLL_CFLAGS@ @GTK_CFLAGS@ @GTKMAC_CFLAGS@ -DLIBDIR=\"$(libdir)\" \
  78 + -DDATAROOTDIR=\"$(datarootdir)\" -I../../src/include -I./include
  79 +
77 80 LIBS=@LIBS@ @GTK_LIBS@ @GTKMAC_LIBS@ @SOCKET_LIBS@
78 81  
79 82 #---[ Rules ]------------------------------------------------------------------
... ...
src/pw3270/actions.c
... ... @@ -31,9 +31,12 @@
31 31  
32 32 #include "globals.h"
33 33 #include "uiparser/parser.h"
34   - #include <pw3270/v3270.h>
  34 +
  35 + #include <v3270.h>
  36 + #include <v3270ft.h>
  37 +
35 38 #include <pw3270/plugin.h>
36   - #include "filetransfer.h"
  39 + // #include "filetransfer.h"
37 40 #include <lib3270/actions.h>
38 41 #include <lib3270/selection.h>
39 42 #include <lib3270/trace.h>
... ... @@ -215,6 +218,21 @@ static void copy_as_html_action(GtkAction *action, GtkWidget *widget)
215 218 }
216 219 #endif // DEBUG
217 220  
  221 +G_GNUC_INTERNAL void transfer_action(GtkAction *action, GtkWidget *widget)
  222 +{
  223 +
  224 +}
  225 +
  226 +G_GNUC_INTERNAL void download_action(GtkAction *action, GtkWidget *widget)
  227 +{
  228 +
  229 +}
  230 +
  231 +G_GNUC_INTERNAL void upload_action(GtkAction *action, GtkWidget *widget)
  232 +{
  233 +
  234 +}
  235 +
218 236 static void connect_standard_action(GtkAction *action, GtkWidget *widget, const gchar *name)
219 237 {
220 238 #undef DECLARE_LIB3270_ACTION
... ... @@ -257,6 +275,7 @@ static void connect_standard_action(GtkAction *action, GtkWidget *widget, const
257 275 { "kpadd", kp_add_action },
258 276 { "download", download_action },
259 277 { "upload", upload_action },
  278 + { "transfer", transfer_action },
260 279 #ifdef DEBUG
261 280 { "copyashtml", copy_as_html_action },
262 281 #endif // DEBUG
... ...
src/pw3270/filetransfer.c
... ... @@ -1,376 +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 filetransfer.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   - * Agradecimento:
29   - *
30   - * Roberto Soares (a_r_soares@hotmail.com)
31   - *
32   - */
33   -
34   -#include <stdlib.h>
35   -#include "globals.h"
36   -#include "ft/v3270ft.h"
37   -#include <lib3270/filetransfer.h>
38   -
39   -/*--[ Constants ]------------------------------------------------------------------------------------*/
40   -
41   - static const struct _ftoptions
42   - {
43   - LIB3270_FT_OPTION val;
44   - const gchar * name;
45   - }
46   - ftoptions[] =
47   - { { LIB3270_FT_OPTION_ASCII, "text" },
48   - { LIB3270_FT_OPTION_CRLF, "cr" },
49   - { LIB3270_FT_OPTION_APPEND, "append" },
50   - { LIB3270_FT_OPTION_REMAP, "remap" }
51   - };
52   -
53   - static const struct _recfm
54   - {
55   - LIB3270_FT_OPTION val;
56   - const gchar * name;
57   - } recfm[] =
58   - {
59   - { LIB3270_FT_RECORD_FORMAT_DEFAULT, "default" },
60   - { LIB3270_FT_RECORD_FORMAT_FIXED, "fixed" },
61   - { LIB3270_FT_RECORD_FORMAT_VARIABLE, "variable" },
62   - { LIB3270_FT_RECORD_FORMAT_UNDEFINED, "undefined" }
63   - };
64   -
65   - static const struct _ftunits
66   - {
67   - LIB3270_FT_OPTION val;
68   - const gchar * name;
69   - } units[] =
70   - {
71   - { LIB3270_FT_ALLOCATION_UNITS_DEFAULT, "default" },
72   - { LIB3270_FT_ALLOCATION_UNITS_TRACKS, "tracks" },
73   - { LIB3270_FT_ALLOCATION_UNITS_CYLINDERS, "cylinders" },
74   - { LIB3270_FT_ALLOCATION_UNITS_AVBLOCK, "avblock" }
75   - };
76   -
77   -
78   -/*--[ Implement ]------------------------------------------------------------------------------------*/
79   -
80   -static LIB3270_FT_OPTION get_options_from_config(const gchar *group)
81   -{
82   - int f;
83   - LIB3270_FT_OPTION rc = 0;
84   - gchar * ptr;
85   -
86   - // Get base FT options
87   - for(f=0;f<G_N_ELEMENTS(ftoptions);f++)
88   - {
89   - if(get_boolean_from_config(group,ftoptions[f].name,FALSE))
90   - rc |= ftoptions[f].val;
91   - }
92   -
93   - // Get Record format
94   - ptr = get_string_from_config(group, "units", "default");
95   - for(f=0;f<G_N_ELEMENTS(units);f++)
96   - {
97   - if(!g_ascii_strcasecmp(ptr,units[f].name))
98   - rc |= units[f].val;
99   - }
100   - g_free(ptr);
101   -
102   - // Get allocation units
103   - ptr = get_string_from_config(group, "recfm", "variable");
104   - for(f=0;f<G_N_ELEMENTS(recfm);f++)
105   - {
106   - if(!g_ascii_strcasecmp(ptr,recfm[f].name))
107   - rc |= recfm[f].val;
108   - }
109   - g_free(ptr);
110   -
111   -
112   - return rc;
113   -}
114   -
115   -static void ft_dialog_load(GtkWidget *widget, const gchar *name)
116   -{
117   - gchar *ptr;
118   -
119   - ptr = get_string_from_config(name, "remote", "");
120   - v3270_ft_dialog_set_host_filename(widget,ptr);
121   - g_free(ptr);
122   -
123   - ptr = get_string_from_config(name, "local", "");
124   - v3270_ft_dialog_set_local_filename(widget,ptr);
125   - g_free(ptr);
126   -
127   - v3270_ft_dialog_set_dft_buffer_size(widget,get_integer_from_config(name,"dft",4096));
128   - v3270_ft_dialog_set_record_length(widget,get_integer_from_config(name,"reclen",0));
129   - v3270_ft_dialog_set_block_size(widget,get_integer_from_config(name,"blksize",0));
130   - v3270_ft_dialog_set_primary_space(widget,get_integer_from_config(name,"primspace",0));
131   - v3270_ft_dialog_set_secondary_space(widget,get_integer_from_config(name,"secspace",0));
132   -
133   -}
134   -
135   -static void ft_dialog_save(GtkWidget *widget, const gchar *name)
136   -{
137   - LIB3270_FT_OPTION opt = v3270_ft_dialog_get_options(widget);
138   - const gchar * filename = v3270_ft_dialog_get_local_filename(widget);
139   - int f;
140   -
141   - for(f=0;f<G_N_ELEMENTS(ftoptions);f++)
142   - {
143   - trace("%s=%s",ftoptions[f].name,((opt & ftoptions[f].val) != 0) ? "ON" : "OFF");
144   - set_boolean_to_config(name, ftoptions[f].name, ((opt & ftoptions[f].val) != 0));
145   - }
146   -
147   - for(f=0;f<G_N_ELEMENTS(recfm);f++)
148   - {
149   - if((opt & LIB3270_FT_RECORD_FORMAT_MASK) == recfm[f].val)
150   - set_string_to_config(name,"recfm","%s",recfm[f].name);
151   - }
152   -
153   - for(f=0;f<G_N_ELEMENTS(units);f++)
154   - {
155   - if( (opt & LIB3270_FT_ALLOCATION_UNITS_MASK) == units[f].val)
156   - set_string_to_config(name,"units","%s",units[f].name);
157   - }
158   -
159   - set_integer_to_config(name,"dft",v3270_ft_dialog_get_dft_buffer_size(widget));
160   - set_integer_to_config(name,"reclen",v3270_ft_dialog_get_record_length(widget));
161   - set_integer_to_config(name,"blksize",v3270_ft_dialog_get_block_size(widget));
162   - set_integer_to_config(name,"primspace",v3270_ft_dialog_get_primary_space(widget));
163   - set_integer_to_config(name,"secspace",v3270_ft_dialog_get_secondary_space(widget));
164   -
165   - set_string_to_config(name,"local","%s",filename);
166   - set_string_to_config(name,"remote","%s",v3270_ft_dialog_get_host_filename(widget));
167   -
168   -#ifdef HAVE_WIN_REGISTRY
169   - gchar *ext = strrchr(filename,'.');
170   -
171   - if(ext)
172   - {
173   - // Save extension based file settings
174   - HKEY hKey;
175   - DWORD disp;
176   - gchar * path = g_strdup_printf("%s\\%s\\%s\\%s","SOFTWARE",g_get_application_name(),name,ext+1);
177   -
178   - if(RegCreateKeyEx(HKEY_CURRENT_USER,path,0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hKey,&disp) == ERROR_SUCCESS)
179   - {
180   - DWORD value;
181   -
182   - value = (DWORD) v3270_ft_dialog_get_options(widget);
183   - RegSetValueEx(hKey, "options", 0, REG_DWORD,(const BYTE *) &value,sizeof(value));
184   -
185   - value = (DWORD) v3270_ft_dialog_get_dft_buffer_size(widget);
186   - RegSetValueEx(hKey, "dft", 0, REG_DWORD,(const BYTE *) &value,sizeof(value));
187   -
188   - value = (DWORD) v3270_ft_dialog_get_record_length(widget);
189   - RegSetValueEx(hKey, "reclen", 0, REG_DWORD,(const BYTE *) &value,sizeof(value));
190   -
191   - value = (DWORD) v3270_ft_dialog_get_block_size(widget);
192   - RegSetValueEx(hKey, "blksize", 0, REG_DWORD,(const BYTE *) &value,sizeof(value));
193   -
194   - value = (DWORD) v3270_ft_dialog_get_primary_space(widget);
195   - RegSetValueEx(hKey, "primspace", 0, REG_DWORD,(const BYTE *) &value,sizeof(value));
196   -
197   - value = (DWORD) v3270_ft_dialog_get_secondary_space(widget);
198   - RegSetValueEx(hKey, "secspace", 0, REG_DWORD,(const BYTE *) &value,sizeof(value));
199   -
200   - RegCloseKey(hKey);
201   - }
202   -
203   - g_free(path);
204   - }
205   -
206   -#endif // HAVE_WIN_REGISTRY
207   -
208   -}
209   -
210   -static void ft_complete(H3270 *hSession, unsigned long length,double kbytes_sec, const char *msg, void *widget)
211   -{
212   - v3270_ft_progress_complete(GTK_WIDGET(widget),length,kbytes_sec);
213   - v3270_ft_progress_set_message(GTK_WIDGET(widget),gettext(msg));
214   -}
215   -
216   -static void ft_message(H3270 *hSession, const char *text, void *widget)
217   -{
218   - v3270_ft_progress_set_message(GTK_WIDGET(widget),gettext(text));
219   -}
220   -
221   -static void ft_update(H3270 *hSession, unsigned long current, unsigned long length, double kbytes_sec, void *widget)
222   -{
223   - v3270_ft_progress_update(GTK_WIDGET(widget), current, length, kbytes_sec);
224   -}
225   -
226   -gint v3270_transfer_file(GtkWidget *widget, LIB3270_FT_OPTION options, const gchar *local, const gchar *remote, int lrecl, int blksize, int primspace, int secspace, int dft)
227   -{
228   - g_return_val_if_fail(GTK_IS_V3270(widget),0);
229   -
230   - H3270 * hSession = v3270_get_session(widget);
231   - H3270FT * ft = lib3270_ft_new(hSession,options,local,remote,lrecl,blksize,primspace,secspace,dft,NULL);
232   -
233   - if(!ft)
234   - return -1;
235   -
236   - GtkWidget * dialog = gtk_dialog_new_with_buttons(
237   - (options & LIB3270_FT_OPTION_RECEIVE) ? _( "Receiving file" ) : _( "Sending file" ),
238   - GTK_WINDOW(gtk_widget_get_toplevel(widget)),
239   - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
240   - _( "_Close" ), GTK_RESPONSE_CANCEL,NULL );
241   -
242   -
243   - // Create FT progress dialog
244   - GtkWidget * progress = v3270_ft_progress_new();
245   -
246   - lib3270_ft_set_user_data(hSession,progress);
247   -
248   -
249   - struct lib3270_ft_callbacks *cbk = lib3270_get_ft_callbacks(hSession,sizeof(struct lib3270_ft_callbacks));
250   -
251   - cbk->complete = ft_complete;
252   - cbk->failed = ft_complete;
253   - cbk->update = ft_update;
254   -// cbk->running = ft_running;
255   -// cbk->aborting = ft_aborting;
256   -// cbk->state_changed = ft_state_changed;
257   - cbk->message = ft_message;
258   -
259   - if(options & LIB3270_FT_OPTION_RECEIVE) {
260   -
261   - // Recebendo arquivo
262   - v3270_ft_progress_set_filenames(progress,remote,local);
263   -
264   - } else {
265   -
266   - // Enviando arquivo
267   - v3270_ft_progress_set_filenames(progress,local,remote);
268   -
269   - }
270   -
271   - v3270_ft_progress_set_message(progress,_("Starting transfer"));
272   -
273   - gtk_widget_show_all(progress);
274   - gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(progress),FALSE,TRUE,2);
275   -
276   - gtk_widget_show_all(dialog);
277   - lib3270_ft_start(v3270_get_session(widget));
278   - int rc = gtk_dialog_run(GTK_DIALOG(dialog));
279   - lib3270_ft_destroy(v3270_get_session(widget));
280   -
281   - gtk_widget_destroy(dialog);
282   -
283   - return rc;
284   -
285   -}
286   -
287   -void download_action(GtkAction *action, GtkWidget *widget)
288   -{
289   - const gchar *name = g_object_get_data(G_OBJECT(action),"configuration");
290   -
291   - if(!name)
292   - name = "download";
293   -
294   - if(lib3270_get_ft_state(v3270_get_session(widget)) != LIB3270_FT_STATE_NONE)
295   - {
296   - lib3270_popup_dialog( v3270_get_session(widget),
297   - LIB3270_NOTIFY_ERROR,
298   - _( "Request failed" ),
299   - _( "Can't start download." ),
300   - "%s",
301   - _( "File transfer is already active." ));
302   -
303   - return;
304   - }
305   -
306   - GtkWidget *dialog = v3270_ft_dialog_new(widget,LIB3270_FT_OPTION_RECEIVE|get_options_from_config(name));
307   -
308   - v3270_ft_dialog_set_tso(dialog,lib3270_is_tso(v3270_get_session(widget)));
309   -
310   - ft_dialog_load(dialog,name);
311   -
312   - if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
313   - {
314   - ft_dialog_save(dialog,name);
315   - gtk_widget_hide(dialog);
316   -
317   - v3270_transfer_file( widget,
318   - v3270_ft_dialog_get_options(dialog),
319   - v3270_ft_dialog_get_local_filename(dialog),
320   - v3270_ft_dialog_get_host_filename(dialog),
321   - v3270_ft_dialog_get_record_length(dialog),
322   - v3270_ft_dialog_get_block_size(dialog),
323   - v3270_ft_dialog_get_primary_space(dialog),
324   - v3270_ft_dialog_get_secondary_space(dialog),
325   - v3270_ft_dialog_get_dft_buffer_size(dialog));
326   - }
327   -
328   - gtk_widget_destroy(dialog);
329   -
330   -}
331   -
332   -void upload_action(GtkAction *action, GtkWidget *widget)
333   -{
334   - const gchar *name = g_object_get_data(G_OBJECT(action),"configuration");
335   -
336   - if(!name)
337   - name = "upload";
338   -
339   - if(lib3270_get_ft_state(v3270_get_session(widget)) != LIB3270_FT_STATE_NONE)
340   - {
341   - lib3270_popup_dialog( v3270_get_session(widget),
342   - LIB3270_NOTIFY_ERROR,
343   - _( "Request failed" ),
344   - _( "Can't start upload." ),
345   - "%s",
346   - _( "File transfer is already active." ));
347   -
348   - return;
349   - }
350   -
351   - GtkWidget *dialog = v3270_ft_dialog_new(widget,LIB3270_FT_OPTION_SEND|get_options_from_config(name));
352   -
353   - v3270_ft_dialog_set_tso(dialog,lib3270_is_tso(v3270_get_session(widget)));
354   - ft_dialog_load(dialog,name);
355   -
356   - if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
357   - {
358   - ft_dialog_save(dialog,name);
359   - gtk_widget_hide(dialog);
360   -
361   - v3270_transfer_file( widget,
362   - v3270_ft_dialog_get_options(dialog),
363   - v3270_ft_dialog_get_local_filename(dialog),
364   - v3270_ft_dialog_get_host_filename(dialog),
365   - v3270_ft_dialog_get_record_length(dialog),
366   - v3270_ft_dialog_get_block_size(dialog),
367   - v3270_ft_dialog_get_primary_space(dialog),
368   - v3270_ft_dialog_get_secondary_space(dialog),
369   - v3270_ft_dialog_get_dft_buffer_size(dialog));
370   - }
371   -
372   - gtk_widget_destroy(dialog);
373   -
374   -}
375   -
376   -
src/pw3270/ft/filetransfer.c 0 → 100644
... ... @@ -0,0 +1,376 @@
  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 filetransfer.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 + * Agradecimento:
  29 + *
  30 + * Roberto Soares (a_r_soares@hotmail.com)
  31 + *
  32 + */
  33 +
  34 +#include <stdlib.h>
  35 +#include "globals.h"
  36 +#include "ft/v3270ft.h"
  37 +#include <lib3270/filetransfer.h>
  38 +
  39 +/*--[ Constants ]------------------------------------------------------------------------------------*/
  40 +
  41 + static const struct _ftoptions
  42 + {
  43 + LIB3270_FT_OPTION val;
  44 + const gchar * name;
  45 + }
  46 + ftoptions[] =
  47 + { { LIB3270_FT_OPTION_ASCII, "text" },
  48 + { LIB3270_FT_OPTION_CRLF, "cr" },
  49 + { LIB3270_FT_OPTION_APPEND, "append" },
  50 + { LIB3270_FT_OPTION_REMAP, "remap" }
  51 + };
  52 +
  53 + static const struct _recfm
  54 + {
  55 + LIB3270_FT_OPTION val;
  56 + const gchar * name;
  57 + } recfm[] =
  58 + {
  59 + { LIB3270_FT_RECORD_FORMAT_DEFAULT, "default" },
  60 + { LIB3270_FT_RECORD_FORMAT_FIXED, "fixed" },
  61 + { LIB3270_FT_RECORD_FORMAT_VARIABLE, "variable" },
  62 + { LIB3270_FT_RECORD_FORMAT_UNDEFINED, "undefined" }
  63 + };
  64 +
  65 + static const struct _ftunits
  66 + {
  67 + LIB3270_FT_OPTION val;
  68 + const gchar * name;
  69 + } units[] =
  70 + {
  71 + { LIB3270_FT_ALLOCATION_UNITS_DEFAULT, "default" },
  72 + { LIB3270_FT_ALLOCATION_UNITS_TRACKS, "tracks" },
  73 + { LIB3270_FT_ALLOCATION_UNITS_CYLINDERS, "cylinders" },
  74 + { LIB3270_FT_ALLOCATION_UNITS_AVBLOCK, "avblock" }
  75 + };
  76 +
  77 +
  78 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  79 +
  80 +static LIB3270_FT_OPTION get_options_from_config(const gchar *group)
  81 +{
  82 + int f;
  83 + LIB3270_FT_OPTION rc = 0;
  84 + gchar * ptr;
  85 +
  86 + // Get base FT options
  87 + for(f=0;f<G_N_ELEMENTS(ftoptions);f++)
  88 + {
  89 + if(get_boolean_from_config(group,ftoptions[f].name,FALSE))
  90 + rc |= ftoptions[f].val;
  91 + }
  92 +
  93 + // Get Record format
  94 + ptr = get_string_from_config(group, "units", "default");
  95 + for(f=0;f<G_N_ELEMENTS(units);f++)
  96 + {
  97 + if(!g_ascii_strcasecmp(ptr,units[f].name))
  98 + rc |= units[f].val;
  99 + }
  100 + g_free(ptr);
  101 +
  102 + // Get allocation units
  103 + ptr = get_string_from_config(group, "recfm", "variable");
  104 + for(f=0;f<G_N_ELEMENTS(recfm);f++)
  105 + {
  106 + if(!g_ascii_strcasecmp(ptr,recfm[f].name))
  107 + rc |= recfm[f].val;
  108 + }
  109 + g_free(ptr);
  110 +
  111 +
  112 + return rc;
  113 +}
  114 +
  115 +static void ft_dialog_load(GtkWidget *widget, const gchar *name)
  116 +{
  117 + gchar *ptr;
  118 +
  119 + ptr = get_string_from_config(name, "remote", "");
  120 + v3270_ft_dialog_set_host_filename(widget,ptr);
  121 + g_free(ptr);
  122 +
  123 + ptr = get_string_from_config(name, "local", "");
  124 + v3270_ft_dialog_set_local_filename(widget,ptr);
  125 + g_free(ptr);
  126 +
  127 + v3270_ft_dialog_set_dft_buffer_size(widget,get_integer_from_config(name,"dft",4096));
  128 + v3270_ft_dialog_set_record_length(widget,get_integer_from_config(name,"reclen",0));
  129 + v3270_ft_dialog_set_block_size(widget,get_integer_from_config(name,"blksize",0));
  130 + v3270_ft_dialog_set_primary_space(widget,get_integer_from_config(name,"primspace",0));
  131 + v3270_ft_dialog_set_secondary_space(widget,get_integer_from_config(name,"secspace",0));
  132 +
  133 +}
  134 +
  135 +static void ft_dialog_save(GtkWidget *widget, const gchar *name)
  136 +{
  137 + LIB3270_FT_OPTION opt = v3270_ft_dialog_get_options(widget);
  138 + const gchar * filename = v3270_ft_dialog_get_local_filename(widget);
  139 + int f;
  140 +
  141 + for(f=0;f<G_N_ELEMENTS(ftoptions);f++)
  142 + {
  143 + trace("%s=%s",ftoptions[f].name,((opt & ftoptions[f].val) != 0) ? "ON" : "OFF");
  144 + set_boolean_to_config(name, ftoptions[f].name, ((opt & ftoptions[f].val) != 0));
  145 + }
  146 +
  147 + for(f=0;f<G_N_ELEMENTS(recfm);f++)
  148 + {
  149 + if((opt & LIB3270_FT_RECORD_FORMAT_MASK) == recfm[f].val)
  150 + set_string_to_config(name,"recfm","%s",recfm[f].name);
  151 + }
  152 +
  153 + for(f=0;f<G_N_ELEMENTS(units);f++)
  154 + {
  155 + if( (opt & LIB3270_FT_ALLOCATION_UNITS_MASK) == units[f].val)
  156 + set_string_to_config(name,"units","%s",units[f].name);
  157 + }
  158 +
  159 + set_integer_to_config(name,"dft",v3270_ft_dialog_get_dft_buffer_size(widget));
  160 + set_integer_to_config(name,"reclen",v3270_ft_dialog_get_record_length(widget));
  161 + set_integer_to_config(name,"blksize",v3270_ft_dialog_get_block_size(widget));
  162 + set_integer_to_config(name,"primspace",v3270_ft_dialog_get_primary_space(widget));
  163 + set_integer_to_config(name,"secspace",v3270_ft_dialog_get_secondary_space(widget));
  164 +
  165 + set_string_to_config(name,"local","%s",filename);
  166 + set_string_to_config(name,"remote","%s",v3270_ft_dialog_get_host_filename(widget));
  167 +
  168 +#ifdef HAVE_WIN_REGISTRY
  169 + gchar *ext = strrchr(filename,'.');
  170 +
  171 + if(ext)
  172 + {
  173 + // Save extension based file settings
  174 + HKEY hKey;
  175 + DWORD disp;
  176 + gchar * path = g_strdup_printf("%s\\%s\\%s\\%s","SOFTWARE",g_get_application_name(),name,ext+1);
  177 +
  178 + if(RegCreateKeyEx(HKEY_CURRENT_USER,path,0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hKey,&disp) == ERROR_SUCCESS)
  179 + {
  180 + DWORD value;
  181 +
  182 + value = (DWORD) v3270_ft_dialog_get_options(widget);
  183 + RegSetValueEx(hKey, "options", 0, REG_DWORD,(const BYTE *) &value,sizeof(value));
  184 +
  185 + value = (DWORD) v3270_ft_dialog_get_dft_buffer_size(widget);
  186 + RegSetValueEx(hKey, "dft", 0, REG_DWORD,(const BYTE *) &value,sizeof(value));
  187 +
  188 + value = (DWORD) v3270_ft_dialog_get_record_length(widget);
  189 + RegSetValueEx(hKey, "reclen", 0, REG_DWORD,(const BYTE *) &value,sizeof(value));
  190 +
  191 + value = (DWORD) v3270_ft_dialog_get_block_size(widget);
  192 + RegSetValueEx(hKey, "blksize", 0, REG_DWORD,(const BYTE *) &value,sizeof(value));
  193 +
  194 + value = (DWORD) v3270_ft_dialog_get_primary_space(widget);
  195 + RegSetValueEx(hKey, "primspace", 0, REG_DWORD,(const BYTE *) &value,sizeof(value));
  196 +
  197 + value = (DWORD) v3270_ft_dialog_get_secondary_space(widget);
  198 + RegSetValueEx(hKey, "secspace", 0, REG_DWORD,(const BYTE *) &value,sizeof(value));
  199 +
  200 + RegCloseKey(hKey);
  201 + }
  202 +
  203 + g_free(path);
  204 + }
  205 +
  206 +#endif // HAVE_WIN_REGISTRY
  207 +
  208 +}
  209 +
  210 +static void ft_complete(H3270 *hSession, unsigned long length,double kbytes_sec, const char *msg, void *widget)
  211 +{
  212 + v3270_ft_progress_complete(GTK_WIDGET(widget),length,kbytes_sec);
  213 + v3270_ft_progress_set_message(GTK_WIDGET(widget),gettext(msg));
  214 +}
  215 +
  216 +static void ft_message(H3270 *hSession, const char *text, void *widget)
  217 +{
  218 + v3270_ft_progress_set_message(GTK_WIDGET(widget),gettext(text));
  219 +}
  220 +
  221 +static void ft_update(H3270 *hSession, unsigned long current, unsigned long length, double kbytes_sec, void *widget)
  222 +{
  223 + v3270_ft_progress_update(GTK_WIDGET(widget), current, length, kbytes_sec);
  224 +}
  225 +
  226 +gint v3270_transfer_file(GtkWidget *widget, LIB3270_FT_OPTION options, const gchar *local, const gchar *remote, int lrecl, int blksize, int primspace, int secspace, int dft)
  227 +{
  228 + g_return_val_if_fail(GTK_IS_V3270(widget),0);
  229 +
  230 + H3270 * hSession = v3270_get_session(widget);
  231 + H3270FT * ft = lib3270_ft_new(hSession,options,local,remote,lrecl,blksize,primspace,secspace,dft,NULL);
  232 +
  233 + if(!ft)
  234 + return -1;
  235 +
  236 + GtkWidget * dialog = gtk_dialog_new_with_buttons(
  237 + (options & LIB3270_FT_OPTION_RECEIVE) ? _( "Receiving file" ) : _( "Sending file" ),
  238 + GTK_WINDOW(gtk_widget_get_toplevel(widget)),
  239 + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
  240 + _( "_Close" ), GTK_RESPONSE_CANCEL,NULL );
  241 +
  242 +
  243 + // Create FT progress dialog
  244 + GtkWidget * progress = v3270_ft_progress_new();
  245 +
  246 + lib3270_ft_set_user_data(hSession,progress);
  247 +
  248 +
  249 + struct lib3270_ft_callbacks *cbk = lib3270_get_ft_callbacks(hSession,sizeof(struct lib3270_ft_callbacks));
  250 +
  251 + cbk->complete = ft_complete;
  252 + cbk->failed = ft_complete;
  253 + cbk->update = ft_update;
  254 +// cbk->running = ft_running;
  255 +// cbk->aborting = ft_aborting;
  256 +// cbk->state_changed = ft_state_changed;
  257 + cbk->message = ft_message;
  258 +
  259 + if(options & LIB3270_FT_OPTION_RECEIVE) {
  260 +
  261 + // Recebendo arquivo
  262 + v3270_ft_progress_set_filenames(progress,remote,local);
  263 +
  264 + } else {
  265 +
  266 + // Enviando arquivo
  267 + v3270_ft_progress_set_filenames(progress,local,remote);
  268 +
  269 + }
  270 +
  271 + v3270_ft_progress_set_message(progress,_("Starting transfer"));
  272 +
  273 + gtk_widget_show_all(progress);
  274 + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(progress),FALSE,TRUE,2);
  275 +
  276 + gtk_widget_show_all(dialog);
  277 + lib3270_ft_start(v3270_get_session(widget));
  278 + int rc = gtk_dialog_run(GTK_DIALOG(dialog));
  279 + lib3270_ft_destroy(v3270_get_session(widget));
  280 +
  281 + gtk_widget_destroy(dialog);
  282 +
  283 + return rc;
  284 +
  285 +}
  286 +
  287 +void download_action(GtkAction *action, GtkWidget *widget)
  288 +{
  289 + const gchar *name = g_object_get_data(G_OBJECT(action),"configuration");
  290 +
  291 + if(!name)
  292 + name = "download";
  293 +
  294 + if(lib3270_get_ft_state(v3270_get_session(widget)) != LIB3270_FT_STATE_NONE)
  295 + {
  296 + lib3270_popup_dialog( v3270_get_session(widget),
  297 + LIB3270_NOTIFY_ERROR,
  298 + _( "Request failed" ),
  299 + _( "Can't start download." ),
  300 + "%s",
  301 + _( "File transfer is already active." ));
  302 +
  303 + return;
  304 + }
  305 +
  306 + GtkWidget *dialog = v3270_ft_dialog_new(widget,LIB3270_FT_OPTION_RECEIVE|get_options_from_config(name));
  307 +
  308 + v3270_ft_dialog_set_tso(dialog,lib3270_is_tso(v3270_get_session(widget)));
  309 +
  310 + ft_dialog_load(dialog,name);
  311 +
  312 + if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
  313 + {
  314 + ft_dialog_save(dialog,name);
  315 + gtk_widget_hide(dialog);
  316 +
  317 + v3270_transfer_file( widget,
  318 + v3270_ft_dialog_get_options(dialog),
  319 + v3270_ft_dialog_get_local_filename(dialog),
  320 + v3270_ft_dialog_get_host_filename(dialog),
  321 + v3270_ft_dialog_get_record_length(dialog),
  322 + v3270_ft_dialog_get_block_size(dialog),
  323 + v3270_ft_dialog_get_primary_space(dialog),
  324 + v3270_ft_dialog_get_secondary_space(dialog),
  325 + v3270_ft_dialog_get_dft_buffer_size(dialog));
  326 + }
  327 +
  328 + gtk_widget_destroy(dialog);
  329 +
  330 +}
  331 +
  332 +void upload_action(GtkAction *action, GtkWidget *widget)
  333 +{
  334 + const gchar *name = g_object_get_data(G_OBJECT(action),"configuration");
  335 +
  336 + if(!name)
  337 + name = "upload";
  338 +
  339 + if(lib3270_get_ft_state(v3270_get_session(widget)) != LIB3270_FT_STATE_NONE)
  340 + {
  341 + lib3270_popup_dialog( v3270_get_session(widget),
  342 + LIB3270_NOTIFY_ERROR,
  343 + _( "Request failed" ),
  344 + _( "Can't start upload." ),
  345 + "%s",
  346 + _( "File transfer is already active." ));
  347 +
  348 + return;
  349 + }
  350 +
  351 + GtkWidget *dialog = v3270_ft_dialog_new(widget,LIB3270_FT_OPTION_SEND|get_options_from_config(name));
  352 +
  353 + v3270_ft_dialog_set_tso(dialog,lib3270_is_tso(v3270_get_session(widget)));
  354 + ft_dialog_load(dialog,name);
  355 +
  356 + if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
  357 + {
  358 + ft_dialog_save(dialog,name);
  359 + gtk_widget_hide(dialog);
  360 +
  361 + v3270_transfer_file( widget,
  362 + v3270_ft_dialog_get_options(dialog),
  363 + v3270_ft_dialog_get_local_filename(dialog),
  364 + v3270_ft_dialog_get_host_filename(dialog),
  365 + v3270_ft_dialog_get_record_length(dialog),
  366 + v3270_ft_dialog_get_block_size(dialog),
  367 + v3270_ft_dialog_get_primary_space(dialog),
  368 + v3270_ft_dialog_get_secondary_space(dialog),
  369 + v3270_ft_dialog_get_dft_buffer_size(dialog));
  370 + }
  371 +
  372 + gtk_widget_destroy(dialog);
  373 +
  374 +}
  375 +
  376 +
... ...
src/pw3270/globals.h
... ... @@ -75,6 +75,7 @@
75 75 G_GNUC_INTERNAL void print_copy_action(GtkAction *action, GtkWidget *widget);
76 76 G_GNUC_INTERNAL void editcolors_action(GtkAction *action, GtkWidget *widget);
77 77 G_GNUC_INTERNAL void about_dialog_action(GtkAction *action, GtkWidget *widget);
  78 + G_GNUC_INTERNAL void transfer_action(GtkAction *action, GtkWidget *widget);
78 79 G_GNUC_INTERNAL void download_action(GtkAction *action, GtkWidget *widget);
79 80 G_GNUC_INTERNAL void upload_action(GtkAction *action, GtkWidget *widget);
80 81 G_GNUC_INTERNAL void print_settings_action(GtkAction *action, GtkWidget *widget);
... ...
src/pw3270/include/v3270.h 0 → 100644
... ... @@ -0,0 +1,268 @@
  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 v3270.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 V3270_H_INCLUDED
  33 +
  34 + #include <gtk/gtk.h>
  35 + #include <lib3270/config.h>
  36 + #include <lib3270.h>
  37 + #include <lib3270/popup.h>
  38 + #include <lib3270/filetransfer.h>
  39 +
  40 + #define V3270_H_INCLUDED 1
  41 +
  42 + G_BEGIN_DECLS
  43 +
  44 + #define GTK_TYPE_V3270 (v3270_get_type ())
  45 + #define GTK_V3270(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270, v3270))
  46 + #define GTK_V3270_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_V3270, v3270Class))
  47 + #define GTK_IS_V3270(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_V3270))
  48 + #define GTK_IS_V3270_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_V3270))
  49 + #define GTK_V3270_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_V3270, v3270Class))
  50 +
  51 +#if ! GTK_CHECK_VERSION(3,0,0)
  52 + #define GdkRGBA GdkColor
  53 + #define gdk_cairo_set_source_rgba(cr,cl) gdk_cairo_set_source_color(cr,cl)
  54 + #define gdk_rgba_parse(a,b) gdk_color_parse(b,a)
  55 + #define gdk_rgba_to_string(c) gdk_color_to_string(c)
  56 + #define gdk_rgba_equal(a,b) gdk_color_equal(a,b)
  57 + #define gdk_rgba_to_string(c) gdk_color_to_string(c)
  58 + #define gtk_color_selection_set_current_rgba(w,c) gtk_color_selection_set_current_color(w,c)
  59 + #define gtk_color_selection_get_current_rgba(w,c) gtk_color_selection_get_current_color(w,c)
  60 + #define gtk_color_selection_set_previous_rgba(w,c) gtk_color_selection_set_previous_color(w,c)
  61 + #define gtk_color_selection_set_current_rgba(w,c) gtk_color_selection_set_current_color(w,c)
  62 +#endif // !GTK(3,0,0)
  63 +
  64 +
  65 + typedef struct _v3270 v3270;
  66 + typedef struct _v3270Class v3270Class;
  67 +
  68 + /**
  69 + * @brief Informações para desenho de fontes com o cairo.
  70 + *
  71 + */
  72 + typedef struct _v3270FontInfo {
  73 +
  74 + guint width;
  75 + guint height;
  76 + guint ascent;
  77 + guint descent;
  78 +
  79 + guint spacing;
  80 +
  81 + guint left;
  82 + guint top;
  83 +
  84 + gchar * family;
  85 + cairo_font_weight_t weight;
  86 + cairo_scaled_font_t * scaled;
  87 +
  88 + } v3270FontInfo;
  89 +
  90 + enum V3270_COLOR
  91 + {
  92 + V3270_COLOR_BACKGROUND,
  93 + V3270_COLOR_BLUE,
  94 + V3270_COLOR_RED,
  95 + V3270_COLOR_PINK,
  96 + V3270_COLOR_GREEN,
  97 + V3270_COLOR_TURQUOISE,
  98 + V3270_COLOR_YELLOW,
  99 + V3270_COLOR_WHITE,
  100 + V3270_COLOR_BLACK,
  101 + V3270_COLOR_DARK_BLUE,
  102 + V3270_COLOR_ORANGE,
  103 + V3270_COLOR_PURPLE,
  104 + V3270_COLOR_DARK_GREEN,
  105 + V3270_COLOR_DARK_TURQUOISE,
  106 + V3270_COLOR_MUSTARD,
  107 + V3270_COLOR_GRAY,
  108 +
  109 + V3270_COLOR_FIELD,
  110 + V3270_COLOR_FIELD_INTENSIFIED,
  111 + V3270_COLOR_FIELD_PROTECTED,
  112 + V3270_COLOR_FIELD_PROTECTED_INTENSIFIED,
  113 +
  114 + V3270_COLOR_SELECTED_BG,
  115 + V3270_COLOR_SELECTED_FG,
  116 +
  117 + V3270_COLOR_CROSS_HAIR,
  118 +
  119 + // Oia Colors (Must be the last block)
  120 + V3270_COLOR_OIA_BACKGROUND,
  121 + V3270_COLOR_OIA_FOREGROUND,
  122 + V3270_COLOR_OIA_SEPARATOR,
  123 + V3270_COLOR_OIA_STATUS_OK,
  124 + V3270_COLOR_OIA_STATUS_WARNING,
  125 + V3270_COLOR_OIA_STATUS_INVALID,
  126 +
  127 + V3270_COLOR_COUNT
  128 + };
  129 +
  130 +// #define V3270_COLOR_OIA_STATUS_WARNING V3270_COLOR_OIA_STATUS_OK
  131 +
  132 + typedef enum _v3270_oia_field
  133 + {
  134 + V3270_OIA_UNDERA, /**< "A" underlined */
  135 + V3270_OIA_CONNECTION, /**< solid box if connected, "?" in a box if not */
  136 + V3270_OIA_MESSAGE, /**< message area */
  137 + V3270_OIA_SSL, /**< SSL Status */
  138 + /**< Meta indication ("M" or blank) */
  139 + V3270_OIA_ALT, /**< Alt indication ("A" or blank) */
  140 + /**< Compose indication ("C" or blank) */
  141 + /**< Compose first character */
  142 + V3270_OIA_SHIFT, /**< Shift Status */
  143 + V3270_OIA_TYPEAHEAD, /**< Typeahead indication ("T" or blank) */
  144 + V3270_OIA_INSERT, /**< Insert mode indication (Special symbol/"I" or blank) */
  145 + V3270_OIA_SCRIPT, /**< Script indication ("S" or blank) */
  146 + V3270_OIA_LUNAME, /**< LU Name */
  147 + V3270_OIA_SPINNER, /**< command timing spinner */
  148 + V3270_OIA_TIMER, /**< command timing (mmm:ss, or blank) */
  149 + V3270_OIA_CURSOR_POSITION, /**< cursor position (rrr/ccc or blank) */
  150 +
  151 +// V3270_OIA_CAPS, /**< Caps indication ("A" or blank) */
  152 +
  153 +#ifdef HAVE_PRINTER
  154 + V3270_OIA_PRINTER, /**< Printer indication ("P" or blank) */
  155 +#endif // HAVE_PRINTER
  156 +
  157 + V3270_OIA_FIELD_COUNT
  158 +
  159 + } V3270_OIA_FIELD;
  160 +
  161 + #define V3270_OIA_FIELD_INVALID ((V3270_OIA_FIELD) -1)
  162 +
  163 +
  164 + #define V3270_COLOR_OIA_SPINNER V3270_COLOR_OIA_FOREGROUND
  165 + #define V3270_COLOR_OIA_LUNAME V3270_COLOR_OIA_FOREGROUND
  166 + #define V3270_COLOR_OIA_INSERT V3270_COLOR_OIA_FOREGROUND
  167 +
  168 + #ifndef v3270char
  169 + #define v3270char void
  170 + #endif // v3270_char
  171 +
  172 + LIB3270_EXPORT GtkWidget * v3270_new(void);
  173 + LIB3270_EXPORT GType v3270_get_type(void);
  174 +
  175 + LIB3270_EXPORT void v3270_reload(GtkWidget * widget);
  176 +
  177 + LIB3270_EXPORT void v3270_set_font_family(GtkWidget *widget, const gchar *name);
  178 + LIB3270_EXPORT const gchar * v3270_get_font_family(GtkWidget *widget);
  179 +
  180 + LIB3270_EXPORT H3270 * v3270_get_session(GtkWidget *widget);
  181 + LIB3270_EXPORT gboolean v3270_is_connected(GtkWidget *widget);
  182 +
  183 + LIB3270_EXPORT int v3270_connect(GtkWidget *widget);
  184 + LIB3270_EXPORT void v3270_disconnect(GtkWidget *widget);
  185 +
  186 + LIB3270_EXPORT int v3270_set_host_charset(GtkWidget *widget, const gchar *name);
  187 +
  188 + LIB3270_EXPORT void v3270_set_auto_disconnect(GtkWidget *widget, guint minutes);
  189 + LIB3270_EXPORT guint v3270_get_auto_disconnect(GtkWidget *widget);
  190 +
  191 +
  192 + // Clipboard
  193 + typedef enum _v3270_select_format
  194 + {
  195 + V3270_SELECT_TEXT,
  196 + V3270_SELECT_TABLE,
  197 +
  198 + V3270_SELECT_MAX
  199 + } V3270_SELECT_FORMAT;
  200 +
  201 + LIB3270_EXPORT void v3270_copy(GtkWidget *widget, V3270_SELECT_FORMAT mode, gboolean cut);
  202 + LIB3270_EXPORT void v3270_copy_append(GtkWidget *widget);
  203 + LIB3270_EXPORT gchar * v3270_get_selected(GtkWidget *widget, gboolean cut);
  204 + LIB3270_EXPORT gchar * v3270_get_copy(GtkWidget *widget);
  205 + LIB3270_EXPORT void v3270_set_copy(GtkWidget *widget, const gchar *text);
  206 +
  207 + LIB3270_EXPORT int v3270_run_script(GtkWidget *widget, const gchar *script);
  208 +
  209 + LIB3270_EXPORT gchar * v3270_get_text(GtkWidget *widget,int offset, int len);
  210 + LIB3270_EXPORT gchar * v3270_get_region(GtkWidget *widget, gint start_pos, gint end_pos, gboolean all);
  211 +
  212 + LIB3270_EXPORT void v3270_set_string(GtkWidget *widget, const gchar *str);
  213 + LIB3270_EXPORT void v3270_tab(GtkWidget *widget);
  214 + LIB3270_EXPORT void v3270_backtab(GtkWidget *widget);
  215 +
  216 + // Cut & Paste
  217 + LIB3270_EXPORT gboolean v3270_get_selection_bounds(GtkWidget *widget, gint *start, gint *end);
  218 + LIB3270_EXPORT void v3270_unselect(GtkWidget *widget);
  219 + LIB3270_EXPORT void v3270_select_all(GtkWidget *widget);
  220 + LIB3270_EXPORT void v3270_paste(GtkWidget *widget);
  221 + LIB3270_EXPORT void v3270_paste_string(GtkWidget *widget, const gchar *text, const gchar *encoding);
  222 + LIB3270_EXPORT void v3270_select_region(GtkWidget *widget, gint start, gint end);
  223 +
  224 + // Colors
  225 + LIB3270_EXPORT void v3270_set_colors(GtkWidget *widget, const gchar *);
  226 + LIB3270_EXPORT void v3270_set_color_table(GdkRGBA *table, const gchar *colors);
  227 + LIB3270_EXPORT const GdkRGBA * v3270_get_color_table(GtkWidget *widget);
  228 + LIB3270_EXPORT void v3270_set_mono_color_table(GdkRGBA *table, const gchar *fg, const gchar *bg);
  229 + LIB3270_EXPORT void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, v3270FontInfo *font, GdkRectangle *rect, GdkRGBA *color);
  230 + LIB3270_EXPORT void v3270_set_color(GtkWidget *widget, enum V3270_COLOR id, GdkRGBA *color);
  231 + LIB3270_EXPORT GdkRGBA * v3270_get_color(GtkWidget *widget, enum V3270_COLOR id);
  232 +
  233 + // Misc
  234 + LIB3270_EXPORT GtkIMContext * v3270_get_im_context(GtkWidget *widget);
  235 + LIB3270_EXPORT gboolean v3270_get_toggle(GtkWidget *widget, LIB3270_TOGGLE ix);
  236 + LIB3270_EXPORT void v3270_popup_message(GtkWidget *widget, LIB3270_NOTIFY type, const gchar *title, const gchar *message, const gchar *text);
  237 + LIB3270_EXPORT const gchar * v3270_get_session_name(GtkWidget *widget);
  238 + LIB3270_EXPORT void v3270_set_session_name(GtkWidget *widget, const gchar *name);
  239 + LIB3270_EXPORT int v3270_set_script(GtkWidget *widget, const gchar id, gboolean on);
  240 + LIB3270_EXPORT void v3270_set_scaled_fonts(GtkWidget *widget, gboolean on);
  241 + LIB3270_EXPORT void v3270_set_session_options(GtkWidget *widget, LIB3270_OPTION options);
  242 + LIB3270_EXPORT int v3270_set_session_color_type(GtkWidget *widget, unsigned short colortype);
  243 + LIB3270_EXPORT int v3270_set_host_type(GtkWidget *widget, const char *name);
  244 + LIB3270_EXPORT const gchar * v3270_set_url(GtkWidget *widget, const gchar *uri);
  245 + LIB3270_EXPORT const gchar * v3270_get_hostname(GtkWidget *widget);
  246 + LIB3270_EXPORT GtkWidget * v3270_get_default_widget(void);
  247 +
  248 + // Keyboard & Mouse special actions
  249 + LIB3270_EXPORT gboolean v3270_set_keyboard_action(GtkWidget *widget, const gchar *key_name, GtkAction *action);
  250 + LIB3270_EXPORT void v3270_set_scroll_action(GtkWidget *widget, GdkScrollDirection direction, GtkAction *action);
  251 +
  252 + // SSL & Security
  253 + LIB3270_EXPORT const gchar * v3270_get_ssl_status_icon(GtkWidget *widget);
  254 + LIB3270_EXPORT const gchar * v3270_get_ssl_status_text(GtkWidget *widget);
  255 + LIB3270_EXPORT const gchar * v3270_get_ssl_status_message(GtkWidget *widget);
  256 + LIB3270_EXPORT void v3270_popup_security_dialog(GtkWidget *widget);
  257 +
  258 + // File transfer
  259 + LIB3270_EXPORT gint v3270_transfer_file(GtkWidget *widget, LIB3270_FT_OPTION options, const gchar *local, const gchar *remote, int lrecl, int blksize, int primspace, int secspace, int dft);
  260 +
  261 + // Auxiliary widgets
  262 + LIB3270_EXPORT GtkWidget * v3270_host_select_new(GtkWidget *widget);
  263 + LIB3270_EXPORT void v3270_select_host(GtkWidget *widget);
  264 +
  265 +
  266 + G_END_DECLS
  267 +
  268 +#endif // V3270_H_INCLUDED
... ...
src/pw3270/include/v3270ft.h 0 → 100644
... ... @@ -0,0 +1,82 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como v3270ft.h e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 +#ifndef V3270FT_H_INCLUDED
  32 +
  33 + #define V3270FT_H_INCLUDED 1
  34 +
  35 + #include <glib/gi18n.h>
  36 + #include <gtk/gtk.h>
  37 + #include <lib3270.h>
  38 + #include <lib3270/filetransfer.h>
  39 +
  40 + G_BEGIN_DECLS
  41 +
  42 + #define GTK_TYPE_V3270FT (v3270ft_get_type ())
  43 + #define GTK_V3270FT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270FT, v3270ft))
  44 + #define GTK_V3270FT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_V3270FT, v3270ftClass))
  45 + #define GTK_IS_V3270FT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_V3270FT))
  46 + #define GTK_IS_V3270FT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_V3270FT))
  47 + #define GTK_V3270FT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_V3270FT, v3270ftClass))
  48 +
  49 + typedef struct _v3270ft v3270ft;
  50 + typedef struct _v3270ftClass v3270ftClass;
  51 +
  52 +
  53 + GtkWidget * v3270ft_new(void);
  54 + GType v3270ft_get_type(void);
  55 + void v3270ft_set_options(GtkWidget *widget, LIB3270_FT_OPTION opt);
  56 + LIB3270_FT_OPTION v3270ft_get_options(GtkWidget *widget);
  57 + void v3270ft_reset(GtkWidget *widget);
  58 + gboolean v3270ft_is_valid(GtkWidget *widget);
  59 + guint v3270ft_get_length(GtkWidget *widget);
  60 + void v3270ft_select_first(GtkWidget *widget);
  61 + void v3270ft_select_last(GtkWidget *widget);
  62 + void v3270ft_select_previous(GtkWidget *widget);
  63 + void v3270ft_select_next(GtkWidget *widget);
  64 + void v3270ft_remove_selected(GtkWidget *widget);
  65 + void v3270ft_remove_all(GtkWidget *widget);
  66 + void v3270ft_save(GtkWidget *widget,const gchar *filename);
  67 + void v3270ft_load(GtkWidget *widget,const gchar *filename);
  68 +
  69 + gboolean v3270ft_has_selected(GtkWidget *widget);
  70 + gboolean v3270ft_has_next(GtkWidget *widget);
  71 +
  72 + const gchar * v3270ft_get_local_filename(GtkWidget *widget);
  73 + const gchar * v3270ft_get_remote_filename(GtkWidget *widget);
  74 +
  75 + void v3270ft_append_file(GtkWidget *widget, const gchar *filename, gboolean text);
  76 + guint v3270ft_append_selection(GtkWidget *widget, GtkSelectionData *data);
  77 +
  78 + gint v3270ft_transfer(GtkWidget *dialog, H3270 *session);
  79 +
  80 + G_END_DECLS
  81 +
  82 +#endif // V3270FT_H_INCLUDED
... ...
src/pw3270/include/v3270ftprogress.h 0 → 100644
... ... @@ -0,0 +1,60 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como v3270ftprogress.h e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 +#ifndef V3270FTPROGRESS_H_INCLUDED
  32 +
  33 + #define V3270FTPROGRESS_H_INCLUDED
  34 +
  35 + #include <glib/gi18n.h>
  36 + #include <gtk/gtk.h>
  37 +
  38 + G_BEGIN_DECLS
  39 +
  40 + #define GTK_TYPE_V3270FTPROGRESS (v3270ftprogress_get_type ())
  41 + #define GTK_V3270FTPROGRESS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270FTPROGRESS, v3270ftprogress))
  42 + #define GTK_V3270FTPROGRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_V3270FTPROGRESS, v3270ftprogressClass))
  43 + #define GTK_IS_V3270FTPROGRESS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_V3270FTPROGRESS))
  44 + #define GTK_IS_V3270FTPROGRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_V3270FTPROGRESS))
  45 + #define GTK_V3270FTPROGRESS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_V3270FT, v3270ftprogressClass))
  46 +
  47 + typedef struct _v3270ftprogress v3270ftprogress;
  48 + typedef struct _v3270ftprogressClass v3270ftprogressClass;
  49 +
  50 + GtkWidget * v3270ftprogress_new(void);
  51 +
  52 + GType v3270ftprogress_get_type(void);
  53 +
  54 + void v3270ftprogress_set_header(GtkWidget *widget, const gchar *status);
  55 +
  56 +
  57 + G_END_DECLS
  58 +
  59 +
  60 +#endif // V3270FTPROGRESS_H_INCLUDED
... ...
src/pw3270/v3270ft/Makefile.in 0 → 100644
... ... @@ -0,0 +1,160 @@
  1 +#
  2 +# "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 +# (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 +# aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 +#
  6 +# Copyright (C) <2008> <Banco do Brasil S.A.>
  7 +#
  8 +# Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 +# os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 +# Free Software Foundation.
  11 +#
  12 +# Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 +# GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 +# A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 +# obter mais detalhes.
  16 +#
  17 +# Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 +# programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
  19 +# Place, Suite 330, Boston, MA, 02111-1307, USA
  20 +#
  21 +# Contatos:
  22 +#
  23 +# perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  24 +# erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça)
  25 +#
  26 +
  27 +MODULE_NAME=v3270ft
  28 +
  29 +#---[ Application sources ]--------------------------------------------------------------
  30 +
  31 +SOURCES=filelist.c load.c misc.c select.c tables.c transfer.c \
  32 + v3270ftprogress.c get.c marshal.c save.c set.c testprogram.c v3270ft.c
  33 +
  34 +#---[ Configuration values ]-------------------------------------------------------------
  35 +
  36 +PACKAGE_NAME=@PACKAGE_NAME@
  37 +PACKAGE_VERSION=@PACKAGE_VERSION@
  38 +PACKAGE_TARNAME=@PACKAGE_TARNAME@
  39 +
  40 +prefix=@prefix@
  41 +exec_prefix=@exec_prefix@
  42 +bindir=@bindir@
  43 +sbindir=@sbindir@
  44 +libdir=@libdir@
  45 +includedir=@includedir@
  46 +datarootdir=@datarootdir@
  47 +localedir=@localedir@
  48 +docdir=@docdir@
  49 +documentroot=@documentroot@
  50 +sysconfdir=@sysconfdir@
  51 +cachedir=/var/cache
  52 +logdir=@LOGDIR@
  53 +
  54 +OBJDIR?=.obj
  55 +OBJDBG=$(OBJDIR)/Debug
  56 +OBJRLS=$(OBJDIR)/Release
  57 +
  58 +BINDIR?=.bin
  59 +BINDBG=$(BINDIR)/Debug
  60 +BINRLS=$(BINDIR)/Release
  61 +
  62 +VALGRIND=@VALGRIND@
  63 +DOXYGEN=@DOXYGEN@
  64 +AMTAR=@AMTAR@
  65 +SHELL=@SHELL@
  66 +MKDIR=@MKDIR_P@
  67 +GENMARSHAL=glib-genmarshal
  68 +
  69 +CC=@CC@
  70 +LD=@CC@
  71 +AR=@AR@
  72 +
  73 +LIB3270_CFLAGS=@LIB3270_CFLAGS@
  74 +LIB3270_LIBS=@LIB3270_LIBS@
  75 +
  76 +GTK_CFLAGS=@GTK_CFLAGS@
  77 +GTK_LIBS=@GTK_LIBS@
  78 +
  79 +GLIB_CFLAGS=@GLIB_CFLAGS@
  80 +GLIB_LIBS=@GLIB_LIBS@
  81 +
  82 +CFLAGS=@CFLAGS@ \
  83 + -I../include \
  84 + -DBUILD_DATE=`date +"0x%Y%m%d"` \
  85 + $(GTK_CFLAGS)
  86 +
  87 +LIBS=@LIBS@ $(GTK_LIBS)
  88 +
  89 +DEPENDS=*.h ../include/*.h marshal.c marshal.h Makefile
  90 +
  91 +#---[ Release Rules ]--------------------------------------------------------------------
  92 +
  93 +$(OBJRLS)/%.o: \
  94 + %.c $(DEPENDS)
  95 +
  96 + @echo $(notdir $@) ...
  97 + @$(MKDIR) `dirname $@`
  98 + @$(CC) $(CFLAGS) -DNDEBUG=1 -o $@ -c $<
  99 +
  100 +$(BINRLS)/$(MODULE_NAME).a: \
  101 + $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o)
  102 +
  103 + @echo $(notdir $@) ...
  104 + @$(MKDIR) `dirname $@`
  105 +
  106 + @$(AR) rcs $@ $^
  107 +
  108 +
  109 +#---[ Debug Rules ]----------------------------------------------------------------------
  110 +
  111 +$(OBJDBG)/%.o: \
  112 + %.c $(DEPENDS)
  113 +
  114 + @echo $(notdir $@) ...
  115 + @$(MKDIR) `dirname $@`
  116 + @$(CC) $(CFLAGS) -DDEBUG=1 -o $@ -c $<
  117 +
  118 +$(BINDBG)/$(MODULE_NAME).a: \
  119 + $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).o)
  120 +
  121 + @echo $(notdir $@) ...
  122 + @$(MKDIR) `dirname $@`
  123 +
  124 + @$(AR) rcs $@ $^
  125 +
  126 +#---[ Misc Rules ]-----------------------------------------------------------------------
  127 +
  128 +marshal.h: \
  129 + genmarshal
  130 +
  131 + @echo $(notdir $<) ...
  132 + @$(MKDIR) `dirname $@`
  133 + @$(GENMARSHAL) --prefix=$(MODULE_NAME) --header $< > $@
  134 +
  135 +marshal.c: \
  136 + genmarshal
  137 +
  138 + @echo $(notdir $<) ...
  139 + @$(MKDIR) `dirname $@`
  140 + @$(GENMARSHAL) --prefix=$(MODULE_NAME) --header $< > $@
  141 +
  142 +#---[ Targets ]--------------------------------------------------------------------------
  143 +
  144 +all: \
  145 + $(BINRLS)/$(MODULE_NAME).a
  146 +
  147 +Release: \
  148 + $(BINRLS)/$(MODULE_NAME).a
  149 +
  150 +Debug: \
  151 + $(BINDBG)/$(MODULE_NAME).a
  152 +
  153 +cleanRelease: clean
  154 +
  155 +cleanDebug: clean
  156 +
  157 +clean:
  158 + @rm -fr $(BINDIR)
  159 + @rm -fr $(OBJDIR)
  160 +
... ...
src/pw3270/v3270ft/filelist.c 0 → 100644
... ... @@ -0,0 +1,115 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como filelist.c e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 + #include "private.h"
  32 +
  33 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  34 +
  35 +guint v3270ft_get_length(GtkWidget *widget) {
  36 + return g_list_length(GTK_V3270FT(widget)->files);
  37 +}
  38 +
  39 +
  40 +void v3270ft_select_first(GtkWidget *widget) {
  41 +
  42 + v3270ft * dialog = GTK_V3270FT(widget);
  43 + v3270ft_set_active(dialog,g_list_first(dialog->files));
  44 +
  45 +}
  46 +
  47 +void v3270ft_select_last(GtkWidget *widget) {
  48 +
  49 + v3270ft * dialog = GTK_V3270FT(widget);
  50 + v3270ft_set_active(dialog,g_list_last(dialog->files));
  51 +
  52 +}
  53 +
  54 +void v3270ft_select_previous(GtkWidget *widget) {
  55 +
  56 + v3270ft * dialog = GTK_V3270FT(widget);
  57 + v3270ft_set_active(dialog,g_list_previous(dialog->active));
  58 +
  59 +}
  60 +
  61 +void v3270ft_select_next(GtkWidget *widget) {
  62 +
  63 + v3270ft * dialog = GTK_V3270FT(widget);
  64 + v3270ft_set_active(dialog,g_list_next(dialog->active));
  65 +
  66 +}
  67 +
  68 +void v3270ft_remove_selected(GtkWidget *widget) {
  69 +
  70 + v3270ft * dialog = GTK_V3270FT(widget);
  71 +
  72 + if(dialog->active) {
  73 +
  74 + GList *next = dialog->active->next;
  75 +
  76 + dialog->files = g_list_delete_link(dialog->files,dialog->active);
  77 +
  78 + v3270ft_set_active(dialog,next);
  79 +
  80 + }
  81 +
  82 +}
  83 +
  84 +struct v3270ft_entry * v3270ft_create_entry(void) {
  85 + struct v3270ft_entry *rc = g_new0(struct v3270ft_entry,1);
  86 + rc->value[LIB3270_FT_VALUE_DFT] = 4096;
  87 + return rc;
  88 +}
  89 +
  90 +void v3270ft_append_file(GtkWidget *widget, const gchar *filename, gboolean text) {
  91 +
  92 + v3270ft * dialog = GTK_V3270FT(widget);
  93 +
  94 + debug("%s",filename);
  95 +
  96 + // Se a entrada atual não é valida remove.
  97 + if(!v3270ft_is_valid(widget)) {
  98 + v3270ft_remove_selected(widget);
  99 + }
  100 +
  101 + // Inclui uma nova entrada
  102 + struct v3270ft_entry * entry = v3270ft_create_entry();
  103 + gchar * base = g_path_get_basename(filename);
  104 +
  105 + strncpy(entry->local,filename,FILENAME_MAX);
  106 + strncpy(entry->remote,base,FILENAME_MAX);
  107 +
  108 + g_free(base);
  109 +
  110 + entry->type = text ? 3 : 1;
  111 + entry->options = ft_type[entry->type].opt;
  112 +
  113 + dialog->files = g_list_append(dialog->files,entry);
  114 + v3270ft_select_last(widget);
  115 +}
... ...
src/pw3270/v3270ft/ftdialog.cbp 0 → 100644
... ... @@ -0,0 +1,137 @@
  1 +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
  2 +<CodeBlocks_project_file>
  3 + <FileVersion major="1" minor="6" />
  4 + <Project>
  5 + <Option title="pw3270 File Transfer Dialog" />
  6 + <Option pch_mode="2" />
  7 + <Option compiler="gcc" />
  8 + <Build>
  9 + <Target title="Debug">
  10 + <Option output=".bin/Debug/v3270ft" prefix_auto="1" extension_auto="1" />
  11 + <Option object_output=".obj/Debug/" />
  12 + <Option type="1" />
  13 + <Option compiler="gcc" />
  14 + <Compiler>
  15 + <Add option="-g" />
  16 + <Add option="-DDEBUG=1" />
  17 + </Compiler>
  18 + </Target>
  19 + <Target title="Release">
  20 + <Option output=".bin/Release/v3270ft" prefix_auto="1" extension_auto="1" />
  21 + <Option object_output=".obj/Release/" />
  22 + <Option type="1" />
  23 + <Option compiler="gcc" />
  24 + <Compiler>
  25 + <Add option="-O2" />
  26 + <Add option="-DNDEBUG=1" />
  27 + </Compiler>
  28 + <Linker>
  29 + <Add option="-s" />
  30 + </Linker>
  31 + </Target>
  32 + </Build>
  33 + <Compiler>
  34 + <Add option="-Wall" />
  35 + <Add option="`pkg-config --cflags gtk+-3.0 lib3270`" />
  36 + <Add directory="../include" />
  37 + </Compiler>
  38 + <Linker>
  39 + <Add option="`pkg-config --libs gtk+-3.0 lib3270`" />
  40 + </Linker>
  41 + <ExtraCommands>
  42 + <Add before="glib-genmarshal --prefix=v3270ft --header genmarshal &gt; marshal.h" />
  43 + <Add before="glib-genmarshal --prefix=v3270ft --body genmarshal &gt; marshal.c" />
  44 + </ExtraCommands>
  45 + <Unit filename="../include/v3270.h" />
  46 + <Unit filename="../include/v3270ft.h" />
  47 + <Unit filename="../include/v3270ftprogress.h" />
  48 + <Unit filename="../v3270/actions.c">
  49 + <Option compilerVar="CC" />
  50 + </Unit>
  51 + <Unit filename="../v3270/colors.c">
  52 + <Option compilerVar="CC" />
  53 + </Unit>
  54 + <Unit filename="../v3270/cursor.c">
  55 + <Option compilerVar="CC" />
  56 + </Unit>
  57 + <Unit filename="../v3270/draw.c">
  58 + <Option compilerVar="CC" />
  59 + </Unit>
  60 + <Unit filename="../v3270/font.c">
  61 + <Option compilerVar="CC" />
  62 + </Unit>
  63 + <Unit filename="../v3270/iocallback.c">
  64 + <Option compilerVar="CC" />
  65 + </Unit>
  66 + <Unit filename="../v3270/keyboard.c">
  67 + <Option compilerVar="CC" />
  68 + </Unit>
  69 + <Unit filename="../v3270/marshal.c">
  70 + <Option compilerVar="CC" />
  71 + </Unit>
  72 + <Unit filename="../v3270/marshal.h" />
  73 + <Unit filename="../v3270/mouse.c">
  74 + <Option compilerVar="CC" />
  75 + </Unit>
  76 + <Unit filename="../v3270/oia.c">
  77 + <Option compilerVar="CC" />
  78 + </Unit>
  79 + <Unit filename="../v3270/private.h" />
  80 + <Unit filename="../v3270/properties.c">
  81 + <Option compilerVar="CC" />
  82 + </Unit>
  83 + <Unit filename="../v3270/signals.c">
  84 + <Option compilerVar="CC" />
  85 + </Unit>
  86 + <Unit filename="../v3270/v3270.c">
  87 + <Option compilerVar="CC" />
  88 + </Unit>
  89 + <Unit filename="filelist.c">
  90 + <Option compilerVar="CC" />
  91 + </Unit>
  92 + <Unit filename="genmarshal" />
  93 + <Unit filename="get.c">
  94 + <Option compilerVar="CC" />
  95 + </Unit>
  96 + <Unit filename="load.c">
  97 + <Option compilerVar="CC" />
  98 + </Unit>
  99 + <Unit filename="marshal.c">
  100 + <Option compilerVar="CC" />
  101 + </Unit>
  102 + <Unit filename="misc.c">
  103 + <Option compilerVar="CC" />
  104 + </Unit>
  105 + <Unit filename="private.h" />
  106 + <Unit filename="save.c">
  107 + <Option compilerVar="CC" />
  108 + </Unit>
  109 + <Unit filename="select.c">
  110 + <Option compilerVar="CC" />
  111 + </Unit>
  112 + <Unit filename="set.c">
  113 + <Option compilerVar="CC" />
  114 + </Unit>
  115 + <Unit filename="tables.c">
  116 + <Option compilerVar="CC" />
  117 + </Unit>
  118 + <Unit filename="testprogram.c">
  119 + <Option compilerVar="CC" />
  120 + </Unit>
  121 + <Unit filename="transfer.c">
  122 + <Option compilerVar="CC" />
  123 + </Unit>
  124 + <Unit filename="v3270ft.c">
  125 + <Option compilerVar="CC" />
  126 + </Unit>
  127 + <Unit filename="v3270ftprogress.c">
  128 + <Option compilerVar="CC" />
  129 + </Unit>
  130 + <Extensions>
  131 + <code_completion />
  132 + <envvars />
  133 + <debugger />
  134 + <lib_finder disable_auto="1" />
  135 + </Extensions>
  136 + </Project>
  137 +</CodeBlocks_project_file>
... ...
src/pw3270/v3270ft/genmarshal 0 → 100644
... ... @@ -0,0 +1 @@
  1 +VOID:POINTER,POINTER
... ...
src/pw3270/v3270ft/get.c 0 → 100644
... ... @@ -0,0 +1,110 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como get.c e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 + #include "private.h"
  32 +
  33 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  34 +
  35 +
  36 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  37 +
  38 +/**
  39 + * v3270ft_get_options:
  40 + * @widget: a #v3270ft
  41 + * @return: The lib3270 file transfer options for the current dialog.
  42 + *
  43 + * Since: 5.1
  44 + **/
  45 +LIB3270_FT_OPTION v3270ft_get_options(GtkWidget *widget) {
  46 + return v3270ft_get_selected(GTK_V3270FT(widget))->options;
  47 +}
  48 +
  49 +static void entry_is_valid(struct v3270ft_entry *entry, gboolean *rc) {
  50 +
  51 + *rc = (*rc && entry->valid);
  52 +
  53 +}
  54 +
  55 +const gchar * v3270ft_get_local_filename(GtkWidget *widget) {
  56 + return v3270ft_get_selected(GTK_V3270FT(widget))->local;
  57 +}
  58 +
  59 +const gchar * v3270ft_get_remote_filename(GtkWidget *widget) {
  60 + return v3270ft_get_selected(GTK_V3270FT(widget))->remote;
  61 +}
  62 +
  63 +gboolean v3270ft_has_selected(GtkWidget *widget) {
  64 + return GTK_V3270FT(widget)->active != NULL;
  65 +}
  66 +
  67 +gboolean v3270ft_has_next(GtkWidget *widget) {
  68 +
  69 + g_return_val_if_fail(GTK_IS_V3270FT(widget),FALSE);
  70 +
  71 + v3270ft * dialog = GTK_V3270FT(widget);
  72 +
  73 + return dialog->active && dialog->active->next;
  74 +
  75 +}
  76 +
  77 +gboolean v3270ft_is_valid(GtkWidget *widget) {
  78 +
  79 + gboolean rc = FALSE;
  80 +
  81 + struct v3270ft_entry *entry = v3270ft_get_selected(GTK_V3270FT(widget));
  82 +
  83 + if(entry) {
  84 +
  85 + // Marco como TRUE
  86 + rc = TRUE;
  87 +
  88 + // Primeiro testo o corrente que é o que tem mais chance de ser "FALSE"
  89 + entry_is_valid(entry,&rc);
  90 +
  91 + // Verifico toda a lista
  92 + if(rc) {
  93 + g_list_foreach(GTK_V3270FT(widget)->files,(GFunc) entry_is_valid,&rc);
  94 + }
  95 +
  96 + }
  97 +
  98 + return rc;
  99 +
  100 +}
  101 +
  102 +struct v3270ft_entry * v3270ft_get_selected(v3270ft *dialog) {
  103 +
  104 + if(dialog->active)
  105 + return (struct v3270ft_entry *) dialog->active->data;
  106 +
  107 + return NULL;
  108 +}
  109 +
  110 +
... ...
src/pw3270/v3270ft/load.c 0 → 100644
... ... @@ -0,0 +1,268 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como load.c e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 + #include "private.h"
  32 + #include <ctype.h>
  33 + #include <stdlib.h>
  34 +
  35 +
  36 +/*--[ Statics ]--------------------------------------------------------------------------------------*/
  37 +
  38 +
  39 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  40 +
  41 +static void entry_start(GMarkupParseContext *context, const gchar *element_name, const gchar **names,const gchar **values, struct v3270ft_entry *info, GError **error) {
  42 +
  43 + int f;
  44 +
  45 + if(!(g_ascii_strcasecmp(element_name,"name") && g_ascii_strcasecmp(element_name,"file"))) {
  46 +
  47 + const gchar *type;
  48 + const gchar *path;
  49 +
  50 + if(!g_markup_collect_attributes(
  51 + element_name,names,values,error,
  52 + G_MARKUP_COLLECT_STRING, "type", &type,
  53 + G_MARKUP_COLLECT_STRING, "path", &path,
  54 + G_MARKUP_COLLECT_INVALID
  55 + )) {
  56 +
  57 + return;
  58 +
  59 + }
  60 +
  61 + debug("file[%s]=\"%s\"",type,path);
  62 +
  63 + if(!g_ascii_strcasecmp(type,"local")) {
  64 +
  65 + strncpy(info->local,path,sizeof(info->local));
  66 +
  67 + } else if(!g_ascii_strcasecmp(type,"remote")) {
  68 +
  69 + strncpy(info->remote,path,sizeof(info->remote));
  70 +
  71 + }
  72 +
  73 + } if(!g_ascii_strcasecmp(element_name,"option")) {
  74 +
  75 + const gchar *option;
  76 + const gchar *optval;
  77 +
  78 + if(!g_markup_collect_attributes(
  79 + element_name,names,values,error,
  80 + G_MARKUP_COLLECT_STRING, "name", &option,
  81 + G_MARKUP_COLLECT_STRING, "value", &optval,
  82 + G_MARKUP_COLLECT_INVALID
  83 + )) {
  84 +
  85 + return;
  86 +
  87 + }
  88 +
  89 + // Check for options
  90 + for(f=0;f<NUM_OPTIONS_WIDGETS;f++) {
  91 +
  92 + char *name = g_strdup(ft_option[f].name);
  93 + char *value = strchr(name,'.');
  94 +
  95 + if(value) {
  96 + *(value++) = 0;
  97 + }
  98 +
  99 + if( !g_ascii_strcasecmp(option,name)) {
  100 +
  101 + if(!value) {
  102 +
  103 + // Opção é boolean
  104 +
  105 +// debug("%s=%s",option,optval);
  106 +
  107 + if( toupper(*optval) == 'Y' || toupper(*optval) == 'S' || *optval == '1') {
  108 + info->options |= ft_option[f].opt;
  109 + }
  110 +
  111 + } else if(!g_ascii_strcasecmp(value,optval)) {
  112 +
  113 + // Opção tem valor
  114 +// debug("%s=%s",option,optval);
  115 +
  116 + info->options |= ft_option[f].opt;
  117 +
  118 + }
  119 +
  120 +
  121 + g_free(name);
  122 + return;
  123 + }
  124 +
  125 + g_free(name);
  126 + }
  127 +
  128 + // Check for FT values
  129 + for(f=0;f<LIB3270_FT_VALUE_COUNT;f++) {
  130 +
  131 + if(!g_ascii_strcasecmp(option,ft_value[f].name)) {
  132 +
  133 + info->value[f] = atoi(optval);
  134 +// debug("%s=%d",option,info->value[f]);
  135 + return;
  136 +
  137 + }
  138 + }
  139 +
  140 +
  141 + }
  142 +
  143 +
  144 +}
  145 +
  146 +static void element_start(GMarkupParseContext *context, const gchar *element_name, const gchar **names,const gchar **values, v3270ft *widget, GError **error) {
  147 +
  148 + static const GMarkupParser entry_parser = {
  149 + (void (*)(GMarkupParseContext *, const gchar *, const gchar **, const gchar **, gpointer, GError **)) entry_start,
  150 + (void (*)(GMarkupParseContext *, const gchar *, gpointer, GError **)) NULL,
  151 + (void (*)(GMarkupParseContext *, const gchar *, gsize, gpointer, GError **)) NULL,
  152 + (void (*)(GMarkupParseContext *, const gchar *, gsize, gpointer, GError **)) NULL,
  153 + (void (*)(GMarkupParseContext *, GError *, gpointer)) NULL
  154 + };
  155 +
  156 + if(!(g_ascii_strcasecmp(element_name,"entry") && g_ascii_strcasecmp(element_name,"file"))) {
  157 +
  158 + const gchar *action;
  159 + const gchar *type;
  160 + int f;
  161 +
  162 + struct v3270ft_entry *info = g_new0(struct v3270ft_entry,1);
  163 +
  164 + if(!g_markup_collect_attributes(
  165 + element_name,names,values,error,
  166 + G_MARKUP_COLLECT_STRING, "action", &action,
  167 + G_MARKUP_COLLECT_STRING, "type", &type,
  168 + G_MARKUP_COLLECT_INVALID
  169 + )) {
  170 + return;
  171 + }
  172 +
  173 +// debug("action=%s type=%s",action,type);
  174 + for(f=0;f<NUM_TYPES;f++) {
  175 +
  176 + if(!(g_ascii_strcasecmp(action,ft_type[f].name) || (g_ascii_strcasecmp(type,ft_type[f].type)))) {
  177 + info->type = f;
  178 +// debug("info->type=%d",f);
  179 + break;
  180 + }
  181 +
  182 + }
  183 +
  184 + widget->files = g_list_append(widget->files,info);
  185 +
  186 + g_markup_parse_context_push(context,&entry_parser,info);
  187 +
  188 + }
  189 +
  190 +}
  191 +
  192 +static void element_end(GMarkupParseContext *context, const gchar *element_name, void *info, GError **error) {
  193 +
  194 + if(!(g_ascii_strcasecmp(element_name,"entry") && g_ascii_strcasecmp(element_name,"file"))) {
  195 +
  196 + g_markup_parse_context_pop(context);
  197 +
  198 + } else {
  199 +
  200 + debug("%s(%s)",__FUNCTION__,element_name);
  201 +
  202 + }
  203 +
  204 +
  205 +
  206 +}
  207 +
  208 +static void validate_item(struct v3270ft_entry *entry, GError *error) {
  209 + v3270ft_update_state(entry);
  210 +}
  211 +
  212 +void v3270ft_load(GtkWidget *widget,const gchar *filename) {
  213 +
  214 + static const GMarkupParser parser = {
  215 + (void (*)(GMarkupParseContext *, const gchar *, const gchar **, const gchar **, gpointer, GError **)) element_start,
  216 + (void (*)(GMarkupParseContext *, const gchar *, gpointer, GError **)) element_end,
  217 + (void (*)(GMarkupParseContext *, const gchar *, gsize, gpointer, GError **)) NULL,
  218 + (void (*)(GMarkupParseContext *, const gchar *, gsize, gpointer, GError **)) NULL,
  219 + (void (*)(GMarkupParseContext *, GError *, gpointer)) NULL
  220 + };
  221 +
  222 + GError * error = NULL;
  223 + gchar * text = NULL;
  224 + v3270ft * dialog = GTK_V3270FT(widget);
  225 +
  226 + if(dialog->files) {
  227 + g_list_free_full(dialog->files,g_free);
  228 + dialog->files = NULL;
  229 + dialog->active = NULL;
  230 + }
  231 +
  232 + if(g_file_get_contents(filename,&text,NULL,&error)) {
  233 +
  234 + GMarkupParseContext * context = g_markup_parse_context_new(&parser,G_MARKUP_TREAT_CDATA_AS_TEXT|G_MARKUP_PREFIX_ERROR_POSITION,GTK_V3270FT(widget),NULL);
  235 + g_markup_parse_context_parse(context,text,strlen(text),&error);
  236 + g_markup_parse_context_free(context);
  237 + g_free(text);
  238 +
  239 +
  240 + }
  241 +
  242 + g_list_foreach(GTK_V3270FT(widget)->files,(GFunc) validate_item, error);
  243 + v3270ft_select_last(widget);
  244 +
  245 + if(error) {
  246 +
  247 + GtkWidget *popup = gtk_message_dialog_new_with_markup(
  248 + GTK_WINDOW(widget),
  249 + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
  250 + GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE,
  251 + _("Can't load %s"),filename);
  252 +
  253 + gtk_window_set_title(GTK_WINDOW(popup),_("Operation has failed"));
  254 +
  255 + if(error->message && *error->message) {
  256 + gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(popup),"%s",error->message);
  257 + }
  258 +
  259 + g_error_free(error);
  260 +
  261 + gtk_dialog_run(GTK_DIALOG(popup));
  262 + gtk_widget_destroy(popup);
  263 +
  264 + }
  265 +
  266 +}
  267 +
  268 +
... ...
src/pw3270/v3270ft/marshal.c 0 → 100644
... ... @@ -0,0 +1,88 @@
  1 +
  2 +#include <glib-object.h>
  3 +
  4 +
  5 +#ifdef G_ENABLE_DEBUG
  6 +#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
  7 +#define g_marshal_value_peek_char(v) g_value_get_schar (v)
  8 +#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
  9 +#define g_marshal_value_peek_int(v) g_value_get_int (v)
  10 +#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
  11 +#define g_marshal_value_peek_long(v) g_value_get_long (v)
  12 +#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
  13 +#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
  14 +#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
  15 +#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
  16 +#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
  17 +#define g_marshal_value_peek_float(v) g_value_get_float (v)
  18 +#define g_marshal_value_peek_double(v) g_value_get_double (v)
  19 +#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
  20 +#define g_marshal_value_peek_param(v) g_value_get_param (v)
  21 +#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
  22 +#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
  23 +#define g_marshal_value_peek_object(v) g_value_get_object (v)
  24 +#define g_marshal_value_peek_variant(v) g_value_get_variant (v)
  25 +#else /* !G_ENABLE_DEBUG */
  26 +/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
  27 + * Do not access GValues directly in your code. Instead, use the
  28 + * g_value_get_*() functions
  29 + */
  30 +#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
  31 +#define g_marshal_value_peek_char(v) (v)->data[0].v_int
  32 +#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
  33 +#define g_marshal_value_peek_int(v) (v)->data[0].v_int
  34 +#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
  35 +#define g_marshal_value_peek_long(v) (v)->data[0].v_long
  36 +#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
  37 +#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
  38 +#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
  39 +#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
  40 +#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
  41 +#define g_marshal_value_peek_float(v) (v)->data[0].v_float
  42 +#define g_marshal_value_peek_double(v) (v)->data[0].v_double
  43 +#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
  44 +#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
  45 +#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
  46 +#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
  47 +#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
  48 +#define g_marshal_value_peek_variant(v) (v)->data[0].v_pointer
  49 +#endif /* !G_ENABLE_DEBUG */
  50 +
  51 +
  52 +/* VOID:POINTER,POINTER (genmarshal:1) */
  53 +void
  54 +v3270ft_VOID__POINTER_POINTER (GClosure *closure,
  55 + GValue *return_value G_GNUC_UNUSED,
  56 + guint n_param_values,
  57 + const GValue *param_values,
  58 + gpointer invocation_hint G_GNUC_UNUSED,
  59 + gpointer marshal_data)
  60 +{
  61 + typedef void (*GMarshalFunc_VOID__POINTER_POINTER) (gpointer data1,
  62 + gpointer arg_1,
  63 + gpointer arg_2,
  64 + gpointer data2);
  65 + register GMarshalFunc_VOID__POINTER_POINTER callback;
  66 + register GCClosure *cc = (GCClosure*) closure;
  67 + register gpointer data1, data2;
  68 +
  69 + g_return_if_fail (n_param_values == 3);
  70 +
  71 + if (G_CCLOSURE_SWAP_DATA (closure))
  72 + {
  73 + data1 = closure->data;
  74 + data2 = g_value_peek_pointer (param_values + 0);
  75 + }
  76 + else
  77 + {
  78 + data1 = g_value_peek_pointer (param_values + 0);
  79 + data2 = closure->data;
  80 + }
  81 + callback = (GMarshalFunc_VOID__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
  82 +
  83 + callback (data1,
  84 + g_marshal_value_peek_pointer (param_values + 1),
  85 + g_marshal_value_peek_pointer (param_values + 2),
  86 + data2);
  87 +}
  88 +
... ...
src/pw3270/v3270ft/marshal.h 0 → 100644
... ... @@ -0,0 +1,20 @@
  1 +
  2 +#ifndef __v3270ft_MARSHAL_H__
  3 +#define __v3270ft_MARSHAL_H__
  4 +
  5 +#include <glib-object.h>
  6 +
  7 +G_BEGIN_DECLS
  8 +
  9 +/* VOID:POINTER,POINTER (genmarshal:1) */
  10 +extern void v3270ft_VOID__POINTER_POINTER (GClosure *closure,
  11 + GValue *return_value,
  12 + guint n_param_values,
  13 + const GValue *param_values,
  14 + gpointer invocation_hint,
  15 + gpointer marshal_data);
  16 +
  17 +G_END_DECLS
  18 +
  19 +#endif /* __v3270ft_MARSHAL_H__ */
  20 +
... ...
src/pw3270/v3270ft/misc.c 0 → 100644
... ... @@ -0,0 +1,96 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como misc.c e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 + #include "private.h"
  32 +
  33 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  34 +
  35 +void v3270ft_update_state(struct v3270ft_entry *entry) {
  36 +
  37 + // Reset
  38 + entry->valid = FALSE;
  39 +
  40 + // Have filenames? If not just return
  41 + if(!(*entry->local && *entry->remote))
  42 + return;
  43 +
  44 + // Filename widgets has data, validade it.
  45 + if(entry->options & LIB3270_FT_OPTION_RECEIVE) {
  46 +
  47 + // Receber arquivos, verifico se o diretório de destino é válido
  48 + gchar *dir = g_path_get_dirname(entry->local);
  49 + entry->valid = g_file_test(dir,G_FILE_TEST_IS_DIR);
  50 + g_free(dir);
  51 +
  52 + } else {
  53 +
  54 + entry->valid = g_file_test(entry->local,G_FILE_TEST_IS_REGULAR);
  55 +
  56 + }
  57 +
  58 +}
  59 +
  60 +void v3270ft_update_actions(v3270ft *dialog) {
  61 +
  62 + struct v3270ft_entry *entry = v3270ft_get_selected(dialog);
  63 +
  64 + if(entry) {
  65 +
  66 + v3270ft_update_state(entry);
  67 +
  68 + // Atualizo botões
  69 + gboolean is_valid = v3270ft_is_valid(GTK_WIDGET(dialog));
  70 +
  71 + gtk_widget_set_sensitive(dialog->button[FT_BUTTON_INSERT_FILE],is_valid);
  72 + gtk_widget_set_sensitive(dialog->button[FT_BUTTON_START_TRANSFER],is_valid);
  73 + gtk_widget_set_sensitive(dialog->button[FT_BUTTON_SAVE_LIST],is_valid);
  74 +
  75 + gtk_widget_set_sensitive(dialog->button[FT_BUTTON_GO_PREVIOUS],dialog->active->prev != NULL);
  76 + gtk_widget_set_sensitive(dialog->button[FT_BUTTON_GO_FIRST],dialog->active->prev != NULL);
  77 +
  78 + gtk_widget_set_sensitive(dialog->button[FT_BUTTON_GO_NEXT],dialog->active->next != NULL);
  79 + gtk_widget_set_sensitive(dialog->button[FT_BUTTON_GO_LAST],dialog->active->next != NULL);
  80 +
  81 + } else {
  82 +
  83 + gtk_widget_set_sensitive(dialog->button[FT_BUTTON_INSERT_FILE],FALSE);
  84 + gtk_widget_set_sensitive(dialog->button[FT_BUTTON_START_TRANSFER],FALSE);
  85 + gtk_widget_set_sensitive(dialog->button[FT_BUTTON_SAVE_LIST],FALSE);
  86 +
  87 + gtk_widget_set_sensitive(dialog->button[FT_BUTTON_GO_PREVIOUS],FALSE);
  88 + gtk_widget_set_sensitive(dialog->button[FT_BUTTON_GO_FIRST],FALSE);
  89 +
  90 + gtk_widget_set_sensitive(dialog->button[FT_BUTTON_GO_NEXT],FALSE);
  91 + gtk_widget_set_sensitive(dialog->button[FT_BUTTON_GO_LAST],FALSE);
  92 +
  93 + }
  94 +
  95 +}
  96 +
... ...
src/pw3270/v3270ft/private.h 0 → 100644
... ... @@ -0,0 +1,199 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como private.h e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 +#ifndef PRIVATE_H_INCLUDED
  32 +
  33 + #define PRIVATE_H_INCLUDED 1
  34 +
  35 + #include <v3270ft.h>
  36 + #include <v3270ftprogress.h>
  37 + #include <lib3270.h>
  38 + #include <lib3270/filetransfer.h>
  39 +
  40 + #define NUM_OPTIONS_WIDGETS 12
  41 + #define NUM_TYPES 4
  42 + #define ERROR_DOMAIN g_quark_from_static_string("v3270ft")
  43 +
  44 + typedef enum ft_button {
  45 +
  46 + FT_BUTTON_GO_FIRST,
  47 + FT_BUTTON_GO_PREVIOUS,
  48 + FT_BUTTON_GO_NEXT,
  49 + FT_BUTTON_GO_LAST,
  50 + FT_BUTTON_START_TRANSFER,
  51 + FT_BUTTON_INSERT_FILE,
  52 + FT_BUTTON_REMOVE_FILE,
  53 + FT_BUTTON_SAVE_LIST,
  54 + FT_BUTTON_LOAD_LIST,
  55 +
  56 + FT_BUTTON_COUNT
  57 + } FT_BUTTON;
  58 +
  59 + const struct v3270ft_option {
  60 +
  61 + LIB3270_FT_OPTION opt;
  62 + const char * name;
  63 + const char * label;
  64 + const char * tooltip;
  65 +
  66 + } ft_option[NUM_OPTIONS_WIDGETS];
  67 +
  68 + const struct v3270ft_type {
  69 + LIB3270_FT_OPTION opt;
  70 + const gchar * name;
  71 + const gchar * type;
  72 + const gchar * label;
  73 + } ft_type[NUM_TYPES];
  74 +
  75 + const struct v3270ft_value {
  76 +
  77 + const gchar * name;
  78 + guint minval;
  79 + guint maxval;
  80 + const gchar * label;
  81 + const gchar * tooltip;
  82 +
  83 + } ft_value[LIB3270_FT_VALUE_COUNT];
  84 +
  85 + struct v3270ft_entry {
  86 + gint type; ///< Transfer type.
  87 + gboolean valid; ///< Is dialog content valid?
  88 + gchar local[FILENAME_MAX]; ///< Local file name.
  89 + gchar remote[FILENAME_MAX]; ///< Remote file name.
  90 + LIB3270_FT_OPTION options; ///< File Transfer options.
  91 + guint value[LIB3270_FT_VALUE_COUNT]; ///< File transfer values.
  92 + };
  93 +
  94 + struct _v3270ft {
  95 + GtkDialog parent;
  96 +
  97 + GtkComboBox * type;
  98 + GtkEntry * local; ///< Local file name
  99 + GtkEntry * remote; ///< Remote filename
  100 +
  101 + GtkWidget * opt[NUM_OPTIONS_WIDGETS];
  102 + GtkWidget * button[FT_BUTTON_COUNT];
  103 + GtkWidget * radio[2];
  104 + GtkWidget * value[LIB3270_FT_VALUE_COUNT];
  105 +
  106 + GList * files; /// List of files.
  107 + GList * active; /// Active element.
  108 +
  109 + };
  110 +
  111 + typedef enum progress_field {
  112 +
  113 + PROGRESS_FIELD_LOCAL,
  114 + PROGRESS_FIELD_REMOTE,
  115 + PROGRESS_FIELD_TOTAL,
  116 + PROGRESS_FIELD_CURRENT,
  117 + PROGRESS_FIELD_SPEED,
  118 + PROGRESS_FIELD_ETA,
  119 +
  120 + PROGRESS_FIELD_COUNT
  121 +
  122 + } PROGRESS_FIELD;
  123 +
  124 + enum V3270FTPROGRESS_SIGNAL {
  125 +
  126 + V3270FTPROGRESS_SIGNAL_SUCCESS,
  127 + V3270FTPROGRESS_SIGNAL_FAILED,
  128 +
  129 + V3270FTPROGRESS_SIGNAL_COUNT,
  130 + };
  131 +
  132 + struct _v3270ftprogress {
  133 +
  134 + GtkDialog parent;
  135 +
  136 + struct v3270ft_entry * active; ///< Transferência em andamento.
  137 + H3270 * session; ///< lib3270 session handle.
  138 + time_t timeout; ///< When the transfer will fail with timeout.
  139 +
  140 + GtkEntry * info[PROGRESS_FIELD_COUNT]; ///< Widgets com informações da transferência atual.
  141 + GtkProgressBar * progress;
  142 + GSource * pulse;
  143 + GSource * timer;
  144 +
  145 + };
  146 +
  147 + struct _v3270ftClass {
  148 +
  149 + GtkDialogClass parent_class;
  150 + int dummy;
  151 +
  152 + };
  153 +
  154 + struct _v3270ftprogressClass {
  155 +
  156 + GtkDialogClass parent_class;
  157 +
  158 + /* Signals */
  159 + void (*complete)(GtkWidget *widget);
  160 + void (*failed)(GtkWidget *widget);
  161 +
  162 + };
  163 +
  164 + #ifdef DEBUG
  165 +
  166 + #define debug(fmt, ...) g_message( "%s(%d) " fmt , __FILE__, (int) __LINE__, __VA_ARGS__ )
  167 +
  168 + #else
  169 +
  170 + #define debug(fmt, ...) /* */
  171 +
  172 + #endif // DEBUG
  173 +
  174 +
  175 + G_GNUC_INTERNAL guint v3270ftprogress_signal[V3270FTPROGRESS_SIGNAL_COUNT];
  176 +
  177 +
  178 +// G_GNUC_INTERNAL void v3270ft_store(v3270ft *dialog, struct v3270ft_entry *info);
  179 +// G_GNUC_INTERNAL void v3270ft_restore(v3270ft *dialog, struct v3270ft_entry *info);
  180 +
  181 + G_GNUC_INTERNAL void v3270ft_update_actions(v3270ft *dialog);
  182 + G_GNUC_INTERNAL void v3270ft_update_state(struct v3270ft_entry *entry);
  183 + G_GNUC_INTERNAL void v3270ft_set_active(v3270ft *dialog, GList * active);
  184 + G_GNUC_INTERNAL GtkGrid * v3270ft_new_grid(void);
  185 + G_GNUC_INTERNAL void v3270ft_clear(v3270ft *dialog);
  186 + G_GNUC_INTERNAL gchar * v3270ft_select_file(v3270ft *dialog, const gchar *title, const gchar *button, GtkFileChooserAction action, const gchar *filename);
  187 +
  188 + G_GNUC_INTERNAL void v3270ftprogress_set_session(GtkWidget *widget, H3270 *session);
  189 + G_GNUC_INTERNAL void v3270ftprogress_update(GtkWidget *widget, unsigned long current, unsigned long total, double kbytes_sec);
  190 +
  191 + G_GNUC_INTERNAL void v3270ftprogress_set_transfer(GtkWidget *widget, struct v3270ft_entry *entry);
  192 + G_GNUC_INTERNAL void v3270ftprogress_start_transfer(GtkWidget *widget);
  193 +
  194 + G_GNUC_INTERNAL struct v3270ft_entry * v3270ft_get_selected(v3270ft *dialog);
  195 + G_GNUC_INTERNAL struct v3270ft_entry * v3270ft_create_entry(void);
  196 +
  197 +
  198 +
  199 +#endif // PRIVATE_H_INCLUDED
... ...
src/pw3270/v3270ft/save.c 0 → 100644
... ... @@ -0,0 +1,104 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como save.c e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 + #include "private.h"
  32 +
  33 +
  34 +/*--[ Statics ]--------------------------------------------------------------------------------------*/
  35 +
  36 +
  37 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  38 +
  39 + void get_item(struct v3270ft_entry *entry, GString *str) {
  40 +
  41 + int f;
  42 +
  43 + g_string_append_printf(str,"\t<entry action=\"%s\" type=\"%s\">\n",ft_type[entry->type].name,ft_type[entry->type].type);
  44 + g_string_append_printf(str,"\t\t<file type=\"%s\" path=\"%s\"/>\n","local",entry->local);
  45 + g_string_append_printf(str,"\t\t<file type=\"%s\" path=\"%s\"/>\n","remote",entry->remote);
  46 +
  47 + for(f=0;f<NUM_OPTIONS_WIDGETS;f++) {
  48 +
  49 + if( (entry->options & ft_option[f].opt) == ft_option[f].opt) {
  50 + char *name = g_strdup(ft_option[f].name);
  51 + char *value = strchr(name,'.');
  52 +
  53 + if(value)
  54 + *(value++) = 0;
  55 + else
  56 + value = "yes";
  57 +
  58 + g_string_append_printf(str,"\t\t<option name=\"%s\" value=\"%s\"/>\n",name,value);
  59 +
  60 + g_free(name);
  61 + }
  62 + }
  63 +
  64 + for(f=0;f<LIB3270_FT_VALUE_COUNT;f++) {
  65 + g_string_append_printf(str,"\t\t<option name=\"%s\" value=\"%u\"/>\n",ft_value[f].name,entry->value[f]);
  66 + }
  67 +
  68 + g_string_append(str,"\t</entry>\n");
  69 + }
  70 +
  71 + void v3270ft_save(GtkWidget *widget,const gchar *filename) {
  72 +
  73 + GString * str = g_string_new("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<filelist>\n");
  74 + gchar * text;
  75 + GError * error = NULL;
  76 +
  77 + g_list_foreach(GTK_V3270FT(widget)->files,(GFunc) get_item, str);
  78 +
  79 + g_string_append(str,"</filelist>");
  80 +
  81 + text = g_string_free(str,FALSE);
  82 +
  83 + if(!g_file_set_contents(filename,text,-1,&error)) {
  84 +
  85 + GtkWidget *popup = gtk_message_dialog_new_with_markup(
  86 + GTK_WINDOW(widget),
  87 + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
  88 + GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE,
  89 + _("Can't save %s"),filename);
  90 +
  91 + gtk_window_set_title(GTK_WINDOW(popup),_("Operation has failed"));
  92 +
  93 + gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(popup),"%s",error->message);
  94 + g_error_free(error);
  95 +
  96 + gtk_dialog_run(GTK_DIALOG(popup));
  97 + gtk_widget_destroy(popup);
  98 +
  99 + }
  100 +
  101 + g_free(text);
  102 +
  103 + }
  104 +
... ...
src/pw3270/v3270ft/select.c 0 → 100644
... ... @@ -0,0 +1,88 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como select.c e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 + #include "private.h"
  32 +
  33 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  34 +
  35 +gchar * v3270ft_select_file(v3270ft *dialog, const gchar *title, const gchar *button, GtkFileChooserAction action, const gchar *filename) {
  36 +
  37 + gchar *rc = NULL;
  38 +
  39 +#if GTK_CHECK_VERSION(3,20,0)
  40 +
  41 + GtkFileChooserNative *native = gtk_file_chooser_native_new
  42 + (
  43 + title,
  44 + GTK_WIDGET(dialog),
  45 + action,
  46 + button,
  47 + _( "_Cancel" )
  48 + );
  49 +
  50 +
  51 + if(gtk_native_dialog_run(GTK_NATIVE_DIALOG (native)) == GTK_RESPONSE_ACCEPT) {
  52 + rc = g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(native)));
  53 + }
  54 +
  55 + g_object_unref(native);
  56 +
  57 +#elif defined(_WIN32)
  58 +
  59 + #error Usar diálogo nativo windows
  60 +
  61 +#else
  62 +
  63 + GtkWidget * chooser = gtk_file_chooser_dialog_new
  64 + (
  65 + title,
  66 + GTK_WINDOW(dialog),
  67 + GTK_FILE_CHOOSER_ACTION_OPEN,
  68 + _("_Cancel" ), GTK_RESPONSE_CANCEL,
  69 + button, GTK_RESPONSE_ACCEPT,
  70 + NULL
  71 + );
  72 +
  73 + if(filename && *filename)
  74 + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(chooser),filename);
  75 +
  76 + if(gtk_dialog_run(GTK_DIALOG(chooser)) == GTK_RESPONSE_ACCEPT) {
  77 + rc = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser));
  78 + }
  79 +
  80 + gtk_widget_destroy(chooser);
  81 +
  82 +
  83 +#endif // defined
  84 +
  85 + return rc;
  86 +
  87 +}
  88 +
... ...
src/pw3270/v3270ft/set.c 0 → 100644
... ... @@ -0,0 +1,214 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como set.c e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 + #include "private.h"
  32 +
  33 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  34 +
  35 +void v3270ft_set_active(v3270ft *dialog, GList * active) {
  36 +
  37 + int f;
  38 + gboolean sensitive = (active != NULL);
  39 +
  40 + dialog->active = active;
  41 +
  42 + // Habilita/Desabilita widgets
  43 + gtk_widget_set_sensitive(GTK_WIDGET(dialog->type),sensitive);
  44 + gtk_widget_set_sensitive(GTK_WIDGET(dialog->local),sensitive);
  45 + gtk_widget_set_sensitive(GTK_WIDGET(dialog->remote),sensitive);
  46 +
  47 + for(f=0;f<NUM_OPTIONS_WIDGETS;f++) {
  48 + gtk_widget_set_sensitive(dialog->opt[f],sensitive);
  49 + }
  50 +
  51 + for(f=0;f<FT_BUTTON_COUNT;f++) {
  52 + gtk_widget_set_sensitive(dialog->button[f],sensitive);
  53 + }
  54 +
  55 + for(f = 0; f < LIB3270_FT_VALUE_COUNT; f++) {
  56 + gtk_widget_set_sensitive(dialog->value[f],sensitive);
  57 + }
  58 +
  59 + // Preenche dialogo
  60 + if(sensitive) {
  61 +
  62 + struct v3270ft_entry * info = (struct v3270ft_entry *) active->data;
  63 +
  64 + gtk_combo_box_set_active(dialog->type,info->type);
  65 +
  66 + gtk_entry_set_text(dialog->local,info->local);
  67 + gtk_entry_set_text(dialog->remote,info->remote);
  68 +
  69 + v3270ft_set_options(GTK_WIDGET(dialog),info->options);
  70 +
  71 + for(f = 0; f < LIB3270_FT_VALUE_COUNT; f++) {
  72 + gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->value[f]),info->value[f]);
  73 + }
  74 +
  75 +
  76 + } else {
  77 +
  78 + gtk_entry_set_text(dialog->local,"");
  79 + gtk_entry_set_text(dialog->remote,"");
  80 +
  81 + v3270ft_set_options(GTK_WIDGET(dialog),0);
  82 +
  83 + for(f = 0; f < LIB3270_FT_VALUE_COUNT; f++) {
  84 + gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->value[f]),0);
  85 + }
  86 +
  87 + }
  88 +
  89 +
  90 +}
  91 +
  92 +
  93 +/**
  94 + * v3270ft_set_options:
  95 + * @widget: a #v3270ft
  96 + * @options: The lib3270 file transfer options.
  97 + *
  98 + * Since: 5.1
  99 + **/
  100 +void v3270ft_set_options(GtkWidget *widget, LIB3270_FT_OPTION opt) {
  101 +
  102 + int id;
  103 + v3270ft * ft = GTK_V3270FT(widget);
  104 +
  105 + if(opt & LIB3270_FT_OPTION_RECEIVE) {
  106 +
  107 + // Receber arquivo, reseto flags específicas do envio
  108 + opt &= ~(LIB3270_FT_RECORD_FORMAT_DEFAULT|LIB3270_FT_RECORD_FORMAT_FIXED|LIB3270_FT_RECORD_FORMAT_VARIABLE|LIB3270_FT_RECORD_FORMAT_UNDEFINED|LIB3270_FT_ALLOCATION_UNITS_DEFAULT|LIB3270_FT_ALLOCATION_UNITS_TRACKS|LIB3270_FT_ALLOCATION_UNITS_CYLINDERS|LIB3270_FT_ALLOCATION_UNITS_AVBLOCK);
  109 +
  110 + gtk_widget_set_sensitive(ft->radio[0],FALSE);
  111 + gtk_widget_set_sensitive(ft->radio[1],FALSE);
  112 +
  113 + for(id = 0; id < 4; id++) {
  114 + gtk_widget_set_sensitive(ft->value[id],FALSE);
  115 + gtk_spin_button_set_value(GTK_SPIN_BUTTON(ft->value[id]),0);
  116 + }
  117 +
  118 + } else {
  119 +
  120 + gtk_widget_set_sensitive(ft->radio[0],TRUE);
  121 + gtk_widget_set_sensitive(ft->radio[1],TRUE);
  122 +
  123 + for(id = 0; id < 4; id++) {
  124 + gtk_widget_set_sensitive(ft->value[id],TRUE);
  125 + }
  126 + }
  127 +
  128 + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ft->opt[4]),TRUE);
  129 + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ft->opt[8]),TRUE);
  130 +
  131 + for(id=0;id<NUM_OPTIONS_WIDGETS;id++) {
  132 + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ft->opt[id]),(opt & ft_option[id].opt) == ft_option[id].opt);
  133 + }
  134 +
  135 + struct v3270ft_entry *entry = v3270ft_get_selected(ft);
  136 +
  137 + if(entry) {
  138 + entry->options = opt;
  139 + v3270ft_update_actions(ft);
  140 + }
  141 +
  142 +}
  143 +
  144 +void v3270ftprogress_set_header(GtkWidget *widget, const gchar *status) {
  145 +
  146 + gtk_header_bar_set_subtitle(GTK_HEADER_BAR(gtk_dialog_get_header_bar(GTK_DIALOG(widget))),status);
  147 +
  148 +}
  149 +
  150 +void v3270ftprogress_set_transfer(GtkWidget *widget, struct v3270ft_entry *entry) {
  151 +
  152 + v3270ftprogress * dialog = GTK_V3270FTPROGRESS(widget);
  153 +
  154 + /*
  155 + if(dialog->session) {
  156 + lib3270_ft_set_user_data(dialog->session,NULL);
  157 + lib3270_ft_destroy(dialog->session);
  158 + }
  159 + */
  160 +
  161 + dialog->active = entry;
  162 +
  163 + debug("%s\n%s <-> %s",__FUNCTION__,entry->local,entry->remote);
  164 +
  165 + gtk_entry_set_text(dialog->info[PROGRESS_FIELD_LOCAL],entry->local);
  166 + gtk_entry_set_text(dialog->info[PROGRESS_FIELD_REMOTE],entry->remote);
  167 +
  168 + gtk_entry_set_text(dialog->info[PROGRESS_FIELD_TOTAL],"");
  169 + gtk_entry_set_text(dialog->info[PROGRESS_FIELD_CURRENT],"");
  170 + gtk_entry_set_text(dialog->info[PROGRESS_FIELD_SPEED],"");
  171 + gtk_entry_set_text(dialog->info[PROGRESS_FIELD_ETA],"");
  172 +
  173 + gtk_progress_bar_set_fraction(dialog->progress,0);
  174 + v3270ftprogress_set_header(widget,_("Preparing"));
  175 +
  176 +}
  177 +
  178 +void v3270ftprogress_set_session(GtkWidget *widget, H3270 *session) {
  179 +
  180 + v3270ftprogress * dialog = GTK_V3270FTPROGRESS(widget);
  181 +
  182 + if(dialog->session) {
  183 + lib3270_ft_destroy(dialog->session);
  184 + }
  185 +
  186 + dialog->session = session;
  187 +}
  188 +
  189 +guint v3270ft_append_selection(GtkWidget *widget, GtkSelectionData *data) {
  190 +
  191 + gchar **uri = g_strsplit((const gchar *) gtk_selection_data_get_text(data),"\n",-1);
  192 + size_t f;
  193 + guint qtd = 0;
  194 +
  195 + for(f=0;uri[f];f++) {
  196 +
  197 + if(!g_ascii_strncasecmp("file:///",uri[f],8)) {
  198 +
  199 + const gchar *filename = uri[f]+7;
  200 +
  201 + if(g_file_test(filename,G_FILE_TEST_IS_REGULAR)) {
  202 + v3270ft_append_file(widget,filename,TRUE);
  203 + qtd++;
  204 + }
  205 +
  206 + }
  207 + }
  208 +
  209 + g_strfreev(uri);
  210 +
  211 + return qtd;
  212 +}
  213 +
  214 +
... ...
src/pw3270/v3270ft/tables.c 0 → 100644
... ... @@ -0,0 +1,196 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como new.c e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + * Referências:
  30 + *
  31 + * * http://www3.rocketsoftware.com/bluezone/help/v42/en/bz/DISPLAY/IND$FILE/IND$FILE_Technical_Reference.htm
  32 + *
  33 + */
  34 +
  35 + #include "private.h"
  36 +
  37 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  38 +
  39 +const struct v3270ft_option ft_option[NUM_OPTIONS_WIDGETS] = {
  40 +
  41 + // Transfer options
  42 + {
  43 + LIB3270_FT_OPTION_ASCII,
  44 + "ascii",
  45 + N_("_Text file"),
  46 + N_( "Check this if the file consists of character data only.")
  47 + },
  48 + {
  49 + LIB3270_FT_OPTION_CRLF,
  50 + "crlf",
  51 + N_("Follow the convention for _ASCII text files."),
  52 +#ifdef _WIN32
  53 + N_( "Following the convention for ASCII text files, CR/LF pairs are used to terminate records in the PC file, and a CTRL-Z (x'1A') marks the end of file.")
  54 +#else
  55 + N_( "Following the convention for ASCII text files, LF is used to terminate records in the PC file.")
  56 +#endif // _WIN32
  57 +
  58 + },
  59 + {
  60 + LIB3270_FT_OPTION_APPEND,
  61 + "append",
  62 + N_("A_ppend to file"),
  63 + N_( "Appends the source file to the destination file.")
  64 + },
  65 + {
  66 + LIB3270_FT_OPTION_REMAP,
  67 + "remap",
  68 + N_("Re_map ASCII Characters."),
  69 + N_("Remap the text to ensure maximum compatibility between the workstation's character set and encoding and the host's EBCDIC code page.")
  70 + },
  71 +
  72 + // Record format
  73 + {
  74 + LIB3270_FT_RECORD_FORMAT_DEFAULT,
  75 + "recfm.default",
  76 + N_("Default"),
  77 + N_("Use host default record format.")
  78 + },
  79 + {
  80 + LIB3270_FT_RECORD_FORMAT_FIXED,
  81 + "recfm.fixed",
  82 + N_("Fixed"),
  83 + N_("Creates a file with fixed-length records.")
  84 + },
  85 + {
  86 + LIB3270_FT_RECORD_FORMAT_VARIABLE,
  87 + "recfm.variable",
  88 + N_("Variable"),
  89 + N_("Creates a file with variable-length records.")
  90 + },
  91 + {
  92 + LIB3270_FT_RECORD_FORMAT_UNDEFINED,
  93 + "recfm.undefined",
  94 + N_("Undefined"),
  95 + N_("Creates a file with undefined-length records (TSO hosts only).")
  96 + },
  97 +
  98 + // Space allocation units
  99 + {
  100 + LIB3270_FT_ALLOCATION_UNITS_DEFAULT,
  101 + "units.default",
  102 + N_("Default"),
  103 + NULL
  104 + },
  105 + {
  106 + LIB3270_FT_ALLOCATION_UNITS_TRACKS,
  107 + "units.tracks",
  108 + N_("Tracks"),
  109 + NULL
  110 + },
  111 + {
  112 + LIB3270_FT_ALLOCATION_UNITS_CYLINDERS,
  113 + "units.cylinders",
  114 + N_("Cylinders"),
  115 + NULL
  116 + },
  117 + {
  118 + LIB3270_FT_ALLOCATION_UNITS_AVBLOCK,
  119 + "units.avblock",
  120 + N_("Avblock"),
  121 + NULL
  122 + },
  123 +
  124 +};
  125 +
  126 +const struct v3270ft_type ft_type[NUM_TYPES] = {
  127 +
  128 + {
  129 + LIB3270_FT_OPTION_SEND,
  130 + "send",
  131 + "binary",
  132 + N_("Send file")
  133 + },
  134 + {
  135 + LIB3270_FT_OPTION_RECEIVE,
  136 + "receive",
  137 + "binary",
  138 + N_("Receive file")
  139 + },
  140 + {
  141 + LIB3270_FT_OPTION_SEND|LIB3270_FT_OPTION_ASCII|LIB3270_FT_OPTION_CRLF|LIB3270_FT_OPTION_REMAP,
  142 + "send",
  143 + "text",
  144 + N_("Send text file")
  145 + },
  146 + {
  147 + LIB3270_FT_OPTION_RECEIVE|LIB3270_FT_OPTION_ASCII|LIB3270_FT_OPTION_CRLF|LIB3270_FT_OPTION_REMAP,
  148 + "receive",
  149 + "text",
  150 + N_("Receive text file")
  151 + }
  152 +};
  153 +
  154 +const struct v3270ft_value ft_value[LIB3270_FT_VALUE_COUNT] = {
  155 + {
  156 + "lrecl",
  157 + 0, 32760,
  158 + N_( "Record Length:" ),
  159 + N_( "Specifies the logical record length (n) for a data set consisting of fixed length records or the maximum logical record length for a data set consisting of variable length records." )
  160 + },
  161 +
  162 +
  163 + {
  164 + "primary",
  165 + 0,99999,
  166 + N_( "Primary space:" ),
  167 + N_( "Primary allocation for a file created on a TSO host.\nThe units are given by the space allocation units option." )
  168 + },
  169 +
  170 + {
  171 + "blksize",
  172 + 0,32760,
  173 + N_( "Block size:" ),
  174 + N_( "Specifies the block size (n) for a new data set. For data sets containing fixed " \
  175 + "length records, the block size must be a multiple of the record length. " \
  176 + "For data sets containing variable length records, the block size must be " \
  177 + "greater than or equal to the record length plus four bytes. The block size " \
  178 + "must not exceed the track length of the device on which the data set resides." )
  179 + },
  180 +
  181 + {
  182 + "secondary",
  183 + 0,99999,
  184 + N_( "Secondary space:" ),
  185 + N_( "Secondary allocation for a file created on a TSO host.\nThe units are given by the space allocation units option." )
  186 + },
  187 +
  188 + {
  189 + "dft",
  190 + 0,99999,
  191 + N_( "DFT B_uffer size:" ),
  192 + N_("Specifies the default buffer size for DFT IND$FILE file transfers.")
  193 + },
  194 +
  195 +};
  196 +
... ...
src/pw3270/v3270ft/testprogram.c 0 → 100644
... ... @@ -0,0 +1,132 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como testprogram.c e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 + #include <v3270.h>
  32 + #include <v3270ft.h>
  33 + #include <v3270ftprogress.h>
  34 + #include <stdlib.h>
  35 +
  36 + /*---[ Implement ]----------------------------------------------------------------------------------*/
  37 +
  38 +static gboolean popup_menu(GtkWidget *widget, gboolean selected, gboolean online, GdkEventButton *event, gpointer user_data) {
  39 +
  40 + if(!online)
  41 + return FALSE;
  42 +
  43 + GtkWidget * dialog = v3270ft_new();
  44 +
  45 + v3270ft_load(dialog,"transfer.xml");
  46 +
  47 + gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(gtk_widget_get_toplevel(widget)));
  48 +
  49 + do {
  50 +
  51 + gtk_widget_show_all(dialog);
  52 +
  53 + switch(gtk_dialog_run(GTK_DIALOG(dialog))) {
  54 + case GTK_RESPONSE_APPLY:
  55 + case GTK_RESPONSE_OK:
  56 + case GTK_RESPONSE_YES:
  57 + gtk_widget_hide(dialog);
  58 + v3270ft_transfer(dialog,v3270_get_session(widget));
  59 + break;
  60 +
  61 + case GTK_RESPONSE_CANCEL:
  62 + case GTK_RESPONSE_NO:
  63 + case GTK_RESPONSE_DELETE_EVENT:
  64 + v3270ft_remove_all(dialog);
  65 + break;
  66 +
  67 + default:
  68 + g_warning("Unexpected response from v3270ft");
  69 + }
  70 +
  71 + } while(v3270ft_get_length(dialog) > 0);
  72 +
  73 + gtk_widget_destroy(dialog);
  74 +
  75 + return TRUE;
  76 +
  77 +}
  78 +
  79 +static void activate(GtkApplication* app, gpointer user_data) {
  80 +
  81 + const gchar * search[] = {
  82 +
  83 + g_get_user_config_dir(),
  84 + g_get_user_data_dir(),
  85 + g_get_home_dir(),
  86 + NULL
  87 +
  88 + };
  89 +
  90 + GtkWidget * window = gtk_application_window_new(app);
  91 + GtkWidget * terminal = v3270_new();
  92 + gchar * filename = NULL;
  93 +
  94 + // Setup terminal
  95 + GKeyFile * conf = g_key_file_new();
  96 +
  97 + g_key_file_load_from_dirs(conf,"pw3270.conf",(const gchar **) search, &filename,G_KEY_FILE_NONE,NULL);
  98 + g_message("Configuration from %s",filename);
  99 +
  100 + v3270_set_from_keyfile(terminal,conf);
  101 +
  102 + g_key_file_unref(conf);
  103 +
  104 + v3270_connect(terminal);
  105 +
  106 + g_signal_connect(terminal,"popup",G_CALLBACK(popup_menu),NULL);
  107 +
  108 + // Setup and show window
  109 + gtk_window_set_title(GTK_WINDOW(window), "Window");
  110 + gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
  111 + gtk_window_set_default_size (GTK_WINDOW (window), 800, 500);
  112 + gtk_container_add(GTK_CONTAINER(window),terminal);
  113 + gtk_widget_show_all (window);
  114 +
  115 +}
  116 +
  117 +int main (int argc, char **argv) {
  118 +
  119 + GtkApplication *app;
  120 + int status;
  121 +
  122 + app = gtk_application_new ("br.com.bb.pw3270",G_APPLICATION_FLAGS_NONE);
  123 +
  124 + g_signal_connect (app, "activate", G_CALLBACK(activate), NULL);
  125 +
  126 + status = g_application_run (G_APPLICATION (app), argc, argv);
  127 + g_object_unref (app);
  128 +
  129 + g_message("rc=%d",status);
  130 + return status;
  131 +}
  132 +
... ...
src/pw3270/v3270ft/transfer.c 0 → 100644
... ... @@ -0,0 +1,165 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como transfer.c e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 + #include <pw3270/v3270.h>
  32 + #include "private.h"
  33 +
  34 +
  35 +/*--[ Statics ]--------------------------------------------------------------------------------------*/
  36 +
  37 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  38 +
  39 +static gboolean transfer_mapped(GtkWidget *widget, GdkEvent *event, v3270ft *ft) {
  40 + v3270ftprogress_set_transfer(widget,ft->active->data);
  41 + v3270ftprogress_start_transfer(widget);
  42 + return TRUE;
  43 +}
  44 +
  45 +static void transfer_complete(GtkWidget *progress, const gchar *primary, const gchar *secondary, v3270ft *ft) {
  46 +
  47 + debug("%s",__FUNCTION__);
  48 +
  49 + if(ft->active) {
  50 +
  51 + GList *next = g_list_next(ft->active);
  52 +
  53 + ft->files = g_list_delete_link(ft->files,ft->active);
  54 +
  55 + v3270ft_set_active(ft,next);
  56 + }
  57 +
  58 + if(ft->active) {
  59 +
  60 + v3270ftprogress_set_transfer(progress,ft->active->data);
  61 + v3270ftprogress_start_transfer(progress);
  62 +
  63 + } else {
  64 +
  65 + gtk_dialog_response(GTK_DIALOG(progress),GTK_RESPONSE_OK);
  66 +
  67 + }
  68 +
  69 +}
  70 +
  71 +static void transfer_failed(GtkWidget *progress, const gchar *primary, const gchar *secondary, v3270ft *ft) {
  72 +
  73 + GtkWidget * widget;
  74 + GtkWidget * message = gtk_message_dialog_new(GTK_WINDOW(progress),
  75 + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
  76 + GTK_MESSAGE_ERROR,
  77 + GTK_BUTTONS_NONE,
  78 + "%s",primary);
  79 +
  80 + widget = gtk_dialog_add_button(GTK_DIALOG(message), _("Ignore"), GTK_RESPONSE_OK);
  81 + gtk_widget_set_tooltip_markup(widget,_("Ignore the fail and remove the file from queue."));
  82 +
  83 + widget = gtk_dialog_add_button(GTK_DIALOG(message), _("Retry"), GTK_RESPONSE_APPLY);
  84 + gtk_widget_set_tooltip_markup(widget,_("Try again with the same file."));
  85 +
  86 + widget = gtk_dialog_add_button(GTK_DIALOG(message), _("Skip"), GTK_RESPONSE_ACCEPT);
  87 + gtk_widget_set_tooltip_markup(widget,_("Skip this transfer, keep the file on queue."));
  88 +
  89 + widget = gtk_dialog_add_button(GTK_DIALOG(message), _("Cancel"), GTK_RESPONSE_CANCEL);
  90 + gtk_widget_set_tooltip_markup(widget,_("Cancel transfer operation."));
  91 +
  92 + if(secondary && *secondary)
  93 + gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(message),"%s",secondary);
  94 +
  95 + gtk_window_set_title(GTK_WINDOW(message),v3270ft_get_remote_filename(GTK_WIDGET(ft)));
  96 +
  97 + switch(gtk_dialog_run(GTK_DIALOG(message))) {
  98 +
  99 + case GTK_RESPONSE_CANCEL: // Cancel
  100 + gtk_dialog_response(GTK_DIALOG(progress),GTK_RESPONSE_CANCEL);
  101 + break;
  102 +
  103 + case GTK_RESPONSE_APPLY: // Retry
  104 + v3270ftprogress_start_transfer(progress);
  105 + break;
  106 +
  107 + case GTK_RESPONSE_OK: // Remove from queue and start next one
  108 + transfer_complete(progress,primary,secondary,ft);
  109 + break;
  110 +
  111 + case GTK_RESPONSE_ACCEPT: // skip
  112 +
  113 + if(ft->active) {
  114 + v3270ft_set_active(ft,g_list_next(ft->active));
  115 + }
  116 +
  117 + if(ft->active) {
  118 +
  119 + v3270ftprogress_set_transfer(progress,ft->active->data);
  120 + v3270ftprogress_start_transfer(progress);
  121 +
  122 + } else {
  123 +
  124 + gtk_dialog_response(GTK_DIALOG(progress),GTK_RESPONSE_OK);
  125 +
  126 + }
  127 +
  128 + break;
  129 +
  130 + }
  131 +
  132 + gtk_widget_destroy(message);
  133 +
  134 +}
  135 +
  136 +gint v3270ft_transfer(GtkWidget *dialog, H3270 *session) {
  137 +
  138 + GtkWidget * progress = v3270ftprogress_new();
  139 + gint rc = GTK_RESPONSE_NONE;
  140 +
  141 + gtk_window_set_transient_for(GTK_WINDOW(progress),GTK_WINDOW(dialog));
  142 +// gtk_window_set_deletable(progress,FALSE);
  143 +
  144 + v3270ft_select_first(dialog);
  145 + v3270ftprogress_set_session(progress,session);
  146 +
  147 + g_signal_connect(progress,"success",G_CALLBACK(transfer_complete),dialog);
  148 + g_signal_connect(progress,"failed",G_CALLBACK(transfer_failed),dialog);
  149 + g_signal_connect(progress,"map-event",G_CALLBACK(transfer_mapped),dialog);
  150 +
  151 + // Executa diálogo de transferência
  152 + gtk_widget_show_all(progress);
  153 +
  154 + rc = gtk_dialog_run(GTK_DIALOG(progress));
  155 +
  156 + gtk_widget_destroy(progress);
  157 +
  158 + // Garante que vou sair com um arquivo selecionado.
  159 + if(!v3270ft_has_selected(dialog))
  160 + v3270ft_select_last(dialog);
  161 +
  162 + return rc;
  163 +}
  164 +
  165 +
... ...
src/pw3270/v3270ft/v3270ft.c 0 → 100644
... ... @@ -0,0 +1,594 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como v3270ft.c e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 +/**
  32 + * SECTION:v3270ft
  33 + * @Short_description: A 3270 file transfer dialog
  34 + * @Title: v3270ft
  35 + *
  36 + */
  37 +
  38 + #include <limits.h>
  39 + #include "private.h"
  40 +
  41 +/*--[ GTK Requires ]---------------------------------------------------------------------------------*/
  42 +
  43 + G_DEFINE_TYPE(v3270ft, v3270ft, GTK_TYPE_DIALOG);
  44 +
  45 +
  46 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  47 +
  48 +
  49 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  50 +
  51 +void v3270ft_remove_all(GtkWidget *widget) {
  52 +
  53 + v3270ft *dialog = GTK_V3270FT(widget);
  54 +
  55 + if(dialog->files) {
  56 + g_list_free_full(dialog->files,g_free);
  57 + dialog->files = NULL;
  58 + dialog->active = NULL;
  59 + }
  60 +
  61 + v3270ft_set_active(dialog,NULL);
  62 +
  63 +}
  64 +
  65 +static void v3270ft_finalize(GObject *object) {
  66 +
  67 + v3270ft *dialog = GTK_V3270FT(object);
  68 +
  69 + debug("%s",__FUNCTION__);
  70 +
  71 + if(dialog->files) {
  72 + g_list_free_full(dialog->files,g_free);
  73 + dialog->files = NULL;
  74 + dialog->active = NULL;
  75 + }
  76 +
  77 + G_OBJECT_CLASS(v3270ft_parent_class)->finalize(object);
  78 +
  79 +}
  80 +
  81 +static void v3270ft_class_init(v3270ftClass *klass) {
  82 +
  83 + debug("%s",__FUNCTION__);
  84 +
  85 + G_OBJECT_CLASS(klass)->finalize = v3270ft_finalize;
  86 +}
  87 +
  88 +GtkGrid * v3270ft_new_grid(void) {
  89 + GtkGrid * grid = GTK_GRID(gtk_grid_new());
  90 + gtk_grid_set_column_spacing(grid,4);
  91 + gtk_grid_set_row_spacing(grid,4);
  92 + gtk_container_set_border_width(GTK_CONTAINER(grid),3);
  93 + return grid;
  94 +}
  95 +
  96 +static void transfer_type_changed(GtkComboBox *widget, v3270ft *dialog) {
  97 +
  98 + gint selected = gtk_combo_box_get_active(widget);
  99 +
  100 + if(selected >= 0) {
  101 +
  102 + // Tem opção seleciona
  103 +
  104 + struct v3270ft_entry *entry = v3270ft_get_selected(dialog);
  105 + LIB3270_FT_OPTION opt = entry->options & ~(LIB3270_FT_OPTION_SEND|LIB3270_FT_OPTION_RECEIVE|LIB3270_FT_OPTION_ASCII|LIB3270_FT_OPTION_CRLF|LIB3270_FT_OPTION_REMAP);
  106 +
  107 + opt |= ft_type[selected].opt;
  108 +
  109 + entry->type = selected;
  110 + debug("Transfer type=%d opt=%08x last=%08x",selected,opt,entry->options);
  111 +
  112 + if(entry->options != opt) {
  113 + debug("Transfer type=%d opt=%08x",selected,opt);
  114 + v3270ft_set_options(GTK_WIDGET(dialog),opt);
  115 + }
  116 +
  117 + }
  118 +
  119 + v3270ft_update_actions(dialog);
  120 +
  121 +}
  122 +
  123 +static void local_file_changed(GtkEntry *widget, v3270ft *dialog) {
  124 +
  125 + struct v3270ft_entry *entry = v3270ft_get_selected(dialog);
  126 +
  127 + if(entry) {
  128 + strncpy(entry->local,gtk_entry_get_text(widget),sizeof(entry->local));
  129 + v3270ft_update_actions(dialog);
  130 + }
  131 +
  132 +}
  133 +
  134 +static void remote_file_changed(GtkEntry *widget, v3270ft *dialog) {
  135 +
  136 + struct v3270ft_entry *entry = v3270ft_get_selected(dialog);
  137 +
  138 + if(entry) {
  139 + strncpy(entry->remote,gtk_entry_get_text(widget),sizeof(entry->remote));
  140 + v3270ft_update_actions(dialog);
  141 + }
  142 +
  143 +}
  144 +
  145 +static void start_transfer(GtkButton *button, v3270ft *dialog) {
  146 + gtk_dialog_response(GTK_DIALOG(dialog),GTK_RESPONSE_APPLY);
  147 +}
  148 +
  149 +static void select_first(GtkButton *button, v3270ft *dialog) {
  150 + v3270ft_select_first(GTK_WIDGET(dialog));
  151 +}
  152 +
  153 +static void select_last(GtkButton *button, v3270ft *dialog) {
  154 + v3270ft_select_last(GTK_WIDGET(dialog));
  155 +}
  156 +
  157 +static void select_previous(GtkButton *button, v3270ft *dialog) {
  158 + v3270ft_select_previous(GTK_WIDGET(dialog));
  159 +}
  160 +
  161 +static void select_next(GtkButton *button, v3270ft *dialog) {
  162 + v3270ft_select_next(GTK_WIDGET(dialog));
  163 +}
  164 +
  165 +static void insert_file(GtkButton *button, v3270ft *dialog) {
  166 + dialog->files = g_list_append(dialog->files,v3270ft_create_entry());
  167 + v3270ft_select_last(GTK_WIDGET(dialog));
  168 +}
  169 +
  170 +static void remove_file(GtkButton *button, v3270ft *dialog) {
  171 +
  172 + GList *next = dialog->active->next;
  173 +
  174 + debug("%s",__FUNCTION__);
  175 +
  176 + dialog->files = g_list_delete_link(dialog->files,dialog->active);
  177 +
  178 + if(next) {
  179 +
  180 + v3270ft_set_active(dialog,next);
  181 +
  182 + } else {
  183 +
  184 + if(!dialog->files) {
  185 + dialog->files = g_list_append(dialog->files,v3270ft_create_entry());
  186 + }
  187 +
  188 + v3270ft_select_last(GTK_WIDGET(dialog));
  189 + }
  190 +
  191 +}
  192 +
  193 +static void load_file(GtkButton *button, v3270ft *dialog) {
  194 +
  195 + gchar * filename = v3270ft_select_file(dialog, _("Load queue from file"), _("Load"), GTK_FILE_CHOOSER_ACTION_OPEN, NULL);
  196 +
  197 + if(filename) {
  198 + v3270ft_load(GTK_WIDGET(dialog),filename);
  199 + g_free(filename);
  200 + v3270ft_select_last(GTK_WIDGET(dialog));
  201 + }
  202 +
  203 +
  204 +}
  205 +
  206 +static void save_file(GtkButton *button, v3270ft *dialog) {
  207 +
  208 + gchar * filename = v3270ft_select_file(dialog, _("Save queue to file"), _("Save"), GTK_FILE_CHOOSER_ACTION_SAVE, NULL);
  209 +
  210 + if(filename) {
  211 + v3270ft_save(GTK_WIDGET(dialog),filename);
  212 + g_free(filename);
  213 + }
  214 +
  215 +}
  216 +
  217 +static void option_toggled(GtkToggleButton *togglebutton, v3270ft *ft) {
  218 +
  219 + struct v3270ft_entry * entry = v3270ft_get_selected(ft);
  220 +
  221 + if(entry) {
  222 +
  223 + LIB3270_FT_OPTION newoption = entry->options;
  224 + int id;
  225 +
  226 + // Reseta todas as opções
  227 + for(id=0;id<NUM_OPTIONS_WIDGETS;id++) {
  228 + newoption &= ~ft_option[id].opt;
  229 + }
  230 +
  231 + // Ativo apenas as opções selecionadas
  232 + for(id=0;id<NUM_OPTIONS_WIDGETS;id++) {
  233 +
  234 + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ft->opt[id]))) {
  235 + newoption |= ft_option[id].opt;
  236 + }
  237 +
  238 + }
  239 +
  240 + if(entry->options != newoption) {
  241 + debug("Options: %08lx -> %08lx",(unsigned long) entry->options, (unsigned long) newoption);
  242 + entry->options = newoption;
  243 + }
  244 +
  245 + }
  246 +
  247 +}
  248 +
  249 +static void spin_changed(GtkWidget *button, v3270ft *ft) {
  250 +
  251 + int f;
  252 + struct v3270ft_entry * entry = v3270ft_get_selected(ft);
  253 +
  254 + if(entry) {
  255 + for(f=0;f < LIB3270_FT_VALUE_COUNT;f++) {
  256 +
  257 + if(button == ft->value[f]) {
  258 + v3270ft_get_selected(ft)->value[f] = (guint) gtk_spin_button_get_value(GTK_SPIN_BUTTON(button));
  259 + return;
  260 + }
  261 +
  262 + }
  263 + }
  264 +
  265 +}
  266 +
  267 +static gboolean spin_format(GtkSpinButton *spin, gpointer data) {
  268 +
  269 + GtkAdjustment * adjustment = gtk_spin_button_get_adjustment (spin);
  270 + int value = (int)gtk_adjustment_get_value(adjustment);
  271 +
  272 + if(value < 1) {
  273 + gtk_entry_set_text(GTK_ENTRY(spin), "");
  274 + } else {
  275 + gchar * text = g_strdup_printf ("%d", value);
  276 + gtk_entry_set_text (GTK_ENTRY(spin), text);
  277 + g_free (text);
  278 + }
  279 +
  280 + return TRUE;
  281 +}
  282 +
  283 +void icon_press(GtkEntry *entry, GtkEntryIconPosition icon_pos, GdkEvent *event, v3270ft *dialog) {
  284 +
  285 + gchar *filename = v3270ft_select_file(dialog, _("Select local file"), _("Select"), GTK_FILE_CHOOSER_ACTION_OPEN, gtk_entry_get_text(dialog->local));
  286 +
  287 + if(filename) {
  288 +
  289 + gtk_entry_set_text(dialog->local,filename);
  290 +
  291 + g_free(filename);
  292 + }
  293 +
  294 +}
  295 +
  296 +static void drag_data_received(GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint info, guint time) {
  297 +
  298 + gtk_drag_finish(context, v3270ft_append_selection(widget, data) > 0, FALSE, time);
  299 +
  300 +}
  301 +
  302 +static void v3270ft_init(v3270ft *dialog) {
  303 +
  304 + static const gchar * label[] = {
  305 + N_( "_Operation:" ),
  306 + N_( "_Local file:"),
  307 + N_( "_Remote file:")
  308 + };
  309 +
  310 + static const gchar * frame[] = {
  311 + N_("Transfer options"),
  312 + N_("Record format"),
  313 + N_("Space allocation units")
  314 + };
  315 +
  316 + int f;
  317 + GtkGrid * grid;
  318 + GtkTreeModel * model;
  319 + GtkCellRenderer * renderer;
  320 + GtkWidget * widget;
  321 + GtkBox * box = GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog)));
  322 + GtkWidget * entry[G_N_ELEMENTS(label)];
  323 +
  324 + // Initialize
  325 + gtk_window_set_title(GTK_WINDOW(dialog),_( "3270 File transfer"));
  326 + gtk_window_set_resizable(GTK_WINDOW(dialog),FALSE);
  327 + gtk_container_set_border_width(GTK_CONTAINER(box),3);
  328 + dialog->files = dialog->active = g_list_append(NULL,v3270ft_create_entry());
  329 +
  330 + // Buttons
  331 + // https://developer.gnome.org/icon-naming-spec/
  332 + static const struct _action {
  333 + FT_BUTTON id;
  334 + gboolean start;
  335 + const gchar * name;
  336 + const gchar * tooltip;
  337 + GCallback callback;
  338 + } action[FT_BUTTON_COUNT] = {
  339 +
  340 + {
  341 + FT_BUTTON_START_TRANSFER,
  342 + FALSE,
  343 + "network-server",
  344 + N_("Start file transfer"),
  345 + G_CALLBACK(start_transfer)
  346 + },
  347 + {
  348 + FT_BUTTON_GO_LAST,
  349 + FALSE,
  350 + "go-last",
  351 + N_("Select last file"),
  352 + G_CALLBACK(select_last)
  353 + },
  354 + {
  355 + FT_BUTTON_GO_NEXT,
  356 + FALSE,
  357 + "go-next",
  358 + N_("Select next file"),
  359 + G_CALLBACK(select_next)
  360 + },
  361 + {
  362 + FT_BUTTON_GO_PREVIOUS,
  363 + FALSE,
  364 + "go-previous",
  365 + N_("Select previous file"),
  366 + G_CALLBACK(select_previous)
  367 + },
  368 + {
  369 + FT_BUTTON_GO_FIRST,
  370 + FALSE,
  371 + "go-first",
  372 + N_("Select first file"),
  373 + G_CALLBACK(select_first)
  374 + },
  375 +
  376 + {
  377 + FT_BUTTON_LOAD_LIST,
  378 + TRUE,
  379 + "document-open",
  380 + N_("Get transfer queue from an external XML file"),
  381 + G_CALLBACK(load_file)
  382 + },
  383 +
  384 + {
  385 + FT_BUTTON_SAVE_LIST,
  386 + TRUE,
  387 + "document-save",
  388 + N_("Save transfer queue to an external XML file"),
  389 + G_CALLBACK(save_file)
  390 + },
  391 + {
  392 + FT_BUTTON_INSERT_FILE,
  393 + TRUE,
  394 + "list-add",
  395 + N_("Insert new file in the transfer queue"),
  396 + G_CALLBACK(insert_file)
  397 + },
  398 + {
  399 + FT_BUTTON_REMOVE_FILE,
  400 + TRUE,
  401 + "list-remove",
  402 + N_("Remove selected file from the transfer queue"),
  403 + G_CALLBACK(remove_file)
  404 + },
  405 + };
  406 +
  407 + widget = gtk_dialog_get_header_bar(GTK_DIALOG(dialog));
  408 + for(f=0;f<G_N_ELEMENTS(action);f++) {
  409 +
  410 + GtkWidget *button = gtk_button_new_from_icon_name(action[f].name,GTK_ICON_SIZE_BUTTON);
  411 +
  412 + gtk_widget_set_tooltip_markup(button,gettext(action[f].tooltip));
  413 +
  414 + if(action[f].start) {
  415 + gtk_header_bar_pack_start(GTK_HEADER_BAR(widget),button);
  416 + } else {
  417 + gtk_header_bar_pack_end(GTK_HEADER_BAR(widget),button);
  418 + }
  419 +
  420 + g_signal_connect(button,"clicked",action[f].callback,dialog);
  421 +
  422 + dialog->button[action[f].id] = button;
  423 + gtk_widget_set_sensitive(button,FALSE);
  424 +
  425 + }
  426 +
  427 + gtk_widget_set_sensitive(dialog->button[FT_BUTTON_LOAD_LIST],TRUE);
  428 + gtk_widget_set_sensitive(dialog->button[FT_BUTTON_REMOVE_FILE],TRUE);
  429 +
  430 + // Top level
  431 + grid = v3270ft_new_grid();
  432 + gtk_box_pack_start(box,GTK_WIDGET(grid),TRUE,TRUE,2);
  433 +
  434 + // Transfer type combo
  435 + model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_ULONG);
  436 + renderer = gtk_cell_renderer_text_new();
  437 +
  438 + widget = gtk_combo_box_new_with_model(model);
  439 + g_signal_connect(G_OBJECT(widget),"changed",G_CALLBACK(transfer_type_changed),dialog);
  440 + entry[0] = GTK_WIDGET(widget);
  441 +
  442 + dialog->type = GTK_COMBO_BOX(widget);
  443 + gtk_grid_attach(grid,GTK_WIDGET(widget),1,0,1,1);
  444 + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, TRUE);
  445 + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget), renderer, "text", 0, NULL);
  446 +
  447 + for(f=0;f < NUM_TYPES;f++) {
  448 +
  449 + GtkTreeIter iter;
  450 +
  451 + gtk_list_store_append((GtkListStore *) model,&iter);
  452 + gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(ft_type[f].label),-1);
  453 +
  454 + if(!f) {
  455 + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widget),&iter);
  456 + }
  457 + }
  458 +
  459 + // File selection box
  460 + dialog->local = GTK_ENTRY(gtk_entry_new());
  461 + entry[1] = GTK_WIDGET(dialog->local);
  462 +
  463 + gtk_widget_set_hexpand(GTK_WIDGET(dialog->local),TRUE);
  464 + gtk_entry_set_icon_from_icon_name(dialog->local,GTK_ENTRY_ICON_SECONDARY,"document-open");
  465 + gtk_entry_set_icon_activatable(dialog->local,GTK_ENTRY_ICON_SECONDARY,TRUE);
  466 + gtk_entry_set_icon_tooltip_text(dialog->local,GTK_ENTRY_ICON_SECONDARY,_("Select file"));
  467 +
  468 + g_signal_connect(G_OBJECT(dialog->local),"icon-press",G_CALLBACK(icon_press),dialog);
  469 + g_signal_connect(G_OBJECT(dialog->local),"changed",G_CALLBACK(local_file_changed),dialog);
  470 +
  471 + gtk_entry_set_width_chars(dialog->local,60);
  472 + gtk_entry_set_max_length(dialog->local,PATH_MAX);
  473 + gtk_grid_attach(grid,GTK_WIDGET(dialog->local),1,1,1,1);
  474 +
  475 + dialog->remote = GTK_ENTRY(gtk_entry_new());
  476 + entry[2] = GTK_WIDGET(dialog->remote);
  477 +
  478 + gtk_widget_set_hexpand(GTK_WIDGET(dialog->remote),TRUE);
  479 +
  480 + g_signal_connect(G_OBJECT(dialog->remote),"changed",G_CALLBACK(remote_file_changed),dialog);
  481 +
  482 + gtk_entry_set_width_chars(dialog->remote,60);
  483 + gtk_entry_set_max_length(dialog->remote,PATH_MAX);
  484 + gtk_grid_attach(grid,GTK_WIDGET(dialog->remote),1,2,1,1);
  485 +
  486 + for(f=0;f<G_N_ELEMENTS(label);f++) {
  487 + GtkWidget * widget = gtk_label_new_with_mnemonic(gettext(label[f]));
  488 + gtk_widget_set_halign(widget,GTK_ALIGN_START);
  489 + gtk_widget_set_valign(widget,GTK_ALIGN_CENTER);
  490 + gtk_grid_attach(grid,GTK_WIDGET(widget),0,f,1,1);
  491 + gtk_label_set_mnemonic_widget(GTK_LABEL(widget),entry[f]);
  492 + }
  493 +
  494 + // Transfer options
  495 + widget = gtk_frame_new(gettext(frame[0]));
  496 + grid = v3270ft_new_grid();
  497 + gtk_grid_set_column_homogeneous(grid,TRUE);
  498 + gtk_container_add(GTK_CONTAINER(widget),GTK_WIDGET(grid));
  499 + gtk_box_pack_start(box,widget,FALSE,TRUE,2);
  500 +
  501 + for(f=0;f<4;f++) {
  502 +
  503 + dialog->opt[f] = widget = gtk_check_button_new_with_mnemonic(gettext(ft_option[f].label));
  504 + gtk_widget_set_tooltip_markup(widget,gettext(ft_option[f].tooltip));
  505 + gtk_grid_attach(grid,widget,f&1,f/2,1,1);
  506 + g_signal_connect(G_OBJECT(widget),"toggled",G_CALLBACK(option_toggled),dialog);
  507 +
  508 + }
  509 +
  510 + // Formats
  511 + grid = v3270ft_new_grid();
  512 + gtk_grid_set_column_homogeneous(grid,TRUE);
  513 + gtk_box_pack_start(box,GTK_WIDGET(grid),FALSE,TRUE,2);
  514 +
  515 + // Record & Space allocation
  516 + for(f=0;f<2;f++) {
  517 + int i;
  518 + GtkBox * box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL,2));
  519 + GSList * group = NULL;
  520 +
  521 + dialog->radio[f] = gtk_frame_new(gettext(frame[f+1]));
  522 + gtk_container_add(GTK_CONTAINER(dialog->radio[f]),GTK_WIDGET(box));
  523 + gtk_container_add(GTK_CONTAINER(grid),dialog->radio[f]);
  524 +
  525 + for(i=0;i<4;i++) {
  526 +
  527 + int ix = ((f+1)*4)+i;
  528 +
  529 + dialog->opt[ix] = widget = gtk_radio_button_new_with_label(group,gettext(ft_option[ix].label));
  530 +
  531 + g_signal_connect(G_OBJECT(widget),"toggled",G_CALLBACK(option_toggled),dialog);
  532 + gtk_widget_set_tooltip_markup(widget,gettext(ft_option[ix].tooltip));
  533 + gtk_box_pack_start(box,widget,FALSE,FALSE,2);
  534 + group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(widget));
  535 +
  536 + }
  537 +
  538 + }
  539 +
  540 + // Values
  541 + grid = v3270ft_new_grid();
  542 + gtk_grid_set_column_homogeneous(grid,TRUE);
  543 + gtk_box_pack_start(box,GTK_WIDGET(grid),FALSE,TRUE,2);
  544 +
  545 + for(f=0;f < LIB3270_FT_VALUE_COUNT;f++) {
  546 +
  547 + GtkWidget * label = gtk_label_new_with_mnemonic(gettext(ft_value[f].label));
  548 + gtk_widget_set_halign(label,GTK_ALIGN_START);
  549 + gtk_widget_set_valign(label,GTK_ALIGN_CENTER);
  550 +
  551 + widget = gtk_spin_button_new_with_range(ft_value[f].minval,ft_value[f].maxval,1);
  552 + g_signal_connect(G_OBJECT(widget),"value-changed",G_CALLBACK(spin_changed),dialog);
  553 + g_signal_connect(G_OBJECT(widget),"output",G_CALLBACK(spin_format),dialog);
  554 +
  555 + gtk_widget_set_tooltip_markup(widget,gettext(ft_value[f].tooltip));
  556 + gtk_widget_set_tooltip_markup(label,gettext(ft_value[f].tooltip));
  557 +
  558 + gtk_label_set_mnemonic_widget(GTK_LABEL(label),widget);
  559 +
  560 + gtk_grid_attach(grid,label,(f&1)*2,f/2,1,1);
  561 + gtk_grid_attach(grid,widget,((f&1)*2)+1,f/2,1,1);
  562 +
  563 + dialog->value[f] = widget;
  564 +
  565 + }
  566 +
  567 + // Setup drag & drop
  568 + // http://ftp.math.utah.edu/u/ma/hohn/linux/gnome/developer.gnome.org/doc/tutorials/gnome-libs/x1003.html
  569 + static const GtkTargetEntry targets[] = {
  570 + { "text/plain", GTK_TARGET_OTHER_APP, 0 }
  571 + };
  572 +
  573 + gtk_drag_dest_set(GTK_WIDGET(dialog),GTK_DEST_DEFAULT_ALL,targets,G_N_ELEMENTS(targets),GDK_ACTION_COPY);
  574 + // g_signal_connect(dialog,"drag-drop",G_CALLBACK(drag_drop),dialog);
  575 + g_signal_connect(dialog,"drag-data-received",G_CALLBACK(drag_data_received),dialog);
  576 +
  577 +
  578 + // Finish setup
  579 + v3270ft_select_last(GTK_WIDGET(dialog));
  580 +
  581 +
  582 +}
  583 +
  584 +/**
  585 + * v3270ft_dialog_new:
  586 + *
  587 + * Creates a new #v3270ft.
  588 + *
  589 + * Returns: a new #v3270ft.
  590 + */
  591 +GtkWidget * v3270ft_new(void) {
  592 + return GTK_WIDGET(g_object_new(GTK_TYPE_V3270FT, "use-header-bar", (gint) 1, NULL));
  593 +}
  594 +
... ...
src/pw3270/v3270ft/v3270ftprogress.c 0 → 100644
... ... @@ -0,0 +1,811 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como v3270ft.c e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 +/**
  32 + * SECTION:v3270ftprogress
  33 + * @Short_description: A 3270 file transfer progress dialog
  34 + * @Title: v3270ftprogress
  35 + *
  36 + */
  37 +
  38 + #include "private.h"
  39 + #include "marshal.h"
  40 + #include <lib3270/filetransfer.h>
  41 +
  42 +/*--[ GTK Requires ]---------------------------------------------------------------------------------*/
  43 +
  44 + G_DEFINE_TYPE(v3270ftprogress, v3270ftprogress, GTK_TYPE_DIALOG);
  45 +
  46 +
  47 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  48 +
  49 +guint v3270ftprogress_signal[V3270FTPROGRESS_SIGNAL_COUNT] = { 0 };
  50 +
  51 +static const struct _field {
  52 +
  53 + const gchar *label;
  54 + const gchar *tooltip;
  55 +
  56 +} field[PROGRESS_FIELD_COUNT] = {
  57 +
  58 + {
  59 + N_("Local:"),
  60 + N_("Path and name of the local file")
  61 + },
  62 +
  63 + {
  64 + N_("Remote:"),
  65 + N_("The name of the file in the host")
  66 + },
  67 +
  68 + {
  69 + N_("Total:"),
  70 + N_("Total bytes to transfer")
  71 + },
  72 +
  73 + {
  74 + N_("Current:"),
  75 + N_("Current transfer position")
  76 + },
  77 +
  78 + {
  79 + N_("Speed:"),
  80 + N_("Transfer speed")
  81 + },
  82 +
  83 + {
  84 + N_("ETA:"),
  85 + N_("Estimated transfer arrival")
  86 + },
  87 +
  88 +};
  89 +
  90 +// http://www3.rocketsoftware.com/bluezone/help/v42/en/bz/DISPLAY/IND$FILE/IND$FILE_Technical_Reference.htm
  91 +
  92 +static const struct _ftmsg {
  93 +
  94 + const char * id;
  95 + unsigned char failed;
  96 + const char * text;
  97 +
  98 +} ftmsg[] = {
  99 +
  100 + {
  101 + "TRANS00",
  102 + TRUE, // - Error in file transfer: file transfer canceled
  103 + N_("An error occurred in the file transfer, which may be an error in the data being transferred, or an unidentified system error.")
  104 + },
  105 +
  106 + {
  107 + "TRANS03",
  108 + FALSE, // - File transfer complete
  109 + N_("The file transfer operation has been successfully completed.")
  110 + },
  111 +
  112 + {
  113 + "TRANS04",
  114 + FALSE, // - File transfer complete with records segmented
  115 + N_("The file transfer operation has been completed, and any record greater than the logical record length (LRECL) of the file being appended has been divided and becomes multiple records.")
  116 + },
  117 +
  118 + {
  119 + "TRANS05",
  120 + TRUE, // - Personal computer filespec incorrect: file transfer canceled
  121 + N_("An error exists in the PC's file name.")
  122 + },
  123 +
  124 + {
  125 + "TRANS06",
  126 + TRUE, // - Command incomplete: file transfer canceled
  127 + N_("You did not enter the required parameters after a SEND or RECEIVE command.")
  128 + },
  129 +
  130 + {
  131 + "TRANS13",
  132 + TRUE, // - Error writing file to host: file transfer canceled
  133 + N_("The host program has detected an error in the file data during a RECEIVE operation.")
  134 + },
  135 +
  136 + {
  137 + "TRANS14",
  138 + TRUE, // - Error reading file from host: file transfer canceled
  139 + N_("The host program has detected an error in the file data during a RECEIVE operation.")
  140 + },
  141 +
  142 + {
  143 + "TRANS15",
  144 + TRUE, // - Required host storage unavailable: file transfer canceled
  145 + N_("You need 30 KB of main storage (not disk space) on the host for the file transfer, in addition to the host requirement.")
  146 + },
  147 +
  148 + {
  149 + "TRANS16",
  150 + TRUE, // - Incorrect request code: file transfer canceled
  151 + N_("An invalid SEND or RECEIVE parameter was sent to the host.")
  152 + },
  153 +
  154 + {
  155 + "TRANS17",
  156 + TRUE,
  157 + NULL
  158 + },
  159 +
  160 + /*
  161 + {
  162 + "TRANS17",
  163 + TRUE, // - Missing or incorrect TSO data set name: file transfer canceled
  164 + N_("You did not specify the TSO data set name, or the specified TSO data set name is not a sequential or partitioned data set.")
  165 + },
  166 +
  167 + {
  168 + "TRANS17",
  169 + TRUE, // - Invalid file name: file transfer canceled
  170 + N_("The command that started the file transfer specified a file name that is not a valid file name for the host. Correct CICS file names must be 1 to 8 characters, composed of letters and numbers.")
  171 + },
  172 +
  173 + {
  174 + "TRANS17",
  175 + TRUE, // - Missing or incorrect CMS data set name: file transfer canceled
  176 + N_("You did not specify the CMS data set name, or the specified CMS data set name is incorrect.")
  177 + },
  178 +*/
  179 +
  180 + {
  181 + "TRANS18",
  182 + TRUE, // - Incorrect option specified: file transfer canceled
  183 + N_("You specified an option that is invalid.")
  184 + },
  185 +
  186 + {
  187 + "TRANS19",
  188 + TRUE, // - Error while reading or writing to host disk: file transfer canceled
  189 + N_("There is not enough space available for data on the host.")
  190 + },
  191 +
  192 + {
  193 + "TRANS28",
  194 + TRUE, // - Invalid option xxxxxxxx: file transfer canceled
  195 + N_("You selected an option that is either not recognized, is specified as a positional keyword, or has an associated value that is incorrect.")
  196 + },
  197 +
  198 + {
  199 + "TRANS29",
  200 + TRUE, // - Invalid option xxxxxxxx with RECEIVE: file transfer canceled
  201 + N_("You selected an option that is not valid with RECEIVE, but can be used with SEND.")
  202 + },
  203 +
  204 + {
  205 + "TRANS30",
  206 + TRUE, // - Invalid option xxxxxxxx with APPEND: file transfer canceled
  207 + N_("You selected an option that is not valid with APPEND, but otherwise may be used.")
  208 + },
  209 +
  210 + {
  211 + "TRANS31",
  212 + TRUE, // - Invalid option xxxxxxxx without SPACE: file transfer canceled
  213 + N_("You selected an option that can only be used if SPACE is also specified.")
  214 + },
  215 +
  216 + {
  217 + "TRANS32",
  218 + TRUE, // - Invalid option xxxxxxxx with PDS: file transfer canceled
  219 + N_("You selected an option that is invalid with a host-partitioned data set.")
  220 + },
  221 +
  222 + {
  223 + "TRANS33",
  224 + TRUE, // - Only one of TRACKS, CYLINDERS, AVBLOCK allowed: file transfer canceled
  225 + N_("SPACE can be specified in units of TRACKS, CYLINDERS, or AVBLOCK, and only one option can be used.")
  226 + },
  227 +
  228 + {
  229 + "TRANS34",
  230 + TRUE, // - CMS file not found: file transfer canceled
  231 + N_("You did not specify an existing CMS file for RECEIVE.")
  232 + },
  233 +
  234 + {
  235 + "TRANS35",
  236 + TRUE, // - CMS disk is read-only: file transfer canceled
  237 + N_("You specified a CMS file mode for the SEND key that does not allow write access.")
  238 + },
  239 +
  240 + {
  241 + "TRANS36",
  242 + TRUE, // - CMS disk is not accessed: file transfer canceled
  243 + N_("You specified a CMS file mode that is not in the CMS search order.")
  244 + },
  245 +
  246 + {
  247 + "TRANS37",
  248 + TRUE, // - CMS disk is full: file transfer canceled
  249 + N_("The CMS disk is full, or the maximum number of files on the minidisk (3400) has been reached, or the maximum number of data blocks per file (16060) has been reached.")
  250 + },
  251 +
  252 + {
  253 + "TRANS99",
  254 + TRUE, // - Host program error code xxxxxxxxxx: file transfer canceled
  255 + N_("This is a host program error.")
  256 + },
  257 +
  258 +};
  259 +
  260 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  261 +
  262 +static void stop_pulse(void *widget) {
  263 +
  264 + v3270ftprogress * dialog = GTK_V3270FTPROGRESS(widget);
  265 +
  266 + if(dialog->pulse) {
  267 + g_source_destroy(dialog->pulse);
  268 + dialog->pulse = NULL;
  269 + }
  270 +
  271 +}
  272 +
  273 +static void stop_timer(void *widget) {
  274 +
  275 + v3270ftprogress * dialog = GTK_V3270FTPROGRESS(widget);
  276 +
  277 + if(dialog->timer) {
  278 + g_source_destroy(dialog->timer);
  279 + dialog->timer = NULL;
  280 + }
  281 +
  282 +}
  283 +
  284 +gboolean v3270ftprogress_cleanup(v3270ftprogress * dialog) {
  285 +
  286 + if(dialog->session) {
  287 + debug("%s: FT session was destroyed",__FUNCTION__);
  288 + lib3270_ft_set_user_data(dialog->session,NULL);
  289 + lib3270_ft_destroy(dialog->session);
  290 + }
  291 +
  292 + return FALSE;
  293 +
  294 +}
  295 +
  296 +static void v3270ftprogress_finalize(GObject *object) {
  297 +
  298 + v3270ftprogress * dialog = GTK_V3270FTPROGRESS(object);
  299 +
  300 + debug("%s",__FUNCTION__);
  301 +
  302 + stop_pulse(object);
  303 + stop_timer(object);
  304 +
  305 + // Tem sessão, removo do objeto para evitar a geração de sinais e destruo.
  306 + v3270ftprogress_cleanup(dialog);
  307 + dialog->session = NULL;
  308 +
  309 + G_OBJECT_CLASS(v3270ftprogress_parent_class)->finalize(object);
  310 +
  311 +}
  312 +
  313 +static void dialog_response(GtkDialog *widget, gint response_id) {
  314 +
  315 + v3270ftprogress * dialog = GTK_V3270FTPROGRESS(widget);
  316 + GtkDialogClass * klass = GTK_DIALOG_CLASS(v3270ftprogress_parent_class);
  317 +
  318 + debug("%s(%d)",__FUNCTION__,(int) response_id);
  319 +
  320 + if(dialog->session) {
  321 +
  322 + // Removo do objeto para evitar a geração de sinais e destruo.
  323 + lib3270_ft_set_user_data(dialog->session,NULL);
  324 + lib3270_ft_destroy(dialog->session);
  325 +
  326 + }
  327 +
  328 + if(klass->response)
  329 + klass->response(widget,response_id);
  330 +
  331 +}
  332 +
  333 +static void dialog_close(GtkDialog *object) {
  334 +
  335 + v3270ftprogress * dialog = GTK_V3270FTPROGRESS(object);
  336 +
  337 + debug("%s",__FUNCTION__);
  338 +
  339 + // Se tem sessão e conseguiu cancelar.
  340 + if(dialog->session && lib3270_ft_cancel(dialog->session,0) == 0)
  341 + return;
  342 +
  343 + GTK_DIALOG_CLASS(v3270ftprogress_parent_class)->close(object);
  344 +
  345 +}
  346 +
  347 +static void v3270ftprogress_class_init(v3270ftprogressClass *klass) {
  348 +
  349 + GObjectClass * gobject_class = G_OBJECT_CLASS(klass);
  350 + GtkDialogClass * dialog_class = GTK_DIALOG_CLASS(klass);
  351 +// GtkWidgetClass * widget_class = GTK_WIDGET_CLASS(klass);
  352 +
  353 + gobject_class->finalize = v3270ftprogress_finalize;
  354 + dialog_class->response = dialog_response;
  355 + dialog_class->close = dialog_close;
  356 +
  357 + v3270ftprogress_signal[V3270FTPROGRESS_SIGNAL_SUCCESS] =
  358 + g_signal_new( "success",
  359 + G_OBJECT_CLASS_TYPE (gobject_class),
  360 + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
  361 + 0,
  362 + NULL, NULL,
  363 + v3270ft_VOID__POINTER_POINTER,
  364 + G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
  365 +
  366 + v3270ftprogress_signal[V3270FTPROGRESS_SIGNAL_FAILED] =
  367 + g_signal_new( "failed",
  368 + G_OBJECT_CLASS_TYPE (gobject_class),
  369 + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
  370 + 0,
  371 + NULL, NULL,
  372 + v3270ft_VOID__POINTER_POINTER,
  373 + G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
  374 +
  375 +
  376 +}
  377 +
  378 +static GtkWidget * create_text(guint width) {
  379 +
  380 + GtkWidget * widget = gtk_entry_new();
  381 +
  382 + gtk_entry_set_width_chars(GTK_ENTRY(widget),width);
  383 + gtk_editable_set_editable(GTK_EDITABLE(widget),FALSE);
  384 +
  385 + gtk_widget_set_halign(GTK_WIDGET(widget),GTK_ALIGN_START);
  386 + gtk_widget_set_valign(GTK_WIDGET(widget),GTK_ALIGN_CENTER);
  387 +
  388 + return GTK_WIDGET(widget);
  389 +}
  390 +
  391 +static GtkWidget * create_label(int id, GtkWidget *entry) {
  392 +
  393 + GtkWidget * widget = gtk_label_new(gettext(field[id].label));
  394 +
  395 + gtk_widget_set_tooltip_markup(widget,field[id].tooltip);
  396 + gtk_widget_set_tooltip_markup(entry,field[id].tooltip);
  397 +
  398 + gtk_widget_set_halign(widget,GTK_ALIGN_START);
  399 + gtk_widget_set_valign(widget,GTK_ALIGN_CENTER);
  400 +
  401 + return widget;
  402 +}
  403 +
  404 +static void cancel_clicked(GtkButton *button,v3270ftprogress *dialog) {
  405 +
  406 + debug("%s",__FUNCTION__);
  407 +
  408 + if(dialog->session) {
  409 + lib3270_ft_cancel(dialog->session,1);
  410 + }
  411 +}
  412 +
  413 +
  414 +static void v3270ftprogress_init(v3270ftprogress *dialog) {
  415 +
  416 + int f;
  417 + GtkWidget * frame;
  418 + GtkGrid * grid;
  419 + GtkWidget * widget;
  420 + GtkBox * box = GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog)));
  421 +
  422 + // Initialize
  423 + gtk_container_set_border_width(GTK_CONTAINER(box),3);
  424 + gtk_window_set_title(GTK_WINDOW(dialog),_( "3270 File transfer"));
  425 + gtk_window_set_resizable(GTK_WINDOW(dialog),FALSE);
  426 +
  427 + // Information box
  428 + frame = gtk_frame_new( _( "Current file" ) );
  429 + gtk_box_pack_start(box,GTK_WIDGET(frame),FALSE,TRUE,2);
  430 + grid = v3270ft_new_grid();
  431 + gtk_container_add(GTK_CONTAINER(frame),GTK_WIDGET(grid));
  432 +
  433 + for(f=0;f<2;f++) {
  434 +
  435 + dialog->info[f] = GTK_ENTRY(widget = create_text(50));
  436 + gtk_widget_set_hexpand(widget,TRUE);
  437 +
  438 + gtk_grid_attach(grid,create_label(f,widget),0,f,1,1);
  439 +
  440 + gtk_grid_attach(grid,widget,1,f,1,1);
  441 +
  442 + }
  443 +
  444 + // Progress box
  445 + frame = gtk_frame_new( _( "Progress" ) );
  446 + gtk_box_pack_start(box,GTK_WIDGET(frame),FALSE,TRUE,2);
  447 + grid = v3270ft_new_grid();
  448 + gtk_container_add(GTK_CONTAINER(frame),GTK_WIDGET(grid));
  449 +
  450 + for(f=0;f<4;f++) {
  451 +
  452 + dialog->info[f+2] = GTK_ENTRY(widget = create_text(15));
  453 + gtk_entry_set_alignment(GTK_ENTRY(widget),1);
  454 + gtk_widget_set_hexpand(widget,TRUE);
  455 +
  456 + gtk_grid_attach(grid,create_label(f+2,widget),(f&1)*2,f/2,1,1);
  457 +
  458 + gtk_grid_attach(grid,widget,((f&1)*2)+1,f/2,1,1);
  459 +
  460 + }
  461 +
  462 + dialog->progress = GTK_PROGRESS_BAR(widget = gtk_progress_bar_new());
  463 + gtk_widget_set_hexpand(widget,TRUE);
  464 + gtk_grid_attach(grid,widget,0,2,4,1);
  465 +
  466 + // Set defaults.
  467 + v3270ftprogress_set_header(GTK_WIDGET(dialog),_("No active transfer"));
  468 +
  469 +
  470 + // Buttons
  471 + frame = gtk_dialog_get_header_bar(GTK_DIALOG(dialog));
  472 +
  473 + // https://developer.gnome.org/icon-naming-spec/
  474 + widget = gtk_button_new_with_label(_("Cancel"));
  475 + g_signal_connect(widget,"clicked",G_CALLBACK(cancel_clicked),dialog);
  476 + gtk_header_bar_pack_start(GTK_HEADER_BAR(frame),widget);
  477 +
  478 +}
  479 +
  480 +/**
  481 + * v3270ftprogress_dialog_new:
  482 + *
  483 + * Creates a new #v3270ftprogress.
  484 + *
  485 + * Returns: a new #v3270ftprogress.
  486 + */
  487 +GtkWidget * v3270ftprogress_new(void) {
  488 + return GTK_WIDGET(g_object_new(GTK_TYPE_V3270FTPROGRESS, "use-header-bar", (gint) 1, NULL));
  489 +}
  490 +
  491 +void v3270ftprogress_update(GtkWidget *widget, unsigned long current, unsigned long total, double kbytes_sec) {
  492 +
  493 + gchar * text;
  494 + v3270ftprogress * dialog = GTK_V3270FTPROGRESS(widget);
  495 +
  496 + if(current && total) {
  497 +
  498 + if(dialog->pulse) {
  499 + g_source_destroy(dialog->pulse);
  500 + dialog->pulse = NULL;
  501 + }
  502 +
  503 + double remaining = ((double) (total - current))/1024.0;
  504 +
  505 + if(remaining > 0 && kbytes_sec > 0) {
  506 +
  507 + char buffer[40];
  508 + double seconds = ((double) remaining) / kbytes_sec;
  509 + time_t eta = time(0) + ((time_t) seconds);
  510 + strftime(buffer, 39, "%H:%M:%S", localtime(&eta));
  511 +
  512 + gtk_entry_set_text(dialog->info[PROGRESS_FIELD_ETA],buffer);
  513 +
  514 + } else {
  515 +
  516 + gtk_entry_set_text(dialog->info[PROGRESS_FIELD_ETA],"-");
  517 +
  518 + }
  519 +
  520 + gtk_progress_bar_set_fraction(dialog->progress, ((gdouble) current) / ((gdouble) total));
  521 +
  522 + }
  523 +
  524 + debug("%s(%lu/%lu)",__FUNCTION__,current,total);
  525 +
  526 + text = g_strdup_printf("%lu",current);
  527 + gtk_entry_set_text(dialog->info[PROGRESS_FIELD_CURRENT],text);
  528 + g_free(text);
  529 +
  530 + text = g_strdup_printf("%lu",total);
  531 + gtk_entry_set_text(dialog->info[PROGRESS_FIELD_TOTAL],text);
  532 + g_free(text);
  533 +
  534 + text = g_strdup_printf("%ld KB/s",(unsigned long) kbytes_sec);
  535 + gtk_entry_set_text(dialog->info[PROGRESS_FIELD_SPEED],text);
  536 + g_free(text);
  537 +
  538 +
  539 +}
  540 +
  541 +struct delayed_signal {
  542 + H3270 * hSession;
  543 + int signal;
  544 + gchar * msg;
  545 + gchar * text;
  546 +};
  547 +
  548 +gboolean send_delayed_signal(struct delayed_signal *sig) {
  549 +
  550 + void * userdata = lib3270_ft_get_user_data(sig->hSession);
  551 +
  552 + lib3270_ft_set_user_data(sig->hSession,NULL);
  553 + lib3270_ft_destroy(sig->hSession);
  554 +
  555 + if(userdata) {
  556 + g_signal_emit(GTK_WIDGET(userdata),v3270ftprogress_signal[sig->signal], 0, sig->msg, sig->text);
  557 + }
  558 +
  559 + return FALSE;
  560 +
  561 +}
  562 +
  563 +
  564 +static void delay_signal(H3270 *hSession, int signal, const gchar *msg, const gchar *text) {
  565 +
  566 + size_t sz[] = { strlen(msg),strlen(text ? text : "") };
  567 +
  568 + struct delayed_signal *sig = g_malloc0(sizeof(struct delayed_signal)+sz[0]+sz[1]+3);
  569 +
  570 + sig->hSession = hSession;
  571 + sig->signal = signal;
  572 +
  573 + sig->msg = (char *) (sig+1);
  574 + if(msg)
  575 + strcpy(sig->msg,msg);
  576 +
  577 + sig->text = sig->msg + strlen(sig->msg) + 1;
  578 + if(text)
  579 + strcpy(sig->text,text);
  580 +
  581 + gdk_threads_add_idle_full(G_PRIORITY_LOW,(GSourceFunc) send_delayed_signal,sig,g_free);
  582 +
  583 +}
  584 +
  585 +static void ft_failed(H3270 *hSession, unsigned long length,double kbytes_sec,const char *msg, void *userdata) {
  586 +
  587 + debug("%s (user_data=%p length=%lu msg=%s)",__FUNCTION__, userdata, length, msg);
  588 +
  589 + if(userdata) {
  590 +
  591 + size_t f;
  592 +
  593 + GtkWidget * widget = GTK_WIDGET(userdata);
  594 + const gchar * text = gettext(msg);
  595 +
  596 + stop_pulse(widget);
  597 + stop_timer(widget);
  598 +
  599 + v3270ftprogress_update(widget, length, length, kbytes_sec);
  600 + v3270ftprogress_set_header(widget,text);
  601 +
  602 + for(f=0;f < G_N_ELEMENTS(ftmsg); f++) {
  603 +
  604 + if(!g_ascii_strncasecmp(ftmsg[f].id,msg,7)) {
  605 +
  606 + // Known message, get translated one
  607 +
  608 + while(*text && !g_ascii_isspace(*text))
  609 + text++;
  610 +
  611 + while(*text && g_ascii_isspace(*text))
  612 + text++;
  613 +
  614 + delay_signal(hSession, V3270FTPROGRESS_SIGNAL_FAILED, text, gettext(ftmsg[f].text));
  615 +
  616 + return;
  617 +
  618 + }
  619 +
  620 + }
  621 +
  622 + delay_signal(hSession, V3270FTPROGRESS_SIGNAL_FAILED, text, NULL);
  623 +
  624 + }
  625 +
  626 +}
  627 +
  628 +static void ft_complete(H3270 *hSession, unsigned long length,double kbytes_sec,const char *msg, void *userdata) {
  629 +
  630 + debug("%s (user_data=%p length=%lu msg=%s)",__FUNCTION__, userdata, length, msg);
  631 +
  632 + if(userdata) {
  633 +
  634 + size_t f;
  635 +
  636 + GtkWidget * widget = GTK_WIDGET(userdata);
  637 + const gchar * text = gettext(msg);
  638 +
  639 + stop_pulse(widget);
  640 + stop_timer(widget);
  641 +
  642 + v3270ftprogress_update(widget, length, length, kbytes_sec);
  643 + v3270ftprogress_set_header(widget,text);
  644 +
  645 + for(f=0;f < G_N_ELEMENTS(ftmsg); f++) {
  646 +
  647 + if(!g_ascii_strncasecmp(ftmsg[f].id,msg,7)) {
  648 +
  649 + // Known message, get translated message
  650 +
  651 + while(*text && !g_ascii_isspace(*text))
  652 + text++;
  653 +
  654 + while(*text && g_ascii_isspace(*text))
  655 + text++;
  656 +
  657 + delay_signal(hSession, ftmsg[f].failed ? V3270FTPROGRESS_SIGNAL_FAILED : V3270FTPROGRESS_SIGNAL_SUCCESS, text, gettext(ftmsg[f].text));
  658 +
  659 + return;
  660 +
  661 + }
  662 +
  663 + }
  664 +
  665 + delay_signal(hSession, V3270FTPROGRESS_SIGNAL_SUCCESS, text, NULL);
  666 +
  667 + }
  668 +
  669 +}
  670 +
  671 +static void ft_message(H3270 *hSession, const char *text, void *widget){
  672 +
  673 + debug("%s(%s,%p)",__FUNCTION__,text,widget);
  674 +
  675 + if(widget) {
  676 + v3270ftprogress_set_header(GTK_WIDGET(widget),gettext(text));
  677 + }
  678 +}
  679 +
  680 +static void ft_update(H3270 *hSession, unsigned long current, unsigned long total, double kbytes_sec, void *widget) {
  681 +
  682 + if(widget) {
  683 + v3270ftprogress_update(GTK_WIDGET(widget), current, total, kbytes_sec);
  684 + }
  685 +}
  686 +
  687 +static void ft_running(H3270 *hSession, int is_cut, void *widget) {
  688 + GTK_V3270FTPROGRESS(widget)->timeout = time(NULL)+10;
  689 +}
  690 +
  691 +static void ft_aborting(H3270 *hSession, void *widget) {
  692 +
  693 + if(widget) {
  694 + v3270ftprogress_set_header(GTK_WIDGET(widget),_("Aborting transfer"));
  695 + }
  696 +
  697 +}
  698 +
  699 +static void ft_state_changed(H3270 *hSession, LIB3270_FT_STATE state, const char *text, void *widget) {
  700 +
  701 + if(widget) {
  702 + v3270ftprogress_set_header(GTK_WIDGET(widget),gettext(text));
  703 + }
  704 +
  705 +}
  706 +
  707 +
  708 +static gboolean do_pulse(v3270ftprogress *dialog) {
  709 + gtk_progress_bar_pulse(dialog->progress);
  710 + return TRUE;
  711 +}
  712 +
  713 +static gboolean do_timer(v3270ftprogress *dialog) {
  714 + debug("%d",(int) (dialog->timeout - time(NULL)));
  715 +
  716 + if(time(NULL) > dialog->timeout) {
  717 +
  718 + v3270ftprogress_set_header(GTK_WIDGET(dialog),strerror(ETIMEDOUT));
  719 +
  720 + stop_pulse(dialog);
  721 + stop_timer(dialog);
  722 +
  723 + if(dialog->session) {
  724 + lib3270_ft_set_user_data(dialog->session,NULL);
  725 + lib3270_ft_destroy(dialog->session);
  726 + }
  727 +
  728 + g_signal_emit(GTK_WIDGET(dialog),v3270ftprogress_signal[V3270FTPROGRESS_SIGNAL_FAILED], 0, _( "Transfer failed" ), strerror(ETIMEDOUT));
  729 + }
  730 +
  731 + return TRUE;
  732 +}
  733 +
  734 +void v3270ftprogress_start_transfer(GtkWidget *widget) {
  735 +
  736 + v3270ftprogress * dialog = GTK_V3270FTPROGRESS(widget);
  737 + H3270FT * ft;
  738 + const char * message = NULL;
  739 +
  740 + if(!(dialog->session && dialog->active)) {
  741 + g_warning("Unexpected call to %s without session or file",__FUNCTION__);
  742 + gtk_dialog_response(GTK_DIALOG(widget),GTK_RESPONSE_REJECT);
  743 + return;
  744 + }
  745 +
  746 + gtk_window_set_title(GTK_WINDOW(widget),(dialog->active->options & LIB3270_FT_OPTION_RECEIVE) ? _("Receiving file") : _("Sending file"));
  747 +
  748 + ft = lib3270_ft_new( dialog->session,
  749 + dialog->active->options,
  750 + dialog->active->local,
  751 + dialog->active->remote,
  752 + dialog->active->value[LIB3270_FT_VALUE_LRECL],
  753 + dialog->active->value[LIB3270_FT_VALUE_BLKSIZE],
  754 + dialog->active->value[LIB3270_FT_VALUE_PRIMSPACE],
  755 + dialog->active->value[LIB3270_FT_VALUE_SECSPACE],
  756 + dialog->active->value[LIB3270_FT_VALUE_DFT],
  757 + &message);
  758 +
  759 + if(!ft) {
  760 +
  761 + if(message) {
  762 +
  763 + g_signal_emit(GTK_WIDGET(widget),v3270ftprogress_signal[V3270FTPROGRESS_SIGNAL_FAILED], 0, gettext(message), NULL);
  764 +
  765 + } else {
  766 +
  767 + g_signal_emit(GTK_WIDGET(widget),v3270ftprogress_signal[V3270FTPROGRESS_SIGNAL_FAILED], 0, _( "Can't start file transfer session" ), NULL);
  768 +
  769 + }
  770 +
  771 + return;
  772 + }
  773 +
  774 + // Instala callbacks
  775 + struct lib3270_ft_callbacks *cbk = lib3270_get_ft_callbacks(dialog->session, sizeof(struct lib3270_ft_callbacks));
  776 +
  777 + if(!cbk) {
  778 +
  779 + lib3270_ft_destroy(dialog->session);
  780 + g_signal_emit(GTK_WIDGET(widget),v3270ftprogress_signal[V3270FTPROGRESS_SIGNAL_FAILED], 0, _( "Can't set callback table" ), NULL);
  781 +
  782 + return;
  783 + }
  784 +
  785 + lib3270_ft_set_user_data(dialog->session,widget);
  786 +
  787 + cbk->complete = ft_complete;
  788 + cbk->failed = ft_failed;
  789 + cbk->update = ft_update;
  790 + cbk->running = ft_running;
  791 + cbk->aborting = ft_aborting;
  792 + cbk->state_changed = ft_state_changed;
  793 + cbk->message = ft_message;
  794 +
  795 + dialog->timeout = time(NULL)+10;
  796 +
  797 + v3270ftprogress_set_header(widget,_("Starting"));
  798 +
  799 + // Pulse timer
  800 + dialog->pulse = g_timeout_source_new(100);
  801 + g_source_set_callback(dialog->pulse,(GSourceFunc) do_pulse,dialog,NULL);
  802 + g_source_attach(dialog->pulse,NULL);
  803 +
  804 + // Timeout timer
  805 + dialog->timer = g_timeout_source_new_seconds(1);
  806 + g_source_set_callback(dialog->timer,(GSourceFunc) do_timer,dialog,NULL);
  807 + g_source_attach(dialog->timer,NULL);
  808 +
  809 + lib3270_ft_start(dialog->session);
  810 +
  811 +}
... ...