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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? vobject.cpp

?? funambol windows mobile plugin source code, the source code is taken from the funambol site
?? CPP
字號:
/*
 * Copyright (C) 2003-2007 Funambol, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY, TITLE, NONINFRINGEMENT or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 * 02111-1307  USA
 */


#include "base/util/utils.h"
#include "base/util/WString.h"
#include "base/Log.h"
#include "vocl/VObject.h"
#include "string.h"

VObject::VObject() {
    productID = NULL;
    version = NULL;
    properties = new ArrayList();
}

VObject::VObject(const WCHAR* prodID, const WCHAR* ver) {

    productID = NULL;
    version = NULL;

    if (prodID) {
        setProdID(prodID);
    }
    if (ver) {
        setVersion(ver);
    }
    properties = new ArrayList();
}

VObject::~VObject() {
    if (productID) {
        delete [] productID; productID = NULL;
    }
    if (version) {
        delete [] version; version = NULL;
    }
    if (properties) {
        delete properties; properties = NULL;
    }
}

void VObject::set(WCHAR** p, const WCHAR* v) {
    if (*p) {
        delete [] *p;
    }
    *p = (v) ? wstrdup(v) : NULL;
}

void VObject::setVersion(const WCHAR* ver) {
    set(&version, ver);
}

void VObject::setProdID(const WCHAR* prodID) {
    set(&productID, prodID);
}

WCHAR* VObject::getVersion() {
    return version;
}

WCHAR* VObject::getProdID() {
    return productID;
}

void VObject::addProperty(VProperty* vProp) {
    properties->add((ArrayElement&) *vProp);
}

int VObject::propertiesCount() {
    return properties->size();
}

bool VObject::removeProperty(int index) {
    if(index < 0 || index >= propertiesCount())
        return false;
    properties->removeElementAt(index);
    return true;
}

void VObject::removeProperty(WCHAR* propName) {
    for (int i=0; i<properties->size(); i++) {
        VProperty *property;
        property = (VProperty* )properties->get(i);
        if(!wcscmp(property->getName(), propName)) {
            properties->removeElementAt(i);
            break;
        }
    }
}

bool VObject::containsProperty(const WCHAR* propName) {
    for (int i=0; i<properties->size(); i++) {
        VProperty *property;
        property = (VProperty* )properties->get(i);
        if(!wcscmp(property->getName(), propName)) {
            return true;
        }
    }
    return false;
}

VProperty* VObject::getProperty(int index) {
    return (VProperty*)properties->get(index);
}

VProperty* VObject::getProperty(const WCHAR* propName) {
    for (int i=0; i<properties->size(); i++) {

        VProperty *property;
        property = (VProperty* )properties->get(i);

        if(!wcscmp(property->getName(), propName)) {
            return property;
        }
    }
    return NULL;
}

/*
 * Returns the VCard - iCal string fro this VObject.
 * Note:
 * The returned WCHAR* is new allocated, must be freed by the caller.
 */
WCHAR* VObject::toString() {

    WString strVObject;

    BOOL is_30 = FALSE;
    if (version) {
        is_30 = !wcscmp(getVersion(), TEXT("3.0"));
    }

    // *** FIXME ***
    // By now folding feature not supported on server...
    bool useFolding = false;

    // let's reserve some space to avoid reallocation in most cases
    strVObject.reserve(5000);

    for (int i=0; i<properties->size(); i++) {
        VProperty *prop = getProperty(i);
        WCHAR* propString = prop->toString(version);
        WCHAR* valueConv = NULL;

        // Folding
        if (useFolding && wcslen(propString) > VCARD_MAX_LINE_LEN) {
            valueConv = folding(propString, VCARD_MAX_LINE_LEN);
            strVObject.append(valueConv);
        }
        else {
            strVObject.append(propString);
        }
        strVObject.append(RFC822_LINE_BREAK);

        if (propString) {
            delete [] propString;  propString = NULL;
        }
        if (valueConv) {
            delete [] valueConv;   valueConv = NULL;
        }
    }

    // memory must be free by caller with delete []
    WCHAR *str = wstrdup(strVObject);
    return str;
}


void VObject::insertProperty(VProperty* property) {

    if (propertiesCount() == 0 || wcscmp(getProperty(propertiesCount()-1)->getName(),TEXT("END")))
        addProperty(property);
    else {
        VProperty* lastProperty = getProperty(TEXT("END"));
        removeProperty(TEXT("END"));
        addProperty(property);
        addProperty(lastProperty);
    }
}

void VObject::addFirstProperty(VProperty* property) {
    properties->add(0,(ArrayElement&)*property);
}

void VObject::removeAllProperies(WCHAR* propName) {
    for(int i = 0, m = propertiesCount(); i < m ; i++)
        if(!wcscmp(getProperty(i)->getName(), propName)) {
            removeProperty(i);
            --i;
            --m;
        }
}

#ifdef VOCL_ENCODING_FIX

// Patrick Ohly: hack below, see header file

static int hex2int( WCHAR x )
{
    return (x >= '0' && x <= '9') ? x - '0' :
        (x >= 'A' && x <= 'F') ? x - 'A' + 10 :
        (x >= 'a' && x <= 'f') ? x - 'a' + 10 :
        0;
}

#define SEMICOLON_REPLACEMENT '\a'

void VObject::toNativeEncoding()
{
    BOOL is_30 = !wcscmp(getVersion(), TEXT("3.0"));
    // line break is encoded with either one or two
    // characters on different platforms
    const int linebreaklen = wcslen(SYNC4J_LINEBREAK);

    for (int index = propertiesCount() - 1; index >= 0; index--) {
        VProperty *vprop = getProperty(index);
        WCHAR *foreign = vprop->getValue();
        // the native encoding is always shorter than the foreign one
        WCHAR *native = new WCHAR[wcslen(foreign) + 1];

        if (vprop->equalsEncoding(TEXT("QUOTED-PRINTABLE"))) {
            int in = 0, out = 0;
            WCHAR curr;

            // this is a very crude quoted-printable decoder,
            // based on Wikipedia's explanation of quoted-printable
            while ((curr = foreign[in]) != 0) {
                in++;
                if (curr == '=') {
                    WCHAR values[2];
                    values[0] = foreign[in];
                    in++;
                    if (!values[0]) {
                        // incomplete?!
                        break;
                    }
                    values[1] = foreign[in];
                    in++;
                    if (values[0] == '\r' && values[1] == '\n') {
                        // soft line break, ignore it
                    } else {
                        native[out] = (hex2int(values[0]) << 4) |
                            hex2int(values[1]);
                        out++;

                        // replace \r\n with \n?
                        if ( linebreaklen == 1 &&
                             out >= 2 &&
                             native[out - 2] == '\r' &&
                             native[out - 1] == '\n' ) {
                            native[out - 2] = SYNC4J_LINEBREAK[0];
                            out--;
                        }

                        // the conversion to wchar on Windows is
                        // probably missing here
                    }
                } else {
                    native[out] = curr;
                    out++;
                }
            }
            native[out] = 0;
            out++;
        } else {
            wcscpy(native, foreign);
        }

        // decode escaped characters after backslash:
        // \n is line break only in 3.0
        WCHAR curr;
        int in = 0, out = 0;
        while ((curr = native[in]) != 0) {
            in++;
            switch (curr) {
             case '\\':
                curr = native[in];
                in++;
                switch (curr) {
                 case 'n':
                    if (is_30) {
                        // replace with line break
                        wcsncpy(native + out, SYNC4J_LINEBREAK, linebreaklen);
                        out += linebreaklen;
                    } else {
                        // normal escaped character
                        native[out] = curr;
                        out++;
                    }
                    break;
                 case 0:
                    // unexpected end of string
                    break;
                 default:
                    // just copy next character
                    native[out] = curr;
                    out++;
                    break;
                }
                break;
             case ';':
                // field separator - must replace with something special
                // so that we can encode it again in fromNativeEncoding()
                native[out] = SEMICOLON_REPLACEMENT;
                out++;
                break;
             default:
                native[out] = curr;
                out++;
            }
        }
        native[out] = 0;
        out++;

        // charset handling:
        // - doesn't exist at the moment, vCards have to be in ASCII or UTF-8
        // - an explicit CHARSET parameter is removed because its parameter
        //   value might differ between 2.1 and 3.0 (quotation marks allowed in
        //   3.0 but not 2.1) and thus would require extra code to convert it;
        //   when charsets really get supported this needs to be addressed
        WCHAR *charset = vprop->getParameterValue(TEXT("CHARSET"));
        if (charset) {
            // proper decoding of the value and the property value text
            // would go here, for the time being we just remove the
            // value
            if (_wcsicmp(charset, TEXT("UTF-8")) &&
                _wcsicmp(charset, TEXT("\"UTF-8\""))) {
                LOG.error("ignoring unsupported charset");
            }
            vprop->removeParameter(TEXT("CHARSET"));
        }

        vprop->setValue(native);
        delete [] native;
    }
}

void VObject::fromNativeEncoding()
{
    BOOL is_30 = !wcscmp(getVersion(), TEXT("3.0"));

    for (int index = propertiesCount() - 1; index >= 0; index--) {
        VProperty *vprop = getProperty(index);

        if (vprop->equalsEncoding(TEXT("QUOTED-PRINTABLE"))) {
            // remove this, we cannot recreate it
            vprop->removeParameter(TEXT("ENCODING"));
        }

        WCHAR *native = vprop->getValue();
        // in the worst case every comma/linebreak is replaced with
        // two characters and each \n with =0D=0A
        WCHAR *foreign = new WCHAR[6 * wcslen(native) + 1];
        WCHAR curr;
        int in = 0, out = 0;
        // line break is encoded with either one or two
        // characters on different platforms
        const int linebreaklen = wcslen(SYNC4J_LINEBREAK);

        // use backslash for special characters,
        // if necessary do quoted-printable encoding
        bool doquoted = !is_30 &&
            wcsstr(native, SYNC4J_LINEBREAK) != NULL;
        while ((curr = native[in]) != 0) {
            in++;
            switch (curr) {
             case ',':
                if (!is_30) {
                    // normal character
                    foreign[out] = curr;
                    out++;
                    break;
                }
                // no break!
             case ';':
             case '\\':
                foreign[out] = '\\';
                out++;
                foreign[out] = curr;
                out++;
                break;
             case SEMICOLON_REPLACEMENT:
                foreign[out] = ';';
                out++;
                break;
             default:
                if (doquoted &&
                    (curr == '=' || (unsigned char)curr >= 128)) {
                    // escape = and non-ASCII characters
                    swprintf(foreign + out, 4, TEXT("=%02X"), (unsigned int)(unsigned char)curr);
                    out += 3;
                } else if (!wcsncmp(native + in - 1,
                                    SYNC4J_LINEBREAK,
                                    linebreaklen)) {
                    // line break
                    if (is_30) {
                        foreign[out] = '\\';
                        out++;
                        foreign[out] = 'n';
                        out++;
                    } else {
                        wcscpy(foreign + out, TEXT("=0D=0A"));
                        out += 6;
                    }
                    in += linebreaklen - 1;
                } else {
                    foreign[out] = curr;
                    out++;
                }
                break;
            }
        }
        foreign[out] = 0;
        vprop->setValue(foreign);
        delete [] foreign;
        if (doquoted) {
            // we have used quoted-printable encoding
            vprop->addParameter(TEXT("ENCODING"), TEXT("QUOTED-PRINTABLE"));
        }
    }
}

#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合久久六月婷婷中文字幕| 欧美在线视频全部完| 色播五月激情综合网| 7777精品伊人久久久大香线蕉的 | 午夜成人免费视频| 国产aⅴ综合色| 欧美乱妇一区二区三区不卡视频| 国产视频一区在线观看| 午夜影院在线观看欧美| 高清国产一区二区三区| 欧美一区二区三区免费观看视频 | 日韩免费高清电影| 亚洲欧美日韩中文字幕一区二区三区| 美女爽到高潮91| 欧美日韩在线一区二区| 综合久久久久综合| 国产成人啪午夜精品网站男同| 91精品中文字幕一区二区三区 | 久久久亚洲精品石原莉奈| 亚洲一区二区黄色| 色av一区二区| 亚洲视频狠狠干| 国产一区二区不卡老阿姨| 666欧美在线视频| 亚洲午夜久久久| 色哟哟欧美精品| 国产精品麻豆欧美日韩ww| 国产麻豆视频一区二区| 日韩欧美国产午夜精品| 波多野结衣在线一区| 日韩精品专区在线影院重磅| 亚洲a一区二区| 91超碰这里只有精品国产| 天堂久久久久va久久久久| 精品视频色一区| 亚洲第一狼人社区| 69av一区二区三区| 美女诱惑一区二区| 久久综合999| 美日韩一区二区| 欧美男女性生活在线直播观看| 一区二区三区在线影院| 色综合激情五月| 亚洲高清视频在线| 337p亚洲精品色噜噜狠狠| 亚洲18女电影在线观看| 91麻豆精品91久久久久久清纯| 日日夜夜精品视频天天综合网| 欧美浪妇xxxx高跟鞋交| 日本vs亚洲vs韩国一区三区二区| 欧美一区二区在线视频| 久久91精品国产91久久小草| 精品国产免费久久| 春色校园综合激情亚洲| 1区2区3区欧美| 欧美日韩一区三区四区| 日本不卡一区二区| 国产片一区二区三区| 色诱视频网站一区| 亚洲成av人影院在线观看网| 91精品婷婷国产综合久久竹菊| 久草精品在线观看| 亚洲天堂精品视频| 欧美一级生活片| 91精品国产色综合久久久蜜香臀| 国内精品久久久久影院薰衣草| 日本一区二区三区电影| 欧美日韩中文一区| 国产精品一区二区三区四区| 国产精品不卡在线| 欧美一区二区在线免费观看| 大白屁股一区二区视频| 偷拍日韩校园综合在线| 久久久不卡影院| 欧美日韩五月天| 丁香另类激情小说| 免费观看成人av| 亚洲天堂久久久久久久| 51精品视频一区二区三区| 岛国精品一区二区| 免费观看久久久4p| 亚洲综合激情小说| 国产日韩欧美高清| 91.com在线观看| 色系网站成人免费| 国产精品一区二区三区四区| 五月天精品一区二区三区| 久久日韩粉嫩一区二区三区| 欧美乱妇一区二区三区不卡视频| 成人污污视频在线观看| 久久国产精品72免费观看| 亚洲男同性恋视频| 久久久精品一品道一区| 日韩精品一区二区三区蜜臀| 日本韩国一区二区三区| 国产精品亚洲视频| 欧美a级理论片| 亚洲午夜激情av| **网站欧美大片在线观看| 日韩美女在线视频| 欧美日韩精品专区| 91免费看片在线观看| 国产裸体歌舞团一区二区| 亚洲高清视频在线| 亚洲黄色av一区| 亚洲人成亚洲人成在线观看图片| 国产三级欧美三级日产三级99 | 国产精品综合网| 奇米精品一区二区三区在线观看一| 亚洲乱码国产乱码精品精的特点| 国产婷婷一区二区| 欧美激情综合在线| 国产午夜精品久久久久久免费视 | 中文字幕免费在线观看视频一区| 欧美videos中文字幕| 在线播放欧美女士性生活| 欧美日韩国产区一| 欧美一区二区福利视频| 精品视频色一区| 欧美福利一区二区| 4hu四虎永久在线影院成人| 欧美精品在线视频| 宅男噜噜噜66一区二区66| 欧美日韩免费一区二区三区| 欧美午夜精品免费| 欧美精品日韩一区| 日韩美女天天操| 久久免费视频色| 国产精品青草久久| 一区二区三区毛片| 亚洲国产精品一区二区www | 亚洲免费在线观看| 一区二区三区中文字幕| 婷婷中文字幕一区三区| 日韩国产一区二| 韩国v欧美v亚洲v日本v| 国产 日韩 欧美大片| 99久久精品费精品国产一区二区| 色婷婷综合久久久久中文一区二区| 91麻豆精品在线观看| 欧美日韩一区二区三区四区五区 | 日本成人在线网站| 黄页网站大全一区二区| 国产成人av电影在线观看| 99久久免费国产| 欧美人牲a欧美精品| 久久日韩粉嫩一区二区三区| 国产精品美女久久久久久久久| 麻豆91精品视频| 国产成a人无v码亚洲福利| 91视频com| 日韩一区二区免费在线电影| ww亚洲ww在线观看国产| 中文字幕日本不卡| 日韩av中文字幕一区二区三区| 国产一区二区三区香蕉| 一本久道久久综合中文字幕| 日韩精品资源二区在线| 国产精品高潮呻吟| 麻豆视频一区二区| 99久久精品一区| 日韩欧美国产一二三区| 亚洲欧美日韩国产综合| 免费亚洲电影在线| 91看片淫黄大片一级在线观看| 欧美一区二区私人影院日本| 国产精品理论在线观看| 蜜臀av一区二区| 91行情网站电视在线观看高清版| 久久中文字幕电影| 久久精品欧美一区二区三区不卡 | 麻豆91精品视频| 色丁香久综合在线久综合在线观看| 精品久久久久久亚洲综合网 | 欧美日韩国产在线观看| 欧美精品一区二区三区在线| 一区二区免费在线| 成人免费视频caoporn| 日韩精品一区在线| 亚洲成人动漫av| 色94色欧美sute亚洲线路一久 | 国产一区二区调教| 51精品国自产在线| 亚洲国产精品一区二区www| 成人av在线影院| 久久日韩粉嫩一区二区三区| 视频一区在线播放| 欧美网站大全在线观看| 亚洲女子a中天字幕| 懂色av中文一区二区三区 | 在线观看91视频| 国产精品国产三级国产三级人妇 | 欧美激情在线观看视频免费| 美国欧美日韩国产在线播放| 欧美欧美午夜aⅴ在线观看| 一区二区三区成人| 91久久精品一区二区| 国产99精品视频| 久久久www免费人成精品| 韩国视频一区二区|