From ac85d8803e660e34cae26fcc8c3e112382ac6df5 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Tue, 24 May 2016 17:45:49 -0300 Subject: [PATCH] Ajustes para empacotamento windows. --- src/java/plugin.cc | 3 +++ src/plugins/hllapi/pluginmain.c | 2 ++ src/plugins/rx3270/pluginmain.cc | 3 +++ src/pw3270/v3270ft/select.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 88 insertions(+), 1 deletion(-) diff --git a/src/java/plugin.cc b/src/java/plugin.cc index 75ae735..49355b6 100644 --- a/src/java/plugin.cc +++ b/src/java/plugin.cc @@ -340,7 +340,10 @@ } int file_transfer(LIB3270_FT_OPTION options, const gchar *local, const gchar *remote, int lrecl = 0, int blksize = 0, int primspace = 0, int secspace = 0, int dft = 4096) { + /* return v3270_transfer_file(v3270_get_default_widget(),options,local,remote,lrecl,blksize,primspace,secspace,dft); + */ + return EINVAL; } void set_unlock_delay(unsigned short ms) diff --git a/src/plugins/hllapi/pluginmain.c b/src/plugins/hllapi/pluginmain.c index a024b4b..5e7bd4e 100644 --- a/src/plugins/hllapi/pluginmain.c +++ b/src/plugins/hllapi/pluginmain.c @@ -185,6 +185,7 @@ static int do_file_transfer(struct hllapi_packet_file_transfer * source) { + /* const gchar * local = (const char *) source->text; const gchar * remote = (const char *) (local+strlen(local)+1); @@ -197,6 +198,7 @@ source->primspace, source->secspace, source->dft ); + */ } static void process_input(pipe_source *source, DWORD cbRead) diff --git a/src/plugins/rx3270/pluginmain.cc b/src/plugins/rx3270/pluginmain.cc index f1984f2..b083c1c 100644 --- a/src/plugins/rx3270/pluginmain.cc +++ b/src/plugins/rx3270/pluginmain.cc @@ -836,7 +836,10 @@ const char * plugin::ebc2asc(unsigned char *str, int sz) int plugin::file_transfer(LIB3270_FT_OPTION options, const gchar *local, const gchar *remote, int lrecl, int blksize, int primspace, int secspace, int dft) { + /* return v3270_transfer_file(v3270_get_default_widget(),options,local,remote,lrecl,blksize,primspace,secspace,dft); + */ + return EINVAL; } void plugin::set_unlock_delay(unsigned short ms) diff --git a/src/pw3270/v3270ft/select.c b/src/pw3270/v3270ft/select.c index b59f1f4..29da6e5 100644 --- a/src/pw3270/v3270ft/select.c +++ b/src/pw3270/v3270ft/select.c @@ -30,8 +30,47 @@ #include "private.h" +#ifdef WIN32 + #include +#endif // WIN32 + /*--[ Implement ]------------------------------------------------------------------------------------*/ +#if defined(_WIN32) + +struct file { + OPENFILENAME ofn; + gboolean enabled; + char szName[260]; // buffer for file name + GtkFileChooserAction action; + BOOL ok; +}; + +static gpointer select_file(struct file *fl) { + + + switch(fl->action) { + case GTK_FILE_CHOOSER_ACTION_SAVE: // Receber arquivo + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms646839(v=vs.85).aspx + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms646829(v=vs.85).aspx#open_file + fl->ofn.Flags = OFN_OVERWRITEPROMPT; + fl->ok = GetSaveFileName(&fl->ofn); + break; + + case GTK_FILE_CHOOSER_ACTION_OPEN: // Enviar arquivo + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms646928(v=vs.85).aspx + fl->ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; + fl->ok = GetOpenFileName(&fl->ofn); + break; + } + + fl->enabled = FALSE; + + return 0; +} + +#endif // _WIN32 + gchar * v3270ft_select_file(v3270ft *dialog, const gchar *title, const gchar *button, GtkFileChooserAction action, const gchar *filename) { gchar *rc = NULL; @@ -56,7 +95,47 @@ gchar * v3270ft_select_file(v3270ft *dialog, const gchar *title, const gchar *bu #elif defined(_WIN32) - #error Usar diálogo nativo windows + GThread * thd; + struct file fl; + GdkWindow * win = gtk_widget_get_window(GTK_WIDGET(dialog)); + + gtk_widget_set_sensitive(GTK_WIDGET(dialog),FALSE); + + memset(&fl,0,sizeof(fl)); + fl.ofn.lStructSize = sizeof(fl.ofn); + fl.ofn.hwndOwner = GDK_WINDOW_HWND(win); + fl.ofn.lpstrFile = fl.szName; + + // Set lpstrFile[0] to '\0' so that GetOpenFileName does not + // use the contents of szFile to initialize itself. + fl.ofn.lpstrFile[0] = '\0'; + + fl.ofn.nMaxFile = sizeof(fl.szName); + fl.ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0"; + fl.ofn.nFilterIndex = 1; + fl.ofn.nMaxFileTitle = 0; + fl.ofn.lpstrInitialDir = NULL; + + // Guarda o valor atual + strncpy(fl.szName,filename,fl.ofn.nMaxFile); + + fl.action = action; + + thd = g_thread_new("GetFileName",(GThreadFunc) select_file, &fl); + + fl.enabled = TRUE; + while(fl.enabled) { + g_main_context_iteration(NULL,TRUE); + } + + g_thread_unref(thd); + + if(fl.ok) { + rc = g_strdup(fl.szName); + } + + gtk_widget_set_sensitive(GTK_WIDGET(dialog),TRUE); + #else -- libgit2 0.21.2