// This is a part of the SocketPro package.
// Copyright (C) 2000-2002 UDAParts
// All rights reserved.
//
// This source code is only intended as a supplement to the
// SocketPro Classes Reference and related
// electronic documentation provided with the package.
// See these sources for detailed information regarding this
// UDAParts product.
// Please don't disclose any source code of the software to any person or entity,
//
// Please don't decompile, disassemble, or reverse engineer any object code of
// any portion of the software.
//
// Copyright (c) 2002 by Yuancai (Charlie) Ye
// yekerui@yahoo.com
#ifndef __SOCKETPRO_UTIL_TEMP_H__
#define __SOCKETPRO_UTIL_TEMP_H__
#define IDC_SRCSOCKCLIENTEVENT 1
static _ATL_FUNC_INFO OnSockEventFuncInfo = {CC_STDCALL, VT_I4, 2, {VT_I4, VT_I4}};
static _ATL_FUNC_INFO OnSockEventWinMsgInfo = {CC_STDCALL, VT_I4, 3, {VT_I4, VT_I4, VT_I4}};
static _ATL_FUNC_INFO OnSockGetHostByAddr = {CC_STDCALL, VT_I4, 4, {VT_I4, VT_BSTR, VT_BSTR, VT_I4}};
static _ATL_FUNC_INFO OnSockGetHostByName = {CC_STDCALL, VT_I4, 5, {VT_I4, VT_BSTR, VT_BSTR, VT_BSTR, VT_I4}};
template <class T>
class SocketIConnectionPointContainerImpl : public IConnectionPointContainerImpl<T>
{
public:
public:
STDMETHOD(EnumConnectionPoints)(IEnumConnectionPoints** ppEnum)
{
HRESULT hr=IConnectionPointContainerImpl<T>::EnumConnectionPoints(ppEnum);
if(FAILED(hr))
{
CComPtr<IConnectionPointContainer> pIConnectionPointContainer;
hr=m_pIUnknownForPointContainer->QueryInterface(__uuidof(IConnectionPointContainer), (void**)&pIConnectionPointContainer);
if(FAILED(hr))
return hr;
return pIConnectionPointContainer->EnumConnectionPoints(ppEnum);
}
return hr;
}
STDMETHOD(FindConnectionPoint)(REFIID riid, IConnectionPoint** ppCP)
{
HRESULT hr=IConnectionPointContainerImpl<T>::FindConnectionPoint(riid, ppCP);
if(FAILED(hr))
{
CComPtr<IConnectionPointContainer> pIConnectionPointContainer;
hr=m_pIUnknownForPointContainer->QueryInterface(__uuidof(IConnectionPointContainer), (void**)&pIConnectionPointContainer);
if(FAILED(hr))
return hr;
return pIConnectionPointContainer->FindConnectionPoint(riid, ppCP);
}
return hr;
}
protected:
IUnknown *m_pIUnknownForPointContainer;
};
template <class T, const IID* piid, const GUID* plibid>
class SocketIDispatchImpl : public IDispatchImpl<T, piid, plibid>
{
public:
SocketIDispatchImpl()
{
m_pIUnknownClientSocket=NULL;
}
STDMETHOD(GetTypeInfo)(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
{
HRESULT hr=IDispatchImpl<T, piid, plibid>::GetTypeInfo(itinfo, lcid, pptinfo);
if(FAILED(hr))
{
CComPtr<IDispatch> pIDispatch;
hr=m_pIUnknownClientSocket->QueryInterface(__uuidof(IDispatch), (void**)&pIDispatch);
if(FAILED(hr))
return hr;
return pIDispatch->GetTypeInfo(itinfo, lcid, pptinfo);
}
return hr;
}
STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR* rgszNames, UINT cNames,
LCID lcid, DISPID* rgdispid)
{
HRESULT hr=IDispatchImpl<T, piid, plibid>::GetIDsOfNames(riid, rgszNames, cNames, lcid, rgdispid);
if(FAILED(hr))
{
CComPtr<IDispatch> pIDispatch;
hr=m_pIUnknownClientSocket->QueryInterface(__uuidof(IDispatch), (void**)&pIDispatch);
if(FAILED(hr))
return hr;
return pIDispatch->GetIDsOfNames(riid, rgszNames, cNames, lcid, rgdispid);
}
return hr;
}
STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid,
LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
EXCEPINFO* pexcepinfo, UINT* puArgErr)
{
HRESULT hr=IDispatchImpl<T, piid, plibid>::Invoke(dispidMember, riid, lcid, wFlags, pdispparams, pvarResult, pexcepinfo, puArgErr);
if(FAILED(hr))
{
CComPtr<IDispatch> pIDispatch;
hr=m_pIUnknownClientSocket->QueryInterface(__uuidof(IDispatch), (void**)&pIDispatch);
if(FAILED(hr))
return hr;
return pIDispatch->Invoke(dispidMember, riid, lcid, wFlags, pdispparams, pvarResult, pexcepinfo, puArgErr);
}
return hr;
}
protected:
IUnknown *m_pIUnknownClientSocket;
};
#endif
// This is a part of the SocketPro package.
// Copyright (C) 2000-2002 UDAParts
// All rights reserved.
//
// This source code is only intended as a supplement to the
// SocketPro Classes Reference and related
// electronic documentation provided with the package.
// See these sources for detailed information regarding this
// UDAParts product.
// Please don't disclose any source code of the software to any person or entity,
//
// Please don't decompile, disassemble, or reverse engineer any object code of
// any portion of the software.
//
// Copyright (c) 2002 by Yuancai (Charlie) Ye
// yekerui@yahoo.com