📄 formathandler.h
字号:
//
// 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.
//
#ifndef _EXCHANGECLIENTFORMATHANDLER_H_183346875_ // To prevent multiple #includes
#define _EXCHANGECLIENTFORMATHANDLER_H_183346875_
#include "IExchangeClient.h"
#include "msxml.h"
#include "memtracking.h"
class CXMLDataRecordParser;
struct ParseParameters;
//IExchangeClientFormatHandler abstract class - interface!
//Used for configuring XMLHTTPRequests and XMLDataRecordParsers for various request types
class IExchangeClientFormatHandler
{
public:
//Lifetime management
virtual VOID AddRef() = 0;
virtual VOID Release() = 0;
public:
//Gets the Method, URL and Body necessary to make an HttpRequest
virtual HRESULT GetFormattedHttpParameters(
BSTR * pbstrMethod,
BSTR * pbstrUrl,
BSTR * pbstrBody
) = 0;
//Sets up the parser's internal data structures
virtual HRESULT SetParsingFormat(
CXMLDataRecordParser * pParser
) = 0;
//Sets any additional headers this type of request may need
//(e.g. Content-type: text/xml
virtual HRESULT SetAdditionalHeaders(
IXMLHTTPRequest *piRequest
) = 0;
//Generic initialize method with an extra lparam
virtual HRESULT Initialize(
const WCHAR *c_wszServername,
VOID *pvParam
) = 0;
virtual INT GetDataRecordSize() = 0;
};
//Base implementation of IExchangeFormatHandler - implements base construction/
//lifetime management and parsing via Parameter tables
class CGenericFormatHandler : IExchangeClientFormatHandler
{
public:
CGenericFormatHandler()
{
m_pParameters = NULL;
m_cRefs = 1;
}
virtual ~CGenericFormatHandler()
{
m_pParameters = NULL;
}
public:
//Not thread safe - ASSERTING that this is called within a thread safe
//area of code
VOID AddRef()
{
m_cRefs++;
}
VOID Release()
{
--m_cRefs;
if (m_cRefs <= 0)
delete this;
}
public:
//Functions implemented in the .cpp file
virtual HRESULT GetFormattedHttpParameters(
BSTR * pbstrMethod,
BSTR * pbstrUrl,
BSTR * pbstrBody
);
virtual HRESULT SetParsingFormat(
CXMLDataRecordParser * pParser
);
virtual HRESULT SetAdditionalHeaders(
IXMLHTTPRequest * piRequest
);
virtual HRESULT Initialize(
const WCHAR *c_wszDomain,
VOID *pvParam
);
public:
virtual INT GetDataRecordSize()
{
ASSERT(! L"This should be overloaded");
return -1;
}
protected: //allow children classes to override/call
//Sets parsing table
HRESULT Initialize(
const ParseParameters *pParameters
);
//Generic method to set headers from reg values if the header string exists
HRESULT SetAdditionalHeadersFromValue(
IXMLHTTPRequest *piRequest,
const WCHAR* c_wszHeaderName,
const WCHAR* c_wszValue
);
private:
LONG m_cRefs;
const ParseParameters *m_pParameters;
};
#endif // !defined _EXCHANGECLIENTFORMATHANDLER_H_183346875_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -