Commit c8809203852e988a8c2052a8554b4bbe67fd39cd
1 parent
d43bde4c
Exists in
master
and in
5 other branches
Modificando apresentação de mensagem em caso de erro ao iniciar transferência de…
… arquivos para compatibilizar com o novo diálogo.
Showing
3 changed files
with
21 additions
and
35 deletions
Show diff stats
src/include/lib3270/filetransfer.h
| @@ -162,11 +162,12 @@ | @@ -162,11 +162,12 @@ | ||
| 162 | * @param primspace | 162 | * @param primspace |
| 163 | * @param secspace | 163 | * @param secspace |
| 164 | * @param dft | 164 | * @param dft |
| 165 | + * @param msg Pointer to receive message text. | ||
| 165 | * | 166 | * |
| 166 | * @return Filetransfer handle if ok, NULL if failed | 167 | * @return Filetransfer handle if ok, NULL if failed |
| 167 | * | 168 | * |
| 168 | */ | 169 | */ |
| 169 | - 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); | 170 | + 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); |
| 170 | 171 | ||
| 171 | LIB3270_EXPORT int lib3270_ft_start(H3270 *hSession); | 172 | LIB3270_EXPORT int lib3270_ft_start(H3270 *hSession); |
| 172 | LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession); | 173 | LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession); |
src/lib3270/ft.c
| @@ -178,8 +178,21 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | @@ -178,8 +178,21 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | ||
| 178 | 178 | ||
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | + static H3270FT * ft_creation_failed(H3270 *session, int rc, const char **dest, const char *message) { | ||
| 181 | 182 | ||
| 182 | - 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) | 183 | + errno = rc; |
| 184 | + | ||
| 185 | + if(!dest) { | ||
| 186 | + // Não tem destino para a mensagem, apresenta | ||
| 187 | + lib3270_popup_dialog(session, LIB3270_NOTIFY_ERROR, _( "Request failed" ), _( "Can't start file transfer." ), "%s", message); | ||
| 188 | + } else { | ||
| 189 | + *dest = message; | ||
| 190 | + } | ||
| 191 | + | ||
| 192 | + return NULL; | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + 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) | ||
| 183 | { | 196 | { |
| 184 | static const unsigned short asc2ft[256] = | 197 | static const unsigned short asc2ft[256] = |
| 185 | { | 198 | { |
| @@ -229,40 +242,18 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | @@ -229,40 +242,18 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | ||
| 229 | // trace("%s(%s)",__FUNCTION__,local); | 242 | // trace("%s(%s)",__FUNCTION__,local); |
| 230 | if(!lib3270_connected(session)) | 243 | if(!lib3270_connected(session)) |
| 231 | { | 244 | { |
| 232 | - lib3270_popup_dialog( session, | ||
| 233 | - LIB3270_NOTIFY_ERROR, | ||
| 234 | - _( "Request failed" ), | ||
| 235 | - _( "Can't start file transfer." ), | ||
| 236 | - "%s", | ||
| 237 | - _( "Disconnected from host." )); | ||
| 238 | - errno = ENOTCONN; | ||
| 239 | - return NULL; | 245 | + return ft_creation_failed(session,ENOTCONN,message,_( "Disconnected from host." )); |
| 240 | } | 246 | } |
| 241 | 247 | ||
| 242 | if(ftHandle) | 248 | if(ftHandle) |
| 243 | { | 249 | { |
| 244 | - lib3270_popup_dialog( session, | ||
| 245 | - LIB3270_NOTIFY_ERROR, | ||
| 246 | - _( "Request failed" ), | ||
| 247 | - _( "Can't start file transfer." ), | ||
| 248 | - "%s", | ||
| 249 | - _( "File transfer is already active in this session." )); | ||
| 250 | - | ||
| 251 | - errno = EBUSY; | ||
| 252 | - return NULL; | 250 | + return ft_creation_failed(session,EBUSY,message,_( "File transfer is already active in this session." )); |
| 253 | } | 251 | } |
| 254 | 252 | ||
| 255 | // Check remote file | 253 | // Check remote file |
| 256 | if(!*remote) | 254 | if(!*remote) |
| 257 | { | 255 | { |
| 258 | - lib3270_popup_dialog( session, | ||
| 259 | - LIB3270_NOTIFY_ERROR, | ||
| 260 | - _( "Request failed" ), | ||
| 261 | - _( "Can't start file transfer." ), | ||
| 262 | - "%s", | ||
| 263 | - _( "The remote file name is invalid." )); | ||
| 264 | - errno = EINVAL; | ||
| 265 | - return NULL; | 256 | + return ft_creation_failed(session,EINVAL,message,_( "The remote file name is invalid." )); |
| 266 | } | 257 | } |
| 267 | 258 | ||
| 268 | // Open local file | 259 | // Open local file |
| @@ -274,13 +265,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | @@ -274,13 +265,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | ||
| 274 | 265 | ||
| 275 | if(!ft_local_file) | 266 | if(!ft_local_file) |
| 276 | { | 267 | { |
| 277 | - lib3270_popup_dialog( session, | ||
| 278 | - LIB3270_NOTIFY_ERROR, | ||
| 279 | - _( "Request failed" ), | ||
| 280 | - _( "Can't open local file." ), | ||
| 281 | - "%s", | ||
| 282 | - strerror(errno)); | ||
| 283 | - return NULL; | 268 | + return ft_creation_failed(session,errno,message,strerror(errno)); |
| 284 | } | 269 | } |
| 285 | 270 | ||
| 286 | // Set options | 271 | // Set options |
src/pw3270/filetransfer.c
| @@ -238,7 +238,7 @@ gint v3270_transfer_file(GtkWidget *widget, LIB3270_FT_OPTION options, const gch | @@ -238,7 +238,7 @@ gint v3270_transfer_file(GtkWidget *widget, LIB3270_FT_OPTION options, const gch | ||
| 238 | { | 238 | { |
| 239 | g_return_val_if_fail(GTK_IS_V3270(widget),0); | 239 | g_return_val_if_fail(GTK_IS_V3270(widget),0); |
| 240 | 240 | ||
| 241 | - H3270FT * ft = lib3270_ft_new(v3270_get_session(widget),options,local,remote,lrecl,blksize,primspace,secspace,dft); | 241 | + H3270FT * ft = lib3270_ft_new(v3270_get_session(widget),options,local,remote,lrecl,blksize,primspace,secspace,dft,NULL); |
| 242 | 242 | ||
| 243 | if(!ft) | 243 | if(!ft) |
| 244 | return -1; | 244 | return -1; |