From 86d529600952d1b3606e2b163a4edefbf988d1b9 Mon Sep 17 00:00:00 2001 From: pdmef Date: Sun, 14 Aug 2005 12:18:04 +0000 Subject: [PATCH] Rocco Rutte: - modify nntp_buffy() to offer _next_ group with new articles instead of _first_ when attempting to change group (partially strange ordering of groups remains) (still this needs to be handled via ) (reported by Peter J. Holzer ) - display some progress while fetching NNTP headers from cache git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@402 e385b8ad-14ed-0310-8656-cc95a2468c6d --- curs_main.c | 2 +- nntp/newsrc.c | 48 +++++++++++++++++++++++++++++++++++------------- nntp/nntp.c | 10 +++++++--- nntp/nntp.h | 2 +- 4 files changed, 44 insertions(+), 18 deletions(-) diff --git a/curs_main.c b/curs_main.c index 8469724..c3b9c14 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1187,7 +1187,7 @@ int mutt_index_menu (void) cp = _("Open newsgroup in read-only mode"); else cp = _("Open newsgroup"); - nntp_buffy (buf); + nntp_buffy (buf, sizeof (buf)); } else #endif diff --git a/nntp/newsrc.c b/nntp/newsrc.c index ef9537e..bc1e99c 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -1065,26 +1065,48 @@ NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER * news, char *group) } /* this routine gives the first newsgroup with new messages */ -void nntp_buffy (char *s) -{ +void nntp_buffy (char* dst, size_t dstlen) { LIST *list; + int count = 0; + /* forward to current group */ for (list = CurrentNewsSrv->list; list; list = list->next) { NNTP_DATA *data = (NNTP_DATA *) list->data; + if (data && data->subscribed && data->unread && + Context && Context->magic == M_NNTP && + str_cmp (data->group, ((NNTP_DATA *) Context->data)->group) == 0) + break; + } + + *dst = '\0'; + + while (count < 2) { - if (data && data->subscribed && data->unread) { - if (Context && Context->magic == M_NNTP && - !str_cmp (data->group, ((NNTP_DATA *) Context->data)->group)) { - unsigned int i, unread = 0; + if (!list) + list = CurrentNewsSrv->list; - for (i = 0; i < Context->msgcount; i++) - if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted) - unread++; - if (!unread) - continue; + for (; list; list = list->next) { + NNTP_DATA *data = (NNTP_DATA *) list->data; + + if (data && data->subscribed && data->unread) { + if (Context && Context->magic == M_NNTP && + !str_cmp (data->group, ((NNTP_DATA *) Context->data)->group)) { + unsigned int i, unread = 0; + + for (i = 0; i < Context->msgcount; i++) + if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted) + unread++; + if (!unread) + continue; + } + strncpy (dst, data->group, dstlen); + break; } - strcpy (s, data->group); - break; } + /* done if found */ + if (dst && *dst) + return; + count++; } + *dst = '\0'; } diff --git a/nntp/nntp.c b/nntp/nntp.c index de68916..29ac491 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -641,6 +641,7 @@ static int nntp_fetch_headers (CONTEXT * ctx, unsigned int first, { char buf[HUGE_STRING]; char *msg = _("Fetching message headers..."); + char *msg2 = _("Fetching headers from cache..."); NNTP_DATA *nntp_data = ((NNTP_DATA *) ctx->data); int ret; int num; @@ -682,10 +683,10 @@ static int nntp_fetch_headers (CONTEXT * ctx, unsigned int first, num = nntp_data->lastCached - first + 1; if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0) { nntp_cache_expand (buf, nntp_data->cache); - mutt_message _("Fetching headers from cache..."); + mutt_message (msg2); if ((f = safe_fopen (buf, "r"))) { - int r = 0; + int r = 0, c = 0; /* counting number of lines */ while (fgets (buf, sizeof (buf), f) != NULL) @@ -697,8 +698,11 @@ static int nntp_fetch_headers (CONTEXT * ctx, unsigned int first, fc.first = first; fc.last = first + num - 1; fc.msg = NULL; - while (fgets (buf, sizeof (buf), f) != NULL) + while (fgets (buf, sizeof (buf), f) != NULL) { + if (ReadInc && ((++c) % ReadInc == 0)) + mutt_message ("%s %d/%d", msg2, c, r); add_xover_line (buf, &fc); + } fclose (f); nntp_data->lastLoaded = fc.last; first = fc.last + 1; diff --git a/nntp/nntp.h b/nntp/nntp.h index 3e40fb7..0dbcc39 100644 --- a/nntp/nntp.h +++ b/nntp/nntp.h @@ -111,7 +111,7 @@ int nntp_fetch_message (MESSAGE *, CONTEXT *, int); int nntp_post (const char *); int nntp_check_msgid (CONTEXT *, const char *); int nntp_check_children (CONTEXT *, const char *); -void nntp_buffy (char *); +void nntp_buffy (char* dst, size_t dstlen); void nntp_expand_path (char *, size_t, ACCOUNT *); void nntp_logout_all (); const char *nntp_format_str (char *, size_t, char, const char *, const char *, -- 2.20.1