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

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

?? exchangeclient.cpp

?? 一個WinCE6。0下的IP phone的源代碼
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
#include "ExchangeClient.h"
#include "..\contacts\ContactsFormatHandler.h"
#include "..\galsearch\GALSearchFormatHandler.h"
#include "..\freebusy\FreeBusyFormatHandler.h"
#include "ExchangeRequest.h"
#include "XMLDataRecordParser.h"
#include <algorithm>
#include "Settings.h"
#include "utilities.h"
#include "SecurityUtils.h"

const WCHAR c_wszWindowName[] = L"ExchangeClientHiddenWindow";

#define ECM_WORKER_THREAD_TERMINATED    (WM_USER + 100)
#define ECM_USER_CALLBACK               (ECM_WORKER_THREAD_TERMINATED + 1)

/*------------------------------------

        Constructor/Destructor

------------------------------------*/
CExchangeClient::CExchangeClient()
{
    TRACE_(ZONE_OWAEC_TRACING_CTOR);
    MemTrackAdd();
    
    m_cpCallback       = NULL;
    m_cpHttpRequest    = NULL;
    m_fInitialized     = FALSE;
    m_hEventExit       = NULL;
    m_hEventNewRequest = NULL;
    m_hWorkerThread    = NULL;
    m_hwndCallback     = NULL;
    InitializeRequestLock();
}

CExchangeClient::~CExchangeClient()
{
    TRACE_(ZONE_OWAEC_TRACING_CTOR);
    MemTrackRemove();

    //Force the CComPtr's to release their references
    m_cpCallback    = NULL;
    m_cpHttpRequest = NULL;
    SetCurrentRequest(NULL);
    m_cpXMLHTTPRequestClassFactory = NULL;
    
    //Close the event/thread handles
    CloseHandle(m_hEventExit);
    CloseHandle(m_hEventNewRequest);
    CloseHandle(m_hWorkerThread);
    UnregisterClass(c_wszWindowName, _Module.m_hInst);

    //Free each request in the queue
    CExchangeClientRequest *pRequest      = NULL;
    BOOL                    fMoreRequests = TRUE;
    
    while (fMoreRequests)
    {
        if (GetNextRequest(&pRequest) == S_FALSE)
        {
            fMoreRequests = FALSE;
            break;
        }
        else
        {
            SafeRelease(pRequest);
        }
    }

    DeleteRequestLock();
}

/*--------------------------------------------------------------

        IExchangeClient Implementation

---------------------------------------------------------------*/

/*------------------------------------------------------------------------------
    CExchangeClient::Initialize
    
    Initializes the exchange client by setting up callbacks and internal
    data structures
    
    Returns (HRESULT): Indicating success or failure
------------------------------------------------------------------------------*/
HRESULT CExchangeClient::Initialize(
    IExchangeClientRequestCallback *piCallback
    )
{
    TRACE();
    HRESULT     hr = S_OK;

    //check params
    if (m_fInitialized)
    {
        return OWAEC_E_ALREADYINITIALIZED;
    }

    //Check parameters
    if (piCallback == NULL)
    {
        return E_POINTER;
    }

    //Initialize the callback pointer and the critical section
    m_cpCallback = piCallback;

    if (SUCCEEDED(hr))
    {
        //create the xmlhttp request class factory
        hr = CoGetClassObject(
            CLSID_XMLHTTPRequest,
            CLSCTX_INPROC_SERVER,
            NULL,
            IID_IClassFactory,
            reinterpret_cast<void**>(&m_cpXMLHTTPRequestClassFactory)
            );
    }

    if (SUCCEEDED(hr))
    {
        //Create the XMLHttp request object
        hr = RecreateXMLHttpObject();
    }

    if (SUCCEEDED(hr))
    {
        //register the hidden window for handling callbacks
        hr = RegisterCallbackWindow();
    }

    if (SUCCEEDED(hr))
    {
        //create the events and worker thread that will handle the requests
        hr = CreateWorkerThreadAndEvents();
    }
    
    m_fInitialized = SUCCEEDED(hr);

    //cleanup in case of failure
    if (FAILED(hr))
    {
        //CComPtr's release references to previously allocated objects
        m_cpHttpRequest                = NULL;
        m_cpCallback                   = NULL;
        m_cpXMLHTTPRequestClassFactory = NULL;
    }
    
    return hr;
}

/*------------------------------------------------------------------------------
    CExchangeClient::CreateXMLHttpObject
    
    Create's the IXMLHTTPRequest object through the class factory obtained on initialization
------------------------------------------------------------------------------*/
HRESULT CExchangeClient::RecreateXMLHttpObject()
{
    PREFAST_ASSERT(m_cpXMLHTTPRequestClassFactory != NULL);
    
    m_cpHttpRequest = NULL;

    return m_cpXMLHTTPRequestClassFactory->CreateInstance(
        NULL,
        IID_IXMLHTTPRequest,
        reinterpret_cast<void**>(&m_cpHttpRequest)
        );
}

/*------------------------------------------------------------------------------
    CExchangeClient::CreateWorkerThreadAndEvents
    
    Creates the worker thread and events used for signalling between threads
    
    Returns (HRESULT): Indicating whether the events and threads were initialized
                       successfully
------------------------------------------------------------------------------*/
HRESULT CExchangeClient::CreateWorkerThreadAndEvents()
{
    HRESULT     hr = S_OK;

    if (SUCCEEDED(hr))
    {
        //Create the Exit and NewRequest events
        m_hEventExit       = CreateEvent(NULL, TRUE, FALSE, NULL);
        m_hEventNewRequest = CreateEvent(NULL, TRUE, FALSE, NULL);
        
        if (!m_hEventExit || !m_hEventNewRequest)
        {
            hr = HRESULT_FROM_WIN32(GetLastError());
        }
    }

    if (SUCCEEDED(hr))
    {
        //Include 'this' as the parameter to the worker thread.
        //Add a reference to myself to ensure the thread can always
        //access the object variables correctly
        AddRef();
        
        m_hWorkerThread = CreateThread(
            NULL,
            0,
            s_WorkerThreadProc,
            reinterpret_cast<void*>(this),
            0,
            NULL
            );
        
        if (m_hWorkerThread == NULL)
        {
            //If we couldn't create the thread, release the reference added
            //before the call to CreateThread
            Release();
            hr = HRESULT_FROM_WIN32(GetLastError());
            DEBUGMSG(ZONE_OWAEC_ERROR, (L"OWAExchangeClient:: Failed to create worker thread 0x%x", hr));
        }
    }

    if (FAILED(hr))
    {
        //if creating the thread failed, but we were able to create the events
        //close and delete the event handles
        CloseHandle(m_hEventExit);
        m_hEventExit = NULL;
        
        CloseHandle(m_hEventNewRequest);
        m_hEventExit = NULL;
    }
    return hr;
}


/*------------------------------------------------------------------------------
    CExchangeClient::RegisterCallbackWindow
    
    Register the internal hidden window used to marshall results between threads
    back to the main application
    
    Returns (HRESULT): Indicating whether the window was registered properly or
                       S_FALSE to indicate the window was previously registered
------------------------------------------------------------------------------*/
HRESULT CExchangeClient::RegisterCallbackWindow()
{
    //if the hidden window is already registered, return S_FALSE
    if (m_hwndCallback != NULL)
    {
        return S_FALSE;
    }
    
    HRESULT     hr   = S_OK;
    WNDCLASS    wc   = {0};
    
    wc.lpfnWndProc   = s_CallbackWindowProc;
    wc.cbWndExtra    = sizeof(this); 
    wc.hInstance     = _Module.m_hInst;
    wc.lpszClassName = c_wszWindowName;

    if (RegisterClass(&wc) == 0)
    {
        DWORD dwLastErr = GetLastError();
        if (dwLastErr != ERROR_CLASS_ALREADY_EXISTS)
        {
            hr = HRESULT_FROM_WIN32(dwLastErr);
        }
    }  
    
    if (SUCCEEDED(hr))
    {
        //Going to pack 'this' into the CREATESTRUCT of CreateWindow, so add a reference to myself
        AddRef();
        
        m_hwndCallback = CreateWindow(
            (LPCWSTR)c_wszWindowName,
            NULL,
            WS_OVERLAPPED & ~WS_VISIBLE,
            0,
            0,
            0,
            0,
            NULL,
            NULL,
            _Module.m_hInst,
            reinterpret_cast<VOID*>(this)
            );

        if (m_hwndCallback == NULL)
        {
            //if we couldn't create the window, release the reference added before the call
            //to CreateWindow
            
            Release();
            hr = HRESULT_FROM_WIN32(GetLastError());
            DEBUGMSG(ZONE_OWAEC_ERROR, (L"OWAExchangeClient:: Failed to create hidden window 0x%x", hr));
        }
    }

    //Nothing to clean up
    return hr;
}

/*------------------------------------------------------------------------------
    CExchangeClient::s_CallbackWindowProc
    
    Static Window Proc on the main app thread - used for marshalling data
    between threads
------------------------------------------------------------------------------*/
LRESULT CALLBACK CExchangeClient::s_CallbackWindowProc(
    HWND    hwnd,
    UINT    uMsg,
    WPARAM  wParam,
    LPARAM  lParam
    )
{
    //The client instance to use
    CExchangeClient *pClient = NULL;
    LRESULT          lRes    = 0;
    HRESULT          hr      = S_OK;

    //In the case of WM_CREATE, pack the ExchangeClient instance into the WindowLong of the
    //window and prepare for the rest of the callbacks
    if (uMsg == WM_CREATE)
    {
        CREATESTRUCT *pcs = reinterpret_cast<CREATESTRUCT *>(lParam);
        if (pcs == NULL)
        {
            ASSERT(FALSE);
            return E_UNEXPECTED;
        }

        pClient = reinterpret_cast<CExchangeClient*>(pcs->lpCreateParams);
        if (pClient == NULL)
        {
            ASSERT(FALSE);
            return E_UNEXPECTED;
        }

        //store the pointer in the window class
        SetWindowLong(
            hwnd,
            0,
            reinterpret_cast<LONG_PTR>(pClient)
            );
    }
    //Otherwise get the client from the window long to use in handling the message
    else 
    {
        pClient = reinterpret_cast<CExchangeClient*>(GetWindowLong(hwnd, 0));
        if (pClient == NULL)
        {
            ASSERT(FALSE);
            hr = HRESULT_FROM_WIN32(GetLastError());
        }
    }

    //Dispatch the message to the appopriate handler
    if (SUCCEEDED(hr))
    {
        switch (uMsg)
        {
        //When the window is being destroyed - release the reference to the client
        //that was added before the window was created
        case WM_DESTROY:
            pClient->Release();
            break;

        case ECM_WORKER_THREAD_TERMINATED:
            DestroyWindow(hwnd);
            (VOID)pClient->GetCallbackInterface()->OnShutdown();
            break;

        case ECM_USER_CALLBACK:
            (VOID)pClient->GetCallbackInterface()->OnRequestProgress(
                (IExchangeClientRequest*)wParam,
                (ExchangeClientRequestStatus)lParam
                );
            ((IExchangeClientRequest*)wParam)->Release();
            break;
            
        default:
            lRes = DefWindowProc(hwnd, uMsg, wParam, lParam);
            break;
        }
    }

    return lRes;
}

/*------------------------------------------------------------------------------
    CExchangeClient::s_WorkerThreadProc
    
    Worker Thread ThreadProc - unpacks the CExchangeClient instance and 
    begins the processing of requests

    There was a reference added to the client for the thread proc, 
    before terminating this proc needs to release the reference added to the client
        
    Parameters:
        LPVOID - VOID casted ExchangeClient to unpack
    
------------------------------------------------------------------------------*/
DWORD WINAPI CExchangeClient::s_WorkerThreadProc(LPVOID lpvThreadParam)
{
    TRACE();
    if (lpvThreadParam == NULL)
    {
        ASSERT(FALSE);
        return E_POINTER;
    }

    CExchangeClient *pClient = reinterpret_cast<CExchangeClient*>(lpvThreadParam);

    HRESULT hr =  pClient->WorkerThreadProc();

    //epilogue (notify callback etc)
    (VOID)pClient->OnWorkerThreadTermination();

    //release the reference added before CreateThread
    pClient->Release();

    DEBUGMSG(ZONE_OWAEC_TRACING_INFORMATIONAL, (L"OWAExchangeClient:: Worker thread exiting with hr = 0x%x", hr));
    
    return (DWORD)hr;
}

/*------------------------------------------------------------------------------

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成人一二三| 亚洲国产精品精华液网站| 欧美综合一区二区| 精品一区二区在线免费观看| 国产精品乱人伦| 欧美tk—视频vk| 337p亚洲精品色噜噜噜| 99国产精品久| 国产激情一区二区三区四区 | 伊人一区二区三区| 欧美日韩精品欧美日韩精品| 国产精品资源网| 日韩av成人高清| 亚洲一区二区三区四区在线观看 | 国产精品日韩成人| 欧美肥胖老妇做爰| 欧美专区亚洲专区| 91丝袜呻吟高潮美腿白嫩在线观看| 老司机午夜精品| 日韩高清不卡一区二区| 亚洲激情图片qvod| 亚洲精品国产无套在线观| 亚洲天堂成人在线观看| 国产精品美女久久久久久久| 久久久精品影视| 国产精品久久一卡二卡| 国产精品久久久久久久蜜臀| 亚洲欧美自拍偷拍色图| 日韩一区在线播放| 亚洲精品一二三四区| 国产精品午夜在线观看| 中文字幕在线观看不卡| 亚洲美女精品一区| 日韩激情视频网站| 另类的小说在线视频另类成人小视频在线| 亚洲第一搞黄网站| 久久疯狂做爰流白浆xx| 成人午夜在线视频| 欧美专区日韩专区| 精品福利视频一区二区三区| 久久久国产精品午夜一区ai换脸| 国产精品午夜久久| 亚洲国产另类av| 国产毛片精品国产一区二区三区| 高清不卡在线观看| 欧美一区二区三区日韩| 国产精品成人一区二区艾草 | 中文字幕 久热精品 视频在线 | 麻豆91精品视频| 不卡电影一区二区三区| 欧美精品v日韩精品v韩国精品v| 欧美精品一区二区三区一线天视频| 久久精品夜色噜噜亚洲aⅴ| 综合久久久久久| 国内精品久久久久影院色| 色老汉一区二区三区| 久久伊99综合婷婷久久伊| 亚洲成人自拍偷拍| 成人av午夜电影| 精品乱人伦小说| 午夜一区二区三区视频| av电影在线观看不卡| 国产亚洲成年网址在线观看| 亚洲在线观看免费视频| 国产成人av福利| 精品国产成人在线影院 | 国产精品自拍三区| 成人午夜私人影院| 久久女同互慰一区二区三区| 日韩高清欧美激情| 欧美色网站导航| 亚洲国产美女搞黄色| 欧美三级资源在线| 亚洲自拍另类综合| 欧美视频一区二区在线观看| 亚洲综合色噜噜狠狠| 欧美电影一区二区三区| 亚洲bt欧美bt精品| 日韩一区二区三区四区五区六区 | 欧美色综合网站| 91婷婷韩国欧美一区二区| 日韩欧美一二三四区| 国产午夜亚洲精品不卡| 处破女av一区二区| 成人免费视频在线观看| 日本电影欧美片| 中文字幕一区二区三区乱码在线| 一区二区三区日韩欧美| 老司机精品视频在线| 91影院在线观看| 日韩精品专区在线影院重磅| 国产夜色精品一区二区av| 亚洲另类在线制服丝袜| 免费在线观看一区| 99久久精品国产网站| 欧美在线视频全部完| 国产人久久人人人人爽| 日日欢夜夜爽一区| www.亚洲国产| 国产欧美日韩不卡| 国产一区在线视频| 日韩精品一区二区三区视频| 亚洲午夜激情av| 色香色香欲天天天影视综合网| 久久色在线视频| 久久se这里有精品| 亚洲精品一区二区三区香蕉| 亚洲成人先锋电影| 717成人午夜免费福利电影| 亚洲自拍偷拍网站| 欧美日韩国产大片| 视频一区国产视频| 在线电影一区二区三区| 丝袜美腿亚洲色图| 日韩午夜电影av| 韩国精品久久久| 精品福利一二区| 北条麻妃一区二区三区| 99热99精品| 亚洲无人区一区| 欧美日韩三级一区二区| 久久66热re国产| 国产欧美视频一区二区三区| 91尤物视频在线观看| 亚洲va国产天堂va久久en| 日韩精品资源二区在线| 国产v日产∨综合v精品视频| 亚洲特级片在线| 91精品国产综合久久蜜臀| 国产在线国偷精品免费看| 亚洲日本免费电影| 欧美不卡一区二区| 一本色道a无线码一区v| 久久精品99国产精品| 亚洲综合在线电影| 久久久国产精华| 精品久久久久久久久久久久久久久 | 欧美曰成人黄网| 26uuu欧美日本| 1000精品久久久久久久久| 成av人片一区二区| 日韩成人免费在线| 一区二区三区日韩欧美| 国产精品精品国产色婷婷| 欧美变态tickling挠脚心| 91久久久免费一区二区| 成人在线视频首页| 高清beeg欧美| 风间由美一区二区av101 | 精品电影一区二区| 欧美日韩国产成人在线91| 欧美性猛交xxxx黑人交| 成人av资源在线观看| 国产成人亚洲精品青草天美| 久久99精品一区二区三区三区| 青草av.久久免费一区| 日韩精品一二三| 精品一区中文字幕| 成人精品gif动图一区| 成人蜜臀av电影| 一本大道久久a久久精二百| 成人app网站| 欧美一二三区精品| 国产精品久线在线观看| 亚洲.国产.中文慕字在线| 国产美女在线精品| 在线中文字幕一区二区| 91精品国产手机| 欧美极品aⅴ影院| 午夜欧美大尺度福利影院在线看| 美女诱惑一区二区| 欧美在线观看视频一区二区三区| 3d动漫精品啪啪| 欧美激情自拍偷拍| 久久国产精品72免费观看| 在线观看视频欧美| 欧美国产视频在线| 精品一区精品二区高清| 欧美日韩激情一区二区| 国产精品成人一区二区艾草| 国产在线精品国自产拍免费| 7777精品伊人久久久大香线蕉经典版下载| 欧美一区三区二区| 视频一区在线视频| 制服丝袜亚洲精品中文字幕| 中文乱码免费一区二区| 国产高清不卡一区| 26uuu亚洲| 国产在线一区二区| 久久亚洲一区二区三区四区| 蜜臀av亚洲一区中文字幕| 欧美肥妇毛茸茸| 石原莉奈在线亚洲二区| 欧美日本在线播放| 琪琪一区二区三区| 日本一区二区成人| 在线一区二区视频| 免费黄网站欧美| 国产日韩欧美电影| 欧美视频在线不卡|