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

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

?? wintransportagent.cpp

?? funambol windows mobile plugin source code, the source code is taken from the funambol site
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/*
 * 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
 */

/*
 How to test SSL connections
 ----------------------------

 On the server:
 1) create the keystore:
    %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA
 2) In $CATALINA_HOME/conf/server.xml uncomment the lines:
    <Connector className="org.apache.catalina.connector.http.HttpConnector"
               port="8443" minProcessors="5" maxProcessors="75"
               enableLookups="true"
               acceptCount="10" debug="0" scheme="https" secure="true">
      <Factory className="org.apache.catalina.net.SSLServerSocketFactory" clientAuth="false" protocol="TLS"/>
    </Connector>
 2) Export the certificate from the key store:
    %JAVA_HOME%\bin\keytool -export -alias tomcat -file myroot.cer

 On the client:
  [for _WIN32_WCE]
   1)  Copy myroot.cer in a device/emulator directory
   2) Click on it to import the certificate as a trusted CA
  [for WIN32]
   1) Connect (via https) to the server using a web-browser (type "https://<server_address>:8443)
   2) Accept and install the certificate sent from the server
*/

#include "base/Log.h"
#include "base/messages.h"
#include "base/util/utils.h"
#include "http/constants.h"
#include "http/errors.h"
#include "http/WinTransportAgent.h"
#include "spdm/spdmutils.h"
#include "event/FireEvent.h"
#include "base/util/StringBuffer.h"

#ifdef _WIN32_WCE
#include "http/GPRSConnection.h"
#endif


#define ENTERING(func) // LOG.debug("Entering %ls", func);
#define EXITING(func)  // LOG.debug("Exiting %ls", func);

#ifdef USE_ZLIB
#include "zlib.h"
#endif

/**
 * Constructor.
 * In this implementation newProxy is ignored, since proxy configuration
 * is taken from the WinInet subsystem.
 *
 * @param url    the url where messages will be sent with sendMessage()
 * @param proxy  proxy information or NULL if no proxy should be used
 */
WinTransportAgent::WinTransportAgent(URL& newURL, Proxy& newProxy,
                                     unsigned int maxResponseTimeout,
                                     unsigned int maxmsgsize)
                                     // Use base class constructor to initialize common attributes
                                     : TransportAgent(newURL,
                                     newProxy,
                                     maxResponseTimeout,
                                     maxmsgsize) {

    if (maxResponseTimeout == 0) {
        setTimeout(DEFAULT_MAX_TIMEOUT);
    } else {
        setTimeout(maxResponseTimeout);
    }

    isToDeflate    = FALSE;
    isFirstMessage = TRUE;
    isToInflate    = FALSE;

#ifdef _WIN32_WCE
    // used by default. check connection before...
    if (!EstablishConnection()) {

#  ifdef WIN32_PLATFORM_PSPC
        lastErrorCode = ERR_INTERNET_CONNECTION_MISSING;
        sprintf(lastErrorMsg, "%s: %d",
            "Internet Connection Missing",
            ERR_INTERNET_CONNECTION_MISSING);
#  else
        LOG.error("Warning: internet connection missing.");
#  endif  // #ifdef WIN32_PLATFORM_PSPC
    }
#endif  // #ifdef _WIN32_WCE

}

WinTransportAgent::~WinTransportAgent(){}



/*
 * Sends the given SyncML message to the server specified
 * by the install property 'url'. Returns the server's response.
 * The response string has to be freed with delete [].
 * In case of an error, NULL is returned and lastErrorCode/Msg
 * is set.
 */
char* WinTransportAgent::sendMessage(const char* msg) {

    ENTERING(L"TransportAgent::sendMessage");

#ifdef USE_ZLIB
    // This is the locally allocated buffer for the compressed message.
    // Must be deleted after send.
    Bytef* compr   = NULL;
    WCHAR* wbuffer = NULL;
    WCHAR* buffer  = NULL;
#endif

    char* bufferA = new char[readBufferSize+1];
    int status = -1;
    unsigned int contentLength = 0;
    WCHAR* wurlHost      = NULL;
    WCHAR* wurlResource  = NULL;
    char*  p             = NULL;
    char*  response      = NULL;

    HINTERNET inet       = NULL,
              connection = NULL,
              request    = NULL;


    // Check sending msg and host.
    if (!msg) {
        lastErrorCode = ERR_NETWORK_INIT;
        sprintf(lastErrorMsg, "TransportAgent::sendMessage error: NULL message.");
        goto exit;
    }
    if (!(url.host) || strlen(url.host) == 0) {
        lastErrorCode = ERR_HOST_NOT_FOUND;
        sprintf(lastErrorMsg, "TransportAgent::sendMessage error: %s.", ERRMSG_HOST_NOT_FOUND);
        goto exit;
    }

    DWORD size  = 0,
          read  = 0,
          flags = INTERNET_FLAG_RELOAD |
                  INTERNET_FLAG_NO_CACHE_WRITE |
                  INTERNET_FLAG_KEEP_CONNECTION |           // This is necessary if authentication is required.
                  INTERNET_FLAG_NO_COOKIES;                 // This is used to avoid possible server errors on successive sessions.

	LPCWSTR acceptTypes[2] = {TEXT("*/*"), NULL};


    // Set flags for secure connection (https).
    if (url.isSecure()) {
        flags = flags
              | INTERNET_FLAG_SECURE
              | INTERNET_FLAG_IGNORE_CERT_CN_INVALID
              | INTERNET_FLAG_IGNORE_CERT_DATE_INVALID
              ;
    }


    //
    // Open Internet connection.
    //
    WCHAR* ua = toWideChar(userAgent);
    inet = InternetOpen (ua, INTERNET_OPEN_TYPE_PRECONFIG, NULL, 0, 0);
	if (ua) {delete [] ua; ua = NULL; }

    if (!inet) {
        lastErrorCode = ERR_NETWORK_INIT;
        DWORD code = GetLastError();
        char* tmp = createHttpErrorMessage(code);
        sprintf (lastErrorMsg, "InternetOpen Error: %d - %s", code, tmp);
		delete [] tmp;
        goto exit;
    }
    LOG.debug("Connecting to %s:%d", url.host, url.port);


    //
    // Open an HTTP session for a specified site by using lpszServer.
    //
    wurlHost = toWideChar(url.host);
    if (!(connection = InternetConnect (inet,
                                        wurlHost,
                                        url.port,
                                        NULL, // username
                                        NULL, // password
                                        INTERNET_SERVICE_HTTP,
                                        0,
                                        0))) {
        lastErrorCode = ERR_CONNECT;
        DWORD code = GetLastError();
        char* tmp = createHttpErrorMessage(code);
        sprintf (lastErrorMsg, "InternetConnect Error: %d - %s", code, tmp);
        delete [] tmp;
        goto exit;
    }
    LOG.debug("Requesting resource %s", url.resource);

    //
    // Open an HTTP request handle.
	//
    wurlResource = toWideChar(url.resource);
    if (!(request = HttpOpenRequest (connection,
                                     METHOD_POST,
                                     wurlResource,
                                     HTTP_VERSION,
                                     NULL,
                                     acceptTypes,
                                     flags, 0))) {
        lastErrorCode = ERR_CONNECT;
        DWORD code = GetLastError();
        char* tmp = createHttpErrorMessage(code);
        sprintf (lastErrorMsg, "HttpOpenRequest Error: %d - %s", code, tmp);
        delete [] tmp;
        goto exit;
    }


    //
    // Prepares headers
    //
    WCHAR headers[512];
    contentLength = strlen(msg);

    // Msg to send is the original msg by default.
    // If compression is enabled, it will be switched to
    // compr. We don't want to touch this pointer, so
    // it's const (msg is also const).
    const void* msgToSend = (const void*)msg;

#ifdef USE_ZLIB
    if(compression){
        // This is the locally allocated buffer for the compressed message.
        // Must be deleted after send.

	    //
	    // Say the client can accept the zipped content but the first message is clear
	    //
	    if (isFirstMessage || !isToDeflate) {
	        wsprintf(headers, TEXT("Content-Type: %s\r\nContent-Length: %d\r\nAccept-Encoding: deflate"),
	                          SYNCML_CONTENT_TYPE, contentLength);
	        isFirstMessage = false;
	    }
	    else if (isToDeflate) {
	        //
	        // DEFLATE (compress data)
	        //
	        uLong comprLen = contentLength;
	        compr = new Bytef[contentLength];
	
	        // Compresses the source buffer into the destination buffer.
	        int err = compress(compr, &comprLen, (Bytef*)msg, contentLength);
	        if (err != Z_OK) {
	            lastErrorCode = ERR_HTTP_DEFLATE;
	            sprintf(lastErrorMsg, "ZLIB: error occurred compressing data.");
	            delete [] compr;
	            compr = NULL;
	            goto exit;
	        }
	
	        // Msg to send is the compressed data.
	        msgToSend = (const void*)compr;
	        int uncomprLenght = contentLength;
	        contentLength = comprLen;
	
	        wsprintf(headers, TEXT("Content-Type: %s\r\nContent-Length: %d\r\nAccept-Encoding: deflate\r\nUncompressed-Content-Length: %d\r\nContent-Encoding: deflate"),
	                          SYNCML_CONTENT_TYPE, contentLength, uncomprLenght);
	    }
    }
    else {
        wsprintf(headers, TEXT("Content-Type: %s\r\nContent-Length: %d"), SYNCML_CONTENT_TYPE, contentLength);
    } //end if compression
#else
    wsprintf(headers, TEXT("Content-Type: %s\r\nContent-Length: %d"), SYNCML_CONTENT_TYPE, contentLength);
#endif


    // Timeout to receive a rensponse from server (default = 5 min).
    DWORD timeoutMsec = timeout*1000;
    InternetSetOption(request, INTERNET_OPTION_RECEIVE_TIMEOUT, &timeoutMsec, sizeof(DWORD));


    //
    // Try MAX_RETRIES times to send http request, in case of network errors
    //
    DWORD errorCode = 0;
    int numretries;
    for (numretries=0; numretries < MAX_RETRIES; numretries++) {

        //
        // Send a request to the HTTP server.
        //
        fireTransportEvent(contentLength, SEND_DATA_BEGIN);
        if (!HttpSendRequest(request, headers, wcslen(headers), (LPVOID)msgToSend, contentLength)) {

            errorCode = GetLastError();
            char* tmp = createHttpErrorMessage(errorCode);
            sprintf(lastErrorMsg, "HttpSendRequest error %d: %s", errorCode, tmp);
            LOG.debug(lastErrorMsg);

            if (errorCode == ERROR_INTERNET_OFFLINE_MODE) {                     // 00002 -> retry
                LOG.debug("Offline mode detected: go-online and retry...");
                WCHAR* wurl = toWideChar(url.fullURL);
                InternetGoOnline(wurl, NULL, NULL);
                delete [] wurl;
                continue;
            }
            else if (errorCode == ERROR_INTERNET_TIMEOUT ||                     // 12002 -> out code 2007
                     errorCode == ERROR_INTERNET_INCORRECT_HANDLE_STATE) {      // 12019 -> out code 2007
                lastErrorCode = ERR_HTTP_TIME_OUT;
                sprintf(lastErrorMsg, "Network error: the request has timed out -> exit.");
                LOG.debug(lastErrorMsg);
                goto exit;
            }
            else if (errorCode == ERROR_INTERNET_CANNOT_CONNECT) {              // 12029 -> out code 2001
                lastErrorCode = ERR_CONNECT;
                sprintf(lastErrorMsg, "Network error: the attempt to connect to the server failed -> exit");
                LOG.debug(lastErrorMsg);
                goto exit;
            }
            // Other network error: retry.
            LOG.info("Network error writing data from client: retry %i time...", numretries + 1);
            continue;
        }

        LOG.debug(MESSAGE_SENT);
        fireTransportEvent(contentLength, SEND_DATA_END);


        //
        // Check the status code.
        //
        size = sizeof(status);
        HttpQueryInfo (request,
                       HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER,
                       (LPDWORD)&status,
                       (LPDWORD)&size,
                       NULL);

        // OK: status 200
        if (status == HTTP_STATUS_OK) {
        	LOG.debug("Data sent succesfully to server. Server responds OK");
            break;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧洲三级电影| 欧美刺激午夜性久久久久久久| 麻豆免费看一区二区三区| 亚洲午夜av在线| 悠悠色在线精品| 亚洲另类中文字| 亚洲精品伦理在线| 亚洲制服丝袜av| 亚洲午夜视频在线| 视频一区欧美精品| 狠狠色狠狠色合久久伊人| 日韩精品免费视频人成| 美日韩黄色大片| 激情五月婷婷综合网| 国产成人高清视频| 色婷婷亚洲婷婷| 9191成人精品久久| 久久亚洲精品国产精品紫薇| 国产三级久久久| 亚洲女人小视频在线观看| 玉米视频成人免费看| 亚洲午夜在线观看视频在线| 日韩**一区毛片| 国产综合色在线| 日本不卡不码高清免费观看| 天天影视涩香欲综合网| 久久99久久99小草精品免视看| 国产一区二区毛片| 色综合天天综合网天天狠天天| 精品视频在线视频| 久久久久久一级片| 亚洲欧洲美洲综合色网| 亚洲午夜激情网站| 国产麻豆一精品一av一免费| 99久久国产综合精品色伊| 在线电影一区二区三区| 国产香蕉久久精品综合网| 一区二区不卡在线视频 午夜欧美不卡在| 亚洲国产精品自拍| 国产aⅴ精品一区二区三区色成熟| jvid福利写真一区二区三区| 777奇米成人网| 亚洲男女毛片无遮挡| 久久91精品久久久久久秒播| 91香蕉视频污| 久久午夜羞羞影院免费观看| 亚洲成人一区二区在线观看| 国产福利一区在线| 日韩美女一区二区三区四区| 一区二区三区 在线观看视频| 国产一区二区三区在线观看免费视频 | 国内精品写真在线观看| 色综合色综合色综合色综合色综合 | 亚洲欧美自拍偷拍| 久久精品国产亚洲a| 91久久精品一区二区二区| 国产欧美一区二区三区在线老狼| 日韩av网站在线观看| 91久久精品网| 亚洲天堂2014| 成人在线视频一区| 久久精品亚洲一区二区三区浴池| 日韩av一二三| 欧美日韩国产系列| 一个色在线综合| 99re在线视频这里只有精品| 国产精品区一区二区三| 国产一区二区三区av电影 | 国产麻豆午夜三级精品| 91麻豆精品国产综合久久久久久 | 欧美性生活一区| 亚洲自拍偷拍图区| 色婷婷久久99综合精品jk白丝 | 丝袜美腿亚洲综合| 欧美午夜视频网站| 亚洲成a人v欧美综合天堂下载 | 日韩免费高清电影| 亚洲444eee在线观看| 欧美午夜精品一区二区蜜桃| 一区二区成人在线视频| 欧美日韩在线亚洲一区蜜芽| 亚洲一区欧美一区| 欧洲激情一区二区| 午夜电影一区二区三区| 欧美一级二级在线观看| 免费观看日韩电影| 精品国产一区二区国模嫣然| 久久99精品一区二区三区| 久久久久亚洲蜜桃| 成人中文字幕电影| 一个色综合av| 欧美一级日韩免费不卡| 蜜臀va亚洲va欧美va天堂| 亚洲精品在线网站| 国产99久久久国产精品潘金 | 久久久久99精品国产片| 风间由美一区二区三区在线观看| 国产精品福利一区二区三区| 91久久人澡人人添人人爽欧美| 亚洲va欧美va人人爽午夜| 欧美老肥妇做.爰bbww视频| 热久久久久久久| 久久精品一区八戒影视| 一本久久精品一区二区| 亚洲成人午夜电影| 久久影院午夜片一区| av网站一区二区三区| 亚洲123区在线观看| 国产欧美日韩中文久久| 欧美亚洲免费在线一区| 国产乱码精品一区二区三| 亚洲精品第一国产综合野| 日韩一区二区电影网| 99久久综合精品| 精品一区二区三区免费播放| 中文字幕视频一区| 日韩女优电影在线观看| 91网站在线播放| 国产一区三区三区| 午夜精品一区二区三区电影天堂 | 日韩国产精品久久久| 国产精品美女久久久久久久网站| 欧美乱熟臀69xxxxxx| 成人在线视频一区| 激情综合网av| 午夜国产精品一区| 亚洲欧美一区二区三区孕妇| 精品成人一区二区| 在线播放91灌醉迷j高跟美女 | 亚洲国产精品久久人人爱蜜臀| 日本人妖一区二区| 日韩一区二区三| 一本色道久久综合狠狠躁的推荐| 国产成人精品一区二| 免费观看一级欧美片| 亚洲综合久久久| 国产精品的网站| 中文字幕不卡的av| 26uuu另类欧美| 日韩一区二区三| 欧美日韩一区二区三区四区五区| av在线一区二区三区| 成人精品电影在线观看| 国产精品亚洲视频| 国内外成人在线| 九九精品视频在线看| 麻豆精品视频在线| 日韩av电影一区| 麻豆一区二区99久久久久| 欧美aaa在线| 蜜桃久久久久久| 久久精品国产亚洲一区二区三区| 日本vs亚洲vs韩国一区三区 | 日韩欧美国产成人一区二区| 欧美色男人天堂| 欧美日韩激情一区二区| 在线成人av网站| 日韩欧美123| 久久精品一级爱片| 国产精品日产欧美久久久久| 国产日韩视频一区二区三区| 国产精品美女www爽爽爽| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ原创 | av一区二区不卡| 91视频观看免费| 在线一区二区三区四区| 欧美一a一片一级一片| 9191成人精品久久| 久久新电视剧免费观看| 国产精品人妖ts系列视频| 亚洲欧美电影一区二区| 午夜精品久久久久影视| 蜜桃av噜噜一区| a级精品国产片在线观看| 91在线国内视频| 欧美二区在线观看| 国产午夜久久久久| 亚洲女性喷水在线观看一区| 日韩电影一区二区三区四区| 韩国成人在线视频| 91丝袜呻吟高潮美腿白嫩在线观看| 色老综合老女人久久久| 欧美videos中文字幕| 国产精品女主播av| 石原莉奈在线亚洲二区| 国产成+人+日韩+欧美+亚洲| 在线国产电影不卡| 26uuu成人网一区二区三区| 亚洲日本在线看| 裸体一区二区三区| 99国内精品久久| 亚洲精品在线三区| 亚洲精选在线视频| 国产福利一区二区三区视频在线| 91精彩视频在线观看| 久久久久久电影| 天天操天天综合网| 97久久人人超碰| 久久久久久久久久久久电影| 一二三四社区欧美黄|