Clear statusbar's progressbar in case of NNTP xhdr/xover failure.
[claws.git] / src / etpan / nntp-thread.c
index cebdf69dcce744d7cc9a541b4dbfb4fc1baab281..3c147d26d12e6ac15886b5ac41c8a5554dcdbb07 100644 (file)
 #include "remotefolder.h"
 #include "main.h"
 #include "account.h"
+#include "statusbar.h"
 
 #define DISABLE_LOG_DURING_LOGIN
 
-#define NNTP_BATCH_SIZE 4999
+#define NNTP_BATCH_SIZE 5000
 
 static struct etpan_thread_manager * thread_manager = NULL;
 static chash * nntp_hash = NULL;
@@ -844,10 +845,13 @@ int nntp_threaded_xover(Folder * folder, guint32 beg, guint32 end, struct newsnn
         * and to allow updating any progress indicators while we work. */
        cbeg = beg;
        while (cbeg <= end && cend <= end) {
-               cend = cbeg + NNTP_BATCH_SIZE;
+               cend = cbeg + (NNTP_BATCH_SIZE - 1);
                if (cend > end)
                        cend = end;
 
+               statusbar_progress_all(cbeg - beg, end - beg, 1);
+               GTK_EVENTS_FLUSH();
+
                param.nntp = get_nntp(folder);
                param.beg = cbeg;
                param.end = cend;
@@ -863,6 +867,7 @@ int nntp_threaded_xover(Folder * folder, guint32 beg, guint32 end, struct newsnn
                        if (l != NULL)
                                newsnntp_xover_resp_list_free(l);
                        newsnntp_xover_resp_list_free(h);
+                       statusbar_progress_all(0, 0, 0);
                        return result.error;
                }
 
@@ -875,8 +880,10 @@ int nntp_threaded_xover(Folder * folder, guint32 beg, guint32 end, struct newsnn
                        l = NULL;
                }
 
-               cbeg += NNTP_BATCH_SIZE + 1;
+               cbeg += NNTP_BATCH_SIZE;
        }
+
+       statusbar_progress_all(0, 0, 0);
        
        debug_print("nntp xover - end\n");
 
@@ -937,10 +944,13 @@ int nntp_threaded_xhdr(Folder * folder, const char *header, guint32 beg, guint32
         * and to allow updating any progress indicators while we work. */
        cbeg = beg;
        while (cbeg <= end && cend <= end) {
-               cend = cbeg + NNTP_BATCH_SIZE;
+               cend = cbeg + NNTP_BATCH_SIZE - 1;
                if (cend > end)
                        cend = end;
 
+               statusbar_progress_all(cbeg - beg, end - beg, 1);
+               GTK_EVENTS_FLUSH();
+
                param.nntp = get_nntp(folder);
                param.header = header;
                param.beg = cbeg;
@@ -956,6 +966,7 @@ int nntp_threaded_xhdr(Folder * folder, const char *header, guint32 beg, guint32
                        if (l != NULL)
                                newsnntp_xhdr_free(l);
                        newsnntp_xhdr_free(h);
+                       statusbar_progress_all(0, 0, 0);
                        return result.error;
                }
 
@@ -968,8 +979,10 @@ int nntp_threaded_xhdr(Folder * folder, const char *header, guint32 beg, guint32
                        l = NULL;
                }
 
-               cbeg += NNTP_BATCH_SIZE + 1;
+               cbeg += NNTP_BATCH_SIZE;
        }
+
+       statusbar_progress_all(0, 0, 0);
        
        debug_print("nntp xhdr %s - end (%d-%d)\n", header, beg, end);