Esempio n. 1
0
static Variant HHVM_FUNCTION(imap_body, const Resource& imap_stream,
                             int64_t msg_number, int64_t options /* = 0 */) {
  if (options && ((options & ~(FT_UID|FT_PEEK|FT_INTERNAL)) != 0)) {
    raise_warning("invalid value for the options parameter");
    return false;
  }

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

  int msgindex;
  if (options & FT_UID) {
    /* This should be cached; if it causes an extra RTT to the
       IMAP server, then that's the price we pay for making sure
       we don't crash. */
    msgindex = mail_msgno(obj->m_stream, msg_number);
  } else {
    msgindex = msg_number;
  }

  if (!obj->checkMsgNumber(msgindex)) {
    return false;
  }

  unsigned long body_len = 0;
  char *body = mail_fetchtext_full(obj->m_stream, msg_number,
                                   &body_len, (options ? options : NIL));
  if (body_len == 0) {
    return empty_string;
  } else {
    return String(body, body_len, CopyString);
  }
}
Esempio n. 2
0
  std::string 
  ImapClient::fetchText(const std::string& aHost, 
                        const std::string& aUserName,
                        const std::string& aPassword,
                        const std::string& aMailbox,
                        unsigned long aMessageNumber,
                        bool aUid)
  {
#include "linkage.c"
    
    MAILSTREAM* lSource = getMailStream(aHost, aUserName, aPassword, aMailbox, true); 
    unsigned long lLenght;
    return std::string(mail_fetchtext_full(lSource, aMessageNumber, &lLenght, (aUid ? FT_UID : NIL))); 
  }