From 7aa9bd9823f0e56e9ae209b417b71e2f277f451e Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Mon, 22 Jun 2009 12:04:41 +0900 Subject: [PATCH] msctf: Implement ITfCompartmentEventSink. --- dlls/msctf/compartmentmgr.c | 34 +++++++++++++++++++++++++++++++--- include/msctf.idl | 11 +++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/dlls/msctf/compartmentmgr.c b/dlls/msctf/compartmentmgr.c index 7e116906eb7..3afcfda7cc0 100644 --- a/dlls/msctf/compartmentmgr.c +++ b/dlls/msctf/compartmentmgr.c @@ -72,7 +72,7 @@ typedef struct tagCompartmentSink { struct list entry; union { IUnknown *pIUnknown; - /* ITfCompartmentEventSink *pITfCompartmentEventSink; */ + ITfCompartmentEventSink *pITfCompartmentEventSink; } interfaces; } CompartmentSink; @@ -493,6 +493,7 @@ static HRESULT WINAPI Compartment_SetValue(ITfCompartment *iface, TfClientId tid, const VARIANT *pvarValue) { Compartment *This = (Compartment *)iface; + struct list *cursor; TRACE("(%p) %i %p\n",This,tid,pvarValue); @@ -517,6 +518,12 @@ static HRESULT WINAPI Compartment_SetValue(ITfCompartment *iface, else if (V_VT(pvarValue) == VT_UNKNOWN) IUnknown_AddRef(V_UNKNOWN(&This->variant)); + LIST_FOR_EACH(cursor, &This->CompartmentEventSink) + { + CompartmentSink* sink = LIST_ENTRY(cursor,CompartmentSink,entry); + ITfCompartmentEventSink_OnChange(sink->interfaces.pITfCompartmentEventSink,&This->valueData->guid); + } + return S_OK; } @@ -570,6 +577,7 @@ static ULONG WINAPI Source_Release(ITfSource *iface) static WINAPI HRESULT CompartmentSource_AdviseSink(ITfSource *iface, REFIID riid, IUnknown *punk, DWORD *pdwCookie) { + CompartmentSink *cs; Compartment *This = impl_from_ITfSourceVtbl(iface); TRACE("(%p) %s %p %p\n",This,debugstr_guid(riid),punk,pdwCookie); @@ -577,8 +585,28 @@ static WINAPI HRESULT CompartmentSource_AdviseSink(ITfSource *iface, if (!riid || !punk || !pdwCookie) return E_INVALIDARG; - FIXME("(%p) Unhandled Sink: %s\n",This,debugstr_guid(riid)); - return E_NOTIMPL; + if (IsEqualIID(riid, &IID_ITfCompartmentEventSink)) + { + cs = HeapAlloc(GetProcessHeap(),0,sizeof(CompartmentSink)); + if (!cs) + return E_OUTOFMEMORY; + if (FAILED(IUnknown_QueryInterface(punk, riid, (LPVOID *)&cs->interfaces.pITfCompartmentEventSink))) + { + HeapFree(GetProcessHeap(),0,cs); + return CONNECT_E_CANNOTCONNECT; + } + list_add_head(&This->CompartmentEventSink,&cs->entry); + *pdwCookie = generate_Cookie(COOKIE_MAGIC_COMPARTMENTSINK , cs); + } + else + { + FIXME("(%p) Unhandled Sink: %s\n",This,debugstr_guid(riid)); + return E_NOTIMPL; + } + + TRACE("cookie %x\n",*pdwCookie); + + return S_OK; } static WINAPI HRESULT CompartmentSource_UnadviseSink(ITfSource *iface, DWORD pdwCookie) diff --git a/include/msctf.idl b/include/msctf.idl index 4db67f4db69..10580573e92 100644 --- a/include/msctf.idl +++ b/include/msctf.idl @@ -938,3 +938,14 @@ interface ITfCompartmentMgr : IUnknown HRESULT EnumCompartments( [out] IEnumGUID **ppEnum); }; + +[ + object, + uuid(743abd5f-f26d-48df-8cc5-238492419b64), + pointer_default(unique) +] +interface ITfCompartmentEventSink : IUnknown +{ + HRESULT OnChange( + [in] REFGUID rguid); +}