static void test_rowposition(void) { IEnumConnectionPoints *enum_points; IConnectionPointContainer *cpc; IConnectionPoint *cp; IRowPosition *rowpos; HRESULT hr; IID iid; hr = CoCreateInstance(&CLSID_OLEDB_ROWPOSITIONLIBRARY, NULL, CLSCTX_INPROC_SERVER, &IID_IRowPosition, (void**)&rowpos); ok(hr == S_OK, "got %08x\n", hr); hr = IRowPosition_QueryInterface(rowpos, &IID_IConnectionPointContainer, (void**)&cpc); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IConnectionPointContainer_EnumConnectionPoints(cpc, &enum_points); todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); if (hr == S_OK) { hr = IEnumConnectionPoints_Next(enum_points, 1, &cp, NULL); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IConnectionPoint_GetConnectionInterface(cp, &iid); ok(hr == S_OK, "got 0x%08x\n", hr); ok(IsEqualIID(&iid, &IID_IRowPositionChange), "got %s\n", wine_dbgstr_guid(&iid)); IConnectionPoint_Release(cp); hr = IEnumConnectionPoints_Next(enum_points, 1, &cp, NULL); ok(hr == S_FALSE, "got 0x%08x\n", hr); IEnumConnectionPoints_Release(enum_points); } IConnectionPointContainer_Release(cpc); IRowPosition_Release(rowpos); }
static void advise_cp(IUnknown *unk, BOOL init) { IConnectionPointContainer *container; IConnectionPoint *point; HRESULT hres; static DWORD cookie = 100; hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container); ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres); if(FAILED(hres)) return; hres = IConnectionPointContainer_FindConnectionPoint(container, &DIID_DWebBrowserEvents2, &point); IConnectionPointContainer_Release(container); ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres); if(FAILED(hres)) return; if(init) { hres = IConnectionPoint_Advise(point, (IUnknown*)&Dispatch, &cookie); ok(hres == S_OK, "Advise failed: %08x\n", hres); }else { hres = IConnectionPoint_Unadvise(point, cookie); ok(hres == S_OK, "Unadvise failed: %08x\n", hres); } IConnectionPoint_Release(point); }
static void test_ConnectionPoint(IOleObject *unk) { IConnectionPointContainer *container; IConnectionPoint *point; HRESULT hres; static DWORD dw = 100; hres = IOleObject_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container); ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres); if(FAILED(hres)) return; hres = IConnectionPointContainer_FindConnectionPoint(container, &IID__WMPOCXEvents, &point); IConnectionPointContainer_Release(container); ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres); if(FAILED(hres)) return; hres = IConnectionPoint_Advise(point, (IUnknown*)&WMPOCXEvents, &dw); ok(hres == S_OK, "Advise failed: %08x\n", hres); ok(dw == 1, "dw=%d, expected 1\n", dw); hres = IConnectionPoint_Unadvise(point, dw); ok(hres == S_OK, "Unadvise failed: %08x\n", hres); IConnectionPoint_Release(point); }
static void test_IConnectionPointContainer(IOleObject *oleobj) { IConnectionPointContainer *container; IConnectionPoint *point; HRESULT hres; hres = IOleObject_QueryInterface(oleobj, &IID_IConnectionPointContainer, (void**)&container); ok(hres == S_OK, "Could not get IConnectionPointContainer iface: %08x\n", hres); hres = IConnectionPointContainer_FindConnectionPoint(container, &IID_IPropertyNotifySink, &point); ok(hres == CONNECT_E_NOCONNECTION, "got: %08x\n", hres); point = NULL; hres = IConnectionPointContainer_FindConnectionPoint(container, &IID_IWMPEvents, &point); todo_wine ok(hres == S_OK, "got: %08x\n", hres); if(point) IConnectionPoint_Release(point); point = NULL; hres = IConnectionPointContainer_FindConnectionPoint(container, &IID_IWMPEvents2, &point); todo_wine ok(hres == S_OK, "got: %08x\n", hres); if(point) IConnectionPoint_Release(point); point = NULL; hres = IConnectionPointContainer_FindConnectionPoint(container, &IID_IWMPEvents3, &point); if(FAILED(hres)) todo_wine win_skip("IWMPEvents3 not supported\n"); if(point) IConnectionPoint_Release(point); point = NULL; hres = IConnectionPointContainer_FindConnectionPoint(container, &IID_IWMPEvents4, &point); if(FAILED(hres)) todo_wine win_skip("IWMPEvents4 not supported\n"); if(point) IConnectionPoint_Release(point); point = NULL; hres = IConnectionPointContainer_FindConnectionPoint(container, &IID__WMPOCXEvents, &point); ok(hres == S_OK, "got: %08x\n", hres); if(point) IConnectionPoint_Release(point); IConnectionPointContainer_Release(container); }
/************************************************************************ * * The exported function to create the connection point. * NB not a windows API * * PARAMS * pUnk [in] IUnknown of object to which the ConnectionPoint is associated. * Needed to access IConnectionPointContainer. * * riid [in] IID of sink interface that this ConnectionPoint manages * * pCP [out] returns IConnectionPoint * */ HRESULT CreateConnectionPoint(IUnknown *pUnk, REFIID riid, IConnectionPoint **pCP) { ConnectionPointImpl *Obj; HRESULT hr; Obj = ConnectionPointImpl_Construct(pUnk, riid); if(!Obj) return E_OUTOFMEMORY; hr = IConnectionPoint_QueryInterface(&Obj->IConnectionPoint_iface, &IID_IConnectionPoint, (void**)pCP); IConnectionPoint_Release(&Obj->IConnectionPoint_iface); return hr; }
static ULONG WINAPI EnumConnections_Release(IEnumConnections *iface) { EnumConnections *This = impl_from_IEnumConnections(iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); if(!ref) { IConnectionPoint_Release(&This->cp->IConnectionPoint_iface); heap_free(This); } return ref; }
static void init_onchange_sink(IRowPosition *rowpos) { IConnectionPointContainer *cpc; IConnectionPoint *cp; DWORD cookie; HRESULT hr; hr = IRowPosition_QueryInterface(rowpos, &IID_IConnectionPointContainer, (void**)&cpc); ok(hr == S_OK, "got %08x\n", hr); hr = IConnectionPointContainer_FindConnectionPoint(cpc, &IID_IRowPositionChange, &cp); ok(hr == S_OK, "got %08x\n", hr); hr = IConnectionPoint_Advise(cp, (IUnknown*)&onchangesink, &cookie); ok(hr == S_OK, "got %08x\n", hr); IConnectionPoint_Release(cp); IConnectionPointContainer_Release(cpc); }
static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise) { IConnectionPointContainer *container; IConnectionPoint *cp; DWORD cookie; HRESULT hres; hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container); ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres); hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp); IConnectionPointContainer_Release(container); ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres); hres = IConnectionPoint_Advise(cp, unk_advise, &cookie); IConnectionPoint_Release(cp); ok(hres == S_OK, "Advise failed: %08x\n", hres); }
/*********************************************************************** * AtlUnadvise [atl100.@] */ HRESULT WINAPI AtlUnadvise(IUnknown *pUnkCP, const IID *iid, DWORD dw) { IConnectionPointContainer *container; IConnectionPoint *cp; HRESULT hres; TRACE("%p %p %d\n", pUnkCP, iid, dw); 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_Unadvise(cp, dw); IConnectionPoint_Release(cp); return hres; }
void php_com_object_enable_event_sink(php_com_dotnet_object *obj, int enable) { if (obj->sink_dispatch) { IConnectionPointContainer *cont; IConnectionPoint *point; if (SUCCEEDED(IDispatch_QueryInterface(V_DISPATCH(&obj->v), &IID_IConnectionPointContainer, (void**)&cont))) { if (SUCCEEDED(IConnectionPointContainer_FindConnectionPoint(cont, &obj->sink_id, &point))) { if (enable) { IConnectionPoint_Advise(point, (IUnknown*)obj->sink_dispatch, &obj->sink_cookie); } else { IConnectionPoint_Unadvise(point, obj->sink_cookie); } IConnectionPoint_Release(point); } IConnectionPointContainer_Release(cont); } } }
/*********************************************************************** * AtlAdvise [atl100.@] */ HRESULT WINAPI AtlAdvise(IUnknown *pUnkCP, IUnknown *pUnk, const IID *iid, DWORD *pdw) { IConnectionPointContainer *container; IConnectionPoint *cp; HRESULT hres; TRACE("%p %p %p %p\n", pUnkCP, pUnk, iid, pdw); if(!pUnkCP) return E_INVALIDARG; 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; }
static void advise_prop_notif(DocHost *This, BOOL set) { IConnectionPointContainer *cp_container; IConnectionPoint *cp; HRESULT hres; hres = IUnknown_QueryInterface(This->document, &IID_IConnectionPointContainer, (void**)&cp_container); if(FAILED(hres)) return; hres = IConnectionPointContainer_FindConnectionPoint(cp_container, &IID_IPropertyNotifySink, &cp); IConnectionPointContainer_Release(cp_container); if(FAILED(hres)) return; if(set) hres = IConnectionPoint_Advise(cp, (IUnknown*)&This->IPropertyNotifySink_iface, &This->prop_notif_cookie); else hres = IConnectionPoint_Unadvise(cp, This->prop_notif_cookie); IConnectionPoint_Release(cp); if(SUCCEEDED(hres)) This->is_prop_notif = set; }
static void test_Load(void) { static const WCHAR xmlview_xmlW[] = {'/','x','m','l','/','x','m','l','v','i','e','w','.','x','m','l',0}; static const WCHAR res[] = {'r','e','s',':','/','/',0}; WCHAR buf[1024]; IPersistMoniker *pers_mon; IConnectionPointContainer *cpc; IConnectionPoint *cp; IMoniker *mon; IBindCtx *bctx; IHTMLElement *elem; HRESULT hres; MSG msg; BSTR source; lstrcpyW(buf, res); GetModuleFileNameW(NULL, buf+lstrlenW(buf), (sizeof(buf)-sizeof(res))/sizeof(WCHAR)); lstrcatW(buf, xmlview_xmlW); if(!pCreateURLMoniker) { win_skip("CreateURLMoniker not available\n"); return; } hres = CoCreateInstance(&CLSID_XMLView, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, &IID_IPersistMoniker, (void**)&pers_mon); if(FAILED(hres)) { win_skip("Failed to create XMLView instance\n"); return; } ok(hres == S_OK, "CoCreateInstance returned %x, expected S_OK\n", hres); hres = IPersistMoniker_QueryInterface(pers_mon, &IID_IHTMLDocument2, (void**)&html_doc); ok(hres == S_OK, "QueryInterface(HTMLDocument2) returned %x, expected S_OK\n", hres); hres = IPersistMoniker_QueryInterface(pers_mon, &IID_IConnectionPointContainer, (void**)&cpc); ok(hres == S_OK, "QueryInterface(IConnectionPointContainer) returned %x, expected S_OK\n", hres); hres = IConnectionPointContainer_FindConnectionPoint(cpc, &IID_IDispatch, &cp); ok(hres == S_OK, "FindConnectionPoint returned %x, expected S_OK\n", hres); hres = IConnectionPoint_Advise(cp, (IUnknown*)&HTMLEvents, NULL); ok(hres == S_OK, "Advise returned %x, expected S_OK\n", hres); IConnectionPoint_Release(cp); IConnectionPointContainer_Release(cpc); hres = CreateBindCtx(0, &bctx); ok(hres == S_OK, "CreateBindCtx returned %x, expected S_OK\n", hres); hres = pCreateURLMoniker(NULL, buf, &mon); ok(hres == S_OK, "CreateUrlMoniker returned %x, expected S_OK\n", hres); loaded = FALSE; hres = IPersistMoniker_Load(pers_mon, TRUE, mon, bctx, 0); ok(hres == S_OK, "Load returned %x, expected S_OK\n", hres); IBindCtx_Release(bctx); IMoniker_Release(mon); while(!loaded && GetMessageA(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessageA(&msg); } hres = IHTMLDocument2_get_body(html_doc, &elem); ok(hres == S_OK, "get_body returned %x, expected S_OK\n", hres); hres = IHTMLElement_get_outerHTML(elem, &source); ok(hres == S_OK, "get_outerHTML returned %x, expected S_OK\n", hres); ok(!html_src_compare(source, xmlview_html), "Incorrect HTML source: %s\n", wine_dbgstr_w(source)); IHTMLElement_Release(elem); SysFreeString(source); IHTMLDocument2_Release(html_doc); html_doc = NULL; IPersistMoniker_Release(pers_mon); }
static void test_font_events_disp(void) { static const WCHAR nameW[] = {'N','a','m','e',0}; static const WCHAR sizeW[] = {'S','i','z','e',0}; static const WCHAR boldW[] = {'B','o','l','d',0}; static const WCHAR italicW[] = {'I','t','a','l','i','c',0}; static const WCHAR underlineW[] = {'U','n','d','e','r','l','i','n','e',0}; static const WCHAR strikeW[] = {'S','t','r','i','k','e','t','h','r','o','u','g','h',0}; static const WCHAR weightW[] = {'W','e','i','g','h','t',0}; static const WCHAR charsetW[] = {'C','h','a','r','s','e','t',0}; static const struct font_dispid font_dispids[] = { { DISPID_FONT_NAME, nameW }, { DISPID_FONT_SIZE, sizeW }, { DISPID_FONT_BOLD, boldW }, { DISPID_FONT_ITALIC, italicW }, { DISPID_FONT_UNDER, underlineW }, { DISPID_FONT_STRIKE, strikeW }, { DISPID_FONT_WEIGHT, weightW }, { DISPID_FONT_CHARSET, charsetW } }; IFont *pFont; IFont *pFont2; IConnectionPointContainer *pCPC; IConnectionPoint *pCP; FONTDESC fontdesc; HRESULT hr; DWORD dwCookie; IFontDisp *pFontDisp; DISPPARAMS dispparams; VARIANTARG vararg; INT i; fontdesc.cbSizeofstruct = sizeof(fontdesc); fontdesc.lpstrName = MSSansSerif_font; fontdesc.cySize.int64 = 12 * 10000; /* 12 pt */ fontdesc.sWeight = FW_NORMAL; fontdesc.sCharset = 0; fontdesc.fItalic = FALSE; fontdesc.fUnderline = FALSE; fontdesc.fStrikethrough = FALSE; hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void **)&pFont); EXPECT_HR(hr, S_OK); hr = IFont_QueryInterface(pFont, &IID_IConnectionPointContainer, (void **)&pCPC); EXPECT_HR(hr, S_OK); hr = IConnectionPointContainer_FindConnectionPoint(pCPC, &IID_IFontEventsDisp, &pCP); EXPECT_HR(hr, S_OK); IConnectionPointContainer_Release(pCPC); hr = IConnectionPoint_Advise(pCP, (IUnknown *)&FontEventsDisp, &dwCookie); EXPECT_HR(hr, S_OK); IConnectionPoint_Release(pCP); fonteventsdisp_invoke_called = 0; fonteventsdisp_invoke_arg0 = NULL; hr = IFont_put_Bold(pFont, TRUE); EXPECT_HR(hr, S_OK); ok(fonteventsdisp_invoke_called == 1, "IFontEventDisp::Invoke wasn't called once\n"); SysFreeString(fonteventsdisp_invoke_arg0); hr = IFont_QueryInterface(pFont, &IID_IFontDisp, (void **)&pFontDisp); EXPECT_HR(hr, S_OK); for (i = 0; i < sizeof(font_dispids)/sizeof(font_dispids[0]); i++) { switch (font_dispids[i].dispid) { case DISPID_FONT_NAME: { static const WCHAR arialW[] = {'A','r','i','a','l',0}; V_VT(&vararg) = VT_BSTR; V_BSTR(&vararg) = SysAllocString(arialW); break; } case DISPID_FONT_SIZE: V_VT(&vararg) = VT_CY; S(V_CY(&vararg)).Lo = 25; S(V_CY(&vararg)).Hi = 0; break; case DISPID_FONT_BOLD: V_VT(&vararg) = VT_BOOL; V_BOOL(&vararg) = VARIANT_FALSE; break; case DISPID_FONT_ITALIC: case DISPID_FONT_UNDER: case DISPID_FONT_STRIKE: V_VT(&vararg) = VT_BOOL; V_BOOL(&vararg) = VARIANT_TRUE; break; case DISPID_FONT_WEIGHT: V_VT(&vararg) = VT_I2; V_I2(&vararg) = FW_BLACK; break; case DISPID_FONT_CHARSET: V_VT(&vararg) = VT_I2; V_I2(&vararg) = 1; break; default: ; } dispparams.cNamedArgs = 0; dispparams.rgdispidNamedArgs = NULL; dispparams.cArgs = 1; dispparams.rgvarg = &vararg; fonteventsdisp_invoke_called = 0; hr = IFontDisp_Invoke(pFontDisp, font_dispids[i].dispid, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL); ok(hr == S_OK, "dispid=%d, got 0x%08x\n", font_dispids[i].dispid, hr); ok(fonteventsdisp_invoke_called == 1, "dispid=%d, DISPID_FONT_CHANGED not called, got %d\n", font_dispids[i].dispid, fonteventsdisp_invoke_called); if (hr == S_OK) { ok(!lstrcmpW(font_dispids[i].name, fonteventsdisp_invoke_arg0), "dispid=%d, got %s, expected %s\n", font_dispids[i].dispid, wine_dbgstr_w(fonteventsdisp_invoke_arg0), wine_dbgstr_w(font_dispids[i].name)); SysFreeString(fonteventsdisp_invoke_arg0); } VariantClear(&vararg); } IFontDisp_Release(pFontDisp); hr = IFont_Clone(pFont, &pFont2); EXPECT_HR(hr, S_OK); IFont_Release(pFont); /* this test shows that the notification routine isn't called again */ fonteventsdisp_invoke_called = 0; hr = IFont_put_Bold(pFont2, FALSE); EXPECT_HR(hr, S_OK); ok(fonteventsdisp_invoke_called == 0, "got %d\n", fonteventsdisp_invoke_called); IFont_Release(pFont2); }