Пример #1
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;
    
  }
Пример #2
0
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;
}