コード例 #1
0
ファイル: ext_imap.cpp プロジェクト: abacaxinho/hhvm
static char* _php_imap_parse_address(ADDRESS *addresslist, Array &paddress) {
  ADDRESS *addresstmp = addresslist;
  char *fulladdress = _php_rfc822_write_address(addresstmp);
  do {
    Object tmpvals(SystemLib::AllocStdClassObject());
    OBJ_SET_ENTRY(tmpvals, addresstmp, "personal", personal);
    OBJ_SET_ENTRY(tmpvals, addresstmp, "adl",      adl);
    OBJ_SET_ENTRY(tmpvals, addresstmp, "mailbox",  mailbox);
    OBJ_SET_ENTRY(tmpvals, addresstmp, "host",     host);
    paddress.append(tmpvals);
  } while ((addresstmp = addresstmp->next));
  return fulladdress;
}
コード例 #2
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;
}