亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
亚洲成人动漫精品| 欧美福利一区二区| 久久99国产精品免费网站| 亚洲影院免费观看| 国产精品久久久久久久久免费相片| 日韩视频一区二区三区在线播放| 91麻豆精品久久久久蜜臀| 在线成人高清不卡| 91麻豆精品国产91久久久| 91麻豆精品国产91久久久久久久久 | 欧美日韩一区二区三区在线| 99re这里只有精品6| 91麻豆国产福利精品| 在线看日本不卡| 欧美另类高清zo欧美| 91精品视频网| 久久久综合精品| 17c精品麻豆一区二区免费| 亚洲女子a中天字幕| 亚洲免费av观看| 五月婷婷久久综合| 日韩高清不卡在线| 国产一区二区三区四| 不卡av在线网| 欧美久久久久久蜜桃| 精品国产免费一区二区三区香蕉| 国产午夜亚洲精品理论片色戒| 国产精品免费aⅴ片在线观看| 一区在线中文字幕| 午夜激情一区二区三区| 国产自产高清不卡| 不卡av在线网| 日韩欧美一区中文| 国产精品私人影院| 亚洲国产精品久久人人爱蜜臀| 乱一区二区av| 在线观看视频91| 日韩欧美一二三区| 国产精品久久久久久久久晋中 | 欧美日韩精品专区| 久久亚洲欧美国产精品乐播| 亚洲男同性恋视频| 麻豆freexxxx性91精品| 91小视频在线免费看| 日韩三级电影网址| 综合精品久久久| 国产成人综合在线播放| 欧美久久婷婷综合色| 国产精品国产三级国产专播品爱网| 一区二区三区鲁丝不卡| 国产在线精品一区二区| 欧美视频在线一区二区三区| 国产精品视频九色porn| 青青草国产成人99久久| 色悠久久久久综合欧美99| 久久先锋资源网| 日韩国产精品久久久| 91久久人澡人人添人人爽欧美| 国产网红主播福利一区二区| 美女视频黄免费的久久 | 久久99精品一区二区三区| 91麻豆swag| 中文字幕国产一区| 久久国产福利国产秒拍| 欧美日韩黄色一区二区| 亚洲蜜臀av乱码久久精品蜜桃| 国产成人亚洲精品狼色在线| 精品三级在线看| 日韩电影免费在线看| 欧洲激情一区二区| 日韩久久一区二区| 成人免费高清在线观看| 久久伊99综合婷婷久久伊| 久久国产精品露脸对白| 日韩一区二区三区免费看| 三级影片在线观看欧美日韩一区二区| 在线观看欧美日本| 亚洲一区二区中文在线| 色网综合在线观看| 亚洲黄色录像片| 欧美色综合久久| 亚洲一区免费观看| 欧美天天综合网| 天堂成人免费av电影一区| 欧美亚洲动漫精品| 亚洲午夜精品在线| 7777精品久久久大香线蕉| 天堂久久久久va久久久久| 日韩一区二区三区视频在线| 韩国v欧美v日本v亚洲v| 久久一夜天堂av一区二区三区| 国产999精品久久| 最新热久久免费视频| 欧美视频一区二区三区四区| 免费在线观看一区| 久久丝袜美腿综合| 99在线热播精品免费| 亚洲精品中文在线| 欧美疯狂做受xxxx富婆| 免费av网站大全久久| 久久久91精品国产一区二区三区| 国产suv精品一区二区三区| 中文字幕一区二区三中文字幕| 在线免费观看日韩欧美| 午夜精品视频一区| 精品对白一区国产伦| 不卡视频一二三四| 天堂一区二区在线| 国产欧美一区二区三区网站| 欧美亚洲动漫精品| 久久国产尿小便嘘嘘| **欧美大码日韩| 精品区一区二区| 91免费精品国自产拍在线不卡| 石原莉奈一区二区三区在线观看| 国产精品污污网站在线观看| 5月丁香婷婷综合| av一区二区三区| 精品一区二区在线视频| 一区二区三区欧美亚洲| 久久只精品国产| 777亚洲妇女| 91丨porny丨中文| 国产精品综合av一区二区国产馆| 一区二区三区精品| 国产亚洲1区2区3区| 欧美日韩国产一级| 99久久精品一区二区| 九九国产精品视频| 五月天激情小说综合| 中文字幕在线观看一区| 亚洲免费观看高清| 日韩精品一区二区三区视频在线观看 | 国产女人aaa级久久久级| 欧美理论片在线| 91国产免费看| 成人午夜av在线| 国产精品夜夜嗨| 精品一区二区影视| 日本三级亚洲精品| 午夜精品成人在线视频| 亚洲男人天堂av| 亚洲国产精品av| 精品国产乱码久久久久久老虎| 欧美电影在哪看比较好| 在线精品视频一区二区三四| av亚洲精华国产精华精华| 国产乱国产乱300精品| 美女看a上一区| 久久精品噜噜噜成人88aⅴ| 日日摸夜夜添夜夜添国产精品 | 久久女同精品一区二区| 91精品国产乱| 欧美一区二区精品在线| 欧美日韩激情在线| 欧美日韩欧美一区二区| 欧美军同video69gay| 欧美男女性生活在线直播观看| 色老汉一区二区三区| 色一情一伦一子一伦一区| 91久久精品一区二区二区| 色www精品视频在线观看| 欧美亚男人的天堂| 欧美日韩在线播放三区四区| 欧美日韩免费视频| 欧美日韩mp4| 精品理论电影在线| 日韩久久精品一区| 国产婷婷一区二区| 国产精品福利在线播放| 亚洲人123区| 五月综合激情婷婷六月色窝| 美女任你摸久久| 成人av免费在线观看| 在线亚洲一区二区| 91精品国产欧美一区二区18| 26uuu另类欧美| 亚洲欧美日韩久久精品| 亚洲小说欧美激情另类| 青娱乐精品视频| 成人精品高清在线| 色丁香久综合在线久综合在线观看| 69堂亚洲精品首页| 国产欧美日韩不卡免费| 亚洲视频一区在线| 日韩黄色小视频| 波多野结衣视频一区| 欧美撒尿777hd撒尿| 精品少妇一区二区三区视频免付费| 国产精品毛片无遮挡高清| 亚洲成av人片在线观看无码| 欧美亚洲高清一区| 日韩欧美一二三四区| 亚洲日本在线看| 久久精品免费观看| 91精品福利视频| 国产日韩欧美精品综合| 午夜伊人狠狠久久| 国产成人精品免费网站| 欧美三级视频在线观看|