Commit e57b22b9 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

atl100: Added AtlAdvise implementation.

parent ded41970
...@@ -41,10 +41,26 @@ static ICatRegister *catreg; ...@@ -41,10 +41,26 @@ static ICatRegister *catreg;
/*********************************************************************** /***********************************************************************
* AtlAdvise [atl100.@] * AtlAdvise [atl100.@]
*/ */
HRESULT WINAPI AtlAdvise(IUnknown *pUnkCP, IUnknown *pUnk, const IID *iid, LPDWORD pdw) HRESULT WINAPI AtlAdvise(IUnknown *pUnkCP, IUnknown *pUnk, const IID *iid, DWORD *pdw)
{ {
FIXME("%p %p %p %p\n", pUnkCP, pUnk, iid, pdw); IConnectionPointContainer *container;
return E_FAIL; IConnectionPoint *cp;
HRESULT hres;
TRACE("%p %p %p %p\n", pUnkCP, pUnk, iid, pdw);
hres = IUnknown_QueryInterface(pUnkCP, &IID_IConnectionPointContainer, (void**)&container);
if(FAILED(hres))
return hres;
hres = IConnectionPointContainer_FindConnectionPoint(container, iid, &cp);
IConnectionPointContainer_Release(container);
if(FAILED(hres))
return hres;
hres = IConnectionPoint_Advise(cp, pUnk, pdw);
IConnectionPoint_Release(cp);
return hres;
} }
/*********************************************************************** /***********************************************************************
......
TESTDLL = atl100.dll TESTDLL = atl100.dll
IMPORTS = atl100 oleaut32 ole32 advapi32 IMPORTS = uuid atl100 oleaut32 ole32 advapi32
EXTRADEFS = -D_ATL_VER=_ATL_VER_100 EXTRADEFS = -D_ATL_VER=_ATL_VER_100
C_SRCS = \ C_SRCS = \
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <stdio.h> #include <stdio.h>
#define COBJMACROS #define COBJMACROS
#define CONST_VTABLE
#include <atlbase.h> #include <atlbase.h>
...@@ -207,6 +208,132 @@ static void test_typelib(void) ...@@ -207,6 +208,132 @@ static void test_typelib(void)
ITypeLib_Release(typelib); ITypeLib_Release(typelib);
} }
static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface, REFIID riid, void **ppv)
{
if(IsEqualGUID(&IID_IConnectionPoint, riid)) {
*ppv = iface;
return S_OK;
}
ok(0, "unexpected call\n");
return E_NOINTERFACE;
}
static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface)
{
return 2;
}
static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface)
{
return 1;
}
static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *pIID)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoint *iface,
IConnectionPointContainer **ppCPC)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *pUnkSink,
DWORD *pdwCookie)
{
ok(pUnkSink == (IUnknown*)0xdead0000, "pUnkSink = %p\n", pUnkSink);
*pdwCookie = 0xdeadbeef;
return S_OK;
}
static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD dwCookie)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface,
IEnumConnections **ppEnum)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static const IConnectionPointVtbl ConnectionPointVtbl =
{
ConnectionPoint_QueryInterface,
ConnectionPoint_AddRef,
ConnectionPoint_Release,
ConnectionPoint_GetConnectionInterface,
ConnectionPoint_GetConnectionPointContainer,
ConnectionPoint_Advise,
ConnectionPoint_Unadvise,
ConnectionPoint_EnumConnections
};
static IConnectionPoint ConnectionPoint = { &ConnectionPointVtbl };
static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface,
REFIID riid, void **ppv)
{
if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
*ppv = iface;
return S_OK;
}
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
{
return 2;
}
static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
{
return 1;
}
static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface,
IEnumConnectionPoints **ppEnum)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface,
REFIID riid, IConnectionPoint **ppCP)
{
ok(IsEqualGUID(riid, &CLSID_Test), "unexpected riid\n");
*ppCP = &ConnectionPoint;
return S_OK;
}
static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl = {
ConnectionPointContainer_QueryInterface,
ConnectionPointContainer_AddRef,
ConnectionPointContainer_Release,
ConnectionPointContainer_EnumConnectionPoints,
ConnectionPointContainer_FindConnectionPoint
};
static IConnectionPointContainer ConnectionPointContainer = { &ConnectionPointContainerVtbl };
static void test_cp(void)
{
DWORD cookie = 0;
HRESULT hres;
hres = AtlAdvise((IUnknown*)&ConnectionPointContainer, (IUnknown*)0xdead0000, &CLSID_Test, &cookie);
ok(hres == S_OK, "AtlAdvise failed: %08x\n", hres);
ok(cookie == 0xdeadbeef, "cookie = %x\n", cookie);
}
START_TEST(atl) START_TEST(atl)
{ {
CoInitialize(NULL); CoInitialize(NULL);
...@@ -214,6 +341,7 @@ START_TEST(atl) ...@@ -214,6 +341,7 @@ START_TEST(atl)
test_winmodule(); test_winmodule();
test_regcat(); test_regcat();
test_typelib(); test_typelib();
test_cp();
CoUninitialize(); CoUninitialize();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment