Rocco Rutte:
authorpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Sun, 14 Aug 2005 12:18:04 +0000 (12:18 +0000)
committerpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Sun, 14 Aug 2005 12:18:04 +0000 (12:18 +0000)
- 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 <buffy-cycle>) (reported by Peter J. Holzer <hjp@hjp.at>)
- 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
nntp/newsrc.c
nntp/nntp.c
nntp/nntp.h

index 8469724..c3b9c14 100644 (file)
@@ -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
index ef9537e..bc1e99c 100644 (file)
@@ -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';
 }
index de68916..29ac491 100644 (file)
@@ -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;
index 3e40fb7..0dbcc39 100644 (file)
@@ -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 *,