亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? mailmessage.cpp

?? funambol windows mobile plugin source code, the source code is taken from the funambol site
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/**
 * Format a mailmessage in a RFC2822 string
 */
char * MailMessage::format() {

    // If the message is empty, return null
    if ( empty() ) {
        LOG.debug("MailMessage::format: empty message.");
        return 0;
    }

    StringBuffer ret;

    LOG.debug("MailMessage::format START");

    if ( contentType.empty() ) {
        if ( attachments.size() ) {
            contentType = "multipart/mixed";
        }
        else {
            contentType = body.getMimeType();

            if (headers.size() > 0) {
                StringBuffer *line; int j = 0;
                for (line=(StringBuffer *)headers.front(); line; line=(StringBuffer *)headers.next() ) {
                    if (strstr(line->c_str(), "format=") != 0
                        || strstr(line->c_str(),"reply-type=") != 0 ) {
                            contentType.append("; ");
                            line->replaceAll(";", " ");
                            contentType.append(line->c_str());
                            headers.removeElementAt(j);
                            j--;
                         }
                     j++;
                }
            }

        }
    }
    if ( mimeVersion.empty() ) {
        mimeVersion = "1.0";
    }

    // Add generics headers
    ret.join((ArrayList &)headers, NL);
    // Add parsed headers
    ret += MIMEVERS; ret += mimeVersion; ret += NL;
    ret += MESSAGEID; ret += messageId; ret += NL;
    LOG.debug("MailMessage: From: %s\n", from.c_str());
    ret += FROM; ret += from; ret += NL;
    ret += TO; ret += to; ret += NL;
    if (cc.length() ) {
        ret += CC; ret += cc; ret += NL;
    }
    if (bcc.length() ) {
        ret += BCC; ret += bcc; ret += NL;
    }
    ret += DATE; ret += date.formatRfc822(); ret += NL;
    ret += SUBJECT;

    ret += encodeHeader(subject);

    ret += NL;
    ret += MIMETYPE; ret += contentType; ret+= "; ";
    if (contentType.ifind(MULTIPART) != StringBuffer::npos ){
        if ( boundary.empty() ) {
            generateBoundary(boundary);
        }
        ret += "\n boundary=\""; ret += boundary;
        ret += "\"\n\nThis is a multi-part message in MIME format.\n";
        // Prepare a string with the boundary on a line alone
        StringBuffer bound = "\n--"; bound += boundary;
        // Body
        ret += bound; ret += NL;
        ret += formatBodyPart(body);
        ret += bound;
        // Attachments
        const BodyPart *part;
        for ( part=(const BodyPart *)attachments.front();
              part;
              part=(BodyPart *)attachments.next() ) {
            ret += NL;
            ret += formatBodyPart(*part);
            ret += bound;
        }
        ret += "--\n";
    }
    else {
        // Body
        if(body.getCharset())
            ret += CT_CHARSET; ret += body.getCharset(); ret += NL;
        if( body.getEncoding() )
            ret += ENCODING; ret += body.getEncoding();
        // end of headers
        ret += NL;
        ret += NL;
        ret += body.getContent(); ret += NL;
    }
    LOG.debug("MailMessage::format END");
	return stringdup(ret.c_str());
}


int MailMessage::parse(const char *rfc2822, size_t len) {
    StringBuffer s(rfc2822, len);
    int rc;

    LOG.debug("MailMessage::parse START");

    size_t hdrlen = getHeadersLen(s, newline);

    StringBuffer headers = s.substr(0, hdrlen);    
    StringBuffer rfcbody;

    rc = parseHeaders(headers);
    if(rc)
        return rc;

    if(contentType.ifind(MULTIPART) != StringBuffer::npos) {
        // Multipart message
        rfcbody = s.substr(hdrlen);
        rc= parseBodyParts(rfcbody);
    }
    else {
        // go to the beginning of the body
        hdrlen = hdrlen + strlen(newline) + strlen(newline);
        rfcbody = s.substr(hdrlen);
        body.setMimeType(contentType);
        // FIXME: handle all encodings, not only quoted-printable
        if( strcmp(body.getEncoding(), "quoted-printable") == 0 ) {
            char *decoded = qp_decode( rfcbody );
            body.setContent ( decoded );
            delete [] decoded;
        }
        else if ( strcmp(body.getEncoding(), "base64") == 0 ) {
            char *decoded = NULL;
            size_t len = 0;
            rc = uudecode( rfcbody, &decoded, &len ) ;
            if( !rc ) {
                body.setContent ( decoded );
                delete [] decoded;
            }
        }
        else body.setContent(rfcbody);
    }

    LOG.debug("MailMessage::parse END");
    return rc;
}

StringBuffer decodeHeader(StringBuffer line) {

    if (!line || line.empty()) {
        return line;
    }

    size_t startPos = 0;
    StringBuffer ret;
    StringBuffer charset;
    while( (startPos = line.find("=?", startPos)) != StringBuffer::npos) {
        // Skip the '=?'
        startPos += 2;
        // Find the first '?'
        size_t firstMark = line.find("?", startPos);
        if (firstMark == StringBuffer::npos) {
            LOG.error("Invalid encoded header");
            return line;
        }
        // Find the second '?'
        size_t secondMark = line.find("?", firstMark+1);
        if (secondMark == StringBuffer::npos) {
            LOG.error("Invalid encoded header");
            return line;
        }
        // Find the final '?='
        size_t endPos = line.find("?=", secondMark+1);
        if (endPos == StringBuffer::npos) {
            LOG.error("Invalid encoded header");
            return line;
        }

        charset = line.substr(startPos, firstMark - startPos);
        StringBuffer encoding = line.substr(firstMark+1, secondMark - (firstMark + 1));
        StringBuffer text = line.substr(secondMark+1, endPos - (secondMark + 1));

        if (encoding == "Q") {
            // quoted-printable
            text.replaceAll("_", " ");
            char* dec = qp_decode(text);
            if (startPos >= 2 &&  ret.length() == 0) {
                ret += line.substr(0, startPos - 2);
            }

            ret += dec;
            delete [] dec;
        }
        else if (encoding == "B"){
        // base64
            char* dec = new char[text.length()];
            int len = b64_decode((void *)dec, text);
            dec[len]=0;
            if (startPos >= 2 &&  ret.length() == 0) {
                ret += line.substr(0, startPos - 2);
            }
            ret += dec;
            delete [] dec;
        }

        startPos = endPos;
    }

    if (ret.length() == 0) {
        ret += line;
    }

    WCHAR* wret = toWideChar(ret, charset);
    ret.set(NULL);
    char* t = toMultibyte(wret);
    ret.set(t);
    if (wret) {delete [] wret;}
    if (t) {delete [] t;}
    return ret;
}


//---------------------------------------------------------- Private Methods

int MailMessage::parseHeaders(StringBuffer &rfcHeaders) {

    ArrayList lines;
    const StringBuffer *line;
    StringBuffer strReceived;
    BOOL receivedExtracted = FALSE;
    LOG.debug("parseHeaders START");

    // Join header parts using \t or 8 blank
    StringBuffer joinlinetab("\t");
    rfcHeaders.replaceAll(joinlinetab, " ");

    StringBuffer joinlinespaces(newline);
    joinlinespaces+=" ";  // 8 blanks

    rfcHeaders.replaceAll(joinlinespaces, " ");

    rfcHeaders.split(lines, newline);

    for ( line=(StringBuffer *)lines.front();
		  line;
		  line=(StringBuffer *)lines.next() ) {

        if( *line == "\r" )
            break;
        // The first empty line marks the end of the header section
        if( line->empty() ){
            break;
        }
        // Process the headers
        bool unknown=false;

        if( line->ifind(TO) == 0 ){
            to = decodeHeader(line->substr(TO_LEN));
        }
        else if( line->ifind(FROM) == 0 ) {
            from = decodeHeader(line->substr(FROM_LEN));
        }
        else if( line->ifind(CC) == 0 ) {
            cc = decodeHeader(line->substr(CC_LEN));
        }
        else if( line->ifind(BCC) == 0 ) {
            bcc = decodeHeader(line->substr(BCC_LEN));
        }
        else if ( line->ifind(DATE) == 0 ) {
            //subjectParsing = FALSE;
            if( date.parseRfc822(line->substr(DATE_LEN)) ) {
                LOG.error("Error parsing date");
                return 500;
            }
        }
        else if( line->ifind(SUBJECT) == 0 ) {

            subject = decodeHeader(line->substr(SUBJECT_LEN));
            LOG.debug("SUBJECT: %s", subject.c_str());
        }
        else if( line->ifind(ENCODING) == 0 ) {  // it is here for single part only
            body.setEncoding(line->substr(ENCODING_LEN));
        }
        else if(line->ifind(MIMEVERS) == 0 ) {
            mimeVersion = line->substr(MIMEVERS_LEN);
        }
        else if(line->ifind(MESSAGEID) == 0 ) {
            messageId = line->substr(MESSAGEID_LEN);
        }
        else if( line->ifind(MIMETYPE) == 0 ) {

            StringBuffer sb = getTokenValue(line, MIMETYPE);

            if (sb.length() > 0)
                contentType = sb;

            sb.reset();
            sb = getTokenValue(line, "boundary=", false);

            if (sb.length() > 0) {
                boundary = sb;
            } else {
                body.setCharset(getTokenValue(line, CT_CHARSET));
            }
            /*

            size_t len = line->find(";") - MIMETYPE_LEN ;
            contentType = line->substr(MIMETYPE_LEN, len);

            // Save boundary for multipart
            size_t begin = line->ifind("boundary=");
            size_t end = StringBuffer::npos;

            if( begin != StringBuffer::npos ) {
                begin += strlen("boundary=\"");
			    end = line->find("\"", begin) ;
			    boundary = line->substr( begin, end-begin );
		    }
            else {
                    begin=line->ifind(CT_CHARSET);
                if( begin != StringBuffer::npos ) {
                    begin += strlen(CT_CHARSET);
                    size_t end = begin;
                    size_t quote = line->find("\"", begin);
                    if (quote != StringBuffer::npos){
                        begin = quote + 1;
                        end = line->find("\"", begin) ;
                    }
                    else {
                        end = line->find(";", begin) ;
                        if (end == StringBuffer::npos) {
                            end = line->find(" ", begin);
                        }
                    }
                    body.setCharset( line->substr( begin, end-begin ) );
                }
            }
            */
	    }
        else if(line->ifind(RECEIVED) == 0) {
            if (!receivedExtracted) {
                strReceived = line->substr(line->rfind(";") );

                if (!strReceived.empty()) {
                    received.parseRfc822(strReceived.substr(2));
                    receivedExtracted = TRUE;
                }
                /*
                while (!strReceived.empty()) {
                    if (received.parseRfc822(strReceived.substr(2)) == 0) {
                        receivedExtracted = TRUE;
                        break;
                    } else {
                        StringBuffer s(line->substr(line->rfind(strReceived.c_str())));
                        strReceived = line->substr(s.rfind(";"));
                    }
                }
                */

            }
        }
        else {
            headers.add(*(StringBuffer *)line);
        }

    }
    // If received was not found, copy send date
    if( received == BasicTime() ){
        received = date;
    }
    LOG.debug("parseHeaders END");

	// FIXME: should check for mandatory headers before return 0
	return 0;
}


int MailMessage::parseBodyParts(StringBuffer &rfcBody) {

    BodyPart part;
    // The boundary is the one defined in the headers preceded by
    // a newline and two hypens
    StringBuffer bound("\n--");
    bound += boundary;

    LOG.debug("parseBodyParts START");

    size_t nextBoundary = rfcBody.find(bound);
    getBodyPart(rfcBody, bound, body, nextBoundary, false);

    if (contentType.ifind("multipart/alternative") == StringBuffer::npos) {
        // If it's not multipart/alternative, get the other parts
        while( getBodyPart(rfcBody, bound, part, nextBoundary, true) ) {
            // some problem in the attachment?
            if( part.getContent() ) {
                attachments.add(part);
            }
            else LOG.error("Empty content in attachment.");
            part = BodyPart();
        }
    }

    LOG.debug("parseBodyParts END");
    return 0;
}

// Return true if the instance is empty (a valid MailMessage must have a valid date that is not
// the default 1/1/1970)
bool MailMessage::empty() {
    return ( this->getDate() == BasicTime() );
}

ArrayElement* MailMessage::clone() {
    return new MailMessage(*this);
}


void MailMessage::setHeaders(const char* chExtraHeaders)
{
    if(chExtraHeaders){
        StringBuffer extraHeaders(chExtraHeaders);
        ArrayList lines;
        extraHeaders.split(headers, "\n");
    }
}

/**
 * The result must be deleted by caller
 */
const char* MailMessage::getHeaders()
{
    if( headers.size() ) {
        StringBuffer buff;
        buff.join(headers, "\n");
        char* strHeaders = stringdup(buff.c_str(), buff.length() -1);
        return strHeaders;
    }
    else return 0;
}

bool MailMessage::operator==(MailMessage& that){
    return (
        this->to == that.to &&
        this->from == that.from &&
        this->cc == that.cc &&
        this->bcc == that.bcc &&
        this->subject == that.subject &&

        this->date == that.date &&
        this->received == that.received &&

        this->contentType == that.contentType &&
        this->boundary == that.boundary &&
        this->mimeVersion == that.mimeVersion &&
        this->messageId == that.messageId
        );
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩精品中文字幕一区二区三区| 亚洲三级理论片| 亚洲成人午夜影院| 在线观看免费一区| 亚洲一级二级在线| 欧美色图片你懂的| 五月激情综合色| 欧美猛男超大videosgay| 亚洲一区二区精品久久av| 99久久免费视频.com| 国产精品热久久久久夜色精品三区 | 2021国产精品久久精品| 蜜桃在线一区二区三区| 欧美岛国在线观看| 国产成人一区二区精品非洲| 久久你懂得1024| 成人久久久精品乱码一区二区三区 | 日韩av一二三| 91精品国产aⅴ一区二区| 亚洲综合免费观看高清完整版| 在线免费观看日韩欧美| 一区二区三区在线播放| 欧美日本一区二区三区四区| 麻豆极品一区二区三区| 久久精品人人做人人爽97| 成人性视频网站| 一区二区日韩电影| 日韩精品中文字幕一区二区三区| 国产精品白丝jk白祙喷水网站| 国产精品嫩草久久久久| 在线视频国内一区二区| 日韩中文字幕1| 精品久久久久av影院| 粗大黑人巨茎大战欧美成人| 国产精品福利影院| 欧美色中文字幕| 国产一区二区三区精品欧美日韩一区二区三区 | 欧美精三区欧美精三区| 精品一区二区影视| 亚洲视频在线观看一区| 538在线一区二区精品国产| 国产一区二区三区在线观看免费视频| 中文乱码免费一区二区| 欧美日韩美女一区二区| 国产91精品免费| 亚洲免费观看高清完整版在线观看熊| 欧美日韩一区二区三区在线| 国产麻豆91精品| 亚洲图片欧美一区| 国产精品色呦呦| 欧美一级一区二区| 91黄色激情网站| 国产精品一区不卡| 热久久国产精品| 亚洲欧洲日产国码二区| 欧美一区二区三区啪啪| 色婷婷久久久综合中文字幕| 极品少妇一区二区| 亚洲成人综合在线| 久久人人97超碰com| 欧美写真视频网站| 成人免费福利片| 紧缚奴在线一区二区三区| 亚洲美女少妇撒尿| 中文字幕av在线一区二区三区| 欧美一区二区高清| 欧美性大战久久久久久久蜜臀| 国产99久久久久久免费看农村| 日日夜夜一区二区| 亚洲一二三区不卡| 亚洲欧美国产三级| 中文字幕亚洲在| 国产人成亚洲第一网站在线播放 | 欧美国产日韩亚洲一区| 555www色欧美视频| 欧美专区日韩专区| 91美女在线看| 成人高清视频在线| 国产激情精品久久久第一区二区| 日本aⅴ免费视频一区二区三区 | 亚洲乱码一区二区三区在线观看| 国产日产欧美一区二区视频| 日韩精品一区二区三区中文精品| 欧美一区二区网站| 在线91免费看| 91精品国产综合久久久久| 欧美在线免费观看亚洲| 日本精品一级二级| 欧美吞精做爰啪啪高潮| 国产精品1区2区3区在线观看| 狂野欧美性猛交blacked| 午夜影院在线观看欧美| 亚洲色图20p| 亚洲精品少妇30p| 一区二区三区中文免费| 一区二区三区高清| 丝袜美腿亚洲一区| 久久国内精品自在自线400部| 日本不卡高清视频| 国产在线精品一区二区不卡了 | 欧美日韩精品欧美日韩精品| 91国模大尺度私拍在线视频| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 欧美一区二区观看视频| 欧美一区二区三区视频在线观看 | 国产精品嫩草影院com| 亚洲人成网站在线| 亚洲精品视频一区| 一区二区三区不卡在线观看| 亚洲自拍偷拍麻豆| 久久国产综合精品| 国产一区二区不卡老阿姨| 日本视频在线一区| 国产毛片一区二区| 成人av在线网站| 成人激情校园春色| av午夜精品一区二区三区| 91久久精品一区二区三| 制服.丝袜.亚洲.另类.中文| 欧美成人精品高清在线播放| 日韩精品最新网址| 国产日韩在线不卡| 亚洲精品五月天| 天堂成人国产精品一区| 国产呦萝稀缺另类资源| 91丨porny丨户外露出| 色呦呦一区二区三区| 欧美一卡二卡在线| 中文字幕一区av| 偷拍与自拍一区| 国产乱妇无码大片在线观看| av在线综合网| 欧美另类久久久品| 久久久精品欧美丰满| 亚洲人成网站精品片在线观看| 日韩国产精品久久| 盗摄精品av一区二区三区| 91丝袜美腿高跟国产极品老师| 欧美一区日本一区韩国一区| 国产精品国产三级国产a| 日韩精品一级中文字幕精品视频免费观看 | 国产精品污www在线观看| 亚洲午夜私人影院| 国产精品一级在线| 欧美日韩一区视频| 国产精品美女久久久久av爽李琼 | 99久久婷婷国产综合精品电影| 欧美一区二区私人影院日本| 最近中文字幕一区二区三区| 久久精品99国产精品| 日本韩国欧美三级| 欧美激情一区在线| 久久91精品国产91久久小草| 欧美综合在线视频| 国产精品久久久久婷婷二区次| 美日韩一区二区| 欧美影视一区二区三区| 欧美极品美女视频| 久久成人综合网| 欧美日高清视频| 一区二区欧美精品| 99精品视频一区二区| 久久先锋影音av| 奇米精品一区二区三区四区 | 国产精品午夜在线| 国产乱淫av一区二区三区 | 久久精品理论片| 欧美做爰猛烈大尺度电影无法无天| 亚洲国产高清aⅴ视频| 精品一区二区三区视频| 欧美顶级少妇做爰| 无码av免费一区二区三区试看| 色综合视频一区二区三区高清| 欧美韩国日本不卡| 国产成人一区在线| 国产精品日产欧美久久久久| 成人午夜碰碰视频| 中文字幕第一区第二区| 国产综合色精品一区二区三区| 日韩一区和二区| 婷婷久久综合九色综合绿巨人 | 麻豆成人免费电影| 欧美大片日本大片免费观看| 午夜精品久久久久久| 欧美日韩国产免费| 日本亚洲欧美天堂免费| 日韩一卡二卡三卡国产欧美| 奇米影视在线99精品| 日韩一二三四区| 国产一区二区精品在线观看| 国产亚洲成aⅴ人片在线观看| 国产91清纯白嫩初高中在线观看| 日本一区二区免费在线观看视频 | 大尺度一区二区| 亚洲欧洲成人精品av97| av电影天堂一区二区在线观看| 亚洲日本护士毛茸茸| 欧美三级资源在线| 久久爱另类一区二区小说| 国产亚洲一区二区三区四区 |