📄 sdkemsviewerruleclient.h
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/******************************************************************************
File: SDKEMSViewerRuleClient.h
Purpose: Class and macros definitions for EMS rule client
******************************************************************************/
#pragma once
#pragma warning(disable : 4201)
#pragma warning(disable : 4512)
#pragma warning(disable : 4245)
#pragma warning(disable : 4063)
#include <windows.h>
#include <stdlib.h>
#include <cemapi.h>
//MACROS///////////////////////////////////////////////////////////////////////
#define CountOf(p) (sizeof(p) / sizeof(*(p)))
#define SAFE_RELEASE(p) if(p){p->Release(); p=NULL;}
#define SAFE_DELETE(p) if(p){delete p; p=NULL;}
#define CBR(fResult, bRet) do {if (!(fResult)){bRet = FALSE; goto Exit;}} while(0,0)
#define CBRH(fResult, hr) do {if (!(fResult)){hr = E_FAIL; goto Exit;}} while(0,0)
#define STR_EMSID _T("{0FB7FE4F-BC3C-41ef-9B86-E916F5C25CA6}")
/*Information Element Identifiers, defined in "3GPP TS 23.040 V4.3.0 (2001-06)"
These are the ones of interest in processing EMS messages*/
#define IEI_MULTI_8BIT 0x00 //Present only if multipart SM
#define IEI_MULTI_16BIT 0x08 //ditto, but ID is 2 octets
#define IEI_TEXT_FORMATTING 0x0A //Text formatting info
#define IEI_PREDEFINED_SOUND 0x0B //System defined sound
#define IEI_USERDEFINED_SOUND 0x0C //custom sound data (max 128 bytes)
#define IEI_PREDEFINED_ANIM 0x0D //System defined animation
#define IEI_LARGE_ANIM 0x0E //custom animation 32x32x4
#define IEI_SMALL_ANIM 0x0F //custom animation 16x16x4
#define IEI_LARGE_PICTURE 0x10 //32x32 picture
#define IEI_SMALL_PICTURE 0x11 //16x16 picture
#define IEI_VARIABLE_PICTURE 0x12 //NxN picture
#define IEI_USER_PROMPT 0x13 //Notification to prompt user
#define IEI_TEXT_ONLY 0xFF //NOT 3GPP defined, but we only use
//it on incoming data, not sent out
#define PICTURE_RES_LARGE 32 //Dimensions of LARGE PICTURE
#define PICTURE_RES_SMALL 16 //Dimensions of SMALL PICTURE
#define MAX_IMELODY_LEN 128 //Max byte length of iMelody data
#define BASE_HEX 16 //Hex base for _itot
#define BASE_BIN 2 //Binary base for _itot
#define NUM_ANIM_FRAMES 4 //Frames in animation sequence
#define MAX_EMS_HEADERS 255 //Max parts of Multipart SM
typedef HRESULT (*FPCREATEINSTANCE)(IUnknown*, IUnknown**);
typedef union _SMREFIDVAL {
BYTE chRefID; //8-bit ID
WORD wRefID; //16-bit ID
} SMREFIDVAL, *LPSMREFIDVAL;
typedef struct _EMSHEADERINFO {
LPBYTE lpData; //Header buffer
UINT cbData; //Size of buffer
LPTSTR pszUserData;//Text string in SM
UINT uNumParts; //Number of parts in SM
UINT uCurrPart; //Current part
BOOL fMultiPart; //TRUE if part of larger message
BOOL fRef16Bit; //TRUE if using 16bit ref id
SMREFIDVAL smRefIDVal; //ID, valid only if fMultiPart is TRUE
} EMSHEADERINFO, *LPEMSHEADERINFO;
#define FREE_EMSHEADERINFO(p) {if(NULL != p.lpData){free(p.lpData); p.lpData = NULL;}\
if(NULL != p.pszUserData){free(p.pszUserData);}memset(&p, 0, sizeof(p));}
/******************************************************************************
CFactoryData - Each component hosted by CFactory in the DLL must register
with the global varibale g_rgFactoryData, which is a collection of the info
in this class. This info is needed so one generic class factory can create
several different components (as oppossed to having to write a class factory
for each one - which is boring and repetitive).
The global variable, g_rgFactoryData, is in SDKEMSViewerRuleClient.cpp
******************************************************************************/
class CFactoryData
{
public:
//CLSID of component
const CLSID* m_pCLSID;
//Pointer to function that creates component
FPCREATEINSTANCE CreateInstance;
//Helper to check CLSID
BOOL IsClassID(const CLSID& clsid) const { return (*m_pCLSID == clsid); }
};
/******************************************************************************
CFactory - Generic class factory for all the components in this DLL. The
sharing magic is accomplished by the GetClassObject method, called by
DllGetClassObject, which will look up the CLSID in the supported components
global array and create the proper class factory.
******************************************************************************/
class CFactory : public IClassFactory
{
public:
CFactory(const CFactoryData* pFData);
~CFactory();
//IUnknown interface
STDMETHOD (QueryInterface)(const IID& iid, LPVOID *ppv);
STDMETHOD_(ULONG, AddRef)();
STDMETHOD_(ULONG, Release)();
//IClassFactory interface
STDMETHOD (CreateInstance)(IUnknown *pUnknownOuter, const IID& iid, LPVOID *ppv);
STDMETHOD (LockServer)(BOOL bLock);
//Called by DllGetClassObject
static HRESULT GetClassObject(const CLSID& clsid, const IID& iid, void** ppv);
private:
long m_cRef; //object reference count
CFactoryData m_FactoryData; //info needed to create the correct component
//provided by GetClassObject() method
};
/******************************************************************************
CRuleClientBase - Rule client base class. It implements IUnknown goo, and
some basic functionality. Derived classes implement the IMailRuleClient
methods.
******************************************************************************/
class CRuleClientBase : public IMailRuleClient
{
protected:
CRuleClientBase();
virtual ~CRuleClientBase();
//IUnknown interface
STDMETHOD (QueryInterface)(const IID& iid, LPVOID *ppv);
STDMETHOD_(ULONG, AddRef)();
STDMETHOD_(ULONG, Release)();
//Derived classes need to override these
MAPIMETHOD(Initialize)(
IMsgStore *pMsgStore,
MRCACCESS *pmaDesired
);
MAPIMETHOD(ProcessMessage)(
IMsgStore *pMsgStore,
ULONG cbMsg,
LPENTRYID lpMsg,
ULONG cbDestFolder,
LPENTRYID lpDestFolder,
ULONG *pulEventType,
MRCHANDLED *pHandled
);
long m_cRef; //object reference count
public:
MRCACCESS m_mrcAccess; //Requested access
MRCHANDLED m_mrcHandled; //does the client handle the message
};
/******************************************************************************
CRuleClient_EMS - Rule client that intercepts EMS only.
******************************************************************************/
class CRuleClient_EMS : public CRuleClientBase
{
public:
//Required by CFactory
static HRESULT CreateInstance(IUnknown* pUnknownOuter,
IUnknown** ppNewComponent);
~CRuleClient_EMS();
private:
//IMailRuleClient Implementation
MAPIMETHOD(Initialize)(
IMsgStore *pMsgStore,
MRCACCESS *pmaDesired
);
MAPIMETHOD(ProcessMessage)(
IMsgStore *pMsgStore,
ULONG cbMsg,
LPENTRYID lpMsg,
ULONG cbDestFolder,
LPENTRYID lpDestFolder,
ULONG *pulEventType,
MRCHANDLED *pHandled
);
};
/******************************************************************************
CEMSBaseObject - All EMS objects are derived from this class. Each has an
offset into the user data (text) and some data associated with it. Every
object must also provide some way to validate its data and convert itself
to a text string that gets written to the body of the message. The custom
read form will parse this string to determine how to display the object.
******************************************************************************/
class CEMSBaseObject
{
protected:
CEMSBaseObject(LPBYTE lpData, ULONG cbData, ULONG ulBaseOffset, LPCTSTR szUserData);
~CEMSBaseObject();
//Must be overloaded by derived EMS objects
virtual BOOL ValidateData() _PURE;
virtual BOOL ExtractInfoFromHeader() _PURE;
virtual BOOL ToString(LPTSTR* ppszObjectData) _PURE;
ULONG m_ulOffset; //Offset into UserData (text)
ULONG m_cbData; //size of data buffer
LPBYTE m_lpData; //data buffer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -