[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pan-devel] Downloading next N headers
From: |
Rico |
Subject: |
[Pan-devel] Downloading next N headers |
Date: |
Fri, 21 Feb 2003 03:55:48 -0800 (PST) |
Hello All!
Pan is some awesome piece of beautiful code. Just for fun I've been working on
this feature that I like from O.E. It was brought up before. Could you
guys have a look at the following? I would really appreciate some comments.
What would be the pro's and con's of such a feature? [Actually, it's not so
undesirable since Haran mentioned how the current way of downloading just a
sample of N _new_ headers is sometimes limiting... ]
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 ]
Thanks for any input.
Rico.
*******************************************************************************
diff -u -p -3 -r pan-0.13.3/pan/articlelist.c ../pan-0.13.3/pan/articlelist.c
--- pan-0.13.3/pan/articlelist.c Fri Dec 20 20:36:14 2002
+++ ../pan-0.13.3/pan/articlelist.c Fri Feb 14 02:15:38 2003
@@ -2970,6 +2970,8 @@ clear_group (gpointer unused)
return 0;
}
+#define SAMPLE_SIZE_DEFAULT 600
+
static int
set_group_mainthread_end (gpointer p)
{
@@ -3022,7 +3024,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/pan/base/file-grouplist.c
../pan-0.13.3/pan/base/file-grouplist.c
--- pan-0.13.3/pan/base/file-grouplist.c Fri Dec 20 20:36:16 2002
+++ ../pan-0.13.3/pan/base/file-grouplist.c Fri Feb 14 02:23:04 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/pan/base/group.h ../pan-0.13.3/pan/base/group.h
--- pan-0.13.3/pan/base/group.h Tue Dec 10 19:22:34 2002
+++ ../pan-0.13.3/pan/base/group.h Tue Feb 11 18:42:37 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/pan/dialogs/dialog-headers.c
../pan-0.13.3/pan/dialogs/dialog-headers.c
--- pan-0.13.3/pan/dialogs/dialog-headers.c Mon Nov 25 22:08:10 2002
+++ ../pan-0.13.3/pan/dialogs/dialog-headers.c Thu Feb 20 01:55:56 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/pan/task-headers.c ../pan-0.13.3/pan/task-headers.c
--- pan-0.13.3/pan/task-headers.c Sun Aug 4 23:50:53 2002
+++ ../pan-0.13.3/pan/task-headers.c Fri Feb 14 01:31:44 2003
@@ -45,7 +45,7 @@
********************** Defines / Enumerated types
*********************/
-#define SAMPLE_SIZE_DEFAULT 150
+#define SAMPLE_SIZE_DEFAULT 600
/*********************
********************** Macros
@@ -258,6 +258,10 @@ task_headers_run (Task* task)
retval_set = TRUE;
retval = 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)
@@ -434,8 +438,20 @@ task_get_header_range (TaskHeaders * t
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)
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/
- [Pan-devel] Downloading next N headers,
Rico <=