#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));
}
{
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;
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)
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;
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 */
nntp_data->entries[0].first = 1;
nntp_data->entries[0].last = 0;
}
+ update_sidebar (nntp_data);
}
time (&nntp_data->nserv->check_time);