gdiplus: Implemented GdipSetClipHrgn.
[wine] / dlls / msctf / threadmgr.c
1 /*
2  *  ITfThreadMgr implementation
3  *
4  *  Copyright 2008 Aric Stewart, CodeWeavers
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "config.h"
22
23 #include <stdarg.h>
24
25 #define COBJMACROS
26
27 #include "wine/debug.h"
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winreg.h"
31 #include "winuser.h"
32 #include "shlwapi.h"
33 #include "winerror.h"
34 #include "objbase.h"
35
36 #include "wine/unicode.h"
37
38 #include "msctf.h"
39 #include "msctf_internal.h"
40
41 WINE_DEFAULT_DEBUG_CHANNEL(msctf);
42
43 typedef struct tagACLMulti {
44     const ITfThreadMgrVtbl *ThreadMgrVtbl;
45     LONG refCount;
46 } ThreadMgr;
47
48 static void ThreadMgr_Destructor(ThreadMgr *This)
49 {
50     TRACE("destroying %p\n", This);
51     HeapFree(GetProcessHeap(),0,This);
52 }
53
54 static HRESULT WINAPI ThreadMgr_QueryInterface(ITfThreadMgr *iface, REFIID iid, LPVOID *ppvOut)
55 {
56     ThreadMgr *This = (ThreadMgr *)iface;
57     *ppvOut = NULL;
58
59     if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfThreadMgr))
60     {
61         *ppvOut = This;
62     }
63
64     if (*ppvOut)
65     {
66         IUnknown_AddRef(iface);
67         return S_OK;
68     }
69
70     WARN("unsupported interface: %s\n", debugstr_guid(iid));
71     return E_NOINTERFACE;
72 }
73
74 static ULONG WINAPI ThreadMgr_AddRef(ITfThreadMgr *iface)
75 {
76     ThreadMgr *This = (ThreadMgr *)iface;
77     return InterlockedIncrement(&This->refCount);
78 }
79
80 static ULONG WINAPI ThreadMgr_Release(ITfThreadMgr *iface)
81 {
82     ThreadMgr *This = (ThreadMgr *)iface;
83     ULONG ret;
84
85     ret = InterlockedDecrement(&This->refCount);
86     if (ret == 0)
87         ThreadMgr_Destructor(This);
88     return ret;
89 }
90
91 /*****************************************************
92  * ITfThreadMgr functions
93  *****************************************************/
94
95 static HRESULT WINAPI ThreadMgr_fnActivate( ITfThreadMgr* iface, TfClientId *ptid)
96 {
97     ThreadMgr *This = (ThreadMgr *)iface;
98     FIXME("STUB:(%p)\n",This);
99     return E_NOTIMPL;
100 }
101
102 static HRESULT WINAPI ThreadMgr_fnDeactivate( ITfThreadMgr* iface)
103 {
104     ThreadMgr *This = (ThreadMgr *)iface;
105     FIXME("STUB:(%p)\n",This);
106     return E_NOTIMPL;
107 }
108
109 static HRESULT WINAPI ThreadMgr_CreateDocumentMgr( ITfThreadMgr* iface, ITfDocumentMgr
110 **ppdim)
111 {
112     TRACE("(%p)\n",iface);
113     return DocumentMgr_Constructor(ppdim);
114 }
115
116 static HRESULT WINAPI ThreadMgr_EnumDocumentMgrs( ITfThreadMgr* iface, IEnumTfDocumentMgrs
117 **ppEnum)
118 {
119     ThreadMgr *This = (ThreadMgr *)iface;
120     FIXME("STUB:(%p)\n",This);
121     return E_NOTIMPL;
122 }
123
124 static HRESULT WINAPI ThreadMgr_GetFocus( ITfThreadMgr* iface, ITfDocumentMgr
125 **ppdimFocus)
126 {
127     ThreadMgr *This = (ThreadMgr *)iface;
128     FIXME("STUB:(%p)\n",This);
129     return E_NOTIMPL;
130 }
131
132 static HRESULT WINAPI ThreadMgr_SetFocus( ITfThreadMgr* iface, ITfDocumentMgr *pdimFocus)
133 {
134     ThreadMgr *This = (ThreadMgr *)iface;
135     FIXME("STUB:(%p)\n",This);
136     return E_NOTIMPL;
137 }
138
139 static HRESULT WINAPI ThreadMgr_AssociateFocus( ITfThreadMgr* iface, HWND hwnd,
140 ITfDocumentMgr *pdimNew, ITfDocumentMgr **ppdimPrev)
141 {
142     ThreadMgr *This = (ThreadMgr *)iface;
143     FIXME("STUB:(%p)\n",This);
144     return E_NOTIMPL;
145 }
146
147 static HRESULT WINAPI ThreadMgr_IsThreadFocus( ITfThreadMgr* iface, BOOL *pfThreadFocus)
148 {
149     ThreadMgr *This = (ThreadMgr *)iface;
150     FIXME("STUB:(%p)\n",This);
151     return E_NOTIMPL;
152 }
153
154 static HRESULT WINAPI ThreadMgr_GetFunctionProvider( ITfThreadMgr* iface, REFCLSID clsid,
155 ITfFunctionProvider **ppFuncProv)
156 {
157     ThreadMgr *This = (ThreadMgr *)iface;
158     FIXME("STUB:(%p)\n",This);
159     return E_NOTIMPL;
160 }
161
162 static HRESULT WINAPI ThreadMgr_EnumFunctionProviders( ITfThreadMgr* iface,
163 IEnumTfFunctionProviders **ppEnum)
164 {
165     ThreadMgr *This = (ThreadMgr *)iface;
166     FIXME("STUB:(%p)\n",This);
167     return E_NOTIMPL;
168 }
169
170 static HRESULT WINAPI ThreadMgr_GetGlobalCompartment( ITfThreadMgr* iface,
171 ITfCompartmentMgr **ppCompMgr)
172 {
173     ThreadMgr *This = (ThreadMgr *)iface;
174     FIXME("STUB:(%p)\n",This);
175     return E_NOTIMPL;
176 }
177
178 static const ITfThreadMgrVtbl ThreadMgr_ThreadMgrVtbl =
179 {
180     ThreadMgr_QueryInterface,
181     ThreadMgr_AddRef,
182     ThreadMgr_Release,
183
184     ThreadMgr_fnActivate,
185     ThreadMgr_fnDeactivate,
186     ThreadMgr_CreateDocumentMgr,
187     ThreadMgr_EnumDocumentMgrs,
188     ThreadMgr_GetFocus,
189     ThreadMgr_SetFocus,
190     ThreadMgr_AssociateFocus,
191     ThreadMgr_IsThreadFocus,
192     ThreadMgr_GetFunctionProvider,
193     ThreadMgr_EnumFunctionProviders,
194     ThreadMgr_GetGlobalCompartment
195 };
196
197 HRESULT ThreadMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
198 {
199     ThreadMgr *This;
200     if (pUnkOuter)
201         return CLASS_E_NOAGGREGATION;
202
203     This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ThreadMgr));
204     if (This == NULL)
205         return E_OUTOFMEMORY;
206
207     This->ThreadMgrVtbl= &ThreadMgr_ThreadMgrVtbl;
208     This->refCount = 1;
209
210     TRACE("returning %p\n", This);
211     *ppOut = (IUnknown *)This;
212     return S_OK;
213 }