示例#1
0
/*----------------------------------------------------------------------
  Got thru the message mapping table, and remove messages with DELETED flag

   Accepts: stream -- mail stream to removed message references from
	    msgs -- pointer to message manipulation struct
	    f -- flags to use a purge criteria
  ----*/
void
msgno_exclude_deleted(MAILSTREAM *stream, MSGNO_S *msgs, char *sequence)
{
    long	  i, rawno;
    MESSAGECACHE *mc;
    int           need_isort_reset = 0;

    if(!msgs || msgs->max_msgno < 1L)
      return;

    /*
     * With 3.91 we're using a new strategy for finding and operating
     * on all the messages with deleted status.  The idea is to do a
     * mail_search for deleted messages so the elt's "searched" bit gets
     * set, and then to scan the elt's for them and set our local bit
     * to indicate they're excluded...
     */
    (void) count_flagged(stream, F_DEL);

    if(sequence)
	mail_sequence (stream,sequence);

    /*
     * Start with the end of the folder and work backwards so that
     * msgno_exclude doesn't have to shift the entire array each time when
     * there are lots of deleteds. In fact, if everything is deleted (like
     * might be the case in a huge newsgroup) then it never has to shift
     * anything. It is always at the end of the array just eliminating the
     * last one instead. So instead of an n**2 operation, it is n.
     */
    for(i = msgs->max_msgno; i >= 1L; i--)
      if((rawno = mn_m2raw(msgs, i)) > 0L && stream && rawno <= stream->nmsgs
	 && (mc = mail_elt(stream, rawno))
	 && (sequence ? mc->sequence : 1)
	 && ((mc->valid && mc->deleted) || (!mc->valid && mc->searched))){
	  msgno_exclude(stream, msgs, i, 0);
	  need_isort_reset++;
      }
    
    if(need_isort_reset)
      msgno_reset_isort(msgs);

    /*
     * If we excluded away a zoomed display, unhide everything...
     */
    if(msgs->max_msgno > 0L && any_lflagged(msgs, MN_HIDE) >= msgs->max_msgno)
      for(i = 1L; i <= msgs->max_msgno; i++)
	set_lflag(stream, msgs, i, MN_HIDE, 0);
}
示例#2
0
long dummy_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options)
{
  if ((options & CP_UID) ? mail_uid_sequence (stream,sequence) :
      mail_sequence (stream,sequence)) fatal ("Impossible dummy_copy");
  return NIL;
}
示例#3
0
文件: ext_imap.cpp 项目: 2bj/hhvm
Variant f_imap_fetch_overview(const Resource& imap_stream, const String& sequence,
                              int64_t options /* = 0 */) {
  if (options && options != FT_UID) {
    Logger::Warning("invalid value for the options parameter");
    return false;
  }

  ImapStream *obj = imap_stream.getTyped<ImapStream>();

  Array ret(Array::Create());

  long status = (options & FT_UID)
    ? mail_uid_sequence(obj->m_stream, (unsigned char *)sequence.data())
    : mail_sequence(obj->m_stream, (unsigned char *)sequence.data());

  if (status) {
    MESSAGECACHE *elt;
    ENVELOPE *env;
    for (unsigned long i = 1; i <= obj->m_stream->nmsgs; i++) {
      if (((elt = mail_elt(obj->m_stream, i))->sequence) &&
          (env = mail_fetch_structure(obj->m_stream, i, NIL, NIL))) {

        Object myoverview(SystemLib::AllocStdClassObject());
        OBJ_SET_ENTRY(myoverview, env, "subject", subject);

        if (env->from) {
          env->from->next = NULL;
          char *address = _php_rfc822_write_address(env->from);
          if (address) {
            myoverview.o_set("from", String(address, AttachString));
          }
        }
        if (env->to) {
          env->to->next = NULL;
          char *address = _php_rfc822_write_address(env->to);
          if (address) {
            myoverview.o_set("to", String(address, AttachString));
          }
        }

        OBJ_SET_ENTRY(myoverview, env, "date",        date);
        OBJ_SET_ENTRY(myoverview, env, "message_id",  message_id);
        OBJ_SET_ENTRY(myoverview, env, "references",  references);
        OBJ_SET_ENTRY(myoverview, env, "in_reply_to", in_reply_to);

        myoverview.o_set("size",     (int64_t)elt->rfc822_size);
        myoverview.o_set("uid",      (int64_t)mail_uid(obj->m_stream, i));
        myoverview.o_set("msgno",    (int64_t)i);
        myoverview.o_set("recent",   (int64_t)elt->recent);
        myoverview.o_set("flagged",  (int64_t)elt->flagged);
        myoverview.o_set("answered", (int64_t)elt->answered);
        myoverview.o_set("deleted",  (int64_t)elt->deleted);
        myoverview.o_set("seen",     (int64_t)elt->seen);
        myoverview.o_set("draft",    (int64_t)elt->draft);

        ret.append(myoverview);
      }
    }
  }

  return ret;
}