예제 #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);
  }
}
예제 #2
0
파일: ext_imap.cpp 프로젝트: 2bj/hhvm
Variant f_imap_fetchheader(const Resource& imap_stream, int64_t msg_number,
                           int64_t options /* = 0 */) {
  if (options && ((options & ~(FT_UID|FT_INTERNAL|FT_PREFETCHTEXT)) != 0)) {
    Logger::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;
  }

  return String(mail_fetchheader_full(obj->m_stream, msgindex, NIL, NIL,
                                      (options ? options : NIL)), CopyString);
}
예제 #3
0
  void 
  ImapClient::fetchFlags(const std::string& aHost,
                         const std::string& aUserName,
                         const std::string& aPassword,
                         const std::string& aMailbox,
                         unsigned long aMessageNumber,
                         std::vector<int>& aFlagsVector,
                         const bool aUid) {
    
#include "linkage.c"
    
    
    MAILSTREAM* lSource = getMailStream(aHost, aUserName, aPassword, aMailbox, true);
    // convert aMessageNumber to message sequence number if necessary     
    std::string lSequenceNumber;
    std::stringstream lConverter;
    lConverter << aMessageNumber;
    lConverter >> lSequenceNumber; 
    char* lSequence = const_cast<char*>(lSequenceNumber.c_str());
    
    
    
    // update cache for this message (could have changed because of a call to setFlags) 
    mail_fetchflags_full(lSource, lSequence, (aUid ? FT_UID : NIL));  
    
    if (aUid) {
      aMessageNumber = mail_msgno(lSource, aMessageNumber); 
    }     
    
    MESSAGECACHE* lCache = mail_elt(lSource, aMessageNumber);
    
    if (lCache->seen == 1) {
      aFlagsVector[0] = 1;
    }
    if (lCache->deleted == 1) {
      aFlagsVector[1] = 1;
    }
    if (lCache->flagged == 1) {
      aFlagsVector[2] = 1;
    } 
    if (lCache->answered == 1) {
      aFlagsVector[3] = 1;
    }
    if (lCache->draft == 1) {
      aFlagsVector[4] = 1;
    }
    
  }
예제 #4
0
  ENVELOPE* 
  ImapClient::fetchStructure(const std::string& aHost, 
                             const std::string& aUserName, 
                             const std::string& aPassword, 
                             const std::string& aMailbox, 
                             BODY** aBody,  
                             unsigned long aMessageNumber, 
                             bool aUid,
                             std::vector<int>& aFlagsVector) 
  {
#include "linkage.c"
    *aBody = mail_newbody(); 
    MAILSTREAM* lSource = getMailStream(aHost, aUserName, aPassword, aMailbox, true);    
    
    ENVELOPE * lResult = mail_fetchstructure_full (lSource, aMessageNumber, aBody, (aUid ? FT_UID : NIL));
    
    if (!lResult) {
      throw EmailException("WRONG_ID", "Could not get message - wrong message id.");
    }
    
    if (aUid) {
      aMessageNumber = mail_msgno(lSource, aMessageNumber);
    }
    
    MESSAGECACHE* lCache = mail_elt(lSource, aMessageNumber);
    
    if (lCache->seen == 1) {
      aFlagsVector[0] = 1;
    }
    if (lCache->deleted == 1) {
      aFlagsVector[1] = 1;
    }
    if (lCache->flagged == 1) {
      aFlagsVector[2] = 1;
    }
    if (lCache->answered == 1) {
      aFlagsVector[3] = 1;
    }
    if (lCache->draft == 1) {
      aFlagsVector[4] = 1;
    }
    
    return lResult;
    
  }
예제 #5
0
  ENVELOPE * 
  ImapClient::fetchEnvelope(const std::string& aHost, 
                            const std::string& aUsername, 
                            const std::string& aPassword, 
                            const std::string& aMailbox, 
                            unsigned long aMessageNumber,
                            std::vector<int>& aFlagsVector,
                            const bool aUid) 
  {
#include "linkage.c"
    MAILSTREAM* lSource = getMailStream(aHost, aUsername, aPassword, aMailbox, true); 
    
    if (aUid) {
      aMessageNumber = mail_msgno(lSource, aMessageNumber);
    }
    
    ENVELOPE* lResult = mail_fetchenvelope(lSource, aMessageNumber);
    
    if (!lResult) {
      throw EmailException("WRONG_ID", "Could not get message - wrong message id.");
    }
    
    
    MESSAGECACHE* lCache = mail_elt(lSource, aMessageNumber);
    
    if (lCache->seen == 1) {
      aFlagsVector[0] = 1;
    }
    if (lCache->deleted == 1) {
      aFlagsVector[1] = 1;
    }
    if (lCache->flagged == 1) {
      aFlagsVector[2] = 1;
    }
    if (lCache->answered == 1) {
      aFlagsVector[3] = 1;
    }
    if (lCache->draft == 1) {
      aFlagsVector[4] = 1;
    }
    
    return  lResult;
    
  }
예제 #6
0
  long                            
  ImapClient::convertNumber(const std::string& aHost,
                            const std::string& aUserName,
                            const std::string& aPassword,
                            const std::string& aMailbox,
                            const unsigned long aMessageNumber,
                            const bool aUid) {
    
#include "linkage.c"
    
    MAILSTREAM* lSource = getMailStream(aHost, aUserName, aPassword, aMailbox, true); 
    
    if (aUid) {
      return mail_uid(lSource, aMessageNumber);
    } else {
      return mail_msgno(lSource, aMessageNumber);
    }
    
    
  }
예제 #7
0
파일: ext_imap.cpp 프로젝트: 2bj/hhvm
Variant f_imap_fetchstructure(const Resource& imap_stream, int64_t msg_number,
                              int64_t options /* = 0 */) {
  if (options && ((options & ~FT_UID) != 0)) {
    raise_warning("invalid value for the options parameter");
    return false;
  }

  if (msg_number < 1) {
    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;
  }

  BODY *body;

  mail_fetchstructure_full(obj->m_stream, msg_number, &body,
                           (options ? options : NIL));

  if (!body) {
    raise_warning("No body information available");
    return false;
  }

  Object ret(SystemLib::AllocStdClassObject());
  _php_imap_add_body(ret, body, true);

  return ret;
}
예제 #8
0
파일: ext_imap.cpp 프로젝트: 2bj/hhvm
Variant f_imap_msgno(const Resource& imap_stream, int64_t uid) {
  ImapStream *obj = imap_stream.getTyped<ImapStream>();
  return (int64_t)mail_msgno(obj->m_stream, uid);
}