2 * ITfThreadMgr implementation
4 * Copyright 2008 Aric Stewart, CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/debug.h"
36 #include "wine/unicode.h"
39 #include "msctf_internal.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(msctf);
43 typedef struct tagACLMulti {
44 const ITfThreadMgrVtbl *ThreadMgrVtbl;
47 ITfDocumentMgr *focus;
50 static void ThreadMgr_Destructor(ThreadMgr *This)
52 TlsSetValue(tlsIndex,NULL);
53 TRACE("destroying %p\n", This);
55 ITfDocumentMgr_Release(This->focus);
56 HeapFree(GetProcessHeap(),0,This);
59 static HRESULT WINAPI ThreadMgr_QueryInterface(ITfThreadMgr *iface, REFIID iid, LPVOID *ppvOut)
61 ThreadMgr *This = (ThreadMgr *)iface;
64 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfThreadMgr))
71 IUnknown_AddRef(iface);
75 WARN("unsupported interface: %s\n", debugstr_guid(iid));
79 static ULONG WINAPI ThreadMgr_AddRef(ITfThreadMgr *iface)
81 ThreadMgr *This = (ThreadMgr *)iface;
82 return InterlockedIncrement(&This->refCount);
85 static ULONG WINAPI ThreadMgr_Release(ITfThreadMgr *iface)
87 ThreadMgr *This = (ThreadMgr *)iface;
90 ret = InterlockedDecrement(&This->refCount);
92 ThreadMgr_Destructor(This);
96 /*****************************************************
97 * ITfThreadMgr functions
98 *****************************************************/
100 static HRESULT WINAPI ThreadMgr_fnActivate( ITfThreadMgr* iface, TfClientId *ptid)
102 ThreadMgr *This = (ThreadMgr *)iface;
103 FIXME("STUB:(%p)\n",This);
107 static HRESULT WINAPI ThreadMgr_fnDeactivate( ITfThreadMgr* iface)
109 ThreadMgr *This = (ThreadMgr *)iface;
110 FIXME("STUB:(%p)\n",This);
114 static HRESULT WINAPI ThreadMgr_CreateDocumentMgr( ITfThreadMgr* iface, ITfDocumentMgr
117 TRACE("(%p)\n",iface);
118 return DocumentMgr_Constructor(ppdim);
121 static HRESULT WINAPI ThreadMgr_EnumDocumentMgrs( ITfThreadMgr* iface, IEnumTfDocumentMgrs
124 ThreadMgr *This = (ThreadMgr *)iface;
125 FIXME("STUB:(%p)\n",This);
129 static HRESULT WINAPI ThreadMgr_GetFocus( ITfThreadMgr* iface, ITfDocumentMgr
132 ThreadMgr *This = (ThreadMgr *)iface;
133 TRACE("(%p)\n",This);
138 *ppdimFocus = This->focus;
140 TRACE("->%p\n",This->focus);
142 if (This->focus == NULL)
145 ITfDocumentMgr_AddRef(This->focus);
150 static HRESULT WINAPI ThreadMgr_SetFocus( ITfThreadMgr* iface, ITfDocumentMgr *pdimFocus)
152 ITfDocumentMgr *check;
153 ThreadMgr *This = (ThreadMgr *)iface;
155 TRACE("(%p) %p\n",This,pdimFocus);
157 if (!pdimFocus || FAILED(IUnknown_QueryInterface(pdimFocus,&IID_ITfDocumentMgr,(LPVOID*) &check)))
161 ITfDocumentMgr_Release(This->focus);
167 static HRESULT WINAPI ThreadMgr_AssociateFocus( ITfThreadMgr* iface, HWND hwnd,
168 ITfDocumentMgr *pdimNew, ITfDocumentMgr **ppdimPrev)
170 ThreadMgr *This = (ThreadMgr *)iface;
171 FIXME("STUB:(%p)\n",This);
175 static HRESULT WINAPI ThreadMgr_IsThreadFocus( ITfThreadMgr* iface, BOOL *pfThreadFocus)
177 ThreadMgr *This = (ThreadMgr *)iface;
178 FIXME("STUB:(%p)\n",This);
182 static HRESULT WINAPI ThreadMgr_GetFunctionProvider( ITfThreadMgr* iface, REFCLSID clsid,
183 ITfFunctionProvider **ppFuncProv)
185 ThreadMgr *This = (ThreadMgr *)iface;
186 FIXME("STUB:(%p)\n",This);
190 static HRESULT WINAPI ThreadMgr_EnumFunctionProviders( ITfThreadMgr* iface,
191 IEnumTfFunctionProviders **ppEnum)
193 ThreadMgr *This = (ThreadMgr *)iface;
194 FIXME("STUB:(%p)\n",This);
198 static HRESULT WINAPI ThreadMgr_GetGlobalCompartment( ITfThreadMgr* iface,
199 ITfCompartmentMgr **ppCompMgr)
201 ThreadMgr *This = (ThreadMgr *)iface;
202 FIXME("STUB:(%p)\n",This);
206 static const ITfThreadMgrVtbl ThreadMgr_ThreadMgrVtbl =
208 ThreadMgr_QueryInterface,
212 ThreadMgr_fnActivate,
213 ThreadMgr_fnDeactivate,
214 ThreadMgr_CreateDocumentMgr,
215 ThreadMgr_EnumDocumentMgrs,
218 ThreadMgr_AssociateFocus,
219 ThreadMgr_IsThreadFocus,
220 ThreadMgr_GetFunctionProvider,
221 ThreadMgr_EnumFunctionProviders,
222 ThreadMgr_GetGlobalCompartment
225 HRESULT ThreadMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
229 return CLASS_E_NOAGGREGATION;
231 /* Only 1 ThreadMgr is created per thread */
232 This = TlsGetValue(tlsIndex);
235 ThreadMgr_AddRef((ITfThreadMgr*)This);
236 *ppOut = (IUnknown*)This;
240 This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ThreadMgr));
242 return E_OUTOFMEMORY;
244 This->ThreadMgrVtbl= &ThreadMgr_ThreadMgrVtbl;
246 TlsSetValue(tlsIndex,This);
248 TRACE("returning %p\n", This);
249 *ppOut = (IUnknown *)This;