From c8809203852e988a8c2052a8554b4bbe67fd39cd Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Tue, 17 May 2016 13:36:29 -0300 Subject: [PATCH] Modificando apresentação de mensagem em caso de erro ao iniciar transferência de arquivos para compatibilizar com o novo diálogo. --- src/include/lib3270/filetransfer.h | 3 ++- src/lib3270/ft.c | 51 ++++++++++++++++++--------------------------------- src/pw3270/filetransfer.c | 2 +- 3 files changed, 21 insertions(+), 35 deletions(-) diff --git a/src/include/lib3270/filetransfer.h b/src/include/lib3270/filetransfer.h index 819dff7..d5a23a3 100644 --- a/src/include/lib3270/filetransfer.h +++ b/src/include/lib3270/filetransfer.h @@ -162,11 +162,12 @@ * @param primspace * @param secspace * @param dft + * @param msg Pointer to receive message text. * * @return Filetransfer handle if ok, NULL if failed * */ - LIB3270_EXPORT H3270FT * lib3270_ft_new(H3270 *hSession, LIB3270_FT_OPTION flags, const char *local, const char *remote, int lrecl, int blksize, int primspace, int secspace, int dft); + LIB3270_EXPORT H3270FT * lib3270_ft_new(H3270 *hSession, LIB3270_FT_OPTION flags, const char *local, const char *remote, int lrecl, int blksize, int primspace, int secspace, int dft, const char **msg); LIB3270_EXPORT int lib3270_ft_start(H3270 *hSession); LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession); diff --git a/src/lib3270/ft.c b/src/lib3270/ft.c index 38daa6d..07c2e72 100644 --- a/src/lib3270/ft.c +++ b/src/lib3270/ft.c @@ -178,8 +178,21 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); } + static H3270FT * ft_creation_failed(H3270 *session, int rc, const char **dest, const char *message) { - LIB3270_EXPORT H3270FT * lib3270_ft_new(H3270 *session, LIB3270_FT_OPTION flags, const char *local, const char *remote, int lrecl, int blksize, int primspace, int secspace, int dft) + errno = rc; + + if(!dest) { + // Não tem destino para a mensagem, apresenta + lib3270_popup_dialog(session, LIB3270_NOTIFY_ERROR, _( "Request failed" ), _( "Can't start file transfer." ), "%s", message); + } else { + *dest = message; + } + + return NULL; + } + + LIB3270_EXPORT H3270FT * lib3270_ft_new(H3270 *session, LIB3270_FT_OPTION flags, const char *local, const char *remote, int lrecl, int blksize, int primspace, int secspace, int dft, const char **message) { static const unsigned short asc2ft[256] = { @@ -229,40 +242,18 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); // trace("%s(%s)",__FUNCTION__,local); if(!lib3270_connected(session)) { - lib3270_popup_dialog( session, - LIB3270_NOTIFY_ERROR, - _( "Request failed" ), - _( "Can't start file transfer." ), - "%s", - _( "Disconnected from host." )); - errno = ENOTCONN; - return NULL; + return ft_creation_failed(session,ENOTCONN,message,_( "Disconnected from host." )); } if(ftHandle) { - lib3270_popup_dialog( session, - LIB3270_NOTIFY_ERROR, - _( "Request failed" ), - _( "Can't start file transfer." ), - "%s", - _( "File transfer is already active in this session." )); - - errno = EBUSY; - return NULL; + return ft_creation_failed(session,EBUSY,message,_( "File transfer is already active in this session." )); } // Check remote file if(!*remote) { - lib3270_popup_dialog( session, - LIB3270_NOTIFY_ERROR, - _( "Request failed" ), - _( "Can't start file transfer." ), - "%s", - _( "The remote file name is invalid." )); - errno = EINVAL; - return NULL; + return ft_creation_failed(session,EINVAL,message,_( "The remote file name is invalid." )); } // Open local file @@ -274,13 +265,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); if(!ft_local_file) { - lib3270_popup_dialog( session, - LIB3270_NOTIFY_ERROR, - _( "Request failed" ), - _( "Can't open local file." ), - "%s", - strerror(errno)); - return NULL; + return ft_creation_failed(session,errno,message,strerror(errno)); } // Set options diff --git a/src/pw3270/filetransfer.c b/src/pw3270/filetransfer.c index 45b25cc..8e01ceb 100644 --- a/src/pw3270/filetransfer.c +++ b/src/pw3270/filetransfer.c @@ -238,7 +238,7 @@ gint v3270_transfer_file(GtkWidget *widget, LIB3270_FT_OPTION options, const gch { g_return_val_if_fail(GTK_IS_V3270(widget),0); - H3270FT * ft = lib3270_ft_new(v3270_get_session(widget),options,local,remote,lrecl,blksize,primspace,secspace,dft); + H3270FT * ft = lib3270_ft_new(v3270_get_session(widget),options,local,remote,lrecl,blksize,primspace,secspace,dft,NULL); if(!ft) return -1; -- libgit2 0.21.2