Module: wine Branch: master Commit: c0efd074b2fc9bec2a520d8a80bdbd74c8d562dc URL: http://source.winehq.org/git/wine.git/?a=commit;h=c0efd074b2fc9bec2a520d8a80...
Author: Jacek Caban jacek@codeweavers.com Date: Wed May 4 19:40:47 2016 +0200
msctf: Moved thread manager's AdviseSink implementation into a more generic helper.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/msctf/msctf.c | 21 +++++++++++++++++++++ dlls/msctf/msctf_internal.h | 2 ++ dlls/msctf/threadmgr.c | 24 +++--------------------- 3 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/dlls/msctf/msctf.c b/dlls/msctf/msctf.c index 83eaab9..23845d4 100644 --- a/dlls/msctf/msctf.c +++ b/dlls/msctf/msctf.c @@ -32,6 +32,7 @@ #include "shlwapi.h" #include "shlguid.h" #include "comcat.h" +#include "olectl.h" #include "rpcproxy.h" #include "msctf.h" #include "inputscope.h" @@ -283,6 +284,26 @@ DWORD enumerate_Cookie(DWORD magic, DWORD *index) return 0x0; }
+HRESULT advise_sink(struct list *sink_list, REFIID riid, DWORD cookie_magic, IUnknown *unk, DWORD *cookie) +{ + Sink *sink; + + sink = HeapAlloc(GetProcessHeap(), 0, sizeof(*sink)); + if (!sink) + return E_OUTOFMEMORY; + + if (FAILED(IUnknown_QueryInterface(unk, riid, (void**)&sink->interfaces.pIUnknown))) + { + HeapFree(GetProcessHeap(), 0, sink); + return CONNECT_E_CANNOTCONNECT; + } + + list_add_head(sink_list, &sink->entry); + *cookie = generate_Cookie(cookie_magic, sink); + TRACE("cookie %x\n", *cookie); + return S_OK; +} + /***************************************************************************** * Active Text Service Management *****************************************************************************/ diff --git a/dlls/msctf/msctf_internal.h b/dlls/msctf/msctf_internal.h index 8923c60..1f7e7df 100644 --- a/dlls/msctf/msctf_internal.h +++ b/dlls/msctf/msctf_internal.h @@ -75,6 +75,8 @@ typedef struct { } interfaces; } Sink;
+HRESULT advise_sink(struct list *sink_list, REFIID riid, DWORD cookie_magic, IUnknown *unk, DWORD *cookie) DECLSPEC_HIDDEN; + extern const WCHAR szwSystemTIPKey[] DECLSPEC_HIDDEN; extern const WCHAR szwSystemCTFKey[] DECLSPEC_HIDDEN;
diff --git a/dlls/msctf/threadmgr.c b/dlls/msctf/threadmgr.c index 44e8c87..c6a227c 100644 --- a/dlls/msctf/threadmgr.c +++ b/dlls/msctf/threadmgr.c @@ -643,7 +643,6 @@ static HRESULT WINAPI ThreadMgrSource_AdviseSink(ITfSource *iface, REFIID riid, IUnknown *punk, DWORD *pdwCookie) { ThreadMgr *This = impl_from_ITfSource(iface); - Sink *tms;
TRACE("(%p) %s %p %p\n",This,debugstr_guid(riid),punk,pdwCookie);
@@ -651,27 +650,10 @@ static HRESULT WINAPI ThreadMgrSource_AdviseSink(ITfSource *iface, return E_INVALIDARG;
if (IsEqualIID(riid, &IID_ITfThreadMgrEventSink)) - { - tms = HeapAlloc(GetProcessHeap(),0,sizeof(*tms)); - if (!tms) - return E_OUTOFMEMORY; - if (FAILED(IUnknown_QueryInterface(punk, riid, (LPVOID *)&tms->interfaces.pITfThreadMgrEventSink))) - { - HeapFree(GetProcessHeap(),0,tms); - return CONNECT_E_CANNOTCONNECT; - } - list_add_head(&This->ThreadMgrEventSink,&tms->entry); - *pdwCookie = generate_Cookie(COOKIE_MAGIC_TMSINK, tms); - } - else - { - FIXME("(%p) Unhandled Sink: %s\n",This,debugstr_guid(riid)); - return E_NOTIMPL; - } - - TRACE("cookie %x\n",*pdwCookie); + return advise_sink(&This->ThreadMgrEventSink, &IID_ITfThreadMgrEventSink, COOKIE_MAGIC_TMSINK, punk, pdwCookie);
- return S_OK; + FIXME("(%p) Unhandled Sink: %s\n",This,debugstr_guid(riid)); + return E_NOTIMPL; }
static HRESULT WINAPI ThreadMgrSource_UnadviseSink(ITfSource *iface, DWORD pdwCookie)