Rocco Rutte:
authorpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Sun, 14 Aug 2005 13:59:01 +0000 (13:59 +0000)
committerpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Sun, 14 Aug 2005 13:59:01 +0000 (13:59 +0000)
- add newsgroup counters to sidebar, <buffy-cycle> still broken
- improve nntp_buffy to start off at next from current instead of current

git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@404 e385b8ad-14ed-0310-8656-cc95a2468c6d

nntp/newsrc.c
nntp/nntp.c

index bc1e99c..a8e1576 100644 (file)
@@ -1074,8 +1074,10 @@ void nntp_buffy (char* dst, size_t dstlen) {
     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)
+        str_cmp (data->group, ((NNTP_DATA *) Context->data)->group) == 0) {
+      list = list->next;
       break;
+    }
   }
 
   *dst = '\0';
index 29ac491..4875f67 100644 (file)
@@ -22,6 +22,8 @@
 #include "rfc1524.h"
 #include "rfc2047.h"
 #include "nntp.h"
+#include "sidebar.h"
+#include "buffy.h"
 
 #include "mutt_crypt.h"
 
 
 static unsigned int _checked = 0;
 
+static void update_sidebar (NNTP_DATA* data) {
+  int i = 0;
+  BUFFY* tmp = NULL;
+  char buf[STRING];
+
+  if (list_empty (Incoming))
+    return;
+
+  /* unfortunately, NNTP_DATA::group only is the plain
+   * group name, so for every single update, we need to
+   * compose the full string which must be defined via
+   * mailboxes command ;-((( FIXME
+   */
+  buf[0] = '\0';
+  snprintf (buf, sizeof (buf), "nntp%s://%s%s/%s",
+            (data->nserv->conn->account.flags & M_ACCT_SSL) ? "s" : "",
+            NONULL (data->nserv->conn->account.user),
+            data->nserv->conn->account.host,
+            data->group);
+  debug_print (4, ("group == '%s'\n", buf));
+
+  /* bail out if group not found via mailboxes */
+  if ((i = buffy_lookup (buf)) < 0)
+    return;
+
+  tmp = (BUFFY*) Incoming->data[i];
+  /* copied from browser.c */
+  if (option (OPTMARKOLD) &&
+      data->lastCached >= data->firstMessage &&
+      data->lastCached <= data->lastMessage)
+    tmp->msg_unread = data->lastMessage - data->lastCached;
+  else
+    tmp->msg_unread = data->unread;
+  tmp->new = data->unread > 0;
+  /* this is closest to a "total" count we can get */
+  tmp->msgcount = data->lastMessage - data->firstMessage;
+}
+
 static void nntp_error (const char *where, const char *msg) {
   debug_print (1, ("unexpected response in %s: %s\n", where, msg));
 }
@@ -1095,6 +1135,8 @@ void nntp_fastclose_mailbox (CONTEXT * ctx)
   if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL
       || tmp != data)
     nntp_delete_data (data);
+  else
+    update_sidebar (data);
 }
 
 /* commit changes and terminate connection */
@@ -1181,6 +1223,7 @@ static int _nntp_check_mailbox (CONTEXT * ctx, NNTP_DATA * nntp_data)
       nntp_data->entries[0].first = 1;
       nntp_data->entries[0].last = 0;
     }
+    update_sidebar (nntp_data);
   }
 
   time (&nntp_data->nserv->check_time);