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

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

?? syncitem.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 <string.h>
#include <stdlib.h>

#include "base/util/utils.h"
#include "spds/SyncItem.h"
#include "spds/DataTransformerFactory.h"

const char* const SyncItem::encodings::plain = "bin";
const char* const SyncItem::encodings::escaped = "b64";
const char* const SyncItem::encodings::des = "des;b64";

/*
 * Default constructor
 */
SyncItem::SyncItem() {
    initialize();
}


/*
 * Constructs a new SyncItem identified by the given key. The key must
 * not be longer than DIM_KEY (see SPDS Constants).
 *
 * @param key - the key
 */
SyncItem::SyncItem(const WCHAR* itemKey) {
    initialize();
    wcsncpy(key, itemKey, DIM_KEY);
    key[DIM_KEY-1] = 0;
}

/**
 * Initializes private members
 */
void SyncItem::initialize() {
    type[0] = 0;
    data = NULL;
    encoding = NULL;
    size = -1;
    lastModificationTime = -1;
    key[0] = 0;
    targetParent = NULL;
    sourceParent = NULL;
}

/*
 * Destructor. Free the allocated memory (if any)
 */
SyncItem::~SyncItem() {
    if (data) {
        delete [] data; data = NULL;
    }
    if (encoding) {
        delete [] encoding; encoding = NULL;
    }
    if (targetParent) {
        delete [] targetParent; targetParent = NULL;
    }
    if (sourceParent) {
        delete [] sourceParent; sourceParent = NULL;
    }
}

const char* SyncItem::getDataEncoding() {
    return encoding;
}

void SyncItem::setDataEncoding(const char* enc) {
    if (encoding) {
        delete [] encoding;
    }
    encoding = stringdup(enc);
}



int SyncItem::changeDataEncoding(const char* enc, const char* encryption, const char* credentialInfo) {
    int res = ERR_NONE;
    char encToUse[30];

    // First: if encryption not NULL and valid, it is used and 'enc'
    // value is ignored.
    if ( (encryption) && (!strcmp(encryption, "des")) ) {
        strcpy(encToUse, encodings::des);
    }
    else {
        strcpy(encToUse, enc);
    }

    // nothing to be done?
    if (getDataSize() <= 0 ||
        !strcmp(encodings::encodingString(encoding), encodings::encodingString(encToUse))) {
        return ERR_NONE;
    }

    // sanity check: both encodings must be valid
    if (!encodings::isSupported(encToUse) ||
        !encodings::isSupported(encoding)) {
        return ERR_UNSPECIFIED;
    }

    // always convert to plain encoding first
    if (strcmp(encodings::encodingString(encoding), encodings::plain)) {
        if (!strcmp(encoding, encodings::escaped) ||
            !strcmp(encoding, encodings::des)) {
            res = transformData("b64", FALSE, credentialInfo);
            if (res) {
                return res;
            }
        }
        if (!strcmp(encoding, encodings::des)) {
            res = transformData("des", FALSE, credentialInfo);
            if (res) {
                return res;
            }
        }
        setDataEncoding(encodings::plain);
    }

    // now convert to new encoding
    if (strcmp(encodings::encodingString(encoding), encodings::encodingString(encToUse))) {
        if (!strcmp(encToUse, encodings::des)) {
            res = transformData("des", TRUE, credentialInfo);
            if (res) {
                return res;
            }
        }
        if (!strcmp(encToUse, encodings::escaped) ||
            !strcmp(encToUse, encodings::des)) {
            res = transformData("b64", TRUE, credentialInfo);
            if (res) {
                return res;
            }
        }

        setDataEncoding(encodings::encodingString(encToUse));
    }

    return ERR_NONE;
}

int SyncItem::transformData(const char* name, BOOL encode, const char* password)
{
    char* buffer = NULL;
    DataTransformer *dt = encode ?
        DataTransformerFactory::getEncoder(name) :
        DataTransformerFactory::getDecoder(name);
    TransformationInfo info;
    int res = ERR_NONE;

    if (dt == NULL) {
        res = lastErrorCode;
        goto exit;
    }

    info.size = getDataSize();
    info.password = password;
    buffer = dt->transform((char*)getData(), info);
    if (!buffer) {
        res = lastErrorCode;
        goto exit;
    }
    // danger, transformer may or may not have manipulated the data in place
    if (info.newReturnedData) {
        setData(buffer, info.size);
    } else {
        buffer = NULL;
        setDataSize(info.size);
    }

  exit:
    if (buffer) {
        delete [] buffer;
    }
    if (dt) {
        delete dt;
    }
    return res;
}

/*
 * Returns the SyncItem's key. If key is NULL, the internal buffer is
 * returned; if key is not NULL, the value is copied in the caller
 * allocated buffer and the given buffer pointer is returned.
 *
 * @param key - buffer where the key will be stored
 */
const WCHAR* SyncItem::getKey() {
        return key;
    }

/*
 * Changes the SyncItem key. The key must not be longer than DIM_KEY
 * (see SPDS Constants).
 *
 * @param key - the key
 */
void SyncItem::setKey(const WCHAR* itemKey) {
    wcsncpy(key, itemKey, DIM_KEY);
    key[DIM_KEY-1] = 0;
}

/*
 * Sets the SyncItem modification timestamp. timestamp is a milliseconds
 * timestamp since a reference time (which is platform specific).
 *
 * @param timestamp - last modification timestamp
 */
 void SyncItem::setModificationTime(long timestamp) {
     lastModificationTime = timestamp;
 }

/*
 * Returns the SyncItem modeification timestamp. The returned value
 * is a milliseconds timestamp since a reference time (which is
 * platform specific).
 */
long SyncItem::getModificationTime() {
    return lastModificationTime;
}

/*
 * Sets the SyncItem content data. The passed data are copied into an
 * internal buffer so that the caller can release the buffer after
 * calling setData(). The buffer is fred in the destructor.
 * If when calling setData, there was an existing allocated data block,
 * it is reused (shrinked or expanded as necessary).
 */
void* SyncItem::setData(const void* itemData, long dataSize) {
    if (data) {
        delete [] data; data = NULL;
    }

    size = dataSize;

    // Not yet set.
    if (size == -1) {
        data = NULL;
        return data;
    }

    data = new char[size + 1];
    if (data == NULL) {
        lastErrorCode = ERR_NOT_ENOUGH_MEMORY;
        sprintf(lastErrorMsg, ERRMSG_NOT_ENOUGH_MEMORY, dataSize);
        return NULL;
    }

    if (itemData) {
        memcpy(data, itemData, size);
        data[size] = 0;  // FIXME: needed?
    } else {
        memset(data, 0, size + 1);
    }

    return data;
}

/*
 * Returns the SyncItem data buffer. It is deleted in the destructor.
 */
void* SyncItem::getData() {
    return data;
}

/*
 * Returns the SyncItem data size.
 */
long SyncItem::getDataSize() {
    return size;
}

/*
 * Sets the SyncItem data size.
 */
void SyncItem::setDataSize(long s) {
    size = s;
}

/*
 * Sets the SyncItem data mime type
 *
 * @param - type the content mimetype
 */
void SyncItem::setDataType(const WCHAR* mimeType) {
    wcsncpy(type, mimeType, DIM_MIME_TYPE);
    type[DIM_MIME_TYPE-1] = 0;
}

/*
 * Returns the SyncItem data mime type.
 *
 */
const WCHAR* SyncItem::getDataType() {
    return type;
}

/*
 * Sets the SyncItem state
 *
 * @param state the new SyncItem state
 */
void SyncItem::setState(SyncState newState) {
    state = newState;
}

/*
 * Gets the SyncItem state
 */
SyncState SyncItem::getState() {
    return state;
}

/**
 * Gets the taregtParent property
 *
 * @return the taregtParent property value
 */
const WCHAR* SyncItem::getTargetParent() {
    return targetParent;
}

/**
 * Sets the taregtParent property
 *
 * @param parent the taregtParent property
 */
void SyncItem::setTargetParent(const WCHAR* parent) {
    if (targetParent) {
        delete [] targetParent; targetParent = NULL;
    }
    targetParent = wstrdup(parent);
}

/**
 * Gets the sourceParent property
 *
 * @return the sourceParent property value
 */
const WCHAR* SyncItem::getSourceParent() {
    return sourceParent;
}

/**
 * Sets the sourceParent property
 *
 * @param parent the sourceParent property
 */
void SyncItem::setSourceParent(const WCHAR* parent) {
    if (sourceParent) {
        delete [] sourceParent; sourceParent = NULL;
    }
    sourceParent = wstrdup(parent);
}

ArrayElement* SyncItem::clone() {
    SyncItem* ret = new SyncItem(key);

    ret->setData(data, size);
    ret->setDataType(type);
    ret->setModificationTime(lastModificationTime);
    ret->setState(state);
    ret->setSourceParent(sourceParent);
    ret->setTargetParent(targetParent);

    return ret;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品看片你懂得| 久久蜜桃一区二区| 国产嫩草影院久久久久| 激情综合色播五月| 成人国产在线观看| 中文字幕一区av| 欧美午夜精品久久久| 亚洲成人www| 欧美α欧美αv大片| 精品一区二区三区视频| 日本人妖一区二区| 久久精品视频免费| 91福利在线看| 国产中文字幕一区| 国产麻豆成人精品| 亚洲狼人国产精品| 91精品国产aⅴ一区二区| 精品亚洲porn| 成人在线一区二区三区| 日本va欧美va瓶| 一区二区三区在线免费| 久久亚洲一级片| 91精品在线一区二区| 国产成人精品影视| 久久成人免费电影| 午夜久久久久久| 亚洲欧美另类综合偷拍| 久久久久国产精品人| 亚洲精品乱码久久久久久黑人| 久久综合五月天婷婷伊人| 日韩视频免费观看高清完整版在线观看 | 精品午夜久久福利影院| 粉嫩嫩av羞羞动漫久久久| 亚洲国产成人精品视频| 国产精品污网站| 久久综合狠狠综合久久激情| 国产精品久久久久久久久图文区| 亚洲综合一二三区| 亚洲精品成a人| 蜜桃传媒麻豆第一区在线观看| 亚洲一区电影777| 精品一区二区影视| 色婷婷久久综合| 色欲综合视频天天天| 日韩女优av电影| 2020国产精品| 亚洲成人福利片| aaa亚洲精品| 91蜜桃传媒精品久久久一区二区| 成人蜜臀av电影| 欧美一区二区精品| 一区二区三区欧美| 国产大陆a不卡| 欧美一区二区三区性视频| 亚洲欧美日韩国产手机在线| 国产一区欧美二区| 精品少妇一区二区三区 | 日韩欧美国产不卡| 亚洲一区在线观看视频| 北条麻妃国产九九精品视频| 欧美成人精品高清在线播放 | 国产日本欧美一区二区| 蜜桃av一区二区| 884aa四虎影成人精品一区| 一区二区三区中文免费| 国产不卡视频在线播放| 精品第一国产综合精品aⅴ| 日韩欧美在线网站| 爽好久久久欧美精品| 国产在线精品免费av| 欧美成人免费网站| 精品一区二区综合| 久久久综合激的五月天| 国内一区二区视频| 国产午夜亚洲精品不卡| 国产综合色在线视频区| 久久久久久久综合| 韩国三级在线一区| 久久网站热最新地址| 国产一区二区三区| 国产性做久久久久久| 成人精品高清在线| 中文字幕在线不卡| 91在线免费视频观看| 91精品国产综合久久精品性色| 亚洲成人一区在线| 91精品国产综合久久久久久久久久| 亚洲成a人片在线观看中文| 欧美私模裸体表演在线观看| 亚洲aaa精品| 精品区一区二区| 国产91丝袜在线播放0| 国产精品久线在线观看| 色噜噜狠狠成人中文综合| 亚洲制服丝袜av| 在线观看91av| 伊人一区二区三区| 88在线观看91蜜桃国自产| 久久97超碰国产精品超碰| 国产欧美综合在线观看第十页| 91蜜桃传媒精品久久久一区二区| 亚洲国产美女搞黄色| www国产精品av| 99久久99久久精品免费观看| 亚洲3atv精品一区二区三区| 精品美女在线观看| 色域天天综合网| 激情av综合网| 亚洲精选一二三| 欧美成人a视频| 91美女福利视频| 精品在线一区二区| 亚洲精品一二三四区| 日韩精品一区二区三区视频播放| 国产91露脸合集magnet| 天堂成人国产精品一区| 国产精品热久久久久夜色精品三区| 在线一区二区观看| 国产激情视频一区二区在线观看| 亚洲午夜久久久久久久久电影网| 精品福利一二区| 91精品久久久久久久91蜜桃| 成人av网站免费观看| 久久99国产精品尤物| 亚洲一卡二卡三卡四卡| 国产精品久久久久久亚洲伦| 日韩欧美久久久| 欧美天天综合网| 色婷婷综合久久久| 福利一区在线观看| 精品亚洲国内自在自线福利| 亚洲综合丝袜美腿| 一区免费观看视频| 亚洲国产精品二十页| 粉嫩欧美一区二区三区高清影视| 婷婷中文字幕一区三区| 亚洲乱码中文字幕| 国产精品拍天天在线| 久久色在线视频| 日韩三级电影网址| 91精品蜜臀在线一区尤物| 欧洲精品一区二区| 免费成人av在线| 亚洲大片免费看| 亚洲三级久久久| 777亚洲妇女| 欧美日韩亚洲丝袜制服| 免费亚洲电影在线| 日韩中文字幕91| 日韩福利视频网| 蜜臀av性久久久久蜜臀aⅴ四虎 | 中文字幕亚洲区| 久久久久88色偷偷免费 | 99riav久久精品riav| 不卡av在线网| 日本精品视频一区二区| 91久久精品国产91性色tv| 91网上在线视频| 色94色欧美sute亚洲线路二 | 成人一级视频在线观看| 成人免费视频国产在线观看| 成人激情免费电影网址| www.亚洲人| 欧美视频自拍偷拍| 日韩欧美国产小视频| 久久午夜电影网| 亚洲精品伦理在线| 免费在线一区观看| 国产在线精品视频| av高清不卡在线| 欧美综合在线视频| 日韩欧美在线123| 国产午夜精品久久久久久免费视| 国产精品久久毛片a| 亚洲精品国产a| 美脚の诱脚舐め脚责91| 顶级嫩模精品视频在线看| 一本到不卡免费一区二区| 欧美老女人在线| 2020日本不卡一区二区视频| 18成人在线观看| 日韩av不卡一区二区| 国产麻豆精品一区二区| 91日韩精品一区| 日韩一区二区视频| 国产精品久久久久永久免费观看| 亚洲制服丝袜一区| 国产精品资源网| 蜜臀av性久久久久av蜜臀妖精| 国产麻豆欧美日韩一区| 欧美三电影在线| 久久久亚洲高清| 日日夜夜精品视频天天综合网| 国产高清成人在线| 欧美日韩一级二级| 国产精品久久久久久久久动漫 | 欧美高清一级片在线观看| 亚洲图片欧美一区| 不卡av在线网| 久久久久久亚洲综合影院红桃|