亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
日韩手机在线导航| 国产欧美一区在线| 日本不卡中文字幕| 精品久久久久一区| 成人av电影在线观看| 中文字幕亚洲视频| 91精品在线一区二区| 国产精品影视网| 国产精品免费aⅴ片在线观看| 欧美性高清videossexo| 极品瑜伽女神91| 亚洲精品乱码久久久久久日本蜜臀| 精品国产凹凸成av人导航| 成年人午夜久久久| 久久国产婷婷国产香蕉| 一区二区三区四区av| 538在线一区二区精品国产| 欧美一级日韩不卡播放免费| 国产精品女主播在线观看| 午夜精品123| 91久久国产最好的精华液| 另类调教123区| 黄一区二区三区| 久久精品国产在热久久| 欧美一区二区精品在线| 依依成人精品视频| 在线中文字幕一区| 成人精品视频一区二区三区尤物| 一区二区三区在线免费观看| 91九色最新地址| 日本色综合中文字幕| 欧美二区三区91| 亚洲日穴在线视频| 一区二区免费看| 精品日本一线二线三线不卡| jizz一区二区| 国产高清久久久| 国产999精品久久久久久绿帽| 日韩一本二本av| 亚洲精品美腿丝袜| 日韩欧美高清dvd碟片| 午夜精品久久久久久久99樱桃| 岛国精品在线观看| 国产欧美1区2区3区| 国产99久久久久久免费看农村| 综合欧美一区二区三区| 国产一区二区三区最好精华液| 26uuu亚洲综合色欧美| 成人黄色在线网站| 久久久久久**毛片大全| 秋霞电影网一区二区| 日韩精品综合一本久道在线视频| 91免费小视频| 久久蜜桃av一区精品变态类天堂 | 中文字幕一区二区三区在线播放 | 成人免费看的视频| 欧美大尺度电影在线| 国产在线播放一区| 欧美性xxxxxx少妇| 一区二区在线观看免费视频播放| 欧美成人video| 91在线无精精品入口| 国产精品嫩草99a| 国产精品第13页| 国产亚洲欧美一级| 亚洲精品在线观| 欧美日韩一区高清| www.成人网.com| 99在线视频精品| 美女爽到高潮91| 日韩高清不卡在线| 亚洲成人精品影院| 欧美日韩日日摸| 久久精品99国产国产精| 在线观看网站黄不卡| 精品入口麻豆88视频| 亚洲精品在线免费播放| 精品国产乱码久久久久久浪潮| 成人欧美一区二区三区视频网页| 青青草97国产精品免费观看 | 久久99久久精品| 欧美电影影音先锋| 青青草97国产精品免费观看| 亚洲综合在线第一页| 日韩一区二区免费在线电影 | 国产欧美一区二区三区沐欲| 久久综合九色综合97_久久久| 久久婷婷成人综合色| 欧美一区二区三区免费在线看| 91免费观看视频在线| 日本韩国精品一区二区在线观看| 日本不卡一二三| 大桥未久av一区二区三区中文| 国产一区二区三区在线观看免费视频 | 麻豆91免费看| 久久er99精品| 国产a精品视频| 久久99国产精品久久| www.欧美亚洲| 国产欧美一区二区精品性| wwwwww.欧美系列| 日本中文一区二区三区| 美女视频网站久久| 91啪亚洲精品| 91福利国产精品| 中文字幕精品综合| 亚洲天堂2014| 国产精品福利一区| 久久久精品中文字幕麻豆发布| 精品国产一二三| 亚洲精品乱码久久久久久| 奇米影视一区二区三区小说| 欧美色综合网站| 一二三四区精品视频| 久久无码av三级| 日韩在线一区二区三区| 成人一区二区视频| 欧美电影免费观看高清完整版在线观看 | 91麻豆产精品久久久久久| 欧美一区午夜精品| 亚洲国产中文字幕在线视频综合| 激情图片小说一区| 日韩欧美中文字幕精品| 一区二区三区欧美在线观看| 成人av片在线观看| 欧美成人性福生活免费看| 日本强好片久久久久久aaa| 91社区在线播放| 国产精品久久久久影院色老大| 美女脱光内衣内裤视频久久网站| 欧美日本乱大交xxxxx| 亚洲图片激情小说| aaa亚洲精品| 久久精品视频免费| 国产高清久久久| 337p亚洲精品色噜噜噜| 日韩国产精品久久| 欧美视频中文一区二区三区在线观看| 欧美一卡2卡3卡4卡| 欧美aaaaaa午夜精品| 欧美一区二区播放| 捆绑变态av一区二区三区| 欧美日韩国产一二三| 午夜精品福利视频网站| av成人动漫在线观看| 精品少妇一区二区三区在线视频| 免费视频最近日韩| 国产精品理论片| 欧美一二三区精品| 欧美精品99久久久**| 国产一区二区三区蝌蚪| 一区二区高清视频在线观看| 日韩色视频在线观看| caoporn国产一区二区| 久久综合狠狠综合久久综合88| 亚洲综合一区二区| 国产精品中文欧美| 欧美精品一区二区三区四区| 国产精品一卡二| 国产日本一区二区| 成人黄色小视频在线观看| 欧美成人video| 成人一区二区三区中文字幕| 亚洲欧美一区二区三区极速播放| 91麻豆精品在线观看| 亚洲影院在线观看| 欧美美女视频在线观看| 麻豆高清免费国产一区| 欧美成人a∨高清免费观看| 东方aⅴ免费观看久久av| 欧美激情在线一区二区| 91国产成人在线| 亚洲午夜免费电影| 日韩一级二级三级| 粉嫩av亚洲一区二区图片| 国产精品你懂的在线| 欧美午夜宅男影院| 欧美aⅴ一区二区三区视频| 国产精品家庭影院| 色婷婷综合激情| 久久99精品久久久久久国产越南| 国产日韩欧美综合在线| 欧美性大战久久久| 国产精品一区二区在线看| av激情综合网| 日韩一区二区不卡| 亚洲一区二区三区自拍| 国产一区二区日韩精品| 国产精品网站在线播放| 日本中文一区二区三区| 不卡av在线免费观看| 国产精品美女久久久久久久久久久| 色综合天天综合色综合av| 亚洲国产成人精品视频| 日韩欧美国产一区二区在线播放| 九九久久精品视频| 国产精品视频一二三| 欧美精品tushy高清| 99精品欧美一区二区三区小说 | 欧美电影免费观看高清完整版|