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

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

?? syncmanager.cpp

?? funambol windows mobile plugin source code, the source code is taken from the funambol site
?? CPP
?? 第 1 頁 / 共 5 頁
字號:
/*
 * 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/fscapi.h"
#include "base/Log.h"
#include "base/debug.h"
#include "base/util/utils.h"
#include "base/base64.h"
#include "base/messages.h"
#include "http/TransportAgentFactory.h"
#include "spds/constants.h"
#include "spds/DataTransformer.h"
#include "spds/DataTransformerFactory.h"
#include "spds/SyncManagerConfig.h"
#include "spds/SyncManager.h"
#include "spds/SyncMLProcessor.h"
#include "spds/spdsutils.h"
#include "syncml/core/TagNames.h"
#include "syncml/core/ObjectDel.h"

#include "event/FireEvent.h"

#include <limits.h>

const char SyncManager::encodedKeyPrefix[] = "funambol-b64-";
char prevSourceName[64];
char prevSourceUri[64];
SyncMode prevSyncMode;

BOOL isFiredSyncEventBEGIN;
BOOL isFiredSyncEventEND;
void SyncManager::decodeItemKey(SyncItem *syncItem)
{
    char *key;

    if (syncItem &&
        (key = toMultibyte(syncItem->getKey())) != NULL &&
        !strncmp(key, encodedKeyPrefix, strlen(encodedKeyPrefix))) {
        int len;
        char *decoded = (char *)b64_decode(len, key + strlen(encodedKeyPrefix));
        LOG.debug("replacing encoded key '%s' with unsafe key '%s'", key, decoded);
        WCHAR* t = toWideChar(decoded);
        syncItem->setKey(t);
        delete [] decoded;
        delete [] key;
        delete [] t;
    }
}

void SyncManager::encodeItemKey(SyncItem *syncItem)
{
    char *key;

    if (syncItem &&
        (key = toMultibyte(syncItem->getKey())) != NULL &&
        (strchr(key, '<') || strchr(key, '&'))) {
        StringBuffer encoded;
        b64_encode(encoded, key, strlen(key));
        StringBuffer newkey(encodedKeyPrefix);
        newkey += encoded;
        LOG.debug("replacing unsafe key '%s' with encoded key '%s'", key, newkey.c_str());
        WCHAR* t = toWideChar(newkey.c_str());
        syncItem->setKey(t);
        delete [] key;
        delete [] t;
    }
}

/**
 * Is the given status code an error status code? Error codes are the ones
 * outside the range 200-299.
 *
 * @param status the status code to check
 */
inline static bool isErrorStatus(int status) {
    return (status) && ((status < 200) || (status > 299));
}

/**
 * Return true if the status code is authentication failed
 *
 * @param status the status code to check
 */
inline static bool isAuthFailed(int status) {
    return (status) && ((status == 401) || (status == 407));
}

/**
 * Return true if there's no more work to do
 * (if no source has a correct status)
 */
bool SyncManager::isToExit() {
    for (int i = 0; i < sourcesNumber; i++) {
        if (sources[i]->getReport()->checkState() == true) {
            return false;
        }
    }
    return true;
}

/*
 * Utility to set a SyncSource state + errorCode + errorMsg.
 */
void SyncManager::setSourceStateAndError(unsigned int index, SourceState  state,
                                         unsigned int code,  const char*  msg) {

    SyncSourceReport* report = sources[index]->getReport();

    report->setState(state);
    report->setLastErrorCode(code);
    report->setLastErrorMsg(msg);
}


// Used to reserve some more space (DATA_SIZE_TOLERANCE) for incoming items.
// This is used to add a little tolerance to the data size of items sent by
// server in case of large object (item splitted in multiple chunks).
long SyncManager::getToleranceDataSize(long size) {
    return (long)(size*DATA_SIZE_TOLERANCE + 0.5);
}


// Used to verify if data size of incoming item is different from the one declared.
bool SyncManager::testIfDataSizeMismatch(long allocatedSize, long receivedSize) {
    long declaredSize = (long) (allocatedSize/DATA_SIZE_TOLERANCE + 0.5);
    if (declaredSize != receivedSize) {
        LOG.info("WARNING! Item size mismatch: real size = %d, declared size = %d", receivedSize, declaredSize);
        return true;
    }
    return false;
}


SyncManager::SyncManager(SyncManagerConfig& c, SyncReport& report) : config(c), syncReport(report) {
    initialize();
}

void SyncManager::initialize() {
    // set all values which are checked by the destructor;
    // previously some pointers were only set later, leading to
    // uninitialized memory reads and potential crashes when
    // constructing a SyncManager, but not using it
    transportAgent = NULL;
    mappings       = NULL;
    sources        = NULL;
    currentState   = STATE_START;
    sourcesNumber  = 0;
    count          = 0;
    commands       = NULL;
    devInf         = NULL;
    incomingItem   = NULL;

    AccessConfig& c = config.getAccessConfig();
    DeviceConfig& dc = config.getDeviceConfig();

    syncURL = c.getSyncURL();
    deviceId = dc.getDevID();

    credentialHandler.setUsername           (c.getUsername());
    credentialHandler.setPassword           (c.getPassword());
    credentialHandler.setClientNonce        (c.getClientNonce());
    credentialHandler.setClientAuthType     (c.getClientAuthType());

    credentialHandler.setServerID           (c.getServerID());
    credentialHandler.setServerPWD          (c.getServerPWD());
    credentialHandler.setServerNonce        (c.getServerNonce());
    credentialHandler.setServerAuthType     (c.getServerAuthType());
    credentialHandler.setServerAuthRequired (c.getServerAuthRequired());

    commands = new ArrayList();

    responseTimeout = c.getResponseTimeout();
    if (responseTimeout <= 0) {
        responseTimeout = DEFAULT_MAX_TIMEOUT;
    }
    maxMsgSize   = c.getMaxMsgSize();
    if (maxMsgSize <= 0) {
        maxMsgSize = DEFAULT_MAX_MSG_SIZE;
    }
    maxObjSize   = dc.getMaxObjSize();
    loSupport    = dc.getLoSupport();
    readBufferSize = 5000; // default value

    if (c.getReadBufferSize() > 0)
        readBufferSize = c.getReadBufferSize();

    syncMLBuilder.set(syncURL.c_str(), deviceId.c_str());
    memset(credentialInfo, 0, 1024*sizeof(char));
    sortedSourcesFromServer = NULL;
    prevSourceName[0] = 0;
    prevSourceUri[0] = 0;
    prevSyncMode = SYNC_NONE;
    isFiredSyncEventBEGIN = FALSE;

}

SyncManager::~SyncManager() {
    if (transportAgent) {
        delete transportAgent;
    }
    if (commands) {
        commands->clear(); delete commands; commands = NULL;
    }
    if (mappings) {
        for (int i=0; i<sourcesNumber; i++) {
            deleteArrayList(&mappings[i]);
            delete mappings[i];
        }
        delete [] mappings; mappings = NULL;
    }
    if (sources) {
        // This deletes only SyncSource array
        // We DON'T want to release SyncSource objects here!
        delete [] sources;
    }
    if (devInf) {
        delete devInf;
    }
    if (incomingItem) {
        delete incomingItem;
    }
    if (sortedSourcesFromServer) {
        int i=0;
        while (sortedSourcesFromServer[i]) {
            delete [] sortedSourcesFromServer[i];
            i++;
        }
        delete [] sortedSourcesFromServer;
    }
}

/*
 * Modification to perform the sync of an array of sync sources.
 */

int SyncManager::prepareSync(SyncSource** s) {

    char* initMsg               = NULL;
    const char* respURI         = NULL;
    char* responseMsg           = NULL;
    SyncML*  syncml             = NULL;
    int ret                     = 0;
    int serverRet               = 0;
    int count                   = 0;
    const char* requestedAuthType  = NULL;
    ArrayList* list             = new ArrayList();
    ArrayList* alerts           = new ArrayList();

    // for authentication improvments
    BOOL isServerAuthRequired   = credentialHandler.getServerAuthRequired();
    int clientAuthRetries       = 1;
    int serverAuthRetries       = 1;
    int authStatusCode          = 200;

    BOOL isClientAuthenticated  = FALSE;
    BOOL isServerAuthenticated  = FALSE;
    Chal*   clientChal          = NULL; // The chal of the server to the client
    Chal*   serverChal          = NULL; // The chal of the client to the server
    Status* status              = NULL; // The status from the client to the server
    Cred*   cred                = NULL;
    Alert*  alert               = NULL;
    SyncSource** buf            = NULL;
    StringBuffer* devInfStr     = NULL;
    BOOL putDevInf              = FALSE;
    char devInfHash[16 * 4 +1]; // worst case factor base64 is four
    unsigned long timestamp = (unsigned long)time(NULL);

    lastErrorCode = 0;

    // Fire Sync Begin Event
    fireSyncEvent(NULL, SYNC_BEGIN);

    URL url(config.getAccessConfig().getSyncURL());
    Proxy proxy;
    LOG.info(MSG_SYNC_URL, syncURL.c_str());

    // Copy and validate given
    sourcesNumber = assignSources(s);
    if (lastErrorCode) {
        ret = lastErrorCode;    // set when a source has an invalid config
    }

    if (isToExit()) {
        if (!ret) {
            // error: no source to sync
            ret = lastErrorCode = ERR_NO_SOURCE_TO_SYNC;
            sprintf(lastErrorMsg, ERRMSG_NO_SOURCE_TO_SYNC);
        }

        goto finally;
    }

    // Set proxy username/password if proxy is used.
    if (config.getAccessConfig().getUseProxy()) {
        //char* proxyHost = config.getAccessConfig().getProxyHost();
        //int    proxyPort = config.getAccessConfig().getProxyPort();
        const char* proxyUser = config.getAccessConfig().getProxyUsername();
        const char* proxyPwd  = config.getAccessConfig().getProxyPassword();
        proxy.setProxy(NULL, 0, proxyUser, proxyPwd);
    }

    mappings = new ArrayList*[sourcesNumber + 1];
    for (count = 0; count < sourcesNumber; count++) {
        mappings[count] = new ArrayList();
        LOG.info(MSG_PREPARING_SYNC, _wcc(sources[count]->getName()));
    }

    syncMLBuilder.resetCommandID();
    syncMLBuilder.resetMessageID();
    config.getAccessConfig().setBeginSync(timestamp);

    // Create the device informations.
    devInf = createDeviceInfo();

    // check device information for changes
    if (devInf) {
        char md5[16];
        devInfStr = Formatter::getDevInf(devInf);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
性做久久久久久久久| 国产高清不卡一区| 国产精品一区二区久久不卡 | 国产精品综合久久| 欧美综合色免费| 国产欧美精品一区aⅴ影院 | 免费久久99精品国产| 色综合久久中文综合久久97| 在线成人免费视频| 国产精品美女一区二区三区| 日韩av一二三| 欧美日韩二区三区| 一区二区三区在线免费视频 | 免费的国产精品| 色哟哟精品一区| 国产视频一区在线播放| 老司机精品视频一区二区三区| 色一情一乱一乱一91av| 亚洲欧洲精品天堂一级| 国产精品88av| 久久日韩粉嫩一区二区三区| 天堂一区二区在线免费观看| 日本乱码高清不卡字幕| ...av二区三区久久精品| 粉嫩一区二区三区性色av| 精品国产一区二区精华| 日韩黄色片在线观看| 欧美日韩国产小视频在线观看| 综合久久给合久久狠狠狠97色| 国产成人av一区二区三区在线| 欧美一二三四区在线| 婷婷成人综合网| 欧美日韩卡一卡二| 五月激情六月综合| 3d动漫精品啪啪1区2区免费| 天堂在线亚洲视频| 欧美一区二区视频在线观看2022| 婷婷开心久久网| 欧美一区二区久久久| 日韩vs国产vs欧美| 亚洲女与黑人做爰| 国产视频911| 日韩欧美的一区二区| 国产福利一区二区三区视频在线| 日韩av不卡一区二区| 国产人成亚洲第一网站在线播放| 中文字幕久久午夜不卡| 91国偷自产一区二区三区成为亚洲经典 | 中文一区在线播放| 国产女同互慰高潮91漫画| 国产精品国产a级| 日韩影院在线观看| 成人av电影在线观看| 4438成人网| 一区二区三区中文在线观看| 久草热8精品视频在线观看| 国产91精品在线观看| 欧美一区二区三区白人| 亚洲欧美国产三级| 成人av在线播放网址| 884aa四虎影成人精品一区| 国产欧美日韩麻豆91| 日韩不卡一二三区| 在线综合视频播放| 亚洲一区二区黄色| 在线亚洲免费视频| 亚洲最大成人网4388xx| 不卡视频一二三四| 久久蜜桃一区二区| 亚洲成人综合视频| 色哟哟亚洲精品| 一区二区三区欧美日| 精品一区二区影视| 91香蕉国产在线观看软件| 26uuu国产电影一区二区| 亚洲一区二区三区精品在线| 韩国女主播一区| 久久综合精品国产一区二区三区 | 国产精品每日更新在线播放网址| 色噜噜狠狠成人中文综合| 一区二区三区免费观看| 日韩午夜精品电影| 国产成人av影院| 亚洲美女视频一区| 日韩欧美国产系列| 91首页免费视频| 久久97超碰色| 老色鬼精品视频在线观看播放| 欧美一区二区三区小说| 喷水一区二区三区| 精品国产在天天线2019| 国产精品一区久久久久| 亚洲人成网站在线| 久久婷婷一区二区三区| 欧美在线一二三四区| 久久99精品国产.久久久久久 | 欧美成人猛片aaaaaaa| 国产一区视频导航| 日韩国产欧美在线播放| 欧美aⅴ一区二区三区视频| 亚洲午夜精品17c| 欧美一区在线视频| 51久久夜色精品国产麻豆| 99国产精品一区| 不卡av电影在线播放| 日韩二区在线观看| 日韩专区一卡二卡| 五月天中文字幕一区二区| 天堂资源在线中文精品| 精品久久久久99| 中文字幕亚洲视频| 视频一区二区三区在线| 成人精品鲁一区一区二区| 欧美三级电影在线观看| 国产三级一区二区三区| 亚洲第一福利一区| www.欧美色图| 欧美一区二区三区视频免费| 欧美精选一区二区| 国产亚洲一区字幕| 亚洲人成电影网站色mp4| 亚洲最色的网站| 久久er99精品| 92国产精品观看| 欧美高清hd18日本| 亚洲精品一区二区三区在线观看| 日韩欧美国产系列| 日日摸夜夜添夜夜添国产精品| 国产真实乱对白精彩久久| 国产一区免费电影| 色综合 综合色| 最新国产成人在线观看| 国产在线不卡一区| 成人免费看片app下载| 91香蕉视频黄| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 亚洲一区二区影院| 蜜臀久久久久久久| 成人少妇影院yyyy| 日韩一级片网站| 中文字幕电影一区| 五月激情丁香一区二区三区| 国产乱人伦精品一区二区在线观看 | 色综合天天视频在线观看| 日韩一本二本av| 国产精品传媒在线| 人妖欧美一区二区| 91网址在线看| 久久久99久久| 久久国产婷婷国产香蕉| 色综合视频在线观看| 国产亚洲午夜高清国产拍精品 | 亚洲男女毛片无遮挡| 激情小说亚洲一区| 欧美巨大另类极品videosbest| 在线播放中文一区| 亚洲美女精品一区| 91麻豆免费观看| 国产精品久久三| av电影在线不卡| 中文字幕日韩一区| 91影视在线播放| 最新热久久免费视频| 91网上在线视频| 亚洲另类在线视频| 欧美撒尿777hd撒尿| 一区二区欧美精品| 7777精品伊人久久久大香线蕉的 | 日本欧美久久久久免费播放网| 色哟哟精品一区| 日本欧美久久久久免费播放网| 欧美日本一道本| 久久精品av麻豆的观看方式| 日韩免费高清电影| 成人黄动漫网站免费app| 亚洲日本青草视频在线怡红院| 91色乱码一区二区三区| 亚洲国产日韩av| 久久久久久夜精品精品免费| 亚洲v日本v欧美v久久精品| 色久优优欧美色久优优| 毛片一区二区三区| 亚洲色图色小说| 欧美美女直播网站| 成人av免费在线播放| 亚洲成精国产精品女| 国产欧美日产一区| 91精品国产91久久久久久一区二区| 九色综合狠狠综合久久| 一区二区三区鲁丝不卡| 国产日韩欧美综合在线| 欧洲一区在线电影| 成人毛片老司机大片| 日韩av一区二区三区| 亚洲小说春色综合另类电影| 欧美国产精品中文字幕| 久久看人人爽人人| 日韩欧美在线不卡| 制服.丝袜.亚洲.中文.综合| 国产精品99久久久久久久vr |