Пример #1
0
Файл: mh.c Проект: hww3/pexts
int mh_buffy (const char *path)
{
  int i, r = 0;
  struct mh_sequences mhs;
  memset (&mhs, 0, sizeof (mhs));
  
  mh_read_sequences (&mhs, path);
  for (i = 0; !r && i <= mhs.max; i++)
    if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN)
      r = 1;
  mhs_free_sequences (&mhs);
  return r;
}
Пример #2
0
Файл: mh.c Проект: hww3/pexts
static void mhs_write_one_sequence (FILE *fp, struct mh_sequences *mhs,
				    short f, const char *tag)
{
  int i;
  int first, last;
  fprintf (fp, "%s:", tag);
  
  first = -1;
  last  = -1;
  
  for (i = 0; i <= mhs->max; i++)
  {
    if ((mhs_check (mhs, i) & f))
    {
      if (first < 0)
	first = i;
      else
	last = i;
    }
    else if (first >= 0)
    {
      if (last < 0)
	fprintf (fp, " %d", first);
      else
	fprintf (fp, " %d-%d", first, last);
      
      first = -1;
      last = -1;
    }
  }
  
  if (first >= 0)
  {
    if (last < 0)
      fprintf (fp, " %d", first);
    else
      fprintf (fp, " %d-%d", first, last);
  }
  
  fputc ('\n', fp);
}
Пример #3
0
Файл: mh.c Проект: hww3/pexts
static void mh_update_maildir (struct maildir *md, struct mh_sequences *mhs)
{
  int i;
  short f;
  char *p;
  
  for (; md; md = md->next)
  {
    if ((p = strrchr (md->h->path, '/')))
      p++;
    else
      p = md->h->path;

    i = atoi (p);
    f = mhs_check (mhs, i);
    
    md->h->read    = (f & MH_SEQ_UNSEEN)  ? 0 : 1;
    md->h->flagged = (f & MH_SEQ_FLAGGED) ? 1 : 0;
    md->h->replied = (f & MH_SEQ_REPLIED) ? 1 : 0;
  }
}
Пример #4
0
Файл: mh.c Проект: kdave/neomutt
/**
 * mh_update_maildir - Update our record of flags
 * @param md  Maildir to update
 * @param mhs Sequences
 */
void mh_update_maildir(struct Maildir *md, struct MhSequences *mhs)
{
  int i;

  for (; md; md = md->next)
  {
    char *p = strrchr(md->email->path, '/');
    if (p)
      p++;
    else
      p = md->email->path;

    if (mutt_str_atoi(p, &i) < 0)
      continue;
    MhSeqFlags flags = mhs_check(mhs, i);

    md->email->read = (flags & MH_SEQ_UNSEEN) ? false : true;
    md->email->flagged = (flags & MH_SEQ_FLAGGED) ? true : false;
    md->email->replied = (flags & MH_SEQ_REPLIED) ? true : false;
  }
}
Пример #5
0
Файл: mh.c Проект: kdave/neomutt
/**
 * mh_mbox_check_stats - Implements MxOps::check_stats
 */
static int mh_mbox_check_stats(struct Mailbox *m, int flags)
{
  struct MhSequences mhs = { 0 };
  bool check_new = true;
  bool rc = false;
  DIR *dirp = NULL;
  struct dirent *de = NULL;

  /* when $mail_check_recent is set and the .mh_sequences file hasn't changed
   * since the last m visit, there is no "new mail" */
  if (C_MailCheckRecent && (mh_sequences_changed(m) <= 0))
  {
    rc = false;
    check_new = false;
  }

  if (!check_new)
    return 0;

  if (mh_read_sequences(&mhs, m->path) < 0)
    return false;

  m->msg_count = 0;
  m->msg_unread = 0;
  m->msg_flagged = 0;

  for (int i = mhs.max; i > 0; i--)
  {
    if ((mhs_check(&mhs, i) & MH_SEQ_FLAGGED))
      m->msg_flagged++;
    if (mhs_check(&mhs, i) & MH_SEQ_UNSEEN)
    {
      m->msg_unread++;
      if (check_new)
      {
        /* if the first unseen message we encounter was in the m during the
         * last visit, don't notify about it */
        if (!C_MailCheckRecent || (mh_already_notified(m, i) == 0))
        {
          m->has_new = true;
          rc = true;
        }
        /* Because we are traversing from high to low, we can stop
         * checking for new mail after the first unseen message.
         * Whether it resulted in "new mail" or not. */
        check_new = false;
      }
    }
  }

  mhs_free_sequences(&mhs);

  dirp = opendir(m->path);
  if (dirp)
  {
    while ((de = readdir(dirp)))
    {
      if (*de->d_name == '.')
        continue;
      if (mh_valid_message(de->d_name))
        m->msg_count++;
    }
    closedir(dirp);
  }

  return rc;
}