#include "Sdk.h"
#include "ComUtils.h"
#include "Addin.h"
#include "InspectorsEvents.h"
#include "OutlookUtils.h"
#include "DllMgr.h"
#include "MemMgr.h"
// Outlook interface IDs
static const
IID DIID_InspectorsEvents = {
0x00063079,
0x0000, 0x0000,
{ 0xC0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x46,
}
};
const IID*
InspectorsEvents_GetIID(
VOID
) {
return &DIID_InspectorsEvents;
}
static
HRESULT
__stdcall
FInspectorsEvents_QueryInterface(
DInspectorsEvents *This,
const IID *riid,
void **ppv
) {
// check input object
_ASSERTE(This != NULL);
if(This == NULL) {
return E_UNEXPECTED;
}
// check output pointer validity
_ASSERTE(ppv != NULL);
if(ppv == NULL) {
return E_INVALIDARG;
}
*ppv = NULL;
if(IID_IsEqual(riid, &IID_IUnknown)) {
*ppv = (void *)((IUnknown *)This);
}
else if(IID_IsEqual(riid, &IID_IDispatch)) {
*ppv = (void *)((IDispatch *)This);
}
else if(IID_IsEqual(riid, InspectorsEvents_GetIID())) {
*ppv = (void *)((DInspectorsEvents *)This);
}
if(*ppv != NULL) {
IUnknown_AddRef((IUnknown *)(*ppv));
return S_OK;
}
return E_NOINTERFACE;
}
static
ULONG
__stdcall
FInspectorsEvents_AddRef(
DInspectorsEvents *This
) {
XInspectorsEvents* pInspectorsEvents = NULL;
_ASSERTE(This != NULL);
if(This == NULL) {
return 1;
}
DllMgr_AddObjRef(DllMgr_GetObject());
pInspectorsEvents = IFace_GetStruct(XInspectorsEvents,
iInspectorsEvents,
This
);
return ++pInspectorsEvents->Ref;
}
static
ULONG
__stdcall
FInspectorsEvents_Release(
DInspectorsEvents *This
) {
XInspectorsEvents* pInspectorsEvents = NULL;
_ASSERTE(This != NULL);
if(This == NULL) {
return 1;
}
DllMgr_ReleaseObjRef(DllMgr_GetObject());
pInspectorsEvents = IFace_GetStruct(XInspectorsEvents,
iInspectorsEvents,
This
);
if(--pInspectorsEvents->Ref == 0) {
Allocator_FreeRef(&This);
return 0;
}
return pInspectorsEvents->Ref;
}
static
HRESULT
__stdcall
FInspectorsEvents_GetTypeInfoCount(
DInspectorsEvents *This,
UINT *pctinfo
) {
if(pctinfo != NULL) {
*pctinfo = 0;
}
return S_OK;
UNREFERENCED_PARAMETER(This);
}
static
HRESULT
__stdcall
FInspectorsEvents_GetTypeInfo(
DInspectorsEvents *This,
UINT iTInfo,
LCID lcid,
ITypeInfo **ppTInfo
) {
if(iTInfo != 0) {
return DISP_E_BADINDEX;
}
if(ppTInfo != NULL) {
*ppTInfo = NULL;
}
return TYPE_E_ELEMENTNOTFOUND;
UNREFERENCED_PARAMETER(lcid);
UNREFERENCED_PARAMETER(This);
}
static
HRESULT
__stdcall
FInspectorsEvents_GetIDsOfNames(
DInspectorsEvents *This,
REFIID riid,
LPOLESTR *rgszNames,
UINT cNames,
LCID lcid,
DISPID *rgDispId
) {
if(rgDispId != NULL) {
UINT c;
for(c = 0; c < cNames; c++) {
rgDispId[c] = DISPID_UNKNOWN;
}
}
return DISP_E_UNKNOWNNAME;
UNREFERENCED_PARAMETER(riid);
UNREFERENCED_PARAMETER(rgszNames);
UNREFERENCED_PARAMETER(lcid);
UNREFERENCED_PARAMETER(This);
}
static
HRESULT
__stdcall
FInspectorsEvents_Invoke(
DInspectorsEvents *This,
DISPID dispIdMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS *pDispParams,
VARIANT *pVarResult,
EXCEPINFO *pExcepInfo,
UINT *puArgErr
) {
XInspectorsEvents* pInspectorsEvents = NULL;
if(This == NULL) {
return E_NOTIMPL;
}
pInspectorsEvents = IFace_GetStruct(XInspectorsEvents,
iInspectorsEvents,
This
);
if(dispIdMember == DISPID_INSPECTORSEVENTS_NEWINSPECTOR) {
if(pDispParams != NULL) {
if(pDispParams->cArgs == 1) {
if(V_VT(&pDispParams->rgvarg[0]) == VT_DISPATCH) {
pInspectorsEvents->OnNewInspector(pInspectorsEvents,
V_DISPATCH(&pDispParams->rgvarg[0])
);
}
}
}
}
return E_NOTIMPL;
UNREFERENCED_PARAMETER(puArgErr);
UNREFERENCED_PARAMETER(pExcepInfo);
UNREFERENCED_PARAMETER(pVarResult);
UNREFERENCED_PARAMETER(pDispParams);
UNREFERENCED_PARAMETER(wFlags);
UNREFERENCED_PARAMETER(lcid);
UNREFERENCED_PARAMETER(riid);
}
static
struct _DInspectorsEventsVtbl
___DInspectorsEventsVtbl = {
&FInspectorsEvents_QueryInterface,
&FInspectorsEvents_AddRef,
&FInspectorsEvents_Release,
&FInspectorsEvents_GetTypeInfoCount,
&FInspectorsEvents_GetTypeInfo,
&FInspectorsEvents_GetIDsOfNames,
&FInspectorsEvents_Invoke,
};
// direct calls thru XInspectorsEvents object
static
HRESULT
__stdcall
FXInspectorsEvents_QueryInterface(
XInspectorsEvents *pInspectorsEvents,
REFIID riid,
void **ppv
) {
// check input object
_ASSERTE(pInspectorsEvents != NULL);
if(pInspectorsEvents == NULL) {
return E_UNEXPECTED;
}
return InspectorsEvents_QueryInterface(&pInspectorsEvents->iInspectorsEvents,
riid,
ppv
);
}
static
ULONG
__stdcall
FXInspectorsEvents_AddRef(
XInspectorsEvents *pInspectorsEvents
) {
// check input object
_ASSERTE(pInspectorsEvents != NULL);
if(pInspectorsEvents == NULL) {
return 1;
}
DllMgr_AddObjRef(DllMgr_GetObject());
return InspectorsEvents_AddRef(&pInspectorsEvents->iInspectorsEvents);
}
static
ULONG
__stdcall
FXInspectorsEvents_Release(
XInspectorsEvents *pInspectorsEvents
) {
// check input object
_ASSERTE(pInspectorsEvents != NULL);
if(pInspectorsEvents == NULL) {
return 1;
}
DllMgr_ReleaseObjRef(DllMgr_GetObject());
return InspectorsEvents_Release(&pInspectorsEvents->iInspectorsEvents);
}
static
VOID
__stdcall
FXInspectorsEvents_OnNewInspector(
XInspectorsEvents *pInspectorsEvents,
IDispatch *pNewInspector
) {
// check input object
_ASSERTE(pInspectorsEvents != NULL);
if(pInspectorsEvents == NULL) {
return;
}
pInspectorsEvents->pAddin->OnNewInspector(pInspectorsEvents->pAddin,
pNewInspector
);
return;
}
HRESULT
NDAPI
XInspectorsEvents_Create(
XAddin *pAddin,
XInspectorsEvents **ppInspectorsEvents
) {
XInspectorsEvents *pInspectorsEvents = NULL;
_ASSERTE(ppInspectorsEvents != NULL);
if(ppInspectorsEvents == NULL) {
return E_POINTER;
}
*ppInspectorsEvents = NULL;
Allocator_AllocRef(sizeof(XInspectorsEvents),
&pInspectorsEvents
);
if(pInspectorsEvents == NULL) {
return E_OUTOFMEMORY;
}
// set vtable
pInspectorsEvents->iInspectorsEvents.lpVtbl = &___DInspectorsEventsVtbl;
pInspectorsEvents->QueryInterface = &FXInspectorsEvents_QueryInterface;
pInspectorsEvents->AddRef = &FXInspectorsEvents_AddRef;
pInspectorsEvents->Release = &FXInspectorsEvents_Release;
pInspectorsEvents->OnNewInspector = &FXInspectorsEvents_OnNewInspector;
// initialize data members
pInspectorsEvents->Ref = 0;
InspectorsEvents_AddRef(&pInspectorsEvents->iInspectorsEvents);
pInspectorsEvents->CookieID = INVALID_ADVISE_COOKIE_ID;
pInspectorsEvents->pAddin = pAddin;
*ppInspectorsEvents = pInspectorsEvents;
return S_OK;
}