Commit ba2a2d286a0ca4e75e6ca24abea6bdf5b383d26c

Authored by Perry Werneck
1 parent b6fec630

Melhorando tratamento de timeouts durante a transferência de arquivos.

src/pw3270/v3270ft/private.h
... ... @@ -143,6 +143,7 @@
143 143  
144 144 struct v3270ft_entry * active; ///< Transferência em andamento.
145 145 H3270 * session; ///< lib3270 session handle.
  146 + unsigned long current; ///< Quantidade de bytes recebidos/enviados.
146 147 time_t timeout; ///< When the transfer will fail with timeout.
147 148  
148 149 GtkEntry * info[PROGRESS_FIELD_COUNT]; ///< Widgets com informações da transferência atual.
... ...
src/pw3270/v3270ft/v3270ftprogress.c
... ... @@ -497,10 +497,17 @@ void v3270ftprogress_update(GtkWidget *widget, unsigned long current, unsigned l
497 497 gchar * text;
498 498 v3270ftprogress * dialog = GTK_V3270FTPROGRESS(widget);
499 499  
  500 + debug("%s(current=%lu total=%lu kbytes/sec=%u)",__FUNCTION__,current,total,(unsigned int) kbytes_sec);
  501 +
500 502 if(current) {
501 503  
502   - // Tem dados, atualiza
503   - dialog->timeout = time(NULL) + 10;
  504 + if(current != dialog->current) {
  505 +
  506 + // Recebi um bloco de dados, cancelo timeout por 10 segundos.
  507 + dialog->timeout = time(NULL) + 10;
  508 + dialog->current = current;
  509 +
  510 + }
504 511  
505 512 if(total) {
506 513  
... ... @@ -528,27 +535,34 @@ void v3270ftprogress_update(GtkWidget *widget, unsigned long current, unsigned l
528 535  
529 536 gtk_progress_bar_set_fraction(dialog->progress, ((gdouble) current) / ((gdouble) total));
530 537  
531   - }
  538 + text = g_strdup_printf("%lu",total);
  539 + gtk_entry_set_text(dialog->info[PROGRESS_FIELD_TOTAL],text);
  540 + g_free(text);
532 541  
533   - }
  542 + } else {
534 543  
535   - debug("%s(current=%lu total=%lu kbytes/sec=%u)",__FUNCTION__,current,total,(unsigned int) kbytes_sec);
  544 + gtk_entry_set_text(dialog->info[PROGRESS_FIELD_TOTAL],_("N/A"));
536 545  
537   - text = g_strdup_printf("%lu",current);
538   - gtk_entry_set_text(dialog->info[PROGRESS_FIELD_CURRENT],text);
539   - g_free(text);
  546 + }
540 547  
541   - if(total) {
542   - text = g_strdup_printf("%lu",total);
543   - gtk_entry_set_text(dialog->info[PROGRESS_FIELD_TOTAL],text);
  548 + text = g_strdup_printf("%lu",current);
  549 + gtk_entry_set_text(dialog->info[PROGRESS_FIELD_CURRENT],text);
544 550 g_free(text);
  551 +
545 552 } else {
546   - gtk_entry_set_text(dialog->info[PROGRESS_FIELD_TOTAL],_("N/A"));
  553 +
  554 + // Não tem posição de arquivo
  555 + gtk_entry_set_text(dialog->info[PROGRESS_FIELD_CURRENT],_("N/A"));
  556 +
547 557 }
548 558  
549   - text = g_strdup_printf("%ld KB/s",(unsigned long) kbytes_sec);
550   - gtk_entry_set_text(dialog->info[PROGRESS_FIELD_SPEED],text);
551   - g_free(text);
  559 + if(kbytes_sec > 0) {
  560 + text = g_strdup_printf("%ld KB/s",(unsigned long) kbytes_sec);
  561 + gtk_entry_set_text(dialog->info[PROGRESS_FIELD_SPEED],text);
  562 + g_free(text);
  563 + } else {
  564 + gtk_entry_set_text(dialog->info[PROGRESS_FIELD_SPEED],"");
  565 + }
552 566  
553 567  
554 568 }
... ...