pan-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Pan-devel] Downloading next N headers


From: Rico
Subject: Re: [Pan-devel] Downloading next N headers
Date: Fri, 21 Feb 2003 23:00:02 -0800 (PST)

--- Charles Kerr <address@hidden> wrote:
> On Fri, Feb 21, 2003 at 03:55:48AM -0800, Rico wrote:
> > To note: - version of index increased from 12 to 13 to accomodate new data
> >            member in struct _Group, i.e last_old_fetched
> >          - activating a group on mouse click downloads up to 600 headers by

> >            default
> >          - a single request for N headers from "More Download Options"
> >            triggers _two_ downloads, second one always downloads 600. Why? 
> >            [ suspecting modification made in set_group_mainthread_end() but
> >              haven't nailed it down after tracing through ]
 
Hi Charles,

> This looks pretty nice.  If I'm reading it right, the first sample will get
> the latest N articles, then a second fetch will get the next oldest set, and
> so on, which is a really nice idea.

All right! That's what it does, yes.
 
> Please bump SAMPLE_SIZE_DEFAULT into task-headers.h so that 
> articlelist, dialog_headers, and task-headers.c can all use the
> same definition.

done.
 
> Commenting the new code in task-headers.c::task_get_header_range() to
> explain what the different states are, and what will happen from them,
> would also be nice.

done.

> Lastly, making the patch against 0.13.3.93 instead of 0.13.3 would be nice.

done. I managed to apply the previous one cleanly though. But the one I've
included might just put you guys more at ease.  :)

> In all though, I really like this idea.

cool. Good start for me, though I still gotta look into the two downloads 
triggered thingy... But for now, it's time to get dirrty and be off for the
party! ;-)

ciao!
Rico.
******************************************************************************
diff -u -p -3 -r pan-0.13.3.93/pan/articlelist.c
pan-0.13.3.93_src/pan/articlelist.c
--- pan-0.13.3.93/pan/articlelist.c     Thu Feb 13 20:06:39 2003
+++ pan-0.13.3.93_src/pan/articlelist.c Sat Feb 22 14:32:51 2003
@@ -3000,6 +3000,7 @@ clear_group (gpointer unused)
        return 0;
 }
 
+
 static int
 set_group_mainthread_end (gpointer p)
 {
@@ -3052,7 +3053,7 @@ set_group_mainthread_end (gpointer p)
        /* Now that the articlelist is fully loaded,
           get new headers, if required. */
        if (fetch_new_on_group_load && !group_is_folder(group))
-               queue_insert_tasks
(g_slist_append(NULL,task_headers_new(group,HEADERS_NEW)), 0);
+               queue_insert_tasks (g_slist_append(NULL,task_headers_new_sample 
(group,
SAMPLE_SIZE_DEFAULT, FALSE)), 0);
 
        debug_exit ("set_group_mainthread_end");
        return 0;
diff -u -p -3 -r pan-0.13.3.93/pan/base/file-grouplist.c
pan-0.13.3.93_src/pan/base/file-grouplist.c
--- pan-0.13.3.93/pan/base/file-grouplist.c     Fri Jan 24 01:47:18 2003
+++ pan-0.13.3.93_src/pan/base/file-grouplist.c Sat Feb 22 14:32:51 2003
@@ -131,7 +131,7 @@ read_group_data (Server        * server,
        groups = g_ptr_array_new ();
        if (version==1 || version==2 || version==3 || version==4 || 
            version==5 || version==6 || version==7 || version==8 ||
-           version==9 || version==10 || version==11 || version==12)
+           version==9 || version==10 || version==11 || version==12 || 
version==13)
        {
                long i;
                long qty = get_next_token_long (march_idx, '\n', &march_idx);
@@ -238,6 +238,10 @@ read_group_data (Server        * server,
                                g->article_high_old = (gulong)  
get_next_token_ulong (march_idx, '\n',
&march_idx);
                        else
                                g->article_high_old =  g->article_high;
+                       
+                       /* article_last_low_fetched added in version 13 */
+                       if (version>=13)
+                               g->article_last_low_fetched = (gulong) 
get_next_token_ulong (march_idx,
'\n', &march_idx);
 
                        g->article_qty      = (gint32)  get_next_token_int   
(march_idx, '\n',
&march_idx);
                        g->article_read_qty = (gint32)  get_next_token_int   
(march_idx, '\n',
&march_idx);
@@ -412,7 +416,7 @@ write_groups (FILE * idx_fp, FILE * dat_
 
        /* Write the group information... */
        pos = 0;
-       fprintf (idx_fp, "12\n"); /* file format version number */
+       fprintf (idx_fp, "13\n"); /* file format version number */
        fprintf (idx_fp, "%u\n", groups->len); /* number of groups */
        for (i=0; i!=groups->len; ++i)
        {
@@ -439,7 +443,7 @@ write_groups (FILE * idx_fp, FILE * dat_
                /* write the non-string fields. */
                fprintf (idx_fp,
                         "%ld\n" "%ld\n" "%ld\n" "%ld\n" "%ld\n" "%ld\n" 
"%ld\n" "%ld\n"
-                        "%u\n" "%lu\n" "%lu\n" "%d\n" "%d\n" "%d\n" "%lu\n" 
"%lu\n" "%lu\n"
"%d\n" "%d\n" "%c\n",
+                        "%u\n" "%lu\n" "%lu\n" "%d\n" "%d\n" "%d\n" "%lu\n" 
"%lu\n" "%lu\n"
"%lu\n" "%d\n" "%d\n" "%c\n",
                         name_idx, desc_idx, path_idx, char_idx, news_idx, 
dead_idx,
filt_idx, iden_idx,
                         (unsigned)(group->flags & ~GROUP_NEW),
                         group->filter_show,
@@ -450,6 +454,7 @@ write_groups (FILE * idx_fp, FILE * dat_
                         (unsigned long)group->article_low,
                         (unsigned long)group->article_high,
                         (unsigned long)group->article_high_old,
+                        (unsigned long)group->article_last_low_fetched,
                         (int)group->article_qty,
                         (int)group->article_read_qty,
                         (char)(group->permission!='\0' ? group->permission : 
'?'));
diff -u -p -3 -r pan-0.13.3.93/pan/base/group.h
pan-0.13.3.93_src/pan/base/group.h
--- pan-0.13.3.93/pan/base/group.h      Tue Dec 10 19:22:34 2002
+++ pan-0.13.3.93_src/pan/base/group.h  Sat Feb 22 14:32:51 2003
@@ -92,6 +92,7 @@ typedef struct _Group
        gint32         article_qty;                      /* (read only) # of 
articles
in group */
        gint32         article_read_qty;                 /* (read only) # of 
read
articles */
        gulong         article_low;                      /* (read only) low 
article
number */
+       gulong         article_last_low_fetched;
        gulong         article_high;                     /* (read only) high 
article
number */
        gulong         article_high_old;                 /* (read only) 
previous high
article */
 
diff -u -p -3 -r pan-0.13.3.93/pan/dialogs/dialog-headers.c
pan-0.13.3.93_src/pan/dialogs/dialog-headers.c
--- pan-0.13.3.93/pan/dialogs/dialog-headers.c  Mon Nov 25 22:08:10 2002
+++ pan-0.13.3.93_src/pan/dialogs/dialog-headers.c      Sat Feb 22 14:32:51 2003
@@ -205,10 +205,11 @@ dialog_download_headers (GtkWindow * par
        /* some new headers */
        hbox = gtk_hbox_new (FALSE, 0);
        w = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON(w),
_("Download _recent headers: "));
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), TRUE);
        gtk_box_pack_start (GTK_BOX(hbox), w, FALSE, FALSE, 0);
        dialog->latest_n_headers_rb = w;
        adj = GTK_ADJUSTMENT(gtk_adjustment_new (
-               150, 0, INT_MAX, 50, 50, 1));
+               600, 0, INT_MAX, 50, 50, 1));
        w = gtk_spin_button_new (adj, 1, 0);
        gtk_box_pack_start (GTK_BOX(hbox), w, FALSE, FALSE, 0);
        dialog->n_headers_spinbutton = w;
diff -u -p -3 -r pan-0.13.3.93/pan/task-headers.c
pan-0.13.3.93_src/pan/task-headers.c
--- pan-0.13.3.93/pan/task-headers.c    Fri Jan 24 19:26:28 2003
+++ pan-0.13.3.93_src/pan/task-headers.c        Sat Feb 22 14:32:51 2003
@@ -46,8 +46,6 @@
 **********************  Defines / Enumerated types
 *********************/
 
-#define SAMPLE_SIZE_DEFAULT 150
-
 /*********************
 **********************  Macros
 *********************/
@@ -259,6 +257,10 @@ task_headers_run_download (Task * task, 
                        state_set = TRUE;
                        state = result;
                }
+               else {
+                       task_h->group->article_last_low_fetched = low_to_fetch;
+                       task_h->group->article_high_old = 
task_h->group->article_high;
+               }
 
                if (1)
                {
@@ -378,12 +380,12 @@ task_headers_run_download (Task * task, 
 static int
 task_get_header_range (TaskHeaders   * task,
                        PanSocket     * sock,
-                      gulong        * setme_lo_article_in_group,
-                      gulong        * setme_hi_article_in_group,
+                              gulong        * setme_lo_article_in_group,
+                              gulong        * setme_hi_article_in_group,
                        gulong        * setme_lo_article_to_fetch,
-                      gulong        * setme_hi_article_to_fetch,
-                      gulong        * setme_total_in_group,
-                      const char   ** setme_progress_fmt)
+                              gulong        * setme_hi_article_to_fetch,
+                              gulong        * setme_total_in_group,
+                              const char   ** setme_progress_fmt)
 {
        const gboolean * const abort = &TASK(task)->hint_abort;
        Group *group = TASK_HEADERS(task)->group;
@@ -432,14 +434,32 @@ task_get_header_range (TaskHeaders   * t
                hi_article_to_fetch = hi_article_in_group;
                progress_fmt = _("New %lu of %lu");
        }
-
        else if (dl_type==HEADERS_SAMPLE)
        {
+/*  Two cases to consider when sampling:-
+       1) We already have the very latest article(s) on the server
+               i)  Are there articles sandwich'ed between the last article 
from the
previous 
+                   download and the highest local article _before_ the 
download ?
+               ii) Are there articles older than the very lowest local one ?
+       2) When we don't have the very latest articles, then we get them 
+*/     
                const int qty = MIN (total_in_group, task->sample_size);
                status_item_emit_status_va (
                        STATUS_ITEM(task), _("Sampling %d articles"), qty);
-               lo_article_to_fetch = hi_article_in_group - qty;
-               hi_article_to_fetch = hi_article_in_group;
+               if(hi_article_in_group == group->article_high) {
+                       if(group->article_last_low_fetched - 
group->article_high_old > 1) {
+                               hi_article_to_fetch = 
group->article_last_low_fetched - 1;
+                               lo_article_to_fetch = hi_article_to_fetch - qty;
+                       }
+                       else if(group->article_low > lo_article_in_group) {
+                               hi_article_to_fetch = group->article_low - 1;
+                               lo_article_to_fetch = hi_article_to_fetch - qty;
+                       }
+               }
+               else {
+                       lo_article_to_fetch = hi_article_in_group - qty;
+                       hi_article_to_fetch = hi_article_in_group;
+               }
                progress_fmt = _("Sampling %lu of %lu");
        }
        else if (dl_type==HEADERS_ALL)
diff -u -p -3 -r pan-0.13.3.93/pan/task-headers.h
pan-0.13.3.93_src/pan/task-headers.h
--- pan-0.13.3.93/pan/task-headers.h    Sun Aug  4 23:50:53 2002
+++ pan-0.13.3.93_src/pan/task-headers.h        Sat Feb 22 14:32:51 2003
@@ -29,6 +29,7 @@
 **/
 
 #define TASK_HEADERS(a) ((TaskHeaders *)a)
+#define SAMPLE_SIZE_DEFAULT 600
 
 typedef struct _TaskHeaders TaskHeaders;



__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]