Commit d90797ee167dad598e9758376139c6bcf2f05a98
1 parent
584e38d8
Exists in
master
and in
5 other branches
Separando notificações de transferência completa e falha para facilitar o novo d…
…iálogo de transferência de arquivos.
Showing
6 changed files
with
35 additions
and
20 deletions
Show diff stats
src/include/lib3270/filetransfer.h
| ... | ... | @@ -141,7 +141,8 @@ |
| 141 | 141 | struct lib3270_charset charset; |
| 142 | 142 | |
| 143 | 143 | // Callbacks |
| 144 | - void (*complete)(struct _h3270ft *ft,unsigned long length,double kbytes_sec); | |
| 144 | + void (*complete)(struct _h3270ft *ft,unsigned long length,double kbytes_sec,const char *msg); | |
| 145 | + void (*failed)(struct _h3270ft *ft,unsigned long length,double kbytes_sec,const char *msg); | |
| 145 | 146 | void (*message)(struct _h3270ft *ft, const char *msg); |
| 146 | 147 | void (*update)(struct _h3270ft *ft, unsigned long current, unsigned long length, double kbytes_sec); |
| 147 | 148 | void (*running)(struct _h3270ft *ft, int is_cut); | ... | ... |
src/lib3270/ft.c
| ... | ... | @@ -144,13 +144,19 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); |
| 144 | 144 | return EBUSY; |
| 145 | 145 | |
| 146 | 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 | 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 | 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 | 295 | ftHandle->local_file = ft_local_file; |
| 290 | 296 | ftHandle->state = LIB3270_FT_STATE_AWAIT_ACK; |
| 291 | 297 | ftHandle->complete = def_complete; |
| 298 | + ftHandle->failed = def_failed; | |
| 292 | 299 | ftHandle->message = def_message; |
| 293 | 300 | ftHandle->update = def_update; |
| 294 | 301 | ftHandle->running = def_running; |
| ... | ... | @@ -365,7 +372,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); |
| 365 | 372 | // Sending file |
| 366 | 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 | 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 | 466 | if (!flen || flen < strlen(buffer) - 1) |
| 460 | 467 | { |
| 461 | 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 | 470 | return errno = EINVAL; |
| 464 | 471 | } |
| 465 | 472 | |
| ... | ... | @@ -484,11 +491,7 @@ void ft_message(H3270FT *ft, const char *msg) |
| 484 | 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 | 496 | double kbytes_sec = 0; |
| 494 | 497 | struct timeval t1; |
| ... | ... | @@ -510,11 +513,17 @@ void ft_complete(H3270FT *ft, const char *errmsg) |
| 510 | 513 | |
| 511 | 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 | 529 | LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession) |
| ... | ... | @@ -528,7 +537,9 @@ LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession) |
| 528 | 537 | return EINVAL; |
| 529 | 538 | |
| 530 | 539 | if (session->state != LIB3270_FT_STATE_NONE) |
| 540 | + { | |
| 531 | 541 | lib3270_ft_cancel(hSession,1); |
| 542 | + } | |
| 532 | 543 | |
| 533 | 544 | if(session->local_file) |
| 534 | 545 | { |
| ... | ... | @@ -597,14 +608,14 @@ void ft_aborting(H3270FT *h) |
| 597 | 608 | static void ft_connected(H3270 *hSession, int ignored, void *dunno) |
| 598 | 609 | { |
| 599 | 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 | 614 | /* Process an abort from no longer being in 3270 mode. */ |
| 604 | 615 | static void ft_in3270(H3270 *hSession, int ignored, void *dunno) |
| 605 | 616 | { |
| 606 | 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 | 621 | LIB3270_EXPORT LIB3270_FT_STATE lib3270_get_ft_state(H3270 *session) | ... | ... |
src/lib3270/ft_cut.c
| ... | ... | @@ -334,7 +334,7 @@ static void cut_control_code(H3270 *hSession) |
| 334 | 334 | trace_ds(hSession,"XFER_COMPLETE\n"); |
| 335 | 335 | cut_ack(hSession); |
| 336 | 336 | hSession->cut_xfer_in_progress = 0; |
| 337 | - ft_complete(ft,N_( "Transfer complete" ) ); | |
| 337 | + ft_complete(ft,NULL); | |
| 338 | 338 | break; |
| 339 | 339 | |
| 340 | 340 | case SC_ABORT_FILE: |
| ... | ... | @@ -369,7 +369,7 @@ static void cut_control_code(H3270 *hSession) |
| 369 | 369 | if (!*buf) |
| 370 | 370 | strcpy(buf, N_( "Transfer cancelled by host" ) ); |
| 371 | 371 | } |
| 372 | - ft_complete(hSession->ft,buf); | |
| 372 | + ft_failed(hSession->ft,buf); | |
| 373 | 373 | lib3270_free(buf); |
| 374 | 374 | break; |
| 375 | 375 | ... | ... |
src/lib3270/ft_dft.c
| ... | ... | @@ -270,12 +270,12 @@ static void dft_data_insert(H3270 *hSession, struct data_buffer *data_bufr) |
| 270 | 270 | else if (lib3270_get_ft_state(hSession) == FT_ABORT_SENT && ((H3270FT *) hSession->ft)->abort_string != CN) |
| 271 | 271 | { |
| 272 | 272 | lib3270_free(msgp); |
| 273 | - ft_complete(ft,ft->abort_string); | |
| 273 | + ft_failed(ft,ft->abort_string); | |
| 274 | 274 | lib3270_free(ft->abort_string); |
| 275 | 275 | } |
| 276 | 276 | else |
| 277 | 277 | { |
| 278 | - ft_complete(hSession->ft,(char *)msgp); | |
| 278 | + ft_failed(hSession->ft,(char *)msgp); | |
| 279 | 279 | lib3270_free(msgp); |
| 280 | 280 | } |
| 281 | 281 | } else if (my_length > 0) { | ... | ... |
src/lib3270/ftc.h
| ... | ... | @@ -34,6 +34,7 @@ |
| 34 | 34 | |
| 35 | 35 | LIB3270_INTERNAL void ft_aborting(H3270FT *h); |
| 36 | 36 | LIB3270_INTERNAL void ft_complete(H3270FT *h, const char *errmsg); |
| 37 | + LIB3270_INTERNAL void ft_failed(H3270FT *h, const char *errmsg); | |
| 37 | 38 | LIB3270_INTERNAL void ft_message(H3270FT *h, const char *msg); |
| 38 | 39 | LIB3270_INTERNAL void ft_running(H3270FT *h, Boolean is_cut); |
| 39 | 40 | LIB3270_INTERNAL void ft_update_length(H3270FT *h); | ... | ... |
src/pw3270/filetransfer.c
| ... | ... | @@ -207,9 +207,10 @@ static void ft_dialog_save(GtkWidget *widget, const gchar *name) |
| 207 | 207 | |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | -static void ft_complete(H3270FT *ft, unsigned long length,double kbytes_sec) | |
| 210 | +static void ft_complete(H3270FT *ft, unsigned long length,double kbytes_sec, const char *msg) | |
| 211 | 211 | { |
| 212 | 212 | v3270_ft_progress_complete(GTK_WIDGET(ft->widget),length,kbytes_sec); |
| 213 | + v3270_ft_progress_set_message(GTK_WIDGET(ft->widget),gettext(msg)); | |
| 213 | 214 | } |
| 214 | 215 | |
| 215 | 216 | static void ft_message(struct _h3270ft *ft, const char *text) |
| ... | ... | @@ -255,6 +256,7 @@ gint v3270_transfer_file(GtkWidget *widget, LIB3270_FT_OPTION options, const gch |
| 255 | 256 | |
| 256 | 257 | ft->widget = progress; |
| 257 | 258 | ft->complete = ft_complete; |
| 259 | + ft->failed = ft_complete; | |
| 258 | 260 | ft->update = ft_update; |
| 259 | 261 | ft->running = ft_running; |
| 260 | 262 | ft->aborting = ft_aborting; | ... | ... |