Commit c7bab6e71f64ca41815b8bdd0037662aa5177de5
1 parent
4409c836
Exists in
master
and in
5 other branches
Movendo todas as funções do terminal para a lib3270 para facilitar a implementação de plugins
Showing
8 changed files
with
130 additions
and
50 deletions
Show diff stats
pw3270.cbp
@@ -250,6 +250,9 @@ | @@ -250,6 +250,9 @@ | ||
250 | <Unit filename="src/pw3270/print.c"> | 250 | <Unit filename="src/pw3270/print.c"> |
251 | <Option compilerVar="CC" /> | 251 | <Option compilerVar="CC" /> |
252 | </Unit> | 252 | </Unit> |
253 | + <Unit filename="src/pw3270/tools.c"> | ||
254 | + <Option compilerVar="CC" /> | ||
255 | + </Unit> | ||
253 | <Unit filename="src/pw3270/uiparser/Makefile.in" /> | 256 | <Unit filename="src/pw3270/uiparser/Makefile.in" /> |
254 | <Unit filename="src/pw3270/uiparser/accelerator.c"> | 257 | <Unit filename="src/pw3270/uiparser/accelerator.c"> |
255 | <Option compilerVar="CC" /> | 258 | <Option compilerVar="CC" /> |
src/include/pw3270.h
@@ -56,6 +56,7 @@ | @@ -56,6 +56,7 @@ | ||
56 | LIB3270_EXPORT gboolean pw3270_get_toggle(GtkWidget *widget, LIB3270_TOGGLE ix); | 56 | LIB3270_EXPORT gboolean pw3270_get_toggle(GtkWidget *widget, LIB3270_TOGGLE ix); |
57 | LIB3270_EXPORT H3270 * pw3270_get_session(GtkWidget *widget); | 57 | LIB3270_EXPORT H3270 * pw3270_get_session(GtkWidget *widget); |
58 | LIB3270_EXPORT GtkWidget * pw3270_get_terminal_widget(GtkWidget *widget); | 58 | LIB3270_EXPORT GtkWidget * pw3270_get_terminal_widget(GtkWidget *widget); |
59 | + LIB3270_EXPORT gchar * pw3270_build_filename(GtkWidget *widget, const gchar *first_element, ...); | ||
59 | 60 | ||
60 | G_END_DECLS | 61 | G_END_DECLS |
61 | 62 |
src/pw3270/Makefile.in
@@ -56,11 +56,12 @@ include uiparser/sources.mak | @@ -56,11 +56,12 @@ include uiparser/sources.mak | ||
56 | 56 | ||
57 | #---[ Targets ]---------------------------------------------------------------- | 57 | #---[ Targets ]---------------------------------------------------------------- |
58 | 58 | ||
59 | -APP_SOURCES= main.c window.c actions.c fonts.c dialog.c print.c colors.c \ | ||
60 | - filetransfer.c \ | ||
61 | - $(foreach SRC, $(UI_PARSER_SRC), uiparser/$(SRC)) | 59 | +APP_SOURCES= main.c |
62 | 60 | ||
63 | -LIB_SOURCES= $(foreach SRC, $(V3270_SRC), v3270/$(SRC)) \ | 61 | +LIB_SOURCES= window.c actions.c fonts.c dialog.c print.c colors.c \ |
62 | + filetransfer.c tools.c \ | ||
63 | + $(foreach SRC, $(UI_PARSER_SRC), uiparser/$(SRC)) \ | ||
64 | + $(foreach SRC, $(V3270_SRC), v3270/$(SRC)) \ | ||
64 | $(foreach SRC, $(COMMON_SRC), common/$(SRC)) | 65 | $(foreach SRC, $(COMMON_SRC), common/$(SRC)) |
65 | 66 | ||
66 | DEPENDS=*.h common/*.h uiparser/*.h v3270/*.h $(GLOBAL_DEPS) | 67 | DEPENDS=*.h common/*.h uiparser/*.h v3270/*.h $(GLOBAL_DEPS) |
src/pw3270/common/common.h.in
@@ -54,22 +54,6 @@ | @@ -54,22 +54,6 @@ | ||
54 | #define PACKAGE_NAME "@PACKAGE_NAME@" | 54 | #define PACKAGE_NAME "@PACKAGE_NAME@" |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | - #if defined(_WIN32) | ||
58 | - | ||
59 | - #include <windows.h> | ||
60 | - #define DLL_EXPORT __declspec (dllexport) | ||
61 | - | ||
62 | - #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) | ||
63 | - | ||
64 | - #define DLL_EXPORT | ||
65 | - | ||
66 | - #else | ||
67 | - | ||
68 | - #define DLL_EXPORT __attribute__((visibility("default"))) extern | ||
69 | - | ||
70 | - #endif | ||
71 | - | ||
72 | - | ||
73 | #define ENABLE_NLS | 57 | #define ENABLE_NLS |
74 | 58 | ||
75 | #ifndef GETTEXT_PACKAGE | 59 | #ifndef GETTEXT_PACKAGE |
@@ -86,26 +70,27 @@ | @@ -86,26 +70,27 @@ | ||
86 | #endif | 70 | #endif |
87 | 71 | ||
88 | // Configuration | 72 | // Configuration |
89 | - DLL_EXPORT void configuration_init(void); | ||
90 | - DLL_EXPORT void configuration_deinit(void); | 73 | + void configuration_init(void); |
74 | + void configuration_deinit(void); | ||
91 | 75 | ||
92 | - DLL_EXPORT gchar * get_string_from_config(const gchar *group, const gchar *key, const gchar *def); | ||
93 | - DLL_EXPORT gboolean get_boolean_from_config(const gchar *group, const gchar *key, gboolean def); | ||
94 | - DLL_EXPORT gint get_integer_from_config(const gchar *group, const gchar *key, gint def); | 76 | + gchar * get_string_from_config(const gchar *group, const gchar *key, const gchar *def); |
77 | + gboolean get_boolean_from_config(const gchar *group, const gchar *key, gboolean def); | ||
78 | + gint get_integer_from_config(const gchar *group, const gchar *key, gint def); | ||
95 | 79 | ||
96 | - DLL_EXPORT void set_string_to_config(const gchar *group, const gchar *key, const gchar *fmt, ...); | ||
97 | - DLL_EXPORT void set_boolean_to_config(const gchar *group, const gchar *key, gboolean val); | ||
98 | - DLL_EXPORT void set_integer_to_config(const gchar *group, const gchar *key, gint val); | 80 | + void set_string_to_config(const gchar *group, const gchar *key, const gchar *fmt, ...); |
81 | + void set_boolean_to_config(const gchar *group, const gchar *key, gboolean val); | ||
82 | + void set_integer_to_config(const gchar *group, const gchar *key, gint val); | ||
99 | 83 | ||
100 | - DLL_EXPORT gchar * build_data_filename(const gchar *first_element, ...); | 84 | + gchar * build_data_filename(const gchar *first_element, ...); |
85 | + gchar * filename_from_va(const gchar *first_element, va_list args); | ||
101 | 86 | ||
102 | #ifdef WIN_REGISTRY_ENABLED | 87 | #ifdef WIN_REGISTRY_ENABLED |
103 | - DLL_EXPORT gboolean get_registry_handle(const gchar *group, HKEY *hKey, REGSAM samDesired); | ||
104 | - DLL_EXPORT void registry_foreach(HKEY parent, const gchar *name,void (*cbk)(const gchar *key, const gchar *val, gpointer *user_data), gpointer *user_data); | ||
105 | - DLL_EXPORT void registry_set_double(HKEY hKey, const gchar *key, gdouble value); | ||
106 | - DLL_EXPORT gboolean registry_get_double(HKEY hKey, const gchar *key, gdouble *value); | 88 | + gboolean get_registry_handle(const gchar *group, HKEY *hKey, REGSAM samDesired); |
89 | + void registry_foreach(HKEY parent, const gchar *name,void (*cbk)(const gchar *key, const gchar *val, gpointer *user_data), gpointer *user_data); | ||
90 | + void registry_set_double(HKEY hKey, const gchar *key, gdouble value); | ||
91 | + gboolean registry_get_double(HKEY hKey, const gchar *key, gdouble *value); | ||
107 | #else | 92 | #else |
108 | - DLL_EXPORT GKeyFile * get_application_keyfile(void); | 93 | + GKeyFile * get_application_keyfile(void); |
109 | #endif // WIN_REGISTRY_ENABLED | 94 | #endif // WIN_REGISTRY_ENABLED |
110 | 95 | ||
111 | #endif | 96 | #endif |
src/pw3270/common/config.c
@@ -380,10 +380,7 @@ gchar * get_last_error_msg(void) | @@ -380,10 +380,7 @@ gchar * get_last_error_msg(void) | ||
380 | 380 | ||
381 | void configuration_init(void) | 381 | void configuration_init(void) |
382 | { | 382 | { |
383 | -#ifdef WIN_REGISTRY_ENABLED | ||
384 | - | ||
385 | -#else | ||
386 | - | 383 | +#ifndef WIN_REGISTRY_ENABLED |
387 | gchar *filename = search_for_ini(); | 384 | gchar *filename = search_for_ini(); |
388 | 385 | ||
389 | if(program_config) | 386 | if(program_config) |
@@ -554,11 +551,21 @@ void configuration_deinit(void) | @@ -554,11 +551,21 @@ void configuration_deinit(void) | ||
554 | 551 | ||
555 | gchar * build_data_filename(const gchar *first_element, ...) | 552 | gchar * build_data_filename(const gchar *first_element, ...) |
556 | { | 553 | { |
554 | + va_list args; | ||
555 | + gchar *path; | ||
556 | + | ||
557 | + va_start(args, first_element); | ||
558 | + path = filename_from_va(first_element,args); | ||
559 | + va_end(args); | ||
560 | + return path; | ||
561 | +} | ||
562 | + | ||
563 | +gchar * filename_from_va(const gchar *first_element, va_list args) | ||
564 | +{ | ||
557 | static const gchar * datadir = NULL; | 565 | static const gchar * datadir = NULL; |
558 | const gchar * appname[] = { g_get_application_name(), PACKAGE_NAME }; | 566 | const gchar * appname[] = { g_get_application_name(), PACKAGE_NAME }; |
559 | GString * result = NULL; | 567 | GString * result = NULL; |
560 | const gchar * element; | 568 | const gchar * element; |
561 | - va_list args; | ||
562 | 569 | ||
563 | if(datadir) | 570 | if(datadir) |
564 | result = g_string_new(datadir); | 571 | result = g_string_new(datadir); |
@@ -627,16 +634,12 @@ gchar * build_data_filename(const gchar *first_element, ...) | @@ -627,16 +634,12 @@ gchar * build_data_filename(const gchar *first_element, ...) | ||
627 | g_warning("Unable to find application datadir, using %s",result->str); | 634 | g_warning("Unable to find application datadir, using %s",result->str); |
628 | } | 635 | } |
629 | 636 | ||
630 | - va_start(args, first_element); | ||
631 | - | ||
632 | for(element = first_element;element;element = va_arg(args, gchar *)) | 637 | for(element = first_element;element;element = va_arg(args, gchar *)) |
633 | { | 638 | { |
634 | g_string_append_c(result,G_DIR_SEPARATOR); | 639 | g_string_append_c(result,G_DIR_SEPARATOR); |
635 | g_string_append(result,element); | 640 | g_string_append(result,element); |
636 | } | 641 | } |
637 | 642 | ||
638 | - va_end(args); | ||
639 | - | ||
640 | return g_string_free(result, FALSE); | 643 | return g_string_free(result, FALSE); |
641 | } | 644 | } |
642 | 645 |
src/pw3270/main.c
@@ -75,7 +75,7 @@ static int initialize(void) | @@ -75,7 +75,7 @@ static int initialize(void) | ||
75 | static void toplevel_setup(GtkWindow *window) | 75 | static void toplevel_setup(GtkWindow *window) |
76 | { | 76 | { |
77 | gchar * name = g_strdup_printf("%s.png",g_get_application_name()); | 77 | gchar * name = g_strdup_printf("%s.png",g_get_application_name()); |
78 | - gchar * filename = build_data_filename(name,NULL); | 78 | + gchar * filename = pw3270_build_filename(GTK_WIDGET(window),name,NULL); |
79 | 79 | ||
80 | gtk_window_set_type_hint(window,GDK_WINDOW_TYPE_HINT_NORMAL); | 80 | gtk_window_set_type_hint(window,GDK_WINDOW_TYPE_HINT_NORMAL); |
81 | gtk_window_set_position(window,GTK_WIN_POS_CENTER); | 81 | gtk_window_set_position(window,GTK_WIN_POS_CENTER); |
@@ -200,7 +200,6 @@ int main(int argc, char *argv[]) | @@ -200,7 +200,6 @@ int main(int argc, char *argv[]) | ||
200 | if(!rc) | 200 | if(!rc) |
201 | { | 201 | { |
202 | GtkSettings *settings = gtk_settings_get_default(); | 202 | GtkSettings *settings = gtk_settings_get_default(); |
203 | - configuration_init(); | ||
204 | 203 | ||
205 | if(settings) | 204 | if(settings) |
206 | { | 205 | { |
@@ -218,7 +217,6 @@ int main(int argc, char *argv[]) | @@ -218,7 +217,6 @@ int main(int argc, char *argv[]) | ||
218 | 217 | ||
219 | gtk_main(); | 218 | gtk_main(); |
220 | 219 | ||
221 | - configuration_deinit(); | ||
222 | } | 220 | } |
223 | 221 | ||
224 | return rc; | 222 | return rc; |
@@ -0,0 +1,90 @@ | @@ -0,0 +1,90 @@ | ||
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 tools.c e possui - linhas de código. | ||
22 | + * | ||
23 | + * Contatos: | ||
24 | + * | ||
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
27 | + * | ||
28 | + */ | ||
29 | + | ||
30 | + #include "globals.h" | ||
31 | + | ||
32 | +#if defined WIN32 | ||
33 | + BOOL WINAPI DllMain(HANDLE hinst, DWORD dwcallpurpose, LPVOID lpvResvd); | ||
34 | + | ||
35 | + static int libpw3270_loaded(void); | ||
36 | + static int libpw3270_unloaded(void); | ||
37 | + | ||
38 | +#else | ||
39 | + int libpw3270_loaded(void) __attribute__((constructor)); | ||
40 | + int libpw3270_unloaded(void) __attribute__((destructor)); | ||
41 | +#endif | ||
42 | + | ||
43 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | ||
44 | + | ||
45 | +#if defined WIN32 | ||
46 | + | ||
47 | +BOOL WINAPI DllMain(HANDLE hinst, DWORD dwcallpurpose, LPVOID lpvResvd) | ||
48 | +{ | ||
49 | +// Trace("%s - Library %s",__FUNCTION__,(dwcallpurpose == DLL_PROCESS_ATTACH) ? "Loaded" : "Unloaded"); | ||
50 | + | ||
51 | + switch(dwcallpurpose) | ||
52 | + { | ||
53 | + case DLL_PROCESS_ATTACH: | ||
54 | + libpw3270_loaded(); | ||
55 | + break; | ||
56 | + | ||
57 | + case DLL_PROCESS_DETACH: | ||
58 | + libpw3270_unloaded(); | ||
59 | + break; | ||
60 | + } | ||
61 | + | ||
62 | + return TRUE; | ||
63 | +} | ||
64 | + | ||
65 | +#endif // WIN32 | ||
66 | + | ||
67 | +int libpw3270_loaded(void) | ||
68 | +{ | ||
69 | + trace("%s",__FUNCTION__); | ||
70 | + return 0; | ||
71 | +} | ||
72 | + | ||
73 | +int libpw3270_unloaded(void) | ||
74 | +{ | ||
75 | + trace("%s",__FUNCTION__); | ||
76 | + configuration_deinit(); | ||
77 | + return 0; | ||
78 | +} | ||
79 | + | ||
80 | + | ||
81 | +gchar * pw3270_build_filename(GtkWidget *widget, const gchar *first_element, ...) | ||
82 | +{ | ||
83 | + va_list args; | ||
84 | + gchar *path; | ||
85 | + | ||
86 | + va_start(args, first_element); | ||
87 | + path = filename_from_va(first_element,args); | ||
88 | + va_end(args); | ||
89 | + return path; | ||
90 | +} |
src/pw3270/window.c
@@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
18 | * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | 18 | * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin |
19 | * St, Fifth Floor, Boston, MA 02110-1301 USA | 19 | * St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | * | 20 | * |
21 | - * Este programa está nomeado como mainwindow.c e possui - linhas de código. | 21 | + * Este programa está nomeado como window.c e possui - linhas de código. |
22 | * | 22 | * |
23 | * Contatos: | 23 | * Contatos: |
24 | * | 24 | * |
@@ -149,8 +149,6 @@ | @@ -149,8 +149,6 @@ | ||
149 | 149 | ||
150 | static void pw3270_class_init(pw3270Class *klass) | 150 | static void pw3270_class_init(pw3270Class *klass) |
151 | { | 151 | { |
152 | -// GObjectClass * gobject_class = G_OBJECT_CLASS(klass); | ||
153 | - | ||
154 | #if GTK_CHECK_VERSION(3,0,0) | 152 | #if GTK_CHECK_VERSION(3,0,0) |
155 | GtkWidgetClass * widget_class = GTK_WIDGET_CLASS(klass); | 153 | GtkWidgetClass * widget_class = GTK_WIDGET_CLASS(klass); |
156 | widget_class->destroy = pw3270_destroy; | 154 | widget_class->destroy = pw3270_destroy; |
@@ -161,6 +159,7 @@ | @@ -161,6 +159,7 @@ | ||
161 | } | 159 | } |
162 | #endif // GTK3 | 160 | #endif // GTK3 |
163 | 161 | ||
162 | + configuration_init(); | ||
164 | lib3270_set_popup_handler(popup_handler); | 163 | lib3270_set_popup_handler(popup_handler); |
165 | 164 | ||
166 | } | 165 | } |
@@ -426,7 +425,7 @@ | @@ -426,7 +425,7 @@ | ||
426 | 425 | ||
427 | // Load UI | 426 | // Load UI |
428 | { | 427 | { |
429 | - gchar *path = build_data_filename("ui",NULL); | 428 | + gchar *path = pw3270_build_filename(GTK_WIDGET(widget),"ui",NULL); |
430 | 429 | ||
431 | if(ui_parse_xml_folder(GTK_WINDOW(widget),path,groupname,popupname,widget->terminal,widget_setup)) | 430 | if(ui_parse_xml_folder(GTK_WINDOW(widget),path,groupname,popupname,widget->terminal,widget_setup)) |
432 | { | 431 | { |