* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
+
+#include <stdarg.h>
+
+#define COBJMACROS
+
+#include "wine/debug.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winreg.h"
+#include "winuser.h"
+#include "shlwapi.h"
+#include "winerror.h"
+#include "objbase.h"
+#include "oleauto.h"
+#include "olectl.h"
+
+#include "wine/unicode.h"
+
+#include "msctf.h"
#include "msctf_internal.h"
-#include <oleauto.h>
+WINE_DEFAULT_DEBUG_CHANNEL(msctf);
typedef struct tagCompartmentValue {
struct list entry;
struct list *cursor;
} CompartmentEnumGuid;
-
-typedef struct tagCompartmentSink {
- struct list entry;
- union {
- IUnknown *pIUnknown;
- ITfCompartmentEventSink *pITfCompartmentEventSink;
- } interfaces;
-} CompartmentSink;
-
typedef struct tagCompartment {
ITfCompartment ITfCompartment_iface;
ITfSource ITfSource_iface;
/**************************************************
* ITfCompartment
**************************************************/
-static void free_sink(CompartmentSink *sink)
-{
- IUnknown_Release(sink->interfaces.pIUnknown);
- HeapFree(GetProcessHeap(),0,sink);
-}
-
static void Compartment_Destructor(Compartment *This)
{
- struct list *cursor, *cursor2;
TRACE("destroying %p\n", This);
VariantClear(&This->variant);
- LIST_FOR_EACH_SAFE(cursor, cursor2, &This->CompartmentEventSink)
- {
- CompartmentSink* sink = LIST_ENTRY(cursor,CompartmentSink,entry);
- list_remove(cursor);
- free_sink(sink);
- }
+ free_sinks(&This->CompartmentEventSink);
HeapFree(GetProcessHeap(),0,This);
}
TfClientId tid, const VARIANT *pvarValue)
{
Compartment *This = impl_from_ITfCompartment(iface);
+ ITfCompartmentEventSink *sink;
struct list *cursor;
TRACE("(%p) %i %p\n",This,tid,pvarValue);
else if (V_VT(pvarValue) == VT_UNKNOWN)
IUnknown_AddRef(V_UNKNOWN(&This->variant));
- LIST_FOR_EACH(cursor, &This->CompartmentEventSink)
+ SINK_FOR_EACH(cursor, &This->CompartmentEventSink, ITfCompartmentEventSink, sink)
{
- CompartmentSink* sink = LIST_ENTRY(cursor,CompartmentSink,entry);
- ITfCompartmentEventSink_OnChange(sink->interfaces.pITfCompartmentEventSink,&This->valueData->guid);
+ ITfCompartmentEventSink_OnChange(sink, &This->valueData->guid);
}
return S_OK;
REFIID riid, IUnknown *punk, DWORD *pdwCookie)
{
Compartment *This = impl_from_ITfSource(iface);
- CompartmentSink *cs;
TRACE("(%p) %s %p %p\n",This,debugstr_guid(riid),punk,pdwCookie);
return E_INVALIDARG;
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 advise_sink(&This->CompartmentEventSink, &IID_ITfCompartmentEventSink,
+ COOKIE_MAGIC_COMPARTMENTSINK, punk, pdwCookie);
- return S_OK;
+ FIXME("(%p) Unhandled Sink: %s\n",This,debugstr_guid(riid));
+ return E_NOTIMPL;
}
static HRESULT WINAPI CompartmentSource_UnadviseSink(ITfSource *iface, DWORD pdwCookie)
{
Compartment *This = impl_from_ITfSource(iface);
- CompartmentSink *sink;
TRACE("(%p) %x\n",This,pdwCookie);
if (get_Cookie_magic(pdwCookie)!=COOKIE_MAGIC_COMPARTMENTSINK)
return E_INVALIDARG;
- sink = remove_Cookie(pdwCookie);
- if (!sink)
- return CONNECT_E_NOCONNECTION;
-
- list_remove(&sink->entry);
- free_sink(sink);
-
- return S_OK;
+ return unadvise_sink(pdwCookie);
}
static const ITfSourceVtbl CompartmentSourceVtbl =