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 | 250 | <Unit filename="src/pw3270/print.c"> |
251 | 251 | <Option compilerVar="CC" /> |
252 | 252 | </Unit> |
253 | + <Unit filename="src/pw3270/tools.c"> | |
254 | + <Option compilerVar="CC" /> | |
255 | + </Unit> | |
253 | 256 | <Unit filename="src/pw3270/uiparser/Makefile.in" /> |
254 | 257 | <Unit filename="src/pw3270/uiparser/accelerator.c"> |
255 | 258 | <Option compilerVar="CC" /> | ... | ... |
src/include/pw3270.h
... | ... | @@ -56,6 +56,7 @@ |
56 | 56 | LIB3270_EXPORT gboolean pw3270_get_toggle(GtkWidget *widget, LIB3270_TOGGLE ix); |
57 | 57 | LIB3270_EXPORT H3270 * pw3270_get_session(GtkWidget *widget); |
58 | 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 | 61 | G_END_DECLS |
61 | 62 | ... | ... |
src/pw3270/Makefile.in
... | ... | @@ -56,11 +56,12 @@ include uiparser/sources.mak |
56 | 56 | |
57 | 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 | 65 | $(foreach SRC, $(COMMON_SRC), common/$(SRC)) |
65 | 66 | |
66 | 67 | DEPENDS=*.h common/*.h uiparser/*.h v3270/*.h $(GLOBAL_DEPS) | ... | ... |
src/pw3270/common/common.h.in
... | ... | @@ -54,22 +54,6 @@ |
54 | 54 | #define PACKAGE_NAME "@PACKAGE_NAME@" |
55 | 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 | 57 | #define ENABLE_NLS |
74 | 58 | |
75 | 59 | #ifndef GETTEXT_PACKAGE |
... | ... | @@ -86,26 +70,27 @@ |
86 | 70 | #endif |
87 | 71 | |
88 | 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 | 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 | 92 | #else |
108 | - DLL_EXPORT GKeyFile * get_application_keyfile(void); | |
93 | + GKeyFile * get_application_keyfile(void); | |
109 | 94 | #endif // WIN_REGISTRY_ENABLED |
110 | 95 | |
111 | 96 | #endif | ... | ... |
src/pw3270/common/config.c
... | ... | @@ -380,10 +380,7 @@ gchar * get_last_error_msg(void) |
380 | 380 | |
381 | 381 | void configuration_init(void) |
382 | 382 | { |
383 | -#ifdef WIN_REGISTRY_ENABLED | |
384 | - | |
385 | -#else | |
386 | - | |
383 | +#ifndef WIN_REGISTRY_ENABLED | |
387 | 384 | gchar *filename = search_for_ini(); |
388 | 385 | |
389 | 386 | if(program_config) |
... | ... | @@ -554,11 +551,21 @@ void configuration_deinit(void) |
554 | 551 | |
555 | 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 | 565 | static const gchar * datadir = NULL; |
558 | 566 | const gchar * appname[] = { g_get_application_name(), PACKAGE_NAME }; |
559 | 567 | GString * result = NULL; |
560 | 568 | const gchar * element; |
561 | - va_list args; | |
562 | 569 | |
563 | 570 | if(datadir) |
564 | 571 | result = g_string_new(datadir); |
... | ... | @@ -627,16 +634,12 @@ gchar * build_data_filename(const gchar *first_element, ...) |
627 | 634 | g_warning("Unable to find application datadir, using %s",result->str); |
628 | 635 | } |
629 | 636 | |
630 | - va_start(args, first_element); | |
631 | - | |
632 | 637 | for(element = first_element;element;element = va_arg(args, gchar *)) |
633 | 638 | { |
634 | 639 | g_string_append_c(result,G_DIR_SEPARATOR); |
635 | 640 | g_string_append(result,element); |
636 | 641 | } |
637 | 642 | |
638 | - va_end(args); | |
639 | - | |
640 | 643 | return g_string_free(result, FALSE); |
641 | 644 | } |
642 | 645 | ... | ... |
src/pw3270/main.c
... | ... | @@ -75,7 +75,7 @@ static int initialize(void) |
75 | 75 | static void toplevel_setup(GtkWindow *window) |
76 | 76 | { |
77 | 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 | 80 | gtk_window_set_type_hint(window,GDK_WINDOW_TYPE_HINT_NORMAL); |
81 | 81 | gtk_window_set_position(window,GTK_WIN_POS_CENTER); |
... | ... | @@ -200,7 +200,6 @@ int main(int argc, char *argv[]) |
200 | 200 | if(!rc) |
201 | 201 | { |
202 | 202 | GtkSettings *settings = gtk_settings_get_default(); |
203 | - configuration_init(); | |
204 | 203 | |
205 | 204 | if(settings) |
206 | 205 | { |
... | ... | @@ -218,7 +217,6 @@ int main(int argc, char *argv[]) |
218 | 217 | |
219 | 218 | gtk_main(); |
220 | 219 | |
221 | - configuration_deinit(); | |
222 | 220 | } |
223 | 221 | |
224 | 222 | return rc; | ... | ... |
... | ... | @@ -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 | 18 | * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin |
19 | 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 | 23 | * Contatos: |
24 | 24 | * |
... | ... | @@ -149,8 +149,6 @@ |
149 | 149 | |
150 | 150 | static void pw3270_class_init(pw3270Class *klass) |
151 | 151 | { |
152 | -// GObjectClass * gobject_class = G_OBJECT_CLASS(klass); | |
153 | - | |
154 | 152 | #if GTK_CHECK_VERSION(3,0,0) |
155 | 153 | GtkWidgetClass * widget_class = GTK_WIDGET_CLASS(klass); |
156 | 154 | widget_class->destroy = pw3270_destroy; |
... | ... | @@ -161,6 +159,7 @@ |
161 | 159 | } |
162 | 160 | #endif // GTK3 |
163 | 161 | |
162 | + configuration_init(); | |
164 | 163 | lib3270_set_popup_handler(popup_handler); |
165 | 164 | |
166 | 165 | } |
... | ... | @@ -426,7 +425,7 @@ |
426 | 425 | |
427 | 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 | 430 | if(ui_parse_xml_folder(GTK_WINDOW(widget),path,groupname,popupname,widget->terminal,widget_setup)) |
432 | 431 | { | ... | ... |