Commit 957c1f8d2a5e04e5917e21f14ae7e11cf701a709
1 parent
b75798ba
Exists in
master
and in
3 other branches
Separando notificações de transferência completa e falha para facilitar o novo d…
…iálogo de transferência de arquivos.
Showing
4 changed files
with
30 additions
and
18 deletions
Show diff stats
@@ -144,13 +144,19 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | @@ -144,13 +144,19 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | ||
144 | return EBUSY; | 144 | return EBUSY; |
145 | 145 | ||
146 | // Impatient user or hung host -- just clean up. | 146 | // Impatient user or hung host -- just clean up. |
147 | - ft_complete(ft, N_("Cancelled by user") ); | 147 | + ft_failed(ft, N_("Cancelled by user") ); |
148 | 148 | ||
149 | return 0; | 149 | return 0; |
150 | } | 150 | } |
151 | 151 | ||
152 | - static void def_complete(H3270FT *ft,unsigned long length,double kbytes_sec) | 152 | + static void def_complete(H3270FT *ft,unsigned long length,double kbytes_sec,const char *msg) |
153 | { | 153 | { |
154 | + ft->message(ft,msg); | ||
155 | + } | ||
156 | + | ||
157 | + static void def_failed(struct _h3270ft *ft,unsigned long length,double kbytes_sec,const char *msg) | ||
158 | + { | ||
159 | + ft->complete(ft,ft->ft_length,kbytes_sec,msg ? msg : N_("Transfer failed")); | ||
154 | } | 160 | } |
155 | 161 | ||
156 | static void def_message(H3270FT *ft, const char *errmsg) | 162 | static void def_message(H3270FT *ft, const char *errmsg) |
@@ -289,6 +295,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | @@ -289,6 +295,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | ||
289 | ftHandle->local_file = ft_local_file; | 295 | ftHandle->local_file = ft_local_file; |
290 | ftHandle->state = LIB3270_FT_STATE_AWAIT_ACK; | 296 | ftHandle->state = LIB3270_FT_STATE_AWAIT_ACK; |
291 | ftHandle->complete = def_complete; | 297 | ftHandle->complete = def_complete; |
298 | + ftHandle->failed = def_failed; | ||
292 | ftHandle->message = def_message; | 299 | ftHandle->message = def_message; |
293 | ftHandle->update = def_update; | 300 | ftHandle->update = def_update; |
294 | ftHandle->running = def_running; | 301 | ftHandle->running = def_running; |
@@ -365,7 +372,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | @@ -365,7 +372,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | ||
365 | // Sending file | 372 | // Sending file |
366 | if(fseek(ft->local_file,0L,SEEK_END) < 0) | 373 | if(fseek(ft->local_file,0L,SEEK_END) < 0) |
367 | { | 374 | { |
368 | - ft_complete(ft,N_( "Can't get file size" )); | 375 | + ft_failed(ft,N_( "Can't get file size" )); |
369 | return errno ? errno : -1; | 376 | return errno ? errno : -1; |
370 | } | 377 | } |
371 | 378 | ||
@@ -459,7 +466,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | @@ -459,7 +466,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | ||
459 | if (!flen || flen < strlen(buffer) - 1) | 466 | if (!flen || flen < strlen(buffer) - 1) |
460 | { | 467 | { |
461 | lib3270_write_log(ft->host, "Unable to send command \"%s\" (flen=%d szBuffer=%d)",buffer,flen,strlen(buffer)); | 468 | lib3270_write_log(ft->host, "Unable to send command \"%s\" (flen=%d szBuffer=%d)",buffer,flen,strlen(buffer)); |
462 | - ft_complete(ft,N_( "Unable to send file-transfer request" )); | 469 | + ft_failed(ft,N_( "Unable to send file-transfer request" )); |
463 | return errno = EINVAL; | 470 | return errno = EINVAL; |
464 | } | 471 | } |
465 | 472 | ||
@@ -484,11 +491,7 @@ void ft_message(H3270FT *ft, const char *msg) | @@ -484,11 +491,7 @@ void ft_message(H3270FT *ft, const char *msg) | ||
484 | ft->message(ft,msg); | 491 | ft->message(ft,msg); |
485 | } | 492 | } |
486 | 493 | ||
487 | -/** | ||
488 | - * Pop up a message, end the transfer, release resources. | ||
489 | - * | ||
490 | - */ | ||
491 | -void ft_complete(H3270FT *ft, const char *errmsg) | 494 | +static double finish(H3270FT *ft) |
492 | { | 495 | { |
493 | double kbytes_sec = 0; | 496 | double kbytes_sec = 0; |
494 | struct timeval t1; | 497 | struct timeval t1; |
@@ -510,11 +513,17 @@ void ft_complete(H3270FT *ft, const char *errmsg) | @@ -510,11 +513,17 @@ void ft_complete(H3270FT *ft, const char *errmsg) | ||
510 | 513 | ||
511 | ft_update_length(ft); | 514 | ft_update_length(ft); |
512 | 515 | ||
513 | - ft->complete(ft,ft->ft_length,kbytes_sec); | ||
514 | - | ||
515 | - ft_message(ft,errmsg ? errmsg : N_("Transfer complete")); | 516 | + return kbytes_sec; |
517 | +} | ||
516 | 518 | ||
519 | +void ft_complete(H3270FT *ft, const char *errmsg) | ||
520 | +{ | ||
521 | + ft->complete(ft,ft->ft_length,finish(ft),errmsg ? errmsg : N_("Transfer complete")); | ||
522 | +} | ||
517 | 523 | ||
524 | +void ft_failed(H3270FT *ft, const char *errmsg) | ||
525 | +{ | ||
526 | + ft->failed(ft,ft->ft_length,finish(ft),errmsg ? errmsg : N_("Transfer failed")); | ||
518 | } | 527 | } |
519 | 528 | ||
520 | LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession) | 529 | LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession) |
@@ -528,7 +537,9 @@ LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession) | @@ -528,7 +537,9 @@ LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession) | ||
528 | return EINVAL; | 537 | return EINVAL; |
529 | 538 | ||
530 | if (session->state != LIB3270_FT_STATE_NONE) | 539 | if (session->state != LIB3270_FT_STATE_NONE) |
540 | + { | ||
531 | lib3270_ft_cancel(hSession,1); | 541 | lib3270_ft_cancel(hSession,1); |
542 | + } | ||
532 | 543 | ||
533 | if(session->local_file) | 544 | if(session->local_file) |
534 | { | 545 | { |
@@ -597,14 +608,14 @@ void ft_aborting(H3270FT *h) | @@ -597,14 +608,14 @@ void ft_aborting(H3270FT *h) | ||
597 | static void ft_connected(H3270 *hSession, int ignored, void *dunno) | 608 | static void ft_connected(H3270 *hSession, int ignored, void *dunno) |
598 | { | 609 | { |
599 | if (!CONNECTED && lib3270_get_ft_state(hSession) != LIB3270_FT_STATE_NONE) | 610 | if (!CONNECTED && lib3270_get_ft_state(hSession) != LIB3270_FT_STATE_NONE) |
600 | - ft_complete(get_ft_handle(hSession),_("Host disconnected, transfer cancelled")); | 611 | + ft_failed(get_ft_handle(hSession),_("Host disconnected, transfer cancelled")); |
601 | } | 612 | } |
602 | 613 | ||
603 | /* Process an abort from no longer being in 3270 mode. */ | 614 | /* Process an abort from no longer being in 3270 mode. */ |
604 | static void ft_in3270(H3270 *hSession, int ignored, void *dunno) | 615 | static void ft_in3270(H3270 *hSession, int ignored, void *dunno) |
605 | { | 616 | { |
606 | if (!IN_3270 && lib3270_get_ft_state(hSession) != LIB3270_FT_STATE_NONE) | 617 | if (!IN_3270 && lib3270_get_ft_state(hSession) != LIB3270_FT_STATE_NONE) |
607 | - ft_complete(get_ft_handle(hSession),_("Not in 3270 mode, transfer cancelled")); | 618 | + ft_failed(get_ft_handle(hSession),_("Not in 3270 mode, transfer cancelled")); |
608 | } | 619 | } |
609 | 620 | ||
610 | LIB3270_EXPORT LIB3270_FT_STATE lib3270_get_ft_state(H3270 *session) | 621 | LIB3270_EXPORT LIB3270_FT_STATE lib3270_get_ft_state(H3270 *session) |
ft_cut.c
@@ -334,7 +334,7 @@ static void cut_control_code(H3270 *hSession) | @@ -334,7 +334,7 @@ static void cut_control_code(H3270 *hSession) | ||
334 | trace_ds(hSession,"XFER_COMPLETE\n"); | 334 | trace_ds(hSession,"XFER_COMPLETE\n"); |
335 | cut_ack(hSession); | 335 | cut_ack(hSession); |
336 | hSession->cut_xfer_in_progress = 0; | 336 | hSession->cut_xfer_in_progress = 0; |
337 | - ft_complete(ft,N_( "Transfer complete" ) ); | 337 | + ft_complete(ft,NULL); |
338 | break; | 338 | break; |
339 | 339 | ||
340 | case SC_ABORT_FILE: | 340 | case SC_ABORT_FILE: |
@@ -369,7 +369,7 @@ static void cut_control_code(H3270 *hSession) | @@ -369,7 +369,7 @@ static void cut_control_code(H3270 *hSession) | ||
369 | if (!*buf) | 369 | if (!*buf) |
370 | strcpy(buf, N_( "Transfer cancelled by host" ) ); | 370 | strcpy(buf, N_( "Transfer cancelled by host" ) ); |
371 | } | 371 | } |
372 | - ft_complete(hSession->ft,buf); | 372 | + ft_failed(hSession->ft,buf); |
373 | lib3270_free(buf); | 373 | lib3270_free(buf); |
374 | break; | 374 | break; |
375 | 375 |
ft_dft.c
@@ -270,12 +270,12 @@ static void dft_data_insert(H3270 *hSession, struct data_buffer *data_bufr) | @@ -270,12 +270,12 @@ static void dft_data_insert(H3270 *hSession, struct data_buffer *data_bufr) | ||
270 | else if (lib3270_get_ft_state(hSession) == FT_ABORT_SENT && ((H3270FT *) hSession->ft)->abort_string != CN) | 270 | else if (lib3270_get_ft_state(hSession) == FT_ABORT_SENT && ((H3270FT *) hSession->ft)->abort_string != CN) |
271 | { | 271 | { |
272 | lib3270_free(msgp); | 272 | lib3270_free(msgp); |
273 | - ft_complete(ft,ft->abort_string); | 273 | + ft_failed(ft,ft->abort_string); |
274 | lib3270_free(ft->abort_string); | 274 | lib3270_free(ft->abort_string); |
275 | } | 275 | } |
276 | else | 276 | else |
277 | { | 277 | { |
278 | - ft_complete(hSession->ft,(char *)msgp); | 278 | + ft_failed(hSession->ft,(char *)msgp); |
279 | lib3270_free(msgp); | 279 | lib3270_free(msgp); |
280 | } | 280 | } |
281 | } else if (my_length > 0) { | 281 | } else if (my_length > 0) { |
@@ -34,6 +34,7 @@ | @@ -34,6 +34,7 @@ | ||
34 | 34 | ||
35 | LIB3270_INTERNAL void ft_aborting(H3270FT *h); | 35 | LIB3270_INTERNAL void ft_aborting(H3270FT *h); |
36 | LIB3270_INTERNAL void ft_complete(H3270FT *h, const char *errmsg); | 36 | LIB3270_INTERNAL void ft_complete(H3270FT *h, const char *errmsg); |
37 | + LIB3270_INTERNAL void ft_failed(H3270FT *h, const char *errmsg); | ||
37 | LIB3270_INTERNAL void ft_message(H3270FT *h, const char *msg); | 38 | LIB3270_INTERNAL void ft_message(H3270FT *h, const char *msg); |
38 | LIB3270_INTERNAL void ft_running(H3270FT *h, Boolean is_cut); | 39 | LIB3270_INTERNAL void ft_running(H3270FT *h, Boolean is_cut); |
39 | LIB3270_INTERNAL void ft_update_length(H3270FT *h); | 40 | LIB3270_INTERNAL void ft_update_length(H3270FT *h); |